@subwallet/extension-base 1.0.7-1 → 1.0.8-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 (55) hide show
  1. package/background/KoniTypes.d.ts +6 -4
  2. package/background/KoniTypes.js +1 -0
  3. package/background/errors/TransactionError.js +5 -1
  4. package/cjs/background/KoniTypes.js +1 -0
  5. package/cjs/background/errors/TransactionError.js +4 -0
  6. package/cjs/constants/index.js +6 -3
  7. package/cjs/koni/api/dotsama/balance.js +2 -1
  8. package/cjs/koni/api/dotsama/crowdloan.js +1 -1
  9. package/cjs/koni/api/dotsama/transfer.js +2 -2
  10. package/cjs/koni/api/staking/bonding/astar.js +5 -4
  11. package/cjs/koni/api/staking/bonding/relayChain.js +12 -3
  12. package/cjs/koni/api/staking/bonding/utils.js +7 -0
  13. package/cjs/koni/api/xcm/polkadotXcm.js +18 -37
  14. package/cjs/koni/api/xcm/utils.js +78 -11
  15. package/cjs/koni/api/xcm/xTokens.js +4 -33
  16. package/cjs/koni/api/xcm/xcmPallet.js +4 -36
  17. package/cjs/koni/background/handlers/Extension.js +179 -97
  18. package/cjs/koni/background/handlers/State.js +1 -1
  19. package/cjs/packageInfo.js +1 -1
  20. package/cjs/services/chain-service/constants.js +8 -6
  21. package/cjs/services/chain-service/index.js +19 -15
  22. package/cjs/services/chain-service/utils.js +1 -5
  23. package/cjs/services/transaction-service/helpers/index.js +45 -2
  24. package/cjs/services/transaction-service/index.js +58 -24
  25. package/cjs/utils/number.js +112 -0
  26. package/constants/index.d.ts +1 -0
  27. package/constants/index.js +1 -0
  28. package/koni/api/dotsama/balance.js +2 -1
  29. package/koni/api/dotsama/crowdloan.js +2 -2
  30. package/koni/api/dotsama/transfer.js +2 -2
  31. package/koni/api/staking/bonding/astar.js +5 -4
  32. package/koni/api/staking/bonding/relayChain.js +13 -4
  33. package/koni/api/staking/bonding/utils.d.ts +5 -0
  34. package/koni/api/staking/bonding/utils.js +6 -0
  35. package/koni/api/xcm/polkadotXcm.js +20 -39
  36. package/koni/api/xcm/utils.d.ts +36 -3
  37. package/koni/api/xcm/utils.js +72 -11
  38. package/koni/api/xcm/xTokens.js +6 -35
  39. package/koni/api/xcm/xcmPallet.js +5 -35
  40. package/koni/background/handlers/Extension.js +109 -29
  41. package/koni/background/handlers/State.js +2 -2
  42. package/package.json +13 -8
  43. package/packageInfo.js +1 -1
  44. package/services/chain-service/constants.d.ts +1 -0
  45. package/services/chain-service/constants.js +8 -7
  46. package/services/chain-service/index.js +13 -8
  47. package/services/chain-service/types.d.ts +8 -0
  48. package/services/chain-service/utils.d.ts +0 -1
  49. package/services/chain-service/utils.js +1 -4
  50. package/services/transaction-service/helpers/index.d.ts +2 -0
  51. package/services/transaction-service/helpers/index.js +42 -0
  52. package/services/transaction-service/index.js +54 -20
  53. package/services/transaction-service/types.d.ts +2 -2
  54. package/utils/number.d.ts +9 -0
  55. package/utils/number.js +100 -0
@@ -6,11 +6,13 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = void 0;
8
8
  var _common = _interopRequireDefault(require("@ethereumjs/common"));
9
+ var _types = require("@subwallet/chain-list/types");
9
10
  var _TransactionError = require("@subwallet/extension-base/background/errors/TransactionError");
10
11
  var _Extension = require("@subwallet/extension-base/background/handlers/Extension");
11
12
  var _helpers = require("@subwallet/extension-base/background/handlers/helpers");
12
13
  var _subscriptions = require("@subwallet/extension-base/background/handlers/subscriptions");
13
14
  var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
15
+ var _TransactionWarning = require("@subwallet/extension-base/background/warnings/TransactionWarning");
14
16
  var _constants = require("@subwallet/extension-base/constants");
15
17
  var _defaults = require("@subwallet/extension-base/defaults");
16
18
  var _parseTransaction = require("@subwallet/extension-base/koni/api/dotsama/parseTransaction");
@@ -29,11 +31,12 @@ var _utils2 = require("@subwallet/extension-base/utils");
29
31
  var _address2 = require("@subwallet/extension-base/utils/address");
