@subwallet/extension-base 1.1.2-1 → 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.
Files changed (51) hide show
  1. package/background/KoniTypes.d.ts +18 -0
  2. package/background/KoniTypes.js +2 -1
  3. package/cjs/background/KoniTypes.js +4 -2
  4. package/cjs/koni/api/dotsama/transfer.js +0 -2
  5. package/cjs/koni/background/handlers/Extension.js +179 -120
  6. package/cjs/koni/background/handlers/State.js +73 -48
  7. package/cjs/packageInfo.js +1 -1
  8. package/cjs/services/chain-service/constants.js +2 -1
  9. package/cjs/services/chain-service/handler/SubstrateApi.js +8 -0
  10. package/cjs/services/chain-service/handler/manta/MantaPrivateHandler.js +1 -1
  11. package/cjs/services/chain-service/handler/manta/manta-extension-sdk-empty.js +13 -0
  12. package/cjs/services/chain-service/index.js +11 -6
  13. package/cjs/services/request-service/handler/PopupHandler.js +2 -2
  14. package/cjs/services/request-service/helper/index.js +2 -26
  15. package/cjs/services/storage-service/db-stores/Metadata.js +1 -1
  16. package/cjs/services/wallet-connect-service/constants.js +8 -5
  17. package/cjs/services/wallet-connect-service/index.js +50 -36
  18. package/cjs/utils/environment.js +32 -2
  19. package/cjs/utils/index.js +21 -5
  20. package/cjs/utils/registry.js +25 -0
  21. package/koni/api/dotsama/transfer.js +0 -2
  22. package/koni/background/handlers/Extension.d.ts +2 -0
  23. package/koni/background/handlers/Extension.js +72 -15
  24. package/koni/background/handlers/State.d.ts +7 -2
  25. package/koni/background/handlers/State.js +73 -48
  26. package/package.json +17 -6
  27. package/packageInfo.js +1 -1
  28. package/services/chain-service/constants.d.ts +1 -0
  29. package/services/chain-service/constants.js +2 -1
  30. package/services/chain-service/handler/SubstrateApi.js +8 -0
  31. package/services/chain-service/handler/manta/MantaPrivateHandler.d.ts +1 -1
  32. package/services/chain-service/handler/manta/MantaPrivateHandler.js +1 -1
  33. package/services/chain-service/handler/manta/manta-extension-sdk-empty.d.ts +4 -0
  34. package/services/chain-service/handler/manta/manta-extension-sdk-empty.js +5 -0
  35. package/services/chain-service/index.d.ts +2 -1
  36. package/services/chain-service/index.js +11 -6
  37. package/services/request-service/handler/PopupHandler.js +1 -1
  38. package/services/request-service/helper/index.d.ts +0 -2
  39. package/services/request-service/helper/index.js +0 -23
  40. package/services/request-service/types.d.ts +0 -1
  41. package/services/storage-service/db-stores/Metadata.js +1 -1
  42. package/services/wallet-connect-service/constants.d.ts +2 -1
  43. package/services/wallet-connect-service/constants.js +5 -3
  44. package/services/wallet-connect-service/index.d.ts +0 -1
  45. package/services/wallet-connect-service/index.js +50 -36
  46. package/utils/environment.d.ts +4 -1
  47. package/utils/environment.js +28 -1
  48. package/utils/index.d.ts +2 -0
  49. package/utils/index.js +4 -1
  50. package/utils/registry.d.ts +4 -0
  51. package/utils/registry.js +18 -0
@@ -222,7 +222,8 @@ class KoniState {
222
222
  await this.startSubscription();
223
223
  }
224
224
  async initMantaPay(password) {
225
- const mantaPayConfig = await this.chainService.mantaPay.getMantaPayFirstConfig(_constants2._DEFAULT_MANTA_ZK_CHAIN);
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);
@@ -629,6 +630,15 @@ class KoniState {
629
630
  this.settingService.setSettings(newSettings);
630
631
  });
631
632
  }
633
+ setShowBalance(value) {
634
+ this.settingService.getSettings(settings => {
635
+ const newSettings = {
636
+ ...settings,
637
+ isShowBalance: value
638
+ };
639
+ this.settingService.setSettings(newSettings);
640
+ });
641
+ }
632
642
  subscribeSettingsSubject() {
633
643
  return this.settingService.getSubject();
634
644
  }
