From 1a86feafaaa7744ab518891618637ef32db3cb6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Leszczyk?= Date: Fri, 18 Oct 2024 09:04:54 +0200 Subject: [PATCH 01/16] feat: pchain dynamic fees" --- package.json | 30 +-- .../services/accounts/AccountsService.ts | 29 +- .../balances/handlers/getAvaxBalance.ts | 2 +- .../bridge/handlers/avalanche_bridgeAsset.ts | 4 +- .../services/network/NetworkService.ts | 36 ++- .../services/network/utils/getSyncDomain.ts | 2 +- .../network/utils/isAvalanchePchainNetwork.ts | 4 +- .../network/utils/isAvalancheXchainNetwork.ts | 4 +- .../services/networkFee/NetworkFeeService.ts | 2 +- .../services/secrets/SecretsService.ts | 29 +- .../services/seedless/SeedlessWallet.ts | 4 +- .../services/wallet/WalletService.ts | 2 +- .../handlers/avalanche_sendTransaction.ts | 10 +- .../handlers/avalanche_signTransaction.ts | 2 + src/background/utils/findToken.ts | 2 +- src/contexts/BridgeProvider.test.tsx | 2 +- src/contexts/BridgeProvider.tsx | 12 +- src/contexts/NetworkProvider.tsx | 88 ++++-- src/contexts/SwapProvider/SwapProvider.tsx | 10 +- src/contexts/UnifiedBridgeProvider.tsx | 20 +- src/hooks/useApproveAction.ts | 2 +- src/pages/ApproveAction/AvalancheSignTx.tsx | 1 - .../components/ApproveBaseTx.tsx | 9 +- .../components/ApproveExportTx.tsx | 18 +- .../components/ApproveImportTx.tsx | 18 +- .../ApproveAction/components/AvaxAmount.tsx | 15 +- src/pages/Collectibles/CollectibleSend.tsx | 25 +- src/pages/Send/Send.tsx | 30 ++- src/pages/Send/hooks/useSend/usePVMSend.ts | 7 +- src/pages/Send/utils/getMaxUtxos.ts | 1 + src/utils/caipConversion.ts | 3 +- src/utils/environment.ts | 2 + src/utils/network/getProviderForNetwork.ts | 19 +- webpack.alpha.js | 5 +- yarn.lock | 252 +++++++++++------- 35 files changed, 462 insertions(+), 239 deletions(-) diff --git a/package.json b/package.json index 4fa3ba4d6..c98129d83 100644 --- a/package.json +++ b/package.json @@ -23,25 +23,25 @@ "sentry": "node sentryscript.js" }, "dependencies": { - "@avalabs/avalanche-module": "0.11.2", + "@avalabs/avalanche-module": "0.0.0-feat-p-dynamic-fees-20241029181751", "@avalabs/avalanchejs": "4.1.0-alpha.7", - "@avalabs/bitcoin-module": "0.11.2", + "@avalabs/bitcoin-module": "0.0.0-feat-p-dynamic-fees-20241029181751", "@avalabs/bridge-unified": "0.0.0-feat-ictt-configs-20241009072139", - "@avalabs/core-bridge-sdk": "3.1.0-alpha.10", - "@avalabs/core-chains-sdk": "3.1.0-alpha.10", - "@avalabs/core-coingecko-sdk": "3.1.0-alpha.10", - "@avalabs/core-covalent-sdk": "3.1.0-alpha.10", - "@avalabs/core-etherscan-sdk": "3.1.0-alpha.10", + "@avalabs/core-bridge-sdk": "3.1.0-canary.d8363d2.0+d8363d2", + "@avalabs/core-chains-sdk": "3.1.0-canary.d8363d2.0+d8363d2", + "@avalabs/core-coingecko-sdk": "3.1.0-canary.d8363d2.0+d8363d2", + "@avalabs/core-covalent-sdk": "3.1.0-canary.d8363d2.0+d8363d2", + "@avalabs/core-etherscan-sdk": "3.1.0-canary.d8363d2.0+d8363d2", "@avalabs/core-k2-components": "4.18.0-alpha.47", - "@avalabs/core-snowtrace-sdk": "3.1.0-alpha.10", - "@avalabs/core-token-prices-sdk": "3.1.0-alpha.10", - "@avalabs/core-utils-sdk": "3.1.0-alpha.10", - "@avalabs/core-wallets-sdk": "3.1.0-alpha.10", - "@avalabs/evm-module": "0.11.2", - "@avalabs/glacier-sdk": "3.1.0-alpha.10", + "@avalabs/core-snowtrace-sdk": "3.1.0-canary.d8363d2.0+d8363d2", + "@avalabs/core-token-prices-sdk": "3.1.0-canary.d8363d2.0+d8363d2", + "@avalabs/core-utils-sdk": "3.1.0-canary.d8363d2.0+d8363d2", + "@avalabs/core-wallets-sdk": "3.1.0-canary.d8363d2.0+d8363d2", + "@avalabs/evm-module": "0.0.0-feat-p-dynamic-fees-20241029181751", + "@avalabs/glacier-sdk": "3.1.0-canary.d8363d2.0+d8363d2", "@avalabs/hw-app-avalanche": "0.14.1", - "@avalabs/types": "3.1.0-alpha.10", - "@avalabs/vm-module-types": "0.11.2", + "@avalabs/types": "3.1.0-canary.d8363d2.0+d8363d2", + "@avalabs/vm-module-types": "0.0.0-feat-p-dynamic-fees-20241029181751", "@blockaid/client": "0.10.0", "@coinbase/cbpay-js": "1.6.0", "@cubist-labs/cubesigner-sdk": "0.3.28", diff --git a/src/background/services/accounts/AccountsService.ts b/src/background/services/accounts/AccountsService.ts index d6264d9c0..eac7f29c3 100644 --- a/src/background/services/accounts/AccountsService.ts +++ b/src/background/services/accounts/AccountsService.ts @@ -26,6 +26,7 @@ import getAllAddressesForAccount from '@src/utils/getAllAddressesForAccount'; import { SecretsService } from '../secrets/SecretsService'; import { LedgerService } from '../ledger/LedgerService'; import { WalletConnectService } from '../walletConnect/WalletConnectService'; +import { Network } from '../network/models'; type AddAccountParams = { walletId: string; @@ -98,8 +99,24 @@ export class AccountsService implements OnLock, OnUnlock { // refresh addresses so in case the user switches to testnet mode, // as the BTC address needs to be updated this.networkService.developerModeChanged.add(this.onDeveloperModeChanged); + this.networkService.uiActiveNetworkChanged.add( + this.#onActiveNetworkChanged + ); } + #wasDevnet = false; + + #onActiveNetworkChanged = async (network?: Network) => { + if (!network) { + return; + } + + if (Boolean(network.isDevnet) !== this.#wasDevnet) { + this.#wasDevnet = Boolean(network?.isDevnet || network.chainId === 43117); + await this.onDeveloperModeChanged(network?.isTestnet); + } + }; + onLock() { this.accounts = { active: undefined, @@ -110,6 +127,9 @@ export class AccountsService implements OnLock, OnUnlock { this.networkService.developerModeChanged.remove( this.onDeveloperModeChanged ); + this.networkService.uiActiveNetworkChanged.remove( + this.#onActiveNetworkChanged + ); } private onDeveloperModeChanged = async (isTestnet?: boolean) => { @@ -201,8 +221,10 @@ export class AccountsService implements OnLock, OnUnlock { async getAddressesForAccount(account: Account): Promise { if (account.type !== AccountType.PRIMARY) { - const isMainnet = this.networkService.isMainnet(); - return this.secretsService.getImportedAddresses(account.id, isMainnet); + return this.secretsService.getImportedAddresses( + account.id, + this.networkService + ); } const addresses = await this.secretsService.getAddresses( @@ -385,10 +407,9 @@ export class AccountsService implements OnLock, OnUnlock { name?: string; }) { try { - const isMainnet = this.networkService.isMainnet(); const { account, commit } = await this.secretsService.addImportedWallet( options, - isMainnet + this.networkService ); const existingAccount = this.#findAccountByAddress(account.addressC); diff --git a/src/background/services/balances/handlers/getAvaxBalance.ts b/src/background/services/balances/handlers/getAvaxBalance.ts index e4b73b7d7..d49bddf00 100644 --- a/src/background/services/balances/handlers/getAvaxBalance.ts +++ b/src/background/services/balances/handlers/getAvaxBalance.ts @@ -27,7 +27,7 @@ export class GetAvaxBalanceHandler implements HandlerType { const params = request.params || []; const [address] = params; const avalancheNetwork = await this.networkService.getAvalancheNetwork(); - const provider = getProviderForNetwork(avalancheNetwork); + const provider = await getProviderForNetwork(avalancheNetwork); if ( provider instanceof BitcoinProvider || provider instanceof Avalanche.JsonRpcProvider diff --git a/src/background/services/bridge/handlers/avalanche_bridgeAsset.ts b/src/background/services/bridge/handlers/avalanche_bridgeAsset.ts index 0f63417e3..c3fe56139 100644 --- a/src/background/services/bridge/handlers/avalanche_bridgeAsset.ts +++ b/src/background/services/bridge/handlers/avalanche_bridgeAsset.ts @@ -426,9 +426,9 @@ export class AvalancheBridgeAsset extends DAppRequestHandler signAndSendEVM: async (txData) => { const tx = txData as ContractTransaction; // TODO: update types in the SDK? - const provider = getProviderForNetwork( + const provider = (await getProviderForNetwork( network - ) as JsonRpcBatchInternal; + )) as JsonRpcBatchInternal; const nonce = await provider.getTransactionCount( this.#getSourceAccount().addressC diff --git a/src/background/services/network/NetworkService.ts b/src/background/services/network/NetworkService.ts index f3f4aa29e..a0780a704 100644 --- a/src/background/services/network/NetworkService.ts +++ b/src/background/services/network/NetworkService.ts @@ -18,8 +18,10 @@ import { NetworkWithCaipId, } from './models'; import { + AVALANCHE_P_DEV_NETWORK, AVALANCHE_XP_NETWORK, AVALANCHE_XP_TEST_NETWORK, + AVALANCHE_X_DEV_NETWORK, BITCOIN_NETWORK, BITCOIN_TEST_NETWORK, ChainId, @@ -375,6 +377,13 @@ export class NetworkService implements OnLock, OnStorageReady { return networkList; } + private _getPchainDevnet(): Network { + return decorateWithCaipId(AVALANCHE_P_DEV_NETWORK); + } + + private _getXchainDevnet(): Network { + return decorateWithCaipId(AVALANCHE_X_DEV_NETWORK); + } private _getPchainNetwork(isTestnet: boolean): Network { const network = isTestnet @@ -394,7 +403,7 @@ export class NetworkService implements OnLock, OnStorageReady { 'https://images.ctfassets.net/gcj8jwzm6086/5VHupNKwnDYJvqMENeV7iJ/3e4b8ff10b69bfa31e70080a4b142cd0/avalanche-avax-logo.svg', // from contentful }, explorerUrl: isTestnet - ? 'https://subnets-test.avax.network/p-chain' + ? 'https://495e3bcd.subnets.pages.dev/p-chain' : 'https://subnets.avax.network/p-chain', }); } @@ -403,6 +412,7 @@ export class NetworkService implements OnLock, OnStorageReady { const network = isTestnet ? AVALANCHE_XP_TEST_NETWORK : AVALANCHE_XP_NETWORK; + return decorateWithCaipId({ ...network, chainId: isTestnet ? ChainId.AVALANCHE_TEST_X : ChainId.AVALANCHE_X, @@ -417,7 +427,7 @@ export class NetworkService implements OnLock, OnStorageReady { 'https://images.ctfassets.net/gcj8jwzm6086/5VHupNKwnDYJvqMENeV7iJ/3e4b8ff10b69bfa31e70080a4b142cd0/avalanche-avax-logo.svg', // from contentful }, explorerUrl: isTestnet - ? 'https://subnets-test.avax.network/x-chain' + ? 'https://495e3bcd.subnets.pages.dev/x-chain' : 'https://subnets.avax.network/x-chain', }); } @@ -443,6 +453,8 @@ export class NetworkService implements OnLock, OnStorageReady { [ChainId.AVALANCHE_P]: this._getPchainNetwork(false), [ChainId.AVALANCHE_TEST_X]: this._getXchainNetwork(true), [ChainId.AVALANCHE_X]: this._getXchainNetwork(false), + [ChainId.AVALANCHE_DEVNET_P]: this._getPchainDevnet(), + [ChainId.AVALANCHE_DEVNET_X]: this._getXchainDevnet(), }; } else { attempt += 1; @@ -479,7 +491,11 @@ export class NetworkService implements OnLock, OnStorageReady { * Returns the network object for Avalanche X/P Chains */ getAvalancheNetworkXP() { - return this._getXchainNetwork(!this.isMainnet()); + const isDevnetActive = + this.uiActiveNetwork?.isDevnet || this.uiActiveNetwork?.chainId === 43117; + return isDevnetActive + ? this._getXchainDevnet() + : this._getXchainNetwork(!this.isMainnet()); } async getAvalancheNetwork() { @@ -498,16 +514,16 @@ export class NetworkService implements OnLock, OnStorageReady { */ async getAvalancheProvider(): Promise { const network = await this.getAvalancheNetwork(); - return getProviderForNetwork(network) as JsonRpcBatchInternal; + return (await getProviderForNetwork(network)) as JsonRpcBatchInternal; } /** * Returns the provider used by Avalanche X/P/CoreEth chains. */ - getAvalanceProviderXP(): Avalanche.JsonRpcProvider { - return getProviderForNetwork( + async getAvalanceProviderXP(): Promise { + return (await getProviderForNetwork( this.getAvalancheNetworkXP() - ) as Avalanche.JsonRpcProvider; + )) as Avalanche.JsonRpcProvider; } async getEthereumNetwork(): Promise { @@ -521,7 +537,7 @@ export class NetworkService implements OnLock, OnStorageReady { async getEthereumProvider() { const network = await this.getEthereumNetwork(); - return getProviderForNetwork(network) as JsonRpcBatchInternal; + return (await getProviderForNetwork(network)) as JsonRpcBatchInternal; } async getBitcoinNetwork(): Promise { @@ -535,7 +551,7 @@ export class NetworkService implements OnLock, OnStorageReady { async getBitcoinProvider(): Promise { const network = await this.getBitcoinNetwork(); - return getProviderForNetwork(network) as BitcoinProvider; + return (await getProviderForNetwork(network)) as BitcoinProvider; } /** @@ -553,7 +569,7 @@ export class NetworkService implements OnLock, OnStorageReady { return txHash; } - const provider = getProviderForNetwork(network); + const provider = await getProviderForNetwork(network); if (provider instanceof JsonRpcBatchInternal) { return (await provider.broadcastTransaction(signedTx)).hash; } diff --git a/src/background/services/network/utils/getSyncDomain.ts b/src/background/services/network/utils/getSyncDomain.ts index e63b72a23..5695e0482 100644 --- a/src/background/services/network/utils/getSyncDomain.ts +++ b/src/background/services/network/utils/getSyncDomain.ts @@ -6,7 +6,7 @@ const SYNCED_DOMAINS = [ 'test.core.app', runtime.id, // Helpful for Core Web devs: - 'localhost', + // 'localhost', '127.0.0.1', ]; diff --git a/src/background/services/network/utils/isAvalanchePchainNetwork.ts b/src/background/services/network/utils/isAvalanchePchainNetwork.ts index db405e347..ea75b8ed2 100644 --- a/src/background/services/network/utils/isAvalanchePchainNetwork.ts +++ b/src/background/services/network/utils/isAvalanchePchainNetwork.ts @@ -9,6 +9,8 @@ export function isPchainNetwork(network?: Network) { export function isPchainNetworkId(chainId: number) { return ( - ChainId.AVALANCHE_P === chainId || ChainId.AVALANCHE_TEST_P === chainId + ChainId.AVALANCHE_P === chainId || + ChainId.AVALANCHE_TEST_P === chainId || + ChainId.AVALANCHE_DEVNET_P === chainId ); } diff --git a/src/background/services/network/utils/isAvalancheXchainNetwork.ts b/src/background/services/network/utils/isAvalancheXchainNetwork.ts index 34e8de206..e437b0274 100644 --- a/src/background/services/network/utils/isAvalancheXchainNetwork.ts +++ b/src/background/services/network/utils/isAvalancheXchainNetwork.ts @@ -10,6 +10,8 @@ export function isXchainNetwork(network?: Network) { //TODO: Fix this once we figure out how to separate between x and p chain ID export function isXchainNetworkId(chainId: number) { return ( - ChainId.AVALANCHE_X === chainId || ChainId.AVALANCHE_TEST_X === chainId + ChainId.AVALANCHE_X === chainId || + ChainId.AVALANCHE_TEST_X === chainId || + ChainId.AVALANCHE_DEVNET_X === chainId ); } diff --git a/src/background/services/networkFee/NetworkFeeService.ts b/src/background/services/networkFee/NetworkFeeService.ts index caaccde98..03a2ae005 100644 --- a/src/background/services/networkFee/NetworkFeeService.ts +++ b/src/background/services/networkFee/NetworkFeeService.ts @@ -32,7 +32,7 @@ export class NetworkFeeService { return null; } - const provider = getProviderForNetwork(network); + const provider = await getProviderForNetwork(network); const nonce = await (provider as JsonRpcBatchInternal).getTransactionCount( from ); diff --git a/src/background/services/secrets/SecretsService.ts b/src/background/services/secrets/SecretsService.ts index 26fb68e8f..e43fce557 100644 --- a/src/background/services/secrets/SecretsService.ts +++ b/src/background/services/secrets/SecretsService.ts @@ -554,7 +554,10 @@ export class SecretsService implements OnUnlock { return walletSecrets?.secretType; } - async addImportedWallet(importData: ImportData, isMainnet: boolean) { + async addImportedWallet( + importData: ImportData, + networkService: NetworkService + ) { const id = crypto.randomUUID(); // let the AccountService validate the account's uniqueness and save the secret using this callback @@ -596,10 +599,14 @@ export class SecretsService implements OnUnlock { } if (importData.importType === ImportType.PRIVATE_KEY) { + const addresses = await this.#calculateAddressesForPrivateKey( + importData.data, + networkService + ); return { account: { id, - ...this.#calculateAddressesForPrivateKey(importData.data, isMainnet), + ...addresses, }, commit, }; @@ -608,7 +615,10 @@ export class SecretsService implements OnUnlock { throw new Error('Unknown import type'); } - #calculateAddressesForPrivateKey(privateKey: string, isMainnet: boolean) { + async #calculateAddressesForPrivateKey( + privateKey: string, + networkService: NetworkService + ) { const addresses = { addressBTC: '', addressC: '', @@ -617,16 +627,14 @@ export class SecretsService implements OnUnlock { addressCoreEth: '', }; - const provXP = isMainnet - ? Avalanche.JsonRpcProvider.getDefaultMainnetProvider() - : Avalanche.JsonRpcProvider.getDefaultFujiProvider(); + const provXP = await networkService.getAvalanceProviderXP(); try { const publicKey = getPublicKeyFromPrivateKey(privateKey); addresses.addressC = getEvmAddressFromPubKey(publicKey); addresses.addressBTC = getBtcAddressFromPubKey( publicKey, - isMainnet ? networks.bitcoin : networks.testnet + networkService.isMainnet() ? networks.bitcoin : networks.testnet ); addresses.addressAVM = provXP.getAddress(publicKey, 'X'); addresses.addressPVM = provXP.getAddress(publicKey, 'P'); @@ -819,7 +827,7 @@ export class SecretsService implements OnUnlock { throw new Error('No public key available'); } - async getImportedAddresses(id: string, isMainnet: boolean) { + async getImportedAddresses(id: string, networkService: NetworkService) { const secrets = await this.getImportedAccountSecrets(id); if ( @@ -830,7 +838,10 @@ export class SecretsService implements OnUnlock { } if (secrets.secretType === SecretType.PrivateKey) { - return this.#calculateAddressesForPrivateKey(secrets.secret, isMainnet); + return this.#calculateAddressesForPrivateKey( + secrets.secret, + networkService + ); } throw new Error('Unsupported import type'); diff --git a/src/background/services/seedless/SeedlessWallet.ts b/src/background/services/seedless/SeedlessWallet.ts index 29d91f353..787e801a7 100644 --- a/src/background/services/seedless/SeedlessWallet.ts +++ b/src/background/services/seedless/SeedlessWallet.ts @@ -366,7 +366,7 @@ export class SeedlessWallet { throw new Error('Unknown network'); } - const provider = getProviderForNetwork(this.#network); + const provider = await getProviderForNetwork(this.#network); if (!(provider instanceof JsonRpcApiProvider)) { throw new Error('Wrong provider obtained for EVM transaction'); } @@ -427,7 +427,7 @@ export class SeedlessWallet { ); } - const provider = getProviderForNetwork(this.#network); + const provider = await getProviderForNetwork(this.#network); if (!(provider instanceof BitcoinProvider)) { throw new Error('Wrong provider obtained for BTC transaction'); diff --git a/src/background/services/wallet/WalletService.ts b/src/background/services/wallet/WalletService.ts index 4a6239a96..86a7d5bf1 100644 --- a/src/background/services/wallet/WalletService.ts +++ b/src/background/services/wallet/WalletService.ts @@ -166,7 +166,7 @@ export class WalletService implements OnUnlock { return; } - const provider = getProviderForNetwork(network); + const provider = await getProviderForNetwork(network); const { secretType } = secrets; // Seedless wallet uses a universal signer class (one for all tx types) diff --git a/src/background/services/wallet/handlers/avalanche_sendTransaction.ts b/src/background/services/wallet/handlers/avalanche_sendTransaction.ts index 55ed4d1c9..2f62915d1 100644 --- a/src/background/services/wallet/handlers/avalanche_sendTransaction.ts +++ b/src/background/services/wallet/handlers/avalanche_sendTransaction.ts @@ -33,6 +33,7 @@ type TxParams = { externalIndices?: number[]; internalIndices?: number[]; utxos?: string[]; + feeTolerance?: number; }; @injectable() @@ -63,6 +64,7 @@ export class AvalancheSendTransactionHandler extends DAppRequestHandler< externalIndices, internalIndices, utxos: providedUtxoHexes, + feeTolerance, } = (request.params ?? {}) as TxParams; if (!transactionHex || !chainAlias) { @@ -73,7 +75,7 @@ export class AvalancheSendTransactionHandler extends DAppRequestHandler< }), }; } - + const network = await this.networkService.getAvalancheNetworkXP(); const vm = Avalanche.getVmByChainAlias(chainAlias); const txBytes = utils.hexToBuffer(transactionHex); const provider = await this.networkService.getAvalanceProviderXP(); @@ -100,6 +102,7 @@ export class AvalancheSendTransactionHandler extends DAppRequestHandler< : await Avalanche.getUtxosByTxFromGlacier({ transactionHex, chainAlias, + isDevnet: network.isDevnet || network.chainId === 43117, // FIXME: just a temporary condition isTestnet: !this.networkService.isMainnet(), url: process.env.GLACIER_URL as string, token: process.env.GLACIER_API_KEY, @@ -151,7 +154,10 @@ export class AvalancheSendTransactionHandler extends DAppRequestHandler< const txData = await Avalanche.parseAvalancheTx( unsignedTx, provider, - currentAddress + currentAddress, + { + feeTolerance, + } ); if (txData.type === 'unknown') { diff --git a/src/background/services/wallet/handlers/avalanche_signTransaction.ts b/src/background/services/wallet/handlers/avalanche_signTransaction.ts index 92a77f1bd..5f217d572 100644 --- a/src/background/services/wallet/handlers/avalanche_signTransaction.ts +++ b/src/background/services/wallet/handlers/avalanche_signTransaction.ts @@ -80,6 +80,7 @@ export class AvalancheSignTransactionHandler extends DAppRequestHandler { jest.mocked(useNetworkContext).mockReturnValue({ ...networkContext, ethereumProvider: undefined, - avalancheProvider: undefined, + avalancheProviderC: undefined, }); }); diff --git a/src/contexts/BridgeProvider.tsx b/src/contexts/BridgeProvider.tsx index 6b0cef01f..7c6be630e 100644 --- a/src/contexts/BridgeProvider.tsx +++ b/src/contexts/BridgeProvider.tsx @@ -79,7 +79,7 @@ function InnerBridgeProvider({ children }: { children: any }) { const { t } = useTranslation(); const { request, events } = useConnectionContext(); const { currentBlockchain, bridgeConfig } = useBridgeSDK(); - const { network, avalancheProvider, ethereumProvider } = useNetworkContext(); + const { network, avaxProviderC, ethereumProvider } = useNetworkContext(); const { accounts: { active }, } = useAccountsContext(); @@ -165,7 +165,7 @@ function InnerBridgeProvider({ children }: { children: any }) { !isEvmSourceChain || !active?.addressC || !ethereumProvider || - !avalancheProvider || + !avaxProviderC || !bridgeConfig.config ) { return; @@ -177,7 +177,7 @@ function InnerBridgeProvider({ children }: { children: any }) { asset as Exclude, { ethereum: ethereumProvider, - avalanche: avalancheProvider, + avalanche: avaxProviderC, }, bridgeConfig.config, currentBlockchain @@ -186,7 +186,7 @@ function InnerBridgeProvider({ children }: { children: any }) { [ currentBlockchain, active?.addressC, - avalancheProvider, + avaxProviderC, ethereumProvider, bridgeConfig.config, ] @@ -209,7 +209,7 @@ function InnerBridgeProvider({ children }: { children: any }) { amount, account: active?.addressC as string, asset, - avalancheProvider: avalancheProvider!, + avalancheProvider: avaxProviderC!, ethereumProvider: ethereumProvider!, config: bridgeConfig.config!, onStatusChange: (status) => { @@ -269,7 +269,7 @@ function InnerBridgeProvider({ children }: { children: any }) { }, [ active?.addressC, - avalancheProvider, + avaxProviderC, bridgeConfig.config, currentBlockchain, ethereumProvider, diff --git a/src/contexts/NetworkProvider.tsx b/src/contexts/NetworkProvider.tsx index bdf06bbc3..2bdef8650 100644 --- a/src/contexts/NetworkProvider.tsx +++ b/src/contexts/NetworkProvider.tsx @@ -1,4 +1,6 @@ import { + Dispatch, + SetStateAction, createContext, useCallback, useContext, @@ -20,6 +22,7 @@ import { SaveCustomNetworkHandler } from '@src/background/services/network/handl import { AddFavoriteNetworkHandler } from '@src/background/services/network/handlers/addFavoriteNetwork'; import { UpdateDefaultNetworkHandler } from '@src/background/services/network/handlers/updateDefaultNetwork'; import { + Avalanche, BitcoinProvider, JsonRpcBatchInternal, } from '@avalabs/core-wallets-sdk'; @@ -53,7 +56,8 @@ const NetworkContext = createContext<{ isCustomNetwork(chainId: number): boolean; isChainIdExist(chainId: number): boolean; getNetwork(chainId: number | string): NetworkWithCaipId | undefined; - avalancheProvider?: JsonRpcBatchInternal; + avaxProviderC?: JsonRpcBatchInternal; + avaxProviderP?: Avalanche.JsonRpcProvider; ethereumProvider?: JsonRpcBatchInternal; bitcoinProvider?: BitcoinProvider; }>({} as any); @@ -113,45 +117,74 @@ export function NetworkContextProvider({ children }: { children: any }) { [networks] ); - const avalancheProvider = useMemo(() => { - const avaxNetwork = getNetwork( - network?.isTestnet - ? ChainId.AVALANCHE_TESTNET_ID - : ChainId.AVALANCHE_MAINNET_ID - ); + const [bitcoinProvider, setBitcoinProvider] = useState(); + const [ethereumProvider, setEthereumProvider] = + useState(); + const [avaxProviderC, setAvaxProviderC] = useState(); + const [avaxProviderP, setAvaxProviderP] = + useState(); - if (!avaxNetwork) { + useEffect(() => { + if (!network) { + setBitcoinProvider(undefined); + setEthereumProvider(undefined); + setAvaxProviderC(undefined); + setAvaxProviderP(undefined); return; } - return getProviderForNetwork(avaxNetwork) as JsonRpcBatchInternal; - }, [network?.isTestnet, getNetwork]); + let isMounted = true; - const ethereumProvider = useMemo(() => { + const avaxNetworkC = getNetwork( + network.isTestnet + ? ChainId.AVALANCHE_TESTNET_ID + : ChainId.AVALANCHE_MAINNET_ID + ); + const avaxNetworkP = getNetwork( + network.isTestnet ? ChainId.AVALANCHE_TEST_P : ChainId.AVALANCHE_P + ); const ethNetwork = getNetwork( - network?.isTestnet + network.isTestnet ? ChainId.ETHEREUM_TEST_SEPOLIA : ChainId.ETHEREUM_HOMESTEAD ); - - if (!ethNetwork) { - return; - } - - return getProviderForNetwork(ethNetwork) as JsonRpcBatchInternal; - }, [network?.isTestnet, getNetwork]); - - const bitcoinProvider = useMemo(() => { const btcNetwork = getNetwork( - network?.isTestnet ? ChainId.BITCOIN_TESTNET : ChainId.BITCOIN + network.isTestnet ? ChainId.BITCOIN_TESTNET : ChainId.BITCOIN ); - if (!btcNetwork) { - return; + function updateIfMounted(setter: Dispatch>) { + return (p) => { + if (isMounted) { + setter(p); + } + }; } - return getProviderForNetwork(btcNetwork) as BitcoinProvider; - }, [network?.isTestnet, getNetwork]); + if (avaxNetworkC) { + getProviderForNetwork(avaxNetworkC).then( + updateIfMounted(setAvaxProviderC) + ); + } + if (avaxNetworkP) { + getProviderForNetwork(avaxNetworkP).then( + updateIfMounted(setAvaxProviderP) + ); + } + if (ethNetwork) { + getProviderForNetwork(ethNetwork).then( + updateIfMounted(setEthereumProvider) + ); + } + if (btcNetwork) { + getProviderForNetwork(btcNetwork).then( + updateIfMounted(setBitcoinProvider) + ); + } + + return () => { + isMounted = false; + }; + }, [getNetwork, network]); const getNetworkState = useCallback(() => { return request({ @@ -278,7 +311,8 @@ export function NetworkContextProvider({ children }: { children: any }) { isCustomNetwork, isChainIdExist, getNetwork, - avalancheProvider, + avaxProviderC, + avaxProviderP, bitcoinProvider, ethereumProvider, }} diff --git a/src/contexts/SwapProvider/SwapProvider.tsx b/src/contexts/SwapProvider/SwapProvider.tsx index 0f176f40a..2d371dcf9 100644 --- a/src/contexts/SwapProvider/SwapProvider.tsx +++ b/src/contexts/SwapProvider/SwapProvider.tsx @@ -42,7 +42,7 @@ export const SwapContext = createContext({} as any); export function SwapContextProvider({ children }: { children: any }) { const { request } = useConnectionContext(); - const { network: activeNetwork, avalancheProvider } = useNetworkContext(); + const { network: activeNetwork, avaxProviderC } = useNetworkContext(); const { accounts: { active: activeAccount }, } = useAccountsContext(); @@ -296,7 +296,7 @@ export function SwapContextProvider({ children }: { children: any }) { throw new Error('Account address missing'); } - if (!avalancheProvider) { + if (!avaxProviderC) { throw new Error('RPC provider is not available'); } @@ -330,7 +330,7 @@ export function SwapContextProvider({ children }: { children: any }) { const contract = new ethers.Contract( srcTokenAddress, ERC20.abi, - avalancheProvider + avaxProviderC ); if (!contract.allowance) { @@ -447,7 +447,7 @@ export function SwapContextProvider({ children }: { children: any }) { throwError(signError); } - avalancheProvider.waitForTransaction(swapTxHash).then(async (tx) => { + avaxProviderC.waitForTransaction(swapTxHash).then(async (tx) => { const isSuccessful = tx && tx.status === 1; captureEncrypted(isSuccessful ? 'SwapSuccessful' : 'SwapFailed', { @@ -502,7 +502,7 @@ export function SwapContextProvider({ children }: { children: any }) { [ activeAccount?.addressC, activeNetwork, - avalancheProvider, + avaxProviderC, buildTx, captureEncrypted, getParaswapSpender, diff --git a/src/contexts/UnifiedBridgeProvider.tsx b/src/contexts/UnifiedBridgeProvider.tsx index 27112e659..a9f7cb9fb 100644 --- a/src/contexts/UnifiedBridgeProvider.tsx +++ b/src/contexts/UnifiedBridgeProvider.tsx @@ -299,15 +299,15 @@ export function UnifiedBridgeProvider({ ); const buildParams = useCallback( - ( + async ( targetChainId: string - ): { + ): Promise<{ sourceChain: Chain; sourceChainId: string; targetChain: Chain; provider: JsonRpcApiProvider; fromAddress: `0x${string}`; - } => { + }> => { assert(activeAccount, CommonError.NoActiveAccount); assert(activeNetwork, CommonError.NoActiveNetwork); assert( @@ -318,9 +318,9 @@ export function UnifiedBridgeProvider({ const sourceChain = buildChain(activeNetwork.caipId); const targetChain = buildChain(targetChainId); - const provider = getProviderForNetwork( + const provider = (await getProviderForNetwork( activeNetwork - ) as JsonRpcBatchInternal; + )) as JsonRpcBatchInternal; const fromAddress = activeAccount.addressC as `0x${string}`; @@ -377,8 +377,9 @@ export function UnifiedBridgeProvider({ assert(asset, UnifiedBridgeError.UnknownAsset); - const { fromAddress, sourceChain, targetChain } = - buildParams(targetChainId); + const { fromAddress, sourceChain, targetChain } = await buildParams( + targetChainId + ); const gasLimit = await core.estimateGas({ asset, @@ -429,8 +430,9 @@ export function UnifiedBridgeProvider({ assert(asset, UnifiedBridgeError.UnknownAsset); - const { fromAddress, sourceChain, targetChain } = - buildParams(targetChainId); + const { fromAddress, sourceChain, targetChain } = await buildParams( + targetChainId + ); let requiredSignatures = 1; let currentSignature = 1; diff --git a/src/hooks/useApproveAction.ts b/src/hooks/useApproveAction.ts index dbd426aff..03c964645 100644 --- a/src/hooks/useApproveAction.ts +++ b/src/hooks/useApproveAction.ts @@ -82,7 +82,7 @@ export function useApproveAction(actionId: string) { } }, [actionId, request, approval, isConfirmPopup]); - useWindowGetsClosedOrHidden(cancelHandler); + // useWindowGetsClosedOrHidden(cancelHandler); return { action, updateAction, error, cancelHandler }; } diff --git a/src/pages/ApproveAction/AvalancheSignTx.tsx b/src/pages/ApproveAction/AvalancheSignTx.tsx index 8a1014def..f6ed5dc50 100644 --- a/src/pages/ApproveAction/AvalancheSignTx.tsx +++ b/src/pages/ApproveAction/AvalancheSignTx.tsx @@ -70,7 +70,6 @@ export function AvalancheSignTx() { LedgerAppType.AVALANCHE, network ); - useWindowGetsClosedOrHidden(() => handleRejection()); const signTx = useCallback(async () => { await updateAction( diff --git a/src/pages/ApproveAction/components/ApproveBaseTx.tsx b/src/pages/ApproveAction/components/ApproveBaseTx.tsx index 3c61ed8ea..c14d1962a 100644 --- a/src/pages/ApproveAction/components/ApproveBaseTx.tsx +++ b/src/pages/ApproveAction/components/ApproveBaseTx.tsx @@ -6,11 +6,10 @@ import { Typography, } from '@avalabs/core-k2-components'; import { useTranslation } from 'react-i18next'; -import { bigIntToString, bigToLocaleString } from '@avalabs/core-utils-sdk'; +import { TokenUnit, bigIntToString } from '@avalabs/core-utils-sdk'; import { useSettingsContext } from '@src/contexts/SettingsProvider'; import { Avalanche } from '@avalabs/core-wallets-sdk'; import { AvalancheChainStrings } from '@src/background/services/wallet/handlers/eth_sendTransaction/models'; -import { bigintToBig } from '@src/utils/bigintToBig'; import { PVM } from '@avalabs/avalanchejs'; export function BaseTxView({ @@ -41,6 +40,8 @@ export function BaseTxView({ ); }; + const fee = new TokenUnit(txFee, 9, 'AVAX'); + return ( {/* source chain */} @@ -270,7 +271,7 @@ export function BaseTxView({ fontWeight: 'fontWeightSemibold', }} > - {bigToLocaleString(bigintToBig(txFee, 9), 6)} AVAX + {fee.toDisplay()} AVAX {currencyFormatter( - bigintToBig(txFee, 9).times(avaxPrice).toNumber() + fee.toDisplay({ asNumber: true }) * avaxPrice )} diff --git a/src/pages/ApproveAction/components/ApproveExportTx.tsx b/src/pages/ApproveAction/components/ApproveExportTx.tsx index 13a45560a..91e7cedcc 100644 --- a/src/pages/ApproveAction/components/ApproveExportTx.tsx +++ b/src/pages/ApproveAction/components/ApproveExportTx.tsx @@ -7,11 +7,10 @@ import { Typography, } from '@avalabs/core-k2-components'; import { useTranslation } from 'react-i18next'; -import { bigToLocaleString } from '@avalabs/core-utils-sdk'; +import { TokenUnit } from '@avalabs/core-utils-sdk'; import { useSettingsContext } from '@src/contexts/SettingsProvider'; import { Avalanche } from '@avalabs/core-wallets-sdk'; import { AvalancheChainStrings } from '@src/background/services/wallet/handlers/eth_sendTransaction/models'; -import { bigintToBig } from '@src/utils/bigintToBig'; export function ExportTxView({ tx, @@ -22,8 +21,9 @@ export function ExportTxView({ }) { const { t } = useTranslation(); const { currencyFormatter } = useSettingsContext(); - const { amount, chain, destination, type, txFee } = tx; - const fee = bigintToBig(txFee, 9); + const { amount: amountRaw, chain, destination, type, txFee } = tx; + const amount = new TokenUnit(amountRaw, 9, 'AVAX'); + const fee = new TokenUnit(txFee, 9, 'AVAX'); return ( @@ -145,7 +145,7 @@ export function ExportTxView({ fontWeight: 'fontWeightSemibold', }} > - {bigToLocaleString(bigintToBig(amount, 9), 4)} AVAX + {amount.toDisplay()} AVAX {currencyFormatter( - bigintToBig(amount, 9).times(avaxPrice).toNumber() + amount.toDisplay({ asNumber: true }) * avaxPrice )} @@ -200,7 +200,7 @@ export function ExportTxView({ fontWeight: 'fontWeightSemibold', }} > - {bigToLocaleString(fee, 6)} AVAX + {fee.toString()} AVAX - {currencyFormatter(fee.times(avaxPrice).toNumber())} + {currencyFormatter( + fee.toDisplay({ asNumber: true }) * avaxPrice + )} diff --git a/src/pages/ApproveAction/components/ApproveImportTx.tsx b/src/pages/ApproveAction/components/ApproveImportTx.tsx index 0b18aff26..661c7c2a7 100644 --- a/src/pages/ApproveAction/components/ApproveImportTx.tsx +++ b/src/pages/ApproveAction/components/ApproveImportTx.tsx @@ -7,11 +7,10 @@ import { Typography, } from '@avalabs/core-k2-components'; import { useTranslation } from 'react-i18next'; -import { bigToLocaleString } from '@avalabs/core-utils-sdk'; +import { TokenUnit } from '@avalabs/core-utils-sdk'; import { useSettingsContext } from '@src/contexts/SettingsProvider'; import { Avalanche } from '@avalabs/core-wallets-sdk'; import { AvalancheChainStrings } from '@src/background/services/wallet/handlers/eth_sendTransaction/models'; -import { bigintToBig } from '@src/utils/bigintToBig'; export function ImportTxView({ tx, @@ -23,8 +22,9 @@ export function ImportTxView({ const { t } = useTranslation(); const { currencyFormatter } = useSettingsContext(); - const { amount, chain, source, type, txFee } = tx; - const fee = bigintToBig(txFee, 9); + const { amount: amountRaw, chain, source, type, txFee } = tx; + const amount = new TokenUnit(amountRaw, 9, 'AVAX'); + const fee = new TokenUnit(txFee, 9, 'AVAX'); return ( @@ -146,7 +146,7 @@ export function ImportTxView({ fontWeight: 'fontWeightSemibold', }} > - {bigToLocaleString(bigintToBig(amount, 9), 6)} AVAX + {amount.toDisplay()} AVAX {currencyFormatter( - bigintToBig(amount, 9).times(avaxPrice).toNumber() + amount.toDisplay({ asNumber: true }) * avaxPrice )} @@ -201,7 +201,7 @@ export function ImportTxView({ fontWeight: 'fontWeightSemibold', }} > - {bigToLocaleString(fee, 6)} AVAX + {fee.toString()} AVAX - {currencyFormatter(fee.times(avaxPrice).toNumber())} + {currencyFormatter( + fee.toDisplay({ asNumber: true }) * avaxPrice + )} diff --git a/src/pages/ApproveAction/components/AvaxAmount.tsx b/src/pages/ApproveAction/components/AvaxAmount.tsx index fb14434ef..1070f6fd2 100644 --- a/src/pages/ApproveAction/components/AvaxAmount.tsx +++ b/src/pages/ApproveAction/components/AvaxAmount.tsx @@ -1,23 +1,24 @@ import { Stack, Typography } from '@avalabs/core-k2-components'; -import { bigToLocaleString } from '@avalabs/core-utils-sdk'; +import { TokenUnit } from '@avalabs/core-utils-sdk'; import { useSettingsContext } from '@src/contexts/SettingsProvider'; -import { bigintToBig } from '@src/utils/bigintToBig'; type AvaxAmountProps = { amount: bigint; avaxPrice: number; }; -export const AvaxAmount = ({ amount, avaxPrice }: AvaxAmountProps) => { +export const AvaxAmount = ({ + amount: amountRaw, + avaxPrice, +}: AvaxAmountProps) => { const { currencyFormatter } = useSettingsContext(); + const amount = new TokenUnit(amountRaw, 9, 'AVAX'); return ( - - {bigToLocaleString(bigintToBig(amount, 9), 4)} AVAX - + {amount.toDisplay()} AVAX - {currencyFormatter(bigintToBig(amount, 9).times(avaxPrice).toNumber())} + {currencyFormatter(amount.toDisplay({ asNumber: true }) * avaxPrice)} ); diff --git a/src/pages/Collectibles/CollectibleSend.tsx b/src/pages/Collectibles/CollectibleSend.tsx index 688e8aae1..da5eba898 100644 --- a/src/pages/Collectibles/CollectibleSend.tsx +++ b/src/pages/Collectibles/CollectibleSend.tsx @@ -1,4 +1,4 @@ -import { useCallback, useMemo } from 'react'; +import { useCallback, useEffect, useMemo, useState } from 'react'; import { useHistory } from 'react-router-dom'; import { NetworkVMType } from '@avalabs/core-chains-sdk'; import { useTranslation } from 'react-i18next'; @@ -49,10 +49,25 @@ export function CollectibleSend() { const nativeToken = tokens.find(({ type }) => type === TokenType.NATIVE); - const provider = useMemo( - () => (network ? getProviderForNetwork(network) : undefined), - [network] - ); + const [provider, setProvider] = useState(); + + useEffect(() => { + if (!network) { + setProvider(undefined); + } else { + let isMounted = true; + + getProviderForNetwork(network).then((p) => { + if (isMounted && p instanceof JsonRpcBatchInternal) { + setProvider(p); + } + }); + + return () => { + isMounted = false; + }; + } + }, [network]); const fromAddress = useMemo(() => { if (network?.vmName === NetworkVMType.EVM) { diff --git a/src/pages/Send/Send.tsx b/src/pages/Send/Send.tsx index 56de2e8b2..819bcf6ff 100644 --- a/src/pages/Send/Send.tsx +++ b/src/pages/Send/Send.tsx @@ -1,4 +1,4 @@ -import { useCallback, useMemo } from 'react'; +import { useCallback, useEffect, useMemo, useState } from 'react'; import { PageTitle } from '@src/components/common/PageTitle'; import { useTokensWithBalances } from '@src/hooks/useTokensWithBalances'; import { useAnalyticsContext } from '@src/contexts/AnalyticsProvider'; @@ -14,7 +14,10 @@ import { import { FunctionIsUnavailable } from '@src/components/common/FunctionIsUnavailable'; import { useAccountsContext } from '@src/contexts/AccountsProvider'; import { useNetworkFeeContext } from '@src/contexts/NetworkFeeProvider'; -import { getProviderForNetwork } from '@src/utils/network/getProviderForNetwork'; +import { + SupportedProvider, + getProviderForNetwork, +} from '@src/utils/network/getProviderForNetwork'; import { Avalanche, BitcoinProvider, @@ -62,10 +65,25 @@ export function SendPage() { const nativeToken = tokens.find(({ type }) => type === TokenType.NATIVE); - const provider = useMemo( - () => (network ? getProviderForNetwork(network) : undefined), - [network] - ); + const [provider, setProvider] = useState(); + + useEffect(() => { + if (!network) { + setProvider(undefined); + } else { + let isMounted = true; + + getProviderForNetwork(network).then((p) => { + if (isMounted) { + setProvider(p); + } + }); + + return () => { + isMounted = false; + }; + } + }, [network]); const fromAddress = useMemo(() => { if (network?.vmName === NetworkVMType.EVM) { diff --git a/src/pages/Send/hooks/useSend/usePVMSend.ts b/src/pages/Send/hooks/useSend/usePVMSend.ts index 2576f4463..36242bc60 100644 --- a/src/pages/Send/hooks/useSend/usePVMSend.ts +++ b/src/pages/Send/hooks/useSend/usePVMSend.ts @@ -130,8 +130,11 @@ export const usePvmSend: SendAdapterPVM = ({ const avax = provider.getAvaxID(); const amountBigInt = bigToBigInt(Big(amount), token.decimals); - const changeAddress = utils.parse(account.addressPVM)[2]; + const changeAddress = utils.parse( + account.addressPVM //.replace('fuji', 'custom') // TODO: just testing + )[2]; + const feeState = await provider.getApiP().getFeeState(); const unsignedTx = wallet.baseTX({ utxoSet: utxos, chain: PCHAIN_ALIAS, @@ -142,6 +145,7 @@ export const usePvmSend: SendAdapterPVM = ({ options: { changeAddresses: [changeAddress], }, + feeState, }); const manager = utils.getManagerForVM(unsignedTx.getVM()); const [codec] = manager.getCodecFromBuffer(unsignedTx.toBytes()); @@ -152,6 +156,7 @@ export const usePvmSend: SendAdapterPVM = ({ utxos: unsignedTx.utxos.map((utxo) => utils.bufferToHex(utxo.toBytes(codec)) ), + feeTolerance: 100, }; return await request({ method: DAppProviderRequest.AVALANCHE_SEND_TRANSACTION, diff --git a/src/pages/Send/utils/getMaxUtxos.ts b/src/pages/Send/utils/getMaxUtxos.ts index 4df107c67..b2842f8e6 100644 --- a/src/pages/Send/utils/getMaxUtxos.ts +++ b/src/pages/Send/utils/getMaxUtxos.ts @@ -28,6 +28,7 @@ export async function getMaxUtxoSet( utxos: utxos.getUTXOs(), sizeSupportedTx: Avalanche.SizeSupportedTx.BaseP, limit: isLedgerWallet ? LEDGER_TX_SIZE_LIMIT_BYTES : undefined, + feeState: await provider.getApiP().getFeeState(), }); } catch (error) { console.error('Error calculating maximum utxo set', { diff --git a/src/utils/caipConversion.ts b/src/utils/caipConversion.ts index e759c277d..55b5e9c5c 100644 --- a/src/utils/caipConversion.ts +++ b/src/utils/caipConversion.ts @@ -13,12 +13,13 @@ const BitcoinCaipId = { [ChainId.BITCOIN]: `${CaipNamespace.BIP122}:000000000019d6689c085ae165831e93`, [ChainId.BITCOIN_TESTNET]: `${CaipNamespace.BIP122}:000000000933ea01ad0ee984209779ba`, }; - const AvaxCaipId = { [ChainId.AVALANCHE_P]: `${CaipNamespace.AVAX}:${Avalanche.MainnetContext.pBlockchainID}`, [ChainId.AVALANCHE_X]: `${CaipNamespace.AVAX}:${Avalanche.MainnetContext.xBlockchainID}`, [ChainId.AVALANCHE_TEST_P]: `${CaipNamespace.AVAX}:fuji${Avalanche.FujiContext.pBlockchainID}`, [ChainId.AVALANCHE_TEST_X]: `${CaipNamespace.AVAX}:fuji${Avalanche.FujiContext.xBlockchainID}`, + [ChainId.AVALANCHE_DEVNET_P]: `${CaipNamespace.AVAX}:custom11111111111111111111111111111111LpoYY`, + [ChainId.AVALANCHE_DEVNET_X]: `${CaipNamespace.AVAX}:custom2piQ2AVHCjnduiWXsSY15DtbVuwHE2cwMHYnEXHsLL73BBkdbV`, } as const; export const getNetworkCaipId = (network: PartialBy) => { diff --git a/src/utils/environment.ts b/src/utils/environment.ts index 5961a74a3..6f1ab5569 100644 --- a/src/utils/environment.ts +++ b/src/utils/environment.ts @@ -1,7 +1,9 @@ export function isDevelopment() { + return true; return process.env.NODE_ENV === 'development'; } export function isProductionBuild() { + return false; return process.env.RELEASE === 'production'; } diff --git a/src/utils/network/getProviderForNetwork.ts b/src/utils/network/getProviderForNetwork.ts index 1f9852a9c..ecc8f18bb 100644 --- a/src/utils/network/getProviderForNetwork.ts +++ b/src/utils/network/getProviderForNetwork.ts @@ -9,11 +9,18 @@ import { FetchRequest, Network as EthersNetwork } from 'ethers'; import { Network } from '@src/background/services/network/models'; import { addGlacierAPIKeyIfNeeded } from './addGlacierAPIKeyIfNeeded'; +import { Info } from '@avalabs/avalanchejs'; +import { GetUpgradesInfoResponse } from '@avalabs/avalanchejs/dist/info/model'; -export const getProviderForNetwork = ( +export type SupportedProvider = + | BitcoinProvider + | JsonRpcBatchInternal + | Avalanche.JsonRpcProvider; + +export const getProviderForNetwork = async ( network: Network, useMulticall = false -): BitcoinProvider | JsonRpcBatchInternal | Avalanche.JsonRpcProvider => { +): Promise => { if (network.vmName === NetworkVMType.BITCOIN) { return new BitcoinProvider( !network.isTestnet, @@ -57,6 +64,14 @@ export const getProviderForNetwork = ( network.vmName === NetworkVMType.AVM || network.vmName === NetworkVMType.PVM ) { + if (network.isDevnet) { + const upgradesInfo = await new Info(network.rpcUrl) + .getUpgradesInfo() + .catch(() => ({} as GetUpgradesInfoResponse)); // If we can't get the upgrades info, return an empty object. This will result in pre-Etna behavior + + return Avalanche.JsonRpcProvider.getDefaultDevnetProvider(upgradesInfo); + } + return network.isTestnet ? Avalanche.JsonRpcProvider.getDefaultFujiProvider() : Avalanche.JsonRpcProvider.getDefaultMainnetProvider(); diff --git a/webpack.alpha.js b/webpack.alpha.js index 02488f012..df9131016 100644 --- a/webpack.alpha.js +++ b/webpack.alpha.js @@ -15,10 +15,11 @@ module.exports = merge(prod, { from: '**/*.json', to: '../', transform: transformManifestFiles({ - name: 'Core Beta DEVELOPMENT BUILD', + name: 'Core ETNA BUILD', shortName: 'Core Beta', - actionDefaultTitle: 'Core Beta Browser Extension DEVELOPMENT BUILD', + actionDefaultTitle: 'Core Beta Browser Extension ETNA BUILD', oAuthClientId: process.env.GOOGLE_OAUTH_CLIENT_ID, + publicKey: process.env.EXTENSION_PUBLIC_KEY, }), force: true, }, diff --git a/yarn.lock b/yarn.lock index 20409fc72..d1f88592e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -29,20 +29,20 @@ resolved "https://registry.yarnpkg.com/@apocentre/alias-sampling/-/alias-sampling-0.5.3.tgz#897ff181b48ad7b2bcb4ecf29400214888244f08" integrity sha512-7UDWIIF9hIeJqfKXkNIzkVandlwLf1FWTSdrb9iXvOP8oF544JRXQjCbiTmCv2c9n44n/FIWtehhBfNuAx2CZA== -"@avalabs/avalanche-module@0.11.2": - version "0.11.2" - resolved "https://registry.yarnpkg.com/@avalabs/avalanche-module/-/avalanche-module-0.11.2.tgz#265d0a9c781d623cd0ae61495a161c9649972f26" - integrity sha512-8oMmaQrTBV3iGntZA2VQYSLP5NKCRRD3rbcMa9WkzxCe16DWhT+tiygH6gqU48dI5pP5ELGcpoD6Bmg3JGN2QA== +"@avalabs/avalanche-module@0.0.0-feat-p-dynamic-fees-20241029181751": + version "0.0.0-feat-p-dynamic-fees-20241029181751" + resolved "https://registry.yarnpkg.com/@avalabs/avalanche-module/-/avalanche-module-0.0.0-feat-p-dynamic-fees-20241029181751.tgz#8ba40b07fc8c52fc61e64764c1743f4555948047" + integrity sha512-K/92eVtAS9cksbTRjPPtYlfT0bKNaZW6PruIvqA3c1mWk30uuH6xGhK99Yi7StSpwWpKb30DoezabbKfm6kmkQ== dependencies: "@avalabs/avalanchejs" "4.1.0-alpha.7" - "@avalabs/core-chains-sdk" "3.1.0-alpha.10" - "@avalabs/core-coingecko-sdk" "3.1.0-alpha.10" - "@avalabs/core-etherscan-sdk" "3.1.0-alpha.10" - "@avalabs/core-utils-sdk" "3.1.0-alpha.10" - "@avalabs/core-wallets-sdk" "3.1.0-alpha.10" - "@avalabs/glacier-sdk" "3.1.0-alpha.10" - "@avalabs/types" "3.1.0-alpha.10" - "@avalabs/vm-module-types" "0.11.2" + "@avalabs/core-chains-sdk" "3.1.0-canary.bef569b.0+bef569b" + "@avalabs/core-coingecko-sdk" "3.1.0-canary.bef569b.0+bef569b" + "@avalabs/core-etherscan-sdk" "3.1.0-canary.bef569b.0+bef569b" + "@avalabs/core-utils-sdk" "3.1.0-canary.bef569b.0+bef569b" + "@avalabs/core-wallets-sdk" "3.1.0-canary.bef569b.0+bef569b" + "@avalabs/glacier-sdk" "3.1.0-canary.bef569b.0+bef569b" + "@avalabs/types" "3.1.0-canary.bef569b.0+bef569b" + "@avalabs/vm-module-types" "0.0.0-feat-p-dynamic-fees-20241029181751" "@metamask/rpc-errors" "6.3.0" big.js "6.2.1" bn.js "5.2.1" @@ -59,15 +59,15 @@ "@scure/base" "1.1.5" micro-eth-signer "0.7.2" -"@avalabs/bitcoin-module@0.11.2": - version "0.11.2" - resolved "https://registry.yarnpkg.com/@avalabs/bitcoin-module/-/bitcoin-module-0.11.2.tgz#1603d00481bd6ecc3e30e67abc41c0f7866278f9" - integrity sha512-BpyyEN0M0YHXPX1erHHfNeTvbVZ80zEdy9W9zS6m9Eeep9P/1fAxs1NndLZpQOzjP3J+pSzr+pNDkeJfIz/lPw== +"@avalabs/bitcoin-module@0.0.0-feat-p-dynamic-fees-20241029181751": + version "0.0.0-feat-p-dynamic-fees-20241029181751" + resolved "https://registry.yarnpkg.com/@avalabs/bitcoin-module/-/bitcoin-module-0.0.0-feat-p-dynamic-fees-20241029181751.tgz#433051adb82629b89a44cdec0b104d48b368806c" + integrity sha512-TaHJS+UUJ2fPebGwgcrBy4JZ/nuWUwz4dvo/tb6Mf9GBpQUznG9IErpkNvN27qV0npl+L1qO3BgTcfPxojDD7w== dependencies: - "@avalabs/core-coingecko-sdk" "3.1.0-alpha.10" - "@avalabs/core-utils-sdk" "3.1.0-alpha.10" - "@avalabs/core-wallets-sdk" "3.1.0-alpha.10" - "@avalabs/vm-module-types" "0.11.2" + "@avalabs/core-coingecko-sdk" "3.1.0-canary.bef569b.0+bef569b" + "@avalabs/core-utils-sdk" "3.1.0-canary.bef569b.0+bef569b" + "@avalabs/core-wallets-sdk" "3.1.0-canary.bef569b.0+bef569b" + "@avalabs/vm-module-types" "0.0.0-feat-p-dynamic-fees-20241029181751" "@metamask/rpc-errors" "6.3.0" big.js "6.2.1" bitcoinjs-lib "5.2.0" @@ -86,42 +86,63 @@ viem "2.11.1" zod "3.23.8" -"@avalabs/core-bridge-sdk@3.1.0-alpha.10": - version "3.1.0-alpha.10" - resolved "https://registry.yarnpkg.com/@avalabs/core-bridge-sdk/-/core-bridge-sdk-3.1.0-alpha.10.tgz#1bcfb84f8ecd3f2e3e5eaef28403a88a4ad338d7" - integrity sha512-pu70aALpM57DuBu+9nhe4/UsiKJ+J4Nbbs2xc2TLdygmaNgQ1E3Eib7BRXKDfNsVrWRPvd21EJDBtSJrAaiEIw== +"@avalabs/core-bridge-sdk@3.1.0-canary.d8363d2.0+d8363d2": + version "3.1.0-canary.d8363d2.0" + resolved "https://registry.yarnpkg.com/@avalabs/core-bridge-sdk/-/core-bridge-sdk-3.1.0-canary.d8363d2.0.tgz#5e6436b9852e64d3d66431d5c84855dde1fa0b58" + integrity sha512-XOmkaPbrjuHnN6xXyguyXaPChK8wEbMVlE3kj+16CsNb1H1BUNfOngTlnJSyhzvixwTzGHFgNgNwl5hMguwFrg== dependencies: - "@avalabs/core-coingecko-sdk" "3.1.0-alpha.10" - "@avalabs/core-utils-sdk" "3.1.0-alpha.10" - "@avalabs/core-wallets-sdk" "3.1.0-alpha.10" + "@avalabs/core-coingecko-sdk" "3.1.0-canary.d8363d2.0+d8363d2" + "@avalabs/core-utils-sdk" "3.1.0-canary.d8363d2.0+d8363d2" + "@avalabs/core-wallets-sdk" "3.1.0-canary.d8363d2.0+d8363d2" -"@avalabs/core-chains-sdk@3.1.0-alpha.10": - version "3.1.0-alpha.10" - resolved "https://registry.yarnpkg.com/@avalabs/core-chains-sdk/-/core-chains-sdk-3.1.0-alpha.10.tgz#131fa0732ca42f14f4b8941988dd26fb62be9f55" - integrity sha512-a8tBpKcq35iYRx2kixJqHHtbsLtztBdFIYq0bz6Qfk4UI4FKFcpGQFZYjsSJrf5nxZojpfGXxexjacgQ7OkdYQ== +"@avalabs/core-chains-sdk@3.1.0-canary.bef569b.0+bef569b": + version "3.1.0-canary.bef569b.0" + resolved "https://registry.yarnpkg.com/@avalabs/core-chains-sdk/-/core-chains-sdk-3.1.0-canary.bef569b.0.tgz#92fb01cc27e12892ff32f69ea080178ca003fd66" + integrity sha512-xBQzhcKv8H7/DkWkP59fs25B2/duEn4u3G/fhByeLqlMFA32TmMZ3mLVI3Igixq8C9KTn7C9gmh2Pfuy2IkfOQ== dependencies: - "@avalabs/core-utils-sdk" "3.1.0-alpha.10" + "@avalabs/core-utils-sdk" "3.1.0-canary.bef569b.0+bef569b" -"@avalabs/core-coingecko-sdk@3.1.0-alpha.10": - version "3.1.0-alpha.10" - resolved "https://registry.yarnpkg.com/@avalabs/core-coingecko-sdk/-/core-coingecko-sdk-3.1.0-alpha.10.tgz#cd3a24fa74678f9d89aab338bd9a04fbddd1ffd6" - integrity sha512-ynBMHBEcNNPHpjTQcAoSIrtl5xlc9fhrTw50whLz8zyi+JQ4XD7jD/PjWqnAhtGmlH8ATpjMGGcnqo6jTlvW6w== +"@avalabs/core-chains-sdk@3.1.0-canary.d8363d2.0+d8363d2": + version "3.1.0-canary.d8363d2.0" + resolved "https://registry.yarnpkg.com/@avalabs/core-chains-sdk/-/core-chains-sdk-3.1.0-canary.d8363d2.0.tgz#517d13b30a4760201b2c3f084f021a990662ebb3" + integrity sha512-75H2YuNt9CpT8+EBIR/w2+6ArcXwm3CDHX+bmAbZS/3hLVcQ7PMSwHONbMN4K5nBpT262t+L1ZXufGHL2dqdRg== dependencies: - "@avalabs/core-utils-sdk" "3.1.0-alpha.10" + "@avalabs/core-utils-sdk" "3.1.0-canary.d8363d2.0+d8363d2" -"@avalabs/core-covalent-sdk@3.1.0-alpha.10": - version "3.1.0-alpha.10" - resolved "https://registry.yarnpkg.com/@avalabs/core-covalent-sdk/-/core-covalent-sdk-3.1.0-alpha.10.tgz#69d3d7d11658b2e13f22af9603befff3d396872f" - integrity sha512-np6Us1e2kokZxeOLfo3B7UUy87U14+1xmz+q1/LnlYKZmUQv4GCxYlYmTC+Hm2z6oD4zp91vUBvylXvgX5dv2Q== +"@avalabs/core-coingecko-sdk@3.1.0-canary.bef569b.0+bef569b": + version "3.1.0-canary.bef569b.0" + resolved "https://registry.yarnpkg.com/@avalabs/core-coingecko-sdk/-/core-coingecko-sdk-3.1.0-canary.bef569b.0.tgz#6aaaf19547749b3c9099b7edfbd531207b196f51" + integrity sha512-kTaZSb5hjLbQ4ewwTJV6nR/hKnbGE0fLRfmB4jiL1HdKLDzFJEIaDaeg9EwOGi77QrhEJb3SCfDmQ1Aue3n7yg== dependencies: - "@avalabs/core-utils-sdk" "3.1.0-alpha.10" + "@avalabs/core-utils-sdk" "3.1.0-canary.bef569b.0+bef569b" -"@avalabs/core-etherscan-sdk@3.1.0-alpha.10": - version "3.1.0-alpha.10" - resolved "https://registry.yarnpkg.com/@avalabs/core-etherscan-sdk/-/core-etherscan-sdk-3.1.0-alpha.10.tgz#0f34e9e23c21f009fcc3770ec53be7787bc5ade9" - integrity sha512-3DARUurEPSMQA5SsKt1Ef+PRl9QDDOpeoCrTXlGy7yl3KxMkLF1ufYTSThKNPfnGct+N91M60NAshqIIHRynNA== +"@avalabs/core-coingecko-sdk@3.1.0-canary.d8363d2.0+d8363d2": + version "3.1.0-canary.d8363d2.0" + resolved "https://registry.yarnpkg.com/@avalabs/core-coingecko-sdk/-/core-coingecko-sdk-3.1.0-canary.d8363d2.0.tgz#5605bd4707c4fcfc6a6cb5d1f282661d7a969405" + integrity sha512-cebtNtFLFZ/ppL8uPxKpQwGn6H5960mOxUi/dANZ6tYZQVQ8oiQuer27bVQ4nGmwvrjty64Fao8VmKQ41bHt9A== dependencies: - "@avalabs/core-utils-sdk" "3.1.0-alpha.10" + "@avalabs/core-utils-sdk" "3.1.0-canary.d8363d2.0+d8363d2" + +"@avalabs/core-covalent-sdk@3.1.0-canary.d8363d2.0+d8363d2": + version "3.1.0-canary.d8363d2.0" + resolved "https://registry.yarnpkg.com/@avalabs/core-covalent-sdk/-/core-covalent-sdk-3.1.0-canary.d8363d2.0.tgz#c81866e7134e9f6b09e42865169e2007365b375d" + integrity sha512-6DOMEXp6K5s8MVl8WlvRQWIqUuWnDmcO0DrTdXsVS1DqcFsqrI0BN7HmNN2tWsvW7cPITAkKU85ZXbznRbXq2A== + dependencies: + "@avalabs/core-utils-sdk" "3.1.0-canary.d8363d2.0+d8363d2" + +"@avalabs/core-etherscan-sdk@3.1.0-canary.bef569b.0+bef569b": + version "3.1.0-canary.bef569b.0" + resolved "https://registry.yarnpkg.com/@avalabs/core-etherscan-sdk/-/core-etherscan-sdk-3.1.0-canary.bef569b.0.tgz#658386cfa19f763e028dba1ea346c8ca18d7c102" + integrity sha512-5KuwLzWOaQfee916NLkWo22bB0fiRi21jFAjX1KcxwsF6p/jdTivgYaUB7qgZvrwLJ7KlgcXZ78k+zaQe9HBhQ== + dependencies: + "@avalabs/core-utils-sdk" "3.1.0-canary.bef569b.0+bef569b" + +"@avalabs/core-etherscan-sdk@3.1.0-canary.d8363d2.0+d8363d2": + version "3.1.0-canary.d8363d2.0" + resolved "https://registry.yarnpkg.com/@avalabs/core-etherscan-sdk/-/core-etherscan-sdk-3.1.0-canary.d8363d2.0.tgz#5013f01375b1b063a65a330d17f315d21772b44c" + integrity sha512-OCrzi9diGVhhh7/FZcpfcv9Kl/5qEIWubekFIF99qalpdXGQf5r5x79cBlnB28Vvpkh1/MMr4w92ytdppH2UPg== + dependencies: + "@avalabs/core-utils-sdk" "3.1.0-canary.d8363d2.0+d8363d2" "@avalabs/core-k2-components@4.18.0-alpha.47": version "4.18.0-alpha.47" @@ -146,38 +167,47 @@ react-hotkeys-hook "4.4.3" uuid "9.0.1" -"@avalabs/core-snowtrace-sdk@3.1.0-alpha.10": - version "3.1.0-alpha.10" - resolved "https://registry.yarnpkg.com/@avalabs/core-snowtrace-sdk/-/core-snowtrace-sdk-3.1.0-alpha.10.tgz#5e9787629ce09f49b06ab7e737daf0980c91c86a" - integrity sha512-jtw8DuJe9LV3hm8vYXPc0V6ibRjqvXeQsyS09QW22VhX858mWI8rCdBm/po0Oj6JRCfQrFEey9sswB7adc0enA== +"@avalabs/core-snowtrace-sdk@3.1.0-canary.d8363d2.0+d8363d2": + version "3.1.0-canary.d8363d2.0" + resolved "https://registry.yarnpkg.com/@avalabs/core-snowtrace-sdk/-/core-snowtrace-sdk-3.1.0-canary.d8363d2.0.tgz#21a84e5fc983a4f506fb50284432532890695372" + integrity sha512-0MonWOnHRGnukURBM7pkey4rvwOMyF8qTJ2pffeX+Ag9pGHr+iXV8JgTf59fwwGQ/jWB4vwbiNSh/IJ2xtNwcQ== + dependencies: + "@avalabs/core-utils-sdk" "3.1.0-canary.d8363d2.0+d8363d2" + +"@avalabs/core-token-prices-sdk@3.1.0-canary.d8363d2.0+d8363d2": + version "3.1.0-canary.d8363d2.0" + resolved "https://registry.yarnpkg.com/@avalabs/core-token-prices-sdk/-/core-token-prices-sdk-3.1.0-canary.d8363d2.0.tgz#72a18f03da2906bcf532be9b89f447a662448cc0" + integrity sha512-UTS0/jQqRGa4703kcUDITPNu8ROKttJ/5gjz6nnZxPo9jUkEXxuAX2kd+ppFXs+q7Pn6wW8zrfNnv3G1AFKj1A== dependencies: - "@avalabs/core-utils-sdk" "3.1.0-alpha.10" + "@avalabs/core-coingecko-sdk" "3.1.0-canary.d8363d2.0+d8363d2" + "@avalabs/core-utils-sdk" "3.1.0-canary.d8363d2.0+d8363d2" -"@avalabs/core-token-prices-sdk@3.1.0-alpha.10": - version "3.1.0-alpha.10" - resolved "https://registry.yarnpkg.com/@avalabs/core-token-prices-sdk/-/core-token-prices-sdk-3.1.0-alpha.10.tgz#760c966dae5aba23f66d2d11d572acb4640aa38a" - integrity sha512-MRDNpJO1VNLLBsew8PCWPfOLWGUsTRRFbslZDoMiW3PIjCEmvlj/iaX4LC1D5dhLAYS+g464kISYtdjmGZXJJw== +"@avalabs/core-utils-sdk@3.1.0-canary.bef569b.0+bef569b": + version "3.1.0-canary.bef569b.0" + resolved "https://registry.yarnpkg.com/@avalabs/core-utils-sdk/-/core-utils-sdk-3.1.0-canary.bef569b.0.tgz#c001cf62de1fa7366ab678d4c86f160ad3bcdc7d" + integrity sha512-YbxY6FikSo9LDHRhVyan7nEuqReSX1SktOVbXLYiQezpJBJAb0cgC9rZTl/0MKmyHX76ggSXuxsBeONxWQvIfA== dependencies: - "@avalabs/core-coingecko-sdk" "3.1.0-alpha.10" - "@avalabs/core-utils-sdk" "3.1.0-alpha.10" + "@avalabs/avalanchejs" "4.1.0-alpha.7" + "@hpke/core" "1.2.5" + is-ipfs "6.0.2" -"@avalabs/core-utils-sdk@3.1.0-alpha.10": - version "3.1.0-alpha.10" - resolved "https://registry.yarnpkg.com/@avalabs/core-utils-sdk/-/core-utils-sdk-3.1.0-alpha.10.tgz#813388b9ebeaa0c8c9b736b9890127234839bc1a" - integrity sha512-e4ZKBTAxxeDVPKEQyCkoJJyMCzt98ZHOsNhNsLHq/pQSPhxw91GatZFhniGv0fjoIgubLstf6GLo54IQdh+77g== +"@avalabs/core-utils-sdk@3.1.0-canary.d8363d2.0+d8363d2": + version "3.1.0-canary.d8363d2.0" + resolved "https://registry.yarnpkg.com/@avalabs/core-utils-sdk/-/core-utils-sdk-3.1.0-canary.d8363d2.0.tgz#adfb43a4fdbaeb01396a4db1226e1c8adcf9d178" + integrity sha512-OzQvBqr4N89Bcc+uVcvhmkm6XQjnuKWMWnpcjQvr8WXahomEWLkOBKku2LCTz1OmcZnNSjUO1/+nR6tg1pFIHQ== dependencies: "@avalabs/avalanchejs" "4.1.0-alpha.7" "@hpke/core" "1.2.5" is-ipfs "6.0.2" -"@avalabs/core-wallets-sdk@3.1.0-alpha.10": - version "3.1.0-alpha.10" - resolved "https://registry.yarnpkg.com/@avalabs/core-wallets-sdk/-/core-wallets-sdk-3.1.0-alpha.10.tgz#624e4ec426fc8952af36e3570c363236a73afa16" - integrity sha512-zx95Wts+ZPepKZar8N1f18+KaWGPD6IwY8uP1XbuzSM1WBJN7sDK6i7iupPUHqlablNzSDkT8e4k8ofdXjQ1yw== +"@avalabs/core-wallets-sdk@3.1.0-canary.bef569b.0+bef569b": + version "3.1.0-canary.bef569b.0" + resolved "https://registry.yarnpkg.com/@avalabs/core-wallets-sdk/-/core-wallets-sdk-3.1.0-canary.bef569b.0.tgz#1a1352bc8fc82d68e4e0e3c152b08ba65065e7e7" + integrity sha512-5fm3m3JNSWoY4P/+yTL5ZSqcTwpeuwhZsYRkLWm1rZBf23Ty0j46sIQ4zcblM5bWou+q/r8A322s4BwCQ2gA5Q== dependencies: "@avalabs/avalanchejs" "4.1.0-alpha.7" - "@avalabs/core-chains-sdk" "3.1.0-alpha.10" - "@avalabs/glacier-sdk" "3.1.0-alpha.10" + "@avalabs/core-chains-sdk" "3.1.0-canary.bef569b.0+bef569b" + "@avalabs/glacier-sdk" "3.1.0-canary.bef569b.0+bef569b" "@avalabs/hw-app-avalanche" "0.14.1" "@ledgerhq/hw-app-btc" "10.2.4" "@ledgerhq/hw-app-eth" "6.36.1" @@ -194,18 +224,42 @@ ledger-bitcoin "0.2.3" xss "1.0.14" -"@avalabs/evm-module@0.11.2": - version "0.11.2" - resolved "https://registry.yarnpkg.com/@avalabs/evm-module/-/evm-module-0.11.2.tgz#9f91ddc4c198f63e4a7b4a5045c59c4ad77408bc" - integrity sha512-2es5NKGurKUXq87a7xYH+zL3kvprjZ4DtcL+CVLIVCIsmVXSYRIAnNl7JgM1SakqrIeI+BAUuBi+OxMhBMc2HA== - dependencies: - "@avalabs/core-coingecko-sdk" "3.1.0-alpha.10" - "@avalabs/core-etherscan-sdk" "3.1.0-alpha.10" - "@avalabs/core-utils-sdk" "3.1.0-alpha.10" - "@avalabs/core-wallets-sdk" "3.1.0-alpha.10" - "@avalabs/glacier-sdk" "3.1.0-alpha.10" - "@avalabs/types" "3.1.0-alpha.10" - "@avalabs/vm-module-types" "0.11.2" +"@avalabs/core-wallets-sdk@3.1.0-canary.d8363d2.0+d8363d2": + version "3.1.0-canary.d8363d2.0" + resolved "https://registry.yarnpkg.com/@avalabs/core-wallets-sdk/-/core-wallets-sdk-3.1.0-canary.d8363d2.0.tgz#7c1047d1b4c3e73a24f67b9b66530115eb55f201" + integrity sha512-d66MNoZ3hcjP/UUaSCTPhJqXY8e6qL2ApZokkF7TQwIqkTzIXS+J+YN90m0DrcgI3k7ck5oGuH1MAvPTShgSaw== + dependencies: + "@avalabs/avalanchejs" "4.1.0-alpha.7" + "@avalabs/core-chains-sdk" "3.1.0-canary.d8363d2.0+d8363d2" + "@avalabs/glacier-sdk" "3.1.0-canary.d8363d2.0+d8363d2" + "@avalabs/hw-app-avalanche" "0.14.1" + "@ledgerhq/hw-app-btc" "10.2.4" + "@ledgerhq/hw-app-eth" "6.36.1" + "@ledgerhq/hw-transport" "6.30.6" + "@metamask/eth-sig-util" "7.0.2" + "@openzeppelin/contracts" "4.9.6" + bip32 "2.0.6" + bip32-path "0.4.2" + bip39 "3.0.4" + bitcoinjs-lib "5.2.0" + coinselect "3.1.13" + create-hash "1.2.0" + hdkey "2.0.1" + ledger-bitcoin "0.2.3" + xss "1.0.14" + +"@avalabs/evm-module@0.0.0-feat-p-dynamic-fees-20241029181751": + version "0.0.0-feat-p-dynamic-fees-20241029181751" + resolved "https://registry.yarnpkg.com/@avalabs/evm-module/-/evm-module-0.0.0-feat-p-dynamic-fees-20241029181751.tgz#5875fb4b7f67252b7c8e2b7e8129a8556d3a36fd" + integrity sha512-1Z0XEVKijbP/gDsByIrZsK1GeaCnM+gel0VIsIpXiHQRNcqAdmDjYokzybWQRYuN6QneRNIJi1dBQcZby06QFw== + dependencies: + "@avalabs/core-coingecko-sdk" "3.1.0-canary.bef569b.0+bef569b" + "@avalabs/core-etherscan-sdk" "3.1.0-canary.bef569b.0+bef569b" + "@avalabs/core-utils-sdk" "3.1.0-canary.bef569b.0+bef569b" + "@avalabs/core-wallets-sdk" "3.1.0-canary.bef569b.0+bef569b" + "@avalabs/glacier-sdk" "3.1.0-canary.bef569b.0+bef569b" + "@avalabs/types" "3.1.0-canary.bef569b.0+bef569b" + "@avalabs/vm-module-types" "0.0.0-feat-p-dynamic-fees-20241029181751" "@blockaid/client" "0.11.0" "@metamask/rpc-errors" "6.3.0" "@openzeppelin/contracts" "4.9.6" @@ -214,10 +268,15 @@ xss "1.0.13" zod "3.23.8" -"@avalabs/glacier-sdk@3.1.0-alpha.10": - version "3.1.0-alpha.10" - resolved "https://registry.yarnpkg.com/@avalabs/glacier-sdk/-/glacier-sdk-3.1.0-alpha.10.tgz#c0711d5b3e841e3928fdd8d45cfbe7c3032185b7" - integrity sha512-XolZv8o9BkU9sTC+oaaLSX9KP38WUUy6crgmmJ8JmokHNqFDvPF5Py0GapooNgcgG5QS3InnBFDtCnOa8pXx1g== +"@avalabs/glacier-sdk@3.1.0-canary.bef569b.0+bef569b": + version "3.1.0-canary.bef569b.0" + resolved "https://registry.yarnpkg.com/@avalabs/glacier-sdk/-/glacier-sdk-3.1.0-canary.bef569b.0.tgz#c466f2d0afde2638659a28c46caa6a9c23ed0bd5" + integrity sha512-DID9me9knHcU10l642xZThiiH7P1N9ihnlf/ZgyJypjZpKr9LIpfqXh9MDy6B1r5iUNWWfXYgA0HE6+zrq4ULg== + +"@avalabs/glacier-sdk@3.1.0-canary.d8363d2.0+d8363d2": + version "3.1.0-canary.d8363d2.0" + resolved "https://registry.yarnpkg.com/@avalabs/glacier-sdk/-/glacier-sdk-3.1.0-canary.d8363d2.0.tgz#8dedcfba53eb601f87cb70536ce4754e4ee71961" + integrity sha512-zjsOjTyAu8SPvuEMRfZpL33vXCEqmAPk5P0MsWT0vNi3HqyZDKrf5v+et/gtixKheDLYW8vp/qbjzo1PFc8Okg== "@avalabs/hw-app-avalanche@0.14.1": version "0.14.1" @@ -230,18 +289,23 @@ ledger-bitcoin "^0.2.1" sha3 "2.1.4" -"@avalabs/types@3.1.0-alpha.10": - version "3.1.0-alpha.10" - resolved "https://registry.yarnpkg.com/@avalabs/types/-/types-3.1.0-alpha.10.tgz#408766fce72882b0dc04ac045e5f3e95d21503d3" - integrity sha512-MgWAsW9K+y75tDMK8JCNdRLT4Lkdr1LysiPhlAaYg8Ino7KsZZmGzbIcLHakQwjSbY4CWQblDlB5y4SHN+fdmA== +"@avalabs/types@3.1.0-canary.bef569b.0+bef569b": + version "3.1.0-canary.bef569b.0" + resolved "https://registry.yarnpkg.com/@avalabs/types/-/types-3.1.0-canary.bef569b.0.tgz#751c3e7254d8289b24dd6adcb7d7d384b3189c1c" + integrity sha512-9An7sRbl3tvTm3gdE847dw8wyU/hGnQ5AGLoUoaysh8woXH/9z4IX/1WunEp1slDIDLXGImeSmDpTGGuTbsZrQ== + +"@avalabs/types@3.1.0-canary.d8363d2.0+d8363d2": + version "3.1.0-canary.d8363d2.0" + resolved "https://registry.yarnpkg.com/@avalabs/types/-/types-3.1.0-canary.d8363d2.0.tgz#8e8179bce20517b5c27a6a6b993a6d14236256b6" + integrity sha512-9TRPsxJ/i4mmXuCE9WYMB7lRz0HjSWnbXHKw9IvmXkUVECCaKnlZDp17ub2UCG4XzE03k5Z6+xSS5GzkiyW1sA== -"@avalabs/vm-module-types@0.11.2": - version "0.11.2" - resolved "https://registry.yarnpkg.com/@avalabs/vm-module-types/-/vm-module-types-0.11.2.tgz#faa2df6533da181f5d7c6f4cd6e366196c653c91" - integrity sha512-PdMCNSKy+jPfDWbNoj6sIzJc1T5XwXfnsAJFonEF+KKHW7j/Vy0WvOyL7bHRECIrvfGdUYFhnfVLragfGBGARQ== +"@avalabs/vm-module-types@0.0.0-feat-p-dynamic-fees-20241029181751": + version "0.0.0-feat-p-dynamic-fees-20241029181751" + resolved "https://registry.yarnpkg.com/@avalabs/vm-module-types/-/vm-module-types-0.0.0-feat-p-dynamic-fees-20241029181751.tgz#ce86787de406698f0b1e17723121ec20fb264149" + integrity sha512-IJDNfhUAJFNT4+UtqwBs8FhffxToyCAe7rtQEi7zimn5yVxhtWcp7y8OiGHRDiNZSIF1A2cAXJFrSGQn2NoKuw== dependencies: - "@avalabs/core-wallets-sdk" "3.1.0-alpha.10" - "@avalabs/glacier-sdk" "3.1.0-alpha.10" + "@avalabs/core-wallets-sdk" "3.1.0-canary.bef569b.0+bef569b" + "@avalabs/glacier-sdk" "3.1.0-canary.bef569b.0+bef569b" "@metamask/rpc-errors" "6.3.0" bitcoinjs-lib "5.2.0" zod "3.23.8" From 725fa54a1ccf47eaa58dfdcdf59ebdf28e0c8ecb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Leszczyk?= Date: Thu, 31 Oct 2024 11:25:16 +0100 Subject: [PATCH 02/16] fix: balances fetching fixes, handling P-Chain send --- .../connections/dAppConnection/registry.ts | 2 +- .../balances/BalanceAggregatorService.ts | 39 ++- .../services/networkFee/NetworkFeeService.ts | 4 +- .../vmModules/ApprovalController.ts | 33 ++ src/components/common/CustomFees.tsx | 304 +++++++++--------- src/contexts/UnifiedBridgeProvider.tsx | 15 +- src/pages/Send/Send.tsx | 24 +- src/pages/Send/components/SendForm.tsx | 22 +- src/pages/Send/components/SendPVM.tsx | 65 +++- src/pages/Send/hooks/useSend/models.ts | 19 +- src/pages/Send/hooks/useSend/usePVMSend.ts | 204 +++++++++--- src/pages/Send/models.ts | 5 +- src/pages/Send/utils/getMaxUtxos.ts | 12 +- src/pages/Send/utils/sendErrorMessages.ts | 1 + src/utils/assertions.ts | 11 + src/utils/send/models.ts | 1 + 16 files changed, 511 insertions(+), 250 deletions(-) diff --git a/src/background/connections/dAppConnection/registry.ts b/src/background/connections/dAppConnection/registry.ts index c5246db61..c4fe7a337 100644 --- a/src/background/connections/dAppConnection/registry.ts +++ b/src/background/connections/dAppConnection/registry.ts @@ -52,7 +52,7 @@ import { AvalancheRenameWalletHandler } from '@src/background/services/secrets/h { token: 'DAppRequestHandler', useToken: AvalancheSelectWalletHandler }, { token: 'DAppRequestHandler', useToken: AvalancheSelectAccountHandler }, { token: 'DAppRequestHandler', useToken: AvalancheGetAccountPubKeyHandler }, - { token: 'DAppRequestHandler', useToken: AvalancheSendTransactionHandler }, + // { token: 'DAppRequestHandler', useToken: AvalancheSendTransactionHandler }, { token: 'DAppRequestHandler', useToken: AvalancheSignTransactionHandler }, { token: 'DAppRequestHandler', useToken: AvalancheSignMessageHandler }, { token: 'DAppRequestHandler', useToken: AvalancheRenameAccountHandler }, diff --git a/src/background/services/balances/BalanceAggregatorService.ts b/src/background/services/balances/BalanceAggregatorService.ts index a75e3bd54..c6951cc2a 100644 --- a/src/background/services/balances/BalanceAggregatorService.ts +++ b/src/background/services/balances/BalanceAggregatorService.ts @@ -6,11 +6,11 @@ import { BalancesService } from './BalancesService'; import { NetworkService } from '../network/NetworkService'; import { EventEmitter } from 'events'; import * as Sentry from '@sentry/browser'; +import { isEqual, pick } from 'lodash'; import { LockService } from '../lock/LockService'; import { StorageService } from '../storage/StorageService'; import { CachedBalancesInfo } from './models'; -import { isEqual, merge } from 'lodash'; import { PriceChangesData, TOKENS_PRICE_DATA, @@ -89,10 +89,18 @@ export class BalanceAggregatorService implements OnLock, OnUnlock { .map(({ value }) => value); const networksWithChanges = updatedNetworks - .filter( - ({ chainId, networkBalances }) => - !isEqual(networkBalances, this.balances[chainId]) - ) + .filter(({ chainId, networkBalances }) => { + // We may have balances of other accounts cached for this chain ID, + // so to check for updates we need to only compare against a subsection + // of the cached balances. + const fetchedAddresses = Object.keys(networkBalances); + const cachedBalances = pick( + this.balances[chainId] ?? {}, + fetchedAddresses + ); + + return !isEqual(networkBalances, cachedBalances); + }) .map(({ chainId }) => chainId); const freshBalances = updatedNetworks.reduce<{ @@ -111,7 +119,6 @@ export class BalanceAggregatorService implements OnLock, OnUnlock { { tokens: {}, nfts: {} } ); - const aggregatedBalances = merge({}, this.balances, freshBalances.tokens); // NFTs don't have balance = 0, if they are sent they should be removed // from the list, hence deep merge doesn't work const hasFetchedNfts = @@ -123,7 +130,25 @@ export class BalanceAggregatorService implements OnLock, OnUnlock { ...freshBalances.nfts, } : this.nfts; - const hasChanges = networksWithChanges.length > 0; + const hasBalanceChanges = networksWithChanges.length > 0; + const hasNftChanges = !isEqual(aggregatedNfts, this.nfts); + const hasChanges = hasBalanceChanges || hasNftChanges; + + const aggregatedBalances = { ...this.balances }; + if (hasBalanceChanges) { + const freshData = Object.entries(freshBalances.tokens); + // We don't want to merge the account's balances, but overwrite them. + // Merging will result in wrong values when there are nested properties, + // such as UTXOs or "balanceByType" for X/P chains. + for (const [chainId, chainBalances] of freshData) { + for (const [address, addressBalance] of Object.entries(chainBalances)) { + aggregatedBalances[chainId] = { + ...chainBalances, + [address]: addressBalance, + }; + } + } + } if (hasChanges && !this.lockService.locked) { this.#balances = aggregatedBalances; diff --git a/src/background/services/networkFee/NetworkFeeService.ts b/src/background/services/networkFee/NetworkFeeService.ts index 03a2ae005..25f901f02 100644 --- a/src/background/services/networkFee/NetworkFeeService.ts +++ b/src/background/services/networkFee/NetworkFeeService.ts @@ -12,12 +12,10 @@ export class NetworkFeeService { async getNetworkFee(network: NetworkWithCaipId): Promise { const module = await this.moduleManager.loadModuleByNetwork(network); - const displayDecimals = network.vmName === NetworkVMType.BITCOIN ? 0 : 9; - const fees = await module.getNetworkFee(network); return { ...fees, - displayDecimals: fees.displayDecimals || displayDecimals, + displayDecimals: fees.displayDecimals ?? 0, }; } diff --git a/src/background/vmModules/ApprovalController.ts b/src/background/vmModules/ApprovalController.ts index 7e4bbd654..59d01c0db 100644 --- a/src/background/vmModules/ApprovalController.ts +++ b/src/background/vmModules/ApprovalController.ts @@ -19,6 +19,8 @@ import { NetworkWithCaipId } from '../services/network/models'; import { ApprovalParamsWithContext } from './models'; import { ACTION_HANDLED_BY_MODULE } from '../models'; +import { EVM, EVMUnsignedTx, UnsignedTx } from '@avalabs/avalanchejs'; +import { Avalanche } from '@avalabs/core-wallets-sdk'; @singleton() export class ApprovalController implements IApprovalController { @@ -180,6 +182,37 @@ export class ApprovalController implements IApprovalController { network, action.tabId ); + case RpcMethod.AVALANCHE_SEND_TRANSACTION: { + const result = await this.#walletService.sign( + { + tx: + signingData.vm === EVM + ? EVMUnsignedTx.fromJSON(signingData.unsignedTxJson) + : UnsignedTx.fromJSON(signingData.unsignedTxJson), + internalIndices: signingData.internalIndices, + externalIndices: signingData.externalIndices, + }, + network, + action.tabId + ); + + if ('txHash' in result) { + return result; + } + + const signedTransaction = + signingData.vm === EVM + ? EVMUnsignedTx.fromJSON(result.signedTx) + : UnsignedTx.fromJSON(result.signedTx); + + if (!signedTransaction.hasAllSignatures()) { + throw new Error('Signing error, missing signatures.'); + } + + return { + signedTx: Avalanche.signedTxToHex(signedTransaction.getSignedTx()), + }; + } default: throw new Error('Unrecognized method: ' + params.request.method); diff --git a/src/components/common/CustomFees.tsx b/src/components/common/CustomFees.tsx index cf2bb9c1c..3559b4c31 100644 --- a/src/components/common/CustomFees.tsx +++ b/src/components/common/CustomFees.tsx @@ -4,7 +4,7 @@ import { useSettingsContext } from '@src/contexts/SettingsProvider'; import { useNativeTokenPrice } from '@src/hooks/useTokenPrice'; import { Network, NetworkVMType } from '@avalabs/core-chains-sdk'; import { formatUnits, parseUnits } from 'ethers'; -import { Trans, useTranslation } from 'react-i18next'; +import { useTranslation } from 'react-i18next'; import { TokenType } from '@avalabs/vm-module-types'; import { FeeRate, @@ -12,6 +12,8 @@ import { } from '@src/background/services/networkFee/models'; import { Button, + ChevronDownIcon, + Collapse, Dialog, DialogProps, GearIcon, @@ -39,11 +41,12 @@ interface CustomGasFeesProps { }): void; onModifierChangeCallback?: (feeType?: GasFeeModifier) => void; gasPriceEditDisabled?: boolean; - maxGasPrice?: string; + maxGasPrice?: bigint; selectedGasFeeModifier?: GasFeeModifier; network?: Network; networkFee: NetworkFee | null; isLimitReadonly?: boolean; + isCollapsible?: boolean; } export enum GasFeeModifier { @@ -117,11 +120,22 @@ const CustomInput = styled('input')` } `; -export function getUpToTwoDecimals(input: bigint, decimals: number) { - const result = (input * 100n) / 10n ** BigInt(decimals); +const formatGasPrice = (value: bigint, decimals: number): string => { + const formatted = formatUnits(value, decimals); + const [wholes, fraction] = formatted.split('.'); - return formatUnits(result, 2); -} + // If something has changed and it's not dot-separated, just return the formatted string. + if (!wholes || !fraction) { + return formatted; + } + + // Otherwise, simplify + if (fraction === '0') { + return wholes; + } + + return formatted; +}; export const getGasFeeToDisplay = (fee: string, networkFee: NetworkFee) => { if (fee === '') { @@ -160,6 +174,7 @@ export function CustomFees({ network, networkFee, isLimitReadonly, + isCollapsible, }: CustomGasFeesProps) { const { t } = useTranslation(); const tokenPrice = useNativeTokenPrice(network); @@ -179,7 +194,7 @@ export function CustomFees({ gasLimit, }) ); - const [isGasPriceTooHigh, setIsGasPriceTooHigh] = useState(false); + const [isCollapsed, setIsCollapsed] = useState(isCollapsible); const customInputRef = useRef(null); const [showEditGasLimit, setShowEditGasLimit] = useState(false); const [selectedFee, setSelectedFee] = useState( @@ -198,12 +213,12 @@ export function CustomFees({ const handleGasChange = useCallback( (rate: FeeRate, modifier: GasFeeModifier): void => { - setIsGasPriceTooHigh(false); - if (modifier === GasFeeModifier.CUSTOM) { setCustomFee(rate); } + const isTooHigh = maxGasPrice ? rate.maxFeePerGas > maxGasPrice : false; + // update const updatedFees = calculateGasAndFees({ maxFeePerGas: rate.maxFeePerGas, @@ -212,25 +227,16 @@ export function CustomFees({ gasLimit, }); - if (maxGasPrice && updatedFees.bnFee > BigInt(maxGasPrice)) { - setIsGasPriceTooHigh(true); - // call cb with limit and gas - onChange({ - customGasLimit: customGasLimit, - maxFeePerGas: rate.maxFeePerGas, - maxPriorityFeePerGas: rate.maxPriorityFeePerGas, - feeType: modifier, - }); - return; - } - setNewFees(updatedFees); - // call cb with limit and gas onChange({ customGasLimit: customGasLimit, maxFeePerGas: rate.maxFeePerGas, maxPriorityFeePerGas: rate.maxPriorityFeePerGas, feeType: modifier, }); + + if (!isTooHigh) { + setNewFees(updatedFees); + } }, [ tokenPrice, @@ -334,137 +340,149 @@ export function CustomFees({ : undefined } > - {isCustomGasLimitSupported && ( + {isCollapsible ? ( setShowEditGasLimit(true)} + data-testid="customize-fee-button" + onClick={() => setIsCollapsed((wasCollapsed) => !wasCollapsed)} > - + + ) : ( + isCustomGasLimitSupported && ( + setShowEditGasLimit(true)} + > + + + ) )} - - { - handleModifierClick(GasFeeModifier.NORMAL); - }} - > - - {t('Normal')} - - - {getGasFeeToDisplay( - getUpToTwoDecimals( + + + { + handleModifierClick(GasFeeModifier.NORMAL); + }} + > + + {t('Normal')} + + + {formatGasPrice( networkFee.low.maxFeePerGas, networkFee.displayDecimals - ), - networkFee - )} - - - {!networkFee.isFixedFee && ( - <> - { - handleModifierClick(GasFeeModifier.FAST); - }} - > - - {t('Fast')} - - - {getGasFeeToDisplay( - getUpToTwoDecimals( + )} + + + {!networkFee.isFixedFee && ( + <> + { + handleModifierClick(GasFeeModifier.FAST); + }} + > + + {t('Fast')} + + + {formatGasPrice( networkFee.medium.maxFeePerGas, networkFee.displayDecimals - ), - networkFee - )} - - - { - handleModifierClick(GasFeeModifier.INSTANT); - }} - > - - {t('Instant')} - - - {getGasFeeToDisplay( - getUpToTwoDecimals( + )} + + + { + handleModifierClick(GasFeeModifier.INSTANT); + }} + > + + {t('Instant')} + + + {formatGasPrice( networkFee.high.maxFeePerGas, networkFee.displayDecimals - ), - networkFee - )} - - - { - handleModifierClick(GasFeeModifier.CUSTOM); - customInputRef?.current?.focus(); - }} - disableRipple - > - - {t('Custom')} - - + + { + handleModifierClick(GasFeeModifier.CUSTOM); + customInputRef?.current?.focus(); + }} + disableRipple + > + + {t('Custom')} + + { - handleGasChange( - getFeeRateForCustomGasPrice( - e.target.value || '0', - networkFee - ), - GasFeeModifier.CUSTOM - ); - }} - onBlur={(e) => { - if (e.target.value === '') { - handleGasChange(networkFee.low, GasFeeModifier.CUSTOM); - } - }} - /> - - - )} - + )} + min={1} + step={1} + onChange={(e) => { + handleGasChange( + getFeeRateForCustomGasPrice( + e.target.value || '0', + networkFee + ), + GasFeeModifier.CUSTOM + ); + }} + onBlur={(e) => { + if (e.target.value === '') { + handleGasChange(networkFee.low, GasFeeModifier.CUSTOM); + } + }} + /> + + + )} + + - {isGasPriceTooHigh && ( - - - - - - )} (DEFAULT_STATE); -function assert( - value: unknown, - reason?: ErrorCode -): asserts value is NonNullable { - if (!value) { - throw ethErrors.rpc.internal({ - data: { reason: reason ?? CommonError.Unknown }, - }); - } -} - export function UnifiedBridgeProvider({ children, }: { diff --git a/src/pages/Send/Send.tsx b/src/pages/Send/Send.tsx index 819bcf6ff..48b61d5c7 100644 --- a/src/pages/Send/Send.tsx +++ b/src/pages/Send/Send.tsx @@ -152,10 +152,17 @@ export function SendPage() { return ; } - const isNetworkFeeReady = - isPchainNetwork(network) || isXchainNetwork(network) - ? !!provider - : !!networkFee?.low?.maxFeePerGas; + const isNetworkFeeReady = !!networkFee?.low?.maxFeePerGas; + const isProviderReady = + provider && + network && + ((network.vmName === NetworkVMType.EVM && + provider instanceof JsonRpcBatchInternal) || + ((network.vmName === NetworkVMType.PVM || + network.vmName === NetworkVMType.AVM) && + provider instanceof Avalanche.JsonRpcProvider) || + (network.vmName === NetworkVMType.BITCOIN && + provider instanceof BitcoinProvider)); const isLoading = !active || @@ -163,7 +170,8 @@ export function SendPage() { !fromAddress || !provider || !isNetworkFeeReady || - !nativeToken; + !nativeToken || + !isProviderReady; return ( @@ -198,14 +206,14 @@ export function SendPage() { /> )} {!isLoading && + networkFee && network.vmName === NetworkVMType.PVM && isPvmCapableAccount(active) && ( { + children, +}: PropsWithChildren) => { const { t } = useTranslation(); const identifyAddress = useIdentifyAddress(); const contact = useMemo( @@ -131,6 +139,14 @@ export const SendForm = ({ setIsOpen={(open) => setIsTokenSelectOpen(open)} /> + {children} + {error && generalErrors.includes(error) && ( + + + {getSendErrorMessage(error)} + + + )} {!isContactsOpen && !isTokenSelectOpen && ( diff --git a/src/pages/Send/components/SendPVM.tsx b/src/pages/Send/components/SendPVM.tsx index 81723df49..c57813ce2 100644 --- a/src/pages/Send/components/SendPVM.tsx +++ b/src/pages/Send/components/SendPVM.tsx @@ -1,5 +1,6 @@ import { Avalanche } from '@avalabs/core-wallets-sdk'; import { useCallback, useEffect, useMemo, useState } from 'react'; +import { Grow, Stack } from '@avalabs/core-k2-components'; import { handleTxOutcome } from '@src/utils/handleTxOutcome'; @@ -12,12 +13,14 @@ import { NotSupportedByWallet } from '@src/components/common/NotSupportedByWalle import { FunctionNames } from '@src/hooks/useIsFunctionAvailable'; import { TokenWithBalancePVM } from '@avalabs/vm-module-types'; import { stringToBigint } from '@src/utils/stringToBigint'; +import { CustomFees } from '@src/components/common/CustomFees'; export const SendPVM = ({ network, fromAddress, maxFee, nativeToken, + networkFee, provider, tokenList, account, @@ -33,19 +36,28 @@ export const SendPVM = ({ const params = useQueryParams(); const [address, setAddress] = useState(params.get('address') ?? ''); const [amount, setAmount] = useState(''); + const [gasPrice, setGasPrice] = useState(networkFee.low.maxFeePerGas); - const { error, isSending, isValid, isValidating, maxAmount, send, validate } = - usePvmSend({ - network, - from: fromAddress, - maxFee, - provider, - nativeToken, - account, - }); + const { + error, + isSending, + isValid, + isValidating, + maxAmount, + send, + validate, + estimatedFee, + } = usePvmSend({ + network, + from: fromAddress, + maxFee, + provider, + nativeToken, + account, + }); useEffect(() => { - validate({ address, token: nativeToken, amount }); + validate({ address, amount, gasPrice }); if (address || amount) { setStateInParams({ @@ -63,6 +75,7 @@ export const SendPVM = ({ nativeToken, account, tokenList, + gasPrice, ]); const onSend = useCallback(async () => { @@ -75,7 +88,7 @@ export const SendPVM = ({ hasError, result: txHash, error: txError, - } = await handleTxOutcome(send({ address, token: nativeToken, amount })); + } = await handleTxOutcome(send({ address, amount, gasPrice })); if (isApproved) { onApproved(); @@ -90,11 +103,11 @@ export const SendPVM = ({ address, amount, isValid, - nativeToken, onApproved, onFailure, onSuccess, send, + gasPrice, ]); const inputAmount = useMemo( @@ -103,6 +116,10 @@ export const SendPVM = ({ [nativeToken, amount] ); + const onFeeCustomized = useCallback((values: { maxFeePerGas: bigint }) => { + setGasPrice(values.maxFeePerGas); + }, []); + if (account && !account.addressPVM) { return ( + > + + + + + + ); }; diff --git a/src/pages/Send/hooks/useSend/models.ts b/src/pages/Send/hooks/useSend/models.ts index 8a0e12151..4ed40e829 100644 --- a/src/pages/Send/hooks/useSend/models.ts +++ b/src/pages/Send/hooks/useSend/models.ts @@ -5,7 +5,12 @@ import { } from '@avalabs/core-wallets-sdk'; import { Network } from '@avalabs/core-chains-sdk'; -import { BaseSendOptions, NativeSendOptions, SendOptions } from '../../models'; +import { + BaseSendOptions, + NativeSendOptions, + PVMSendOptions, + SendOptions, +} from '../../models'; import { Account } from '@src/background/services/accounts/models'; import { EnsureDefined } from '@src/background/models'; @@ -66,7 +71,8 @@ type SendAdapter< Provider = unknown, NetworkSendOptions = unknown, CustomOptions = unknown, - Token = NetworkTokenWithBalance + Token = NetworkTokenWithBalance, + AdditionalOutput = Record > = (options: CommonAdapterOptions & CustomOptions) => { isSending: boolean; isValidating: boolean; @@ -76,7 +82,7 @@ type SendAdapter< send(options: NetworkSendOptions): Promise; validate(options: Partial): Promise; -}; +} & AdditionalOutput; export type SendAdapterEVM = SendAdapter< JsonRpcBatchInternal, @@ -94,9 +100,12 @@ export type SendAdapterBTC = SendAdapter< export type SendAdapterPVM = SendAdapter< Avalanche.JsonRpcProvider, - NativeSendOptions, + PVMSendOptions, AdapterOptionsP, - TokenWithBalancePVM + TokenWithBalancePVM, + { + estimatedFee: bigint; + } >; export type SendAdapterAVM = SendAdapter< diff --git a/src/pages/Send/hooks/useSend/usePVMSend.ts b/src/pages/Send/hooks/useSend/usePVMSend.ts index 36242bc60..ad2342f4d 100644 --- a/src/pages/Send/hooks/useSend/usePVMSend.ts +++ b/src/pages/Send/hooks/useSend/usePVMSend.ts @@ -2,7 +2,7 @@ import Big from 'big.js'; import { utils } from '@avalabs/avalanchejs'; import { Avalanche } from '@avalabs/core-wallets-sdk'; import { bigToBigInt } from '@avalabs/core-utils-sdk'; -import { useCallback, useMemo, useState } from 'react'; +import { useCallback, useEffect, useMemo, useState } from 'react'; import { resolve } from '@src/utils/promiseResolver'; import { FeatureGates } from '@src/background/services/featureFlags/models'; @@ -19,8 +19,10 @@ import { getMaxUtxoSet } from '../../utils/getMaxUtxos'; import { PVMSendOptions } from '../../models'; import { SendAdapterPVM } from './models'; import { correctAddressByPrefix } from '../../utils/correctAddressByPrefix'; +import { FeeState } from '@avalabs/avalanchejs/dist/vms/pvm'; const PCHAIN_ALIAS = 'P' as const; +const AVAX_DECIMALS = 9; export const usePvmSend: SendAdapterPVM = ({ network, @@ -37,6 +39,34 @@ export const usePvmSend: SendAdapterPVM = ({ const [isValidating, setIsValidating] = useState(false); const [isSending, setIsSending] = useState(false); const [maxAmount, setMaxAmount] = useState('0'); + const [estimatedFee, setEstimatedFee] = useState(0n); + const [feeState, setFeeState] = useState(); + + useEffect(() => { + let isMounted = true; + + if (provider.isEtnaEnabled()) { + provider + .getApiP() + .getFeeState() + .then((state) => { + if (!isMounted) { + return; + } + + setFeeState(state); + }) + .catch(() => { + setError(SendErrorMessage.INVALID_NETWORK_FEE); + }); + } else { + setFeeState(undefined); + } + + return () => { + isMounted = false; + }; + }, [provider]); const wallet = useMemo(() => { return new Avalanche.AddressWallet( @@ -59,9 +89,85 @@ export const usePvmSend: SendAdapterPVM = ({ setIsValidating(false); } + const getFeeState = useCallback( + (gasPrice?: bigint) => { + if (!gasPrice) { + return feeState; + } + + if (!feeState) { + return; + } + + return { + ...feeState, + price: gasPrice, + }; + }, + [feeState] + ); + + const buildTransaction = useCallback( + async ({ address, amount, gasPrice }: PVMSendOptions) => { + const avax = provider.getAvaxID(); + const amountBigInt = bigToBigInt(Big(amount), AVAX_DECIMALS); + const changeAddress = utils.parse(account.addressPVM)[2]; + const { utxos } = await getMaxUtxoSet( + isLedgerWallet, + provider, + wallet, + network, + getFeeState(gasPrice) + ); + + return wallet.baseTX({ + utxoSet: utxos, + chain: PCHAIN_ALIAS, + toAddress: correctAddressByPrefix(address, 'P-'), + amountsPerAsset: { + [avax]: amountBigInt, + }, + options: { + changeAddresses: [changeAddress], + }, + feeState: + feeState && gasPrice ? { ...feeState, price: gasPrice } : feeState, + }); + }, + [ + account.addressPVM, + provider, + wallet, + feeState, + isLedgerWallet, + network, + getFeeState, + ] + ); + + const parseTx = useCallback( + async ({ address, amount, gasPrice }: PVMSendOptions) => { + const unsignedTx = await buildTransaction({ + address, + amount, + gasPrice, + }); + + const parsedTx = await Avalanche.parseAvalancheTx( + unsignedTx, + provider, + account.addressPVM, + { feeTolerance: 100 } + ); + + return parsedTx; + }, + [buildTransaction, provider, account.addressPVM] + ); + const validate = useCallback( async (options: PVMSendOptions) => { - const { address, token, amount } = options; + const { address, amount, gasPrice } = options; const amountToUse = amount ? amount : '0'; setIsValidating(true); @@ -73,15 +179,38 @@ export const usePvmSend: SendAdapterPVM = ({ return setErrorAndEndValidating(errorReason); } + if (typeof gasPrice === 'bigint' && feeState) { + if (feeState.price > gasPrice) { + return setErrorAndEndValidating(SendErrorMessage.INVALID_NETWORK_FEE); + } else if (gasPrice > feeState.price * 2n) { + return setErrorAndEndValidating( + SendErrorMessage.EXCESSIVE_NETWORK_FEE + ); + } + } + + if (provider.isEtnaEnabled() && !feeState) { + // Fee state has not been fetched yet, we can't proceed with other validations. + // If there is an error with fetching the fee state when it's required, + // that error is captured outside of the validate() function. + return; + } + // using filtered UTXOs because there is size limit const [utxos, utxosError] = await resolve( - getMaxUtxoSet(isLedgerWallet, provider, wallet, network) + getMaxUtxoSet( + isLedgerWallet, + provider, + wallet, + network, + getFeeState(gasPrice) + ) ); if (utxosError) { return setErrorAndEndValidating(SendErrorMessage.UNABLE_TO_FETCH_UTXOS); } - const amountBigInt = bigToBigInt(Big(amountToUse), token.decimals); + const amountBigInt = bigToBigInt(Big(amountToUse), 9); // maxMount calculation const available = utxos?.balance.available ?? BigInt(0); const maxAvailable = available - maxFee; @@ -103,6 +232,10 @@ export const usePvmSend: SendAdapterPVM = ({ setIsValidating(false); setError(undefined); + + const parsedTx = await parseTx({ address, amount, gasPrice }); + + setEstimatedFee(parsedTx.txFee); }, [ checkFunctionAvailability, @@ -111,57 +244,45 @@ export const usePvmSend: SendAdapterPVM = ({ network, provider, wallet, + getFeeState, + parseTx, + feeState, ] ); const send = useCallback( - async ({ address, token, amount }: PVMSendOptions) => { + async ({ address, amount, gasPrice }: PVMSendOptions) => { checkFunctionAvailability(); - setIsSending(true); try { - const { utxos } = await getMaxUtxoSet( - isLedgerWallet, - provider, - wallet, - network - ); - - const avax = provider.getAvaxID(); - const amountBigInt = bigToBigInt(Big(amount), token.decimals); - const changeAddress = utils.parse( - account.addressPVM //.replace('fuji', 'custom') // TODO: just testing - )[2]; - - const feeState = await provider.getApiP().getFeeState(); - const unsignedTx = wallet.baseTX({ - utxoSet: utxos, - chain: PCHAIN_ALIAS, - toAddress: correctAddressByPrefix(address, 'P-'), - amountsPerAsset: { - [avax]: amountBigInt, - }, - options: { - changeAddresses: [changeAddress], - }, - feeState, + const unsignedTx = await buildTransaction({ + address, + amount, + gasPrice, }); const manager = utils.getManagerForVM(unsignedTx.getVM()); const [codec] = manager.getCodecFromBuffer(unsignedTx.toBytes()); const params = { - transactionHex: Buffer.from(unsignedTx.toBytes()).toString('hex'), + transactionHex: `0x${Buffer.from(unsignedTx.toBytes()).toString( + 'hex' + )}`, chainAlias: PCHAIN_ALIAS, utxos: unsignedTx.utxos.map((utxo) => utils.bufferToHex(utxo.toBytes(codec)) ), feeTolerance: 100, }; - return await request({ - method: DAppProviderRequest.AVALANCHE_SEND_TRANSACTION, - params, - }); + return await request( + { + method: DAppProviderRequest.AVALANCHE_SEND_TRANSACTION, + params, + }, + { + currentAddress: account.addressPVM, + } + ); } catch (err) { console.error(err); throw err; @@ -169,15 +290,7 @@ export const usePvmSend: SendAdapterPVM = ({ setIsSending(false); } }, - [ - account, - checkFunctionAvailability, - isLedgerWallet, - network, - provider, - request, - wallet, - ] + [buildTransaction, checkFunctionAvailability, request, account.addressPVM] ); return { @@ -188,5 +301,6 @@ export const usePvmSend: SendAdapterPVM = ({ maxAmount, send, validate, + estimatedFee, }; }; diff --git a/src/pages/Send/models.ts b/src/pages/Send/models.ts index d55373585..7dd1466cf 100644 --- a/src/pages/Send/models.ts +++ b/src/pages/Send/models.ts @@ -7,8 +7,8 @@ import { TokenWithBalanceAVM, TokenWithBalanceBTC, TokenWithBalanceERC20, - TokenWithBalancePVM, } from '@avalabs/vm-module-types'; +import { NetworkFee } from '@src/background/services/networkFee/models'; export type SendPageProps = { network: Network; @@ -35,6 +35,7 @@ export type SendPagePropsWithWalletPVM = SendPageProps< Tokens > & { account: PvmCapableAccount; + networkFee: NetworkFee; }; export type SendPagePropsWithWalletAVM = SendPageProps< @@ -59,7 +60,7 @@ export type AVMSendOptions = BaseSendOptions & { }; export type PVMSendOptions = BaseSendOptions & { - token: TokenWithBalancePVM; + gasPrice?: bigint; }; export type Erc20SendOptions = BaseSendOptions & { diff --git a/src/pages/Send/utils/getMaxUtxos.ts b/src/pages/Send/utils/getMaxUtxos.ts index b2842f8e6..c437d4cf5 100644 --- a/src/pages/Send/utils/getMaxUtxos.ts +++ b/src/pages/Send/utils/getMaxUtxos.ts @@ -1,8 +1,11 @@ import { utils } from '@avalabs/avalanchejs'; +import { FeeState } from '@avalabs/avalanchejs/dist/vms/pvm'; import { Network } from '@avalabs/core-chains-sdk'; import { Avalanche } from '@avalabs/core-wallets-sdk'; import { LEDGER_TX_SIZE_LIMIT_BYTES } from '@src/background/services/ledger/models'; import { isPchainNetwork } from '@src/background/services/network/utils/isAvalanchePchainNetwork'; +import { assert } from '@src/utils/assertions'; +import { CommonError } from '@src/utils/errors'; const MAX_LEDGER_OUTPUTS = 64; enum CHAIN_ALIAS { P = 'P', @@ -13,7 +16,8 @@ export async function getMaxUtxoSet( isLedgerWallet: boolean, provider: Avalanche.JsonRpcProvider, wallet: Avalanche.AddressWallet, - network: Network + network: Network, + feeState?: FeeState ) { const chainAliasToUse = isPchainNetwork(network) ? CHAIN_ALIAS.P @@ -22,13 +26,17 @@ export async function getMaxUtxoSet( let filteredUtxos = Avalanche.sortUTXOsByAmount(utxos.getUTXOs(), true); if (isPchainNetwork(network)) { + if (provider.isEtnaEnabled()) { + assert(feeState, CommonError.UnknownNetworkFee); + } + try { filteredUtxos = Avalanche.getMaximumUtxoSet({ wallet, utxos: utxos.getUTXOs(), sizeSupportedTx: Avalanche.SizeSupportedTx.BaseP, limit: isLedgerWallet ? LEDGER_TX_SIZE_LIMIT_BYTES : undefined, - feeState: await provider.getApiP().getFeeState(), + feeState, }); } catch (error) { console.error('Error calculating maximum utxo set', { diff --git a/src/pages/Send/utils/sendErrorMessages.ts b/src/pages/Send/utils/sendErrorMessages.ts index bf4341749..18453bc59 100644 --- a/src/pages/Send/utils/sendErrorMessages.ts +++ b/src/pages/Send/utils/sendErrorMessages.ts @@ -18,6 +18,7 @@ export function getSendErrorMessage(key: SendErrorMessage): string { ), [SendErrorMessage.UNSUPPORTED_TOKEN]: t('Unsupported token'), [SendErrorMessage.UNKNOWN_ERROR]: t('Unknown error'), + [SendErrorMessage.EXCESSIVE_NETWORK_FEE]: t('Selected fee is too high'), }; return translations[key] ?? key; diff --git a/src/utils/assertions.ts b/src/utils/assertions.ts index 18e330181..f98ba1ed6 100644 --- a/src/utils/assertions.ts +++ b/src/utils/assertions.ts @@ -39,3 +39,14 @@ export function assertTrue(condition: unknown): asserts condition is true { }); } } + +export function assert( + value: unknown, + reason?: ErrorCode +): asserts value is NonNullable { + if (!value) { + throw ethErrors.rpc.internal({ + data: { reason: reason ?? CommonError.Unknown }, + }); + } +} diff --git a/src/utils/send/models.ts b/src/utils/send/models.ts index 7e7132edb..961becb2d 100644 --- a/src/utils/send/models.ts +++ b/src/utils/send/models.ts @@ -6,6 +6,7 @@ export enum SendErrorMessage { INVALID_NETWORK_FEE = 'INVALID_NETWORK_FEE', INSUFFICIENT_BALANCE = 'INSUFFICIENT_BALANCE', INSUFFICIENT_BALANCE_FOR_FEE = 'INSUFFICIENT_BALANCE_FOR_FEE', + EXCESSIVE_NETWORK_FEE = 'EXCESSIVE_NETWORK_FEE', TOKEN_REQUIRED = 'TOKEN_REQUIRED', UNSUPPORTED_TOKEN = 'UNSUPPORTED_TOKEN', UNABLE_TO_FETCH_UTXOS = 'UNABLE_TO_FETCH_UTXOS', From 99fc93168f3924cca2d3fa598b26d2efaa329707 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Leszczyk?= Date: Thu, 31 Oct 2024 14:56:09 +0100 Subject: [PATCH 03/16] chore: translations --- src/localization/locales/en/translation.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/localization/locales/en/translation.json b/src/localization/locales/en/translation.json index 536dd0929..52caf7b27 100644 --- a/src/localization/locales/en/translation.json +++ b/src/localization/locales/en/translation.json @@ -413,7 +413,6 @@ "Instant": "Instant", "Insufficient balance": "Insufficient balance", "Insufficient balance for fee": "Insufficient balance for fee", - "Insufficient balance to cover gas costs.
Please add {{tokenSymbol}}.": "Insufficient balance to cover gas costs.
Please add {{tokenSymbol}}.", "Insufficient balance to cover gas costs.
Please add {{token}}.": "Insufficient balance to cover gas costs.
Please add {{token}}.", "Insufficient balance.": "Insufficient balance.", "Insufficient funds": "Insufficient funds", @@ -730,6 +729,7 @@ "Select the first word": "Select the first word", "Select the word that comes after": "Select the word that comes after", "Select the words below to verify your secret recovery phrase.": "Select the words below to verify your secret recovery phrase.", + "Selected fee is too high": "Selected fee is too high", "Send": "Send", "Send Feedback": "Send Feedback", "Send Successful": "Send Successful", From 76a89bc6d692bdec161688132e205ac697e29660 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Leszczyk?= Date: Thu, 31 Oct 2024 17:13:57 +0100 Subject: [PATCH 04/16] chore: cleanup + isDevnet() util instead of property --- package.json | 30 +-- .../connections/dAppConnection/registry.ts | 2 +- .../services/accounts/AccountsService.ts | 8 +- .../services/network/NetworkService.ts | 17 +- .../services/network/utils/getSyncDomain.ts | 2 +- .../handlers/avalanche_sendTransaction.ts | 3 +- .../handlers/avalanche_signTransaction.ts | 3 +- src/contexts/NetworkProvider.tsx | 7 +- src/contexts/UnifiedBridgeProvider.tsx | 13 +- src/hooks/useApproveAction.ts | 2 +- src/pages/ApproveAction/AvalancheSignTx.tsx | 1 - .../components/ApproveBaseTx.tsx | 5 +- src/pages/Send/Send.tsx | 38 ++- src/pages/Send/components/SendPVM.tsx | 7 +- src/pages/Send/hooks/useSend/usePVMSend.ts | 62 +++-- src/pages/Send/models.ts | 2 + src/utils/caipConversion.ts | 1 - src/utils/environment.ts | 2 - src/utils/isDevnet.ts | 5 + src/utils/network/getProviderForNetwork.ts | 22 +- yarn.lock | 252 +++++++----------- 21 files changed, 228 insertions(+), 256 deletions(-) create mode 100644 src/utils/isDevnet.ts diff --git a/package.json b/package.json index c98129d83..16925ebd5 100644 --- a/package.json +++ b/package.json @@ -23,25 +23,25 @@ "sentry": "node sentryscript.js" }, "dependencies": { - "@avalabs/avalanche-module": "0.0.0-feat-p-dynamic-fees-20241029181751", + "@avalabs/avalanche-module": "0.0.0-feat-p-dynamic-fees-20241031151758", "@avalabs/avalanchejs": "4.1.0-alpha.7", - "@avalabs/bitcoin-module": "0.0.0-feat-p-dynamic-fees-20241029181751", + "@avalabs/bitcoin-module": "0.0.0-feat-p-dynamic-fees-20241031151758", "@avalabs/bridge-unified": "0.0.0-feat-ictt-configs-20241009072139", - "@avalabs/core-bridge-sdk": "3.1.0-canary.d8363d2.0+d8363d2", - "@avalabs/core-chains-sdk": "3.1.0-canary.d8363d2.0+d8363d2", - "@avalabs/core-coingecko-sdk": "3.1.0-canary.d8363d2.0+d8363d2", - "@avalabs/core-covalent-sdk": "3.1.0-canary.d8363d2.0+d8363d2", - "@avalabs/core-etherscan-sdk": "3.1.0-canary.d8363d2.0+d8363d2", + "@avalabs/core-bridge-sdk": "3.1.0-canary.d762cf9.0+d762cf9", + "@avalabs/core-chains-sdk": "3.1.0-canary.d762cf9.0+d762cf9", + "@avalabs/core-coingecko-sdk": "3.1.0-canary.d762cf9.0+d762cf9", + "@avalabs/core-covalent-sdk": "3.1.0-canary.d762cf9.0+d762cf9", + "@avalabs/core-etherscan-sdk": "3.1.0-canary.d762cf9.0+d762cf9", "@avalabs/core-k2-components": "4.18.0-alpha.47", - "@avalabs/core-snowtrace-sdk": "3.1.0-canary.d8363d2.0+d8363d2", - "@avalabs/core-token-prices-sdk": "3.1.0-canary.d8363d2.0+d8363d2", - "@avalabs/core-utils-sdk": "3.1.0-canary.d8363d2.0+d8363d2", - "@avalabs/core-wallets-sdk": "3.1.0-canary.d8363d2.0+d8363d2", - "@avalabs/evm-module": "0.0.0-feat-p-dynamic-fees-20241029181751", - "@avalabs/glacier-sdk": "3.1.0-canary.d8363d2.0+d8363d2", + "@avalabs/core-snowtrace-sdk": "3.1.0-canary.d762cf9.0+d762cf9", + "@avalabs/core-token-prices-sdk": "3.1.0-canary.d762cf9.0+d762cf9", + "@avalabs/core-utils-sdk": "3.1.0-canary.d762cf9.0+d762cf9", + "@avalabs/core-wallets-sdk": "3.1.0-canary.d762cf9.0+d762cf9", + "@avalabs/evm-module": "0.0.0-feat-p-dynamic-fees-20241031151758", + "@avalabs/glacier-sdk": "3.1.0-canary.d762cf9.0+d762cf9", "@avalabs/hw-app-avalanche": "0.14.1", - "@avalabs/types": "3.1.0-canary.d8363d2.0+d8363d2", - "@avalabs/vm-module-types": "0.0.0-feat-p-dynamic-fees-20241029181751", + "@avalabs/types": "3.1.0-canary.d762cf9.0+d762cf9", + "@avalabs/vm-module-types": "0.0.0-feat-p-dynamic-fees-20241031151758", "@blockaid/client": "0.10.0", "@coinbase/cbpay-js": "1.6.0", "@cubist-labs/cubesigner-sdk": "0.3.28", diff --git a/src/background/connections/dAppConnection/registry.ts b/src/background/connections/dAppConnection/registry.ts index c4fe7a337..c5246db61 100644 --- a/src/background/connections/dAppConnection/registry.ts +++ b/src/background/connections/dAppConnection/registry.ts @@ -52,7 +52,7 @@ import { AvalancheRenameWalletHandler } from '@src/background/services/secrets/h { token: 'DAppRequestHandler', useToken: AvalancheSelectWalletHandler }, { token: 'DAppRequestHandler', useToken: AvalancheSelectAccountHandler }, { token: 'DAppRequestHandler', useToken: AvalancheGetAccountPubKeyHandler }, - // { token: 'DAppRequestHandler', useToken: AvalancheSendTransactionHandler }, + { token: 'DAppRequestHandler', useToken: AvalancheSendTransactionHandler }, { token: 'DAppRequestHandler', useToken: AvalancheSignTransactionHandler }, { token: 'DAppRequestHandler', useToken: AvalancheSignMessageHandler }, { token: 'DAppRequestHandler', useToken: AvalancheRenameAccountHandler }, diff --git a/src/background/services/accounts/AccountsService.ts b/src/background/services/accounts/AccountsService.ts index eac7f29c3..43bc8e0fb 100644 --- a/src/background/services/accounts/AccountsService.ts +++ b/src/background/services/accounts/AccountsService.ts @@ -27,6 +27,7 @@ import { SecretsService } from '../secrets/SecretsService'; import { LedgerService } from '../ledger/LedgerService'; import { WalletConnectService } from '../walletConnect/WalletConnectService'; import { Network } from '../network/models'; +import { isDevnet } from '@src/utils/isDevnet'; type AddAccountParams = { walletId: string; @@ -99,6 +100,9 @@ export class AccountsService implements OnLock, OnUnlock { // refresh addresses so in case the user switches to testnet mode, // as the BTC address needs to be updated this.networkService.developerModeChanged.add(this.onDeveloperModeChanged); + + // TODO(@meeh0w): + // Remove this listener after E-upgrade activation on Fuji. It will be no longer needed. this.networkService.uiActiveNetworkChanged.add( this.#onActiveNetworkChanged ); @@ -111,8 +115,8 @@ export class AccountsService implements OnLock, OnUnlock { return; } - if (Boolean(network.isDevnet) !== this.#wasDevnet) { - this.#wasDevnet = Boolean(network?.isDevnet || network.chainId === 43117); + if (isDevnet(network) !== this.#wasDevnet) { + this.#wasDevnet = isDevnet(network); await this.onDeveloperModeChanged(network?.isTestnet); } }; diff --git a/src/background/services/network/NetworkService.ts b/src/background/services/network/NetworkService.ts index a0780a704..8b1c65f1c 100644 --- a/src/background/services/network/NetworkService.ts +++ b/src/background/services/network/NetworkService.ts @@ -21,7 +21,6 @@ import { AVALANCHE_P_DEV_NETWORK, AVALANCHE_XP_NETWORK, AVALANCHE_XP_TEST_NETWORK, - AVALANCHE_X_DEV_NETWORK, BITCOIN_NETWORK, BITCOIN_TEST_NETWORK, ChainId, @@ -54,6 +53,7 @@ import { decorateWithCaipId, } from '@src/utils/caipConversion'; import { getSyncDomain, isSyncDomain } from './utils/getSyncDomain'; +import { isDevnet } from '@src/utils/isDevnet'; @singleton() export class NetworkService implements OnLock, OnStorageReady { @@ -381,10 +381,6 @@ export class NetworkService implements OnLock, OnStorageReady { return decorateWithCaipId(AVALANCHE_P_DEV_NETWORK); } - private _getXchainDevnet(): Network { - return decorateWithCaipId(AVALANCHE_X_DEV_NETWORK); - } - private _getPchainNetwork(isTestnet: boolean): Network { const network = isTestnet ? AVALANCHE_XP_TEST_NETWORK @@ -403,7 +399,7 @@ export class NetworkService implements OnLock, OnStorageReady { 'https://images.ctfassets.net/gcj8jwzm6086/5VHupNKwnDYJvqMENeV7iJ/3e4b8ff10b69bfa31e70080a4b142cd0/avalanche-avax-logo.svg', // from contentful }, explorerUrl: isTestnet - ? 'https://495e3bcd.subnets.pages.dev/p-chain' + ? 'https://subnets-test.avax.network/p-chain' : 'https://subnets.avax.network/p-chain', }); } @@ -427,7 +423,7 @@ export class NetworkService implements OnLock, OnStorageReady { 'https://images.ctfassets.net/gcj8jwzm6086/5VHupNKwnDYJvqMENeV7iJ/3e4b8ff10b69bfa31e70080a4b142cd0/avalanche-avax-logo.svg', // from contentful }, explorerUrl: isTestnet - ? 'https://495e3bcd.subnets.pages.dev/x-chain' + ? 'https://subnets-test.avax.network/x-chain' : 'https://subnets.avax.network/x-chain', }); } @@ -454,7 +450,6 @@ export class NetworkService implements OnLock, OnStorageReady { [ChainId.AVALANCHE_TEST_X]: this._getXchainNetwork(true), [ChainId.AVALANCHE_X]: this._getXchainNetwork(false), [ChainId.AVALANCHE_DEVNET_P]: this._getPchainDevnet(), - [ChainId.AVALANCHE_DEVNET_X]: this._getXchainDevnet(), }; } else { attempt += 1; @@ -491,10 +486,12 @@ export class NetworkService implements OnLock, OnStorageReady { * Returns the network object for Avalanche X/P Chains */ getAvalancheNetworkXP() { + // TODO(@meeh0w): clean up after E-upgrade activation on Fuji const isDevnetActive = - this.uiActiveNetwork?.isDevnet || this.uiActiveNetwork?.chainId === 43117; + this.uiActiveNetwork && isDevnet(this.uiActiveNetwork); + return isDevnetActive - ? this._getXchainDevnet() + ? this._getPchainDevnet() : this._getXchainNetwork(!this.isMainnet()); } diff --git a/src/background/services/network/utils/getSyncDomain.ts b/src/background/services/network/utils/getSyncDomain.ts index 5695e0482..e63b72a23 100644 --- a/src/background/services/network/utils/getSyncDomain.ts +++ b/src/background/services/network/utils/getSyncDomain.ts @@ -6,7 +6,7 @@ const SYNCED_DOMAINS = [ 'test.core.app', runtime.id, // Helpful for Core Web devs: - // 'localhost', + 'localhost', '127.0.0.1', ]; diff --git a/src/background/services/wallet/handlers/avalanche_sendTransaction.ts b/src/background/services/wallet/handlers/avalanche_sendTransaction.ts index 2f62915d1..ce6e89427 100644 --- a/src/background/services/wallet/handlers/avalanche_sendTransaction.ts +++ b/src/background/services/wallet/handlers/avalanche_sendTransaction.ts @@ -26,6 +26,7 @@ import { ChainId } from '@avalabs/core-chains-sdk'; import { openApprovalWindow } from '@src/background/runtime/openApprovalWindow'; import { measureDuration } from '@src/utils/measureDuration'; import { HEADERS } from '../../glacier/glacierConfig'; +import { isDevnet } from '@src/utils/isDevnet'; type TxParams = { transactionHex: string; @@ -102,7 +103,7 @@ export class AvalancheSendTransactionHandler extends DAppRequestHandler< : await Avalanche.getUtxosByTxFromGlacier({ transactionHex, chainAlias, - isDevnet: network.isDevnet || network.chainId === 43117, // FIXME: just a temporary condition + isDevnet: isDevnet(network), isTestnet: !this.networkService.isMainnet(), url: process.env.GLACIER_URL as string, token: process.env.GLACIER_API_KEY, diff --git a/src/background/services/wallet/handlers/avalanche_signTransaction.ts b/src/background/services/wallet/handlers/avalanche_signTransaction.ts index 5f217d572..78deff7f3 100644 --- a/src/background/services/wallet/handlers/avalanche_signTransaction.ts +++ b/src/background/services/wallet/handlers/avalanche_signTransaction.ts @@ -21,6 +21,7 @@ import { Avalanche } from '@avalabs/core-wallets-sdk'; import getProvidedUtxos from '../utils/getProvidedUtxos'; import { openApprovalWindow } from '@src/background/runtime/openApprovalWindow'; import { HEADERS } from '../../glacier/glacierConfig'; +import { isDevnet } from '@src/utils/isDevnet'; type TxParams = { transactionHex: string; @@ -90,7 +91,7 @@ export class AvalancheSignTransactionHandler extends DAppRequestHandler => { assert(activeAccount, CommonError.NoActiveAccount); @@ -307,9 +308,7 @@ export function UnifiedBridgeProvider({ const sourceChain = buildChain(activeNetwork.caipId); const targetChain = buildChain(targetChainId); - const provider = (await getProviderForNetwork( - activeNetwork - )) as JsonRpcBatchInternal; + const provider = await getProviderForNetwork(activeNetwork); const fromAddress = activeAccount.addressC as `0x${string}`; diff --git a/src/hooks/useApproveAction.ts b/src/hooks/useApproveAction.ts index 03c964645..dbd426aff 100644 --- a/src/hooks/useApproveAction.ts +++ b/src/hooks/useApproveAction.ts @@ -82,7 +82,7 @@ export function useApproveAction(actionId: string) { } }, [actionId, request, approval, isConfirmPopup]); - // useWindowGetsClosedOrHidden(cancelHandler); + useWindowGetsClosedOrHidden(cancelHandler); return { action, updateAction, error, cancelHandler }; } diff --git a/src/pages/ApproveAction/AvalancheSignTx.tsx b/src/pages/ApproveAction/AvalancheSignTx.tsx index f6ed5dc50..85786e5ed 100644 --- a/src/pages/ApproveAction/AvalancheSignTx.tsx +++ b/src/pages/ApproveAction/AvalancheSignTx.tsx @@ -37,7 +37,6 @@ import { FunctionNames, useIsFunctionAvailable, } from '@src/hooks/useIsFunctionAvailable'; -import { useWindowGetsClosedOrHidden } from '@src/utils/useWindowGetsClosedOrHidden'; export function AvalancheSignTx() { const requestId = useGetRequestId(); diff --git a/src/pages/ApproveAction/components/ApproveBaseTx.tsx b/src/pages/ApproveAction/components/ApproveBaseTx.tsx index c14d1962a..5fcd21cde 100644 --- a/src/pages/ApproveAction/components/ApproveBaseTx.tsx +++ b/src/pages/ApproveAction/components/ApproveBaseTx.tsx @@ -119,7 +119,7 @@ export function BaseTxView({ )} - {out.assetDescription?.symbol} + {out.assetDescription?.symbol ?? (out.isAvax && 'AVAX')} @@ -134,7 +134,8 @@ export function BaseTxView({ out.amount, out.assetDescription?.denomination || defaultDenomination - )} + )}{' '} + {out.assetDescription?.symbol ?? (out.isAvax && 'AVAX')} {out.isAvax && ( ); } + +// Helper utility for checking if the provider network & provider match. +// This is useful, since updates of `network` and `provider` may come +// in different render runs, in which case we should still wait. +const doesProviderMatchTheNetwork = ( + network?: Network, + provider?: SupportedProvider +) => { + if (!network || !provider) { + return false; + } + + switch (network.vmName) { + case NetworkVMType.EVM: + return provider instanceof JsonRpcBatchInternal; + + case NetworkVMType.AVM: + case NetworkVMType.PVM: + return provider instanceof Avalanche.JsonRpcProvider; + + case NetworkVMType.BITCOIN: + return provider instanceof BitcoinProvider; + + default: + return false; + } +}; diff --git a/src/pages/Send/components/SendPVM.tsx b/src/pages/Send/components/SendPVM.tsx index c57813ce2..a90dba74f 100644 --- a/src/pages/Send/components/SendPVM.tsx +++ b/src/pages/Send/components/SendPVM.tsx @@ -57,7 +57,7 @@ export const SendPVM = ({ }); useEffect(() => { - validate({ address, amount, gasPrice }); + validate({ address, amount, gasPrice, token: nativeToken }); if (address || amount) { setStateInParams({ @@ -88,7 +88,9 @@ export const SendPVM = ({ hasError, result: txHash, error: txError, - } = await handleTxOutcome(send({ address, amount, gasPrice })); + } = await handleTxOutcome( + send({ address, amount, gasPrice, token: nativeToken }) + ); if (isApproved) { onApproved(); @@ -108,6 +110,7 @@ export const SendPVM = ({ onSuccess, send, gasPrice, + nativeToken, ]); const inputAmount = useMemo( diff --git a/src/pages/Send/hooks/useSend/usePVMSend.ts b/src/pages/Send/hooks/useSend/usePVMSend.ts index ad2342f4d..1951fe312 100644 --- a/src/pages/Send/hooks/useSend/usePVMSend.ts +++ b/src/pages/Send/hooks/useSend/usePVMSend.ts @@ -22,7 +22,6 @@ import { correctAddressByPrefix } from '../../utils/correctAddressByPrefix'; import { FeeState } from '@avalabs/avalanchejs/dist/vms/pvm'; const PCHAIN_ALIAS = 'P' as const; -const AVAX_DECIMALS = 9; export const usePvmSend: SendAdapterPVM = ({ network, @@ -91,14 +90,10 @@ export const usePvmSend: SendAdapterPVM = ({ const getFeeState = useCallback( (gasPrice?: bigint) => { - if (!gasPrice) { + if (!gasPrice || !feeState) { return feeState; } - if (!feeState) { - return; - } - return { ...feeState, price: gasPrice, @@ -108,9 +103,9 @@ export const usePvmSend: SendAdapterPVM = ({ ); const buildTransaction = useCallback( - async ({ address, amount, gasPrice }: PVMSendOptions) => { + async ({ address, amount, gasPrice, token }: PVMSendOptions) => { const avax = provider.getAvaxID(); - const amountBigInt = bigToBigInt(Big(amount), AVAX_DECIMALS); + const amountBigInt = bigToBigInt(Big(amount), token.decimals); const changeAddress = utils.parse(account.addressPVM)[2]; const { utxos } = await getMaxUtxoSet( isLedgerWallet, @@ -146,11 +141,12 @@ export const usePvmSend: SendAdapterPVM = ({ ); const parseTx = useCallback( - async ({ address, amount, gasPrice }: PVMSendOptions) => { + async ({ address, amount, gasPrice, token }: PVMSendOptions) => { const unsignedTx = await buildTransaction({ address, amount, gasPrice, + token, }); const parsedTx = await Avalanche.parseAvalancheTx( @@ -167,7 +163,7 @@ export const usePvmSend: SendAdapterPVM = ({ const validate = useCallback( async (options: PVMSendOptions) => { - const { address, amount, gasPrice } = options; + const { address, amount, gasPrice, token } = options; const amountToUse = amount ? amount : '0'; setIsValidating(true); @@ -210,7 +206,7 @@ export const usePvmSend: SendAdapterPVM = ({ if (utxosError) { return setErrorAndEndValidating(SendErrorMessage.UNABLE_TO_FETCH_UTXOS); } - const amountBigInt = bigToBigInt(Big(amountToUse), 9); + const amountBigInt = bigToBigInt(Big(amountToUse), token.decimals); // maxMount calculation const available = utxos?.balance.available ?? BigInt(0); const maxAvailable = available - maxFee; @@ -233,7 +229,7 @@ export const usePvmSend: SendAdapterPVM = ({ setIsValidating(false); setError(undefined); - const parsedTx = await parseTx({ address, amount, gasPrice }); + const parsedTx = await parseTx({ address, amount, gasPrice, token }); setEstimatedFee(parsedTx.txFee); }, @@ -251,7 +247,7 @@ export const usePvmSend: SendAdapterPVM = ({ ); const send = useCallback( - async ({ address, amount, gasPrice }: PVMSendOptions) => { + async ({ address, amount, gasPrice, token }: PVMSendOptions) => { checkFunctionAvailability(); setIsSending(true); @@ -259,30 +255,24 @@ export const usePvmSend: SendAdapterPVM = ({ const unsignedTx = await buildTransaction({ address, amount, + token, gasPrice, }); const manager = utils.getManagerForVM(unsignedTx.getVM()); const [codec] = manager.getCodecFromBuffer(unsignedTx.toBytes()); - + const feeTolerance = getFeeTolerance(gasPrice, feeState); const params = { - transactionHex: `0x${Buffer.from(unsignedTx.toBytes()).toString( - 'hex' - )}`, + transactionHex: Buffer.from(unsignedTx.toBytes()).toString('hex'), chainAlias: PCHAIN_ALIAS, utxos: unsignedTx.utxos.map((utxo) => utils.bufferToHex(utxo.toBytes(codec)) ), - feeTolerance: 100, + feeTolerance, }; - return await request( - { - method: DAppProviderRequest.AVALANCHE_SEND_TRANSACTION, - params, - }, - { - currentAddress: account.addressPVM, - } - ); + return await request({ + method: DAppProviderRequest.AVALANCHE_SEND_TRANSACTION, + params, + }); } catch (err) { console.error(err); throw err; @@ -290,7 +280,7 @@ export const usePvmSend: SendAdapterPVM = ({ setIsSending(false); } }, - [buildTransaction, checkFunctionAvailability, request, account.addressPVM] + [buildTransaction, checkFunctionAvailability, request, feeState] ); return { @@ -304,3 +294,19 @@ export const usePvmSend: SendAdapterPVM = ({ estimatedFee, }; }; + +const getFeeTolerance = (chosenGasPrice?: bigint, feeState?: FeeState) => { + if (!chosenGasPrice || !feeState) { + return; + } + + const marketGasPrice = feeState.price; + // Technically this should never be negative, but let's safe-guard + const difference = Math.abs(Number(chosenGasPrice - marketGasPrice)); + + // Cap between 1 and 100 + return Math.min( + 100, + Math.max(1, Math.ceil((difference / Number(marketGasPrice)) * 100)) + ); +}; diff --git a/src/pages/Send/models.ts b/src/pages/Send/models.ts index 7dd1466cf..c09ad5cf9 100644 --- a/src/pages/Send/models.ts +++ b/src/pages/Send/models.ts @@ -7,6 +7,7 @@ import { TokenWithBalanceAVM, TokenWithBalanceBTC, TokenWithBalanceERC20, + TokenWithBalancePVM, } from '@avalabs/vm-module-types'; import { NetworkFee } from '@src/background/services/networkFee/models'; @@ -60,6 +61,7 @@ export type AVMSendOptions = BaseSendOptions & { }; export type PVMSendOptions = BaseSendOptions & { + token: TokenWithBalancePVM; gasPrice?: bigint; }; diff --git a/src/utils/caipConversion.ts b/src/utils/caipConversion.ts index 55b5e9c5c..99b088ceb 100644 --- a/src/utils/caipConversion.ts +++ b/src/utils/caipConversion.ts @@ -19,7 +19,6 @@ const AvaxCaipId = { [ChainId.AVALANCHE_TEST_P]: `${CaipNamespace.AVAX}:fuji${Avalanche.FujiContext.pBlockchainID}`, [ChainId.AVALANCHE_TEST_X]: `${CaipNamespace.AVAX}:fuji${Avalanche.FujiContext.xBlockchainID}`, [ChainId.AVALANCHE_DEVNET_P]: `${CaipNamespace.AVAX}:custom11111111111111111111111111111111LpoYY`, - [ChainId.AVALANCHE_DEVNET_X]: `${CaipNamespace.AVAX}:custom2piQ2AVHCjnduiWXsSY15DtbVuwHE2cwMHYnEXHsLL73BBkdbV`, } as const; export const getNetworkCaipId = (network: PartialBy) => { diff --git a/src/utils/environment.ts b/src/utils/environment.ts index 6f1ab5569..5961a74a3 100644 --- a/src/utils/environment.ts +++ b/src/utils/environment.ts @@ -1,9 +1,7 @@ export function isDevelopment() { - return true; return process.env.NODE_ENV === 'development'; } export function isProductionBuild() { - return false; return process.env.RELEASE === 'production'; } diff --git a/src/utils/isDevnet.ts b/src/utils/isDevnet.ts new file mode 100644 index 000000000..5ede382f8 --- /dev/null +++ b/src/utils/isDevnet.ts @@ -0,0 +1,5 @@ +import { ChainId } from '@avalabs/core-chains-sdk'; +import { Network } from '@src/background/services/network/models'; + +export const isDevnet = (network: Network) => + network.chainId === ChainId.AVALANCHE_DEVNET_P || network.chainId === 43117; diff --git a/src/utils/network/getProviderForNetwork.ts b/src/utils/network/getProviderForNetwork.ts index ecc8f18bb..c5923ae70 100644 --- a/src/utils/network/getProviderForNetwork.ts +++ b/src/utils/network/getProviderForNetwork.ts @@ -5,12 +5,12 @@ import { } from '@avalabs/core-wallets-sdk'; import { NetworkVMType } from '@avalabs/core-chains-sdk'; import { FetchRequest, Network as EthersNetwork } from 'ethers'; +import { Info } from '@avalabs/avalanchejs'; import { Network } from '@src/background/services/network/models'; +import { isDevnet } from '../isDevnet'; import { addGlacierAPIKeyIfNeeded } from './addGlacierAPIKeyIfNeeded'; -import { Info } from '@avalabs/avalanchejs'; -import { GetUpgradesInfoResponse } from '@avalabs/avalanchejs/dist/info/model'; export type SupportedProvider = | BitcoinProvider @@ -64,17 +64,15 @@ export const getProviderForNetwork = async ( network.vmName === NetworkVMType.AVM || network.vmName === NetworkVMType.PVM ) { - if (network.isDevnet) { - const upgradesInfo = await new Info(network.rpcUrl) - .getUpgradesInfo() - .catch(() => ({} as GetUpgradesInfoResponse)); // If we can't get the upgrades info, return an empty object. This will result in pre-Etna behavior - - return Avalanche.JsonRpcProvider.getDefaultDevnetProvider(upgradesInfo); - } + const upgradesInfo = await new Info(network.rpcUrl) + .getUpgradesInfo() + .catch(() => undefined); - return network.isTestnet - ? Avalanche.JsonRpcProvider.getDefaultFujiProvider() - : Avalanche.JsonRpcProvider.getDefaultMainnetProvider(); + return isDevnet(network) + ? Avalanche.JsonRpcProvider.getDefaultDevnetProvider(upgradesInfo) + : network.isTestnet + ? Avalanche.JsonRpcProvider.getDefaultFujiProvider(upgradesInfo) + : Avalanche.JsonRpcProvider.getDefaultMainnetProvider(upgradesInfo); } else { throw new Error('unsupported network'); } diff --git a/yarn.lock b/yarn.lock index d1f88592e..463a30eb8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -29,20 +29,20 @@ resolved "https://registry.yarnpkg.com/@apocentre/alias-sampling/-/alias-sampling-0.5.3.tgz#897ff181b48ad7b2bcb4ecf29400214888244f08" integrity sha512-7UDWIIF9hIeJqfKXkNIzkVandlwLf1FWTSdrb9iXvOP8oF544JRXQjCbiTmCv2c9n44n/FIWtehhBfNuAx2CZA== -"@avalabs/avalanche-module@0.0.0-feat-p-dynamic-fees-20241029181751": - version "0.0.0-feat-p-dynamic-fees-20241029181751" - resolved "https://registry.yarnpkg.com/@avalabs/avalanche-module/-/avalanche-module-0.0.0-feat-p-dynamic-fees-20241029181751.tgz#8ba40b07fc8c52fc61e64764c1743f4555948047" - integrity sha512-K/92eVtAS9cksbTRjPPtYlfT0bKNaZW6PruIvqA3c1mWk30uuH6xGhK99Yi7StSpwWpKb30DoezabbKfm6kmkQ== +"@avalabs/avalanche-module@0.0.0-feat-p-dynamic-fees-20241031151758": + version "0.0.0-feat-p-dynamic-fees-20241031151758" + resolved "https://registry.yarnpkg.com/@avalabs/avalanche-module/-/avalanche-module-0.0.0-feat-p-dynamic-fees-20241031151758.tgz#6a7f82740526da86dd29b770ef30586ac4d554c8" + integrity sha512-D+OjWg7qTeIVYkF5w0jqCPIcyycbRqB7zK1Xc9eBim9mSotGAsyDCmDPuxDWYz/51he/6FiYmniBdFBwvHl1OA== dependencies: "@avalabs/avalanchejs" "4.1.0-alpha.7" - "@avalabs/core-chains-sdk" "3.1.0-canary.bef569b.0+bef569b" - "@avalabs/core-coingecko-sdk" "3.1.0-canary.bef569b.0+bef569b" - "@avalabs/core-etherscan-sdk" "3.1.0-canary.bef569b.0+bef569b" - "@avalabs/core-utils-sdk" "3.1.0-canary.bef569b.0+bef569b" - "@avalabs/core-wallets-sdk" "3.1.0-canary.bef569b.0+bef569b" - "@avalabs/glacier-sdk" "3.1.0-canary.bef569b.0+bef569b" - "@avalabs/types" "3.1.0-canary.bef569b.0+bef569b" - "@avalabs/vm-module-types" "0.0.0-feat-p-dynamic-fees-20241029181751" + "@avalabs/core-chains-sdk" "3.1.0-canary.d762cf9.0+d762cf9" + "@avalabs/core-coingecko-sdk" "3.1.0-canary.d762cf9.0+d762cf9" + "@avalabs/core-etherscan-sdk" "3.1.0-canary.d762cf9.0+d762cf9" + "@avalabs/core-utils-sdk" "3.1.0-canary.d762cf9.0+d762cf9" + "@avalabs/core-wallets-sdk" "3.1.0-canary.d762cf9.0+d762cf9" + "@avalabs/glacier-sdk" "3.1.0-canary.d762cf9.0+d762cf9" + "@avalabs/types" "3.1.0-canary.d762cf9.0+d762cf9" + "@avalabs/vm-module-types" "0.0.0-feat-p-dynamic-fees-20241031151758" "@metamask/rpc-errors" "6.3.0" big.js "6.2.1" bn.js "5.2.1" @@ -59,15 +59,15 @@ "@scure/base" "1.1.5" micro-eth-signer "0.7.2" -"@avalabs/bitcoin-module@0.0.0-feat-p-dynamic-fees-20241029181751": - version "0.0.0-feat-p-dynamic-fees-20241029181751" - resolved "https://registry.yarnpkg.com/@avalabs/bitcoin-module/-/bitcoin-module-0.0.0-feat-p-dynamic-fees-20241029181751.tgz#433051adb82629b89a44cdec0b104d48b368806c" - integrity sha512-TaHJS+UUJ2fPebGwgcrBy4JZ/nuWUwz4dvo/tb6Mf9GBpQUznG9IErpkNvN27qV0npl+L1qO3BgTcfPxojDD7w== +"@avalabs/bitcoin-module@0.0.0-feat-p-dynamic-fees-20241031151758": + version "0.0.0-feat-p-dynamic-fees-20241031151758" + resolved "https://registry.yarnpkg.com/@avalabs/bitcoin-module/-/bitcoin-module-0.0.0-feat-p-dynamic-fees-20241031151758.tgz#89c34b9f1ddd751d4d44fabeea82331fc1b130bc" + integrity sha512-cqhZhGQXFh46qI1sI4aL0rqRJvbQTtLdKXRoMuugGLdLjEIs+P5BHKjMX9OMLpGDDqtMDHEYVszSSeR1VDq7OA== dependencies: - "@avalabs/core-coingecko-sdk" "3.1.0-canary.bef569b.0+bef569b" - "@avalabs/core-utils-sdk" "3.1.0-canary.bef569b.0+bef569b" - "@avalabs/core-wallets-sdk" "3.1.0-canary.bef569b.0+bef569b" - "@avalabs/vm-module-types" "0.0.0-feat-p-dynamic-fees-20241029181751" + "@avalabs/core-coingecko-sdk" "3.1.0-canary.d762cf9.0+d762cf9" + "@avalabs/core-utils-sdk" "3.1.0-canary.d762cf9.0+d762cf9" + "@avalabs/core-wallets-sdk" "3.1.0-canary.d762cf9.0+d762cf9" + "@avalabs/vm-module-types" "0.0.0-feat-p-dynamic-fees-20241031151758" "@metamask/rpc-errors" "6.3.0" big.js "6.2.1" bitcoinjs-lib "5.2.0" @@ -86,63 +86,42 @@ viem "2.11.1" zod "3.23.8" -"@avalabs/core-bridge-sdk@3.1.0-canary.d8363d2.0+d8363d2": - version "3.1.0-canary.d8363d2.0" - resolved "https://registry.yarnpkg.com/@avalabs/core-bridge-sdk/-/core-bridge-sdk-3.1.0-canary.d8363d2.0.tgz#5e6436b9852e64d3d66431d5c84855dde1fa0b58" - integrity sha512-XOmkaPbrjuHnN6xXyguyXaPChK8wEbMVlE3kj+16CsNb1H1BUNfOngTlnJSyhzvixwTzGHFgNgNwl5hMguwFrg== +"@avalabs/core-bridge-sdk@3.1.0-canary.d762cf9.0+d762cf9": + version "3.1.0-canary.d762cf9.0" + resolved "https://registry.yarnpkg.com/@avalabs/core-bridge-sdk/-/core-bridge-sdk-3.1.0-canary.d762cf9.0.tgz#c1440c49a67f2f83e6b73ef08928b6b670d99b09" + integrity sha512-ia20a5HibJimFw+lfNvqvM21zOWlhpAC4kTCJWcfwGn0L/HebSDEjQ/ZNBsv/0uoP9sF8EjUNkFLCAnH1CLfgg== dependencies: - "@avalabs/core-coingecko-sdk" "3.1.0-canary.d8363d2.0+d8363d2" - "@avalabs/core-utils-sdk" "3.1.0-canary.d8363d2.0+d8363d2" - "@avalabs/core-wallets-sdk" "3.1.0-canary.d8363d2.0+d8363d2" + "@avalabs/core-coingecko-sdk" "3.1.0-canary.d762cf9.0+d762cf9" + "@avalabs/core-utils-sdk" "3.1.0-canary.d762cf9.0+d762cf9" + "@avalabs/core-wallets-sdk" "3.1.0-canary.d762cf9.0+d762cf9" -"@avalabs/core-chains-sdk@3.1.0-canary.bef569b.0+bef569b": - version "3.1.0-canary.bef569b.0" - resolved "https://registry.yarnpkg.com/@avalabs/core-chains-sdk/-/core-chains-sdk-3.1.0-canary.bef569b.0.tgz#92fb01cc27e12892ff32f69ea080178ca003fd66" - integrity sha512-xBQzhcKv8H7/DkWkP59fs25B2/duEn4u3G/fhByeLqlMFA32TmMZ3mLVI3Igixq8C9KTn7C9gmh2Pfuy2IkfOQ== +"@avalabs/core-chains-sdk@3.1.0-canary.d762cf9.0+d762cf9": + version "3.1.0-canary.d762cf9.0" + resolved "https://registry.yarnpkg.com/@avalabs/core-chains-sdk/-/core-chains-sdk-3.1.0-canary.d762cf9.0.tgz#6f46a9342409f5fefd832ff74c4451ce6781d7c1" + integrity sha512-wK4c9BCFSwUcjaCXZcVJkSGGmkv9erHRYNaQasHXg7QUyX+p7kNw3zlcUX29vX9XsA3Joqkc/zahSb3I+G2t7Q== dependencies: - "@avalabs/core-utils-sdk" "3.1.0-canary.bef569b.0+bef569b" + "@avalabs/core-utils-sdk" "3.1.0-canary.d762cf9.0+d762cf9" -"@avalabs/core-chains-sdk@3.1.0-canary.d8363d2.0+d8363d2": - version "3.1.0-canary.d8363d2.0" - resolved "https://registry.yarnpkg.com/@avalabs/core-chains-sdk/-/core-chains-sdk-3.1.0-canary.d8363d2.0.tgz#517d13b30a4760201b2c3f084f021a990662ebb3" - integrity sha512-75H2YuNt9CpT8+EBIR/w2+6ArcXwm3CDHX+bmAbZS/3hLVcQ7PMSwHONbMN4K5nBpT262t+L1ZXufGHL2dqdRg== +"@avalabs/core-coingecko-sdk@3.1.0-canary.d762cf9.0+d762cf9": + version "3.1.0-canary.d762cf9.0" + resolved "https://registry.yarnpkg.com/@avalabs/core-coingecko-sdk/-/core-coingecko-sdk-3.1.0-canary.d762cf9.0.tgz#81d117b80e10d418dde721d73cbbcf4dc834cd12" + integrity sha512-WI0XW9B/3VTXBGcC1G9ViwcJIDXe1yJpcj70XAyo/XdLAk/YKHNhI8atdn8ZVlvFcgImwdXu5oHZeziRwCPgLA== dependencies: - "@avalabs/core-utils-sdk" "3.1.0-canary.d8363d2.0+d8363d2" + "@avalabs/core-utils-sdk" "3.1.0-canary.d762cf9.0+d762cf9" -"@avalabs/core-coingecko-sdk@3.1.0-canary.bef569b.0+bef569b": - version "3.1.0-canary.bef569b.0" - resolved "https://registry.yarnpkg.com/@avalabs/core-coingecko-sdk/-/core-coingecko-sdk-3.1.0-canary.bef569b.0.tgz#6aaaf19547749b3c9099b7edfbd531207b196f51" - integrity sha512-kTaZSb5hjLbQ4ewwTJV6nR/hKnbGE0fLRfmB4jiL1HdKLDzFJEIaDaeg9EwOGi77QrhEJb3SCfDmQ1Aue3n7yg== +"@avalabs/core-covalent-sdk@3.1.0-canary.d762cf9.0+d762cf9": + version "3.1.0-canary.d762cf9.0" + resolved "https://registry.yarnpkg.com/@avalabs/core-covalent-sdk/-/core-covalent-sdk-3.1.0-canary.d762cf9.0.tgz#da4f57bdb7e2f9398a276c4365611534e66e4fd8" + integrity sha512-lnxNM5saGedWbm9/wHiVP9AI+F2On3ElQgI/XLfgfotEjc+5yCSyT5WZXfNJBcwjOVP2wNggskv5FDHhoQWOdA== dependencies: - "@avalabs/core-utils-sdk" "3.1.0-canary.bef569b.0+bef569b" + "@avalabs/core-utils-sdk" "3.1.0-canary.d762cf9.0+d762cf9" -"@avalabs/core-coingecko-sdk@3.1.0-canary.d8363d2.0+d8363d2": - version "3.1.0-canary.d8363d2.0" - resolved "https://registry.yarnpkg.com/@avalabs/core-coingecko-sdk/-/core-coingecko-sdk-3.1.0-canary.d8363d2.0.tgz#5605bd4707c4fcfc6a6cb5d1f282661d7a969405" - integrity sha512-cebtNtFLFZ/ppL8uPxKpQwGn6H5960mOxUi/dANZ6tYZQVQ8oiQuer27bVQ4nGmwvrjty64Fao8VmKQ41bHt9A== +"@avalabs/core-etherscan-sdk@3.1.0-canary.d762cf9.0+d762cf9": + version "3.1.0-canary.d762cf9.0" + resolved "https://registry.yarnpkg.com/@avalabs/core-etherscan-sdk/-/core-etherscan-sdk-3.1.0-canary.d762cf9.0.tgz#0be5cd893fbb2cdd13783f6fd78d922e4a084eff" + integrity sha512-2vAqj5G8rvesoDrmPyUAcdjjVR8oPx/Uj0FZPGcpGqBlFk14l3Hs0exCKkPhldtL8nHMm95UmbEZhU5tDI08AQ== dependencies: - "@avalabs/core-utils-sdk" "3.1.0-canary.d8363d2.0+d8363d2" - -"@avalabs/core-covalent-sdk@3.1.0-canary.d8363d2.0+d8363d2": - version "3.1.0-canary.d8363d2.0" - resolved "https://registry.yarnpkg.com/@avalabs/core-covalent-sdk/-/core-covalent-sdk-3.1.0-canary.d8363d2.0.tgz#c81866e7134e9f6b09e42865169e2007365b375d" - integrity sha512-6DOMEXp6K5s8MVl8WlvRQWIqUuWnDmcO0DrTdXsVS1DqcFsqrI0BN7HmNN2tWsvW7cPITAkKU85ZXbznRbXq2A== - dependencies: - "@avalabs/core-utils-sdk" "3.1.0-canary.d8363d2.0+d8363d2" - -"@avalabs/core-etherscan-sdk@3.1.0-canary.bef569b.0+bef569b": - version "3.1.0-canary.bef569b.0" - resolved "https://registry.yarnpkg.com/@avalabs/core-etherscan-sdk/-/core-etherscan-sdk-3.1.0-canary.bef569b.0.tgz#658386cfa19f763e028dba1ea346c8ca18d7c102" - integrity sha512-5KuwLzWOaQfee916NLkWo22bB0fiRi21jFAjX1KcxwsF6p/jdTivgYaUB7qgZvrwLJ7KlgcXZ78k+zaQe9HBhQ== - dependencies: - "@avalabs/core-utils-sdk" "3.1.0-canary.bef569b.0+bef569b" - -"@avalabs/core-etherscan-sdk@3.1.0-canary.d8363d2.0+d8363d2": - version "3.1.0-canary.d8363d2.0" - resolved "https://registry.yarnpkg.com/@avalabs/core-etherscan-sdk/-/core-etherscan-sdk-3.1.0-canary.d8363d2.0.tgz#5013f01375b1b063a65a330d17f315d21772b44c" - integrity sha512-OCrzi9diGVhhh7/FZcpfcv9Kl/5qEIWubekFIF99qalpdXGQf5r5x79cBlnB28Vvpkh1/MMr4w92ytdppH2UPg== - dependencies: - "@avalabs/core-utils-sdk" "3.1.0-canary.d8363d2.0+d8363d2" + "@avalabs/core-utils-sdk" "3.1.0-canary.d762cf9.0+d762cf9" "@avalabs/core-k2-components@4.18.0-alpha.47": version "4.18.0-alpha.47" @@ -167,47 +146,38 @@ react-hotkeys-hook "4.4.3" uuid "9.0.1" -"@avalabs/core-snowtrace-sdk@3.1.0-canary.d8363d2.0+d8363d2": - version "3.1.0-canary.d8363d2.0" - resolved "https://registry.yarnpkg.com/@avalabs/core-snowtrace-sdk/-/core-snowtrace-sdk-3.1.0-canary.d8363d2.0.tgz#21a84e5fc983a4f506fb50284432532890695372" - integrity sha512-0MonWOnHRGnukURBM7pkey4rvwOMyF8qTJ2pffeX+Ag9pGHr+iXV8JgTf59fwwGQ/jWB4vwbiNSh/IJ2xtNwcQ== - dependencies: - "@avalabs/core-utils-sdk" "3.1.0-canary.d8363d2.0+d8363d2" - -"@avalabs/core-token-prices-sdk@3.1.0-canary.d8363d2.0+d8363d2": - version "3.1.0-canary.d8363d2.0" - resolved "https://registry.yarnpkg.com/@avalabs/core-token-prices-sdk/-/core-token-prices-sdk-3.1.0-canary.d8363d2.0.tgz#72a18f03da2906bcf532be9b89f447a662448cc0" - integrity sha512-UTS0/jQqRGa4703kcUDITPNu8ROKttJ/5gjz6nnZxPo9jUkEXxuAX2kd+ppFXs+q7Pn6wW8zrfNnv3G1AFKj1A== +"@avalabs/core-snowtrace-sdk@3.1.0-canary.d762cf9.0+d762cf9": + version "3.1.0-canary.d762cf9.0" + resolved "https://registry.yarnpkg.com/@avalabs/core-snowtrace-sdk/-/core-snowtrace-sdk-3.1.0-canary.d762cf9.0.tgz#af03e0ebd32e746b53174c77225bc39d3deca896" + integrity sha512-bnmnGv3LyidBXE+c5/ICziOKobnJbMznJ+/vR4lZRuMDfedGqZJUdhjiX3jhtpUq6HJh3waAZ8GQa1i/t2vQNw== dependencies: - "@avalabs/core-coingecko-sdk" "3.1.0-canary.d8363d2.0+d8363d2" - "@avalabs/core-utils-sdk" "3.1.0-canary.d8363d2.0+d8363d2" + "@avalabs/core-utils-sdk" "3.1.0-canary.d762cf9.0+d762cf9" -"@avalabs/core-utils-sdk@3.1.0-canary.bef569b.0+bef569b": - version "3.1.0-canary.bef569b.0" - resolved "https://registry.yarnpkg.com/@avalabs/core-utils-sdk/-/core-utils-sdk-3.1.0-canary.bef569b.0.tgz#c001cf62de1fa7366ab678d4c86f160ad3bcdc7d" - integrity sha512-YbxY6FikSo9LDHRhVyan7nEuqReSX1SktOVbXLYiQezpJBJAb0cgC9rZTl/0MKmyHX76ggSXuxsBeONxWQvIfA== +"@avalabs/core-token-prices-sdk@3.1.0-canary.d762cf9.0+d762cf9": + version "3.1.0-canary.d762cf9.0" + resolved "https://registry.yarnpkg.com/@avalabs/core-token-prices-sdk/-/core-token-prices-sdk-3.1.0-canary.d762cf9.0.tgz#5a2c1248c42f839327d5f609f726a1afd6099010" + integrity sha512-LTl5JqlWJkY4reH+DxEv+E2zwPvKw8h0d0xfQgQP58HyOzwb+xxbTwtfUHZix4dKPJIIWwgTEc8jdtW+ETKiJQ== dependencies: - "@avalabs/avalanchejs" "4.1.0-alpha.7" - "@hpke/core" "1.2.5" - is-ipfs "6.0.2" + "@avalabs/core-coingecko-sdk" "3.1.0-canary.d762cf9.0+d762cf9" + "@avalabs/core-utils-sdk" "3.1.0-canary.d762cf9.0+d762cf9" -"@avalabs/core-utils-sdk@3.1.0-canary.d8363d2.0+d8363d2": - version "3.1.0-canary.d8363d2.0" - resolved "https://registry.yarnpkg.com/@avalabs/core-utils-sdk/-/core-utils-sdk-3.1.0-canary.d8363d2.0.tgz#adfb43a4fdbaeb01396a4db1226e1c8adcf9d178" - integrity sha512-OzQvBqr4N89Bcc+uVcvhmkm6XQjnuKWMWnpcjQvr8WXahomEWLkOBKku2LCTz1OmcZnNSjUO1/+nR6tg1pFIHQ== +"@avalabs/core-utils-sdk@3.1.0-canary.d762cf9.0+d762cf9": + version "3.1.0-canary.d762cf9.0" + resolved "https://registry.yarnpkg.com/@avalabs/core-utils-sdk/-/core-utils-sdk-3.1.0-canary.d762cf9.0.tgz#812b8b89f64a28942a8f753ac09a64fd8635d5e3" + integrity sha512-NjNeMdllp/tYH9BqOCEZ8IM4hV6Y0ceJGZmOW7iH5RaFvL87SQhDmGc563WRPBfnvTDOFbqYZZYQcO3QCSu1EQ== dependencies: "@avalabs/avalanchejs" "4.1.0-alpha.7" "@hpke/core" "1.2.5" is-ipfs "6.0.2" -"@avalabs/core-wallets-sdk@3.1.0-canary.bef569b.0+bef569b": - version "3.1.0-canary.bef569b.0" - resolved "https://registry.yarnpkg.com/@avalabs/core-wallets-sdk/-/core-wallets-sdk-3.1.0-canary.bef569b.0.tgz#1a1352bc8fc82d68e4e0e3c152b08ba65065e7e7" - integrity sha512-5fm3m3JNSWoY4P/+yTL5ZSqcTwpeuwhZsYRkLWm1rZBf23Ty0j46sIQ4zcblM5bWou+q/r8A322s4BwCQ2gA5Q== +"@avalabs/core-wallets-sdk@3.1.0-canary.d762cf9.0+d762cf9": + version "3.1.0-canary.d762cf9.0" + resolved "https://registry.yarnpkg.com/@avalabs/core-wallets-sdk/-/core-wallets-sdk-3.1.0-canary.d762cf9.0.tgz#e2406c1f710dad04fcf37a6c92f710f96991f799" + integrity sha512-8kY0m7TMcbzEgPKqWtt9P0luVQj3cTMBCyN65lWGORXwo05VuuZulMR3ysHccGmJZeRGzZwkOjQB+6hVIziKUA== dependencies: "@avalabs/avalanchejs" "4.1.0-alpha.7" - "@avalabs/core-chains-sdk" "3.1.0-canary.bef569b.0+bef569b" - "@avalabs/glacier-sdk" "3.1.0-canary.bef569b.0+bef569b" + "@avalabs/core-chains-sdk" "3.1.0-canary.d762cf9.0+d762cf9" + "@avalabs/glacier-sdk" "3.1.0-canary.d762cf9.0+d762cf9" "@avalabs/hw-app-avalanche" "0.14.1" "@ledgerhq/hw-app-btc" "10.2.4" "@ledgerhq/hw-app-eth" "6.36.1" @@ -224,42 +194,18 @@ ledger-bitcoin "0.2.3" xss "1.0.14" -"@avalabs/core-wallets-sdk@3.1.0-canary.d8363d2.0+d8363d2": - version "3.1.0-canary.d8363d2.0" - resolved "https://registry.yarnpkg.com/@avalabs/core-wallets-sdk/-/core-wallets-sdk-3.1.0-canary.d8363d2.0.tgz#7c1047d1b4c3e73a24f67b9b66530115eb55f201" - integrity sha512-d66MNoZ3hcjP/UUaSCTPhJqXY8e6qL2ApZokkF7TQwIqkTzIXS+J+YN90m0DrcgI3k7ck5oGuH1MAvPTShgSaw== - dependencies: - "@avalabs/avalanchejs" "4.1.0-alpha.7" - "@avalabs/core-chains-sdk" "3.1.0-canary.d8363d2.0+d8363d2" - "@avalabs/glacier-sdk" "3.1.0-canary.d8363d2.0+d8363d2" - "@avalabs/hw-app-avalanche" "0.14.1" - "@ledgerhq/hw-app-btc" "10.2.4" - "@ledgerhq/hw-app-eth" "6.36.1" - "@ledgerhq/hw-transport" "6.30.6" - "@metamask/eth-sig-util" "7.0.2" - "@openzeppelin/contracts" "4.9.6" - bip32 "2.0.6" - bip32-path "0.4.2" - bip39 "3.0.4" - bitcoinjs-lib "5.2.0" - coinselect "3.1.13" - create-hash "1.2.0" - hdkey "2.0.1" - ledger-bitcoin "0.2.3" - xss "1.0.14" - -"@avalabs/evm-module@0.0.0-feat-p-dynamic-fees-20241029181751": - version "0.0.0-feat-p-dynamic-fees-20241029181751" - resolved "https://registry.yarnpkg.com/@avalabs/evm-module/-/evm-module-0.0.0-feat-p-dynamic-fees-20241029181751.tgz#5875fb4b7f67252b7c8e2b7e8129a8556d3a36fd" - integrity sha512-1Z0XEVKijbP/gDsByIrZsK1GeaCnM+gel0VIsIpXiHQRNcqAdmDjYokzybWQRYuN6QneRNIJi1dBQcZby06QFw== - dependencies: - "@avalabs/core-coingecko-sdk" "3.1.0-canary.bef569b.0+bef569b" - "@avalabs/core-etherscan-sdk" "3.1.0-canary.bef569b.0+bef569b" - "@avalabs/core-utils-sdk" "3.1.0-canary.bef569b.0+bef569b" - "@avalabs/core-wallets-sdk" "3.1.0-canary.bef569b.0+bef569b" - "@avalabs/glacier-sdk" "3.1.0-canary.bef569b.0+bef569b" - "@avalabs/types" "3.1.0-canary.bef569b.0+bef569b" - "@avalabs/vm-module-types" "0.0.0-feat-p-dynamic-fees-20241029181751" +"@avalabs/evm-module@0.0.0-feat-p-dynamic-fees-20241031151758": + version "0.0.0-feat-p-dynamic-fees-20241031151758" + resolved "https://registry.yarnpkg.com/@avalabs/evm-module/-/evm-module-0.0.0-feat-p-dynamic-fees-20241031151758.tgz#c1d6c9359814ef703c0ddcc3a6a1147910d8d8f5" + integrity sha512-ey0hTVyWCuyG2UPF+EBATRsDpzylpSoYkseqtaYcaMhTFkgwpzwcoI2+zzFHN7YP3GB1Qf9OEN5Wqdw13L1m1A== + dependencies: + "@avalabs/core-coingecko-sdk" "3.1.0-canary.d762cf9.0+d762cf9" + "@avalabs/core-etherscan-sdk" "3.1.0-canary.d762cf9.0+d762cf9" + "@avalabs/core-utils-sdk" "3.1.0-canary.d762cf9.0+d762cf9" + "@avalabs/core-wallets-sdk" "3.1.0-canary.d762cf9.0+d762cf9" + "@avalabs/glacier-sdk" "3.1.0-canary.d762cf9.0+d762cf9" + "@avalabs/types" "3.1.0-canary.d762cf9.0+d762cf9" + "@avalabs/vm-module-types" "0.0.0-feat-p-dynamic-fees-20241031151758" "@blockaid/client" "0.11.0" "@metamask/rpc-errors" "6.3.0" "@openzeppelin/contracts" "4.9.6" @@ -268,15 +214,10 @@ xss "1.0.13" zod "3.23.8" -"@avalabs/glacier-sdk@3.1.0-canary.bef569b.0+bef569b": - version "3.1.0-canary.bef569b.0" - resolved "https://registry.yarnpkg.com/@avalabs/glacier-sdk/-/glacier-sdk-3.1.0-canary.bef569b.0.tgz#c466f2d0afde2638659a28c46caa6a9c23ed0bd5" - integrity sha512-DID9me9knHcU10l642xZThiiH7P1N9ihnlf/ZgyJypjZpKr9LIpfqXh9MDy6B1r5iUNWWfXYgA0HE6+zrq4ULg== - -"@avalabs/glacier-sdk@3.1.0-canary.d8363d2.0+d8363d2": - version "3.1.0-canary.d8363d2.0" - resolved "https://registry.yarnpkg.com/@avalabs/glacier-sdk/-/glacier-sdk-3.1.0-canary.d8363d2.0.tgz#8dedcfba53eb601f87cb70536ce4754e4ee71961" - integrity sha512-zjsOjTyAu8SPvuEMRfZpL33vXCEqmAPk5P0MsWT0vNi3HqyZDKrf5v+et/gtixKheDLYW8vp/qbjzo1PFc8Okg== +"@avalabs/glacier-sdk@3.1.0-canary.d762cf9.0+d762cf9": + version "3.1.0-canary.d762cf9.0" + resolved "https://registry.yarnpkg.com/@avalabs/glacier-sdk/-/glacier-sdk-3.1.0-canary.d762cf9.0.tgz#5993fb1a9ffcc41df903c83952e95538057f02d3" + integrity sha512-lFvqLMISJ18jtNf1WdnKRED6T1ugFsphfMCKHZ+su+9H9DBWLqR/PRzjMgWmyPE9zM+Ly9h2TMbq3kaWZXzKxQ== "@avalabs/hw-app-avalanche@0.14.1": version "0.14.1" @@ -289,23 +230,18 @@ ledger-bitcoin "^0.2.1" sha3 "2.1.4" -"@avalabs/types@3.1.0-canary.bef569b.0+bef569b": - version "3.1.0-canary.bef569b.0" - resolved "https://registry.yarnpkg.com/@avalabs/types/-/types-3.1.0-canary.bef569b.0.tgz#751c3e7254d8289b24dd6adcb7d7d384b3189c1c" - integrity sha512-9An7sRbl3tvTm3gdE847dw8wyU/hGnQ5AGLoUoaysh8woXH/9z4IX/1WunEp1slDIDLXGImeSmDpTGGuTbsZrQ== - -"@avalabs/types@3.1.0-canary.d8363d2.0+d8363d2": - version "3.1.0-canary.d8363d2.0" - resolved "https://registry.yarnpkg.com/@avalabs/types/-/types-3.1.0-canary.d8363d2.0.tgz#8e8179bce20517b5c27a6a6b993a6d14236256b6" - integrity sha512-9TRPsxJ/i4mmXuCE9WYMB7lRz0HjSWnbXHKw9IvmXkUVECCaKnlZDp17ub2UCG4XzE03k5Z6+xSS5GzkiyW1sA== +"@avalabs/types@3.1.0-canary.d762cf9.0+d762cf9": + version "3.1.0-canary.d762cf9.0" + resolved "https://registry.yarnpkg.com/@avalabs/types/-/types-3.1.0-canary.d762cf9.0.tgz#36a08ffd342f5e94907e03dca34d3412c8ae9736" + integrity sha512-IWAVBwq6ACEh5i+RsYD4WMCKXCTmqCrRxV9VINt4y/dVdDbGqAHE8qpHvjqrlrOahvJ2FUSexlZwls++G3WRHQ== -"@avalabs/vm-module-types@0.0.0-feat-p-dynamic-fees-20241029181751": - version "0.0.0-feat-p-dynamic-fees-20241029181751" - resolved "https://registry.yarnpkg.com/@avalabs/vm-module-types/-/vm-module-types-0.0.0-feat-p-dynamic-fees-20241029181751.tgz#ce86787de406698f0b1e17723121ec20fb264149" - integrity sha512-IJDNfhUAJFNT4+UtqwBs8FhffxToyCAe7rtQEi7zimn5yVxhtWcp7y8OiGHRDiNZSIF1A2cAXJFrSGQn2NoKuw== +"@avalabs/vm-module-types@0.0.0-feat-p-dynamic-fees-20241031151758": + version "0.0.0-feat-p-dynamic-fees-20241031151758" + resolved "https://registry.yarnpkg.com/@avalabs/vm-module-types/-/vm-module-types-0.0.0-feat-p-dynamic-fees-20241031151758.tgz#bb3a053709f09fbf8807757315860699324b300e" + integrity sha512-JAbBzlbX7kDDltBMpp+2r2YGdd1zcub7GEKRZ2maEGAgKKWlKLKhGcATqs5VkhX/Pa5hTsWVoUKdLEJTYYaa5A== dependencies: - "@avalabs/core-wallets-sdk" "3.1.0-canary.bef569b.0+bef569b" - "@avalabs/glacier-sdk" "3.1.0-canary.bef569b.0+bef569b" + "@avalabs/core-wallets-sdk" "3.1.0-canary.d762cf9.0+d762cf9" + "@avalabs/glacier-sdk" "3.1.0-canary.d762cf9.0+d762cf9" "@metamask/rpc-errors" "6.3.0" bitcoinjs-lib "5.2.0" zod "3.23.8" From 466adf41cc2f0895338cd821e06d748e2301b645 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Leszczyk?= Date: Thu, 31 Oct 2024 17:56:01 +0100 Subject: [PATCH 05/16] chore: cleanup + test updates --- .../services/accounts/AccountsService.test.ts | 12 ++-- .../networkFee/NetworkFeeService.test.ts | 6 +- .../services/secrets/SecretsService.test.ts | 24 ++++---- .../services/seedless/SeedlessWallet.test.ts | 4 +- .../avalanche_sendTransaction.test.ts | 2 + .../avalanche_signTransaction.test.ts | 24 ++++---- src/contexts/BridgeProvider.test.tsx | 8 +-- .../SwapProvider/SwapProvider.test.tsx | 4 +- .../network/getProviderForNetwork.test.ts | 58 ++++++++++--------- webpack.alpha.js | 5 +- 10 files changed, 74 insertions(+), 73 deletions(-) diff --git a/src/background/services/accounts/AccountsService.test.ts b/src/background/services/accounts/AccountsService.test.ts index 4829c66f1..c4ef91ae5 100644 --- a/src/background/services/accounts/AccountsService.test.ts +++ b/src/background/services/accounts/AccountsService.test.ts @@ -361,7 +361,6 @@ describe('background/services/accounts/AccountsService', () => { }); it('correctly updates addresses for selected imported account', async () => { - const isMainnet = true; jest .mocked(secretsService.getImportedAddresses) .mockImplementation((id) => { @@ -379,7 +378,7 @@ describe('background/services/accounts/AccountsService', () => { expect(secretsService.getImportedAddresses).toHaveBeenCalledWith( 'fb-acc', - isMainnet + networkService ); expect(secretsService.getAddresses).toHaveBeenCalledTimes(0); expect(accountsService.getAccounts().imported['fb-acc']).toEqual({ @@ -658,7 +657,6 @@ describe('background/services/accounts/AccountsService', () => { const commitMock = jest.fn(); it('adds account to the imported list correctly', async () => { - const isMainnet = true; const options: ImportData = { importType: ImportType.PRIVATE_KEY, data: 'privateKey', @@ -684,7 +682,7 @@ describe('background/services/accounts/AccountsService', () => { expect(secretsService.addImportedWallet).toBeCalledTimes(1); expect(secretsService.addImportedWallet).toBeCalledWith( options, - isMainnet + networkService ); expect(commitMock).toHaveBeenCalled(); expect(permissionsService.addWhitelistDomains).toBeCalledTimes(1); @@ -718,7 +716,6 @@ describe('background/services/accounts/AccountsService', () => { }); it('sets default name when no name is given', async () => { - const isMainnet = true; const options: ImportData = { importType: ImportType.PRIVATE_KEY, data: 'privateKey', @@ -743,7 +740,7 @@ describe('background/services/accounts/AccountsService', () => { expect(secretsService.addImportedWallet).toBeCalledTimes(1); expect(secretsService.addImportedWallet).toBeCalledWith( options, - isMainnet + networkService ); expect(commitMock).toHaveBeenCalled(); expect(permissionsService.addWhitelistDomains).toBeCalledTimes(1); @@ -818,7 +815,6 @@ describe('background/services/accounts/AccountsService', () => { }); it('returns the existing account id on duplicated accounts imports', async () => { - const isMainnet = true; const options: ImportData = { importType: ImportType.PRIVATE_KEY, data: 'privateKey', @@ -845,7 +841,7 @@ describe('background/services/accounts/AccountsService', () => { expect(secretsService.addImportedWallet).toBeCalledTimes(1); expect(secretsService.addImportedWallet).toBeCalledWith( options, - isMainnet + networkService ); expect(commitMock).not.toHaveBeenCalled(); expect(permissionsService.addWhitelistDomains).not.toHaveBeenCalled(); diff --git a/src/background/services/networkFee/NetworkFeeService.test.ts b/src/background/services/networkFee/NetworkFeeService.test.ts index fda0c0145..6347f1704 100644 --- a/src/background/services/networkFee/NetworkFeeService.test.ts +++ b/src/background/services/networkFee/NetworkFeeService.test.ts @@ -69,6 +69,7 @@ describe('src/background/services/networkFee/NetworkFeeService', () => { low: { maxFeePerGas: 3n }, medium: { maxFeePerGas: 4n }, high: { maxFeePerGas: 5n }, + displayDecimals: 9, }; const getNetworkFee = jest.fn().mockResolvedValue(networkFees); @@ -84,10 +85,7 @@ describe('src/background/services/networkFee/NetworkFeeService', () => { expect(moduleManager.loadModuleByNetwork).toHaveBeenCalledWith(evm); - expect(fees).toEqual({ - displayDecimals: 9, - ...networkFees, - }); + expect(fees).toEqual(networkFees); }); }); }); diff --git a/src/background/services/secrets/SecretsService.test.ts b/src/background/services/secrets/SecretsService.test.ts index 2097786aa..47a03a1c8 100644 --- a/src/background/services/secrets/SecretsService.test.ts +++ b/src/background/services/secrets/SecretsService.test.ts @@ -1508,7 +1508,6 @@ describe('src/background/services/secrets/SecretsService.ts', () => { describe('addImportedWallet', () => { const pubKeyBuffer = Buffer.from('0x111', 'hex'); - const isMainnet = false; beforeEach(() => { (networkService.isMainnet as jest.Mock).mockReturnValue(false); @@ -1531,7 +1530,7 @@ describe('src/background/services/secrets/SecretsService.ts', () => { importType: ImportType.PRIVATE_KEY, data: 'privateKey', }, - isMainnet + networkService ); expect(result).toStrictEqual({ @@ -1570,7 +1569,7 @@ describe('src/background/services/secrets/SecretsService.ts', () => { importType: ImportType.PRIVATE_KEY, data: 'privateKey', }, - isMainnet + networkService ) ).rejects.toThrow('Error while calculating addresses'); }); @@ -1590,7 +1589,7 @@ describe('src/background/services/secrets/SecretsService.ts', () => { importType: ImportType.PRIVATE_KEY, data: 'privateKey', }, - isMainnet + networkService ) ).rejects.toThrow('Error while calculating addresses'); }); @@ -1610,7 +1609,7 @@ describe('src/background/services/secrets/SecretsService.ts', () => { importType: ImportType.PRIVATE_KEY, data: 'privateKey', }, - isMainnet + networkService ) ).rejects.toThrow('Error while calculating addresses'); }); @@ -1620,7 +1619,7 @@ describe('src/background/services/secrets/SecretsService.ts', () => { const pubKeyBuffer = Buffer.from('0x111', 'hex'); beforeEach(() => { - (networkService.isMainnet as jest.Mock).mockReturnValue(false); + (networkService.isMainnet as jest.Mock).mockReturnValue(true); (getPublicKeyFromPrivateKey as jest.Mock).mockReturnValue(pubKeyBuffer); (getEvmAddressFromPubKey as jest.Mock).mockReturnValue('0x1'); (getBtcAddressFromPubKey as jest.Mock).mockReturnValue('0x2'); @@ -1633,7 +1632,7 @@ describe('src/background/services/secrets/SecretsService.ts', () => { ); await expect( - secretsService.getImportedAddresses('id', true) + secretsService.getImportedAddresses('id', networkService) ).rejects.toThrow('No secrets found for imported account'); }); @@ -1644,11 +1643,12 @@ describe('src/background/services/secrets/SecretsService.ts', () => { ); await expect( - secretsService.getImportedAddresses('id', true) + secretsService.getImportedAddresses('id', networkService) ).rejects.toThrow('Unsupported import type'); }); it('throws if addresses are missing', async () => { + (networkService.isMainnet as jest.Mock).mockReturnValue(false); secretsService.getImportedAccountSecrets = jest.fn(); (secretsService.getImportedAccountSecrets as jest.Mock).mockResolvedValue( { secretType: SecretType.PrivateKey, secret: 'secret' } @@ -1657,17 +1657,21 @@ describe('src/background/services/secrets/SecretsService.ts', () => { (getBtcAddressFromPubKey as jest.Mock).mockReturnValueOnce(''); await expect( - secretsService.getImportedAddresses('id', false) + secretsService.getImportedAddresses('id', networkService) ).rejects.toThrow('Missing address'); }); it('returns the addresses for PRIVATE_KEY correctly', async () => { + (networkService.isMainnet as jest.Mock).mockReturnValue(false); secretsService.getImportedAccountSecrets = jest.fn(); (secretsService.getImportedAccountSecrets as jest.Mock).mockResolvedValue( { secretType: SecretType.PrivateKey, secret: 'secret' } ); - const result = await secretsService.getImportedAddresses('id', false); + const result = await secretsService.getImportedAddresses( + 'id', + networkService + ); expect(result).toStrictEqual({ addressBTC: '0x2', diff --git a/src/background/services/seedless/SeedlessWallet.test.ts b/src/background/services/seedless/SeedlessWallet.test.ts index fce10715e..c1bfcfc4c 100644 --- a/src/background/services/seedless/SeedlessWallet.test.ts +++ b/src/background/services/seedless/SeedlessWallet.test.ts @@ -972,7 +972,7 @@ describe('src/background/services/seedless/SeedlessWallet', () => { mockPsbt(); jest .mocked(getProviderForNetwork) - .mockReturnValue(new BitcoinProvider()); + .mockResolvedValue(new BitcoinProvider()); wallet = new SeedlessWallet({ networkService, sessionStorage, @@ -1000,7 +1000,7 @@ describe('src/background/services/seedless/SeedlessWallet', () => { jest .spyOn(bitcoinProvider, 'getNetwork') .mockReturnValue(networks.bitcoin); - jest.mocked(getProviderForNetwork).mockReturnValue(bitcoinProvider); + jest.mocked(getProviderForNetwork).mockResolvedValue(bitcoinProvider); wallet = new SeedlessWallet({ networkService, sessionStorage, diff --git a/src/background/services/wallet/handlers/avalanche_sendTransaction.test.ts b/src/background/services/wallet/handlers/avalanche_sendTransaction.test.ts index 8e96c5dd8..311455769 100644 --- a/src/background/services/wallet/handlers/avalanche_sendTransaction.test.ts +++ b/src/background/services/wallet/handlers/avalanche_sendTransaction.test.ts @@ -334,6 +334,7 @@ describe('src/background/services/wallet/handlers/avalanche_sendTransaction.ts', transactionHex: request.params.transactionHex, chainAlias: request.params.chainAlias, isTestnet: true, + isDevnet: false, url: process.env.GLACIER_URL, token: process.env.GLACIER_API_KEY, headers: HEADERS, @@ -415,6 +416,7 @@ describe('src/background/services/wallet/handlers/avalanche_sendTransaction.ts', transactionHex: request.params.transactionHex, chainAlias: request.params.chainAlias, isTestnet: true, + isDevnet: false, url: process.env.GLACIER_URL, token: process.env.GLACIER_API_KEY, headers: HEADERS, diff --git a/src/background/services/wallet/handlers/avalanche_signTransaction.test.ts b/src/background/services/wallet/handlers/avalanche_signTransaction.test.ts index a9047d0d8..c6e7f3b1d 100644 --- a/src/background/services/wallet/handlers/avalanche_signTransaction.test.ts +++ b/src/background/services/wallet/handlers/avalanche_signTransaction.test.ts @@ -15,6 +15,7 @@ import getProvidedUtxos from '../utils/getProvidedUtxos'; import { openApprovalWindow } from '@src/background/runtime/openApprovalWindow'; import { buildRpcCall } from '@src/tests/test-utils'; import { HEADERS } from '../../glacier/glacierConfig'; +import { AVALANCHE_XP_TEST_NETWORK } from '@avalabs/core-chains-sdk'; jest.mock('@avalabs/avalanchejs'); jest.mock('@avalabs/core-wallets-sdk'); @@ -93,6 +94,9 @@ describe('src/background/services/wallet/handlers/avalanche_signTransaction', () (Avalanche.getVmByChainAlias as jest.Mock).mockReturnValue(AVM); (utils.hexToBuffer as jest.Mock).mockReturnValue(txBytes); networkServiceMock.getAvalanceProviderXP.mockReturnValue(providerMock); + networkServiceMock.getAvalancheNetworkXP.mockReturnValueOnce( + AVALANCHE_XP_TEST_NETWORK + ); (utils.unpackWithManager as jest.Mock).mockReturnValue(txMock); (utils.addressesFromBytes as jest.Mock).mockReturnValue([ signerAddressMock, @@ -225,6 +229,7 @@ describe('src/background/services/wallet/handlers/avalanche_signTransaction', () transactionHex: request.params.transactionHex, chainAlias: request.params.chainAlias, isTestnet: true, + isDevnet: false, url: process.env.GLACIER_URL, token: process.env.GLACIER_API_KEY, headers: HEADERS, @@ -273,6 +278,7 @@ describe('src/background/services/wallet/handlers/avalanche_signTransaction', () transactionHex: request.params.transactionHex, chainAlias: request.params.chainAlias, isTestnet: true, + isDevnet: false, url: process.env.GLACIER_URL, token: process.env.GLACIER_API_KEY, headers: HEADERS, @@ -328,6 +334,7 @@ describe('src/background/services/wallet/handlers/avalanche_signTransaction', () transactionHex: request.params.transactionHex, chainAlias: request.params.chainAlias, isTestnet: true, + isDevnet: false, url: process.env.GLACIER_URL, token: process.env.GLACIER_API_KEY, headers: HEADERS, @@ -385,6 +392,7 @@ describe('src/background/services/wallet/handlers/avalanche_signTransaction', () transactionHex: request.params.transactionHex, chainAlias: request.params.chainAlias, isTestnet: true, + isDevnet: false, url: process.env.GLACIER_URL, token: process.env.GLACIER_API_KEY, headers: HEADERS, @@ -527,6 +535,7 @@ describe('src/background/services/wallet/handlers/avalanche_signTransaction', () transactionHex: request.params.transactionHex, chainAlias: request.params.chainAlias, isTestnet: true, + isDevnet: false, url: process.env.GLACIER_URL, token: process.env.GLACIER_API_KEY, headers: HEADERS, @@ -534,7 +543,7 @@ describe('src/background/services/wallet/handlers/avalanche_signTransaction', () }); }); - describe('(partially) signex tx', () => { + describe('(partially) signed tx', () => { const checkExpected = (req, result, signaturesMock) => { expect(result).toEqual({ ...req, @@ -716,6 +725,7 @@ describe('src/background/services/wallet/handlers/avalanche_signTransaction', () transactionHex: request.params.transactionHex, chainAlias: request.params.chainAlias, isTestnet: true, + isDevnet: false, url: process.env.GLACIER_URL, token: process.env.GLACIER_API_KEY, headers: HEADERS, @@ -780,9 +790,6 @@ describe('src/background/services/wallet/handlers/avalanche_signTransaction', () (Avalanche.signedTxToHex as jest.Mock).mockReturnValueOnce( signedTransactionHex ); - networkServiceMock.getAvalancheNetworkXP.mockReturnValueOnce( - providerMock - ); const handler = new AvalancheSignTransactionHandler( walletServiceMock as any, @@ -837,10 +844,6 @@ describe('src/background/services/wallet/handlers/avalanche_signTransaction', () (Avalanche.signedTxToHex as jest.Mock).mockReturnValueOnce( signedTransactionHex ); - networkServiceMock.getAvalancheNetworkXP.mockReturnValueOnce( - providerMock - ); - const handler = new AvalancheSignTransactionHandler( walletServiceMock as any, networkServiceMock as any, @@ -874,9 +877,6 @@ describe('src/background/services/wallet/handlers/avalanche_signTransaction', () (Avalanche.signedTxToHex as jest.Mock).mockReturnValueOnce( signedTransactionHex ); - networkServiceMock.getAvalancheNetworkXP.mockReturnValueOnce( - providerMock - ); const handler = new AvalancheSignTransactionHandler( walletServiceMock as any, @@ -913,7 +913,7 @@ describe('src/background/services/wallet/handlers/avalanche_signTransaction', () { tx: mockedTx, }, - providerMock, + AVALANCHE_XP_TEST_NETWORK, frontendTabId ); expect(signedTxMock.getCredentials).toHaveBeenCalled(); diff --git a/src/contexts/BridgeProvider.test.tsx b/src/contexts/BridgeProvider.test.tsx index 9020ad14b..dcebc6de7 100644 --- a/src/contexts/BridgeProvider.test.tsx +++ b/src/contexts/BridgeProvider.test.tsx @@ -93,7 +93,7 @@ describe('contexts/BridgeProvider', () => { symbol: 'AVAX', }, }, - avalancheProvider: { + avaxProviderC: { waitForTransaction: jest.fn(), }, ethereumProvider: { @@ -249,7 +249,7 @@ describe('contexts/BridgeProvider', () => { amount, asset: currentAssetData, account: accountsContext.accounts.active.addressC, - avalancheProvider: networkContext.avalancheProvider, + avalancheProvider: networkContext.avaxProviderC, ethereumProvider: networkContext.ethereumProvider, config: bridgeSDKContext.bridgeConfig.config, onStatusChange: expect.any(Function), @@ -300,7 +300,7 @@ describe('contexts/BridgeProvider', () => { jest.mocked(useNetworkContext).mockReturnValue({ ...networkContext, ethereumProvider: undefined, - avalancheProviderC: undefined, + avaxProviderC: undefined, }); }); @@ -337,7 +337,7 @@ describe('contexts/BridgeProvider', () => { asset, { ethereum: networkContext.ethereumProvider, - avalanche: networkContext.avalancheProvider, + avalanche: networkContext.avaxProviderC, }, bridgeSDKContext.bridgeConfig.config, bridgeSDKContext.currentBlockchain diff --git a/src/contexts/SwapProvider/SwapProvider.test.tsx b/src/contexts/SwapProvider/SwapProvider.test.tsx index 7d9424340..c501ab5c5 100644 --- a/src/contexts/SwapProvider/SwapProvider.test.tsx +++ b/src/contexts/SwapProvider/SwapProvider.test.tsx @@ -98,7 +98,7 @@ describe('contexts/SwapProvider', () => { symbol: 'AVAX', }, }, - avalancheProvider: { + avaxProviderC: { waitForTransaction: jest.fn(), }, } as any; @@ -339,7 +339,7 @@ describe('contexts/SwapProvider', () => { } as SwapParams); beforeEach(() => { - networkContext.avalancheProvider.waitForTransaction.mockResolvedValue({ + networkContext.avaxProviderC.waitForTransaction.mockResolvedValue({ status: 1, }); }); diff --git a/src/utils/network/getProviderForNetwork.test.ts b/src/utils/network/getProviderForNetwork.test.ts index 6627a8e86..0e265000b 100644 --- a/src/utils/network/getProviderForNetwork.test.ts +++ b/src/utils/network/getProviderForNetwork.test.ts @@ -93,9 +93,9 @@ describe('src/utils/network/getProviderForNetwork', () => { jest.mocked(FetchRequest).mockImplementation((url) => ({ url } as any)); }); - it('returns a json rpc provider for evm chains', () => { + it('returns a json rpc provider for evm chains', async () => { const mockEVMNetwork = mockNetwork(NetworkVMType.EVM); - const provider = getProviderForNetwork(mockEVMNetwork); + const provider = await getProviderForNetwork(mockEVMNetwork); expect(JsonRpcBatchInternal).toHaveBeenCalledTimes(1); expect(JsonRpcBatchInternal).toHaveBeenCalledWith( @@ -119,7 +119,7 @@ describe('src/utils/network/getProviderForNetwork', () => { }, }); - getProviderForNetwork(mockEVMNetwork); + await getProviderForNetwork(mockEVMNetwork); expect(fetchConfig.setHeader).toHaveBeenCalledTimes(1); expect(fetchConfig.setHeader).toHaveBeenCalledWith( @@ -135,9 +135,9 @@ describe('src/utils/network/getProviderForNetwork', () => { ); }); - it('uses multicall when requested', () => { + it('uses multicall when requested', async () => { const mockEVMNetwork = mockNetwork(NetworkVMType.EVM); - const provider = getProviderForNetwork( + const provider = await getProviderForNetwork( { ...mockEVMNetwork, utilityAddresses: { @@ -159,13 +159,13 @@ describe('src/utils/network/getProviderForNetwork', () => { ); }); - it('adds glacier api key for glacier urls', () => { + it('adds glacier api key for glacier urls', async () => { (addGlacierAPIKeyIfNeeded as jest.Mock).mockReturnValue( 'https://urlwithglacierkey.example' ); const mockEVMNetwork = mockNetwork(NetworkVMType.EVM); - const provider = getProviderForNetwork(mockEVMNetwork); + const provider = await getProviderForNetwork(mockEVMNetwork); expect(provider).toBe(mockJsonRpcBatchInternalInstance); expect(addGlacierAPIKeyIfNeeded).toHaveBeenCalledWith( @@ -179,8 +179,8 @@ describe('src/utils/network/getProviderForNetwork', () => { ); }); - it('returns bitcoin provider for BTC testnet', () => { - const provider = getProviderForNetwork( + it('returns bitcoin provider for BTC testnet', async () => { + const provider = await getProviderForNetwork( decorateWithCaipId(BITCOIN_TEST_NETWORK) ); @@ -195,8 +195,10 @@ describe('src/utils/network/getProviderForNetwork', () => { ); }); - it('returns bitcoin provider for BTC mainnet', () => { - const provider = getProviderForNetwork(decorateWithCaipId(BITCOIN_NETWORK)); + it('returns bitcoin provider for BTC mainnet', async () => { + const provider = await getProviderForNetwork( + decorateWithCaipId(BITCOIN_NETWORK) + ); expect(provider).toBe(mockBitcoinProviderInstance); expect(BitcoinProvider).toHaveBeenCalledTimes(1); @@ -209,9 +211,9 @@ describe('src/utils/network/getProviderForNetwork', () => { ); }); - it('returns fuji provider for X-Chain test network', () => { + it('returns fuji provider for X-Chain test network', async () => { const mockAVMNetwork = mockNetwork(NetworkVMType.AVM); - const provider = getProviderForNetwork(mockAVMNetwork); + const provider = await getProviderForNetwork(mockAVMNetwork); expect(provider).toBe(mockFujiProviderInstance); expect( @@ -219,9 +221,9 @@ describe('src/utils/network/getProviderForNetwork', () => { ).toHaveBeenCalledTimes(1); }); - it('returns mainnet provider for X-Chain network', () => { + it('returns mainnet provider for X-Chain network', async () => { const mockAVMNetwork = mockNetwork(NetworkVMType.AVM, false); - const provider = getProviderForNetwork(mockAVMNetwork); + const provider = await getProviderForNetwork(mockAVMNetwork); expect(provider).toBe(mockMainnetProviderInstance); expect( @@ -229,9 +231,9 @@ describe('src/utils/network/getProviderForNetwork', () => { ).toHaveBeenCalledTimes(1); }); - it('returns fuji provider for P-Chain test network', () => { + it('returns fuji provider for P-Chain test network', async () => { const mockAVMNetwork = mockNetwork(NetworkVMType.PVM); - const provider = getProviderForNetwork(mockAVMNetwork); + const provider = await getProviderForNetwork(mockAVMNetwork); expect(provider).toBe(mockFujiProviderInstance); expect( @@ -239,9 +241,9 @@ describe('src/utils/network/getProviderForNetwork', () => { ).toHaveBeenCalledTimes(1); }); - it('returns mainnet provider for P-Chain network', () => { + it('returns mainnet provider for P-Chain network', async () => { const mockAVMNetwork = mockNetwork(NetworkVMType.PVM, false); - const provider = getProviderForNetwork(mockAVMNetwork); + const provider = await getProviderForNetwork(mockAVMNetwork); expect(provider).toBe(mockMainnetProviderInstance); expect( @@ -249,13 +251,13 @@ describe('src/utils/network/getProviderForNetwork', () => { ).toHaveBeenCalledTimes(1); }); - it('returns error when VM is not supported', () => { - const mockEVMNetwork = mockNetwork(NetworkVMType.EVM); - expect(() => { - getProviderForNetwork({ - ...mockEVMNetwork, - vmName: 'CRAPPYVM' as unknown as NetworkVMType, - }); - }).toThrow(new Error('unsupported network')); - }); + // it('returns error when VM is not supported', () => { + // const mockEVMNetwork = mockNetwork(NetworkVMType.EVM); + // expect(() => { + // getProviderForNetwork({ + // ...mockEVMNetwork, + // vmName: 'CRAPPYVM' as unknown as NetworkVMType, + // }); + // }).toThrow(new Error('unsupported network')); + // }); }); diff --git a/webpack.alpha.js b/webpack.alpha.js index df9131016..02488f012 100644 --- a/webpack.alpha.js +++ b/webpack.alpha.js @@ -15,11 +15,10 @@ module.exports = merge(prod, { from: '**/*.json', to: '../', transform: transformManifestFiles({ - name: 'Core ETNA BUILD', + name: 'Core Beta DEVELOPMENT BUILD', shortName: 'Core Beta', - actionDefaultTitle: 'Core Beta Browser Extension ETNA BUILD', + actionDefaultTitle: 'Core Beta Browser Extension DEVELOPMENT BUILD', oAuthClientId: process.env.GOOGLE_OAUTH_CLIENT_ID, - publicKey: process.env.EXTENSION_PUBLIC_KEY, }), force: true, }, From e3d6e663bcf7523ba78a2791fc04764243250289 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Leszczyk?= Date: Mon, 4 Nov 2024 13:59:23 +0100 Subject: [PATCH 06/16] chore: some refactors, missing tests added --- .../balances/BalanceAggregatorService.test.ts | 68 +++++++++++++++ .../avalanche_sendTransaction.test.ts | 35 ++++++++ src/contexts/NetworkProvider.tsx | 86 ++----------------- src/hooks/useAvalancheCProvider.ts | 36 ++++++++ src/hooks/useBitcoinProvider.ts | 36 ++++++++ src/hooks/useEthereumProvider.ts | 36 ++++++++ src/pages/Send/utils/getMaxUtxos.test.ts | 70 +++++++++++++++ 7 files changed, 287 insertions(+), 80 deletions(-) create mode 100644 src/hooks/useAvalancheCProvider.ts create mode 100644 src/hooks/useBitcoinProvider.ts create mode 100644 src/hooks/useEthereumProvider.ts create mode 100644 src/pages/Send/utils/getMaxUtxos.test.ts diff --git a/src/background/services/balances/BalanceAggregatorService.test.ts b/src/background/services/balances/BalanceAggregatorService.test.ts index 957c4ddae..9816a855d 100644 --- a/src/background/services/balances/BalanceAggregatorService.test.ts +++ b/src/background/services/balances/BalanceAggregatorService.test.ts @@ -414,5 +414,73 @@ describe('src/background/services/balances/BalanceAggregatorService.ts', () => { expect(balances).toEqual(freshBalances); }); + + it.only('emits the BalanceServiceEvents.UPDATED if balances did change', async () => { + // Cached balances include two accounts: account1, account2 + const cachedBalances = { + [network2.chainId]: { + ...balanceForNetwork2, + [account2.addressC]: network1TokenBalance, + }, + }; + + (storageService.load as jest.Mock).mockResolvedValue({ + balances: cachedBalances, + }); + + await service.onUnlock(); + + // Fresh balances include only one account (account2) and the values for it HAVE changed + balancesServiceMock.getBalancesForNetwork.mockResolvedValueOnce({ + [account2.addressC]: { + [networkToken2.symbol]: { + ...network1TokenBalance, + balance: 200n, + balanceDisplayValue: '0.00002', + }, + }, + }); + + const updatesListener = jest.fn(); + service.addListener(BalanceServiceEvents.UPDATED, updatesListener); + + await service.getBalancesForNetworks([network2.chainId], [account2], []); + await new Promise(process.nextTick); + + // The fresh balances include new information, therefore an event should be emitted. + expect(updatesListener).toHaveBeenCalled(); + }); + + it.only('DOES NOT emit the BalanceServiceEvents.UPDATED if balances did not change', async () => { + // Cached balances include two accounts: account1, account2 + const cachedBalances = { + [network2.chainId]: { + ...balanceForNetwork2, + [account2.addressC]: balanceForNetwork1, + }, + }; + + (storageService.load as jest.Mock).mockResolvedValue({ + balances: cachedBalances, + }); + + await service.onUnlock(); + + // Fresh balances include only one account (account1) and the values for it DID NOT change + balancesServiceMock.getBalancesForNetwork.mockResolvedValueOnce( + balanceForNetwork2 + ); + + const updatesListener = jest.fn(); + service.addListener(BalanceServiceEvents.UPDATED, updatesListener); + + await service.getBalancesForNetworks([network2.chainId], [account1], []); + await new Promise(process.nextTick); + + // Cached & fresh balances as a whole are different, + // but the fresh balances do not include any new information, + // therefore no event should be emitted. + expect(updatesListener).not.toHaveBeenCalled(); + }); }); }); diff --git a/src/background/services/wallet/handlers/avalanche_sendTransaction.test.ts b/src/background/services/wallet/handlers/avalanche_sendTransaction.test.ts index 311455769..b43a392e0 100644 --- a/src/background/services/wallet/handlers/avalanche_sendTransaction.test.ts +++ b/src/background/services/wallet/handlers/avalanche_sendTransaction.test.ts @@ -7,6 +7,7 @@ import { AVM, utils, EVM, + PVM, } from '@avalabs/avalanchejs'; import { DEFERRED_RESPONSE } from '@src/background/connections/middlewares/models'; import { Action } from '../../actions/models'; @@ -309,6 +310,40 @@ describe('src/background/services/wallet/handlers/avalanche_sendTransaction.ts', checkExpected(requestWithUtxos, result, tx); }); + it('passes feeTolerance to the parsing util', async () => { + const tx = { vm: PVM }; + (utils.unpackWithManager as jest.Mock).mockReturnValueOnce(tx); + getAddressesByIndicesMock.mockResolvedValue([]); + (Avalanche.parseAvalancheTx as jest.Mock).mockReturnValueOnce({ + type: 'import', + }); + (utils.parse as jest.Mock).mockReturnValueOnce([ + undefined, + undefined, + new Uint8Array([0, 1, 2]), + ]); + ( + Avalanche.createAvalancheUnsignedTx as jest.Mock + ).mockReturnValueOnce(unsignedTxMock); + + await handler.handleAuthenticated( + buildRpcCall({ + ...request, + params: { + ...request.params, + feeTolerance: 25, + }, + }) + ); + + expect(Avalanche.parseAvalancheTx).toHaveBeenCalledWith( + unsignedTxMock, + providerMock, + expect.anything(), + { feeTolerance: 25 } + ); + }); + it('works without provided UTXOs', async () => { const tx = { vm: AVM }; (utils.unpackWithManager as jest.Mock).mockReturnValueOnce(tx); diff --git a/src/contexts/NetworkProvider.tsx b/src/contexts/NetworkProvider.tsx index 49205851a..70ba52bc1 100644 --- a/src/contexts/NetworkProvider.tsx +++ b/src/contexts/NetworkProvider.tsx @@ -1,6 +1,4 @@ import { - Dispatch, - SetStateAction, createContext, useCallback, useContext, @@ -11,7 +9,6 @@ import { import { useConnectionContext } from './ConnectionProvider'; import { filter, map } from 'rxjs'; import { ExtensionRequest } from '@src/background/connections/extensionConnection/models'; -import { ChainId } from '@avalabs/core-chains-sdk'; import { networksUpdatedEventListener } from '@src/background/services/network/events/networksUpdatedEventListener'; import { useAnalyticsContext } from './AnalyticsProvider'; import { SetDevelopermodeNetworkHandler } from '@src/background/services/network/handlers/setDeveloperMode'; @@ -22,7 +19,6 @@ import { SaveCustomNetworkHandler } from '@src/background/services/network/handl import { AddFavoriteNetworkHandler } from '@src/background/services/network/handlers/addFavoriteNetwork'; import { UpdateDefaultNetworkHandler } from '@src/background/services/network/handlers/updateDefaultNetwork'; import { - Avalanche, BitcoinProvider, JsonRpcBatchInternal, } from '@avalabs/core-wallets-sdk'; @@ -32,13 +28,14 @@ import { NetworkOverrides, NetworkWithCaipId, } from '@src/background/services/network/models'; -import { getProviderForNetwork } from '@src/utils/network/getProviderForNetwork'; import { isNetworkUpdatedEvent } from '@src/background/services/network/events/isNetworkUpdatedEvent'; import { SetActiveNetworkHandler } from '@src/background/services/network/handlers/setActiveNetwork'; import { updateIfDifferent } from '@src/utils/updateIfDifferent'; import { getNetworkCaipId } from '@src/utils/caipConversion'; -import { isDevnet } from '@src/utils/isDevnet'; import { networkChanged } from './NetworkProvider/networkChanges'; +import { useBitcoinProvider } from '@src/hooks/useBitcoinProvider'; +import { useEthereumProvider } from '@src/hooks/useEthereumProvider'; +import { useAvalancheCProvider } from '@src/hooks/useAvalancheCProvider'; const NetworkContext = createContext<{ network?: NetworkWithCaipId | undefined; @@ -58,7 +55,6 @@ const NetworkContext = createContext<{ isChainIdExist(chainId: number): boolean; getNetwork(chainId: number | string): NetworkWithCaipId | undefined; avaxProviderC?: JsonRpcBatchInternal; - avaxProviderP?: Avalanche.JsonRpcProvider; ethereumProvider?: JsonRpcBatchInternal; bitcoinProvider?: BitcoinProvider; }>({} as any); @@ -118,78 +114,9 @@ export function NetworkContextProvider({ children }: { children: any }) { [networks] ); - const [bitcoinProvider, setBitcoinProvider] = useState(); - const [ethereumProvider, setEthereumProvider] = - useState(); - const [avaxProviderC, setAvaxProviderC] = useState(); - const [avaxProviderP, setAvaxProviderP] = - useState(); - - useEffect(() => { - if (!network) { - setBitcoinProvider(undefined); - setEthereumProvider(undefined); - setAvaxProviderC(undefined); - setAvaxProviderP(undefined); - return; - } - - let isMounted = true; - - const avaxNetworkC = getNetwork( - network.isTestnet - ? ChainId.AVALANCHE_TESTNET_ID - : ChainId.AVALANCHE_MAINNET_ID - ); - const avaxNetworkP = getNetwork( - isDevnet(network) - ? ChainId.AVALANCHE_DEVNET_P - : network.isTestnet - ? ChainId.AVALANCHE_TEST_P - : ChainId.AVALANCHE_P - ); - const ethNetwork = getNetwork( - network.isTestnet - ? ChainId.ETHEREUM_TEST_SEPOLIA - : ChainId.ETHEREUM_HOMESTEAD - ); - const btcNetwork = getNetwork( - network.isTestnet ? ChainId.BITCOIN_TESTNET : ChainId.BITCOIN - ); - - function updateIfMounted(setter: Dispatch>) { - return (p) => { - if (isMounted) { - setter(p); - } - }; - } - - if (avaxNetworkC) { - getProviderForNetwork(avaxNetworkC).then( - updateIfMounted(setAvaxProviderC) - ); - } - if (avaxNetworkP) { - getProviderForNetwork(avaxNetworkP).then( - updateIfMounted(setAvaxProviderP) - ); - } - if (ethNetwork) { - getProviderForNetwork(ethNetwork).then( - updateIfMounted(setEthereumProvider) - ); - } - if (btcNetwork) { - getProviderForNetwork(btcNetwork).then( - updateIfMounted(setBitcoinProvider) - ); - } - - return () => { - isMounted = false; - }; - }, [getNetwork, network]); + const bitcoinProvider = useBitcoinProvider(Boolean(network?.isTestnet)); + const ethereumProvider = useEthereumProvider(Boolean(network?.isTestnet)); + const avaxProviderC = useAvalancheCProvider(Boolean(network?.isTestnet)); const getNetworkState = useCallback(() => { return request({ @@ -317,7 +244,6 @@ export function NetworkContextProvider({ children }: { children: any }) { isChainIdExist, getNetwork, avaxProviderC, - avaxProviderP, bitcoinProvider, ethereumProvider, }} diff --git a/src/hooks/useAvalancheCProvider.ts b/src/hooks/useAvalancheCProvider.ts new file mode 100644 index 000000000..405085fad --- /dev/null +++ b/src/hooks/useAvalancheCProvider.ts @@ -0,0 +1,36 @@ +import { useEffect, useState } from 'react'; +import { ChainId } from '@avalabs/core-chains-sdk'; +import { JsonRpcBatchInternal } from '@avalabs/core-wallets-sdk'; + +import { useNetworkContext } from '@src/contexts/NetworkProvider'; +import { getProviderForNetwork } from '@src/utils/network/getProviderForNetwork'; + +export const useAvalancheCProvider = (isTestnet) => { + const { getNetwork } = useNetworkContext(); + + const [provider, setProvider] = useState(); + + useEffect(() => { + const cChain = getNetwork( + isTestnet ? ChainId.AVALANCHE_MAINNET_ID : ChainId.AVALANCHE_TESTNET_ID + ); + + if (!cChain) { + return; + } + + let isMounted = true; + + getProviderForNetwork(cChain).then((cChainProvider) => { + if (isMounted && cChainProvider instanceof JsonRpcBatchInternal) { + setProvider(cChainProvider); + } + }); + + return () => { + isMounted = false; + }; + }); + + return provider; +}; diff --git a/src/hooks/useBitcoinProvider.ts b/src/hooks/useBitcoinProvider.ts new file mode 100644 index 000000000..1b6a65775 --- /dev/null +++ b/src/hooks/useBitcoinProvider.ts @@ -0,0 +1,36 @@ +import { useEffect, useState } from 'react'; +import { ChainId } from '@avalabs/core-chains-sdk'; +import { BitcoinProvider } from '@avalabs/core-wallets-sdk'; + +import { useNetworkContext } from '@src/contexts/NetworkProvider'; +import { getProviderForNetwork } from '@src/utils/network/getProviderForNetwork'; + +export const useBitcoinProvider = (isTestnet) => { + const { getNetwork } = useNetworkContext(); + + const [provider, setProvider] = useState(); + + useEffect(() => { + const btcNetwork = getNetwork( + isTestnet ? ChainId.BITCOIN_TESTNET : ChainId.BITCOIN + ); + + if (!btcNetwork) { + return; + } + + let isMounted = true; + + getProviderForNetwork(btcNetwork).then((bitcoinProvider) => { + if (isMounted && bitcoinProvider instanceof BitcoinProvider) { + setProvider(bitcoinProvider); + } + }); + + return () => { + isMounted = false; + }; + }); + + return provider; +}; diff --git a/src/hooks/useEthereumProvider.ts b/src/hooks/useEthereumProvider.ts new file mode 100644 index 000000000..ae139f5cf --- /dev/null +++ b/src/hooks/useEthereumProvider.ts @@ -0,0 +1,36 @@ +import { useEffect, useState } from 'react'; +import { ChainId } from '@avalabs/core-chains-sdk'; +import { JsonRpcBatchInternal } from '@avalabs/core-wallets-sdk'; + +import { useNetworkContext } from '@src/contexts/NetworkProvider'; +import { getProviderForNetwork } from '@src/utils/network/getProviderForNetwork'; + +export const useEthereumProvider = (isTestnet) => { + const { getNetwork } = useNetworkContext(); + + const [provider, setProvider] = useState(); + + useEffect(() => { + const ethNetwork = getNetwork( + isTestnet ? ChainId.ETHEREUM_TEST_SEPOLIA : ChainId.ETHEREUM_HOMESTEAD + ); + + if (!ethNetwork) { + return; + } + + let isMounted = true; + + getProviderForNetwork(ethNetwork).then((ethProvider) => { + if (isMounted && ethProvider instanceof JsonRpcBatchInternal) { + setProvider(ethProvider); + } + }); + + return () => { + isMounted = false; + }; + }); + + return provider; +}; diff --git a/src/pages/Send/utils/getMaxUtxos.test.ts b/src/pages/Send/utils/getMaxUtxos.test.ts new file mode 100644 index 000000000..096e89f60 --- /dev/null +++ b/src/pages/Send/utils/getMaxUtxos.test.ts @@ -0,0 +1,70 @@ +import { Avalanche } from '@avalabs/core-wallets-sdk'; +import { getMaxUtxoSet } from './getMaxUtxos'; +import { AVALANCHE_P_DEV_NETWORK } from '@avalabs/core-chains-sdk'; +import { ethErrors } from 'eth-rpc-errors'; +import { CommonError } from '@src/utils/errors'; + +jest.mock('@avalabs/core-wallets-sdk'); + +describe('src/pages/Send/utils/getMaxUtxos', () => { + const getUTXOs = jest.fn(); + + const mockedWallet = { + getUTXOs, + } as any; + + beforeEach(() => { + jest.spyOn(Avalanche, 'getMaximumUtxoSet').mockReturnValue([]); + jest.spyOn(Avalanche, 'sortUTXOsByAmount'); + + getUTXOs.mockResolvedValue({ + getUTXOs: () => [], + }); + }); + + it('requires feeState for post-Etna transactions', async () => { + const provider = { + isEtnaEnabled: jest.fn().mockReturnValue(true), + } as any; + + try { + await getMaxUtxoSet( + false, + provider, + mockedWallet, + AVALANCHE_P_DEV_NETWORK + ); + fail('The call above should have failed'); + } catch (err) { + expect(err).toEqual( + ethErrors.rpc.internal({ + data: { reason: CommonError.UnknownNetworkFee }, + }) + ); + } + }); + + it('passes feeState to the SDK call', async () => { + const provider = { + isEtnaEnabled: jest.fn().mockReturnValue(true), + getAvaxID: () => 'avax-id', + } as any; + const feeState = { price: 2n } as any; + + await getMaxUtxoSet( + false, + provider, + mockedWallet, + AVALANCHE_P_DEV_NETWORK, + feeState + ); + + expect(Avalanche.getMaximumUtxoSet).toHaveBeenCalledWith({ + wallet: mockedWallet, + utxos: [], + sizeSupportedTx: Avalanche.SizeSupportedTx.BaseP, + limit: undefined, + feeState, + }); + }); +}); From daa3db016f79f95e984c505352955eec06ba5766 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Leszczyk?= Date: Thu, 7 Nov 2024 10:28:13 +0100 Subject: [PATCH 07/16] chore: update avalanchejs --- package.json | 24 ++-- .../network/getProviderForNetwork.test.ts | 18 +-- src/utils/network/getProviderForNetwork.ts | 4 +- yarn.lock | 121 ++++++++++++++---- 4 files changed, 121 insertions(+), 46 deletions(-) diff --git a/package.json b/package.json index 16925ebd5..f847d16a5 100644 --- a/package.json +++ b/package.json @@ -24,23 +24,23 @@ }, "dependencies": { "@avalabs/avalanche-module": "0.0.0-feat-p-dynamic-fees-20241031151758", - "@avalabs/avalanchejs": "4.1.0-alpha.7", + "@avalabs/avalanchejs": "4.1.0-alpha.15", "@avalabs/bitcoin-module": "0.0.0-feat-p-dynamic-fees-20241031151758", "@avalabs/bridge-unified": "0.0.0-feat-ictt-configs-20241009072139", - "@avalabs/core-bridge-sdk": "3.1.0-canary.d762cf9.0+d762cf9", - "@avalabs/core-chains-sdk": "3.1.0-canary.d762cf9.0+d762cf9", - "@avalabs/core-coingecko-sdk": "3.1.0-canary.d762cf9.0+d762cf9", - "@avalabs/core-covalent-sdk": "3.1.0-canary.d762cf9.0+d762cf9", - "@avalabs/core-etherscan-sdk": "3.1.0-canary.d762cf9.0+d762cf9", + "@avalabs/core-bridge-sdk": "3.1.0-canary.78916bb.0+78916bb", + "@avalabs/core-chains-sdk": "3.1.0-canary.78916bb.0+78916bb", + "@avalabs/core-coingecko-sdk": "3.1.0-canary.78916bb.0+78916bb", + "@avalabs/core-covalent-sdk": "3.1.0-canary.78916bb.0+78916bb", + "@avalabs/core-etherscan-sdk": "3.1.0-canary.78916bb.0+78916bb", "@avalabs/core-k2-components": "4.18.0-alpha.47", - "@avalabs/core-snowtrace-sdk": "3.1.0-canary.d762cf9.0+d762cf9", - "@avalabs/core-token-prices-sdk": "3.1.0-canary.d762cf9.0+d762cf9", - "@avalabs/core-utils-sdk": "3.1.0-canary.d762cf9.0+d762cf9", - "@avalabs/core-wallets-sdk": "3.1.0-canary.d762cf9.0+d762cf9", + "@avalabs/core-snowtrace-sdk": "3.1.0-canary.78916bb.0+78916bb", + "@avalabs/core-token-prices-sdk": "3.1.0-canary.78916bb.0+78916bb", + "@avalabs/core-utils-sdk": "3.1.0-canary.78916bb.0+78916bb", + "@avalabs/core-wallets-sdk": "3.1.0-canary.78916bb.0+78916bb", "@avalabs/evm-module": "0.0.0-feat-p-dynamic-fees-20241031151758", - "@avalabs/glacier-sdk": "3.1.0-canary.d762cf9.0+d762cf9", + "@avalabs/glacier-sdk": "3.1.0-canary.78916bb.0+78916bb", "@avalabs/hw-app-avalanche": "0.14.1", - "@avalabs/types": "3.1.0-canary.d762cf9.0+d762cf9", + "@avalabs/types": "3.1.0-canary.78916bb.0+78916bb", "@avalabs/vm-module-types": "0.0.0-feat-p-dynamic-fees-20241031151758", "@blockaid/client": "0.10.0", "@coinbase/cbpay-js": "1.6.0", diff --git a/src/utils/network/getProviderForNetwork.test.ts b/src/utils/network/getProviderForNetwork.test.ts index 0e265000b..2aa40d8ce 100644 --- a/src/utils/network/getProviderForNetwork.test.ts +++ b/src/utils/network/getProviderForNetwork.test.ts @@ -251,13 +251,13 @@ describe('src/utils/network/getProviderForNetwork', () => { ).toHaveBeenCalledTimes(1); }); - // it('returns error when VM is not supported', () => { - // const mockEVMNetwork = mockNetwork(NetworkVMType.EVM); - // expect(() => { - // getProviderForNetwork({ - // ...mockEVMNetwork, - // vmName: 'CRAPPYVM' as unknown as NetworkVMType, - // }); - // }).toThrow(new Error('unsupported network')); - // }); + it('returns error when VM is not supported', async () => { + const mockEVMNetwork = mockNetwork(NetworkVMType.EVM); + await expect( + getProviderForNetwork({ + ...mockEVMNetwork, + vmName: 'CRAPPYVM' as unknown as NetworkVMType, + }) + ).rejects.toThrow(new Error('unsupported network')); + }); }); diff --git a/src/utils/network/getProviderForNetwork.ts b/src/utils/network/getProviderForNetwork.ts index c5923ae70..7d224c171 100644 --- a/src/utils/network/getProviderForNetwork.ts +++ b/src/utils/network/getProviderForNetwork.ts @@ -5,7 +5,7 @@ import { } from '@avalabs/core-wallets-sdk'; import { NetworkVMType } from '@avalabs/core-chains-sdk'; import { FetchRequest, Network as EthersNetwork } from 'ethers'; -import { Info } from '@avalabs/avalanchejs'; +import { info } from '@avalabs/avalanchejs'; import { Network } from '@src/background/services/network/models'; @@ -64,7 +64,7 @@ export const getProviderForNetwork = async ( network.vmName === NetworkVMType.AVM || network.vmName === NetworkVMType.PVM ) { - const upgradesInfo = await new Info(network.rpcUrl) + const upgradesInfo = await new info.InfoApi(network.rpcUrl) .getUpgradesInfo() .catch(() => undefined); diff --git a/yarn.lock b/yarn.lock index 463a30eb8..4d14df09e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -48,6 +48,17 @@ bn.js "5.2.1" zod "3.23.8" +"@avalabs/avalanchejs@4.1.0-alpha.15": + version "4.1.0-alpha.15" + resolved "https://registry.yarnpkg.com/@avalabs/avalanchejs/-/avalanchejs-4.1.0-alpha.15.tgz#4ce13f65eefe95b1673c7f0dc84da6e1551b652d" + integrity sha512-85jq9MmG81MXzeCnvIwEvlXougzM27SZ2Ic4IIGLA7LpryH4I1oXh70aGmnNvpae+hOjsch6cQ24t+gvJuMFoA== + dependencies: + "@noble/curves" "1.3.0" + "@noble/hashes" "1.3.3" + "@noble/secp256k1" "2.0.0" + "@scure/base" "1.1.5" + micro-eth-signer "0.7.2" + "@avalabs/avalanchejs@4.1.0-alpha.7": version "4.1.0-alpha.7" resolved "https://registry.yarnpkg.com/@avalabs/avalanchejs/-/avalanchejs-4.1.0-alpha.7.tgz#480a4bf29abd78833ca759cbc23387e750e4fbd5" @@ -86,14 +97,21 @@ viem "2.11.1" zod "3.23.8" -"@avalabs/core-bridge-sdk@3.1.0-canary.d762cf9.0+d762cf9": - version "3.1.0-canary.d762cf9.0" - resolved "https://registry.yarnpkg.com/@avalabs/core-bridge-sdk/-/core-bridge-sdk-3.1.0-canary.d762cf9.0.tgz#c1440c49a67f2f83e6b73ef08928b6b670d99b09" - integrity sha512-ia20a5HibJimFw+lfNvqvM21zOWlhpAC4kTCJWcfwGn0L/HebSDEjQ/ZNBsv/0uoP9sF8EjUNkFLCAnH1CLfgg== +"@avalabs/core-bridge-sdk@3.1.0-canary.78916bb.0+78916bb": + version "3.1.0-canary.78916bb.0" + resolved "https://registry.yarnpkg.com/@avalabs/core-bridge-sdk/-/core-bridge-sdk-3.1.0-canary.78916bb.0.tgz#7283ab66e0eeb3ca0fe92f62c08708809de65df0" + integrity sha512-5mr02Gt3vrEwLNQirqNDAQE55n6KOf3QVApt4F9GGpIYCN1YwLri8SBhKKyP/m34rMjha79a5mPno5LtqPdnmA== dependencies: - "@avalabs/core-coingecko-sdk" "3.1.0-canary.d762cf9.0+d762cf9" - "@avalabs/core-utils-sdk" "3.1.0-canary.d762cf9.0+d762cf9" - "@avalabs/core-wallets-sdk" "3.1.0-canary.d762cf9.0+d762cf9" + "@avalabs/core-coingecko-sdk" "3.1.0-canary.78916bb.0+78916bb" + "@avalabs/core-utils-sdk" "3.1.0-canary.78916bb.0+78916bb" + "@avalabs/core-wallets-sdk" "3.1.0-canary.78916bb.0+78916bb" + +"@avalabs/core-chains-sdk@3.1.0-canary.78916bb.0+78916bb": + version "3.1.0-canary.78916bb.0" + resolved "https://registry.yarnpkg.com/@avalabs/core-chains-sdk/-/core-chains-sdk-3.1.0-canary.78916bb.0.tgz#b189febf28a70906e5592768b2bef6ef164b52e6" + integrity sha512-PbApSvgSc1jvCghm1oohd5dbYRSuRtz3hqnF52nklHv28LMJYYBGS9EZBY/2w8EBfzOtTSiiAbAA42PBYfg/cg== + dependencies: + "@avalabs/core-utils-sdk" "3.1.0-canary.78916bb.0+78916bb" "@avalabs/core-chains-sdk@3.1.0-canary.d762cf9.0+d762cf9": version "3.1.0-canary.d762cf9.0" @@ -102,6 +120,13 @@ dependencies: "@avalabs/core-utils-sdk" "3.1.0-canary.d762cf9.0+d762cf9" +"@avalabs/core-coingecko-sdk@3.1.0-canary.78916bb.0+78916bb": + version "3.1.0-canary.78916bb.0" + resolved "https://registry.yarnpkg.com/@avalabs/core-coingecko-sdk/-/core-coingecko-sdk-3.1.0-canary.78916bb.0.tgz#ba2f5813a4da8a81ed3b365dbb41244042276ce0" + integrity sha512-qT+4HAga6sP9cytYkt0z/m4s7gZTlaE9MBmMef/RzQ0Az1eu4ovjDErg4zfDg/Rwtn7PefhXIXYr4/3p++jK/A== + dependencies: + "@avalabs/core-utils-sdk" "3.1.0-canary.78916bb.0+78916bb" + "@avalabs/core-coingecko-sdk@3.1.0-canary.d762cf9.0+d762cf9": version "3.1.0-canary.d762cf9.0" resolved "https://registry.yarnpkg.com/@avalabs/core-coingecko-sdk/-/core-coingecko-sdk-3.1.0-canary.d762cf9.0.tgz#81d117b80e10d418dde721d73cbbcf4dc834cd12" @@ -109,12 +134,19 @@ dependencies: "@avalabs/core-utils-sdk" "3.1.0-canary.d762cf9.0+d762cf9" -"@avalabs/core-covalent-sdk@3.1.0-canary.d762cf9.0+d762cf9": - version "3.1.0-canary.d762cf9.0" - resolved "https://registry.yarnpkg.com/@avalabs/core-covalent-sdk/-/core-covalent-sdk-3.1.0-canary.d762cf9.0.tgz#da4f57bdb7e2f9398a276c4365611534e66e4fd8" - integrity sha512-lnxNM5saGedWbm9/wHiVP9AI+F2On3ElQgI/XLfgfotEjc+5yCSyT5WZXfNJBcwjOVP2wNggskv5FDHhoQWOdA== +"@avalabs/core-covalent-sdk@3.1.0-canary.78916bb.0+78916bb": + version "3.1.0-canary.78916bb.0" + resolved "https://registry.yarnpkg.com/@avalabs/core-covalent-sdk/-/core-covalent-sdk-3.1.0-canary.78916bb.0.tgz#ffcc021a83ef03987cdd88195cb15fab37383b18" + integrity sha512-Z0D0F6TGDSdRnm+KmFX4vK8OyLKSUi5ZJXTIYyHuubT9m/g16k0MzLPw/0PSh71ijb15vO7YUM9DAHclV4ZFIw== dependencies: - "@avalabs/core-utils-sdk" "3.1.0-canary.d762cf9.0+d762cf9" + "@avalabs/core-utils-sdk" "3.1.0-canary.78916bb.0+78916bb" + +"@avalabs/core-etherscan-sdk@3.1.0-canary.78916bb.0+78916bb": + version "3.1.0-canary.78916bb.0" + resolved "https://registry.yarnpkg.com/@avalabs/core-etherscan-sdk/-/core-etherscan-sdk-3.1.0-canary.78916bb.0.tgz#f4a0513d3827f147c1b0521f0539687acab5aba2" + integrity sha512-ReIs3LZldZgcqu9LU29BYXN6N1JqgebYc2G+8gb2jP+gFSrCZrMvfNXRfeSAhe1Rg2toer9CFZj4svaBxuAkQQ== + dependencies: + "@avalabs/core-utils-sdk" "3.1.0-canary.78916bb.0+78916bb" "@avalabs/core-etherscan-sdk@3.1.0-canary.d762cf9.0+d762cf9": version "3.1.0-canary.d762cf9.0" @@ -146,20 +178,29 @@ react-hotkeys-hook "4.4.3" uuid "9.0.1" -"@avalabs/core-snowtrace-sdk@3.1.0-canary.d762cf9.0+d762cf9": - version "3.1.0-canary.d762cf9.0" - resolved "https://registry.yarnpkg.com/@avalabs/core-snowtrace-sdk/-/core-snowtrace-sdk-3.1.0-canary.d762cf9.0.tgz#af03e0ebd32e746b53174c77225bc39d3deca896" - integrity sha512-bnmnGv3LyidBXE+c5/ICziOKobnJbMznJ+/vR4lZRuMDfedGqZJUdhjiX3jhtpUq6HJh3waAZ8GQa1i/t2vQNw== +"@avalabs/core-snowtrace-sdk@3.1.0-canary.78916bb.0+78916bb": + version "3.1.0-canary.78916bb.0" + resolved "https://registry.yarnpkg.com/@avalabs/core-snowtrace-sdk/-/core-snowtrace-sdk-3.1.0-canary.78916bb.0.tgz#898acc85dc34c24377658cf05efca27bf67b211e" + integrity sha512-XyFsov84bf70bdP6QLtXqikRmWA6hzI7RTf8tUAN6excaIFCqXZrPZyYNs6DKFVjyzJe8W71xSPFzauh16Uu8A== dependencies: - "@avalabs/core-utils-sdk" "3.1.0-canary.d762cf9.0+d762cf9" + "@avalabs/core-utils-sdk" "3.1.0-canary.78916bb.0+78916bb" -"@avalabs/core-token-prices-sdk@3.1.0-canary.d762cf9.0+d762cf9": - version "3.1.0-canary.d762cf9.0" - resolved "https://registry.yarnpkg.com/@avalabs/core-token-prices-sdk/-/core-token-prices-sdk-3.1.0-canary.d762cf9.0.tgz#5a2c1248c42f839327d5f609f726a1afd6099010" - integrity sha512-LTl5JqlWJkY4reH+DxEv+E2zwPvKw8h0d0xfQgQP58HyOzwb+xxbTwtfUHZix4dKPJIIWwgTEc8jdtW+ETKiJQ== +"@avalabs/core-token-prices-sdk@3.1.0-canary.78916bb.0+78916bb": + version "3.1.0-canary.78916bb.0" + resolved "https://registry.yarnpkg.com/@avalabs/core-token-prices-sdk/-/core-token-prices-sdk-3.1.0-canary.78916bb.0.tgz#a7fb97893c97c2867118ef6e5f944adde2cdbc44" + integrity sha512-e4BH3kpXOX72iL/934UxhC7CjtGkET4pS2lN0OsvcL2oYLWwe/HvfTEVaVfsPZUpd9q1d9n1lBEjy8r2XRf3QA== dependencies: - "@avalabs/core-coingecko-sdk" "3.1.0-canary.d762cf9.0+d762cf9" - "@avalabs/core-utils-sdk" "3.1.0-canary.d762cf9.0+d762cf9" + "@avalabs/core-coingecko-sdk" "3.1.0-canary.78916bb.0+78916bb" + "@avalabs/core-utils-sdk" "3.1.0-canary.78916bb.0+78916bb" + +"@avalabs/core-utils-sdk@3.1.0-canary.78916bb.0+78916bb": + version "3.1.0-canary.78916bb.0" + resolved "https://registry.yarnpkg.com/@avalabs/core-utils-sdk/-/core-utils-sdk-3.1.0-canary.78916bb.0.tgz#4ee6f2e1043cdfb5ecaa5004a17e691446bcffd2" + integrity sha512-HAu1BaGVKIM/vQ70X0sQiArLDYkB8vCinBYFOivrACKETTmTsUsltApgKp2eAhcvMGYX/7wNjQ9JJwmrPoh1MQ== + dependencies: + "@avalabs/avalanchejs" "4.1.0-alpha.15" + "@hpke/core" "1.2.5" + is-ipfs "6.0.2" "@avalabs/core-utils-sdk@3.1.0-canary.d762cf9.0+d762cf9": version "3.1.0-canary.d762cf9.0" @@ -170,6 +211,30 @@ "@hpke/core" "1.2.5" is-ipfs "6.0.2" +"@avalabs/core-wallets-sdk@3.1.0-canary.78916bb.0+78916bb": + version "3.1.0-canary.78916bb.0" + resolved "https://registry.yarnpkg.com/@avalabs/core-wallets-sdk/-/core-wallets-sdk-3.1.0-canary.78916bb.0.tgz#ab1e5510171bc49368fba3cae1382266ad8158af" + integrity sha512-5vyky83Oz/MhKHum6RUmYM0G2/2M0Mgep6mIfrbgI4QsQKUcUMFxDN7hXAwiIV0B1ULRIAnLndoyQUyKmwBRAA== + dependencies: + "@avalabs/avalanchejs" "4.1.0-alpha.15" + "@avalabs/core-chains-sdk" "3.1.0-canary.78916bb.0+78916bb" + "@avalabs/glacier-sdk" "3.1.0-canary.78916bb.0+78916bb" + "@avalabs/hw-app-avalanche" "0.14.1" + "@ledgerhq/hw-app-btc" "10.2.4" + "@ledgerhq/hw-app-eth" "6.36.1" + "@ledgerhq/hw-transport" "6.30.6" + "@metamask/eth-sig-util" "7.0.2" + "@openzeppelin/contracts" "4.9.6" + bip32 "2.0.6" + bip32-path "0.4.2" + bip39 "3.0.4" + bitcoinjs-lib "5.2.0" + coinselect "3.1.13" + create-hash "1.2.0" + hdkey "2.0.1" + ledger-bitcoin "0.2.3" + xss "1.0.14" + "@avalabs/core-wallets-sdk@3.1.0-canary.d762cf9.0+d762cf9": version "3.1.0-canary.d762cf9.0" resolved "https://registry.yarnpkg.com/@avalabs/core-wallets-sdk/-/core-wallets-sdk-3.1.0-canary.d762cf9.0.tgz#e2406c1f710dad04fcf37a6c92f710f96991f799" @@ -214,6 +279,11 @@ xss "1.0.13" zod "3.23.8" +"@avalabs/glacier-sdk@3.1.0-canary.78916bb.0+78916bb": + version "3.1.0-canary.78916bb.0" + resolved "https://registry.yarnpkg.com/@avalabs/glacier-sdk/-/glacier-sdk-3.1.0-canary.78916bb.0.tgz#17969b409fddbeecb842dd5f130a09b13f1f2c8d" + integrity sha512-wNuQFi73aIQm54PP3i1YnoKzmVn8aLWS/bOaz0qV0gUcnvrQq02KkBbC7nlm1f+1p1LbdhyOZ613jU6Y6nXO1A== + "@avalabs/glacier-sdk@3.1.0-canary.d762cf9.0+d762cf9": version "3.1.0-canary.d762cf9.0" resolved "https://registry.yarnpkg.com/@avalabs/glacier-sdk/-/glacier-sdk-3.1.0-canary.d762cf9.0.tgz#5993fb1a9ffcc41df903c83952e95538057f02d3" @@ -230,6 +300,11 @@ ledger-bitcoin "^0.2.1" sha3 "2.1.4" +"@avalabs/types@3.1.0-canary.78916bb.0+78916bb": + version "3.1.0-canary.78916bb.0" + resolved "https://registry.yarnpkg.com/@avalabs/types/-/types-3.1.0-canary.78916bb.0.tgz#3b0d7864fbdbafe7153ea744b95044b9393846f9" + integrity sha512-Jjvn47sa0ZjRS/JC6jE9SYTvW4vU2yxAoSai29M/7UB8wij5+g1FpiX6KUci//e0GrQxukqMWMMXZ/5E24h/UQ== + "@avalabs/types@3.1.0-canary.d762cf9.0+d762cf9": version "3.1.0-canary.d762cf9.0" resolved "https://registry.yarnpkg.com/@avalabs/types/-/types-3.1.0-canary.d762cf9.0.tgz#36a08ffd342f5e94907e03dca34d3412c8ae9736" From c3e7105530d4c027692bae83039064527982b4b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Leszczyk?= Date: Thu, 7 Nov 2024 10:30:43 +0100 Subject: [PATCH 08/16] chore: update vm modules --- package.json | 8 +-- yarn.lock | 153 +++++++++++++-------------------------------------- 2 files changed, 43 insertions(+), 118 deletions(-) diff --git a/package.json b/package.json index f847d16a5..8a142c71a 100644 --- a/package.json +++ b/package.json @@ -23,9 +23,9 @@ "sentry": "node sentryscript.js" }, "dependencies": { - "@avalabs/avalanche-module": "0.0.0-feat-p-dynamic-fees-20241031151758", + "@avalabs/avalanche-module": "0.0.0-feat-p-dynamic-fees-20241107092624", "@avalabs/avalanchejs": "4.1.0-alpha.15", - "@avalabs/bitcoin-module": "0.0.0-feat-p-dynamic-fees-20241031151758", + "@avalabs/bitcoin-module": "0.0.0-feat-p-dynamic-fees-20241107092624", "@avalabs/bridge-unified": "0.0.0-feat-ictt-configs-20241009072139", "@avalabs/core-bridge-sdk": "3.1.0-canary.78916bb.0+78916bb", "@avalabs/core-chains-sdk": "3.1.0-canary.78916bb.0+78916bb", @@ -37,11 +37,11 @@ "@avalabs/core-token-prices-sdk": "3.1.0-canary.78916bb.0+78916bb", "@avalabs/core-utils-sdk": "3.1.0-canary.78916bb.0+78916bb", "@avalabs/core-wallets-sdk": "3.1.0-canary.78916bb.0+78916bb", - "@avalabs/evm-module": "0.0.0-feat-p-dynamic-fees-20241031151758", + "@avalabs/evm-module": "0.0.0-feat-p-dynamic-fees-20241107092624", "@avalabs/glacier-sdk": "3.1.0-canary.78916bb.0+78916bb", "@avalabs/hw-app-avalanche": "0.14.1", "@avalabs/types": "3.1.0-canary.78916bb.0+78916bb", - "@avalabs/vm-module-types": "0.0.0-feat-p-dynamic-fees-20241031151758", + "@avalabs/vm-module-types": "0.0.0-feat-p-dynamic-fees-20241107092624", "@blockaid/client": "0.10.0", "@coinbase/cbpay-js": "1.6.0", "@cubist-labs/cubesigner-sdk": "0.3.28", diff --git a/yarn.lock b/yarn.lock index 4d14df09e..14ca25f7d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -29,20 +29,20 @@ resolved "https://registry.yarnpkg.com/@apocentre/alias-sampling/-/alias-sampling-0.5.3.tgz#897ff181b48ad7b2bcb4ecf29400214888244f08" integrity sha512-7UDWIIF9hIeJqfKXkNIzkVandlwLf1FWTSdrb9iXvOP8oF544JRXQjCbiTmCv2c9n44n/FIWtehhBfNuAx2CZA== -"@avalabs/avalanche-module@0.0.0-feat-p-dynamic-fees-20241031151758": - version "0.0.0-feat-p-dynamic-fees-20241031151758" - resolved "https://registry.yarnpkg.com/@avalabs/avalanche-module/-/avalanche-module-0.0.0-feat-p-dynamic-fees-20241031151758.tgz#6a7f82740526da86dd29b770ef30586ac4d554c8" - integrity sha512-D+OjWg7qTeIVYkF5w0jqCPIcyycbRqB7zK1Xc9eBim9mSotGAsyDCmDPuxDWYz/51he/6FiYmniBdFBwvHl1OA== - dependencies: - "@avalabs/avalanchejs" "4.1.0-alpha.7" - "@avalabs/core-chains-sdk" "3.1.0-canary.d762cf9.0+d762cf9" - "@avalabs/core-coingecko-sdk" "3.1.0-canary.d762cf9.0+d762cf9" - "@avalabs/core-etherscan-sdk" "3.1.0-canary.d762cf9.0+d762cf9" - "@avalabs/core-utils-sdk" "3.1.0-canary.d762cf9.0+d762cf9" - "@avalabs/core-wallets-sdk" "3.1.0-canary.d762cf9.0+d762cf9" - "@avalabs/glacier-sdk" "3.1.0-canary.d762cf9.0+d762cf9" - "@avalabs/types" "3.1.0-canary.d762cf9.0+d762cf9" - "@avalabs/vm-module-types" "0.0.0-feat-p-dynamic-fees-20241031151758" +"@avalabs/avalanche-module@0.0.0-feat-p-dynamic-fees-20241107092624": + version "0.0.0-feat-p-dynamic-fees-20241107092624" + resolved "https://registry.yarnpkg.com/@avalabs/avalanche-module/-/avalanche-module-0.0.0-feat-p-dynamic-fees-20241107092624.tgz#e2eae8e402ec8efb5113feb6dbd2ad1ce2738bb0" + integrity sha512-wn4Vglh6POxrtN6ZatssJaWbiQltVOq0tU1XxTVVeQRp+lWPkjqM6WQ7gZQs3A3MI/DA6sSdnBVTkEOYJ3Emnw== + dependencies: + "@avalabs/avalanchejs" "4.1.0-alpha.15" + "@avalabs/core-chains-sdk" "3.1.0-canary.78916bb.0+78916bb" + "@avalabs/core-coingecko-sdk" "3.1.0-canary.78916bb.0+78916bb" + "@avalabs/core-etherscan-sdk" "3.1.0-canary.78916bb.0+78916bb" + "@avalabs/core-utils-sdk" "3.1.0-canary.78916bb.0+78916bb" + "@avalabs/core-wallets-sdk" "3.1.0-canary.78916bb.0+78916bb" + "@avalabs/glacier-sdk" "3.1.0-canary.78916bb.0+78916bb" + "@avalabs/types" "3.1.0-canary.78916bb.0+78916bb" + "@avalabs/vm-module-types" "0.0.0-feat-p-dynamic-fees-20241107092624" "@metamask/rpc-errors" "6.3.0" big.js "6.2.1" bn.js "5.2.1" @@ -59,26 +59,15 @@ "@scure/base" "1.1.5" micro-eth-signer "0.7.2" -"@avalabs/avalanchejs@4.1.0-alpha.7": - version "4.1.0-alpha.7" - resolved "https://registry.yarnpkg.com/@avalabs/avalanchejs/-/avalanchejs-4.1.0-alpha.7.tgz#480a4bf29abd78833ca759cbc23387e750e4fbd5" - integrity sha512-Oouj54ujsYzVNd24W01Bbj2XH35BU2FB3A2reHdX0uU2X3Nt3rCeHx2BcxA73x8oSan/d99DfbAsFvwcQ9tjhw== - dependencies: - "@noble/curves" "1.3.0" - "@noble/hashes" "1.3.3" - "@noble/secp256k1" "2.0.0" - "@scure/base" "1.1.5" - micro-eth-signer "0.7.2" - -"@avalabs/bitcoin-module@0.0.0-feat-p-dynamic-fees-20241031151758": - version "0.0.0-feat-p-dynamic-fees-20241031151758" - resolved "https://registry.yarnpkg.com/@avalabs/bitcoin-module/-/bitcoin-module-0.0.0-feat-p-dynamic-fees-20241031151758.tgz#89c34b9f1ddd751d4d44fabeea82331fc1b130bc" - integrity sha512-cqhZhGQXFh46qI1sI4aL0rqRJvbQTtLdKXRoMuugGLdLjEIs+P5BHKjMX9OMLpGDDqtMDHEYVszSSeR1VDq7OA== +"@avalabs/bitcoin-module@0.0.0-feat-p-dynamic-fees-20241107092624": + version "0.0.0-feat-p-dynamic-fees-20241107092624" + resolved "https://registry.yarnpkg.com/@avalabs/bitcoin-module/-/bitcoin-module-0.0.0-feat-p-dynamic-fees-20241107092624.tgz#254a009eb34680606ac7fb084ac40713be7270d7" + integrity sha512-ljfdg3lq5nMmOWqZ2HHB8mh1hrHNdmm0sOHs53TUEaP0KOxWhKjg8wE/kY2c0oCVPH5o9Q1JvqvkYMKlfd8QAg== dependencies: - "@avalabs/core-coingecko-sdk" "3.1.0-canary.d762cf9.0+d762cf9" - "@avalabs/core-utils-sdk" "3.1.0-canary.d762cf9.0+d762cf9" - "@avalabs/core-wallets-sdk" "3.1.0-canary.d762cf9.0+d762cf9" - "@avalabs/vm-module-types" "0.0.0-feat-p-dynamic-fees-20241031151758" + "@avalabs/core-coingecko-sdk" "3.1.0-canary.78916bb.0+78916bb" + "@avalabs/core-utils-sdk" "3.1.0-canary.78916bb.0+78916bb" + "@avalabs/core-wallets-sdk" "3.1.0-canary.78916bb.0+78916bb" + "@avalabs/vm-module-types" "0.0.0-feat-p-dynamic-fees-20241107092624" "@metamask/rpc-errors" "6.3.0" big.js "6.2.1" bitcoinjs-lib "5.2.0" @@ -113,13 +102,6 @@ dependencies: "@avalabs/core-utils-sdk" "3.1.0-canary.78916bb.0+78916bb" -"@avalabs/core-chains-sdk@3.1.0-canary.d762cf9.0+d762cf9": - version "3.1.0-canary.d762cf9.0" - resolved "https://registry.yarnpkg.com/@avalabs/core-chains-sdk/-/core-chains-sdk-3.1.0-canary.d762cf9.0.tgz#6f46a9342409f5fefd832ff74c4451ce6781d7c1" - integrity sha512-wK4c9BCFSwUcjaCXZcVJkSGGmkv9erHRYNaQasHXg7QUyX+p7kNw3zlcUX29vX9XsA3Joqkc/zahSb3I+G2t7Q== - dependencies: - "@avalabs/core-utils-sdk" "3.1.0-canary.d762cf9.0+d762cf9" - "@avalabs/core-coingecko-sdk@3.1.0-canary.78916bb.0+78916bb": version "3.1.0-canary.78916bb.0" resolved "https://registry.yarnpkg.com/@avalabs/core-coingecko-sdk/-/core-coingecko-sdk-3.1.0-canary.78916bb.0.tgz#ba2f5813a4da8a81ed3b365dbb41244042276ce0" @@ -127,13 +109,6 @@ dependencies: "@avalabs/core-utils-sdk" "3.1.0-canary.78916bb.0+78916bb" -"@avalabs/core-coingecko-sdk@3.1.0-canary.d762cf9.0+d762cf9": - version "3.1.0-canary.d762cf9.0" - resolved "https://registry.yarnpkg.com/@avalabs/core-coingecko-sdk/-/core-coingecko-sdk-3.1.0-canary.d762cf9.0.tgz#81d117b80e10d418dde721d73cbbcf4dc834cd12" - integrity sha512-WI0XW9B/3VTXBGcC1G9ViwcJIDXe1yJpcj70XAyo/XdLAk/YKHNhI8atdn8ZVlvFcgImwdXu5oHZeziRwCPgLA== - dependencies: - "@avalabs/core-utils-sdk" "3.1.0-canary.d762cf9.0+d762cf9" - "@avalabs/core-covalent-sdk@3.1.0-canary.78916bb.0+78916bb": version "3.1.0-canary.78916bb.0" resolved "https://registry.yarnpkg.com/@avalabs/core-covalent-sdk/-/core-covalent-sdk-3.1.0-canary.78916bb.0.tgz#ffcc021a83ef03987cdd88195cb15fab37383b18" @@ -148,13 +123,6 @@ dependencies: "@avalabs/core-utils-sdk" "3.1.0-canary.78916bb.0+78916bb" -"@avalabs/core-etherscan-sdk@3.1.0-canary.d762cf9.0+d762cf9": - version "3.1.0-canary.d762cf9.0" - resolved "https://registry.yarnpkg.com/@avalabs/core-etherscan-sdk/-/core-etherscan-sdk-3.1.0-canary.d762cf9.0.tgz#0be5cd893fbb2cdd13783f6fd78d922e4a084eff" - integrity sha512-2vAqj5G8rvesoDrmPyUAcdjjVR8oPx/Uj0FZPGcpGqBlFk14l3Hs0exCKkPhldtL8nHMm95UmbEZhU5tDI08AQ== - dependencies: - "@avalabs/core-utils-sdk" "3.1.0-canary.d762cf9.0+d762cf9" - "@avalabs/core-k2-components@4.18.0-alpha.47": version "4.18.0-alpha.47" resolved "https://registry.yarnpkg.com/@avalabs/core-k2-components/-/core-k2-components-4.18.0-alpha.47.tgz#94d588cf109350fe57d246dbf36bc127a1fc0584" @@ -202,15 +170,6 @@ "@hpke/core" "1.2.5" is-ipfs "6.0.2" -"@avalabs/core-utils-sdk@3.1.0-canary.d762cf9.0+d762cf9": - version "3.1.0-canary.d762cf9.0" - resolved "https://registry.yarnpkg.com/@avalabs/core-utils-sdk/-/core-utils-sdk-3.1.0-canary.d762cf9.0.tgz#812b8b89f64a28942a8f753ac09a64fd8635d5e3" - integrity sha512-NjNeMdllp/tYH9BqOCEZ8IM4hV6Y0ceJGZmOW7iH5RaFvL87SQhDmGc563WRPBfnvTDOFbqYZZYQcO3QCSu1EQ== - dependencies: - "@avalabs/avalanchejs" "4.1.0-alpha.7" - "@hpke/core" "1.2.5" - is-ipfs "6.0.2" - "@avalabs/core-wallets-sdk@3.1.0-canary.78916bb.0+78916bb": version "3.1.0-canary.78916bb.0" resolved "https://registry.yarnpkg.com/@avalabs/core-wallets-sdk/-/core-wallets-sdk-3.1.0-canary.78916bb.0.tgz#ab1e5510171bc49368fba3cae1382266ad8158af" @@ -235,42 +194,18 @@ ledger-bitcoin "0.2.3" xss "1.0.14" -"@avalabs/core-wallets-sdk@3.1.0-canary.d762cf9.0+d762cf9": - version "3.1.0-canary.d762cf9.0" - resolved "https://registry.yarnpkg.com/@avalabs/core-wallets-sdk/-/core-wallets-sdk-3.1.0-canary.d762cf9.0.tgz#e2406c1f710dad04fcf37a6c92f710f96991f799" - integrity sha512-8kY0m7TMcbzEgPKqWtt9P0luVQj3cTMBCyN65lWGORXwo05VuuZulMR3ysHccGmJZeRGzZwkOjQB+6hVIziKUA== +"@avalabs/evm-module@0.0.0-feat-p-dynamic-fees-20241107092624": + version "0.0.0-feat-p-dynamic-fees-20241107092624" + resolved "https://registry.yarnpkg.com/@avalabs/evm-module/-/evm-module-0.0.0-feat-p-dynamic-fees-20241107092624.tgz#23087cb4d86a600bd354baa89a78011d01f773c3" + integrity sha512-c3qztYdYLBxfq6r3gON3rNk/tVeQZ8r6kU3ERijPRCmELbf4v+hSJWZPG3ncwPSzh/N0WStiOv7OzQ6XA7Kysw== dependencies: - "@avalabs/avalanchejs" "4.1.0-alpha.7" - "@avalabs/core-chains-sdk" "3.1.0-canary.d762cf9.0+d762cf9" - "@avalabs/glacier-sdk" "3.1.0-canary.d762cf9.0+d762cf9" - "@avalabs/hw-app-avalanche" "0.14.1" - "@ledgerhq/hw-app-btc" "10.2.4" - "@ledgerhq/hw-app-eth" "6.36.1" - "@ledgerhq/hw-transport" "6.30.6" - "@metamask/eth-sig-util" "7.0.2" - "@openzeppelin/contracts" "4.9.6" - bip32 "2.0.6" - bip32-path "0.4.2" - bip39 "3.0.4" - bitcoinjs-lib "5.2.0" - coinselect "3.1.13" - create-hash "1.2.0" - hdkey "2.0.1" - ledger-bitcoin "0.2.3" - xss "1.0.14" - -"@avalabs/evm-module@0.0.0-feat-p-dynamic-fees-20241031151758": - version "0.0.0-feat-p-dynamic-fees-20241031151758" - resolved "https://registry.yarnpkg.com/@avalabs/evm-module/-/evm-module-0.0.0-feat-p-dynamic-fees-20241031151758.tgz#c1d6c9359814ef703c0ddcc3a6a1147910d8d8f5" - integrity sha512-ey0hTVyWCuyG2UPF+EBATRsDpzylpSoYkseqtaYcaMhTFkgwpzwcoI2+zzFHN7YP3GB1Qf9OEN5Wqdw13L1m1A== - dependencies: - "@avalabs/core-coingecko-sdk" "3.1.0-canary.d762cf9.0+d762cf9" - "@avalabs/core-etherscan-sdk" "3.1.0-canary.d762cf9.0+d762cf9" - "@avalabs/core-utils-sdk" "3.1.0-canary.d762cf9.0+d762cf9" - "@avalabs/core-wallets-sdk" "3.1.0-canary.d762cf9.0+d762cf9" - "@avalabs/glacier-sdk" "3.1.0-canary.d762cf9.0+d762cf9" - "@avalabs/types" "3.1.0-canary.d762cf9.0+d762cf9" - "@avalabs/vm-module-types" "0.0.0-feat-p-dynamic-fees-20241031151758" + "@avalabs/core-coingecko-sdk" "3.1.0-canary.78916bb.0+78916bb" + "@avalabs/core-etherscan-sdk" "3.1.0-canary.78916bb.0+78916bb" + "@avalabs/core-utils-sdk" "3.1.0-canary.78916bb.0+78916bb" + "@avalabs/core-wallets-sdk" "3.1.0-canary.78916bb.0+78916bb" + "@avalabs/glacier-sdk" "3.1.0-canary.78916bb.0+78916bb" + "@avalabs/types" "3.1.0-canary.78916bb.0+78916bb" + "@avalabs/vm-module-types" "0.0.0-feat-p-dynamic-fees-20241107092624" "@blockaid/client" "0.11.0" "@metamask/rpc-errors" "6.3.0" "@openzeppelin/contracts" "4.9.6" @@ -284,11 +219,6 @@ resolved "https://registry.yarnpkg.com/@avalabs/glacier-sdk/-/glacier-sdk-3.1.0-canary.78916bb.0.tgz#17969b409fddbeecb842dd5f130a09b13f1f2c8d" integrity sha512-wNuQFi73aIQm54PP3i1YnoKzmVn8aLWS/bOaz0qV0gUcnvrQq02KkBbC7nlm1f+1p1LbdhyOZ613jU6Y6nXO1A== -"@avalabs/glacier-sdk@3.1.0-canary.d762cf9.0+d762cf9": - version "3.1.0-canary.d762cf9.0" - resolved "https://registry.yarnpkg.com/@avalabs/glacier-sdk/-/glacier-sdk-3.1.0-canary.d762cf9.0.tgz#5993fb1a9ffcc41df903c83952e95538057f02d3" - integrity sha512-lFvqLMISJ18jtNf1WdnKRED6T1ugFsphfMCKHZ+su+9H9DBWLqR/PRzjMgWmyPE9zM+Ly9h2TMbq3kaWZXzKxQ== - "@avalabs/hw-app-avalanche@0.14.1": version "0.14.1" resolved "https://registry.yarnpkg.com/@avalabs/hw-app-avalanche/-/hw-app-avalanche-0.14.1.tgz#70b6248e67cf7d64d0640517f88c19632524ac68" @@ -305,18 +235,13 @@ resolved "https://registry.yarnpkg.com/@avalabs/types/-/types-3.1.0-canary.78916bb.0.tgz#3b0d7864fbdbafe7153ea744b95044b9393846f9" integrity sha512-Jjvn47sa0ZjRS/JC6jE9SYTvW4vU2yxAoSai29M/7UB8wij5+g1FpiX6KUci//e0GrQxukqMWMMXZ/5E24h/UQ== -"@avalabs/types@3.1.0-canary.d762cf9.0+d762cf9": - version "3.1.0-canary.d762cf9.0" - resolved "https://registry.yarnpkg.com/@avalabs/types/-/types-3.1.0-canary.d762cf9.0.tgz#36a08ffd342f5e94907e03dca34d3412c8ae9736" - integrity sha512-IWAVBwq6ACEh5i+RsYD4WMCKXCTmqCrRxV9VINt4y/dVdDbGqAHE8qpHvjqrlrOahvJ2FUSexlZwls++G3WRHQ== - -"@avalabs/vm-module-types@0.0.0-feat-p-dynamic-fees-20241031151758": - version "0.0.0-feat-p-dynamic-fees-20241031151758" - resolved "https://registry.yarnpkg.com/@avalabs/vm-module-types/-/vm-module-types-0.0.0-feat-p-dynamic-fees-20241031151758.tgz#bb3a053709f09fbf8807757315860699324b300e" - integrity sha512-JAbBzlbX7kDDltBMpp+2r2YGdd1zcub7GEKRZ2maEGAgKKWlKLKhGcATqs5VkhX/Pa5hTsWVoUKdLEJTYYaa5A== +"@avalabs/vm-module-types@0.0.0-feat-p-dynamic-fees-20241107092624": + version "0.0.0-feat-p-dynamic-fees-20241107092624" + resolved "https://registry.yarnpkg.com/@avalabs/vm-module-types/-/vm-module-types-0.0.0-feat-p-dynamic-fees-20241107092624.tgz#3bd50e2bb642814c27b011b6534aa6cc61a4a04c" + integrity sha512-GUDkXV8yvzCVF8kKiaXnE1kF0h6n7olBrqoAAPH3NsFqZHODhXBkaGaQNe78L4BztDfZQnRfCSxLwYirdoO/hQ== dependencies: - "@avalabs/core-wallets-sdk" "3.1.0-canary.d762cf9.0+d762cf9" - "@avalabs/glacier-sdk" "3.1.0-canary.d762cf9.0+d762cf9" + "@avalabs/core-wallets-sdk" "3.1.0-canary.78916bb.0+78916bb" + "@avalabs/glacier-sdk" "3.1.0-canary.78916bb.0+78916bb" "@metamask/rpc-errors" "6.3.0" bitcoinjs-lib "5.2.0" zod "3.23.8" From 26fa8ffc670861f6d789d64e59427a685aaec156 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Leszczyk?= Date: Fri, 8 Nov 2024 10:32:30 +0100 Subject: [PATCH 09/16] fix: preinitialize NetworkContext --- src/contexts/NetworkProvider.tsx | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/contexts/NetworkProvider.tsx b/src/contexts/NetworkProvider.tsx index 70ba52bc1..7e308085f 100644 --- a/src/contexts/NetworkProvider.tsx +++ b/src/contexts/NetworkProvider.tsx @@ -57,7 +57,27 @@ const NetworkContext = createContext<{ avaxProviderC?: JsonRpcBatchInternal; ethereumProvider?: JsonRpcBatchInternal; bitcoinProvider?: BitcoinProvider; -}>({} as any); +}>({ + network: undefined, + setNetwork() {}, + networks: [], + setDeveloperMode() {}, + async saveCustomNetwork() {}, + async updateDefaultNetwork() {}, + async removeCustomNetwork() {}, + isDeveloperMode: false, + favoriteNetworks: [], + addFavoriteNetwork() {}, + removeFavoriteNetwork() {}, + isFavoriteNetwork: () => false, + customNetworks: [], + isCustomNetwork: () => false, + isChainIdExist: () => false, + getNetwork: () => undefined, + avaxProviderC: undefined, + ethereumProvider: undefined, + bitcoinProvider: undefined, +}); /** * Network is being saved to chrome storage so we can share it across all contexts. With that when the From 41ef4f0e52f222e5b33d31afb30b83c189f61787 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Leszczyk?= Date: Fri, 15 Nov 2024 14:18:12 +0100 Subject: [PATCH 10/16] fix: restored tests, updated sdks, fixed ui issues --- package.json | 32 +-- .../balances/BalanceAggregatorService.test.ts | 4 +- .../network/utils/isAvalanchePchainNetwork.ts | 2 +- .../network/utils/isAvalancheXchainNetwork.ts | 2 +- .../avalanche_sendTransaction.test.ts | 6 +- .../handlers/avalanche_sendTransaction.ts | 8 +- .../avalanche_signTransaction.test.ts | 18 +- .../handlers/avalanche_signTransaction.ts | 8 +- src/components/common/CustomFees.tsx | 25 ++- .../components/ApproveBaseTx.tsx | 3 +- src/pages/Send/components/SendPVM.tsx | 5 +- src/pages/Send/hooks/useSend/usePVMSend.ts | 55 +++-- src/pages/Send/utils/getMaxUtxos.ts | 5 +- yarn.lock | 204 +++++++++--------- 14 files changed, 212 insertions(+), 165 deletions(-) diff --git a/package.json b/package.json index 8a142c71a..5abea7960 100644 --- a/package.json +++ b/package.json @@ -23,25 +23,25 @@ "sentry": "node sentryscript.js" }, "dependencies": { - "@avalabs/avalanche-module": "0.0.0-feat-p-dynamic-fees-20241107092624", - "@avalabs/avalanchejs": "4.1.0-alpha.15", - "@avalabs/bitcoin-module": "0.0.0-feat-p-dynamic-fees-20241107092624", + "@avalabs/avalanche-module": "0.0.0-feat-p-dynamic-fees-20241115122103", + "@avalabs/avalanchejs": "4.1.0-alpha.21", + "@avalabs/bitcoin-module": "0.0.0-feat-p-dynamic-fees-20241115122103", "@avalabs/bridge-unified": "0.0.0-feat-ictt-configs-20241009072139", - "@avalabs/core-bridge-sdk": "3.1.0-canary.78916bb.0+78916bb", - "@avalabs/core-chains-sdk": "3.1.0-canary.78916bb.0+78916bb", - "@avalabs/core-coingecko-sdk": "3.1.0-canary.78916bb.0+78916bb", - "@avalabs/core-covalent-sdk": "3.1.0-canary.78916bb.0+78916bb", - "@avalabs/core-etherscan-sdk": "3.1.0-canary.78916bb.0+78916bb", + "@avalabs/core-bridge-sdk": "3.1.0-canary.dca9ac0.0+dca9ac0", + "@avalabs/core-chains-sdk": "3.1.0-canary.dca9ac0.0+dca9ac0", + "@avalabs/core-coingecko-sdk": "3.1.0-canary.dca9ac0.0+dca9ac0", + "@avalabs/core-covalent-sdk": "3.1.0-canary.dca9ac0.0+dca9ac0", + "@avalabs/core-etherscan-sdk": "3.1.0-canary.dca9ac0.0+dca9ac0", "@avalabs/core-k2-components": "4.18.0-alpha.47", - "@avalabs/core-snowtrace-sdk": "3.1.0-canary.78916bb.0+78916bb", - "@avalabs/core-token-prices-sdk": "3.1.0-canary.78916bb.0+78916bb", - "@avalabs/core-utils-sdk": "3.1.0-canary.78916bb.0+78916bb", - "@avalabs/core-wallets-sdk": "3.1.0-canary.78916bb.0+78916bb", - "@avalabs/evm-module": "0.0.0-feat-p-dynamic-fees-20241107092624", - "@avalabs/glacier-sdk": "3.1.0-canary.78916bb.0+78916bb", + "@avalabs/core-snowtrace-sdk": "3.1.0-canary.dca9ac0.0+dca9ac0", + "@avalabs/core-token-prices-sdk": "3.1.0-canary.dca9ac0.0+dca9ac0", + "@avalabs/core-utils-sdk": "3.1.0-canary.dca9ac0.0+dca9ac0", + "@avalabs/core-wallets-sdk": "3.1.0-canary.dca9ac0.0+dca9ac0", + "@avalabs/evm-module": "0.0.0-feat-p-dynamic-fees-20241115122103", + "@avalabs/glacier-sdk": "3.1.0-canary.dca9ac0.0+dca9ac0", "@avalabs/hw-app-avalanche": "0.14.1", - "@avalabs/types": "3.1.0-canary.78916bb.0+78916bb", - "@avalabs/vm-module-types": "0.0.0-feat-p-dynamic-fees-20241107092624", + "@avalabs/types": "3.1.0-canary.dca9ac0.0+dca9ac0", + "@avalabs/vm-module-types": "0.0.0-feat-p-dynamic-fees-20241115122103", "@blockaid/client": "0.10.0", "@coinbase/cbpay-js": "1.6.0", "@cubist-labs/cubesigner-sdk": "0.3.28", diff --git a/src/background/services/balances/BalanceAggregatorService.test.ts b/src/background/services/balances/BalanceAggregatorService.test.ts index 9816a855d..39295eadb 100644 --- a/src/background/services/balances/BalanceAggregatorService.test.ts +++ b/src/background/services/balances/BalanceAggregatorService.test.ts @@ -415,7 +415,7 @@ describe('src/background/services/balances/BalanceAggregatorService.ts', () => { expect(balances).toEqual(freshBalances); }); - it.only('emits the BalanceServiceEvents.UPDATED if balances did change', async () => { + it('emits the BalanceServiceEvents.UPDATED if balances did change', async () => { // Cached balances include two accounts: account1, account2 const cachedBalances = { [network2.chainId]: { @@ -451,7 +451,7 @@ describe('src/background/services/balances/BalanceAggregatorService.ts', () => { expect(updatesListener).toHaveBeenCalled(); }); - it.only('DOES NOT emit the BalanceServiceEvents.UPDATED if balances did not change', async () => { + it('DOES NOT emit the BalanceServiceEvents.UPDATED if balances did not change', async () => { // Cached balances include two accounts: account1, account2 const cachedBalances = { [network2.chainId]: { diff --git a/src/background/services/network/utils/isAvalanchePchainNetwork.ts b/src/background/services/network/utils/isAvalanchePchainNetwork.ts index ea75b8ed2..8513cb4a8 100644 --- a/src/background/services/network/utils/isAvalanchePchainNetwork.ts +++ b/src/background/services/network/utils/isAvalanchePchainNetwork.ts @@ -11,6 +11,6 @@ export function isPchainNetworkId(chainId: number) { return ( ChainId.AVALANCHE_P === chainId || ChainId.AVALANCHE_TEST_P === chainId || - ChainId.AVALANCHE_DEVNET_P === chainId + ChainId.AVALANCHE_DEVNET_P === chainId // TODO: to remove this. ); } diff --git a/src/background/services/network/utils/isAvalancheXchainNetwork.ts b/src/background/services/network/utils/isAvalancheXchainNetwork.ts index e437b0274..3bef0c0aa 100644 --- a/src/background/services/network/utils/isAvalancheXchainNetwork.ts +++ b/src/background/services/network/utils/isAvalancheXchainNetwork.ts @@ -12,6 +12,6 @@ export function isXchainNetworkId(chainId: number) { return ( ChainId.AVALANCHE_X === chainId || ChainId.AVALANCHE_TEST_X === chainId || - ChainId.AVALANCHE_DEVNET_X === chainId + ChainId.AVALANCHE_DEVNET_X === chainId // TODO: to remove this. ); } diff --git a/src/background/services/wallet/handlers/avalanche_sendTransaction.test.ts b/src/background/services/wallet/handlers/avalanche_sendTransaction.test.ts index b43a392e0..f8a215eb2 100644 --- a/src/background/services/wallet/handlers/avalanche_sendTransaction.test.ts +++ b/src/background/services/wallet/handlers/avalanche_sendTransaction.test.ts @@ -368,8 +368,7 @@ describe('src/background/services/wallet/handlers/avalanche_sendTransaction.ts', expect(Avalanche.getUtxosByTxFromGlacier).toHaveBeenCalledWith({ transactionHex: request.params.transactionHex, chainAlias: request.params.chainAlias, - isTestnet: true, - isDevnet: false, + network: 'mainnet', url: process.env.GLACIER_URL, token: process.env.GLACIER_API_KEY, headers: HEADERS, @@ -450,8 +449,7 @@ describe('src/background/services/wallet/handlers/avalanche_sendTransaction.ts', expect(Avalanche.getUtxosByTxFromGlacier).toHaveBeenCalledWith({ transactionHex: request.params.transactionHex, chainAlias: request.params.chainAlias, - isTestnet: true, - isDevnet: false, + network: 'mainnet', url: process.env.GLACIER_URL, token: process.env.GLACIER_API_KEY, headers: HEADERS, diff --git a/src/background/services/wallet/handlers/avalanche_sendTransaction.ts b/src/background/services/wallet/handlers/avalanche_sendTransaction.ts index ce6e89427..e01fcd69b 100644 --- a/src/background/services/wallet/handlers/avalanche_sendTransaction.ts +++ b/src/background/services/wallet/handlers/avalanche_sendTransaction.ts @@ -20,6 +20,7 @@ import { ethErrors } from 'eth-rpc-errors'; import { AccountsService } from '../../accounts/AccountsService'; import getAddressByVM from '../utils/getAddressByVM'; import { Avalanche } from '@avalabs/core-wallets-sdk'; +import { Network } from '@avalabs/glacier-sdk'; import getProvidedUtxos from '../utils/getProvidedUtxos'; import { AnalyticsServicePosthog } from '../../analytics/AnalyticsServicePosthog'; import { ChainId } from '@avalabs/core-chains-sdk'; @@ -103,8 +104,11 @@ export class AvalancheSendTransactionHandler extends DAppRequestHandler< : await Avalanche.getUtxosByTxFromGlacier({ transactionHex, chainAlias, - isDevnet: isDevnet(network), - isTestnet: !this.networkService.isMainnet(), + network: isDevnet(network) + ? Network.DEVNET + : network.isTestnet + ? Network.FUJI + : Network.MAINNET, url: process.env.GLACIER_URL as string, token: process.env.GLACIER_API_KEY, headers: HEADERS, diff --git a/src/background/services/wallet/handlers/avalanche_signTransaction.test.ts b/src/background/services/wallet/handlers/avalanche_signTransaction.test.ts index c6e7f3b1d..59925ebaa 100644 --- a/src/background/services/wallet/handlers/avalanche_signTransaction.test.ts +++ b/src/background/services/wallet/handlers/avalanche_signTransaction.test.ts @@ -228,8 +228,7 @@ describe('src/background/services/wallet/handlers/avalanche_signTransaction', () expect(Avalanche.getUtxosByTxFromGlacier).toHaveBeenCalledWith({ transactionHex: request.params.transactionHex, chainAlias: request.params.chainAlias, - isTestnet: true, - isDevnet: false, + network: 'fuji', url: process.env.GLACIER_URL, token: process.env.GLACIER_API_KEY, headers: HEADERS, @@ -277,8 +276,7 @@ describe('src/background/services/wallet/handlers/avalanche_signTransaction', () expect(Avalanche.getUtxosByTxFromGlacier).toHaveBeenCalledWith({ transactionHex: request.params.transactionHex, chainAlias: request.params.chainAlias, - isTestnet: true, - isDevnet: false, + network: 'fuji', url: process.env.GLACIER_URL, token: process.env.GLACIER_API_KEY, headers: HEADERS, @@ -333,8 +331,7 @@ describe('src/background/services/wallet/handlers/avalanche_signTransaction', () expect(Avalanche.getUtxosByTxFromGlacier).toHaveBeenCalledWith({ transactionHex: request.params.transactionHex, chainAlias: request.params.chainAlias, - isTestnet: true, - isDevnet: false, + network: 'fuji', url: process.env.GLACIER_URL, token: process.env.GLACIER_API_KEY, headers: HEADERS, @@ -391,8 +388,7 @@ describe('src/background/services/wallet/handlers/avalanche_signTransaction', () expect(Avalanche.getUtxosByTxFromGlacier).toHaveBeenCalledWith({ transactionHex: request.params.transactionHex, chainAlias: request.params.chainAlias, - isTestnet: true, - isDevnet: false, + network: 'fuji', url: process.env.GLACIER_URL, token: process.env.GLACIER_API_KEY, headers: HEADERS, @@ -534,8 +530,7 @@ describe('src/background/services/wallet/handlers/avalanche_signTransaction', () expect(Avalanche.getUtxosByTxFromGlacier).toHaveBeenCalledWith({ transactionHex: request.params.transactionHex, chainAlias: request.params.chainAlias, - isTestnet: true, - isDevnet: false, + network: 'fuji', url: process.env.GLACIER_URL, token: process.env.GLACIER_API_KEY, headers: HEADERS, @@ -724,8 +719,7 @@ describe('src/background/services/wallet/handlers/avalanche_signTransaction', () expect(Avalanche.getUtxosByTxFromGlacier).toHaveBeenCalledWith({ transactionHex: request.params.transactionHex, chainAlias: request.params.chainAlias, - isTestnet: true, - isDevnet: false, + network: 'fuji', url: process.env.GLACIER_URL, token: process.env.GLACIER_API_KEY, headers: HEADERS, diff --git a/src/background/services/wallet/handlers/avalanche_signTransaction.ts b/src/background/services/wallet/handlers/avalanche_signTransaction.ts index 78deff7f3..f1c4d6335 100644 --- a/src/background/services/wallet/handlers/avalanche_signTransaction.ts +++ b/src/background/services/wallet/handlers/avalanche_signTransaction.ts @@ -18,6 +18,7 @@ import { ethErrors } from 'eth-rpc-errors'; import { AccountsService } from '../../accounts/AccountsService'; import getAddressByVM from '../utils/getAddressByVM'; import { Avalanche } from '@avalabs/core-wallets-sdk'; +import { Network } from '@avalabs/glacier-sdk'; import getProvidedUtxos from '../utils/getProvidedUtxos'; import { openApprovalWindow } from '@src/background/runtime/openApprovalWindow'; import { HEADERS } from '../../glacier/glacierConfig'; @@ -91,8 +92,11 @@ export class AvalancheSignTransactionHandler extends DAppRequestHandler { + if (!network?.networkToken) { + return '-'; + } + + if (typeof estimatedFee === 'bigint') { + return new TokenUnit( + estimatedFee, + network?.networkToken.decimals, + network?.networkToken.symbol + ).toString(); + } + + return newFees.fee; + }, [network?.networkToken, estimatedFee, newFees.fee]); + if (!networkFee) { return null; } @@ -505,7 +524,7 @@ export function CustomFees({ data-testid="network-fee-token-amount" sx={{ fontWeight: 'fontWeightSemibold' }} > - {newFees.fee} {network?.networkToken.symbol} + {feeAmount} {network?.networkToken.symbol} setShowEditGasLimit(false)} diff --git a/src/pages/ApproveAction/components/ApproveBaseTx.tsx b/src/pages/ApproveAction/components/ApproveBaseTx.tsx index 5fcd21cde..67aa6f9b7 100644 --- a/src/pages/ApproveAction/components/ApproveBaseTx.tsx +++ b/src/pages/ApproveAction/components/ApproveBaseTx.tsx @@ -135,7 +135,8 @@ export function BaseTxView({ out.assetDescription?.denomination || defaultDenomination )}{' '} - {out.assetDescription?.symbol ?? (out.isAvax && 'AVAX')} + {out.assetDescription?.symbol ?? + (out.isAvax ? 'AVAX' : '')} {out.isAvax && ( diff --git a/src/pages/Send/hooks/useSend/usePVMSend.ts b/src/pages/Send/hooks/useSend/usePVMSend.ts index 1951fe312..48eee2784 100644 --- a/src/pages/Send/hooks/useSend/usePVMSend.ts +++ b/src/pages/Send/hooks/useSend/usePVMSend.ts @@ -40,6 +40,38 @@ export const usePvmSend: SendAdapterPVM = ({ const [maxAmount, setMaxAmount] = useState('0'); const [estimatedFee, setEstimatedFee] = useState(0n); const [feeState, setFeeState] = useState(); + const [utxoSet, setUtxoSet] = useState(); + + const wallet = useMemo(() => { + return new Avalanche.AddressWallet( + account.addressC, + stripAddressPrefix(account.addressCoreEth), + [stripAddressPrefix(account.addressPVM)], + stripAddressPrefix(account.addressPVM), + provider as Avalanche.JsonRpcProvider + ); + }, [account, provider]); + + useEffect(() => { + let isMounted = true; + + wallet + .getUTXOs('P') + .then((u) => { + if (!isMounted) { + return; + } + + setUtxoSet(u); + }) + .catch(() => { + setError(SendErrorMessage.UNABLE_TO_FETCH_UTXOS); + }); + + return () => { + isMounted = false; + }; + }, [wallet]); useEffect(() => { let isMounted = true; @@ -67,16 +99,6 @@ export const usePvmSend: SendAdapterPVM = ({ }; }, [provider]); - const wallet = useMemo(() => { - return new Avalanche.AddressWallet( - account.addressC, - stripAddressPrefix(account.addressCoreEth), - [stripAddressPrefix(account.addressPVM)], - stripAddressPrefix(account.addressPVM), - provider as Avalanche.JsonRpcProvider - ); - }, [account, provider]); - const checkFunctionAvailability = useCallback(() => { if (!featureFlags[FeatureGates.SEND_P_CHAIN]) { return SendErrorMessage.SEND_NOT_AVAILABLE; @@ -112,7 +134,8 @@ export const usePvmSend: SendAdapterPVM = ({ provider, wallet, network, - getFeeState(gasPrice) + getFeeState(gasPrice), + utxoSet ); return wallet.baseTX({ @@ -137,6 +160,7 @@ export const usePvmSend: SendAdapterPVM = ({ isLedgerWallet, network, getFeeState, + utxoSet, ] ); @@ -149,16 +173,17 @@ export const usePvmSend: SendAdapterPVM = ({ token, }); + const feeTolerance = getFeeTolerance(gasPrice, feeState); const parsedTx = await Avalanche.parseAvalancheTx( unsignedTx, provider, account.addressPVM, - { feeTolerance: 100 } + { feeTolerance } ); return parsedTx; }, - [buildTransaction, provider, account.addressPVM] + [buildTransaction, provider, account.addressPVM, feeState] ); const validate = useCallback( @@ -199,7 +224,8 @@ export const usePvmSend: SendAdapterPVM = ({ provider, wallet, network, - getFeeState(gasPrice) + getFeeState(gasPrice), + utxoSet ) ); @@ -243,6 +269,7 @@ export const usePvmSend: SendAdapterPVM = ({ getFeeState, parseTx, feeState, + utxoSet, ] ); diff --git a/src/pages/Send/utils/getMaxUtxos.ts b/src/pages/Send/utils/getMaxUtxos.ts index c437d4cf5..6ebffed99 100644 --- a/src/pages/Send/utils/getMaxUtxos.ts +++ b/src/pages/Send/utils/getMaxUtxos.ts @@ -17,12 +17,13 @@ export async function getMaxUtxoSet( provider: Avalanche.JsonRpcProvider, wallet: Avalanche.AddressWallet, network: Network, - feeState?: FeeState + feeState?: FeeState, + preloadedUtxoSet?: utils.UtxoSet ) { const chainAliasToUse = isPchainNetwork(network) ? CHAIN_ALIAS.P : CHAIN_ALIAS.X; - const utxos = await wallet.getUTXOs(chainAliasToUse); + const utxos = preloadedUtxoSet ?? (await wallet.getUTXOs(chainAliasToUse)); let filteredUtxos = Avalanche.sortUTXOsByAmount(utxos.getUTXOs(), true); if (isPchainNetwork(network)) { diff --git a/yarn.lock b/yarn.lock index 14ca25f7d..0ec3a75a0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -29,29 +29,29 @@ resolved "https://registry.yarnpkg.com/@apocentre/alias-sampling/-/alias-sampling-0.5.3.tgz#897ff181b48ad7b2bcb4ecf29400214888244f08" integrity sha512-7UDWIIF9hIeJqfKXkNIzkVandlwLf1FWTSdrb9iXvOP8oF544JRXQjCbiTmCv2c9n44n/FIWtehhBfNuAx2CZA== -"@avalabs/avalanche-module@0.0.0-feat-p-dynamic-fees-20241107092624": - version "0.0.0-feat-p-dynamic-fees-20241107092624" - resolved "https://registry.yarnpkg.com/@avalabs/avalanche-module/-/avalanche-module-0.0.0-feat-p-dynamic-fees-20241107092624.tgz#e2eae8e402ec8efb5113feb6dbd2ad1ce2738bb0" - integrity sha512-wn4Vglh6POxrtN6ZatssJaWbiQltVOq0tU1XxTVVeQRp+lWPkjqM6WQ7gZQs3A3MI/DA6sSdnBVTkEOYJ3Emnw== - dependencies: - "@avalabs/avalanchejs" "4.1.0-alpha.15" - "@avalabs/core-chains-sdk" "3.1.0-canary.78916bb.0+78916bb" - "@avalabs/core-coingecko-sdk" "3.1.0-canary.78916bb.0+78916bb" - "@avalabs/core-etherscan-sdk" "3.1.0-canary.78916bb.0+78916bb" - "@avalabs/core-utils-sdk" "3.1.0-canary.78916bb.0+78916bb" - "@avalabs/core-wallets-sdk" "3.1.0-canary.78916bb.0+78916bb" - "@avalabs/glacier-sdk" "3.1.0-canary.78916bb.0+78916bb" - "@avalabs/types" "3.1.0-canary.78916bb.0+78916bb" - "@avalabs/vm-module-types" "0.0.0-feat-p-dynamic-fees-20241107092624" +"@avalabs/avalanche-module@0.0.0-feat-p-dynamic-fees-20241115122103": + version "0.0.0-feat-p-dynamic-fees-20241115122103" + resolved "https://registry.yarnpkg.com/@avalabs/avalanche-module/-/avalanche-module-0.0.0-feat-p-dynamic-fees-20241115122103.tgz#f5597c863d825fca45d7d0d5c4e009427ac25b1d" + integrity sha512-qqzRY6M7whj9BDP9nPt203q2D/7jKOkxoCtyn6IypARfabNHoQniau6QKeVbGffQoC/XuuGa/3fHxQxN/Lq+Kw== + dependencies: + "@avalabs/avalanchejs" "4.1.0-alpha.21" + "@avalabs/core-chains-sdk" "3.1.0-canary.dca9ac0.0" + "@avalabs/core-coingecko-sdk" "3.1.0-canary.dca9ac0.0" + "@avalabs/core-etherscan-sdk" "3.1.0-canary.dca9ac0.0" + "@avalabs/core-utils-sdk" "3.1.0-canary.dca9ac0.0" + "@avalabs/core-wallets-sdk" "3.1.0-canary.dca9ac0.0" + "@avalabs/glacier-sdk" "3.1.0-canary.dca9ac0.0" + "@avalabs/types" "3.1.0-canary.dca9ac0.0" + "@avalabs/vm-module-types" "0.0.0-feat-p-dynamic-fees-20241115122103" "@metamask/rpc-errors" "6.3.0" big.js "6.2.1" bn.js "5.2.1" zod "3.23.8" -"@avalabs/avalanchejs@4.1.0-alpha.15": - version "4.1.0-alpha.15" - resolved "https://registry.yarnpkg.com/@avalabs/avalanchejs/-/avalanchejs-4.1.0-alpha.15.tgz#4ce13f65eefe95b1673c7f0dc84da6e1551b652d" - integrity sha512-85jq9MmG81MXzeCnvIwEvlXougzM27SZ2Ic4IIGLA7LpryH4I1oXh70aGmnNvpae+hOjsch6cQ24t+gvJuMFoA== +"@avalabs/avalanchejs@4.1.0-alpha.21": + version "4.1.0-alpha.21" + resolved "https://registry.yarnpkg.com/@avalabs/avalanchejs/-/avalanchejs-4.1.0-alpha.21.tgz#79ba75fba0e5e96c069d8d9695c8c4ac97beced6" + integrity sha512-RHczoHf1j4+AImOykZn18kP5MQQA1+6RXNfzWsjt2482LauoaaHGvpM7GpEFd325Sd+N8zgVH6AqxYadAu8Sow== dependencies: "@noble/curves" "1.3.0" "@noble/hashes" "1.3.3" @@ -59,15 +59,15 @@ "@scure/base" "1.1.5" micro-eth-signer "0.7.2" -"@avalabs/bitcoin-module@0.0.0-feat-p-dynamic-fees-20241107092624": - version "0.0.0-feat-p-dynamic-fees-20241107092624" - resolved "https://registry.yarnpkg.com/@avalabs/bitcoin-module/-/bitcoin-module-0.0.0-feat-p-dynamic-fees-20241107092624.tgz#254a009eb34680606ac7fb084ac40713be7270d7" - integrity sha512-ljfdg3lq5nMmOWqZ2HHB8mh1hrHNdmm0sOHs53TUEaP0KOxWhKjg8wE/kY2c0oCVPH5o9Q1JvqvkYMKlfd8QAg== +"@avalabs/bitcoin-module@0.0.0-feat-p-dynamic-fees-20241115122103": + version "0.0.0-feat-p-dynamic-fees-20241115122103" + resolved "https://registry.yarnpkg.com/@avalabs/bitcoin-module/-/bitcoin-module-0.0.0-feat-p-dynamic-fees-20241115122103.tgz#966492875039f3b4a328091b6b094ac6ddc8a54f" + integrity sha512-Y7xyfQE3EQs03WntwXRhAAJTzbpVReKJ8QyHTn4Zrw3O+u48j4MSoJPsiaAz8JfjxGz7Xh0P93BMXRPmzT2Gfw== dependencies: - "@avalabs/core-coingecko-sdk" "3.1.0-canary.78916bb.0+78916bb" - "@avalabs/core-utils-sdk" "3.1.0-canary.78916bb.0+78916bb" - "@avalabs/core-wallets-sdk" "3.1.0-canary.78916bb.0+78916bb" - "@avalabs/vm-module-types" "0.0.0-feat-p-dynamic-fees-20241107092624" + "@avalabs/core-coingecko-sdk" "3.1.0-canary.dca9ac0.0" + "@avalabs/core-utils-sdk" "3.1.0-canary.dca9ac0.0" + "@avalabs/core-wallets-sdk" "3.1.0-canary.dca9ac0.0" + "@avalabs/vm-module-types" "0.0.0-feat-p-dynamic-fees-20241115122103" "@metamask/rpc-errors" "6.3.0" big.js "6.2.1" bitcoinjs-lib "5.2.0" @@ -86,42 +86,42 @@ viem "2.11.1" zod "3.23.8" -"@avalabs/core-bridge-sdk@3.1.0-canary.78916bb.0+78916bb": - version "3.1.0-canary.78916bb.0" - resolved "https://registry.yarnpkg.com/@avalabs/core-bridge-sdk/-/core-bridge-sdk-3.1.0-canary.78916bb.0.tgz#7283ab66e0eeb3ca0fe92f62c08708809de65df0" - integrity sha512-5mr02Gt3vrEwLNQirqNDAQE55n6KOf3QVApt4F9GGpIYCN1YwLri8SBhKKyP/m34rMjha79a5mPno5LtqPdnmA== +"@avalabs/core-bridge-sdk@3.1.0-canary.dca9ac0.0+dca9ac0": + version "3.1.0-canary.dca9ac0.0" + resolved "https://registry.yarnpkg.com/@avalabs/core-bridge-sdk/-/core-bridge-sdk-3.1.0-canary.dca9ac0.0.tgz#9c1612225168965615536256407308dcf5c32ffe" + integrity sha512-JWqDqO37B++Cd792MHvXaQ1rCzbGXo/m2kyRtg8KXSrhFhEE7Rt85LWUMzkPouUEdTNLOXU23cg6x+7rYTzVMw== dependencies: - "@avalabs/core-coingecko-sdk" "3.1.0-canary.78916bb.0+78916bb" - "@avalabs/core-utils-sdk" "3.1.0-canary.78916bb.0+78916bb" - "@avalabs/core-wallets-sdk" "3.1.0-canary.78916bb.0+78916bb" + "@avalabs/core-coingecko-sdk" "3.1.0-canary.dca9ac0.0+dca9ac0" + "@avalabs/core-utils-sdk" "3.1.0-canary.dca9ac0.0+dca9ac0" + "@avalabs/core-wallets-sdk" "3.1.0-canary.dca9ac0.0+dca9ac0" -"@avalabs/core-chains-sdk@3.1.0-canary.78916bb.0+78916bb": - version "3.1.0-canary.78916bb.0" - resolved "https://registry.yarnpkg.com/@avalabs/core-chains-sdk/-/core-chains-sdk-3.1.0-canary.78916bb.0.tgz#b189febf28a70906e5592768b2bef6ef164b52e6" - integrity sha512-PbApSvgSc1jvCghm1oohd5dbYRSuRtz3hqnF52nklHv28LMJYYBGS9EZBY/2w8EBfzOtTSiiAbAA42PBYfg/cg== +"@avalabs/core-chains-sdk@3.1.0-canary.dca9ac0.0", "@avalabs/core-chains-sdk@3.1.0-canary.dca9ac0.0+dca9ac0": + version "3.1.0-canary.dca9ac0.0" + resolved "https://registry.yarnpkg.com/@avalabs/core-chains-sdk/-/core-chains-sdk-3.1.0-canary.dca9ac0.0.tgz#6780f3d85035d753fc8ceca0e616f6a04b36e855" + integrity sha512-Y8+9JF1x6cfmGH4avPLYituFKEihjywtq2CVkwDL1No1MG/nvH1pFPnggy7zLWTtU/nzcM5olw5FZm1LWmjS9Q== dependencies: - "@avalabs/core-utils-sdk" "3.1.0-canary.78916bb.0+78916bb" + "@avalabs/core-utils-sdk" "3.1.0-canary.dca9ac0.0+dca9ac0" -"@avalabs/core-coingecko-sdk@3.1.0-canary.78916bb.0+78916bb": - version "3.1.0-canary.78916bb.0" - resolved "https://registry.yarnpkg.com/@avalabs/core-coingecko-sdk/-/core-coingecko-sdk-3.1.0-canary.78916bb.0.tgz#ba2f5813a4da8a81ed3b365dbb41244042276ce0" - integrity sha512-qT+4HAga6sP9cytYkt0z/m4s7gZTlaE9MBmMef/RzQ0Az1eu4ovjDErg4zfDg/Rwtn7PefhXIXYr4/3p++jK/A== +"@avalabs/core-coingecko-sdk@3.1.0-canary.dca9ac0.0", "@avalabs/core-coingecko-sdk@3.1.0-canary.dca9ac0.0+dca9ac0": + version "3.1.0-canary.dca9ac0.0" + resolved "https://registry.yarnpkg.com/@avalabs/core-coingecko-sdk/-/core-coingecko-sdk-3.1.0-canary.dca9ac0.0.tgz#50c59f642a6cb804069044ef32d5f0f83a6281e9" + integrity sha512-DN2bC98MXw0PkbJqzHnrvDgP9zFprn+b6HjhsR9LLIC2fCMhQzyIWJaEQXzwc0ZNyo86HI2lSJE6gHq8w+a0WQ== dependencies: - "@avalabs/core-utils-sdk" "3.1.0-canary.78916bb.0+78916bb" + "@avalabs/core-utils-sdk" "3.1.0-canary.dca9ac0.0+dca9ac0" -"@avalabs/core-covalent-sdk@3.1.0-canary.78916bb.0+78916bb": - version "3.1.0-canary.78916bb.0" - resolved "https://registry.yarnpkg.com/@avalabs/core-covalent-sdk/-/core-covalent-sdk-3.1.0-canary.78916bb.0.tgz#ffcc021a83ef03987cdd88195cb15fab37383b18" - integrity sha512-Z0D0F6TGDSdRnm+KmFX4vK8OyLKSUi5ZJXTIYyHuubT9m/g16k0MzLPw/0PSh71ijb15vO7YUM9DAHclV4ZFIw== +"@avalabs/core-covalent-sdk@3.1.0-canary.dca9ac0.0+dca9ac0": + version "3.1.0-canary.dca9ac0.0" + resolved "https://registry.yarnpkg.com/@avalabs/core-covalent-sdk/-/core-covalent-sdk-3.1.0-canary.dca9ac0.0.tgz#39af6930dc251d6da657894a2b687cd2721efaba" + integrity sha512-ii5PZQFqPT+ssQLzUhsp1wGSLLXVmfOrLkCg6l4/5lGHCBaPFmlkH8VE0V0CMzOXYjiDI+8FWXqVYI5Stp7Uug== dependencies: - "@avalabs/core-utils-sdk" "3.1.0-canary.78916bb.0+78916bb" + "@avalabs/core-utils-sdk" "3.1.0-canary.dca9ac0.0+dca9ac0" -"@avalabs/core-etherscan-sdk@3.1.0-canary.78916bb.0+78916bb": - version "3.1.0-canary.78916bb.0" - resolved "https://registry.yarnpkg.com/@avalabs/core-etherscan-sdk/-/core-etherscan-sdk-3.1.0-canary.78916bb.0.tgz#f4a0513d3827f147c1b0521f0539687acab5aba2" - integrity sha512-ReIs3LZldZgcqu9LU29BYXN6N1JqgebYc2G+8gb2jP+gFSrCZrMvfNXRfeSAhe1Rg2toer9CFZj4svaBxuAkQQ== +"@avalabs/core-etherscan-sdk@3.1.0-canary.dca9ac0.0", "@avalabs/core-etherscan-sdk@3.1.0-canary.dca9ac0.0+dca9ac0": + version "3.1.0-canary.dca9ac0.0" + resolved "https://registry.yarnpkg.com/@avalabs/core-etherscan-sdk/-/core-etherscan-sdk-3.1.0-canary.dca9ac0.0.tgz#e50195780d041b4ade5f6ab74a53da7d3f1220ca" + integrity sha512-su57VGITrZic5nt94n4Mmfmk55eNV5jSMoiJE4DtK7phkMAywUsA/6YGD/wROkuHK7/39706EtI+dyyOkRBumw== dependencies: - "@avalabs/core-utils-sdk" "3.1.0-canary.78916bb.0+78916bb" + "@avalabs/core-utils-sdk" "3.1.0-canary.dca9ac0.0+dca9ac0" "@avalabs/core-k2-components@4.18.0-alpha.47": version "4.18.0-alpha.47" @@ -146,38 +146,38 @@ react-hotkeys-hook "4.4.3" uuid "9.0.1" -"@avalabs/core-snowtrace-sdk@3.1.0-canary.78916bb.0+78916bb": - version "3.1.0-canary.78916bb.0" - resolved "https://registry.yarnpkg.com/@avalabs/core-snowtrace-sdk/-/core-snowtrace-sdk-3.1.0-canary.78916bb.0.tgz#898acc85dc34c24377658cf05efca27bf67b211e" - integrity sha512-XyFsov84bf70bdP6QLtXqikRmWA6hzI7RTf8tUAN6excaIFCqXZrPZyYNs6DKFVjyzJe8W71xSPFzauh16Uu8A== +"@avalabs/core-snowtrace-sdk@3.1.0-canary.dca9ac0.0+dca9ac0": + version "3.1.0-canary.dca9ac0.0" + resolved "https://registry.yarnpkg.com/@avalabs/core-snowtrace-sdk/-/core-snowtrace-sdk-3.1.0-canary.dca9ac0.0.tgz#59943a595bed8101e3a1debb8c91e20dceae54df" + integrity sha512-ZveSa7j2ezZbGiSISKUaqi5/Tche7y3qtXh6ymnoQ6AA9T0+kV5FJwkLr/iJqczBwzmMRdYLJX9Nqrovlmup2g== dependencies: - "@avalabs/core-utils-sdk" "3.1.0-canary.78916bb.0+78916bb" + "@avalabs/core-utils-sdk" "3.1.0-canary.dca9ac0.0+dca9ac0" -"@avalabs/core-token-prices-sdk@3.1.0-canary.78916bb.0+78916bb": - version "3.1.0-canary.78916bb.0" - resolved "https://registry.yarnpkg.com/@avalabs/core-token-prices-sdk/-/core-token-prices-sdk-3.1.0-canary.78916bb.0.tgz#a7fb97893c97c2867118ef6e5f944adde2cdbc44" - integrity sha512-e4BH3kpXOX72iL/934UxhC7CjtGkET4pS2lN0OsvcL2oYLWwe/HvfTEVaVfsPZUpd9q1d9n1lBEjy8r2XRf3QA== +"@avalabs/core-token-prices-sdk@3.1.0-canary.dca9ac0.0+dca9ac0": + version "3.1.0-canary.dca9ac0.0" + resolved "https://registry.yarnpkg.com/@avalabs/core-token-prices-sdk/-/core-token-prices-sdk-3.1.0-canary.dca9ac0.0.tgz#c0c19658cfcfcf702efd92503a3a9ff45d5f8b43" + integrity sha512-BJzqzgmqxUgArNwuZdPspLSH0Ec/iWx8HfZOcObuOVLSDaAh/5rktAv9sQ2NL8DhR2e/cQRmTI4NmY/DYGKVaQ== dependencies: - "@avalabs/core-coingecko-sdk" "3.1.0-canary.78916bb.0+78916bb" - "@avalabs/core-utils-sdk" "3.1.0-canary.78916bb.0+78916bb" + "@avalabs/core-coingecko-sdk" "3.1.0-canary.dca9ac0.0+dca9ac0" + "@avalabs/core-utils-sdk" "3.1.0-canary.dca9ac0.0+dca9ac0" -"@avalabs/core-utils-sdk@3.1.0-canary.78916bb.0+78916bb": - version "3.1.0-canary.78916bb.0" - resolved "https://registry.yarnpkg.com/@avalabs/core-utils-sdk/-/core-utils-sdk-3.1.0-canary.78916bb.0.tgz#4ee6f2e1043cdfb5ecaa5004a17e691446bcffd2" - integrity sha512-HAu1BaGVKIM/vQ70X0sQiArLDYkB8vCinBYFOivrACKETTmTsUsltApgKp2eAhcvMGYX/7wNjQ9JJwmrPoh1MQ== +"@avalabs/core-utils-sdk@3.1.0-canary.dca9ac0.0", "@avalabs/core-utils-sdk@3.1.0-canary.dca9ac0.0+dca9ac0": + version "3.1.0-canary.dca9ac0.0" + resolved "https://registry.yarnpkg.com/@avalabs/core-utils-sdk/-/core-utils-sdk-3.1.0-canary.dca9ac0.0.tgz#e2e5bd6b2bc8d1414c6cc18f9c98999e6cbdf176" + integrity sha512-qdq0GhHXCFItb35rRFYc1xCHeJXDFuwCbWSFxkPAeiCTGfsK2LA2XZ1DPxpZrdjmelgE5M376vNnHJBFEPE19w== dependencies: - "@avalabs/avalanchejs" "4.1.0-alpha.15" + "@avalabs/avalanchejs" "4.1.0-alpha.21" "@hpke/core" "1.2.5" is-ipfs "6.0.2" -"@avalabs/core-wallets-sdk@3.1.0-canary.78916bb.0+78916bb": - version "3.1.0-canary.78916bb.0" - resolved "https://registry.yarnpkg.com/@avalabs/core-wallets-sdk/-/core-wallets-sdk-3.1.0-canary.78916bb.0.tgz#ab1e5510171bc49368fba3cae1382266ad8158af" - integrity sha512-5vyky83Oz/MhKHum6RUmYM0G2/2M0Mgep6mIfrbgI4QsQKUcUMFxDN7hXAwiIV0B1ULRIAnLndoyQUyKmwBRAA== +"@avalabs/core-wallets-sdk@3.1.0-canary.dca9ac0.0", "@avalabs/core-wallets-sdk@3.1.0-canary.dca9ac0.0+dca9ac0": + version "3.1.0-canary.dca9ac0.0" + resolved "https://registry.yarnpkg.com/@avalabs/core-wallets-sdk/-/core-wallets-sdk-3.1.0-canary.dca9ac0.0.tgz#a8fbd91b6b041299d77e1e74c0423bd4a324e02e" + integrity sha512-eZU64TC7eOo1L6duI+Nj6qxIEWRHum+RNrrC0U0SUX95Lg2Z3s5gQMwa7nUHH8ByIb6ONDKUPqgqSt9iH4ErFg== dependencies: - "@avalabs/avalanchejs" "4.1.0-alpha.15" - "@avalabs/core-chains-sdk" "3.1.0-canary.78916bb.0+78916bb" - "@avalabs/glacier-sdk" "3.1.0-canary.78916bb.0+78916bb" + "@avalabs/avalanchejs" "4.1.0-alpha.21" + "@avalabs/core-chains-sdk" "3.1.0-canary.dca9ac0.0+dca9ac0" + "@avalabs/glacier-sdk" "3.1.0-canary.dca9ac0.0+dca9ac0" "@avalabs/hw-app-avalanche" "0.14.1" "@ledgerhq/hw-app-btc" "10.2.4" "@ledgerhq/hw-app-eth" "6.36.1" @@ -194,18 +194,18 @@ ledger-bitcoin "0.2.3" xss "1.0.14" -"@avalabs/evm-module@0.0.0-feat-p-dynamic-fees-20241107092624": - version "0.0.0-feat-p-dynamic-fees-20241107092624" - resolved "https://registry.yarnpkg.com/@avalabs/evm-module/-/evm-module-0.0.0-feat-p-dynamic-fees-20241107092624.tgz#23087cb4d86a600bd354baa89a78011d01f773c3" - integrity sha512-c3qztYdYLBxfq6r3gON3rNk/tVeQZ8r6kU3ERijPRCmELbf4v+hSJWZPG3ncwPSzh/N0WStiOv7OzQ6XA7Kysw== - dependencies: - "@avalabs/core-coingecko-sdk" "3.1.0-canary.78916bb.0+78916bb" - "@avalabs/core-etherscan-sdk" "3.1.0-canary.78916bb.0+78916bb" - "@avalabs/core-utils-sdk" "3.1.0-canary.78916bb.0+78916bb" - "@avalabs/core-wallets-sdk" "3.1.0-canary.78916bb.0+78916bb" - "@avalabs/glacier-sdk" "3.1.0-canary.78916bb.0+78916bb" - "@avalabs/types" "3.1.0-canary.78916bb.0+78916bb" - "@avalabs/vm-module-types" "0.0.0-feat-p-dynamic-fees-20241107092624" +"@avalabs/evm-module@0.0.0-feat-p-dynamic-fees-20241115122103": + version "0.0.0-feat-p-dynamic-fees-20241115122103" + resolved "https://registry.yarnpkg.com/@avalabs/evm-module/-/evm-module-0.0.0-feat-p-dynamic-fees-20241115122103.tgz#b4a96c16caf7f0c0de102018f94462f2e58e4e1e" + integrity sha512-/ZHAmNE7rdP0dSrWmjUB7uLd0kb9FTiVBdih1cv6Dg6TdAaLwyziZNdZ7M+vQyZjll1wv5ftWhYcmE9IyaZ9dA== + dependencies: + "@avalabs/core-coingecko-sdk" "3.1.0-canary.dca9ac0.0" + "@avalabs/core-etherscan-sdk" "3.1.0-canary.dca9ac0.0" + "@avalabs/core-utils-sdk" "3.1.0-canary.dca9ac0.0" + "@avalabs/core-wallets-sdk" "3.1.0-canary.dca9ac0.0" + "@avalabs/glacier-sdk" "3.1.0-canary.dca9ac0.0" + "@avalabs/types" "3.1.0-canary.dca9ac0.0" + "@avalabs/vm-module-types" "0.0.0-feat-p-dynamic-fees-20241115122103" "@blockaid/client" "0.11.0" "@metamask/rpc-errors" "6.3.0" "@openzeppelin/contracts" "4.9.6" @@ -214,10 +214,10 @@ xss "1.0.13" zod "3.23.8" -"@avalabs/glacier-sdk@3.1.0-canary.78916bb.0+78916bb": - version "3.1.0-canary.78916bb.0" - resolved "https://registry.yarnpkg.com/@avalabs/glacier-sdk/-/glacier-sdk-3.1.0-canary.78916bb.0.tgz#17969b409fddbeecb842dd5f130a09b13f1f2c8d" - integrity sha512-wNuQFi73aIQm54PP3i1YnoKzmVn8aLWS/bOaz0qV0gUcnvrQq02KkBbC7nlm1f+1p1LbdhyOZ613jU6Y6nXO1A== +"@avalabs/glacier-sdk@3.1.0-canary.dca9ac0.0", "@avalabs/glacier-sdk@3.1.0-canary.dca9ac0.0+dca9ac0": + version "3.1.0-canary.dca9ac0.0" + resolved "https://registry.yarnpkg.com/@avalabs/glacier-sdk/-/glacier-sdk-3.1.0-canary.dca9ac0.0.tgz#f325ace412a644ccfe0ac09fd59c4fb60803810f" + integrity sha512-CXSlrmAGQKGDNfUYaG1arnKLeA/cRidQDdWjWaSYsgNr7CHBAvadQZGsixBuAI8Z301HZl3edco1IUazgjKJYQ== "@avalabs/hw-app-avalanche@0.14.1": version "0.14.1" @@ -230,18 +230,18 @@ ledger-bitcoin "^0.2.1" sha3 "2.1.4" -"@avalabs/types@3.1.0-canary.78916bb.0+78916bb": - version "3.1.0-canary.78916bb.0" - resolved "https://registry.yarnpkg.com/@avalabs/types/-/types-3.1.0-canary.78916bb.0.tgz#3b0d7864fbdbafe7153ea744b95044b9393846f9" - integrity sha512-Jjvn47sa0ZjRS/JC6jE9SYTvW4vU2yxAoSai29M/7UB8wij5+g1FpiX6KUci//e0GrQxukqMWMMXZ/5E24h/UQ== +"@avalabs/types@3.1.0-canary.dca9ac0.0", "@avalabs/types@3.1.0-canary.dca9ac0.0+dca9ac0": + version "3.1.0-canary.dca9ac0.0" + resolved "https://registry.yarnpkg.com/@avalabs/types/-/types-3.1.0-canary.dca9ac0.0.tgz#f23564a79b0fd264a26205a2509e5d86069c7714" + integrity sha512-UK5koEbp+ePFjDxGqv8BvA1SqEeIWfkWmkRgXVCEbdqwQWCIRSmNekTRXaL42JN4idDx773D/p2bhMGkFd5aUQ== -"@avalabs/vm-module-types@0.0.0-feat-p-dynamic-fees-20241107092624": - version "0.0.0-feat-p-dynamic-fees-20241107092624" - resolved "https://registry.yarnpkg.com/@avalabs/vm-module-types/-/vm-module-types-0.0.0-feat-p-dynamic-fees-20241107092624.tgz#3bd50e2bb642814c27b011b6534aa6cc61a4a04c" - integrity sha512-GUDkXV8yvzCVF8kKiaXnE1kF0h6n7olBrqoAAPH3NsFqZHODhXBkaGaQNe78L4BztDfZQnRfCSxLwYirdoO/hQ== +"@avalabs/vm-module-types@0.0.0-feat-p-dynamic-fees-20241115122103": + version "0.0.0-feat-p-dynamic-fees-20241115122103" + resolved "https://registry.yarnpkg.com/@avalabs/vm-module-types/-/vm-module-types-0.0.0-feat-p-dynamic-fees-20241115122103.tgz#9dc616945a8868eeaed667d58fb89601c597bbc8" + integrity sha512-aX9uXGSXBliL7T6k/JiGmkF8rtLgU1nUNjYpYlGI4DFc0p+Eaf03aF48eQUNzmnMQ5nbUfQpTgS2fADgp9kinw== dependencies: - "@avalabs/core-wallets-sdk" "3.1.0-canary.78916bb.0+78916bb" - "@avalabs/glacier-sdk" "3.1.0-canary.78916bb.0+78916bb" + "@avalabs/core-wallets-sdk" "3.1.0-canary.dca9ac0.0" + "@avalabs/glacier-sdk" "3.1.0-canary.dca9ac0.0" "@metamask/rpc-errors" "6.3.0" bitcoinjs-lib "5.2.0" zod "3.23.8" From eb35b361043b60f3ff9c9a2d981a3f6de226ea7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Leszczyk?= Date: Fri, 15 Nov 2024 15:17:51 +0100 Subject: [PATCH 11/16] chore: remove avalanche_sendTransaction from approval controller --- .../vmModules/ApprovalController.ts | 33 ------------------- 1 file changed, 33 deletions(-) diff --git a/src/background/vmModules/ApprovalController.ts b/src/background/vmModules/ApprovalController.ts index 59d01c0db..7e4bbd654 100644 --- a/src/background/vmModules/ApprovalController.ts +++ b/src/background/vmModules/ApprovalController.ts @@ -19,8 +19,6 @@ import { NetworkWithCaipId } from '../services/network/models'; import { ApprovalParamsWithContext } from './models'; import { ACTION_HANDLED_BY_MODULE } from '../models'; -import { EVM, EVMUnsignedTx, UnsignedTx } from '@avalabs/avalanchejs'; -import { Avalanche } from '@avalabs/core-wallets-sdk'; @singleton() export class ApprovalController implements IApprovalController { @@ -182,37 +180,6 @@ export class ApprovalController implements IApprovalController { network, action.tabId ); - case RpcMethod.AVALANCHE_SEND_TRANSACTION: { - const result = await this.#walletService.sign( - { - tx: - signingData.vm === EVM - ? EVMUnsignedTx.fromJSON(signingData.unsignedTxJson) - : UnsignedTx.fromJSON(signingData.unsignedTxJson), - internalIndices: signingData.internalIndices, - externalIndices: signingData.externalIndices, - }, - network, - action.tabId - ); - - if ('txHash' in result) { - return result; - } - - const signedTransaction = - signingData.vm === EVM - ? EVMUnsignedTx.fromJSON(result.signedTx) - : UnsignedTx.fromJSON(result.signedTx); - - if (!signedTransaction.hasAllSignatures()) { - throw new Error('Signing error, missing signatures.'); - } - - return { - signedTx: Avalanche.signedTxToHex(signedTransaction.getSignedTx()), - }; - } default: throw new Error('Unrecognized method: ' + params.request.method); From c6a7781b4dee8141d7ae1a8b4e4217d7930bad98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Leszczyk?= Date: Fri, 15 Nov 2024 20:21:27 +0100 Subject: [PATCH 12/16] chore: switch from canary to alpha SDKs --- package.json | 30 ++++---- yarn.lock | 188 +++++++++++++++++++++++++-------------------------- 2 files changed, 109 insertions(+), 109 deletions(-) diff --git a/package.json b/package.json index 5abea7960..0c6e39a4f 100644 --- a/package.json +++ b/package.json @@ -23,25 +23,25 @@ "sentry": "node sentryscript.js" }, "dependencies": { - "@avalabs/avalanche-module": "0.0.0-feat-p-dynamic-fees-20241115122103", + "@avalabs/avalanche-module": "0.11.10", "@avalabs/avalanchejs": "4.1.0-alpha.21", - "@avalabs/bitcoin-module": "0.0.0-feat-p-dynamic-fees-20241115122103", + "@avalabs/bitcoin-module": "0.11.10", "@avalabs/bridge-unified": "0.0.0-feat-ictt-configs-20241009072139", - "@avalabs/core-bridge-sdk": "3.1.0-canary.dca9ac0.0+dca9ac0", - "@avalabs/core-chains-sdk": "3.1.0-canary.dca9ac0.0+dca9ac0", - "@avalabs/core-coingecko-sdk": "3.1.0-canary.dca9ac0.0+dca9ac0", - "@avalabs/core-covalent-sdk": "3.1.0-canary.dca9ac0.0+dca9ac0", - "@avalabs/core-etherscan-sdk": "3.1.0-canary.dca9ac0.0+dca9ac0", + "@avalabs/core-bridge-sdk": "3.1.0-alpha.13", + "@avalabs/core-chains-sdk": "3.1.0-alpha.13", + "@avalabs/core-coingecko-sdk": "3.1.0-alpha.13", + "@avalabs/core-covalent-sdk": "3.1.0-alpha.13", + "@avalabs/core-etherscan-sdk": "3.1.0-alpha.13", "@avalabs/core-k2-components": "4.18.0-alpha.47", - "@avalabs/core-snowtrace-sdk": "3.1.0-canary.dca9ac0.0+dca9ac0", - "@avalabs/core-token-prices-sdk": "3.1.0-canary.dca9ac0.0+dca9ac0", - "@avalabs/core-utils-sdk": "3.1.0-canary.dca9ac0.0+dca9ac0", - "@avalabs/core-wallets-sdk": "3.1.0-canary.dca9ac0.0+dca9ac0", - "@avalabs/evm-module": "0.0.0-feat-p-dynamic-fees-20241115122103", - "@avalabs/glacier-sdk": "3.1.0-canary.dca9ac0.0+dca9ac0", + "@avalabs/core-snowtrace-sdk": "3.1.0-alpha.13", + "@avalabs/core-token-prices-sdk": "3.1.0-alpha.13", + "@avalabs/core-utils-sdk": "3.1.0-alpha.13", + "@avalabs/core-wallets-sdk": "3.1.0-alpha.13", + "@avalabs/evm-module": "0.11.10", + "@avalabs/glacier-sdk": "3.1.0-alpha.13", "@avalabs/hw-app-avalanche": "0.14.1", - "@avalabs/types": "3.1.0-canary.dca9ac0.0+dca9ac0", - "@avalabs/vm-module-types": "0.0.0-feat-p-dynamic-fees-20241115122103", + "@avalabs/types": "3.1.0-alpha.13", + "@avalabs/vm-module-types": "0.11.10", "@blockaid/client": "0.10.0", "@coinbase/cbpay-js": "1.6.0", "@cubist-labs/cubesigner-sdk": "0.3.28", diff --git a/yarn.lock b/yarn.lock index 0ec3a75a0..f762b31a6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -29,20 +29,20 @@ resolved "https://registry.yarnpkg.com/@apocentre/alias-sampling/-/alias-sampling-0.5.3.tgz#897ff181b48ad7b2bcb4ecf29400214888244f08" integrity sha512-7UDWIIF9hIeJqfKXkNIzkVandlwLf1FWTSdrb9iXvOP8oF544JRXQjCbiTmCv2c9n44n/FIWtehhBfNuAx2CZA== -"@avalabs/avalanche-module@0.0.0-feat-p-dynamic-fees-20241115122103": - version "0.0.0-feat-p-dynamic-fees-20241115122103" - resolved "https://registry.yarnpkg.com/@avalabs/avalanche-module/-/avalanche-module-0.0.0-feat-p-dynamic-fees-20241115122103.tgz#f5597c863d825fca45d7d0d5c4e009427ac25b1d" - integrity sha512-qqzRY6M7whj9BDP9nPt203q2D/7jKOkxoCtyn6IypARfabNHoQniau6QKeVbGffQoC/XuuGa/3fHxQxN/Lq+Kw== +"@avalabs/avalanche-module@0.11.10": + version "0.11.10" + resolved "https://registry.yarnpkg.com/@avalabs/avalanche-module/-/avalanche-module-0.11.10.tgz#e3d34ff2bb03fadbc0a5f6620dd73a132a158103" + integrity sha512-EJnOfKlOgnDDRRuNrKr82b3+Q3/qEjR42K7AJ831AxzZBYOeiaVa/PUAqvS8xD69vIJQS/WL7igaqzIqcsFVQw== dependencies: "@avalabs/avalanchejs" "4.1.0-alpha.21" - "@avalabs/core-chains-sdk" "3.1.0-canary.dca9ac0.0" - "@avalabs/core-coingecko-sdk" "3.1.0-canary.dca9ac0.0" - "@avalabs/core-etherscan-sdk" "3.1.0-canary.dca9ac0.0" - "@avalabs/core-utils-sdk" "3.1.0-canary.dca9ac0.0" - "@avalabs/core-wallets-sdk" "3.1.0-canary.dca9ac0.0" - "@avalabs/glacier-sdk" "3.1.0-canary.dca9ac0.0" - "@avalabs/types" "3.1.0-canary.dca9ac0.0" - "@avalabs/vm-module-types" "0.0.0-feat-p-dynamic-fees-20241115122103" + "@avalabs/core-chains-sdk" "3.1.0-alpha.13" + "@avalabs/core-coingecko-sdk" "3.1.0-alpha.13" + "@avalabs/core-etherscan-sdk" "3.1.0-alpha.13" + "@avalabs/core-utils-sdk" "3.1.0-alpha.13" + "@avalabs/core-wallets-sdk" "3.1.0-alpha.13" + "@avalabs/glacier-sdk" "3.1.0-alpha.13" + "@avalabs/types" "3.1.0-alpha.13" + "@avalabs/vm-module-types" "0.11.10" "@metamask/rpc-errors" "6.3.0" big.js "6.2.1" bn.js "5.2.1" @@ -59,15 +59,15 @@ "@scure/base" "1.1.5" micro-eth-signer "0.7.2" -"@avalabs/bitcoin-module@0.0.0-feat-p-dynamic-fees-20241115122103": - version "0.0.0-feat-p-dynamic-fees-20241115122103" - resolved "https://registry.yarnpkg.com/@avalabs/bitcoin-module/-/bitcoin-module-0.0.0-feat-p-dynamic-fees-20241115122103.tgz#966492875039f3b4a328091b6b094ac6ddc8a54f" - integrity sha512-Y7xyfQE3EQs03WntwXRhAAJTzbpVReKJ8QyHTn4Zrw3O+u48j4MSoJPsiaAz8JfjxGz7Xh0P93BMXRPmzT2Gfw== +"@avalabs/bitcoin-module@0.11.10": + version "0.11.10" + resolved "https://registry.yarnpkg.com/@avalabs/bitcoin-module/-/bitcoin-module-0.11.10.tgz#f16e44aa5dd6813f710d4adae8f9eb2d2a318787" + integrity sha512-sjRwUDIfo8d2ycSp/Bi72PSeWVN5wZQTdygAEm3KBr/kpKCopQIjBhOMHw0v1NYp0ImFAA/4xQkUb2HsxYGwpg== dependencies: - "@avalabs/core-coingecko-sdk" "3.1.0-canary.dca9ac0.0" - "@avalabs/core-utils-sdk" "3.1.0-canary.dca9ac0.0" - "@avalabs/core-wallets-sdk" "3.1.0-canary.dca9ac0.0" - "@avalabs/vm-module-types" "0.0.0-feat-p-dynamic-fees-20241115122103" + "@avalabs/core-coingecko-sdk" "3.1.0-alpha.13" + "@avalabs/core-utils-sdk" "3.1.0-alpha.13" + "@avalabs/core-wallets-sdk" "3.1.0-alpha.13" + "@avalabs/vm-module-types" "0.11.10" "@metamask/rpc-errors" "6.3.0" big.js "6.2.1" bitcoinjs-lib "5.2.0" @@ -86,42 +86,42 @@ viem "2.11.1" zod "3.23.8" -"@avalabs/core-bridge-sdk@3.1.0-canary.dca9ac0.0+dca9ac0": - version "3.1.0-canary.dca9ac0.0" - resolved "https://registry.yarnpkg.com/@avalabs/core-bridge-sdk/-/core-bridge-sdk-3.1.0-canary.dca9ac0.0.tgz#9c1612225168965615536256407308dcf5c32ffe" - integrity sha512-JWqDqO37B++Cd792MHvXaQ1rCzbGXo/m2kyRtg8KXSrhFhEE7Rt85LWUMzkPouUEdTNLOXU23cg6x+7rYTzVMw== +"@avalabs/core-bridge-sdk@3.1.0-alpha.13": + version "3.1.0-alpha.13" + resolved "https://registry.yarnpkg.com/@avalabs/core-bridge-sdk/-/core-bridge-sdk-3.1.0-alpha.13.tgz#04f0f7869581a5959103d2ee29a094681ca5cbd8" + integrity sha512-Rb8vbUw22alst0w9oJ/zbmxS9eryjFf9WzLrdsevoG/C9CW9nl2b49kvNoSA7GRrogaa0mTuQe32RwDyAJWVxA== dependencies: - "@avalabs/core-coingecko-sdk" "3.1.0-canary.dca9ac0.0+dca9ac0" - "@avalabs/core-utils-sdk" "3.1.0-canary.dca9ac0.0+dca9ac0" - "@avalabs/core-wallets-sdk" "3.1.0-canary.dca9ac0.0+dca9ac0" + "@avalabs/core-coingecko-sdk" "3.1.0-alpha.13" + "@avalabs/core-utils-sdk" "3.1.0-alpha.13" + "@avalabs/core-wallets-sdk" "3.1.0-alpha.13" -"@avalabs/core-chains-sdk@3.1.0-canary.dca9ac0.0", "@avalabs/core-chains-sdk@3.1.0-canary.dca9ac0.0+dca9ac0": - version "3.1.0-canary.dca9ac0.0" - resolved "https://registry.yarnpkg.com/@avalabs/core-chains-sdk/-/core-chains-sdk-3.1.0-canary.dca9ac0.0.tgz#6780f3d85035d753fc8ceca0e616f6a04b36e855" - integrity sha512-Y8+9JF1x6cfmGH4avPLYituFKEihjywtq2CVkwDL1No1MG/nvH1pFPnggy7zLWTtU/nzcM5olw5FZm1LWmjS9Q== +"@avalabs/core-chains-sdk@3.1.0-alpha.13": + version "3.1.0-alpha.13" + resolved "https://registry.yarnpkg.com/@avalabs/core-chains-sdk/-/core-chains-sdk-3.1.0-alpha.13.tgz#fff4ec37e20252f662b8d643bdc7a58cebd77130" + integrity sha512-BJsG4q0PV9vtrfKE8G50VSaDkhUYS1RvkqNk/VH5RKiSmpLSF/XVl6b/wO5sZEPzARTesEKoO2LMuZnwGwj4hQ== dependencies: - "@avalabs/core-utils-sdk" "3.1.0-canary.dca9ac0.0+dca9ac0" + "@avalabs/core-utils-sdk" "3.1.0-alpha.13" -"@avalabs/core-coingecko-sdk@3.1.0-canary.dca9ac0.0", "@avalabs/core-coingecko-sdk@3.1.0-canary.dca9ac0.0+dca9ac0": - version "3.1.0-canary.dca9ac0.0" - resolved "https://registry.yarnpkg.com/@avalabs/core-coingecko-sdk/-/core-coingecko-sdk-3.1.0-canary.dca9ac0.0.tgz#50c59f642a6cb804069044ef32d5f0f83a6281e9" - integrity sha512-DN2bC98MXw0PkbJqzHnrvDgP9zFprn+b6HjhsR9LLIC2fCMhQzyIWJaEQXzwc0ZNyo86HI2lSJE6gHq8w+a0WQ== +"@avalabs/core-coingecko-sdk@3.1.0-alpha.13": + version "3.1.0-alpha.13" + resolved "https://registry.yarnpkg.com/@avalabs/core-coingecko-sdk/-/core-coingecko-sdk-3.1.0-alpha.13.tgz#080fd79ff9a9fc28ea0eec863481b1dbd40fd2e9" + integrity sha512-m25kY+NeqRYwJL6YbRYFbiNaoUfl33ggXI6i+rGU3QlCnZ0A7oCSa0vT/PUZr5caqJccDuYHICDysZcYAtjpMg== dependencies: - "@avalabs/core-utils-sdk" "3.1.0-canary.dca9ac0.0+dca9ac0" + "@avalabs/core-utils-sdk" "3.1.0-alpha.13" -"@avalabs/core-covalent-sdk@3.1.0-canary.dca9ac0.0+dca9ac0": - version "3.1.0-canary.dca9ac0.0" - resolved "https://registry.yarnpkg.com/@avalabs/core-covalent-sdk/-/core-covalent-sdk-3.1.0-canary.dca9ac0.0.tgz#39af6930dc251d6da657894a2b687cd2721efaba" - integrity sha512-ii5PZQFqPT+ssQLzUhsp1wGSLLXVmfOrLkCg6l4/5lGHCBaPFmlkH8VE0V0CMzOXYjiDI+8FWXqVYI5Stp7Uug== +"@avalabs/core-covalent-sdk@3.1.0-alpha.13": + version "3.1.0-alpha.13" + resolved "https://registry.yarnpkg.com/@avalabs/core-covalent-sdk/-/core-covalent-sdk-3.1.0-alpha.13.tgz#a6bf5a8721f1aa141cbf6a71cdb850041348cd98" + integrity sha512-t94q2nlUMOTGlMj23ncu+3hlrRE1o/A9ZtvQbwkOYrwwTf/Adpn+nmjON9KKUKdNkwA9esp5Xd8vIXTwC+TEEw== dependencies: - "@avalabs/core-utils-sdk" "3.1.0-canary.dca9ac0.0+dca9ac0" + "@avalabs/core-utils-sdk" "3.1.0-alpha.13" -"@avalabs/core-etherscan-sdk@3.1.0-canary.dca9ac0.0", "@avalabs/core-etherscan-sdk@3.1.0-canary.dca9ac0.0+dca9ac0": - version "3.1.0-canary.dca9ac0.0" - resolved "https://registry.yarnpkg.com/@avalabs/core-etherscan-sdk/-/core-etherscan-sdk-3.1.0-canary.dca9ac0.0.tgz#e50195780d041b4ade5f6ab74a53da7d3f1220ca" - integrity sha512-su57VGITrZic5nt94n4Mmfmk55eNV5jSMoiJE4DtK7phkMAywUsA/6YGD/wROkuHK7/39706EtI+dyyOkRBumw== +"@avalabs/core-etherscan-sdk@3.1.0-alpha.13": + version "3.1.0-alpha.13" + resolved "https://registry.yarnpkg.com/@avalabs/core-etherscan-sdk/-/core-etherscan-sdk-3.1.0-alpha.13.tgz#b6b963b6dd81d659bc65d16a39ab38cc989dda77" + integrity sha512-5pZBsjS0aK5AIQjLliuQgcoFftUUaJ2QGMEqlHwvw26R/imXlY5a8JGrWlJ/ZkfIY8RWoqhf1LuKvRG1+Xi7DQ== dependencies: - "@avalabs/core-utils-sdk" "3.1.0-canary.dca9ac0.0+dca9ac0" + "@avalabs/core-utils-sdk" "3.1.0-alpha.13" "@avalabs/core-k2-components@4.18.0-alpha.47": version "4.18.0-alpha.47" @@ -146,38 +146,38 @@ react-hotkeys-hook "4.4.3" uuid "9.0.1" -"@avalabs/core-snowtrace-sdk@3.1.0-canary.dca9ac0.0+dca9ac0": - version "3.1.0-canary.dca9ac0.0" - resolved "https://registry.yarnpkg.com/@avalabs/core-snowtrace-sdk/-/core-snowtrace-sdk-3.1.0-canary.dca9ac0.0.tgz#59943a595bed8101e3a1debb8c91e20dceae54df" - integrity sha512-ZveSa7j2ezZbGiSISKUaqi5/Tche7y3qtXh6ymnoQ6AA9T0+kV5FJwkLr/iJqczBwzmMRdYLJX9Nqrovlmup2g== +"@avalabs/core-snowtrace-sdk@3.1.0-alpha.13": + version "3.1.0-alpha.13" + resolved "https://registry.yarnpkg.com/@avalabs/core-snowtrace-sdk/-/core-snowtrace-sdk-3.1.0-alpha.13.tgz#4093728087903cec0dff461e37d2d261a361d3dc" + integrity sha512-gDtuUHoXAfUharWfd5ETGvjWl77ass+VwgcadxmCAeAN+WMzucP4cuxjFgYrHrzXqbPbXt2iO22F+q5hgGjoCw== dependencies: - "@avalabs/core-utils-sdk" "3.1.0-canary.dca9ac0.0+dca9ac0" + "@avalabs/core-utils-sdk" "3.1.0-alpha.13" -"@avalabs/core-token-prices-sdk@3.1.0-canary.dca9ac0.0+dca9ac0": - version "3.1.0-canary.dca9ac0.0" - resolved "https://registry.yarnpkg.com/@avalabs/core-token-prices-sdk/-/core-token-prices-sdk-3.1.0-canary.dca9ac0.0.tgz#c0c19658cfcfcf702efd92503a3a9ff45d5f8b43" - integrity sha512-BJzqzgmqxUgArNwuZdPspLSH0Ec/iWx8HfZOcObuOVLSDaAh/5rktAv9sQ2NL8DhR2e/cQRmTI4NmY/DYGKVaQ== +"@avalabs/core-token-prices-sdk@3.1.0-alpha.13": + version "3.1.0-alpha.13" + resolved "https://registry.yarnpkg.com/@avalabs/core-token-prices-sdk/-/core-token-prices-sdk-3.1.0-alpha.13.tgz#0f3b531485a564e41737606aa892835b0ab50bce" + integrity sha512-F5+6mFLzynZL07qobL+om7nkKu+b6mG4CmLyfhYAJLG071m5l6EHUigK8pis256v9D0HIFqrLMYZDAA6jwxYSw== dependencies: - "@avalabs/core-coingecko-sdk" "3.1.0-canary.dca9ac0.0+dca9ac0" - "@avalabs/core-utils-sdk" "3.1.0-canary.dca9ac0.0+dca9ac0" + "@avalabs/core-coingecko-sdk" "3.1.0-alpha.13" + "@avalabs/core-utils-sdk" "3.1.0-alpha.13" -"@avalabs/core-utils-sdk@3.1.0-canary.dca9ac0.0", "@avalabs/core-utils-sdk@3.1.0-canary.dca9ac0.0+dca9ac0": - version "3.1.0-canary.dca9ac0.0" - resolved "https://registry.yarnpkg.com/@avalabs/core-utils-sdk/-/core-utils-sdk-3.1.0-canary.dca9ac0.0.tgz#e2e5bd6b2bc8d1414c6cc18f9c98999e6cbdf176" - integrity sha512-qdq0GhHXCFItb35rRFYc1xCHeJXDFuwCbWSFxkPAeiCTGfsK2LA2XZ1DPxpZrdjmelgE5M376vNnHJBFEPE19w== +"@avalabs/core-utils-sdk@3.1.0-alpha.13": + version "3.1.0-alpha.13" + resolved "https://registry.yarnpkg.com/@avalabs/core-utils-sdk/-/core-utils-sdk-3.1.0-alpha.13.tgz#ae6a785478c8dfd0907bf61e7f1758cce386598c" + integrity sha512-uo0JnLSnZYUswRlLfcrJ7KmO3/UOIHMKKQgU0KdQQ7j7oUBFOTyq7PBDalQ3T7tBIKC1qOAdmH19QyUGdf2/+w== dependencies: "@avalabs/avalanchejs" "4.1.0-alpha.21" "@hpke/core" "1.2.5" is-ipfs "6.0.2" -"@avalabs/core-wallets-sdk@3.1.0-canary.dca9ac0.0", "@avalabs/core-wallets-sdk@3.1.0-canary.dca9ac0.0+dca9ac0": - version "3.1.0-canary.dca9ac0.0" - resolved "https://registry.yarnpkg.com/@avalabs/core-wallets-sdk/-/core-wallets-sdk-3.1.0-canary.dca9ac0.0.tgz#a8fbd91b6b041299d77e1e74c0423bd4a324e02e" - integrity sha512-eZU64TC7eOo1L6duI+Nj6qxIEWRHum+RNrrC0U0SUX95Lg2Z3s5gQMwa7nUHH8ByIb6ONDKUPqgqSt9iH4ErFg== +"@avalabs/core-wallets-sdk@3.1.0-alpha.13": + version "3.1.0-alpha.13" + resolved "https://registry.yarnpkg.com/@avalabs/core-wallets-sdk/-/core-wallets-sdk-3.1.0-alpha.13.tgz#b4ff83a019c94c83e69e0c83604b2ba9c840ea63" + integrity sha512-/aPsFw46OXVl1anzqCm1+qKa/Jna+f/aAMsttb11AmFaHOAK3I1s35XQKmO9ZJTSLePA+24Im5dTR/QwrURLuw== dependencies: "@avalabs/avalanchejs" "4.1.0-alpha.21" - "@avalabs/core-chains-sdk" "3.1.0-canary.dca9ac0.0+dca9ac0" - "@avalabs/glacier-sdk" "3.1.0-canary.dca9ac0.0+dca9ac0" + "@avalabs/core-chains-sdk" "3.1.0-alpha.13" + "@avalabs/glacier-sdk" "3.1.0-alpha.13" "@avalabs/hw-app-avalanche" "0.14.1" "@ledgerhq/hw-app-btc" "10.2.4" "@ledgerhq/hw-app-eth" "6.36.1" @@ -194,18 +194,18 @@ ledger-bitcoin "0.2.3" xss "1.0.14" -"@avalabs/evm-module@0.0.0-feat-p-dynamic-fees-20241115122103": - version "0.0.0-feat-p-dynamic-fees-20241115122103" - resolved "https://registry.yarnpkg.com/@avalabs/evm-module/-/evm-module-0.0.0-feat-p-dynamic-fees-20241115122103.tgz#b4a96c16caf7f0c0de102018f94462f2e58e4e1e" - integrity sha512-/ZHAmNE7rdP0dSrWmjUB7uLd0kb9FTiVBdih1cv6Dg6TdAaLwyziZNdZ7M+vQyZjll1wv5ftWhYcmE9IyaZ9dA== - dependencies: - "@avalabs/core-coingecko-sdk" "3.1.0-canary.dca9ac0.0" - "@avalabs/core-etherscan-sdk" "3.1.0-canary.dca9ac0.0" - "@avalabs/core-utils-sdk" "3.1.0-canary.dca9ac0.0" - "@avalabs/core-wallets-sdk" "3.1.0-canary.dca9ac0.0" - "@avalabs/glacier-sdk" "3.1.0-canary.dca9ac0.0" - "@avalabs/types" "3.1.0-canary.dca9ac0.0" - "@avalabs/vm-module-types" "0.0.0-feat-p-dynamic-fees-20241115122103" +"@avalabs/evm-module@0.11.10": + version "0.11.10" + resolved "https://registry.yarnpkg.com/@avalabs/evm-module/-/evm-module-0.11.10.tgz#d7f028bd140f765aa07870fb2cfe5439e40f7f79" + integrity sha512-SZN32O8U37M6rCh6sCefOqXkMief3qkZvapuFH9NmZPj93o2tYSznDp2kwj/L8j7L42Nsq/wtnz8qzowmPq8hA== + dependencies: + "@avalabs/core-coingecko-sdk" "3.1.0-alpha.13" + "@avalabs/core-etherscan-sdk" "3.1.0-alpha.13" + "@avalabs/core-utils-sdk" "3.1.0-alpha.13" + "@avalabs/core-wallets-sdk" "3.1.0-alpha.13" + "@avalabs/glacier-sdk" "3.1.0-alpha.13" + "@avalabs/types" "3.1.0-alpha.13" + "@avalabs/vm-module-types" "0.11.10" "@blockaid/client" "0.11.0" "@metamask/rpc-errors" "6.3.0" "@openzeppelin/contracts" "4.9.6" @@ -214,10 +214,10 @@ xss "1.0.13" zod "3.23.8" -"@avalabs/glacier-sdk@3.1.0-canary.dca9ac0.0", "@avalabs/glacier-sdk@3.1.0-canary.dca9ac0.0+dca9ac0": - version "3.1.0-canary.dca9ac0.0" - resolved "https://registry.yarnpkg.com/@avalabs/glacier-sdk/-/glacier-sdk-3.1.0-canary.dca9ac0.0.tgz#f325ace412a644ccfe0ac09fd59c4fb60803810f" - integrity sha512-CXSlrmAGQKGDNfUYaG1arnKLeA/cRidQDdWjWaSYsgNr7CHBAvadQZGsixBuAI8Z301HZl3edco1IUazgjKJYQ== +"@avalabs/glacier-sdk@3.1.0-alpha.13": + version "3.1.0-alpha.13" + resolved "https://registry.yarnpkg.com/@avalabs/glacier-sdk/-/glacier-sdk-3.1.0-alpha.13.tgz#cd11d2dfa6492d53f5f6e647c74d463c597cee76" + integrity sha512-B1bRC6J/89dTdVuXyEJxDbOdoHV3THPkearlVGcE0Rc0t/ZC+fJxuFFtLWyf9Td6pZ9C7xa3OLxSHRElrKIvLA== "@avalabs/hw-app-avalanche@0.14.1": version "0.14.1" @@ -230,18 +230,18 @@ ledger-bitcoin "^0.2.1" sha3 "2.1.4" -"@avalabs/types@3.1.0-canary.dca9ac0.0", "@avalabs/types@3.1.0-canary.dca9ac0.0+dca9ac0": - version "3.1.0-canary.dca9ac0.0" - resolved "https://registry.yarnpkg.com/@avalabs/types/-/types-3.1.0-canary.dca9ac0.0.tgz#f23564a79b0fd264a26205a2509e5d86069c7714" - integrity sha512-UK5koEbp+ePFjDxGqv8BvA1SqEeIWfkWmkRgXVCEbdqwQWCIRSmNekTRXaL42JN4idDx773D/p2bhMGkFd5aUQ== +"@avalabs/types@3.1.0-alpha.13": + version "3.1.0-alpha.13" + resolved "https://registry.yarnpkg.com/@avalabs/types/-/types-3.1.0-alpha.13.tgz#e018c9d9feae1b211e24ec33fe8b53135f1c938f" + integrity sha512-YX2SAFYl/7VeDjVhNOUqjDZ+R/gkTBZVll8+dgBE53A062j81QPCq0XlsLwvlYpjdPNmCjoSgi1mRe6cyrS0Lw== -"@avalabs/vm-module-types@0.0.0-feat-p-dynamic-fees-20241115122103": - version "0.0.0-feat-p-dynamic-fees-20241115122103" - resolved "https://registry.yarnpkg.com/@avalabs/vm-module-types/-/vm-module-types-0.0.0-feat-p-dynamic-fees-20241115122103.tgz#9dc616945a8868eeaed667d58fb89601c597bbc8" - integrity sha512-aX9uXGSXBliL7T6k/JiGmkF8rtLgU1nUNjYpYlGI4DFc0p+Eaf03aF48eQUNzmnMQ5nbUfQpTgS2fADgp9kinw== +"@avalabs/vm-module-types@0.11.10": + version "0.11.10" + resolved "https://registry.yarnpkg.com/@avalabs/vm-module-types/-/vm-module-types-0.11.10.tgz#6aa783c65bc1b4da83a56b4c823a7d52f55a5315" + integrity sha512-ppEWkV91f8XFLYyVO/TB9Xlv6WWCg0QlgolXHusYY3yqXmXoaTBjw+i4GzPZ2i3lL+/mFIwqCKqLqtVIuCzrwg== dependencies: - "@avalabs/core-wallets-sdk" "3.1.0-canary.dca9ac0.0" - "@avalabs/glacier-sdk" "3.1.0-canary.dca9ac0.0" + "@avalabs/core-wallets-sdk" "3.1.0-alpha.13" + "@avalabs/glacier-sdk" "3.1.0-alpha.13" "@metamask/rpc-errors" "6.3.0" bitcoinjs-lib "5.2.0" zod "3.23.8" From 9d7c17810c813bbfe55d69fc6893c4eecb1c769d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Leszczyk?= Date: Thu, 21 Nov 2024 09:44:56 +0100 Subject: [PATCH 13/16] chore: update sdks and vmms --- package.json | 32 +-- .../ActivityCard/PrimaryNetworkMethodIcon.tsx | 10 +- yarn.lock | 204 +++++++++--------- 3 files changed, 123 insertions(+), 123 deletions(-) diff --git a/package.json b/package.json index 0c6e39a4f..4f916ef5f 100644 --- a/package.json +++ b/package.json @@ -23,25 +23,25 @@ "sentry": "node sentryscript.js" }, "dependencies": { - "@avalabs/avalanche-module": "0.11.10", - "@avalabs/avalanchejs": "4.1.0-alpha.21", - "@avalabs/bitcoin-module": "0.11.10", + "@avalabs/avalanche-module": "0.0.0-chore-update-skds-20241121081024", + "@avalabs/avalanchejs": "4.1.0-alpha.24", + "@avalabs/bitcoin-module": "0.0.0-chore-update-skds-20241121081024", "@avalabs/bridge-unified": "0.0.0-feat-ictt-configs-20241009072139", - "@avalabs/core-bridge-sdk": "3.1.0-alpha.13", - "@avalabs/core-chains-sdk": "3.1.0-alpha.13", - "@avalabs/core-coingecko-sdk": "3.1.0-alpha.13", - "@avalabs/core-covalent-sdk": "3.1.0-alpha.13", - "@avalabs/core-etherscan-sdk": "3.1.0-alpha.13", + "@avalabs/core-bridge-sdk": "3.1.0-alpha.17", + "@avalabs/core-chains-sdk": "3.1.0-alpha.17", + "@avalabs/core-coingecko-sdk": "3.1.0-alpha.17", + "@avalabs/core-covalent-sdk": "3.1.0-alpha.17", + "@avalabs/core-etherscan-sdk": "3.1.0-alpha.17", "@avalabs/core-k2-components": "4.18.0-alpha.47", - "@avalabs/core-snowtrace-sdk": "3.1.0-alpha.13", - "@avalabs/core-token-prices-sdk": "3.1.0-alpha.13", - "@avalabs/core-utils-sdk": "3.1.0-alpha.13", - "@avalabs/core-wallets-sdk": "3.1.0-alpha.13", - "@avalabs/evm-module": "0.11.10", - "@avalabs/glacier-sdk": "3.1.0-alpha.13", + "@avalabs/core-snowtrace-sdk": "3.1.0-alpha.17", + "@avalabs/core-token-prices-sdk": "3.1.0-alpha.17", + "@avalabs/core-utils-sdk": "3.1.0-alpha.17", + "@avalabs/core-wallets-sdk": "3.1.0-alpha.17", + "@avalabs/evm-module": "0.0.0-chore-update-skds-20241121081024", + "@avalabs/glacier-sdk": "3.1.0-alpha.17", "@avalabs/hw-app-avalanche": "0.14.1", - "@avalabs/types": "3.1.0-alpha.13", - "@avalabs/vm-module-types": "0.11.10", + "@avalabs/types": "3.1.0-alpha.17", + "@avalabs/vm-module-types": "0.0.0-chore-update-skds-20241121081024", "@blockaid/client": "0.10.0", "@coinbase/cbpay-js": "1.6.0", "@cubist-labs/cubesigner-sdk": "0.3.28", diff --git a/src/pages/Wallet/components/History/components/ActivityCard/PrimaryNetworkMethodIcon.tsx b/src/pages/Wallet/components/History/components/ActivityCard/PrimaryNetworkMethodIcon.tsx index f8036dd40..f7d8be2dd 100644 --- a/src/pages/Wallet/components/History/components/ActivityCard/PrimaryNetworkMethodIcon.tsx +++ b/src/pages/Wallet/components/History/components/ActivityCard/PrimaryNetworkMethodIcon.tsx @@ -59,11 +59,11 @@ const METHOD_NAME_TO_ICON: Record< RemoveSubnetValidatorTx: MinusCircleIcon, RewardValidatorTx: AirdropIcon, AdvanceTimeTx: ClockIcon, - [PChainTransactionType.CONVERT_SUBNET_TX]: RefreshIcon, - [PChainTransactionType.REGISTER_SUBNET_VALIDATOR_TX]: ValidatorIcon, - [PChainTransactionType.SET_SUBNET_VALIDATOR_WEIGHT_TX]: BuildIcon, - [PChainTransactionType.DISABLE_SUBNET_VALIDATOR_TX]: DownloadIcon, - [PChainTransactionType.INCREASE_BALANCE_TX]: ChevronDoubleUpIcon, + [PChainTransactionType.CONVERT_SUBNET_TO_L1TX]: RefreshIcon, + [PChainTransactionType.REGISTER_L1VALIDATOR_TX]: ValidatorIcon, + [PChainTransactionType.SET_L1VALIDATOR_WEIGHT_TX]: BuildIcon, + [PChainTransactionType.DISABLE_L1VALIDATOR_TX]: DownloadIcon, + [PChainTransactionType.INCREASE_L1VALIDATOR_BALANCE_TX]: ChevronDoubleUpIcon, UNKNOWN: HelpCircleIcon, }; diff --git a/yarn.lock b/yarn.lock index f762b31a6..e04a8efda 100644 --- a/yarn.lock +++ b/yarn.lock @@ -29,29 +29,29 @@ resolved "https://registry.yarnpkg.com/@apocentre/alias-sampling/-/alias-sampling-0.5.3.tgz#897ff181b48ad7b2bcb4ecf29400214888244f08" integrity sha512-7UDWIIF9hIeJqfKXkNIzkVandlwLf1FWTSdrb9iXvOP8oF544JRXQjCbiTmCv2c9n44n/FIWtehhBfNuAx2CZA== -"@avalabs/avalanche-module@0.11.10": - version "0.11.10" - resolved "https://registry.yarnpkg.com/@avalabs/avalanche-module/-/avalanche-module-0.11.10.tgz#e3d34ff2bb03fadbc0a5f6620dd73a132a158103" - integrity sha512-EJnOfKlOgnDDRRuNrKr82b3+Q3/qEjR42K7AJ831AxzZBYOeiaVa/PUAqvS8xD69vIJQS/WL7igaqzIqcsFVQw== - dependencies: - "@avalabs/avalanchejs" "4.1.0-alpha.21" - "@avalabs/core-chains-sdk" "3.1.0-alpha.13" - "@avalabs/core-coingecko-sdk" "3.1.0-alpha.13" - "@avalabs/core-etherscan-sdk" "3.1.0-alpha.13" - "@avalabs/core-utils-sdk" "3.1.0-alpha.13" - "@avalabs/core-wallets-sdk" "3.1.0-alpha.13" - "@avalabs/glacier-sdk" "3.1.0-alpha.13" - "@avalabs/types" "3.1.0-alpha.13" - "@avalabs/vm-module-types" "0.11.10" +"@avalabs/avalanche-module@0.0.0-chore-update-skds-20241121081024": + version "0.0.0-chore-update-skds-20241121081024" + resolved "https://registry.yarnpkg.com/@avalabs/avalanche-module/-/avalanche-module-0.0.0-chore-update-skds-20241121081024.tgz#8db687d833aabba6427ec2aac872833c21637241" + integrity sha512-5+nfeCXc++gM9l6RtLhQUaIosXW0mgRvKpGO7tDPWIL6/vsytlmDLLQxNlPdU3fBZjvqNAWCUq3NRGvvkNIwag== + dependencies: + "@avalabs/avalanchejs" "4.1.0-alpha.24" + "@avalabs/core-chains-sdk" "3.1.0-alpha.17" + "@avalabs/core-coingecko-sdk" "3.1.0-alpha.17" + "@avalabs/core-etherscan-sdk" "3.1.0-alpha.17" + "@avalabs/core-utils-sdk" "3.1.0-alpha.17" + "@avalabs/core-wallets-sdk" "3.1.0-alpha.17" + "@avalabs/glacier-sdk" "3.1.0-alpha.17" + "@avalabs/types" "3.1.0-alpha.17" + "@avalabs/vm-module-types" "0.0.0-chore-update-skds-20241121081024" "@metamask/rpc-errors" "6.3.0" big.js "6.2.1" bn.js "5.2.1" zod "3.23.8" -"@avalabs/avalanchejs@4.1.0-alpha.21": - version "4.1.0-alpha.21" - resolved "https://registry.yarnpkg.com/@avalabs/avalanchejs/-/avalanchejs-4.1.0-alpha.21.tgz#79ba75fba0e5e96c069d8d9695c8c4ac97beced6" - integrity sha512-RHczoHf1j4+AImOykZn18kP5MQQA1+6RXNfzWsjt2482LauoaaHGvpM7GpEFd325Sd+N8zgVH6AqxYadAu8Sow== +"@avalabs/avalanchejs@4.1.0-alpha.24": + version "4.1.0-alpha.24" + resolved "https://registry.yarnpkg.com/@avalabs/avalanchejs/-/avalanchejs-4.1.0-alpha.24.tgz#d68c07ed2e9659a303f292d38fe052a57a95b6c6" + integrity sha512-hmnzk6G0f5PAUQg+x6zgH/VL7ei+vTSST6nn9ozJXeCQWc9SPYC+hPijr1+M9hFByCFYWiscWLt78RpnFbx4Ew== dependencies: "@noble/curves" "1.3.0" "@noble/hashes" "1.3.3" @@ -59,15 +59,15 @@ "@scure/base" "1.1.5" micro-eth-signer "0.7.2" -"@avalabs/bitcoin-module@0.11.10": - version "0.11.10" - resolved "https://registry.yarnpkg.com/@avalabs/bitcoin-module/-/bitcoin-module-0.11.10.tgz#f16e44aa5dd6813f710d4adae8f9eb2d2a318787" - integrity sha512-sjRwUDIfo8d2ycSp/Bi72PSeWVN5wZQTdygAEm3KBr/kpKCopQIjBhOMHw0v1NYp0ImFAA/4xQkUb2HsxYGwpg== +"@avalabs/bitcoin-module@0.0.0-chore-update-skds-20241121081024": + version "0.0.0-chore-update-skds-20241121081024" + resolved "https://registry.yarnpkg.com/@avalabs/bitcoin-module/-/bitcoin-module-0.0.0-chore-update-skds-20241121081024.tgz#7d71dbb246e215b2cb1bbb5d5de1b55c5c4822da" + integrity sha512-KSWcQYjxdxuZkrpN8Fybpmxnuyf/g4SSNlmWTC8UbX6AYRQC90tkptPTP8ADBDyIoYwiCDQesEU05mcORneQ2g== dependencies: - "@avalabs/core-coingecko-sdk" "3.1.0-alpha.13" - "@avalabs/core-utils-sdk" "3.1.0-alpha.13" - "@avalabs/core-wallets-sdk" "3.1.0-alpha.13" - "@avalabs/vm-module-types" "0.11.10" + "@avalabs/core-coingecko-sdk" "3.1.0-alpha.17" + "@avalabs/core-utils-sdk" "3.1.0-alpha.17" + "@avalabs/core-wallets-sdk" "3.1.0-alpha.17" + "@avalabs/vm-module-types" "0.0.0-chore-update-skds-20241121081024" "@metamask/rpc-errors" "6.3.0" big.js "6.2.1" bitcoinjs-lib "5.2.0" @@ -86,42 +86,42 @@ viem "2.11.1" zod "3.23.8" -"@avalabs/core-bridge-sdk@3.1.0-alpha.13": - version "3.1.0-alpha.13" - resolved "https://registry.yarnpkg.com/@avalabs/core-bridge-sdk/-/core-bridge-sdk-3.1.0-alpha.13.tgz#04f0f7869581a5959103d2ee29a094681ca5cbd8" - integrity sha512-Rb8vbUw22alst0w9oJ/zbmxS9eryjFf9WzLrdsevoG/C9CW9nl2b49kvNoSA7GRrogaa0mTuQe32RwDyAJWVxA== +"@avalabs/core-bridge-sdk@3.1.0-alpha.17": + version "3.1.0-alpha.17" + resolved "https://registry.yarnpkg.com/@avalabs/core-bridge-sdk/-/core-bridge-sdk-3.1.0-alpha.17.tgz#072e9306053cc064ee8f5f5deca8478514df87ca" + integrity sha512-DUTy0NyyDv4FkOg2XImkp3LmL5Z/O2I7rockLySpSgMR1QWTsHnXKfAikKF5n6fsg67+oHdQbWIPgHh/qjTMpg== dependencies: - "@avalabs/core-coingecko-sdk" "3.1.0-alpha.13" - "@avalabs/core-utils-sdk" "3.1.0-alpha.13" - "@avalabs/core-wallets-sdk" "3.1.0-alpha.13" + "@avalabs/core-coingecko-sdk" "3.1.0-alpha.17" + "@avalabs/core-utils-sdk" "3.1.0-alpha.17" + "@avalabs/core-wallets-sdk" "3.1.0-alpha.17" -"@avalabs/core-chains-sdk@3.1.0-alpha.13": - version "3.1.0-alpha.13" - resolved "https://registry.yarnpkg.com/@avalabs/core-chains-sdk/-/core-chains-sdk-3.1.0-alpha.13.tgz#fff4ec37e20252f662b8d643bdc7a58cebd77130" - integrity sha512-BJsG4q0PV9vtrfKE8G50VSaDkhUYS1RvkqNk/VH5RKiSmpLSF/XVl6b/wO5sZEPzARTesEKoO2LMuZnwGwj4hQ== +"@avalabs/core-chains-sdk@3.1.0-alpha.17": + version "3.1.0-alpha.17" + resolved "https://registry.yarnpkg.com/@avalabs/core-chains-sdk/-/core-chains-sdk-3.1.0-alpha.17.tgz#5007f75365517b3d1953e8d1f9508b30c172ef43" + integrity sha512-FOZHW7cFRrvpI/fPEB3JuMNC//7+Ewo17IzRzklaGHxya+CcgQeZB/xgVkcsIPI02nrCQNca2sjXwJLIC/X/Zw== dependencies: - "@avalabs/core-utils-sdk" "3.1.0-alpha.13" + "@avalabs/core-utils-sdk" "3.1.0-alpha.17" -"@avalabs/core-coingecko-sdk@3.1.0-alpha.13": - version "3.1.0-alpha.13" - resolved "https://registry.yarnpkg.com/@avalabs/core-coingecko-sdk/-/core-coingecko-sdk-3.1.0-alpha.13.tgz#080fd79ff9a9fc28ea0eec863481b1dbd40fd2e9" - integrity sha512-m25kY+NeqRYwJL6YbRYFbiNaoUfl33ggXI6i+rGU3QlCnZ0A7oCSa0vT/PUZr5caqJccDuYHICDysZcYAtjpMg== +"@avalabs/core-coingecko-sdk@3.1.0-alpha.17": + version "3.1.0-alpha.17" + resolved "https://registry.yarnpkg.com/@avalabs/core-coingecko-sdk/-/core-coingecko-sdk-3.1.0-alpha.17.tgz#6b135c81ae325d6530ed6706cd1c33ae70b18e24" + integrity sha512-1Mtd6QZutIPSS90BcnXGIHs1MQvO+Dq8dWt8nMYvjLTjBe9Pq8+ysjijfAU6moAKNeibCMVY1jxVPeY/vU5Fgg== dependencies: - "@avalabs/core-utils-sdk" "3.1.0-alpha.13" + "@avalabs/core-utils-sdk" "3.1.0-alpha.17" -"@avalabs/core-covalent-sdk@3.1.0-alpha.13": - version "3.1.0-alpha.13" - resolved "https://registry.yarnpkg.com/@avalabs/core-covalent-sdk/-/core-covalent-sdk-3.1.0-alpha.13.tgz#a6bf5a8721f1aa141cbf6a71cdb850041348cd98" - integrity sha512-t94q2nlUMOTGlMj23ncu+3hlrRE1o/A9ZtvQbwkOYrwwTf/Adpn+nmjON9KKUKdNkwA9esp5Xd8vIXTwC+TEEw== +"@avalabs/core-covalent-sdk@3.1.0-alpha.17": + version "3.1.0-alpha.17" + resolved "https://registry.yarnpkg.com/@avalabs/core-covalent-sdk/-/core-covalent-sdk-3.1.0-alpha.17.tgz#7ae3e245fc33149d427cf3ab7c5a77a4d58d9cd4" + integrity sha512-4bYIi/yZ6Qcg3uqv/EU5dlv4qTmTAcVefeJsoYMeEtPUVlsfDK5U/gW6+GFfEf7aPkdX6n3psxA3/YCJklQkMw== dependencies: - "@avalabs/core-utils-sdk" "3.1.0-alpha.13" + "@avalabs/core-utils-sdk" "3.1.0-alpha.17" -"@avalabs/core-etherscan-sdk@3.1.0-alpha.13": - version "3.1.0-alpha.13" - resolved "https://registry.yarnpkg.com/@avalabs/core-etherscan-sdk/-/core-etherscan-sdk-3.1.0-alpha.13.tgz#b6b963b6dd81d659bc65d16a39ab38cc989dda77" - integrity sha512-5pZBsjS0aK5AIQjLliuQgcoFftUUaJ2QGMEqlHwvw26R/imXlY5a8JGrWlJ/ZkfIY8RWoqhf1LuKvRG1+Xi7DQ== +"@avalabs/core-etherscan-sdk@3.1.0-alpha.17": + version "3.1.0-alpha.17" + resolved "https://registry.yarnpkg.com/@avalabs/core-etherscan-sdk/-/core-etherscan-sdk-3.1.0-alpha.17.tgz#600c6b94f312e5fd927fb34b9cd4c5be0ddf611c" + integrity sha512-lhWG16AzV4kZg/htEy/ETudf+pTYGbk0aK92Fv8CSqRsasEfsXTXcwOfzf9mJuBI3SYvv64C8Lf0MtOWrUV1Ug== dependencies: - "@avalabs/core-utils-sdk" "3.1.0-alpha.13" + "@avalabs/core-utils-sdk" "3.1.0-alpha.17" "@avalabs/core-k2-components@4.18.0-alpha.47": version "4.18.0-alpha.47" @@ -146,38 +146,38 @@ react-hotkeys-hook "4.4.3" uuid "9.0.1" -"@avalabs/core-snowtrace-sdk@3.1.0-alpha.13": - version "3.1.0-alpha.13" - resolved "https://registry.yarnpkg.com/@avalabs/core-snowtrace-sdk/-/core-snowtrace-sdk-3.1.0-alpha.13.tgz#4093728087903cec0dff461e37d2d261a361d3dc" - integrity sha512-gDtuUHoXAfUharWfd5ETGvjWl77ass+VwgcadxmCAeAN+WMzucP4cuxjFgYrHrzXqbPbXt2iO22F+q5hgGjoCw== +"@avalabs/core-snowtrace-sdk@3.1.0-alpha.17": + version "3.1.0-alpha.17" + resolved "https://registry.yarnpkg.com/@avalabs/core-snowtrace-sdk/-/core-snowtrace-sdk-3.1.0-alpha.17.tgz#fc8e946c8962e47bbdaf786619e4a08c3032845c" + integrity sha512-wYtCFdV4aADuhTZppzpjur0f6oMLHQlq4OCgrIwqqLKmXaD/12v595tvxj98mYvvlwaYa6NHS+L+CZpeS+PzDw== dependencies: - "@avalabs/core-utils-sdk" "3.1.0-alpha.13" + "@avalabs/core-utils-sdk" "3.1.0-alpha.17" -"@avalabs/core-token-prices-sdk@3.1.0-alpha.13": - version "3.1.0-alpha.13" - resolved "https://registry.yarnpkg.com/@avalabs/core-token-prices-sdk/-/core-token-prices-sdk-3.1.0-alpha.13.tgz#0f3b531485a564e41737606aa892835b0ab50bce" - integrity sha512-F5+6mFLzynZL07qobL+om7nkKu+b6mG4CmLyfhYAJLG071m5l6EHUigK8pis256v9D0HIFqrLMYZDAA6jwxYSw== +"@avalabs/core-token-prices-sdk@3.1.0-alpha.17": + version "3.1.0-alpha.17" + resolved "https://registry.yarnpkg.com/@avalabs/core-token-prices-sdk/-/core-token-prices-sdk-3.1.0-alpha.17.tgz#18268ffa94656022961aba74cf2591005d7ea7cc" + integrity sha512-tayJQIeG/mHUnQEDCmwKsThRAuAlvPsAdPN/oxQm+UteUykHOxoXUMQQIpPZCC9u5FA/wr6dtLZ0WOruASwXxQ== dependencies: - "@avalabs/core-coingecko-sdk" "3.1.0-alpha.13" - "@avalabs/core-utils-sdk" "3.1.0-alpha.13" + "@avalabs/core-coingecko-sdk" "3.1.0-alpha.17" + "@avalabs/core-utils-sdk" "3.1.0-alpha.17" -"@avalabs/core-utils-sdk@3.1.0-alpha.13": - version "3.1.0-alpha.13" - resolved "https://registry.yarnpkg.com/@avalabs/core-utils-sdk/-/core-utils-sdk-3.1.0-alpha.13.tgz#ae6a785478c8dfd0907bf61e7f1758cce386598c" - integrity sha512-uo0JnLSnZYUswRlLfcrJ7KmO3/UOIHMKKQgU0KdQQ7j7oUBFOTyq7PBDalQ3T7tBIKC1qOAdmH19QyUGdf2/+w== +"@avalabs/core-utils-sdk@3.1.0-alpha.17": + version "3.1.0-alpha.17" + resolved "https://registry.yarnpkg.com/@avalabs/core-utils-sdk/-/core-utils-sdk-3.1.0-alpha.17.tgz#6c691707590b0387b8a8303a596b56b707ab3739" + integrity sha512-ArqPDw9IsKj6G78JSwiVKl7eqaggV+PTGBMJb7IAZki6rRaI2YSwFpczbq6VczvbesWm96e2Mfh0ALjVdiUE6Q== dependencies: - "@avalabs/avalanchejs" "4.1.0-alpha.21" + "@avalabs/avalanchejs" "4.1.0-alpha.24" "@hpke/core" "1.2.5" is-ipfs "6.0.2" -"@avalabs/core-wallets-sdk@3.1.0-alpha.13": - version "3.1.0-alpha.13" - resolved "https://registry.yarnpkg.com/@avalabs/core-wallets-sdk/-/core-wallets-sdk-3.1.0-alpha.13.tgz#b4ff83a019c94c83e69e0c83604b2ba9c840ea63" - integrity sha512-/aPsFw46OXVl1anzqCm1+qKa/Jna+f/aAMsttb11AmFaHOAK3I1s35XQKmO9ZJTSLePA+24Im5dTR/QwrURLuw== +"@avalabs/core-wallets-sdk@3.1.0-alpha.17": + version "3.1.0-alpha.17" + resolved "https://registry.yarnpkg.com/@avalabs/core-wallets-sdk/-/core-wallets-sdk-3.1.0-alpha.17.tgz#1b2a97583dbd5c01bc4ba8d2918ac5fd12381715" + integrity sha512-PkbG0aOzN9MZGtHLagQGEEBu4KI/B/1IuGFs1RqkEXnIWO91T5HDhCqIuPt7UE3ZYl/yrvxpfgVitt6ou6IgOg== dependencies: - "@avalabs/avalanchejs" "4.1.0-alpha.21" - "@avalabs/core-chains-sdk" "3.1.0-alpha.13" - "@avalabs/glacier-sdk" "3.1.0-alpha.13" + "@avalabs/avalanchejs" "4.1.0-alpha.24" + "@avalabs/core-chains-sdk" "3.1.0-alpha.17" + "@avalabs/glacier-sdk" "3.1.0-alpha.17" "@avalabs/hw-app-avalanche" "0.14.1" "@ledgerhq/hw-app-btc" "10.2.4" "@ledgerhq/hw-app-eth" "6.36.1" @@ -194,18 +194,18 @@ ledger-bitcoin "0.2.3" xss "1.0.14" -"@avalabs/evm-module@0.11.10": - version "0.11.10" - resolved "https://registry.yarnpkg.com/@avalabs/evm-module/-/evm-module-0.11.10.tgz#d7f028bd140f765aa07870fb2cfe5439e40f7f79" - integrity sha512-SZN32O8U37M6rCh6sCefOqXkMief3qkZvapuFH9NmZPj93o2tYSznDp2kwj/L8j7L42Nsq/wtnz8qzowmPq8hA== - dependencies: - "@avalabs/core-coingecko-sdk" "3.1.0-alpha.13" - "@avalabs/core-etherscan-sdk" "3.1.0-alpha.13" - "@avalabs/core-utils-sdk" "3.1.0-alpha.13" - "@avalabs/core-wallets-sdk" "3.1.0-alpha.13" - "@avalabs/glacier-sdk" "3.1.0-alpha.13" - "@avalabs/types" "3.1.0-alpha.13" - "@avalabs/vm-module-types" "0.11.10" +"@avalabs/evm-module@0.0.0-chore-update-skds-20241121081024": + version "0.0.0-chore-update-skds-20241121081024" + resolved "https://registry.yarnpkg.com/@avalabs/evm-module/-/evm-module-0.0.0-chore-update-skds-20241121081024.tgz#872a4aaf20ae432cff6ca602b2d24bfb8cba6375" + integrity sha512-ljcf8GKVLqYpOFDJ1ycf2htAaaJ8jShMP8iMvK9z158h/kzmQR0GkO4tmDLZ/rhqqkpW2pBwFH+Wx1eWgVLpCA== + dependencies: + "@avalabs/core-coingecko-sdk" "3.1.0-alpha.17" + "@avalabs/core-etherscan-sdk" "3.1.0-alpha.17" + "@avalabs/core-utils-sdk" "3.1.0-alpha.17" + "@avalabs/core-wallets-sdk" "3.1.0-alpha.17" + "@avalabs/glacier-sdk" "3.1.0-alpha.17" + "@avalabs/types" "3.1.0-alpha.17" + "@avalabs/vm-module-types" "0.0.0-chore-update-skds-20241121081024" "@blockaid/client" "0.11.0" "@metamask/rpc-errors" "6.3.0" "@openzeppelin/contracts" "4.9.6" @@ -214,10 +214,10 @@ xss "1.0.13" zod "3.23.8" -"@avalabs/glacier-sdk@3.1.0-alpha.13": - version "3.1.0-alpha.13" - resolved "https://registry.yarnpkg.com/@avalabs/glacier-sdk/-/glacier-sdk-3.1.0-alpha.13.tgz#cd11d2dfa6492d53f5f6e647c74d463c597cee76" - integrity sha512-B1bRC6J/89dTdVuXyEJxDbOdoHV3THPkearlVGcE0Rc0t/ZC+fJxuFFtLWyf9Td6pZ9C7xa3OLxSHRElrKIvLA== +"@avalabs/glacier-sdk@3.1.0-alpha.17": + version "3.1.0-alpha.17" + resolved "https://registry.yarnpkg.com/@avalabs/glacier-sdk/-/glacier-sdk-3.1.0-alpha.17.tgz#447b75a6268d91b3f087117559de5162aea7dc4d" + integrity sha512-MVne/Hl+akMwVP3Yrz1WgO2tYeW7lIepEEppLsVE8PO9DcPEAzlKlq0GOONuyZb4K/96jwGj2jzL3F2e5g7Ifw== "@avalabs/hw-app-avalanche@0.14.1": version "0.14.1" @@ -230,18 +230,18 @@ ledger-bitcoin "^0.2.1" sha3 "2.1.4" -"@avalabs/types@3.1.0-alpha.13": - version "3.1.0-alpha.13" - resolved "https://registry.yarnpkg.com/@avalabs/types/-/types-3.1.0-alpha.13.tgz#e018c9d9feae1b211e24ec33fe8b53135f1c938f" - integrity sha512-YX2SAFYl/7VeDjVhNOUqjDZ+R/gkTBZVll8+dgBE53A062j81QPCq0XlsLwvlYpjdPNmCjoSgi1mRe6cyrS0Lw== +"@avalabs/types@3.1.0-alpha.17": + version "3.1.0-alpha.17" + resolved "https://registry.yarnpkg.com/@avalabs/types/-/types-3.1.0-alpha.17.tgz#4f28d2918bb2836db3058e7f1b15e00af82d1c29" + integrity sha512-xBJw1eFRP42i39xOF06vyWOZ3sNNlMm4fkHTaaoA1AsoTa/w1mRrVru2nPaaaaXU77Hbd5QPRaxBEMFE8Mt4ng== -"@avalabs/vm-module-types@0.11.10": - version "0.11.10" - resolved "https://registry.yarnpkg.com/@avalabs/vm-module-types/-/vm-module-types-0.11.10.tgz#6aa783c65bc1b4da83a56b4c823a7d52f55a5315" - integrity sha512-ppEWkV91f8XFLYyVO/TB9Xlv6WWCg0QlgolXHusYY3yqXmXoaTBjw+i4GzPZ2i3lL+/mFIwqCKqLqtVIuCzrwg== +"@avalabs/vm-module-types@0.0.0-chore-update-skds-20241121081024": + version "0.0.0-chore-update-skds-20241121081024" + resolved "https://registry.yarnpkg.com/@avalabs/vm-module-types/-/vm-module-types-0.0.0-chore-update-skds-20241121081024.tgz#82133c289cadae8621d64ad59a6d4b151c3fa329" + integrity sha512-B0BWjwOt2HAeSwuMvGD+gWvk5HPiDYqasCnivClATDUz/F5QBupftqUg+xJd4s2hvk12v6L4IAh89Nwcqb08TA== dependencies: - "@avalabs/core-wallets-sdk" "3.1.0-alpha.13" - "@avalabs/glacier-sdk" "3.1.0-alpha.13" + "@avalabs/core-wallets-sdk" "3.1.0-alpha.17" + "@avalabs/glacier-sdk" "3.1.0-alpha.17" "@metamask/rpc-errors" "6.3.0" bitcoinjs-lib "5.2.0" zod "3.23.8" From 3cf03480c776abe29f73fdbe79eb22144e9cf3cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Leszczyk?= Date: Thu, 21 Nov 2024 20:04:03 +0100 Subject: [PATCH 14/16] chore: update ajs, sdks and vm modules --- package.json | 32 ++++---- yarn.lock | 204 +++++++++++++++++++++++++-------------------------- 2 files changed, 118 insertions(+), 118 deletions(-) diff --git a/package.json b/package.json index 4f916ef5f..af6d383bf 100644 --- a/package.json +++ b/package.json @@ -23,25 +23,25 @@ "sentry": "node sentryscript.js" }, "dependencies": { - "@avalabs/avalanche-module": "0.0.0-chore-update-skds-20241121081024", - "@avalabs/avalanchejs": "4.1.0-alpha.24", - "@avalabs/bitcoin-module": "0.0.0-chore-update-skds-20241121081024", + "@avalabs/avalanche-module": "0.11.12", + "@avalabs/avalanchejs": "4.1.0-alpha.25", + "@avalabs/bitcoin-module": "0.11.12", "@avalabs/bridge-unified": "0.0.0-feat-ictt-configs-20241009072139", - "@avalabs/core-bridge-sdk": "3.1.0-alpha.17", - "@avalabs/core-chains-sdk": "3.1.0-alpha.17", - "@avalabs/core-coingecko-sdk": "3.1.0-alpha.17", - "@avalabs/core-covalent-sdk": "3.1.0-alpha.17", - "@avalabs/core-etherscan-sdk": "3.1.0-alpha.17", + "@avalabs/core-bridge-sdk": "3.1.0-alpha.19", + "@avalabs/core-chains-sdk": "3.1.0-alpha.19", + "@avalabs/core-coingecko-sdk": "3.1.0-alpha.19", + "@avalabs/core-covalent-sdk": "3.1.0-alpha.19", + "@avalabs/core-etherscan-sdk": "3.1.0-alpha.19", "@avalabs/core-k2-components": "4.18.0-alpha.47", - "@avalabs/core-snowtrace-sdk": "3.1.0-alpha.17", - "@avalabs/core-token-prices-sdk": "3.1.0-alpha.17", - "@avalabs/core-utils-sdk": "3.1.0-alpha.17", - "@avalabs/core-wallets-sdk": "3.1.0-alpha.17", - "@avalabs/evm-module": "0.0.0-chore-update-skds-20241121081024", - "@avalabs/glacier-sdk": "3.1.0-alpha.17", + "@avalabs/core-snowtrace-sdk": "3.1.0-alpha.19", + "@avalabs/core-token-prices-sdk": "3.1.0-alpha.19", + "@avalabs/core-utils-sdk": "3.1.0-alpha.19", + "@avalabs/core-wallets-sdk": "3.1.0-alpha.19", + "@avalabs/evm-module": "0.11.12", + "@avalabs/glacier-sdk": "3.1.0-alpha.19", "@avalabs/hw-app-avalanche": "0.14.1", - "@avalabs/types": "3.1.0-alpha.17", - "@avalabs/vm-module-types": "0.0.0-chore-update-skds-20241121081024", + "@avalabs/types": "3.1.0-alpha.19", + "@avalabs/vm-module-types": "0.11.12", "@blockaid/client": "0.10.0", "@coinbase/cbpay-js": "1.6.0", "@cubist-labs/cubesigner-sdk": "0.3.28", diff --git a/yarn.lock b/yarn.lock index e04a8efda..2357ae725 100644 --- a/yarn.lock +++ b/yarn.lock @@ -29,29 +29,29 @@ resolved "https://registry.yarnpkg.com/@apocentre/alias-sampling/-/alias-sampling-0.5.3.tgz#897ff181b48ad7b2bcb4ecf29400214888244f08" integrity sha512-7UDWIIF9hIeJqfKXkNIzkVandlwLf1FWTSdrb9iXvOP8oF544JRXQjCbiTmCv2c9n44n/FIWtehhBfNuAx2CZA== -"@avalabs/avalanche-module@0.0.0-chore-update-skds-20241121081024": - version "0.0.0-chore-update-skds-20241121081024" - resolved "https://registry.yarnpkg.com/@avalabs/avalanche-module/-/avalanche-module-0.0.0-chore-update-skds-20241121081024.tgz#8db687d833aabba6427ec2aac872833c21637241" - integrity sha512-5+nfeCXc++gM9l6RtLhQUaIosXW0mgRvKpGO7tDPWIL6/vsytlmDLLQxNlPdU3fBZjvqNAWCUq3NRGvvkNIwag== - dependencies: - "@avalabs/avalanchejs" "4.1.0-alpha.24" - "@avalabs/core-chains-sdk" "3.1.0-alpha.17" - "@avalabs/core-coingecko-sdk" "3.1.0-alpha.17" - "@avalabs/core-etherscan-sdk" "3.1.0-alpha.17" - "@avalabs/core-utils-sdk" "3.1.0-alpha.17" - "@avalabs/core-wallets-sdk" "3.1.0-alpha.17" - "@avalabs/glacier-sdk" "3.1.0-alpha.17" - "@avalabs/types" "3.1.0-alpha.17" - "@avalabs/vm-module-types" "0.0.0-chore-update-skds-20241121081024" +"@avalabs/avalanche-module@0.11.12": + version "0.11.12" + resolved "https://registry.yarnpkg.com/@avalabs/avalanche-module/-/avalanche-module-0.11.12.tgz#ddd4ebbd0341357e70647afdf9d88632839698f5" + integrity sha512-1RLoD1exbm0mLubvJQmrr0aLqjXuysnW1mOugUQLjPm2WugQn93X8gQHz2SV5RapLHnFFqoTmF3jp7Nt4fI61w== + dependencies: + "@avalabs/avalanchejs" "4.1.0-alpha.25" + "@avalabs/core-chains-sdk" "3.1.0-alpha.19" + "@avalabs/core-coingecko-sdk" "3.1.0-alpha.19" + "@avalabs/core-etherscan-sdk" "3.1.0-alpha.19" + "@avalabs/core-utils-sdk" "3.1.0-alpha.19" + "@avalabs/core-wallets-sdk" "3.1.0-alpha.19" + "@avalabs/glacier-sdk" "3.1.0-alpha.19" + "@avalabs/types" "3.1.0-alpha.19" + "@avalabs/vm-module-types" "0.11.12" "@metamask/rpc-errors" "6.3.0" big.js "6.2.1" bn.js "5.2.1" zod "3.23.8" -"@avalabs/avalanchejs@4.1.0-alpha.24": - version "4.1.0-alpha.24" - resolved "https://registry.yarnpkg.com/@avalabs/avalanchejs/-/avalanchejs-4.1.0-alpha.24.tgz#d68c07ed2e9659a303f292d38fe052a57a95b6c6" - integrity sha512-hmnzk6G0f5PAUQg+x6zgH/VL7ei+vTSST6nn9ozJXeCQWc9SPYC+hPijr1+M9hFByCFYWiscWLt78RpnFbx4Ew== +"@avalabs/avalanchejs@4.1.0-alpha.25": + version "4.1.0-alpha.25" + resolved "https://registry.yarnpkg.com/@avalabs/avalanchejs/-/avalanchejs-4.1.0-alpha.25.tgz#65a85dc00b5b2f15d69ed746d8892c3e1432606f" + integrity sha512-ZQb5X3KN2RyzSYcPMxMgczxyiOwBAXv73Rps7LeDrJpFZTZf2TDRyWVNeeYvL7GFT1atkvZmGbNd9l4RDLSqJA== dependencies: "@noble/curves" "1.3.0" "@noble/hashes" "1.3.3" @@ -59,15 +59,15 @@ "@scure/base" "1.1.5" micro-eth-signer "0.7.2" -"@avalabs/bitcoin-module@0.0.0-chore-update-skds-20241121081024": - version "0.0.0-chore-update-skds-20241121081024" - resolved "https://registry.yarnpkg.com/@avalabs/bitcoin-module/-/bitcoin-module-0.0.0-chore-update-skds-20241121081024.tgz#7d71dbb246e215b2cb1bbb5d5de1b55c5c4822da" - integrity sha512-KSWcQYjxdxuZkrpN8Fybpmxnuyf/g4SSNlmWTC8UbX6AYRQC90tkptPTP8ADBDyIoYwiCDQesEU05mcORneQ2g== +"@avalabs/bitcoin-module@0.11.12": + version "0.11.12" + resolved "https://registry.yarnpkg.com/@avalabs/bitcoin-module/-/bitcoin-module-0.11.12.tgz#8f6c8f83010bf89c6fb54e80bbf7fb4326f76886" + integrity sha512-JRq+4NKKKaj6Fs0wmLlUmQKYH2AtZHwF2PQu44ceqcoys2TVhWXDU94U4blK+J2aFu9A7ZMrXpm1njlEhUJnxw== dependencies: - "@avalabs/core-coingecko-sdk" "3.1.0-alpha.17" - "@avalabs/core-utils-sdk" "3.1.0-alpha.17" - "@avalabs/core-wallets-sdk" "3.1.0-alpha.17" - "@avalabs/vm-module-types" "0.0.0-chore-update-skds-20241121081024" + "@avalabs/core-coingecko-sdk" "3.1.0-alpha.19" + "@avalabs/core-utils-sdk" "3.1.0-alpha.19" + "@avalabs/core-wallets-sdk" "3.1.0-alpha.19" + "@avalabs/vm-module-types" "0.11.12" "@metamask/rpc-errors" "6.3.0" big.js "6.2.1" bitcoinjs-lib "5.2.0" @@ -86,42 +86,42 @@ viem "2.11.1" zod "3.23.8" -"@avalabs/core-bridge-sdk@3.1.0-alpha.17": - version "3.1.0-alpha.17" - resolved "https://registry.yarnpkg.com/@avalabs/core-bridge-sdk/-/core-bridge-sdk-3.1.0-alpha.17.tgz#072e9306053cc064ee8f5f5deca8478514df87ca" - integrity sha512-DUTy0NyyDv4FkOg2XImkp3LmL5Z/O2I7rockLySpSgMR1QWTsHnXKfAikKF5n6fsg67+oHdQbWIPgHh/qjTMpg== +"@avalabs/core-bridge-sdk@3.1.0-alpha.19": + version "3.1.0-alpha.19" + resolved "https://registry.yarnpkg.com/@avalabs/core-bridge-sdk/-/core-bridge-sdk-3.1.0-alpha.19.tgz#31e8f8afb75c193c8d35ab9664659416a3e48c39" + integrity sha512-olXyz71vzmRDkTOeIIHii46GaodXA3DVs/8tHidtjvyGqU7YoULIk2JbiiBtfQst1k8g2IrMIJdw3onrum+RDg== dependencies: - "@avalabs/core-coingecko-sdk" "3.1.0-alpha.17" - "@avalabs/core-utils-sdk" "3.1.0-alpha.17" - "@avalabs/core-wallets-sdk" "3.1.0-alpha.17" + "@avalabs/core-coingecko-sdk" "3.1.0-alpha.19" + "@avalabs/core-utils-sdk" "3.1.0-alpha.19" + "@avalabs/core-wallets-sdk" "3.1.0-alpha.19" -"@avalabs/core-chains-sdk@3.1.0-alpha.17": - version "3.1.0-alpha.17" - resolved "https://registry.yarnpkg.com/@avalabs/core-chains-sdk/-/core-chains-sdk-3.1.0-alpha.17.tgz#5007f75365517b3d1953e8d1f9508b30c172ef43" - integrity sha512-FOZHW7cFRrvpI/fPEB3JuMNC//7+Ewo17IzRzklaGHxya+CcgQeZB/xgVkcsIPI02nrCQNca2sjXwJLIC/X/Zw== +"@avalabs/core-chains-sdk@3.1.0-alpha.19": + version "3.1.0-alpha.19" + resolved "https://registry.yarnpkg.com/@avalabs/core-chains-sdk/-/core-chains-sdk-3.1.0-alpha.19.tgz#26cbc4dd404b55b62c929adcb519692c6260c652" + integrity sha512-Nbno+lCv8KbMGFhqBJSfFrPHCfwKZqch632NfwbbNTz3UOsueWlsqa7QOnf+gIZva4lLeMtq1gyUK2NaE+zgCA== dependencies: - "@avalabs/core-utils-sdk" "3.1.0-alpha.17" + "@avalabs/core-utils-sdk" "3.1.0-alpha.19" -"@avalabs/core-coingecko-sdk@3.1.0-alpha.17": - version "3.1.0-alpha.17" - resolved "https://registry.yarnpkg.com/@avalabs/core-coingecko-sdk/-/core-coingecko-sdk-3.1.0-alpha.17.tgz#6b135c81ae325d6530ed6706cd1c33ae70b18e24" - integrity sha512-1Mtd6QZutIPSS90BcnXGIHs1MQvO+Dq8dWt8nMYvjLTjBe9Pq8+ysjijfAU6moAKNeibCMVY1jxVPeY/vU5Fgg== +"@avalabs/core-coingecko-sdk@3.1.0-alpha.19": + version "3.1.0-alpha.19" + resolved "https://registry.yarnpkg.com/@avalabs/core-coingecko-sdk/-/core-coingecko-sdk-3.1.0-alpha.19.tgz#511f3d12cdb8c9b803b1e68abc595af75ca8f092" + integrity sha512-1BmLxIJ4dbvIf4hMLfZ7iGcR7CivJbkS09yS01uv87Pg7RmIVoAvXnFhNSkUvyBMz3SANq39u7DJj3R/edp0Jg== dependencies: - "@avalabs/core-utils-sdk" "3.1.0-alpha.17" + "@avalabs/core-utils-sdk" "3.1.0-alpha.19" -"@avalabs/core-covalent-sdk@3.1.0-alpha.17": - version "3.1.0-alpha.17" - resolved "https://registry.yarnpkg.com/@avalabs/core-covalent-sdk/-/core-covalent-sdk-3.1.0-alpha.17.tgz#7ae3e245fc33149d427cf3ab7c5a77a4d58d9cd4" - integrity sha512-4bYIi/yZ6Qcg3uqv/EU5dlv4qTmTAcVefeJsoYMeEtPUVlsfDK5U/gW6+GFfEf7aPkdX6n3psxA3/YCJklQkMw== +"@avalabs/core-covalent-sdk@3.1.0-alpha.19": + version "3.1.0-alpha.19" + resolved "https://registry.yarnpkg.com/@avalabs/core-covalent-sdk/-/core-covalent-sdk-3.1.0-alpha.19.tgz#63047650c5f31c37c4eafb7e6701342255d87465" + integrity sha512-OOSEfpovwKlJAIdiXJCTpXhfKi/3xpQNqRIVl66env3K8AGrGJlgiJ8DV8OhhQX+uSpc92aOos/IND2JzPYIEQ== dependencies: - "@avalabs/core-utils-sdk" "3.1.0-alpha.17" + "@avalabs/core-utils-sdk" "3.1.0-alpha.19" -"@avalabs/core-etherscan-sdk@3.1.0-alpha.17": - version "3.1.0-alpha.17" - resolved "https://registry.yarnpkg.com/@avalabs/core-etherscan-sdk/-/core-etherscan-sdk-3.1.0-alpha.17.tgz#600c6b94f312e5fd927fb34b9cd4c5be0ddf611c" - integrity sha512-lhWG16AzV4kZg/htEy/ETudf+pTYGbk0aK92Fv8CSqRsasEfsXTXcwOfzf9mJuBI3SYvv64C8Lf0MtOWrUV1Ug== +"@avalabs/core-etherscan-sdk@3.1.0-alpha.19": + version "3.1.0-alpha.19" + resolved "https://registry.yarnpkg.com/@avalabs/core-etherscan-sdk/-/core-etherscan-sdk-3.1.0-alpha.19.tgz#6603df78daba9f5c3c9e95d56e98323bd24b92af" + integrity sha512-g5qZzCXkIA/qgtYGbjWPFY+CTFeq1i3UR+1VmWvfwfiiJfxIPxutj32YNAaDcCvp3gp/aPb1hvXWfYMxHPmY7g== dependencies: - "@avalabs/core-utils-sdk" "3.1.0-alpha.17" + "@avalabs/core-utils-sdk" "3.1.0-alpha.19" "@avalabs/core-k2-components@4.18.0-alpha.47": version "4.18.0-alpha.47" @@ -146,38 +146,38 @@ react-hotkeys-hook "4.4.3" uuid "9.0.1" -"@avalabs/core-snowtrace-sdk@3.1.0-alpha.17": - version "3.1.0-alpha.17" - resolved "https://registry.yarnpkg.com/@avalabs/core-snowtrace-sdk/-/core-snowtrace-sdk-3.1.0-alpha.17.tgz#fc8e946c8962e47bbdaf786619e4a08c3032845c" - integrity sha512-wYtCFdV4aADuhTZppzpjur0f6oMLHQlq4OCgrIwqqLKmXaD/12v595tvxj98mYvvlwaYa6NHS+L+CZpeS+PzDw== +"@avalabs/core-snowtrace-sdk@3.1.0-alpha.19": + version "3.1.0-alpha.19" + resolved "https://registry.yarnpkg.com/@avalabs/core-snowtrace-sdk/-/core-snowtrace-sdk-3.1.0-alpha.19.tgz#8657b177223f0ac14f1d3e8f2e72f125f2c7192d" + integrity sha512-ahTbduryJKJqJcpBj2T7RGjItd719YtZZJZkLmEPDxKzm7xa60SuuowDLhZkADyJEG2VhDECacil+xrSxDbMwg== dependencies: - "@avalabs/core-utils-sdk" "3.1.0-alpha.17" + "@avalabs/core-utils-sdk" "3.1.0-alpha.19" -"@avalabs/core-token-prices-sdk@3.1.0-alpha.17": - version "3.1.0-alpha.17" - resolved "https://registry.yarnpkg.com/@avalabs/core-token-prices-sdk/-/core-token-prices-sdk-3.1.0-alpha.17.tgz#18268ffa94656022961aba74cf2591005d7ea7cc" - integrity sha512-tayJQIeG/mHUnQEDCmwKsThRAuAlvPsAdPN/oxQm+UteUykHOxoXUMQQIpPZCC9u5FA/wr6dtLZ0WOruASwXxQ== +"@avalabs/core-token-prices-sdk@3.1.0-alpha.19": + version "3.1.0-alpha.19" + resolved "https://registry.yarnpkg.com/@avalabs/core-token-prices-sdk/-/core-token-prices-sdk-3.1.0-alpha.19.tgz#06a44cee576531b697d5c85446130d6845cac06e" + integrity sha512-STz75BAZhIRxRG0QIXa/gXxRNQGbpYe16GYPgJEJCKGzFDGP3MWNqdWaXVVoh/eZE05UMxBejgyd3Zq0n4eX+w== dependencies: - "@avalabs/core-coingecko-sdk" "3.1.0-alpha.17" - "@avalabs/core-utils-sdk" "3.1.0-alpha.17" + "@avalabs/core-coingecko-sdk" "3.1.0-alpha.19" + "@avalabs/core-utils-sdk" "3.1.0-alpha.19" -"@avalabs/core-utils-sdk@3.1.0-alpha.17": - version "3.1.0-alpha.17" - resolved "https://registry.yarnpkg.com/@avalabs/core-utils-sdk/-/core-utils-sdk-3.1.0-alpha.17.tgz#6c691707590b0387b8a8303a596b56b707ab3739" - integrity sha512-ArqPDw9IsKj6G78JSwiVKl7eqaggV+PTGBMJb7IAZki6rRaI2YSwFpczbq6VczvbesWm96e2Mfh0ALjVdiUE6Q== +"@avalabs/core-utils-sdk@3.1.0-alpha.19": + version "3.1.0-alpha.19" + resolved "https://registry.yarnpkg.com/@avalabs/core-utils-sdk/-/core-utils-sdk-3.1.0-alpha.19.tgz#84a6097eeb0e980365e5cdcc4c05a719bbf00657" + integrity sha512-D8A0vkabx5xt55HkZgdyAoWwb+pCp6ef6i8X37ckvIoAZT96pRr1Y8BhhwSkFY2G/Y5OZzEQqBbLndq+GwUMzQ== dependencies: - "@avalabs/avalanchejs" "4.1.0-alpha.24" + "@avalabs/avalanchejs" "4.1.0-alpha.25" "@hpke/core" "1.2.5" is-ipfs "6.0.2" -"@avalabs/core-wallets-sdk@3.1.0-alpha.17": - version "3.1.0-alpha.17" - resolved "https://registry.yarnpkg.com/@avalabs/core-wallets-sdk/-/core-wallets-sdk-3.1.0-alpha.17.tgz#1b2a97583dbd5c01bc4ba8d2918ac5fd12381715" - integrity sha512-PkbG0aOzN9MZGtHLagQGEEBu4KI/B/1IuGFs1RqkEXnIWO91T5HDhCqIuPt7UE3ZYl/yrvxpfgVitt6ou6IgOg== +"@avalabs/core-wallets-sdk@3.1.0-alpha.19": + version "3.1.0-alpha.19" + resolved "https://registry.yarnpkg.com/@avalabs/core-wallets-sdk/-/core-wallets-sdk-3.1.0-alpha.19.tgz#7e91225eda65404368d6a2c8195d25ec4dd2167f" + integrity sha512-lnCJvmH/EVvJDr4j3NW3a4liD7ZUTftecPGovu/Mx1AhHHMJJlmT9OPbCvyVzbkpGV+xtGEeMMnM2vtUwc259A== dependencies: - "@avalabs/avalanchejs" "4.1.0-alpha.24" - "@avalabs/core-chains-sdk" "3.1.0-alpha.17" - "@avalabs/glacier-sdk" "3.1.0-alpha.17" + "@avalabs/avalanchejs" "4.1.0-alpha.25" + "@avalabs/core-chains-sdk" "3.1.0-alpha.19" + "@avalabs/glacier-sdk" "3.1.0-alpha.19" "@avalabs/hw-app-avalanche" "0.14.1" "@ledgerhq/hw-app-btc" "10.2.4" "@ledgerhq/hw-app-eth" "6.36.1" @@ -194,18 +194,18 @@ ledger-bitcoin "0.2.3" xss "1.0.14" -"@avalabs/evm-module@0.0.0-chore-update-skds-20241121081024": - version "0.0.0-chore-update-skds-20241121081024" - resolved "https://registry.yarnpkg.com/@avalabs/evm-module/-/evm-module-0.0.0-chore-update-skds-20241121081024.tgz#872a4aaf20ae432cff6ca602b2d24bfb8cba6375" - integrity sha512-ljcf8GKVLqYpOFDJ1ycf2htAaaJ8jShMP8iMvK9z158h/kzmQR0GkO4tmDLZ/rhqqkpW2pBwFH+Wx1eWgVLpCA== - dependencies: - "@avalabs/core-coingecko-sdk" "3.1.0-alpha.17" - "@avalabs/core-etherscan-sdk" "3.1.0-alpha.17" - "@avalabs/core-utils-sdk" "3.1.0-alpha.17" - "@avalabs/core-wallets-sdk" "3.1.0-alpha.17" - "@avalabs/glacier-sdk" "3.1.0-alpha.17" - "@avalabs/types" "3.1.0-alpha.17" - "@avalabs/vm-module-types" "0.0.0-chore-update-skds-20241121081024" +"@avalabs/evm-module@0.11.12": + version "0.11.12" + resolved "https://registry.yarnpkg.com/@avalabs/evm-module/-/evm-module-0.11.12.tgz#ae8fce1d9686523f06e5143d73141ed3f643e324" + integrity sha512-Dcva82dZG2pCSTg1mKR0fCt04I6HxYSvKpKmArBqheNuLey4AlJ1xhQbUtpxTZ9FnhtfKaCUWTuRtjN+0jafqQ== + dependencies: + "@avalabs/core-coingecko-sdk" "3.1.0-alpha.19" + "@avalabs/core-etherscan-sdk" "3.1.0-alpha.19" + "@avalabs/core-utils-sdk" "3.1.0-alpha.19" + "@avalabs/core-wallets-sdk" "3.1.0-alpha.19" + "@avalabs/glacier-sdk" "3.1.0-alpha.19" + "@avalabs/types" "3.1.0-alpha.19" + "@avalabs/vm-module-types" "0.11.12" "@blockaid/client" "0.11.0" "@metamask/rpc-errors" "6.3.0" "@openzeppelin/contracts" "4.9.6" @@ -214,10 +214,10 @@ xss "1.0.13" zod "3.23.8" -"@avalabs/glacier-sdk@3.1.0-alpha.17": - version "3.1.0-alpha.17" - resolved "https://registry.yarnpkg.com/@avalabs/glacier-sdk/-/glacier-sdk-3.1.0-alpha.17.tgz#447b75a6268d91b3f087117559de5162aea7dc4d" - integrity sha512-MVne/Hl+akMwVP3Yrz1WgO2tYeW7lIepEEppLsVE8PO9DcPEAzlKlq0GOONuyZb4K/96jwGj2jzL3F2e5g7Ifw== +"@avalabs/glacier-sdk@3.1.0-alpha.19": + version "3.1.0-alpha.19" + resolved "https://registry.yarnpkg.com/@avalabs/glacier-sdk/-/glacier-sdk-3.1.0-alpha.19.tgz#ef553e631a2ecbecb557ba7a074ae8f2fc601de9" + integrity sha512-7wF67yJJgXrFTA/XD0xPDqLDkaAj5T1M7P5tXaR7WlTQ4QTq5vZltnNSxI9Jd8cpXnO9+LDu1vwcGHsZCbi9XQ== "@avalabs/hw-app-avalanche@0.14.1": version "0.14.1" @@ -230,18 +230,18 @@ ledger-bitcoin "^0.2.1" sha3 "2.1.4" -"@avalabs/types@3.1.0-alpha.17": - version "3.1.0-alpha.17" - resolved "https://registry.yarnpkg.com/@avalabs/types/-/types-3.1.0-alpha.17.tgz#4f28d2918bb2836db3058e7f1b15e00af82d1c29" - integrity sha512-xBJw1eFRP42i39xOF06vyWOZ3sNNlMm4fkHTaaoA1AsoTa/w1mRrVru2nPaaaaXU77Hbd5QPRaxBEMFE8Mt4ng== +"@avalabs/types@3.1.0-alpha.19": + version "3.1.0-alpha.19" + resolved "https://registry.yarnpkg.com/@avalabs/types/-/types-3.1.0-alpha.19.tgz#4ae21f3aaead9c97a0b10b4782e6a96646113660" + integrity sha512-zieVqgpihllEuyi0NDiPkKT0b69FV/sC0rUQ1oPNe6F1L9fw9bRv6o7L6hVD+w5hVcth1A8P1PtMJOwCfbvXBQ== -"@avalabs/vm-module-types@0.0.0-chore-update-skds-20241121081024": - version "0.0.0-chore-update-skds-20241121081024" - resolved "https://registry.yarnpkg.com/@avalabs/vm-module-types/-/vm-module-types-0.0.0-chore-update-skds-20241121081024.tgz#82133c289cadae8621d64ad59a6d4b151c3fa329" - integrity sha512-B0BWjwOt2HAeSwuMvGD+gWvk5HPiDYqasCnivClATDUz/F5QBupftqUg+xJd4s2hvk12v6L4IAh89Nwcqb08TA== +"@avalabs/vm-module-types@0.11.12": + version "0.11.12" + resolved "https://registry.yarnpkg.com/@avalabs/vm-module-types/-/vm-module-types-0.11.12.tgz#ac6b1224f6cf734263ad5aea4987d7419e88c50e" + integrity sha512-0kfqjXhWqBHcq/nF33qb7j/bNdEWPaijaBn26I+wGAhHO1St5kk2YAy5FY+GdMzlg+B27iOlL7hAoWRoDkHl7Q== dependencies: - "@avalabs/core-wallets-sdk" "3.1.0-alpha.17" - "@avalabs/glacier-sdk" "3.1.0-alpha.17" + "@avalabs/core-wallets-sdk" "3.1.0-alpha.19" + "@avalabs/glacier-sdk" "3.1.0-alpha.19" "@metamask/rpc-errors" "6.3.0" bitcoinjs-lib "5.2.0" zod "3.23.8" From 2d616fe311490b8e68bd7cfdeec0f9c60c96c646 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Leszczyk?= Date: Fri, 8 Nov 2024 19:25:15 +0100 Subject: [PATCH 15/16] feat: new etna txs --- src/pages/ApproveAction/AvalancheSignTx.tsx | 17 +++ .../components/ApproveConvertSubnetToL1.tsx | 108 ++++++++++++++++++ .../components/ApproveDisableL1Validator.tsx | 45 ++++++++ .../ApproveIncreaseL1ValidatorBalance.tsx | 48 ++++++++ .../components/ApproveRegisterL1Validator.tsx | 43 +++++++ .../ApproveSetL1ValidatorWeight.tsx | 35 ++++++ .../components/AvalancheTxHeader.tsx | 21 ++++ 7 files changed, 317 insertions(+) create mode 100644 src/pages/ApproveAction/components/ApproveConvertSubnetToL1.tsx create mode 100644 src/pages/ApproveAction/components/ApproveDisableL1Validator.tsx create mode 100644 src/pages/ApproveAction/components/ApproveIncreaseL1ValidatorBalance.tsx create mode 100644 src/pages/ApproveAction/components/ApproveRegisterL1Validator.tsx create mode 100644 src/pages/ApproveAction/components/ApproveSetL1ValidatorWeight.tsx diff --git a/src/pages/ApproveAction/AvalancheSignTx.tsx b/src/pages/ApproveAction/AvalancheSignTx.tsx index 85786e5ed..e561d9756 100644 --- a/src/pages/ApproveAction/AvalancheSignTx.tsx +++ b/src/pages/ApproveAction/AvalancheSignTx.tsx @@ -37,6 +37,11 @@ import { FunctionNames, useIsFunctionAvailable, } from '@src/hooks/useIsFunctionAvailable'; +import { ApproveConvertSubnetToL1 } from './components/ApproveConvertSubnetToL1'; +import { ApproveRegisterL1Validator } from './components/ApproveRegisterL1Validator'; +import { ApproveIncreaseL1ValidatorBalance } from './components/ApproveIncreaseL1ValidatorBalance'; +import { ApproveDisableL1Validator } from './components/ApproveDisableL1Validator'; +import { ApproveSetL1ValidatorWeight } from './components/ApproveSetL1ValidatorWeight'; export function AvalancheSignTx() { const requestId = useGetRequestId(); @@ -136,6 +141,18 @@ export function AvalancheSignTx() { return ; } else if (Avalanche.isBaseTx(tx)) { return ; + } else if (Avalanche.isConvertSubnetToL1Tx(tx)) { + return ; + } else if (Avalanche.isRegisterL1ValidatorTx(tx)) { + return ; + } else if (Avalanche.isDisableL1ValidatorTx(tx)) { + return ; + } else if (Avalanche.isSetL1ValidatorWeightTx(tx)) { + return ; + } else if (Avalanche.isIncreaseL1ValidatorBalance(tx)) { + return ( + + ); } else if (Avalanche.isCreateSubnetTx(tx)) { return ( + + + + + + + + + + + + + + + + + } + > + {validators.map( + ({ + balance, + stake, + nodeId, + remainingBalanceOwners, + deactivationOwners, + }) => ( + + + + + + + + + + + + + {t('Owners Able to Deactivate')} + + + {deactivationOwners.map((address) => ( + + ))} + + + + + {t('Owners of the Remaining Balance')} + + + {remainingBalanceOwners.map((address) => ( + + ))} + + + + ) + )} + + + + + + + + + + + + ); +} diff --git a/src/pages/ApproveAction/components/ApproveDisableL1Validator.tsx b/src/pages/ApproveAction/components/ApproveDisableL1Validator.tsx new file mode 100644 index 000000000..3bf9b656b --- /dev/null +++ b/src/pages/ApproveAction/components/ApproveDisableL1Validator.tsx @@ -0,0 +1,45 @@ +import { useTranslation } from 'react-i18next'; + +import { + ApprovalSection, + ApprovalSectionBody, + ApprovalSectionHeader, +} from '@src/components/common/approval/ApprovalSection'; +import { TxDetailsRow } from '@src/components/common/approval/TxDetailsRow'; + +import { AvaxAmount } from './AvaxAmount'; +import { Avalanche } from '@avalabs/core-wallets-sdk'; +import { TruncatedIdentifier } from './TruncatedIdentifier'; + +export function ApproveDisableL1Validator({ + tx, + avaxPrice, +}: { + tx: Avalanche.DisableL1ValidatorTx; + avaxPrice: number; +}) { + const { t } = useTranslation(); + + const { txFee, validationId } = tx; + + return ( + <> + + + + + + + + + + + + + + + + + + ); +} diff --git a/src/pages/ApproveAction/components/ApproveIncreaseL1ValidatorBalance.tsx b/src/pages/ApproveAction/components/ApproveIncreaseL1ValidatorBalance.tsx new file mode 100644 index 000000000..c666549b4 --- /dev/null +++ b/src/pages/ApproveAction/components/ApproveIncreaseL1ValidatorBalance.tsx @@ -0,0 +1,48 @@ +import { useTranslation } from 'react-i18next'; + +import { + ApprovalSection, + ApprovalSectionBody, + ApprovalSectionHeader, +} from '@src/components/common/approval/ApprovalSection'; +import { TxDetailsRow } from '@src/components/common/approval/TxDetailsRow'; + +import { AvaxAmount } from './AvaxAmount'; +import { Avalanche } from '@avalabs/core-wallets-sdk'; +import { TruncatedIdentifier } from './TruncatedIdentifier'; + +export function ApproveIncreaseL1ValidatorBalance({ + tx, + avaxPrice, +}: { + tx: Avalanche.IncreaseL1ValidatorBalanceTx; + avaxPrice: number; +}) { + const { t } = useTranslation(); + + const { txFee, balance, validationId } = tx; + + return ( + <> + + + + + + + + + + + + + + + + + + + + + ); +} diff --git a/src/pages/ApproveAction/components/ApproveRegisterL1Validator.tsx b/src/pages/ApproveAction/components/ApproveRegisterL1Validator.tsx new file mode 100644 index 000000000..0b96f3c3d --- /dev/null +++ b/src/pages/ApproveAction/components/ApproveRegisterL1Validator.tsx @@ -0,0 +1,43 @@ +import { useTranslation } from 'react-i18next'; + +import { + ApprovalSection, + ApprovalSectionBody, + ApprovalSectionHeader, +} from '@src/components/common/approval/ApprovalSection'; +import { TxDetailsRow } from '@src/components/common/approval/TxDetailsRow'; + +import { AvaxAmount } from './AvaxAmount'; +import { Avalanche } from '@avalabs/core-wallets-sdk'; + +export function ApproveRegisterL1Validator({ + tx, + avaxPrice, +}: { + tx: Avalanche.RegisterL1ValidatorTx; + avaxPrice: number; +}) { + const { t } = useTranslation(); + const { txFee, balance } = tx; + + return ( + <> + + + + + + + + + + + + + + + + + + ); +} diff --git a/src/pages/ApproveAction/components/ApproveSetL1ValidatorWeight.tsx b/src/pages/ApproveAction/components/ApproveSetL1ValidatorWeight.tsx new file mode 100644 index 000000000..2e6d82000 --- /dev/null +++ b/src/pages/ApproveAction/components/ApproveSetL1ValidatorWeight.tsx @@ -0,0 +1,35 @@ +import { useTranslation } from 'react-i18next'; + +import { + ApprovalSection, + ApprovalSectionBody, + ApprovalSectionHeader, +} from '@src/components/common/approval/ApprovalSection'; +import { TxDetailsRow } from '@src/components/common/approval/TxDetailsRow'; + +import { AvaxAmount } from './AvaxAmount'; +import { Avalanche } from '@avalabs/core-wallets-sdk'; + +export function ApproveSetL1ValidatorWeight({ + tx, + avaxPrice, +}: { + tx: Avalanche.SetL1ValidatorWeightTx; + avaxPrice: number; +}) { + const { t } = useTranslation(); + const { txFee } = tx; + + return ( + <> + + + + + + + + + + ); +} diff --git a/src/pages/ApproveAction/components/AvalancheTxHeader.tsx b/src/pages/ApproveAction/components/AvalancheTxHeader.tsx index cc93cd4a5..5ca22e7eb 100644 --- a/src/pages/ApproveAction/components/AvalancheTxHeader.tsx +++ b/src/pages/ApproveAction/components/AvalancheTxHeader.tsx @@ -39,6 +39,27 @@ const useAvalancheTxHeader = (tx: Avalanche.Tx) => { case Avalanche.TxType.Base: return t('Approve Transaction'); + case Avalanche.TxType.ConvertSubnetToL1: + return t('Convert Subnet to L1'); + + case Avalanche.TxType.DisableL1Validator: + return t('Disable L1 Validator'); + + case Avalanche.TxType.IncreaseL1ValidatorBalance: + return t('Increase L1 Validator Balance'); + + case Avalanche.TxType.RegisterL1Validator: + return t('Register L1 Validator'); + + case Avalanche.TxType.SetL1ValidatorWeight: + return t('Set L1 Validator Weight'); + + case Avalanche.TxType.TransformSubnet: + return t('Transform Subnet'); + + case Avalanche.TxType.TransferSubnetOwnership: + return t('Transfer Subnet Ownership'); + default: return t('Unknown Transaction'); } From 6f3bc1ad0f27637d81da4c635940109ae0f2e7a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Leszczyk?= Date: Thu, 21 Nov 2024 20:13:11 +0100 Subject: [PATCH 16/16] chore: translations --- src/localization/locales/en/translation.json | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/localization/locales/en/translation.json b/src/localization/locales/en/translation.json index 52caf7b27..922dc7326 100644 --- a/src/localization/locales/en/translation.json +++ b/src/localization/locales/en/translation.json @@ -202,6 +202,7 @@ "Contract Call": "Contract Call", "Contract Deployment Approval": "Contract Deployment Approval", "Contract Type": "Contract Type", + "Convert Subnet to L1": "Convert Subnet to L1", "Copied!": "Copied!", "Copy": "Copy", "Copy Code": "Copy Code", @@ -256,6 +257,7 @@ "Description": "Description", "Details": "Details", "Developer Docs": "Developer Docs", + "Disable L1 Validator": "Disable L1 Validator", "Disconnect": "Disconnect", "Disconnected": "Disconnected", "Discover top dApps on Avalanche now.": "Discover top dApps on Avalanche now.", @@ -406,6 +408,9 @@ "Incompatible Wallet": "Incompatible Wallet", "Incorrect Ledger": "Incorrect Ledger", "Incorrect code. Try again.": "Incorrect code. Try again.", + "Increase L1 Validator Balance": "Increase L1 Validator Balance", + "Increase by amount": "Increase by amount", + "Initial balance": "Initial balance", "Input API Key": "Input API Key", "Input Password": "Input Password", "Input Secret Key": "Input Secret Key", @@ -475,6 +480,7 @@ "Manage Collectibles": "Manage Collectibles", "Manage Networks": "Manage Networks", "Manage Tokens": "Manage Tokens", + "Manager Address": "Manager Address", "Manually Create New Wallet": "Manually Create New Wallet", "Max Base Fee": "Max Base Fee", "Max Priority Fee": "Max Priority Fee", @@ -571,6 +577,8 @@ "Outgoing": "Outgoing", "Owner": "Owner", "Owners": "Owners", + "Owners Able to Deactivate": "Owners Able to Deactivate", + "Owners of the Remaining Balance": "Owners of the Remaining Balance", "Participate in Core Analytics": "Participate in Core Analytics", "Passkey": "Passkey", "Passkey Name": "Passkey Name", @@ -662,6 +670,7 @@ "Reenter the transaction details and try again.": "Reenter the transaction details and try again.", "Refresh is only available once per hour.": "Refresh is only available once per hour.", "Regenerate QR code": "Regenerate QR code", + "Register L1 Validator": "Register L1 Validator", "Register Wallet": "Register Wallet", "Reject": "Reject", "Reject Connection": "Reject Connection", @@ -736,6 +745,7 @@ "Sending Amount": "Sending Amount", "Sending To": "Sending To", "Sent": "Sent", + "Set L1 Validator Weight": "Set L1 Validator Weight", "Set Up Later": "Set Up Later", "Set a limit that you will allow {{domain}} to automatically spend.": "Set a limit that you will allow {{domain}} to automatically spend.", "Show Private Key": "Show Private Key", @@ -770,6 +780,7 @@ "Spendable Balance": "Spendable Balance", "Spender": "Spender", "Spending limit": "Spending limit", + "Stake": "Stake", "Stake Amount": "Stake Amount", "Staked": "Staked", "Staking Details": "Staking Details", @@ -937,6 +948,8 @@ "User declined the transaction": "User declined the transaction", "User rejected the request": "User rejected the request", "Users may not use the Bridge if they are on the Specially Designated Nationals (SDN) List of the Office of Foreign Assets Control (OFAC) or any other sanctions or are otherwise a sanctioned person or from a sanctioned jurisdiction": "Users may not use the Bridge if they are on the Specially Designated Nationals (SDN) List of the Office of Foreign Assets Control (OFAC) or any other sanctions or are otherwise a sanctioned person or from a sanctioned jurisdiction", + "Validation ID": "Validation ID", + "Validators": "Validators", "Value": "Value", "Verify": "Verify", "Verify Code": "Verify Code",