diff --git a/e2e/serial/swap/1_swapFlow1.test.ts b/e2e/serial/swap/1_swapFlow1.test.ts index ad28107fac..6d9da751d1 100644 --- a/e2e/serial/swap/1_swapFlow1.test.ts +++ b/e2e/serial/swap/1_swapFlow1.test.ts @@ -640,16 +640,16 @@ it('should be able to filter assets to buy by network', async () => { await typeOnTextInput({ id: 'token-to-buy-search-token-input', driver, - text: 'matic', + text: 'pol', }); await delayTime('long'); await findElementByTestIdAndClick({ - id: `${SWAP_VARIABLES.MATIC_POLYGON_ID}-favorites-token-to-buy-row`, + id: `${SWAP_VARIABLES.POL_POLYGON_ID}-favorites-token-to-buy-row`, driver, }); // ARBITRUM await findElementByTestIdAndClick({ - id: `${SWAP_VARIABLES.MATIC_POLYGON_ID}-token-to-buy-token-input-remove`, + id: `${SWAP_VARIABLES.POL_POLYGON_ID}-token-to-buy-token-input-remove`, driver, }); await findElementByTestIdAndClick({ diff --git a/e2e/walletVariables.ts b/e2e/walletVariables.ts index 9412fd5fac..f7f033e422 100644 --- a/e2e/walletVariables.ts +++ b/e2e/walletVariables.ts @@ -41,7 +41,7 @@ export const SWAP_VARIABLES = { ETH_MAINNET_ID: 'eth_1', ETH_OPTIMISM_ID: '0x0000000000000000000000000000000000000000_10', GMX_ARBITRUM_ID: '0xfc5a1a6eb076a2c7ad06ed22c90d7e710e35ad0a_42161', - MATIC_POLYGON_ID: '0x0000000000000000000000000000000000001010_137', + POL_POLYGON_ID: '0x0000000000000000000000000000000000001010_137', OP_OPTIMISM_ID: '0x4200000000000000000000000000000000000042_10', UNI_BNB_ID: '0xbf5140a22578168fd562dccf235e5d43a02ce9b1_56', USDC_ARBITRUM_ID: '0xaf88d065e77c8cc2239327c5edb3a432268e5831_42161', diff --git a/package.json b/package.json index 286cf43fb3..4d661c3b68 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "browser-extension", "license": "GPL-3.0-only", - "version": "1.5.38", + "version": "1.5.39", "scripts": { "//enable dev mode": "", "devmode:on": "sed -i'' -e 's/IS_DEV.*/IS_DEV=true/g' .env", @@ -277,7 +277,9 @@ "braces": "3.0.3", "ws": "8.17.1", "micromatch": "4.0.8", - "webpack": "5.94.0" + "webpack": "5.94.0", + "path-to-regexp": "6.3.0", + "dset": "3.1.4" }, "lavamoat": { "allowScripts": { diff --git a/src/core/references/index.ts b/src/core/references/index.ts index 79eab77b9a..0f2a42968f 100644 --- a/src/core/references/index.ts +++ b/src/core/references/index.ts @@ -50,8 +50,7 @@ export const ETH_ADDRESS = 'eth'; export const DAI_ADDRESS = '0x6b175474e89094c44da98b954eedeac495271d0f'; export const USDC_ADDRESS = '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'; export const WBTC_ADDRESS = '0x2260fac5e5542a773aa44fbcfedf7c193bc2c599'; -export const MATIC_MAINNET_ADDRESS = - '0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0'; +export const POL_MAINNET_ADDRESS = '0x455e53CBB86018Ac2B8092FdCd39d8444aFFC3F6'; export const BNB_MAINNET_ADDRESS = '0xb8c77482e45f1f44de1745f52c74426c631bdd52'; export const SOCKS_ADDRESS = '0x23b608675a2b2fb1890d3abbd85c5775c51691d5'; export const WETH_ADDRESS = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'; @@ -84,8 +83,7 @@ export const DAI_BSC_ADDRESS = '0x6b175474e89094c44da98b954eedeac495271d0f'; export const USDC_BSC_ADDRESS = '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'; // polygon -export const MATIC_POLYGON_ADDRESS = - '0x0000000000000000000000000000000000001010'; +export const POL_POLYGON_ADDRESS = '0x0000000000000000000000000000000000001010'; export const WETH_POLYGON_ADDRESS = '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619'; export const DAI_POLYGON_ADDRESS = '0x8f3cf7ad23cd3cadbd9735aff958023239c6a063'; diff --git a/src/core/resources/addys/addysSummary.ts b/src/core/resources/addys/addysSummary.ts index 09e0e64258..8660fa2c48 100644 --- a/src/core/resources/addys/addysSummary.ts +++ b/src/core/resources/addys/addysSummary.ts @@ -28,7 +28,7 @@ export interface AddySummary { [key: Address]: { summary: { native_balance_by_symbol: { - [key in 'ETH' | 'MATIC' | 'BNB' | 'AVAX']: { + [key in 'ETH' | 'POL' | 'BNB' | 'AVAX']: { symbol: string; quantity: string; decimals: number; diff --git a/src/core/state/favorites/index.ts b/src/core/state/favorites/index.ts index 29ecd3f7bc..dd3b84bf5d 100644 --- a/src/core/state/favorites/index.ts +++ b/src/core/state/favorites/index.ts @@ -17,8 +17,8 @@ import { ETH_BLAST_ADDRESS, ETH_OPTIMISM_ADDRESS, ETH_ZORA_ADDRESS, - MATIC_POLYGON_ADDRESS, OP_ADDRESS, + POL_POLYGON_ADDRESS, SOCKS_ADDRESS, SOCKS_ARBITRUM_ADDRESS, USDB_BLAST_ADDRESS, @@ -77,7 +77,7 @@ const defaultFavorites = { ], [ChainId.bsc]: [BNB_BSC_ADDRESS, DAI_BSC_ADDRESS, USDC_BSC_ADDRESS], [ChainId.polygon]: [ - MATIC_POLYGON_ADDRESS, + POL_POLYGON_ADDRESS, WETH_POLYGON_ADDRESS, DAI_POLYGON_ADDRESS, USDC_POLYGON_ADDRESS, diff --git a/src/core/types/transactions.ts b/src/core/types/transactions.ts index b3672d4127..2d5ca55de0 100644 --- a/src/core/types/transactions.ts +++ b/src/core/types/transactions.ts @@ -36,7 +36,7 @@ type BaseTransaction = { direction?: TransactionDirection; flashbots?: boolean; - value?: string; // network asset amount sent with the tx (like eth or matic) + value?: string; // network asset amount sent with the tx (like eth or pol) fee?: string; native?: { // fee and value but in the user prefered currency terms (USD, EUR, etc) diff --git a/src/core/utils/transactions.ts b/src/core/utils/transactions.ts index 79a52b4350..820eebf77a 100644 --- a/src/core/utils/transactions.ts +++ b/src/core/utils/transactions.ts @@ -222,7 +222,10 @@ const parseFees = ( const feeValue = FixedNumber.from( formatUnits(BigInt(fee.value) + rollupFee, nativeAssetDecimals), ); - const feePrice = FixedNumber.fromString(fee.price.toString()); + const feePrice = FixedNumber.fromString( + fee.price.toFixed(nativeAssetDecimals).toString(), + nativeAssetDecimals, + ); return { fee: feeValue.toString(), @@ -278,19 +281,23 @@ export function parseTransaction({ const description = getDescription(asset, type, meta); const nativeAsset = changes.find((change) => change?.asset.isNativeAsset); - const nativeAssetPrice = FixedNumber.fromString( - nativeAsset?.price?.toString() || '0', - ); const value = FixedNumber.fromValue( BigNumber.from(nativeAsset?.value || 0), nativeAsset?.asset.decimals || 0, ); - const valueInNative = value.mulUnsafe(nativeAssetPrice).toString(); - const nativeAssetDecimals = 18; // we only support networks with 18 decimals native assets rn, backend will change when we support more + const nativeAssetPrice = FixedNumber.fromString( + typeof nativeAsset?.price === 'number' + ? nativeAsset.price.toFixed(nativeAssetDecimals).toString() + : '0', + nativeAssetDecimals, + ); + + const valueInNative = value.mulUnsafe(nativeAssetPrice).toString(); + const { feeInNative, ...fee } = parseFees(tx.fee, nativeAssetDecimals); const native = { diff --git a/src/entries/popup/components/TransactionFee/TransactionFee.tsx b/src/entries/popup/components/TransactionFee/TransactionFee.tsx index c5b172162a..5bfc248721 100644 --- a/src/entries/popup/components/TransactionFee/TransactionFee.tsx +++ b/src/entries/popup/components/TransactionFee/TransactionFee.tsx @@ -45,6 +45,7 @@ import { SwitchTransactionSpeedMenu } from './TransactionSpeedsMenu'; type FeeProps = { chainId: ChainId; + disableShortcuts?: boolean; accentColor?: string; plainTriggerBorder?: boolean; selectedSpeed: GasSpeed; @@ -71,6 +72,7 @@ function Fee({ analyticsEvents, baseFeeTrend, chainId, + disableShortcuts, currentBaseFee, gasFeeParamsBySpeed, isLoading, @@ -130,22 +132,24 @@ function Fee({ useKeyboardShortcut({ handler: (e: KeyboardEvent) => { - if (e.key === shortcuts.global.OPEN_CUSTOM_GAS_MENU.key) { - if (chainId === ChainId.mainnet) { - trackShortcut({ - key: shortcuts.global.OPEN_CUSTOM_GAS_MENU.display, - type: 'customGasMenu.open', - }); - // hackery preventing GweiInputMask from firing an onChange event when opening the menu with KB - setTimeout(() => openCustomGasSheet(), 0); - } - } else if (e.key === shortcuts.global.OPEN_GAS_MENU.key) { - if (chainId === ChainId.mainnet || chainId === ChainId.polygon) { - trackShortcut({ - key: shortcuts.global.OPEN_GAS_MENU.display, - type: 'gasMenu.open', - }); - switchTransactionSpeedMenuRef?.current?.open(); + if (!disableShortcuts) { + if (e.key === shortcuts.global.OPEN_CUSTOM_GAS_MENU.key) { + if (chainId === ChainId.mainnet) { + trackShortcut({ + key: shortcuts.global.OPEN_CUSTOM_GAS_MENU.display, + type: 'customGasMenu.open', + }); + // hackery preventing GweiInputMask from firing an onChange event when opening the menu with KB + setTimeout(() => openCustomGasSheet(), 0); + } + } else if (e.key === shortcuts.global.OPEN_GAS_MENU.key) { + if (chainId === ChainId.mainnet || chainId === ChainId.polygon) { + trackShortcut({ + key: shortcuts.global.OPEN_GAS_MENU.display, + type: 'gasMenu.open', + }); + switchTransactionSpeedMenuRef?.current?.open(); + } } } }, @@ -256,6 +260,7 @@ function Fee({ type TransactionFeeProps = { chainId: ChainId; + disableShortcuts?: boolean; address?: Address; defaultSpeed?: GasSpeed; transactionRequest: TransactionRequest; @@ -271,6 +276,7 @@ type TransactionFeeProps = { export function TransactionFee({ chainId, + disableShortcuts, address, defaultSpeed, transactionRequest, @@ -302,6 +308,7 @@ export function TransactionFee({ return ( { - if (e.altKey) { - if (e.key === shortcuts.send.FOCUS_TO_ADDRESS.key) { - trackShortcut({ - key: shortcuts.send.FOCUS_TO_ADDRESS.display, - type: 'send.focusToAddress', - }); - toAddressInputRef?.current?.focus(); - sendTokenInputRef?.current?.blur(); - } - if (e.key === shortcuts.send.FOCUS_ASSET.key) { - trackShortcut({ - key: shortcuts.send.FOCUS_ASSET.display, - type: 'send.focusAsset', - }); - toAddressInputRef?.current?.blur(); - sendTokenInputRef.current?.focus(); - } - } else { - if (!toAddressInputRef.current?.isFocused?.()) { - if (e.key === shortcuts.send.SET_MAX_AMOUNT.key) { + if (!explainerSheetParams.show && !contactSaveAction.show) { + if (e.altKey) { + if (e.key === shortcuts.send.FOCUS_TO_ADDRESS.key) { trackShortcut({ - key: shortcuts.send.SET_MAX_AMOUNT.display, - type: 'send.setMax', + key: shortcuts.send.FOCUS_TO_ADDRESS.display, + type: 'send.focusToAddress', }); - setMaxAssetAmount(); + toAddressInputRef?.current?.focus(); + sendTokenInputRef?.current?.blur(); } - if (e.key === shortcuts.send.SWITCH_CURRENCY_LABEL.key) { + if (e.key === shortcuts.send.FOCUS_ASSET.key) { trackShortcut({ - key: shortcuts.send.SWITCH_CURRENCY_LABEL.display, - type: 'send.switchCurrency', + key: shortcuts.send.FOCUS_ASSET.display, + type: 'send.focusAsset', }); - switchIndependentField(); + toAddressInputRef?.current?.blur(); + sendTokenInputRef.current?.focus(); + } + } else { + if (!toAddressInputRef.current?.isFocused?.()) { + if (e.key === shortcuts.send.SET_MAX_AMOUNT.key) { + trackShortcut({ + key: shortcuts.send.SET_MAX_AMOUNT.display, + type: 'send.setMax', + }); + setMaxAssetAmount(); + } + if (e.key === shortcuts.send.SWITCH_CURRENCY_LABEL.key) { + trackShortcut({ + key: shortcuts.send.SWITCH_CURRENCY_LABEL.display, + type: 'send.switchCurrency', + }); + switchIndependentField(); + } + } + if ( + e.key === shortcuts.send.OPEN_CONTACT_MENU.key && + !valueInputRef.current?.isFocused?.() + ) { + trackShortcut({ + key: shortcuts.send.OPEN_CONTACT_MENU.display, + type: 'send.openContactMenu', + }); + clickHeaderRight(); } - } - if ( - e.key === shortcuts.send.OPEN_CONTACT_MENU.key && - !valueInputRef.current?.isFocused?.() - ) { - trackShortcut({ - key: shortcuts.send.OPEN_CONTACT_MENU.display, - type: 'send.openContactMenu', - }); - clickHeaderRight(); } } }, @@ -753,6 +755,7 @@ export function Send() {