@subwallet/extension-base 1.3.8-0 → 1.3.10-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 (37) hide show
  1. package/background/KoniTypes.d.ts +4 -0
  2. package/cjs/core/logic-validation/transfer.js +35 -24
  3. package/cjs/core/substrate/system-pallet.js +1 -1
  4. package/cjs/core/utils.js +2 -2
  5. package/cjs/koni/background/handlers/Extension.js +116 -83
  6. package/cjs/packageInfo.js +1 -1
  7. package/cjs/services/balance-service/index.js +24 -2
  8. package/cjs/services/balance-service/transfer/smart-contract.js +16 -5
  9. package/cjs/services/chain-service/constants.js +5 -3
  10. package/cjs/services/chain-service/health-check/utils/new-utils/asset-asset-validate.js +1 -1
  11. package/cjs/services/swap-service/handler/asset-hub/utils.js +1 -0
  12. package/cjs/types/transaction/error.js +1 -0
  13. package/core/logic-validation/transfer.d.ts +2 -1
  14. package/core/logic-validation/transfer.js +36 -25
  15. package/core/substrate/system-pallet.js +1 -1
  16. package/core/types.d.ts +1 -0
  17. package/core/utils.js +2 -2
  18. package/koni/api/staking/bonding/utils.d.ts +1 -0
  19. package/koni/background/handlers/Extension.d.ts +2 -0
  20. package/koni/background/handlers/Extension.js +50 -18
  21. package/package.json +17 -17
  22. package/packageInfo.js +1 -1
  23. package/services/balance-service/index.d.ts +3 -0
  24. package/services/balance-service/index.js +21 -2
  25. package/services/balance-service/transfer/smart-contract.js +16 -5
  26. package/services/chain-service/constants.d.ts +1 -0
  27. package/services/chain-service/constants.js +3 -2
  28. package/services/chain-service/health-check/utils/new-utils/asset-asset-validate.js +1 -1
  29. package/services/earning-service/handlers/native-staking/relay-chain.d.ts +1 -0
  30. package/services/earning-service/handlers/special.d.ts +1 -0
  31. package/services/earning-service/utils/index.d.ts +1 -0
  32. package/services/swap-service/handler/asset-hub/utils.js +1 -0
  33. package/types/balance/index.d.ts +1 -0
  34. package/types/transaction/error.d.ts +2 -1
  35. package/types/transaction/error.js +1 -0
  36. package/types/yield/info/pallet.d.ts +1 -0
  37. package/utils/index.d.ts +1 -0
@@ -471,6 +471,10 @@ export interface BasicTokenInfo {
471
471
  decimals: number;
472
472
  symbol: string;
473
473
  }
474
+ export interface SufficientMetadata {
475
+ isSufficient: boolean;
476
+ minBalance: number;
477
+ }
474
478
  export interface AmountData extends BasicTokenInfo {
475
479
  value: string;
476
480
  metadata?: unknown;
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.additionalValidateTransfer = additionalValidateTransfer;
7
+ exports.additionalValidateTransferForRecipient = additionalValidateTransferForRecipient;
8
8
  exports.additionalValidateXcmTransfer = additionalValidateXcmTransfer;
9
9
  exports.checkBalanceWithTransactionFee = checkBalanceWithTransactionFee;
10
10
  exports.checkSigningAccountForTransaction = checkSigningAccountForTransaction;
@@ -59,44 +59,55 @@ function validateTransferRequest(tokenInfo, from, to, value, transferAll) {
59
59
  }
60
60
  return [errors, keypair, transferValue];
61
61
  }
