@subwallet/extension-base 1.2.24-0 → 1.2.24-1

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 (61) hide show
  1. package/cjs/core/substrate/assets-pallet.js +35 -0
  2. package/cjs/core/substrate/foreign-asset-pallet.js +13 -3
  3. package/cjs/core/substrate/nominationpools-pallet.js +4 -6
  4. package/cjs/core/substrate/ormlTokens-pallet.js +24 -0
  5. package/cjs/core/substrate/system-pallet.js +16 -18
  6. package/cjs/core/substrate/tokens-pallet.js +24 -0
  7. package/cjs/core/substrate/types.js +19 -0
  8. package/cjs/core/substrate/xcm-parser.js +16 -2
  9. package/cjs/core/utils.js +31 -0
  10. package/cjs/koni/background/handlers/Extension.js +1 -1
  11. package/cjs/packageInfo.js +1 -1
  12. package/cjs/services/balance-service/helpers/subscribe/substrate/equilibrium.js +2 -2
  13. package/cjs/services/balance-service/helpers/subscribe/substrate/index.js +120 -133
  14. package/cjs/services/balance-service/transfer/xcm/index.js +2 -1
  15. package/cjs/services/balance-service/transfer/xcm/polkadotXcm.js +1 -1
  16. package/cjs/services/balance-service/transfer/xcm/utils.js +3 -2
  17. package/cjs/services/chain-service/constants.js +1 -1
  18. package/cjs/services/chain-service/handler/SubstrateApi.js +128 -34
  19. package/cjs/services/chain-service/handler/SubstrateChainHandler.js +26 -9
  20. package/cjs/services/chain-service/utils/index.js +5 -0
  21. package/core/substrate/assets-pallet.d.ts +4 -0
  22. package/core/substrate/assets-pallet.js +28 -0
  23. package/core/substrate/foreign-asset-pallet.d.ts +4 -8
  24. package/core/substrate/foreign-asset-pallet.js +13 -3
  25. package/core/substrate/nominationpools-pallet.d.ts +4 -10
  26. package/core/substrate/nominationpools-pallet.js +4 -5
  27. package/core/substrate/ormlTokens-pallet.d.ts +4 -0
  28. package/core/substrate/ormlTokens-pallet.js +17 -0
  29. package/core/substrate/system-pallet.d.ts +4 -24
  30. package/core/substrate/system-pallet.js +16 -21
  31. package/core/substrate/tokens-pallet.d.ts +5 -0
  32. package/core/substrate/tokens-pallet.js +16 -0
  33. package/core/substrate/types.d.ts +43 -0
  34. package/core/substrate/types.js +12 -0
  35. package/core/substrate/xcm-parser.d.ts +1 -0
  36. package/core/substrate/xcm-parser.js +15 -2
  37. package/core/utils.d.ts +4 -0
  38. package/core/utils.js +23 -0
  39. package/koni/api/staking/bonding/relayChain.d.ts +1 -1
  40. package/koni/background/handlers/Extension.js +1 -1
  41. package/koni/background/handlers/State.d.ts +2 -2
  42. package/package.json +31 -6
  43. package/packageInfo.js +1 -1
  44. package/services/balance-service/helpers/subscribe/substrate/equilibrium.js +2 -2
  45. package/services/balance-service/helpers/subscribe/substrate/index.js +109 -121
  46. package/services/balance-service/transfer/xcm/index.d.ts +1 -1
  47. package/services/balance-service/transfer/xcm/index.js +2 -1
  48. package/services/balance-service/transfer/xcm/polkadotXcm.js +1 -1
  49. package/services/balance-service/transfer/xcm/utils.d.ts +1 -1
  50. package/services/balance-service/transfer/xcm/utils.js +3 -2
  51. package/services/chain-service/constants.js +1 -1
  52. package/services/chain-service/handler/SubstrateApi.d.ts +5 -7
  53. package/services/chain-service/handler/SubstrateApi.js +128 -35
  54. package/services/chain-service/handler/SubstrateChainHandler.d.ts +5 -6
  55. package/services/chain-service/handler/SubstrateChainHandler.js +26 -9
  56. package/services/chain-service/index.d.ts +3 -3
  57. package/services/chain-service/types.d.ts +22 -5
  58. package/services/chain-service/utils/index.d.ts +1 -0
  59. package/services/chain-service/utils/index.js +3 -0
  60. package/services/earning-service/handlers/nomination-pool/index.d.ts +1 -1
  61. package/types/balance/index.d.ts +2 -3
