@moonbeam-network/mrl 1.0.0-dev.268 → 1.0.0-dev.270

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
@@ -21,19 +21,19 @@ import {
21
21
  wormholeFactory
22
22
  } from "@moonbeam-network/xcm-builder";
23
23
 
24
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@3.8.5_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-tokenbridge/dist/esm/index.js
24
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@4.0.2_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-tokenbridge/dist/esm/index.js
25
25
  import { registerProtocol as registerProtocol2 } from "@wormhole-foundation/sdk-connect";
26
26
  import { _platform as _platform2 } from "@wormhole-foundation/sdk-evm";
27
27
 
28
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@3.8.5_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-tokenbridge/dist/esm/tokenBridge.js
28
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@4.0.2_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-tokenbridge/dist/esm/tokenBridge.js
29
29
  import { ErrNotWrapped, UniversalAddress, isNative, keccak256 as keccak2562, nativeChainIds as nativeChainIds2, serialize as serialize2, toChain, toChainId, toNative } from "@wormhole-foundation/sdk-connect";
30
30
  import { EvmAddress as EvmAddress2, EvmPlatform as EvmPlatform2, EvmUnsignedTransaction as EvmUnsignedTransaction2, EvmZeroAddress, addChainId as addChainId2, addFrom as addFrom2, unusedArbiterFee, unusedNonce, WETH_CONTRACTS } from "@wormhole-foundation/sdk-evm";
31
31
 
32
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-core@3.8.5_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-core/dist/esm/index.js
32
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-core@4.0.2_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-core/dist/esm/index.js
33
33
  import { registerProtocol } from "@wormhole-foundation/sdk-connect";
34
34
  import { _platform } from "@wormhole-foundation/sdk-evm";
35
35
 
36
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-core@3.8.5_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-core/dist/esm/core.js
36
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-core@4.0.2_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-core/dist/esm/core.js
37
37
  import { nativeChainIds, createVAA, isWormholeMessageId, encoding, serialize } from "@wormhole-foundation/sdk-connect";
38
38
  import { EvmAddress, EvmPlatform, EvmUnsignedTransaction, addChainId, addFrom } from "@wormhole-foundation/sdk-evm";
39
39
  var EvmWormholeCore = class _EvmWormholeCore {
@@ -150,7 +150,7 @@ var EvmWormholeCore = class _EvmWormholeCore {
150
150
  }
151
151
  };
152
152
 
153
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-core@3.8.5_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-core/dist/esm/ethers-contracts/index.js
153
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-core@4.0.2_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-core/dist/esm/ethers-contracts/index.js
154
154
  var ethers_contracts_exports = {};
