@subwallet/extension-base 1.1.8-0 → 1.1.9-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/koni/api/dotsama/domain.js +3 -1
- package/cjs/koni/api/nft/acala_nft/index.js +1 -1
- package/cjs/koni/api/nft/karura_nft/index.js +1 -1
- package/cjs/koni/api/nft/nft.js +3 -0
- package/cjs/koni/api/nft/wasm_nft/index.js +25 -7
- package/cjs/koni/api/tokens/wasm/index.js +14 -0
- package/cjs/koni/background/cron.js +1 -1
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/chain-service/helper/index.js +8 -2
- package/cjs/services/wallet-connect-service/index.js +18 -10
- package/koni/api/dotsama/domain.d.ts +1 -0
- package/koni/api/dotsama/domain.js +1 -0
- package/koni/api/nft/acala_nft/index.js +1 -1
- package/koni/api/nft/karura_nft/index.js +1 -1
- package/koni/api/nft/nft.js +3 -0
- package/koni/api/nft/wasm_nft/index.js +26 -8
- package/koni/api/tokens/wasm/index.d.ts +2 -0
- package/koni/api/tokens/wasm/index.js +13 -1
- package/koni/background/cron.js +1 -1
- package/package.json +9 -7
- package/packageInfo.js +1 -1
- package/services/chain-service/helper/azero_domain_registry_abi.json +5428 -0
- package/services/chain-service/helper/index.d.ts +2 -0
- package/services/chain-service/helper/index.js +5 -1
- package/services/chain-service/helper/pink_psp34_abi.json +2758 -0
- package/services/wallet-connect-service/index.js +18 -10
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.TZERO_ID_SUFFIX = exports.SUPPORTED_DOMAIN_SUFFIX = exports.ENS_SUFFIX = exports.CHAINS_SUPPORTED_DOMAIN = exports.AZERO_ID_SUFFIX = void 0;
|
|
6
|
+
exports.TZERO_ID_SUFFIX = exports.SUPPORTED_DOMAIN_SUFFIX = exports.ENS_SUFFIX = exports.CHAINS_SUPPORTED_DOMAIN = exports.AZERO_ID_SUFFIX = exports.AZERO_DOMAIN_CONTRACTS = void 0;
|
|
7
7
|
exports.isAzeroDomain = isAzeroDomain;
|
|
8
8
|
exports.resolveAzeroAddressToDomain = resolveAzeroAddressToDomain;
|
|
9
9
|
exports.resolveAzeroDomainToAddress = resolveAzeroDomainToAddress;
|
|
@@ -21,6 +21,8 @@ const SUPPORTED_DOMAIN_SUFFIX = [ENS_SUFFIX, TZERO_ID_SUFFIX, AZERO_ID_SUFFIX];
|
|
|
21
21
|
exports.SUPPORTED_DOMAIN_SUFFIX = SUPPORTED_DOMAIN_SUFFIX;
|
|
22
22
|
const CHAINS_SUPPORTED_DOMAIN = ['aleph', 'alephTest'];
|
|
23
23
|
exports.CHAINS_SUPPORTED_DOMAIN = CHAINS_SUPPORTED_DOMAIN;
|
|
24
|
+
const AZERO_DOMAIN_CONTRACTS = ['5FsB91tXSEuMj6akzdPczAtmBaVKToqHmtAwSUzXh49AYzaD', '5CTQBfBC9SfdrCDBJdfLiyW2pg9z5W6C6Es8sK313BLnFgDf'];
|
|
25
|
+
exports.AZERO_DOMAIN_CONTRACTS = AZERO_DOMAIN_CONTRACTS;
|
|
24
26
|
async function resolveAzeroDomainToAddress(domain, chain, api) {
|
|
25
27
|
let chainId = _resolverCore.SupportedChainId.AlephZero;
|
|
26
28
|
if (chain === 'alephTest') {
|
|
@@ -143,7 +143,7 @@ const getMetadata = metadataUrl => {
|
|
|
143
143
|
if (!metadataUrl) {
|
|
144
144
|
return null;
|
|
145
145
|
}
|
|
146
|
-
url = (0, _config.getRandomIpfsGateway)() + metadataUrl + '/
|
|
146
|
+
url = (0, _config.getRandomIpfsGateway)() + metadataUrl + '/azero_domain_registry_abi.json';
|
|
147
147
|
return (0, _crossFetch.default)(url, {
|
|
148
148
|
method: 'GET',
|
|
149
149
|
headers
|
|
@@ -146,7 +146,7 @@ const getKaruraMetadata = metadataUrl => {
|
|
|
146
146
|
if (!metadataUrl) {
|
|
147
147
|
return null;
|
|
148
148
|
}
|
|
149
|
-
url = (0, _config.getRandomIpfsGateway)() + metadataUrl + '/
|
|
149
|
+
url = (0, _config.getRandomIpfsGateway)() + metadataUrl + '/azero_domain_registry_abi.json';
|
|
150
150
|
return (0, _crossFetch.default)(url, {
|
|
151
151
|
method: 'GET',
|
|
152
152
|
headers: {
|
package/cjs/koni/api/nft/nft.js
CHANGED
|
@@ -6,11 +6,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.WasmNftApi = void 0;
|
|
8
8
|
var _types = require("@subwallet/chain-list/types");
|
|
9
|
+
var _domain = require("@subwallet/extension-base/koni/api/dotsama/domain");
|
|
9
10
|
var _nft = require("@subwallet/extension-base/koni/api/nft/nft");
|
|
10
11
|
var _utils = require("@subwallet/extension-base/koni/api/nft/wasm_nft/utils");
|
|
11
12
|
var _wasm = require("@subwallet/extension-base/koni/api/tokens/wasm");
|
|
12
13
|
var _utils2 = require("@subwallet/extension-base/koni/api/tokens/wasm/utils");
|
|
13
14
|
var _utils3 = require("@subwallet/extension-base/services/chain-service/utils");
|
|
15
|
+
var _utils4 = require("@subwallet/extension-base/utils");
|
|
14
16
|
var _axios = _interopRequireDefault(require("axios"));
|
|
15
17
|
var _crossFetch = _interopRequireDefault(require("cross-fetch"));
|
|
16
18
|
var _utilCrypto = require("@polkadot/util-crypto");
|
|
@@ -76,6 +78,9 @@ class WasmNftApi extends _nft.BaseNftApi {
|
|
|
76
78
|
if (!tokenUri || tokenUri.length === 0) {
|
|
77
79
|
return undefined;
|
|
78
80
|
}
|
|
81
|
+
if ((0, _utils4.isUrl)(tokenUri)) {
|
|
82
|
+
return tokenUri;
|
|
83
|
+
}
|
|
79
84
|
if (tokenUri.startsWith('/ipfs/')) {
|
|
80
85
|
return tokenUri;
|
|
81
86
|
}
|
|
@@ -262,16 +267,19 @@ class WasmNftApi extends _nft.BaseNftApi {
|
|
|
262
267
|
owner: '',
|
|
263
268
|
name: tokenId
|
|
264
269
|
};
|
|
265
|
-
const
|
|
270
|
+
const _isFeatured = isFeatured && !_domain.AZERO_DOMAIN_CONTRACTS.includes(contractPromise.address.toString());
|
|
271
|
+
const _tokenUri = await contractPromise.query[(0, _wasm.isPinkRoboNft)(contractPromise.address.toString()) ? 'pinkMint::tokenUri' : 'psp34Traits::tokenUri'](address, {
|
|
266
272
|
gasLimit: (0, _utils2.getDefaultWeightV2)((_this$substrateApi2 = this.substrateApi) === null || _this$substrateApi2 === void 0 ? void 0 : _this$substrateApi2.api)
|
|
267
|
-
},
|
|
273
|
+
}, (0, _wasm.isAzeroDomainNft)(contractPromise.address.toString()) ? {
|
|
274
|
+
bytes: tokenId
|
|
275
|
+
} : tokenId);
|
|
268
276
|
if (_tokenUri.output) {
|
|
269
277
|
let itemDetail = false;
|
|
270
278
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
271
279
|
const _tokenUriObj = _tokenUri.output.toJSON();
|
|
272
280
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
273
|
-
const tokenUri = _tokenUriObj.Ok || _tokenUriObj.ok;
|
|
274
|
-
if (
|
|
281
|
+
const tokenUri = (0, _wasm.isPinkRoboNft)(contractPromise.address.toString()) ? _tokenUriObj.ok.ok : _tokenUriObj.Ok || _tokenUriObj.ok;
|
|
282
|
+
if (_isFeatured) {
|
|
275
283
|
const parsedTokenUri = this.parseFeaturedTokenUri(tokenUri);
|
|
276
284
|
if (parsedTokenUri) {
|
|
277
285
|
const resp = await (0, _crossFetch.default)(`${(0, _utils.ipfsApiFromArtZero)(this.chain)}?input=${parsedTokenUri}`);
|
|
@@ -283,6 +291,11 @@ class WasmNftApi extends _nft.BaseNftApi {
|
|
|
283
291
|
if (detailUrl) {
|
|
284
292
|
const resp = await (0, _crossFetch.default)(detailUrl);
|
|
285
293
|
itemDetail = resp && resp.ok && (await resp.json());
|
|
294
|
+
if (_domain.AZERO_DOMAIN_CONTRACTS.includes(contractPromise.address.toString())) {
|
|
295
|
+
var _itemDetail;
|
|
296
|
+
// @ts-ignore
|
|
297
|
+
itemDetail = (_itemDetail = itemDetail) === null || _itemDetail === void 0 ? void 0 : _itemDetail.metadata;
|
|
298
|
+
}
|
|
286
299
|
}
|
|
287
300
|
}
|
|
288
301
|
if (!itemDetail) {
|
|
@@ -292,14 +305,14 @@ class WasmNftApi extends _nft.BaseNftApi {
|
|
|
292
305
|
nftItem.description = itemDetail.description;
|
|
293
306
|
nftItem.externalUrl = itemDetail.external_url;
|
|
294
307
|
const rawImageSrc = itemDetail.image ? itemDetail.image : itemDetail.image_url;
|
|
295
|
-
if (
|
|
308
|
+
if (_isFeatured) {
|
|
296
309
|
nftItem.image = await this.parseFeaturedNftImage(rawImageSrc);
|
|
297
310
|
nftItem.externalUrl = (0, _utils.externalUrlOnArtZero)(this.chain);
|
|
298
311
|
} else {
|
|
299
312
|
nftItem.image = this.parseUrl(rawImageSrc);
|
|
300
313
|
}
|
|
301
314
|
const propertiesMap = {};
|
|
302
|
-
const traitList = itemDetail.attributes
|
|
315
|
+
const traitList = itemDetail.attributes || itemDetail.traits;
|
|
303
316
|
if (traitList) {
|
|
304
317
|
traitList.forEach(traitMap => {
|
|
305
318
|
propertiesMap[traitMap.trait_type] = {
|
|
@@ -345,8 +358,13 @@ class WasmNftApi extends _nft.BaseNftApi {
|
|
|
345
358
|
if (_tokenByIndexResp.output) {
|
|
346
359
|
const rawTokenId = _tokenByIndexResp.output.toHuman();
|
|
347
360
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
348
|
-
|
|
361
|
+
let tokenIdObj = rawTokenId.Ok.Ok || rawTokenId.ok.ok; // capital O, not normal o
|
|
349
362
|
const tokenId = Object.values(tokenIdObj)[0].replaceAll(',', '');
|
|
363
|
+
if ((0, _wasm.isAzeroDomainNft)(contractPromise.address.toString())) {
|
|
364
|
+
tokenIdObj = {
|
|
365
|
+
bytes: tokenId
|
|
366
|
+
};
|
|
367
|
+
}
|
|
350
368
|
nftIds.push(tokenId);
|
|
351
369
|
let tokenUri;
|
|
352
370
|
try {
|
|
@@ -6,6 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.getPSP22ContractPromise = getPSP22ContractPromise;
|
|
7
7
|
exports.getPSP34ContractPromise = getPSP34ContractPromise;
|
|
8
8
|
exports.getPSP34TransferExtrinsic = getPSP34TransferExtrinsic;
|
|
9
|
+
exports.isAzeroDomainNft = isAzeroDomainNft;
|
|
10
|
+
exports.isPinkRoboNft = isPinkRoboNft;
|
|
9
11
|
var _utils = require("@subwallet/extension-base/koni/api/tokens/wasm/utils");
|
|
10
12
|
var _helper = require("@subwallet/extension-base/services/chain-service/helper");
|
|
11
13
|
var _apiContract = require("@polkadot/api-contract");
|
|
@@ -15,7 +17,19 @@ var _apiContract = require("@polkadot/api-contract");
|
|
|
15
17
|
function getPSP22ContractPromise(apiPromise, contractAddress) {
|
|
16
18
|
return new _apiContract.ContractPromise(apiPromise, _helper._PSP22_ABI, contractAddress);
|
|
17
19
|
}
|
|
20
|
+
function isPinkRoboNft(contractAddress) {
|
|
21
|
+
return ['XoywUxTTtNKPRrRN7V5KXCqz2QLMFeK7DxhpSniqZHps5Xq'].includes(contractAddress);
|
|
22
|
+
}
|
|
23
|
+
function isAzeroDomainNft(contractAddress) {
|
|
24
|
+
return ['5FsB91tXSEuMj6akzdPczAtmBaVKToqHmtAwSUzXh49AYzaD', '5CTQBfBC9SfdrCDBJdfLiyW2pg9z5W6C6Es8sK313BLnFgDf'].includes(contractAddress);
|
|
25
|
+
}
|
|
18
26
|
function getPSP34ContractPromise(apiPromise, contractAddress) {
|
|
27
|
+
if (isPinkRoboNft(contractAddress)) {
|
|
28
|
+
return new _apiContract.ContractPromise(apiPromise, _helper._PINK_PSP34_ABI, contractAddress);
|
|
29
|
+
}
|
|
30
|
+
if (isAzeroDomainNft(contractAddress)) {
|
|
31
|
+
return new _apiContract.ContractPromise(apiPromise, _helper._AZERO_DOMAIN_REGISTRY_ABI, contractAddress);
|
|
32
|
+
}
|
|
19
33
|
return new _apiContract.ContractPromise(apiPromise, _helper._PSP34_ABI, contractAddress);
|
|
20
34
|
}
|
|
21
35
|
const mustFormatNumberReg = /^-?[0-9][0-9,.]+$/;
|
|
@@ -116,7 +116,7 @@ class KoniCron {
|
|
|
116
116
|
this.resetNft(currentAccountInfo.address);
|
|
117
117
|
this.addCron('refreshNft', this.refreshNft(currentAccountInfo.address, this.state.getApiMap(), this.state.getSmartContractNfts(), this.state.getActiveChainInfoMap()), _constants.CRON_REFRESH_NFT_INTERVAL);
|
|
118
118
|
this.addCron('refreshStakingReward', this.refreshStakingReward(currentAccountInfo.address), _constants.CRON_REFRESH_STAKING_REWARD_INTERVAL);
|
|
119
|
-
this.addCron('
|
|
119
|
+
this.addCron('refreshPoolingSta kingReward', this.refreshStakingRewardFastInterval(currentAccountInfo.address), _constants.CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL);
|
|
120
120
|
this.addCron('syncMantaPay', this.syncMantaPay, _constants.CRON_SYNC_MANTA_PAY);
|
|
121
121
|
} else {
|
|
122
122
|
this.setStakingRewardReady();
|
package/cjs/packageInfo.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports._TEST_ERC721_ABI = exports._PSP34_ABI = exports._PSP22_ABI = exports._ERC721_ABI = exports._ERC20_ABI = void 0;
|
|
6
|
+
exports._TEST_ERC721_ABI = exports._PSP34_ABI = exports._PSP22_ABI = exports._PINK_PSP34_ABI = exports._ERC721_ABI = exports._ERC20_ABI = exports._AZERO_DOMAIN_REGISTRY_ABI = void 0;
|
|
7
7
|
// Copyright 2019-2022 @subwallet/extension-base
|
|
8
8
|
// SPDX-License-Identifier: Apache-2.0
|
|
9
9
|
|
|
@@ -21,4 +21,10 @@ const _PSP22_ABI = require('./psp22_abi.json');
|
|
|
21
21
|
// eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
|
|
22
22
|
exports._PSP22_ABI = _PSP22_ABI;
|
|
23
23
|
const _PSP34_ABI = require('./psp34_abi.json');
|
|
24
|
-
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
|
|
25
|
+
exports._PSP34_ABI = _PSP34_ABI;
|
|
26
|
+
const _PINK_PSP34_ABI = require('./pink_psp34_abi.json');
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
|
|
28
|
+
exports._PINK_PSP34_ABI = _PINK_PSP34_ABI;
|
|
29
|
+
const _AZERO_DOMAIN_REGISTRY_ABI = require('./azero_domain_registry_abi.json');
|
|
30
|
+
exports._AZERO_DOMAIN_REGISTRY_ABI = _AZERO_DOMAIN_REGISTRY_ABI;
|
|
@@ -145,21 +145,29 @@ class WalletConnectService {
|
|
|
145
145
|
// Disconnect session
|
|
146
146
|
const sessions = ((_classPrivateFieldLoo7 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo7 === void 0 ? void 0 : _classPrivateFieldLoo7.session.values) || [];
|
|
147
147
|
for (const session of sessions) {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
148
|
+
try {
|
|
149
|
+
var _classPrivateFieldLoo8;
|
|
150
|
+
await ((_classPrivateFieldLoo8 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo8 === void 0 ? void 0 : _classPrivateFieldLoo8.disconnect({
|
|
151
|
+
topic: session.topic,
|
|
152
|
+
reason: (0, _utils2.getSdkError)('USER_DISCONNECTED')
|
|
153
|
+
}));
|
|
154
|
+
} catch (e) {
|
|
155
|
+
console.error(e);
|
|
156
|
+
}
|
|
153
157
|
}
|
|
154
158
|
|
|
155
159
|
// Disconnect pair
|
|
156
160
|
const pairs = ((_classPrivateFieldLoo9 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo9 === void 0 ? void 0 : _classPrivateFieldLoo9.pairing.values) || [];
|
|
157
161
|
for (const pair of pairs) {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
162
|
+
try {
|
|
163
|
+
var _classPrivateFieldLoo10;
|
|
164
|
+
await ((_classPrivateFieldLoo10 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo10 === void 0 ? void 0 : _classPrivateFieldLoo10.disconnect({
|
|
165
|
+
topic: pair.topic,
|
|
166
|
+
reason: (0, _utils2.getSdkError)('USER_DISCONNECTED')
|
|
167
|
+
}));
|
|
168
|
+
} catch (e) {
|
|
169
|
+
console.error(e);
|
|
170
|
+
}
|
|
163
171
|
}
|
|
164
172
|
const keys = (await ((_classPrivateFieldLoo11 = (0, _classPrivateFieldLooseBase2.default)(this, _client)[_client]) === null || _classPrivateFieldLoo11 === void 0 ? void 0 : _classPrivateFieldLoo11.core.storage.getKeys())) || [];
|
|
165
173
|
const deleteKeys = resetAll ? keys : keys.filter(key => key.startsWith('wc@'));
|
|
@@ -4,6 +4,7 @@ export declare const TZERO_ID_SUFFIX = ".tzero";
|
|
|
4
4
|
export declare const AZERO_ID_SUFFIX = ".azero";
|
|
5
5
|
export declare const SUPPORTED_DOMAIN_SUFFIX: string[];
|
|
6
6
|
export declare const CHAINS_SUPPORTED_DOMAIN: string[];
|
|
7
|
+
export declare const AZERO_DOMAIN_CONTRACTS: string[];
|
|
7
8
|
export declare function resolveAzeroDomainToAddress(domain: string, chain: string, api: ApiPromise): Promise<string | undefined>;
|
|
8
9
|
export declare function resolveAzeroAddressToDomain(address: string, chain: string, api: ApiPromise): Promise<string | undefined>;
|
|
9
10
|
export declare function isAzeroDomain(input: string): boolean;
|
|
@@ -7,6 +7,7 @@ export const TZERO_ID_SUFFIX = '.tzero';
|
|
|
7
7
|
export const AZERO_ID_SUFFIX = '.azero';
|
|
8
8
|
export const SUPPORTED_DOMAIN_SUFFIX = [ENS_SUFFIX, TZERO_ID_SUFFIX, AZERO_ID_SUFFIX];
|
|
9
9
|
export const CHAINS_SUPPORTED_DOMAIN = ['aleph', 'alephTest'];
|
|
10
|
+
export const AZERO_DOMAIN_CONTRACTS = ['5FsB91tXSEuMj6akzdPczAtmBaVKToqHmtAwSUzXh49AYzaD', '5CTQBfBC9SfdrCDBJdfLiyW2pg9z5W6C6Es8sK313BLnFgDf'];
|
|
10
11
|
export async function resolveAzeroDomainToAddress(domain, chain, api) {
|
|
11
12
|
let chainId = SupportedChainId.AlephZero;
|
|
12
13
|
if (chain === 'alephTest') {
|
|
@@ -135,7 +135,7 @@ const getMetadata = metadataUrl => {
|
|
|
135
135
|
if (!metadataUrl) {
|
|
136
136
|
return null;
|
|
137
137
|
}
|
|
138
|
-
url = getRandomIpfsGateway() + metadataUrl + '/
|
|
138
|
+
url = getRandomIpfsGateway() + metadataUrl + '/azero_domain_registry_abi.json';
|
|
139
139
|
return fetch(url, {
|
|
140
140
|
method: 'GET',
|
|
141
141
|
headers
|
|
@@ -137,7 +137,7 @@ const getKaruraMetadata = metadataUrl => {
|
|
|
137
137
|
if (!metadataUrl) {
|
|
138
138
|
return null;
|
|
139
139
|
}
|
|
140
|
-
url = getRandomIpfsGateway() + metadataUrl + '/
|
|
140
|
+
url = getRandomIpfsGateway() + metadataUrl + '/azero_domain_registry_abi.json';
|
|
141
141
|
return fetch(url, {
|
|
142
142
|
method: 'GET',
|
|
143
143
|
headers: {
|
package/koni/api/nft/nft.js
CHANGED
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { _AssetType } from '@subwallet/chain-list/types';
|
|
5
|
+
import { AZERO_DOMAIN_CONTRACTS } from '@subwallet/extension-base/koni/api/dotsama/domain';
|
|
5
6
|
import { BaseNftApi } from '@subwallet/extension-base/koni/api/nft/nft';
|
|
6
7
|
import { collectionApiFromArtZero, collectionDetailApiFromArtZero, externalUrlOnArtZero, ipfsApiFromArtZero, itemImageApiFromArtZero } from '@subwallet/extension-base/koni/api/nft/wasm_nft/utils';
|
|
7
|
-
import { getPSP34ContractPromise } from '@subwallet/extension-base/koni/api/tokens/wasm';
|
|
8
|
+
import { getPSP34ContractPromise, isAzeroDomainNft, isPinkRoboNft } from '@subwallet/extension-base/koni/api/tokens/wasm';
|
|
8
9
|
import { getDefaultWeightV2 } from '@subwallet/extension-base/koni/api/tokens/wasm/utils';
|
|
9
10
|
import { _getContractAddressOfToken } from '@subwallet/extension-base/services/chain-service/utils';
|
|
11
|
+
import { isUrl } from '@subwallet/extension-base/utils';
|
|
10
12
|
import axios from 'axios';
|
|
11
13
|
import fetch from 'cross-fetch';
|
|
12
14
|
import { isEthereumAddress } from '@polkadot/util-crypto';
|
|
@@ -70,6 +72,9 @@ export class WasmNftApi extends BaseNftApi {
|
|
|
70
72
|
if (!tokenUri || tokenUri.length === 0) {
|
|
71
73
|
return undefined;
|
|
72
74
|
}
|
|
75
|
+
if (isUrl(tokenUri)) {
|
|
76
|
+
return tokenUri;
|
|
77
|
+
}
|
|
73
78
|
if (tokenUri.startsWith('/ipfs/')) {
|
|
74
79
|
return tokenUri;
|
|
75
80
|
}
|
|
@@ -256,16 +261,19 @@ export class WasmNftApi extends BaseNftApi {
|
|
|
256
261
|
owner: '',
|
|
257
262
|
name: tokenId
|
|
258
263
|
};
|
|
259
|
-
const
|
|
264
|
+
const _isFeatured = isFeatured && !AZERO_DOMAIN_CONTRACTS.includes(contractPromise.address.toString());
|
|
265
|
+
const _tokenUri = await contractPromise.query[isPinkRoboNft(contractPromise.address.toString()) ? 'pinkMint::tokenUri' : 'psp34Traits::tokenUri'](address, {
|
|
260
266
|
gasLimit: getDefaultWeightV2((_this$substrateApi2 = this.substrateApi) === null || _this$substrateApi2 === void 0 ? void 0 : _this$substrateApi2.api)
|
|
261
|
-
},
|
|
267
|
+
}, isAzeroDomainNft(contractPromise.address.toString()) ? {
|
|
268
|
+
bytes: tokenId
|
|
269
|
+
} : tokenId);
|
|
262
270
|
if (_tokenUri.output) {
|
|
263
271
|
let itemDetail = false;
|
|
264
272
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
265
273
|
const _tokenUriObj = _tokenUri.output.toJSON();
|
|
266
274
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
267
|
-
const tokenUri = _tokenUriObj.Ok || _tokenUriObj.ok;
|
|
268
|
-
if (
|
|
275
|
+
const tokenUri = isPinkRoboNft(contractPromise.address.toString()) ? _tokenUriObj.ok.ok : _tokenUriObj.Ok || _tokenUriObj.ok;
|
|
276
|
+
if (_isFeatured) {
|
|
269
277
|
const parsedTokenUri = this.parseFeaturedTokenUri(tokenUri);
|
|
270
278
|
if (parsedTokenUri) {
|
|
271
279
|
const resp = await fetch(`${ipfsApiFromArtZero(this.chain)}?input=${parsedTokenUri}`);
|
|
@@ -277,6 +285,11 @@ export class WasmNftApi extends BaseNftApi {
|
|
|
277
285
|
if (detailUrl) {
|
|
278
286
|
const resp = await fetch(detailUrl);
|
|
279
287
|
itemDetail = resp && resp.ok && (await resp.json());
|
|
288
|
+
if (AZERO_DOMAIN_CONTRACTS.includes(contractPromise.address.toString())) {
|
|
289
|
+
var _itemDetail;
|
|
290
|
+
// @ts-ignore
|
|
291
|
+
itemDetail = (_itemDetail = itemDetail) === null || _itemDetail === void 0 ? void 0 : _itemDetail.metadata;
|
|
292
|
+
}
|
|
280
293
|
}
|
|
281
294
|
}
|
|
282
295
|
if (!itemDetail) {
|
|
@@ -286,14 +299,14 @@ export class WasmNftApi extends BaseNftApi {
|
|
|
286
299
|
nftItem.description = itemDetail.description;
|
|
287
300
|
nftItem.externalUrl = itemDetail.external_url;
|
|
288
301
|
const rawImageSrc = itemDetail.image ? itemDetail.image : itemDetail.image_url;
|
|
289
|
-
if (
|
|
302
|
+
if (_isFeatured) {
|
|
290
303
|
nftItem.image = await this.parseFeaturedNftImage(rawImageSrc);
|
|
291
304
|
nftItem.externalUrl = externalUrlOnArtZero(this.chain);
|
|
292
305
|
} else {
|
|
293
306
|
nftItem.image = this.parseUrl(rawImageSrc);
|
|
294
307
|
}
|
|
295
308
|
const propertiesMap = {};
|
|
296
|
-
const traitList = itemDetail.attributes
|
|
309
|
+
const traitList = itemDetail.attributes || itemDetail.traits;
|
|
297
310
|
if (traitList) {
|
|
298
311
|
traitList.forEach(traitMap => {
|
|
299
312
|
propertiesMap[traitMap.trait_type] = {
|
|
@@ -339,8 +352,13 @@ export class WasmNftApi extends BaseNftApi {
|
|
|
339
352
|
if (_tokenByIndexResp.output) {
|
|
340
353
|
const rawTokenId = _tokenByIndexResp.output.toHuman();
|
|
341
354
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
342
|
-
|
|
355
|
+
let tokenIdObj = rawTokenId.Ok.Ok || rawTokenId.ok.ok; // capital O, not normal o
|
|
343
356
|
const tokenId = Object.values(tokenIdObj)[0].replaceAll(',', '');
|
|
357
|
+
if (isAzeroDomainNft(contractPromise.address.toString())) {
|
|
358
|
+
tokenIdObj = {
|
|
359
|
+
bytes: tokenId
|
|
360
|
+
};
|
|
361
|
+
}
|
|
344
362
|
nftIds.push(tokenId);
|
|
345
363
|
let tokenUri;
|
|
346
364
|
try {
|
|
@@ -2,5 +2,7 @@ import { _SubstrateApi } from '@subwallet/extension-base/services/chain-service/
|
|
|
2
2
|
import { ApiPromise } from '@polkadot/api';
|
|
3
3
|
import { ContractPromise } from '@polkadot/api-contract';
|
|
4
4
|
export declare function getPSP22ContractPromise(apiPromise: ApiPromise, contractAddress: string): ContractPromise;
|
|
5
|
+
export declare function isPinkRoboNft(contractAddress: string): boolean;
|
|
6
|
+
export declare function isAzeroDomainNft(contractAddress: string): boolean;
|
|
5
7
|
export declare function getPSP34ContractPromise(apiPromise: ApiPromise, contractAddress: string): ContractPromise;
|
|
6
8
|
export declare function getPSP34TransferExtrinsic(networkKey: string, substrateApi: _SubstrateApi, senderAddress: string, recipientAddress: string, params: Record<string, any>): Promise<import("@polkadot/api-base/types").SubmittableExtrinsic<"promise", import("@polkadot/types/types").ISubmittableResult> | null>;
|
|
@@ -2,12 +2,24 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { getWasmContractGasLimit } from '@subwallet/extension-base/koni/api/tokens/wasm/utils';
|
|
5
|
-
import { _PSP22_ABI, _PSP34_ABI } from '@subwallet/extension-base/services/chain-service/helper';
|
|
5
|
+
import { _AZERO_DOMAIN_REGISTRY_ABI, _PINK_PSP34_ABI, _PSP22_ABI, _PSP34_ABI } from '@subwallet/extension-base/services/chain-service/helper';
|
|
6
6
|
import { ContractPromise } from '@polkadot/api-contract';
|
|
7
7
|
export function getPSP22ContractPromise(apiPromise, contractAddress) {
|
|
8
8
|
return new ContractPromise(apiPromise, _PSP22_ABI, contractAddress);
|
|
9
9
|
}
|
|
10
|
+
export function isPinkRoboNft(contractAddress) {
|
|
11
|
+
return ['XoywUxTTtNKPRrRN7V5KXCqz2QLMFeK7DxhpSniqZHps5Xq'].includes(contractAddress);
|
|
12
|
+
}
|
|
13
|
+
export function isAzeroDomainNft(contractAddress) {
|
|
14
|
+
return ['5FsB91tXSEuMj6akzdPczAtmBaVKToqHmtAwSUzXh49AYzaD', '5CTQBfBC9SfdrCDBJdfLiyW2pg9z5W6C6Es8sK313BLnFgDf'].includes(contractAddress);
|
|
15
|
+
}
|
|
10
16
|
export function getPSP34ContractPromise(apiPromise, contractAddress) {
|
|
17
|
+
if (isPinkRoboNft(contractAddress)) {
|
|
18
|
+
return new ContractPromise(apiPromise, _PINK_PSP34_ABI, contractAddress);
|
|
19
|
+
}
|
|
20
|
+
if (isAzeroDomainNft(contractAddress)) {
|
|
21
|
+
return new ContractPromise(apiPromise, _AZERO_DOMAIN_REGISTRY_ABI, contractAddress);
|
|
22
|
+
}
|
|
11
23
|
return new ContractPromise(apiPromise, _PSP34_ABI, contractAddress);
|
|
12
24
|
}
|
|
13
25
|
const mustFormatNumberReg = /^-?[0-9][0-9,.]+$/;
|
package/koni/background/cron.js
CHANGED
|
@@ -105,7 +105,7 @@ export class KoniCron {
|
|
|
105
105
|
this.resetNft(currentAccountInfo.address);
|
|
106
106
|
this.addCron('refreshNft', this.refreshNft(currentAccountInfo.address, this.state.getApiMap(), this.state.getSmartContractNfts(), this.state.getActiveChainInfoMap()), CRON_REFRESH_NFT_INTERVAL);
|
|
107
107
|
this.addCron('refreshStakingReward', this.refreshStakingReward(currentAccountInfo.address), CRON_REFRESH_STAKING_REWARD_INTERVAL);
|
|
108
|
-
this.addCron('
|
|
108
|
+
this.addCron('refreshPoolingSta kingReward', this.refreshStakingRewardFastInterval(currentAccountInfo.address), CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL);
|
|
109
109
|
this.addCron('syncMantaPay', this.syncMantaPay, CRON_SYNC_MANTA_PAY);
|
|
110
110
|
} else {
|
|
111
111
|
this.setStakingRewardReady();
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"./cjs/detectPackage.js"
|
|
18
18
|
],
|
|
19
19
|
"type": "module",
|
|
20
|
-
"version": "1.1.
|
|
20
|
+
"version": "1.1.9-0",
|
|
21
21
|
"main": "./cjs/index.js",
|
|
22
22
|
"module": "./index.js",
|
|
23
23
|
"types": "./index.d.ts",
|
|
@@ -575,8 +575,10 @@
|
|
|
575
575
|
"require": "./cjs/services/chain-service/helper/api-helper/spec/dataavail.js",
|
|
576
576
|
"default": "./services/chain-service/helper/api-helper/spec/dataavail.js"
|
|
577
577
|
},
|
|
578
|
+
"./services/chain-service/helper/azero_domain_registry_abi.json": "./services/chain-service/helper/azero_domain_registry_abi.json",
|
|
578
579
|
"./services/chain-service/helper/erc20_abi.json": "./services/chain-service/helper/erc20_abi.json",
|
|
579
580
|
"./services/chain-service/helper/erc721_abi.json": "./services/chain-service/helper/erc721_abi.json",
|
|
581
|
+
"./services/chain-service/helper/pink_psp34_abi.json": "./services/chain-service/helper/pink_psp34_abi.json",
|
|
580
582
|
"./services/chain-service/helper/psp22_abi.json": "./services/chain-service/helper/psp22_abi.json",
|
|
581
583
|
"./services/chain-service/helper/psp34_abi.json": "./services/chain-service/helper/psp34_abi.json",
|
|
582
584
|
"./services/chain-service/helper/test_erc721_abi.json": "./services/chain-service/helper/test_erc721_abi.json",
|
|
@@ -1174,7 +1176,7 @@
|
|
|
1174
1176
|
"dependencies": {
|
|
1175
1177
|
"@acala-network/api": "^5.0.2",
|
|
1176
1178
|
"@apollo/client": "^3.7.14",
|
|
1177
|
-
"@azns/resolver-core": "^1.
|
|
1179
|
+
"@azns/resolver-core": "^1.4.0",
|
|
1178
1180
|
"@equilab/api": "^1.14.25",
|
|
1179
1181
|
"@ethereumjs/common": "^2.6.5",
|
|
1180
1182
|
"@ethereumjs/tx": "^4.0.2",
|
|
@@ -1199,11 +1201,11 @@
|
|
|
1199
1201
|
"@reduxjs/toolkit": "^1.9.1",
|
|
1200
1202
|
"@sora-substrate/type-definitions": "^1.17.7",
|
|
1201
1203
|
"@substrate/connect": "^0.7.26",
|
|
1202
|
-
"@subwallet/chain-list": "0.2.
|
|
1203
|
-
"@subwallet/extension-base": "^1.1.
|
|
1204
|
-
"@subwallet/extension-chains": "^1.1.
|
|
1205
|
-
"@subwallet/extension-dapp": "^1.1.
|
|
1206
|
-
"@subwallet/extension-inject": "^1.1.
|
|
1204
|
+
"@subwallet/chain-list": "0.2.11-beta.0",
|
|
1205
|
+
"@subwallet/extension-base": "^1.1.9-0",
|
|
1206
|
+
"@subwallet/extension-chains": "^1.1.9-0",
|
|
1207
|
+
"@subwallet/extension-dapp": "^1.1.9-0",
|
|
1208
|
+
"@subwallet/extension-inject": "^1.1.9-0",
|
|
1207
1209
|
"@subwallet/keyring": "^0.0.10",
|
|
1208
1210
|
"@subwallet/ui-keyring": "^0.0.10",
|
|
1209
1211
|
"@walletconnect/sign-client": "^2.8.4",
|
package/packageInfo.js
CHANGED
|
@@ -7,5 +7,5 @@ export const packageInfo = {
|
|
|
7
7
|
name: '@subwallet/extension-base',
|
|
8
8
|
path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto',
|
|
9
9
|
type: 'esm',
|
|
10
|
-
version: '1.1.
|
|
10
|
+
version: '1.1.9-0'
|
|
11
11
|
};
|