@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
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import BaseMigrationJob from '@subwallet/extension-base/services/migration-service/Base';
|
|
5
|
+
export default class MigrateEarningVersion extends BaseMigrationJob {
|
|
6
|
+
async run() {
|
|
7
|
+
try {
|
|
8
|
+
await this.state.dbService.removeOldEarningData();
|
|
9
|
+
} catch (e) {
|
|
10
|
+
console.error(e);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
+
import DeleteEarningData from '@subwallet/extension-base/services/migration-service/scripts/DeleteEarningData';
|
|
5
|
+
import EnableEarningChains from '@subwallet/extension-base/services/migration-service/scripts/EnableEarningChains';
|
|
6
|
+
import MigrateEarningVersion from "./databases/MigrateEarningVersion.js";
|
|
4
7
|
import MigrateEthProvider from "./providers/MigrateEthProvider.js";
|
|
5
8
|
import MigratePioneerProvider from "./providers/MigratePioneerProvider.js";
|
|
6
9
|
import MigrateProvidersV1M1P24 from "./providers/MigrateProvidersV1M1P24.js";
|
|
@@ -33,9 +36,12 @@ export default {
|
|
|
33
36
|
'1.1.6-01': MigrateWalletReference,
|
|
34
37
|
'1.1.7': DeleteChain,
|
|
35
38
|
'1.1.13-01': MigrateTokenDecimals,
|
|
39
|
+
'1.1.13-02': EnableEarningChains,
|
|
40
|
+
'1.1.13-03': DeleteEarningData,
|
|
36
41
|
'1.1.17-01': MigratePioneerProvider,
|
|
37
42
|
'1.1.17-03': EnableVaraChain,
|
|
38
43
|
'1.1.24-01': MigrateProvidersV1M1P24,
|
|
39
|
-
'1.1.26-01': MigratePolygonUSDCProvider
|
|
44
|
+
'1.1.26-01': MigratePolygonUSDCProvider,
|
|
45
|
+
'1.1.28-01': MigrateEarningVersion
|
|
40
46
|
// [`${EVERYTIME}-1`]: AutoEnableChainsTokens
|
|
41
47
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import KoniState from '@subwallet/extension-base/koni/background/handlers/State';
|
|
2
|
+
import { UnlockDotSubmitMintData, UnlockDotTransactionNft } from '@subwallet/extension-base/types';
|
|
3
|
+
export default class UnlockDotCampaign {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(state: KoniState);
|
|
6
|
+
mintNft({ address, extrinsicHash, network, slug, transactionId }: UnlockDotSubmitMintData): Promise<void>;
|
|
7
|
+
private checkMint;
|
|
8
|
+
private submitNft;
|
|
9
|
+
private getMinted;
|
|
10
|
+
canMint(address: string, slug: string, network: string): Promise<boolean>;
|
|
11
|
+
subscribeMintedNft(transactionId: string, cb: (data: UnlockDotTransactionNft) => void): import("rxjs").Subscription;
|
|
12
|
+
getMintedNft(transactionId: string): UnlockDotTransactionNft;
|
|
13
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { isSameAddress } from '@subwallet/extension-base/utils';
|
|
5
|
+
import axios from 'axios';
|
|
6
|
+
import { BehaviorSubject } from 'rxjs';
|
|
7
|
+
import { MINT_HOST } from "../constants.js";
|
|
8
|
+
export default class UnlockDotCampaign {
|
|
9
|
+
#host = MINT_HOST;
|
|
10
|
+
#campaignId = 4;
|
|
11
|
+
#state;
|
|
12
|
+
#transactionNftSubject = new BehaviorSubject({});
|
|
13
|
+
#transactionNftState = {};
|
|
14
|
+
constructor(state) {
|
|
15
|
+
this.#state = state;
|
|
16
|
+
}
|
|
17
|
+
async mintNft({
|
|
18
|
+
address,
|
|
19
|
+
extrinsicHash,
|
|
20
|
+
network,
|
|
21
|
+
slug,
|
|
22
|
+
transactionId
|
|
23
|
+
}) {
|
|
24
|
+
var _result;
|
|
25
|
+
this.#transactionNftState[transactionId] = undefined;
|
|
26
|
+
this.#transactionNftSubject.next(this.#transactionNftState);
|
|
27
|
+
const requestId = await this.checkMint({
|
|
28
|
+
address,
|
|
29
|
+
extrinsicHash,
|
|
30
|
+
network,
|
|
31
|
+
slug
|
|
32
|
+
});
|
|
33
|
+
let result;
|
|
34
|
+
if (requestId) {
|
|
35
|
+
result = await this.submitNft(address, requestId);
|
|
36
|
+
await this.#state.reloadNft();
|
|
37
|
+
// } else {
|
|
38
|
+
// result = await this.getMinted(address, slug);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
this.#transactionNftState[transactionId] = (_result = result) !== null && _result !== void 0 ? _result : {
|
|
42
|
+
nftImage: ''
|
|
43
|
+
};
|
|
44
|
+
this.#transactionNftSubject.next(this.#transactionNftState);
|
|
45
|
+
}
|
|
46
|
+
async checkMint({
|
|
47
|
+
address,
|
|
48
|
+
extrinsicHash,
|
|
49
|
+
network,
|
|
50
|
+
slug
|
|
51
|
+
}) {
|
|
52
|
+
const data = {
|
|
53
|
+
address,
|
|
54
|
+
campaignId: this.#campaignId,
|
|
55
|
+
category: slug,
|
|
56
|
+
additionalData: {
|
|
57
|
+
slug,
|
|
58
|
+
extrinsicHash,
|
|
59
|
+
network
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const response = await axios.request({
|
|
63
|
+
baseURL: this.#host,
|
|
64
|
+
url: '/api/mint/check',
|
|
65
|
+
method: 'POST',
|
|
66
|
+
data
|
|
67
|
+
});
|
|
68
|
+
const respData = response.data;
|
|
69
|
+
if (respData.inMintingTime && respData.hasBalance && respData.validCampaign && respData.validCategory && respData.validUser && respData.notDuplicated && respData.requestId && respData.requestId > 1) {
|
|
70
|
+
return respData.requestId;
|
|
71
|
+
}
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
async submitNft(address, id) {
|
|
75
|
+
const data = {
|
|
76
|
+
requestId: id,
|
|
77
|
+
recipient: address
|
|
78
|
+
};
|
|
79
|
+
const response = await axios.request({
|
|
80
|
+
baseURL: this.#host,
|
|
81
|
+
url: '/api/mint/submit',
|
|
82
|
+
method: 'POST',
|
|
83
|
+
data
|
|
84
|
+
});
|
|
85
|
+
return response.data;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// @ts-ignore
|
|
89
|
+
async getMinted(address, slug) {
|
|
90
|
+
const params = {
|
|
91
|
+
address
|
|
92
|
+
};
|
|
93
|
+
const response = await axios.request({
|
|
94
|
+
baseURL: this.#host,
|
|
95
|
+
url: '/api/mint/fetch',
|
|
96
|
+
method: 'GET',
|
|
97
|
+
params: params
|
|
98
|
+
});
|
|
99
|
+
const data = response.data;
|
|
100
|
+
for (const item of data) {
|
|
101
|
+
if (isSameAddress(item.address, address) && slug === item.mintCategory && item.status === 'success' && item.campaignId === this.#campaignId) {
|
|
102
|
+
return item;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return undefined;
|
|
106
|
+
}
|
|
107
|
+
async canMint(address, slug, network) {
|
|
108
|
+
const data = {
|
|
109
|
+
address,
|
|
110
|
+
campaignId: this.#campaignId,
|
|
111
|
+
category: slug,
|
|
112
|
+
additionalData: {
|
|
113
|
+
slug,
|
|
114
|
+
network
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
const response = await axios.request({
|
|
118
|
+
baseURL: this.#host,
|
|
119
|
+
url: '/api/mint/check',
|
|
120
|
+
method: 'POST',
|
|
121
|
+
data
|
|
122
|
+
});
|
|
123
|
+
const respData = response.data;
|
|
124
|
+
if (respData.inMintingTime && respData.validCampaign && respData.validCategory && respData.validUser && respData.notDuplicated) {
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
subscribeMintedNft(transactionId, cb) {
|
|
130
|
+
return this.#transactionNftSubject.subscribe({
|
|
131
|
+
next: map => {
|
|
132
|
+
cb(map[transactionId]);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
getMintedNft(transactionId) {
|
|
137
|
+
return this.#transactionNftSubject.value[transactionId];
|
|
138
|
+
}
|
|
139
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as UnlockDotCampaign } from './UnlockDotCampaign';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const MINT_HOST: string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import KoniState from '@subwallet/extension-base/koni/background/handlers/State';
|
|
2
|
+
import { UnlockDotCampaign } from './campaigns';
|
|
3
|
+
export default class MintCampaignService {
|
|
4
|
+
#private;
|
|
5
|
+
readonly unlockDotCampaign: UnlockDotCampaign;
|
|
6
|
+
constructor(state: KoniState);
|
|
7
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Copyright 2019-2022 @polkadot/extension-base authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { UnlockDotCampaign } from "./campaigns/index.js";
|
|
5
|
+
export default class MintCampaignService {
|
|
6
|
+
#state;
|
|
7
|
+
constructor(state) {
|
|
8
|
+
this.#state = state;
|
|
9
|
+
this.unlockDotCampaign = new UnlockDotCampaign(this.#state);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -8,7 +8,9 @@ import ChainStakingMetadataStore from '@subwallet/extension-base/services/storag
|
|
|
8
8
|
import MantaPayStore from '@subwallet/extension-base/services/storage-service/db-stores/MantaPay';
|
|
9
9
|
import NominatorMetadataStore from '@subwallet/extension-base/services/storage-service/db-stores/NominatorMetadata';
|
|
10
10
|
import { HistoryQuery } from '@subwallet/extension-base/services/storage-service/db-stores/Transaction';
|
|
11
|
-
import
|
|
11
|
+
import YieldPoolStore from '@subwallet/extension-base/services/storage-service/db-stores/YieldPoolStore';
|
|
12
|
+
import YieldPositionStore from '@subwallet/extension-base/services/storage-service/db-stores/YieldPositionStore';
|
|
13
|
+
import { BalanceItem, YieldPoolInfo, YieldPoolType, YieldPositionInfo } from '@subwallet/extension-base/types';
|
|
12
14
|
import { Subscription } from 'dexie';
|
|
13
15
|
import { DexieExportJsonStructure } from 'dexie-export-import';
|
|
14
16
|
export declare const DEXIE_BACKUP_TABLES: string[];
|
|
@@ -27,6 +29,8 @@ export default class DatabaseService {
|
|
|
27
29
|
metadata: MetadataStore;
|
|
28
30
|
chain: ChainStore;
|
|
29
31
|
asset: AssetStore;
|
|
32
|
+
yieldPoolInfo: YieldPoolStore;
|
|
33
|
+
yieldPosition: YieldPositionStore;
|
|
30
34
|
chainStakingMetadata: ChainStakingMetadataStore;
|
|
31
35
|
nominatorMetadata: NominatorMetadataStore;
|
|
32
36
|
mantaPay: MantaPayStore;
|
|
@@ -35,6 +39,7 @@ export default class DatabaseService {
|
|
|
35
39
|
private logger;
|
|
36
40
|
private nftSubscription;
|
|
37
41
|
private stakingSubscription;
|
|
42
|
+
private yieldInfoSubscription;
|
|
38
43
|
constructor(eventService: EventService);
|
|
39
44
|
updatePriceStore(priceData: PriceJson): Promise<void>;
|
|
40
45
|
getPriceStore(): Promise<PriceJson | undefined>;
|
|
@@ -83,6 +88,18 @@ export default class DatabaseService {
|
|
|
83
88
|
subscribeMantaPayConfig(chain: string, callback: (data: MantaPayConfig[]) => void): void;
|
|
84
89
|
getMantaPayConfig(chain: string): Promise<any[]>;
|
|
85
90
|
getMantaPayFirstConfig(chain: string): Promise<any>;
|
|
91
|
+
removeOldEarningData(): Promise<void>;
|
|
92
|
+
updateYieldPoolStore(data: YieldPoolInfo): Promise<void>;
|
|
93
|
+
deleteYieldPoolInfo(slugs: string[]): Promise<void>;
|
|
94
|
+
getYieldPools(): Promise<YieldPoolInfo[]>;
|
|
95
|
+
getYieldPoolStakingInfo(chain: string, poolType: YieldPoolType): Promise<YieldPoolInfo | undefined>;
|
|
96
|
+
getYieldPool(slug: string): Promise<YieldPoolInfo | undefined>;
|
|
97
|
+
getYieldPositionByAddressAndSlug(address: string, slug: string): Promise<YieldPositionInfo | undefined>;
|
|
98
|
+
subscribeYieldPoolInfo(chains: string[], callback: (data: YieldPoolInfo[]) => void): Subscription;
|
|
99
|
+
updateYieldPosition(data: YieldPositionInfo): Promise<void>;
|
|
100
|
+
getYieldPositionByAddress(addresses: string[]): Promise<YieldPositionInfo[]>;
|
|
101
|
+
subscribeYieldPosition(addresses: string[], callback: (data: YieldPositionInfo[]) => void): Subscription;
|
|
102
|
+
getYieldNominationPoolPosition(addresses: string[], chains: string[]): Promise<YieldPositionInfo[]>;
|
|
86
103
|
subscribeProcessingCampaign(): import("dexie").Observable<import("@subwallet/extension-base/background/KoniTypes").CampaignData[]>;
|
|
87
104
|
getProcessingCampaign(): Promise<import("@subwallet/extension-base/background/KoniTypes").CampaignData[]>;
|
|
88
105
|
getCampaign(slug: string): Promise<import("@subwallet/extension-base/background/KoniTypes").CampaignData | undefined>;
|
|
@@ -8,6 +8,8 @@ import CampaignStore from '@subwallet/extension-base/services/storage-service/db
|
|
|
8
8
|
import ChainStakingMetadataStore from '@subwallet/extension-base/services/storage-service/db-stores/ChainStakingMetadata';
|
|
9
9
|
import MantaPayStore from '@subwallet/extension-base/services/storage-service/db-stores/MantaPay';
|
|
10
10
|
import NominatorMetadataStore from '@subwallet/extension-base/services/storage-service/db-stores/NominatorMetadata';
|
|
11
|
+
import YieldPoolStore from '@subwallet/extension-base/services/storage-service/db-stores/YieldPoolStore';
|
|
12
|
+
import YieldPositionStore from '@subwallet/extension-base/services/storage-service/db-stores/YieldPositionStore';
|
|
11
13
|
import { reformatAddress } from '@subwallet/extension-base/utils';
|
|
12
14
|
import { exportDB } from 'dexie-export-import';
|
|
13
15
|
import { logger as createLogger } from '@polkadot/util';
|
|
@@ -34,6 +36,9 @@ export default class DatabaseService {
|
|
|
34
36
|
metadata: new MetadataStore(this._db.metadata),
|
|
35
37
|
chain: new ChainStore(this._db.chain),
|
|
36
38
|
asset: new AssetStore(this._db.asset),
|
|
39
|
+
// yield
|
|
40
|
+
yieldPoolInfo: new YieldPoolStore(this._db.yieldPoolInfo),
|
|
41
|
+
yieldPosition: new YieldPositionStore(this._db.yieldPosition),
|
|
37
42
|
// staking
|
|
38
43
|
chainStakingMetadata: new ChainStakingMetadataStore(this._db.chainStakingMetadata),
|
|
39
44
|
nominatorMetadata: new NominatorMetadataStore(this._db.nominatorMetadata),
|
|
@@ -272,6 +277,52 @@ export default class DatabaseService {
|
|
|
272
277
|
return this.stores.mantaPay.getFirstConfig(chain);
|
|
273
278
|
}
|
|
274
279
|
|
|
280
|
+
/* Earning */
|
|
281
|
+
|
|
282
|
+
async removeOldEarningData() {
|
|
283
|
+
await this.stores.yieldPoolInfo.clear();
|
|
284
|
+
await this.stores.yieldPosition.clear();
|
|
285
|
+
}
|
|
286
|
+
async updateYieldPoolStore(data) {
|
|
287
|
+
await this.stores.yieldPoolInfo.upsert(data);
|
|
288
|
+
}
|
|
289
|
+
async deleteYieldPoolInfo(slugs) {
|
|
290
|
+
await this.stores.yieldPoolInfo.bulkDelete(slugs);
|
|
291
|
+
}
|
|
292
|
+
async getYieldPools() {
|
|
293
|
+
return this.stores.yieldPoolInfo.getAll();
|
|
294
|
+
}
|
|
295
|
+
async getYieldPoolStakingInfo(chain, poolType) {
|
|
296
|
+
return this.stores.yieldPoolInfo.getByChainAndType(chain, poolType);
|
|
297
|
+
}
|
|
298
|
+
async getYieldPool(slug) {
|
|
299
|
+
return this.stores.yieldPoolInfo.getBySlug(slug);
|
|
300
|
+
}
|
|
301
|
+
async getYieldPositionByAddressAndSlug(address, slug) {
|
|
302
|
+
return this.stores.yieldPosition.getByAddressAndSlug(address, slug);
|
|
303
|
+
}
|
|
304
|
+
subscribeYieldPoolInfo(chains, callback) {
|
|
305
|
+
this.yieldInfoSubscription && this.yieldInfoSubscription.unsubscribe();
|
|
306
|
+
this.yieldInfoSubscription = this.stores.yieldPoolInfo.subscribeYieldPoolInfo(chains).subscribe({
|
|
307
|
+
next: data => callback && callback(data)
|
|
308
|
+
});
|
|
309
|
+
return this.yieldInfoSubscription;
|
|
310
|
+
}
|
|
311
|
+
async updateYieldPosition(data) {
|
|
312
|
+
await this.stores.yieldPosition.upsert(data);
|
|
313
|
+
}
|
|
314
|
+
async getYieldPositionByAddress(addresses) {
|
|
315
|
+
return this.stores.yieldPosition.getByAddress(addresses);
|
|
316
|
+
}
|
|
317
|
+
subscribeYieldPosition(addresses, callback) {
|
|
318
|
+
return this.stores.yieldPosition.subscribeYieldPositions(addresses).subscribe({
|
|
319
|
+
next: data => callback && callback(data)
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
async getYieldNominationPoolPosition(addresses, chains) {
|
|
323
|
+
return this.stores.yieldPosition.getByAddressAndChains(addresses, chains);
|
|
324
|
+
}
|
|
325
|
+
|
|
275
326
|
/* Campaign */
|
|
276
327
|
|
|
277
328
|
subscribeProcessingCampaign() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { _ChainAsset, _ChainInfo } from '@subwallet/chain-list/types';
|
|
2
2
|
import { CampaignData, ChainStakingMetadata, CrowdloanItem, MetadataItem, NftCollection, NftItem, NominatorMetadata, PriceJson, StakingItem, TransactionHistoryItem } from '@subwallet/extension-base/background/KoniTypes';
|
|
3
|
-
import { BalanceItem } from '@subwallet/extension-base/types';
|
|
3
|
+
import { BalanceItem, YieldPoolInfo, YieldPositionInfo } from '@subwallet/extension-base/types';
|
|
4
4
|
import Dexie, { Table } from 'dexie';
|
|
5
5
|
export interface DefaultChainDoc {
|
|
6
6
|
chain: string;
|
|
@@ -45,6 +45,8 @@ export default class KoniDatabase extends Dexie {
|
|
|
45
45
|
asset: Table<_ChainAsset, object>;
|
|
46
46
|
chainStakingMetadata: Table<ChainStakingMetadata, object>;
|
|
47
47
|
nominatorMetadata: Table<NominatorMetadata, object>;
|
|
48
|
+
yieldPoolInfo: Table<YieldPoolInfo, object>;
|
|
49
|
+
yieldPosition: Table<YieldPositionInfo, object>;
|
|
48
50
|
mantaPay: Table<IMantaPayLedger, object>;
|
|
49
51
|
campaign: Table<ICampaign, object>;
|
|
50
52
|
private schemaVersion;
|
|
@@ -31,6 +31,10 @@ export default class KoniDatabase extends Dexie {
|
|
|
31
31
|
mantaPay: 'key, chain'
|
|
32
32
|
});
|
|
33
33
|
this.conditionalVersion(4, {
|
|
34
|
+
yieldPoolInfo: 'slug, chain, type',
|
|
35
|
+
yieldPosition: '[slug+chain+address], [address+slug], address, chain'
|
|
36
|
+
});
|
|
37
|
+
this.conditionalVersion(5, {
|
|
34
38
|
campaign: 'slug'
|
|
35
39
|
});
|
|
36
40
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { StakingStatus } from '@subwallet/extension-base/background/KoniTypes';
|
|
5
4
|
import BaseStoreWithAddressAndChain from '@subwallet/extension-base/services/storage-service/db-stores/BaseStoreWithAddressAndChain';
|
|
5
|
+
import { EarningStatus } from '@subwallet/extension-base/types';
|
|
6
6
|
import { liveQuery } from 'dexie';
|
|
7
7
|
export default class NominatorMetadataStore extends BaseStoreWithAddressAndChain {
|
|
8
8
|
async getAll() {
|
|
9
|
-
return this.table.filter(item => item.status !==
|
|
9
|
+
return this.table.filter(item => item.status !== EarningStatus.NOT_STAKING).toArray();
|
|
10
10
|
}
|
|
11
11
|
subscribeByAddresses(addresses) {
|
|
12
12
|
return liveQuery(() => this.getByAddress(addresses));
|
|
@@ -15,7 +15,7 @@ export default class NominatorMetadataStore extends BaseStoreWithAddressAndChain
|
|
|
15
15
|
return liveQuery(() => this.getAll());
|
|
16
16
|
}
|
|
17
17
|
getByAddress(addresses) {
|
|
18
|
-
return this.table.where('address').anyOfIgnoreCase(addresses).and(item => item.status !==
|
|
18
|
+
return this.table.where('address').anyOfIgnoreCase(addresses).and(item => item.status !== EarningStatus.NOT_STAKING).toArray();
|
|
19
19
|
}
|
|
20
20
|
async removeByAddress(address) {
|
|
21
21
|
return this.table.where('address').anyOfIgnoreCase(address).delete();
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import BaseStore from '@subwallet/extension-base/services/storage-service/db-stores/BaseStore';
|
|
2
|
+
import { YieldPoolInfo, YieldPoolType } from '@subwallet/extension-base/types';
|
|
3
|
+
export default class YieldPoolStore extends BaseStore<YieldPoolInfo> {
|
|
4
|
+
getAll(): Promise<YieldPoolInfo[]>;
|
|
5
|
+
getByChains(chains: string[]): Promise<YieldPoolInfo[]>;
|
|
6
|
+
getByChainAndType(chain: string, poolType: YieldPoolType): Promise<YieldPoolInfo | undefined>;
|
|
7
|
+
bulkDelete(slugs: string[]): Promise<void>;
|
|
8
|
+
getBySlug(slug: string): Promise<YieldPoolInfo | undefined>;
|
|
9
|
+
subscribeYieldPoolInfo(chains: string[]): import("dexie").Observable<YieldPoolInfo[]>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import BaseStore from '@subwallet/extension-base/services/storage-service/db-stores/BaseStore';
|
|
5
|
+
import { liveQuery } from 'dexie';
|
|
6
|
+
export default class YieldPoolStore extends BaseStore {
|
|
7
|
+
async getAll() {
|
|
8
|
+
return this.table.toArray();
|
|
9
|
+
}
|
|
10
|
+
async getByChains(chains) {
|
|
11
|
+
if (chains.length === 0) {
|
|
12
|
+
return this.getAll();
|
|
13
|
+
}
|
|
14
|
+
return this.table.where('chain').anyOfIgnoreCase(chains).toArray();
|
|
15
|
+
}
|
|
16
|
+
async getByChainAndType(chain, poolType) {
|
|
17
|
+
return this.table.where('chain').equals(chain).and(item => item.type === poolType).first();
|
|
18
|
+
}
|
|
19
|
+
async bulkDelete(slugs) {
|
|
20
|
+
return this.table.bulkDelete(slugs);
|
|
21
|
+
}
|
|
22
|
+
async getBySlug(slug) {
|
|
23
|
+
return this.table.get(slug);
|
|
24
|
+
}
|
|
25
|
+
subscribeYieldPoolInfo(chains) {
|
|
26
|
+
return liveQuery(() => this.getByChains(chains));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import BaseStore from '@subwallet/extension-base/services/storage-service/db-stores/BaseStore';
|
|
2
|
+
import { YieldPositionInfo } from '@subwallet/extension-base/types';
|
|
3
|
+
export default class YieldPositionStore extends BaseStore<YieldPositionInfo> {
|
|
4
|
+
getAll(): Promise<YieldPositionInfo[]>;
|
|
5
|
+
getByAddress(addresses: string[]): Promise<YieldPositionInfo[]>;
|
|
6
|
+
getByAddressAndChains(addresses: string[], chains: string[]): Promise<YieldPositionInfo[]>;
|
|
7
|
+
getByAddressAndSlug(address: string, slug: string): import("dexie").PromiseExtended<YieldPositionInfo | undefined>;
|
|
8
|
+
subscribeYieldPositions(addresses: string[]): import("dexie").Observable<YieldPositionInfo[]>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import BaseStore from '@subwallet/extension-base/services/storage-service/db-stores/BaseStore';
|
|
5
|
+
import { liveQuery } from 'dexie';
|
|
6
|
+
export default class YieldPositionStore extends BaseStore {
|
|
7
|
+
async getAll() {
|
|
8
|
+
return this.table
|
|
9
|
+
// .filter((item) => {
|
|
10
|
+
// let isValidLiquidStaking = false;
|
|
11
|
+
//
|
|
12
|
+
// if (item.type === YieldPoolType.LIQUID_STAKING) {
|
|
13
|
+
// const nominatorMetadata = item.metadata as NominatorMetadata;
|
|
14
|
+
//
|
|
15
|
+
// if (nominatorMetadata.unstakings.length > 0) {
|
|
16
|
+
// console.log('true', item);
|
|
17
|
+
// isValidLiquidStaking = true;
|
|
18
|
+
// }
|
|
19
|
+
// }
|
|
20
|
+
//
|
|
21
|
+
// return parseInt(item.balance[0].activeBalance) > 0 || isValidLiquidStaking;
|
|
22
|
+
// })
|
|
23
|
+
.toArray();
|
|
24
|
+
}
|
|
25
|
+
async getByAddress(addresses) {
|
|
26
|
+
if (addresses.length === 0) {
|
|
27
|
+
return this.getAll();
|
|
28
|
+
}
|
|
29
|
+
return this.table.where('address').anyOfIgnoreCase(addresses)
|
|
30
|
+
// .filter((item) => {
|
|
31
|
+
// let isValidLiquidStaking = false;
|
|
32
|
+
//
|
|
33
|
+
// if (item.type === YieldPoolType.LIQUID_STAKING) {
|
|
34
|
+
// const nominatorMetadata = item.metadata as NominatorMetadata;
|
|
35
|
+
//
|
|
36
|
+
// if (nominatorMetadata && nominatorMetadata?.unstakings?.length > 0) {
|
|
37
|
+
// isValidLiquidStaking = true;
|
|
38
|
+
// }
|
|
39
|
+
// }
|
|
40
|
+
//
|
|
41
|
+
// return parseInt(item.balance[0].activeBalance) > 0 || isValidLiquidStaking;
|
|
42
|
+
// })
|
|
43
|
+
.toArray();
|
|
44
|
+
}
|
|
45
|
+
async getByAddressAndChains(addresses, chains) {
|
|
46
|
+
return this.table.where('address').anyOfIgnoreCase(addresses).filter(item => chains.includes(item.chain)).toArray();
|
|
47
|
+
}
|
|
48
|
+
getByAddressAndSlug(address, slug) {
|
|
49
|
+
return this.table.get({
|
|
50
|
+
address,
|
|
51
|
+
slug
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
subscribeYieldPositions(addresses) {
|
|
55
|
+
return liveQuery(() => this.getByAddress(addresses));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CrowdloanContributionsResponse, ExtrinsicItem, ExtrinsicsListResponse, IMultiChainBalance, RequestBlockRange, TransferItem, TransfersListResponse } from '@subwallet/extension-base/services/subscan-service/types';
|
|
1
|
+
import { CrowdloanContributionsResponse, ExtrinsicItem, ExtrinsicsListResponse, IMultiChainBalance, RequestBlockRange, SubscanRequest, TransferItem, TransfersListResponse } from '@subwallet/extension-base/services/subscan-service/types';
|
|
2
2
|
export declare class SubscanService {
|
|
3
3
|
private subscanChainMap;
|
|
4
4
|
private limitRate;
|
|
@@ -15,7 +15,7 @@ export declare class SubscanService {
|
|
|
15
15
|
});
|
|
16
16
|
private getApiUrl;
|
|
17
17
|
private postRequest;
|
|
18
|
-
|
|
18
|
+
addRequest<T>(run: SubscanRequest<T>['run']): Promise<T>;
|
|
19
19
|
private process;
|
|
20
20
|
checkSupportedSubscanChain(chain: string): boolean;
|
|
21
21
|
setSubscanChainMap(subscanChainMap: Record<string, string>): void;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { _ChainAsset, _ChainInfo } from '@subwallet/chain-list/types';
|
|
2
|
-
import { TransactionHistoryItem } from '@subwallet/extension-base/background/KoniTypes';
|
|
2
|
+
import { ExtrinsicType, TransactionHistoryItem } from '@subwallet/extension-base/background/KoniTypes';
|
|
3
3
|
import { EventRecord } from '@polkadot/types/interfaces';
|
|
4
4
|
export declare function parseXcmEventLogs(historyItem: Partial<TransactionHistoryItem>, eventLogs: EventRecord[], chain: string, sendingTokenInfo: _ChainAsset, chainInfo: _ChainInfo): void;
|
|
5
5
|
export declare function parseTransferEventLogs(historyItem: Partial<TransactionHistoryItem>, eventLogs: EventRecord[], chain: string, sendingTokenInfo: _ChainAsset, chainInfo: _ChainInfo): void;
|
|
6
|
+
export declare function parseLiquidStakingEvents(historyItem: Partial<TransactionHistoryItem>, eventLogs: EventRecord[], inputTokenInfo: _ChainAsset, chainInfo: _ChainInfo, feePaidWithInputAsset: boolean, extrinsicType: ExtrinsicType): void;
|
|
7
|
+
export declare function parseLiquidStakingFastUnstakeEvents(historyItem: Partial<TransactionHistoryItem>, eventLogs: EventRecord[], chainInfo: _ChainInfo, extrinsicType: ExtrinsicType): void;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
|
|
5
|
+
import { _getAssetDecimals, _getAssetSymbol, _getChainNativeTokenBasicInfo } from '@subwallet/extension-base/services/chain-service/utils';
|
|
5
6
|
export function parseXcmEventLogs(historyItem, eventLogs, chain, sendingTokenInfo, chainInfo) {
|
|
6
7
|
for (let index = 0; index < eventLogs.length; index++) {
|
|
7
8
|
const record = eventLogs[index];
|
|
@@ -65,4 +66,59 @@ export function parseTransferEventLogs(historyItem, eventLogs, chain, sendingTok
|
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
68
|
}
|
|
69
|
+
}
|
|
70
|
+
export function parseLiquidStakingEvents(historyItem, eventLogs, inputTokenInfo, chainInfo, feePaidWithInputAsset, extrinsicType) {
|
|
71
|
+
if (feePaidWithInputAsset) {
|
|
72
|
+
historyItem.fee = {
|
|
73
|
+
value: '0',
|
|
74
|
+
// TODO
|
|
75
|
+
symbol: _getAssetSymbol(inputTokenInfo),
|
|
76
|
+
decimals: _getAssetDecimals(inputTokenInfo)
|
|
77
|
+
};
|
|
78
|
+
} else {
|
|
79
|
+
for (let index = 0; index < eventLogs.length; index++) {
|
|
80
|
+
const record = eventLogs[index];
|
|
81
|
+
const {
|
|
82
|
+
decimals: nativeDecimals,
|
|
83
|
+
symbol: nativeSymbol
|
|
84
|
+
} = _getChainNativeTokenBasicInfo(chainInfo);
|
|
85
|
+
const section = extrinsicType === ExtrinsicType.REDEEM_QDOT ? 'tokens' : 'balances';
|
|
86
|
+
const eventMethod = extrinsicType === ExtrinsicType.REDEEM_QDOT ? 'withdrawn' : 'withdraw';
|
|
87
|
+
if (record.event.section === section && record.event.method.toLowerCase() === eventMethod) {
|
|
88
|
+
var _record$event$data$9;
|
|
89
|
+
if ((_record$event$data$9 = record.event.data[2]) !== null && _record$event$data$9 !== void 0 && _record$event$data$9.toString()) {
|
|
90
|
+
var _record$event$data$10;
|
|
91
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
92
|
+
historyItem.fee = {
|
|
93
|
+
value: ((_record$event$data$10 = record.event.data[2]) === null || _record$event$data$10 === void 0 ? void 0 : _record$event$data$10.toString()) || '0',
|
|
94
|
+
symbol: nativeSymbol,
|
|
95
|
+
decimals: nativeDecimals
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
export function parseLiquidStakingFastUnstakeEvents(historyItem, eventLogs, chainInfo, extrinsicType) {
|
|
103
|
+
for (let index = 0; index < eventLogs.length; index++) {
|
|
104
|
+
const record = eventLogs[index];
|
|
105
|
+
const {
|
|
106
|
+
decimals: nativeDecimals,
|
|
107
|
+
symbol: nativeSymbol
|
|
108
|
+
} = _getChainNativeTokenBasicInfo(chainInfo);
|
|
109
|
+
const section = extrinsicType === ExtrinsicType.REDEEM_QDOT ? 'tokens' : 'balances';
|
|
110
|
+
const eventMethod = extrinsicType === ExtrinsicType.REDEEM_QDOT ? 'withdrawn' : 'withdraw';
|
|
111
|
+
if (record.event.section === section && record.event.method.toLowerCase() === eventMethod) {
|
|
112
|
+
var _record$event$data$11;
|
|
113
|
+
if ((_record$event$data$11 = record.event.data[2]) !== null && _record$event$data$11 !== void 0 && _record$event$data$11.toString()) {
|
|
114
|
+
var _record$event$data$12;
|
|
115
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
116
|
+
historyItem.fee = {
|
|
117
|
+
value: ((_record$event$data$12 = record.event.data[2]) === null || _record$event$data$12 === void 0 ? void 0 : _record$event$data$12.toString()) || '0',
|
|
118
|
+
symbol: nativeSymbol,
|
|
119
|
+
decimals: nativeDecimals
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
68
124
|
}
|
|
@@ -30,7 +30,7 @@ const typeName = type => {
|
|
|
30
30
|
case ExtrinsicType.STAKING_BOND:
|
|
31
31
|
return 'Bond';
|
|
32
32
|
case ExtrinsicType.STAKING_UNBOND:
|
|
33
|
-
return '
|
|
33
|
+
return 'Unstake';
|
|
34
34
|
case ExtrinsicType.STAKING_CLAIM_REWARD:
|
|
35
35
|
return 'Claim reward';
|
|
36
36
|
case ExtrinsicType.STAKING_WITHDRAW:
|
|
@@ -45,6 +45,8 @@ const typeName = type => {
|
|
|
45
45
|
return 'Cancel compounding';
|
|
46
46
|
case ExtrinsicType.STAKING_POOL_WITHDRAW:
|
|
47
47
|
return 'Withdraw pool';
|
|
48
|
+
case ExtrinsicType.JOIN_YIELD_POOL:
|
|
49
|
+
return 'Start earning';
|
|
48
50
|
case ExtrinsicType.UNKNOWN:
|
|
49
51
|
default:
|
|
50
52
|
return 'unknown';
|