@subwallet/extension-base 1.3.69-0 → 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 (208) hide show
  1. package/background/KoniTypes.d.ts +11 -0
  2. package/background/KoniTypes.js +68 -8
  3. package/cjs/background/KoniTypes.js +68 -8
  4. package/cjs/constants/blocked-actions.js +3 -0
  5. package/cjs/core/logic-validation/swap.js +0 -3
  6. package/cjs/core/substrate/system-pallet.js +0 -2
  7. package/cjs/koni/api/nft/wasm_nft/index.js +0 -1
  8. package/cjs/koni/api/staking/bonding/astar.js +0 -2
  9. package/cjs/koni/api/staking/bonding/paraChain.js +0 -3
  10. package/cjs/koni/api/staking/bonding/relayChain.js +2 -4
  11. package/cjs/koni/api/staking/bonding/utils.js +0 -4
  12. package/cjs/koni/background/cron.js +0 -1
  13. package/cjs/koni/background/handlers/Extension.js +216 -158
  14. package/cjs/koni/background/handlers/State.js +59 -54
  15. package/cjs/koni/background/handlers/Tabs.js +39 -34
  16. package/cjs/packageInfo.js +1 -1
  17. package/cjs/page/index.js +7 -0
  18. package/cjs/page/substrate/PostMessageProvider.js +3 -0
  19. package/cjs/services/balance-service/helpers/subscribe/cardano/utils.js +0 -1
  20. package/cjs/services/balance-service/helpers/subscribe/substrate/gear.js +0 -2
  21. package/cjs/services/balance-service/helpers/subscribe/substrate/index.js +2 -3
  22. package/cjs/services/balance-service/helpers/subscribe/ton/utils.js +0 -3
  23. package/cjs/services/balance-service/index.js +103 -7
  24. package/cjs/services/balance-service/transfer/bitcoin-transfer.js +0 -1
  25. package/cjs/services/balance-service/transfer/cardano-transfer.js +1 -2
  26. package/cjs/services/balance-service/transfer/smart-contract.js +0 -1
  27. package/cjs/services/balance-service/transfer/token.js +0 -2
  28. package/cjs/services/balance-service/transfer/ton-transfer.js +0 -1
  29. package/cjs/services/balance-service/transfer/xcm/snowBridge.js +0 -1
  30. package/cjs/services/chain-service/constants.js +15 -4
  31. package/cjs/services/chain-service/handler/CardanoApi.js +3 -1
  32. package/cjs/services/chain-service/handler/SubstrateApi.js +0 -2
  33. package/cjs/services/chain-service/handler/light-client/index.js +1 -2
  34. package/cjs/services/chain-service/health-check/index.js +0 -1
  35. package/cjs/services/chain-service/health-check/utils/new-utils/chain-asset-validate.js +0 -1
  36. package/cjs/services/chain-service/index.js +18 -26
  37. package/cjs/services/chain-service/utils/index.js +34 -30
  38. package/cjs/services/earning-service/handlers/base.js +32 -0
  39. package/cjs/services/earning-service/handlers/lending/base.js +0 -2
  40. package/cjs/services/earning-service/handlers/liquid-staking/acala.js +0 -1
  41. package/cjs/services/earning-service/handlers/liquid-staking/base.js +0 -2
  42. package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +0 -2
  43. package/cjs/services/earning-service/handlers/liquid-staking/parallel.js +0 -1
  44. package/cjs/services/earning-service/handlers/native-staking/astar.js +0 -2
  45. package/cjs/services/earning-service/handlers/native-staking/dtao.js +43 -2
  46. package/cjs/services/earning-service/handlers/native-staking/energy.js +0 -1
  47. package/cjs/services/earning-service/handlers/native-staking/mythos.js +0 -2
  48. package/cjs/services/earning-service/handlers/native-staking/para-chain.js +0 -2
  49. package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +8 -9
  50. package/cjs/services/earning-service/handlers/special.js +7 -0
  51. package/cjs/services/event-service/index.js +1 -0
  52. package/cjs/services/history-service/subsquid-multi-chain-history.js +0 -1
  53. package/cjs/services/keyring-service/context/handlers/Derive.js +1 -1
  54. package/cjs/services/keyring-service/context/handlers/Migration.js +11 -9
  55. package/cjs/services/keyring-service/context/handlers/Mnemonic.js +18 -13
  56. package/cjs/services/keyring-service/context/state.js +21 -3
  57. package/cjs/services/keyring-service/utils.js +12 -2
  58. package/cjs/services/migration-service/index.js +1 -2
  59. package/cjs/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -1
  60. package/cjs/services/nft-service/index.js +5 -0
  61. package/cjs/services/open-gov/handler.js +561 -0
  62. package/cjs/services/open-gov/index.js +273 -0
  63. package/cjs/services/open-gov/interface.js +31 -0
  64. package/cjs/services/open-gov/utils.js +66 -0
  65. package/cjs/services/request-service/handler/BitcoinRequestHandler.js +1 -2
  66. package/cjs/services/request-service/handler/CardanoRequestHandler.js +0 -1
  67. package/cjs/services/request-service/handler/EvmRequestHandler.js +0 -1
  68. package/cjs/services/request-service/handler/TonRequestHandler.js +0 -1
  69. package/cjs/services/request-service/helper/index.js +1 -2
  70. package/cjs/services/storage-service/DatabaseService.js +19 -3
  71. package/cjs/services/storage-service/databases/index.js +5 -0
  72. package/cjs/services/storage-service/db-stores/GovLockedInfoStore.js +35 -0
  73. package/cjs/services/swap-service/handler/asset-hub/handler.js +0 -1
  74. package/cjs/services/swap-service/handler/asset-hub/router.js +0 -1
  75. package/cjs/services/swap-service/handler/chainflip-handler.js +1 -4
  76. package/cjs/services/swap-service/handler/hydradx-handler.js +0 -1
  77. package/cjs/services/swap-service/handler/kyber-handler.js +0 -1
  78. package/cjs/services/swap-service/handler/optimex-handler.js +1 -2
  79. package/cjs/services/swap-service/handler/simpleswap-handler.js +1 -3
  80. package/cjs/services/swap-service/handler/uniswap-handler.js +0 -3
  81. package/cjs/services/transaction-service/event-parser/index.js +6 -6
  82. package/cjs/services/transaction-service/helpers/index.js +6 -0
  83. package/cjs/services/transaction-service/index.js +71 -28
  84. package/cjs/services/wallet-connect-service/index.js +21 -18
  85. package/cjs/services/wallet-connect-service/types.js +1 -1
  86. package/cjs/types/account/info/keyring.js +9 -1
  87. package/cjs/types/balance/index.js +5 -1
  88. package/cjs/types/swap/index.js +2 -1
  89. package/cjs/types/transaction/process.js +2 -0
  90. package/cjs/types/yield/actions/join/step.js +17 -1
  91. package/cjs/utils/account/common.js +0 -26
  92. package/cjs/utils/account/derive/info/solo.js +7 -4
  93. package/cjs/utils/account/derive/validate.js +1 -1
  94. package/cjs/utils/account/transform.js +10 -5
  95. package/cjs/utils/auth.js +1 -1
  96. package/cjs/utils/bitcoin/utxo-management.js +0 -1
  97. package/cjs/utils/environment.js +2 -1
  98. package/cjs/utils/fee/transfer.js +1 -2
  99. package/cjs/utils/index.js +1 -2
  100. package/constants/blocked-actions.js +3 -0
  101. package/core/logic-validation/swap.js +0 -3
  102. package/core/substrate/system-pallet.js +0 -2
  103. package/koni/api/nft/wasm_nft/index.js +0 -1
  104. package/koni/api/staking/bonding/astar.js +0 -2
  105. package/koni/api/staking/bonding/paraChain.js +0 -3
  106. package/koni/api/staking/bonding/relayChain.js +2 -4
  107. package/koni/api/staking/bonding/utils.js +0 -4
  108. package/koni/background/cron.js +0 -1
  109. package/koni/background/handlers/Extension.d.ts +4 -0
  110. package/koni/background/handlers/Extension.js +70 -11
  111. package/koni/background/handlers/State.d.ts +2 -0
  112. package/koni/background/handlers/State.js +46 -40
  113. package/koni/background/handlers/Tabs.js +9 -3
  114. package/package.json +44 -20
  115. package/packageInfo.js +1 -1
  116. package/page/substrate/PostMessageProvider.js +3 -0
  117. package/services/balance-service/helpers/subscribe/cardano/utils.js +0 -1
  118. package/services/balance-service/helpers/subscribe/substrate/gear.js +0 -2
  119. package/services/balance-service/helpers/subscribe/substrate/index.js +0 -1
  120. package/services/balance-service/helpers/subscribe/ton/utils.js +0 -3
  121. package/services/balance-service/index.d.ts +8 -0
  122. package/services/balance-service/index.js +105 -9
  123. package/services/balance-service/transfer/bitcoin-transfer.js +0 -1
  124. package/services/balance-service/transfer/smart-contract.js +0 -1
  125. package/services/balance-service/transfer/token.js +0 -2
  126. package/services/balance-service/transfer/ton-transfer.js +0 -1
  127. package/services/balance-service/transfer/xcm/snowBridge.js +0 -1
  128. package/services/chain-service/constants.d.ts +8 -0
  129. package/services/chain-service/constants.js +12 -2
  130. package/services/chain-service/handler/CardanoApi.js +3 -1
  131. package/services/chain-service/handler/SubstrateApi.js +0 -2
  132. package/services/chain-service/health-check/index.js +0 -1
  133. package/services/chain-service/health-check/utils/new-utils/chain-asset-validate.js +0 -1
  134. package/services/chain-service/index.d.ts +0 -1
  135. package/services/chain-service/index.js +15 -23
  136. package/services/chain-service/utils/index.js +35 -31
  137. package/services/earning-service/handlers/base.js +32 -0
  138. package/services/earning-service/handlers/lending/base.js +0 -2
  139. package/services/earning-service/handlers/liquid-staking/acala.js +0 -1
  140. package/services/earning-service/handlers/liquid-staking/base.js +0 -2
  141. package/services/earning-service/handlers/liquid-staking/bifrost.js +0 -2
  142. package/services/earning-service/handlers/liquid-staking/parallel.js +0 -1
  143. package/services/earning-service/handlers/native-staking/astar.js +0 -2
  144. package/services/earning-service/handlers/native-staking/dtao.js +43 -0
  145. package/services/earning-service/handlers/native-staking/energy.js +0 -1
  146. package/services/earning-service/handlers/native-staking/mythos.js +0 -2
  147. package/services/earning-service/handlers/native-staking/para-chain.js +0 -2
  148. package/services/earning-service/handlers/native-staking/relay-chain.js +8 -9
  149. package/services/earning-service/handlers/special.js +7 -0
  150. package/services/event-service/index.d.ts +1 -0
  151. package/services/event-service/index.js +1 -0
  152. package/services/event-service/types.d.ts +1 -0
  153. package/services/history-service/subsquid-multi-chain-history.js +0 -1
  154. package/services/keyring-service/context/handlers/Derive.js +2 -2
  155. package/services/keyring-service/context/handlers/Migration.js +3 -1
  156. package/services/keyring-service/context/handlers/Mnemonic.d.ts +1 -1
  157. package/services/keyring-service/context/handlers/Mnemonic.js +16 -10
  158. package/services/keyring-service/context/state.d.ts +3 -0
  159. package/services/keyring-service/context/state.js +21 -3
  160. package/services/keyring-service/utils.d.ts +1 -0
  161. package/services/keyring-service/utils.js +9 -0
  162. package/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -1
  163. package/services/nft-service/index.js +6 -0
  164. package/services/open-gov/handler.d.ts +27 -0
  165. package/services/open-gov/handler.js +545 -0
  166. package/services/open-gov/index.d.ts +45 -0
  167. package/services/open-gov/index.js +265 -0
  168. package/services/open-gov/interface.d.ts +141 -0
  169. package/services/open-gov/interface.js +24 -0
  170. package/services/open-gov/utils.d.ts +14 -0
  171. package/services/open-gov/utils.js +52 -0
  172. package/services/request-service/handler/CardanoRequestHandler.js +0 -1
  173. package/services/request-service/handler/EvmRequestHandler.js +0 -1
  174. package/services/request-service/handler/TonRequestHandler.js +0 -1
  175. package/services/setting-service/constants.js +0 -1
  176. package/services/storage-service/DatabaseService.d.ts +7 -0
  177. package/services/storage-service/DatabaseService.js +19 -3
  178. package/services/storage-service/databases/index.d.ts +2 -0
  179. package/services/storage-service/databases/index.js +6 -0
  180. package/services/storage-service/db-stores/GovLockedInfoStore.d.ts +10 -0
  181. package/services/storage-service/db-stores/GovLockedInfoStore.js +27 -0
  182. package/services/swap-service/handler/asset-hub/handler.js +0 -1
  183. package/services/swap-service/handler/asset-hub/router.js +0 -1
  184. package/services/swap-service/handler/chainflip-handler.js +0 -2
  185. package/services/swap-service/handler/hydradx-handler.js +0 -1
  186. package/services/swap-service/handler/kyber-handler.js +0 -1
  187. package/services/swap-service/handler/simpleswap-handler.js +0 -1
  188. package/services/swap-service/handler/uniswap-handler.js +0 -3
  189. package/services/transaction-service/event-parser/index.js +6 -6
  190. package/services/transaction-service/helpers/index.js +6 -0
  191. package/services/transaction-service/index.js +43 -0
  192. package/services/wallet-connect-service/index.js +21 -18
  193. package/services/wallet-connect-service/types.js +1 -1
  194. package/types/account/action/add/mnemonic.d.ts +3 -2
  195. package/types/account/info/keyring.js +9 -1
  196. package/types/balance/index.js +5 -1
  197. package/types/swap/index.js +2 -1
  198. package/types/transaction/process.js +3 -1
  199. package/types/yield/actions/join/step.js +17 -1
  200. package/utils/account/common.d.ts +0 -3
  201. package/utils/account/common.js +0 -24
  202. package/utils/account/derive/info/solo.js +8 -5
  203. package/utils/account/derive/validate.d.ts +2 -2
  204. package/utils/account/derive/validate.js +1 -1
  205. package/utils/account/transform.js +10 -5
  206. package/utils/auth.js +2 -2
  207. package/utils/bitcoin/utxo-management.js +0 -1
  208. package/utils/index.js +2 -5
