@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.
Files changed (110) hide show
  1. package/background/KoniTypes.d.ts +32 -4
  2. package/background/KoniTypes.js +2 -1
  3. package/cjs/background/KoniTypes.js +4 -2
  4. package/cjs/constants/i18n.js +10 -2
  5. package/cjs/koni/api/dotsama/transfer.js +6 -2
  6. package/cjs/koni/api/nft/acala_nft/index.js +0 -2
  7. package/cjs/koni/api/nft/bit.country/index.js +49 -18
  8. package/cjs/koni/api/nft/config.js +5 -3
  9. package/cjs/koni/api/nft/evm_nft/index.js +0 -5
  10. package/cjs/koni/api/nft/index.js +2 -3
  11. package/cjs/koni/api/nft/karura_nft/index.js +0 -2
  12. package/cjs/koni/api/nft/rmrk_nft/index.js +0 -4
  13. package/cjs/koni/api/nft/statemine_nft/index.js +0 -2
  14. package/cjs/koni/api/nft/unique_nft/index.js +0 -5
  15. package/cjs/koni/api/nft/wasm_nft/index.js +0 -5
  16. package/cjs/koni/api/staking/bonding/amplitude.js +6 -6
  17. package/cjs/koni/api/staking/bonding/astar.js +6 -6
  18. package/cjs/koni/api/staking/bonding/paraChain.js +5 -5
  19. package/cjs/koni/api/staking/bonding/relayChain.js +24 -14
  20. package/cjs/koni/api/staking/bonding/utils.js +1 -7
  21. package/cjs/koni/api/xcm/xTokens.js +1 -1
  22. package/cjs/koni/background/cron.js +2 -37
  23. package/cjs/koni/background/handlers/Extension.js +206 -137
  24. package/cjs/koni/background/handlers/State.js +72 -84
  25. package/cjs/koni/background/subscription.js +6 -88
  26. package/cjs/packageInfo.js +1 -1
  27. package/cjs/services/chain-service/constants.js +8 -5
  28. package/cjs/services/chain-service/handler/SubstrateApi.js +8 -0
  29. package/cjs/services/chain-service/handler/manta/MantaPrivateHandler.js +1 -1
  30. package/cjs/services/chain-service/handler/manta/manta-extension-sdk-empty.js +13 -0
  31. package/cjs/services/chain-service/index.js +11 -6
  32. package/cjs/services/request-service/handler/PopupHandler.js +2 -2
  33. package/cjs/services/request-service/helper/index.js +2 -26
  34. package/cjs/services/setting-service/constants.js +16 -6
  35. package/cjs/services/storage-service/DatabaseService.js +3 -0
  36. package/cjs/services/storage-service/db-stores/Metadata.js +1 -1
  37. package/cjs/services/storage-service/db-stores/Nft.js +3 -0
  38. package/cjs/services/storage-service/db-stores/NominatorMetadata.js +3 -2
  39. package/cjs/services/wallet-connect-service/constants.js +8 -5
  40. package/cjs/services/wallet-connect-service/index.js +50 -36
  41. package/cjs/utils/environment.js +32 -2
  42. package/cjs/utils/index.js +33 -5
  43. package/cjs/utils/registry.js +25 -0
  44. package/cjs/utils/translate.js +11 -0
  45. package/constants/i18n.d.ts +2 -1
  46. package/constants/i18n.js +8 -1
  47. package/koni/api/dotsama/transfer.js +6 -2
  48. package/koni/api/nft/acala_nft/index.js +0 -2
  49. package/koni/api/nft/bit.country/index.d.ts +1 -0
  50. package/koni/api/nft/bit.country/index.js +50 -19
  51. package/koni/api/nft/config.d.ts +2 -1
  52. package/koni/api/nft/config.js +2 -1
  53. package/koni/api/nft/evm_nft/index.js +0 -4
  54. package/koni/api/nft/index.d.ts +1 -1
  55. package/koni/api/nft/index.js +2 -3
  56. package/koni/api/nft/karura_nft/index.js +0 -2
  57. package/koni/api/nft/nft.d.ts +0 -1
  58. package/koni/api/nft/rmrk_nft/index.js +0 -4
  59. package/koni/api/nft/statemine_nft/index.js +0 -2
  60. package/koni/api/nft/unique_nft/index.js +0 -5
  61. package/koni/api/nft/wasm_nft/index.js +0 -4
  62. package/koni/api/staking/bonding/amplitude.js +6 -6
  63. package/koni/api/staking/bonding/astar.js +6 -6
  64. package/koni/api/staking/bonding/paraChain.js +5 -5
  65. package/koni/api/staking/bonding/relayChain.js +24 -14
  66. package/koni/api/staking/bonding/utils.js +1 -7
  67. package/koni/api/xcm/xTokens.js +1 -1
  68. package/koni/background/cron.d.ts +0 -5
  69. package/koni/background/cron.js +4 -39
  70. package/koni/background/handlers/Extension.d.ts +4 -0
  71. package/koni/background/handlers/Extension.js +97 -32
  72. package/koni/background/handlers/State.d.ts +8 -7
  73. package/koni/background/handlers/State.js +72 -84
  74. package/koni/background/subscription.d.ts +1 -4
  75. package/koni/background/subscription.js +9 -88
  76. package/package.json +22 -6
  77. package/packageInfo.js +1 -1
  78. package/services/chain-service/constants.d.ts +2 -0
  79. package/services/chain-service/constants.js +8 -5
  80. package/services/chain-service/handler/SubstrateApi.js +8 -0
  81. package/services/chain-service/handler/manta/MantaPrivateHandler.d.ts +1 -1
  82. package/services/chain-service/handler/manta/MantaPrivateHandler.js +1 -1
  83. package/services/chain-service/handler/manta/manta-extension-sdk-empty.d.ts +4 -0
  84. package/services/chain-service/handler/manta/manta-extension-sdk-empty.js +5 -0
  85. package/services/chain-service/index.d.ts +2 -1
  86. package/services/chain-service/index.js +11 -6
  87. package/services/request-service/handler/PopupHandler.js +1 -1
  88. package/services/request-service/helper/index.d.ts +0 -2
  89. package/services/request-service/helper/index.js +0 -23
  90. package/services/request-service/types.d.ts +0 -1
  91. package/services/setting-service/constants.d.ts +6 -1
  92. package/services/setting-service/constants.js +10 -5
  93. package/services/storage-service/DatabaseService.d.ts +1 -0
  94. package/services/storage-service/DatabaseService.js +3 -0
  95. package/services/storage-service/db-stores/Metadata.js +1 -1
  96. package/services/storage-service/db-stores/Nft.d.ts +1 -0
  97. package/services/storage-service/db-stores/Nft.js +3 -0
  98. package/services/storage-service/db-stores/NominatorMetadata.js +3 -2
  99. package/services/wallet-connect-service/constants.d.ts +2 -1
  100. package/services/wallet-connect-service/constants.js +5 -3
  101. package/services/wallet-connect-service/index.d.ts +0 -1
  102. package/services/wallet-connect-service/index.js +50 -36
  103. package/utils/environment.d.ts +4 -1
  104. package/utils/environment.js +28 -1
  105. package/utils/index.d.ts +3 -0
  106. package/utils/index.js +6 -2
  107. package/utils/registry.d.ts +4 -0
  108. package/utils/registry.js +18 -0
  109. package/utils/translate.d.ts +1 -0
  110. package/utils/translate.js +4 -0