@@ -1,12 +1,11 @@
1
1
  import '@polkadot/types-augment';
2
2
  import { MetadataItem } from '@subwallet/extension-base/background/KoniTypes';
3
3
  import { _ApiOptions } from '@subwallet/extension-base/services/chain-service/handler/types';
4
- import { _ChainConnectionStatus, _SubstrateApi, _SubstrateDefaultFormatBalance } from '@subwallet/extension-base/services/chain-service/types';
5
- import { BehaviorSubject } from 'rxjs';
4
+ import { _ChainConnectionStatus, _SubstrateAdapterQueryArgs, _SubstrateAdapterSubscriptionArgs, _SubstrateApi } from '@subwallet/extension-base/services/chain-service/types';
5
+ import { BehaviorSubject, Subscription } from 'rxjs';
6
6
  import { ApiPromise } from '@polkadot/api';
7
- import { SubmittableExtrinsicFunction } from '@polkadot/api/promise/types';
8
7
  import { ProviderInterface } from '@polkadot/rpc-provider/types';
9
- import { Registry } from '@polkadot/types/types';
8
+ import { AnyJson, Registry } from '@polkadot/types/types';
10
9
  export declare class SubstrateApi implements _SubstrateApi {
11
10
  chainSlug: string;
12
11
  api: ApiPromise;
@@ -25,9 +24,6 @@ export declare class SubstrateApi implements _SubstrateApi {
25
24
  substrateRetry: number;
26
25
  get connectionStatus(): _ChainConnectionStatus;
27
26
  private updateConnectionStatus;
28
- apiDefaultTx?: SubmittableExtrinsicFunction;
29
- apiDefaultTxSudo?: SubmittableExtrinsicFunction;
30
- defaultFormatBalance?: _SubstrateDefaultFormatBalance;
31
27
  registry: Registry;
32
28
  specName: string;
33
29
  specVersion: string;
@@ -48,4 +44,6 @@ export declare class SubstrateApi implements _SubstrateApi {
48
44
  onDisconnect(): void;
49
45
  onError(e: Error): void;
50
46
  fillApiInfo(): Promise<void>;
47
+ makeRpcQuery<T>({ args, method, module, section }: _SubstrateAdapterQueryArgs): Promise<T>;
48
+ subscribeDataWithMulti(params: _SubstrateAdapterSubscriptionArgs[], callback: (rs: Record<string, AnyJson[]>) => void): Subscription;
51
49
  }
@@ -7,16 +7,13 @@ import { GearApi } from '@gear-js/api';
7
7
  import { rpc as oakRpc, types as oakTypes } from '@oak-foundation/types';
8
8
  import { _API_OPTIONS_CHAIN_GROUP, API_AUTO_CONNECT_MS, API_CONNECT_TIMEOUT } from '@subwallet/extension-base/services/chain-service/constants';
9
9
  import { getSubstrateConnectProvider } from '@subwallet/extension-base/services/chain-service/handler/light-client';
10
- import { DEFAULT_AUX } from '@subwallet/extension-base/services/chain-service/handler/SubstrateChainHandler';
11
10
  import { _ChainConnectionStatus } from '@subwallet/extension-base/services/chain-service/types';
12
11
  import { createPromiseHandler } from '@subwallet/extension-base/utils/promise';
13
12
  import { goldbergRpc, goldbergTypes, spec as availSpec } from 'avail-js-sdk';
14
- import { BehaviorSubject } from 'rxjs';
13
+ import { BehaviorSubject, combineLatest, map, Observable } from 'rxjs';
15
14
  import { ApiPromise, WsProvider } from '@polkadot/api';
16
15
  import { typesBundle as _typesBundle } from '@polkadot/apps-config/api';
17
16
  import { TypeRegistry } from '@polkadot/types/create';
18
- import { formatBalance } from '@polkadot/util';
19
- import { defaults as addressDefaults } from '@polkadot/util-crypto/address/defaults';
20
17
  const typesBundle = {
21
18
  ..._typesBundle
22
19
  };
@@ -56,6 +53,11 @@ export class SubstrateApi {
56
53
  this.connectionStatusSubject.next(status);
57
54
  }
58
55
  }
56
+
57
+ // apiDefaultTx?: SubmittableExtrinsicFunction;
58
+ // apiDefaultTxSudo?: SubmittableExtrinsicFunction;
59
+ // defaultFormatBalance?: _SubstrateDefaultFormatBalance;
60
+
59
61
  specName = '';
60
62
  specVersion = '';
61
63
  systemChain = '';
@@ -224,43 +226,134 @@ export class SubstrateApi {
224
226
  console.warn(`${this.chainSlug} connection got error`, e);
225
227
  }
226
228
  async fillApiInfo() {
227
- var _api$rpc$system, _api$rpc$system2, _api$rpc$system3;
228
- const {
229
- api,
230
- registry
231
- } = this;
232
- const DEFAULT_DECIMALS = registry.createType('u32', 12);
233
- const DEFAULT_SS58 = registry.createType('u32', addressDefaults.prefix);
229
+ // const { registry } = this;
230
+ // const DEFAULT_DECIMALS = registry.createType('u32', 12);
231
+ // const DEFAULT_SS58 = registry.createType('u32', addressDefaults.prefix);
232
+
234
233
  this.specName = this.api.runtimeVersion.specName.toString();
235
234
  this.specVersion = this.api.runtimeVersion.specVersion.toString();
236
- const [systemChain, systemName, systemVersion] = await Promise.all([(_api$rpc$system = api.rpc.system) === null || _api$rpc$system === void 0 ? void 0 : _api$rpc$system.chain(), (_api$rpc$system2 = api.rpc.system) === null || _api$rpc$system2 === void 0 ? void 0 : _api$rpc$system2.name(), (_api$rpc$system3 = api.rpc.system) === null || _api$rpc$system3 === void 0 ? void 0 : _api$rpc$system3.version()]);
235
+ const [systemChain, systemName, systemVersion] = await Promise.all([this.makeRpcQuery({
236
+ section: 'rpc',
237
+ module: 'system',
238
+ method: 'chain'
239
+ }), this.makeRpcQuery({
240
+ section: 'rpc',
241
+ module: 'system',
242
+ method: 'name'
243
+ }), this.makeRpcQuery({
244
+ section: 'rpc',
245
+ module: 'system',
246
+ method: 'version'
247
+ })]);
237
248
  this.systemChain = systemChain.toString();
238
249
  this.systemName = systemName.toString();
239
250
  this.systemVersion = systemVersion.toString();
240
- const properties = registry.createType('ChainProperties', {
241
- ss58Format: api.registry.chainSS58,
242
- tokenDecimals: api.registry.chainDecimals,
243
- tokenSymbol: api.registry.chainTokens
244
- });
245
- const ss58Format = properties.ss58Format.unwrapOr(DEFAULT_SS58).toNumber();
246
- const tokenSymbol = properties.tokenSymbol.unwrapOr([formatBalance.getDefaults().unit, ...DEFAULT_AUX]);
247
- const tokenDecimals = properties.tokenDecimals.unwrapOr([DEFAULT_DECIMALS]);
248
- registry.setChainProperties(registry.createType('ChainProperties', {
249
- ss58Format,
250
- tokenDecimals,
251
- tokenSymbol
252
- }));
251
+
252
+ // const [ss58Format, tokenDecimals, tokenSymbol] = await Promise.all([
253
+ // this.makeRpcQuery<number | undefined>({ section: 'registry', module: 'chainSS58' }),
254
+ // this.makeRpcQuery<number[]>({ section: 'registry', module: 'chainDecimals' }),
255
+ // this.makeRpcQuery<string[]>({ section: 'registry', module: 'chainTokens' })
256
+ // ]);
257
+ //
258
+ // const properties = registry.createType('ChainProperties', {
259
+ // ss58Format,
260
+ // tokenDecimals,
261
+ // tokenSymbol
262
+ // });
263
+ // const ss58Format = properties.ss58Format.unwrapOr(DEFAULT_SS58).toNumber();
264
+ // const tokenSymbol = properties.tokenSymbol.unwrapOr([formatBalance.getDefaults().unit, ...DEFAULT_AUX]);
265
+ // const tokenDecimals = properties.tokenDecimals.unwrapOr([DEFAULT_DECIMALS]);
266
+ //
267
+ // registry.setChainProperties(registry.createType('ChainProperties', { ss58Format, tokenDecimals, tokenSymbol }));
253
268
 
254
269
  // first set up the UI helpers
255
- this.defaultFormatBalance = {
256
- decimals: tokenDecimals.map(b => {
257
- return b.toNumber();
258
- }),
259
- unit: tokenSymbol[0].toString()
260
- };
261
- const defaultSection = Object.keys(api.tx)[0];
262
- const defaultMethod = Object.keys(api.tx[defaultSection])[0];
263
- this.apiDefaultTx = api.tx[defaultSection][defaultMethod];
264
- this.apiDefaultTxSudo = api.tx.system && api.tx.system.setCode || this.apiDefaultTx;
270
+ // this.defaultFormatBalance = {
271
+ // decimals: tokenDecimals.map((b: BN) => {
272
+ // return b.toNumber();
273
+ // }),
274
+ // unit: tokenSymbol[0].toString()
275
+ // };
276
+ //
277
+ // const defaultSection = Object.keys(api.tx)[0];
278
+ // const defaultMethod = Object.keys(api.tx[defaultSection])[0];
279
+
280
+ // this.apiDefaultTx = api.tx[defaultSection][defaultMethod];
281
+ // this.apiDefaultTxSudo = (api.tx.system && api.tx.system.setCode) || this.apiDefaultTx;
282
+ }
283
+
284
+ async makeRpcQuery({
285
+ args,
286
+ method,
287
+ module,
288
+ section
289
+ }) {
290
+ const isGetterCall = section === 'genesisHash' || section === 'extrinsicVersion' || section === 'runtimeVersion' || section === 'runtimeMetadata' || section === 'registry';
291
+ const isRuntimeConstQuery = section === 'consts' && !!method && !!module && !args;
292
+ const isRpcQuery = section === 'rpc' && !!method && !!module && !args;
293
+ const isStateQuery = section === 'query' && method && module;
294
+ if (isGetterCall) {
295
+ if (section === 'genesisHash') {
296
+ return this.api[section].toHex();
297
+ } else if (section === 'extrinsicVersion') {
298
+ return this.api[section];
299
+ } else if (section === 'runtimeVersion') {
300
+ return this.api[section].toPrimitive();
301
+ } else if (section === 'runtimeMetadata') {
302
+ return this.api[section].toHex();
303
+ } else if (section === 'registry') {
304
+ return this.api[section];
305
+ }
306
+ }
307
+ if (isRuntimeConstQuery) {
308
+ if (!this.api[section][module]) {
309
+ return undefined;
310
+ }
311
+ return this.api[section][module][method].toPrimitive();
312
+ }
313
+ if (isRpcQuery) {
314
+ // @ts-ignore
315
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
316
+ if (!this.api[section][module]) {
317
+ return undefined;
318
+ }
319
+
320
+ // @ts-ignore
321
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
322
+ return (await this.api[section][module][method]()).toPrimitive(); // todo: improve this
323
+ }
324
+
325
+ if (isStateQuery) {
326
+ if (!this.api[section][module]) {
327
+ return undefined;
328
+ }
329
+ if (args) {
330
+ return (await this.api[section][module][method](...args)).toPrimitive();
331
+ } else {
332
+ return (await this.api[section][module][method]()).toPrimitive();
333
+ }
334
+ }
335
+ return Promise.reject(new Error('Cannot handle query'));
336
+ }
337
+ subscribeDataWithMulti(params, callback) {
338
+ const apiRx = this.api.rx;
339
+ const observables = {};
340
+ params.forEach(queryParams => {
341
+ const {
342
+ args,
343
+ method,
344
+ module,
345
+ section
346
+ } = queryParams;
347
+ const key = `${section}_${module}_${method}`;
348
+ if (!this.api[section][module] || !this.api[section][module][method]) {
349
+ // if method not found, returns an empty observable
350
+ observables[key] = new Observable(subscriber => {
351
+ subscriber.next([]);
352
+ });
353
+ } else {
354
+ observables[key] = apiRx[section][module][method].multi(args).pipe(map(codecs => codecs.map(codec => codec.toPrimitive())));
355
+ }
356
+ });
357
+ return combineLatest(observables).subscribe(callback);
265
358
  }
266
359
  }
