@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
|
@@ -19,6 +19,7 @@ var _types2 = require("@subwallet/extension-base/services/chain-service/handler/
|
|
|
19
19
|
var _utils = require("@subwallet/extension-base/services/chain-service/utils");
|
|
20
20
|
var _constants2 = require("@subwallet/extension-base/services/setting-service/constants");
|
|
21
21
|
var _utils2 = require("@subwallet/extension-base/utils");
|
|
22
|
+
var _types3 = require("@subwallet/keyring/types");
|
|
22
23
|
var _web = _interopRequireDefault(require("web3"));
|
|
23
24
|
var _phishing = require("@polkadot/phishing");
|
|
24
25
|
var _util = require("@polkadot/util");
|
|
@@ -29,51 +30,51 @@ var _utilCrypto = require("@polkadot/util-crypto");
|
|
|
29
30
|
function transformAccountsV2(accounts) {
|
|
30
31
|
let anyType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
31
32
|
let authInfo = arguments.length > 2 ? arguments[2] : undefined;
|
|
32
|
-
let
|
|
33
|
+
let accountAuthTypes = arguments.length > 3 ? arguments[3] : undefined;
|
|
33
34
|
const accountSelected = authInfo ? authInfo.isAllowed ? Object.keys(authInfo.isAllowedMap).filter(address => authInfo.isAllowedMap[address]) : [] : [];
|
|
34
|
-
|
|
35
|
+
const authTypeFilter = _ref => {
|
|
35
36
|
let {
|
|
36
37
|
type
|
|
37
38
|
} = _ref;
|
|
38
|
-
|
|
39
|
+
if (accountAuthTypes) {
|
|
40
|
+
if (!type) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
const validTypes = {
|
|
44
|
+
evm: _types3.EthereumKeypairTypes,
|
|
45
|
+
substrate: _types3.SubstrateKeypairTypes,
|
|
46
|
+
ton: _types3.TonKeypairTypes
|
|
47
|
+
};
|
|
48
|
+
return accountAuthTypes.some(authType => {
|
|
49
|
+
var _validTypes$authType;
|
|
50
|
+
return (_validTypes$authType = validTypes[authType]) === null || _validTypes$authType === void 0 ? void 0 : _validTypes$authType.includes(type);
|
|
51
|
+
});
|
|
52
|
+
} else {
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
39
55
|
};
|
|
40
|
-
|
|
41
|
-
authTypeFilter = _ref2 => {
|
|
42
|
-
let {
|
|
43
|
-
type
|
|
44
|
-
} = _ref2;
|
|
45
|
-
return type !== 'ethereum';
|
|
46
|
-
};
|
|
47
|
-
} else if (accountAuthType === 'evm') {
|
|
48
|
-
authTypeFilter = _ref3 => {
|
|
49
|
-
let {
|
|
50
|
-
type
|
|
51
|
-
} = _ref3;
|
|
52
|
-
return type === 'ethereum';
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
return Object.values(accounts).filter(_ref4 => {
|
|
56
|
+
return Object.values(accounts).filter(_ref2 => {
|
|
56
57
|
let {
|
|
57
58
|
json: {
|
|
58
59
|
meta: {
|
|
59
60
|
isHidden
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
|
-
} =
|
|
63
|
+
} = _ref2;
|
|
63
64
|
return !isHidden;
|
|
64
|
-
}).filter(
|
|
65
|
+
}).filter(_ref3 => {
|
|
65
66
|
let {
|
|
66
67
|
type
|
|
67
|
-
} =
|
|
68
|
+
} = _ref3;
|
|
68
69
|
return anyType ? true : (0, _utils2.canDerive)(type);
|
|
69
|
-
}).filter(authTypeFilter).filter(
|
|
70
|
+
}).filter(authTypeFilter).filter(_ref4 => {
|
|
70
71
|
let {
|
|
71
72
|
json: {
|
|
72
73
|
address
|
|
73
74
|
}
|
|
74
|
-
} =
|
|
75
|
+
} = _ref4;
|
|
75
76
|
return accountSelected.includes(address);
|
|
76
|
-
}).sort((a, b) => (a.json.meta.whenCreated || 0) - (b.json.meta.whenCreated || 0)).map(
|
|
77
|
+
}).sort((a, b) => (a.json.meta.whenCreated || 0) - (b.json.meta.whenCreated || 0)).map(_ref5 => {
|
|
77
78
|
let {
|
|
78
79
|
json: {
|
|
79
80
|
address,
|
|
@@ -83,7 +84,7 @@ function transformAccountsV2(accounts) {
|
|
|
83
84
|
}
|
|
84
85
|
},
|
|
85
86
|
type
|
|
86
|
-
} =
|
|
87
|
+
} = _ref5;
|
|
87
88
|
return {
|
|
88
89
|
address,
|
|
89
90
|
genesisHash,
|
|
@@ -143,12 +144,13 @@ class KoniTabs {
|
|
|
143
144
|
payloadAfterValidated: request
|
|
144
145
|
};
|
|
145
146
|
const {
|
|
146
|
-
|
|
147
|
+
errors
|
|
147
148
|
} = await (0, _logicValidation.generateValidationProcess)(this.#koniState, url, payloadValidate, [_logicValidation.validationAuthMiddleware]);
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
149
|
+
if (errors.length === 0) {
|
|
150
|
+
return this.#koniState.sign(url, new _RequestBytesSign.default(request));
|
|
151
|
+
} else {
|
|
152
|
+
throw errors[0];
|
|
153
|
+
}
|
|
152
154
|
}
|
|
153
155
|
async extrinsicSign(url, request) {
|
|
154
156
|
const address = request.address;
|
|
@@ -159,12 +161,14 @@ class KoniTabs {
|
|
|
159
161
|
payloadAfterValidated: request
|
|
160
162
|
};
|
|
161
163
|
const {
|
|
164
|
+
errors,
|
|
162
165
|
pair
|
|
163
166
|
} = await (0, _logicValidation.generateValidationProcess)(this.#koniState, url, payloadValidate, [_logicValidation.validationAuthMiddleware]);
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
167
|
+
if (pair && errors.length === 0) {
|
|
168
|
+
return this.#koniState.sign(url, new _RequestExtrinsicSign.default(request));
|
|
169
|
+
} else {
|
|
170
|
+
throw errors[0];
|
|
171
|
+
}
|
|
168
172
|
}
|
|
169
173
|
metadataProvide(url, request) {
|
|
170
174
|
return this.#koniState.injectMetadata(url, request);
|
|
@@ -172,11 +176,11 @@ class KoniTabs {
|
|
|
172
176
|
|
|
173
177
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
174
178
|
metadataList(url) {
|
|
175
|
-
return this.#koniState.knownMetadata.map(
|
|
179
|
+
return this.#koniState.knownMetadata.map(_ref6 => {
|
|
176
180
|
let {
|
|
177
181
|
genesisHash,
|
|
178
182
|
specVersion
|
|
179
|
-
} =
|
|
183
|
+
} = _ref6;
|
|
180
184
|
return {
|
|
181
185
|
genesisHash,
|
|
182
186
|
specVersion
|
|
@@ -224,10 +228,10 @@ class KoniTabs {
|
|
|
224
228
|
chrome.tabs.query({
|
|
225
229
|
url: nonFragment
|
|
226
230
|
}, tabs => {
|
|
227
|
-
tabs.map(
|
|
231
|
+
tabs.map(_ref7 => {
|
|
228
232
|
let {
|
|
229
233
|
id
|
|
230
|
-
} =
|
|
234
|
+
} = _ref7;
|
|
231
235
|
return id;
|
|
232
236
|
}).filter(id => (0, _util.isNumber)(id)).forEach(id => (0, _helpers.withErrorLog)(() => chrome.tabs.update(id, {
|
|
233
237
|
url
|
|
@@ -273,26 +277,49 @@ class KoniTabs {
|
|
|
273
277
|
const shortenUrl = (0, _utils2.stripUrl)(url);
|
|
274
278
|
return authList[shortenUrl];
|
|
275
279
|
}
|
|
276
|
-
async accountsListV2(url,
|
|
280
|
+
async accountsListV2(url, _ref8) {
|
|
277
281
|
let {
|
|
278
282
|
accountAuthType,
|
|
279
283
|
anyType
|
|
280
|
-
} =
|
|
284
|
+
} = _ref8;
|
|
281
285
|
const authInfo = await this.getAuthInfo(url);
|
|
282
|
-
|
|
286
|
+
const accountAuthTypes = [];
|
|
287
|
+
if (accountAuthType) {
|
|
288
|
+
accountAuthTypes.push(accountAuthType);
|
|
289
|
+
} else if (authInfo) {
|
|
290
|
+
if (authInfo.accountAuthTypes.includes('substrate')) {
|
|
291
|
+
accountAuthTypes.push('substrate');
|
|
292
|
+
}
|
|
293
|
+
if (authInfo.accountAuthTypes.includes('evm')) {
|
|
294
|
+
accountAuthTypes.push('evm');
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
return transformAccountsV2(this.#koniState.keyringService.context.pairs, anyType, authInfo, accountAuthTypes);
|
|
283
298
|
}
|
|
284
|
-
|
|
299
|
+
|
|
300
|
+
// TODO: Update logic
|
|
301
|
+
accountsSubstrateSubscribeV2(url, _ref9, id, port) {
|
|
285
302
|
let {
|
|
286
303
|
accountAuthType
|
|
287
|
-
} =
|
|
304
|
+
} = _ref9;
|
|
288
305
|
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
289
306
|
const authInfoSubject = this.#koniState.requestService.subscribeAuthorizeUrlSubject;
|
|
290
307
|
this.#accountSubs[id] = {
|
|
291
308
|
subscription: authInfoSubject.subscribe(infos => {
|
|
292
309
|
this.getAuthInfo(url, infos).then(authInfo => {
|
|
293
|
-
const
|
|
294
|
-
|
|
295
|
-
|
|
310
|
+
const accountAuthTypes = [];
|
|
311
|
+
if (accountAuthType) {
|
|
312
|
+
accountAuthTypes.push(accountAuthType);
|
|
313
|
+
} else if (authInfo) {
|
|
314
|
+
if (authInfo.accountAuthTypes.includes('substrate')) {
|
|
315
|
+
accountAuthTypes.push('substrate');
|
|
316
|
+
}
|
|
317
|
+
if (authInfo.accountAuthTypes.includes('evm')) {
|
|
318
|
+
accountAuthTypes.push('evm');
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
const accounts = this.#koniState.keyringService.context.pairs;
|
|
322
|
+
return cb(transformAccountsV2(accounts, false, authInfo, accountAuthTypes));
|
|
296
323
|
}).catch(console.error);
|
|
297
324
|
}),
|
|
298
325
|
url
|
|
@@ -306,10 +333,10 @@ class KoniTabs {
|
|
|
306
333
|
});
|
|
307
334
|
return id;
|
|
308
335
|
}
|
|
309
|
-
accountsUnsubscribe(url,
|
|
336
|
+
accountsUnsubscribe(url, _ref10) {
|
|
310
337
|
let {
|
|
311
338
|
id
|
|
312
|
-
} =
|
|
339
|
+
} = _ref10;
|
|
313
340
|
const sub = this.#accountSubs[id];
|
|
314
341
|
if (!sub || sub.url !== url) {
|
|
315
342
|
return false;
|
|
@@ -320,7 +347,9 @@ class KoniTabs {
|
|
|
320
347
|
return true;
|
|
321
348
|
}
|
|
322
349
|
authorizeV2(url, request) {
|
|
323
|
-
|
|
350
|
+
var _request$accountAuthT, _request$accountAuthT2;
|
|
351
|
+
const isConnectOnlyEvmAccountType = ((_request$accountAuthT = request.accountAuthTypes) === null || _request$accountAuthT === void 0 ? void 0 : _request$accountAuthT.length) === 1 && ((_request$accountAuthT2 = request.accountAuthTypes) === null || _request$accountAuthT2 === void 0 ? void 0 : _request$accountAuthT2.includes('evm'));
|
|
352
|
+
if (isConnectOnlyEvmAccountType) {
|
|
324
353
|
return new Promise((resolve, reject) => {
|
|
325
354
|
this.#koniState.authorizeUrlV2(url, request).then(resolve).catch(e => {
|
|
326
355
|
reject(new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.USER_REJECTED_REQUEST));
|
|
@@ -330,23 +359,30 @@ class KoniTabs {
|
|
|
330
359
|
return this.#koniState.authorizeUrlV2(url, request);
|
|
331
360
|
}
|
|
332
361
|
}
|
|
362
|
+
|
|
363
|
+
// TODO: Update logic
|
|
333
364
|
async getEvmCurrentAccount(url) {
|
|
334
365
|
return await new Promise(resolve => {
|
|
335
366
|
this.getAuthInfo(url).then(authInfo => {
|
|
336
|
-
const allAccounts = this.#koniState.keyringService.
|
|
337
|
-
const accountList = transformAccountsV2(allAccounts, false, authInfo, 'evm').map(a => a.address);
|
|
367
|
+
const allAccounts = this.#koniState.keyringService.context.pairs;
|
|
368
|
+
const accountList = transformAccountsV2(allAccounts, false, authInfo, ['evm']).map(a => a.address);
|
|
338
369
|
let accounts = [];
|
|
339
|
-
const
|
|
340
|
-
if (
|
|
370
|
+
const proxyId = this.#koniState.keyringService.context.currentAccount.proxyId;
|
|
371
|
+
if (proxyId === _constants.ALL_ACCOUNT_KEY || !proxyId) {
|
|
341
372
|
accounts = accountList;
|
|
342
373
|
} else {
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
374
|
+
const addresses = this.#koniState.keyringService.context.addressesByProxyId(proxyId);
|
|
375
|
+
const result = [];
|
|
376
|
+
const inList = [];
|
|
377
|
+
for (const account of accountList) {
|
|
378
|
+
if (!addresses.includes(account)) {
|
|
379
|
+
result.push(account);
|
|
380
|
+
} else {
|
|
381
|
+
inList.push(account);
|
|
382
|
+
}
|
|
349
383
|
}
|
|
384
|
+
result.unshift(...inList);
|
|
385
|
+
accounts = result;
|
|
350
386
|
}
|
|
351
387
|
resolve(accounts);
|
|
352
388
|
}).catch(console.error);
|
|
@@ -422,10 +458,10 @@ class KoniTabs {
|
|
|
422
458
|
date: new Date().getTime()
|
|
423
459
|
}];
|
|
424
460
|
}
|
|
425
|
-
async revokePermissions(url, id,
|
|
461
|
+
async revokePermissions(url, id, _ref11) {
|
|
426
462
|
let {
|
|
427
463
|
params
|
|
428
|
-
} =
|
|
464
|
+
} = _ref11;
|
|
429
465
|
if (!params || !(0, _util.isArray)(params) || params.length === 0) {
|
|
430
466
|
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, 'No list of permissions found to revoke in the parameters.');
|
|
431
467
|
}
|
|
@@ -449,35 +485,31 @@ class KoniTabs {
|
|
|
449
485
|
const urlStripped = (0, _utils2.stripUrl)(url);
|
|
450
486
|
if (value && value[urlStripped]) {
|
|
451
487
|
const {
|
|
452
|
-
|
|
488
|
+
accountAuthTypes,
|
|
453
489
|
isAllowedMap
|
|
454
490
|
} = {
|
|
455
491
|
...value[urlStripped]
|
|
456
492
|
};
|
|
457
|
-
if (!
|
|
493
|
+
if (!accountAuthTypes) {
|
|
458
494
|
resolve();
|
|
459
495
|
}
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
resolve();
|
|
463
|
-
break;
|
|
464
|
-
case 'evm':
|
|
496
|
+
if (accountAuthTypes !== null && accountAuthTypes !== void 0 && accountAuthTypes.includes('evm')) {
|
|
497
|
+
if (accountAuthTypes.length === 1) {
|
|
465
498
|
delete value[urlStripped];
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
}
|
|
499
|
+
} else {
|
|
500
|
+
value[urlStripped].isAllowedMap = Object.entries(isAllowedMap).reduce((allowedMap, _ref12) => {
|
|
501
|
+
let [address, value] = _ref12;
|
|
502
|
+
if ((0, _utilCrypto.isEthereumAddress)(address)) {
|
|
503
|
+
allowedMap[address] = false;
|
|
504
|
+
} else {
|
|
505
|
+
allowedMap[address] = value;
|
|
506
|
+
}
|
|
507
|
+
return allowedMap;
|
|
508
|
+
}, {});
|
|
509
|
+
value[urlStripped].accountAuthTypes = accountAuthTypes === null || accountAuthTypes === void 0 ? void 0 : accountAuthTypes.filter(type => type !== 'evm');
|
|
510
|
+
}
|
|
511
|
+
} else {
|
|
512
|
+
resolve();
|
|
481
513
|
}
|
|
482
514
|
this.#koniState.setAuthorize(value, () => {
|
|
483
515
|
resolve();
|
|
@@ -492,10 +524,10 @@ class KoniTabs {
|
|
|
492
524
|
await Promise.all(Array.from(permissions).map(permissionPromise));
|
|
493
525
|
return null;
|
|
494
526
|
}
|
|
495
|
-
async switchEvmChain(id, url,
|
|
527
|
+
async switchEvmChain(id, url, _ref13) {
|
|
496
528
|
let {
|
|
497
529
|
params
|
|
498
|
-
} =
|
|
530
|
+
} = _ref13;
|
|
499
531
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
500
532
|
const chainId = params[0].chainId;
|
|
501
533
|
const chainIdDec = parseInt(chainId, 16);
|
|
@@ -527,11 +559,11 @@ class KoniTabs {
|
|
|
527
559
|
}
|
|
528
560
|
return null;
|
|
529
561
|
}
|
|
530
|
-
async addEvmToken(id, url,
|
|
562
|
+
async addEvmToken(id, url, _ref14) {
|
|
531
563
|
var _input$type, _input$options, _input$options2, _input$options3, _input$options4, _input$options5;
|
|
532
564
|
let {
|
|
533
565
|
params
|
|
534
|
-
} =
|
|
566
|
+
} = _ref14;
|
|
535
567
|
const input = params;
|
|
536
568
|
const _tokenType = (input === null || input === void 0 ? void 0 : (_input$type = input.type) === null || _input$type === void 0 ? void 0 : _input$type.toLowerCase()) || '';
|
|
537
569
|
if (_tokenType !== 'erc20' && _tokenType !== 'erc721') {
|
|
@@ -584,10 +616,10 @@ class KoniTabs {
|
|
|
584
616
|
|
|
585
617
|
return await this.#koniState.addTokenConfirm(id, url, tokenInfo);
|
|
586
618
|
}
|
|
587
|
-
async addEvmChain(id, url,
|
|
619
|
+
async addEvmChain(id, url, _ref15) {
|
|
588
620
|
let {
|
|
589
621
|
params
|
|
590
|
-
} =
|
|
622
|
+
} = _ref15;
|
|
591
623
|
const input = params;
|
|
592
624
|
if (input && input.length > 0) {
|
|
593
625
|
const {
|
|
@@ -716,6 +748,8 @@ class KoniTabs {
|
|
|
716
748
|
const evmState = await this.getEvmState(url);
|
|
717
749
|
return evmState.chainId || '0x0';
|
|
718
750
|
}
|
|
751
|
+
|
|
752
|
+
// TODO: Update logic
|
|
719
753
|
async evmSubscribeEvents(url, id, port) {
|
|
720
754
|
// This method will be called after DApp request connect to extension
|
|
721
755
|
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
@@ -740,7 +774,7 @@ class KoniTabs {
|
|
|
740
774
|
currentAccountList = newAccountList;
|
|
741
775
|
}
|
|
742
776
|
};
|
|
743
|
-
const accountListSubscription = this.#koniState.keyringService.
|
|
777
|
+
const accountListSubscription = this.#koniState.keyringService.context.observable.currentAccount.subscribe(() => {
|
|
744
778
|
onCurrentAccountChanged().catch(console.error);
|
|
745
779
|
});
|
|
746
780
|
|
|
@@ -790,11 +824,11 @@ class KoniTabs {
|
|
|
790
824
|
const networkCheckInterval = setInterval(networkCheck, _constants.CRON_GET_API_MAP_STATUS);
|
|
791
825
|
const provider = await this.getEvmProvider(url);
|
|
792
826
|
const eventMap = {};
|
|
793
|
-
eventMap.data =
|
|
827
|
+
eventMap.data = _ref16 => {
|
|
794
828
|
let {
|
|
795
829
|
method,
|
|
796
830
|
params
|
|
797
|
-
} =
|
|
831
|
+
} = _ref16;
|
|
798
832
|
emitEvent('message', {
|
|
799
833
|
type: method,
|
|
800
834
|
data: params
|
|
@@ -803,8 +837,8 @@ class KoniTabs {
|
|
|
803
837
|
eventMap.error = rs => {
|
|
804
838
|
emitEvent('error', rs);
|
|
805
839
|
};
|
|
806
|
-
Object.entries(eventMap).forEach(
|
|
807
|
-
let [event, callback] =
|
|
840
|
+
Object.entries(eventMap).forEach(_ref17 => {
|
|
841
|
+
let [event, callback] = _ref17;
|
|
808
842
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
809
843
|
(provider === null || provider === void 0 ? void 0 : provider.on) && (provider === null || provider === void 0 ? void 0 : provider.on(event, callback));
|
|
810
844
|
});
|
|
@@ -818,8 +852,8 @@ class KoniTabs {
|
|
|
818
852
|
if (this.evmEventEmitterMap[url][id]) {
|
|
819
853
|
delete this.evmEventEmitterMap[url][id];
|
|
820
854
|
}
|
|
821
|
-
Object.entries(eventMap).forEach(
|
|
822
|
-
let [event, callback] =
|
|
855
|
+
Object.entries(eventMap).forEach(_ref18 => {
|
|
856
|
+
let [event, callback] = _ref18;
|
|
823
857
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
824
858
|
(provider === null || provider === void 0 ? void 0 : provider.removeListener) && (provider === null || provider === void 0 ? void 0 : provider.removeListener(event, callback));
|
|
825
859
|
});
|
|
@@ -854,11 +888,11 @@ class KoniTabs {
|
|
|
854
888
|
}
|
|
855
889
|
return provider;
|
|
856
890
|
}
|
|
857
|
-
async performWeb3Method(id, url,
|
|
891
|
+
async performWeb3Method(id, url, _ref19, callback) {
|
|
858
892
|
let {
|
|
859
893
|
method,
|
|
860
894
|
params
|
|
861
|
-
} =
|
|
895
|
+
} = _ref19;
|
|
862
896
|
const provider = await this.getEvmProvider(url);
|
|
863
897
|
this.checkAndHandleProviderStatus(provider);
|
|
864
898
|
return new Promise((resolve, reject) => {
|
|
@@ -894,11 +928,11 @@ class KoniTabs {
|
|
|
894
928
|
const allowedAccounts = await this.getEvmCurrentAccount(url);
|
|
895
929
|
return !!allowedAccounts.find(acc => acc.toLowerCase() === address.toLowerCase());
|
|
896
930
|
}
|
|
897
|
-
async evmSign(id, url,
|
|
931
|
+
async evmSign(id, url, _ref20) {
|
|
898
932
|
let {
|
|
899
933
|
method,
|
|
900
934
|
params
|
|
901
|
-
} =
|
|
935
|
+
} = _ref20;
|
|
902
936
|
const signResult = await this.#koniState.evmSign(id, url, method, params);
|
|
903
937
|
if (signResult) {
|
|
904
938
|
return signResult;
|
|
@@ -906,10 +940,12 @@ class KoniTabs {
|
|
|
906
940
|
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, 'Failed to sign message');
|
|
907
941
|
}
|
|
908
942
|
}
|
|
909
|
-
|
|
943
|
+
|
|
944
|
+
// TODO: Update logic
|
|
945
|
+
async evmSendTransaction(id, url, _ref21) {
|
|
910
946
|
let {
|
|
911
947
|
params
|
|
912
|
-
} =
|
|
948
|
+
} = _ref21;
|
|
913
949
|
const transactionParams = params[0];
|
|
914
950
|
const transactionHash = await this.#koniState.evmSendTransaction(id, url, transactionParams);
|
|
915
951
|
if (!transactionHash) {
|
|
@@ -946,7 +982,7 @@ class KoniTabs {
|
|
|
946
982
|
case 'wallet_requestPermissions':
|
|
947
983
|
await this.authorizeV2(url, {
|
|
948
984
|
origin: '',
|
|
949
|
-
|
|
985
|
+
accountAuthTypes: ['evm'],
|
|
950
986
|
reConfirm: true
|
|
951
987
|
});
|
|
952
988
|
return await this.getEvmPermission(url, id);
|
|
@@ -995,11 +1031,11 @@ class KoniTabs {
|
|
|
995
1031
|
isEvmPublicRequest(type, request) {
|
|
996
1032
|
return type === 'evm(request)' && ['eth_chainId', 'net_version', 'wallet_requestPermissions', 'wallet_getPermissions'].includes(request === null || request === void 0 ? void 0 : request.method) || type === 'evm(events.subscribe)';
|
|
997
1033
|
}
|
|
998
|
-
async addPspToken(id, url,
|
|
1034
|
+
async addPspToken(id, url, _ref22) {
|
|
999
1035
|
let {
|
|
1000
1036
|
genesisHash,
|
|
1001
1037
|
tokenInfo: input
|
|
1002
|
-
} =
|
|
1038
|
+
} = _ref22;
|
|
1003
1039
|
const _tokenType = input.type;
|
|
1004
1040
|
if (_tokenType !== 'psp22' && _tokenType !== 'psp34') {
|
|
1005
1041
|
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, 'Assets type {{tokenType}} is not supported'.replace('{{tokenType}}', _tokenType));
|
|
@@ -1100,7 +1136,7 @@ class KoniTabs {
|
|
|
1100
1136
|
case 'pub(accounts.listV2)':
|
|
1101
1137
|
return this.accountsListV2(url, request);
|
|
1102
1138
|
case 'pub(accounts.subscribeV2)':
|
|
1103
|
-
return this.
|
|
1139
|
+
return this.accountsSubstrateSubscribeV2(url, request, id, port);
|
|
1104
1140
|
case 'pub(accounts.unsubscribe)':
|
|
1105
1141
|
return this.accountsUnsubscribe(url, request);
|
|
1106
1142
|
case 'evm(events.subscribe)':
|
|
@@ -49,7 +49,7 @@ class KoniSubscription {
|
|
|
49
49
|
async start() {
|
|
50
50
|
var _this$state$keyringSe;
|
|
51
51
|
await Promise.all([this.state.eventService.waitCryptoReady, this.state.eventService.waitKeyringReady, this.state.eventService.waitAssetReady]);
|
|
52
|
-
const currentAddress = (_this$state$keyringSe = this.state.keyringService.currentAccount) === null || _this$state$keyringSe === void 0 ? void 0 : _this$state$keyringSe.
|
|
52
|
+
const currentAddress = (_this$state$keyringSe = this.state.keyringService.context.currentAccount) === null || _this$state$keyringSe === void 0 ? void 0 : _this$state$keyringSe.proxyId;
|
|
53
53
|
if (currentAddress) {
|
|
54
54
|
this.subscribeCrowdloans(currentAddress, this.state.getSubstrateApiMap());
|
|
55
55
|
}
|
|
@@ -60,7 +60,7 @@ class KoniSubscription {
|
|
|
60
60
|
if (!needReload) {
|
|
61
61
|
return;
|
|
62
62
|
}
|
|
63
|
-
const address = (_serviceInfo$currentA = serviceInfo.currentAccountInfo) === null || _serviceInfo$currentA === void 0 ? void 0 : _serviceInfo$currentA.
|
|
63
|
+
const address = (_serviceInfo$currentA = serviceInfo.currentAccountInfo) === null || _serviceInfo$currentA === void 0 ? void 0 : _serviceInfo$currentA.proxyId;
|
|
64
64
|
if (!address) {
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
@@ -77,7 +77,7 @@ class KoniSubscription {
|
|
|
77
77
|
return Promise.resolve();
|
|
78
78
|
}
|
|
79
79
|
subscribeCrowdloans(address, substrateApiMap, onlyRunOnFirstTime) {
|
|
80
|
-
const addresses = this.state.getDecodedAddresses(address);
|
|
80
|
+
const addresses = this.state.keyringService.context.getDecodedAddresses(address);
|
|
81
81
|
if (!addresses.length) {
|
|
82
82
|
return;
|
|
83
83
|
}
|
|
@@ -98,7 +98,7 @@ class KoniSubscription {
|
|
|
98
98
|
};
|
|
99
99
|
}
|
|
100
100
|
subscribeNft(address, substrateApiMap, evmApiMap, smartContractNfts, chainInfoMap) {
|
|
101
|
-
const addresses = this.state.getDecodedAddresses(address);
|
|
101
|
+
const addresses = this.state.keyringService.context.getDecodedAddresses(address);
|
|
102
102
|
if (!addresses.length) {
|
|
103
103
|
return;
|
|
104
104
|
}
|
|
@@ -118,7 +118,7 @@ class KoniSubscription {
|
|
|
118
118
|
}
|
|
119
119
|
async reloadCrowdloan() {
|
|
120
120
|
var _this$state$keyringSe2;
|
|
121
|
-
const currentAddress = (_this$state$keyringSe2 = this.state.keyringService.currentAccount) === null || _this$state$keyringSe2 === void 0 ? void 0 : _this$state$keyringSe2.
|
|
121
|
+
const currentAddress = (_this$state$keyringSe2 = this.state.keyringService.context.currentAccount) === null || _this$state$keyringSe2 === void 0 ? void 0 : _this$state$keyringSe2.proxyId;
|
|
122
122
|
this.subscribeCrowdloans(currentAddress, this.state.getSubstrateApiMap());
|
|
123
123
|
await (0, _utils.waitTimeout)(1800);
|
|
124
124
|
}
|
package/cjs/packageInfo.js
CHANGED
package/cjs/page/Accounts.js
CHANGED
|
@@ -15,15 +15,12 @@ class Accounts {
|
|
|
15
15
|
}
|
|
16
16
|
get(anyType) {
|
|
17
17
|
return sendRequest('pub(accounts.listV2)', {
|
|
18
|
-
anyType
|
|
19
|
-
accountAuthType: 'substrate'
|
|
18
|
+
anyType
|
|
20
19
|
});
|
|
21
20
|
}
|
|
22
21
|
subscribe(cb) {
|
|
23
22
|
let id = null;
|
|
24
|
-
sendRequest('pub(accounts.subscribeV2)', {
|
|
25
|
-
accountAuthType: 'substrate'
|
|
26
|
-
}, cb).then(subId => {
|
|
23
|
+
sendRequest('pub(accounts.subscribeV2)', {}, cb).then(subId => {
|
|
27
24
|
id = subId;
|
|
28
25
|
}).catch(console.error);
|
|
29
26
|
return () => {
|
|
@@ -88,7 +88,7 @@ class SubWalletEvmProvider extends _safeEventEmitter.default {
|
|
|
88
88
|
const origin = document.title !== '' ? document.title : window.location.hostname;
|
|
89
89
|
this.sendMessage('pub(authorize.tabV2)', {
|
|
90
90
|
origin,
|
|
91
|
-
|
|
91
|
+
accountAuthTypes: ['evm']
|
|
92
92
|
}).then(() => {
|
|
93
93
|
// Return account list
|
|
94
94
|
this.request({
|
package/cjs/page/index.js
CHANGED
|
@@ -43,9 +43,10 @@ function sendMessage(message, request, subscriber) {
|
|
|
43
43
|
// the enable function, called by the dapp to allow access
|
|
44
44
|
|
|
45
45
|
async function enable(origin, opt) {
|
|
46
|
+
const accountAuthTypes = (opt === null || opt === void 0 ? void 0 : opt.accountAuthType) === 'both' ? ['substrate', 'evm'] : [(opt === null || opt === void 0 ? void 0 : opt.accountAuthType) || 'substrate'];
|
|
46
47
|
await sendMessage('pub(authorize.tabV2)', {
|
|
47
48
|
origin,
|
|
48
|
-
|
|
49
|
+
accountAuthTypes
|
|
49
50
|
});
|
|
50
51
|
return new _Injected.default(sendMessage);
|
|
51
52
|
}
|