@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
package/utils/index.js
CHANGED
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { CrowdloanParaState } from '@subwallet/extension-base/background/KoniTypes';
|
|
5
|
-
import { ALL_ACCOUNT_KEY } from '@subwallet/extension-base/constants';
|
|
6
5
|
import { getRandomIpfsGateway, SUBWALLET_IPFS } from '@subwallet/extension-base/koni/api/nft/config';
|
|
6
|
+
import { _isChainEvmCompatible, _isChainSubstrateCompatible, _isChainTonCompatible } from '@subwallet/extension-base/services/chain-service/utils';
|
|
7
|
+
import { reformatAddress } from '@subwallet/extension-base/utils/account';
|
|
8
|
+
import { decodeAddress, encodeAddress, isTonAddress } from '@subwallet/keyring';
|
|
7
9
|
import { t } from 'i18next';
|
|
8
10
|
import { assert, BN, hexToU8a, isHex } from '@polkadot/util';
|
|
9
|
-
import {
|
|
11
|
+
import { ethereumEncode, isEthereumAddress } from '@polkadot/util-crypto';
|
|
10
12
|
export { canDerive } from "./canDerive.js";
|
|
11
13
|
export * from "./mv3.js";
|
|
12
14
|
export * from "./fetch.js";
|
|
@@ -14,33 +16,10 @@ export const notDef = x => x === null || typeof x === 'undefined';
|
|
|
14
16
|
export const isDef = x => !notDef(x);
|
|
15
17
|
export const nonEmptyArr = x => Array.isArray(x) && x.length > 0;
|
|
16
18
|
export const isEmptyArray = x => !Array.isArray(x) || Array.isArray(x) && x.length === 0;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
try {
|
|
22
|
-
if (!address || address === '') {
|
|
23
|
-
return '';
|
|
24
|
-
}
|
|
25
|
-
if (isEthereumAddress(address)) {
|
|
26
|
-
return address;
|
|
27
|
-
}
|
|
28
|
-
if (isAccountAll(address)) {
|
|
29
|
-
return address;
|
|
30
|
-
}
|
|
31
|
-
const publicKey = decodeAddress(address);
|
|
32
|
-
if (isEthereum) {
|
|
33
|
-
return ethereumEncode(publicKey);
|
|
34
|
-
}
|
|
35
|
-
if (networkPrefix < 0) {
|
|
36
|
-
return address;
|
|
37
|
-
}
|
|
38
|
-
return encodeAddress(publicKey, networkPrefix);
|
|
39
|
-
} catch (e) {
|
|
40
|
-
console.warn('Get error while reformat address', address, e);
|
|
41
|
-
return address;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @deprecated
|
|
22
|
+
* */
|
|
44
23
|
export function filterAddressByNetworkKey(addresses, networkKey, isEthereum) {
|
|
45
24
|
if (isEthereum) {
|
|
46
25
|
return addresses.filter(address => {
|
|
@@ -52,23 +31,10 @@ export function filterAddressByNetworkKey(addresses, networkKey, isEthereum) {
|
|
|
52
31
|
});
|
|
53
32
|
}
|
|
54
33
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if (isEthereumAddress(address)) {
|
|
60
|
-
evmAddresses.push(address);
|
|
61
|
-
} else {
|
|
62
|
-
substrateAddresses.push(address);
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
return [substrateAddresses, evmAddresses];
|
|
66
|
-
}
|
|
67
|
-
export function categoryNetworks(networks) {
|
|
68
|
-
const substrateAddresses = [];
|
|
69
|
-
const evmAddresses = [];
|
|
70
|
-
return [substrateAddresses, evmAddresses];
|
|
71
|
-
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @deprecated
|
|
37
|
+
* */
|
|
72
38
|
export function convertToEvmAddress(substrateAddress) {
|
|
73
39
|
const addressBytes = decodeAddress(substrateAddress);
|
|
74
40
|
return ethereumEncode('0x' + Buffer.from(addressBytes.subarray(0, 20)).toString('hex'));
|
|
@@ -277,6 +243,20 @@ export function isSameAddress(address1, address2) {
|
|
|
277
243
|
return reformatAddress(address1, 0) === reformatAddress(address2, 0); // TODO: maybe there's a better way
|
|
278
244
|
}
|
|
279
245
|
|
|
246
|
+
export function isSameAddressType(address1, address2) {
|
|
247
|
+
const isSameEvmAddress = isEthereumAddress(address1) && isEthereumAddress(address2);
|
|
248
|
+
const isSameTonAddress = isTonAddress(address1) && isTonAddress(address2);
|
|
249
|
+
const isSameSubstrateAddress = !isEthereumAddress(address1) && !isTonAddress(address1) && !isEthereumAddress(address2) && !isTonAddress(address2); // todo: need isSubstrateAddress util function to check exactly
|
|
250
|
+
|
|
251
|
+
return isSameEvmAddress || isSameTonAddress || isSameSubstrateAddress;
|
|
252
|
+
}
|
|
253
|
+
export function isAddressAndChainCompatible(address, chain) {
|
|
254
|
+
const isEvmCompatible = isEthereumAddress(address) && _isChainEvmCompatible(chain);
|
|
255
|
+
const isTonCompatible = isTonAddress(address) && _isChainTonCompatible(chain);
|
|
256
|
+
const isSubstrateCompatible = !isEthereumAddress(address) && !isTonAddress(address) && _isChainSubstrateCompatible(chain); // todo: need isSubstrateAddress util function to check exactly
|
|
257
|
+
|
|
258
|
+
return isEvmCompatible || isSubstrateCompatible || isTonCompatible;
|
|
259
|
+
}
|
|
280
260
|
export function getDomainFromUrl(url) {
|
|
281
261
|
return url.replace(/^(https?:\/\/)?(www\.)?/, '').split('/')[0];
|
|
282
262
|
}
|
|
@@ -344,9 +324,10 @@ export function wait(milliseconds) {
|
|
|
344
324
|
}, milliseconds);
|
|
345
325
|
});
|
|
346
326
|
}
|
|
347
|
-
export * from "./account.js";
|
|
327
|
+
export * from "./account/index.js";
|
|
348
328
|
export * from "./array.js";
|
|
349
329
|
export * from "./asset.js";
|
|
330
|
+
export * from "./auth.js";
|
|
350
331
|
export * from "./environment.js";
|
|
351
332
|
export * from "./eth.js";
|
|
352
333
|
export * from "./fetchEvmChainInfo.js";
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
// Copyright 2017-2022 @polkadot/react-signer authors & contributors
|
|
8
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
9
|
-
|
|
10
|
-
let id = 1;
|
|
11
|
-
class KeyringSigner {
|
|
12
|
-
#pair;
|
|
13
|
-
#registry;
|
|
14
|
-
constructor(_ref) {
|
|
15
|
-
let {
|
|
16
|
-
keyPair,
|
|
17
|
-
registry
|
|
18
|
-
} = _ref;
|
|
19
|
-
this.#pair = keyPair;
|
|
20
|
-
this.#registry = registry;
|
|
21
|
-
}
|
|
22
|
-
async signPayload(payload) {
|
|
23
|
-
return new Promise(resolve => {
|
|
24
|
-
const wrapper = this.#registry.createType('ExtrinsicPayload', payload, {
|
|
25
|
-
version: payload.version
|
|
26
|
-
});
|
|
27
|
-
const signature = wrapper.sign(this.#pair).signature;
|
|
28
|
-
resolve({
|
|
29
|
-
id: id++,
|
|
30
|
-
signature: signature
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
exports.default = KeyringSigner;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
8
|
-
var _util = require("@polkadot/util");
|
|
9
|
-
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
10
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
11
|
-
|
|
12
|
-
class LedgerSigner {
|
|
13
|
-
#registry;
|
|
14
|
-
#callback;
|
|
15
|
-
#setState;
|
|
16
|
-
#id;
|
|
17
|
-
constructor(registry, callback, id, setState) {
|
|
18
|
-
this.#registry = registry;
|
|
19
|
-
this.#callback = callback;
|
|
20
|
-
this.#id = id;
|
|
21
|
-
this.#setState = setState;
|
|
22
|
-
}
|
|
23
|
-
async signPayload(payload) {
|
|
24
|
-
return new Promise((resolve, reject) => {
|
|
25
|
-
const raw = this.#registry.createType('ExtrinsicPayload', payload, {
|
|
26
|
-
version: payload.version
|
|
27
|
-
});
|
|
28
|
-
const ledgerPayload = raw.toU8a(true);
|
|
29
|
-
this.#setState({
|
|
30
|
-
reject: reject,
|
|
31
|
-
resolve: resolve,
|
|
32
|
-
status: _KoniTypes.ExternalRequestPromiseStatus.PENDING,
|
|
33
|
-
createdAt: new Date().getTime()
|
|
34
|
-
});
|
|
35
|
-
this.#callback({
|
|
36
|
-
ledgerState: {
|
|
37
|
-
ledgerPayload: (0, _util.u8aToHex)(ledgerPayload),
|
|
38
|
-
ledgerId: this.#id
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
exports.default = LedgerSigner;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
8
|
-
var _util = require("@polkadot/util");
|
|
9
|
-
var _utilCrypto = require("@polkadot/util-crypto");
|
|
10
|
-
// Copyright 2017-2022 @polkadot/react-signer authors & contributors
|
|
11
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
12
|
-
|
|
13
|
-
class QrSigner {
|
|
14
|
-
#callback;
|
|
15
|
-
#id;
|
|
16
|
-
#registry;
|
|
17
|
-
#resolver;
|
|
18
|
-
#setState;
|
|
19
|
-
constructor(_ref) {
|
|
20
|
-
let {
|
|
21
|
-
callback,
|
|
22
|
-
id,
|
|
23
|
-
registry,
|
|
24
|
-
resolver,
|
|
25
|
-
setState
|
|
26
|
-
} = _ref;
|
|
27
|
-
this.#callback = callback;
|
|
28
|
-
this.#id = id;
|
|
29
|
-
this.#registry = registry;
|
|
30
|
-
this.#resolver = resolver;
|
|
31
|
-
this.#setState = setState;
|
|
32
|
-
}
|
|
33
|
-
async signPayload(payload) {
|
|
34
|
-
return new Promise((resolve, reject) => {
|
|
35
|
-
// limit size of the transaction
|
|
36
|
-
const isQrHashed = payload.method.length > 5000;
|
|
37
|
-
const wrapper = this.#registry.createType('ExtrinsicPayload', payload, {
|
|
38
|
-
version: payload.version
|
|
39
|
-
});
|
|
40
|
-
const qrPayload = isQrHashed ? (0, _utilCrypto.blake2AsU8a)(wrapper.toU8a(true)) : wrapper.toU8a();
|
|
41
|
-
const resolver = result => {
|
|
42
|
-
this.#resolver();
|
|
43
|
-
resolve(result);
|
|
44
|
-
};
|
|
45
|
-
this.#setState({
|
|
46
|
-
reject: reject,
|
|
47
|
-
resolve: resolver,
|
|
48
|
-
status: _KoniTypes.ExternalRequestPromiseStatus.PENDING,
|
|
49
|
-
createdAt: new Date().getTime()
|
|
50
|
-
});
|
|
51
|
-
this.#callback({
|
|
52
|
-
qrState: {
|
|
53
|
-
isQrHashed,
|
|
54
|
-
qrAddress: payload.address,
|
|
55
|
-
qrPayload: (0, _util.u8aToHex)(qrPayload),
|
|
56
|
-
qrId: this.#id,
|
|
57
|
-
isEthereum: false
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
exports.default = QrSigner;
|
package/cjs/signers/types.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.SignerType = void 0;
|
|
7
|
-
// Copyright 2019-2022 @polkadot/extension-koni authors & contributors
|
|
8
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
9
|
-
let SignerType;
|
|
10
|
-
exports.SignerType = SignerType;
|
|
11
|
-
(function (SignerType) {
|
|
12
|
-
SignerType["PASSWORD"] = "PASSWORD";
|
|
13
|
-
SignerType["QR"] = "QR";
|
|
14
|
-
SignerType["LEDGER"] = "LEDGER";
|
|
15
|
-
})(SignerType || (exports.SignerType = SignerType = {}));
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
8
|
-
var _ethereumjsUtil = require("ethereumjs-util");
|
|
9
|
-
var _ethers = require("ethers");
|
|
10
|
-
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
11
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
12
|
-
|
|
13
|
-
class QrSigner {
|
|
14
|
-
#callback;
|
|
15
|
-
#id;
|
|
16
|
-
#resolver;
|
|
17
|
-
#setState;
|
|
18
|
-
constructor(_ref) {
|
|
19
|
-
let {
|
|
20
|
-
callback,
|
|
21
|
-
id,
|
|
22
|
-
resolver,
|
|
23
|
-
setState
|
|
24
|
-
} = _ref;
|
|
25
|
-
this.#callback = callback;
|
|
26
|
-
this.#id = id;
|
|
27
|
-
this.#resolver = resolver;
|
|
28
|
-
this.#setState = setState;
|
|
29
|
-
}
|
|
30
|
-
async signTransaction(tx) {
|
|
31
|
-
return new Promise((resolve, reject) => {
|
|
32
|
-
var _tx$nonce;
|
|
33
|
-
const txObject = {
|
|
34
|
-
nonce: (_tx$nonce = tx.nonce) !== null && _tx$nonce !== void 0 ? _tx$nonce : 0,
|
|
35
|
-
gasPrice: (0, _ethereumjsUtil.addHexPrefix)(tx.gasPrice.toString(16)),
|
|
36
|
-
maxPriorityFeePerGas: (0, _ethereumjsUtil.addHexPrefix)(tx.maxPriorityFeePerGas.toString(16)),
|
|
37
|
-
maxFeePerGas: (0, _ethereumjsUtil.addHexPrefix)(tx.maxFeePerGas.toString(16)),
|
|
38
|
-
gasLimit: (0, _ethereumjsUtil.addHexPrefix)(tx.gasLimit.toString(16)),
|
|
39
|
-
to: tx.to !== undefined ? tx.to : '',
|
|
40
|
-
value: (0, _ethereumjsUtil.addHexPrefix)(tx.value.toString(16)),
|
|
41
|
-
data: tx.data,
|
|
42
|
-
chainId: tx.chainId
|
|
43
|
-
};
|
|
44
|
-
const qrPayload = _ethers.ethers.Transaction.from(txObject).unsignedSerialized;
|
|
45
|
-
const resolver = result => {
|
|
46
|
-
this.#resolver();
|
|
47
|
-
resolve(result);
|
|
48
|
-
};
|
|
49
|
-
this.#setState({
|
|
50
|
-
reject: reject,
|
|
51
|
-
resolve: resolver,
|
|
52
|
-
status: _KoniTypes.ExternalRequestPromiseStatus.PENDING,
|
|
53
|
-
createdAt: new Date().getTime()
|
|
54
|
-
});
|
|
55
|
-
this.#callback({
|
|
56
|
-
qrState: {
|
|
57
|
-
isQrHashed: false,
|
|
58
|
-
qrAddress: tx.from,
|
|
59
|
-
qrPayload: qrPayload,
|
|
60
|
-
qrId: this.#id,
|
|
61
|
-
isEthereum: true
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
exports.default = QrSigner;
|
package/cjs/utils/account.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.convertSubjectInfoToAddresses = void 0;
|
|
7
|
-
exports.quickFormatAddressToCompare = quickFormatAddressToCompare;
|
|
8
|
-
exports.simpleAddress = void 0;
|
|
9
|
-
var _index = require("@subwallet/extension-base/utils/index");
|
|
10
|
-
var _utilCrypto = require("@polkadot/util-crypto");
|
|
11
|
-
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
12
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
13
|
-
|
|
14
|
-
const simpleAddress = address => {
|
|
15
|
-
if ((0, _utilCrypto.isEthereumAddress)(address)) {
|
|
16
|
-
return address;
|
|
17
|
-
}
|
|
18
|
-
return (0, _utilCrypto.encodeAddress)((0, _utilCrypto.decodeAddress)(address));
|
|
19
|
-
};
|
|
20
|
-
exports.simpleAddress = simpleAddress;
|
|
21
|
-
function quickFormatAddressToCompare(address) {
|
|
22
|
-
if (!(0, _utilCrypto.isAddress)(address)) {
|
|
23
|
-
return address;
|
|
24
|
-
}
|
|
25
|
-
return (0, _index.reformatAddress)(address, 42).toLowerCase();
|
|
26
|
-
}
|
|
27
|
-
const convertSubjectInfoToAddresses = subjectInfo => {
|
|
28
|
-
return Object.values(subjectInfo).map(info => ({
|
|
29
|
-
address: info.json.address,
|
|
30
|
-
type: info.type,
|
|
31
|
-
...info.json.meta
|
|
32
|
-
}));
|
|
33
|
-
};
|
|
34
|
-
exports.convertSubjectInfoToAddresses = convertSubjectInfoToAddresses;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Signer, SignerResult } from '@polkadot/api/types';
|
|
2
|
-
import type { Registry, SignerPayloadJSON } from '@polkadot/types/types';
|
|
3
|
-
import { KeyringPair } from '@subwallet/keyring/types';
|
|
4
|
-
interface KeyringSignerProps {
|
|
5
|
-
registry: Registry;
|
|
6
|
-
keyPair: KeyringPair;
|
|
7
|
-
}
|
|
8
|
-
export default class KeyringSigner implements Signer {
|
|
9
|
-
#private;
|
|
10
|
-
constructor({ keyPair, registry }: KeyringSignerProps);
|
|
11
|
-
signPayload(payload: SignerPayloadJSON): Promise<SignerResult>;
|
|
12
|
-
}
|
|
13
|
-
export {};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
// Copyright 2017-2022 @polkadot/react-signer authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
let id = 1;
|
|
5
|
-
export default class KeyringSigner {
|
|
6
|
-
#pair;
|
|
7
|
-
#registry;
|
|
8
|
-
constructor({
|
|
9
|
-
keyPair,
|
|
10
|
-
registry
|
|
11
|
-
}) {
|
|
12
|
-
this.#pair = keyPair;
|
|
13
|
-
this.#registry = registry;
|
|
14
|
-
}
|
|
15
|
-
async signPayload(payload) {
|
|
16
|
-
return new Promise(resolve => {
|
|
17
|
-
const wrapper = this.#registry.createType('ExtrinsicPayload', payload, {
|
|
18
|
-
version: payload.version
|
|
19
|
-
});
|
|
20
|
-
const signature = wrapper.sign(this.#pair).signature;
|
|
21
|
-
resolve({
|
|
22
|
-
id: id++,
|
|
23
|
-
signature: signature
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Signer, SignerResult } from '@polkadot/api/types';
|
|
2
|
-
import type { Registry, SignerPayloadJSON } from '@polkadot/types/types';
|
|
3
|
-
import { ExternalRequestPromise } from '@subwallet/extension-base/background/KoniTypes';
|
|
4
|
-
import { LedgerState } from '@subwallet/extension-base/signers/types';
|
|
5
|
-
interface CallbackProps {
|
|
6
|
-
ledgerState: LedgerState;
|
|
7
|
-
}
|
|
8
|
-
export default class LedgerSigner implements Signer {
|
|
9
|
-
#private;
|
|
10
|
-
constructor(registry: Registry, callback: (state: CallbackProps) => void, id: string, setState: (promise: ExternalRequestPromise) => void);
|
|
11
|
-
signPayload(payload: SignerPayloadJSON): Promise<SignerResult>;
|
|
12
|
-
}
|
|
13
|
-
export {};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
import { ExternalRequestPromiseStatus } from '@subwallet/extension-base/background/KoniTypes';
|
|
5
|
-
import { u8aToHex } from '@polkadot/util';
|
|
6
|
-
export default class LedgerSigner {
|
|
7
|
-
#registry;
|
|
8
|
-
#callback;
|
|
9
|
-
#setState;
|
|
10
|
-
#id;
|
|
11
|
-
constructor(registry, callback, id, setState) {
|
|
12
|
-
this.#registry = registry;
|
|
13
|
-
this.#callback = callback;
|
|
14
|
-
this.#id = id;
|
|
15
|
-
this.#setState = setState;
|
|
16
|
-
}
|
|
17
|
-
async signPayload(payload) {
|
|
18
|
-
return new Promise((resolve, reject) => {
|
|
19
|
-
const raw = this.#registry.createType('ExtrinsicPayload', payload, {
|
|
20
|
-
version: payload.version
|
|
21
|
-
});
|
|
22
|
-
const ledgerPayload = raw.toU8a(true);
|
|
23
|
-
this.#setState({
|
|
24
|
-
reject: reject,
|
|
25
|
-
resolve: resolve,
|
|
26
|
-
status: ExternalRequestPromiseStatus.PENDING,
|
|
27
|
-
createdAt: new Date().getTime()
|
|
28
|
-
});
|
|
29
|
-
this.#callback({
|
|
30
|
-
ledgerState: {
|
|
31
|
-
ledgerPayload: u8aToHex(ledgerPayload),
|
|
32
|
-
ledgerId: this.#id
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { Signer, SignerResult } from '@polkadot/api/types';
|
|
2
|
-
import type { Registry, SignerPayloadJSON } from '@polkadot/types/types';
|
|
3
|
-
import { ExternalRequestPromise } from '@subwallet/extension-base/background/KoniTypes';
|
|
4
|
-
import { QrState } from '@subwallet/extension-base/signers/types';
|
|
5
|
-
interface CallbackProps {
|
|
6
|
-
qrState: QrState;
|
|
7
|
-
}
|
|
8
|
-
interface QrSignerProps {
|
|
9
|
-
registry: Registry;
|
|
10
|
-
callback: (state: CallbackProps) => void;
|
|
11
|
-
id: string;
|
|
12
|
-
setState: (promise: ExternalRequestPromise) => void;
|
|
13
|
-
resolver: () => void;
|
|
14
|
-
}
|
|
15
|
-
export default class QrSigner implements Signer {
|
|
16
|
-
#private;
|
|
17
|
-
constructor({ callback, id, registry, resolver, setState }: QrSignerProps);
|
|
18
|
-
signPayload(payload: SignerPayloadJSON): Promise<SignerResult>;
|
|
19
|
-
}
|
|
20
|
-
export {};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
// Copyright 2017-2022 @polkadot/react-signer authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
import { ExternalRequestPromiseStatus } from '@subwallet/extension-base/background/KoniTypes';
|
|
5
|
-
import { u8aToHex } from '@polkadot/util';
|
|
6
|
-
import { blake2AsU8a } from '@polkadot/util-crypto';
|
|
7
|
-
export default class QrSigner {
|
|
8
|
-
#callback;
|
|
9
|
-
#id;
|
|
10
|
-
#registry;
|
|
11
|
-
#resolver;
|
|
12
|
-
#setState;
|
|
13
|
-
constructor({
|
|
14
|
-
callback,
|
|
15
|
-
id,
|
|
16
|
-
registry,
|
|
17
|
-
resolver,
|
|
18
|
-
setState
|
|
19
|
-
}) {
|
|
20
|
-
this.#callback = callback;
|
|
21
|
-
this.#id = id;
|
|
22
|
-
this.#registry = registry;
|
|
23
|
-
this.#resolver = resolver;
|
|
24
|
-
this.#setState = setState;
|
|
25
|
-
}
|
|
26
|
-
async signPayload(payload) {
|
|
27
|
-
return new Promise((resolve, reject) => {
|
|
28
|
-
// limit size of the transaction
|
|
29
|
-
const isQrHashed = payload.method.length > 5000;
|
|
30
|
-
const wrapper = this.#registry.createType('ExtrinsicPayload', payload, {
|
|
31
|
-
version: payload.version
|
|
32
|
-
});
|
|
33
|
-
const qrPayload = isQrHashed ? blake2AsU8a(wrapper.toU8a(true)) : wrapper.toU8a();
|
|
34
|
-
const resolver = result => {
|
|
35
|
-
this.#resolver();
|
|
36
|
-
resolve(result);
|
|
37
|
-
};
|
|
38
|
-
this.#setState({
|
|
39
|
-
reject: reject,
|
|
40
|
-
resolve: resolver,
|
|
41
|
-
status: ExternalRequestPromiseStatus.PENDING,
|
|
42
|
-
createdAt: new Date().getTime()
|
|
43
|
-
});
|
|
44
|
-
this.#callback({
|
|
45
|
-
qrState: {
|
|
46
|
-
isQrHashed,
|
|
47
|
-
qrAddress: payload.address,
|
|
48
|
-
qrPayload: u8aToHex(qrPayload),
|
|
49
|
-
qrId: this.#id,
|
|
50
|
-
isEthereum: false
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
}
|
package/signers/types.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
export interface QrState {
|
|
2
|
-
isQrHashed: boolean;
|
|
3
|
-
qrAddress: string;
|
|
4
|
-
qrPayload: `0x${string}`;
|
|
5
|
-
qrId: string;
|
|
6
|
-
isEthereum: boolean;
|
|
7
|
-
}
|
|
8
|
-
export interface Web3TransactionBase {
|
|
9
|
-
to?: string;
|
|
10
|
-
gasPrice: number;
|
|
11
|
-
maxFeePerGas: number;
|
|
12
|
-
maxPriorityFeePerGas: number;
|
|
13
|
-
gasLimit: number;
|
|
14
|
-
nonce: number;
|
|
15
|
-
chainId: number;
|
|
16
|
-
data?: string;
|
|
17
|
-
value: number;
|
|
18
|
-
}
|
|
19
|
-
export interface Web3Transaction extends Web3TransactionBase {
|
|
20
|
-
from: string;
|
|
21
|
-
}
|
|
22
|
-
export interface LedgerState {
|
|
23
|
-
ledgerPayload: `0x${string}`;
|
|
24
|
-
ledgerId: string;
|
|
25
|
-
}
|
|
26
|
-
export interface ExternalState {
|
|
27
|
-
externalId: string;
|
|
28
|
-
}
|
|
29
|
-
export declare enum SignerType {
|
|
30
|
-
PASSWORD = "PASSWORD",
|
|
31
|
-
QR = "QR",
|
|
32
|
-
LEDGER = "LEDGER"
|
|
33
|
-
}
|
|
34
|
-
export declare type SignerExternal = SignerType.LEDGER | SignerType.QR;
|
package/signers/types.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// Copyright 2019-2022 @polkadot/extension-koni authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
export let SignerType;
|
|
5
|
-
(function (SignerType) {
|
|
6
|
-
SignerType["PASSWORD"] = "PASSWORD";
|
|
7
|
-
SignerType["QR"] = "QR";
|
|
8
|
-
SignerType["LEDGER"] = "LEDGER";
|
|
9
|
-
})(SignerType || (SignerType = {}));
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { ExternalRequestPromise } from '@subwallet/extension-base/background/KoniTypes';
|
|
2
|
-
import { QrState, Web3Transaction } from '@subwallet/extension-base/signers/types';
|
|
3
|
-
import { SignerResult } from '@polkadot/api/types';
|
|
4
|
-
interface CallbackProps {
|
|
5
|
-
qrState: QrState;
|
|
6
|
-
}
|
|
7
|
-
interface QrSignerProps {
|
|
8
|
-
callback: (state: CallbackProps) => void;
|
|
9
|
-
id: string;
|
|
10
|
-
setState: (promise: ExternalRequestPromise) => void;
|
|
11
|
-
resolver: () => void;
|
|
12
|
-
}
|
|
13
|
-
export default class QrSigner {
|
|
14
|
-
#private;
|
|
15
|
-
constructor({ callback, id, resolver, setState }: QrSignerProps);
|
|
16
|
-
signTransaction(tx: Web3Transaction): Promise<SignerResult>;
|
|
17
|
-
}
|
|
18
|
-
export {};
|
package/signers/web3/QrSigner.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
import { ExternalRequestPromiseStatus } from '@subwallet/extension-base/background/KoniTypes';
|
|
5
|
-
import { addHexPrefix } from 'ethereumjs-util';
|
|
6
|
-
import { ethers } from 'ethers';
|
|
7
|
-
export default class QrSigner {
|
|
8
|
-
#callback;
|
|
9
|
-
#id;
|
|
10
|
-
#resolver;
|
|
11
|
-
#setState;
|
|
12
|
-
constructor({
|
|
13
|
-
callback,
|
|
14
|
-
id,
|
|
15
|
-
resolver,
|
|
16
|
-
setState
|
|
17
|
-
}) {
|
|
18
|
-
this.#callback = callback;
|
|
19
|
-
this.#id = id;
|
|
20
|
-
this.#resolver = resolver;
|
|
21
|
-
this.#setState = setState;
|
|
22
|
-
}
|
|
23
|
-
async signTransaction(tx) {
|
|
24
|
-
return new Promise((resolve, reject) => {
|
|
25
|
-
var _tx$nonce;
|
|
26
|
-
const txObject = {
|
|
27
|
-
nonce: (_tx$nonce = tx.nonce) !== null && _tx$nonce !== void 0 ? _tx$nonce : 0,
|
|
28
|
-
gasPrice: addHexPrefix(tx.gasPrice.toString(16)),
|
|
29
|
-
maxPriorityFeePerGas: addHexPrefix(tx.maxPriorityFeePerGas.toString(16)),
|
|
30
|
-
maxFeePerGas: addHexPrefix(tx.maxFeePerGas.toString(16)),
|
|
31
|
-
gasLimit: addHexPrefix(tx.gasLimit.toString(16)),
|
|
32
|
-
to: tx.to !== undefined ? tx.to : '',
|
|
33
|
-
value: addHexPrefix(tx.value.toString(16)),
|
|
34
|
-
data: tx.data,
|
|
35
|
-
chainId: tx.chainId
|
|
36
|
-
};
|
|
37
|
-
const qrPayload = ethers.Transaction.from(txObject).unsignedSerialized;
|
|
38
|
-
const resolver = result => {
|
|
39
|
-
this.#resolver();
|
|
40
|
-
resolve(result);
|
|
41
|
-
};
|
|
42
|
-
this.#setState({
|
|
43
|
-
reject: reject,
|
|
44
|
-
resolve: resolver,
|
|
45
|
-
status: ExternalRequestPromiseStatus.PENDING,
|
|
46
|
-
createdAt: new Date().getTime()
|
|
47
|
-
});
|
|
48
|
-
this.#callback({
|
|
49
|
-
qrState: {
|
|
50
|
-
isQrHashed: false,
|
|
51
|
-
qrAddress: tx.from,
|
|
52
|
-
qrPayload: qrPayload,
|
|
53
|
-
qrId: this.#id,
|
|
54
|
-
isEthereum: true
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
}
|
package/types/transaction.d.ts
DELETED