@@ -213,7 +213,8 @@ export default class KoniState {
213
213
  await this.startSubscription();
214
214
  }
215
215
  async initMantaPay(password) {
216
- const mantaPayConfig = await this.chainService.mantaPay.getMantaPayFirstConfig(_DEFAULT_MANTA_ZK_CHAIN);
216
+ var _this$chainService, _this$chainService$ma;
217
+ 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(_DEFAULT_MANTA_ZK_CHAIN));
217
218
  if (mantaPayConfig && mantaPayConfig.enabled && !this.isMantaPayEnabled) {
218
219
  // only init the first login
219
220
  console.debug('Initiating MantaPay for', mantaPayConfig.address);
@@ -605,51 +606,20 @@ export default class KoniState {
605
606
  setSettings(settings, callback) {
606
607
  this.settingService.setSettings(settings, callback);
607
608
  }
608
- setTheme(theme, callback) {
609
+ updateSetting(key, value) {
609
610
  this.settingService.getSettings(settings => {
610
611
  const newSettings = {
611
612
  ...settings,
612
- theme
613
- };
614
- this.settingService.setSettings(newSettings, () => {
615
- callback && callback(newSettings);
616
- });
617
- });
618
- }
619
- setBrowserConfirmationType(browserConfirmationType, callback) {
620
- this.settingService.getSettings(settings => {
621
- const newSettings = {
622
- ...settings,
623
- browserConfirmationType
624
- };
625
- this.settingService.setSettings(newSettings, () => {
626
- callback && callback(newSettings);
627
- });
628
- });
629
- }
630
- setCamera(value) {
631
- this.settingService.getSettings(settings => {
632
- const newSettings = {
633
- ...settings,
634
- camera: value
635
- };
636
- this.settingService.setSettings(newSettings);
637
- });
638
- }
639
- setAutoLockTime(value) {
640
- this.settingService.getSettings(settings => {
641
- const newSettings = {
642
- ...settings,
643
- timeAutoLock: value
613
+ [key]: value
644
614
  };
645
615
  this.settingService.setSettings(newSettings);
646
616
  });
647
617
  }
648
- setEnableChainPatrol(value) {
618
+ setShowBalance(value) {
649
619
  this.settingService.getSettings(settings => {
650
620
  const newSettings = {
651
621
  ...settings,
652
- enableChainPatrol: value
622
+ isShowBalance: value
653
623
  };
654
624
  this.settingService.setSettings(newSettings);
655
625
  });
@@ -902,7 +872,8 @@ export default class KoniState {
902
872
  async disableChain(chainSlug) {
903
873
  await this.chainService.updateAssetSettingByChain(chainSlug, false);
904
874
  if (_MANTA_ZK_CHAIN_GROUP.includes(chainSlug)) {
905
- const mantaPayConfig = await this.chainService.mantaPay.getMantaPayFirstConfig(_DEFAULT_MANTA_ZK_CHAIN);
875
+ var _this$chainService2, _this$chainService2$m;
876
+ 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(_DEFAULT_MANTA_ZK_CHAIN));
906
877
  if (mantaPayConfig && mantaPayConfig.enabled && this.isMantaPayEnabled) {
907
878
  await this.disableMantaPay(mantaPayConfig.address);
908
879
  }
@@ -1535,10 +1506,13 @@ export default class KoniState {
1535
1506
  });
1536
1507
  }
1537
1508
  async reloadNft() {
1509
+ const currentAddress = this.keyringService.currentAccount.address;
1510
+ await this.dbService.removeNftsByAddress(currentAddress);
1538
1511
  return await this.cron.reloadNft();
1539
1512
  }
1540
1513
  async reloadStaking() {
1541
- return await this.cron.reloadStaking();
1514
+ await this.subscription.reloadStaking();
1515
+ return true;
1542
1516
  }
1543
1517
  async approvePassPhishingPage(_url) {
1544
1518
  return new Promise(resolve => {
@@ -1570,95 +1544,95 @@ export default class KoniState {
1570
1544
  await this.chainService.init();
1571
1545
  }
1572
1546
  async enableMantaPay(updateStore, address, password, seedPhrase) {
1573
- var _this$chainService$ma, _this$chainService$ma6;
1547
+ var _this$chainService3, _this$chainService3$m, _this$chainService4, _this$chainService4$m, _this$chainService4$m2, _this$chainService11, _this$chainService11$, _this$chainService11$2;
1574
1548
  if (!address || isEthereumAddress(address)) {
1575
1549
  return;
1576
1550
  }
1577
- this.chainService.mantaPay.setCurrentAddress(address);
1578
- await ((_this$chainService$ma = this.chainService.mantaPay.privateWallet) === null || _this$chainService$ma === void 0 ? void 0 : _this$chainService$ma.initialSigner());
1551
+ (_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);
1552
+ 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());
1579
1553
  if (updateStore && seedPhrase) {
1580
- var _this$chainService$ma2, _this$chainService$ma3, _this$chainService$ma4;
1554
+ 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;
1581
1555
  // first time initiation
1582
- await ((_this$chainService$ma2 = this.chainService.mantaPay.privateWallet) === null || _this$chainService$ma2 === void 0 ? void 0 : _this$chainService$ma2.loadUserSeedPhrase(seedPhrase));
1583
- const authContext = await ((_this$chainService$ma3 = this.chainService.mantaPay.privateWallet) === null || _this$chainService$ma3 === void 0 ? void 0 : _this$chainService$ma3.getAuthorizationContext());
1584
- await ((_this$chainService$ma4 = this.chainService.mantaPay.privateWallet) === null || _this$chainService$ma4 === void 0 ? void 0 : _this$chainService$ma4.loadAuthorizationContext(authContext));
1556
+ 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));
1557
+ 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());
1558
+ 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));
1585
1559
  // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
1586
1560
  const encryptedData = await passworder.encrypt(password, authContext);
1587
- await this.chainService.mantaPay.saveMantaAuthContext({
1561
+ 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({
1588
1562
  chain: _DEFAULT_MANTA_ZK_CHAIN,
1589
1563
  address,
1590
1564
  data: encryptedData
1591
- });
1565
+ }));
1592
1566
  } else {
1593
- var _this$chainService$ma5;
1594
- const authContext = await this.chainService.mantaPay.getMantaAuthContext(address, _DEFAULT_MANTA_ZK_CHAIN);
1567
+ var _this$chainService9, _this$chainService9$m, _this$chainService10, _this$chainService10$, _this$chainService10$2;
1568
+ 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, _DEFAULT_MANTA_ZK_CHAIN));
1595
1569
 
1596
1570
  // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
1597
1571
  const decryptedData = await passworder.decrypt(password, authContext.data);
1598
1572
 
1599
1573
  // eslint-disable-next-line @typescript-eslint/no-unsafe-argument,@typescript-eslint/no-unsafe-member-access
1600
1574
  const proofAuthKey = new Uint8Array(Object.values(decryptedData.proof_authorization_key));
1601
- await ((_this$chainService$ma5 = this.chainService.mantaPay.privateWallet) === null || _this$chainService$ma5 === void 0 ? void 0 : _this$chainService$ma5.loadAuthorizationContext({
1575
+ 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({
1602
1576
  proof_authorization_key: proofAuthKey
1603
1577
  }));
1604
1578
  }
1605
- const zkAddress = await ((_this$chainService$ma6 = this.chainService.mantaPay.privateWallet) === null || _this$chainService$ma6 === void 0 ? void 0 : _this$chainService$ma6.getZkAddress());
1579
+ 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());
1606
1580
  if (updateStore) {
1607
- var _this$chainService$ma7, _this$chainService$ma8;
1608
- await this.chainService.mantaPay.saveMantaPayConfig({
1581
+ var _this$chainService12, _this$chainService12$, _this$chainService13, _this$chainService13$, _this$chainService13$2, _this$chainService13$3;
1582
+ 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({
1609
1583
  address,
1610
1584
  zkAddress: zkAddress,
1611
1585
  enabled: true,
1612
- 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(),
1586
+ 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(),
1613
1587
  isInitialSync: false
1614
- });
1588
+ }));
1615
1589
  }
