@moonbeam-network/mrl 4.0.23 → 4.1.1
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 +461 -184
- package/build/index.mjs.map +1 -1
- package/package.json +12 -12
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@4.
|
|
24
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@4.6.0_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@4.
|
|
28
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@4.6.0_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@4.
|
|
32
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-core@4.6.0_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@4.
|
|
36
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-core@4.6.0_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@4.
|
|
153
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-core@4.6.0_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@4.
|
|
7319
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-core@4.6.0_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@4.
|
|
8389
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-core@4.6.0_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@4.
|
|
8392
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@4.6.0_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@4.
|
|
8530
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@4.6.0_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@4.
|
|
8638
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@4.6.0_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@4.0
|
|
8642
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-base@4.6.0/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@4.0
|
|
8647
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-base@4.6.0/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@4.0
|
|
8723
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-base@4.6.0/node_modules/@wormhole-foundation/sdk-base/dist/esm/utils/misc.js
|
|
8724
8724
|
function lazyInstantiate(factory) {
|
|
8725
8725
|
let instance = null;
|
|
8726
8726
|
return () => {
|
|
@@ -9612,7 +9612,7 @@ function bitsetItem(bitnames, size) {
|
|
|
9612
9612
|
};
|
|
9613
9613
|
}
|
|
9614
9614
|
|
|
9615
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-base@4.0
|
|
9615
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-base@4.6.0/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@4.0
|
|
10002
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-base@4.6.0/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@4.0
|
|
10098
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-base@4.6.0/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)
|
|
@@ -10144,6 +10144,7 @@ var chainIdAndChainEntries = [
|
|
|
10144
10144
|
[59, "CreditCoin"],
|
|
10145
10145
|
[60, "Stacks"],
|
|
10146
10146
|
[63, "Moca"],
|
|
10147
|
+
[64, "MegaETH"],
|
|
10147
10148
|
[3104, "Wormchain"],
|
|
10148
10149
|
[4e3, "Cosmoshub"],
|
|
10149
10150
|
[4001, "Evmos"],
|
|
@@ -10187,7 +10188,7 @@ var toChain2 = (chain2) => {
|
|
|
10187
10188
|
throw Error(`Cannot convert to Chain: ${chain2}`);
|
|
10188
10189
|
};
|
|
10189
10190
|
|
|
10190
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-base@4.0
|
|
10191
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-base@4.6.0/node_modules/@wormhole-foundation/sdk-base/dist/esm/constants/platforms.js
|
|
10191
10192
|
var platformAndChainsEntries = [
|
|
10192
10193
|
[
|
|
10193
10194
|
"Evm",
|
|
@@ -10229,7 +10230,8 @@ var platformAndChainsEntries = [
|
|
|
10229
10230
|
"CreditCoin",
|
|
10230
10231
|
"HyperCore",
|
|
10231
10232
|
// not an actual EVM platform; treating as EVM
|
|
10232
|
-
"Moca"
|
|
10233
|
+
"Moca",
|
|
10234
|
+
"MegaETH"
|
|
10233
10235
|
]
|
|
10234
10236
|
],
|
|
10235
10237
|
[
|
|
@@ -10313,7 +10315,7 @@ var platformAddressFormatEntries = [
|
|
|
10313
10315
|
];
|
|
10314
10316
|
var platformToAddressFormat = constMap(platformAddressFormatEntries);
|
|
10315
10317
|
|
|
10316
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-base@4.0
|
|
10318
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-base@4.6.0/node_modules/@wormhole-foundation/sdk-base/dist/esm/constants/tbtc.js
|
|
10317
10319
|
var tbtc_exports = {};
|
|
10318
10320
|
__export(tbtc_exports, {
|
|
10319
10321
|
tbtcTokens: () => tbtcTokens
|
|
@@ -13135,7 +13137,7 @@ function sqrtMod(y) {
|
|
|
13135
13137
|
var Fpk1 = Field(secp256k1_CURVE.p, { sqrt: sqrtMod });
|
|
13136
13138
|
var secp256k1 = createCurve({ ...secp256k1_CURVE, Fp: Fpk1, lowS: true, endo: secp256k1_ENDO }, sha256);
|
|
13137
13139
|
|
|
13138
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0
|
|
13140
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.6.0/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/universalAddress.js
|
|
13139
13141
|
var algorandAppIdLayout = [
|
|
13140
13142
|
{ name: "appIdPrefix", binary: "bytes", custom: encoding_exports.bytes.encode("appID"), omit: true },
|
|
13141
13143
|
{ name: "appId", binary: "uint", size: 8 }
|
|
@@ -13199,7 +13201,7 @@ var UniversalAddress2 = class _UniversalAddress {
|
|
|
13199
13201
|
}
|
|
13200
13202
|
};
|
|
13201
13203
|
|
|
13202
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0
|
|
13204
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.6.0/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/address.js
|
|
13203
13205
|
function isChainSpecificAddress(thing) {
|
|
13204
13206
|
return typeof thing === "object" && "setChain" in thing;
|
|
13205
13207
|
}
|
|
@@ -13229,7 +13231,7 @@ function toUniversal(chain2, address) {
|
|
|
13229
13231
|
return new UniversalAddress2(address, platformToAddressFormat.get(platform));
|
|
13230
13232
|
}
|
|
13231
13233
|
|
|
13232
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0
|
|
13234
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.6.0/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/vaa/registration.js
|
|
13233
13235
|
var composeLiteral = (protocol, payloadName) => protocol ? `${protocol}:${payloadName}` : payloadName;
|
|
13234
13236
|
var payloadFactory = /* @__PURE__ */ new Map();
|
|
13235
13237
|
function registerPayloadType(protocol, name, layout) {
|
|
@@ -13243,13 +13245,13 @@ function registerPayloadTypes(protocol, payloads) {
|
|
|
13243
13245
|
registerPayloadType(protocol, name, layout);
|
|
13244
13246
|
}
|
|
13245
13247
|
|
|
13246
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0
|
|
13248
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.6.0/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/layout-items/amount.js
|
|
13247
13249
|
var amountItem = {
|
|
13248
13250
|
binary: "uint",
|
|
13249
13251
|
size: 32
|
|
13250
13252
|
};
|
|
13251
13253
|
|
|
13252
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0
|
|
13254
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.6.0/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/layout-items/chain.js
|
|
13253
13255
|
var chainItemBase = { binary: "uint", size: 2 };
|
|
13254
13256
|
var chainItem = (opts) => ({
|
|
13255
13257
|
...chainItemBase,
|
|
@@ -13270,7 +13272,7 @@ var chainItem = (opts) => ({
|
|
|
13270
13272
|
}
|
|
13271
13273
|
});
|
|
13272
13274
|
|
|
13273
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0
|
|
13275
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.6.0/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/layout-items/circle.js
|
|
13274
13276
|
var circleDomainItem = {
|
|
13275
13277
|
binary: "uint",
|
|
13276
13278
|
size: 4
|
|
@@ -13280,19 +13282,19 @@ var circleNonceItem = {
|
|
|
13280
13282
|
size: 8
|
|
13281
13283
|
};
|
|
13282
13284
|
|
|
13283
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0
|
|
13285
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.6.0/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/layout-items/date.js
|
|
13284
13286
|
var dateConversion = {
|
|
13285
13287
|
to: (encoded) => new Date(Number(encoded * 1000n)),
|
|
13286
13288
|
from: (decoded) => BigInt(decoded.getTime()) / 1000n
|
|
13287
13289
|
};
|
|
13288
13290
|
|
|
13289
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0
|
|
13291
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.6.0/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/layout-items/guardianSet.js
|
|
13290
13292
|
var guardianSetItem = {
|
|
13291
13293
|
binary: "uint",
|
|
13292
13294
|
size: 4
|
|
13293
13295
|
};
|
|
13294
13296
|
|
|
13295
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0
|
|
13297
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.6.0/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/layout-items/payloadId.js
|
|
13296
13298
|
var payloadIdItem = (id2) => ({
|
|
13297
13299
|
name: "payloadId",
|
|
13298
13300
|
binary: "uint",
|
|
@@ -13301,13 +13303,13 @@ var payloadIdItem = (id2) => ({
|
|
|
13301
13303
|
omit: true
|
|
13302
13304
|
});
|
|
13303
13305
|
|
|
13304
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0
|
|
13306
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.6.0/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/layout-items/sequence.js
|
|
13305
13307
|
var sequenceItem = {
|
|
13306
13308
|
binary: "uint",
|
|
13307
13309
|
size: 8
|
|
13308
13310
|
};
|
|
13309
13311
|
|
|
13310
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0
|
|
13312
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.6.0/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/signature.js
|
|
13311
13313
|
var Signature = class {
|
|
13312
13314
|
r;
|
|
13313
13315
|
s;
|
|
@@ -13351,7 +13353,7 @@ var SignatureUtils;
|
|
|
13351
13353
|
SignatureUtils2.recover = recover;
|
|
13352
13354
|
})(SignatureUtils || (SignatureUtils = {}));
|
|
13353
13355
|
|
|
13354
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0
|
|
13356
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.6.0/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/layout-items/signature.js
|
|
13355
13357
|
var signatureLayout = [
|
|
13356
13358
|
{ name: "r", binary: "uint", size: 32 },
|
|
13357
13359
|
{ name: "s", binary: "uint", size: 32 },
|
|
@@ -13366,7 +13368,7 @@ var signatureItem = {
|
|
|
13366
13368
|
}
|
|
13367
13369
|
};
|
|
13368
13370
|
|
|
13369
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0
|
|
13371
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.6.0/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/layout-items/universalAddress.js
|
|
13370
13372
|
var universalAddressItem = {
|
|
13371
13373
|
binary: "bytes",
|
|
13372
13374
|
size: 32,
|
|
@@ -13376,7 +13378,7 @@ var universalAddressItem = {
|
|
|
13376
13378
|
}
|
|
13377
13379
|
};
|
|
13378
13380
|
|
|
13379
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0
|
|
13381
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.6.0/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/layout-items/string.js
|
|
13380
13382
|
var trimZeros = (arr) => {
|
|
13381
13383
|
const i = arr.findIndex((x) => x !== 0);
|
|
13382
13384
|
return -1 < i ? arr.slice(i) : new Uint8Array([]);
|
|
@@ -13394,7 +13396,7 @@ var fixedLengthStringItem = (size) => ({
|
|
|
13394
13396
|
}
|
|
13395
13397
|
});
|
|
13396
13398
|
|
|
13397
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0
|
|
13399
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.6.0/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/vaa/vaa.js
|
|
13398
13400
|
var guardianSignatureLayout = [
|
|
13399
13401
|
{ name: "guardianIndex", binary: "uint", size: 1 },
|
|
13400
13402
|
{ name: "signature", ...signatureItem }
|
|
@@ -13414,7 +13416,7 @@ var envelopeLayout = [
|
|
|
13414
13416
|
];
|
|
13415
13417
|
var baseLayout = [...headerLayout, ...envelopeLayout];
|
|
13416
13418
|
|
|
13417
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0
|
|
13419
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.6.0/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/vaa/functions.js
|
|
13418
13420
|
function getPayloadLayout(layoutLiteral) {
|
|
13419
13421
|
const layout = payloadFactory.get(layoutLiteral);
|
|
13420
13422
|
if (!layout)
|
|
@@ -13439,7 +13441,7 @@ function payloadDiscriminator(payloadLiterals, allowAmbiguous) {
|
|
|
13439
13441
|
});
|
|
13440
13442
|
}
|
|
13441
13443
|
|
|
13442
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0
|
|
13444
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.6.0/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/circleBridge/automaticCircleBridgeLayout.js
|
|
13443
13445
|
var depositWithPayloadLayout = (customPayload) => [
|
|
13444
13446
|
payloadIdItem(1),
|
|
13445
13447
|
{
|
|
@@ -13469,7 +13471,7 @@ var automaticCircleBridgeNamedPayloads = [
|
|
|
13469
13471
|
];
|
|
13470
13472
|
registerPayloadTypes("AutomaticCircleBridge", automaticCircleBridgeNamedPayloads);
|
|
13471
13473
|
|
|
13472
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0
|
|
13474
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.6.0/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/circleBridge/circleBridgeLayout.js
|
|
13473
13475
|
var messageVersionItem = { binary: "uint", size: 4, custom: 0, omit: true };
|
|
13474
13476
|
var circleBurnMessageLayout = [
|
|
13475
13477
|
// messageBodyVersion is:
|
|
@@ -13499,7 +13501,7 @@ var circleBridgeNamedPayloads = [
|
|
|
13499
13501
|
];
|
|
13500
13502
|
registerPayloadTypes("CircleBridge", circleBridgeNamedPayloads);
|
|
13501
13503
|
|
|
13502
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0
|
|
13504
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.6.0/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/circleBridge/circleBridge.js
|
|
13503
13505
|
var CircleBridge;
|
|
13504
13506
|
(function(CircleBridge2) {
|
|
13505
13507
|
const _protocol = "CircleBridge";
|
|
@@ -13523,7 +13525,7 @@ var AutomaticCircleBridge;
|
|
|
13523
13525
|
AutomaticCircleBridge2.getTransferDiscriminator = lazyInstantiate(() => payloadDiscriminator([_protocol, _payloads]));
|
|
13524
13526
|
})(AutomaticCircleBridge || (AutomaticCircleBridge = {}));
|
|
13525
13527
|
|
|
13526
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0
|
|
13528
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.6.0/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/tokenBridge/tokenBridgeLayout.js
|
|
13527
13529
|
var fixedLengthStringItem2 = {
|
|
13528
13530
|
binary: "bytes",
|
|
13529
13531
|
size: 32,
|
|
@@ -13585,7 +13587,7 @@ var tokenBridgeNamedPayloads = [
|
|
|
13585
13587
|
];
|
|
13586
13588
|
registerPayloadTypes("TokenBridge", tokenBridgeNamedPayloads);
|
|
13587
13589
|
|
|
13588
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0
|
|
13590
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.6.0/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/portico/porticoLayout.js
|
|
13589
13591
|
var flagsItem = bitsetItem(["shouldWrapNative", "shouldUnwrapNative"]);
|
|
13590
13592
|
var porticoFlagSetLayout = [
|
|
13591
13593
|
{ name: "recipientChain", binary: "uint", endianness: "little", size: 2 },
|
|
@@ -13620,7 +13622,7 @@ var namedPayloads = [
|
|
|
13620
13622
|
];
|
|
13621
13623
|
registerPayloadTypes("PorticoBridge", namedPayloads);
|
|
13622
13624
|
|
|
13623
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0
|
|
13625
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.6.0/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/portico/portico.js
|
|
13624
13626
|
var PorticoBridge;
|
|
13625
13627
|
(function(PorticoBridge2) {
|
|
13626
13628
|
const _protocol = "PorticoBridge";
|
|
@@ -13640,7 +13642,7 @@ var PorticoBridge;
|
|
|
13640
13642
|
};
|
|
13641
13643
|
})(PorticoBridge || (PorticoBridge = {}));
|
|
13642
13644
|
|
|
13643
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0
|
|
13645
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.6.0/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/relayer/relayerLayout.js
|
|
13644
13646
|
var encodedExecutionInfoItem = {
|
|
13645
13647
|
binary: "bytes",
|
|
13646
13648
|
layout: [
|
|
@@ -13707,7 +13709,7 @@ var namedPayloads2 = [
|
|
|
13707
13709
|
];
|
|
13708
13710
|
registerPayloadTypes("Relayer", namedPayloads2);
|
|
13709
13711
|
|
|
13710
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0
|
|
13712
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.6.0/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/tokenBridge/automaticTokenBridgeLayout.js
|
|
13711
13713
|
var connectPayload = [
|
|
13712
13714
|
payloadIdItem(1),
|
|
13713
13715
|
{ name: "targetRelayerFee", ...amountItem },
|
|
@@ -13719,7 +13721,7 @@ var automaticTokenBridgeNamedPayloads = [
|
|
|
13719
13721
|
];
|
|
13720
13722
|
registerPayloadTypes("AutomaticTokenBridge", automaticTokenBridgeNamedPayloads);
|
|
13721
13723
|
|
|
13722
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0
|
|
13724
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.6.0/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/tokenBridge/tokenBridge.js
|
|
13723
13725
|
var TokenBridge;
|
|
13724
13726
|
(function(TokenBridge2) {
|
|
13725
13727
|
const _protocol = "TokenBridge";
|
|
@@ -13739,21 +13741,21 @@ var ExecutorTokenBridge;
|
|
|
13739
13741
|
const _payloads = ["TransferWithExecutorRelay"];
|
|
13740
13742
|
})(ExecutorTokenBridge || (ExecutorTokenBridge = {}));
|
|
13741
13743
|
|
|
13742
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0
|
|
13744
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.6.0/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/tokenBridge/executorTokenBridgeLayout.js
|
|
13743
13745
|
var payload = [{ name: "targetRecipient", ...universalAddressItem }];
|
|
13744
13746
|
var executorTokenBridgeNamedPayloads = [
|
|
13745
13747
|
["TransferWithExecutorRelay", transferWithPayloadLayout(payload)]
|
|
13746
13748
|
];
|
|
13747
13749
|
registerPayloadTypes("ExecutorTokenBridge", executorTokenBridgeNamedPayloads);
|
|
13748
13750
|
|
|
13749
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0
|
|
13751
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.6.0/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/governance/globalAccountant.js
|
|
13750
13752
|
var modificationKinds = [
|
|
13751
13753
|
["Add", 1],
|
|
13752
13754
|
["Subtract", 2],
|
|
13753
13755
|
["Unknown", 3]
|
|
13754
13756
|
];
|
|
13755
13757
|
|
|
13756
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0
|
|
13758
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.6.0/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/governance/layout.js
|
|
13757
13759
|
var rawEvmAddressItem = {
|
|
13758
13760
|
binary: "bytes",
|
|
13759
13761
|
size: 20,
|
|
@@ -14015,7 +14017,7 @@ registerPayloadTypes("GeneralPurposeGovernance", generalPurposeGovernancePayload
|
|
|
14015
14017
|
registerPayloadTypes("WormchainGovernance", wormchainGovernancePayloads);
|
|
14016
14018
|
registerPayloadTypes("GatewayGovernance", gatewayGovernancePayloads);
|
|
14017
14019
|
|
|
14018
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0
|
|
14020
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.6.0/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/tbtc/tbtc.js
|
|
14019
14021
|
var TBTCBridge;
|
|
14020
14022
|
(function(TBTCBridge2) {
|
|
14021
14023
|
const _protocol = "TBTCBridge";
|
|
@@ -14033,7 +14035,7 @@ var TBTCBridge;
|
|
|
14033
14035
|
};
|
|
14034
14036
|
})(TBTCBridge || (TBTCBridge = {}));
|
|
14035
14037
|
|
|
14036
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0
|
|
14038
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.6.0/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/tbtc/tbtcLayout.js
|
|
14037
14039
|
var tbtcPayloadLayout = [
|
|
14038
14040
|
{ name: "recipient", ...universalAddressItem }
|
|
14039
14041
|
];
|
|
@@ -14046,7 +14048,7 @@ var namedPayloads3 = [
|
|
|
14046
14048
|
];
|
|
14047
14049
|
registerPayloadTypes("TBTCBridge", namedPayloads3);
|
|
14048
14050
|
|
|
14049
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0
|
|
14051
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.6.0/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/executor/relayInstruction.js
|
|
14050
14052
|
var gasInstructionLayout = [
|
|
14051
14053
|
{ name: "gasLimit", binary: "uint", size: 16 },
|
|
14052
14054
|
{ name: "msgValue", binary: "uint", size: 16 }
|
|
@@ -14055,6 +14057,14 @@ var gasDropOffInstructionLayout = [
|
|
|
14055
14057
|
{ name: "dropOff", binary: "uint", size: 16 },
|
|
14056
14058
|
{ name: "recipient", ...universalAddressItem }
|
|
14057
14059
|
];
|
|
14060
|
+
var stacksNttReceiveInstructionLayout = [
|
|
14061
|
+
{ name: "nttManager", binary: "bytes", lengthSize: 1 },
|
|
14062
|
+
// Stacks contract principal (variable length)
|
|
14063
|
+
{ name: "recipient", binary: "bytes", lengthSize: 1 },
|
|
14064
|
+
// Stacks recipient address (variable length)
|
|
14065
|
+
{ name: "gasDropOff", binary: "uint", size: 16 }
|
|
14066
|
+
// STX amount for gas drop-off
|
|
14067
|
+
];
|
|
14058
14068
|
var relayInstructionLayout = [
|
|
14059
14069
|
{
|
|
14060
14070
|
name: "request",
|
|
@@ -14063,7 +14073,8 @@ var relayInstructionLayout = [
|
|
|
14063
14073
|
idTag: "type",
|
|
14064
14074
|
layouts: [
|
|
14065
14075
|
[[1, "GasInstruction"], gasInstructionLayout],
|
|
14066
|
-
[[2, "GasDropOffInstruction"], gasDropOffInstructionLayout]
|
|
14076
|
+
[[2, "GasDropOffInstruction"], gasDropOffInstructionLayout],
|
|
14077
|
+
[[3, "StacksNttReceiveInstruction"], stacksNttReceiveInstructionLayout]
|
|
14067
14078
|
]
|
|
14068
14079
|
}
|
|
14069
14080
|
];
|
|
@@ -14075,7 +14086,7 @@ var relayInstructionsLayout = [
|
|
|
14075
14086
|
}
|
|
14076
14087
|
];
|
|
14077
14088
|
|
|
14078
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0
|
|
14089
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.6.0/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/executor/signedQuote.js
|
|
14079
14090
|
var quoteLayout = [
|
|
14080
14091
|
{
|
|
14081
14092
|
name: "quote",
|
|
@@ -14118,7 +14129,7 @@ var signedQuoteLayout = [
|
|
|
14118
14129
|
{ name: "signature", binary: "bytes", size: 65 }
|
|
14119
14130
|
];
|
|
14120
14131
|
|
|
14121
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.0
|
|
14132
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-definitions@4.6.0/node_modules/@wormhole-foundation/sdk-definitions/dist/esm/protocols/executor/api.js
|
|
14122
14133
|
var RelayStatus;
|
|
14123
14134
|
(function(RelayStatus2) {
|
|
14124
14135
|
RelayStatus2["Pending"] = "pending";
|
|
@@ -14137,7 +14148,7 @@ var RequestPrefix;
|
|
|
14137
14148
|
RequestPrefix2["ERC2"] = "ERC2";
|
|
14138
14149
|
})(RequestPrefix || (RequestPrefix = {}));
|
|
14139
14150
|
|
|
14140
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@4.
|
|
14151
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@4.6.0_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-tokenbridge/dist/esm/executorTokenBridge.js
|
|
14141
14152
|
var RELAYER_ABI = [
|
|
14142
14153
|
"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)",
|
|
14143
14154
|
"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)",
|
|
@@ -14257,14 +14268,14 @@ var EvmExecutorTokenBridge = class _EvmExecutorTokenBridge {
|
|
|
14257
14268
|
}
|
|
14258
14269
|
};
|
|
14259
14270
|
|
|
14260
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@4.
|
|
14271
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@4.6.0_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-tokenbridge/dist/esm/ethers-contracts/index.js
|
|
14261
14272
|
var ethers_contracts_exports2 = {};
|
|
14262
14273
|
__export(ethers_contracts_exports2, {
|
|
14263
14274
|
Bridge__factory: () => Bridge__factory,
|
|
14264
14275
|
TokenBridgeRelayer__factory: () => TokenBridgeRelayer__factory
|
|
14265
14276
|
});
|
|
14266
14277
|
|
|
14267
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@4.
|
|
14278
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@4.6.0_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
|
|
14268
14279
|
var _abi2 = [
|
|
14269
14280
|
{
|
|
14270
14281
|
anonymous: false,
|
|
@@ -15504,7 +15515,7 @@ var Bridge__factory = class extends ContractFactory {
|
|
|
15504
15515
|
}
|
|
15505
15516
|
};
|
|
15506
15517
|
|
|
15507
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@4.
|
|
15518
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@4.6.0_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
|
|
15508
15519
|
var _abi3 = [
|
|
15509
15520
|
{
|
|
15510
15521
|
inputs: [
|
|
@@ -16575,7 +16586,7 @@ var TokenBridgeRelayer__factory = class extends ContractFactory {
|
|
|
16575
16586
|
}
|
|
16576
16587
|
};
|
|
16577
16588
|
|
|
16578
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@4.
|
|
16589
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@4.6.0_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-tokenbridge/dist/esm/index.js
|
|
16579
16590
|
registerProtocol2(_platform2, "TokenBridge", EvmTokenBridge);
|
|
16580
16591
|
registerProtocol2(_platform2, "AutomaticTokenBridge", EvmAutomaticTokenBridge);
|
|
16581
16592
|
registerProtocol2(_platform2, "ExecutorTokenBridge", EvmExecutorTokenBridge);
|
|
@@ -16770,34 +16781,189 @@ async function getExecuteTransferData({
|
|
|
16770
16781
|
|
|
16771
16782
|
// src/getTransferData/getTransferData.ts
|
|
16772
16783
|
import {
|
|
16773
|
-
ContractConfig as
|
|
16784
|
+
ContractConfig as ContractConfig3,
|
|
16774
16785
|
ExtrinsicConfig,
|
|
16786
|
+
SnowbridgeConfig as SnowbridgeConfig2,
|
|
16775
16787
|
WormholeConfig as WormholeConfig2
|
|
16776
16788
|
} from "@moonbeam-network/xcm-builder";
|
|
16777
16789
|
import {
|
|
16778
16790
|
convertToChainDecimals as convertToChainDecimals2,
|
|
16779
|
-
EvmService as
|
|
16791
|
+
EvmService as EvmService4,
|
|
16780
16792
|
getDestinationData,
|
|
16781
|
-
PolkadotService as
|
|
16793
|
+
PolkadotService as PolkadotService3
|
|
16782
16794
|
} from "@moonbeam-network/xcm-sdk";
|
|
16783
16795
|
import {
|
|
16784
16796
|
AssetAmount as AssetAmount3,
|
|
16785
|
-
EvmChain,
|
|
16786
|
-
EvmParachain as
|
|
16797
|
+
EvmChain as EvmChain3,
|
|
16798
|
+
EvmParachain as EvmParachain4
|
|
16787
16799
|
} from "@moonbeam-network/xcm-types";
|
|
16788
16800
|
import { toBigInt as toBigInt3 } from "@moonbeam-network/xcm-utils";
|
|
16789
16801
|
import Big2 from "big.js";
|
|
16790
16802
|
|
|
16791
|
-
// src/
|
|
16792
|
-
import { getMoonChain } from "@moonbeam-network/xcm-config";
|
|
16793
|
-
import { getBalance, getDestinationFee } from "@moonbeam-network/xcm-sdk";
|
|
16803
|
+
// src/services/snowbridge/SnowbridgeService.ts
|
|
16794
16804
|
import {
|
|
16795
|
-
|
|
16796
|
-
|
|
16797
|
-
|
|
16805
|
+
ContractConfig,
|
|
16806
|
+
ERC20_ABI,
|
|
16807
|
+
GATEWAY_ABI
|
|
16808
|
+
} from "@moonbeam-network/xcm-builder";
|
|
16809
|
+
import { EvmService as EvmService2 } from "@moonbeam-network/xcm-sdk";
|
|
16810
|
+
import { EvmChain } from "@moonbeam-network/xcm-types";
|
|
16811
|
+
import { u8aToHex } from "@polkadot/util";
|
|
16812
|
+
import { decodeAddress } from "@polkadot/util-crypto";
|
|
16813
|
+
import { encodeFunctionData } from "viem";
|
|
16814
|
+
var SnowbridgeService = class _SnowbridgeService {
|
|
16815
|
+
chain;
|
|
16816
|
+
#evmService;
|
|
16817
|
+
#gatewayAddress;
|
|
16818
|
+
static create(chain2) {
|
|
16819
|
+
return new _SnowbridgeService(chain2);
|
|
16820
|
+
}
|
|
16821
|
+
constructor(chain2) {
|
|
16822
|
+
if (!EvmChain.is(chain2) || !chain2.contracts?.Gateway) {
|
|
16823
|
+
throw new Error(
|
|
16824
|
+
"Chain must be an EVMChain with the Gateway contract address configured for Snowbridge operations"
|
|
16825
|
+
);
|
|
16826
|
+
}
|
|
16827
|
+
this.chain = chain2;
|
|
16828
|
+
this.#gatewayAddress = chain2.contracts.Gateway;
|
|
16829
|
+
this.#evmService = EvmService2.create(chain2);
|
|
16830
|
+
}
|
|
16831
|
+
async checkAllowance(ownerAddress, tokenAddress, spenderAddress) {
|
|
16832
|
+
const allowance = await this.#evmService.client.readContract({
|
|
16833
|
+
abi: ERC20_ABI,
|
|
16834
|
+
address: tokenAddress,
|
|
16835
|
+
args: [ownerAddress, spenderAddress],
|
|
16836
|
+
functionName: "allowance"
|
|
16837
|
+
});
|
|
16838
|
+
if (typeof allowance !== "bigint") {
|
|
16839
|
+
throw new Error(
|
|
16840
|
+
`Could not get allowance on ${this.chain.name} for token ${tokenAddress}`
|
|
16841
|
+
);
|
|
16842
|
+
}
|
|
16843
|
+
return allowance;
|
|
16844
|
+
}
|
|
16845
|
+
async transfer(signer, transfer) {
|
|
16846
|
+
const { args } = transfer;
|
|
16847
|
+
const { tokenAddress, amount, requiresApproval } = args;
|
|
16848
|
+
if (!signer.account) {
|
|
16849
|
+
throw new Error("Signer account is required");
|
|
16850
|
+
}
|
|
16851
|
+
const contract = this.buildContractConfig(transfer);
|
|
16852
|
+
if (!requiresApproval) {
|
|
16853
|
+
return await this.#evmService.transfer(signer, contract);
|
|
16854
|
+
}
|
|
16855
|
+
const currentAllowance = await this.checkAllowance(
|
|
16856
|
+
signer.account.address,
|
|
16857
|
+
tokenAddress,
|
|
16858
|
+
this.#gatewayAddress
|
|
16859
|
+
);
|
|
16860
|
+
if (currentAllowance < amount) {
|
|
16861
|
+
await this.approve(signer, tokenAddress, this.#gatewayAddress, amount);
|
|
16862
|
+
}
|
|
16863
|
+
return await this.#evmService.transfer(signer, contract);
|
|
16864
|
+
}
|
|
16865
|
+
buildContractConfig(transfer) {
|
|
16866
|
+
const { args } = transfer;
|
|
16867
|
+
const {
|
|
16868
|
+
tokenAddress,
|
|
16869
|
+
destinationAddress,
|
|
16870
|
+
destinationParaId,
|
|
16871
|
+
amount,
|
|
16872
|
+
bridgeFeeAmount,
|
|
16873
|
+
requiresApproval
|
|
16874
|
+
} = args;
|
|
16875
|
+
const value = requiresApproval ? bridgeFeeAmount : amount + bridgeFeeAmount;
|
|
16876
|
+
const contractArgs = [
|
|
16877
|
+
tokenAddress,
|
|
16878
|
+
destinationParaId,
|
|
16879
|
+
{
|
|
16880
|
+
kind: 1,
|
|
16881
|
+
data: u8aToHex(decodeAddress(destinationAddress))
|
|
16882
|
+
},
|
|
16883
|
+
0n,
|
|
16884
|
+
amount
|
|
16885
|
+
];
|
|
16886
|
+
return new ContractConfig({
|
|
16887
|
+
address: this.#gatewayAddress,
|
|
16888
|
+
abi: GATEWAY_ABI,
|
|
16889
|
+
args: contractArgs,
|
|
16890
|
+
func: "sendToken",
|
|
16891
|
+
value,
|
|
16892
|
+
module: "Gateway"
|
|
16893
|
+
});
|
|
16894
|
+
}
|
|
16895
|
+
async approve(signer, tokenAddress, spenderAddress, amount) {
|
|
16896
|
+
const { request } = await this.#evmService.client.simulateContract({
|
|
16897
|
+
abi: ERC20_ABI,
|
|
16898
|
+
account: signer.account,
|
|
16899
|
+
address: tokenAddress,
|
|
16900
|
+
functionName: "approve",
|
|
16901
|
+
args: [spenderAddress, amount]
|
|
16902
|
+
});
|
|
16903
|
+
const hash = await signer.writeContract(request);
|
|
16904
|
+
await this.#evmService.client.waitForTransactionReceipt({
|
|
16905
|
+
hash
|
|
16906
|
+
});
|
|
16907
|
+
return hash;
|
|
16908
|
+
}
|
|
16909
|
+
async getFee(address, transfer) {
|
|
16910
|
+
const { args } = transfer;
|
|
16911
|
+
const { tokenAddress, amount, requiresApproval } = args;
|
|
16912
|
+
const contract = this.buildContractConfig(transfer);
|
|
16913
|
+
if (!requiresApproval) {
|
|
16914
|
+
return await this.#evmService.getFee(address, contract);
|
|
16915
|
+
}
|
|
16916
|
+
const currentAllowance = await this.checkAllowance(
|
|
16917
|
+
address,
|
|
16918
|
+
tokenAddress,
|
|
16919
|
+
this.#gatewayAddress
|
|
16920
|
+
);
|
|
16921
|
+
if (currentAllowance >= amount) {
|
|
16922
|
+
return await this.#evmService.getFee(address, contract);
|
|
16923
|
+
}
|
|
16924
|
+
return await this.estimateApproveAndSendFee(address, transfer);
|
|
16925
|
+
}
|
|
16926
|
+
async estimateApproveAndSendFee(address, transfer) {
|
|
16927
|
+
const { args } = transfer;
|
|
16928
|
+
const { tokenAddress, amount } = args;
|
|
16929
|
+
const contract = this.buildContractConfig(transfer);
|
|
16930
|
+
try {
|
|
16931
|
+
const approveData = encodeFunctionData({
|
|
16932
|
+
abi: ERC20_ABI,
|
|
16933
|
+
functionName: "approve",
|
|
16934
|
+
args: [this.#gatewayAddress, amount]
|
|
16935
|
+
});
|
|
16936
|
+
const approveGas = await this.#evmService.client.estimateGas({
|
|
16937
|
+
account: address,
|
|
16938
|
+
to: tokenAddress,
|
|
16939
|
+
data: approveData
|
|
16940
|
+
});
|
|
16941
|
+
const sendData = encodeFunctionData({
|
|
16942
|
+
abi: contract.abi,
|
|
16943
|
+
functionName: contract.func,
|
|
16944
|
+
args: contract.args
|
|
16945
|
+
});
|
|
16946
|
+
const sendGas = await this.#evmService.client.estimateGas({
|
|
16947
|
+
account: address,
|
|
16948
|
+
to: contract.address,
|
|
16949
|
+
data: sendData,
|
|
16950
|
+
value: contract.value
|
|
16951
|
+
});
|
|
16952
|
+
const gasPrice = await this.#evmService.client.getGasPrice();
|
|
16953
|
+
return (approveGas + sendGas) * gasPrice;
|
|
16954
|
+
} catch (error) {
|
|
16955
|
+
console.error("Error estimating approve + send fee:", error);
|
|
16956
|
+
return 0n;
|
|
16957
|
+
}
|
|
16958
|
+
}
|
|
16959
|
+
};
|
|
16960
|
+
|
|
16961
|
+
// src/getTransferData/getBridgeChainData.ts
|
|
16962
|
+
import { getBalance, getDestinationFee } from "@moonbeam-network/xcm-sdk";
|
|
16963
|
+
import { EvmParachain, Parachain } from "@moonbeam-network/xcm-types";
|
|
16798
16964
|
import { getMultilocationDerivedAddresses } from "@moonbeam-network/xcm-utils";
|
|
16799
16965
|
import { evmToAddress } from "@polkadot/util-crypto";
|
|
16800
|
-
async function
|
|
16966
|
+
async function getBridgeChainData({
|
|
16801
16967
|
route,
|
|
16802
16968
|
sourceAddress,
|
|
16803
16969
|
destinationAddress
|
|
@@ -16807,80 +16973,87 @@ async function getMoonChainData({
|
|
|
16807
16973
|
`MRL config is not defined for source chain ${route.source.chain.name} and asset ${route.source.asset.originSymbol}`
|
|
16808
16974
|
);
|
|
16809
16975
|
}
|
|
16810
|
-
const
|
|
16811
|
-
const
|
|
16812
|
-
|
|
16813
|
-
destination: route.destination.chain,
|
|
16976
|
+
const bridgeChain = route.mrl.bridgeChain.chain;
|
|
16977
|
+
const bridgeChainAddress = getBridgeChainAddress({
|
|
16978
|
+
route,
|
|
16814
16979
|
sourceAddress,
|
|
16815
16980
|
destinationAddress
|
|
16816
16981
|
});
|
|
16817
16982
|
const fee = await getDestinationFee({
|
|
16818
|
-
address:
|
|
16983
|
+
address: bridgeChainAddress,
|
|
16819
16984
|
asset: route.source.asset,
|
|
16820
|
-
destination:
|
|
16821
|
-
fee: route.mrl.
|
|
16822
|
-
feeAsset: route.mrl.
|
|
16985
|
+
destination: bridgeChain,
|
|
16986
|
+
fee: route.mrl.bridgeChain.fee.amount,
|
|
16987
|
+
feeAsset: route.mrl.bridgeChain.fee.asset,
|
|
16823
16988
|
source: route.source.chain
|
|
16824
16989
|
});
|
|
16825
16990
|
const balance = await getBalance({
|
|
16826
|
-
address:
|
|
16827
|
-
asset:
|
|
16828
|
-
builder: route.mrl.
|
|
16829
|
-
chain:
|
|
16991
|
+
address: bridgeChainAddress,
|
|
16992
|
+
asset: bridgeChain.getChainAsset(route.mrl.bridgeChain.asset),
|
|
16993
|
+
builder: route.mrl.bridgeChain.balance,
|
|
16994
|
+
chain: bridgeChain
|
|
16830
16995
|
});
|
|
16831
16996
|
const feeBalance = await getBalance({
|
|
16832
|
-
address:
|
|
16833
|
-
asset:
|
|
16834
|
-
builder: route.mrl.
|
|
16835
|
-
chain:
|
|
16997
|
+
address: bridgeChainAddress,
|
|
16998
|
+
asset: bridgeChain.getChainAsset(route.mrl.bridgeChain.fee.asset),
|
|
16999
|
+
builder: route.mrl.bridgeChain.fee.balance,
|
|
17000
|
+
chain: bridgeChain
|
|
16836
17001
|
});
|
|
16837
17002
|
return {
|
|
16838
|
-
address:
|
|
17003
|
+
address: bridgeChainAddress,
|
|
16839
17004
|
balance,
|
|
16840
17005
|
feeBalance,
|
|
16841
|
-
chain:
|
|
17006
|
+
chain: bridgeChain,
|
|
16842
17007
|
fee
|
|
16843
17008
|
};
|
|
16844
17009
|
}
|
|
16845
|
-
function
|
|
16846
|
-
|
|
16847
|
-
destination,
|
|
17010
|
+
function getBridgeChainAddress({
|
|
17011
|
+
route,
|
|
16848
17012
|
sourceAddress,
|
|
16849
17013
|
destinationAddress
|
|
16850
17014
|
}) {
|
|
16851
|
-
const
|
|
16852
|
-
const
|
|
16853
|
-
const
|
|
16854
|
-
|
|
16855
|
-
|
|
17015
|
+
const source = route.source.chain;
|
|
17016
|
+
const destination = route.destination.chain;
|
|
17017
|
+
const bridgeChain = route.mrl.bridgeChain.chain;
|
|
17018
|
+
const isDestinationBridgeChain = bridgeChain.isEqual(destination);
|
|
17019
|
+
const isSourceBridgeChain = bridgeChain.isEqual(source);
|
|
17020
|
+
let bridgeChainAddress = isDestinationBridgeChain ? destinationAddress : sourceAddress;
|
|
17021
|
+
if (Parachain.is(source) && !isSourceBridgeChain) {
|
|
16856
17022
|
const isSourceEvmSigner = EvmParachain.is(source) && source.isEvmSigner;
|
|
16857
17023
|
const { address20: computedOriginAccount } = getMultilocationDerivedAddresses({
|
|
16858
17024
|
address: isSourceEvmSigner ? evmToAddress(sourceAddress) : sourceAddress,
|
|
16859
17025
|
paraId: source.parachainId,
|
|
16860
17026
|
isParents: true
|
|
16861
17027
|
});
|
|
16862
|
-
|
|
17028
|
+
bridgeChainAddress = computedOriginAccount;
|
|
16863
17029
|
}
|
|
16864
|
-
return
|
|
17030
|
+
return bridgeChainAddress;
|
|
16865
17031
|
}
|
|
16866
17032
|
|
|
16867
17033
|
// src/getTransferData/getSourceData.ts
|
|
16868
17034
|
import {
|
|
16869
|
-
ContractConfig,
|
|
17035
|
+
ContractConfig as ContractConfig2,
|
|
16870
17036
|
MrlBuilder as MrlBuilder3,
|
|
17037
|
+
Provider as Provider2,
|
|
17038
|
+
SnowbridgeConfig,
|
|
17039
|
+
SubstrateQueryConfig,
|
|
16871
17040
|
WormholeConfig
|
|
16872
17041
|
} from "@moonbeam-network/xcm-builder";
|
|
16873
17042
|
import {
|
|
17043
|
+
EvmService as EvmService3,
|
|
16874
17044
|
getAssetMin,
|
|
16875
17045
|
getBalance as getBalance2,
|
|
16876
17046
|
getContractFee,
|
|
16877
17047
|
getDestinationFeeBalance,
|
|
16878
17048
|
getExistentialDeposit,
|
|
16879
17049
|
getExtrinsicFee,
|
|
16880
|
-
getMax
|
|
17050
|
+
getMax,
|
|
17051
|
+
PolkadotService as PolkadotService2
|
|
16881
17052
|
} from "@moonbeam-network/xcm-sdk";
|
|
16882
17053
|
import {
|
|
16883
|
-
AssetAmount as AssetAmount2
|
|
17054
|
+
AssetAmount as AssetAmount2,
|
|
17055
|
+
EvmChain as EvmChain2,
|
|
17056
|
+
EvmParachain as EvmParachain3
|
|
16884
17057
|
} from "@moonbeam-network/xcm-types";
|
|
16885
17058
|
import { toBigInt as toBigInt2 } from "@moonbeam-network/xcm-utils";
|
|
16886
17059
|
|
|
@@ -16888,11 +17061,11 @@ import { toBigInt as toBigInt2 } from "@moonbeam-network/xcm-utils";
|
|
|
16888
17061
|
import {
|
|
16889
17062
|
BATCH_CONTRACT_ABI,
|
|
16890
17063
|
BATCH_CONTRACT_ADDRESS,
|
|
16891
|
-
ERC20_ABI,
|
|
16892
|
-
MrlBuilder as MrlBuilder2
|
|
17064
|
+
ERC20_ABI as ERC20_ABI2,
|
|
17065
|
+
MrlBuilder as MrlBuilder2,
|
|
17066
|
+
Provider
|
|
16893
17067
|
} from "@moonbeam-network/xcm-builder";
|
|
16894
17068
|
import {
|
|
16895
|
-
getMoonChain as getMoonChain2,
|
|
16896
17069
|
moonbaseAlpha,
|
|
16897
17070
|
moonbeam
|
|
16898
17071
|
} from "@moonbeam-network/xcm-config";
|
|
@@ -16909,33 +17082,33 @@ import {
|
|
|
16909
17082
|
import Big from "big.js";
|
|
16910
17083
|
import {
|
|
16911
17084
|
createPublicClient as createPublicClient2,
|
|
16912
|
-
encodeFunctionData,
|
|
17085
|
+
encodeFunctionData as encodeFunctionData2,
|
|
16913
17086
|
http as http2
|
|
16914
17087
|
} from "viem";
|
|
16915
17088
|
var MOON_CHAIN_AUTOMATIC_GAS_ESTIMATION = {
|
|
16916
17089
|
[moonbeam.key]: 1273110n,
|
|
16917
17090
|
[moonbaseAlpha.key]: 1470417n
|
|
16918
17091
|
};
|
|
16919
|
-
function
|
|
17092
|
+
function getBridgeChainFeeValueOnSource({
|
|
16920
17093
|
destinationData,
|
|
16921
|
-
|
|
17094
|
+
bridgeChainData,
|
|
16922
17095
|
sourceData
|
|
16923
17096
|
}) {
|
|
16924
17097
|
const isSourceParachain = EvmParachain2.isAnyParachain(sourceData.chain);
|
|
16925
|
-
const
|
|
16926
|
-
|
|
17098
|
+
const isDestinationBridgeChain = destinationData.chain.isEqual(
|
|
17099
|
+
bridgeChainData.chain
|
|
16927
17100
|
);
|
|
16928
|
-
const
|
|
16929
|
-
|
|
17101
|
+
const isSameAssetPayingBridgeChainFee = sourceData.balance.isSame(
|
|
17102
|
+
bridgeChainData.fee
|
|
16930
17103
|
);
|
|
16931
|
-
return !
|
|
16932
|
-
asset:
|
|
16933
|
-
target: sourceData.chain.getChainAsset(
|
|
17104
|
+
return !isDestinationBridgeChain && isSourceParachain && isSameAssetPayingBridgeChainFee ? convertToChainDecimals({
|
|
17105
|
+
asset: bridgeChainData.fee,
|
|
17106
|
+
target: sourceData.chain.getChainAsset(bridgeChainData.fee)
|
|
16934
17107
|
}).toBig() : Big(0);
|
|
16935
17108
|
}
|
|
16936
17109
|
function getMrlMin({
|
|
16937
17110
|
destinationData,
|
|
16938
|
-
|
|
17111
|
+
bridgeChainData,
|
|
16939
17112
|
sourceData
|
|
16940
17113
|
}) {
|
|
16941
17114
|
const minInDestination = getMin(destinationData);
|
|
@@ -16945,16 +17118,19 @@ function getMrlMin({
|
|
|
16945
17118
|
amount: minInDestination.amount
|
|
16946
17119
|
}
|
|
16947
17120
|
);
|
|
16948
|
-
const
|
|
17121
|
+
const bridgeChainFee = getBridgeChainFeeValueOnSource({
|
|
16949
17122
|
destinationData,
|
|
16950
|
-
|
|
17123
|
+
bridgeChainData,
|
|
16951
17124
|
sourceData
|
|
16952
17125
|
});
|
|
16953
|
-
const relayerFee = sourceData.
|
|
17126
|
+
const relayerFee = sourceData.otherFees?.relayer?.amount ? sourceData.otherFees.relayer.toBig() : Big(0);
|
|
16954
17127
|
return min.copyWith({
|
|
16955
|
-
amount: BigInt(min.toBig().add(
|
|
17128
|
+
amount: BigInt(min.toBig().add(bridgeChainFee).add(relayerFee).toFixed())
|
|
16956
17129
|
});
|
|
16957
17130
|
}
|
|
17131
|
+
function requiresTransact(route) {
|
|
17132
|
+
return route.mrl?.transfer.provider === Provider.Wormhole && EvmParachain2.isAnyParachain(route.source.chain);
|
|
17133
|
+
}
|
|
16958
17134
|
async function buildTransfer(params) {
|
|
16959
17135
|
const { route } = params;
|
|
16960
17136
|
if (!route.mrl) {
|
|
@@ -16970,11 +17146,12 @@ async function buildTransfer(params) {
|
|
|
16970
17146
|
const builderParams = await getMrlBuilderParams(params);
|
|
16971
17147
|
return route.mrl.transfer.build({
|
|
16972
17148
|
...builderParams,
|
|
16973
|
-
transact:
|
|
17149
|
+
transact: requiresTransact(route) ? await getTransact(builderParams) : void 0
|
|
16974
17150
|
});
|
|
16975
17151
|
}
|
|
16976
17152
|
async function getMrlBuilderParams({
|
|
16977
17153
|
asset,
|
|
17154
|
+
protocolFee,
|
|
16978
17155
|
destinationAddress,
|
|
16979
17156
|
feeAsset,
|
|
16980
17157
|
isAutomatic,
|
|
@@ -16989,22 +17166,23 @@ async function getMrlBuilderParams({
|
|
|
16989
17166
|
}
|
|
16990
17167
|
const source = route.source.chain;
|
|
16991
17168
|
const destination = route.destination.chain;
|
|
16992
|
-
const
|
|
16993
|
-
const [sourceApi, destinationApi,
|
|
17169
|
+
const bridgeChain = route.mrl.bridgeChain.chain;
|
|
17170
|
+
const [sourceApi, destinationApi, bridgeApi] = await Promise.all([
|
|
16994
17171
|
EvmParachain2.isAnyParachain(source) ? getPolkadotApi(source.ws) : void 0,
|
|
16995
17172
|
EvmParachain2.isAnyParachain(destination) ? getPolkadotApi(destination.ws) : void 0,
|
|
16996
|
-
getPolkadotApi(
|
|
17173
|
+
getPolkadotApi(bridgeChain.ws)
|
|
16997
17174
|
]);
|
|
16998
17175
|
return {
|
|
16999
17176
|
asset,
|
|
17177
|
+
protocolFee,
|
|
17000
17178
|
destination,
|
|
17001
17179
|
destinationAddress,
|
|
17002
17180
|
destinationApi,
|
|
17003
17181
|
fee: feeAsset,
|
|
17004
17182
|
isAutomatic,
|
|
17005
|
-
moonApi,
|
|
17006
|
-
moonAsset:
|
|
17007
|
-
|
|
17183
|
+
moonApi: bridgeApi,
|
|
17184
|
+
moonAsset: bridgeChain.nativeAsset,
|
|
17185
|
+
bridgeChain,
|
|
17008
17186
|
sendOnlyRemoteExecution,
|
|
17009
17187
|
source,
|
|
17010
17188
|
sourceAddress,
|
|
@@ -17012,9 +17190,9 @@ async function getMrlBuilderParams({
|
|
|
17012
17190
|
};
|
|
17013
17191
|
}
|
|
17014
17192
|
async function getTransact(params) {
|
|
17015
|
-
const { sourceAddress, source,
|
|
17016
|
-
const polkadot = await PolkadotService.create(
|
|
17017
|
-
const
|
|
17193
|
+
const { sourceAddress, source, bridgeChain } = params;
|
|
17194
|
+
const polkadot = await PolkadotService.create(bridgeChain);
|
|
17195
|
+
const bridgeChainGasLimit = await getBridgeChainGasLimit(params);
|
|
17018
17196
|
if (!EvmParachain2.isAnyParachain(source)) {
|
|
17019
17197
|
throw new Error("Source chain must be Parachain or EvmParachain");
|
|
17020
17198
|
}
|
|
@@ -17023,7 +17201,7 @@ async function getTransact(params) {
|
|
|
17023
17201
|
paraId: source.parachainId,
|
|
17024
17202
|
isParents: true
|
|
17025
17203
|
});
|
|
17026
|
-
const extrinsic = MrlBuilder2().wormhole().extrinsic().ethereumXcm().transact().build({ ...params,
|
|
17204
|
+
const extrinsic = MrlBuilder2().wormhole().extrinsic().ethereumXcm().transact().build({ ...params, bridgeChainGasLimit });
|
|
17027
17205
|
const { weight } = await polkadot.getPaymentInfo(address20, extrinsic);
|
|
17028
17206
|
return {
|
|
17029
17207
|
call: polkadot.getExtrinsicCallHash(extrinsic),
|
|
@@ -17033,13 +17211,16 @@ async function getTransact(params) {
|
|
|
17033
17211
|
}
|
|
17034
17212
|
};
|
|
17035
17213
|
}
|
|
17036
|
-
async function
|
|
17037
|
-
const { asset, isAutomatic,
|
|
17214
|
+
async function getBridgeChainGasLimit(params) {
|
|
17215
|
+
const { asset, isAutomatic, bridgeChain, source, sourceAddress } = params;
|
|
17038
17216
|
if (!EvmParachain2.isAnyParachain(source)) {
|
|
17039
17217
|
throw new Error("Source chain must be Parachain or EvmParachain");
|
|
17040
17218
|
}
|
|
17219
|
+
if (!EvmParachain2.is(bridgeChain)) {
|
|
17220
|
+
throw new Error("Bridge chain must be an EvmParachain");
|
|
17221
|
+
}
|
|
17041
17222
|
const client = createPublicClient2({
|
|
17042
|
-
chain:
|
|
17223
|
+
chain: bridgeChain.getViemChain(),
|
|
17043
17224
|
transport: http2()
|
|
17044
17225
|
});
|
|
17045
17226
|
const { address20 } = getMultilocationDerivedAddresses2({
|
|
@@ -17048,28 +17229,28 @@ async function getMoonGasLimit(params) {
|
|
|
17048
17229
|
isParents: true
|
|
17049
17230
|
});
|
|
17050
17231
|
if (isAutomatic) {
|
|
17051
|
-
return MOON_CHAIN_AUTOMATIC_GAS_ESTIMATION[
|
|
17232
|
+
return MOON_CHAIN_AUTOMATIC_GAS_ESTIMATION[bridgeChain.key] * 110n / 100n;
|
|
17052
17233
|
}
|
|
17053
17234
|
const contract = MrlBuilder2().wormhole().contract().TokenBridge().transferTokens().build({
|
|
17054
17235
|
...params,
|
|
17055
17236
|
asset: asset.copyWith({ amount: 0n })
|
|
17056
17237
|
});
|
|
17057
|
-
const approveTx =
|
|
17058
|
-
abi:
|
|
17238
|
+
const approveTx = encodeFunctionData2({
|
|
17239
|
+
abi: ERC20_ABI2,
|
|
17059
17240
|
functionName: "approve",
|
|
17060
17241
|
args: [contract.address, 0n]
|
|
17061
17242
|
});
|
|
17062
|
-
const
|
|
17063
|
-
if (!
|
|
17243
|
+
const tokenAddressOnBridgeChain = bridgeChain.getChainAsset(asset).address;
|
|
17244
|
+
if (!tokenAddressOnBridgeChain) {
|
|
17064
17245
|
throw new Error(
|
|
17065
|
-
`Asset ${asset.symbol} does not have a token address on chain ${
|
|
17246
|
+
`Asset ${asset.symbol} does not have a token address on chain ${bridgeChain.name}`
|
|
17066
17247
|
);
|
|
17067
17248
|
}
|
|
17068
|
-
const batchAll =
|
|
17249
|
+
const batchAll = encodeFunctionData2({
|
|
17069
17250
|
abi: BATCH_CONTRACT_ABI,
|
|
17070
17251
|
functionName: "batchAll",
|
|
17071
17252
|
args: [
|
|
17072
|
-
[
|
|
17253
|
+
[tokenAddressOnBridgeChain, contract.address],
|
|
17073
17254
|
[0n, 0n],
|
|
17074
17255
|
// Value to send for each call
|
|
17075
17256
|
[approveTx, contract.encodeFunctionData()],
|
|
@@ -17085,6 +17266,11 @@ async function getMoonGasLimit(params) {
|
|
|
17085
17266
|
});
|
|
17086
17267
|
return gasEstimation * 110n / 100n;
|
|
17087
17268
|
}
|
|
17269
|
+
function getAmountForTransferSimulation(balance, protocolFee) {
|
|
17270
|
+
return balance.copyWith({
|
|
17271
|
+
amount: balance.amount - protocolFee.amount > 0 ? balance.amount - protocolFee.amount : 0n
|
|
17272
|
+
});
|
|
17273
|
+
}
|
|
17088
17274
|
|
|
17089
17275
|
// src/getTransferData/getSourceData.ts
|
|
17090
17276
|
async function getSourceData({
|
|
@@ -17100,6 +17286,7 @@ async function getSourceData({
|
|
|
17100
17286
|
);
|
|
17101
17287
|
}
|
|
17102
17288
|
const source = route.source.chain;
|
|
17289
|
+
const destination = route.destination.chain;
|
|
17103
17290
|
const asset = source.getChainAsset(route.source.asset);
|
|
17104
17291
|
const feeAsset = route.source.fee ? source.getChainAsset(route.source.fee.asset) : asset;
|
|
17105
17292
|
const balance = await getBalance2({
|
|
@@ -17120,7 +17307,7 @@ async function getSourceData({
|
|
|
17120
17307
|
route,
|
|
17121
17308
|
sourceAddress
|
|
17122
17309
|
});
|
|
17123
|
-
const
|
|
17310
|
+
const bridgeChainFeeBalance = await getBridgeChainFeeBalance({
|
|
17124
17311
|
balance,
|
|
17125
17312
|
feeBalance,
|
|
17126
17313
|
route,
|
|
@@ -17132,8 +17319,18 @@ async function getSourceData({
|
|
|
17132
17319
|
builder: route.source.min,
|
|
17133
17320
|
chain: source
|
|
17134
17321
|
});
|
|
17322
|
+
const protocolFee = await getProtocolFee({
|
|
17323
|
+
source,
|
|
17324
|
+
destination,
|
|
17325
|
+
asset,
|
|
17326
|
+
feeAsset,
|
|
17327
|
+
balance,
|
|
17328
|
+
protocolFee: route.source.protocolFee,
|
|
17329
|
+
address: destinationAddress
|
|
17330
|
+
});
|
|
17135
17331
|
const transfer = await buildTransfer({
|
|
17136
|
-
asset: balance,
|
|
17332
|
+
asset: getAmountForTransferSimulation(balance, protocolFee),
|
|
17333
|
+
protocolFee,
|
|
17137
17334
|
destinationAddress,
|
|
17138
17335
|
feeAsset: feeBalance,
|
|
17139
17336
|
isAutomatic,
|
|
@@ -17170,13 +17367,16 @@ async function getSourceData({
|
|
|
17170
17367
|
chain: source,
|
|
17171
17368
|
destinationFee,
|
|
17172
17369
|
destinationFeeBalance,
|
|
17173
|
-
|
|
17370
|
+
bridgeChainFeeBalance,
|
|
17174
17371
|
existentialDeposit,
|
|
17175
17372
|
fee,
|
|
17176
17373
|
feeBalance,
|
|
17177
17374
|
max,
|
|
17178
17375
|
min,
|
|
17179
|
-
|
|
17376
|
+
otherFees: {
|
|
17377
|
+
protocol: protocolFee,
|
|
17378
|
+
relayer: relayerFee?.amount ? relayerFee : void 0
|
|
17379
|
+
}
|
|
17180
17380
|
};
|
|
17181
17381
|
}
|
|
17182
17382
|
async function getFee({
|
|
@@ -17193,16 +17393,33 @@ async function getFee({
|
|
|
17193
17393
|
amount: 0n
|
|
17194
17394
|
});
|
|
17195
17395
|
}
|
|
17196
|
-
if (
|
|
17197
|
-
|
|
17198
|
-
|
|
17199
|
-
|
|
17200
|
-
|
|
17201
|
-
|
|
17202
|
-
|
|
17203
|
-
|
|
17204
|
-
|
|
17205
|
-
|
|
17396
|
+
if (SnowbridgeConfig.is(transfer)) {
|
|
17397
|
+
const snowbridge = SnowbridgeService.create(chain2);
|
|
17398
|
+
try {
|
|
17399
|
+
const feeAmount = await snowbridge.getFee(sourceAddress, transfer);
|
|
17400
|
+
return AssetAmount2.fromChainAsset(chain2.getChainAsset(feeBalance), {
|
|
17401
|
+
amount: feeAmount
|
|
17402
|
+
});
|
|
17403
|
+
} catch (error) {
|
|
17404
|
+
console.error(error);
|
|
17405
|
+
return feeBalance.copyWith({ amount: 0n });
|
|
17406
|
+
}
|
|
17407
|
+
}
|
|
17408
|
+
if (ContractConfig2.is(transfer)) {
|
|
17409
|
+
try {
|
|
17410
|
+
return getContractFee({
|
|
17411
|
+
address: sourceAddress,
|
|
17412
|
+
balance,
|
|
17413
|
+
chain: chain2,
|
|
17414
|
+
contract: transfer,
|
|
17415
|
+
destinationFee,
|
|
17416
|
+
feeBalance,
|
|
17417
|
+
feeConfig
|
|
17418
|
+
});
|
|
17419
|
+
} catch (error) {
|
|
17420
|
+
console.error(error);
|
|
17421
|
+
return feeBalance.copyWith({ amount: 0n });
|
|
17422
|
+
}
|
|
17206
17423
|
}
|
|
17207
17424
|
return getExtrinsicFee({
|
|
17208
17425
|
address: sourceAddress,
|
|
@@ -17223,19 +17440,25 @@ async function getRelayerFee({
|
|
|
17223
17440
|
sourceAddress,
|
|
17224
17441
|
transfer
|
|
17225
17442
|
}) {
|
|
17443
|
+
if (route.mrl.transfer.provider === Provider2.Snowbridge || SnowbridgeConfig.is(transfer)) {
|
|
17444
|
+
return void 0;
|
|
17445
|
+
}
|
|
17226
17446
|
if (WormholeConfig.is(transfer)) {
|
|
17227
17447
|
return getWormholeFee({ asset, chain: chain2, config: transfer });
|
|
17228
17448
|
}
|
|
17229
|
-
|
|
17230
|
-
|
|
17231
|
-
|
|
17232
|
-
|
|
17233
|
-
|
|
17234
|
-
|
|
17235
|
-
|
|
17236
|
-
|
|
17237
|
-
|
|
17238
|
-
|
|
17449
|
+
if (route.mrl.transfer.provider === Provider2.Wormhole) {
|
|
17450
|
+
const builderParams = await getMrlBuilderParams({
|
|
17451
|
+
asset,
|
|
17452
|
+
destinationAddress,
|
|
17453
|
+
feeAsset,
|
|
17454
|
+
isAutomatic,
|
|
17455
|
+
route,
|
|
17456
|
+
sourceAddress
|
|
17457
|
+
});
|
|
17458
|
+
const wormholeConfig = MrlBuilder3().wormhole().wormhole().tokenTransfer().build(builderParams);
|
|
17459
|
+
return getWormholeFee({ asset, chain: chain2, config: wormholeConfig });
|
|
17460
|
+
}
|
|
17461
|
+
return;
|
|
17239
17462
|
}
|
|
17240
17463
|
async function getWormholeFee({
|
|
17241
17464
|
asset,
|
|
@@ -17252,33 +17475,78 @@ async function getWormholeFee({
|
|
|
17252
17475
|
}
|
|
17253
17476
|
return;
|
|
17254
17477
|
}
|
|
17255
|
-
async function
|
|
17478
|
+
async function getBridgeChainFeeBalance({
|
|
17256
17479
|
balance,
|
|
17257
17480
|
feeBalance,
|
|
17258
17481
|
route,
|
|
17259
17482
|
sourceAddress
|
|
17260
17483
|
}) {
|
|
17261
|
-
if (!route.source.
|
|
17484
|
+
if (!route.source.bridgeChainFee) {
|
|
17262
17485
|
return void 0;
|
|
17263
17486
|
}
|
|
17264
|
-
if (route.mrl?.
|
|
17487
|
+
if (route.mrl?.bridgeChain.fee.asset.isEqual(balance)) {
|
|
17265
17488
|
return balance;
|
|
17266
17489
|
}
|
|
17267
|
-
if (route.mrl?.
|
|
17490
|
+
if (route.mrl?.bridgeChain.fee.asset.isEqual(feeBalance)) {
|
|
17268
17491
|
return feeBalance;
|
|
17269
17492
|
}
|
|
17270
|
-
if (!route.source.
|
|
17493
|
+
if (!route.source.bridgeChainFee.balance) {
|
|
17271
17494
|
throw new Error(
|
|
17272
|
-
"BalanceBuilder must be defined for source.
|
|
17495
|
+
"BalanceBuilder must be defined for source.bridgeChainFee.balance for MrlAssetRoute"
|
|
17273
17496
|
);
|
|
17274
17497
|
}
|
|
17275
17498
|
return getBalance2({
|
|
17276
17499
|
address: sourceAddress,
|
|
17277
|
-
asset: route.source.chain.getChainAsset(route.source.
|
|
17278
|
-
builder: route.source.
|
|
17500
|
+
asset: route.source.chain.getChainAsset(route.source.bridgeChainFee.asset),
|
|
17501
|
+
builder: route.source.bridgeChainFee.balance,
|
|
17279
17502
|
chain: route.source.chain
|
|
17280
17503
|
});
|
|
17281
17504
|
}
|
|
17505
|
+
async function getProtocolFee({
|
|
17506
|
+
address,
|
|
17507
|
+
asset,
|
|
17508
|
+
feeAsset,
|
|
17509
|
+
balance,
|
|
17510
|
+
protocolFee,
|
|
17511
|
+
destination,
|
|
17512
|
+
source
|
|
17513
|
+
}) {
|
|
17514
|
+
if (typeof protocolFee === "number") {
|
|
17515
|
+
return AssetAmount2.fromChainAsset(asset, {
|
|
17516
|
+
amount: protocolFee
|
|
17517
|
+
});
|
|
17518
|
+
}
|
|
17519
|
+
const config = protocolFee?.build({
|
|
17520
|
+
address,
|
|
17521
|
+
asset,
|
|
17522
|
+
feeAsset,
|
|
17523
|
+
balance,
|
|
17524
|
+
destination,
|
|
17525
|
+
source
|
|
17526
|
+
});
|
|
17527
|
+
if (ContractConfig2.is(config) && EvmChain2.is(source)) {
|
|
17528
|
+
const evm = EvmService3.create(source);
|
|
17529
|
+
const amount = await evm.read(config);
|
|
17530
|
+
if (typeof amount !== "bigint") {
|
|
17531
|
+
throw new Error(
|
|
17532
|
+
`Error getting bridge fee: expected bigint from contract call, but received ${typeof amount}. `
|
|
17533
|
+
);
|
|
17534
|
+
}
|
|
17535
|
+
return AssetAmount2.fromChainAsset(feeAsset, {
|
|
17536
|
+
amount
|
|
17537
|
+
});
|
|
17538
|
+
}
|
|
17539
|
+
if (SubstrateQueryConfig.is(config) && EvmParachain3.isAnyParachain(source)) {
|
|
17540
|
+
const polkadot = await PolkadotService2.create(source);
|
|
17541
|
+
const amount = await polkadot.query(config);
|
|
17542
|
+
return AssetAmount2.fromChainAsset(feeAsset, {
|
|
17543
|
+
amount
|
|
17544
|
+
});
|
|
17545
|
+
}
|
|
17546
|
+
return AssetAmount2.fromChainAsset(feeAsset, {
|
|
17547
|
+
amount: 0n
|
|
17548
|
+
});
|
|
17549
|
+
}
|
|
17282
17550
|
|
|
17283
17551
|
// src/getTransferData/getTransferData.ts
|
|
17284
17552
|
async function getTransferData({
|
|
@@ -17307,7 +17575,7 @@ async function getTransferData({
|
|
|
17307
17575
|
destinationFee,
|
|
17308
17576
|
sourceAddress
|
|
17309
17577
|
});
|
|
17310
|
-
const
|
|
17578
|
+
const bridgeChainData = await getBridgeChainData({
|
|
17311
17579
|
route,
|
|
17312
17580
|
sourceAddress,
|
|
17313
17581
|
destinationAddress
|
|
@@ -17319,14 +17587,14 @@ async function getTransferData({
|
|
|
17319
17587
|
const bigAmount = Big2(
|
|
17320
17588
|
toBigInt3(amount, sourceData.balance.decimals).toString()
|
|
17321
17589
|
);
|
|
17322
|
-
const fee =
|
|
17590
|
+
const fee = getBridgeChainFeeValueOnSource({
|
|
17323
17591
|
destinationData,
|
|
17324
|
-
|
|
17592
|
+
bridgeChainData,
|
|
17325
17593
|
sourceData
|
|
17326
17594
|
});
|
|
17327
17595
|
const result = bigAmount.minus(
|
|
17328
17596
|
isSameAssetPayingDestinationFee ? destinationFee.toBig() : Big2(0)
|
|
17329
|
-
).minus(fee).minus(sourceData.
|
|
17597
|
+
).minus(fee).minus(sourceData.otherFees?.relayer?.toBig() || Big2(0));
|
|
17330
17598
|
return sourceData.balance.copyWith({
|
|
17331
17599
|
amount: result.lt(0) ? 0n : BigInt(result.toFixed())
|
|
17332
17600
|
});
|
|
@@ -17335,10 +17603,10 @@ async function getTransferData({
|
|
|
17335
17603
|
max: sourceData.max,
|
|
17336
17604
|
min: getMrlMin({
|
|
17337
17605
|
destinationData,
|
|
17338
|
-
|
|
17606
|
+
bridgeChainData,
|
|
17339
17607
|
sourceData
|
|
17340
17608
|
}),
|
|
17341
|
-
|
|
17609
|
+
bridgeChain: bridgeChainData,
|
|
17342
17610
|
source: sourceData,
|
|
17343
17611
|
async transfer({
|
|
17344
17612
|
amount,
|
|
@@ -17361,6 +17629,7 @@ async function getTransferData({
|
|
|
17361
17629
|
);
|
|
17362
17630
|
const transfer = await buildTransfer({
|
|
17363
17631
|
asset,
|
|
17632
|
+
protocolFee: sourceData.otherFees?.protocol,
|
|
17364
17633
|
destinationAddress,
|
|
17365
17634
|
feeAsset,
|
|
17366
17635
|
isAutomatic: isAutomatic2,
|
|
@@ -17368,19 +17637,19 @@ async function getTransferData({
|
|
|
17368
17637
|
sendOnlyRemoteExecution,
|
|
17369
17638
|
sourceAddress
|
|
17370
17639
|
});
|
|
17371
|
-
if (
|
|
17640
|
+
if (ContractConfig3.is(transfer) && (EvmChain3.is(source) || EvmParachain4.is(source))) {
|
|
17372
17641
|
if (!evmSigner) {
|
|
17373
17642
|
throw new Error("EVM Signer must be provided");
|
|
17374
17643
|
}
|
|
17375
|
-
const evm =
|
|
17644
|
+
const evm = EvmService4.create(source);
|
|
17376
17645
|
const hash = await evm.transfer(evmSigner, transfer);
|
|
17377
17646
|
return [hash];
|
|
17378
17647
|
}
|
|
17379
|
-
if (ExtrinsicConfig.is(transfer) &&
|
|
17648
|
+
if (ExtrinsicConfig.is(transfer) && EvmParachain4.isAnyParachain(source)) {
|
|
17380
17649
|
if (!polkadotSigner) {
|
|
17381
17650
|
throw new Error("Polkadot signer must be provided");
|
|
17382
17651
|
}
|
|
17383
|
-
const polkadot = await
|
|
17652
|
+
const polkadot = await PolkadotService3.create(source);
|
|
17384
17653
|
const hash = await polkadot.transfer(
|
|
17385
17654
|
sourceAddress,
|
|
17386
17655
|
transfer,
|
|
@@ -17389,13 +17658,21 @@ async function getTransferData({
|
|
|
17389
17658
|
);
|
|
17390
17659
|
return [hash];
|
|
17391
17660
|
}
|
|
17392
|
-
if (WormholeConfig2.is(transfer) && (
|
|
17661
|
+
if (WormholeConfig2.is(transfer) && (EvmChain3.is(source) || EvmParachain4.is(source))) {
|
|
17393
17662
|
if (!evmSigner) {
|
|
17394
17663
|
throw new Error("EVM Signer must be provided");
|
|
17395
17664
|
}
|
|
17396
17665
|
const wh = WormholeService.create(source);
|
|
17397
17666
|
return wh.transfer(evmSigner, transfer);
|
|
17398
17667
|
}
|
|
17668
|
+
if (SnowbridgeConfig2.is(transfer) && (EvmChain3.is(source) || EvmParachain4.is(source))) {
|
|
17669
|
+
if (!evmSigner) {
|
|
17670
|
+
throw new Error("EVM Signer must be provided");
|
|
17671
|
+
}
|
|
17672
|
+
const snowbridge = SnowbridgeService.create(source);
|
|
17673
|
+
const hash = await snowbridge.transfer(evmSigner, transfer);
|
|
17674
|
+
return [hash];
|
|
17675
|
+
}
|
|
17399
17676
|
throw new Error("Either contract or extrinsic must be provided");
|
|
17400
17677
|
}
|
|
17401
17678
|
};
|