@subwallet/extension-base 1.1.33-beta.3 → 1.1.35-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/background/KoniTypes.d.ts +69 -111
- package/background/KoniTypes.js +13 -19
- package/background/errors/TransactionError.js +0 -9
- package/cjs/background/KoniTypes.js +16 -20
- package/cjs/background/errors/TransactionError.js +0 -9
- package/cjs/constants/index.js +4 -19
- package/cjs/koni/api/nft/config.js +23 -33
- package/cjs/koni/api/nft/index.js +0 -14
- package/cjs/koni/api/nft/nft.js +22 -1
- package/cjs/koni/api/staking/bonding/amplitude.js +16 -19
- package/cjs/koni/api/staking/bonding/astar.js +10 -11
- package/cjs/koni/api/staking/bonding/index.js +1 -4
- package/cjs/koni/api/staking/bonding/paraChain.js +23 -25
- package/cjs/koni/api/staking/bonding/relayChain.js +45 -48
- package/cjs/koni/api/staking/bonding/utils.js +86 -104
- package/cjs/koni/api/staking/index.js +5 -6
- package/cjs/koni/api/staking/paraChain.js +17 -10
- package/cjs/koni/api/staking/relayChain.js +2 -3
- package/cjs/koni/background/cron.js +21 -3
- package/cjs/koni/background/handlers/Extension.js +69 -368
- package/cjs/koni/background/handlers/State.js +12 -18
- package/cjs/koni/background/handlers/index.js +2 -4
- package/cjs/koni/background/subscription.js +104 -7
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/helpers/subscribe/substrate/index.js +1 -3
- package/cjs/services/campaign-service/index.js +6 -9
- package/cjs/services/chain-service/constants.js +16 -1
- package/cjs/services/chain-service/index.js +2 -5
- package/cjs/services/chain-service/utils.js +1 -7
- package/cjs/services/event-service/index.js +0 -5
- package/cjs/services/keyring-service/index.js +2 -14
- package/cjs/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
- package/cjs/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
- package/cjs/services/migration-service/scripts/index.js +1 -6
- package/cjs/services/notification-service/NotificationService.js +1 -1
- package/cjs/services/storage-service/DatabaseService.js +0 -63
- package/cjs/services/storage-service/databases/index.js +0 -4
- package/cjs/services/storage-service/db-stores/NominatorMetadata.js +3 -3
- package/cjs/services/subscan-service/index.js +0 -16
- package/cjs/services/transaction-service/event-parser/index.js +0 -58
- package/cjs/services/transaction-service/helpers/index.js +1 -3
- package/cjs/services/transaction-service/index.js +75 -249
- package/cjs/services/transaction-service/utils.js +0 -1
- package/cjs/types/index.js +0 -44
- package/cjs/utils/fetchStaticData.js +1 -2
- package/cjs/utils/index.js +1 -89
- package/cjs/utils/number.js +2 -6
- package/constants/index.d.ts +1 -6
- package/constants/index.js +1 -6
- package/koni/api/nft/config.js +23 -33
- package/koni/api/nft/index.js +1 -15
- package/koni/api/nft/nft.js +23 -2
- package/koni/api/staking/bonding/amplitude.js +10 -13
- package/koni/api/staking/bonding/astar.js +8 -9
- package/koni/api/staking/bonding/index.d.ts +1 -1
- package/koni/api/staking/bonding/index.js +1 -5
- package/koni/api/staking/bonding/paraChain.js +10 -12
- package/koni/api/staking/bonding/relayChain.d.ts +2 -2
- package/koni/api/staking/bonding/relayChain.js +30 -33
- package/koni/api/staking/bonding/utils.d.ts +38 -15
- package/koni/api/staking/bonding/utils.js +69 -85
- package/koni/api/staking/index.js +1 -2
- package/koni/api/staking/paraChain.js +18 -11
- package/koni/api/staking/relayChain.js +3 -4
- package/koni/background/cron.d.ts +4 -0
- package/koni/background/cron.js +22 -4
- package/koni/background/handlers/Extension.d.ts +1 -17
- package/koni/background/handlers/Extension.js +30 -327
- package/koni/background/handlers/State.d.ts +1 -6
- package/koni/background/handlers/State.js +12 -17
- package/koni/background/handlers/index.js +2 -4
- package/koni/background/subscription.d.ts +6 -1
- package/koni/background/subscription.js +104 -8
- package/package.json +7 -320
- package/packageInfo.js +1 -1
- package/services/balance-service/helpers/subscribe/substrate/index.js +2 -4
- package/services/campaign-service/index.js +6 -9
- package/services/chain-service/constants.d.ts +12 -0
- package/services/chain-service/constants.js +14 -0
- package/services/chain-service/index.js +2 -5
- package/services/chain-service/utils.d.ts +0 -1
- package/services/chain-service/utils.js +1 -5
- package/services/event-service/index.d.ts +0 -2
- package/services/event-service/index.js +0 -5
- package/services/event-service/types.d.ts +0 -9
- package/services/keyring-service/index.d.ts +1 -2
- package/services/keyring-service/index.js +2 -14
- package/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
- package/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
- package/services/migration-service/scripts/index.js +1 -6
- package/services/notification-service/NotificationService.js +1 -1
- package/services/storage-service/DatabaseService.d.ts +1 -22
- package/services/storage-service/DatabaseService.js +0 -63
- package/services/storage-service/databases/index.d.ts +1 -3
- package/services/storage-service/databases/index.js +0 -4
- package/services/storage-service/db-stores/NominatorMetadata.js +3 -3
- package/services/subscan-service/index.d.ts +2 -3
- package/services/subscan-service/index.js +0 -15
- package/services/subscan-service/types.d.ts +0 -20
- package/services/transaction-service/event-parser/index.d.ts +1 -3
- package/services/transaction-service/event-parser/index.js +1 -57
- package/services/transaction-service/helpers/index.js +1 -3
- package/services/transaction-service/index.d.ts +13 -6
- package/services/transaction-service/index.js +73 -247
- package/services/transaction-service/types.d.ts +0 -2
- package/services/transaction-service/utils.js +0 -1
- package/types/index.d.ts +0 -5
- package/types/index.js +1 -5
- package/utils/fetchStaticData.js +1 -2
- package/utils/index.d.ts +0 -5
- package/utils/index.js +0 -52
- package/utils/number.d.ts +1 -2
- package/utils/number.js +1 -2
- package/cjs/koni/api/dotsama/balance.js +0 -464
- package/cjs/koni/api/nft/ordinal_nft/constants.js +0 -21
- package/cjs/koni/api/nft/ordinal_nft/index.js +0 -121
- package/cjs/koni/api/nft/ordinal_nft/utils.js +0 -41
- package/cjs/koni/api/yield/helper/utils.js +0 -46
- package/cjs/services/earning-service/constants/chains.js +0 -30
- package/cjs/services/earning-service/constants/index.js +0 -27
- package/cjs/services/earning-service/constants/step.js +0 -18
- package/cjs/services/earning-service/handlers/base.js +0 -262
- package/cjs/services/earning-service/handlers/index.js +0 -60
- package/cjs/services/earning-service/handlers/lending/base.js +0 -81
- package/cjs/services/earning-service/handlers/lending/index.js +0 -13
- package/cjs/services/earning-service/handlers/lending/interlay.js +0 -192
- package/cjs/services/earning-service/handlers/liquid-staking/acala.js +0 -240
- package/cjs/services/earning-service/handlers/liquid-staking/base.js +0 -97
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost-manta.js +0 -140
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +0 -298
- package/cjs/services/earning-service/handlers/liquid-staking/index.js +0 -34
- package/cjs/services/earning-service/handlers/liquid-staking/parallel.js +0 -227
- package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +0 -404
- package/cjs/services/earning-service/handlers/native-staking/amplitude.js +0 -434
- package/cjs/services/earning-service/handlers/native-staking/astar.js +0 -466
- package/cjs/services/earning-service/handlers/native-staking/base-para.js +0 -146
- package/cjs/services/earning-service/handlers/native-staking/base.js +0 -161
- package/cjs/services/earning-service/handlers/native-staking/index.js +0 -34
- package/cjs/services/earning-service/handlers/native-staking/para-chain.js +0 -390
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +0 -567
- package/cjs/services/earning-service/handlers/nomination-pool/index.js +0 -566
- package/cjs/services/earning-service/handlers/special.js +0 -493
- package/cjs/services/earning-service/service.js +0 -740
- package/cjs/services/earning-service/utils/index.js +0 -128
- package/cjs/services/migration-service/scripts/DeleteEarningData.js +0 -21
- package/cjs/services/migration-service/scripts/EnableEarningChains.js +0 -21
- package/cjs/services/migration-service/scripts/MigrateEthProvider.js +0 -17
- package/cjs/services/migration-service/scripts/MigratePioneerProvider.js +0 -17
- package/cjs/services/migration-service/scripts/MigrateProvider.js +0 -29
- package/cjs/services/migration-service/scripts/databases/MigrateEarningHistory.js +0 -21
- package/cjs/services/migration-service/scripts/databases/MigrateEarningVersion.js +0 -21
- package/cjs/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -149
- package/cjs/services/mint-campaign-service/campaigns/index.js +0 -13
- package/cjs/services/mint-campaign-service/constants.js +0 -11
- package/cjs/services/mint-campaign-service/index.js +0 -18
- package/cjs/services/storage-service/db-stores/YieldPoolStore.js +0 -36
- package/cjs/services/storage-service/db-stores/YieldPositionStore.js +0 -71
- package/cjs/services/storage-service/index.js +0 -241
- package/cjs/types/campaigns/index.js +0 -16
- package/cjs/types/campaigns/unlock-dot.js +0 -1
- package/cjs/types/ordinal.js +0 -1
- package/cjs/types/transaction.js +0 -1
- package/cjs/types/yield/actions/index.js +0 -27
- package/cjs/types/yield/actions/join/index.js +0 -38
- package/cjs/types/yield/actions/join/step.js +0 -47
- package/cjs/types/yield/actions/join/submit.js +0 -1
- package/cjs/types/yield/actions/join/validate.js +0 -16
- package/cjs/types/yield/actions/others.js +0 -1
- package/cjs/types/yield/index.js +0 -27
- package/cjs/types/yield/info/account/index.js +0 -49
- package/cjs/types/yield/info/account/info.js +0 -1
- package/cjs/types/yield/info/account/reward.js +0 -1
- package/cjs/types/yield/info/account/target.js +0 -32
- package/cjs/types/yield/info/account/unstake.js +0 -27
- package/cjs/types/yield/info/base.js +0 -41
- package/cjs/types/yield/info/chain/index.js +0 -27
- package/cjs/types/yield/info/chain/info.js +0 -1
- package/cjs/types/yield/info/chain/target.js +0 -1
- package/cjs/types/yield/info/index.js +0 -49
- package/cjs/types/yield/info/pallet.js +0 -15
- package/cjs/types.js +0 -1
- package/cjs/utils/address.js +0 -34
- package/cjs/utils/keyring.js +0 -57
- package/cjs/utils/object.js +0 -12
- package/koni/api/nft/ordinal_nft/constants.d.ts +0 -9
- package/koni/api/nft/ordinal_nft/constants.js +0 -12
- package/koni/api/nft/ordinal_nft/index.d.ts +0 -8
- package/koni/api/nft/ordinal_nft/index.js +0 -114
- package/koni/api/nft/ordinal_nft/utils.d.ts +0 -2
- package/koni/api/nft/ordinal_nft/utils.js +0 -33
- package/koni/api/yield/helper/utils.d.ts +0 -10
- package/koni/api/yield/helper/utils.js +0 -32
- package/services/earning-service/constants/abis/compound_finance_v2_abi.json +0 -1235
- package/services/earning-service/constants/abis/st_liquid_token_abi.json +0 -1355
- package/services/earning-service/constants/chains.d.ts +0 -15
- package/services/earning-service/constants/chains.js +0 -22
- package/services/earning-service/constants/index.d.ts +0 -2
- package/services/earning-service/constants/index.js +0 -5
- package/services/earning-service/constants/step.d.ts +0 -3
- package/services/earning-service/constants/step.js +0 -10
- package/services/earning-service/handlers/base.d.ts +0 -113
- package/services/earning-service/handlers/base.js +0 -256
- package/services/earning-service/handlers/index.d.ts +0 -5
- package/services/earning-service/handlers/index.js +0 -8
- package/services/earning-service/handlers/lending/base.d.ts +0 -8
- package/services/earning-service/handlers/lending/base.js +0 -73
- package/services/earning-service/handlers/lending/index.d.ts +0 -1
- package/services/earning-service/handlers/lending/index.js +0 -4
- package/services/earning-service/handlers/lending/interlay.d.ts +0 -24
- package/services/earning-service/handlers/lending/interlay.js +0 -184
- package/services/earning-service/handlers/liquid-staking/acala.d.ts +0 -27
- package/services/earning-service/handlers/liquid-staking/acala.js +0 -232
- package/services/earning-service/handlers/liquid-staking/base.d.ts +0 -11
- package/services/earning-service/handlers/liquid-staking/base.js +0 -89
- package/services/earning-service/handlers/liquid-staking/bifrost.d.ts +0 -46
- package/services/earning-service/handlers/liquid-staking/bifrost.js +0 -287
- package/services/earning-service/handlers/liquid-staking/index.d.ts +0 -4
- package/services/earning-service/handlers/liquid-staking/index.js +0 -7
- package/services/earning-service/handlers/liquid-staking/parallel.d.ts +0 -26
- package/services/earning-service/handlers/liquid-staking/parallel.js +0 -219
- package/services/earning-service/handlers/liquid-staking/stella-swap.d.ts +0 -34
- package/services/earning-service/handlers/liquid-staking/stella-swap.js +0 -394
- package/services/earning-service/handlers/native-staking/amplitude.d.ts +0 -22
- package/services/earning-service/handlers/native-staking/amplitude.js +0 -425
- package/services/earning-service/handlers/native-staking/astar.d.ts +0 -19
- package/services/earning-service/handlers/native-staking/astar.js +0 -456
- package/services/earning-service/handlers/native-staking/base-para.d.ts +0 -11
- package/services/earning-service/handlers/native-staking/base-para.js +0 -138
- package/services/earning-service/handlers/native-staking/base.d.ts +0 -21
- package/services/earning-service/handlers/native-staking/base.js +0 -152
- package/services/earning-service/handlers/native-staking/index.d.ts +0 -4
- package/services/earning-service/handlers/native-staking/index.js +0 -7
- package/services/earning-service/handlers/native-staking/para-chain.d.ts +0 -15
- package/services/earning-service/handlers/native-staking/para-chain.js +0 -382
- package/services/earning-service/handlers/native-staking/relay-chain.d.ts +0 -21
- package/services/earning-service/handlers/native-staking/relay-chain.js +0 -558
- package/services/earning-service/handlers/nomination-pool/index.d.ts +0 -36
- package/services/earning-service/handlers/nomination-pool/index.js +0 -556
- package/services/earning-service/handlers/special.d.ts +0 -64
- package/services/earning-service/handlers/special.js +0 -485
- package/services/earning-service/service.d.ts +0 -94
- package/services/earning-service/service.js +0 -729
- package/services/earning-service/utils/index.d.ts +0 -18
- package/services/earning-service/utils/index.js +0 -112
- package/services/migration-service/scripts/DeleteEarningData.d.ts +0 -4
- package/services/migration-service/scripts/DeleteEarningData.js +0 -13
- package/services/migration-service/scripts/EnableEarningChains.d.ts +0 -4
- package/services/migration-service/scripts/EnableEarningChains.js +0 -13
- package/services/migration-service/scripts/databases/MigrateEarningHistory.d.ts +0 -4
- package/services/migration-service/scripts/databases/MigrateEarningHistory.js +0 -13
- package/services/migration-service/scripts/databases/MigrateEarningVersion.d.ts +0 -4
- package/services/migration-service/scripts/databases/MigrateEarningVersion.js +0 -13
- package/services/mint-campaign-service/campaigns/UnlockDotCampaign.d.ts +0 -13
- package/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -139
- package/services/mint-campaign-service/campaigns/index.d.ts +0 -1
- package/services/mint-campaign-service/campaigns/index.js +0 -4
- package/services/mint-campaign-service/constants.d.ts +0 -1
- package/services/mint-campaign-service/constants.js +0 -4
- package/services/mint-campaign-service/index.d.ts +0 -7
- package/services/mint-campaign-service/index.js +0 -11
- package/services/storage-service/db-stores/YieldPoolStore.d.ts +0 -10
- package/services/storage-service/db-stores/YieldPoolStore.js +0 -28
- package/services/storage-service/db-stores/YieldPositionStore.d.ts +0 -11
- package/services/storage-service/db-stores/YieldPositionStore.js +0 -63
- package/types/campaigns/index.d.ts +0 -1
- package/types/campaigns/index.js +0 -4
- package/types/campaigns/unlock-dot.d.ts +0 -71
- package/types/campaigns/unlock-dot.js +0 -1
- package/types/ordinal.d.ts +0 -69
- package/types/ordinal.js +0 -1
- package/types/transaction.d.ts +0 -3
- package/types/transaction.js +0 -1
- package/types/yield/actions/index.d.ts +0 -2
- package/types/yield/actions/index.js +0 -5
- package/types/yield/actions/join/index.d.ts +0 -3
- package/types/yield/actions/join/index.js +0 -6
- package/types/yield/actions/join/step.d.ts +0 -95
- package/types/yield/actions/join/step.js +0 -46
- package/types/yield/actions/join/submit.d.ts +0 -58
- package/types/yield/actions/join/submit.js +0 -1
- package/types/yield/actions/join/validate.d.ts +0 -18
- package/types/yield/actions/join/validate.js +0 -10
- package/types/yield/actions/others.d.ts +0 -85
- package/types/yield/actions/others.js +0 -1
- package/types/yield/index.d.ts +0 -2
- package/types/yield/index.js +0 -5
- package/types/yield/info/account/index.d.ts +0 -4
- package/types/yield/info/account/index.js +0 -7
- package/types/yield/info/account/info.d.ts +0 -92
- package/types/yield/info/account/info.js +0 -1
- package/types/yield/info/account/reward.d.ts +0 -47
- package/types/yield/info/account/reward.js +0 -1
- package/types/yield/info/account/target.d.ts +0 -43
- package/types/yield/info/account/target.js +0 -27
- package/types/yield/info/account/unstake.d.ts +0 -31
- package/types/yield/info/account/unstake.js +0 -22
- package/types/yield/info/base.d.ts +0 -45
- package/types/yield/info/base.js +0 -36
- package/types/yield/info/chain/index.d.ts +0 -2
- package/types/yield/info/chain/index.js +0 -5
- package/types/yield/info/chain/info.d.ts +0 -252
- package/types/yield/info/chain/info.js +0 -1
- package/types/yield/info/chain/target.d.ts +0 -37
- package/types/yield/info/chain/target.js +0 -1
- package/types/yield/info/index.d.ts +0 -4
- package/types/yield/info/index.js +0 -7
- package/types/yield/info/pallet.d.ts +0 -143
- package/types/yield/info/pallet.js +0 -9
- package/utils/object.d.ts +0 -1
- package/utils/object.js +0 -6
package/cjs/utils/index.js
CHANGED
|
@@ -36,12 +36,9 @@ var _exportNames = {
|
|
|
36
36
|
getDomainFromUrl: true,
|
|
37
37
|
waitTimeout: true,
|
|
38
38
|
stripUrl: true,
|
|
39
|
-
baseParseIPFSUrl: true,
|
|
40
|
-
swParseIPFSUrl: true,
|
|
41
39
|
wait: true,
|
|
42
40
|
canDerive: true
|
|
43
41
|
};
|
|
44
|
-
exports.baseParseIPFSUrl = void 0;
|
|
45
42
|
Object.defineProperty(exports, "canDerive", {
|
|
46
43
|
enumerable: true,
|
|
47
44
|
get: function () {
|
|
@@ -70,13 +67,12 @@ exports.parseRawNumber = parseRawNumber;
|
|
|
70
67
|
exports.reformatAddress = reformatAddress;
|
|
71
68
|
exports.stripUrl = void 0;
|
|
72
69
|
exports.sumBN = sumBN;
|
|
73
|
-
exports.toUnit =
|
|
70
|
+
exports.toUnit = void 0;
|
|
74
71
|
exports.utf16ToString = utf16ToString;
|
|
75
72
|
exports.wait = wait;
|
|
76
73
|
exports.waitTimeout = waitTimeout;
|
|
77
74
|
var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
78
75
|
var _constants = require("@subwallet/extension-base/constants");
|
|
79
|
-
var _config = require("@subwallet/extension-base/koni/api/nft/config");
|
|
80
76
|
var _environment = require("@subwallet/extension-base/utils/environment");
|
|
81
77
|
var _i18next = require("i18next");
|
|
82
78
|
var _util = require("@polkadot/util");
|
|
@@ -118,18 +114,6 @@ Object.keys(_environment2).forEach(function (key) {
|
|
|
118
114
|
}
|
|
119
115
|
});
|
|
120
116
|
});
|
|
121
|
-
var _number = require("./number");
|
|
122
|
-
Object.keys(_number).forEach(function (key) {
|
|
123
|
-
if (key === "default" || key === "__esModule") return;
|
|
124
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
125
|
-
if (key in exports && exports[key] === _number[key]) return;
|
|
126
|
-
Object.defineProperty(exports, key, {
|
|
127
|
-
enumerable: true,
|
|
128
|
-
get: function () {
|
|
129
|
-
return _number[key];
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
117
|
var _lazy = require("./lazy");
|
|
134
118
|
Object.keys(_lazy).forEach(function (key) {
|
|
135
119
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -142,18 +126,6 @@ Object.keys(_lazy).forEach(function (key) {
|
|
|
142
126
|
}
|
|
143
127
|
});
|
|
144
128
|
});
|
|
145
|
-
var _promise = require("./promise");
|
|
146
|
-
Object.keys(_promise).forEach(function (key) {
|
|
147
|
-
if (key === "default" || key === "__esModule") return;
|
|
148
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
149
|
-
if (key in exports && exports[key] === _promise[key]) return;
|
|
150
|
-
Object.defineProperty(exports, key, {
|
|
151
|
-
enumerable: true,
|
|
152
|
-
get: function () {
|
|
153
|
-
return _promise[key];
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
});
|
|
157
129
|
var _registry = require("./registry");
|
|
158
130
|
Object.keys(_registry).forEach(function (key) {
|
|
159
131
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -178,18 +150,6 @@ Object.keys(_translate).forEach(function (key) {
|
|
|
178
150
|
}
|
|
179
151
|
});
|
|
180
152
|
});
|
|
181
|
-
var _object = require("./object");
|
|
182
|
-
Object.keys(_object).forEach(function (key) {
|
|
183
|
-
if (key === "default" || key === "__esModule") return;
|
|
184
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
185
|
-
if (key in exports && exports[key] === _object[key]) return;
|
|
186
|
-
Object.defineProperty(exports, key, {
|
|
187
|
-
enumerable: true,
|
|
188
|
-
get: function () {
|
|
189
|
-
return _object[key];
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
});
|
|
193
153
|
var _fetchStaticData = require("./fetchStaticData");
|
|
194
154
|
Object.keys(_fetchStaticData).forEach(function (key) {
|
|
195
155
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -514,54 +474,6 @@ const stripUrl = url => {
|
|
|
514
474
|
return parts[2];
|
|
515
475
|
};
|
|
516
476
|
exports.stripUrl = stripUrl;
|
|
517
|
-
const baseParseIPFSUrl = input => {
|
|
518
|
-
if (!input || input.length === 0) {
|
|
519
|
-
return undefined;
|
|
520
|
-
}
|
|
521
|
-
if (isUrl(input)) {
|
|
522
|
-
return input;
|
|
523
|
-
}
|
|
524
|
-
if (isUrl(input) || input.includes('https://') || input.includes('http')) {
|
|
525
|
-
return input;
|
|
526
|
-
}
|
|
527
|
-
if (input.startsWith('/ipfs/')) {
|
|
528
|
-
return (0, _config.getRandomIpfsGateway)() + input.split('/ipfs/')[1];
|
|
529
|
-
}
|
|
530
|
-
if (!input.includes('ipfs://') && !input.includes('ipfs://ipfs/')) {
|
|
531
|
-
// just the IPFS hash
|
|
532
|
-
return (0, _config.getRandomIpfsGateway)() + input;
|
|
533
|
-
}
|
|
534
|
-
if (input.includes('ipfs://') && !input.includes('ipfs://ipfs/')) {
|
|
535
|
-
// starts with ipfs://
|
|
536
|
-
return (0, _config.getRandomIpfsGateway)() + input.split('ipfs://')[1];
|
|
537
|
-
}
|
|
538
|
-
return (0, _config.getRandomIpfsGateway)() + input.split('ipfs://ipfs/')[1]; // starts with ipfs://ipfs/
|
|
539
|
-
};
|
|
540
|
-
exports.baseParseIPFSUrl = baseParseIPFSUrl;
|
|
541
|
-
const swParseIPFSUrl = input => {
|
|
542
|
-
if (!input || input.length === 0) {
|
|
543
|
-
return undefined;
|
|
544
|
-
}
|
|
545
|
-
if (isUrl(input)) {
|
|
546
|
-
return input;
|
|
547
|
-
}
|
|
548
|
-
if (isUrl(input) || input.includes('https://') || input.includes('http')) {
|
|
549
|
-
return input;
|
|
550
|
-
}
|
|
551
|
-
if (input.startsWith('/ipfs/')) {
|
|
552
|
-
return _config.SUBWALLET_IPFS + input.split('/ipfs/')[1];
|
|
553
|
-
}
|
|
554
|
-
if (!input.includes('ipfs://') && !input.includes('ipfs://ipfs/')) {
|
|
555
|
-
// just the IPFS hash
|
|
556
|
-
return _config.SUBWALLET_IPFS + input;
|
|
557
|
-
}
|
|
558
|
-
if (input.includes('ipfs://') && !input.includes('ipfs://ipfs/')) {
|
|
559
|
-
// starts with ipfs://
|
|
560
|
-
return _config.SUBWALLET_IPFS + input.split('ipfs://')[1];
|
|
561
|
-
}
|
|
562
|
-
return _config.SUBWALLET_IPFS + input.split('ipfs://ipfs/')[1]; // starts with ipfs://ipfs/
|
|
563
|
-
};
|
|
564
|
-
exports.swParseIPFSUrl = swParseIPFSUrl;
|
|
565
477
|
function wait(milliseconds) {
|
|
566
478
|
return new Promise(resolve => {
|
|
567
479
|
setTimeout(() => {
|
package/cjs/utils/number.js
CHANGED
|
@@ -4,13 +4,11 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.toBNString = exports.formatNumber = exports.balanceFormatter = exports.PREDEFINED_FORMATTER = exports.
|
|
7
|
+
exports.toBNString = exports.formatNumber = exports.balanceFormatter = exports.PREDEFINED_FORMATTER = exports.BN_TEN = void 0;
|
|
8
8
|
var _bignumber = _interopRequireDefault(require("bignumber.js"));
|
|
9
9
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
10
10
|
// SPDX-License-Identifier: Apache-2.0
|
|
11
11
|
|
|
12
|
-
const BN_ZERO = new _bignumber.default(0);
|
|
13
|
-
exports.BN_ZERO = BN_ZERO;
|
|
14
12
|
const BN_TEN = new _bignumber.default(10);
|
|
15
13
|
exports.BN_TEN = BN_TEN;
|
|
16
14
|
// Clear zero from end, use with decimal only
|
|
@@ -107,9 +105,7 @@ const toBNString = (input, decimal) => {
|
|
|
107
105
|
return raw.multipliedBy(BN_TEN.pow(decimal)).toFixed();
|
|
108
106
|
};
|
|
109
107
|
exports.toBNString = toBNString;
|
|
110
|
-
const formatNumber =
|
|
111
|
-
let formatter = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : balanceFormatter;
|
|
112
|
-
let metadata = arguments.length > 3 ? arguments[3] : undefined;
|
|
108
|
+
const formatNumber = (input, decimal, formatter, metadata) => {
|
|
113
109
|
const raw = new _bignumber.default(input).dividedBy(BN_TEN.pow(decimal)).toFixed();
|
|
114
110
|
return formatter(raw, metadata);
|
|
115
111
|
};
|
package/constants/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
export declare const BASE_SECOND_INTERVAL = 1000;
|
|
2
|
-
export declare const BASE_MINUTE_INTERVAL: number;
|
|
3
1
|
export declare const CRON_REFRESH_PRICE_INTERVAL = 30000;
|
|
4
2
|
export declare const CRON_AUTO_RECOVER_DOTSAMA_INTERVAL = 60000;
|
|
5
3
|
export declare const CRON_AUTO_RECOVER_WEB3_INTERVAL = 90000;
|
|
@@ -8,7 +6,7 @@ export declare const ASTAR_REFRESH_BALANCE_INTERVAL = 60000;
|
|
|
8
6
|
export declare const SUB_TOKEN_REFRESH_BALANCE_INTERVAL = 60000;
|
|
9
7
|
export declare const CRON_REFRESH_NFT_INTERVAL = 7200000;
|
|
10
8
|
export declare const CRON_REFRESH_STAKING_REWARD_INTERVAL = 900000;
|
|
11
|
-
export declare const CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL =
|
|
9
|
+
export declare const CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL = 300000;
|
|
12
10
|
export declare const CRON_REFRESH_HISTORY_INTERVAL = 900000;
|
|
13
11
|
export declare const CRON_GET_API_MAP_STATUS = 10000;
|
|
14
12
|
export declare const CRON_REFRESH_CHAIN_STAKING_METADATA = 900000;
|
|
@@ -16,7 +14,6 @@ export declare const CRON_REFRESH_CHAIN_NOMINATOR_METADATA = 1800000;
|
|
|
16
14
|
export declare const CRON_RECOVER_HISTORY_INTERVAL = 30000;
|
|
17
15
|
export declare const CRON_SYNC_MANTA_PAY = 300000;
|
|
18
16
|
export declare const MANTA_PAY_BALANCE_INTERVAL = 30000;
|
|
19
|
-
export declare const CRON_REFRESH_EARNING_REWARD_HISTORY_INTERVAL: number;
|
|
20
17
|
export declare const ALL_ACCOUNT_KEY = "ALL";
|
|
21
18
|
export declare const ALL_NETWORK_KEY = "all";
|
|
22
19
|
export declare const ALL_GENESIS_HASH: null;
|
|
@@ -25,7 +22,5 @@ export declare const IGNORE_QR_SIGNER: string[];
|
|
|
25
22
|
export declare const XCM_MIN_AMOUNT_RATIO = 1.2;
|
|
26
23
|
export declare const GAS_PRICE_RATIO: number;
|
|
27
24
|
export declare const NETWORK_MULTI_GAS_FEE: string[];
|
|
28
|
-
export declare const ORDINAL_COLLECTION = "__Ordinal__";
|
|
29
|
-
export declare const ORDINAL_METHODS: string[];
|
|
30
25
|
export * from './staking';
|
|
31
26
|
export * from './storage';
|
package/constants/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
export const BASE_SECOND_INTERVAL = 1000;
|
|
5
|
-
export const BASE_MINUTE_INTERVAL = 60 * BASE_SECOND_INTERVAL;
|
|
6
4
|
export const CRON_REFRESH_PRICE_INTERVAL = 30000;
|
|
7
5
|
export const CRON_AUTO_RECOVER_DOTSAMA_INTERVAL = 60000;
|
|
8
6
|
export const CRON_AUTO_RECOVER_WEB3_INTERVAL = 90000;
|
|
@@ -11,7 +9,7 @@ export const ASTAR_REFRESH_BALANCE_INTERVAL = 60000;
|
|
|
11
9
|
export const SUB_TOKEN_REFRESH_BALANCE_INTERVAL = 60000;
|
|
12
10
|
export const CRON_REFRESH_NFT_INTERVAL = 7200000;
|
|
13
11
|
export const CRON_REFRESH_STAKING_REWARD_INTERVAL = 900000;
|
|
14
|
-
export const CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL =
|
|
12
|
+
export const CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL = 300000;
|
|
15
13
|
export const CRON_REFRESH_HISTORY_INTERVAL = 900000;
|
|
16
14
|
export const CRON_GET_API_MAP_STATUS = 10000;
|
|
17
15
|
export const CRON_REFRESH_CHAIN_STAKING_METADATA = 900000;
|
|
@@ -19,7 +17,6 @@ export const CRON_REFRESH_CHAIN_NOMINATOR_METADATA = 1800000;
|
|
|
19
17
|
export const CRON_RECOVER_HISTORY_INTERVAL = 30000;
|
|
20
18
|
export const CRON_SYNC_MANTA_PAY = 300000;
|
|
21
19
|
export const MANTA_PAY_BALANCE_INTERVAL = 30000;
|
|
22
|
-
export const CRON_REFRESH_EARNING_REWARD_HISTORY_INTERVAL = 15 * BASE_MINUTE_INTERVAL;
|
|
23
20
|
export const ALL_ACCOUNT_KEY = 'ALL';
|
|
24
21
|
export const ALL_NETWORK_KEY = 'all';
|
|
25
22
|
export const ALL_GENESIS_HASH = null;
|
|
@@ -28,7 +25,5 @@ export const IGNORE_QR_SIGNER = [];
|
|
|
28
25
|
export const XCM_MIN_AMOUNT_RATIO = 1.2;
|
|
29
26
|
export const GAS_PRICE_RATIO = 1 + 2 / 100;
|
|
30
27
|
export const NETWORK_MULTI_GAS_FEE = ['*'];
|
|
31
|
-
export const ORDINAL_COLLECTION = '__Ordinal__';
|
|
32
|
-
export const ORDINAL_METHODS = ['drc-20', 'pol-20'];
|
|
33
28
|
export * from "./staking.js";
|
|
34
29
|
export * from "./storage.js";
|
package/koni/api/nft/config.js
CHANGED
|
@@ -15,11 +15,7 @@ export const CLOUDFLARE_PINATA_SERVER = 'https://cloudflare-ipfs.com/ipfs/';
|
|
|
15
15
|
export const BIT_COUNTRY_IPFS_SERVER = 'https://ipfs-cdn.bit.country/';
|
|
16
16
|
export const BIT_COUNTRY_LAND_ESTATE_METADATA_API = 'https://pioneer-api.bit.country/metadata/landTokenUriPioneer';
|
|
17
17
|
export const BIT_COUNTRY_THUMBNAIL_RESOLVER = 'https://res.cloudinary.com/ddftctzph/image/upload/c_scale,q_100,w_250/production-ipfs/asset/';
|
|
18
|
-
|
|
19
|
-
// XOrigin
|
|
20
18
|
export const CF_IPFS_GATEWAY = 'https://cf-ipfs.com/ipfs/';
|
|
21
|
-
|
|
22
|
-
// XOrigin
|
|
23
19
|
export const PINATA_IPFS_GATEWAY = 'https://gateway.pinata.cloud/ipfs/';
|
|
24
20
|
export const UNIQUE_SCAN_ENDPOINT = 'https://explorer-api.unique.network/v1/graphql';
|
|
25
21
|
export const QUARTZ_SCAN_ENDPOINT = 'https://hasura-quartz.unique.network/v1/graphql';
|
|
@@ -28,18 +24,10 @@ export const VARA_SCAN_ENDPOINT = 'https://nft-explorer.vara-network.io/graphql'
|
|
|
28
24
|
// GATEWAY
|
|
29
25
|
|
|
30
26
|
export const UNIQUE_IPFS_GATEWAY = 'https://ipfs.unique.network/ipfs/';
|
|
31
|
-
|
|
32
|
-
// XOrigin
|
|
33
27
|
export const NFT_STORAGE_GATEWAY = 'https://nftstorage.link/ipfs/';
|
|
34
28
|
export const IPFS_W3S_LINK = 'https://w3s.link/ipfs/';
|
|
35
|
-
|
|
36
|
-
// XOrigin
|
|
37
29
|
export const GATEWAY_IPFS_IO = 'https://gateway.ipfs.io/ipfs/';
|
|
38
|
-
|
|
39
|
-
// XOrigin
|
|
40
30
|
export const IPFS_IO = 'https://ipfs.io/ipfs/';
|
|
41
|
-
|
|
42
|
-
// XOrigin
|
|
43
31
|
export const DWEB_LINK = 'https://dweb.link/ipfs/';
|
|
44
32
|
export const IPFS_GATEWAY_4EVERLAND = 'https://4everland.io/ipfs/';
|
|
45
33
|
export const IPFS_FLEEK = 'https://ipfs.fleek.co/ipfs/';
|
|
@@ -95,8 +83,26 @@ export let SUPPORTED_TRANSFER_SUBSTRATE_CHAIN_NAME;
|
|
|
95
83
|
SUPPORTED_TRANSFER_SUBSTRATE_CHAIN_NAME["pioneer"] = "pioneer";
|
|
96
84
|
})(SUPPORTED_TRANSFER_SUBSTRATE_CHAIN_NAME || (SUPPORTED_TRANSFER_SUBSTRATE_CHAIN_NAME = {}));
|
|
97
85
|
const RANDOM_IPFS_GATEWAY_SETTING = [{
|
|
86
|
+
provider: CF_IPFS_GATEWAY,
|
|
87
|
+
weight: 4
|
|
88
|
+
}, {
|
|
98
89
|
provider: CLOUDFLARE_PINATA_SERVER,
|
|
99
90
|
weight: 10
|
|
91
|
+
}, {
|
|
92
|
+
provider: PINATA_IPFS_GATEWAY,
|
|
93
|
+
weight: 1 // Rate limit too low
|
|
94
|
+
}, {
|
|
95
|
+
provider: DWEB_LINK,
|
|
96
|
+
weight: 5
|
|
97
|
+
}, {
|
|
98
|
+
provider: GATEWAY_IPFS_IO,
|
|
99
|
+
weight: 5
|
|
100
|
+
}, {
|
|
101
|
+
provider: IPFS_IO,
|
|
102
|
+
weight: 5
|
|
103
|
+
}, {
|
|
104
|
+
provider: NFT_STORAGE_GATEWAY,
|
|
105
|
+
weight: 50
|
|
100
106
|
}];
|
|
101
107
|
if (isFirefox) {
|
|
102
108
|
RANDOM_IPFS_GATEWAY_SETTING.push({
|
|
@@ -104,34 +110,18 @@ if (isFirefox) {
|
|
|
104
110
|
weight: 5000
|
|
105
111
|
});
|
|
106
112
|
}
|
|
107
|
-
if (!RuntimeInfo.protocol ||
|
|
113
|
+
if (!RuntimeInfo.protocol || RuntimeInfo.protocol && !RuntimeInfo.protocol.startsWith('http')) {
|
|
108
114
|
RANDOM_IPFS_GATEWAY_SETTING.push({
|
|
109
115
|
provider: IPFS_FLEEK,
|
|
110
116
|
weight: 4
|
|
111
|
-
}
|
|
117
|
+
});
|
|
118
|
+
RANDOM_IPFS_GATEWAY_SETTING.push({
|
|
112
119
|
provider: IPFS_GATEWAY_4EVERLAND,
|
|
113
120
|
weight: 2
|
|
114
|
-
}
|
|
121
|
+
});
|
|
122
|
+
RANDOM_IPFS_GATEWAY_SETTING.push({
|
|
115
123
|
provider: IPFS_W3S_LINK,
|
|
116
124
|
weight: 1
|
|
117
|
-
}, {
|
|
118
|
-
provider: CF_IPFS_GATEWAY,
|
|
119
|
-
weight: 4
|
|
120
|
-
}, {
|
|
121
|
-
provider: PINATA_IPFS_GATEWAY,
|
|
122
|
-
weight: 1 // Rate limit too low
|
|
123
|
-
}, {
|
|
124
|
-
provider: NFT_STORAGE_GATEWAY,
|
|
125
|
-
weight: 50
|
|
126
|
-
}, {
|
|
127
|
-
provider: GATEWAY_IPFS_IO,
|
|
128
|
-
weight: 5
|
|
129
|
-
}, {
|
|
130
|
-
provider: DWEB_LINK,
|
|
131
|
-
weight: 5
|
|
132
|
-
}, {
|
|
133
|
-
provider: IPFS_IO,
|
|
134
|
-
weight: 5
|
|
135
125
|
});
|
|
136
126
|
}
|
|
137
127
|
const RANDOM_IPFS_GATEWAY_TOTAL_WEIGHT = RANDOM_IPFS_GATEWAY_SETTING.reduce((value, item) => value + item.weight, 0);
|
package/koni/api/nft/index.js
CHANGED
|
@@ -5,14 +5,13 @@ import { AcalaNftApi } from '@subwallet/extension-base/koni/api/nft/acala_nft';
|
|
|
5
5
|
import { BitCountryNftApi } from '@subwallet/extension-base/koni/api/nft/bit.country';
|
|
6
6
|
import { EvmNftApi } from '@subwallet/extension-base/koni/api/nft/evm_nft';
|
|
7
7
|
import { KaruraNftApi } from '@subwallet/extension-base/koni/api/nft/karura_nft';
|
|
8
|
-
import OrdinalNftApi from '@subwallet/extension-base/koni/api/nft/ordinal_nft';
|
|
9
8
|
import { RmrkNftApi } from '@subwallet/extension-base/koni/api/nft/rmrk_nft';
|
|
10
9
|
import StatemineNftApi from '@subwallet/extension-base/koni/api/nft/statemine_nft';
|
|
11
10
|
import UniqueNftApi from '@subwallet/extension-base/koni/api/nft/unique_nft';
|
|
12
11
|
import { VaraNftApi } from '@subwallet/extension-base/koni/api/nft/vara_nft';
|
|
13
12
|
import { WasmNftApi } from '@subwallet/extension-base/koni/api/nft/wasm_nft';
|
|
14
13
|
import { _NFT_CHAIN_GROUP } from '@subwallet/extension-base/services/chain-service/constants';
|
|
15
|
-
import { _isChainSupportEvmNft, _isChainSupportNativeNft, _isChainSupportWasmNft
|
|
14
|
+
import { _isChainSupportEvmNft, _isChainSupportNativeNft, _isChainSupportWasmNft } from '@subwallet/extension-base/services/chain-service/utils';
|
|
16
15
|
import { categoryAddresses } from '@subwallet/extension-base/utils';
|
|
17
16
|
import StatemintNftApi from "./statemint_nft/index.js";
|
|
18
17
|
function createSubstrateNftApi(chain, substrateApi, addresses) {
|
|
@@ -44,9 +43,6 @@ function createWeb3NftApi(chain, evmApi, addresses) {
|
|
|
44
43
|
const [, evmAddresses] = categoryAddresses(addresses);
|
|
45
44
|
return new EvmNftApi(evmApi, evmAddresses, chain);
|
|
46
45
|
}
|
|
47
|
-
const createOrdinalApi = (chain, subscanChain, addresses) => {
|
|
48
|
-
return new OrdinalNftApi(addresses, chain, subscanChain);
|
|
49
|
-
};
|
|
50
46
|
export class NftHandler {
|
|
51
47
|
// General settings
|
|
52
48
|
chainInfoMap = {};
|
|
@@ -126,16 +122,6 @@ export class NftHandler {
|
|
|
126
122
|
}
|
|
127
123
|
}
|
|
128
124
|
}
|
|
129
|
-
if (_isSupportOrdinal(chain)) {
|
|
130
|
-
var _chainInfo$extraInfo;
|
|
131
|
-
const subscanChain = (_chainInfo$extraInfo = chainInfo.extraInfo) === null || _chainInfo$extraInfo === void 0 ? void 0 : _chainInfo$extraInfo.subscanSlug;
|
|
132
|
-
if (subscanChain) {
|
|
133
|
-
const handler = createOrdinalApi(chain, subscanChain, substrateAddresses);
|
|
134
|
-
if (handler && !this.handlers.includes(handler)) {
|
|
135
|
-
this.handlers.push(handler);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
125
|
});
|
|
140
126
|
this.needSetupApi = false;
|
|
141
127
|
}
|
package/koni/api/nft/nft.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { getRandomIpfsGateway } from '@subwallet/extension-base/koni/api/nft/config';
|
|
5
|
+
import { isUrl } from '@subwallet/extension-base/utils';
|
|
5
6
|
export class BaseNftApi {
|
|
6
7
|
chain = '';
|
|
7
8
|
substrateApi = null;
|
|
@@ -64,7 +65,27 @@ export class BaseNftApi {
|
|
|
64
65
|
return tokenId;
|
|
65
66
|
}
|
|
66
67
|
parseUrl(input) {
|
|
67
|
-
|
|
68
|
+
if (!input || input.length === 0) {
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
if (isUrl(input)) {
|
|
72
|
+
return input;
|
|
73
|
+
}
|
|
74
|
+
if (isUrl(input) || input.includes('https://') || input.includes('http')) {
|
|
75
|
+
return input;
|
|
76
|
+
}
|
|
77
|
+
if (input.startsWith('/ipfs/')) {
|
|
78
|
+
return getRandomIpfsGateway() + input.split('/ipfs/')[1];
|
|
79
|
+
}
|
|
80
|
+
if (!input.includes('ipfs://') && !input.includes('ipfs://ipfs/')) {
|
|
81
|
+
// just the IPFS hash
|
|
82
|
+
return getRandomIpfsGateway() + input;
|
|
83
|
+
}
|
|
84
|
+
if (input.includes('ipfs://') && !input.includes('ipfs://ipfs/')) {
|
|
85
|
+
// starts with ipfs://
|
|
86
|
+
return getRandomIpfsGateway() + input.split('ipfs://')[1];
|
|
87
|
+
}
|
|
88
|
+
return getRandomIpfsGateway() + input.split('ipfs://ipfs/')[1]; // starts with ipfs://ipfs/
|
|
68
89
|
}
|
|
69
90
|
|
|
70
91
|
// Subclass implements this function to parse data into prop result
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { StakingType } from '@subwallet/extension-base/background/KoniTypes';
|
|
5
|
-
import { getBondedValidators,
|
|
6
|
-
import { _STAKING_ERA_LENGTH_MAP } from '@subwallet/extension-base/services/chain-service/constants';
|
|
7
|
-
import { _STAKING_CHAIN_GROUP } from '@subwallet/extension-base/services/earning-service/constants';
|
|
8
|
-
import { parseIdentity } from '@subwallet/extension-base/services/earning-service/utils';
|
|
9
|
-
import { EarningStatus, UnstakingStatus } from '@subwallet/extension-base/types';
|
|
4
|
+
import { StakingStatus, StakingType, UnstakingStatus } from '@subwallet/extension-base/background/KoniTypes';
|
|
5
|
+
import { getBondedValidators, getStakingStatusByNominations, isUnstakeAll, parseIdentity } from '@subwallet/extension-base/koni/api/staking/bonding/utils';
|
|
6
|
+
import { _STAKING_CHAIN_GROUP, _STAKING_ERA_LENGTH_MAP } from '@subwallet/extension-base/services/chain-service/constants';
|
|
10
7
|
import { parseRawNumber, reformatAddress } from '@subwallet/extension-base/utils';
|
|
11
8
|
import { BN, BN_ZERO } from '@polkadot/util';
|
|
12
9
|
import { isEthereumAddress } from '@polkadot/util-crypto';
|
|
@@ -72,9 +69,9 @@ export async function subscribeAmplitudeNominatorMetadata(chainInfo, address, su
|
|
|
72
69
|
const [identity] = identities[i];
|
|
73
70
|
activeStake = delegate.amount.toString();
|
|
74
71
|
const bnActiveStake = new BN(activeStake);
|
|
75
|
-
let delegationStatus =
|
|
72
|
+
let delegationStatus = StakingStatus.NOT_EARNING;
|
|
76
73
|
if (bnActiveStake.gt(BN_ZERO) && bnActiveStake.gte(new BN(minDelegatorStake))) {
|
|
77
|
-
delegationStatus =
|
|
74
|
+
delegationStatus = StakingStatus.EARNING_REWARD;
|
|
78
75
|
}
|
|
79
76
|
nominationList.push({
|
|
80
77
|
status: delegationStatus,
|
|
@@ -108,7 +105,7 @@ export async function subscribeAmplitudeNominatorMetadata(chainInfo, address, su
|
|
|
108
105
|
}
|
|
109
106
|
}
|
|
110
107
|
}
|
|
111
|
-
const stakingStatus =
|
|
108
|
+
const stakingStatus = getStakingStatusByNominations(new BN(activeStake), nominationList);
|
|
112
109
|
return {
|
|
113
110
|
chain: chainInfo.slug,
|
|
114
111
|
type: StakingType.NOMINATED,
|
|
@@ -140,7 +137,7 @@ export async function getAmplitudeNominatorMetadata(chainInfo, address, substrat
|
|
|
140
137
|
chain: chainInfo.slug,
|
|
141
138
|
type: StakingType.NOMINATED,
|
|
142
139
|
address,
|
|
143
|
-
status:
|
|
140
|
+
status: StakingStatus.NOT_STAKING,
|
|
144
141
|
activeStake: '0',
|
|
145
142
|
nominations: [],
|
|
146
143
|
unstakings: []
|
|
@@ -152,9 +149,9 @@ export async function getAmplitudeNominatorMetadata(chainInfo, address, substrat
|
|
|
152
149
|
const [identity] = await parseIdentity(substrateApi, delegatorState.owner);
|
|
153
150
|
activeStake = delegatorState.amount.toString();
|
|
154
151
|
const bnActiveStake = new BN(activeStake);
|
|
155
|
-
let delegationStatus =
|
|
152
|
+
let delegationStatus = StakingStatus.NOT_EARNING;
|
|
156
153
|
if (bnActiveStake.gt(BN_ZERO) && bnActiveStake.gte(new BN(minDelegatorStake))) {
|
|
157
|
-
delegationStatus =
|
|
154
|
+
delegationStatus = StakingStatus.EARNING_REWARD;
|
|
158
155
|
}
|
|
159
156
|
nominationList.push({
|
|
160
157
|
status: delegationStatus,
|
|
@@ -190,7 +187,7 @@ export async function getAmplitudeNominatorMetadata(chainInfo, address, substrat
|
|
|
190
187
|
if (nominationList.length === 0 && unstakingList.length === 0) {
|
|
191
188
|
return;
|
|
192
189
|
}
|
|
193
|
-
const stakingStatus =
|
|
190
|
+
const stakingStatus = getStakingStatusByNominations(new BN(activeStake), nominationList);
|
|
194
191
|
return {
|
|
195
192
|
chain,
|
|
196
193
|
type: StakingType.NOMINATED,
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { StakingType } from '@subwallet/extension-base/background/KoniTypes';
|
|
5
|
-
import {
|
|
4
|
+
import { StakingStatus, StakingType, UnstakingStatus } from '@subwallet/extension-base/background/KoniTypes';
|
|
5
|
+
import { getStakingStatusByNominations } from '@subwallet/extension-base/koni/api/staking/bonding/utils';
|
|
6
6
|
import { _STAKING_ERA_LENGTH_MAP } from '@subwallet/extension-base/services/chain-service/constants';
|
|
7
|
-
import { EarningStatus, UnstakingStatus } from '@subwallet/extension-base/types';
|
|
8
7
|
import { isUrl, parseRawNumber } from '@subwallet/extension-base/utils';
|
|
9
8
|
import fetch from 'cross-fetch';
|
|
10
9
|
import { BN, BN_ZERO } from '@polkadot/util';
|
|
@@ -100,7 +99,7 @@ export async function subscribeAstarNominatorMetadata(chainInfo, address, substr
|
|
|
100
99
|
const currentStake = stakeList.slice(-1)[0].staked.toString() || '0';
|
|
101
100
|
const bnCurrentStake = new BN(currentStake);
|
|
102
101
|
if (bnCurrentStake.gt(BN_ZERO)) {
|
|
103
|
-
const dappStakingStatus = bnCurrentStake.gt(BN_ZERO) && bnCurrentStake.gte(new BN(minDelegatorStake)) ?
|
|
102
|
+
const dappStakingStatus = bnCurrentStake.gt(BN_ZERO) && bnCurrentStake.gte(new BN(minDelegatorStake)) ? StakingStatus.EARNING_REWARD : StakingStatus.NOT_EARNING;
|
|
104
103
|
bnTotalActiveStake = bnTotalActiveStake.add(bnCurrentStake);
|
|
105
104
|
const dappInfo = dAppInfoMap[dappAddress];
|
|
106
105
|
nominationList.push({
|
|
@@ -135,13 +134,13 @@ export async function subscribeAstarNominatorMetadata(chainInfo, address, substr
|
|
|
135
134
|
chain: chainInfo.slug,
|
|
136
135
|
type: StakingType.NOMINATED,
|
|
137
136
|
address,
|
|
138
|
-
status:
|
|
137
|
+
status: StakingStatus.NOT_STAKING,
|
|
139
138
|
activeStake: '0',
|
|
140
139
|
nominations: [],
|
|
141
140
|
unstakings: []
|
|
142
141
|
};
|
|
143
142
|
}
|
|
144
|
-
const stakingStatus =
|
|
143
|
+
const stakingStatus = getStakingStatusByNominations(bnTotalActiveStake, nominationList);
|
|
145
144
|
return {
|
|
146
145
|
chain: chainInfo.slug,
|
|
147
146
|
type: StakingType.NOMINATED,
|
|
@@ -186,7 +185,7 @@ export async function getAstarNominatorMetadata(chainInfo, address, substrateApi
|
|
|
186
185
|
const currentStake = stakeList.slice(-1)[0].staked.toString() || '0';
|
|
187
186
|
const bnCurrentStake = new BN(currentStake);
|
|
188
187
|
if (bnCurrentStake.gt(BN_ZERO)) {
|
|
189
|
-
const dappStakingStatus = bnCurrentStake.gt(BN_ZERO) && bnCurrentStake.gte(new BN(minDelegatorStake)) ?
|
|
188
|
+
const dappStakingStatus = bnCurrentStake.gt(BN_ZERO) && bnCurrentStake.gte(new BN(minDelegatorStake)) ? StakingStatus.EARNING_REWARD : StakingStatus.NOT_EARNING;
|
|
190
189
|
bnTotalActiveStake = bnTotalActiveStake.add(bnCurrentStake);
|
|
191
190
|
const dappInfo = dAppInfoMap[dappAddress];
|
|
192
191
|
nominationList.push({
|
|
@@ -221,13 +220,13 @@ export async function getAstarNominatorMetadata(chainInfo, address, substrateApi
|
|
|
221
220
|
chain: chainInfo.slug,
|
|
222
221
|
type: StakingType.NOMINATED,
|
|
223
222
|
address,
|
|
224
|
-
status:
|
|
223
|
+
status: StakingStatus.NOT_STAKING,
|
|
225
224
|
activeStake: '0',
|
|
226
225
|
nominations: [],
|
|
227
226
|
unstakings: []
|
|
228
227
|
};
|
|
229
228
|
}
|
|
230
|
-
const stakingStatus =
|
|
229
|
+
const stakingStatus = getStakingStatusByNominations(bnTotalActiveStake, nominationList);
|
|
231
230
|
return {
|
|
232
231
|
chain,
|
|
233
232
|
type: StakingType.NOMINATED,
|
|
@@ -11,7 +11,7 @@ export declare function getChainStakingMetadata(chainInfo: _ChainInfo, substrate
|
|
|
11
11
|
* */
|
|
12
12
|
export declare function getNominatorMetadata(chainInfo: _ChainInfo, address: string, substrateApi: _SubstrateApi): Promise<NominatorMetadata | undefined>;
|
|
13
13
|
export declare function getValidatorsInfo(networkKey: string, substrateApi: _SubstrateApi, decimals: number, chainStakingMetadata: ChainStakingMetadata): Promise<ValidatorInfo[]>;
|
|
14
|
-
export declare function getNominationPoolsInfo(chain: string, substrateApi: _SubstrateApi): Promise<import("
|
|
14
|
+
export declare function getNominationPoolsInfo(chain: string, substrateApi: _SubstrateApi): Promise<import("@subwallet/extension-base/background/KoniTypes").NominationPoolInfo[]>;
|
|
15
15
|
export declare function getBondingExtrinsic(chainInfo: _ChainInfo, amount: string, selectedValidators: ValidatorInfo[], substrateApi: _SubstrateApi, address: string, nominatorMetadata?: NominatorMetadata): Promise<import("@polkadot/api-base/types").SubmittableExtrinsic<"promise", import("@polkadot/types/types").ISubmittableResult>>;
|
|
16
16
|
export declare function getUnbondingExtrinsic(nominatorMetadata: NominatorMetadata, amount: string, chain: string, substrateApi: _SubstrateApi, selectedValidator?: string): Promise<import("@polkadot/api-base/types").SubmittableExtrinsic<"promise", import("@polkadot/types/types").ISubmittableResult>>;
|
|
17
17
|
export declare function getWithdrawalExtrinsic(substrateApi: _SubstrateApi, chain: string, nominatorMetadata: NominatorMetadata, validatorAddress?: string): Promise<import("@polkadot/api-base/types").SubmittableExtrinsic<"promise", import("@polkadot/types/types").ISubmittableResult>>;
|
|
@@ -6,14 +6,10 @@ import { getAmplitudeBondingExtrinsic, getAmplitudeClaimRewardExtrinsic, getAmpl
|
|
|
6
6
|
import { getAstarBondingExtrinsic, getAstarClaimRewardExtrinsic, getAstarDappsInfo, getAstarNominatorMetadata, getAstarStakingMetadata, getAstarUnbondingExtrinsic, getAstarWithdrawalExtrinsic, subscribeAstarStakingMetadata } from '@subwallet/extension-base/koni/api/staking/bonding/astar';
|
|
7
7
|
import { getParaBondingExtrinsic, getParaCancelWithdrawalExtrinsic, getParachainCollatorsInfo, getParaChainNominatorMetadata, getParaChainStakingMetadata, getParaUnbondingExtrinsic, getParaWithdrawalExtrinsic, subscribeParaChainStakingMetadata, validateParaChainBondingCondition, validateParaChainUnbondingCondition } from '@subwallet/extension-base/koni/api/staking/bonding/paraChain';
|
|
8
8
|
import { getPoolingClaimRewardExtrinsic, getPoolingWithdrawalExtrinsic, getRelayBondingExtrinsic, getRelayCancelWithdrawalExtrinsic, getRelayChainNominatorMetadata, getRelayChainStakingMetadata, getRelayPoolsInfo, getRelayUnbondingExtrinsic, getRelayValidatorsInfo, getRelayWithdrawalExtrinsic, subscribeRelayChainStakingMetadata, validateRelayBondingCondition, validateRelayUnbondingCondition } from '@subwallet/extension-base/koni/api/staking/bonding/relayChain';
|
|
9
|
-
import { _STAKING_CHAIN_GROUP } from '@subwallet/extension-base/services/
|
|
10
|
-
|
|
9
|
+
import { _STAKING_CHAIN_GROUP } from '@subwallet/extension-base/services/chain-service/constants';
|
|
11
10
|
// all addresses must be converted to its chain format
|
|
12
11
|
|
|
13
12
|
export function validateUnbondingCondition(nominatorMetadata, amount, chain, chainStakingMetadata, selectedValidator) {
|
|
14
|
-
if (nominatorMetadata.type === StakingType.LIQUID_STAKING) {
|
|
15
|
-
return [];
|
|
16
|
-
}
|
|
17
13
|
if (_STAKING_CHAIN_GROUP.relay.includes(chain)) {
|
|
18
14
|
return validateRelayUnbondingCondition(amount, chainStakingMetadata, nominatorMetadata);
|
|
19
15
|
}
|
|
@@ -2,12 +2,10 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { TransactionError } from '@subwallet/extension-base/background/errors/TransactionError';
|
|
5
|
-
import { BasicTxErrorType, StakingTxErrorType, StakingType } from '@subwallet/extension-base/background/KoniTypes';
|
|
6
|
-
import { getBondedValidators,
|
|
5
|
+
import { BasicTxErrorType, StakingStatus, StakingTxErrorType, StakingType, UnstakingStatus } from '@subwallet/extension-base/background/KoniTypes';
|
|
6
|
+
import { getBondedValidators, getExistUnstakeErrorMessage, getMaxValidatorErrorMessage, getMinStakeErrorMessage, getParaCurrentInflation, getStakingStatusByNominations, isUnstakeAll, parseIdentity } from '@subwallet/extension-base/koni/api/staking/bonding/utils';
|
|
7
7
|
import { _STAKING_ERA_LENGTH_MAP } from '@subwallet/extension-base/services/chain-service/constants';
|
|
8
8
|
import { _isChainEvmCompatible } from '@subwallet/extension-base/services/chain-service/utils';
|
|
9
|
-
import { parseIdentity } from '@subwallet/extension-base/services/earning-service/utils';
|
|
10
|
-
import { EarningStatus, UnstakingStatus } from '@subwallet/extension-base/types';
|
|
11
9
|
import { isSameAddress, parseRawNumber, reformatAddress } from '@subwallet/extension-base/utils';
|
|
12
10
|
import { BN, BN_ZERO } from '@polkadot/util';
|
|
13
11
|
import { isEthereumAddress } from '@polkadot/util-crypto';
|
|
@@ -48,7 +46,7 @@ export function validateParaChainBondingCondition(chainInfo, amount, selectedCol
|
|
|
48
46
|
const minStakeErrorMessage = getMinStakeErrorMessage(chainInfo, bnMinStake);
|
|
49
47
|
const maxValidatorErrorMessage = getMaxValidatorErrorMessage(chainInfo, chainStakingMetadata.maxValidatorPerNominator);
|
|
50
48
|
const existUnstakeErrorMessage = getExistUnstakeErrorMessage(chainInfo.slug, nominatorMetadata === null || nominatorMetadata === void 0 ? void 0 : nominatorMetadata.type, true);
|
|
51
|
-
if (!nominatorMetadata || nominatorMetadata.status ===
|
|
49
|
+
if (!nominatorMetadata || nominatorMetadata.status === StakingStatus.NOT_STAKING) {
|
|
52
50
|
if (!bnTotalStake.gte(bnMinStake)) {
|
|
53
51
|
errors.push(new TransactionError(StakingTxErrorType.NOT_ENOUGH_MIN_STAKE, minStakeErrorMessage));
|
|
54
52
|
}
|
|
@@ -162,7 +160,7 @@ export async function subscribeParaChainNominatorMetadata(chainInfo, address, su
|
|
|
162
160
|
const minDelegation = collatorInfo === null || collatorInfo === void 0 ? void 0 : collatorInfo.lowestTopDelegationAmount.toString();
|
|
163
161
|
const delegationScheduledRequests = _delegationScheduledRequests.toPrimitive();
|
|
164
162
|
let hasUnstaking = false;
|
|
165
|
-
let delegationStatus =
|
|
163
|
+
let delegationStatus = StakingStatus.NOT_EARNING;
|
|
166
164
|
|
|
167
165
|
// parse unstaking info
|
|
168
166
|
if (delegationScheduledRequests) {
|
|
@@ -190,7 +188,7 @@ export async function subscribeParaChainNominatorMetadata(chainInfo, address, su
|
|
|
190
188
|
const bnUnstakeBalance = unstakingMap[delegation.owner] ? new BN(unstakingMap[delegation.owner].claimable) : BN_ZERO;
|
|
191
189
|
const bnActiveStake = bnStake.sub(bnUnstakeBalance);
|
|
192
190
|
if (bnActiveStake.gt(BN_ZERO) && bnActiveStake.gte(new BN(minDelegation))) {
|
|
193
|
-
delegationStatus =
|
|
191
|
+
delegationStatus = StakingStatus.EARNING_REWARD;
|
|
194
192
|
}
|
|
195
193
|
bnTotalActiveStake = bnTotalActiveStake.add(bnActiveStake);
|
|
196
194
|
nominationList.push({
|
|
@@ -211,7 +209,7 @@ export async function subscribeParaChainNominatorMetadata(chainInfo, address, su
|
|
|
211
209
|
// nomination.validatorMinStake = collatorInfo.lowestTopDelegationAmount.toString();
|
|
212
210
|
// }));
|
|
213
211
|
|
|
214
|
-
const stakingStatus =
|
|
212
|
+
const stakingStatus = getStakingStatusByNominations(bnTotalActiveStake, nominationList);
|
|
215
213
|
return {
|
|
216
214
|
chain: chainInfo.slug,
|
|
217
215
|
type: StakingType.NOMINATED,
|
|
@@ -241,7 +239,7 @@ export async function getParaChainNominatorMetadata(chainInfo, address, substrat
|
|
|
241
239
|
chain: chainInfo.slug,
|
|
242
240
|
type: StakingType.NOMINATED,
|
|
243
241
|
address,
|
|
244
|
-
status:
|
|
242
|
+
status: StakingStatus.NOT_STAKING,
|
|
245
243
|
activeStake: '0',
|
|
246
244
|
nominations: [],
|
|
247
245
|
unstakings: []
|
|
@@ -256,7 +254,7 @@ export async function getParaChainNominatorMetadata(chainInfo, address, substrat
|
|
|
256
254
|
const delegationScheduledRequests = _delegationScheduledRequests.toPrimitive();
|
|
257
255
|
const currentRound = roundInfo.current;
|
|
258
256
|
let hasUnstaking = false;
|
|
259
|
-
let delegationStatus =
|
|
257
|
+
let delegationStatus = StakingStatus.NOT_EARNING;
|
|
260
258
|
|
|
261
259
|
// parse unstaking info
|
|
262
260
|
if (delegationScheduledRequests) {
|
|
@@ -284,7 +282,7 @@ export async function getParaChainNominatorMetadata(chainInfo, address, substrat
|
|
|
284
282
|
const bnUnstakeBalance = unstakingMap[delegation.owner] ? new BN(unstakingMap[delegation.owner].claimable) : BN_ZERO;
|
|
285
283
|
const bnActiveStake = bnStake.sub(bnUnstakeBalance);
|
|
286
284
|
if (bnActiveStake.gt(BN_ZERO) && bnActiveStake.gte(new BN(minDelegation))) {
|
|
287
|
-
delegationStatus =
|
|
285
|
+
delegationStatus = StakingStatus.EARNING_REWARD;
|
|
288
286
|
}
|
|
289
287
|
bnTotalActiveStake = bnTotalActiveStake.add(bnActiveStake);
|
|
290
288
|
nominationList.push({
|
|
@@ -301,7 +299,7 @@ export async function getParaChainNominatorMetadata(chainInfo, address, substrat
|
|
|
301
299
|
const collatorInfo = _collatorInfo.toPrimitive();
|
|
302
300
|
nomination.validatorMinStake = collatorInfo.lowestTopDelegationAmount.toString();
|
|
303
301
|
}));
|
|
304
|
-
const stakingStatus =
|
|
302
|
+
const stakingStatus = getStakingStatusByNominations(bnTotalActiveStake, nominationList);
|
|
305
303
|
return {
|
|
306
304
|
chain,
|
|
307
305
|
type: StakingType.NOMINATED,
|