1616
1590
  this.isMantaPayEnabled = true;
1617
1591
  return zkAddress;
1618
1592
  }
1619
1593
  async disableMantaPay(address) {
1620
- var _this$chainService$ma9, _this$chainService$ma10;
1621
- const config = await this.chainService.mantaPay.getMantaPayConfig(address, _DEFAULT_MANTA_ZK_CHAIN);
1594
+ 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$;
1595
+ 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, _DEFAULT_MANTA_ZK_CHAIN));
1622
1596
  if (!config) {
1623
1597
  return false;
1624
1598
  }
1625
- await ((_this$chainService$ma9 = this.chainService.mantaPay.privateWallet) === null || _this$chainService$ma9 === void 0 ? void 0 : _this$chainService$ma9.dropAuthorizationContext());
1626
- await ((_this$chainService$ma10 = this.chainService.mantaPay.privateWallet) === null || _this$chainService$ma10 === void 0 ? void 0 : _this$chainService$ma10.dropUserSeedPhrase());
1627
- // await this.chainService.mantaPay.privateWallet?.resetState();
1628
- await this.chainService.mantaPay.deleteMantaPayConfig(address, _DEFAULT_MANTA_ZK_CHAIN);
1629
- await this.chainService.mantaPay.deleteMantaAuthContext(address, _DEFAULT_MANTA_ZK_CHAIN);
1599
+ 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());
1600
+ 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());
1601
+ // await this.chainService?.mantaPay?.privateWallet?.resetState();
1602
+ 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, _DEFAULT_MANTA_ZK_CHAIN));
1603
+ 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, _DEFAULT_MANTA_ZK_CHAIN));
1630
1604
  this.chainService.setMantaZkAssetSettings(false);