155
155
  __export(ethers_contracts_exports, {
156
156
  Implementation__factory: () => Implementation__factory
@@ -7316,7 +7316,7 @@ var ContractFactory = class _ContractFactory {
7316
7316
  }
7317
7317
  };
7318
7318
 
7319
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-core@3.8.5_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-core/dist/esm/ethers-contracts/factories/Implementation__factory.js
7319
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-core@4.0.2_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-core/dist/esm/ethers-contracts/factories/Implementation__factory.js
7320
7320
  var _abi = [
7321
7321
  {
7322
7322
  anonymous: false,
@@ -8386,10 +8386,10 @@ var Implementation__factory = class extends ContractFactory {
8386
8386
  }
8387
8387
  };
8388
8388
 
8389
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-core@3.8.5_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-core/dist/esm/index.js
8389
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-core@4.0.2_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-core/dist/esm/index.js
8390
8390
  registerProtocol(_platform, "WormholeCore", EvmWormholeCore);
8391
8391
 
8392
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@3.8.5_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-tokenbridge/dist/esm/tokenBridge.js
8392
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@4.0.2_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-tokenbridge/dist/esm/tokenBridge.js
8393
8393
  var EvmTokenBridge = class _EvmTokenBridge {
8394
8394
  network;
8395
8395
  chain;
@@ -8527,7 +8527,7 @@ var EvmTokenBridge = class _EvmTokenBridge {
8527
8527
  }
8528
8528
  };
8529
8529
 
8530
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@3.8.5_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-tokenbridge/dist/esm/automaticTokenBridge.js
8530
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@4.0.2_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-tokenbridge/dist/esm/automaticTokenBridge.js
8531
8531
  import { isNative as isNative2, serialize as serialize3, toNative as toNative2, nativeChainIds as nativeChainIds3, toChainId as toChainId2 } from "@wormhole-foundation/sdk-connect";
8532
8532
  import { EvmAddress as EvmAddress3, EvmPlatform as EvmPlatform3, EvmUnsignedTransaction as EvmUnsignedTransaction3, WETH_CONTRACTS as WETH_CONTRACTS2, addChainId as addChainId3, addFrom as addFrom3 } from "@wormhole-foundation/sdk-evm";
8533
8533
  var EvmAutomaticTokenBridge = class _EvmAutomaticTokenBridge {
@@ -8635,16 +8635,16 @@ var EvmAutomaticTokenBridge = class _EvmAutomaticTokenBridge {
8635
8635
  }
8636
8636
  };
8637
8637
 
8638
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@3.8.5_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-tokenbridge/dist/esm/executorTokenBridge.js
8638
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@4.0.2_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-tokenbridge/dist/esm/executorTokenBridge.js
8639
8639
  import { nativeChainIds as nativeChainIds4, toChainId as toChainId3, signedQuoteLayout as signedQuoteLayout2, isNative as isNative4, serializeLayout, serialize as serialize5, contracts } from "@wormhole-foundation/sdk-connect";
8640
8640
  import { EvmAddress as EvmAddress4, EvmPlatform as EvmPlatform4, EvmUnsignedTransaction as EvmUnsignedTransaction4, addChainId as addChainId4, addFrom as addFrom4 } from "@wormhole-foundation/sdk-evm";
8641
8641
 
8642
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-base@3.8.5/node_modules/@wormhole-foundation/sdk-base/dist/esm/utils/array.js
8642
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-base@4.0.2/node_modules/@wormhole-foundation/sdk-base/dist/esm/utils/array.js
8643
8643
  var range = (length) => [...Array(length).keys()];
8644
8644
  var column = (tupArr, index) => tupArr.map((tuple) => tuple[index]);
8645
8645
  var zip = (arr) => range(arr[0].length).map((col) => range(arr.length).map((row) => arr[row][col]));
8646
8646
 
8647
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-base@3.8.5/node_modules/@wormhole-foundation/sdk-base/dist/esm/utils/mapping.js
8647
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-base@4.0.2/node_modules/@wormhole-foundation/sdk-base/dist/esm/utils/mapping.js
8648
8648
  function isMappableKey(key) {
8649
8649
  return ["string", "number", "symbol", "bigint", "boolean"].includes(typeof key);
8650
8650
  }
@@ -8720,7 +8720,7 @@ function constMap(mappingEntries, shape) {
8720
8720
  return toConstMap(toMapping(mappingEntries, shape));
8721
8721
  }
8722
8722
 
8723
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-base@3.8.5/node_modules/@wormhole-foundation/sdk-base/dist/esm/utils/misc.js
8723
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-base@4.0.2/node_modules/@wormhole-foundation/sdk-base/dist/esm/utils/misc.js
8724
8724
  function lazyInstantiate(factory) {
8725
8725
  let instance = null;
8726
8726
  return () => {
@@ -8738,7 +8738,7 @@ function throws(fn) {
8738
8738
  }
8739
8739
  }
8740
8740
 
8741
- // ../../node_modules/.pnpm/binary-layout@1.3.1/node_modules/binary-layout/dist/index.mjs
8741
+ // ../../node_modules/.pnpm/binary-layout@1.3.2/node_modules/binary-layout/dist/index.mjs
8742
8742
  var binaryLiterals = ["int", "uint", "bytes", "array", "switch"];
8743
8743
  var defaultEndianness = "big";
8744
8744
  var numberMaxSize = 6;
@@ -9612,7 +9612,7 @@ function bitsetItem(bitnames, size) {
9612
9612
  };
9613
9613
  }
9614
9614
 
9615
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-base@3.8.5/node_modules/@wormhole-foundation/sdk-base/dist/esm/utils/encoding.js
9615
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-base@4.0.2/node_modules/@wormhole-foundation/sdk-base/dist/esm/utils/encoding.js
9616
9616
  var encoding_exports = {};
9617
9617
  __export(encoding_exports, {
9618
9618
  b58: () => b58,
@@ -9999,7 +9999,7 @@ function genBech32(encoding2) {
9999
9999
  }
10000
10000
  var bech32 = /* @__PURE__ */ genBech32("bech32");
10001
10001
 
10002
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-base@3.8.5/node_modules/@wormhole-foundation/sdk-base/dist/esm/utils/encoding.js
10002
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-base@4.0.2/node_modules/@wormhole-foundation/sdk-base/dist/esm/utils/encoding.js
10003
10003
  var stripPrefix = (prefix, str) => str.startsWith(prefix) ? str.slice(prefix.length) : str;
10004
10004
  var isHexRegex = /^(?:0x)?[0-9a-fA-F]+$/;
10005
10005
  var hex = {
@@ -10095,7 +10095,7 @@ var bytes2 = {
10095
10095
  }
10096
10096
  };
10097
10097
 
10098
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-base@3.8.5/node_modules/@wormhole-foundation/sdk-base/dist/esm/constants/chains.js
10098
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-base@4.0.2/node_modules/@wormhole-foundation/sdk-base/dist/esm/constants/chains.js
10099
10099
  var chainIdAndChainEntries = [
10100
10100
  //Unlike the old sdk, we are not including an "Unset" chain with chainId 0 here because:
10101
10101
  // * no other types would be associated with it (such as contracts or a platform)
@@ -10142,6 +10142,8 @@ var chainIdAndChainEntries = [
10142
10142
  [57, "XRPLEVM"],
10143
10143
  [58, "Plasma"],
10144
10144
  [59, "CreditCoin"],
10145
+ [60, "Stacks"],
10146
+ [63, "Moca"],
10145
10147
  [3104, "Wormchain"],
10146
10148
  [4e3, "Cosmoshub"],
10147
10149
  [4001, "Evmos"],
@@ -10185,7 +10187,7 @@ var toChain2 = (chain2) => {
10185
10187
  throw Error(`Cannot convert to Chain: ${chain2}`);
10186
10188
  };
10187
10189
 
10188
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-base@3.8.5/node_modules/@wormhole-foundation/sdk-base/dist/esm/constants/platforms.js
10190
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-base@4.0.2/node_modules/@wormhole-foundation/sdk-base/dist/esm/constants/platforms.js
10189
10191
  var platformAndChainsEntries = [
10190
10192
  [
10191
10193
  "Evm",
@@ -10225,8 +10227,9 @@ var platformAndChainsEntries = [
10225
10227
  "XRPLEVM",
10226
10228
  "Plasma",
10227
10229
  "CreditCoin",
10228
- "HyperCore"
10230
+ "HyperCore",
10229
10231
  // not an actual EVM platform; treating as EVM
10232
+ "Moca"
10230
10233
  ]
10231
10234
  ],
10232
10235
  [
@@ -10285,6 +10288,12 @@ var platformAndChainsEntries = [
10285
10288
  [
10286
10289
  "Near"
10287
10290
  ]
10291
+ ],
10292
+ [
10293
+ "Stacks",
10294
+ [
10295
+ "Stacks"
10296
+ ]
10288
10297
  ]
10289
10298
  ];
10290
10299
  var platforms = column(platformAndChainsEntries, 0);
@@ -10299,11 +10308,12 @@ var platformAddressFormatEntries = [
10299
10308
  ["Algorand", "algorandAppId"],
10300
10309
  ["Sui", "hex"],
10301
10310
  ["Aptos", "hex"],
10302
- ["Near", "sha256"]
10311
+ ["Near", "sha256"],
10312
+ ["Stacks", "keccak256"]
10303
10313
  ];
10304
10314
  var platformToAddressFormat = constMap(platformAddressFormatEntries);
10305
10315
 
10306
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-base@3.8.5/node_modules/@wormhole-foundation/sdk-base/dist/esm/constants/tbtc.js
10316
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-base@4.0.2/node_modules/@wormhole-foundation/sdk-base/dist/esm/constants/tbtc.js
10307
10317
  var tbtc_exports = {};
10308
10318
  __export(tbtc_exports, {
10309
10319
  tbtcTokens: () => tbtcTokens
@@ -13125,7 +13135,7 @@ function sqrtMod(y) {
13125
13135
  var Fpk1 = Field(secp256k1_CURVE.p, { sqrt: sqrtMod });
13126
13136
  var secp256k1 = createCurve({ ...secp256k1_CURVE, Fp: Fpk1, lowS: true, endo: secp256k1_ENDO }, sha256);
13127
13137
 
13128
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@3.8.5/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/universalAddress.js
13138
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0.2/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/universalAddress.js
13129
13139
  var algorandAppIdLayout = [
13130
13140
  { name: "appIdPrefix", binary: "bytes", custom: encoding_exports.bytes.encode("appID"), omit: true },
13131
13141
  { name: "appId", binary: "uint", size: 8 }
@@ -13177,15 +13187,19 @@ var UniversalAddress2 = class _UniversalAddress {
13177
13187
  return sha512_2562(serialize4(algorandAppIdLayout, { appId: BigInt(address) }));
13178
13188
  case "sha256":
13179
13189
  return sha2562(address);
13190
+ case "keccak256":
13191
+ return keccak_2562(address);
13180
13192
  }
13181
13193
  })();
13194
+ if (!decoded)
13195
+ throw new Error(`string ${address} could not be decoded for format ${format}`);
13182
13196
  if (decoded.length > _UniversalAddress.byteSize)
13183
13197
  throw new Error(`string ${address} has invalid length for format ${format}`);
13184
13198
  return decoded.length < _UniversalAddress.byteSize ? encoding_exports.bytes.zpad(decoded, _UniversalAddress.byteSize) : decoded;
13185
13199
  }
13186
13200
  };
13187
13201
 
13188
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@3.8.5/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/address.js
13202
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0.2/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/address.js
13189
13203
  function isChainSpecificAddress(thing) {
13190
13204
  return typeof thing === "object" && "setChain" in thing;
13191
13205
  }
@@ -13215,7 +13229,7 @@ function toUniversal(chain2, address) {
13215
13229
  return new UniversalAddress2(address, platformToAddressFormat.get(platform));
13216
13230
  }
13217
13231
 
13218
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@3.8.5/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/vaa/registration.js
13232
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0.2/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/vaa/registration.js
13219
13233
  var composeLiteral = (protocol, payloadName) => protocol ? `${protocol}:${payloadName}` : payloadName;
13220
13234
  var payloadFactory = /* @__PURE__ */ new Map();
13221
13235
  function registerPayloadType(protocol, name, layout) {
@@ -13229,13 +13243,13 @@ function registerPayloadTypes(protocol, payloads) {
13229
13243
  registerPayloadType(protocol, name, layout);
13230
13244
  }
13231
13245
 
13232
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@3.8.5/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/layout-items/amount.js
13246
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0.2/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/layout-items/amount.js
13233
13247
  var amountItem = {
13234
13248
  binary: "uint",
13235
13249
  size: 32
13236
13250
  };
13237
13251
 
13238
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@3.8.5/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/layout-items/chain.js
13252
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0.2/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/layout-items/chain.js
13239
13253
  var chainItemBase = { binary: "uint", size: 2 };
13240
13254
  var chainItem = (opts) => ({
13241
13255
  ...chainItemBase,
@@ -13256,7 +13270,7 @@ var chainItem = (opts) => ({
13256
13270
  }
13257
13271
  });
13258
13272
 
13259
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@3.8.5/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/layout-items/circle.js
13273
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0.2/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/layout-items/circle.js
13260
13274
  var circleDomainItem = {
13261
13275
  binary: "uint",
13262
13276
  size: 4
@@ -13266,19 +13280,19 @@ var circleNonceItem = {
13266
13280
  size: 8
13267
13281
  };
13268
13282
 
13269
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@3.8.5/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/layout-items/date.js
13283
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0.2/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/layout-items/date.js
13270
13284
  var dateConversion = {
13271
13285
  to: (encoded) => new Date(Number(encoded * 1000n)),
13272
13286
  from: (decoded) => BigInt(decoded.getTime()) / 1000n
13273
13287
  };
13274
13288
 
13275
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@3.8.5/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/layout-items/guardianSet.js
13289
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0.2/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/layout-items/guardianSet.js
13276
13290
  var guardianSetItem = {
13277
13291
  binary: "uint",
13278
13292
  size: 4
13279
13293
  };
13280
13294
 
13281
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@3.8.5/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/layout-items/payloadId.js
13295
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0.2/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/layout-items/payloadId.js
13282
13296
  var payloadIdItem = (id2) => ({
13283
13297
  name: "payloadId",
13284
13298
  binary: "uint",
@@ -13287,13 +13301,13 @@ var payloadIdItem = (id2) => ({
13287
13301
  omit: true
13288
13302
  });
13289
13303
 
13290
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@3.8.5/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/layout-items/sequence.js
13304
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0.2/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/layout-items/sequence.js
13291
13305
  var sequenceItem = {
13292
13306
  binary: "uint",
13293
13307
  size: 8
13294
13308
  };
13295
13309
 
13296
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@3.8.5/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/signature.js
13310
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0.2/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/signature.js
13297
13311
  var Signature = class {
13298
13312
  r;
13299
13313
  s;
@@ -13337,7 +13351,7 @@ var SignatureUtils;
13337
13351
  SignatureUtils2.recover = recover;
13338
13352
  })(SignatureUtils || (SignatureUtils = {}));
13339
13353
 
13340
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@3.8.5/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/layout-items/signature.js
13354
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0.2/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/layout-items/signature.js
13341
13355
  var signatureLayout = [
13342
13356
  { name: "r", binary: "uint", size: 32 },
13343
13357
  { name: "s", binary: "uint", size: 32 },
@@ -13352,7 +13366,7 @@ var signatureItem = {
13352
13366
  }
13353
13367
  };
13354
13368
 
13355
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@3.8.5/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/layout-items/universalAddress.js
13369
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0.2/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/layout-items/universalAddress.js
13356
13370
  var universalAddressItem = {
13357
13371
  binary: "bytes",
13358
13372
  size: 32,
@@ -13362,7 +13376,7 @@ var universalAddressItem = {
13362
13376
  }
13363
13377
  };
13364
13378
 
13365
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@3.8.5/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/layout-items/string.js
13379
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0.2/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/layout-items/string.js
13366
13380
  var trimZeros = (arr) => {
13367
13381
  const i = arr.findIndex((x) => x !== 0);
13368
13382
  return -1 < i ? arr.slice(i) : new Uint8Array([]);
@@ -13380,7 +13394,7 @@ var fixedLengthStringItem = (size) => ({
13380
13394
  }
13381
13395
  });
13382
13396
 
13383
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@3.8.5/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/vaa/vaa.js
13397
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0.2/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/vaa/vaa.js
13384
13398
  var guardianSignatureLayout = [
13385
13399
  { name: "guardianIndex", binary: "uint", size: 1 },
13386
13400
  { name: "signature", ...signatureItem }
@@ -13400,7 +13414,7 @@ var envelopeLayout = [
13400
13414
  ];
13401
13415
  var baseLayout = [...headerLayout, ...envelopeLayout];
13402
13416
 
13403
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@3.8.5/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/vaa/functions.js
13417
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0.2/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/vaa/functions.js
13404
13418
  function getPayloadLayout(layoutLiteral) {
13405
13419
  const layout = payloadFactory.get(layoutLiteral);
13406
13420
  if (!layout)
@@ -13425,7 +13439,7 @@ function payloadDiscriminator(payloadLiterals, allowAmbiguous) {
13425
13439
  });
13426
13440
  }
13427
13441
 
13428
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@3.8.5/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/circleBridge/automaticCircleBridgeLayout.js
13442
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0.2/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/circleBridge/automaticCircleBridgeLayout.js
13429
13443
  var depositWithPayloadLayout = (customPayload) => [
13430
13444
  payloadIdItem(1),
13431
13445
  {
@@ -13455,7 +13469,7 @@ var automaticCircleBridgeNamedPayloads = [
13455
13469
  ];
13456
13470
  registerPayloadTypes("AutomaticCircleBridge", automaticCircleBridgeNamedPayloads);
13457
13471
 
13458
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@3.8.5/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/circleBridge/circleBridgeLayout.js
13472
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0.2/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/circleBridge/circleBridgeLayout.js
13459
13473
  var messageVersionItem = { binary: "uint", size: 4, custom: 0, omit: true };
13460
13474
  var circleBurnMessageLayout = [
13461
13475
  // messageBodyVersion is:
@@ -13485,7 +13499,7 @@ var circleBridgeNamedPayloads = [
13485
13499
  ];
13486
13500
  registerPayloadTypes("CircleBridge", circleBridgeNamedPayloads);
13487
13501
 
13488
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@3.8.5/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/circleBridge/circleBridge.js
13502
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0.2/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/circleBridge/circleBridge.js
13489
13503
  var CircleBridge;
13490
13504
  (function(CircleBridge2) {
13491
13505
  const _protocol = "CircleBridge";
@@ -13509,7 +13523,7 @@ var AutomaticCircleBridge;
13509
13523
  AutomaticCircleBridge2.getTransferDiscriminator = lazyInstantiate(() => payloadDiscriminator([_protocol, _payloads]));
13510
13524
  })(AutomaticCircleBridge || (AutomaticCircleBridge = {}));
13511
13525
 
13512
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@3.8.5/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/tokenBridge/tokenBridgeLayout.js
13526
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0.2/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/tokenBridge/tokenBridgeLayout.js
13513
13527
  var fixedLengthStringItem2 = {
13514
13528
  binary: "bytes",
13515
13529
  size: 32,
@@ -13571,7 +13585,7 @@ var tokenBridgeNamedPayloads = [
13571
13585
  ];
13572
13586
  registerPayloadTypes("TokenBridge", tokenBridgeNamedPayloads);
13573
13587
 
13574
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@3.8.5/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/portico/porticoLayout.js
13588
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0.2/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/portico/porticoLayout.js
13575
13589
  var flagsItem = bitsetItem(["shouldWrapNative", "shouldUnwrapNative"]);
13576
13590
  var porticoFlagSetLayout = [
13577
13591
  { name: "recipientChain", binary: "uint", endianness: "little", size: 2 },
@@ -13606,7 +13620,7 @@ var namedPayloads = [
13606
13620
  ];
13607
13621
  registerPayloadTypes("PorticoBridge", namedPayloads);
13608
13622
 
13609
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@3.8.5/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/portico/portico.js
13623
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0.2/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/portico/portico.js
13610
13624
  var PorticoBridge;
13611
13625
  (function(PorticoBridge2) {
13612
13626
  const _protocol = "PorticoBridge";
@@ -13626,7 +13640,7 @@ var PorticoBridge;
13626
13640
  };
13627
13641
  })(PorticoBridge || (PorticoBridge = {}));
13628
13642
 
13629
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@3.8.5/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/relayer/relayerLayout.js
13643
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0.2/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/relayer/relayerLayout.js
13630
13644
  var encodedExecutionInfoItem = {
13631
13645
  binary: "bytes",
13632
13646
  layout: [
@@ -13693,7 +13707,7 @@ var namedPayloads2 = [
13693
13707
  ];
13694
13708
  registerPayloadTypes("Relayer", namedPayloads2);
13695
13709
 
13696
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@3.8.5/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/tokenBridge/automaticTokenBridgeLayout.js
13710
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0.2/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/tokenBridge/automaticTokenBridgeLayout.js
13697
13711
  var connectPayload = [
13698
13712
  payloadIdItem(1),
13699
13713
  { name: "targetRelayerFee", ...amountItem },
@@ -13705,7 +13719,7 @@ var automaticTokenBridgeNamedPayloads = [
13705
13719
  ];
13706
13720
  registerPayloadTypes("AutomaticTokenBridge", automaticTokenBridgeNamedPayloads);
13707
13721
 
13708
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@3.8.5/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/tokenBridge/tokenBridge.js
13722
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0.2/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/tokenBridge/tokenBridge.js
13709
13723
  var TokenBridge;
13710
13724
  (function(TokenBridge2) {
13711
13725
  const _protocol = "TokenBridge";
@@ -13725,21 +13739,21 @@ var ExecutorTokenBridge;
13725
13739
  const _payloads = ["TransferWithExecutorRelay"];
13726
13740
  })(ExecutorTokenBridge || (ExecutorTokenBridge = {}));
13727
13741
 
13728
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@3.8.5/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/tokenBridge/executorTokenBridgeLayout.js
13742
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0.2/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/tokenBridge/executorTokenBridgeLayout.js
13729
13743
  var payload = [{ name: "targetRecipient", ...universalAddressItem }];
13730
13744
  var executorTokenBridgeNamedPayloads = [
13731
13745
  ["TransferWithExecutorRelay", transferWithPayloadLayout(payload)]
13732
13746
  ];
13733
13747
  registerPayloadTypes("ExecutorTokenBridge", executorTokenBridgeNamedPayloads);
13734
13748
 
13735
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@3.8.5/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/governance/globalAccountant.js
13749
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0.2/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/governance/globalAccountant.js
13736
13750
  var modificationKinds = [
13737
13751
  ["Add", 1],
13738
13752
  ["Subtract", 2],
13739
13753
  ["Unknown", 3]
13740
13754
  ];
13741
13755
 
13742
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@3.8.5/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/governance/layout.js
13756
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0.2/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/governance/layout.js
13743
13757
  var rawEvmAddressItem = {
13744
13758
  binary: "bytes",
13745
13759
  size: 20,
@@ -14001,7 +14015,7 @@ registerPayloadTypes("GeneralPurposeGovernance", generalPurposeGovernancePayload
14001
14015
  registerPayloadTypes("WormchainGovernance", wormchainGovernancePayloads);
14002
14016
  registerPayloadTypes("GatewayGovernance", gatewayGovernancePayloads);
14003
14017
 
14004
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@3.8.5/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/tbtc/tbtc.js
14018
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0.2/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/tbtc/tbtc.js
14005
14019
  var TBTCBridge;
14006
14020
  (function(TBTCBridge2) {
14007
14021
  const _protocol = "TBTCBridge";
@@ -14019,7 +14033,7 @@ var TBTCBridge;
14019
14033
  };
14020
14034
  })(TBTCBridge || (TBTCBridge = {}));
14021
14035
 
14022
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@3.8.5/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/tbtc/tbtcLayout.js
14036
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0.2/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/tbtc/tbtcLayout.js
14023
14037
  var tbtcPayloadLayout = [
14024
14038
  { name: "recipient", ...universalAddressItem }
14025
14039
  ];
@@ -14032,7 +14046,7 @@ var namedPayloads3 = [
14032
14046
  ];
14033
14047
  registerPayloadTypes("TBTCBridge", namedPayloads3);
14034
14048
 
14035
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@3.8.5/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/executor/relayInstruction.js
14049
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0.2/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/executor/relayInstruction.js
14036
14050
  var gasInstructionLayout = [
14037
14051
  { name: "gasLimit", binary: "uint", size: 16 },
14038
14052
  { name: "msgValue", binary: "uint", size: 16 }
@@ -14061,7 +14075,7 @@ var relayInstructionsLayout = [
14061
14075
  }
14062
14076
  ];
14063
14077
 
14064
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@3.8.5/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/executor/signedQuote.js
14078
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0.2/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/executor/signedQuote.js
14065
14079
  var quoteLayout = [
14066
14080
  {
14067
14081
  name: "quote",
@@ -14104,7 +14118,7 @@ var signedQuoteLayout = [
14104
14118
  { name: "signature", binary: "bytes", size: 65 }
14105
14119
  ];
14106
14120
 
14107
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@3.8.5/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/executor/api.js
14121
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0.2/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/executor/api.js
14108
14122
  var RelayStatus;
14109
14123
  (function(RelayStatus2) {
14110
14124
  RelayStatus2["Pending"] = "pending";
@@ -14123,7 +14137,7 @@ var RequestPrefix;
14123
14137
  RequestPrefix2["ERC2"] = "ERC2";
14124
14138
  })(RequestPrefix || (RequestPrefix = {}));
14125
14139
 
14126
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@3.8.5_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-tokenbridge/dist/esm/executorTokenBridge.js
14140
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@4.0.2_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-tokenbridge/dist/esm/executorTokenBridge.js
14127
14141
  var RELAYER_ABI = [
14128
14142
  "function transferTokensWithRelay(address token, uint256 amount, uint16 targetChain, bytes32 targetRecipient, uint32 nonce, bytes32 dstTransferRecipient, bytes32 dstExecutionAddress, uint256 executionAmount, address refundAddr, bytes calldata signedQuoteBytes, bytes calldata relayInstructions) payable returns (uint64)",
14129
14143
  "function wrapAndTransferEthWithRelay(uint16 targetChain, bytes32 targetRecipient, uint32 nonce, bytes32 dstTransferRecipient, bytes32 dstExecutionAddress, uint256 executionAmount, address refundAddr, bytes calldata signedQuoteBytes, bytes calldata relayInstructions) payable returns (uint64)",
@@ -14225,6 +14239,7 @@ var EvmExecutorTokenBridge = class _EvmExecutorTokenBridge {
14225
14239
  switch (receivedToken.chain) {
14226
14240
  case "Arbitrum":
14227
14241
  case "Bsc":
14242
+ case "Monad":
14228
14243
  case "Moonbeam":
14229
14244
  gasLimit = 1000000n;
14230
14245
  break;
@@ -14242,14 +14257,14 @@ var EvmExecutorTokenBridge = class _EvmExecutorTokenBridge {
14242
14257
  }
14243
14258
  };
14244
14259
 
14245
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@3.8.5_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-tokenbridge/dist/esm/ethers-contracts/index.js
14260
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@4.0.2_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-tokenbridge/dist/esm/ethers-contracts/index.js
14246
14261
  var ethers_contracts_exports2 = {};
14247
14262
  __export(ethers_contracts_exports2, {
14248
14263
  Bridge__factory: () => Bridge__factory,
14249
14264
  TokenBridgeRelayer__factory: () => TokenBridgeRelayer__factory
14250
14265
  });
14251
14266
 
14252
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@3.8.5_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-tokenbridge/dist/esm/ethers-contracts/factories/Bridge__factory.js
14267
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@4.0.2_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-tokenbridge/dist/esm/ethers-contracts/factories/Bridge__factory.js
14253
14268
  var _abi2 = [
14254
14269
  {
14255
14270
  anonymous: false,
@@ -15489,7 +15504,7 @@ var Bridge__factory = class extends ContractFactory {
15489
15504
  }
15490
15505
  };
15491
15506
 
15492
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@3.8.5_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-tokenbridge/dist/esm/ethers-contracts/factories/TokenBridgeRelayer__factory.js
15507
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@4.0.2_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-tokenbridge/dist/esm/ethers-contracts/factories/TokenBridgeRelayer__factory.js
15493
15508
  var _abi3 = [
15494
15509
  {
15495
15510
  inputs: [
@@ -16560,7 +16575,7 @@ var TokenBridgeRelayer__factory = class extends ContractFactory {
16560
16575
  }
16561
16576
  };
16562
16577
 
16563
- // ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@3.8.5_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-tokenbridge/dist/esm/index.js
16578
+ // ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@4.0.2_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-tokenbridge/dist/esm/index.js
16564
16579
  registerProtocol2(_platform2, "TokenBridge", EvmTokenBridge);
16565
16580
  registerProtocol2(_platform2, "AutomaticTokenBridge", EvmAutomaticTokenBridge);
16566
16581
  registerProtocol2(_platform2, "ExecutorTokenBridge", EvmExecutorTokenBridge);
@@ -16755,189 +16770,34 @@ async function getExecuteTransferData({
16755
16770
 
16756
16771
  // src/getTransferData/getTransferData.ts
16757
16772
  import {
16758
- ContractConfig as ContractConfig3,
16773
+ ContractConfig as ContractConfig2,
16759
16774
  ExtrinsicConfig,
16760
- SnowbridgeConfig as SnowbridgeConfig2,
16761
16775
  WormholeConfig as WormholeConfig2
16762
16776
  } from "@moonbeam-network/xcm-builder";
16763
16777
  import {
16764
16778
  convertToChainDecimals as convertToChainDecimals2,
16765
- EvmService as EvmService4,
16779
+ EvmService as EvmService2,
16766
16780
  getDestinationData,
16767
- PolkadotService as PolkadotService3
16781
+ PolkadotService as PolkadotService2
16768
16782
  } from "@moonbeam-network/xcm-sdk";
16769
16783
  import {
16770
16784
  AssetAmount as AssetAmount3,
16771
- EvmChain as EvmChain3,
16772
- EvmParachain as EvmParachain4
16785
+ EvmChain,
16786
+ EvmParachain as EvmParachain3
16773
16787
  } from "@moonbeam-network/xcm-types";
16774
16788
  import { toBigInt as toBigInt3 } from "@moonbeam-network/xcm-utils";
16775
16789
  import Big2 from "big.js";
16776
16790
 
16777
- // src/services/snowbridge/SnowbridgeService.ts
16778
- import {
16779
- ContractConfig,
16780
- ERC20_ABI,
16781
- GATEWAY_ABI
16782
- } from "@moonbeam-network/xcm-builder";
16783
- import { EvmService as EvmService2 } from "@moonbeam-network/xcm-sdk";
16784
- import { EvmChain } from "@moonbeam-network/xcm-types";
16785
- import { u8aToHex } from "@polkadot/util";
16786
- import { decodeAddress } from "@polkadot/util-crypto";
16787
- import { encodeFunctionData } from "viem";
16788
- var SnowbridgeService = class _SnowbridgeService {
16789
- chain;
16790
- #evmService;
16791
- #gatewayAddress;
16792
- static create(chain2) {
16793
- return new _SnowbridgeService(chain2);
16794
- }
16795
- constructor(chain2) {
16796
- if (!EvmChain.is(chain2) || !chain2.contracts?.Gateway) {
16797
- throw new Error(
16798
- "Chain must be an EVMChain with the Gateway contract address configured for Snowbridge operations"
16799
- );
16800
- }
16801
- this.chain = chain2;
16802
- this.#gatewayAddress = chain2.contracts.Gateway;
16803
- this.#evmService = EvmService2.create(chain2);
16804
- }
16805
- async checkAllowance(ownerAddress, tokenAddress, spenderAddress) {
16806
- const allowance = await this.#evmService.client.readContract({
16807
- abi: ERC20_ABI,
16808
- address: tokenAddress,
16809
- args: [ownerAddress, spenderAddress],
16810
- functionName: "allowance"
16811
- });
16812
- if (typeof allowance !== "bigint") {
16813
- throw new Error(
16814
- `Could not get allowance on ${this.chain.name} for token ${tokenAddress}`
16815
- );
16816
- }
16817
- return allowance;
16818
- }
16819
- async transfer(signer, transfer) {
16820
- const { args } = transfer;
16821
- const { tokenAddress, amount, requiresApproval } = args;
16822
- if (!signer.account) {
16823
- throw new Error("Signer account is required");
16824
- }
16825
- const contract = this.buildContractConfig(transfer);
16826
- if (!requiresApproval) {
16827
- return await this.#evmService.transfer(signer, contract);
16828
- }
16829
- const currentAllowance = await this.checkAllowance(
16830
- signer.account.address,
16831
- tokenAddress,
16832
- this.#gatewayAddress
16833
- );
16834
- if (currentAllowance < amount) {
16835
- await this.approve(signer, tokenAddress, this.#gatewayAddress, amount);
16836
- }
16837
- return await this.#evmService.transfer(signer, contract);
16838
- }
16839
- buildContractConfig(transfer) {
16840
- const { args } = transfer;
16841
- const {
16842
- tokenAddress,
16843
- destinationAddress,
16844
- destinationParaId,
16845
- amount,
16846
- bridgeFeeAmount,
16847
- requiresApproval
16848
- } = args;
16849
- const value = requiresApproval ? bridgeFeeAmount : amount + bridgeFeeAmount;
16850
- const contractArgs = [
16851
- tokenAddress,
16852
- destinationParaId,
16853
- {
16854
- kind: 1,
16855
- data: u8aToHex(decodeAddress(destinationAddress))
16856
- },
16857
- 0n,
16858
- amount
16859
- ];
16860
- return new ContractConfig({
16861
- address: this.#gatewayAddress,
16862
- abi: GATEWAY_ABI,
16863
- args: contractArgs,
16864
- func: "sendToken",
16865
- value,
16866
- module: "Gateway"
16867
- });
16868
- }
16869
- async approve(signer, tokenAddress, spenderAddress, amount) {
16870
- const { request } = await this.#evmService.client.simulateContract({
16871
- abi: ERC20_ABI,
16872
- account: signer.account,
16873
- address: tokenAddress,
16874
- functionName: "approve",
16875
- args: [spenderAddress, amount]
16876
- });
16877
- const hash = await signer.writeContract(request);
16878
- await this.#evmService.client.waitForTransactionReceipt({
16879
- hash
16880
- });
16881
- return hash;
16882
- }
16883
- async getFee(address, transfer) {
16884
- const { args } = transfer;
16885
- const { tokenAddress, amount, requiresApproval } = args;
16886
- const contract = this.buildContractConfig(transfer);
16887
- if (!requiresApproval) {
16888
- return await this.#evmService.getFee(address, contract);
16889
- }
16890
- const currentAllowance = await this.checkAllowance(
16891
- address,
16892
- tokenAddress,
16893
- this.#gatewayAddress
16894
- );
16895
- if (currentAllowance >= amount) {
16896
- return await this.#evmService.getFee(address, contract);
16897
- }
16898
- return await this.estimateApproveAndSendFee(address, transfer);
16899
- }
16900
- async estimateApproveAndSendFee(address, transfer) {
16901
- const { args } = transfer;
16902
- const { tokenAddress, amount } = args;
16903
- const contract = this.buildContractConfig(transfer);
16904
- try {
16905
- const approveData = encodeFunctionData({
16906
- abi: ERC20_ABI,
16907
- functionName: "approve",
16908
- args: [this.#gatewayAddress, amount]
16909
- });
16910
- const approveGas = await this.#evmService.client.estimateGas({
16911
- account: address,
16912
- to: tokenAddress,
16913
- data: approveData
16914
- });
16915
- const sendData = encodeFunctionData({
16916
- abi: contract.abi,
16917
- functionName: contract.func,
16918
- args: contract.args
16919
- });
16920
- const sendGas = await this.#evmService.client.estimateGas({
16921
- account: address,
16922
- to: contract.address,
16923
- data: sendData,
16924
- value: contract.value
16925
- });
16926
- const gasPrice = await this.#evmService.client.getGasPrice();
16927
- return (approveGas + sendGas) * gasPrice;
16928
- } catch (error) {
16929
- console.error("Error estimating approve + send fee:", error);
16930
- return 0n;
16931
- }
16932
- }
16933
- };
16934
-
16935
- // src/getTransferData/getBridgeChainData.ts
16791
+ // src/getTransferData/getMoonChainData.ts
16792
+ import { getMoonChain } from "@moonbeam-network/xcm-config";
16936
16793
  import { getBalance, getDestinationFee } from "@moonbeam-network/xcm-sdk";
16937
- import { EvmParachain, Parachain } from "@moonbeam-network/xcm-types";
16794
+ import {
16795
+ EvmParachain,
16796
+ Parachain
16797
+ } from "@moonbeam-network/xcm-types";
16938
16798
  import { getMultilocationDerivedAddresses } from "@moonbeam-network/xcm-utils";
16939
16799
  import { evmToAddress } from "@polkadot/util-crypto";
16940
- async function getBridgeChainData({
16800
+ async function getMoonChainData({
16941
16801
  route,
16942
16802
  sourceAddress,
16943
16803
  destinationAddress
@@ -16947,86 +16807,80 @@ async function getBridgeChainData({
16947
16807
  `MRL config is not defined for source chain ${route.source.chain.name} and asset ${route.source.asset.originSymbol}`
16948
16808
  );
16949
16809
  }
16950
- const bridgeChain = route.mrl.bridgeChain.chain;
16951
- const bridgeChainAddress = getBridgeChainAddress({
16952
- route,
16810
+ const moonChain = getMoonChain(route.source.chain);
16811
+ const moonChainAddress = getMoonChainAddress({
16812
+ source: route.source.chain,
16813
+ destination: route.destination.chain,
16953
16814
  sourceAddress,
16954
16815
  destinationAddress
16955
16816
  });
16956
16817
  const fee = await getDestinationFee({
16957
- address: bridgeChainAddress,
16818
+ address: moonChainAddress,
16958
16819
  asset: route.source.asset,
16959
- destination: bridgeChain,
16960
- fee: route.mrl.bridgeChain.fee.amount,
16961
- feeAsset: route.mrl.bridgeChain.fee.asset,
16820
+ destination: moonChain,
16821
+ fee: route.mrl.moonChain.fee.amount,
16822
+ feeAsset: route.mrl.moonChain.fee.asset,
16962
16823
  source: route.source.chain
16963
16824
  });
16964
16825
  const balance = await getBalance({
16965
- address: bridgeChainAddress,
16966
- asset: bridgeChain.getChainAsset(route.mrl.bridgeChain.asset),
16967
- builder: route.mrl.bridgeChain.balance,
16968
- chain: bridgeChain
16826
+ address: moonChainAddress,
16827
+ asset: moonChain.getChainAsset(route.mrl.moonChain.asset),
16828
+ builder: route.mrl.moonChain.balance,
16829
+ chain: moonChain
16969
16830
  });
16970
16831
  const feeBalance = await getBalance({
16971
- address: bridgeChainAddress,
16972
- asset: bridgeChain.getChainAsset(route.mrl.bridgeChain.fee.asset),
16973
- builder: route.mrl.bridgeChain.fee.balance,
16974
- chain: bridgeChain
16832
+ address: moonChainAddress,
16833
+ asset: moonChain.getChainAsset(route.mrl.moonChain.fee.asset),
16834
+ builder: route.mrl.moonChain.fee.balance,
16835
+ chain: moonChain
16975
16836
  });
16976
16837
  return {
16977
- address: bridgeChainAddress,
16838
+ address: moonChainAddress,
16978
16839
  balance,
16979
16840
  feeBalance,
16980
- chain: bridgeChain,
16841
+ chain: moonChain,
16981
16842
  fee
16982
16843
  };
16983
16844
  }
16984
- function getBridgeChainAddress({
16985
- route,
16845
+ function getMoonChainAddress({
16846
+ source,
16847
+ destination,
16986
16848
  sourceAddress,
16987
16849
  destinationAddress
16988
16850
  }) {
16989
- const source = route.source.chain;
16990
- const destination = route.destination.chain;
16991
- const bridgeChain = route.mrl.bridgeChain.chain;
16992
- const isDestinationBridgeChain = bridgeChain.isEqual(destination);
16993
- const isSourceBridgeChain = bridgeChain.isEqual(source);
16994
- let bridgeChainAddress = isDestinationBridgeChain ? destinationAddress : sourceAddress;
16995
- if (Parachain.is(source) && !isSourceBridgeChain) {
16851
+ const moonChain = getMoonChain(source);
16852
+ const isDestinationMoonChain = moonChain.isEqual(destination);
16853
+ const isSourceMoonChain = moonChain.isEqual(source);
16854
+ let moonChainAddress = isDestinationMoonChain ? destinationAddress : sourceAddress;
16855
+ if (Parachain.is(source) && !isSourceMoonChain) {
16996
16856
  const isSourceEvmSigner = EvmParachain.is(source) && source.isEvmSigner;
16997
16857
  const { address20: computedOriginAccount } = getMultilocationDerivedAddresses({
16998
16858
  address: isSourceEvmSigner ? evmToAddress(sourceAddress) : sourceAddress,
16999
16859
  paraId: source.parachainId,
17000
16860
  isParents: true
17001
16861
  });
17002
- bridgeChainAddress = computedOriginAccount;
16862
+ moonChainAddress = computedOriginAccount;
17003
16863
  }
17004
- return bridgeChainAddress;
16864
+ return moonChainAddress;
17005
16865
  }
17006
16866
 
17007
16867
  // src/getTransferData/getSourceData.ts
17008
16868
  import {
17009
- ContractConfig as ContractConfig2,
16869
+ ContractConfig,
17010
16870
  MrlBuilder as MrlBuilder3,
17011
- SnowbridgeConfig,
17012
- SubstrateQueryConfig,
17013
16871
  WormholeConfig
17014
16872
  } from "@moonbeam-network/xcm-builder";
17015
16873
  import {
17016
- EvmService as EvmService3,
17017
16874
  getAssetMin,
17018
16875
  getBalance as getBalance2,
17019
16876
  getContractFee,
17020
16877
  getDestinationFeeBalance,
17021
16878
  getExistentialDeposit,
17022
16879
  getExtrinsicFee,
17023
- getMax,
17024
- PolkadotService as PolkadotService2
16880
+ getMax
17025
16881
  } from "@moonbeam-network/xcm-sdk";
17026
16882
  import {
17027
- AssetAmount as AssetAmount2,
17028
- EvmChain as EvmChain2,
17029
- EvmParachain as EvmParachain3
16883
+ AssetAmount as AssetAmount2
17030
16884
  } from "@moonbeam-network/xcm-types";
17031
16885
  import { toBigInt as toBigInt2 } from "@moonbeam-network/xcm-utils";
17032
16886
 
@@ -17034,12 +16888,14 @@ import { toBigInt as toBigInt2 } from "@moonbeam-network/xcm-utils";
17034
16888
  import {
17035
16889
  BATCH_CONTRACT_ABI,
17036
16890
  BATCH_CONTRACT_ADDRESS,
17037
- ERC20_ABI as ERC20_ABI2,
16891
+ ERC20_ABI,
17038
16892
  MrlBuilder as MrlBuilder2
17039
16893
  } from "@moonbeam-network/xcm-builder";
17040
16894
  import {
16895
+ getMoonChain as getMoonChain2,
17041
16896
  moonbaseAlpha,
17042
- moonbeam
16897
+ moonbeam,
16898
+ moonriver
17043
16899
  } from "@moonbeam-network/xcm-config";
17044
16900
  import {
17045
16901
  convertToChainDecimals,
@@ -17054,33 +16910,34 @@ import {
17054
16910
  import Big from "big.js";
17055
16911
  import {
17056
16912
  createPublicClient as createPublicClient2,
17057
- encodeFunctionData as encodeFunctionData2,
16913
+ encodeFunctionData,
17058
16914
  http as http2
17059
16915
  } from "viem";
17060
16916
  var MOON_CHAIN_AUTOMATIC_GAS_ESTIMATION = {
17061
16917
  [moonbeam.key]: 1273110n,
16918
+ [moonriver.key]: 1273110n,
17062
16919
  [moonbaseAlpha.key]: 1470417n
17063
16920
  };
17064
- function getBridgeChainFeeValueOnSource({
16921
+ function getMoonChainFeeValueOnSource({
17065
16922
  destinationData,
17066
- bridgeChainData,
16923
+ moonChainData,
17067
16924
  sourceData
17068
16925
  }) {
17069
16926
  const isSourceParachain = EvmParachain2.isAnyParachain(sourceData.chain);
17070
- const isDestinationBridgeChain = destinationData.chain.isEqual(
17071
- bridgeChainData.chain
16927
+ const isDestinationMoonChain = destinationData.chain.isEqual(
16928
+ moonChainData.chain
17072
16929
  );
17073
- const isSameAssetPayingBridgeChainFee = sourceData.balance.isSame(
17074
- bridgeChainData.fee
16930
+ const isSameAssetPayingMoonChainFee = sourceData.balance.isSame(
16931
+ moonChainData.fee
17075
16932
  );
17076
- return !isDestinationBridgeChain && isSourceParachain && isSameAssetPayingBridgeChainFee ? convertToChainDecimals({
17077
- asset: bridgeChainData.fee,
17078
- target: sourceData.chain.getChainAsset(bridgeChainData.fee)
16933
+ return !isDestinationMoonChain && isSourceParachain && isSameAssetPayingMoonChainFee ? convertToChainDecimals({
16934
+ asset: moonChainData.fee,
16935
+ target: sourceData.chain.getChainAsset(moonChainData.fee)
17079
16936
  }).toBig() : Big(0);
17080
16937
  }
17081
16938
  function getMrlMin({
17082
16939
  destinationData,
17083
- bridgeChainData,
16940
+ moonChainData,
17084
16941
  sourceData
17085
16942
  }) {
17086
16943
  const minInDestination = getMin(destinationData);
@@ -17090,19 +16947,16 @@ function getMrlMin({
17090
16947
  amount: minInDestination.amount
17091
16948
  }
17092
16949
  );
17093
- const bridgeChainFee = getBridgeChainFeeValueOnSource({
16950
+ const moonChainFee = getMoonChainFeeValueOnSource({
17094
16951
  destinationData,
17095
- bridgeChainData,
16952
+ moonChainData,
17096
16953
  sourceData
17097
16954
  });
17098
- const relayerFee = sourceData.otherFees?.relayer?.amount ? sourceData.otherFees.relayer.toBig() : Big(0);
16955
+ const relayerFee = sourceData.relayerFee?.amount ? sourceData.relayerFee.toBig() : Big(0);
17099
16956
  return min.copyWith({
17100
- amount: BigInt(min.toBig().add(bridgeChainFee).add(relayerFee).toFixed())
16957
+ amount: BigInt(min.toBig().add(moonChainFee).add(relayerFee).toFixed())
17101
16958
  });
17102
16959
  }
17103
- function requiresTransact(route) {
17104
- return route.mrl?.transfer.provider === "wormhole" && EvmParachain2.isAnyParachain(route.source.chain);
17105
- }
17106
16960
  async function buildTransfer(params) {
17107
16961
  const { route } = params;
17108
16962
  if (!route.mrl) {
@@ -17118,12 +16972,11 @@ async function buildTransfer(params) {
17118
16972
  const builderParams = await getMrlBuilderParams(params);
17119
16973
  return route.mrl.transfer.build({
17120
16974
  ...builderParams,
17121
- transact: requiresTransact(route) ? await getTransact(builderParams) : void 0
16975
+ transact: EvmParachain2.isAnyParachain(route.source.chain) ? await getTransact(builderParams) : void 0
17122
16976
  });
17123
16977
  }
17124
16978
  async function getMrlBuilderParams({
17125
16979
  asset,
17126
- protocolFee,
17127
16980
  destinationAddress,
17128
16981
  feeAsset,
17129
16982
  isAutomatic,
@@ -17138,23 +16991,22 @@ async function getMrlBuilderParams({
17138
16991
  }
17139
16992
  const source = route.source.chain;
17140
16993
  const destination = route.destination.chain;
17141
- const bridgeChain = route.mrl.bridgeChain.chain;
17142
- const [sourceApi, destinationApi, bridgeApi] = await Promise.all([
16994
+ const moonChain = getMoonChain2(source);
16995
+ const [sourceApi, destinationApi, moonApi] = await Promise.all([
17143
16996
  EvmParachain2.isAnyParachain(source) ? getPolkadotApi(source.ws) : void 0,
17144
16997
  EvmParachain2.isAnyParachain(destination) ? getPolkadotApi(destination.ws) : void 0,
17145
- getPolkadotApi(bridgeChain.ws)
16998
+ getPolkadotApi(moonChain.ws)
17146
16999
  ]);
17147
17000
  return {
17148
17001
  asset,
17149
- protocolFee,
17150
17002
  destination,
17151
17003
  destinationAddress,
17152
17004
  destinationApi,
17153
17005
  fee: feeAsset,
17154
17006
  isAutomatic,
17155
- moonApi: bridgeApi,
17156
- moonAsset: bridgeChain.nativeAsset,
17157
- bridgeChain,
17007
+ moonApi,
17008
+ moonAsset: moonChain.nativeAsset,
17009
+ moonChain,
17158
17010
  sendOnlyRemoteExecution,
17159
17011
  source,
17160
17012
  sourceAddress,
@@ -17162,9 +17014,9 @@ async function getMrlBuilderParams({
17162
17014
  };
17163
17015
  }
17164
17016
  async function getTransact(params) {
17165
- const { sourceAddress, source, bridgeChain } = params;
17166
- const polkadot = await PolkadotService.create(bridgeChain);
17167
- const bridgeChainGasLimit = await getBridgeChainGasLimit(params);
17017
+ const { sourceAddress, source, moonChain } = params;
17018
+ const polkadot = await PolkadotService.create(moonChain);
17019
+ const moonGasLimit = await getMoonGasLimit(params);
17168
17020
  if (!EvmParachain2.isAnyParachain(source)) {
17169
17021
  throw new Error("Source chain must be Parachain or EvmParachain");
17170
17022
  }
@@ -17173,8 +17025,9 @@ async function getTransact(params) {
17173
17025
  paraId: source.parachainId,
17174
17026
  isParents: true
17175
17027
  });
17176
- const extrinsic = MrlBuilder2().wormhole().extrinsic().ethereumXcm().transact().build({ ...params, bridgeChainGasLimit });
17028
+ const extrinsic = MrlBuilder2().wormhole().extrinsic().ethereumXcm().transact().build({ ...params, moonGasLimit });
17177
17029
  const { weight } = await polkadot.getPaymentInfo(address20, extrinsic);
17030
+ console.log("extrinsic", extrinsic.getArgs());
17178
17031
  return {
17179
17032
  call: polkadot.getExtrinsicCallHash(extrinsic),
17180
17033
  txWeight: {
@@ -17183,16 +17036,13 @@ async function getTransact(params) {
17183
17036
  }
17184
17037
  };
17185
17038
  }
17186
- async function getBridgeChainGasLimit(params) {
17187
- const { asset, isAutomatic, bridgeChain, source, sourceAddress } = params;
17039
+ async function getMoonGasLimit(params) {
17040
+ const { asset, isAutomatic, moonChain, source, sourceAddress } = params;
17188
17041
  if (!EvmParachain2.isAnyParachain(source)) {
17189
17042
  throw new Error("Source chain must be Parachain or EvmParachain");
17190
17043
  }
17191
- if (!EvmParachain2.is(bridgeChain)) {
17192
- throw new Error("Bridge chain must be an EvmParachain");
17193
- }
17194
17044
  const client = createPublicClient2({
17195
- chain: bridgeChain.getViemChain(),
17045
+ chain: moonChain.getViemChain(),
17196
17046
  transport: http2()
17197
17047
  });
17198
17048
  const { address20 } = getMultilocationDerivedAddresses2({
@@ -17201,28 +17051,28 @@ async function getBridgeChainGasLimit(params) {
17201
17051
  isParents: true
17202
17052
  });
17203
17053
  if (isAutomatic) {
17204
- return MOON_CHAIN_AUTOMATIC_GAS_ESTIMATION[bridgeChain.key] * 110n / 100n;
17054
+ return MOON_CHAIN_AUTOMATIC_GAS_ESTIMATION[moonChain.key] * 110n / 100n;
17205
17055
  }
17206
17056
  const contract = MrlBuilder2().wormhole().contract().TokenBridge().transferTokens().build({
17207
17057
  ...params,
17208
17058
  asset: asset.copyWith({ amount: 0n })
17209
17059
  });
17210
- const approveTx = encodeFunctionData2({
17211
- abi: ERC20_ABI2,
17060
+ const approveTx = encodeFunctionData({
17061
+ abi: ERC20_ABI,
17212
17062
  functionName: "approve",
17213
17063
  args: [contract.address, 0n]
17214
17064
  });
17215
- const tokenAddressOnBridgeChain = bridgeChain.getChainAsset(asset).address;
17216
- if (!tokenAddressOnBridgeChain) {
17065
+ const tokenAddressOnMoonChain = moonChain.getChainAsset(asset).address;
17066
+ if (!tokenAddressOnMoonChain) {
17217
17067
  throw new Error(
17218
- `Asset ${asset.symbol} does not have a token address on chain ${bridgeChain.name}`
17068
+ `Asset ${asset.symbol} does not have a token address on chain ${moonChain.name}`
17219
17069
  );
17220
17070
  }
17221
- const batchAll = encodeFunctionData2({
17071
+ const batchAll = encodeFunctionData({
17222
17072
  abi: BATCH_CONTRACT_ABI,
17223
17073
  functionName: "batchAll",
17224
17074
  args: [
17225
- [tokenAddressOnBridgeChain, contract.address],
17075
+ [tokenAddressOnMoonChain, contract.address],
17226
17076
  [0n, 0n],
17227
17077
  // Value to send for each call
17228
17078
  [approveTx, contract.encodeFunctionData()],
@@ -17253,7 +17103,6 @@ async function getSourceData({
17253
17103
  );
17254
17104
  }
17255
17105
  const source = route.source.chain;
17256
- const destination = route.destination.chain;
17257
17106
  const asset = source.getChainAsset(route.source.asset);
17258
17107
  const feeAsset = route.source.fee ? source.getChainAsset(route.source.fee.asset) : asset;
17259
17108
  const balance = await getBalance2({
@@ -17274,7 +17123,7 @@ async function getSourceData({
17274
17123
  route,
17275
17124
  sourceAddress
17276
17125
  });
17277
- const bridgeChainFeeBalance = await getBridgeChainFeeBalance({
17126
+ const moonChainFeeBalance = await getMoonChainFeeBalance({
17278
17127
  balance,
17279
17128
  feeBalance,
17280
17129
  route,
@@ -17286,19 +17135,8 @@ async function getSourceData({
17286
17135
  builder: route.source.min,
17287
17136
  chain: source
17288
17137
  });
17289
- const protocolFee = await getProtocolFee({
17290
- source,
17291
- destination,
17292
- // For now, the fee asset is always the one used for the protocol fee
17293
- // If it where to change, we need make protocolFee a FeeConfig in MrlSourceConfig
17294
- asset: feeAsset,
17295
- balance,
17296
- protocolFee: route.source.protocolFee,
17297
- address: destinationAddress
17298
- });
17299
17138
  const transfer = await buildTransfer({
17300
- asset: balance.copyWith({ amount: balance.amount - protocolFee.amount }),
17301
- protocolFee,
17139
+ asset: balance,
17302
17140
  destinationAddress,
17303
17141
  feeAsset: feeBalance,
17304
17142
  isAutomatic,
@@ -17335,16 +17173,13 @@ async function getSourceData({
17335
17173
  chain: source,
17336
17174
  destinationFee,
17337
17175
  destinationFeeBalance,
17338
- bridgeChainFeeBalance,
17176
+ moonChainFeeBalance,
17339
17177
  existentialDeposit,
17340
17178
  fee,
17341
17179
  feeBalance,
17342
17180
  max,
17343
17181
  min,
17344
- otherFees: {
17345
- protocol: protocolFee,
17346
- relayer: relayerFee?.amount ? relayerFee : void 0
17347
- }
17182
+ relayerFee
17348
17183
  };
17349
17184
  }
17350
17185
  async function getFee({
@@ -17361,29 +17196,17 @@ async function getFee({
17361
17196
  amount: 0n
17362
17197
  });
17363
17198
  }
17364
- if (SnowbridgeConfig.is(transfer)) {
17365
- const snowbridge = SnowbridgeService.create(chain2);
17366
- const feeAmount = await snowbridge.getFee(sourceAddress, transfer);
17367
- return AssetAmount2.fromChainAsset(chain2.getChainAsset(feeBalance), {
17368
- amount: feeAmount
17199
+ if (ContractConfig.is(transfer)) {
17200
+ return getContractFee({
17201
+ address: sourceAddress,
17202
+ balance,
17203
+ chain: chain2,
17204
+ contract: transfer,
17205
+ destinationFee,
17206
+ feeBalance,
17207
+ feeConfig
17369
17208
  });
17370
17209
  }
17371
- if (ContractConfig2.is(transfer)) {
17372
- try {
17373
- return getContractFee({
17374
- address: sourceAddress,
17375
- balance,
17376
- chain: chain2,
17377
- contract: transfer,
17378
- destinationFee,
17379
- feeBalance,
17380
- feeConfig
17381
- });
17382
- } catch (error) {
17383
- console.error(error);
17384
- return feeBalance.copyWith({ amount: 0n });
17385
- }
17386
- }
17387
17210
  return getExtrinsicFee({
17388
17211
  address: sourceAddress,
17389
17212
  balance,
@@ -17403,25 +17226,19 @@ async function getRelayerFee({
17403
17226
  sourceAddress,
17404
17227
  transfer
17405
17228
  }) {
17406
- if (route.mrl.transfer.provider === "snowbridge" || SnowbridgeConfig.is(transfer)) {
17407
- return void 0;
17408
- }
17409
17229
  if (WormholeConfig.is(transfer)) {
17410
17230
  return getWormholeFee({ asset, chain: chain2, config: transfer });
17411
17231
  }
17412
- if (route.mrl.transfer.provider === "wormhole") {
17413
- const builderParams = await getMrlBuilderParams({
17414
- asset,
17415
- destinationAddress,
17416
- feeAsset,
17417
- isAutomatic,
17418
- route,
17419
- sourceAddress
17420
- });
17421
- const wormholeConfig = MrlBuilder3().wormhole().wormhole().tokenTransfer().build(builderParams);
17422
- return getWormholeFee({ asset, chain: chain2, config: wormholeConfig });
17423
- }
17424
- return;
17232
+ const builderParams = await getMrlBuilderParams({
17233
+ asset,
17234
+ destinationAddress,
17235
+ feeAsset,
17236
+ isAutomatic,
17237
+ route,
17238
+ sourceAddress
17239
+ });
17240
+ const wormholeConfig = MrlBuilder3().wormhole().wormhole().tokenTransfer().build(builderParams);
17241
+ return getWormholeFee({ asset, chain: chain2, config: wormholeConfig });
17425
17242
  }
17426
17243
  async function getWormholeFee({
17427
17244
  asset,
@@ -17438,76 +17255,33 @@ async function getWormholeFee({
17438
17255
  }
17439
17256
  return;
17440
17257
  }
17441
- async function getBridgeChainFeeBalance({
17258
+ async function getMoonChainFeeBalance({
17442
17259
  balance,
17443
17260
  feeBalance,
17444
17261
  route,
17445
17262
  sourceAddress
17446
17263
  }) {
17447
- if (!route.source.bridgeChainFee) {
17264
+ if (!route.source.moonChainFee) {
17448
17265
  return void 0;
17449
17266
  }
17450
- if (route.mrl?.bridgeChain.fee.asset.isEqual(balance)) {
17267
+ if (route.mrl?.moonChain.fee.asset.isEqual(balance)) {
17451
17268
  return balance;
17452
17269
  }
17453
- if (route.mrl?.bridgeChain.fee.asset.isEqual(feeBalance)) {
17270
+ if (route.mrl?.moonChain.fee.asset.isEqual(feeBalance)) {
17454
17271
  return feeBalance;
17455
17272
  }
17456
- if (!route.source.bridgeChainFee.balance) {
17273
+ if (!route.source.moonChainFee.balance) {
17457
17274
  throw new Error(
17458
- "BalanceBuilder must be defined for source.bridgeChainFee.balance for MrlAssetRoute"
17275
+ "BalanceBuilder must be defined for source.moonChainFee.balance for MrlAssetRoute"
17459
17276
  );
17460
17277
  }
17461
17278
  return getBalance2({
17462
17279
  address: sourceAddress,
17463
- asset: route.source.chain.getChainAsset(route.source.bridgeChainFee.asset),
17464
- builder: route.source.bridgeChainFee.balance,
17280
+ asset: route.source.chain.getChainAsset(route.source.moonChainFee.asset),
17281
+ builder: route.source.moonChainFee.balance,
17465
17282
  chain: route.source.chain
17466
17283
  });
17467
17284
  }
17468
- async function getProtocolFee({
17469
- address,
17470
- asset,
17471
- balance,
17472
- protocolFee,
17473
- destination,
17474
- source
17475
- }) {
17476
- if (typeof protocolFee === "number") {
17477
- return AssetAmount2.fromChainAsset(asset, {
17478
- amount: protocolFee
17479
- });
17480
- }
17481
- const config = protocolFee?.build({
17482
- address,
17483
- asset,
17484
- balance,
17485
- destination,
17486
- source
17487
- });
17488
- if (ContractConfig2.is(config) && EvmChain2.is(source)) {
17489
- const evm = EvmService3.create(source);
17490
- const amount = await evm.read(config);
17491
- if (typeof amount !== "bigint") {
17492
- throw new Error(
17493
- `Error getting bridge fee: expected bigint from contract call, but received ${typeof amount}. `
17494
- );
17495
- }
17496
- return AssetAmount2.fromChainAsset(asset, {
17497
- amount
17498
- });
17499
- }
17500
- if (SubstrateQueryConfig.is(config) && EvmParachain3.isAnyParachain(source)) {
17501
- const polkadot = await PolkadotService2.create(source);
17502
- const amount = await polkadot.query(config);
17503
- return AssetAmount2.fromChainAsset(asset, {
17504
- amount
17505
- });
17506
- }
17507
- return AssetAmount2.fromChainAsset(source.getChainAsset(asset), {
17508
- amount: 0n
17509
- });
17510
- }
17511
17285
 
17512
17286
  // src/getTransferData/getTransferData.ts
17513
17287
  async function getTransferData({
@@ -17536,7 +17310,7 @@ async function getTransferData({
17536
17310
  destinationFee,
17537
17311
  sourceAddress
17538
17312
  });
17539
- const bridgeChainData = await getBridgeChainData({
17313
+ const moonChainData = await getMoonChainData({
17540
17314
  route,
17541
17315
  sourceAddress,
17542
17316
  destinationAddress
@@ -17548,14 +17322,14 @@ async function getTransferData({
17548
17322
  const bigAmount = Big2(
17549
17323
  toBigInt3(amount, sourceData.balance.decimals).toString()
17550
17324
  );
17551
- const fee = getBridgeChainFeeValueOnSource({
17325
+ const fee = getMoonChainFeeValueOnSource({
17552
17326
  destinationData,
17553
- bridgeChainData,
17327
+ moonChainData,
17554
17328
  sourceData
17555
17329
  });
17556
17330
  const result = bigAmount.minus(
17557
17331
  isSameAssetPayingDestinationFee ? destinationFee.toBig() : Big2(0)
17558
- ).minus(fee).minus(sourceData.otherFees?.relayer?.toBig() || Big2(0));
17332
+ ).minus(fee).minus(sourceData.relayerFee?.toBig() || Big2(0));
17559
17333
  return sourceData.balance.copyWith({
17560
17334
  amount: result.lt(0) ? 0n : BigInt(result.toFixed())
17561
17335
  });
@@ -17564,10 +17338,10 @@ async function getTransferData({
17564
17338
  max: sourceData.max,
17565
17339
  min: getMrlMin({
17566
17340
  destinationData,
17567
- bridgeChainData,
17341
+ moonChainData,
17568
17342
  sourceData
17569
17343
  }),
17570
- bridgeChain: bridgeChainData,
17344
+ moonChain: moonChainData,
17571
17345
  source: sourceData,
17572
17346
  async transfer({
17573
17347
  amount,
@@ -17590,7 +17364,6 @@ async function getTransferData({
17590
17364
  );
17591
17365
  const transfer = await buildTransfer({
17592
17366
  asset,
17593
- protocolFee: sourceData.otherFees?.protocol,
17594
17367
  destinationAddress,
17595
17368
  feeAsset,
17596
17369
  isAutomatic: isAutomatic2,
@@ -17598,19 +17371,19 @@ async function getTransferData({
17598
17371
  sendOnlyRemoteExecution,
17599
17372
  sourceAddress
17600
17373
  });
17601
- if (ContractConfig3.is(transfer) && (EvmChain3.is(source) || EvmParachain4.is(source))) {
17374
+ if (ContractConfig2.is(transfer) && (EvmChain.is(source) || EvmParachain3.is(source))) {
17602
17375
  if (!evmSigner) {
17603
17376
  throw new Error("EVM Signer must be provided");
17604
17377
  }
17605
- const evm = EvmService4.create(source);
17378
+ const evm = EvmService2.create(source);
17606
17379
  const hash = await evm.transfer(evmSigner, transfer);
17607
17380
  return [hash];
17608
17381
  }
17609
- if (ExtrinsicConfig.is(transfer) && EvmParachain4.isAnyParachain(source)) {
17382
+ if (ExtrinsicConfig.is(transfer) && EvmParachain3.isAnyParachain(source)) {
17610
17383
  if (!polkadotSigner) {
17611
17384
  throw new Error("Polkadot signer must be provided");
17612
17385
  }
17613
- const polkadot = await PolkadotService3.create(source);
17386
+ const polkadot = await PolkadotService2.create(source);
17614
17387
  const hash = await polkadot.transfer(
17615
17388
  sourceAddress,
17616
17389
  transfer,
@@ -17619,21 +17392,13 @@ async function getTransferData({
17619
17392
  );
17620
17393
  return [hash];
17621
17394
  }
17622
- if (WormholeConfig2.is(transfer) && (EvmChain3.is(source) || EvmParachain4.is(source))) {
17395
+ if (WormholeConfig2.is(transfer) && (EvmChain.is(source) || EvmParachain3.is(source))) {
17623
17396
  if (!evmSigner) {
17624
17397
  throw new Error("EVM Signer must be provided");
17625
17398
  }
17626
17399
  const wh = WormholeService.create(source);
17627
17400
  return wh.transfer(evmSigner, transfer);
17628
17401
  }
17629
- if (SnowbridgeConfig2.is(transfer) && (EvmChain3.is(source) || EvmParachain4.is(source))) {
17630
- if (!evmSigner) {
17631
- throw new Error("EVM Signer must be provided");
17632
- }
17633
- const snowbridge = SnowbridgeService.create(source);
17634
- const hash = await snowbridge.transfer(evmSigner, transfer);
17635
- return [hash];
17636
- }
17637
17402
  throw new Error("Either contract or extrinsic must be provided");
17638
17403
  }
17639
17404
  };