@subwallet/extension-base 1.1.38-1 → 1.1.39-beta.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 (67) hide show
  1. package/background/KoniTypes.d.ts +2 -0
  2. package/background/types.d.ts +1 -0
  3. package/cjs/koni/api/dotsama/balance.js +464 -0
  4. package/cjs/koni/api/nft/unique_network_nft/index.js +4 -0
  5. package/cjs/koni/background/handlers/Extension.js +64 -13
  6. package/cjs/koni/background/handlers/State.js +6 -5
  7. package/cjs/packageInfo.js +1 -1
  8. package/cjs/services/balance-service/helpers/subscribe/balance.js +1 -1
  9. package/cjs/services/chain-service/health-check/constants/index.js +36 -0
  10. package/cjs/services/chain-service/health-check/utils/asset-info.js +282 -0
  11. package/cjs/services/chain-service/health-check/utils/chain-info.js +36 -0
  12. package/cjs/services/chain-service/health-check/utils/index.js +38 -0
  13. package/cjs/services/chain-service/health-check/utils/provider.js +186 -0
  14. package/cjs/services/chain-service/index.js +61 -51
  15. package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +42 -26
  16. package/cjs/services/earning-service/service.js +9 -2
  17. package/cjs/services/migration-service/scripts/MigrateEthProvider.js +17 -0
  18. package/cjs/services/migration-service/scripts/MigratePioneerProvider.js +17 -0
  19. package/cjs/services/migration-service/scripts/MigrateProvider.js +29 -0
  20. package/cjs/services/storage-service/index.js +241 -0
  21. package/cjs/services/transaction-service/index.js +6 -4
  22. package/cjs/types.js +1 -0
  23. package/cjs/utils/address.js +34 -0
  24. package/cjs/utils/eth/mergeTransactionAndSignature.js +8 -3
  25. package/cjs/utils/index.js +6 -5
  26. package/cjs/utils/keyring.js +57 -0
  27. package/cjs/utils/staticData/index.js +5 -5
  28. package/koni/api/nft/unique_network_nft/index.d.ts +1 -0
  29. package/koni/api/nft/unique_network_nft/index.js +5 -1
  30. package/koni/api/staking/bonding/utils.d.ts +0 -1
  31. package/koni/background/handlers/Extension.d.ts +1 -0
  32. package/koni/background/handlers/Extension.js +64 -13
  33. package/koni/background/handlers/State.js +2 -1
  34. package/package.json +42 -17
  35. package/packageInfo.js +1 -1
  36. package/services/balance-service/helpers/subscribe/balance.js +1 -1
  37. package/services/chain-service/health-check/constants/index.d.ts +4 -0
  38. package/services/chain-service/health-check/constants/index.js +26 -0
  39. package/services/chain-service/health-check/utils/asset-info.d.ts +14 -0
  40. package/services/chain-service/health-check/utils/asset-info.js +269 -0
  41. package/services/chain-service/health-check/utils/chain-info.d.ts +8 -0
  42. package/services/chain-service/health-check/utils/chain-info.js +28 -0
  43. package/services/chain-service/health-check/utils/index.d.ts +3 -0
  44. package/services/chain-service/health-check/utils/index.js +6 -0
  45. package/services/chain-service/health-check/utils/provider.d.ts +25 -0
  46. package/services/chain-service/health-check/utils/provider.js +172 -0
  47. package/services/chain-service/index.d.ts +7 -3
  48. package/services/chain-service/index.js +52 -43
  49. package/services/chain-service/types.d.ts +4 -0
  50. package/services/earning-service/handlers/native-staking/relay-chain.d.ts +0 -1
  51. package/services/earning-service/handlers/native-staking/relay-chain.js +42 -26
  52. package/services/earning-service/handlers/special.d.ts +0 -1
  53. package/services/earning-service/service.js +10 -3
  54. package/services/transaction-service/index.js +6 -4
  55. package/types/balance.d.ts +0 -1
  56. package/types/yield/info/pallet.d.ts +4 -1
  57. package/utils/eth/mergeTransactionAndSignature.js +8 -3
  58. package/utils/index.d.ts +1 -2
  59. package/utils/index.js +6 -5
  60. package/utils/staticData/buyServiceInfos.json +0 -1
  61. package/utils/staticData/buyTokenConfigs.json +0 -15
  62. package/utils/staticData/chains.json +192 -89
  63. package/utils/staticData/crowdloanFunds.json +433 -58
  64. package/utils/staticData/index.d.ts +1 -2
  65. package/utils/staticData/index.js +4 -3
  66. package/utils/staticData/marketingCampaigns.json +1 -298
  67. package/utils/staticData/termAndCondition.json +1 -1
