@subwallet/extension-base 1.0.13-0 → 1.1.1-dev.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/background/KoniTypes.d.ts +37 -0
- package/background/KoniTypes.js +8 -1
- package/background/handlers/Extension.js +17 -2
- package/background/types.d.ts +6 -1
- package/bundle-polkadot-extension-base.js +20 -0
- package/cjs/background/KoniTypes.js +10 -2
- package/cjs/background/handlers/Extension.js +22 -6
- 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/staking/bonding/astar.js +2 -2
- package/cjs/koni/api/staking/bonding/relayChain.js +12 -2
- package/cjs/koni/api/staking/bonding/utils.js +2 -2
- package/cjs/koni/background/cron.js +13 -37
- package/cjs/koni/background/handlers/Extension.js +324 -147
- package/cjs/koni/background/handlers/State.js +224 -51
- package/cjs/koni/background/subscription.js +9 -86
- package/cjs/packageInfo.js +1 -1
- 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/helper/erc20_abi.json +224 -0
- package/cjs/services/chain-service/helper/erc721_abi.json +384 -0
- package/cjs/services/chain-service/helper/psp22_abi.json +1127 -0
- package/cjs/services/chain-service/helper/psp34_abi.json +3144 -0
- package/cjs/services/chain-service/helper/test_erc721_abi.json +393 -0
- package/cjs/services/chain-service/index.js +54 -5
- package/cjs/services/chain-service/utils.js +6 -1
- package/cjs/services/event-service/types.js +3 -1
- 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/utils/index.js +12 -0
- 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/staking/bonding/astar.d.ts +1 -1
- package/koni/api/staking/bonding/astar.js +1 -1
- package/koni/api/staking/bonding/relayChain.js +12 -2
- package/koni/api/staking/bonding/utils.js +3 -3
- package/koni/background/cron.d.ts +1 -5
- package/koni/background/cron.js +15 -39
- package/koni/background/handlers/Extension.d.ts +5 -0
- package/koni/background/handlers/Extension.js +186 -11
- package/koni/background/handlers/State.d.ts +15 -3
- package/koni/background/handlers/State.js +226 -50
- package/koni/background/subscription.d.ts +1 -4
- package/koni/background/subscription.js +11 -87
- package/package.json +23 -6
- package/packageInfo.js +1 -1
- 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 +1 -0
- package/services/chain-service/utils.js +5 -1
- package/services/event-service/types.d.ts +3 -0
- package/services/event-service/types.js +3 -1
- 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/utils/index.d.ts +1 -0
- package/utils/index.js +2 -1
- package/utils/lazy.d.ts +2 -0
- package/utils/lazy.js +43 -0
|
@@ -44,6 +44,8 @@ var _subscription = require("../subscription");
|
|
|
44
44
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
45
45
|
// SPDX-License-Identifier: Apache-2.0
|
|
46
46
|
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
|
|
48
|
+
const passworder = require('browser-passworder');
|
|
47
49
|
const ETH_DERIVE_DEFAULT = '/m/44\'/60\'/0\'/0/0';
|
|
48
50
|
|
|
49
51
|
// List of providers passed into constructor. This is the list of providers
|
|
@@ -75,6 +77,8 @@ class KoniState {
|
|
|
75
77
|
crowdloanMap = generateDefaultCrowdloanMap();
|
|
76
78
|
crowdloanSubject = new _rxjs.Subject();
|
|
77
79
|
nftSubject = new _rxjs.Subject();
|
|
80
|
+
mantaPayConfigSubject = new _rxjs.Subject();
|
|
81
|
+
isMantaPayEnabled = false;
|
|
78
82
|
stakingSubject = new _rxjs.Subject();
|
|
79
83
|
chainStakingMetadataSubject = new _rxjs.Subject();
|
|
80
84
|
stakingNominatorMetadataSubject = new _rxjs.Subject();
|
|
@@ -217,11 +221,25 @@ class KoniState {
|
|
|
217
221
|
this.onAccountRemove();
|
|
218
222
|
await this.startSubscription();
|
|
219
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
|
+
}
|
|
220
235
|
async startSubscription() {
|
|
221
236
|
await this.eventService.waitKeyringReady;
|
|
222
237
|
this.dbService.subscribeChainStakingMetadata([], data => {
|
|
223
238
|
this.chainStakingMetadataSubject.next(data);
|
|
224
239
|
});
|
|
240
|
+
this.dbService.subscribeMantaPayConfig(_constants2._DEFAULT_MANTA_ZK_CHAIN, data => {
|
|
241
|
+
this.mantaPayConfigSubject.next(data);
|
|
242
|
+
});
|
|
225
243
|
let unsub;
|
|
226
244
|
this.keyringService.accountSubject.subscribe(accounts => {
|
|
227
245
|
// TODO: improve this
|
|
@@ -297,6 +315,10 @@ class KoniState {
|
|
|
297
315
|
async getNominatorMetadata() {
|
|
298
316
|
return this.dbService.getNominatorMetadata();
|
|
299
317
|
}
|
|
318
|
+
async getMantaPayConfig(chain) {
|
|
319
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
320
|
+
return this.dbService.getMantaPayConfig(chain);
|
|
321
|
+
}
|
|
300
322
|
async getStaking() {
|
|
301
323
|
const addresses = this.getDecodedAddresses();
|
|
302
324
|
const stakings = await this.dbService.getStakings(addresses, this.activeChainSlugs);
|
|
@@ -318,6 +340,9 @@ class KoniState {
|
|
|
318
340
|
async getPooledStakingRecordsByAddress(addresses) {
|
|
319
341
|
return this.dbService.getPooledStakings(addresses, this.activeChainSlugs);
|
|
320
342
|
}
|
|
343
|
+
subscribeMantaPayConfig() {
|
|
344
|
+
return this.mantaPayConfigSubject;
|
|
345
|
+
}
|
|
321
346
|
subscribeStaking() {
|
|
322
347
|
return this.stakingSubject;
|
|
323
348
|
}
|
|
@@ -891,8 +916,13 @@ class KoniState {
|
|
|
891
916
|
return result;
|
|
892
917
|
};
|
|
893
918
|
async disableChain(chainSlug) {
|
|
894
|
-
// const defaultChains = this.getDefaultNetworkKeys();
|
|
895
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
|
+
}
|
|
896
926
|
return this.chainService.disableChain(chainSlug);
|
|
897
927
|
}
|
|
898
928
|
async enableChain(chainSlug) {
|
|
@@ -1327,50 +1357,51 @@ class KoniState {
|
|
|
1327
1357
|
return await this.requestService.completeConfirmation(request);
|
|
1328
1358
|
}
|
|
1329
1359
|
onInstall() {
|
|
1330
|
-
const singleModes = Object.values(
|
|
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
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
}
|
|
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
|
+
// });
|
|
1374
1405
|
}
|
|
1375
1406
|
get activeNetworks() {
|
|
1376
1407
|
return this.chainService.getActiveChainInfos();
|
|
@@ -1458,9 +1489,6 @@ class KoniState {
|
|
|
1458
1489
|
createUnsubscriptionHandle(id, unsubscribe) {
|
|
1459
1490
|
this.unsubscriptionMap[id] = unsubscribe;
|
|
1460
1491
|
}
|
|
1461
|
-
updateChainConnectionStatus(chain, status) {
|
|
1462
|
-
this.chainService.setChainConnectionStatus(chain, status);
|
|
1463
|
-
}
|
|
1464
1492
|
async autoEnableChains(addresses) {
|
|
1465
1493
|
const assetMap = this.chainService.getAssetRegistry();
|
|
1466
1494
|
const promiseList = addresses.map(address => {
|
|
@@ -1475,7 +1503,7 @@ class KoniState {
|
|
|
1475
1503
|
const chainMap = this.chainService.getChainInfoMap();
|
|
1476
1504
|
const balanceDataList = await Promise.all(promiseList);
|
|
1477
1505
|
balanceDataList.forEach(balanceData => {
|
|
1478
|
-
balanceData && balanceData.forEach(
|
|
1506
|
+
balanceData && balanceData.forEach(_ref12 => {
|
|
1479
1507
|
var _currentAssetSettings;
|
|
1480
1508
|
let {
|
|
1481
1509
|
balance,
|
|
@@ -1484,7 +1512,7 @@ class KoniState {
|
|
|
1484
1512
|
locked,
|
|
1485
1513
|
network,
|
|
1486
1514
|
symbol
|
|
1487
|
-
} =
|
|
1515
|
+
} = _ref12;
|
|
1488
1516
|
const chain = _subscanChainMap.SUBSCAN_CHAIN_MAP_REVERSE[network];
|
|
1489
1517
|
const chainInfo = chain ? chainMap[chain] : null;
|
|
1490
1518
|
const balanceIsEmpty = (!balance || balance === '0') && (!locked || locked === '0') && (!bonded || bonded === '0');
|
|
@@ -1536,7 +1564,8 @@ class KoniState {
|
|
|
1536
1564
|
return await this.cron.reloadNft();
|
|
1537
1565
|
}
|
|
1538
1566
|
async reloadStaking() {
|
|
1539
|
-
|
|
1567
|
+
await this.subscription.reloadStaking();
|
|
1568
|
+
return true;
|
|
1540
1569
|
}
|
|
1541
1570
|
async approvePassPhishingPage(_url) {
|
|
1542
1571
|
return new Promise(resolve => {
|
|
@@ -1567,5 +1596,149 @@ class KoniState {
|
|
|
1567
1596
|
await this.walletConnectService.resetWallet(resetAll);
|
|
1568
1597
|
await this.chainService.init();
|
|
1569
1598
|
}
|
|
1599
|
+
async enableMantaPay(updateStore, address, password, seedPhrase) {
|
|
1600
|
+
var _this$chainService$ma, _this$chainService$ma6;
|
|
1601
|
+
if (!address || (0, _utilCrypto.isEthereumAddress)(address)) {
|
|
1602
|
+
return;
|
|
1603
|
+
}
|
|
1604
|
+
this.chainService.mantaPay.setCurrentAddress(address);
|
|
1605
|
+
await ((_this$chainService$ma = this.chainService.mantaPay.privateWallet) === null || _this$chainService$ma === void 0 ? void 0 : _this$chainService$ma.initialSigner());
|
|
1606
|
+
if (updateStore && seedPhrase) {
|
|
1607
|
+
var _this$chainService$ma2, _this$chainService$ma3, _this$chainService$ma4;
|
|
1608
|
+
// first time initiation
|
|
1609
|
+
await ((_this$chainService$ma2 = this.chainService.mantaPay.privateWallet) === null || _this$chainService$ma2 === void 0 ? void 0 : _this$chainService$ma2.loadUserSeedPhrase(seedPhrase));
|
|
1610
|
+
const authContext = await ((_this$chainService$ma3 = this.chainService.mantaPay.privateWallet) === null || _this$chainService$ma3 === void 0 ? void 0 : _this$chainService$ma3.getAuthorizationContext());
|
|
1611
|
+
await ((_this$chainService$ma4 = this.chainService.mantaPay.privateWallet) === null || _this$chainService$ma4 === void 0 ? void 0 : _this$chainService$ma4.loadAuthorizationContext(authContext));
|
|
1612
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
|
|
1613
|
+
const encryptedData = await passworder.encrypt(password, authContext);
|
|
1614
|
+
await this.chainService.mantaPay.saveMantaAuthContext({
|
|
1615
|
+
chain: _constants2._DEFAULT_MANTA_ZK_CHAIN,
|
|
1616
|
+
address,
|
|
1617
|
+
data: encryptedData
|
|
1618
|
+
});
|
|
1619
|
+
} else {
|
|
1620
|
+
var _this$chainService$ma5;
|
|
1621
|
+
const authContext = await this.chainService.mantaPay.getMantaAuthContext(address, _constants2._DEFAULT_MANTA_ZK_CHAIN);
|
|
1622
|
+
|
|
1623
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
|
|
1624
|
+
const decryptedData = await passworder.decrypt(password, authContext.data);
|
|
1625
|
+
|
|
1626
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument,@typescript-eslint/no-unsafe-member-access
|
|
1627
|
+
const proofAuthKey = new Uint8Array(Object.values(decryptedData.proof_authorization_key));
|
|
1628
|
+
await ((_this$chainService$ma5 = this.chainService.mantaPay.privateWallet) === null || _this$chainService$ma5 === void 0 ? void 0 : _this$chainService$ma5.loadAuthorizationContext({
|
|
1629
|
+
proof_authorization_key: proofAuthKey
|
|
1630
|
+
}));
|
|
1631
|
+
}
|
|
1632
|
+
const zkAddress = await ((_this$chainService$ma6 = this.chainService.mantaPay.privateWallet) === null || _this$chainService$ma6 === void 0 ? void 0 : _this$chainService$ma6.getZkAddress());
|
|
1633
|
+
if (updateStore) {
|
|
1634
|
+
var _this$chainService$ma7, _this$chainService$ma8;
|
|
1635
|
+
await this.chainService.mantaPay.saveMantaPayConfig({
|
|
1636
|
+
address,
|
|
1637
|
+
zkAddress: zkAddress,
|
|
1638
|
+
enabled: true,
|
|
1639
|
+
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(),
|
|
1640
|
+
isInitialSync: false
|
|
1641
|
+
});
|
|
1642
|
+
}
|
|
1643
|
+
this.isMantaPayEnabled = true;
|
|
1644
|
+
return zkAddress;
|
|
1645
|
+
}
|
|
1646
|
+
async disableMantaPay(address) {
|
|
1647
|
+
var _this$chainService$ma9, _this$chainService$ma10;
|
|
1648
|
+
const config = await this.chainService.mantaPay.getMantaPayConfig(address, _constants2._DEFAULT_MANTA_ZK_CHAIN);
|
|
1649
|
+
if (!config) {
|
|
1650
|
+
return false;
|
|
1651
|
+
}
|
|
1652
|
+
await ((_this$chainService$ma9 = this.chainService.mantaPay.privateWallet) === null || _this$chainService$ma9 === void 0 ? void 0 : _this$chainService$ma9.dropAuthorizationContext());
|
|
1653
|
+
await ((_this$chainService$ma10 = this.chainService.mantaPay.privateWallet) === null || _this$chainService$ma10 === void 0 ? void 0 : _this$chainService$ma10.dropUserSeedPhrase());
|
|
1654
|
+
// await this.chainService.mantaPay.privateWallet?.resetState();
|
|
1655
|
+
await this.chainService.mantaPay.deleteMantaPayConfig(address, _constants2._DEFAULT_MANTA_ZK_CHAIN);
|
|
1656
|
+
await this.chainService.mantaPay.deleteMantaAuthContext(address, _constants2._DEFAULT_MANTA_ZK_CHAIN);
|
|
1657
|
+
this.chainService.setMantaZkAssetSettings(false);
|
|
1658
|
+
this.isMantaPayEnabled = false;
|
|
1659
|
+
return true;
|
|
1660
|
+
}
|
|
1661
|
+
async initialSyncMantaPay(address) {
|
|
1662
|
+
var _this$chainService$ma11, _this$chainService$ma12, _this$chainService$ma13;
|
|
1663
|
+
if (!address || (0, _utilCrypto.isEthereumAddress)(address)) {
|
|
1664
|
+
return;
|
|
1665
|
+
}
|
|
1666
|
+
this.chainService.mantaPay.setCurrentAddress(address);
|
|
1667
|
+
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());
|
|
1668
|
+
const syncResult = await ((_this$chainService$ma13 = this.chainService.mantaPay.privateWallet) === null || _this$chainService$ma13 === void 0 ? void 0 : _this$chainService$ma13.initialWalletSync());
|
|
1669
|
+
await this.chainService.mantaPay.updateMantaPayConfig(address, _constants2._DEFAULT_MANTA_ZK_CHAIN, {
|
|
1670
|
+
isInitialSync: true
|
|
1671
|
+
});
|
|
1672
|
+
this.eventService.emit('mantaPay.initSync', undefined);
|
|
1673
|
+
return syncResult;
|
|
1674
|
+
}
|
|
1675
|
+
getMantaZkBalance() {
|
|
1676
|
+
var _this$chainService, _this$chainService$ma14, _this$chainService$ma15, _this$chainService2, _this$chainService2$m, _this$chainService$ma16;
|
|
1677
|
+
if (!this.chainService || !this.chainService.mantaPay) {
|
|
1678
|
+
return;
|
|
1679
|
+
}
|
|
1680
|
+
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)) {
|
|
1681
|
+
return;
|
|
1682
|
+
}
|
|
1683
|
+
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;
|
|
1684
|
+
if (!chain) {
|
|
1685
|
+
return;
|
|
1686
|
+
}
|
|
1687
|
+
const assetMap = this.chainService.getMantaZkAssets(chain === null || chain === void 0 ? void 0 : chain.toLowerCase());
|
|
1688
|
+
(_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 => {
|
|
1689
|
+
const assetList = Object.values(assetMap);
|
|
1690
|
+
for (let i = 0; i < assetList.length; i++) {
|
|
1691
|
+
var _zkBalances$i;
|
|
1692
|
+
const balanceItem = {
|
|
1693
|
+
tokenSlug: assetList[i].slug,
|
|
1694
|
+
state: _KoniTypes.APIItemState.PENDING,
|
|
1695
|
+
free: '0',
|
|
1696
|
+
locked: '0'
|
|
1697
|
+
};
|
|
1698
|
+
balanceItem.free = ((_zkBalances$i = zkBalances[i]) === null || _zkBalances$i === void 0 ? void 0 : _zkBalances$i.toString()) || '0';
|
|
1699
|
+
balanceItem.state = _KoniTypes.APIItemState.READY;
|
|
1700
|
+
this.setBalanceItem(balanceItem.tokenSlug, balanceItem);
|
|
1701
|
+
}
|
|
1702
|
+
}).catch(console.warn);
|
|
1703
|
+
}
|
|
1704
|
+
subscribeMantaPayBalance() {
|
|
1705
|
+
let interval;
|
|
1706
|
+
this.chainService.mantaPay.getMantaPayConfig(this.keyringService.currentAccount.address, _constants2._DEFAULT_MANTA_ZK_CHAIN).then(config => {
|
|
1707
|
+
if (config && config.enabled && config.isInitialSync) {
|
|
1708
|
+
this.getMantaZkBalance();
|
|
1709
|
+
interval = setInterval(this.getMantaZkBalance, _constants.MANTA_PAY_BALANCE_INTERVAL);
|
|
1710
|
+
}
|
|
1711
|
+
}).catch(console.warn);
|
|
1712
|
+
return () => {
|
|
1713
|
+
interval && clearInterval(interval);
|
|
1714
|
+
};
|
|
1715
|
+
}
|
|
1716
|
+
async syncMantaPay() {
|
|
1717
|
+
var _this$chainService3, _this$chainService3$m, _this$chainService3$m2;
|
|
1718
|
+
const config = await this.chainService.mantaPay.getMantaPayFirstConfig(_constants2._DEFAULT_MANTA_ZK_CHAIN);
|
|
1719
|
+
if (!config.isInitialSync) {
|
|
1720
|
+
return;
|
|
1721
|
+
}
|
|
1722
|
+
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) {
|
|
1723
|
+
var _this$chainService4, _this$chainService4$m, _this$chainService4$m2;
|
|
1724
|
+
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());
|
|
1725
|
+
} else {
|
|
1726
|
+
var _this$chainService5, _this$chainService5$m, _this$chainService5$m2;
|
|
1727
|
+
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());
|
|
1728
|
+
}
|
|
1729
|
+
}
|
|
1730
|
+
async getMantaPayZkBalance(address, tokenInfo) {
|
|
1731
|
+
var _this$chainService$ma17;
|
|
1732
|
+
const bnAssetId = new _util.BN((0, _utils._getTokenOnChainAssetId)(tokenInfo));
|
|
1733
|
+
const balance = await ((_this$chainService$ma17 = this.chainService.mantaPay.privateWallet) === null || _this$chainService$ma17 === void 0 ? void 0 : _this$chainService$ma17.getZkBalance(bnAssetId));
|
|
1734
|
+
return {
|
|
1735
|
+
decimals: tokenInfo.decimals || 0,
|
|
1736
|
+
symbol: tokenInfo.symbol,
|
|
1737
|
+
value: (balance === null || balance === void 0 ? void 0 : balance.toString()) || '0'
|
|
1738
|
+
};
|
|
1739
|
+
}
|
|
1740
|
+
subscribeMantaPaySyncState() {
|
|
1741
|
+
return this.chainService.mantaPay.subscribeSyncState();
|
|
1742
|
+
}
|
|
1570
1743
|
}
|
|
1571
1744
|
exports.default = KoniState;
|
|
@@ -1,24 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.KoniSubscription = void 0;
|
|
8
|
-
var _constants = require("@subwallet/extension-base/constants");
|
|
9
7
|
var _balance = require("@subwallet/extension-base/koni/api/dotsama/balance");
|
|
10
8
|
var _crowdloan = require("@subwallet/extension-base/koni/api/dotsama/crowdloan");
|
|
11
9
|
var _staking = require("@subwallet/extension-base/koni/api/staking");
|
|
12
10
|
var _bonding = require("@subwallet/extension-base/koni/api/staking/bonding");
|
|
13
|
-
var _relayChain = require("@subwallet/extension-base/koni/api/staking/bonding/relayChain");
|
|
14
11
|
var _paraChain = require("@subwallet/extension-base/koni/api/staking/paraChain");
|
|
15
12
|
var _handlers = require("@subwallet/extension-base/koni/background/handlers");
|
|
16
|
-
var _constants2 = require("@subwallet/extension-base/services/chain-service/constants");
|
|
17
13
|
var _utils = require("@subwallet/extension-base/services/chain-service/utils");
|
|
18
14
|
var _types = require("@subwallet/extension-base/services/event-service/types");
|
|
19
|
-
var
|
|
15
|
+
var _utils2 = require("@subwallet/extension-base/utils");
|
|
20
16
|
var _util = require("@polkadot/util");
|
|
21
|
-
var _utilCrypto = require("@polkadot/util-crypto");
|
|
22
17
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
23
18
|
// SPDX-License-Identifier: Apache-2.0
|
|
24
19
|
|
|
@@ -158,12 +153,15 @@ class KoniSubscription {
|
|
|
158
153
|
const unsub = (0, _balance.subscribeBalance)(addresses, filteredChainInfoMap, substrateApiMap, evmApiMap, result => {
|
|
159
154
|
this.state.setBalanceItem(result.tokenSlug, result);
|
|
160
155
|
});
|
|
156
|
+
const unsub2 = this.state.subscribeMantaPayBalance();
|
|
161
157
|
if (onlyRunOnFirstTime) {
|
|
162
158
|
unsub && unsub();
|
|
159
|
+
unsub2 && unsub2();
|
|
163
160
|
return;
|
|
164
161
|
}
|
|
165
162
|
return () => {
|
|
166
163
|
unsub && unsub();
|
|
164
|
+
unsub2 && unsub2();
|
|
167
165
|
};
|
|
168
166
|
}
|
|
169
167
|
initCrowdloanSubscription(addresses, substrateApiMap, onlyRunOnFirstTime) {
|
|
@@ -247,86 +245,11 @@ class KoniSubscription {
|
|
|
247
245
|
};
|
|
248
246
|
await Promise.all([(0, _staking.getPoolingStakingRewardData)(pooledAddresses, targetChainMap, this.state.getSubstrateApiMap(), updateState), (0, _paraChain.getAmplitudeUnclaimedStakingReward)(this.state.getSubstrateApiMap(), addresses, chainInfoMap, activeNetworks, updateState)]);
|
|
249
247
|
}
|
|
250
|
-
async
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
}
|
|
256
|
-
} catch (e) {
|
|
257
|
-
this.logger.error(e);
|
|
258
|
-
}
|
|
259
|
-
return {};
|
|
260
|
-
}
|
|
261
|
-
async fetchChainStakingMetadata(chainInfoMap, chainStateMap, substrateApiMap) {
|
|
262
|
-
const filteredChainInfoMap = {};
|
|
263
|
-
Object.values(chainInfoMap).forEach(chainInfo => {
|
|
264
|
-
const chainState = chainStateMap[chainInfo.slug];
|
|
265
|
-
if (chainState !== null && chainState !== void 0 && chainState.active && (0, _utils._isChainSupportSubstrateStaking)(chainInfo)) {
|
|
266
|
-
filteredChainInfoMap[chainInfo.slug] = chainInfo;
|
|
267
|
-
}
|
|
268
|
-
});
|
|
269
|
-
if (Object.values(filteredChainInfoMap).length === 0) {
|
|
270
|
-
return;
|
|
271
|
-
}
|
|
272
|
-
const timeout = new Promise(resolve => {
|
|
273
|
-
const id = setTimeout(() => {
|
|
274
|
-
clearTimeout(id);
|
|
275
|
-
resolve(null);
|
|
276
|
-
}, 3000);
|
|
277
|
-
});
|
|
278
|
-
|
|
279
|
-
// Fetch data from helper API
|
|
280
|
-
const _dataFromApi = await Promise.race([this.fetchingStakingFromApi(), timeout]);
|
|
281
|
-
const dataFromApi = _dataFromApi;
|
|
282
|
-
await Promise.all(Object.values(filteredChainInfoMap).map(async chainInfo => {
|
|
283
|
-
// Use fetch API data if available
|
|
284
|
-
if (dataFromApi && dataFromApi[chainInfo.slug]) {
|
|
285
|
-
this.state.updateChainStakingMetadata(dataFromApi[chainInfo.slug], {
|
|
286
|
-
expectedReturn: dataFromApi[chainInfo.slug].expectedReturn,
|
|
287
|
-
inflation: dataFromApi[chainInfo.slug].inflation,
|
|
288
|
-
nominatorCount: dataFromApi[chainInfo.slug].nominatorCount
|
|
289
|
-
});
|
|
290
|
-
} else {
|
|
291
|
-
const chainStakingMetadata = await (0, _bonding.getChainStakingMetadata)(chainInfo, substrateApiMap[chainInfo.slug]);
|
|
292
|
-
this.state.updateChainStakingMetadata(chainStakingMetadata, {
|
|
293
|
-
expectedReturn: chainStakingMetadata.expectedReturn,
|
|
294
|
-
inflation: chainStakingMetadata.inflation,
|
|
295
|
-
nominatorCount: chainStakingMetadata.nominatorCount
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
}));
|
|
299
|
-
}
|
|
300
|
-
async fetchNominatorMetadata(currentAddress, chainInfoMap, chainStateMap, substrateApiMap) {
|
|
301
|
-
const filteredChainInfoMap = {};
|
|
302
|
-
Object.values(chainInfoMap).forEach(chainInfo => {
|
|
303
|
-
const chainState = chainStateMap[chainInfo.slug];
|
|
304
|
-
if (chainState !== null && chainState !== void 0 && chainState.active && (0, _utils._isChainSupportSubstrateStaking)(chainInfo)) {
|
|
305
|
-
filteredChainInfoMap[chainInfo.slug] = chainInfo;
|
|
306
|
-
}
|
|
307
|
-
});
|
|
308
|
-
let addresses = [currentAddress];
|
|
309
|
-
if (currentAddress === _constants.ALL_ACCOUNT_KEY) {
|
|
310
|
-
addresses = await this.state.getStakingOwnersByChains(Object.keys(filteredChainInfoMap));
|
|
311
|
-
}
|
|
312
|
-
await Promise.all(addresses.map(async address => {
|
|
313
|
-
const isEvmAddress = (0, _utilCrypto.isEthereumAddress)(address);
|
|
314
|
-
await Promise.all(Object.values(filteredChainInfoMap).map(async chainInfo => {
|
|
315
|
-
if (isEvmAddress && !(0, _utils._isChainEvmCompatible)(chainInfo)) {
|
|
316
|
-
return;
|
|
317
|
-
}
|
|
318
|
-
if ((0, _utils._isSubstrateRelayChain)(chainInfo) && _constants2._STAKING_CHAIN_GROUP.nominationPool.includes(chainInfo.slug)) {
|
|
319
|
-
const poolMemberMetadata = await (0, _relayChain.getRelayChainPoolMemberMetadata)(chainInfo, address, substrateApiMap[chainInfo.slug]);
|
|
320
|
-
if (poolMemberMetadata) {
|
|
321
|
-
this.state.updateStakingNominatorMetadata(poolMemberMetadata);
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
const nominatorMetadata = await (0, _bonding.getNominatorMetadata)(chainInfo, address, substrateApiMap[chainInfo.slug]);
|
|
325
|
-
if (nominatorMetadata) {
|
|
326
|
-
this.state.updateStakingNominatorMetadata(nominatorMetadata);
|
|
327
|
-
}
|
|
328
|
-
}));
|
|
329
|
-
}));
|
|
248
|
+
async reloadStaking() {
|
|
249
|
+
var _this$state$keyringSe2;
|
|
250
|
+
const currentAddress = (_this$state$keyringSe2 = this.state.keyringService.currentAccount) === null || _this$state$keyringSe2 === void 0 ? void 0 : _this$state$keyringSe2.address;
|
|
251
|
+
this.subscribeStakingOnChain(currentAddress, this.state.getSubstrateApiMap());
|
|
252
|
+
await (0, _utils2.waitTimeout)(1800);
|
|
330
253
|
}
|
|
331
254
|
}
|
|
332
255
|
exports.KoniSubscription = KoniSubscription;
|
package/cjs/packageInfo.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);
|