@subwallet/extension-base 1.2.3-0 → 1.2.4-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 (94) hide show
  1. package/background/KoniTypes.d.ts +4 -153
  2. package/background/KoniTypes.js +0 -21
  3. package/cjs/background/KoniTypes.js +1 -22
  4. package/cjs/core/logic-validation/earning.js +47 -0
  5. package/cjs/core/logic-validation/swap.js +99 -0
  6. package/cjs/core/logic-validation/transfer.js +212 -0
  7. package/cjs/core/substrate/nominationpools-pallet.js +22 -0
  8. package/cjs/core/substrate/system-pallet.js +77 -0
  9. package/cjs/core/substrate/xcm-parser.js +190 -0
  10. package/cjs/koni/api/dotsama/transfer.js +58 -122
  11. package/cjs/koni/api/staking/bonding/utils.js +1 -1
  12. package/cjs/koni/api/xcm/index.js +30 -2
  13. package/cjs/koni/api/xcm/polkadotXcm.js +12 -20
  14. package/cjs/koni/api/xcm/utils.js +8 -126
  15. package/cjs/koni/api/xcm/xTokens.js +10 -8
  16. package/cjs/koni/api/xcm/xcmPallet.js +6 -6
  17. package/cjs/koni/background/handlers/Extension.js +223 -356
  18. package/cjs/packageInfo.js +1 -1
  19. package/cjs/services/balance-service/helpers/group.js +4 -27
  20. package/cjs/services/balance-service/helpers/subscribe/index.js +2 -30
  21. package/cjs/services/balance-service/helpers/subscribe/substrate/index.js +46 -82
  22. package/cjs/services/balance-service/index.js +11 -9
  23. package/cjs/services/chain-service/constants.js +2 -2
  24. package/cjs/services/chain-service/index.js +0 -1
  25. package/cjs/services/chain-service/utils/index.js +13 -2
  26. package/cjs/services/earning-service/handlers/base.js +1 -1
  27. package/cjs/services/earning-service/handlers/special.js +11 -12
  28. package/cjs/services/migration-service/scripts/MigrateTransactionHistoryBySymbol.js +2 -1
  29. package/cjs/services/migration-service/scripts/databases/MigrateAssetSetting.js +2 -1
  30. package/cjs/services/migration-service/scripts/index.js +2 -2
  31. package/cjs/services/swap-service/handler/base-handler.js +30 -44
  32. package/cjs/services/swap-service/handler/chainflip-handler.js +23 -21
  33. package/cjs/services/swap-service/handler/hydradx-handler.js +41 -39
  34. package/cjs/services/swap-service/index.js +6 -0
  35. package/cjs/services/swap-service/utils.js +8 -49
  36. package/cjs/services/transaction-service/index.js +66 -155
  37. package/core/logic-validation/earning.d.ts +10 -0
  38. package/core/logic-validation/earning.js +37 -0
  39. package/core/logic-validation/swap.d.ts +8 -0
  40. package/core/logic-validation/swap.js +89 -0
  41. package/core/logic-validation/transfer.d.ts +16 -0
  42. package/core/logic-validation/transfer.js +199 -0
  43. package/core/substrate/nominationpools-pallet.d.ts +10 -0
  44. package/core/substrate/nominationpools-pallet.js +13 -0
  45. package/core/substrate/system-pallet.d.ts +27 -0
  46. package/core/substrate/system-pallet.js +70 -0
  47. package/core/substrate/xcm-parser.d.ts +49 -0
  48. package/core/substrate/xcm-parser.js +181 -0
  49. package/koni/api/dotsama/transfer.d.ts +3 -4
  50. package/koni/api/dotsama/transfer.js +54 -118
  51. package/koni/api/staking/bonding/relayChain.d.ts +2 -1
  52. package/koni/api/staking/bonding/utils.js +1 -1
  53. package/koni/api/xcm/index.d.ts +2 -0
  54. package/koni/api/xcm/index.js +27 -1
  55. package/koni/api/xcm/polkadotXcm.js +14 -22
  56. package/koni/api/xcm/utils.d.ts +3 -48
  57. package/koni/api/xcm/utils.js +5 -114
  58. package/koni/api/xcm/xTokens.js +12 -10
  59. package/koni/api/xcm/xcmPallet.js +7 -7
  60. package/koni/background/handlers/Extension.d.ts +6 -8
  61. package/koni/background/handlers/Extension.js +117 -247
  62. package/package.json +39 -9
  63. package/packageInfo.js +1 -1
  64. package/services/balance-service/helpers/group.js +4 -27
  65. package/services/balance-service/helpers/subscribe/index.d.ts +2 -1
  66. package/services/balance-service/helpers/subscribe/index.js +2 -30
  67. package/services/balance-service/helpers/subscribe/substrate/index.d.ts +2 -1
  68. package/services/balance-service/helpers/subscribe/substrate/index.js +31 -66
  69. package/services/balance-service/index.d.ts +7 -6
  70. package/services/balance-service/index.js +12 -10
  71. package/services/chain-service/constants.js +2 -2
  72. package/services/chain-service/index.js +0 -1
  73. package/services/chain-service/utils/index.d.ts +4 -2
  74. package/services/chain-service/utils/index.js +9 -2
  75. package/services/earning-service/handlers/base.js +1 -1
  76. package/services/earning-service/handlers/nomination-pool/index.d.ts +2 -1
  77. package/services/earning-service/handlers/special.js +11 -12
  78. package/services/migration-service/scripts/MigrateTransactionHistoryBySymbol.js +2 -1
  79. package/services/migration-service/scripts/databases/MigrateAssetSetting.js +2 -1
  80. package/services/migration-service/scripts/index.js +2 -2
  81. package/services/swap-service/handler/base-handler.d.ts +3 -2
  82. package/services/swap-service/handler/base-handler.js +28 -42
  83. package/services/swap-service/handler/chainflip-handler.d.ts +2 -1
  84. package/services/swap-service/handler/chainflip-handler.js +4 -2
  85. package/services/swap-service/handler/hydradx-handler.d.ts +2 -1
  86. package/services/swap-service/handler/hydradx-handler.js +8 -6
  87. package/services/swap-service/index.js +7 -1
  88. package/services/swap-service/utils.d.ts +2 -4
  89. package/services/swap-service/utils.js +7 -47
  90. package/services/transaction-service/index.d.ts +1 -1
  91. package/services/transaction-service/index.js +30 -119
  92. package/services/transaction-service/types.d.ts +1 -0
  93. package/types/balance/index.d.ts +6 -10
  94. package/types/yield/info/pallet.d.ts +0 -6
@@ -8,45 +8,43 @@ exports.default = exports.SEED_LENGTHS = exports.SEED_DEFAULT_LENGTH = void 0;
8
8
  exports.isJsonPayload = isJsonPayload;
9
9
  var _common = require("@ethereumjs/common");
10
10
  var _tx = require("@ethereumjs/tx");
11
- var _types = require("@subwallet/chain-list/types");
12
11
  var _TransactionError = require("@subwallet/extension-base/background/errors/TransactionError");
13
12
  var _helpers = require("@subwallet/extension-base/background/handlers/helpers");
14
13
  var _subscriptions = require("@subwallet/extension-base/background/handlers/subscriptions");
15
14
  var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
16
- var _TransactionWarning = require("@subwallet/extension-base/background/warnings/TransactionWarning");
17
15
  var _constants = require("@subwallet/extension-base/constants");
16
+ var _transfer = require("@subwallet/extension-base/core/logic-validation/transfer");
18
17
  var _defaults = require("@subwallet/extension-base/defaults");
19
18
  var _domain = require("@subwallet/extension-base/koni/api/dotsama/domain");
20
19
  var _parseTransaction = require("@subwallet/extension-base/koni/api/dotsama/parseTransaction");
21
- var _transfer = require("@subwallet/extension-base/koni/api/dotsama/transfer");
22
- var _transfer2 = require("@subwallet/extension-base/koni/api/nft/transfer");
20
+ var _transfer2 = require("@subwallet/extension-base/koni/api/dotsama/transfer");
21
+ var _transfer3 = require("@subwallet/extension-base/koni/api/nft/transfer");
23
22
  var _bonding = require("@subwallet/extension-base/koni/api/staking/bonding");
24
23
  var _paraChain = require("@subwallet/extension-base/koni/api/staking/bonding/paraChain");
25
24
  var _relayChain = require("@subwallet/extension-base/koni/api/staking/bonding/relayChain");
26
- var _transfer3 = require("@subwallet/extension-base/koni/api/tokens/evm/transfer");
25
+ var _transfer4 = require("@subwallet/extension-base/koni/api/tokens/evm/transfer");
27
26
  var _wasm = require("@subwallet/extension-base/koni/api/tokens/wasm");
28
27
  var _xcm = require("@subwallet/extension-base/koni/api/xcm");
29
28
  var _utils = require("@subwallet/extension-base/koni/api/yield/helper/utils");
30
29
  var _constants2 = require("@subwallet/extension-base/services/chain-service/constants");
31
- var _types2 = require("@subwallet/extension-base/services/chain-service/types");
30
+ var _types = require("@subwallet/extension-base/services/chain-service/types");
32
31
  var _utils2 = require("@subwallet/extension-base/services/chain-service/utils");
33
- var _utils3 = require("@subwallet/extension-base/services/fee-service/utils");
34
32
  var _constants3 = require("@subwallet/extension-base/services/request-service/constants");
35
33
  var _constants4 = require("@subwallet/extension-base/services/setting-service/constants");
