@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,299 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-base
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { AccountExternalErrorCode } from '@subwallet/extension-base/background/KoniTypes';
|
|
5
|
+
import { AccountChainType, CommonAccountErrorType, SWCommonAccountError } from '@subwallet/extension-base/types';
|
|
6
|
+
import { getKeypairTypeByAddress } from '@subwallet/keyring';
|
|
7
|
+
import { decodePair } from '@subwallet/keyring/pair/decode';
|
|
8
|
+
import { BitcoinKeypairTypes, TonKeypairTypes } from '@subwallet/keyring/types';
|
|
9
|
+
import keyring from '@subwallet/ui-keyring';
|
|
10
|
+
import { t } from 'i18next';
|
|
11
|
+
import { assert, hexStripPrefix, hexToU8a, isHex, u8aToHex } from '@polkadot/util';
|
|
12
|
+
import { base64Decode, keyExtractSuri } from '@polkadot/util-crypto';
|
|
13
|
+
import { AccountBaseHandler } from "./Base.js";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @class AccountSecretHandler
|
|
17
|
+
* @extends AccountBaseHandler
|
|
18
|
+
* @description Handler for account's mnemonic
|
|
19
|
+
* */
|
|
20
|
+
export class AccountSecretHandler extends AccountBaseHandler {
|
|
21
|
+
/* Add QR-signer, read-only */
|
|
22
|
+
async accountsCreateExternalV2(request) {
|
|
23
|
+
const {
|
|
24
|
+
address,
|
|
25
|
+
isAllowed,
|
|
26
|
+
isReadOnly,
|
|
27
|
+
name
|
|
28
|
+
} = request;
|
|
29
|
+
const type = getKeypairTypeByAddress(address);
|
|
30
|
+
try {
|
|
31
|
+
try {
|
|
32
|
+
const exists = keyring.getPair(address);
|
|
33
|
+
if (exists) {
|
|
34
|
+
if (exists.type === type) {
|
|
35
|
+
return [{
|
|
36
|
+
code: AccountExternalErrorCode.INVALID_ADDRESS,
|
|
37
|
+
message: t('Account exists')
|
|
38
|
+
}];
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
} catch (e) {}
|
|
42
|
+
const nameExists = this.state.checkNameExists(name);
|
|
43
|
+
if (nameExists) {
|
|
44
|
+
throw Error(t('Account name already exists'));
|
|
45
|
+
}
|
|
46
|
+
const meta = {
|
|
47
|
+
name,
|
|
48
|
+
isExternal: true,
|
|
49
|
+
isReadOnly,
|
|
50
|
+
genesisHash: ''
|
|
51
|
+
};
|
|
52
|
+
if ([...BitcoinKeypairTypes, ...TonKeypairTypes].includes(type) && isReadOnly) {
|
|
53
|
+
meta.noPublicKey = true;
|
|
54
|
+
}
|
|
55
|
+
const result = keyring.keyring.addFromAddress(address, meta, null, type);
|
|
56
|
+
keyring.saveAccount(result);
|
|
57
|
+
const _address = result.address;
|
|
58
|
+
const modifiedPairs = this.state.modifyPairs;
|
|
59
|
+
modifiedPairs[_address] = {
|
|
60
|
+
migrated: true,
|
|
61
|
+
key: _address
|
|
62
|
+
};
|
|
63
|
+
this.state.upsertModifyPairs(modifiedPairs);
|
|
64
|
+
await new Promise(resolve => {
|
|
65
|
+
this.state.saveCurrentAccountProxyId(_address, () => {
|
|
66
|
+
this.state._addAddressToAuthList(_address, isAllowed);
|
|
67
|
+
resolve();
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
return [];
|
|
71
|
+
} catch (e) {
|
|
72
|
+
return [{
|
|
73
|
+
code: AccountExternalErrorCode.KEYRING_ERROR,
|
|
74
|
+
message: e.message
|
|
75
|
+
}];
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/* Import ethereum account with the private key */
|
|
80
|
+
_checkValidatePrivateKey({
|
|
81
|
+
chainType,
|
|
82
|
+
privateKey
|
|
83
|
+
}, autoAddPrefix = false) {
|
|
84
|
+
const {
|
|
85
|
+
phrase
|
|
86
|
+
} = keyExtractSuri(privateKey);
|
|
87
|
+
const rs = {
|
|
88
|
+
autoAddPrefix: autoAddPrefix,
|
|
89
|
+
addressMap: {}
|
|
90
|
+
};
|
|
91
|
+
const types = [];
|
|
92
|
+
if (chainType) {
|
|
93
|
+
switch (chainType) {
|
|
94
|
+
case AccountChainType.ETHEREUM:
|
|
95
|
+
types.push('ethereum');
|
|
96
|
+
break;
|
|
97
|
+
case AccountChainType.TON:
|
|
98
|
+
types.push('ton');
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
} else {
|
|
102
|
+
if (isHex(phrase, 256)) {
|
|
103
|
+
types.push('ethereum');
|
|
104
|
+
} else if (isHex(phrase, 512)) {
|
|
105
|
+
types.push('ton');
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
types.forEach(type => {
|
|
109
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
110
|
+
rs.addressMap[type] = '';
|
|
111
|
+
});
|
|
112
|
+
if (types.length) {
|
|
113
|
+
types && types.forEach(type => {
|
|
114
|
+
rs.addressMap[type] = keyring.createFromUri(privateKey, {}, type).address;
|
|
115
|
+
});
|
|
116
|
+
rs.keyTypes = types;
|
|
117
|
+
} else {
|
|
118
|
+
rs.autoAddPrefix = false;
|
|
119
|
+
assert(false, t('Invalid private key'));
|
|
120
|
+
}
|
|
121
|
+
const exists = this.state.checkAddressExists(Object.values(rs.addressMap));
|
|
122
|
+
assert(!exists, t('Account already exists under the name {{name}}', {
|
|
123
|
+
replace: {
|
|
124
|
+
name: (exists === null || exists === void 0 ? void 0 : exists.name) || (exists === null || exists === void 0 ? void 0 : exists.address) || ''
|
|
125
|
+
}
|
|
126
|
+
}));
|
|
127
|
+
return rs;
|
|
128
|
+
}
|
|
129
|
+
privateKeyValidateV2({
|
|
130
|
+
chainType,
|
|
131
|
+
privateKey
|
|
132
|
+
}) {
|
|
133
|
+
const isHex = privateKey.startsWith('0x');
|
|
134
|
+
if (isHex) {
|
|
135
|
+
return this._checkValidatePrivateKey({
|
|
136
|
+
chainType,
|
|
137
|
+
privateKey
|
|
138
|
+
});
|
|
139
|
+
} else {
|
|
140
|
+
return this._checkValidatePrivateKey({
|
|
141
|
+
chainType,
|
|
142
|
+
privateKey: `0x${privateKey}`
|
|
143
|
+
}, true);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
async accountsCreateWithSecret(request) {
|
|
147
|
+
const {
|
|
148
|
+
isAllow,
|
|
149
|
+
isEthereum,
|
|
150
|
+
name,
|
|
151
|
+
publicKey,
|
|
152
|
+
secretKey
|
|
153
|
+
} = request;
|
|
154
|
+
try {
|
|
155
|
+
let keyringPair = null;
|
|
156
|
+
if (isEthereum) {
|
|
157
|
+
const _secret = hexStripPrefix(secretKey);
|
|
158
|
+
if (_secret.length === 64) {
|
|
159
|
+
const suri = `0x${_secret}`;
|
|
160
|
+
const {
|
|
161
|
+
phrase
|
|
162
|
+
} = keyExtractSuri(suri);
|
|
163
|
+
if (isHex(phrase) && isHex(phrase, 256)) {
|
|
164
|
+
const type = 'ethereum';
|
|
165
|
+
keyringPair = keyring.createFromUri(suri, {
|
|
166
|
+
name: name
|
|
167
|
+
}, type);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
} else {
|
|
171
|
+
keyringPair = keyring.keyring.createFromPair({
|
|
172
|
+
publicKey: hexToU8a(publicKey),
|
|
173
|
+
secretKey: hexToU8a(secretKey)
|
|
174
|
+
}, {
|
|
175
|
+
name
|
|
176
|
+
}, 'sr25519');
|
|
177
|
+
}
|
|
178
|
+
if (!keyringPair) {
|
|
179
|
+
return {
|
|
180
|
+
success: false,
|
|
181
|
+
errors: [{
|
|
182
|
+
code: AccountExternalErrorCode.KEYRING_ERROR,
|
|
183
|
+
message: t('Cannot create account')
|
|
184
|
+
}]
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
const _address = keyringPair.address;
|
|
188
|
+
const exists = this.state.checkAddressExists([_address]);
|
|
189
|
+
assert(!exists, t('Account already exists under the name {{name}}', {
|
|
190
|
+
replace: {
|
|
191
|
+
name: (exists === null || exists === void 0 ? void 0 : exists.name) || (exists === null || exists === void 0 ? void 0 : exists.address) || ''
|
|
192
|
+
}
|
|
193
|
+
}));
|
|
194
|
+
const nameExists = this.state.checkNameExists(name);
|
|
195
|
+
assert(!nameExists, new SWCommonAccountError(CommonAccountErrorType.ACCOUNT_NAME_EXISTED).message);
|
|
196
|
+
const modifyPairs = this.state.modifyPairs;
|
|
197
|
+
modifyPairs[_address] = {
|
|
198
|
+
migrated: true,
|
|
199
|
+
key: _address
|
|
200
|
+
};
|
|
201
|
+
this.state.upsertModifyPairs(modifyPairs);
|
|
202
|
+
keyring.addPair(keyringPair, true);
|
|
203
|
+
await new Promise(resolve => {
|
|
204
|
+
this.state.saveCurrentAccountProxyId(_address, () => {
|
|
205
|
+
this.state._addAddressToAuthList(_address, isAllow);
|
|
206
|
+
resolve();
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
return {
|
|
210
|
+
errors: [],
|
|
211
|
+
success: true
|
|
212
|
+
};
|
|
213
|
+
} catch (e) {
|
|
214
|
+
return {
|
|
215
|
+
success: false,
|
|
216
|
+
errors: [{
|
|
217
|
+
code: AccountExternalErrorCode.KEYRING_ERROR,
|
|
218
|
+
message: e.message
|
|
219
|
+
}]
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
checkPublicAndSecretKey({
|
|
224
|
+
publicKey,
|
|
225
|
+
secretKey
|
|
226
|
+
}) {
|
|
227
|
+
let response = {
|
|
228
|
+
address: '',
|
|
229
|
+
isValid: true,
|
|
230
|
+
isEthereum: false
|
|
231
|
+
};
|
|
232
|
+
try {
|
|
233
|
+
const _secret = hexStripPrefix(secretKey);
|
|
234
|
+
if (_secret.length === 64) {
|
|
235
|
+
const suri = `0x${_secret}`;
|
|
236
|
+
const {
|
|
237
|
+
phrase
|
|
238
|
+
} = keyExtractSuri(suri);
|
|
239
|
+
if (isHex(phrase) && isHex(phrase, 256)) {
|
|
240
|
+
const type = 'ethereum';
|
|
241
|
+
const address = keyring.createFromUri(suri, {}, type).address;
|
|
242
|
+
response = {
|
|
243
|
+
address: address,
|
|
244
|
+
isValid: true,
|
|
245
|
+
isEthereum: true
|
|
246
|
+
};
|
|
247
|
+
} else {
|
|
248
|
+
response = {
|
|
249
|
+
address: '',
|
|
250
|
+
isValid: false,
|
|
251
|
+
isEthereum: true
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
} else {
|
|
255
|
+
const keyPair = keyring.keyring.createFromPair({
|
|
256
|
+
publicKey: hexToU8a(publicKey),
|
|
257
|
+
secretKey: hexToU8a(secretKey)
|
|
258
|
+
}, {}, 'sr25519');
|
|
259
|
+
response = {
|
|
260
|
+
address: keyPair.address,
|
|
261
|
+
isValid: true,
|
|
262
|
+
isEthereum: false
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
} catch (e) {
|
|
266
|
+
console.error(e);
|
|
267
|
+
return {
|
|
268
|
+
address: '',
|
|
269
|
+
isValid: false,
|
|
270
|
+
isEthereum: false,
|
|
271
|
+
errorMessage: t(e.message)
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
if (response.isValid) {
|
|
275
|
+
const exists = this.state.checkAddressExists([response.address]);
|
|
276
|
+
if (exists) {
|
|
277
|
+
response.errorMessage = t('Account already exists under the name {{name}}', {
|
|
278
|
+
replace: {
|
|
279
|
+
name: (exists === null || exists === void 0 ? void 0 : exists.name) || (exists === null || exists === void 0 ? void 0 : exists.address) || ''
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
response.isValid = false;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
return response;
|
|
286
|
+
}
|
|
287
|
+
accountExportPrivateKey(request) {
|
|
288
|
+
const {
|
|
289
|
+
address,
|
|
290
|
+
password
|
|
291
|
+
} = request;
|
|
292
|
+
const exportedJson = keyring.backupAccount(keyring.getPair(address), password);
|
|
293
|
+
const decoded = decodePair(password, base64Decode(exportedJson.encoded), exportedJson.encoding.type);
|
|
294
|
+
return {
|
|
295
|
+
privateKey: u8aToHex(decoded.secretKey),
|
|
296
|
+
publicKey: u8aToHex(decoded.publicKey)
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
export * from "./Derive.js";
|
|
5
|
+
export * from "./Inject.js";
|
|
6
|
+
export * from "./Json.js";
|
|
7
|
+
export * from "./Ledger.js";
|
|
8
|
+
export * from "./Mnemonic.js";
|
|
9
|
+
export * from "./Modify.js";
|
|
10
|
+
export * from "./Secret.js";
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import KoniState from '@subwallet/extension-base/koni/background/handlers/State';
|
|
2
|
+
import { AccountProxy, AccountProxyData, AccountProxyMap, AccountProxyStoreData, CurrentAccountInfo, ModifyPairStoreData } from '@subwallet/extension-base/types';
|
|
3
|
+
import { SubjectInfo } from '@subwallet/ui-keyring/observable/types';
|
|
4
|
+
interface ExistsAccount {
|
|
5
|
+
address: string;
|
|
6
|
+
name: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class AccountState {
|
|
9
|
+
private readonly koniState;
|
|
10
|
+
private readonly _currentAccount;
|
|
11
|
+
private readonly _accountProxy;
|
|
12
|
+
private readonly _modifyPair;
|
|
13
|
+
private readonly contactSubject;
|
|
14
|
+
private readonly pairSubject;
|
|
15
|
+
private readonly accountSubject;
|
|
16
|
+
private readonly accountRefStore;
|
|
17
|
+
private beforeAccount;
|
|
18
|
+
private _injected;
|
|
19
|
+
constructor(koniState: KoniState);
|
|
20
|
+
private subscribeAccounts;
|
|
21
|
+
get injected(): boolean;
|
|
22
|
+
setInjected(injected: boolean): void;
|
|
23
|
+
get pairs(): SubjectInfo;
|
|
24
|
+
get contacts(): SubjectInfo;
|
|
25
|
+
get accounts(): AccountProxyMap;
|
|
26
|
+
get accountProxies(): AccountProxyStoreData;
|
|
27
|
+
get modifyPairs(): ModifyPairStoreData;
|
|
28
|
+
get value(): {
|
|
29
|
+
readonly pairs: SubjectInfo;
|
|
30
|
+
readonly accounts: AccountProxyMap;
|
|
31
|
+
readonly accountProxy: AccountProxyStoreData;
|
|
32
|
+
readonly currentAccount: CurrentAccountInfo;
|
|
33
|
+
readonly contacts: SubjectInfo;
|
|
34
|
+
readonly modifyPair: ModifyPairStoreData;
|
|
35
|
+
};
|
|
36
|
+
get observable(): {
|
|
37
|
+
readonly pairs: import("rxjs").Observable<SubjectInfo>;
|
|
38
|
+
readonly accounts: import("rxjs").Observable<AccountProxyMap>;
|
|
39
|
+
readonly accountProxy: import("rxjs").Observable<AccountProxyStoreData>;
|
|
40
|
+
readonly currentAccount: import("rxjs").Observable<CurrentAccountInfo>;
|
|
41
|
+
readonly contacts: import("rxjs").Observable<SubjectInfo>;
|
|
42
|
+
};
|
|
43
|
+
get currentAccount(): CurrentAccountInfo;
|
|
44
|
+
private setCurrentAccount;
|
|
45
|
+
/**
|
|
46
|
+
* Updates the current account proxy ID and emits an event to notify about the update.
|
|
47
|
+
* For case the proxy ID is set as `ALL_ACCOUNT_KEY`, it will be updated to the first account proxy ID if there is only one account.
|
|
48
|
+
*
|
|
49
|
+
* Note: This function should be called after account data is updated.
|
|
50
|
+
*
|
|
51
|
+
* @param _proxyId - The proxy ID to be set as the current account proxy ID.
|
|
52
|
+
* @param callback - Optional callback function to be executed after the current account proxy ID is updated.
|
|
53
|
+
* @param preventOneAccount - Optional flag to prevent setting the proxy ID if there is only one account.
|
|
54
|
+
*/
|
|
55
|
+
saveCurrentAccountProxyId(_proxyId: string, callback?: (data: CurrentAccountInfo) => void, preventOneAccount?: boolean): void;
|
|
56
|
+
checkAddressExists(addresses: string[]): ExistsAccount | undefined;
|
|
57
|
+
checkNameExists(name: string, proxyId?: string): boolean;
|
|
58
|
+
getDuplicateAccountNames: (accounts: AccountProxy[]) => string[];
|
|
59
|
+
_addAddressesToAuthList(addresses: string[], isAllowed: boolean): void;
|
|
60
|
+
changeAddressAllowedAuthList(oldAddress: string, newAddress: string): void;
|
|
61
|
+
_addAddressToAuthList(address: string, isAllowed: boolean): void;
|
|
62
|
+
upsertAccountProxy(data: AccountProxyStoreData, callback?: () => void): void;
|
|
63
|
+
upsertAccountProxyByKey(data: AccountProxyData, callback?: () => void): void;
|
|
64
|
+
deleteAccountProxy(key: string, callback?: () => void): void;
|
|
65
|
+
isUnifiedAccount(proxyId: string): boolean;
|
|
66
|
+
belongUnifiedAccount(address: string): string | undefined;
|
|
67
|
+
addressesByProxyId(proxyId: string): string[];
|
|
68
|
+
upsertModifyPairs(data: ModifyPairStoreData): void;
|
|
69
|
+
getAllAddresses(): string[];
|
|
70
|
+
getProxyId(): string | null;
|
|
71
|
+
getDecodedAddresses(accountProxy?: string, allowGetAllAccount?: boolean): string[];
|
|
72
|
+
/**
|
|
73
|
+
* Account ref
|
|
74
|
+
* @deprecated
|
|
75
|
+
* */
|
|
76
|
+
/** @deprecated */
|
|
77
|
+
getAccountRefMap(callback: (refMap: Record<string, Array<string>>) => void): void;
|
|
78
|
+
/** @deprecated */
|
|
79
|
+
addAccountRef(addresses: string[], callback: () => void): void;
|
|
80
|
+
/** @deprecated */
|
|
81
|
+
removeAccountRef(address: string, callback: () => void): void;
|
|
82
|
+
/**
|
|
83
|
+
* Account ref
|
|
84
|
+
* */
|
|
85
|
+
removeNoneHardwareGenesisHash(): void;
|
|
86
|
+
updateMetadataForPair(): void;
|
|
87
|
+
updateMetadataForProxy(): void;
|
|
88
|
+
findNetworkKeyByGenesisHash(genesisHash?: string): string | undefined;
|
|
89
|
+
enableChain(slug: string): void;
|
|
90
|
+
resetWallet(): void;
|
|
91
|
+
}
|
|
92
|
+
export {};
|