30
32
  var _eth = require("@subwallet/extension-base/utils/eth");
31
33
  var _parseTransaction2 = require("@subwallet/extension-base/utils/eth/parseTransaction");
34
+ var _number = require("@subwallet/extension-base/utils/number");
32
35
  var _keyring = require("@subwallet/keyring");
33
36
  var _uiKeyring = require("@subwallet/ui-keyring");
34
37
  var _bignumber = _interopRequireDefault(require("bignumber.js"));
35
38
  var _ethereumjsTx = require("ethereumjs-tx");
36
- var _types = require("@polkadot/types");
39
+ var _types2 = require("@polkadot/types");
37
40
  var _util = require("@polkadot/util");
38
41
  var _utilCrypto = require("@polkadot/util-crypto");
39
42
  // Copyright 2019-2022 @subwallet/extension-koni authors & contributors
@@ -1446,31 +1449,58 @@ class KoniExtension {
1446
1449
 
1447
1450
  // Get native token amount
1448
1451
  const freeBalance = await this.#koniState.balanceService.getTokenFreeBalance(from, networkKey, tokenSlug);
1449
- if ((0, _utilCrypto.isEthereumAddress)(from) && (0, _utilCrypto.isEthereumAddress)(to) && (0, _utils._isTokenTransferredByEvm)(tokenInfo)) {
1450
- // TODO: review this
1451
- chainType = _KoniTypes.ChainType.EVM;
1452
- const txVal = transferAll ? freeBalance.value : value || '0';
1453
-
1454
- // Estimate with EVM API
1455
- if ((0, _utils._isTokenEvmSmartContract)(tokenInfo) || (0, _utils._isLocalToken)(tokenInfo)) {
1456
- [transaction, transferAmount.value] = await (0, _transfer3.getERC20TransactionObject)((0, _utils._getContractAddressOfToken)(tokenInfo), chainInfo, from, to, txVal, !!transferAll, evmApiMap);
1452
+ try {
1453
+ if ((0, _utilCrypto.isEthereumAddress)(from) && (0, _utilCrypto.isEthereumAddress)(to) && (0, _utils._isTokenTransferredByEvm)(tokenInfo)) {
1454
+ // TODO: review this
1455
+ chainType = _KoniTypes.ChainType.EVM;
1456
+ const txVal = transferAll ? freeBalance.value : value || '0';
1457
+
1458
+ // Estimate with EVM API
1459
+ if ((0, _utils._isTokenEvmSmartContract)(tokenInfo) || (0, _utils._isLocalToken)(tokenInfo)) {
1460
+ [transaction, transferAmount.value] = await (0, _transfer3.getERC20TransactionObject)((0, _utils._getContractAddressOfToken)(tokenInfo), chainInfo, from, to, txVal, !!transferAll, evmApiMap);
1461
+ } else {
1462
+ [transaction, transferAmount.value] = await (0, _transfer3.getEVMTransactionObject)(chainInfo, to, txVal, !!transferAll, evmApiMap);
1463
+ }
1457
1464
  } else {
1458
- [transaction, transferAmount.value] = await (0, _transfer3.getEVMTransactionObject)(chainInfo, to, txVal, !!transferAll, evmApiMap);
1465
+ const substrateApi = this.#koniState.getSubstrateApi(networkKey);
1466
+ [transaction, transferAmount.value] = await (0, _transfer.createTransferExtrinsic)({
1467
+ transferAll: !!transferAll,
1468
+ value: value || '0',
1469
+ from: from,
1470
+ networkKey,
1471
+ tokenInfo,
1472
+ to: to,
1473
+ substrateApi
1474
+ });
1459
1475
  }
1460
- } else {
1461
- const substrateApi = this.#koniState.getSubstrateApi(networkKey);
1462
- [transaction, transferAmount.value] = await (0, _transfer.createTransferExtrinsic)({
1463
- transferAll: !!transferAll,
1464
- value: value || '0',
1465
- from: from,
1466
- networkKey,
1467
- tokenInfo,
1468
- to: to,
1469
- substrateApi
1470
- });
1476
+ } catch (e) {
1477
+ const error = e;
1478
+ if (error.message.includes('transfer amount exceeds balance')) {
1479
+ error.message = 'Not enough balance';
1480
+ }
1481
+ throw error;
1471
1482
  }
1472
1483
  const transferNativeAmount = isTransferNativeToken ? transferAmount.value : '0';
1473
1484
  this.addContact(to);
1485
+ const additionalValidator = async inputTransaction => {
1486
+ const minAmount = tokenInfo.minAmount || '0';
1487
+ if (!isTransferNativeToken) {
1488
+ const {
1489
+ value: balance
1490
+ } = await this.#koniState.balanceService.getTokenFreeBalance(from, networkKey, tokenSlug);
1491
+ if (new _bignumber.default(balance).minus(transferAmount.value).lt(minAmount)) {
1492
+ inputTransaction.warnings.push(new _TransactionWarning.TransactionWarning(_KoniTypes.BasicTxWarningCode.NOT_ENOUGH_EXISTENTIAL_DEPOSIT, ''));
1493
+ }
1494
+ }
1495
+ const {
1496
+ value: receiverBalance
1497
+ } = await this.#koniState.balanceService.getTokenFreeBalance(to, networkKey, tokenSlug);
1498
+ if (new _bignumber.default(receiverBalance).plus(transferAmount.value).lt(minAmount)) {
1499
+ const atLeast = new _bignumber.default(minAmount).minus(receiverBalance).plus((tokenInfo.decimals || 0) === 0 ? 0 : 1);
1500
+ const atLeastStr = (0, _number.formatNumber)(atLeast, tokenInfo.decimals || 0, _number.balanceFormatter);
1501
+ inputTransaction.errors.push(new _TransactionError.TransactionError(_KoniTypes.TransferTxErrorType.RECEIVER_NOT_ENOUGH_EXISTENTIAL_DEPOSIT, `You must transfer at least ${atLeastStr} ${tokenInfo.symbol} to keep the destination account alive`));
1502
+ }
1503
+ };
1474
1504
  return this.#koniState.transactionService.handleTransaction({
1475
1505
  errors,
1476
1506
  warnings,
@@ -1482,8 +1512,9 @@ class KoniExtension {
1482
1512
  data: inputData,
1483
1513
  extrinsicType: isTransferNativeToken ? _KoniTypes.ExtrinsicType.TRANSFER_BALANCE : _KoniTypes.ExtrinsicType.TRANSFER_TOKEN,
1484
1514
  ignoreWarnings: transferAll,
1485
- isTransferAll: transferAll,
1486
- edAsWarning: isTransferNativeToken
1515
+ isTransferAll: isTransferNativeToken ? transferAll : false,
1516
+ edAsWarning: isTransferNativeToken,
1517
+ additionalValidator: additionalValidator
1487
1518
  });
1488
1519
  }
1489
1520
  validateCrossChainTransfer(destinationNetworkKey, sendingTokenSlug, sender, sendingValue) {
@@ -1511,6 +1542,8 @@ class KoniExtension {
1511
1542
  if (errors.length > 0) {
1512
1543
  return this.#koniState.transactionService.generateBeforeHandleResponseErrors(errors);
1513
1544
  }
1545
+ let additionalValidator;
1546
+ let eventsHandler;
1514
1547
  if (fromKeyPair && destinationTokenInfo) {
1515
1548
  const substrateApi = this.#koniState.getSubstrateApi(originNetworkKey);
1516
1549
  const chainInfoMap = this.#koniState.getChainInfoMap();
@@ -1522,6 +1555,40 @@ class KoniExtension {
1522
1555
  chainInfoMap,
1523
1556
  substrateApi
1524
1557
  });
1558
+ additionalValidator = async inputTransaction => {
1559
+ const destMinAmount = destinationTokenInfo.minAmount || '0';
1560
+ const atLeast = new _bignumber.default(destMinAmount).multipliedBy(_constants.XCM_MIN_AMOUNT_RATIO);
1561
+ if (new _bignumber.default(value).lt(atLeast)) {
1562
+ const atLeastStr = (0, _number.formatNumber)(atLeast, destinationTokenInfo.decimals || 0, _number.balanceFormatter);
1563
+ inputTransaction.errors.push(new _TransactionError.TransactionError(_KoniTypes.TransferTxErrorType.RECEIVER_NOT_ENOUGH_EXISTENTIAL_DEPOSIT, `You must transfer at least ${atLeastStr} ${originTokenInfo.symbol} to keep the destination account alive`));
1564
+ }
1565
+ const srcMinAmount = originTokenInfo.minAmount || '0';
1566
+ const isTransferNativeToken = originTokenInfo.assetType === _types._AssetType.NATIVE;
1567
+ if (!isTransferNativeToken) {
1568
+ const {
1569
+ value: balance
1570
+ } = await this.#koniState.balanceService.getTokenFreeBalance(from, originNetworkKey, originTokenInfo.slug);
1571
+ if (new _bignumber.default(balance).minus(value).lt(srcMinAmount)) {
1572
+ inputTransaction.warnings.push(new _TransactionWarning.TransactionWarning(_KoniTypes.BasicTxWarningCode.NOT_ENOUGH_EXISTENTIAL_DEPOSIT, ''));
1573
+ }
1574
+ }
1575
+ };
1576
+ eventsHandler = eventEmitter => {
1577
+ eventEmitter.on('send', () => {
1578
+ try {
1579
+ const dest = _uiKeyring.keyring.getPair(to);
1580
+ if (dest) {
1581
+ this.updateAssetSetting({
1582
+ autoEnableNativeToken: false,
1583
+ tokenSlug: destinationTokenInfo.slug,
1584
+ assetSetting: {
1585
+ visible: true
1586
+ }
1587
+ }).catch(console.error);
1588
+ }
1589
+ } catch (e) {}
1590
+ });
1591
+ };
1525
1592
  }
1526
1593
  this.addContact(to);
1527
1594
  return await this.#koniState.transactionService.handleTransaction({
@@ -1533,8 +1600,11 @@ class KoniExtension {
1533
1600
  extrinsicType: _KoniTypes.ExtrinsicType.TRANSFER_XCM,
1534
1601
  chainType: _KoniTypes.ChainType.SUBSTRATE,
1535
1602
  transferNativeAmount: (0, _utils._isNativeToken)(originTokenInfo) ? value : '0',
1603
+ ignoreWarnings: inputData.transferAll,
1536
1604
  isTransferAll: inputData.transferAll,
1537
- errors
1605
+ errors,
1606
+ additionalValidator: additionalValidator,
1607
+ eventsHandler: eventsHandler
1538
1608
  });
1539
1609
  }
