@subwallet/extension-base 1.2.32-0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/background/KoniTypes.d.ts +78 -227
- package/background/KoniTypes.js +3 -40
- package/background/errors/SWError.d.ts +4 -7
- package/background/errors/SWError.js +4 -0
- package/background/errors/TransactionError.d.ts +2 -2
- package/background/errors/TransactionError.js +2 -4
- package/background/handlers/State.d.ts +0 -12
- package/background/types.d.ts +9 -134
- package/background/warnings/TransactionWarning.d.ts +1 -1
- package/background/warnings/TransactionWarning.js +5 -1
- package/cjs/background/KoniTypes.js +4 -44
- package/cjs/background/errors/SWError.js +4 -0
- package/cjs/background/errors/TransactionError.js +13 -15
- package/cjs/background/warnings/TransactionWarning.js +6 -2
- package/cjs/constants/environment.js +13 -0
- package/cjs/constants/index.js +40 -13
- package/cjs/constants/signing.js +23 -0
- package/cjs/constants/storage.js +4 -2
- package/cjs/core/consts.js +20 -0
- package/cjs/core/logic-validation/recipientAddress.js +106 -0
- package/cjs/core/logic-validation/request.js +11 -19
- package/cjs/core/logic-validation/swap.js +5 -5
- package/cjs/core/logic-validation/transfer.js +83 -42
- package/cjs/core/types.js +26 -0
- package/cjs/core/utils.js +113 -0
- package/cjs/koni/api/dotsama/crowdloan.js +1 -1
- package/cjs/koni/api/nft/index.js +14 -5
- package/cjs/koni/api/staking/bonding/paraChain.js +8 -8
- package/cjs/koni/api/staking/bonding/relayChain.js +9 -9
- package/cjs/koni/api/staking/index.js +4 -1
- package/cjs/koni/background/cron.js +7 -7
- package/cjs/koni/background/handlers/Extension.js +510 -1446
- package/cjs/koni/background/handlers/State.js +61 -238
- package/cjs/koni/background/handlers/Tabs.js +143 -107
- package/cjs/koni/background/subscription.js +5 -5
- package/cjs/packageInfo.js +1 -1
- package/cjs/page/Accounts.js +2 -5
- package/cjs/page/SubWalleEvmProvider.js +1 -1
- package/cjs/page/index.js +2 -1
- package/cjs/services/balance-service/BalanceMapImpl.js +48 -20
- package/cjs/services/balance-service/helpers/subscribe/index.js +27 -12
- package/cjs/services/balance-service/helpers/subscribe/ton/consts.js +40 -0
- package/cjs/services/balance-service/helpers/subscribe/ton/ton.js +120 -0
- package/cjs/services/balance-service/helpers/subscribe/ton/utils.js +181 -0
- package/cjs/services/balance-service/index.js +25 -13
- package/cjs/services/balance-service/transfer/token.js +41 -24
- package/cjs/services/balance-service/transfer/ton-transfer.js +136 -0
- package/cjs/services/buy-service/index.js +5 -1
- package/cjs/services/chain-service/constants.js +1 -1
- package/cjs/services/chain-service/handler/TonApi.js +213 -0
- package/cjs/services/chain-service/handler/TonChainHandler.js +81 -0
- package/cjs/services/chain-service/index.js +32 -8
- package/cjs/services/chain-service/utils/index.js +78 -22
- package/cjs/services/earning-service/constants/chains.js +3 -1
- package/cjs/services/earning-service/handlers/base.js +2 -1
- package/cjs/services/earning-service/handlers/lending/base.js +8 -9
- package/cjs/services/earning-service/handlers/lending/interlay.js +1 -1
- package/cjs/services/earning-service/handlers/liquid-staking/base.js +9 -10
- package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +1 -1
- package/cjs/services/earning-service/handlers/native-staking/amplitude.js +1 -1
- package/cjs/services/earning-service/handlers/native-staking/astar.js +2 -2
- package/cjs/services/earning-service/handlers/native-staking/base-para.js +13 -13
- package/cjs/services/earning-service/handlers/native-staking/base.js +2 -2
- package/cjs/services/earning-service/handlers/native-staking/para-chain.js +2 -2
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +15 -15
- package/cjs/services/earning-service/handlers/nomination-pool/index.js +14 -14
- package/cjs/services/earning-service/handlers/special.js +10 -10
- package/cjs/services/earning-service/service.js +26 -17
- package/cjs/services/history-service/helpers/subscan-extrinsic-parser-helper.js +1 -1
- package/cjs/services/history-service/index.js +29 -11
- package/cjs/services/history-service/subscan-history.js +9 -21
- package/cjs/services/keyring-service/context/account-context.js +259 -0
- package/cjs/services/keyring-service/context/handlers/Base.js +20 -0
- package/cjs/services/keyring-service/context/handlers/Derive.js +377 -0
- package/cjs/services/keyring-service/context/handlers/Inject.js +75 -0
- package/cjs/services/keyring-service/context/handlers/Json.js +348 -0
- package/cjs/services/keyring-service/context/handlers/Ledger.js +165 -0
- package/cjs/services/keyring-service/context/handlers/Mnemonic.js +218 -0
- package/cjs/services/keyring-service/context/handlers/Modify.js +258 -0
- package/cjs/services/keyring-service/context/handlers/Secret.js +310 -0
- package/cjs/services/keyring-service/context/handlers/index.js +82 -0
- package/cjs/services/keyring-service/context/state.js +649 -0
- package/cjs/services/keyring-service/context/stores/AccountProxy.js +32 -0
- package/cjs/services/keyring-service/context/stores/Base.js +37 -0
- package/cjs/services/keyring-service/context/stores/CurrentAccount.js +28 -0
- package/cjs/services/keyring-service/context/stores/ModifyPair.js +19 -0
- package/cjs/services/keyring-service/context/stores/index.js +38 -0
- package/cjs/services/keyring-service/index.js +20 -164
- package/cjs/services/migration-service/scripts/index.js +6 -4
- package/cjs/services/migration-service/scripts/{MigrateLedgerAccountV2.js → keyring/MigrateLedgerAccountV2.js} +1 -1
- package/cjs/services/migration-service/scripts/keyring/MigratePairData.js +28 -0
- package/cjs/services/migration-service/scripts/{MigrateRemoveGenesisHash.js → keyring/MigrateRemoveGenesisHash.js} +1 -1
- package/cjs/services/request-service/constants.js +5 -3
- package/cjs/services/request-service/handler/AuthRequestHandler.js +104 -57
- package/cjs/services/request-service/handler/EvmRequestHandler.js +3 -4
- package/cjs/services/request-service/handler/SubstrateRequestHandler.js +5 -11
- package/cjs/services/request-service/handler/TonRequestHandler.js +175 -0
- package/cjs/services/request-service/index.js +24 -5
- package/cjs/services/swap-service/handler/asset-hub/handler.js +6 -5
- package/cjs/services/swap-service/handler/base-handler.js +8 -8
- package/cjs/services/swap-service/handler/chainflip-handler.js +5 -4
- package/cjs/services/swap-service/handler/hydradx-handler.js +4 -3
- package/cjs/services/swap-service/index.js +4 -4
- package/cjs/services/transaction-service/helpers/index.js +6 -1
- package/cjs/services/transaction-service/index.js +184 -84
- package/cjs/services/wallet-connect-service/handler/PolkadotRequestHandler.js +2 -10
- package/cjs/stores/AccountProxyStore.js +18 -0
- package/cjs/stores/ModifyPairStore.js +18 -0
- package/cjs/stores/index.js +23 -2
- package/cjs/types/account/action/add/index.js +38 -0
- package/cjs/types/account/action/add/json.js +1 -0
- package/cjs/types/account/action/add/mnemonic.js +1 -0
- package/cjs/types/account/action/add/secret.js +1 -0
- package/cjs/types/account/action/derive.js +1 -0
- package/cjs/types/account/action/edit.js +1 -0
- package/cjs/types/account/action/export.js +1 -0
- package/cjs/types/account/action/index.js +71 -0
- package/cjs/types/account/action/subscribe.js +16 -0
- package/cjs/types/account/action/validate.js +1 -0
- package/cjs/types/account/error/common.js +40 -0
- package/cjs/types/account/error/derive.js +55 -0
- package/cjs/types/account/error/index.js +27 -0
- package/cjs/types/account/index.js +38 -0
- package/cjs/types/account/info/current.js +1 -0
- package/cjs/types/account/info/index.js +38 -0
- package/cjs/types/account/info/keyring.js +90 -0
- package/cjs/types/account/info/proxy.js +49 -0
- package/cjs/types/error.js +1 -0
- package/cjs/types/index.js +44 -0
- package/cjs/types/transaction/data.js +1 -0
- package/cjs/types/transaction/error.js +53 -0
- package/cjs/types/transaction/index.js +49 -0
- package/cjs/types/transaction/request.js +1 -0
- package/cjs/types/transaction/warning.js +14 -0
- package/cjs/types/yield/actions/join/validate.js +1 -16
- package/cjs/utils/account/analyze.js +166 -0
- package/cjs/utils/account/common.js +121 -0
- package/cjs/utils/account/derive/index.js +27 -0
- package/cjs/utils/account/derive/info/index.js +27 -0
- package/cjs/utils/account/derive/info/solo.js +246 -0
- package/cjs/utils/account/derive/info/unified.js +112 -0
- package/cjs/utils/account/derive/validate.js +177 -0
- package/cjs/utils/account/index.js +49 -0
- package/cjs/utils/account/transform.js +566 -0
- package/cjs/utils/auth.js +46 -0
- package/cjs/utils/getId.js +8 -1
- package/cjs/utils/index.js +48 -62
- package/constants/environment.d.ts +1 -0
- package/constants/environment.js +6 -0
- package/constants/index.d.ts +5 -1
- package/constants/index.js +5 -2
- package/constants/signing.d.ts +4 -0
- package/constants/signing.js +15 -0
- package/constants/storage.d.ts +1 -0
- package/constants/storage.js +2 -1
- package/core/consts.d.ts +1 -0
- package/core/consts.js +13 -0
- package/core/logic-validation/recipientAddress.d.ts +2 -0
- package/core/logic-validation/recipientAddress.js +100 -0
- package/core/logic-validation/request.js +10 -18
- package/core/logic-validation/swap.js +1 -1
- package/core/logic-validation/transfer.d.ts +3 -2
- package/core/logic-validation/transfer.js +50 -10
- package/core/types.d.ts +26 -0
- package/core/types.js +19 -0
- package/core/utils.d.ts +10 -0
- package/core/utils.js +105 -0
- package/koni/api/dotsama/crowdloan.js +1 -1
- package/koni/api/nft/index.js +14 -5
- package/koni/api/staking/bonding/paraChain.js +2 -2
- package/koni/api/staking/bonding/relayChain.js +2 -2
- package/koni/api/staking/index.js +4 -1
- package/koni/background/cron.js +7 -7
- package/koni/background/handlers/Extension.d.ts +26 -35
- package/koni/background/handlers/Extension.js +337 -1242
- package/koni/background/handlers/State.d.ts +12 -19
- package/koni/background/handlers/State.js +57 -231
- package/koni/background/handlers/Tabs.d.ts +2 -3
- package/koni/background/handlers/Tabs.js +105 -61
- package/koni/background/subscription.js +5 -5
- package/package.json +352 -53
- package/packageInfo.js +1 -1
- package/page/Accounts.js +2 -5
- package/page/SubWalleEvmProvider.js +1 -1
- package/page/index.js +2 -1
- package/services/balance-service/BalanceMapImpl.d.ts +6 -4
- package/services/balance-service/BalanceMapImpl.js +44 -18
- package/services/balance-service/helpers/subscribe/index.d.ts +3 -4
- package/services/balance-service/helpers/subscribe/index.js +29 -14
- package/services/balance-service/helpers/subscribe/ton/consts.d.ts +18 -0
- package/services/balance-service/helpers/subscribe/ton/consts.js +28 -0
- package/services/balance-service/helpers/subscribe/ton/ton.d.ts +3 -0
- package/services/balance-service/helpers/subscribe/ton/ton.js +111 -0
- package/services/balance-service/helpers/subscribe/ton/types.d.ts +26 -0
- package/services/balance-service/helpers/subscribe/ton/utils.d.ts +32 -0
- package/services/balance-service/helpers/subscribe/ton/utils.js +159 -0
- package/services/balance-service/index.js +25 -13
- package/services/balance-service/transfer/token.d.ts +2 -2
- package/services/balance-service/transfer/token.js +18 -1
- package/services/balance-service/transfer/ton-transfer.d.ts +25 -0
- package/services/balance-service/transfer/ton-transfer.js +127 -0
- package/services/buy-service/index.js +5 -1
- package/services/buy-service/types.d.ts +2 -2
- package/services/chain-service/constants.js +1 -1
- package/services/chain-service/handler/TonApi.d.ts +52 -0
- package/services/chain-service/handler/TonApi.js +204 -0
- package/services/chain-service/handler/TonChainHandler.d.ts +17 -0
- package/services/chain-service/handler/TonChainHandler.js +73 -0
- package/services/chain-service/index.d.ts +5 -1
- package/services/chain-service/index.js +32 -8
- package/services/chain-service/types.d.ts +24 -0
- package/services/chain-service/utils/index.d.ts +10 -2
- package/services/chain-service/utils/index.js +59 -18
- package/services/earning-service/constants/chains.d.ts +1 -0
- package/services/earning-service/constants/chains.js +1 -0
- package/services/earning-service/handlers/base.js +3 -2
- package/services/earning-service/handlers/lending/base.js +1 -2
- package/services/earning-service/handlers/lending/interlay.js +2 -2
- package/services/earning-service/handlers/liquid-staking/base.js +1 -2
- package/services/earning-service/handlers/liquid-staking/stella-swap.js +2 -2
- package/services/earning-service/handlers/native-staking/amplitude.js +2 -2
- package/services/earning-service/handlers/native-staking/astar.js +2 -2
- package/services/earning-service/handlers/native-staking/base-para.js +2 -2
- package/services/earning-service/handlers/native-staking/base.js +2 -2
- package/services/earning-service/handlers/native-staking/para-chain.js +2 -2
- package/services/earning-service/handlers/native-staking/relay-chain.js +2 -2
- package/services/earning-service/handlers/nomination-pool/index.js +2 -2
- package/services/earning-service/handlers/special.js +2 -2
- package/services/earning-service/service.js +18 -9
- package/services/event-service/types.d.ts +3 -1
- package/services/history-service/helpers/subscan-extrinsic-parser-helper.js +1 -1
- package/services/history-service/index.d.ts +4 -1
- package/services/history-service/index.js +29 -11
- package/services/history-service/subscan-history.js +8 -20
- package/services/keyring-service/context/account-context.d.ts +87 -0
- package/services/keyring-service/context/account-context.js +250 -0
- package/services/keyring-service/context/handlers/Base.d.ts +11 -0
- package/services/keyring-service/context/handlers/Base.js +13 -0
- package/services/keyring-service/context/handlers/Derive.d.ts +29 -0
- package/services/keyring-service/context/handlers/Derive.js +365 -0
- package/services/keyring-service/context/handlers/Inject.d.ts +11 -0
- package/services/keyring-service/context/handlers/Inject.js +69 -0
- package/services/keyring-service/context/handlers/Json.d.ts +18 -0
- package/services/keyring-service/context/handlers/Json.js +328 -0
- package/services/keyring-service/context/handlers/Ledger.d.ts +11 -0
- package/services/keyring-service/context/handlers/Ledger.js +158 -0
- package/services/keyring-service/context/handlers/Mnemonic.d.ts +15 -0
- package/services/keyring-service/context/handlers/Mnemonic.js +206 -0
- package/services/keyring-service/context/handlers/Modify.d.ts +16 -0
- package/services/keyring-service/context/handlers/Modify.js +250 -0
- package/services/keyring-service/context/handlers/Secret.d.ts +16 -0
- package/services/keyring-service/context/handlers/Secret.js +299 -0
- package/services/keyring-service/context/handlers/index.d.ts +7 -0
- package/services/keyring-service/context/handlers/index.js +10 -0
- package/services/keyring-service/context/state.d.ts +92 -0
- package/services/keyring-service/context/state.js +629 -0
- package/services/keyring-service/context/stores/AccountProxy.d.ts +13 -0
- package/services/keyring-service/context/stores/AccountProxy.js +25 -0
- package/services/keyring-service/context/stores/Base.d.ts +22 -0
- package/services/keyring-service/context/stores/Base.js +30 -0
- package/services/keyring-service/context/stores/CurrentAccount.d.ts +15 -0
- package/services/keyring-service/context/stores/CurrentAccount.js +21 -0
- package/services/keyring-service/context/stores/ModifyPair.d.ts +10 -0
- package/services/keyring-service/context/stores/ModifyPair.js +12 -0
- package/services/keyring-service/context/stores/index.d.ts +3 -0
- package/services/keyring-service/context/stores/index.js +6 -0
- package/services/keyring-service/index.d.ts +10 -22
- package/services/keyring-service/index.js +20 -161
- package/services/migration-service/scripts/index.js +6 -4
- package/services/migration-service/scripts/{MigrateLedgerAccountV2.d.ts → keyring/MigrateLedgerAccountV2.d.ts} +1 -1
- package/services/migration-service/scripts/{MigrateLedgerAccountV2.js → keyring/MigrateLedgerAccountV2.js} +1 -1
- package/services/migration-service/scripts/keyring/MigratePairData.d.ts +4 -0
- package/services/migration-service/scripts/keyring/MigratePairData.js +20 -0
- package/services/migration-service/scripts/{MigrateRemoveGenesisHash.js → keyring/MigrateRemoveGenesisHash.js} +1 -1
- package/services/request-service/constants.d.ts +1 -1
- package/services/request-service/constants.js +2 -1
- package/services/request-service/handler/AuthRequestHandler.d.ts +1 -0
- package/services/request-service/handler/AuthRequestHandler.js +93 -45
- package/services/request-service/handler/EvmRequestHandler.js +3 -4
- package/services/request-service/handler/SubstrateRequestHandler.d.ts +2 -2
- package/services/request-service/handler/SubstrateRequestHandler.js +5 -11
- package/services/request-service/handler/TonRequestHandler.d.ts +17 -0
- package/services/request-service/handler/TonRequestHandler.js +168 -0
- package/services/request-service/index.d.ts +8 -3
- package/services/request-service/index.js +23 -5
- package/services/request-service/types.d.ts +6 -3
- package/services/swap-service/handler/asset-hub/handler.d.ts +1 -1
- package/services/swap-service/handler/asset-hub/handler.js +2 -1
- package/services/swap-service/handler/base-handler.js +1 -1
- package/services/swap-service/handler/chainflip-handler.d.ts +1 -1
- package/services/swap-service/handler/chainflip-handler.js +4 -3
- package/services/swap-service/handler/hydradx-handler.d.ts +1 -1
- package/services/swap-service/handler/hydradx-handler.js +2 -1
- package/services/swap-service/index.js +1 -1
- package/services/transaction-service/helpers/index.d.ts +2 -0
- package/services/transaction-service/helpers/index.js +4 -0
- package/services/transaction-service/index.d.ts +1 -0
- package/services/transaction-service/index.js +114 -17
- package/services/transaction-service/types.d.ts +4 -2
- package/services/wallet-connect-service/handler/PolkadotRequestHandler.js +2 -10
- package/stores/AccountProxyStore.d.ts +5 -0
- package/stores/AccountProxyStore.js +10 -0
- package/stores/Authorize.d.ts +1 -1
- package/stores/CurrentAccountStore.d.ts +1 -1
- package/stores/ModifyPairStore.d.ts +5 -0
- package/stores/ModifyPairStore.js +10 -0
- package/stores/index.d.ts +4 -1
- package/stores/index.js +5 -2
- package/types/account/action/add/index.d.ts +3 -0
- package/types/account/action/add/index.js +6 -0
- package/types/account/action/add/json.d.ts +29 -0
- package/types/account/action/add/json.js +1 -0
- package/types/account/action/add/mnemonic.d.ts +77 -0
- package/types/account/action/add/mnemonic.js +1 -0
- package/types/account/action/add/secret.d.ts +55 -0
- package/types/account/action/add/secret.js +1 -0
- package/types/account/action/derive.d.ts +77 -0
- package/types/account/action/derive.js +1 -0
- package/types/account/action/edit.d.ts +31 -0
- package/types/account/action/edit.js +1 -0
- package/types/account/action/export.d.ts +15 -0
- package/types/account/action/export.js +1 -0
- package/types/account/action/index.d.ts +6 -0
- package/types/account/action/index.js +9 -0
- package/types/account/action/subscribe.d.ts +22 -0
- package/types/account/action/subscribe.js +10 -0
- package/types/account/action/validate.d.ts +17 -0
- package/types/account/action/validate.js +1 -0
- package/types/account/error/common.d.ts +10 -0
- package/types/account/error/common.js +33 -0
- package/types/account/error/derive.d.ts +13 -0
- package/types/account/error/derive.js +48 -0
- package/types/account/error/index.d.ts +2 -0
- package/types/account/error/index.js +5 -0
- package/types/account/index.d.ts +3 -0
- package/types/account/index.js +6 -0
- package/types/account/info/current.d.ts +10 -0
- package/types/account/info/current.js +1 -0
- package/types/account/info/index.d.ts +3 -0
- package/types/account/info/index.js +6 -0
- package/types/account/info/keyring.d.ts +161 -0
- package/types/account/info/keyring.js +88 -0
- package/types/account/info/proxy.d.ts +73 -0
- package/types/account/info/proxy.js +46 -0
- package/types/balance/index.d.ts +4 -1
- package/types/buy.d.ts +3 -1
- package/types/error.d.ts +8 -0
- package/types/error.js +1 -0
- package/types/index.d.ts +4 -0
- package/types/index.js +5 -1
- package/types/transaction/data.d.ts +17 -0
- package/types/transaction/data.js +1 -0
- package/types/transaction/error.d.ts +39 -0
- package/types/transaction/error.js +44 -0
- package/types/transaction/index.d.ts +4 -0
- package/types/transaction/index.js +7 -0
- package/types/transaction/request.d.ts +24 -0
- package/types/transaction/request.js +1 -0
- package/types/transaction/warning.d.ts +5 -0
- package/types/transaction/warning.js +8 -0
- package/types/yield/actions/join/submit.d.ts +2 -2
- package/types/yield/actions/join/validate.d.ts +1 -6
- package/types/yield/actions/join/validate.js +1 -10
- package/types/yield/actions/others.d.ts +1 -1
- package/utils/account/analyze.d.ts +4 -0
- package/utils/account/analyze.js +159 -0
- package/utils/account/common.d.ts +16 -0
- package/utils/account/common.js +104 -0
- package/utils/account/derive/index.d.ts +2 -0
- package/utils/account/derive/index.js +5 -0
- package/utils/account/derive/info/index.d.ts +2 -0
- package/utils/account/derive/info/index.js +5 -0
- package/utils/account/derive/info/solo.d.ts +11 -0
- package/utils/account/derive/info/solo.js +230 -0
- package/utils/account/derive/info/unified.d.ts +7 -0
- package/utils/account/derive/info/unified.js +102 -0
- package/utils/account/derive/validate.d.ts +8 -0
- package/utils/account/derive/validate.js +165 -0
- package/utils/account/index.d.ts +4 -0
- package/utils/account/index.js +7 -0
- package/utils/account/transform.d.ts +41 -0
- package/utils/account/transform.js +533 -0
- package/utils/auth.d.ts +2 -0
- package/utils/auth.js +39 -0
- package/utils/canDerive.d.ts +1 -1
- package/utils/eth/mergeTransactionAndSignature.d.ts +1 -1
- package/utils/getId.d.ts +1 -0
- package/utils/getId.js +3 -1
- package/utils/index.d.ts +12 -5
- package/utils/index.js +28 -47
- package/cjs/signers/substrates/KeyringSigner.js +0 -35
- package/cjs/signers/substrates/LedgerSigner.js +0 -44
- package/cjs/signers/substrates/QrSigner.js +0 -63
- package/cjs/signers/types.js +0 -15
- package/cjs/signers/web3/QrSigner.js +0 -67
- package/cjs/utils/account.js +0 -34
- package/signers/substrates/KeyringSigner.d.ts +0 -13
- package/signers/substrates/KeyringSigner.js +0 -27
- package/signers/substrates/LedgerSigner.d.ts +0 -13
- package/signers/substrates/LedgerSigner.js +0 -37
- package/signers/substrates/QrSigner.d.ts +0 -20
- package/signers/substrates/QrSigner.js +0 -55
- package/signers/types.d.ts +0 -34
- package/signers/types.js +0 -9
- package/signers/web3/QrSigner.d.ts +0 -18
- package/signers/web3/QrSigner.js +0 -59
- package/types/transaction.d.ts +0 -3
- package/utils/account.d.ts +0 -5
- package/utils/account.js +0 -24
- /package/cjs/{types/transaction.js → services/balance-service/helpers/subscribe/ton/types.js} +0 -0
- /package/cjs/services/migration-service/scripts/{MigrateLedgerAccount.js → keyring/MigrateLedgerAccount.js} +0 -0
- /package/{types/transaction.js → services/balance-service/helpers/subscribe/ton/types.js} +0 -0
- /package/services/migration-service/scripts/{MigrateLedgerAccount.d.ts → keyring/MigrateLedgerAccount.d.ts} +0 -0
- /package/services/migration-service/scripts/{MigrateLedgerAccount.js → keyring/MigrateLedgerAccount.js} +0 -0
- /package/services/migration-service/scripts/{MigrateRemoveGenesisHash.d.ts → keyring/MigrateRemoveGenesisHash.d.ts} +0 -0
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SEED_LENGTHS = exports.SEED_DEFAULT_LENGTH = exports.AccountMnemonicHandler = void 0;
|
|
7
|
+
var _types = require("@subwallet/extension-base/types");
|
|
8
|
+
var _utils = require("@subwallet/extension-base/utils");
|
|
9
|
+
var _keyring = require("@subwallet/keyring");
|
|
10
|
+
var _utils2 = require("@subwallet/keyring/utils");
|
|
11
|
+
var _uiKeyring = require("@subwallet/ui-keyring");
|
|
12
|
+
var _i18next = require("i18next");
|
|
13
|
+
var _util = require("@polkadot/util");
|
|
14
|
+
var _utilCrypto = require("@polkadot/util-crypto");
|
|
15
|
+
var _Base = require("./Base");
|
|
16
|
+
// Copyright 2019-2022 @subwallet/extension-base
|
|
17
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
18
|
+
|
|
19
|
+
const SEED_DEFAULT_LENGTH = 12;
|
|
20
|
+
exports.SEED_DEFAULT_LENGTH = SEED_DEFAULT_LENGTH;
|
|
21
|
+
const SEED_LENGTHS = [12, 15, 18, 21, 24];
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @class AccountMnemonicHandler
|
|
25
|
+
* @extends AccountBaseHandler
|
|
26
|
+
* @description Handler for account's mnemonic
|
|
27
|
+
* */
|
|
28
|
+
exports.SEED_LENGTHS = SEED_LENGTHS;
|
|
29
|
+
class AccountMnemonicHandler extends _Base.AccountBaseHandler {
|
|
30
|
+
/* Create with mnemonic */
|
|
31
|
+
|
|
32
|
+
/* Create seed */
|
|
33
|
+
async mnemonicCreateV2(_ref) {
|
|
34
|
+
let {
|
|
35
|
+
length = SEED_DEFAULT_LENGTH,
|
|
36
|
+
mnemonic: _seed,
|
|
37
|
+
type = 'general'
|
|
38
|
+
} = _ref;
|
|
39
|
+
const types = type === 'general' ? ['sr25519', 'ethereum', 'ton'] : ['ton-native'];
|
|
40
|
+
const seed = _seed || type === 'general' ? (0, _utilCrypto.mnemonicGenerate)(length) : await (0, _keyring.tonMnemonicGenerate)(length);
|
|
41
|
+
const rs = {
|
|
42
|
+
mnemonic: seed,
|
|
43
|
+
addressMap: {}
|
|
44
|
+
};
|
|
45
|
+
types === null || types === void 0 ? void 0 : types.forEach(type => {
|
|
46
|
+
rs.addressMap[type] = _uiKeyring.keyring.createFromUri((0, _utils.getSuri)(seed, type), {}, type).address;
|
|
47
|
+
});
|
|
48
|
+
return rs;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/* Validate seed */
|
|
52
|
+
mnemonicValidateV2(_ref2) {
|
|
53
|
+
let {
|
|
54
|
+
mnemonic
|
|
55
|
+
} = _ref2;
|
|
56
|
+
const {
|
|
57
|
+
phrase
|
|
58
|
+
} = (0, _utilCrypto.keyExtractSuri)(mnemonic);
|
|
59
|
+
let mnemonicTypes = 'general';
|
|
60
|
+
let pairTypes = [];
|
|
61
|
+
if ((0, _util.isHex)(phrase)) {
|
|
62
|
+
(0, _util.assert)((0, _util.isHex)(phrase, 256), (0, _i18next.t)('Invalid seed phrase. Please try again.'));
|
|
63
|
+
} else {
|
|
64
|
+
// sadly isHex detects as string, so we need a cast here
|
|
65
|
+
(0, _util.assert)(SEED_LENGTHS.includes(phrase.split(' ').length), (0, _i18next.t)('Seed phrase needs to contain {{x}} words', {
|
|
66
|
+
replace: {
|
|
67
|
+
x: SEED_LENGTHS.join(', ')
|
|
68
|
+
}
|
|
69
|
+
}));
|
|
70
|
+
try {
|
|
71
|
+
(0, _util.assert)((0, _utilCrypto.mnemonicValidate)(phrase), (0, _i18next.t)('Invalid seed phrase. Please try again.'));
|
|
72
|
+
mnemonicTypes = 'general';
|
|
73
|
+
pairTypes = ['sr25519', 'ethereum', 'ton'];
|
|
74
|
+
} catch (e) {
|
|
75
|
+
(0, _util.assert)((0, _utils2.tonMnemonicValidate)(phrase), (0, _i18next.t)('Invalid seed phrase. Please try again.'));
|
|
76
|
+
mnemonicTypes = 'ton';
|
|
77
|
+
pairTypes = ['ton-native'];
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const rs = {
|
|
81
|
+
mnemonic,
|
|
82
|
+
addressMap: {},
|
|
83
|
+
mnemonicTypes,
|
|
84
|
+
pairTypes
|
|
85
|
+
};
|
|
86
|
+
pairTypes.forEach(type => {
|
|
87
|
+
rs.addressMap[type] = _uiKeyring.keyring.createFromUri((0, _utils.getSuri)(mnemonic, type), {}, type).address;
|
|
88
|
+
});
|
|
89
|
+
const exists = this.state.checkAddressExists(Object.values(rs.addressMap));
|
|
90
|
+
(0, _util.assert)(!exists, (0, _i18next.t)('Account already exists under the name {{name}}', {
|
|
91
|
+
replace: {
|
|
92
|
+
name: (exists === null || exists === void 0 ? void 0 : exists.name) || (exists === null || exists === void 0 ? void 0 : exists.address) || ''
|
|
93
|
+
}
|
|
94
|
+
}));
|
|
95
|
+
return rs;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/* Add accounts from mnemonic */
|
|
99
|
+
accountsCreateSuriV2(request) {
|
|
100
|
+
const {
|
|
101
|
+
isAllowed,
|
|
102
|
+
name,
|
|
103
|
+
password,
|
|
104
|
+
suri: _suri,
|
|
105
|
+
type
|
|
106
|
+
} = request;
|
|
107
|
+
const addressDict = {};
|
|
108
|
+
let changedAccount = false;
|
|
109
|
+
const hasMasterPassword = _uiKeyring.keyring.keyring.hasMasterPassword;
|
|
110
|
+
const types = type ? [type] : ['sr25519', 'ethereum', 'ton'];
|
|
111
|
+
if (!hasMasterPassword) {
|
|
112
|
+
if (!password) {
|
|
113
|
+
throw Error((0, _i18next.t)('The password of each account is needed to set up master password'));
|
|
114
|
+
} else {
|
|
115
|
+
_uiKeyring.keyring.changeMasterPassword(password);
|
|
116
|
+
this.parentService.updateKeyringState();
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (!types || !types.length) {
|
|
120
|
+
throw Error((0, _i18next.t)('Please choose at least one account type'));
|
|
121
|
+
}
|
|
122
|
+
const nameExists = this.state.checkNameExists(name);
|
|
123
|
+
if (nameExists) {
|
|
124
|
+
throw new _types.SWCommonAccountError(_types.CommonAccountErrorType.ACCOUNT_NAME_EXISTED);
|
|
125
|
+
}
|
|
126
|
+
const multiChain = types.length > 1;
|
|
127
|
+
const proxyId = multiChain ? (0, _utils.createAccountProxyId)(_suri) : '';
|
|
128
|
+
const modifiedPairs = this.state.modifyPairs;
|
|
129
|
+
types.forEach(type => {
|
|
130
|
+
const suri = (0, _utils.getSuri)(_suri, type);
|
|
131
|
+
const pair = _uiKeyring.keyring.createFromUri(suri, {}, type);
|
|
132
|
+
const address = pair.address;
|
|
133
|
+
modifiedPairs[address] = {
|
|
134
|
+
accountProxyId: proxyId,
|
|
135
|
+
migrated: true,
|
|
136
|
+
key: address
|
|
137
|
+
};
|
|
138
|
+
addressDict[type] = address;
|
|
139
|
+
});
|
|
140
|
+
const exists = this.state.checkAddressExists(Object.values(addressDict));
|
|
141
|
+
(0, _util.assert)(!exists, (0, _i18next.t)('Account already exists under the name {{name}}', {
|
|
142
|
+
replace: {
|
|
143
|
+
name: (exists === null || exists === void 0 ? void 0 : exists.name) || (exists === null || exists === void 0 ? void 0 : exists.address) || ''
|
|
144
|
+
}
|
|
145
|
+
}));
|
|
146
|
+
|
|
147
|
+
// Upsert account group first, to avoid combine latest have no account group data.
|
|
148
|
+
if (proxyId) {
|
|
149
|
+
this.state.upsertAccountProxyByKey({
|
|
150
|
+
id: proxyId,
|
|
151
|
+
name
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// Upsert modify pair before add account to keyring
|
|
156
|
+
this.state.upsertModifyPairs(modifiedPairs);
|
|
157
|
+
types.forEach(type => {
|
|
158
|
+
const suri = (0, _utils.getSuri)(_suri, type);
|
|
159
|
+
const {
|
|
160
|
+
derivePath
|
|
161
|
+
} = (0, _utilCrypto.keyExtractSuri)(suri);
|
|
162
|
+
const metadata = {
|
|
163
|
+
name,
|
|
164
|
+
derivationPath: derivePath ? derivePath.substring(1) : undefined
|
|
165
|
+
};
|
|
166
|
+
const rs = _uiKeyring.keyring.addUri(suri, metadata, type);
|
|
167
|
+
const address = rs.pair.address;
|
|
168
|
+
this.state._addAddressToAuthList(address, isAllowed);
|
|
169
|
+
if (!changedAccount) {
|
|
170
|
+
if (!proxyId) {
|
|
171
|
+
this.state.saveCurrentAccountProxyId(address);
|
|
172
|
+
} else {
|
|
173
|
+
this.state.saveCurrentAccountProxyId(proxyId);
|
|
174
|
+
}
|
|
175
|
+
changedAccount = true;
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
return addressDict;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/* Create with mnemonic */
|
|
182
|
+
|
|
183
|
+
/* Export mnemonic */
|
|
184
|
+
|
|
185
|
+
exportAccountProxyMnemonic(_ref3) {
|
|
186
|
+
let {
|
|
187
|
+
password,
|
|
188
|
+
proxyId
|
|
189
|
+
} = _ref3;
|
|
190
|
+
const isUnified = this.state.isUnifiedAccount(proxyId);
|
|
191
|
+
if (!isUnified) {
|
|
192
|
+
const pair = _uiKeyring.keyring.getPair(proxyId);
|
|
193
|
+
(0, _util.assert)(pair, (0, _i18next.t)('Unable to find account'));
|
|
194
|
+
const result = pair.exportMnemonic(password);
|
|
195
|
+
return {
|
|
196
|
+
result
|
|
197
|
+
};
|
|
198
|
+
} else {
|
|
199
|
+
const modifyPairs = this.state.modifyPairs;
|
|
200
|
+
const addresses = Object.keys(modifyPairs).filter(address => modifyPairs[address].accountProxyId === proxyId);
|
|
201
|
+
let pair;
|
|
202
|
+
for (const address of addresses) {
|
|
203
|
+
pair = _uiKeyring.keyring.getPair(address);
|
|
204
|
+
if (pair && pair.haveEntropy) {
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
(0, _util.assert)(pair, (0, _i18next.t)('Unable to find account'));
|
|
209
|
+
const result = pair.exportMnemonic(password) || '';
|
|
210
|
+
return {
|
|
211
|
+
result
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/* Export mnemonic */
|
|
217
|
+
}
|
|
218
|
+
exports.AccountMnemonicHandler = AccountMnemonicHandler;
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.AccountModifyHandler = void 0;
|
|
7
|
+
var _constants = require("@subwallet/extension-base/constants");
|
|
8
|
+
var _types = require("@subwallet/extension-base/types");
|
|
9
|
+
var _types2 = require("@subwallet/keyring/types");
|
|
10
|
+
var _uiKeyring = require("@subwallet/ui-keyring");
|
|
11
|
+
var _i18next = require("i18next");
|
|
12
|
+
var _util = require("@polkadot/util");
|
|
13
|
+
var _Base = require("./Base");
|
|
14
|
+
// Copyright 2019-2022 @subwallet/extension-base
|
|
15
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @class AccountModifyHandler
|
|
19
|
+
* @extends AccountBaseHandler
|
|
20
|
+
* @description Handler for modify account actions (change master password, migrate master password, edit account, forget account, ...)
|
|
21
|
+
* */
|
|
22
|
+
class AccountModifyHandler extends _Base.AccountBaseHandler {
|
|
23
|
+
keyringChangeMasterPassword(request, callback) {
|
|
24
|
+
const {
|
|
25
|
+
createNew,
|
|
26
|
+
newPassword,
|
|
27
|
+
oldPassword
|
|
28
|
+
} = request;
|
|
29
|
+
try {
|
|
30
|
+
// Remove isMasterPassword meta if createNew
|
|
31
|
+
if (createNew && !_uiKeyring.keyring.keyring.hasMasterPassword) {
|
|
32
|
+
const pairs = _uiKeyring.keyring.getPairs();
|
|
33
|
+
for (const pair of pairs) {
|
|
34
|
+
if (pair.meta.isInjected) {
|
|
35
|
+
// Empty
|
|
36
|
+
} else {
|
|
37
|
+
const meta = {
|
|
38
|
+
...pair.meta,
|
|
39
|
+
isMasterPassword: false
|
|
40
|
+
};
|
|
41
|
+
if (!meta.originGenesisHash) {
|
|
42
|
+
meta.genesisHash = '';
|
|
43
|
+
}
|
|
44
|
+
pair.setMeta(meta);
|
|
45
|
+
_uiKeyring.keyring.saveAccountMeta(pair, pair.meta);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
_uiKeyring.keyring.changeMasterPassword(newPassword, oldPassword);
|
|
50
|
+
} catch (e) {
|
|
51
|
+
console.error(e);
|
|
52
|
+
return {
|
|
53
|
+
errors: [(0, _i18next.t)(e.message)],
|
|
54
|
+
status: false
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
this.parentService.updateKeyringState();
|
|
58
|
+
callback();
|
|
59
|
+
return {
|
|
60
|
+
status: true,
|
|
61
|
+
errors: []
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
keyringMigrateMasterPassword(request, callback) {
|
|
65
|
+
const {
|
|
66
|
+
address,
|
|
67
|
+
password
|
|
68
|
+
} = request;
|
|
69
|
+
try {
|
|
70
|
+
_uiKeyring.keyring.migrateWithMasterPassword(address, password);
|
|
71
|
+
callback();
|
|
72
|
+
} catch (e) {
|
|
73
|
+
console.error(e);
|
|
74
|
+
return {
|
|
75
|
+
errors: [e.message],
|
|
76
|
+
status: false
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
status: true,
|
|
81
|
+
errors: []
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
accountsEdit(_ref) {
|
|
85
|
+
let {
|
|
86
|
+
name,
|
|
87
|
+
proxyId
|
|
88
|
+
} = _ref;
|
|
89
|
+
const accountProxies = this.state.accountProxies;
|
|
90
|
+
const modifyPairs = this.state.modifyPairs;
|
|
91
|
+
const nameExists = this.state.checkNameExists(name, proxyId);
|
|
92
|
+
if (nameExists) {
|
|
93
|
+
throw new _types.SWCommonAccountError(_types.CommonAccountErrorType.ACCOUNT_NAME_EXISTED);
|
|
94
|
+
}
|
|
95
|
+
if (!accountProxies[proxyId]) {
|
|
96
|
+
const pair = _uiKeyring.keyring.getPair(proxyId);
|
|
97
|
+
(0, _util.assert)(pair, (0, _i18next.t)('Unable to find account'));
|
|
98
|
+
_uiKeyring.keyring.saveAccountMeta(pair, {
|
|
99
|
+
...pair.meta,
|
|
100
|
+
name
|
|
101
|
+
});
|
|
102
|
+
} else {
|
|
103
|
+
const accountProxy = accountProxies[proxyId];
|
|
104
|
+
const addresses = Object.keys(modifyPairs).filter(address => modifyPairs[address].accountProxyId === proxyId);
|
|
105
|
+
accountProxy.name = name;
|
|
106
|
+
this.state.upsertAccountProxyByKey(accountProxy);
|
|
107
|
+
for (const address of addresses) {
|
|
108
|
+
const pair = _uiKeyring.keyring.getPair(address);
|
|
109
|
+
(0, _util.assert)(pair, (0, _i18next.t)('Unable to find account'));
|
|
110
|
+
_uiKeyring.keyring.saveAccountMeta(pair, {
|
|
111
|
+
...pair.meta,
|
|
112
|
+
name
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
async accountProxyForget(_ref2) {
|
|
119
|
+
let {
|
|
120
|
+
proxyId
|
|
121
|
+
} = _ref2;
|
|
122
|
+
const modifyPairs = this.state.modifyPairs;
|
|
123
|
+
const isUnified = this.state.isUnifiedAccount(proxyId);
|
|
124
|
+
let addresses;
|
|
125
|
+
if (!isUnified) {
|
|
126
|
+
addresses = [proxyId];
|
|
127
|
+
} else {
|
|
128
|
+
addresses = Object.keys(modifyPairs).filter(address => modifyPairs[address].accountProxyId === proxyId);
|
|
129
|
+
this.state.deleteAccountProxy(proxyId);
|
|
130
|
+
this.parentService.eventRemoveAccount(proxyId);
|
|
131
|
+
}
|
|
132
|
+
for (const address of addresses) {
|
|
133
|
+
delete modifyPairs[address];
|
|
134
|
+
}
|
|
135
|
+
this.state.upsertModifyPairs(modifyPairs);
|
|
136
|
+
for (const address of addresses) {
|
|
137
|
+
_uiKeyring.keyring.forgetAccount(address);
|
|
138
|
+
}
|
|
139
|
+
await Promise.all(addresses.map(address => new Promise(resolve => this.state.removeAccountRef(address, resolve))));
|
|
140
|
+
this.state.saveCurrentAccountProxyId(_constants.ALL_ACCOUNT_KEY);
|
|
141
|
+
return addresses;
|
|
142
|
+
}
|
|
143
|
+
tonGetAllTonWalletContractVersion(request) {
|
|
144
|
+
const {
|
|
145
|
+
address,
|
|
146
|
+
isTestnet
|
|
147
|
+
} = request;
|
|
148
|
+
const pair = _uiKeyring.keyring.getPair(address);
|
|
149
|
+
if (!pair) {
|
|
150
|
+
throw new Error('Account not found');
|
|
151
|
+
}
|
|
152
|
+
const contractVersion = pair.meta.tonContractVersion;
|
|
153
|
+
const getContractAddress = version => {
|
|
154
|
+
return pair.ton.contractWithVersion(version).address.toString({
|
|
155
|
+
bounceable: false,
|
|
156
|
+
testOnly: isTestnet
|
|
157
|
+
});
|
|
158
|
+
};
|
|
159
|
+
const addressMap = {
|
|
160
|
+
v3r1: getContractAddress('v3r1'),
|
|
161
|
+
v3r2: getContractAddress('v3r2'),
|
|
162
|
+
v4: getContractAddress('v4'),
|
|
163
|
+
v5r1: getContractAddress('v5r1')
|
|
164
|
+
};
|
|
165
|
+
return {
|
|
166
|
+
address: pair.address,
|
|
167
|
+
currentVersion: contractVersion,
|
|
168
|
+
addressMap: addressMap
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
tonAccountChangeWalletContractVersion(request) {
|
|
172
|
+
const {
|
|
173
|
+
address,
|
|
174
|
+
proxyId,
|
|
175
|
+
version
|
|
176
|
+
} = request;
|
|
177
|
+
const accounts = this.state.accounts;
|
|
178
|
+
let modifyAddress = '';
|
|
179
|
+
const findAddressByProxyId = () => {
|
|
180
|
+
const accountProxy = accounts[proxyId];
|
|
181
|
+
if (!accountProxy) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
const tonAccount = accountProxy.accounts.find(account => account.chainType === _types.AccountChainType.TON);
|
|
185
|
+
if (tonAccount) {
|
|
186
|
+
modifyAddress = tonAccount.address;
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
if (address) {
|
|
190
|
+
try {
|
|
191
|
+
_uiKeyring.keyring.getPair(address);
|
|
192
|
+
modifyAddress = address;
|
|
193
|
+
} catch (e) {
|
|
194
|
+
findAddressByProxyId();
|
|
195
|
+
}
|
|
196
|
+
} else {
|
|
197
|
+
findAddressByProxyId();
|
|
198
|
+
}
|
|
199
|
+
if (!modifyAddress) {
|
|
200
|
+
throw new Error('Account not found');
|
|
201
|
+
}
|
|
202
|
+
const pair = _uiKeyring.keyring.getPair(modifyAddress);
|
|
203
|
+
if (!pair) {
|
|
204
|
+
throw new Error('Account not found');
|
|
205
|
+
}
|
|
206
|
+
if (!_types2.TonKeypairTypes.includes(pair.type)) {
|
|
207
|
+
throw new Error('Invalid account type');
|
|
208
|
+
}
|
|
209
|
+
const oldVerion = pair.ton.contractVersion;
|
|
210
|
+
const oldAddress = pair.address;
|
|
211
|
+
if (oldVerion === version) {
|
|
212
|
+
return oldAddress;
|
|
213
|
+
}
|
|
214
|
+
const modifiedPairs = this.state.modifyPairs;
|
|
215
|
+
const modifiedPair = modifiedPairs[oldAddress];
|
|
216
|
+
const accountProxies = this.state.accountProxies;
|
|
217
|
+
const accountProxy = accountProxies[oldAddress];
|
|
218
|
+
_uiKeyring.keyring.changeTonWalletContractVersion(modifyAddress, version);
|
|
219
|
+
const newAddress = pair.address;
|
|
220
|
+
|
|
221
|
+
// Migrate modified pair
|
|
222
|
+
if (modifiedPair) {
|
|
223
|
+
delete modifiedPairs[oldAddress];
|
|
224
|
+
if (modifiedPair.accountProxyId === oldAddress) {
|
|
225
|
+
modifiedPair.accountProxyId = newAddress;
|
|
226
|
+
}
|
|
227
|
+
modifiedPair.key = newAddress;
|
|
228
|
+
modifiedPairs[newAddress] = modifiedPair;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// Migrate account proxy
|
|
232
|
+
if (accountProxy) {
|
|
233
|
+
delete accountProxies[oldAddress];
|
|
234
|
+
accountProxy.id = newAddress;
|
|
235
|
+
accountProxies[newAddress] = accountProxy;
|
|
236
|
+
}
|
|
237
|
+
const pairs = _uiKeyring.keyring.getPairs();
|
|
238
|
+
const childPairs = pairs.filter(pair => pair.meta.parentAddress === oldAddress);
|
|
239
|
+
for (const childPair of childPairs) {
|
|
240
|
+
(0, _util.assert)(pair, (0, _i18next.t)('Unable to find account'));
|
|
241
|
+
_uiKeyring.keyring.saveAccountMeta(childPair, {
|
|
242
|
+
...childPair.meta,
|
|
243
|
+
parentAddress: newAddress
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// In case the current account is a single account, and is the account being modified, update the current proxy id
|
|
248
|
+
const currentProxy = this.state.currentAccount.proxyId;
|
|
249
|
+
if (currentProxy === oldAddress) {
|
|
250
|
+
this.state.saveCurrentAccountProxyId(newAddress);
|
|
251
|
+
}
|
|
252
|
+
this.state.upsertModifyPairs(modifiedPairs);
|
|
253
|
+
this.state.upsertAccountProxy(accountProxies);
|
|
254
|
+
this.state.changeAddressAllowedAuthList(oldAddress, newAddress);
|
|
255
|
+
return newAddress;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
exports.AccountModifyHandler = AccountModifyHandler;
|