@subwallet/extension-base 1.3.70-2 → 1.3.71-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 (182) hide show
  1. package/background/KoniTypes.js +65 -8
  2. package/cjs/background/KoniTypes.js +65 -8
  3. package/cjs/constants/blocked-actions.js +3 -0
  4. package/cjs/core/logic-validation/swap.js +0 -3
  5. package/cjs/core/substrate/system-pallet.js +0 -2
  6. package/cjs/koni/api/nft/wasm_nft/index.js +0 -1
  7. package/cjs/koni/api/staking/bonding/astar.js +0 -2
  8. package/cjs/koni/api/staking/bonding/paraChain.js +0 -3
  9. package/cjs/koni/api/staking/bonding/relayChain.js +2 -4
  10. package/cjs/koni/api/staking/bonding/utils.js +0 -4
  11. package/cjs/koni/background/cron.js +0 -1
  12. package/cjs/koni/background/handlers/Extension.js +154 -158
  13. package/cjs/koni/background/handlers/State.js +54 -52
  14. package/cjs/koni/background/handlers/Tabs.js +39 -34
  15. package/cjs/packageInfo.js +1 -1
  16. package/cjs/page/index.js +7 -0
  17. package/cjs/page/substrate/PostMessageProvider.js +3 -0
  18. package/cjs/services/balance-service/helpers/subscribe/cardano/utils.js +0 -1
  19. package/cjs/services/balance-service/helpers/subscribe/substrate/gear.js +0 -2
  20. package/cjs/services/balance-service/helpers/subscribe/substrate/index.js +2 -3
  21. package/cjs/services/balance-service/helpers/subscribe/ton/utils.js +0 -3
  22. package/cjs/services/balance-service/index.js +103 -7
  23. package/cjs/services/balance-service/transfer/bitcoin-transfer.js +0 -1
  24. package/cjs/services/balance-service/transfer/cardano-transfer.js +1 -2
  25. package/cjs/services/balance-service/transfer/smart-contract.js +0 -1
  26. package/cjs/services/balance-service/transfer/token.js +0 -2
  27. package/cjs/services/balance-service/transfer/ton-transfer.js +0 -1
  28. package/cjs/services/balance-service/transfer/xcm/snowBridge.js +0 -1
  29. package/cjs/services/chain-service/handler/CardanoApi.js +3 -1
  30. package/cjs/services/chain-service/handler/SubstrateApi.js +0 -2
  31. package/cjs/services/chain-service/handler/light-client/index.js +1 -2
  32. package/cjs/services/chain-service/health-check/index.js +0 -1
  33. package/cjs/services/chain-service/health-check/utils/new-utils/chain-asset-validate.js +0 -1
  34. package/cjs/services/chain-service/index.js +18 -26
  35. package/cjs/services/chain-service/utils/index.js +21 -25
  36. package/cjs/services/earning-service/handlers/base.js +32 -0
  37. package/cjs/services/earning-service/handlers/lending/base.js +0 -2
  38. package/cjs/services/earning-service/handlers/liquid-staking/acala.js +0 -1
  39. package/cjs/services/earning-service/handlers/liquid-staking/base.js +0 -2
  40. package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +0 -2
  41. package/cjs/services/earning-service/handlers/liquid-staking/parallel.js +0 -1
  42. package/cjs/services/earning-service/handlers/native-staking/astar.js +0 -2
  43. package/cjs/services/earning-service/handlers/native-staking/dtao.js +43 -2
  44. package/cjs/services/earning-service/handlers/native-staking/energy.js +0 -1
  45. package/cjs/services/earning-service/handlers/native-staking/mythos.js +0 -2
  46. package/cjs/services/earning-service/handlers/native-staking/para-chain.js +0 -2
  47. package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +8 -9
  48. package/cjs/services/earning-service/handlers/special.js +7 -0
  49. package/cjs/services/history-service/subsquid-multi-chain-history.js +0 -1
  50. package/cjs/services/keyring-service/context/handlers/Derive.js +1 -1
  51. package/cjs/services/keyring-service/context/handlers/Migration.js +11 -9
  52. package/cjs/services/keyring-service/context/handlers/Mnemonic.js +18 -13
  53. package/cjs/services/keyring-service/context/state.js +21 -3
  54. package/cjs/services/keyring-service/utils.js +12 -2
  55. package/cjs/services/migration-service/index.js +1 -2
  56. package/cjs/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -1
  57. package/cjs/services/nft-service/index.js +5 -0
  58. package/cjs/services/open-gov/handler.js +0 -2
  59. package/cjs/services/open-gov/interface.js +4 -1
  60. package/cjs/services/request-service/handler/BitcoinRequestHandler.js +1 -2
  61. package/cjs/services/request-service/handler/CardanoRequestHandler.js +0 -1
  62. package/cjs/services/request-service/handler/EvmRequestHandler.js +0 -1
  63. package/cjs/services/request-service/handler/TonRequestHandler.js +0 -1
  64. package/cjs/services/request-service/helper/index.js +1 -2
  65. package/cjs/services/storage-service/DatabaseService.js +0 -2
  66. package/cjs/services/storage-service/databases/index.js +2 -0
  67. package/cjs/services/swap-service/handler/asset-hub/handler.js +0 -1
  68. package/cjs/services/swap-service/handler/asset-hub/router.js +0 -1
  69. package/cjs/services/swap-service/handler/chainflip-handler.js +1 -4
  70. package/cjs/services/swap-service/handler/hydradx-handler.js +0 -1
  71. package/cjs/services/swap-service/handler/kyber-handler.js +0 -1
  72. package/cjs/services/swap-service/handler/optimex-handler.js +1 -2
  73. package/cjs/services/swap-service/handler/simpleswap-handler.js +1 -3
  74. package/cjs/services/swap-service/handler/uniswap-handler.js +0 -3
  75. package/cjs/services/transaction-service/event-parser/index.js +6 -6
  76. package/cjs/services/transaction-service/index.js +28 -28
  77. package/cjs/services/wallet-connect-service/index.js +21 -18
  78. package/cjs/services/wallet-connect-service/types.js +1 -1
  79. package/cjs/types/account/info/keyring.js +9 -1
  80. package/cjs/types/balance/index.js +5 -1
  81. package/cjs/types/swap/index.js +2 -1
  82. package/cjs/types/transaction/process.js +2 -0
  83. package/cjs/types/yield/actions/join/step.js +17 -1
  84. package/cjs/utils/account/common.js +0 -26
  85. package/cjs/utils/account/derive/info/solo.js +7 -4
  86. package/cjs/utils/account/derive/validate.js +1 -1
  87. package/cjs/utils/account/transform.js +5 -1
  88. package/cjs/utils/auth.js +1 -1
  89. package/cjs/utils/bitcoin/utxo-management.js +0 -1
  90. package/cjs/utils/environment.js +2 -1
  91. package/cjs/utils/fee/transfer.js +1 -2
  92. package/cjs/utils/index.js +1 -2
  93. package/constants/blocked-actions.js +3 -0
  94. package/core/logic-validation/swap.js +0 -3
  95. package/core/substrate/system-pallet.js +0 -2
  96. package/koni/api/nft/wasm_nft/index.js +0 -1
  97. package/koni/api/staking/bonding/astar.js +0 -2
  98. package/koni/api/staking/bonding/paraChain.js +0 -3
  99. package/koni/api/staking/bonding/relayChain.js +2 -4
  100. package/koni/api/staking/bonding/utils.js +0 -4
  101. package/koni/background/cron.js +0 -1
  102. package/koni/background/handlers/Extension.js +8 -11
  103. package/koni/background/handlers/State.js +41 -38
  104. package/koni/background/handlers/Tabs.js +9 -3
  105. package/package.json +19 -20
  106. package/packageInfo.js +1 -1
  107. package/page/substrate/PostMessageProvider.js +3 -0
  108. package/services/balance-service/helpers/subscribe/cardano/utils.js +0 -1
  109. package/services/balance-service/helpers/subscribe/substrate/gear.js +0 -2
  110. package/services/balance-service/helpers/subscribe/substrate/index.js +0 -1
  111. package/services/balance-service/helpers/subscribe/ton/utils.js +0 -3
  112. package/services/balance-service/index.d.ts +8 -0
  113. package/services/balance-service/index.js +105 -9
  114. package/services/balance-service/transfer/bitcoin-transfer.js +0 -1
  115. package/services/balance-service/transfer/smart-contract.js +0 -1
  116. package/services/balance-service/transfer/token.js +0 -2
  117. package/services/balance-service/transfer/ton-transfer.js +0 -1
  118. package/services/balance-service/transfer/xcm/snowBridge.js +0 -1
  119. package/services/chain-service/handler/CardanoApi.js +3 -1
  120. package/services/chain-service/handler/SubstrateApi.js +0 -2
  121. package/services/chain-service/health-check/index.js +0 -1
  122. package/services/chain-service/health-check/utils/new-utils/chain-asset-validate.js +0 -1
  123. package/services/chain-service/index.d.ts +0 -1
  124. package/services/chain-service/index.js +15 -23
  125. package/services/chain-service/utils/index.js +22 -26
  126. package/services/earning-service/handlers/base.js +32 -0
  127. package/services/earning-service/handlers/lending/base.js +0 -2
  128. package/services/earning-service/handlers/liquid-staking/acala.js +0 -1
  129. package/services/earning-service/handlers/liquid-staking/base.js +0 -2
  130. package/services/earning-service/handlers/liquid-staking/bifrost.js +0 -2
  131. package/services/earning-service/handlers/liquid-staking/parallel.js +0 -1
  132. package/services/earning-service/handlers/native-staking/astar.js +0 -2
  133. package/services/earning-service/handlers/native-staking/dtao.js +43 -0
  134. package/services/earning-service/handlers/native-staking/energy.js +0 -1
  135. package/services/earning-service/handlers/native-staking/mythos.js +0 -2
  136. package/services/earning-service/handlers/native-staking/para-chain.js +0 -2
  137. package/services/earning-service/handlers/native-staking/relay-chain.js +8 -9
  138. package/services/earning-service/handlers/special.js +7 -0
  139. package/services/history-service/subsquid-multi-chain-history.js +0 -1
  140. package/services/keyring-service/context/handlers/Derive.js +2 -2
  141. package/services/keyring-service/context/handlers/Migration.js +3 -1
  142. package/services/keyring-service/context/handlers/Mnemonic.d.ts +1 -1
  143. package/services/keyring-service/context/handlers/Mnemonic.js +16 -10
  144. package/services/keyring-service/context/state.d.ts +3 -0
  145. package/services/keyring-service/context/state.js +21 -3
  146. package/services/keyring-service/utils.d.ts +1 -0
  147. package/services/keyring-service/utils.js +9 -0
  148. package/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -1
  149. package/services/nft-service/index.js +6 -0
  150. package/services/open-gov/handler.js +0 -2
  151. package/services/open-gov/interface.js +4 -1
  152. package/services/request-service/handler/CardanoRequestHandler.js +0 -1
  153. package/services/request-service/handler/EvmRequestHandler.js +0 -1
  154. package/services/request-service/handler/TonRequestHandler.js +0 -1
  155. package/services/setting-service/constants.js +0 -1
  156. package/services/storage-service/DatabaseService.js +0 -2
  157. package/services/storage-service/databases/index.js +3 -0
  158. package/services/swap-service/handler/asset-hub/handler.js +0 -1
  159. package/services/swap-service/handler/asset-hub/router.js +0 -1
  160. package/services/swap-service/handler/chainflip-handler.js +0 -2
  161. package/services/swap-service/handler/hydradx-handler.js +0 -1
  162. package/services/swap-service/handler/kyber-handler.js +0 -1
  163. package/services/swap-service/handler/simpleswap-handler.js +0 -1
  164. package/services/swap-service/handler/uniswap-handler.js +0 -3
  165. package/services/transaction-service/event-parser/index.js +6 -6
  166. package/services/wallet-connect-service/index.js +21 -18
  167. package/services/wallet-connect-service/types.js +1 -1
  168. package/types/account/action/add/mnemonic.d.ts +3 -2
  169. package/types/account/info/keyring.js +9 -1
  170. package/types/balance/index.js +5 -1
  171. package/types/swap/index.js +2 -1
  172. package/types/transaction/process.js +3 -1
  173. package/types/yield/actions/join/step.js +17 -1
  174. package/utils/account/common.d.ts +0 -3
  175. package/utils/account/common.js +0 -24
  176. package/utils/account/derive/info/solo.js +8 -5
  177. package/utils/account/derive/validate.d.ts +2 -2
  178. package/utils/account/derive/validate.js +1 -1
  179. package/utils/account/transform.js +5 -1
  180. package/utils/auth.js +2 -2
  181. package/utils/bitcoin/utxo-management.js +0 -1
  182. package/utils/index.js +2 -5
