@subwallet/extension-base 1.1.2-0 → 1.1.3-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 +32 -4
- package/background/KoniTypes.js +2 -1
- package/cjs/background/KoniTypes.js +4 -2
- package/cjs/constants/i18n.js +10 -2
- package/cjs/koni/api/dotsama/transfer.js +6 -2
- package/cjs/koni/api/nft/acala_nft/index.js +0 -2
- package/cjs/koni/api/nft/bit.country/index.js +49 -18
- package/cjs/koni/api/nft/config.js +5 -3
- package/cjs/koni/api/nft/evm_nft/index.js +0 -5
- package/cjs/koni/api/nft/index.js +2 -3
- package/cjs/koni/api/nft/karura_nft/index.js +0 -2
- package/cjs/koni/api/nft/rmrk_nft/index.js +0 -4
- package/cjs/koni/api/nft/statemine_nft/index.js +0 -2
- package/cjs/koni/api/nft/unique_nft/index.js +0 -5
- package/cjs/koni/api/nft/wasm_nft/index.js +0 -5
- package/cjs/koni/api/staking/bonding/amplitude.js +6 -6
- package/cjs/koni/api/staking/bonding/astar.js +6 -6
- package/cjs/koni/api/staking/bonding/paraChain.js +5 -5
- package/cjs/koni/api/staking/bonding/relayChain.js +24 -14
- package/cjs/koni/api/staking/bonding/utils.js +1 -7
- package/cjs/koni/api/xcm/xTokens.js +1 -1
- package/cjs/koni/background/cron.js +2 -37
- package/cjs/koni/background/handlers/Extension.js +206 -137
- package/cjs/koni/background/handlers/State.js +72 -84
- package/cjs/koni/background/subscription.js +6 -88
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/chain-service/constants.js +8 -5
- package/cjs/services/chain-service/handler/SubstrateApi.js +8 -0
- package/cjs/services/chain-service/handler/manta/MantaPrivateHandler.js +1 -1
- package/cjs/services/chain-service/handler/manta/manta-extension-sdk-empty.js +13 -0
- package/cjs/services/chain-service/index.js +11 -6
- package/cjs/services/request-service/handler/PopupHandler.js +2 -2
- package/cjs/services/request-service/helper/index.js +2 -26
- package/cjs/services/setting-service/constants.js +16 -6
- package/cjs/services/storage-service/DatabaseService.js +3 -0
- package/cjs/services/storage-service/db-stores/Metadata.js +1 -1
- package/cjs/services/storage-service/db-stores/Nft.js +3 -0
- package/cjs/services/storage-service/db-stores/NominatorMetadata.js +3 -2
- package/cjs/services/wallet-connect-service/constants.js +8 -5
- package/cjs/services/wallet-connect-service/index.js +50 -36
- package/cjs/utils/environment.js +32 -2
- package/cjs/utils/index.js +33 -5
- package/cjs/utils/registry.js +25 -0
- package/cjs/utils/translate.js +11 -0
- package/constants/i18n.d.ts +2 -1
- package/constants/i18n.js +8 -1
- package/koni/api/dotsama/transfer.js +6 -2
- package/koni/api/nft/acala_nft/index.js +0 -2
- package/koni/api/nft/bit.country/index.d.ts +1 -0
- package/koni/api/nft/bit.country/index.js +50 -19
- package/koni/api/nft/config.d.ts +2 -1
- package/koni/api/nft/config.js +2 -1
- package/koni/api/nft/evm_nft/index.js +0 -4
- package/koni/api/nft/index.d.ts +1 -1
- package/koni/api/nft/index.js +2 -3
- package/koni/api/nft/karura_nft/index.js +0 -2
- package/koni/api/nft/nft.d.ts +0 -1
- package/koni/api/nft/rmrk_nft/index.js +0 -4
- package/koni/api/nft/statemine_nft/index.js +0 -2
- package/koni/api/nft/unique_nft/index.js +0 -5
- package/koni/api/nft/wasm_nft/index.js +0 -4
- package/koni/api/staking/bonding/amplitude.js +6 -6
- package/koni/api/staking/bonding/astar.js +6 -6
- package/koni/api/staking/bonding/paraChain.js +5 -5
- package/koni/api/staking/bonding/relayChain.js +24 -14
- package/koni/api/staking/bonding/utils.js +1 -7
- package/koni/api/xcm/xTokens.js +1 -1
- package/koni/background/cron.d.ts +0 -5
- package/koni/background/cron.js +4 -39
- package/koni/background/handlers/Extension.d.ts +4 -0
- package/koni/background/handlers/Extension.js +97 -32
- package/koni/background/handlers/State.d.ts +8 -7
- package/koni/background/handlers/State.js +72 -84
- package/koni/background/subscription.d.ts +1 -4
- package/koni/background/subscription.js +9 -88
- package/package.json +22 -6
- package/packageInfo.js +1 -1
- package/services/chain-service/constants.d.ts +2 -0
- package/services/chain-service/constants.js +8 -5
- package/services/chain-service/handler/SubstrateApi.js +8 -0
- package/services/chain-service/handler/manta/MantaPrivateHandler.d.ts +1 -1
- package/services/chain-service/handler/manta/MantaPrivateHandler.js +1 -1
- package/services/chain-service/handler/manta/manta-extension-sdk-empty.d.ts +4 -0
- package/services/chain-service/handler/manta/manta-extension-sdk-empty.js +5 -0
- package/services/chain-service/index.d.ts +2 -1
- package/services/chain-service/index.js +11 -6
- package/services/request-service/handler/PopupHandler.js +1 -1
- package/services/request-service/helper/index.d.ts +0 -2
- package/services/request-service/helper/index.js +0 -23
- package/services/request-service/types.d.ts +0 -1
- package/services/setting-service/constants.d.ts +6 -1
- package/services/setting-service/constants.js +10 -5
- package/services/storage-service/DatabaseService.d.ts +1 -0
- package/services/storage-service/DatabaseService.js +3 -0
- package/services/storage-service/db-stores/Metadata.js +1 -1
- package/services/storage-service/db-stores/Nft.d.ts +1 -0
- package/services/storage-service/db-stores/Nft.js +3 -0
- package/services/storage-service/db-stores/NominatorMetadata.js +3 -2
- package/services/wallet-connect-service/constants.d.ts +2 -1
- package/services/wallet-connect-service/constants.js +5 -3
- package/services/wallet-connect-service/index.d.ts +0 -1
- package/services/wallet-connect-service/index.js +50 -36
- package/utils/environment.d.ts +4 -1
- package/utils/environment.js +28 -1
- package/utils/index.d.ts +3 -0
- package/utils/index.js +6 -2
- package/utils/registry.d.ts +4 -0
- package/utils/registry.js +18 -0
- package/utils/translate.d.ts +1 -0
- package/utils/translate.js +4 -0
|
@@ -222,7 +222,8 @@ class KoniState {
|
|
|
222
222
|
await this.startSubscription();
|
|
223
223
|
}
|
|
224
224
|
async initMantaPay(password) {
|
|
225
|
-
|
|
225
|
+
var _this$chainService, _this$chainService$ma;
|
|
226
|
+
const mantaPayConfig = await ((_this$chainService = this.chainService) === null || _this$chainService === void 0 ? void 0 : (_this$chainService$ma = _this$chainService.mantaPay) === null || _this$chainService$ma === void 0 ? void 0 : _this$chainService$ma.getMantaPayFirstConfig(_constants2._DEFAULT_MANTA_ZK_CHAIN));
|
|
226
227
|
if (mantaPayConfig && mantaPayConfig.enabled && !this.isMantaPayEnabled) {
|
|
227
228
|
// only init the first login
|
|
228
229
|
console.debug('Initiating MantaPay for', mantaPayConfig.address);
|
|
@@ -620,51 +621,20 @@ class KoniState {
|
|
|
620
621
|
setSettings(settings, callback) {
|
|
621
622
|
this.settingService.setSettings(settings, callback);
|
|
622
623
|
}
|
|
623
|
-
|
|
624
|
+
updateSetting(key, value) {
|
|
624
625
|
this.settingService.getSettings(settings => {
|
|
625
626
|
const newSettings = {
|
|
626
627
|
...settings,
|
|
627
|
-
|
|
628
|
-
};
|
|
629
|
-
this.settingService.setSettings(newSettings, () => {
|
|
630
|
-
callback && callback(newSettings);
|
|
631
|
-
});
|
|
632
|
-
});
|
|
633
|
-
}
|
|
634
|
-
setBrowserConfirmationType(browserConfirmationType, callback) {
|
|
635
|
-
this.settingService.getSettings(settings => {
|
|
636
|
-
const newSettings = {
|
|
637
|
-
...settings,
|
|
638
|
-
browserConfirmationType
|
|
639
|
-
};
|
|
640
|
-
this.settingService.setSettings(newSettings, () => {
|
|
641
|
-
callback && callback(newSettings);
|
|
642
|
-
});
|
|
643
|
-
});
|
|
644
|
-
}
|
|
645
|
-
setCamera(value) {
|
|
646
|
-
this.settingService.getSettings(settings => {
|
|
647
|
-
const newSettings = {
|
|
648
|
-
...settings,
|
|
649
|
-
camera: value
|
|
650
|
-
};
|
|
651
|
-
this.settingService.setSettings(newSettings);
|
|
652
|
-
});
|
|
653
|
-
}
|
|
654
|
-
setAutoLockTime(value) {
|
|
655
|
-
this.settingService.getSettings(settings => {
|
|
656
|
-
const newSettings = {
|
|
657
|
-
...settings,
|
|
658
|
-
timeAutoLock: value
|
|
628
|
+
[key]: value
|
|
659
629
|
};
|
|
660
630
|
this.settingService.setSettings(newSettings);
|
|
661
631
|
});
|
|
662
632
|
}
|
|
663
|
-
|
|
633
|
+
setShowBalance(value) {
|
|
664
634
|
this.settingService.getSettings(settings => {
|
|
665
635
|
const newSettings = {
|
|
666
636
|
...settings,
|
|
667
|
-
|
|
637
|
+
isShowBalance: value
|
|
668
638
|
};
|
|
669
639
|
this.settingService.setSettings(newSettings);
|
|
670
640
|
});
|
|
@@ -918,7 +888,8 @@ class KoniState {
|
|
|
918
888
|
async disableChain(chainSlug) {
|
|
919
889
|
await this.chainService.updateAssetSettingByChain(chainSlug, false);
|
|
920
890
|
if (_constants2._MANTA_ZK_CHAIN_GROUP.includes(chainSlug)) {
|
|
921
|
-
|
|
891
|
+
var _this$chainService2, _this$chainService2$m;
|
|
892
|
+
const mantaPayConfig = await ((_this$chainService2 = this.chainService) === null || _this$chainService2 === void 0 ? void 0 : (_this$chainService2$m = _this$chainService2.mantaPay) === null || _this$chainService2$m === void 0 ? void 0 : _this$chainService2$m.getMantaPayFirstConfig(_constants2._DEFAULT_MANTA_ZK_CHAIN));
|
|
922
893
|
if (mantaPayConfig && mantaPayConfig.enabled && this.isMantaPayEnabled) {
|
|
923
894
|
await this.disableMantaPay(mantaPayConfig.address);
|
|
924
895
|
}
|
|
@@ -1561,10 +1532,13 @@ class KoniState {
|
|
|
1561
1532
|
});
|
|
1562
1533
|
}
|
|
1563
1534
|
async reloadNft() {
|
|
1535
|
+
const currentAddress = this.keyringService.currentAccount.address;
|
|
1536
|
+
await this.dbService.removeNftsByAddress(currentAddress);
|
|
1564
1537
|
return await this.cron.reloadNft();
|
|
1565
1538
|
}
|
|
1566
1539
|
async reloadStaking() {
|
|
1567
|
-
|
|
1540
|
+
await this.subscription.reloadStaking();
|
|
1541
|
+
return true;
|
|
1568
1542
|
}
|
|
1569
1543
|
async approvePassPhishingPage(_url) {
|
|
1570
1544
|
return new Promise(resolve => {
|
|
@@ -1596,95 +1570,95 @@ class KoniState {
|
|
|
1596
1570
|
await this.chainService.init();
|
|
1597
1571
|
}
|
|
1598
1572
|
async enableMantaPay(updateStore, address, password, seedPhrase) {
|
|
1599
|
-
var _this$
|
|
1573
|
+
var _this$chainService3, _this$chainService3$m, _this$chainService4, _this$chainService4$m, _this$chainService4$m2, _this$chainService11, _this$chainService11$, _this$chainService11$2;
|
|
1600
1574
|
if (!address || (0, _utilCrypto.isEthereumAddress)(address)) {
|
|
1601
1575
|
return;
|
|
1602
1576
|
}
|
|
1603
|
-
this.chainService.mantaPay.setCurrentAddress(address);
|
|
1604
|
-
await ((_this$
|
|
1577
|
+
(_this$chainService3 = this.chainService) === null || _this$chainService3 === void 0 ? void 0 : (_this$chainService3$m = _this$chainService3.mantaPay) === null || _this$chainService3$m === void 0 ? void 0 : _this$chainService3$m.setCurrentAddress(address);
|
|
1578
|
+
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.initialSigner());
|
|
1605
1579
|
if (updateStore && seedPhrase) {
|
|
1606
|
-
var _this$
|
|
1580
|
+
var _this$chainService5, _this$chainService5$m, _this$chainService5$m2, _this$chainService6, _this$chainService6$m, _this$chainService6$m2, _this$chainService7, _this$chainService7$m, _this$chainService7$m2, _this$chainService8, _this$chainService8$m;
|
|
1607
1581
|
// first time initiation
|
|
1608
|
-
await ((_this$
|
|
1609
|
-
const authContext = await ((_this$
|
|
1610
|
-
await ((_this$
|
|
1582
|
+
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.loadUserSeedPhrase(seedPhrase));
|
|
1583
|
+
const authContext = await ((_this$chainService6 = this.chainService) === null || _this$chainService6 === void 0 ? void 0 : (_this$chainService6$m = _this$chainService6.mantaPay) === null || _this$chainService6$m === void 0 ? void 0 : (_this$chainService6$m2 = _this$chainService6$m.privateWallet) === null || _this$chainService6$m2 === void 0 ? void 0 : _this$chainService6$m2.getAuthorizationContext());
|
|
1584
|
+
await ((_this$chainService7 = this.chainService) === null || _this$chainService7 === void 0 ? void 0 : (_this$chainService7$m = _this$chainService7.mantaPay) === null || _this$chainService7$m === void 0 ? void 0 : (_this$chainService7$m2 = _this$chainService7$m.privateWallet) === null || _this$chainService7$m2 === void 0 ? void 0 : _this$chainService7$m2.loadAuthorizationContext(authContext));
|
|
1611
1585
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
|
|
1612
1586
|
const encryptedData = await passworder.encrypt(password, authContext);
|
|
1613
|
-
await this.chainService.mantaPay.saveMantaAuthContext({
|
|
1587
|
+
await ((_this$chainService8 = this.chainService) === null || _this$chainService8 === void 0 ? void 0 : (_this$chainService8$m = _this$chainService8.mantaPay) === null || _this$chainService8$m === void 0 ? void 0 : _this$chainService8$m.saveMantaAuthContext({
|
|
1614
1588
|
chain: _constants2._DEFAULT_MANTA_ZK_CHAIN,
|
|
1615
1589
|
address,
|
|
1616
1590
|
data: encryptedData
|
|
1617
|
-
});
|
|
1591
|
+
}));
|
|
1618
1592
|
} else {
|
|
1619
|
-
var _this$
|
|
1620
|
-
const authContext = await this.chainService.mantaPay.getMantaAuthContext(address, _constants2._DEFAULT_MANTA_ZK_CHAIN);
|
|
1593
|
+
var _this$chainService9, _this$chainService9$m, _this$chainService10, _this$chainService10$, _this$chainService10$2;
|
|
1594
|
+
const authContext = await ((_this$chainService9 = this.chainService) === null || _this$chainService9 === void 0 ? void 0 : (_this$chainService9$m = _this$chainService9.mantaPay) === null || _this$chainService9$m === void 0 ? void 0 : _this$chainService9$m.getMantaAuthContext(address, _constants2._DEFAULT_MANTA_ZK_CHAIN));
|
|
1621
1595
|
|
|
1622
1596
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
|
|
1623
1597
|
const decryptedData = await passworder.decrypt(password, authContext.data);
|
|
1624
1598
|
|
|
1625
1599
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument,@typescript-eslint/no-unsafe-member-access
|
|
1626
1600
|
const proofAuthKey = new Uint8Array(Object.values(decryptedData.proof_authorization_key));
|
|
1627
|
-
await ((_this$
|
|
1601
|
+
await ((_this$chainService10 = this.chainService) === null || _this$chainService10 === void 0 ? void 0 : (_this$chainService10$ = _this$chainService10.mantaPay) === null || _this$chainService10$ === void 0 ? void 0 : (_this$chainService10$2 = _this$chainService10$.privateWallet) === null || _this$chainService10$2 === void 0 ? void 0 : _this$chainService10$2.loadAuthorizationContext({
|
|
1628
1602
|
proof_authorization_key: proofAuthKey
|
|
1629
1603
|
}));
|
|
1630
1604
|
}
|
|
1631
|
-
const zkAddress = await ((_this$
|
|
1605
|
+
const zkAddress = await ((_this$chainService11 = this.chainService) === null || _this$chainService11 === void 0 ? void 0 : (_this$chainService11$ = _this$chainService11.mantaPay) === null || _this$chainService11$ === void 0 ? void 0 : (_this$chainService11$2 = _this$chainService11$.privateWallet) === null || _this$chainService11$2 === void 0 ? void 0 : _this$chainService11$2.getZkAddress());
|
|
1632
1606
|
if (updateStore) {
|
|
1633
|
-
var _this$
|
|
1634
|
-
await this.chainService.mantaPay
|
|
1607
|
+
var _this$chainService12, _this$chainService12$, _this$chainService13, _this$chainService13$, _this$chainService13$2, _this$chainService13$3;
|
|
1608
|
+
await ((_this$chainService12 = this.chainService) === null || _this$chainService12 === void 0 ? void 0 : (_this$chainService12$ = _this$chainService12.mantaPay) === null || _this$chainService12$ === void 0 ? void 0 : _this$chainService12$.saveMantaPayConfig({
|
|
1635
1609
|
address,
|
|
1636
1610
|
zkAddress: zkAddress,
|
|
1637
1611
|
enabled: true,
|
|
1638
|
-
chain: (_this$
|
|
1612
|
+
chain: (_this$chainService13 = this.chainService) === null || _this$chainService13 === void 0 ? void 0 : (_this$chainService13$ = _this$chainService13.mantaPay) === null || _this$chainService13$ === void 0 ? void 0 : (_this$chainService13$2 = _this$chainService13$.privateWallet) === null || _this$chainService13$2 === void 0 ? void 0 : (_this$chainService13$3 = _this$chainService13$2.network) === null || _this$chainService13$3 === void 0 ? void 0 : _this$chainService13$3.toLowerCase(),
|
|
1639
1613
|
isInitialSync: false
|
|
1640
|
-
});
|
|
1614
|
+
}));
|
|
1641
1615
|
}
|
|
1642
1616
|
this.isMantaPayEnabled = true;
|
|
1643
1617
|
return zkAddress;
|
|
1644
1618
|
}
|
|
1645
1619
|
async disableMantaPay(address) {
|
|
1646
|
-
var _this$
|
|
1647
|
-
const config = await this.chainService.mantaPay
|
|
1620
|
+
var _this$chainService14, _this$chainService14$, _this$chainService15, _this$chainService15$, _this$chainService15$2, _this$chainService16, _this$chainService16$, _this$chainService16$2, _this$chainService17, _this$chainService17$, _this$chainService18, _this$chainService18$;
|
|
1621
|
+
const config = await ((_this$chainService14 = this.chainService) === null || _this$chainService14 === void 0 ? void 0 : (_this$chainService14$ = _this$chainService14.mantaPay) === null || _this$chainService14$ === void 0 ? void 0 : _this$chainService14$.getMantaPayConfig(address, _constants2._DEFAULT_MANTA_ZK_CHAIN));
|
|
1648
1622
|
if (!config) {
|
|
1649
1623
|
return false;
|
|
1650
1624
|
}
|
|
1651
|
-
await ((_this$
|
|
1652
|
-
await ((_this$
|
|
1653
|
-
// await this.chainService
|
|
1654
|
-
await this.chainService.mantaPay
|
|
1655
|
-
await this.chainService.mantaPay
|
|
1625
|
+
await ((_this$chainService15 = this.chainService) === null || _this$chainService15 === void 0 ? void 0 : (_this$chainService15$ = _this$chainService15.mantaPay) === null || _this$chainService15$ === void 0 ? void 0 : (_this$chainService15$2 = _this$chainService15$.privateWallet) === null || _this$chainService15$2 === void 0 ? void 0 : _this$chainService15$2.dropAuthorizationContext());
|
|
1626
|
+
await ((_this$chainService16 = this.chainService) === null || _this$chainService16 === void 0 ? void 0 : (_this$chainService16$ = _this$chainService16.mantaPay) === null || _this$chainService16$ === void 0 ? void 0 : (_this$chainService16$2 = _this$chainService16$.privateWallet) === null || _this$chainService16$2 === void 0 ? void 0 : _this$chainService16$2.dropUserSeedPhrase());
|
|
1627
|
+
// await this.chainService?.mantaPay?.privateWallet?.resetState();
|
|
1628
|
+
await ((_this$chainService17 = this.chainService) === null || _this$chainService17 === void 0 ? void 0 : (_this$chainService17$ = _this$chainService17.mantaPay) === null || _this$chainService17$ === void 0 ? void 0 : _this$chainService17$.deleteMantaPayConfig(address, _constants2._DEFAULT_MANTA_ZK_CHAIN));
|
|
1629
|
+
await ((_this$chainService18 = this.chainService) === null || _this$chainService18 === void 0 ? void 0 : (_this$chainService18$ = _this$chainService18.mantaPay) === null || _this$chainService18$ === void 0 ? void 0 : _this$chainService18$.deleteMantaAuthContext(address, _constants2._DEFAULT_MANTA_ZK_CHAIN));
|
|
1656
1630
|
this.chainService.setMantaZkAssetSettings(false);
|
|
1657
1631
|
this.isMantaPayEnabled = false;
|
|
1658
1632
|
return true;
|
|
1659
1633
|
}
|
|
1660
1634
|
async initialSyncMantaPay(address) {
|
|
1661
|
-
var _this$
|
|
1635
|
+
var _this$chainService19, _this$chainService19$, _this$chainService20, _this$chainService20$, _this$chainService20$2, _this$chainService20$3, _this$chainService21, _this$chainService21$, _this$chainService21$2, _this$chainService22, _this$chainService22$;
|
|
1662
1636
|
if (!address || (0, _utilCrypto.isEthereumAddress)(address)) {
|
|
1663
1637
|
return;
|
|
1664
1638
|
}
|
|
1665
|
-
this.chainService.mantaPay
|
|
1666
|
-
await ((_this$
|
|
1667
|
-
const syncResult = await ((_this$
|
|
1668
|
-
await this.chainService.mantaPay
|
|
1639
|
+
(_this$chainService19 = this.chainService) === null || _this$chainService19 === void 0 ? void 0 : (_this$chainService19$ = _this$chainService19.mantaPay) === null || _this$chainService19$ === void 0 ? void 0 : _this$chainService19$.setCurrentAddress(address);
|
|
1640
|
+
await ((_this$chainService20 = this.chainService) === null || _this$chainService20 === void 0 ? void 0 : (_this$chainService20$ = _this$chainService20.mantaPay) === null || _this$chainService20$ === void 0 ? void 0 : (_this$chainService20$2 = _this$chainService20$.privateWallet) === null || _this$chainService20$2 === void 0 ? void 0 : (_this$chainService20$3 = _this$chainService20$2.baseWallet) === null || _this$chainService20$3 === void 0 ? void 0 : _this$chainService20$3.isApiReady());
|
|
1641
|
+
const syncResult = await ((_this$chainService21 = this.chainService) === null || _this$chainService21 === void 0 ? void 0 : (_this$chainService21$ = _this$chainService21.mantaPay) === null || _this$chainService21$ === void 0 ? void 0 : (_this$chainService21$2 = _this$chainService21$.privateWallet) === null || _this$chainService21$2 === void 0 ? void 0 : _this$chainService21$2.initialWalletSync());
|
|
1642
|
+
await ((_this$chainService22 = this.chainService) === null || _this$chainService22 === void 0 ? void 0 : (_this$chainService22$ = _this$chainService22.mantaPay) === null || _this$chainService22$ === void 0 ? void 0 : _this$chainService22$.updateMantaPayConfig(address, _constants2._DEFAULT_MANTA_ZK_CHAIN, {
|
|
1669
1643
|
isInitialSync: true
|
|
1670
|
-
});
|
|
1644
|
+
}));
|
|
1671
1645
|
this.eventService.emit('mantaPay.initSync', undefined);
|
|
1672
1646
|
return syncResult;
|
|
1673
1647
|
}
|
|
1674
1648
|
getMantaZkBalance() {
|
|
1675
|
-
var _this$
|
|
1676
|
-
if (!this.chainService || !this.chainService.mantaPay) {
|
|
1649
|
+
var _this$chainService23, _this$chainService24, _this$chainService24$, _this$chainService24$2, _this$chainService25, _this$chainService25$, _this$chainService26, _this$chainService26$, _this$chainService26$2;
|
|
1650
|
+
if (!this.chainService || !((_this$chainService23 = this.chainService) !== null && _this$chainService23 !== void 0 && _this$chainService23.mantaPay)) {
|
|
1677
1651
|
return;
|
|
1678
1652
|
}
|
|
1679
|
-
if (!((_this$
|
|
1653
|
+
if (!((_this$chainService24 = this.chainService) !== null && _this$chainService24 !== void 0 && (_this$chainService24$ = _this$chainService24.mantaPay) !== null && _this$chainService24$ !== void 0 && (_this$chainService24$2 = _this$chainService24$.privateWallet) !== null && _this$chainService24$2 !== void 0 && _this$chainService24$2.initialSyncIsFinished)) {
|
|
1680
1654
|
return;
|
|
1681
1655
|
}
|
|
1682
|
-
const chain = (_this$
|
|
1656
|
+
const chain = (_this$chainService25 = this.chainService) === null || _this$chainService25 === void 0 ? void 0 : (_this$chainService25$ = _this$chainService25.mantaPay.privateWallet) === null || _this$chainService25$ === void 0 ? void 0 : _this$chainService25$.network;
|
|
1683
1657
|
if (!chain) {
|
|
1684
1658
|
return;
|
|
1685
1659
|
}
|
|
1686
1660
|
const assetMap = this.chainService.getMantaZkAssets(chain === null || chain === void 0 ? void 0 : chain.toLowerCase());
|
|
1687
|
-
(_this$
|
|
1661
|
+
(_this$chainService26 = this.chainService) === null || _this$chainService26 === void 0 ? void 0 : (_this$chainService26$ = _this$chainService26.mantaPay) === null || _this$chainService26$ === void 0 ? void 0 : (_this$chainService26$2 = _this$chainService26$.privateWallet) === null || _this$chainService26$2 === void 0 ? void 0 : _this$chainService26$2.getMultiZkBalance(Object.values(assetMap).map(tokenInfo => new _util.BN((0, _utils._getTokenOnChainAssetId)(tokenInfo)))).then(zkBalances => {
|
|
1688
1662
|
const assetList = Object.values(assetMap);
|
|
1689
1663
|
for (let i = 0; i < assetList.length; i++) {
|
|
1690
1664
|
var _zkBalances$i;
|
|
@@ -1701,8 +1675,9 @@ class KoniState {
|
|
|
1701
1675
|
}).catch(console.warn);
|
|
1702
1676
|
}
|
|
1703
1677
|
subscribeMantaPayBalance() {
|
|
1678
|
+
var _this$chainService27, _this$chainService27$;
|
|
1704
1679
|
let interval;
|
|
1705
|
-
this.chainService.mantaPay
|
|
1680
|
+
(_this$chainService27 = this.chainService) === null || _this$chainService27 === void 0 ? void 0 : (_this$chainService27$ = _this$chainService27.mantaPay) === null || _this$chainService27$ === void 0 ? void 0 : _this$chainService27$.getMantaPayConfig(this.keyringService.currentAccount.address, _constants2._DEFAULT_MANTA_ZK_CHAIN).then(config => {
|
|
1706
1681
|
if (config && config.enabled && config.isInitialSync) {
|
|
1707
1682
|
this.getMantaZkBalance();
|
|
1708
1683
|
interval = setInterval(this.getMantaZkBalance, _constants.MANTA_PAY_BALANCE_INTERVAL);
|
|
@@ -1713,23 +1688,23 @@ class KoniState {
|
|
|
1713
1688
|
};
|
|
1714
1689
|
}
|
|
1715
1690
|
async syncMantaPay() {
|
|
1716
|
-
var _this$
|
|
1717
|
-
const config = await this.chainService.mantaPay
|
|
1691
|
+
var _this$chainService28, _this$chainService28$, _this$chainService29, _this$chainService29$, _this$chainService29$2;
|
|
1692
|
+
const config = await ((_this$chainService28 = this.chainService) === null || _this$chainService28 === void 0 ? void 0 : (_this$chainService28$ = _this$chainService28.mantaPay) === null || _this$chainService28$ === void 0 ? void 0 : _this$chainService28$.getMantaPayFirstConfig(_constants2._DEFAULT_MANTA_ZK_CHAIN));
|
|
1718
1693
|
if (!config.isInitialSync) {
|
|
1719
1694
|
return;
|
|
1720
1695
|
}
|
|
1721
|
-
if ((_this$
|
|
1722
|
-
var _this$
|
|
1723
|
-
await ((_this$
|
|
1696
|
+
if ((_this$chainService29 = this.chainService) !== null && _this$chainService29 !== void 0 && (_this$chainService29$ = _this$chainService29.mantaPay) !== null && _this$chainService29$ !== void 0 && (_this$chainService29$2 = _this$chainService29$.privateWallet) !== null && _this$chainService29$2 !== void 0 && _this$chainService29$2.initialSyncIsFinished) {
|
|
1697
|
+
var _this$chainService30, _this$chainService30$, _this$chainService30$2;
|
|
1698
|
+
await ((_this$chainService30 = this.chainService) === null || _this$chainService30 === void 0 ? void 0 : (_this$chainService30$ = _this$chainService30.mantaPay) === null || _this$chainService30$ === void 0 ? void 0 : (_this$chainService30$2 = _this$chainService30$.privateWallet) === null || _this$chainService30$2 === void 0 ? void 0 : _this$chainService30$2.walletSync());
|
|
1724
1699
|
} else {
|
|
1725
|
-
var _this$
|
|
1726
|
-
await ((_this$
|
|
1700
|
+
var _this$chainService31, _this$chainService31$, _this$chainService31$2;
|
|
1701
|
+
await ((_this$chainService31 = this.chainService) === null || _this$chainService31 === void 0 ? void 0 : (_this$chainService31$ = _this$chainService31.mantaPay) === null || _this$chainService31$ === void 0 ? void 0 : (_this$chainService31$2 = _this$chainService31$.privateWallet) === null || _this$chainService31$2 === void 0 ? void 0 : _this$chainService31$2.initialWalletSync());
|
|
1727
1702
|
}
|
|
1728
1703
|
}
|
|
1729
1704
|
async getMantaPayZkBalance(address, tokenInfo) {
|
|
1730
|
-
var _this$
|
|
1705
|
+
var _this$chainService32, _this$chainService32$, _this$chainService32$2;
|
|
1731
1706
|
const bnAssetId = new _util.BN((0, _utils._getTokenOnChainAssetId)(tokenInfo));
|
|
1732
|
-
const balance = await ((_this$
|
|
1707
|
+
const balance = await ((_this$chainService32 = this.chainService) === null || _this$chainService32 === void 0 ? void 0 : (_this$chainService32$ = _this$chainService32.mantaPay) === null || _this$chainService32$ === void 0 ? void 0 : (_this$chainService32$2 = _this$chainService32$.privateWallet) === null || _this$chainService32$2 === void 0 ? void 0 : _this$chainService32$2.getZkBalance(bnAssetId));
|
|
1733
1708
|
return {
|
|
1734
1709
|
decimals: tokenInfo.decimals || 0,
|
|
1735
1710
|
symbol: tokenInfo.symbol,
|
|
@@ -1737,7 +1712,20 @@ class KoniState {
|
|
|
1737
1712
|
};
|
|
1738
1713
|
}
|
|
1739
1714
|
subscribeMantaPaySyncState() {
|
|
1740
|
-
|
|
1715
|
+
var _this$chainService33, _this$chainService34, _this$chainService34$;
|
|
1716
|
+
if (!((_this$chainService33 = this.chainService) !== null && _this$chainService33 !== void 0 && _this$chainService33.mantaPay)) {
|
|
1717
|
+
return new _rxjs.Subject();
|
|
1718
|
+
}
|
|
1719
|
+
return (_this$chainService34 = this.chainService) === null || _this$chainService34 === void 0 ? void 0 : (_this$chainService34$ = _this$chainService34.mantaPay) === null || _this$chainService34$ === void 0 ? void 0 : _this$chainService34$.subscribeSyncState();
|
|
1720
|
+
}
|
|
1721
|
+
|
|
1722
|
+
// Metadata
|
|
1723
|
+
async findMetadata(hash) {
|
|
1724
|
+
const metadata = await this.chainService.getMetadataByHash(hash);
|
|
1725
|
+
return {
|
|
1726
|
+
metadata: (metadata === null || metadata === void 0 ? void 0 : metadata.hexValue) || '',
|
|
1727
|
+
specVersion: parseInt((metadata === null || metadata === void 0 ? void 0 : metadata.specVersion) || '0')
|
|
1728
|
+
};
|
|
1741
1729
|
}
|
|
1742
1730
|
}
|
|
1743
1731
|
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
|
|
|
@@ -198,8 +193,6 @@ class KoniSubscription {
|
|
|
198
193
|
return _this.state.updateNftData(...arguments);
|
|
199
194
|
}, function () {
|
|
200
195
|
return _this.state.setNftCollection(...arguments);
|
|
201
|
-
}, function () {
|
|
202
|
-
return _this.state.cleanUpNfts(...arguments);
|
|
203
196
|
}).catch(this.logger.log);
|
|
204
197
|
}
|
|
205
198
|
async subscribeStakingReward(address) {
|
|
@@ -250,86 +243,11 @@ class KoniSubscription {
|
|
|
250
243
|
};
|
|
251
244
|
await Promise.all([(0, _staking.getPoolingStakingRewardData)(pooledAddresses, targetChainMap, this.state.getSubstrateApiMap(), updateState), (0, _paraChain.getAmplitudeUnclaimedStakingReward)(this.state.getSubstrateApiMap(), addresses, chainInfoMap, activeNetworks, updateState)]);
|
|
252
245
|
}
|
|
253
|
-
async
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
}
|
|
259
|
-
} catch (e) {
|
|
260
|
-
this.logger.error(e);
|
|
261
|
-
}
|
|
262
|
-
return {};
|
|
263
|
-
}
|
|
264
|
-
async fetchChainStakingMetadata(chainInfoMap, chainStateMap, substrateApiMap) {
|
|
265
|
-
const filteredChainInfoMap = {};
|
|
266
|
-
Object.values(chainInfoMap).forEach(chainInfo => {
|
|
267
|
-
const chainState = chainStateMap[chainInfo.slug];
|
|
268
|
-
if (chainState !== null && chainState !== void 0 && chainState.active && (0, _utils._isChainSupportSubstrateStaking)(chainInfo)) {
|
|
269
|
-
filteredChainInfoMap[chainInfo.slug] = chainInfo;
|
|
270
|
-
}
|
|
271
|
-
});
|
|
272
|
-
if (Object.values(filteredChainInfoMap).length === 0) {
|
|
273
|
-
return;
|
|
274
|
-
}
|
|
275
|
-
const timeout = new Promise(resolve => {
|
|
276
|
-
const id = setTimeout(() => {
|
|
277
|
-
clearTimeout(id);
|
|
278
|
-
resolve(null);
|
|
279
|
-
}, 3000);
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
// Fetch data from helper API
|
|
283
|
-
const _dataFromApi = await Promise.race([this.fetchingStakingFromApi(), timeout]);
|
|
284
|
-
const dataFromApi = _dataFromApi;
|
|
285
|
-
await Promise.all(Object.values(filteredChainInfoMap).map(async chainInfo => {
|
|
286
|
-
// Use fetch API data if available
|
|
287
|
-
if (dataFromApi && dataFromApi[chainInfo.slug]) {
|
|
288
|
-
this.state.updateChainStakingMetadata(dataFromApi[chainInfo.slug], {
|
|
289
|
-
expectedReturn: dataFromApi[chainInfo.slug].expectedReturn,
|
|
290
|
-
inflation: dataFromApi[chainInfo.slug].inflation,
|
|
291
|
-
nominatorCount: dataFromApi[chainInfo.slug].nominatorCount
|
|
292
|
-
});
|
|
293
|
-
} else {
|
|
294
|
-
const chainStakingMetadata = await (0, _bonding.getChainStakingMetadata)(chainInfo, substrateApiMap[chainInfo.slug]);
|
|
295
|
-
this.state.updateChainStakingMetadata(chainStakingMetadata, {
|
|
296
|
-
expectedReturn: chainStakingMetadata.expectedReturn,
|
|
297
|
-
inflation: chainStakingMetadata.inflation,
|
|
298
|
-
nominatorCount: chainStakingMetadata.nominatorCount
|
|
299
|
-
});
|
|
300
|
-
}
|
|
301
|
-
}));
|
|
302
|
-
}
|
|
303
|
-
async fetchNominatorMetadata(currentAddress, chainInfoMap, chainStateMap, substrateApiMap) {
|
|
304
|
-
const filteredChainInfoMap = {};
|
|
305
|
-
Object.values(chainInfoMap).forEach(chainInfo => {
|
|
306
|
-
const chainState = chainStateMap[chainInfo.slug];
|
|
307
|
-
if (chainState !== null && chainState !== void 0 && chainState.active && (0, _utils._isChainSupportSubstrateStaking)(chainInfo)) {
|
|
308
|
-
filteredChainInfoMap[chainInfo.slug] = chainInfo;
|
|
309
|
-
}
|
|
310
|
-
});
|
|
311
|
-
let addresses = [currentAddress];
|
|
312
|
-
if (currentAddress === _constants.ALL_ACCOUNT_KEY) {
|
|
313
|
-
addresses = await this.state.getStakingOwnersByChains(Object.keys(filteredChainInfoMap));
|
|
314
|
-
}
|
|
315
|
-
await Promise.all(addresses.map(async address => {
|
|
316
|
-
const isEvmAddress = (0, _utilCrypto.isEthereumAddress)(address);
|
|
317
|
-
await Promise.all(Object.values(filteredChainInfoMap).map(async chainInfo => {
|
|
318
|
-
if (isEvmAddress && !(0, _utils._isChainEvmCompatible)(chainInfo)) {
|
|
319
|
-
return;
|
|
320
|
-
}
|
|
321
|
-
if ((0, _utils._isSubstrateRelayChain)(chainInfo) && _constants2._STAKING_CHAIN_GROUP.nominationPool.includes(chainInfo.slug)) {
|
|
322
|
-
const poolMemberMetadata = await (0, _relayChain.getRelayChainPoolMemberMetadata)(chainInfo, address, substrateApiMap[chainInfo.slug]);
|
|
323
|
-
if (poolMemberMetadata) {
|
|
324
|
-
this.state.updateStakingNominatorMetadata(poolMemberMetadata);
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
const nominatorMetadata = await (0, _bonding.getNominatorMetadata)(chainInfo, address, substrateApiMap[chainInfo.slug]);
|
|
328
|
-
if (nominatorMetadata) {
|
|
329
|
-
this.state.updateStakingNominatorMetadata(nominatorMetadata);
|
|
330
|
-
}
|
|
331
|
-
}));
|
|
332
|
-
}));
|
|
246
|
+
async reloadStaking() {
|
|
247
|
+
var _this$state$keyringSe2;
|
|
248
|
+
const currentAddress = (_this$state$keyringSe2 = this.state.keyringService.currentAccount) === null || _this$state$keyringSe2 === void 0 ? void 0 : _this$state$keyringSe2.address;
|
|
249
|
+
this.subscribeStakingOnChain(currentAddress, this.state.getSubstrateApiMap());
|
|
250
|
+
await (0, _utils2.waitTimeout)(1800);
|
|
333
251
|
}
|
|
334
252
|
}
|
|
335
253
|
exports.KoniSubscription = KoniSubscription;
|
package/cjs/packageInfo.js
CHANGED
|
@@ -18,7 +18,8 @@ const API_MAX_RETRY = 2;
|
|
|
18
18
|
exports.API_MAX_RETRY = API_MAX_RETRY;
|
|
19
19
|
const _API_OPTIONS_CHAIN_GROUP = {
|
|
20
20
|
acala: ['acala', 'karura', 'origintrail', 'kintsugi'],
|
|
21
|
-
turing: ['turingStaging', 'turing']
|
|
21
|
+
turing: ['turingStaging', 'turing'],
|
|
22
|
+
avail: ['kate']
|
|
22
23
|
};
|
|
23
24
|
exports._API_OPTIONS_CHAIN_GROUP = _API_OPTIONS_CHAIN_GROUP;
|
|
24
25
|
const _PREDEFINED_SINGLE_MODES = {
|
|
@@ -37,7 +38,7 @@ const _BALANCE_CHAIN_GROUP = {
|
|
|
37
38
|
kintsugi: ['kintsugi', 'interlay', 'kintsugi_test', 'mangatax_para'],
|
|
38
39
|
genshiro: ['genshiro_testnet', 'genshiro'],
|
|
39
40
|
equilibrium_parachain: ['equilibrium_parachain'],
|
|
40
|
-
bifrost: ['bifrost', 'acala', 'karura', 'acala_testnet', 'pioneer', 'bitcountry', 'bifrost_dot', 'hydradx_main'],
|
|
41
|
+
bifrost: ['bifrost', 'acala', 'karura', 'acala_testnet', 'pioneer', 'bitcountry', 'bifrost_dot', 'hydradx_main', 'pendulum'],
|
|
41
42
|
statemine: ['statemine', 'astar', 'shiden', 'statemint', 'moonbeam', 'moonbase', 'moonriver', 'crabParachain', 'darwinia2', 'parallel', 'calamari'],
|
|
42
43
|
kusama: ['kusama', 'kintsugi', 'kintsugi_test', 'interlay', 'acala', 'statemint', 'karura', 'bifrost'] // perhaps there are some runtime updates
|
|
43
44
|
};
|
|
@@ -63,7 +64,7 @@ const _STAKING_CHAIN_GROUP = {
|
|
|
63
64
|
relay: ['polkadot', 'kusama', 'aleph', 'polkadex', 'ternoa', 'ternoa_alphanet', 'alephTest', 'polkadexTest', 'westend'],
|
|
64
65
|
para: ['moonbeam', 'moonriver', 'moonbase', 'turing', 'turingStaging', 'bifrost', 'bifrost_testnet', 'calamari_test', 'calamari'],
|
|
65
66
|
astar: ['astar', 'shiden', 'shibuya'],
|
|
66
|
-
amplitude: ['amplitude', 'amplitude_test', 'kilt', 'kilt_peregrine'],
|
|
67
|
+
amplitude: ['amplitude', 'amplitude_test', 'kilt', 'kilt_peregrine', 'pendulum'],
|
|
67
68
|
// amplitude and kilt only share some common logic
|
|
68
69
|
kilt: ['kilt', 'kilt_peregrine'],
|
|
69
70
|
nominationPool: ['polkadot', 'kusama', 'westend', 'alephTest', 'aleph'],
|
|
@@ -97,6 +98,7 @@ const _STAKING_ERA_LENGTH_MAP = {
|
|
|
97
98
|
calamari_test: 6,
|
|
98
99
|
amplitude: 2,
|
|
99
100
|
amplitude_test: 2,
|
|
101
|
+
pendulum: 2,
|
|
100
102
|
kilt: 2,
|
|
101
103
|
kilt_peregrine: 2
|
|
102
104
|
};
|
|
@@ -201,7 +203,8 @@ const _TRANSFER_CHAIN_GROUP = {
|
|
|
201
203
|
statemine: ['statemint', 'statemine', 'darwinia2', 'astar', 'shiden', 'shibuya', 'parallel'],
|
|
202
204
|
riochain: ['riochain'],
|
|
203
205
|
sora_substrate: ['sora_substrate'],
|
|
204
|
-
avail: ['kate']
|
|
206
|
+
avail: ['kate'],
|
|
207
|
+
pendulum: ['pendulum']
|
|
205
208
|
};
|
|
206
209
|
exports._TRANSFER_CHAIN_GROUP = _TRANSFER_CHAIN_GROUP;
|
|
207
210
|
const _BALANCE_PARSING_CHAIN_GROUP = {
|
|
@@ -234,7 +237,7 @@ const _DEFAULT_ACTIVE_CHAINS = [..._chainList._DEFAULT_CHAINS];
|
|
|
234
237
|
|
|
235
238
|
// TODO: review
|
|
236
239
|
exports._DEFAULT_ACTIVE_CHAINS = _DEFAULT_ACTIVE_CHAINS;
|
|
237
|
-
const TARGET_BRANCH = process.env.NODE_ENV !== 'production' ? 'koni
|
|
240
|
+
const TARGET_BRANCH = process.env.NODE_ENV !== 'production' ? 'koni-dev' : 'master';
|
|
238
241
|
const _CHAIN_INFO_SRC = `https://raw.githubusercontent.com/Koniverse/SubWallet-Chain/${TARGET_BRANCH}/packages/chain-list/src/data/ChainInfo.json`;
|
|
239
242
|
exports._CHAIN_INFO_SRC = _CHAIN_INFO_SRC;
|
|
240
243
|
const _CHAIN_ASSET_SRC = `https://raw.githubusercontent.com/Koniverse/SubWallet-Chain/${TARGET_BRANCH}/packages/chain-list/src/data/ChainAsset.json`;
|
|
@@ -11,6 +11,7 @@ var _constants = require("@subwallet/extension-base/services/chain-service/const
|
|
|
11
11
|
var _lightClient = require("@subwallet/extension-base/services/chain-service/handler/light-client");
|
|
12
12
|
var _SubstrateChainHandler = require("@subwallet/extension-base/services/chain-service/handler/SubstrateChainHandler");
|
|
13
13
|
var _promise = require("@subwallet/extension-base/utils/promise");
|
|
14
|
+
var _availJsSdk = require("avail-js-sdk");
|
|
14
15
|
var _rxjs = require("rxjs");
|
|
15
16
|
var _api2 = require("@polkadot/api");
|
|
16
17
|
var _api3 = require("@polkadot/apps-config/api");
|
|
@@ -69,6 +70,13 @@ class SubstrateApi {
|
|
|
69
70
|
rpc: _types.rpc,
|
|
70
71
|
types: _types.types
|
|
71
72
|
});
|
|
73
|
+
} else if (_constants._API_OPTIONS_CHAIN_GROUP.avail.includes(this.chainSlug)) {
|
|
74
|
+
return new _api2.ApiPromise({
|
|
75
|
+
provider,
|
|
76
|
+
rpc: _availJsSdk.spec.rpc,
|
|
77
|
+
types: _availJsSdk.spec.types,
|
|
78
|
+
signedExtensions: _availJsSdk.spec.signedExtensions
|
|
79
|
+
});
|
|
72
80
|
} else {
|
|
73
81
|
return new _api2.ApiPromise(apiOption);
|
|
74
82
|
}
|
|
@@ -94,7 +94,7 @@ class MantaPrivateHandler {
|
|
|
94
94
|
|
|
95
95
|
const baseWallet = await _mantaExtensionSdk.BaseWallet.init({
|
|
96
96
|
apiEndpoint: providerUrl,
|
|
97
|
-
loggingEnabled:
|
|
97
|
+
loggingEnabled: true,
|
|
98
98
|
provingFilePath: './manta-pay/proving',
|
|
99
99
|
parametersFilePath: './manta-pay/parameters',
|
|
100
100
|
saveStorageStateToLocal: this.saveLedgerState.bind(this),
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.MantaPayWallet = exports.BaseWallet = void 0;
|
|
7
|
+
// Copyright 2019-2022 @subwallet/web-runner authors & contributors
|
|
8
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
9
|
+
|
|
10
|
+
class BaseWallet {}
|
|
11
|
+
exports.BaseWallet = BaseWallet;
|
|
12
|
+
class MantaPayWallet {}
|
|
13
|
+
exports.MantaPayWallet = MantaPayWallet;
|
|
@@ -15,6 +15,7 @@ var _types2 = require("@subwallet/extension-base/services/chain-service/handler/
|
|
|
15
15
|
var _types3 = require("@subwallet/extension-base/services/chain-service/types");
|
|
16
16
|
var _utils = require("@subwallet/extension-base/services/chain-service/utils");
|
|
17
17
|
var _AssetSetting = _interopRequireDefault(require("@subwallet/extension-base/stores/AssetSetting"));
|
|
18
|
+
var _utils2 = require("@subwallet/extension-base/utils");
|
|
18
19
|
var _rxjs = require("rxjs");
|
|
19
20
|
var _web = _interopRequireDefault(require("web3"));
|
|
20
21
|
var _logger = require("@polkadot/util/logger");
|
|
@@ -47,14 +48,14 @@ class ChainService {
|
|
|
47
48
|
constructor(dbService, eventService) {
|
|
48
49
|
this.dbService = dbService;
|
|
49
50
|
this.eventService = eventService;
|
|
50
|
-
this.substrateChainHandler = new _SubstrateChainHandler.SubstrateChainHandler();
|
|
51
|
-
this.evmChainHandler = new _EvmChainHandler.EvmChainHandler();
|
|
52
|
-
this.mantaChainHandler = new _MantaPrivateHandler.MantaPrivateHandler(dbService);
|
|
53
51
|
this.chainInfoMapSubject.next(this.dataMap.chainInfoMap);
|
|
54
52
|
this.chainStateMapSubject.next(this.dataMap.chainStateMap);
|
|
55
|
-
this.chainInfoMapSubject.next(this.dataMap.chainInfoMap);
|
|
56
53
|
this.assetRegistrySubject.next(this.dataMap.assetRegistry);
|
|
57
54
|
this.xcmRefMapSubject.next(this.dataMap.assetRefMap);
|
|
55
|
+
if (_utils2.MODULE_SUPPORT.MANTA_ZK) {
|
|
56
|
+
console.log('Init Manta ZK');
|
|
57
|
+
this.mantaChainHandler = new _MantaPrivateHandler.MantaPrivateHandler(dbService);
|
|
58
|
+
}
|
|
58
59
|
this.substrateChainHandler = new _SubstrateChainHandler.SubstrateChainHandler(this);
|
|
59
60
|
this.evmChainHandler = new _EvmChainHandler.EvmChainHandler(this);
|
|
60
61
|
this.logger = (0, _logger.logger)('chain-service');
|
|
@@ -433,8 +434,9 @@ class ChainService {
|
|
|
433
434
|
}
|
|
434
435
|
};
|
|
435
436
|
if (chainInfo.substrateInfo !== null && chainInfo.substrateInfo !== undefined) {
|
|
436
|
-
if (_constants._MANTA_ZK_CHAIN_GROUP.includes(chainInfo.slug)) {
|
|
437
|
-
|
|
437
|
+
if (_constants._MANTA_ZK_CHAIN_GROUP.includes(chainInfo.slug) && _utils2.MODULE_SUPPORT.MANTA_ZK && this.mantaChainHandler) {
|
|
438
|
+
var _this$mantaChainHandl;
|
|
439
|
+
const apiPromise = await ((_this$mantaChainHandl = this.mantaChainHandler) === null || _this$mantaChainHandl === void 0 ? void 0 : _this$mantaChainHandl.initMantaPay(endpoint, chainInfo.slug));
|
|
438
440
|
const chainApi = await this.substrateChainHandler.initApi(chainInfo.slug, endpoint, {
|
|
439
441
|
providerName,
|
|
440
442
|
externalApiPromise: apiPromise,
|
|
@@ -1322,5 +1324,8 @@ class ChainService {
|
|
|
1322
1324
|
upsertMetadata(chain, metadata) {
|
|
1323
1325
|
return this.dbService.stores.metadata.upsertMetadata(chain, metadata);
|
|
1324
1326
|
}
|
|
1327
|
+
getMetadataByHash(hash) {
|
|
1328
|
+
return this.dbService.stores.metadata.getMetadataByGenesisHash(hash);
|
|
1329
|
+
}
|
|
1325
1330
|
}
|
|
1326
1331
|
exports.ChainService = ChainService;
|
|
@@ -5,13 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _helpers = require("@subwallet/extension-base/background/handlers/helpers");
|
|
8
|
-
var _helper = require("@subwallet/extension-base/services/request-service/helper");
|
|
9
8
|
var _constants = require("@subwallet/extension-base/services/setting-service/constants");
|
|
9
|
+
var _utils = require("@subwallet/extension-base/utils");
|
|
10
10
|
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
11
11
|
// SPDX-License-Identifier: Apache-2.0
|
|
12
12
|
|
|
13
13
|
const NOTIFICATION_URL = chrome.extension.getURL('notification.html');
|
|
14
|
-
const OS = (0,
|
|
14
|
+
const OS = (0, _utils.getOS)();
|
|
15
15
|
const extraHeight = OS === 'Linux' ? 0 : 28;
|
|
16
16
|
const extraWidth = OS === 'Windows' ? 16 : 0;
|
|
17
17
|
const POPUP_WINDOW_OPTS = {
|