From 45d67542e1a68ef2cfe1738ed7334ec725e02212 Mon Sep 17 00:00:00 2001 From: Daniel Sinclair <4412473+DanielSinclair@users.noreply.github.com> Date: Wed, 25 Sep 2024 23:17:07 -0400 Subject: [PATCH] adopt eip-1559 for hardware wallets (#1712) Co-authored-by: brdy <41711440+BrodyHughes@users.noreply.github.com> --- src/core/references/index.ts | 15 ++------------- src/entries/popup/handlers/ledger.ts | 11 ++--------- src/entries/popup/handlers/trezor.ts | 12 ++---------- 3 files changed, 6 insertions(+), 32 deletions(-) diff --git a/src/core/references/index.ts b/src/core/references/index.ts index 9df60444b0..1d2ae26e93 100644 --- a/src/core/references/index.ts +++ b/src/core/references/index.ts @@ -1,7 +1,5 @@ import { AddressZero } from '@ethersproject/constants'; -import { ChainId } from '~/core/types/chains'; - export { ethUnits } from './ethUnits'; export { supportedCurrencies } from './supportedCurrencies'; @@ -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'; @@ -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'; @@ -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, -]; diff --git a/src/entries/popup/handlers/ledger.ts b/src/entries/popup/handlers/ledger.ts index 87e860584f..eea1a521c8 100644 --- a/src/entries/popup/handlers/ledger.ts +++ b/src/entries/popup/handlers/ledger.ts @@ -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'; @@ -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; diff --git a/src/entries/popup/handlers/trezor.ts b/src/entries/popup/handlers/trezor.ts index 364b65cc92..a7e5238e09 100644 --- a/src/entries/popup/handlers/trezor.ts +++ b/src/entries/popup/handlers/trezor.ts @@ -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'; @@ -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 {