1631
1605
  this.isMantaPayEnabled = false;
1632
1606
  return true;
1633
1607
  }
1634
1608
  async initialSyncMantaPay(address) {
1635
- var _this$chainService$ma11, _this$chainService$ma12, _this$chainService$ma13;
1609
+ 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$;
1636
1610
  if (!address || isEthereumAddress(address)) {
1637
1611
  return;
1638
1612
  }
1639
- this.chainService.mantaPay.setCurrentAddress(address);
1640
- 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());
1641
- const syncResult = await ((_this$chainService$ma13 = this.chainService.mantaPay.privateWallet) === null || _this$chainService$ma13 === void 0 ? void 0 : _this$chainService$ma13.initialWalletSync());
1642
- await this.chainService.mantaPay.updateMantaPayConfig(address, _DEFAULT_MANTA_ZK_CHAIN, {
1613
+ (_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);
1614
+ 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());
1615
+ 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());
1616
+ 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, _DEFAULT_MANTA_ZK_CHAIN, {
1643
1617
  isInitialSync: true
1644
- });
1618
+ }));
1645
1619
  this.eventService.emit('mantaPay.initSync', undefined);
1646
1620
  return syncResult;
1647
1621
  }
1648
1622
  getMantaZkBalance() {
1649
- var _this$chainService, _this$chainService$ma14, _this$chainService$ma15, _this$chainService2, _this$chainService2$m, _this$chainService$ma16;
1650
- if (!this.chainService || !this.chainService.mantaPay) {
1623
+ var _this$chainService23, _this$chainService24, _this$chainService24$, _this$chainService24$2, _this$chainService25, _this$chainService25$, _this$chainService26, _this$chainService26$, _this$chainService26$2;
1624
+ if (!this.chainService || !((_this$chainService23 = this.chainService) !== null && _this$chainService23 !== void 0 && _this$chainService23.mantaPay)) {
1651
1625
  return;
1652
1626
  }
1653
- 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)) {
1627
+ 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)) {
1654
1628
  return;
1655
1629
  }
1656
- 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;
1630
+ 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;
1657
1631
  if (!chain) {
1658
1632
  return;
1659
1633
  }
1660
1634
  const assetMap = this.chainService.getMantaZkAssets(chain === null || chain === void 0 ? void 0 : chain.toLowerCase());
1661
- (_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 BN(_getTokenOnChainAssetId(tokenInfo)))).then(zkBalances => {
1635
+ (_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 BN(_getTokenOnChainAssetId(tokenInfo)))).then(zkBalances => {
1662
1636
  const assetList = Object.values(assetMap);
1663
1637
  for (let i = 0; i < assetList.length; i++) {
1664
1638
  var _zkBalances$i;
@@ -1675,8 +1649,9 @@ export default class KoniState {
1675
1649
  }).catch(console.warn);
1676
1650
  }
1677
1651
  subscribeMantaPayBalance() {
1652
+ var _this$chainService27, _this$chainService27$;
1678
1653
  let interval;
1679
- this.chainService.mantaPay.getMantaPayConfig(this.keyringService.currentAccount.address, _DEFAULT_MANTA_ZK_CHAIN).then(config => {
1654
+ (_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, _DEFAULT_MANTA_ZK_CHAIN).then(config => {
1680
1655
  if (config && config.enabled && config.isInitialSync) {
1681
1656
  this.getMantaZkBalance();
1682
1657
  interval = setInterval(this.getMantaZkBalance, MANTA_PAY_BALANCE_INTERVAL);
@@ -1687,23 +1662,23 @@ export default class KoniState {
1687
1662
  };
1688
1663
  }
1689
1664
  async syncMantaPay() {
1690
- var _this$chainService3, _this$chainService3$m, _this$chainService3$m2;
1691
- const config = await this.chainService.mantaPay.getMantaPayFirstConfig(_DEFAULT_MANTA_ZK_CHAIN);
1665
+ var _this$chainService28, _this$chainService28$, _this$chainService29, _this$chainService29$, _this$chainService29$2;
1666
+ 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(_DEFAULT_MANTA_ZK_CHAIN));
1692
1667
  if (!config.isInitialSync) {
1693
1668
  return;
1694
1669
  }
1695
- 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) {
1696
- var _this$chainService4, _this$chainService4$m, _this$chainService4$m2;
1697
- 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());
1670
+ 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) {
1671
+ var _this$chainService30, _this$chainService30$, _this$chainService30$2;
1672
+ 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());
1698
1673
  } else {
1699
- var _this$chainService5, _this$chainService5$m, _this$chainService5$m2;
1700
- 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());
1674
+ var _this$chainService31, _this$chainService31$, _this$chainService31$2;
1675
+ 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());
1701
1676
  }
1702
1677
  }
1703
1678
  async getMantaPayZkBalance(address, tokenInfo) {
1704
- var _this$chainService$ma17;
1679
+ var _this$chainService32, _this$chainService32$, _this$chainService32$2;
1705
1680
  const bnAssetId = new BN(_getTokenOnChainAssetId(tokenInfo));
1706
- const balance = await ((_this$chainService$ma17 = this.chainService.mantaPay.privateWallet) === null || _this$chainService$ma17 === void 0 ? void 0 : _this$chainService$ma17.getZkBalance(bnAssetId));
1681
+ 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));
1707
1682
  return {
1708
1683
  decimals: tokenInfo.decimals || 0,
1709
1684
  symbol: tokenInfo.symbol,
@@ -1711,6 +1686,19 @@ export default class KoniState {
1711
1686
  };
1712
1687
  }
