@moonbeam-network/mrl 4.0.22 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.d.ts +13 -7
- package/build/index.mjs +466 -185
- package/build/index.mjs.map +1 -1
- package/package.json +14 -14
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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.
|
|
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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@
|
|
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,34 +16770,189 @@ async function getExecuteTransferData({
|
|
|
16755
16770
|
|
|
16756
16771
|
// src/getTransferData/getTransferData.ts
|
|
16757
16772
|
import {
|
|
16758
|
-
ContractConfig as
|
|
16773
|
+
ContractConfig as ContractConfig3,
|
|
16759
16774
|
ExtrinsicConfig,
|
|
16775
|
+
SnowbridgeConfig as SnowbridgeConfig2,
|
|
16760
16776
|
WormholeConfig as WormholeConfig2
|
|
16761
16777
|
} from "@moonbeam-network/xcm-builder";
|
|
16762
16778
|
import {
|
|
16763
16779
|
convertToChainDecimals as convertToChainDecimals2,
|
|
16764
|
-
EvmService as
|
|
16780
|
+
EvmService as EvmService4,
|
|
16765
16781
|
getDestinationData,
|
|
16766
|
-
PolkadotService as
|
|
16782
|
+
PolkadotService as PolkadotService3
|
|
16767
16783
|
} from "@moonbeam-network/xcm-sdk";
|
|
16768
16784
|
import {
|
|
16769
16785
|
AssetAmount as AssetAmount3,
|
|
16770
|
-
EvmChain,
|
|
16771
|
-
EvmParachain as
|
|
16786
|
+
EvmChain as EvmChain3,
|
|
16787
|
+
EvmParachain as EvmParachain4
|
|
16772
16788
|
} from "@moonbeam-network/xcm-types";
|
|
16773
16789
|
import { toBigInt as toBigInt3 } from "@moonbeam-network/xcm-utils";
|
|
16774
16790
|
import Big2 from "big.js";
|
|
16775
16791
|
|
|
16776
|
-
// src/
|
|
16777
|
-
import { getMoonChain } from "@moonbeam-network/xcm-config";
|
|
16778
|
-
import { getBalance, getDestinationFee } from "@moonbeam-network/xcm-sdk";
|
|
16792
|
+
// src/services/snowbridge/SnowbridgeService.ts
|
|
16779
16793
|
import {
|
|
16780
|
-
|
|
16781
|
-
|
|
16782
|
-
|
|
16794
|
+
ContractConfig,
|
|
16795
|
+
ERC20_ABI,
|
|
16796
|
+
GATEWAY_ABI
|
|
16797
|
+
} from "@moonbeam-network/xcm-builder";
|
|
16798
|
+
import { EvmService as EvmService2 } from "@moonbeam-network/xcm-sdk";
|
|
16799
|
+
import { EvmChain } from "@moonbeam-network/xcm-types";
|
|
16800
|
+
import { u8aToHex } from "@polkadot/util";
|
|
16801
|
+
import { decodeAddress } from "@polkadot/util-crypto";
|
|
16802
|
+
import { encodeFunctionData } from "viem";
|
|
16803
|
+
var SnowbridgeService = class _SnowbridgeService {
|
|
16804
|
+
chain;
|
|
16805
|
+
#evmService;
|
|
16806
|
+
#gatewayAddress;
|
|
16807
|
+
static create(chain2) {
|
|
16808
|
+
return new _SnowbridgeService(chain2);
|
|
16809
|
+
}
|
|
16810
|
+
constructor(chain2) {
|
|
16811
|
+
if (!EvmChain.is(chain2) || !chain2.contracts?.Gateway) {
|
|
16812
|
+
throw new Error(
|
|
16813
|
+
"Chain must be an EVMChain with the Gateway contract address configured for Snowbridge operations"
|
|
16814
|
+
);
|
|
16815
|
+
}
|
|
16816
|
+
this.chain = chain2;
|
|
16817
|
+
this.#gatewayAddress = chain2.contracts.Gateway;
|
|
16818
|
+
this.#evmService = EvmService2.create(chain2);
|
|
16819
|
+
}
|
|
16820
|
+
async checkAllowance(ownerAddress, tokenAddress, spenderAddress) {
|
|
16821
|
+
const allowance = await this.#evmService.client.readContract({
|
|
16822
|
+
abi: ERC20_ABI,
|
|
16823
|
+
address: tokenAddress,
|
|
16824
|
+
args: [ownerAddress, spenderAddress],
|
|
16825
|
+
functionName: "allowance"
|
|
16826
|
+
});
|
|
16827
|
+
if (typeof allowance !== "bigint") {
|
|
16828
|
+
throw new Error(
|
|
16829
|
+
`Could not get allowance on ${this.chain.name} for token ${tokenAddress}`
|
|
16830
|
+
);
|
|
16831
|
+
}
|
|
16832
|
+
return allowance;
|
|
16833
|
+
}
|
|
16834
|
+
async transfer(signer, transfer) {
|
|
16835
|
+
const { args } = transfer;
|
|
16836
|
+
const { tokenAddress, amount, requiresApproval } = args;
|
|
16837
|
+
if (!signer.account) {
|
|
16838
|
+
throw new Error("Signer account is required");
|
|
16839
|
+
}
|
|
16840
|
+
const contract = this.buildContractConfig(transfer);
|
|
16841
|
+
if (!requiresApproval) {
|
|
16842
|
+
return await this.#evmService.transfer(signer, contract);
|
|
16843
|
+
}
|
|
16844
|
+
const currentAllowance = await this.checkAllowance(
|
|
16845
|
+
signer.account.address,
|
|
16846
|
+
tokenAddress,
|
|
16847
|
+
this.#gatewayAddress
|
|
16848
|
+
);
|
|
16849
|
+
if (currentAllowance < amount) {
|
|
16850
|
+
await this.approve(signer, tokenAddress, this.#gatewayAddress, amount);
|
|
16851
|
+
}
|
|
16852
|
+
return await this.#evmService.transfer(signer, contract);
|
|
16853
|
+
}
|
|
16854
|
+
buildContractConfig(transfer) {
|
|
16855
|
+
const { args } = transfer;
|
|
16856
|
+
const {
|
|
16857
|
+
tokenAddress,
|
|
16858
|
+
destinationAddress,
|
|
16859
|
+
destinationParaId,
|
|
16860
|
+
amount,
|
|
16861
|
+
bridgeFeeAmount,
|
|
16862
|
+
requiresApproval
|
|
16863
|
+
} = args;
|
|
16864
|
+
const value = requiresApproval ? bridgeFeeAmount : amount + bridgeFeeAmount;
|
|
16865
|
+
const contractArgs = [
|
|
16866
|
+
tokenAddress,
|
|
16867
|
+
destinationParaId,
|
|
16868
|
+
{
|
|
16869
|
+
kind: 1,
|
|
16870
|
+
data: u8aToHex(decodeAddress(destinationAddress))
|
|
16871
|
+
},
|
|
16872
|
+
0n,
|
|
16873
|
+
amount
|
|
16874
|
+
];
|
|
16875
|
+
return new ContractConfig({
|
|
16876
|
+
address: this.#gatewayAddress,
|
|
16877
|
+
abi: GATEWAY_ABI,
|
|
16878
|
+
args: contractArgs,
|
|
16879
|
+
func: "sendToken",
|
|
16880
|
+
value,
|
|
16881
|
+
module: "Gateway"
|
|
16882
|
+
});
|
|
16883
|
+
}
|
|
16884
|
+
async approve(signer, tokenAddress, spenderAddress, amount) {
|
|
16885
|
+
const { request } = await this.#evmService.client.simulateContract({
|
|
16886
|
+
abi: ERC20_ABI,
|
|
16887
|
+
account: signer.account,
|
|
16888
|
+
address: tokenAddress,
|
|
16889
|
+
functionName: "approve",
|
|
16890
|
+
args: [spenderAddress, amount]
|
|
16891
|
+
});
|
|
16892
|
+
const hash = await signer.writeContract(request);
|
|
16893
|
+
await this.#evmService.client.waitForTransactionReceipt({
|
|
16894
|
+
hash
|
|
16895
|
+
});
|
|
16896
|
+
return hash;
|
|
16897
|
+
}
|
|
16898
|
+
async getFee(address, transfer) {
|
|
16899
|
+
const { args } = transfer;
|
|
16900
|
+
const { tokenAddress, amount, requiresApproval } = args;
|
|
16901
|
+
const contract = this.buildContractConfig(transfer);
|
|
16902
|
+
if (!requiresApproval) {
|
|
16903
|
+
return await this.#evmService.getFee(address, contract);
|
|
16904
|
+
}
|
|
16905
|
+
const currentAllowance = await this.checkAllowance(
|
|
16906
|
+
address,
|
|
16907
|
+
tokenAddress,
|
|
16908
|
+
this.#gatewayAddress
|
|
16909
|
+
);
|
|
16910
|
+
if (currentAllowance >= amount) {
|
|
16911
|
+
return await this.#evmService.getFee(address, contract);
|
|
16912
|
+
}
|
|
16913
|
+
return await this.estimateApproveAndSendFee(address, transfer);
|
|
16914
|
+
}
|
|
16915
|
+
async estimateApproveAndSendFee(address, transfer) {
|
|
16916
|
+
const { args } = transfer;
|
|
16917
|
+
const { tokenAddress, amount } = args;
|
|
16918
|
+
const contract = this.buildContractConfig(transfer);
|
|
16919
|
+
try {
|
|
16920
|
+
const approveData = encodeFunctionData({
|
|
16921
|
+
abi: ERC20_ABI,
|
|
16922
|
+
functionName: "approve",
|
|
16923
|
+
args: [this.#gatewayAddress, amount]
|
|
16924
|
+
});
|
|
16925
|
+
const approveGas = await this.#evmService.client.estimateGas({
|
|
16926
|
+
account: address,
|
|
16927
|
+
to: tokenAddress,
|
|
16928
|
+
data: approveData
|
|
16929
|
+
});
|
|
16930
|
+
const sendData = encodeFunctionData({
|
|
16931
|
+
abi: contract.abi,
|
|
16932
|
+
functionName: contract.func,
|
|
16933
|
+
args: contract.args
|
|
16934
|
+
});
|
|
16935
|
+
const sendGas = await this.#evmService.client.estimateGas({
|
|
16936
|
+
account: address,
|
|
16937
|
+
to: contract.address,
|
|
16938
|
+
data: sendData,
|
|
16939
|
+
value: contract.value
|
|
16940
|
+
});
|
|
16941
|
+
const gasPrice = await this.#evmService.client.getGasPrice();
|
|
16942
|
+
return (approveGas + sendGas) * gasPrice;
|
|
16943
|
+
} catch (error) {
|
|
16944
|
+
console.error("Error estimating approve + send fee:", error);
|
|
16945
|
+
return 0n;
|
|
16946
|
+
}
|
|
16947
|
+
}
|
|
16948
|
+
};
|
|
16949
|
+
|
|
16950
|
+
// src/getTransferData/getBridgeChainData.ts
|
|
16951
|
+
import { getBalance, getDestinationFee } from "@moonbeam-network/xcm-sdk";
|
|
16952
|
+
import { EvmParachain, Parachain } from "@moonbeam-network/xcm-types";
|
|
16783
16953
|
import { getMultilocationDerivedAddresses } from "@moonbeam-network/xcm-utils";
|
|
16784
16954
|
import { evmToAddress } from "@polkadot/util-crypto";
|
|
16785
|
-
async function
|
|
16955
|
+
async function getBridgeChainData({
|
|
16786
16956
|
route,
|
|
16787
16957
|
sourceAddress,
|
|
16788
16958
|
destinationAddress
|
|
@@ -16792,80 +16962,87 @@ async function getMoonChainData({
|
|
|
16792
16962
|
`MRL config is not defined for source chain ${route.source.chain.name} and asset ${route.source.asset.originSymbol}`
|
|
16793
16963
|
);
|
|
16794
16964
|
}
|
|
16795
|
-
const
|
|
16796
|
-
const
|
|
16797
|
-
|
|
16798
|
-
destination: route.destination.chain,
|
|
16965
|
+
const bridgeChain = route.mrl.bridgeChain.chain;
|
|
16966
|
+
const bridgeChainAddress = getBridgeChainAddress({
|
|
16967
|
+
route,
|
|
16799
16968
|
sourceAddress,
|
|
16800
16969
|
destinationAddress
|
|
16801
16970
|
});
|
|
16802
16971
|
const fee = await getDestinationFee({
|
|
16803
|
-
address:
|
|
16972
|
+
address: bridgeChainAddress,
|
|
16804
16973
|
asset: route.source.asset,
|
|
16805
|
-
destination:
|
|
16806
|
-
fee: route.mrl.
|
|
16807
|
-
feeAsset: route.mrl.
|
|
16974
|
+
destination: bridgeChain,
|
|
16975
|
+
fee: route.mrl.bridgeChain.fee.amount,
|
|
16976
|
+
feeAsset: route.mrl.bridgeChain.fee.asset,
|
|
16808
16977
|
source: route.source.chain
|
|
16809
16978
|
});
|
|
16810
16979
|
const balance = await getBalance({
|
|
16811
|
-
address:
|
|
16812
|
-
asset:
|
|
16813
|
-
builder: route.mrl.
|
|
16814
|
-
chain:
|
|
16980
|
+
address: bridgeChainAddress,
|
|
16981
|
+
asset: bridgeChain.getChainAsset(route.mrl.bridgeChain.asset),
|
|
16982
|
+
builder: route.mrl.bridgeChain.balance,
|
|
16983
|
+
chain: bridgeChain
|
|
16815
16984
|
});
|
|
16816
16985
|
const feeBalance = await getBalance({
|
|
16817
|
-
address:
|
|
16818
|
-
asset:
|
|
16819
|
-
builder: route.mrl.
|
|
16820
|
-
chain:
|
|
16986
|
+
address: bridgeChainAddress,
|
|
16987
|
+
asset: bridgeChain.getChainAsset(route.mrl.bridgeChain.fee.asset),
|
|
16988
|
+
builder: route.mrl.bridgeChain.fee.balance,
|
|
16989
|
+
chain: bridgeChain
|
|
16821
16990
|
});
|
|
16822
16991
|
return {
|
|
16823
|
-
address:
|
|
16992
|
+
address: bridgeChainAddress,
|
|
16824
16993
|
balance,
|
|
16825
16994
|
feeBalance,
|
|
16826
|
-
chain:
|
|
16995
|
+
chain: bridgeChain,
|
|
16827
16996
|
fee
|
|
16828
16997
|
};
|
|
16829
16998
|
}
|
|
16830
|
-
function
|
|
16831
|
-
|
|
16832
|
-
destination,
|
|
16999
|
+
function getBridgeChainAddress({
|
|
17000
|
+
route,
|
|
16833
17001
|
sourceAddress,
|
|
16834
17002
|
destinationAddress
|
|
16835
17003
|
}) {
|
|
16836
|
-
const
|
|
16837
|
-
const
|
|
16838
|
-
const
|
|
16839
|
-
|
|
16840
|
-
|
|
17004
|
+
const source = route.source.chain;
|
|
17005
|
+
const destination = route.destination.chain;
|
|
17006
|
+
const bridgeChain = route.mrl.bridgeChain.chain;
|
|
17007
|
+
const isDestinationBridgeChain = bridgeChain.isEqual(destination);
|
|
17008
|
+
const isSourceBridgeChain = bridgeChain.isEqual(source);
|
|
17009
|
+
let bridgeChainAddress = isDestinationBridgeChain ? destinationAddress : sourceAddress;
|
|
17010
|
+
if (Parachain.is(source) && !isSourceBridgeChain) {
|
|
16841
17011
|
const isSourceEvmSigner = EvmParachain.is(source) && source.isEvmSigner;
|
|
16842
17012
|
const { address20: computedOriginAccount } = getMultilocationDerivedAddresses({
|
|
16843
17013
|
address: isSourceEvmSigner ? evmToAddress(sourceAddress) : sourceAddress,
|
|
16844
17014
|
paraId: source.parachainId,
|
|
16845
17015
|
isParents: true
|
|
16846
17016
|
});
|
|
16847
|
-
|
|
17017
|
+
bridgeChainAddress = computedOriginAccount;
|
|
16848
17018
|
}
|
|
16849
|
-
return
|
|
17019
|
+
return bridgeChainAddress;
|
|
16850
17020
|
}
|
|
16851
17021
|
|
|
16852
17022
|
// src/getTransferData/getSourceData.ts
|
|
16853
17023
|
import {
|
|
16854
|
-
ContractConfig,
|
|
17024
|
+
ContractConfig as ContractConfig2,
|
|
16855
17025
|
MrlBuilder as MrlBuilder3,
|
|
17026
|
+
Provider as Provider2,
|
|
17027
|
+
SnowbridgeConfig,
|
|
17028
|
+
SubstrateQueryConfig,
|
|
16856
17029
|
WormholeConfig
|
|
16857
17030
|
} from "@moonbeam-network/xcm-builder";
|
|
16858
17031
|
import {
|
|
17032
|
+
EvmService as EvmService3,
|
|
16859
17033
|
getAssetMin,
|
|
16860
17034
|
getBalance as getBalance2,
|
|
16861
17035
|
getContractFee,
|
|
16862
17036
|
getDestinationFeeBalance,
|
|
16863
17037
|
getExistentialDeposit,
|
|
16864
17038
|
getExtrinsicFee,
|
|
16865
|
-
getMax
|
|
17039
|
+
getMax,
|
|
17040
|
+
PolkadotService as PolkadotService2
|
|
16866
17041
|
} from "@moonbeam-network/xcm-sdk";
|
|
16867
17042
|
import {
|
|
16868
|
-
AssetAmount as AssetAmount2
|
|
17043
|
+
AssetAmount as AssetAmount2,
|
|
17044
|
+
EvmChain as EvmChain2,
|
|
17045
|
+
EvmParachain as EvmParachain3
|
|
16869
17046
|
} from "@moonbeam-network/xcm-types";
|
|
16870
17047
|
import { toBigInt as toBigInt2 } from "@moonbeam-network/xcm-utils";
|
|
16871
17048
|
|
|
@@ -16873,11 +17050,11 @@ import { toBigInt as toBigInt2 } from "@moonbeam-network/xcm-utils";
|
|
|
16873
17050
|
import {
|
|
16874
17051
|
BATCH_CONTRACT_ABI,
|
|
16875
17052
|
BATCH_CONTRACT_ADDRESS,
|
|
16876
|
-
ERC20_ABI,
|
|
16877
|
-
MrlBuilder as MrlBuilder2
|
|
17053
|
+
ERC20_ABI as ERC20_ABI2,
|
|
17054
|
+
MrlBuilder as MrlBuilder2,
|
|
17055
|
+
Provider
|
|
16878
17056
|
} from "@moonbeam-network/xcm-builder";
|
|
16879
17057
|
import {
|
|
16880
|
-
getMoonChain as getMoonChain2,
|
|
16881
17058
|
moonbaseAlpha,
|
|
16882
17059
|
moonbeam
|
|
16883
17060
|
} from "@moonbeam-network/xcm-config";
|
|
@@ -16894,33 +17071,33 @@ import {
|
|
|
16894
17071
|
import Big from "big.js";
|
|
16895
17072
|
import {
|
|
16896
17073
|
createPublicClient as createPublicClient2,
|
|
16897
|
-
encodeFunctionData,
|
|
17074
|
+
encodeFunctionData as encodeFunctionData2,
|
|
16898
17075
|
http as http2
|
|
16899
17076
|
} from "viem";
|
|
16900
17077
|
var MOON_CHAIN_AUTOMATIC_GAS_ESTIMATION = {
|
|
16901
17078
|
[moonbeam.key]: 1273110n,
|
|
16902
17079
|
[moonbaseAlpha.key]: 1470417n
|
|
16903
17080
|
};
|
|
16904
|
-
function
|
|
17081
|
+
function getBridgeChainFeeValueOnSource({
|
|
16905
17082
|
destinationData,
|
|
16906
|
-
|
|
17083
|
+
bridgeChainData,
|
|
16907
17084
|
sourceData
|
|
16908
17085
|
}) {
|
|
16909
17086
|
const isSourceParachain = EvmParachain2.isAnyParachain(sourceData.chain);
|
|
16910
|
-
const
|
|
16911
|
-
|
|
17087
|
+
const isDestinationBridgeChain = destinationData.chain.isEqual(
|
|
17088
|
+
bridgeChainData.chain
|
|
16912
17089
|
);
|
|
16913
|
-
const
|
|
16914
|
-
|
|
17090
|
+
const isSameAssetPayingBridgeChainFee = sourceData.balance.isSame(
|
|
17091
|
+
bridgeChainData.fee
|
|
16915
17092
|
);
|
|
16916
|
-
return !
|
|
16917
|
-
asset:
|
|
16918
|
-
target: sourceData.chain.getChainAsset(
|
|
17093
|
+
return !isDestinationBridgeChain && isSourceParachain && isSameAssetPayingBridgeChainFee ? convertToChainDecimals({
|
|
17094
|
+
asset: bridgeChainData.fee,
|
|
17095
|
+
target: sourceData.chain.getChainAsset(bridgeChainData.fee)
|
|
16919
17096
|
}).toBig() : Big(0);
|
|
16920
17097
|
}
|
|
16921
17098
|
function getMrlMin({
|
|
16922
17099
|
destinationData,
|
|
16923
|
-
|
|
17100
|
+
bridgeChainData,
|
|
16924
17101
|
sourceData
|
|
16925
17102
|
}) {
|
|
16926
17103
|
const minInDestination = getMin(destinationData);
|
|
@@ -16930,16 +17107,19 @@ function getMrlMin({
|
|
|
16930
17107
|
amount: minInDestination.amount
|
|
16931
17108
|
}
|
|
16932
17109
|
);
|
|
16933
|
-
const
|
|
17110
|
+
const bridgeChainFee = getBridgeChainFeeValueOnSource({
|
|
16934
17111
|
destinationData,
|
|
16935
|
-
|
|
17112
|
+
bridgeChainData,
|
|
16936
17113
|
sourceData
|
|
16937
17114
|
});
|
|
16938
|
-
const relayerFee = sourceData.
|
|
17115
|
+
const relayerFee = sourceData.otherFees?.relayer?.amount ? sourceData.otherFees.relayer.toBig() : Big(0);
|
|
16939
17116
|
return min.copyWith({
|
|
16940
|
-
amount: BigInt(min.toBig().add(
|
|
17117
|
+
amount: BigInt(min.toBig().add(bridgeChainFee).add(relayerFee).toFixed())
|
|
16941
17118
|
});
|
|
16942
17119
|
}
|
|
17120
|
+
function requiresTransact(route) {
|
|
17121
|
+
return route.mrl?.transfer.provider === Provider.Wormhole && EvmParachain2.isAnyParachain(route.source.chain);
|
|
17122
|
+
}
|
|
16943
17123
|
async function buildTransfer(params) {
|
|
16944
17124
|
const { route } = params;
|
|
16945
17125
|
if (!route.mrl) {
|
|
@@ -16955,11 +17135,12 @@ async function buildTransfer(params) {
|
|
|
16955
17135
|
const builderParams = await getMrlBuilderParams(params);
|
|
16956
17136
|
return route.mrl.transfer.build({
|
|
16957
17137
|
...builderParams,
|
|
16958
|
-
transact:
|
|
17138
|
+
transact: requiresTransact(route) ? await getTransact(builderParams) : void 0
|
|
16959
17139
|
});
|
|
16960
17140
|
}
|
|
16961
17141
|
async function getMrlBuilderParams({
|
|
16962
17142
|
asset,
|
|
17143
|
+
protocolFee,
|
|
16963
17144
|
destinationAddress,
|
|
16964
17145
|
feeAsset,
|
|
16965
17146
|
isAutomatic,
|
|
@@ -16974,22 +17155,23 @@ async function getMrlBuilderParams({
|
|
|
16974
17155
|
}
|
|
16975
17156
|
const source = route.source.chain;
|
|
16976
17157
|
const destination = route.destination.chain;
|
|
16977
|
-
const
|
|
16978
|
-
const [sourceApi, destinationApi,
|
|
17158
|
+
const bridgeChain = route.mrl.bridgeChain.chain;
|
|
17159
|
+
const [sourceApi, destinationApi, bridgeApi] = await Promise.all([
|
|
16979
17160
|
EvmParachain2.isAnyParachain(source) ? getPolkadotApi(source.ws) : void 0,
|
|
16980
17161
|
EvmParachain2.isAnyParachain(destination) ? getPolkadotApi(destination.ws) : void 0,
|
|
16981
|
-
getPolkadotApi(
|
|
17162
|
+
getPolkadotApi(bridgeChain.ws)
|
|
16982
17163
|
]);
|
|
16983
17164
|
return {
|
|
16984
17165
|
asset,
|
|
17166
|
+
protocolFee,
|
|
16985
17167
|
destination,
|
|
16986
17168
|
destinationAddress,
|
|
16987
17169
|
destinationApi,
|
|
16988
17170
|
fee: feeAsset,
|
|
16989
17171
|
isAutomatic,
|
|
16990
|
-
moonApi,
|
|
16991
|
-
moonAsset:
|
|
16992
|
-
|
|
17172
|
+
moonApi: bridgeApi,
|
|
17173
|
+
moonAsset: bridgeChain.nativeAsset,
|
|
17174
|
+
bridgeChain,
|
|
16993
17175
|
sendOnlyRemoteExecution,
|
|
16994
17176
|
source,
|
|
16995
17177
|
sourceAddress,
|
|
@@ -16997,9 +17179,9 @@ async function getMrlBuilderParams({
|
|
|
16997
17179
|
};
|
|
16998
17180
|
}
|
|
16999
17181
|
async function getTransact(params) {
|
|
17000
|
-
const { sourceAddress, source,
|
|
17001
|
-
const polkadot = await PolkadotService.create(
|
|
17002
|
-
const
|
|
17182
|
+
const { sourceAddress, source, bridgeChain } = params;
|
|
17183
|
+
const polkadot = await PolkadotService.create(bridgeChain);
|
|
17184
|
+
const bridgeChainGasLimit = await getBridgeChainGasLimit(params);
|
|
17003
17185
|
if (!EvmParachain2.isAnyParachain(source)) {
|
|
17004
17186
|
throw new Error("Source chain must be Parachain or EvmParachain");
|
|
17005
17187
|
}
|
|
@@ -17008,7 +17190,7 @@ async function getTransact(params) {
|
|
|
17008
17190
|
paraId: source.parachainId,
|
|
17009
17191
|
isParents: true
|
|
17010
17192
|
});
|
|
17011
|
-
const extrinsic = MrlBuilder2().wormhole().extrinsic().ethereumXcm().transact().build({ ...params,
|
|
17193
|
+
const extrinsic = MrlBuilder2().wormhole().extrinsic().ethereumXcm().transact().build({ ...params, bridgeChainGasLimit });
|
|
17012
17194
|
const { weight } = await polkadot.getPaymentInfo(address20, extrinsic);
|
|
17013
17195
|
return {
|
|
17014
17196
|
call: polkadot.getExtrinsicCallHash(extrinsic),
|
|
@@ -17018,13 +17200,16 @@ async function getTransact(params) {
|
|
|
17018
17200
|
}
|
|
17019
17201
|
};
|
|
17020
17202
|
}
|
|
17021
|
-
async function
|
|
17022
|
-
const { asset, isAutomatic,
|
|
17203
|
+
async function getBridgeChainGasLimit(params) {
|
|
17204
|
+
const { asset, isAutomatic, bridgeChain, source, sourceAddress } = params;
|
|
17023
17205
|
if (!EvmParachain2.isAnyParachain(source)) {
|
|
17024
17206
|
throw new Error("Source chain must be Parachain or EvmParachain");
|
|
17025
17207
|
}
|
|
17208
|
+
if (!EvmParachain2.is(bridgeChain)) {
|
|
17209
|
+
throw new Error("Bridge chain must be an EvmParachain");
|
|
17210
|
+
}
|
|
17026
17211
|
const client = createPublicClient2({
|
|
17027
|
-
chain:
|
|
17212
|
+
chain: bridgeChain.getViemChain(),
|
|
17028
17213
|
transport: http2()
|
|
17029
17214
|
});
|
|
17030
17215
|
const { address20 } = getMultilocationDerivedAddresses2({
|
|
@@ -17033,28 +17218,28 @@ async function getMoonGasLimit(params) {
|
|
|
17033
17218
|
isParents: true
|
|
17034
17219
|
});
|
|
17035
17220
|
if (isAutomatic) {
|
|
17036
|
-
return MOON_CHAIN_AUTOMATIC_GAS_ESTIMATION[
|
|
17221
|
+
return MOON_CHAIN_AUTOMATIC_GAS_ESTIMATION[bridgeChain.key] * 110n / 100n;
|
|
17037
17222
|
}
|
|
17038
17223
|
const contract = MrlBuilder2().wormhole().contract().TokenBridge().transferTokens().build({
|
|
17039
17224
|
...params,
|
|
17040
17225
|
asset: asset.copyWith({ amount: 0n })
|
|
17041
17226
|
});
|
|
17042
|
-
const approveTx =
|
|
17043
|
-
abi:
|
|
17227
|
+
const approveTx = encodeFunctionData2({
|
|
17228
|
+
abi: ERC20_ABI2,
|
|
17044
17229
|
functionName: "approve",
|
|
17045
17230
|
args: [contract.address, 0n]
|
|
17046
17231
|
});
|
|
17047
|
-
const
|
|
17048
|
-
if (!
|
|
17232
|
+
const tokenAddressOnBridgeChain = bridgeChain.getChainAsset(asset).address;
|
|
17233
|
+
if (!tokenAddressOnBridgeChain) {
|
|
17049
17234
|
throw new Error(
|
|
17050
|
-
`Asset ${asset.symbol} does not have a token address on chain ${
|
|
17235
|
+
`Asset ${asset.symbol} does not have a token address on chain ${bridgeChain.name}`
|
|
17051
17236
|
);
|
|
17052
17237
|
}
|
|
17053
|
-
const batchAll =
|
|
17238
|
+
const batchAll = encodeFunctionData2({
|
|
17054
17239
|
abi: BATCH_CONTRACT_ABI,
|
|
17055
17240
|
functionName: "batchAll",
|
|
17056
17241
|
args: [
|
|
17057
|
-
[
|
|
17242
|
+
[tokenAddressOnBridgeChain, contract.address],
|
|
17058
17243
|
[0n, 0n],
|
|
17059
17244
|
// Value to send for each call
|
|
17060
17245
|
[approveTx, contract.encodeFunctionData()],
|
|
@@ -17070,6 +17255,11 @@ async function getMoonGasLimit(params) {
|
|
|
17070
17255
|
});
|
|
17071
17256
|
return gasEstimation * 110n / 100n;
|
|
17072
17257
|
}
|
|
17258
|
+
function getAmountForTransferSimulation(balance, protocolFee) {
|
|
17259
|
+
return balance.copyWith({
|
|
17260
|
+
amount: balance.amount - protocolFee.amount > 0 ? balance.amount - protocolFee.amount : 0n
|
|
17261
|
+
});
|
|
17262
|
+
}
|
|
17073
17263
|
|
|
17074
17264
|
// src/getTransferData/getSourceData.ts
|
|
17075
17265
|
async function getSourceData({
|
|
@@ -17085,6 +17275,7 @@ async function getSourceData({
|
|
|
17085
17275
|
);
|
|
17086
17276
|
}
|
|
17087
17277
|
const source = route.source.chain;
|
|
17278
|
+
const destination = route.destination.chain;
|
|
17088
17279
|
const asset = source.getChainAsset(route.source.asset);
|
|
17089
17280
|
const feeAsset = route.source.fee ? source.getChainAsset(route.source.fee.asset) : asset;
|
|
17090
17281
|
const balance = await getBalance2({
|
|
@@ -17105,7 +17296,7 @@ async function getSourceData({
|
|
|
17105
17296
|
route,
|
|
17106
17297
|
sourceAddress
|
|
17107
17298
|
});
|
|
17108
|
-
const
|
|
17299
|
+
const bridgeChainFeeBalance = await getBridgeChainFeeBalance({
|
|
17109
17300
|
balance,
|
|
17110
17301
|
feeBalance,
|
|
17111
17302
|
route,
|
|
@@ -17117,8 +17308,18 @@ async function getSourceData({
|
|
|
17117
17308
|
builder: route.source.min,
|
|
17118
17309
|
chain: source
|
|
17119
17310
|
});
|
|
17311
|
+
const protocolFee = await getProtocolFee({
|
|
17312
|
+
source,
|
|
17313
|
+
destination,
|
|
17314
|
+
asset,
|
|
17315
|
+
feeAsset,
|
|
17316
|
+
balance,
|
|
17317
|
+
protocolFee: route.source.protocolFee,
|
|
17318
|
+
address: destinationAddress
|
|
17319
|
+
});
|
|
17120
17320
|
const transfer = await buildTransfer({
|
|
17121
|
-
asset: balance,
|
|
17321
|
+
asset: getAmountForTransferSimulation(balance, protocolFee),
|
|
17322
|
+
protocolFee,
|
|
17122
17323
|
destinationAddress,
|
|
17123
17324
|
feeAsset: feeBalance,
|
|
17124
17325
|
isAutomatic,
|
|
@@ -17155,13 +17356,16 @@ async function getSourceData({
|
|
|
17155
17356
|
chain: source,
|
|
17156
17357
|
destinationFee,
|
|
17157
17358
|
destinationFeeBalance,
|
|
17158
|
-
|
|
17359
|
+
bridgeChainFeeBalance,
|
|
17159
17360
|
existentialDeposit,
|
|
17160
17361
|
fee,
|
|
17161
17362
|
feeBalance,
|
|
17162
17363
|
max,
|
|
17163
17364
|
min,
|
|
17164
|
-
|
|
17365
|
+
otherFees: {
|
|
17366
|
+
protocol: protocolFee,
|
|
17367
|
+
relayer: relayerFee?.amount ? relayerFee : void 0
|
|
17368
|
+
}
|
|
17165
17369
|
};
|
|
17166
17370
|
}
|
|
17167
17371
|
async function getFee({
|
|
@@ -17178,16 +17382,33 @@ async function getFee({
|
|
|
17178
17382
|
amount: 0n
|
|
17179
17383
|
});
|
|
17180
17384
|
}
|
|
17181
|
-
if (
|
|
17182
|
-
|
|
17183
|
-
|
|
17184
|
-
|
|
17185
|
-
|
|
17186
|
-
|
|
17187
|
-
|
|
17188
|
-
|
|
17189
|
-
|
|
17190
|
-
|
|
17385
|
+
if (SnowbridgeConfig.is(transfer)) {
|
|
17386
|
+
const snowbridge = SnowbridgeService.create(chain2);
|
|
17387
|
+
try {
|
|
17388
|
+
const feeAmount = await snowbridge.getFee(sourceAddress, transfer);
|
|
17389
|
+
return AssetAmount2.fromChainAsset(chain2.getChainAsset(feeBalance), {
|
|
17390
|
+
amount: feeAmount
|
|
17391
|
+
});
|
|
17392
|
+
} catch (error) {
|
|
17393
|
+
console.error(error);
|
|
17394
|
+
return feeBalance.copyWith({ amount: 0n });
|
|
17395
|
+
}
|
|
17396
|
+
}
|
|
17397
|
+
if (ContractConfig2.is(transfer)) {
|
|
17398
|
+
try {
|
|
17399
|
+
return getContractFee({
|
|
17400
|
+
address: sourceAddress,
|
|
17401
|
+
balance,
|
|
17402
|
+
chain: chain2,
|
|
17403
|
+
contract: transfer,
|
|
17404
|
+
destinationFee,
|
|
17405
|
+
feeBalance,
|
|
17406
|
+
feeConfig
|
|
17407
|
+
});
|
|
17408
|
+
} catch (error) {
|
|
17409
|
+
console.error(error);
|
|
17410
|
+
return feeBalance.copyWith({ amount: 0n });
|
|
17411
|
+
}
|
|
17191
17412
|
}
|
|
17192
17413
|
return getExtrinsicFee({
|
|
17193
17414
|
address: sourceAddress,
|
|
@@ -17208,19 +17429,25 @@ async function getRelayerFee({
|
|
|
17208
17429
|
sourceAddress,
|
|
17209
17430
|
transfer
|
|
17210
17431
|
}) {
|
|
17432
|
+
if (route.mrl.transfer.provider === Provider2.Snowbridge || SnowbridgeConfig.is(transfer)) {
|
|
17433
|
+
return void 0;
|
|
17434
|
+
}
|
|
17211
17435
|
if (WormholeConfig.is(transfer)) {
|
|
17212
17436
|
return getWormholeFee({ asset, chain: chain2, config: transfer });
|
|
17213
17437
|
}
|
|
17214
|
-
|
|
17215
|
-
|
|
17216
|
-
|
|
17217
|
-
|
|
17218
|
-
|
|
17219
|
-
|
|
17220
|
-
|
|
17221
|
-
|
|
17222
|
-
|
|
17223
|
-
|
|
17438
|
+
if (route.mrl.transfer.provider === Provider2.Wormhole) {
|
|
17439
|
+
const builderParams = await getMrlBuilderParams({
|
|
17440
|
+
asset,
|
|
17441
|
+
destinationAddress,
|
|
17442
|
+
feeAsset,
|
|
17443
|
+
isAutomatic,
|
|
17444
|
+
route,
|
|
17445
|
+
sourceAddress
|
|
17446
|
+
});
|
|
17447
|
+
const wormholeConfig = MrlBuilder3().wormhole().wormhole().tokenTransfer().build(builderParams);
|
|
17448
|
+
return getWormholeFee({ asset, chain: chain2, config: wormholeConfig });
|
|
17449
|
+
}
|
|
17450
|
+
return;
|
|
17224
17451
|
}
|
|
17225
17452
|
async function getWormholeFee({
|
|
17226
17453
|
asset,
|
|
@@ -17237,33 +17464,78 @@ async function getWormholeFee({
|
|
|
17237
17464
|
}
|
|
17238
17465
|
return;
|
|
17239
17466
|
}
|
|
17240
|
-
async function
|
|
17467
|
+
async function getBridgeChainFeeBalance({
|
|
17241
17468
|
balance,
|
|
17242
17469
|
feeBalance,
|
|
17243
17470
|
route,
|
|
17244
17471
|
sourceAddress
|
|
17245
17472
|
}) {
|
|
17246
|
-
if (!route.source.
|
|
17473
|
+
if (!route.source.bridgeChainFee) {
|
|
17247
17474
|
return void 0;
|
|
17248
17475
|
}
|
|
17249
|
-
if (route.mrl?.
|
|
17476
|
+
if (route.mrl?.bridgeChain.fee.asset.isEqual(balance)) {
|
|
17250
17477
|
return balance;
|
|
17251
17478
|
}
|
|
17252
|
-
if (route.mrl?.
|
|
17479
|
+
if (route.mrl?.bridgeChain.fee.asset.isEqual(feeBalance)) {
|
|
17253
17480
|
return feeBalance;
|
|
17254
17481
|
}
|
|
17255
|
-
if (!route.source.
|
|
17482
|
+
if (!route.source.bridgeChainFee.balance) {
|
|
17256
17483
|
throw new Error(
|
|
17257
|
-
"BalanceBuilder must be defined for source.
|
|
17484
|
+
"BalanceBuilder must be defined for source.bridgeChainFee.balance for MrlAssetRoute"
|
|
17258
17485
|
);
|
|
17259
17486
|
}
|
|
17260
17487
|
return getBalance2({
|
|
17261
17488
|
address: sourceAddress,
|
|
17262
|
-
asset: route.source.chain.getChainAsset(route.source.
|
|
17263
|
-
builder: route.source.
|
|
17489
|
+
asset: route.source.chain.getChainAsset(route.source.bridgeChainFee.asset),
|
|
17490
|
+
builder: route.source.bridgeChainFee.balance,
|
|
17264
17491
|
chain: route.source.chain
|
|
17265
17492
|
});
|
|
17266
17493
|
}
|
|
17494
|
+
async function getProtocolFee({
|
|
17495
|
+
address,
|
|
17496
|
+
asset,
|
|
17497
|
+
feeAsset,
|
|
17498
|
+
balance,
|
|
17499
|
+
protocolFee,
|
|
17500
|
+
destination,
|
|
17501
|
+
source
|
|
17502
|
+
}) {
|
|
17503
|
+
if (typeof protocolFee === "number") {
|
|
17504
|
+
return AssetAmount2.fromChainAsset(asset, {
|
|
17505
|
+
amount: protocolFee
|
|
17506
|
+
});
|
|
17507
|
+
}
|
|
17508
|
+
const config = protocolFee?.build({
|
|
17509
|
+
address,
|
|
17510
|
+
asset,
|
|
17511
|
+
feeAsset,
|
|
17512
|
+
balance,
|
|
17513
|
+
destination,
|
|
17514
|
+
source
|
|
17515
|
+
});
|
|
17516
|
+
if (ContractConfig2.is(config) && EvmChain2.is(source)) {
|
|
17517
|
+
const evm = EvmService3.create(source);
|
|
17518
|
+
const amount = await evm.read(config);
|
|
17519
|
+
if (typeof amount !== "bigint") {
|
|
17520
|
+
throw new Error(
|
|
17521
|
+
`Error getting bridge fee: expected bigint from contract call, but received ${typeof amount}. `
|
|
17522
|
+
);
|
|
17523
|
+
}
|
|
17524
|
+
return AssetAmount2.fromChainAsset(feeAsset, {
|
|
17525
|
+
amount
|
|
17526
|
+
});
|
|
17527
|
+
}
|
|
17528
|
+
if (SubstrateQueryConfig.is(config) && EvmParachain3.isAnyParachain(source)) {
|
|
17529
|
+
const polkadot = await PolkadotService2.create(source);
|
|
17530
|
+
const amount = await polkadot.query(config);
|
|
17531
|
+
return AssetAmount2.fromChainAsset(feeAsset, {
|
|
17532
|
+
amount
|
|
17533
|
+
});
|
|
17534
|
+
}
|
|
17535
|
+
return AssetAmount2.fromChainAsset(feeAsset, {
|
|
17536
|
+
amount: 0n
|
|
17537
|
+
});
|
|
17538
|
+
}
|
|
17267
17539
|
|
|
17268
17540
|
// src/getTransferData/getTransferData.ts
|
|
17269
17541
|
async function getTransferData({
|
|
@@ -17292,7 +17564,7 @@ async function getTransferData({
|
|
|
17292
17564
|
destinationFee,
|
|
17293
17565
|
sourceAddress
|
|
17294
17566
|
});
|
|
17295
|
-
const
|
|
17567
|
+
const bridgeChainData = await getBridgeChainData({
|
|
17296
17568
|
route,
|
|
17297
17569
|
sourceAddress,
|
|
17298
17570
|
destinationAddress
|
|
@@ -17304,14 +17576,14 @@ async function getTransferData({
|
|
|
17304
17576
|
const bigAmount = Big2(
|
|
17305
17577
|
toBigInt3(amount, sourceData.balance.decimals).toString()
|
|
17306
17578
|
);
|
|
17307
|
-
const fee =
|
|
17579
|
+
const fee = getBridgeChainFeeValueOnSource({
|
|
17308
17580
|
destinationData,
|
|
17309
|
-
|
|
17581
|
+
bridgeChainData,
|
|
17310
17582
|
sourceData
|
|
17311
17583
|
});
|
|
17312
17584
|
const result = bigAmount.minus(
|
|
17313
17585
|
isSameAssetPayingDestinationFee ? destinationFee.toBig() : Big2(0)
|
|
17314
|
-
).minus(fee).minus(sourceData.
|
|
17586
|
+
).minus(fee).minus(sourceData.otherFees?.relayer?.toBig() || Big2(0));
|
|
17315
17587
|
return sourceData.balance.copyWith({
|
|
17316
17588
|
amount: result.lt(0) ? 0n : BigInt(result.toFixed())
|
|
17317
17589
|
});
|
|
@@ -17320,10 +17592,10 @@ async function getTransferData({
|
|
|
17320
17592
|
max: sourceData.max,
|
|
17321
17593
|
min: getMrlMin({
|
|
17322
17594
|
destinationData,
|
|
17323
|
-
|
|
17595
|
+
bridgeChainData,
|
|
17324
17596
|
sourceData
|
|
17325
17597
|
}),
|
|
17326
|
-
|
|
17598
|
+
bridgeChain: bridgeChainData,
|
|
17327
17599
|
source: sourceData,
|
|
17328
17600
|
async transfer({
|
|
17329
17601
|
amount,
|
|
@@ -17346,6 +17618,7 @@ async function getTransferData({
|
|
|
17346
17618
|
);
|
|
17347
17619
|
const transfer = await buildTransfer({
|
|
17348
17620
|
asset,
|
|
17621
|
+
protocolFee: sourceData.otherFees?.protocol,
|
|
17349
17622
|
destinationAddress,
|
|
17350
17623
|
feeAsset,
|
|
17351
17624
|
isAutomatic: isAutomatic2,
|
|
@@ -17353,19 +17626,19 @@ async function getTransferData({
|
|
|
17353
17626
|
sendOnlyRemoteExecution,
|
|
17354
17627
|
sourceAddress
|
|
17355
17628
|
});
|
|
17356
|
-
if (
|
|
17629
|
+
if (ContractConfig3.is(transfer) && (EvmChain3.is(source) || EvmParachain4.is(source))) {
|
|
17357
17630
|
if (!evmSigner) {
|
|
17358
17631
|
throw new Error("EVM Signer must be provided");
|
|
17359
17632
|
}
|
|
17360
|
-
const evm =
|
|
17633
|
+
const evm = EvmService4.create(source);
|
|
17361
17634
|
const hash = await evm.transfer(evmSigner, transfer);
|
|
17362
17635
|
return [hash];
|
|
17363
17636
|
}
|
|
17364
|
-
if (ExtrinsicConfig.is(transfer) &&
|
|
17637
|
+
if (ExtrinsicConfig.is(transfer) && EvmParachain4.isAnyParachain(source)) {
|
|
17365
17638
|
if (!polkadotSigner) {
|
|
17366
17639
|
throw new Error("Polkadot signer must be provided");
|
|
17367
17640
|
}
|
|
17368
|
-
const polkadot = await
|
|
17641
|
+
const polkadot = await PolkadotService3.create(source);
|
|
17369
17642
|
const hash = await polkadot.transfer(
|
|
17370
17643
|
sourceAddress,
|
|
17371
17644
|
transfer,
|
|
@@ -17374,13 +17647,21 @@ async function getTransferData({
|
|
|
17374
17647
|
);
|
|
17375
17648
|
return [hash];
|
|
17376
17649
|
}
|
|
17377
|
-
if (WormholeConfig2.is(transfer) && (
|
|
17650
|
+
if (WormholeConfig2.is(transfer) && (EvmChain3.is(source) || EvmParachain4.is(source))) {
|
|
17378
17651
|
if (!evmSigner) {
|
|
17379
17652
|
throw new Error("EVM Signer must be provided");
|
|
17380
17653
|
}
|
|
17381
17654
|
const wh = WormholeService.create(source);
|
|
17382
17655
|
return wh.transfer(evmSigner, transfer);
|
|
17383
17656
|
}
|
|
17657
|
+
if (SnowbridgeConfig2.is(transfer) && (EvmChain3.is(source) || EvmParachain4.is(source))) {
|
|
17658
|
+
if (!evmSigner) {
|
|
17659
|
+
throw new Error("EVM Signer must be provided");
|
|
17660
|
+
}
|
|
17661
|
+
const snowbridge = SnowbridgeService.create(source);
|
|
17662
|
+
const hash = await snowbridge.transfer(evmSigner, transfer);
|
|
17663
|
+
return [hash];
|
|
17664
|
+
}
|
|
17384
17665
|
throw new Error("Either contract or extrinsic must be provided");
|
|
17385
17666
|
}
|
|
17386
17667
|
};
|