36
34
  var _constants5 = require("@subwallet/extension-base/services/wallet-connect-service/constants");
37
35
  var _helpers2 = require("@subwallet/extension-base/services/wallet-connect-service/helpers");
38
36
  var _storage = require("@subwallet/extension-base/storage");
39
37
  var _stores = require("@subwallet/extension-base/stores");
40
- var _types3 = require("@subwallet/extension-base/types");
41
- var _utils4 = require("@subwallet/extension-base/utils");
38
+ var _types2 = require("@subwallet/extension-base/types");
39
+ var _utils3 = require("@subwallet/extension-base/utils");
42
40
  var _parseTransaction2 = require("@subwallet/extension-base/utils/eth/parseTransaction");
43
- var _number = require("@subwallet/extension-base/utils/number");
44
41
  var _keyring = require("@subwallet/keyring");
45
42
  var _uiKeyring = require("@subwallet/ui-keyring");
46
- var _utils5 = require("@walletconnect/utils");
43
+ var _utils4 = require("@walletconnect/utils");
47
44
  var _bignumber = _interopRequireDefault(require("bignumber.js"));
48
45
  var _i18next = require("i18next");
49
- var _types4 = require("@polkadot/types");
46
+ var _rxjs = require("rxjs");
47
+ var _types3 = require("@polkadot/types");
50
48
  var _util = require("@polkadot/util");
51
49
  var _utilCrypto = require("@polkadot/util-crypto");
52
50
  // Copyright 2019-2022 @subwallet/extension-koni authors & contributors