@@ -34,6 +34,7 @@ var _mintCampaignService = _interopRequireDefault(require("@subwallet/extension-
34
34
  var _mktCampaignService = _interopRequireDefault(require("@subwallet/extension-base/services/mkt-campaign-service"));
35
35
  var _nftService = _interopRequireDefault(require("@subwallet/extension-base/services/nft-service"));
36
36
  var _NotificationService = _interopRequireDefault(require("@subwallet/extension-base/services/notification-service/NotificationService"));
37
+ var _openGov = _interopRequireDefault(require("@subwallet/extension-base/services/open-gov"));
37
38
  var _priceService = require("@subwallet/extension-base/services/price-service");
38
39
  var _requestService = _interopRequireDefault(require("@subwallet/extension-base/services/request-service"));
39
40
  var _PopupHandler = require("@subwallet/extension-base/services/request-service/handler/PopupHandler");
@@ -59,8 +60,7 @@ var _util = require("@polkadot/util");
59
60
  var _utilCrypto = require("@polkadot/util-crypto");
60
61
  var _cron = require("../cron");
61
62
  var _subscription = require("../subscription");
62
- 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); }
63
- 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); }
64
64
  // Copyright 2019-2022 @subwallet/extension-koni authors & contributors
65
65
  // SPDX-License-Identifier: Apache-2.0