@@ -346,13 +346,14 @@ class TransactionService {
346
346
  transactionToHistories(id, startBlock, nonce, eventLogs) {
347
347
  const transaction = this.getTransaction(id);
348
348
  const extrinsicType = transaction.extrinsicType;
349
+ const chainInfo = this.state.chainService.getChainInfoByKey(transaction.chain);
349
350
  const formattedTransactionAddress = (0, _utils3.reformatAddress)(transaction.address);
350
351
  const historyItem = {
351
352
  origin: 'app',
352
353
  chain: transaction.chain,
353
354
  direction: _KoniTypes.TransactionDirection.SEND,
354
355
  type: transaction.extrinsicType,
355
- from: formattedTransactionAddress,
356
+ from: transaction.address,
356
357
  to: '',
357
358
  chainType: transaction.chainType,
358
359
  address: formattedTransactionAddress,
@@ -368,7 +369,6 @@ class TransactionService {
368
369
  nonce: nonce !== null && nonce !== void 0 ? nonce : 0,
369
370
  startBlock: startBlock || 0
370
371
  };
371
- const chainInfo = this.state.chainService.getChainInfoByKey(transaction.chain);
372
372
  const nativeAsset = (0, _utils._getChainNativeTokenBasicInfo)(chainInfo);
373
373
  const baseNativeAmount = {
374
374
  value: '0',
@@ -874,7 +874,8 @@ class TransactionService {
874
874
  to: transaction.to !== undefined ? transaction.to : '',
875
875
  value: (0, _ethereumjsUtil.addHexPrefix)((0, _eth.anyNumberToBN)(transaction.value).toString(16)),
876
876
  data: transaction.data,
877
- chainId: (0, _utils._getEvmChainId)(chainInfo)
877
+ chainId: (0, _utils._getEvmChainId)(chainInfo),
878
+ type: 2
878
879
  };
879
880
  } else {
880
881
  var _transaction$nonce2;
@@ -885,7 +886,8 @@ class TransactionService {
885
886
  to: transaction.to !== undefined ? transaction.to : '',
886
887
  value: (0, _ethereumjsUtil.addHexPrefix)((0, _eth.anyNumberToBN)(transaction.value).toString(16)),
887
888
  data: transaction.data,
888
- chainId: (0, _utils._getEvmChainId)(chainInfo)
889
+ chainId: (0, _utils._getEvmChainId)(chainInfo),
890
+ type: 0
889
891
  };
890
892
  }
891
893
  return _ethers.ethers.Transaction.from(txObject).unsignedSerialized;
package/cjs/types.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.convertSubjectInfoToAddresses = void 0;
7
+ exports.quickFormatAddressToCompare = quickFormatAddressToCompare;
8
+ exports.simpleAddress = void 0;
9
+ var _index = require("@subwallet/extension-base/utils/index");
10
+ var _utilCrypto = require("@polkadot/util-crypto");
11
+ // Copyright 2019-2022 @subwallet/extension-base authors & contributors
12
+ // SPDX-License-Identifier: Apache-2.0
13
+
14
+ const simpleAddress = address => {
15
+ if ((0, _utilCrypto.isEthereumAddress)(address)) {
16
+ return address;
17
+ }
18
+ return (0, _utilCrypto.encodeAddress)((0, _utilCrypto.decodeAddress)(address));
19
+ };
20
+ exports.simpleAddress = simpleAddress;
21
+ function quickFormatAddressToCompare(address) {
22
+ if (!(0, _utilCrypto.isAddress)(address)) {
23
+ return address;
24
+ }
25
+ return (0, _index.reformatAddress)(address, 42).toLowerCase();
26
+ }
27
+ const convertSubjectInfoToAddresses = subjectInfo => {
28
+ return Object.values(subjectInfo).map(info => ({
29
+ address: info.json.address,
30
+ type: info.type,
31
+ ...info.json.meta
32
+ }));
33
+ };
34
+ exports.convertSubjectInfoToAddresses = convertSubjectInfoToAddresses;
@@ -4,6 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.mergeTransactionAndSignature = void 0;
7
+ var _utils = require("@subwallet/extension-base/utils");
8
+ var _eth = require("@subwallet/extension-base/utils/eth");
7
9
  var _ethereumjsUtil = require("ethereumjs-util");
8
10
  var _ethers = require("ethers");
9
11
  // Copyright 2019-2022 @subwallet/extension-base authors & contributors
@@ -17,7 +19,8 @@ const mergeTransactionAndSignature = (tx, _rawSignature) => {
17
19
  v: parseInt(`0x${_signature.substring(128)}`)
18
20
  };
19
21
  let transaction;
20
- if (tx.maxFeePerGas) {
22
+ const max = (0, _eth.anyNumberToBN)(tx.maxFeePerGas);
23
+ if (max.gt(_utils.BN_ZERO)) {
21
24
  transaction = {
22
25
  nonce: tx.nonce,
23
26
  maxFeePerGas: (0, _ethereumjsUtil.addHexPrefix)(tx.maxFeePerGas.toString(16)),
@@ -27,7 +30,8 @@ const mergeTransactionAndSignature = (tx, _rawSignature) => {
27
30
  value: (0, _ethereumjsUtil.addHexPrefix)(tx.value.toString(16)),
28
31
  data: tx.data,
29
32
  chainId: tx.chainId,
30
- signature: signature
33
+ signature: signature,
34
+ type: 2
31
35
  };
32
36
  } else {
33
37
  transaction = {
@@ -38,7 +42,8 @@ const mergeTransactionAndSignature = (tx, _rawSignature) => {
38
42
  value: (0, _ethereumjsUtil.addHexPrefix)(tx.value.toString(16)),
39
43
  data: tx.data,
40
44
  chainId: tx.chainId,
41
- signature: signature
45
+ signature: signature,
46
+ type: 0
42
47
  };
43
48
  }
44
49
  return _ethers.ethers.Transaction.from(transaction).serialized;
@@ -510,7 +510,8 @@ const stripUrl = url => {
510
510
  return parts[2];
511
511
  };
512
512
  exports.stripUrl = stripUrl;
513
- const baseParseIPFSUrl = input => {
513
+ const baseParseIPFSUrl = (input, customDomain) => {
514
+ const selectedDomain = customDomain || (0, _config.getRandomIpfsGateway)();
514
515
  if (!input || input.length === 0) {
515
516
  return undefined;
516
517
  }
@@ -521,17 +522,17 @@ const baseParseIPFSUrl = input => {
521
522
  return input;
522
523
  }
523
524
  if (input.startsWith('/ipfs/')) {
524
- return (0, _config.getRandomIpfsGateway)() + input.split('/ipfs/')[1];
525
+ return selectedDomain + input.split('/ipfs/')[1];
525
526
  }
526
527
  if (!input.includes('ipfs://') && !input.includes('ipfs://ipfs/')) {
527
528
  // just the IPFS hash
528
- return (0, _config.getRandomIpfsGateway)() + input;
529
+ return selectedDomain + input;
529
530
  }
530
531
  if (input.includes('ipfs://') && !input.includes('ipfs://ipfs/')) {
531
532
  // starts with ipfs://
532
- return (0, _config.getRandomIpfsGateway)() + input.split('ipfs://')[1];
533
+ return selectedDomain + input.split('ipfs://')[1];
533
534
  }
534
- return (0, _config.getRandomIpfsGateway)() + input.split('ipfs://ipfs/')[1]; // starts with ipfs://ipfs/
535
+ return selectedDomain + input.split('ipfs://ipfs/')[1]; // starts with ipfs://ipfs/
535
536
  };
536
537
  exports.baseParseIPFSUrl = baseParseIPFSUrl;
537
538
  const swParseIPFSUrl = input => {
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.extractPrivateKey = extractPrivateKey;
7
+ exports.unlockAccount = exports.lockAccount = void 0;
8
+ var _uiKeyring = require("@subwallet/ui-keyring");
9
+ // Copyright 2019-2022 @subwallet/extension-base
10
+ // SPDX-License-Identifier: Apache-2.0
11
+
12
+ // import _decode from '@polkadot/keyring/pair/decode';
13
+
14
+ function extract(address) {
15
+ // @ts-ignore
16
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
17
+ const rs = this.getPair(address);
18
+
19
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
20
+ console.log(rs.publicKey);
21
+ }
22
+ function extractPrivateKey(keyring, address, password) {
23
+ extract.call(keyring, address);
24
+ }
25
+ const unlockAccount = signAddress => {
26
+ let publicKey;
27
+ try {
28
+ publicKey = _uiKeyring.keyring.decodeAddress(signAddress);
29
+ } catch (error) {
30
+ console.error(error);
31
+ return 'Unable to decode address';
32
+ }
33
+ const pair = _uiKeyring.keyring.getPair(publicKey);
34
+ if (!pair) {
35
+ return 'Unable to find pair';
36
+ }
37
+ if (pair.isLocked) {
38
+ try {
39
+ _uiKeyring.keyring.unlockPair(pair.address);
40
+ } catch (e) {
41
+ return e.message;
42
+ }
43
+ }
44
+ return null;
45
+ };
46
+ exports.unlockAccount = unlockAccount;
47
+ const lockAccount = address => {
48
+ try {
49
+ const pair = _uiKeyring.keyring.getPair(address);
50
+ if (pair) {
51
+ pair.lock();
52
+ }
53
+ } catch (error) {
54
+ console.error('Unable to lock account', error);
55
+ }
56
+ };
57
+ exports.lockAccount = lockAccount;
@@ -3,20 +3,20 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.termAndCondition = exports.staticData = exports.marketingCampaigns = exports.crowdloanFunds = exports.chains = exports.buyTokenConfigs = exports.buyServiceInfos = exports.StaticKey = void 0;
6
+ exports.termAndCondition = exports.staticData = exports.marketingCampaigns = exports.crowdloanFunds = exports.buyTokenConfigs = exports.buyServiceInfos = exports.StaticKey = void 0;
7
+ var _chainList = require("@subwallet/chain-list");
7
8
  // Copyright 2019-2022 @subwallet/extension-base authors & contributors
8
9
  // SPDX-License-Identifier: Apache-2.0
9
10
 
10
11
  // eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
12
+
13
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-var-requires
11
14
  const buyServiceInfos = require('./buyServiceInfos.json');
12
15
  // eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
13
16
  exports.buyServiceInfos = buyServiceInfos;
14
17
  const buyTokenConfigs = require('./buyTokenConfigs.json');
15
18
  // eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
16
19
  exports.buyTokenConfigs = buyTokenConfigs;
17
- const chains = require('./chains.json');
18
- // eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
19
- exports.chains = chains;
20
20
  const crowdloanFunds = require('./crowdloanFunds.json');
21
21
  // eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
22
22
  exports.crowdloanFunds = crowdloanFunds;
@@ -36,7 +36,7 @@ exports.StaticKey = StaticKey;
36
36
  StaticKey["BUY_TOKEN_CONFIGS"] = "buy-token-configs";
37
37
  })(StaticKey || (exports.StaticKey = StaticKey = {}));
38
38
  const staticData = {
39
- [StaticKey.CHAINS]: chains,
39
+ [StaticKey.CHAINS]: Object.values(_chainList.ChainInfoMap),
40
40
  [StaticKey.BUY_SERVICE_INFOS]: buyServiceInfos,
41
41
  [StaticKey.CROWDLOAN_FUNDS]: crowdloanFunds,
42
42
  [StaticKey.MARKETING_CAMPAINGS]: marketingCampaigns,
@@ -1,6 +1,7 @@
1
1
  import { BaseNftApi, HandleNftParams } from '@subwallet/extension-base/koni/api/nft/nft';
2
2
  export declare class UniqueNftApi extends BaseNftApi {
3
3
  constructor(chain: string, addresses: string[]);
4
+ parseUrl(input: string): string | undefined;
4
5
  private handleProperties;
5
6
  private static parseNftRequest;
6
7
  private getNftByAccount;
@@ -1,14 +1,18 @@
1
1
  // Copyright 2019-2022 @subwallet/extension-koni authors & contributors
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { OPAL_SCAN_ENDPOINT, QUARTZ_SCAN_ENDPOINT, UNIQUE_SCAN_ENDPOINT } from '@subwallet/extension-base/koni/api/nft/config';
4
+ import { OPAL_SCAN_ENDPOINT, QUARTZ_SCAN_ENDPOINT, UNIQUE_IPFS_GATEWAY, UNIQUE_SCAN_ENDPOINT } from '@subwallet/extension-base/koni/api/nft/config';
5
5
  import { BaseNftApi } from '@subwallet/extension-base/koni/api/nft/nft';
6
+ import { baseParseIPFSUrl } from '@subwallet/extension-base/utils';
6
7
  import fetch from 'cross-fetch';
7
8
  import { decodeAddress, encodeAddress } from '@polkadot/util-crypto';
8
9
  export class UniqueNftApi extends BaseNftApi {
9
10
  constructor(chain, addresses) {
10
11
  super(chain, undefined, addresses);
11
12
  }
13
+ parseUrl(input) {
14
+ return baseParseIPFSUrl(input, UNIQUE_IPFS_GATEWAY);
15
+ }
12
16
  handleProperties(nft) {
13
17
  const propertiesMap = {};
14
18
  const attRecord = nft.attributes;
@@ -1,4 +1,3 @@
1
- /// <reference types="bn.js" />
2
1
  import { _ChainInfo } from '@subwallet/chain-list/types';
3
2
  import { NominationInfo, NominatorMetadata, StakingType, UnstakingInfo } from '@subwallet/extension-base/background/KoniTypes';
4
3
  import { _SubstrateInflationParams } from '@subwallet/extension-base/services/chain-service/constants';
@@ -185,6 +185,7 @@ export default class KoniExtension {
185
185
  private getListDeriveAccounts;
186
186
  private subscribeChainInfoMap;
187
187
  private subscribeChainStateMap;
188
+ private subscribeChainStatusMap;
188
189
  private subscribeAssetRegistry;
189
190
  private subscribeMultiChainAssetMap;
190
191
  private subscribeXcmRefMap;
@@ -30,6 +30,7 @@ import { EXTENSION_REQUEST_URL } from '@subwallet/extension-base/services/reques
30
30
  import { DEFAULT_AUTO_LOCK_TIME } from '@subwallet/extension-base/services/setting-service/constants';
31
31
  import { WALLET_CONNECT_EIP155_NAMESPACE } from '@subwallet/extension-base/services/wallet-connect-service/constants';
32
32
  import { isProposalExpired, isSupportWalletConnectChain, isSupportWalletConnectNamespace } from '@subwallet/extension-base/services/wallet-connect-service/helpers';
33
+ import { AccountsStore } from '@subwallet/extension-base/stores';
33
34
  import { YieldPoolType } from '@subwallet/extension-base/types';
34
35
  import { convertSubjectInfoToAddresses, isSameAddress, reformatAddress, uniqueStringArray } from '@subwallet/extension-base/utils';
35
36
  import { calculateGasFeeParams, createTransactionFromRLP, signatureToHex } from '@subwallet/extension-base/utils/eth';
@@ -517,11 +518,16 @@ export default class KoniExtension {
517
518
  }
518
519
  subscribeAddresses(id, port) {
519
520
  const _cb = createSubscription(id, port);
521
+ let old = '';
520
522
  const subscription = this.#koniState.keyringService.addressesSubject.subscribe(subjectInfo => {
521
523
  const addresses = convertSubjectInfoToAddresses(subjectInfo);
522
- _cb({
523
- addresses: addresses
524
- });
524
+ const _new = JSON.stringify(addresses);
525
+ if (old !== _new) {
526
+ _cb({
527
+ addresses: addresses
528
+ });
529
+ old = _new;
530
+ }
525
531
  });
526
532
  this.createUnsubscriptionHandle(id, subscription.unsubscribe);
527
533
  port.onDisconnect.addListener(() => {
@@ -533,16 +539,42 @@ export default class KoniExtension {
533
539
  };
534
540
  }
535
541
  saveRecentAccount({
536
- accountId
542
+ accountId,
543
+ chain
537
544
  }) {
538
545
  if (isAddress(accountId)) {
539
546
  const address = reformatAddress(accountId);
540
547
  const account = keyring.getAccount(address);
541
- const contact = keyring.getAddress(address);
542
- return account || contact || {
543
- ...keyring.saveRecent(address).json,
544
- publicKey: decodeAddress(address)
545
- };
548
+ const contact = keyring.getAddress(address, 'address');
549
+ if (account) {
550
+ return account;
551
+ } else {
552
+ let metadata;
553
+ if (contact) {
554
+ metadata = contact.meta;
555
+ } else {
556
+ const _new = keyring.saveRecent(address);
557
+ metadata = _new.json.meta;
558
+ }
559
+ if (contact && !metadata.isRecent) {
560
+ return contact;
561
+ }
562
+ const recentChainSlugs = metadata.recentChainSlugs || [];
563
+ if (chain) {
564
+ if (!recentChainSlugs.includes(chain)) {
565
+ recentChainSlugs.push(chain);
566
+ }
567
+ }
568
+ metadata.recentChainSlugs = recentChainSlugs;
569
+ const result = keyring.addresses.add(new AccountsStore(), address, {
570
+ address: address,
571
+ meta: metadata
572
+ });
573
+ return {
574
+ ...result.json,
575
+ publicKey: decodeAddress(address)
576
+ };
577
+ }
546
578
  } else {
547
579
  throw Error(t('This is not an address'));
548
580
  }
@@ -1594,7 +1626,9 @@ export default class KoniExtension {
1594
1626
  // Check ed for receiver
1595
1627
  if (new BigN(receiverBalance).plus(transferAmount.value).lt(minAmount)) {
1596
1628
  const atLeast = new BigN(minAmount).minus(receiverBalance).plus((tokenInfo.decimals || 0) === 0 ? 0 : 1);
1597
- const atLeastStr = formatNumber(atLeast, tokenInfo.decimals || 0, balanceFormatter);
1629
+ const atLeastStr = formatNumber(atLeast, tokenInfo.decimals || 0, balanceFormatter, {
1630
+ maxNumberFormat: tokenInfo.decimals || 6
1631
+ });
1598
1632
  inputTransaction.errors.push(new TransactionError(TransferTxErrorType.RECEIVER_NOT_ENOUGH_EXISTENTIAL_DEPOSIT, t('You must transfer at least {{amount}} {{symbol}} to keep the destination account alive', {
1599
1633
  replace: {
1600
1634
  amount: atLeastStr,
@@ -1663,7 +1697,9 @@ export default class KoniExtension {
1663
1697
 
1664
1698
  // Check ed for receiver
1665
1699
  if (new BigN(value).lt(atLeast)) {
1666
- const atLeastStr = formatNumber(atLeast, destinationTokenInfo.decimals || 0, balanceFormatter);
1700
+ const atLeastStr = formatNumber(atLeast, destinationTokenInfo.decimals || 0, balanceFormatter, {
1701
+ maxNumberFormat: destinationTokenInfo.decimals || 6
1702
+ });
1667
1703
  inputTransaction.errors.push(new TransactionError(TransferTxErrorType.RECEIVER_NOT_ENOUGH_EXISTENTIAL_DEPOSIT, t('You must transfer at least {{amount}} {{symbol}} to keep the destination account alive', {
1668
1704
  replace: {
1669
1705
  amount: atLeastStr,
@@ -2919,7 +2955,7 @@ export default class KoniExtension {
2919
2955
  if (chainInfo && (_API_OPTIONS_CHAIN_GROUP.avail.includes(chainInfo.slug) || _API_OPTIONS_CHAIN_GROUP.goldberg.includes(chainInfo.slug))) {
2920
2956
  const isChainActive = this.#koniState.getChainStateByKey(chainInfo.slug).active;
2921
2957
  if (!isChainActive) {
2922
- reject(new Error('Please active chain {{chain}} before sign'.replaceAll('{{chain}}', chainInfo.name)));
2958
+ reject(new Error('Please activate {{chain}} network before signing'.replaceAll('{{chain}}', chainInfo.name)));
2923
2959
  return false;
2924
2960
  } else {
2925
2961
  registry = this.#koniState.getSubstrateApi(chainInfo.slug).api.registry;
@@ -3133,6 +3169,19 @@ export default class KoniExtension {
3133
3169
  });
3134
3170
  return this.#koniState.getChainStateMap();
3135
3171
  }
3172
+ subscribeChainStatusMap(id, port) {
3173
+ const cb = createSubscription(id, port);
3174
+ const chainStateMapSubscription = this.#koniState.chainService.subscribeChainStatusMap().subscribe({
3175
+ next: rs => {
3176
+ cb(rs);
3177
+ }
3178
+ });
3179
+ this.createUnsubscriptionHandle(id, chainStateMapSubscription.unsubscribe);
3180
+ port.onDisconnect.addListener(() => {
3181
+ this.cancelSubscription(id);
3182
+ });
3183
+ return this.#koniState.chainService.getChainStatusMap();
3184
+ }
3136
3185
  async subscribeAssetRegistry(id, port) {
3137
3186
  const cb = createSubscription(id, port);
3138
3187
  let ready = false;
@@ -3422,7 +3471,7 @@ export default class KoniExtension {
3422
3471
  });
3423
3472
  const {
3424
3473
  connectionStatus
3425
- } = this.#koniState.chainService.getChainStateByKey(_DEFAULT_MANTA_ZK_CHAIN);
3474
+ } = this.#koniState.chainService.getChainStatusByKey(_DEFAULT_MANTA_ZK_CHAIN);
3426
3475
  if (connectionStatus !== _ChainConnectionStatus.CONNECTED) {
3427
3476
  // TODO: do better
3428
3477
  await timeout();
@@ -4158,6 +4207,8 @@ export default class KoniExtension {
4158
4207
  return this.subscribeChainInfoMap(id, port);
4159
4208
  case 'pri(chainService.subscribeChainStateMap)':
4160
4209
  return this.subscribeChainStateMap(id, port);
4210
+ case 'pri(chainService.subscribeChainStatusMap)':
4211
+ return this.subscribeChainStatusMap(id, port);
4161
4212
  case 'pri(chainService.subscribeXcmRefMap)':
4162
4213
  return this.subscribeXcmRefMap(id, port);
4163
4214
  case 'pri(chainService.getSupportedContractTypes)':
@@ -37,10 +37,11 @@ import { createPromiseHandler } from '@subwallet/extension-base/utils/promise';
37
37
  import { decodePair } from '@subwallet/keyring/pair/decode';
38
38
  import { keyring } from '@subwallet/ui-keyring';
39
39
  import BigN from 'bignumber.js';
40
+ import BN from 'bn.js';
40
41
  import SimpleKeyring from 'eth-simple-keyring';
41
42
  import { t } from 'i18next';
42
43
  import { Subject } from 'rxjs';
43
- import { assert, BN, hexStripPrefix, hexToU8a, isHex, logger as createLogger, u8aToHex } from '@polkadot/util';
44
+ import { assert, hexStripPrefix, hexToU8a, isHex, logger as createLogger, u8aToHex } from '@polkadot/util';
44
45
  import { base64Decode, isEthereumAddress, keyExtractSuri } from '@polkadot/util-crypto';
45
46
  import { KoniCron } from "../cron.js";
46
47
  import { KoniSubscription } from "../subscription.js";
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "./cjs/detectPackage.js"
18
18
  ],
19
19
  "type": "module",
20
- "version": "1.1.38-1",
20
+ "version": "1.1.39-beta.0",
21
21
  "main": "./cjs/index.js",
22
22
  "module": "./index.js",
23
23
  "types": "./index.d.ts",
@@ -670,6 +670,31 @@
670
670
  "require": "./cjs/services/chain-service/health-check/index.js",
671
671
  "default": "./services/chain-service/health-check/index.js"
672
672
  },
673
+ "./services/chain-service/health-check/constants": {
674
+ "types": "./services/chain-service/health-check/constants/index.d.ts",
675
+ "require": "./cjs/services/chain-service/health-check/constants/index.js",
676
+ "default": "./services/chain-service/health-check/constants/index.js"
677
+ },
678
+ "./services/chain-service/health-check/utils": {
679
+ "types": "./services/chain-service/health-check/utils/index.d.ts",
680
+ "require": "./cjs/services/chain-service/health-check/utils/index.js",
681
+ "default": "./services/chain-service/health-check/utils/index.js"
682
+ },
683
+ "./services/chain-service/health-check/utils/asset-info": {
684
+ "types": "./services/chain-service/health-check/utils/asset-info.d.ts",
685
+ "require": "./cjs/services/chain-service/health-check/utils/asset-info.js",
686
+ "default": "./services/chain-service/health-check/utils/asset-info.js"
687
+ },
688
+ "./services/chain-service/health-check/utils/chain-info": {
689
+ "types": "./services/chain-service/health-check/utils/chain-info.d.ts",
690
+ "require": "./cjs/services/chain-service/health-check/utils/chain-info.js",
691
+ "default": "./services/chain-service/health-check/utils/chain-info.js"
692
+ },
693
+ "./services/chain-service/health-check/utils/provider": {
694
+ "types": "./services/chain-service/health-check/utils/provider.d.ts",
695
+ "require": "./cjs/services/chain-service/health-check/utils/provider.js",
696
+ "default": "./services/chain-service/health-check/utils/provider.js"
697
+ },
673
698
  "./services/chain-service/helper": {
674
699
  "types": "./services/chain-service/helper/index.d.ts",
675
700
  "require": "./cjs/services/chain-service/helper/index.js",
@@ -1719,28 +1744,28 @@
1719
1744
  "@metamask/safe-event-emitter": "^2.0.0",
1720
1745
  "@metaverse-network-sdk/type-definitions": "^0.0.1-13",
1721
1746
  "@oak-foundation/types": "^0.0.23",
1722
- "@polkadot/api": "^10.11.1",
1747
+ "@polkadot/api": "^10.11.2",
1723
1748
  "@polkadot/api-base": "^10.9.1",
1724
- "@polkadot/api-contract": "^10.11.1",
1725
- "@polkadot/api-derive": "^10.11.1",
1749
+ "@polkadot/api-contract": "^10.11.2",
1750
+ "@polkadot/api-derive": "^10.11.2",
1726
1751
  "@polkadot/apps-config": "^0.133.1",
1727
- "@polkadot/hw-ledger": "^12.6.1",
1728
- "@polkadot/networks": "^12.6.1",
1752
+ "@polkadot/hw-ledger": "^12.6.2",
1753
+ "@polkadot/networks": "^12.6.2",
1729
1754
  "@polkadot/phishing": "^0.22.1",
1730
- "@polkadot/rpc-provider": "^10.11.1",
1731
- "@polkadot/types": "^10.11.1",
1732
- "@polkadot/types-augment": "^10.11.1",
1755
+ "@polkadot/rpc-provider": "^10.11.2",
1756
+ "@polkadot/types": "^10.11.2",
1757
+ "@polkadot/types-augment": "^10.11.2",
1733
1758
  "@polkadot/ui-settings": "^3.6.4",
1734
- "@polkadot/util": "^12.6.1",
1735
- "@polkadot/util-crypto": "^12.6.1",
1759
+ "@polkadot/util": "^12.6.2",
1760
+ "@polkadot/util-crypto": "^12.6.2",
1736
1761
  "@reduxjs/toolkit": "^1.9.1",
1737
1762
  "@sora-substrate/type-definitions": "^1.17.7",
1738
1763
  "@substrate/connect": "^0.7.26",
1739
- "@subwallet/chain-list": "0.2.41",
1740
- "@subwallet/extension-base": "^1.1.38-1",
1741
- "@subwallet/extension-chains": "^1.1.38-1",
1742
- "@subwallet/extension-dapp": "^1.1.38-1",
1743
- "@subwallet/extension-inject": "^1.1.38-1",
1764
+ "@subwallet/chain-list": "0.2.42-beta.0",
1765
+ "@subwallet/extension-base": "^1.1.39-0",
1766
+ "@subwallet/extension-chains": "^1.1.39-0",
1767
+ "@subwallet/extension-dapp": "^1.1.39-0",
1768
+ "@subwallet/extension-inject": "^1.1.39-0",
1744
1769
  "@subwallet/keyring": "^0.1.3",
1745
1770
  "@subwallet/ui-keyring": "^0.1.3",
1746
1771
  "@walletconnect/sign-client": "^2.8.4",
@@ -1777,4 +1802,4 @@
1777
1802
  "web3-eth-contract": "^1.10.0",
1778
1803
  "web3-utils": "^1.10.0"
1779
1804
  }
1780
- }
1805
+ }
package/packageInfo.js CHANGED
@@ -7,5 +7,5 @@ export const packageInfo = {
7
7
  name: '@subwallet/extension-base',
8
8
  path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto',
9
9
  type: 'esm',
10
- version: '1.1.38-1'
10
+ version: '1.1.39-0'
11
11
  };
@@ -40,7 +40,7 @@ const filterAddress = (addresses, chainInfo) => {
40
40
  const isEvmChain = _isChainEvmCompatible(chainInfo);
41
41
  const [substrateAddresses, evmAddresses] = categoryAddresses(addresses);
42
42
  if (isEvmChain) {
43
- return [evmAddresses, []];
43
+ return [evmAddresses, substrateAddresses];
44
44
  } else {
45
45
  const fetchList = [];
46
46
  const unfetchList = [];
@@ -0,0 +1,4 @@
1
+ import BigN from 'bignumber.js';
2
+ export declare const chainProvider: Record<string, number>;
3
+ export declare const chainProviderBackup: Record<string, number>;
4
+ export declare const BIG_TEN: BigN;
@@ -0,0 +1,26 @@
1
+ // Copyright 2019-2022 @subwallet/extension-base authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import BigN from 'bignumber.js';
5
+ export const chainProvider = {
6
+ default: 0,
7
+ ethereum: 1,
8
+ polygon: 2,
9
+ shidenEvm: 2,
10
+ shiden: 2,
11
+ ajunaPolkadot: 1,
12
+ crabParachain: 1,
13
+ astarEvm: 1,
14
+ shibuya: 1,
15
+ shibuyaEvm: 0
16
+ };
17
+ export const chainProviderBackup = {
18
+ default: 1,
19
+ pangolin: 0,
20
+ moonbeam: 0,
21
+ moonbase: 0,
22
+ moonriver: 3,
23
+ darwinia2: 2,
24
+ crabParachain: 1
25
+ };
26
+ export const BIG_TEN = new BigN(10);
@@ -0,0 +1,14 @@
1
+ import { _ChainAsset } from '@subwallet/chain-list/types';
2
+ import { _EvmApi } from '@subwallet/extension-base/services/chain-service/types';
3
+ import { ApiPromise } from '@polkadot/api';
4
+ export interface AssetSpec {
5
+ minAmount: string;
6
+ symbol: string;
7
+ decimals: number;
8
+ }
9
+ export declare const getLocalAssetInfo: (chain: string, asset: _ChainAsset, api: ApiPromise) => Promise<AssetSpec>;
10
+ export declare const getSubstrateNativeInfo: (api: ApiPromise) => Promise<AssetSpec>;
11
+ export declare const getPsp22AssetInfo: (asset: _ChainAsset, api: ApiPromise) => Promise<AssetSpec>;
12
+ export declare const getEvmNativeInfo: (api: _EvmApi) => Promise<AssetSpec>;
13
+ export declare const getErc20AssetInfo: (asset: _ChainAsset, api: _EvmApi) => Promise<AssetSpec>;
14
+ export declare const compareAsset: (assetInfo: AssetSpec, asset: _ChainAsset, errors: string[]) => void;