@subwallet/extension-base 1.2.31-0 → 1.2.33-0
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 -15
- 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/SubstrateApi.js +1 -0
- 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 -17
- 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/SubstrateApi.js +1 -0
- 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/mkt-campaign-service/types.d.ts +4 -0
- 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,348 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.AccountJsonHandler = void 0;
|
|
7
|
+
var _constants = require("@subwallet/extension-base/constants");
|
|
8
|
+
var _utils = require("@subwallet/extension-base/utils");
|
|
9
|
+
var _getId = require("@subwallet/extension-base/utils/getId");
|
|
10
|
+
var _keyring = require("@subwallet/keyring");
|
|
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
|
+
/**
|
|
20
|
+
* @class AccountJsonHandler
|
|
21
|
+
* @extends AccountBaseHandler
|
|
22
|
+
* @description Handler for account's JSON
|
|
23
|
+
* */
|
|
24
|
+
class AccountJsonHandler extends _Base.AccountBaseHandler {
|
|
25
|
+
decodeAddress = (key, ignoreChecksum, ss58Format) => {
|
|
26
|
+
return _uiKeyring.keyring.decodeAddress(key, ignoreChecksum, ss58Format);
|
|
27
|
+
};
|
|
28
|
+
encodeAddress = (key, ss58Format) => {
|
|
29
|
+
return _uiKeyring.keyring.encodeAddress(key, ss58Format);
|
|
30
|
+
};
|
|
31
|
+
validatePassword(json, password) {
|
|
32
|
+
const cryptoType = Array.isArray(json.encoding.content) ? json.encoding.content[1] : 'ed25519';
|
|
33
|
+
const encType = Array.isArray(json.encoding.type) ? json.encoding.type : [json.encoding.type];
|
|
34
|
+
const pair = (0, _keyring.createPair)({
|
|
35
|
+
toSS58: this.encodeAddress,
|
|
36
|
+
type: cryptoType
|
|
37
|
+
}, {
|
|
38
|
+
publicKey: this.decodeAddress(json.address, true)
|
|
39
|
+
}, json.meta, (0, _util.isHex)(json.encoded) ? (0, _util.hexToU8a)(json.encoded) : (0, _utilCrypto.base64Decode)(json.encoded), encType);
|
|
40
|
+
|
|
41
|
+
// unlock then lock (locking cleans secretKey, so needs to be last)
|
|
42
|
+
try {
|
|
43
|
+
pair.decodePkcs8(password);
|
|
44
|
+
pair.lock();
|
|
45
|
+
return true;
|
|
46
|
+
} catch (e) {
|
|
47
|
+
console.error(e);
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
parseInfoSingleJson(_ref) {
|
|
52
|
+
let {
|
|
53
|
+
json,
|
|
54
|
+
password
|
|
55
|
+
} = _ref;
|
|
56
|
+
const isPasswordValidated = this.validatePassword(json, password);
|
|
57
|
+
if (isPasswordValidated) {
|
|
58
|
+
try {
|
|
59
|
+
const {
|
|
60
|
+
address,
|
|
61
|
+
meta,
|
|
62
|
+
type
|
|
63
|
+
} = _uiKeyring.keyring.createFromJson(json);
|
|
64
|
+
const {
|
|
65
|
+
name
|
|
66
|
+
} = meta;
|
|
67
|
+
const account = (0, _utils.transformAccount)(address, type, meta);
|
|
68
|
+
const accountExists = this.state.checkAddressExists([address]);
|
|
69
|
+
const nameExists = this.state.checkNameExists(name);
|
|
70
|
+
// Note: Show accountName of account exists to support user to know which account is existed
|
|
71
|
+
const accountName = accountExists ? accountExists.name : account.name || account.address;
|
|
72
|
+
const proxy = {
|
|
73
|
+
id: address,
|
|
74
|
+
accountType: (0, _utils.convertAccountProxyType)(account.signMode),
|
|
75
|
+
name: accountName,
|
|
76
|
+
accounts: [account],
|
|
77
|
+
chainTypes: [account.chainType],
|
|
78
|
+
parentId: account.parentAddress,
|
|
79
|
+
suri: account.suri,
|
|
80
|
+
tokenTypes: account.tokenTypes,
|
|
81
|
+
accountActions: [],
|
|
82
|
+
isExistAccount: !!accountExists,
|
|
83
|
+
isExistName: nameExists
|
|
84
|
+
};
|
|
85
|
+
return {
|
|
86
|
+
accountProxy: proxy
|
|
87
|
+
};
|
|
88
|
+
} catch (e) {
|
|
89
|
+
console.error(e);
|
|
90
|
+
throw new Error(e.message);
|
|
91
|
+
}
|
|
92
|
+
} else {
|
|
93
|
+
throw new Error((0, _i18next.t)('Incorrect password'));
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
jsonRestoreV2(_ref2, onDone) {
|
|
97
|
+
let {
|
|
98
|
+
address,
|
|
99
|
+
file,
|
|
100
|
+
isAllowed,
|
|
101
|
+
password,
|
|
102
|
+
withMasterPassword
|
|
103
|
+
} = _ref2;
|
|
104
|
+
const isPasswordValidated = this.validatePassword(file, password);
|
|
105
|
+
const {
|
|
106
|
+
promise,
|
|
107
|
+
reject,
|
|
108
|
+
resolve
|
|
109
|
+
} = (0, _utils.createPromiseHandler)();
|
|
110
|
+
if (isPasswordValidated) {
|
|
111
|
+
try {
|
|
112
|
+
const _pair = _uiKeyring.keyring.createFromJson(file);
|
|
113
|
+
const exists = this.state.checkAddressExists([_pair.address]);
|
|
114
|
+
(0, _util.assert)(!exists, (0, _i18next.t)('Account already exists under the name {{name}}', {
|
|
115
|
+
replace: {
|
|
116
|
+
name: (exists === null || exists === void 0 ? void 0 : exists.name) || (exists === null || exists === void 0 ? void 0 : exists.address) || _pair.address
|
|
117
|
+
}
|
|
118
|
+
}));
|
|
119
|
+
_uiKeyring.keyring.restoreAccount(file, password, withMasterPassword);
|
|
120
|
+
const pair = _uiKeyring.keyring.getPair(_pair.address);
|
|
121
|
+
const _name = pair.meta.name || '';
|
|
122
|
+
const nameExists = this.state.checkNameExists(_name);
|
|
123
|
+
if (nameExists) {
|
|
124
|
+
const newName = _name.concat(' - ').concat((0, _getId.generateRandomString)());
|
|
125
|
+
_uiKeyring.keyring.saveAccountMeta(pair, {
|
|
126
|
+
...pair.meta,
|
|
127
|
+
name: newName
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
this.state.saveCurrentAccountProxyId(address, () => {
|
|
131
|
+
this.state.updateMetadataForPair();
|
|
132
|
+
this.state._addAddressToAuthList(address, isAllowed);
|
|
133
|
+
resolve([address]);
|
|
134
|
+
onDone();
|
|
135
|
+
});
|
|
136
|
+
} catch (error) {
|
|
137
|
+
reject(error);
|
|
138
|
+
}
|
|
139
|
+
} else {
|
|
140
|
+
reject(new Error((0, _i18next.t)('Incorrect password')));
|
|
141
|
+
}
|
|
142
|
+
return promise;
|
|
143
|
+
}
|
|
144
|
+
validatedAccountsPassword(json, password) {
|
|
145
|
+
try {
|
|
146
|
+
const decoded = (0, _util.u8aToString)((0, _utilCrypto.jsonDecrypt)(json, password));
|
|
147
|
+
return JSON.parse(decoded);
|
|
148
|
+
} catch (e) {
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
parseInfoMultiJson(_ref3) {
|
|
153
|
+
let {
|
|
154
|
+
json,
|
|
155
|
+
password
|
|
156
|
+
} = _ref3;
|
|
157
|
+
const jsons = this.validatedAccountsPassword(json, password);
|
|
158
|
+
if (jsons) {
|
|
159
|
+
try {
|
|
160
|
+
const {
|
|
161
|
+
accountProxies,
|
|
162
|
+
modifyPairs
|
|
163
|
+
} = json;
|
|
164
|
+
const pairs = jsons.map(pair => _uiKeyring.keyring.createFromJson(pair));
|
|
165
|
+
const accountProxyMap = (0, _utils.combineAccountsWithKeyPair)(pairs, modifyPairs, accountProxies);
|
|
166
|
+
const result = Object.values(accountProxyMap).map(proxy => {
|
|
167
|
+
const rs = {
|
|
168
|
+
...proxy,
|
|
169
|
+
isExistAccount: false,
|
|
170
|
+
isExistName: false
|
|
171
|
+
};
|
|
172
|
+
const accountExists = this.state.checkAddressExists(proxy.accounts.map(account => account.address));
|
|
173
|
+
const nameExists = this.state.checkNameExists(proxy.name);
|
|
174
|
+
rs.isExistAccount = !!accountExists;
|
|
175
|
+
rs.isExistName = nameExists;
|
|
176
|
+
rs.name = accountExists ? accountExists.name : proxy.name;
|
|
177
|
+
return rs;
|
|
178
|
+
});
|
|
179
|
+
return {
|
|
180
|
+
accountProxies: result
|
|
181
|
+
};
|
|
182
|
+
} catch (e) {
|
|
183
|
+
console.error(e);
|
|
184
|
+
throw new Error(e.message);
|
|
185
|
+
}
|
|
186
|
+
} else {
|
|
187
|
+
throw new Error((0, _i18next.t)('Incorrect password'));
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
batchRestoreV2(_ref4) {
|
|
191
|
+
let {
|
|
192
|
+
file,
|
|
193
|
+
isAllowed,
|
|
194
|
+
password,
|
|
195
|
+
proxyIds: _proxyIds
|
|
196
|
+
} = _ref4;
|
|
197
|
+
const jsons = this.validatedAccountsPassword(file, password);
|
|
198
|
+
const {
|
|
199
|
+
promise,
|
|
200
|
+
reject,
|
|
201
|
+
resolve
|
|
202
|
+
} = (0, _utils.createPromiseHandler)();
|
|
203
|
+
if (jsons) {
|
|
204
|
+
try {
|
|
205
|
+
const {
|
|
206
|
+
accountProxies,
|
|
207
|
+
modifyPairs
|
|
208
|
+
} = file;
|
|
209
|
+
const pairs = jsons.map(pair => _uiKeyring.keyring.createFromJson(pair));
|
|
210
|
+
const accountProxyMap = (0, _utils.combineAccountsWithKeyPair)(pairs, modifyPairs, accountProxies);
|
|
211
|
+
const rawProxyIds = _proxyIds && _proxyIds.length ? _proxyIds : Object.keys(accountProxyMap);
|
|
212
|
+
let _exists;
|
|
213
|
+
const proxiesChangeName = {};
|
|
214
|
+
const accountNameDuplicates = this.state.getDuplicateAccountNames(Object.values(accountProxyMap).filter(_ref5 => {
|
|
215
|
+
let {
|
|
216
|
+
id
|
|
217
|
+
} = _ref5;
|
|
218
|
+
return rawProxyIds.includes(id);
|
|
219
|
+
}));
|
|
220
|
+
const filteredAccountProxies = Object.fromEntries(Object.entries(accountProxyMap).filter(_ref6 => {
|
|
221
|
+
let [proxyId, accountProxy] = _ref6;
|
|
222
|
+
if (!rawProxyIds.includes(proxyId)) {
|
|
223
|
+
return false;
|
|
224
|
+
}
|
|
225
|
+
const addresses = accountProxy.accounts.map(account => account.address);
|
|
226
|
+
const exists = this.state.checkAddressExists(addresses);
|
|
227
|
+
const name = accountProxy.name;
|
|
228
|
+
if (this.state.checkNameExists(name) || accountNameDuplicates.includes(name)) {
|
|
229
|
+
proxiesChangeName[proxyId] = name.concat(' - ').concat((0, _getId.generateRandomString)());
|
|
230
|
+
}
|
|
231
|
+
_exists = exists;
|
|
232
|
+
return !exists;
|
|
233
|
+
}));
|
|
234
|
+
const addresses = Object.values(filteredAccountProxies).flatMap(proxy => proxy.accounts.map(account => account.address));
|
|
235
|
+
const proxyIds = Object.values(filteredAccountProxies).flatMap(proxy => proxy.id);
|
|
236
|
+
if (!addresses.length) {
|
|
237
|
+
if (_exists) {
|
|
238
|
+
throw new Error((0, _i18next.t)('Account already exists under the name {{name}}', {
|
|
239
|
+
replace: {
|
|
240
|
+
name: _exists.name || _exists.address || ''
|
|
241
|
+
}
|
|
242
|
+
}));
|
|
243
|
+
} else {
|
|
244
|
+
throw new Error((0, _i18next.t)('No accounts found to import'));
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
const _accountProxies = this.state.value.accountProxy;
|
|
248
|
+
const _modifyPairs = this.state.value.modifyPair;
|
|
249
|
+
const currentProxyId = this.state.value.currentAccount.proxyId;
|
|
250
|
+
const nextAccountProxyId = !proxyIds.length ? currentProxyId : proxyIds.length === 1 ? proxyIds[0] : _constants.ALL_ACCOUNT_KEY;
|
|
251
|
+
if (accountProxies) {
|
|
252
|
+
for (const proxyId of proxyIds) {
|
|
253
|
+
const accountProxy = accountProxies[proxyId];
|
|
254
|
+
if (accountProxy) {
|
|
255
|
+
if (proxiesChangeName[proxyId]) {
|
|
256
|
+
accountProxy.name = proxiesChangeName[proxyId];
|
|
257
|
+
}
|
|
258
|
+
_accountProxies[proxyId] = accountProxy;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
if (modifyPairs) {
|
|
263
|
+
for (const [key, modifyPair] of Object.entries(modifyPairs)) {
|
|
264
|
+
if (proxyIds.includes(modifyPair.accountProxyId || '')) {
|
|
265
|
+
_modifyPairs[key] = modifyPair;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
this.state.upsertAccountProxy(_accountProxies);
|
|
270
|
+
this.state.upsertModifyPairs(_modifyPairs);
|
|
271
|
+
_uiKeyring.keyring.restoreAccounts(file, password, addresses);
|
|
272
|
+
for (const [proxyId, accountProxy] of Object.entries(accountProxyMap)) {
|
|
273
|
+
const name = proxiesChangeName[proxyId];
|
|
274
|
+
if (name) {
|
|
275
|
+
for (const account of accountProxy.accounts) {
|
|
276
|
+
const pair = _uiKeyring.keyring.getPair(account.address);
|
|
277
|
+
_uiKeyring.keyring.saveAccountMeta(pair, {
|
|
278
|
+
...pair.meta,
|
|
279
|
+
name
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
const successAddressList = addresses.reduce((rs, address) => {
|
|
285
|
+
try {
|
|
286
|
+
const account = _uiKeyring.keyring.getPair(address);
|
|
287
|
+
if (account) {
|
|
288
|
+
rs.push(address);
|
|
289
|
+
}
|
|
290
|
+
} catch (error) {
|
|
291
|
+
console.log(error);
|
|
292
|
+
}
|
|
293
|
+
return rs;
|
|
294
|
+
}, []);
|
|
295
|
+
this.state.saveCurrentAccountProxyId(nextAccountProxyId, () => {
|
|
296
|
+
this.state.updateMetadataForPair();
|
|
297
|
+
this.state._addAddressesToAuthList(addresses, isAllowed);
|
|
298
|
+
resolve(successAddressList);
|
|
299
|
+
});
|
|
300
|
+
} catch (error) {
|
|
301
|
+
throw new Error(error.message);
|
|
302
|
+
}
|
|
303
|
+
} else {
|
|
304
|
+
reject(new Error((0, _i18next.t)('Incorrect password')));
|
|
305
|
+
}
|
|
306
|
+
return promise;
|
|
307
|
+
}
|
|
308
|
+
async batchExportV2(request) {
|
|
309
|
+
const {
|
|
310
|
+
password,
|
|
311
|
+
proxyIds
|
|
312
|
+
} = request;
|
|
313
|
+
try {
|
|
314
|
+
if (proxyIds && !proxyIds.length) {
|
|
315
|
+
throw new Error((0, _i18next.t)('No accounts found to export'));
|
|
316
|
+
}
|
|
317
|
+
const _accountProxy = this.state.value.accountProxy;
|
|
318
|
+
const _modifyPair = this.state.value.modifyPair;
|
|
319
|
+
const _account = this.state.value.accounts;
|
|
320
|
+
const _proxyIds = proxyIds || Object.keys(_account);
|
|
321
|
+
const modifyPairs = Object.fromEntries(Object.entries(_modifyPair).filter(_ref7 => {
|
|
322
|
+
let [, modifyPair] = _ref7;
|
|
323
|
+
return _proxyIds.includes(modifyPair.accountProxyId || '');
|
|
324
|
+
}));
|
|
325
|
+
const accountProxies = Object.fromEntries(Object.entries(_accountProxy).filter(_ref8 => {
|
|
326
|
+
let [, proxy] = _ref8;
|
|
327
|
+
return _proxyIds.includes(proxy.id);
|
|
328
|
+
}));
|
|
329
|
+
const addresses = Object.values(_account).filter(account => _proxyIds.includes(account.id)).flatMap(proxy => proxy.accounts.map(account => account.address));
|
|
330
|
+
const rs = await _uiKeyring.keyring.backupAccounts(password, addresses);
|
|
331
|
+
if (Object.keys(modifyPairs).length && Object.keys(accountProxies).length) {
|
|
332
|
+
rs.accountProxies = accountProxies;
|
|
333
|
+
rs.modifyPairs = modifyPairs;
|
|
334
|
+
}
|
|
335
|
+
return {
|
|
336
|
+
exportedJson: rs
|
|
337
|
+
};
|
|
338
|
+
} catch (e) {
|
|
339
|
+
const error = e;
|
|
340
|
+
if (error.message === 'Invalid master password') {
|
|
341
|
+
throw new Error((0, _i18next.t)('Incorrect password'));
|
|
342
|
+
} else {
|
|
343
|
+
throw error;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
exports.AccountJsonHandler = AccountJsonHandler;
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.AccountLedgerHandler = void 0;
|
|
7
|
+
var _constants = require("@subwallet/extension-base/constants");
|
|
8
|
+
var _uiKeyring = require("@subwallet/ui-keyring");
|
|
9
|
+
var _i18next = require("i18next");
|
|
10
|
+
var _util = require("@polkadot/util");
|
|
11
|
+
var _Base = require("./Base");
|
|
12
|
+
// Copyright 2019-2022 @subwallet/extension-base
|
|
13
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @class AccountLedgerHandler
|
|
17
|
+
* @extends AccountBaseHandler
|
|
18
|
+
* @description Handler for Ledger account actions
|
|
19
|
+
* */
|
|
20
|
+
class AccountLedgerHandler extends _Base.AccountBaseHandler {
|
|
21
|
+
/* Ledger */
|
|
22
|
+
|
|
23
|
+
/* For custom derive path */
|
|
24
|
+
async accountsCreateHardwareV2(request) {
|
|
25
|
+
const {
|
|
26
|
+
accountIndex,
|
|
27
|
+
address,
|
|
28
|
+
addressOffset,
|
|
29
|
+
genesisHash,
|
|
30
|
+
hardwareType,
|
|
31
|
+
isAllowed,
|
|
32
|
+
isEthereum,
|
|
33
|
+
isGeneric,
|
|
34
|
+
name,
|
|
35
|
+
originGenesisHash
|
|
36
|
+
} = request;
|
|
37
|
+
const exists = this.state.checkAddressExists([address]);
|
|
38
|
+
(0, _util.assert)(!exists, (0, _i18next.t)('Account already exists under the name {{name}}', {
|
|
39
|
+
replace: {
|
|
40
|
+
name: (exists === null || exists === void 0 ? void 0 : exists.name) || (exists === null || exists === void 0 ? void 0 : exists.address) || address
|
|
41
|
+
}
|
|
42
|
+
}));
|
|
43
|
+
const baseMeta = {
|
|
44
|
+
name,
|
|
45
|
+
hardwareType,
|
|
46
|
+
accountIndex,
|
|
47
|
+
addressOffset,
|
|
48
|
+
genesisHash,
|
|
49
|
+
originGenesisHash,
|
|
50
|
+
isGeneric
|
|
51
|
+
};
|
|
52
|
+
const type = isEthereum ? 'ethereum' : 'sr25519';
|
|
53
|
+
const pair = _uiKeyring.keyring.keyring.createFromAddress(address, {
|
|
54
|
+
...baseMeta,
|
|
55
|
+
isExternal: true,
|
|
56
|
+
isHardware: true,
|
|
57
|
+
availableGenesisHashes: isGeneric ? undefined : [genesisHash]
|
|
58
|
+
}, null, type);
|
|
59
|
+
const _address = pair.address;
|
|
60
|
+
const modifiedPairs = this.state.modifyPairs;
|
|
61
|
+
modifiedPairs[_address] = {
|
|
62
|
+
migrated: true,
|
|
63
|
+
key: _address
|
|
64
|
+
};
|
|
65
|
+
this.state.upsertModifyPairs(modifiedPairs);
|
|
66
|
+
_uiKeyring.keyring.addPair(pair, false);
|
|
67
|
+
await new Promise(resolve => {
|
|
68
|
+
this.state.saveCurrentAccountProxyId(_address, () => {
|
|
69
|
+
this.state._addAddressToAuthList(_address, isAllowed || false);
|
|
70
|
+
resolve();
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/* For multi select */
|
|
77
|
+
async accountsCreateHardwareMultiple(_ref) {
|
|
78
|
+
let {
|
|
79
|
+
accounts
|
|
80
|
+
} = _ref;
|
|
81
|
+
const addresses = [];
|
|
82
|
+
if (!accounts.length) {
|
|
83
|
+
throw new Error((0, _i18next.t)('Can\'t find an account. Please try again'));
|
|
84
|
+
}
|
|
85
|
+
const exists = this.state.checkAddressExists(accounts.map(account => account.address));
|
|
86
|
+
(0, _util.assert)(!exists, (0, _i18next.t)('Account already exists under the name {{name}}', {
|
|
87
|
+
replace: {
|
|
88
|
+
name: (exists === null || exists === void 0 ? void 0 : exists.name) || (exists === null || exists === void 0 ? void 0 : exists.address) || ''
|
|
89
|
+
}
|
|
90
|
+
}));
|
|
91
|
+
const slugMap = {};
|
|
92
|
+
const modifyPairs = this.state.modifyPairs;
|
|
93
|
+
const pairs = [];
|
|
94
|
+
for (const account of accounts) {
|
|
95
|
+
const {
|
|
96
|
+
accountIndex,
|
|
97
|
+
address,
|
|
98
|
+
addressOffset,
|
|
99
|
+
genesisHash,
|
|
100
|
+
hardwareType,
|
|
101
|
+
isEthereum,
|
|
102
|
+
isGeneric,
|
|
103
|
+
name,
|
|
104
|
+
originGenesisHash
|
|
105
|
+
} = account;
|
|
106
|
+
const baseMeta = {
|
|
107
|
+
name,
|
|
108
|
+
hardwareType,
|
|
109
|
+
accountIndex,
|
|
110
|
+
addressOffset,
|
|
111
|
+
genesisHash,
|
|
112
|
+
originGenesisHash,
|
|
113
|
+
isGeneric
|
|
114
|
+
};
|
|
115
|
+
const type = isEthereum ? 'ethereum' : 'sr25519';
|
|
116
|
+
const pair = _uiKeyring.keyring.keyring.createFromAddress(address, {
|
|
117
|
+
...baseMeta,
|
|
118
|
+
isExternal: true,
|
|
119
|
+
isHardware: true,
|
|
120
|
+
availableGenesisHashes: isGeneric ? undefined : [genesisHash]
|
|
121
|
+
}, null, type);
|
|
122
|
+
if (isEthereum) {
|
|
123
|
+
slugMap.ethereum = 'ethereum';
|
|
124
|
+
} else {
|
|
125
|
+
const slug = this.state.findNetworkKeyByGenesisHash(genesisHash);
|
|
126
|
+
if (slug) {
|
|
127
|
+
slugMap[slug] = slug;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
const _address = pair.address;
|
|
131
|
+
modifyPairs[_address] = {
|
|
132
|
+
migrated: true,
|
|
133
|
+
key: _address
|
|
134
|
+
};
|
|
135
|
+
addresses.push(_address);
|
|
136
|
+
pairs.push(pair);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// const currentAccount = this.#koniState.keyringService.context.currentAccount;
|
|
140
|
+
// const allGenesisHash = currentAccount?.allGenesisHash || undefined;
|
|
141
|
+
|
|
142
|
+
this.state.upsertModifyPairs(modifyPairs);
|
|
143
|
+
for (const pair of pairs) {
|
|
144
|
+
_uiKeyring.keyring.addPair(pair, false);
|
|
145
|
+
}
|
|
146
|
+
await new Promise(resolve => {
|
|
147
|
+
this.state._addAddressesToAuthList(addresses, true);
|
|
148
|
+
resolve();
|
|
149
|
+
});
|
|
150
|
+
if (addresses.length <= 1) {
|
|
151
|
+
this.state.saveCurrentAccountProxyId(addresses[0]);
|
|
152
|
+
} else {
|
|
153
|
+
this.state.saveCurrentAccountProxyId(_constants.ALL_ACCOUNT_KEY);
|
|
154
|
+
}
|
|
155
|
+
if (Object.keys(slugMap).length) {
|
|
156
|
+
for (const chainSlug of Object.keys(slugMap)) {
|
|
157
|
+
this.state.enableChain(chainSlug);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/* Ledger */
|
|
164
|
+
}
|
|
165
|
+
exports.AccountLedgerHandler = AccountLedgerHandler;
|