@@ -878,7 +888,8 @@ class KoniState {
878
888
  async disableChain(chainSlug) {
879
889
  await this.chainService.updateAssetSettingByChain(chainSlug, false);
880
890
  if (_constants2._MANTA_ZK_CHAIN_GROUP.includes(chainSlug)) {
881
- const mantaPayConfig = await this.chainService.mantaPay.getMantaPayFirstConfig(_constants2._DEFAULT_MANTA_ZK_CHAIN);
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));
882
893
  if (mantaPayConfig && mantaPayConfig.enabled && this.isMantaPayEnabled) {
883
894
  await this.disableMantaPay(mantaPayConfig.address);
884
895
  }
@@ -1559,95 +1570,95 @@ class KoniState {
1559
1570
  await this.chainService.init();
1560
1571
  }
1561
1572
  async enableMantaPay(updateStore, address, password, seedPhrase) {
1562
- var _this$chainService$ma, _this$chainService$ma6;
1573
+ var _this$chainService3, _this$chainService3$m, _this$chainService4, _this$chainService4$m, _this$chainService4$m2, _this$chainService11, _this$chainService11$, _this$chainService11$2;
1563
1574
  if (!address || (0, _utilCrypto.isEthereumAddress)(address)) {
1564
1575
  return;
1565
1576
  }
1566
- this.chainService.mantaPay.setCurrentAddress(address);
1567
- await ((_this$chainService$ma = this.chainService.mantaPay.privateWallet) === null || _this$chainService$ma === void 0 ? void 0 : _this$chainService$ma.initialSigner());
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());
1568
1579
  if (updateStore && seedPhrase) {
1569
- var _this$chainService$ma2, _this$chainService$ma3, _this$chainService$ma4;
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;
1570
1581
  // first time initiation
1571
- await ((_this$chainService$ma2 = this.chainService.mantaPay.privateWallet) === null || _this$chainService$ma2 === void 0 ? void 0 : _this$chainService$ma2.loadUserSeedPhrase(seedPhrase));
1572
- const authContext = await ((_this$chainService$ma3 = this.chainService.mantaPay.privateWallet) === null || _this$chainService$ma3 === void 0 ? void 0 : _this$chainService$ma3.getAuthorizationContext());
1573
- await ((_this$chainService$ma4 = this.chainService.mantaPay.privateWallet) === null || _this$chainService$ma4 === void 0 ? void 0 : _this$chainService$ma4.loadAuthorizationContext(authContext));
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));
1574
1585
  // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
1575
1586
  const encryptedData = await passworder.encrypt(password, authContext);
1576
- 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({
1577
1588
  chain: _constants2._DEFAULT_MANTA_ZK_CHAIN,
1578
1589
  address,
1579
1590
  data: encryptedData
1580
- });
1591
+ }));
1581
1592
  } else {
1582
- var _this$chainService$ma5;
1583
- 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));
1584
1595
 
1585
1596
  // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
1586
1597
  const decryptedData = await passworder.decrypt(password, authContext.data);
1587
1598
 
1588
1599
  // eslint-disable-next-line @typescript-eslint/no-unsafe-argument,@typescript-eslint/no-unsafe-member-access
1589
1600
  const proofAuthKey = new Uint8Array(Object.values(decryptedData.proof_authorization_key));
1590
- await ((_this$chainService$ma5 = this.chainService.mantaPay.privateWallet) === null || _this$chainService$ma5 === void 0 ? void 0 : _this$chainService$ma5.loadAuthorizationContext({
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({
1591
1602
  proof_authorization_key: proofAuthKey
1592
1603
  }));
1593
1604
  }
1594
- const zkAddress = await ((_this$chainService$ma6 = this.chainService.mantaPay.privateWallet) === null || _this$chainService$ma6 === void 0 ? void 0 : _this$chainService$ma6.getZkAddress());
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());
1595
1606
  if (updateStore) {
1596
- var _this$chainService$ma7, _this$chainService$ma8;
1597
- await this.chainService.mantaPay.saveMantaPayConfig({
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({
1598
1609
  address,
1599
1610
  zkAddress: zkAddress,
1600
1611
  enabled: true,
1601
- 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(),
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(),
1602
1613
  isInitialSync: false
1603
- });
1614
+ }));
1604
1615
  }
