@subwallet/extension-base 1.1.28-1 → 1.1.28-beta.2
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 +57 -4
- package/cjs/koni/background/handlers/index.js +4 -2
- package/cjs/koni/background/subscription.js +89 -19
- 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 +220 -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 +170 -0
- package/cjs/services/earning-service/handlers/liquid-staking/acala.js +198 -0
- package/cjs/services/earning-service/handlers/liquid-staking/base.js +43 -0
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +259 -0
- package/cjs/services/earning-service/handlers/liquid-staking/index.js +34 -0
- package/cjs/services/earning-service/handlers/liquid-staking/parallel.js +182 -0
- package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +375 -0
- package/cjs/services/earning-service/handlers/native-staking/amplitude.js +373 -0
- package/cjs/services/earning-service/handlers/native-staking/astar.js +446 -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 +375 -0
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +529 -0
- package/cjs/services/earning-service/handlers/nomination-pool/index.js +521 -0
- package/cjs/services/earning-service/handlers/special.js +411 -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 +180 -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 +56 -4
- package/koni/background/handlers/index.js +4 -2
- package/koni/background/subscription.d.ts +5 -1
- package/koni/background/subscription.js +91 -21
- package/package.json +317 -4
- 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 +107 -0
- package/services/earning-service/handlers/base.js +213 -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 +162 -0
- package/services/earning-service/handlers/liquid-staking/acala.d.ts +27 -0
- package/services/earning-service/handlers/liquid-staking/acala.js +190 -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 +248 -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 +174 -0
- package/services/earning-service/handlers/liquid-staking/stella-swap.d.ts +36 -0
- package/services/earning-service/handlers/liquid-staking/stella-swap.js +365 -0
- package/services/earning-service/handlers/native-staking/amplitude.d.ts +22 -0
- package/services/earning-service/handlers/native-staking/amplitude.js +364 -0
- package/services/earning-service/handlers/native-staking/astar.d.ts +19 -0
- package/services/earning-service/handlers/native-staking/astar.js +436 -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 +367 -0
- package/services/earning-service/handlers/native-staking/relay-chain.d.ts +21 -0
- package/services/earning-service/handlers/native-staking/relay-chain.js +520 -0
- package/services/earning-service/handlers/nomination-pool/index.d.ts +33 -0
- package/services/earning-service/handlers/nomination-pool/index.js +511 -0
- package/services/earning-service/handlers/special.d.ts +58 -0
- package/services/earning-service/handlers/special.js +403 -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 +178 -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 +208 -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
|
@@ -1,27 +1,15 @@
|
|
|
1
1
|
import { TransactionError } from '@subwallet/extension-base/background/errors/TransactionError';
|
|
2
|
-
import
|
|
3
|
-
import { ChainService } from '@subwallet/extension-base/services/chain-service';
|
|
4
|
-
import { EventService } from '@subwallet/extension-base/services/event-service';
|
|
5
|
-
import { HistoryService } from '@subwallet/extension-base/services/history-service';
|
|
6
|
-
import NotificationService from '@subwallet/extension-base/services/notification-service/NotificationService';
|
|
7
|
-
import RequestService from '@subwallet/extension-base/services/request-service';
|
|
8
|
-
import DatabaseService from '@subwallet/extension-base/services/storage-service/DatabaseService';
|
|
2
|
+
import KoniState from '@subwallet/extension-base/koni/background/handlers/State';
|
|
9
3
|
import { SWTransaction, SWTransactionInput, SWTransactionResponse, TransactionEmitter } from '@subwallet/extension-base/services/transaction-service/types';
|
|
10
4
|
import { BehaviorSubject } from 'rxjs';
|
|
11
5
|
import { TransactionConfig } from 'web3-core';
|
|
12
6
|
import { HexString } from '@polkadot/util/types';
|
|
13
7
|
export default class TransactionService {
|
|
14
|
-
private readonly
|
|
15
|
-
private readonly chainService;
|
|
16
|
-
private readonly databaseService;
|
|
17
|
-
private readonly eventService;
|
|
18
|
-
private readonly historyService;
|
|
19
|
-
private readonly notificationService;
|
|
20
|
-
private readonly requestService;
|
|
8
|
+
private readonly state;
|
|
21
9
|
private readonly transactionSubject;
|
|
22
10
|
private readonly watchTransactionSubscribes;
|
|
23
11
|
private get transactions();
|
|
24
|
-
constructor(
|
|
12
|
+
constructor(state: KoniState);
|
|
25
13
|
private get allTransactions();
|
|
26
14
|
private get processingTransactions();
|
|
27
15
|
getTransaction(id: string): SWTransaction;
|
|
@@ -47,5 +35,6 @@ export default class TransactionService {
|
|
|
47
35
|
private signAndSendEvmTransaction;
|
|
48
36
|
private signAndSendSubstrateTransaction;
|
|
49
37
|
private handleTransactionTimeout;
|
|
38
|
+
private handlePostEarningTransaction;
|
|
50
39
|
resetWallet(): void;
|
|
51
40
|
}
|
|
@@ -6,14 +6,14 @@ import { TransactionError } from '@subwallet/extension-base/background/errors/Tr
|
|
|
6
6
|
import { BasicTxErrorType, BasicTxWarningCode, ChainType, EvmProviderErrorType, ExtrinsicStatus, ExtrinsicType, NotificationType, TransactionDirection } from '@subwallet/extension-base/background/KoniTypes';
|
|
7
7
|
import { TransactionWarning } from '@subwallet/extension-base/background/warnings/TransactionWarning';
|
|
8
8
|
import { ALL_ACCOUNT_KEY } from '@subwallet/extension-base/constants';
|
|
9
|
-
import {
|
|
10
|
-
import { _getChainNativeTokenBasicInfo, _getEvmChainId } from '@subwallet/extension-base/services/chain-service/utils';
|
|
9
|
+
import { _getAssetDecimals, _getAssetSymbol, _getChainNativeTokenBasicInfo, _getEvmChainId, _isChainEvmCompatible } from '@subwallet/extension-base/services/chain-service/utils';
|
|
11
10
|
import { EXTENSION_REQUEST_URL } from '@subwallet/extension-base/services/request-service/constants';
|
|
12
11
|
import { TRANSACTION_TIMEOUT } from '@subwallet/extension-base/services/transaction-service/constants';
|
|
13
|
-
import { parseTransferEventLogs, parseXcmEventLogs } from '@subwallet/extension-base/services/transaction-service/event-parser';
|
|
12
|
+
import { parseLiquidStakingEvents, parseLiquidStakingFastUnstakeEvents, parseTransferEventLogs, parseXcmEventLogs } from '@subwallet/extension-base/services/transaction-service/event-parser';
|
|
14
13
|
import { getBaseTransactionInfo, getTransactionId, isSubstrateTransaction } from '@subwallet/extension-base/services/transaction-service/helpers';
|
|
15
14
|
import { getExplorerLink, parseTransactionData } from '@subwallet/extension-base/services/transaction-service/utils';
|
|
16
15
|
import { isWalletConnectRequest } from '@subwallet/extension-base/services/wallet-connect-service/helpers';
|
|
16
|
+
import { YieldPoolType } from '@subwallet/extension-base/types';
|
|
17
17
|
import { reformatAddress } from '@subwallet/extension-base/utils';
|
|
18
18
|
import { anyNumberToBN, recalculateGasPrice } from '@subwallet/extension-base/utils/eth';
|
|
19
19
|
import { mergeTransactionAndSignature } from '@subwallet/extension-base/utils/eth/mergeTransactionAndSignature';
|
|
@@ -26,20 +26,15 @@ import EventEmitter from 'eventemitter3';
|
|
|
26
26
|
import { t } from 'i18next';
|
|
27
27
|
import { BehaviorSubject } from 'rxjs';
|
|
28
28
|
import { isHex } from '@polkadot/util';
|
|
29
|
+
import { _TRANSFER_CHAIN_GROUP } from "../chain-service/constants.js";
|
|
29
30
|
export default class TransactionService {
|
|
30
31
|
transactionSubject = new BehaviorSubject({});
|
|
31
32
|
watchTransactionSubscribes = {};
|
|
32
33
|
get transactions() {
|
|
33
34
|
return this.transactionSubject.getValue();
|
|
34
35
|
}
|
|
35
|
-
constructor(
|
|
36
|
-
this.
|
|
37
|
-
this.eventService = eventService;
|
|
38
|
-
this.requestService = requestService;
|
|
39
|
-
this.balanceService = balanceService;
|
|
40
|
-
this.historyService = historyService;
|
|
41
|
-
this.notificationService = notificationService;
|
|
42
|
-
this.databaseService = databaseService;
|
|
36
|
+
constructor(state) {
|
|
37
|
+
this.state = state;
|
|
43
38
|
}
|
|
44
39
|
get allTransactions() {
|
|
45
40
|
return Object.values(this.transactions);
|
|
@@ -96,7 +91,7 @@ export default class TransactionService {
|
|
|
96
91
|
decimals: 0,
|
|
97
92
|
value: ''
|
|
98
93
|
};
|
|
99
|
-
const chainInfo = this.chainService.getChainInfoByKey(chain);
|
|
94
|
+
const chainInfo = this.state.chainService.getChainInfoByKey(chain);
|
|
100
95
|
if (!chainInfo) {
|
|
101
96
|
validationResponse.errors.push(new TransactionError(BasicTxErrorType.INTERNAL_ERROR, t('Cannot find network')));
|
|
102
97
|
} else {
|
|
@@ -111,7 +106,7 @@ export default class TransactionService {
|
|
|
111
106
|
if (isSubstrateTransaction(transaction)) {
|
|
112
107
|
estimateFee.value = (await transaction.paymentInfo(address)).partialFee.toString();
|
|
113
108
|
} else {
|
|
114
|
-
const web3 = this.chainService.getEvmApi(chain);
|
|
109
|
+
const web3 = this.state.chainService.getEvmApi(chain);
|
|
115
110
|
if (!web3) {
|
|
116
111
|
validationResponse.errors.push(new TransactionError(BasicTxErrorType.CHAIN_DISCONNECTED, undefined));
|
|
117
112
|
} else {
|
|
@@ -145,32 +140,35 @@ export default class TransactionService {
|
|
|
145
140
|
|
|
146
141
|
// Balance
|
|
147
142
|
const transferNative = validationResponse.transferNativeAmount || '0';
|
|
148
|
-
const nativeTokenInfo = this.chainService.getNativeTokenInfo(chain);
|
|
149
|
-
const balance = await this.balanceService.getTokenFreeBalance(address, chain, nativeTokenInfo.slug);
|
|
143
|
+
const nativeTokenInfo = this.state.chainService.getNativeTokenInfo(chain);
|
|
144
|
+
const balance = await this.state.balanceService.getTokenFreeBalance(address, chain, nativeTokenInfo.slug);
|
|
150
145
|
const existentialDeposit = nativeTokenInfo.minAmount || '0';
|
|
151
146
|
const feeNum = parseInt(estimateFee.value);
|
|
152
147
|
const balanceNum = parseInt(balance.value);
|
|
153
148
|
const edNum = parseInt(existentialDeposit);
|
|
154
149
|
const transferNativeNum = parseInt(transferNative);
|
|
155
|
-
if (!
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
if (transferNativeNum + feeNum > balanceNum) {
|
|
159
|
-
if (!isTransferAll) {
|
|
150
|
+
if (!validationInput.skipFeeValidation) {
|
|
151
|
+
// TODO
|
|
152
|
+
if (!new BigN(balance.value).gt(0)) {
|
|
160
153
|
validationResponse.errors.push(new TransactionError(BasicTxErrorType.NOT_ENOUGH_BALANCE));
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
|
|
154
|
+
}
|
|
155
|
+
if (transferNativeNum + feeNum > balanceNum) {
|
|
156
|
+
if (!isTransferAll) {
|
|
164
157
|
validationResponse.errors.push(new TransactionError(BasicTxErrorType.NOT_ENOUGH_BALANCE));
|
|
158
|
+
} else {
|
|
159
|
+
if ([..._TRANSFER_CHAIN_GROUP.acala, ..._TRANSFER_CHAIN_GROUP.genshiro, ..._TRANSFER_CHAIN_GROUP.bitcountry, ..._TRANSFER_CHAIN_GROUP.statemine].includes(chain)) {
|
|
160
|
+
// Chain not have transfer all function
|
|
161
|
+
validationResponse.errors.push(new TransactionError(BasicTxErrorType.NOT_ENOUGH_BALANCE));
|
|
162
|
+
}
|
|
165
163
|
}
|
|
166
164
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
165
|
+
if (!isTransferAll) {
|
|
166
|
+
if (balanceNum - (transferNativeNum + feeNum) < edNum) {
|
|
167
|
+
if (edAsWarning) {
|
|
168
|
+
validationResponse.warnings.push(new TransactionWarning(BasicTxWarningCode.NOT_ENOUGH_EXISTENTIAL_DEPOSIT));
|
|
169
|
+
} else {
|
|
170
|
+
validationResponse.errors.push(new TransactionError(BasicTxErrorType.NOT_ENOUGH_EXISTENTIAL_DEPOSIT));
|
|
171
|
+
}
|
|
174
172
|
}
|
|
175
173
|
}
|
|
176
174
|
}
|
|
@@ -237,12 +235,21 @@ export default class TransactionService {
|
|
|
237
235
|
}
|
|
238
236
|
validatedTransaction.warnings = [];
|
|
239
237
|
const emitter = await this.addTransaction(validatedTransaction);
|
|
240
|
-
await new Promise(resolve => {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
238
|
+
await new Promise((resolve, reject) => {
|
|
239
|
+
// TODO
|
|
240
|
+
if (transaction.resolveOnDone) {
|
|
241
|
+
emitter.on('success', data => {
|
|
242
|
+
validatedTransaction.id = data.id;
|
|
243
|
+
validatedTransaction.extrinsicHash = data.extrinsicHash;
|
|
244
|
+
resolve();
|
|
245
|
+
});
|
|
246
|
+
} else {
|
|
247
|
+
emitter.on('signed', data => {
|
|
248
|
+
validatedTransaction.id = data.id;
|
|
249
|
+
validatedTransaction.extrinsicHash = data.extrinsicHash;
|
|
250
|
+
resolve();
|
|
251
|
+
});
|
|
252
|
+
}
|
|
246
253
|
emitter.on('error', data => {
|
|
247
254
|
if (data.errors.length > 0) {
|
|
248
255
|
validatedTransaction.errors.push(...data.errors);
|
|
@@ -308,7 +315,7 @@ export default class TransactionService {
|
|
|
308
315
|
}
|
|
309
316
|
getTransactionLink(id) {
|
|
310
317
|
const transaction = this.getTransaction(id);
|
|
311
|
-
const chainInfo = this.chainService.getChainInfoByKey(transaction.chain);
|
|
318
|
+
const chainInfo = this.state.chainService.getChainInfoByKey(transaction.chain);
|
|
312
319
|
return getExplorerLink(chainInfo, transaction.extrinsicHash, 'tx');
|
|
313
320
|
}
|
|
314
321
|
transactionToHistories(id, startBlock, nonce, eventLogs) {
|
|
@@ -336,7 +343,7 @@ export default class TransactionService {
|
|
|
336
343
|
nonce: nonce !== null && nonce !== void 0 ? nonce : 0,
|
|
337
344
|
startBlock: startBlock || 0
|
|
338
345
|
};
|
|
339
|
-
const chainInfo = this.chainService.getChainInfoByKey(transaction.chain);
|
|
346
|
+
const chainInfo = this.state.chainService.getChainInfoByKey(transaction.chain);
|
|
340
347
|
const nativeAsset = _getChainNativeTokenBasicInfo(chainInfo);
|
|
341
348
|
const baseNativeAmount = {
|
|
342
349
|
value: '0',
|
|
@@ -350,7 +357,7 @@ export default class TransactionService {
|
|
|
350
357
|
{
|
|
351
358
|
const inputData = parseTransactionData(transaction.data);
|
|
352
359
|
historyItem.to = inputData.to;
|
|
353
|
-
const sendingTokenInfo = this.chainService.getAssetBySlug(inputData.tokenSlug);
|
|
360
|
+
const sendingTokenInfo = this.state.chainService.getAssetBySlug(inputData.tokenSlug);
|
|
354
361
|
historyItem.amount = {
|
|
355
362
|
value: inputData.value || '0',
|
|
356
363
|
decimals: sendingTokenInfo.decimals || 0,
|
|
@@ -363,7 +370,7 @@ export default class TransactionService {
|
|
|
363
370
|
{
|
|
364
371
|
const inputData = parseTransactionData(transaction.data);
|
|
365
372
|
historyItem.to = inputData.to;
|
|
366
|
-
const sendingTokenInfo = this.chainService.getAssetBySlug(inputData.tokenSlug);
|
|
373
|
+
const sendingTokenInfo = this.state.chainService.getAssetBySlug(inputData.tokenSlug);
|
|
367
374
|
historyItem.amount = {
|
|
368
375
|
value: inputData.value || '0',
|
|
369
376
|
decimals: sendingTokenInfo.decimals || 0,
|
|
@@ -376,7 +383,7 @@ export default class TransactionService {
|
|
|
376
383
|
{
|
|
377
384
|
const inputData = parseTransactionData(transaction.data);
|
|
378
385
|
historyItem.to = inputData.to;
|
|
379
|
-
const sendingTokenInfo = this.chainService.getAssetBySlug(inputData.tokenSlug);
|
|
386
|
+
const sendingTokenInfo = this.state.chainService.getAssetBySlug(inputData.tokenSlug);
|
|
380
387
|
historyItem.amount = {
|
|
381
388
|
value: inputData.value || '0',
|
|
382
389
|
decimals: sendingTokenInfo.decimals || 0,
|
|
@@ -425,17 +432,29 @@ export default class TransactionService {
|
|
|
425
432
|
case ExtrinsicType.STAKING_UNBOND:
|
|
426
433
|
{
|
|
427
434
|
const data = parseTransactionData(transaction.data);
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
435
|
+
if (data.isLiquidStaking && data.derivativeTokenInfo && data.exchangeRate && data.inputTokenInfo) {
|
|
436
|
+
historyItem.amount = {
|
|
437
|
+
decimals: _getAssetDecimals(data.derivativeTokenInfo),
|
|
438
|
+
symbol: _getAssetSymbol(data.derivativeTokenInfo),
|
|
439
|
+
value: data.amount
|
|
440
|
+
};
|
|
441
|
+
historyItem.additionalInfo = {
|
|
442
|
+
inputTokenSlug: data.inputTokenInfo.slug,
|
|
443
|
+
exchangeRate: data.exchangeRate
|
|
444
|
+
};
|
|
445
|
+
} else {
|
|
446
|
+
historyItem.to = data.validatorAddress || '';
|
|
447
|
+
historyItem.amount = {
|
|
448
|
+
...baseNativeAmount,
|
|
449
|
+
value: data.amount || '0'
|
|
450
|
+
};
|
|
451
|
+
}
|
|
433
452
|
}
|
|
434
453
|
break;
|
|
435
454
|
case ExtrinsicType.STAKING_LEAVE_POOL:
|
|
436
455
|
{
|
|
437
456
|
const data = parseTransactionData(transaction.data);
|
|
438
|
-
historyItem.to = data.
|
|
457
|
+
historyItem.to = data.address || '';
|
|
439
458
|
historyItem.amount = {
|
|
440
459
|
...baseNativeAmount,
|
|
441
460
|
value: data.amount || '0'
|
|
@@ -454,7 +473,7 @@ export default class TransactionService {
|
|
|
454
473
|
case ExtrinsicType.STAKING_WITHDRAW:
|
|
455
474
|
{
|
|
456
475
|
const data = parseTransactionData(transaction.data);
|
|
457
|
-
historyItem.to = data.validatorAddress || '';
|
|
476
|
+
historyItem.to = data.unstakingInfo.validatorAddress || '';
|
|
458
477
|
historyItem.amount = {
|
|
459
478
|
...baseNativeAmount,
|
|
460
479
|
value: data.unstakingInfo.claimable || '0'
|
|
@@ -479,6 +498,68 @@ export default class TransactionService {
|
|
|
479
498
|
historyItem.to = (data === null || data === void 0 ? void 0 : data.to) || '';
|
|
480
499
|
break;
|
|
481
500
|
}
|
|
501
|
+
case ExtrinsicType.MINT_STDOT:
|
|
502
|
+
case ExtrinsicType.MINT_QDOT:
|
|
503
|
+
case ExtrinsicType.MINT_LDOT:
|
|
504
|
+
case ExtrinsicType.MINT_SDOT:
|
|
505
|
+
|
|
506
|
+
// eslint-disable-next-line no-fallthrough
|
|
507
|
+
case ExtrinsicType.MINT_VDOT:
|
|
508
|
+
{
|
|
509
|
+
const data = parseTransactionData(transaction.data);
|
|
510
|
+
const params = data.data;
|
|
511
|
+
const inputTokenInfo = this.state.chainService.getAssetBySlug(params.inputTokenSlug);
|
|
512
|
+
const isFeePaidWithInputAsset = params.feeTokenSlug === params.inputTokenSlug;
|
|
513
|
+
historyItem.amount = {
|
|
514
|
+
value: params.amount,
|
|
515
|
+
symbol: _getAssetSymbol(inputTokenInfo),
|
|
516
|
+
decimals: _getAssetDecimals(inputTokenInfo)
|
|
517
|
+
};
|
|
518
|
+
historyItem.additionalInfo = {
|
|
519
|
+
derivativeTokenSlug: params.derivativeTokenSlug,
|
|
520
|
+
exchangeRate: params.exchangeRate
|
|
521
|
+
};
|
|
522
|
+
eventLogs && !_isChainEvmCompatible(chainInfo) && parseLiquidStakingEvents(historyItem, eventLogs, inputTokenInfo, chainInfo, isFeePaidWithInputAsset, extrinsicType);
|
|
523
|
+
break;
|
|
524
|
+
}
|
|
525
|
+
case ExtrinsicType.REDEEM_QDOT:
|
|
526
|
+
{
|
|
527
|
+
const data = parseTransactionData(transaction.data);
|
|
528
|
+
const yieldPoolInfo = data.poolInfo;
|
|
529
|
+
if (yieldPoolInfo.metadata.derivativeAssets) {
|
|
530
|
+
const inputTokenSlug = yieldPoolInfo.metadata.inputAsset;
|
|
531
|
+
const inputTokenInfo = this.state.chainService.getAssetBySlug(inputTokenSlug);
|
|
532
|
+
historyItem.amount = {
|
|
533
|
+
value: data.amount,
|
|
534
|
+
symbol: _getAssetSymbol(inputTokenInfo),
|
|
535
|
+
decimals: _getAssetDecimals(inputTokenInfo)
|
|
536
|
+
};
|
|
537
|
+
eventLogs && parseLiquidStakingFastUnstakeEvents(historyItem, eventLogs, chainInfo, extrinsicType);
|
|
538
|
+
}
|
|
539
|
+
break;
|
|
540
|
+
}
|
|
541
|
+
case ExtrinsicType.REDEEM_STDOT:
|
|
542
|
+
case ExtrinsicType.REDEEM_LDOT:
|
|
543
|
+
case ExtrinsicType.REDEEM_SDOT:
|
|
544
|
+
|
|
545
|
+
// eslint-disable-next-line no-fallthrough
|
|
546
|
+
case ExtrinsicType.REDEEM_VDOT:
|
|
547
|
+
{
|
|
548
|
+
const data = parseTransactionData(transaction.data);
|
|
549
|
+
const yieldPoolInfo = data.poolInfo;
|
|
550
|
+
if (yieldPoolInfo.metadata.derivativeAssets) {
|
|
551
|
+
const derivativeTokenSlug = yieldPoolInfo.metadata.derivativeAssets[0];
|
|
552
|
+
const derivativeTokenInfo = this.state.chainService.getAssetBySlug(derivativeTokenSlug);
|
|
553
|
+
const chainInfo = this.state.chainService.getChainInfoByKey(data.poolInfo.chain);
|
|
554
|
+
historyItem.amount = {
|
|
555
|
+
value: data.amount,
|
|
556
|
+
symbol: _getAssetSymbol(derivativeTokenInfo),
|
|
557
|
+
decimals: _getAssetDecimals(derivativeTokenInfo)
|
|
558
|
+
};
|
|
559
|
+
eventLogs && !_isChainEvmCompatible(chainInfo) && parseLiquidStakingFastUnstakeEvents(historyItem, eventLogs, chainInfo, extrinsicType);
|
|
560
|
+
}
|
|
561
|
+
break;
|
|
562
|
+
}
|
|
482
563
|
case ExtrinsicType.UNKNOWN:
|
|
483
564
|
break;
|
|
484
565
|
}
|
|
@@ -524,7 +605,7 @@ export default class TransactionService {
|
|
|
524
605
|
});
|
|
525
606
|
|
|
526
607
|
// Create Input History Transaction History
|
|
527
|
-
this.historyService.insertHistories(this.transactionToHistories(id, startBlock, nonce)).catch(console.error);
|
|
608
|
+
this.state.historyService.insertHistories(this.transactionToHistories(id, startBlock, nonce)).catch(console.error);
|
|
528
609
|
console.debug(`Transaction "${id}" is sent`);
|
|
529
610
|
}
|
|
530
611
|
onHasTransactionHash({
|
|
@@ -541,8 +622,12 @@ export default class TransactionService {
|
|
|
541
622
|
this.updateTransaction(id, updateData);
|
|
542
623
|
|
|
543
624
|
// In this case transaction id is the same as extrinsic hash and will change after below update
|
|
544
|
-
this.historyService.updateHistoryByExtrinsicHash(id, updateData).catch(console.error);
|
|
625
|
+
this.state.historyService.updateHistoryByExtrinsicHash(id, updateData).catch(console.error);
|
|
545
626
|
console.debug(`Transaction "${id}" is submitted with hash ${extrinsicHash || ''}`);
|
|
627
|
+
const transaction = this.getTransaction(id);
|
|
628
|
+
if ([ExtrinsicType.STAKING_JOIN_POOL, ExtrinsicType.JOIN_YIELD_POOL, ExtrinsicType.MINT_LDOT, ExtrinsicType.MINT_QDOT, ExtrinsicType.MINT_SDOT, ExtrinsicType.MINT_VDOT].includes(transaction.extrinsicType)) {
|
|
629
|
+
this.handlePostEarningTransaction(id);
|
|
630
|
+
}
|
|
546
631
|
}
|
|
547
632
|
handlePostProcessing(id) {
|
|
548
633
|
// must be done after success/failure to make sure the transaction is finalized
|
|
@@ -551,15 +636,15 @@ export default class TransactionService {
|
|
|
551
636
|
const inputData = parseTransactionData(transaction.data);
|
|
552
637
|
try {
|
|
553
638
|
const sender = keyring.getPair(inputData.senderAddress);
|
|
554
|
-
sender && this.
|
|
555
|
-
this.eventService.emit('transaction.transferNft', undefined);
|
|
639
|
+
sender && this.state.dbService.handleNftTransfer(transaction.chain, [sender.address, ALL_ACCOUNT_KEY], inputData.nftItem).then(() => {
|
|
640
|
+
this.state.eventService.emit('transaction.transferNft', undefined);
|
|
556
641
|
}).catch(console.error);
|
|
557
642
|
} catch (e) {
|
|
558
643
|
console.error(e);
|
|
559
644
|
}
|
|
560
645
|
try {
|
|
561
646
|
const recipient = keyring.getPair(inputData.recipientAddress);
|
|
562
|
-
recipient && this.
|
|
647
|
+
recipient && this.state.dbService.addNft(recipient.address, {
|
|
563
648
|
...inputData.nftItem,
|
|
564
649
|
owner: recipient.address
|
|
565
650
|
}).catch(console.error);
|
|
@@ -567,7 +652,7 @@ export default class TransactionService {
|
|
|
567
652
|
console.error(e);
|
|
568
653
|
}
|
|
569
654
|
} else if ([ExtrinsicType.STAKING_BOND, ExtrinsicType.STAKING_UNBOND, ExtrinsicType.STAKING_WITHDRAW, ExtrinsicType.STAKING_CANCEL_UNSTAKE, ExtrinsicType.STAKING_CLAIM_REWARD, ExtrinsicType.STAKING_JOIN_POOL, ExtrinsicType.STAKING_POOL_WITHDRAW, ExtrinsicType.STAKING_LEAVE_POOL].includes(transaction.extrinsicType)) {
|
|
570
|
-
this.eventService.emit('transaction.submitStaking', transaction.chain);
|
|
655
|
+
this.state.eventService.emit('transaction.submitStaking', transaction.chain);
|
|
571
656
|
}
|
|
572
657
|
}
|
|
573
658
|
onSuccess({
|
|
@@ -583,14 +668,14 @@ export default class TransactionService {
|
|
|
583
668
|
});
|
|
584
669
|
|
|
585
670
|
// Write success transaction history
|
|
586
|
-
this.historyService.updateHistoryByExtrinsicHash(transaction.extrinsicHash, {
|
|
671
|
+
this.state.historyService.updateHistoryByExtrinsicHash(transaction.extrinsicHash, {
|
|
587
672
|
extrinsicHash,
|
|
588
673
|
status: ExtrinsicStatus.SUCCESS,
|
|
589
674
|
blockNumber: blockNumber || 0,
|
|
590
675
|
blockHash: blockHash || ''
|
|
591
676
|
}).catch(console.error);
|
|
592
|
-
const info = isHex(extrinsicHash) ? extrinsicHash : getBaseTransactionInfo(transaction, this.chainService.getChainInfoMap());
|
|
593
|
-
this.notificationService.notify({
|
|
677
|
+
const info = isHex(extrinsicHash) ? extrinsicHash : getBaseTransactionInfo(transaction, this.state.chainService.getChainInfoMap());
|
|
678
|
+
this.state.notificationService.notify({
|
|
594
679
|
type: NotificationType.SUCCESS,
|
|
595
680
|
title: t('Transaction completed'),
|
|
596
681
|
message: t('Transaction {{info}} completed', {
|
|
@@ -603,7 +688,7 @@ export default class TransactionService {
|
|
|
603
688
|
},
|
|
604
689
|
notifyViaBrowser: true
|
|
605
690
|
});
|
|
606
|
-
this.eventService.emit('transaction.done', transaction);
|
|
691
|
+
this.state.eventService.emit('transaction.done', transaction);
|
|
607
692
|
}
|
|
608
693
|
onFailed({
|
|
609
694
|
blockHash,
|
|
@@ -622,14 +707,14 @@ export default class TransactionService {
|
|
|
622
707
|
});
|
|
623
708
|
|
|
624
709
|
// Write failed transaction history
|
|
625
|
-
this.historyService.updateHistoryByExtrinsicHash(transaction.extrinsicHash, {
|
|
710
|
+
this.state.historyService.updateHistoryByExtrinsicHash(transaction.extrinsicHash, {
|
|
626
711
|
extrinsicHash: extrinsicHash || transaction.extrinsicHash,
|
|
627
712
|
status: nextStatus,
|
|
628
713
|
blockNumber: blockNumber || 0,
|
|
629
714
|
blockHash: blockHash || ''
|
|
630
715
|
}).catch(console.error);
|
|
631
|
-
const info = isHex(transaction === null || transaction === void 0 ? void 0 : transaction.extrinsicHash) ? transaction === null || transaction === void 0 ? void 0 : transaction.extrinsicHash : getBaseTransactionInfo(transaction, this.chainService.getChainInfoMap());
|
|
632
|
-
this.notificationService.notify({
|
|
716
|
+
const info = isHex(transaction === null || transaction === void 0 ? void 0 : transaction.extrinsicHash) ? transaction === null || transaction === void 0 ? void 0 : transaction.extrinsicHash : getBaseTransactionInfo(transaction, this.state.chainService.getChainInfoMap());
|
|
717
|
+
this.state.notificationService.notify({
|
|
633
718
|
type: NotificationType.ERROR,
|
|
634
719
|
title: t('Transaction failed'),
|
|
635
720
|
message: t('Transaction {{info}} failed', {
|
|
@@ -643,11 +728,11 @@ export default class TransactionService {
|
|
|
643
728
|
notifyViaBrowser: true
|
|
644
729
|
});
|
|
645
730
|
}
|
|
646
|
-
this.eventService.emit('transaction.failed', transaction);
|
|
731
|
+
this.state.eventService.emit('transaction.failed', transaction);
|
|
647
732
|
}
|
|
648
733
|
generateHashPayload(chain, transaction) {
|
|
649
734
|
var _transaction$nonce;
|
|
650
|
-
const chainInfo = this.chainService.getChainInfoByKey(chain);
|
|
735
|
+
const chainInfo = this.state.chainService.getChainInfoByKey(chain);
|
|
651
736
|
const txObject = {
|
|
652
737
|
nonce: (_transaction$nonce = transaction.nonce) !== null && _transaction$nonce !== void 0 ? _transaction$nonce : 0,
|
|
653
738
|
gasPrice: addHexPrefix(anyNumberToBN(transaction.gasPrice).toString(16)),
|
|
@@ -668,8 +753,8 @@ export default class TransactionService {
|
|
|
668
753
|
}) {
|
|
669
754
|
var _payload$nonce;
|
|
670
755
|
const payload = transaction;
|
|
671
|
-
const evmApi = this.chainService.getEvmApi(chain);
|
|
672
|
-
const chainInfo = this.chainService.getChainInfoByKey(chain);
|
|
756
|
+
const evmApi = this.state.chainService.getEvmApi(chain);
|
|
757
|
+
const chainInfo = this.state.chainService.getChainInfoByKey(chain);
|
|
673
758
|
const accountPair = keyring.getPair(address);
|
|
674
759
|
const account = {
|
|
675
760
|
address,
|
|
@@ -699,7 +784,7 @@ export default class TransactionService {
|
|
|
699
784
|
|
|
700
785
|
// Set unique nonce to avoid transaction errors
|
|
701
786
|
if (!payload.nonce) {
|
|
702
|
-
const evmApi = this.chainService.getEvmApi(chain);
|
|
787
|
+
const evmApi = this.state.chainService.getEvmApi(chain);
|
|
703
788
|
payload.nonce = await evmApi.api.eth.getTransactionCount(address);
|
|
704
789
|
}
|
|
705
790
|
if (!payload.chainId) {
|
|
@@ -734,7 +819,7 @@ export default class TransactionService {
|
|
|
734
819
|
extrinsicHash: id
|
|
735
820
|
};
|
|
736
821
|
if (isInjected) {
|
|
737
|
-
this.requestService.addConfirmation(id, url || EXTENSION_REQUEST_URL, 'evmWatchTransactionRequest', payload, {}).then(async ({
|
|
822
|
+
this.state.requestService.addConfirmation(id, url || EXTENSION_REQUEST_URL, 'evmWatchTransactionRequest', payload, {}).then(async ({
|
|
738
823
|
isApproved,
|
|
739
824
|
payload
|
|
740
825
|
}) => {
|
|
@@ -742,7 +827,7 @@ export default class TransactionService {
|
|
|
742
827
|
if (!payload) {
|
|
743
828
|
throw new EvmProviderError(EvmProviderErrorType.UNAUTHORIZED, 'Bad signature');
|
|
744
829
|
}
|
|
745
|
-
const web3Api = this.chainService.getEvmApi(chain).api;
|
|
830
|
+
const web3Api = this.state.chainService.getEvmApi(chain).api;
|
|
746
831
|
|
|
747
832
|
// Emit signed event
|
|
748
833
|
emitter.emit('signed', eventData);
|
|
@@ -798,7 +883,7 @@ export default class TransactionService {
|
|
|
798
883
|
emitter.emit('error', eventData);
|
|
799
884
|
});
|
|
800
885
|
} else {
|
|
801
|
-
this.requestService.addConfirmation(id, url || EXTENSION_REQUEST_URL, 'evmSendTransactionRequest', payload, {}).then(async ({
|
|
886
|
+
this.state.requestService.addConfirmation(id, url || EXTENSION_REQUEST_URL, 'evmSendTransactionRequest', payload, {}).then(async ({
|
|
802
887
|
isApproved,
|
|
803
888
|
payload
|
|
804
889
|
}) => {
|
|
@@ -807,7 +892,7 @@ export default class TransactionService {
|
|
|
807
892
|
if (!payload) {
|
|
808
893
|
throw new EvmProviderError(EvmProviderErrorType.UNAUTHORIZED, t('Failed to sign'));
|
|
809
894
|
}
|
|
810
|
-
const web3Api = this.chainService.getEvmApi(chain).api;
|
|
895
|
+
const web3Api = this.state.chainService.getEvmApi(chain).api;
|
|
811
896
|
if (!isExternal) {
|
|
812
897
|
signedTransaction = payload;
|
|
813
898
|
} else {
|
|
@@ -874,7 +959,7 @@ export default class TransactionService {
|
|
|
874
959
|
transaction.signAsync(address, {
|
|
875
960
|
signer: {
|
|
876
961
|
signPayload: async payload => {
|
|
877
|
-
const signing = await this.requestService.signInternalTransaction(id, address, url || EXTENSION_REQUEST_URL, payload);
|
|
962
|
+
const signing = await this.state.requestService.signInternalTransaction(id, address, url || EXTENSION_REQUEST_URL, payload);
|
|
878
963
|
return {
|
|
879
964
|
id: new Date().getTime(),
|
|
880
965
|
signature: signing.signature
|
|
@@ -886,7 +971,7 @@ export default class TransactionService {
|
|
|
886
971
|
emitter.emit('signed', eventData);
|
|
887
972
|
|
|
888
973
|
// Send transaction
|
|
889
|
-
const api = this.chainService.getSubstrateApi(chain);
|
|
974
|
+
const api = this.state.chainService.getSubstrateApi(chain);
|
|
890
975
|
eventData.nonce = rs.nonce.toNumber();
|
|
891
976
|
eventData.startBlock = (await api.api.query.system.number()).toPrimitive();
|
|
892
977
|
this.handleTransactionTimeout(emitter, eventData);
|
|
@@ -954,6 +1039,27 @@ export default class TransactionService {
|
|
|
954
1039
|
clearTimeout(timeout);
|
|
955
1040
|
});
|
|
956
1041
|
}
|
|
1042
|
+
handlePostEarningTransaction(id) {
|
|
1043
|
+
const transaction = this.getTransaction(id);
|
|
1044
|
+
const data = transaction.data;
|
|
1045
|
+
const slug = data.data.slug;
|
|
1046
|
+
const poolHandler = this.state.earningService.getPoolHandler(slug);
|
|
1047
|
+
if (poolHandler) {
|
|
1048
|
+
const type = poolHandler.type;
|
|
1049
|
+
if (type === YieldPoolType.NATIVE_STAKING) {
|
|
1050
|
+
return;
|
|
1051
|
+
}
|
|
1052
|
+
} else {
|
|
1053
|
+
return;
|
|
1054
|
+
}
|
|
1055
|
+
this.state.mintCampaignService.unlockDotCampaign.mintNft({
|
|
1056
|
+
transactionId: id,
|
|
1057
|
+
address: transaction.address,
|
|
1058
|
+
slug: slug,
|
|
1059
|
+
network: transaction.chain,
|
|
1060
|
+
extrinsicHash: transaction.extrinsicHash
|
|
1061
|
+
}).catch(console.error);
|
|
1062
|
+
}
|
|
957
1063
|
resetWallet() {
|
|
958
1064
|
this.transactionSubject.next({});
|
|
959
1065
|
}
|
|
@@ -30,6 +30,8 @@ export interface SWTransactionInput extends SwInputBase, Partial<Pick<SWTransact
|
|
|
30
30
|
errors?: SWTransaction['errors'];
|
|
31
31
|
edAsWarning?: boolean;
|
|
32
32
|
isTransferAll?: boolean;
|
|
33
|
+
resolveOnDone?: boolean;
|
|
34
|
+
skipFeeValidation?: boolean;
|
|
33
35
|
}
|
|
34
36
|
export declare type SWTransactionResponse = SwInputBase & Pick<SWTransaction, 'warnings' | 'errors'> & Partial<Pick<SWTransaction, 'id' | 'extrinsicHash' | 'status' | 'estimateFee'>>;
|
|
35
37
|
export declare type ValidateTransactionResponseInput = SWTransactionInput;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './unlock-dot';
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
export interface UnlockDotAdditionalData {
|
|
2
|
+
slug: string;
|
|
3
|
+
network: string;
|
|
4
|
+
extrinsicHash?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface UnlockDotCheckMintRequest {
|
|
7
|
+
address: string;
|
|
8
|
+
additionalData: UnlockDotAdditionalData;
|
|
9
|
+
category: string;
|
|
10
|
+
campaignId: number;
|
|
11
|
+
}
|
|
12
|
+
export interface UnlockDotCheckMintResponse {
|
|
13
|
+
requestId: number | null;
|
|
14
|
+
userId: number;
|
|
15
|
+
validUser: boolean;
|
|
16
|
+
validCampaign: boolean;
|
|
17
|
+
validCategory: boolean;
|
|
18
|
+
isWhiteList: boolean;
|
|
19
|
+
isOwner: boolean;
|
|
20
|
+
hasBalance: boolean;
|
|
21
|
+
notDuplicated: boolean;
|
|
22
|
+
inMintingTime: boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface UnlockDotMintedData {
|
|
25
|
+
id: number;
|
|
26
|
+
campaignId: number;
|
|
27
|
+
collectionId: number;
|
|
28
|
+
userId: number;
|
|
29
|
+
address: string;
|
|
30
|
+
status: string;
|
|
31
|
+
extrinsicHash: string;
|
|
32
|
+
mintCategory: string;
|
|
33
|
+
mintDate: null;
|
|
34
|
+
rmrkNftId: string;
|
|
35
|
+
nftName: string;
|
|
36
|
+
nftImage: string;
|
|
37
|
+
recipient: string;
|
|
38
|
+
blockNumber: number;
|
|
39
|
+
additionalData: string;
|
|
40
|
+
}
|
|
41
|
+
export declare type UnlockDotTransactionNft = UnlockDotMintedData | undefined | Pick<UnlockDotMintedData, 'nftImage'>;
|
|
42
|
+
export interface UnlockDotFetchMintedRequest {
|
|
43
|
+
address: string;
|
|
44
|
+
}
|
|
45
|
+
export declare type UnlockDotFetchMintedResponse = UnlockDotMintedData[];
|
|
46
|
+
export interface UnlockDotMintSubmitRequest {
|
|
47
|
+
recipient: string;
|
|
48
|
+
requestId: number;
|
|
49
|
+
}
|
|
50
|
+
export declare type UnlockDotMintSubmitResponse = UnlockDotMintedData;
|
|
51
|
+
export interface UnlockDotCheckMintData {
|
|
52
|
+
address: string;
|
|
53
|
+
slug: string;
|
|
54
|
+
network: string;
|
|
55
|
+
extrinsicHash?: string;
|
|
56
|
+
}
|
|
57
|
+
export interface UnlockDotSubmitMintData {
|
|
58
|
+
transactionId: string;
|
|
59
|
+
address: string;
|
|
60
|
+
slug: string;
|
|
61
|
+
network: string;
|
|
62
|
+
extrinsicHash: string;
|
|
63
|
+
}
|
|
64
|
+
export interface RequestUnlockDotCheckCanMint {
|
|
65
|
+
address: string;
|
|
66
|
+
slug: string;
|
|
67
|
+
network: string;
|
|
68
|
+
}
|
|
69
|
+
export interface RequestUnlockDotSubscribeMintedData {
|
|
70
|
+
transactionId: string;
|
|
71
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/types/index.d.ts
CHANGED
|
@@ -5,7 +5,12 @@ export interface Message extends MessageEvent {
|
|
|
5
5
|
origin: string;
|
|
6
6
|
response?: string;
|
|
7
7
|
subscription?: string;
|
|
8
|
+
sender?: string;
|
|
8
9
|
};
|
|
9
10
|
}
|
|
10
11
|
export * from './balance';
|
|
11
12
|
export * from './buy';
|
|
13
|
+
export * from './campaigns';
|
|
14
|
+
export * from './ordinal';
|
|
15
|
+
export * from './transaction';
|
|
16
|
+
export * from './yield';
|