1713
1688
  subscribeMantaPaySyncState() {
1714
- return this.chainService.mantaPay.subscribeSyncState();
1689
+ var _this$chainService33, _this$chainService34, _this$chainService34$;
1690
+ if (!((_this$chainService33 = this.chainService) !== null && _this$chainService33 !== void 0 && _this$chainService33.mantaPay)) {
1691
+ return new Subject();
1692
+ }
1693
+ 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();
1694
+ }
1695
+
1696
+ // Metadata
1697
+ async findMetadata(hash) {
1698
+ const metadata = await this.chainService.getMetadataByHash(hash);
1699
+ return {
1700
+ metadata: (metadata === null || metadata === void 0 ? void 0 : metadata.hexValue) || '',
1701
+ specVersion: parseInt((metadata === null || metadata === void 0 ? void 0 : metadata.specVersion) || '0')
1702
+ };
1715
1703
  }
1716
1704
  }
@@ -1,5 +1,4 @@
1
1
  import { _ChainAsset, _ChainInfo } from '@subwallet/chain-list/types';
2
- import { ChainStakingMetadata } from '@subwallet/extension-base/background/KoniTypes';
3
2
  import { _ChainState, _EvmApi, _SubstrateApi } from '@subwallet/extension-base/services/chain-service/types';
4
3
  import DatabaseService from '@subwallet/extension-base/services/storage-service/DatabaseService';
5
4
  import KoniState from './handlers/State';
@@ -27,8 +26,6 @@ export declare class KoniSubscription {
27
26
  initNftSubscription(addresses: string[], substrateApiMap: Record<string, _SubstrateApi>, evmApiMap: Record<string, _EvmApi>, smartContractNfts: _ChainAsset[], chainInfoMap: Record<string, _ChainInfo>): void;
28
27
  subscribeStakingReward(address: string): Promise<void>;
29
28
  subscribeStakingRewardFastInterval(address: string): Promise<void>;
30
- fetchingStakingFromApi(): Promise<Record<string, ChainStakingMetadata>>;
31
- fetchChainStakingMetadata(chainInfoMap: Record<string, _ChainInfo>, chainStateMap: Record<string, _ChainState>, substrateApiMap: Record<string, _SubstrateApi>): Promise<void>;
32
- fetchNominatorMetadata(currentAddress: string, chainInfoMap: Record<string, _ChainInfo>, chainStateMap: Record<string, _ChainState>, substrateApiMap: Record<string, _SubstrateApi>): Promise<void>;
29
+ reloadStaking(): Promise<void>;
33
30
  }
34
31
  export {};
@@ -1,20 +1,16 @@
1
1
  // Copyright 2019-2022 @subwallet/extension-koni authors & contributors
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { ALL_ACCOUNT_KEY } from '@subwallet/extension-base/constants';
5
4
  import { subscribeBalance } from '@subwallet/extension-base/koni/api/dotsama/balance';
6
5
  import { subscribeCrowdloan } from '@subwallet/extension-base/koni/api/dotsama/crowdloan';
7
6
  import { getNominationStakingRewardData, getPoolingStakingRewardData, stakingOnChainApi } from '@subwallet/extension-base/koni/api/staking';
8
- import { getChainStakingMetadata, getNominatorMetadata, subscribeEssentialChainStakingMetadata } from '@subwallet/extension-base/koni/api/staking/bonding';
9
- import { getRelayChainPoolMemberMetadata } from '@subwallet/extension-base/koni/api/staking/bonding/relayChain';
7
+ import { subscribeEssentialChainStakingMetadata } from '@subwallet/extension-base/koni/api/staking/bonding';
10
8
  import { getAmplitudeUnclaimedStakingReward } from '@subwallet/extension-base/koni/api/staking/paraChain';
11
9
  import { nftHandler } from '@subwallet/extension-base/koni/background/handlers';
12
- import { _STAKING_CHAIN_GROUP } from '@subwallet/extension-base/services/chain-service/constants';
13
- import { _isChainEnabled, _isChainEvmCompatible, _isChainSupportSubstrateStaking, _isSubstrateRelayChain } from '@subwallet/extension-base/services/chain-service/utils';
10
+ import { _isChainEnabled, _isChainSupportSubstrateStaking } from '@subwallet/extension-base/services/chain-service/utils';
14
11
  import { COMMON_RELOAD_EVENTS } from '@subwallet/extension-base/services/event-service/types';
15
- import axios from 'axios';
12
+ import { waitTimeout } from '@subwallet/extension-base/utils';
16
13
  import { logger as createLogger } from '@polkadot/util';
