@subwallet/extension-base 1.1.32-0 → 1.1.32-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 +112 -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/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 +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 +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/services/campaign-service/index.js +28 -6
- package/cjs/services/chain-service/constants.js +1 -15
- package/cjs/services/chain-service/index.js +3 -2
- 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 +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.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 +389 -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 +720 -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 +1 -1
- package/cjs/services/storage-service/DatabaseService.js +66 -0
- package/cjs/services/storage-service/databases/index.js +4 -0
- package/cjs/services/storage-service/db-stores/Campaign.js +9 -3
- 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 +245 -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/fetchStaticData.js +2 -1
- package/cjs/utils/index.js +89 -1
- package/cjs/utils/keyring.js +57 -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/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.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 +316 -3
- package/services/campaign-service/index.js +28 -6
- package/services/chain-service/constants.d.ts +0 -11
- package/services/chain-service/constants.js +0 -13
- package/services/chain-service/index.js +3 -2
- 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 +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 +380 -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 +93 -0
- package/services/earning-service/service.js +709 -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 +1 -1
- package/services/storage-service/DatabaseService.d.ts +23 -1
- package/services/storage-service/DatabaseService.js +66 -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/Campaign.js +9 -3
- 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 +4 -15
- package/services/transaction-service/index.js +243 -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 +251 -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/number.d.ts +2 -1
- package/utils/number.js +2 -1
- package/utils/object.d.ts +1 -0
- package/utils/object.js +6 -0
|
@@ -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,11 +473,21 @@ export default class TransactionService {
|
|
|
454
473
|
case ExtrinsicType.STAKING_WITHDRAW:
|
|
455
474
|
{
|
|
456
475
|
const data = parseTransactionData(transaction.data);
|
|
457
|
-
|
|
458
|
-
|
|
476
|
+
const slug = data.slug;
|
|
477
|
+
const poolHandler = this.state.earningService.getPoolHandler(slug);
|
|
478
|
+
const amount = {
|
|
459
479
|
...baseNativeAmount,
|
|
460
480
|
value: data.unstakingInfo.claimable || '0'
|
|
461
481
|
};
|
|
482
|
+
if (poolHandler) {
|
|
483
|
+
const asset = this.state.getAssetBySlug(poolHandler.metadataInfo.inputAsset);
|
|
484
|
+
if (asset) {
|
|
485
|
+
amount.decimals = asset.decimals || 0;
|
|
486
|
+
amount.symbol = asset.symbol;
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
historyItem.to = data.unstakingInfo.validatorAddress || '';
|
|
490
|
+
historyItem.amount = amount;
|
|
462
491
|
break;
|
|
463
492
|
}
|
|
464
493
|
case ExtrinsicType.STAKING_CANCEL_UNSTAKE:
|
|
@@ -479,6 +508,116 @@ export default class TransactionService {
|
|
|
479
508
|
historyItem.to = (data === null || data === void 0 ? void 0 : data.to) || '';
|
|
480
509
|
break;
|
|
481
510
|
}
|
|
511
|
+
case ExtrinsicType.MINT_STDOT:
|
|
512
|
+
case ExtrinsicType.MINT_QDOT:
|
|
513
|
+
case ExtrinsicType.MINT_LDOT:
|
|
514
|
+
case ExtrinsicType.MINT_SDOT:
|
|
515
|
+
|
|
516
|
+
// eslint-disable-next-line no-fallthrough
|
|
517
|
+
case ExtrinsicType.MINT_VDOT:
|
|
518
|
+
{
|
|
519
|
+
const params = parseTransactionData(transaction.data);
|
|
520
|
+
const inputTokenInfo = this.state.chainService.getAssetBySlug(params.inputTokenSlug);
|
|
521
|
+
const isFeePaidWithInputAsset = params.feeTokenSlug === params.inputTokenSlug;
|
|
522
|
+
historyItem.amount = {
|
|
523
|
+
value: params.amount,
|
|
524
|
+
symbol: _getAssetSymbol(inputTokenInfo),
|
|
525
|
+
decimals: _getAssetDecimals(inputTokenInfo)
|
|
526
|
+
};
|
|
527
|
+
const additionalInfo = {
|
|
528
|
+
slug: params.slug,
|
|
529
|
+
derivativeTokenSlug: params.derivativeTokenSlug,
|
|
530
|
+
exchangeRate: params.exchangeRate
|
|
531
|
+
};
|
|
532
|
+
historyItem.additionalInfo = additionalInfo;
|
|
533
|
+
eventLogs && !_isChainEvmCompatible(chainInfo) && parseLiquidStakingEvents(historyItem, eventLogs, inputTokenInfo, chainInfo, isFeePaidWithInputAsset, extrinsicType);
|
|
534
|
+
break;
|
|
535
|
+
}
|
|
536
|
+
case ExtrinsicType.UNSTAKE_QDOT:
|
|
537
|
+
|
|
538
|
+
// eslint-disable-next-line no-fallthrough
|
|
539
|
+
case ExtrinsicType.REDEEM_QDOT:
|
|
540
|
+
{
|
|
541
|
+
const data = parseTransactionData(transaction.data);
|
|
542
|
+
const yieldPoolInfo = data.poolInfo;
|
|
543
|
+
if (yieldPoolInfo.metadata.derivativeAssets) {
|
|
544
|
+
const inputTokenSlug = yieldPoolInfo.metadata.inputAsset;
|
|
545
|
+
const inputTokenInfo = this.state.chainService.getAssetBySlug(inputTokenSlug);
|
|
546
|
+
historyItem.amount = {
|
|
547
|
+
value: data.amount,
|
|
548
|
+
symbol: _getAssetSymbol(inputTokenInfo),
|
|
549
|
+
decimals: _getAssetDecimals(inputTokenInfo)
|
|
550
|
+
};
|
|
551
|
+
eventLogs && parseLiquidStakingFastUnstakeEvents(historyItem, eventLogs, chainInfo, extrinsicType);
|
|
552
|
+
const additionalInfo = {
|
|
553
|
+
minAmountPercent: 1,
|
|
554
|
+
symbol: inputTokenInfo.symbol,
|
|
555
|
+
decimals: inputTokenInfo.decimals || 0,
|
|
556
|
+
exchangeRate: 1,
|
|
557
|
+
slug: yieldPoolInfo.slug,
|
|
558
|
+
type: yieldPoolInfo.type,
|
|
559
|
+
chain: yieldPoolInfo.chain,
|
|
560
|
+
group: yieldPoolInfo.group,
|
|
561
|
+
isFast: data.fastLeave
|
|
562
|
+
};
|
|
563
|
+
historyItem.additionalInfo = additionalInfo;
|
|
564
|
+
}
|
|
565
|
+
break;
|
|
566
|
+
}
|
|
567
|
+
case ExtrinsicType.UNSTAKE_VDOT:
|
|
568
|
+
case ExtrinsicType.UNSTAKE_LDOT:
|
|
569
|
+
case ExtrinsicType.UNSTAKE_SDOT:
|
|
570
|
+
case ExtrinsicType.UNSTAKE_STDOT:
|
|
571
|
+
case ExtrinsicType.REDEEM_STDOT:
|
|
572
|
+
case ExtrinsicType.REDEEM_LDOT:
|
|
573
|
+
case ExtrinsicType.REDEEM_SDOT:
|
|
574
|
+
|
|
575
|
+
// eslint-disable-next-line no-fallthrough
|
|
576
|
+
case ExtrinsicType.REDEEM_VDOT:
|
|
577
|
+
{
|
|
578
|
+
const data = parseTransactionData(transaction.data);
|
|
579
|
+
const yieldPoolInfo = data.poolInfo;
|
|
580
|
+
const minAmountPercents = this.state.earningService.getMinAmountPercent();
|
|
581
|
+
if (yieldPoolInfo.metadata.derivativeAssets) {
|
|
582
|
+
var _yieldPoolInfo$statis;
|
|
583
|
+
const derivativeTokenSlug = yieldPoolInfo.metadata.derivativeAssets[0];
|
|
584
|
+
const derivativeTokenInfo = this.state.chainService.getAssetBySlug(derivativeTokenSlug);
|
|
585
|
+
const chainInfo = this.state.chainService.getChainInfoByKey(data.poolInfo.chain);
|
|
586
|
+
historyItem.amount = {
|
|
587
|
+
value: data.amount,
|
|
588
|
+
symbol: _getAssetSymbol(derivativeTokenInfo),
|
|
589
|
+
decimals: _getAssetDecimals(derivativeTokenInfo)
|
|
590
|
+
};
|
|
591
|
+
eventLogs && !_isChainEvmCompatible(chainInfo) && parseLiquidStakingFastUnstakeEvents(historyItem, eventLogs, chainInfo, extrinsicType);
|
|
592
|
+
const minAmountPercent = minAmountPercents[yieldPoolInfo.slug] || 1;
|
|
593
|
+
const inputTokenSlug = yieldPoolInfo.metadata.inputAsset;
|
|
594
|
+
const inputTokenInfo = this.state.chainService.getAssetBySlug(inputTokenSlug);
|
|
595
|
+
const additionalInfo = {
|
|
596
|
+
minAmountPercent,
|
|
597
|
+
symbol: inputTokenInfo.symbol,
|
|
598
|
+
decimals: inputTokenInfo.decimals || 0,
|
|
599
|
+
exchangeRate: ((_yieldPoolInfo$statis = yieldPoolInfo.statistic) === null || _yieldPoolInfo$statis === void 0 ? void 0 : _yieldPoolInfo$statis.assetEarning[0].exchangeRate) || 1,
|
|
600
|
+
slug: yieldPoolInfo.slug,
|
|
601
|
+
type: yieldPoolInfo.type,
|
|
602
|
+
chain: yieldPoolInfo.chain,
|
|
603
|
+
group: yieldPoolInfo.group,
|
|
604
|
+
isFast: data.fastLeave
|
|
605
|
+
};
|
|
606
|
+
historyItem.additionalInfo = additionalInfo;
|
|
607
|
+
}
|
|
608
|
+
break;
|
|
609
|
+
}
|
|
610
|
+
case ExtrinsicType.TOKEN_APPROVE:
|
|
611
|
+
{
|
|
612
|
+
const data = parseTransactionData(transaction.data);
|
|
613
|
+
const inputAsset = this.state.chainService.getAssetBySlug(data.inputTokenSlug);
|
|
614
|
+
historyItem.amount = {
|
|
615
|
+
value: '0',
|
|
616
|
+
symbol: _getAssetSymbol(inputAsset),
|
|
617
|
+
decimals: _getAssetDecimals(inputAsset)
|
|
618
|
+
};
|
|
619
|
+
break;
|
|
620
|
+
}
|
|
482
621
|
case ExtrinsicType.UNKNOWN:
|
|
483
622
|
break;
|
|
484
623
|
}
|
|
@@ -524,7 +663,7 @@ export default class TransactionService {
|
|
|
524
663
|
});
|
|
525
664
|
|
|
526
665
|
// Create Input History Transaction History
|
|
527
|
-
this.historyService.insertHistories(this.transactionToHistories(id, startBlock, nonce)).catch(console.error);
|
|
666
|
+
this.state.historyService.insertHistories(this.transactionToHistories(id, startBlock, nonce)).catch(console.error);
|
|
528
667
|
console.debug(`Transaction "${id}" is sent`);
|
|
529
668
|
}
|
|
530
669
|
onHasTransactionHash({
|
|
@@ -541,8 +680,12 @@ export default class TransactionService {
|
|
|
541
680
|
this.updateTransaction(id, updateData);
|
|
542
681
|
|
|
543
682
|
// 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);
|
|
683
|
+
this.state.historyService.updateHistoryByExtrinsicHash(id, updateData).catch(console.error);
|
|
545
684
|
console.debug(`Transaction "${id}" is submitted with hash ${extrinsicHash || ''}`);
|
|
685
|
+
const transaction = this.getTransaction(id);
|
|
686
|
+
if ([ExtrinsicType.STAKING_JOIN_POOL, ExtrinsicType.JOIN_YIELD_POOL, ExtrinsicType.MINT_LDOT, ExtrinsicType.MINT_QDOT, ExtrinsicType.MINT_SDOT, ExtrinsicType.MINT_VDOT].includes(transaction.extrinsicType)) {
|
|
687
|
+
this.handlePostEarningTransaction(id);
|
|
688
|
+
}
|
|
546
689
|
}
|
|
547
690
|
handlePostProcessing(id) {
|
|
548
691
|
// must be done after success/failure to make sure the transaction is finalized
|
|
@@ -551,15 +694,15 @@ export default class TransactionService {
|
|
|
551
694
|
const inputData = parseTransactionData(transaction.data);
|
|
552
695
|
try {
|
|
553
696
|
const sender = keyring.getPair(inputData.senderAddress);
|
|
554
|
-
sender && this.
|
|
555
|
-
this.eventService.emit('transaction.transferNft', undefined);
|
|
697
|
+
sender && this.state.dbService.handleNftTransfer(transaction.chain, [sender.address, ALL_ACCOUNT_KEY], inputData.nftItem).then(() => {
|
|
698
|
+
this.state.eventService.emit('transaction.transferNft', undefined);
|
|
556
699
|
}).catch(console.error);
|
|
557
700
|
} catch (e) {
|
|
558
701
|
console.error(e);
|
|
559
702
|
}
|
|
560
703
|
try {
|
|
561
704
|
const recipient = keyring.getPair(inputData.recipientAddress);
|
|
562
|
-
recipient && this.
|
|
705
|
+
recipient && this.state.dbService.addNft(recipient.address, {
|
|
563
706
|
...inputData.nftItem,
|
|
564
707
|
owner: recipient.address
|
|
565
708
|
}).catch(console.error);
|
|
@@ -567,7 +710,7 @@ export default class TransactionService {
|
|
|
567
710
|
console.error(e);
|
|
568
711
|
}
|
|
569
712
|
} 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);
|
|
713
|
+
this.state.eventService.emit('transaction.submitStaking', transaction.chain);
|
|
571
714
|
}
|
|
572
715
|
}
|
|
573
716
|
onSuccess({
|
|
@@ -583,14 +726,14 @@ export default class TransactionService {
|
|
|
583
726
|
});
|
|
584
727
|
|
|
585
728
|
// Write success transaction history
|
|
586
|
-
this.historyService.updateHistoryByExtrinsicHash(transaction.extrinsicHash, {
|
|
729
|
+
this.state.historyService.updateHistoryByExtrinsicHash(transaction.extrinsicHash, {
|
|
587
730
|
extrinsicHash,
|
|
588
731
|
status: ExtrinsicStatus.SUCCESS,
|
|
589
732
|
blockNumber: blockNumber || 0,
|
|
590
733
|
blockHash: blockHash || ''
|
|
591
734
|
}).catch(console.error);
|
|
592
|
-
const info = isHex(extrinsicHash) ? extrinsicHash : getBaseTransactionInfo(transaction, this.chainService.getChainInfoMap());
|
|
593
|
-
this.notificationService.notify({
|
|
735
|
+
const info = isHex(extrinsicHash) ? extrinsicHash : getBaseTransactionInfo(transaction, this.state.chainService.getChainInfoMap());
|
|
736
|
+
this.state.notificationService.notify({
|
|
594
737
|
type: NotificationType.SUCCESS,
|
|
595
738
|
title: t('Transaction completed'),
|
|
596
739
|
message: t('Transaction {{info}} completed', {
|
|
@@ -603,7 +746,7 @@ export default class TransactionService {
|
|
|
603
746
|
},
|
|
604
747
|
notifyViaBrowser: true
|
|
605
748
|
});
|
|
606
|
-
this.eventService.emit('transaction.done', transaction);
|
|
749
|
+
this.state.eventService.emit('transaction.done', transaction);
|
|
607
750
|
}
|
|
608
751
|
onFailed({
|
|
609
752
|
blockHash,
|
|
@@ -622,14 +765,14 @@ export default class TransactionService {
|
|
|
622
765
|
});
|
|
623
766
|
|
|
624
767
|
// Write failed transaction history
|
|
625
|
-
this.historyService.updateHistoryByExtrinsicHash(transaction.extrinsicHash, {
|
|
768
|
+
this.state.historyService.updateHistoryByExtrinsicHash(transaction.extrinsicHash, {
|
|
626
769
|
extrinsicHash: extrinsicHash || transaction.extrinsicHash,
|
|
627
770
|
status: nextStatus,
|
|
628
771
|
blockNumber: blockNumber || 0,
|
|
629
772
|
blockHash: blockHash || ''
|
|
630
773
|
}).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({
|
|
774
|
+
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());
|
|
775
|
+
this.state.notificationService.notify({
|
|
633
776
|
type: NotificationType.ERROR,
|
|
634
777
|
title: t('Transaction failed'),
|
|
635
778
|
message: t('Transaction {{info}} failed', {
|
|
@@ -643,11 +786,11 @@ export default class TransactionService {
|
|
|
643
786
|
notifyViaBrowser: true
|
|
644
787
|
});
|
|
645
788
|
}
|
|
646
|
-
this.eventService.emit('transaction.failed', transaction);
|
|
789
|
+
this.state.eventService.emit('transaction.failed', transaction);
|
|
647
790
|
}
|
|
648
791
|
generateHashPayload(chain, transaction) {
|
|
649
792
|
var _transaction$nonce;
|
|
650
|
-
const chainInfo = this.chainService.getChainInfoByKey(chain);
|
|
793
|
+
const chainInfo = this.state.chainService.getChainInfoByKey(chain);
|
|
651
794
|
const txObject = {
|
|
652
795
|
nonce: (_transaction$nonce = transaction.nonce) !== null && _transaction$nonce !== void 0 ? _transaction$nonce : 0,
|
|
653
796
|
gasPrice: addHexPrefix(anyNumberToBN(transaction.gasPrice).toString(16)),
|
|
@@ -668,8 +811,8 @@ export default class TransactionService {
|
|
|
668
811
|
}) {
|
|
669
812
|
var _payload$nonce;
|
|
670
813
|
const payload = transaction;
|
|
671
|
-
const evmApi = this.chainService.getEvmApi(chain);
|
|
672
|
-
const chainInfo = this.chainService.getChainInfoByKey(chain);
|
|
814
|
+
const evmApi = this.state.chainService.getEvmApi(chain);
|
|
815
|
+
const chainInfo = this.state.chainService.getChainInfoByKey(chain);
|
|
673
816
|
const accountPair = keyring.getPair(address);
|
|
674
817
|
const account = {
|
|
675
818
|
address,
|
|
@@ -699,7 +842,7 @@ export default class TransactionService {
|
|
|
699
842
|
|
|
700
843
|
// Set unique nonce to avoid transaction errors
|
|
701
844
|
if (!payload.nonce) {
|
|
702
|
-
const evmApi = this.chainService.getEvmApi(chain);
|
|
845
|
+
const evmApi = this.state.chainService.getEvmApi(chain);
|
|
703
846
|
payload.nonce = await evmApi.api.eth.getTransactionCount(address);
|
|
704
847
|
}
|
|
705
848
|
if (!payload.chainId) {
|
|
@@ -734,7 +877,7 @@ export default class TransactionService {
|
|
|
734
877
|
extrinsicHash: id
|
|
735
878
|
};
|
|
736
879
|
if (isInjected) {
|
|
737
|
-
this.requestService.addConfirmation(id, url || EXTENSION_REQUEST_URL, 'evmWatchTransactionRequest', payload, {}).then(async ({
|
|
880
|
+
this.state.requestService.addConfirmation(id, url || EXTENSION_REQUEST_URL, 'evmWatchTransactionRequest', payload, {}).then(async ({
|
|
738
881
|
isApproved,
|
|
739
882
|
payload
|
|
740
883
|
}) => {
|
|
@@ -742,7 +885,7 @@ export default class TransactionService {
|
|
|
742
885
|
if (!payload) {
|
|
743
886
|
throw new EvmProviderError(EvmProviderErrorType.UNAUTHORIZED, 'Bad signature');
|
|
744
887
|
}
|
|
745
|
-
const web3Api = this.chainService.getEvmApi(chain).api;
|
|
888
|
+
const web3Api = this.state.chainService.getEvmApi(chain).api;
|
|
746
889
|
|
|
747
890
|
// Emit signed event
|
|
748
891
|
emitter.emit('signed', eventData);
|
|
@@ -798,7 +941,7 @@ export default class TransactionService {
|
|
|
798
941
|
emitter.emit('error', eventData);
|
|
799
942
|
});
|
|
800
943
|
} else {
|
|
801
|
-
this.requestService.addConfirmation(id, url || EXTENSION_REQUEST_URL, 'evmSendTransactionRequest', payload, {}).then(async ({
|
|
944
|
+
this.state.requestService.addConfirmation(id, url || EXTENSION_REQUEST_URL, 'evmSendTransactionRequest', payload, {}).then(async ({
|
|
802
945
|
isApproved,
|
|
803
946
|
payload
|
|
804
947
|
}) => {
|
|
@@ -807,7 +950,7 @@ export default class TransactionService {
|
|
|
807
950
|
if (!payload) {
|
|
808
951
|
throw new EvmProviderError(EvmProviderErrorType.UNAUTHORIZED, t('Failed to sign'));
|
|
809
952
|
}
|
|
810
|
-
const web3Api = this.chainService.getEvmApi(chain).api;
|
|
953
|
+
const web3Api = this.state.chainService.getEvmApi(chain).api;
|
|
811
954
|
if (!isExternal) {
|
|
812
955
|
signedTransaction = payload;
|
|
813
956
|
} else {
|
|
@@ -874,7 +1017,7 @@ export default class TransactionService {
|
|
|
874
1017
|
transaction.signAsync(address, {
|
|
875
1018
|
signer: {
|
|
876
1019
|
signPayload: async payload => {
|
|
877
|
-
const signing = await this.requestService.signInternalTransaction(id, address, url || EXTENSION_REQUEST_URL, payload);
|
|
1020
|
+
const signing = await this.state.requestService.signInternalTransaction(id, address, url || EXTENSION_REQUEST_URL, payload);
|
|
878
1021
|
return {
|
|
879
1022
|
id: new Date().getTime(),
|
|
880
1023
|
signature: signing.signature
|
|
@@ -886,7 +1029,7 @@ export default class TransactionService {
|
|
|
886
1029
|
emitter.emit('signed', eventData);
|
|
887
1030
|
|
|
888
1031
|
// Send transaction
|
|
889
|
-
const api = this.chainService.getSubstrateApi(chain);
|
|
1032
|
+
const api = this.state.chainService.getSubstrateApi(chain);
|
|
890
1033
|
eventData.nonce = rs.nonce.toNumber();
|
|
891
1034
|
eventData.startBlock = (await api.api.query.system.number()).toPrimitive();
|
|
892
1035
|
this.handleTransactionTimeout(emitter, eventData);
|
|
@@ -954,6 +1097,33 @@ export default class TransactionService {
|
|
|
954
1097
|
clearTimeout(timeout);
|
|
955
1098
|
});
|
|
956
1099
|
}
|
|
1100
|
+
handlePostEarningTransaction(id) {
|
|
1101
|
+
const transaction = this.getTransaction(id);
|
|
1102
|
+
let slug;
|
|
1103
|
+
|
|
1104
|
+
// TODO
|
|
1105
|
+
if ('data' in transaction.data) {
|
|
1106
|
+
slug = transaction.data.data.slug;
|
|
1107
|
+
} else {
|
|
1108
|
+
slug = transaction.data.slug;
|
|
1109
|
+
}
|
|
1110
|
+
const poolHandler = this.state.earningService.getPoolHandler(slug);
|
|
1111
|
+
if (poolHandler) {
|
|
1112
|
+
const type = poolHandler.type;
|
|
1113
|
+
if (type === YieldPoolType.NATIVE_STAKING) {
|
|
1114
|
+
return;
|
|
1115
|
+
}
|
|
1116
|
+
} else {
|
|
1117
|
+
return;
|
|
1118
|
+
}
|
|
1119
|
+
this.state.mintCampaignService.unlockDotCampaign.mintNft({
|
|
1120
|
+
transactionId: id,
|
|
1121
|
+
address: transaction.address,
|
|
1122
|
+
slug: slug,
|
|
1123
|
+
network: transaction.chain,
|
|
1124
|
+
extrinsicHash: transaction.extrinsicHash
|
|
1125
|
+
}).catch(console.error);
|
|
1126
|
+
}
|
|
957
1127
|
resetWallet() {
|
|
958
1128
|
this.transactionSubject.next({});
|
|
959
1129
|
}
|
|
@@ -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 {};
|