From 2b8a8520ab0c28e9bbb2cdd619a8ec148315bbca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Leszczyk?= Date: Mon, 7 Oct 2024 18:33:51 +0200 Subject: [PATCH] feat: provide custom headers to Glacier calls (#58) --- package.json | 28 +- .../services/balances/BalancesService.test.ts | 24 +- .../utils/isTokenWithBalanceAVM.test.ts | 24 +- .../utils/isTokenWithBalancePVM.test.ts | 24 +- .../services/bridge/BridgeService.test.ts | 8 +- .../services/bridge/BridgeService.ts | 2 +- .../handlers/avalanche_bridgeAsset.test.ts | 7 +- .../bridge/handlers/avalanche_bridgeAsset.ts | 21 +- .../services/glacier/GlacierService.test.ts | 76 ------ .../services/glacier/GlacierService.ts | 95 +------ .../services/glacier/glacierConfig.ts | 7 + .../avalanche_sendTransaction.test.ts | 3 + .../handlers/avalanche_sendTransaction.ts | 2 + .../avalanche_signTransaction.test.ts | 7 + .../handlers/avalanche_signTransaction.ts | 2 + src/background/vmModules/ModuleManager.ts | 16 +- yarn.lock | 247 +++++++----------- 17 files changed, 210 insertions(+), 383 deletions(-) create mode 100644 src/background/services/glacier/glacierConfig.ts diff --git a/package.json b/package.json index 4ee7816b..0ccfe458 100644 --- a/package.json +++ b/package.json @@ -23,25 +23,25 @@ "sentry": "node sentryscript.js" }, "dependencies": { - "@avalabs/avalanche-module": "0.7.0", + "@avalabs/avalanche-module": "0.7.3", "@avalabs/avalanchejs": "4.0.5", - "@avalabs/bitcoin-module": "0.7.0", + "@avalabs/bitcoin-module": "0.7.3", "@avalabs/bridge-unified": "2.1.0", - "@avalabs/core-bridge-sdk": "3.1.0-alpha.4", - "@avalabs/core-chains-sdk": "3.1.0-alpha.4", - "@avalabs/core-coingecko-sdk": "3.1.0-alpha.4", - "@avalabs/core-covalent-sdk": "3.1.0-alpha.4", - "@avalabs/core-etherscan-sdk": "3.1.0-alpha.4", + "@avalabs/core-bridge-sdk": "3.1.0-alpha.7", + "@avalabs/core-chains-sdk": "3.1.0-alpha.7", + "@avalabs/core-coingecko-sdk": "3.1.0-alpha.7", + "@avalabs/core-covalent-sdk": "3.1.0-alpha.7", + "@avalabs/core-etherscan-sdk": "3.1.0-alpha.7", "@avalabs/core-k2-components": "4.18.0-alpha.47", - "@avalabs/core-snowtrace-sdk": "3.1.0-alpha.4", - "@avalabs/core-token-prices-sdk": "3.1.0-alpha.4", - "@avalabs/core-utils-sdk": "3.1.0-alpha.4", - "@avalabs/core-wallets-sdk": "3.1.0-alpha.4", - "@avalabs/evm-module": "0.7.0", - "@avalabs/glacier-sdk": "3.1.0-alpha.4", + "@avalabs/core-snowtrace-sdk": "3.1.0-alpha.7", + "@avalabs/core-token-prices-sdk": "3.1.0-alpha.7", + "@avalabs/core-utils-sdk": "3.1.0-alpha.7", + "@avalabs/core-wallets-sdk": "3.1.0-alpha.7", + "@avalabs/evm-module": "0.7.3", + "@avalabs/glacier-sdk": "3.1.0-alpha.7", "@avalabs/hw-app-avalanche": "0.14.1", "@avalabs/types": "3.1.0-alpha.3", - "@avalabs/vm-module-types": "0.7.0", + "@avalabs/vm-module-types": "0.7.3", "@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/BalancesService.test.ts b/src/background/services/balances/BalancesService.test.ts index 54a361da..20fd8a0b 100644 --- a/src/background/services/balances/BalancesService.test.ts +++ b/src/background/services/balances/BalancesService.test.ts @@ -67,14 +67,14 @@ describe('src/background/services/balances/BalancesService.ts', () => { atomicMemoryLocked: [], }, balancePerType: { - lockedStaked: 1, - lockedStakeable: 0, - lockedPlatform: 0, - atomicMemoryLocked: 0, - atomicMemoryUnlocked: 0, - unlockedUnstaked: 0, - unlockedStaked: 0, - pendingStaked: 0, + lockedStaked: 1n, + lockedStakeable: 0n, + lockedPlatform: 0n, + atomicMemoryLocked: 0n, + atomicMemoryUnlocked: 0n, + unlockedUnstaked: 0n, + unlockedStaked: 0n, + pendingStaked: 0n, }, }, }, @@ -128,10 +128,10 @@ describe('src/background/services/balances/BalancesService.ts', () => { }, balancePerType: { - locked: 3, - unlocked: 3, - atomicMemoryLocked: 0, - atomicMemoryUnlocked: 0, + locked: 3n, + unlocked: 3n, + atomicMemoryLocked: 0n, + atomicMemoryUnlocked: 0n, }, }, }, diff --git a/src/background/services/balances/utils/isTokenWithBalanceAVM.test.ts b/src/background/services/balances/utils/isTokenWithBalanceAVM.test.ts index 64e4c433..5f8e417d 100644 --- a/src/background/services/balances/utils/isTokenWithBalanceAVM.test.ts +++ b/src/background/services/balances/utils/isTokenWithBalanceAVM.test.ts @@ -20,10 +20,10 @@ describe('src/background/services/balances/utils/isTokenWithBalanceAVM.ts', () = description: 'description', logoUri: 'logoUri', balancePerType: { - locked: 1, - unlocked: 2, - atomicMemoryUnlocked: 3, - atomicMemoryLocked: 4, + locked: 1n, + unlocked: 2n, + atomicMemoryUnlocked: 3n, + atomicMemoryLocked: 4n, }, }; @@ -38,14 +38,14 @@ describe('src/background/services/balances/utils/isTokenWithBalanceAVM.ts', () = description: 'description', logoUri: 'logoUri', balancePerType: { - atomicMemoryLocked: 4, - atomicMemoryUnlocked: 5, - lockedStaked: 1, - lockedStakeable: 2, - lockedPlatform: 3, - unlockedUnstaked: 6, - unlockedStaked: 7, - pendingStaked: 8, + atomicMemoryLocked: 4n, + atomicMemoryUnlocked: 5n, + lockedStaked: 1n, + lockedStakeable: 2n, + lockedPlatform: 3n, + unlockedUnstaked: 6n, + unlockedStaked: 7n, + pendingStaked: 8n, }, }; diff --git a/src/background/services/balances/utils/isTokenWithBalancePVM.test.ts b/src/background/services/balances/utils/isTokenWithBalancePVM.test.ts index 950bc1aa..5e3a3788 100644 --- a/src/background/services/balances/utils/isTokenWithBalancePVM.test.ts +++ b/src/background/services/balances/utils/isTokenWithBalancePVM.test.ts @@ -19,10 +19,10 @@ describe('src/background/services/balances/utils/isTokenWithBalancePVM.ts', () = description: 'description', logoUri: 'logoUri', balancePerType: { - locked: 1, - unlocked: 2, - atomicMemoryUnlocked: 3, - atomicMemoryLocked: 4, + locked: 1n, + unlocked: 2n, + atomicMemoryUnlocked: 3n, + atomicMemoryLocked: 4n, }, }; @@ -37,14 +37,14 @@ describe('src/background/services/balances/utils/isTokenWithBalancePVM.ts', () = description: 'description', logoUri: 'logoUri', balancePerType: { - lockedStaked: 1, - lockedStakeable: 2, - lockedPlatform: 3, - atomicMemoryLocked: 4, - atomicMemoryUnlocked: 5, - unlockedUnstaked: 6, - unlockedStaked: 7, - pendingStaked: 8, + lockedStaked: 1n, + lockedStakeable: 2n, + lockedPlatform: 3n, + atomicMemoryLocked: 4n, + atomicMemoryUnlocked: 5n, + unlockedUnstaked: 6n, + unlockedStaked: 7n, + pendingStaked: 8n, }, }; diff --git a/src/background/services/bridge/BridgeService.test.ts b/src/background/services/bridge/BridgeService.test.ts index 302cb528..966687a6 100644 --- a/src/background/services/bridge/BridgeService.test.ts +++ b/src/background/services/bridge/BridgeService.test.ts @@ -54,9 +54,11 @@ const addressBTC = 'tb01234'; const networkBalancesService = { getBalancesForNetworks: async () => ({ - [ChainId.BITCOIN_TESTNET]: { - [addressBTC]: { - BTC: {}, + tokens: { + [ChainId.BITCOIN_TESTNET]: { + [addressBTC]: { + BTC: {}, + }, }, }, }), diff --git a/src/background/services/bridge/BridgeService.ts b/src/background/services/bridge/BridgeService.ts index 1001ff31..f31578eb 100644 --- a/src/background/services/bridge/BridgeService.ts +++ b/src/background/services/bridge/BridgeService.ts @@ -197,7 +197,7 @@ export class BridgeService implements OnLock, OnStorageReady { [this.accountsService.activeAccount] ); - const token = balances[btcNetwork.chainId]?.[addressBtc]?.[ + const token = balances.tokens[btcNetwork.chainId]?.[addressBtc]?.[ 'BTC' ] as TokenWithBalanceBTC; diff --git a/src/background/services/bridge/handlers/avalanche_bridgeAsset.test.ts b/src/background/services/bridge/handlers/avalanche_bridgeAsset.test.ts index 782287a8..b64d7dbe 100644 --- a/src/background/services/bridge/handlers/avalanche_bridgeAsset.test.ts +++ b/src/background/services/bridge/handlers/avalanche_bridgeAsset.test.ts @@ -167,7 +167,10 @@ describe('background/services/bridge/handlers/avalanche_bridgeAsset', () => { networkServiceMock.getBitcoinProvider.mockResolvedValue({ waitForTx: jest.fn().mockResolvedValue(btcResult), }); - balanceAggregatorServiceMock.getBalancesForNetworks.mockResolvedValue({}); + balanceAggregatorServiceMock.getBalancesForNetworks.mockResolvedValue({ + tokens: {}, + nfts: {}, + }); jest.mocked(openApprovalWindow).mockResolvedValue({} as any); jest.mocked(getAssets).mockReturnValue({ BTC: btcAsset, @@ -607,7 +610,7 @@ describe('background/services/bridge/handlers/avalanche_bridgeAsset', () => { expect(transferAssetBTC).toHaveBeenCalledTimes(1); expect(transferAssetBTC).toHaveBeenCalledWith( expect.objectContaining({ - amount: String(btcToSatoshi(amount)), + amount: btcToSatoshi(amount), }) ); diff --git a/src/background/services/bridge/handlers/avalanche_bridgeAsset.ts b/src/background/services/bridge/handlers/avalanche_bridgeAsset.ts index 26d894f7..1db0c7d1 100644 --- a/src/background/services/bridge/handlers/avalanche_bridgeAsset.ts +++ b/src/background/services/bridge/handlers/avalanche_bridgeAsset.ts @@ -310,7 +310,7 @@ export class AvalancheBridgeAsset extends DAppRequestHandler 0 ); - const token = balances[network.chainId]?.[addressBTC]?.[ + const token = balances.tokens[network.chainId]?.[addressBTC]?.[ 'BTC' ] as TokenWithBalanceBTC; @@ -319,17 +319,20 @@ export class AvalancheBridgeAsset extends DAppRequestHandler const utxos = await getBtcInputUtxos(btcProvider, token, highFeeRate); const hash = await transferAssetBTC({ + fromAccount: addressBTC, config: this.#getConfig(), - amount: String(btcToSatoshi(amount)), - feeRate: highFeeRate, + amount: btcToSatoshi(amount), + feeRate: + Number(pendingAction.displayData.gasSettings?.maxFeePerGas ?? 0) || + highFeeRate, onStatusChange: () => {}, onTxHashChange: () => {}, - signAndSendBTC: async ([address, amountAsString, feeRate]) => { + signAndSendBTC: async ({ amount: signAmount, feeRate, to, from }) => { const error = validateBtcSend( - addressBTC, + from, { - address, - amount: Number(amountAsString), + address: to, + amount: signAmount, feeRate, token, }, @@ -347,8 +350,8 @@ export class AvalancheBridgeAsset extends DAppRequestHandler addressBTC, btcProvider, { - amount: Number(amountAsString), - address, + amount: signAmount, + address: to, token, feeRate, } diff --git a/src/background/services/glacier/GlacierService.test.ts b/src/background/services/glacier/GlacierService.test.ts index bb165c1b..0b680802 100644 --- a/src/background/services/glacier/GlacierService.test.ts +++ b/src/background/services/glacier/GlacierService.test.ts @@ -1,7 +1,5 @@ import { - BlockchainId, Glacier, - Network, PrimaryNetwork, PrimaryNetworkChainName, } from '@avalabs/glacier-sdk'; @@ -38,11 +36,6 @@ const pchainBalance = { }, }; -const waitForFirstHealthCheck = async () => { - jest.runOnlyPendingTimers(); - await new Promise(jest.requireActual('timers').setImmediate); -}; - describe('src/background/services/glacier/GlacierService.ts', () => { beforeEach(() => { jest.resetAllMocks(); @@ -72,14 +65,6 @@ describe('src/background/services/glacier/GlacierService.ts', () => { afterEach(() => { jest.useRealTimers(); }); - it('should call a `setTimeout` which sets `isGlacierHealthy` to true after 5 mins', async () => { - jest.spyOn(global, 'setTimeout'); - - const glacierService = new GlacierService(); - glacierService.setGlacierToUnhealthy(); - - expect(setTimeout).toHaveBeenCalled(); - }); describe('reindexNft', () => { it('schedules reindexing of the given NFT', async () => { @@ -176,65 +161,4 @@ describe('src/background/services/glacier/GlacierService.ts', () => { expect(getTokenDetails).toHaveBeenCalledTimes(10); }); }); - - describe('isNetworkSupported', () => { - it('should set the `isNetworkSupported` to false (and set the `isGlacierHealthy` to false as well)', async () => { - const glacierService = new GlacierService(); - glacierService.setGlacierToUnhealthy(); - - const isNetworkSupported = await glacierService.isNetworkSupported(1); - expect(isNetworkSupported).toBe(false); - }); - - it('returns false if fetching supported chains fails', async () => { - supportedChainsMock.mockRejectedValue('some error'); - - const glacierService = new GlacierService(); - supportedChainsMock.mockReset(); // It's first called when GlacierService is instantiated, so we need to reset the counter. - - await waitForFirstHealthCheck(); - - const result = await glacierService.isNetworkSupported(1); - - expect(result).toBe(false); - expect(supportedChainsMock).toHaveBeenCalledTimes(1); - }); - - it('returns true if the provided chain id is supported', async () => { - supportedChainsMock.mockResolvedValue({ chains: [{ chainId: '1' }] }); - - const glacierService = new GlacierService(); - await waitForFirstHealthCheck(); - - const result = await glacierService.isNetworkSupported(1); - expect(result).toBe(true); - }); - - it('fetches supported chains only once', async () => { - supportedChainsMock.mockResolvedValue({ chains: [{ chainId: '1' }] }); - - const glacierService = new GlacierService(); - await waitForFirstHealthCheck(); - - const result_1 = await glacierService.isNetworkSupported(1); - const result_2 = await glacierService.isNetworkSupported(1); - const result_3 = await glacierService.isNetworkSupported(1); - - expect([result_1, result_2, result_3]).toStrictEqual([true, true, true]); - expect(supportedChainsMock).toHaveBeenCalledTimes(1); - }); - }); - - describe('getChainBalance', () => { - it('should return response from getBalancesByAddresses', async () => { - const glacierService = new GlacierService(); - const result = await glacierService.getChainBalance({ - blockchainId: BlockchainId.P_CHAIN, - network: Network.FUJI, - addresses: 'address', - }); - - expect(result).toEqual(pchainBalance); - }); - }); }); diff --git a/src/background/services/glacier/GlacierService.ts b/src/background/services/glacier/GlacierService.ts index 43e28894..776164dc 100644 --- a/src/background/services/glacier/GlacierService.ts +++ b/src/background/services/glacier/GlacierService.ts @@ -1,40 +1,17 @@ -import { - BlockchainId, - Erc1155Token, - Erc721Token, - Glacier, - Network, - PrimaryNetworkTxType, - SortOrder, -} from '@avalabs/glacier-sdk'; +import { Erc1155Token, Erc721Token, Glacier } from '@avalabs/glacier-sdk'; import { singleton } from 'tsyringe'; import { wait } from '@avalabs/core-utils-sdk'; import { CommonError } from '@src/utils/errors'; +import { HEADERS } from './glacierConfig'; + @singleton() export class GlacierService { - private glacierSdkInstance = new Glacier({ BASE: process.env.GLACIER_URL }); - private isGlacierHealthy = true; - private supportedNetworks: string[] = []; - - private async getSupportedNetworks() { - if (this.supportedNetworks.length) { - return this.supportedNetworks; - } - - try { - const supportedNetworks = - await this.glacierSdkInstance.evmChains.supportedChains({}); - this.supportedNetworks = supportedNetworks.chains.map( - (chain) => chain.chainId - ); - - return this.supportedNetworks; - } catch { - return []; - } - } + private glacierSdkInstance = new Glacier({ + BASE: process.env.GLACIER_URL, + HEADERS, + }); async refreshNftMetadata(address: string, chainId: string, tokenId: string) { const requestTimestamp = Math.floor(Date.now() / 1000); @@ -77,62 +54,4 @@ export class GlacierService { return token; } - - async isNetworkSupported(chainId: number) { - if (!this.isGlacierHealthy) return this.isGlacierHealthy; - const networks = await this.getSupportedNetworks(); - return networks.includes(chainId.toString()); - } - - constructor() { - /** - * This is for performance, basically we just cache the health of glacier every 5 seconds and - * go off of that instead of every request - */ - this.getSupportedNetworks().catch(() => { - // Noop. It will be retried by .isSupportedNetwork calls upon unlocking if necessary. - }); - } - - setGlacierToUnhealthy() { - this.isGlacierHealthy = false; - setTimeout(() => { - this.isGlacierHealthy = true; - }, 5 * 60 * 1000); - } - - async getChainBalance(params: { - blockchainId: BlockchainId; - network: Network; - blockTimestamp?: number; - addresses?: string; - }) { - return this.glacierSdkInstance.primaryNetworkBalances.getBalancesByAddresses( - params - ); - } - - async listLatestPrimaryNetworkTransactions(params: { - blockchainId: BlockchainId; - network: Network; - addresses?: string; - txTypes?: Array; - startTimestamp?: number; - endTimestamp?: number; - pageToken?: string; - pageSize?: number; - sortOrder?: SortOrder; - }) { - return this.glacierSdkInstance.primaryNetworkTransactions.listLatestPrimaryNetworkTransactions( - params - ); - } - async getChainIdsForAddresses(params: { - addresses: string; - network: Network; - }) { - return this.glacierSdkInstance.primaryNetwork.getChainIdsForAddresses( - params - ); - } } diff --git a/src/background/services/glacier/glacierConfig.ts b/src/background/services/glacier/glacierConfig.ts new file mode 100644 index 00000000..20ea3f47 --- /dev/null +++ b/src/background/services/glacier/glacierConfig.ts @@ -0,0 +1,7 @@ +import { AppName } from '@avalabs/vm-module-types'; +import { runtime } from 'webextension-polyfill'; + +export const HEADERS = { + 'x-application-name': AppName.CORE_EXTENSION, + 'x-application-version': runtime.getManifest().version, +}; diff --git a/src/background/services/wallet/handlers/avalanche_sendTransaction.test.ts b/src/background/services/wallet/handlers/avalanche_sendTransaction.test.ts index df98bca9..8e96c5dd 100644 --- a/src/background/services/wallet/handlers/avalanche_sendTransaction.test.ts +++ b/src/background/services/wallet/handlers/avalanche_sendTransaction.test.ts @@ -17,6 +17,7 @@ import { encryptAnalyticsData } from '../../analytics/utils/encryptAnalyticsData import { openApprovalWindow } from '@src/background/runtime/openApprovalWindow'; import { buildRpcCall } from '@src/tests/test-utils'; import { measureDuration } from '@src/utils/measureDuration'; +import { HEADERS } from '../../glacier/glacierConfig'; jest.mock('@avalabs/avalanchejs'); jest.mock('@avalabs/core-wallets-sdk'); @@ -335,6 +336,7 @@ describe('src/background/services/wallet/handlers/avalanche_sendTransaction.ts', isTestnet: true, url: process.env.GLACIER_URL, token: process.env.GLACIER_API_KEY, + headers: HEADERS, }); checkExpected(request, result, tx); }); @@ -415,6 +417,7 @@ describe('src/background/services/wallet/handlers/avalanche_sendTransaction.ts', isTestnet: true, 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 9c306d14..55ed4d1c 100644 --- a/src/background/services/wallet/handlers/avalanche_sendTransaction.ts +++ b/src/background/services/wallet/handlers/avalanche_sendTransaction.ts @@ -25,6 +25,7 @@ import { AnalyticsServicePosthog } from '../../analytics/AnalyticsServicePosthog 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'; type TxParams = { transactionHex: string; @@ -102,6 +103,7 @@ export class AvalancheSendTransactionHandler extends DAppRequestHandler< isTestnet: !this.networkService.isMainnet(), url: process.env.GLACIER_URL as string, token: process.env.GLACIER_API_KEY, + headers: HEADERS, }); if (vm === EVM) { diff --git a/src/background/services/wallet/handlers/avalanche_signTransaction.test.ts b/src/background/services/wallet/handlers/avalanche_signTransaction.test.ts index 7491feb9..a9047d0d 100644 --- a/src/background/services/wallet/handlers/avalanche_signTransaction.test.ts +++ b/src/background/services/wallet/handlers/avalanche_signTransaction.test.ts @@ -14,6 +14,7 @@ import { Action } from '../../actions/models'; import getProvidedUtxos from '../utils/getProvidedUtxos'; import { openApprovalWindow } from '@src/background/runtime/openApprovalWindow'; import { buildRpcCall } from '@src/tests/test-utils'; +import { HEADERS } from '../../glacier/glacierConfig'; jest.mock('@avalabs/avalanchejs'); jest.mock('@avalabs/core-wallets-sdk'); @@ -226,6 +227,7 @@ describe('src/background/services/wallet/handlers/avalanche_signTransaction', () isTestnet: true, url: process.env.GLACIER_URL, token: process.env.GLACIER_API_KEY, + headers: HEADERS, }); expect(Avalanche.createAvalancheUnsignedTx).toHaveBeenCalledWith({ tx: txMock, @@ -273,6 +275,7 @@ describe('src/background/services/wallet/handlers/avalanche_signTransaction', () isTestnet: true, url: process.env.GLACIER_URL, token: process.env.GLACIER_API_KEY, + headers: HEADERS, }); expect(Avalanche.createAvalancheUnsignedTx).toHaveBeenCalledWith({ tx: txMock, @@ -327,6 +330,7 @@ describe('src/background/services/wallet/handlers/avalanche_signTransaction', () isTestnet: true, url: process.env.GLACIER_URL, token: process.env.GLACIER_API_KEY, + headers: HEADERS, }); expect(Avalanche.createAvalancheUnsignedTx).toHaveBeenCalledWith({ tx: txMock, @@ -383,6 +387,7 @@ describe('src/background/services/wallet/handlers/avalanche_signTransaction', () isTestnet: true, url: process.env.GLACIER_URL, token: process.env.GLACIER_API_KEY, + headers: HEADERS, }); expect(Avalanche.createAvalancheUnsignedTx).toHaveBeenCalledWith({ tx: txMock, @@ -524,6 +529,7 @@ describe('src/background/services/wallet/handlers/avalanche_signTransaction', () isTestnet: true, url: process.env.GLACIER_URL, token: process.env.GLACIER_API_KEY, + headers: HEADERS, }); }); }); @@ -712,6 +718,7 @@ describe('src/background/services/wallet/handlers/avalanche_signTransaction', () isTestnet: true, 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 42809dbc..92a77f1b 100644 --- a/src/background/services/wallet/handlers/avalanche_signTransaction.ts +++ b/src/background/services/wallet/handlers/avalanche_signTransaction.ts @@ -20,6 +20,7 @@ import getAddressByVM from '../utils/getAddressByVM'; import { Avalanche } from '@avalabs/core-wallets-sdk'; import getProvidedUtxos from '../utils/getProvidedUtxos'; import { openApprovalWindow } from '@src/background/runtime/openApprovalWindow'; +import { HEADERS } from '../../glacier/glacierConfig'; type TxParams = { transactionHex: string; @@ -91,6 +92,7 @@ export class AvalancheSignTransactionHandler extends DAppRequestHandler