17
- import { isEthereumAddress } from '@polkadot/util-crypto';
18
14
  export class KoniSubscription {
19
15
  subscriptionMap = {
20
16
  crowdloan: undefined,
@@ -186,7 +182,7 @@ export class KoniSubscription {
186
182
  nftHandler.setDotSamaApiMap(substrateApiMap);
187
183
  nftHandler.setWeb3ApiMap(evmApiMap);
188
184
  nftHandler.setAddresses(addresses);
189
- nftHandler.handleNfts(smartContractNfts, (...args) => this.state.updateNftData(...args), (...args) => this.state.setNftCollection(...args), (...args) => this.state.cleanUpNfts(...args)).catch(this.logger.log);
185
+ nftHandler.handleNfts(smartContractNfts, (...args) => this.state.updateNftData(...args), (...args) => this.state.setNftCollection(...args)).catch(this.logger.log);
190
186
  }
191
187
  async subscribeStakingReward(address) {
192
188
  const addresses = this.state.getDecodedAddresses(address);
@@ -234,85 +230,10 @@ export class KoniSubscription {
234
230
  };
235
231
  await Promise.all([getPoolingStakingRewardData(pooledAddresses, targetChainMap, this.state.getSubstrateApiMap(), updateState), getAmplitudeUnclaimedStakingReward(this.state.getSubstrateApiMap(), addresses, chainInfoMap, activeNetworks, updateState)]);
236
232
  }
237
- async fetchingStakingFromApi() {
238
- try {
239
- const response = await axios.get('https://staking-data.subwallet.app/api/staking/get');
240
- if (response.status === 200) {
241
- return response.data;
242
- }
243
- } catch (e) {
244
- this.logger.error(e);
245
- }
246
- return {};
247
- }
248
- async fetchChainStakingMetadata(chainInfoMap, chainStateMap, substrateApiMap) {
249
- const filteredChainInfoMap = {};
250
- Object.values(chainInfoMap).forEach(chainInfo => {
251
- const chainState = chainStateMap[chainInfo.slug];
252
- if (chainState !== null && chainState !== void 0 && chainState.active && _isChainSupportSubstrateStaking(chainInfo)) {
253
- filteredChainInfoMap[chainInfo.slug] = chainInfo;
254
- }
255
- });
256
- if (Object.values(filteredChainInfoMap).length === 0) {
257
- return;
258
- }
259
- const timeout = new Promise(resolve => {
260
- const id = setTimeout(() => {
261
- clearTimeout(id);
262
- resolve(null);
263
- }, 3000);
264
- });
265
-
266
- // Fetch data from helper API
267
- const _dataFromApi = await Promise.race([this.fetchingStakingFromApi(), timeout]);
268
- const dataFromApi = _dataFromApi;
269
- await Promise.all(Object.values(filteredChainInfoMap).map(async chainInfo => {
270
- // Use fetch API data if available
271
- if (dataFromApi && dataFromApi[chainInfo.slug]) {
272
- this.state.updateChainStakingMetadata(dataFromApi[chainInfo.slug], {
273
- expectedReturn: dataFromApi[chainInfo.slug].expectedReturn,
274
- inflation: dataFromApi[chainInfo.slug].inflation,
275
- nominatorCount: dataFromApi[chainInfo.slug].nominatorCount
276
- });
277
- } else {
278
- const chainStakingMetadata = await getChainStakingMetadata(chainInfo, substrateApiMap[chainInfo.slug]);
279
- this.state.updateChainStakingMetadata(chainStakingMetadata, {
280
- expectedReturn: chainStakingMetadata.expectedReturn,
281
- inflation: chainStakingMetadata.inflation,
282
- nominatorCount: chainStakingMetadata.nominatorCount
283
- });
284
- }
285
- }));
286
- }
287
- async fetchNominatorMetadata(currentAddress, chainInfoMap, chainStateMap, substrateApiMap) {
288
- const filteredChainInfoMap = {};
289
- Object.values(chainInfoMap).forEach(chainInfo => {
290
- const chainState = chainStateMap[chainInfo.slug];
291
- if (chainState !== null && chainState !== void 0 && chainState.active && _isChainSupportSubstrateStaking(chainInfo)) {
292
- filteredChainInfoMap[chainInfo.slug] = chainInfo;
293
- }
294
- });
295
- let addresses = [currentAddress];
296
- if (currentAddress === ALL_ACCOUNT_KEY) {
297
- addresses = await this.state.getStakingOwnersByChains(Object.keys(filteredChainInfoMap));
298
- }
299
- await Promise.all(addresses.map(async address => {
300
- const isEvmAddress = isEthereumAddress(address);
301
- await Promise.all(Object.values(filteredChainInfoMap).map(async chainInfo => {
302
- if (isEvmAddress && !_isChainEvmCompatible(chainInfo)) {
303
- return;
304
- }
305
- if (_isSubstrateRelayChain(chainInfo) && _STAKING_CHAIN_GROUP.nominationPool.includes(chainInfo.slug)) {
306
- const poolMemberMetadata = await getRelayChainPoolMemberMetadata(chainInfo, address, substrateApiMap[chainInfo.slug]);
307
- if (poolMemberMetadata) {
308
- this.state.updateStakingNominatorMetadata(poolMemberMetadata);
309
- }
310
- }
311
- const nominatorMetadata = await getNominatorMetadata(chainInfo, address, substrateApiMap[chainInfo.slug]);
312
- if (nominatorMetadata) {
313
- this.state.updateStakingNominatorMetadata(nominatorMetadata);
314
- }
315
- }));
316
- }));
233
+ async reloadStaking() {
234
+ var _this$state$keyringSe2;
235
+ const currentAddress = (_this$state$keyringSe2 = this.state.keyringService.currentAccount) === null || _this$state$keyringSe2 === void 0 ? void 0 : _this$state$keyringSe2.address;
236
+ this.subscribeStakingOnChain(currentAddress, this.state.getSubstrateApiMap());
237
+ await waitTimeout(1800);
317
238
  }
318
239
  }
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "./cjs/detectPackage.js"
18
18
  ],
19
19
  "type": "module",
20
- "version": "1.1.2-0",
20
+ "version": "1.1.3-0",
21
21
  "main": "./cjs/index.js",
22
22
  "module": "./index.js",
23
23
  "types": "./index.d.ts",
@@ -530,6 +530,11 @@
530
530
  "require": "./cjs/services/chain-service/handler/light-client/index.js",
531
531
  "default": "./services/chain-service/handler/light-client/index.js"
532
532
  },
