@moonbeam-network/xcm-sdk 1.0.0-dev.29 → 1.0.0-dev.291

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,20 +1,10 @@
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
 
7
- ## v1 (current)
8
-
9
- - [readme](https://github.com/PureStake/xcm-sdk/tree/main)
10
- - [usage](https://docs.moonbeam.network/builders/interoperability/xcm/xcm-sdk/v1/xcm-sdk/)
11
- - [reference](https://docs.moonbeam.network/builders/interoperability/xcm/xcm-sdk/v1/reference/)
12
-
13
- ## v0 (previous)
14
-
15
- - [readme](https://github.com/PureStake/xcm-sdk/tree/v0)
16
- - [usage](https://docs.moonbeam.network/builders/interoperability/xcm/xcm-sdk/v0/xcm-sdk/)
17
- - [reference](https://docs.moonbeam.network/builders/interoperability/xcm/xcm-sdk/v0/reference/)
7
+ You can find the documentation at [https://moonbeam-foundation.github.io/xcm-sdk/latest/](https://moonbeam-foundation.github.io/xcm-sdk/latest/).
18
8
 
19
9
  # Installation
20
10
 
@@ -25,40 +15,30 @@ npm i @moonbeam-network/xcm-sdk
25
15
  :warning: You need to have peer dependencies of SDK installed as well.
26
16
 
27
17
  ```bash
28
- 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
29
19
  ```
30
20
 
31
21
  # Usage
32
22
 
33
- 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 v1 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).
34
24
 
35
25
  ## Build XCM Transfer Data
36
26
 
37
27
  ```js
38
28
  import { Sdk } from '@moonbeam-network/xcm-sdk';
39
29
 
40
- const { assets, getTransferData } = Sdk();
41
-
42
- // You can build the XCM transfer data via the assets function
43
- const dataViaAssetsMethod = await assets()
44
- .asset('INSERT_ASSET')
45
- .source('INSERT_SOURCE_CHAIN')
46
- .destination('INSERT_DESTINATION_CHAIN')
47
- .accounts('INSERT_SOURCE_ADDRESS', 'INSERT_DESTINATION_ADDRESS', {
48
- evmSigner?: 'INSERT_EVM_SIGNER',
49
- polkadotSigner?: 'INSERT_POLKADOT_SIGNER',
50
- });
51
-
52
- // Or via the getTransferData function
53
- const dataViaGetTransferDataMethod = await getTransferData({
54
- destinationAddress: 'INSERT_DESTINATION_ADDRESS',
55
- destinationKeyOrChain: 'INSERT_DESTINATION_CHAIN',
56
- evmSigner?: 'INSERT_EVM_SIGNER',
57
- keyOrAsset: 'INSERT_ASSET',
58
- polkadotSigner?: 'INSERT_POLKADOT_SIGNER',
59
- sourceAddress: 'INSERT_SOURCE_ADDRESS',
60
- sourceKeyOrChain: 'INSERT_SOURCE_CHAIN',
61
- });
30
+ const fromPolkadot = async () => {
31
+ const transferData = await Sdk()
32
+ .setAsset(dot)
33
+ .setSource(polkadot)
34
+ .setDestination(moonbeam)
35
+ .setAddresses({
36
+ sourceAddress: pair.address,
37
+ destinationAddress: "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
38
+ });
39
+ };
40
+
41
+ fromPolkadot();
62
42
  ```
63
43
 
64
44
  ## Transfer
@@ -66,30 +46,41 @@ const dataViaGetTransferDataMethod = await getTransferData({
66
46
  ```js
67
47
  ...
68
48
 
69
- const hash = await dataViaGetTransferDataMethod.transfer('INSERT_TRANSFER_AMOUNT');
49
+ const hash = await data.transfer({
50
+ amount: 1,
51
+ signers: { polkadotSigner: pair }, // Insert the signer, in this case a Substrate key pair
52
+ });
53
+
70
54
  ```
71
55
 
72
56
  # Examples
73
57
 
74
- - [sdk](https://github.com/PureStake/xcm-sdk/blob/main/examples/sdk-simple)
58
+ - [sdk](https://github.com/moonbeam-foundation/xcm-sdk/blob/main/examples/sdk-simple)
75
59
 
76
60
  ```bash
77
- git clone git@github.com:PureStake/xcm-sdk.git
61
+ git clone git@github.com:moonbeam-foundation/xcm-sdk.git
78
62
  cd xcm-sdk
79
- npm i
63
+ pnpm install
80
64
  cd examples/sdk-simple
81
65
 
82
66
  # edit index.ts by adding your accounts
83
67
 
84
- npm start
68
+ pnpm run start
85
69
  ```
86
70
 
87
71
  # Contributing
88
72
 
73
+ First fork the repository and clone it.
74
+
89
75
  ```bash
90
- git clone git@github.com:PureStake/xcm-sdk.git
91
- npm i
92
- npm run dev
76
+ git clone git@github.com:YOUR_GITHUB_USERNAME/xcm-sdk.git
77
+ pnpm install
78
+ ```
79
+
80
+ Optionally, you can install the `pre-commit` hook to run the linter and tests before committing:
81
+
82
+ ```bash
83
+ pnpm lefthook install
93
84
  ```
94
85
 
95
86
  # Tests
@@ -97,14 +88,49 @@ npm run dev
97
88
  ## Unit tests
98
89
 
99
90
  ```bash
100
- npm run test
91
+ pnpm run test
101
92
  ```
102
93
 
103
94
  ## Acceptance tests
104
95
 
105
96
  ```bash
106
- cp .env.example .env
107
- # add private key and suri to .env file
97
+ pnpm run test:acc
98
+ ```
99
+
100
+ # Release
101
+
102
+ To create a dev version go to GitHub actions and run `publish dev versions` workflow.
103
+
104
+ To create a release version run:
105
+
106
+ ```bash
107
+ pnpm run changeset
108
+ ```
109
+
110
+ # Testing the change in the SDK locally
111
+
112
+ Build the project:
108
113
 
109
- npm run test:acc
114
+ ```bash
115
+ pnpm run build
116
+ ```
117
+
118
+ Link the SDK:
119
+
120
+ ```bash
121
+ pnpm run clean && pnpm run build && pnpm run link
122
+ ```
123
+
124
+ In your project where you would like to test the changes:
125
+
126
+ ```bash
127
+ pnpm link @moonbeam-network/xcm-types @moonbeam-network/xcm-utils @moonbeam-network/xcm-builder @moonbeam-network/xcm-config @moonbeam-network/xcm-sdk
128
+ ```
129
+
130
+ If you need you can link other packages too.
131
+
132
+ After testing is done, unlink the SDK:
133
+
134
+ ```bash
135
+ pnpm unlink @moonbeam-network/xcm-types @moonbeam-network/xcm-utils @moonbeam-network/xcm-builder @moonbeam-network/xcm-config @moonbeam-network/xcm-sdk
110
136
  ```
package/build/index.d.ts CHANGED
@@ -1,227 +1,233 @@
1
- import {
2
- SubstrateQueryConfig,
3
- ExtrinsicConfig,
4
- ContractConfig,
5
- } from '@moonbeam-network/xcm-builder';
6
- import {
7
- IConfigService,
8
- TransferConfig,
9
- FeeAssetConfig,
10
- } from '@moonbeam-network/xcm-config';
11
- import {
12
- AnyParachain,
13
- Asset,
14
- AssetAmount,
15
- ChainAssetId,
16
- AnyChain,
17
- Ecosystem,
18
- } from '@moonbeam-network/xcm-types';
1
+ import { AssetRoute, FeeConfig, ConfigService } from '@moonbeam-network/xcm-config';
2
+ import * as _moonbeam_network_xcm_types from '@moonbeam-network/xcm-types';
3
+ import { AssetAmount, AnyChain, AnyParachain, ChainAsset, Asset, EvmChain, EvmParachain, Ecosystem, AnyAsset } from '@moonbeam-network/xcm-types';
4
+ import { Signer, SubmittableExtrinsic } from '@polkadot/api/types';
5
+ import { IKeyringPair, ISubmittableResult } from '@polkadot/types/types';
6
+ import { WalletClient, PublicClient, HttpTransport, Hash } from 'viem';
7
+ import { ContractConfig, ExtrinsicConfig, BalanceConfigBuilder, AssetMinConfigBuilder, FeeConfigBuilder, EvmQueryConfig, SubstrateQueryConfig, EventMonitoringConfig } from '@moonbeam-network/xcm-builder';
19
8
  import { ApiPromise } from '@polkadot/api';
20
- import { Signer } from '@polkadot/api/types';
21
- import { IKeyringPair } from '@polkadot/types/types';
22
- import { Signer as Signer$1 } from 'ethers';
23
- import { WalletClient } from 'viem';
9
+ import { RuntimeDispatchInfo, EventRecord } from '@polkadot/types/interfaces';
10
+ import { HexString } from '@polkadot/util/types';
24
11
 
25
- declare class PolkadotService {
26
- #private;
27
- readonly api: ApiPromise;
28
- readonly chain: AnyParachain;
29
- readonly configService: IConfigService;
30
- constructor(
31
- api: ApiPromise,
32
- chain: AnyParachain,
33
- configService: IConfigService,
34
- );
35
- static create(
36
- chain: AnyParachain,
37
- configService: IConfigService,
38
- ): Promise<PolkadotService>;
39
- static createMulti(
40
- chains: AnyParachain[],
41
- configService: IConfigService,
42
- ): Promise<PolkadotService[]>;
43
- get decimals(): number;
44
- get asset(): Asset;
45
- get existentialDeposit(): AssetAmount;
46
- getAssetMeta(asset: ChainAssetId): Promise<
47
- | {
48
- symbol: string;
49
- decimals: number;
50
- }
51
- | undefined
52
- >;
53
- getAssetDecimalsFromQuery(asset: ChainAssetId): Promise<number | undefined>;
54
- getAssetDecimals(asset: Asset): Promise<number>;
55
- query(config: SubstrateQueryConfig): Promise<bigint>;
56
- getFee(account: string, config: ExtrinsicConfig): Promise<bigint>;
57
- transfer(
58
- account: string,
59
- config: ExtrinsicConfig,
60
- signer: Signer | IKeyringPair,
61
- ): Promise<string>;
62
- }
63
-
64
- type EvmSigner = Signer$1 | WalletClient;
12
+ type EvmSigner = WalletClient;
65
13
  interface Signers {
66
- /**
67
- * @deprecated ethersSigner - is deprecated and will be removed in v2, use evmSigner instead
68
- */
69
- ethersSigner?: Signer$1;
70
- evmSigner?: EvmSigner;
71
- polkadotSigner: Signer | IKeyringPair;
14
+ evmSigner?: EvmSigner;
15
+ polkadotSigner?: Signer | IKeyringPair;
72
16
  }
73
17
  interface TransferData {
74
- destination: DestinationChainTransferData;
75
- getEstimate(amount: number | string): AssetAmount;
76
- isSwapPossible: boolean;
77
- max: AssetAmount;
78
- min: AssetAmount;
79
- source: SourceChainTransferData;
80
- swap(): Promise<TransferData | undefined>;
81
- 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(params: TransferParams): Promise<string>;
24
+ }
25
+ interface TransferParams {
26
+ amount: number | string;
27
+ signers: Partial<Signers>;
28
+ statusCallback?: (status: ISubmittableResult) => void;
29
+ onSourceFinalized?: () => void;
30
+ onSourceError?: (error: Error) => void;
31
+ onDestinationFinalized?: () => void;
32
+ onDestinationError?: (error: Error) => void;
82
33
  }
83
34
  interface SourceChainTransferData extends ChainTransferData {
84
- destinationFeeBalance: AssetAmount;
85
- feeBalance: AssetAmount;
86
- max: AssetAmount;
35
+ destinationFee: AssetAmount;
36
+ destinationFeeBalance: AssetAmount;
37
+ feeBalance: AssetAmount;
38
+ max: AssetAmount;
39
+ }
40
+ interface SovereignAccountBalance {
41
+ feeAssetBalance: bigint | undefined;
42
+ transferAssetBalance: bigint;
43
+ }
44
+ interface DestinationChainTransferData extends ChainTransferData {
45
+ sovereignAccountBalances?: SovereignAccountBalance;
87
46
  }
88
- interface DestinationChainTransferData extends ChainTransferData {}
89
47
  interface ChainTransferData {
90
- balance: AssetAmount;
91
- chain: AnyChain;
92
- existentialDeposit: AssetAmount;
93
- fee: AssetAmount;
94
- min: AssetAmount;
48
+ balance: AssetAmount;
49
+ chain: AnyChain;
50
+ existentialDeposit?: AssetAmount;
51
+ fee: AssetAmount;
52
+ min: AssetAmount;
53
+ }
54
+
55
+ interface GetDestinationDataParams {
56
+ route: AssetRoute;
57
+ destinationAddress: string;
95
58
  }
59
+ declare function getDestinationData({ route, destinationAddress, }: GetDestinationDataParams): Promise<DestinationChainTransferData>;
96
60
 
97
61
  interface GetSourceDataParams {
98
- transferConfig: TransferConfig;
99
- destinationAddress: string;
100
- destinationFee: AssetAmount;
101
- evmSigner?: EvmSigner;
102
- polkadot: PolkadotService;
103
- sourceAddress: string;
104
- }
105
- declare function getSourceData({
106
- transferConfig,
107
- destinationAddress,
108
- destinationFee,
109
- evmSigner,
110
- polkadot,
111
- sourceAddress,
112
- }: GetSourceDataParams): Promise<SourceChainTransferData>;
113
- interface GetBalancesParams {
114
- address: string;
115
- balance: bigint;
116
- feeConfig: FeeAssetConfig | undefined;
117
- polkadot: PolkadotService;
118
- }
119
- declare function getFeeBalances({
120
- address,
121
- balance,
122
- feeConfig,
123
- polkadot,
124
- }: GetBalancesParams): Promise<bigint>;
62
+ route: AssetRoute;
63
+ destinationAddress: string;
64
+ destinationFee: AssetAmount;
65
+ sourceAddress: string;
66
+ }
67
+ declare function getSourceData({ route, destinationAddress, destinationFee, sourceAddress, }: GetSourceDataParams): Promise<SourceChainTransferData>;
125
68
  interface GetFeeParams {
126
- balance: bigint;
127
- contract?: ContractConfig;
128
- decimals: number;
129
- evmSigner?: EvmSigner;
130
- extrinsic?: ExtrinsicConfig;
131
- polkadot: PolkadotService;
132
- sourceAddress: string;
133
- }
134
- declare function getFee({
135
- balance,
136
- contract,
137
- decimals,
138
- evmSigner,
139
- extrinsic,
140
- polkadot,
141
- sourceAddress,
142
- }: GetFeeParams): Promise<bigint>;
143
- declare function getContractFee(
144
- balance: bigint,
145
- config: ContractConfig,
146
- decimals: number,
147
- evmSigner: EvmSigner,
148
- ): Promise<bigint>;
149
- declare function getExtrinsicFee(
150
- balance: bigint,
151
- extrinsic: ExtrinsicConfig,
152
- polkadot: PolkadotService,
153
- sourceAddress: string,
154
- ): Promise<bigint>;
69
+ balance: AssetAmount;
70
+ feeBalance: AssetAmount;
71
+ contract?: ContractConfig;
72
+ chain: AnyParachain;
73
+ destinationFee: AssetAmount;
74
+ extrinsic?: ExtrinsicConfig;
75
+ feeConfig?: FeeConfig;
76
+ sourceAddress: string;
77
+ }
78
+ declare function getFee({ balance, feeBalance, chain, contract, destinationFee, extrinsic, feeConfig, sourceAddress, }: GetFeeParams): Promise<AssetAmount>;
79
+ interface GetAssetsBalancesParams {
80
+ address: string;
81
+ chain: AnyParachain;
82
+ routes: AssetRoute[];
83
+ evmSigner?: EvmSigner;
84
+ }
85
+ declare function getAssetsBalances({ address, chain, routes, }: GetAssetsBalancesParams): Promise<AssetAmount[]>;
86
+
87
+ interface GetBalancesParams {
88
+ address: string;
89
+ asset: ChainAsset;
90
+ builder: BalanceConfigBuilder;
91
+ chain: AnyChain;
92
+ }
93
+ declare function getBalance({ address, asset, builder, chain, }: GetBalancesParams): Promise<AssetAmount>;
94
+ interface GetMinParams {
95
+ asset: Asset;
96
+ builder?: AssetMinConfigBuilder;
97
+ chain: AnyChain;
98
+ }
99
+ declare function getAssetMin({ asset, builder, chain, }: GetMinParams): Promise<AssetAmount>;
100
+ declare function getMin({ balance, existentialDeposit, fee, min, }: DestinationChainTransferData): AssetAmount;
155
101
  interface GetMaxParams {
156
- balanceAmount: AssetAmount;
157
- existentialDeposit: AssetAmount;
158
- feeAmount: AssetAmount;
159
- minAmount: AssetAmount;
160
- }
161
- declare function getMax({
162
- balanceAmount,
163
- existentialDeposit,
164
- feeAmount,
165
- minAmount,
166
- }: GetMaxParams): AssetAmount;
102
+ balance: AssetAmount;
103
+ existentialDeposit?: AssetAmount;
104
+ fee: AssetAmount;
105
+ min: AssetAmount;
106
+ }
107
+ declare function getMax({ balance, existentialDeposit, fee, min, }: GetMaxParams): AssetAmount;
108
+ interface GetDestinationFeeParams {
109
+ address: string;
110
+ asset: Asset;
111
+ feeAsset: Asset;
112
+ destination: AnyChain;
113
+ fee: number | FeeConfigBuilder;
114
+ source: AnyChain;
115
+ }
116
+ declare function getDestinationFee({ address, asset, destination, fee, feeAsset, source, }: GetDestinationFeeParams): Promise<AssetAmount>;
117
+ interface ConvertToChainDecimalsParams {
118
+ asset: AssetAmount;
119
+ target: ChainAsset;
120
+ }
121
+ declare function convertToChainDecimals({ asset, target, }: ConvertToChainDecimalsParams): AssetAmount;
122
+ declare function getExistentialDeposit(chain: AnyChain): Promise<AssetAmount | undefined>;
123
+ interface GetDestinationFeeBalanceParams {
124
+ balance: AssetAmount;
125
+ feeBalance: AssetAmount;
126
+ route: AssetRoute;
127
+ sourceAddress: string;
128
+ }
129
+ declare function getDestinationFeeBalance({ balance, feeBalance, route, sourceAddress, }: GetDestinationFeeBalanceParams): Promise<AssetAmount>;
130
+ interface GetExtrinsicFeeParams {
131
+ address: string;
132
+ balance: AssetAmount;
133
+ chain: AnyParachain;
134
+ extrinsic: ExtrinsicConfig;
135
+ feeBalance: AssetAmount;
136
+ feeConfig?: FeeConfig;
137
+ }
138
+ declare function getExtrinsicFee({ address, balance, chain, extrinsic, feeBalance, feeConfig, }: GetExtrinsicFeeParams): Promise<AssetAmount>;
139
+ interface GetContractFeeParams {
140
+ address: string;
141
+ balance: AssetAmount;
142
+ chain: EvmChain | EvmParachain;
143
+ contract: ContractConfig;
144
+ destinationFee: AssetAmount;
145
+ feeBalance: AssetAmount;
146
+ feeConfig?: FeeConfig;
147
+ }
148
+ declare function getContractFee({ address, balance, chain, contract, destinationFee, feeBalance, feeConfig, }: GetContractFeeParams): Promise<AssetAmount>;
149
+ interface ValidateSovereignAccountBalancesProps {
150
+ amount: bigint;
151
+ destinationData: DestinationChainTransferData;
152
+ sourceData: SourceChainTransferData;
153
+ }
154
+ declare function validateSovereignAccountBalances({ amount, sourceData, destinationData, }: ValidateSovereignAccountBalancesProps): void;
167
155
 
168
- interface SdkOptions extends Partial<Signers> {
169
- configService?: IConfigService;
170
- }
171
- declare function Sdk(options?: SdkOptions): {
172
- assets(ecosystem?: Ecosystem): {
173
- assets: Asset[];
174
- asset(keyOrAsset: string | Asset): {
175
- sourceChains: AnyChain[];
176
- source(keyOrChain: string | AnyChain): {
177
- destinationChains: AnyChain[];
178
- destination(destKeyOrChain: string | AnyChain): {
179
- accounts(
180
- sourceAddress: string,
181
- destinationAddress: string,
182
- signers?: Partial<Signers>,
183
- ): Promise<TransferData>;
156
+ interface SdkOptions {
157
+ configService?: ConfigService;
158
+ ecosystem?: Ecosystem;
159
+ }
160
+ declare function Sdk({ configService, ecosystem }?: SdkOptions): {
161
+ assets: _moonbeam_network_xcm_types.Asset[];
162
+ setAsset(asset: string | AnyAsset): {
163
+ sources: AnyChain[];
164
+ setSource(source: string | AnyChain): {
165
+ destinations: AnyChain[];
166
+ setDestination(destination: string | AnyChain): {
167
+ setAddresses({ sourceAddress, destinationAddress, }: {
168
+ sourceAddress: string;
169
+ destinationAddress: string;
170
+ }): Promise<TransferData>;
171
+ };
184
172
  };
185
- };
186
173
  };
187
- };
188
- getTransferData({
189
- destinationAddress,
190
- destinationKeyOrChain,
191
- ethersSigner,
192
- evmSigner,
193
- keyOrAsset,
194
- polkadotSigner,
195
- sourceAddress,
196
- sourceKeyOrChain,
197
- }: SdkTransferParams): Promise<TransferData>;
198
174
  };
199
- interface SdkTransferParams extends Partial<Signers> {
200
- destinationAddress: string;
201
- destinationKeyOrChain: string | AnyChain;
202
- keyOrAsset: string | Asset;
203
- sourceAddress: string;
204
- sourceKeyOrChain: string | AnyChain;
175
+ declare function getParachainBalances(chain: AnyParachain, address: string, service?: ConfigService): Promise<AssetAmount[]>;
176
+
177
+ declare class EvmService {
178
+ readonly chain: EvmChain | EvmParachain;
179
+ readonly client: PublicClient<HttpTransport>;
180
+ static create(chain: EvmChain | EvmParachain): EvmService;
181
+ constructor(chain: EvmChain | EvmParachain);
182
+ query(query: EvmQueryConfig): Promise<bigint>;
183
+ read(config: ContractConfig): Promise<unknown>;
184
+ getFee(address: string, contract: ContractConfig): Promise<bigint>;
185
+ getBalance(address: string, contract: ContractConfig): Promise<bigint>;
186
+ transfer(signer: EvmSigner, contract: ContractConfig): Promise<Hash>;
205
187
  }
206
188
 
207
- export {
208
- ChainTransferData,
209
- DestinationChainTransferData,
210
- EvmSigner,
211
- GetBalancesParams,
212
- GetFeeParams,
213
- GetMaxParams,
214
- GetSourceDataParams,
215
- Sdk,
216
- SdkOptions,
217
- SdkTransferParams,
218
- Signers,
219
- SourceChainTransferData,
220
- TransferData,
221
- getContractFee,
222
- getExtrinsicFee,
223
- getFee,
224
- getFeeBalances,
225
- getMax,
226
- getSourceData,
227
- };
189
+ declare class PolkadotService {
190
+ #private;
191
+ readonly api: ApiPromise;
192
+ readonly chain: AnyParachain;
193
+ constructor(api: ApiPromise, chain: AnyParachain);
194
+ static create(chain: AnyParachain): Promise<PolkadotService>;
195
+ static createMulti(chains: AnyParachain[]): Promise<PolkadotService[]>;
196
+ get decimals(): number;
197
+ get existentialDeposit(): AssetAmount;
198
+ query(config: SubstrateQueryConfig): Promise<bigint>;
199
+ getExtrinsic(config: ExtrinsicConfig): SubmittableExtrinsic<'promise', ISubmittableResult>;
200
+ getExtrinsicCallHash(config: ExtrinsicConfig): HexString;
201
+ getPaymentInfo(account: string, config: ExtrinsicConfig): Promise<RuntimeDispatchInfo>;
202
+ getFee(account: string, config: ExtrinsicConfig): Promise<bigint>;
203
+ transfer(account: string, config: ExtrinsicConfig, signer: Signer | IKeyringPair, statusCallback?: (params: ISubmittableResult) => void): Promise<string>;
204
+ }
205
+
206
+ interface ListenToDestinationEventsProps {
207
+ route: AssetRoute;
208
+ monitoringConfig: EventMonitoringConfig;
209
+ messageId?: string;
210
+ onDestinationFinalized?: () => void;
211
+ onDestinationError?: (error: Error) => void;
212
+ }
213
+ declare function listenToDestinationEvents({ route, monitoringConfig, messageId, onDestinationFinalized, onDestinationError, }: ListenToDestinationEventsProps): Promise<void>;
214
+ interface CreateMonitoringCallbackProps {
215
+ sourceAddress: string;
216
+ route: AssetRoute;
217
+ statusCallback?: (status: ISubmittableResult) => void;
218
+ onSourceFinalized?: () => void;
219
+ onSourceError?: (error: Error) => void;
220
+ onDestinationFinalized?: () => void;
221
+ onDestinationError?: (error: Error) => void;
222
+ }
223
+ interface ListenToSourceEventsProps extends CreateMonitoringCallbackProps {
224
+ }
225
+ interface ProcessSourceEventsProps extends ListenToSourceEventsProps {
226
+ events: EventRecord[];
227
+ unsubscribe?: () => void;
228
+ }
229
+ declare function processSourceEvents({ events, sourceAddress, route, onSourceFinalized, onSourceError, onDestinationFinalized, onDestinationError, unsubscribe, }: ProcessSourceEventsProps): void;
230
+ declare function createMonitoringCallback({ sourceAddress, route, statusCallback, onSourceFinalized, onSourceError, onDestinationFinalized, onDestinationError, }: CreateMonitoringCallbackProps): (status: ISubmittableResult) => void;
231
+ declare function listenToSourceEvents({ route, sourceAddress, onSourceFinalized, onSourceError, onDestinationFinalized, onDestinationError, }: ListenToSourceEventsProps): Promise<void>;
232
+
233
+ 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, type TransferParams, convertToChainDecimals, createMonitoringCallback, getAssetMin, getAssetsBalances, getBalance, getContractFee, getDestinationData, getDestinationFee, getDestinationFeeBalance, getExistentialDeposit, getExtrinsicFee, getFee, getMax, getMin, getParachainBalances, getSourceData, listenToDestinationEvents, listenToSourceEvents, processSourceEvents, validateSovereignAccountBalances };