@moonbeam-network/xcm-sdk 1.0.0-dev.152 → 1.0.0-dev.154
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 +1 -1
- package/README.md +11 -19
- package/build/index.cjs +2 -0
- package/build/index.cjs.map +1 -0
- package/build/index.d.cts +177 -0
- package/build/index.d.ts +301 -167
- package/build/index.mjs +1 -749
- package/build/index.mjs.map +1 -1
- package/package.json +28 -20
package/build/index.d.ts
CHANGED
|
@@ -1,194 +1,328 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import {
|
|
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';
|
|
8
23
|
import { ApiPromise } from '@polkadot/api';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
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';
|
|
11
28
|
|
|
12
|
-
|
|
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;
|
|
13
69
|
interface Signers {
|
|
14
|
-
|
|
15
|
-
|
|
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;
|
|
16
76
|
}
|
|
17
77
|
interface TransferData {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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>;
|
|
24
86
|
}
|
|
25
87
|
interface SourceChainTransferData extends ChainTransferData {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
88
|
+
destinationFee: AssetAmount;
|
|
89
|
+
destinationFeeBalance: AssetAmount;
|
|
90
|
+
feeBalance: AssetAmount;
|
|
91
|
+
max: AssetAmount;
|
|
30
92
|
}
|
|
31
93
|
interface SovereignAccountBalance {
|
|
32
|
-
|
|
33
|
-
|
|
94
|
+
feeAssetBalance: bigint | undefined;
|
|
95
|
+
transferAssetBalance: bigint;
|
|
34
96
|
}
|
|
35
97
|
interface DestinationChainTransferData extends ChainTransferData {
|
|
36
|
-
|
|
98
|
+
sovereignAccountBalances?: SovereignAccountBalance;
|
|
37
99
|
}
|
|
38
100
|
interface ChainTransferData {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
101
|
+
balance: AssetAmount;
|
|
102
|
+
chain: AnyChain;
|
|
103
|
+
existentialDeposit: AssetAmount;
|
|
104
|
+
fee: AssetAmount;
|
|
105
|
+
min: AssetAmount;
|
|
44
106
|
}
|
|
45
107
|
|
|
46
|
-
interface
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
sourceAddress: string;
|
|
108
|
+
interface BaseParams {
|
|
109
|
+
address: string;
|
|
110
|
+
chain: AnyChain;
|
|
111
|
+
polkadot: PolkadotService;
|
|
51
112
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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>;
|
|
64
|
-
interface GetAssetsBalancesParams {
|
|
65
|
-
address: string;
|
|
66
|
-
chain: AnyParachain;
|
|
67
|
-
routes: AssetRoute[];
|
|
68
|
-
evmSigner?: EvmSigner;
|
|
113
|
+
interface GetBalancesParams extends BaseParams {
|
|
114
|
+
asset: Asset;
|
|
115
|
+
balanceBuilder: BalanceConfigBuilder;
|
|
116
|
+
decimals: number;
|
|
69
117
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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;
|
|
75
147
|
}
|
|
76
|
-
declare function
|
|
148
|
+
declare function validateSovereignAccountBalances({
|
|
149
|
+
amount,
|
|
150
|
+
source,
|
|
151
|
+
destination,
|
|
152
|
+
}: ValidateSovereignAccountBalancesProps): void;
|
|
77
153
|
|
|
78
|
-
interface
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
154
|
+
interface GetSourceDataParams {
|
|
155
|
+
transferConfig: TransferConfig;
|
|
156
|
+
destinationAddress: string;
|
|
157
|
+
destinationFee: AssetAmount;
|
|
158
|
+
evmSigner?: EvmSigner;
|
|
159
|
+
polkadot: PolkadotService;
|
|
160
|
+
sourceAddress: string;
|
|
161
|
+
}
|
|
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>;
|
|
183
|
+
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>;
|
|
92
228
|
interface GetMaxParams {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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
|
-
chain: EvmChain | EvmParachain;
|
|
132
|
-
contract: ContractConfig;
|
|
133
|
-
destinationFee: AssetAmount;
|
|
134
|
-
feeBalance: AssetAmount;
|
|
135
|
-
feeConfig?: FeeConfig;
|
|
136
|
-
}
|
|
137
|
-
declare function getContractFee({ address, chain, contract, destinationFee, feeBalance, feeConfig, }: GetContractFeeParams): Promise<AssetAmount>;
|
|
138
|
-
interface ValidateSovereignAccountBalancesProps {
|
|
139
|
-
amount: bigint;
|
|
140
|
-
destinationData: DestinationChainTransferData;
|
|
141
|
-
sourceData: SourceChainTransferData;
|
|
229
|
+
balanceAmount: AssetAmount;
|
|
230
|
+
existentialDeposit: AssetAmount;
|
|
231
|
+
feeAmount: AssetAmount;
|
|
232
|
+
minAmount: AssetAmount;
|
|
142
233
|
}
|
|
143
|
-
declare function
|
|
234
|
+
declare function getMax({
|
|
235
|
+
balanceAmount,
|
|
236
|
+
existentialDeposit,
|
|
237
|
+
feeAmount,
|
|
238
|
+
minAmount,
|
|
239
|
+
}: GetMaxParams): AssetAmount;
|
|
240
|
+
interface GetAssetsBalancesParams {
|
|
241
|
+
address: string;
|
|
242
|
+
chain: AnyChain;
|
|
243
|
+
assets: AssetConfig[];
|
|
244
|
+
evmSigner?: EvmSigner;
|
|
245
|
+
polkadot: PolkadotService;
|
|
246
|
+
}
|
|
247
|
+
declare function getAssetsBalances({
|
|
248
|
+
address,
|
|
249
|
+
chain,
|
|
250
|
+
assets,
|
|
251
|
+
polkadot,
|
|
252
|
+
}: GetAssetsBalancesParams): Promise<AssetAmount[]>;
|
|
144
253
|
|
|
145
|
-
interface SdkOptions {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
assets:
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
254
|
+
interface SdkOptions extends Partial<Signers> {
|
|
255
|
+
configService?: IConfigService;
|
|
256
|
+
}
|
|
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>;
|
|
161
270
|
};
|
|
271
|
+
};
|
|
162
272
|
};
|
|
273
|
+
};
|
|
274
|
+
getTransferData({
|
|
275
|
+
destinationAddress,
|
|
276
|
+
destinationKeyOrChain,
|
|
277
|
+
ethersSigner,
|
|
278
|
+
evmSigner,
|
|
279
|
+
keyOrAsset,
|
|
280
|
+
polkadotSigner,
|
|
281
|
+
sourceAddress,
|
|
282
|
+
sourceKeyOrChain,
|
|
283
|
+
}: SdkTransferParams): Promise<TransferData>;
|
|
163
284
|
};
|
|
164
|
-
declare function getParachainBalances(
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
get existentialDeposit(): AssetAmount;
|
|
175
|
-
query(config: SubstrateQueryConfig): Promise<bigint>;
|
|
176
|
-
getExtrinsic(config: ExtrinsicConfig): SubmittableExtrinsic<'promise', ISubmittableResult>;
|
|
177
|
-
getExtrinsicCallHash(config: ExtrinsicConfig): HexString;
|
|
178
|
-
getPaymentInfo(account: string, config: ExtrinsicConfig): Promise<RuntimeDispatchInfo>;
|
|
179
|
-
getFee(account: string, config: ExtrinsicConfig): Promise<bigint>;
|
|
180
|
-
transfer(account: string, config: ExtrinsicConfig, signer: Signer | IKeyringPair): Promise<string>;
|
|
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;
|
|
181
295
|
}
|
|
182
296
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
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
|
+
};
|