@subwallet/extension-base 1.1.40-0 → 1.1.41-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 (96) hide show
  1. package/background/KoniTypes.d.ts +3 -1
  2. package/cjs/constants/index.js +1 -1
  3. package/cjs/constants/staking.js +1 -1
  4. package/cjs/koni/api/dotsama/transfer.js +1 -1
  5. package/cjs/koni/api/nft/bit.country/index.js +2 -0
  6. package/cjs/koni/api/nft/config.js +3 -1
  7. package/cjs/koni/api/tokens/evm/transfer.js +4 -4
  8. package/cjs/koni/background/handlers/Extension.js +32 -17
  9. package/cjs/koni/background/handlers/State.js +41 -9
  10. package/cjs/packageInfo.js +1 -1
  11. package/cjs/services/balance-service/helpers/subscribe/substrate/index.js +58 -0
  12. package/cjs/services/chain-service/constants.js +11 -7
  13. package/cjs/services/chain-service/handler/chain-spec/goldberg.js +75 -8
  14. package/cjs/services/chain-service/index.js +71 -59
  15. package/cjs/services/chain-service/utils.js +11 -6
  16. package/cjs/services/earning-service/constants/chains.js +2 -2
  17. package/cjs/services/earning-service/handlers/liquid-staking/acala.js +9 -3
  18. package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +8 -1
  19. package/cjs/services/earning-service/handlers/liquid-staking/parallel.js +6 -1
  20. package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +25 -17
  21. package/cjs/services/earning-service/handlers/native-staking/amplitude.js +4 -0
  22. package/cjs/services/earning-service/handlers/native-staking/astar.js +6 -2
  23. package/cjs/services/earning-service/handlers/native-staking/para-chain.js +5 -0
  24. package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +14 -16
  25. package/cjs/services/earning-service/handlers/nomination-pool/index.js +9 -11
  26. package/cjs/services/earning-service/handlers/special.js +2 -0
  27. package/cjs/services/earning-service/service.js +51 -18
  28. package/cjs/services/fee-service/service.js +70 -0
  29. package/cjs/services/fee-service/utils/index.js +209 -0
  30. package/cjs/services/migration-service/scripts/DeleteChainStaking.js +23 -0
  31. package/cjs/services/migration-service/scripts/index.js +3 -1
  32. package/cjs/services/transaction-service/index.js +37 -37
  33. package/cjs/types/fee/index.js +1 -0
  34. package/cjs/types/index.js +11 -0
  35. package/cjs/utils/eth.js +2 -105
  36. package/cjs/utils/index.js +12 -0
  37. package/cjs/utils/reportError.js +31 -0
  38. package/constants/index.d.ts +1 -1
  39. package/constants/index.js +1 -1
  40. package/constants/staking.js +1 -1
  41. package/koni/api/dotsama/transfer.js +1 -1
  42. package/koni/api/nft/bit.country/index.js +3 -1
  43. package/koni/api/nft/config.d.ts +1 -0
  44. package/koni/api/nft/config.js +1 -0
  45. package/koni/api/tokens/evm/transfer.js +1 -1
  46. package/koni/background/handlers/Extension.d.ts +1 -0
  47. package/koni/background/handlers/Extension.js +18 -3
  48. package/koni/background/handlers/State.d.ts +4 -1
  49. package/koni/background/handlers/State.js +32 -1
  50. package/package.json +32 -7
  51. package/packageInfo.js +1 -1
  52. package/services/balance-service/helpers/subscribe/substrate/index.js +59 -1
  53. package/services/chain-service/constants.d.ts +2 -0
  54. package/services/chain-service/constants.js +11 -7
  55. package/services/chain-service/handler/chain-spec/goldberg.d.ts +70 -1
  56. package/services/chain-service/handler/chain-spec/goldberg.js +75 -8
  57. package/services/chain-service/index.d.ts +7 -3
  58. package/services/chain-service/index.js +62 -51
  59. package/services/chain-service/types.d.ts +4 -0
  60. package/services/chain-service/utils.d.ts +1 -0
  61. package/services/chain-service/utils.js +10 -6
  62. package/services/earning-service/constants/chains.js +2 -2
  63. package/services/earning-service/handlers/liquid-staking/acala.js +9 -3
  64. package/services/earning-service/handlers/liquid-staking/bifrost.js +8 -1
  65. package/services/earning-service/handlers/liquid-staking/parallel.d.ts +1 -1
  66. package/services/earning-service/handlers/liquid-staking/parallel.js +6 -1
  67. package/services/earning-service/handlers/liquid-staking/stella-swap.js +25 -17
  68. package/services/earning-service/handlers/native-staking/amplitude.js +4 -0
  69. package/services/earning-service/handlers/native-staking/astar.js +6 -2
  70. package/services/earning-service/handlers/native-staking/para-chain.js +5 -0
  71. package/services/earning-service/handlers/native-staking/relay-chain.js +15 -17
  72. package/services/earning-service/handlers/nomination-pool/index.js +10 -12
  73. package/services/earning-service/handlers/special.d.ts +1 -0
  74. package/services/earning-service/handlers/special.js +2 -0
  75. package/services/earning-service/service.d.ts +4 -1
  76. package/services/earning-service/service.js +52 -19
  77. package/services/fee-service/service.d.ts +12 -0
  78. package/services/fee-service/service.js +63 -0
  79. package/services/fee-service/utils/index.d.ts +8 -0
  80. package/services/fee-service/utils/index.js +193 -0
  81. package/services/migration-service/scripts/DeleteChainStaking.d.ts +4 -0
  82. package/services/migration-service/scripts/DeleteChainStaking.js +15 -0
  83. package/services/migration-service/scripts/index.js +3 -1
  84. package/services/transaction-service/index.js +2 -2
  85. package/types/fee/index.d.ts +49 -0
  86. package/types/fee/index.js +1 -0
  87. package/types/index.d.ts +1 -0
  88. package/types/index.js +1 -0
  89. package/types/yield/info/account/unstake.d.ts +2 -0
  90. package/types/yield/info/pallet.d.ts +4 -0
  91. package/utils/eth.d.ts +0 -15
  92. package/utils/eth.js +0 -101
  93. package/utils/index.d.ts +1 -0
  94. package/utils/index.js +1 -0
  95. package/utils/reportError.d.ts +1 -0
  96. package/utils/reportError.js +23 -0
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.reportError = void 0;
8
+ var _environment = require("@subwallet/extension-base/utils/environment");
9
+ var _crossFetch = _interopRequireDefault(require("cross-fetch"));
10
+ // Copyright 2019-2022 @subwallet/extension-base authors & contributors
11
+ // SPDX-License-Identifier: Apache-2.0
12
+
13
+ const EXTENSION_REPORT_ERROR_URL = 'https://extension-feedback.subwallet.app/gelf';
14
+ const WEBAPP_REPORT_ERROR_URL = 'https://web-feedback.subwallet.app/gelf';
15
+ const reportError = async (e, pathName) => {
16
+ const errorContent = JSON.stringify(e.stack);
17
+ const errorShortMessage = e.message;
18
+ const body = {
19
+ content: errorContent,
20
+ short_message: errorShortMessage,
21
+ platform: _environment.TARGET_ENV,
22
+ device_version: '',
23
+ app_version: JSON.stringify(process.env.PKG_VERSION),
24
+ current_routes: pathName
25
+ };
26
+ await (0, _crossFetch.default)(_environment.TARGET_ENV === 'extension' ? EXTENSION_REPORT_ERROR_URL : WEBAPP_REPORT_ERROR_URL, {
27
+ method: 'POST',
28
+ body: JSON.stringify(body)
29
+ });
30
+ };
31
+ exports.reportError = reportError;
@@ -11,7 +11,7 @@ export declare const CRON_REFRESH_STAKING_REWARD_INTERVAL = 900000;
11
11
  export declare const CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL = 90000;