533
+ "./services/chain-service/handler/manta/manta-extension-sdk-empty": {
534
+ "types": "./services/chain-service/handler/manta/manta-extension-sdk-empty.d.ts",
535
+ "require": "./cjs/services/chain-service/handler/manta/manta-extension-sdk-empty.js",
536
+ "default": "./services/chain-service/handler/manta/manta-extension-sdk-empty.js"
537
+ },
533
538
  "./services/chain-service/handler/manta/MantaPrivateHandler": {
534
539
  "types": "./services/chain-service/handler/manta/MantaPrivateHandler.d.ts",
535
540
  "require": "./cjs/services/chain-service/handler/manta/MantaPrivateHandler.js",
@@ -1125,10 +1130,20 @@
1125
1130
  "require": "./cjs/utils/promise.js",
1126
1131
  "default": "./utils/promise.js"
1127
1132
  },
1133
+ "./utils/registry": {
1134
+ "types": "./utils/registry.d.ts",
1135
+ "require": "./cjs/utils/registry.js",
1136
+ "default": "./utils/registry.js"
1137
+ },
1128
1138
  "./utils/request": {
1129
1139
  "types": "./utils/request.d.ts",
1130
1140
  "require": "./cjs/utils/request.js",
1131
1141
  "default": "./utils/request.js"
1142
+ },
1143
+ "./utils/translate": {
1144
+ "types": "./utils/translate.d.ts",
1145
+ "require": "./cjs/utils/translate.js",
1146
+ "default": "./utils/translate.js"
1132
1147
  }
1133
1148
  },
