@subwallet/extension-base 1.1.34-0 → 1.1.35-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 +111 -69
- package/background/KoniTypes.js +19 -13
- package/background/errors/TransactionError.js +9 -0
- package/cjs/background/KoniTypes.js +20 -16
- package/cjs/background/errors/TransactionError.js +9 -0
- package/cjs/constants/index.js +19 -4
- package/cjs/constants/staking.js +1 -1
- package/cjs/koni/api/dotsama/balance.js +464 -0
- 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 +19 -16
- 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 +3 -21
- package/cjs/koni/background/handlers/Extension.js +368 -69
- package/cjs/koni/background/handlers/State.js +18 -12
- package/cjs/koni/background/handlers/index.js +4 -2
- package/cjs/koni/background/subscription.js +7 -104
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/campaign-service/index.js +9 -6
- package/cjs/services/chain-service/constants.js +2 -17
- package/cjs/services/chain-service/index.js +50 -3
- package/cjs/services/chain-service/utils.js +7 -1
- package/cjs/services/earning-service/constants/chains.js +30 -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 +262 -0
- package/cjs/services/earning-service/handlers/index.js +60 -0
- package/cjs/services/earning-service/handlers/lending/base.js +81 -0
- package/cjs/services/earning-service/handlers/lending/index.js +13 -0
- package/cjs/services/earning-service/handlers/lending/interlay.js +192 -0
- package/cjs/services/earning-service/handlers/liquid-staking/acala.js +240 -0
- package/cjs/services/earning-service/handlers/liquid-staking/base.js +97 -0
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost-manta.js +140 -0
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +298 -0
- package/cjs/services/earning-service/handlers/liquid-staking/index.js +34 -0
- package/cjs/services/earning-service/handlers/liquid-staking/parallel.js +227 -0
- package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +404 -0
- package/cjs/services/earning-service/handlers/native-staking/amplitude.js +434 -0
- package/cjs/services/earning-service/handlers/native-staking/astar.js +466 -0
- package/cjs/services/earning-service/handlers/native-staking/base-para.js +146 -0
- package/cjs/services/earning-service/handlers/native-staking/base.js +161 -0
- package/cjs/services/earning-service/handlers/native-staking/index.js +34 -0
- package/cjs/services/earning-service/handlers/native-staking/para-chain.js +390 -0
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +567 -0
- package/cjs/services/earning-service/handlers/nomination-pool/index.js +566 -0
- package/cjs/services/earning-service/handlers/special.js +493 -0
- package/cjs/services/earning-service/service.js +733 -0
- package/cjs/services/earning-service/utils/index.js +128 -0
- package/cjs/services/event-service/index.js +5 -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/MigrateEthProvider.js +17 -0
- package/cjs/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
- package/cjs/services/migration-service/scripts/MigratePioneerProvider.js +17 -0
- package/cjs/services/migration-service/scripts/MigrateProvider.js +29 -0
- 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 +6 -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 +3 -2
- package/cjs/services/request-service/handler/PopupHandler.js +2 -3
- package/cjs/services/storage-service/DatabaseService.js +97 -0
- package/cjs/services/storage-service/databases/index.js +4 -0
- package/cjs/services/storage-service/db-stores/AssetRef.js +24 -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 +71 -0
- package/cjs/services/storage-service/index.js +241 -0
- package/cjs/services/subscan-service/index.js +16 -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 +249 -75
- 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/types.js +1 -0
- package/cjs/utils/address.js +34 -0
- package/cjs/utils/environment.js +23 -28
- package/cjs/utils/fetchStaticCache.js +22 -0
- package/cjs/utils/fetchStaticData.js +2 -1
- package/cjs/utils/index.js +94 -10
- package/cjs/utils/keyring.js +57 -0
- package/cjs/utils/mv3.js +14 -0
- package/cjs/utils/number.js +6 -2
- package/cjs/utils/object.js +12 -0
- package/constants/index.d.ts +6 -1
- package/constants/index.js +6 -1
- package/constants/staking.js +1 -1
- 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 +13 -10
- 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.d.ts +0 -4
- package/koni/background/cron.js +4 -22
- package/koni/background/handlers/Extension.d.ts +17 -1
- package/koni/background/handlers/Extension.js +327 -30
- package/koni/background/handlers/State.d.ts +6 -1
- package/koni/background/handlers/State.js +17 -12
- package/koni/background/handlers/index.js +4 -2
- package/koni/background/subscription.d.ts +1 -6
- package/koni/background/subscription.js +8 -104
- package/package.json +335 -7
- package/packageInfo.js +1 -1
- package/services/campaign-service/index.js +9 -6
- package/services/chain-service/constants.d.ts +1 -13
- package/services/chain-service/constants.js +1 -15
- package/services/chain-service/index.d.ts +3 -0
- package/services/chain-service/index.js +50 -3
- 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 +15 -0
- package/services/earning-service/constants/chains.js +22 -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 +113 -0
- package/services/earning-service/handlers/base.js +256 -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 +8 -0
- package/services/earning-service/handlers/lending/base.js +73 -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 +24 -0
- package/services/earning-service/handlers/lending/interlay.js +184 -0
- package/services/earning-service/handlers/liquid-staking/acala.d.ts +27 -0
- package/services/earning-service/handlers/liquid-staking/acala.js +232 -0
- package/services/earning-service/handlers/liquid-staking/base.d.ts +11 -0
- package/services/earning-service/handlers/liquid-staking/base.js +89 -0
- package/services/earning-service/handlers/liquid-staking/bifrost.d.ts +46 -0
- package/services/earning-service/handlers/liquid-staking/bifrost.js +287 -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 +26 -0
- package/services/earning-service/handlers/liquid-staking/parallel.js +219 -0
- package/services/earning-service/handlers/liquid-staking/stella-swap.d.ts +34 -0
- package/services/earning-service/handlers/liquid-staking/stella-swap.js +394 -0
- package/services/earning-service/handlers/native-staking/amplitude.d.ts +22 -0
- package/services/earning-service/handlers/native-staking/amplitude.js +425 -0
- package/services/earning-service/handlers/native-staking/astar.d.ts +19 -0
- package/services/earning-service/handlers/native-staking/astar.js +456 -0
- package/services/earning-service/handlers/native-staking/base-para.d.ts +11 -0
- package/services/earning-service/handlers/native-staking/base-para.js +138 -0
- package/services/earning-service/handlers/native-staking/base.d.ts +21 -0
- package/services/earning-service/handlers/native-staking/base.js +152 -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 +382 -0
- package/services/earning-service/handlers/native-staking/relay-chain.d.ts +21 -0
- package/services/earning-service/handlers/native-staking/relay-chain.js +558 -0
- package/services/earning-service/handlers/nomination-pool/index.d.ts +36 -0
- package/services/earning-service/handlers/nomination-pool/index.js +556 -0
- package/services/earning-service/handlers/special.d.ts +64 -0
- package/services/earning-service/handlers/special.js +485 -0
- package/services/earning-service/service.d.ts +94 -0
- package/services/earning-service/service.js +722 -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 +2 -0
- package/services/event-service/index.js +5 -0
- package/services/event-service/types.d.ts +9 -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 +6 -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 +3 -2
- package/services/request-service/handler/PopupHandler.js +3 -4
- package/services/storage-service/DatabaseService.d.ts +22 -1
- package/services/storage-service/DatabaseService.js +97 -0
- package/services/storage-service/databases/index.d.ts +7 -2
- package/services/storage-service/databases/index.js +4 -0
- package/services/storage-service/db-stores/AssetRef.d.ts +7 -0
- package/services/storage-service/db-stores/AssetRef.js +16 -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 +11 -0
- package/services/storage-service/db-stores/YieldPositionStore.js +63 -0
- package/services/subscan-service/index.d.ts +3 -2
- package/services/subscan-service/index.js +15 -0
- package/services/subscan-service/types.d.ts +20 -0
- 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 +6 -13
- package/services/transaction-service/index.js +247 -73
- 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 +95 -0
- package/types/yield/actions/join/step.js +46 -0
- package/types/yield/actions/join/submit.d.ts +58 -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 +85 -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 +92 -0
- package/types/yield/info/account/info.js +1 -0
- package/types/yield/info/account/reward.d.ts +47 -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 +252 -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/environment.d.ts +9 -2
- package/utils/environment.js +14 -26
- package/utils/fetchStaticCache.d.ts +1 -0
- package/utils/fetchStaticCache.js +14 -0
- package/utils/fetchStaticData.js +2 -1
- package/utils/index.d.ts +5 -1
- package/utils/index.js +53 -3
- package/utils/mv3.d.ts +2 -0
- package/utils/mv3.js +6 -0
- package/utils/number.d.ts +2 -1
- package/utils/number.js +2 -1
- package/utils/object.d.ts +1 -0
- package/utils/object.js +6 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { _SubstrateApi } from '@subwallet/extension-base/services/chain-service/types';
|
|
2
|
+
import { LendingYieldPoolInfo, LiquidYieldPoolInfo, NativeYieldPoolInfo, NominationYieldPoolInfo, YieldAssetExpectedEarning, YieldCompoundingPeriod, YieldPoolInfo, YieldPoolType } from '@subwallet/extension-base/types';
|
|
3
|
+
export declare function calculateReward(apr: number, amount?: number, compoundingPeriod?: YieldCompoundingPeriod, isApy?: boolean): YieldAssetExpectedEarning;
|
|
4
|
+
/**
|
|
5
|
+
* @returns
|
|
6
|
+
* <p>
|
|
7
|
+
* [0] - identity
|
|
8
|
+
* </p>
|
|
9
|
+
* <p>
|
|
10
|
+
* [1] - isReasonable (isVerified)
|
|
11
|
+
* </p>
|
|
12
|
+
* */
|
|
13
|
+
export declare function parseIdentity(substrateApi: _SubstrateApi, address: string, children?: string): Promise<[string | undefined, boolean]>;
|
|
14
|
+
export declare function isActionFromValidator(stakingType: YieldPoolType, chain: string): boolean;
|
|
15
|
+
export declare const isNominationPool: (pool: YieldPoolInfo) => pool is NominationYieldPoolInfo;
|
|
16
|
+
export declare const isNativeStakingPool: (pool: YieldPoolInfo) => pool is NativeYieldPoolInfo;
|
|
17
|
+
export declare const isLiquidPool: (pool: YieldPoolInfo) => pool is LiquidYieldPoolInfo;
|
|
18
|
+
export declare const isLendingPool: (pool: YieldPoolInfo) => pool is LendingYieldPoolInfo;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-base
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { _STAKING_CHAIN_GROUP } from '@subwallet/extension-base/services/earning-service/constants';
|
|
5
|
+
import { YieldCompoundingPeriod, YieldPoolType } from '@subwallet/extension-base/types';
|
|
6
|
+
import { hexToString, isHex } from '@polkadot/util';
|
|
7
|
+
export function calculateReward(apr, amount = 0, compoundingPeriod = YieldCompoundingPeriod.YEARLY, isApy = false) {
|
|
8
|
+
if (!apr) {
|
|
9
|
+
return {};
|
|
10
|
+
}
|
|
11
|
+
if (!isApy) {
|
|
12
|
+
const periodApr = apr / 365 * compoundingPeriod; // APR is always annually
|
|
13
|
+
const earningRatio = periodApr / 100 / compoundingPeriod;
|
|
14
|
+
const periodApy = (1 + earningRatio) ** compoundingPeriod - 1;
|
|
15
|
+
const reward = periodApy * amount;
|
|
16
|
+
return {
|
|
17
|
+
apy: periodApy * 100,
|
|
18
|
+
rewardInToken: reward
|
|
19
|
+
};
|
|
20
|
+
} else {
|
|
21
|
+
const reward = apr / 100 * amount;
|
|
22
|
+
return {
|
|
23
|
+
apy: apr,
|
|
24
|
+
rewardInToken: reward * (compoundingPeriod / YieldCompoundingPeriod.YEARLY)
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @returns
|
|
31
|
+
* <p>
|
|
32
|
+
* [0] - identity
|
|
33
|
+
* </p>
|
|
34
|
+
* <p>
|
|
35
|
+
* [1] - isReasonable (isVerified)
|
|
36
|
+
* </p>
|
|
37
|
+
* */
|
|
38
|
+
export async function parseIdentity(substrateApi, address, children) {
|
|
39
|
+
const compactResult = rs => {
|
|
40
|
+
const result = [];
|
|
41
|
+
if (rs) {
|
|
42
|
+
result.push(rs);
|
|
43
|
+
}
|
|
44
|
+
if (children) {
|
|
45
|
+
result.push(children);
|
|
46
|
+
}
|
|
47
|
+
if (result.length > 0) {
|
|
48
|
+
return result.join('/');
|
|
49
|
+
} else {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
if (substrateApi.api.query.identity) {
|
|
54
|
+
let identity;
|
|
55
|
+
const _parent = await substrateApi.api.query.identity.superOf(address);
|
|
56
|
+
const parentInfo = _parent.toHuman();
|
|
57
|
+
if (parentInfo) {
|
|
58
|
+
const [parentAddress, {
|
|
59
|
+
Raw: data
|
|
60
|
+
}] = parentInfo;
|
|
61
|
+
const child = isHex(data) ? hexToString(data) : data;
|
|
62
|
+
|
|
63
|
+
// TODO: Re-check
|
|
64
|
+
if (address !== parentAddress) {
|
|
65
|
+
const [rs, isReasonable] = await parseIdentity(substrateApi, parentAddress, child);
|
|
66
|
+
return [compactResult(rs), isReasonable];
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const _identity = await substrateApi.api.query.identity.identityOf(address);
|
|
70
|
+
const identityInfo = _identity.toHuman();
|
|
71
|
+
if (identityInfo) {
|
|
72
|
+
var _identityInfo$info, _identityInfo$info$di, _identityInfo$info2, _identityInfo$info2$w, _identityInfo$info3, _identityInfo$info3$r, _identityInfo$info4, _identityInfo$info4$t;
|
|
73
|
+
const displayName = (_identityInfo$info = identityInfo.info) === null || _identityInfo$info === void 0 ? void 0 : (_identityInfo$info$di = _identityInfo$info.display) === null || _identityInfo$info$di === void 0 ? void 0 : _identityInfo$info$di.Raw;
|
|
74
|
+
const web = (_identityInfo$info2 = identityInfo.info) === null || _identityInfo$info2 === void 0 ? void 0 : (_identityInfo$info2$w = _identityInfo$info2.web) === null || _identityInfo$info2$w === void 0 ? void 0 : _identityInfo$info2$w.Raw;
|
|
75
|
+
const riot = (_identityInfo$info3 = identityInfo.info) === null || _identityInfo$info3 === void 0 ? void 0 : (_identityInfo$info3$r = _identityInfo$info3.riot) === null || _identityInfo$info3$r === void 0 ? void 0 : _identityInfo$info3$r.Raw;
|
|
76
|
+
const twitter = (_identityInfo$info4 = identityInfo.info) === null || _identityInfo$info4 === void 0 ? void 0 : (_identityInfo$info4$t = _identityInfo$info4.twitter) === null || _identityInfo$info4$t === void 0 ? void 0 : _identityInfo$info4$t.Raw;
|
|
77
|
+
const isReasonable = identityInfo.judgements.length > 0;
|
|
78
|
+
if (displayName) {
|
|
79
|
+
identity = isHex(displayName) ? hexToString(displayName) : displayName;
|
|
80
|
+
} else {
|
|
81
|
+
identity = twitter || web || riot;
|
|
82
|
+
}
|
|
83
|
+
return [compactResult(identity), isReasonable];
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return [undefined, false];
|
|
87
|
+
}
|
|
88
|
+
export function isActionFromValidator(stakingType, chain) {
|
|
89
|
+
if (stakingType === YieldPoolType.NOMINATION_POOL || stakingType === YieldPoolType.LIQUID_STAKING || stakingType === YieldPoolType.LENDING) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
if (_STAKING_CHAIN_GROUP.astar.includes(chain)) {
|
|
93
|
+
return true;
|
|
94
|
+
} else if (_STAKING_CHAIN_GROUP.amplitude.includes(chain)) {
|
|
95
|
+
return true;
|
|
96
|
+
} else if (_STAKING_CHAIN_GROUP.para.includes(chain)) {
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
export const isNominationPool = pool => {
|
|
102
|
+
return pool.type === YieldPoolType.NOMINATION_POOL;
|
|
103
|
+
};
|
|
104
|
+
export const isNativeStakingPool = pool => {
|
|
105
|
+
return pool.type === YieldPoolType.NATIVE_STAKING;
|
|
106
|
+
};
|
|
107
|
+
export const isLiquidPool = pool => {
|
|
108
|
+
return pool.type === YieldPoolType.LIQUID_STAKING;
|
|
109
|
+
};
|
|
110
|
+
export const isLendingPool = pool => {
|
|
111
|
+
return pool.type === YieldPoolType.LENDING;
|
|
112
|
+
};
|
|
@@ -8,12 +8,14 @@ export declare class EventService extends EventEmitter<EventRegistry> {
|
|
|
8
8
|
readonly waitDatabaseReady: Promise<boolean>;
|
|
9
9
|
readonly waitKeyringReady: Promise<boolean>;
|
|
10
10
|
readonly waitAccountReady: Promise<boolean>;
|
|
11
|
+
readonly waitInjectReady: Promise<boolean>;
|
|
11
12
|
readonly waitChainReady: Promise<boolean>;
|
|
12
13
|
readonly waitAssetReady: Promise<boolean>;
|
|
13
14
|
readonly waitMigrateReady: Promise<boolean>;
|
|
14
15
|
readonly waitCampaignReady: Promise<boolean>;
|
|
15
16
|
readonly waitBuyTokenReady: Promise<boolean>;
|
|
16
17
|
readonly waitBuyServiceReady: Promise<boolean>;
|
|
18
|
+
readonly waitEarningReady: Promise<boolean>;
|
|
17
19
|
constructor();
|
|
18
20
|
private generateWaitPromise;
|
|
19
21
|
private setLazyTimeout;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
// Stateless service handle runtime event on background
|
|
5
5
|
|
|
6
|
+
import { TARGET_ENV } from '@subwallet/extension-base/utils';
|
|
6
7
|
import EventEmitter from 'eventemitter3';
|
|
7
8
|
const DEFAULT_LAZY_TIME = 300;
|
|
8
9
|
const LONG_LAZY_TIME = 900;
|
|
@@ -17,16 +18,20 @@ export class EventService extends EventEmitter {
|
|
|
17
18
|
this.waitDatabaseReady = this.generateWaitPromise('database.ready');
|
|
18
19
|
this.waitKeyringReady = this.generateWaitPromise('keyring.ready');
|
|
19
20
|
this.waitAccountReady = this.generateWaitPromise('account.ready');
|
|
21
|
+
// TODO: Need to merge logic on web-runner file
|
|
22
|
+
this.waitInjectReady = TARGET_ENV === 'webapp' ? this.generateWaitPromise('inject.ready') : Promise.resolve(true);
|
|
20
23
|
this.waitChainReady = this.generateWaitPromise('chain.ready');
|
|
21
24
|
this.waitAssetReady = this.generateWaitPromise('asset.ready');
|
|
22
25
|
this.waitMigrateReady = this.generateWaitPromise('migration.done');
|
|
23
26
|
this.waitCampaignReady = this.generateWaitPromise('campaign.ready');
|
|
24
27
|
this.waitBuyTokenReady = this.generateWaitPromise('buy.tokens.ready');
|
|
25
28
|
this.waitBuyServiceReady = this.generateWaitPromise('buy.services.ready');
|
|
29
|
+
this.waitEarningReady = this.generateWaitPromise('earning.ready');
|
|
26
30
|
}
|
|
27
31
|
generateWaitPromise(eventType) {
|
|
28
32
|
return new Promise(resolve => {
|
|
29
33
|
this.once(eventType, isReady => {
|
|
34
|
+
console.log('===LOG generateWaitPromise eventType', eventType);
|
|
30
35
|
resolve(isReady);
|
|
31
36
|
});
|
|
32
37
|
});
|
|
@@ -5,12 +5,20 @@ export interface EventRegistry {
|
|
|
5
5
|
'general.wakeup': [boolean];
|
|
6
6
|
'crypto.ready': [boolean];
|
|
7
7
|
'database.ready': [boolean];
|
|
8
|
+
/** Password state ready */
|
|
8
9
|
'keyring.ready': [boolean];
|
|
10
|
+
/** Update current account */
|
|
9
11
|
'account.updateCurrent': [CurrentAccountInfo];
|
|
12
|
+
/** Account list loaded */
|
|
10
13
|
'account.ready': [boolean];
|
|
14
|
+
/** Add a new account */
|
|
11
15
|
'account.add': [string];
|
|
16
|
+
/** Update account */
|
|
12
17
|
'account.update': [string];
|
|
18
|
+
/** Remove a account */
|
|
13
19
|
'account.remove': [string];
|
|
20
|
+
/** Inject account done */
|
|
21
|
+
'inject.ready': [boolean];
|
|
14
22
|
'chain.ready': [boolean];
|
|
15
23
|
'chain.add': [string];
|
|
16
24
|
'chain.updateState': [string];
|
|
@@ -28,6 +36,7 @@ export interface EventRegistry {
|
|
|
28
36
|
'campaign.ready': [boolean];
|
|
29
37
|
'buy.tokens.ready': [boolean];
|
|
30
38
|
'buy.services.ready': [boolean];
|
|
39
|
+
'earning.ready': [boolean];
|
|
31
40
|
}
|
|
32
41
|
export declare type EventType = keyof EventRegistry;
|
|
33
42
|
export declare const COMMON_RELOAD_EVENTS: EventType[];
|
|
@@ -10,6 +10,7 @@ export declare class KeyringService {
|
|
|
10
10
|
readonly addressesSubject: BehaviorSubject<SubjectInfo>;
|
|
11
11
|
readonly accountSubject: BehaviorSubject<SubjectInfo>;
|
|
12
12
|
private beforeAccount;
|
|
13
|
+
private injected;
|
|
13
14
|
readonly keyringStateSubject: BehaviorSubject<KeyringState>;
|
|
14
15
|
constructor(eventService: EventService);
|
|
15
16
|
private subscribeAccounts;
|
|
@@ -21,6 +22,6 @@ export declare class KeyringService {
|
|
|
21
22
|
setCurrentAccount(currentAccountData: CurrentAccountInfo): void;
|
|
22
23
|
lock(): void;
|
|
23
24
|
addInjectAccounts(accounts: InjectedAccountWithMeta[]): void;
|
|
24
|
-
removeInjectAccounts(
|
|
25
|
+
removeInjectAccounts(_addresses: string[]): void;
|
|
25
26
|
resetWallet(resetAll: boolean): Promise<void>;
|
|
26
27
|
}
|
|
@@ -22,6 +22,7 @@ export class KeyringService {
|
|
|
22
22
|
});
|
|
23
23
|
constructor(eventService) {
|
|
24
24
|
this.eventService = eventService;
|
|
25
|
+
this.injected = false;
|
|
25
26
|
this.eventService.waitCryptoReady.then(() => {
|
|
26
27
|
this.currentAccountStore.get('CurrentAccountInfo', rs => {
|
|
27
28
|
rs && this.currentAccountSubject.next(rs);
|
|
@@ -133,8 +134,19 @@ export class KeyringService {
|
|
|
133
134
|
currentGenesisHash: null
|
|
134
135
|
});
|
|
135
136
|
}
|
|
137
|
+
if (!this.injected) {
|
|
138
|
+
this.eventService.emit('inject.ready', true);
|
|
139
|
+
this.injected = true;
|
|
140
|
+
}
|
|
136
141
|
}
|
|
137
|
-
removeInjectAccounts(
|
|
142
|
+
removeInjectAccounts(_addresses) {
|
|
143
|
+
const addresses = _addresses.map(address => {
|
|
144
|
+
try {
|
|
145
|
+
return keyring.getPair(address).address;
|
|
146
|
+
} catch (error) {
|
|
147
|
+
return address;
|
|
148
|
+
}
|
|
149
|
+
});
|
|
138
150
|
const currentAddress = this.currentAccountSubject.value.address;
|
|
139
151
|
const afterAccounts = Object.keys(this.accounts).filter(address => addresses.indexOf(address) < 0);
|
|
140
152
|
if (afterAccounts.length === 1) {
|
|
@@ -159,7 +171,7 @@ export class KeyringService {
|
|
|
159
171
|
await new Promise(resolve => {
|
|
160
172
|
setTimeout(() => {
|
|
161
173
|
resolve();
|
|
162
|
-
},
|
|
174
|
+
}, 1500);
|
|
163
175
|
});
|
|
164
176
|
this.updateKeyringState();
|
|
165
177
|
this.currentAccountSubject.next({
|
|
@@ -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 DeleteEarningData extends BaseMigrationJob {
|
|
6
|
+
async run() {
|
|
7
|
+
try {
|
|
8
|
+
await this.state.dbService.deleteYieldPoolInfo(['LcDOT___acala_euphrates_liquid_staking', 'xcDOT___moonwell_lending']);
|
|
9
|
+
} catch (e) {
|
|
10
|
+
console.error(e);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -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 EnableEarningChains extends BaseMigrationJob {
|
|
6
|
+
async run() {
|
|
7
|
+
try {
|
|
8
|
+
await this.state.chainService.enableChains(['moonbeam', 'acala', 'bifrost_dot', 'interlay', 'parallel']);
|
|
9
|
+
} catch (e) {
|
|
10
|
+
console.error(e);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -11,7 +11,7 @@ export default class MigrateLedgerAccount extends BaseMigrationJob {
|
|
|
11
11
|
const store = new AccountsStore();
|
|
12
12
|
const update = (key, value) => {
|
|
13
13
|
var _value$meta;
|
|
14
|
-
if (key.startsWith('account:') && value.meta && isString((_value$meta = value.meta) === null || _value$meta === void 0 ? void 0 : _value$meta.originGenesisHash)) {
|
|
14
|
+
if (key.startsWith('account:') && value !== null && value !== void 0 && value.meta && isString((_value$meta = value.meta) === null || _value$meta === void 0 ? void 0 : _value$meta.originGenesisHash)) {
|
|
15
15
|
const newValue = {
|
|
16
16
|
...value
|
|
17
17
|
};
|
|
@@ -12,7 +12,7 @@ export default class MigrateTransactionHistory extends BaseMigrationJob {
|
|
|
12
12
|
const chainInfoMap = state.getChainInfoMap();
|
|
13
13
|
const assetList = Object.values(state.getAssetRegistry());
|
|
14
14
|
try {
|
|
15
|
-
const db = new Dexie('
|
|
15
|
+
const db = new Dexie('SubWalletDB_v2');
|
|
16
16
|
const dexieDB = await db.open();
|
|
17
17
|
const transactionTable = dexieDB.table('transactions');
|
|
18
18
|
const oldTransactionData = await transactionTable.toArray();
|
|
@@ -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 MigrateEarningHistory extends BaseMigrationJob {
|
|
6
|
+
async run() {
|
|
7
|
+
try {
|
|
8
|
+
await this.state.dbService.removeOldEarningData();
|
|
9
|
+
} catch (e) {
|
|
10
|
+
console.error(e);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -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,8 @@
|
|
|
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 MigrateEarningVersion from "./databases/MigrateEarningVersion.js";
|
|
4
6
|
import MigrateEthProvider from "./providers/MigrateEthProvider.js";
|
|
5
7
|
import MigratePioneerProvider from "./providers/MigratePioneerProvider.js";
|
|
6
8
|
import MigrateProvidersV1M1P24 from "./providers/MigrateProvidersV1M1P24.js";
|
|
@@ -33,9 +35,12 @@ export default {
|
|
|
33
35
|
'1.1.6-01': MigrateWalletReference,
|
|
34
36
|
'1.1.7': DeleteChain,
|
|
35
37
|
'1.1.13-01': MigrateTokenDecimals,
|
|
38
|
+
// '1.1.13-02-2': EnableEarningChains,
|
|
39
|
+
'1.1.13-03': DeleteEarningData,
|
|
36
40
|
'1.1.17-01': MigratePioneerProvider,
|
|
37
41
|
'1.1.17-03': EnableVaraChain,
|
|
38
42
|
'1.1.24-01': MigrateProvidersV1M1P24,
|
|
39
|
-
'1.1.26-01': MigratePolygonUSDCProvider
|
|
43
|
+
'1.1.26-01': MigratePolygonUSDCProvider,
|
|
44
|
+
'1.1.28-01': MigrateEarningVersion
|
|
40
45
|
// [`${EVERYTIME}-1`]: AutoEnableChainsTokens
|
|
41
46
|
};
|
|
@@ -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
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
+
import { isFirefox } from '@subwallet/extension-base/utils';
|
|
4
5
|
import { BehaviorSubject } from 'rxjs';
|
|
5
6
|
export default class NotificationService {
|
|
6
7
|
notificationSubject = new BehaviorSubject([]);
|
|
@@ -33,10 +34,10 @@ export default class NotificationService {
|
|
|
33
34
|
type: 'basic',
|
|
34
35
|
title,
|
|
35
36
|
message,
|
|
36
|
-
iconUrl: '
|
|
37
|
+
iconUrl: '/images/icon-128.png',
|
|
37
38
|
priority: 2,
|
|
38
39
|
isClickable: !!link || !!onClick,
|
|
39
|
-
buttons
|
|
40
|
+
buttons: isFirefox ? undefined : buttons
|
|
40
41
|
}, notificationId => {
|
|
41
42
|
if (link || onClick) {
|
|
42
43
|
chrome.notifications.onClicked.addListener(nId => {
|
|
@@ -3,11 +3,10 @@
|
|
|
3
3
|
|
|
4
4
|
import { withErrorLog } from '@subwallet/extension-base/background/handlers/helpers';
|
|
5
5
|
import { DEFAULT_NOTIFICATION_TYPE } from '@subwallet/extension-base/services/setting-service/constants';
|
|
6
|
-
import {
|
|
6
|
+
import { osName } from '@subwallet/extension-base/utils';
|
|
7
7
|
const NOTIFICATION_URL = chrome.extension.getURL('notification.html');
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const extraWidth = OS === 'Windows' ? 16 : 0;
|
|
8
|
+
const extraHeight = osName === 'Linux' ? 0 : 28;
|
|
9
|
+
const extraWidth = osName === 'Windows' ? 16 : 0;
|
|
11
10
|
const POPUP_WINDOW_OPTS = {
|
|
12
11
|
focused: true,
|
|
13
12
|
height: 600 + extraHeight,
|