@subwallet/extension-base 1.1.33-beta.3 → 1.1.35-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 +69 -111
- package/background/KoniTypes.js +13 -19
- package/background/errors/TransactionError.js +0 -9
- package/cjs/background/KoniTypes.js +16 -20
- package/cjs/background/errors/TransactionError.js +0 -9
- package/cjs/constants/index.js +4 -19
- package/cjs/koni/api/nft/config.js +23 -33
- package/cjs/koni/api/nft/index.js +0 -14
- package/cjs/koni/api/nft/nft.js +22 -1
- package/cjs/koni/api/staking/bonding/amplitude.js +16 -19
- package/cjs/koni/api/staking/bonding/astar.js +10 -11
- package/cjs/koni/api/staking/bonding/index.js +1 -4
- package/cjs/koni/api/staking/bonding/paraChain.js +23 -25
- package/cjs/koni/api/staking/bonding/relayChain.js +45 -48
- package/cjs/koni/api/staking/bonding/utils.js +86 -104
- package/cjs/koni/api/staking/index.js +5 -6
- package/cjs/koni/api/staking/paraChain.js +17 -10
- package/cjs/koni/api/staking/relayChain.js +2 -3
- package/cjs/koni/background/cron.js +21 -3
- package/cjs/koni/background/handlers/Extension.js +69 -368
- package/cjs/koni/background/handlers/State.js +12 -18
- package/cjs/koni/background/handlers/index.js +2 -4
- package/cjs/koni/background/subscription.js +104 -7
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/helpers/subscribe/substrate/index.js +1 -3
- package/cjs/services/campaign-service/index.js +6 -9
- package/cjs/services/chain-service/constants.js +16 -1
- package/cjs/services/chain-service/index.js +2 -5
- package/cjs/services/chain-service/utils.js +1 -7
- package/cjs/services/event-service/index.js +0 -5
- package/cjs/services/keyring-service/index.js +2 -14
- package/cjs/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
- package/cjs/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
- package/cjs/services/migration-service/scripts/index.js +1 -6
- package/cjs/services/notification-service/NotificationService.js +1 -1
- package/cjs/services/storage-service/DatabaseService.js +0 -63
- package/cjs/services/storage-service/databases/index.js +0 -4
- package/cjs/services/storage-service/db-stores/NominatorMetadata.js +3 -3
- package/cjs/services/subscan-service/index.js +0 -16
- package/cjs/services/transaction-service/event-parser/index.js +0 -58
- package/cjs/services/transaction-service/helpers/index.js +1 -3
- package/cjs/services/transaction-service/index.js +75 -249
- package/cjs/services/transaction-service/utils.js +0 -1
- package/cjs/types/index.js +0 -44
- package/cjs/utils/fetchStaticData.js +1 -2
- package/cjs/utils/index.js +1 -89
- package/cjs/utils/number.js +2 -6
- package/constants/index.d.ts +1 -6
- package/constants/index.js +1 -6
- package/koni/api/nft/config.js +23 -33
- package/koni/api/nft/index.js +1 -15
- package/koni/api/nft/nft.js +23 -2
- package/koni/api/staking/bonding/amplitude.js +10 -13
- package/koni/api/staking/bonding/astar.js +8 -9
- package/koni/api/staking/bonding/index.d.ts +1 -1
- package/koni/api/staking/bonding/index.js +1 -5
- package/koni/api/staking/bonding/paraChain.js +10 -12
- package/koni/api/staking/bonding/relayChain.d.ts +2 -2
- package/koni/api/staking/bonding/relayChain.js +30 -33
- package/koni/api/staking/bonding/utils.d.ts +38 -15
- package/koni/api/staking/bonding/utils.js +69 -85
- package/koni/api/staking/index.js +1 -2
- package/koni/api/staking/paraChain.js +18 -11
- package/koni/api/staking/relayChain.js +3 -4
- package/koni/background/cron.d.ts +4 -0
- package/koni/background/cron.js +22 -4
- package/koni/background/handlers/Extension.d.ts +1 -17
- package/koni/background/handlers/Extension.js +30 -327
- package/koni/background/handlers/State.d.ts +1 -6
- package/koni/background/handlers/State.js +12 -17
- package/koni/background/handlers/index.js +2 -4
- package/koni/background/subscription.d.ts +6 -1
- package/koni/background/subscription.js +104 -8
- package/package.json +7 -320
- package/packageInfo.js +1 -1
- package/services/balance-service/helpers/subscribe/substrate/index.js +2 -4
- package/services/campaign-service/index.js +6 -9
- package/services/chain-service/constants.d.ts +12 -0
- package/services/chain-service/constants.js +14 -0
- package/services/chain-service/index.js +2 -5
- package/services/chain-service/utils.d.ts +0 -1
- package/services/chain-service/utils.js +1 -5
- package/services/event-service/index.d.ts +0 -2
- package/services/event-service/index.js +0 -5
- package/services/event-service/types.d.ts +0 -9
- package/services/keyring-service/index.d.ts +1 -2
- package/services/keyring-service/index.js +2 -14
- package/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
- package/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
- package/services/migration-service/scripts/index.js +1 -6
- package/services/notification-service/NotificationService.js +1 -1
- package/services/storage-service/DatabaseService.d.ts +1 -22
- package/services/storage-service/DatabaseService.js +0 -63
- package/services/storage-service/databases/index.d.ts +1 -3
- package/services/storage-service/databases/index.js +0 -4
- package/services/storage-service/db-stores/NominatorMetadata.js +3 -3
- package/services/subscan-service/index.d.ts +2 -3
- package/services/subscan-service/index.js +0 -15
- package/services/subscan-service/types.d.ts +0 -20
- package/services/transaction-service/event-parser/index.d.ts +1 -3
- package/services/transaction-service/event-parser/index.js +1 -57
- package/services/transaction-service/helpers/index.js +1 -3
- package/services/transaction-service/index.d.ts +13 -6
- package/services/transaction-service/index.js +73 -247
- package/services/transaction-service/types.d.ts +0 -2
- package/services/transaction-service/utils.js +0 -1
- package/types/index.d.ts +0 -5
- package/types/index.js +1 -5
- package/utils/fetchStaticData.js +1 -2
- package/utils/index.d.ts +0 -5
- package/utils/index.js +0 -52
- package/utils/number.d.ts +1 -2
- package/utils/number.js +1 -2
- package/cjs/koni/api/dotsama/balance.js +0 -464
- package/cjs/koni/api/nft/ordinal_nft/constants.js +0 -21
- package/cjs/koni/api/nft/ordinal_nft/index.js +0 -121
- package/cjs/koni/api/nft/ordinal_nft/utils.js +0 -41
- package/cjs/koni/api/yield/helper/utils.js +0 -46
- package/cjs/services/earning-service/constants/chains.js +0 -30
- package/cjs/services/earning-service/constants/index.js +0 -27
- package/cjs/services/earning-service/constants/step.js +0 -18
- package/cjs/services/earning-service/handlers/base.js +0 -262
- package/cjs/services/earning-service/handlers/index.js +0 -60
- package/cjs/services/earning-service/handlers/lending/base.js +0 -81
- package/cjs/services/earning-service/handlers/lending/index.js +0 -13
- package/cjs/services/earning-service/handlers/lending/interlay.js +0 -192
- package/cjs/services/earning-service/handlers/liquid-staking/acala.js +0 -240
- package/cjs/services/earning-service/handlers/liquid-staking/base.js +0 -97
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost-manta.js +0 -140
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +0 -298
- package/cjs/services/earning-service/handlers/liquid-staking/index.js +0 -34
- package/cjs/services/earning-service/handlers/liquid-staking/parallel.js +0 -227
- package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +0 -404
- package/cjs/services/earning-service/handlers/native-staking/amplitude.js +0 -434
- package/cjs/services/earning-service/handlers/native-staking/astar.js +0 -466
- package/cjs/services/earning-service/handlers/native-staking/base-para.js +0 -146
- package/cjs/services/earning-service/handlers/native-staking/base.js +0 -161
- package/cjs/services/earning-service/handlers/native-staking/index.js +0 -34
- package/cjs/services/earning-service/handlers/native-staking/para-chain.js +0 -390
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +0 -567
- package/cjs/services/earning-service/handlers/nomination-pool/index.js +0 -566
- package/cjs/services/earning-service/handlers/special.js +0 -493
- package/cjs/services/earning-service/service.js +0 -740
- package/cjs/services/earning-service/utils/index.js +0 -128
- package/cjs/services/migration-service/scripts/DeleteEarningData.js +0 -21
- package/cjs/services/migration-service/scripts/EnableEarningChains.js +0 -21
- package/cjs/services/migration-service/scripts/MigrateEthProvider.js +0 -17
- package/cjs/services/migration-service/scripts/MigratePioneerProvider.js +0 -17
- package/cjs/services/migration-service/scripts/MigrateProvider.js +0 -29
- package/cjs/services/migration-service/scripts/databases/MigrateEarningHistory.js +0 -21
- package/cjs/services/migration-service/scripts/databases/MigrateEarningVersion.js +0 -21
- package/cjs/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -149
- package/cjs/services/mint-campaign-service/campaigns/index.js +0 -13
- package/cjs/services/mint-campaign-service/constants.js +0 -11
- package/cjs/services/mint-campaign-service/index.js +0 -18
- package/cjs/services/storage-service/db-stores/YieldPoolStore.js +0 -36
- package/cjs/services/storage-service/db-stores/YieldPositionStore.js +0 -71
- package/cjs/services/storage-service/index.js +0 -241
- package/cjs/types/campaigns/index.js +0 -16
- package/cjs/types/campaigns/unlock-dot.js +0 -1
- package/cjs/types/ordinal.js +0 -1
- package/cjs/types/transaction.js +0 -1
- package/cjs/types/yield/actions/index.js +0 -27
- package/cjs/types/yield/actions/join/index.js +0 -38
- package/cjs/types/yield/actions/join/step.js +0 -47
- package/cjs/types/yield/actions/join/submit.js +0 -1
- package/cjs/types/yield/actions/join/validate.js +0 -16
- package/cjs/types/yield/actions/others.js +0 -1
- package/cjs/types/yield/index.js +0 -27
- package/cjs/types/yield/info/account/index.js +0 -49
- package/cjs/types/yield/info/account/info.js +0 -1
- package/cjs/types/yield/info/account/reward.js +0 -1
- package/cjs/types/yield/info/account/target.js +0 -32
- package/cjs/types/yield/info/account/unstake.js +0 -27
- package/cjs/types/yield/info/base.js +0 -41
- package/cjs/types/yield/info/chain/index.js +0 -27
- package/cjs/types/yield/info/chain/info.js +0 -1
- package/cjs/types/yield/info/chain/target.js +0 -1
- package/cjs/types/yield/info/index.js +0 -49
- package/cjs/types/yield/info/pallet.js +0 -15
- package/cjs/types.js +0 -1
- package/cjs/utils/address.js +0 -34
- package/cjs/utils/keyring.js +0 -57
- package/cjs/utils/object.js +0 -12
- package/koni/api/nft/ordinal_nft/constants.d.ts +0 -9
- package/koni/api/nft/ordinal_nft/constants.js +0 -12
- package/koni/api/nft/ordinal_nft/index.d.ts +0 -8
- package/koni/api/nft/ordinal_nft/index.js +0 -114
- package/koni/api/nft/ordinal_nft/utils.d.ts +0 -2
- package/koni/api/nft/ordinal_nft/utils.js +0 -33
- package/koni/api/yield/helper/utils.d.ts +0 -10
- package/koni/api/yield/helper/utils.js +0 -32
- package/services/earning-service/constants/abis/compound_finance_v2_abi.json +0 -1235
- package/services/earning-service/constants/abis/st_liquid_token_abi.json +0 -1355
- package/services/earning-service/constants/chains.d.ts +0 -15
- package/services/earning-service/constants/chains.js +0 -22
- package/services/earning-service/constants/index.d.ts +0 -2
- package/services/earning-service/constants/index.js +0 -5
- package/services/earning-service/constants/step.d.ts +0 -3
- package/services/earning-service/constants/step.js +0 -10
- package/services/earning-service/handlers/base.d.ts +0 -113
- package/services/earning-service/handlers/base.js +0 -256
- package/services/earning-service/handlers/index.d.ts +0 -5
- package/services/earning-service/handlers/index.js +0 -8
- package/services/earning-service/handlers/lending/base.d.ts +0 -8
- package/services/earning-service/handlers/lending/base.js +0 -73
- package/services/earning-service/handlers/lending/index.d.ts +0 -1
- package/services/earning-service/handlers/lending/index.js +0 -4
- package/services/earning-service/handlers/lending/interlay.d.ts +0 -24
- package/services/earning-service/handlers/lending/interlay.js +0 -184
- package/services/earning-service/handlers/liquid-staking/acala.d.ts +0 -27
- package/services/earning-service/handlers/liquid-staking/acala.js +0 -232
- package/services/earning-service/handlers/liquid-staking/base.d.ts +0 -11
- package/services/earning-service/handlers/liquid-staking/base.js +0 -89
- package/services/earning-service/handlers/liquid-staking/bifrost.d.ts +0 -46
- package/services/earning-service/handlers/liquid-staking/bifrost.js +0 -287
- package/services/earning-service/handlers/liquid-staking/index.d.ts +0 -4
- package/services/earning-service/handlers/liquid-staking/index.js +0 -7
- package/services/earning-service/handlers/liquid-staking/parallel.d.ts +0 -26
- package/services/earning-service/handlers/liquid-staking/parallel.js +0 -219
- package/services/earning-service/handlers/liquid-staking/stella-swap.d.ts +0 -34
- package/services/earning-service/handlers/liquid-staking/stella-swap.js +0 -394
- package/services/earning-service/handlers/native-staking/amplitude.d.ts +0 -22
- package/services/earning-service/handlers/native-staking/amplitude.js +0 -425
- package/services/earning-service/handlers/native-staking/astar.d.ts +0 -19
- package/services/earning-service/handlers/native-staking/astar.js +0 -456
- package/services/earning-service/handlers/native-staking/base-para.d.ts +0 -11
- package/services/earning-service/handlers/native-staking/base-para.js +0 -138
- package/services/earning-service/handlers/native-staking/base.d.ts +0 -21
- package/services/earning-service/handlers/native-staking/base.js +0 -152
- package/services/earning-service/handlers/native-staking/index.d.ts +0 -4
- package/services/earning-service/handlers/native-staking/index.js +0 -7
- package/services/earning-service/handlers/native-staking/para-chain.d.ts +0 -15
- package/services/earning-service/handlers/native-staking/para-chain.js +0 -382
- package/services/earning-service/handlers/native-staking/relay-chain.d.ts +0 -21
- package/services/earning-service/handlers/native-staking/relay-chain.js +0 -558
- package/services/earning-service/handlers/nomination-pool/index.d.ts +0 -36
- package/services/earning-service/handlers/nomination-pool/index.js +0 -556
- package/services/earning-service/handlers/special.d.ts +0 -64
- package/services/earning-service/handlers/special.js +0 -485
- package/services/earning-service/service.d.ts +0 -94
- package/services/earning-service/service.js +0 -729
- package/services/earning-service/utils/index.d.ts +0 -18
- package/services/earning-service/utils/index.js +0 -112
- package/services/migration-service/scripts/DeleteEarningData.d.ts +0 -4
- package/services/migration-service/scripts/DeleteEarningData.js +0 -13
- package/services/migration-service/scripts/EnableEarningChains.d.ts +0 -4
- package/services/migration-service/scripts/EnableEarningChains.js +0 -13
- package/services/migration-service/scripts/databases/MigrateEarningHistory.d.ts +0 -4
- package/services/migration-service/scripts/databases/MigrateEarningHistory.js +0 -13
- package/services/migration-service/scripts/databases/MigrateEarningVersion.d.ts +0 -4
- package/services/migration-service/scripts/databases/MigrateEarningVersion.js +0 -13
- package/services/mint-campaign-service/campaigns/UnlockDotCampaign.d.ts +0 -13
- package/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -139
- package/services/mint-campaign-service/campaigns/index.d.ts +0 -1
- package/services/mint-campaign-service/campaigns/index.js +0 -4
- package/services/mint-campaign-service/constants.d.ts +0 -1
- package/services/mint-campaign-service/constants.js +0 -4
- package/services/mint-campaign-service/index.d.ts +0 -7
- package/services/mint-campaign-service/index.js +0 -11
- package/services/storage-service/db-stores/YieldPoolStore.d.ts +0 -10
- package/services/storage-service/db-stores/YieldPoolStore.js +0 -28
- package/services/storage-service/db-stores/YieldPositionStore.d.ts +0 -11
- package/services/storage-service/db-stores/YieldPositionStore.js +0 -63
- package/types/campaigns/index.d.ts +0 -1
- package/types/campaigns/index.js +0 -4
- package/types/campaigns/unlock-dot.d.ts +0 -71
- package/types/campaigns/unlock-dot.js +0 -1
- package/types/ordinal.d.ts +0 -69
- package/types/ordinal.js +0 -1
- package/types/transaction.d.ts +0 -3
- package/types/transaction.js +0 -1
- package/types/yield/actions/index.d.ts +0 -2
- package/types/yield/actions/index.js +0 -5
- package/types/yield/actions/join/index.d.ts +0 -3
- package/types/yield/actions/join/index.js +0 -6
- package/types/yield/actions/join/step.d.ts +0 -95
- package/types/yield/actions/join/step.js +0 -46
- package/types/yield/actions/join/submit.d.ts +0 -58
- package/types/yield/actions/join/submit.js +0 -1
- package/types/yield/actions/join/validate.d.ts +0 -18
- package/types/yield/actions/join/validate.js +0 -10
- package/types/yield/actions/others.d.ts +0 -85
- package/types/yield/actions/others.js +0 -1
- package/types/yield/index.d.ts +0 -2
- package/types/yield/index.js +0 -5
- package/types/yield/info/account/index.d.ts +0 -4
- package/types/yield/info/account/index.js +0 -7
- package/types/yield/info/account/info.d.ts +0 -92
- package/types/yield/info/account/info.js +0 -1
- package/types/yield/info/account/reward.d.ts +0 -47
- package/types/yield/info/account/reward.js +0 -1
- package/types/yield/info/account/target.d.ts +0 -43
- package/types/yield/info/account/target.js +0 -27
- package/types/yield/info/account/unstake.d.ts +0 -31
- package/types/yield/info/account/unstake.js +0 -22
- package/types/yield/info/base.d.ts +0 -45
- package/types/yield/info/base.js +0 -36
- package/types/yield/info/chain/index.d.ts +0 -2
- package/types/yield/info/chain/index.js +0 -5
- package/types/yield/info/chain/info.d.ts +0 -252
- package/types/yield/info/chain/info.js +0 -1
- package/types/yield/info/chain/target.d.ts +0 -37
- package/types/yield/info/chain/target.js +0 -1
- package/types/yield/info/index.d.ts +0 -4
- package/types/yield/info/index.js +0 -7
- package/types/yield/info/pallet.d.ts +0 -143
- package/types/yield/info/pallet.js +0 -9
- package/utils/object.d.ts +0 -1
- package/utils/object.js +0 -6
|
@@ -25,26 +25,24 @@ 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");
|
|
29
28
|
var _constants2 = require("@subwallet/extension-base/services/chain-service/constants");
|
|
30
29
|
var _types2 = require("@subwallet/extension-base/services/chain-service/types");
|
|
31
|
-
var
|
|
30
|
+
var _utils = require("@subwallet/extension-base/services/chain-service/utils");
|
|
32
31
|
var _constants3 = require("@subwallet/extension-base/services/request-service/constants");
|
|
33
32
|
var _constants4 = require("@subwallet/extension-base/services/setting-service/constants");
|
|
34
33
|
var _constants5 = require("@subwallet/extension-base/services/wallet-connect-service/constants");
|
|
35
34
|
var _helpers2 = require("@subwallet/extension-base/services/wallet-connect-service/helpers");
|
|
36
|
-
var
|
|
37
|
-
var _utils3 = require("@subwallet/extension-base/utils");
|
|
35
|
+
var _utils2 = require("@subwallet/extension-base/utils");
|
|
38
36
|
var _eth = require("@subwallet/extension-base/utils/eth");
|
|
39
37
|
var _parseTransaction2 = require("@subwallet/extension-base/utils/eth/parseTransaction");
|
|
40
38
|
var _number = require("@subwallet/extension-base/utils/number");
|
|
41
39
|
var _keyring = require("@subwallet/keyring");
|
|
42
40
|
var _uiKeyring = require("@subwallet/ui-keyring");
|
|
43
|
-
var
|
|
41
|
+
var _utils3 = require("@walletconnect/utils");
|
|
44
42
|
var _bignumber = _interopRequireDefault(require("bignumber.js"));
|
|
45
43
|
var _ethereumjsTx = require("ethereumjs-tx");
|
|
46
44
|
var _i18next = require("i18next");
|
|
47
|
-
var
|
|
45
|
+
var _types3 = require("@polkadot/types");
|
|
48
46
|
var _util = require("@polkadot/util");
|
|
49
47
|
var _utilCrypto = require("@polkadot/util-crypto");
|
|
50
48
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
@@ -500,7 +498,6 @@ class KoniExtension {
|
|
|
500
498
|
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
501
499
|
const keyringService = this.#koniState.keyringService;
|
|
502
500
|
await this.#koniState.eventService.waitAccountReady;
|
|
503
|
-
await this.#koniState.eventService.waitInjectReady;
|
|
504
501
|
const currentAccount = keyringService.currentAccount;
|
|
505
502
|
const transformedAccounts = transformAccounts(keyringService.accounts);
|
|
506
503
|
const responseData = {
|
|
@@ -548,7 +545,7 @@ class KoniExtension {
|
|
|
548
545
|
subscribeAddresses(id, port) {
|
|
549
546
|
const _cb = (0, _subscriptions.createSubscription)(id, port);
|
|
550
547
|
const subscription = this.#koniState.keyringService.addressesSubject.subscribe(subjectInfo => {
|
|
551
|
-
const addresses = (0,
|
|
548
|
+
const addresses = (0, _utils2.convertSubjectInfoToAddresses)(subjectInfo);
|
|
552
549
|
_cb({
|
|
553
550
|
addresses: addresses
|
|
554
551
|
});
|
|
@@ -559,7 +556,7 @@ class KoniExtension {
|
|
|
559
556
|
});
|
|
560
557
|
const subjectInfo = this.#koniState.keyringService.addresses;
|
|
561
558
|
return {
|
|
562
|
-
addresses: (0,
|
|
559
|
+
addresses: (0, _utils2.convertSubjectInfoToAddresses)(subjectInfo)
|
|
563
560
|
};
|
|
564
561
|
}
|
|
565
562
|
saveRecentAccount(_ref22) {
|
|
@@ -567,7 +564,7 @@ class KoniExtension {
|
|
|
567
564
|
accountId
|
|
568
565
|
} = _ref22;
|
|
569
566
|
if ((0, _utilCrypto.isAddress)(accountId)) {
|
|
570
|
-
const address = (0,
|
|
567
|
+
const address = (0, _utils2.reformatAddress)(accountId);
|
|
571
568
|
const account = _uiKeyring.keyring.getAccount(address);
|
|
572
569
|
const contact = _uiKeyring.keyring.getAddress(address);
|
|
573
570
|
return account || contact || {
|
|
@@ -584,7 +581,7 @@ class KoniExtension {
|
|
|
584
581
|
meta
|
|
585
582
|
} = _ref23;
|
|
586
583
|
if ((0, _utilCrypto.isAddress)(address)) {
|
|
587
|
-
const _address = (0,
|
|
584
|
+
const _address = (0, _utils2.reformatAddress)(address);
|
|
588
585
|
_uiKeyring.keyring.saveAddress(_address, meta);
|
|
589
586
|
return true;
|
|
590
587
|
} else {
|
|
@@ -596,7 +593,7 @@ class KoniExtension {
|
|
|
596
593
|
address
|
|
597
594
|
} = _ref24;
|
|
598
595
|
if ((0, _utilCrypto.isAddress)(address)) {
|
|
599
|
-
const _address = (0,
|
|
596
|
+
const _address = (0, _utils2.reformatAddress)(address);
|
|
600
597
|
_uiKeyring.keyring.forgetAddress(_address);
|
|
601
598
|
return true;
|
|
602
599
|
} else {
|
|
@@ -1068,9 +1065,6 @@ class KoniExtension {
|
|
|
1068
1065
|
getCrowdloan(reset) {
|
|
1069
1066
|
return this.#koniState.getCrowdloan(reset);
|
|
1070
1067
|
}
|
|
1071
|
-
getCrowdloanContributions(request) {
|
|
1072
|
-
return this.#koniState.getCrowdloanContributions(request);
|
|
1073
|
-
}
|
|
1074
1068
|
subscribeCrowdloan(id, port) {
|
|
1075
1069
|
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
1076
1070
|
const crowdloanSubscription = this.#koniState.subscribeCrowdloan().subscribe({
|
|
@@ -1489,7 +1483,7 @@ class KoniExtension {
|
|
|
1489
1483
|
const addresses = _uiKeyring.keyring.getAccounts().map(a => a.address);
|
|
1490
1484
|
|
|
1491
1485
|
// Re-filter
|
|
1492
|
-
cb(histories.filter(item => addresses.some(address => (0,
|
|
1486
|
+
cb(histories.filter(item => addresses.some(address => (0, _utils2.isSameAddress)(item.address, address))));
|
|
1493
1487
|
});
|
|
1494
1488
|
this.createUnsubscriptionHandle(id, subscription.unsubscribe);
|
|
1495
1489
|
port.onDisconnect.addListener(() => {
|
|
@@ -1498,7 +1492,7 @@ class KoniExtension {
|
|
|
1498
1492
|
const addresses = _uiKeyring.keyring.getAccounts().map(a => a.address);
|
|
1499
1493
|
|
|
1500
1494
|
// Re-filter
|
|
1501
|
-
return historySubject.getValue().filter(item => addresses.some(address => (0,
|
|
1495
|
+
return historySubject.getValue().filter(item => addresses.some(address => (0, _utils2.isSameAddress)(item.address, address)));
|
|
1502
1496
|
}
|
|
1503
1497
|
subscribeHistoryByChainAndAddress(_ref44, id, port) {
|
|
1504
1498
|
let {
|
|
@@ -1544,7 +1538,7 @@ class KoniExtension {
|
|
|
1544
1538
|
if (!tokenInfo) {
|
|
1545
1539
|
errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INVALID_PARAMS, (0, _i18next.t)('Not found token from registry')));
|
|
1546
1540
|
}
|
|
1547
|
-
if ((0, _utilCrypto.isEthereumAddress)(from) && (0, _utilCrypto.isEthereumAddress)(to) && (0,
|
|
1541
|
+
if ((0, _utilCrypto.isEthereumAddress)(from) && (0, _utilCrypto.isEthereumAddress)(to) && (0, _utils._isTokenEvmSmartContract)(tokenInfo) && (0, _utils._getContractAddressOfToken)(tokenInfo).length === 0) {
|
|
1548
1542
|
errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INVALID_PARAMS, (0, _i18next.t)('Not found ERC20 address for this token')));
|
|
1549
1543
|
}
|
|
1550
1544
|
return [errors, keypair, transferValue, tokenInfo];
|
|
@@ -1583,18 +1577,18 @@ class KoniExtension {
|
|
|
1583
1577
|
token: tokenSlug
|
|
1584
1578
|
});
|
|
1585
1579
|
try {
|
|
1586
|
-
if ((0, _utilCrypto.isEthereumAddress)(from) && (0, _utilCrypto.isEthereumAddress)(to) && (0,
|
|
1580
|
+
if ((0, _utilCrypto.isEthereumAddress)(from) && (0, _utilCrypto.isEthereumAddress)(to) && (0, _utils._isTokenTransferredByEvm)(tokenInfo)) {
|
|
1587
1581
|
// TODO: review this
|
|
1588
1582
|
chainType = _KoniTypes.ChainType.EVM;
|
|
1589
1583
|
const txVal = transferAll ? freeBalance.value : value || '0';
|
|
1590
1584
|
|
|
1591
1585
|
// Estimate with EVM API
|
|
1592
|
-
if ((0,
|
|
1593
|
-
[transaction, transferAmount.value] = await (0, _transfer3.getERC20TransactionObject)((0,
|
|
1586
|
+
if ((0, _utils._isTokenEvmSmartContract)(tokenInfo) || (0, _utils._isLocalToken)(tokenInfo)) {
|
|
1587
|
+
[transaction, transferAmount.value] = await (0, _transfer3.getERC20TransactionObject)((0, _utils._getContractAddressOfToken)(tokenInfo), chainInfo, from, to, txVal, !!transferAll, evmApiMap);
|
|
1594
1588
|
} else {
|
|
1595
1589
|
[transaction, transferAmount.value] = await (0, _transfer3.getEVMTransactionObject)(chainInfo, from, to, txVal, !!transferAll, evmApiMap);
|
|
1596
1590
|
}
|
|
1597
|
-
} else if ((0,
|
|
1591
|
+
} else if ((0, _utils._isMantaZkAsset)(tokenInfo)) {
|
|
1598
1592
|
// TODO
|
|
1599
1593
|
transaction = undefined;
|
|
1600
1594
|
transferAmount.value = '0';
|
|
@@ -1770,7 +1764,7 @@ class KoniExtension {
|
|
|
1770
1764
|
data: inputData,
|
|
1771
1765
|
extrinsicType: _KoniTypes.ExtrinsicType.TRANSFER_XCM,
|
|
1772
1766
|
chainType: _KoniTypes.ChainType.SUBSTRATE,
|
|
1773
|
-
transferNativeAmount: (0,
|
|
1767
|
+
transferNativeAmount: (0, _utils._isNativeToken)(originTokenInfo) ? value : '0',
|
|
1774
1768
|
ignoreWarnings: inputData.transferAll,
|
|
1775
1769
|
isTransferAll: inputData.transferAll,
|
|
1776
1770
|
errors,
|
|
@@ -1854,10 +1848,10 @@ class KoniExtension {
|
|
|
1854
1848
|
}
|
|
1855
1849
|
async deleteCustomAsset(assetSlug) {
|
|
1856
1850
|
const assetInfo = this.#koniState.getAssetBySlug(assetSlug);
|
|
1857
|
-
if (assetInfo && (0,
|
|
1858
|
-
if ((0,
|
|
1851
|
+
if (assetInfo && (0, _utils._isCustomAsset)(assetSlug)) {
|
|
1852
|
+
if ((0, _utils._isAssetSmartContractNft)(assetInfo)) {
|
|
1859
1853
|
// check if deleting a smart contract NFT
|
|
1860
|
-
await this.#koniState.deleteNftCollection(assetInfo.originChain, (0,
|
|
1854
|
+
await this.#koniState.deleteNftCollection(assetInfo.originChain, (0, _utils._getContractAddressOfToken)(assetInfo));
|
|
1861
1855
|
}
|
|
1862
1856
|
this.#koniState.deleteCustomAssets([assetSlug]);
|
|
1863
1857
|
return true;
|
|
@@ -1895,7 +1889,7 @@ class KoniExtension {
|
|
|
1895
1889
|
token
|
|
1896
1890
|
});
|
|
1897
1891
|
const tokenInfo = token ? this.#koniState.chainService.getAssetBySlug(token) : this.#koniState.chainService.getNativeTokenInfo(networkKey);
|
|
1898
|
-
if (!(0,
|
|
1892
|
+
if (!(0, _utils._isNativeToken)(tokenInfo)) {
|
|
1899
1893
|
return freeBalance;
|
|
1900
1894
|
} else {
|
|
1901
1895
|
const substrateApi = this.#koniState.chainService.getSubstrateApi(networkKey);
|
|
@@ -1911,7 +1905,7 @@ class KoniExtension {
|
|
|
1911
1905
|
maxTransferable = maxTransferable.sub(new _util.BN(tokenInfo.minAmount || '0'));
|
|
1912
1906
|
const desChainInfo = chainInfoMap[destChain];
|
|
1913
1907
|
const orgChainInfo = chainInfoMap[networkKey];
|
|
1914
|
-
const recipient = !(0, _utilCrypto.isEthereumAddress)(address) && (0,
|
|
1908
|
+
const recipient = !(0, _utilCrypto.isEthereumAddress)(address) && (0, _utils._isChainEvmCompatible)(desChainInfo) && !(0, _utils._isChainEvmCompatible)(orgChainInfo) ? (0, _util.u8aToHex)((0, _utilCrypto.addressToEvm)(address)) : address;
|
|
1915
1909
|
const mockTx = await (0, _xcm.createXcmExtrinsic)({
|
|
1916
1910
|
chainInfoMap,
|
|
1917
1911
|
destinationTokenInfo,
|
|
@@ -1930,7 +1924,7 @@ class KoniExtension {
|
|
|
1930
1924
|
}
|
|
1931
1925
|
} else {
|
|
1932
1926
|
const chainInfo = this.#koniState.chainService.getChainInfoByKey(networkKey);
|
|
1933
|
-
if ((0,
|
|
1927
|
+
if ((0, _utils._isChainEvmCompatible)(chainInfo) && (0, _utils._isTokenTransferredByEvm)(tokenInfo)) {
|
|
1934
1928
|
const web3 = this.#koniState.chainService.getEvmApi(networkKey);
|
|
1935
1929
|
const transaction = {
|
|
1936
1930
|
value: 0,
|
|
@@ -1975,22 +1969,12 @@ class KoniExtension {
|
|
|
1975
1969
|
token
|
|
1976
1970
|
} = _ref49;
|
|
1977
1971
|
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
1978
|
-
const
|
|
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);
|
|
1972
|
+
const [unsub, currentFreeBalance] = await this.#koniState.balanceService.subscribeTokenFreeBalance(address, networkKey, token, cb);
|
|
1989
1973
|
this.createUnsubscriptionHandle(id, unsub);
|
|
1990
1974
|
port.onDisconnect.addListener(() => {
|
|
1991
1975
|
this.cancelSubscription(id);
|
|
1992
1976
|
});
|
|
1993
|
-
return
|
|
1977
|
+
return currentFreeBalance;
|
|
1994
1978
|
}
|
|
1995
1979
|
async transferCheckReferenceCount(_ref50) {
|
|
1996
1980
|
let {
|
|
@@ -2013,7 +1997,7 @@ class KoniExtension {
|
|
|
2013
1997
|
tokenSlug
|
|
2014
1998
|
} = _ref52;
|
|
2015
1999
|
const tokenInfo = this.#koniState.getAssetBySlug(tokenSlug);
|
|
2016
|
-
return (0,
|
|
2000
|
+
return (0, _utils._getTokenMinAmount)(tokenInfo);
|
|
2017
2001
|
}
|
|
2018
2002
|
async substrateNftSubmitTransaction(inputData) {
|
|
2019
2003
|
const {
|
|
@@ -2106,9 +2090,9 @@ class KoniExtension {
|
|
|
2106
2090
|
let _gen = '';
|
|
2107
2091
|
if (genesisHash) {
|
|
2108
2092
|
for (const network of Object.values(chainInfoMap)) {
|
|
2109
|
-
if ((0,
|
|
2093
|
+
if ((0, _utils._getEvmChainId)(network) === parseInt(genesisHash)) {
|
|
2110
2094
|
// TODO: pure EVM chains do not have genesisHash
|
|
2111
|
-
_gen = (0,
|
|
2095
|
+
_gen = (0, _utils._getSubstrateGenesisHash)(network);
|
|
2112
2096
|
}
|
|
2113
2097
|
}
|
|
2114
2098
|
}
|
|
@@ -2392,7 +2376,7 @@ class KoniExtension {
|
|
|
2392
2376
|
continue;
|
|
2393
2377
|
}
|
|
2394
2378
|
const networkInfo = chainInfoMap[n];
|
|
2395
|
-
if ((0,
|
|
2379
|
+
if ((0, _utils._isChainEvmCompatible)(networkInfo)) {
|
|
2396
2380
|
return networkInfo;
|
|
2397
2381
|
}
|
|
2398
2382
|
}
|
|
@@ -2403,7 +2387,7 @@ class KoniExtension {
|
|
|
2403
2387
|
continue;
|
|
2404
2388
|
}
|
|
2405
2389
|
const networkInfo = chainInfoMap[n];
|
|
2406
|
-
if ((0,
|
|
2390
|
+
if ((0, _utils._getEvmChainId)(networkInfo) === chainId) {
|
|
2407
2391
|
return networkInfo;
|
|
2408
2392
|
}
|
|
2409
2393
|
}
|
|
@@ -2445,7 +2429,7 @@ class KoniExtension {
|
|
|
2445
2429
|
withType: true
|
|
2446
2430
|
})));
|
|
2447
2431
|
const network = this.#koniState.getChainInfo(networkKey);
|
|
2448
|
-
if ((0,
|
|
2432
|
+
if ((0, _utils._isChainEvmCompatible)(network)) {
|
|
2449
2433
|
signed = signed.substring(2);
|
|
2450
2434
|
}
|
|
2451
2435
|
return {
|
|
@@ -2494,8 +2478,8 @@ class KoniExtension {
|
|
|
2494
2478
|
};
|
|
2495
2479
|
const common = _common.default.forCustomChain('mainnet', {
|
|
2496
2480
|
name: network.name,
|
|
2497
|
-
networkId: (0,
|
|
2498
|
-
chainId: (0,
|
|
2481
|
+
networkId: (0, _utils._getEvmChainId)(network),
|
|
2482
|
+
chainId: (0, _utils._getEvmChainId)(network)
|
|
2499
2483
|
}, 'petersburg');
|
|
2500
2484
|
|
|
2501
2485
|
// @ts-ignore
|
|
@@ -2552,7 +2536,7 @@ class KoniExtension {
|
|
|
2552
2536
|
}
|
|
2553
2537
|
const {
|
|
2554
2538
|
decimals
|
|
2555
|
-
} = (0,
|
|
2539
|
+
} = (0, _utils._getChainNativeTokenBasicInfo)(chainInfo);
|
|
2556
2540
|
return await (0, _bonding.getValidatorsInfo)(chain, apiProps, decimals, chainStakingMetadata);
|
|
2557
2541
|
}
|
|
2558
2542
|
async getNominationPoolOptions(chain) {
|
|
@@ -2620,18 +2604,36 @@ class KoniExtension {
|
|
|
2620
2604
|
chainType: _KoniTypes.ChainType.SUBSTRATE
|
|
2621
2605
|
});
|
|
2622
2606
|
}
|
|
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
|
+
}
|
|
2623
2627
|
async submitStakeClaimReward(inputData) {
|
|
2624
2628
|
const {
|
|
2625
2629
|
address,
|
|
2626
2630
|
bondReward,
|
|
2627
|
-
|
|
2631
|
+
chain,
|
|
2632
|
+
stakingType
|
|
2628
2633
|
} = inputData;
|
|
2629
|
-
|
|
2630
|
-
if (!address || !poolHandler) {
|
|
2634
|
+
if (!address) {
|
|
2631
2635
|
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INVALID_PARAMS)]);
|
|
2632
2636
|
}
|
|
2633
|
-
const chain = poolHandler.chain;
|
|
2634
|
-
const stakingType = poolHandler.type === _types3.YieldPoolType.NOMINATION_POOL ? _KoniTypes.StakingType.POOLED : _KoniTypes.StakingType.NOMINATED;
|
|
2635
2637
|
const substrateApi = this.#koniState.getSubstrateApi(chain);
|
|
2636
2638
|
const extrinsic = await (0, _bonding.getClaimRewardExtrinsic)(substrateApi, chain, address, stakingType, bondReward);
|
|
2637
2639
|
return await this.#koniState.transactionService.handleTransaction({
|
|
@@ -2644,18 +2646,15 @@ class KoniExtension {
|
|
|
2644
2646
|
});
|
|
2645
2647
|
}
|
|
2646
2648
|
async submitCancelStakeWithdrawal(inputData) {
|
|
2647
|
-
var _this$koniState$earni;
|
|
2648
2649
|
const {
|
|
2649
2650
|
address,
|
|
2650
|
-
|
|
2651
|
-
|
|
2651
|
+
chain,
|
|
2652
|
+
selectedUnstaking
|
|
2652
2653
|
} = 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
|
|
2659
2658
|
const extrinsic = await (0, _bonding.getCancelWithdrawalExtrinsic)(substrateApi, chain, selectedUnstaking);
|
|
2660
2659
|
return await this.#koniState.transactionService.handleTransaction({
|
|
2661
2660
|
address,
|
|
@@ -2757,7 +2756,7 @@ class KoniExtension {
|
|
|
2757
2756
|
const chainInfo = this.#koniState.getChainInfo(networkKey);
|
|
2758
2757
|
const {
|
|
2759
2758
|
decimals
|
|
2760
|
-
} = (0,
|
|
2759
|
+
} = (0, _utils._getChainNativeTokenBasicInfo)(chainInfo);
|
|
2761
2760
|
const parsedAccountMinimum = parseFloat(accountMinimum) * 10 ** decimals;
|
|
2762
2761
|
const extrinsic = await (0, _paraChain.getTuringCompoundExtrinsic)(dotSamaApi, address, collatorAddress, parsedAccountMinimum.toString(), bondedAmount);
|
|
2763
2762
|
return await this.#koniState.transactionService.handleTransaction({
|
|
@@ -2978,7 +2977,7 @@ class KoniExtension {
|
|
|
2978
2977
|
const {
|
|
2979
2978
|
payload
|
|
2980
2979
|
} = request;
|
|
2981
|
-
let registry = new
|
|
2980
|
+
let registry = new _types3.TypeRegistry();
|
|
2982
2981
|
let isEvm = false;
|
|
2983
2982
|
if ((0, _Extension.isJsonPayload)(payload)) {
|
|
2984
2983
|
// Get the metadata for the genesisHash
|
|
@@ -3000,7 +2999,7 @@ class KoniExtension {
|
|
|
3000
2999
|
}
|
|
3001
3000
|
}
|
|
3002
3001
|
if (chainInfo) {
|
|
3003
|
-
isEvm = (0,
|
|
3002
|
+
isEvm = (0, _utils._isChainEvmCompatible)(chainInfo);
|
|
3004
3003
|
}
|
|
3005
3004
|
}
|
|
3006
3005
|
const result = request.sign(registry, pair);
|
|
@@ -3378,12 +3377,12 @@ class KoniExtension {
|
|
|
3378
3377
|
if (namespace.chains) {
|
|
3379
3378
|
const unSupportChains = namespace.chains.filter(chain => !(0, _helpers2.isSupportWalletConnectChain)(chain, chainInfoMap));
|
|
3380
3379
|
if (unSupportChains.length) {
|
|
3381
|
-
throw new Error((0,
|
|
3380
|
+
throw new Error((0, _utils3.getSdkError)('UNSUPPORTED_CHAINS').message + ' ' + unSupportChains.toString());
|
|
3382
3381
|
}
|
|
3383
3382
|
availableNamespaces[key] = namespace;
|
|
3384
3383
|
}
|
|
3385
3384
|
} else {
|
|
3386
|
-
throw new Error((0,
|
|
3385
|
+
throw new Error((0, _utils3.getSdkError)('UNSUPPORTED_NAMESPACE_KEY').message + ' ' + key);
|
|
3387
3386
|
}
|
|
3388
3387
|
});
|
|
3389
3388
|
Object.entries(optionalNamespaces).forEach(_ref84 => {
|
|
@@ -3415,7 +3414,7 @@ class KoniExtension {
|
|
|
3415
3414
|
let [key, namespace] = _ref85;
|
|
3416
3415
|
if (namespace.chains) {
|
|
3417
3416
|
const accounts = [];
|
|
3418
|
-
const chains = (0,
|
|
3417
|
+
const chains = (0, _utils2.uniqueStringArray)(namespace.chains);
|
|
3419
3418
|
chains.forEach(chain => {
|
|
3420
3419
|
accounts.push(...selectedAccounts.filter(address => (0, _utilCrypto.isEthereumAddress)(address) === (key === _constants5.WALLET_CONNECT_EIP155_NAMESPACE)).map(address => `${chain}:${address}`));
|
|
3421
3420
|
});
|
|
@@ -3655,245 +3654,9 @@ class KoniExtension {
|
|
|
3655
3654
|
this.#koniState.keyringService.removeInjectAccounts(request.addresses);
|
|
3656
3655
|
return true;
|
|
3657
3656
|
}
|
|
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
|
-
}
|
|
3874
3657
|
|
|
3875
3658
|
/* Campaign */
|
|
3876
3659
|
|
|
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
|
-
}
|
|
3897
3660
|
async subscribeProcessingBanner(id, port) {
|
|
3898
3661
|
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
3899
3662
|
const filterBanner = data => {
|
|
@@ -3917,10 +3680,10 @@ class KoniExtension {
|
|
|
3917
3680
|
});
|
|
3918
3681
|
return filterBanner(await this.#koniState.campaignService.getProcessingCampaign());
|
|
3919
3682
|
}
|
|
3920
|
-
async completeCampaignBanner(
|
|
3683
|
+
async completeCampaignBanner(_ref92) {
|
|
3921
3684
|
let {
|
|
3922
3685
|
slug
|
|
3923
|
-
} =
|
|
3686
|
+
} = _ref92;
|
|
3924
3687
|
const campaign = await this.#koniState.dbService.getCampaign(slug);
|
|
3925
3688
|
if (campaign) {
|
|
3926
3689
|
await this.#koniState.dbService.upsertCampaign({
|
|
@@ -4097,8 +3860,6 @@ class KoniExtension {
|
|
|
4097
3860
|
return await this.subscribeBalance(id, port);
|
|
4098
3861
|
case 'pri(crowdloan.getCrowdloan)':
|
|
4099
3862
|
return this.getCrowdloan();
|
|
4100
|
-
case 'pri(crowdloan.getCrowdloanContributions)':
|
|
4101
|
-
return this.getCrowdloanContributions(request);
|
|
4102
3863
|
case 'pri(crowdloan.getSubscription)':
|
|
4103
3864
|
return this.subscribeCrowdloan(id, port);
|
|
4104
3865
|
case 'pri(derivation.createV2)':
|
|
@@ -4128,57 +3889,6 @@ class KoniExtension {
|
|
|
4128
3889
|
case 'pri(transaction.history.subscribe)':
|
|
4129
3890
|
return this.subscribeHistoryByChainAndAddress(request, id, port);
|
|
4130
3891
|
|
|
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
|
-
|
|
4182
3892
|
/* Account management */
|
|
4183
3893
|
// Add account
|
|
4184
3894
|
case 'pri(accounts.create.suriV2)':
|
|
@@ -4297,8 +4007,6 @@ class KoniExtension {
|
|
|
4297
4007
|
return this.transferGetExistentialDeposit(request);
|
|
4298
4008
|
case 'pri(transfer.getMaxTransferable)':
|
|
4299
4009
|
return this.transferGetMaxTransferable(request);
|
|
4300
|
-
case 'pri(transfer.subscribeMaxTransferable)':
|
|
4301
|
-
return this.transferGetMaxTransferable(request);
|
|
4302
4010
|
case 'pri(freeBalance.get)':
|
|
4303
4011
|
return this.getAddressFreeBalance(request);
|
|
4304
4012
|
case 'pri(freeBalance.subscribe)':
|
|
@@ -4357,6 +4065,8 @@ class KoniExtension {
|
|
|
4357
4065
|
return await this.submitBonding(request);
|
|
4358
4066
|
case 'pri(unbonding.submitTransaction)':
|
|
4359
4067
|
return await this.submitUnbonding(request);
|
|
4068
|
+
case 'pri(unbonding.submitWithdrawal)':
|
|
4069
|
+
return await this.submitStakeWithdrawal(request);
|
|
4360
4070
|
case 'pri(staking.submitClaimReward)':
|
|
4361
4071
|
return await this.submitStakeClaimReward(request);
|
|
4362
4072
|
case 'pri(staking.submitCancelWithdrawal)':
|
|
@@ -4460,15 +4170,6 @@ class KoniExtension {
|
|
|
4460
4170
|
case 'pri(mantaPay.subscribeSyncingState)':
|
|
4461
4171
|
return this.subscribeMantaPaySyncState(id, port);
|
|
4462
4172
|
|
|
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
|
-
|
|
4472
4173
|
// Metadata
|
|
4473
4174
|
case 'pri(metadata.find)':
|
|
4474
4175
|
return this.findRawMetadata(request);
|