@subwallet/extension-base 1.1.18-0 → 1.1.19-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/transfer.js +1 -1
- package/cjs/koni/api/nft/acala_nft/index.js +1 -1
- package/cjs/koni/api/nft/config.js +21 -1
- package/cjs/koni/api/nft/karura_nft/index.js +1 -1
- package/cjs/koni/api/nft/vara_nft/index.js +19 -17
- package/cjs/koni/background/handlers/Extension.js +12 -8
- package/cjs/koni/background/handlers/State.js +3 -0
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/chain-service/index.js +27 -5
- package/cjs/services/storage-service/db-stores/Crowdloan.js +14 -0
- package/koni/api/dotsama/transfer.js +1 -1
- package/koni/api/nft/acala_nft/index.js +1 -1
- package/koni/api/nft/config.d.ts +4 -0
- package/koni/api/nft/config.js +16 -0
- package/koni/api/nft/karura_nft/index.js +1 -1
- package/koni/api/nft/vara_nft/index.js +19 -17
- package/koni/background/handlers/Extension.js +12 -8
- package/koni/background/handlers/State.js +3 -0
- package/package.json +7 -6
- package/packageInfo.js +1 -1
- package/services/chain-service/index.js +28 -6
- package/services/storage-service/db-stores/Crowdloan.d.ts +1 -0
- package/services/storage-service/db-stores/Crowdloan.js +14 -0
|
@@ -190,7 +190,7 @@ const createTransferExtrinsic = async _ref => {
|
|
|
190
190
|
if (transferAll) {
|
|
191
191
|
transfer = api.tx.balances.transferAll(to, false);
|
|
192
192
|
} else if (value) {
|
|
193
|
-
transfer = api.tx.balances.
|
|
193
|
+
transfer = api.tx.balances.transferKeepAlive(to, new _util.BN(value));
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
196
|
return [transfer, transferAmount || value];
|
|
@@ -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 + '/metadata.json';
|
|
147
147
|
return (0, _crossFetch.default)(url, {
|
|
148
148
|
method: 'GET',
|
|
149
149
|
headers
|
|
@@ -1,11 +1,13 @@
|
|
|
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
|
});
|
|
6
|
-
exports.VARA_SCAN_ENDPOINT = 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_W3S_LINK = exports.IPFS_IO = exports.IPFS_GATEWAY_4EVERLAND = 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
|
+
exports.W3S_IPFS = exports.VARA_SCAN_ENDPOINT = 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.SUBWALLET_IPFS = 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_W3S_LINK = exports.IPFS_IO = exports.IPFS_GATEWAY_4EVERLAND = exports.IPFS_FLEEK = exports.IPFS_ETH_ARAGON = exports.IPFS2_RMRK = 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
8
|
exports.getRandomIpfsGateway = getRandomIpfsGateway;
|
|
8
9
|
var _utils = require("@subwallet/extension-base/utils");
|
|
10
|
+
var _bowser = _interopRequireDefault(require("bowser"));
|
|
9
11
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
10
12
|
// SPDX-License-Identifier: Apache-2.0
|
|
11
13
|
|
|
@@ -59,6 +61,18 @@ const IPFS_GATEWAY_4EVERLAND = 'https://4everland.io/ipfs/';
|
|
|
59
61
|
exports.IPFS_GATEWAY_4EVERLAND = IPFS_GATEWAY_4EVERLAND;
|
|
60
62
|
const IPFS_FLEEK = 'https://ipfs.fleek.co/ipfs/';
|
|
61
63
|
exports.IPFS_FLEEK = IPFS_FLEEK;
|
|
64
|
+
const W3S_IPFS = 'https://w3s.link/ipfs/'; // 400
|
|
65
|
+
exports.W3S_IPFS = W3S_IPFS;
|
|
66
|
+
const IPFS2_RMRK = 'https://ipfs2.rmrk.link/ipfs/'; // ????
|
|
67
|
+
exports.IPFS2_RMRK = IPFS2_RMRK;
|
|
68
|
+
const IPFS_ETH_ARAGON = 'https://ipfs.eth.aragon.network/ipfs/'; // 400
|
|
69
|
+
exports.IPFS_ETH_ARAGON = IPFS_ETH_ARAGON;
|
|
70
|
+
const SUBWALLET_IPFS = 'https://ipfs.subwallet.app/ipfs/'; // ???
|
|
71
|
+
exports.SUBWALLET_IPFS = SUBWALLET_IPFS;
|
|
72
|
+
const detectFirefox = () => {
|
|
73
|
+
return (localStorage.getItem('browserInfo') || _bowser.default.getParser(window.navigator.userAgent).getBrowserName()).toLowerCase() === 'firefox';
|
|
74
|
+
};
|
|
75
|
+
const isFirefox = detectFirefox();
|
|
62
76
|
let SUPPORTED_NFT_NETWORKS;
|
|
63
77
|
exports.SUPPORTED_NFT_NETWORKS = SUPPORTED_NFT_NETWORKS;
|
|
64
78
|
(function (SUPPORTED_NFT_NETWORKS) {
|
|
@@ -128,6 +142,12 @@ const RANDOM_IPFS_GATEWAY_SETTING = [{
|
|
|
128
142
|
provider: NFT_STORAGE_GATEWAY,
|
|
129
143
|
weight: 50
|
|
130
144
|
}];
|
|
145
|
+
if (isFirefox) {
|
|
146
|
+
RANDOM_IPFS_GATEWAY_SETTING.push({
|
|
147
|
+
provider: SUBWALLET_IPFS,
|
|
148
|
+
weight: 5000
|
|
149
|
+
});
|
|
150
|
+
}
|
|
131
151
|
if (!_utils.RuntimeInfo.protocol || _utils.RuntimeInfo.protocol && !_utils.RuntimeInfo.protocol.startsWith('http')) {
|
|
132
152
|
RANDOM_IPFS_GATEWAY_SETTING.push({
|
|
133
153
|
provider: IPFS_FLEEK,
|
|
@@ -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 + '/metadata.json';
|
|
150
150
|
return (0, _crossFetch.default)(url, {
|
|
151
151
|
method: 'GET',
|
|
152
152
|
headers: {
|
|
@@ -72,23 +72,25 @@ class VaraNftApi extends _nft.BaseNftApi {
|
|
|
72
72
|
try {
|
|
73
73
|
await Promise.all(this.addresses.map(async address => {
|
|
74
74
|
const nfts = await this.getNftByAccount(address);
|
|
75
|
-
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
75
|
+
if (nfts) {
|
|
76
|
+
for (const nft of nfts) {
|
|
77
|
+
const parsedNft = {
|
|
78
|
+
id: nft.tokenId,
|
|
79
|
+
chain: this.chain,
|
|
80
|
+
owner: address,
|
|
81
|
+
name: nft.name,
|
|
82
|
+
image: this.parseUrl(nft.mediaUrl),
|
|
83
|
+
description: nft.description,
|
|
84
|
+
collectionId: nft.collection.id
|
|
85
|
+
};
|
|
86
|
+
const parsedCollection = {
|
|
87
|
+
collectionId: nft.collection.id,
|
|
88
|
+
chain: this.chain,
|
|
89
|
+
collectionName: nft.collection.name
|
|
90
|
+
};
|
|
91
|
+
params.updateItem(this.chain, parsedNft, address);
|
|
92
|
+
params.updateCollection(this.chain, parsedCollection);
|
|
93
|
+
}
|
|
92
94
|
}
|
|
93
95
|
}));
|
|
94
96
|
} catch (e) {
|
|
@@ -1625,7 +1625,7 @@ class KoniExtension {
|
|
|
1625
1625
|
if (new _bignumber.default(receiverBalance).plus(transferAmount.value).lt(minAmount)) {
|
|
1626
1626
|
const atLeast = new _bignumber.default(minAmount).minus(receiverBalance).plus((tokenInfo.decimals || 0) === 0 ? 0 : 1);
|
|
1627
1627
|
const atLeastStr = (0, _number.formatNumber)(atLeast, tokenInfo.decimals || 0, _number.balanceFormatter);
|
|
1628
|
-
inputTransaction.errors.push(new _TransactionError.TransactionError(_KoniTypes.TransferTxErrorType.RECEIVER_NOT_ENOUGH_EXISTENTIAL_DEPOSIT, (0, _i18next.t)('You must transfer at least {{amount}}{{symbol}} to keep the destination account alive', {
|
|
1628
|
+
inputTransaction.errors.push(new _TransactionError.TransactionError(_KoniTypes.TransferTxErrorType.RECEIVER_NOT_ENOUGH_EXISTENTIAL_DEPOSIT, (0, _i18next.t)('You must transfer at least {{amount}} {{symbol}} to keep the destination account alive', {
|
|
1629
1629
|
replace: {
|
|
1630
1630
|
amount: atLeastStr,
|
|
1631
1631
|
symbol: tokenInfo.symbol
|
|
@@ -1694,7 +1694,7 @@ class KoniExtension {
|
|
|
1694
1694
|
// Check ed for receiver
|
|
1695
1695
|
if (new _bignumber.default(value).lt(atLeast)) {
|
|
1696
1696
|
const atLeastStr = (0, _number.formatNumber)(atLeast, destinationTokenInfo.decimals || 0, _number.balanceFormatter);
|
|
1697
|
-
inputTransaction.errors.push(new _TransactionError.TransactionError(_KoniTypes.TransferTxErrorType.RECEIVER_NOT_ENOUGH_EXISTENTIAL_DEPOSIT, (0, _i18next.t)('You must transfer at least {{amount}}{{symbol}} to keep the destination account alive', {
|
|
1697
|
+
inputTransaction.errors.push(new _TransactionError.TransactionError(_KoniTypes.TransferTxErrorType.RECEIVER_NOT_ENOUGH_EXISTENTIAL_DEPOSIT, (0, _i18next.t)('You must transfer at least {{amount}} {{symbol}} to keep the destination account alive', {
|
|
1698
1698
|
replace: {
|
|
1699
1699
|
amount: atLeastStr,
|
|
1700
1700
|
symbol: originTokenInfo.symbol
|
|
@@ -1884,7 +1884,6 @@ class KoniExtension {
|
|
|
1884
1884
|
if (!destinationTokenInfo) {
|
|
1885
1885
|
estimatedFee = '0';
|
|
1886
1886
|
} else {
|
|
1887
|
-
var _paymentInfo$partialF;
|
|
1888
1887
|
maxTransferable = maxTransferable.sub(new _util.BN(tokenInfo.minAmount || '0'));
|
|
1889
1888
|
const desChainInfo = chainInfoMap[destChain];
|
|
1890
1889
|
const orgChainInfo = chainInfoMap[networkKey];
|
|
@@ -1894,11 +1893,16 @@ class KoniExtension {
|
|
|
1894
1893
|
destinationTokenInfo,
|
|
1895
1894
|
originTokenInfo: tokenInfo,
|
|
1896
1895
|
recipient: recipient,
|
|
1897
|
-
sendingValue: '
|
|
1896
|
+
sendingValue: '1000000000000000000',
|
|
1898
1897
|
substrateApi
|
|
1899
1898
|
});
|
|
1900
|
-
|
|
1901
|
-
|
|
1899
|
+
try {
|
|
1900
|
+
var _paymentInfo$partialF;
|
|
1901
|
+
const paymentInfo = await mockTx.paymentInfo(address);
|
|
1902
|
+
estimatedFee = (paymentInfo === null || paymentInfo === void 0 ? void 0 : (_paymentInfo$partialF = paymentInfo.partialFee) === null || _paymentInfo$partialF === void 0 ? void 0 : _paymentInfo$partialF.toString()) || '0';
|
|
1903
|
+
} catch (e) {
|
|
1904
|
+
estimatedFee = tokenInfo.minAmount || '0';
|
|
1905
|
+
}
|
|
1902
1906
|
}
|
|
1903
1907
|
} else {
|
|
1904
1908
|
const chainInfo = this.#koniState.chainService.getChainInfoByKey(networkKey);
|
|
@@ -1922,7 +1926,7 @@ class KoniExtension {
|
|
|
1922
1926
|
to: address,
|
|
1923
1927
|
tokenInfo,
|
|
1924
1928
|
transferAll: true,
|
|
1925
|
-
value: '
|
|
1929
|
+
value: '1000000000000000000'
|
|
1926
1930
|
});
|
|
1927
1931
|
const paymentInfo = await (mockTx === null || mockTx === void 0 ? void 0 : mockTx.paymentInfo(address));
|
|
1928
1932
|
estimatedFee = (paymentInfo === null || paymentInfo === void 0 ? void 0 : (_paymentInfo$partialF2 = paymentInfo.partialFee) === null || _paymentInfo$partialF2 === void 0 ? void 0 : _paymentInfo$partialF2.toString()) || '0';
|
|
@@ -2777,7 +2781,7 @@ class KoniExtension {
|
|
|
2777
2781
|
} = _ref65;
|
|
2778
2782
|
try {
|
|
2779
2783
|
// Remove isMasterPassword meta if createNew
|
|
2780
|
-
if (createNew) {
|
|
2784
|
+
if (createNew && !_uiKeyring.keyring.keyring.hasMasterPassword) {
|
|
2781
2785
|
const pairs = _uiKeyring.keyring.getPairs();
|
|
2782
2786
|
for (const pair of pairs) {
|
|
2783
2787
|
if (pair.meta.isInjected) {
|
|
@@ -212,6 +212,9 @@ class KoniState {
|
|
|
212
212
|
this.onReady();
|
|
213
213
|
this.onAccountAdd();
|
|
214
214
|
this.onAccountRemove();
|
|
215
|
+
|
|
216
|
+
// TODO: consider moving this to a separate service
|
|
217
|
+
await this.dbService.stores.crowdloan.removeEndedCrowdloans();
|
|
215
218
|
await this.startSubscription();
|
|
216
219
|
}
|
|
217
220
|
async initMantaPay(password) {
|
package/cjs/packageInfo.js
CHANGED
|
@@ -647,12 +647,34 @@ class ChainService {
|
|
|
647
647
|
for (const [storedSlug, storedChainInfo] of Object.entries(storedChainSettingMap)) {
|
|
648
648
|
if (storedSlug in latestChainInfoMap) {
|
|
649
649
|
// check predefined chains first, keep setting for providers and currentProvider
|
|
650
|
-
|
|
651
|
-
|
|
650
|
+
// TODO: review merging providers
|
|
651
|
+
// Keep customer provider only
|
|
652
|
+
const providers = {
|
|
652
653
|
...mergedChainInfoMap[storedSlug].providers
|
|
653
|
-
};
|
|
654
|
+
};
|
|
655
|
+
for (const [key, value] of Object.entries(storedChainInfo.providers)) {
|
|
656
|
+
if ((0, _utils._isCustomProvider)(key)) {
|
|
657
|
+
if (!Object.values(providers).includes(value)) {
|
|
658
|
+
providers[key] = value;
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
mergedChainInfoMap[storedSlug].providers = providers;
|
|
663
|
+
|
|
664
|
+
// Merge current provider
|
|
665
|
+
let currentProvider = storedChainInfo.currentProvider;
|
|
666
|
+
const providerValue = storedChainInfo.providers[currentProvider] || '';
|
|
667
|
+
if (!providers[currentProvider]) {
|
|
668
|
+
currentProvider = Object.keys(providers)[0];
|
|
669
|
+
for (const [key, value] of Object.entries(providers)) {
|
|
670
|
+
if (providerValue === value) {
|
|
671
|
+
currentProvider = key;
|
|
672
|
+
break;
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
}
|
|
654
676
|
this.dataMap.chainStateMap[storedSlug] = {
|
|
655
|
-
currentProvider:
|
|
677
|
+
currentProvider: currentProvider,
|
|
656
678
|
slug: storedSlug,
|
|
657
679
|
connectionStatus: _types3._ChainConnectionStatus.DISCONNECTED,
|
|
658
680
|
active: storedChainInfo.active
|
|
@@ -660,7 +682,7 @@ class ChainService {
|
|
|
660
682
|
newStorageData.push({
|
|
661
683
|
...mergedChainInfoMap[storedSlug],
|
|
662
684
|
active: storedChainInfo.active,
|
|
663
|
-
currentProvider:
|
|
685
|
+
currentProvider: currentProvider
|
|
664
686
|
});
|
|
665
687
|
} else {
|
|
666
688
|
var _storedChainInfo$subs, _storedChainInfo$evmI;
|
|
@@ -10,6 +10,20 @@ var _BaseStoreWithAddressAndChain = _interopRequireDefault(require("@subwallet/e
|
|
|
10
10
|
// SPDX-License-Identifier: Apache-2.0
|
|
11
11
|
|
|
12
12
|
class CrowdloanStore extends _BaseStoreWithAddressAndChain.default {
|
|
13
|
+
async removeEndedCrowdloans() {
|
|
14
|
+
const now = new Date();
|
|
15
|
+
const removeList = [];
|
|
16
|
+
await this.table.each((obj, cursor) => {
|
|
17
|
+
try {
|
|
18
|
+
if (!obj.endTime || new Date(obj.endTime) < now) {
|
|
19
|
+
removeList.push(cursor.primaryKey);
|
|
20
|
+
}
|
|
21
|
+
} catch (e) {
|
|
22
|
+
console.error(e);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
await this.table.bulkDelete(removeList);
|
|
26
|
+
}
|
|
13
27
|
getCrowdloan(address) {
|
|
14
28
|
return this.table.where('address').equals(address).toArray();
|
|
15
29
|
}
|
|
@@ -181,7 +181,7 @@ export const createTransferExtrinsic = async ({
|
|
|
181
181
|
if (transferAll) {
|
|
182
182
|
transfer = api.tx.balances.transferAll(to, false);
|
|
183
183
|
} else if (value) {
|
|
184
|
-
transfer = api.tx.balances.
|
|
184
|
+
transfer = api.tx.balances.transferKeepAlive(to, new BN(value));
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
187
|
return [transfer, transferAmount || value];
|
|
@@ -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 + '/metadata.json';
|
|
139
139
|
return fetch(url, {
|
|
140
140
|
method: 'GET',
|
|
141
141
|
headers
|
package/koni/api/nft/config.d.ts
CHANGED
|
@@ -22,6 +22,10 @@ export declare const IPFS_IO = "https://ipfs.io/ipfs/";
|
|
|
22
22
|
export declare const DWEB_LINK = "https://dweb.link/ipfs/";
|
|
23
23
|
export declare const IPFS_GATEWAY_4EVERLAND = "https://4everland.io/ipfs/";
|
|
24
24
|
export declare const IPFS_FLEEK = "https://ipfs.fleek.co/ipfs/";
|
|
25
|
+
export declare const W3S_IPFS = "https://w3s.link/ipfs/";
|
|
26
|
+
export declare const IPFS2_RMRK = "https://ipfs2.rmrk.link/ipfs/";
|
|
27
|
+
export declare const IPFS_ETH_ARAGON = "https://ipfs.eth.aragon.network/ipfs/";
|
|
28
|
+
export declare const SUBWALLET_IPFS = "https://ipfs.subwallet.app/ipfs/";
|
|
25
29
|
export declare enum SUPPORTED_NFT_NETWORKS {
|
|
26
30
|
karura = "karura",
|
|
27
31
|
acala = "acala",
|
package/koni/api/nft/config.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { RuntimeInfo } from '@subwallet/extension-base/utils';
|
|
5
|
+
import Bowser from 'bowser';
|
|
5
6
|
export const SINGULAR_V1_ENDPOINT = 'https://singular.rmrk-api.xyz/api/account-rmrk1/';
|
|
6
7
|
export const SINGULAR_V2_ENDPOINT = 'https://singular.rmrk-api.xyz/api/account/';
|
|
7
8
|
export const KANARIA_ENDPOINT = 'https://kanaria.rmrk.app/api/rmrk2/';
|
|
@@ -29,6 +30,15 @@ export const IPFS_IO = 'https://ipfs.io/ipfs/';
|
|
|
29
30
|
export const DWEB_LINK = 'https://dweb.link/ipfs/';
|
|
30
31
|
export const IPFS_GATEWAY_4EVERLAND = 'https://4everland.io/ipfs/';
|
|
31
32
|
export const IPFS_FLEEK = 'https://ipfs.fleek.co/ipfs/';
|
|
33
|
+
export const W3S_IPFS = 'https://w3s.link/ipfs/'; // 400
|
|
34
|
+
export const IPFS2_RMRK = 'https://ipfs2.rmrk.link/ipfs/'; // ????
|
|
35
|
+
export const IPFS_ETH_ARAGON = 'https://ipfs.eth.aragon.network/ipfs/'; // 400
|
|
36
|
+
export const SUBWALLET_IPFS = 'https://ipfs.subwallet.app/ipfs/'; // ???
|
|
37
|
+
|
|
38
|
+
const detectFirefox = () => {
|
|
39
|
+
return (localStorage.getItem('browserInfo') || Bowser.getParser(window.navigator.userAgent).getBrowserName()).toLowerCase() === 'firefox';
|
|
40
|
+
};
|
|
41
|
+
const isFirefox = detectFirefox();
|
|
32
42
|
export let SUPPORTED_NFT_NETWORKS;
|
|
33
43
|
(function (SUPPORTED_NFT_NETWORKS) {
|
|
34
44
|
SUPPORTED_NFT_NETWORKS["karura"] = "karura";
|
|
@@ -93,6 +103,12 @@ const RANDOM_IPFS_GATEWAY_SETTING = [{
|
|
|
93
103
|
provider: NFT_STORAGE_GATEWAY,
|
|
94
104
|
weight: 50
|
|
95
105
|
}];
|
|
106
|
+
if (isFirefox) {
|
|
107
|
+
RANDOM_IPFS_GATEWAY_SETTING.push({
|
|
108
|
+
provider: SUBWALLET_IPFS,
|
|
109
|
+
weight: 5000
|
|
110
|
+
});
|
|
111
|
+
}
|
|
96
112
|
if (!RuntimeInfo.protocol || RuntimeInfo.protocol && !RuntimeInfo.protocol.startsWith('http')) {
|
|
97
113
|
RANDOM_IPFS_GATEWAY_SETTING.push({
|
|
98
114
|
provider: IPFS_FLEEK,
|
|
@@ -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 + '/metadata.json';
|
|
141
141
|
return fetch(url, {
|
|
142
142
|
method: 'GET',
|
|
143
143
|
headers: {
|
|
@@ -65,23 +65,25 @@ export class VaraNftApi extends BaseNftApi {
|
|
|
65
65
|
try {
|
|
66
66
|
await Promise.all(this.addresses.map(async address => {
|
|
67
67
|
const nfts = await this.getNftByAccount(address);
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
68
|
+
if (nfts) {
|
|
69
|
+
for (const nft of nfts) {
|
|
70
|
+
const parsedNft = {
|
|
71
|
+
id: nft.tokenId,
|
|
72
|
+
chain: this.chain,
|
|
73
|
+
owner: address,
|
|
74
|
+
name: nft.name,
|
|
75
|
+
image: this.parseUrl(nft.mediaUrl),
|
|
76
|
+
description: nft.description,
|
|
77
|
+
collectionId: nft.collection.id
|
|
78
|
+
};
|
|
79
|
+
const parsedCollection = {
|
|
80
|
+
collectionId: nft.collection.id,
|
|
81
|
+
chain: this.chain,
|
|
82
|
+
collectionName: nft.collection.name
|
|
83
|
+
};
|
|
84
|
+
params.updateItem(this.chain, parsedNft, address);
|
|
85
|
+
params.updateCollection(this.chain, parsedCollection);
|
|
86
|
+
}
|
|
85
87
|
}
|
|
86
88
|
}));
|
|
87
89
|
} catch (e) {
|
|
@@ -1572,7 +1572,7 @@ export default class KoniExtension {
|
|
|
1572
1572
|
if (new BigN(receiverBalance).plus(transferAmount.value).lt(minAmount)) {
|
|
1573
1573
|
const atLeast = new BigN(minAmount).minus(receiverBalance).plus((tokenInfo.decimals || 0) === 0 ? 0 : 1);
|
|
1574
1574
|
const atLeastStr = formatNumber(atLeast, tokenInfo.decimals || 0, balanceFormatter);
|
|
1575
|
-
inputTransaction.errors.push(new TransactionError(TransferTxErrorType.RECEIVER_NOT_ENOUGH_EXISTENTIAL_DEPOSIT, t('You must transfer at least {{amount}}{{symbol}} to keep the destination account alive', {
|
|
1575
|
+
inputTransaction.errors.push(new TransactionError(TransferTxErrorType.RECEIVER_NOT_ENOUGH_EXISTENTIAL_DEPOSIT, t('You must transfer at least {{amount}} {{symbol}} to keep the destination account alive', {
|
|
1576
1576
|
replace: {
|
|
1577
1577
|
amount: atLeastStr,
|
|
1578
1578
|
symbol: tokenInfo.symbol
|
|
@@ -1641,7 +1641,7 @@ export default class KoniExtension {
|
|
|
1641
1641
|
// Check ed for receiver
|
|
1642
1642
|
if (new BigN(value).lt(atLeast)) {
|
|
1643
1643
|
const atLeastStr = formatNumber(atLeast, destinationTokenInfo.decimals || 0, balanceFormatter);
|
|
1644
|
-
inputTransaction.errors.push(new TransactionError(TransferTxErrorType.RECEIVER_NOT_ENOUGH_EXISTENTIAL_DEPOSIT, t('You must transfer at least {{amount}}{{symbol}} to keep the destination account alive', {
|
|
1644
|
+
inputTransaction.errors.push(new TransactionError(TransferTxErrorType.RECEIVER_NOT_ENOUGH_EXISTENTIAL_DEPOSIT, t('You must transfer at least {{amount}} {{symbol}} to keep the destination account alive', {
|
|
1645
1645
|
replace: {
|
|
1646
1646
|
amount: atLeastStr,
|
|
1647
1647
|
symbol: originTokenInfo.symbol
|
|
@@ -1827,7 +1827,6 @@ export default class KoniExtension {
|
|
|
1827
1827
|
if (!destinationTokenInfo) {
|
|
1828
1828
|
estimatedFee = '0';
|
|
1829
1829
|
} else {
|
|
1830
|
-
var _paymentInfo$partialF;
|
|
1831
1830
|
maxTransferable = maxTransferable.sub(new BN(tokenInfo.minAmount || '0'));
|
|
1832
1831
|
const desChainInfo = chainInfoMap[destChain];
|
|
1833
1832
|
const orgChainInfo = chainInfoMap[networkKey];
|
|
@@ -1837,11 +1836,16 @@ export default class KoniExtension {
|
|
|
1837
1836
|
destinationTokenInfo,
|
|
1838
1837
|
originTokenInfo: tokenInfo,
|
|
1839
1838
|
recipient: recipient,
|
|
1840
|
-
sendingValue: '
|
|
1839
|
+
sendingValue: '1000000000000000000',
|
|
1841
1840
|
substrateApi
|
|
1842
1841
|
});
|
|
1843
|
-
|
|
1844
|
-
|
|
1842
|
+
try {
|
|
1843
|
+
var _paymentInfo$partialF;
|
|
1844
|
+
const paymentInfo = await mockTx.paymentInfo(address);
|
|
1845
|
+
estimatedFee = (paymentInfo === null || paymentInfo === void 0 ? void 0 : (_paymentInfo$partialF = paymentInfo.partialFee) === null || _paymentInfo$partialF === void 0 ? void 0 : _paymentInfo$partialF.toString()) || '0';
|
|
1846
|
+
} catch (e) {
|
|
1847
|
+
estimatedFee = tokenInfo.minAmount || '0';
|
|
1848
|
+
}
|
|
1845
1849
|
}
|
|
1846
1850
|
} else {
|
|
1847
1851
|
const chainInfo = this.#koniState.chainService.getChainInfoByKey(networkKey);
|
|
@@ -1865,7 +1869,7 @@ export default class KoniExtension {
|
|
|
1865
1869
|
to: address,
|
|
1866
1870
|
tokenInfo,
|
|
1867
1871
|
transferAll: true,
|
|
1868
|
-
value: '
|
|
1872
|
+
value: '1000000000000000000'
|
|
1869
1873
|
});
|
|
1870
1874
|
const paymentInfo = await (mockTx === null || mockTx === void 0 ? void 0 : mockTx.paymentInfo(address));
|
|
1871
1875
|
estimatedFee = (paymentInfo === null || paymentInfo === void 0 ? void 0 : (_paymentInfo$partialF2 = paymentInfo.partialFee) === null || _paymentInfo$partialF2 === void 0 ? void 0 : _paymentInfo$partialF2.toString()) || '0';
|
|
@@ -2702,7 +2706,7 @@ export default class KoniExtension {
|
|
|
2702
2706
|
}) {
|
|
2703
2707
|
try {
|
|
2704
2708
|
// Remove isMasterPassword meta if createNew
|
|
2705
|
-
if (createNew) {
|
|
2709
|
+
if (createNew && !keyring.keyring.hasMasterPassword) {
|
|
2706
2710
|
const pairs = keyring.getPairs();
|
|
2707
2711
|
for (const pair of pairs) {
|
|
2708
2712
|
if (pair.meta.isInjected) {
|
|
@@ -204,6 +204,9 @@ export default class KoniState {
|
|
|
204
204
|
this.onReady();
|
|
205
205
|
this.onAccountAdd();
|
|
206
206
|
this.onAccountRemove();
|
|
207
|
+
|
|
208
|
+
// TODO: consider moving this to a separate service
|
|
209
|
+
await this.dbService.stores.crowdloan.removeEndedCrowdloans();
|
|
207
210
|
await this.startSubscription();
|
|
208
211
|
}
|
|
209
212
|
async initMantaPay(password) {
|
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.19-0",
|
|
21
21
|
"main": "./cjs/index.js",
|
|
22
22
|
"module": "./index.js",
|
|
23
23
|
"types": "./index.d.ts",
|
|
@@ -1277,11 +1277,11 @@
|
|
|
1277
1277
|
"@reduxjs/toolkit": "^1.9.1",
|
|
1278
1278
|
"@sora-substrate/type-definitions": "^1.17.7",
|
|
1279
1279
|
"@substrate/connect": "^0.7.26",
|
|
1280
|
-
"@subwallet/chain-list": "0.2.18-beta.
|
|
1281
|
-
"@subwallet/extension-base": "^1.1.
|
|
1282
|
-
"@subwallet/extension-chains": "^1.1.
|
|
1283
|
-
"@subwallet/extension-dapp": "^1.1.
|
|
1284
|
-
"@subwallet/extension-inject": "^1.1.
|
|
1280
|
+
"@subwallet/chain-list": "0.2.18-beta.3",
|
|
1281
|
+
"@subwallet/extension-base": "^1.1.19-0",
|
|
1282
|
+
"@subwallet/extension-chains": "^1.1.19-0",
|
|
1283
|
+
"@subwallet/extension-dapp": "^1.1.19-0",
|
|
1284
|
+
"@subwallet/extension-inject": "^1.1.19-0",
|
|
1285
1285
|
"@subwallet/keyring": "^0.1.1",
|
|
1286
1286
|
"@subwallet/ui-keyring": "^0.1.1",
|
|
1287
1287
|
"@walletconnect/sign-client": "^2.8.4",
|
|
@@ -1291,6 +1291,7 @@
|
|
|
1291
1291
|
"axios": "^1.2.1",
|
|
1292
1292
|
"bignumber.js": "^9.1.1",
|
|
1293
1293
|
"bn.js": "^5.2.1",
|
|
1294
|
+
"bowser": "^2.11.0",
|
|
1294
1295
|
"browser-passworder": "^2.0.3",
|
|
1295
1296
|
"buffer": "^6.0.3",
|
|
1296
1297
|
"cross-fetch": "^3.1.5",
|
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.19-0'
|
|
11
11
|
};
|
|
@@ -9,7 +9,7 @@ import { MantaPrivateHandler } from '@subwallet/extension-base/services/chain-se
|
|
|
9
9
|
import { SubstrateChainHandler } from '@subwallet/extension-base/services/chain-service/handler/SubstrateChainHandler';
|
|
10
10
|
import { _CHAIN_VALIDATION_ERROR } from '@subwallet/extension-base/services/chain-service/handler/types';
|
|
11
11
|
import { _ChainConnectionStatus, _CUSTOM_PREFIX, _NFT_CONTRACT_STANDARDS, _SMART_CONTRACT_STANDARDS } from '@subwallet/extension-base/services/chain-service/types';
|
|
12
|
-
import { _isAssetFungibleToken, _isChainEnabled, _isCustomAsset, _isCustomChain, _isEqualContractAddress, _isEqualSmartContractAsset, _isMantaZkAsset, _isPureEvmChain, _isPureSubstrateChain, _parseAssetRefKey } from '@subwallet/extension-base/services/chain-service/utils';
|
|
12
|
+
import { _isAssetFungibleToken, _isChainEnabled, _isCustomAsset, _isCustomChain, _isCustomProvider, _isEqualContractAddress, _isEqualSmartContractAsset, _isMantaZkAsset, _isPureEvmChain, _isPureSubstrateChain, _parseAssetRefKey } from '@subwallet/extension-base/services/chain-service/utils';
|
|
13
13
|
import AssetSettingStore from '@subwallet/extension-base/stores/AssetSetting';
|
|
14
14
|
import { MODULE_SUPPORT } from '@subwallet/extension-base/utils';
|
|
15
15
|
import { BehaviorSubject, Subject } from 'rxjs';
|
|
@@ -631,12 +631,34 @@ export class ChainService {
|
|
|
631
631
|
for (const [storedSlug, storedChainInfo] of Object.entries(storedChainSettingMap)) {
|
|
632
632
|
if (storedSlug in latestChainInfoMap) {
|
|
633
633
|
// check predefined chains first, keep setting for providers and currentProvider
|
|
634
|
-
|
|
635
|
-
|
|
634
|
+
// TODO: review merging providers
|
|
635
|
+
// Keep customer provider only
|
|
636
|
+
const providers = {
|
|
636
637
|
...mergedChainInfoMap[storedSlug].providers
|
|
637
|
-
};
|
|
638
|
+
};
|
|
639
|
+
for (const [key, value] of Object.entries(storedChainInfo.providers)) {
|
|
640
|
+
if (_isCustomProvider(key)) {
|
|
641
|
+
if (!Object.values(providers).includes(value)) {
|
|
642
|
+
providers[key] = value;
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
mergedChainInfoMap[storedSlug].providers = providers;
|
|
647
|
+
|
|
648
|
+
// Merge current provider
|
|
649
|
+
let currentProvider = storedChainInfo.currentProvider;
|
|
650
|
+
const providerValue = storedChainInfo.providers[currentProvider] || '';
|
|
651
|
+
if (!providers[currentProvider]) {
|
|
652
|
+
currentProvider = Object.keys(providers)[0];
|
|
653
|
+
for (const [key, value] of Object.entries(providers)) {
|
|
654
|
+
if (providerValue === value) {
|
|
655
|
+
currentProvider = key;
|
|
656
|
+
break;
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
}
|
|
638
660
|
this.dataMap.chainStateMap[storedSlug] = {
|
|
639
|
-
currentProvider:
|
|
661
|
+
currentProvider: currentProvider,
|
|
640
662
|
slug: storedSlug,
|
|
641
663
|
connectionStatus: _ChainConnectionStatus.DISCONNECTED,
|
|
642
664
|
active: storedChainInfo.active
|
|
@@ -644,7 +666,7 @@ export class ChainService {
|
|
|
644
666
|
newStorageData.push({
|
|
645
667
|
...mergedChainInfoMap[storedSlug],
|
|
646
668
|
active: storedChainInfo.active,
|
|
647
|
-
currentProvider:
|
|
669
|
+
currentProvider: currentProvider
|
|
648
670
|
});
|
|
649
671
|
} else {
|
|
650
672
|
var _storedChainInfo$subs, _storedChainInfo$evmI;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import BaseStoreWithAddressAndChain from '@subwallet/extension-base/services/storage-service/db-stores/BaseStoreWithAddressAndChain';
|
|
2
2
|
import { ICrowdloanItem } from '../databases';
|
|
3
3
|
export default class CrowdloanStore extends BaseStoreWithAddressAndChain<ICrowdloanItem> {
|
|
4
|
+
removeEndedCrowdloans(): Promise<void>;
|
|
4
5
|
getCrowdloan(address: string): import("dexie").PromiseExtended<ICrowdloanItem[]>;
|
|
5
6
|
deleteByChainAndAddress(chain: string, address: string): import("dexie").PromiseExtended<number>;
|
|
6
7
|
}
|
|
@@ -3,6 +3,20 @@
|
|
|
3
3
|
|
|
4
4
|
import BaseStoreWithAddressAndChain from '@subwallet/extension-base/services/storage-service/db-stores/BaseStoreWithAddressAndChain';
|
|
5
5
|
export default class CrowdloanStore extends BaseStoreWithAddressAndChain {
|
|
6
|
+
async removeEndedCrowdloans() {
|
|
7
|
+
const now = new Date();
|
|
8
|
+
const removeList = [];
|
|
9
|
+
await this.table.each((obj, cursor) => {
|
|
10
|
+
try {
|
|
11
|
+
if (!obj.endTime || new Date(obj.endTime) < now) {
|
|
12
|
+
removeList.push(cursor.primaryKey);
|
|
13
|
+
}
|
|
14
|
+
} catch (e) {
|
|
15
|
+
console.error(e);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
await this.table.bulkDelete(removeList);
|
|
19
|
+
}
|
|
6
20
|
getCrowdloan(address) {
|
|
7
21
|
return this.table.where('address').equals(address).toArray();
|
|
8
22
|
}
|