Skip to content

Commit

Permalink
deprecate force legacy, adopt eip 1559 for hwws
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielSinclair committed Sep 24, 2024
1 parent 5b0c758 commit ff20e70
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 32 deletions.
15 changes: 2 additions & 13 deletions src/core/references/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { AddressZero } from '@ethersproject/constants';

import { ChainId } from '~/core/types/chains';

export { ethUnits } from './ethUnits';
export { supportedCurrencies } from './supportedCurrencies';

Expand Down Expand Up @@ -50,8 +48,7 @@ export const ETH_ADDRESS = 'eth';
export const DAI_ADDRESS = '0x6b175474e89094c44da98b954eedeac495271d0f';
export const USDC_ADDRESS = '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48';
export const WBTC_ADDRESS = '0x2260fac5e5542a773aa44fbcfedf7c193bc2c599';
export const POL_MAINNET_ADDRESS =
'0x455e53CBB86018Ac2B8092FdCd39d8444aFFC3F6';
export const POL_MAINNET_ADDRESS = '0x455e53CBB86018Ac2B8092FdCd39d8444aFFC3F6';
export const BNB_MAINNET_ADDRESS = '0xb8c77482e45f1f44de1745f52c74426c631bdd52';
export const SOCKS_ADDRESS = '0x23b608675a2b2fb1890d3abbd85c5775c51691d5';
export const WETH_ADDRESS = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2';
Expand Down Expand Up @@ -84,8 +81,7 @@ export const DAI_BSC_ADDRESS = '0x6b175474e89094c44da98b954eedeac495271d0f';
export const USDC_BSC_ADDRESS = '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48';

// polygon
export const POL_POLYGON_ADDRESS =
'0x0000000000000000000000000000000000001010';
export const POL_POLYGON_ADDRESS = '0x0000000000000000000000000000000000001010';
export const WETH_POLYGON_ADDRESS =
'0x7ceb23fd6bc0add59e62ac25578270cff1b9f619';
export const DAI_POLYGON_ADDRESS = '0x8f3cf7ad23cd3cadbd9735aff958023239c6a063';
Expand Down Expand Up @@ -130,10 +126,3 @@ export const OVM_GAS_PRICE_ORACLE =
export type ReferrerType = 'browser-extension' | 'bx-claim';
export const REFERRER: ReferrerType = 'browser-extension';
export const REFERRER_CLAIM: ReferrerType = 'bx-claim';

export const LEGACY_CHAINS_FOR_HW = [
ChainId.optimism,
ChainId.arbitrum,
ChainId.zora,
ChainId.base,
];
11 changes: 2 additions & 9 deletions src/entries/popup/handlers/ledger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ import AppEth, { ledgerService } from '@ledgerhq/hw-app-eth';
import type Transport from '@ledgerhq/hw-transport';
import TransportWebHID from '@ledgerhq/hw-transport-webhid';
import { SignTypedDataVersion, TypedDataUtils } from '@metamask/eth-sig-util';
import { ChainId } from '@rainbow-me/swaps';
import { Address } from 'viem';

import { i18n } from '~/core/languages';
import { LEGACY_CHAINS_FOR_HW } from '~/core/references';
import { getProvider } from '~/core/wagmi/clientToProvider';
import { logger } from '~/logger';

Expand Down Expand Up @@ -56,15 +54,10 @@ export async function signTransactionFromLedger(
: undefined,
};

let forceLegacy = false;
// Ledger doesn't support type 2 for these networks yet
if (LEGACY_CHAINS_FOR_HW.includes(transaction.chainId as ChainId)) {
forceLegacy = true;
}

if (transaction.gasPrice) {
baseTx.gasPrice = transaction.gasPrice;
} else if (!forceLegacy) {
} else if (transaction.maxFeePerGas || transaction.maxPriorityFeePerGas) {
// eip-1559
baseTx.maxFeePerGas = transaction.maxFeePerGas || undefined;
baseTx.maxPriorityFeePerGas =
transaction.maxPriorityFeePerGas || undefined;
Expand Down
12 changes: 2 additions & 10 deletions src/entries/popup/handlers/trezor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ import {
serialize,
} from '@ethersproject/transactions';
import { SignTypedDataVersion, TypedDataUtils } from '@metamask/eth-sig-util';
import { ChainId } from '@rainbow-me/swaps';
import transformTypedDataPlugin from '@trezor/connect-plugin-ethereum';
import { Address } from 'viem';

import { LEGACY_CHAINS_FOR_HW } from '~/core/references';
import { addHexPrefix } from '~/core/utils/hex';
import { getProvider } from '~/core/wagmi/clientToProvider';
import { logger } from '~/logger';
Expand Down Expand Up @@ -51,16 +49,10 @@ export async function signTransactionFromTrezor(
: '0x0',
};

let forceLegacy = false;

// Trezor doesn't support type 2 for these networks yet
if (LEGACY_CHAINS_FOR_HW.includes(transaction.chainId as ChainId)) {
forceLegacy = true;
}

if (transaction.gasPrice) {
baseTx.gasPrice = transaction.gasPrice;
} else if (!forceLegacy) {
} else if (transaction.maxFeePerGas || transaction.maxPriorityFeePerGas) {
// eip-1559
baseTx.maxFeePerGas = transaction.maxFeePerGas;
baseTx.maxPriorityFeePerGas = transaction.maxPriorityFeePerGas;
} else {
Expand Down

0 comments on commit ff20e70

Please sign in to comment.