@subwallet/extension-base 1.1.2-1 → 1.1.3-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 (51) hide show
  1. package/background/KoniTypes.d.ts +18 -0
  2. package/background/KoniTypes.js +2 -1
  3. package/cjs/background/KoniTypes.js +4 -2
  4. package/cjs/koni/api/dotsama/transfer.js +0 -2
  5. package/cjs/koni/background/handlers/Extension.js +179 -120
  6. package/cjs/koni/background/handlers/State.js +73 -48
  7. package/cjs/packageInfo.js +1 -1
  8. package/cjs/services/chain-service/constants.js +2 -1
  9. package/cjs/services/chain-service/handler/SubstrateApi.js +8 -0
  10. package/cjs/services/chain-service/handler/manta/MantaPrivateHandler.js +1 -1
  11. package/cjs/services/chain-service/handler/manta/manta-extension-sdk-empty.js +13 -0
  12. package/cjs/services/chain-service/index.js +11 -6
  13. package/cjs/services/request-service/handler/PopupHandler.js +2 -2
  14. package/cjs/services/request-service/helper/index.js +2 -26
  15. package/cjs/services/storage-service/db-stores/Metadata.js +1 -1
  16. package/cjs/services/wallet-connect-service/constants.js +8 -5
  17. package/cjs/services/wallet-connect-service/index.js +50 -36
  18. package/cjs/utils/environment.js +32 -2
  19. package/cjs/utils/index.js +21 -5
  20. package/cjs/utils/registry.js +25 -0
  21. package/koni/api/dotsama/transfer.js +0 -2
  22. package/koni/background/handlers/Extension.d.ts +2 -0
  23. package/koni/background/handlers/Extension.js +72 -15
  24. package/koni/background/handlers/State.d.ts +7 -2
  25. package/koni/background/handlers/State.js +73 -48
  26. package/package.json +17 -6
  27. package/packageInfo.js +1 -1
  28. package/services/chain-service/constants.d.ts +1 -0
  29. package/services/chain-service/constants.js +2 -1
  30. package/services/chain-service/handler/SubstrateApi.js +8 -0
  31. package/services/chain-service/handler/manta/MantaPrivateHandler.d.ts +1 -1
  32. package/services/chain-service/handler/manta/MantaPrivateHandler.js +1 -1
  33. package/services/chain-service/handler/manta/manta-extension-sdk-empty.d.ts +4 -0
  34. package/services/chain-service/handler/manta/manta-extension-sdk-empty.js +5 -0
  35. package/services/chain-service/index.d.ts +2 -1
  36. package/services/chain-service/index.js +11 -6
  37. package/services/request-service/handler/PopupHandler.js +1 -1
  38. package/services/request-service/helper/index.d.ts +0 -2
  39. package/services/request-service/helper/index.js +0 -23
  40. package/services/request-service/types.d.ts +0 -1
  41. package/services/storage-service/db-stores/Metadata.js +1 -1
  42. package/services/wallet-connect-service/constants.d.ts +2 -1
  43. package/services/wallet-connect-service/constants.js +5 -3
  44. package/services/wallet-connect-service/index.d.ts +0 -1
  45. package/services/wallet-connect-service/index.js +50 -36
  46. package/utils/environment.d.ts +4 -1
  47. package/utils/environment.js +28 -1
  48. package/utils/index.d.ts +2 -0
  49. package/utils/index.js +4 -1
  50. package/utils/registry.d.ts +4 -0
  51. package/utils/registry.js +18 -0
@@ -920,6 +920,13 @@ class KoniExtension {
920
920
  this.#koniState.updateSetting('language', language);
921
921
  return true;
922
922
  }
923
+ setShowBalance(_ref33) {
924
+ let {
925
+ enable
926
+ } = _ref33;
927
+ this.#koniState.updateSetting('isShowBalance', enable);
928
+ return true;
929
+ }
923
930
  async subscribeAuthUrls(id, port) {
924
931
  const cb = (0, _subscriptions.createSubscription)(id, port);
925
932
  const authorizeUrlSubscription = this.#koniState.subscribeAuthorizeUrlSubject().subscribe({
@@ -1092,7 +1099,7 @@ class KoniExtension {
1092
1099
  }
1093
1100
  });
1094
1101
  }
1095
- async accountsCreateSuriV2(_ref33) {
1102
+ async accountsCreateSuriV2(_ref34) {
1096
1103
  let {
1097
1104
  genesisHash,
1098
1105
  isAllowed,
@@ -1100,7 +1107,7 @@ class KoniExtension {
1100
1107
  password,
1101
1108
  suri: _suri,
1102
1109
  types
1103
- } = _ref33;
1110
+ } = _ref34;
1104
1111
  const addressDict = {};
1105
1112
  let changedAccount = false;
1106
1113
  const hasMasterPassword = _uiKeyring.keyring.keyring.hasMasterPassword;
@@ -1148,10 +1155,10 @@ class KoniExtension {
1148
1155
  });
1149
1156
  return addressDict;
1150
1157
  }