1134
1149
  "dependencies": {
@@ -1158,16 +1173,17 @@
1158
1173
  "@reduxjs/toolkit": "^1.9.1",
1159
1174
  "@sora-substrate/type-definitions": "^1.17.7",
1160
1175
  "@substrate/connect": "^0.7.26",
1161
- "@subwallet/chain-list": "^0.2.4",
1162
- "@subwallet/extension-base": "^1.1.2-0",
1163
- "@subwallet/extension-chains": "^1.1.2-0",
1164
- "@subwallet/extension-dapp": "^1.1.2-0",
1165
- "@subwallet/extension-inject": "^1.1.2-0",
1176
+ "@subwallet/chain-list": "^0.2.7",
1177
+ "@subwallet/extension-base": "^1.1.3-0",
1178
+ "@subwallet/extension-chains": "^1.1.3-0",
1179
+ "@subwallet/extension-dapp": "^1.1.3-0",
1180
+ "@subwallet/extension-inject": "^1.1.3-0",
1166
1181
  "@subwallet/keyring": "^0.0.10",
1167
1182
  "@subwallet/ui-keyring": "^0.0.10",
1168
1183
  "@walletconnect/sign-client": "^2.8.4",
1169
1184
  "@walletconnect/types": "^2.8.4",
1170
1185
  "@walletconnect/utils": "^2.8.4",
1186
+ "avail-js-sdk": "^0.0.10",
1171
1187
  "axios": "^1.2.1",
1172
1188
  "bignumber.js": "^9.1.1",
1173
1189
  "bn.js": "^5.2.1",
package/packageInfo.js CHANGED
@@ -7,5 +7,5 @@ export const packageInfo = {
7
7
  name: '@subwallet/extension-base',
8
8
  path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto',
9
9
  type: 'esm',
10
- version: '1.1.2-0'
10
+ version: '1.1.3-0'
11
11
  };
@@ -5,6 +5,7 @@ export declare const API_MAX_RETRY = 2;
5
5
  export declare const _API_OPTIONS_CHAIN_GROUP: {
6
6
  acala: string[];
7
7
  turing: string[];
8
+ avail: string[];
8
9
  };
9
10
  export declare const _PREDEFINED_SINGLE_MODES: Record<string, SingleModeJson>;
10
11
  export declare const _PURE_EVM_CHAINS: string[];
@@ -66,6 +67,7 @@ export declare const _TRANSFER_CHAIN_GROUP: {
66
67
  riochain: string[];
67
68
  sora_substrate: string[];
68
69
  avail: string[];
70
+ pendulum: string[];
69
71
  };
70
72
  export declare const _BALANCE_PARSING_CHAIN_GROUP: {
71
73
  bobabeam: string[];
@@ -9,7 +9,8 @@ export const API_CONNECT_TIMEOUT = 30000;
9
9
  export const API_MAX_RETRY = 2;
10
10
  export const _API_OPTIONS_CHAIN_GROUP = {
11
11
  acala: ['acala', 'karura', 'origintrail', 'kintsugi'],
12
- turing: ['turingStaging', 'turing']
12
+ turing: ['turingStaging', 'turing'],
13
+ avail: ['kate']
13
14
  };
14
15
  export const _PREDEFINED_SINGLE_MODES = {
15
16
  subspace: {
@@ -26,7 +27,7 @@ export const _BALANCE_CHAIN_GROUP = {
26
27
  kintsugi: ['kintsugi', 'interlay', 'kintsugi_test', 'mangatax_para'],
27
28
  genshiro: ['genshiro_testnet', 'genshiro'],
28
29
  equilibrium_parachain: ['equilibrium_parachain'],
29
- bifrost: ['bifrost', 'acala', 'karura', 'acala_testnet', 'pioneer', 'bitcountry', 'bifrost_dot', 'hydradx_main'],
30
+ bifrost: ['bifrost', 'acala', 'karura', 'acala_testnet', 'pioneer', 'bitcountry', 'bifrost_dot', 'hydradx_main', 'pendulum'],
30
31
  statemine: ['statemine', 'astar', 'shiden', 'statemint', 'moonbeam', 'moonbase', 'moonriver', 'crabParachain', 'darwinia2', 'parallel', 'calamari'],
31
32
  kusama: ['kusama', 'kintsugi', 'kintsugi_test', 'interlay', 'acala', 'statemint', 'karura', 'bifrost'] // perhaps there are some runtime updates
32
33
  };
@@ -51,7 +52,7 @@ export const _STAKING_CHAIN_GROUP = {
51
52
  relay: ['polkadot', 'kusama', 'aleph', 'polkadex', 'ternoa', 'ternoa_alphanet', 'alephTest', 'polkadexTest', 'westend'],
52
53
  para: ['moonbeam', 'moonriver', 'moonbase', 'turing', 'turingStaging', 'bifrost', 'bifrost_testnet', 'calamari_test', 'calamari'],
53
54
  astar: ['astar', 'shiden', 'shibuya'],
54
- amplitude: ['amplitude', 'amplitude_test', 'kilt', 'kilt_peregrine'],
55
+ amplitude: ['amplitude', 'amplitude_test', 'kilt', 'kilt_peregrine', 'pendulum'],
55
56
  // amplitude and kilt only share some common logic
56
57
  kilt: ['kilt', 'kilt_peregrine'],
57
58
  nominationPool: ['polkadot', 'kusama', 'westend', 'alephTest', 'aleph'],
@@ -84,6 +85,7 @@ export const _STAKING_ERA_LENGTH_MAP = {
84
85
  calamari_test: 6,
85
86
  amplitude: 2,
86
87
  amplitude_test: 2,
88
+ pendulum: 2,
87
89
  kilt: 2,
88
90
  kilt_peregrine: 2
89
91
  };
@@ -184,7 +186,8 @@ export const _TRANSFER_CHAIN_GROUP = {
184
186
  statemine: ['statemint', 'statemine', 'darwinia2', 'astar', 'shiden', 'shibuya', 'parallel'],
185
187
  riochain: ['riochain'],
186
188
  sora_substrate: ['sora_substrate'],
187
- avail: ['kate']
189
+ avail: ['kate'],
190
+ pendulum: ['pendulum']
188
191
  };
189
192
  export const _BALANCE_PARSING_CHAIN_GROUP = {
190
193
  bobabeam: ['bobabeam', 'bobabase']
@@ -212,7 +215,7 @@ export const _XCM_TYPE = {
212
215
  export const _DEFAULT_ACTIVE_CHAINS = [..._DEFAULT_CHAINS];
213
216
 
214
217
  // TODO: review
215
- const TARGET_BRANCH = process.env.NODE_ENV !== 'production' ? 'koni/dev/issue-15' : 'master';
218
+ const TARGET_BRANCH = process.env.NODE_ENV !== 'production' ? 'koni-dev' : 'master';
216
219
  export const _CHAIN_INFO_SRC = `https://raw.githubusercontent.com/Koniverse/SubWallet-Chain/${TARGET_BRANCH}/packages/chain-list/src/data/ChainInfo.json`;
217
220
  export const _CHAIN_ASSET_SRC = `https://raw.githubusercontent.com/Koniverse/SubWallet-Chain/${TARGET_BRANCH}/packages/chain-list/src/data/ChainAsset.json`;
218
221
  export const _ASSET_REF_SRC = `https://raw.githubusercontent.com/Koniverse/SubWallet-Chain/${TARGET_BRANCH}/packages/chain-list/src/data/AssetRef.json`;
@@ -8,6 +8,7 @@ import { _API_OPTIONS_CHAIN_GROUP, API_AUTO_CONNECT_MS, API_CONNECT_TIMEOUT } fr
8
8
  import { getSubstrateConnectProvider } from '@subwallet/extension-base/services/chain-service/handler/light-client';
9
9
  import { DEFAULT_AUX } from '@subwallet/extension-base/services/chain-service/handler/SubstrateChainHandler';
10
10
  import { createPromiseHandler } from '@subwallet/extension-base/utils/promise';
11
+ import { spec as availSpec } from 'avail-js-sdk';
11
12
  import { BehaviorSubject } from 'rxjs';
12
13
  import { ApiPromise, WsProvider } from '@polkadot/api';
13
14
  import { typesBundle } from '@polkadot/apps-config/api';
@@ -63,6 +64,13 @@ export class SubstrateApi {
63
64
  rpc: oakRpc,
64
65
  types: oakTypes
65
66
  });
67
+ } else if (_API_OPTIONS_CHAIN_GROUP.avail.includes(this.chainSlug)) {
68
+ return new ApiPromise({
69
+ provider,
70
+ rpc: availSpec.rpc,
71
+ types: availSpec.types,
72
+ signedExtensions: availSpec.signedExtensions
73
+ });
66
74
  } else {
67
75
  return new ApiPromise(apiOption);
68
76
  }
@@ -23,7 +23,7 @@ export declare class MantaPrivateHandler {
23
23
  deleteMantaAuthContext(address: string, chain: string): Promise<number>;
24
24
  private saveLedgerState;
25
25
  private getLedgerState;
26
- initMantaPay(providerUrl: string, network: string): Promise<import("@polkadot/api").ApiPromise>;
26
+ initMantaPay(providerUrl: string, network: string): Promise<import("avail-js-sdk").ApiPromise>;
27
27
  getCurrentLedgerState(): Promise<number>;
28
28
  setSyncState(data: MantaPaySyncState): void;
29
29
  subscribeSyncProgress(): Promise<() => void>;