@subwallet/extension-base 1.0.12-0 → 1.0.13-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 +89 -0
- package/background/KoniTypes.js +18 -19
- package/background/handlers/Extension.js +17 -2
- package/background/handlers/State.d.ts +0 -1
- package/background/handlers/State.js +4 -8
- package/background/types.d.ts +6 -1
- package/cjs/background/KoniTypes.js +21 -11
- package/cjs/background/handlers/Extension.js +22 -6
- package/cjs/background/handlers/State.js +4 -8
- package/cjs/constants/index.js +7 -1
- package/cjs/defaults.js +1 -1
- package/cjs/koni/api/dotsama/balance.js +5 -0
- package/cjs/koni/api/dotsama/transfer.js +6 -0
- package/cjs/koni/api/nft/config.js +11 -6
- package/cjs/koni/api/xcm/polkadotXcm.js +1 -1
- package/cjs/koni/api/xcm/xTokens.js +2 -2
- package/cjs/koni/background/cron.js +12 -1
- package/cjs/koni/background/handlers/Extension.js +457 -131
- package/cjs/koni/background/handlers/State.js +236 -53
- package/cjs/koni/background/handlers/Tabs.js +61 -9
- package/cjs/koni/background/subscription.js +3 -0
- package/cjs/packageInfo.js +1 -1
- package/cjs/page/Metadata.js +3 -0
- package/cjs/services/chain-service/constants.js +10 -4
- package/cjs/services/chain-service/handler/SubstrateApi.js +2 -1
- package/cjs/services/chain-service/handler/SubstrateChainHandler.js +3 -1
- package/cjs/services/chain-service/handler/manta/MantaPrivateHandler.js +147 -0
- package/cjs/services/chain-service/index.js +54 -5
- package/cjs/services/chain-service/utils.js +32 -0
- package/cjs/services/event-service/types.js +3 -1
- package/cjs/services/request-service/handler/AuthRequestHandler.js +4 -9
- package/cjs/services/request-service/handler/SubstrateRequestHandler.js +2 -2
- package/cjs/services/request-service/handler/WalletConnectRequestHandler.js +71 -0
- package/cjs/services/request-service/index.js +24 -6
- package/cjs/services/storage-service/DatabaseService.js +31 -1
- package/cjs/services/storage-service/databases/index.js +3 -0
- package/cjs/services/storage-service/db-stores/MantaPay.js +40 -0
- package/cjs/services/transaction-service/helpers/index.js +3 -2
- package/cjs/services/transaction-service/index.js +2 -1
- package/cjs/services/wallet-connect-service/constants.js +38 -0
- package/cjs/services/wallet-connect-service/handler/Eip155RequestHandler.js +113 -0
- package/cjs/services/wallet-connect-service/handler/PolkadotRequestHandler.js +123 -0
- package/cjs/services/wallet-connect-service/helpers.js +81 -0
- package/cjs/services/wallet-connect-service/index.js +273 -0
- package/cjs/services/wallet-connect-service/types.js +27 -0
- package/cjs/utils/array.js +17 -0
- package/cjs/utils/environment.js +66 -0
- package/cjs/utils/index.js +78 -1
- package/cjs/utils/lazy.js +52 -0
- package/constants/index.d.ts +2 -0
- package/constants/index.js +2 -0
- package/defaults.d.ts +1 -1
- package/defaults.js +1 -1
- package/koni/api/dotsama/balance.js +6 -1
- package/koni/api/dotsama/transfer.js +7 -1
- package/koni/api/nft/config.js +11 -6
- package/koni/api/xcm/polkadotXcm.js +1 -1
- package/koni/api/xcm/xTokens.js +2 -2
- package/koni/background/cron.d.ts +1 -0
- package/koni/background/cron.js +13 -2
- package/koni/background/handlers/Extension.d.ts +11 -0
- package/koni/background/handlers/Extension.js +329 -12
- package/koni/background/handlers/State.d.ts +17 -3
- package/koni/background/handlers/State.js +238 -52
- package/koni/background/handlers/Tabs.d.ts +2 -0
- package/koni/background/handlers/Tabs.js +58 -7
- package/koni/background/subscription.js +3 -0
- package/package.json +72 -6
- package/packageInfo.js +1 -1
- package/page/Metadata.d.ts +2 -0
- package/page/Metadata.js +3 -0
- package/services/chain-service/constants.d.ts +3 -0
- package/services/chain-service/constants.js +5 -2
- package/services/chain-service/handler/SubstrateApi.d.ts +1 -1
- package/services/chain-service/handler/SubstrateApi.js +2 -1
- package/services/chain-service/handler/SubstrateChainHandler.d.ts +1 -1
- package/services/chain-service/handler/SubstrateChainHandler.js +3 -1
- package/services/chain-service/handler/manta/MantaPrivateHandler.d.ts +30 -0
- package/services/chain-service/handler/manta/MantaPrivateHandler.js +140 -0
- package/services/chain-service/handler/types.d.ts +2 -0
- package/services/chain-service/index.d.ts +7 -3
- package/services/chain-service/index.js +56 -7
- package/services/chain-service/utils.d.ts +3 -0
- package/services/chain-service/utils.js +28 -0
- package/services/event-service/types.d.ts +3 -0
- package/services/event-service/types.js +3 -1
- package/services/request-service/handler/AuthRequestHandler.d.ts +0 -1
- package/services/request-service/handler/AuthRequestHandler.js +5 -10
- package/services/request-service/handler/SubstrateRequestHandler.d.ts +1 -1
- package/services/request-service/handler/SubstrateRequestHandler.js +2 -2
- package/services/request-service/handler/WalletConnectRequestHandler.d.ts +15 -0
- package/services/request-service/handler/WalletConnectRequestHandler.js +62 -0
- package/services/request-service/index.d.ts +7 -2
- package/services/request-service/index.js +24 -6
- package/services/storage-service/DatabaseService.d.ts +10 -1
- package/services/storage-service/DatabaseService.js +31 -1
- package/services/storage-service/databases/index.d.ts +2 -0
- package/services/storage-service/databases/index.js +3 -0
- package/services/storage-service/db-stores/MantaPay.d.ts +9 -0
- package/services/storage-service/db-stores/MantaPay.js +32 -0
- package/services/transaction-service/helpers/index.d.ts +1 -1
- package/services/transaction-service/helpers/index.js +2 -2
- package/services/transaction-service/index.js +2 -1
- package/services/transaction-service/types.d.ts +2 -1
- package/services/wallet-connect-service/constants.d.ts +11 -0
- package/services/wallet-connect-service/constants.js +23 -0
- package/services/wallet-connect-service/handler/Eip155RequestHandler.d.ts +8 -0
- package/services/wallet-connect-service/handler/Eip155RequestHandler.js +106 -0
- package/services/wallet-connect-service/handler/PolkadotRequestHandler.d.ts +8 -0
- package/services/wallet-connect-service/handler/PolkadotRequestHandler.js +114 -0
- package/services/wallet-connect-service/helpers.d.ts +12 -0
- package/services/wallet-connect-service/helpers.js +67 -0
- package/services/wallet-connect-service/index.d.ts +20 -0
- package/services/wallet-connect-service/index.js +265 -0
- package/services/wallet-connect-service/types.d.ts +46 -0
- package/services/wallet-connect-service/types.js +20 -0
- package/utils/array.d.ts +1 -0
- package/utils/array.js +10 -0
- package/utils/environment.d.ts +2 -0
- package/utils/environment.js +59 -0
- package/utils/index.d.ts +4 -0
- package/utils/index.js +10 -2
- package/utils/lazy.d.ts +2 -0
- package/utils/lazy.js +43 -0
|
@@ -28,7 +28,9 @@ var _DatabaseService = _interopRequireDefault(require("@subwallet/extension-base
|
|
|
28
28
|
var _subscanService = require("@subwallet/extension-base/services/subscan-service");
|
|
29
29
|
var _subscanChainMap = require("@subwallet/extension-base/services/subscan-service/subscan-chain-map");
|
|
30
30
|
var _transactionService = _interopRequireDefault(require("@subwallet/extension-base/services/transaction-service"));
|
|
31
|
+
var _walletConnectService = _interopRequireDefault(require("@subwallet/extension-base/services/wallet-connect-service"));
|
|
31
32
|
var _AccountRef = _interopRequireDefault(require("@subwallet/extension-base/stores/AccountRef"));
|
|
33
|
+
var _utils2 = require("@subwallet/extension-base/utils");
|
|
32
34
|
var _parseTransaction = require("@subwallet/extension-base/utils/eth/parseTransaction");
|
|
33
35
|
var _promise = require("@subwallet/extension-base/utils/promise");
|
|
34
36
|
var _decode = require("@subwallet/keyring/pair/decode");
|
|
@@ -42,6 +44,8 @@ var _subscription = require("../subscription");
|
|
|
42
44
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
43
45
|
// SPDX-License-Identifier: Apache-2.0
|
|
44
46
|
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
|
|
48
|
+
const passworder = require('browser-passworder');
|
|
45
49
|
const ETH_DERIVE_DEFAULT = '/m/44\'/60\'/0\'/0/0';
|
|
46
50
|
|
|
47
51
|
// List of providers passed into constructor. This is the list of providers
|
|
@@ -73,6 +77,8 @@ class KoniState {
|
|
|
73
77
|
crowdloanMap = generateDefaultCrowdloanMap();
|
|
74
78
|
crowdloanSubject = new _rxjs.Subject();
|
|
75
79
|
nftSubject = new _rxjs.Subject();
|
|
80
|
+
mantaPayConfigSubject = new _rxjs.Subject();
|
|
81
|
+
isMantaPayEnabled = false;
|
|
76
82
|
stakingSubject = new _rxjs.Subject();
|
|
77
83
|
chainStakingMetadataSubject = new _rxjs.Subject();
|
|
78
84
|
stakingNominatorMetadataSubject = new _rxjs.Subject();
|
|
@@ -101,6 +107,7 @@ class KoniState {
|
|
|
101
107
|
this.balanceService = new _balanceService.BalanceService(this.chainService);
|
|
102
108
|
this.historyService = new _historyService.HistoryService(this.dbService, this.chainService, this.eventService, this.keyringService);
|
|
103
109
|
this.transactionService = new _transactionService.default(this.chainService, this.eventService, this.requestService, this.balanceService, this.historyService, this.notificationService, this.dbService);
|
|
110
|
+
this.walletConnectService = new _walletConnectService.default(this, this.requestService);
|
|
104
111
|
this.migrationService = new _migrationService.default(this);
|
|
105
112
|
this.subscription = new _subscription.KoniSubscription(this, this.dbService);
|
|
106
113
|
this.cron = new _cron.KoniCron(this, this.subscription, this.dbService);
|
|
@@ -214,11 +221,25 @@ class KoniState {
|
|
|
214
221
|
this.onAccountRemove();
|
|
215
222
|
await this.startSubscription();
|
|
216
223
|
}
|
|
224
|
+
async initMantaPay(password) {
|
|
225
|
+
const mantaPayConfig = await this.chainService.mantaPay.getMantaPayFirstConfig(_constants2._DEFAULT_MANTA_ZK_CHAIN);
|
|
226
|
+
if (mantaPayConfig && mantaPayConfig.enabled && !this.isMantaPayEnabled) {
|
|
227
|
+
// only init the first login
|
|
228
|
+
console.debug('Initiating MantaPay for', mantaPayConfig.address);
|
|
229
|
+
await this.enableMantaPay(false, mantaPayConfig.address, password);
|
|
230
|
+
console.debug('Initiated MantaPay for', mantaPayConfig.address);
|
|
231
|
+
this.isMantaPayEnabled = true;
|
|
232
|
+
this.eventService.emit('mantaPay.enable', mantaPayConfig.address);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
217
235
|
async startSubscription() {
|
|
218
236
|
await this.eventService.waitKeyringReady;
|
|
219
237
|
this.dbService.subscribeChainStakingMetadata([], data => {
|
|
220
238
|
this.chainStakingMetadataSubject.next(data);
|
|
221
239
|
});
|
|
240
|
+
this.dbService.subscribeMantaPayConfig(_constants2._DEFAULT_MANTA_ZK_CHAIN, data => {
|
|
241
|
+
this.mantaPayConfigSubject.next(data);
|
|
242
|
+
});
|
|
222
243
|
let unsub;
|
|
223
244
|
this.keyringService.accountSubject.subscribe(accounts => {
|
|
224
245
|
// TODO: improve this
|
|
@@ -294,6 +315,10 @@ class KoniState {
|
|
|
294
315
|
async getNominatorMetadata() {
|
|
295
316
|
return this.dbService.getNominatorMetadata();
|
|
296
317
|
}
|
|
318
|
+
async getMantaPayConfig(chain) {
|
|
319
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
320
|
+
return this.dbService.getMantaPayConfig(chain);
|
|
321
|
+
}
|
|
297
322
|
async getStaking() {
|
|
298
323
|
const addresses = this.getDecodedAddresses();
|
|
299
324
|
const stakings = await this.dbService.getStakings(addresses, this.activeChainSlugs);
|
|
@@ -315,6 +340,9 @@ class KoniState {
|
|
|
315
340
|
async getPooledStakingRecordsByAddress(addresses) {
|
|
316
341
|
return this.dbService.getPooledStakings(addresses, this.activeChainSlugs);
|
|
317
342
|
}
|
|
343
|
+
subscribeMantaPayConfig() {
|
|
344
|
+
return this.mantaPayConfigSubject;
|
|
345
|
+
}
|
|
318
346
|
subscribeStaking() {
|
|
319
347
|
return this.stakingSubject;
|
|
320
348
|
}
|
|
@@ -888,8 +916,13 @@ class KoniState {
|
|
|
888
916
|
return result;
|
|
889
917
|
};
|
|
890
918
|
async disableChain(chainSlug) {
|
|
891
|
-
// const defaultChains = this.getDefaultNetworkKeys();
|
|
892
919
|
await this.chainService.updateAssetSettingByChain(chainSlug, false);
|
|
920
|
+
if (_constants2._MANTA_ZK_CHAIN_GROUP.includes(chainSlug)) {
|
|
921
|
+
const mantaPayConfig = await this.chainService.mantaPay.getMantaPayFirstConfig(_constants2._DEFAULT_MANTA_ZK_CHAIN);
|
|
922
|
+
if (mantaPayConfig && mantaPayConfig.enabled && this.isMantaPayEnabled) {
|
|
923
|
+
await this.disableMantaPay(mantaPayConfig.address);
|
|
924
|
+
}
|
|
925
|
+
}
|
|
893
926
|
return this.chainService.disableChain(chainSlug);
|
|
894
927
|
}
|
|
895
928
|
async enableChain(chainSlug) {
|
|
@@ -1273,9 +1306,10 @@ class KoniState {
|
|
|
1273
1306
|
const transactionData = {
|
|
1274
1307
|
...transaction
|
|
1275
1308
|
};
|
|
1309
|
+
const token = this.chainService.getNativeTokenInfo(networkKey);
|
|
1276
1310
|
if (eType === _KoniTypes.ExtrinsicType.TRANSFER_BALANCE) {
|
|
1277
1311
|
// @ts-ignore
|
|
1278
|
-
transactionData.tokenSlug =
|
|
1312
|
+
transactionData.tokenSlug = token.slug;
|
|
1279
1313
|
}
|
|
1280
1314
|
|
|
1281
1315
|
// Custom handle this instead of general handler transaction
|
|
@@ -1286,7 +1320,13 @@ class KoniState {
|
|
|
1286
1320
|
url,
|
|
1287
1321
|
data: transactionData,
|
|
1288
1322
|
extrinsicType: eType,
|
|
1289
|
-
chainType: _KoniTypes.ChainType.EVM
|
|
1323
|
+
chainType: _KoniTypes.ChainType.EVM,
|
|
1324
|
+
estimateFee: {
|
|
1325
|
+
value: estimateGas,
|
|
1326
|
+
symbol: token.symbol,
|
|
1327
|
+
decimals: token.decimals || 18
|
|
1328
|
+
},
|
|
1329
|
+
id
|
|
1290
1330
|
});
|
|
1291
1331
|
|
|
1292
1332
|
// Wait extrinsic hash
|
|
@@ -1317,50 +1357,51 @@ class KoniState {
|
|
|
1317
1357
|
return await this.requestService.completeConfirmation(request);
|
|
1318
1358
|
}
|
|
1319
1359
|
onInstall() {
|
|
1320
|
-
const singleModes = Object.values(
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
};
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
}
|
|
1360
|
+
// const singleModes = Object.values(_PREDEFINED_SINGLE_MODES);
|
|
1361
|
+
|
|
1362
|
+
// This logic is moved to installation.ts
|
|
1363
|
+
// try {
|
|
1364
|
+
// // Open expand page
|
|
1365
|
+
// const url = `${chrome.extension.getURL('index.html')}#/`;
|
|
1366
|
+
//
|
|
1367
|
+
// withErrorLog(() => chrome.tabs.create({ url }));
|
|
1368
|
+
// } catch (e) {
|
|
1369
|
+
// console.error(e);
|
|
1370
|
+
// }
|
|
1371
|
+
|
|
1372
|
+
// const setUpSingleMode = ({ networkKeys, theme }: SingleModeJson) => {
|
|
1373
|
+
// networkKeys.forEach((key) => {
|
|
1374
|
+
// this.enableChain(key).catch(console.error);
|
|
1375
|
+
// });
|
|
1376
|
+
//
|
|
1377
|
+
// const chainInfo = this.chainService.getChainInfoByKey(networkKeys[0]);
|
|
1378
|
+
// const genesisHash = _getSubstrateGenesisHash(chainInfo);
|
|
1379
|
+
//
|
|
1380
|
+
// this.setCurrentAccount({
|
|
1381
|
+
// address: ALL_ACCOUNT_KEY,
|
|
1382
|
+
// currentGenesisHash: genesisHash.length > 0 ? genesisHash : null
|
|
1383
|
+
// });
|
|
1384
|
+
// this.setTheme(theme);
|
|
1385
|
+
// };
|
|
1386
|
+
//
|
|
1387
|
+
// chrome.tabs.query({}, function (tabs) {
|
|
1388
|
+
// const openingUrls = tabs.map((t) => t.url);
|
|
1389
|
+
//
|
|
1390
|
+
// const singleMode = singleModes.find(({ autoTriggerDomain }) => {
|
|
1391
|
+
// const urlRegex = new RegExp(autoTriggerDomain);
|
|
1392
|
+
//
|
|
1393
|
+
// return Boolean(openingUrls.find((url) => {
|
|
1394
|
+
// return url && urlRegex.test(url);
|
|
1395
|
+
// }));
|
|
1396
|
+
// });
|
|
1397
|
+
//
|
|
1398
|
+
// if (singleMode) {
|
|
1399
|
+
// // Wait for everything is ready before enable single mode
|
|
1400
|
+
// setTimeout(() => {
|
|
1401
|
+
// setUpSingleMode(singleMode);
|
|
1402
|
+
// }, 999);
|
|
1403
|
+
// }
|
|
1404
|
+
// });
|
|
1364
1405
|
}
|
|
1365
1406
|
get activeNetworks() {
|
|
1366
1407
|
return this.chainService.getActiveChainInfos();
|
|
@@ -1448,9 +1489,6 @@ class KoniState {
|
|
|
1448
1489
|
createUnsubscriptionHandle(id, unsubscribe) {
|
|
1449
1490
|
this.unsubscriptionMap[id] = unsubscribe;
|
|
1450
1491
|
}
|
|
1451
|
-
updateChainConnectionStatus(chain, status) {
|
|
1452
|
-
this.chainService.setChainConnectionStatus(chain, status);
|
|
1453
|
-
}
|
|
1454
1492
|
async autoEnableChains(addresses) {
|
|
1455
1493
|
const assetMap = this.chainService.getAssetRegistry();
|
|
1456
1494
|
const promiseList = addresses.map(address => {
|
|
@@ -1465,7 +1503,7 @@ class KoniState {
|
|
|
1465
1503
|
const chainMap = this.chainService.getChainInfoMap();
|
|
1466
1504
|
const balanceDataList = await Promise.all(promiseList);
|
|
1467
1505
|
balanceDataList.forEach(balanceData => {
|
|
1468
|
-
balanceData && balanceData.forEach(
|
|
1506
|
+
balanceData && balanceData.forEach(_ref12 => {
|
|
1469
1507
|
var _currentAssetSettings;
|
|
1470
1508
|
let {
|
|
1471
1509
|
balance,
|
|
@@ -1474,7 +1512,7 @@ class KoniState {
|
|
|
1474
1512
|
locked,
|
|
1475
1513
|
network,
|
|
1476
1514
|
symbol
|
|
1477
|
-
} =
|
|
1515
|
+
} = _ref12;
|
|
1478
1516
|
const chain = _subscanChainMap.SUBSCAN_CHAIN_MAP_REVERSE[network];
|
|
1479
1517
|
const chainInfo = chain ? chainMap[chain] : null;
|
|
1480
1518
|
const balanceIsEmpty = (!balance || balance === '0') && (!locked || locked === '0') && (!bonded || bonded === '0');
|
|
@@ -1534,7 +1572,7 @@ class KoniState {
|
|
|
1534
1572
|
const result = {
|
|
1535
1573
|
...value
|
|
1536
1574
|
};
|
|
1537
|
-
const url =
|
|
1575
|
+
const url = (0, _utils2.stripUrl)(_url);
|
|
1538
1576
|
result[url] = {
|
|
1539
1577
|
pass: true
|
|
1540
1578
|
};
|
|
@@ -1554,7 +1592,152 @@ class KoniState {
|
|
|
1554
1592
|
this.settingService.resetWallet();
|
|
1555
1593
|
}
|
|
1556
1594
|
this.chainService.resetWallet(resetAll);
|
|
1595
|
+
await this.walletConnectService.resetWallet(resetAll);
|
|
1557
1596
|
await this.chainService.init();
|
|
1558
1597
|
}
|
|
1598
|
+
async enableMantaPay(updateStore, address, password, seedPhrase) {
|
|
1599
|
+
var _this$chainService$ma, _this$chainService$ma6;
|
|
1600
|
+
if (!address || (0, _utilCrypto.isEthereumAddress)(address)) {
|
|
1601
|
+
return;
|
|
1602
|
+
}
|
|
1603
|
+
this.chainService.mantaPay.setCurrentAddress(address);
|
|
1604
|
+
await ((_this$chainService$ma = this.chainService.mantaPay.privateWallet) === null || _this$chainService$ma === void 0 ? void 0 : _this$chainService$ma.initialSigner());
|
|
1605
|
+
if (updateStore && seedPhrase) {
|
|
1606
|
+
var _this$chainService$ma2, _this$chainService$ma3, _this$chainService$ma4;
|
|
1607
|
+
// first time initiation
|
|
1608
|
+
await ((_this$chainService$ma2 = this.chainService.mantaPay.privateWallet) === null || _this$chainService$ma2 === void 0 ? void 0 : _this$chainService$ma2.loadUserSeedPhrase(seedPhrase));
|
|
1609
|
+
const authContext = await ((_this$chainService$ma3 = this.chainService.mantaPay.privateWallet) === null || _this$chainService$ma3 === void 0 ? void 0 : _this$chainService$ma3.getAuthorizationContext());
|
|
1610
|
+
await ((_this$chainService$ma4 = this.chainService.mantaPay.privateWallet) === null || _this$chainService$ma4 === void 0 ? void 0 : _this$chainService$ma4.loadAuthorizationContext(authContext));
|
|
1611
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
|
|
1612
|
+
const encryptedData = await passworder.encrypt(password, authContext);
|
|
1613
|
+
await this.chainService.mantaPay.saveMantaAuthContext({
|
|
1614
|
+
chain: _constants2._DEFAULT_MANTA_ZK_CHAIN,
|
|
1615
|
+
address,
|
|
1616
|
+
data: encryptedData
|
|
1617
|
+
});
|
|
1618
|
+
} else {
|
|
1619
|
+
var _this$chainService$ma5;
|
|
1620
|
+
const authContext = await this.chainService.mantaPay.getMantaAuthContext(address, _constants2._DEFAULT_MANTA_ZK_CHAIN);
|
|
1621
|
+
|
|
1622
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
|
|
1623
|
+
const decryptedData = await passworder.decrypt(password, authContext.data);
|
|
1624
|
+
|
|
1625
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument,@typescript-eslint/no-unsafe-member-access
|
|
1626
|
+
const proofAuthKey = new Uint8Array(Object.values(decryptedData.proof_authorization_key));
|
|
1627
|
+
await ((_this$chainService$ma5 = this.chainService.mantaPay.privateWallet) === null || _this$chainService$ma5 === void 0 ? void 0 : _this$chainService$ma5.loadAuthorizationContext({
|
|
1628
|
+
proof_authorization_key: proofAuthKey
|
|
1629
|
+
}));
|
|
1630
|
+
}
|
|
1631
|
+
const zkAddress = await ((_this$chainService$ma6 = this.chainService.mantaPay.privateWallet) === null || _this$chainService$ma6 === void 0 ? void 0 : _this$chainService$ma6.getZkAddress());
|
|
1632
|
+
if (updateStore) {
|
|
1633
|
+
var _this$chainService$ma7, _this$chainService$ma8;
|
|
1634
|
+
await this.chainService.mantaPay.saveMantaPayConfig({
|
|
1635
|
+
address,
|
|
1636
|
+
zkAddress: zkAddress,
|
|
1637
|
+
enabled: true,
|
|
1638
|
+
chain: (_this$chainService$ma7 = this.chainService.mantaPay.privateWallet) === null || _this$chainService$ma7 === void 0 ? void 0 : (_this$chainService$ma8 = _this$chainService$ma7.network) === null || _this$chainService$ma8 === void 0 ? void 0 : _this$chainService$ma8.toLowerCase(),
|
|
1639
|
+
isInitialSync: false
|
|
1640
|
+
});
|
|
1641
|
+
}
|
|
1642
|
+
this.isMantaPayEnabled = true;
|
|
1643
|
+
return zkAddress;
|
|
1644
|
+
}
|
|
1645
|
+
async disableMantaPay(address) {
|
|
1646
|
+
var _this$chainService$ma9, _this$chainService$ma10;
|
|
1647
|
+
const config = await this.chainService.mantaPay.getMantaPayConfig(address, _constants2._DEFAULT_MANTA_ZK_CHAIN);
|
|
1648
|
+
if (!config) {
|
|
1649
|
+
return false;
|
|
1650
|
+
}
|
|
1651
|
+
await ((_this$chainService$ma9 = this.chainService.mantaPay.privateWallet) === null || _this$chainService$ma9 === void 0 ? void 0 : _this$chainService$ma9.dropAuthorizationContext());
|
|
1652
|
+
await ((_this$chainService$ma10 = this.chainService.mantaPay.privateWallet) === null || _this$chainService$ma10 === void 0 ? void 0 : _this$chainService$ma10.dropUserSeedPhrase());
|
|
1653
|
+
// await this.chainService.mantaPay.privateWallet?.resetState();
|
|
1654
|
+
await this.chainService.mantaPay.deleteMantaPayConfig(address, _constants2._DEFAULT_MANTA_ZK_CHAIN);
|
|
1655
|
+
await this.chainService.mantaPay.deleteMantaAuthContext(address, _constants2._DEFAULT_MANTA_ZK_CHAIN);
|
|
1656
|
+
this.chainService.setMantaZkAssetSettings(false);
|
|
1657
|
+
this.isMantaPayEnabled = false;
|
|
1658
|
+
return true;
|
|
1659
|
+
}
|
|
1660
|
+
async initialSyncMantaPay(address) {
|
|
1661
|
+
var _this$chainService$ma11, _this$chainService$ma12, _this$chainService$ma13;
|
|
1662
|
+
if (!address || (0, _utilCrypto.isEthereumAddress)(address)) {
|
|
1663
|
+
return;
|
|
1664
|
+
}
|
|
1665
|
+
this.chainService.mantaPay.setCurrentAddress(address);
|
|
1666
|
+
await ((_this$chainService$ma11 = this.chainService.mantaPay.privateWallet) === null || _this$chainService$ma11 === void 0 ? void 0 : (_this$chainService$ma12 = _this$chainService$ma11.baseWallet) === null || _this$chainService$ma12 === void 0 ? void 0 : _this$chainService$ma12.isApiReady());
|
|
1667
|
+
const syncResult = await ((_this$chainService$ma13 = this.chainService.mantaPay.privateWallet) === null || _this$chainService$ma13 === void 0 ? void 0 : _this$chainService$ma13.initialWalletSync());
|
|
1668
|
+
await this.chainService.mantaPay.updateMantaPayConfig(address, _constants2._DEFAULT_MANTA_ZK_CHAIN, {
|
|
1669
|
+
isInitialSync: true
|
|
1670
|
+
});
|
|
1671
|
+
this.eventService.emit('mantaPay.initSync', undefined);
|
|
1672
|
+
return syncResult;
|
|
1673
|
+
}
|
|
1674
|
+
getMantaZkBalance() {
|
|
1675
|
+
var _this$chainService, _this$chainService$ma14, _this$chainService$ma15, _this$chainService2, _this$chainService2$m, _this$chainService$ma16;
|
|
1676
|
+
if (!this.chainService || !this.chainService.mantaPay) {
|
|
1677
|
+
return;
|
|
1678
|
+
}
|
|
1679
|
+
if (!((_this$chainService = this.chainService) !== null && _this$chainService !== void 0 && (_this$chainService$ma14 = _this$chainService.mantaPay) !== null && _this$chainService$ma14 !== void 0 && (_this$chainService$ma15 = _this$chainService$ma14.privateWallet) !== null && _this$chainService$ma15 !== void 0 && _this$chainService$ma15.initialSyncIsFinished)) {
|
|
1680
|
+
return;
|
|
1681
|
+
}
|
|
1682
|
+
const chain = (_this$chainService2 = this.chainService) === null || _this$chainService2 === void 0 ? void 0 : (_this$chainService2$m = _this$chainService2.mantaPay.privateWallet) === null || _this$chainService2$m === void 0 ? void 0 : _this$chainService2$m.network;
|
|
1683
|
+
if (!chain) {
|
|
1684
|
+
return;
|
|
1685
|
+
}
|
|
1686
|
+
const assetMap = this.chainService.getMantaZkAssets(chain === null || chain === void 0 ? void 0 : chain.toLowerCase());
|
|
1687
|
+
(_this$chainService$ma16 = this.chainService.mantaPay.privateWallet) === null || _this$chainService$ma16 === void 0 ? void 0 : _this$chainService$ma16.getMultiZkBalance(Object.values(assetMap).map(tokenInfo => new _util.BN((0, _utils._getTokenOnChainAssetId)(tokenInfo)))).then(zkBalances => {
|
|
1688
|
+
const assetList = Object.values(assetMap);
|
|
1689
|
+
for (let i = 0; i < assetList.length; i++) {
|
|
1690
|
+
var _zkBalances$i;
|
|
1691
|
+
const balanceItem = {
|
|
1692
|
+
tokenSlug: assetList[i].slug,
|
|
1693
|
+
state: _KoniTypes.APIItemState.PENDING,
|
|
1694
|
+
free: '0',
|
|
1695
|
+
locked: '0'
|
|
1696
|
+
};
|
|
1697
|
+
balanceItem.free = ((_zkBalances$i = zkBalances[i]) === null || _zkBalances$i === void 0 ? void 0 : _zkBalances$i.toString()) || '0';
|
|
1698
|
+
balanceItem.state = _KoniTypes.APIItemState.READY;
|
|
1699
|
+
this.setBalanceItem(balanceItem.tokenSlug, balanceItem);
|
|
1700
|
+
}
|
|
1701
|
+
}).catch(console.warn);
|
|
1702
|
+
}
|
|
1703
|
+
subscribeMantaPayBalance() {
|
|
1704
|
+
let interval;
|
|
1705
|
+
this.chainService.mantaPay.getMantaPayConfig(this.keyringService.currentAccount.address, _constants2._DEFAULT_MANTA_ZK_CHAIN).then(config => {
|
|
1706
|
+
if (config && config.enabled && config.isInitialSync) {
|
|
1707
|
+
this.getMantaZkBalance();
|
|
1708
|
+
interval = setInterval(this.getMantaZkBalance, _constants.MANTA_PAY_BALANCE_INTERVAL);
|
|
1709
|
+
}
|
|
1710
|
+
}).catch(console.warn);
|
|
1711
|
+
return () => {
|
|
1712
|
+
interval && clearInterval(interval);
|
|
1713
|
+
};
|
|
1714
|
+
}
|
|
1715
|
+
async syncMantaPay() {
|
|
1716
|
+
var _this$chainService3, _this$chainService3$m, _this$chainService3$m2;
|
|
1717
|
+
const config = await this.chainService.mantaPay.getMantaPayFirstConfig(_constants2._DEFAULT_MANTA_ZK_CHAIN);
|
|
1718
|
+
if (!config.isInitialSync) {
|
|
1719
|
+
return;
|
|
1720
|
+
}
|
|
1721
|
+
if ((_this$chainService3 = this.chainService) !== null && _this$chainService3 !== void 0 && (_this$chainService3$m = _this$chainService3.mantaPay) !== null && _this$chainService3$m !== void 0 && (_this$chainService3$m2 = _this$chainService3$m.privateWallet) !== null && _this$chainService3$m2 !== void 0 && _this$chainService3$m2.initialSyncIsFinished) {
|
|
1722
|
+
var _this$chainService4, _this$chainService4$m, _this$chainService4$m2;
|
|
1723
|
+
await ((_this$chainService4 = this.chainService) === null || _this$chainService4 === void 0 ? void 0 : (_this$chainService4$m = _this$chainService4.mantaPay) === null || _this$chainService4$m === void 0 ? void 0 : (_this$chainService4$m2 = _this$chainService4$m.privateWallet) === null || _this$chainService4$m2 === void 0 ? void 0 : _this$chainService4$m2.walletSync());
|
|
1724
|
+
} else {
|
|
1725
|
+
var _this$chainService5, _this$chainService5$m, _this$chainService5$m2;
|
|
1726
|
+
await ((_this$chainService5 = this.chainService) === null || _this$chainService5 === void 0 ? void 0 : (_this$chainService5$m = _this$chainService5.mantaPay) === null || _this$chainService5$m === void 0 ? void 0 : (_this$chainService5$m2 = _this$chainService5$m.privateWallet) === null || _this$chainService5$m2 === void 0 ? void 0 : _this$chainService5$m2.initialWalletSync());
|
|
1727
|
+
}
|
|
1728
|
+
}
|
|
1729
|
+
async getMantaPayZkBalance(address, tokenInfo) {
|
|
1730
|
+
var _this$chainService$ma17;
|
|
1731
|
+
const bnAssetId = new _util.BN((0, _utils._getTokenOnChainAssetId)(tokenInfo));
|
|
1732
|
+
const balance = await ((_this$chainService$ma17 = this.chainService.mantaPay.privateWallet) === null || _this$chainService$ma17 === void 0 ? void 0 : _this$chainService$ma17.getZkBalance(bnAssetId));
|
|
1733
|
+
return {
|
|
1734
|
+
decimals: tokenInfo.decimals || 0,
|
|
1735
|
+
symbol: tokenInfo.symbol,
|
|
1736
|
+
value: (balance === null || balance === void 0 ? void 0 : balance.toString()) || '0'
|
|
1737
|
+
};
|
|
1738
|
+
}
|
|
1739
|
+
subscribeMantaPaySyncState() {
|
|
1740
|
+
return this.chainService.mantaPay.subscribeSyncState();
|
|
1741
|
+
}
|
|
1559
1742
|
}
|
|
1560
1743
|
exports.default = KoniState;
|
|
@@ -25,11 +25,6 @@ var _util = require("@polkadot/util");
|
|
|
25
25
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
26
26
|
// SPDX-License-Identifier: Apache-2.0
|
|
27
27
|
|
|
28
|
-
function stripUrl(url) {
|
|
29
|
-
(0, _util.assert)(url && (url.startsWith('http:') || url.startsWith('https:') || url.startsWith('ipfs:') || url.startsWith('ipns:')), `Invalid url ${url}, expected to start with http: or https: or ipfs: or ipns:`);
|
|
30
|
-
const parts = url.split('/');
|
|
31
|
-
return parts[2];
|
|
32
|
-
}
|
|
33
28
|
function transformAccountsV2(accounts) {
|
|
34
29
|
let anyType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
35
30
|
let authInfo = arguments.length > 2 ? arguments[2] : undefined;
|
|
@@ -227,7 +222,7 @@ class KoniTabs {
|
|
|
227
222
|
});
|
|
228
223
|
}
|
|
229
224
|
checkPassList(_url) {
|
|
230
|
-
const url = stripUrl(_url);
|
|
225
|
+
const url = (0, _utils2.stripUrl)(_url);
|
|
231
226
|
const result = this.#passPhishing[url];
|
|
232
227
|
return result ? !result.pass : true;
|
|
233
228
|
}
|
|
@@ -262,7 +257,7 @@ class KoniTabs {
|
|
|
262
257
|
}
|
|
263
258
|
async getAuthInfo(url) {
|
|
264
259
|
const authList = await this.#koniState.getAuthList();
|
|
265
|
-
const shortenUrl = stripUrl(url);
|
|
260
|
+
const shortenUrl = (0, _utils2.stripUrl)(url);
|
|
266
261
|
return authList[shortenUrl];
|
|
267
262
|
}
|
|
268
263
|
async accountsListV2(url, _ref10) {
|
|
@@ -399,7 +394,7 @@ class KoniTabs {
|
|
|
399
394
|
}
|
|
400
395
|
const [networkKey] = this.#koniState.findNetworkKeyByChainId(parseInt(chainId, 16));
|
|
401
396
|
if (networkKey) {
|
|
402
|
-
await this.#koniState.switchEvmNetworkByUrl(stripUrl(url), networkKey);
|
|
397
|
+
await this.#koniState.switchEvmNetworkByUrl((0, _utils2.stripUrl)(url), networkKey);
|
|
403
398
|
} else {
|
|
404
399
|
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, `Not found chainId ${chainId} in wallet`);
|
|
405
400
|
}
|
|
@@ -444,7 +439,7 @@ class KoniTabs {
|
|
|
444
439
|
tokenInfo.contractError = true;
|
|
445
440
|
} else {
|
|
446
441
|
tokenInfo.slug = validate === null || validate === void 0 ? void 0 : validate.existedSlug;
|
|
447
|
-
tokenInfo.name = validate.name;
|
|
442
|
+
tokenInfo.name = validate.name || tokenInfo.name;
|
|
448
443
|
tokenInfo.symbol = validate.symbol;
|
|
449
444
|
tokenInfo.decimals = validate.decimals;
|
|
450
445
|
}
|
|
@@ -875,6 +870,61 @@ class KoniTabs {
|
|
|
875
870
|
return false;
|
|
876
871
|
}
|
|
877
872
|
}
|
|
873
|
+
async addPspToken(id, url, _ref21) {
|
|
874
|
+
let {
|
|
875
|
+
genesisHash,
|
|
876
|
+
tokenInfo: input
|
|
877
|
+
} = _ref21;
|
|
878
|
+
const _tokenType = input.type;
|
|
879
|
+
if (_tokenType !== 'psp22' && _tokenType !== 'psp34') {
|
|
880
|
+
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, `Assets type ${_tokenType} is not supported`);
|
|
881
|
+
}
|
|
882
|
+
if (!input.address || !input.symbol) {
|
|
883
|
+
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, 'Assets params require address and symbol');
|
|
884
|
+
}
|
|
885
|
+
const [chain] = this.#koniState.findNetworkKeyByGenesisHash(genesisHash);
|
|
886
|
+
if (!chain) {
|
|
887
|
+
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INTERNAL_ERROR, 'Current chain is not available');
|
|
888
|
+
}
|
|
889
|
+
const state = this.#koniState.getChainStateByKey(chain);
|
|
890
|
+
if (!state.active) {
|
|
891
|
+
await this.#koniState.enableChain(chain, false);
|
|
892
|
+
const api = this.#koniState.getSubstrateApi(chain);
|
|
893
|
+
await api.isReady;
|
|
894
|
+
}
|
|
895
|
+
const tokenType = _tokenType === 'psp22' ? _types._AssetType.PSP22 : _types._AssetType.PSP34;
|
|
896
|
+
const tokenInfo = {
|
|
897
|
+
slug: '',
|
|
898
|
+
type: tokenType,
|
|
899
|
+
name: input.symbol || '',
|
|
900
|
+
contractAddress: input.address,
|
|
901
|
+
symbol: input.symbol || '',
|
|
902
|
+
decimals: input.decimals || 0,
|
|
903
|
+
originChain: chain,
|
|
904
|
+
contractError: false,
|
|
905
|
+
validated: false
|
|
906
|
+
};
|
|
907
|
+
this.#koniState.validateCustomAsset({
|
|
908
|
+
type: tokenType,
|
|
909
|
+
contractAddress: input.address,
|
|
910
|
+
originChain: chain
|
|
911
|
+
}).then(validate => {
|
|
912
|
+
if (validate.contractError) {
|
|
913
|
+
tokenInfo.contractError = true;
|
|
914
|
+
} else {
|
|
915
|
+
tokenInfo.slug = validate === null || validate === void 0 ? void 0 : validate.existedSlug;
|
|
916
|
+
tokenInfo.name = validate.name || tokenInfo.name;
|
|
917
|
+
tokenInfo.symbol = validate.symbol;
|
|
918
|
+
tokenInfo.decimals = validate.decimals;
|
|
919
|
+
}
|
|
920
|
+
}).catch(() => {
|
|
921
|
+
tokenInfo.contractError = true;
|
|
922
|
+
}).finally(() => {
|
|
923
|
+
tokenInfo.validated = true;
|
|
924
|
+
this.#koniState.requestService.updateConfirmation(id, 'addTokenRequest', tokenInfo);
|
|
925
|
+
});
|
|
926
|
+
return await this.#koniState.addTokenConfirm(id, url, tokenInfo);
|
|
927
|
+
}
|
|
878
928
|
async handle(id, type, request, url, port) {
|
|
879
929
|
if (type === 'pub(phishing.redirectIfDenied)') {
|
|
880
930
|
return this.redirectIfPhishing(url);
|
|
@@ -910,6 +960,8 @@ class KoniTabs {
|
|
|
910
960
|
return this.rpcSubscribeConnected(request, id, port);
|
|
911
961
|
case 'pub(rpc.unsubscribe)':
|
|
912
962
|
return this.rpcUnsubscribe(request, port);
|
|
963
|
+
case 'pub(token.add)':
|
|
964
|
+
return this.addPspToken(id, url, request);
|
|
913
965
|
|
|
914
966
|
///
|
|
915
967
|
case 'pub(authorize.tabV2)':
|
|
@@ -158,12 +158,15 @@ class KoniSubscription {
|
|
|
158
158
|
const unsub = (0, _balance.subscribeBalance)(addresses, filteredChainInfoMap, substrateApiMap, evmApiMap, result => {
|
|
159
159
|
this.state.setBalanceItem(result.tokenSlug, result);
|
|
160
160
|
});
|
|
161
|
+
const unsub2 = this.state.subscribeMantaPayBalance();
|
|
161
162
|
if (onlyRunOnFirstTime) {
|
|
162
163
|
unsub && unsub();
|
|
164
|
+
unsub2 && unsub2();
|
|
163
165
|
return;
|
|
164
166
|
}
|
|
165
167
|
return () => {
|
|
166
168
|
unsub && unsub();
|
|
169
|
+
unsub2 && unsub2();
|
|
167
170
|
};
|
|
168
171
|
}
|
|
169
172
|
initCrowdloanSubscription(addresses, substrateApiMap, onlyRunOnFirstTime) {
|
package/cjs/packageInfo.js
CHANGED
package/cjs/page/Metadata.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports._XCM_TYPE = exports._XCM_CHAIN_GROUP = exports._TRANSFER_NOT_SUPPORTED_CHAINS = exports._TRANSFER_CHAIN_GROUP = exports._SUBSTRATE_DEFAULT_INFLATION_PARAMS = exports._STAKING_ERA_LENGTH_MAP = exports._STAKING_CHAIN_GROUP = exports._PURE_EVM_CHAINS = exports._PREDEFINED_SINGLE_MODES = exports._PARACHAIN_INFLATION_DISTRIBUTION = exports._NFT_CHAIN_GROUP = exports._MULTI_CHAIN_ASSET_SRC = exports._KNOWN_CHAIN_INFLATION_PARAMS = exports._DEFAULT_ACTIVE_CHAINS = exports._CHAIN_LOGO_MAP_SRC = exports._CHAIN_INFO_SRC = exports._CHAIN_ASSET_SRC = exports._BALANCE_TOKEN_GROUP = exports._BALANCE_PARSING_CHAIN_GROUP = exports._BALANCE_CHAIN_GROUP = exports._ASSET_REF_SRC = exports._ASSET_LOGO_MAP_SRC = exports._API_OPTIONS_CHAIN_GROUP = exports.API_MAX_RETRY = exports.API_CONNECT_TIMEOUT = exports.API_AUTO_CONNECT_MS = void 0;
|
|
6
|
+
exports._ZK_ASSET_PREFIX = exports._XCM_TYPE = exports._XCM_CHAIN_GROUP = exports._TRANSFER_NOT_SUPPORTED_CHAINS = exports._TRANSFER_CHAIN_GROUP = exports._SUBSTRATE_DEFAULT_INFLATION_PARAMS = exports._STAKING_ERA_LENGTH_MAP = exports._STAKING_CHAIN_GROUP = exports._PURE_EVM_CHAINS = exports._PREDEFINED_SINGLE_MODES = exports._PARACHAIN_INFLATION_DISTRIBUTION = exports._NFT_CHAIN_GROUP = exports._MULTI_CHAIN_ASSET_SRC = exports._MANTA_ZK_CHAIN_GROUP = exports._KNOWN_CHAIN_INFLATION_PARAMS = exports._DEFAULT_MANTA_ZK_CHAIN = exports._DEFAULT_ACTIVE_CHAINS = exports._CHAIN_LOGO_MAP_SRC = exports._CHAIN_INFO_SRC = exports._CHAIN_ASSET_SRC = exports._BALANCE_TOKEN_GROUP = exports._BALANCE_PARSING_CHAIN_GROUP = exports._BALANCE_CHAIN_GROUP = exports._ASSET_REF_SRC = exports._ASSET_LOGO_MAP_SRC = exports._API_OPTIONS_CHAIN_GROUP = exports.API_MAX_RETRY = exports.API_CONNECT_TIMEOUT = exports.API_AUTO_CONNECT_MS = void 0;
|
|
7
7
|
var _chainList = require("@subwallet/chain-list");
|
|
8
8
|
var _types = require("@subwallet/chain-list/types");
|
|
9
9
|
var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
@@ -38,7 +38,7 @@ const _BALANCE_CHAIN_GROUP = {
|
|
|
38
38
|
genshiro: ['genshiro_testnet', 'genshiro'],
|
|
39
39
|
equilibrium_parachain: ['equilibrium_parachain'],
|
|
40
40
|
bifrost: ['bifrost', 'acala', 'karura', 'acala_testnet', 'pioneer', 'bitcountry', 'bifrost_dot', 'hydradx_main'],
|
|
41
|
-
statemine: ['statemine', 'astar', 'shiden', 'statemint', 'moonbeam', 'moonbase', 'moonriver', 'crabParachain', 'darwinia2', 'parallel'],
|
|
41
|
+
statemine: ['statemine', 'astar', 'shiden', 'statemint', 'moonbeam', 'moonbase', 'moonriver', 'crabParachain', 'darwinia2', 'parallel', 'calamari'],
|
|
42
42
|
kusama: ['kusama', 'kintsugi', 'kintsugi_test', 'interlay', 'acala', 'statemint', 'karura', 'bifrost'] // perhaps there are some runtime updates
|
|
43
43
|
};
|
|
44
44
|
exports._BALANCE_CHAIN_GROUP = _BALANCE_CHAIN_GROUP;
|
|
@@ -207,9 +207,15 @@ exports._TRANSFER_CHAIN_GROUP = _TRANSFER_CHAIN_GROUP;
|
|
|
207
207
|
const _BALANCE_PARSING_CHAIN_GROUP = {
|
|
208
208
|
bobabeam: ['bobabeam', 'bobabase']
|
|
209
209
|
};
|
|
210
|
+
exports._BALANCE_PARSING_CHAIN_GROUP = _BALANCE_PARSING_CHAIN_GROUP;
|
|
211
|
+
const _MANTA_ZK_CHAIN_GROUP = ['calamari'];
|
|
212
|
+
exports._MANTA_ZK_CHAIN_GROUP = _MANTA_ZK_CHAIN_GROUP;
|
|
213
|
+
const _ZK_ASSET_PREFIX = 'zk';
|
|
214
|
+
exports._ZK_ASSET_PREFIX = _ZK_ASSET_PREFIX;
|
|
215
|
+
const _DEFAULT_MANTA_ZK_CHAIN = 'calamari';
|
|
210
216
|
|
|
211
217
|
// XCM------------------------------------------------------------------------------------------------------------------
|
|
212
|
-
exports.
|
|
218
|
+
exports._DEFAULT_MANTA_ZK_CHAIN = _DEFAULT_MANTA_ZK_CHAIN;
|
|
213
219
|
const _XCM_CHAIN_GROUP = {
|
|
214
220
|
polkadotXcm: ['astar', 'shiden', 'statemine', 'statemint', 'equilibrium_parachain'],
|
|
215
221
|
xcmPallet: ['polkadot', 'kusama']
|
|
@@ -228,7 +234,7 @@ const _DEFAULT_ACTIVE_CHAINS = [..._chainList._DEFAULT_CHAINS];
|
|
|
228
234
|
|
|
229
235
|
// TODO: review
|
|
230
236
|
exports._DEFAULT_ACTIVE_CHAINS = _DEFAULT_ACTIVE_CHAINS;
|
|
231
|
-
const TARGET_BRANCH = process.env.NODE_ENV !== 'production' ? 'koni-
|
|
237
|
+
const TARGET_BRANCH = process.env.NODE_ENV !== 'production' ? 'koni/dev/issue-15' : 'master';
|
|
232
238
|
const _CHAIN_INFO_SRC = `https://raw.githubusercontent.com/Koniverse/SubWallet-Chain/${TARGET_BRANCH}/packages/chain-list/src/data/ChainInfo.json`;
|
|
233
239
|
exports._CHAIN_INFO_SRC = _CHAIN_INFO_SRC;
|
|
234
240
|
const _CHAIN_ASSET_SRC = `https://raw.githubusercontent.com/Koniverse/SubWallet-Chain/${TARGET_BRANCH}/packages/chain-list/src/data/ChainAsset.json`;
|
|
@@ -75,6 +75,7 @@ class SubstrateApi {
|
|
|
75
75
|
}
|
|
76
76
|
constructor(chainSlug, apiUrl) {
|
|
77
77
|
let {
|
|
78
|
+
externalApiPromise,
|
|
78
79
|
metadata,
|
|
79
80
|
providerName
|
|
80
81
|
} = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
@@ -84,7 +85,7 @@ class SubstrateApi {
|
|
|
84
85
|
this.registry = new _create.TypeRegistry();
|
|
85
86
|
this.metadata = metadata;
|
|
86
87
|
this.provider = this.createProvider(apiUrl);
|
|
87
|
-
this.api = this.createApi(this.provider);
|
|
88
|
+
this.api = externalApiPromise || this.createApi(this.provider);
|
|
88
89
|
this.handleApiReady = (0, _promise.createPromiseHandler)();
|
|
89
90
|
this.api.on('ready', this.onReady.bind(this));
|
|
90
91
|
this.api.on('connected', this.onConnect.bind(this));
|
|
@@ -182,6 +182,7 @@ class SubstrateChainHandler extends _AbstractChainHandler.AbstractChainHandler {
|
|
|
182
182
|
async initApi(chainSlug, apiUrl) {
|
|
183
183
|
var _this$parent2;
|
|
184
184
|
let {
|
|
185
|
+
externalApiPromise,
|
|
185
186
|
onUpdateStatus,
|
|
186
187
|
providerName
|
|
187
188
|
} = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
@@ -198,7 +199,8 @@ class SubstrateChainHandler extends _AbstractChainHandler.AbstractChainHandler {
|
|
|
198
199
|
const metadata = await ((_this$parent2 = this.parent) === null || _this$parent2 === void 0 ? void 0 : _this$parent2.getMetadata(chainSlug));
|
|
199
200
|
const apiObject = new _SubstrateApi2.SubstrateApi(chainSlug, apiUrl, {
|
|
200
201
|
providerName,
|
|
201
|
-
metadata
|
|
202
|
+
metadata,
|
|
203
|
+
externalApiPromise
|
|
202
204
|
});
|
|
203
205
|
apiObject.isApiConnectedSubject.subscribe(this.handleConnect.bind(this, chainSlug));
|
|
204
206
|
onUpdateStatus && apiObject.isApiConnectedSubject.subscribe(onUpdateStatus);
|