66
66
 
@@ -94,6 +94,9 @@ class KoniState {
94
94
  data: {}
95
95
  };
96
96
  lazyMap = {};
97
+
98
+ // TODO: consider making chainService public (or getter) and call function directly
99
+
97
100
  // Handle the general status of the extension
98
101
  generalStatus = _types.ServiceStatus.INITIALIZING;
99
102
  waitSleeping = null;
@@ -128,6 +131,7 @@ class KoniState {
128
131
  this.swapService = new _swapService.SwapService(this);
129
132
  this.inappNotificationService = new _inappNotificationService.InappNotificationService(this.dbService, this.keyringService, this.eventService, this.chainService);
130
133
  this.chainOnlineService = new _chainOnlineService.ChainOnlineService(this.chainService, this.settingService, this.eventService, this.dbService);
134
+ this.openGovService = new _openGov.default(this);
131
135
  this.subscription = new _subscription.KoniSubscription(this, this.dbService);
132
136
  this.cron = new _cron.KoniCron(this, this.subscription, this.dbService);
133
137
  this.logger = (0, _util.logger)('State');
@@ -232,6 +236,7 @@ class KoniState {
232
236
  await this.earningService.init();
233
237
  await this.swapService.init();
234
238
  await this.inappNotificationService.init();
239
+ await this.openGovService.init();
235
240
 
236
241
  // this.onReady();
237
242
  this.onAccountAdd();
@@ -758,7 +763,7 @@ class KoniState {
758
763
  async enableChainWithPriorityAssets(chainSlug) {
759
764
  let enableTokens = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
760
765
  if (enableTokens) {
761
- await this.chainService.updatePriorityAssetsByChain(chainSlug, true);
766
+ await this.balanceService.updatePriorityAssetsByChain(chainSlug, true);
762
767
  }
763
768
  return this.chainService.enableChain(chainSlug);
764
769
  }
@@ -1361,10 +1366,10 @@ class KoniState {
1361
1366
  const psbtGenerate = bitcoin.Psbt.fromHex(psbt, {
1362
1367
  network: network_
1363
1368
  });
1364
- const isExistedInput = (inputs, address) => inputs.findIndex(_ref10 => {
1369
+ const isExistedInput = (inputs, address) => inputs.findIndex(_ref0 => {
1365
1370
  let {
1366
1371
  address: address_
1367
- } = _ref10;
1372
+ } = _ref0;
1368
1373
  return (0, _utils3.isSameAddress)(address, address_ || '');
1369
1374
  });
1370
1375
  let to = '';
@@ -1372,11 +1377,11 @@ class KoniState {
1372
1377
  let value = new _bignumber.default(0);
1373
1378
  const totalBalance = await this.balanceService.getTotalBalance(address, result.networkKey, tokenInfo.slug);
1374
1379
  let inputAmount = new _bignumber.default(0);
1375
- const psbtInputData = psbtGenerate.data.inputs.reduce((inputs, _ref11, inputIndex) => {
1380
+ const psbtInputData = psbtGenerate.data.inputs.reduce((inputs, _ref1, inputIndex) => {
1376
1381
  let {
1377
1382
  nonWitnessUtxo,
1378
1383
  witnessUtxo
1379
- } = _ref11;
1384
+ } = _ref1;
1380
1385
  let inputData = null;
1381
1386
  if (witnessUtxo) {
1382
1387
  inputData = {
@@ -1434,11 +1439,11 @@ class KoniState {
1434
1439
  txInput: psbtInputData,
1435
1440
  txOutput: psbtOutputData
1436
1441
  };
1437
- return this.requestService.addConfirmationBitcoin(id, url, 'bitcoinSignPsbtRequest', payloadAfterValidated, {}).then(_ref12 => {
1442
+ return this.requestService.addConfirmationBitcoin(id, url, 'bitcoinSignPsbtRequest', payloadAfterValidated, {}).then(_ref10 => {
1438
1443
  let {
1439
1444
  isApproved,
1440
1445
  payload
1441
- } = _ref12;
1446
+ } = _ref10;
1442
1447
  if (isApproved) {
1443
1448
  if (payload) {
1444
1449
  return payload;
@@ -1470,11 +1475,11 @@ class KoniState {
1470
1475
  };
1471
1476
 
1472
1477
  // Custom handle this instead of general handler transaction
1473
- return this.requestService.addConfirmationBitcoin(id, url, 'bitcoinSendTransactionRequestAfterConfirmation', requestPayload, {}).then(_ref13 => {
1478
+ return this.requestService.addConfirmationBitcoin(id, url, 'bitcoinSendTransactionRequestAfterConfirmation', requestPayload, {}).then(_ref11 => {
1474
1479
  let {
1475
1480
  isApproved,
1476
1481
  payload
1477
- } = _ref13;
1482
+ } = _ref11;
1478
1483
  if (isApproved) {
1479
1484
  if (payload) {
1480
1485
  return payload;
@@ -1580,11 +1585,11 @@ class KoniState {
1580
1585
  const subscription = this.keyringService.context.observable.currentAccount.subscribe(handleRemind);
1581
1586
  }
1582
1587
  }
1583
- async setStorageFromWS(_ref14) {
1588
+ async setStorageFromWS(_ref12) {
1584
1589
  let {
1585
1590
  key,
1586
1591
  value
1587
- } = _ref14;
1592
+ } = _ref12;
1588
1593
  try {
1589
1594
  const jsonData = JSON.stringify(value);
1590
1595
  await _storage.SWStorage.instance.setItem(key, jsonData);
@@ -1687,7 +1692,7 @@ class KoniState {
1687
1692
  this.campaignService.stop();
1688
1693
  await Promise.all([this.cron.stop(), this.subscription.stop()]);
1689
1694
  await this.pauseAllNetworks(undefined, 'IDLE mode');
1690
- await Promise.all([this.historyService.stop(), this.priceService.stop(), this.balanceService.stop(), this.earningService.stop(), this.swapService.stop(), this.inappNotificationService.stop()]);
1695
+ await Promise.all([this.historyService.stop(), this.priceService.stop(), this.balanceService.stop(), this.earningService.stop(), this.swapService.stop(), this.inappNotificationService.stop(), this.openGovService.stop()]);
1691
1696
 
1692
1697
  // Complete sleeping
1693
1698
  sleeping.resolve();
@@ -1743,7 +1748,7 @@ class KoniState {
1743
1748
  this.generalStatus = _types.ServiceStatus.STARTING_FULL;
1744
1749
  const startingFull = (0, _promise.createPromiseHandler)();
1745
1750
  this.waitStartingFull = startingFull.promise;
1746
- await Promise.all([this.cron.start(), this.subscription.start(), this.historyService.start(), this.priceService.start(), this.balanceService.start(), this.earningService.start(), this.swapService.start(), this.inappNotificationService.start()]);
1751
+ await Promise.all([this.cron.start(), this.subscription.start(), this.historyService.start(), this.priceService.start(), this.balanceService.start(), this.earningService.start(), this.swapService.start(), this.inappNotificationService.start(), this.openGovService.start()]);
1747
1752
  this.eventService.emit('general.start_full', true);
1748
1753
  this.waitStartingFull = null;
1749
1754
  this.generalStatus = _types.ServiceStatus.STARTED_FULL;
@@ -1875,7 +1880,7 @@ class KoniState {
1875
1880
  });
1876
1881
  }
1877
1882
  async enableMantaPay(updateStore, address, password, seedPhrase) {
1878
- 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;
1879
1884
  if (!address || (0, _utilCrypto.isEthereumAddress)(address)) {
1880
1885
  return;
1881
1886
  }
@@ -1895,7 +1900,7 @@ class KoniState {
1895
1900
  data: encryptedData
1896
1901
  }));
1897
1902
  } else {
1898
- 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;
1899
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));
1900
1905
 
1901
1906
  // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
@@ -1903,18 +1908,18 @@ class KoniState {
1903
1908
 
1904
1909
  // eslint-disable-next-line @typescript-eslint/no-unsafe-argument,@typescript-eslint/no-unsafe-member-access
1905
1910
  const proofAuthKey = new Uint8Array(Object.values(decryptedData.proof_authorization_key));
1906
- 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({
1907
1912
  proof_authorization_key: proofAuthKey
1908
1913
  }));
1909
1914
  }
1910
- 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());
1911
1916
  if (updateStore) {
1912
- var _this$chainService12, _this$chainService12$, _this$chainService13, _this$chainService13$, _this$chainService13$2, _this$chainService13$3;
1913
- 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({
1914
1919
  address,
1915
1920
  zkAddress: zkAddress,
1916
1921
  enabled: true,
1917
- 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(),
1918
1923
  isInitialSync: false
1919
1924
  }));
1920
1925
  }
@@ -1922,48 +1927,48 @@ class KoniState {
1922
1927
  return zkAddress;
1923
1928
  }
1924
1929
  async disableMantaPay(address) {
1925
- 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$;
1926
- 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));
1927
1932
  if (!config) {
1928
1933
  return false;
1929
1934
  }
1930
- 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());
1931
- 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());
1932
1937
  // await this.chainService?.mantaPay?.privateWallet?.resetState();
1933
- 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));
1934
- 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));
1935
1940
  this.chainService.setMantaZkAssetSettings(false);
1936
1941
  this.isMantaPayEnabled = false;
1937
1942
  return true;
1938
1943
  }
1939
1944
  async initialSyncMantaPay(address) {
1940
- 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$;
1941
1946
  if (!address || (0, _utilCrypto.isEthereumAddress)(address)) {
1942
1947
  return;
1943
1948
  }
1944
- (_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);
1945
- 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());
1946
- 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());
1947
- 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, {
1948
1953
  isInitialSync: true
1949
1954
  }));
1950
1955
  this.eventService.emit('mantaPay.initSync', undefined);
1951
1956
  return syncResult;
1952
1957
  }
1953
1958
  getMantaZkBalance() {
1954
- var _this$chainService23, _this$chainService24, _this$chainService24$, _this$chainService24$2, _this$chainService25, _this$chainService25$, _this$chainService26, _this$chainService26$, _this$chainService26$2;
1955
- 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)) {
1956
1961
  return;
1957
1962
  }
1958
- 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)) {
1959
1964
  return;
1960
1965
  }
1961
- 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;
1962
1967
  if (!chain) {
1963
1968
  return;
1964
1969
  }
1965
1970
  const assetMap = this.chainService.getMantaZkAssets(chain === null || chain === void 0 ? void 0 : chain.toLowerCase());
1966
- (_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 => {
1967
1972
  const assetList = Object.values(assetMap);
1968
1973
  for (let i = 0; i < assetList.length; i++) {
1969
1974
  var _zkBalances$i;
@@ -1980,9 +1985,9 @@ class KoniState {
1980
1985
  }).catch(console.warn);
1981
1986
  }
1982
1987
  subscribeMantaPayBalance() {
1983
- var _this$chainService27, _this$chainService27$;
1988
+ var _this$chainService25, _this$chainService25$;
1984
1989
  let interval;
1985
- (_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 => {
1986
1991
  if (config && config.enabled && config.isInitialSync) {
1987
1992
  this.getMantaZkBalance();
1988
1993
  interval = setInterval(this.getMantaZkBalance, _constants.MANTA_PAY_BALANCE_INTERVAL);
@@ -1993,23 +1998,23 @@ class KoniState {
1993
1998
  };
1994
1999
  }
1995
2000
  async syncMantaPay() {
1996
- var _this$chainService28, _this$chainService28$, _this$chainService29, _this$chainService29$, _this$chainService29$2;
1997
- 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));
1998
2003
  if (!config.isInitialSync) {
1999
2004
  return;
2000
2005
  }
2001
- 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) {
2002
- var _this$chainService30, _this$chainService30$, _this$chainService30$2;
2003
- 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());
2004
2009
  } else {
2005
- var _this$chainService31, _this$chainService31$, _this$chainService31$2;
2006
- 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());
2007
2012
  }
2008
2013
  }