1605
1616
  this.isMantaPayEnabled = true;
1606
1617
  return zkAddress;
1607
1618
  }
1608
1619
  async disableMantaPay(address) {
1609
- var _this$chainService$ma9, _this$chainService$ma10;
1610
- const config = await this.chainService.mantaPay.getMantaPayConfig(address, _constants2._DEFAULT_MANTA_ZK_CHAIN);
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));
1611
1622
  if (!config) {
1612
1623
  return false;
1613
1624
  }
1614
- await ((_this$chainService$ma9 = this.chainService.mantaPay.privateWallet) === null || _this$chainService$ma9 === void 0 ? void 0 : _this$chainService$ma9.dropAuthorizationContext());
1615
- await ((_this$chainService$ma10 = this.chainService.mantaPay.privateWallet) === null || _this$chainService$ma10 === void 0 ? void 0 : _this$chainService$ma10.dropUserSeedPhrase());
1616
- // await this.chainService.mantaPay.privateWallet?.resetState();
1617
- await this.chainService.mantaPay.deleteMantaPayConfig(address, _constants2._DEFAULT_MANTA_ZK_CHAIN);
1618
- await this.chainService.mantaPay.deleteMantaAuthContext(address, _constants2._DEFAULT_MANTA_ZK_CHAIN);
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));
1619
1630
  this.chainService.setMantaZkAssetSettings(false);
1620
1631
  this.isMantaPayEnabled = false;
1621
1632
  return true;
1622
1633
  }
1623
1634
  async initialSyncMantaPay(address) {
1624
- var _this$chainService$ma11, _this$chainService$ma12, _this$chainService$ma13;
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$;
1625
1636
  if (!address || (0, _utilCrypto.isEthereumAddress)(address)) {
1626
1637
  return;
1627
1638
  }
1628
- this.chainService.mantaPay.setCurrentAddress(address);
1629
- 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());
1630
- const syncResult = await ((_this$chainService$ma13 = this.chainService.mantaPay.privateWallet) === null || _this$chainService$ma13 === void 0 ? void 0 : _this$chainService$ma13.initialWalletSync());
1631
- await this.chainService.mantaPay.updateMantaPayConfig(address, _constants2._DEFAULT_MANTA_ZK_CHAIN, {
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, {
1632
1643
  isInitialSync: true
1633
- });
1644
+ }));
1634
1645
  this.eventService.emit('mantaPay.initSync', undefined);
1635
1646
  return syncResult;
1636
1647
  }
1637
1648
  getMantaZkBalance() {
1638
- var _this$chainService, _this$chainService$ma14, _this$chainService$ma15, _this$chainService2, _this$chainService2$m, _this$chainService$ma16;
1639
- 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)) {
1640
1651
  return;
1641
1652
  }
1642
- 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)) {
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)) {
1643
1654
  return;
1644
1655
  }
1645
- 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;
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;
1646
1657
  if (!chain) {
1647
1658
  return;
1648
1659
  }
1649
1660
  const assetMap = this.chainService.getMantaZkAssets(chain === null || chain === void 0 ? void 0 : chain.toLowerCase());
