@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
|
@@ -33,12 +33,8 @@ exports.BIT_COUNTRY_IPFS_SERVER = BIT_COUNTRY_IPFS_SERVER;
|
|
|
33
33
|
const BIT_COUNTRY_LAND_ESTATE_METADATA_API = 'https://pioneer-api.bit.country/metadata/landTokenUriPioneer';
|
|
34
34
|
exports.BIT_COUNTRY_LAND_ESTATE_METADATA_API = BIT_COUNTRY_LAND_ESTATE_METADATA_API;
|
|
35
35
|
const BIT_COUNTRY_THUMBNAIL_RESOLVER = 'https://res.cloudinary.com/ddftctzph/image/upload/c_scale,q_100,w_250/production-ipfs/asset/';
|
|
36
|
-
|
|
37
|
-
// XOrigin
|
|
38
36
|
exports.BIT_COUNTRY_THUMBNAIL_RESOLVER = BIT_COUNTRY_THUMBNAIL_RESOLVER;
|
|
39
37
|
const CF_IPFS_GATEWAY = 'https://cf-ipfs.com/ipfs/';
|
|
40
|
-
|
|
41
|
-
// XOrigin
|
|
42
38
|
exports.CF_IPFS_GATEWAY = CF_IPFS_GATEWAY;
|
|
43
39
|
const PINATA_IPFS_GATEWAY = 'https://gateway.pinata.cloud/ipfs/';
|
|
44
40
|
exports.PINATA_IPFS_GATEWAY = PINATA_IPFS_GATEWAY;
|
|
@@ -51,22 +47,14 @@ const VARA_SCAN_ENDPOINT = 'https://nft-explorer.vara-network.io/graphql';
|
|
|
51
47
|
// GATEWAY
|
|
52
48
|
exports.VARA_SCAN_ENDPOINT = VARA_SCAN_ENDPOINT;
|
|
53
49
|
const UNIQUE_IPFS_GATEWAY = 'https://ipfs.unique.network/ipfs/';
|
|
54
|
-
|
|
55
|
-
// XOrigin
|
|
56
50
|
exports.UNIQUE_IPFS_GATEWAY = UNIQUE_IPFS_GATEWAY;
|
|
57
51
|
const NFT_STORAGE_GATEWAY = 'https://nftstorage.link/ipfs/';
|
|
58
52
|
exports.NFT_STORAGE_GATEWAY = NFT_STORAGE_GATEWAY;
|
|
59
53
|
const IPFS_W3S_LINK = 'https://w3s.link/ipfs/';
|
|
60
|
-
|
|
61
|
-
// XOrigin
|
|
62
54
|
exports.IPFS_W3S_LINK = IPFS_W3S_LINK;
|
|
63
55
|
const GATEWAY_IPFS_IO = 'https://gateway.ipfs.io/ipfs/';
|
|
64
|
-
|
|
65
|
-
// XOrigin
|
|
66
56
|
exports.GATEWAY_IPFS_IO = GATEWAY_IPFS_IO;
|
|
67
57
|
const IPFS_IO = 'https://ipfs.io/ipfs/';
|
|
68
|
-
|
|
69
|
-
// XOrigin
|
|
70
58
|
exports.IPFS_IO = IPFS_IO;
|
|
71
59
|
const DWEB_LINK = 'https://dweb.link/ipfs/';
|
|
72
60
|
exports.DWEB_LINK = DWEB_LINK;
|
|
@@ -134,8 +122,26 @@ exports.SUPPORTED_TRANSFER_SUBSTRATE_CHAIN_NAME = SUPPORTED_TRANSFER_SUBSTRATE_C
|
|
|
134
122
|
SUPPORTED_TRANSFER_SUBSTRATE_CHAIN_NAME["pioneer"] = "pioneer";
|
|
135
123
|
})(SUPPORTED_TRANSFER_SUBSTRATE_CHAIN_NAME || (exports.SUPPORTED_TRANSFER_SUBSTRATE_CHAIN_NAME = SUPPORTED_TRANSFER_SUBSTRATE_CHAIN_NAME = {}));
|
|
136
124
|
const RANDOM_IPFS_GATEWAY_SETTING = [{
|
|
125
|
+
provider: CF_IPFS_GATEWAY,
|
|
126
|
+
weight: 4
|
|
127
|
+
}, {
|
|
137
128
|
provider: CLOUDFLARE_PINATA_SERVER,
|
|
138
129
|
weight: 10
|
|
130
|
+
}, {
|
|
131
|
+
provider: PINATA_IPFS_GATEWAY,
|
|
132
|
+
weight: 1 // Rate limit too low
|
|
133
|
+
}, {
|
|
134
|
+
provider: DWEB_LINK,
|
|
135
|
+
weight: 5
|
|
136
|
+
}, {
|
|
137
|
+
provider: GATEWAY_IPFS_IO,
|
|
138
|
+
weight: 5
|
|
139
|
+
}, {
|
|
140
|
+
provider: IPFS_IO,
|
|
141
|
+
weight: 5
|
|
142
|
+
}, {
|
|
143
|
+
provider: NFT_STORAGE_GATEWAY,
|
|
144
|
+
weight: 50
|
|
139
145
|
}];
|
|
140
146
|
if (isFirefox) {
|
|
141
147
|
RANDOM_IPFS_GATEWAY_SETTING.push({
|
|
@@ -143,34 +149,18 @@ if (isFirefox) {
|
|
|
143
149
|
weight: 5000
|
|
144
150
|
});
|
|
145
151
|
}
|
|
146
|
-
if (!_utils.RuntimeInfo.protocol ||
|
|
152
|
+
if (!_utils.RuntimeInfo.protocol || _utils.RuntimeInfo.protocol && !_utils.RuntimeInfo.protocol.startsWith('http')) {
|
|
147
153
|
RANDOM_IPFS_GATEWAY_SETTING.push({
|
|
148
154
|
provider: IPFS_FLEEK,
|
|
149
155
|
weight: 4
|
|
150
|
-
}
|
|
156
|
+
});
|
|
157
|
+
RANDOM_IPFS_GATEWAY_SETTING.push({
|
|
151
158
|
provider: IPFS_GATEWAY_4EVERLAND,
|
|
152
159
|
weight: 2
|
|
153
|
-
}
|
|
160
|
+
});
|
|
161
|
+
RANDOM_IPFS_GATEWAY_SETTING.push({
|
|
154
162
|
provider: IPFS_W3S_LINK,
|
|
155
163
|
weight: 1
|
|
156
|
-
}, {
|
|
157
|
-
provider: CF_IPFS_GATEWAY,
|
|
158
|
-
weight: 4
|
|
159
|
-
}, {
|
|
160
|
-
provider: PINATA_IPFS_GATEWAY,
|
|
161
|
-
weight: 1 // Rate limit too low
|
|
162
|
-
}, {
|
|
163
|
-
provider: NFT_STORAGE_GATEWAY,
|
|
164
|
-
weight: 50
|
|
165
|
-
}, {
|
|
166
|
-
provider: GATEWAY_IPFS_IO,
|
|
167
|
-
weight: 5
|
|
168
|
-
}, {
|
|
169
|
-
provider: DWEB_LINK,
|
|
170
|
-
weight: 5
|
|
171
|
-
}, {
|
|
172
|
-
provider: IPFS_IO,
|
|
173
|
-
weight: 5
|
|
174
164
|
});
|
|
175
165
|
}
|
|
176
166
|
const RANDOM_IPFS_GATEWAY_TOTAL_WEIGHT = RANDOM_IPFS_GATEWAY_SETTING.reduce((value, item) => value + item.weight, 0);
|
|
@@ -9,7 +9,6 @@ var _acala_nft = require("@subwallet/extension-base/koni/api/nft/acala_nft");
|
|
|
9
9
|
var _bit = require("@subwallet/extension-base/koni/api/nft/bit.country");
|
|
10
10
|
var _evm_nft = require("@subwallet/extension-base/koni/api/nft/evm_nft");
|
|
11
11
|
var _karura_nft = require("@subwallet/extension-base/koni/api/nft/karura_nft");
|
|
12
|
-
var _ordinal_nft = _interopRequireDefault(require("@subwallet/extension-base/koni/api/nft/ordinal_nft"));
|
|
13
12
|
var _rmrk_nft = require("@subwallet/extension-base/koni/api/nft/rmrk_nft");
|
|
14
13
|
var _statemine_nft = _interopRequireDefault(require("@subwallet/extension-base/koni/api/nft/statemine_nft"));
|
|
15
14
|
var _unique_nft = _interopRequireDefault(require("@subwallet/extension-base/koni/api/nft/unique_nft"));
|
|
@@ -51,9 +50,6 @@ function createWeb3NftApi(chain, evmApi, addresses) {
|
|
|
51
50
|
const [, evmAddresses] = (0, _utils2.categoryAddresses)(addresses);
|
|
52
51
|
return new _evm_nft.EvmNftApi(evmApi, evmAddresses, chain);
|
|
53
52
|
}
|
|
54
|
-
const createOrdinalApi = (chain, subscanChain, addresses) => {
|
|
55
|
-
return new _ordinal_nft.default(addresses, chain, subscanChain);
|
|
56
|
-
};
|
|
57
53
|
class NftHandler {
|
|
58
54
|
// General settings
|
|
59
55
|
chainInfoMap = {};
|
|
@@ -134,16 +130,6 @@ class NftHandler {
|
|
|
134
130
|
}
|
|
135
131
|
}
|
|
136
132
|
}
|
|
137
|
-
if ((0, _utils._isSupportOrdinal)(chain)) {
|
|
138
|
-
var _chainInfo$extraInfo;
|
|
139
|
-
const subscanChain = (_chainInfo$extraInfo = chainInfo.extraInfo) === null || _chainInfo$extraInfo === void 0 ? void 0 : _chainInfo$extraInfo.subscanSlug;
|
|
140
|
-
if (subscanChain) {
|
|
141
|
-
const handler = createOrdinalApi(chain, subscanChain, substrateAddresses);
|
|
142
|
-
if (handler && !this.handlers.includes(handler)) {
|
|
143
|
-
this.handlers.push(handler);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
133
|
});
|
|
148
134
|
this.needSetupApi = false;
|
|
149
135
|
}
|
package/cjs/koni/api/nft/nft.js
CHANGED
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.BaseNftApi = void 0;
|
|
7
|
+
var _config = require("@subwallet/extension-base/koni/api/nft/config");
|
|
7
8
|
var _utils = require("@subwallet/extension-base/utils");
|
|
8
9
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
9
10
|
// SPDX-License-Identifier: Apache-2.0
|
|
@@ -70,7 +71,27 @@ class BaseNftApi {
|
|
|
70
71
|
return tokenId;
|
|
71
72
|
}
|
|
72
73
|
parseUrl(input) {
|
|
73
|
-
|
|
74
|
+
if (!input || input.length === 0) {
|
|
75
|
+
return undefined;
|
|
76
|
+
}
|
|
77
|
+
if ((0, _utils.isUrl)(input)) {
|
|
78
|
+
return input;
|
|
79
|
+
}
|
|
80
|
+
if ((0, _utils.isUrl)(input) || input.includes('https://') || input.includes('http')) {
|
|
81
|
+
return input;
|
|
82
|
+
}
|
|
83
|
+
if (input.startsWith('/ipfs/')) {
|
|
84
|
+
return (0, _config.getRandomIpfsGateway)() + input.split('/ipfs/')[1];
|
|
85
|
+
}
|
|
86
|
+
if (!input.includes('ipfs://') && !input.includes('ipfs://ipfs/')) {
|
|
87
|
+
// just the IPFS hash
|
|
88
|
+
return (0, _config.getRandomIpfsGateway)() + input;
|
|
89
|
+
}
|
|
90
|
+
if (input.includes('ipfs://') && !input.includes('ipfs://ipfs/')) {
|
|
91
|
+
// starts with ipfs://
|
|
92
|
+
return (0, _config.getRandomIpfsGateway)() + input.split('ipfs://')[1];
|
|
93
|
+
}
|
|
94
|
+
return (0, _config.getRandomIpfsGateway)() + input.split('ipfs://ipfs/')[1]; // starts with ipfs://ipfs/
|
|
74
95
|
}
|
|
75
96
|
|
|
76
97
|
// Subclass implements this function to parse data into prop result
|
|
@@ -15,9 +15,7 @@ exports.subscribeAmplitudeStakingMetadata = subscribeAmplitudeStakingMetadata;
|
|
|
15
15
|
var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
16
16
|
var _utils = require("@subwallet/extension-base/koni/api/staking/bonding/utils");
|
|
17
17
|
var _constants = require("@subwallet/extension-base/services/chain-service/constants");
|
|
18
|
-
var _utils2 = require("@subwallet/extension-base/
|
|
19
|
-
var _types = require("@subwallet/extension-base/types");
|
|
20
|
-
var _utils3 = require("@subwallet/extension-base/utils");
|
|
18
|
+
var _utils2 = require("@subwallet/extension-base/utils");
|
|
21
19
|
var _util = require("@polkadot/util");
|
|
22
20
|
var _utilCrypto = require("@polkadot/util-crypto");
|
|
23
21
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
@@ -26,7 +24,7 @@ var _utilCrypto = require("@polkadot/util-crypto");
|
|
|
26
24
|
function subscribeAmplitudeStakingMetadata(chain, substrateApi, callback) {
|
|
27
25
|
return substrateApi.api.query.parachainStaking.round(_round => {
|
|
28
26
|
const roundObj = _round.toHuman();
|
|
29
|
-
const round = (0,
|
|
27
|
+
const round = (0, _utils2.parseRawNumber)(roundObj.current);
|
|
30
28
|
const maxDelegations = substrateApi.api.consts.parachainStaking.maxDelegationsPerRound.toString();
|
|
31
29
|
const minDelegatorStake = substrateApi.api.consts.parachainStaking.minDelegatorStake.toString();
|
|
32
30
|
const unstakingDelay = substrateApi.api.consts.parachainStaking.stakeDuration.toString();
|
|
@@ -50,7 +48,7 @@ function subscribeAmplitudeStakingMetadata(chain, substrateApi, callback) {
|
|
|
50
48
|
async function getAmplitudeStakingMetadata(chain, substrateApi) {
|
|
51
49
|
const chainApi = await substrateApi.isReady;
|
|
52
50
|
const _round = (await chainApi.api.query.parachainStaking.round()).toHuman();
|
|
53
|
-
const round = (0,
|
|
51
|
+
const round = (0, _utils2.parseRawNumber)(_round.current);
|
|
54
52
|
const maxDelegations = chainApi.api.consts.parachainStaking.maxDelegationsPerRound.toString();
|
|
55
53
|
const minDelegatorStake = chainApi.api.consts.parachainStaking.minDelegatorStake.toString();
|
|
56
54
|
const unstakingDelay = chainApi.api.consts.parachainStaking.stakeDuration.toString();
|
|
@@ -77,12 +75,12 @@ async function subscribeAmplitudeNominatorMetadata(chainInfo, address, substrate
|
|
|
77
75
|
let activeStake = '0';
|
|
78
76
|
if (delegatorState) {
|
|
79
77
|
// delegatorState can be null while unstaking all
|
|
80
|
-
const [identity] = await (0,
|
|
78
|
+
const [identity] = await (0, _utils.parseIdentity)(substrateApi, delegatorState.owner);
|
|
81
79
|
activeStake = delegatorState.amount.toString();
|
|
82
80
|
const bnActiveStake = new _util.BN(activeStake);
|
|
83
|
-
let delegationStatus =
|
|
81
|
+
let delegationStatus = _KoniTypes.StakingStatus.NOT_EARNING;
|
|
84
82
|
if (bnActiveStake.gt(_util.BN_ZERO) && bnActiveStake.gte(new _util.BN(minDelegatorStake))) {
|
|
85
|
-
delegationStatus =
|
|
83
|
+
delegationStatus = _KoniTypes.StakingStatus.EARNING_REWARD;
|
|
86
84
|
}
|
|
87
85
|
nominationList.push({
|
|
88
86
|
status: delegationStatus,
|
|
@@ -109,13 +107,13 @@ async function subscribeAmplitudeNominatorMetadata(chainInfo, address, substrate
|
|
|
109
107
|
const waitingTime = remainingBlock * blockDuration;
|
|
110
108
|
unstakingList.push({
|
|
111
109
|
chain: chainInfo.slug,
|
|
112
|
-
status: isClaimable ?
|
|
110
|
+
status: isClaimable ? _KoniTypes.UnstakingStatus.CLAIMABLE : _KoniTypes.UnstakingStatus.UNLOCKING,
|
|
113
111
|
claimable: nearestUnstakingAmount.toString(),
|
|
114
112
|
waitingTime,
|
|
115
113
|
validatorAddress: (delegatorState === null || delegatorState === void 0 ? void 0 : delegatorState.owner) || undefined
|
|
116
114
|
});
|
|
117
115
|
}
|
|
118
|
-
const stakingStatus = (0, _utils.
|
|
116
|
+
const stakingStatus = (0, _utils.getStakingStatusByNominations)(new _util.BN(activeStake), nominationList);
|
|
119
117
|
return {
|
|
120
118
|
chain: chainInfo.slug,
|
|
121
119
|
type: _KoniTypes.StakingType.NOMINATED,
|
|
@@ -147,7 +145,7 @@ async function getAmplitudeNominatorMetadata(chainInfo, address, substrateApi) {
|
|
|
147
145
|
chain: chainInfo.slug,
|
|
148
146
|
type: _KoniTypes.StakingType.NOMINATED,
|
|
149
147
|
address,
|
|
150
|
-
status:
|
|
148
|
+
status: _KoniTypes.StakingStatus.NOT_STAKING,
|
|
151
149
|
activeStake: '0',
|
|
152
150
|
nominations: [],
|
|
153
151
|
unstakings: []
|
|
@@ -156,12 +154,12 @@ async function getAmplitudeNominatorMetadata(chainInfo, address, substrateApi) {
|
|
|
156
154
|
let activeStake = '0';
|
|
157
155
|
if (delegatorState) {
|
|
158
156
|
// delegatorState can be null while unstaking all
|
|
159
|
-
const [identity] = await (0,
|
|
157
|
+
const [identity] = await (0, _utils.parseIdentity)(substrateApi, delegatorState.owner);
|
|
160
158
|
activeStake = delegatorState.amount.toString();
|
|
161
159
|
const bnActiveStake = new _util.BN(activeStake);
|
|
162
|
-
let delegationStatus =
|
|
160
|
+
let delegationStatus = _KoniTypes.StakingStatus.NOT_EARNING;
|
|
163
161
|
if (bnActiveStake.gt(_util.BN_ZERO) && bnActiveStake.gte(new _util.BN(minDelegatorStake))) {
|
|
164
|
-
delegationStatus =
|
|
162
|
+
delegationStatus = _KoniTypes.StakingStatus.EARNING_REWARD;
|
|
165
163
|
}
|
|
166
164
|
nominationList.push({
|
|
167
165
|
status: delegationStatus,
|
|
@@ -188,7 +186,7 @@ async function getAmplitudeNominatorMetadata(chainInfo, address, substrateApi) {
|
|
|
188
186
|
const waitingTime = remainingBlock * blockDuration;
|
|
189
187
|
unstakingList.push({
|
|
190
188
|
chain,
|
|
191
|
-
status: isClaimable ?
|
|
189
|
+
status: isClaimable ? _KoniTypes.UnstakingStatus.CLAIMABLE : _KoniTypes.UnstakingStatus.UNLOCKING,
|
|
192
190
|
claimable: nearestUnstakingAmount.toString(),
|
|
193
191
|
waitingTime,
|
|
194
192
|
validatorAddress: (delegatorState === null || delegatorState === void 0 ? void 0 : delegatorState.owner) || undefined
|
|
@@ -197,7 +195,7 @@ async function getAmplitudeNominatorMetadata(chainInfo, address, substrateApi) {
|
|
|
197
195
|
if (nominationList.length === 0 && unstakingList.length === 0) {
|
|
198
196
|
return;
|
|
199
197
|
}
|
|
200
|
-
const stakingStatus = (0, _utils.
|
|
198
|
+
const stakingStatus = (0, _utils.getStakingStatusByNominations)(new _util.BN(activeStake), nominationList);
|
|
201
199
|
return {
|
|
202
200
|
chain,
|
|
203
201
|
type: _KoniTypes.StakingType.NOMINATED,
|
|
@@ -247,7 +245,7 @@ async function getAmplitudeBondingExtrinsic(substrateApi, amount, selectedValida
|
|
|
247
245
|
const {
|
|
248
246
|
bondedValidators
|
|
249
247
|
} = (0, _utils.getBondedValidators)(nominatorMetadata.nominations);
|
|
250
|
-
if (!bondedValidators.includes((0,
|
|
248
|
+
if (!bondedValidators.includes((0, _utils2.reformatAddress)(selectedValidatorInfo.address, 0))) {
|
|
251
249
|
return chainApi.api.tx.parachainStaking.joinDelegators(selectedValidatorInfo.address, binaryAmount);
|
|
252
250
|
} else {
|
|
253
251
|
const _params = chainApi.api.tx.parachainStaking.delegatorStakeMore.toJSON();
|
|
@@ -17,7 +17,6 @@ exports.subscribeAstarStakingMetadata = subscribeAstarStakingMetadata;
|
|
|
17
17
|
var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
18
18
|
var _utils = require("@subwallet/extension-base/koni/api/staking/bonding/utils");
|
|
19
19
|
var _constants = require("@subwallet/extension-base/services/chain-service/constants");
|
|
20
|
-
var _types = require("@subwallet/extension-base/types");
|
|
21
20
|
var _utils2 = require("@subwallet/extension-base/utils");
|
|
22
21
|
var _crossFetch = _interopRequireDefault(require("cross-fetch"));
|
|
23
22
|
var _util = require("@polkadot/util");
|
|
@@ -116,7 +115,7 @@ async function subscribeAstarNominatorMetadata(chainInfo, address, substrateApi,
|
|
|
116
115
|
const currentStake = stakeList.slice(-1)[0].staked.toString() || '0';
|
|
117
116
|
const bnCurrentStake = new _util.BN(currentStake);
|
|
118
117
|
if (bnCurrentStake.gt(_util.BN_ZERO)) {
|
|
119
|
-
const dappStakingStatus = bnCurrentStake.gt(_util.BN_ZERO) && bnCurrentStake.gte(new _util.BN(minDelegatorStake)) ?
|
|
118
|
+
const dappStakingStatus = bnCurrentStake.gt(_util.BN_ZERO) && bnCurrentStake.gte(new _util.BN(minDelegatorStake)) ? _KoniTypes.StakingStatus.EARNING_REWARD : _KoniTypes.StakingStatus.NOT_EARNING;
|
|
120
119
|
bnTotalActiveStake = bnTotalActiveStake.add(bnCurrentStake);
|
|
121
120
|
const dappInfo = dAppInfoMap[dappAddress];
|
|
122
121
|
nominationList.push({
|
|
@@ -140,7 +139,7 @@ async function subscribeAstarNominatorMetadata(chainInfo, address, substrateApi,
|
|
|
140
139
|
const waitingTime = remainingEra * _constants._STAKING_ERA_LENGTH_MAP[chainInfo.slug];
|
|
141
140
|
unstakingList.push({
|
|
142
141
|
chain: chainInfo.slug,
|
|
143
|
-
status: isClaimable ?
|
|
142
|
+
status: isClaimable ? _KoniTypes.UnstakingStatus.CLAIMABLE : _KoniTypes.UnstakingStatus.UNLOCKING,
|
|
144
143
|
claimable: unlockingChunk.amount.toString(),
|
|
145
144
|
waitingTime
|
|
146
145
|
});
|
|
@@ -151,13 +150,13 @@ async function subscribeAstarNominatorMetadata(chainInfo, address, substrateApi,
|
|
|
151
150
|
chain: chainInfo.slug,
|
|
152
151
|
type: _KoniTypes.StakingType.NOMINATED,
|
|
153
152
|
address,
|
|
154
|
-
status:
|
|
153
|
+
status: _KoniTypes.StakingStatus.NOT_STAKING,
|
|
155
154
|
activeStake: '0',
|
|
156
155
|
nominations: [],
|
|
157
156
|
unstakings: []
|
|
158
157
|
};
|
|
159
158
|
}
|
|
160
|
-
const stakingStatus = (0, _utils.
|
|
159
|
+
const stakingStatus = (0, _utils.getStakingStatusByNominations)(bnTotalActiveStake, nominationList);
|
|
161
160
|
return {
|
|
162
161
|
chain: chainInfo.slug,
|
|
163
162
|
type: _KoniTypes.StakingType.NOMINATED,
|
|
@@ -202,7 +201,7 @@ async function getAstarNominatorMetadata(chainInfo, address, substrateApi) {
|
|
|
202
201
|
const currentStake = stakeList.slice(-1)[0].staked.toString() || '0';
|
|
203
202
|
const bnCurrentStake = new _util.BN(currentStake);
|
|
204
203
|
if (bnCurrentStake.gt(_util.BN_ZERO)) {
|
|
205
|
-
const dappStakingStatus = bnCurrentStake.gt(_util.BN_ZERO) && bnCurrentStake.gte(new _util.BN(minDelegatorStake)) ?
|
|
204
|
+
const dappStakingStatus = bnCurrentStake.gt(_util.BN_ZERO) && bnCurrentStake.gte(new _util.BN(minDelegatorStake)) ? _KoniTypes.StakingStatus.EARNING_REWARD : _KoniTypes.StakingStatus.NOT_EARNING;
|
|
206
205
|
bnTotalActiveStake = bnTotalActiveStake.add(bnCurrentStake);
|
|
207
206
|
const dappInfo = dAppInfoMap[dappAddress];
|
|
208
207
|
nominationList.push({
|
|
@@ -226,7 +225,7 @@ async function getAstarNominatorMetadata(chainInfo, address, substrateApi) {
|
|
|
226
225
|
const waitingTime = remainingEra * _constants._STAKING_ERA_LENGTH_MAP[chain];
|
|
227
226
|
unstakingList.push({
|
|
228
227
|
chain,
|
|
229
|
-
status: isClaimable ?
|
|
228
|
+
status: isClaimable ? _KoniTypes.UnstakingStatus.CLAIMABLE : _KoniTypes.UnstakingStatus.UNLOCKING,
|
|
230
229
|
claimable: unlockingChunk.amount.toString(),
|
|
231
230
|
waitingTime
|
|
232
231
|
});
|
|
@@ -237,13 +236,13 @@ async function getAstarNominatorMetadata(chainInfo, address, substrateApi) {
|
|
|
237
236
|
chain: chainInfo.slug,
|
|
238
237
|
type: _KoniTypes.StakingType.NOMINATED,
|
|
239
238
|
address,
|
|
240
|
-
status:
|
|
239
|
+
status: _KoniTypes.StakingStatus.NOT_STAKING,
|
|
241
240
|
activeStake: '0',
|
|
242
241
|
nominations: [],
|
|
243
242
|
unstakings: []
|
|
244
243
|
};
|
|
245
244
|
}
|
|
246
|
-
const stakingStatus = (0, _utils.
|
|
245
|
+
const stakingStatus = (0, _utils.getStakingStatusByNominations)(bnTotalActiveStake, nominationList);
|
|
247
246
|
return {
|
|
248
247
|
chain,
|
|
249
248
|
type: _KoniTypes.StakingType.NOMINATED,
|
|
@@ -370,13 +369,13 @@ async function getAstarClaimRewardExtrinsic(substrateApi, address) {
|
|
|
370
369
|
function getAstarWithdrawable(nominatorMetadata) {
|
|
371
370
|
const unstakingInfo = {
|
|
372
371
|
chain: nominatorMetadata.chain,
|
|
373
|
-
status:
|
|
372
|
+
status: _KoniTypes.UnstakingStatus.CLAIMABLE,
|
|
374
373
|
claimable: '0',
|
|
375
374
|
waitingTime: 0
|
|
376
375
|
};
|
|
377
376
|
let bnWithdrawable = _util.BN_ZERO;
|
|
378
377
|
for (const unstaking of nominatorMetadata.unstakings) {
|
|
379
|
-
if (unstaking.status ===
|
|
378
|
+
if (unstaking.status === _KoniTypes.UnstakingStatus.CLAIMABLE) {
|
|
380
379
|
bnWithdrawable = bnWithdrawable.add(new _util.BN(unstaking.claimable));
|
|
381
380
|
}
|
|
382
381
|
}
|
|
@@ -20,16 +20,13 @@ var _amplitude = require("@subwallet/extension-base/koni/api/staking/bonding/amp
|
|
|
20
20
|
var _astar = require("@subwallet/extension-base/koni/api/staking/bonding/astar");
|
|
21
21
|
var _paraChain = require("@subwallet/extension-base/koni/api/staking/bonding/paraChain");
|
|
22
22
|
var _relayChain = require("@subwallet/extension-base/koni/api/staking/bonding/relayChain");
|
|
23
|
-
var _constants = require("@subwallet/extension-base/services/
|
|
23
|
+
var _constants = require("@subwallet/extension-base/services/chain-service/constants");
|
|
24
24
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
25
25
|
// SPDX-License-Identifier: Apache-2.0
|
|
26
26
|
|
|
27
27
|
// all addresses must be converted to its chain format
|
|
28
28
|
|
|
29
29
|
function validateUnbondingCondition(nominatorMetadata, amount, chain, chainStakingMetadata, selectedValidator) {
|
|
30
|
-
if (nominatorMetadata.type === _KoniTypes.StakingType.LIQUID_STAKING) {
|
|
31
|
-
return [];
|
|
32
|
-
}
|
|
33
30
|
if (_constants._STAKING_CHAIN_GROUP.relay.includes(chain)) {
|
|
34
31
|
return (0, _relayChain.validateRelayUnbondingCondition)(amount, chainStakingMetadata, nominatorMetadata);
|
|
35
32
|
}
|
|
@@ -41,6 +38,8 @@ function validateBondingCondition(chainInfo, amount, selectedValidators, address
|
|
|
41
38
|
}
|
|
42
39
|
return (0, _paraChain.validateParaChainBondingCondition)(chainInfo, amount, selectedValidators, address, chainStakingMetadata, nominatorMetadata);
|
|
43
40
|
}
|
|
41
|
+
|
|
42
|
+
/** Deprecated */
|
|
44
43
|
async function getChainStakingMetadata(chainInfo, substrateApi) {
|
|
45
44
|
if (_constants._STAKING_CHAIN_GROUP.astar.includes(chainInfo.slug)) {
|
|
46
45
|
return (0, _astar.getAstarStakingMetadata)(chainInfo.slug, substrateApi);
|
|
@@ -21,9 +21,7 @@ var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
|
21
21
|
var _utils = require("@subwallet/extension-base/koni/api/staking/bonding/utils");
|
|
22
22
|
var _constants = require("@subwallet/extension-base/services/chain-service/constants");
|
|
23
23
|
var _utils2 = require("@subwallet/extension-base/services/chain-service/utils");
|
|
24
|
-
var _utils3 = require("@subwallet/extension-base/
|
|
25
|
-
var _types = require("@subwallet/extension-base/types");
|
|
26
|
-
var _utils4 = require("@subwallet/extension-base/utils");
|
|
24
|
+
var _utils3 = require("@subwallet/extension-base/utils");
|
|
27
25
|
var _util = require("@polkadot/util");
|
|
28
26
|
var _utilCrypto = require("@polkadot/util-crypto");
|
|
29
27
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
@@ -33,7 +31,7 @@ function validateParaChainUnbondingCondition(amount, nominatorMetadata, chainSta
|
|
|
33
31
|
const errors = [];
|
|
34
32
|
let targetNomination;
|
|
35
33
|
for (const nomination of nominatorMetadata.nominations) {
|
|
36
|
-
if ((0,
|
|
34
|
+
if ((0, _utils3.isSameAddress)(nomination.validatorAddress, selectedCollator)) {
|
|
37
35
|
targetNomination = nomination;
|
|
38
36
|
break;
|
|
39
37
|
}
|
|
@@ -66,7 +64,7 @@ function validateParaChainBondingCondition(chainInfo, amount, selectedCollators,
|
|
|
66
64
|
const minStakeErrorMessage = (0, _utils.getMinStakeErrorMessage)(chainInfo, bnMinStake);
|
|
67
65
|
const maxValidatorErrorMessage = (0, _utils.getMaxValidatorErrorMessage)(chainInfo, chainStakingMetadata.maxValidatorPerNominator);
|
|
68
66
|
const existUnstakeErrorMessage = (0, _utils.getExistUnstakeErrorMessage)(chainInfo.slug, nominatorMetadata === null || nominatorMetadata === void 0 ? void 0 : nominatorMetadata.type, true);
|
|
69
|
-
if (!nominatorMetadata || nominatorMetadata.status ===
|
|
67
|
+
if (!nominatorMetadata || nominatorMetadata.status === _KoniTypes.StakingStatus.NOT_STAKING) {
|
|
70
68
|
if (!bnTotalStake.gte(bnMinStake)) {
|
|
71
69
|
errors.push(new _TransactionError.TransactionError(_KoniTypes.StakingTxErrorType.NOT_ENOUGH_MIN_STAKE, minStakeErrorMessage));
|
|
72
70
|
}
|
|
@@ -75,7 +73,7 @@ function validateParaChainBondingCondition(chainInfo, amount, selectedCollators,
|
|
|
75
73
|
const {
|
|
76
74
|
bondedValidators
|
|
77
75
|
} = (0, _utils.getBondedValidators)(nominatorMetadata.nominations);
|
|
78
|
-
const parsedSelectedCollatorAddress = (0,
|
|
76
|
+
const parsedSelectedCollatorAddress = (0, _utils3.reformatAddress)(selectedCollator.address, 0);
|
|
79
77
|
if (!bondedValidators.includes(parsedSelectedCollatorAddress)) {
|
|
80
78
|
// new delegation
|
|
81
79
|
if (!bnTotalStake.gte(bnMinStake)) {
|
|
@@ -89,7 +87,7 @@ function validateParaChainBondingCondition(chainInfo, amount, selectedCollators,
|
|
|
89
87
|
let currentDelegationAmount = '0';
|
|
90
88
|
let hasUnstaking = false;
|
|
91
89
|
for (const delegation of nominatorMetadata.nominations) {
|
|
92
|
-
if ((0,
|
|
90
|
+
if ((0, _utils3.reformatAddress)(delegation.validatorAddress, 0) === parsedSelectedCollatorAddress) {
|
|
93
91
|
currentDelegationAmount = delegation.activeStake;
|
|
94
92
|
hasUnstaking = !!delegation.hasUnstaking && delegation.hasUnstaking;
|
|
95
93
|
break;
|
|
@@ -107,17 +105,18 @@ function validateParaChainBondingCondition(chainInfo, amount, selectedCollators,
|
|
|
107
105
|
}
|
|
108
106
|
function subscribeParaChainStakingMetadata(chain, substrateApi, callback) {
|
|
109
107
|
return substrateApi.api.query.parachainStaking.round(_round => {
|
|
110
|
-
var _substrateApi$api$con, _substrateApi$api$con2, _substrateApi$api$con3;
|
|
108
|
+
var _substrateApi$api$con, _substrateApi$api$con2, _substrateApi$api$con3, _substrateApi$api$con4, _substrateApi$api$con5, _substrateApi$api$con6;
|
|
111
109
|
const roundObj = _round.toHuman();
|
|
112
|
-
const round = (0,
|
|
110
|
+
const round = (0, _utils3.parseRawNumber)(roundObj.current);
|
|
113
111
|
const maxDelegations = (_substrateApi$api$con = substrateApi.api.consts) === null || _substrateApi$api$con === void 0 ? void 0 : (_substrateApi$api$con2 = _substrateApi$api$con.parachainStaking) === null || _substrateApi$api$con2 === void 0 ? void 0 : (_substrateApi$api$con3 = _substrateApi$api$con2.maxDelegationsPerDelegator) === null || _substrateApi$api$con3 === void 0 ? void 0 : _substrateApi$api$con3.toString();
|
|
114
112
|
const unstakingDelay = substrateApi.api.consts.parachainStaking.delegationBondLessDelay.toString();
|
|
115
113
|
const unstakingPeriod = parseInt(unstakingDelay) * (_constants._STAKING_ERA_LENGTH_MAP[chain] || _constants._STAKING_ERA_LENGTH_MAP.default);
|
|
114
|
+
const minDelegatorStake = (_substrateApi$api$con4 = substrateApi.api.consts) === null || _substrateApi$api$con4 === void 0 ? void 0 : (_substrateApi$api$con5 = _substrateApi$api$con4.parachainStaking) === null || _substrateApi$api$con5 === void 0 ? void 0 : (_substrateApi$api$con6 = _substrateApi$api$con5.minDelegatorStk) === null || _substrateApi$api$con6 === void 0 ? void 0 : _substrateApi$api$con6.toString();
|
|
116
115
|
callback(chain, {
|
|
117
116
|
chain,
|
|
118
117
|
type: _KoniTypes.StakingType.NOMINATED,
|
|
119
118
|
era: round,
|
|
120
|
-
minStake: '0',
|
|
119
|
+
minStake: minDelegatorStake || '0',
|
|
121
120
|
maxValidatorPerNominator: parseInt(maxDelegations),
|
|
122
121
|
maxWithdrawalRequestPerValidator: 1,
|
|
123
122
|
// by default
|
|
@@ -127,11 +126,13 @@ function subscribeParaChainStakingMetadata(chain, substrateApi, callback) {
|
|
|
127
126
|
});
|
|
128
127
|
}
|
|
129
128
|
async function getParaChainStakingMetadata(chain, substrateApi) {
|
|
129
|
+
var _chainApi$api$consts$, _chainApi$api$consts$2;
|
|
130
130
|
const chainApi = await substrateApi.isReady;
|
|
131
131
|
const _round = (await chainApi.api.query.parachainStaking.round()).toHuman();
|
|
132
|
-
const round = (0,
|
|
132
|
+
const round = (0, _utils3.parseRawNumber)(_round.current);
|
|
133
133
|
const maxDelegations = chainApi.api.consts.parachainStaking.maxDelegationsPerDelegator.toString();
|
|
134
134
|
const unstakingDelay = chainApi.api.consts.parachainStaking.delegationBondLessDelay.toString();
|
|
135
|
+
const minDelegatorStake = (_chainApi$api$consts$ = chainApi.api.consts.parachainStaking) === null || _chainApi$api$consts$ === void 0 ? void 0 : (_chainApi$api$consts$2 = _chainApi$api$consts$.minDelegatorStk) === null || _chainApi$api$consts$2 === void 0 ? void 0 : _chainApi$api$consts$2.toString();
|
|
135
136
|
let _unvestedAllocation;
|
|
136
137
|
if (chainApi.api.query.vesting && chainApi.api.query.vesting.totalUnvestedAllocation) {
|
|
137
138
|
_unvestedAllocation = await chainApi.api.query.vesting.totalUnvestedAllocation();
|
|
@@ -149,14 +150,14 @@ async function getParaChainStakingMetadata(chain, substrateApi) {
|
|
|
149
150
|
}
|
|
150
151
|
|
|
151
152
|
const inflationConfig = _inflation.toHuman();
|
|
152
|
-
const inflation = (0, _utils.getParaCurrentInflation)((0,
|
|
153
|
+
const inflation = (0, _utils.getParaCurrentInflation)((0, _utils3.parseRawNumber)(totalStake.toString()), inflationConfig);
|
|
153
154
|
const unstakingPeriod = parseInt(unstakingDelay) * _constants._STAKING_ERA_LENGTH_MAP[chain];
|
|
154
155
|
return {
|
|
155
156
|
chain,
|
|
156
157
|
type: _KoniTypes.StakingType.NOMINATED,
|
|
157
158
|
era: round,
|
|
158
159
|
inflation,
|
|
159
|
-
minStake: '0',
|
|
160
|
+
minStake: minDelegatorStake || '0',
|
|
160
161
|
maxValidatorPerNominator: parseInt(maxDelegations),
|
|
161
162
|
maxWithdrawalRequestPerValidator: 1,
|
|
162
163
|
// by default
|
|
@@ -172,17 +173,17 @@ async function subscribeParaChainNominatorMetadata(chainInfo, address, substrate
|
|
|
172
173
|
const roundInfo = _roundInfo.toPrimitive();
|
|
173
174
|
const currentRound = roundInfo.current;
|
|
174
175
|
await Promise.all(delegatorState.delegations.map(async delegation => {
|
|
175
|
-
const [_delegationScheduledRequests, [identity], _collatorInfo] = await Promise.all([substrateApi.api.query.parachainStaking.delegationScheduledRequests(delegation.owner), (0,
|
|
176
|
+
const [_delegationScheduledRequests, [identity], _collatorInfo] = await Promise.all([substrateApi.api.query.parachainStaking.delegationScheduledRequests(delegation.owner), (0, _utils.parseIdentity)(substrateApi, delegation.owner), substrateApi.api.query.parachainStaking.candidateInfo(delegation.owner)]);
|
|
176
177
|
const collatorInfo = _collatorInfo.toPrimitive();
|
|
177
178
|
const minDelegation = collatorInfo === null || collatorInfo === void 0 ? void 0 : collatorInfo.lowestTopDelegationAmount.toString();
|
|
178
179
|
const delegationScheduledRequests = _delegationScheduledRequests.toPrimitive();
|
|
179
180
|
let hasUnstaking = false;
|
|
180
|
-
let delegationStatus =
|
|
181
|
+
let delegationStatus = _KoniTypes.StakingStatus.NOT_EARNING;
|
|
181
182
|
|
|
182
183
|
// parse unstaking info
|
|
183
184
|
if (delegationScheduledRequests) {
|
|
184
185
|
for (const scheduledRequest of delegationScheduledRequests) {
|
|
185
|
-
if ((0,
|
|
186
|
+
if ((0, _utils3.reformatAddress)(scheduledRequest.delegator, 0) === (0, _utils3.reformatAddress)(address, 0)) {
|
|
186
187
|
// add network prefix
|
|
187
188
|
const isClaimable = scheduledRequest.whenExecutable - currentRound < 0;
|
|
188
189
|
const remainingEra = scheduledRequest.whenExecutable - currentRound;
|
|
@@ -190,7 +191,7 @@ async function subscribeParaChainNominatorMetadata(chainInfo, address, substrate
|
|
|
190
191
|
const claimable = Object.values(scheduledRequest.action)[0];
|
|
191
192
|
unstakingMap[delegation.owner] = {
|
|
192
193
|
chain: chainInfo.slug,
|
|
193
|
-
status: isClaimable ?
|
|
194
|
+
status: isClaimable ? _KoniTypes.UnstakingStatus.CLAIMABLE : _KoniTypes.UnstakingStatus.UNLOCKING,
|
|
194
195
|
validatorAddress: delegation.owner,
|
|
195
196
|
claimable: claimable.toString(),
|
|
196
197
|
waitingTime
|
|
@@ -205,7 +206,7 @@ async function subscribeParaChainNominatorMetadata(chainInfo, address, substrate
|
|
|
205
206
|
const bnUnstakeBalance = unstakingMap[delegation.owner] ? new _util.BN(unstakingMap[delegation.owner].claimable) : _util.BN_ZERO;
|
|
206
207
|
const bnActiveStake = bnStake.sub(bnUnstakeBalance);
|
|
207
208
|
if (bnActiveStake.gt(_util.BN_ZERO) && bnActiveStake.gte(new _util.BN(minDelegation))) {
|
|
208
|
-
delegationStatus =
|
|
209
|
+
delegationStatus = _KoniTypes.StakingStatus.EARNING_REWARD;
|
|
209
210
|
}
|
|
210
211
|
bnTotalActiveStake = bnTotalActiveStake.add(bnActiveStake);
|
|
211
212
|
nominationList.push({
|
|
@@ -226,7 +227,7 @@ async function subscribeParaChainNominatorMetadata(chainInfo, address, substrate
|
|
|
226
227
|
// nomination.validatorMinStake = collatorInfo.lowestTopDelegationAmount.toString();
|
|
227
228
|
// }));
|
|
228
229
|
|
|
229
|
-
const stakingStatus = (0, _utils.
|
|
230
|
+
const stakingStatus = (0, _utils.getStakingStatusByNominations)(bnTotalActiveStake, nominationList);
|
|
230
231
|
return {
|
|
231
232
|
chain: chainInfo.slug,
|
|
232
233
|
type: _KoniTypes.StakingType.NOMINATED,
|
|
@@ -256,7 +257,7 @@ async function getParaChainNominatorMetadata(chainInfo, address, substrateApi) {
|
|
|
256
257
|
chain: chainInfo.slug,
|
|
257
258
|
type: _KoniTypes.StakingType.NOMINATED,
|
|
258
259
|
address,
|
|
259
|
-
status:
|
|
260
|
+
status: _KoniTypes.StakingStatus.NOT_STAKING,
|
|
260
261
|
activeStake: '0',
|
|
261
262
|
nominations: [],
|
|
262
263
|
unstakings: []
|
|
@@ -264,19 +265,19 @@ async function getParaChainNominatorMetadata(chainInfo, address, substrateApi) {
|
|
|
264
265
|
}
|
|
265
266
|
let bnTotalActiveStake = _util.BN_ZERO;
|
|
266
267
|
await Promise.all(delegatorState.delegations.map(async delegation => {
|
|
267
|
-
const [_delegationScheduledRequests, [identity], _roundInfo, _collatorInfo] = await Promise.all([chainApi.api.query.parachainStaking.delegationScheduledRequests(delegation.owner), (0,
|
|
268
|
+
const [_delegationScheduledRequests, [identity], _roundInfo, _collatorInfo] = await Promise.all([chainApi.api.query.parachainStaking.delegationScheduledRequests(delegation.owner), (0, _utils.parseIdentity)(substrateApi, delegation.owner), chainApi.api.query.parachainStaking.round(), chainApi.api.query.parachainStaking.candidateInfo(delegation.owner)]);
|
|
268
269
|
const rawCollatorInfo = _collatorInfo.toHuman();
|
|
269
270
|
const minDelegation = (rawCollatorInfo === null || rawCollatorInfo === void 0 ? void 0 : rawCollatorInfo.lowestTopDelegationAmount).replaceAll(',', '');
|
|
270
271
|
const roundInfo = _roundInfo.toPrimitive();
|
|
271
272
|
const delegationScheduledRequests = _delegationScheduledRequests.toPrimitive();
|
|
272
273
|
const currentRound = roundInfo.current;
|
|
273
274
|
let hasUnstaking = false;
|
|
274
|
-
let delegationStatus =
|
|
275
|
+
let delegationStatus = _KoniTypes.StakingStatus.NOT_EARNING;
|
|
275
276
|
|
|
276
277
|
// parse unstaking info
|
|
277
278
|
if (delegationScheduledRequests) {
|
|
278
279
|
for (const scheduledRequest of delegationScheduledRequests) {
|
|
279
|
-
if ((0,
|
|
280
|
+
if ((0, _utils3.reformatAddress)(scheduledRequest.delegator, 0) === (0, _utils3.reformatAddress)(address, 0)) {
|
|
280
281
|
// add network prefix
|
|
281
282
|
const isClaimable = scheduledRequest.whenExecutable - currentRound < 0;
|
|
282
283
|
const remainingEra = scheduledRequest.whenExecutable - (currentRound + 1);
|
|
@@ -284,7 +285,7 @@ async function getParaChainNominatorMetadata(chainInfo, address, substrateApi) {
|
|
|
284
285
|
const claimable = Object.values(scheduledRequest.action)[0];
|
|
285
286
|
unstakingMap[delegation.owner] = {
|
|
286
287
|
chain,
|
|
287
|
-
status: isClaimable ?
|
|
288
|
+
status: isClaimable ? _KoniTypes.UnstakingStatus.CLAIMABLE : _KoniTypes.UnstakingStatus.UNLOCKING,
|
|
288
289
|
validatorAddress: delegation.owner,
|
|
289
290
|
claimable: claimable.toString(),
|
|
290
291
|
waitingTime: waitingTime
|
|
@@ -299,7 +300,7 @@ async function getParaChainNominatorMetadata(chainInfo, address, substrateApi) {
|
|
|
299
300
|
const bnUnstakeBalance = unstakingMap[delegation.owner] ? new _util.BN(unstakingMap[delegation.owner].claimable) : _util.BN_ZERO;
|
|
300
301
|
const bnActiveStake = bnStake.sub(bnUnstakeBalance);
|
|
301
302
|
if (bnActiveStake.gt(_util.BN_ZERO) && bnActiveStake.gte(new _util.BN(minDelegation))) {
|
|
302
|
-
delegationStatus =
|
|
303
|
+
delegationStatus = _KoniTypes.StakingStatus.EARNING_REWARD;
|
|
303
304
|
}
|
|
304
305
|
bnTotalActiveStake = bnTotalActiveStake.add(bnActiveStake);
|
|
305
306
|
nominationList.push({
|
|
@@ -316,7 +317,7 @@ async function getParaChainNominatorMetadata(chainInfo, address, substrateApi) {
|
|
|
316
317
|
const collatorInfo = _collatorInfo.toPrimitive();
|
|
317
318
|
nomination.validatorMinStake = collatorInfo.lowestTopDelegationAmount.toString();
|
|
318
319
|
}));
|
|
319
|
-
const stakingStatus = (0, _utils.
|
|
320
|
+
const stakingStatus = (0, _utils.getStakingStatusByNominations)(bnTotalActiveStake, nominationList);
|
|
320
321
|
return {
|
|
321
322
|
chain,
|
|
322
323
|
type: _KoniTypes.StakingType.NOMINATED,
|
|
@@ -359,7 +360,7 @@ async function getParachainCollatorsInfo(chain, substrateApi) {
|
|
|
359
360
|
}
|
|
360
361
|
const extraInfoMap = {};
|
|
361
362
|
await Promise.all(allCollators.map(async collator => {
|
|
362
|
-
const [_info, [identity, isReasonable]] = await Promise.all([apiProps.api.query.parachainStaking.candidateInfo(collator.address), (0,
|
|
363
|
+
const [_info, [identity, isReasonable]] = await Promise.all([apiProps.api.query.parachainStaking.candidateInfo(collator.address), (0, _utils.parseIdentity)(apiProps, collator.address)]);
|
|
363
364
|
const rawInfo = _info.toHuman();
|
|
364
365
|
const active = (rawInfo === null || rawInfo === void 0 ? void 0 : rawInfo.status) === 'Active';
|
|
365
366
|
extraInfoMap[collator.address] = {
|
|
@@ -387,7 +388,7 @@ async function getParaBondingExtrinsic(chainInfo, substrateApi, amount, selected
|
|
|
387
388
|
bondedValidators,
|
|
388
389
|
nominationCount
|
|
389
390
|
} = (0, _utils.getBondedValidators)(nominatorMetadata.nominations);
|
|
390
|
-
const parsedSelectedCollatorAddress = (0,
|
|
391
|
+
const parsedSelectedCollatorAddress = (0, _utils3.reformatAddress)(selectedCollatorInfo.address, 0);
|
|
391
392
|
if (!bondedValidators.includes(parsedSelectedCollatorAddress)) {
|
|
392
393
|
return apiPromise.api.tx.parachainStaking.delegate(selectedCollatorInfo.address, binaryAmount, new _util.BN(selectedCollatorInfo.nominatorCount), nominationCount);
|
|
393
394
|
} else {
|