@subwallet/extension-base 1.1.31-beta.0 → 1.1.32-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/background/KoniTypes.d.ts +69 -111
- package/background/KoniTypes.js +13 -19
- package/background/errors/TransactionError.js +0 -9
- package/cjs/background/KoniTypes.js +16 -20
- package/cjs/background/errors/TransactionError.js +0 -9
- package/cjs/constants/index.js +4 -19
- package/cjs/koni/api/nft/config.js +23 -33
- package/cjs/koni/api/nft/index.js +0 -14
- package/cjs/koni/api/nft/nft.js +22 -1
- package/cjs/koni/api/staking/bonding/amplitude.js +15 -17
- package/cjs/koni/api/staking/bonding/astar.js +10 -11
- package/cjs/koni/api/staking/bonding/index.js +3 -4
- package/cjs/koni/api/staking/bonding/paraChain.js +29 -28
- 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 +5 -6
- package/cjs/koni/api/staking/relayChain.js +2 -3
- package/cjs/koni/background/cron.js +1 -11
- package/cjs/koni/background/handlers/Extension.js +69 -362
- package/cjs/koni/background/handlers/State.js +3 -51
- package/cjs/koni/background/handlers/index.js +2 -4
- package/cjs/koni/background/subscription.js +37 -95
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/campaign-service/index.js +6 -9
- package/cjs/services/chain-service/constants.js +18 -3
- package/cjs/services/chain-service/index.js +2 -3
- package/cjs/services/chain-service/utils.js +1 -7
- package/cjs/services/event-service/index.js +0 -4
- 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 -7
- package/cjs/services/notification-service/NotificationService.js +1 -1
- package/cjs/services/storage-service/DatabaseService.js +0 -51
- package/cjs/services/storage-service/databases/index.js +0 -4
- package/cjs/services/storage-service/db-stores/NominatorMetadata.js +3 -3
- package/cjs/services/subscan-service/index.js +0 -16
- package/cjs/services/transaction-service/event-parser/index.js +0 -58
- package/cjs/services/transaction-service/helpers/index.js +1 -3
- package/cjs/services/transaction-service/index.js +75 -231
- 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 +1 -3
- 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 +9 -11
- package/koni/api/staking/bonding/astar.js +8 -9
- package/koni/api/staking/bonding/index.d.ts +2 -1
- package/koni/api/staking/bonding/index.js +3 -5
- package/koni/api/staking/bonding/paraChain.js +16 -15
- 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 +6 -7
- package/koni/api/staking/relayChain.js +3 -4
- package/koni/background/cron.d.ts +0 -1
- package/koni/background/cron.js +2 -12
- package/koni/background/handlers/Extension.d.ts +1 -17
- package/koni/background/handlers/Extension.js +30 -321
- package/koni/background/handlers/State.d.ts +2 -18
- package/koni/background/handlers/State.js +3 -50
- package/koni/background/handlers/index.js +2 -4
- package/koni/background/subscription.d.ts +1 -6
- package/koni/background/subscription.js +38 -97
- package/package.json +8 -321
- package/packageInfo.js +1 -1
- package/services/campaign-service/index.js +6 -9
- package/services/chain-service/constants.d.ts +11 -0
- package/services/chain-service/constants.js +16 -2
- package/services/chain-service/index.js +2 -3
- 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 -1
- package/services/event-service/index.js +0 -4
- package/services/event-service/types.d.ts +0 -8
- 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 -7
- package/services/notification-service/NotificationService.js +1 -1
- package/services/storage-service/DatabaseService.d.ts +1 -18
- package/services/storage-service/DatabaseService.js +0 -51
- package/services/storage-service/databases/index.d.ts +1 -3
- package/services/storage-service/databases/index.js +0 -4
- package/services/storage-service/db-stores/NominatorMetadata.js +3 -3
- package/services/subscan-service/index.d.ts +2 -3
- package/services/subscan-service/index.js +0 -15
- package/services/subscan-service/types.d.ts +0 -20
- package/services/transaction-service/event-parser/index.d.ts +1 -3
- package/services/transaction-service/event-parser/index.js +1 -57
- package/services/transaction-service/helpers/index.js +1 -3
- package/services/transaction-service/index.d.ts +15 -4
- package/services/transaction-service/index.js +73 -229
- 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 +1 -53
- package/utils/number.d.ts +1 -1
- package/utils/number.js +1 -1
- package/cjs/koni/api/dotsama/balance.js +0 -464
- package/cjs/koni/api/nft/ordinal_nft/constants.js +0 -21
- package/cjs/koni/api/nft/ordinal_nft/index.js +0 -121
- package/cjs/koni/api/nft/ordinal_nft/utils.js +0 -41
- package/cjs/koni/api/yield/helper/utils.js +0 -46
- package/cjs/services/earning-service/constants/chains.js +0 -29
- 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 -259
- package/cjs/services/earning-service/handlers/index.js +0 -60
- package/cjs/services/earning-service/handlers/lending/base.js +0 -20
- package/cjs/services/earning-service/handlers/lending/index.js +0 -13
- package/cjs/services/earning-service/handlers/lending/interlay.js +0 -191
- package/cjs/services/earning-service/handlers/liquid-staking/acala.js +0 -239
- package/cjs/services/earning-service/handlers/liquid-staking/base.js +0 -43
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +0 -297
- package/cjs/services/earning-service/handlers/liquid-staking/index.js +0 -34
- package/cjs/services/earning-service/handlers/liquid-staking/parallel.js +0 -226
- package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +0 -395
- package/cjs/services/earning-service/handlers/native-staking/amplitude.js +0 -384
- package/cjs/services/earning-service/handlers/native-staking/astar.js +0 -461
- package/cjs/services/earning-service/handlers/native-staking/base-para.js +0 -146
- package/cjs/services/earning-service/handlers/native-staking/base.js +0 -159
- package/cjs/services/earning-service/handlers/native-staking/index.js +0 -34
- package/cjs/services/earning-service/handlers/native-staking/para-chain.js +0 -385
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +0 -558
- package/cjs/services/earning-service/handlers/nomination-pool/index.js +0 -560
- package/cjs/services/earning-service/handlers/special.js +0 -503
- package/cjs/services/earning-service/service.js +0 -387
- package/cjs/services/earning-service/utils/index.js +0 -128
- package/cjs/services/migration-service/scripts/DeleteEarningData.js +0 -21
- package/cjs/services/migration-service/scripts/EnableEarningChains.js +0 -21
- package/cjs/services/migration-service/scripts/MigrateEthProvider.js +0 -17
- package/cjs/services/migration-service/scripts/MigratePioneerProvider.js +0 -17
- package/cjs/services/migration-service/scripts/MigrateProvider.js +0 -29
- package/cjs/services/migration-service/scripts/databases/MigrateEarningHistory.js +0 -21
- package/cjs/services/migration-service/scripts/databases/MigrateEarningVersion.js +0 -21
- package/cjs/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -149
- package/cjs/services/mint-campaign-service/campaigns/index.js +0 -13
- package/cjs/services/mint-campaign-service/constants.js +0 -11
- package/cjs/services/mint-campaign-service/index.js +0 -18
- package/cjs/services/storage-service/db-stores/YieldPoolStore.js +0 -36
- package/cjs/services/storage-service/db-stores/YieldPositionStore.js +0 -65
- package/cjs/services/storage-service/index.js +0 -241
- package/cjs/types/campaigns/index.js +0 -16
- package/cjs/types/campaigns/unlock-dot.js +0 -1
- package/cjs/types/ordinal.js +0 -1
- package/cjs/types/transaction.js +0 -1
- package/cjs/types/yield/actions/index.js +0 -27
- package/cjs/types/yield/actions/join/index.js +0 -38
- package/cjs/types/yield/actions/join/step.js +0 -47
- package/cjs/types/yield/actions/join/submit.js +0 -1
- package/cjs/types/yield/actions/join/validate.js +0 -16
- package/cjs/types/yield/actions/others.js +0 -1
- package/cjs/types/yield/index.js +0 -27
- package/cjs/types/yield/info/account/index.js +0 -49
- package/cjs/types/yield/info/account/info.js +0 -1
- package/cjs/types/yield/info/account/reward.js +0 -1
- package/cjs/types/yield/info/account/target.js +0 -32
- package/cjs/types/yield/info/account/unstake.js +0 -27
- package/cjs/types/yield/info/base.js +0 -41
- package/cjs/types/yield/info/chain/index.js +0 -27
- package/cjs/types/yield/info/chain/info.js +0 -1
- package/cjs/types/yield/info/chain/target.js +0 -1
- package/cjs/types/yield/info/index.js +0 -49
- package/cjs/types/yield/info/pallet.js +0 -15
- package/cjs/types.js +0 -1
- package/cjs/utils/address.js +0 -34
- package/cjs/utils/keyring.js +0 -57
- package/cjs/utils/object.js +0 -12
- package/koni/api/nft/ordinal_nft/constants.d.ts +0 -9
- package/koni/api/nft/ordinal_nft/constants.js +0 -12
- package/koni/api/nft/ordinal_nft/index.d.ts +0 -8
- package/koni/api/nft/ordinal_nft/index.js +0 -114
- package/koni/api/nft/ordinal_nft/utils.d.ts +0 -2
- package/koni/api/nft/ordinal_nft/utils.js +0 -33
- package/koni/api/yield/helper/utils.d.ts +0 -10
- package/koni/api/yield/helper/utils.js +0 -32
- package/services/earning-service/constants/abis/compound_finance_v2_abi.json +0 -1235
- package/services/earning-service/constants/abis/st_liquid_token_abi.json +0 -1355
- package/services/earning-service/constants/chains.d.ts +0 -14
- package/services/earning-service/constants/chains.js +0 -21
- 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 -112
- package/services/earning-service/handlers/base.js +0 -253
- 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 -6
- package/services/earning-service/handlers/lending/base.js +0 -12
- 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 -183
- package/services/earning-service/handlers/liquid-staking/acala.d.ts +0 -27
- package/services/earning-service/handlers/liquid-staking/acala.js +0 -231
- package/services/earning-service/handlers/liquid-staking/base.d.ts +0 -9
- package/services/earning-service/handlers/liquid-staking/base.js +0 -35
- package/services/earning-service/handlers/liquid-staking/bifrost.d.ts +0 -46
- package/services/earning-service/handlers/liquid-staking/bifrost.js +0 -286
- package/services/earning-service/handlers/liquid-staking/index.d.ts +0 -4
- package/services/earning-service/handlers/liquid-staking/index.js +0 -7
- package/services/earning-service/handlers/liquid-staking/parallel.d.ts +0 -26
- package/services/earning-service/handlers/liquid-staking/parallel.js +0 -218
- package/services/earning-service/handlers/liquid-staking/stella-swap.d.ts +0 -34
- package/services/earning-service/handlers/liquid-staking/stella-swap.js +0 -385
- package/services/earning-service/handlers/native-staking/amplitude.d.ts +0 -22
- package/services/earning-service/handlers/native-staking/amplitude.js +0 -375
- package/services/earning-service/handlers/native-staking/astar.d.ts +0 -19
- package/services/earning-service/handlers/native-staking/astar.js +0 -451
- 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 -150
- 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 -377
- package/services/earning-service/handlers/native-staking/relay-chain.d.ts +0 -21
- package/services/earning-service/handlers/native-staking/relay-chain.js +0 -549
- package/services/earning-service/handlers/nomination-pool/index.d.ts +0 -36
- package/services/earning-service/handlers/nomination-pool/index.js +0 -550
- package/services/earning-service/handlers/special.d.ts +0 -65
- package/services/earning-service/handlers/special.js +0 -495
- package/services/earning-service/service.d.ts +0 -45
- package/services/earning-service/service.js +0 -379
- package/services/earning-service/utils/index.d.ts +0 -18
- package/services/earning-service/utils/index.js +0 -112
- package/services/migration-service/scripts/DeleteEarningData.d.ts +0 -4
- package/services/migration-service/scripts/DeleteEarningData.js +0 -13
- package/services/migration-service/scripts/EnableEarningChains.d.ts +0 -4
- package/services/migration-service/scripts/EnableEarningChains.js +0 -13
- package/services/migration-service/scripts/databases/MigrateEarningHistory.d.ts +0 -4
- package/services/migration-service/scripts/databases/MigrateEarningHistory.js +0 -13
- package/services/migration-service/scripts/databases/MigrateEarningVersion.d.ts +0 -4
- package/services/migration-service/scripts/databases/MigrateEarningVersion.js +0 -13
- package/services/mint-campaign-service/campaigns/UnlockDotCampaign.d.ts +0 -13
- package/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -139
- package/services/mint-campaign-service/campaigns/index.d.ts +0 -1
- package/services/mint-campaign-service/campaigns/index.js +0 -4
- package/services/mint-campaign-service/constants.d.ts +0 -1
- package/services/mint-campaign-service/constants.js +0 -4
- package/services/mint-campaign-service/index.d.ts +0 -7
- package/services/mint-campaign-service/index.js +0 -11
- package/services/storage-service/db-stores/YieldPoolStore.d.ts +0 -10
- package/services/storage-service/db-stores/YieldPoolStore.js +0 -28
- package/services/storage-service/db-stores/YieldPositionStore.d.ts +0 -9
- package/services/storage-service/db-stores/YieldPositionStore.js +0 -57
- package/types/campaigns/index.d.ts +0 -1
- package/types/campaigns/index.js +0 -4
- package/types/campaigns/unlock-dot.d.ts +0 -71
- package/types/campaigns/unlock-dot.js +0 -1
- package/types/ordinal.d.ts +0 -69
- package/types/ordinal.js +0 -1
- package/types/transaction.d.ts +0 -3
- package/types/transaction.js +0 -1
- package/types/yield/actions/index.d.ts +0 -2
- package/types/yield/actions/index.js +0 -5
- package/types/yield/actions/join/index.d.ts +0 -3
- package/types/yield/actions/join/index.js +0 -6
- package/types/yield/actions/join/step.d.ts +0 -95
- package/types/yield/actions/join/step.js +0 -46
- package/types/yield/actions/join/submit.d.ts +0 -57
- 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 -45
- 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 -251
- 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,121 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _constants = require("@subwallet/extension-base/constants");
|
|
8
|
-
var _nft = require("@subwallet/extension-base/koni/api/nft/nft");
|
|
9
|
-
var _utils = require("@subwallet/extension-base/koni/api/nft/ordinal_nft/utils");
|
|
10
|
-
var _handlers = require("@subwallet/extension-base/koni/background/handlers");
|
|
11
|
-
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
12
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
13
|
-
|
|
14
|
-
const parseParamData = (param, event, chain, address) => {
|
|
15
|
-
const ordinalData = JSON.parse(param.value);
|
|
16
|
-
if ('p' in ordinalData) {
|
|
17
|
-
const properties = {};
|
|
18
|
-
for (const [key, value] of Object.entries(ordinalData)) {
|
|
19
|
-
const _name = key.charAt(0).toUpperCase() + key.slice(1);
|
|
20
|
-
properties[_name] = {
|
|
21
|
-
value: value
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
properties['Block number'] = {
|
|
25
|
-
value: event.extrinsic_index.split('-')[0]
|
|
26
|
-
};
|
|
27
|
-
properties.Timestamp = {
|
|
28
|
-
value: event.block_timestamp
|
|
29
|
-
};
|
|
30
|
-
const op = ordinalData.op.charAt(0).toUpperCase() + ordinalData.op.slice(1);
|
|
31
|
-
const nameParams = [op];
|
|
32
|
-
if (ordinalData.amt !== undefined) {
|
|
33
|
-
nameParams.push(ordinalData.amt);
|
|
34
|
-
}
|
|
35
|
-
nameParams.push(ordinalData.tick);
|
|
36
|
-
const name = nameParams.join(' ');
|
|
37
|
-
return {
|
|
38
|
-
chain: chain,
|
|
39
|
-
collectionId: _constants.ORDINAL_COLLECTION,
|
|
40
|
-
id: event.extrinsic_hash,
|
|
41
|
-
description: JSON.stringify(ordinalData),
|
|
42
|
-
name,
|
|
43
|
-
owner: address,
|
|
44
|
-
properties: properties
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
return undefined;
|
|
48
|
-
};
|
|
49
|
-
class OrdinalNftApi extends _nft.BaseNftApi {
|
|
50
|
-
constructor(addresses, chain, subscanChain) {
|
|
51
|
-
super(chain, undefined, addresses);
|
|
52
|
-
this.subscanChain = subscanChain;
|
|
53
|
-
}
|
|
54
|
-
async handleNft(address, handleNftParams) {
|
|
55
|
-
const events = await _handlers.state.subscanService.addRequest(async () => {
|
|
56
|
-
return await (0, _utils.fetchRemarkEvent)(this.subscanChain, address);
|
|
57
|
-
});
|
|
58
|
-
if (events && events.length) {
|
|
59
|
-
const extrinsicIds = events.map(data => data.extrinsic_index);
|
|
60
|
-
const extrinsicParams = await _handlers.state.subscanService.addRequest(async () => {
|
|
61
|
-
return await (0, _utils.fetchExtrinsicParams)(this.subscanChain, extrinsicIds);
|
|
62
|
-
});
|
|
63
|
-
const items = [];
|
|
64
|
-
for (const data of extrinsicParams) {
|
|
65
|
-
const {
|
|
66
|
-
extrinsic_index: extrinsicIndex,
|
|
67
|
-
params
|
|
68
|
-
} = data;
|
|
69
|
-
const event = events.find(item => item.extrinsic_index === extrinsicIndex);
|
|
70
|
-
if (params.length === 1 && event) {
|
|
71
|
-
const [param] = params;
|
|
72
|
-
if (param.name === 'remark') {
|
|
73
|
-
const childParam = {
|
|
74
|
-
name: param.name,
|
|
75
|
-
type: param.type,
|
|
76
|
-
value: param.value
|
|
77
|
-
};
|
|
78
|
-
const item = parseParamData(childParam, event, this.chain, address);
|
|
79
|
-
if (item) {
|
|
80
|
-
items.push(item);
|
|
81
|
-
}
|
|
82
|
-
} else if (param.name === 'calls') {
|
|
83
|
-
const children = param.value;
|
|
84
|
-
for (const child of children) {
|
|
85
|
-
if (child.call_module === 'System' && child.call_name === 'remark_with_event') {
|
|
86
|
-
for (const childParam of child.params) {
|
|
87
|
-
const item = parseParamData(childParam, event, this.chain, address);
|
|
88
|
-
if (item) {
|
|
89
|
-
items.push(item);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
if (items.length) {
|
|
98
|
-
// handleNftParams.updateCollection(this.chain, {
|
|
99
|
-
// chain: this.chain,
|
|
100
|
-
// collectionId: ORDINAL_COLLECTION
|
|
101
|
-
// });
|
|
102
|
-
|
|
103
|
-
for (const item of items) {
|
|
104
|
-
handleNftParams.updateItem(this.chain, item, address);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
async handleNfts(params) {
|
|
110
|
-
await Promise.all(this.addresses.map(address => this.handleNft(address, params)));
|
|
111
|
-
}
|
|
112
|
-
async fetchNfts(params) {
|
|
113
|
-
try {
|
|
114
|
-
await this.handleNfts(params);
|
|
115
|
-
} catch (e) {
|
|
116
|
-
return 0;
|
|
117
|
-
}
|
|
118
|
-
return 1;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
exports.default = OrdinalNftApi;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.fetchRemarkEvent = exports.fetchExtrinsicParams = void 0;
|
|
7
|
-
var _constants = require("./constants");
|
|
8
|
-
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
9
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
10
|
-
|
|
11
|
-
const fetchRemarkEvent = async (chain, address) => {
|
|
12
|
-
const params = {
|
|
13
|
-
..._constants.BASE_FETCH_ORDINAL_EVENT_DATA,
|
|
14
|
-
address
|
|
15
|
-
};
|
|
16
|
-
const response = await fetch(_constants.GET_EVENT_LIST_API.replace('{{chain}}', chain), {
|
|
17
|
-
method: 'POST',
|
|
18
|
-
headers: {
|
|
19
|
-
'Content-Type': 'application/json'
|
|
20
|
-
},
|
|
21
|
-
body: JSON.stringify(params)
|
|
22
|
-
});
|
|
23
|
-
const data = await response.json();
|
|
24
|
-
return data.data.events;
|
|
25
|
-
};
|
|
26
|
-
exports.fetchRemarkEvent = fetchRemarkEvent;
|
|
27
|
-
const fetchExtrinsicParams = async (chain, extrinsicIndexes) => {
|
|
28
|
-
const params = {
|
|
29
|
-
extrinsic_index: extrinsicIndexes
|
|
30
|
-
};
|
|
31
|
-
const response = await fetch(_constants.GET_EXTRINSIC_PARAMS_API.replace('{{chain}}', chain), {
|
|
32
|
-
method: 'POST',
|
|
33
|
-
headers: {
|
|
34
|
-
'Content-Type': 'application/json'
|
|
35
|
-
},
|
|
36
|
-
body: JSON.stringify(params)
|
|
37
|
-
});
|
|
38
|
-
const data = await response.json();
|
|
39
|
-
return data.data;
|
|
40
|
-
};
|
|
41
|
-
exports.fetchExtrinsicParams = fetchExtrinsicParams;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.YIELD_POOL_STAT_REFRESH_INTERVAL = exports.YIELD_POOL_MIN_AMOUNT_PERCENT = exports.YIELD_EXTRINSIC_TYPES = exports.DEFAULT_YIELD_FIRST_STEP = void 0;
|
|
7
|
-
exports.calculateAlternativeFee = calculateAlternativeFee;
|
|
8
|
-
exports.convertDerivativeToOriginToken = convertDerivativeToOriginToken;
|
|
9
|
-
exports.syntheticSelectedValidators = void 0;
|
|
10
|
-
var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
11
|
-
var _utils = require("@subwallet/extension-base/services/chain-service/utils");
|
|
12
|
-
var _types = require("@subwallet/extension-base/types");
|
|
13
|
-
// Copyright 2019-2022 @subwallet/extension-base
|
|
14
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
15
|
-
|
|
16
|
-
const syntheticSelectedValidators = ['15MLn9YQaHZ4GMkhK3qXqR5iGGSdULyJ995ctjeBgFRseyi6', '1REAJ1k691g5Eqqg9gL7vvZCBG7FCCZ8zgQkZWd4va5ESih', '1yGJ3h7TQuJWLYSsUVPZbM8aR8UsQXCqMvrFx5Fn1ktiAmq', '16GDRhRYxk42paoK6TfHAqWej8PdDDUwdDazjv4bAn4KGNeb', '13Ybj8CPEArUee78DxUAP9yX3ABmFNVQME1ZH4w8HVncHGzc', '14yx4vPAACZRhoDQm1dyvXD3QdRQyCRRCe5tj1zPomhhS29a', '14Vh8S1DzzycngbAB9vqEgPFR9JpSvmF1ezihTUES1EaHAV', '153YD8ZHD9dRh82U419bSCB5SzWhbdAFzjj4NtA5pMazR2yC', '1LUckyocmz9YzeQZHVpBvYYRGXb3rnSm2tvfz79h3G3JDgP', '14oRE62MB1SWR6h5RTx3GY5HK2oZipi1Gp3zdiLwVYLfEyRZ', '1cFsLn7o74nmjbRyDtMAnMpQMc5ZLsjgCSz9Np2mcejUK83', '15ZvLonEseaWZNy8LDkXXj3Y8bmAjxCjwvpy4pXWSL4nGSBs', '1NebF2xZHb4TJJpiqZZ3reeTo8dZov6LZ49qZqcHHbsmHfo', '1HmAqbBRrWvsqbLkvpiVDkdA2PcctUE5JUe3qokEh1FN455', '15tfUt4iQNjMyhZiJGBf4EpETE2KqtW1nfJwbBT1MvWjvcK9', '12RXTLiaYh59PokjZVhQvKzcfBEB5CvDnjKKUmDUotzcTH3S'];
|
|
17
|
-
exports.syntheticSelectedValidators = syntheticSelectedValidators;
|
|
18
|
-
function calculateAlternativeFee(feeInfo) {
|
|
19
|
-
return feeInfo.partialFee;
|
|
20
|
-
}
|
|
21
|
-
const DEFAULT_YIELD_FIRST_STEP = {
|
|
22
|
-
id: 0,
|
|
23
|
-
name: 'Fill information',
|
|
24
|
-
type: _types.YieldStepType.DEFAULT
|
|
25
|
-
};
|
|
26
|
-
exports.DEFAULT_YIELD_FIRST_STEP = DEFAULT_YIELD_FIRST_STEP;
|
|
27
|
-
const YIELD_EXTRINSIC_TYPES = [_KoniTypes.ExtrinsicType.MINT_VDOT, _KoniTypes.ExtrinsicType.MINT_LDOT, _KoniTypes.ExtrinsicType.MINT_SDOT, _KoniTypes.ExtrinsicType.MINT_QDOT, _KoniTypes.ExtrinsicType.MINT_STDOT, _KoniTypes.ExtrinsicType.REDEEM_QDOT, _KoniTypes.ExtrinsicType.REDEEM_SDOT, _KoniTypes.ExtrinsicType.REDEEM_VDOT, _KoniTypes.ExtrinsicType.REDEEM_LDOT, _KoniTypes.ExtrinsicType.REDEEM_STDOT, _KoniTypes.ExtrinsicType.STAKING_JOIN_POOL, _KoniTypes.ExtrinsicType.STAKING_CLAIM_REWARD, _KoniTypes.ExtrinsicType.STAKING_LEAVE_POOL, _KoniTypes.ExtrinsicType.STAKING_POOL_WITHDRAW];
|
|
28
|
-
exports.YIELD_EXTRINSIC_TYPES = YIELD_EXTRINSIC_TYPES;
|
|
29
|
-
const YIELD_POOL_STAT_REFRESH_INTERVAL = 90000;
|
|
30
|
-
exports.YIELD_POOL_STAT_REFRESH_INTERVAL = YIELD_POOL_STAT_REFRESH_INTERVAL;
|
|
31
|
-
const YIELD_POOL_MIN_AMOUNT_PERCENT = {
|
|
32
|
-
DOT___acala_liquid_staking: 0.98,
|
|
33
|
-
DOT___bifrost_liquid_staking: 0.99,
|
|
34
|
-
DOT___parallel_liquid_staking: 0.97,
|
|
35
|
-
default: 0.98
|
|
36
|
-
};
|
|
37
|
-
exports.YIELD_POOL_MIN_AMOUNT_PERCENT = YIELD_POOL_MIN_AMOUNT_PERCENT;
|
|
38
|
-
function convertDerivativeToOriginToken(amount, poolInfo, derivativeTokenInfo, originTokenInfo) {
|
|
39
|
-
var _poolInfo$statistic, _poolInfo$statistic$a;
|
|
40
|
-
const derivativeDecimals = (0, _utils._getAssetDecimals)(derivativeTokenInfo);
|
|
41
|
-
const originDecimals = (0, _utils._getAssetDecimals)(originTokenInfo);
|
|
42
|
-
const exchangeRate = ((_poolInfo$statistic = poolInfo.statistic) === null || _poolInfo$statistic === void 0 ? void 0 : (_poolInfo$statistic$a = _poolInfo$statistic.assetEarning) === null || _poolInfo$statistic$a === void 0 ? void 0 : _poolInfo$statistic$a[0].exchangeRate) || 1;
|
|
43
|
-
const formattedAmount = parseInt(amount) / 10 ** derivativeDecimals; // TODO: decimals
|
|
44
|
-
const minAmount = formattedAmount * exchangeRate;
|
|
45
|
-
return Math.floor(minAmount * 10 ** originDecimals);
|
|
46
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports._STAKING_CHAIN_GROUP = exports.ST_LIQUID_TOKEN_ABI = void 0;
|
|
7
|
-
// Copyright 2019-2022 @subwallet/extension-base
|
|
8
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
9
|
-
|
|
10
|
-
const _STAKING_CHAIN_GROUP = {
|
|
11
|
-
relay: ['polkadot', 'kusama', 'aleph', 'polkadex', 'ternoa', 'ternoa_alphanet', 'alephTest', 'polkadexTest', 'westend', 'kate', 'edgeware', 'creditcoin', 'vara_network', 'goldberg_testnet'],
|
|
12
|
-
para: ['moonbeam', 'moonriver', 'moonbase', 'turing', 'turingStaging', 'bifrost', 'bifrost_testnet', 'calamari_test', 'calamari'],
|
|
13
|
-
astar: ['astar', 'shiden', 'shibuya'],
|
|
14
|
-
amplitude: ['amplitude', 'amplitude_test', 'kilt', 'kilt_peregrine', 'pendulum'],
|
|
15
|
-
// amplitude and kilt only share some common logic
|
|
16
|
-
kilt: ['kilt', 'kilt_peregrine'],
|
|
17
|
-
nominationPool: ['polkadot', 'kusama', 'westend', 'alephTest', 'aleph', 'kate', 'vara_network', 'goldberg_testnet'],
|
|
18
|
-
bifrost: ['bifrost', 'bifrost_testnet'],
|
|
19
|
-
aleph: ['aleph', 'alephTest'],
|
|
20
|
-
// A0 has distinct tokenomics
|
|
21
|
-
ternoa: ['ternoa', 'ternoa_alphanet'],
|
|
22
|
-
liquidStaking: ['bifrost_dot', 'acala', 'parallel', 'moonbeam'],
|
|
23
|
-
lending: ['interlay']
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
|
|
27
|
-
exports._STAKING_CHAIN_GROUP = _STAKING_CHAIN_GROUP;
|
|
28
|
-
const ST_LIQUID_TOKEN_ABI = require('./abis/st_liquid_token_abi.json');
|
|
29
|
-
exports.ST_LIQUID_TOKEN_ABI = ST_LIQUID_TOKEN_ABI;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _chains = require("./chains");
|
|
7
|
-
Object.keys(_chains).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _chains[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _chains[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
var _step = require("./step");
|
|
18
|
-
Object.keys(_step).forEach(function (key) {
|
|
19
|
-
if (key === "default" || key === "__esModule") return;
|
|
20
|
-
if (key in exports && exports[key] === _step[key]) return;
|
|
21
|
-
Object.defineProperty(exports, key, {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function () {
|
|
24
|
-
return _step[key];
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.fakeAddress = exports.DEFAULT_YIELD_FIRST_STEP = void 0;
|
|
7
|
-
var _types = require("@subwallet/extension-base/types");
|
|
8
|
-
// Copyright 2019-2022 @subwallet/extension-base
|
|
9
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
10
|
-
|
|
11
|
-
const DEFAULT_YIELD_FIRST_STEP = {
|
|
12
|
-
id: 0,
|
|
13
|
-
name: 'Fill information',
|
|
14
|
-
type: _types.YieldStepType.DEFAULT
|
|
15
|
-
};
|
|
16
|
-
exports.DEFAULT_YIELD_FIRST_STEP = DEFAULT_YIELD_FIRST_STEP;
|
|
17
|
-
const fakeAddress = '15MLn9YQaHZ4GMkhK3qXqR5iGGSdULyJ995ctjeBgFRseyi6';
|
|
18
|
-
exports.fakeAddress = fakeAddress;
|
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
8
|
-
var _constants = require("@subwallet/extension-base/constants");
|
|
9
|
-
var _constants2 = require("@subwallet/extension-base/services/earning-service/constants");
|
|
10
|
-
var _utils = require("@subwallet/extension-base/utils");
|
|
11
|
-
var _util = require("@polkadot/util");
|
|
12
|
-
// Copyright 2019-2022 @subwallet/extension-base
|
|
13
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @class BasePoolHandler
|
|
17
|
-
* @description Base pool handler
|
|
18
|
-
* */
|
|
19
|
-
class BasePoolHandler {
|
|
20
|
-
/** Koni state */
|
|
21
|
-
|
|
22
|
-
/** Pool's chain */
|
|
23
|
-
|
|
24
|
-
/** Pool's logo */
|
|
25
|
-
|
|
26
|
-
/** Pool's slug */
|
|
27
|
-
|
|
28
|
-
/** Pool's type */
|
|
29
|
-
|
|
30
|
-
/** Pool's name */
|
|
31
|
-
|
|
32
|
-
/** Pool's short name */
|
|
33
|
-
|
|
34
|
-
/** Pool's transaction type */
|
|
35
|
-
transactionChainType = _KoniTypes.ChainType.SUBSTRATE;
|
|
36
|
-
|
|
37
|
-
/** Pool's available method */
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* @constructor
|
|
41
|
-
* @param {KoniState} state - Koni state
|
|
42
|
-
* @param {string} chain - Pool's chain
|
|
43
|
-
* */
|
|
44
|
-
constructor(state, chain) {
|
|
45
|
-
this.state = state;
|
|
46
|
-
this.chain = chain;
|
|
47
|
-
this._logo = chain;
|
|
48
|
-
}
|
|
49
|
-
get logo() {
|
|
50
|
-
return this._logo;
|
|
51
|
-
}
|
|
52
|
-
get group() {
|
|
53
|
-
const groupSlug = this.nativeToken.multiChainAsset;
|
|
54
|
-
return groupSlug || this.nativeToken.slug;
|
|
55
|
-
}
|
|
56
|
-
get isActive() {
|
|
57
|
-
return this.state.activeChainSlugs.includes(this.chain);
|
|
58
|
-
}
|
|
59
|
-
get substrateApi() {
|
|
60
|
-
return this.state.getSubstrateApi(this.chain);
|
|
61
|
-
}
|
|
62
|
-
get evmApi() {
|
|
63
|
-
return this.state.getEvmApi(this.chain);
|
|
64
|
-
}
|
|
65
|
-
get chainInfo() {
|
|
66
|
-
return this.state.getChainInfo(this.chain);
|
|
67
|
-
}
|
|
68
|
-
get nativeToken() {
|
|
69
|
-
return this.state.getNativeTokenInfo(this.chain);
|
|
70
|
-
}
|
|
71
|
-
get baseInfo() {
|
|
72
|
-
return {
|
|
73
|
-
group: this.group,
|
|
74
|
-
chain: this.chain,
|
|
75
|
-
slug: this.slug
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
get maintainBalance() {
|
|
79
|
-
const decimals = this.nativeToken.decimals || 0;
|
|
80
|
-
const defaultMaintainBalance = new _util.BN(1).mul(_util.BN_TEN.pow(new _util.BN(decimals)));
|
|
81
|
-
const ed = new _util.BN(this.nativeToken.minAmount || '0');
|
|
82
|
-
const maintainBalance = ed.gte(defaultMaintainBalance) ? new _util.BN(15).mul(ed).div(_util.BN_TEN) : defaultMaintainBalance;
|
|
83
|
-
return maintainBalance.toString();
|
|
84
|
-
}
|
|
85
|
-
get metadataInfo() {
|
|
86
|
-
return {
|
|
87
|
-
name: this.name,
|
|
88
|
-
shortName: this.shortName,
|
|
89
|
-
logo: this.logo,
|
|
90
|
-
inputAsset: this.nativeToken.slug,
|
|
91
|
-
isAvailable: true,
|
|
92
|
-
maintainAsset: this.nativeToken.slug,
|
|
93
|
-
maintainBalance: this.maintainBalance,
|
|
94
|
-
availableMethod: this.availableMethod
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/** Can mint when haven't enough native token (use input token for fee) */
|
|
99
|
-
get isPoolSupportAlternativeFee() {
|
|
100
|
-
return false;
|
|
101
|
-
}
|
|
102
|
-
async getPoolInfo() {
|
|
103
|
-
return this.state.dbService.getYieldPool(this.slug);
|
|
104
|
-
}
|
|
105
|
-
async getPoolPosition(address) {
|
|
106
|
-
return this.state.dbService.getYieldPositionByAddressAndSlug(address, this.slug);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/* Subscribe data */
|
|
110
|
-
|
|
111
|
-
/** Subscribe pool info */
|
|
112
|
-
|
|
113
|
-
/* Subscribe data */
|
|
114
|
-
|
|
115
|
-
/* Join action */
|
|
116
|
-
|
|
117
|
-
/* Early validate */
|
|
118
|
-
|
|
119
|
-
async earlyValidate(request) {
|
|
120
|
-
var _poolInfo$statistic, _poolInfo$statistic2, _poolInfo$statistic2$;
|
|
121
|
-
const poolInfo = await this.getPoolInfo();
|
|
122
|
-
if (!poolInfo || !((_poolInfo$statistic = poolInfo.statistic) !== null && _poolInfo$statistic !== void 0 && _poolInfo$statistic.earningThreshold.join)) {
|
|
123
|
-
return {
|
|
124
|
-
passed: false,
|
|
125
|
-
errorMessage: 'There\'s a trouble fetching data, please check your internet connection and try again'
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
if (request.address === _constants.ALL_ACCOUNT_KEY) {
|
|
129
|
-
return {
|
|
130
|
-
passed: true
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
const nativeTokenInfo = this.state.chainService.getNativeTokenInfo(this.chain);
|
|
134
|
-
const nativeTokenBalance = await this.state.balanceService.getTokenFreeBalance(request.address, this.chain);
|
|
135
|
-
const bnNativeTokenBalance = new _util.BN(nativeTokenBalance.value);
|
|
136
|
-
if (bnNativeTokenBalance.lte(new _util.BN((_poolInfo$statistic2 = poolInfo.statistic) === null || _poolInfo$statistic2 === void 0 ? void 0 : (_poolInfo$statistic2$ = _poolInfo$statistic2.earningThreshold) === null || _poolInfo$statistic2$ === void 0 ? void 0 : _poolInfo$statistic2$.join))) {
|
|
137
|
-
var _poolInfo$statistic3, _poolInfo$statistic3$;
|
|
138
|
-
const minJoin = (0, _utils.formatNumber)(((_poolInfo$statistic3 = poolInfo.statistic) === null || _poolInfo$statistic3 === void 0 ? void 0 : (_poolInfo$statistic3$ = _poolInfo$statistic3.earningThreshold) === null || _poolInfo$statistic3$ === void 0 ? void 0 : _poolInfo$statistic3$.join) || '0', this.nativeToken.decimals || 0);
|
|
139
|
-
const originChain = this.state.getChainInfo(nativeTokenInfo.originChain);
|
|
140
|
-
return {
|
|
141
|
-
passed: false,
|
|
142
|
-
errorMessage: `You need at least ${minJoin} ${nativeTokenInfo.symbol} (${originChain.name}) to start earning`
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
return {
|
|
146
|
-
passed: true
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
/* Early validate */
|
|
151
|
-
|
|
152
|
-
/* Generate steps */
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* @function firstStepFee
|
|
156
|
-
* */
|
|
157
|
-
get firstStepFee() {
|
|
158
|
-
return {
|
|
159
|
-
slug: ''
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* @function defaultSubmitStep
|
|
165
|
-
* @description Default submit step data
|
|
166
|
-
* */
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* @async
|
|
170
|
-
* @function getTokenApproveStep
|
|
171
|
-
* @param {OptimalYieldPathParams} params - base param to join pool
|
|
172
|
-
* @description Generate token approve step data
|
|
173
|
-
* */
|
|
174
|
-
async getTokenApproveStep(params) {
|
|
175
|
-
return Promise.resolve(undefined);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* @async
|
|
180
|
-
* @function getXcmStep
|
|
181
|
-
* @param {OptimalYieldPathParams} params - base param to join pool
|
|
182
|
-
* @description Generate token approve step data
|
|
183
|
-
* */
|
|
184
|
-
async getXcmStep(params) {
|
|
185
|
-
return Promise.resolve(undefined);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* @async
|
|
190
|
-
* @function getSubmitStep
|
|
191
|
-
* @param {OptimalYieldPathParams} params - base param to join pool
|
|
192
|
-
* @description Generate token approve step data
|
|
193
|
-
* */
|
|
194
|
-
|
|
195
|
-
/** Generate the optimal steps to join pool */
|
|
196
|
-
async generateOptimalPath(params) {
|
|
197
|
-
const result = {
|
|
198
|
-
totalFee: [this.firstStepFee],
|
|
199
|
-
steps: [_constants2.DEFAULT_YIELD_FIRST_STEP]
|
|
200
|
-
};
|
|
201
|
-
try {
|
|
202
|
-
const stepFunctions = [this.getTokenApproveStep, this.getXcmStep, this.getSubmitStep];
|
|
203
|
-
for (const stepFunction of stepFunctions) {
|
|
204
|
-
const step = await stepFunction.bind(this, params)();
|
|
205
|
-
if (step) {
|
|
206
|
-
const [info, fee] = step;
|
|
207
|
-
result.steps.push({
|
|
208
|
-
id: result.steps.length,
|
|
209
|
-
...info
|
|
210
|
-
});
|
|
211
|
-
result.totalFee.push(fee);
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
return result;
|
|
215
|
-
} catch (e) {
|
|
216
|
-
const errorMessage = e.message;
|
|
217
|
-
if (errorMessage.includes('network')) {
|
|
218
|
-
result.connectionError = errorMessage.split(' ')[0];
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
/* Submit step */
|
|
222
|
-
|
|
223
|
-
const [step, fee] = this.defaultSubmitStep;
|
|
224
|
-
result.steps.push({
|
|
225
|
-
id: result.steps.length,
|
|
226
|
-
...step
|
|
227
|
-
});
|
|
228
|
-
result.totalFee.push(fee);
|
|
229
|
-
|
|
230
|
-
/* Submit step */
|
|
231
|
-
|
|
232
|
-
return result;
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
/* Generate steps */
|
|
237
|
-
|
|
238
|
-
/* Validate */
|
|
239
|
-
|
|
240
|
-
/** Validate param to join the pool */
|
|
241
|
-
|
|
242
|
-
/** Create `transaction` to leave the pool */
|
|
243
|
-
async handleYieldLeave(fastLeave, amount, address, selectedTarget) {
|
|
244
|
-
if (fastLeave) {
|
|
245
|
-
return this.handleYieldRedeem(amount, address, selectedTarget);
|
|
246
|
-
} else {
|
|
247
|
-
return this.handleYieldUnstake(amount, address, selectedTarget);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
/* Leave action */
|
|
252
|
-
|
|
253
|
-
/* Other actions */
|
|
254
|
-
|
|
255
|
-
/** Create `transaction` to withdraw unstaked amount */
|
|
256
|
-
|
|
257
|
-
/* Other actions */
|
|
258
|
-
}
|
|
259
|
-
exports.default = BasePoolHandler;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
var _exportNames = {
|
|
8
|
-
BasePoolHandler: true,
|
|
9
|
-
NominationPoolHandler: true
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "BasePoolHandler", {
|
|
12
|
-
enumerable: true,
|
|
13
|
-
get: function () {
|
|
14
|
-
return _base.default;
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
Object.defineProperty(exports, "NominationPoolHandler", {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: function () {
|
|
20
|
-
return _nominationPool.default;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
var _base = _interopRequireDefault(require("./base"));
|
|
24
|
-
var _nominationPool = _interopRequireDefault(require("./nomination-pool"));
|
|
25
|
-
var _lending = require("./lending");
|
|
26
|
-
Object.keys(_lending).forEach(function (key) {
|
|
27
|
-
if (key === "default" || key === "__esModule") return;
|
|
28
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
29
|
-
if (key in exports && exports[key] === _lending[key]) return;
|
|
30
|
-
Object.defineProperty(exports, key, {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function () {
|
|
33
|
-
return _lending[key];
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
var _liquidStaking = require("./liquid-staking");
|
|
38
|
-
Object.keys(_liquidStaking).forEach(function (key) {
|
|
39
|
-
if (key === "default" || key === "__esModule") return;
|
|
40
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
41
|
-
if (key in exports && exports[key] === _liquidStaking[key]) return;
|
|
42
|
-
Object.defineProperty(exports, key, {
|
|
43
|
-
enumerable: true,
|
|
44
|
-
get: function () {
|
|
45
|
-
return _liquidStaking[key];
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
var _nativeStaking = require("./native-staking");
|
|
50
|
-
Object.keys(_nativeStaking).forEach(function (key) {
|
|
51
|
-
if (key === "default" || key === "__esModule") return;
|
|
52
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
53
|
-
if (key in exports && exports[key] === _nativeStaking[key]) return;
|
|
54
|
-
Object.defineProperty(exports, key, {
|
|
55
|
-
enumerable: true,
|
|
56
|
-
get: function () {
|
|
57
|
-
return _nativeStaking[key];
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
});
|
|
@@ -1,20 +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 _types = require("@subwallet/extension-base/types");
|
|
9
|
-
var _special = _interopRequireDefault(require("../special"));
|
|
10
|
-
// Copyright 2019-2022 @subwallet/extension-base
|
|
11
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
12
|
-
|
|
13
|
-
class BaseLendingPoolHandler extends _special.default {
|
|
14
|
-
type = _types.YieldPoolType.LENDING;
|
|
15
|
-
|
|
16
|
-
/* Subscribe pool info */
|
|
17
|
-
|
|
18
|
-
/* Subscribe pool info */
|
|
19
|
-
}
|
|
20
|
-
exports.default = BaseLendingPoolHandler;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
Object.defineProperty(exports, "InterlayLendingPoolHandler", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: function () {
|
|
10
|
-
return _interlay.default;
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
var _interlay = _interopRequireDefault(require("./interlay"));
|