12
12
  export declare const CRON_REFRESH_HISTORY_INTERVAL = 900000;
13
13
  export declare const CRON_GET_API_MAP_STATUS = 10000;
14
- export declare const CRON_REFRESH_CHAIN_STAKING_METADATA = 900000;
14
+ export declare const CRON_REFRESH_CHAIN_STAKING_METADATA = 90000;
15
15
  export declare const CRON_REFRESH_CHAIN_NOMINATOR_METADATA = 1800000;
16
16
  export declare const CRON_RECOVER_HISTORY_INTERVAL = 30000;
17
17
  export declare const CRON_SYNC_MANTA_PAY = 300000;
@@ -14,7 +14,7 @@ export const CRON_REFRESH_STAKING_REWARD_INTERVAL = 900000;
14
14
  export const CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL = 90000;
15
15
  export const CRON_REFRESH_HISTORY_INTERVAL = 900000;
16
16
  export const CRON_GET_API_MAP_STATUS = 10000;
17
- export const CRON_REFRESH_CHAIN_STAKING_METADATA = 900000;
17
+ export const CRON_REFRESH_CHAIN_STAKING_METADATA = 90000;
18
18
  export const CRON_REFRESH_CHAIN_NOMINATOR_METADATA = 1800000;
19
19
  export const CRON_RECOVER_HISTORY_INTERVAL = 30000;
20
20
  export const CRON_SYNC_MANTA_PAY = 300000;
@@ -4,7 +4,7 @@
4
4
  export const PREDEFINED_STAKING_POOL = {
5
5
  kusama: 80,
6
6
  polkadot: 39,
7
- vara_network: 29,
7
+ vara_network: 50,
8
8
  aleph: 82
9
9
  };
10
10
  export const MAX_NOMINATIONS = '16';