2009
2014
  async getMantaPayZkBalance(address, tokenInfo) {
2010
- var _this$chainService32, _this$chainService32$, _this$chainService32$2;
2015
+ var _this$chainService30, _this$chainService30$, _this$chainService30$2;
2011
2016
  const bnAssetId = new _bn.default((0, _utils._getTokenOnChainAssetId)(tokenInfo));
2012
- 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));
2013
2018
  return {
2014
2019
  decimals: tokenInfo.decimals || 0,
2015
2020
  symbol: tokenInfo.symbol,
@@ -2017,11 +2022,11 @@ class KoniState {
2017
2022
  };
2018
2023
  }
2019
2024
  subscribeMantaPaySyncState() {
2020
- var _this$chainService33, _this$chainService34, _this$chainService34$;
2021
- 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)) {
2022
2027
  return new _rxjs.Subject();
2023
2028
  }
2024
- 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();
2025
2030
  }
2026
2031
 
2027
2032
  /* Metadata */
@@ -2044,12 +2049,12 @@ class KoniState {
2044
2049
 
2045
2050
  /* Metadata */
2046
2051
 
2047
- getCrowdloanContributions(_ref15) {
2052
+ getCrowdloanContributions(_ref13) {
2048
2053
  let {
2049
2054
  address,
2050
2055
  page,
2051
2056
  relayChain
2052
- } = _ref15;
2057
+ } = _ref13;
2053
2058
  return this.subscanService.getCrowdloanContributions(relayChain, address, page);
2054
2059
  }
2055
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.69-0'
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 () => {