@@ -1,7 +1,6 @@
1
1
  import { _AssetType } from '@subwallet/chain-list/types';
2
2
  import { ChainService } from '@subwallet/extension-base/services/chain-service';
3
3
  import { AbstractChainHandler } from '@subwallet/extension-base/services/chain-service/handler/AbstractChainHandler';
4
- import { SubstrateApi } from '@subwallet/extension-base/services/chain-service/handler/SubstrateApi';
5
4
  import { _ApiOptions, _SubstrateChainSpec } from '@subwallet/extension-base/services/chain-service/handler/types';
6
5
  import { _SmartContractTokenInfo, _SubstrateApi } from '@subwallet/extension-base/services/chain-service/types';
7
6
  export declare const DEFAULT_AUX: string[];
@@ -9,9 +8,9 @@ export declare class SubstrateChainHandler extends AbstractChainHandler {
9
8
  private substrateApiMap;
10
9
  private logger;
11
10
  constructor(parent?: ChainService);
12
- getSubstrateApiMap(): Record<string, SubstrateApi>;
13
- getSubstrateApiByChain(chainSlug: string): SubstrateApi;
14
- getApiByChain(chain: string): SubstrateApi;
11
+ getSubstrateApiMap(): Record<string, _SubstrateApi>;
12
+ getSubstrateApiByChain(chainSlug: string): _SubstrateApi;
13
+ getApiByChain(chain: string): _SubstrateApi;
15
14
  wakeUp(): Promise<void>;
16
15
  sleep(): Promise<void>;
17
16
  recoverApi(chainSlug: string): Promise<void>;
@@ -21,7 +20,7 @@ export declare class SubstrateChainHandler extends AbstractChainHandler {
21
20
  private getGrc20TokenInfo;
22
21
  private getVftTokenInfo;
23
22
  getSubstrateContractTokenInfo(contractAddress: string, tokenType: _AssetType, originChain: string, contractCaller?: string): Promise<_SmartContractTokenInfo>;
24
- setSubstrateApi(chainSlug: string, substrateApi: SubstrateApi): void;
23
+ setSubstrateApi(chainSlug: string, substrateApi: _SubstrateApi): void;
25
24
  destroySubstrateApi(chainSlug: string): void;
26
- initApi(chainSlug: string, apiUrl: string, { externalApiPromise, onUpdateStatus, providerName }?: Omit<_ApiOptions, 'metadata'>): Promise<SubstrateApi>;
25
+ initApi(chainSlug: string, apiUrl: string, { externalApiPromise, onUpdateStatus, providerName }?: Omit<_ApiOptions, 'metadata'>): Promise<_SubstrateApi>;
27
26
  }
@@ -62,12 +62,13 @@ export class SubstrateChainHandler extends AbstractChainHandler {
62
62
  }
63
63
  }
