@subwallet/extension-base 1.1.29-0 → 1.1.29-beta.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 +94 -68
- package/background/KoniTypes.js +16 -13
- package/background/errors/TransactionError.js +9 -0
- package/cjs/background/KoniTypes.js +17 -16
- package/cjs/background/errors/TransactionError.js +9 -0
- package/cjs/constants/index.js +9 -3
- package/cjs/koni/api/nft/config.js +33 -23
- package/cjs/koni/api/nft/index.js +14 -0
- package/cjs/koni/api/nft/nft.js +1 -22
- package/cjs/koni/api/nft/ordinal_nft/constants.js +21 -0
- package/cjs/koni/api/nft/ordinal_nft/index.js +121 -0
- package/cjs/koni/api/nft/ordinal_nft/utils.js +41 -0
- package/cjs/koni/api/staking/bonding/amplitude.js +17 -15
- package/cjs/koni/api/staking/bonding/astar.js +11 -10
- package/cjs/koni/api/staking/bonding/index.js +4 -1
- package/cjs/koni/api/staking/bonding/paraChain.js +25 -23
- package/cjs/koni/api/staking/bonding/relayChain.js +48 -45
- package/cjs/koni/api/staking/bonding/utils.js +104 -86
- package/cjs/koni/api/staking/index.js +6 -5
- package/cjs/koni/api/staking/paraChain.js +6 -5
- package/cjs/koni/api/staking/relayChain.js +3 -2
- package/cjs/koni/api/yield/helper/utils.js +46 -0
- package/cjs/koni/background/cron.js +2 -0
- package/cjs/koni/background/handlers/Extension.js +347 -69
- package/cjs/koni/background/handlers/State.js +51 -3
- package/cjs/koni/background/handlers/index.js +4 -2
- package/cjs/koni/background/subscription.js +88 -18
- package/cjs/services/campaign-service/index.js +9 -6
- package/cjs/services/chain-service/constants.js +2 -16
- package/cjs/services/chain-service/utils.js +7 -1
- package/cjs/services/earning-service/constants/chains.js +29 -0
- package/cjs/services/earning-service/constants/index.js +27 -0
- package/cjs/services/earning-service/constants/step.js +18 -0
- package/cjs/services/earning-service/handlers/base.js +230 -0
- package/cjs/services/earning-service/handlers/index.js +60 -0
- package/cjs/services/earning-service/handlers/lending/base.js +20 -0
- package/cjs/services/earning-service/handlers/lending/index.js +13 -0
- package/cjs/services/earning-service/handlers/lending/interlay.js +176 -0
- package/cjs/services/earning-service/handlers/liquid-staking/acala.js +206 -0
- package/cjs/services/earning-service/handlers/liquid-staking/base.js +43 -0
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +267 -0
- package/cjs/services/earning-service/handlers/liquid-staking/index.js +34 -0
- package/cjs/services/earning-service/handlers/liquid-staking/parallel.js +190 -0
- package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +382 -0
- package/cjs/services/earning-service/handlers/native-staking/amplitude.js +380 -0
- package/cjs/services/earning-service/handlers/native-staking/astar.js +454 -0
- package/cjs/services/earning-service/handlers/native-staking/base-para.js +137 -0
- package/cjs/services/earning-service/handlers/native-staking/base.js +119 -0
- package/cjs/services/earning-service/handlers/native-staking/index.js +34 -0
- package/cjs/services/earning-service/handlers/native-staking/para-chain.js +381 -0
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +540 -0
- package/cjs/services/earning-service/handlers/nomination-pool/index.js +528 -0
- package/cjs/services/earning-service/handlers/special.js +412 -0
- package/cjs/services/earning-service/service.js +351 -0
- package/cjs/services/earning-service/utils/index.js +128 -0
- package/cjs/services/event-service/index.js +4 -0
- package/cjs/services/keyring-service/index.js +14 -2
- package/cjs/services/migration-service/scripts/DeleteEarningData.js +21 -0
- package/cjs/services/migration-service/scripts/EnableEarningChains.js +21 -0
- package/cjs/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
- package/cjs/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
- package/cjs/services/migration-service/scripts/databases/MigrateEarningHistory.js +21 -0
- package/cjs/services/migration-service/scripts/databases/MigrateEarningVersion.js +21 -0
- package/cjs/services/migration-service/scripts/index.js +7 -1
- package/cjs/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +149 -0
- package/cjs/services/mint-campaign-service/campaigns/index.js +13 -0
- package/cjs/services/mint-campaign-service/constants.js +11 -0
- package/cjs/services/mint-campaign-service/index.js +18 -0
- package/cjs/services/notification-service/NotificationService.js +1 -1
- package/cjs/services/storage-service/DatabaseService.js +51 -0
- package/cjs/services/storage-service/databases/index.js +4 -0
- package/cjs/services/storage-service/db-stores/NominatorMetadata.js +3 -3
- package/cjs/services/storage-service/db-stores/YieldPoolStore.js +36 -0
- package/cjs/services/storage-service/db-stores/YieldPositionStore.js +65 -0
- package/cjs/services/transaction-service/event-parser/index.js +58 -0
- package/cjs/services/transaction-service/helpers/index.js +3 -1
- package/cjs/services/transaction-service/index.js +185 -74
- package/cjs/services/transaction-service/utils.js +1 -0
- package/cjs/types/campaigns/index.js +16 -0
- package/cjs/types/campaigns/unlock-dot.js +1 -0
- package/cjs/types/index.js +44 -0
- package/cjs/types/ordinal.js +1 -0
- package/cjs/types/transaction.js +1 -0
- package/cjs/types/yield/actions/index.js +27 -0
- package/cjs/types/yield/actions/join/index.js +38 -0
- package/cjs/types/yield/actions/join/step.js +47 -0
- package/cjs/types/yield/actions/join/submit.js +1 -0
- package/cjs/types/yield/actions/join/validate.js +16 -0
- package/cjs/types/yield/actions/others.js +1 -0
- package/cjs/types/yield/index.js +27 -0
- package/cjs/types/yield/info/account/index.js +49 -0
- package/cjs/types/yield/info/account/info.js +1 -0
- package/cjs/types/yield/info/account/reward.js +1 -0
- package/cjs/types/yield/info/account/target.js +32 -0
- package/cjs/types/yield/info/account/unstake.js +27 -0
- package/cjs/types/yield/info/base.js +41 -0
- package/cjs/types/yield/info/chain/index.js +27 -0
- package/cjs/types/yield/info/chain/info.js +1 -0
- package/cjs/types/yield/info/chain/target.js +1 -0
- package/cjs/types/yield/info/index.js +49 -0
- package/cjs/types/yield/info/pallet.js +15 -0
- package/cjs/utils/fetchStaticData.js +2 -1
- package/cjs/utils/index.js +89 -1
- package/cjs/utils/object.js +12 -0
- package/cjs/utils/yield/index.js +3 -0
- package/constants/index.d.ts +2 -0
- package/constants/index.js +2 -0
- package/koni/api/nft/config.js +33 -23
- package/koni/api/nft/index.js +15 -1
- package/koni/api/nft/nft.js +2 -23
- package/koni/api/nft/ordinal_nft/constants.d.ts +9 -0
- package/koni/api/nft/ordinal_nft/constants.js +12 -0
- package/koni/api/nft/ordinal_nft/index.d.ts +8 -0
- package/koni/api/nft/ordinal_nft/index.js +114 -0
- package/koni/api/nft/ordinal_nft/utils.d.ts +2 -0
- package/koni/api/nft/ordinal_nft/utils.js +33 -0
- package/koni/api/staking/bonding/amplitude.js +11 -9
- package/koni/api/staking/bonding/astar.js +9 -8
- package/koni/api/staking/bonding/index.d.ts +1 -1
- package/koni/api/staking/bonding/index.js +5 -1
- package/koni/api/staking/bonding/paraChain.js +12 -10
- package/koni/api/staking/bonding/relayChain.d.ts +2 -2
- package/koni/api/staking/bonding/relayChain.js +33 -30
- package/koni/api/staking/bonding/utils.d.ts +15 -38
- package/koni/api/staking/bonding/utils.js +85 -69
- package/koni/api/staking/index.js +2 -1
- package/koni/api/staking/paraChain.js +7 -6
- package/koni/api/staking/relayChain.js +4 -3
- package/koni/api/yield/helper/utils.d.ts +10 -0
- package/koni/api/yield/helper/utils.js +32 -0
- package/koni/background/cron.js +2 -0
- package/koni/background/handlers/Extension.d.ts +16 -1
- package/koni/background/handlers/Extension.js +306 -30
- package/koni/background/handlers/State.d.ts +18 -2
- package/koni/background/handlers/State.js +50 -3
- package/koni/background/handlers/index.js +4 -2
- package/koni/background/subscription.d.ts +5 -1
- package/koni/background/subscription.js +90 -20
- package/package.json +316 -3
- package/services/campaign-service/index.js +9 -6
- package/services/chain-service/constants.d.ts +0 -11
- package/services/chain-service/constants.js +1 -14
- package/services/chain-service/utils.d.ts +1 -0
- package/services/chain-service/utils.js +5 -1
- package/services/earning-service/constants/abis/compound_finance_v2_abi.json +1235 -0
- package/services/earning-service/constants/abis/st_liquid_token_abi.json +1355 -0
- package/services/earning-service/constants/chains.d.ts +14 -0
- package/services/earning-service/constants/chains.js +21 -0
- package/services/earning-service/constants/index.d.ts +2 -0
- package/services/earning-service/constants/index.js +5 -0
- package/services/earning-service/constants/step.d.ts +3 -0
- package/services/earning-service/constants/step.js +10 -0
- package/services/earning-service/handlers/base.d.ts +108 -0
- package/services/earning-service/handlers/base.js +224 -0
- package/services/earning-service/handlers/index.d.ts +5 -0
- package/services/earning-service/handlers/index.js +8 -0
- package/services/earning-service/handlers/lending/base.d.ts +6 -0
- package/services/earning-service/handlers/lending/base.js +12 -0
- package/services/earning-service/handlers/lending/index.d.ts +1 -0
- package/services/earning-service/handlers/lending/index.js +4 -0
- package/services/earning-service/handlers/lending/interlay.d.ts +22 -0
- package/services/earning-service/handlers/lending/interlay.js +168 -0
- package/services/earning-service/handlers/liquid-staking/acala.d.ts +27 -0
- package/services/earning-service/handlers/liquid-staking/acala.js +198 -0
- package/services/earning-service/handlers/liquid-staking/base.d.ts +9 -0
- package/services/earning-service/handlers/liquid-staking/base.js +35 -0
- package/services/earning-service/handlers/liquid-staking/bifrost.d.ts +44 -0
- package/services/earning-service/handlers/liquid-staking/bifrost.js +256 -0
- package/services/earning-service/handlers/liquid-staking/index.d.ts +4 -0
- package/services/earning-service/handlers/liquid-staking/index.js +7 -0
- package/services/earning-service/handlers/liquid-staking/parallel.d.ts +27 -0
- package/services/earning-service/handlers/liquid-staking/parallel.js +182 -0
- package/services/earning-service/handlers/liquid-staking/stella-swap.d.ts +36 -0
- package/services/earning-service/handlers/liquid-staking/stella-swap.js +372 -0
- package/services/earning-service/handlers/native-staking/amplitude.d.ts +22 -0
- package/services/earning-service/handlers/native-staking/amplitude.js +371 -0
- package/services/earning-service/handlers/native-staking/astar.d.ts +19 -0
- package/services/earning-service/handlers/native-staking/astar.js +444 -0
- package/services/earning-service/handlers/native-staking/base-para.d.ts +11 -0
- package/services/earning-service/handlers/native-staking/base-para.js +129 -0
- package/services/earning-service/handlers/native-staking/base.d.ts +20 -0
- package/services/earning-service/handlers/native-staking/base.js +110 -0
- package/services/earning-service/handlers/native-staking/index.d.ts +4 -0
- package/services/earning-service/handlers/native-staking/index.js +7 -0
- package/services/earning-service/handlers/native-staking/para-chain.d.ts +15 -0
- package/services/earning-service/handlers/native-staking/para-chain.js +373 -0
- package/services/earning-service/handlers/native-staking/relay-chain.d.ts +21 -0
- package/services/earning-service/handlers/native-staking/relay-chain.js +531 -0
- package/services/earning-service/handlers/nomination-pool/index.d.ts +33 -0
- package/services/earning-service/handlers/nomination-pool/index.js +518 -0
- package/services/earning-service/handlers/special.d.ts +59 -0
- package/services/earning-service/handlers/special.js +404 -0
- package/services/earning-service/service.d.ts +40 -0
- package/services/earning-service/service.js +343 -0
- package/services/earning-service/utils/index.d.ts +18 -0
- package/services/earning-service/utils/index.js +112 -0
- package/services/event-service/index.d.ts +1 -0
- package/services/event-service/index.js +4 -0
- package/services/event-service/types.d.ts +8 -0
- package/services/keyring-service/index.d.ts +2 -1
- package/services/keyring-service/index.js +14 -2
- package/services/migration-service/scripts/DeleteEarningData.d.ts +4 -0
- package/services/migration-service/scripts/DeleteEarningData.js +13 -0
- package/services/migration-service/scripts/EnableEarningChains.d.ts +4 -0
- package/services/migration-service/scripts/EnableEarningChains.js +13 -0
- package/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
- package/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
- package/services/migration-service/scripts/databases/MigrateEarningHistory.d.ts +4 -0
- package/services/migration-service/scripts/databases/MigrateEarningHistory.js +13 -0
- package/services/migration-service/scripts/databases/MigrateEarningVersion.d.ts +4 -0
- package/services/migration-service/scripts/databases/MigrateEarningVersion.js +13 -0
- package/services/migration-service/scripts/index.js +7 -1
- package/services/mint-campaign-service/campaigns/UnlockDotCampaign.d.ts +13 -0
- package/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +139 -0
- package/services/mint-campaign-service/campaigns/index.d.ts +1 -0
- package/services/mint-campaign-service/campaigns/index.js +4 -0
- package/services/mint-campaign-service/constants.d.ts +1 -0
- package/services/mint-campaign-service/constants.js +4 -0
- package/services/mint-campaign-service/index.d.ts +7 -0
- package/services/mint-campaign-service/index.js +11 -0
- package/services/notification-service/NotificationService.js +1 -1
- package/services/storage-service/DatabaseService.d.ts +18 -1
- package/services/storage-service/DatabaseService.js +51 -0
- package/services/storage-service/databases/index.d.ts +3 -1
- package/services/storage-service/databases/index.js +4 -0
- package/services/storage-service/db-stores/NominatorMetadata.js +3 -3
- package/services/storage-service/db-stores/YieldPoolStore.d.ts +10 -0
- package/services/storage-service/db-stores/YieldPoolStore.js +28 -0
- package/services/storage-service/db-stores/YieldPositionStore.d.ts +9 -0
- package/services/storage-service/db-stores/YieldPositionStore.js +57 -0
- package/services/subscan-service/index.d.ts +2 -2
- package/services/transaction-service/event-parser/index.d.ts +3 -1
- package/services/transaction-service/event-parser/index.js +57 -1
- package/services/transaction-service/helpers/index.js +3 -1
- package/services/transaction-service/index.d.ts +4 -15
- package/services/transaction-service/index.js +183 -72
- package/services/transaction-service/types.d.ts +2 -0
- package/services/transaction-service/utils.js +1 -0
- package/types/campaigns/index.d.ts +1 -0
- package/types/campaigns/index.js +4 -0
- package/types/campaigns/unlock-dot.d.ts +71 -0
- package/types/campaigns/unlock-dot.js +1 -0
- package/types/index.d.ts +5 -0
- package/types/index.js +5 -1
- package/types/ordinal.d.ts +69 -0
- package/types/ordinal.js +1 -0
- package/types/transaction.d.ts +3 -0
- package/types/transaction.js +1 -0
- package/types/yield/actions/index.d.ts +2 -0
- package/types/yield/actions/index.js +5 -0
- package/types/yield/actions/join/index.d.ts +3 -0
- package/types/yield/actions/join/index.js +6 -0
- package/types/yield/actions/join/step.d.ts +94 -0
- package/types/yield/actions/join/step.js +46 -0
- package/types/yield/actions/join/submit.d.ts +53 -0
- package/types/yield/actions/join/submit.js +1 -0
- package/types/yield/actions/join/validate.d.ts +18 -0
- package/types/yield/actions/join/validate.js +10 -0
- package/types/yield/actions/others.d.ts +63 -0
- package/types/yield/actions/others.js +1 -0
- package/types/yield/index.d.ts +2 -0
- package/types/yield/index.js +5 -0
- package/types/yield/info/account/index.d.ts +4 -0
- package/types/yield/info/account/index.js +7 -0
- package/types/yield/info/account/info.d.ts +101 -0
- package/types/yield/info/account/info.js +1 -0
- package/types/yield/info/account/reward.d.ts +30 -0
- package/types/yield/info/account/reward.js +1 -0
- package/types/yield/info/account/target.d.ts +43 -0
- package/types/yield/info/account/target.js +27 -0
- package/types/yield/info/account/unstake.d.ts +31 -0
- package/types/yield/info/account/unstake.js +22 -0
- package/types/yield/info/base.d.ts +45 -0
- package/types/yield/info/base.js +36 -0
- package/types/yield/info/chain/index.d.ts +2 -0
- package/types/yield/info/chain/index.js +5 -0
- package/types/yield/info/chain/info.d.ts +217 -0
- package/types/yield/info/chain/info.js +1 -0
- package/types/yield/info/chain/target.d.ts +37 -0
- package/types/yield/info/chain/target.js +1 -0
- package/types/yield/info/index.d.ts +4 -0
- package/types/yield/info/index.js +7 -0
- package/types/yield/info/pallet.d.ts +143 -0
- package/types/yield/info/pallet.js +9 -0
- package/utils/fetchStaticData.js +2 -1
- package/utils/index.d.ts +5 -0
- package/utils/index.js +53 -1
- package/utils/object.d.ts +1 -0
- package/utils/object.js +6 -0
package/koni/api/nft/config.js
CHANGED
|
@@ -15,7 +15,11 @@ 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
|
|
18
20
|
export const CF_IPFS_GATEWAY = 'https://cf-ipfs.com/ipfs/';
|
|
21
|
+
|
|
22
|
+
// XOrigin
|
|
19
23
|
export const PINATA_IPFS_GATEWAY = 'https://gateway.pinata.cloud/ipfs/';
|
|
20
24
|
export const UNIQUE_SCAN_ENDPOINT = 'https://explorer-api.unique.network/v1/graphql';
|
|
21
25
|
export const QUARTZ_SCAN_ENDPOINT = 'https://hasura-quartz.unique.network/v1/graphql';
|
|
@@ -24,10 +28,18 @@ export const VARA_SCAN_ENDPOINT = 'https://nft-explorer.vara-network.io/graphql'
|
|
|
24
28
|
// GATEWAY
|
|
25
29
|
|
|
26
30
|
export const UNIQUE_IPFS_GATEWAY = 'https://ipfs.unique.network/ipfs/';
|
|
31
|
+
|
|
32
|
+
// XOrigin
|
|
27
33
|
export const NFT_STORAGE_GATEWAY = 'https://nftstorage.link/ipfs/';
|
|
28
34
|
export const IPFS_W3S_LINK = 'https://w3s.link/ipfs/';
|
|
35
|
+
|
|
36
|
+
// XOrigin
|
|
29
37
|
export const GATEWAY_IPFS_IO = 'https://gateway.ipfs.io/ipfs/';
|
|
38
|
+
|
|
39
|
+
// XOrigin
|
|
30
40
|
export const IPFS_IO = 'https://ipfs.io/ipfs/';
|
|
41
|
+
|
|
42
|
+
// XOrigin
|
|
31
43
|
export const DWEB_LINK = 'https://dweb.link/ipfs/';
|
|
32
44
|
export const IPFS_GATEWAY_4EVERLAND = 'https://4everland.io/ipfs/';
|
|
33
45
|
export const IPFS_FLEEK = 'https://ipfs.fleek.co/ipfs/';
|
|
@@ -83,26 +95,8 @@ export let SUPPORTED_TRANSFER_SUBSTRATE_CHAIN_NAME;
|
|
|
83
95
|
SUPPORTED_TRANSFER_SUBSTRATE_CHAIN_NAME["pioneer"] = "pioneer";
|
|
84
96
|
})(SUPPORTED_TRANSFER_SUBSTRATE_CHAIN_NAME || (SUPPORTED_TRANSFER_SUBSTRATE_CHAIN_NAME = {}));
|
|
85
97
|
const RANDOM_IPFS_GATEWAY_SETTING = [{
|
|
86
|
-
provider: CF_IPFS_GATEWAY,
|
|
87
|
-
weight: 4
|
|
88
|
-
}, {
|
|
89
98
|
provider: CLOUDFLARE_PINATA_SERVER,
|
|
90
99
|
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
|
|
106
100
|
}];
|
|
107
101
|
if (isFirefox) {
|
|
108
102
|
RANDOM_IPFS_GATEWAY_SETTING.push({
|
|
@@ -110,18 +104,34 @@ if (isFirefox) {
|
|
|
110
104
|
weight: 5000
|
|
111
105
|
});
|
|
112
106
|
}
|
|
113
|
-
if (!RuntimeInfo.protocol || RuntimeInfo.protocol
|
|
107
|
+
if (!RuntimeInfo.protocol || !RuntimeInfo.protocol.startsWith('http') || RuntimeInfo.protocol.startsWith('https')) {
|
|
114
108
|
RANDOM_IPFS_GATEWAY_SETTING.push({
|
|
115
109
|
provider: IPFS_FLEEK,
|
|
116
110
|
weight: 4
|
|
117
|
-
}
|
|
118
|
-
RANDOM_IPFS_GATEWAY_SETTING.push({
|
|
111
|
+
}, {
|
|
119
112
|
provider: IPFS_GATEWAY_4EVERLAND,
|
|
120
113
|
weight: 2
|
|
121
|
-
}
|
|
122
|
-
RANDOM_IPFS_GATEWAY_SETTING.push({
|
|
114
|
+
}, {
|
|
123
115
|
provider: IPFS_W3S_LINK,
|
|
124
116
|
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
|
|
125
135
|
});
|
|
126
136
|
}
|
|
127
137
|
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,13 +5,14 @@ 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';
|
|
8
9
|
import { RmrkNftApi } from '@subwallet/extension-base/koni/api/nft/rmrk_nft';
|
|
9
10
|
import StatemineNftApi from '@subwallet/extension-base/koni/api/nft/statemine_nft';
|
|
10
11
|
import UniqueNftApi from '@subwallet/extension-base/koni/api/nft/unique_nft';
|
|
11
12
|
import { VaraNftApi } from '@subwallet/extension-base/koni/api/nft/vara_nft';
|
|
12
13
|
import { WasmNftApi } from '@subwallet/extension-base/koni/api/nft/wasm_nft';
|
|
13
14
|
import { _NFT_CHAIN_GROUP } from '@subwallet/extension-base/services/chain-service/constants';
|
|
14
|
-
import { _isChainSupportEvmNft, _isChainSupportNativeNft, _isChainSupportWasmNft } from '@subwallet/extension-base/services/chain-service/utils';
|
|
15
|
+
import { _isChainSupportEvmNft, _isChainSupportNativeNft, _isChainSupportWasmNft, _isSupportOrdinal } from '@subwallet/extension-base/services/chain-service/utils';
|
|
15
16
|
import { categoryAddresses } from '@subwallet/extension-base/utils';
|
|
16
17
|
import StatemintNftApi from "./statemint_nft/index.js";
|
|
17
18
|
function createSubstrateNftApi(chain, substrateApi, addresses) {
|
|
@@ -43,6 +44,9 @@ function createWeb3NftApi(chain, evmApi, addresses) {
|
|
|
43
44
|
const [, evmAddresses] = categoryAddresses(addresses);
|
|
44
45
|
return new EvmNftApi(evmApi, evmAddresses, chain);
|
|
45
46
|
}
|
|
47
|
+
const createOrdinalApi = (chain, subscanChain, addresses) => {
|
|
48
|
+
return new OrdinalNftApi(addresses, chain, subscanChain);
|
|
49
|
+
};
|
|
46
50
|
export class NftHandler {
|
|
47
51
|
// General settings
|
|
48
52
|
chainInfoMap = {};
|
|
@@ -122,6 +126,16 @@ export class NftHandler {
|
|
|
122
126
|
}
|
|
123
127
|
}
|
|
124
128
|
}
|
|
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
|
+
}
|
|
125
139
|
});
|
|
126
140
|
this.needSetupApi = false;
|
|
127
141
|
}
|
package/koni/api/nft/nft.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import { isUrl } from '@subwallet/extension-base/utils';
|
|
4
|
+
import { baseParseIPFSUrl } from '@subwallet/extension-base/utils';
|
|
6
5
|
export class BaseNftApi {
|
|
7
6
|
chain = '';
|
|
8
7
|
substrateApi = null;
|
|
@@ -65,27 +64,7 @@ export class BaseNftApi {
|
|
|
65
64
|
return tokenId;
|
|
66
65
|
}
|
|
67
66
|
parseUrl(input) {
|
|
68
|
-
|
|
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/
|
|
67
|
+
return baseParseIPFSUrl(input);
|
|
89
68
|
}
|
|
90
69
|
|
|
91
70
|
// Subclass implements this function to parse data into prop result
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const GET_EVENT_LIST_API = "https://{{chain}}.api.subscan.io/api/v2/scan/events";
|
|
2
|
+
export declare const GET_EXTRINSIC_PARAMS_API = "https://{{chain}}.api.subscan.io/api/scan/extrinsic/params";
|
|
3
|
+
export declare const BASE_FETCH_ORDINAL_EVENT_DATA: {
|
|
4
|
+
event_id: string;
|
|
5
|
+
module: string;
|
|
6
|
+
order: string;
|
|
7
|
+
success: boolean;
|
|
8
|
+
row: number;
|
|
9
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
export const GET_EVENT_LIST_API = 'https://{{chain}}.api.subscan.io/api/v2/scan/events';
|
|
5
|
+
export const GET_EXTRINSIC_PARAMS_API = 'https://{{chain}}.api.subscan.io/api/scan/extrinsic/params';
|
|
6
|
+
export const BASE_FETCH_ORDINAL_EVENT_DATA = {
|
|
7
|
+
event_id: 'Remarked',
|
|
8
|
+
module: 'system',
|
|
9
|
+
order: 'desc',
|
|
10
|
+
success: true,
|
|
11
|
+
row: 100
|
|
12
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BaseNftApi, HandleNftParams } from '@subwallet/extension-base/koni/api/nft/nft';
|
|
2
|
+
export default class OrdinalNftApi extends BaseNftApi {
|
|
3
|
+
subscanChain: string;
|
|
4
|
+
constructor(addresses: string[], chain: string, subscanChain: string);
|
|
5
|
+
handleNft(address: string, handleNftParams: HandleNftParams): Promise<void>;
|
|
6
|
+
handleNfts(params: HandleNftParams): Promise<void>;
|
|
7
|
+
fetchNfts(params: HandleNftParams): Promise<number>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { ORDINAL_COLLECTION } from '@subwallet/extension-base/constants';
|
|
5
|
+
import { BaseNftApi } from '@subwallet/extension-base/koni/api/nft/nft';
|
|
6
|
+
import { fetchExtrinsicParams, fetchRemarkEvent } from '@subwallet/extension-base/koni/api/nft/ordinal_nft/utils';
|
|
7
|
+
import { state } from '@subwallet/extension-base/koni/background/handlers';
|
|
8
|
+
const parseParamData = (param, event, chain, address) => {
|
|
9
|
+
const ordinalData = JSON.parse(param.value);
|
|
10
|
+
if ('p' in ordinalData) {
|
|
11
|
+
const properties = {};
|
|
12
|
+
for (const [key, value] of Object.entries(ordinalData)) {
|
|
13
|
+
const _name = key.charAt(0).toUpperCase() + key.slice(1);
|
|
14
|
+
properties[_name] = {
|
|
15
|
+
value: value
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
properties['Block number'] = {
|
|
19
|
+
value: event.extrinsic_index.split('-')[0]
|
|
20
|
+
};
|
|
21
|
+
properties.Timestamp = {
|
|
22
|
+
value: event.block_timestamp
|
|
23
|
+
};
|
|
24
|
+
const op = ordinalData.op.charAt(0).toUpperCase() + ordinalData.op.slice(1);
|
|
25
|
+
const nameParams = [op];
|
|
26
|
+
if (ordinalData.amt !== undefined) {
|
|
27
|
+
nameParams.push(ordinalData.amt);
|
|
28
|
+
}
|
|
29
|
+
nameParams.push(ordinalData.tick);
|
|
30
|
+
const name = nameParams.join(' ');
|
|
31
|
+
return {
|
|
32
|
+
chain: chain,
|
|
33
|
+
collectionId: ORDINAL_COLLECTION,
|
|
34
|
+
id: event.extrinsic_hash,
|
|
35
|
+
description: JSON.stringify(ordinalData),
|
|
36
|
+
name,
|
|
37
|
+
owner: address,
|
|
38
|
+
properties: properties
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
return undefined;
|
|
42
|
+
};
|
|
43
|
+
export default class OrdinalNftApi extends BaseNftApi {
|
|
44
|
+
constructor(addresses, chain, subscanChain) {
|
|
45
|
+
super(chain, undefined, addresses);
|
|
46
|
+
this.subscanChain = subscanChain;
|
|
47
|
+
}
|
|
48
|
+
async handleNft(address, handleNftParams) {
|
|
49
|
+
const events = await state.subscanService.addRequest(async () => {
|
|
50
|
+
return await fetchRemarkEvent(this.subscanChain, address);
|
|
51
|
+
});
|
|
52
|
+
if (events && events.length) {
|
|
53
|
+
const extrinsicIds = events.map(data => data.extrinsic_index);
|
|
54
|
+
const extrinsicParams = await state.subscanService.addRequest(async () => {
|
|
55
|
+
return await fetchExtrinsicParams(this.subscanChain, extrinsicIds);
|
|
56
|
+
});
|
|
57
|
+
const items = [];
|
|
58
|
+
for (const data of extrinsicParams) {
|
|
59
|
+
const {
|
|
60
|
+
extrinsic_index: extrinsicIndex,
|
|
61
|
+
params
|
|
62
|
+
} = data;
|
|
63
|
+
const event = events.find(item => item.extrinsic_index === extrinsicIndex);
|
|
64
|
+
if (params.length === 1 && event) {
|
|
65
|
+
const [param] = params;
|
|
66
|
+
if (param.name === 'remark') {
|
|
67
|
+
const childParam = {
|
|
68
|
+
name: param.name,
|
|
69
|
+
type: param.type,
|
|
70
|
+
value: param.value
|
|
71
|
+
};
|
|
72
|
+
const item = parseParamData(childParam, event, this.chain, address);
|
|
73
|
+
if (item) {
|
|
74
|
+
items.push(item);
|
|
75
|
+
}
|
|
76
|
+
} else if (param.name === 'calls') {
|
|
77
|
+
const children = param.value;
|
|
78
|
+
for (const child of children) {
|
|
79
|
+
if (child.call_module === 'System' && child.call_name === 'remark_with_event') {
|
|
80
|
+
for (const childParam of child.params) {
|
|
81
|
+
const item = parseParamData(childParam, event, this.chain, address);
|
|
82
|
+
if (item) {
|
|
83
|
+
items.push(item);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (items.length) {
|
|
92
|
+
// handleNftParams.updateCollection(this.chain, {
|
|
93
|
+
// chain: this.chain,
|
|
94
|
+
// collectionId: ORDINAL_COLLECTION
|
|
95
|
+
// });
|
|
96
|
+
|
|
97
|
+
for (const item of items) {
|
|
98
|
+
handleNftParams.updateItem(this.chain, item, address);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
async handleNfts(params) {
|
|
104
|
+
await Promise.all(this.addresses.map(address => this.handleNft(address, params)));
|
|
105
|
+
}
|
|
106
|
+
async fetchNfts(params) {
|
|
107
|
+
try {
|
|
108
|
+
await this.handleNfts(params);
|
|
109
|
+
} catch (e) {
|
|
110
|
+
return 0;
|
|
111
|
+
}
|
|
112
|
+
return 1;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const fetchRemarkEvent: (chain: string, address: string) => Promise<import("@subwallet/extension-base/types").SubscanEventBaseItemData[]>;
|
|
2
|
+
export declare const fetchExtrinsicParams: (chain: string, extrinsicIndexes: string[]) => Promise<import("@subwallet/extension-base/types").SubscanExtrinsicParam[]>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { BASE_FETCH_ORDINAL_EVENT_DATA, GET_EVENT_LIST_API, GET_EXTRINSIC_PARAMS_API } from "./constants.js";
|
|
5
|
+
export const fetchRemarkEvent = async (chain, address) => {
|
|
6
|
+
const params = {
|
|
7
|
+
...BASE_FETCH_ORDINAL_EVENT_DATA,
|
|
8
|
+
address
|
|
9
|
+
};
|
|
10
|
+
const response = await fetch(GET_EVENT_LIST_API.replace('{{chain}}', chain), {
|
|
11
|
+
method: 'POST',
|
|
12
|
+
headers: {
|
|
13
|
+
'Content-Type': 'application/json'
|
|
14
|
+
},
|
|
15
|
+
body: JSON.stringify(params)
|
|
16
|
+
});
|
|
17
|
+
const data = await response.json();
|
|
18
|
+
return data.data.events;
|
|
19
|
+
};
|
|
20
|
+
export const fetchExtrinsicParams = async (chain, extrinsicIndexes) => {
|
|
21
|
+
const params = {
|
|
22
|
+
extrinsic_index: extrinsicIndexes
|
|
23
|
+
};
|
|
24
|
+
const response = await fetch(GET_EXTRINSIC_PARAMS_API.replace('{{chain}}', chain), {
|
|
25
|
+
method: 'POST',
|
|
26
|
+
headers: {
|
|
27
|
+
'Content-Type': 'application/json'
|
|
28
|
+
},
|
|
29
|
+
body: JSON.stringify(params)
|
|
30
|
+
});
|
|
31
|
+
const data = await response.json();
|
|
32
|
+
return data.data;
|
|
33
|
+
};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import { getBondedValidators,
|
|
4
|
+
import { StakingType } from '@subwallet/extension-base/background/KoniTypes';
|
|
5
|
+
import { getBondedValidators, getEarningStatusByNominations, isUnstakeAll } 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 { parseIdentity } from '@subwallet/extension-base/services/earning-service/utils';
|
|
8
|
+
import { EarningStatus, UnstakingStatus } from '@subwallet/extension-base/types';
|
|
7
9
|
import { parseRawNumber, reformatAddress } from '@subwallet/extension-base/utils';
|
|
8
10
|
import { BN, BN_ZERO } from '@polkadot/util';
|
|
9
11
|
import { isEthereumAddress } from '@polkadot/util-crypto';
|
|
@@ -64,9 +66,9 @@ export async function subscribeAmplitudeNominatorMetadata(chainInfo, address, su
|
|
|
64
66
|
const [identity] = await parseIdentity(substrateApi, delegatorState.owner);
|
|
65
67
|
activeStake = delegatorState.amount.toString();
|
|
66
68
|
const bnActiveStake = new BN(activeStake);
|
|
67
|
-
let delegationStatus =
|
|
69
|
+
let delegationStatus = EarningStatus.NOT_EARNING;
|
|
68
70
|
if (bnActiveStake.gt(BN_ZERO) && bnActiveStake.gte(new BN(minDelegatorStake))) {
|
|
69
|
-
delegationStatus =
|
|
71
|
+
delegationStatus = EarningStatus.EARNING_REWARD;
|
|
70
72
|
}
|
|
71
73
|
nominationList.push({
|
|
72
74
|
status: delegationStatus,
|
|
@@ -99,7 +101,7 @@ export async function subscribeAmplitudeNominatorMetadata(chainInfo, address, su
|
|
|
99
101
|
validatorAddress: (delegatorState === null || delegatorState === void 0 ? void 0 : delegatorState.owner) || undefined
|
|
100
102
|
});
|
|
101
103
|
}
|
|
102
|
-
const stakingStatus =
|
|
104
|
+
const stakingStatus = getEarningStatusByNominations(new BN(activeStake), nominationList);
|
|
103
105
|
return {
|
|
104
106
|
chain: chainInfo.slug,
|
|
105
107
|
type: StakingType.NOMINATED,
|
|
@@ -131,7 +133,7 @@ export async function getAmplitudeNominatorMetadata(chainInfo, address, substrat
|
|
|
131
133
|
chain: chainInfo.slug,
|
|
132
134
|
type: StakingType.NOMINATED,
|
|
133
135
|
address,
|
|
134
|
-
status:
|
|
136
|
+
status: EarningStatus.NOT_STAKING,
|
|
135
137
|
activeStake: '0',
|
|
136
138
|
nominations: [],
|
|
137
139
|
unstakings: []
|
|
@@ -143,9 +145,9 @@ export async function getAmplitudeNominatorMetadata(chainInfo, address, substrat
|
|
|
143
145
|
const [identity] = await parseIdentity(substrateApi, delegatorState.owner);
|
|
144
146
|
activeStake = delegatorState.amount.toString();
|
|
145
147
|
const bnActiveStake = new BN(activeStake);
|
|
146
|
-
let delegationStatus =
|
|
148
|
+
let delegationStatus = EarningStatus.NOT_EARNING;
|
|
147
149
|
if (bnActiveStake.gt(BN_ZERO) && bnActiveStake.gte(new BN(minDelegatorStake))) {
|
|
148
|
-
delegationStatus =
|
|
150
|
+
delegationStatus = EarningStatus.EARNING_REWARD;
|
|
149
151
|
}
|
|
150
152
|
nominationList.push({
|
|
151
153
|
status: delegationStatus,
|
|
@@ -181,7 +183,7 @@ export async function getAmplitudeNominatorMetadata(chainInfo, address, substrat
|
|
|
181
183
|
if (nominationList.length === 0 && unstakingList.length === 0) {
|
|
182
184
|
return;
|
|
183
185
|
}
|
|
184
|
-
const stakingStatus =
|
|
186
|
+
const stakingStatus = getEarningStatusByNominations(new BN(activeStake), nominationList);
|
|
185
187
|
return {
|
|
186
188
|
chain,
|
|
187
189
|
type: StakingType.NOMINATED,
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { StakingType } from '@subwallet/extension-base/background/KoniTypes';
|
|
5
|
+
import { getEarningStatusByNominations } 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';
|
|
7
8
|
import { isUrl, parseRawNumber } from '@subwallet/extension-base/utils';
|
|
8
9
|
import fetch from 'cross-fetch';
|
|
9
10
|
import { BN, BN_ZERO } from '@polkadot/util';
|
|
@@ -99,7 +100,7 @@ export async function subscribeAstarNominatorMetadata(chainInfo, address, substr
|
|
|
99
100
|
const currentStake = stakeList.slice(-1)[0].staked.toString() || '0';
|
|
100
101
|
const bnCurrentStake = new BN(currentStake);
|
|
101
102
|
if (bnCurrentStake.gt(BN_ZERO)) {
|
|
102
|
-
const dappStakingStatus = bnCurrentStake.gt(BN_ZERO) && bnCurrentStake.gte(new BN(minDelegatorStake)) ?
|
|
103
|
+
const dappStakingStatus = bnCurrentStake.gt(BN_ZERO) && bnCurrentStake.gte(new BN(minDelegatorStake)) ? EarningStatus.EARNING_REWARD : EarningStatus.NOT_EARNING;
|
|
103
104
|
bnTotalActiveStake = bnTotalActiveStake.add(bnCurrentStake);
|
|
104
105
|
const dappInfo = dAppInfoMap[dappAddress];
|
|
105
106
|
nominationList.push({
|
|
@@ -134,13 +135,13 @@ export async function subscribeAstarNominatorMetadata(chainInfo, address, substr
|
|
|
134
135
|
chain: chainInfo.slug,
|
|
135
136
|
type: StakingType.NOMINATED,
|
|
136
137
|
address,
|
|
137
|
-
status:
|
|
138
|
+
status: EarningStatus.NOT_STAKING,
|
|
138
139
|
activeStake: '0',
|
|
139
140
|
nominations: [],
|
|
140
141
|
unstakings: []
|
|
141
142
|
};
|
|
142
143
|
}
|
|
143
|
-
const stakingStatus =
|
|
144
|
+
const stakingStatus = getEarningStatusByNominations(bnTotalActiveStake, nominationList);
|
|
144
145
|
return {
|
|
145
146
|
chain: chainInfo.slug,
|
|
146
147
|
type: StakingType.NOMINATED,
|
|
@@ -185,7 +186,7 @@ export async function getAstarNominatorMetadata(chainInfo, address, substrateApi
|
|
|
185
186
|
const currentStake = stakeList.slice(-1)[0].staked.toString() || '0';
|
|
186
187
|
const bnCurrentStake = new BN(currentStake);
|
|
187
188
|
if (bnCurrentStake.gt(BN_ZERO)) {
|
|
188
|
-
const dappStakingStatus = bnCurrentStake.gt(BN_ZERO) && bnCurrentStake.gte(new BN(minDelegatorStake)) ?
|
|
189
|
+
const dappStakingStatus = bnCurrentStake.gt(BN_ZERO) && bnCurrentStake.gte(new BN(minDelegatorStake)) ? EarningStatus.EARNING_REWARD : EarningStatus.NOT_EARNING;
|
|
189
190
|
bnTotalActiveStake = bnTotalActiveStake.add(bnCurrentStake);
|
|
190
191
|
const dappInfo = dAppInfoMap[dappAddress];
|
|
191
192
|
nominationList.push({
|
|
@@ -220,13 +221,13 @@ export async function getAstarNominatorMetadata(chainInfo, address, substrateApi
|
|
|
220
221
|
chain: chainInfo.slug,
|
|
221
222
|
type: StakingType.NOMINATED,
|
|
222
223
|
address,
|
|
223
|
-
status:
|
|
224
|
+
status: EarningStatus.NOT_STAKING,
|
|
224
225
|
activeStake: '0',
|
|
225
226
|
nominations: [],
|
|
226
227
|
unstakings: []
|
|
227
228
|
};
|
|
228
229
|
}
|
|
229
|
-
const stakingStatus =
|
|
230
|
+
const stakingStatus = getEarningStatusByNominations(bnTotalActiveStake, nominationList);
|
|
230
231
|
return {
|
|
231
232
|
chain,
|
|
232
233
|
type: StakingType.NOMINATED,
|
|
@@ -10,7 +10,7 @@ export declare function getChainStakingMetadata(chainInfo: _ChainInfo, substrate
|
|
|
10
10
|
* */
|
|
11
11
|
export declare function getNominatorMetadata(chainInfo: _ChainInfo, address: string, substrateApi: _SubstrateApi): Promise<NominatorMetadata | undefined>;
|
|
12
12
|
export declare function getValidatorsInfo(networkKey: string, substrateApi: _SubstrateApi, decimals: number, chainStakingMetadata: ChainStakingMetadata): Promise<ValidatorInfo[]>;
|
|
13
|
-
export declare function getNominationPoolsInfo(chain: string, substrateApi: _SubstrateApi): Promise<import("
|
|
13
|
+
export declare function getNominationPoolsInfo(chain: string, substrateApi: _SubstrateApi): Promise<import("../../../../types").NominationPoolInfo[]>;
|
|
14
14
|
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>>;
|
|
15
15
|
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>>;
|
|
16
16
|
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,10 +6,14 @@ 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/
|
|
9
|
+
import { _STAKING_CHAIN_GROUP } from '@subwallet/extension-base/services/earning-service/constants';
|
|
10
|
+
|
|
10
11
|
// all addresses must be converted to its chain format
|
|
11
12
|
|
|
12
13
|
export function validateUnbondingCondition(nominatorMetadata, amount, chain, chainStakingMetadata, selectedValidator) {
|
|
14
|
+
if (nominatorMetadata.type === StakingType.LIQUID_STAKING) {
|
|
15
|
+
return [];
|
|
16
|
+
}
|
|
13
17
|
if (_STAKING_CHAIN_GROUP.relay.includes(chain)) {
|
|
14
18
|
return validateRelayUnbondingCondition(amount, chainStakingMetadata, nominatorMetadata);
|
|
15
19
|
}
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { TransactionError } from '@subwallet/extension-base/background/errors/TransactionError';
|
|
5
|
-
import { BasicTxErrorType,
|
|
6
|
-
import { getBondedValidators, getExistUnstakeErrorMessage, getMaxValidatorErrorMessage, getMinStakeErrorMessage, getParaCurrentInflation,
|
|
5
|
+
import { BasicTxErrorType, StakingTxErrorType, StakingType } from '@subwallet/extension-base/background/KoniTypes';
|
|
6
|
+
import { getBondedValidators, getEarningStatusByNominations, getExistUnstakeErrorMessage, getMaxValidatorErrorMessage, getMinStakeErrorMessage, getParaCurrentInflation, isUnstakeAll } 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';
|
|
9
11
|
import { isSameAddress, parseRawNumber, reformatAddress } from '@subwallet/extension-base/utils';
|
|
10
12
|
import { BN, BN_ZERO } from '@polkadot/util';
|
|
11
13
|
import { isEthereumAddress } from '@polkadot/util-crypto';
|
|
@@ -46,7 +48,7 @@ export function validateParaChainBondingCondition(chainInfo, amount, selectedCol
|
|
|
46
48
|
const minStakeErrorMessage = getMinStakeErrorMessage(chainInfo, bnMinStake);
|
|
47
49
|
const maxValidatorErrorMessage = getMaxValidatorErrorMessage(chainInfo, chainStakingMetadata.maxValidatorPerNominator);
|
|
48
50
|
const existUnstakeErrorMessage = getExistUnstakeErrorMessage(chainInfo.slug, nominatorMetadata === null || nominatorMetadata === void 0 ? void 0 : nominatorMetadata.type, true);
|
|
49
|
-
if (!nominatorMetadata || nominatorMetadata.status ===
|
|
51
|
+
if (!nominatorMetadata || nominatorMetadata.status === EarningStatus.NOT_STAKING) {
|
|
50
52
|
if (!bnTotalStake.gte(bnMinStake)) {
|
|
51
53
|
errors.push(new TransactionError(StakingTxErrorType.NOT_ENOUGH_MIN_STAKE, minStakeErrorMessage));
|
|
52
54
|
}
|
|
@@ -157,7 +159,7 @@ export async function subscribeParaChainNominatorMetadata(chainInfo, address, su
|
|
|
157
159
|
const minDelegation = collatorInfo === null || collatorInfo === void 0 ? void 0 : collatorInfo.lowestTopDelegationAmount.toString();
|
|
158
160
|
const delegationScheduledRequests = _delegationScheduledRequests.toPrimitive();
|
|
159
161
|
let hasUnstaking = false;
|
|
160
|
-
let delegationStatus =
|
|
162
|
+
let delegationStatus = EarningStatus.NOT_EARNING;
|
|
161
163
|
|
|
162
164
|
// parse unstaking info
|
|
163
165
|
if (delegationScheduledRequests) {
|
|
@@ -185,7 +187,7 @@ export async function subscribeParaChainNominatorMetadata(chainInfo, address, su
|
|
|
185
187
|
const bnUnstakeBalance = unstakingMap[delegation.owner] ? new BN(unstakingMap[delegation.owner].claimable) : BN_ZERO;
|
|
186
188
|
const bnActiveStake = bnStake.sub(bnUnstakeBalance);
|
|
187
189
|
if (bnActiveStake.gt(BN_ZERO) && bnActiveStake.gte(new BN(minDelegation))) {
|
|
188
|
-
delegationStatus =
|
|
190
|
+
delegationStatus = EarningStatus.EARNING_REWARD;
|
|
189
191
|
}
|
|
190
192
|
bnTotalActiveStake = bnTotalActiveStake.add(bnActiveStake);
|
|
191
193
|
nominationList.push({
|
|
@@ -206,7 +208,7 @@ export async function subscribeParaChainNominatorMetadata(chainInfo, address, su
|
|
|
206
208
|
// nomination.validatorMinStake = collatorInfo.lowestTopDelegationAmount.toString();
|
|
207
209
|
// }));
|
|
208
210
|
|
|
209
|
-
const stakingStatus =
|
|
211
|
+
const stakingStatus = getEarningStatusByNominations(bnTotalActiveStake, nominationList);
|
|
210
212
|
return {
|
|
211
213
|
chain: chainInfo.slug,
|
|
212
214
|
type: StakingType.NOMINATED,
|
|
@@ -236,7 +238,7 @@ export async function getParaChainNominatorMetadata(chainInfo, address, substrat
|
|
|
236
238
|
chain: chainInfo.slug,
|
|
237
239
|
type: StakingType.NOMINATED,
|
|
238
240
|
address,
|
|
239
|
-
status:
|
|
241
|
+
status: EarningStatus.NOT_STAKING,
|
|
240
242
|
activeStake: '0',
|
|
241
243
|
nominations: [],
|
|
242
244
|
unstakings: []
|
|
@@ -251,7 +253,7 @@ export async function getParaChainNominatorMetadata(chainInfo, address, substrat
|
|
|
251
253
|
const delegationScheduledRequests = _delegationScheduledRequests.toPrimitive();
|
|
252
254
|
const currentRound = roundInfo.current;
|
|
253
255
|
let hasUnstaking = false;
|
|
254
|
-
let delegationStatus =
|
|
256
|
+
let delegationStatus = EarningStatus.NOT_EARNING;
|
|
255
257
|
|
|
256
258
|
// parse unstaking info
|
|
257
259
|
if (delegationScheduledRequests) {
|
|
@@ -279,7 +281,7 @@ export async function getParaChainNominatorMetadata(chainInfo, address, substrat
|
|
|
279
281
|
const bnUnstakeBalance = unstakingMap[delegation.owner] ? new BN(unstakingMap[delegation.owner].claimable) : BN_ZERO;
|
|
280
282
|
const bnActiveStake = bnStake.sub(bnUnstakeBalance);
|
|
281
283
|
if (bnActiveStake.gt(BN_ZERO) && bnActiveStake.gte(new BN(minDelegation))) {
|
|
282
|
-
delegationStatus =
|
|
284
|
+
delegationStatus = EarningStatus.EARNING_REWARD;
|
|
283
285
|
}
|
|
284
286
|
bnTotalActiveStake = bnTotalActiveStake.add(bnActiveStake);
|
|
285
287
|
nominationList.push({
|
|
@@ -296,7 +298,7 @@ export async function getParaChainNominatorMetadata(chainInfo, address, substrat
|
|
|
296
298
|
const collatorInfo = _collatorInfo.toPrimitive();
|
|
297
299
|
nomination.validatorMinStake = collatorInfo.lowestTopDelegationAmount.toString();
|
|
298
300
|
}));
|
|
299
|
-
const stakingStatus =
|
|
301
|
+
const stakingStatus = getEarningStatusByNominations(bnTotalActiveStake, nominationList);
|
|
300
302
|
return {
|
|
301
303
|
chain,
|
|
302
304
|
type: StakingType.NOMINATED,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { _ChainInfo } from '@subwallet/chain-list/types';
|
|
2
2
|
import { TransactionError } from '@subwallet/extension-base/background/errors/TransactionError';
|
|
3
|
-
import { ChainStakingMetadata,
|
|
4
|
-
import { PalletNominationPoolsPoolMember } from '@subwallet/extension-base/koni/api/staking/bonding/utils';
|
|
3
|
+
import { ChainStakingMetadata, NominatorMetadata, UnstakingInfo, ValidatorInfo } from '@subwallet/extension-base/background/KoniTypes';
|
|
5
4
|
import { _SubstrateApi } from '@subwallet/extension-base/services/chain-service/types';
|
|
5
|
+
import { NominationPoolInfo, PalletNominationPoolsPoolMember } from '@subwallet/extension-base/types';
|
|
6
6
|
import { Codec } from '@polkadot/types/types';
|
|
7
7
|
export interface PalletStakingNominations {
|
|
8
8
|
targets: string[];
|