1650
- (_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 => {
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 => {
1651
1662
  const assetList = Object.values(assetMap);
1652
1663
  for (let i = 0; i < assetList.length; i++) {
1653
1664
  var _zkBalances$i;
@@ -1664,8 +1675,9 @@ class KoniState {
1664
1675
  }).catch(console.warn);
1665
1676
  }
1666
1677
  subscribeMantaPayBalance() {
1678
+ var _this$chainService27, _this$chainService27$;
1667
1679
  let interval;
1668
- this.chainService.mantaPay.getMantaPayConfig(this.keyringService.currentAccount.address, _constants2._DEFAULT_MANTA_ZK_CHAIN).then(config => {
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 => {
1669
1681
  if (config && config.enabled && config.isInitialSync) {
1670
1682
  this.getMantaZkBalance();
1671
1683
  interval = setInterval(this.getMantaZkBalance, _constants.MANTA_PAY_BALANCE_INTERVAL);
@@ -1676,23 +1688,23 @@ class KoniState {
1676
1688
  };
1677
1689
  }
1678
1690
  async syncMantaPay() {
1679
- var _this$chainService3, _this$chainService3$m, _this$chainService3$m2;
1680
- const config = await this.chainService.mantaPay.getMantaPayFirstConfig(_constants2._DEFAULT_MANTA_ZK_CHAIN);
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));
1681
1693
  if (!config.isInitialSync) {
1682
1694
  return;
1683
1695
  }
1684
- 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) {
1685
- var _this$chainService4, _this$chainService4$m, _this$chainService4$m2;
1686
- 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());
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());
1687
1699
  } else {
1688
- var _this$chainService5, _this$chainService5$m, _this$chainService5$m2;
1689
- 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());
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());
1690
1702
  }
1691
1703
  }
1692
1704
  async getMantaPayZkBalance(address, tokenInfo) {
1693
- var _this$chainService$ma17;
1705
+ var _this$chainService32, _this$chainService32$, _this$chainService32$2;
1694
1706
  const bnAssetId = new _util.BN((0, _utils._getTokenOnChainAssetId)(tokenInfo));
1695
- const balance = await ((_this$chainService$ma17 = this.chainService.mantaPay.privateWallet) === null || _this$chainService$ma17 === void 0 ? void 0 : _this$chainService$ma17.getZkBalance(bnAssetId));
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));
1696
1708
  return {
1697
1709
  decimals: tokenInfo.decimals || 0,
1698
1710
  symbol: tokenInfo.symbol,
@@ -1700,7 +1712,20 @@ class KoniState {
1700
1712
  };
1701
1713
  }
1702
1714
  subscribeMantaPaySyncState() {
1703
- return this.chainService.mantaPay.subscribeSyncState();
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
+ };
1704
1729
  }
1705
1730
  }
1706
1731
  exports.default = KoniState;
@@ -13,6 +13,6 @@ const packageInfo = {
13
13
  name: '@subwallet/extension-base',
14
14
  path: typeof __dirname === 'string' ? __dirname : 'auto',
15
15
  type: 'cjs',
16
- version: '1.1.2-1'
16
+ version: '1.1.3-0'
17
17
  };
18
18
  exports.packageInfo = packageInfo;
@@ -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 = {
@@ -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: false,
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
- const apiPromise = await this.mantaChainHandler.initMantaPay(endpoint, chainInfo.slug);
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, _helper.getOS)();
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 = {
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getOS = exports.extractMetadata = void 0;
6
+ exports.extractMetadata = void 0;
7
7
  var _extensionChains = require("@subwallet/extension-chains");
8
8
  var _defaults = require("@polkadot/networks/defaults");
9
9
  // Copyright 2019-2022 @subwallet/extension-base authors & contributors
@@ -55,28 +55,4 @@ const extractMetadata = store => {
55
55
  });
56
56
  });
57
57
  };
58
- exports.extractMetadata = extractMetadata;
59
- const getOS = () => {
60
- var _window$navigator, _window$navigator$use;
61
- const userAgent = window.navigator.userAgent;
62
- // @ts-ignore
63
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
64
- const platform = ((_window$navigator = window.navigator) === null || _window$navigator === void 0 ? void 0 : (_window$navigator$use = _window$navigator.userAgentData) === null || _window$navigator$use === void 0 ? void 0 : _window$navigator$use.platform) || window.navigator.platform;
65
- const macosPlatforms = ['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K'];
66
- const windowsPlatforms = ['Win32', 'Win64', 'Windows', 'WinCE'];
67
- const iosPlatforms = ['iPhone', 'iPad', 'iPod'];
68
- let os = 'Unknown';
69
- if (macosPlatforms.indexOf(platform) !== -1) {
70
- os = 'Mac OS';
71
- } else if (iosPlatforms.indexOf(platform) !== -1) {
72
- os = 'iOS';
73
- } else if (windowsPlatforms.indexOf(platform) !== -1) {
74
- os = 'Windows';
75
- } else if (/Android/.test(userAgent)) {
76
- os = 'Android';
77
- } else if (/Linux/.test(platform)) {
78
- os = 'Linux';
79
- }
80
- return os;
81
- };
82
- exports.getOS = getOS;
58
+ exports.extractMetadata = extractMetadata;
@@ -17,7 +17,7 @@ class MetadataStore extends _BaseStoreWithChain.default {
17
17
  return this.table.put(metadata, chain);
18
18
  }