@@ -60,8 +60,7 @@ var _util = require("@polkadot/util");
60
60
  var _utilCrypto = require("@polkadot/util-crypto");
61
61
  var _cron = require("../cron");
62
62
  var _subscription = require("../subscription");
63
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
64
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
63
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
65
64
  // Copyright 2019-2022 @subwallet/extension-koni authors & contributors
66
65
  // SPDX-License-Identifier: Apache-2.0
67
66
 
@@ -95,6 +94,9 @@ class KoniState {
95
94
  data: {}
96
95
  };
97
96
  lazyMap = {};
97
+
98
+ // TODO: consider making chainService public (or getter) and call function directly
99
+
98
100
  // Handle the general status of the extension
99
101
  generalStatus = _types.ServiceStatus.INITIALIZING;
100
102
  waitSleeping = null;
@@ -761,7 +763,7 @@ class KoniState {
761
763
  async enableChainWithPriorityAssets(chainSlug) {
762
764
  let enableTokens = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
763
765
  if (enableTokens) {
764
- await this.chainService.updatePriorityAssetsByChain(chainSlug, true);
766
+ await this.balanceService.updatePriorityAssetsByChain(chainSlug, true);
765
767
  }
766
768
  return this.chainService.enableChain(chainSlug);
767
769
  }
@@ -1364,10 +1366,10 @@ class KoniState {
1364
1366
  const psbtGenerate = bitcoin.Psbt.fromHex(psbt, {
1365
1367
  network: network_
1366
1368
  });
1367
- const isExistedInput = (inputs, address) => inputs.findIndex(_ref10 => {
1369
+ const isExistedInput = (inputs, address) => inputs.findIndex(_ref0 => {
1368
1370
  let {
1369
1371
  address: address_
1370
- } = _ref10;
1372
+ } = _ref0;
1371
1373
  return (0, _utils3.isSameAddress)(address, address_ || '');
1372
1374
  });
1373
1375
  let to = '';
@@ -1375,11 +1377,11 @@ class KoniState {
1375
1377
  let value = new _bignumber.default(0);
1376
1378
  const totalBalance = await this.balanceService.getTotalBalance(address, result.networkKey, tokenInfo.slug);
1377
1379
  let inputAmount = new _bignumber.default(0);
1378
- const psbtInputData = psbtGenerate.data.inputs.reduce((inputs, _ref11, inputIndex) => {
1380
+ const psbtInputData = psbtGenerate.data.inputs.reduce((inputs, _ref1, inputIndex) => {
1379
1381
  let {
1380
1382
  nonWitnessUtxo,
1381
1383
  witnessUtxo
1382
- } = _ref11;
1384
+ } = _ref1;
1383
1385
  let inputData = null;
1384
1386
  if (witnessUtxo) {
1385
1387
  inputData = {
@@ -1437,11 +1439,11 @@ class KoniState {
1437
1439
  txInput: psbtInputData,
1438
1440
  txOutput: psbtOutputData
1439
1441
  };
1440
- return this.requestService.addConfirmationBitcoin(id, url, 'bitcoinSignPsbtRequest', payloadAfterValidated, {}).then(_ref12 => {
1442
+ return this.requestService.addConfirmationBitcoin(id, url, 'bitcoinSignPsbtRequest', payloadAfterValidated, {}).then(_ref10 => {
1441
1443
  let {
1442
1444
  isApproved,
1443
1445
  payload
1444
- } = _ref12;
1446
+ } = _ref10;
1445
1447
  if (isApproved) {
1446
1448
  if (payload) {
1447
1449
  return payload;
@@ -1473,11 +1475,11 @@ class KoniState {
1473
1475
  };
1474
1476
 
1475
1477
  // Custom handle this instead of general handler transaction
1476
- return this.requestService.addConfirmationBitcoin(id, url, 'bitcoinSendTransactionRequestAfterConfirmation', requestPayload, {}).then(_ref13 => {
1478
+ return this.requestService.addConfirmationBitcoin(id, url, 'bitcoinSendTransactionRequestAfterConfirmation', requestPayload, {}).then(_ref11 => {
1477
1479
  let {
1478
1480
  isApproved,
1479
1481
  payload
1480
- } = _ref13;
1482
+ } = _ref11;
1481
1483
  if (isApproved) {
1482
1484
  if (payload) {
1483
1485
  return payload;
@@ -1583,11 +1585,11 @@ class KoniState {
1583
1585
  const subscription = this.keyringService.context.observable.currentAccount.subscribe(handleRemind);
1584
1586
  }
1585
1587
  }
1586
- async setStorageFromWS(_ref14) {
1588
+ async setStorageFromWS(_ref12) {
1587
1589
  let {
1588
1590
  key,
1589
1591
  value
1590
- } = _ref14;
1592
+ } = _ref12;
1591
1593
  try {
1592
1594
  const jsonData = JSON.stringify(value);
1593
1595
  await _storage.SWStorage.instance.setItem(key, jsonData);
@@ -1878,7 +1880,7 @@ class KoniState {
1878
1880
  });
1879
1881
  }
1880
1882
  async enableMantaPay(updateStore, address, password, seedPhrase) {
1881
- var _this$chainService3, _this$chainService3$m, _this$chainService4, _this$chainService4$m, _this$chainService4$m2, _this$chainService11, _this$chainService11$, _this$chainService11$2;
1883
+ var _this$chainService3, _this$chainService3$m, _this$chainService4, _this$chainService4$m, _this$chainService4$m2, _this$chainService1, _this$chainService1$m, _this$chainService1$m2;
1882
1884
  if (!address || (0, _utilCrypto.isEthereumAddress)(address)) {
1883
1885
  return;
1884
1886
  }
@@ -1898,7 +1900,7 @@ class KoniState {
1898
1900
  data: encryptedData
1899
1901
  }));
1900
1902
  } else {
1901
- var _this$chainService9, _this$chainService9$m, _this$chainService10, _this$chainService10$, _this$chainService10$2;
1903
+ var _this$chainService9, _this$chainService9$m, _this$chainService0, _this$chainService0$m, _this$chainService0$m2;
1902
1904
  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));
1903
1905
 
1904
1906
  // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
@@ -1906,18 +1908,18 @@ class KoniState {
1906
1908
 
1907
1909
  // eslint-disable-next-line @typescript-eslint/no-unsafe-argument,@typescript-eslint/no-unsafe-member-access
1908
1910
  const proofAuthKey = new Uint8Array(Object.values(decryptedData.proof_authorization_key));
1909
- 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({
1911
+ await ((_this$chainService0 = this.chainService) === null || _this$chainService0 === void 0 ? void 0 : (_this$chainService0$m = _this$chainService0.mantaPay) === null || _this$chainService0$m === void 0 ? void 0 : (_this$chainService0$m2 = _this$chainService0$m.privateWallet) === null || _this$chainService0$m2 === void 0 ? void 0 : _this$chainService0$m2.loadAuthorizationContext({
1910
1912
  proof_authorization_key: proofAuthKey
1911
1913
  }));
1912
1914
  }
1913
- 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());
1915
+ const zkAddress = await ((_this$chainService1 = this.chainService) === null || _this$chainService1 === void 0 ? void 0 : (_this$chainService1$m = _this$chainService1.mantaPay) === null || _this$chainService1$m === void 0 ? void 0 : (_this$chainService1$m2 = _this$chainService1$m.privateWallet) === null || _this$chainService1$m2 === void 0 ? void 0 : _this$chainService1$m2.getZkAddress());
1914
1916
  if (updateStore) {
1915
- var _this$chainService12, _this$chainService12$, _this$chainService13, _this$chainService13$, _this$chainService13$2, _this$chainService13$3;
1916
- 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({
1917
+ var _this$chainService10, _this$chainService10$, _this$chainService11, _this$chainService11$, _this$chainService11$2, _this$chainService11$3;
1918
+ 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$.saveMantaPayConfig({
1917
1919
  address,
1918
1920
  zkAddress: zkAddress,
1919
1921
  enabled: true,
1920
- 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(),
1922
+ chain: (_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$3 = _this$chainService11$2.network) === null || _this$chainService11$3 === void 0 ? void 0 : _this$chainService11$3.toLowerCase(),
1921
1923
  isInitialSync: false
1922
1924
  }));
1923
1925
  }
@@ -1925,48 +1927,48 @@ class KoniState {
1925
1927
  return zkAddress;
1926
1928
  }
1927
1929
  async disableMantaPay(address) {
1928
- 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$;
1929
- 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));
1930
+ var _this$chainService12, _this$chainService12$, _this$chainService13, _this$chainService13$, _this$chainService13$2, _this$chainService14, _this$chainService14$, _this$chainService14$2, _this$chainService15, _this$chainService15$, _this$chainService16, _this$chainService16$;
1931
+ const config = 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$.getMantaPayConfig(address, _constants2._DEFAULT_MANTA_ZK_CHAIN));
1930
1932
  if (!config) {
1931
1933
  return false;
1932
1934
  }
1933
- 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());
1934
- 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());
1935
+ await ((_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$2.dropAuthorizationContext());
1936
+ 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$2 = _this$chainService14$.privateWallet) === null || _this$chainService14$2 === void 0 ? void 0 : _this$chainService14$2.dropUserSeedPhrase());
1935
1937
  // await this.chainService?.mantaPay?.privateWallet?.resetState();
1936
- 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));
1937
- 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));
1938
+ 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$.deleteMantaPayConfig(address, _constants2._DEFAULT_MANTA_ZK_CHAIN));
1939
+ 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$.deleteMantaAuthContext(address, _constants2._DEFAULT_MANTA_ZK_CHAIN));
1938
1940
  this.chainService.setMantaZkAssetSettings(false);
1939
1941
  this.isMantaPayEnabled = false;
1940
1942
  return true;
1941
1943
  }
1942
1944
  async initialSyncMantaPay(address) {
1943
- 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$;
1945
+ var _this$chainService17, _this$chainService17$, _this$chainService18, _this$chainService18$, _this$chainService18$2, _this$chainService18$3, _this$chainService19, _this$chainService19$, _this$chainService19$2, _this$chainService20, _this$chainService20$;
1944
1946
  if (!address || (0, _utilCrypto.isEthereumAddress)(address)) {
1945
1947
  return;
1946
1948
  }
1947
- (_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);
1948
- 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());
1949
- 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());
1950
- 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, {
1949
+ (_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$.setCurrentAddress(address);
1950
+ 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$2 = _this$chainService18$.privateWallet) === null || _this$chainService18$2 === void 0 ? void 0 : (_this$chainService18$3 = _this$chainService18$2.baseWallet) === null || _this$chainService18$3 === void 0 ? void 0 : _this$chainService18$3.isApiReady());
1951
+ const syncResult = await ((_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$2 = _this$chainService19$.privateWallet) === null || _this$chainService19$2 === void 0 ? void 0 : _this$chainService19$2.initialWalletSync());
1952
+ 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$.updateMantaPayConfig(address, _constants2._DEFAULT_MANTA_ZK_CHAIN, {
1951
1953
  isInitialSync: true
1952
1954
  }));
1953
1955
  this.eventService.emit('mantaPay.initSync', undefined);
1954
1956
  return syncResult;
1955
1957
  }
1956
1958
  getMantaZkBalance() {
1957
- var _this$chainService23, _this$chainService24, _this$chainService24$, _this$chainService24$2, _this$chainService25, _this$chainService25$, _this$chainService26, _this$chainService26$, _this$chainService26$2;
1958
- if (!this.chainService || !((_this$chainService23 = this.chainService) !== null && _this$chainService23 !== void 0 && _this$chainService23.mantaPay)) {
1959
+ var _this$chainService21, _this$chainService22, _this$chainService22$, _this$chainService22$2, _this$chainService23, _this$chainService23$, _this$chainService24, _this$chainService24$, _this$chainService24$2;
1960
+ if (!this.chainService || !((_this$chainService21 = this.chainService) !== null && _this$chainService21 !== void 0 && _this$chainService21.mantaPay)) {
1959
1961
  return;
1960
1962
  }
1961
- 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)) {
1963
+ if (!((_this$chainService22 = this.chainService) !== null && _this$chainService22 !== void 0 && (_this$chainService22$ = _this$chainService22.mantaPay) !== null && _this$chainService22$ !== void 0 && (_this$chainService22$2 = _this$chainService22$.privateWallet) !== null && _this$chainService22$2 !== void 0 && _this$chainService22$2.initialSyncIsFinished)) {
1962
1964
  return;
1963
1965
  }
1964
- 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;
1966
+ const chain = (_this$chainService23 = this.chainService) === null || _this$chainService23 === void 0 ? void 0 : (_this$chainService23$ = _this$chainService23.mantaPay.privateWallet) === null || _this$chainService23$ === void 0 ? void 0 : _this$chainService23$.network;
1965
1967
  if (!chain) {
1966
1968
  return;
1967
1969
  }
1968
1970
  const assetMap = this.chainService.getMantaZkAssets(chain === null || chain === void 0 ? void 0 : chain.toLowerCase());
1969
- (_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.default((0, _utils._getTokenOnChainAssetId)(tokenInfo)))).then(zkBalances => {
1971
+ (_this$chainService24 = this.chainService) === null || _this$chainService24 === void 0 ? void 0 : (_this$chainService24$ = _this$chainService24.mantaPay) === null || _this$chainService24$ === void 0 ? void 0 : (_this$chainService24$2 = _this$chainService24$.privateWallet) === null || _this$chainService24$2 === void 0 ? void 0 : _this$chainService24$2.getMultiZkBalance(Object.values(assetMap).map(tokenInfo => new _bn.default((0, _utils._getTokenOnChainAssetId)(tokenInfo)))).then(zkBalances => {
1970
1972
  const assetList = Object.values(assetMap);
1971
1973
  for (let i = 0; i < assetList.length; i++) {
1972
1974
  var _zkBalances$i;
@@ -1983,9 +1985,9 @@ class KoniState {
1983
1985
  }).catch(console.warn);
1984
1986
  }
1985
1987
  subscribeMantaPayBalance() {
1986
- var _this$chainService27, _this$chainService27$;
1988
+ var _this$chainService25, _this$chainService25$;
1987
1989
  let interval;
1988
- (_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.context.currentAccount.proxyId, _constants2._DEFAULT_MANTA_ZK_CHAIN).then(config => {
1990
+ (_this$chainService25 = this.chainService) === null || _this$chainService25 === void 0 ? void 0 : (_this$chainService25$ = _this$chainService25.mantaPay) === null || _this$chainService25$ === void 0 ? void 0 : _this$chainService25$.getMantaPayConfig(this.keyringService.context.currentAccount.proxyId, _constants2._DEFAULT_MANTA_ZK_CHAIN).then(config => {
1989
1991
  if (config && config.enabled && config.isInitialSync) {
1990
1992
  this.getMantaZkBalance();
1991
1993
  interval = setInterval(this.getMantaZkBalance, _constants.MANTA_PAY_BALANCE_INTERVAL);
@@ -1996,23 +1998,23 @@ class KoniState {
1996
1998
  };
1997
1999
  }
1998
2000
  async syncMantaPay() {
1999
- var _this$chainService28, _this$chainService28$, _this$chainService29, _this$chainService29$, _this$chainService29$2;
2000
- 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));
2001
+ var _this$chainService26, _this$chainService26$, _this$chainService27, _this$chainService27$, _this$chainService27$2;
2002
+ const config = await ((_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$.getMantaPayFirstConfig(_constants2._DEFAULT_MANTA_ZK_CHAIN));
2001
2003
  if (!config.isInitialSync) {
2002
2004
  return;
2003
2005
  }
2004
- 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) {
2005
- var _this$chainService30, _this$chainService30$, _this$chainService30$2;
2006
- 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());
2006
+ if ((_this$chainService27 = this.chainService) !== null && _this$chainService27 !== void 0 && (_this$chainService27$ = _this$chainService27.mantaPay) !== null && _this$chainService27$ !== void 0 && (_this$chainService27$2 = _this$chainService27$.privateWallet) !== null && _this$chainService27$2 !== void 0 && _this$chainService27$2.initialSyncIsFinished) {
2007
+ var _this$chainService28, _this$chainService28$, _this$chainService28$2;
2008
+ 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$2 = _this$chainService28$.privateWallet) === null || _this$chainService28$2 === void 0 ? void 0 : _this$chainService28$2.walletSync());
2007
2009
  } else {
2008
- var _this$chainService31, _this$chainService31$, _this$chainService31$2;
2009
- 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());
2010
+ var _this$chainService29, _this$chainService29$, _this$chainService29$2;
2011
+ await ((_this$chainService29 = this.chainService) === null || _this$chainService29 === void 0 ? void 0 : (_this$chainService29$ = _this$chainService29.mantaPay) === null || _this$chainService29$ === void 0 ? void 0 : (_this$chainService29$2 = _this$chainService29$.privateWallet) === null || _this$chainService29$2 === void 0 ? void 0 : _this$chainService29$2.initialWalletSync());
2010
2012
  }
2011
2013
  }
2012
2014
  async getMantaPayZkBalance(address, tokenInfo) {
2013
- var _this$chainService32, _this$chainService32$, _this$chainService32$2;
2015
+ var _this$chainService30, _this$chainService30$, _this$chainService30$2;
2014
2016
  const bnAssetId = new _bn.default((0, _utils._getTokenOnChainAssetId)(tokenInfo));
2015
- 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));
2017
+ const balance = 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.getZkBalance(bnAssetId));
2016
2018
  return {
2017
2019
  decimals: tokenInfo.decimals || 0,
2018
2020
  symbol: tokenInfo.symbol,
@@ -2020,11 +2022,11 @@ class KoniState {
2020
2022
  };
2021
2023
  }
2022
2024
  subscribeMantaPaySyncState() {
2023
- var _this$chainService33, _this$chainService34, _this$chainService34$;
2024
- if (!((_this$chainService33 = this.chainService) !== null && _this$chainService33 !== void 0 && _this$chainService33.mantaPay)) {
2025
+ var _this$chainService31, _this$chainService32, _this$chainService32$;
2026
+ if (!((_this$chainService31 = this.chainService) !== null && _this$chainService31 !== void 0 && _this$chainService31.mantaPay)) {
2025
2027
  return new _rxjs.Subject();
2026
2028
  }
2027
- 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();
2029
+ return (_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$.subscribeSyncState();
2028
2030
  }
2029
2031
 
2030
2032
  /* Metadata */
@@ -2047,12 +2049,12 @@ class KoniState {
2047
2049
 
2048
2050
  /* Metadata */
2049
2051
 
2050
- getCrowdloanContributions(_ref15) {
2052
+ getCrowdloanContributions(_ref13) {
2051
2053
  let {
2052
2054
  address,
2053
2055
  page,
2054
2056
  relayChain
2055
- } = _ref15;
2057
+ } = _ref13;
2056
2058
  return this.subscanService.getCrowdloanContributions(relayChain, address, page);
2057
2059
  }
2058
2060
  }
@@ -30,8 +30,7 @@ var _web = _interopRequireDefault(require("web3"));
30
30
  var _phishing = require("@polkadot/phishing");
31
31
  var _util = require("@polkadot/util");
32
32
  var _utilCrypto = require("@polkadot/util-crypto");
33
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
34
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
33
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
35
34
  // Copyright 2019-2022 @subwallet/extension-koni authors & contributors
36
35
  // SPDX-License-Identifier: Apache-2.0
37
36
 
@@ -52,7 +51,7 @@ function transformAccountsV2(accounts) {
52
51
  }
53
52
  const validTypes = {
54
53
  evm: _types3.EthereumKeypairTypes,
55
- substrate: _types3.SubstrateKeypairTypes,
54
+ substrate: _types3.AllSubstrateKeypairTypes,
56
55
  ton: _types3.TonKeypairTypes,
57
56
  cardano: _types3.CardanoKeypairTypes,
58
57
  bitcoin: _types3.BitcoinKeypairTypes
@@ -80,7 +79,7 @@ function transformAccountsV2(accounts) {
80
79
  return true;
81
80
  }
82
81
  };
83
- return Object.values(accounts).filter(_ref2 => {
82
+ const injectedAccounts = Object.values(accounts).filter(_ref2 => {
84
83
  let {
85
84
  json: {
86
85
  meta: {
@@ -114,6 +113,12 @@ function transformAccountsV2(accounts) {
114
113
  type
115
114
  };
116
115
  });
116
+ return injectedAccounts.map(acc => {
117
+ if (acc.type === 'ed25519-tw') {
118
+ acc.type = 'ed25519';
119
+ }
120
+ return acc;
121
+ });
117
122
  }
118
123
  // check if a URL is blocked
119
124
  const chainPatrolCheckUrl = async url => {
@@ -503,10 +508,10 @@ class KoniTabs {
503
508
  date: new Date().getTime()
504
509
  }];
505
510
  }
506
- async revokePermissions(url, id, _ref10) {
511
+ async revokePermissions(url, id, _ref0) {
507
512
  let {
508
513
  params
509
- } = _ref10;
514
+ } = _ref0;
510
515
  if (!params || !(0, _util.isArray)(params) || params.length === 0) {
511
516
  throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, 'No list of permissions found to revoke in the parameters.');
512
517
  }
@@ -542,8 +547,8 @@ class KoniTabs {
542
547
  if (accountAuthTypes.length === 1) {
543
548
  delete value[urlStripped];
544
549
  } else {
545
- value[urlStripped].isAllowedMap = Object.entries(isAllowedMap).reduce((allowedMap, _ref11) => {
546
- let [address, value] = _ref11;
550
+ value[urlStripped].isAllowedMap = Object.entries(isAllowedMap).reduce((allowedMap, _ref1) => {
551
+ let [address, value] = _ref1;
547
552
  if ((0, _utilCrypto.isEthereumAddress)(address)) {
548
553
  allowedMap[address] = false;
549
554
  } else {
@@ -569,10 +574,10 @@ class KoniTabs {
569
574
  await Promise.all(Array.from(permissions).map(permissionPromise));
570
575
  return null;
571
576
  }
572
- async switchEvmChain(id, url, _ref12) {
577
+ async switchEvmChain(id, url, _ref10) {
573
578
  let {
574
579
  params
575
- } = _ref12;
580
+ } = _ref10;
576
581
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
577
582
  const chainId = params[0].chainId;
578
583
  const chainIdDec = parseInt(chainId, 16);
@@ -627,11 +632,11 @@ class KoniTabs {
627
632
  }
628
633
  return null;
629
634
  }
630
- async addEvmToken(id, url, _ref13) {
635
+ async addEvmToken(id, url, _ref11) {
631
636
  var _input$type, _input$options, _input$options2, _input$options3, _input$options4, _input$options5;
632
637
  let {
633
638
  params
634
- } = _ref13;
639
+ } = _ref11;
635
640
  const input = params;
636
641
  const _tokenType = (input === null || input === void 0 ? void 0 : (_input$type = input.type) === null || _input$type === void 0 ? void 0 : _input$type.toLowerCase()) || '';
637
642
  if (_tokenType !== 'erc20' && _tokenType !== 'erc721') {
@@ -684,10 +689,10 @@ class KoniTabs {
684
689
 
685
690
  return await this.#koniState.addTokenConfirm(id, url, tokenInfo);
686
691
  }
687
- async addEvmChain(id, url, _ref14) {
692
+ async addEvmChain(id, url, _ref12) {
688
693
  let {
689
694
  params
690
- } = _ref14;
695
+ } = _ref12;
691
696
  const input = params;
692
697
  if (input && input.length > 0) {
693
698
  const {
@@ -892,11 +897,11 @@ class KoniTabs {
892
897
  const networkCheckInterval = setInterval(networkCheck, _constants.CRON_GET_API_MAP_STATUS);
893
898
  const provider = await this.getEvmProvider(url);
894
899
  const eventMap = {};
895
- eventMap.data = _ref15 => {
900
+ eventMap.data = _ref13 => {
896
901
  let {
897
902
  method,
898
903
  params
899
- } = _ref15;
904
+ } = _ref13;
900
905
  emitEvent('message', {
901
906
  type: method,
902
907
  data: params
@@ -905,8 +910,8 @@ class KoniTabs {
905
910
  eventMap.error = rs => {
906
911
  emitEvent('error', rs);
907
912
  };
908
- Object.entries(eventMap).forEach(_ref16 => {
909
- let [event, callback] = _ref16;
913
+ Object.entries(eventMap).forEach(_ref14 => {
914
+ let [event, callback] = _ref14;
910
915
  // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
911
916
  (provider === null || provider === void 0 ? void 0 : provider.on) && (provider === null || provider === void 0 ? void 0 : provider.on(event, callback));
912
917
  });
@@ -920,8 +925,8 @@ class KoniTabs {
920
925
  if (this.evmEventEmitterMap[url][id]) {
921
926
  delete this.evmEventEmitterMap[url][id];
922
927
  }
923
- Object.entries(eventMap).forEach(_ref17 => {
924
- let [event, callback] = _ref17;
928
+ Object.entries(eventMap).forEach(_ref15 => {
929
+ let [event, callback] = _ref15;
925
930
  // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
926
931
  (provider === null || provider === void 0 ? void 0 : provider.removeListener) && (provider === null || provider === void 0 ? void 0 : provider.removeListener(event, callback));
927
932
  });
@@ -956,11 +961,11 @@ class KoniTabs {
956
961
  }
957
962
  return provider;
958
963
  }
959
- async performWeb3Method(id, url, _ref18, callback) {
964
+ async performWeb3Method(id, url, _ref16, callback) {
960
965
  let {
961
966
  method,
962
967
  params
963
- } = _ref18;
968
+ } = _ref16;
964
969
  const provider = await this.getEvmProvider(url);
965
970
  this.checkAndHandleProviderStatus(provider);
966
971
  return new Promise((resolve, reject) => {
@@ -992,11 +997,11 @@ class KoniTabs {
992
997
  });
993
998
  });
994
999
  }
995
- async evmSign(id, url, _ref19) {
1000
+ async evmSign(id, url, _ref17) {
996
1001
  let {
997
1002
  method,
998
1003
  params
999
- } = _ref19;
1004
+ } = _ref17;
1000
1005
  const signResult = await this.#koniState.evmSign(id, url, method, params);
1001
1006
  if (signResult) {
1002
1007
  return signResult;
@@ -1006,10 +1011,10 @@ class KoniTabs {
1006
1011
  }
1007
1012
 
1008
1013
  // TODO: Update logic
1009
- async evmSendTransaction(id, url, _ref20) {
1014
+ async evmSendTransaction(id, url, _ref18) {
1010
1015
  let {
1011
1016
  params
1012
- } = _ref20;
1017
+ } = _ref18;
1013
1018
  const transactionParams = params[0];
1014
1019
  const transactionHash = await this.#koniState.evmSendTransaction(id, url, transactionParams);
1015
1020
  if (!transactionHash) {
@@ -1095,11 +1100,11 @@ class KoniTabs {
1095
1100
  isEvmPublicRequest(type, request) {
1096
1101
  return type === 'evm(request)' && ['eth_chainId', 'net_version', 'wallet_requestPermissions', 'wallet_getPermissions'].includes(request === null || request === void 0 ? void 0 : request.method) || type === 'evm(events.subscribe)';
1097
1102
  }
1098
- async addPspToken(id, url, _ref21) {
1103
+ async addPspToken(id, url, _ref19) {
1099
1104
  let {
1100
1105
  genesisHash,
1101
1106
  tokenInfo: input
1102
- } = _ref21;
1107
+ } = _ref19;
1103
1108
  const _tokenType = input.type;
1104
1109
  if (_tokenType !== 'psp22' && _tokenType !== 'psp34') {
1105
1110
  throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, 'Assets type {{tokenType}} is not supported'.replace('{{tokenType}}', _tokenType));
@@ -1401,11 +1406,11 @@ class KoniTabs {
1401
1406
  throw new _BitcoinProviderError.BitcoinProviderError(_KoniTypes.BitcoinProviderErrorType.USER_REJECTED_REQUEST);
1402
1407
  }
1403
1408
  }
1404
- async bitcoinSign(id, url, _ref22) {
1409
+ async bitcoinSign(id, url, _ref20) {
1405
1410
  let {
1406
1411
  method,
1407
1412
  params
1408
- } = _ref22;
1413
+ } = _ref20;
1409
1414
  const signResult = await this.#koniState.bitcoinSign(id, url, method, params);
1410
1415
  if (signResult) {
1411
1416
  return signResult;
@@ -1413,11 +1418,11 @@ class KoniTabs {
1413
1418
  throw new _BitcoinProviderError.BitcoinProviderError(_KoniTypes.BitcoinProviderErrorType.INVALID_PARAMS, 'Failed to sign message');
1414
1419
  }
1415
1420
  }
1416
- async bitcoinSignPspt(id, url, _ref23) {
1421
+ async bitcoinSignPspt(id, url, _ref21) {
1417
1422
  let {
1418
1423
  method,
1419
1424
  params
1420
- } = _ref23;
1425
+ } = _ref21;
1421
1426
  const psbtParams = params;
1422
1427
  const signResult = await this.#koniState.bitcoinSignPspt(id, url, psbtParams);
1423
1428
  if (signResult) {
@@ -1426,10 +1431,10 @@ class KoniTabs {
1426
1431
  throw new _BitcoinProviderError.BitcoinProviderError(_KoniTypes.BitcoinProviderErrorType.INVALID_PARAMS, 'Failed to sign message');
1427
1432
  }
1428
1433
  }
1429
- async bitcoinSendTransfer(id, url, _ref24) {
1434
+ async bitcoinSendTransfer(id, url, _ref22) {
1430
1435
  let {
1431
1436
  params
1432
- } = _ref24;
1437
+ } = _ref22;
1433
1438
  const transactionParams = params;
1434
1439
  const transactionHash = await this.#koniState.bitcoinSendTransaction(id, url, transactionParams);
1435
1440
  if (!transactionHash) {
@@ -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.3.70-2'
16
+ version: '1.3.71-0'
17
17
  };
18
18
  exports.packageInfo = packageInfo;
package/cjs/page/index.js CHANGED
@@ -21,6 +21,13 @@ var _getId = require("../utils/getId");
21
21
  // Copyright 2019-2022 @polkadot/extension authors & contributors
22
22
  // SPDX-License-Identifier: Apache-2.0
23
23
 
24
+ // when sending a message from the injector to the extension, we
25
+ // - create an event - this we send to the loader
26
+ // - the loader takes this event and uses port.postMessage to background
27
+ // - on response, the loader creates a reponse event
28
+ // - this injector, listens on the events, maps it to the original
29
+ // - resolves/rejects the promise with the result (or sub data)
30
+
24
31
  const handlers = {};
25
32
 
26
33
  // a generic message sender that creates an event, returning a promise that will
@@ -11,6 +11,9 @@ var _util = require("@polkadot/util");
11
11
  // SPDX-License-Identifier: Apache-2.0
12
12
 
13
13
  const l = (0, _util.logger)('PostMessageProvider');
14
+
15
+ // Same as https://github.com/polkadot-js/api/blob/57ca9a9c3204339e1e1f693fcacc33039868dc27/packages/rpc-provider/src/ws/Provider.ts#L17
16
+
14
17
  // External to class, this.# is not private enough (yet)
15
18
  let sendRequest;
16
19
 
@@ -49,7 +49,6 @@ async function retryCardanoTxStatus(fn, options) {
49
49
  await new Promise(resolve => setTimeout(resolve, options.delay)); // wait for delay period, then recall the fn()
50
50
  }
51
51
  }
52
-
53
52
  console.error('Cardano transaction timeout', lastError); // throw only last error, in case no successful result from fn()
54
53
 
55
54
  return false;
@@ -67,7 +67,6 @@ const subscribeGRC20Balance = _ref => {
67
67
  }
68
68
  });
69
69
  };
70
-
71
70
  getTokenBalances();
72
71
  const interval = setInterval(getTokenBalances, _constants.SUB_TOKEN_REFRESH_BALANCE_INTERVAL);
73
72
  return () => {
@@ -127,7 +126,6 @@ const subscribeVftBalance = _ref3 => {
127
126
  }
128
127
  });
129
128
  };
130
-
131
129
  getTokenBalances();
132
130
  const interval = setInterval(getTokenBalances, _constants.SUB_TOKEN_REFRESH_BALANCE_INTERVAL);
133
131
  return () => {
@@ -356,7 +356,6 @@ const subscribePSP22Balance = _ref4 => {
356
356
  }
357
357
  });
358
358
  };
359
-
360
359
  getTokenBalances();
361
360
  const interval = setInterval(getTokenBalances, _constants.SUB_TOKEN_REFRESH_BALANCE_INTERVAL);
362
361
  return () => {
@@ -572,8 +571,8 @@ const subscribeSubnetAlphaPallet = async _ref9 => {
572
571
  }
573
572
  for (const chainAsset of Object.values(tokenMap)) {
574
573
  const netuid = (0, _utils2._getAssetNetuid)(chainAsset);
575
- const items = Object.entries(converted).map(_ref10 => {
576
- let [address, stakeMap] = _ref10;
574
+ const items = Object.entries(converted).map(_ref0 => {
575
+ let [address, stakeMap] = _ref0;
577
576
  const value = stakeMap[netuid] || (0, _bignumber.default)(0);
578
577
  return {
579
578
  address: address,
@@ -57,10 +57,8 @@ async function retryTonTxStatus(fn, options) {
57
57
  await new Promise(resolve => setTimeout(resolve, options.delay)); // wait for delay period, then recall the fn()
58
58
  }
59
59
  }
60
-
61
60
  throw lastError; // throw only last error, in case no successful result from fn()
62
61
  }
63
-
64
62
  function getMessageTxStatus(txByMsgInfo) {
65
63
  var _txDetailInfo$descrip, _txDetailInfo$descrip2, _txDetailInfo$descrip3, _txDetailInfo$descrip4, _txDetailInfo$descrip5, _txDetailInfo$descrip6, _txDetailInfo$out_msg, _txDetailInfo$out_msg2;
66
64
  const txDetailInfo = txByMsgInfo.transactions[0];
@@ -86,7 +84,6 @@ async function getJettonTxStatus(tonApi, jettonTransferMsgHash) {
86
84
  const jettonInternalTransferTxInfoRaw = await tonApi.getTxByInMsg(jettonInternalTransferHash);
87
85
  return getMessageTxStatus(jettonInternalTransferTxInfoRaw); // Jetton Internal Transfer success -> Receiver successfully receiver fund!
88
86
  }
89
-
90
87
  return false;
91
88
  }
92
89
  async function estimateTonTxFee(tonApi, messages, walletContract, _seqno) {