@subwallet/extension-base 1.1.33-beta.1 → 1.1.34-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 -120
- package/background/KoniTypes.js +13 -22
- package/background/errors/TransactionError.js +0 -9
- package/cjs/background/KoniTypes.js +16 -23
- 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 +17 -2
- package/cjs/services/chain-service/index.js +3 -25
- 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 +1 -92
- package/cjs/services/storage-service/databases/index.js +0 -7
- 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 -252
- 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 +8 -331
- 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 +13 -1
- package/services/chain-service/constants.js +15 -1
- package/services/chain-service/index.d.ts +0 -2
- package/services/chain-service/index.js +3 -25
- 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 +3 -30
- package/services/storage-service/DatabaseService.js +1 -91
- package/services/storage-service/databases/index.d.ts +2 -8
- package/services/storage-service/databases/index.js +0 -7
- 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 -250
- 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 -49
- 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 -98
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost-manta.js +0 -140
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +0 -299
- package/cjs/services/earning-service/handlers/liquid-staking/index.js +0 -41
- 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 -497
- package/cjs/services/earning-service/service.js +0 -741
- 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/AssetRef.js +0 -24
- 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 -48
- 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 -34
- 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 -90
- package/services/earning-service/handlers/liquid-staking/bifrost-manta.d.ts +0 -37
- package/services/earning-service/handlers/liquid-staking/bifrost-manta.js +0 -132
- package/services/earning-service/handlers/liquid-staking/bifrost.d.ts +0 -46
- package/services/earning-service/handlers/liquid-staking/bifrost.js +0 -288
- package/services/earning-service/handlers/liquid-staking/index.d.ts +0 -5
- package/services/earning-service/handlers/liquid-staking/index.js +0 -8
- 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 -489
- package/services/earning-service/service.d.ts +0 -94
- package/services/earning-service/service.js +0 -730
- 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/AssetRef.d.ts +0 -7
- package/services/storage-service/db-stores/AssetRef.js +0 -16
- 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 -96
- package/types/yield/actions/join/step.js +0 -47
- 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
|
@@ -1,497 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _TransactionError = require("@subwallet/extension-base/background/errors/TransactionError");
|
|
9
|
-
var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
10
|
-
var _constants = require("@subwallet/extension-base/constants");
|
|
11
|
-
var _xcm = require("@subwallet/extension-base/koni/api/xcm");
|
|
12
|
-
var _utils = require("@subwallet/extension-base/koni/api/yield/helper/utils");
|
|
13
|
-
var _utils2 = require("@subwallet/extension-base/services/chain-service/utils");
|
|
14
|
-
var _types = require("@subwallet/extension-base/types");
|
|
15
|
-
var _utils3 = require("@subwallet/extension-base/utils");
|
|
16
|
-
var _i18next = require("i18next");
|
|
17
|
-
var _util = require("@polkadot/util");
|
|
18
|
-
var _base = _interopRequireDefault(require("./base"));
|
|
19
|
-
// Copyright 2019-2022 @subwallet/extension-base
|
|
20
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
21
|
-
|
|
22
|
-
class BaseSpecialStakingPoolHandler extends _base.default {
|
|
23
|
-
/** Pool's type */
|
|
24
|
-
|
|
25
|
-
/** Exchange rate before divine with decimals */
|
|
26
|
-
rate = 0;
|
|
27
|
-
constructor(state, chain) {
|
|
28
|
-
super(state, chain);
|
|
29
|
-
this.exchangeRatePromise = (0, _utils3.createPromiseHandler)();
|
|
30
|
-
}
|
|
31
|
-
get metadataInfo() {
|
|
32
|
-
return {
|
|
33
|
-
altInputAssets: this.altInputAsset,
|
|
34
|
-
derivativeAssets: this.derivativeAssets,
|
|
35
|
-
inputAsset: this.inputAsset,
|
|
36
|
-
rewardAssets: this.rewardAssets,
|
|
37
|
-
feeAssets: this.feeAssets,
|
|
38
|
-
logo: this.logo,
|
|
39
|
-
shortName: this.shortName,
|
|
40
|
-
name: this.name,
|
|
41
|
-
isAvailable: true,
|
|
42
|
-
maintainAsset: this.nativeToken.slug,
|
|
43
|
-
maintainBalance: this.maintainBalance,
|
|
44
|
-
availableMethod: this.availableMethod
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
updateExchangeRate(rate) {
|
|
48
|
-
this.rate = rate;
|
|
49
|
-
this.exchangeRatePromise.resolve(true);
|
|
50
|
-
}
|
|
51
|
-
async getExchangeRate() {
|
|
52
|
-
await this.exchangeRatePromise.promise;
|
|
53
|
-
return this.rate;
|
|
54
|
-
}
|
|
55
|
-
get isPoolSupportAlternativeFee() {
|
|
56
|
-
return this.feeAssets.length > 1;
|
|
57
|
-
}
|
|
58
|
-
async earlyValidate(request) {
|
|
59
|
-
var _poolInfo$statistic;
|
|
60
|
-
const poolInfo = await this.getPoolInfo();
|
|
61
|
-
if (!poolInfo || !((_poolInfo$statistic = poolInfo.statistic) !== null && _poolInfo$statistic !== void 0 && _poolInfo$statistic.earningThreshold.join)) {
|
|
62
|
-
return {
|
|
63
|
-
passed: false,
|
|
64
|
-
errorMessage: 'There is a problem fetching your data. Check your Internet connection or change the network endpoint and try again.'
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
if (request.address === _constants.ALL_ACCOUNT_KEY) {
|
|
68
|
-
return {
|
|
69
|
-
passed: true
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
const feeAssetInfo = this.state.chainService.getAssetBySlug(this.feeAssets[0]);
|
|
73
|
-
const altInputAssetInfo = this.state.chainService.getAssetBySlug(this.altInputAsset);
|
|
74
|
-
const inputAssetInfo = this.state.chainService.getAssetBySlug(this.inputAsset);
|
|
75
|
-
const [inputAssetBalance, altInputAssetBalance, feeAssetBalance] = await Promise.all([this.state.balanceService.getTokenFreeBalance(request.address, inputAssetInfo.originChain, inputAssetInfo.slug), altInputAssetInfo ? this.state.balanceService.getTokenFreeBalance(request.address, altInputAssetInfo.originChain, altInputAssetInfo.slug) : Promise.resolve({
|
|
76
|
-
symbol: '',
|
|
77
|
-
decimals: 0,
|
|
78
|
-
value: '0'
|
|
79
|
-
}), this.state.balanceService.getTokenFreeBalance(request.address, feeAssetInfo.originChain, feeAssetInfo.slug)]);
|
|
80
|
-
const bnInputAssetBalance = new _util.BN(inputAssetBalance.value);
|
|
81
|
-
const bnAltInputAssetBalance = new _util.BN(altInputAssetBalance.value);
|
|
82
|
-
const bnMinJoinPool = new _util.BN(poolInfo.statistic.earningThreshold.join);
|
|
83
|
-
const inputTokenInfo = this.state.chainService.getAssetBySlug(this.inputAsset);
|
|
84
|
-
const altInputTokenInfo = this.state.chainService.getAssetBySlug(this.altInputAsset);
|
|
85
|
-
if (bnInputAssetBalance.add(bnAltInputAssetBalance).lt(bnMinJoinPool)) {
|
|
86
|
-
const originChain = this.state.getChainInfo(inputTokenInfo.originChain);
|
|
87
|
-
const altChain = this.state.getChainInfo(altInputTokenInfo.originChain);
|
|
88
|
-
const parsedMinJoinPool = (0, _utils3.formatNumber)(bnMinJoinPool.toString(), inputAssetInfo.decimals || 0);
|
|
89
|
-
return {
|
|
90
|
-
passed: false,
|
|
91
|
-
errorMessage: `You need at least ${parsedMinJoinPool} ${inputTokenInfo.symbol} (${originChain.name}) or ${altInputTokenInfo.symbol} (${altChain.name}) to start earning`
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
if (this.feeAssets.length === 1) {
|
|
95
|
-
const bnFeeAssetBalance = new _util.BN(feeAssetBalance.value);
|
|
96
|
-
const minFeeAssetBalance = new _util.BN(this.maintainBalance || '0');
|
|
97
|
-
const feeAssetDiv = _util.BN_TEN.pow(new _util.BN(feeAssetInfo.decimals || 0));
|
|
98
|
-
const parsedMinFeeAssetBalance = minFeeAssetBalance.div(feeAssetDiv).mul(new _util.BN(12)).div(_util.BN_TEN);
|
|
99
|
-
if (bnFeeAssetBalance.lte(_util.BN_ZERO)) {
|
|
100
|
-
const feeChain = this.state.getChainInfo(feeAssetInfo.originChain);
|
|
101
|
-
return {
|
|
102
|
-
passed: false,
|
|
103
|
-
errorMessage: `You need at least ${parsedMinFeeAssetBalance.toString()} ${feeAssetInfo.symbol} (${feeChain.name}) to start earning`
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return {
|
|
108
|
-
passed: true
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
get group() {
|
|
112
|
-
const inputAsset = this.state.getAssetBySlug(this.inputAsset);
|
|
113
|
-
const groupSlug = inputAsset.multiChainAsset;
|
|
114
|
-
return groupSlug || this.inputAsset;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/* Subscribe pool info */
|
|
118
|
-
|
|
119
|
-
async subscribePoolInfo(callback) {
|
|
120
|
-
let cancel = false;
|
|
121
|
-
const _callback = data => {
|
|
122
|
-
!cancel && callback(data);
|
|
123
|
-
};
|
|
124
|
-
const defaultCallback = async () => {
|
|
125
|
-
const data = {
|
|
126
|
-
...this.baseInfo,
|
|
127
|
-
type: this.type,
|
|
128
|
-
metadata: {
|
|
129
|
-
...this.metadataInfo,
|
|
130
|
-
description: this.getDescription()
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
const poolInfo = await this.getPoolInfo();
|
|
134
|
-
!poolInfo && _callback(data);
|
|
135
|
-
};
|
|
136
|
-
const getStatInterval = () => {
|
|
137
|
-
if (!this.isActive) {
|
|
138
|
-
defaultCallback().catch(console.error);
|
|
139
|
-
} else {
|
|
140
|
-
defaultCallback().then(() => {
|
|
141
|
-
return this.getPoolStat();
|
|
142
|
-
}).then(rs => {
|
|
143
|
-
_callback(rs);
|
|
144
|
-
}).catch(console.error);
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
getStatInterval();
|
|
148
|
-
const interval = setInterval(() => {
|
|
149
|
-
if (cancel) {
|
|
150
|
-
clearInterval(interval);
|
|
151
|
-
} else {
|
|
152
|
-
getStatInterval();
|
|
153
|
-
}
|
|
154
|
-
}, _utils.YIELD_POOL_STAT_REFRESH_INTERVAL);
|
|
155
|
-
return new Promise(resolve => {
|
|
156
|
-
const rs = () => {
|
|
157
|
-
cancel = true;
|
|
158
|
-
clearInterval(interval);
|
|
159
|
-
};
|
|
160
|
-
resolve(rs);
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/* Subscribe pool info */
|
|
165
|
-
|
|
166
|
-
/* Get pool reward */
|
|
167
|
-
|
|
168
|
-
async getPoolReward() {
|
|
169
|
-
return new Promise(resolve => resolve(_util.noop));
|
|
170
|
-
}
|
|
171
|
-
async getPoolRewardHistory() {
|
|
172
|
-
return new Promise(resolve => resolve(_util.noop));
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/* Get pool reward */
|
|
176
|
-
|
|
177
|
-
/* Get pool targets */
|
|
178
|
-
|
|
179
|
-
async getPoolTargets() {
|
|
180
|
-
return new Promise(resolve => resolve([]));
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/* Get pool targets */
|
|
184
|
-
|
|
185
|
-
/* Join pool action */
|
|
186
|
-
|
|
187
|
-
/* Generate steps */
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* @async
|
|
191
|
-
* @function getXcmStep
|
|
192
|
-
* */
|
|
193
|
-
async getXcmStep(params) {
|
|
194
|
-
const {
|
|
195
|
-
address,
|
|
196
|
-
amount
|
|
197
|
-
} = params;
|
|
198
|
-
const bnAmount = new _util.BN(amount);
|
|
199
|
-
const inputTokenSlug = this.inputAsset; // assume that the pool only has 1 input token, will update later
|
|
200
|
-
const inputTokenInfo = this.state.getAssetBySlug(inputTokenSlug);
|
|
201
|
-
const inputTokenBalance = await this.state.balanceService.getTokenFreeBalance(address, inputTokenInfo.originChain, inputTokenSlug);
|
|
202
|
-
const bnInputTokenBalance = new _util.BN(inputTokenBalance.value);
|
|
203
|
-
if (!bnInputTokenBalance.gte(bnAmount)) {
|
|
204
|
-
if (this.altInputAsset) {
|
|
205
|
-
const altInputTokenSlug = this.altInputAsset;
|
|
206
|
-
const altInputTokenInfo = this.state.getAssetBySlug(altInputTokenSlug);
|
|
207
|
-
const altInputTokenBalance = await this.state.balanceService.getTokenFreeBalance(address, altInputTokenInfo.originChain, altInputTokenSlug);
|
|
208
|
-
const bnAltInputTokenBalance = new _util.BN(altInputTokenBalance.value || '0');
|
|
209
|
-
if (bnAltInputTokenBalance.gt(_util.BN_ZERO)) {
|
|
210
|
-
const altChainInfo = this.state.getChainInfo(altInputTokenInfo.originChain);
|
|
211
|
-
const symbol = altInputTokenInfo.symbol;
|
|
212
|
-
const networkName = altChainInfo.name;
|
|
213
|
-
const step = {
|
|
214
|
-
metadata: {
|
|
215
|
-
sendingValue: bnAmount.toString(),
|
|
216
|
-
originTokenInfo: altInputTokenInfo,
|
|
217
|
-
destinationTokenInfo: inputTokenInfo
|
|
218
|
-
},
|
|
219
|
-
name: `Transfer ${symbol} from ${networkName}`,
|
|
220
|
-
type: _types.YieldStepType.XCM
|
|
221
|
-
};
|
|
222
|
-
const xcmOriginSubstrateApi = await this.state.getSubstrateApi(altInputTokenInfo.originChain).isReady;
|
|
223
|
-
const xcmTransfer = await (0, _xcm.createXcmExtrinsic)({
|
|
224
|
-
originTokenInfo: altInputTokenInfo,
|
|
225
|
-
destinationTokenInfo: inputTokenInfo,
|
|
226
|
-
sendingValue: bnAmount.toString(),
|
|
227
|
-
recipient: address,
|
|
228
|
-
chainInfoMap: this.state.getChainInfoMap(),
|
|
229
|
-
substrateApi: xcmOriginSubstrateApi
|
|
230
|
-
});
|
|
231
|
-
const _xcmFeeInfo = await xcmTransfer.paymentInfo(address);
|
|
232
|
-
const xcmFeeInfo = _xcmFeeInfo.toPrimitive();
|
|
233
|
-
// TODO: calculate fee for destination chain
|
|
234
|
-
|
|
235
|
-
const fee = {
|
|
236
|
-
slug: altInputTokenSlug,
|
|
237
|
-
amount: Math.round(xcmFeeInfo.partialFee * 1.2).toString() // TODO
|
|
238
|
-
};
|
|
239
|
-
|
|
240
|
-
return [step, fee];
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
return undefined;
|
|
245
|
-
}
|
|
246
|
-
get defaultSubmitStep() {
|
|
247
|
-
return [this.submitJoinStepInfo, {
|
|
248
|
-
slug: this.feeAssets[0],
|
|
249
|
-
amount: '0'
|
|
250
|
-
}];
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* @function submitJoinStepInfo
|
|
255
|
-
* @description Base info of submit step
|
|
256
|
-
* @return Fee of the submitting step
|
|
257
|
-
* */
|
|
258
|
-
|
|
259
|
-
async getSubmitStep(params) {
|
|
260
|
-
const fee = await this.getSubmitStepFee(params);
|
|
261
|
-
return [this.submitJoinStepInfo, fee];
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
/* Generate steps */
|
|
265
|
-
|
|
266
|
-
/* Validate join action */
|
|
267
|
-
|
|
268
|
-
async validateTokenApproveStep(params, path) {
|
|
269
|
-
return Promise.resolve([new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.UNSUPPORTED)]);
|
|
270
|
-
}
|
|
271
|
-
async validateXcmStep(params, path, bnInputTokenBalance) {
|
|
272
|
-
const processValidation = {
|
|
273
|
-
ok: true,
|
|
274
|
-
status: _types.YieldValidationStatus.OK
|
|
275
|
-
};
|
|
276
|
-
const bnAmount = new _util.BN(params.amount);
|
|
277
|
-
const altInputTokenSlug = this.altInputAsset || '';
|
|
278
|
-
const altInputTokenInfo = this.state.getAssetBySlug(altInputTokenSlug);
|
|
279
|
-
const inputTokenInfo = this.state.getAssetBySlug(this.inputAsset);
|
|
280
|
-
const altInputTokenBalance = await this.state.balanceService.getTokenFreeBalance(params.address, altInputTokenInfo.originChain, altInputTokenSlug);
|
|
281
|
-
const missingAmount = bnAmount.sub(bnInputTokenBalance); // TODO: what if input token is not LOCAL ??
|
|
282
|
-
const xcmFee = new _util.BN(path.totalFee[1].amount || '0');
|
|
283
|
-
const xcmAmount = missingAmount.add(xcmFee);
|
|
284
|
-
const bnAltInputTokenBalance = new _util.BN(altInputTokenBalance.value || '0');
|
|
285
|
-
const altInputTokenMinAmount = new _util.BN(altInputTokenInfo.minAmount || '0');
|
|
286
|
-
if (!bnAltInputTokenBalance.sub(xcmAmount).gte(altInputTokenMinAmount)) {
|
|
287
|
-
processValidation.failedStep = path.steps[1];
|
|
288
|
-
processValidation.ok = false;
|
|
289
|
-
processValidation.status = _types.YieldValidationStatus.NOT_ENOUGH_BALANCE;
|
|
290
|
-
const maxBn = bnInputTokenBalance.add(new _util.BN(altInputTokenBalance.value)).sub(xcmFee).sub(altInputTokenMinAmount);
|
|
291
|
-
const maxValue = (0, _utils3.formatNumber)(maxBn.toString(), inputTokenInfo.decimals || 0);
|
|
292
|
-
const altInputTokenInfo = this.state.getAssetBySlug(altInputTokenSlug);
|
|
293
|
-
const symbol = altInputTokenInfo.symbol;
|
|
294
|
-
const altNetwork = this.state.getChainInfo(altInputTokenInfo.originChain);
|
|
295
|
-
const inputNetworkName = this.chainInfo.name;
|
|
296
|
-
const altNetworkName = altNetwork.name;
|
|
297
|
-
const currentValue = (0, _utils3.formatNumber)(bnInputTokenBalance.toString(), inputTokenInfo.decimals || 0);
|
|
298
|
-
const bnMaxXCM = new _util.BN(altInputTokenBalance.value).sub(xcmFee).sub(altInputTokenMinAmount);
|
|
299
|
-
const maxXCMValue = (0, _utils3.formatNumber)(bnMaxXCM.toString(), inputTokenInfo.decimals || 0);
|
|
300
|
-
processValidation.message = (0, _i18next.t)('You can only enter a maximum of {{maxValue}} {{symbol}}, which is {{currentValue}} {{symbol}} ({{inputNetworkName}}) and {{maxXCMValue}} {{symbol}} ({{altNetworkName}}). Lower your amount and try again.', {
|
|
301
|
-
replace: {
|
|
302
|
-
symbol,
|
|
303
|
-
maxValue,
|
|
304
|
-
inputNetworkName,
|
|
305
|
-
altNetworkName,
|
|
306
|
-
currentValue,
|
|
307
|
-
maxXCMValue
|
|
308
|
-
}
|
|
309
|
-
});
|
|
310
|
-
return [new _TransactionError.TransactionError(_types.YieldValidationStatus.NOT_ENOUGH_BALANCE, processValidation.message, processValidation)];
|
|
311
|
-
}
|
|
312
|
-
return [];
|
|
313
|
-
}
|
|
314
|
-
async validateJoinStep(id, params, path, bnInputTokenBalance, isXcmOk) {
|
|
315
|
-
const _poolInfo = await this.getPoolInfo();
|
|
316
|
-
if (!_poolInfo) {
|
|
317
|
-
return [new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INTERNAL_ERROR)];
|
|
318
|
-
}
|
|
319
|
-
const poolInfo = _poolInfo;
|
|
320
|
-
if (!poolInfo.statistic) {
|
|
321
|
-
return [new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INTERNAL_ERROR)];
|
|
322
|
-
}
|
|
323
|
-
const processValidation = {
|
|
324
|
-
ok: true,
|
|
325
|
-
status: _types.YieldValidationStatus.OK
|
|
326
|
-
};
|
|
327
|
-
const feeTokenSlug = path.totalFee[id].slug;
|
|
328
|
-
const feeTokenInfo = this.state.getAssetBySlug(feeTokenSlug);
|
|
329
|
-
const inputTokenInfo = this.state.getAssetBySlug(this.inputAsset);
|
|
330
|
-
const defaultFeeTokenSlug = this.feeAssets[0];
|
|
331
|
-
const bnAmount = new _util.BN(params.amount);
|
|
332
|
-
if (this.feeAssets.length === 1 && feeTokenSlug === defaultFeeTokenSlug) {
|
|
333
|
-
var _path$totalFee$id;
|
|
334
|
-
const bnFeeAmount = new _util.BN(((_path$totalFee$id = path.totalFee[id]) === null || _path$totalFee$id === void 0 ? void 0 : _path$totalFee$id.amount) || '0');
|
|
335
|
-
const feeTokenBalance = await this.state.balanceService.getTokenFreeBalance(params.address, feeTokenInfo.originChain, feeTokenSlug);
|
|
336
|
-
const bnFeeTokenBalance = new _util.BN(feeTokenBalance.value || '0');
|
|
337
|
-
const bnFeeTokenMinAmount = new _util.BN((feeTokenInfo === null || feeTokenInfo === void 0 ? void 0 : feeTokenInfo.minAmount) || '0');
|
|
338
|
-
if (!bnFeeTokenBalance.sub(bnFeeAmount).gte(bnFeeTokenMinAmount)) {
|
|
339
|
-
processValidation.failedStep = path.steps[id];
|
|
340
|
-
processValidation.ok = false;
|
|
341
|
-
processValidation.status = _types.YieldValidationStatus.NOT_ENOUGH_FEE;
|
|
342
|
-
return [new _TransactionError.TransactionError(_types.YieldValidationStatus.NOT_ENOUGH_FEE, processValidation.message, processValidation)];
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
if (!bnAmount.gte(new _util.BN(poolInfo.statistic.earningThreshold.join || '0'))) {
|
|
346
|
-
processValidation.failedStep = path.steps[id];
|
|
347
|
-
processValidation.ok = false;
|
|
348
|
-
processValidation.status = _types.YieldValidationStatus.NOT_ENOUGH_MIN_JOIN_POOL;
|
|
349
|
-
return [new _TransactionError.TransactionError(_types.YieldValidationStatus.NOT_ENOUGH_MIN_JOIN_POOL, processValidation.message, processValidation)];
|
|
350
|
-
}
|
|
351
|
-
if (!isXcmOk && bnAmount.gt(bnInputTokenBalance)) {
|
|
352
|
-
processValidation.failedStep = path.steps[id];
|
|
353
|
-
processValidation.ok = false;
|
|
354
|
-
processValidation.status = _types.YieldValidationStatus.NOT_ENOUGH_BALANCE;
|
|
355
|
-
const maxString = (0, _utils3.formatNumber)(bnInputTokenBalance.toString(), inputTokenInfo.decimals || 0);
|
|
356
|
-
if (maxString !== '0') {
|
|
357
|
-
processValidation.message = (0, _i18next.t)('Amount must be equal or less than {{number}}', {
|
|
358
|
-
replace: {
|
|
359
|
-
number: maxString
|
|
360
|
-
}
|
|
361
|
-
});
|
|
362
|
-
} else {
|
|
363
|
-
processValidation.message = (0, _i18next.t)('You need balance greater than 0 to continue');
|
|
364
|
-
}
|
|
365
|
-
return [new _TransactionError.TransactionError(_types.YieldValidationStatus.NOT_ENOUGH_BALANCE, processValidation.message, processValidation)];
|
|
366
|
-
}
|
|
367
|
-
return [];
|
|
368
|
-
}
|
|
369
|
-
async validateYieldJoin(params, path) {
|
|
370
|
-
const inputTokenSlug = this.inputAsset;
|
|
371
|
-
const inputTokenInfo = this.state.getAssetBySlug(inputTokenSlug);
|
|
372
|
-
const balanceService = this.state.balanceService;
|
|
373
|
-
const inputTokenBalance = await balanceService.getTokenFreeBalance(params.address, inputTokenInfo.originChain, inputTokenSlug);
|
|
374
|
-
const bnInputTokenBalance = new _util.BN(inputTokenBalance.value || '0');
|
|
375
|
-
const bnAmount = new _util.BN(params.amount);
|
|
376
|
-
if (bnAmount.lte(_util.BN_ZERO)) {
|
|
377
|
-
return [new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INVALID_PARAMS, 'Amount must be greater than 0')];
|
|
378
|
-
}
|
|
379
|
-
let isXcmOk = false;
|
|
380
|
-
for (const step of path.steps) {
|
|
381
|
-
const getErrors = async () => {
|
|
382
|
-
switch (step.type) {
|
|
383
|
-
case _types.YieldStepType.DEFAULT:
|
|
384
|
-
return Promise.resolve([]);
|
|
385
|
-
case _types.YieldStepType.XCM:
|
|
386
|
-
return this.validateXcmStep(params, path, bnInputTokenBalance);
|
|
387
|
-
case _types.YieldStepType.TOKEN_APPROVAL:
|
|
388
|
-
return this.validateTokenApproveStep(params, path);
|
|
389
|
-
default:
|
|
390
|
-
return this.validateJoinStep(step.id, params, path, bnInputTokenBalance, isXcmOk);
|
|
391
|
-
}
|
|
392
|
-
};
|
|
393
|
-
const errors = await getErrors();
|
|
394
|
-
if (errors.length) {
|
|
395
|
-
return errors;
|
|
396
|
-
} else if (step.type === _types.YieldStepType.XCM) {
|
|
397
|
-
isXcmOk = true;
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
return [];
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
/* Validate join action */
|
|
404
|
-
|
|
405
|
-
/* Submit join action */
|
|
406
|
-
|
|
407
|
-
async handleTokenApproveStep(data, path) {
|
|
408
|
-
return Promise.reject(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.UNSUPPORTED));
|
|
409
|
-
}
|
|
410
|
-
async handleXcmStep(data, path, xcmFee) {
|
|
411
|
-
const {
|
|
412
|
-
address,
|
|
413
|
-
amount
|
|
414
|
-
} = data;
|
|
415
|
-
const destinationTokenSlug = this.inputAsset;
|
|
416
|
-
const altInputTokenSlug = this.altInputAsset || '';
|
|
417
|
-
const altInputTokenInfo = this.state.getAssetBySlug(altInputTokenSlug);
|
|
418
|
-
const originChainInfo = this.state.getChainInfo(altInputTokenInfo.originChain);
|
|
419
|
-
const originTokenSlug = (0, _utils2._getChainNativeTokenSlug)(originChainInfo);
|
|
420
|
-
const originTokenInfo = this.state.getAssetBySlug(originTokenSlug);
|
|
421
|
-
const destinationTokenInfo = this.state.getAssetBySlug(destinationTokenSlug);
|
|
422
|
-
const substrateApi = this.state.getSubstrateApi(originChainInfo.slug);
|
|
423
|
-
const inputTokenBalance = await this.state.balanceService.getTokenFreeBalance(address, destinationTokenInfo.originChain, destinationTokenSlug);
|
|
424
|
-
const bnInputTokenBalance = new _util.BN(inputTokenBalance.value);
|
|
425
|
-
const bnXcmFee = new _util.BN(xcmFee);
|
|
426
|
-
const bnAmount = new _util.BN(amount);
|
|
427
|
-
const bnTotalAmount = bnAmount.sub(bnInputTokenBalance).add(bnXcmFee);
|
|
428
|
-
const extrinsic = await (0, _xcm.createXcmExtrinsic)({
|
|
429
|
-
chainInfoMap: this.state.getChainInfoMap(),
|
|
430
|
-
destinationTokenInfo,
|
|
431
|
-
originTokenInfo,
|
|
432
|
-
recipient: address,
|
|
433
|
-
sendingValue: bnTotalAmount.toString(),
|
|
434
|
-
substrateApi
|
|
435
|
-
});
|
|
436
|
-
const xcmData = {
|
|
437
|
-
originNetworkKey: originChainInfo.slug,
|
|
438
|
-
destinationNetworkKey: destinationTokenInfo.originChain,
|
|
439
|
-
from: address,
|
|
440
|
-
to: address,
|
|
441
|
-
value: bnTotalAmount.toString(),
|
|
442
|
-
tokenSlug: originTokenSlug,
|
|
443
|
-
showExtraWarning: true
|
|
444
|
-
};
|
|
445
|
-
return {
|
|
446
|
-
txChain: originChainInfo.slug,
|
|
447
|
-
extrinsicType: _KoniTypes.ExtrinsicType.TRANSFER_XCM,
|
|
448
|
-
extrinsic,
|
|
449
|
-
txData: xcmData,
|
|
450
|
-
transferNativeAmount: bnTotalAmount.toString(),
|
|
451
|
-
chainType: _KoniTypes.ChainType.SUBSTRATE
|
|
452
|
-
};
|
|
453
|
-
}
|
|
454
|
-
handleYieldJoin(data, path, currentStep) {
|
|
455
|
-
const type = path.steps[currentStep].type;
|
|
456
|
-
switch (type) {
|
|
457
|
-
case _types.YieldStepType.DEFAULT:
|
|
458
|
-
return Promise.reject(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.UNSUPPORTED));
|
|
459
|
-
case _types.YieldStepType.TOKEN_APPROVAL:
|
|
460
|
-
return this.handleTokenApproveStep(data, path);
|
|
461
|
-
case _types.YieldStepType.XCM:
|
|
462
|
-
{
|
|
463
|
-
const xcmFee = path.totalFee[currentStep].amount || '0';
|
|
464
|
-
return this.handleXcmStep(data, path, xcmFee);
|
|
465
|
-
}
|
|
466
|
-
default:
|
|
467
|
-
return this.handleSubmitStep(data, path);
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
/* Submit join action */
|
|
472
|
-
|
|
473
|
-
/* Join pool action */
|
|
474
|
-
|
|
475
|
-
/* Leave pool action */
|
|
476
|
-
|
|
477
|
-
handleYieldUnstake(amount, address, selectedTarget) {
|
|
478
|
-
return Promise.reject(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.UNSUPPORTED));
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
/* Leave pool action */
|
|
482
|
-
|
|
483
|
-
/* Other action */
|
|
484
|
-
|
|
485
|
-
handleYieldCancelUnstake() {
|
|
486
|
-
return Promise.reject(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.UNSUPPORTED));
|
|
487
|
-
}
|
|
488
|
-
handleYieldClaimReward(address, bondReward) {
|
|
489
|
-
return Promise.reject(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.UNSUPPORTED));
|
|
490
|
-
}
|
|
491
|
-
handleYieldWithdraw(address, unstakingInfo) {
|
|
492
|
-
return Promise.reject(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.UNSUPPORTED));
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
/* Other actions */
|
|
496
|
-
}
|
|
497
|
-
exports.default = BaseSpecialStakingPoolHandler;
|