@@ -181,7 +181,7 @@ export const createTransferExtrinsic = async ({
181
181
  } else if (_TRANSFER_CHAIN_GROUP.sora_substrate.includes(networkKey) && isTxAssetsSupported) {
182
182
  transfer = api.tx.assets.transfer(_getTokenOnChainAssetId(tokenInfo), to, value);
183
183
  } else if (isTxBalancesSupported && _isNativeToken(tokenInfo)) {
184
- if (networkKey === 'invarch') {
184
+ if (_TRANSFER_CHAIN_GROUP.disable_transfer.includes(networkKey)) {
185
185
  return [null, transferAmount || value];
186
186
  }
187
187
  if (transferAll) {
@@ -1,7 +1,7 @@
1
1
  // Copyright 2019-2022 @subwallet/extension-base
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { BIT_COUNTRY_IPFS_SERVER, BIT_COUNTRY_LAND_ESTATE_METADATA_API } from '@subwallet/extension-base/koni/api/nft/config';
4
+ import { BIT_AVATAR_API, BIT_COUNTRY_IPFS_SERVER, BIT_COUNTRY_LAND_ESTATE_METADATA_API } from '@subwallet/extension-base/koni/api/nft/config';
5
5
  import { BaseNftApi } from '@subwallet/extension-base/koni/api/nft/nft';
6
6
  import { isUrl } from '@subwallet/extension-base/utils';
7
7
  import fetch from 'cross-fetch';
@@ -53,6 +53,8 @@ export class BitCountryNftApi extends BaseNftApi {
53
53
  // check if NFT is Land/Estate
54
54
  if (onChainMeta.data.attributes['MetaverseId:']) {
55
55
  return await fetch(`${BIT_COUNTRY_LAND_ESTATE_METADATA_API}/${assetId.classId}/${assetId.tokenId}/metadata.json`).then(resp => resp.json());
56
+ } else if (onChainMeta.metadata.startsWith('/avatar/')) {
57
+ return await fetch(BIT_AVATAR_API + onChainMeta.metadata).then(resp => resp.json());
56
58
  } else {
57
59
  return await fetch(BIT_COUNTRY_IPFS_SERVER + onChainMeta.metadata).then(resp => resp.json());
58
60
  }
@@ -7,6 +7,7 @@ export declare const SINGULAR_V2_COLLECTION_ENDPOINT = "https://singular.app/api
7
7
  export declare const KANARIA_EXTERNAL_SERVER = "https://kanaria.rmrk.app/catalogue/";
8
8
  export declare const CLOUDFLARE_PINATA_SERVER = "https://cloudflare-ipfs.com/ipfs/";
9
9
  export declare const BIT_COUNTRY_IPFS_SERVER = "https://ipfs-cdn.bit.country/";
10
+ export declare const BIT_AVATAR_API = "https://api.bitavatar.io/v1";
10
11
  export declare const BIT_COUNTRY_LAND_ESTATE_METADATA_API = "https://pioneer-api.bit.country/metadata/landTokenUriPioneer";
11
12
  export declare const BIT_COUNTRY_THUMBNAIL_RESOLVER = "https://res.cloudinary.com/ddftctzph/image/upload/c_scale,q_100,w_250/production-ipfs/asset/";
12
13
  export declare const CF_IPFS_GATEWAY = "https://cf-ipfs.com/ipfs/";
@@ -13,6 +13,7 @@ export const SINGULAR_V2_COLLECTION_ENDPOINT = 'https://singular.app/api/rmrk2/c
13
13
  export const KANARIA_EXTERNAL_SERVER = 'https://kanaria.rmrk.app/catalogue/';
14
14
  export const CLOUDFLARE_PINATA_SERVER = 'https://cloudflare-ipfs.com/ipfs/';
15
15
  export const BIT_COUNTRY_IPFS_SERVER = 'https://ipfs-cdn.bit.country/';
16
+ export const BIT_AVATAR_API = 'https://api.bitavatar.io/v1';
16
17
  export const BIT_COUNTRY_LAND_ESTATE_METADATA_API = 'https://pioneer-api.bit.country/metadata/landTokenUriPioneer';
17
18
  export const BIT_COUNTRY_THUMBNAIL_RESOLVER = 'https://res.cloudinary.com/ddftctzph/image/upload/c_scale,q_100,w_250/production-ipfs/asset/';
18
19
 
@@ -5,7 +5,7 @@ import { ExternalRequestPromiseStatus } from '@subwallet/extension-base/backgrou
5
5
  import { getERC20Contract } from '@subwallet/extension-base/koni/api/tokens/evm/web3';
6
6
  import { _BALANCE_PARSING_CHAIN_GROUP, EVM_REFORMAT_DECIMALS } from '@subwallet/extension-base/services/chain-service/constants';
7
7
  import { _ERC721_ABI } from '@subwallet/extension-base/services/chain-service/helper';
8
- import { calculateGasFeeParams } from '@subwallet/extension-base/utils/eth';
8
+ import { calculateGasFeeParams } from '@subwallet/extension-base/services/fee-service/utils';
9
9
  import BigN from 'bignumber.js';
10
10
  import { hexToBn } from '@polkadot/util';
11
11
  export const handleTransferBalanceResult = ({
@@ -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;
@@ -26,14 +26,14 @@ import { YIELD_EXTRINSIC_TYPES } from '@subwallet/extension-base/koni/api/yield/
26
26
  import { _API_OPTIONS_CHAIN_GROUP, _DEFAULT_MANTA_ZK_CHAIN, _MANTA_ZK_CHAIN_GROUP, _ZK_ASSET_PREFIX } from '@subwallet/extension-base/services/chain-service/constants';
27
27
  import { _ChainConnectionStatus } from '@subwallet/extension-base/services/chain-service/types';
28
28
  import { _getChainNativeTokenBasicInfo, _getContractAddressOfToken, _getEvmChainId, _getSubstrateGenesisHash, _getTokenMinAmount, _isAssetSmartContractNft, _isChainEvmCompatible, _isCustomAsset, _isLocalToken, _isMantaZkAsset, _isNativeToken, _isTokenEvmSmartContract, _isTokenTransferredByEvm } from '@subwallet/extension-base/services/chain-service/utils';
29
+ import { calculateGasFeeParams } from '@subwallet/extension-base/services/fee-service/utils';
29
30
  import { EXTENSION_REQUEST_URL } from '@subwallet/extension-base/services/request-service/constants';
30
31
  import { DEFAULT_AUTO_LOCK_TIME } from '@subwallet/extension-base/services/setting-service/constants';
31
32
  import { WALLET_CONNECT_EIP155_NAMESPACE } from '@subwallet/extension-base/services/wallet-connect-service/constants';
32
33
  import { isProposalExpired, isSupportWalletConnectChain, isSupportWalletConnectNamespace } from '@subwallet/extension-base/services/wallet-connect-service/helpers';
33
34
  import { AccountsStore } from '@subwallet/extension-base/stores';
34
35
  import { YieldPoolType } from '@subwallet/extension-base/types';
35
- import { convertSubjectInfoToAddresses, isSameAddress, reformatAddress, uniqueStringArray } from '@subwallet/extension-base/utils';
36
- import { calculateGasFeeParams, createTransactionFromRLP, signatureToHex } from '@subwallet/extension-base/utils/eth';
36
+ import { convertSubjectInfoToAddresses, createTransactionFromRLP, isSameAddress, reformatAddress, signatureToHex, uniqueStringArray } from '@subwallet/extension-base/utils';
37
37
  import { parseContractInput, parseEvmRlp } from '@subwallet/extension-base/utils/eth/parseTransaction';
38
38
  import { balanceFormatter, formatNumber } from '@subwallet/extension-base/utils/number';
39
39
  import { createPair } from '@subwallet/keyring';
@@ -3169,6 +3169,19 @@ export default class KoniExtension {
3169
3169
  });
3170
3170
  return this.#koniState.getChainStateMap();
3171
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
+ }
3172
3185
  async subscribeAssetRegistry(id, port) {
3173
3186
  const cb = createSubscription(id, port);
3174
3187
  let ready = false;
@@ -3458,7 +3471,7 @@ export default class KoniExtension {
3458
3471
  });
3459
3472
  const {
3460
3473
  connectionStatus
3461
- } = this.#koniState.chainService.getChainStateByKey(_DEFAULT_MANTA_ZK_CHAIN);
3474
+ } = this.#koniState.chainService.getChainStatusByKey(_DEFAULT_MANTA_ZK_CHAIN);
3462
3475
  if (connectionStatus !== _ChainConnectionStatus.CONNECTED) {
3463
3476
  // TODO: do better
3464
3477
  await timeout();
@@ -4194,6 +4207,8 @@ export default class KoniExtension {
4194
4207
  return this.subscribeChainInfoMap(id, port);
4195
4208
  case 'pri(chainService.subscribeChainStateMap)':
4196
4209
  return this.subscribeChainStateMap(id, port);
4210
+ case 'pri(chainService.subscribeChainStatusMap)':
4211
+ return this.subscribeChainStatusMap(id, port);
4197
4212
  case 'pri(chainService.subscribeXcmRefMap)':
4198
4213
  return this.subscribeXcmRefMap(id, port);
4199
4214
  case 'pri(chainService.getSupportedContractTypes)':
@@ -9,6 +9,7 @@ import { ChainService } from '@subwallet/extension-base/services/chain-service';
9
9
  import { _ChainState, _NetworkUpsertParams, _ValidateCustomAssetRequest } from '@subwallet/extension-base/services/chain-service/types';
10
10
  import EarningService from '@subwallet/extension-base/services/earning-service/service';
11
11
  import { EventService } from '@subwallet/extension-base/services/event-service';
12
+ import FeeService from '@subwallet/extension-base/services/fee-service/service';
12
13
  import { HistoryService } from '@subwallet/extension-base/services/history-service';
13
14
  import { KeyringService } from '@subwallet/extension-base/services/keyring-service';
14
15
  import MigrationService from '@subwallet/extension-base/services/migration-service';
@@ -22,7 +23,7 @@ import DatabaseService from '@subwallet/extension-base/services/storage-service/
22
23
  import { SubscanService } from '@subwallet/extension-base/services/subscan-service';
23
24
  import TransactionService from '@subwallet/extension-base/services/transaction-service';
24
25
  import WalletConnectService from '@subwallet/extension-base/services/wallet-connect-service';
25
- import { BalanceItem, BalanceJson, BalanceMap } from '@subwallet/extension-base/types';
26
+ import { BalanceItem, BalanceJson, BalanceMap, EvmFeeInfo } from '@subwallet/extension-base/types';
26
27
  import { MetadataDef, ProviderMeta } from '@subwallet/extension-inject/types';
27
28
  import SimpleKeyring from 'eth-simple-keyring';
28
29
  import { BehaviorSubject, Subject } from 'rxjs';
@@ -70,6 +71,7 @@ export default class KoniState {
70
71
  readonly campaignService: CampaignService;
71
72
  readonly buyService: BuyService;
72
73
  readonly earningService: EarningService;
74
+ readonly feeService: FeeService;
73
75
  private generalStatus;
74
76
  private waitSleeping;
75
77
  private waitStarting;
@@ -223,6 +225,7 @@ export default class KoniState {
223
225
  checkPublicAndSecretKey({ publicKey, secretKey }: RequestCheckPublicAndSecretKey): ResponseCheckPublicAndSecretKey;
224
226
  getEthKeyring(address: string, password: string): Promise<SimpleKeyring>;
225
227
  evmSign(id: string, url: string, method: string, params: any, allowedAccounts: string[]): Promise<string | undefined>;
228
+ calculateAllGasFeeOnChain(activeEvmChains: string[], timeout?: number): Promise<Record<string, EvmFeeInfo | null>>;
226
229
  evmSendTransaction(id: string, url: string, networkKey: string, allowedAccounts: string[], transactionParams: EvmSendTransactionParams): Promise<string | undefined>;
227
230
  getConfirmationsQueueSubject(): BehaviorSubject<ConfirmationsQueue>;
228
231
  completeConfirmation(request: RequestConfirmationComplete): Promise<boolean>;
@@ -16,6 +16,8 @@ import { _DEFAULT_MANTA_ZK_CHAIN, _MANTA_ZK_CHAIN_GROUP, _PREDEFINED_SINGLE_MODE
16
16
  import { _getEvmChainId, _getSubstrateGenesisHash, _getTokenOnChainAssetId, _isAssetFungibleToken, _isChainEnabled, _isChainTestNet, _parseMetadataForSmartContractAsset } from '@subwallet/extension-base/services/chain-service/utils';
17
17
  import EarningService from '@subwallet/extension-base/services/earning-service/service';
18
18
  import { EventService } from '@subwallet/extension-base/services/event-service';
19
+ import FeeService from '@subwallet/extension-base/services/fee-service/service';
20
+ import { calculateGasFeeParams } from '@subwallet/extension-base/services/fee-service/utils';
19
21
  import { HistoryService } from '@subwallet/extension-base/services/history-service';
20
22
  import { KeyringService } from '@subwallet/extension-base/services/keyring-service';
21
23
  import MigrationService from '@subwallet/extension-base/services/migration-service';
@@ -31,7 +33,6 @@ import TransactionService from '@subwallet/extension-base/services/transaction-s
31
33
  import WalletConnectService from '@subwallet/extension-base/services/wallet-connect-service';
32
34
  import AccountRefStore from '@subwallet/extension-base/stores/AccountRef';
33
35
  import { addLazy, isAccountAll, stripUrl, TARGET_ENV } from '@subwallet/extension-base/utils';
34
- import { calculateGasFeeParams } from '@subwallet/extension-base/utils/eth';
35
36
  import { isContractAddress, parseContractInput } from '@subwallet/extension-base/utils/eth/parseTransaction';
36
37
  import { createPromiseHandler } from '@subwallet/extension-base/utils/promise';
37
38
  import { decodePair } from '@subwallet/keyring/pair/decode';
@@ -104,6 +105,7 @@ export default class KoniState {
104
105
  this.buyService = new BuyService(this);
105
106
  this.transactionService = new TransactionService(this);
106
107
  this.earningService = new EarningService(this);
108
+ this.feeService = new FeeService(this);
107
109
  this.subscription = new KoniSubscription(this, this.dbService);
108
110
  this.cron = new KoniCron(this, this.subscription, this.dbService);
109
111
  this.logger = createLogger('State');
@@ -1206,6 +1208,35 @@ export default class KoniState {
1206
1208
  }
1207
1209
  });
1208
1210
  }
1211
+ async calculateAllGasFeeOnChain(activeEvmChains, timeout = 10000) {
1212
+ const promiseList = [];
1213
+ activeEvmChains.forEach(slug => {
1214
+ const timeoutPromise = new Promise(resolve => {
1215
+ setTimeout(() => resolve(null), timeout);
1216
+ });
1217
+ const promise = (async () => {
1218
+ try {
1219
+ const web3Api = this.chainService.getEvmApi(slug);
1220
+ await web3Api.isReady;
1221
+ return await calculateGasFeeParams(web3Api, slug, false, false);
1222
+ } catch (e) {
1223
+ console.error(e);
1224
+ return null;
1225
+ }
1226
+ })();
1227
+ promiseList.push(Promise.race([promise, timeoutPromise]).then(result => {
1228
+ var _result$gasPrice, _result$maxFeePerGas, _result$maxPriorityFe, _result$baseGasFee;
1229
+ return [slug, result ? {
1230
+ ...result,
1231
+ gasPrice: (_result$gasPrice = result.gasPrice) === null || _result$gasPrice === void 0 ? void 0 : _result$gasPrice.toString(),
1232
+ maxFeePerGas: (_result$maxFeePerGas = result.maxFeePerGas) === null || _result$maxFeePerGas === void 0 ? void 0 : _result$maxFeePerGas.toString(),
1233
+ maxPriorityFeePerGas: (_result$maxPriorityFe = result.maxPriorityFeePerGas) === null || _result$maxPriorityFe === void 0 ? void 0 : _result$maxPriorityFe.toString(),
1234
+ baseGasFee: (_result$baseGasFee = result.baseGasFee) === null || _result$baseGasFee === void 0 ? void 0 : _result$baseGasFee.toString()
1235
+ } : null];
1236
+ }));
1237
+ });
1238
+ return Object.fromEntries(await Promise.all(promiseList));
1239
+ }
1209
1240
  async evmSendTransaction(id, url, networkKey, allowedAccounts, transactionParams) {
1210
1241
  const evmApi = this.getEvmApi(networkKey);
1211
1242
  const evmNetwork = this.getChainInfo(networkKey);
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "./cjs/detectPackage.js"
18
18
  ],
19
19
  "type": "module",
20
- "version": "1.1.40-0",
20
+ "version": "1.1.41-0",
21
21
  "main": "./cjs/index.js",
22
22
  "module": "./index.js",
23
23
  "types": "./index.d.ts",
@@ -865,6 +865,16 @@
865
865
  "require": "./cjs/services/event-service/types.js",
866
866
  "default": "./services/event-service/types.js"
867
867
  },
868
+ "./services/fee-service/service": {
869
+ "types": "./services/fee-service/service.d.ts",
870
+ "require": "./cjs/services/fee-service/service.js",
871
+ "default": "./services/fee-service/service.js"
872
+ },
873
+ "./services/fee-service/utils": {
874
+ "types": "./services/fee-service/utils/index.d.ts",
875
+ "require": "./cjs/services/fee-service/utils/index.js",
876
+ "default": "./services/fee-service/utils/index.js"
877
+ },
868
878
  "./services/history-service": {
869
879
  "types": "./services/history-service/index.d.ts",
870
880
  "require": "./cjs/services/history-service/index.js",
@@ -945,6 +955,11 @@
945
955
  "require": "./cjs/services/migration-service/scripts/DeleteChain.js",
946
956
  "default": "./services/migration-service/scripts/DeleteChain.js"
947
957
  },
958
+ "./services/migration-service/scripts/DeleteChainStaking": {
959
+ "types": "./services/migration-service/scripts/DeleteChainStaking.d.ts",
960
+ "require": "./cjs/services/migration-service/scripts/DeleteChainStaking.js",
961
+ "default": "./services/migration-service/scripts/DeleteChainStaking.js"
962
+ },
948
963
  "./services/migration-service/scripts/DeleteEarningData": {
949
964
  "types": "./services/migration-service/scripts/DeleteEarningData.d.ts",
950
965
  "require": "./cjs/services/migration-service/scripts/DeleteEarningData.js",
@@ -1515,6 +1530,11 @@
1515
1530
  "require": "./cjs/types/campaigns/unlock-dot.js",
1516
1531
  "default": "./types/campaigns/unlock-dot.js"
1517
1532
  },
1533
+ "./types/fee": {
1534
+ "types": "./types/fee/index.d.ts",
1535
+ "require": "./cjs/types/fee/index.js",
1536
+ "default": "./types/fee/index.js"
1537
+ },
1518
1538
  "./types/ordinal": {
1519
1539
  "types": "./types/ordinal.d.ts",
1520
1540
  "require": "./cjs/types/ordinal.js",
@@ -1710,6 +1730,11 @@
1710
1730
  "require": "./cjs/utils/registry.js",
1711
1731
  "default": "./utils/registry.js"
1712
1732
  },
1733
+ "./utils/reportError": {
1734
+ "types": "./utils/reportError.d.ts",
1735
+ "require": "./cjs/utils/reportError.js",
1736
+ "default": "./utils/reportError.js"
1737
+ },
1713
1738
  "./utils/request": {
1714
1739
  "types": "./utils/request.d.ts",
1715
1740
  "require": "./cjs/utils/request.js",
@@ -1745,7 +1770,7 @@
1745
1770
  "@metaverse-network-sdk/type-definitions": "^0.0.1-13",
1746
1771
  "@oak-foundation/types": "^0.0.23",
1747
1772
  "@polkadot/api": "^10.11.2",
1748
- "@polkadot/api-base": "^10.9.1",
1773
+ "@polkadot/api-base": "^10.11.2",
1749
1774
  "@polkadot/api-contract": "^10.11.2",
1750
1775
  "@polkadot/api-derive": "^10.11.2",
1751
1776
  "@polkadot/apps-config": "^0.133.1",
@@ -1761,11 +1786,11 @@
1761
1786
  "@reduxjs/toolkit": "^1.9.1",
1762
1787
  "@sora-substrate/type-definitions": "^1.17.7",
1763
1788
  "@substrate/connect": "^0.7.26",
1764
- "@subwallet/chain-list": "0.2.42-beta.0",
1765
- "@subwallet/extension-base": "^1.1.40-0",
1766
- "@subwallet/extension-chains": "^1.1.40-0",
1767
- "@subwallet/extension-dapp": "^1.1.40-0",
1768
- "@subwallet/extension-inject": "^1.1.40-0",
1789
+ "@subwallet/chain-list": "0.2.42",
1790
+ "@subwallet/extension-base": "^1.1.41-0",
1791
+ "@subwallet/extension-chains": "^1.1.41-0",
1792
+ "@subwallet/extension-dapp": "^1.1.41-0",
1793
+ "@subwallet/extension-inject": "^1.1.41-0",
1769
1794
  "@subwallet/keyring": "^0.1.3",
1770
1795
  "@subwallet/ui-keyring": "^0.1.3",
1771
1796
  "@walletconnect/sign-client": "^2.8.4",
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.40-0'
10
+ version: '1.1.41-0'
11
11
  };
@@ -9,7 +9,7 @@ import { getDefaultWeightV2 } from '@subwallet/extension-base/koni/api/tokens/wa
9
9
  import { state } from '@subwallet/extension-base/koni/background/handlers';
10
10
  import { subscribeERC20Interval } from '@subwallet/extension-base/services/balance-service/helpers/subscribe/evm';
11
11
  import { _BALANCE_CHAIN_GROUP, _MANTA_ZK_CHAIN_GROUP, _ZK_ASSET_PREFIX } from '@subwallet/extension-base/services/chain-service/constants';
12
- import { _checkSmartContractSupportByChain, _getChainNativeTokenSlug, _getContractAddressOfToken, _getTokenOnChainAssetId, _getTokenOnChainInfo, _isChainEvmCompatible, _isSubstrateRelayChain } from '@subwallet/extension-base/services/chain-service/utils';
12
+ import { _checkSmartContractSupportByChain, _getChainNativeTokenSlug, _getContractAddressOfToken, _getTokenOnChainAssetId, _getTokenOnChainInfo, _getXcmAssetMultilocation, _isBridgedToken, _isChainEvmCompatible, _isSubstrateRelayChain } from '@subwallet/extension-base/services/chain-service/utils';
13
13
  import { BN, BN_ZERO } from '@polkadot/util';
14
14
  import { subscribeEquilibriumTokenBalance } from "./equilibrium.js";
15
15
  export async function subscribeSubstrateBalance(addresses, chainInfo, chain, networkAPI, evmApiMap, callBack) {
@@ -20,6 +20,7 @@ export async function subscribeSubstrateBalance(addresses, chainInfo, chain, net
20
20
  let unsubLocalToken;
21
21
  let unsubEvmContractToken;
22
22
  let unsubWasmContractToken;
23
+ let unsubBridgedToken;
23
24
  try {
24
25
  if (_BALANCE_CHAIN_GROUP.bifrost.includes(chain)) {
25
26
  unsubLocalToken = await subscribeTokensAccountsPallet(addresses, chain, networkAPI.api, callBack);
@@ -32,6 +33,9 @@ export async function subscribeSubstrateBalance(addresses, chainInfo, chain, net
32
33
  } else if (_BALANCE_CHAIN_GROUP.centrifuge.includes(chain)) {
33
34
  unsubLocalToken = await subscribeOrmlTokensPallet(addresses, chain, networkAPI.api, callBack);
34
35
  }
36
+ if (_BALANCE_CHAIN_GROUP.supportBridged.includes(chain)) {
37
+ unsubBridgedToken = await subscribeBridgedBalance(addresses, chain, networkAPI.api, callBack);
38
+ }
35
39
  if (_isChainEvmCompatible(chainInfo)) {
36
40
  unsubEvmContractToken = subscribeERC20Interval(addresses, chain, evmApiMap, callBack);
37
41
  }
@@ -47,6 +51,7 @@ export async function subscribeSubstrateBalance(addresses, chainInfo, chain, net
47
51
  unsubLocalToken && unsubLocalToken();
48
52
  unsubEvmContractToken && unsubEvmContractToken();
49
53
  unsubWasmContractToken && unsubWasmContractToken();
54
+ unsubBridgedToken && unsubBridgedToken();
50
55
  };
51
56
  }
52
57
 
@@ -110,6 +115,59 @@ async function subscribeWithSystemAccountPallet(addresses, chainInfo, networkAPI
110
115
  unsub();
111
116
  };
112
117
  }
118
+ async function subscribeBridgedBalance(addresses, chain, api, callBack) {
119
+ const tokenMap = state.getAssetByChainAndAsset(chain, [_AssetType.LOCAL]);
120
+
121
+ // @ts-ignore
122
+ const unsubList = await Promise.all(Object.values(tokenMap).map(async tokenInfo => {
123
+ try {
124
+ const isBridgedToken = _isBridgedToken(tokenInfo);
125
+ if (isBridgedToken) {
126
+ const multiLocation = _getXcmAssetMultilocation(tokenInfo);
127
+ return await api.query.foreignAssets.account.multi(addresses.map(address => [multiLocation, address]), balances => {
128
+ const items = balances.map((balance, index) => {
129
+ const bdata = balance === null || balance === void 0 ? void 0 : balance.toHuman();
130
+ let frozen = BN_ZERO;
131
+ let total = BN_ZERO;
132
+ if (bdata) {
133
+ // @ts-ignore
134
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-argument
135
+ const addressBalance = new BN(String(bdata === null || bdata === void 0 ? void 0 : bdata.balance).replaceAll(',', '') || '0');
136
+
137
+ // @ts-ignore
138
+ if (bdata !== null && bdata !== void 0 && bdata.isFrozen) {
139
+ frozen = addressBalance;
140
+ } else {
141
+ total = addressBalance;
142
+ }
143
+ }
144
+ const free = total.sub(frozen);
145
+ return {
146
+ address: addresses[index],
147
+ tokenSlug: tokenInfo.slug,
148
+ free: free.toString(),
149
+ locked: frozen.toString(),
150
+ state: APIItemState.READY,
151
+ substrateInfo: {
152
+ miscFrozen: frozen.toString(),
153
+ reserved: '0'
154
+ }
155
+ };
156
+ });
157
+ callBack(items);
158
+ });
159
+ }
160
+ } catch (err) {
161
+ console.warn(err);
162
+ }
163
+ return undefined;
164
+ }));
165
+ return () => {
166
+ unsubList.forEach(unsub => {
167
+ unsub && unsub();
168
+ });
169
+ };
170
+ }
113
171
  function subscribePSP22Balance(addresses, chain, api, callBack) {
114
172
  let tokenList = {};
115
173
  const psp22ContractMap = {};
@@ -18,6 +18,7 @@ export declare const _BALANCE_CHAIN_GROUP: {
18
18
  statemine: string[];
19
19
  kusama: string[];
20
20
  centrifuge: string[];
21
+ supportBridged: string[];
21
22
  };
22
23
  export declare const _BALANCE_TOKEN_GROUP: {
23
24
  crab: string[];
@@ -63,6 +64,7 @@ export declare const _TRANSFER_CHAIN_GROUP: {
63
64
  avail: string[];
64
65
  pendulum: string[];
65
66
  centrifuge: string[];
67
+ disable_transfer: string[];
66
68
  };
67
69
  export declare const _BALANCE_PARSING_CHAIN_GROUP: {
68
70
  bobabeam: string[];
@@ -28,11 +28,12 @@ export const _BALANCE_CHAIN_GROUP = {
28
28
  kintsugi: ['kintsugi', 'interlay', 'kintsugi_test', 'mangatax_para'],
29
29
  genshiro: ['genshiro_testnet', 'genshiro'],
30
30
  equilibrium_parachain: ['equilibrium_parachain'],
31
- bifrost: ['bifrost', 'acala', 'karura', 'acala_testnet', 'pioneer', 'bitcountry', 'bifrost_dot', 'hydradx_main', 'pendulum', 'amplitude'],
32
- statemine: ['statemine', 'astar', 'shiden', 'statemint', 'moonbeam', 'moonbase', 'moonriver', 'crabParachain', 'darwinia2', 'parallel', 'calamari', 'manta_network'],
31
+ bifrost: ['bifrost', 'acala', 'karura', 'acala_testnet', 'pioneer', 'bitcountry', 'bifrost_dot', 'hydradx_main', 'pendulum', 'amplitude', 'continuum_network'],
32
+ statemine: ['statemine', 'astar', 'shiden', 'statemint', 'moonbeam', 'moonbase', 'moonriver', 'crabParachain', 'darwinia2', 'parallel', 'calamari', 'manta_network', 'rococo_assethub', 'liberlandTest', 'liberland'],
33
33
  kusama: ['kusama', 'kintsugi', 'kintsugi_test', 'interlay', 'acala', 'statemint', 'karura', 'bifrost'],
34
34
  // perhaps there are some runtime updates
35
- centrifuge: ['centrifuge']
35
+ centrifuge: ['centrifuge'],
36
+ supportBridged: ['rococo_assethub']
36
37
  };
37
38
  export const _BALANCE_TOKEN_GROUP = {
38
39
  crab: ['CKTON', 'PKTON'],
@@ -46,7 +47,7 @@ export const _NFT_CHAIN_GROUP = {
46
47
  statemine: ['statemine'],
47
48
  statemint: ['statemint'],
48
49
  unique_network: ['unique_network', 'quartz', 'opal'],
49
- bitcountry: ['bitcountry', 'pioneer'],
50
+ bitcountry: ['bitcountry', 'pioneer', 'continuum_network'],
50
51
  vara: ['vara_network']
51
52
  };
52
53
 
@@ -71,6 +72,7 @@ export const _STAKING_ERA_LENGTH_MAP = {
71
72
  shibuya: 24,
72
73
  bifrost_testnet: 0.5,
73
74
  bifrost: 2,
75
+ bifrost_dot: 24,
74
76
  ternoa: 24,
75
77
  calamari: 6,
76
78
  calamari_test: 6,
@@ -201,12 +203,13 @@ export const _TRANSFER_CHAIN_GROUP = {
201
203
  genshiro: ['genshiro_testnet', 'genshiro', 'equilibrium_parachain'],
202
204
  crab: ['crab', 'pangolin'],
203
205
  bitcountry: ['pioneer', 'bitcountry', 'bifrost', 'bifrost_dot'],
204
- statemine: ['statemint', 'statemine', 'darwinia2', 'astar', 'shiden', 'shibuya', 'parallel'],
206
+ statemine: ['statemint', 'statemine', 'darwinia2', 'astar', 'shiden', 'shibuya', 'parallel', 'liberland', 'liberlandTest'],
205
207
  riochain: ['riochain'],
206
208
  sora_substrate: ['sora_substrate'],
207
209
  avail: ['kate', 'goldberg_testnet'],
208
210
  pendulum: ['pendulum', 'amplitude', 'amplitude_test', 'hydradx_main'],
209
- centrifuge: ['centrifuge']
211
+ centrifuge: ['centrifuge'],
212
+ disable_transfer: ['invarch', 'continuum_network']
210
213
  };
211
214
  export const _BALANCE_PARSING_CHAIN_GROUP = {
212
215
  bobabeam: ['bobabeam', 'bobabase']
@@ -233,7 +236,8 @@ export const _XCM_TYPE = {
233
236
 
234
237
  export const _DEFAULT_ACTIVE_CHAINS = [..._DEFAULT_CHAINS, 'vara_network'];
235
238
  export const EVM_PASS_CONNECT_STATUS = {
236
- arbitrum_one: ['*']
239
+ arbitrum_one: ['*'],
240
+ okxTest: ['*']
237
241
  };
238
242
  export const EVM_REFORMAT_DECIMALS = {
239
243
  acala: ['acala_evm', 'karura_evm']