@subwallet/extension-base 1.1.28-1 → 1.1.28-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 +92 -68
- package/background/KoniTypes.js +16 -13
- package/background/errors/TransactionError.js +9 -0
- package/cjs/background/KoniTypes.js +17 -16
- package/cjs/background/errors/TransactionError.js +9 -0
- package/cjs/constants/index.js +9 -3
- 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 +17 -15
- 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 +2 -0
- package/cjs/koni/background/handlers/Extension.js +323 -69
- package/cjs/koni/background/handlers/State.js +57 -4
- package/cjs/koni/background/handlers/index.js +4 -2
- package/cjs/koni/background/subscription.js +89 -19
- package/cjs/services/campaign-service/index.js +9 -6
- package/cjs/services/chain-service/constants.js +2 -16
- package/cjs/services/chain-service/utils.js +7 -1
- package/cjs/services/earning-service/constants/chains.js +29 -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 +202 -0
- package/cjs/services/earning-service/handlers/index.js +60 -0
- package/cjs/services/earning-service/handlers/lending/base.js +20 -0
- package/cjs/services/earning-service/handlers/lending/index.js +13 -0
- package/cjs/services/earning-service/handlers/lending/interlay.js +168 -0
- package/cjs/services/earning-service/handlers/liquid-staking/acala.js +196 -0
- package/cjs/services/earning-service/handlers/liquid-staking/base.js +39 -0
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +257 -0
- package/cjs/services/earning-service/handlers/liquid-staking/index.js +34 -0
- package/cjs/services/earning-service/handlers/liquid-staking/parallel.js +180 -0
- package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +373 -0
- package/cjs/services/earning-service/handlers/native-staking/amplitude.js +359 -0
- package/cjs/services/earning-service/handlers/native-staking/astar.js +426 -0
- package/cjs/services/earning-service/handlers/native-staking/base-para.js +137 -0
- package/cjs/services/earning-service/handlers/native-staking/base.js +109 -0
- package/cjs/services/earning-service/handlers/native-staking/index.js +34 -0
- package/cjs/services/earning-service/handlers/native-staking/para-chain.js +361 -0
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +512 -0
- package/cjs/services/earning-service/handlers/nomination-pool/index.js +501 -0
- package/cjs/services/earning-service/handlers/special.js +387 -0
- package/cjs/services/earning-service/service.js +327 -0
- package/cjs/services/earning-service/utils/index.js +111 -0
- package/cjs/services/event-service/index.js +4 -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/index.js +4 -0
- 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 +1 -1
- package/cjs/services/storage-service/DatabaseService.js +47 -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 +65 -0
- package/cjs/services/storage-service/index.js +241 -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 +180 -74
- 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 +37 -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 +34 -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/fetchStaticData.js +2 -1
- package/cjs/utils/index.js +89 -1
- package/cjs/utils/keyring.js +57 -0
- package/cjs/utils/object.js +12 -0
- package/constants/index.d.ts +2 -0
- package/constants/index.js +2 -0
- 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 +11 -9
- 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.js +2 -0
- package/koni/background/handlers/Extension.d.ts +14 -1
- package/koni/background/handlers/Extension.js +282 -30
- package/koni/background/handlers/State.d.ts +18 -2
- package/koni/background/handlers/State.js +56 -4
- package/koni/background/handlers/index.js +4 -2
- package/koni/background/subscription.d.ts +5 -1
- package/koni/background/subscription.js +91 -21
- package/package.json +307 -4
- package/services/campaign-service/index.js +9 -6
- package/services/chain-service/constants.d.ts +0 -11
- package/services/chain-service/constants.js +1 -14
- 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 +14 -0
- package/services/earning-service/constants/chains.js +21 -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 +105 -0
- package/services/earning-service/handlers/base.js +195 -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 +6 -0
- package/services/earning-service/handlers/lending/base.js +12 -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 +22 -0
- package/services/earning-service/handlers/lending/interlay.js +160 -0
- package/services/earning-service/handlers/liquid-staking/acala.d.ts +27 -0
- package/services/earning-service/handlers/liquid-staking/acala.js +188 -0
- package/services/earning-service/handlers/liquid-staking/base.d.ts +8 -0
- package/services/earning-service/handlers/liquid-staking/base.js +31 -0
- package/services/earning-service/handlers/liquid-staking/bifrost.d.ts +44 -0
- package/services/earning-service/handlers/liquid-staking/bifrost.js +246 -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 +27 -0
- package/services/earning-service/handlers/liquid-staking/parallel.js +172 -0
- package/services/earning-service/handlers/liquid-staking/stella-swap.d.ts +36 -0
- package/services/earning-service/handlers/liquid-staking/stella-swap.js +363 -0
- package/services/earning-service/handlers/native-staking/amplitude.d.ts +22 -0
- package/services/earning-service/handlers/native-staking/amplitude.js +350 -0
- package/services/earning-service/handlers/native-staking/astar.d.ts +18 -0
- package/services/earning-service/handlers/native-staking/astar.js +416 -0
- package/services/earning-service/handlers/native-staking/base-para.d.ts +11 -0
- package/services/earning-service/handlers/native-staking/base-para.js +129 -0
- package/services/earning-service/handlers/native-staking/base.d.ts +19 -0
- package/services/earning-service/handlers/native-staking/base.js +101 -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 +353 -0
- package/services/earning-service/handlers/native-staking/relay-chain.d.ts +21 -0
- package/services/earning-service/handlers/native-staking/relay-chain.js +503 -0
- package/services/earning-service/handlers/nomination-pool/index.d.ts +33 -0
- package/services/earning-service/handlers/nomination-pool/index.js +492 -0
- package/services/earning-service/handlers/special.d.ts +56 -0
- package/services/earning-service/handlers/special.js +379 -0
- package/services/earning-service/service.d.ts +36 -0
- package/services/earning-service/service.js +320 -0
- package/services/earning-service/utils/index.d.ts +14 -0
- package/services/earning-service/utils/index.js +100 -0
- package/services/event-service/index.d.ts +1 -0
- package/services/event-service/index.js +4 -0
- package/services/event-service/types.d.ts +8 -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/index.js +4 -0
- 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 +1 -1
- package/services/storage-service/DatabaseService.d.ts +17 -1
- package/services/storage-service/DatabaseService.js +47 -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 +9 -0
- package/services/storage-service/db-stores/YieldPositionStore.js +57 -0
- package/services/subscan-service/index.d.ts +2 -2
- 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 +4 -15
- package/services/transaction-service/index.js +178 -72
- 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 +75 -0
- package/types/yield/actions/join/step.js +34 -0
- package/types/yield/actions/join/submit.d.ts +53 -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 +60 -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 +112 -0
- package/types/yield/info/account/info.js +1 -0
- package/types/yield/info/account/reward.d.ts +41 -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 +28 -0
- package/types/yield/info/base.js +28 -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 +190 -0
- package/types/yield/info/chain/info.js +1 -0
- package/types/yield/info/chain/target.d.ts +33 -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/fetchStaticData.js +2 -1
- package/utils/index.d.ts +5 -0
- package/utils/index.js +53 -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) {
|
|
@@ -2599,36 +2615,18 @@ class KoniExtension {
|
|
|
2599
2615
|
chainType: _KoniTypes.ChainType.SUBSTRATE
|
|
2600
2616
|
});
|
|
2601
2617
|
}
|
|
2602
|
-
async submitStakeWithdrawal(inputData) {
|
|
2603
|
-
const {
|
|
2604
|
-
chain,
|
|
2605
|
-
nominatorMetadata,
|
|
2606
|
-
validatorAddress
|
|
2607
|
-
} = inputData;
|
|
2608
|
-
if (!nominatorMetadata) {
|
|
2609
|
-
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INVALID_PARAMS)]);
|
|
2610
|
-
}
|
|
2611
|
-
const dotSamaApi = this.#koniState.getSubstrateApi(chain);
|
|
2612
|
-
const extrinsic = await (0, _bonding.getWithdrawalExtrinsic)(dotSamaApi, chain, nominatorMetadata, validatorAddress);
|
|
2613
|
-
return await this.#koniState.transactionService.handleTransaction({
|
|
2614
|
-
address: nominatorMetadata.address,
|
|
2615
|
-
chain: chain,
|
|
2616
|
-
transaction: extrinsic,
|
|
2617
|
-
data: inputData,
|
|
2618
|
-
extrinsicType: _KoniTypes.ExtrinsicType.STAKING_WITHDRAW,
|
|
2619
|
-
chainType: _KoniTypes.ChainType.SUBSTRATE
|
|
2620
|
-
});
|
|
2621
|
-
}
|
|
2622
2618
|
async submitStakeClaimReward(inputData) {
|
|
2623
2619
|
const {
|
|
2624
2620
|
address,
|
|
2625
2621
|
bondReward,
|
|
2626
|
-
|
|
2627
|
-
stakingType
|
|
2622
|
+
slug
|
|
2628
2623
|
} = inputData;
|
|
2629
|
-
|
|
2624
|
+
const poolHandler = this.#koniState.earningService.getPoolHandler(slug);
|
|
2625
|
+
if (!address || !poolHandler) {
|
|
2630
2626
|
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INVALID_PARAMS)]);
|
|
2631
2627
|
}
|
|
2628
|
+
const chain = poolHandler.chain;
|
|
2629
|
+
const stakingType = poolHandler.type === _types3.YieldPoolType.NOMINATION_POOL ? _KoniTypes.StakingType.POOLED : _KoniTypes.StakingType.NOMINATED;
|
|
2632
2630
|
const substrateApi = this.#koniState.getSubstrateApi(chain);
|
|
2633
2631
|
const extrinsic = await (0, _bonding.getClaimRewardExtrinsic)(substrateApi, chain, address, stakingType, bondReward);
|
|
2634
2632
|
return await this.#koniState.transactionService.handleTransaction({
|
|
@@ -2641,15 +2639,18 @@ class KoniExtension {
|
|
|
2641
2639
|
});
|
|
2642
2640
|
}
|
|
2643
2641
|
async submitCancelStakeWithdrawal(inputData) {
|
|
2642
|
+
var _this$koniState$earni;
|
|
2644
2643
|
const {
|
|
2645
2644
|
address,
|
|
2646
|
-
|
|
2647
|
-
|
|
2645
|
+
selectedUnstaking,
|
|
2646
|
+
slug
|
|
2648
2647
|
} = inputData;
|
|
2648
|
+
const chain = (_this$koniState$earni = this.#koniState.earningService.getPoolHandler(slug)) === null || _this$koniState$earni === void 0 ? void 0 : _this$koniState$earni.chain;
|
|
2649
2649
|
if (!chain || !selectedUnstaking) {
|
|
2650
2650
|
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INVALID_PARAMS)]);
|
|
2651
2651
|
}
|
|
2652
2652
|
const substrateApi = this.#koniState.getSubstrateApi(chain);
|
|
2653
|
+
// @ts-ignore
|
|
2653
2654
|
const extrinsic = await (0, _bonding.getCancelWithdrawalExtrinsic)(substrateApi, chain, selectedUnstaking);
|
|
2654
2655
|
return await this.#koniState.transactionService.handleTransaction({
|
|
2655
2656
|
address,
|
|
@@ -2740,7 +2741,7 @@ class KoniExtension {
|
|
|
2740
2741
|
const chainInfo = this.#koniState.getChainInfo(networkKey);
|
|
2741
2742
|
const {
|
|
2742
2743
|
decimals
|
|
2743
|
-
} = (0,
|
|
2744
|
+
} = (0, _utils2._getChainNativeTokenBasicInfo)(chainInfo);
|
|
2744
2745
|
const parsedAccountMinimum = parseFloat(accountMinimum) * 10 ** decimals;
|
|
2745
2746
|
const extrinsic = await (0, _paraChain.getTuringCompoundExtrinsic)(dotSamaApi, address, collatorAddress, parsedAccountMinimum.toString(), bondedAmount);
|
|
2746
2747
|
return await this.#koniState.transactionService.handleTransaction({
|
|
@@ -2961,7 +2962,7 @@ class KoniExtension {
|
|
|
2961
2962
|
const {
|
|
2962
2963
|
payload
|
|
2963
2964
|
} = request;
|
|
2964
|
-
let registry = new
|
|
2965
|
+
let registry = new _types4.TypeRegistry();
|
|
2965
2966
|
let isEvm = false;
|
|
2966
2967
|
if ((0, _Extension.isJsonPayload)(payload)) {
|
|
2967
2968
|
// Get the metadata for the genesisHash
|
|
@@ -2983,7 +2984,7 @@ class KoniExtension {
|
|
|
2983
2984
|
}
|
|
2984
2985
|
}
|
|
2985
2986
|
if (chainInfo) {
|
|
2986
|
-
isEvm = (0,
|
|
2987
|
+
isEvm = (0, _utils2._isChainEvmCompatible)(chainInfo);
|
|
2987
2988
|
}
|
|
2988
2989
|
}
|
|
2989
2990
|
const result = request.sign(registry, pair);
|
|
@@ -3361,12 +3362,12 @@ class KoniExtension {
|
|
|
3361
3362
|
if (namespace.chains) {
|
|
3362
3363
|
const unSupportChains = namespace.chains.filter(chain => !(0, _helpers2.isSupportWalletConnectChain)(chain, chainInfoMap));
|
|
3363
3364
|
if (unSupportChains.length) {
|
|
3364
|
-
throw new Error((0,
|
|
3365
|
+
throw new Error((0, _utils4.getSdkError)('UNSUPPORTED_CHAINS').message + ' ' + unSupportChains.toString());
|
|
3365
3366
|
}
|
|
3366
3367
|
availableNamespaces[key] = namespace;
|
|
3367
3368
|
}
|
|
3368
3369
|
} else {
|
|
3369
|
-
throw new Error((0,
|
|
3370
|
+
throw new Error((0, _utils4.getSdkError)('UNSUPPORTED_NAMESPACE_KEY').message + ' ' + key);
|
|
3370
3371
|
}
|
|
3371
3372
|
});
|
|
3372
3373
|
Object.entries(optionalNamespaces).forEach(_ref84 => {
|
|
@@ -3398,7 +3399,7 @@ class KoniExtension {
|
|
|
3398
3399
|
let [key, namespace] = _ref85;
|
|
3399
3400
|
if (namespace.chains) {
|
|
3400
3401
|
const accounts = [];
|
|
3401
|
-
const chains = (0,
|
|
3402
|
+
const chains = (0, _utils3.uniqueStringArray)(namespace.chains);
|
|
3402
3403
|
chains.forEach(chain => {
|
|
3403
3404
|
accounts.push(...selectedAccounts.filter(address => (0, _utilCrypto.isEthereumAddress)(address) === (key === _constants5.WALLET_CONNECT_EIP155_NAMESPACE)).map(address => `${chain}:${address}`));
|
|
3404
3405
|
});
|
|
@@ -3638,9 +3639,206 @@ class KoniExtension {
|
|
|
3638
3639
|
this.#koniState.keyringService.removeInjectAccounts(request.addresses);
|
|
3639
3640
|
return true;
|
|
3640
3641
|
}
|
|
3642
|
+
subscribeYieldPoolInfo(id, port) {
|
|
3643
|
+
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
3644
|
+
const yieldPoolSubscription = this.#koniState.subscribeYieldPoolInfo().subscribe({
|
|
3645
|
+
next: rs => {
|
|
3646
|
+
cb(rs);
|
|
3647
|
+
}
|
|
3648
|
+
});
|
|
3649
|
+
this.createUnsubscriptionHandle(id, yieldPoolSubscription.unsubscribe);
|
|
3650
|
+
port.onDisconnect.addListener(() => {
|
|
3651
|
+
this.cancelSubscription(id);
|
|
3652
|
+
});
|
|
3653
|
+
return this.#koniState.getYieldPoolInfo();
|
|
3654
|
+
}
|
|
3655
|
+
async getOptimalYieldPath(request) {
|
|
3656
|
+
return await this.#koniState.earningService.generateOptimalSteps(request);
|
|
3657
|
+
}
|
|
3658
|
+
async handleYieldStep(inputData) {
|
|
3659
|
+
const {
|
|
3660
|
+
data,
|
|
3661
|
+
path
|
|
3662
|
+
} = inputData;
|
|
3663
|
+
const {
|
|
3664
|
+
address
|
|
3665
|
+
} = data;
|
|
3666
|
+
if (!data) {
|
|
3667
|
+
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INTERNAL_ERROR)]);
|
|
3668
|
+
}
|
|
3669
|
+
const isLastStep = inputData.currentStep + 1 === path.steps.length;
|
|
3670
|
+
const yieldValidation = await this.#koniState.earningService.validateYieldJoin({
|
|
3671
|
+
data,
|
|
3672
|
+
path
|
|
3673
|
+
}); // TODO: validate, set to fail upon submission
|
|
3674
|
+
|
|
3675
|
+
if (yieldValidation.length > 0) {
|
|
3676
|
+
return this.#koniState.transactionService.generateBeforeHandleResponseErrors(yieldValidation);
|
|
3677
|
+
}
|
|
3678
|
+
|
|
3679
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
3680
|
+
const {
|
|
3681
|
+
extrinsic,
|
|
3682
|
+
extrinsicType,
|
|
3683
|
+
transferNativeAmount,
|
|
3684
|
+
txChain,
|
|
3685
|
+
txData
|
|
3686
|
+
} = await this.#koniState.earningService.handleYieldJoin(inputData);
|
|
3687
|
+
const isPoolSupportAlternativeFee = this.#koniState.earningService.isPoolSupportAlternativeFee(inputData.data.slug);
|
|
3688
|
+
const isMintingStep = _utils.YIELD_EXTRINSIC_TYPES.includes(extrinsicType);
|
|
3689
|
+
const chainInfo = this.#koniState.getChainInfo(txChain);
|
|
3690
|
+
return await this.#koniState.transactionService.handleTransaction({
|
|
3691
|
+
address,
|
|
3692
|
+
chain: txChain,
|
|
3693
|
+
transaction: extrinsic,
|
|
3694
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
3695
|
+
data: txData,
|
|
3696
|
+
extrinsicType,
|
|
3697
|
+
// change this depends on step
|
|
3698
|
+
chainType: (0, _utils2._isChainEvmCompatible)(chainInfo) ? _KoniTypes.ChainType.EVM : _KoniTypes.ChainType.SUBSTRATE,
|
|
3699
|
+
resolveOnDone: !isLastStep,
|
|
3700
|
+
transferNativeAmount,
|
|
3701
|
+
skipFeeValidation: isMintingStep && isPoolSupportAlternativeFee
|
|
3702
|
+
});
|
|
3703
|
+
}
|
|
3704
|
+
async handleYieldLeave(params) {
|
|
3705
|
+
const {
|
|
3706
|
+
address,
|
|
3707
|
+
slug
|
|
3708
|
+
} = params;
|
|
3709
|
+
const leaveValidation = await this.#koniState.earningService.validateYieldLeave(params);
|
|
3710
|
+
if (leaveValidation.length > 0) {
|
|
3711
|
+
return this.#koniState.transactionService.generateBeforeHandleResponseErrors(leaveValidation);
|
|
3712
|
+
}
|
|
3713
|
+
const [extrinsicType, extrinsic] = await this.#koniState.earningService.handleYieldLeave(params);
|
|
3714
|
+
const handler = this.#koniState.earningService.getPoolHandler(slug);
|
|
3715
|
+
return await this.#koniState.transactionService.handleTransaction({
|
|
3716
|
+
address,
|
|
3717
|
+
chain: (handler === null || handler === void 0 ? void 0 : handler.chain) || '',
|
|
3718
|
+
transaction: extrinsic,
|
|
3719
|
+
data: params,
|
|
3720
|
+
// TODO
|
|
3721
|
+
extrinsicType,
|
|
3722
|
+
chainType: (handler === null || handler === void 0 ? void 0 : handler.transactionChainType) || _KoniTypes.ChainType.SUBSTRATE
|
|
3723
|
+
});
|
|
3724
|
+
}
|
|
3725
|
+
async getYieldPoolTargets(request) {
|
|
3726
|
+
const {
|
|
3727
|
+
slug
|
|
3728
|
+
} = request;
|
|
3729
|
+
return this.#koniState.earningService.getPoolTargets(slug);
|
|
3730
|
+
}
|
|
3731
|
+
async subscribeYieldPosition(id, port) {
|
|
3732
|
+
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
3733
|
+
const yieldPositionSubscription = this.#koniState.subscribeYieldPosition().subscribe({
|
|
3734
|
+
next: rs => {
|
|
3735
|
+
cb(rs);
|
|
3736
|
+
}
|
|
3737
|
+
});
|
|
3738
|
+
this.createUnsubscriptionHandle(id, yieldPositionSubscription.unsubscribe);
|
|
3739
|
+
port.onDisconnect.addListener(() => {
|
|
3740
|
+
this.cancelSubscription(id);
|
|
3741
|
+
});
|
|
3742
|
+
return this.#koniState.getYieldPositionInfo();
|
|
3743
|
+
}
|
|
3744
|
+
subscribeYieldReward(id, port) {
|
|
3745
|
+
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
3746
|
+
const stakingRewardSubscription = this.#koniState.earningService.subscribeEarningReward().subscribe({
|
|
3747
|
+
next: rs => {
|
|
3748
|
+
cb(rs);
|
|
3749
|
+
}
|
|
3750
|
+
});
|
|
3751
|
+
this.createUnsubscriptionHandle(id, stakingRewardSubscription.unsubscribe);
|
|
3752
|
+
port.onDisconnect.addListener(() => {
|
|
3753
|
+
this.cancelSubscription(id);
|
|
3754
|
+
});
|
|
3755
|
+
return this.#koniState.earningService.getEarningRewards();
|
|
3756
|
+
}
|
|
3757
|
+
handleValidateYieldProcess(inputData) {
|
|
3758
|
+
return this.#koniState.earningService.validateYieldJoin(inputData);
|
|
3759
|
+
}
|
|
3760
|
+
async yieldSubmitWithdrawal(params) {
|
|
3761
|
+
const {
|
|
3762
|
+
address,
|
|
3763
|
+
slug
|
|
3764
|
+
} = params;
|
|
3765
|
+
const poolHandler = this.#koniState.earningService.getPoolHandler(slug);
|
|
3766
|
+
if (!poolHandler) {
|
|
3767
|
+
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INVALID_PARAMS)]);
|
|
3768
|
+
}
|
|
3769
|
+
const extrinsic = await this.#koniState.earningService.handleYieldWithdraw(params);
|
|
3770
|
+
return await this.#koniState.transactionService.handleTransaction({
|
|
3771
|
+
address: address,
|
|
3772
|
+
chain: poolHandler.chain,
|
|
3773
|
+
transaction: extrinsic,
|
|
3774
|
+
data: params,
|
|
3775
|
+
extrinsicType: _KoniTypes.ExtrinsicType.STAKING_WITHDRAW,
|
|
3776
|
+
chainType: (poolHandler === null || poolHandler === void 0 ? void 0 : poolHandler.transactionChainType) || _KoniTypes.ChainType.SUBSTRATE
|
|
3777
|
+
});
|
|
3778
|
+
}
|
|
3779
|
+
async yieldSubmitCancelWithdrawal(params) {
|
|
3780
|
+
const {
|
|
3781
|
+
address,
|
|
3782
|
+
selectedUnstaking,
|
|
3783
|
+
slug
|
|
3784
|
+
} = params;
|
|
3785
|
+
const poolHandler = this.#koniState.earningService.getPoolHandler(slug);
|
|
3786
|
+
if (!poolHandler || !selectedUnstaking) {
|
|
3787
|
+
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INVALID_PARAMS)]);
|
|
3788
|
+
}
|
|
3789
|
+
const chain = poolHandler.chain;
|
|
3790
|
+
const extrinsic = await this.#koniState.earningService.handleYieldCancelUnstake(params);
|
|
3791
|
+
return await this.#koniState.transactionService.handleTransaction({
|
|
3792
|
+
address,
|
|
3793
|
+
chain,
|
|
3794
|
+
transaction: extrinsic,
|
|
3795
|
+
data: params,
|
|
3796
|
+
extrinsicType: _KoniTypes.ExtrinsicType.STAKING_CANCEL_UNSTAKE,
|
|
3797
|
+
chainType: (poolHandler === null || poolHandler === void 0 ? void 0 : poolHandler.transactionChainType) || _KoniTypes.ChainType.SUBSTRATE
|
|
3798
|
+
});
|
|
3799
|
+
}
|
|
3800
|
+
async yieldSubmitClaimReward(params) {
|
|
3801
|
+
const {
|
|
3802
|
+
address,
|
|
3803
|
+
slug
|
|
3804
|
+
} = params;
|
|
3805
|
+
const poolHandler = this.#koniState.earningService.getPoolHandler(slug);
|
|
3806
|
+
if (!address || !poolHandler) {
|
|
3807
|
+
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INVALID_PARAMS)]);
|
|
3808
|
+
}
|
|
3809
|
+
const extrinsic = await this.#koniState.earningService.handleYieldClaimReward(params);
|
|
3810
|
+
return await this.#koniState.transactionService.handleTransaction({
|
|
3811
|
+
address,
|
|
3812
|
+
chain: poolHandler.chain,
|
|
3813
|
+
transaction: extrinsic,
|
|
3814
|
+
data: params,
|
|
3815
|
+
extrinsicType: _KoniTypes.ExtrinsicType.STAKING_CLAIM_REWARD,
|
|
3816
|
+
chainType: (poolHandler === null || poolHandler === void 0 ? void 0 : poolHandler.transactionChainType) || _KoniTypes.ChainType.SUBSTRATE
|
|
3817
|
+
});
|
|
3818
|
+
}
|
|
3641
3819
|
|
|
3642
3820
|
/* Campaign */
|
|
3643
3821
|
|
|
3822
|
+
unlockDotCheckCanMint(_ref92) {
|
|
3823
|
+
let {
|
|
3824
|
+
address,
|
|
3825
|
+
network,
|
|
3826
|
+
slug
|
|
3827
|
+
} = _ref92;
|
|
3828
|
+
return this.#koniState.mintCampaignService.unlockDotCampaign.canMint(address, slug, network);
|
|
3829
|
+
}
|
|
3830
|
+
unlockDotSubscribeMintedData(id, port, _ref93) {
|
|
3831
|
+
let {
|
|
3832
|
+
transactionId
|
|
3833
|
+
} = _ref93;
|
|
3834
|
+
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
3835
|
+
const subscription = this.#koniState.mintCampaignService.unlockDotCampaign.subscribeMintedNft(transactionId, cb);
|
|
3836
|
+
this.createUnsubscriptionHandle(id, subscription.unsubscribe);
|
|
3837
|
+
port.onDisconnect.addListener(() => {
|
|
3838
|
+
this.cancelSubscription(id);
|
|
3839
|
+
});
|
|
3840
|
+
return this.#koniState.mintCampaignService.unlockDotCampaign.getMintedNft(transactionId);
|
|
3841
|
+
}
|
|
3644
3842
|
async subscribeProcessingBanner(id, port) {
|
|
3645
3843
|
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
3646
3844
|
const filterBanner = data => {
|
|
@@ -3664,10 +3862,10 @@ class KoniExtension {
|
|
|
3664
3862
|
});
|
|
3665
3863
|
return filterBanner(await this.#koniState.campaignService.getProcessingCampaign());
|
|
3666
3864
|
}
|
|
3667
|
-
async completeCampaignBanner(
|
|
3865
|
+
async completeCampaignBanner(_ref94) {
|
|
3668
3866
|
let {
|
|
3669
3867
|
slug
|
|
3670
|
-
} =
|
|
3868
|
+
} = _ref94;
|
|
3671
3869
|
const campaign = await this.#koniState.dbService.getCampaign(slug);
|
|
3672
3870
|
if (campaign) {
|
|
3673
3871
|
await this.#koniState.dbService.upsertCampaign({
|
|
@@ -3844,6 +4042,8 @@ class KoniExtension {
|
|
|
3844
4042
|
return await this.subscribeBalance(id, port);
|
|
3845
4043
|
case 'pri(crowdloan.getCrowdloan)':
|
|
3846
4044
|
return this.getCrowdloan();
|
|
4045
|
+
case 'pri(crowdloan.getCrowdloanContributions)':
|
|
4046
|
+
return this.getCrowdloanContributions(request);
|
|
3847
4047
|
case 'pri(crowdloan.getSubscription)':
|
|
3848
4048
|
return this.subscribeCrowdloan(id, port);
|
|
3849
4049
|
case 'pri(derivation.createV2)':
|
|
@@ -3873,6 +4073,51 @@ class KoniExtension {
|
|
|
3873
4073
|
case 'pri(transaction.history.subscribe)':
|
|
3874
4074
|
return this.subscribeHistoryByChainAndAddress(request, id, port);
|
|
3875
4075
|
|
|
4076
|
+
/* Earning */
|
|
4077
|
+
|
|
4078
|
+
/* Info */
|
|
4079
|
+
|
|
4080
|
+
case 'pri(yield.subscribePoolInfo)':
|
|
4081
|
+
return this.subscribeYieldPoolInfo(id, port);
|
|
4082
|
+
case 'pri(yield.getTargets)':
|
|
4083
|
+
return this.getYieldPoolTargets(request);
|
|
4084
|
+
case 'pri(yield.subscribeYieldPosition)':
|
|
4085
|
+
return this.subscribeYieldPosition(id, port);
|
|
4086
|
+
case 'pri(yield.subscribeYieldReward)':
|
|
4087
|
+
return this.subscribeYieldReward(id, port);
|
|
4088
|
+
|
|
4089
|
+
/* Info */
|
|
4090
|
+
|
|
4091
|
+
/* Actions */
|
|
4092
|
+
|
|
4093
|
+
/* Join */
|
|
4094
|
+
|
|
4095
|
+
case 'pri(yield.join.getOptimalPath)':
|
|
4096
|
+
return await this.getOptimalYieldPath(request);
|
|
4097
|
+
case 'pri(yield.join.handleStep)':
|
|
4098
|
+
return await this.handleYieldStep(request);
|
|
4099
|
+
case 'pri(yield.join.validateProcess)':
|
|
4100
|
+
return await this.handleValidateYieldProcess(request);
|
|
4101
|
+
|
|
4102
|
+
/* Join */
|
|
4103
|
+
|
|
4104
|
+
/* Others */
|
|
4105
|
+
|
|
4106
|
+
case 'pri(yield.leave.submit)':
|
|
4107
|
+
return await this.handleYieldLeave(request);
|
|
4108
|
+
case 'pri(yield.withdraw.submit)':
|
|
4109
|
+
return await this.yieldSubmitWithdrawal(request);
|
|
4110
|
+
case 'pri(yield.cancelWithdrawal.submit)':
|
|
4111
|
+
return await this.yieldSubmitCancelWithdrawal(request);
|
|
4112
|
+
case 'pri(yield.claimReward.submit)':
|
|
4113
|
+
return await this.yieldSubmitClaimReward(request);
|
|
4114
|
+
|
|
4115
|
+
/* Others */
|
|
4116
|
+
|
|
4117
|
+
/* Actions */
|
|
4118
|
+
|
|
4119
|
+
/* Earning */
|
|
4120
|
+
|
|
3876
4121
|
/* Account management */
|
|
3877
4122
|
// Add account
|
|
3878
4123
|
case 'pri(accounts.create.suriV2)':
|
|
@@ -3991,6 +4236,8 @@ class KoniExtension {
|
|
|
3991
4236
|
return this.transferGetExistentialDeposit(request);
|
|
3992
4237
|
case 'pri(transfer.getMaxTransferable)':
|
|
3993
4238
|
return this.transferGetMaxTransferable(request);
|
|
4239
|
+
case 'pri(transfer.subscribeMaxTransferable)':
|
|
4240
|
+
return this.transferGetMaxTransferable(request);
|
|
3994
4241
|
case 'pri(freeBalance.get)':
|
|
3995
4242
|
return this.getAddressFreeBalance(request);
|
|
3996
4243
|
case 'pri(freeBalance.subscribe)':
|
|
@@ -4049,8 +4296,6 @@ class KoniExtension {
|
|
|
4049
4296
|
return await this.submitBonding(request);
|
|
4050
4297
|
case 'pri(unbonding.submitTransaction)':
|
|
4051
4298
|
return await this.submitUnbonding(request);
|
|
4052
|
-
case 'pri(unbonding.submitWithdrawal)':
|
|
4053
|
-
return await this.submitStakeWithdrawal(request);
|
|
4054
4299
|
case 'pri(staking.submitClaimReward)':
|
|
4055
4300
|
return await this.submitStakeClaimReward(request);
|
|
4056
4301
|
case 'pri(staking.submitCancelWithdrawal)':
|
|
@@ -4154,6 +4399,15 @@ class KoniExtension {
|
|
|
4154
4399
|
case 'pri(mantaPay.subscribeSyncingState)':
|
|
4155
4400
|
return this.subscribeMantaPaySyncState(id, port);
|
|
4156
4401
|
|
|
4402
|
+
/* Campaign */
|
|
4403
|
+
|
|
4404
|
+
case 'pri(campaign.unlockDot.canMint)':
|
|
4405
|
+
return this.unlockDotCheckCanMint(request);
|
|
4406
|
+
case 'pri(campaign.unlockDot.subscribe)':
|
|
4407
|
+
return this.unlockDotSubscribeMintedData(id, port, request);
|
|
4408
|
+
|
|
4409
|
+
/* Campaign */
|
|
4410
|
+
|
|
4157
4411
|
// Metadata
|
|
4158
4412
|
case 'pri(metadata.find)':
|
|
4159
4413
|
return this.findRawMetadata(request);
|