62
- function additionalValidateTransfer(tokenInfo, nativeTokenInfo, extrinsicType, receiverTransferTokenFreeBalance, transferAmount, senderTransferTokenTransferable, receiverNativeTransferable) {
63
- const minAmount = (0, _utils2._getTokenMinAmount)(tokenInfo);
64
- const nativeMinAmount = (0, _utils2._getTokenMinAmount)(nativeTokenInfo);
62
+ function additionalValidateTransferForRecipient(sendingTokenInfo, nativeTokenInfo, extrinsicType, receiverSendingTokenKeepAliveBalance, transferAmount, senderSendingTokenTransferable, receiverSystemAccountInfo, isSendingTokenSufficient) {
63
+ const sendingTokenMinAmount = BigInt((0, _utils2._getTokenMinAmount)(sendingTokenInfo));
64
+ const nativeTokenMinAmount = (0, _utils2._getTokenMinAmount)(nativeTokenInfo);
65
65
  const warnings = [];
66
66
  const errors = [];
67
-
68
- // Check ed of not native token for sender after sending
69
- if (extrinsicType === _KoniTypes.ExtrinsicType.TRANSFER_TOKEN && senderTransferTokenTransferable) {
70
- if (new _bignumber.default(senderTransferTokenTransferable).minus(transferAmount).lt(minAmount)) {
67
+ const remainingSendingTokenOfSenderEnoughED = senderSendingTokenTransferable ? senderSendingTokenTransferable - transferAmount >= sendingTokenMinAmount : false;
68
+ const isReceiverAliveByNativeToken = receiverSystemAccountInfo ? (0, _systemPallet._isAccountActive)(receiverSystemAccountInfo) : false;
69
+ const isReceivingAmountPassED = receiverSendingTokenKeepAliveBalance + transferAmount >= sendingTokenMinAmount;
70
+ if (extrinsicType === _KoniTypes.ExtrinsicType.TRANSFER_TOKEN) {
71
+ if (!remainingSendingTokenOfSenderEnoughED) {
71
72
  const warning = new _TransactionWarning.TransactionWarning(_types.BasicTxWarningCode.NOT_ENOUGH_EXISTENTIAL_DEPOSIT);
72
73
  warnings.push(warning);
73
74
  }
74
- }
75
-
76
- // Check ed for receiver before sending
77
- if (extrinsicType === _KoniTypes.ExtrinsicType.TRANSFER_TOKEN && receiverNativeTransferable) {
78
- if (new _bignumber.default(receiverNativeTransferable).lt(nativeMinAmount)) {
79
- const error = new _TransactionError.TransactionError(_types.TransferTxErrorType.RECEIVER_NOT_ENOUGH_EXISTENTIAL_DEPOSIT, (0, _i18next.t)('The recipient account has {{amount}} {{nativeSymbol}} which can lead to your {{localSymbol}} being lost. Change recipient account and try again', {
75
+ if (!isReceiverAliveByNativeToken && !isSendingTokenSufficient) {
76
+ const balanceKeepAlive = (0, _utils4.formatNumber)(nativeTokenMinAmount, (0, _utils2._getAssetDecimals)(nativeTokenInfo), _utils4.balanceFormatter, {
77
+ maxNumberFormat: (0, _utils2._getAssetDecimals)(nativeTokenInfo) || 6
78
+ });
79
+ const error = new _TransactionError.TransactionError(_types.TransferTxErrorType.RECEIVER_NOT_ENOUGH_EXISTENTIAL_DEPOSIT, (0, _i18next.t)('The recipient account has less than {{amount}} {{nativeSymbol}}, which can lead to your {{localSymbol}} being lost. Change recipient account and try again', {
80
80
  replace: {
81
- amount: receiverNativeTransferable,
81
+ amount: balanceKeepAlive,
82
82
  nativeSymbol: nativeTokenInfo.symbol,
83
- localSymbol: tokenInfo.symbol
83
+ localSymbol: sendingTokenInfo.symbol
84
+ }
85
+ }));
86
+ errors.push(error);
87
+ }
88
+ if (!isReceivingAmountPassED) {
89
+ const atLeast = sendingTokenMinAmount - receiverSendingTokenKeepAliveBalance;
90
+ const atLeastStr = (0, _utils4.formatNumber)(atLeast.toString(), (0, _utils2._getAssetDecimals)(sendingTokenInfo), _utils4.balanceFormatter, {
91
+ maxNumberFormat: (0, _utils2._getAssetDecimals)(sendingTokenInfo) || 6
92
+ });
93
+ const error = new _TransactionError.TransactionError(_types.TransferTxErrorType.RECEIVER_NOT_ENOUGH_EXISTENTIAL_DEPOSIT, (0, _i18next.t)('You must transfer at least {{amount}} {{symbol}} to avoid losing funds on the recipient account. Increase amount and try again', {
94
+ replace: {
95
+ amount: atLeastStr,
96
+ symbol: sendingTokenInfo.symbol
84
97
  }
85
98
  }));
86
99
  errors.push(error);
87
100
  }
88
101
  }
89
-
90
- // Check ed for receiver after sending
91
- if (new _bignumber.default(receiverTransferTokenFreeBalance).plus(transferAmount).lt(minAmount)) {
92
- const atLeast = new _bignumber.default(minAmount).minus(receiverTransferTokenFreeBalance).plus((tokenInfo.decimals || 0) === 0 ? 0 : 1);
93
- const atLeastStr = (0, _utils4.formatNumber)(atLeast, tokenInfo.decimals || 0, _utils4.balanceFormatter, {
94
- maxNumberFormat: tokenInfo.decimals || 6
102
+ if (!isReceivingAmountPassED) {
103
+ const atLeast = sendingTokenMinAmount - receiverSendingTokenKeepAliveBalance;
104
+ const atLeastStr = (0, _utils4.formatNumber)(atLeast.toString(), (0, _utils2._getAssetDecimals)(sendingTokenInfo), _utils4.balanceFormatter, {
105
+ maxNumberFormat: (0, _utils2._getAssetDecimals)(sendingTokenInfo) || 6
95
106
  });
96
- const error = new _TransactionError.TransactionError(_types.TransferTxErrorType.RECEIVER_NOT_ENOUGH_EXISTENTIAL_DEPOSIT, (0, _i18next.t)('You must transfer at least {{amount}} {{symbol}} to keep the destination account alive', {
107
+ const error = new _TransactionError.TransactionError(_types.TransferTxErrorType.RECEIVER_NOT_ENOUGH_EXISTENTIAL_DEPOSIT, (0, _i18next.t)('You must transfer at least {{amount}} {{symbol}} to keep the recipient account alive. Increase amount and try again', {
97
108
  replace: {
98
109
  amount: atLeastStr,
99
- symbol: tokenInfo.symbol
110
+ symbol: sendingTokenInfo.symbol
100
111
  }
101
112
  }));
102
113
  errors.push(error);
@@ -30,7 +30,7 @@ function _canAccountBeReaped(accountInfo) {
30
30
  }
31
31
 
32
32
  function _isAccountActive(accountInfo) {
33
- return accountInfo.providers === 0 && accountInfo.consumers === 0;
33
+ return !(accountInfo.consumers === 0 && accountInfo.providers === 0 && accountInfo.sufficients === 0);
34
34
  }
35
35
  function _getSystemPalletTotalBalance(accountInfo) {
36
36
  if (isV1(accountInfo)) {
package/cjs/core/utils.js CHANGED
@@ -15,7 +15,6 @@ exports.getMaxBigInt = getMaxBigInt;
15
15
  exports.getStrictMode = getStrictMode;
16
16
  exports.ledgerMustCheckNetwork = ledgerMustCheckNetwork;
17
17
  var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
18
- var _consts = require("@subwallet/extension-base/core/consts");
19
18
  var _types = require("@subwallet/extension-base/core/substrate/types");
20
19
  var _utils = require("@subwallet/extension-base/services/balance-service/helpers/subscribe/ton/utils");
21
20
  var _utils2 = require("@subwallet/extension-base/services/chain-service/utils");
@@ -115,6 +114,7 @@ function _isNotDuplicateAddress(validateRecipientParams) {
115
114
  function _isSupportLedgerAccount(validateRecipientParams) {
116
115
  const {
117
116
  account,
117
+ allowLedgerGenerics,
118
118
  destChainInfo
119
119
  } = validateRecipientParams;
120
120
  if (account !== null && account !== void 0 && account.isHardware) {
@@ -129,7 +129,7 @@ function _isSupportLedgerAccount(validateRecipientParams) {
129
129
  } else {
130
130
  // For ledger generic
131
131
  const ledgerCheck = ledgerMustCheckNetwork(account);
132
- if (ledgerCheck !== 'unnecessary' && !_consts.LEDGER_GENERIC_ALLOW_NETWORKS.includes(destChainInfo.slug)) {
132
+ if (ledgerCheck !== 'unnecessary' && !allowLedgerGenerics.includes(destChainInfo.slug)) {
133
133
  return `Ledger ${ledgerCheck === 'polkadot' ? 'Polkadot' : 'Migration'} address is not supported for this transfer`;
134
134
  }
135
135
  }
@@ -39,7 +39,6 @@ var _types2 = require("@subwallet/extension-base/services/chain-service/types");
39
39
  var _utils4 = require("@subwallet/extension-base/services/chain-service/utils");
40
40
  var _constants3 = require("@subwallet/extension-base/services/request-service/constants");
41
41
  var _constants4 = require("@subwallet/extension-base/services/setting-service/constants");
42
- var _constants5 = require("@subwallet/extension-base/services/wallet-connect-service/constants");
43
42
  var _helpers2 = require("@subwallet/extension-base/services/wallet-connect-service/helpers");
44
43
  var _storage = require("@subwallet/extension-base/storage");
45
44
  var _stores = require("@subwallet/extension-base/stores");
@@ -1219,35 +1218,41 @@ class KoniExtension {
1219
1218
  }
1220
1219
  const transferNativeAmount = isTransferNativeToken ? transferAmount.value : '0';
1221
1220
  const additionalValidator = async inputTransaction => {
1222
- let senderTransferTokenTransferable;
1223
- let receiverNativeTransferable;
1221
+ let senderSendingTokenTransferable;
1222
+ let receiverSystemAccountInfo;
1223
+ if (!(0, _utils4._isChainSubstrateCompatible)(chainInfo)) {
1224
+ return undefined;
1225
+ }
1224
1226
 
1225
1227
  // Check ed for sender
1226
1228
  if (!isTransferNativeToken) {
1227
- const [_senderTransferTokenTransferable, _receiverNativeTransferable] = await Promise.all([this.getAddressTransferableBalance({
1229
+ const [_senderSendingTokenTransferable, _receiverNativeTotal] = await Promise.all([this.getAddressTransferableBalance({
1228
1230
  address: from,
1229
1231
  networkKey,
1230
1232
  token: tokenSlug,
1231
1233
  extrinsicType
1232
- }), this.getAddressTransferableBalance({
1234
+ }), this.getAddressTotalBalance({
1233
1235
  address: to,
1234
1236
  networkKey,
1235
1237
  token: nativeTokenSlug,
1236
1238
  extrinsicType: _KoniTypes.ExtrinsicType.TRANSFER_BALANCE
1237
1239
  })]);
1238
- senderTransferTokenTransferable = _senderTransferTokenTransferable.value;
1239
- receiverNativeTransferable = _receiverNativeTransferable.value;
1240
+ senderSendingTokenTransferable = BigInt(_senderSendingTokenTransferable.value);
1241
+ receiverSystemAccountInfo = _receiverNativeTotal.metadata;
1240
1242
  }
1241
1243
  const {
1242
- value: receiverTransferTokenTransferable
1243
- } = await this.getAddressTransferableBalance({
1244
+ value: _receiverSendingTokenKeepAliveBalance
1245
+ } = await this.getAddressTotalBalance({
1244
1246
  address: to,
1245
1247
  networkKey,
1246
1248
  token: tokenSlug,
1247
1249
  extrinsicType
1248
1250
  }); // todo: shouldn't be just transferable, locked also counts
1249
-
1250
- const [warnings, errors] = (0, _transfer.additionalValidateTransfer)(transferTokenInfo, nativeTokenInfo, extrinsicType, receiverTransferTokenTransferable, transferAmount.value, senderTransferTokenTransferable, receiverNativeTransferable);
1251
+ const receiverSendingTokenKeepAliveBalance = BigInt(_receiverSendingTokenKeepAliveBalance);
1252
+ const amount = BigInt(transferAmount.value);
1253
+ const substrateApi = this.#koniState.getSubstrateApi(networkKey);
1254
+ const isSendingTokenSufficient = await this.isSufficientToken(transferTokenInfo, substrateApi);
1255
+ const [warnings, errors] = (0, _transfer.additionalValidateTransferForRecipient)(transferTokenInfo, nativeTokenInfo, extrinsicType, receiverSendingTokenKeepAliveBalance, amount, senderSendingTokenTransferable, receiverSystemAccountInfo, isSendingTokenSufficient);
1251
1256
  warnings.length && inputTransaction.warnings.push(...warnings);
1252
1257
  errors.length && inputTransaction.errors.push(...errors);
1253
1258
  };
@@ -1508,6 +1513,25 @@ class KoniExtension {
1508
1513
  };
1509
1514
  }
1510
1515
  }
1516
+ async isSufficientToken(tokenInfo, substrateApi) {
1517
+ let metadata;
1518
+ if (_constants2.SUFFICIENT_CHAIN.includes(tokenInfo.originChain) && tokenInfo.assetType !== _types._AssetType.NATIVE) {
1519
+ const assetId = (0, _utils4._isBridgedToken)(tokenInfo) ? (0, _utils4._getXcmAssetMultilocation)(tokenInfo) : (0, _utils4._getTokenOnChainAssetId)(tokenInfo);
1520
+ const queryParams = {
1521
+ section: 'query',
1522
+ module: 'foreignAssets',
1523
+ method: 'asset',
1524
+ args: [assetId]
1525
+ };
1526
+ if (!(0, _utils4._isBridgedToken)(tokenInfo)) {
1527
+ queryParams.module = 'assets';
1528
+ }
1529
+ metadata = await substrateApi.makeRpcQuery(queryParams);
1530
+ } else {
1531
+ return false;
1532
+ }
1533
+ return metadata.isSufficient;
1534
+ }
1511
1535
  async deleteCustomAsset(assetSlug) {
1512
1536
  const assetInfo = this.#koniState.getAssetBySlug(assetSlug);
1513
1537
  if (assetInfo && (0, _utils4._isCustomAsset)(assetSlug)) {
@@ -1538,14 +1562,23 @@ class KoniExtension {
1538
1562
  }
1539
1563
  return await this.#koniState.balanceService.getTransferableBalance(address, networkKey, token, extrinsicType);
1540
1564
  }
1541
- async getMaxTransferable(_ref30) {
1565
+ async getAddressTotalBalance(_ref30) {
1566
+ let {
1567
+ address,
1568
+ extrinsicType,
1569
+ networkKey,
1570
+ token
1571
+ } = _ref30;
1572
+ return await this.#koniState.balanceService.getTotalBalance(address, networkKey, token, extrinsicType);
1573
+ }
1574
+ async getMaxTransferable(_ref31) {
1542
1575
  let {
1543
1576
  address,
1544
1577
  destChain,
1545
1578
  isXcmTransfer,
1546
1579
  networkKey,
1547
1580
  token
1548
- } = _ref30;
1581
+ } = _ref31;
1549
1582
  const tokenInfo = token ? this.#koniState.chainService.getAssetBySlug(token) : this.#koniState.chainService.getNativeTokenInfo(networkKey);
1550
1583
  if (!(0, _utils4._isNativeToken)(tokenInfo)) {
1551
1584
  return await this.getAddressTransferableBalance({
@@ -1603,13 +1636,13 @@ class KoniExtension {
1603
1636
  const bnMaxTransferable = new _bignumber.default(value);
1604
1637
  return bnMaxTransferable.minus(mockTxFee);
1605
1638
  }
1606
- async subscribeAddressTransferableBalance(_ref31, id, port) {
1639
+ async subscribeAddressTransferableBalance(_ref32, id, port) {
1607
1640
  let {
1608
1641
  address,
1609
1642
  extrinsicType,
1610
1643
  networkKey,
1611
1644
  token
1612
- } = _ref31;
1645
+ } = _ref32;
1613
1646
  const cb = (0, _subscriptions.createSubscription)(id, port);
1614
1647
  const convertData = data => {
1615
1648
  return {
@@ -1660,11 +1693,11 @@ class KoniExtension {
1660
1693
  isSendingSelf
1661
1694
  };
1662
1695
  }
1663
- async enableChains(_ref32) {
1696
+ async enableChains(_ref33) {
1664
1697
  let {
1665
1698
  chainSlugs,
1666
1699
  enableTokens
1667
- } = _ref32;
1700
+ } = _ref33;
1668
1701
  try {
1669
1702
  await Promise.all(chainSlugs.map(chainSlug => this.enableChain({
1670
1703
  chainSlug,
@@ -1785,30 +1818,30 @@ class KoniExtension {
1785
1818
 
1786
1819
  // Parse transaction
1787
1820
 
1788
- parseSubstrateTransaction(_ref33) {
1821
+ parseSubstrateTransaction(_ref34) {
1789
1822
  let {
1790
1823
  data,
1791
1824
  networkKey
1792
- } = _ref33;
1825
+ } = _ref34;
1793
1826
  const apiProps = this.#koniState.getSubstrateApi(networkKey);
1794
1827
  const apiPromise = apiProps.api;
1795
1828
  return (0, _parseTransaction.parseSubstrateTransaction)(data, apiPromise);
1796
1829
  }
1797
- async parseEVMRLP(_ref34) {
1830
+ async parseEVMRLP(_ref35) {
1798
1831
  let {
1799
1832
  data
1800
- } = _ref34;
1833
+ } = _ref35;
1801
1834
  return await (0, _parseTransaction2.parseEvmRlp)(data, this.#koniState.getChainInfoMap(), this.#koniState.getEvmApiMap());
1802
1835
  }
1803
1836
 
1804
1837
  // Sign
1805
1838
 
1806
- qrSignSubstrate(_ref35) {
1839
+ qrSignSubstrate(_ref36) {
1807
1840
  let {
1808
1841
  address,
1809
1842
  data,
1810
1843
  networkKey
1811
- } = _ref35;
1844
+ } = _ref36;
1812
1845
  const pair = _uiKeyring.keyring.getPair(address);
1813
1846
  (0, _util.assert)(pair, (0, _i18next.t)('Unable to find account'));
1814
1847
  if (pair.isLocked) {
@@ -1825,13 +1858,13 @@ class KoniExtension {
1825
1858
  signature: signed
1826
1859
  };
1827
1860
  }
1828
- async qrSignEVM(_ref36) {
1861
+ async qrSignEVM(_ref37) {
1829
1862
  let {
1830
1863
  address,
1831
1864
  chainId,
1832
1865
  message,
1833
1866
  type
1834
- } = _ref36;
1867
+ } = _ref37;
1835
1868
  let signed;
1836
1869
  const network = this.getNetworkJsonByChainId(chainId);
1837
1870
  if (!network) {
@@ -1915,11 +1948,11 @@ class KoniExtension {
1915
1948
  });
1916
1949
  return this.#koniState.getNominatorMetadata();
1917
1950
  }
1918
- async getBondingOptions(_ref37) {
1951
+ async getBondingOptions(_ref38) {
1919
1952
  let {
1920
1953
  chain,
1921
1954
  type
1922
- } = _ref37;
1955
+ } = _ref38;
1923
1956
  const apiProps = this.#koniState.getSubstrateApi(chain);
1924
1957
  const chainInfo = this.#koniState.getChainInfo(chain);
1925
1958
  const chainStakingMetadata = await this.#koniState.getStakingMetadataByChain(chain, type);
@@ -2109,12 +2142,12 @@ class KoniExtension {
2109
2142
  }
2110
2143
 
2111
2144
  // EVM Transaction
2112
- async parseContractInput(_ref38) {
2145
+ async parseContractInput(_ref39) {
2113
2146
  let {
2114
2147
  chainId,
2115
2148
  contract,
2116
2149
  data
2117
- } = _ref38;
2150
+ } = _ref39;
2118
2151
  const network = this.getNetworkJsonByChainId(chainId);
2119
2152
  return await (0, _parseTransaction2.parseContractInput)(data, contract, network);
2120
2153
  }
@@ -2214,10 +2247,10 @@ class KoniExtension {
2214
2247
 
2215
2248
  // Unlock wallet
2216
2249
 
2217
- keyringUnlock(_ref39) {
2250
+ keyringUnlock(_ref40) {
2218
2251
  let {
2219
2252
  password
2220
- } = _ref39;
2253
+ } = _ref40;
2221
2254
  try {
2222
2255
  _uiKeyring.keyring.unlockKeyring(password);
2223
2256
  // this.#koniState.initMantaPay(password)
@@ -2248,11 +2281,11 @@ class KoniExtension {
2248
2281
 
2249
2282
  // Export mnemonic
2250
2283
 
2251
- keyringExportMnemonic(_ref40) {
2284
+ keyringExportMnemonic(_ref41) {
2252
2285
  let {
2253
2286
  address,
2254
2287
  password
2255
- } = _ref40;
2288
+ } = _ref41;
2256
2289
  const pair = _uiKeyring.keyring.getPair(address);
2257
2290
  const result = pair.exportMnemonic(password);
2258
2291
  return {
@@ -2262,10 +2295,10 @@ class KoniExtension {
2262
2295
 
2263
2296
  // Reset wallet
2264
2297
 
2265
- async resetWallet(_ref41) {
2298
+ async resetWallet(_ref42) {
2266
2299
  let {
2267
2300
  resetAll
2268
- } = _ref41;
2301
+ } = _ref42;
2269
2302
  try {
2270
2303
  await this.#koniState.resetWallet(resetAll);
2271
2304
  return {
@@ -2281,10 +2314,10 @@ class KoniExtension {
2281
2314
  }
2282
2315
 
2283
2316
  /// Signing substrate request
2284
- async signingApprovePasswordV2(_ref42) {
2317
+ async signingApprovePasswordV2(_ref43) {
2285
2318
  let {
2286
2319
  id
2287
- } = _ref42;
2320
+ } = _ref43;
2288
2321
  const queued = this.#koniState.getSignRequest(id);
2289
2322
  (0, _util.assert)(queued, (0, _i18next.t)('Unable to proceed. Please try again'));
2290
2323
  const {
@@ -2490,10 +2523,10 @@ class KoniExtension {
2490
2523
  getSupportedSmartContractTypes() {
2491
2524
  return this.#koniState.getSupportedSmartContractTypes();
2492
2525
  }
2493
- getTransaction(_ref43) {
2526
+ getTransaction(_ref44) {
2494
2527
  let {
2495
2528
  id
2496
- } = _ref43;
2529
+ } = _ref44;
2497
2530
  const {
2498
2531
  transaction,
2499
2532
  ...transactionResult
@@ -2503,8 +2536,8 @@ class KoniExtension {
2503
2536
  subscribeTransactions(id, port) {
2504
2537
  const cb = (0, _subscriptions.createSubscription)(id, port);
2505
2538
  function convertRs(rs) {
2506
- return Object.fromEntries(Object.entries(rs).map(_ref44 => {
2507
- let [key, value] = _ref44;
2539
+ return Object.fromEntries(Object.entries(rs).map(_ref45 => {
2540
+ let [key, value] = _ref45;
2508
2541
  const {
2509
2542
  additionalValidator,
2510
2543
  eventsHandler,
@@ -2536,10 +2569,10 @@ class KoniExtension {
2536
2569
  });
2537
2570
  return notificationSubject.value;
2538
2571
  }
2539
- async reloadCron(_ref45) {
2572
+ async reloadCron(_ref46) {
2540
2573
  let {
2541
2574
  data
2542
- } = _ref45;
2575
+ } = _ref46;
2543
2576
  if (data === 'nft') {
2544
2577
  return await this.#koniState.reloadNft();
2545
2578
  } else if (data === 'staking') {
@@ -2582,10 +2615,10 @@ class KoniExtension {
2582
2615
  }
2583
2616
 
2584
2617
  // Phishing detect
2585
- async passPhishingPage(_ref46) {
2618
+ async passPhishingPage(_ref47) {
2586
2619
  let {
2587
2620
  url
2588
- } = _ref46;
2621
+ } = _ref47;
2589
2622
  return await this.#koniState.approvePassPhishingPage(url);
2590
2623
  }
2591
2624
 
@@ -2606,10 +2639,10 @@ class KoniExtension {
2606
2639
  /// Wallet connect
2607
2640
 
2608
2641
  // Connect
2609
- async connectWalletConnect(_ref47) {
2642
+ async connectWalletConnect(_ref48) {
2610
2643
  let {
2611
2644
  uri
2612
- } = _ref47;
2645
+ } = _ref48;
2613
2646
  await this.#koniState.walletConnectService.connect(uri);
2614
2647
  return true;
2615
2648
  }
@@ -2622,11 +2655,11 @@ class KoniExtension {
2622
2655
  });
2623
2656
  return this.#koniState.requestService.allConnectWCRequests;
2624
2657
  }
2625
- async approveWalletConnectSession(_ref48) {
2658
+ async approveWalletConnectSession(_ref49) {
2626
2659
  let {
2627
2660
  accounts: selectedAccounts,
2628
2661
  id
2629
- } = _ref48;
2662
+ } = _ref49;
2630
2663
  const request = this.#koniState.requestService.getConnectWCRequest(id);
2631
2664
  if ((0, _helpers2.isProposalExpired)(request.request.params)) {
2632
2665
  throw new Error('The proposal has been expired');
@@ -2638,8 +2671,8 @@ class KoniExtension {
2638
2671
  const availableNamespaces = {};
2639
2672
  const namespaces = {};
2640
2673
  const chainInfoMap = this.#koniState.getChainInfoMap();
2641
- Object.entries(requiredNamespaces).forEach(_ref49 => {
2642
- let [key, namespace] = _ref49;
2674
+ Object.entries(requiredNamespaces).forEach(_ref50 => {
2675
+ let [key, namespace] = _ref50;
2643
2676
  if ((0, _helpers2.isSupportWalletConnectNamespace)(key)) {
2644
2677
  if (namespace.chains) {
2645
2678
  const unSupportChains = namespace.chains.filter(chain => !(0, _helpers2.isSupportWalletConnectChain)(chain, chainInfoMap));
@@ -2652,8 +2685,8 @@ class KoniExtension {
2652
2685
  throw new Error((0, _utils6.getSdkError)('UNSUPPORTED_NAMESPACE_KEY').message + ' ' + key);
2653
2686
  }
2654
2687
  });
2655
- Object.entries(optionalNamespaces).forEach(_ref50 => {
2656
- let [key, namespace] = _ref50;
2688
+ Object.entries(optionalNamespaces).forEach(_ref51 => {
2689
+ let [key, namespace] = _ref51;
2657
2690
  if ((0, _helpers2.isSupportWalletConnectNamespace)(key)) {
2658
2691
  if (namespace.chains) {
2659
2692
  const supportChains = namespace.chains.filter(chain => (0, _helpers2.isSupportWalletConnectChain)(chain, chainInfoMap)) || [];
@@ -2677,14 +2710,14 @@ class KoniExtension {
2677
2710
  }
2678
2711
  }
2679
2712
  });
2680
- Object.entries(availableNamespaces).forEach(_ref51 => {
2681
- let [key, namespace] = _ref51;
2713
+ Object.entries(availableNamespaces).forEach(_ref52 => {
2714
+ let [key, namespace] = _ref52;
2682
2715
  if (namespace.chains) {
2683
- const accounts = [];
2684
- const chains = (0, _utils5.uniqueStringArray)(namespace.chains);
2685
- chains.forEach(chain => {
2686
- accounts.push(...selectedAccounts.filter(address => (0, _utilCrypto.isEthereumAddress)(address) === (key === _constants5.WALLET_CONNECT_EIP155_NAMESPACE)).map(address => `${chain}:${address}`));
2716
+ const accounts = selectedAccounts.filter(address => {
2717
+ const [_namespace] = address.split(':');
2718
+ return _namespace === key;
2687
2719
  });
2720
+ const chains = (0, _utils5.uniqueStringArray)(namespace.chains);
2688
2721
  namespaces[key] = {
2689
2722
  accounts,
2690
2723
  methods: namespace.methods,
@@ -2702,10 +2735,10 @@ class KoniExtension {
2702
2735
  request.resolve();
2703
2736
  return true;
2704
2737
  }
2705
- async rejectWalletConnectSession(_ref52) {
2738
+ async rejectWalletConnectSession(_ref53) {
2706
2739
  let {
2707
2740
  id
2708
- } = _ref52;
2741
+ } = _ref53;
2709
2742
  const request = this.#koniState.requestService.getConnectWCRequest(id);
2710
2743
  const wcId = request.request.id;
2711
2744
  if ((0, _helpers2.isProposalExpired)(request.request.params)) {
@@ -2727,10 +2760,10 @@ class KoniExtension {
2727
2760
  });
2728
2761
  return this.#koniState.walletConnectService.sessions;
2729
2762
  }
2730
- async disconnectWalletConnectSession(_ref53) {
2763
+ async disconnectWalletConnectSession(_ref54) {
2731
2764
  let {
2732
2765
  topic
2733
- } = _ref53;
2766
+ } = _ref54;
2734
2767
  await this.#koniState.walletConnectService.disconnect(topic);
2735
2768
  return true;
2736
2769
  }
@@ -2743,18 +2776,18 @@ class KoniExtension {
2743
2776
  });
2744
2777
  return this.#koniState.requestService.allNotSupportWCRequests;
2745
2778
  }
2746
- approveWalletConnectNotSupport(_ref54) {
2779
+ approveWalletConnectNotSupport(_ref55) {
2747
2780
  let {
2748
2781
  id
2749
- } = _ref54;
2782
+ } = _ref55;
2750
2783
  const request = this.#koniState.requestService.getNotSupportWCRequest(id);
2751
2784
  request.resolve();
2752
2785
  return true;
2753
2786
  }
2754
- rejectWalletConnectNotSupport(_ref55) {
2787
+ rejectWalletConnectNotSupport(_ref56) {
2755
2788
  let {
2756
2789
  id
2757
- } = _ref55;
2790
+ } = _ref56;
2758
2791
  const request = this.#koniState.requestService.getNotSupportWCRequest(id);
2759
2792
  request.reject(new Error('USER_REJECTED'));
2760
2793
  return true;
@@ -2762,11 +2795,11 @@ class KoniExtension {
2762
2795
 
2763
2796
  /// Manta
2764
2797
 
2765
- async enableMantaPay(_ref56) {
2798
+ async enableMantaPay(_ref57) {
2766
2799
  let {
2767
2800
  address,
2768
2801
  password
2769
- } = _ref56;
2802
+ } = _ref57;
2770
2803
  // always takes the current account
2771
2804
  function timeout() {
2772
2805
  return new Promise(resolve => setTimeout(resolve, 1500));
@@ -2856,11 +2889,11 @@ class KoniExtension {
2856
2889
  async disableMantaPay(address) {
2857
2890
  return this.#koniState.disableMantaPay(address);
2858
2891
  }
2859
- async isTonBounceableAddress(_ref57) {
2892
+ async isTonBounceableAddress(_ref58) {
2860
2893
  let {
2861
2894
  address,
2862
2895
  chain
2863
- } = _ref57;
2896
+ } = _ref58;
2864
2897
  try {
2865
2898
  const tonApi = this.#koniState.getTonApi(chain);
2866
2899
  const state = await tonApi.getAccountState(address);
@@ -2906,10 +2939,10 @@ class KoniExtension {
2906
2939
 
2907
2940
  /* Metadata */
2908
2941
 
2909
- async findRawMetadata(_ref58) {
2942
+ async findRawMetadata(_ref59) {
2910
2943
  let {
2911
2944
  genesisHash
2912
- } = _ref58;
2945
+ } = _ref59;
2913
2946
  const {
2914
2947
  metadata,
2915
2948
  specVersion,
@@ -2923,20 +2956,20 @@ class KoniExtension {
2923
2956
  userExtensions
2924
2957
  };
2925
2958
  }
2926
- async calculateMetadataHash(_ref59) {
2959
+ async calculateMetadataHash(_ref60) {
2927
2960
  let {
2928
2961
  chain
2929
- } = _ref59;
2962
+ } = _ref60;
2930
2963
  const hash = await this.#koniState.calculateMetadataHash(chain);
2931
2964
  return {
2932
2965
  metadataHash: hash || ''
2933
2966
  };
2934
2967
  }
2935
- async shortenMetadata(_ref60) {
2968
+ async shortenMetadata(_ref61) {
2936
2969
  let {
2937
2970
  chain,
2938
2971
  txBlob
2939
- } = _ref60;
2972
+ } = _ref61;
2940
2973
  const shorten = await this.#koniState.shortenMetadata(chain, txBlob);
2941
2974
  return {
2942
2975
  txMetadata: shorten || ''
@@ -3182,18 +3215,18 @@ class KoniExtension {
3182
3215
 
3183
3216
  /* Campaign */
3184
3217
 
3185
- unlockDotCheckCanMint(_ref61) {
3218
+ unlockDotCheckCanMint(_ref62) {
3186
3219
  let {
3187
3220
  address,
3188
3221
  network,
3189
3222
  slug
3190
- } = _ref61;
3223
+ } = _ref62;
3191
3224
  return this.#koniState.mintCampaignService.unlockDotCampaign.canMint(address, slug, network);
3192
3225
  }
3193
- unlockDotSubscribeMintedData(id, port, _ref62) {
3226
+ unlockDotSubscribeMintedData(id, port, _ref63) {
3194
3227
  let {
3195
3228
  transactionId
3196
- } = _ref62;
3229
+ } = _ref63;
3197
3230
  const cb = (0, _subscriptions.createSubscription)(id, port);
3198
3231
  const subscription = this.#koniState.mintCampaignService.unlockDotCampaign.subscribeMintedNft(transactionId, cb);
3199
3232
  this.createUnsubscriptionHandle(id, subscription.unsubscribe);
@@ -3225,10 +3258,10 @@ class KoniExtension {
3225
3258
  });
3226
3259
  return filterBanner(await this.#koniState.campaignService.getProcessingCampaign());
3227
3260
  }
3228
- async completeCampaignBanner(_ref63) {
3261
+ async completeCampaignBanner(_ref64) {
3229
3262
  let {
3230
3263
  slug
3231
- } = _ref63;
3264
+ } = _ref64;
3232
3265
  const campaign = await this.#koniState.dbService.getCampaign(slug);
3233
3266
  if (campaign) {
3234
3267
  await this.#koniState.dbService.upsertCampaign({