@subwallet/extension-base 1.1.35-0 → 1.1.35-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/background/KoniTypes.d.ts +111 -69
- package/background/KoniTypes.js +19 -13
- package/background/errors/TransactionError.js +9 -0
- package/cjs/background/KoniTypes.js +20 -16
- package/cjs/background/errors/TransactionError.js +9 -0
- package/cjs/constants/index.js +19 -4
- package/cjs/koni/api/dotsama/balance.js +464 -0
- package/cjs/koni/api/nft/config.js +33 -23
- package/cjs/koni/api/nft/index.js +14 -0
- package/cjs/koni/api/nft/nft.js +1 -22
- package/cjs/koni/api/nft/ordinal_nft/constants.js +21 -0
- package/cjs/koni/api/nft/ordinal_nft/index.js +121 -0
- package/cjs/koni/api/nft/ordinal_nft/utils.js +41 -0
- package/cjs/koni/api/staking/bonding/amplitude.js +19 -16
- package/cjs/koni/api/staking/bonding/astar.js +11 -10
- package/cjs/koni/api/staking/bonding/index.js +4 -1
- package/cjs/koni/api/staking/bonding/paraChain.js +25 -23
- package/cjs/koni/api/staking/bonding/relayChain.js +48 -45
- package/cjs/koni/api/staking/bonding/utils.js +104 -86
- package/cjs/koni/api/staking/index.js +6 -5
- package/cjs/koni/api/staking/paraChain.js +6 -5
- package/cjs/koni/api/staking/relayChain.js +3 -2
- package/cjs/koni/api/yield/helper/utils.js +46 -0
- package/cjs/koni/background/cron.js +3 -21
- package/cjs/koni/background/handlers/Extension.js +368 -69
- package/cjs/koni/background/handlers/State.js +18 -12
- package/cjs/koni/background/handlers/index.js +4 -2
- package/cjs/koni/background/subscription.js +7 -104
- package/cjs/services/campaign-service/index.js +9 -6
- package/cjs/services/chain-service/constants.js +1 -16
- package/cjs/services/chain-service/index.js +6 -2
- package/cjs/services/chain-service/utils.js +7 -1
- package/cjs/services/earning-service/constants/chains.js +30 -0
- package/cjs/services/earning-service/constants/index.js +27 -0
- package/cjs/services/earning-service/constants/step.js +18 -0
- package/cjs/services/earning-service/handlers/base.js +262 -0
- package/cjs/services/earning-service/handlers/index.js +60 -0
- package/cjs/services/earning-service/handlers/lending/base.js +81 -0
- package/cjs/services/earning-service/handlers/lending/index.js +13 -0
- package/cjs/services/earning-service/handlers/lending/interlay.js +192 -0
- package/cjs/services/earning-service/handlers/liquid-staking/acala.js +240 -0
- package/cjs/services/earning-service/handlers/liquid-staking/base.js +97 -0
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost-manta.js +140 -0
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +298 -0
- package/cjs/services/earning-service/handlers/liquid-staking/index.js +34 -0
- package/cjs/services/earning-service/handlers/liquid-staking/parallel.js +227 -0
- package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +404 -0
- package/cjs/services/earning-service/handlers/native-staking/amplitude.js +434 -0
- package/cjs/services/earning-service/handlers/native-staking/astar.js +466 -0
- package/cjs/services/earning-service/handlers/native-staking/base-para.js +146 -0
- package/cjs/services/earning-service/handlers/native-staking/base.js +161 -0
- package/cjs/services/earning-service/handlers/native-staking/index.js +34 -0
- package/cjs/services/earning-service/handlers/native-staking/para-chain.js +390 -0
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +567 -0
- package/cjs/services/earning-service/handlers/nomination-pool/index.js +566 -0
- package/cjs/services/earning-service/handlers/special.js +493 -0
- package/cjs/services/earning-service/service.js +733 -0
- package/cjs/services/earning-service/utils/index.js +128 -0
- package/cjs/services/event-service/index.js +5 -0
- package/cjs/services/keyring-service/index.js +14 -2
- package/cjs/services/migration-service/scripts/DeleteEarningData.js +21 -0
- package/cjs/services/migration-service/scripts/EnableEarningChains.js +21 -0
- package/cjs/services/migration-service/scripts/MigrateEthProvider.js +17 -0
- package/cjs/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
- package/cjs/services/migration-service/scripts/MigratePioneerProvider.js +17 -0
- package/cjs/services/migration-service/scripts/MigrateProvider.js +29 -0
- package/cjs/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
- package/cjs/services/migration-service/scripts/databases/MigrateEarningHistory.js +21 -0
- package/cjs/services/migration-service/scripts/databases/MigrateEarningVersion.js +21 -0
- package/cjs/services/migration-service/scripts/index.js +6 -1
- package/cjs/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +149 -0
- package/cjs/services/mint-campaign-service/campaigns/index.js +13 -0
- package/cjs/services/mint-campaign-service/constants.js +11 -0
- package/cjs/services/mint-campaign-service/index.js +18 -0
- package/cjs/services/notification-service/NotificationService.js +3 -2
- package/cjs/services/request-service/handler/PopupHandler.js +2 -3
- package/cjs/services/storage-service/DatabaseService.js +63 -0
- package/cjs/services/storage-service/databases/index.js +4 -0
- package/cjs/services/storage-service/db-stores/NominatorMetadata.js +3 -3
- package/cjs/services/storage-service/db-stores/YieldPoolStore.js +36 -0
- package/cjs/services/storage-service/db-stores/YieldPositionStore.js +71 -0
- package/cjs/services/storage-service/index.js +241 -0
- package/cjs/services/subscan-service/index.js +16 -0
- package/cjs/services/transaction-service/event-parser/index.js +58 -0
- package/cjs/services/transaction-service/helpers/index.js +3 -1
- package/cjs/services/transaction-service/index.js +249 -75
- package/cjs/services/transaction-service/utils.js +1 -0
- package/cjs/types/campaigns/index.js +16 -0
- package/cjs/types/campaigns/unlock-dot.js +1 -0
- package/cjs/types/index.js +44 -0
- package/cjs/types/ordinal.js +1 -0
- package/cjs/types/transaction.js +1 -0
- package/cjs/types/yield/actions/index.js +27 -0
- package/cjs/types/yield/actions/join/index.js +38 -0
- package/cjs/types/yield/actions/join/step.js +47 -0
- package/cjs/types/yield/actions/join/submit.js +1 -0
- package/cjs/types/yield/actions/join/validate.js +16 -0
- package/cjs/types/yield/actions/others.js +1 -0
- package/cjs/types/yield/index.js +27 -0
- package/cjs/types/yield/info/account/index.js +49 -0
- package/cjs/types/yield/info/account/info.js +1 -0
- package/cjs/types/yield/info/account/reward.js +1 -0
- package/cjs/types/yield/info/account/target.js +32 -0
- package/cjs/types/yield/info/account/unstake.js +27 -0
- package/cjs/types/yield/info/base.js +41 -0
- package/cjs/types/yield/info/chain/index.js +27 -0
- package/cjs/types/yield/info/chain/info.js +1 -0
- package/cjs/types/yield/info/chain/target.js +1 -0
- package/cjs/types/yield/info/index.js +49 -0
- package/cjs/types/yield/info/pallet.js +15 -0
- package/cjs/types.js +1 -0
- package/cjs/utils/address.js +34 -0
- package/cjs/utils/environment.js +23 -28
- package/cjs/utils/fetchStaticCache.js +22 -0
- package/cjs/utils/fetchStaticData.js +2 -1
- package/cjs/utils/index.js +94 -10
- package/cjs/utils/keyring.js +57 -0
- package/cjs/utils/mv3.js +21 -0
- package/cjs/utils/number.js +6 -2
- package/cjs/utils/object.js +12 -0
- package/constants/index.d.ts +6 -1
- package/constants/index.js +6 -1
- package/koni/api/nft/config.js +33 -23
- package/koni/api/nft/index.js +15 -1
- package/koni/api/nft/nft.js +2 -23
- package/koni/api/nft/ordinal_nft/constants.d.ts +9 -0
- package/koni/api/nft/ordinal_nft/constants.js +12 -0
- package/koni/api/nft/ordinal_nft/index.d.ts +8 -0
- package/koni/api/nft/ordinal_nft/index.js +114 -0
- package/koni/api/nft/ordinal_nft/utils.d.ts +2 -0
- package/koni/api/nft/ordinal_nft/utils.js +33 -0
- package/koni/api/staking/bonding/amplitude.js +13 -10
- package/koni/api/staking/bonding/astar.js +9 -8
- package/koni/api/staking/bonding/index.d.ts +1 -1
- package/koni/api/staking/bonding/index.js +5 -1
- package/koni/api/staking/bonding/paraChain.js +12 -10
- package/koni/api/staking/bonding/relayChain.d.ts +2 -2
- package/koni/api/staking/bonding/relayChain.js +33 -30
- package/koni/api/staking/bonding/utils.d.ts +15 -38
- package/koni/api/staking/bonding/utils.js +85 -69
- package/koni/api/staking/index.js +2 -1
- package/koni/api/staking/paraChain.js +7 -6
- package/koni/api/staking/relayChain.js +4 -3
- package/koni/api/yield/helper/utils.d.ts +10 -0
- package/koni/api/yield/helper/utils.js +32 -0
- package/koni/background/cron.d.ts +0 -4
- package/koni/background/cron.js +4 -22
- package/koni/background/handlers/Extension.d.ts +17 -1
- package/koni/background/handlers/Extension.js +327 -30
- package/koni/background/handlers/State.d.ts +6 -1
- package/koni/background/handlers/State.js +17 -12
- package/koni/background/handlers/index.js +4 -2
- package/koni/background/subscription.d.ts +1 -6
- package/koni/background/subscription.js +8 -104
- package/package.json +326 -3
- package/services/campaign-service/index.js +9 -6
- package/services/chain-service/constants.d.ts +0 -12
- package/services/chain-service/constants.js +0 -14
- package/services/chain-service/index.js +6 -2
- package/services/chain-service/utils.d.ts +1 -0
- package/services/chain-service/utils.js +5 -1
- package/services/earning-service/constants/abis/compound_finance_v2_abi.json +1235 -0
- package/services/earning-service/constants/abis/st_liquid_token_abi.json +1355 -0
- package/services/earning-service/constants/chains.d.ts +15 -0
- package/services/earning-service/constants/chains.js +22 -0
- package/services/earning-service/constants/index.d.ts +2 -0
- package/services/earning-service/constants/index.js +5 -0
- package/services/earning-service/constants/step.d.ts +3 -0
- package/services/earning-service/constants/step.js +10 -0
- package/services/earning-service/handlers/base.d.ts +113 -0
- package/services/earning-service/handlers/base.js +256 -0
- package/services/earning-service/handlers/index.d.ts +5 -0
- package/services/earning-service/handlers/index.js +8 -0
- package/services/earning-service/handlers/lending/base.d.ts +8 -0
- package/services/earning-service/handlers/lending/base.js +73 -0
- package/services/earning-service/handlers/lending/index.d.ts +1 -0
- package/services/earning-service/handlers/lending/index.js +4 -0
- package/services/earning-service/handlers/lending/interlay.d.ts +24 -0
- package/services/earning-service/handlers/lending/interlay.js +184 -0
- package/services/earning-service/handlers/liquid-staking/acala.d.ts +27 -0
- package/services/earning-service/handlers/liquid-staking/acala.js +232 -0
- package/services/earning-service/handlers/liquid-staking/base.d.ts +11 -0
- package/services/earning-service/handlers/liquid-staking/base.js +89 -0
- package/services/earning-service/handlers/liquid-staking/bifrost.d.ts +46 -0
- package/services/earning-service/handlers/liquid-staking/bifrost.js +287 -0
- package/services/earning-service/handlers/liquid-staking/index.d.ts +4 -0
- package/services/earning-service/handlers/liquid-staking/index.js +7 -0
- package/services/earning-service/handlers/liquid-staking/parallel.d.ts +26 -0
- package/services/earning-service/handlers/liquid-staking/parallel.js +219 -0
- package/services/earning-service/handlers/liquid-staking/stella-swap.d.ts +34 -0
- package/services/earning-service/handlers/liquid-staking/stella-swap.js +394 -0
- package/services/earning-service/handlers/native-staking/amplitude.d.ts +22 -0
- package/services/earning-service/handlers/native-staking/amplitude.js +425 -0
- package/services/earning-service/handlers/native-staking/astar.d.ts +19 -0
- package/services/earning-service/handlers/native-staking/astar.js +456 -0
- package/services/earning-service/handlers/native-staking/base-para.d.ts +11 -0
- package/services/earning-service/handlers/native-staking/base-para.js +138 -0
- package/services/earning-service/handlers/native-staking/base.d.ts +21 -0
- package/services/earning-service/handlers/native-staking/base.js +152 -0
- package/services/earning-service/handlers/native-staking/index.d.ts +4 -0
- package/services/earning-service/handlers/native-staking/index.js +7 -0
- package/services/earning-service/handlers/native-staking/para-chain.d.ts +15 -0
- package/services/earning-service/handlers/native-staking/para-chain.js +382 -0
- package/services/earning-service/handlers/native-staking/relay-chain.d.ts +21 -0
- package/services/earning-service/handlers/native-staking/relay-chain.js +558 -0
- package/services/earning-service/handlers/nomination-pool/index.d.ts +36 -0
- package/services/earning-service/handlers/nomination-pool/index.js +556 -0
- package/services/earning-service/handlers/special.d.ts +64 -0
- package/services/earning-service/handlers/special.js +485 -0
- package/services/earning-service/service.d.ts +94 -0
- package/services/earning-service/service.js +722 -0
- package/services/earning-service/utils/index.d.ts +18 -0
- package/services/earning-service/utils/index.js +112 -0
- package/services/event-service/index.d.ts +2 -0
- package/services/event-service/index.js +5 -0
- package/services/event-service/types.d.ts +9 -0
- package/services/keyring-service/index.d.ts +2 -1
- package/services/keyring-service/index.js +14 -2
- package/services/migration-service/scripts/DeleteEarningData.d.ts +4 -0
- package/services/migration-service/scripts/DeleteEarningData.js +13 -0
- package/services/migration-service/scripts/EnableEarningChains.d.ts +4 -0
- package/services/migration-service/scripts/EnableEarningChains.js +13 -0
- package/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
- package/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
- package/services/migration-service/scripts/databases/MigrateEarningHistory.d.ts +4 -0
- package/services/migration-service/scripts/databases/MigrateEarningHistory.js +13 -0
- package/services/migration-service/scripts/databases/MigrateEarningVersion.d.ts +4 -0
- package/services/migration-service/scripts/databases/MigrateEarningVersion.js +13 -0
- package/services/migration-service/scripts/index.js +6 -1
- package/services/mint-campaign-service/campaigns/UnlockDotCampaign.d.ts +13 -0
- package/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +139 -0
- package/services/mint-campaign-service/campaigns/index.d.ts +1 -0
- package/services/mint-campaign-service/campaigns/index.js +4 -0
- package/services/mint-campaign-service/constants.d.ts +1 -0
- package/services/mint-campaign-service/constants.js +4 -0
- package/services/mint-campaign-service/index.d.ts +7 -0
- package/services/mint-campaign-service/index.js +11 -0
- package/services/notification-service/NotificationService.js +3 -2
- package/services/request-service/handler/PopupHandler.js +3 -4
- package/services/storage-service/DatabaseService.d.ts +22 -1
- package/services/storage-service/DatabaseService.js +63 -0
- package/services/storage-service/databases/index.d.ts +3 -1
- package/services/storage-service/databases/index.js +4 -0
- package/services/storage-service/db-stores/NominatorMetadata.js +3 -3
- package/services/storage-service/db-stores/YieldPoolStore.d.ts +10 -0
- package/services/storage-service/db-stores/YieldPoolStore.js +28 -0
- package/services/storage-service/db-stores/YieldPositionStore.d.ts +11 -0
- package/services/storage-service/db-stores/YieldPositionStore.js +63 -0
- package/services/subscan-service/index.d.ts +3 -2
- package/services/subscan-service/index.js +15 -0
- package/services/subscan-service/types.d.ts +20 -0
- package/services/transaction-service/event-parser/index.d.ts +3 -1
- package/services/transaction-service/event-parser/index.js +57 -1
- package/services/transaction-service/helpers/index.js +3 -1
- package/services/transaction-service/index.d.ts +6 -13
- package/services/transaction-service/index.js +247 -73
- package/services/transaction-service/types.d.ts +2 -0
- package/services/transaction-service/utils.js +1 -0
- package/types/campaigns/index.d.ts +1 -0
- package/types/campaigns/index.js +4 -0
- package/types/campaigns/unlock-dot.d.ts +71 -0
- package/types/campaigns/unlock-dot.js +1 -0
- package/types/index.d.ts +5 -0
- package/types/index.js +5 -1
- package/types/ordinal.d.ts +69 -0
- package/types/ordinal.js +1 -0
- package/types/transaction.d.ts +3 -0
- package/types/transaction.js +1 -0
- package/types/yield/actions/index.d.ts +2 -0
- package/types/yield/actions/index.js +5 -0
- package/types/yield/actions/join/index.d.ts +3 -0
- package/types/yield/actions/join/index.js +6 -0
- package/types/yield/actions/join/step.d.ts +95 -0
- package/types/yield/actions/join/step.js +46 -0
- package/types/yield/actions/join/submit.d.ts +58 -0
- package/types/yield/actions/join/submit.js +1 -0
- package/types/yield/actions/join/validate.d.ts +18 -0
- package/types/yield/actions/join/validate.js +10 -0
- package/types/yield/actions/others.d.ts +85 -0
- package/types/yield/actions/others.js +1 -0
- package/types/yield/index.d.ts +2 -0
- package/types/yield/index.js +5 -0
- package/types/yield/info/account/index.d.ts +4 -0
- package/types/yield/info/account/index.js +7 -0
- package/types/yield/info/account/info.d.ts +92 -0
- package/types/yield/info/account/info.js +1 -0
- package/types/yield/info/account/reward.d.ts +47 -0
- package/types/yield/info/account/reward.js +1 -0
- package/types/yield/info/account/target.d.ts +43 -0
- package/types/yield/info/account/target.js +27 -0
- package/types/yield/info/account/unstake.d.ts +31 -0
- package/types/yield/info/account/unstake.js +22 -0
- package/types/yield/info/base.d.ts +45 -0
- package/types/yield/info/base.js +36 -0
- package/types/yield/info/chain/index.d.ts +2 -0
- package/types/yield/info/chain/index.js +5 -0
- package/types/yield/info/chain/info.d.ts +252 -0
- package/types/yield/info/chain/info.js +1 -0
- package/types/yield/info/chain/target.d.ts +37 -0
- package/types/yield/info/chain/target.js +1 -0
- package/types/yield/info/index.d.ts +4 -0
- package/types/yield/info/index.js +7 -0
- package/types/yield/info/pallet.d.ts +143 -0
- package/types/yield/info/pallet.js +9 -0
- package/utils/environment.d.ts +9 -2
- package/utils/environment.js +14 -26
- package/utils/fetchStaticCache.d.ts +1 -0
- package/utils/fetchStaticCache.js +14 -0
- package/utils/fetchStaticData.js +2 -1
- package/utils/index.d.ts +5 -1
- package/utils/index.js +53 -3
- package/utils/mv3.d.ts +2 -0
- package/utils/mv3.js +13 -0
- package/utils/number.d.ts +2 -1
- package/utils/number.js +2 -1
- package/utils/object.d.ts +1 -0
- package/utils/object.js +6 -0
|
@@ -25,24 +25,26 @@ var _relayChain = require("@subwallet/extension-base/koni/api/staking/bonding/re
|
|
|
25
25
|
var _transfer3 = require("@subwallet/extension-base/koni/api/tokens/evm/transfer");
|
|
26
26
|
var _wasm = require("@subwallet/extension-base/koni/api/tokens/wasm");
|
|
27
27
|
var _xcm = require("@subwallet/extension-base/koni/api/xcm");
|
|
28
|
+
var _utils = require("@subwallet/extension-base/koni/api/yield/helper/utils");
|
|
28
29
|
var _constants2 = require("@subwallet/extension-base/services/chain-service/constants");
|
|
29
30
|
var _types2 = require("@subwallet/extension-base/services/chain-service/types");
|
|
30
|
-
var
|
|
31
|
+
var _utils2 = require("@subwallet/extension-base/services/chain-service/utils");
|
|
31
32
|
var _constants3 = require("@subwallet/extension-base/services/request-service/constants");
|
|
32
33
|
var _constants4 = require("@subwallet/extension-base/services/setting-service/constants");
|
|
33
34
|
var _constants5 = require("@subwallet/extension-base/services/wallet-connect-service/constants");
|
|
34
35
|
var _helpers2 = require("@subwallet/extension-base/services/wallet-connect-service/helpers");
|
|
35
|
-
var
|
|
36
|
+
var _types3 = require("@subwallet/extension-base/types");
|
|
37
|
+
var _utils3 = require("@subwallet/extension-base/utils");
|
|
36
38
|
var _eth = require("@subwallet/extension-base/utils/eth");
|
|
37
39
|
var _parseTransaction2 = require("@subwallet/extension-base/utils/eth/parseTransaction");
|
|
38
40
|
var _number = require("@subwallet/extension-base/utils/number");
|
|
39
41
|
var _keyring = require("@subwallet/keyring");
|
|
40
42
|
var _uiKeyring = require("@subwallet/ui-keyring");
|
|
41
|
-
var
|
|
43
|
+
var _utils4 = require("@walletconnect/utils");
|
|
42
44
|
var _bignumber = _interopRequireDefault(require("bignumber.js"));
|
|
43
45
|
var _ethereumjsTx = require("ethereumjs-tx");
|
|
44
46
|
var _i18next = require("i18next");
|
|
45
|
-
var
|
|
47
|
+
var _types4 = require("@polkadot/types");
|
|
46
48
|
var _util = require("@polkadot/util");
|
|
47
49
|
var _utilCrypto = require("@polkadot/util-crypto");
|
|
48
50
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
@@ -498,6 +500,7 @@ class KoniExtension {
|
|
|
498
500
|
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
499
501
|
const keyringService = this.#koniState.keyringService;
|
|
500
502
|
await this.#koniState.eventService.waitAccountReady;
|
|
503
|
+
await this.#koniState.eventService.waitInjectReady;
|
|
501
504
|
const currentAccount = keyringService.currentAccount;
|
|
502
505
|
const transformedAccounts = transformAccounts(keyringService.accounts);
|
|
503
506
|
const responseData = {
|
|
@@ -545,7 +548,7 @@ class KoniExtension {
|
|
|
545
548
|
subscribeAddresses(id, port) {
|
|
546
549
|
const _cb = (0, _subscriptions.createSubscription)(id, port);
|
|
547
550
|
const subscription = this.#koniState.keyringService.addressesSubject.subscribe(subjectInfo => {
|
|
548
|
-
const addresses = (0,
|
|
551
|
+
const addresses = (0, _utils3.convertSubjectInfoToAddresses)(subjectInfo);
|
|
549
552
|
_cb({
|
|
550
553
|
addresses: addresses
|
|
551
554
|
});
|
|
@@ -556,7 +559,7 @@ class KoniExtension {
|
|
|
556
559
|
});
|
|
557
560
|
const subjectInfo = this.#koniState.keyringService.addresses;
|
|
558
561
|
return {
|
|
559
|
-
addresses: (0,
|
|
562
|
+
addresses: (0, _utils3.convertSubjectInfoToAddresses)(subjectInfo)
|
|
560
563
|
};
|
|
561
564
|
}
|
|
562
565
|
saveRecentAccount(_ref22) {
|
|
@@ -564,7 +567,7 @@ class KoniExtension {
|
|
|
564
567
|
accountId
|
|
565
568
|
} = _ref22;
|
|
566
569
|
if ((0, _utilCrypto.isAddress)(accountId)) {
|
|
567
|
-
const address = (0,
|
|
570
|
+
const address = (0, _utils3.reformatAddress)(accountId);
|
|
568
571
|
const account = _uiKeyring.keyring.getAccount(address);
|
|
569
572
|
const contact = _uiKeyring.keyring.getAddress(address);
|
|
570
573
|
return account || contact || {
|
|
@@ -581,7 +584,7 @@ class KoniExtension {
|
|
|
581
584
|
meta
|
|
582
585
|
} = _ref23;
|
|
583
586
|
if ((0, _utilCrypto.isAddress)(address)) {
|
|
584
|
-
const _address = (0,
|
|
587
|
+
const _address = (0, _utils3.reformatAddress)(address);
|
|
585
588
|
_uiKeyring.keyring.saveAddress(_address, meta);
|
|
586
589
|
return true;
|
|
587
590
|
} else {
|
|
@@ -593,7 +596,7 @@ class KoniExtension {
|
|
|
593
596
|
address
|
|
594
597
|
} = _ref24;
|
|
595
598
|
if ((0, _utilCrypto.isAddress)(address)) {
|
|
596
|
-
const _address = (0,
|
|
599
|
+
const _address = (0, _utils3.reformatAddress)(address);
|
|
597
600
|
_uiKeyring.keyring.forgetAddress(_address);
|
|
598
601
|
return true;
|
|
599
602
|
} else {
|
|
@@ -1065,6 +1068,9 @@ class KoniExtension {
|
|
|
1065
1068
|
getCrowdloan(reset) {
|
|
1066
1069
|
return this.#koniState.getCrowdloan(reset);
|
|
1067
1070
|
}
|
|
1071
|
+
getCrowdloanContributions(request) {
|
|
1072
|
+
return this.#koniState.getCrowdloanContributions(request);
|
|
1073
|
+
}
|
|
1068
1074
|
subscribeCrowdloan(id, port) {
|
|
1069
1075
|
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
1070
1076
|
const crowdloanSubscription = this.#koniState.subscribeCrowdloan().subscribe({
|
|
@@ -1483,7 +1489,7 @@ class KoniExtension {
|
|
|
1483
1489
|
const addresses = _uiKeyring.keyring.getAccounts().map(a => a.address);
|
|
1484
1490
|
|
|
1485
1491
|
// Re-filter
|
|
1486
|
-
cb(histories.filter(item => addresses.some(address => (0,
|
|
1492
|
+
cb(histories.filter(item => addresses.some(address => (0, _utils3.isSameAddress)(item.address, address))));
|
|
1487
1493
|
});
|
|
1488
1494
|
this.createUnsubscriptionHandle(id, subscription.unsubscribe);
|
|
1489
1495
|
port.onDisconnect.addListener(() => {
|
|
@@ -1492,7 +1498,7 @@ class KoniExtension {
|
|
|
1492
1498
|
const addresses = _uiKeyring.keyring.getAccounts().map(a => a.address);
|
|
1493
1499
|
|
|
1494
1500
|
// Re-filter
|
|
1495
|
-
return historySubject.getValue().filter(item => addresses.some(address => (0,
|
|
1501
|
+
return historySubject.getValue().filter(item => addresses.some(address => (0, _utils3.isSameAddress)(item.address, address)));
|
|
1496
1502
|
}
|
|
1497
1503
|
subscribeHistoryByChainAndAddress(_ref44, id, port) {
|
|
1498
1504
|
let {
|
|
@@ -1538,7 +1544,7 @@ class KoniExtension {
|
|
|
1538
1544
|
if (!tokenInfo) {
|
|
1539
1545
|
errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INVALID_PARAMS, (0, _i18next.t)('Not found token from registry')));
|
|
1540
1546
|
}
|
|
1541
|
-
if ((0, _utilCrypto.isEthereumAddress)(from) && (0, _utilCrypto.isEthereumAddress)(to) && (0,
|
|
1547
|
+
if ((0, _utilCrypto.isEthereumAddress)(from) && (0, _utilCrypto.isEthereumAddress)(to) && (0, _utils2._isTokenEvmSmartContract)(tokenInfo) && (0, _utils2._getContractAddressOfToken)(tokenInfo).length === 0) {
|
|
1542
1548
|
errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INVALID_PARAMS, (0, _i18next.t)('Not found ERC20 address for this token')));
|
|
1543
1549
|
}
|
|
1544
1550
|
return [errors, keypair, transferValue, tokenInfo];
|
|
@@ -1577,18 +1583,18 @@ class KoniExtension {
|
|
|
1577
1583
|
token: tokenSlug
|
|
1578
1584
|
});
|
|
1579
1585
|
try {
|
|
1580
|
-
if ((0, _utilCrypto.isEthereumAddress)(from) && (0, _utilCrypto.isEthereumAddress)(to) && (0,
|
|
1586
|
+
if ((0, _utilCrypto.isEthereumAddress)(from) && (0, _utilCrypto.isEthereumAddress)(to) && (0, _utils2._isTokenTransferredByEvm)(tokenInfo)) {
|
|
1581
1587
|
// TODO: review this
|
|
1582
1588
|
chainType = _KoniTypes.ChainType.EVM;
|
|
1583
1589
|
const txVal = transferAll ? freeBalance.value : value || '0';
|
|
1584
1590
|
|
|
1585
1591
|
// Estimate with EVM API
|
|
1586
|
-
if ((0,
|
|
1587
|
-
[transaction, transferAmount.value] = await (0, _transfer3.getERC20TransactionObject)((0,
|
|
1592
|
+
if ((0, _utils2._isTokenEvmSmartContract)(tokenInfo) || (0, _utils2._isLocalToken)(tokenInfo)) {
|
|
1593
|
+
[transaction, transferAmount.value] = await (0, _transfer3.getERC20TransactionObject)((0, _utils2._getContractAddressOfToken)(tokenInfo), chainInfo, from, to, txVal, !!transferAll, evmApiMap);
|
|
1588
1594
|
} else {
|
|
1589
1595
|
[transaction, transferAmount.value] = await (0, _transfer3.getEVMTransactionObject)(chainInfo, from, to, txVal, !!transferAll, evmApiMap);
|
|
1590
1596
|
}
|
|
1591
|
-
} else if ((0,
|
|
1597
|
+
} else if ((0, _utils2._isMantaZkAsset)(tokenInfo)) {
|
|
1592
1598
|
// TODO
|
|
1593
1599
|
transaction = undefined;
|
|
1594
1600
|
transferAmount.value = '0';
|
|
@@ -1764,7 +1770,7 @@ class KoniExtension {
|
|
|
1764
1770
|
data: inputData,
|
|
1765
1771
|
extrinsicType: _KoniTypes.ExtrinsicType.TRANSFER_XCM,
|
|
1766
1772
|
chainType: _KoniTypes.ChainType.SUBSTRATE,
|
|
1767
|
-
transferNativeAmount: (0,
|
|
1773
|
+
transferNativeAmount: (0, _utils2._isNativeToken)(originTokenInfo) ? value : '0',
|
|
1768
1774
|
ignoreWarnings: inputData.transferAll,
|
|
1769
1775
|
isTransferAll: inputData.transferAll,
|
|
1770
1776
|
errors,
|
|
@@ -1848,10 +1854,10 @@ class KoniExtension {
|
|
|
1848
1854
|
}
|
|
1849
1855
|
async deleteCustomAsset(assetSlug) {
|
|
1850
1856
|
const assetInfo = this.#koniState.getAssetBySlug(assetSlug);
|
|
1851
|
-
if (assetInfo && (0,
|
|
1852
|
-
if ((0,
|
|
1857
|
+
if (assetInfo && (0, _utils2._isCustomAsset)(assetSlug)) {
|
|
1858
|
+
if ((0, _utils2._isAssetSmartContractNft)(assetInfo)) {
|
|
1853
1859
|
// check if deleting a smart contract NFT
|
|
1854
|
-
await this.#koniState.deleteNftCollection(assetInfo.originChain, (0,
|
|
1860
|
+
await this.#koniState.deleteNftCollection(assetInfo.originChain, (0, _utils2._getContractAddressOfToken)(assetInfo));
|
|
1855
1861
|
}
|
|
1856
1862
|
this.#koniState.deleteCustomAssets([assetSlug]);
|
|
1857
1863
|
return true;
|
|
@@ -1889,7 +1895,7 @@ class KoniExtension {
|
|
|
1889
1895
|
token
|
|
1890
1896
|
});
|
|
1891
1897
|
const tokenInfo = token ? this.#koniState.chainService.getAssetBySlug(token) : this.#koniState.chainService.getNativeTokenInfo(networkKey);
|
|
1892
|
-
if (!(0,
|
|
1898
|
+
if (!(0, _utils2._isNativeToken)(tokenInfo)) {
|
|
1893
1899
|
return freeBalance;
|
|
1894
1900
|
} else {
|
|
1895
1901
|
const substrateApi = this.#koniState.chainService.getSubstrateApi(networkKey);
|
|
@@ -1905,7 +1911,7 @@ class KoniExtension {
|
|
|
1905
1911
|
maxTransferable = maxTransferable.sub(new _util.BN(tokenInfo.minAmount || '0'));
|
|
1906
1912
|
const desChainInfo = chainInfoMap[destChain];
|
|
1907
1913
|
const orgChainInfo = chainInfoMap[networkKey];
|
|
1908
|
-
const recipient = !(0, _utilCrypto.isEthereumAddress)(address) && (0,
|
|
1914
|
+
const recipient = !(0, _utilCrypto.isEthereumAddress)(address) && (0, _utils2._isChainEvmCompatible)(desChainInfo) && !(0, _utils2._isChainEvmCompatible)(orgChainInfo) ? (0, _util.u8aToHex)((0, _utilCrypto.addressToEvm)(address)) : address;
|
|
1909
1915
|
const mockTx = await (0, _xcm.createXcmExtrinsic)({
|
|
1910
1916
|
chainInfoMap,
|
|
1911
1917
|
destinationTokenInfo,
|
|
@@ -1924,7 +1930,7 @@ class KoniExtension {
|
|
|
1924
1930
|
}
|
|
1925
1931
|
} else {
|
|
1926
1932
|
const chainInfo = this.#koniState.chainService.getChainInfoByKey(networkKey);
|
|
1927
|
-
if ((0,
|
|
1933
|
+
if ((0, _utils2._isChainEvmCompatible)(chainInfo) && (0, _utils2._isTokenTransferredByEvm)(tokenInfo)) {
|
|
1928
1934
|
const web3 = this.#koniState.chainService.getEvmApi(networkKey);
|
|
1929
1935
|
const transaction = {
|
|
1930
1936
|
value: 0,
|
|
@@ -1969,12 +1975,22 @@ class KoniExtension {
|
|
|
1969
1975
|
token
|
|
1970
1976
|
} = _ref49;
|
|
1971
1977
|
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
1972
|
-
const
|
|
1978
|
+
const convertData = data => {
|
|
1979
|
+
return {
|
|
1980
|
+
...data,
|
|
1981
|
+
id
|
|
1982
|
+
};
|
|
1983
|
+
};
|
|
1984
|
+
const _cb = data => {
|
|
1985
|
+
// eslint-disable-next-line node/no-callback-literal
|
|
1986
|
+
cb(convertData(data));
|
|
1987
|
+
};
|
|
1988
|
+
const [unsub, currentFreeBalance] = await this.#koniState.balanceService.subscribeTokenFreeBalance(address, networkKey, token, _cb);
|
|
1973
1989
|
this.createUnsubscriptionHandle(id, unsub);
|
|
1974
1990
|
port.onDisconnect.addListener(() => {
|
|
1975
1991
|
this.cancelSubscription(id);
|
|
1976
1992
|
});
|
|
1977
|
-
return currentFreeBalance;
|
|
1993
|
+
return convertData(currentFreeBalance);
|
|
1978
1994
|
}
|
|
1979
1995
|
async transferCheckReferenceCount(_ref50) {
|
|
1980
1996
|
let {
|
|
@@ -1997,7 +2013,7 @@ class KoniExtension {
|
|
|
1997
2013
|
tokenSlug
|
|
1998
2014
|
} = _ref52;
|
|
1999
2015
|
const tokenInfo = this.#koniState.getAssetBySlug(tokenSlug);
|
|
2000
|
-
return (0,
|
|
2016
|
+
return (0, _utils2._getTokenMinAmount)(tokenInfo);
|
|
2001
2017
|
}
|
|
2002
2018
|
async substrateNftSubmitTransaction(inputData) {
|
|
2003
2019
|
const {
|
|
@@ -2090,9 +2106,9 @@ class KoniExtension {
|
|
|
2090
2106
|
let _gen = '';
|
|
2091
2107
|
if (genesisHash) {
|
|
2092
2108
|
for (const network of Object.values(chainInfoMap)) {
|
|
2093
|
-
if ((0,
|
|
2109
|
+
if ((0, _utils2._getEvmChainId)(network) === parseInt(genesisHash)) {
|
|
2094
2110
|
// TODO: pure EVM chains do not have genesisHash
|
|
2095
|
-
_gen = (0,
|
|
2111
|
+
_gen = (0, _utils2._getSubstrateGenesisHash)(network);
|
|
2096
2112
|
}
|
|
2097
2113
|
}
|
|
2098
2114
|
}
|
|
@@ -2376,7 +2392,7 @@ class KoniExtension {
|
|
|
2376
2392
|
continue;
|
|
2377
2393
|
}
|
|
2378
2394
|
const networkInfo = chainInfoMap[n];
|
|
2379
|
-
if ((0,
|
|
2395
|
+
if ((0, _utils2._isChainEvmCompatible)(networkInfo)) {
|
|
2380
2396
|
return networkInfo;
|
|
2381
2397
|
}
|
|
2382
2398
|
}
|
|
@@ -2387,7 +2403,7 @@ class KoniExtension {
|
|
|
2387
2403
|
continue;
|
|
2388
2404
|
}
|
|
2389
2405
|
const networkInfo = chainInfoMap[n];
|
|
2390
|
-
if ((0,
|
|
2406
|
+
if ((0, _utils2._getEvmChainId)(networkInfo) === chainId) {
|
|
2391
2407
|
return networkInfo;
|
|
2392
2408
|
}
|
|
2393
2409
|
}
|
|
@@ -2429,7 +2445,7 @@ class KoniExtension {
|
|
|
2429
2445
|
withType: true
|
|
2430
2446
|
})));
|
|
2431
2447
|
const network = this.#koniState.getChainInfo(networkKey);
|
|
2432
|
-
if ((0,
|
|
2448
|
+
if ((0, _utils2._isChainEvmCompatible)(network)) {
|
|
2433
2449
|
signed = signed.substring(2);
|
|
2434
2450
|
}
|
|
2435
2451
|
return {
|
|
@@ -2478,8 +2494,8 @@ class KoniExtension {
|
|
|
2478
2494
|
};
|
|
2479
2495
|
const common = _common.default.forCustomChain('mainnet', {
|
|
2480
2496
|
name: network.name,
|
|
2481
|
-
networkId: (0,
|
|
2482
|
-
chainId: (0,
|
|
2497
|
+
networkId: (0, _utils2._getEvmChainId)(network),
|
|
2498
|
+
chainId: (0, _utils2._getEvmChainId)(network)
|
|
2483
2499
|
}, 'petersburg');
|
|
2484
2500
|
|
|
2485
2501
|
// @ts-ignore
|
|
@@ -2536,7 +2552,7 @@ class KoniExtension {
|
|
|
2536
2552
|
}
|
|
2537
2553
|
const {
|
|
2538
2554
|
decimals
|
|
2539
|
-
} = (0,
|
|
2555
|
+
} = (0, _utils2._getChainNativeTokenBasicInfo)(chainInfo);
|
|
2540
2556
|
return await (0, _bonding.getValidatorsInfo)(chain, apiProps, decimals, chainStakingMetadata);
|
|
2541
2557
|
}
|
|
2542
2558
|
async getNominationPoolOptions(chain) {
|
|
@@ -2604,36 +2620,18 @@ class KoniExtension {
|
|
|
2604
2620
|
chainType: _KoniTypes.ChainType.SUBSTRATE
|
|
2605
2621
|
});
|
|
2606
2622
|
}
|
|
2607
|
-
async submitStakeWithdrawal(inputData) {
|
|
2608
|
-
const {
|
|
2609
|
-
chain,
|
|
2610
|
-
nominatorMetadata,
|
|
2611
|
-
validatorAddress
|
|
2612
|
-
} = inputData;
|
|
2613
|
-
if (!nominatorMetadata) {
|
|
2614
|
-
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INVALID_PARAMS)]);
|
|
2615
|
-
}
|
|
2616
|
-
const dotSamaApi = this.#koniState.getSubstrateApi(chain);
|
|
2617
|
-
const extrinsic = await (0, _bonding.getWithdrawalExtrinsic)(dotSamaApi, chain, nominatorMetadata, validatorAddress);
|
|
2618
|
-
return await this.#koniState.transactionService.handleTransaction({
|
|
2619
|
-
address: nominatorMetadata.address,
|
|
2620
|
-
chain: chain,
|
|
2621
|
-
transaction: extrinsic,
|
|
2622
|
-
data: inputData,
|
|
2623
|
-
extrinsicType: _KoniTypes.ExtrinsicType.STAKING_WITHDRAW,
|
|
2624
|
-
chainType: _KoniTypes.ChainType.SUBSTRATE
|
|
2625
|
-
});
|
|
2626
|
-
}
|
|
2627
2623
|
async submitStakeClaimReward(inputData) {
|
|
2628
2624
|
const {
|
|
2629
2625
|
address,
|
|
2630
2626
|
bondReward,
|
|
2631
|
-
|
|
2632
|
-
stakingType
|
|
2627
|
+
slug
|
|
2633
2628
|
} = inputData;
|
|
2634
|
-
|
|
2629
|
+
const poolHandler = this.#koniState.earningService.getPoolHandler(slug);
|
|
2630
|
+
if (!address || !poolHandler) {
|
|
2635
2631
|
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INVALID_PARAMS)]);
|
|
2636
2632
|
}
|
|
2633
|
+
const chain = poolHandler.chain;
|
|
2634
|
+
const stakingType = poolHandler.type === _types3.YieldPoolType.NOMINATION_POOL ? _KoniTypes.StakingType.POOLED : _KoniTypes.StakingType.NOMINATED;
|
|
2637
2635
|
const substrateApi = this.#koniState.getSubstrateApi(chain);
|
|
2638
2636
|
const extrinsic = await (0, _bonding.getClaimRewardExtrinsic)(substrateApi, chain, address, stakingType, bondReward);
|
|
2639
2637
|
return await this.#koniState.transactionService.handleTransaction({
|
|
@@ -2646,15 +2644,18 @@ class KoniExtension {
|
|
|
2646
2644
|
});
|
|
2647
2645
|
}
|
|
2648
2646
|
async submitCancelStakeWithdrawal(inputData) {
|
|
2647
|
+
var _this$koniState$earni;
|
|
2649
2648
|
const {
|
|
2650
2649
|
address,
|
|
2651
|
-
|
|
2652
|
-
|
|
2650
|
+
selectedUnstaking,
|
|
2651
|
+
slug
|
|
2653
2652
|
} = inputData;
|
|
2653
|
+
const chain = (_this$koniState$earni = this.#koniState.earningService.getPoolHandler(slug)) === null || _this$koniState$earni === void 0 ? void 0 : _this$koniState$earni.chain;
|
|
2654
2654
|
if (!chain || !selectedUnstaking) {
|
|
2655
2655
|
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INVALID_PARAMS)]);
|
|
2656
2656
|
}
|
|
2657
2657
|
const substrateApi = this.#koniState.getSubstrateApi(chain);
|
|
2658
|
+
// @ts-ignore
|
|
2658
2659
|
const extrinsic = await (0, _bonding.getCancelWithdrawalExtrinsic)(substrateApi, chain, selectedUnstaking);
|
|
2659
2660
|
return await this.#koniState.transactionService.handleTransaction({
|
|
2660
2661
|
address,
|
|
@@ -2756,7 +2757,7 @@ class KoniExtension {
|
|
|
2756
2757
|
const chainInfo = this.#koniState.getChainInfo(networkKey);
|
|
2757
2758
|
const {
|
|
2758
2759
|
decimals
|
|
2759
|
-
} = (0,
|
|
2760
|
+
} = (0, _utils2._getChainNativeTokenBasicInfo)(chainInfo);
|
|
2760
2761
|
const parsedAccountMinimum = parseFloat(accountMinimum) * 10 ** decimals;
|
|
2761
2762
|
const extrinsic = await (0, _paraChain.getTuringCompoundExtrinsic)(dotSamaApi, address, collatorAddress, parsedAccountMinimum.toString(), bondedAmount);
|
|
2762
2763
|
return await this.#koniState.transactionService.handleTransaction({
|
|
@@ -2977,7 +2978,7 @@ class KoniExtension {
|
|
|
2977
2978
|
const {
|
|
2978
2979
|
payload
|
|
2979
2980
|
} = request;
|
|
2980
|
-
let registry = new
|
|
2981
|
+
let registry = new _types4.TypeRegistry();
|
|
2981
2982
|
let isEvm = false;
|
|
2982
2983
|
if ((0, _Extension.isJsonPayload)(payload)) {
|
|
2983
2984
|
// Get the metadata for the genesisHash
|
|
@@ -2999,7 +3000,7 @@ class KoniExtension {
|
|
|
2999
3000
|
}
|
|
3000
3001
|
}
|
|
3001
3002
|
if (chainInfo) {
|
|
3002
|
-
isEvm = (0,
|
|
3003
|
+
isEvm = (0, _utils2._isChainEvmCompatible)(chainInfo);
|
|
3003
3004
|
}
|
|
3004
3005
|
}
|
|
3005
3006
|
const result = request.sign(registry, pair);
|
|
@@ -3377,12 +3378,12 @@ class KoniExtension {
|
|
|
3377
3378
|
if (namespace.chains) {
|
|
3378
3379
|
const unSupportChains = namespace.chains.filter(chain => !(0, _helpers2.isSupportWalletConnectChain)(chain, chainInfoMap));
|
|
3379
3380
|
if (unSupportChains.length) {
|
|
3380
|
-
throw new Error((0,
|
|
3381
|
+
throw new Error((0, _utils4.getSdkError)('UNSUPPORTED_CHAINS').message + ' ' + unSupportChains.toString());
|
|
3381
3382
|
}
|
|
3382
3383
|
availableNamespaces[key] = namespace;
|
|
3383
3384
|
}
|
|
3384
3385
|
} else {
|
|
3385
|
-
throw new Error((0,
|
|
3386
|
+
throw new Error((0, _utils4.getSdkError)('UNSUPPORTED_NAMESPACE_KEY').message + ' ' + key);
|
|
3386
3387
|
}
|
|
3387
3388
|
});
|
|
3388
3389
|
Object.entries(optionalNamespaces).forEach(_ref84 => {
|
|
@@ -3414,7 +3415,7 @@ class KoniExtension {
|
|
|
3414
3415
|
let [key, namespace] = _ref85;
|
|
3415
3416
|
if (namespace.chains) {
|
|
3416
3417
|
const accounts = [];
|
|
3417
|
-
const chains = (0,
|
|
3418
|
+
const chains = (0, _utils3.uniqueStringArray)(namespace.chains);
|
|
3418
3419
|
chains.forEach(chain => {
|
|
3419
3420
|
accounts.push(...selectedAccounts.filter(address => (0, _utilCrypto.isEthereumAddress)(address) === (key === _constants5.WALLET_CONNECT_EIP155_NAMESPACE)).map(address => `${chain}:${address}`));
|
|
3420
3421
|
});
|
|
@@ -3654,9 +3655,245 @@ class KoniExtension {
|
|
|
3654
3655
|
this.#koniState.keyringService.removeInjectAccounts(request.addresses);
|
|
3655
3656
|
return true;
|
|
3656
3657
|
}
|
|
3658
|
+
async subscribeYieldPoolInfo(id, port) {
|
|
3659
|
+
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
3660
|
+
await this.#koniState.earningService.waitForStarted();
|
|
3661
|
+
const yieldPoolSubscription = this.#koniState.earningService.subscribeYieldPoolInfo().subscribe({
|
|
3662
|
+
next: rs => {
|
|
3663
|
+
cb(Object.values(rs));
|
|
3664
|
+
}
|
|
3665
|
+
});
|
|
3666
|
+
this.createUnsubscriptionHandle(id, yieldPoolSubscription.unsubscribe);
|
|
3667
|
+
port.onDisconnect.addListener(() => {
|
|
3668
|
+
this.cancelSubscription(id);
|
|
3669
|
+
});
|
|
3670
|
+
return this.#koniState.earningService.getYieldPoolInfo();
|
|
3671
|
+
}
|
|
3672
|
+
async earlyValidateJoin(request) {
|
|
3673
|
+
return await this.#koniState.earningService.earlyValidateJoin(request);
|
|
3674
|
+
}
|
|
3675
|
+
async getOptimalYieldPath(request) {
|
|
3676
|
+
return await this.#koniState.earningService.generateOptimalSteps(request);
|
|
3677
|
+
}
|
|
3678
|
+
async handleYieldStep(inputData) {
|
|
3679
|
+
const {
|
|
3680
|
+
data,
|
|
3681
|
+
path
|
|
3682
|
+
} = inputData;
|
|
3683
|
+
const {
|
|
3684
|
+
address
|
|
3685
|
+
} = data;
|
|
3686
|
+
if (!data) {
|
|
3687
|
+
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INTERNAL_ERROR)]);
|
|
3688
|
+
}
|
|
3689
|
+
const isLastStep = inputData.currentStep + 1 === path.steps.length;
|
|
3690
|
+
const yieldValidation = await this.#koniState.earningService.validateYieldJoin({
|
|
3691
|
+
data,
|
|
3692
|
+
path
|
|
3693
|
+
}); // TODO: validate, set to fail upon submission
|
|
3694
|
+
|
|
3695
|
+
if (yieldValidation.length > 0) {
|
|
3696
|
+
return this.#koniState.transactionService.generateBeforeHandleResponseErrors(yieldValidation);
|
|
3697
|
+
}
|
|
3698
|
+
|
|
3699
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
3700
|
+
const {
|
|
3701
|
+
chainType,
|
|
3702
|
+
extrinsic,
|
|
3703
|
+
extrinsicType,
|
|
3704
|
+
transferNativeAmount,
|
|
3705
|
+
txChain,
|
|
3706
|
+
txData
|
|
3707
|
+
} = await this.#koniState.earningService.handleYieldJoin(inputData);
|
|
3708
|
+
const isPoolSupportAlternativeFee = this.#koniState.earningService.isPoolSupportAlternativeFee(inputData.data.slug);
|
|
3709
|
+
const isMintingStep = _utils.YIELD_EXTRINSIC_TYPES.includes(extrinsicType);
|
|
3710
|
+
return await this.#koniState.transactionService.handleTransaction({
|
|
3711
|
+
address,
|
|
3712
|
+
chain: txChain,
|
|
3713
|
+
transaction: extrinsic,
|
|
3714
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
3715
|
+
data: txData,
|
|
3716
|
+
extrinsicType,
|
|
3717
|
+
// change this depends on step
|
|
3718
|
+
chainType,
|
|
3719
|
+
resolveOnDone: !isLastStep,
|
|
3720
|
+
transferNativeAmount,
|
|
3721
|
+
skipFeeValidation: isMintingStep && isPoolSupportAlternativeFee
|
|
3722
|
+
});
|
|
3723
|
+
}
|
|
3724
|
+
async handleYieldLeave(params) {
|
|
3725
|
+
const {
|
|
3726
|
+
address,
|
|
3727
|
+
slug
|
|
3728
|
+
} = params;
|
|
3729
|
+
const leaveValidation = await this.#koniState.earningService.validateYieldLeave(params);
|
|
3730
|
+
if (leaveValidation.length > 0) {
|
|
3731
|
+
return this.#koniState.transactionService.generateBeforeHandleResponseErrors(leaveValidation);
|
|
3732
|
+
}
|
|
3733
|
+
const [extrinsicType, extrinsic] = await this.#koniState.earningService.handleYieldLeave(params);
|
|
3734
|
+
const handler = this.#koniState.earningService.getPoolHandler(slug);
|
|
3735
|
+
return await this.#koniState.transactionService.handleTransaction({
|
|
3736
|
+
address,
|
|
3737
|
+
chain: (handler === null || handler === void 0 ? void 0 : handler.chain) || '',
|
|
3738
|
+
transaction: extrinsic,
|
|
3739
|
+
data: params,
|
|
3740
|
+
// TODO
|
|
3741
|
+
extrinsicType,
|
|
3742
|
+
chainType: (handler === null || handler === void 0 ? void 0 : handler.transactionChainType) || _KoniTypes.ChainType.SUBSTRATE
|
|
3743
|
+
});
|
|
3744
|
+
}
|
|
3745
|
+
async getYieldPoolTargets(request) {
|
|
3746
|
+
const {
|
|
3747
|
+
slug
|
|
3748
|
+
} = request;
|
|
3749
|
+
await this.#koniState.earningService.waitForStarted();
|
|
3750
|
+
const targets = await this.#koniState.earningService.getPoolTargets(slug);
|
|
3751
|
+
return {
|
|
3752
|
+
slug,
|
|
3753
|
+
targets
|
|
3754
|
+
};
|
|
3755
|
+
}
|
|
3756
|
+
async subscribeYieldPosition(id, port) {
|
|
3757
|
+
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
3758
|
+
await this.#koniState.earningService.waitForStarted();
|
|
3759
|
+
const yieldPositionSubscription = this.#koniState.earningService.subscribeYieldPosition().subscribe({
|
|
3760
|
+
next: rs => {
|
|
3761
|
+
cb(rs);
|
|
3762
|
+
}
|
|
3763
|
+
});
|
|
3764
|
+
this.createUnsubscriptionHandle(id, yieldPositionSubscription.unsubscribe);
|
|
3765
|
+
port.onDisconnect.addListener(() => {
|
|
3766
|
+
this.cancelSubscription(id);
|
|
3767
|
+
});
|
|
3768
|
+
return await this.#koniState.earningService.getYieldPositionInfo();
|
|
3769
|
+
}
|
|
3770
|
+
async subscribeYieldReward(id, port) {
|
|
3771
|
+
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
3772
|
+
await this.#koniState.earningService.waitForStarted();
|
|
3773
|
+
const stakingRewardSubscription = this.#koniState.earningService.subscribeEarningReward().subscribe({
|
|
3774
|
+
next: rs => {
|
|
3775
|
+
cb(rs);
|
|
3776
|
+
}
|
|
3777
|
+
});
|
|
3778
|
+
this.createUnsubscriptionHandle(id, stakingRewardSubscription.unsubscribe);
|
|
3779
|
+
port.onDisconnect.addListener(() => {
|
|
3780
|
+
this.cancelSubscription(id);
|
|
3781
|
+
});
|
|
3782
|
+
return this.#koniState.earningService.getEarningRewards();
|
|
3783
|
+
}
|
|
3784
|
+
async subscribeYieldRewardHistory(id, port) {
|
|
3785
|
+
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
3786
|
+
await this.#koniState.earningService.waitForStarted();
|
|
3787
|
+
const rewardHistorySubscription = this.#koniState.earningService.subscribeEarningRewardHistory().subscribe({
|
|
3788
|
+
next: rs => {
|
|
3789
|
+
cb(rs);
|
|
3790
|
+
}
|
|
3791
|
+
});
|
|
3792
|
+
this.createUnsubscriptionHandle(id, rewardHistorySubscription.unsubscribe);
|
|
3793
|
+
port.onDisconnect.addListener(() => {
|
|
3794
|
+
this.cancelSubscription(id);
|
|
3795
|
+
});
|
|
3796
|
+
return this.#koniState.earningService.getEarningRewardHistory();
|
|
3797
|
+
}
|
|
3798
|
+
async subscribeEarningMinAmountPercent(id, port) {
|
|
3799
|
+
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
3800
|
+
await this.#koniState.earningService.waitForStarted();
|
|
3801
|
+
const earningMinAmountPercentSubscription = this.#koniState.earningService.subscribeMinAmountPercent().subscribe({
|
|
3802
|
+
next: rs => {
|
|
3803
|
+
cb(rs);
|
|
3804
|
+
}
|
|
3805
|
+
});
|
|
3806
|
+
this.createUnsubscriptionHandle(id, earningMinAmountPercentSubscription.unsubscribe);
|
|
3807
|
+
port.onDisconnect.addListener(() => {
|
|
3808
|
+
this.cancelSubscription(id);
|
|
3809
|
+
});
|
|
3810
|
+
return this.#koniState.earningService.getMinAmountPercent();
|
|
3811
|
+
}
|
|
3812
|
+
handleValidateYieldProcess(inputData) {
|
|
3813
|
+
return this.#koniState.earningService.validateYieldJoin(inputData);
|
|
3814
|
+
}
|
|
3815
|
+
async yieldSubmitWithdrawal(params) {
|
|
3816
|
+
const {
|
|
3817
|
+
address,
|
|
3818
|
+
slug
|
|
3819
|
+
} = params;
|
|
3820
|
+
const poolHandler = this.#koniState.earningService.getPoolHandler(slug);
|
|
3821
|
+
if (!poolHandler) {
|
|
3822
|
+
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INVALID_PARAMS)]);
|
|
3823
|
+
}
|
|
3824
|
+
const extrinsic = await this.#koniState.earningService.handleYieldWithdraw(params);
|
|
3825
|
+
return await this.#koniState.transactionService.handleTransaction({
|
|
3826
|
+
address: address,
|
|
3827
|
+
chain: poolHandler.chain,
|
|
3828
|
+
transaction: extrinsic,
|
|
3829
|
+
data: params,
|
|
3830
|
+
extrinsicType: _KoniTypes.ExtrinsicType.STAKING_WITHDRAW,
|
|
3831
|
+
chainType: (poolHandler === null || poolHandler === void 0 ? void 0 : poolHandler.transactionChainType) || _KoniTypes.ChainType.SUBSTRATE
|
|
3832
|
+
});
|
|
3833
|
+
}
|
|
3834
|
+
async yieldSubmitCancelWithdrawal(params) {
|
|
3835
|
+
const {
|
|
3836
|
+
address,
|
|
3837
|
+
selectedUnstaking,
|
|
3838
|
+
slug
|
|
3839
|
+
} = params;
|
|
3840
|
+
const poolHandler = this.#koniState.earningService.getPoolHandler(slug);
|
|
3841
|
+
if (!poolHandler || !selectedUnstaking) {
|
|
3842
|
+
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INVALID_PARAMS)]);
|
|
3843
|
+
}
|
|
3844
|
+
const chain = poolHandler.chain;
|
|
3845
|
+
const extrinsic = await this.#koniState.earningService.handleYieldCancelUnstake(params);
|
|
3846
|
+
return await this.#koniState.transactionService.handleTransaction({
|
|
3847
|
+
address,
|
|
3848
|
+
chain,
|
|
3849
|
+
transaction: extrinsic,
|
|
3850
|
+
data: params,
|
|
3851
|
+
extrinsicType: _KoniTypes.ExtrinsicType.STAKING_CANCEL_UNSTAKE,
|
|
3852
|
+
chainType: (poolHandler === null || poolHandler === void 0 ? void 0 : poolHandler.transactionChainType) || _KoniTypes.ChainType.SUBSTRATE
|
|
3853
|
+
});
|
|
3854
|
+
}
|
|
3855
|
+
async yieldSubmitClaimReward(params) {
|
|
3856
|
+
const {
|
|
3857
|
+
address,
|
|
3858
|
+
slug
|
|
3859
|
+
} = params;
|
|
3860
|
+
const poolHandler = this.#koniState.earningService.getPoolHandler(slug);
|
|
3861
|
+
if (!address || !poolHandler) {
|
|
3862
|
+
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INVALID_PARAMS)]);
|
|
3863
|
+
}
|
|
3864
|
+
const extrinsic = await this.#koniState.earningService.handleYieldClaimReward(params);
|
|
3865
|
+
return await this.#koniState.transactionService.handleTransaction({
|
|
3866
|
+
address,
|
|
3867
|
+
chain: poolHandler.chain,
|
|
3868
|
+
transaction: extrinsic,
|
|
3869
|
+
data: params,
|
|
3870
|
+
extrinsicType: _KoniTypes.ExtrinsicType.STAKING_CLAIM_REWARD,
|
|
3871
|
+
chainType: (poolHandler === null || poolHandler === void 0 ? void 0 : poolHandler.transactionChainType) || _KoniTypes.ChainType.SUBSTRATE
|
|
3872
|
+
});
|
|
3873
|
+
}
|
|
3657
3874
|
|
|
3658
3875
|
/* Campaign */
|
|
3659
3876
|
|
|
3877
|
+
unlockDotCheckCanMint(_ref92) {
|
|
3878
|
+
let {
|
|
3879
|
+
address,
|
|
3880
|
+
network,
|
|
3881
|
+
slug
|
|
3882
|
+
} = _ref92;
|
|
3883
|
+
return this.#koniState.mintCampaignService.unlockDotCampaign.canMint(address, slug, network);
|
|
3884
|
+
}
|
|
3885
|
+
unlockDotSubscribeMintedData(id, port, _ref93) {
|
|
3886
|
+
let {
|
|
3887
|
+
transactionId
|
|
3888
|
+
} = _ref93;
|
|
3889
|
+
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
3890
|
+
const subscription = this.#koniState.mintCampaignService.unlockDotCampaign.subscribeMintedNft(transactionId, cb);
|
|
3891
|
+
this.createUnsubscriptionHandle(id, subscription.unsubscribe);
|
|
3892
|
+
port.onDisconnect.addListener(() => {
|
|
3893
|
+
this.cancelSubscription(id);
|
|
3894
|
+
});
|
|
3895
|
+
return this.#koniState.mintCampaignService.unlockDotCampaign.getMintedNft(transactionId);
|
|
3896
|
+
}
|
|
3660
3897
|
async subscribeProcessingBanner(id, port) {
|
|
3661
3898
|
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
3662
3899
|
const filterBanner = data => {
|
|
@@ -3680,10 +3917,10 @@ class KoniExtension {
|
|
|
3680
3917
|
});
|
|
3681
3918
|
return filterBanner(await this.#koniState.campaignService.getProcessingCampaign());
|
|
3682
3919
|
}
|
|
3683
|
-
async completeCampaignBanner(
|
|
3920
|
+
async completeCampaignBanner(_ref94) {
|
|
3684
3921
|
let {
|
|
3685
3922
|
slug
|
|
3686
|
-
} =
|
|
3923
|
+
} = _ref94;
|
|
3687
3924
|
const campaign = await this.#koniState.dbService.getCampaign(slug);
|
|
3688
3925
|
if (campaign) {
|
|
3689
3926
|
await this.#koniState.dbService.upsertCampaign({
|
|
@@ -3860,6 +4097,8 @@ class KoniExtension {
|
|
|
3860
4097
|
return await this.subscribeBalance(id, port);
|
|
3861
4098
|
case 'pri(crowdloan.getCrowdloan)':
|
|
3862
4099
|
return this.getCrowdloan();
|
|
4100
|
+
case 'pri(crowdloan.getCrowdloanContributions)':
|
|
4101
|
+
return this.getCrowdloanContributions(request);
|
|
3863
4102
|
case 'pri(crowdloan.getSubscription)':
|
|
3864
4103
|
return this.subscribeCrowdloan(id, port);
|
|
3865
4104
|
case 'pri(derivation.createV2)':
|
|
@@ -3889,6 +4128,57 @@ class KoniExtension {
|
|
|
3889
4128
|
case 'pri(transaction.history.subscribe)':
|
|
3890
4129
|
return this.subscribeHistoryByChainAndAddress(request, id, port);
|
|
3891
4130
|
|
|
4131
|
+
/* Earning */
|
|
4132
|
+
|
|
4133
|
+
/* Info */
|
|
4134
|
+
|
|
4135
|
+
case 'pri(yield.subscribePoolInfo)':
|
|
4136
|
+
return this.subscribeYieldPoolInfo(id, port);
|
|
4137
|
+
case 'pri(yield.getTargets)':
|
|
4138
|
+
return this.getYieldPoolTargets(request);
|
|
4139
|
+
case 'pri(yield.subscribeYieldPosition)':
|
|
4140
|
+
return this.subscribeYieldPosition(id, port);
|
|
4141
|
+
case 'pri(yield.subscribeYieldReward)':
|
|
4142
|
+
return this.subscribeYieldReward(id, port);
|
|
4143
|
+
case 'pri(yield.subscribeRewardHistory)':
|
|
4144
|
+
return this.subscribeYieldRewardHistory(id, port);
|
|
4145
|
+
case 'pri(yield.minAmountPercent)':
|
|
4146
|
+
return this.subscribeEarningMinAmountPercent(id, port);
|
|
4147
|
+
|
|
4148
|
+
/* Info */
|
|
4149
|
+
|
|
4150
|
+
/* Actions */
|
|
4151
|
+
|
|
4152
|
+
/* Join */
|
|
4153
|
+
|
|
4154
|
+
case 'pri(yield.join.earlyValidate)':
|
|
4155
|
+
return await this.earlyValidateJoin(request);
|
|
4156
|
+
case 'pri(yield.join.getOptimalPath)':
|
|
4157
|
+
return await this.getOptimalYieldPath(request);
|
|
4158
|
+
case 'pri(yield.join.handleStep)':
|
|
4159
|
+
return await this.handleYieldStep(request);
|
|
4160
|
+
case 'pri(yield.join.validateProcess)':
|
|
4161
|
+
return await this.handleValidateYieldProcess(request);
|
|
4162
|
+
|
|
4163
|
+
/* Join */
|
|
4164
|
+
|
|
4165
|
+
/* Others */
|
|
4166
|
+
|
|
4167
|
+
case 'pri(yield.leave.submit)':
|
|
4168
|
+
return await this.handleYieldLeave(request);
|
|
4169
|
+
case 'pri(yield.withdraw.submit)':
|
|
4170
|
+
return await this.yieldSubmitWithdrawal(request);
|
|
4171
|
+
case 'pri(yield.cancelWithdrawal.submit)':
|
|
4172
|
+
return await this.yieldSubmitCancelWithdrawal(request);
|
|
4173
|
+
case 'pri(yield.claimReward.submit)':
|
|
4174
|
+
return await this.yieldSubmitClaimReward(request);
|
|
4175
|
+
|
|
4176
|
+
/* Others */
|
|
4177
|
+
|
|
4178
|
+
/* Actions */
|
|
4179
|
+
|
|
4180
|
+
/* Earning */
|
|
4181
|
+
|
|
3892
4182
|
/* Account management */
|
|
3893
4183
|
// Add account
|
|
3894
4184
|
case 'pri(accounts.create.suriV2)':
|
|
@@ -4007,6 +4297,8 @@ class KoniExtension {
|
|
|
4007
4297
|
return this.transferGetExistentialDeposit(request);
|
|
4008
4298
|
case 'pri(transfer.getMaxTransferable)':
|
|
4009
4299
|
return this.transferGetMaxTransferable(request);
|
|
4300
|
+
case 'pri(transfer.subscribeMaxTransferable)':
|
|
4301
|
+
return this.transferGetMaxTransferable(request);
|
|
4010
4302
|
case 'pri(freeBalance.get)':
|
|
4011
4303
|
return this.getAddressFreeBalance(request);
|
|
4012
4304
|
case 'pri(freeBalance.subscribe)':
|
|
@@ -4065,8 +4357,6 @@ class KoniExtension {
|
|
|
4065
4357
|
return await this.submitBonding(request);
|
|
4066
4358
|
case 'pri(unbonding.submitTransaction)':
|
|
4067
4359
|
return await this.submitUnbonding(request);
|
|
4068
|
-
case 'pri(unbonding.submitWithdrawal)':
|
|
4069
|
-
return await this.submitStakeWithdrawal(request);
|
|
4070
4360
|
case 'pri(staking.submitClaimReward)':
|
|
4071
4361
|
return await this.submitStakeClaimReward(request);
|
|
4072
4362
|
case 'pri(staking.submitCancelWithdrawal)':
|
|
@@ -4170,6 +4460,15 @@ class KoniExtension {
|
|
|
4170
4460
|
case 'pri(mantaPay.subscribeSyncingState)':
|
|
4171
4461
|
return this.subscribeMantaPaySyncState(id, port);
|
|
4172
4462
|
|
|
4463
|
+
/* Campaign */
|
|
4464
|
+
|
|
4465
|
+
case 'pri(campaign.unlockDot.canMint)':
|
|
4466
|
+
return this.unlockDotCheckCanMint(request);
|
|
4467
|
+
case 'pri(campaign.unlockDot.subscribe)':
|
|
4468
|
+
return this.unlockDotSubscribeMintedData(id, port, request);
|
|
4469
|
+
|
|
4470
|
+
/* Campaign */
|
|
4471
|
+
|
|
4173
4472
|
// Metadata
|
|
4174
4473
|
case 'pri(metadata.find)':
|
|
4175
4474
|
return this.findRawMetadata(request);
|