1540
1610
  async evmNftSubmitTransaction(inputData) {
@@ -1572,14 +1642,18 @@ class KoniExtension {
1572
1642
  disableChain(networkKey) {
1573
1643
  return this.#koniState.disableChain(networkKey);
1574
1644
  }
1575
- async enableChain(networkKey) {
1576
- return await this.#koniState.enableChain(networkKey);
1645
+ async enableChain(_ref39) {
1646
+ let {
1647
+ chainSlug,
1648
+ enableTokens
1649
+ } = _ref39;
1650
+ return await this.#koniState.enableChain(chainSlug, enableTokens);
1577
1651
  }
1578
- async validateNetwork(_ref39) {
1652
+ async validateNetwork(_ref40) {
1579
1653
  let {
1580
1654
  existedChainSlug,
1581
1655
  provider
1582
- } = _ref39;
1656
+ } = _ref40;
1583
1657
  return await this.#koniState.validateCustomChain(provider, existedChainSlug);
1584
1658
  }
1585
1659
  resetDefaultNetwork() {
@@ -1617,22 +1691,22 @@ class KoniExtension {
1617
1691
  async validateCustomAsset(data) {
1618
1692
  return await this.#koniState.validateCustomAsset(data);
1619
1693
  }
1620
- async getAddressFreeBalance(_ref40) {
1694
+ async getAddressFreeBalance(_ref41) {
1621
1695
  let {
1622
1696
  address,
1623
1697
  networkKey,
1624
1698
  token
1625
- } = _ref40;
1699
+ } = _ref41;
1626
1700
  return await this.#koniState.balanceService.getTokenFreeBalance(address, networkKey, token);
1627
1701
  }
1628
- async transferGetMaxTransferable(_ref41) {
1702
+ async transferGetMaxTransferable(_ref42) {
1629
1703
  let {
1630
1704
  address,
1631
1705
  destChain,
1632
1706
  isXcmTransfer,
1633
1707
  networkKey,
1634
1708
  token
1635
- } = _ref41;
1709
+ } = _ref42;
1636
1710
  const freeBalance = await this.#koniState.balanceService.getTokenFreeBalance(address, networkKey, token);
1637
1711
  const tokenInfo = token ? this.#koniState.chainService.getAssetBySlug(token) : this.#koniState.chainService.getNativeTokenInfo(networkKey);
1638
1712
  if (!(0, _utils._isNativeToken)(tokenInfo)) {
@@ -1703,12 +1777,12 @@ class KoniExtension {
1703
1777
  };
1704
1778
  }
1705
1779
  }
1706
- async subscribeAddressFreeBalance(_ref42, id, port) {
1780
+ async subscribeAddressFreeBalance(_ref43, id, port) {
1707
1781
  let {
1708
1782
  address,
1709
1783
  networkKey,
1710
1784
  token
1711
- } = _ref42;
1785
+ } = _ref43;
1712
1786
  const cb = (0, _subscriptions.createSubscription)(id, port);
1713
1787
  const [unsub, currentFreeBalance] = await this.#koniState.balanceService.subscribeTokenFreeBalance(address, networkKey, token, cb);
1714
1788
  this.createUnsubscriptionHandle(id, unsub);
@@ -1717,26 +1791,26 @@ class KoniExtension {
1717
1791
  });
1718
1792
  return currentFreeBalance;
1719
1793
  }
1720
- async transferCheckReferenceCount(_ref43) {
1794
+ async transferCheckReferenceCount(_ref44) {
1721
1795
  let {
1722
1796
  address,
1723
1797
  networkKey
1724
- } = _ref43;
1798
+ } = _ref44;
1725
1799
  // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-return
1726
1800
  return await (0, _transfer.checkReferenceCount)(networkKey, address, this.#koniState.getSubstrateApiMap(), this.#koniState.getChainInfo(networkKey));
1727
1801
  }
1728
- async transferCheckSupporting(_ref44) {
1802
+ async transferCheckSupporting(_ref45) {
1729
1803
  let {
1730
1804
  networkKey,
1731
1805
  tokenSlug
1732
- } = _ref44;
1806
+ } = _ref45;
1733
1807
  const tokenInfo = this.#koniState.getAssetBySlug(tokenSlug);
1734
1808
  return await (0, _transfer.checkSupportTransfer)(networkKey, tokenInfo, this.#koniState.getSubstrateApiMap(), this.#koniState.getChainInfo(networkKey));
1735
1809
  }
1736
- transferGetExistentialDeposit(_ref45) {
1810
+ transferGetExistentialDeposit(_ref46) {
1737
1811
  let {
1738
1812
  tokenSlug
1739
- } = _ref45;
1813
+ } = _ref46;
1740
1814
  const tokenInfo = this.#koniState.getAssetBySlug(tokenSlug);
1741
1815
  return (0, _utils._getTokenMinAmount)(tokenInfo);
1742
1816
  }
@@ -1770,32 +1844,39 @@ class KoniExtension {
1770
1844
  isSendingSelf
1771
1845
  };
1772
1846
  }
1773
- async enableChains(targetKeys) {
1847
+ async enableChains(_ref47) {
1848
+ let {
1849
+ chainSlugs,
1850
+ enableTokens
1851
+ } = _ref47;
1774
1852
  try {
1775
- await Promise.all(targetKeys.map(networkKey => this.enableChain(networkKey)));
1853
+ await Promise.all(chainSlugs.map(chainSlug => this.enableChain({
1854
+ chainSlug,
1855
+ enableTokens
1856
+ })));
1776
1857
  } catch (e) {
1777
1858
  return false;
1778
1859
  }
1779
1860
  return true;
1780
1861
  }
1781
- getAccountMeta(_ref46) {
1862
+ getAccountMeta(_ref48) {
1782
1863
  let {
1783
1864
  address
1784
- } = _ref46;
1865
+ } = _ref48;
1785
1866
  const pair = _uiKeyring.keyring.getPair(address);
1786
1867
  (0, _util.assert)(pair, 'Unable to find pair');
1787
1868
  return {
1788
1869
  meta: pair.meta
1789
1870
  };
1790
1871
  }
1791
- accountsTie2(_ref47) {
1872
+ accountsTie2(_ref49) {
1792
1873
  let {
1793
1874
  address,
1794
1875
  genesisHash
1795
- } = _ref47;
1876
+ } = _ref49;
1796
1877
  return this.#koniState.setAccountTie(address, genesisHash);
1797
1878
  }
1798
- async accountsCreateExternalV2(_ref48) {
1879
+ async accountsCreateExternalV2(_ref50) {
1799
1880
  let {
1800
1881
  address,
1801
1882
  genesisHash,
@@ -1803,7 +1884,7 @@ class KoniExtension {
1803
1884
  isEthereum,
1804
1885
  isReadOnly,
1805
1886
  name
1806
- } = _ref48;
1887
+ } = _ref50;
1807
1888
  try {
1808
1889
  let result;
1809
1890
  try {
@@ -1862,7 +1943,7 @@ class KoniExtension {
1862
1943
  }];
1863
1944
  }
1864
1945
  }
1865
- async accountsCreateHardwareV2(_ref49) {
1946
+ async accountsCreateHardwareV2(_ref51) {
1866
1947
  let {
1867
1948
  accountIndex,
1868
1949
  address,
@@ -1871,7 +1952,7 @@ class KoniExtension {
1871
1952
  hardwareType,
1872
1953
  isAllowed,
1873
1954
  name
1874
- } = _ref49;
1955
+ } = _ref51;
1875
1956
  const key = _uiKeyring.keyring.addHardware(address, hardwareType, {
1876
1957
  accountIndex,
1877
1958
  addressOffset,
@@ -1894,10 +1975,10 @@ class KoniExtension {
1894
1975
  });
1895
1976
  return true;
1896
1977
  }
1897
- async accountsCreateHardwareMultiple(_ref50) {
1978
+ async accountsCreateHardwareMultiple(_ref52) {
1898
1979
  let {
1899
1980
  accounts
1900
- } = _ref50;
1981
+ } = _ref52;
1901
1982
  const addresses = [];
1902
1983
  if (!accounts.length) {
1903
1984
  throw new Error('No accounts to import');
@@ -1948,14 +2029,14 @@ class KoniExtension {
1948
2029
  });
1949
2030
  return true;
1950
2031
  }
1951
- async accountsCreateWithSecret(_ref51) {
2032
+ async accountsCreateWithSecret(_ref53) {
1952
2033
  let {
1953
2034
  isAllow,
1954
2035
  isEthereum,
1955
2036
  name,
1956
2037
  publicKey,
1957
2038
  secretKey
1958
- } = _ref51;
2039
+ } = _ref53;
1959
2040
  try {
1960
2041
  let keyringPair = null;
1961
2042
  if (isEthereum) {
@@ -2098,30 +2179,30 @@ class KoniExtension {
2098
2179
 
2099
2180
  // Parse transaction
2100
2181
 
2101
- parseSubstrateTransaction(_ref52) {
2182
+ parseSubstrateTransaction(_ref54) {
2102
2183
  let {
2103
2184
  data,
2104
2185
  networkKey
2105
- } = _ref52;
2186
+ } = _ref54;
2106
2187
  const apiProps = this.#koniState.getSubstrateApi(networkKey);
2107
2188
  const apiPromise = apiProps.api;
2108
2189
  return (0, _parseTransaction.parseSubstrateTransaction)(data, apiPromise);
2109
2190
  }
2110
- async parseEVMRLP(_ref53) {
2191
+ async parseEVMRLP(_ref55) {
2111
2192
  let {
2112
2193
  data
2113
- } = _ref53;
2194
+ } = _ref55;
2114
2195
  return await (0, _parseTransaction2.parseEvmRlp)(data, this.#koniState.getChainInfoMap(), this.#koniState.getEvmApiMap());
2115
2196
  }
2116
2197
 
2117
2198
  // Sign
2118
2199
 
2119
- qrSignSubstrate(_ref54) {
2200
+ qrSignSubstrate(_ref56) {
2120
2201
  let {
2121
2202
  address,
2122
2203
  data,
2123
2204
  networkKey
2124
- } = _ref54;
2205
+ } = _ref56;
2125
2206
  const pair = _uiKeyring.keyring.getPair(address);
2126
2207
  (0, _util.assert)(pair, 'Unable to find pair');
2127
2208
  if (pair.isLocked) {
@@ -2138,13 +2219,13 @@ class KoniExtension {
2138
2219
  signature: signed
2139
2220
  };
2140
2221
  }
2141
- async qrSignEVM(_ref55) {
2222
+ async qrSignEVM(_ref57) {
2142
2223
  let {
2143
2224
  address,
2144
2225
  chainId,
2145
2226
  message,
2146
2227
  type
2147
- } = _ref55;
2228
+ } = _ref57;
2148
2229
  let signed;
2149
2230
  const network = this.getNetworkJsonByChainId(chainId);
2150
2231
  if (!network) {
@@ -2225,11 +2306,11 @@ class KoniExtension {
2225
2306
  });
2226
2307
  return this.#koniState.getNominatorMetadata();
2227
2308
  }
2228
- async getBondingOptions(_ref56) {
2309
+ async getBondingOptions(_ref58) {
2229
2310
  let {
2230
2311
  chain,
2231
2312
  type
2232
- } = _ref56;
2313
+ } = _ref58;
2233
2314
  const apiProps = this.#koniState.getSubstrateApi(chain);
2234
2315
  const chainInfo = this.#koniState.getChainInfo(chain);
2235
2316
  const chainStakingMetadata = await this.#koniState.getStakingMetadataByChain(chain, type);
@@ -2418,12 +2499,12 @@ class KoniExtension {
2418
2499
  }
2419
2500
 
2420
2501
  // EVM Transaction
2421
- async parseContractInput(_ref57) {
2502
+ async parseContractInput(_ref59) {
2422
2503
  let {
2423
2504
  chainId,
2424
2505
  contract,
2425
2506
  data
2426
- } = _ref57;
2507
+ } = _ref59;
2427
2508
  const network = this.getNetworkJsonByChainId(chainId);
2428
2509
  return await (0, _parseTransaction2.parseContractInput)(data, contract, network);
2429
2510
  }
@@ -2494,12 +2575,12 @@ class KoniExtension {
2494
2575
 
2495
2576
  // Change master password
2496
2577
 
2497
- keyringChangeMasterPassword(_ref58) {
2578
+ keyringChangeMasterPassword(_ref60) {
2498
2579
  let {
2499
2580
  createNew,
2500
2581
  newPassword,
2501
2582
  oldPassword
2502
- } = _ref58;
2583
+ } = _ref60;
2503
2584
  try {
2504
2585
  // Remove isMasterPassword meta if createNew
2505
2586
  if (createNew) {
@@ -2533,11 +2614,11 @@ class KoniExtension {
2533
2614
 
2534
2615
  // Migrate password
2535
2616
 
2536
- keyringMigrateMasterPassword(_ref59) {
2617
+ keyringMigrateMasterPassword(_ref61) {
2537
2618
  let {
2538
2619
  address,
2539
2620
  password
2540
- } = _ref59;
2621
+ } = _ref61;
2541
2622
  try {
2542
2623
  _uiKeyring.keyring.migrateWithMasterPassword(address, password);
2543
2624
  } catch (e) {
@@ -2555,10 +2636,10 @@ class KoniExtension {
2555
2636
 
2556
2637
  // Unlock wallet
2557
2638
 
2558
- keyringUnlock(_ref60) {
2639
+ keyringUnlock(_ref62) {
2559
2640
  let {
2560
2641
  password
2561
- } = _ref60;
2642
+ } = _ref62;
2562
2643
  try {
2563
2644
  _uiKeyring.keyring.unlockKeyring(password);
2564
2645
  } catch (e) {
@@ -2584,11 +2665,11 @@ class KoniExtension {
2584
2665
 
2585
2666
  // Export mnemonic
2586
2667
 
2587
- keyringExportMnemonic(_ref61) {
2668
+ keyringExportMnemonic(_ref63) {
2588
2669
  let {
2589
2670
  address,
2590
2671
  password
2591
- } = _ref61;
2672
+ } = _ref63;
2592
2673
  const pair = _uiKeyring.keyring.getPair(address);
2593
2674
  const result = pair.exportMnemonic(password);
2594
2675
  return {
@@ -2598,10 +2679,10 @@ class KoniExtension {
2598
2679
 
2599
2680
  // Reset wallet
2600
2681
 
2601
- async resetWallet(_ref62) {
2682
+ async resetWallet(_ref64) {
2602
2683
  let {
2603
2684
  resetAll
2604
- } = _ref62;
2685
+ } = _ref64;
2605
2686
  try {
2606
2687
  await this.#koniState.resetWallet(resetAll);
2607
2688
  return {
@@ -2617,10 +2698,10 @@ class KoniExtension {
2617
2698
  }
2618
2699
 
2619
2700
  /// Signing external request
2620
- signingApprovePasswordV2(_ref63) {
2701
+ signingApprovePasswordV2(_ref65) {
2621
2702
  let {
2622
2703
  id
2623
- } = _ref63;
2704
+ } = _ref65;
2624
2705
  const queued = this.#koniState.getSignRequest(id);
2625
2706
  (0, _util.assert)(queued, 'Unable to find request');
2626
2707
  const {
@@ -2646,7 +2727,7 @@ class KoniExtension {
2646
2727
  const {
2647
2728
  payload
2648
2729
  } = request;
2649
- const registry = new _types.TypeRegistry();
2730
+ const registry = new _types2.TypeRegistry();
2650
2731
  let isEvm = false;
2651
2732
  if ((0, _Extension.isJsonPayload)(payload)) {
2652
2733
  // Get the metadata for the genesisHash
@@ -2673,22 +2754,22 @@ class KoniExtension {
2673
2754
 
2674
2755
  /// Derive account
2675
2756
 
2676
- derivationCreateMultiple(_ref64) {
2757
+ derivationCreateMultiple(_ref66) {
2677
2758
  let {
2678
2759
  isAllowed,
2679
2760
  items,
2680
2761
  parentAddress
2681
- } = _ref64;
2762
+ } = _ref66;
2682
2763
  const parentPair = _uiKeyring.keyring.getPair(parentAddress);
2683
2764
  const isEvm = parentPair.type === 'ethereum';
2684
2765
  if (parentPair.isLocked) {
2685
2766
  _uiKeyring.keyring.unlockPair(parentPair.address);
2686
2767
  }
2687
- const createChild = _ref65 => {
2768
+ const createChild = _ref67 => {
2688
2769
  let {
2689
2770
  name,
2690
2771
  suri
2691
- } = _ref65;
2772
+ } = _ref67;
2692
2773
  const meta = {
2693
2774
  name: name,
2694
2775
  parentAddress
@@ -2734,10 +2815,10 @@ class KoniExtension {
2734
2815
  }
2735
2816
  return true;
2736
2817
  }
2737
- derivationCreateV3(_ref66) {
2818
+ derivationCreateV3(_ref68) {
2738
2819
  let {
2739
2820
  address: parentAddress
2740
- } = _ref66;
2821
+ } = _ref68;
2741
2822
  const parentPair = _uiKeyring.keyring.getPair(parentAddress);
2742
2823
  const isEvm = parentPair.type === 'ethereum';
2743
2824
  if (parentPair.isLocked) {
@@ -2769,11 +2850,11 @@ class KoniExtension {
2769
2850
  });
2770
2851
  return true;
2771
2852
  }
2772
- validateDerivePath(_ref67) {
2853
+ validateDerivePath(_ref69) {
2773
2854
  let {
2774
2855
  parentAddress,
2775
2856
  suri
2776
- } = _ref67;
2857
+ } = _ref69;
2777
2858
  const parentPair = _uiKeyring.keyring.getPair(parentAddress);
2778
2859
  const isEvm = parentPair.type === 'ethereum';
2779
2860
  if (parentPair.isLocked) {
@@ -2806,12 +2887,12 @@ class KoniExtension {
2806
2887
  suri: meta.suri
2807
2888
  };
2808
2889
  }
2809
- getListDeriveAccounts(_ref68) {
2890
+ getListDeriveAccounts(_ref70) {
2810
2891
  let {
2811
2892
  limit,
2812
2893
  page,
2813
2894
  parentAddress
2814
- } = _ref68;
2895
+ } = _ref70;
2815
2896
  const parentPair = _uiKeyring.keyring.getPair(parentAddress);
2816
2897
  const isEvm = parentPair.type === 'ethereum';
2817
2898
  if (parentPair.isLocked) {
@@ -2902,10 +2983,10 @@ class KoniExtension {
2902
2983
  getSupportedSmartContractTypes() {
2903
2984
  return this.#koniState.getSupportedSmartContractTypes();
2904
2985
  }
2905
- getTransaction(_ref69) {
2986
+ getTransaction(_ref71) {
2906
2987
  let {
2907
2988
  id
2908
- } = _ref69;
2989
+ } = _ref71;
2909
2990
  const {
2910
2991
  transaction,
2911
2992
  ...transactionResult
@@ -2915,10 +2996,11 @@ class KoniExtension {
2915
2996
  subscribeTransactions(id, port) {
2916
2997
  const cb = (0, _subscriptions.createSubscription)(id, port);
2917
2998
  function convertRs(rs) {
2918
- return Object.fromEntries(Object.entries(rs).map(_ref70 => {
2919
- let [key, value] = _ref70;
2999
+ return Object.fromEntries(Object.entries(rs).map(_ref72 => {
3000
+ let [key, value] = _ref72;
2920
3001
  const {
2921
3002
  additionalValidator,
3003
+ eventsHandler,
2922
3004
  transaction,
2923
3005
  ...transactionResult
2924
3006
  } = value;
@@ -2947,10 +3029,10 @@ class KoniExtension {
2947
3029
  });
2948
3030
  return notificationSubject.value;
2949
3031
  }
2950
- async reloadCron(_ref71) {
3032
+ async reloadCron(_ref73) {
2951
3033
  let {
2952
3034
  data
2953
- } = _ref71;
3035
+ } = _ref73;
2954
3036
  if (data === 'nft') {
2955
3037
  return await this.#koniState.reloadNft();
2956
3038
  } else if (data === 'staking') {
@@ -2968,10 +3050,10 @@ class KoniExtension {
2968
3050
 
2969
3051
  // Phishing detect
2970
3052
 
2971
- async passPhishingPage(_ref72) {
3053
+ async passPhishingPage(_ref74) {
2972
3054
  let {
2973
3055
  url
2974
- } = _ref72;
3056
+ } = _ref74;
2975
3057
  return await this.#koniState.approvePassPhishingPage(url);
2976
3058
  }
2977
3059
 
@@ -52,7 +52,7 @@ const generateDefaultCrowdloanMap = () => {
52
52
  const crowdloanMap = {};
53
53
  Object.entries(_chainList.ChainInfoMap).forEach(_ref => {
54
54
  let [networkKey, chainInfo] = _ref;
55
- if ((0, _utils._isSubstrateParachain)(chainInfo)) {
55
+ if ((0, _utils._isSubstrateParaChain)(chainInfo)) {
56
56
  crowdloanMap[networkKey] = {
57
57
  state: _KoniTypes.APIItemState.PENDING,
58
58
  contribute: '0'
@@ -13,6 +13,6 @@ const packageInfo = {
13
13
  name: '@subwallet/extension-base',
14
14
  path: typeof __dirname === 'string' ? __dirname : 'auto',
15
15
  type: 'cjs',
16
- version: '1.0.7-1'
16
+ version: '1.0.8-0'
17
17
  };
18
18
  exports.packageInfo = packageInfo;