@subwallet/extension-base 1.1.1 → 1.1.2-1
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 +14 -4
- package/cjs/constants/i18n.js +10 -2
- package/cjs/koni/api/dotsama/transfer.js +6 -0
- package/cjs/koni/api/nft/acala_nft/index.js +0 -2
- package/cjs/koni/api/nft/bit.country/index.js +49 -18
- package/cjs/koni/api/nft/config.js +5 -3
- package/cjs/koni/api/nft/evm_nft/index.js +0 -5
- package/cjs/koni/api/nft/index.js +2 -3
- package/cjs/koni/api/nft/karura_nft/index.js +0 -2
- package/cjs/koni/api/nft/rmrk_nft/index.js +0 -4
- package/cjs/koni/api/nft/statemine_nft/index.js +0 -2
- package/cjs/koni/api/nft/unique_nft/index.js +0 -5
- package/cjs/koni/api/nft/wasm_nft/index.js +0 -5
- package/cjs/koni/api/staking/bonding/amplitude.js +6 -6
- package/cjs/koni/api/staking/bonding/astar.js +6 -6
- package/cjs/koni/api/staking/bonding/paraChain.js +5 -5
- package/cjs/koni/api/staking/bonding/relayChain.js +24 -14
- package/cjs/koni/api/staking/bonding/utils.js +1 -7
- package/cjs/koni/api/xcm/xTokens.js +1 -1
- package/cjs/koni/background/cron.js +2 -37
- package/cjs/koni/background/handlers/Extension.js +133 -123
- package/cjs/koni/background/handlers/State.js +6 -43
- package/cjs/koni/background/subscription.js +6 -88
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/chain-service/constants.js +6 -4
- package/cjs/services/setting-service/constants.js +16 -6
- package/cjs/services/storage-service/DatabaseService.js +3 -0
- package/cjs/services/storage-service/db-stores/Nft.js +3 -0
- package/cjs/services/storage-service/db-stores/NominatorMetadata.js +3 -2
- package/cjs/utils/index.js +12 -0
- package/cjs/utils/translate.js +11 -0
- package/constants/i18n.d.ts +2 -1
- package/constants/i18n.js +8 -1
- package/koni/api/dotsama/transfer.js +6 -0
- package/koni/api/nft/acala_nft/index.js +0 -2
- package/koni/api/nft/bit.country/index.d.ts +1 -0
- package/koni/api/nft/bit.country/index.js +50 -19
- package/koni/api/nft/config.d.ts +2 -1
- package/koni/api/nft/config.js +2 -1
- package/koni/api/nft/evm_nft/index.js +0 -4
- package/koni/api/nft/index.d.ts +1 -1
- package/koni/api/nft/index.js +2 -3
- package/koni/api/nft/karura_nft/index.js +0 -2
- package/koni/api/nft/nft.d.ts +0 -1
- package/koni/api/nft/rmrk_nft/index.js +0 -4
- package/koni/api/nft/statemine_nft/index.js +0 -2
- package/koni/api/nft/unique_nft/index.js +0 -5
- package/koni/api/nft/wasm_nft/index.js +0 -4
- package/koni/api/staking/bonding/amplitude.js +6 -6
- package/koni/api/staking/bonding/astar.js +6 -6
- package/koni/api/staking/bonding/paraChain.js +5 -5
- package/koni/api/staking/bonding/relayChain.js +24 -14
- package/koni/api/staking/bonding/utils.js +1 -7
- package/koni/api/xcm/xTokens.js +1 -1
- package/koni/background/cron.d.ts +0 -5
- package/koni/background/cron.js +4 -39
- package/koni/background/handlers/Extension.d.ts +2 -0
- package/koni/background/handlers/Extension.js +25 -17
- package/koni/background/handlers/State.d.ts +2 -6
- package/koni/background/handlers/State.js +6 -43
- package/koni/background/subscription.d.ts +1 -4
- package/koni/background/subscription.js +9 -88
- package/package.json +11 -6
- package/packageInfo.js +1 -1
- package/services/chain-service/constants.d.ts +1 -0
- package/services/chain-service/constants.js +6 -4
- package/services/setting-service/constants.d.ts +6 -1
- package/services/setting-service/constants.js +10 -5
- package/services/storage-service/DatabaseService.d.ts +1 -0
- package/services/storage-service/DatabaseService.js +3 -0
- package/services/storage-service/db-stores/Nft.d.ts +1 -0
- package/services/storage-service/db-stores/Nft.js +3 -0
- package/services/storage-service/db-stores/NominatorMetadata.js +3 -2
- package/utils/index.d.ts +1 -0
- package/utils/index.js +2 -1
- package/utils/translate.d.ts +1 -0
- package/utils/translate.js +4 -0
|
@@ -300,14 +300,16 @@ export interface CurrentAccountInfo {
|
|
|
300
300
|
currentGenesisHash: string | null;
|
|
301
301
|
allGenesisHash?: string;
|
|
302
302
|
}
|
|
303
|
-
export declare type LanguageType = 'en' | 'zh' | 'fr' | 'tr' | 'pl' | 'th' | 'ur';
|
|
303
|
+
export declare type LanguageType = 'en' | 'zh' | 'fr' | 'tr' | 'pl' | 'th' | 'ur' | 'vi' | 'ja';
|
|
304
304
|
export declare type LanguageOptionType = {
|
|
305
305
|
text: string;
|
|
306
306
|
value: LanguageType;
|
|
307
307
|
};
|
|
308
308
|
export declare type BrowserConfirmationType = 'extension' | 'popup' | 'window';
|
|
309
309
|
export interface UiSettings {
|
|
310
|
+
language: LanguageType;
|
|
310
311
|
browserConfirmationType: BrowserConfirmationType;
|
|
312
|
+
isShowZeroBalance: boolean;
|
|
311
313
|
isShowBalance: boolean;
|
|
312
314
|
accountAllLogo: string;
|
|
313
315
|
theme: ThemeNames;
|
|
@@ -325,6 +327,12 @@ export declare type RequestChangeTimeAutoLock = {
|
|
|
325
327
|
export declare type RequestChangeEnableChainPatrol = {
|
|
326
328
|
enable: boolean;
|
|
327
329
|
};
|
|
330
|
+
export declare type RequestChangeShowZeroBalance = {
|
|
331
|
+
show: boolean;
|
|
332
|
+
};
|
|
333
|
+
export declare type RequestChangeLanguage = {
|
|
334
|
+
language: LanguageType;
|
|
335
|
+
};
|
|
328
336
|
export interface RandomTestRequest {
|
|
329
337
|
start: number;
|
|
330
338
|
end: number;
|
|
@@ -1578,13 +1586,15 @@ export interface KoniRequestSignatures {
|
|
|
1578
1586
|
'pri(accounts.deleteContact)': [RequestDeleteContactAccount, boolean];
|
|
1579
1587
|
'pri(settings.changeBalancesVisibility)': [null, boolean];
|
|
1580
1588
|
'pri(settings.subscribe)': [null, UiSettings, UiSettings];
|
|
1589
|
+
'pri(settings.getLogoMaps)': [null, AllLogoMap];
|
|
1581
1590
|
'pri(settings.saveAccountAllLogo)': [string, boolean, UiSettings];
|
|
1582
|
-
'pri(settings.saveTheme)': [ThemeNames, boolean
|
|
1583
|
-
'pri(settings.saveBrowserConfirmationType)': [BrowserConfirmationType, boolean
|
|
1591
|
+
'pri(settings.saveTheme)': [ThemeNames, boolean];
|
|
1592
|
+
'pri(settings.saveBrowserConfirmationType)': [BrowserConfirmationType, boolean];
|
|
1584
1593
|
'pri(settings.saveCamera)': [RequestCameraSettings, boolean];
|
|
1585
1594
|
'pri(settings.saveAutoLockTime)': [RequestChangeTimeAutoLock, boolean];
|
|
1586
1595
|
'pri(settings.saveEnableChainPatrol)': [RequestChangeEnableChainPatrol, boolean];
|
|
1587
|
-
'pri(settings.
|
|
1596
|
+
'pri(settings.saveLanguage)': [RequestChangeLanguage, boolean];
|
|
1597
|
+
'pri(settings.saveShowZeroBalance)': [RequestChangeShowZeroBalance, boolean];
|
|
1588
1598
|
'pri(transaction.history.getSubscription)': [null, TransactionHistoryItem[], TransactionHistoryItem[]];
|
|
1589
1599
|
'pri(transfer.checkReferenceCount)': [RequestTransferCheckReferenceCount, boolean];
|
|
1590
1600
|
'pri(transfer.checkSupporting)': [RequestTransferCheckSupporting, SupportTransferResponse];
|
package/cjs/constants/i18n.js
CHANGED
|
@@ -3,16 +3,22 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.languageOptions = void 0;
|
|
6
|
+
exports.languageOptions = exports.ENABLE_LANGUAGES = void 0;
|
|
7
7
|
// Copyright 2019-2022 @polkadot/extension-ui authors & contributors
|
|
8
8
|
// SPDX-License-Identifier: Apache-2.0
|
|
9
9
|
|
|
10
10
|
const languageOptions = [{
|
|
11
11
|
text: 'English',
|
|
12
12
|
value: 'en'
|
|
13
|
+
}, {
|
|
14
|
+
text: 'Tiếng Việt',
|
|
15
|
+
value: 'vi'
|
|
13
16
|
}, {
|
|
14
17
|
text: '汉语',
|
|
15
18
|
value: 'zh'
|
|
19
|
+
}, {
|
|
20
|
+
text: '日本語',
|
|
21
|
+
value: 'ja'
|
|
16
22
|
}, {
|
|
17
23
|
text: 'Français',
|
|
18
24
|
value: 'fr'
|
|
@@ -29,4 +35,6 @@ const languageOptions = [{
|
|
|
29
35
|
text: 'اردو',
|
|
30
36
|
value: 'ur'
|
|
31
37
|
}];
|
|
32
|
-
exports.languageOptions = languageOptions;
|
|
38
|
+
exports.languageOptions = languageOptions;
|
|
39
|
+
const ENABLE_LANGUAGES = ['en', 'vi', 'zh'];
|
|
40
|
+
exports.ENABLE_LANGUAGES = ENABLE_LANGUAGES;
|
|
@@ -149,6 +149,12 @@ const createTransferExtrinsic = async _ref => {
|
|
|
149
149
|
} else if (value) {
|
|
150
150
|
transfer = api.tx.tokens.transfer(to, (0, _utils2._getTokenOnChainInfo)(tokenInfo) || (0, _utils2._getTokenOnChainAssetId)(tokenInfo), new _util.BN(value));
|
|
151
151
|
}
|
|
152
|
+
} else if (_constants._TRANSFER_CHAIN_GROUP.pendulum.includes(networkKey) && isTxTokensSupported) {
|
|
153
|
+
if (transferAll) {
|
|
154
|
+
transfer = api.tx.tokens.transferAll(to, (0, _utils2._getTokenOnChainInfo)(tokenInfo), false);
|
|
155
|
+
} else if (value) {
|
|
156
|
+
transfer = api.tx.tokens.transfer(to, (0, _utils2._getTokenOnChainInfo)(tokenInfo), new _util.BN(value));
|
|
157
|
+
}
|
|
152
158
|
} else if (_constants._TRANSFER_CHAIN_GROUP.genshiro.includes(networkKey)
|
|
153
159
|
// && isTxEqBalancesSupported
|
|
154
160
|
) {
|
|
@@ -82,7 +82,6 @@ class AcalaNftApi extends _nft.BaseNftApi {
|
|
|
82
82
|
const assetIds = await this.getNfts([address]);
|
|
83
83
|
try {
|
|
84
84
|
if (!assetIds || assetIds.length === 0) {
|
|
85
|
-
params.cleanUpNfts(this.chain, address, [], [], true);
|
|
86
85
|
return;
|
|
87
86
|
}
|
|
88
87
|
const collectionIds = [];
|
|
@@ -118,7 +117,6 @@ class AcalaNftApi extends _nft.BaseNftApi {
|
|
|
118
117
|
params.updateItem(this.chain, parsedNft, address);
|
|
119
118
|
params.updateCollection(this.chain, parsedCollection);
|
|
120
119
|
}));
|
|
121
|
-
params.cleanUpNfts(this.chain, address, collectionIds, nftIds);
|
|
122
120
|
} catch (e) {
|
|
123
121
|
console.error(`${this.chain}`, e);
|
|
124
122
|
}
|
|
@@ -9,6 +9,7 @@ var _config = require("@subwallet/extension-base/koni/api/nft/config");
|
|
|
9
9
|
var _nft = require("@subwallet/extension-base/koni/api/nft/nft");
|
|
10
10
|
var _utils = require("@subwallet/extension-base/utils");
|
|
11
11
|
var _crossFetch = _interopRequireDefault(require("cross-fetch"));
|
|
12
|
+
var _util = require("@polkadot/util");
|
|
12
13
|
// Copyright 2019-2022 @subwallet/extension-base
|
|
13
14
|
// SPDX-License-Identifier: Apache-2.0
|
|
14
15
|
|
|
@@ -24,9 +25,9 @@ class BitCountryNftApi extends _nft.BaseNftApi {
|
|
|
24
25
|
return input;
|
|
25
26
|
}
|
|
26
27
|
if (!input.includes('ipfs://')) {
|
|
27
|
-
return _config.
|
|
28
|
+
return _config.BIT_COUNTRY_IPFS_SERVER + input;
|
|
28
29
|
}
|
|
29
|
-
return _config.
|
|
30
|
+
return _config.BIT_COUNTRY_IPFS_SERVER + input.split('ipfs://')[1];
|
|
30
31
|
}
|
|
31
32
|
async getNfts(addresses) {
|
|
32
33
|
if (!this.substrateApi) {
|
|
@@ -55,7 +56,13 @@ class BitCountryNftApi extends _nft.BaseNftApi {
|
|
|
55
56
|
if (!onChainMeta.metadata) {
|
|
56
57
|
return null;
|
|
57
58
|
}
|
|
58
|
-
|
|
59
|
+
|
|
60
|
+
// check if NFT is Land/Estate
|
|
61
|
+
if (onChainMeta.data.attributes['MetaverseId:']) {
|
|
62
|
+
return await (0, _crossFetch.default)(`${_config.BIT_COUNTRY_LAND_ESTATE_METADATA_API}/${assetId.classId}/${assetId.tokenId}/metadata.json`).then(resp => resp.json());
|
|
63
|
+
} else {
|
|
64
|
+
return await (0, _crossFetch.default)(_config.BIT_COUNTRY_IPFS_SERVER + onChainMeta.metadata).then(resp => resp.json());
|
|
65
|
+
}
|
|
59
66
|
}
|
|
60
67
|
async getCollectionDetails(collectionId) {
|
|
61
68
|
if (!this.substrateApi) {
|
|
@@ -65,7 +72,41 @@ class BitCountryNftApi extends _nft.BaseNftApi {
|
|
|
65
72
|
if (!metadataCollection.metadata) {
|
|
66
73
|
return null;
|
|
67
74
|
}
|
|
68
|
-
|
|
75
|
+
if (metadataCollection.data.attributes['MetaverseId:']) {
|
|
76
|
+
const category = metadataCollection.data.attributes['Category:'];
|
|
77
|
+
const hexMetaverseId = metadataCollection.data.attributes['MetaverseId:'];
|
|
78
|
+
let metaverseId = _util.BN_ZERO;
|
|
79
|
+
try {
|
|
80
|
+
metaverseId = (0, _util.hexToBn)(hexMetaverseId);
|
|
81
|
+
} catch (e) {
|
|
82
|
+
console.warn('Error parsing metaverse id', e);
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
name: `${category} #${collectionId}`,
|
|
86
|
+
metaverseId: metaverseId.toString()
|
|
87
|
+
};
|
|
88
|
+
} else {
|
|
89
|
+
return await (0, _crossFetch.default)(_config.BIT_COUNTRY_IPFS_SERVER + metadataCollection.metadata).then(resp => resp.json());
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
parseMetadata(data) {
|
|
93
|
+
const traitList = data !== null && data !== void 0 && data.traits ? data.traits : data === null || data === void 0 ? void 0 : data.attributes;
|
|
94
|
+
const propertiesMap = {};
|
|
95
|
+
if (traitList) {
|
|
96
|
+
traitList.forEach(traitMap => {
|
|
97
|
+
propertiesMap[traitMap.trait_type] = {
|
|
98
|
+
value: traitMap.value
|
|
99
|
+
};
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
name: data === null || data === void 0 ? void 0 : data.name,
|
|
104
|
+
image: data !== null && data !== void 0 && data.image_url ? this.parseUrl(data.image_url) : this.parseUrl(data === null || data === void 0 ? void 0 : data.image),
|
|
105
|
+
description: data === null || data === void 0 ? void 0 : data.description,
|
|
106
|
+
properties: propertiesMap,
|
|
107
|
+
externalUrl: data === null || data === void 0 ? void 0 : data.external_url,
|
|
108
|
+
chain: this.chain
|
|
109
|
+
};
|
|
69
110
|
}
|
|
70
111
|
async fetchNfts(params) {
|
|
71
112
|
try {
|
|
@@ -80,7 +121,6 @@ class BitCountryNftApi extends _nft.BaseNftApi {
|
|
|
80
121
|
const assetIds = await this.getNfts([address]);
|
|
81
122
|
try {
|
|
82
123
|
if (!assetIds || assetIds.length === 0) {
|
|
83
|
-
params.cleanUpNfts(this.chain, address, [], [], true);
|
|
84
124
|
return;
|
|
85
125
|
}
|
|
86
126
|
const collectionIds = [];
|
|
@@ -93,18 +133,10 @@ class BitCountryNftApi extends _nft.BaseNftApi {
|
|
|
93
133
|
}
|
|
94
134
|
nftIds.push(parsedTokenId);
|
|
95
135
|
const [tokenInfo, collectionMeta] = await Promise.all([this.getTokenDetails(assetId), this.getCollectionDetails(parsedClassId)]);
|
|
96
|
-
const parsedNft =
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access
|
|
101
|
-
description: tokenInfo && tokenInfo.description ? tokenInfo.description : collectionMeta === null || collectionMeta === void 0 ? void 0 : collectionMeta.description,
|
|
102
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
|
|
103
|
-
image: tokenInfo && tokenInfo.image_url ? this.parseUrl(tokenInfo === null || tokenInfo === void 0 ? void 0 : tokenInfo.image_url) : this.parseUrl(collectionMeta === null || collectionMeta === void 0 ? void 0 : collectionMeta.image_url),
|
|
104
|
-
collectionId: parsedClassId,
|
|
105
|
-
chain: this.chain,
|
|
106
|
-
owner: address
|
|
107
|
-
};
|
|
136
|
+
const parsedNft = this.parseMetadata(tokenInfo);
|
|
137
|
+
parsedNft.collectionId = parsedClassId;
|
|
138
|
+
parsedNft.id = parsedTokenId;
|
|
139
|
+
parsedNft.owner = address;
|
|
108
140
|
const parsedCollection = {
|
|
109
141
|
collectionId: parsedClassId,
|
|
110
142
|
chain: this.chain,
|
|
@@ -116,7 +148,6 @@ class BitCountryNftApi extends _nft.BaseNftApi {
|
|
|
116
148
|
params.updateItem(this.chain, parsedNft, address);
|
|
117
149
|
params.updateCollection(this.chain, parsedCollection);
|
|
118
150
|
}));
|
|
119
|
-
params.cleanUpNfts(this.chain, address, collectionIds, nftIds);
|
|
120
151
|
} catch (e) {
|
|
121
152
|
console.error(`${this.chain}`, e);
|
|
122
153
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.UNIQUE_SCAN_ENDPOINT = exports.UNIQUE_IPFS_GATEWAY = exports.TRANSFER_CHAIN_ID = exports.SUPPORTED_TRANSFER_SUBSTRATE_CHAIN_NAME = exports.SUPPORTED_TRANSFER_EVM_CHAIN_NAME = exports.SUPPORTED_TRANSFER_EVM_CHAIN = exports.SUPPORTED_NFT_NETWORKS = exports.SINGULAR_V2_ENDPOINT = exports.SINGULAR_V2_COLLECTION_ENDPOINT = exports.SINGULAR_V1_ENDPOINT = exports.SINGULAR_V1_COLLECTION_ENDPOINT = exports.RMRK_PINATA_SERVER = exports.QUARTZ_SCAN_ENDPOINT = exports.PINATA_IPFS_GATEWAY = exports.NFT_STORAGE_GATEWAY = exports.KANARIA_EXTERNAL_SERVER = exports.KANARIA_ENDPOINT = exports.IPFS_TELOS_MIAMI = exports.IPFS_IO_GATEWAY = exports.IPFS_GATEWAY_CLOUD = exports.IPFS_FLEEK = exports.GATEWAY_IPFS_IO = exports.DWEB_LINK = exports.CLOUDFLARE_PINATA_SERVER = exports.CF_IPFS_GATEWAY = exports.BIT_COUNTRY_THUMBNAIL_RESOLVER = exports.
|
|
6
|
+
exports.UNIQUE_SCAN_ENDPOINT = exports.UNIQUE_IPFS_GATEWAY = exports.TRANSFER_CHAIN_ID = exports.SUPPORTED_TRANSFER_SUBSTRATE_CHAIN_NAME = exports.SUPPORTED_TRANSFER_EVM_CHAIN_NAME = exports.SUPPORTED_TRANSFER_EVM_CHAIN = exports.SUPPORTED_NFT_NETWORKS = exports.SINGULAR_V2_ENDPOINT = exports.SINGULAR_V2_COLLECTION_ENDPOINT = exports.SINGULAR_V1_ENDPOINT = exports.SINGULAR_V1_COLLECTION_ENDPOINT = exports.RMRK_PINATA_SERVER = exports.QUARTZ_SCAN_ENDPOINT = exports.PINATA_IPFS_GATEWAY = exports.NFT_STORAGE_GATEWAY = exports.KANARIA_EXTERNAL_SERVER = exports.KANARIA_ENDPOINT = exports.IPFS_TELOS_MIAMI = exports.IPFS_IO_GATEWAY = exports.IPFS_GATEWAY_CLOUD = exports.IPFS_FLEEK = exports.GATEWAY_IPFS_IO = exports.DWEB_LINK = exports.CLOUDFLARE_PINATA_SERVER = exports.CF_IPFS_GATEWAY = exports.BIT_COUNTRY_THUMBNAIL_RESOLVER = exports.BIT_COUNTRY_LAND_ESTATE_METADATA_API = exports.BIT_COUNTRY_IPFS_SERVER = void 0;
|
|
7
7
|
exports.getRandomIpfsGateway = getRandomIpfsGateway;
|
|
8
8
|
var _utils = require("@subwallet/extension-base/utils");
|
|
9
9
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
@@ -25,8 +25,10 @@ const KANARIA_EXTERNAL_SERVER = 'https://kanaria.rmrk.app/catalogue/';
|
|
|
25
25
|
exports.KANARIA_EXTERNAL_SERVER = KANARIA_EXTERNAL_SERVER;
|
|
26
26
|
const CLOUDFLARE_PINATA_SERVER = 'https://cloudflare-ipfs.com/ipfs/';
|
|
27
27
|
exports.CLOUDFLARE_PINATA_SERVER = CLOUDFLARE_PINATA_SERVER;
|
|
28
|
-
const
|
|
29
|
-
exports.
|
|
28
|
+
const BIT_COUNTRY_IPFS_SERVER = 'https://ipfs-cdn.bit.country/';
|
|
29
|
+
exports.BIT_COUNTRY_IPFS_SERVER = BIT_COUNTRY_IPFS_SERVER;
|
|
30
|
+
const BIT_COUNTRY_LAND_ESTATE_METADATA_API = 'https://pioneer-api.bit.country/metadata/landTokenUriPioneer';
|
|
31
|
+
exports.BIT_COUNTRY_LAND_ESTATE_METADATA_API = BIT_COUNTRY_LAND_ESTATE_METADATA_API;
|
|
30
32
|
const BIT_COUNTRY_THUMBNAIL_RESOLVER = 'https://res.cloudinary.com/ddftctzph/image/upload/c_scale,q_100,w_250/production-ipfs/asset/';
|
|
31
33
|
exports.BIT_COUNTRY_THUMBNAIL_RESOLVER = BIT_COUNTRY_THUMBNAIL_RESOLVER;
|
|
32
34
|
const CF_IPFS_GATEWAY = 'https://cf-ipfs.com/ipfs/';
|
|
@@ -92,7 +92,6 @@ class EvmNftApi extends _nft.BaseNftApi {
|
|
|
92
92
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
|
|
93
93
|
const balance = await contract.methods.balanceOf(address).call();
|
|
94
94
|
if (Number(balance) === 0) {
|
|
95
|
-
nftParams.cleanUpNfts(this.chain, address, [smartContract], []);
|
|
96
95
|
return;
|
|
97
96
|
}
|
|
98
97
|
const itemIndexes = [];
|
|
@@ -147,10 +146,6 @@ class EvmNftApi extends _nft.BaseNftApi {
|
|
|
147
146
|
originAsset: tokenInfo.slug
|
|
148
147
|
};
|
|
149
148
|
nftParams.updateCollection(this.chain, nftCollection);
|
|
150
|
-
Object.entries(nftOwnerMap).forEach(_ref => {
|
|
151
|
-
let [owner, nftIds] = _ref;
|
|
152
|
-
nftParams.cleanUpNfts(this.chain, owner, [smartContract], nftIds);
|
|
153
|
-
});
|
|
154
149
|
}
|
|
155
150
|
}
|
|
156
151
|
async handleNfts(params) {
|
|
@@ -131,14 +131,13 @@ class NftHandler {
|
|
|
131
131
|
console.error(e);
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
|
-
async handleNfts(nftContracts, updateItem, updateCollection
|
|
134
|
+
async handleNfts(nftContracts, updateItem, updateCollection) {
|
|
135
135
|
this.setupApi();
|
|
136
136
|
this.setupNftContracts(nftContracts);
|
|
137
137
|
await Promise.all(this.handlers.map(async handler => {
|
|
138
138
|
await handler.fetchNfts({
|
|
139
139
|
updateItem,
|
|
140
|
-
updateCollection
|
|
141
|
-
cleanUpNfts
|
|
140
|
+
updateCollection
|
|
142
141
|
});
|
|
143
142
|
}));
|
|
144
143
|
}
|
|
@@ -90,7 +90,6 @@ class KaruraNftApi extends _nft.BaseNftApi {
|
|
|
90
90
|
const assetIds = await this.getNfts([address]);
|
|
91
91
|
try {
|
|
92
92
|
if (!assetIds || assetIds.length === 0) {
|
|
93
|
-
params.cleanUpNfts(this.chain, address, [], [], true);
|
|
94
93
|
return;
|
|
95
94
|
}
|
|
96
95
|
const collectionIds = [];
|
|
@@ -124,7 +123,6 @@ class KaruraNftApi extends _nft.BaseNftApi {
|
|
|
124
123
|
params.updateItem(this.chain, parsedNft, address);
|
|
125
124
|
params.updateCollection(this.chain, parsedCollection);
|
|
126
125
|
}));
|
|
127
|
-
params.cleanUpNfts(this.chain, address, collectionIds, nftIds);
|
|
128
126
|
} catch (e) {
|
|
129
127
|
console.error(`${this.chain}`, e);
|
|
130
128
|
}
|
|
@@ -136,7 +136,6 @@ class RmrkNftApi extends _nft.BaseNftApi {
|
|
|
136
136
|
const kusamaAddress = (0, _utils.reformatAddress)(address, 2);
|
|
137
137
|
allNfts = await this.getAllByAccount(kusamaAddress);
|
|
138
138
|
if (allNfts.length <= 0) {
|
|
139
|
-
params.cleanUpNfts(this.chain, address, [], [], true);
|
|
140
139
|
return;
|
|
141
140
|
}
|
|
142
141
|
const collectionInfoUrl = [];
|
|
@@ -244,9 +243,6 @@ class RmrkNftApi extends _nft.BaseNftApi {
|
|
|
244
243
|
});
|
|
245
244
|
params.updateCollection(this.chain, parsedCollection);
|
|
246
245
|
});
|
|
247
|
-
const allCollectionIds = allCollections.map(item => item.collectionId);
|
|
248
|
-
const allNftIds = allNfts.map(nft => nft === null || nft === void 0 ? void 0 : nft.id);
|
|
249
|
-
params.cleanUpNfts(this.chain, address, allCollectionIds, allNftIds);
|
|
250
246
|
} catch (e) {
|
|
251
247
|
console.error(`${this.chain}`, e);
|
|
252
248
|
}
|
|
@@ -93,7 +93,6 @@ class StatemineNftApi extends _nft.BaseNftApi {
|
|
|
93
93
|
const assetIds = await this.getNfts([address]);
|
|
94
94
|
try {
|
|
95
95
|
if (!assetIds || assetIds.length === 0) {
|
|
96
|
-
params.cleanUpNfts(this.chain, address, [], [], true);
|
|
97
96
|
return;
|
|
98
97
|
}
|
|
99
98
|
const collectionIds = [];
|
|
@@ -124,7 +123,6 @@ class StatemineNftApi extends _nft.BaseNftApi {
|
|
|
124
123
|
};
|
|
125
124
|
params.updateCollection(this.chain, parsedCollection);
|
|
126
125
|
}));
|
|
127
|
-
params.cleanUpNfts(this.chain, address, collectionIds, nftIds);
|
|
128
126
|
} catch (e) {
|
|
129
127
|
console.error(`${this.chain}`, e);
|
|
130
128
|
}
|
|
@@ -141,8 +141,6 @@ class UniqueNftApi extends _nft.BaseNftApi {
|
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
}));
|
|
144
|
-
const collectionIds = [];
|
|
145
|
-
let allNftIds = [];
|
|
146
144
|
await Promise.all(allCollectionId.map(async collectionId => {
|
|
147
145
|
const collectionIdStr = collectionId.toString();
|
|
148
146
|
|
|
@@ -150,8 +148,6 @@ class UniqueNftApi extends _nft.BaseNftApi {
|
|
|
150
148
|
const collection = (await this.substrateApi.api.query.nft.collectionById(collectionId)).toJSON();
|
|
151
149
|
collectionMap[collectionIdStr] = collection;
|
|
152
150
|
const nftIds = Object.entries(nftMap).filter(item => item[1] === collectionId).map(item => item[0]);
|
|
153
|
-
collectionIds.push(collectionIdStr);
|
|
154
|
-
allNftIds = allNftIds.concat(nftIds);
|
|
155
151
|
const parsedCollection = {
|
|
156
152
|
collectionId: collectionIdStr,
|
|
157
153
|
chain: this.chain
|
|
@@ -181,7 +177,6 @@ class UniqueNftApi extends _nft.BaseNftApi {
|
|
|
181
177
|
}
|
|
182
178
|
}));
|
|
183
179
|
}));
|
|
184
|
-
params.cleanUpNfts(this.chain, address, collectionIds, allNftIds);
|
|
185
180
|
} catch (e) {
|
|
186
181
|
console.error(`${this.chain}`, e);
|
|
187
182
|
}
|
|
@@ -330,7 +330,6 @@ class WasmNftApi extends _nft.BaseNftApi {
|
|
|
330
330
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
331
331
|
const balance = _balance.output ? balanceJson.ok || balanceJson.Ok : '0';
|
|
332
332
|
if (parseInt(balance) === 0) {
|
|
333
|
-
nftParams.cleanUpNfts(this.chain, address, [smartContract], []);
|
|
334
333
|
return;
|
|
335
334
|
}
|
|
336
335
|
const itemIndexes = [];
|
|
@@ -414,10 +413,6 @@ class WasmNftApi extends _nft.BaseNftApi {
|
|
|
414
413
|
originAsset: tokenInfo.slug
|
|
415
414
|
};
|
|
416
415
|
nftParams.updateCollection(this.chain, nftCollection);
|
|
417
|
-
Object.entries(nftOwnerMap).forEach(_ref => {
|
|
418
|
-
let [owner, nftIds] = _ref;
|
|
419
|
-
nftParams.cleanUpNfts(this.chain, owner, [smartContract], nftIds);
|
|
420
|
-
});
|
|
421
416
|
}
|
|
422
417
|
}
|
|
423
418
|
async fetchNfts(params) {
|
|
@@ -103,14 +103,14 @@ async function subscribeAmplitudeNominatorMetadata(chainInfo, address, substrate
|
|
|
103
103
|
const nearestUnstakingAmount = Object.values(unstakingInfo)[0];
|
|
104
104
|
const blockDuration = (_constants._STAKING_ERA_LENGTH_MAP[chainInfo.slug] || _constants._STAKING_ERA_LENGTH_MAP.default) / blockPerRound; // in hours
|
|
105
105
|
|
|
106
|
-
const isClaimable = parseInt(nearestUnstakingBlock) - currentBlockNumber
|
|
107
|
-
const remainingBlock = parseInt(nearestUnstakingBlock) -
|
|
106
|
+
const isClaimable = parseInt(nearestUnstakingBlock) - currentBlockNumber < 0;
|
|
107
|
+
const remainingBlock = parseInt(nearestUnstakingBlock) - currentBlockNumber;
|
|
108
108
|
const waitingTime = remainingBlock * blockDuration;
|
|
109
109
|
unstakingList.push({
|
|
110
110
|
chain: chainInfo.slug,
|
|
111
111
|
status: isClaimable ? _KoniTypes.UnstakingStatus.CLAIMABLE : _KoniTypes.UnstakingStatus.UNLOCKING,
|
|
112
112
|
claimable: nearestUnstakingAmount.toString(),
|
|
113
|
-
waitingTime
|
|
113
|
+
waitingTime,
|
|
114
114
|
validatorAddress: (delegatorState === null || delegatorState === void 0 ? void 0 : delegatorState.owner) || undefined
|
|
115
115
|
});
|
|
116
116
|
}
|
|
@@ -179,14 +179,14 @@ async function getAmplitudeNominatorMetadata(chainInfo, address, substrateApi) {
|
|
|
179
179
|
const nearestUnstakingAmount = Object.values(unstakingInfo)[0];
|
|
180
180
|
const blockDuration = (_constants._STAKING_ERA_LENGTH_MAP[chain] || _constants._STAKING_ERA_LENGTH_MAP.default) / blockPerRound; // in hours
|
|
181
181
|
|
|
182
|
-
const isClaimable = parseInt(nearestUnstakingBlock) - currentBlockNumber
|
|
183
|
-
const remainingBlock = parseInt(nearestUnstakingBlock) -
|
|
182
|
+
const isClaimable = parseInt(nearestUnstakingBlock) - currentBlockNumber < 0;
|
|
183
|
+
const remainingBlock = parseInt(nearestUnstakingBlock) - currentBlockNumber;
|
|
184
184
|
const waitingTime = remainingBlock * blockDuration;
|
|
185
185
|
unstakingList.push({
|
|
186
186
|
chain,
|
|
187
187
|
status: isClaimable ? _KoniTypes.UnstakingStatus.CLAIMABLE : _KoniTypes.UnstakingStatus.UNLOCKING,
|
|
188
188
|
claimable: nearestUnstakingAmount.toString(),
|
|
189
|
-
waitingTime
|
|
189
|
+
waitingTime,
|
|
190
190
|
validatorAddress: (delegatorState === null || delegatorState === void 0 ? void 0 : delegatorState.owner) || undefined
|
|
191
191
|
});
|
|
192
192
|
}
|
|
@@ -127,14 +127,14 @@ async function subscribeAstarNominatorMetadata(chainInfo, address, substrateApi,
|
|
|
127
127
|
const unlockingChunks = ledger.unbondingInfo.unlockingChunks;
|
|
128
128
|
if (unlockingChunks.length > 0) {
|
|
129
129
|
for (const unlockingChunk of unlockingChunks) {
|
|
130
|
-
const isClaimable = unlockingChunk.unlockEra - parseInt(currentEra)
|
|
131
|
-
const remainingEra = unlockingChunk.unlockEra -
|
|
130
|
+
const isClaimable = unlockingChunk.unlockEra - parseInt(currentEra) < 0;
|
|
131
|
+
const remainingEra = unlockingChunk.unlockEra - parseInt(currentEra);
|
|
132
132
|
const waitingTime = remainingEra * _constants._STAKING_ERA_LENGTH_MAP[chainInfo.slug];
|
|
133
133
|
unstakingList.push({
|
|
134
134
|
chain: chainInfo.slug,
|
|
135
135
|
status: isClaimable ? _KoniTypes.UnstakingStatus.CLAIMABLE : _KoniTypes.UnstakingStatus.UNLOCKING,
|
|
136
136
|
claimable: unlockingChunk.amount.toString(),
|
|
137
|
-
waitingTime
|
|
137
|
+
waitingTime
|
|
138
138
|
});
|
|
139
139
|
}
|
|
140
140
|
}
|
|
@@ -215,14 +215,14 @@ async function getAstarNominatorMetadata(chainInfo, address, substrateApi) {
|
|
|
215
215
|
const unlockingChunks = ledger.unbondingInfo.unlockingChunks;
|
|
216
216
|
if (unlockingChunks.length > 0) {
|
|
217
217
|
for (const unlockingChunk of unlockingChunks) {
|
|
218
|
-
const isClaimable = unlockingChunk.unlockEra - parseInt(currentEra)
|
|
219
|
-
const remainingEra = unlockingChunk.unlockEra -
|
|
218
|
+
const isClaimable = unlockingChunk.unlockEra - parseInt(currentEra) < 0;
|
|
219
|
+
const remainingEra = unlockingChunk.unlockEra - parseInt(currentEra);
|
|
220
220
|
const waitingTime = remainingEra * _constants._STAKING_ERA_LENGTH_MAP[chain];
|
|
221
221
|
unstakingList.push({
|
|
222
222
|
chain,
|
|
223
223
|
status: isClaimable ? _KoniTypes.UnstakingStatus.CLAIMABLE : _KoniTypes.UnstakingStatus.UNLOCKING,
|
|
224
224
|
claimable: unlockingChunk.amount.toString(),
|
|
225
|
-
waitingTime
|
|
225
|
+
waitingTime
|
|
226
226
|
});
|
|
227
227
|
}
|
|
228
228
|
}
|
|
@@ -180,8 +180,8 @@ async function subscribeParaChainNominatorMetadata(chainInfo, address, substrate
|
|
|
180
180
|
for (const scheduledRequest of delegationScheduledRequests) {
|
|
181
181
|
if ((0, _utils3.reformatAddress)(scheduledRequest.delegator, 0) === (0, _utils3.reformatAddress)(address, 0)) {
|
|
182
182
|
// add network prefix
|
|
183
|
-
const isClaimable = scheduledRequest.whenExecutable - currentRound
|
|
184
|
-
const remainingEra = scheduledRequest.whenExecutable -
|
|
183
|
+
const isClaimable = scheduledRequest.whenExecutable - currentRound < 0;
|
|
184
|
+
const remainingEra = scheduledRequest.whenExecutable - currentRound;
|
|
185
185
|
const waitingTime = remainingEra * _constants._STAKING_ERA_LENGTH_MAP[chainInfo.slug];
|
|
186
186
|
const claimable = Object.values(scheduledRequest.action)[0];
|
|
187
187
|
unstakingMap[delegation.owner] = {
|
|
@@ -189,7 +189,7 @@ async function subscribeParaChainNominatorMetadata(chainInfo, address, substrate
|
|
|
189
189
|
status: isClaimable ? _KoniTypes.UnstakingStatus.CLAIMABLE : _KoniTypes.UnstakingStatus.UNLOCKING,
|
|
190
190
|
validatorAddress: delegation.owner,
|
|
191
191
|
claimable: claimable.toString(),
|
|
192
|
-
waitingTime
|
|
192
|
+
waitingTime
|
|
193
193
|
};
|
|
194
194
|
hasUnstaking = true;
|
|
195
195
|
break; // only handle 1 scheduledRequest per collator
|
|
@@ -272,7 +272,7 @@ async function getParaChainNominatorMetadata(chainInfo, address, substrateApi) {
|
|
|
272
272
|
for (const scheduledRequest of delegationScheduledRequests) {
|
|
273
273
|
if ((0, _utils3.reformatAddress)(scheduledRequest.delegator, 0) === (0, _utils3.reformatAddress)(address, 0)) {
|
|
274
274
|
// add network prefix
|
|
275
|
-
const isClaimable = scheduledRequest.whenExecutable - currentRound
|
|
275
|
+
const isClaimable = scheduledRequest.whenExecutable - currentRound < 0;
|
|
276
276
|
const remainingEra = scheduledRequest.whenExecutable - (currentRound + 1);
|
|
277
277
|
const waitingTime = remainingEra * _constants._STAKING_ERA_LENGTH_MAP[chain];
|
|
278
278
|
const claimable = Object.values(scheduledRequest.action)[0];
|
|
@@ -281,7 +281,7 @@ async function getParaChainNominatorMetadata(chainInfo, address, substrateApi) {
|
|
|
281
281
|
status: isClaimable ? _KoniTypes.UnstakingStatus.CLAIMABLE : _KoniTypes.UnstakingStatus.UNLOCKING,
|
|
282
282
|
validatorAddress: delegation.owner,
|
|
283
283
|
claimable: claimable.toString(),
|
|
284
|
-
waitingTime: waitingTime
|
|
284
|
+
waitingTime: waitingTime
|
|
285
285
|
};
|
|
286
286
|
hasUnstaking = true;
|
|
287
287
|
break; // only handle 1 scheduledRequest per collator
|
|
@@ -238,14 +238,14 @@ async function subscribeRelayChainNominatorMetadata(chainInfo, address, substrat
|
|
|
238
238
|
}
|
|
239
239
|
}
|
|
240
240
|
ledger.unlocking.forEach(unlockingChunk => {
|
|
241
|
-
const isClaimable = unlockingChunk.era - parseInt(currentEra)
|
|
242
|
-
const remainingEra = unlockingChunk.era -
|
|
241
|
+
const isClaimable = unlockingChunk.era - parseInt(currentEra) < 0;
|
|
242
|
+
const remainingEra = unlockingChunk.era - parseInt(currentEra);
|
|
243
243
|
const waitingTime = remainingEra * _constants._STAKING_ERA_LENGTH_MAP[chain];
|
|
244
244
|
unstakingList.push({
|
|
245
245
|
chain,
|
|
246
246
|
status: isClaimable ? _KoniTypes.UnstakingStatus.CLAIMABLE : _KoniTypes.UnstakingStatus.UNLOCKING,
|
|
247
247
|
claimable: unlockingChunk.value.toString(),
|
|
248
|
-
waitingTime: waitingTime
|
|
248
|
+
waitingTime: waitingTime
|
|
249
249
|
});
|
|
250
250
|
});
|
|
251
251
|
return {
|
|
@@ -337,14 +337,14 @@ async function getRelayChainNominatorMetadata(chainInfo, address, substrateApi)
|
|
|
337
337
|
}
|
|
338
338
|
}
|
|
339
339
|
ledger.unlocking.forEach(unlockingChunk => {
|
|
340
|
-
const isClaimable = unlockingChunk.era - parseInt(currentEra)
|
|
341
|
-
const remainingEra = unlockingChunk.era -
|
|
340
|
+
const isClaimable = unlockingChunk.era - parseInt(currentEra) < 0;
|
|
341
|
+
const remainingEra = unlockingChunk.era - parseInt(currentEra);
|
|
342
342
|
const waitingTime = remainingEra * _constants._STAKING_ERA_LENGTH_MAP[chain];
|
|
343
343
|
unstakingList.push({
|
|
344
344
|
chain,
|
|
345
345
|
status: isClaimable ? _KoniTypes.UnstakingStatus.CLAIMABLE : _KoniTypes.UnstakingStatus.UNLOCKING,
|
|
346
346
|
claimable: unlockingChunk.value.toString(),
|
|
347
|
-
waitingTime: waitingTime
|
|
347
|
+
waitingTime: waitingTime
|
|
348
348
|
});
|
|
349
349
|
});
|
|
350
350
|
return {
|
|
@@ -395,14 +395,14 @@ async function subscribeRelayChainPoolMemberMetadata(chainInfo, address, substra
|
|
|
395
395
|
const unstakings = [];
|
|
396
396
|
Object.entries(poolMemberInfo.unbondingEras).forEach(_ref => {
|
|
397
397
|
let [unlockingEra, amount] = _ref;
|
|
398
|
-
const isClaimable = parseInt(unlockingEra) - parseInt(currentEra)
|
|
399
|
-
const remainingEra = parseInt(unlockingEra) -
|
|
398
|
+
const isClaimable = parseInt(unlockingEra) - parseInt(currentEra) < 0;
|
|
399
|
+
const remainingEra = parseInt(unlockingEra) - parseInt(currentEra);
|
|
400
400
|
const waitingTime = remainingEra * _constants._STAKING_ERA_LENGTH_MAP[chainInfo.slug];
|
|
401
401
|
unstakings.push({
|
|
402
402
|
chain: chainInfo.slug,
|
|
403
403
|
status: isClaimable ? _KoniTypes.UnstakingStatus.CLAIMABLE : _KoniTypes.UnstakingStatus.UNLOCKING,
|
|
404
404
|
claimable: amount.toString(),
|
|
405
|
-
waitingTime: waitingTime
|
|
405
|
+
waitingTime: waitingTime
|
|
406
406
|
});
|
|
407
407
|
});
|
|
408
408
|
const bnActiveStake = new _util.BN(poolMemberInfo.points.toString());
|
|
@@ -473,14 +473,14 @@ async function getRelayChainPoolMemberMetadata(chainInfo, address, substrateApi)
|
|
|
473
473
|
const unstakings = [];
|
|
474
474
|
Object.entries(poolMemberInfo.unbondingEras).forEach(_ref2 => {
|
|
475
475
|
let [unlockingEra, amount] = _ref2;
|
|
476
|
-
const isClaimable = parseInt(unlockingEra) - parseInt(currentEra)
|
|
477
|
-
const remainingEra = parseInt(unlockingEra) -
|
|
476
|
+
const isClaimable = parseInt(unlockingEra) - parseInt(currentEra) < 0;
|
|
477
|
+
const remainingEra = parseInt(unlockingEra) - parseInt(currentEra);
|
|
478
478
|
const waitingTime = remainingEra * _constants._STAKING_ERA_LENGTH_MAP[chainInfo.slug];
|
|
479
479
|
unstakings.push({
|
|
480
480
|
chain: chainInfo.slug,
|
|
481
481
|
status: isClaimable ? _KoniTypes.UnstakingStatus.CLAIMABLE : _KoniTypes.UnstakingStatus.UNLOCKING,
|
|
482
482
|
claimable: amount.toString(),
|
|
483
|
-
waitingTime: waitingTime
|
|
483
|
+
waitingTime: waitingTime
|
|
484
484
|
});
|
|
485
485
|
});
|
|
486
486
|
const bnActiveStake = new _util.BN(poolMemberInfo.points.toString());
|
|
@@ -615,17 +615,27 @@ async function getRelayBondingExtrinsic(substrateApi, amount, targetValidators,
|
|
|
615
615
|
const binaryAmount = new _util.BN(amount);
|
|
616
616
|
let bondTx;
|
|
617
617
|
let nominateTx;
|
|
618
|
+
const _params = chainApi.api.tx.staking.bond.toJSON();
|
|
619
|
+
const paramsCount = _params.args.length;
|
|
618
620
|
const validatorParamList = targetValidators.map(validator => {
|
|
619
621
|
return validator.address;
|
|
620
622
|
});
|
|
621
623
|
if (!nominatorMetadata) {
|
|
622
|
-
|
|
624
|
+
if (paramsCount === 2) {
|
|
625
|
+
bondTx = chainApi.api.tx.staking.bond(binaryAmount, bondDest);
|
|
626
|
+
} else {
|
|
627
|
+
bondTx = chainApi.api.tx.staking.bond(address, binaryAmount, bondDest);
|
|
628
|
+
}
|
|
623
629
|
nominateTx = chainApi.api.tx.staking.nominate(validatorParamList);
|
|
624
630
|
return chainApi.api.tx.utility.batchAll([bondTx, nominateTx]);
|
|
625
631
|
}
|
|
626
632
|
if (!nominatorMetadata.isBondedBefore) {
|
|
627
633
|
// first time
|
|
628
|
-
|
|
634
|
+
if (paramsCount === 2) {
|
|
635
|
+
bondTx = chainApi.api.tx.staking.bond(binaryAmount, bondDest);
|
|
636
|
+
} else {
|
|
637
|
+
bondTx = chainApi.api.tx.staking.bond(nominatorMetadata.address, binaryAmount, bondDest);
|
|
638
|
+
}
|
|
629
639
|
nominateTx = chainApi.api.tx.staking.nominate(validatorParamList);
|
|
630
640
|
return chainApi.api.tx.utility.batchAll([bondTx, nominateTx]);
|
|
631
641
|
} else {
|
|
@@ -218,13 +218,7 @@ function getStakingAvailableActionsByNominator(nominatorMetadata, unclaimedRewar
|
|
|
218
218
|
}
|
|
219
219
|
if (nominatorMetadata.unstakings.length > 0) {
|
|
220
220
|
result.push(StakingAction.CANCEL_UNSTAKE);
|
|
221
|
-
|
|
222
|
-
for (const unstaking of nominatorMetadata.unstakings) {
|
|
223
|
-
if (unstaking.status === _KoniTypes.UnstakingStatus.CLAIMABLE) {
|
|
224
|
-
hasClaimable = true;
|
|
225
|
-
break;
|
|
226
|
-
}
|
|
227
|
-
}
|
|
221
|
+
const hasClaimable = nominatorMetadata.unstakings.some(unstaking => unstaking.status === _KoniTypes.UnstakingStatus.CLAIMABLE);
|
|
228
222
|
if (hasClaimable) {
|
|
229
223
|
result.push(StakingAction.WITHDRAW);
|
|
230
224
|
}
|
|
@@ -25,6 +25,6 @@ function getCurrencyId(tokenInfo) {
|
|
|
25
25
|
}
|
|
26
26
|
function getExtrinsicByXtokensPallet(tokenInfo, originChainInfo, destinationChainInfo, recipientAddress, value, api) {
|
|
27
27
|
const weightParam = ['pioneer'].includes(originChainInfo.slug) ? _utils.FOUR_INSTRUCTIONS_WEIGHT : (0, _utils.getDestWeight)();
|
|
28
|
-
const destVersion = ['moonbeam', 'moonriver', 'bifrost_dot', 'interlay', 'hydradx_main'].includes(originChainInfo.slug) ? 'V3' : undefined;
|
|
28
|
+
const destVersion = ['moonbeam', 'moonriver', 'bifrost_dot', 'interlay', 'hydradx_main', 'acala'].includes(originChainInfo.slug) ? 'V3' : undefined;
|
|
29
29
|
return api.tx.xTokens.transfer(getCurrencyId(tokenInfo), value, (0, _utils.getDestMultilocation)(destinationChainInfo, recipientAddress, destVersion), weightParam);
|
|
30
30
|
}
|