@moonbeam-network/xcm-sdk 4.2.10 → 4.2.11
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/build/index.d.mts +236 -0
- package/build/index.d.ts +2 -2
- package/package.json +5 -5
|
@@ -0,0 +1,236 @@
|
|
|
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, EvmChain, EvmParachain, Asset, 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, StateOverride, Hash, Address } from 'viem';
|
|
7
|
+
import { ContractConfig, ExtrinsicConfig, BalanceConfigBuilder, FeeConfigBuilder, AssetMinConfigBuilder, EvmQueryConfig, SubstrateQueryConfig, EventMonitoringConfig } from '@moonbeam-network/xcm-builder';
|
|
8
|
+
import { ApiPromise } from '@polkadot/api';
|
|
9
|
+
import { RuntimeDispatchInfo, EventRecord } from '@polkadot/types/interfaces';
|
|
10
|
+
import { HexString } from '@polkadot/util/types';
|
|
11
|
+
|
|
12
|
+
type EvmSigner = WalletClient;
|
|
13
|
+
interface Signers {
|
|
14
|
+
evmSigner?: EvmSigner;
|
|
15
|
+
polkadotSigner?: Signer | IKeyringPair;
|
|
16
|
+
}
|
|
17
|
+
interface TransferData {
|
|
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;
|
|
33
|
+
}
|
|
34
|
+
interface SourceChainTransferData extends ChainTransferData {
|
|
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;
|
|
46
|
+
}
|
|
47
|
+
interface ChainTransferData {
|
|
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;
|
|
58
|
+
}
|
|
59
|
+
declare function getDestinationData({ route, destinationAddress, }: GetDestinationDataParams): Promise<DestinationChainTransferData>;
|
|
60
|
+
|
|
61
|
+
interface GetSourceDataParams {
|
|
62
|
+
route: AssetRoute;
|
|
63
|
+
destinationAddress: string;
|
|
64
|
+
destinationFee: AssetAmount;
|
|
65
|
+
sourceAddress: string;
|
|
66
|
+
}
|
|
67
|
+
declare function getSourceData({ route, destinationAddress, destinationFee, sourceAddress, }: GetSourceDataParams): Promise<SourceChainTransferData>;
|
|
68
|
+
interface GetFeeParams {
|
|
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;
|
|
101
|
+
interface GetMaxParams {
|
|
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;
|
|
155
|
+
|
|
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
|
+
};
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
};
|
|
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, stateOverride?: StateOverride): Promise<bigint>;
|
|
185
|
+
getBalance(address: string, contract: ContractConfig): Promise<bigint>;
|
|
186
|
+
transfer(signer: EvmSigner, contract: ContractConfig): Promise<Hash>;
|
|
187
|
+
}
|
|
188
|
+
|
|
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
|
+
declare function getAllowanceSlot(owner: string, spender: string, allowanceSlot: number): Address;
|
|
207
|
+
declare const MAX_ALLOWANCE_HEX: `0x${string}`;
|
|
208
|
+
|
|
209
|
+
interface ListenToDestinationEventsProps {
|
|
210
|
+
route: AssetRoute;
|
|
211
|
+
monitoringConfig: EventMonitoringConfig;
|
|
212
|
+
messageId?: string;
|
|
213
|
+
onDestinationFinalized?: () => void;
|
|
214
|
+
onDestinationError?: (error: Error) => void;
|
|
215
|
+
}
|
|
216
|
+
declare function listenToDestinationEvents({ route, monitoringConfig, messageId, onDestinationFinalized, onDestinationError, }: ListenToDestinationEventsProps): Promise<void>;
|
|
217
|
+
interface CreateMonitoringCallbackProps {
|
|
218
|
+
sourceAddress: string;
|
|
219
|
+
route: AssetRoute;
|
|
220
|
+
statusCallback?: (status: ISubmittableResult) => void;
|
|
221
|
+
onSourceFinalized?: () => void;
|
|
222
|
+
onSourceError?: (error: Error) => void;
|
|
223
|
+
onDestinationFinalized?: () => void;
|
|
224
|
+
onDestinationError?: (error: Error) => void;
|
|
225
|
+
}
|
|
226
|
+
interface ListenToSourceEventsProps extends CreateMonitoringCallbackProps {
|
|
227
|
+
}
|
|
228
|
+
interface ProcessSourceEventsProps extends ListenToSourceEventsProps {
|
|
229
|
+
events: EventRecord[];
|
|
230
|
+
unsubscribe?: () => void;
|
|
231
|
+
}
|
|
232
|
+
declare function processSourceEvents({ events, sourceAddress, route, onSourceFinalized, onSourceError, onDestinationFinalized, onDestinationError, unsubscribe, }: ProcessSourceEventsProps): void;
|
|
233
|
+
declare function createMonitoringCallback({ sourceAddress, route, statusCallback, onSourceFinalized, onSourceError, onDestinationFinalized, onDestinationError, }: CreateMonitoringCallbackProps): (status: ISubmittableResult) => void;
|
|
234
|
+
declare function listenToSourceEvents({ route, sourceAddress, onSourceFinalized, onSourceError, onDestinationFinalized, onDestinationError, }: ListenToSourceEventsProps): Promise<void>;
|
|
235
|
+
|
|
236
|
+
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, MAX_ALLOWANCE_HEX, PolkadotService, Sdk, type SdkOptions, type Signers, type SourceChainTransferData, type SovereignAccountBalance, type TransferData, type TransferParams, convertToChainDecimals, createMonitoringCallback, getAllowanceSlot, getAssetMin, getAssetsBalances, getBalance, getContractFee, getDestinationData, getDestinationFee, getDestinationFeeBalance, getExistentialDeposit, getExtrinsicFee, getFee, getMax, getMin, getParachainBalances, getSourceData, listenToDestinationEvents, listenToSourceEvents, processSourceEvents, validateSovereignAccountBalances };
|
package/build/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { AssetRoute, FeeConfig, ConfigService } from '@moonbeam-network/xcm-config';
|
|
2
2
|
import * as _moonbeam_network_xcm_types from '@moonbeam-network/xcm-types';
|
|
3
|
-
import { AssetAmount, AnyChain, AnyParachain, ChainAsset,
|
|
3
|
+
import { AssetAmount, AnyChain, AnyParachain, ChainAsset, EvmChain, EvmParachain, Asset, Ecosystem, AnyAsset } from '@moonbeam-network/xcm-types';
|
|
4
4
|
import { Signer, SubmittableExtrinsic } from '@polkadot/api/types';
|
|
5
5
|
import { IKeyringPair, ISubmittableResult } from '@polkadot/types/types';
|
|
6
6
|
import { WalletClient, PublicClient, HttpTransport, StateOverride, Hash, Address } from 'viem';
|
|
7
|
-
import { ContractConfig, ExtrinsicConfig, BalanceConfigBuilder,
|
|
7
|
+
import { ContractConfig, ExtrinsicConfig, BalanceConfigBuilder, FeeConfigBuilder, AssetMinConfigBuilder, EvmQueryConfig, SubstrateQueryConfig, EventMonitoringConfig } from '@moonbeam-network/xcm-builder';
|
|
8
8
|
import { ApiPromise } from '@polkadot/api';
|
|
9
9
|
import { RuntimeDispatchInfo, EventRecord } from '@polkadot/types/interfaces';
|
|
10
10
|
import { HexString } from '@polkadot/util/types';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moonbeam-network/xcm-sdk",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.11",
|
|
4
4
|
"description": "The Moonbeam XCM SDK enables developers to easily deposit and withdraw assets to Moonbeam/Moonriver from the relay chain and other parachains in the Polkadot/Kusama ecosystem",
|
|
5
5
|
"author": "moonbeam-foundation",
|
|
6
6
|
"license": "MIT",
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
"main": "./build/index.mjs",
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"big.js": "^7.0.1",
|
|
40
|
-
"@moonbeam-network/xcm-builder": "4.5.
|
|
41
|
-
"@moonbeam-network/xcm-config": "4.6.
|
|
42
|
-
"@moonbeam-network/xcm-types": "4.3.
|
|
40
|
+
"@moonbeam-network/xcm-builder": "4.5.1",
|
|
41
|
+
"@moonbeam-network/xcm-config": "4.6.11",
|
|
42
|
+
"@moonbeam-network/xcm-types": "4.3.8",
|
|
43
43
|
"@moonbeam-network/xcm-utils": "4.2.3"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@polkadot/api-augment": "16.5.4",
|
|
48
48
|
"@polkadot/types": "16.5.4",
|
|
49
49
|
"@polkadot/util": "14.0.1",
|
|
50
|
-
"viem": "^2.
|
|
50
|
+
"viem": "^2.45.2"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/big.js": "^6.2.2"
|