@moonbeam-network/xcm-sdk 2.7.10 → 3.0.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.
package/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2022 PureStake
1
+ Copyright 2024 Moonbeam Foundation
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
4
 
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  The Moonbeam XCM SDK enables developers to easily transfer assets between chains, either between parachains or between a parachain and the relay chain, within the Polkadot/Kusama ecosystem. With the SDK, you don't need to worry about determining the multilocation of the origin or destination assets or which extrinsics are used on which networks to send XCM transfers.
2
2
 
3
- The XCM SDK offers helper functions, that provide a very simple interface to execute XCM transfers between chains in the Polkadot/Kusama ecosystem. In addition, the XCM config package allows any parachain project to add their information in a standard way, so they can be immediately supported by the XCM SDK.
3
+ The XCM SDK offers helper functions that provide a very simple interface to execute XCM transfers between chains in the Polkadot/Kusama ecosystem. In addition, the XCM config package allows any parachain project to add their information in a standard way, so they can be immediately supported by the XCM SDK.
4
4
 
5
5
  # Documentation
6
6
 
@@ -15,40 +15,30 @@ npm i @moonbeam-network/xcm-sdk
15
15
  :warning: You need to have peer dependencies of SDK installed as well.
16
16
 
17
17
  ```bash
18
- npm i @polkadot/api @polkadot/api-augment @polkadot/types @polkadot/util @polkadot/util-crypto @polkadot/apps-config ethers
18
+ npm i @polkadot/api @polkadot/util-crypto
19
19
  ```
20
20
 
21
21
  # Usage
22
22
 