@@ -90,6 +88,7 @@ class KoniExtension {
90
88
  #skipAutoLock = false;
91
89
  #firstTime = true;
92
90
  #alwaysLock = false;
91
+ #keyringLockSubject = new _rxjs.Subject();
93
92
  constructor(state) {
94
93
  this.#koniState = state;
95
94
  const updateTimeAutoLock = rs => {
@@ -566,7 +565,7 @@ class KoniExtension {
566
565
  const _cb = (0, _subscriptions.createSubscription)(id, port);
567
566
  let old = '';
568
567
  const subscription = this.#koniState.keyringService.addressesSubject.subscribe(subjectInfo => {
569
- const addresses = (0, _utils4.convertSubjectInfoToAddresses)(subjectInfo);
568
+ const addresses = (0, _utils3.convertSubjectInfoToAddresses)(subjectInfo);
570
569
  const _new = JSON.stringify(addresses);
571
570
  if (old !== _new) {
572
571
  _cb({
@@ -581,7 +580,7 @@ class KoniExtension {
581
580
  });
582
581
  const subjectInfo = this.#koniState.keyringService.addresses;
583
582
  return {
584
- addresses: (0, _utils4.convertSubjectInfoToAddresses)(subjectInfo)
583
+ addresses: (0, _utils3.convertSubjectInfoToAddresses)(subjectInfo)
585
584
  };
586
585
  }
587
586
  saveRecentAccount(_ref22) {
@@ -590,7 +589,7 @@ class KoniExtension {
590
589
  chain
591
590
  } = _ref22;
592
591
  if ((0, _utilCrypto.isAddress)(accountId)) {
593
- const address = (0, _utils4.reformatAddress)(accountId);
592
+ const address = (0, _utils3.reformatAddress)(accountId);
594
593
  const account = _uiKeyring.keyring.getAccount(address);
595
594
  const contact = _uiKeyring.keyring.getAddress(address, 'address');
596
595
  if (account) {
@@ -632,7 +631,7 @@ class KoniExtension {
632
631
  meta
633
632
  } = _ref23;
634
633
  if ((0, _utilCrypto.isAddress)(address)) {
635
- const _address = (0, _utils4.reformatAddress)(address);
634
+ const _address = (0, _utils3.reformatAddress)(address);
636
635
  _uiKeyring.keyring.saveAddress(_address, meta);
637
636
  return true;
638
637
  } else {
@@ -644,7 +643,7 @@ class KoniExtension {
644
643
  address
645
644
  } = _ref24;
646
645
  if ((0, _utilCrypto.isAddress)(address)) {
647
- const _address = (0, _utils4.reformatAddress)(address);
646
+ const _address = (0, _utils3.reformatAddress)(address);
648
647
  _uiKeyring.keyring.forgetAddress(_address);
649
648
  return true;
650
649
  } else {
@@ -1574,7 +1573,7 @@ class KoniExtension {
1574
1573
  const addresses = _uiKeyring.keyring.getAccounts().map(a => a.address);
1575
1574
 
1576
1575
  // Re-filter
1577
- cb(histories.filter(item => addresses.some(address => (0, _utils4.isSameAddress)(item.address, address))));
1576
+ cb(histories.filter(item => addresses.some(address => (0, _utils3.isSameAddress)(item.address, address))));
1578
1577
  });
1579
1578
  this.createUnsubscriptionHandle(id, subscription.unsubscribe);
1580
1579
  port.onDisconnect.addListener(() => {
@@ -1583,7 +1582,7 @@ class KoniExtension {
1583
1582
  const addresses = _uiKeyring.keyring.getAccounts().map(a => a.address);
1584
1583
 
1585
1584
  // Re-filter
1586
- return historySubject.getValue().filter(item => addresses.some(address => (0, _utils4.isSameAddress)(item.address, address)));
1585
+ return historySubject.getValue().filter(item => addresses.some(address => (0, _utils3.isSameAddress)(item.address, address)));
1587
1586
  }
1588
1587
  subscribeHistoryByChainAndAddress(_ref46, id, port) {
1589
1588
  let {
@@ -1601,39 +1600,6 @@ class KoniExtension {
1601
1600
  items: subscribeHistoriesResponse.value
1602
1601
  };
1603
1602
  }
1604
-
1605
- // Save address to contact
1606
- // private addContact (to: string) {
1607
- // const toAddress = reformatAddress(to);
1608
- // const account = keyring.getAccount(toAddress);
1609
- // const contact = keyring.getAddress(toAddress);
1610
- //
1611
- // if (!account && (!contact || contact.meta.isRecent)) {
1612
- // keyring.saveAddress(toAddress, {});
1613
- // }
1614
- // }
1615
-
1616
- validateTransfer(tokenSlug, from, to, value, transferAll) {
1617
- const errors = [];
1618
- const keypair = _uiKeyring.keyring.getPair(from);
1619
- let transferValue;
1620
- if (!transferAll) {
1621
- if (value === undefined) {
1622
- errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INVALID_PARAMS, (0, _i18next.t)('Transfer amount is required')));
1623
- }
1624
- if (value) {
1625
- transferValue = new _util.BN(value);
1626
- }
1627
- }
1628
- const tokenInfo = this.#koniState.getAssetBySlug(tokenSlug);
1629
- if (!tokenInfo) {
1630
- errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INVALID_PARAMS, (0, _i18next.t)('Not found token from registry')));
1631
- }
1632
- if ((0, _utilCrypto.isEthereumAddress)(from) && (0, _utilCrypto.isEthereumAddress)(to) && (0, _utils2._isTokenEvmSmartContract)(tokenInfo) && (0, _utils2._getContractAddressOfToken)(tokenInfo).length === 0) {
1633
- errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INVALID_PARAMS, (0, _i18next.t)('Not found ERC20 address for this token')));
1634
- }
1635
- return [errors, keypair, transferValue, tokenInfo];
1636
- }
1637
1603
  async makeTransfer(inputData) {
1638
1604
  const {
1639
1605
  from,
@@ -1643,55 +1609,51 @@ class KoniExtension {
1643
1609
  transferAll,
1644
1610
  value
1645
1611
  } = inputData;
1646
- const [errors,,, tokenInfo] = this.validateTransfer(tokenSlug, from, to, value, transferAll);
1612
+ const transferTokenInfo = this.#koniState.chainService.getAssetBySlug(tokenSlug);
1613
+ const [errors,,] = (0, _transfer.validateTransferRequest)(transferTokenInfo, from, to, value, transferAll);
1647
1614
  const warnings = [];
1648
1615
  const evmApiMap = this.#koniState.getEvmApiMap();
1649
1616
  const chainInfo = this.#koniState.getChainInfo(networkKey);
1650
1617
  const nativeTokenInfo = this.#koniState.getNativeTokenInfo(networkKey);
1651
1618
  const nativeTokenSlug = nativeTokenInfo.slug;
1652
1619
  const isTransferNativeToken = nativeTokenSlug === tokenSlug;
1620
+ const extrinsicType = isTransferNativeToken ? _KoniTypes.ExtrinsicType.TRANSFER_BALANCE : _KoniTypes.ExtrinsicType.TRANSFER_TOKEN;
1653
1621
  let chainType = _KoniTypes.ChainType.SUBSTRATE;
1654
- const tokenBaseAmount = {
1655
- value: '0',
1656
- symbol: tokenInfo.symbol,
1657
- decimals: tokenInfo.decimals || 0
1658
- };
1659
1622
  const transferAmount = {
1660
- ...tokenBaseAmount
1623
+ value: '0',
1624
+ symbol: (0, _utils2._getAssetSymbol)(transferTokenInfo),
1625
+ decimals: (0, _utils2._getAssetDecimals)(transferTokenInfo)
1661
1626
  };
1662
1627
  let transaction;
1663
-
1664
- // Get native token amount
1665
- const freeBalance = await this.getAddressFreeBalance({
1628
+ const transferTokenAvailable = await this.getAddressTransferableBalance({
1666
1629
  address: from,
1667
1630
  networkKey,
1668
- token: tokenSlug
1631
+ token: tokenSlug,
1632
+ extrinsicType
1669
1633
  });
1670
1634
  try {
1671
- if ((0, _utilCrypto.isEthereumAddress)(from) && (0, _utilCrypto.isEthereumAddress)(to) && (0, _utils2._isTokenTransferredByEvm)(tokenInfo)) {
1672
- // TODO: review this
1635
+ if ((0, _utilCrypto.isEthereumAddress)(from) && (0, _utilCrypto.isEthereumAddress)(to) && (0, _utils2._isTokenTransferredByEvm)(transferTokenInfo)) {
1673
1636
  chainType = _KoniTypes.ChainType.EVM;
1674
- const txVal = transferAll ? freeBalance.value : value || '0';
1637
+ const txVal = transferAll ? transferTokenAvailable.value : value || '0';
1675
1638
  const evmApi = evmApiMap[networkKey];
1676
1639
 
1677
1640
  // Estimate with EVM API
1678
- if ((0, _utils2._isTokenEvmSmartContract)(tokenInfo) || (0, _utils2._isLocalToken)(tokenInfo)) {
1679
- [transaction, transferAmount.value] = await (0, _transfer3.getERC20TransactionObject)((0, _utils2._getContractAddressOfToken)(tokenInfo), chainInfo, from, to, txVal, !!transferAll, evmApi);
1641
+ if ((0, _utils2._isTokenEvmSmartContract)(transferTokenInfo) || (0, _utils2._isLocalToken)(transferTokenInfo)) {
1642
+ [transaction, transferAmount.value] = await (0, _transfer4.getERC20TransactionObject)((0, _utils2._getContractAddressOfToken)(transferTokenInfo), chainInfo, from, to, txVal, !!transferAll, evmApi);
1680
1643
  } else {
1681
- [transaction, transferAmount.value] = await (0, _transfer3.getEVMTransactionObject)(chainInfo, from, to, txVal, !!transferAll, evmApi);
1644
+ [transaction, transferAmount.value] = await (0, _transfer4.getEVMTransactionObject)(chainInfo, from, to, txVal, !!transferAll, evmApi);
1682
1645
  }
1683
- } else if ((0, _utils2._isMantaZkAsset)(tokenInfo)) {
1684
- // TODO
1646
+ } else if ((0, _utils2._isMantaZkAsset)(transferTokenInfo)) {
1685
1647
  transaction = undefined;
1686
1648
  transferAmount.value = '0';
1687
1649
  } else {
1688
1650
  const substrateApi = this.#koniState.getSubstrateApi(networkKey);
1689
- [transaction, transferAmount.value] = await (0, _transfer.createTransferExtrinsic)({
1651
+ [transaction, transferAmount.value] = await (0, _transfer2.createTransferExtrinsic)({
1690
1652
  transferAll: !!transferAll,
1691
1653
  value: value || '0',
1692
1654
  from: from,
1693
1655
  networkKey,
1694
- tokenInfo,
1656
+ tokenInfo: transferTokenInfo,
1695
1657
  to: to,
1696
1658
  substrateApi
1697
1659
  });
@@ -1704,46 +1666,33 @@ class KoniExtension {
1704
1666
  throw error;
1705
1667
  }
1706
1668
  const transferNativeAmount = isTransferNativeToken ? transferAmount.value : '0';
1707
-
1708
- // this.addContact(to);
1709
-
1710
1669
  const additionalValidator = async inputTransaction => {
1711
- const minAmount = tokenInfo.minAmount || '0';
1670
+ let senderTransferTokenTransferable;
1712
1671
 
1713
1672
  // Check ed for sender
1714
1673
  if (!isTransferNativeToken) {
1715
1674
  const {
1716
- value: balance
1717
- } = await this.getAddressFreeBalance({
1675
+ value
1676
+ } = await this.getAddressTransferableBalance({
1718
1677
  address: from,
1719
1678
  networkKey,
1720
- token: tokenSlug
1679
+ token: tokenSlug,
1680
+ extrinsicType
1721
1681
  });
1722
- if (new _bignumber.default(balance).minus(transferAmount.value).lt(minAmount)) {
1723
- inputTransaction.warnings.push(new _TransactionWarning.TransactionWarning(_KoniTypes.BasicTxWarningCode.NOT_ENOUGH_EXISTENTIAL_DEPOSIT));
1724
- }
1682
+ senderTransferTokenTransferable = value;
1725
1683
  }
1726
1684
  const {
1727
- value: receiverBalance
1728
- } = await this.getAddressFreeBalance({
1685
+ value: receiverTransferTokenTransferable
1686
+ } = await this.getAddressTransferableBalance({
1729
1687
  address: to,
1730
1688
  networkKey,
1731
- token: tokenSlug
1732
- });
1689
+ token: tokenSlug,
1690
+ extrinsicType
1691
+ }); // todo: shouldn't be just transferable, locked also counts
1733
1692
 
1734
- // Check ed for receiver
1735
- if (new _bignumber.default(receiverBalance).plus(transferAmount.value).lt(minAmount)) {
1736
- const atLeast = new _bignumber.default(minAmount).minus(receiverBalance).plus((tokenInfo.decimals || 0) === 0 ? 0 : 1);
1737
- const atLeastStr = (0, _number.formatNumber)(atLeast, tokenInfo.decimals || 0, _number.balanceFormatter, {
1738
- maxNumberFormat: tokenInfo.decimals || 6
1739
- });
1740
- inputTransaction.errors.push(new _TransactionError.TransactionError(_KoniTypes.TransferTxErrorType.RECEIVER_NOT_ENOUGH_EXISTENTIAL_DEPOSIT, (0, _i18next.t)('You must transfer at least {{amount}} {{symbol}} to keep the destination account alive', {
1741
- replace: {
1742
- amount: atLeastStr,
1743
- symbol: tokenInfo.symbol
1744
- }
1745
- })));
1746
- }
1693
+ const [warning, error] = (0, _transfer.additionalValidateTransfer)(transferTokenInfo, extrinsicType, receiverTransferTokenTransferable, transferAmount.value, senderTransferTokenTransferable);
1694
+ warning && inputTransaction.warnings.push(warning);
1695
+ error && inputTransaction.errors.push(error);
1747
1696
  };
1748
1697
  return this.#koniState.transactionService.handleTransaction({
1749
1698
  errors,
@@ -1754,24 +1703,13 @@ class KoniExtension {
1754
1703
  transferNativeAmount,
1755
1704
  transaction,
1756
1705
  data: inputData,
1757
- extrinsicType: isTransferNativeToken ? _KoniTypes.ExtrinsicType.TRANSFER_BALANCE : _KoniTypes.ExtrinsicType.TRANSFER_TOKEN,
1706
+ extrinsicType,
1758
1707
  ignoreWarnings: transferAll,
1759
1708
  isTransferAll: isTransferNativeToken ? transferAll : false,
1760
1709
  edAsWarning: isTransferNativeToken,
1761
1710
  additionalValidator: additionalValidator
1762
1711
  });
1763
1712
  }
1764
- validateCrossChainTransfer(destinationNetworkKey, sendingTokenSlug, sender, sendingValue) {
1765
- const errors = [];
1766
- const keypair = _uiKeyring.keyring.getPair(sender);
1767
- const transferValue = new _util.BN(sendingValue);
1768
- const originTokenInfo = this.#koniState.getAssetBySlug(sendingTokenSlug);
1769
- const destinationTokenInfo = this.#koniState.getXcmEqualAssetByChain(destinationNetworkKey, sendingTokenSlug);
1770
- if (!destinationTokenInfo) {
1771
- errors.push(new _TransactionError.TransactionError(_KoniTypes.TransferTxErrorType.INVALID_TOKEN, (0, _i18next.t)('Not found token from registry')));
1772
- }
1773
- return [errors, keypair, transferValue, originTokenInfo, destinationTokenInfo];
1774
- }
1775
1713
  async makeCrossChainTransfer(inputData) {
1776
1714
  const {
1777
1715
  destinationNetworkKey,
@@ -1781,7 +1719,9 @@ class KoniExtension {
1781
1719
  tokenSlug,
1782
1720
  value
1783
1721
  } = inputData;
1784
- const [errors, fromKeyPair,, originTokenInfo, destinationTokenInfo] = this.validateCrossChainTransfer(destinationNetworkKey, tokenSlug, from, value);
1722
+ const originTokenInfo = this.#koniState.getAssetBySlug(tokenSlug);
1723
+ const destinationTokenInfo = this.#koniState.getXcmEqualAssetByChain(destinationNetworkKey, tokenSlug);
1724
+ const [errors, fromKeyPair] = (0, _transfer.validateXcmTransferRequest)(destinationTokenInfo, from, value);
1785
1725
  let extrinsic = null;
1786
1726
  if (errors.length > 0) {
1787
1727
  return this.#koniState.transactionService.generateBeforeHandleResponseErrors(errors);
@@ -1800,37 +1740,16 @@ class KoniExtension {
1800
1740
  substrateApi
1801
1741
  });
1802
1742
  additionalValidator = async inputTransaction => {
1803
- const destMinAmount = destinationTokenInfo.minAmount || '0';
1804
- const atLeast = new _bignumber.default(destMinAmount).multipliedBy(_constants.XCM_MIN_AMOUNT_RATIO);
1805
-
1806
- // Check ed for receiver
1807
- if (new _bignumber.default(value).lt(atLeast)) {
1808
- const atLeastStr = (0, _number.formatNumber)(atLeast, destinationTokenInfo.decimals || 0, _number.balanceFormatter, {
1809
- maxNumberFormat: destinationTokenInfo.decimals || 6
1810
- });
1811
- inputTransaction.errors.push(new _TransactionError.TransactionError(_KoniTypes.TransferTxErrorType.RECEIVER_NOT_ENOUGH_EXISTENTIAL_DEPOSIT, (0, _i18next.t)('You must transfer at least {{amount}} {{symbol}} to keep the destination account alive', {
1812
- replace: {
1813
- amount: atLeastStr,
1814
- symbol: originTokenInfo.symbol
1815
- }
1816
- })));
1817
- }
1818
- const srcMinAmount = originTokenInfo.minAmount || '0';
1819
- const isTransferNativeToken = originTokenInfo.assetType === _types._AssetType.NATIVE;
1820
-
1821
- // Check ed for sender
1822
- if (!isTransferNativeToken) {
1823
- const {
1824
- value: balance
1825
- } = await this.getAddressFreeBalance({
1826
- address: from,
1827
- networkKey: originNetworkKey,
1828
- token: originTokenInfo.slug
1829
- });
1830
- if (new _bignumber.default(balance).minus(value).lt(srcMinAmount)) {
1831
- inputTransaction.warnings.push(new _TransactionWarning.TransactionWarning(_KoniTypes.BasicTxWarningCode.NOT_ENOUGH_EXISTENTIAL_DEPOSIT));
1832
- }
1833
- }
1743
+ const {
1744
+ value: senderTransferable
1745
+ } = await this.getAddressTransferableBalance({
1746
+ address: from,
1747
+ networkKey: originNetworkKey,
1748
+ token: originTokenInfo.slug
1749
+ });
1750
+ const [warning, error] = (0, _transfer.additionalValidateXcmTransfer)(originTokenInfo, destinationTokenInfo, value, senderTransferable);
1751
+ error && inputTransaction.errors.push(error);
1752
+ warning && inputTransaction.warnings.push(warning);
1834
1753
  };
1835
1754
  eventsHandler = eventEmitter => {
1836
1755
  eventEmitter.on('send', () => {
@@ -1849,9 +1768,6 @@ class KoniExtension {
1849
1768
  });
1850
1769
  };
1851
1770
  }
1852
-
1853
- // this.addContact(to);
1854
-
1855
1771
  return await this.#koniState.transactionService.handleTransaction({
1856
1772
  url: _constants3.EXTENSION_REQUEST_URL,
1857
1773
  address: from,
@@ -1877,7 +1793,7 @@ class KoniExtension {
1877
1793
  } = inputData;
1878
1794
  const contractAddress = params.contractAddress;
1879
1795
  const tokenId = params.tokenId;
1880
- const transaction = await (0, _transfer3.getERC721Transaction)(this.#koniState.getEvmApi(networkKey), networkKey, contractAddress, senderAddress, recipientAddress, tokenId);
1796
+ const transaction = await (0, _transfer4.getERC721Transaction)(this.#koniState.getEvmApi(networkKey), networkKey, contractAddress, senderAddress, recipientAddress, tokenId);
1881
1797
 
1882
1798
  // this.addContact(recipientAddress);
1883
1799
 
@@ -1957,9 +1873,10 @@ class KoniExtension {
1957
1873
  async validateCustomAsset(data) {
1958
1874
  return await this.#koniState.validateCustomAsset(data);
1959
1875
  }
1960
- async getAddressFreeBalance(_ref49) {
1876
+ async getAddressTransferableBalance(_ref49) {
1961
1877
  let {
1962
1878
  address,
1879
+ extrinsicType,
1963
1880
  networkKey,
1964
1881
  token
1965
1882
  } = _ref49;
@@ -1969,9 +1886,9 @@ class KoniExtension {
1969
1886
  return await this.#koniState.getMantaPayZkBalance(address, tokenInfo);
1970
1887
  }
1971
1888
  }
1972
- return await this.#koniState.balanceService.getTokenFreeBalance(address, networkKey, token);
1889
+ return await this.#koniState.balanceService.getTransferableBalance(address, networkKey, token, extrinsicType);
1973
1890
  }
1974
- async transferGetMaxTransferable(_ref50) {
1891
+ async getMaxTransferable(_ref50) {
1975
1892
  let {
1976
1893
  address,
1977
1894
  destChain,
@@ -1979,92 +1896,67 @@ class KoniExtension {
1979
1896
  networkKey,
1980
1897
  token
1981
1898
  } = _ref50;
1982
- const freeBalance = await this.getAddressFreeBalance({
1983
- address,
1984
- networkKey,
1985
- token
1986
- });
1987
1899
  const tokenInfo = token ? this.#koniState.chainService.getAssetBySlug(token) : this.#koniState.chainService.getNativeTokenInfo(networkKey);
1988
1900
  if (!(0, _utils2._isNativeToken)(tokenInfo)) {
1989
- return freeBalance;
1901
+ return await this.getAddressTransferableBalance({
1902
+ extrinsicType: _KoniTypes.ExtrinsicType.TRANSFER_TOKEN,
1903
+ address,
1904
+ networkKey,
1905
+ token
1906
+ });
1990
1907
  } else {
1991
- const substrateApi = this.#koniState.chainService.getSubstrateApi(networkKey);
1992
- let estimatedFee;
1993
- let maxTransferable = new _bignumber.default(freeBalance.value);
1994
- try {
1995
- if (isXcmTransfer) {
1996
- const chainInfoMap = this.#koniState.chainService.getChainInfoMap();
1997
- const destinationTokenInfo = this.#koniState.getXcmEqualAssetByChain(destChain, tokenInfo.slug);
1998
- if (!destinationTokenInfo) {
1999
- estimatedFee = '0';
2000
- } else {
2001
- maxTransferable = maxTransferable.minus(new _bignumber.default(tokenInfo.minAmount || '0').multipliedBy(_constants.XCM_MIN_AMOUNT_RATIO));
2002
- const desChainInfo = chainInfoMap[destChain];
2003
- const orgChainInfo = chainInfoMap[networkKey];
2004
- const recipient = !(0, _utilCrypto.isEthereumAddress)(address) && (0, _utils2._isChainEvmCompatible)(desChainInfo) && !(0, _utils2._isChainEvmCompatible)(orgChainInfo) ? (0, _util.u8aToHex)((0, _utilCrypto.addressToEvm)(address)) : address;
2005
- const mockTx = await (0, _xcm.createXcmExtrinsic)({
2006
- chainInfoMap,
2007
- destinationTokenInfo,
2008
- originTokenInfo: tokenInfo,
2009
- recipient: recipient,
2010
- sendingValue: '1000000000000000000',
2011
- substrateApi
2012
- });
2013
- try {
2014
- var _paymentInfo$partialF;
2015
- const paymentInfo = await mockTx.paymentInfo(address);
2016
- estimatedFee = (paymentInfo === null || paymentInfo === void 0 ? void 0 : (_paymentInfo$partialF = paymentInfo.partialFee) === null || _paymentInfo$partialF === void 0 ? void 0 : _paymentInfo$partialF.toString()) || '0';
2017
- } catch (e) {
2018
- estimatedFee = tokenInfo.minAmount || '0';
2019
- }
2020
- }
2021
- } else {
2022
- const chainInfo = this.#koniState.chainService.getChainInfoByKey(networkKey);
2023
- if ((0, _utils2._isChainEvmCompatible)(chainInfo) && (0, _utils2._isTokenTransferredByEvm)(tokenInfo)) {
2024
- const web3 = this.#koniState.chainService.getEvmApi(networkKey);
2025
- const transaction = {
2026
- value: 0,
2027
- to: '0x0000000000000000000000000000000000000000',
2028
- // null address
2029
- from: address
2030
- };
2031
- const gasLimit = await web3.api.eth.estimateGas(transaction);
2032
- const priority = await (0, _utils3.calculateGasFeeParams)(web3, networkKey);
2033
- if (priority.baseGasFee) {
2034
- const maxFee = priority.maxFeePerGas;
2035
- estimatedFee = maxFee.multipliedBy(gasLimit).toFixed(0);
2036
- } else {
2037
- estimatedFee = new _bignumber.default(priority.gasPrice).multipliedBy(gasLimit).toFixed(0);
2038
- }
2039
- } else {
2040
- var _paymentInfo$partialF2;
2041
- const [mockTx] = await (0, _transfer.createTransferExtrinsic)({
2042
- from: address,
2043
- networkKey,
2044
- substrateApi,
2045
- to: address,
2046
- tokenInfo,
2047
- transferAll: true,
2048
- value: '1000000000000000000'
2049
- });
2050
- const paymentInfo = await (mockTx === null || mockTx === void 0 ? void 0 : mockTx.paymentInfo(address));
2051
- estimatedFee = (paymentInfo === null || paymentInfo === void 0 ? void 0 : (_paymentInfo$partialF2 = paymentInfo.partialFee) === null || _paymentInfo$partialF2 === void 0 ? void 0 : _paymentInfo$partialF2.toString()) || '0';
2052
- }
2053
- }
2054
- } catch (e) {
2055
- estimatedFee = '0';
2056
- console.warn('Unable to estimate fee', e);
1908
+ let maxTransferable;
1909
+ if (isXcmTransfer) {
1910
+ maxTransferable = await this.getXcmMaxTransferable(tokenInfo, destChain, address);
1911
+ } else {
1912
+ // regular transfer with native token
1913
+ maxTransferable = await this.getNativeTokenMaxTransferable(tokenInfo, networkKey, address);
2057
1914
  }
2058
- maxTransferable = maxTransferable.minus(new _bignumber.default(estimatedFee).multipliedBy(isXcmTransfer ? _constants.XCM_FEE_RATIO : 1));
2059
1915
  return {
2060
- ...freeBalance,
2061
- value: maxTransferable.gt(_utils4.BN_ZERO) ? maxTransferable.toFixed(0) || '0' : '0'
1916
+ value: maxTransferable.gt(_utils3.BN_ZERO) ? maxTransferable.toFixed(0) || '0' : '0',
1917
+ decimals: tokenInfo.decimals,
1918
+ symbol: tokenInfo.symbol
2062
1919
  };
2063
1920
  }
2064
1921
  }
2065
- async subscribeAddressFreeBalance(_ref51, id, port) {
1922
+ async getXcmMaxTransferable(originTokenInfo, destChain, address) {
1923
+ const substrateApi = this.#koniState.chainService.getSubstrateApi(originTokenInfo.originChain);
1924
+ const chainInfoMap = this.#koniState.chainService.getChainInfoMap();
1925
+ const destinationTokenInfo = this.#koniState.getXcmEqualAssetByChain(destChain, originTokenInfo.slug);
1926
+ if (destinationTokenInfo) {
1927
+ const [bnMockFee, {
1928
+ value
1929
+ }] = await Promise.all([(0, _xcm.getXcmMockTxFee)(substrateApi, chainInfoMap, address, originTokenInfo, destinationTokenInfo), this.getAddressTransferableBalance({
1930
+ extrinsicType: _KoniTypes.ExtrinsicType.TRANSFER_XCM,
1931
+ address,
1932
+ networkKey: originTokenInfo.originChain,
1933
+ token: originTokenInfo.slug
1934
+ })]);
1935
+ const bnMaxTransferable = new _bignumber.default(value);
1936
+ const estimatedFee = bnMockFee.multipliedBy(_constants.XCM_FEE_RATIO); // multiply by weight to account for destination chain fee
1937
+
1938
+ return bnMaxTransferable.minus(estimatedFee);
1939
+ }
1940
+ return new _bignumber.default(0);
1941
+ }
1942
+ async getNativeTokenMaxTransferable(tokenInfo, networkKey, address) {
1943
+ const chainInfo = this.#koniState.chainService.getChainInfoByKey(networkKey);
1944
+ const api = (0, _utils2._isChainEvmCompatible)(chainInfo) && (0, _utils2._isTokenTransferredByEvm)(tokenInfo) ? this.#koniState.chainService.getEvmApi(networkKey) : this.#koniState.chainService.getSubstrateApi(networkKey);
1945
+ const [mockTxFee, {
1946
+ value
1947
+ }] = await Promise.all([(0, _transfer2.getTransferMockTxFee)(address, chainInfo, tokenInfo, api), this.getAddressTransferableBalance({
1948
+ extrinsicType: _KoniTypes.ExtrinsicType.TRANSFER_BALANCE,
1949
+ address,
1950
+ networkKey,
1951
+ token: tokenInfo.slug
1952
+ })]);
1953
+ const bnMaxTransferable = new _bignumber.default(value);
1954
+ return bnMaxTransferable.minus(mockTxFee);
1955
+ }
1956
+ async subscribeAddressTransferableBalance(_ref51, id, port) {
2066
1957
  let {
2067
1958
  address,
1959
+ extrinsicType,
2068
1960
  networkKey,
2069
1961
  token
2070
1962
  } = _ref51;
@@ -2079,49 +1971,26 @@ class KoniExtension {
2079
1971
  // eslint-disable-next-line node/no-callback-literal
2080
1972
  cb(convertData(data));
2081
1973
  };
2082
- const [unsub, currentFreeBalance] = await this.#koniState.balanceService.subscribeTokenFreeBalance(address, networkKey, token, _cb);
1974
+ const [unsub, currentFreeBalance] = await this.#koniState.balanceService.subscribeTransferableBalance(address, networkKey, token, extrinsicType, _cb);
2083
1975
  this.createUnsubscriptionHandle(id, unsub);
2084
1976
  port.onDisconnect.addListener(() => {
2085
1977
  this.cancelSubscription(id);
2086
1978
  });
2087
1979
  return convertData(currentFreeBalance);
2088
1980
  }
2089
- async transferCheckReferenceCount(_ref52) {
2090
- let {
2091
- address,
2092
- networkKey
2093
- } = _ref52;
2094
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-return
2095
- return await (0, _transfer.checkReferenceCount)(networkKey, address, this.#koniState.getSubstrateApiMap(), this.#koniState.getChainInfo(networkKey));
2096
- }
2097
- async transferCheckSupporting(_ref53) {
2098
- let {
2099
- networkKey,
2100
- tokenSlug
2101
- } = _ref53;
2102
- const tokenInfo = this.#koniState.getAssetBySlug(tokenSlug);
2103
- return await (0, _transfer.checkSupportTransfer)(networkKey, tokenInfo, this.#koniState.getSubstrateApiMap(), this.#koniState.getChainInfo(networkKey));
2104
- }
2105
- transferGetExistentialDeposit(_ref54) {
2106
- let {
2107
- tokenSlug
2108
- } = _ref54;
2109
- const tokenInfo = this.#koniState.getAssetBySlug(tokenSlug);
2110
- return (0, _utils2._getTokenMinAmount)(tokenInfo);
2111
- }
2112
1981
  async substrateNftSubmitTransaction(inputData) {
2113
1982
  const {
2114
1983
  params,
2115
1984
  recipientAddress,
2116
1985
  senderAddress
2117
1986
  } = inputData;
2118
- const isSendingSelf = (0, _transfer2.isRecipientSelf)(senderAddress, recipientAddress);
1987
+ const isSendingSelf = (0, _transfer3.isRecipientSelf)(senderAddress, recipientAddress);
2119
1988
 
2120
1989
  // TODO: do better to detect tokenType
2121
1990
  const isPSP34 = params === null || params === void 0 ? void 0 : params.isPsp34;
2122
1991
  const networkKey = params === null || params === void 0 ? void 0 : params.networkKey;
2123
1992
  const apiProps = this.#koniState.getSubstrateApi(networkKey);
2124
- const extrinsic = !isPSP34 ? await (0, _transfer2.getNftTransferExtrinsic)(networkKey, apiProps, senderAddress, recipientAddress, params || {}) : await (0, _wasm.getPSP34TransferExtrinsic)(networkKey, apiProps, senderAddress, recipientAddress, params || {});
1993
+ const extrinsic = !isPSP34 ? await (0, _transfer3.getNftTransferExtrinsic)(networkKey, apiProps, senderAddress, recipientAddress, params || {}) : await (0, _wasm.getPSP34TransferExtrinsic)(networkKey, apiProps, senderAddress, recipientAddress, params || {});
2125
1994
 
2126
1995
  // this.addContact(recipientAddress);
2127
1996
 
@@ -2141,11 +2010,11 @@ class KoniExtension {
2141
2010
  isSendingSelf
2142
2011
  };
2143
2012
  }
2144
- async enableChains(_ref55) {
2013
+ async enableChains(_ref52) {
2145
2014
  let {
2146
2015
  chainSlugs,
2147
2016
  enableTokens
2148
- } = _ref55;
2017
+ } = _ref52;
2149
2018
  try {
2150
2019
  await Promise.all(chainSlugs.map(chainSlug => this.enableChain({
2151
2020
  chainSlug,
@@ -2156,24 +2025,24 @@ class KoniExtension {
2156
2025
  }
2157
2026
  return true;
2158
2027
  }
2159
- getAccountMeta(_ref56) {
2028
+ getAccountMeta(_ref53) {
2160
2029
  let {
2161
2030
  address
2162
- } = _ref56;
2031
+ } = _ref53;
2163
2032
  const pair = _uiKeyring.keyring.getPair(address);
2164
2033
  (0, _util.assert)(pair, (0, _i18next.t)('Unable to find account'));
2165
2034
  return {
2166
2035
  meta: pair.meta
2167
2036
  };
2168
2037
  }
2169
- accountsTie2(_ref57) {
2038
+ accountsTie2(_ref54) {
2170
2039
  let {
2171
2040
  address,
2172
2041
  genesisHash
2173
- } = _ref57;
2042
+ } = _ref54;
2174
2043
  return this.#koniState.setAccountTie(address, genesisHash);
2175
2044
  }
2176
- async accountsCreateExternalV2(_ref58) {
2045
+ async accountsCreateExternalV2(_ref55) {
2177
2046
  let {
2178
2047
  address,
2179
2048
  genesisHash,
@@ -2181,7 +2050,7 @@ class KoniExtension {
2181
2050
  isEthereum,
2182
2051
  isReadOnly,
2183
2052
  name
2184
- } = _ref58;
2053
+ } = _ref55;
2185
2054
  try {
2186
2055
  let result;
2187
2056
  try {
@@ -2240,7 +2109,7 @@ class KoniExtension {
2240
2109
  }];
2241
2110
  }
2242
2111
  }
2243
- async accountsCreateHardwareV2(_ref59) {
2112
+ async accountsCreateHardwareV2(_ref56) {
2244
2113
  let {
2245
2114
  accountIndex,
2246
2115
  address,
@@ -2249,7 +2118,7 @@ class KoniExtension {
2249
2118
  hardwareType,
2250
2119
  isAllowed,
2251
2120
  name
2252
- } = _ref59;
2121
+ } = _ref56;
2253
2122
  const key = _uiKeyring.keyring.addHardware(address, hardwareType, {
2254
2123
  accountIndex,
2255
2124
  addressOffset,
@@ -2272,10 +2141,10 @@ class KoniExtension {
2272
2141
  });
2273
2142
  return true;
2274
2143
  }
2275
- async accountsCreateHardwareMultiple(_ref60) {
2144
+ async accountsCreateHardwareMultiple(_ref57) {
2276
2145
  let {
2277
2146
  accounts
2278
- } = _ref60;
2147
+ } = _ref57;
2279
2148
  const addresses = [];
2280
2149
  if (!accounts.length) {
2281
2150
  throw new Error((0, _i18next.t)("Can't find an account. Please try again"));
@@ -2353,14 +2222,14 @@ class KoniExtension {
2353
2222
  }
2354
2223
  return true;
2355
2224
  }
2356
- async accountsCreateWithSecret(_ref61) {
2225
+ async accountsCreateWithSecret(_ref58) {
2357
2226
  let {
2358
2227
  isAllow,
2359
2228
  isEthereum,
2360
2229
  name,
2361
2230
  publicKey,
2362
2231
  secretKey
2363
- } = _ref61;
2232
+ } = _ref58;
2364
2233
  try {
2365
2234
  let keyringPair = null;
2366
2235
  if (isEthereum) {
@@ -2506,30 +2375,30 @@ class KoniExtension {
2506
2375
 
2507
2376
  // Parse transaction
2508
2377
 
2509
- parseSubstrateTransaction(_ref62) {
2378
+ parseSubstrateTransaction(_ref59) {
2510
2379
  let {
2511
2380
  data,
2512
2381
  networkKey
2513
- } = _ref62;
2382
+ } = _ref59;
2514
2383
  const apiProps = this.#koniState.getSubstrateApi(networkKey);
2515
2384
  const apiPromise = apiProps.api;
2516
2385
  return (0, _parseTransaction.parseSubstrateTransaction)(data, apiPromise);
2517
2386
  }
2518
- async parseEVMRLP(_ref63) {
2387
+ async parseEVMRLP(_ref60) {
2519
2388
  let {
2520
2389
  data
2521
- } = _ref63;
2390
+ } = _ref60;
2522
2391
  return await (0, _parseTransaction2.parseEvmRlp)(data, this.#koniState.getChainInfoMap(), this.#koniState.getEvmApiMap());
2523
2392
  }
2524
2393
 
2525
2394
  // Sign
2526
2395
 
2527
- qrSignSubstrate(_ref64) {
2396
+ qrSignSubstrate(_ref61) {
2528
2397
  let {
2529
2398
  address,
2530
2399
  data,
2531
2400
  networkKey
2532
- } = _ref64;
2401
+ } = _ref61;
2533
2402
  const pair = _uiKeyring.keyring.getPair(address);
2534
2403
  (0, _util.assert)(pair, (0, _i18next.t)('Unable to find account'));
2535
2404
  if (pair.isLocked) {
@@ -2546,13 +2415,13 @@ class KoniExtension {
2546
2415
  signature: signed
2547
2416
  };
2548
2417
  }
2549
- async qrSignEVM(_ref65) {
2418
+ async qrSignEVM(_ref62) {
2550
2419
  let {
2551
2420
  address,
2552
2421
  chainId,
2553
2422
  message,
2554
2423
  type
2555
- } = _ref65;
2424
+ } = _ref62;
2556
2425
  let signed;
2557
2426
  const network = this.getNetworkJsonByChainId(chainId);
2558
2427
  if (!network) {
@@ -2575,7 +2444,7 @@ class KoniExtension {
2575
2444
  signed = await pair.evmSigner.signMessage(data, 'personal_sign');
2576
2445
  } else {
2577
2446
  var _signedTranaction$r, _signedTranaction$s, _signedTranaction$v;
2578
- const tx = (0, _utils4.createTransactionFromRLP)(message);
2447
+ const tx = (0, _utils3.createTransactionFromRLP)(message);
2579
2448
  if (!tx) {
2580
2449
  throw new Error((0, _i18next.t)('Failed to decode data. Please use a valid QR code'));
2581
2450
  }
@@ -2600,7 +2469,7 @@ class KoniExtension {
2600
2469
  common
2601
2470
  });
2602
2471
  const signedTranaction = _tx.LegacyTransaction.fromSerializedTx((0, _util.hexToU8a)(pair.evmSigner.signTransaction(transaction)));
2603
- signed = (0, _utils4.signatureToHex)({
2472
+ signed = (0, _utils3.signatureToHex)({
2604
2473
  r: ((_signedTranaction$r = signedTranaction.r) === null || _signedTranaction$r === void 0 ? void 0 : _signedTranaction$r.toString(16)) || '',
2605
2474
  s: ((_signedTranaction$s = signedTranaction.s) === null || _signedTranaction$s === void 0 ? void 0 : _signedTranaction$s.toString(16)) || '',
2606
2475
  v: ((_signedTranaction$v = signedTranaction.v) === null || _signedTranaction$v === void 0 ? void 0 : _signedTranaction$v.toString(16)) || ''
@@ -2636,11 +2505,11 @@ class KoniExtension {
2636
2505
  });
2637
2506
  return this.#koniState.getNominatorMetadata();
2638
2507
  }
2639
- async getBondingOptions(_ref66) {
2508
+ async getBondingOptions(_ref63) {
2640
2509
  let {
2641
2510
  chain,
2642
2511
  type
2643
- } = _ref66;
2512
+ } = _ref63;
2644
2513
  const apiProps = this.#koniState.getSubstrateApi(chain);
2645
2514
  const chainInfo = this.#koniState.getChainInfo(chain);
2646
2515
  const chainStakingMetadata = await this.#koniState.getStakingMetadataByChain(chain, type);
@@ -2728,7 +2597,7 @@ class KoniExtension {
2728
2597
  return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INVALID_PARAMS)]);
2729
2598
  }
2730
2599
  const chain = poolHandler.chain;
2731
- const stakingType = poolHandler.type === _types3.YieldPoolType.NOMINATION_POOL ? _KoniTypes.StakingType.POOLED : _KoniTypes.StakingType.NOMINATED;
2600
+ const stakingType = poolHandler.type === _types2.YieldPoolType.NOMINATION_POOL ? _KoniTypes.StakingType.POOLED : _KoniTypes.StakingType.NOMINATED;
2732
2601
  const substrateApi = this.#koniState.getSubstrateApi(chain);
2733
2602
  const extrinsic = await (0, _bonding.getClaimRewardExtrinsic)(substrateApi, chain, address, stakingType, bondReward);
2734
2603
  return await this.#koniState.transactionService.handleTransaction({
@@ -2830,12 +2699,12 @@ class KoniExtension {
2830
2699
  }
2831
2700
 
2832
2701
  // EVM Transaction
2833
- async parseContractInput(_ref67) {
2702
+ async parseContractInput(_ref64) {
2834
2703
  let {
2835
2704
  chainId,
2836
2705
  contract,
2837
2706
  data
2838
- } = _ref67;
2707
+ } = _ref64;
2839
2708
  const network = this.getNetworkJsonByChainId(chainId);
2840
2709
  return await (0, _parseTransaction2.parseContractInput)(data, contract, network);
2841
2710
  }
@@ -2906,12 +2775,12 @@ class KoniExtension {
2906
2775
 
2907
2776
  // Change master password
2908
2777
 
2909
- keyringChangeMasterPassword(_ref68) {
2778
+ keyringChangeMasterPassword(_ref65) {
2910
2779
  let {
2911
2780
  createNew,
2912
2781
  newPassword,
2913
2782
  oldPassword
2914
- } = _ref68;
2783
+ } = _ref65;
2915
2784
  try {
2916
2785
  // Remove isMasterPassword meta if createNew
2917
2786
  if (createNew && !_uiKeyring.keyring.keyring.hasMasterPassword) {
@@ -2961,11 +2830,11 @@ class KoniExtension {
2961
2830
  }
2962
2831
  }
2963
2832
  }
2964
- keyringMigrateMasterPassword(_ref69) {
2833
+ keyringMigrateMasterPassword(_ref66) {
2965
2834
  let {
2966
2835
  address,
2967
2836
  password
2968
- } = _ref69;
2837
+ } = _ref66;
2969
2838
  try {
2970
2839
  _uiKeyring.keyring.migrateWithMasterPassword(address, password);
2971
2840
  this.checkLockAfterMigrate();
@@ -2984,10 +2853,10 @@ class KoniExtension {
2984
2853
 
2985
2854
  // Unlock wallet
2986
2855
 
2987
- keyringUnlock(_ref70) {
2856
+ keyringUnlock(_ref67) {
2988
2857
  let {
2989
2858
  password
2990
- } = _ref70;
2859
+ } = _ref67;
2991
2860
  try {
2992
2861
  _uiKeyring.keyring.unlockKeyring(password);
2993
2862
  // this.#koniState.initMantaPay(password)
@@ -3009,16 +2878,20 @@ class KoniExtension {
3009
2878
 
3010
2879
  keyringLock() {
3011
2880
  this.#koniState.keyringService.lock();
2881
+ this.#keyringLockSubject.next(true);
3012
2882
  clearTimeout(this.#lockTimeOut);
3013
2883
  }
2884
+ keyringLockSubscribe(cb) {
2885
+ this.#keyringLockSubject.subscribe(cb);
2886
+ }
3014
2887
 
3015
2888
  // Export mnemonic
3016
2889
 
3017
- keyringExportMnemonic(_ref71) {
2890
+ keyringExportMnemonic(_ref68) {
3018
2891
  let {
3019
2892
  address,
3020
2893
  password
3021
- } = _ref71;
2894
+ } = _ref68;
3022
2895
  const pair = _uiKeyring.keyring.getPair(address);
3023
2896
  const result = pair.exportMnemonic(password);
3024
2897
  return {
@@ -3028,10 +2901,10 @@ class KoniExtension {
3028
2901
 
3029
2902
  // Reset wallet
3030
2903
 
3031
- async resetWallet(_ref72) {
2904
+ async resetWallet(_ref69) {
3032
2905
  let {
3033
2906
  resetAll
3034
- } = _ref72;
2907
+ } = _ref69;
3035
2908
  try {
3036
2909
  await this.#koniState.resetWallet(resetAll);
3037
2910
  return {
@@ -3047,10 +2920,10 @@ class KoniExtension {
3047
2920
  }
3048
2921
 
3049
2922
  /// Signing substrate request
3050
- signingApprovePasswordV2(_ref73) {
2923
+ signingApprovePasswordV2(_ref70) {
3051
2924
  let {
3052
2925
  id
3053
- } = _ref73;
2926
+ } = _ref70;
3054
2927
  const queued = this.#koniState.getSignRequest(id);
3055
2928
  (0, _util.assert)(queued, (0, _i18next.t)('Unable to proceed. Please try again'));
3056
2929
  const {
@@ -3076,7 +2949,7 @@ class KoniExtension {
3076
2949
  const {
3077
2950
  payload
3078
2951
  } = request;
3079
- let registry = new _types4.TypeRegistry();
2952
+ let registry = new _types3.TypeRegistry();
3080
2953
  let isEvm = false;
3081
2954
  if (isJsonPayload(payload)) {
3082
2955
  /**
@@ -3129,22 +3002,22 @@ class KoniExtension {
3129
3002
 
3130
3003
  /// Derive account
3131
3004
 
3132
- derivationCreateMultiple(_ref74) {
3005
+ derivationCreateMultiple(_ref71) {
3133
3006
  let {
3134
3007
  isAllowed,
3135
3008
  items,
3136
3009
  parentAddress
3137
- } = _ref74;
3010
+ } = _ref71;
3138
3011
  const parentPair = _uiKeyring.keyring.getPair(parentAddress);
3139
3012
  const isEvm = parentPair.type === 'ethereum';
3140
3013
  if (parentPair.isLocked) {
3141
3014
  _uiKeyring.keyring.unlockPair(parentPair.address);
3142
3015
  }
3143
- const createChild = _ref75 => {
3016
+ const createChild = _ref72 => {
3144
3017
  let {
3145
3018
  name,
3146
3019
  suri
3147
- } = _ref75;
3020
+ } = _ref72;
3148
3021
  const meta = {
3149
3022
  name: name,
3150
3023
  parentAddress
@@ -3190,10 +3063,10 @@ class KoniExtension {
3190
3063
  }
3191
3064
  return true;
3192
3065
  }
3193
- derivationCreateV3(_ref76) {
3066
+ derivationCreateV3(_ref73) {
3194
3067
  let {
3195
3068
  address: parentAddress
3196
- } = _ref76;
3069
+ } = _ref73;
3197
3070
  const parentPair = _uiKeyring.keyring.getPair(parentAddress);
3198
3071
  const isEvm = parentPair.type === 'ethereum';
3199
3072
  if (parentPair.isLocked) {
@@ -3228,11 +3101,11 @@ class KoniExtension {
3228
3101
  }
3229
3102
  return true;
3230
3103
  }
3231
- validateDerivePath(_ref77) {
3104
+ validateDerivePath(_ref74) {
3232
3105
  let {
3233
3106
  parentAddress,
3234
3107
  suri
3235
- } = _ref77;
3108
+ } = _ref74;
3236
3109
  const parentPair = _uiKeyring.keyring.getPair(parentAddress);
3237
3110
  const isEvm = parentPair.type === 'ethereum';
3238
3111
  if (parentPair.isLocked) {
@@ -3265,12 +3138,12 @@ class KoniExtension {
3265
3138
  suri: meta.suri
3266
3139
  };
3267
3140
  }
3268
- getListDeriveAccounts(_ref78) {
3141
+ getListDeriveAccounts(_ref75) {
3269
3142
  let {
3270
3143
  limit,
3271
3144
  page,
3272
3145
  parentAddress
3273
- } = _ref78;
3146
+ } = _ref75;
3274
3147
  const parentPair = _uiKeyring.keyring.getPair(parentAddress);
3275
3148
  const isEvm = parentPair.type === 'ethereum';
3276
3149
  if (parentPair.isLocked) {
@@ -3380,10 +3253,10 @@ class KoniExtension {
3380
3253
  getSupportedSmartContractTypes() {
3381
3254
  return this.#koniState.getSupportedSmartContractTypes();
3382
3255
  }
3383
- getTransaction(_ref79) {
3256
+ getTransaction(_ref76) {
3384
3257
  let {
3385
3258
  id
3386
- } = _ref79;
3259
+ } = _ref76;
3387
3260
  const {
3388
3261
  transaction,
3389
3262
  ...transactionResult
@@ -3393,8 +3266,8 @@ class KoniExtension {
3393
3266
  subscribeTransactions(id, port) {
3394
3267
  const cb = (0, _subscriptions.createSubscription)(id, port);
3395
3268
  function convertRs(rs) {
3396
- return Object.fromEntries(Object.entries(rs).map(_ref80 => {
3397
- let [key, value] = _ref80;
3269
+ return Object.fromEntries(Object.entries(rs).map(_ref77 => {
3270
+ let [key, value] = _ref77;
3398
3271
  const {
3399
3272
  additionalValidator,
3400
3273
  eventsHandler,
@@ -3426,10 +3299,10 @@ class KoniExtension {
3426
3299
  });
3427
3300
  return notificationSubject.value;
3428
3301
  }
3429
- async reloadCron(_ref81) {
3302
+ async reloadCron(_ref78) {
3430
3303
  let {
3431
3304
  data
3432
- } = _ref81;
3305
+ } = _ref78;
3433
3306
  if (data === 'nft') {
3434
3307
  return await this.#koniState.reloadNft();
3435
3308
  } else if (data === 'staking') {
@@ -3473,20 +3346,20 @@ class KoniExtension {
3473
3346
 
3474
3347
  // Phishing detect
3475
3348
 
3476
- async passPhishingPage(_ref82) {
3349
+ async passPhishingPage(_ref79) {
3477
3350
  let {
3478
3351
  url
3479
- } = _ref82;
3352
+ } = _ref79;
3480
3353
  return await this.#koniState.approvePassPhishingPage(url);
3481
3354
  }
3482
3355
 
3483
3356
  /// Wallet connect
3484
3357
 
3485
3358
  // Connect
3486
- async connectWalletConnect(_ref83) {
3359
+ async connectWalletConnect(_ref80) {
3487
3360
  let {
3488
3361
  uri
3489
- } = _ref83;
3362
+ } = _ref80;
3490
3363
  await this.#koniState.walletConnectService.connect(uri);
3491
3364
  return true;
3492
3365
  }
@@ -3499,11 +3372,11 @@ class KoniExtension {
3499
3372
  });
3500
3373
  return this.#koniState.requestService.allConnectWCRequests;
3501
3374
  }
3502
- async approveWalletConnectSession(_ref84) {
3375
+ async approveWalletConnectSession(_ref81) {
3503
3376
  let {
3504
3377
  accounts: selectedAccounts,
3505
3378
  id
3506
- } = _ref84;
3379
+ } = _ref81;
3507
3380
  const request = this.#koniState.requestService.getConnectWCRequest(id);
3508
3381
  if ((0, _helpers2.isProposalExpired)(request.request.params)) {
3509
3382
  throw new Error('The proposal has been expired');
@@ -3515,22 +3388,22 @@ class KoniExtension {
3515
3388
  const availableNamespaces = {};
3516
3389
  const namespaces = {};
3517
3390
  const chainInfoMap = this.#koniState.getChainInfoMap();
3518
- Object.entries(requiredNamespaces).forEach(_ref85 => {
3519
- let [key, namespace] = _ref85;
3391
+ Object.entries(requiredNamespaces).forEach(_ref82 => {
3392
+ let [key, namespace] = _ref82;
3520
3393
  if ((0, _helpers2.isSupportWalletConnectNamespace)(key)) {
3521
3394
  if (namespace.chains) {
3522
3395
  const unSupportChains = namespace.chains.filter(chain => !(0, _helpers2.isSupportWalletConnectChain)(chain, chainInfoMap));
3523
3396
  if (unSupportChains.length) {
3524
- throw new Error((0, _utils5.getSdkError)('UNSUPPORTED_CHAINS').message + ' ' + unSupportChains.toString());
3397
+ throw new Error((0, _utils4.getSdkError)('UNSUPPORTED_CHAINS').message + ' ' + unSupportChains.toString());
3525
3398
  }
3526
3399
  availableNamespaces[key] = namespace;
3527
3400
  }
3528
3401
  } else {
3529
- throw new Error((0, _utils5.getSdkError)('UNSUPPORTED_NAMESPACE_KEY').message + ' ' + key);
3402
+ throw new Error((0, _utils4.getSdkError)('UNSUPPORTED_NAMESPACE_KEY').message + ' ' + key);
3530
3403
  }
3531
3404
  });
3532
- Object.entries(optionalNamespaces).forEach(_ref86 => {
3533
- let [key, namespace] = _ref86;
3405
+ Object.entries(optionalNamespaces).forEach(_ref83 => {
3406
+ let [key, namespace] = _ref83;
3534
3407
  if ((0, _helpers2.isSupportWalletConnectNamespace)(key)) {
3535
3408
  if (namespace.chains) {
3536
3409
  const supportChains = namespace.chains.filter(chain => (0, _helpers2.isSupportWalletConnectChain)(chain, chainInfoMap)) || [];
@@ -3554,11 +3427,11 @@ class KoniExtension {
3554
3427
  }
3555
3428
  }
3556
3429
  });
3557
- Object.entries(availableNamespaces).forEach(_ref87 => {
3558
- let [key, namespace] = _ref87;
3430
+ Object.entries(availableNamespaces).forEach(_ref84 => {
3431
+ let [key, namespace] = _ref84;
3559
3432
  if (namespace.chains) {
3560
3433
  const accounts = [];
3561
- const chains = (0, _utils4.uniqueStringArray)(namespace.chains);
3434
+ const chains = (0, _utils3.uniqueStringArray)(namespace.chains);
3562
3435
  chains.forEach(chain => {
3563
3436
  accounts.push(...selectedAccounts.filter(address => (0, _utilCrypto.isEthereumAddress)(address) === (key === _constants5.WALLET_CONNECT_EIP155_NAMESPACE)).map(address => `${chain}:${address}`));
3564
3437
  });
@@ -3579,10 +3452,10 @@ class KoniExtension {
3579
3452
  request.resolve();
3580
3453
  return true;
3581
3454
  }
3582
- async rejectWalletConnectSession(_ref88) {
3455
+ async rejectWalletConnectSession(_ref85) {
3583
3456
  let {
3584
3457
  id
3585
- } = _ref88;
3458
+ } = _ref85;
3586
3459
  const request = this.#koniState.requestService.getConnectWCRequest(id);
3587
3460
  const wcId = request.request.id;
3588
3461
  if ((0, _helpers2.isProposalExpired)(request.request.params)) {
@@ -3604,10 +3477,10 @@ class KoniExtension {
3604
3477
  });
3605
3478
  return this.#koniState.walletConnectService.sessions;
3606
3479
  }
3607
- async disconnectWalletConnectSession(_ref89) {
3480
+ async disconnectWalletConnectSession(_ref86) {
3608
3481
  let {
3609
3482
  topic
3610
- } = _ref89;
3483
+ } = _ref86;
3611
3484
  await this.#koniState.walletConnectService.disconnect(topic);
3612
3485
  return true;
3613
3486
  }
@@ -3620,18 +3493,18 @@ class KoniExtension {
3620
3493
  });
3621
3494
  return this.#koniState.requestService.allNotSupportWCRequests;
3622
3495
  }
3623
- approveWalletConnectNotSupport(_ref90) {
3496
+ approveWalletConnectNotSupport(_ref87) {
3624
3497
  let {
3625
3498
  id
3626
- } = _ref90;
3499
+ } = _ref87;
3627
3500
  const request = this.#koniState.requestService.getNotSupportWCRequest(id);
3628
3501
  request.resolve();
3629
3502
  return true;
3630
3503
  }
3631
- rejectWalletConnectNotSupport(_ref91) {
3504
+ rejectWalletConnectNotSupport(_ref88) {
3632
3505
  let {
3633
3506
  id
3634
- } = _ref91;
3507
+ } = _ref88;
3635
3508
  const request = this.#koniState.requestService.getNotSupportWCRequest(id);
3636
3509
  request.reject(new Error('USER_REJECTED'));
3637
3510
  return true;
@@ -3639,11 +3512,11 @@ class KoniExtension {
3639
3512
 
3640
3513
  /// Manta
3641
3514
 
3642
- async enableMantaPay(_ref92) {
3515
+ async enableMantaPay(_ref89) {
3643
3516
  let {
3644
3517
  address,
3645
3518
  password
3646
- } = _ref92;
3519
+ } = _ref89;
3647
3520
  // always takes the current account
3648
3521
  function timeout() {
3649
3522
  return new Promise(resolve => setTimeout(resolve, 1500));
@@ -3659,7 +3532,7 @@ class KoniExtension {
3659
3532
  const {
3660
3533
  connectionStatus
3661
3534
  } = this.#koniState.chainService.getChainStatusByKey(_constants2._DEFAULT_MANTA_ZK_CHAIN);
3662
- if (connectionStatus !== _types2._ChainConnectionStatus.CONNECTED) {
3535
+ if (connectionStatus !== _types._ChainConnectionStatus.CONNECTED) {
3663
3536
  // TODO: do better
3664
3537
  await timeout();
3665
3538
  }
@@ -3700,7 +3573,7 @@ class KoniExtension {
3700
3573
  }
3701
3574
  async initSyncMantaPay(address) {
3702
3575
  var _this$koniState$chain3, _this$koniState$chain4, _this$koniState$chain5, _this$koniState$chain6;
3703
- if ((_this$koniState$chain3 = this.#koniState.chainService) !== null && _this$koniState$chain3 !== void 0 && (_this$koniState$chain4 = _this$koniState$chain3.mantaPay) !== null && _this$koniState$chain4 !== void 0 && _this$koniState$chain4.getSyncState().isSyncing || !_utils4.MODULE_SUPPORT.MANTA_ZK) {
3576
+ if ((_this$koniState$chain3 = this.#koniState.chainService) !== null && _this$koniState$chain3 !== void 0 && (_this$koniState$chain4 = _this$koniState$chain3.mantaPay) !== null && _this$koniState$chain4 !== void 0 && _this$koniState$chain4.getSyncState().isSyncing || !_utils3.MODULE_SUPPORT.MANTA_ZK) {
3704
3577
  return;
3705
3578
  }
3706
3579
  this.#skipAutoLock = true;
@@ -3767,10 +3640,10 @@ class KoniExtension {
3767
3640
 
3768
3641
  /// Metadata
3769
3642
 
3770
- async findRawMetadata(_ref93) {
3643
+ async findRawMetadata(_ref90) {
3771
3644
  let {
3772
3645
  genesisHash
3773
- } = _ref93;
3646
+ } = _ref90;
3774
3647
  const {
3775
3648
  metadata,
3776
3649
  specVersion
@@ -4017,18 +3890,18 @@ class KoniExtension {
4017
3890
 
4018
3891
  /* Campaign */
4019
3892
 
4020
- unlockDotCheckCanMint(_ref94) {
3893
+ unlockDotCheckCanMint(_ref91) {
4021
3894
  let {
4022
3895
  address,
4023
3896
  network,
4024
3897
  slug
4025
- } = _ref94;
3898
+ } = _ref91;
4026
3899
  return this.#koniState.mintCampaignService.unlockDotCampaign.canMint(address, slug, network);
4027
3900
  }
4028
- unlockDotSubscribeMintedData(id, port, _ref95) {
3901
+ unlockDotSubscribeMintedData(id, port, _ref92) {
4029
3902
  let {
4030
3903
  transactionId
4031
- } = _ref95;
3904
+ } = _ref92;
4032
3905
  const cb = (0, _subscriptions.createSubscription)(id, port);
4033
3906
  const subscription = this.#koniState.mintCampaignService.unlockDotCampaign.subscribeMintedNft(transactionId, cb);
4034
3907
  this.createUnsubscriptionHandle(id, subscription.unsubscribe);
@@ -4060,10 +3933,10 @@ class KoniExtension {
4060
3933
  });
4061
3934
  return filterBanner(await this.#koniState.campaignService.getProcessingCampaign());
4062
3935
  }
4063
- async completeCampaignBanner(_ref96) {
3936
+ async completeCampaignBanner(_ref93) {
4064
3937
  let {
4065
3938
  slug
4066
- } = _ref96;
3939
+ } = _ref93;
4067
3940
  const campaign = await this.#koniState.dbService.getCampaign(slug);
4068
3941
  if (campaign) {
4069
3942
  await this.#koniState.dbService.upsertCampaign({
@@ -4516,20 +4389,14 @@ class KoniExtension {
4516
4389
  return this.subscribeAssetSetting(id, port);
4517
4390
  case 'pri(assetSetting.update)':
4518
4391
  return await this.updateAssetSetting(request);
4519
- case 'pri(transfer.checkReferenceCount)':
4520
- return await this.transferCheckReferenceCount(request);
4521
- case 'pri(transfer.checkSupporting)':
4522
- return await this.transferCheckSupporting(request);
4523
- case 'pri(transfer.getExistentialDeposit)':
4524
- return this.transferGetExistentialDeposit(request);
4525
4392
  case 'pri(transfer.getMaxTransferable)':
4526
- return this.transferGetMaxTransferable(request);
4393
+ return this.getMaxTransferable(request);
4527
4394
  case 'pri(transfer.subscribeMaxTransferable)':
4528
- return this.transferGetMaxTransferable(request);
4395
+ return this.getMaxTransferable(request);
4529
4396
  case 'pri(freeBalance.get)':
4530
- return this.getAddressFreeBalance(request);
4397
+ return this.getAddressTransferableBalance(request);
4531
4398
  case 'pri(freeBalance.subscribe)':
4532
- return this.subscribeAddressFreeBalance(request, id, port);
4399
+ return this.subscribeAddressTransferableBalance(request, id, port);
4533
4400
  case 'pri(subscription.cancel)':
4534
4401
  return this.cancelSubscription(request);
4535
4402
  case 'pri(chainService.recoverSubstrateApi)':