@moonbeam-network/xcm-builder 1.0.0-dev.16 → 1.0.0-dev.160

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.mjs CHANGED
@@ -1,2 +1,4481 @@
1
- import"@polkadot/api-augment";var p=(t=>(t.Evm="Evm",t.Substrate="Substrate",t))(p||{});var u=class{module;func;type;constructor({module:r,func:t,type:n}){this.module=r,this.func=t,this.type=n}};var c=class extends u{args;transform;constructor({args:r=[],transform:t,type:n="Substrate",...i}){super({...i,type:n}),this.args=r,this.transform=t}};function Z(){return{assetRegistry:F,assets:O}}function F(){let e="assetRegistry";return{assetMetadatas:()=>({build:({asset:r})=>new c({module:e,func:"assetMetadatas",args:[r],transform:async t=>t.unwrapOrDefault().minimalBalance.toBigInt()})}),currencyMetadatas:()=>({build:({asset:r})=>new c({module:e,func:"currencyMetadatas",args:[r],transform:async t=>t.unwrapOrDefault().minimalBalance.toBigInt()})})}}function O(){return{asset:()=>({build:({asset:e})=>new c({module:"assets",func:"asset",args:[e],transform:async r=>r.unwrapOrDefault().minBalance.toBigInt()})})}}import{isString as W}from"@polkadot/util";import{formatAssetIdToERC20 as C}from"@moonbeam-network/xcm-utils";import{isString as b,u8aToHex as M}from"@polkadot/util";import{decodeAddress as D}from"@polkadot/util-crypto";var m=class extends u{args;address;constructor({args:r,address:t,...n}){super({...n,type:"Evm"}),this.args=r,this.address=t}};function E(){return{transfer:(e=4e9)=>({build:({address:r,amount:t,asset:n,destination:i})=>new m({args:[b(n)?C(n):n,t,h(r,i),e],func:"transfer",module:"Xtokens"})}),transferMultiCurrencies:(e=4e9)=>({build:({address:r,amount:t,asset:n,destination:i,fee:o,feeAsset:s})=>new m({args:[[[b(n)?C(n):n,t],[b(s)?C(s):s,o]],1,h(r,i),e],func:"transferMultiCurrencies",module:"Xtokens"})})}}function h(e,r){let n=`0x${r.isEvmParachain()?"03":"01"}${M(D(e),-1,!1)}00`;return[1,r.parachainId?[`0x0000000${r.parachainId.toString(16)}`,n]:[n]]}function xr(){return{Xtokens:E}}function wr(){return{evm:_,substrate:K}}function _(){return{erc20:R}}function K(){return{assets:q,system:V,tokens:U}}function R(){return{build:({address:e,asset:r})=>{if(!r||!W(r))throw new Error(`Invalid contract address: ${r}`);return new m({address:r,args:[e],func:"balanceOf",module:"Erc20"})}}}function q(){return{account:()=>({build:({address:e,asset:r})=>new c({module:"assets",func:"account",args:[r,e],transform:async t=>t.unwrapOrDefault().balance.toBigInt()})})}}function V(){return{account:()=>({build:({address:e})=>new c({module:"system",func:"account",args:[e],transform:async r=>{let t=r.data,n=t.miscFrozen??t.frozen;return BigInt(t.free.sub(n).toString())}})}),accountEquilibrium:()=>({build:({address:e,asset:r})=>new c({module:"system",func:"account",args:[e],transform:async t=>{var s;if(t.data.isEmpty)return 0n;let n=t.data.toJSON(),i;if(Array.isArray(n)&&(i=n),Array.isArray((s=n==null?void 0:n.v0)==null?void 0:s.balance)&&(i=n.v0.balance),!i)throw new Error("Can't get balance from Equilibrium chain");let o=i.find(([d])=>d===r);return o?BigInt(o[1].positive):0n}})})}}function U(){return{accounts:()=>({build:({address:e,asset:r})=>new c({module:"tokens",func:"accounts",args:[e,r],transform:async({free:t,frozen:n})=>BigInt(t.sub(n).toString())})})}}var a=class extends u{getArgs;constructor({getArgs:r,...t}){super({...t,type:"Substrate"}),this.getArgs=r}};var w="eqBalances";function I(){return{xcmTransfer:()=>({build:({address:e,amount:r,asset:t,destination:n})=>new a({module:w,func:"xcmTransfer",getArgs:()=>[t,r,{parents:1,interior:{X2:[{Parachain:n.parachainId},{AccountKey20:{network:"Any",key:e}}]}},"ThisAccWillPay"]})}),transferXcm:()=>({build:({address:e,amount:r,asset:t,destination:n,fee:i,feeAsset:o})=>new a({module:w,func:"transferXcm",getArgs:()=>{let s=r-i>0n?r-i:0n;return[[t,t===o?s:r],[o,i],{parents:1,interior:{X2:[{Parachain:n.parachainId},{AccountKey20:{network:"Any",key:e}}]}}]}})})}}import{getTypeDef as z}from"@polkadot/types";var A=(n=>(n.v1="V1",n.v2="V2",n.v3="V3",n))(A||{});function f(e,r=0){if(!e)return"V1";let{type:t}=e.meta.args[r],n=e.meta.registry.createType(t.toString()),i=z(n==null?void 0:n.toRawType());if(!i.sub)return"V1";let o=Array.isArray(i.sub)?i.sub.map(s=>s.name):[i.sub.name];if(o.includes("V1"))return"V1";if(o.includes("V2"))return"V2";if(o.includes("V3"))return"V3";throw new Error("Can't find Xcm version")}function l({asset:e,address:r,destination:t,func:n,parents:i=1}){let o=f(n);return[{[o]:{parents:i,interior:{X1:{Parachain:t.parachainId}}}},{[o]:{parents:0,interior:{X1:{AccountKey20:{network:"Any",key:r}}}}},{[o]:e},0,"Unlimited"]}var g="polkadotXcm";function T(){return{limitedReserveTransferAssets:()=>{let e="limitedReserveTransferAssets";return{here:()=>({build:r=>new a({module:g,func:e,getArgs:t=>l({...r,func:t,asset:[{id:{Concrete:{parents:0,interior:"Here"}},fun:{Fungible:r.amount}}]})})}),X1:()=>({build:r=>new a({module:g,func:e,getArgs:t=>l({...r,func:t,asset:[{id:{Concrete:{parents:0,interior:{X1:{PalletInstance:r.palletInstance}}}},fun:{Fungible:r.amount}}]})})}),X2:()=>({build:r=>new a({module:g,func:e,getArgs:t=>l({...r,func:t,asset:[{id:{Concrete:{parents:0,interior:{X2:[{PalletInstance:r.palletInstance},{GeneralIndex:r.asset}]}}},fun:{Fungible:r.amount}}]})})})}},limitedReserveWithdrawAssets:()=>{let e="limitedReserveWithdrawAssets";return{X2:()=>({build:r=>new a({module:g,func:e,getArgs:t=>l({...r,func:t,asset:[{id:{Concrete:{parents:1,interior:{X2:[{Parachain:r.destination.parachainId},{PalletInstance:r.palletInstance}]}}},fun:{Fungible:r.amount}}]})})})}}}}function P(e,r){var n;let t=(n=r==null?void 0:r.meta.args.at(-1))==null?void 0:n.type;return t?t.eq("XcmV2WeightLimit")?{Limited:e}:t.eq("XcmV3WeightLimit")?"Unlimited":e:e}var x="xTokens";function X(){return{transfer:()=>({build:({address:e,amount:r,asset:t,destination:n,source:i})=>new a({module:x,func:"transfer",getArgs:o=>{let s=f(o,2);return[t,r,{[s]:{parents:1,interior:{X2:[{Parachain:n.parachainId},{AccountKey20:{network:"Any",key:e}}]}}},P(i.weight,o)]}})}),transferMultiAsset:e=>{let r="transferMultiasset";return{X1:()=>({build:({address:t,amount:n,destination:i})=>new a({module:x,func:r,getArgs:o=>{let s=f(o,1);return[{[s]:{id:{Concrete:{parents:1,interior:{X1:{Parachain:e}}}},fun:{Fungible:n}}},{[s]:{parents:1,interior:{X2:[{Parachain:i.parachainId},{AccountKey20:{network:"Any",key:t}}]}}},"Unlimited"]}})}),X2:()=>({build:({address:t,amount:n,asset:i,destination:o,source:s})=>new a({module:x,func:r,getArgs:d=>{let B=f(d,1);return[{[B]:{id:{Concrete:{parents:1,interior:{X2:[{Parachain:e},{GeneralKey:i}]}}},fun:{Fungible:n}}},{[B]:{parents:1,interior:{X2:[{Parachain:o.parachainId},{AccountKey20:{network:"Any",key:t}}]}}},P(s.weight,d)]}})})}},transferMultiCurrencies:()=>({build:({address:e,amount:r,asset:t,destination:n,fee:i,feeAsset:o})=>new a({module:x,func:"transferMulticurrencies",getArgs:()=>[[[t,r],[o,i]],1,{["V3"]:{parents:1,interior:{X2:[{Parachain:n.parachainId},{AccountKey20:{key:e}}]}}},"Unlimited"]})})}}var k="xTransfer";function S(){return{transfer:()=>{let e="transfer";return{here:()=>({build:({address:r,amount:t,destination:n})=>new a({module:k,func:e,getArgs:()=>[{id:{Concrete:{parents:0,interior:"Here"}},fun:{Fungible:t}},{parents:1,interior:{X2:[{Parachain:n.parachainId},{AccountKey20:{key:r}}]}},{refTime:5e9,proofSize:0}]})}),X2:()=>({build:({address:r,amount:t,destination:n,palletInstance:i})=>new a({module:k,func:e,getArgs:()=>[{id:{Concrete:{parents:1,interior:{X2:[{Parachain:n.parachainId},{PalletInstance:i}]}}},fun:{Fungible:t||1n}},{parents:1,interior:{X2:[{Parachain:n.parachainId},{AccountKey20:{key:r}}]}},{refTime:5e9,proofSize:0}]})})}}}}var L="xcmPallet";function v(){return{limitedReserveTransferAssets:(e=1)=>{let r="limitedReserveTransferAssets";return{here:()=>({build:t=>new a({module:L,func:r,getArgs:n=>l({...t,parents:e,func:n,asset:[{id:{Concrete:{parents:0,interior:"Here"}},fun:{Fungible:t.amount}}]})})})}}}}function At(){return{eqBalances:I,xTokens:X,xTransfer:S,polkadotXcm:T,xcmPallet:v}}var y=class{api;call;type="Substrate";constructor({api:r,call:t}){this.api=r,this.call=t}};function kt(){return{assetManager:$}}function $(){return{assetTypeUnitsPerSecond:(e=1e9)=>({build:({api:r,asset:t})=>new y({api:r,call:async()=>{let n=await r.query.assetManager.assetIdType(t);if(n.isNone)throw new Error(`No asset type found for asset ${t}`);let i=n.unwrap(),s=(await r.query.assetManager.assetTypeUnitsPerSecond(i)).unwrapOrDefault().toBigInt();return BigInt(e)*s/BigInt(10**12)}})})}}export{Z as AssetMinBuilder,wr as BalanceBuilder,u as BaseConfig,p as CallType,xr as ContractBuilder,m as ContractConfig,At as ExtrinsicBuilder,a as ExtrinsicConfig,kt as FeeBuilder,c as SubstrateQueryConfig,A as XcmVersion,_ as evm,K as substrate};
1
+ // src/index.ts
2
+ import "@polkadot/api-augment";
3
+
4
+ // src/extrinsic/ExtrinsicBuilder.utils.ts
5
+ import { getTypeDef } from "@polkadot/types";
6
+ import { u8aToHex } from "@polkadot/util";
7
+ import { decodeAddress } from "@polkadot/util-crypto";
8
+
9
+ // src/extrinsic/ExtrinsicBuilder.interfaces.ts
10
+ var XcmVersion = /* @__PURE__ */ ((XcmVersion2) => {
11
+ XcmVersion2["v1"] = "V1";
12
+ XcmVersion2["v2"] = "V2";
13
+ XcmVersion2["v3"] = "V3";
14
+ XcmVersion2["v4"] = "V4";
15
+ XcmVersion2["v5"] = "V5";
16
+ return XcmVersion2;
17
+ })(XcmVersion || {});
18
+
19
+ // src/extrinsic/ExtrinsicBuilder.utils.ts
20
+ function getExtrinsicArgumentVersion(func, index = 0) {
21
+ if (!func) return "V1" /* v1 */;
22
+ const { type } = func.meta.args[index];
23
+ const instance = func.meta.registry.createType(type.toString());
24
+ const raw = getTypeDef(instance?.toRawType());
25
+ if (!raw.sub) {
26
+ return "V1" /* v1 */;
27
+ }
28
+ const versions = Array.isArray(raw.sub) ? raw.sub.map((x) => x.name) : [raw.sub.name];
29
+ if (versions.includes("V5" /* v5 */)) {
30
+ return "V5" /* v5 */;
31
+ }
32
+ if (versions.includes("V4" /* v4 */)) {
33
+ return "V4" /* v4 */;
34
+ }
35
+ if (versions.includes("V3" /* v3 */)) {
36
+ return "V3" /* v3 */;
37
+ }
38
+ if (versions.includes("V2" /* v2 */)) {
39
+ return "V2" /* v2 */;
40
+ }
41
+ if (versions.includes("V1" /* v1 */)) {
42
+ return "V1" /* v1 */;
43
+ }
44
+ throw new Error("Can't find XCM version");
45
+ }
46
+ function getExtrinsicAccount(address) {
47
+ const isEthAddress = address.length === 42 && address.startsWith("0x");
48
+ return isEthAddress ? {
49
+ AccountKey20: {
50
+ key: address
51
+ }
52
+ } : {
53
+ AccountId32: {
54
+ id: u8aToHex(decodeAddress(address)),
55
+ network: null
56
+ }
57
+ };
58
+ }
59
+ function isXcmV4(xcmVersion) {
60
+ return xcmVersion >= "V4" /* v4 */;
61
+ }
62
+ function normalizeX1(xcmVersion, versionedObject) {
63
+ if (!isXcmV4(xcmVersion)) return versionedObject;
64
+ const normalizedObject = { ...versionedObject };
65
+ const interior = normalizedObject.interior;
66
+ if ("X1" in interior && interior?.X1 && !Array.isArray(interior.X1)) {
67
+ interior.X1 = [interior.X1];
68
+ } else if ("x1" in interior && interior?.x1 && !Array.isArray(interior.x1)) {
69
+ interior.x1 = [interior.x1];
70
+ }
71
+ return normalizedObject;
72
+ }
73
+ function normalizeConcrete(xcmVersion, versionedObject) {
74
+ return isXcmV4(xcmVersion) ? versionedObject : applyConcreteWrapper(versionedObject);
75
+ }
76
+ function applyConcreteWrapper(versionedObject) {
77
+ return {
78
+ Concrete: { ...versionedObject }
79
+ };
80
+ }
81
+
82
+ // src/types/BaseConfig.ts
83
+ var BaseConfig = class {
84
+ module;
85
+ func;
86
+ constructor({ module: module5, func }) {
87
+ this.module = module5;
88
+ this.func = func;
89
+ }
90
+ };
91
+
92
+ // src/types/substrate/SubstrateQueryConfig.ts
93
+ var SubstrateQueryConfig = class _SubstrateQueryConfig extends BaseConfig {
94
+ args;
95
+ transform;
96
+ static is(obj) {
97
+ return obj instanceof _SubstrateQueryConfig;
98
+ }
99
+ constructor({
100
+ args = [],
101
+ transform,
102
+ ...other
103
+ }) {
104
+ super({ ...other });
105
+ this.args = args;
106
+ this.transform = transform;
107
+ }
108
+ };
109
+
110
+ // src/asset-min/AssetMinBuilder.ts
111
+ function AssetMinBuilder() {
112
+ return {
113
+ assetRegistry,
114
+ assets,
115
+ foreignAssets
116
+ };
117
+ }
118
+ function assetRegistry() {
119
+ const pallet6 = "assetRegistry";
120
+ return {
121
+ assetMetadatas: () => ({
122
+ build: ({ asset }) => new SubstrateQueryConfig({
123
+ module: pallet6,
124
+ func: "assetMetadatas",
125
+ args: [asset],
126
+ // biome-ignore lint/suspicious/noExplicitAny: not sure how to fix this
127
+ transform: async (response) => response.unwrapOrDefault().minimalBalance.toBigInt()
128
+ })
129
+ }),
130
+ currencyMetadatas: () => ({
131
+ build: ({ asset }) => new SubstrateQueryConfig({
132
+ module: pallet6,
133
+ func: "currencyMetadatas",
134
+ args: [asset],
135
+ // biome-ignore lint/suspicious/noExplicitAny: not sure how to fix this
136
+ transform: async (response) => response.unwrapOrDefault().minimalBalance.toBigInt()
137
+ })
138
+ })
139
+ };
140
+ }
141
+ function assets() {
142
+ return {
143
+ asset: () => ({
144
+ build: ({ asset }) => new SubstrateQueryConfig({
145
+ module: "assets",
146
+ func: "asset",
147
+ args: [asset],
148
+ transform: async (response) => response.unwrapOrDefault().minBalance.toBigInt()
149
+ })
150
+ })
151
+ };
152
+ }
153
+ function foreignAssets() {
154
+ return {
155
+ asset: () => ({
156
+ build: ({ address }) => {
157
+ if (!address) {
158
+ throw new Error(
159
+ "Asset address is missing for foreignAssets.asset min calculation"
160
+ );
161
+ }
162
+ const multilocation = {
163
+ parents: 2,
164
+ interior: {
165
+ X2: [
166
+ {
167
+ globalconsensus: {
168
+ ethereum: {
169
+ chainId: 1
170
+ }
171
+ }
172
+ },
173
+ getExtrinsicAccount(address)
174
+ ]
175
+ }
176
+ };
177
+ return new SubstrateQueryConfig({
178
+ module: "foreignAssets",
179
+ func: "asset",
180
+ args: [multilocation],
181
+ transform: async (response) => response.unwrapOrDefault().minBalance.toBigInt()
182
+ });
183
+ }
184
+ })
185
+ };
186
+ }
187
+
188
+ // src/balance/BalanceBuilder.ts
189
+ import { evmToAddress as evmToAddress2 } from "@polkadot/util-crypto";
190
+
191
+ // src/types/evm/ContractConfig.ts
192
+ import { encodeFunctionData } from "viem";
193
+ var ContractConfig = class _ContractConfig extends BaseConfig {
194
+ address;
195
+ abi;
196
+ // biome-ignore lint/suspicious/noExplicitAny: not sure how to fix this
197
+ args;
198
+ static is(obj) {
199
+ return obj instanceof _ContractConfig;
200
+ }
201
+ constructor({
202
+ address,
203
+ abi,
204
+ args,
205
+ ...other
206
+ }) {
207
+ super({ ...other });
208
+ this.address = address;
209
+ this.abi = abi;
210
+ this.args = args;
211
+ }
212
+ encodeFunctionData() {
213
+ return encodeFunctionData({
214
+ abi: this.abi,
215
+ functionName: this.func,
216
+ args: this.args
217
+ });
218
+ }
219
+ };
220
+
221
+ // src/contract/contracts/Xtokens/Xtokens.ts
222
+ import { formatAssetIdToERC20 } from "@moonbeam-network/xcm-utils";
223
+ import { u8aToHex as u8aToHex3 } from "@polkadot/util";
224
+ import { decodeAddress as decodeAddress3, evmToAddress } from "@polkadot/util-crypto";
225
+
226
+ // src/builder.utils.ts
227
+ import { EvmParachain } from "@moonbeam-network/xcm-types";
228
+ import { u8aToHex as u8aToHex2 } from "@polkadot/util";
229
+ import { decodeAddress as decodeAddress2 } from "@polkadot/util-crypto";
230
+ function getPrecompileDestinationInterior(destination, address) {
231
+ if (!address) {
232
+ return [`0x0000000${destination.parachainId.toString(16)}`];
233
+ }
234
+ const accountType = EvmParachain.is(destination) ? "03" : "01";
235
+ const acc = `0x${accountType}${u8aToHex2(
236
+ decodeAddress2(address),
237
+ -1,
238
+ false
239
+ )}00`;
240
+ return destination.parachainId ? [`0x0000000${destination.parachainId.toString(16)}`, acc] : [acc];
241
+ }
242
+
243
+ // src/contract/contracts/Xtokens/XtokensABI.ts
244
+ var XTOKENS_ABI = [
245
+ {
246
+ inputs: [
247
+ {
248
+ internalType: "address",
249
+ name: "currencyAddress",
250
+ type: "address"
251
+ },
252
+ {
253
+ internalType: "uint256",
254
+ name: "amount",
255
+ type: "uint256"
256
+ },
257
+ {
258
+ components: [
259
+ {
260
+ internalType: "uint8",
261
+ name: "parents",
262
+ type: "uint8"
263
+ },
264
+ {
265
+ internalType: "bytes[]",
266
+ name: "interior",
267
+ type: "bytes[]"
268
+ }
269
+ ],
270
+ internalType: "struct Xtokens.Multilocation",
271
+ name: "destination",
272
+ type: "tuple"
273
+ },
274
+ {
275
+ internalType: "uint64",
276
+ name: "weight",
277
+ type: "uint64"
278
+ }
279
+ ],
280
+ name: "transfer",
281
+ outputs: [],
282
+ stateMutability: "nonpayable",
283
+ type: "function"
284
+ },
285
+ {
286
+ inputs: [
287
+ {
288
+ components: [
289
+ {
290
+ internalType: "address",
291
+ name: "currencyAddress",
292
+ type: "address"
293
+ },
294
+ {
295
+ internalType: "uint256",
296
+ name: "amount",
297
+ type: "uint256"
298
+ }
299
+ ],
300
+ internalType: "struct Xtokens.Currency[]",
301
+ name: "currencies",
302
+ type: "tuple[]"
303
+ },
304
+ {
305
+ internalType: "uint32",
306
+ name: "feeItem",
307
+ type: "uint32"
308
+ },
309
+ {
310
+ components: [
311
+ {
312
+ internalType: "uint8",
313
+ name: "parents",
314
+ type: "uint8"
315
+ },
316
+ {
317
+ internalType: "bytes[]",
318
+ name: "interior",
319
+ type: "bytes[]"
320
+ }
321
+ ],
322
+ internalType: "struct Xtokens.Multilocation",
323
+ name: "destination",
324
+ type: "tuple"
325
+ },
326
+ {
327
+ internalType: "uint64",
328
+ name: "weight",
329
+ type: "uint64"
330
+ }
331
+ ],
332
+ name: "transferMultiCurrencies",
333
+ outputs: [],
334
+ stateMutability: "nonpayable",
335
+ type: "function"
336
+ }
337
+ ];
338
+
339
+ // src/contract/contracts/Xtokens/Xtokens.ts
340
+ var U_64_MAX = 18446744073709551615n;
341
+ var XTOKENS_CONTRACT_ADDRESS = "0x0000000000000000000000000000000000000804";
342
+ function Xtokens() {
343
+ return {
344
+ transfer: (weight = U_64_MAX) => ({
345
+ build: ({ destinationAddress, asset, destination }) => new ContractConfig({
346
+ address: XTOKENS_CONTRACT_ADDRESS,
347
+ abi: XTOKENS_ABI,
348
+ args: [
349
+ asset.address ? formatAssetIdToERC20(asset.address) : asset.getAssetId(),
350
+ asset.amount,
351
+ getDestinationMultilocation(destinationAddress, destination),
352
+ weight
353
+ ],
354
+ func: "transfer",
355
+ module: "Xtokens"
356
+ })
357
+ }),
358
+ transferMultiCurrencies: (weight = U_64_MAX) => ({
359
+ build: ({ asset, destination, destinationAddress, fee }) => new ContractConfig({
360
+ address: XTOKENS_CONTRACT_ADDRESS,
361
+ abi: XTOKENS_ABI,
362
+ args: [
363
+ [
364
+ [
365
+ asset.address ? formatAssetIdToERC20(asset.address) : asset.getAssetId(),
366
+ asset.amount
367
+ ],
368
+ [
369
+ fee.address ? formatAssetIdToERC20(fee.address) : fee.getAssetId(),
370
+ fee.amount
371
+ ]
372
+ ],
373
+ 1,
374
+ // index of the fee asset
375
+ getDestinationMultilocation(destinationAddress, destination),
376
+ weight
377
+ ],
378
+ func: "transferMultiCurrencies",
379
+ module: "Xtokens"
380
+ })
381
+ }),
382
+ transferWithEvmTo32: (weight = U_64_MAX) => ({
383
+ build: ({ destinationAddress, asset, destination }) => {
384
+ const multilocation = getDestinationMultilocationForPrecompileDestination(
385
+ destinationAddress,
386
+ destination
387
+ );
388
+ return new ContractConfig({
389
+ address: XTOKENS_CONTRACT_ADDRESS,
390
+ abi: XTOKENS_ABI,
391
+ args: [
392
+ asset.address ? formatAssetIdToERC20(asset.address) : asset.getAssetId(),
393
+ asset.amount,
394
+ multilocation,
395
+ weight
396
+ ],
397
+ func: "transfer",
398
+ module: "Xtokens"
399
+ });
400
+ }
401
+ })
402
+ };
403
+ }
404
+ function getDestinationMultilocationForPrecompileDestination(address, destination) {
405
+ const accountType = "01";
406
+ const substrateAddress = evmToAddress(address);
407
+ const acc = `0x${accountType}${u8aToHex3(
408
+ decodeAddress3(substrateAddress),
409
+ -1,
410
+ false
411
+ )}00`;
412
+ return [
413
+ 1,
414
+ destination.parachainId ? [`0x0000000${destination.parachainId.toString(16)}`, acc] : [acc]
415
+ ];
416
+ }
417
+ function getDestinationMultilocation(address, destination) {
418
+ const interior = getPrecompileDestinationInterior(destination, address);
419
+ return [1, interior];
420
+ }
421
+
422
+ // src/contract/ContractBuilder.ts
423
+ function ContractBuilder() {
424
+ return {
425
+ Xtokens
426
+ };
427
+ }
428
+
429
+ // src/types/evm/EvmQueryConfig.ts
430
+ var EvmQueryConfig = class _EvmQueryConfig {
431
+ args;
432
+ func;
433
+ static is(obj) {
434
+ return obj instanceof _EvmQueryConfig;
435
+ }
436
+ constructor({ args, func }) {
437
+ this.args = args;
438
+ this.func = func;
439
+ }
440
+ };
441
+
442
+ // src/balance/Erc20Abi.ts
443
+ var ERC20_ABI = [
444
+ {
445
+ constant: true,
446
+ inputs: [],
447
+ name: "name",
448
+ outputs: [
449
+ {
450
+ name: "",
451
+ type: "string"
452
+ }
453
+ ],
454
+ payable: false,
455
+ stateMutability: "view",
456
+ type: "function"
457
+ },
458
+ {
459
+ constant: false,
460
+ inputs: [
461
+ {
462
+ name: "_spender",
463
+ type: "address"
464
+ },
465
+ {
466
+ name: "_value",
467
+ type: "uint256"
468
+ }
469
+ ],
470
+ name: "approve",
471
+ outputs: [
472
+ {
473
+ name: "",
474
+ type: "bool"
475
+ }
476
+ ],
477
+ payable: false,
478
+ stateMutability: "nonpayable",
479
+ type: "function"
480
+ },
481
+ {
482
+ constant: true,
483
+ inputs: [],
484
+ name: "totalSupply",
485
+ outputs: [
486
+ {
487
+ name: "",
488
+ type: "uint256"
489
+ }
490
+ ],
491
+ payable: false,
492
+ stateMutability: "view",
493
+ type: "function"
494
+ },
495
+ {
496
+ constant: false,
497
+ inputs: [
498
+ {
499
+ name: "_from",
500
+ type: "address"
501
+ },
502
+ {
503
+ name: "_to",
504
+ type: "address"
505
+ },
506
+ {
507
+ name: "_value",
508
+ type: "uint256"
509
+ }
510
+ ],
511
+ name: "transferFrom",
512
+ outputs: [
513
+ {
514
+ name: "",
515
+ type: "bool"
516
+ }
517
+ ],
518
+ payable: false,
519
+ stateMutability: "nonpayable",
520
+ type: "function"
521
+ },
522
+ {
523
+ constant: true,
524
+ inputs: [],
525
+ name: "decimals",
526
+ outputs: [
527
+ {
528
+ name: "",
529
+ type: "uint8"
530
+ }
531
+ ],
532
+ payable: false,
533
+ stateMutability: "view",
534
+ type: "function"
535
+ },
536
+ {
537
+ constant: true,
538
+ inputs: [
539
+ {
540
+ name: "_owner",
541
+ type: "address"
542
+ }
543
+ ],
544
+ name: "balanceOf",
545
+ outputs: [
546
+ {
547
+ name: "balance",
548
+ type: "uint256"
549
+ }
550
+ ],
551
+ payable: false,
552
+ stateMutability: "view",
553
+ type: "function"
554
+ },
555
+ {
556
+ constant: true,
557
+ inputs: [],
558
+ name: "symbol",
559
+ outputs: [
560
+ {
561
+ name: "",
562
+ type: "string"
563
+ }
564
+ ],
565
+ payable: false,
566
+ stateMutability: "view",
567
+ type: "function"
568
+ },
569
+ {
570
+ constant: false,
571
+ inputs: [
572
+ {
573
+ name: "_to",
574
+ type: "address"
575
+ },
576
+ {
577
+ name: "_value",
578
+ type: "uint256"
579
+ }
580
+ ],
581
+ name: "transfer",
582
+ outputs: [
583
+ {
584
+ name: "",
585
+ type: "bool"
586
+ }
587
+ ],
588
+ payable: false,
589
+ stateMutability: "nonpayable",
590
+ type: "function"
591
+ },
592
+ {
593
+ constant: true,
594
+ inputs: [
595
+ {
596
+ name: "_owner",
597
+ type: "address"
598
+ },
599
+ {
600
+ name: "_spender",
601
+ type: "address"
602
+ }
603
+ ],
604
+ name: "allowance",
605
+ outputs: [
606
+ {
607
+ name: "",
608
+ type: "uint256"
609
+ }
610
+ ],
611
+ payable: false,
612
+ stateMutability: "view",
613
+ type: "function"
614
+ },
615
+ {
616
+ payable: true,
617
+ stateMutability: "payable",
618
+ type: "fallback"
619
+ },
620
+ {
621
+ anonymous: false,
622
+ inputs: [
623
+ {
624
+ indexed: true,
625
+ name: "owner",
626
+ type: "address"
627
+ },
628
+ {
629
+ indexed: true,
630
+ name: "spender",
631
+ type: "address"
632
+ },
633
+ {
634
+ indexed: false,
635
+ name: "value",
636
+ type: "uint256"
637
+ }
638
+ ],
639
+ name: "Approval",
640
+ type: "event"
641
+ },
642
+ {
643
+ anonymous: false,
644
+ inputs: [
645
+ {
646
+ indexed: true,
647
+ name: "from",
648
+ type: "address"
649
+ },
650
+ {
651
+ indexed: true,
652
+ name: "to",
653
+ type: "address"
654
+ },
655
+ {
656
+ indexed: false,
657
+ name: "value",
658
+ type: "uint256"
659
+ }
660
+ ],
661
+ name: "Transfer",
662
+ type: "event"
663
+ }
664
+ ];
665
+
666
+ // src/balance/BalanceBuilder.ts
667
+ function BalanceBuilder() {
668
+ return {
669
+ evm,
670
+ substrate
671
+ };
672
+ }
673
+ function evm() {
674
+ return {
675
+ erc20,
676
+ native
677
+ };
678
+ }
679
+ function erc20() {
680
+ return {
681
+ build: ({ asset, address }) => {
682
+ if (!asset.address) {
683
+ throw new Error(`Asset ${asset.key} has no address`);
684
+ }
685
+ return new ContractConfig({
686
+ address: asset.address,
687
+ abi: ERC20_ABI,
688
+ args: [address],
689
+ func: "balanceOf",
690
+ module: "Erc20"
691
+ });
692
+ }
693
+ };
694
+ }
695
+ function native() {
696
+ return {
697
+ build: ({ address }) => {
698
+ return new EvmQueryConfig({
699
+ func: "getBalance",
700
+ args: [{ address }]
701
+ });
702
+ }
703
+ };
704
+ }
705
+ function substrate() {
706
+ return {
707
+ assets: assets2,
708
+ foreignAssets: foreignAssets2,
709
+ system,
710
+ tokens
711
+ };
712
+ }
713
+ function assets2() {
714
+ return {
715
+ account: () => ({
716
+ build: ({ address, asset }) => new SubstrateQueryConfig({
717
+ module: "assets",
718
+ func: "account",
719
+ args: [asset.getBalanceAssetId(), address],
720
+ transform: async (response) => response.unwrapOrDefault().balance.toBigInt()
721
+ })
722
+ })
723
+ };
724
+ }
725
+ function foreignAssets2() {
726
+ return {
727
+ account: () => ({
728
+ build: ({ address, asset }) => {
729
+ if (!asset.address) {
730
+ throw new Error(
731
+ "Asset address is needed to calculate balance with foreignAssets.account function"
732
+ );
733
+ }
734
+ const multilocation = {
735
+ parents: 2,
736
+ interior: {
737
+ X2: [
738
+ { GlobalConsensus: { ethereum: { chainId: 1 } } },
739
+ getExtrinsicAccount(asset.address)
740
+ ]
741
+ }
742
+ };
743
+ return new SubstrateQueryConfig({
744
+ module: "foreignAssets",
745
+ func: "account",
746
+ args: [multilocation, address],
747
+ transform: async (response) => response.unwrapOrDefault().balance.toBigInt()
748
+ });
749
+ }
750
+ })
751
+ };
752
+ }
753
+ function system() {
754
+ return {
755
+ account: () => ({
756
+ build: ({ address }) => new SubstrateQueryConfig({
757
+ module: "system",
758
+ func: "account",
759
+ args: [address],
760
+ transform: async (response) => calculateSystemAccountBalance(response)
761
+ })
762
+ }),
763
+ accountEquilibrium: () => ({
764
+ build: ({ address, asset }) => new SubstrateQueryConfig({
765
+ module: "system",
766
+ func: "account",
767
+ args: [address],
768
+ transform: async (response) => {
769
+ if (response.data.isEmpty) {
770
+ return 0n;
771
+ }
772
+ const res = response.data.toJSON();
773
+ let balances;
774
+ if (Array.isArray(res)) {
775
+ balances = res;
776
+ }
777
+ if (Array.isArray(res?.v0?.balance)) {
778
+ balances = res.v0.balance;
779
+ }
780
+ if (!balances) {
781
+ throw new Error("Can't get balance from Equilibrium chain");
782
+ }
783
+ const balance = balances.find(
784
+ ([assetId]) => assetId === asset.getBalanceAssetId()
785
+ );
786
+ if (!balance) {
787
+ return 0n;
788
+ }
789
+ return BigInt(balance[1].positive);
790
+ }
791
+ })
792
+ }),
793
+ accountEvmTo32: () => ({
794
+ build: ({ address }) => {
795
+ const substrateAddress = evmToAddress2(address);
796
+ return new SubstrateQueryConfig({
797
+ module: "system",
798
+ func: "account",
799
+ args: [substrateAddress],
800
+ transform: async (response) => calculateSystemAccountBalance(response)
801
+ });
802
+ }
803
+ })
804
+ };
805
+ }
806
+ function tokens() {
807
+ return {
808
+ accounts: () => ({
809
+ build: ({ address, asset }) => new SubstrateQueryConfig({
810
+ module: "tokens",
811
+ func: "accounts",
812
+ args: [address, asset.getBalanceAssetId()],
813
+ transform: async ({
814
+ free,
815
+ frozen
816
+ }) => BigInt(free.sub(frozen).toString())
817
+ })
818
+ })
819
+ };
820
+ }
821
+ async function calculateSystemAccountBalance(response) {
822
+ const balance = response.data;
823
+ const free = BigInt(balance.free.toString());
824
+ const frozen = balance.miscFrozen ?? balance.frozen;
825
+ const frozenMinusReserved = BigInt(frozen.sub(balance.reserved).toString());
826
+ const locked = frozenMinusReserved < 0n ? 0n : frozenMinusReserved;
827
+ return free - locked;
828
+ }
829
+
830
+ // src/types/substrate/ExtrinsicConfig.ts
831
+ var ExtrinsicConfig = class _ExtrinsicConfig extends BaseConfig {
832
+ // biome-ignore lint/suspicious/noExplicitAny: not sure how to fix this
833
+ getArgs;
834
+ static is(obj) {
835
+ return obj instanceof _ExtrinsicConfig;
836
+ }
837
+ constructor({ getArgs, ...other }) {
838
+ super({ ...other });
839
+ this.getArgs = getArgs;
840
+ }
841
+ };
842
+
843
+ // src/extrinsic/pallets/eqBalances/eqBalances.ts
844
+ var pallet = "eqBalances";
845
+ function eqBalances() {
846
+ return {
847
+ xcmTransfer: () => ({
848
+ build: ({ destinationAddress, asset, destination }) => new ExtrinsicConfig({
849
+ module: pallet,
850
+ func: "xcmTransfer",
851
+ getArgs: () => [
852
+ asset.getAssetId(),
853
+ asset.amount,
854
+ {
855
+ parents: 1,
856
+ interior: {
857
+ X2: [
858
+ {
859
+ Parachain: destination.parachainId
860
+ },
861
+ getExtrinsicAccount(destinationAddress)
862
+ ]
863
+ }
864
+ },
865
+ "ThisAccWillPay" /* ThisAccWillPay */
866
+ ]
867
+ })
868
+ }),
869
+ transferXcm: () => ({
870
+ build: ({ destinationAddress: address, asset, destination, fee }) => new ExtrinsicConfig({
871
+ module: pallet,
872
+ func: "transferXcm",
873
+ getArgs: () => {
874
+ const amountWithoutFee = asset.amount - fee.amount > 0n ? asset.amount - fee.amount : 0n;
875
+ return [
876
+ [
877
+ asset.getAssetId(),
878
+ asset.isSame(fee) ? amountWithoutFee : asset.amount
879
+ ],
880
+ [fee.getAssetId(), fee.amount],
881
+ {
882
+ parents: 1,
883
+ interior: {
884
+ X2: [
885
+ {
886
+ Parachain: destination.parachainId
887
+ },
888
+ getExtrinsicAccount(address)
889
+ ]
890
+ }
891
+ }
892
+ ];
893
+ }
894
+ })
895
+ })
896
+ };
897
+ }
898
+
899
+ // src/extrinsic/pallets/polkadotXcm/polkadotXcm.util.ts
900
+ function getPolkadotXcmExtrinsicArgs({
901
+ asset,
902
+ destinationAddress,
903
+ destination,
904
+ func,
905
+ parents = 1,
906
+ feeIndex = 0
907
+ // biome-ignore lint/suspicious/noExplicitAny: not sure how to fix this
908
+ }) {
909
+ const version = getExtrinsicArgumentVersion(func);
910
+ return [
911
+ {
912
+ [version]: normalizeX1(version, {
913
+ parents,
914
+ interior: {
915
+ X1: {
916
+ Parachain: destination.parachainId
917
+ }
918
+ }
919
+ })
920
+ },
921
+ {
922
+ [version]: normalizeX1(version, {
923
+ parents: 0,
924
+ interior: {
925
+ X1: getExtrinsicAccount(destinationAddress)
926
+ }
927
+ })
928
+ },
929
+ {
930
+ [version]: asset
931
+ },
932
+ feeIndex,
933
+ "Unlimited"
934
+ ];
935
+ }
936
+ function shouldFeeAssetPrecedeAsset({
937
+ asset,
938
+ fee
939
+ }) {
940
+ const assetIdNumber = Number(asset.getAssetId());
941
+ const feeAssetIdNumber = Number(fee.getAssetId());
942
+ if (Number.isNaN(assetIdNumber) || Number.isNaN(feeAssetIdNumber)) {
943
+ return false;
944
+ }
945
+ return assetIdNumber > feeAssetIdNumber;
946
+ }
947
+
948
+ // src/extrinsic/pallets/polkadotXcm/polkadotXcm.ts
949
+ var pallet2 = "polkadotXcm";
950
+ function polkadotXcm() {
951
+ return {
952
+ limitedReserveTransferAssets: () => {
953
+ const func = "limitedReserveTransferAssets";
954
+ return {
955
+ here: () => ({
956
+ build: (params) => new ExtrinsicConfig({
957
+ module: pallet2,
958
+ func,
959
+ getArgs: (extrinsicFunction) => {
960
+ const version = getExtrinsicArgumentVersion(extrinsicFunction);
961
+ return getPolkadotXcmExtrinsicArgs({
962
+ ...params,
963
+ func: extrinsicFunction,
964
+ asset: [
965
+ {
966
+ id: normalizeConcrete(version, {
967
+ parents: 0,
968
+ interior: "Here"
969
+ }),
970
+ fun: {
971
+ Fungible: params.asset.amount
972
+ }
973
+ }
974
+ ]
975
+ });
976
+ }
977
+ })
978
+ }),
979
+ X1: () => ({
980
+ build: (params) => new ExtrinsicConfig({
981
+ module: pallet2,
982
+ func,
983
+ getArgs: (extrinsicFunction) => {
984
+ const version = getExtrinsicArgumentVersion(extrinsicFunction);
985
+ return getPolkadotXcmExtrinsicArgs({
986
+ ...params,
987
+ func: extrinsicFunction,
988
+ asset: [
989
+ {
990
+ id: normalizeConcrete(
991
+ version,
992
+ normalizeX1(version, {
993
+ parents: 0,
994
+ interior: {
995
+ X1: {
996
+ PalletInstance: params.asset.getAssetPalletInstance()
997
+ }
998
+ }
999
+ })
1000
+ ),
1001
+ fun: {
1002
+ Fungible: params.asset.amount
1003
+ }
1004
+ }
1005
+ ]
1006
+ });
1007
+ }
1008
+ })
1009
+ }),
1010
+ X2: () => ({
1011
+ build: (params) => new ExtrinsicConfig({
1012
+ module: pallet2,
1013
+ func,
1014
+ getArgs: (extrinsicFunction) => {
1015
+ const isAssetDifferent = !params.asset.isSame(params.fee);
1016
+ const version = getExtrinsicArgumentVersion(extrinsicFunction);
1017
+ const assets3 = [
1018
+ {
1019
+ id: normalizeConcrete(version, {
1020
+ parents: 0,
1021
+ interior: {
1022
+ X2: [
1023
+ {
1024
+ PalletInstance: params.asset.getAssetPalletInstance()
1025
+ },
1026
+ {
1027
+ GeneralIndex: params.asset.getAssetId()
1028
+ }
1029
+ ]
1030
+ }
1031
+ }),
1032
+ fun: {
1033
+ Fungible: params.asset.amount
1034
+ }
1035
+ }
1036
+ ];
1037
+ const shouldFeeAssetPrecede = shouldFeeAssetPrecedeAsset(params);
1038
+ if (isAssetDifferent) {
1039
+ const feeAsset = {
1040
+ id: normalizeConcrete(version, {
1041
+ parents: 0,
1042
+ interior: {
1043
+ X2: [
1044
+ {
1045
+ PalletInstance: params.fee.getAssetPalletInstance()
1046
+ },
1047
+ {
1048
+ GeneralIndex: params.fee.getAssetId()
1049
+ }
1050
+ ]
1051
+ }
1052
+ }),
1053
+ fun: {
1054
+ Fungible: params.fee.amount
1055
+ }
1056
+ };
1057
+ if (shouldFeeAssetPrecede) {
1058
+ assets3.unshift(feeAsset);
1059
+ } else {
1060
+ assets3.push(feeAsset);
1061
+ }
1062
+ }
1063
+ return getPolkadotXcmExtrinsicArgs({
1064
+ ...params,
1065
+ func: extrinsicFunction,
1066
+ asset: assets3,
1067
+ feeIndex: isAssetDifferent && !shouldFeeAssetPrecede ? 1 : 0
1068
+ });
1069
+ }
1070
+ })
1071
+ })
1072
+ };
1073
+ },
1074
+ limitedReserveWithdrawAssets: () => {
1075
+ const func = "limitedReserveWithdrawAssets";
1076
+ return {
1077
+ X2: () => ({
1078
+ build: (params) => new ExtrinsicConfig({
1079
+ module: pallet2,
1080
+ func,
1081
+ getArgs: (extrinsicFunction) => {
1082
+ const version = getExtrinsicArgumentVersion(extrinsicFunction);
1083
+ return getPolkadotXcmExtrinsicArgs({
1084
+ ...params,
1085
+ func: extrinsicFunction,
1086
+ asset: [
1087
+ {
1088
+ id: normalizeConcrete(version, {
1089
+ parents: 1,
1090
+ interior: {
1091
+ X2: [
1092
+ {
1093
+ Parachain: params.destination.parachainId
1094
+ },
1095
+ {
1096
+ PalletInstance: params.asset.getAssetPalletInstance()
1097
+ }
1098
+ ]
1099
+ }
1100
+ }),
1101
+ fun: {
1102
+ Fungible: params.asset.amount
1103
+ }
1104
+ }
1105
+ ]
1106
+ });
1107
+ }
1108
+ })
1109
+ })
1110
+ };
1111
+ },
1112
+ transferAssets: () => {
1113
+ const func = "transferAssets";
1114
+ return {
1115
+ here: () => ({
1116
+ build: (params) => new ExtrinsicConfig({
1117
+ module: pallet2,
1118
+ func,
1119
+ getArgs: (extrinsicFunction) => {
1120
+ const version = getExtrinsicArgumentVersion(extrinsicFunction);
1121
+ return getPolkadotXcmExtrinsicArgs({
1122
+ ...params,
1123
+ func: extrinsicFunction,
1124
+ asset: [
1125
+ {
1126
+ id: normalizeConcrete(version, {
1127
+ parents: 1,
1128
+ interior: "Here"
1129
+ }),
1130
+ fun: {
1131
+ Fungible: params.asset.amount
1132
+ }
1133
+ }
1134
+ ]
1135
+ });
1136
+ }
1137
+ })
1138
+ })
1139
+ };
1140
+ },
1141
+ transferAssetsUsingTypeAndThen: () => {
1142
+ const func = "transferAssetsUsingTypeAndThen";
1143
+ return {
1144
+ // TODO we could pass a parameter globalConsensus in the chain asset if we need a different one
1145
+ globalConsensusEthereum: () => ({
1146
+ build: (params) => new ExtrinsicConfig({
1147
+ module: pallet2,
1148
+ func,
1149
+ getArgs: (extrinsicFunction) => {
1150
+ if (!params.asset.address) {
1151
+ throw new Error(
1152
+ "Asset address is needed for transferAssetsUsingTypeAndThen.globalConsensus function"
1153
+ );
1154
+ }
1155
+ const version = getExtrinsicArgumentVersion(extrinsicFunction);
1156
+ return [
1157
+ {
1158
+ [version]: {
1159
+ parents: 1,
1160
+ interior: {
1161
+ X1: [
1162
+ {
1163
+ Parachain: params.destination.parachainId
1164
+ }
1165
+ ]
1166
+ }
1167
+ }
1168
+ },
1169
+ {
1170
+ [version]: [
1171
+ {
1172
+ id: normalizeConcrete(version, {
1173
+ parents: 2,
1174
+ interior: {
1175
+ X2: [
1176
+ { globalConsensus: { Ethereum: { ChainId: 1 } } },
1177
+ getExtrinsicAccount(params.asset.address)
1178
+ ]
1179
+ }
1180
+ }),
1181
+ fun: { fungible: params.asset.amount }
1182
+ }
1183
+ ]
1184
+ },
1185
+ "LocalReserve",
1186
+ {
1187
+ [version]: normalizeConcrete(version, {
1188
+ parents: 2,
1189
+ interior: {
1190
+ X2: [
1191
+ { globalConsensus: { Ethereum: { ChainId: 1 } } },
1192
+ getExtrinsicAccount(params.asset.address)
1193
+ ]
1194
+ }
1195
+ })
1196
+ },
1197
+ "LocalReserve",
1198
+ {
1199
+ [version]: [
1200
+ {
1201
+ DepositAsset: {
1202
+ assets: {
1203
+ Wild: { AllCounted: 1 }
1204
+ },
1205
+ beneficiary: normalizeX1(version, {
1206
+ parents: 0,
1207
+ interior: {
1208
+ X1: getExtrinsicAccount(
1209
+ params.destinationAddress
1210
+ )
1211
+ }
1212
+ })
1213
+ }
1214
+ }
1215
+ ]
1216
+ },
1217
+ "Unlimited"
1218
+ ];
1219
+ }
1220
+ })
1221
+ })
1222
+ };
1223
+ }
1224
+ };
1225
+ }
1226
+
1227
+ // src/extrinsic/pallets/xTokens/xTokens.utils.ts
1228
+ function getWeight() {
1229
+ return "Unlimited";
1230
+ }
1231
+ function getDestination(version, address, destination) {
1232
+ return {
1233
+ [version]: {
1234
+ parents: 1,
1235
+ interior: {
1236
+ X2: [
1237
+ {
1238
+ Parachain: destination.parachainId
1239
+ },
1240
+ getExtrinsicAccount(address)
1241
+ ]
1242
+ }
1243
+ }
1244
+ };
1245
+ }
1246
+
1247
+ // src/extrinsic/pallets/xTokens/xTokens.ts
1248
+ var pallet3 = "xTokens";
1249
+ function xTokens() {
1250
+ return {
1251
+ transfer: () => ({
1252
+ build: ({ destinationAddress, asset, destination }) => new ExtrinsicConfig({
1253
+ module: pallet3,
1254
+ func: "transfer",
1255
+ getArgs: (func) => {
1256
+ const destIndex = 2;
1257
+ const version = getExtrinsicArgumentVersion(func, destIndex);
1258
+ return [
1259
+ asset.getAssetId(),
1260
+ asset.amount,
1261
+ getDestination(version, destinationAddress, destination),
1262
+ getWeight()
1263
+ ];
1264
+ }
1265
+ })
1266
+ }),
1267
+ transferMultiAsset: (originParachainId) => {
1268
+ const funcName = "transferMultiasset";
1269
+ const destIndex = 1;
1270
+ return {
1271
+ here: () => ({
1272
+ build: ({ destinationAddress: address, asset, destination }) => new ExtrinsicConfig({
1273
+ module: pallet3,
1274
+ func: funcName,
1275
+ getArgs: (func) => {
1276
+ const version = getExtrinsicArgumentVersion(func, destIndex);
1277
+ return [
1278
+ {
1279
+ [version]: {
1280
+ id: normalizeConcrete(version, {
1281
+ parents: 0,
1282
+ interior: "Here"
1283
+ }),
1284
+ fun: {
1285
+ Fungible: asset.amount
1286
+ }
1287
+ }
1288
+ },
1289
+ getDestination(version, address, destination),
1290
+ getWeight()
1291
+ ];
1292
+ }
1293
+ })
1294
+ }),
1295
+ X1: () => ({
1296
+ build: ({ destinationAddress: address, asset, destination }) => new ExtrinsicConfig({
1297
+ module: pallet3,
1298
+ func: funcName,
1299
+ getArgs: (func) => {
1300
+ const version = getExtrinsicArgumentVersion(func, destIndex);
1301
+ return [
1302
+ {
1303
+ [version]: {
1304
+ id: normalizeConcrete(
1305
+ version,
1306
+ normalizeX1(version, {
1307
+ parents: 1,
1308
+ interior: {
1309
+ X1: {
1310
+ Parachain: originParachainId
1311
+ }
1312
+ }
1313
+ })
1314
+ ),
1315
+ fun: {
1316
+ Fungible: asset.amount
1317
+ }
1318
+ }
1319
+ },
1320
+ getDestination(version, address, destination),
1321
+ getWeight()
1322
+ ];
1323
+ }
1324
+ })
1325
+ }),
1326
+ X2: () => ({
1327
+ build: ({ destinationAddress: address, asset, destination }) => new ExtrinsicConfig({
1328
+ module: pallet3,
1329
+ func: funcName,
1330
+ getArgs: (func) => {
1331
+ const version = getExtrinsicArgumentVersion(func, destIndex);
1332
+ return [
1333
+ {
1334
+ [version]: {
1335
+ id: normalizeConcrete(version, {
1336
+ parents: 1,
1337
+ interior: {
1338
+ X2: [
1339
+ {
1340
+ Parachain: originParachainId
1341
+ },
1342
+ {
1343
+ GeneralKey: asset.getAssetId()
1344
+ }
1345
+ ]
1346
+ }
1347
+ }),
1348
+ fun: {
1349
+ Fungible: asset.amount
1350
+ }
1351
+ }
1352
+ },
1353
+ getDestination(version, address, destination),
1354
+ getWeight()
1355
+ ];
1356
+ }
1357
+ })
1358
+ })
1359
+ };
1360
+ },
1361
+ transferMultiCurrencies: () => ({
1362
+ build: ({ destinationAddress: address, asset, destination, fee }) => new ExtrinsicConfig({
1363
+ module: pallet3,
1364
+ func: "transferMulticurrencies",
1365
+ getArgs: () => [
1366
+ [
1367
+ [asset.getAssetId(), asset.amount],
1368
+ [fee.getAssetId(), fee.amount]
1369
+ ],
1370
+ 1,
1371
+ getDestination("V3" /* v3 */, address, destination),
1372
+ getWeight()
1373
+ ]
1374
+ })
1375
+ })
1376
+ };
1377
+ }
1378
+
1379
+ // src/extrinsic/pallets/xTransfer/xTransfer.ts
1380
+ var pallet4 = "xTransfer";
1381
+ function xTransfer() {
1382
+ return {
1383
+ transfer: () => {
1384
+ const method = "transfer";
1385
+ return {
1386
+ here: () => ({
1387
+ build: ({ destinationAddress: address, asset, destination }) => new ExtrinsicConfig({
1388
+ module: pallet4,
1389
+ func: method,
1390
+ getArgs: () => [
1391
+ {
1392
+ id: {
1393
+ Concrete: {
1394
+ parents: 0,
1395
+ interior: "Here"
1396
+ }
1397
+ },
1398
+ fun: {
1399
+ Fungible: asset.amount
1400
+ }
1401
+ },
1402
+ {
1403
+ parents: 1,
1404
+ interior: {
1405
+ X2: [
1406
+ {
1407
+ Parachain: destination.parachainId
1408
+ },
1409
+ getExtrinsicAccount(address)
1410
+ ]
1411
+ }
1412
+ },
1413
+ {
1414
+ refTime: 5e9,
1415
+ proofSize: 0
1416
+ }
1417
+ ]
1418
+ })
1419
+ }),
1420
+ X2: () => ({
1421
+ build: ({ destinationAddress, asset, destination }) => new ExtrinsicConfig({
1422
+ module: pallet4,
1423
+ func: method,
1424
+ getArgs: () => [
1425
+ {
1426
+ id: {
1427
+ Concrete: {
1428
+ parents: 1,
1429
+ interior: {
1430
+ X2: [
1431
+ {
1432
+ Parachain: destination.parachainId
1433
+ },
1434
+ {
1435
+ PalletInstance: asset.getAssetPalletInstance()
1436
+ }
1437
+ ]
1438
+ }
1439
+ }
1440
+ },
1441
+ fun: {
1442
+ Fungible: asset.amount || 1n
1443
+ }
1444
+ },
1445
+ {
1446
+ parents: 1,
1447
+ interior: {
1448
+ X2: [
1449
+ {
1450
+ Parachain: destination.parachainId
1451
+ },
1452
+ getExtrinsicAccount(destinationAddress)
1453
+ ]
1454
+ }
1455
+ },
1456
+ {
1457
+ refTime: 5e9,
1458
+ proofSize: 0
1459
+ }
1460
+ ]
1461
+ })
1462
+ })
1463
+ };
1464
+ }
1465
+ };
1466
+ }
1467
+
1468
+ // src/extrinsic/pallets/xcmPallet/xcmPallet.ts
1469
+ var pallet5 = "xcmPallet";
1470
+ function xcmPallet() {
1471
+ return {
1472
+ limitedReserveTransferAssets: (parents = 1) => {
1473
+ const func = "limitedReserveTransferAssets";
1474
+ return {
1475
+ here: () => ({
1476
+ build: (params) => new ExtrinsicConfig({
1477
+ module: pallet5,
1478
+ func,
1479
+ getArgs: (extrinsicFunction) => {
1480
+ const version = getExtrinsicArgumentVersion(extrinsicFunction);
1481
+ return getPolkadotXcmExtrinsicArgs({
1482
+ ...params,
1483
+ parents,
1484
+ func: extrinsicFunction,
1485
+ asset: [
1486
+ {
1487
+ id: normalizeConcrete(version, {
1488
+ parents: 0,
1489
+ interior: "Here"
1490
+ }),
1491
+ fun: {
1492
+ Fungible: params.asset.amount
1493
+ }
1494
+ }
1495
+ ]
1496
+ });
1497
+ }
1498
+ })
1499
+ })
1500
+ };
1501
+ },
1502
+ transferAssetsUsingTypeAndThen: () => {
1503
+ const func = "transferAssetsUsingTypeAndThen";
1504
+ return {
1505
+ here: () => ({
1506
+ build: (params) => new ExtrinsicConfig({
1507
+ module: pallet5,
1508
+ func,
1509
+ getArgs: () => {
1510
+ const version = "V4" /* v4 */;
1511
+ return [
1512
+ {
1513
+ [version]: {
1514
+ parents: 0,
1515
+ interior: {
1516
+ X1: [
1517
+ {
1518
+ Parachain: params.destination.parachainId
1519
+ }
1520
+ ]
1521
+ }
1522
+ }
1523
+ },
1524
+ {
1525
+ [version]: [
1526
+ {
1527
+ id: {
1528
+ parents: 0,
1529
+ interior: "Here"
1530
+ },
1531
+ fun: {
1532
+ Fungible: params.asset.amount
1533
+ }
1534
+ }
1535
+ ]
1536
+ },
1537
+ "LocalReserve",
1538
+ {
1539
+ [version]: {
1540
+ parents: 0,
1541
+ interior: "Here"
1542
+ }
1543
+ },
1544
+ "LocalReserve",
1545
+ {
1546
+ [version]: [
1547
+ {
1548
+ DepositAsset: {
1549
+ assets: {
1550
+ Wild: { AllCounted: 1 }
1551
+ },
1552
+ beneficiary: {
1553
+ parents: 0,
1554
+ interior: {
1555
+ X1: [
1556
+ getExtrinsicAccount(params.destinationAddress)
1557
+ ]
1558
+ }
1559
+ }
1560
+ }
1561
+ }
1562
+ ]
1563
+ },
1564
+ "Unlimited"
1565
+ ];
1566
+ }
1567
+ })
1568
+ })
1569
+ };
1570
+ }
1571
+ };
1572
+ }
1573
+
1574
+ // src/extrinsic/ExtrinsicBuilder.ts
1575
+ function ExtrinsicBuilder() {
1576
+ return {
1577
+ eqBalances,
1578
+ xTokens,
1579
+ xTransfer,
1580
+ polkadotXcm,
1581
+ xcmPallet
1582
+ };
1583
+ }
1584
+
1585
+ // src/types/substrate/SubstrateCallConfig.ts
1586
+ var SubstrateCallConfig = class _SubstrateCallConfig {
1587
+ api;
1588
+ // biome-ignore lint/suspicious/noExplicitAny: not sure how to fix this
1589
+ call;
1590
+ static is(obj) {
1591
+ return obj instanceof _SubstrateCallConfig;
1592
+ }
1593
+ constructor({ api, call }) {
1594
+ this.api = api;
1595
+ this.call = call;
1596
+ }
1597
+ };
1598
+
1599
+ // src/fee/FeeBuilder.utils.ts
1600
+ var DEFAULT_AMOUNT = 10 ** 6;
1601
+ var DEFAULT_HEX_STRING = "0xabcdef1234567890fedcba0987654321abcdef1234567890fedcba0987654321";
1602
+ var XCM_VERSION = "V4" /* v4 */;
1603
+ function isXcmV42() {
1604
+ return XCM_VERSION === "V4" /* v4 */;
1605
+ }
1606
+ function getWithdrawAssetInstruction(assetTypes) {
1607
+ return {
1608
+ WithdrawAsset: assetTypes.map((assetType) => ({
1609
+ id: { ...assetType },
1610
+ fun: {
1611
+ Fungible: DEFAULT_AMOUNT
1612
+ }
1613
+ }))
1614
+ };
1615
+ }
1616
+ function getReserveAssetDepositedInstruction(assetTypes) {
1617
+ return {
1618
+ ReserveAssetDeposited: assetTypes.map((assetType) => ({
1619
+ id: { ...assetType },
1620
+ fun: {
1621
+ Fungible: DEFAULT_AMOUNT
1622
+ }
1623
+ }))
1624
+ };
1625
+ }
1626
+ function getClearOriginInstruction() {
1627
+ return {
1628
+ ClearOrigin: "NULL"
1629
+ };
1630
+ }
1631
+ function getBuyExecutionInstruction(assetType) {
1632
+ return {
1633
+ BuyExecution: {
1634
+ fees: {
1635
+ id: {
1636
+ ...assetType
1637
+ },
1638
+ fun: {
1639
+ Fungible: DEFAULT_AMOUNT
1640
+ }
1641
+ },
1642
+ weight_limit: {
1643
+ Unlimited: "NULL"
1644
+ }
1645
+ }
1646
+ };
1647
+ }
1648
+ function getDepositAssetInstruction(address, assets3) {
1649
+ const accountKey = {
1650
+ AccountKey20: {
1651
+ key: address,
1652
+ network: null
1653
+ }
1654
+ };
1655
+ return {
1656
+ DepositAsset: {
1657
+ assets: {
1658
+ Wild: {
1659
+ AllCounted: assets3.length
1660
+ }
1661
+ },
1662
+ beneficiary: {
1663
+ interior: {
1664
+ X1: isXcmV42() ? [accountKey] : accountKey
1665
+ },
1666
+ parents: 0
1667
+ },
1668
+ max_assets: 0
1669
+ }
1670
+ };
1671
+ }
1672
+ function getSetTopicInstruction() {
1673
+ return {
1674
+ SetTopic: DEFAULT_HEX_STRING
1675
+ };
1676
+ }
1677
+ function getNativeAssetId(palletInstanceNumber) {
1678
+ if (!palletInstanceNumber) {
1679
+ throw new Error(
1680
+ "No pallet instance configured for the native asset for XcmPaymentApi fee calculation"
1681
+ );
1682
+ }
1683
+ const palletInstance = {
1684
+ PalletInstance: palletInstanceNumber
1685
+ };
1686
+ const id = {
1687
+ interior: {
1688
+ X1: isXcmV42() ? [palletInstance] : palletInstance
1689
+ },
1690
+ parents: "0"
1691
+ };
1692
+ return normalizeConcrete(XCM_VERSION, id);
1693
+ }
1694
+ function getConcreteAssetIdWithAccountKey20(asset, palletInstance) {
1695
+ if (!palletInstance) {
1696
+ throw new Error(
1697
+ `No pallet instance configured for the asset ${asset} for XcmPaymentApi fee calculation`
1698
+ );
1699
+ }
1700
+ const id = {
1701
+ interior: {
1702
+ X2: [
1703
+ {
1704
+ PalletInstance: palletInstance
1705
+ },
1706
+ {
1707
+ AccountKey20: {
1708
+ key: asset,
1709
+ network: null
1710
+ }
1711
+ }
1712
+ ]
1713
+ },
1714
+ parents: "0"
1715
+ };
1716
+ return normalizeConcrete(XCM_VERSION, id);
1717
+ }
1718
+ async function getAssetIdType(api, asset) {
1719
+ const type = await api.query.assetManager.assetIdType(asset);
1720
+ if (type.isNone || !type.unwrap().isXcm) {
1721
+ throw new Error(`No asset type found for asset ${asset}`);
1722
+ }
1723
+ return type;
1724
+ }
1725
+ async function getVersionedAssetId(api, asset, chain) {
1726
+ const assetId = asset.getAssetId();
1727
+ const palletInstance = asset.getAssetPalletInstance();
1728
+ if (assetId === chain.nativeAsset.originSymbol) {
1729
+ return getNativeAssetId(palletInstance);
1730
+ }
1731
+ if (asset.hasOnlyAddress()) {
1732
+ return getConcreteAssetIdWithAccountKey20(asset.address, palletInstance);
1733
+ }
1734
+ const assetType = await getAssetIdType(api, assetId);
1735
+ const assetTypeObject = assetType.unwrap().asXcm.toJSON();
1736
+ const normalizedAssetTypeObject = normalizeX1(XCM_VERSION, assetTypeObject);
1737
+ return normalizeConcrete(XCM_VERSION, normalizedAssetTypeObject);
1738
+ }
1739
+ async function getFeeForXcmInstructionsAndAsset(api, instructions, versionedAssetId) {
1740
+ const xcmToWeightResult = await api.call.xcmPaymentApi.queryXcmWeight({
1741
+ [XCM_VERSION]: instructions
1742
+ });
1743
+ if (!xcmToWeightResult.isOk) {
1744
+ throw new Error(
1745
+ "There was an error trying to get the weight for the xcm instructions (queryXcmWeight)"
1746
+ );
1747
+ }
1748
+ const xcmToWeight = xcmToWeightResult.asOk;
1749
+ const weightToForeignAssets = await api.call.xcmPaymentApi.queryWeightToAssetFee(xcmToWeight, {
1750
+ [XCM_VERSION]: {
1751
+ ...versionedAssetId
1752
+ }
1753
+ });
1754
+ if (!weightToForeignAssets.isOk) {
1755
+ throw new Error(
1756
+ "There was an error trying to get the fee with the weight and asset (weightToForeignAssets)"
1757
+ );
1758
+ }
1759
+ return weightToForeignAssets.asOk.toBigInt();
1760
+ }
1761
+
1762
+ // src/fee/FeeBuilder.ts
1763
+ function FeeBuilder() {
1764
+ return {
1765
+ xcmPaymentApi
1766
+ };
1767
+ }
1768
+ function xcmPaymentApi() {
1769
+ return {
1770
+ xcmPaymentFee: ({
1771
+ isAssetReserveChain,
1772
+ shouldTransferAssetPrecedeFeeAsset = false
1773
+ }) => ({
1774
+ build: ({
1775
+ address,
1776
+ api,
1777
+ asset,
1778
+ destination,
1779
+ feeAsset
1780
+ }) => new SubstrateCallConfig({
1781
+ api,
1782
+ call: async () => {
1783
+ const versionedFeeAssetId = await getVersionedAssetId(
1784
+ api,
1785
+ feeAsset,
1786
+ destination
1787
+ );
1788
+ const versionedTransferAssetId = await getVersionedAssetId(
1789
+ api,
1790
+ asset,
1791
+ destination
1792
+ );
1793
+ const versionedAssets = shouldTransferAssetPrecedeFeeAsset ? [versionedTransferAssetId, versionedFeeAssetId] : [versionedFeeAssetId, versionedTransferAssetId];
1794
+ const assets3 = feeAsset === asset ? [versionedFeeAssetId] : versionedAssets;
1795
+ const instructions = [
1796
+ isAssetReserveChain ? getWithdrawAssetInstruction(assets3) : getReserveAssetDepositedInstruction(assets3),
1797
+ getClearOriginInstruction(),
1798
+ getBuyExecutionInstruction(versionedFeeAssetId),
1799
+ getDepositAssetInstruction(address, assets3),
1800
+ getSetTopicInstruction()
1801
+ ];
1802
+ return getFeeForXcmInstructionsAndAsset(
1803
+ api,
1804
+ instructions,
1805
+ versionedFeeAssetId
1806
+ );
1807
+ }
1808
+ })
1809
+ })
1810
+ };
1811
+ }
1812
+
1813
+ // src/mrl/providers/wormhole/contract/Batch/Batch.ts
1814
+ import {
1815
+ EvmParachain as EvmParachain2
1816
+ } from "@moonbeam-network/xcm-types";
1817
+ import { getMultilocationDerivedAddresses as getMultilocationDerivedAddresses2 } from "@moonbeam-network/xcm-utils";
1818
+ import { evmToAddress as evmToAddress3 } from "@polkadot/util-crypto";
1819
+ import { encodeFunctionData as encodeFunctionData2, maxUint64 } from "viem";
1820
+
1821
+ // src/mrl/providers/wormhole/extrinsic/polkadotXcm/polkadotXcm.ts
1822
+ import {
1823
+ AssetAmount,
1824
+ Parachain
1825
+ } from "@moonbeam-network/xcm-types";
1826
+ import { getMultilocationDerivedAddresses } from "@moonbeam-network/xcm-utils";
1827
+ var BUY_EXECUTION_FEE = 100000000000000000n;
1828
+ var CROSS_CHAIN_FEE = 100000000000000000n;
1829
+ function polkadotXcm2() {
1830
+ return {
1831
+ send: () => ({
1832
+ build: ({
1833
+ asset,
1834
+ destination,
1835
+ destinationAddress,
1836
+ fee,
1837
+ isAutomatic,
1838
+ moonAsset,
1839
+ moonChain,
1840
+ moonApi,
1841
+ sendOnlyRemoteExecution,
1842
+ source,
1843
+ sourceAddress,
1844
+ sourceApi,
1845
+ transact
1846
+ }) => {
1847
+ if (!destination.wh?.name) {
1848
+ throw new Error("Destination chain does not have a wormhole name");
1849
+ }
1850
+ if (!sourceApi) {
1851
+ throw new Error("Source API needs to be defined");
1852
+ }
1853
+ if (!Parachain.is(source)) {
1854
+ throw new Error("Source chain needs to be a parachain");
1855
+ }
1856
+ const { address20: computedOriginAccount } = getMultilocationDerivedAddresses({
1857
+ address: sourceAddress,
1858
+ paraId: source.parachainId,
1859
+ isParents: true
1860
+ });
1861
+ const assetTransferTxs = getAssetTransferTxs({
1862
+ asset,
1863
+ computedOriginAccount,
1864
+ destination,
1865
+ destinationAddress,
1866
+ fee,
1867
+ isAutomatic,
1868
+ moonApi,
1869
+ moonAsset,
1870
+ moonChain,
1871
+ source,
1872
+ sourceAddress,
1873
+ sourceApi
1874
+ });
1875
+ const send = buildSendExtrinsic({
1876
+ asset,
1877
+ destination,
1878
+ destinationAddress,
1879
+ computedOriginAccount,
1880
+ fee,
1881
+ isAutomatic,
1882
+ moonAsset,
1883
+ moonChain,
1884
+ moonApi,
1885
+ source,
1886
+ sourceAddress,
1887
+ sourceApi,
1888
+ transact
1889
+ });
1890
+ const transactionsToSend = sendOnlyRemoteExecution ? [send] : [...assetTransferTxs, send];
1891
+ return new ExtrinsicConfig({
1892
+ module: "utility",
1893
+ func: "batchAll",
1894
+ getArgs: () => [transactionsToSend]
1895
+ });
1896
+ }
1897
+ })
1898
+ };
1899
+ }
1900
+ function buildSendExtrinsic({
1901
+ computedOriginAccount,
1902
+ moonAsset,
1903
+ moonChain,
1904
+ sourceApi,
1905
+ transact
1906
+ }) {
1907
+ if (!transact) {
1908
+ throw new Error("Transact params are required");
1909
+ }
1910
+ return sourceApi.tx.polkadotXcm.send(
1911
+ {
1912
+ // TODO apply XCM versioning
1913
+ V3: {
1914
+ parents: 1,
1915
+ interior: { X1: { Parachain: moonChain.parachainId } }
1916
+ }
1917
+ },
1918
+ {
1919
+ V3: [
1920
+ {
1921
+ WithdrawAsset: [
1922
+ {
1923
+ id: {
1924
+ Concrete: {
1925
+ parents: 0,
1926
+ interior: {
1927
+ X1: {
1928
+ PalletInstance: moonAsset.getAssetPalletInstance()
1929
+ }
1930
+ }
1931
+ }
1932
+ },
1933
+ fun: { Fungible: BUY_EXECUTION_FEE }
1934
+ }
1935
+ ]
1936
+ },
1937
+ {
1938
+ BuyExecution: {
1939
+ fees: {
1940
+ id: {
1941
+ Concrete: {
1942
+ parents: 0,
1943
+ interior: {
1944
+ X1: {
1945
+ PalletInstance: moonAsset.getAssetPalletInstance()
1946
+ }
1947
+ }
1948
+ }
1949
+ },
1950
+ fun: { Fungible: BUY_EXECUTION_FEE }
1951
+ },
1952
+ weightLimit: "Unlimited"
1953
+ }
1954
+ },
1955
+ {
1956
+ Transact: {
1957
+ originKind: "SovereignAccount",
1958
+ requireWeightAtMost: {
1959
+ refTime: transact.txWeight.refTime,
1960
+ proofSize: transact.txWeight.proofSize
1961
+ },
1962
+ call: {
1963
+ encoded: transact.call
1964
+ }
1965
+ }
1966
+ },
1967
+ {
1968
+ SetAppendix: [
1969
+ { RefundSurplus: {} },
1970
+ {
1971
+ DepositAsset: {
1972
+ assets: { Wild: { AllCounted: 1 } },
1973
+ beneficiary: {
1974
+ parents: 0,
1975
+ interior: {
1976
+ X1: { AccountKey20: { key: computedOriginAccount } }
1977
+ }
1978
+ }
1979
+ }
1980
+ }
1981
+ ]
1982
+ }
1983
+ ]
1984
+ }
1985
+ );
1986
+ }
1987
+ function getAssetTransferTxs({
1988
+ asset,
1989
+ computedOriginAccount,
1990
+ fee,
1991
+ moonApi,
1992
+ moonAsset,
1993
+ moonChain,
1994
+ source,
1995
+ sourceAddress,
1996
+ sourceApi
1997
+ }) {
1998
+ const { transfer, transferMulticurrencies } = sourceApi.tx.xTokens;
1999
+ const transferBuilder = ExtrinsicBuilder().xTokens().transfer();
2000
+ const transferMulticurrenciesBuilder = ExtrinsicBuilder().xTokens().transferMultiCurrencies();
2001
+ if (asset.isSame(fee)) {
2002
+ const assetTransferTx = transfer(
2003
+ ...transferBuilder.build({
2004
+ asset: asset.copyWith({
2005
+ // TODO for the moment this is only applicable to peaq, AGNG pays for fees and we have to include the cross chain fee
2006
+ // for this we have to add a new concept in the config (Cross Chain Fee), and get the value from there
2007
+ amount: asset.amount + 10n * CROSS_CHAIN_FEE
2008
+ }),
2009
+ destination: moonChain,
2010
+ destinationAddress: computedOriginAccount,
2011
+ destinationApi: moonApi,
2012
+ fee,
2013
+ source,
2014
+ sourceAddress,
2015
+ sourceApi
2016
+ }).getArgs(transfer)
2017
+ );
2018
+ const feeAssetTransferTx = transfer(
2019
+ ...transferBuilder.build({
2020
+ asset: AssetAmount.fromChainAsset(source.getChainAsset(moonAsset), {
2021
+ amount: CROSS_CHAIN_FEE + BUY_EXECUTION_FEE
2022
+ }),
2023
+ destination: moonChain,
2024
+ destinationAddress: computedOriginAccount,
2025
+ destinationApi: moonApi,
2026
+ fee,
2027
+ source,
2028
+ sourceAddress,
2029
+ sourceApi
2030
+ }).getArgs(transfer)
2031
+ );
2032
+ return [assetTransferTx, feeAssetTransferTx];
2033
+ }
2034
+ const multiCurrenciesTransferTx = transferMulticurrencies(
2035
+ ...transferMulticurrenciesBuilder.build({
2036
+ asset,
2037
+ destination: moonChain,
2038
+ destinationAddress: computedOriginAccount,
2039
+ destinationApi: moonApi,
2040
+ fee: AssetAmount.fromChainAsset(source.getChainAsset(moonAsset), {
2041
+ amount: CROSS_CHAIN_FEE + BUY_EXECUTION_FEE
2042
+ }),
2043
+ source,
2044
+ sourceAddress,
2045
+ sourceApi
2046
+ }).getArgs(transferMulticurrencies)
2047
+ );
2048
+ return [multiCurrenciesTransferTx];
2049
+ }
2050
+
2051
+ // src/mrl/providers/wormhole/contract/Batch/abi/peaq/PeaqBatchContractAbi.ts
2052
+ var PEAQ_BATCH_ABI = [
2053
+ {
2054
+ anonymous: false,
2055
+ inputs: [
2056
+ {
2057
+ indexed: false,
2058
+ internalType: "uint256",
2059
+ name: "index",
2060
+ type: "uint256"
2061
+ }
2062
+ ],
2063
+ name: "SubcallFailed",
2064
+ type: "event"
2065
+ },
2066
+ {
2067
+ anonymous: false,
2068
+ inputs: [
2069
+ {
2070
+ indexed: false,
2071
+ internalType: "uint256",
2072
+ name: "index",
2073
+ type: "uint256"
2074
+ }
2075
+ ],
2076
+ name: "SubcallSucceeded",
2077
+ type: "event"
2078
+ },
2079
+ {
2080
+ inputs: [
2081
+ {
2082
+ internalType: "address[]",
2083
+ name: "to",
2084
+ type: "address[]"
2085
+ },
2086
+ {
2087
+ internalType: "uint256[]",
2088
+ name: "value",
2089
+ type: "uint256[]"
2090
+ },
2091
+ {
2092
+ internalType: "bytes[]",
2093
+ name: "callData",
2094
+ type: "bytes[]"
2095
+ },
2096
+ {
2097
+ internalType: "uint64[]",
2098
+ name: "gasLimit",
2099
+ type: "uint64[]"
2100
+ }
2101
+ ],
2102
+ name: "batchAll",
2103
+ outputs: [],
2104
+ stateMutability: "nonpayable",
2105
+ type: "function"
2106
+ },
2107
+ {
2108
+ inputs: [
2109
+ {
2110
+ internalType: "address[]",
2111
+ name: "to",
2112
+ type: "address[]"
2113
+ },
2114
+ {
2115
+ internalType: "uint256[]",
2116
+ name: "value",
2117
+ type: "uint256[]"
2118
+ },
2119
+ {
2120
+ internalType: "bytes[]",
2121
+ name: "callData",
2122
+ type: "bytes[]"
2123
+ },
2124
+ {
2125
+ internalType: "uint64[]",
2126
+ name: "gasLimit",
2127
+ type: "uint64[]"
2128
+ }
2129
+ ],
2130
+ name: "batchSome",
2131
+ outputs: [],
2132
+ stateMutability: "nonpayable",
2133
+ type: "function"
2134
+ },
2135
+ {
2136
+ inputs: [
2137
+ {
2138
+ internalType: "address[]",
2139
+ name: "to",
2140
+ type: "address[]"
2141
+ },
2142
+ {
2143
+ internalType: "uint256[]",
2144
+ name: "value",
2145
+ type: "uint256[]"
2146
+ },
2147
+ {
2148
+ internalType: "bytes[]",
2149
+ name: "callData",
2150
+ type: "bytes[]"
2151
+ },
2152
+ {
2153
+ internalType: "uint64[]",
2154
+ name: "gasLimit",
2155
+ type: "uint64[]"
2156
+ }
2157
+ ],
2158
+ name: "batchSomeUntilFailure",
2159
+ outputs: [],
2160
+ stateMutability: "nonpayable",
2161
+ type: "function"
2162
+ }
2163
+ ];
2164
+
2165
+ // src/mrl/providers/wormhole/contract/Batch/abi/peaq/PeaqXcmUtilsContractAbi.ts
2166
+ var PEAQ_XCM_UTILS_ABI = [
2167
+ {
2168
+ inputs: [
2169
+ {
2170
+ components: [
2171
+ {
2172
+ internalType: "uint8",
2173
+ name: "parents",
2174
+ type: "uint8"
2175
+ },
2176
+ {
2177
+ internalType: "bytes[]",
2178
+ name: "interior",
2179
+ type: "bytes[]"
2180
+ }
2181
+ ],
2182
+ internalType: "struct XcmUtils.Multilocation",
2183
+ name: "multilocation",
2184
+ type: "tuple"
2185
+ }
2186
+ ],
2187
+ name: "getUnitsPerSecond",
2188
+ outputs: [
2189
+ {
2190
+ internalType: "uint256",
2191
+ name: "unitsPerSecond",
2192
+ type: "uint256"
2193
+ }
2194
+ ],
2195
+ stateMutability: "view",
2196
+ type: "function"
2197
+ },
2198
+ {
2199
+ inputs: [
2200
+ {
2201
+ internalType: "bytes",
2202
+ name: "message",
2203
+ type: "bytes"
2204
+ }
2205
+ ],
2206
+ name: "weightMessage",
2207
+ outputs: [
2208
+ {
2209
+ internalType: "uint64",
2210
+ name: "weight",
2211
+ type: "uint64"
2212
+ }
2213
+ ],
2214
+ stateMutability: "view",
2215
+ type: "function"
2216
+ },
2217
+ {
2218
+ inputs: [
2219
+ {
2220
+ internalType: "bytes",
2221
+ name: "message",
2222
+ type: "bytes"
2223
+ },
2224
+ {
2225
+ internalType: "uint64",
2226
+ name: "maxWeight",
2227
+ type: "uint64"
2228
+ }
2229
+ ],
2230
+ name: "xcmExecute",
2231
+ outputs: [],
2232
+ stateMutability: "nonpayable",
2233
+ type: "function"
2234
+ },
2235
+ {
2236
+ inputs: [
2237
+ {
2238
+ components: [
2239
+ {
2240
+ internalType: "uint8",
2241
+ name: "parents",
2242
+ type: "uint8"
2243
+ },
2244
+ {
2245
+ internalType: "bytes[]",
2246
+ name: "interior",
2247
+ type: "bytes[]"
2248
+ }
2249
+ ],
2250
+ internalType: "struct XcmUtils.Multilocation",
2251
+ name: "dest",
2252
+ type: "tuple"
2253
+ },
2254
+ {
2255
+ internalType: "bytes",
2256
+ name: "message",
2257
+ type: "bytes"
2258
+ }
2259
+ ],
2260
+ name: "xcmSend",
2261
+ outputs: [],
2262
+ stateMutability: "nonpayable",
2263
+ type: "function"
2264
+ }
2265
+ ];
2266
+
2267
+ // src/mrl/providers/wormhole/contract/Batch/abi/peaq/PeaqXtokensContractAbi.ts
2268
+ var PEAQ_XTOKENS_ABI = [
2269
+ {
2270
+ inputs: [
2271
+ {
2272
+ internalType: "address",
2273
+ name: "currencyAddress",
2274
+ type: "address"
2275
+ },
2276
+ {
2277
+ internalType: "uint256",
2278
+ name: "amount",
2279
+ type: "uint256"
2280
+ },
2281
+ {
2282
+ components: [
2283
+ {
2284
+ internalType: "uint8",
2285
+ name: "parents",
2286
+ type: "uint8"
2287
+ },
2288
+ {
2289
+ internalType: "bytes[]",
2290
+ name: "interior",
2291
+ type: "bytes[]"
2292
+ }
2293
+ ],
2294
+ internalType: "struct Xtokens.Multilocation",
2295
+ name: "destination",
2296
+ type: "tuple"
2297
+ },
2298
+ {
2299
+ internalType: "uint64",
2300
+ name: "weight",
2301
+ type: "uint64"
2302
+ }
2303
+ ],
2304
+ name: "transfer",
2305
+ outputs: [],
2306
+ stateMutability: "nonpayable",
2307
+ type: "function"
2308
+ },
2309
+ {
2310
+ inputs: [
2311
+ {
2312
+ components: [
2313
+ {
2314
+ components: [
2315
+ {
2316
+ internalType: "uint8",
2317
+ name: "parents",
2318
+ type: "uint8"
2319
+ },
2320
+ {
2321
+ internalType: "bytes[]",
2322
+ name: "interior",
2323
+ type: "bytes[]"
2324
+ }
2325
+ ],
2326
+ internalType: "struct Xtokens.Multilocation",
2327
+ name: "location",
2328
+ type: "tuple"
2329
+ },
2330
+ {
2331
+ internalType: "uint256",
2332
+ name: "amount",
2333
+ type: "uint256"
2334
+ }
2335
+ ],
2336
+ internalType: "struct Xtokens.MultiAsset[]",
2337
+ name: "assets",
2338
+ type: "tuple[]"
2339
+ },
2340
+ {
2341
+ internalType: "uint32",
2342
+ name: "feeItem",
2343
+ type: "uint32"
2344
+ },
2345
+ {
2346
+ components: [
2347
+ {
2348
+ internalType: "uint8",
2349
+ name: "parents",
2350
+ type: "uint8"
2351
+ },
2352
+ {
2353
+ internalType: "bytes[]",
2354
+ name: "interior",
2355
+ type: "bytes[]"
2356
+ }
2357
+ ],
2358
+ internalType: "struct Xtokens.Multilocation",
2359
+ name: "destination",
2360
+ type: "tuple"
2361
+ },
2362
+ {
2363
+ internalType: "uint64",
2364
+ name: "weight",
2365
+ type: "uint64"
2366
+ }
2367
+ ],
2368
+ name: "transferMultiAssets",
2369
+ outputs: [],
2370
+ stateMutability: "nonpayable",
2371
+ type: "function"
2372
+ },
2373
+ {
2374
+ inputs: [
2375
+ {
2376
+ components: [
2377
+ {
2378
+ internalType: "address",
2379
+ name: "currencyAddress",
2380
+ type: "address"
2381
+ },
2382
+ {
2383
+ internalType: "uint256",
2384
+ name: "amount",
2385
+ type: "uint256"
2386
+ }
2387
+ ],
2388
+ internalType: "struct Xtokens.Currency[]",
2389
+ name: "currencies",
2390
+ type: "tuple[]"
2391
+ },
2392
+ {
2393
+ internalType: "uint32",
2394
+ name: "feeItem",
2395
+ type: "uint32"
2396
+ },
2397
+ {
2398
+ components: [
2399
+ {
2400
+ internalType: "uint8",
2401
+ name: "parents",
2402
+ type: "uint8"
2403
+ },
2404
+ {
2405
+ internalType: "bytes[]",
2406
+ name: "interior",
2407
+ type: "bytes[]"
2408
+ }
2409
+ ],
2410
+ internalType: "struct Xtokens.Multilocation",
2411
+ name: "destination",
2412
+ type: "tuple"
2413
+ },
2414
+ {
2415
+ internalType: "uint64",
2416
+ name: "weight",
2417
+ type: "uint64"
2418
+ }
2419
+ ],
2420
+ name: "transferMultiCurrencies",
2421
+ outputs: [],
2422
+ stateMutability: "nonpayable",
2423
+ type: "function"
2424
+ },
2425
+ {
2426
+ inputs: [
2427
+ {
2428
+ components: [
2429
+ {
2430
+ internalType: "uint8",
2431
+ name: "parents",
2432
+ type: "uint8"
2433
+ },
2434
+ {
2435
+ internalType: "bytes[]",
2436
+ name: "interior",
2437
+ type: "bytes[]"
2438
+ }
2439
+ ],
2440
+ internalType: "struct Xtokens.Multilocation",
2441
+ name: "asset",
2442
+ type: "tuple"
2443
+ },
2444
+ {
2445
+ internalType: "uint256",
2446
+ name: "amount",
2447
+ type: "uint256"
2448
+ },
2449
+ {
2450
+ components: [
2451
+ {
2452
+ internalType: "uint8",
2453
+ name: "parents",
2454
+ type: "uint8"
2455
+ },
2456
+ {
2457
+ internalType: "bytes[]",
2458
+ name: "interior",
2459
+ type: "bytes[]"
2460
+ }
2461
+ ],
2462
+ internalType: "struct Xtokens.Multilocation",
2463
+ name: "destination",
2464
+ type: "tuple"
2465
+ },
2466
+ {
2467
+ internalType: "uint64",
2468
+ name: "weight",
2469
+ type: "uint64"
2470
+ }
2471
+ ],
2472
+ name: "transferMultiasset",
2473
+ outputs: [],
2474
+ stateMutability: "nonpayable",
2475
+ type: "function"
2476
+ },
2477
+ {
2478
+ inputs: [
2479
+ {
2480
+ components: [
2481
+ {
2482
+ internalType: "uint8",
2483
+ name: "parents",
2484
+ type: "uint8"
2485
+ },
2486
+ {
2487
+ internalType: "bytes[]",
2488
+ name: "interior",
2489
+ type: "bytes[]"
2490
+ }
2491
+ ],
2492
+ internalType: "struct Xtokens.Multilocation",
2493
+ name: "asset",
2494
+ type: "tuple"
2495
+ },
2496
+ {
2497
+ internalType: "uint256",
2498
+ name: "amount",
2499
+ type: "uint256"
2500
+ },
2501
+ {
2502
+ internalType: "uint256",
2503
+ name: "fee",
2504
+ type: "uint256"
2505
+ },
2506
+ {
2507
+ components: [
2508
+ {
2509
+ internalType: "uint8",
2510
+ name: "parents",
2511
+ type: "uint8"
2512
+ },
2513
+ {
2514
+ internalType: "bytes[]",
2515
+ name: "interior",
2516
+ type: "bytes[]"
2517
+ }
2518
+ ],
2519
+ internalType: "struct Xtokens.Multilocation",
2520
+ name: "destination",
2521
+ type: "tuple"
2522
+ },
2523
+ {
2524
+ internalType: "uint64",
2525
+ name: "weight",
2526
+ type: "uint64"
2527
+ }
2528
+ ],
2529
+ name: "transferMultiassetWithFee",
2530
+ outputs: [],
2531
+ stateMutability: "nonpayable",
2532
+ type: "function"
2533
+ },
2534
+ {
2535
+ inputs: [
2536
+ {
2537
+ internalType: "address",
2538
+ name: "currencyAddress",
2539
+ type: "address"
2540
+ },
2541
+ {
2542
+ internalType: "uint256",
2543
+ name: "amount",
2544
+ type: "uint256"
2545
+ },
2546
+ {
2547
+ internalType: "uint256",
2548
+ name: "fee",
2549
+ type: "uint256"
2550
+ },
2551
+ {
2552
+ components: [
2553
+ {
2554
+ internalType: "uint8",
2555
+ name: "parents",
2556
+ type: "uint8"
2557
+ },
2558
+ {
2559
+ internalType: "bytes[]",
2560
+ name: "interior",
2561
+ type: "bytes[]"
2562
+ }
2563
+ ],
2564
+ internalType: "struct Xtokens.Multilocation",
2565
+ name: "destination",
2566
+ type: "tuple"
2567
+ },
2568
+ {
2569
+ internalType: "uint64",
2570
+ name: "weight",
2571
+ type: "uint64"
2572
+ }
2573
+ ],
2574
+ name: "transferWithFee",
2575
+ outputs: [],
2576
+ stateMutability: "nonpayable",
2577
+ type: "function"
2578
+ }
2579
+ ];
2580
+
2581
+ // src/mrl/providers/wormhole/contract/Batch/abi/abi.helpers.ts
2582
+ function getAbisForChain(chain) {
2583
+ return {
2584
+ BatchAbi: PEAQ_BATCH_ABI,
2585
+ XcmUtilsAbi: PEAQ_XCM_UTILS_ABI,
2586
+ XtokensAbi: PEAQ_XTOKENS_ABI
2587
+ };
2588
+ }
2589
+
2590
+ // src/mrl/providers/wormhole/contract/Batch/Batch.ts
2591
+ var module = "Batch";
2592
+ function Batch() {
2593
+ return {
2594
+ transferAssetsAndMessage: () => ({
2595
+ build: ({
2596
+ asset,
2597
+ destination,
2598
+ destinationAddress,
2599
+ fee,
2600
+ isAutomatic,
2601
+ moonAsset,
2602
+ moonChain,
2603
+ moonApi,
2604
+ source,
2605
+ sourceAddress,
2606
+ sourceApi,
2607
+ transact
2608
+ }) => {
2609
+ if (!EvmParachain2.is(source)) {
2610
+ throw new Error("Source chain needs to be an EVMParachain");
2611
+ }
2612
+ if (!sourceApi) {
2613
+ throw new Error("Source API needs to be defined");
2614
+ }
2615
+ if (!source.contracts?.Xtokens || !source.contracts?.XcmUtils || !source.contracts?.Batch) {
2616
+ throw new Error(
2617
+ "Source chain needs to have the Xtokens, XcmUtils and Batch contract addresses configured"
2618
+ );
2619
+ }
2620
+ const subMappedAddress = evmToAddress3(sourceAddress);
2621
+ const { BatchAbi, XcmUtilsAbi, XtokensAbi } = getAbisForChain(source);
2622
+ const { address20: computedOriginAccount } = getMultilocationDerivedAddresses2({
2623
+ address: subMappedAddress,
2624
+ paraId: source.parachainId,
2625
+ isParents: true
2626
+ });
2627
+ const send = buildSendExtrinsic({
2628
+ asset,
2629
+ destination,
2630
+ destinationAddress,
2631
+ computedOriginAccount,
2632
+ fee,
2633
+ isAutomatic,
2634
+ moonAsset,
2635
+ moonChain,
2636
+ moonApi,
2637
+ source,
2638
+ sourceAddress,
2639
+ sourceApi,
2640
+ transact
2641
+ });
2642
+ const encodedXcmMessage = send.args[1].toHex();
2643
+ const { destinationParachain, destinationParachainAndAddress } = getDestinationInHex(moonChain, computedOriginAccount);
2644
+ const { currencies, feeItem } = getCurrencies({
2645
+ source,
2646
+ moonAsset,
2647
+ asset
2648
+ });
2649
+ const weight = maxUint64;
2650
+ const multiTransferTxData = encodeFunctionData2({
2651
+ abi: XtokensAbi,
2652
+ functionName: "transferMultiCurrencies",
2653
+ args: [currencies, feeItem, destinationParachainAndAddress, weight]
2654
+ });
2655
+ const xcmSendTxData = encodeFunctionData2({
2656
+ abi: XcmUtilsAbi,
2657
+ functionName: "xcmSend",
2658
+ args: [destinationParachain, encodedXcmMessage]
2659
+ });
2660
+ return new ContractConfig({
2661
+ address: source.contracts.Batch,
2662
+ abi: BatchAbi,
2663
+ args: [
2664
+ [source.contracts.Xtokens, source.contracts.XcmUtils],
2665
+ [],
2666
+ [multiTransferTxData, xcmSendTxData],
2667
+ []
2668
+ ],
2669
+ func: "batchAll",
2670
+ module
2671
+ });
2672
+ }
2673
+ })
2674
+ };
2675
+ }
2676
+ function getDestinationInHex(moonChain, computedOriginAccount) {
2677
+ const destinationParachain = {
2678
+ parents: 1,
2679
+ interior: getPrecompileDestinationInterior(moonChain)
2680
+ };
2681
+ const destinationParachainAndAddress = {
2682
+ parents: 1,
2683
+ interior: getPrecompileDestinationInterior(
2684
+ moonChain,
2685
+ computedOriginAccount
2686
+ )
2687
+ };
2688
+ return {
2689
+ destinationParachain,
2690
+ destinationParachainAndAddress
2691
+ };
2692
+ }
2693
+ function getCurrencies({ source, moonAsset, asset }) {
2694
+ const currencies = [
2695
+ {
2696
+ currencyAddress: source.getChainAsset(moonAsset).address,
2697
+ amount: CROSS_CHAIN_FEE
2698
+ },
2699
+ {
2700
+ currencyAddress: asset.address,
2701
+ amount: asset.amount
2702
+ }
2703
+ ];
2704
+ const feeItem = 0;
2705
+ return { currencies, feeItem };
2706
+ }
2707
+
2708
+ // src/mrl/providers/wormhole/contract/Gmp/Gmp.ts
2709
+ import { u8aToHex as u8aToHex4 } from "@polkadot/util";
2710
+
2711
+ // src/mrl/providers/wormhole/contract/Gmp/GmpAbi.ts
2712
+ var GMP_ABI = [
2713
+ {
2714
+ inputs: [
2715
+ {
2716
+ internalType: "bytes",
2717
+ name: "vaa",
2718
+ type: "bytes"
2719
+ }
2720
+ ],
2721
+ name: "wormholeTransferERC20",
2722
+ outputs: [],
2723
+ stateMutability: "nonpayable",
2724
+ type: "function"
2725
+ }
2726
+ ];
2727
+
2728
+ // src/mrl/providers/wormhole/contract/Gmp/Gmp.ts
2729
+ var module2 = "GMP";
2730
+ var GMP_CONTRACT_ADDRESS = "0x0000000000000000000000000000000000000816";
2731
+ function Gmp() {
2732
+ return {
2733
+ wormholeTransferERC20: () => ({
2734
+ build: ({ bytes }) => {
2735
+ const hex = u8aToHex4(bytes);
2736
+ return new ContractConfig({
2737
+ address: GMP_CONTRACT_ADDRESS,
2738
+ abi: GMP_ABI,
2739
+ args: [hex],
2740
+ func: "wormholeTransferERC20",
2741
+ module: module2
2742
+ });
2743
+ }
2744
+ })
2745
+ };
2746
+ }
2747
+
2748
+ // src/mrl/providers/wormhole/contract/TokenBridge/TokenBridge.ts
2749
+ import { convertAddressTo32Bytes } from "@moonbeam-network/xcm-utils";
2750
+
2751
+ // src/mrl/providers/wormhole/wormhole/wormhole.ts
2752
+ import { EvmChain, EvmParachain as EvmParachain3, Parachain as Parachain2 } from "@moonbeam-network/xcm-types";
2753
+ import { getMultilocationDerivedAddresses as getMultilocationDerivedAddresses3 } from "@moonbeam-network/xcm-utils";
2754
+ import { evmToAddress as evmToAddress4 } from "@polkadot/util-crypto/address";
2755
+ import { Wormhole as Wormhole2 } from "@wormhole-foundation/sdk-connect";
2756
+
2757
+ // src/mrl/providers/wormhole/wormhole/WormholeConfig.ts
2758
+ var WormholeConfig = class _WormholeConfig {
2759
+ args;
2760
+ func;
2761
+ static is(obj) {
2762
+ return obj instanceof _WormholeConfig;
2763
+ }
2764
+ constructor({ args, func }) {
2765
+ this.args = args;
2766
+ this.func = func;
2767
+ }
2768
+ };
2769
+
2770
+ // src/mrl/providers/wormhole/wormhole/wormholeFactory.ts
2771
+ import { Wormhole } from "@wormhole-foundation/sdk-connect";
2772
+ import { EvmPlatform } from "@wormhole-foundation/sdk-evm";
2773
+ function wormholeFactory(chain) {
2774
+ return new Wormhole(chain.isTestChain ? "Testnet" : "Mainnet", [EvmPlatform]);
2775
+ }
2776
+
2777
+ // src/mrl/providers/wormhole/wormhole/wormhole.ts
2778
+ function wormhole() {
2779
+ return {
2780
+ tokenTransfer: () => ({
2781
+ build: ({
2782
+ asset,
2783
+ destination,
2784
+ destinationAddress,
2785
+ isAutomatic,
2786
+ moonApi,
2787
+ moonChain,
2788
+ source,
2789
+ sourceAddress
2790
+ }) => {
2791
+ const isSourceParachain = Parachain2.is(source);
2792
+ const isDestinationMoonChain = destination.isEqual(moonChain);
2793
+ const isDestinationEvmChain = EvmChain.is(destination);
2794
+ const isNativeAsset = asset.isSame(
2795
+ isDestinationEvmChain ? moonChain.nativeAsset : source.nativeAsset
2796
+ );
2797
+ const tokenAddress = isNativeAsset ? "native" : isDestinationEvmChain ? moonChain.getChainAsset(asset).address : asset.address;
2798
+ const { address20: computedOriginAccount } = getMultilocationDerivedAddresses3({
2799
+ address: sourceAddress,
2800
+ paraId: isSourceParachain ? source.parachainId : void 0,
2801
+ isParents: true
2802
+ });
2803
+ if (!tokenAddress) {
2804
+ throw new Error(`Asset ${asset.key} has no address`);
2805
+ }
2806
+ const wh = wormholeFactory(source);
2807
+ const whSource = isDestinationEvmChain ? wh.getChain(moonChain.getWormholeName()) : wh.getChain(source.getWormholeName());
2808
+ const whDestination = isDestinationEvmChain ? wh.getChain(destination.getWormholeName()) : wh.getChain(moonChain.getWormholeName());
2809
+ const whAsset = Wormhole2.tokenId(whSource.chain, tokenAddress);
2810
+ const whSourceAddress = Wormhole2.chainAddress(
2811
+ whSource.chain,
2812
+ isDestinationEvmChain ? computedOriginAccount : sourceAddress
2813
+ );
2814
+ const whDestinationAddress = Wormhole2.chainAddress(
2815
+ whDestination.chain,
2816
+ isDestinationMoonChain || isDestinationEvmChain ? destinationAddress : GMP_CONTRACT_ADDRESS
2817
+ );
2818
+ return new WormholeConfig({
2819
+ args: [
2820
+ whAsset,
2821
+ asset.amount,
2822
+ whSourceAddress,
2823
+ whDestinationAddress,
2824
+ isAutomatic,
2825
+ isDestinationMoonChain || isDestinationEvmChain ? void 0 : getPayload({ destination, destinationAddress, moonApi })
2826
+ ],
2827
+ func: "tokenTransfer"
2828
+ });
2829
+ }
2830
+ })
2831
+ };
2832
+ }
2833
+ function getPayload({
2834
+ moonApi,
2835
+ destination,
2836
+ destinationAddress
2837
+ }) {
2838
+ if (!EvmParachain3.isAnyParachain(destination)) {
2839
+ throw new Error(
2840
+ `Destination ${destination.name} is not a Parachain or EvmParachain`
2841
+ );
2842
+ }
2843
+ const isPeaqEvm = destination.key === "peaq-evm-Alphanet" || destination.key === "peaq-evm";
2844
+ const multilocation = moonApi.createType("XcmVersionedLocation", {
2845
+ V3: {
2846
+ parents: 1,
2847
+ interior: {
2848
+ X2: [
2849
+ {
2850
+ Parachain: destination.parachainId
2851
+ },
2852
+ getExtrinsicAccount(
2853
+ isPeaqEvm ? evmToAddress4(destinationAddress) : destinationAddress
2854
+ )
2855
+ ]
2856
+ }
2857
+ }
2858
+ });
2859
+ const action = moonApi.createType("XcmRoutingUserAction", {
2860
+ destination: multilocation
2861
+ });
2862
+ const versioned = moonApi.createType("VersionedUserAction", {
2863
+ V1: action
2864
+ });
2865
+ return versioned.toU8a();
2866
+ }
2867
+
2868
+ // src/mrl/providers/wormhole/contract/TokenBridge/TokenBridgeAbi.ts
2869
+ var TOKEN_BRIDGE_ABI = [
2870
+ {
2871
+ anonymous: false,
2872
+ inputs: [
2873
+ {
2874
+ indexed: false,
2875
+ internalType: "address",
2876
+ name: "previousAdmin",
2877
+ type: "address"
2878
+ },
2879
+ {
2880
+ indexed: false,
2881
+ internalType: "address",
2882
+ name: "newAdmin",
2883
+ type: "address"
2884
+ }
2885
+ ],
2886
+ name: "AdminChanged",
2887
+ type: "event"
2888
+ },
2889
+ {
2890
+ anonymous: false,
2891
+ inputs: [
2892
+ {
2893
+ indexed: true,
2894
+ internalType: "address",
2895
+ name: "beacon",
2896
+ type: "address"
2897
+ }
2898
+ ],
2899
+ name: "BeaconUpgraded",
2900
+ type: "event"
2901
+ },
2902
+ {
2903
+ anonymous: false,
2904
+ inputs: [
2905
+ {
2906
+ indexed: true,
2907
+ internalType: "address",
2908
+ name: "oldContract",
2909
+ type: "address"
2910
+ },
2911
+ {
2912
+ indexed: true,
2913
+ internalType: "address",
2914
+ name: "newContract",
2915
+ type: "address"
2916
+ }
2917
+ ],
2918
+ name: "ContractUpgraded",
2919
+ type: "event"
2920
+ },
2921
+ {
2922
+ anonymous: false,
2923
+ inputs: [
2924
+ {
2925
+ indexed: true,
2926
+ internalType: "address",
2927
+ name: "implementation",
2928
+ type: "address"
2929
+ }
2930
+ ],
2931
+ name: "Upgraded",
2932
+ type: "event"
2933
+ },
2934
+ {
2935
+ inputs: [],
2936
+ name: "WETH",
2937
+ outputs: [
2938
+ {
2939
+ internalType: "contract IWETH",
2940
+ name: "",
2941
+ type: "address"
2942
+ }
2943
+ ],
2944
+ stateMutability: "view",
2945
+ type: "function"
2946
+ },
2947
+ {
2948
+ inputs: [
2949
+ {
2950
+ internalType: "uint16",
2951
+ name: "chainId_",
2952
+ type: "uint16"
2953
+ }
2954
+ ],
2955
+ name: "bridgeContracts",
2956
+ outputs: [
2957
+ {
2958
+ internalType: "bytes32",
2959
+ name: "",
2960
+ type: "bytes32"
2961
+ }
2962
+ ],
2963
+ stateMutability: "view",
2964
+ type: "function"
2965
+ },
2966
+ {
2967
+ inputs: [],
2968
+ name: "chainId",
2969
+ outputs: [
2970
+ {
2971
+ internalType: "uint16",
2972
+ name: "",
2973
+ type: "uint16"
2974
+ }
2975
+ ],
2976
+ stateMutability: "view",
2977
+ type: "function"
2978
+ },
2979
+ {
2980
+ inputs: [],
2981
+ name: "evmChainId",
2982
+ outputs: [
2983
+ {
2984
+ internalType: "uint256",
2985
+ name: "",
2986
+ type: "uint256"
2987
+ }
2988
+ ],
2989
+ stateMutability: "view",
2990
+ type: "function"
2991
+ },
2992
+ {
2993
+ inputs: [],
2994
+ name: "finality",
2995
+ outputs: [
2996
+ {
2997
+ internalType: "uint8",
2998
+ name: "",
2999
+ type: "uint8"
3000
+ }
3001
+ ],
3002
+ stateMutability: "view",
3003
+ type: "function"
3004
+ },
3005
+ {
3006
+ inputs: [
3007
+ {
3008
+ internalType: "bytes32",
3009
+ name: "hash",
3010
+ type: "bytes32"
3011
+ }
3012
+ ],
3013
+ name: "governanceActionIsConsumed",
3014
+ outputs: [
3015
+ {
3016
+ internalType: "bool",
3017
+ name: "",
3018
+ type: "bool"
3019
+ }
3020
+ ],
3021
+ stateMutability: "view",
3022
+ type: "function"
3023
+ },
3024
+ {
3025
+ inputs: [],
3026
+ name: "governanceChainId",
3027
+ outputs: [
3028
+ {
3029
+ internalType: "uint16",
3030
+ name: "",
3031
+ type: "uint16"
3032
+ }
3033
+ ],
3034
+ stateMutability: "view",
3035
+ type: "function"
3036
+ },
3037
+ {
3038
+ inputs: [],
3039
+ name: "governanceContract",
3040
+ outputs: [
3041
+ {
3042
+ internalType: "bytes32",
3043
+ name: "",
3044
+ type: "bytes32"
3045
+ }
3046
+ ],
3047
+ stateMutability: "view",
3048
+ type: "function"
3049
+ },
3050
+ {
3051
+ inputs: [],
3052
+ name: "isFork",
3053
+ outputs: [
3054
+ {
3055
+ internalType: "bool",
3056
+ name: "",
3057
+ type: "bool"
3058
+ }
3059
+ ],
3060
+ stateMutability: "view",
3061
+ type: "function"
3062
+ },
3063
+ {
3064
+ inputs: [
3065
+ {
3066
+ internalType: "address",
3067
+ name: "impl",
3068
+ type: "address"
3069
+ }
3070
+ ],
3071
+ name: "isInitialized",
3072
+ outputs: [
3073
+ {
3074
+ internalType: "bool",
3075
+ name: "",
3076
+ type: "bool"
3077
+ }
3078
+ ],
3079
+ stateMutability: "view",
3080
+ type: "function"
3081
+ },
3082
+ {
3083
+ inputs: [
3084
+ {
3085
+ internalType: "bytes32",
3086
+ name: "hash",
3087
+ type: "bytes32"
3088
+ }
3089
+ ],
3090
+ name: "isTransferCompleted",
3091
+ outputs: [
3092
+ {
3093
+ internalType: "bool",
3094
+ name: "",
3095
+ type: "bool"
3096
+ }
3097
+ ],
3098
+ stateMutability: "view",
3099
+ type: "function"
3100
+ },
3101
+ {
3102
+ inputs: [
3103
+ {
3104
+ internalType: "address",
3105
+ name: "token",
3106
+ type: "address"
3107
+ }
3108
+ ],
3109
+ name: "isWrappedAsset",
3110
+ outputs: [
3111
+ {
3112
+ internalType: "bool",
3113
+ name: "",
3114
+ type: "bool"
3115
+ }
3116
+ ],
3117
+ stateMutability: "view",
3118
+ type: "function"
3119
+ },
3120
+ {
3121
+ inputs: [
3122
+ {
3123
+ internalType: "address",
3124
+ name: "token",
3125
+ type: "address"
3126
+ }
3127
+ ],
3128
+ name: "outstandingBridged",
3129
+ outputs: [
3130
+ {
3131
+ internalType: "uint256",
3132
+ name: "",
3133
+ type: "uint256"
3134
+ }
3135
+ ],
3136
+ stateMutability: "view",
3137
+ type: "function"
3138
+ },
3139
+ {
3140
+ inputs: [
3141
+ {
3142
+ internalType: "bytes",
3143
+ name: "encodedRecoverChainId",
3144
+ type: "bytes"
3145
+ }
3146
+ ],
3147
+ name: "parseRecoverChainId",
3148
+ outputs: [
3149
+ {
3150
+ components: [
3151
+ {
3152
+ internalType: "bytes32",
3153
+ name: "module",
3154
+ type: "bytes32"
3155
+ },
3156
+ {
3157
+ internalType: "uint8",
3158
+ name: "action",
3159
+ type: "uint8"
3160
+ },
3161
+ {
3162
+ internalType: "uint256",
3163
+ name: "evmChainId",
3164
+ type: "uint256"
3165
+ },
3166
+ {
3167
+ internalType: "uint16",
3168
+ name: "newChainId",
3169
+ type: "uint16"
3170
+ }
3171
+ ],
3172
+ internalType: "struct BridgeStructs.RecoverChainId",
3173
+ name: "rci",
3174
+ type: "tuple"
3175
+ }
3176
+ ],
3177
+ stateMutability: "pure",
3178
+ type: "function"
3179
+ },
3180
+ {
3181
+ inputs: [
3182
+ {
3183
+ internalType: "bytes",
3184
+ name: "encoded",
3185
+ type: "bytes"
3186
+ }
3187
+ ],
3188
+ name: "parseRegisterChain",
3189
+ outputs: [
3190
+ {
3191
+ components: [
3192
+ {
3193
+ internalType: "bytes32",
3194
+ name: "module",
3195
+ type: "bytes32"
3196
+ },
3197
+ {
3198
+ internalType: "uint8",
3199
+ name: "action",
3200
+ type: "uint8"
3201
+ },
3202
+ {
3203
+ internalType: "uint16",
3204
+ name: "chainId",
3205
+ type: "uint16"
3206
+ },
3207
+ {
3208
+ internalType: "uint16",
3209
+ name: "emitterChainID",
3210
+ type: "uint16"
3211
+ },
3212
+ {
3213
+ internalType: "bytes32",
3214
+ name: "emitterAddress",
3215
+ type: "bytes32"
3216
+ }
3217
+ ],
3218
+ internalType: "struct BridgeStructs.RegisterChain",
3219
+ name: "chain",
3220
+ type: "tuple"
3221
+ }
3222
+ ],
3223
+ stateMutability: "pure",
3224
+ type: "function"
3225
+ },
3226
+ {
3227
+ inputs: [
3228
+ {
3229
+ internalType: "bytes",
3230
+ name: "encoded",
3231
+ type: "bytes"
3232
+ }
3233
+ ],
3234
+ name: "parseUpgrade",
3235
+ outputs: [
3236
+ {
3237
+ components: [
3238
+ {
3239
+ internalType: "bytes32",
3240
+ name: "module",
3241
+ type: "bytes32"
3242
+ },
3243
+ {
3244
+ internalType: "uint8",
3245
+ name: "action",
3246
+ type: "uint8"
3247
+ },
3248
+ {
3249
+ internalType: "uint16",
3250
+ name: "chainId",
3251
+ type: "uint16"
3252
+ },
3253
+ {
3254
+ internalType: "bytes32",
3255
+ name: "newContract",
3256
+ type: "bytes32"
3257
+ }
3258
+ ],
3259
+ internalType: "struct BridgeStructs.UpgradeContract",
3260
+ name: "chain",
3261
+ type: "tuple"
3262
+ }
3263
+ ],
3264
+ stateMutability: "pure",
3265
+ type: "function"
3266
+ },
3267
+ {
3268
+ inputs: [
3269
+ {
3270
+ internalType: "bytes",
3271
+ name: "encodedVM",
3272
+ type: "bytes"
3273
+ }
3274
+ ],
3275
+ name: "registerChain",
3276
+ outputs: [],
3277
+ stateMutability: "nonpayable",
3278
+ type: "function"
3279
+ },
3280
+ {
3281
+ inputs: [
3282
+ {
3283
+ internalType: "bytes",
3284
+ name: "encodedVM",
3285
+ type: "bytes"
3286
+ }
3287
+ ],
3288
+ name: "submitRecoverChainId",
3289
+ outputs: [],
3290
+ stateMutability: "nonpayable",
3291
+ type: "function"
3292
+ },
3293
+ {
3294
+ inputs: [],
3295
+ name: "tokenImplementation",
3296
+ outputs: [
3297
+ {
3298
+ internalType: "address",
3299
+ name: "",
3300
+ type: "address"
3301
+ }
3302
+ ],
3303
+ stateMutability: "view",
3304
+ type: "function"
3305
+ },
3306
+ {
3307
+ inputs: [
3308
+ {
3309
+ internalType: "bytes",
3310
+ name: "encodedVM",
3311
+ type: "bytes"
3312
+ }
3313
+ ],
3314
+ name: "upgrade",
3315
+ outputs: [],
3316
+ stateMutability: "nonpayable",
3317
+ type: "function"
3318
+ },
3319
+ {
3320
+ inputs: [],
3321
+ name: "wormhole",
3322
+ outputs: [
3323
+ {
3324
+ internalType: "contract IWormhole",
3325
+ name: "",
3326
+ type: "address"
3327
+ }
3328
+ ],
3329
+ stateMutability: "view",
3330
+ type: "function"
3331
+ },
3332
+ {
3333
+ inputs: [
3334
+ {
3335
+ internalType: "uint16",
3336
+ name: "tokenChainId",
3337
+ type: "uint16"
3338
+ },
3339
+ {
3340
+ internalType: "bytes32",
3341
+ name: "tokenAddress",
3342
+ type: "bytes32"
3343
+ }
3344
+ ],
3345
+ name: "wrappedAsset",
3346
+ outputs: [
3347
+ {
3348
+ internalType: "address",
3349
+ name: "",
3350
+ type: "address"
3351
+ }
3352
+ ],
3353
+ stateMutability: "view",
3354
+ type: "function"
3355
+ },
3356
+ {
3357
+ stateMutability: "payable",
3358
+ type: "receive"
3359
+ },
3360
+ {
3361
+ inputs: [
3362
+ {
3363
+ internalType: "address",
3364
+ name: "tokenAddress",
3365
+ type: "address"
3366
+ },
3367
+ {
3368
+ internalType: "uint32",
3369
+ name: "nonce",
3370
+ type: "uint32"
3371
+ }
3372
+ ],
3373
+ name: "attestToken",
3374
+ outputs: [
3375
+ {
3376
+ internalType: "uint64",
3377
+ name: "sequence",
3378
+ type: "uint64"
3379
+ }
3380
+ ],
3381
+ stateMutability: "payable",
3382
+ type: "function"
3383
+ },
3384
+ {
3385
+ inputs: [
3386
+ {
3387
+ internalType: "uint16",
3388
+ name: "recipientChain",
3389
+ type: "uint16"
3390
+ },
3391
+ {
3392
+ internalType: "bytes32",
3393
+ name: "recipient",
3394
+ type: "bytes32"
3395
+ },
3396
+ {
3397
+ internalType: "uint256",
3398
+ name: "arbiterFee",
3399
+ type: "uint256"
3400
+ },
3401
+ {
3402
+ internalType: "uint32",
3403
+ name: "nonce",
3404
+ type: "uint32"
3405
+ }
3406
+ ],
3407
+ name: "wrapAndTransferETH",
3408
+ outputs: [
3409
+ {
3410
+ internalType: "uint64",
3411
+ name: "sequence",
3412
+ type: "uint64"
3413
+ }
3414
+ ],
3415
+ stateMutability: "payable",
3416
+ type: "function"
3417
+ },
3418
+ {
3419
+ inputs: [
3420
+ {
3421
+ internalType: "uint16",
3422
+ name: "recipientChain",
3423
+ type: "uint16"
3424
+ },
3425
+ {
3426
+ internalType: "bytes32",
3427
+ name: "recipient",
3428
+ type: "bytes32"
3429
+ },
3430
+ {
3431
+ internalType: "uint32",
3432
+ name: "nonce",
3433
+ type: "uint32"
3434
+ },
3435
+ {
3436
+ internalType: "bytes",
3437
+ name: "payload",
3438
+ type: "bytes"
3439
+ }
3440
+ ],
3441
+ name: "wrapAndTransferETHWithPayload",
3442
+ outputs: [
3443
+ {
3444
+ internalType: "uint64",
3445
+ name: "sequence",
3446
+ type: "uint64"
3447
+ }
3448
+ ],
3449
+ stateMutability: "payable",
3450
+ type: "function"
3451
+ },
3452
+ {
3453
+ inputs: [
3454
+ {
3455
+ internalType: "address",
3456
+ name: "token",
3457
+ type: "address"
3458
+ },
3459
+ {
3460
+ internalType: "uint256",
3461
+ name: "amount",
3462
+ type: "uint256"
3463
+ },
3464
+ {
3465
+ internalType: "uint16",
3466
+ name: "recipientChain",
3467
+ type: "uint16"
3468
+ },
3469
+ {
3470
+ internalType: "bytes32",
3471
+ name: "recipient",
3472
+ type: "bytes32"
3473
+ },
3474
+ {
3475
+ internalType: "uint256",
3476
+ name: "arbiterFee",
3477
+ type: "uint256"
3478
+ },
3479
+ {
3480
+ internalType: "uint32",
3481
+ name: "nonce",
3482
+ type: "uint32"
3483
+ }
3484
+ ],
3485
+ name: "transferTokens",
3486
+ outputs: [
3487
+ {
3488
+ internalType: "uint64",
3489
+ name: "sequence",
3490
+ type: "uint64"
3491
+ }
3492
+ ],
3493
+ stateMutability: "payable",
3494
+ type: "function"
3495
+ },
3496
+ {
3497
+ inputs: [
3498
+ {
3499
+ internalType: "address",
3500
+ name: "token",
3501
+ type: "address"
3502
+ },
3503
+ {
3504
+ internalType: "uint256",
3505
+ name: "amount",
3506
+ type: "uint256"
3507
+ },
3508
+ {
3509
+ internalType: "uint16",
3510
+ name: "recipientChain",
3511
+ type: "uint16"
3512
+ },
3513
+ {
3514
+ internalType: "bytes32",
3515
+ name: "recipient",
3516
+ type: "bytes32"
3517
+ },
3518
+ {
3519
+ internalType: "uint32",
3520
+ name: "nonce",
3521
+ type: "uint32"
3522
+ },
3523
+ {
3524
+ internalType: "bytes",
3525
+ name: "payload",
3526
+ type: "bytes"
3527
+ }
3528
+ ],
3529
+ name: "transferTokensWithPayload",
3530
+ outputs: [
3531
+ {
3532
+ internalType: "uint64",
3533
+ name: "sequence",
3534
+ type: "uint64"
3535
+ }
3536
+ ],
3537
+ stateMutability: "payable",
3538
+ type: "function"
3539
+ },
3540
+ {
3541
+ inputs: [
3542
+ {
3543
+ internalType: "bytes",
3544
+ name: "encodedVm",
3545
+ type: "bytes"
3546
+ }
3547
+ ],
3548
+ name: "updateWrapped",
3549
+ outputs: [
3550
+ {
3551
+ internalType: "address",
3552
+ name: "token",
3553
+ type: "address"
3554
+ }
3555
+ ],
3556
+ stateMutability: "nonpayable",
3557
+ type: "function"
3558
+ },
3559
+ {
3560
+ inputs: [
3561
+ {
3562
+ internalType: "bytes",
3563
+ name: "encodedVm",
3564
+ type: "bytes"
3565
+ }
3566
+ ],
3567
+ name: "createWrapped",
3568
+ outputs: [
3569
+ {
3570
+ internalType: "address",
3571
+ name: "token",
3572
+ type: "address"
3573
+ }
3574
+ ],
3575
+ stateMutability: "nonpayable",
3576
+ type: "function"
3577
+ },
3578
+ {
3579
+ inputs: [
3580
+ {
3581
+ internalType: "bytes",
3582
+ name: "encodedVm",
3583
+ type: "bytes"
3584
+ }
3585
+ ],
3586
+ name: "completeTransferWithPayload",
3587
+ outputs: [
3588
+ {
3589
+ internalType: "bytes",
3590
+ name: "",
3591
+ type: "bytes"
3592
+ }
3593
+ ],
3594
+ stateMutability: "nonpayable",
3595
+ type: "function"
3596
+ },
3597
+ {
3598
+ inputs: [
3599
+ {
3600
+ internalType: "bytes",
3601
+ name: "encodedVm",
3602
+ type: "bytes"
3603
+ }
3604
+ ],
3605
+ name: "completeTransferAndUnwrapETHWithPayload",
3606
+ outputs: [
3607
+ {
3608
+ internalType: "bytes",
3609
+ name: "",
3610
+ type: "bytes"
3611
+ }
3612
+ ],
3613
+ stateMutability: "nonpayable",
3614
+ type: "function"
3615
+ },
3616
+ {
3617
+ inputs: [
3618
+ {
3619
+ internalType: "bytes",
3620
+ name: "encodedVm",
3621
+ type: "bytes"
3622
+ }
3623
+ ],
3624
+ name: "completeTransfer",
3625
+ outputs: [],
3626
+ stateMutability: "nonpayable",
3627
+ type: "function"
3628
+ },
3629
+ {
3630
+ inputs: [
3631
+ {
3632
+ internalType: "bytes",
3633
+ name: "encodedVm",
3634
+ type: "bytes"
3635
+ }
3636
+ ],
3637
+ name: "completeTransferAndUnwrapETH",
3638
+ outputs: [],
3639
+ stateMutability: "nonpayable",
3640
+ type: "function"
3641
+ },
3642
+ {
3643
+ inputs: [
3644
+ {
3645
+ components: [
3646
+ {
3647
+ internalType: "uint8",
3648
+ name: "payloadID",
3649
+ type: "uint8"
3650
+ },
3651
+ {
3652
+ internalType: "bytes32",
3653
+ name: "tokenAddress",
3654
+ type: "bytes32"
3655
+ },
3656
+ {
3657
+ internalType: "uint16",
3658
+ name: "tokenChain",
3659
+ type: "uint16"
3660
+ },
3661
+ {
3662
+ internalType: "uint8",
3663
+ name: "decimals",
3664
+ type: "uint8"
3665
+ },
3666
+ {
3667
+ internalType: "bytes32",
3668
+ name: "symbol",
3669
+ type: "bytes32"
3670
+ },
3671
+ {
3672
+ internalType: "bytes32",
3673
+ name: "name",
3674
+ type: "bytes32"
3675
+ }
3676
+ ],
3677
+ internalType: "struct BridgeStructs.AssetMeta",
3678
+ name: "meta",
3679
+ type: "tuple"
3680
+ }
3681
+ ],
3682
+ name: "encodeAssetMeta",
3683
+ outputs: [
3684
+ {
3685
+ internalType: "bytes",
3686
+ name: "encoded",
3687
+ type: "bytes"
3688
+ }
3689
+ ],
3690
+ stateMutability: "pure",
3691
+ type: "function"
3692
+ },
3693
+ {
3694
+ inputs: [
3695
+ {
3696
+ components: [
3697
+ {
3698
+ internalType: "uint8",
3699
+ name: "payloadID",
3700
+ type: "uint8"
3701
+ },
3702
+ {
3703
+ internalType: "uint256",
3704
+ name: "amount",
3705
+ type: "uint256"
3706
+ },
3707
+ {
3708
+ internalType: "bytes32",
3709
+ name: "tokenAddress",
3710
+ type: "bytes32"
3711
+ },
3712
+ {
3713
+ internalType: "uint16",
3714
+ name: "tokenChain",
3715
+ type: "uint16"
3716
+ },
3717
+ {
3718
+ internalType: "bytes32",
3719
+ name: "to",
3720
+ type: "bytes32"
3721
+ },
3722
+ {
3723
+ internalType: "uint16",
3724
+ name: "toChain",
3725
+ type: "uint16"
3726
+ },
3727
+ {
3728
+ internalType: "uint256",
3729
+ name: "fee",
3730
+ type: "uint256"
3731
+ }
3732
+ ],
3733
+ internalType: "struct BridgeStructs.Transfer",
3734
+ name: "transfer",
3735
+ type: "tuple"
3736
+ }
3737
+ ],
3738
+ name: "encodeTransfer",
3739
+ outputs: [
3740
+ {
3741
+ internalType: "bytes",
3742
+ name: "encoded",
3743
+ type: "bytes"
3744
+ }
3745
+ ],
3746
+ stateMutability: "pure",
3747
+ type: "function"
3748
+ },
3749
+ {
3750
+ inputs: [
3751
+ {
3752
+ components: [
3753
+ {
3754
+ internalType: "uint8",
3755
+ name: "payloadID",
3756
+ type: "uint8"
3757
+ },
3758
+ {
3759
+ internalType: "uint256",
3760
+ name: "amount",
3761
+ type: "uint256"
3762
+ },
3763
+ {
3764
+ internalType: "bytes32",
3765
+ name: "tokenAddress",
3766
+ type: "bytes32"
3767
+ },
3768
+ {
3769
+ internalType: "uint16",
3770
+ name: "tokenChain",
3771
+ type: "uint16"
3772
+ },
3773
+ {
3774
+ internalType: "bytes32",
3775
+ name: "to",
3776
+ type: "bytes32"
3777
+ },
3778
+ {
3779
+ internalType: "uint16",
3780
+ name: "toChain",
3781
+ type: "uint16"
3782
+ },
3783
+ {
3784
+ internalType: "bytes32",
3785
+ name: "fromAddress",
3786
+ type: "bytes32"
3787
+ },
3788
+ {
3789
+ internalType: "bytes",
3790
+ name: "payload",
3791
+ type: "bytes"
3792
+ }
3793
+ ],
3794
+ internalType: "struct BridgeStructs.TransferWithPayload",
3795
+ name: "transfer",
3796
+ type: "tuple"
3797
+ }
3798
+ ],
3799
+ name: "encodeTransferWithPayload",
3800
+ outputs: [
3801
+ {
3802
+ internalType: "bytes",
3803
+ name: "encoded",
3804
+ type: "bytes"
3805
+ }
3806
+ ],
3807
+ stateMutability: "pure",
3808
+ type: "function"
3809
+ },
3810
+ {
3811
+ inputs: [
3812
+ {
3813
+ internalType: "bytes",
3814
+ name: "encoded",
3815
+ type: "bytes"
3816
+ }
3817
+ ],
3818
+ name: "parsePayloadID",
3819
+ outputs: [
3820
+ {
3821
+ internalType: "uint8",
3822
+ name: "payloadID",
3823
+ type: "uint8"
3824
+ }
3825
+ ],
3826
+ stateMutability: "pure",
3827
+ type: "function"
3828
+ },
3829
+ {
3830
+ inputs: [
3831
+ {
3832
+ internalType: "bytes",
3833
+ name: "encoded",
3834
+ type: "bytes"
3835
+ }
3836
+ ],
3837
+ name: "parseAssetMeta",
3838
+ outputs: [
3839
+ {
3840
+ components: [
3841
+ {
3842
+ internalType: "uint8",
3843
+ name: "payloadID",
3844
+ type: "uint8"
3845
+ },
3846
+ {
3847
+ internalType: "bytes32",
3848
+ name: "tokenAddress",
3849
+ type: "bytes32"
3850
+ },
3851
+ {
3852
+ internalType: "uint16",
3853
+ name: "tokenChain",
3854
+ type: "uint16"
3855
+ },
3856
+ {
3857
+ internalType: "uint8",
3858
+ name: "decimals",
3859
+ type: "uint8"
3860
+ },
3861
+ {
3862
+ internalType: "bytes32",
3863
+ name: "symbol",
3864
+ type: "bytes32"
3865
+ },
3866
+ {
3867
+ internalType: "bytes32",
3868
+ name: "name",
3869
+ type: "bytes32"
3870
+ }
3871
+ ],
3872
+ internalType: "struct BridgeStructs.AssetMeta",
3873
+ name: "meta",
3874
+ type: "tuple"
3875
+ }
3876
+ ],
3877
+ stateMutability: "pure",
3878
+ type: "function"
3879
+ },
3880
+ {
3881
+ inputs: [
3882
+ {
3883
+ internalType: "bytes",
3884
+ name: "encoded",
3885
+ type: "bytes"
3886
+ }
3887
+ ],
3888
+ name: "parseTransfer",
3889
+ outputs: [
3890
+ {
3891
+ components: [
3892
+ {
3893
+ internalType: "uint8",
3894
+ name: "payloadID",
3895
+ type: "uint8"
3896
+ },
3897
+ {
3898
+ internalType: "uint256",
3899
+ name: "amount",
3900
+ type: "uint256"
3901
+ },
3902
+ {
3903
+ internalType: "bytes32",
3904
+ name: "tokenAddress",
3905
+ type: "bytes32"
3906
+ },
3907
+ {
3908
+ internalType: "uint16",
3909
+ name: "tokenChain",
3910
+ type: "uint16"
3911
+ },
3912
+ {
3913
+ internalType: "bytes32",
3914
+ name: "to",
3915
+ type: "bytes32"
3916
+ },
3917
+ {
3918
+ internalType: "uint16",
3919
+ name: "toChain",
3920
+ type: "uint16"
3921
+ },
3922
+ {
3923
+ internalType: "uint256",
3924
+ name: "fee",
3925
+ type: "uint256"
3926
+ }
3927
+ ],
3928
+ internalType: "struct BridgeStructs.Transfer",
3929
+ name: "transfer",
3930
+ type: "tuple"
3931
+ }
3932
+ ],
3933
+ stateMutability: "pure",
3934
+ type: "function"
3935
+ },
3936
+ {
3937
+ inputs: [
3938
+ {
3939
+ internalType: "bytes",
3940
+ name: "encoded",
3941
+ type: "bytes"
3942
+ }
3943
+ ],
3944
+ name: "parseTransferWithPayload",
3945
+ outputs: [
3946
+ {
3947
+ components: [
3948
+ {
3949
+ internalType: "uint8",
3950
+ name: "payloadID",
3951
+ type: "uint8"
3952
+ },
3953
+ {
3954
+ internalType: "uint256",
3955
+ name: "amount",
3956
+ type: "uint256"
3957
+ },
3958
+ {
3959
+ internalType: "bytes32",
3960
+ name: "tokenAddress",
3961
+ type: "bytes32"
3962
+ },
3963
+ {
3964
+ internalType: "uint16",
3965
+ name: "tokenChain",
3966
+ type: "uint16"
3967
+ },
3968
+ {
3969
+ internalType: "bytes32",
3970
+ name: "to",
3971
+ type: "bytes32"
3972
+ },
3973
+ {
3974
+ internalType: "uint16",
3975
+ name: "toChain",
3976
+ type: "uint16"
3977
+ },
3978
+ {
3979
+ internalType: "bytes32",
3980
+ name: "fromAddress",
3981
+ type: "bytes32"
3982
+ },
3983
+ {
3984
+ internalType: "bytes",
3985
+ name: "payload",
3986
+ type: "bytes"
3987
+ }
3988
+ ],
3989
+ internalType: "struct BridgeStructs.TransferWithPayload",
3990
+ name: "transfer",
3991
+ type: "tuple"
3992
+ }
3993
+ ],
3994
+ stateMutability: "pure",
3995
+ type: "function"
3996
+ },
3997
+ {
3998
+ inputs: [
3999
+ {
4000
+ internalType: "bytes",
4001
+ name: "encoded",
4002
+ type: "bytes"
4003
+ }
4004
+ ],
4005
+ name: "_parseTransferCommon",
4006
+ outputs: [
4007
+ {
4008
+ components: [
4009
+ {
4010
+ internalType: "uint8",
4011
+ name: "payloadID",
4012
+ type: "uint8"
4013
+ },
4014
+ {
4015
+ internalType: "uint256",
4016
+ name: "amount",
4017
+ type: "uint256"
4018
+ },
4019
+ {
4020
+ internalType: "bytes32",
4021
+ name: "tokenAddress",
4022
+ type: "bytes32"
4023
+ },
4024
+ {
4025
+ internalType: "uint16",
4026
+ name: "tokenChain",
4027
+ type: "uint16"
4028
+ },
4029
+ {
4030
+ internalType: "bytes32",
4031
+ name: "to",
4032
+ type: "bytes32"
4033
+ },
4034
+ {
4035
+ internalType: "uint16",
4036
+ name: "toChain",
4037
+ type: "uint16"
4038
+ },
4039
+ {
4040
+ internalType: "uint256",
4041
+ name: "fee",
4042
+ type: "uint256"
4043
+ }
4044
+ ],
4045
+ internalType: "struct BridgeStructs.Transfer",
4046
+ name: "transfer",
4047
+ type: "tuple"
4048
+ }
4049
+ ],
4050
+ stateMutability: "pure",
4051
+ type: "function"
4052
+ }
4053
+ ];
4054
+
4055
+ // src/mrl/providers/wormhole/contract/TokenBridge/TokenBridge.ts
4056
+ var module3 = "TokenBridge";
4057
+ function TokenBridge() {
4058
+ return {
4059
+ transferTokens: () => ({
4060
+ build: ({ asset, destination, destinationAddress, moonChain }) => {
4061
+ const wh = wormholeFactory(moonChain);
4062
+ const whDestination = wh.getChain(destination.getWormholeName()).config.chainId;
4063
+ const tokenAddressOnMoonChain = moonChain.getChainAsset(asset).address;
4064
+ if (!tokenAddressOnMoonChain) {
4065
+ throw new Error(
4066
+ `Asset ${asset.symbol} does not have a token address on chain ${moonChain.name}`
4067
+ );
4068
+ }
4069
+ const destinationAddress32bytes = convertAddressTo32Bytes(
4070
+ destinationAddress
4071
+ );
4072
+ const tokenAmountOnMoonChain = asset.convertDecimals(
4073
+ moonChain.getChainAsset(asset).decimals
4074
+ ).amount;
4075
+ const contractAddress = wh.getChain("Moonbeam").config.contracts.tokenBridge;
4076
+ if (!contractAddress) {
4077
+ throw new Error(`Wormhole address not found for ${moonChain.name}`);
4078
+ }
4079
+ return new ContractConfig({
4080
+ address: contractAddress,
4081
+ abi: TOKEN_BRIDGE_ABI,
4082
+ args: [
4083
+ tokenAddressOnMoonChain,
4084
+ tokenAmountOnMoonChain,
4085
+ whDestination,
4086
+ destinationAddress32bytes,
4087
+ 0n,
4088
+ 0
4089
+ ],
4090
+ func: "transferTokens",
4091
+ module: module3
4092
+ });
4093
+ }
4094
+ })
4095
+ };
4096
+ }
4097
+
4098
+ // src/mrl/providers/wormhole/contract/TokenBridgeRelayer/TokenBridgeRelayer.ts
4099
+ import { convertAddressTo32Bytes as convertAddressTo32Bytes2 } from "@moonbeam-network/xcm-utils";
4100
+
4101
+ // src/mrl/providers/wormhole/contract/TokenBridgeRelayer/TokenBridgeRelayerAbi.ts
4102
+ var TOKEN_BRIDGE_RELAYER_ABI = [
4103
+ {
4104
+ inputs: [
4105
+ {
4106
+ internalType: "uint16",
4107
+ name: "targetChainId",
4108
+ type: "uint16"
4109
+ },
4110
+ {
4111
+ internalType: "address",
4112
+ name: "token",
4113
+ type: "address"
4114
+ },
4115
+ {
4116
+ internalType: "uint8",
4117
+ name: "decimals",
4118
+ type: "uint8"
4119
+ }
4120
+ ],
4121
+ name: "calculateRelayerFee",
4122
+ outputs: [
4123
+ {
4124
+ internalType: "uint256",
4125
+ name: "feeInTokenDenomination",
4126
+ type: "uint256"
4127
+ }
4128
+ ],
4129
+ stateMutability: "view",
4130
+ type: "function"
4131
+ },
4132
+ {
4133
+ inputs: [
4134
+ {
4135
+ internalType: "address",
4136
+ name: "token",
4137
+ type: "address"
4138
+ },
4139
+ {
4140
+ internalType: "uint256",
4141
+ name: "amount",
4142
+ type: "uint256"
4143
+ },
4144
+ {
4145
+ internalType: "uint256",
4146
+ name: "toNativeTokenAmount",
4147
+ type: "uint256"
4148
+ },
4149
+ {
4150
+ internalType: "uint16",
4151
+ name: "targetChain",
4152
+ type: "uint16"
4153
+ },
4154
+ {
4155
+ internalType: "bytes32",
4156
+ name: "targetRecipient",
4157
+ type: "bytes32"
4158
+ },
4159
+ {
4160
+ internalType: "uint32",
4161
+ name: "batchId",
4162
+ type: "uint32"
4163
+ }
4164
+ ],
4165
+ name: "transferTokensWithRelay",
4166
+ outputs: [
4167
+ {
4168
+ internalType: "uint64",
4169
+ name: "messageSequence",
4170
+ type: "uint64"
4171
+ }
4172
+ ],
4173
+ stateMutability: "payable",
4174
+ type: "function"
4175
+ },
4176
+ {
4177
+ inputs: [
4178
+ {
4179
+ internalType: "uint256",
4180
+ name: "toNativeTokenAmount",
4181
+ type: "uint256"
4182
+ },
4183
+ {
4184
+ internalType: "uint16",
4185
+ name: "targetChain",
4186
+ type: "uint16"
4187
+ },
4188
+ {
4189
+ internalType: "bytes32",
4190
+ name: "targetRecipient",
4191
+ type: "bytes32"
4192
+ },
4193
+ {
4194
+ internalType: "uint32",
4195
+ name: "batchId",
4196
+ type: "uint32"
4197
+ }
4198
+ ],
4199
+ name: "wrapAndTransferEthWithRelay",
4200
+ outputs: [
4201
+ {
4202
+ internalType: "uint64",
4203
+ name: "messageSequence",
4204
+ type: "uint64"
4205
+ }
4206
+ ],
4207
+ stateMutability: "payable",
4208
+ type: "function"
4209
+ }
4210
+ ];
4211
+
4212
+ // src/mrl/providers/wormhole/contract/TokenBridgeRelayer/TokenBridgeRelayer.ts
4213
+ var module4 = "TokenBridgeRelayer";
4214
+ function TokenBridgeRelayer() {
4215
+ return {
4216
+ transferTokensWithRelay: () => ({
4217
+ build: ({ asset, destination, destinationAddress, moonChain }) => {
4218
+ const wh = wormholeFactory(moonChain);
4219
+ const whDestination = wh.getChain(destination.getWormholeName()).config.chainId;
4220
+ const tokenAddressOnMoonChain = moonChain.getChainAsset(asset).address;
4221
+ if (!tokenAddressOnMoonChain) {
4222
+ throw new Error(
4223
+ `Asset ${asset.symbol} does not have a token address on chain ${moonChain.name}`
4224
+ );
4225
+ }
4226
+ const destinationAddress32bytes = convertAddressTo32Bytes2(
4227
+ destinationAddress
4228
+ );
4229
+ const tokenAmountOnMoonChain = asset.convertDecimals(
4230
+ moonChain.getChainAsset(asset).decimals
4231
+ ).amount;
4232
+ const contractAddress = wh.getChain("Moonbeam").config.contracts.tokenBridgeRelayer;
4233
+ if (!contractAddress) {
4234
+ throw new Error(`Wormhole address not found for ${moonChain.name}`);
4235
+ }
4236
+ return new ContractConfig({
4237
+ address: contractAddress,
4238
+ abi: TOKEN_BRIDGE_RELAYER_ABI,
4239
+ args: [
4240
+ tokenAddressOnMoonChain,
4241
+ tokenAmountOnMoonChain,
4242
+ 0,
4243
+ whDestination,
4244
+ destinationAddress32bytes,
4245
+ 0
4246
+ ],
4247
+ func: "transferTokensWithRelay",
4248
+ module: module4
4249
+ });
4250
+ }
4251
+ })
4252
+ };
4253
+ }
4254
+
4255
+ // src/mrl/providers/wormhole/contract/index.ts
4256
+ function contract() {
4257
+ return { Batch, Gmp, TokenBridge, TokenBridgeRelayer };
4258
+ }
4259
+
4260
+ // src/mrl/providers/wormhole/extrinsic/ethereumXcm/ethereumXcm.ts
4261
+ import { encodeFunctionData as encodeFunctionData3 } from "viem";
4262
+
4263
+ // src/mrl/MrlBuilder.constants.ts
4264
+ var BATCH_CONTRACT_ADDRESS = "0x0000000000000000000000000000000000000808";
4265
+
4266
+ // src/mrl/providers/wormhole/extrinsic/ethereumXcm/BatchContractAbi.ts
4267
+ var BATCH_CONTRACT_ABI = [
4268
+ {
4269
+ anonymous: false,
4270
+ inputs: [
4271
+ {
4272
+ indexed: false,
4273
+ internalType: "uint256",
4274
+ name: "index",
4275
+ type: "uint256"
4276
+ }
4277
+ ],
4278
+ name: "SubcallFailed",
4279
+ type: "event"
4280
+ },
4281
+ {
4282
+ anonymous: false,
4283
+ inputs: [
4284
+ {
4285
+ indexed: false,
4286
+ internalType: "uint256",
4287
+ name: "index",
4288
+ type: "uint256"
4289
+ }
4290
+ ],
4291
+ name: "SubcallSucceeded",
4292
+ type: "event"
4293
+ },
4294
+ {
4295
+ inputs: [
4296
+ {
4297
+ internalType: "address[]",
4298
+ name: "to",
4299
+ type: "address[]"
4300
+ },
4301
+ {
4302
+ internalType: "uint256[]",
4303
+ name: "value",
4304
+ type: "uint256[]"
4305
+ },
4306
+ {
4307
+ internalType: "bytes[]",
4308
+ name: "callData",
4309
+ type: "bytes[]"
4310
+ },
4311
+ {
4312
+ internalType: "uint64[]",
4313
+ name: "gasLimit",
4314
+ type: "uint64[]"
4315
+ }
4316
+ ],
4317
+ name: "batchAll",
4318
+ outputs: [],
4319
+ stateMutability: "nonpayable",
4320
+ type: "function"
4321
+ },
4322
+ {
4323
+ inputs: [
4324
+ {
4325
+ internalType: "address[]",
4326
+ name: "to",
4327
+ type: "address[]"
4328
+ },
4329
+ {
4330
+ internalType: "uint256[]",
4331
+ name: "value",
4332
+ type: "uint256[]"
4333
+ },
4334
+ {
4335
+ internalType: "bytes[]",
4336
+ name: "callData",
4337
+ type: "bytes[]"
4338
+ },
4339
+ {
4340
+ internalType: "uint64[]",
4341
+ name: "gasLimit",
4342
+ type: "uint64[]"
4343
+ }
4344
+ ],
4345
+ name: "batchSome",
4346
+ outputs: [],
4347
+ stateMutability: "nonpayable",
4348
+ type: "function"
4349
+ },
4350
+ {
4351
+ inputs: [
4352
+ {
4353
+ internalType: "address[]",
4354
+ name: "to",
4355
+ type: "address[]"
4356
+ },
4357
+ {
4358
+ internalType: "uint256[]",
4359
+ name: "value",
4360
+ type: "uint256[]"
4361
+ },
4362
+ {
4363
+ internalType: "bytes[]",
4364
+ name: "callData",
4365
+ type: "bytes[]"
4366
+ },
4367
+ {
4368
+ internalType: "uint64[]",
4369
+ name: "gasLimit",
4370
+ type: "uint64[]"
4371
+ }
4372
+ ],
4373
+ name: "batchSomeUntilFailure",
4374
+ outputs: [],
4375
+ stateMutability: "nonpayable",
4376
+ type: "function"
4377
+ }
4378
+ ];
4379
+
4380
+ // src/mrl/providers/wormhole/extrinsic/ethereumXcm/ethereumXcm.ts
4381
+ function ethereumXcm() {
4382
+ return {
4383
+ transact: () => ({
4384
+ build: (params) => {
4385
+ const { asset, isAutomatic, moonChain, moonGasLimit } = params;
4386
+ if (!moonGasLimit) {
4387
+ throw new Error("moonGasLimit must be defined");
4388
+ }
4389
+ const tokenAddressOnMoonChain = moonChain.getChainAsset(asset).address;
4390
+ if (!tokenAddressOnMoonChain) {
4391
+ throw new Error(
4392
+ `Asset ${asset.symbol} does not have a token address on chain ${moonChain.name}`
4393
+ );
4394
+ }
4395
+ const tokenAmountOnMoonChain = asset.convertDecimals(
4396
+ moonChain.getChainAsset(asset).decimals
4397
+ ).amount;
4398
+ const contract2 = isAutomatic ? contract().TokenBridgeRelayer().transferTokensWithRelay().build(params) : contract().TokenBridge().transferTokens().build(params);
4399
+ const approveTx = encodeFunctionData3({
4400
+ abi: ERC20_ABI,
4401
+ functionName: "approve",
4402
+ args: [contract2.address, tokenAmountOnMoonChain]
4403
+ });
4404
+ const batchAll = encodeFunctionData3({
4405
+ abi: BATCH_CONTRACT_ABI,
4406
+ functionName: "batchAll",
4407
+ args: [
4408
+ [tokenAddressOnMoonChain, contract2.address],
4409
+ [0n, 0n],
4410
+ // Value to send for each call
4411
+ [approveTx, contract2.encodeFunctionData()],
4412
+ // Call data for each call
4413
+ []
4414
+ // Gas limit for each call
4415
+ ]
4416
+ });
4417
+ return new ExtrinsicConfig({
4418
+ module: "ethereumXcm",
4419
+ func: "transact",
4420
+ getArgs: () => [
4421
+ {
4422
+ V2: {
4423
+ gasLimit: moonGasLimit,
4424
+ action: {
4425
+ Call: BATCH_CONTRACT_ADDRESS
4426
+ },
4427
+ value: 0,
4428
+ input: batchAll
4429
+ }
4430
+ }
4431
+ ]
4432
+ });
4433
+ }
4434
+ })
4435
+ };
4436
+ }
4437
+
4438
+ // src/mrl/providers/wormhole/extrinsic/index.ts
4439
+ function extrinsic() {
4440
+ return { ethereumXcm, polkadotXcm: polkadotXcm2 };
4441
+ }
4442
+
4443
+ // src/mrl/providers/wormhole/index.ts
4444
+ function wormhole2() {
4445
+ return {
4446
+ contract,
4447
+ extrinsic,
4448
+ wormhole
4449
+ };
4450
+ }
4451
+
4452
+ // src/mrl/MrlBuilder.ts
4453
+ function MrlBuilder() {
4454
+ return {
4455
+ wormhole: wormhole2
4456
+ };
4457
+ }
4458
+ export {
4459
+ AssetMinBuilder,
4460
+ BATCH_CONTRACT_ABI,
4461
+ BATCH_CONTRACT_ADDRESS,
4462
+ BalanceBuilder,
4463
+ ContractBuilder,
4464
+ ContractConfig,
4465
+ ERC20_ABI,
4466
+ EvmQueryConfig,
4467
+ ExtrinsicBuilder,
4468
+ ExtrinsicConfig,
4469
+ FeeBuilder,
4470
+ MrlBuilder,
4471
+ SubstrateCallConfig,
4472
+ SubstrateQueryConfig,
4473
+ WormholeConfig,
4474
+ XcmVersion,
4475
+ calculateSystemAccountBalance,
4476
+ evm,
4477
+ substrate,
4478
+ wormhole2 as wormhole,
4479
+ wormholeFactory
4480
+ };
2
4481
  //# sourceMappingURL=index.mjs.map