Skip to content

Commit

Permalink
fix: recalculate address on switch to devnet
Browse files Browse the repository at this point in the history
  • Loading branch information
meeh0w committed Oct 29, 2024
1 parent 649521c commit b25d1d4
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 75 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
"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": "2.1.0",
"@avalabs/core-bridge-sdk": "3.1.0-canary.d8363d2.0+d8363d2",
"@avalabs/core-chains-sdk": "3.1.0-canary.d8363d2.0+d8363d2",
Expand All @@ -37,11 +37,11 @@
"@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.11.2",
"@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-canary.d8363d2.0+d8363d2",
"@avalabs/vm-module-types": "0.11.2",
"@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",
Expand Down
20 changes: 20 additions & 0 deletions src/background/services/accounts/AccountsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand All @@ -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) => {
Expand Down
142 changes: 71 additions & 71 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -92,12 +92,12 @@
"@avalabs/core-utils-sdk" "3.1.0-canary.d8363d2.0+d8363d2"
"@avalabs/core-wallets-sdk" "3.1.0-canary.d8363d2.0+d8363d2"

"@avalabs/[email protected]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/[email protected]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/[email protected]+d8363d2":
version "3.1.0-canary.d8363d2.0"
Expand All @@ -106,12 +106,12 @@
dependencies:
"@avalabs/core-utils-sdk" "3.1.0-canary.d8363d2.0+d8363d2"

"@avalabs/[email protected]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/[email protected]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/[email protected]+d8363d2":
version "3.1.0-canary.d8363d2.0"
Expand All @@ -127,12 +127,12 @@
dependencies:
"@avalabs/core-utils-sdk" "3.1.0-canary.d8363d2.0+d8363d2"

"@avalabs/[email protected]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/[email protected]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-alpha.10"
"@avalabs/core-utils-sdk" "3.1.0-canary.bef569b.0+bef569b"

"@avalabs/[email protected]+d8363d2":
version "3.1.0-canary.d8363d2.0"
Expand Down Expand Up @@ -179,10 +179,10 @@
"@avalabs/core-coingecko-sdk" "3.1.0-canary.d8363d2.0+d8363d2"
"@avalabs/core-utils-sdk" "3.1.0-canary.d8363d2.0+d8363d2"

"@avalabs/[email protected]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/[email protected]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/avalanchejs" "4.1.0-alpha.7"
"@hpke/core" "1.2.5"
Expand All @@ -197,14 +197,14 @@
"@hpke/core" "1.2.5"
is-ipfs "6.0.2"

"@avalabs/[email protected]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/[email protected]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"
Expand Down Expand Up @@ -245,18 +245,18 @@
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/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"
Expand All @@ -265,10 +265,10 @@
xss "1.0.13"
zod "3.23.8"

"@avalabs/[email protected]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/[email protected]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/[email protected]+d8363d2":
version "3.1.0-canary.d8363d2.0"
Expand All @@ -286,23 +286,23 @@
ledger-bitcoin "^0.2.1"
sha3 "2.1.4"

"@avalabs/[email protected]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/[email protected]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/[email protected]+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"
Expand Down

0 comments on commit b25d1d4

Please sign in to comment.