1151
- async accountsForgetOverride(_ref34) {
1158
+ async accountsForgetOverride(_ref35) {
1152
1159
  let {
1153
1160
  address
1154
- } = _ref34;
1161
+ } = _ref35;
1155
1162
  _uiKeyring.keyring.forgetAccount(address);
1156
1163
  await new Promise(resolve => {
1157
1164
  this.#koniState.removeAccountRef(address, () => {
@@ -1184,12 +1191,12 @@ class KoniExtension {
1184
1191
  await this.#koniState.disableMantaPay(address);
1185
1192
  return true;
1186
1193
  }
1187
- seedCreateV2(_ref35) {
1194
+ seedCreateV2(_ref36) {
1188
1195
  let {
1189
1196
  length = _Extension.SEED_DEFAULT_LENGTH,
1190
1197
  seed: _seed,
1191
1198
  types
1192
- } = _ref35;
1199
+ } = _ref36;
1193
1200
  const seed = _seed || (0, _utilCrypto.mnemonicGenerate)(length);
1194
1201
  const rs = {
1195
1202
  seed: seed,
@@ -1200,11 +1207,11 @@ class KoniExtension {
1200
1207
  });
1201
1208
  return rs;
1202
1209
  }
1203
- seedValidateV2(_ref36) {
1210
+ seedValidateV2(_ref37) {
1204
1211
  let {
1205
1212
  suri,
1206
1213
  types
1207
- } = _ref36;
1214
+ } = _ref37;
1208
1215
  const {
1209
1216
  phrase
1210
1217
  } = (0, _utilCrypto.keyExtractSuri)(suri);
@@ -1224,11 +1231,11 @@ class KoniExtension {
1224
1231
  });
1225
1232
  return rs;
1226
1233
  }
1227
- _checkValidatePrivateKey(_ref37) {
1234
+ _checkValidatePrivateKey(_ref38) {
1228
1235
  let {
1229
1236
  suri,
1230
1237
  types
1231
- } = _ref37;
1238
+ } = _ref38;
1232
1239
  let autoAddPrefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1233
1240
  const {
1234
1241
  phrase
@@ -1251,11 +1258,11 @@ class KoniExtension {
1251
1258
  }
1252
1259
  return rs;
1253
1260
  }
1254
- metamaskPrivateKeyValidateV2(_ref38) {
1261
+ metamaskPrivateKeyValidateV2(_ref39) {
1255
1262
  let {
1256
1263
  suri,
1257
1264
  types
1258
- } = _ref38;
1265
+ } = _ref39;
1259
1266
  const isValidSuri = suri.startsWith('0x');
1260
1267
  if (isValidSuri) {
1261
1268
  return this._checkValidatePrivateKey({
@@ -1280,14 +1287,14 @@ class KoniExtension {
1280
1287
  throw new Error(`"${suri}" is not a valid derivation path`);
1281
1288
  }
1282
1289
  }
1283
- derivationCreateV2(_ref39) {
1290
+ derivationCreateV2(_ref40) {
1284
1291
  let {
1285
1292
  genesisHash,
1286
1293
  isAllowed,
1287
1294
  name,
1288
1295
  parentAddress,
1289
1296
  suri
1290
- } = _ref39;
1297
+ } = _ref40;
1291
1298
  const childPair = this.deriveV2(parentAddress, suri, {
1292
1299
  genesisHash,
1293
1300
  name,
@@ -1301,14 +1308,14 @@ class KoniExtension {
1301
1308
  });
1302
1309
  return true;
1303
1310
  }
1304
- jsonRestoreV2(_ref40) {
1311
+ jsonRestoreV2(_ref41) {
1305
1312
  let {
1306
1313
  address,
1307
1314
  file,
1308
1315
  isAllowed,
1309
1316
  password,
1310
1317
  withMasterPassword
1311
- } = _ref40;
1318
+ } = _ref41;
1312
1319
  const isPasswordValidated = this.validatePassword(file, password);
1313
1320
  if (isPasswordValidated) {
1314
1321
  try {
@@ -1323,13 +1330,13 @@ class KoniExtension {
1323
1330
  throw new Error('Unable to decode using the supplied passphrase');
1324
1331
  }
1325
1332
  }
1326
- batchRestoreV2(_ref41) {
1333
+ batchRestoreV2(_ref42) {
1327
1334
  let {
1328
1335
  accountsInfo,
1329
1336
  file,
1330
1337
  isAllowed,
1331
1338
  password
1332
- } = _ref41;
1339
+ } = _ref42;
1333
1340
  const addressList = accountsInfo.map(acc => acc.address);
1334
1341
  const isPasswordValidated = this.validatedAccountsPassword(file, password);
1335
1342
  if (isPasswordValidated) {
@@ -1530,6 +1537,8 @@ class KoniExtension {
1530
1537
 
1531
1538
  const additionalValidator = async inputTransaction => {
1532
1539
  const minAmount = tokenInfo.minAmount || '0';
1540
+
1541
+ // Check ed for sender
1533
1542
  if (!isTransferNativeToken) {
1534
1543
  const {
1535
1544
  value: balance
@@ -1545,10 +1554,12 @@ class KoniExtension {
1545
1554
  const {
1546
1555
  value: receiverBalance
1547
1556
  } = await this.getAddressFreeBalance({
1548
- address: from,
1557
+ address: to,
1549
1558
  networkKey,
1550
1559
  token: tokenSlug
1551
1560
  });
1561
+
1562
+ // Check ed for receiver
1552
1563
  if (new _bignumber.default(receiverBalance).plus(transferAmount.value).lt(minAmount)) {
1553
1564
  const atLeast = new _bignumber.default(minAmount).minus(receiverBalance).plus((tokenInfo.decimals || 0) === 0 ? 0 : 1);
1554
1565
  const atLeastStr = (0, _number.formatNumber)(atLeast, tokenInfo.decimals || 0, _number.balanceFormatter);
@@ -1612,16 +1623,24 @@ class KoniExtension {
1612
1623
  additionalValidator = async inputTransaction => {
1613
1624
  const destMinAmount = destinationTokenInfo.minAmount || '0';
1614
1625
  const atLeast = new _bignumber.default(destMinAmount).multipliedBy(_constants.XCM_MIN_AMOUNT_RATIO);
1626
+
1627
+ // Check ed for receiver
1615
1628
  if (new _bignumber.default(value).lt(atLeast)) {
1616
1629
  const atLeastStr = (0, _number.formatNumber)(atLeast, destinationTokenInfo.decimals || 0, _number.balanceFormatter);
1617
1630
  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`));
1618
1631
  }
1619
1632
  const srcMinAmount = originTokenInfo.minAmount || '0';
1620
1633
  const isTransferNativeToken = originTokenInfo.assetType === _types._AssetType.NATIVE;
1634
+
1635
+ // Check ed for sender
1621
1636
  if (!isTransferNativeToken) {
1622
1637
  const {
1623
1638
  value: balance
1624
- } = await this.#koniState.balanceService.getTokenFreeBalance(from, originNetworkKey, originTokenInfo.slug);
1639
+ } = await this.getAddressFreeBalance({
1640
+ address: from,
1641
+ networkKey: originNetworkKey,
1642
+ token: originTokenInfo.slug
1643
+ });
1625
1644
  if (new _bignumber.default(balance).minus(value).lt(srcMinAmount)) {
1626
1645
  inputTransaction.warnings.push(new _TransactionWarning.TransactionWarning(_KoniTypes.BasicTxWarningCode.NOT_ENOUGH_EXISTENTIAL_DEPOSIT, ''));
1627
1646
  }
@@ -1700,18 +1719,18 @@ class KoniExtension {
1700
1719
  disableChain(networkKey) {
1701
1720
  return this.#koniState.disableChain(networkKey);
1702
1721
  }
1703
- async enableChain(_ref42) {
1722
+ async enableChain(_ref43) {
1704
1723
  let {
1705
1724
  chainSlug,
1706
1725
  enableTokens
1707
- } = _ref42;
1726
+ } = _ref43;
1708
1727
  return await this.#koniState.enableChain(chainSlug, enableTokens);
1709
1728
  }
1710
- async validateNetwork(_ref43) {
1729
+ async validateNetwork(_ref44) {
1711
1730
  let {
1712
1731
  existedChainSlug,
1713
1732
  provider
1714
- } = _ref43;
1733
+ } = _ref44;
1715
1734
  return await this.#koniState.validateCustomChain(provider, existedChainSlug);
1716
1735
  }
1717
1736
  resetDefaultNetwork() {
@@ -1749,12 +1768,12 @@ class KoniExtension {
1749
1768
  async validateCustomAsset(data) {
1750
1769
  return await this.#koniState.validateCustomAsset(data);
1751
1770
  }
1752
- async getAddressFreeBalance(_ref44) {
1771
+ async getAddressFreeBalance(_ref45) {
1753
1772
  let {
1754
1773
  address,
1755
1774
  networkKey,
1756
1775
  token
1757
- } = _ref44;
1776
+ } = _ref45;
1758
1777
  if (token && _constants2._MANTA_ZK_CHAIN_GROUP.includes(networkKey)) {
1759
1778
  const tokenInfo = this.#koniState.chainService.getAssetBySlug(token);
1760
1779
  if (tokenInfo.symbol.startsWith(_constants2._ZK_ASSET_PREFIX)) {
@@ -1763,14 +1782,14 @@ class KoniExtension {
1763
1782
  }
1764
1783
  return await this.#koniState.balanceService.getTokenFreeBalance(address, networkKey, token);
1765
1784
  }
1766
- async transferGetMaxTransferable(_ref45) {
1785
+ async transferGetMaxTransferable(_ref46) {
1767
1786
  let {
1768
1787
  address,
1769
1788
  destChain,
1770
1789
  isXcmTransfer,
1771
1790
  networkKey,
1772
1791
  token
1773
- } = _ref45;
1792
+ } = _ref46;
1774
1793
  const freeBalance = await this.getAddressFreeBalance({
1775
1794
  address,
1776
1795
  networkKey,
@@ -1845,12 +1864,12 @@ class KoniExtension {
1845
1864
  };
1846
1865
  }
1847
1866
  }
1848
- async subscribeAddressFreeBalance(_ref46, id, port) {
1867
+ async subscribeAddressFreeBalance(_ref47, id, port) {
1849
1868
  let {
1850
1869
  address,
1851
1870
  networkKey,
1852
1871
  token
1853
- } = _ref46;
1872
+ } = _ref47;
1854
1873
  const cb = (0, _subscriptions.createSubscription)(id, port);
1855
1874
  const [unsub, currentFreeBalance] = await this.#koniState.balanceService.subscribeTokenFreeBalance(address, networkKey, token, cb);
1856
1875
  this.createUnsubscriptionHandle(id, unsub);
@@ -1859,26 +1878,26 @@ class KoniExtension {
1859
1878
  });
1860
1879
  return currentFreeBalance;
1861
1880
  }
1862
- async transferCheckReferenceCount(_ref47) {
1881
+ async transferCheckReferenceCount(_ref48) {
1863
1882
  let {
1864
1883
  address,
1865
1884
  networkKey
1866
- } = _ref47;
1885
+ } = _ref48;
1867
1886
  // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-return
1868
1887
  return await (0, _transfer.checkReferenceCount)(networkKey, address, this.#koniState.getSubstrateApiMap(), this.#koniState.getChainInfo(networkKey));
1869
1888
  }
1870
- async transferCheckSupporting(_ref48) {
1889
+ async transferCheckSupporting(_ref49) {
1871
1890
  let {
1872
1891
  networkKey,
1873
1892
  tokenSlug
1874
- } = _ref48;
1893
+ } = _ref49;
1875
1894
  const tokenInfo = this.#koniState.getAssetBySlug(tokenSlug);
1876
1895
  return await (0, _transfer.checkSupportTransfer)(networkKey, tokenInfo, this.#koniState.getSubstrateApiMap(), this.#koniState.getChainInfo(networkKey));
1877
1896
  }
1878
- transferGetExistentialDeposit(_ref49) {
1897
+ transferGetExistentialDeposit(_ref50) {
1879
1898
  let {
1880
1899
  tokenSlug
1881
- } = _ref49;
1900
+ } = _ref50;
1882
1901
  const tokenInfo = this.#koniState.getAssetBySlug(tokenSlug);
1883
1902
  return (0, _utils._getTokenMinAmount)(tokenInfo);
1884
1903
  }
@@ -1914,11 +1933,11 @@ class KoniExtension {
1914
1933
  isSendingSelf
1915
1934
  };
1916
1935
  }
1917
- async enableChains(_ref50) {
1936
+ async enableChains(_ref51) {
1918
1937
  let {
1919
1938
  chainSlugs,
1920
1939
  enableTokens
1921
- } = _ref50;
1940
+ } = _ref51;
1922
1941
  try {
1923
1942
  await Promise.all(chainSlugs.map(chainSlug => this.enableChain({
1924
1943
  chainSlug,
@@ -1929,24 +1948,24 @@ class KoniExtension {
1929
1948
  }
1930
1949
  return true;
1931
1950
  }
1932
- getAccountMeta(_ref51) {
1951
+ getAccountMeta(_ref52) {
1933
1952
  let {
1934
1953
  address
1935
- } = _ref51;
1954
+ } = _ref52;
1936
1955
  const pair = _uiKeyring.keyring.getPair(address);
1937
1956
  (0, _util.assert)(pair, 'Unable to find pair');
1938
1957
  return {
1939
1958
  meta: pair.meta
1940
1959
  };
1941
1960
  }
1942
- accountsTie2(_ref52) {
1961
+ accountsTie2(_ref53) {
1943
1962
  let {
1944
1963
  address,
1945
1964
  genesisHash
1946
- } = _ref52;
1965
+ } = _ref53;
1947
1966
  return this.#koniState.setAccountTie(address, genesisHash);
1948
1967
  }
1949
- async accountsCreateExternalV2(_ref53) {
1968
+ async accountsCreateExternalV2(_ref54) {
1950
1969
  let {
1951
1970
  address,
1952
1971
  genesisHash,
@@ -1954,7 +1973,7 @@ class KoniExtension {
1954
1973
  isEthereum,
1955
1974
  isReadOnly,
1956
1975
  name
1957
- } = _ref53;
1976
+ } = _ref54;
1958
1977
  try {
1959
1978
  let result;
1960
1979
  try {
@@ -2013,7 +2032,7 @@ class KoniExtension {
2013
2032
  }];
2014
2033
  }
2015
2034
  }
2016
- async accountsCreateHardwareV2(_ref54) {
2035
+ async accountsCreateHardwareV2(_ref55) {
2017
2036
  let {
2018
2037
  accountIndex,
2019
2038
  address,
@@ -2022,7 +2041,7 @@ class KoniExtension {
2022
2041
  hardwareType,
2023
2042
  isAllowed,
2024
2043
  name
2025
- } = _ref54;
2044
+ } = _ref55;
2026
2045
  const key = _uiKeyring.keyring.addHardware(address, hardwareType, {
2027
2046
  accountIndex,
2028
2047
  addressOffset,
@@ -2045,10 +2064,10 @@ class KoniExtension {
2045
2064
  });
2046
2065
  return true;
2047
2066
  }
2048
- async accountsCreateHardwareMultiple(_ref55) {
2067
+ async accountsCreateHardwareMultiple(_ref56) {
2049
2068
  let {
2050
2069
  accounts
2051
- } = _ref55;
2070
+ } = _ref56;
2052
2071
  const addresses = [];
2053
2072
  if (!accounts.length) {
2054
2073
  throw new Error('No accounts to import');
@@ -2126,14 +2145,14 @@ class KoniExtension {
2126
2145
  }
2127
2146
  return true;
2128
2147
  }
2129
- async accountsCreateWithSecret(_ref56) {
2148
+ async accountsCreateWithSecret(_ref57) {
2130
2149
  let {
2131
2150
  isAllow,
2132
2151
  isEthereum,
2133
2152
  name,
2134
2153
  publicKey,
2135
2154
  secretKey
2136
- } = _ref56;
2155
+ } = _ref57;
2137
2156
  try {
2138
2157
  let keyringPair = null;
2139
2158
  if (isEthereum) {
@@ -2276,30 +2295,30 @@ class KoniExtension {
2276
2295
 
2277
2296
  // Parse transaction
2278
2297
 
2279
- parseSubstrateTransaction(_ref57) {
2298
+ parseSubstrateTransaction(_ref58) {
2280
2299
  let {
2281
2300
  data,
2282
2301
  networkKey
2283
- } = _ref57;
2302
+ } = _ref58;
2284
2303
  const apiProps = this.#koniState.getSubstrateApi(networkKey);
2285
2304
  const apiPromise = apiProps.api;
2286
2305
  return (0, _parseTransaction.parseSubstrateTransaction)(data, apiPromise);
2287
2306
  }
2288
- async parseEVMRLP(_ref58) {
2307
+ async parseEVMRLP(_ref59) {
2289
2308
  let {
2290
2309
  data
2291
- } = _ref58;
2310
+ } = _ref59;
2292
2311
  return await (0, _parseTransaction2.parseEvmRlp)(data, this.#koniState.getChainInfoMap(), this.#koniState.getEvmApiMap());
2293
2312
  }
2294
2313
 
2295
2314
  // Sign
2296
2315
 
2297
- qrSignSubstrate(_ref59) {
2316
+ qrSignSubstrate(_ref60) {
2298
2317
  let {
2299
2318
  address,
2300
2319
  data,
2301
2320
  networkKey
2302
- } = _ref59;
2321
+ } = _ref60;
2303
2322
  const pair = _uiKeyring.keyring.getPair(address);
2304
2323
  (0, _util.assert)(pair, 'Unable to find pair');
2305
2324
  if (pair.isLocked) {
@@ -2316,13 +2335,13 @@ class KoniExtension {
2316
2335
  signature: signed
2317
2336
  };
2318
2337
  }
2319
- async qrSignEVM(_ref60) {
2338
+ async qrSignEVM(_ref61) {
2320
2339
  let {
2321
2340
  address,
2322
2341
  chainId,
2323
2342
  message,
2324
2343
  type
2325
- } = _ref60;
2344
+ } = _ref61;
2326
2345
  let signed;
2327
2346
  const network = this.getNetworkJsonByChainId(chainId);
2328
2347
  if (!network) {
@@ -2403,11 +2422,11 @@ class KoniExtension {
2403
2422
  });
2404
2423
  return this.#koniState.getNominatorMetadata();
2405
2424
  }
2406
- async getBondingOptions(_ref61) {
2425
+ async getBondingOptions(_ref62) {
2407
2426
  let {
2408
2427
  chain,
2409
2428
  type
2410
- } = _ref61;
2429
+ } = _ref62;
2411
2430
  const apiProps = this.#koniState.getSubstrateApi(chain);
2412
2431
  const chainInfo = this.#koniState.getChainInfo(chain);
2413
2432
  const chainStakingMetadata = await this.#koniState.getStakingMetadataByChain(chain, type);
@@ -2596,12 +2615,12 @@ class KoniExtension {
2596
2615
  }
2597
2616
 
2598
2617
  // EVM Transaction
2599
- async parseContractInput(_ref62) {
2618
+ async parseContractInput(_ref63) {
2600
2619
  let {
2601
2620
  chainId,
2602
2621
  contract,
2603
2622
  data
2604
- } = _ref62;
2623
+ } = _ref63;
2605
2624
  const network = this.getNetworkJsonByChainId(chainId);
2606
2625
  return await (0, _parseTransaction2.parseContractInput)(data, contract, network);
2607
2626
  }
@@ -2672,12 +2691,12 @@ class KoniExtension {
2672
2691
 
2673
2692
  // Change master password
2674
2693
 
2675
- keyringChangeMasterPassword(_ref63) {
2694
+ keyringChangeMasterPassword(_ref64) {
2676
2695
  let {
2677
2696
  createNew,
2678
2697
  newPassword,
2679
2698
  oldPassword
2680
- } = _ref63;
2699
+ } = _ref64;
2681
2700
  try {
2682
2701
  // Remove isMasterPassword meta if createNew
2683
2702
  if (createNew) {
@@ -2711,11 +2730,11 @@ class KoniExtension {
2711
2730
 
2712
2731
  // Migrate password
2713
2732
 
2714
- keyringMigrateMasterPassword(_ref64) {
2733
+ keyringMigrateMasterPassword(_ref65) {
2715
2734
  let {
2716
2735
  address,
2717
2736
  password
2718
- } = _ref64;
2737
+ } = _ref65;
2719
2738
  try {
2720
2739
  _uiKeyring.keyring.migrateWithMasterPassword(address, password);
2721
2740
  } catch (e) {
@@ -2733,10 +2752,10 @@ class KoniExtension {
2733
2752
 
2734
2753
  // Unlock wallet
2735
2754
 
2736
- keyringUnlock(_ref65) {
2755
+ keyringUnlock(_ref66) {
2737
2756
  let {
2738
2757
  password
2739
- } = _ref65;
2758
+ } = _ref66;
2740
2759
  try {
2741
2760
  _uiKeyring.keyring.unlockKeyring(password);
2742
2761
  this.#koniState.initMantaPay(password).catch(console.error);
@@ -2763,11 +2782,11 @@ class KoniExtension {
2763
2782
 
2764
2783
  // Export mnemonic
2765
2784
 
2766
- keyringExportMnemonic(_ref66) {
2785
+ keyringExportMnemonic(_ref67) {
2767
2786
  let {
2768
2787
  address,
2769
2788
  password
2770
- } = _ref66;
2789
+ } = _ref67;
2771
2790
  const pair = _uiKeyring.keyring.getPair(address);
2772
2791
  const result = pair.exportMnemonic(password);
2773
2792
  return {
@@ -2777,10 +2796,10 @@ class KoniExtension {
2777
2796
 
2778
2797
  // Reset wallet
2779
2798
 
2780
- async resetWallet(_ref67) {
2799
+ async resetWallet(_ref68) {
2781
2800
  let {
2782
2801
  resetAll
2783
- } = _ref67;
2802
+ } = _ref68;
2784
2803
  try {
2785
2804
  await this.#koniState.resetWallet(resetAll);
2786
2805
  return {
@@ -2796,10 +2815,10 @@ class KoniExtension {
2796
2815
  }
2797
2816
 
2798
2817
  /// Signing external request
2799
- signingApprovePasswordV2(_ref68) {
2818
+ signingApprovePasswordV2(_ref69) {
2800
2819
  let {
2801
2820
  id
2802
- } = _ref68;
2821
+ } = _ref69;
2803
2822
  const queued = this.#koniState.getSignRequest(id);
2804
2823
  (0, _util.assert)(queued, 'Unable to find request');
2805
2824
  const {
@@ -2825,7 +2844,7 @@ class KoniExtension {
2825
2844
  const {
2826
2845
  payload
2827
2846
  } = request;
2828
- const registry = new _types3.TypeRegistry();
2847
+ let registry = new _types3.TypeRegistry();
2829
2848
  let isEvm = false;
2830
2849
  if ((0, _Extension.isJsonPayload)(payload)) {
2831
2850
  // Get the metadata for the genesisHash
@@ -2837,6 +2856,15 @@ class KoniExtension {
2837
2856
  registry.register(currentMetadata === null || currentMetadata === void 0 ? void 0 : currentMetadata.types);
2838
2857
  }
2839
2858
  const [, chainInfo] = this.#koniState.findNetworkKeyByGenesisHash(payload.genesisHash);
2859
+ if (chainInfo && _constants2._API_OPTIONS_CHAIN_GROUP.avail.includes(chainInfo.slug)) {
2860
+ const isChainActive = this.#koniState.getChainStateByKey(chainInfo.slug).active;
2861
+ if (!isChainActive) {
2862
+ reject(new Error('Unable to sign'));
2863
+ return false;
2864
+ } else {
2865
+ registry = this.#koniState.getSubstrateApi(chainInfo.slug).api.registry;
2866
+ }
2867
+ }
2840
2868
  if (chainInfo) {
2841
2869
  isEvm = (0, _utils._isChainEvmCompatible)(chainInfo);
2842
2870
  }
@@ -2852,22 +2880,22 @@ class KoniExtension {
2852
2880
 
2853
2881
  /// Derive account
2854
2882
 
2855
- derivationCreateMultiple(_ref69) {
2883
+ derivationCreateMultiple(_ref70) {
2856
2884
  let {
2857
2885
  isAllowed,
2858
2886
  items,
2859
2887
  parentAddress
2860
- } = _ref69;
2888
+ } = _ref70;
2861
2889
  const parentPair = _uiKeyring.keyring.getPair(parentAddress);
2862
2890
  const isEvm = parentPair.type === 'ethereum';
2863
2891
  if (parentPair.isLocked) {
2864
2892
  _uiKeyring.keyring.unlockPair(parentPair.address);
2865
2893
  }
2866
- const createChild = _ref70 => {
2894
+ const createChild = _ref71 => {
2867
2895
  let {
2868
2896
  name,
2869
2897
  suri
2870
- } = _ref70;
2898
+ } = _ref71;
2871
2899
  const meta = {
2872
2900
  name: name,
2873
2901
  parentAddress
@@ -2913,10 +2941,10 @@ class KoniExtension {
2913
2941
  }
2914
2942
  return true;
2915
2943
  }
2916
- derivationCreateV3(_ref71) {
2944
+ derivationCreateV3(_ref72) {
2917
2945
  let {
2918
2946
  address: parentAddress
2919
- } = _ref71;
2947
+ } = _ref72;
2920
2948
  const parentPair = _uiKeyring.keyring.getPair(parentAddress);
2921
2949
  const isEvm = parentPair.type === 'ethereum';
2922
2950
  if (parentPair.isLocked) {
@@ -2948,11 +2976,11 @@ class KoniExtension {
2948
2976
  });
2949
2977
  return true;
2950
2978
  }
2951
- validateDerivePath(_ref72) {
2979
+ validateDerivePath(_ref73) {
2952
2980
  let {
2953
2981
  parentAddress,
2954
2982
  suri
2955
- } = _ref72;
2983
+ } = _ref73;
2956
2984
  const parentPair = _uiKeyring.keyring.getPair(parentAddress);
2957
2985
  const isEvm = parentPair.type === 'ethereum';
2958
2986
  if (parentPair.isLocked) {
@@ -2985,12 +3013,12 @@ class KoniExtension {
2985
3013
  suri: meta.suri
2986
3014
  };
2987
3015
  }
2988
- getListDeriveAccounts(_ref73) {
3016
+ getListDeriveAccounts(_ref74) {
2989
3017
  let {
2990
3018
  limit,
2991
3019
  page,
2992
3020
  parentAddress
2993
- } = _ref73;
3021
+ } = _ref74;
2994
3022
  const parentPair = _uiKeyring.keyring.getPair(parentAddress);
2995
3023
  const isEvm = parentPair.type === 'ethereum';
2996
3024
  if (parentPair.isLocked) {
@@ -3081,10 +3109,10 @@ class KoniExtension {
3081
3109
  getSupportedSmartContractTypes() {
3082
3110
  return this.#koniState.getSupportedSmartContractTypes();
3083
3111
  }
3084
- getTransaction(_ref74) {
3112
+ getTransaction(_ref75) {
3085
3113
  let {
3086
3114
  id
3087
- } = _ref74;
3115
+ } = _ref75;
3088
3116
  const {
3089
3117
  transaction,
3090
3118
  ...transactionResult
@@ -3094,8 +3122,8 @@ class KoniExtension {
3094
3122
  subscribeTransactions(id, port) {
3095
3123
  const cb = (0, _subscriptions.createSubscription)(id, port);
3096
3124
  function convertRs(rs) {
3097
- return Object.fromEntries(Object.entries(rs).map(_ref75 => {
3098
- let [key, value] = _ref75;
3125
+ return Object.fromEntries(Object.entries(rs).map(_ref76 => {
3126
+ let [key, value] = _ref76;
3099
3127
  const {
3100
3128
  additionalValidator,
3101
3129
  eventsHandler,
@@ -3127,10 +3155,10 @@ class KoniExtension {
3127
3155
  });
3128
3156
  return notificationSubject.value;
3129
3157
  }
3130
- async reloadCron(_ref76) {
3158
+ async reloadCron(_ref77) {
3131
3159
  let {
3132
3160
  data
3133
- } = _ref76;
3161
+ } = _ref77;
3134
3162
  if (data === 'nft') {
3135
3163
  return await this.#koniState.reloadNft();
3136
3164
  } else if (data === 'staking') {
@@ -3148,20 +3176,20 @@ class KoniExtension {
3148
3176
 
3149
3177
  // Phishing detect
3150
3178
 
3151
- async passPhishingPage(_ref77) {
3179
+ async passPhishingPage(_ref78) {
3152
3180
  let {
3153
3181
  url
3154
- } = _ref77;
3182
+ } = _ref78;
3155
3183
  return await this.#koniState.approvePassPhishingPage(url);
3156
3184
  }
3157
3185
 
3158
3186
  /// Wallet connect
3159
3187
 
3160
3188
  // Connect
3161
- async connectWalletConnect(_ref78) {
3189
+ async connectWalletConnect(_ref79) {
3162
3190
  let {
3163
3191
  uri
3164
- } = _ref78;
3192
+ } = _ref79;
3165
3193
  await this.#koniState.walletConnectService.connect(uri);
3166
3194
  return true;
3167
3195
  }
@@ -3174,11 +3202,11 @@ class KoniExtension {
3174
3202
  });
3175
3203
  return this.#koniState.requestService.allConnectWCRequests;
3176
3204
  }
3177
- async approveWalletConnectSession(_ref79) {
3205
+ async approveWalletConnectSession(_ref80) {
3178
3206
  let {
3179
3207
  accounts: selectedAccounts,
3180
3208
  id
3181
- } = _ref79;
3209
+ } = _ref80;
3182
3210
  const request = this.#koniState.requestService.getConnectWCRequest(id);
3183
3211
  if ((0, _helpers2.isProposalExpired)(request.request.params)) {
3184
3212
  throw new Error('The proposal has been expired');
@@ -3190,8 +3218,8 @@ class KoniExtension {
3190
3218
  const availableNamespaces = {};
3191
3219
  const namespaces = {};
3192
3220
  const chainInfoMap = this.#koniState.getChainInfoMap();
3193
- Object.entries(requiredNamespaces).forEach(_ref80 => {
3194
- let [key, namespace] = _ref80;
3221
+ Object.entries(requiredNamespaces).forEach(_ref81 => {
3222
+ let [key, namespace] = _ref81;
3195
3223
  if ((0, _helpers2.isSupportWalletConnectNamespace)(key)) {
3196
3224
  if (namespace.chains) {
3197
3225
  const unSupportChains = namespace.chains.filter(chain => !(0, _helpers2.isSupportWalletConnectChain)(chain, chainInfoMap));
@@ -3204,8 +3232,8 @@ class KoniExtension {
3204
3232
  throw new Error((0, _utils3.getSdkError)('UNSUPPORTED_NAMESPACE_KEY').message + ' ' + key);
3205
3233
  }
3206
3234
  });
3207
- Object.entries(optionalNamespaces).forEach(_ref81 => {
3208
- let [key, namespace] = _ref81;
3235
+ Object.entries(optionalNamespaces).forEach(_ref82 => {
3236
+ let [key, namespace] = _ref82;
3209
3237
  if ((0, _helpers2.isSupportWalletConnectNamespace)(key)) {
3210
3238
  if (namespace.chains) {
3211
3239
  const supportChains = namespace.chains.filter(chain => (0, _helpers2.isSupportWalletConnectChain)(chain, chainInfoMap)) || [];
@@ -3229,8 +3257,8 @@ class KoniExtension {
3229
3257
  }
3230
3258
  }
3231
3259
  });
3232
- Object.entries(availableNamespaces).forEach(_ref82 => {
3233
- let [key, namespace] = _ref82;
3260
+ Object.entries(availableNamespaces).forEach(_ref83 => {
3261
+ let [key, namespace] = _ref83;
3234
3262
  if (namespace.chains) {
3235
3263
  const accounts = [];
3236
3264
  const chains = (0, _utils2.uniqueStringArray)(namespace.chains);
@@ -3254,10 +3282,10 @@ class KoniExtension {
3254
3282
  request.resolve();
3255
3283
  return true;
3256
3284
  }
3257
- async rejectWalletConnectSession(_ref83) {
3285
+ async rejectWalletConnectSession(_ref84) {
3258
3286
  let {
3259
3287
  id
3260
- } = _ref83;
3288
+ } = _ref84;
3261
3289
  const request = this.#koniState.requestService.getConnectWCRequest(id);
3262
3290
  const wcId = request.request.id;
3263
3291
  if ((0, _helpers2.isProposalExpired)(request.request.params)) {
@@ -3279,23 +3307,24 @@ class KoniExtension {
3279
3307
  });
3280
3308
  return this.#koniState.walletConnectService.sessions;
3281
3309
  }
3282
- async disconnectWalletConnectSession(_ref84) {
3310
+ async disconnectWalletConnectSession(_ref85) {
3283
3311
  let {
3284
3312
  topic
3285
- } = _ref84;
3313
+ } = _ref85;
3286
3314
  await this.#koniState.walletConnectService.disconnect(topic);
3287
3315
  return true;
3288
3316
  }
3289
- async enableMantaPay(_ref85) {
3317
+ async enableMantaPay(_ref86) {
3290
3318
  let {
3291
3319
  address,
3292
3320
  password
3293
- } = _ref85;
3321
+ } = _ref86;
3294
3322
  // always takes the current account
3295
3323
  function timeout() {
3296
3324
  return new Promise(resolve => setTimeout(resolve, 1500));
3297
3325
  }
3298
3326
  try {
3327
+ var _this$koniState$chain, _this$koniState$chain2;
3299
3328
  await this.#koniState.chainService.enableChain(_constants2._DEFAULT_MANTA_ZK_CHAIN);
3300
3329
  this.#koniState.chainService.setMantaZkAssetSettings(true);
3301
3330
  const mnemonic = this.keyringExportMnemonic({
@@ -3314,16 +3343,16 @@ class KoniExtension {
3314
3343
  await this.saveCurrentAccountAddress({
3315
3344
  address
3316
3345
  });
3317
- const unsubSyncProgress = await this.#koniState.chainService.mantaPay.subscribeSyncProgress();
3346
+ const unsubSyncProgress = await ((_this$koniState$chain = this.#koniState.chainService) === null || _this$koniState$chain === void 0 ? void 0 : (_this$koniState$chain2 = _this$koniState$chain.mantaPay) === null || _this$koniState$chain2 === void 0 ? void 0 : _this$koniState$chain2.subscribeSyncProgress());
3318
3347
  console.debug('Start initial sync for MantaPay');
3319
3348
  this.#koniState.initialSyncMantaPay(address).then(() => {
3320
3349
  console.debug('Finished initial sync for MantaPay');
3321
3350
  this.#skipAutoLock = false;
3322
- unsubSyncProgress();
3351
+ unsubSyncProgress && unsubSyncProgress();
3323
3352
  }).catch(e => {
3324
3353
  console.error('Error syncing MantaPay', e);
3325
3354
  this.#skipAutoLock = false;
3326
- unsubSyncProgress();
3355
+ unsubSyncProgress && unsubSyncProgress();
3327
3356
  });
3328
3357
  return {
3329
3358
  success: !!result,
@@ -3345,29 +3374,32 @@ class KoniExtension {
3345
3374
  }
3346
3375
  }
3347
3376
  async initSyncMantaPay(address) {
3348
- if (this.#koniState.chainService.mantaPay.getSyncState().isSyncing) {
3377
+ var _this$koniState$chain3, _this$koniState$chain4, _this$koniState$chain5, _this$koniState$chain6;
3378
+ 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) {
3349
3379
  return;
3350
3380
  }
3351
3381
  this.#skipAutoLock = true;
3352
3382
  await this.saveCurrentAccountAddress({
3353
3383
  address
3354
3384
  });
3355
- const unsubSyncProgress = await this.#koniState.chainService.mantaPay.subscribeSyncProgress();
3385
+ const unsubSyncProgress = await ((_this$koniState$chain5 = this.#koniState.chainService) === null || _this$koniState$chain5 === void 0 ? void 0 : (_this$koniState$chain6 = _this$koniState$chain5.mantaPay) === null || _this$koniState$chain6 === void 0 ? void 0 : _this$koniState$chain6.subscribeSyncProgress());
3356
3386
  console.debug('Start initial sync for MantaPay');
3357
3387
  this.#koniState.initialSyncMantaPay(address).then(() => {
3388
+ var _this$koniState$chain7, _this$koniState$chain8;
3358
3389
  console.debug('Finished initial sync for MantaPay');
3359
3390
  this.#skipAutoLock = false;
3360
- unsubSyncProgress();
3391
+ unsubSyncProgress && unsubSyncProgress();
3361
3392
  // make sure the sync state is set, just in case it gets unsubscribed
3362
- this.#koniState.chainService.mantaPay.setSyncState({
3393
+ (_this$koniState$chain7 = this.#koniState.chainService) === null || _this$koniState$chain7 === void 0 ? void 0 : (_this$koniState$chain8 = _this$koniState$chain7.mantaPay) === null || _this$koniState$chain8 === void 0 ? void 0 : _this$koniState$chain8.setSyncState({
3363
3394
  progress: 100,
3364
3395
  isSyncing: false
3365
3396
  });
3366
3397
  }).catch(e => {
3398
+ var _this$koniState$chain9, _this$koniState$chain10;
3367
3399
  console.error('Error syncing MantaPay', e);
3368
3400
  this.#skipAutoLock = false;
3369
- unsubSyncProgress();
3370
- this.#koniState.chainService.mantaPay.setSyncState({
3401
+ unsubSyncProgress && unsubSyncProgress();
3402
+ (_this$koniState$chain9 = this.#koniState.chainService) === null || _this$koniState$chain9 === void 0 ? void 0 : (_this$koniState$chain10 = _this$koniState$chain9.mantaPay) === null || _this$koniState$chain10 === void 0 ? void 0 : _this$koniState$chain10.setSyncState({
3371
3403
  progress: 0,
3372
3404
  isSyncing: false
3373
3405
  });
@@ -3390,8 +3422,9 @@ class KoniExtension {
3390
3422
  return this.#koniState.getMantaPayConfig('calamari');
3391
3423
  }
3392
3424
  subscribeMantaPaySyncState(id, port) {
3425
+ var _this$koniState$subsc, _this$koniState$chain11, _this$koniState$chain12;
3393
3426
  const cb = (0, _subscriptions.createSubscription)(id, port);
3394
- const syncingStateSubscription = this.#koniState.subscribeMantaPaySyncState().subscribe({
3427
+ const syncingStateSubscription = (_this$koniState$subsc = this.#koniState.subscribeMantaPaySyncState()) === null || _this$koniState$subsc === void 0 ? void 0 : _this$koniState$subsc.subscribe({
3395
3428
  next: rs => {
3396
3429
  cb(rs);
3397
3430
  }
@@ -3400,7 +3433,27 @@ class KoniExtension {
3400
3433
  port.onDisconnect.addListener(() => {
3401
3434
  this.cancelSubscription(id);
3402
3435
  });
3403
- return this.#koniState.chainService.mantaPay.getSyncState();
3436
+ return ((_this$koniState$chain11 = this.#koniState.chainService) === null || _this$koniState$chain11 === void 0 ? void 0 : (_this$koniState$chain12 = _this$koniState$chain11.mantaPay) === null || _this$koniState$chain12 === void 0 ? void 0 : _this$koniState$chain12.getSyncState()) || {
3437
+ isSyncing: false,
3438
+ progress: 0,
3439
+ needManualSync: false
3440
+ };
3441
+ }
3442
+
3443
+ /// Metadata
3444
+
3445
+ async findRawMetadata(_ref87) {
3446
+ let {
3447
+ genesisHash
3448
+ } = _ref87;
3449
+ const {
3450
+ metadata,
3451
+ specVersion
3452
+ } = await this.#koniState.findMetadata(genesisHash);
3453
+ return {
3454
+ rawMetadata: metadata,
3455
+ specVersion
3456
+ };
3404
3457
  }
3405
3458
 
3406
3459
  // --------------------------------------------------------------
@@ -3512,6 +3565,8 @@ class KoniExtension {
3512
3565
  return this.setShowZeroBalance(request);
3513
3566
  case 'pri(settings.saveLanguage)':
3514
3567
  return this.setLanguage(request);
3568
+ case 'pri(settings.saveShowBalance)':
3569
+ return this.setShowBalance(request);
3515
3570
  case 'pri(price.getPrice)':
3516
3571
  return await this.getPrice();
3517
3572
  case 'pri(price.getSubscription)':
@@ -3805,6 +3860,10 @@ class KoniExtension {
3805
3860
  return await this.disableMantaPay(request);
3806
3861
  case 'pri(mantaPay.subscribeSyncingState)':
3807
3862
  return this.subscribeMantaPaySyncState(id, port);
3863
+
3864
+ // Metadata
3865
+ case 'pri(metadata.find)':
3866
+ return this.findRawMetadata(request);
3808
3867
  // Default
3809
3868
  default:
3810
3869
  throw new Error(`Unable to handle message of type ${type}`);