@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
|
@@ -6,6 +6,7 @@ import KoniDatabase from '@subwallet/extension-base/services/storage-service/dat
|
|
|
6
6
|
import { AssetStore, BalanceStore, ChainStore, CrowdloanStore, MigrationStore, NftCollectionStore, NftStore, PriceStore, StakingStore, TransactionStore } from '@subwallet/extension-base/services/storage-service/db-stores';
|
|
7
7
|
import ChainStakingMetadataStore from '@subwallet/extension-base/services/storage-service/db-stores/ChainStakingMetadata';
|
|
8
8
|
import NominatorMetadataStore from '@subwallet/extension-base/services/storage-service/db-stores/NominatorMetadata';
|
|
9
|
+
import { reformatAddress } from '@subwallet/extension-base/utils';
|
|
9
10
|
import { logger as createLogger } from '@polkadot/util';
|
|
10
11
|
export default class DatabaseService {
|
|
11
12
|
// TODO: might remove this
|
|
@@ -47,7 +48,8 @@ export default class DatabaseService {
|
|
|
47
48
|
}
|
|
48
49
|
async updateBalanceStore(address, item) {
|
|
49
50
|
if (item.state === APIItemState.READY) {
|
|
50
|
-
this.logger.log(`Updating balance for [${item.tokenSlug}]`);
|
|
51
|
+
// this.logger.log(`Updating balance for [${item.tokenSlug}]`);
|
|
52
|
+
|
|
51
53
|
return this.stores.balance.upsert({
|
|
52
54
|
address,
|
|
53
55
|
...item
|
|
@@ -62,14 +64,16 @@ export default class DatabaseService {
|
|
|
62
64
|
// Crowdloan
|
|
63
65
|
async updateCrowdloanStore(chain, address, item) {
|
|
64
66
|
if (item.state === APIItemState.READY && item.contribute !== '0') {
|
|
65
|
-
this.logger.log(`Updating crowdloan for [${chain}]`);
|
|
67
|
+
// this.logger.log(`Updating crowdloan for [${chain}]`);
|
|
68
|
+
|
|
66
69
|
return this.stores.crowdloan.upsert({
|
|
67
70
|
chain,
|
|
68
71
|
address,
|
|
69
72
|
...item
|
|
70
73
|
});
|
|
71
74
|
} else {
|
|
72
|
-
this.logger.debug(`Removing crowdloan for [${chain}]`);
|
|
75
|
+
// this.logger.debug(`Removing crowdloan for [${chain}]`);
|
|
76
|
+
|
|
73
77
|
return this.stores.crowdloan.deleteByChainAndAddress(chain, address);
|
|
74
78
|
}
|
|
75
79
|
}
|
|
@@ -77,22 +81,23 @@ export default class DatabaseService {
|
|
|
77
81
|
// Staking
|
|
78
82
|
async updateStaking(chain, address, item) {
|
|
79
83
|
if (item.state === APIItemState.READY) {
|
|
80
|
-
this.logger.log(`Updating staking for [${chain}]`);
|
|
84
|
+
// this.logger.log(`Updating staking for [${chain}]`);
|
|
85
|
+
|
|
81
86
|
return this.stores.staking.upsert(item);
|
|
82
87
|
}
|
|
83
88
|
}
|
|
84
89
|
async getStakings(addresses, chains) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
return
|
|
90
|
+
// this.logger.log('Get Stakings: ', stakings);
|
|
91
|
+
|
|
92
|
+
return this.stores.staking.getStakings(addresses, chains);
|
|
88
93
|
}
|
|
89
94
|
async getStakingsByChains(chains) {
|
|
90
95
|
return this.stores.staking.getStakingsByChains(chains);
|
|
91
96
|
}
|
|
92
97
|
async getPooledStakings(addresses, chainHashes) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
return
|
|
98
|
+
// this.logger.log('Get Pooled Stakings: ', stakings);
|
|
99
|
+
|
|
100
|
+
return this.stores.staking.getPooledStakings(addresses, chainHashes);
|
|
96
101
|
}
|
|
97
102
|
subscribeStaking(addresses, chainList, callback) {
|
|
98
103
|
this.stakingSubscription && this.stakingSubscription.unsubscribe();
|
|
@@ -114,18 +119,18 @@ export default class DatabaseService {
|
|
|
114
119
|
|
|
115
120
|
// Transaction histories
|
|
116
121
|
async getHistories(query) {
|
|
117
|
-
|
|
118
|
-
this.logger.log('Get histories: ', histories);
|
|
119
|
-
return histories;
|
|
122
|
+
return this.stores.transaction.queryHistory(query);
|
|
120
123
|
}
|
|
121
124
|
async upsertHistory(histories) {
|
|
122
|
-
this.logger.log('Updating transaction histories');
|
|
125
|
+
// this.logger.log('Updating transaction histories');
|
|
126
|
+
|
|
123
127
|
return this.stores.transaction.bulkUpsert(histories);
|
|
124
128
|
}
|
|
125
129
|
|
|
126
130
|
// NFT Collection
|
|
127
131
|
async addNftCollection(collection) {
|
|
128
|
-
this.logger.log(`Updating NFT collection for [${collection.chain}]`);
|
|
132
|
+
// this.logger.log(`Updating NFT collection for [${collection.chain}]`);
|
|
133
|
+
|
|
129
134
|
return this.stores.nftCollection.upsert(collection);
|
|
130
135
|
}
|
|
131
136
|
async deleteNftCollection(chain, collectionId) {
|
|
@@ -144,63 +149,76 @@ export default class DatabaseService {
|
|
|
144
149
|
});
|
|
145
150
|
return this.nftSubscription;
|
|
146
151
|
}
|
|
152
|
+
async cleanUpNft(chain, owner, collectionId, nftIds) {
|
|
153
|
+
const result = await this.stores.nft.cleanUpNfts(chain, reformatAddress(owner, 42), collectionId, nftIds);
|
|
154
|
+
result > 0 && console.debug(`Clean up ${result} NFTs from collection ${collectionId} on chain ${chain} for owner ${owner}`);
|
|
155
|
+
return result;
|
|
156
|
+
}
|
|
147
157
|
async getNft(addresses, chainHashes) {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
return
|
|
158
|
+
// this.logger.log('Get NFTs: ', nfts);
|
|
159
|
+
|
|
160
|
+
return this.stores.nft.getNft(addresses, chainHashes);
|
|
151
161
|
}
|
|
152
162
|
async addNft(address, nft) {
|
|
153
|
-
this.logger.log(`Updating NFT for [${nft.chain}]`);
|
|
163
|
+
// this.logger.log(`Updating NFT for [${nft.chain}]`);
|
|
164
|
+
|
|
154
165
|
return this.stores.nft.upsert({
|
|
155
166
|
...nft,
|
|
156
167
|
address
|
|
157
168
|
});
|
|
158
169
|
}
|
|
159
170
|
handleNftTransfer(chain, addresses, nftItem) {
|
|
160
|
-
return this.stores.nft.
|
|
171
|
+
return this.stores.nft.deleteNftItem(chain, addresses, nftItem);
|
|
161
172
|
}
|
|
162
173
|
removeNfts(chain, address, collectionId, nftIds) {
|
|
163
|
-
this.logger.log(`Remove NFTs [${nftIds.join(', ')}]`);
|
|
174
|
+
// this.logger.log(`Remove NFTs [${nftIds.join(', ')}]`);
|
|
175
|
+
|
|
164
176
|
return this.stores.nft.removeNfts(chain, address, collectionId, nftIds);
|
|
165
177
|
}
|
|
166
178
|
|
|
167
179
|
// Chain
|
|
168
180
|
async updateChainStore(item) {
|
|
169
|
-
this.logger.log(`Updating storageInfo for chain [${item.slug}]`);
|
|
181
|
+
// this.logger.log(`Updating storageInfo for chain [${item.slug}]`);
|
|
182
|
+
|
|
170
183
|
return this.stores.chain.upsert(item);
|
|
171
184
|
}
|
|
172
185
|
async bulkUpdateChainStore(data) {
|
|
173
|
-
this.logger.log('Bulk updating ChainStore');
|
|
186
|
+
// this.logger.log('Bulk updating ChainStore');
|
|
187
|
+
|
|
174
188
|
return this.stores.chain.bulkUpsert(data);
|
|
175
189
|
}
|
|
176
190
|
async removeFromChainStore(chains) {
|
|
177
|
-
this.logger.log('Bulk removing ChainStore');
|
|
191
|
+
// this.logger.log('Bulk removing ChainStore');
|
|
192
|
+
|
|
178
193
|
return this.stores.chain.removeChains(chains);
|
|
179
194
|
}
|
|
180
195
|
async getAllChainStore() {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
return
|
|
196
|
+
// this.logger.log('Get all chains: ', allChains);
|
|
197
|
+
|
|
198
|
+
return this.stores.chain.getAll();
|
|
184
199
|
}
|
|
185
200
|
|
|
186
201
|
// Asset
|
|
187
202
|
async updateAssetStore(item) {
|
|
188
|
-
this.logger.log(`Updating storageInfo for chainAsset [${item.originChain}]`);
|
|
203
|
+
// this.logger.log(`Updating storageInfo for chainAsset [${item.originChain}]`);
|
|
204
|
+
|
|
189
205
|
return this.stores.asset.upsert(item);
|
|
190
206
|
}
|
|
191
207
|
async getAllAssetStore() {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
return
|
|
208
|
+
// this.logger.log('Get all stored assets: ', allAssets);
|
|
209
|
+
|
|
210
|
+
return this.stores.asset.getAll();
|
|
195
211
|
}
|
|
196
212
|
async removeFromAssetStore(items) {
|
|
197
|
-
this.logger.log('Bulk removing AssetStore');
|
|
213
|
+
// this.logger.log('Bulk removing AssetStore');
|
|
214
|
+
|
|
198
215
|
return this.stores.asset.removeAssets(items);
|
|
199
216
|
}
|
|
200
217
|
|
|
201
218
|
// Staking
|
|
202
219
|
async updateChainStakingMetadata(item) {
|
|
203
|
-
this.logger.log('Update ChainStakingMetadata: ', item.chain);
|
|
220
|
+
// this.logger.log('Update ChainStakingMetadata: ', item.chain);
|
|
221
|
+
|
|
204
222
|
return this.stores.chainStakingMetadata.upsert(item);
|
|
205
223
|
}
|
|
206
224
|
async getChainStakingMetadata() {
|
|
@@ -210,7 +228,8 @@ export default class DatabaseService {
|
|
|
210
228
|
return this.stores.chainStakingMetadata.getByChainAndType(chain, type);
|
|
211
229
|
}
|
|
212
230
|
async updateNominatorMetadata(item) {
|
|
213
|
-
this.logger.log('Update NominatorMetadata: ', item.address, item.chain);
|
|
231
|
+
// this.logger.log('Update NominatorMetadata: ', item.address, item.chain);
|
|
232
|
+
|
|
214
233
|
return this.stores.nominatorMetadata.upsert(item);
|
|
215
234
|
}
|
|
216
235
|
async getNominatorMetadata() {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import Dexie from 'dexie';
|
|
5
5
|
const DEFAULT_DATABASE = 'SubWalletDB_v2';
|
|
6
6
|
export default class KoniDatabase extends Dexie {
|
|
7
|
-
constructor(name = DEFAULT_DATABASE, schemaVersion =
|
|
7
|
+
constructor(name = DEFAULT_DATABASE, schemaVersion = 10) {
|
|
8
8
|
super(name);
|
|
9
9
|
this.schemaVersion = schemaVersion;
|
|
10
10
|
this.conditionalVersion(1, {
|
|
@@ -2,6 +2,6 @@ import { DefaultDocWithAddressAndChain } from '@subwallet/extension-base/service
|
|
|
2
2
|
import BaseStore from '@subwallet/extension-base/services/storage-service/db-stores/BaseStore';
|
|
3
3
|
export default class BaseStoreWithAddressAndChain<T extends DefaultDocWithAddressAndChain> extends BaseStore<T> {
|
|
4
4
|
convertToJsonObject(items: T[]): Record<string, T>;
|
|
5
|
-
removeAllByAddress(address: string
|
|
5
|
+
removeAllByAddress(address: string): import("dexie").PromiseExtended<number>;
|
|
6
6
|
getDataByAddressAsObject(address: string): Promise<Record<string, T>>;
|
|
7
7
|
}
|
|
@@ -9,14 +9,8 @@ export default class BaseStoreWithAddressAndChain extends BaseStore {
|
|
|
9
9
|
[v.chain]: v
|
|
10
10
|
}), {});
|
|
11
11
|
}
|
|
12
|
-
removeAllByAddress(address
|
|
13
|
-
|
|
14
|
-
address
|
|
15
|
-
};
|
|
16
|
-
if (chain) {
|
|
17
|
-
conditions.chain = chain;
|
|
18
|
-
}
|
|
19
|
-
return this.table.where(conditions).delete();
|
|
12
|
+
removeAllByAddress(address) {
|
|
13
|
+
return this.table.where('address').equalsIgnoreCase(address).delete();
|
|
20
14
|
}
|
|
21
15
|
async getDataByAddressAsObject(address) {
|
|
22
16
|
const data = await this.table.where('address').equals(address).toArray();
|
|
@@ -4,9 +4,9 @@ import { INft } from '../databases';
|
|
|
4
4
|
export default class NftStore extends BaseStoreWithAddressAndChain<INft> {
|
|
5
5
|
getNft(addresses: string[], chainList?: string[]): import("dexie").PromiseExtended<INft[]>;
|
|
6
6
|
subscribeNft(addresses: string[], chainList?: string[]): import("dexie").Observable<INft[]>;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
cleanUpNfts(chain: string, address: string, collectionId: string, nftIds: string[]): import("dexie").PromiseExtended<number>;
|
|
8
|
+
deleteNftByAddress(addresses: string[]): import("dexie").PromiseExtended<number>;
|
|
9
|
+
deleteNftItem(chain: string, addresses: string[], nftItem: NftItem): import("dexie").PromiseExtended<number>;
|
|
10
10
|
deleteNftsByCollection(chain: string, collectionId: string): import("dexie").PromiseExtended<number>;
|
|
11
11
|
removeNfts(chain: string, address: string, collectionId: string, nftIds: string[]): import("dexie").PromiseExtended<number>;
|
|
12
12
|
}
|
|
@@ -15,26 +15,17 @@ export default class NftStore extends BaseStoreWithAddressAndChain {
|
|
|
15
15
|
subscribeNft(addresses, chainList = []) {
|
|
16
16
|
return liveQuery(() => this.getNft(addresses, chainList));
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
const conditions = {
|
|
20
|
-
chainHash,
|
|
21
|
-
address
|
|
22
|
-
};
|
|
23
|
-
if (!collection && nftIds && nftIds.length) {
|
|
24
|
-
return this.logger.warn('Missing collection id');
|
|
25
|
-
}
|
|
26
|
-
if (collection) {
|
|
27
|
-
conditions.collectionId = collection;
|
|
28
|
-
}
|
|
29
|
-
return this.table.where(conditions).and(item => !nftIds.some(nft => nft === item.id)).delete();
|
|
30
|
-
}
|
|
31
|
-
deleteNftsFromRemovedCollection(chain, address, collectionIds) {
|
|
18
|
+
cleanUpNfts(chain, address, collectionId, nftIds) {
|
|
32
19
|
return this.table.where({
|
|
33
20
|
address,
|
|
34
|
-
chain
|
|
35
|
-
|
|
21
|
+
chain,
|
|
22
|
+
collectionId
|
|
23
|
+
}).and(nft => !nftIds.includes(nft.id)).delete();
|
|
24
|
+
}
|
|
25
|
+
deleteNftByAddress(addresses) {
|
|
26
|
+
return this.table.where('address').anyOfIgnoreCase(addresses).delete();
|
|
36
27
|
}
|
|
37
|
-
|
|
28
|
+
deleteNftItem(chain, addresses, nftItem) {
|
|
38
29
|
return this.table.where('address').anyOfIgnoreCase(addresses).filter(storedItem => storedItem.chain === chain && storedItem.collectionId === nftItem.collectionId && storedItem.id === nftItem.id).delete();
|
|
39
30
|
}
|
|
40
31
|
deleteNftsByCollection(chain, collectionId) {
|
|
@@ -29,13 +29,16 @@ export default class TransactionStore extends BaseStoreWithAddressAndChain {
|
|
|
29
29
|
}
|
|
30
30
|
async bulkUpsert(records) {
|
|
31
31
|
await this.table.bulkPut(records);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}))
|
|
32
|
+
|
|
33
|
+
// await Promise.all(records.map((record) => {
|
|
34
|
+
// return this.table.where({
|
|
35
|
+
// chain: record.chain,
|
|
36
|
+
// address: record.address,
|
|
37
|
+
// extrinsicHash: record.extrinsicHash
|
|
38
|
+
// }).filter((item) => (item.origin === 'app' && record.origin !== 'app'))
|
|
39
|
+
// .delete();
|
|
40
|
+
// }));
|
|
41
|
+
|
|
39
42
|
return true;
|
|
40
43
|
}
|
|
41
44
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { IMultiChainBalance } from '@subwallet/extension-base/services/subscan-service/types';
|
|
2
|
+
export declare class SubscanService {
|
|
3
|
+
private limitRate;
|
|
4
|
+
private intervalCheck;
|
|
5
|
+
private maxRetry;
|
|
6
|
+
private requestMap;
|
|
7
|
+
private nextId;
|
|
8
|
+
private isRunning;
|
|
9
|
+
private getId;
|
|
10
|
+
constructor(options?: {
|
|
11
|
+
limitRate?: number;
|
|
12
|
+
intervalCheck?: number;
|
|
13
|
+
maxRetry?: number;
|
|
14
|
+
});
|
|
15
|
+
private getApiUrl;
|
|
16
|
+
private postRequest;
|
|
17
|
+
private addRequest;
|
|
18
|
+
private process;
|
|
19
|
+
getMultiChainBalance(address: string): Promise<IMultiChainBalance[]>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-base
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { SWError } from '@subwallet/extension-base/background/errors/SWError';
|
|
5
|
+
import SUBSCAN_CHAIN_MAP from '@subwallet/extension-base/services/subscan-service/subscan-chain-map';
|
|
6
|
+
import fetch from 'cross-fetch';
|
|
7
|
+
export class SubscanService {
|
|
8
|
+
limitRate = 2; // limit per interval check
|
|
9
|
+
intervalCheck = 1000; // interval check in ms
|
|
10
|
+
maxRetry = 9; // interval check in ms
|
|
11
|
+
requestMap = {};
|
|
12
|
+
nextId = 0;
|
|
13
|
+
isRunning = false;
|
|
14
|
+
getId() {
|
|
15
|
+
return this.nextId++;
|
|
16
|
+
}
|
|
17
|
+
constructor(options) {
|
|
18
|
+
this.limitRate = (options === null || options === void 0 ? void 0 : options.limitRate) || this.limitRate;
|
|
19
|
+
this.intervalCheck = (options === null || options === void 0 ? void 0 : options.intervalCheck) || this.intervalCheck;
|
|
20
|
+
this.maxRetry = (options === null || options === void 0 ? void 0 : options.maxRetry) || this.maxRetry;
|
|
21
|
+
}
|
|
22
|
+
getApiUrl(chain, path) {
|
|
23
|
+
const subscanChain = SUBSCAN_CHAIN_MAP[chain];
|
|
24
|
+
if (!subscanChain) {
|
|
25
|
+
throw new SWError('NOT_SUPPORTED', 'Chain is not supported');
|
|
26
|
+
}
|
|
27
|
+
return `https://${chain}.api.subscan.io/${path}`;
|
|
28
|
+
}
|
|
29
|
+
postRequest(url, body) {
|
|
30
|
+
return fetch(url, {
|
|
31
|
+
method: 'POST',
|
|
32
|
+
headers: {
|
|
33
|
+
'Content-Type': 'application/json'
|
|
34
|
+
},
|
|
35
|
+
body: JSON.stringify(body)
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
addRequest(run) {
|
|
39
|
+
const newId = this.getId();
|
|
40
|
+
return new Promise((resolve, reject) => {
|
|
41
|
+
this.requestMap[newId] = {
|
|
42
|
+
id: newId,
|
|
43
|
+
status: 'pending',
|
|
44
|
+
retry: -1,
|
|
45
|
+
run,
|
|
46
|
+
resolve,
|
|
47
|
+
reject
|
|
48
|
+
};
|
|
49
|
+
if (!this.isRunning) {
|
|
50
|
+
this.process();
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
process() {
|
|
55
|
+
this.isRunning = true;
|
|
56
|
+
const maxRetry = this.maxRetry;
|
|
57
|
+
const interval = setInterval(() => {
|
|
58
|
+
const remainingRequests = Object.values(this.requestMap);
|
|
59
|
+
if (remainingRequests.length === 0) {
|
|
60
|
+
this.isRunning = false;
|
|
61
|
+
clearInterval(interval);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Get first this.limit requests base on id
|
|
66
|
+
const requests = remainingRequests.filter(request => request.status !== 'running').sort((a, b) => a.id - b.id).slice(0, this.limitRate);
|
|
67
|
+
|
|
68
|
+
// Start requests
|
|
69
|
+
requests.forEach(request => {
|
|
70
|
+
request.status = 'running';
|
|
71
|
+
request.run().then(rs => {
|
|
72
|
+
request.resolve(rs);
|
|
73
|
+
}).catch(e => {
|
|
74
|
+
if (request.retry < maxRetry) {
|
|
75
|
+
request.status = 'pending';
|
|
76
|
+
request.retry++;
|
|
77
|
+
} else {
|
|
78
|
+
// Reject request
|
|
79
|
+
request.reject(new SWError('MAX_RETRY', String(e)));
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
}, this.intervalCheck);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Implement Subscan API
|
|
87
|
+
getMultiChainBalance(address) {
|
|
88
|
+
return this.addRequest(async () => {
|
|
89
|
+
const rs = await this.postRequest(this.getApiUrl('polkadot', 'api/scan/multiChain/account'), {
|
|
90
|
+
address
|
|
91
|
+
});
|
|
92
|
+
if (rs.status !== 200) {
|
|
93
|
+
throw new SWError('SubscanService.getMultiChainBalance', await rs.text());
|
|
94
|
+
}
|
|
95
|
+
const jsonData = await rs.json();
|
|
96
|
+
return jsonData.data;
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-base
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
const SUBSCAN_CHAIN_MAP = {
|
|
5
|
+
polkadot: 'polkadot',
|
|
6
|
+
kusama: 'kusama',
|
|
7
|
+
moonbeam: 'moonbeam',
|
|
8
|
+
acala: 'acala',
|
|
9
|
+
astar: 'astar',
|
|
10
|
+
shiden: 'shiden',
|
|
11
|
+
shibuya: 'shibuya',
|
|
12
|
+
westend: 'westend',
|
|
13
|
+
moonbase: 'moonbase',
|
|
14
|
+
moonriver: 'moonriver',
|
|
15
|
+
turing: 'turing',
|
|
16
|
+
bifrost_testnet: 'bifrost-testnet',
|
|
17
|
+
calamari: 'calamari',
|
|
18
|
+
statemint: 'statemint',
|
|
19
|
+
pioneer: 'pioneer',
|
|
20
|
+
parallel: 'parallel',
|
|
21
|
+
clover: 'clover',
|
|
22
|
+
hydradx_main: 'hydradx',
|
|
23
|
+
edgeware: 'edgeware',
|
|
24
|
+
centrifuge: 'centrifuge',
|
|
25
|
+
interlay: 'interlay',
|
|
26
|
+
nodle: 'nodle',
|
|
27
|
+
darwinia: 'darwinia',
|
|
28
|
+
polkadex: 'polkadex',
|
|
29
|
+
aleph: 'alephzero',
|
|
30
|
+
dolphin: 'dolphin',
|
|
31
|
+
efinity: 'efinity',
|
|
32
|
+
composableFinance: 'composable',
|
|
33
|
+
phala: 'phala',
|
|
34
|
+
crust: 'crust',
|
|
35
|
+
statemine: 'statemine',
|
|
36
|
+
karura: 'karura',
|
|
37
|
+
khala: 'khala',
|
|
38
|
+
kilt: 'spiritnet',
|
|
39
|
+
basilisk: 'basilisk',
|
|
40
|
+
altair: 'altair',
|
|
41
|
+
heiko: 'parallel-heiko',
|
|
42
|
+
kintsugi: 'kintsugi',
|
|
43
|
+
picasso: 'picasso',
|
|
44
|
+
quartz: 'quartz',
|
|
45
|
+
unique_network: 'unique',
|
|
46
|
+
genshiro: 'genshiro',
|
|
47
|
+
zeitgeist: 'zeitgeist',
|
|
48
|
+
sakura: 'sakura',
|
|
49
|
+
shadow: 'shadow',
|
|
50
|
+
robonomics: 'robonomics',
|
|
51
|
+
integritee: 'integritee',
|
|
52
|
+
acala_testnet: 'acala-testnet',
|
|
53
|
+
mangatax: 'mangatax',
|
|
54
|
+
encointer: 'encointer',
|
|
55
|
+
subspace_gemini_2a: 'subspace',
|
|
56
|
+
origintrail: 'origintrail',
|
|
57
|
+
bajun: 'bajun',
|
|
58
|
+
snow: 'snow',
|
|
59
|
+
kilt_peregrine: 'kilt-testnet',
|
|
60
|
+
polymesh: 'polymesh'
|
|
61
|
+
};
|
|
62
|
+
export const SUBSCAN_CHAIN_MAP_REVERSE = Object.fromEntries(Object.entries(SUBSCAN_CHAIN_MAP).map(([k, v]) => [v, k]));
|
|
63
|
+
export default SUBSCAN_CHAIN_MAP;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface SubscanRequest<T> {
|
|
2
|
+
id: number;
|
|
3
|
+
retry: number;
|
|
4
|
+
status: 'pending' | 'running';
|
|
5
|
+
run: () => Promise<any>;
|
|
6
|
+
resolve: (value: any) => T;
|
|
7
|
+
reject: (error?: any) => void;
|
|
8
|
+
}
|
|
9
|
+
export interface SubscanResponse<T = any> {
|
|
10
|
+
code: number;
|
|
11
|
+
message: string;
|
|
12
|
+
data: T;
|
|
13
|
+
}
|
|
14
|
+
export interface IMultiChainBalance {
|
|
15
|
+
network: string;
|
|
16
|
+
symbol: string;
|
|
17
|
+
decimal: number;
|
|
18
|
+
price: string;
|
|
19
|
+
category: string;
|
|
20
|
+
balance: string;
|
|
21
|
+
locked: string;
|
|
22
|
+
reserved: string;
|
|
23
|
+
bonded: string;
|
|
24
|
+
unbonding: string;
|
|
25
|
+
democracy_lock: string;
|
|
26
|
+
election_lock: string;
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { _ChainAsset, _ChainInfo } from '@subwallet/chain-list/types';
|
|
2
2
|
import { TransactionHistoryItem } from '@subwallet/extension-base/background/KoniTypes';
|
|
3
3
|
import { EventRecord } from '@polkadot/types/interfaces';
|
|
4
|
-
export declare function parseXcmEventLogs(historyItem: TransactionHistoryItem
|
|
5
|
-
export declare function parseTransferEventLogs(historyItem: TransactionHistoryItem
|
|
4
|
+
export declare function parseXcmEventLogs(historyItem: Partial<TransactionHistoryItem>, eventLogs: EventRecord[], chain: string, sendingTokenInfo: _ChainAsset, chainInfo: _ChainInfo): void;
|
|
5
|
+
export declare function parseTransferEventLogs(historyItem: Partial<TransactionHistoryItem>, eventLogs: EventRecord[], chain: string, sendingTokenInfo: _ChainAsset, chainInfo: _ChainInfo): void;
|
|
@@ -1,45 +1,30 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { _getAssetDecimals, _getChainNativeTokenBasicInfo
|
|
4
|
+
import { _getAssetDecimals, _getChainNativeTokenBasicInfo } from '@subwallet/extension-base/services/chain-service/utils';
|
|
5
5
|
export function parseXcmEventLogs(historyItem, eventLogs, chain, sendingTokenInfo, chainInfo) {
|
|
6
|
-
let isFeeUseMainTokenSymbol = true;
|
|
7
6
|
for (let index = 0; index < eventLogs.length; index++) {
|
|
8
7
|
const record = eventLogs[index];
|
|
9
|
-
if (['karura', 'acala', 'acala_testnet'].includes(chain) && sendingTokenInfo && !_isNativeToken(sendingTokenInfo)) {
|
|
10
|
-
if (record.event.section === 'currencies' && record.event.method.toLowerCase() === 'transferred') {
|
|
11
|
-
if (index === 0) {
|
|
12
|
-
var _record$event$data$;
|
|
13
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
14
|
-
historyItem.fee = {
|
|
15
|
-
value: ((_record$event$data$ = record.event.data[3]) === null || _record$event$data$ === void 0 ? void 0 : _record$event$data$.toString()) || '0',
|
|
16
|
-
symbol: sendingTokenInfo.symbol,
|
|
17
|
-
decimals: _getAssetDecimals(sendingTokenInfo)
|
|
18
|
-
};
|
|
19
|
-
isFeeUseMainTokenSymbol = false;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
8
|
const {
|
|
24
9
|
decimals: nativeDecimals,
|
|
25
10
|
symbol: nativeSymbol
|
|
26
11
|
} = _getChainNativeTokenBasicInfo(chainInfo);
|
|
27
|
-
if (
|
|
28
|
-
var _record$event$data
|
|
29
|
-
if ((_record$event$data$
|
|
30
|
-
var _record$event$data$
|
|
12
|
+
if (record.event.section === 'balances' && record.event.method.toLowerCase() === 'withdraw') {
|
|
13
|
+
var _record$event$data$;
|
|
14
|
+
if ((_record$event$data$ = record.event.data[1]) !== null && _record$event$data$ !== void 0 && _record$event$data$.toString()) {
|
|
15
|
+
var _record$event$data$2;
|
|
31
16
|
historyItem.fee = {
|
|
32
|
-
value: (_record$event$data$
|
|
17
|
+
value: (_record$event$data$2 = record.event.data[1]) === null || _record$event$data$2 === void 0 ? void 0 : _record$event$data$2.toString(),
|
|
33
18
|
symbol: nativeSymbol,
|
|
34
19
|
decimals: nativeDecimals
|
|
35
20
|
};
|
|
36
21
|
}
|
|
37
|
-
} else if (
|
|
38
|
-
var _record$event$data$
|
|
39
|
-
if ((_record$event$data$
|
|
40
|
-
var _record$event$data$
|
|
22
|
+
} else if (record.event.section === 'tokens' && record.event.method.toLowerCase() === 'withdrawn') {
|
|
23
|
+
var _record$event$data$3;
|
|
24
|
+
if (!historyItem.fee && (_record$event$data$3 = record.event.data[2]) !== null && _record$event$data$3 !== void 0 && _record$event$data$3.toString()) {
|
|
25
|
+
var _record$event$data$4;
|
|
41
26
|
historyItem.fee = {
|
|
42
|
-
value: (_record$event$data$
|
|
27
|
+
value: (_record$event$data$4 = record.event.data[2]) === null || _record$event$data$4 === void 0 ? void 0 : _record$event$data$4.toString(),
|
|
43
28
|
symbol: nativeSymbol,
|
|
44
29
|
decimals: nativeDecimals
|
|
45
30
|
};
|
|
@@ -48,28 +33,15 @@ export function parseXcmEventLogs(historyItem, eventLogs, chain, sendingTokenInf
|
|
|
48
33
|
}
|
|
49
34
|
}
|
|
50
35
|
export function parseTransferEventLogs(historyItem, eventLogs, chain, sendingTokenInfo, chainInfo) {
|
|
51
|
-
let isFeeUseMainTokenSymbol = true;
|
|
52
36
|
for (let index = 0; index < eventLogs.length; index++) {
|
|
53
37
|
const record = eventLogs[index];
|
|
54
|
-
if (['
|
|
55
|
-
if (record.event.section === 'currencies' && record.event.method.toLowerCase() === 'transferred') {
|
|
56
|
-
if (index === 0) {
|
|
57
|
-
var _record$event$data$6;
|
|
58
|
-
historyItem.fee = {
|
|
59
|
-
value: ((_record$event$data$6 = record.event.data[3]) === null || _record$event$data$6 === void 0 ? void 0 : _record$event$data$6.toString()) || '0',
|
|
60
|
-
symbol: sendingTokenInfo.symbol,
|
|
61
|
-
decimals: _getAssetDecimals(sendingTokenInfo)
|
|
62
|
-
};
|
|
63
|
-
isFeeUseMainTokenSymbol = false;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
} else if (['genshiro_testnet', 'genshiro', 'equilibrium_parachain'].includes(chain) && sendingTokenInfo) {
|
|
38
|
+
if (['genshiro_testnet', 'genshiro', 'equilibrium_parachain'].includes(chain) && sendingTokenInfo) {
|
|
67
39
|
if (record.event.section === 'transactionPayment' && record.event.method.toLowerCase() === 'transactionfeepaid') {
|
|
68
|
-
var _record$event$data$
|
|
69
|
-
if ((_record$event$data$
|
|
70
|
-
var _record$event$data$
|
|
40
|
+
var _record$event$data$5;
|
|
41
|
+
if ((_record$event$data$5 = record.event.data[1]) !== null && _record$event$data$5 !== void 0 && _record$event$data$5.toString()) {
|
|
42
|
+
var _record$event$data$6;
|
|
71
43
|
historyItem.fee = {
|
|
72
|
-
value: ((_record$event$data$
|
|
44
|
+
value: ((_record$event$data$6 = record.event.data[1]) === null || _record$event$data$6 === void 0 ? void 0 : _record$event$data$6.toString()) || '0',
|
|
73
45
|
symbol: sendingTokenInfo.symbol,
|
|
74
46
|
decimals: _getAssetDecimals(sendingTokenInfo)
|
|
75
47
|
};
|
|
@@ -80,13 +52,13 @@ export function parseTransferEventLogs(historyItem, eventLogs, chain, sendingTok
|
|
|
80
52
|
decimals: nativeDecimals,
|
|
81
53
|
symbol: nativeSymbol
|
|
82
54
|
} = _getChainNativeTokenBasicInfo(chainInfo);
|
|
83
|
-
if (
|
|
84
|
-
var _record$event$data$
|
|
85
|
-
if ((_record$event$data$
|
|
86
|
-
var _record$event$data$
|
|
55
|
+
if (record.event.section === 'balances' && record.event.method.toLowerCase() === 'withdraw') {
|
|
56
|
+
var _record$event$data$7;
|
|
57
|
+
if ((_record$event$data$7 = record.event.data[1]) !== null && _record$event$data$7 !== void 0 && _record$event$data$7.toString()) {
|
|
58
|
+
var _record$event$data$8;
|
|
87
59
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
88
60
|
historyItem.fee = {
|
|
89
|
-
value: ((_record$event$data$
|
|
61
|
+
value: ((_record$event$data$8 = record.event.data[1]) === null || _record$event$data$8 === void 0 ? void 0 : _record$event$data$8.toString()) || '0',
|
|
90
62
|
symbol: nativeSymbol,
|
|
91
63
|
decimals: nativeDecimals
|
|
92
64
|
};
|