23
- The following sections contain basic examples of how to work with the XCM SDK to build transfer data to transfer an asset from one chain to another and how to submit the transfer. For a detailed overview on how to use each method, including a reference to the parameters and returned data of each method exposed by the SDK, please refer to the [XCM SDK docs](https://docs.moonbeam.network/builders/interoperability/xcm/xcm-sdk/v1/).
23
+ The following sections contain basic examples of how to work with the XCM SDK to build transfer data to transfer an asset from one chain to another and how to submit the transfer. For a detailed overview on how to use it, please refer to the [XCM SDK docs](https://moonbeam-foundation.github.io/xcm-sdk/latest/example-usage/xcm).
24
24
 
25
25
  ## Build XCM Transfer Data
26
26
 
27
27
  ```js
28
28
  import { Sdk } from '@moonbeam-network/xcm-sdk';
29
29
 
30
- const { assets, getTransferData } = Sdk();
31
-
32
- // You can build the XCM transfer data via the assets function
33
- const dataViaAssetsMethod = await assets()
34
- .asset('INSERT_ASSET')
35
- .source('INSERT_SOURCE_CHAIN')
36
- .destination('INSERT_DESTINATION_CHAIN')
37
- .accounts('INSERT_SOURCE_ADDRESS', 'INSERT_DESTINATION_ADDRESS', {
38
- evmSigner?: 'INSERT_EVM_SIGNER',
39
- polkadotSigner?: 'INSERT_POLKADOT_SIGNER',
40
- });
41
-
42
- // Or via the getTransferData function
43
- const dataViaGetTransferDataMethod = await getTransferData({
44
- destinationAddress: 'INSERT_DESTINATION_ADDRESS',
45
- destinationKeyOrChain: 'INSERT_DESTINATION_CHAIN',
46
- evmSigner?: 'INSERT_EVM_SIGNER',
47
- keyOrAsset: 'INSERT_ASSET',
48
- polkadotSigner?: 'INSERT_POLKADOT_SIGNER',
49
- sourceAddress: 'INSERT_SOURCE_ADDRESS',
50
- sourceKeyOrChain: 'INSERT_SOURCE_CHAIN',
51
- });
30
+ const transferData = async () => {
31
+ const transferData = await Sdk()
32
+ .setAsset(INSERT_ASSET)
33
+ .setSource(INSERT_SOURCE_CHAIN)
34
+ .setDestination(INSERT_DESTINATION_CHAIN)
35
+ .setAddresses({
36
+ sourceAddress: INSERT_SOURCE_ADDRESS,
37
+ destinationAddress: INSERT_DESTINATION_ADDRESS,
38
+ });
39
+ };
40
+
41
+ fromPolkadot();
52
42
  ```
53
43
 
54
44
  ## Transfer
@@ -56,7 +46,7 @@ const dataViaGetTransferDataMethod = await getTransferData({
56
46
  ```js
57
47
  ...
58
48
 
59
- const hash = await dataViaGetTransferDataMethod.transfer('INSERT_TRANSFER_AMOUNT');
49
+ const hash = await transferData.transfer(INSERT_TRANSFER_AMOUNT, { INSERT_SIGNERS });
60
50
  ```
61
51
 
62
52
  # Examples
@@ -66,20 +56,27 @@ const hash = await dataViaGetTransferDataMethod.transfer('INSERT_TRANSFER_AMOUNT
66
56
  ```bash
67
57
  git clone git@github.com:moonbeam-foundation/xcm-sdk.git
68
58
  cd xcm-sdk
69
- npm i
59
+ pnpm install
70
60
  cd examples/sdk-simple
71
61
 
72
62
  # edit index.ts by adding your accounts
73
63
 
74
- npm start
64
+ pnpm run start
75
65
  ```
76
66
 
77
67
  # Contributing
78
68
 
69
+ First fork the repository and clone it.
70
+
79
71
  ```bash
80
- git clone git@github.com:moonbeam-foundation/xcm-sdk.git
81
- npm i
82
- npm run dev
72
+ git clone git@github.com:YOUR_GITHUB_USERNAME/xcm-sdk.git
73
+ pnpm install
74
+ ```
75
+
76
+ Optionally, you can install the `pre-commit` hook to run the linter and tests before committing:
77
+
78
+ ```bash
79
+ pnpm lefthook install
83
80
  ```
84
81
 
85
82
  # Tests
@@ -87,16 +84,13 @@ npm run dev
87
84
  ## Unit tests
88
85
 
89
86
  ```bash
90
- npm run test
87
+ pnpm run test
91
88
  ```
92
89
 
93
90
  ## Acceptance tests
94
91
 
95
92
  ```bash
96
- cp .env.example .env
97
- # add private key and suri to .env file
98
-
99
- npm run test:acc
93
+ pnpm run test:acc
100
94
  ```
101
95
 
102
96
  # Release
@@ -106,7 +100,7 @@ To create a dev version go to GitHub actions and run `publish dev versions` work
106
100
  To create a release version run:
107
101
 
108
102
  ```bash
109
- npm run changeset
103
+ pnpm run changeset
110
104
  ```
111
105
 
112
106
  # Testing the change in the SDK locally
@@ -114,17 +108,19 @@ npm run changeset
114
108
  Build the project:
115
109
 
116
110
  ```bash
117
- npm run build
111
+ pnpm run build
118
112
  ```
119
113
 
114
+ Link the SDK:
115
+
120
116
  ```bash
121
- npm run link
117
+ pnpm run clean && pnpm run build && pnpm run link
122
118
  ```
123
119
 
124
120
  In your project where you would like to test the changes:
125
121
 
126
122
  ```bash
127
- npm link @moonbeam-network/xcm-types @moonbeam-network/xcm-utils @moonbeam-network/xcm-builder @moonbeam-network/xcm-config @moonbeam-network/xcm-sdk
123
+ pnpm link @moonbeam-network/xcm-types @moonbeam-network/xcm-utils @moonbeam-network/xcm-builder @moonbeam-network/xcm-config @moonbeam-network/xcm-sdk
128
124
  ```
129
125
 
130
126
  If you need you can link other packages too.
@@ -132,5 +128,5 @@ If you need you can link other packages too.
132
128
  After testing is done, unlink the SDK:
133
129
 
134
130
  ```bash
135
- npm unlink @moonbeam-network/xcm-types @moonbeam-network/xcm-utils @moonbeam-network/xcm-builder @moonbeam-network/xcm-config @moonbeam-network/xcm-sdk
131
+ pnpm unlink @moonbeam-network/xcm-types @moonbeam-network/xcm-utils @moonbeam-network/xcm-builder @moonbeam-network/xcm-config @moonbeam-network/xcm-sdk
136
132
  ```
package/build/index.d.ts CHANGED
@@ -1,328 +1,195 @@
1
- import {
2
- SubstrateQueryConfig,
3
- ExtrinsicConfig,
4
- BalanceConfigBuilder,
5
- ContractConfig,
6
- } from '@moonbeam-network/xcm-builder';
7
- import {
8
- IConfigService,
9
- AssetConfig,
10
- FeeAssetConfig,
11
- TransferConfig,
12
- DestinationFeeConfig,
13
- } from '@moonbeam-network/xcm-config';
14
- import {
15
- AnyParachain,
16
- Asset,
17
- AssetAmount,
18
- ChainAssetId,
19
- AnyChain,
20
- EvmParachain,
21
- Ecosystem,
22
- } from '@moonbeam-network/xcm-types';
1
+ import { ContractConfig, ExtrinsicConfig, BalanceConfigBuilder, AssetMinConfigBuilder, FeeConfigBuilder, SubstrateQueryConfig, EvmQueryConfig } from '@moonbeam-network/xcm-builder';
2
+ import { AssetRoute, FeeConfig, ConfigService } from '@moonbeam-network/xcm-config';
3
+ import * as _moonbeam_network_xcm_types from '@moonbeam-network/xcm-types';
4
+ import { AssetAmount, AnyChain, AnyParachain, ChainAsset, Asset, EvmChain, EvmParachain, Ecosystem, AnyAsset } from '@moonbeam-network/xcm-types';
5
+ import { Signer, SubmittableExtrinsic } from '@polkadot/api/types';
6
+ import { IKeyringPair, ISubmittableResult } from '@polkadot/types/types';
7
+ import { WalletClient, PublicClient, HttpTransport, Hash } from 'viem';
23
8
  import { ApiPromise } from '@polkadot/api';
24
- import { Signer } from '@polkadot/api/types';
25
- import { IKeyringPair } from '@polkadot/types/types';
26
- import { Signer as Signer$1 } from 'ethers';
27
- import { WalletClient } from 'viem';
9
+ import { RuntimeDispatchInfo } from '@polkadot/types/interfaces';
10
+ import { HexString } from '@polkadot/util/types';
28
11
 
29
- declare class PolkadotService {
30
- #private;
31
- readonly api: ApiPromise;
32
- readonly chain: AnyParachain;
33
- readonly configService: IConfigService;
34
- constructor(
35
- api: ApiPromise,
36
- chain: AnyParachain,
37
- configService: IConfigService,
38
- );
39
- static create(
40
- chain: AnyParachain,
41
- configService: IConfigService,
42
- ): Promise<PolkadotService>;
43
- static createMulti(
44
- chains: AnyParachain[],
45
- configService: IConfigService,
46
- ): Promise<PolkadotService[]>;
47
- get decimals(): number;
48
- get asset(): Asset;
49
- get existentialDeposit(): AssetAmount;
50
- getAssetMeta(asset: ChainAssetId): Promise<
51
- | {
52
- symbol: string;
53
- decimals: number;
54
- }
55
- | undefined
56
- >;
57
- getAssetDecimalsFromQuery(asset: ChainAssetId): Promise<number | undefined>;
58
- getAssetDecimals(asset: Asset): Promise<number>;
59
- query(config: SubstrateQueryConfig): Promise<bigint>;
60
- getFee(account: string, config: ExtrinsicConfig): Promise<bigint>;
61
- transfer(
62
- account: string,
63
- config: ExtrinsicConfig,
64
- signer: Signer | IKeyringPair,
65
- ): Promise<string>;
66
- }
67
-
68
- type EvmSigner = Signer$1 | WalletClient;
12
+ type EvmSigner = WalletClient;
69
13
  interface Signers {
70
- /**
71
- * @deprecated ethersSigner - is deprecated and will be removed in v2, use evmSigner instead
72
- */
73
- ethersSigner?: Signer$1;
74
- evmSigner?: EvmSigner;
75
- polkadotSigner: Signer | IKeyringPair;
14
+ evmSigner?: EvmSigner;
15
+ polkadotSigner?: Signer | IKeyringPair;
76
16
  }
77
17
  interface TransferData {
78
- destination: DestinationChainTransferData;
79
- getEstimate(amount: number | string): AssetAmount;
80
- isSwapPossible: boolean;
81
- max: AssetAmount;
82
- min: AssetAmount;
83
- source: SourceChainTransferData;
84
- swap(): Promise<TransferData | undefined>;
85
- transfer(amount: bigint | number | string): Promise<string>;
18
+ destination: DestinationChainTransferData;
19
+ getEstimate(amount: number | string): AssetAmount;
20
+ max: AssetAmount;
21
+ min: AssetAmount;
22
+ source: SourceChainTransferData;
23
+ transfer(amount: bigint | number | string, signers: Signers): Promise<string>;
86
24
  }
87
25
  interface SourceChainTransferData extends ChainTransferData {
88
- destinationFee: AssetAmount;
89
- destinationFeeBalance: AssetAmount;
90
- feeBalance: AssetAmount;
91
- max: AssetAmount;
26
+ destinationFee: AssetAmount;
27
+ destinationFeeBalance: AssetAmount;
28
+ feeBalance: AssetAmount;
29
+ max: AssetAmount;
92
30
  }
93
31
  interface SovereignAccountBalance {
94
- feeAssetBalance: bigint | undefined;
95
- transferAssetBalance: bigint;
32
+ feeAssetBalance: bigint | undefined;
33
+ transferAssetBalance: bigint;
96
34
  }
97
35
  interface DestinationChainTransferData extends ChainTransferData {
98
- sovereignAccountBalances?: SovereignAccountBalance;
36
+ sovereignAccountBalances?: SovereignAccountBalance;
99
37
  }
100
38
  interface ChainTransferData {
101
- balance: AssetAmount;
102
- chain: AnyChain;
103
- existentialDeposit: AssetAmount;
104
- fee: AssetAmount;
105
- min: AssetAmount;
106
- }
107
-
108
- interface BaseParams {
109
- address: string;
110
- chain: AnyChain;
111
- polkadot: PolkadotService;
112
- }
113
- interface GetBalancesParams extends BaseParams {
114
- asset: Asset;
115
- balanceBuilder: BalanceConfigBuilder;
116
- decimals: number;
39
+ balance: AssetAmount;
40
+ chain: AnyChain;
41
+ existentialDeposit?: AssetAmount;
42
+ fee: AssetAmount;
43
+ min: AssetAmount;
117
44
  }
118
- interface GetDecimalsParams extends BaseParams {
119
- asset?: Asset;
120
- config: AssetConfig | FeeAssetConfig;
121
- assetBuiltConfig?: SubstrateQueryConfig | ContractConfig;
122
- }
123
- declare function getBalance({
124
- address,
125
- chain,
126
- balanceBuilder,
127
- asset,
128
- decimals,
129
- polkadot,
130
- }: GetBalancesParams): Promise<bigint>;
131
- declare function getDecimals({
132
- address,
133
- asset,
134
- config,
135
- polkadot,
136
- chain,
137
- assetBuiltConfig,
138
- }: GetDecimalsParams): Promise<number>;
139
- declare function getMin(
140
- config: AssetConfig,
141
- polkadot: PolkadotService,
142
- ): Promise<bigint>;
143
- interface ValidateSovereignAccountBalancesProps {
144
- amount: bigint;
145
- destination: DestinationChainTransferData;
146
- source: SourceChainTransferData;
147
- }
148
- declare function validateSovereignAccountBalances({
149
- amount,
150
- source,
151
- destination,
152
- }: ValidateSovereignAccountBalancesProps): void;
153
45
 
154
46
  interface GetSourceDataParams {
155
- transferConfig: TransferConfig;
156
- destinationAddress: string;
157
- destinationFee: AssetAmount;
158
- evmSigner?: EvmSigner;
159
- polkadot: PolkadotService;
160
- sourceAddress: string;
47
+ route: AssetRoute;
48
+ destinationAddress: string;
49
+ destinationFee: AssetAmount;
50
+ sourceAddress: string;
161
51
  }
162
- declare function getSourceData({
163
- transferConfig,
164
- destinationAddress,
165
- destinationFee,
166
- polkadot,
167
- sourceAddress,
168
- evmSigner,
169
- }: GetSourceDataParams): Promise<SourceChainTransferData>;
170
- interface GetFeeBalanceParams extends BaseParams {
171
- balance: bigint;
172
- feeConfig: FeeAssetConfig | undefined;
173
- decimals: number;
174
- }
175
- declare function getFeeBalance({
176
- address,
177
- balance,
178
- chain,
179
- decimals,
180
- feeConfig,
181
- polkadot,
182
- }: GetFeeBalanceParams): Promise<bigint>;
52
+ declare function getSourceData({ route, destinationAddress, destinationFee, sourceAddress, }: GetSourceDataParams): Promise<SourceChainTransferData>;
183
53
  interface GetFeeParams {
184
- balance: bigint;
185
- contract?: ContractConfig;
186
- chain: AnyChain;
187
- decimals: number;
188
- evmSigner?: EvmSigner;
189
- extrinsic?: ExtrinsicConfig;
190
- feeConfig?: FeeAssetConfig;
191
- destinationFeeConfig?: DestinationFeeConfig;
192
- destinationFeeBalanceAmount?: AssetAmount;
193
- polkadot: PolkadotService;
194
- sourceAddress: string;
195
- }
196
- declare function getFee({
197
- balance,
198
- chain,
199
- contract,
200
- decimals,
201
- destinationFeeConfig,
202
- destinationFeeBalanceAmount,
203
- evmSigner,
204
- extrinsic,
205
- feeConfig,
206
- polkadot,
207
- sourceAddress,
208
- }: GetFeeParams): Promise<bigint>;
209
- declare function getContractFee({
210
- balance,
211
- config,
212
- decimals,
213
- evmSigner,
214
- chain,
215
- }: {
216
- balance: bigint;
217
- config: ContractConfig;
218
- decimals: number;
219
- evmSigner: EvmSigner;
220
- chain: EvmParachain;
221
- }): Promise<bigint>;
222
- declare function getExtrinsicFee(
223
- balance: bigint,
224
- extrinsic: ExtrinsicConfig,
225
- polkadot: PolkadotService,
226
- sourceAddress: string,
227
- ): Promise<bigint>;
228
- interface GetMaxParams {
229
- balanceAmount: AssetAmount;
230
- existentialDeposit: AssetAmount;
231
- feeAmount: AssetAmount;
232
- minAmount: AssetAmount;
233
- }
234
- declare function getMax({
235
- balanceAmount,
236
- existentialDeposit,
237
- feeAmount,
238
- minAmount,
239
- }: GetMaxParams): AssetAmount;
54
+ balance: AssetAmount;
55
+ feeBalance: AssetAmount;
56
+ contract?: ContractConfig;
57
+ chain: AnyParachain;
58
+ destinationFee: AssetAmount;
59
+ extrinsic?: ExtrinsicConfig;
60
+ feeConfig?: FeeConfig;
61
+ sourceAddress: string;
62
+ }
63
+ declare function getFee({ balance, feeBalance, chain, contract, destinationFee, extrinsic, feeConfig, sourceAddress, }: GetFeeParams): Promise<AssetAmount>;
240
64
  interface GetAssetsBalancesParams {
241
- address: string;
242
- chain: AnyChain;
243
- assets: AssetConfig[];
244
- evmSigner?: EvmSigner;
245
- polkadot: PolkadotService;
65
+ address: string;
66
+ chain: AnyParachain;
67
+ routes: AssetRoute[];
68
+ evmSigner?: EvmSigner;
69
+ }
70
+ declare function getAssetsBalances({ address, chain, routes, }: GetAssetsBalancesParams): Promise<AssetAmount[]>;
71
+
72
+ interface GetDestinationDataParams {
73
+ route: AssetRoute;
74
+ destinationAddress: string;
246
75
  }
247
- declare function getAssetsBalances({
248
- address,
249
- chain,
250
- assets,
251
- polkadot,
252
- }: GetAssetsBalancesParams): Promise<AssetAmount[]>;
76
+ declare function getDestinationData({ route, destinationAddress, }: GetDestinationDataParams): Promise<DestinationChainTransferData>;
253
77
 
254
- interface SdkOptions extends Partial<Signers> {
255
- configService?: IConfigService;
78
+ interface GetBalancesParams {
79
+ address: string;
80
+ asset: ChainAsset;
81
+ builder: BalanceConfigBuilder;
82
+ chain: AnyChain;
83
+ }
84
+ declare function getBalance({ address, asset, builder, chain, }: GetBalancesParams): Promise<AssetAmount>;
85
+ interface GetMinParams {
86
+ asset: Asset;
87
+ builder?: AssetMinConfigBuilder;
88
+ chain: AnyChain;
89
+ }
90
+ declare function getAssetMin({ asset, builder, chain, }: GetMinParams): Promise<AssetAmount>;
91
+ declare function getMin({ balance, existentialDeposit, fee, min, }: DestinationChainTransferData): AssetAmount;
92
+ interface GetMaxParams {
93
+ balance: AssetAmount;
94
+ existentialDeposit?: AssetAmount;
95
+ fee: AssetAmount;
96
+ min: AssetAmount;
97
+ }
98
+ declare function getMax({ balance, existentialDeposit, fee, min, }: GetMaxParams): AssetAmount;
99
+ interface GetDestinationFeeParams {
100
+ address: string;
101
+ asset: Asset;
102
+ feeAsset: Asset;
103
+ destination: AnyChain;
104
+ fee: number | FeeConfigBuilder;
105
+ }
106
+ declare function getDestinationFee({ address, asset, destination, fee, feeAsset, }: GetDestinationFeeParams): Promise<AssetAmount>;
107
+ interface ConvertToChainDecimalsParams {
108
+ asset: AssetAmount;
109
+ target: ChainAsset;
110
+ }
111
+ declare function convertToChainDecimals({ asset, target, }: ConvertToChainDecimalsParams): AssetAmount;
112
+ declare function getExistentialDeposit(chain: AnyChain): Promise<AssetAmount | undefined>;
113
+ interface GetDestinationFeeBalanceParams {
114
+ balance: AssetAmount;
115
+ feeBalance: AssetAmount;
116
+ route: AssetRoute;
117
+ sourceAddress: string;
118
+ }
119
+ declare function getDestinationFeeBalance({ balance, feeBalance, route, sourceAddress, }: GetDestinationFeeBalanceParams): Promise<AssetAmount>;
120
+ interface GetExtrinsicFeeParams {
121
+ address: string;
122
+ balance: AssetAmount;
123
+ chain: AnyParachain;
124
+ extrinsic: ExtrinsicConfig;
125
+ feeBalance: AssetAmount;
126
+ feeConfig?: FeeConfig;
127
+ }
128
+ declare function getExtrinsicFee({ address, balance, chain, extrinsic, feeBalance, feeConfig, }: GetExtrinsicFeeParams): Promise<AssetAmount>;
129
+ interface GetContractFeeParams {
130
+ address: string;
131
+ balance: AssetAmount;
132
+ chain: EvmChain | EvmParachain;
133
+ contract: ContractConfig;
134
+ destinationFee: AssetAmount;
135
+ feeBalance: AssetAmount;
136
+ feeConfig?: FeeConfig;
137
+ }
138
+ declare function getContractFee({ address, balance, chain, contract, destinationFee, feeBalance, feeConfig, }: GetContractFeeParams): Promise<AssetAmount>;
139
+ interface ValidateSovereignAccountBalancesProps {
140
+ amount: bigint;
141
+ destinationData: DestinationChainTransferData;
142
+ sourceData: SourceChainTransferData;
256
143
  }
257
- declare function Sdk(options?: SdkOptions): {
258
- assets(ecosystem?: Ecosystem): {
259
- assets: Asset[];
260
- asset(keyOrAsset: string | Asset): {
261
- sourceChains: AnyChain[];
262
- source(keyOrChain: string | AnyChain): {
263
- destinationChains: AnyChain[];
264
- destination(destKeyOrChain: string | AnyChain): {
265
- accounts(
266
- sourceAddress: string,
267
- destinationAddress: string,
268
- signers?: Partial<Signers>,
269
- ): Promise<TransferData>;
144
+ declare function validateSovereignAccountBalances({ amount, sourceData, destinationData, }: ValidateSovereignAccountBalancesProps): void;
145
+
146
+ interface SdkOptions {
147
+ configService?: ConfigService;
148
+ ecosystem?: Ecosystem;
149
+ }
150
+ declare function Sdk({ configService, ecosystem }?: SdkOptions): {
151
+ assets: _moonbeam_network_xcm_types.Asset[];
152
+ setAsset(asset: string | AnyAsset): {
153
+ sources: AnyChain[];
154
+ setSource(source: string | AnyChain): {
155
+ destinations: AnyChain[];
156
+ setDestination(destination: string | AnyChain): {
157
+ setAddresses({ sourceAddress, destinationAddress, }: {
158
+ sourceAddress: string;
159
+ destinationAddress: string;
160
+ }): Promise<TransferData>;
161
+ };
270
162
  };
271
- };
272
163
  };
273
- };
274
- getTransferData({
275
- destinationAddress,
276
- destinationKeyOrChain,
277
- ethersSigner,
278
- evmSigner,
279
- keyOrAsset,
280
- polkadotSigner,
281
- sourceAddress,
282
- sourceKeyOrChain,
283
- }: SdkTransferParams): Promise<TransferData>;
284
164
  };
285
- declare function getParachainBalances(
286
- chain: AnyChain,
287
- address: string,
288
- ): Promise<AssetAmount[]>;
289
- interface SdkTransferParams extends Partial<Signers> {
290
- destinationAddress: string;
291
- destinationKeyOrChain: string | AnyChain;
292
- keyOrAsset: string | Asset;
293
- sourceAddress: string;
294
- sourceKeyOrChain: string | AnyChain;
165
+ declare function getParachainBalances(chain: AnyParachain, address: string, service?: ConfigService): Promise<AssetAmount[]>;
166
+
167
+ declare class PolkadotService {
168
+ #private;
169
+ readonly api: ApiPromise;
170
+ readonly chain: AnyParachain;
171
+ constructor(api: ApiPromise, chain: AnyParachain);
172
+ static create(chain: AnyParachain): Promise<PolkadotService>;
173
+ static createMulti(chains: AnyParachain[]): Promise<PolkadotService[]>;
174
+ get decimals(): number;
175
+ get existentialDeposit(): AssetAmount;
176
+ query(config: SubstrateQueryConfig): Promise<bigint>;
177
+ getExtrinsic(config: ExtrinsicConfig): SubmittableExtrinsic<'promise', ISubmittableResult>;
178
+ getExtrinsicCallHash(config: ExtrinsicConfig): HexString;
179
+ getPaymentInfo(account: string, config: ExtrinsicConfig): Promise<RuntimeDispatchInfo>;
180
+ getFee(account: string, config: ExtrinsicConfig): Promise<bigint>;
181
+ transfer(account: string, config: ExtrinsicConfig, signer: Signer | IKeyringPair, statusCallback?: (params: ISubmittableResult) => void): Promise<string>;
295
182
  }
296
183
 
297
- export {
298
- type BaseParams,
299
- type ChainTransferData,
300
- type DestinationChainTransferData,
301
- type EvmSigner,
302
- type GetAssetsBalancesParams,
303
- type GetBalancesParams,
304
- type GetDecimalsParams,
305
- type GetFeeBalanceParams,
306
- type GetFeeParams,
307
- type GetMaxParams,
308
- type GetSourceDataParams,
309
- Sdk,
310
- type SdkOptions,
311
- type SdkTransferParams,
312
- type Signers,
313
- type SourceChainTransferData,
314
- type SovereignAccountBalance,
315
- type TransferData,
316
- getAssetsBalances,
317
- getBalance,
318
- getContractFee,
319
- getDecimals,
320
- getExtrinsicFee,
321
- getFee,
322
- getFeeBalance,
323
- getMax,
324
- getMin,
325
- getParachainBalances,
326
- getSourceData,
327
- validateSovereignAccountBalances,
328
- };
184
+ declare class EvmService {
185
+ readonly chain: EvmChain | EvmParachain;
186
+ readonly client: PublicClient<HttpTransport>;
187
+ static create(chain: EvmChain | EvmParachain): EvmService;
188
+ constructor(chain: EvmChain | EvmParachain);
189
+ query(query: EvmQueryConfig): Promise<bigint>;
190
+ getFee(address: string, contract: ContractConfig): Promise<bigint>;
191
+ getBalance(address: string, contract: ContractConfig): Promise<bigint>;
192
+ transfer(signer: EvmSigner, contract: ContractConfig): Promise<Hash>;
193
+ }
194
+
195
+ export { type ChainTransferData, type ConvertToChainDecimalsParams, type DestinationChainTransferData, EvmService, type EvmSigner, type GetAssetsBalancesParams, type GetBalancesParams, type GetContractFeeParams, type GetDestinationDataParams, type GetDestinationFeeBalanceParams, type GetDestinationFeeParams, type GetExtrinsicFeeParams, type GetFeeParams, type GetMaxParams, type GetMinParams, type GetSourceDataParams, PolkadotService, Sdk, type SdkOptions, type Signers, type SourceChainTransferData, type SovereignAccountBalance, type TransferData, convertToChainDecimals, getAssetMin, getAssetsBalances, getBalance, getContractFee, getDestinationData, getDestinationFee, getDestinationFeeBalance, getExistentialDeposit, getExtrinsicFee, getFee, getMax, getMin, getParachainBalances, getSourceData, validateSovereignAccountBalances };