19
19
  getMetadataByGenesisHash(genesisHash) {
20
- return this.table.where('[genesisHash]').equals([genesisHash]).first();
20
+ return this.table.get(genesisHash);
21
21
  }
22
22
  updateMetadataByGenesisHash(genesisHash, metadata) {
23
23
  return this.table.put(metadata, genesisHash);
@@ -3,24 +3,27 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.WALLET_CONNECT_SUPPORT_NAMESPACES = exports.WALLET_CONNECT_SUPPORTED_METHODS = exports.WALLET_CONNECT_REQUEST_KEY = exports.WALLET_CONNECT_POLKADOT_NAMESPACE = exports.WALLET_CONNECT_EIP155_NAMESPACE = exports.RELAY_URL = exports.PROJECT_ID = exports.DEFAULT_WALLET_CONNECT_OPTIONS = exports.ALL_WALLET_CONNECT_EVENT = void 0;
6
+ exports.WALLET_CONNECT_SUPPORT_NAMESPACES = exports.WALLET_CONNECT_SUPPORTED_METHODS = exports.WALLET_CONNECT_REQUEST_KEY = exports.WALLET_CONNECT_POLKADOT_NAMESPACE = exports.WALLET_CONNECT_EIP155_NAMESPACE = exports.RELAY_URL = exports.PROJECT_ID_MOBILE = exports.PROJECT_ID_EXTENSION = exports.DEFAULT_WALLET_CONNECT_OPTIONS = exports.ALL_WALLET_CONNECT_EVENT = void 0;
7
7
  var _types = require("@subwallet/extension-base/services/wallet-connect-service/types");
8
+ var _utils = require("@subwallet/extension-base/utils");
8
9
  // Copyright 2019-2022 @subwallet/extension-base authors & contributors
9
10
  // SPDX-License-Identifier: Apache-2.0
10
11
 
11
- const PROJECT_ID = '6da34c0b48164d27681924dd9a46d6be';
12
- exports.PROJECT_ID = PROJECT_ID;
12
+ const PROJECT_ID_EXTENSION = '6da34c0b48164d27681924dd9a46d6be';
13
+ exports.PROJECT_ID_EXTENSION = PROJECT_ID_EXTENSION;
14
+ const PROJECT_ID_MOBILE = '6da34c0b48164d27681924dd9a46d6be';
15
+ exports.PROJECT_ID_MOBILE = PROJECT_ID_MOBILE;
13
16
  const RELAY_URL = 'wss://relay.walletconnect.com';
14
17
  exports.RELAY_URL = RELAY_URL;
15
18
  const DEFAULT_WALLET_CONNECT_OPTIONS = {
16
19
  logger: 'debug',
17
- projectId: PROJECT_ID,
20
+ projectId: !_utils.isMobile ? PROJECT_ID_EXTENSION : PROJECT_ID_MOBILE,
18
21
  relayUrl: RELAY_URL,
19
22
  metadata: {
20
23
  name: 'SubWallet',
21
24
  description: 'React Wallet for WalletConnect',
22
25
  url: 'https://www.subwallet.app/',
23
- icons: ['https://1570604715-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lh39Kwxa1xxZM9WX_Bs%2Ficon%2FiETEgi1ykXUQRW63vPnL%2FLogo%3DWhite%2C%20Background%3DGradient.jpg?alt=media&token=46c5dafa-ce09-4576-bcd9-a5c796786f1a']
26
+ icons: ['https://raw.githubusercontent.com/Koniverse/SubWallet-Extension/master/packages/extension-koni/public/images/icon-128.png']
24
27
  }
25
28
  };
26
29
  exports.DEFAULT_WALLET_CONNECT_OPTIONS = DEFAULT_WALLET_CONNECT_OPTIONS;