@subwallet/extension-base 1.0.2-1b → 1.0.2-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/background/KoniTypes.d.ts +34 -16
- package/background/KoniTypes.js +7 -6
- package/background/errors/TransactionError.js +1 -21
- package/cjs/background/KoniTypes.js +7 -6
- package/cjs/background/errors/TransactionError.js +0 -20
- package/cjs/constants/index.js +26 -8
- package/cjs/koni/api/dotsama/balance.js +224 -49
- package/cjs/koni/api/dotsama/transfer.js +29 -30
- package/cjs/koni/api/nft/acala_nft/index.js +1 -4
- package/cjs/koni/api/nft/bit.country/index.js +1 -4
- package/cjs/koni/api/nft/evm_nft/index.js +3 -7
- package/cjs/koni/api/nft/index.js +6 -3
- package/cjs/koni/api/nft/karura_nft/index.js +1 -4
- package/cjs/koni/api/nft/rmrk_nft/index.js +1 -8
- package/cjs/koni/api/nft/statemine_nft/index.js +1 -4
- package/cjs/koni/api/nft/unique_nft/index.js +1 -6
- package/cjs/koni/api/nft/wasm_nft/index.js +111 -169
- package/cjs/koni/api/nft/wasm_nft/utils.js +7 -11
- package/cjs/koni/api/staking/bonding/amplitude.js +9 -13
- package/cjs/koni/api/staking/bonding/astar.js +13 -15
- package/cjs/koni/api/staking/bonding/index.js +10 -22
- package/cjs/koni/api/staking/bonding/paraChain.js +2 -85
- package/cjs/koni/api/staking/bonding/relayChain.js +16 -119
- package/cjs/koni/api/staking/bonding/utils.js +8 -27
- package/cjs/koni/api/tokens/wasm/index.js +4 -5
- package/cjs/koni/api/xcm/polkadotXcm.js +1 -1
- package/cjs/koni/api/xcm/utils.js +13 -18
- package/cjs/koni/api/xcm/xTokens.js +1 -1
- package/cjs/koni/api/xcm/xcmPallet.js +6 -9
- package/cjs/koni/background/cron.js +47 -150
- package/cjs/koni/background/handlers/Extension.js +64 -106
- package/cjs/koni/background/handlers/State.js +21 -19
- package/cjs/koni/background/handlers/Tabs.js +1 -8
- package/cjs/koni/background/subscription.js +29 -32
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/chain-service/handler/SubstrateChainHandler.js +8 -13
- package/cjs/services/chain-service/handler/light-client/index.js +0 -2
- package/cjs/services/chain-service/index.js +7 -6
- package/cjs/services/event-service/index.js +1 -5
- package/cjs/services/event-service/types.js +1 -11
- package/cjs/services/history-service/index.js +10 -16
- package/cjs/services/history-service/subsquid-multi-chain-history.js +9 -12
- package/cjs/services/price-service/coingecko.js +1 -0
- package/cjs/services/price-service/index.js +3 -2
- package/cjs/services/request-service/handler/AuthRequestHandler.js +2 -6
- package/cjs/services/storage-service/DatabaseService.js +33 -52
- package/cjs/services/storage-service/db-stores/Nft.js +17 -4
- package/cjs/services/transaction-service/event-parser/index.js +48 -20
- package/cjs/services/transaction-service/index.js +14 -23
- package/cjs/utils/index.js +14 -7
- package/constants/index.d.ts +13 -7
- package/constants/index.js +13 -7
- package/koni/api/dotsama/balance.d.ts +1 -0
- package/koni/api/dotsama/balance.js +197 -22
- package/koni/api/dotsama/transfer.js +4 -5
- package/koni/api/nft/acala_nft/index.js +1 -3
- package/koni/api/nft/bit.country/index.js +1 -3
- package/koni/api/nft/evm_nft/index.js +3 -6
- package/koni/api/nft/index.d.ts +2 -1
- package/koni/api/nft/index.js +6 -3
- package/koni/api/nft/karura_nft/index.js +1 -3
- package/koni/api/nft/nft.d.ts +0 -1
- package/koni/api/nft/rmrk_nft/index.js +1 -8
- package/koni/api/nft/statemine_nft/index.js +1 -3
- package/koni/api/nft/unique_nft/index.js +1 -5
- package/koni/api/nft/wasm_nft/index.d.ts +2 -0
- package/koni/api/nft/wasm_nft/index.js +109 -167
- package/koni/api/nft/wasm_nft/utils.d.ts +5 -7
- package/koni/api/nft/wasm_nft/utils.js +5 -7
- package/koni/api/staking/bonding/amplitude.d.ts +1 -0
- package/koni/api/staking/bonding/amplitude.js +10 -15
- package/koni/api/staking/bonding/astar.js +6 -8
- package/koni/api/staking/bonding/index.d.ts +1 -4
- package/koni/api/staking/bonding/index.js +13 -23
- package/koni/api/staking/bonding/paraChain.d.ts +0 -3
- package/koni/api/staking/bonding/paraChain.js +5 -86
- package/koni/api/staking/bonding/relayChain.d.ts +1 -5
- package/koni/api/staking/bonding/relayChain.js +18 -118
- package/koni/api/staking/bonding/utils.d.ts +2 -3
- package/koni/api/staking/bonding/utils.js +9 -27
- package/koni/api/tokens/wasm/index.js +4 -5
- package/koni/api/xcm/polkadotXcm.js +2 -2
- package/koni/api/xcm/utils.d.ts +6 -5
- package/koni/api/xcm/utils.js +10 -15
- package/koni/api/xcm/xTokens.js +2 -2
- package/koni/api/xcm/xcmPallet.js +9 -10
- package/koni/background/cron.d.ts +1 -6
- package/koni/background/cron.js +48 -151
- package/koni/background/handlers/Extension.d.ts +2 -2
- package/koni/background/handlers/Extension.js +67 -108
- package/koni/background/handlers/State.d.ts +6 -5
- package/koni/background/handlers/State.js +21 -19
- package/koni/background/handlers/Tabs.js +1 -8
- package/koni/background/subscription.js +30 -31
- package/package.json +8 -13
- package/packageInfo.js +1 -1
- package/services/chain-service/handler/SubstrateChainHandler.js +9 -14
- package/services/chain-service/handler/light-client/index.d.ts +1 -17
- package/services/chain-service/handler/light-client/index.js +1 -1
- package/services/chain-service/helper/psp22_abi.json +881 -1041
- package/services/chain-service/helper/psp34_abi.json +1808 -2964
- package/services/chain-service/index.js +7 -6
- package/services/event-service/index.js +1 -5
- package/services/event-service/types.d.ts +9 -5
- package/services/event-service/types.js +1 -4
- package/services/history-service/index.d.ts +1 -1
- package/services/history-service/index.js +10 -16
- package/services/history-service/subsquid-multi-chain-history.js +11 -15
- package/services/price-service/coingecko.js +1 -0
- package/services/price-service/index.js +3 -2
- package/services/request-service/handler/AuthRequestHandler.js +2 -6
- package/services/storage-service/DatabaseService.d.ts +0 -1
- package/services/storage-service/DatabaseService.js +33 -52
- package/services/storage-service/db-stores/Nft.d.ts +2 -1
- package/services/storage-service/db-stores/Nft.js +16 -4
- package/services/transaction-service/event-parser/index.js +49 -21
- package/services/transaction-service/index.js +14 -23
- package/utils/index.d.ts +1 -1
- package/utils/index.js +12 -6
- package/cjs/koni/api/tokens/wasm/utils.js +0 -63
- package/koni/api/tokens/wasm/utils.d.ts +0 -6
- package/koni/api/tokens/wasm/utils.js +0 -54
package/cjs/utils/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
@@ -27,14 +28,15 @@ exports.isUrl = isUrl;
|
|
|
27
28
|
exports.isValidSubstrateAddress = exports.isValidProvider = void 0;
|
|
28
29
|
exports.mergeNetworkProviders = mergeNetworkProviders;
|
|
29
30
|
exports.parseIpfsLink = exports.notDef = exports.nonEmptyArr = void 0;
|
|
31
|
+
exports.parseNumberToDisplay = parseNumberToDisplay;
|
|
30
32
|
exports.parseRawNumber = parseRawNumber;
|
|
31
33
|
exports.reformatAddress = reformatAddress;
|
|
32
34
|
exports.sumBN = sumBN;
|
|
33
35
|
exports.toUnit = void 0;
|
|
34
36
|
exports.utf16ToString = utf16ToString;
|
|
35
|
-
exports.waitTimeout = waitTimeout;
|
|
36
37
|
var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
37
38
|
var _constants = require("@subwallet/extension-base/constants");
|
|
39
|
+
var _bignumber = _interopRequireDefault(require("bignumber.js"));
|
|
38
40
|
var _util = require("@polkadot/util");
|
|
39
41
|
var _utilCrypto = require("@polkadot/util-crypto");
|
|
40
42
|
var _canDerive = require("./canDerive");
|
|
@@ -313,16 +315,21 @@ exports.filterAndSortingAccountByAuthType = filterAndSortingAccountByAuthType;
|
|
|
313
315
|
function parseRawNumber(value) {
|
|
314
316
|
return parseFloat(value.replaceAll(',', ''));
|
|
315
317
|
}
|
|
316
|
-
function
|
|
317
|
-
if (
|
|
318
|
-
return
|
|
318
|
+
function parseNumberToDisplay(amount, decimals) {
|
|
319
|
+
if (!decimals) {
|
|
320
|
+
return '0';
|
|
319
321
|
}
|
|
322
|
+
const parsedAmount = parseRawNumber(amount.toString());
|
|
323
|
+
const bigN = new _bignumber.default(parsedAmount / 10 ** decimals);
|
|
324
|
+
const roundedString = bigN.toFixed(9);
|
|
325
|
+
const formattedString = parseFloat(roundedString); // remove excess zeros at the end
|
|
326
|
+
|
|
327
|
+
return formattedString.toString();
|
|
328
|
+
}
|
|
329
|
+
function isSameAddress(address1, address2) {
|
|
320
330
|
return reformatAddress(address1, 0) === reformatAddress(address2, 0); // TODO: maybe there's a better way
|
|
321
331
|
}
|
|
322
332
|
|
|
323
333
|
function getDomainFromUrl(url) {
|
|
324
334
|
return url.replace(/^(https?:\/\/)?(www\.)?/, '').split('/')[0];
|
|
325
|
-
}
|
|
326
|
-
async function waitTimeout(ms) {
|
|
327
|
-
return new Promise(resolve => setTimeout(resolve, ms));
|
|
328
335
|
}
|
package/constants/index.d.ts
CHANGED
|
@@ -1,16 +1,22 @@
|
|
|
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;
|
|
2
5
|
export declare const CRON_AUTO_RECOVER_DOTSAMA_INTERVAL = 60000;
|
|
3
6
|
export declare const CRON_AUTO_RECOVER_WEB3_INTERVAL = 90000;
|
|
4
7
|
export declare const ACALA_REFRESH_CROWDLOAN_INTERVAL = 300000;
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const
|
|
8
|
+
export declare const ACALA_REFRESH_BALANCE_INTERVAL = 30000;
|
|
9
|
+
export declare const ASTAR_REFRESH_BALANCE_INTERVAL = 30000;
|
|
10
|
+
export declare const SUB_TOKEN_REFRESH_BALANCE_INTERVAL = 30000;
|
|
11
|
+
export declare const SUBSCRIBE_BALANCE_FAST_INTERVAL = 9000;
|
|
12
|
+
export declare const CRON_REFRESH_NFT_INTERVAL = 900000;
|
|
8
13
|
export declare const CRON_REFRESH_STAKING_REWARD_INTERVAL = 900000;
|
|
9
|
-
export declare const CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL =
|
|
10
|
-
export declare const CRON_REFRESH_HISTORY_INTERVAL =
|
|
11
|
-
export declare const CRON_GET_API_MAP_STATUS =
|
|
14
|
+
export declare const CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL = 10000;
|
|
15
|
+
export declare const CRON_REFRESH_HISTORY_INTERVAL = 90000;
|
|
16
|
+
export declare const CRON_GET_API_MAP_STATUS = 5000;
|
|
17
|
+
export declare const CRON_REFRESH_STAKING_DATA = 30000;
|
|
12
18
|
export declare const CRON_REFRESH_CHAIN_STAKING_METADATA = 900000;
|
|
13
|
-
export declare const CRON_REFRESH_CHAIN_NOMINATOR_METADATA =
|
|
19
|
+
export declare const CRON_REFRESH_CHAIN_NOMINATOR_METADATA = 900000;
|
|
14
20
|
export declare const ALL_ACCOUNT_KEY = "ALL";
|
|
15
21
|
export declare const ALL_NETWORK_KEY = "all";
|
|
16
22
|
export declare const ALL_GENESIS_HASH: null;
|
package/constants/index.js
CHANGED
|
@@ -2,18 +2,24 @@
|
|
|
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;
|
|
5
8
|
export const CRON_AUTO_RECOVER_DOTSAMA_INTERVAL = 60000;
|
|
6
9
|
export const CRON_AUTO_RECOVER_WEB3_INTERVAL = 90000;
|
|
7
10
|
export const ACALA_REFRESH_CROWDLOAN_INTERVAL = 300000;
|
|
8
|
-
export const
|
|
9
|
-
export const
|
|
10
|
-
export const
|
|
11
|
+
export const ACALA_REFRESH_BALANCE_INTERVAL = 30000;
|
|
12
|
+
export const ASTAR_REFRESH_BALANCE_INTERVAL = 30000;
|
|
13
|
+
export const SUB_TOKEN_REFRESH_BALANCE_INTERVAL = 30000;
|
|
14
|
+
export const SUBSCRIBE_BALANCE_FAST_INTERVAL = 9000;
|
|
15
|
+
export const CRON_REFRESH_NFT_INTERVAL = 900000;
|
|
11
16
|
export const CRON_REFRESH_STAKING_REWARD_INTERVAL = 900000;
|
|
12
|
-
export const CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL =
|
|
13
|
-
export const CRON_REFRESH_HISTORY_INTERVAL =
|
|
14
|
-
export const CRON_GET_API_MAP_STATUS =
|
|
17
|
+
export const CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL = 10000;
|
|
18
|
+
export const CRON_REFRESH_HISTORY_INTERVAL = 90000;
|
|
19
|
+
export const CRON_GET_API_MAP_STATUS = 5000;
|
|
20
|
+
export const CRON_REFRESH_STAKING_DATA = 30000;
|
|
15
21
|
export const CRON_REFRESH_CHAIN_STAKING_METADATA = 900000;
|
|
16
|
-
export const CRON_REFRESH_CHAIN_NOMINATOR_METADATA =
|
|
22
|
+
export const CRON_REFRESH_CHAIN_NOMINATOR_METADATA = 900000;
|
|
17
23
|
export const ALL_ACCOUNT_KEY = 'ALL';
|
|
18
24
|
export const ALL_NETWORK_KEY = 'all';
|
|
19
25
|
export const ALL_GENESIS_HASH = null;
|
|
@@ -4,3 +4,4 @@ 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>;
|
|
@@ -7,12 +7,12 @@ import { ASTAR_REFRESH_BALANCE_INTERVAL, SUB_TOKEN_REFRESH_BALANCE_INTERVAL } fr
|
|
|
7
7
|
import { getEVMBalance } from '@subwallet/extension-base/koni/api/tokens/evm/balance';
|
|
8
8
|
import { getERC20Contract } from '@subwallet/extension-base/koni/api/tokens/evm/web3';
|
|
9
9
|
import { getPSP22ContractPromise } from '@subwallet/extension-base/koni/api/tokens/wasm';
|
|
10
|
-
import { getDefaultWeightV2 } from '@subwallet/extension-base/koni/api/tokens/wasm/utils';
|
|
11
10
|
import { state } from '@subwallet/extension-base/koni/background/handlers';
|
|
12
|
-
import { _BALANCE_CHAIN_GROUP, _PURE_EVM_CHAINS } from '@subwallet/extension-base/services/chain-service/constants';
|
|
13
|
-
import { _checkSmartContractSupportByChain, _getChainNativeTokenSlug, _getContractAddressOfToken, _getTokenOnChainAssetId, _getTokenOnChainInfo, _isChainEvmCompatible, _isPureEvmChain, _isSubstrateRelayChain } from '@subwallet/extension-base/services/chain-service/utils';
|
|
11
|
+
import { _BALANCE_CHAIN_GROUP, _BALANCE_TOKEN_GROUP, _PURE_EVM_CHAINS } from '@subwallet/extension-base/services/chain-service/constants';
|
|
12
|
+
import { _checkSmartContractSupportByChain, _getChainNativeTokenSlug, _getContractAddressOfToken, _getTokenOnChainAssetId, _getTokenOnChainInfo, _isChainEvmCompatible, _isNativeToken, _isPureEvmChain, _isSmartContractToken, _isSubstrateRelayChain } from '@subwallet/extension-base/services/chain-service/utils';
|
|
14
13
|
import { categoryAddresses, sumBN } from '@subwallet/extension-base/utils';
|
|
15
14
|
import { BN, BN_ZERO } from '@polkadot/util';
|
|
15
|
+
import { isEthereumAddress } from '@polkadot/util-crypto';
|
|
16
16
|
// main subscription
|
|
17
17
|
export function subscribeBalance(addresses, chainInfoMap, substrateApiMap, evmApiMap, callback) {
|
|
18
18
|
const [substrateAddresses, evmAddresses] = categoryAddresses(addresses);
|
|
@@ -95,16 +95,11 @@ async function subscribeWithSystemAccountPallet(addresses, chainInfo, networkAPI
|
|
|
95
95
|
let pooledStakingBalance = BN_ZERO;
|
|
96
96
|
if (_isSubstrateRelayChain(chainInfo) && networkAPI.query.nominationPools) {
|
|
97
97
|
const poolMemberDatas = await networkAPI.query.nominationPools.poolMembers.multi(addresses);
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
pooledStakingBalance = pooledStakingBalance.add(pooledBalance);
|
|
104
|
-
Object.entries(poolMemberData.unbondingEras).forEach(([, amount]) => {
|
|
105
|
-
pooledStakingBalance = pooledStakingBalance.add(new BN(amount));
|
|
106
|
-
});
|
|
107
|
-
}
|
|
98
|
+
for (const _poolMemberData of poolMemberDatas) {
|
|
99
|
+
const poolMemberData = _poolMemberData.toPrimitive();
|
|
100
|
+
if (poolMemberData) {
|
|
101
|
+
const pooledBalance = new BN(poolMemberData.points.toString());
|
|
102
|
+
pooledStakingBalance = pooledStakingBalance.add(pooledBalance);
|
|
108
103
|
}
|
|
109
104
|
}
|
|
110
105
|
}
|
|
@@ -125,7 +120,7 @@ async function subscribeWithSystemAccountPallet(addresses, chainInfo, networkAPI
|
|
|
125
120
|
const free = total.sub(locked);
|
|
126
121
|
callBack({
|
|
127
122
|
tokenSlug: chainNativeTokenSlug,
|
|
128
|
-
free: free.
|
|
123
|
+
free: free.toString(),
|
|
129
124
|
locked: locked.toString(),
|
|
130
125
|
state: APIItemState.READY,
|
|
131
126
|
substrateInfo: {
|
|
@@ -139,6 +134,79 @@ async function subscribeWithSystemAccountPallet(addresses, chainInfo, networkAPI
|
|
|
139
134
|
unsub();
|
|
140
135
|
};
|
|
141
136
|
}
|
|
137
|
+
|
|
138
|
+
// deprecated
|
|
139
|
+
// function subscribeDarwiniaBalance (addresses: string[], chainInfo: _ChainInfo, chain: string, networkAPI: ApiPromise, callBack: (rs: BalanceItem) => void) {
|
|
140
|
+
// const tokenMap = state.getAssetByChainAndAsset(chain, [_AssetType.LOCAL]);
|
|
141
|
+
// const nativeTokenSlug = _getChainNativeTokenSlug(chainInfo);
|
|
142
|
+
//
|
|
143
|
+
// let totalBalance: BN = new BN(0);
|
|
144
|
+
// let freeBalance: BN = new BN(0);
|
|
145
|
+
// let miscFrozen: BN = new BN(0);
|
|
146
|
+
// let reservedKtonBalance: BN = new BN(0);
|
|
147
|
+
// let totalKtonBalance: BN = new BN(0);
|
|
148
|
+
//
|
|
149
|
+
// const unsubProms = addresses.map((address) => {
|
|
150
|
+
// return networkAPI.derive.balances?.all(address, async (balance: DeriveBalancesAll) => {
|
|
151
|
+
// // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
152
|
+
// freeBalance = freeBalance.add(balance.availableBalance?.toBn() || new BN(0));
|
|
153
|
+
// miscFrozen = miscFrozen.add(balance.lockedBalance?.toBn() || new BN(0));
|
|
154
|
+
// totalBalance = totalBalance.add(balance.freeBalance?.toBn() || new BN(0));
|
|
155
|
+
//
|
|
156
|
+
// const _systemBalance = await networkAPI.query.system.account(address);
|
|
157
|
+
// const systemBalance = _systemBalance.toHuman() as unknown as AccountInfo;
|
|
158
|
+
//
|
|
159
|
+
// // @ts-ignore
|
|
160
|
+
// const rawTotalKton = (systemBalance.data?.freeKton as string).replaceAll(',', '');
|
|
161
|
+
// // @ts-ignore
|
|
162
|
+
// const rawReservedKton = (systemBalance.data?.reservedKton as string).replaceAll(',', '');
|
|
163
|
+
//
|
|
164
|
+
// // @ts-ignore
|
|
165
|
+
// // eslint-disable-next-line @typescript-eslint/no-unsafe-argument,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
|
|
166
|
+
// totalKtonBalance = totalKtonBalance.add(new BN(rawTotalKton) || new BN(0));
|
|
167
|
+
// // @ts-ignore
|
|
168
|
+
// // eslint-disable-next-line @typescript-eslint/no-unsafe-argument,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
|
|
169
|
+
// reservedKtonBalance = reservedKtonBalance.add(new BN(rawReservedKton) || new BN(0));
|
|
170
|
+
//
|
|
171
|
+
// if (Object.keys(tokenMap).length > 1) {
|
|
172
|
+
// for (const tokenInfo of Object.values(tokenMap)) {
|
|
173
|
+
// if (_BALANCE_TOKEN_GROUP.crab.includes(tokenInfo.symbol)) {
|
|
174
|
+
// const freeKton = totalKtonBalance.sub(reservedKtonBalance);
|
|
175
|
+
//
|
|
176
|
+
// callBack({
|
|
177
|
+
// free: freeKton.toString(),
|
|
178
|
+
// locked: reservedKtonBalance.toString(),
|
|
179
|
+
// state: APIItemState.READY,
|
|
180
|
+
// tokenSlug: tokenInfo.slug
|
|
181
|
+
// });
|
|
182
|
+
// break;
|
|
183
|
+
// }
|
|
184
|
+
// }
|
|
185
|
+
// }
|
|
186
|
+
//
|
|
187
|
+
// const free = totalBalance.sub(miscFrozen);
|
|
188
|
+
//
|
|
189
|
+
// callBack({
|
|
190
|
+
// tokenSlug: nativeTokenSlug,
|
|
191
|
+
// free: free.toString(),
|
|
192
|
+
// locked: miscFrozen.toString(),
|
|
193
|
+
// state: APIItemState.READY,
|
|
194
|
+
// substrateInfo: {
|
|
195
|
+
// miscFrozen: miscFrozen.toString()
|
|
196
|
+
// }
|
|
197
|
+
// });
|
|
198
|
+
// });
|
|
199
|
+
// });
|
|
200
|
+
//
|
|
201
|
+
// return () => {
|
|
202
|
+
// Promise.all(unsubProms).then((unsubs) => {
|
|
203
|
+
// unsubs.forEach((unsub) => {
|
|
204
|
+
// unsub && unsub();
|
|
205
|
+
// });
|
|
206
|
+
// }).catch(console.error);
|
|
207
|
+
// };
|
|
208
|
+
// }
|
|
209
|
+
|
|
142
210
|
function subscribeERC20Interval(addresses, chain, evmApiMap, callBack) {
|
|
143
211
|
let tokenList = {};
|
|
144
212
|
const erc20ContractMap = {};
|
|
@@ -182,12 +250,10 @@ function subscribePSP22Balance(addresses, chain, api, callBack) {
|
|
|
182
250
|
try {
|
|
183
251
|
const contract = psp22ContractMap[tokenInfo.slug];
|
|
184
252
|
const balances = await Promise.all(addresses.map(async address => {
|
|
185
|
-
var _balanceOf$output;
|
|
186
253
|
const _balanceOf = await contract.query['psp22::balanceOf'](address, {
|
|
187
|
-
gasLimit:
|
|
254
|
+
gasLimit: -1
|
|
188
255
|
}, address);
|
|
189
|
-
|
|
190
|
-
return _balanceOf.output ? balanceObj.ok || balanceObj.Ok : '0';
|
|
256
|
+
return _balanceOf.output ? _balanceOf.output.toString() : '0';
|
|
191
257
|
}));
|
|
192
258
|
free = sumBN(balances.map(bal => new BN(bal || 0)));
|
|
193
259
|
callBack({
|
|
@@ -197,11 +263,10 @@ function subscribePSP22Balance(addresses, chain, api, callBack) {
|
|
|
197
263
|
state: APIItemState.READY
|
|
198
264
|
});
|
|
199
265
|
} catch (err) {
|
|
200
|
-
console.
|
|
266
|
+
console.log('There is a problem fetching ' + tokenInfo.slug + ' PSP-22 token balance', err);
|
|
201
267
|
}
|
|
202
268
|
});
|
|
203
269
|
};
|
|
204
|
-
|
|
205
270
|
tokenList = state.getAssetByChainAndAsset(chain, [_AssetType.PSP22]);
|
|
206
271
|
Object.entries(tokenList).forEach(([slug, tokenInfo]) => {
|
|
207
272
|
psp22ContractMap[slug] = getPSP22ContractPromise(api, _getContractAddressOfToken(tokenInfo));
|
|
@@ -331,11 +396,11 @@ async function subscribeAssetsAccountPallet(addresses, chain, api, callBack) {
|
|
|
331
396
|
balances.forEach(b => {
|
|
332
397
|
// @ts-ignore
|
|
333
398
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-assignment
|
|
334
|
-
const bdata = b === null || b === void 0 ? void 0 : b.
|
|
399
|
+
const bdata = b === null || b === void 0 ? void 0 : b.toJSON();
|
|
335
400
|
if (bdata) {
|
|
336
401
|
// @ts-ignore
|
|
337
402
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-argument
|
|
338
|
-
const addressBalance = new BN(String(bdata === null || bdata === void 0 ? void 0 : bdata.balance)
|
|
403
|
+
const addressBalance = new BN(String(bdata === null || bdata === void 0 ? void 0 : bdata.balance) || '0');
|
|
339
404
|
|
|
340
405
|
// @ts-ignore
|
|
341
406
|
if (bdata !== null && bdata !== void 0 && bdata.isFrozen) {
|
|
@@ -389,4 +454,114 @@ export function subscribeEVMBalance(chain, addresses, evmApiMap, callback, token
|
|
|
389
454
|
clearInterval(interval);
|
|
390
455
|
unsub2 && unsub2();
|
|
391
456
|
};
|
|
457
|
+
}
|
|
458
|
+
export async function getFreeBalance(chain, address, substrateApiMap, evmApiMap, tokenSlug) {
|
|
459
|
+
const substrateApi = await substrateApiMap[chain].isReady;
|
|
460
|
+
const api = substrateApi.api;
|
|
461
|
+
const web3Api = evmApiMap[chain];
|
|
462
|
+
const tokenInfo = tokenSlug ? state.getAssetBySlug(tokenSlug) : state.getNativeTokenInfo(chain);
|
|
463
|
+
const chainInfo = state.getChainInfo(chain);
|
|
464
|
+
|
|
465
|
+
// Only EVM Address use with EVM network
|
|
466
|
+
if (Boolean(web3Api || _isChainEvmCompatible(chainInfo)) !== isEthereumAddress(address)) {
|
|
467
|
+
if (!isEthereumAddress(address)) {
|
|
468
|
+
return '0';
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
// web3Api support mean isEthereum Network support
|
|
473
|
+
if (web3Api) {
|
|
474
|
+
if (_isNativeToken(tokenInfo)) {
|
|
475
|
+
var _web3Api$api;
|
|
476
|
+
return (await ((_web3Api$api = web3Api.api) === null || _web3Api$api === void 0 ? void 0 : _web3Api$api.eth.getBalance(address))) || '0';
|
|
477
|
+
} else {
|
|
478
|
+
if (_getContractAddressOfToken(tokenInfo).length > 0) {
|
|
479
|
+
return '0';
|
|
480
|
+
}
|
|
481
|
+
const contract = getERC20Contract(chain, _getContractAddressOfToken(tokenInfo), evmApiMap);
|
|
482
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
|
|
483
|
+
const free = await contract.methods.balanceOf(address).call();
|
|
484
|
+
|
|
485
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-return
|
|
486
|
+
return (free === null || free === void 0 ? void 0 : free.toString()) || '0';
|
|
487
|
+
}
|
|
488
|
+
} else {
|
|
489
|
+
var _balance$availableBal, _balance$availableBal2;
|
|
490
|
+
if (tokenSlug) {
|
|
491
|
+
if (_isSmartContractToken(tokenInfo)) {
|
|
492
|
+
if (_getContractAddressOfToken(tokenInfo).length > 0) {
|
|
493
|
+
return '0';
|
|
494
|
+
}
|
|
495
|
+
const contractPromise = getPSP22ContractPromise(api, _getContractAddressOfToken(tokenInfo));
|
|
496
|
+
const balanceOf = await contractPromise.query['psp22::balanceOf'](address, {
|
|
497
|
+
gasLimit: -1
|
|
498
|
+
}, address);
|
|
499
|
+
return balanceOf.output ? balanceOf.output.toString() : '0';
|
|
500
|
+
} else if (_BALANCE_CHAIN_GROUP.genshiro.includes(chain)) {
|
|
501
|
+
var _balance$asPositive;
|
|
502
|
+
const onChainInfo = _getTokenOnChainInfo(tokenInfo);
|
|
503
|
+
const balance = await api.query.eqBalances.account(address, onChainInfo);
|
|
504
|
+
|
|
505
|
+
// @ts-ignore
|
|
506
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-return
|
|
507
|
+
return ((_balance$asPositive = balance.asPositive) === null || _balance$asPositive === void 0 ? void 0 : _balance$asPositive.toString()) || '0';
|
|
508
|
+
} else if (_BALANCE_CHAIN_GROUP.equilibrium_parachain.includes(chain)) {
|
|
509
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
510
|
+
const balance = await api.query.system.account(address);
|
|
511
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
|
|
512
|
+
const balancesData = JSON.parse(balance.data.toString());
|
|
513
|
+
const balanceList = balancesData.v0.balance;
|
|
514
|
+
let freeTokenBalance;
|
|
515
|
+
const assetId = _getTokenOnChainAssetId(tokenInfo);
|
|
516
|
+
if (!_isNativeToken(tokenInfo)) {
|
|
517
|
+
// @ts-ignore
|
|
518
|
+
freeTokenBalance = balanceList.find(data => data[0] === assetId);
|
|
519
|
+
} else {
|
|
520
|
+
freeTokenBalance = balanceList[0];
|
|
521
|
+
}
|
|
522
|
+
return freeTokenBalance ? freeTokenBalance[1].positive.toString() : '0';
|
|
523
|
+
} else if (_BALANCE_TOKEN_GROUP.crab.includes(tokenInfo.symbol)) {
|
|
524
|
+
var _balance$data5, _balance$data5$freeKt;
|
|
525
|
+
// @ts-ignore
|
|
526
|
+
const balance = await api.query.system.account(address);
|
|
527
|
+
return ((_balance$data5 = balance.data) === null || _balance$data5 === void 0 ? void 0 : (_balance$data5$freeKt = _balance$data5.freeKton) === null || _balance$data5$freeKt === void 0 ? void 0 : _balance$data5$freeKt.toString()) || '0';
|
|
528
|
+
} else if (!_isNativeToken(tokenInfo) && _BALANCE_CHAIN_GROUP.statemine.includes(chain)) {
|
|
529
|
+
var _balanceInfo$balance;
|
|
530
|
+
const assetId = _getTokenOnChainAssetId(tokenInfo);
|
|
531
|
+
const balanceInfo = (await api.query.assets.account(assetId, address)).toHuman();
|
|
532
|
+
|
|
533
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-return
|
|
534
|
+
return (balanceInfo === null || balanceInfo === void 0 ? void 0 : (_balanceInfo$balance = balanceInfo.balance) === null || _balanceInfo$balance === void 0 ? void 0 : _balanceInfo$balance.replaceAll(',', '')) || '0';
|
|
535
|
+
} else if (!_isNativeToken(tokenInfo) || _BALANCE_CHAIN_GROUP.kintsugi.includes(chain)) {
|
|
536
|
+
var _balance$free;
|
|
537
|
+
const onChainInfo = _getTokenOnChainInfo(tokenInfo);
|
|
538
|
+
// @ts-ignore
|
|
539
|
+
const balance = await api.query.tokens.accounts(address, onChainInfo);
|
|
540
|
+
return ((_balance$free = balance.free) === null || _balance$free === void 0 ? void 0 : _balance$free.toString()) || '0';
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
if (_BALANCE_CHAIN_GROUP.kusama.includes(chain)) {
|
|
544
|
+
var _balance$data6, _balance$data7;
|
|
545
|
+
// @ts-ignore
|
|
546
|
+
const _balance = await api.query.system.account(address);
|
|
547
|
+
|
|
548
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
|
|
549
|
+
const balance = _balance.toHuman();
|
|
550
|
+
|
|
551
|
+
// @ts-ignore
|
|
552
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
|
|
553
|
+
const freeBalance = new BN((_balance$data6 = balance.data) === null || _balance$data6 === void 0 ? void 0 : _balance$data6.free.replaceAll(',', ''));
|
|
554
|
+
|
|
555
|
+
// @ts-ignore
|
|
556
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
|
|
557
|
+
const miscFrozen = new BN((_balance$data7 = balance.data) === null || _balance$data7 === void 0 ? void 0 : _balance$data7.miscFrozen.replaceAll(',', ''));
|
|
558
|
+
const transferable = freeBalance.sub(miscFrozen);
|
|
559
|
+
|
|
560
|
+
// @ts-ignore
|
|
561
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-return
|
|
562
|
+
return transferable.toString() || '0';
|
|
563
|
+
}
|
|
564
|
+
const balance = await api.derive.balances.all(address);
|
|
565
|
+
return ((_balance$availableBal = balance.availableBalance) === null || _balance$availableBal === void 0 ? void 0 : (_balance$availableBal2 = _balance$availableBal.toBn()) === null || _balance$availableBal2 === void 0 ? void 0 : _balance$availableBal2.toString()) || '0';
|
|
566
|
+
}
|
|
392
567
|
}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { getPSP22ContractPromise } from '@subwallet/extension-base/koni/api/tokens/wasm';
|
|
5
|
-
import { getWasmContractGasLimit } from '@subwallet/extension-base/koni/api/tokens/wasm/utils';
|
|
6
5
|
import { _BALANCE_TOKEN_GROUP, _TRANSFER_CHAIN_GROUP, _TRANSFER_NOT_SUPPORTED_CHAINS } from '@subwallet/extension-base/services/chain-service/constants';
|
|
7
6
|
import { _getContractAddressOfToken, _getTokenOnChainAssetId, _getTokenOnChainInfo, _isChainEvmCompatible, _isNativeToken, _isTokenWasmSmartContract } from '@subwallet/extension-base/services/chain-service/utils';
|
|
8
7
|
import { BN } from '@polkadot/util';
|
|
@@ -105,10 +104,10 @@ export const createTransferExtrinsic = async ({
|
|
|
105
104
|
|
|
106
105
|
if (_isTokenWasmSmartContract(tokenInfo) && api.query.contracts) {
|
|
107
106
|
const contractPromise = getPSP22ContractPromise(api, _getContractAddressOfToken(tokenInfo));
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
107
|
+
const transferQuery = await contractPromise.query['psp22::transfer'](from, {
|
|
108
|
+
gasLimit: -1
|
|
109
|
+
}, to, value, {});
|
|
110
|
+
const gasLimit = transferQuery.gasRequired.toString();
|
|
112
111
|
transfer = contractPromise.tx['psp22::transfer']({
|
|
113
112
|
gasLimit
|
|
114
113
|
}, to, value, {});
|
|
@@ -110,10 +110,8 @@ export class AcalaNftApi extends BaseNftApi {
|
|
|
110
110
|
};
|
|
111
111
|
params.updateItem(this.chain, parsedNft, address);
|
|
112
112
|
params.updateCollection(this.chain, parsedCollection);
|
|
113
|
+
// params.updateReady(true);
|
|
113
114
|
}));
|
|
114
|
-
Object.entries(collectionNftIds).forEach(([collectionId, nftIds]) => {
|
|
115
|
-
params.cleanUpNfts(this.chain, address, collectionId, nftIds);
|
|
116
|
-
});
|
|
117
115
|
} catch (e) {
|
|
118
116
|
console.error('Failed to fetch acala nft', e);
|
|
119
117
|
}
|
|
@@ -107,10 +107,8 @@ export class BitCountryNftApi extends BaseNftApi {
|
|
|
107
107
|
};
|
|
108
108
|
params.updateItem(this.chain, parsedNft, address);
|
|
109
109
|
params.updateCollection(this.chain, parsedCollection);
|
|
110
|
+
// params.updateReady(true);
|
|
110
111
|
}));
|
|
111
|
-
Object.entries(collectionNftIds).forEach(([collectionId, nftIds]) => {
|
|
112
|
-
params.cleanUpNfts(this.chain, address, collectionId, nftIds);
|
|
113
|
-
});
|
|
114
112
|
} catch (e) {
|
|
115
113
|
console.error('Failed to fetch bit.country nft', e);
|
|
116
114
|
}
|
|
@@ -75,7 +75,6 @@ export class EvmNftApi extends BaseNftApi {
|
|
|
75
75
|
const contract = new this.evmApi.api.eth.Contract(_ERC721_ABI, smartContract);
|
|
76
76
|
let ownItem = false;
|
|
77
77
|
let collectionImage;
|
|
78
|
-
const nftOwnerMap = {};
|
|
79
78
|
await Promise.all(this.addresses.map(async address => {
|
|
80
79
|
if (!isEthereumAddress(address)) {
|
|
81
80
|
return;
|
|
@@ -126,9 +125,8 @@ export class EvmNftApi extends BaseNftApi {
|
|
|
126
125
|
}
|
|
127
126
|
}
|
|
128
127
|
}));
|
|
129
|
-
nftOwnerMap[address] = nftIds;
|
|
130
128
|
} catch (e) {
|
|
131
|
-
console.error('
|
|
129
|
+
console.error('evm nft error', e);
|
|
132
130
|
}
|
|
133
131
|
}));
|
|
134
132
|
if (ownItem) {
|
|
@@ -140,11 +138,10 @@ export class EvmNftApi extends BaseNftApi {
|
|
|
140
138
|
originAsset: tokenInfo.slug
|
|
141
139
|
};
|
|
142
140
|
nftParams.updateCollection(this.chain, nftCollection);
|
|
143
|
-
|
|
144
|
-
nftParams.cleanUpNfts(this.chain, owner, smartContract, nftIds);
|
|
145
|
-
});
|
|
141
|
+
// nftParams.updateReady(true);
|
|
146
142
|
}
|
|
147
143
|
}
|
|
144
|
+
|
|
148
145
|
async handleNfts(params) {
|
|
149
146
|
if (!this.evmContracts || this.evmContracts.length === 0) {
|
|
150
147
|
return;
|
package/koni/api/nft/index.d.ts
CHANGED
|
@@ -17,5 +17,6 @@ export declare class NftHandler {
|
|
|
17
17
|
setAddresses(addresses: string[]): void;
|
|
18
18
|
private setupNftContracts;
|
|
19
19
|
private setupApi;
|
|
20
|
-
handleNfts(nftContracts: _ChainAsset[], updateItem: (chain: string, data: NftItem, owner: string) => void, updateCollection: (chain: string, data: NftCollection) => void
|
|
20
|
+
handleNfts(nftContracts: _ChainAsset[], updateItem: (chain: string, data: NftItem, owner: string) => void, updateCollection: (chain: string, data: NftCollection) => void): Promise<void>;
|
|
21
|
+
parseAssetId(id: string): string;
|
|
21
22
|
}
|
package/koni/api/nft/index.js
CHANGED
|
@@ -124,15 +124,18 @@ export class NftHandler {
|
|
|
124
124
|
console.error('error setting up nft handlers', e);
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
|
-
async handleNfts(nftContracts, updateItem, updateCollection
|
|
127
|
+
async handleNfts(nftContracts, updateItem, updateCollection) {
|
|
128
128
|
this.setupApi();
|
|
129
129
|
this.setupNftContracts(nftContracts);
|
|
130
130
|
await Promise.all(this.handlers.map(async handler => {
|
|
131
131
|
await handler.fetchNfts({
|
|
132
132
|
updateItem,
|
|
133
|
-
updateCollection
|
|
134
|
-
cleanUpNfts
|
|
133
|
+
updateCollection
|
|
135
134
|
});
|
|
136
135
|
}));
|
|
137
136
|
}
|
|
137
|
+
parseAssetId(id) {
|
|
138
|
+
const numberId = parseInt(id);
|
|
139
|
+
return numberId.toString();
|
|
140
|
+
}
|
|
138
141
|
}
|
|
@@ -114,10 +114,8 @@ export class KaruraNftApi extends BaseNftApi {
|
|
|
114
114
|
};
|
|
115
115
|
params.updateItem(this.chain, parsedNft, address);
|
|
116
116
|
params.updateCollection(this.chain, parsedCollection);
|
|
117
|
+
// params.updateReady(true);
|
|
117
118
|
}));
|
|
118
|
-
Object.entries(collectionNftIds).forEach(([collectionId, nftIds]) => {
|
|
119
|
-
params.cleanUpNfts(this.chain, address, collectionId, nftIds);
|
|
120
|
-
});
|
|
121
119
|
} catch (e) {
|
|
122
120
|
console.error('Failed to fetch karura nft', e);
|
|
123
121
|
}
|
package/koni/api/nft/nft.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { _EvmApi, _SubstrateApi } from '@subwallet/extension-base/services/chain
|
|
|
3
3
|
export interface HandleNftParams {
|
|
4
4
|
updateItem: (chain: string, data: NftItem, owner: string) => void;
|
|
5
5
|
updateCollection: (chain: string, data: NftCollection) => void;
|
|
6
|
-
cleanUpNfts: (chain: string, owner: string, collectionId: string, nftIds: string[]) => void;
|
|
7
6
|
}
|
|
8
7
|
export declare abstract class BaseNftApi {
|
|
9
8
|
chain: string;
|
|
@@ -231,15 +231,8 @@ export class RmrkNftApi extends BaseNftApi {
|
|
|
231
231
|
image: allCollectionMeta[item.collectionId] ? this.parseUrl(allCollectionMeta[item.collectionId].image) : null,
|
|
232
232
|
chain: this.chain
|
|
233
233
|
};
|
|
234
|
-
const nftIds = [];
|
|
235
|
-
allNfts.forEach(nft => {
|
|
236
|
-
const nftCollectionId = nft === null || nft === void 0 ? void 0 : nft.collectionId;
|
|
237
|
-
if (nftCollectionId === item.collectionId) {
|
|
238
|
-
nftIds.push(nft === null || nft === void 0 ? void 0 : nft.id);
|
|
239
|
-
}
|
|
240
|
-
});
|
|
241
234
|
params.updateCollection(this.chain, parsedCollection);
|
|
242
|
-
params.
|
|
235
|
+
// params.updateReady(true);
|
|
243
236
|
});
|
|
244
237
|
} catch (e) {
|
|
245
238
|
console.error('Failed to fetch rmrk nft', e);
|
|
@@ -115,10 +115,8 @@ export default class StatemineNftApi extends BaseNftApi {
|
|
|
115
115
|
image: collectionMeta && collectionMeta.image ? this.parseUrl(collectionMeta === null || collectionMeta === void 0 ? void 0 : collectionMeta.image) : undefined
|
|
116
116
|
};
|
|
117
117
|
params.updateCollection(this.chain, parsedCollection);
|
|
118
|
+
// params.updateReady(true);
|
|
118
119
|
}));
|
|
119
|
-
Object.entries(collectionNftIds).forEach(([collectionId, nftIds]) => {
|
|
120
|
-
params.cleanUpNfts(this.chain, address, collectionId, nftIds);
|
|
121
|
-
});
|
|
122
120
|
} catch (e) {
|
|
123
121
|
console.error('Failed to fetch statemine nft', e);
|
|
124
122
|
}
|
|
@@ -133,7 +133,6 @@ export default class UniqueNftApi extends BaseNftApi {
|
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
}));
|
|
136
|
-
const nftCollectionMap = {};
|
|
137
136
|
await Promise.all(allCollectionId.map(async collectionId => {
|
|
138
137
|
const collectionIdStr = collectionId.toString();
|
|
139
138
|
|
|
@@ -141,7 +140,6 @@ export default class UniqueNftApi extends BaseNftApi {
|
|
|
141
140
|
const collection = (await this.substrateApi.api.query.nft.collectionById(collectionId)).toJSON();
|
|
142
141
|
collectionMap[collectionIdStr] = collection;
|
|
143
142
|
const nftIds = Object.entries(nftMap).filter(item => item[1] === collectionId).map(item => item[0]);
|
|
144
|
-
nftCollectionMap[collectionIdStr] = nftIds;
|
|
145
143
|
const parsedCollection = {
|
|
146
144
|
collectionId: collectionIdStr,
|
|
147
145
|
chain: this.chain
|
|
@@ -168,12 +166,10 @@ export default class UniqueNftApi extends BaseNftApi {
|
|
|
168
166
|
}
|
|
169
167
|
params.updateItem(this.chain, parsedItem, address);
|
|
170
168
|
params.updateCollection(this.chain, parsedCollection);
|
|
169
|
+
// params.updateReady(true);
|
|
171
170
|
}
|
|
172
171
|
}));
|
|
173
172
|
}));
|
|
174
|
-
Object.entries(nftCollectionMap).forEach(([collectionId, nftIds]) => {
|
|
175
|
-
params.cleanUpNfts(this.chain, address, collectionId, nftIds);
|
|
176
|
-
});
|
|
177
173
|
} catch (e) {
|
|
178
174
|
console.error('Failed to fetch unique nft', e);
|
|
179
175
|
}
|
|
@@ -8,6 +8,8 @@ export declare class WasmNftApi extends BaseNftApi {
|
|
|
8
8
|
private parseFeaturedTokenUri;
|
|
9
9
|
private parseFeaturedNftImage;
|
|
10
10
|
private parseFeaturedCollectionImage;
|
|
11
|
+
private getCollectionAttributes;
|
|
12
|
+
private processOnChainMetadata;
|
|
11
13
|
private processOffChainMetadata;
|
|
12
14
|
private getItemsByCollection;
|
|
13
15
|
fetchNfts(params: HandleNftParams): Promise<number>;
|