@subwallet/extension-base 1.0.1 → 1.0.2-1b
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 +25 -36
- package/background/KoniTypes.js +12 -7
- package/background/errors/TransactionError.js +21 -1
- package/cjs/background/KoniTypes.js +14 -8
- package/cjs/background/errors/TransactionError.js +20 -0
- package/cjs/constants/index.js +13 -28
- package/cjs/koni/api/dotsama/balance.js +60 -224
- package/cjs/koni/api/dotsama/transfer.js +30 -29
- package/cjs/koni/api/nft/acala_nft/index.js +4 -1
- package/cjs/koni/api/nft/bit.country/index.js +4 -1
- package/cjs/koni/api/nft/evm_nft/index.js +7 -3
- package/cjs/koni/api/nft/index.js +3 -6
- package/cjs/koni/api/nft/karura_nft/index.js +4 -1
- package/cjs/koni/api/nft/rmrk_nft/index.js +8 -1
- package/cjs/koni/api/nft/statemine_nft/index.js +4 -1
- package/cjs/koni/api/nft/unique_nft/index.js +6 -1
- package/cjs/koni/api/nft/wasm_nft/index.js +169 -111
- package/cjs/koni/api/nft/wasm_nft/utils.js +11 -7
- package/cjs/koni/api/staking/bonding/amplitude.js +18 -10
- package/cjs/koni/api/staking/bonding/astar.js +37 -238
- package/cjs/koni/api/staking/bonding/index.js +26 -14
- package/cjs/koni/api/staking/bonding/paraChain.js +100 -11
- package/cjs/koni/api/staking/bonding/relayChain.js +174 -16
- package/cjs/koni/api/staking/bonding/utils.js +55 -10
- package/cjs/koni/api/tokens/wasm/index.js +5 -4
- package/cjs/koni/api/tokens/wasm/utils.js +63 -0
- package/cjs/koni/api/xcm/index.js +0 -111
- package/cjs/koni/api/xcm/polkadotXcm.js +2 -2
- package/cjs/koni/api/xcm/utils.js +18 -13
- package/cjs/koni/api/xcm/xTokens.js +3 -5
- package/cjs/koni/api/xcm/xcmPallet.js +9 -6
- package/cjs/koni/background/cron.js +179 -77
- package/cjs/koni/background/handlers/Extension.js +231 -195
- package/cjs/koni/background/handlers/State.js +147 -111
- package/cjs/koni/background/handlers/Tabs.js +48 -39
- package/cjs/koni/background/subscription.js +64 -56
- package/cjs/packageInfo.js +1 -1
- package/cjs/page/index.js +5 -0
- package/cjs/services/chain-service/constants.js +1 -11
- package/cjs/services/chain-service/handler/SubstrateChainHandler.js +13 -8
- package/cjs/services/chain-service/handler/light-client/index.js +2 -0
- package/cjs/services/chain-service/index.js +39 -6
- package/cjs/services/chain-service/utils.js +4 -0
- package/cjs/services/event-service/index.js +75 -0
- package/cjs/services/event-service/types.js +11 -0
- package/cjs/services/history-service/index.js +46 -21
- package/cjs/services/history-service/subsquid-multi-chain-history.js +19 -11
- package/cjs/services/keyring-service/index.js +101 -0
- package/cjs/services/migration-service/index.js +13 -10
- package/cjs/{koni/migration/scripts/RemoveWrongCrowdloan.js → services/migration-service/scripts/AutoEnableChainsTokens.js} +11 -6
- package/cjs/services/migration-service/scripts/MigrateNetworkSettings.js +39 -19
- package/cjs/services/migration-service/scripts/MigrateSettings.js +31 -0
- package/cjs/services/migration-service/scripts/MigrateTransactionHistory.js +72 -0
- package/cjs/services/migration-service/scripts/index.js +13 -4
- package/cjs/services/price-service/coingecko.js +15 -3
- package/cjs/services/price-service/index.js +15 -18
- package/cjs/services/request-service/constants.js +8 -2
- package/cjs/services/request-service/handler/AuthRequestHandler.js +43 -12
- package/cjs/services/request-service/index.js +3 -0
- package/cjs/services/storage-service/DatabaseService.js +53 -34
- package/cjs/services/storage-service/databases/index.js +1 -1
- package/cjs/services/storage-service/db-stores/BaseStoreWithAddressAndChain.js +2 -8
- package/cjs/services/storage-service/db-stores/Nft.js +8 -18
- package/cjs/services/storage-service/db-stores/Transaction.js +10 -7
- package/cjs/services/subscan-service/index.js +107 -0
- package/cjs/services/subscan-service/subscan-chain-map.js +74 -0
- package/cjs/services/subscan-service/types.js +1 -0
- package/cjs/services/transaction-service/event-parser/index.js +20 -48
- package/cjs/services/transaction-service/index.js +66 -22
- package/cjs/services/transaction-service/utils.js +4 -6
- package/cjs/utils/address.js +9 -1
- package/cjs/utils/index.js +30 -26
- package/constants/index.d.ts +8 -13
- package/constants/index.js +8 -13
- package/koni/api/dotsama/balance.d.ts +0 -1
- package/koni/api/dotsama/balance.js +33 -197
- package/koni/api/dotsama/transfer.js +5 -4
- package/koni/api/nft/acala_nft/index.js +3 -1
- package/koni/api/nft/bit.country/index.js +3 -1
- package/koni/api/nft/evm_nft/index.js +6 -3
- package/koni/api/nft/index.d.ts +1 -2
- package/koni/api/nft/index.js +3 -6
- package/koni/api/nft/karura_nft/index.js +3 -1
- package/koni/api/nft/nft.d.ts +1 -0
- package/koni/api/nft/rmrk_nft/index.js +8 -1
- package/koni/api/nft/statemine_nft/index.js +3 -1
- package/koni/api/nft/unique_nft/index.js +5 -1
- package/koni/api/nft/wasm_nft/index.d.ts +0 -2
- package/koni/api/nft/wasm_nft/index.js +167 -109
- package/koni/api/nft/wasm_nft/utils.d.ts +7 -5
- package/koni/api/nft/wasm_nft/utils.js +7 -5
- package/koni/api/staking/bonding/amplitude.d.ts +1 -2
- package/koni/api/staking/bonding/amplitude.js +22 -13
- package/koni/api/staking/bonding/astar.d.ts +2 -11
- package/koni/api/staking/bonding/astar.js +39 -231
- package/koni/api/staking/bonding/index.d.ts +5 -2
- package/koni/api/staking/bonding/index.js +27 -17
- package/koni/api/staking/bonding/paraChain.d.ts +4 -1
- package/koni/api/staking/bonding/paraChain.js +101 -14
- package/koni/api/staking/bonding/relayChain.d.ts +6 -2
- package/koni/api/staking/bonding/relayChain.js +172 -17
- package/koni/api/staking/bonding/utils.d.ts +15 -2
- package/koni/api/staking/bonding/utils.js +53 -11
- package/koni/api/tokens/wasm/index.js +5 -4
- package/koni/api/tokens/wasm/utils.d.ts +6 -0
- package/koni/api/tokens/wasm/utils.js +54 -0
- package/koni/api/xcm/index.js +1 -112
- package/koni/api/xcm/polkadotXcm.js +3 -3
- package/koni/api/xcm/utils.d.ts +5 -6
- package/koni/api/xcm/utils.js +15 -10
- package/koni/api/xcm/xTokens.js +5 -7
- package/koni/api/xcm/xcmPallet.js +10 -9
- package/koni/background/cron.d.ts +6 -1
- package/koni/background/cron.js +179 -76
- package/koni/background/handlers/Extension.d.ts +2 -2
- package/koni/background/handlers/Extension.js +161 -125
- package/koni/background/handlers/State.d.ts +21 -20
- package/koni/background/handlers/State.js +144 -111
- package/koni/background/handlers/Tabs.js +30 -20
- package/koni/background/subscription.d.ts +1 -1
- package/koni/background/subscription.js +64 -58
- package/package.json +63 -18
- package/packageInfo.js +1 -1
- package/page/index.d.ts +2 -0
- package/page/index.js +4 -0
- package/services/chain-service/constants.d.ts +0 -1
- package/services/chain-service/constants.js +0 -9
- package/services/chain-service/handler/SubstrateChainHandler.js +14 -9
- package/services/chain-service/handler/light-client/index.d.ts +17 -1
- package/services/chain-service/handler/light-client/index.js +1 -1
- package/services/chain-service/helper/psp22_abi.json +1041 -881
- package/services/chain-service/helper/psp34_abi.json +2963 -1807
- package/services/chain-service/index.d.ts +6 -4
- package/services/chain-service/index.js +40 -9
- package/services/chain-service/utils.d.ts +1 -0
- package/services/chain-service/utils.js +3 -0
- package/services/event-service/index.d.ts +22 -0
- package/services/event-service/index.js +63 -0
- package/services/event-service/types.d.ts +28 -0
- package/services/event-service/types.js +4 -0
- package/services/history-service/index.d.ts +5 -3
- package/services/history-service/index.js +46 -21
- package/services/history-service/subsquid-multi-chain-history.js +22 -13
- package/services/keyring-service/index.d.ts +19 -0
- package/services/keyring-service/index.js +93 -0
- package/services/migration-service/index.js +11 -9
- package/services/migration-service/scripts/AutoEnableChainsTokens.d.ts +4 -0
- package/services/migration-service/scripts/AutoEnableChainsTokens.js +13 -0
- package/services/migration-service/scripts/MigrateNetworkSettings.js +37 -18
- package/services/migration-service/scripts/MigrateSettings.d.ts +4 -0
- package/services/migration-service/scripts/MigrateSettings.js +23 -0
- package/services/migration-service/scripts/MigrateTransactionHistory.d.ts +4 -0
- package/services/migration-service/scripts/MigrateTransactionHistory.js +64 -0
- package/services/migration-service/scripts/index.d.ts +1 -0
- package/services/migration-service/scripts/index.js +10 -3
- package/services/price-service/coingecko.js +15 -3
- package/services/price-service/index.d.ts +5 -3
- package/services/price-service/index.js +15 -18
- package/services/request-service/constants.d.ts +1 -0
- package/services/request-service/constants.js +6 -1
- package/services/request-service/handler/AuthRequestHandler.d.ts +8 -1
- package/services/request-service/handler/AuthRequestHandler.js +44 -13
- package/services/request-service/index.d.ts +7 -1
- package/services/request-service/index.js +3 -0
- package/services/storage-service/DatabaseService.d.ts +1 -0
- package/services/storage-service/DatabaseService.js +53 -34
- package/services/storage-service/databases/index.js +1 -1
- package/services/storage-service/db-stores/BaseStoreWithAddressAndChain.d.ts +1 -1
- package/services/storage-service/db-stores/BaseStoreWithAddressAndChain.js +2 -8
- package/services/storage-service/db-stores/Nft.d.ts +3 -3
- package/services/storage-service/db-stores/Nft.js +8 -17
- package/services/storage-service/db-stores/Transaction.js +10 -7
- package/services/subscan-service/index.d.ts +20 -0
- package/services/subscan-service/index.js +99 -0
- package/services/subscan-service/subscan-chain-map.d.ts +5 -0
- package/services/subscan-service/subscan-chain-map.js +63 -0
- package/services/subscan-service/types.d.ts +27 -0
- package/services/subscan-service/types.js +1 -0
- package/services/transaction-service/event-parser/index.d.ts +2 -2
- package/services/transaction-service/event-parser/index.js +21 -49
- package/services/transaction-service/index.d.ts +4 -2
- package/services/transaction-service/index.js +66 -22
- package/services/transaction-service/utils.js +5 -6
- package/utils/address.d.ts +1 -0
- package/utils/address.js +9 -2
- package/utils/index.d.ts +2 -1
- package/utils/index.js +26 -23
- package/cjs/background/errors/EvmRpcError.js +0 -21
- package/cjs/background/errors/SubWalletProviderError.js +0 -17
- package/cjs/constants/ethereum.js +0 -19
- package/cjs/errors/SubWalletProviderError.js +0 -17
- package/cjs/koni/api/xcm/astar.js +0 -160
- package/cjs/koni/api/xcm/moonbeamXcm.js +0 -80
- package/cjs/koni/api/xcm/statemintXcm.js +0 -197
- package/cjs/koni/api/xcm/substrateXcm.js +0 -213
- package/cjs/koni/migration/Base.js +0 -20
- package/cjs/koni/migration/index.js +0 -45
- package/cjs/koni/migration/scripts/ChangeRouteToHome.js +0 -22
- package/cjs/koni/migration/scripts/ClearOldStorage.js +0 -24
- package/cjs/koni/migration/scripts/RemoveWrongTransactionHistoriesFromStore.js +0 -36
- package/cjs/koni/migration/scripts/ResetTransactionHistoryEventIdx.js +0 -21
- package/cjs/koni/migration/scripts/index.js +0 -22
- package/cjs/koni/page/index.js +0 -16
- package/cjs/services/asset-service/index.js +0 -91
- package/cjs/services/storage-service/db-stores/ExtraDelegationInfo.js +0 -17
- package/cjs/stores/Balance.js +0 -18
- package/cjs/stores/Crowdloan.js +0 -18
- package/cjs/stores/CustomEvmToken.js +0 -18
- package/cjs/stores/NetworkMap.js +0 -18
- package/cjs/stores/Nft.js +0 -18
- package/cjs/stores/NftCollection.js +0 -18
- package/cjs/stores/Price.js +0 -18
- package/cjs/stores/Staking.js +0 -18
- package/cjs/stores/StakingReward.js +0 -18
- package/cjs/utils/eth/parseTransactionData.js +0 -284
- package/koni/page/index.d.ts +0 -2
- package/koni/page/index.js +0 -9
- /package/cjs/{koni/page → page}/SubWalleEvmProvider.js +0 -0
- /package/{koni/page → page}/SubWalleEvmProvider.d.ts +0 -0
- /package/{koni/page → page}/SubWalleEvmProvider.js +0 -0
|
@@ -10,43 +10,28 @@ var _utils = require("@subwallet/extension-base/services/chain-service/utils");
|
|
|
10
10
|
// SPDX-License-Identifier: Apache-2.0
|
|
11
11
|
|
|
12
12
|
function parseXcmEventLogs(historyItem, eventLogs, chain, sendingTokenInfo, chainInfo) {
|
|
13
|
-
let isFeeUseMainTokenSymbol = true;
|
|
14
13
|
for (let index = 0; index < eventLogs.length; index++) {
|
|
15
14
|
const record = eventLogs[index];
|
|
16
|
-
if (['karura', 'acala', 'acala_testnet'].includes(chain) && sendingTokenInfo && !(0, _utils._isNativeToken)(sendingTokenInfo)) {
|
|
17
|
-
if (record.event.section === 'currencies' && record.event.method.toLowerCase() === 'transferred') {
|
|
18
|
-
if (index === 0) {
|
|
19
|
-
var _record$event$data$;
|
|
20
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
21
|
-
historyItem.fee = {
|
|
22
|
-
value: ((_record$event$data$ = record.event.data[3]) === null || _record$event$data$ === void 0 ? void 0 : _record$event$data$.toString()) || '0',
|
|
23
|
-
symbol: sendingTokenInfo.symbol,
|
|
24
|
-
decimals: (0, _utils._getAssetDecimals)(sendingTokenInfo)
|
|
25
|
-
};
|
|
26
|
-
isFeeUseMainTokenSymbol = false;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
15
|
const {
|
|
31
16
|
decimals: nativeDecimals,
|
|
32
17
|
symbol: nativeSymbol
|
|
33
18
|
} = (0, _utils._getChainNativeTokenBasicInfo)(chainInfo);
|
|
34
|
-
if (
|
|
35
|
-
var _record$event$data
|
|
36
|
-
if ((_record$event$data$
|
|
37
|
-
var _record$event$data$
|
|
19
|
+
if (record.event.section === 'balances' && record.event.method.toLowerCase() === 'withdraw') {
|
|
20
|
+
var _record$event$data$;
|
|
21
|
+
if ((_record$event$data$ = record.event.data[1]) !== null && _record$event$data$ !== void 0 && _record$event$data$.toString()) {
|
|
22
|
+
var _record$event$data$2;
|
|
38
23
|
historyItem.fee = {
|
|
39
|
-
value: (_record$event$data$
|
|
24
|
+
value: (_record$event$data$2 = record.event.data[1]) === null || _record$event$data$2 === void 0 ? void 0 : _record$event$data$2.toString(),
|
|
40
25
|
symbol: nativeSymbol,
|
|
41
26
|
decimals: nativeDecimals
|
|
42
27
|
};
|
|
43
28
|
}
|
|
44
|
-
} else if (
|
|
45
|
-
var _record$event$data$
|
|
46
|
-
if ((_record$event$data$
|
|
47
|
-
var _record$event$data$
|
|
29
|
+
} else if (record.event.section === 'tokens' && record.event.method.toLowerCase() === 'withdrawn') {
|
|
30
|
+
var _record$event$data$3;
|
|
31
|
+
if (!historyItem.fee && (_record$event$data$3 = record.event.data[2]) !== null && _record$event$data$3 !== void 0 && _record$event$data$3.toString()) {
|
|
32
|
+
var _record$event$data$4;
|
|
48
33
|
historyItem.fee = {
|
|
49
|
-
value: (_record$event$data$
|
|
34
|
+
value: (_record$event$data$4 = record.event.data[2]) === null || _record$event$data$4 === void 0 ? void 0 : _record$event$data$4.toString(),
|
|
50
35
|
symbol: nativeSymbol,
|
|
51
36
|
decimals: nativeDecimals
|
|
52
37
|
};
|
|
@@ -55,28 +40,15 @@ function parseXcmEventLogs(historyItem, eventLogs, chain, sendingTokenInfo, chai
|
|
|
55
40
|
}
|
|
56
41
|
}
|
|
57
42
|
function parseTransferEventLogs(historyItem, eventLogs, chain, sendingTokenInfo, chainInfo) {
|
|
58
|
-
let isFeeUseMainTokenSymbol = true;
|
|
59
43
|
for (let index = 0; index < eventLogs.length; index++) {
|
|
60
44
|
const record = eventLogs[index];
|
|
61
|
-
if (['
|
|
62
|
-
if (record.event.section === 'currencies' && record.event.method.toLowerCase() === 'transferred') {
|
|
63
|
-
if (index === 0) {
|
|
64
|
-
var _record$event$data$6;
|
|
65
|
-
historyItem.fee = {
|
|
66
|
-
value: ((_record$event$data$6 = record.event.data[3]) === null || _record$event$data$6 === void 0 ? void 0 : _record$event$data$6.toString()) || '0',
|
|
67
|
-
symbol: sendingTokenInfo.symbol,
|
|
68
|
-
decimals: (0, _utils._getAssetDecimals)(sendingTokenInfo)
|
|
69
|
-
};
|
|
70
|
-
isFeeUseMainTokenSymbol = false;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
} else if (['genshiro_testnet', 'genshiro', 'equilibrium_parachain'].includes(chain) && sendingTokenInfo) {
|
|
45
|
+
if (['genshiro_testnet', 'genshiro', 'equilibrium_parachain'].includes(chain) && sendingTokenInfo) {
|
|
74
46
|
if (record.event.section === 'transactionPayment' && record.event.method.toLowerCase() === 'transactionfeepaid') {
|
|
75
|
-
var _record$event$data$
|
|
76
|
-
if ((_record$event$data$
|
|
77
|
-
var _record$event$data$
|
|
47
|
+
var _record$event$data$5;
|
|
48
|
+
if ((_record$event$data$5 = record.event.data[1]) !== null && _record$event$data$5 !== void 0 && _record$event$data$5.toString()) {
|
|
49
|
+
var _record$event$data$6;
|
|
78
50
|
historyItem.fee = {
|
|
79
|
-
value: ((_record$event$data$
|
|
51
|
+
value: ((_record$event$data$6 = record.event.data[1]) === null || _record$event$data$6 === void 0 ? void 0 : _record$event$data$6.toString()) || '0',
|
|
80
52
|
symbol: sendingTokenInfo.symbol,
|
|
81
53
|
decimals: (0, _utils._getAssetDecimals)(sendingTokenInfo)
|
|
82
54
|
};
|
|
@@ -87,13 +59,13 @@ function parseTransferEventLogs(historyItem, eventLogs, chain, sendingTokenInfo,
|
|
|
87
59
|
decimals: nativeDecimals,
|
|
88
60
|
symbol: nativeSymbol
|
|
89
61
|
} = (0, _utils._getChainNativeTokenBasicInfo)(chainInfo);
|
|
90
|
-
if (
|
|
91
|
-
var _record$event$data$
|
|
92
|
-
if ((_record$event$data$
|
|
93
|
-
var _record$event$data$
|
|
62
|
+
if (record.event.section === 'balances' && record.event.method.toLowerCase() === 'withdraw') {
|
|
63
|
+
var _record$event$data$7;
|
|
64
|
+
if ((_record$event$data$7 = record.event.data[1]) !== null && _record$event$data$7 !== void 0 && _record$event$data$7.toString()) {
|
|
65
|
+
var _record$event$data$8;
|
|
94
66
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
95
67
|
historyItem.fee = {
|
|
96
|
-
value: ((_record$event$data$
|
|
68
|
+
value: ((_record$event$data$8 = record.event.data[1]) === null || _record$event$data$8 === void 0 ? void 0 : _record$event$data$8.toString()) || '0',
|
|
97
69
|
symbol: nativeSymbol,
|
|
98
70
|
decimals: nativeDecimals
|
|
99
71
|
};
|
|
@@ -31,8 +31,9 @@ class TransactionService {
|
|
|
31
31
|
get transactions() {
|
|
32
32
|
return this.transactionSubject.getValue();
|
|
33
33
|
}
|
|
34
|
-
constructor(chainService, requestService, balanceService, historyService, notificationService, databaseService) {
|
|
34
|
+
constructor(chainService, eventService, requestService, balanceService, historyService, notificationService, databaseService) {
|
|
35
35
|
this.chainService = chainService;
|
|
36
|
+
this.eventService = eventService;
|
|
36
37
|
this.requestService = requestService;
|
|
37
38
|
this.balanceService = balanceService;
|
|
38
39
|
this.historyService = historyService;
|
|
@@ -272,9 +273,10 @@ class TransactionService {
|
|
|
272
273
|
const chainInfo = this.chainService.getChainInfoByKey(transaction.chain);
|
|
273
274
|
return (0, _utils2.getTransactionLink)(chainInfo, transaction.extrinsicHash);
|
|
274
275
|
}
|
|
275
|
-
|
|
276
|
+
transactionToHistories(id, eventLogs) {
|
|
276
277
|
const transaction = this.getTransaction(id);
|
|
277
278
|
const historyItem = {
|
|
279
|
+
origin: 'app',
|
|
278
280
|
chain: transaction.chain,
|
|
279
281
|
direction: _KoniTypes.TransactionDirection.SEND,
|
|
280
282
|
type: transaction.extrinsicType,
|
|
@@ -287,8 +289,8 @@ class TransactionService {
|
|
|
287
289
|
time: transaction.createdAt.getTime(),
|
|
288
290
|
fee: transaction.estimateFee,
|
|
289
291
|
blockNumber: 0,
|
|
290
|
-
//
|
|
291
|
-
blockHash: '' //
|
|
292
|
+
// Will be added in next step
|
|
293
|
+
blockHash: '' // Will be added in next step
|
|
292
294
|
};
|
|
293
295
|
|
|
294
296
|
const chainInfo = this.chainService.getChainInfoByKey(transaction.chain);
|
|
@@ -337,6 +339,12 @@ class TransactionService {
|
|
|
337
339
|
decimals: sendingTokenInfo.decimals || 0,
|
|
338
340
|
symbol: sendingTokenInfo.symbol
|
|
339
341
|
};
|
|
342
|
+
|
|
343
|
+
// @ts-ignore
|
|
344
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
345
|
+
historyItem.additionalInfo = {
|
|
346
|
+
destinationChain: (inputData === null || inputData === void 0 ? void 0 : inputData.destinationNetworkKey) || ''
|
|
347
|
+
};
|
|
340
348
|
eventLogs && (0, _eventParser.parseXcmEventLogs)(historyItem, eventLogs, transaction.chain, sendingTokenInfo, chainInfo);
|
|
341
349
|
}
|
|
342
350
|
break;
|
|
@@ -403,15 +411,41 @@ class TransactionService {
|
|
|
403
411
|
{
|
|
404
412
|
const data = (0, _utils2.parseTransactionData)(transaction.data);
|
|
405
413
|
historyItem.to = data.validatorAddress || '';
|
|
414
|
+
historyItem.amount = {
|
|
415
|
+
...baseNativeAmount,
|
|
416
|
+
value: data.unstakingInfo.claimable || '0'
|
|
417
|
+
};
|
|
418
|
+
break;
|
|
419
|
+
}
|
|
420
|
+
case _KoniTypes.ExtrinsicType.STAKING_CANCEL_UNSTAKE:
|
|
421
|
+
{
|
|
422
|
+
const data = (0, _utils2.parseTransactionData)(transaction.data);
|
|
423
|
+
historyItem.amount = {
|
|
424
|
+
...baseNativeAmount,
|
|
425
|
+
value: data.selectedUnstaking.claimable || '0'
|
|
426
|
+
};
|
|
427
|
+
break;
|
|
406
428
|
}
|
|
407
|
-
break;
|
|
408
429
|
case _KoniTypes.ExtrinsicType.EVM_EXECUTE:
|
|
409
430
|
// Todo: Update historyItem.to
|
|
410
431
|
break;
|
|
411
432
|
case _KoniTypes.ExtrinsicType.UNKNOWN:
|
|
412
433
|
break;
|
|
413
434
|
}
|
|
414
|
-
|
|
435
|
+
try {
|
|
436
|
+
// Return one more history record if transaction send to account in the wallets
|
|
437
|
+
const toAccount = (historyItem === null || historyItem === void 0 ? void 0 : historyItem.to) && _uiKeyring.default.getPair(historyItem.to);
|
|
438
|
+
if (toAccount) {
|
|
439
|
+
return [historyItem, {
|
|
440
|
+
...historyItem,
|
|
441
|
+
address: toAccount.address,
|
|
442
|
+
direction: _KoniTypes.TransactionDirection.RECEIVED
|
|
443
|
+
}];
|
|
444
|
+
}
|
|
445
|
+
} catch (e) {
|
|
446
|
+
console.warn(e);
|
|
447
|
+
}
|
|
448
|
+
return [historyItem];
|
|
415
449
|
}
|
|
416
450
|
onHasTransactionHash(_ref) {
|
|
417
451
|
let {
|
|
@@ -424,24 +458,33 @@ class TransactionService {
|
|
|
424
458
|
extrinsicHash,
|
|
425
459
|
status: _KoniTypes.ExtrinsicStatus.PROCESSING
|
|
426
460
|
});
|
|
427
|
-
this.historyService.
|
|
461
|
+
this.historyService.insertHistories(this.transactionToHistories(id, eventLogs)).catch(console.error);
|
|
428
462
|
console.log(`Transaction "${id}" is submitted with hash ${extrinsicHash || ''}`);
|
|
429
463
|
}
|
|
430
464
|
handlePostProcessing(id) {
|
|
431
465
|
// must be done after success/failure to make sure the transaction is finalized
|
|
432
466
|
const transaction = this.getTransaction(id);
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
467
|
+
if (transaction.extrinsicType === _KoniTypes.ExtrinsicType.SEND_NFT) {
|
|
468
|
+
const inputData = (0, _utils2.parseTransactionData)(transaction.data);
|
|
469
|
+
try {
|
|
470
|
+
const sender = _uiKeyring.default.getPair(inputData.senderAddress);
|
|
471
|
+
sender && this.databaseService.handleNftTransfer(transaction.chain, [sender.address, _constants.ALL_ACCOUNT_KEY], inputData.nftItem).then(() => {
|
|
472
|
+
this.eventService.emit('transaction.transferNft', undefined);
|
|
473
|
+
}).catch(console.error);
|
|
474
|
+
} catch (e) {
|
|
475
|
+
console.error(e);
|
|
476
|
+
}
|
|
477
|
+
try {
|
|
478
|
+
const recipient = _uiKeyring.default.getPair(inputData.recipientAddress);
|
|
479
|
+
recipient && this.databaseService.addNft(recipient.address, {
|
|
480
|
+
...inputData.nftItem,
|
|
481
|
+
owner: recipient.address
|
|
482
|
+
}).catch(console.error);
|
|
483
|
+
} catch (e) {
|
|
484
|
+
console.error(e);
|
|
485
|
+
}
|
|
486
|
+
} else if ([_KoniTypes.ExtrinsicType.STAKING_BOND, _KoniTypes.ExtrinsicType.STAKING_UNBOND, _KoniTypes.ExtrinsicType.STAKING_WITHDRAW, _KoniTypes.ExtrinsicType.STAKING_CANCEL_UNSTAKE, _KoniTypes.ExtrinsicType.STAKING_CLAIM_REWARD, _KoniTypes.ExtrinsicType.STAKING_JOIN_POOL, _KoniTypes.ExtrinsicType.STAKING_POOL_WITHDRAW, _KoniTypes.ExtrinsicType.STAKING_LEAVE_POOL].includes(transaction.extrinsicType)) {
|
|
487
|
+
this.eventService.emit('transaction.submitStaking', transaction.chain);
|
|
445
488
|
}
|
|
446
489
|
}
|
|
447
490
|
onSuccess(_ref2) {
|
|
@@ -457,7 +500,7 @@ class TransactionService {
|
|
|
457
500
|
console.log('Transaction completed', id, transaction.extrinsicHash);
|
|
458
501
|
|
|
459
502
|
// Write success transaction history
|
|
460
|
-
this.historyService.
|
|
503
|
+
this.historyService.updateHistories(transaction.chain, transaction.extrinsicHash, {
|
|
461
504
|
status: _KoniTypes.ExtrinsicStatus.SUCCESS,
|
|
462
505
|
blockNumber: blockNumber || 0,
|
|
463
506
|
blockHash: blockHash || ''
|
|
@@ -471,6 +514,7 @@ class TransactionService {
|
|
|
471
514
|
},
|
|
472
515
|
notifyViaBrowser: true
|
|
473
516
|
});
|
|
517
|
+
this.eventService.emit('transaction.done', transaction);
|
|
474
518
|
}
|
|
475
519
|
onFailed(_ref3) {
|
|
476
520
|
let {
|
|
@@ -488,7 +532,7 @@ class TransactionService {
|
|
|
488
532
|
console.log('Transaction failed', id, transaction.extrinsicHash);
|
|
489
533
|
|
|
490
534
|
// Write failed transaction history
|
|
491
|
-
this.historyService.
|
|
535
|
+
this.historyService.updateHistories(transaction.chain, transaction.extrinsicHash, {
|
|
492
536
|
status: _KoniTypes.ExtrinsicStatus.FAIL,
|
|
493
537
|
blockNumber: blockNumber || 0,
|
|
494
538
|
blockHash: blockHash || ''
|
|
@@ -503,7 +547,7 @@ class TransactionService {
|
|
|
503
547
|
notifyViaBrowser: true
|
|
504
548
|
});
|
|
505
549
|
}
|
|
506
|
-
|
|
550
|
+
this.eventService.emit('transaction.failed', transaction);
|
|
507
551
|
// Log transaction errors
|
|
508
552
|
console.error(errors);
|
|
509
553
|
}
|
|
@@ -5,25 +5,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.getTransactionLink = getTransactionLink;
|
|
7
7
|
exports.parseTransactionData = parseTransactionData;
|
|
8
|
+
var _utils = require("@subwallet/extension-base/services/chain-service/utils");
|
|
8
9
|
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
9
10
|
// SPDX-License-Identifier: Apache-2.0
|
|
10
11
|
|
|
11
12
|
// @ts-ignore
|
|
12
13
|
function parseTransactionData(data) {
|
|
13
|
-
// @ts-ignore
|
|
14
14
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
15
15
|
return data;
|
|
16
16
|
}
|
|
17
17
|
function getTransactionLink(chainInfo, extrinsicHash) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const explorerLink = chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$evmInfo = chainInfo.evmInfo) === null || _chainInfo$evmInfo === void 0 ? void 0 : _chainInfo$evmInfo.blockExplorer;
|
|
18
|
+
const explorerLink = (0, _utils._getBlockExplorerFromChain)(chainInfo);
|
|
19
|
+
if ((0, _utils._isPureEvmChain)(chainInfo)) {
|
|
21
20
|
if (explorerLink) {
|
|
22
21
|
return `${explorerLink}${explorerLink.endsWith('/') ? '' : '/'}tx/${extrinsicHash}`;
|
|
23
22
|
}
|
|
24
23
|
} else {
|
|
25
|
-
|
|
26
|
-
const explorerLink = chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$substrateI = chainInfo.substrateInfo) === null || _chainInfo$substrateI === void 0 ? void 0 : _chainInfo$substrateI.blockExplorer;
|
|
24
|
+
const explorerLink = (0, _utils._getBlockExplorerFromChain)(chainInfo);
|
|
27
25
|
if (explorerLink) {
|
|
28
26
|
return `${explorerLink}${explorerLink.endsWith('/') ? '' : '/'}extrinsic/${extrinsicHash}`;
|
|
29
27
|
}
|
package/cjs/utils/address.js
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.quickFormatAddressToCompare = quickFormatAddressToCompare;
|
|
6
7
|
exports.simpleAddress = void 0;
|
|
8
|
+
var _index = require("@subwallet/extension-base/utils/index");
|
|
7
9
|
var _utilCrypto = require("@polkadot/util-crypto");
|
|
8
10
|
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
9
11
|
// SPDX-License-Identifier: Apache-2.0
|
|
@@ -14,4 +16,10 @@ const simpleAddress = address => {
|
|
|
14
16
|
}
|
|
15
17
|
return (0, _utilCrypto.encodeAddress)((0, _utilCrypto.decodeAddress)(address));
|
|
16
18
|
};
|
|
17
|
-
exports.simpleAddress = simpleAddress;
|
|
19
|
+
exports.simpleAddress = simpleAddress;
|
|
20
|
+
function quickFormatAddressToCompare(address) {
|
|
21
|
+
if (!(0, _utilCrypto.isAddress)(address)) {
|
|
22
|
+
return address;
|
|
23
|
+
}
|
|
24
|
+
return (0, _index.reformatAddress)(address, 42).toLowerCase();
|
|
25
|
+
}
|
package/cjs/utils/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
@@ -15,7 +14,9 @@ exports.categoryNetworks = categoryNetworks;
|
|
|
15
14
|
exports.convertFundStatus = void 0;
|
|
16
15
|
exports.convertToEvmAddress = convertToEvmAddress;
|
|
17
16
|
exports.filterAddressByNetworkKey = filterAddressByNetworkKey;
|
|
18
|
-
exports.
|
|
17
|
+
exports.getCurrentProvider = exports.filterAndSortingAccountByAuthType = void 0;
|
|
18
|
+
exports.getDomainFromUrl = getDomainFromUrl;
|
|
19
|
+
exports.getNftProvider = void 0;
|
|
19
20
|
exports.hexToStr = hexToStr;
|
|
20
21
|
exports.hexToUTF16 = hexToUTF16;
|
|
21
22
|
exports.inJestTest = inJestTest;
|
|
@@ -26,15 +27,14 @@ exports.isUrl = isUrl;
|
|
|
26
27
|
exports.isValidSubstrateAddress = exports.isValidProvider = void 0;
|
|
27
28
|
exports.mergeNetworkProviders = mergeNetworkProviders;
|
|
28
29
|
exports.parseIpfsLink = exports.notDef = exports.nonEmptyArr = void 0;
|
|
29
|
-
exports.parseNumberToDisplay = parseNumberToDisplay;
|
|
30
30
|
exports.parseRawNumber = parseRawNumber;
|
|
31
31
|
exports.reformatAddress = reformatAddress;
|
|
32
32
|
exports.sumBN = sumBN;
|
|
33
33
|
exports.toUnit = void 0;
|
|
34
34
|
exports.utf16ToString = utf16ToString;
|
|
35
|
+
exports.waitTimeout = waitTimeout;
|
|
35
36
|
var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
36
37
|
var _constants = require("@subwallet/extension-base/constants");
|
|
37
|
-
var _bignumber = _interopRequireDefault(require("bignumber.js"));
|
|
38
38
|
var _util = require("@polkadot/util");
|
|
39
39
|
var _utilCrypto = require("@polkadot/util-crypto");
|
|
40
40
|
var _canDerive = require("./canDerive");
|
|
@@ -54,20 +54,25 @@ function isAccountAll(address) {
|
|
|
54
54
|
}
|
|
55
55
|
function reformatAddress(address, networkPrefix) {
|
|
56
56
|
let isEthereum = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
57
|
+
try {
|
|
58
|
+
if ((0, _utilCrypto.isEthereumAddress)(address)) {
|
|
59
|
+
return address;
|
|
60
|
+
}
|
|
61
|
+
if (isAccountAll(address)) {
|
|
62
|
+
return address;
|
|
63
|
+
}
|
|
64
|
+
const publicKey = (0, _utilCrypto.decodeAddress)(address);
|
|
65
|
+
if (isEthereum) {
|
|
66
|
+
return (0, _utilCrypto.ethereumEncode)(publicKey);
|
|
67
|
+
}
|
|
68
|
+
if (networkPrefix < 0) {
|
|
69
|
+
return address;
|
|
70
|
+
}
|
|
71
|
+
return (0, _utilCrypto.encodeAddress)(publicKey, networkPrefix);
|
|
72
|
+
} catch (e) {
|
|
73
|
+
console.warn('Get error while reformat address', address, e);
|
|
68
74
|
return address;
|
|
69
75
|
}
|
|
70
|
-
return (0, _utilCrypto.encodeAddress)(publicKey, networkPrefix);
|
|
71
76
|
}
|
|
72
77
|
function filterAddressByNetworkKey(addresses, networkKey, isEthereum) {
|
|
73
78
|
if (isEthereum) {
|
|
@@ -308,17 +313,16 @@ exports.filterAndSortingAccountByAuthType = filterAndSortingAccountByAuthType;
|
|
|
308
313
|
function parseRawNumber(value) {
|
|
309
314
|
return parseFloat(value.replaceAll(',', ''));
|
|
310
315
|
}
|
|
311
|
-
function
|
|
312
|
-
if (
|
|
313
|
-
return
|
|
316
|
+
function isSameAddress(address1, address2) {
|
|
317
|
+
if ((0, _utilCrypto.isEthereumAddress)(address1)) {
|
|
318
|
+
return address1.toLowerCase() === address2.toLowerCase();
|
|
314
319
|
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
const roundedString = bigN.toFixed(9);
|
|
318
|
-
const formattedString = parseFloat(roundedString); // remove excess zeros at the end
|
|
320
|
+
return reformatAddress(address1, 0) === reformatAddress(address2, 0); // TODO: maybe there's a better way
|
|
321
|
+
}
|
|
319
322
|
|
|
320
|
-
|
|
323
|
+
function getDomainFromUrl(url) {
|
|
324
|
+
return url.replace(/^(https?:\/\/)?(www\.)?/, '').split('/')[0];
|
|
321
325
|
}
|
|
322
|
-
function
|
|
323
|
-
return
|
|
326
|
+
async function waitTimeout(ms) {
|
|
327
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
324
328
|
}
|
package/constants/index.d.ts
CHANGED
|
@@ -1,25 +1,20 @@
|
|
|
1
1
|
export declare const CRON_REFRESH_PRICE_INTERVAL = 30000;
|
|
2
|
-
export declare const DOTSAMA_API_TIMEOUT = 30000;
|
|
3
|
-
export declare const DOTSAMA_AUTO_CONNECT_MS = 3000;
|
|
4
|
-
export declare const DOTSAMA_MAX_CONTINUE_RETRY = 2;
|
|
5
2
|
export declare const CRON_AUTO_RECOVER_DOTSAMA_INTERVAL = 60000;
|
|
6
3
|
export declare const CRON_AUTO_RECOVER_WEB3_INTERVAL = 90000;
|
|
7
4
|
export declare const ACALA_REFRESH_CROWDLOAN_INTERVAL = 300000;
|
|
8
|
-
export declare const
|
|
9
|
-
export declare const
|
|
10
|
-
export declare const
|
|
11
|
-
export declare const SUBSCRIBE_BALANCE_FAST_INTERVAL = 9000;
|
|
12
|
-
export declare const CRON_REFRESH_NFT_INTERVAL = 900000;
|
|
5
|
+
export declare const ASTAR_REFRESH_BALANCE_INTERVAL = 60000;
|
|
6
|
+
export declare const SUB_TOKEN_REFRESH_BALANCE_INTERVAL = 60000;
|
|
7
|
+
export declare const CRON_REFRESH_NFT_INTERVAL = 7200000;
|
|
13
8
|
export declare const CRON_REFRESH_STAKING_REWARD_INTERVAL = 900000;
|
|
14
|
-
export declare const CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL =
|
|
15
|
-
export declare const CRON_REFRESH_HISTORY_INTERVAL =
|
|
16
|
-
export declare const CRON_GET_API_MAP_STATUS =
|
|
17
|
-
export declare const CRON_REFRESH_STAKING_DATA = 30000;
|
|
9
|
+
export declare const CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL = 300000;
|
|
10
|
+
export declare const CRON_REFRESH_HISTORY_INTERVAL = 900000;
|
|
11
|
+
export declare const CRON_GET_API_MAP_STATUS = 10000;
|
|
18
12
|
export declare const CRON_REFRESH_CHAIN_STAKING_METADATA = 900000;
|
|
19
|
-
export declare const CRON_REFRESH_CHAIN_NOMINATOR_METADATA =
|
|
13
|
+
export declare const CRON_REFRESH_CHAIN_NOMINATOR_METADATA = 1800000;
|
|
20
14
|
export declare const ALL_ACCOUNT_KEY = "ALL";
|
|
21
15
|
export declare const ALL_NETWORK_KEY = "all";
|
|
22
16
|
export declare const ALL_GENESIS_HASH: null;
|
|
23
17
|
export declare const IGNORE_GET_SUBSTRATE_FEATURES_LIST: string[];
|
|
24
18
|
export declare const IGNORE_QR_SIGNER: string[];
|
|
19
|
+
export declare const DEFAULT_TIME_AUTO_LOCK: number;
|
|
25
20
|
export * from './staking';
|
package/constants/index.js
CHANGED
|
@@ -2,27 +2,22 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
export const CRON_REFRESH_PRICE_INTERVAL = 30000;
|
|
5
|
-
export const DOTSAMA_API_TIMEOUT = 30000;
|
|
6
|
-
export const DOTSAMA_AUTO_CONNECT_MS = 3000;
|
|
7
|
-
export const DOTSAMA_MAX_CONTINUE_RETRY = 2;
|
|
8
5
|
export const CRON_AUTO_RECOVER_DOTSAMA_INTERVAL = 60000;
|
|
9
6
|
export const CRON_AUTO_RECOVER_WEB3_INTERVAL = 90000;
|
|
10
7
|
export const ACALA_REFRESH_CROWDLOAN_INTERVAL = 300000;
|
|
11
|
-
export const
|
|
12
|
-
export const
|
|
13
|
-
export const
|
|
14
|
-
export const SUBSCRIBE_BALANCE_FAST_INTERVAL = 9000;
|
|
15
|
-
export const CRON_REFRESH_NFT_INTERVAL = 900000;
|
|
8
|
+
export const ASTAR_REFRESH_BALANCE_INTERVAL = 60000;
|
|
9
|
+
export const SUB_TOKEN_REFRESH_BALANCE_INTERVAL = 60000;
|
|
10
|
+
export const CRON_REFRESH_NFT_INTERVAL = 7200000;
|
|
16
11
|
export const CRON_REFRESH_STAKING_REWARD_INTERVAL = 900000;
|
|
17
|
-
export const CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL =
|
|
18
|
-
export const CRON_REFRESH_HISTORY_INTERVAL =
|
|
19
|
-
export const CRON_GET_API_MAP_STATUS =
|
|
20
|
-
export const CRON_REFRESH_STAKING_DATA = 30000;
|
|
12
|
+
export const CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL = 300000;
|
|
13
|
+
export const CRON_REFRESH_HISTORY_INTERVAL = 900000;
|
|
14
|
+
export const CRON_GET_API_MAP_STATUS = 10000;
|
|
21
15
|
export const CRON_REFRESH_CHAIN_STAKING_METADATA = 900000;
|
|
22
|
-
export const CRON_REFRESH_CHAIN_NOMINATOR_METADATA =
|
|
16
|
+
export const CRON_REFRESH_CHAIN_NOMINATOR_METADATA = 1800000;
|
|
23
17
|
export const ALL_ACCOUNT_KEY = 'ALL';
|
|
24
18
|
export const ALL_NETWORK_KEY = 'all';
|
|
25
19
|
export const ALL_GENESIS_HASH = null;
|
|
26
20
|
export const IGNORE_GET_SUBSTRATE_FEATURES_LIST = ['astarEvm', 'ethereum', 'ethereum_goerli', 'binance', 'binance_test', 'boba_rinkeby', 'boba', 'bobabase', 'bobabeam'];
|
|
27
21
|
export const IGNORE_QR_SIGNER = [];
|
|
22
|
+
export const DEFAULT_TIME_AUTO_LOCK = 15 * 60 * 1000;
|
|
28
23
|
export * from "./staking.js";
|
|
@@ -4,4 +4,3 @@ import { _EvmApi, _SubstrateApi } from '@subwallet/extension-base/services/chain
|
|
|
4
4
|
export declare function subscribeBalance(addresses: string[], chainInfoMap: Record<string, _ChainInfo>, substrateApiMap: Record<string, _SubstrateApi>, evmApiMap: Record<string, _EvmApi>, callback: (rs: BalanceItem) => void): () => void;
|
|
5
5
|
export declare function subscribeSubstrateBalance(addresses: string[], chainInfo: _ChainInfo, chain: string, networkAPI: _SubstrateApi, evmApiMap: Record<string, _EvmApi>, callBack: (rs: BalanceItem) => void): Promise<() => void>;
|
|
6
6
|
export declare function subscribeEVMBalance(chain: string, addresses: string[], evmApiMap: Record<string, _EvmApi>, callback: (rs: BalanceItem) => void, tokenInfo: _ChainAsset): () => void;
|
|
7
|
-
export declare function getFreeBalance(chain: string, address: string, substrateApiMap: Record<string, _SubstrateApi>, evmApiMap: Record<string, _EvmApi>, tokenSlug?: string): Promise<string>;
|