64
64
  async getChainSpec(substrateApi) {
65
- var _substrateApi$api$gen, _substrateApi$api, _substrateApi$api$con, _substrateApi$api$con2, _substrateApi$api$con3;
66
65
  const result = {
67
66
  addressPrefix: -1,
68
67
  decimals: 0,
69
68
  existentialDeposit: '',
70
- genesisHash: (_substrateApi$api$gen = substrateApi.api.genesisHash) === null || _substrateApi$api$gen === void 0 ? void 0 : _substrateApi$api$gen.toHex(),
69
+ genesisHash: await substrateApi.makeRpcQuery({
70
+ section: 'genesisHash'
71
+ }),
71
72
  name: '',
72
73
  symbol: '',
73
74
  paraId: null
@@ -75,17 +76,33 @@ export class SubstrateChainHandler extends AbstractChainHandler {
75
76
  const {
76
77
  chainDecimals,
77
78
  chainTokens
78
- } = substrateApi.api.registry;
79
- if (substrateApi.api.query.parachainInfo) {
80
- result.paraId = (await substrateApi.api.query.parachainInfo.parachainId()).toPrimitive();
81
- }
79
+ } = await substrateApi.makeRpcQuery({
80
+ section: 'registry'
81
+ });
82
+ result.paraId = await substrateApi.makeRpcQuery({
83
+ section: 'query',
84
+ module: 'parachainInfo',
85
+ method: 'parachainId'
86
+ });
82
87
 
83
88
  // get first token by default, might change
84
- result.name = (await substrateApi.api.rpc.system.chain()).toPrimitive();
89
+ result.name = await substrateApi.makeRpcQuery({
90
+ section: 'rpc',
91
+ module: 'system',
92
+ method: 'chain'
93
+ });
85
94
  result.symbol = chainTokens[0];
86
95
  result.decimals = chainDecimals[0];
87
- result.addressPrefix = (_substrateApi$api = substrateApi.api) === null || _substrateApi$api === void 0 ? void 0 : (_substrateApi$api$con = _substrateApi$api.consts) === null || _substrateApi$api$con === void 0 ? void 0 : (_substrateApi$api$con2 = _substrateApi$api$con.system) === null || _substrateApi$api$con2 === void 0 ? void 0 : (_substrateApi$api$con3 = _substrateApi$api$con2.ss58Prefix) === null || _substrateApi$api$con3 === void 0 ? void 0 : _substrateApi$api$con3.toPrimitive();
88
- result.existentialDeposit = substrateApi.api.consts.balances.existentialDeposit.toString();
96
+ result.addressPrefix = await substrateApi.makeRpcQuery({
97
+ section: 'consts',
98
+ module: 'system',
99
+ method: 'ss58Prefix'
100
+ });
101
+ result.existentialDeposit = await substrateApi.makeRpcQuery({
102
+ section: 'consts',
103
+ module: 'balances',
104
+ method: 'existentialDeposit'
105
+ });
89
106
  return result;
90
107
  }
91
108
  async getPsp22TokenInfo(apiPromise, contractAddress, contractCaller) {
@@ -2,7 +2,7 @@
2
2
  import { _AssetRef, _AssetType, _ChainAsset, _ChainInfo, _MultiChainAsset } from '@subwallet/chain-list/types';
3
3
  import { AssetSetting, ValidateNetworkResponse } from '@subwallet/extension-base/background/KoniTypes';
4
4
  import { MantaPrivateHandler } from '@subwallet/extension-base/services/chain-service/handler/manta/MantaPrivateHandler';
5
- import { _ChainApiStatus, _ChainConnectionStatus, _ChainState, _NetworkUpsertParams, _ValidateCustomAssetRequest, _ValidateCustomAssetResponse } from '@subwallet/extension-base/services/chain-service/types';
5
+ import { _ChainApiStatus, _ChainConnectionStatus, _ChainState, _NetworkUpsertParams, _SubstrateApi, _ValidateCustomAssetRequest, _ValidateCustomAssetResponse } from '@subwallet/extension-base/services/chain-service/types';
6
6
  import { EventService } from '@subwallet/extension-base/services/event-service';
7
7
  import { IMetadataItem } from '@subwallet/extension-base/services/storage-service/databases';
8
8
  import DatabaseService from '@subwallet/extension-base/services/storage-service/DatabaseService';
@@ -38,8 +38,8 @@ export declare class ChainService {
38
38
  get swapRefMap(): Record<string, _AssetRef>;
39
39
  getEvmApi(slug: string): import("./handler/EvmApi").EvmApi;
40
40
  getEvmApiMap(): Record<string, import("./handler/EvmApi").EvmApi>;
41
- getSubstrateApiMap(): Record<string, import("./handler/SubstrateApi").SubstrateApi>;
42
- getSubstrateApi(slug: string): import("./handler/SubstrateApi").SubstrateApi;
41
+ getSubstrateApiMap(): Record<string, _SubstrateApi>;
42
+ getSubstrateApi(slug: string): _SubstrateApi;
43
43
  getChainCurrentProviderByKey(slug: string): {
44
44
  endpoint: string;
45
45
  providerName: string;
@@ -1,11 +1,13 @@
1
+ import type { ApiInterfaceRx } from '@polkadot/api/types';
1
2
  import { _AssetRef, _AssetType, _ChainAsset, _ChainInfo, _CrowdloanFund } from '@subwallet/chain-list/types';
2
3
  import { _CHAIN_VALIDATION_ERROR } from '@subwallet/extension-base/services/chain-service/handler/types';
3
- import { BehaviorSubject } from 'rxjs';
4
+ import { BehaviorSubject, Subscription } from 'rxjs';
4
5
  import Web3 from 'web3';
5
6
  import { ApiPromise } from '@polkadot/api';
7
+ import { Getters } from '@polkadot/api/base/Getters';
6
8
  import { SubmittableExtrinsicFunction } from '@polkadot/api/promise/types';
7
- import { ChainProperties, ChainType } from '@polkadot/types/interfaces';
8
- import { Registry } from '@polkadot/types/types';
9
+ import { ChainProperties, ChainType, RuntimeVersion } from '@polkadot/types/interfaces';
10
+ import { AnyJson, Registry } from '@polkadot/types/types';
9
11
  export interface _DataMap {
10
12
  chainInfoMap: Record<string, _ChainInfo>;
11
13
  chainStateMap: Record<string, _ChainState>;
@@ -68,7 +70,7 @@ export interface _SubstrateApiState {
68
70
  apiDefaultTxSudo?: SubmittableExtrinsicFunction;
69
71
  defaultFormatBalance?: _SubstrateDefaultFormatBalance;
70
72
  }
71
- export interface _SubstrateApi extends _SubstrateApiState, _ChainBaseApi {
73
+ export interface _SubstrateApi extends _SubstrateApiState, _ChainBaseApi, _SubstrateApiAdapter {
72
74
  api: ApiPromise;
73
75
  isReady: Promise<_SubstrateApi>;
74
76
  connect: (_callbackUpdateMetadata?: (substrateApi: _SubstrateApi) => void) => void;
@@ -77,7 +79,22 @@ export interface _SubstrateApi extends _SubstrateApiState, _ChainBaseApi {
77
79
  systemChain: string;
78
80
  systemName: string;
79
81
  systemVersion: string;
80
- registry: Registry;
82
+ registry?: Registry;
83
+ useLightClient: boolean;
84
+ }
85
+ export interface _SubstrateAdapterQueryArgs {
86
+ section: keyof Getters<'promise'>;
87
+ module?: string;
88
+ method?: string;
89
+ args?: unknown[];
90
+ }
91
+ export interface _SubstrateAdapterSubscriptionArgs extends Omit<Required<_SubstrateAdapterQueryArgs>, 'section'> {
92
+ section: keyof Pick<ApiInterfaceRx, 'query'>;
93
+ isMultiQuery?: boolean;
94
+ }
95
+ export interface _SubstrateApiAdapter {
96
+ makeRpcQuery<T extends AnyJson | `0x${string}` | Registry | RuntimeVersion>(params: _SubstrateAdapterQueryArgs): Promise<T>;
97
+ subscribeDataWithMulti(params: _SubstrateAdapterSubscriptionArgs[], callback: (rs: Record<string, AnyJson[]>) => void): Subscription;
81
98
  }
82
99
  export interface _EvmApi extends _ChainBaseApi {
83
100
  api: Web3;
@@ -91,6 +91,7 @@ export declare const findChainInfoByHalfGenesisHash: (chainMap: Record<string, _
91
91
  export declare const findChainInfoByChainId: (chainMap: Record<string, _ChainInfo>, chainId?: number) => _ChainInfo | null;
92
92
  export declare function _isMantaZkAsset(chainAsset: _ChainAsset): boolean;
93
93
  export declare function _getChainExistentialDeposit(chainInfo: _ChainInfo): string;
94
+ export declare function _getAssetExistentialDeposit(chainAsset: _ChainAsset): string;
94
95
  export declare function randomizeProvider(providers: Record<string, string>, excludedKeys?: string[]): {
95
96
  providerKey: string;
96
97
  providerValue: string;
@@ -417,6 +417,9 @@ export function _getChainExistentialDeposit(chainInfo) {
417
417
  var _chainInfo$substrateI20;
418
418
  return (chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$substrateI20 = chainInfo.substrateInfo) === null || _chainInfo$substrateI20 === void 0 ? void 0 : _chainInfo$substrateI20.existentialDeposit) || '0';
419
419
  }
420
+ export function _getAssetExistentialDeposit(chainAsset) {
421
+ return (chainAsset === null || chainAsset === void 0 ? void 0 : chainAsset.minAmount) || '0';
422
+ }
420
423
  export function randomizeProvider(providers, excludedKeys) {
421
424
  if (Object.keys(providers).length === 0) {
422
425
  return {
@@ -1,6 +1,6 @@
1
1
  import { TransactionError } from '@subwallet/extension-base/background/errors/TransactionError';
2
2
  import { ExtrinsicType, UnstakingInfo } from '@subwallet/extension-base/background/KoniTypes';
3
- import { PalletNominationPoolsPoolMember } from '@subwallet/extension-base/core/substrate/nominationpools-pallet';
3
+ import { PalletNominationPoolsPoolMember } from '@subwallet/extension-base/core/substrate/types';
4
4
  import KoniState from '@subwallet/extension-base/koni/background/handlers/State';
5
5
  import { _SubstrateApi } from '@subwallet/extension-base/services/chain-service/types';
6
6
  import { BaseYieldPositionInfo, EarningRewardHistoryItem, EarningRewardItem, HandleYieldStepData, NominationPoolInfo, OptimalYieldPath, OptimalYieldPathParams, StakeCancelWithdrawalParams, SubmitJoinNominationPool, SubmitYieldJoinData, TransactionData, YieldPoolInfo, YieldPoolMethodInfo, YieldPoolType, YieldPositionInfo, YieldStepBaseInfo, YieldTokenBaseInfo } from '@subwallet/extension-base/types';
@@ -1,7 +1,6 @@
1
1
  import { _ChainAsset, _ChainInfo } from '@subwallet/chain-list/types';
2
2
  import { _BalanceMetadata, APIItemState, ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
3
- import { _EvmApi } from '@subwallet/extension-base/services/chain-service/types';
4
- import { ApiPromise } from '@polkadot/api';
3
+ import { _EvmApi, _SubstrateApi } from '@subwallet/extension-base/services/chain-service/types';
5
4
  import { BN } from '@polkadot/util';
6
5
  export interface TokenBalanceRaw {
7
6
  reserved: BN;
@@ -43,7 +42,7 @@ export interface SubscribeBasePalletBalance {
43
42
  extrinsicType?: ExtrinsicType;
44
43
  }
45
44
  export interface SubscribeSubstratePalletBalance extends SubscribeBasePalletBalance {
46
- substrateApi: ApiPromise;
45
+ substrateApi: _SubstrateApi;
47
46
  includeNativeToken?: boolean;
48
47
  }
49
48
  export interface SubscribeEvmPalletBalance extends SubscribeBasePalletBalance {