@subwallet/extension-base 1.1.28-beta.1 → 1.1.30-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 +70 -93
- package/background/KoniTypes.js +14 -16
- package/background/errors/TransactionError.js +4 -9
- package/cjs/background/KoniTypes.js +17 -17
- package/cjs/background/errors/TransactionError.js +4 -9
- package/cjs/constants/index.js +3 -9
- package/cjs/koni/api/nft/config.js +23 -33
- package/cjs/koni/api/nft/index.js +0 -14
- package/cjs/koni/api/nft/nft.js +22 -1
- package/cjs/koni/api/staking/bonding/amplitude.js +15 -17
- package/cjs/koni/api/staking/bonding/astar.js +10 -11
- package/cjs/koni/api/staking/bonding/index.js +1 -4
- package/cjs/koni/api/staking/bonding/paraChain.js +23 -25
- package/cjs/koni/api/staking/bonding/relayChain.js +45 -48
- package/cjs/koni/api/staking/bonding/utils.js +86 -104
- package/cjs/koni/api/staking/index.js +5 -6
- package/cjs/koni/api/staking/paraChain.js +5 -6
- package/cjs/koni/api/staking/relayChain.js +2 -3
- package/cjs/koni/background/cron.js +0 -2
- package/cjs/koni/background/handlers/Extension.js +88 -326
- package/cjs/koni/background/handlers/State.js +3 -51
- package/cjs/koni/background/handlers/index.js +2 -4
- package/cjs/koni/background/subscription.js +18 -88
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/campaign-service/index.js +6 -9
- package/cjs/services/chain-service/constants.js +16 -2
- package/cjs/services/chain-service/utils.js +1 -7
- package/cjs/services/event-service/index.js +0 -4
- package/cjs/services/keyring-service/index.js +2 -14
- 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/index.js +0 -4
- package/cjs/services/notification-service/NotificationService.js +1 -1
- package/cjs/services/storage-service/DatabaseService.js +0 -47
- package/cjs/services/storage-service/databases/index.js +0 -4
- package/cjs/services/storage-service/db-stores/NominatorMetadata.js +3 -3
- package/cjs/services/transaction-service/event-parser/index.js +0 -58
- package/cjs/services/transaction-service/helpers/index.js +1 -3
- package/cjs/services/transaction-service/index.js +74 -180
- package/cjs/services/transaction-service/utils.js +0 -1
- package/cjs/types/index.js +0 -44
- package/cjs/utils/fetchStaticData.js +1 -2
- package/cjs/utils/index.js +1 -89
- package/constants/index.d.ts +0 -2
- package/constants/index.js +0 -2
- package/koni/api/nft/config.js +23 -33
- package/koni/api/nft/index.js +1 -15
- package/koni/api/nft/nft.js +23 -2
- package/koni/api/staking/bonding/amplitude.js +9 -11
- package/koni/api/staking/bonding/astar.js +8 -9
- package/koni/api/staking/bonding/index.d.ts +1 -1
- package/koni/api/staking/bonding/index.js +1 -5
- package/koni/api/staking/bonding/paraChain.js +10 -12
- package/koni/api/staking/bonding/relayChain.d.ts +2 -2
- package/koni/api/staking/bonding/relayChain.js +30 -33
- package/koni/api/staking/bonding/utils.d.ts +38 -15
- package/koni/api/staking/bonding/utils.js +69 -85
- package/koni/api/staking/index.js +1 -2
- package/koni/api/staking/paraChain.js +6 -7
- package/koni/api/staking/relayChain.js +3 -4
- package/koni/background/cron.js +0 -2
- package/koni/background/handlers/Extension.d.ts +1 -14
- package/koni/background/handlers/Extension.js +50 -286
- package/koni/background/handlers/State.d.ts +2 -18
- package/koni/background/handlers/State.js +3 -50
- package/koni/background/handlers/index.js +2 -4
- package/koni/background/subscription.d.ts +1 -5
- package/koni/background/subscription.js +20 -90
- package/package.json +8 -311
- package/packageInfo.js +1 -1
- package/services/campaign-service/index.js +6 -9
- package/services/chain-service/constants.d.ts +11 -0
- package/services/chain-service/constants.js +14 -1
- package/services/chain-service/utils.d.ts +0 -1
- package/services/chain-service/utils.js +1 -5
- package/services/event-service/index.d.ts +0 -1
- package/services/event-service/index.js +0 -4
- package/services/event-service/types.d.ts +0 -8
- package/services/keyring-service/index.d.ts +1 -2
- package/services/keyring-service/index.js +2 -14
- package/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
- package/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
- package/services/migration-service/scripts/index.js +0 -4
- package/services/notification-service/NotificationService.js +1 -1
- package/services/storage-service/DatabaseService.d.ts +1 -17
- package/services/storage-service/DatabaseService.js +0 -47
- package/services/storage-service/databases/index.d.ts +1 -3
- package/services/storage-service/databases/index.js +0 -4
- package/services/storage-service/db-stores/NominatorMetadata.js +3 -3
- package/services/subscan-service/index.d.ts +2 -2
- package/services/transaction-service/event-parser/index.d.ts +1 -3
- package/services/transaction-service/event-parser/index.js +1 -57
- package/services/transaction-service/helpers/index.js +1 -3
- package/services/transaction-service/index.d.ts +15 -4
- package/services/transaction-service/index.js +72 -178
- package/services/transaction-service/types.d.ts +0 -2
- package/services/transaction-service/utils.js +0 -1
- package/types/index.d.ts +0 -5
- package/types/index.js +1 -5
- package/utils/fetchStaticData.js +1 -2
- package/utils/index.d.ts +0 -5
- package/utils/index.js +1 -53
- package/cjs/koni/api/dotsama/balance.js +0 -464
- package/cjs/koni/api/nft/ordinal_nft/constants.js +0 -21
- package/cjs/koni/api/nft/ordinal_nft/index.js +0 -121
- package/cjs/koni/api/nft/ordinal_nft/utils.js +0 -41
- package/cjs/koni/api/yield/helper/utils.js +0 -46
- package/cjs/services/earning-service/constants/chains.js +0 -29
- package/cjs/services/earning-service/constants/index.js +0 -27
- package/cjs/services/earning-service/constants/step.js +0 -18
- package/cjs/services/earning-service/handlers/base.js +0 -202
- package/cjs/services/earning-service/handlers/index.js +0 -60
- package/cjs/services/earning-service/handlers/lending/base.js +0 -20
- package/cjs/services/earning-service/handlers/lending/index.js +0 -13
- package/cjs/services/earning-service/handlers/lending/interlay.js +0 -168
- package/cjs/services/earning-service/handlers/liquid-staking/acala.js +0 -196
- package/cjs/services/earning-service/handlers/liquid-staking/base.js +0 -39
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +0 -257
- package/cjs/services/earning-service/handlers/liquid-staking/index.js +0 -34
- package/cjs/services/earning-service/handlers/liquid-staking/parallel.js +0 -180
- package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +0 -373
- package/cjs/services/earning-service/handlers/native-staking/amplitude.js +0 -359
- package/cjs/services/earning-service/handlers/native-staking/astar.js +0 -426
- package/cjs/services/earning-service/handlers/native-staking/base-para.js +0 -137
- package/cjs/services/earning-service/handlers/native-staking/base.js +0 -109
- package/cjs/services/earning-service/handlers/native-staking/index.js +0 -34
- package/cjs/services/earning-service/handlers/native-staking/para-chain.js +0 -361
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +0 -512
- package/cjs/services/earning-service/handlers/nomination-pool/index.js +0 -501
- package/cjs/services/earning-service/handlers/special.js +0 -387
- package/cjs/services/earning-service/service.js +0 -327
- package/cjs/services/earning-service/utils/index.js +0 -111
- package/cjs/services/migration-service/scripts/DeleteEarningData.js +0 -21
- package/cjs/services/migration-service/scripts/EnableEarningChains.js +0 -21
- package/cjs/services/migration-service/scripts/MigrateEthProvider.js +0 -17
- package/cjs/services/migration-service/scripts/MigratePioneerProvider.js +0 -17
- package/cjs/services/migration-service/scripts/MigrateProvider.js +0 -29
- package/cjs/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -149
- package/cjs/services/mint-campaign-service/campaigns/index.js +0 -13
- package/cjs/services/mint-campaign-service/constants.js +0 -11
- package/cjs/services/mint-campaign-service/index.js +0 -18
- package/cjs/services/storage-service/db-stores/YieldPoolStore.js +0 -36
- package/cjs/services/storage-service/db-stores/YieldPositionStore.js +0 -65
- package/cjs/services/storage-service/index.js +0 -241
- package/cjs/types/campaigns/index.js +0 -16
- package/cjs/types/campaigns/unlock-dot.js +0 -1
- package/cjs/types/ordinal.js +0 -1
- package/cjs/types/transaction.js +0 -1
- package/cjs/types/yield/actions/index.js +0 -27
- package/cjs/types/yield/actions/join/index.js +0 -38
- package/cjs/types/yield/actions/join/step.js +0 -37
- package/cjs/types/yield/actions/join/submit.js +0 -1
- package/cjs/types/yield/actions/join/validate.js +0 -16
- package/cjs/types/yield/actions/others.js +0 -1
- package/cjs/types/yield/index.js +0 -27
- package/cjs/types/yield/info/account/index.js +0 -49
- package/cjs/types/yield/info/account/info.js +0 -1
- package/cjs/types/yield/info/account/reward.js +0 -1
- package/cjs/types/yield/info/account/target.js +0 -32
- package/cjs/types/yield/info/account/unstake.js +0 -27
- package/cjs/types/yield/info/base.js +0 -34
- package/cjs/types/yield/info/chain/index.js +0 -27
- package/cjs/types/yield/info/chain/info.js +0 -1
- package/cjs/types/yield/info/chain/target.js +0 -1
- package/cjs/types/yield/info/index.js +0 -49
- package/cjs/types/yield/info/pallet.js +0 -15
- package/cjs/types.js +0 -1
- package/cjs/utils/address.js +0 -34
- package/cjs/utils/keyring.js +0 -57
- package/cjs/utils/object.js +0 -12
- package/koni/api/nft/ordinal_nft/constants.d.ts +0 -9
- package/koni/api/nft/ordinal_nft/constants.js +0 -12
- package/koni/api/nft/ordinal_nft/index.d.ts +0 -8
- package/koni/api/nft/ordinal_nft/index.js +0 -114
- package/koni/api/nft/ordinal_nft/utils.d.ts +0 -2
- package/koni/api/nft/ordinal_nft/utils.js +0 -33
- package/koni/api/yield/helper/utils.d.ts +0 -10
- package/koni/api/yield/helper/utils.js +0 -32
- package/services/earning-service/constants/abis/compound_finance_v2_abi.json +0 -1235
- package/services/earning-service/constants/abis/st_liquid_token_abi.json +0 -1355
- package/services/earning-service/constants/chains.d.ts +0 -14
- package/services/earning-service/constants/chains.js +0 -21
- package/services/earning-service/constants/index.d.ts +0 -2
- package/services/earning-service/constants/index.js +0 -5
- package/services/earning-service/constants/step.d.ts +0 -3
- package/services/earning-service/constants/step.js +0 -10
- package/services/earning-service/handlers/base.d.ts +0 -105
- package/services/earning-service/handlers/base.js +0 -195
- package/services/earning-service/handlers/index.d.ts +0 -5
- package/services/earning-service/handlers/index.js +0 -8
- package/services/earning-service/handlers/lending/base.d.ts +0 -6
- package/services/earning-service/handlers/lending/base.js +0 -12
- package/services/earning-service/handlers/lending/index.d.ts +0 -1
- package/services/earning-service/handlers/lending/index.js +0 -4
- package/services/earning-service/handlers/lending/interlay.d.ts +0 -22
- package/services/earning-service/handlers/lending/interlay.js +0 -160
- package/services/earning-service/handlers/liquid-staking/acala.d.ts +0 -27
- package/services/earning-service/handlers/liquid-staking/acala.js +0 -188
- package/services/earning-service/handlers/liquid-staking/base.d.ts +0 -8
- package/services/earning-service/handlers/liquid-staking/base.js +0 -31
- package/services/earning-service/handlers/liquid-staking/bifrost.d.ts +0 -44
- package/services/earning-service/handlers/liquid-staking/bifrost.js +0 -246
- package/services/earning-service/handlers/liquid-staking/index.d.ts +0 -4
- package/services/earning-service/handlers/liquid-staking/index.js +0 -7
- package/services/earning-service/handlers/liquid-staking/parallel.d.ts +0 -27
- package/services/earning-service/handlers/liquid-staking/parallel.js +0 -172
- package/services/earning-service/handlers/liquid-staking/stella-swap.d.ts +0 -36
- package/services/earning-service/handlers/liquid-staking/stella-swap.js +0 -363
- package/services/earning-service/handlers/native-staking/amplitude.d.ts +0 -22
- package/services/earning-service/handlers/native-staking/amplitude.js +0 -350
- package/services/earning-service/handlers/native-staking/astar.d.ts +0 -18
- package/services/earning-service/handlers/native-staking/astar.js +0 -416
- package/services/earning-service/handlers/native-staking/base-para.d.ts +0 -11
- package/services/earning-service/handlers/native-staking/base-para.js +0 -129
- package/services/earning-service/handlers/native-staking/base.d.ts +0 -19
- package/services/earning-service/handlers/native-staking/base.js +0 -101
- package/services/earning-service/handlers/native-staking/index.d.ts +0 -4
- package/services/earning-service/handlers/native-staking/index.js +0 -7
- package/services/earning-service/handlers/native-staking/para-chain.d.ts +0 -15
- package/services/earning-service/handlers/native-staking/para-chain.js +0 -353
- package/services/earning-service/handlers/native-staking/relay-chain.d.ts +0 -21
- package/services/earning-service/handlers/native-staking/relay-chain.js +0 -503
- package/services/earning-service/handlers/nomination-pool/index.d.ts +0 -33
- package/services/earning-service/handlers/nomination-pool/index.js +0 -492
- package/services/earning-service/handlers/special.d.ts +0 -56
- package/services/earning-service/handlers/special.js +0 -379
- package/services/earning-service/service.d.ts +0 -36
- package/services/earning-service/service.js +0 -320
- package/services/earning-service/utils/index.d.ts +0 -14
- package/services/earning-service/utils/index.js +0 -100
- package/services/migration-service/scripts/DeleteEarningData.d.ts +0 -4
- package/services/migration-service/scripts/DeleteEarningData.js +0 -13
- package/services/migration-service/scripts/EnableEarningChains.d.ts +0 -4
- package/services/migration-service/scripts/EnableEarningChains.js +0 -13
- package/services/mint-campaign-service/campaigns/UnlockDotCampaign.d.ts +0 -13
- package/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -139
- package/services/mint-campaign-service/campaigns/index.d.ts +0 -1
- package/services/mint-campaign-service/campaigns/index.js +0 -4
- package/services/mint-campaign-service/constants.d.ts +0 -1
- package/services/mint-campaign-service/constants.js +0 -4
- package/services/mint-campaign-service/index.d.ts +0 -7
- package/services/mint-campaign-service/index.js +0 -11
- package/services/storage-service/db-stores/YieldPoolStore.d.ts +0 -10
- package/services/storage-service/db-stores/YieldPoolStore.js +0 -28
- package/services/storage-service/db-stores/YieldPositionStore.d.ts +0 -9
- package/services/storage-service/db-stores/YieldPositionStore.js +0 -57
- package/types/campaigns/index.d.ts +0 -1
- package/types/campaigns/index.js +0 -4
- package/types/campaigns/unlock-dot.d.ts +0 -71
- package/types/campaigns/unlock-dot.js +0 -1
- package/types/ordinal.d.ts +0 -69
- package/types/ordinal.js +0 -1
- package/types/transaction.d.ts +0 -3
- package/types/transaction.js +0 -1
- package/types/yield/actions/index.d.ts +0 -2
- package/types/yield/actions/index.js +0 -5
- package/types/yield/actions/join/index.d.ts +0 -3
- package/types/yield/actions/join/index.js +0 -6
- package/types/yield/actions/join/step.d.ts +0 -75
- package/types/yield/actions/join/step.js +0 -34
- package/types/yield/actions/join/submit.d.ts +0 -53
- package/types/yield/actions/join/submit.js +0 -1
- package/types/yield/actions/join/validate.d.ts +0 -18
- package/types/yield/actions/join/validate.js +0 -10
- package/types/yield/actions/others.d.ts +0 -60
- package/types/yield/actions/others.js +0 -1
- package/types/yield/index.d.ts +0 -2
- package/types/yield/index.js +0 -5
- package/types/yield/info/account/index.d.ts +0 -4
- package/types/yield/info/account/index.js +0 -7
- package/types/yield/info/account/info.d.ts +0 -112
- package/types/yield/info/account/info.js +0 -1
- package/types/yield/info/account/reward.d.ts +0 -41
- package/types/yield/info/account/reward.js +0 -1
- package/types/yield/info/account/target.d.ts +0 -43
- package/types/yield/info/account/target.js +0 -27
- package/types/yield/info/account/unstake.d.ts +0 -31
- package/types/yield/info/account/unstake.js +0 -22
- package/types/yield/info/base.d.ts +0 -28
- package/types/yield/info/base.js +0 -28
- package/types/yield/info/chain/index.d.ts +0 -2
- package/types/yield/info/chain/index.js +0 -5
- package/types/yield/info/chain/info.d.ts +0 -190
- package/types/yield/info/chain/info.js +0 -1
- package/types/yield/info/chain/target.d.ts +0 -33
- package/types/yield/info/chain/target.js +0 -1
- package/types/yield/info/index.d.ts +0 -4
- package/types/yield/info/index.js +0 -7
- package/types/yield/info/pallet.d.ts +0 -143
- package/types/yield/info/pallet.js +0 -9
- package/utils/object.d.ts +0 -1
- package/utils/object.js +0 -6
|
@@ -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 {
|
|
9
|
+
import { _TRANSFER_CHAIN_GROUP } from '@subwallet/extension-base/services/chain-service/constants';
|
|
10
|
+
import { _getChainNativeTokenBasicInfo, _getEvmChainId } from '@subwallet/extension-base/services/chain-service/utils';
|
|
10
11
|
import { EXTENSION_REQUEST_URL } from '@subwallet/extension-base/services/request-service/constants';
|
|
11
12
|
import { TRANSACTION_TIMEOUT } from '@subwallet/extension-base/services/transaction-service/constants';
|
|
12
|
-
import {
|
|
13
|
+
import { parseTransferEventLogs, parseXcmEventLogs } from '@subwallet/extension-base/services/transaction-service/event-parser';
|
|
13
14
|
import { getBaseTransactionInfo, getTransactionId, isSubstrateTransaction } from '@subwallet/extension-base/services/transaction-service/helpers';
|
|
14
15
|
import { getExplorerLink, parseTransactionData } from '@subwallet/extension-base/services/transaction-service/utils';
|
|
15
16
|
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,15 +26,20 @@ 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";
|
|
30
29
|
export default class TransactionService {
|
|
31
30
|
transactionSubject = new BehaviorSubject({});
|
|
32
31
|
watchTransactionSubscribes = {};
|
|
33
32
|
get transactions() {
|
|
34
33
|
return this.transactionSubject.getValue();
|
|
35
34
|
}
|
|
36
|
-
constructor(
|
|
37
|
-
this.
|
|
35
|
+
constructor(chainService, eventService, requestService, balanceService, historyService, notificationService, databaseService) {
|
|
36
|
+
this.chainService = chainService;
|
|
37
|
+
this.eventService = eventService;
|
|
38
|
+
this.requestService = requestService;
|
|
39
|
+
this.balanceService = balanceService;
|
|
40
|
+
this.historyService = historyService;
|
|
41
|
+
this.notificationService = notificationService;
|
|
42
|
+
this.databaseService = databaseService;
|
|
38
43
|
}
|
|
39
44
|
get allTransactions() {
|
|
40
45
|
return Object.values(this.transactions);
|
|
@@ -91,7 +96,7 @@ export default class TransactionService {
|
|
|
91
96
|
decimals: 0,
|
|
92
97
|
value: ''
|
|
93
98
|
};
|
|
94
|
-
const chainInfo = this.
|
|
99
|
+
const chainInfo = this.chainService.getChainInfoByKey(chain);
|
|
95
100
|
if (!chainInfo) {
|
|
96
101
|
validationResponse.errors.push(new TransactionError(BasicTxErrorType.INTERNAL_ERROR, t('Cannot find network')));
|
|
97
102
|
} else {
|
|
@@ -106,7 +111,7 @@ export default class TransactionService {
|
|
|
106
111
|
if (isSubstrateTransaction(transaction)) {
|
|
107
112
|
estimateFee.value = (await transaction.paymentInfo(address)).partialFee.toString();
|
|
108
113
|
} else {
|
|
109
|
-
const web3 = this.
|
|
114
|
+
const web3 = this.chainService.getEvmApi(chain);
|
|
110
115
|
if (!web3) {
|
|
111
116
|
validationResponse.errors.push(new TransactionError(BasicTxErrorType.CHAIN_DISCONNECTED, undefined));
|
|
112
117
|
} else {
|
|
@@ -140,35 +145,32 @@ export default class TransactionService {
|
|
|
140
145
|
|
|
141
146
|
// Balance
|
|
142
147
|
const transferNative = validationResponse.transferNativeAmount || '0';
|
|
143
|
-
const nativeTokenInfo = this.
|
|
144
|
-
const balance = await this.
|
|
148
|
+
const nativeTokenInfo = this.chainService.getNativeTokenInfo(chain);
|
|
149
|
+
const balance = await this.balanceService.getTokenFreeBalance(address, chain, nativeTokenInfo.slug);
|
|
145
150
|
const existentialDeposit = nativeTokenInfo.minAmount || '0';
|
|
146
151
|
const feeNum = parseInt(estimateFee.value);
|
|
147
152
|
const balanceNum = parseInt(balance.value);
|
|
148
153
|
const edNum = parseInt(existentialDeposit);
|
|
149
154
|
const transferNativeNum = parseInt(transferNative);
|
|
150
|
-
if (!
|
|
151
|
-
|
|
152
|
-
|
|
155
|
+
if (!new BigN(balance.value).gt(0)) {
|
|
156
|
+
validationResponse.errors.push(new TransactionError(BasicTxErrorType.NOT_ENOUGH_BALANCE));
|
|
157
|
+
}
|
|
158
|
+
if (transferNativeNum + feeNum > balanceNum) {
|
|
159
|
+
if (!isTransferAll) {
|
|
153
160
|
validationResponse.errors.push(new TransactionError(BasicTxErrorType.NOT_ENOUGH_BALANCE));
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
|
|
161
|
+
} else {
|
|
162
|
+
if ([..._TRANSFER_CHAIN_GROUP.acala, ..._TRANSFER_CHAIN_GROUP.genshiro, ..._TRANSFER_CHAIN_GROUP.bitcountry, ..._TRANSFER_CHAIN_GROUP.statemine].includes(chain)) {
|
|
163
|
+
// Chain not have transfer all function
|
|
157
164
|
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
|
-
}
|
|
163
165
|
}
|
|
164
166
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
167
|
+
}
|
|
168
|
+
if (!isTransferAll) {
|
|
169
|
+
if (balanceNum - (transferNativeNum + feeNum) < edNum) {
|
|
170
|
+
if (edAsWarning) {
|
|
171
|
+
validationResponse.warnings.push(new TransactionWarning(BasicTxWarningCode.NOT_ENOUGH_EXISTENTIAL_DEPOSIT));
|
|
172
|
+
} else {
|
|
173
|
+
validationResponse.errors.push(new TransactionError(BasicTxErrorType.NOT_ENOUGH_EXISTENTIAL_DEPOSIT));
|
|
172
174
|
}
|
|
173
175
|
}
|
|
174
176
|
}
|
|
@@ -235,21 +237,12 @@ export default class TransactionService {
|
|
|
235
237
|
}
|
|
236
238
|
validatedTransaction.warnings = [];
|
|
237
239
|
const emitter = await this.addTransaction(validatedTransaction);
|
|
238
|
-
await new Promise(
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
resolve();
|
|
245
|
-
});
|
|
246
|
-
} else {
|
|
247
|
-
emitter.on('signed', data => {
|
|
248
|
-
validatedTransaction.id = data.id;
|
|
249
|
-
validatedTransaction.extrinsicHash = data.extrinsicHash;
|
|
250
|
-
resolve();
|
|
251
|
-
});
|
|
252
|
-
}
|
|
240
|
+
await new Promise(resolve => {
|
|
241
|
+
emitter.on('signed', data => {
|
|
242
|
+
validatedTransaction.id = data.id;
|
|
243
|
+
validatedTransaction.extrinsicHash = data.extrinsicHash;
|
|
244
|
+
resolve();
|
|
245
|
+
});
|
|
253
246
|
emitter.on('error', data => {
|
|
254
247
|
if (data.errors.length > 0) {
|
|
255
248
|
validatedTransaction.errors.push(...data.errors);
|
|
@@ -315,7 +308,7 @@ export default class TransactionService {
|
|
|
315
308
|
}
|
|
316
309
|
getTransactionLink(id) {
|
|
317
310
|
const transaction = this.getTransaction(id);
|
|
318
|
-
const chainInfo = this.
|
|
311
|
+
const chainInfo = this.chainService.getChainInfoByKey(transaction.chain);
|
|
319
312
|
return getExplorerLink(chainInfo, transaction.extrinsicHash, 'tx');
|
|
320
313
|
}
|
|
321
314
|
transactionToHistories(id, startBlock, nonce, eventLogs) {
|
|
@@ -343,7 +336,7 @@ export default class TransactionService {
|
|
|
343
336
|
nonce: nonce !== null && nonce !== void 0 ? nonce : 0,
|
|
344
337
|
startBlock: startBlock || 0
|
|
345
338
|
};
|
|
346
|
-
const chainInfo = this.
|
|
339
|
+
const chainInfo = this.chainService.getChainInfoByKey(transaction.chain);
|
|
347
340
|
const nativeAsset = _getChainNativeTokenBasicInfo(chainInfo);
|
|
348
341
|
const baseNativeAmount = {
|
|
349
342
|
value: '0',
|
|
@@ -357,7 +350,7 @@ export default class TransactionService {
|
|
|
357
350
|
{
|
|
358
351
|
const inputData = parseTransactionData(transaction.data);
|
|
359
352
|
historyItem.to = inputData.to;
|
|
360
|
-
const sendingTokenInfo = this.
|
|
353
|
+
const sendingTokenInfo = this.chainService.getAssetBySlug(inputData.tokenSlug);
|
|
361
354
|
historyItem.amount = {
|
|
362
355
|
value: inputData.value || '0',
|
|
363
356
|
decimals: sendingTokenInfo.decimals || 0,
|
|
@@ -370,7 +363,7 @@ export default class TransactionService {
|
|
|
370
363
|
{
|
|
371
364
|
const inputData = parseTransactionData(transaction.data);
|
|
372
365
|
historyItem.to = inputData.to;
|
|
373
|
-
const sendingTokenInfo = this.
|
|
366
|
+
const sendingTokenInfo = this.chainService.getAssetBySlug(inputData.tokenSlug);
|
|
374
367
|
historyItem.amount = {
|
|
375
368
|
value: inputData.value || '0',
|
|
376
369
|
decimals: sendingTokenInfo.decimals || 0,
|
|
@@ -383,7 +376,7 @@ export default class TransactionService {
|
|
|
383
376
|
{
|
|
384
377
|
const inputData = parseTransactionData(transaction.data);
|
|
385
378
|
historyItem.to = inputData.to;
|
|
386
|
-
const sendingTokenInfo = this.
|
|
379
|
+
const sendingTokenInfo = this.chainService.getAssetBySlug(inputData.tokenSlug);
|
|
387
380
|
historyItem.amount = {
|
|
388
381
|
value: inputData.value || '0',
|
|
389
382
|
decimals: sendingTokenInfo.decimals || 0,
|
|
@@ -432,29 +425,17 @@ export default class TransactionService {
|
|
|
432
425
|
case ExtrinsicType.STAKING_UNBOND:
|
|
433
426
|
{
|
|
434
427
|
const data = parseTransactionData(transaction.data);
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
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
|
-
}
|
|
428
|
+
historyItem.to = data.validatorAddress || '';
|
|
429
|
+
historyItem.amount = {
|
|
430
|
+
...baseNativeAmount,
|
|
431
|
+
value: data.amount || '0'
|
|
432
|
+
};
|
|
452
433
|
}
|
|
453
434
|
break;
|
|
454
435
|
case ExtrinsicType.STAKING_LEAVE_POOL:
|
|
455
436
|
{
|
|
456
437
|
const data = parseTransactionData(transaction.data);
|
|
457
|
-
historyItem.to = data.address || '';
|
|
438
|
+
historyItem.to = data.nominatorMetadata.address || '';
|
|
458
439
|
historyItem.amount = {
|
|
459
440
|
...baseNativeAmount,
|
|
460
441
|
value: data.amount || '0'
|
|
@@ -473,7 +454,7 @@ export default class TransactionService {
|
|
|
473
454
|
case ExtrinsicType.STAKING_WITHDRAW:
|
|
474
455
|
{
|
|
475
456
|
const data = parseTransactionData(transaction.data);
|
|
476
|
-
historyItem.to = data.
|
|
457
|
+
historyItem.to = data.validatorAddress || '';
|
|
477
458
|
historyItem.amount = {
|
|
478
459
|
...baseNativeAmount,
|
|
479
460
|
value: data.unstakingInfo.claimable || '0'
|
|
@@ -498,68 +479,6 @@ export default class TransactionService {
|
|
|
498
479
|
historyItem.to = (data === null || data === void 0 ? void 0 : data.to) || '';
|
|
499
480
|
break;
|
|
500
481
|
}
|
|
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.yieldPoolInfo;
|
|
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.yieldPoolInfo;
|
|
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.yieldPoolInfo.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
|
-
}
|
|
563
482
|
case ExtrinsicType.UNKNOWN:
|
|
564
483
|
break;
|
|
565
484
|
}
|
|
@@ -605,7 +524,7 @@ export default class TransactionService {
|
|
|
605
524
|
});
|
|
606
525
|
|
|
607
526
|
// Create Input History Transaction History
|
|
608
|
-
this.
|
|
527
|
+
this.historyService.insertHistories(this.transactionToHistories(id, startBlock, nonce)).catch(console.error);
|
|
609
528
|
console.debug(`Transaction "${id}" is sent`);
|
|
610
529
|
}
|
|
611
530
|
onHasTransactionHash({
|
|
@@ -622,12 +541,8 @@ export default class TransactionService {
|
|
|
622
541
|
this.updateTransaction(id, updateData);
|
|
623
542
|
|
|
624
543
|
// In this case transaction id is the same as extrinsic hash and will change after below update
|
|
625
|
-
this.
|
|
544
|
+
this.historyService.updateHistoryByExtrinsicHash(id, updateData).catch(console.error);
|
|
626
545
|
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
|
-
}
|
|
631
546
|
}
|
|
632
547
|
handlePostProcessing(id) {
|
|
633
548
|
// must be done after success/failure to make sure the transaction is finalized
|
|
@@ -636,15 +551,15 @@ export default class TransactionService {
|
|
|
636
551
|
const inputData = parseTransactionData(transaction.data);
|
|
637
552
|
try {
|
|
638
553
|
const sender = keyring.getPair(inputData.senderAddress);
|
|
639
|
-
sender && this.
|
|
640
|
-
this.
|
|
554
|
+
sender && this.databaseService.handleNftTransfer(transaction.chain, [sender.address, ALL_ACCOUNT_KEY], inputData.nftItem).then(() => {
|
|
555
|
+
this.eventService.emit('transaction.transferNft', undefined);
|
|
641
556
|
}).catch(console.error);
|
|
642
557
|
} catch (e) {
|
|
643
558
|
console.error(e);
|
|
644
559
|
}
|
|
645
560
|
try {
|
|
646
561
|
const recipient = keyring.getPair(inputData.recipientAddress);
|
|
647
|
-
recipient && this.
|
|
562
|
+
recipient && this.databaseService.addNft(recipient.address, {
|
|
648
563
|
...inputData.nftItem,
|
|
649
564
|
owner: recipient.address
|
|
650
565
|
}).catch(console.error);
|
|
@@ -652,7 +567,7 @@ export default class TransactionService {
|
|
|
652
567
|
console.error(e);
|
|
653
568
|
}
|
|
654
569
|
} 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)) {
|
|
655
|
-
this.
|
|
570
|
+
this.eventService.emit('transaction.submitStaking', transaction.chain);
|
|
656
571
|
}
|
|
657
572
|
}
|
|
658
573
|
onSuccess({
|
|
@@ -668,14 +583,14 @@ export default class TransactionService {
|
|
|
668
583
|
});
|
|
669
584
|
|
|
670
585
|
// Write success transaction history
|
|
671
|
-
this.
|
|
586
|
+
this.historyService.updateHistoryByExtrinsicHash(transaction.extrinsicHash, {
|
|
672
587
|
extrinsicHash,
|
|
673
588
|
status: ExtrinsicStatus.SUCCESS,
|
|
674
589
|
blockNumber: blockNumber || 0,
|
|
675
590
|
blockHash: blockHash || ''
|
|
676
591
|
}).catch(console.error);
|
|
677
|
-
const info = isHex(extrinsicHash) ? extrinsicHash : getBaseTransactionInfo(transaction, this.
|
|
678
|
-
this.
|
|
592
|
+
const info = isHex(extrinsicHash) ? extrinsicHash : getBaseTransactionInfo(transaction, this.chainService.getChainInfoMap());
|
|
593
|
+
this.notificationService.notify({
|
|
679
594
|
type: NotificationType.SUCCESS,
|
|
680
595
|
title: t('Transaction completed'),
|
|
681
596
|
message: t('Transaction {{info}} completed', {
|
|
@@ -688,7 +603,7 @@ export default class TransactionService {
|
|
|
688
603
|
},
|
|
689
604
|
notifyViaBrowser: true
|
|
690
605
|
});
|
|
691
|
-
this.
|
|
606
|
+
this.eventService.emit('transaction.done', transaction);
|
|
692
607
|
}
|
|
693
608
|
onFailed({
|
|
694
609
|
blockHash,
|
|
@@ -707,14 +622,14 @@ export default class TransactionService {
|
|
|
707
622
|
});
|
|
708
623
|
|
|
709
624
|
// Write failed transaction history
|
|
710
|
-
this.
|
|
625
|
+
this.historyService.updateHistoryByExtrinsicHash(transaction.extrinsicHash, {
|
|
711
626
|
extrinsicHash: extrinsicHash || transaction.extrinsicHash,
|
|
712
627
|
status: nextStatus,
|
|
713
628
|
blockNumber: blockNumber || 0,
|
|
714
629
|
blockHash: blockHash || ''
|
|
715
630
|
}).catch(console.error);
|
|
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.
|
|
717
|
-
this.
|
|
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({
|
|
718
633
|
type: NotificationType.ERROR,
|
|
719
634
|
title: t('Transaction failed'),
|
|
720
635
|
message: t('Transaction {{info}} failed', {
|
|
@@ -728,11 +643,11 @@ export default class TransactionService {
|
|
|
728
643
|
notifyViaBrowser: true
|
|
729
644
|
});
|
|
730
645
|
}
|
|
731
|
-
this.
|
|
646
|
+
this.eventService.emit('transaction.failed', transaction);
|
|
732
647
|
}
|
|
733
648
|
generateHashPayload(chain, transaction) {
|
|
734
649
|
var _transaction$nonce;
|
|
735
|
-
const chainInfo = this.
|
|
650
|
+
const chainInfo = this.chainService.getChainInfoByKey(chain);
|
|
736
651
|
const txObject = {
|
|
737
652
|
nonce: (_transaction$nonce = transaction.nonce) !== null && _transaction$nonce !== void 0 ? _transaction$nonce : 0,
|
|
738
653
|
gasPrice: addHexPrefix(anyNumberToBN(transaction.gasPrice).toString(16)),
|
|
@@ -753,8 +668,8 @@ export default class TransactionService {
|
|
|
753
668
|
}) {
|
|
754
669
|
var _payload$nonce;
|
|
755
670
|
const payload = transaction;
|
|
756
|
-
const evmApi = this.
|
|
757
|
-
const chainInfo = this.
|
|
671
|
+
const evmApi = this.chainService.getEvmApi(chain);
|
|
672
|
+
const chainInfo = this.chainService.getChainInfoByKey(chain);
|
|
758
673
|
const accountPair = keyring.getPair(address);
|
|
759
674
|
const account = {
|
|
760
675
|
address,
|
|
@@ -784,7 +699,7 @@ export default class TransactionService {
|
|
|
784
699
|
|
|
785
700
|
// Set unique nonce to avoid transaction errors
|
|
786
701
|
if (!payload.nonce) {
|
|
787
|
-
const evmApi = this.
|
|
702
|
+
const evmApi = this.chainService.getEvmApi(chain);
|
|
788
703
|
payload.nonce = await evmApi.api.eth.getTransactionCount(address);
|
|
789
704
|
}
|
|
790
705
|
if (!payload.chainId) {
|
|
@@ -819,7 +734,7 @@ export default class TransactionService {
|
|
|
819
734
|
extrinsicHash: id
|
|
820
735
|
};
|
|
821
736
|
if (isInjected) {
|
|
822
|
-
this.
|
|
737
|
+
this.requestService.addConfirmation(id, url || EXTENSION_REQUEST_URL, 'evmWatchTransactionRequest', payload, {}).then(async ({
|
|
823
738
|
isApproved,
|
|
824
739
|
payload
|
|
825
740
|
}) => {
|
|
@@ -827,7 +742,7 @@ export default class TransactionService {
|
|
|
827
742
|
if (!payload) {
|
|
828
743
|
throw new EvmProviderError(EvmProviderErrorType.UNAUTHORIZED, 'Bad signature');
|
|
829
744
|
}
|
|
830
|
-
const web3Api = this.
|
|
745
|
+
const web3Api = this.chainService.getEvmApi(chain).api;
|
|
831
746
|
|
|
832
747
|
// Emit signed event
|
|
833
748
|
emitter.emit('signed', eventData);
|
|
@@ -883,7 +798,7 @@ export default class TransactionService {
|
|
|
883
798
|
emitter.emit('error', eventData);
|
|
884
799
|
});
|
|
885
800
|
} else {
|
|
886
|
-
this.
|
|
801
|
+
this.requestService.addConfirmation(id, url || EXTENSION_REQUEST_URL, 'evmSendTransactionRequest', payload, {}).then(async ({
|
|
887
802
|
isApproved,
|
|
888
803
|
payload
|
|
889
804
|
}) => {
|
|
@@ -892,7 +807,7 @@ export default class TransactionService {
|
|
|
892
807
|
if (!payload) {
|
|
893
808
|
throw new EvmProviderError(EvmProviderErrorType.UNAUTHORIZED, t('Failed to sign'));
|
|
894
809
|
}
|
|
895
|
-
const web3Api = this.
|
|
810
|
+
const web3Api = this.chainService.getEvmApi(chain).api;
|
|
896
811
|
if (!isExternal) {
|
|
897
812
|
signedTransaction = payload;
|
|
898
813
|
} else {
|
|
@@ -959,7 +874,7 @@ export default class TransactionService {
|
|
|
959
874
|
transaction.signAsync(address, {
|
|
960
875
|
signer: {
|
|
961
876
|
signPayload: async payload => {
|
|
962
|
-
const signing = await this.
|
|
877
|
+
const signing = await this.requestService.signInternalTransaction(id, address, url || EXTENSION_REQUEST_URL, payload);
|
|
963
878
|
return {
|
|
964
879
|
id: new Date().getTime(),
|
|
965
880
|
signature: signing.signature
|
|
@@ -971,7 +886,7 @@ export default class TransactionService {
|
|
|
971
886
|
emitter.emit('signed', eventData);
|
|
972
887
|
|
|
973
888
|
// Send transaction
|
|
974
|
-
const api = this.
|
|
889
|
+
const api = this.chainService.getSubstrateApi(chain);
|
|
975
890
|
eventData.nonce = rs.nonce.toNumber();
|
|
976
891
|
eventData.startBlock = (await api.api.query.system.number()).toPrimitive();
|
|
977
892
|
this.handleTransactionTimeout(emitter, eventData);
|
|
@@ -1039,27 +954,6 @@ export default class TransactionService {
|
|
|
1039
954
|
clearTimeout(timeout);
|
|
1040
955
|
});
|
|
1041
956
|
}
|
|
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
|
-
}
|
|
1063
957
|
resetWallet() {
|
|
1064
958
|
this.transactionSubject.next({});
|
|
1065
959
|
}
|
|
@@ -30,8 +30,6 @@ 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;
|
|
35
33
|
}
|
|
36
34
|
export declare type SWTransactionResponse = SwInputBase & Pick<SWTransaction, 'warnings' | 'errors'> & Partial<Pick<SWTransaction, 'id' | 'extrinsicHash' | 'status' | 'estimateFee'>>;
|
|
37
35
|
export declare type ValidateTransactionResponseInput = SWTransactionInput;
|
package/types/index.d.ts
CHANGED
|
@@ -5,12 +5,7 @@ export interface Message extends MessageEvent {
|
|
|
5
5
|
origin: string;
|
|
6
6
|
response?: string;
|
|
7
7
|
subscription?: string;
|
|
8
|
-
sender?: string;
|
|
9
8
|
};
|
|
10
9
|
}
|
|
11
10
|
export * from './balance';
|
|
12
11
|
export * from './buy';
|
|
13
|
-
export * from './campaigns';
|
|
14
|
-
export * from './ordinal';
|
|
15
|
-
export * from './transaction';
|
|
16
|
-
export * from './yield';
|
package/types/index.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
// Copyright 2019-2022 @
|
|
1
|
+
// Copyright 2019-2022 @polkadot/extension authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
export * from "./balance.js";
|
|
5
5
|
export * from "./buy.js";
|
|
6
|
-
export * from "./campaigns/index.js";
|
|
7
|
-
export * from "./ordinal.js";
|
|
8
|
-
export * from "./transaction.js";
|
|
9
|
-
export * from "./yield/index.js";
|
|
10
6
|
export {};
|
package/utils/fetchStaticData.js
CHANGED
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import axios from 'axios';
|
|
5
|
-
const PRODUCTION_BRANCHES = ['master', 'webapp', 'webapp-dev'];
|
|
6
5
|
const branchName = process.env.BRANCH_NAME || 'koni-dev';
|
|
7
|
-
const fetchTarget =
|
|
6
|
+
const fetchTarget = branchName === 'master' || branchName === 'webapp' ? 'list.json' : 'preview.json';
|
|
8
7
|
export async function fetchStaticData(slug, targetFile) {
|
|
9
8
|
const fetchFile = targetFile || fetchTarget;
|
|
10
9
|
const rs = await axios.get(`https://static-data.subwallet.app/${slug}/${fetchFile}`);
|
package/utils/index.d.ts
CHANGED
|
@@ -39,15 +39,10 @@ export declare function isSameAddress(address1: string, address2: string): boole
|
|
|
39
39
|
export declare function getDomainFromUrl(url: string): string;
|
|
40
40
|
export declare function waitTimeout(ms: number): Promise<void>;
|
|
41
41
|
export declare const stripUrl: (url: string) => string;
|
|
42
|
-
export declare const baseParseIPFSUrl: (input: string) => string | undefined;
|
|
43
|
-
export declare const swParseIPFSUrl: (input: string) => string | undefined;
|
|
44
42
|
export declare function wait(milliseconds: number): Promise<void>;
|
|
45
43
|
export * from './account';
|
|
46
44
|
export * from './array';
|
|
47
45
|
export * from './environment';
|
|
48
|
-
export * from './number';
|
|
49
46
|
export * from './lazy';
|
|
50
|
-
export * from './promise';
|
|
51
47
|
export * from './registry';
|
|
52
48
|
export * from './translate';
|
|
53
|
-
export * from './object';
|
package/utils/index.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
import { CrowdloanParaState, MobileOS } from '@subwallet/extension-base/background/KoniTypes';
|
|
5
5
|
import { ALL_ACCOUNT_KEY } from '@subwallet/extension-base/constants';
|
|
6
|
-
import { getRandomIpfsGateway, SUBWALLET_IPFS } from '@subwallet/extension-base/koni/api/nft/config';
|
|
7
6
|
import { getOS } from '@subwallet/extension-base/utils/environment';
|
|
8
7
|
import { t } from 'i18next';
|
|
9
8
|
import { assert, BN, hexToU8a, isHex } from '@polkadot/util';
|
|
@@ -288,54 +287,6 @@ export const stripUrl = url => {
|
|
|
288
287
|
const parts = url.split('/');
|
|
289
288
|
return parts[2];
|
|
290
289
|
};
|
|
291
|
-
export const baseParseIPFSUrl = input => {
|
|
292
|
-
if (!input || input.length === 0) {
|
|
293
|
-
return undefined;
|
|
294
|
-
}
|
|
295
|
-
if (isUrl(input)) {
|
|
296
|
-
return input;
|
|
297
|
-
}
|
|
298
|
-
if (isUrl(input) || input.includes('https://') || input.includes('http')) {
|
|
299
|
-
return input;
|
|
300
|
-
}
|
|
301
|
-
if (input.startsWith('/ipfs/')) {
|
|
302
|
-
return getRandomIpfsGateway() + input.split('/ipfs/')[1];
|
|
303
|
-
}
|
|
304
|
-
if (!input.includes('ipfs://') && !input.includes('ipfs://ipfs/')) {
|
|
305
|
-
// just the IPFS hash
|
|
306
|
-
return getRandomIpfsGateway() + input;
|
|
307
|
-
}
|
|
308
|
-
if (input.includes('ipfs://') && !input.includes('ipfs://ipfs/')) {
|
|
309
|
-
// starts with ipfs://
|
|
310
|
-
return getRandomIpfsGateway() + input.split('ipfs://')[1];
|
|
311
|
-
}
|
|
312
|
-
return getRandomIpfsGateway() + input.split('ipfs://ipfs/')[1]; // starts with ipfs://ipfs/
|
|
313
|
-
};
|
|
314
|
-
|
|
315
|
-
export const swParseIPFSUrl = input => {
|
|
316
|
-
if (!input || input.length === 0) {
|
|
317
|
-
return undefined;
|
|
318
|
-
}
|
|
319
|
-
if (isUrl(input)) {
|
|
320
|
-
return input;
|
|
321
|
-
}
|
|
322
|
-
if (isUrl(input) || input.includes('https://') || input.includes('http')) {
|
|
323
|
-
return input;
|
|
324
|
-
}
|
|
325
|
-
if (input.startsWith('/ipfs/')) {
|
|
326
|
-
return SUBWALLET_IPFS + input.split('/ipfs/')[1];
|
|
327
|
-
}
|
|
328
|
-
if (!input.includes('ipfs://') && !input.includes('ipfs://ipfs/')) {
|
|
329
|
-
// just the IPFS hash
|
|
330
|
-
return SUBWALLET_IPFS + input;
|
|
331
|
-
}
|
|
332
|
-
if (input.includes('ipfs://') && !input.includes('ipfs://ipfs/')) {
|
|
333
|
-
// starts with ipfs://
|
|
334
|
-
return SUBWALLET_IPFS + input.split('ipfs://')[1];
|
|
335
|
-
}
|
|
336
|
-
return SUBWALLET_IPFS + input.split('ipfs://ipfs/')[1]; // starts with ipfs://ipfs/
|
|
337
|
-
};
|
|
338
|
-
|
|
339
290
|
export function wait(milliseconds) {
|
|
340
291
|
return new Promise(resolve => {
|
|
341
292
|
setTimeout(() => {
|
|
@@ -346,9 +297,6 @@ export function wait(milliseconds) {
|
|
|
346
297
|
export * from "./account.js";
|
|
347
298
|
export * from "./array.js";
|
|
348
299
|
export * from "./environment.js";
|
|
349
|
-
export * from "./number.js";
|
|
350
300
|
export * from "./lazy.js";
|
|
351
|
-
export * from "./promise.js";
|
|
352
301
|
export * from "./registry.js";
|
|
353
|
-
export * from "./translate.js";
|
|
354
|
-
export * from "./object.js";
|
|
302
|
+
export * from "./translate.js";
|