@moonbeam-network/mrl 3.1.1 → 3.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.mjs +42 -24
- package/build/index.mjs.map +1 -1
- package/package.json +14 -14
package/build/index.mjs
CHANGED
|
@@ -20,19 +20,19 @@ import {
|
|
|
20
20
|
wormholeFactory
|
|
21
21
|
} from "@moonbeam-network/xcm-builder";
|
|
22
22
|
|
|
23
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@1.
|
|
23
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@1.15.0_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-tokenbridge/dist/esm/index.js
|
|
24
24
|
import { registerProtocol as registerProtocol2 } from "@wormhole-foundation/sdk-connect";
|
|
25
25
|
import { _platform as _platform2 } from "@wormhole-foundation/sdk-evm";
|
|
26
26
|
|
|
27
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@1.
|
|
27
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@1.15.0_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-tokenbridge/dist/esm/tokenBridge.js
|
|
28
28
|
import { ErrNotWrapped, UniversalAddress, isNative, keccak256 as keccak2562, nativeChainIds as nativeChainIds2, serialize as serialize2, toChain, toChainId, toNative } from "@wormhole-foundation/sdk-connect";
|
|
29
|
-
import { EvmAddress as EvmAddress2, EvmPlatform as EvmPlatform2, EvmUnsignedTransaction as EvmUnsignedTransaction2, EvmZeroAddress, addChainId as addChainId2, addFrom as addFrom2, unusedArbiterFee, unusedNonce } from "@wormhole-foundation/sdk-evm";
|
|
29
|
+
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";
|
|
30
30
|
|
|
31
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-core@1.
|
|
31
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-core@1.15.0_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-core/dist/esm/index.js
|
|
32
32
|
import { registerProtocol } from "@wormhole-foundation/sdk-connect";
|
|
33
33
|
import { _platform } from "@wormhole-foundation/sdk-evm";
|
|
34
34
|
|
|
35
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-core@1.
|
|
35
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-core@1.15.0_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-core/dist/esm/core.js
|
|
36
36
|
import { nativeChainIds, createVAA, isWormholeMessageId, encoding, serialize } from "@wormhole-foundation/sdk-connect";
|
|
37
37
|
import { EvmAddress, EvmPlatform, EvmUnsignedTransaction, addChainId, addFrom } from "@wormhole-foundation/sdk-evm";
|
|
38
38
|
var EvmWormholeCore = class _EvmWormholeCore {
|
|
@@ -80,7 +80,10 @@ var EvmWormholeCore = class _EvmWormholeCore {
|
|
|
80
80
|
}
|
|
81
81
|
async *publishMessage(sender, message, nonce, consistencyLevel) {
|
|
82
82
|
const senderAddr = new EvmAddress(sender).toString();
|
|
83
|
-
const
|
|
83
|
+
const messageFee = await this.getMessageFee();
|
|
84
|
+
const txReq = await this.core.publishMessage.populateTransaction(nonce, message, consistencyLevel, {
|
|
85
|
+
value: messageFee
|
|
86
|
+
});
|
|
84
87
|
yield this.createUnsignedTx(addFrom(txReq, senderAddr), "WormholeCore.publishMessage");
|
|
85
88
|
}
|
|
86
89
|
async *verifyMessage(sender, vaa) {
|
|
@@ -146,7 +149,7 @@ var EvmWormholeCore = class _EvmWormholeCore {
|
|
|
146
149
|
}
|
|
147
150
|
};
|
|
148
151
|
|
|
149
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-core@1.
|
|
152
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-core@1.15.0_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-core/dist/esm/ethers-contracts/index.js
|
|
150
153
|
var ethers_contracts_exports = {};
|
|
151
154
|
__export(ethers_contracts_exports, {
|
|
152
155
|
Implementation__factory: () => Implementation__factory
|
|
@@ -7293,7 +7296,7 @@ var ContractFactory = class _ContractFactory {
|
|
|
7293
7296
|
}
|
|
7294
7297
|
};
|
|
7295
7298
|
|
|
7296
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-core@1.
|
|
7299
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-core@1.15.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
|
|
7297
7300
|
var _abi = [
|
|
7298
7301
|
{
|
|
7299
7302
|
anonymous: false,
|
|
@@ -8363,16 +8366,17 @@ var Implementation__factory = class extends ContractFactory {
|
|
|
8363
8366
|
}
|
|
8364
8367
|
};
|
|
8365
8368
|
|
|
8366
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-core@1.
|
|
8369
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-core@1.15.0_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-core/dist/esm/index.js
|
|
8367
8370
|
registerProtocol(_platform, "WormholeCore", EvmWormholeCore);
|
|
8368
8371
|
|
|
8369
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@1.
|
|
8372
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@1.15.0_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-tokenbridge/dist/esm/tokenBridge.js
|
|
8370
8373
|
var EvmTokenBridge = class _EvmTokenBridge {
|
|
8371
8374
|
network;
|
|
8372
8375
|
chain;
|
|
8373
8376
|
provider;
|
|
8374
8377
|
contracts;
|
|
8375
8378
|
tokenBridge;
|
|
8379
|
+
core;
|
|
8376
8380
|
tokenBridgeAddress;
|
|
8377
8381
|
chainId;
|
|
8378
8382
|
constructor(network, chain, provider, contracts) {
|
|
@@ -8386,6 +8390,7 @@ var EvmTokenBridge = class _EvmTokenBridge {
|
|
|
8386
8390
|
throw new Error(`Wormhole Token Bridge contract for domain ${chain} not found`);
|
|
8387
8391
|
this.tokenBridgeAddress = tokenBridgeAddress;
|
|
8388
8392
|
this.tokenBridge = ethers_contracts_exports2.Bridge__factory.connect(this.tokenBridgeAddress, provider);
|
|
8393
|
+
this.core = new EvmWormholeCore(network, chain, provider, contracts);
|
|
8389
8394
|
}
|
|
8390
8395
|
static async fromRpc(provider, config) {
|
|
8391
8396
|
const [network, chain] = await EvmPlatform2.chainFromRpc(provider);
|
|
@@ -8433,8 +8438,11 @@ var EvmTokenBridge = class _EvmTokenBridge {
|
|
|
8433
8438
|
return this.tokenBridge.isTransferCompleted(keccak2562(vaa.hash));
|
|
8434
8439
|
}
|
|
8435
8440
|
async *createAttestation(token) {
|
|
8441
|
+
const messageFee = await this.core.getMessageFee();
|
|
8436
8442
|
const ignoredNonce = 0;
|
|
8437
|
-
yield this.createUnsignedTx(await this.tokenBridge.attestToken.populateTransaction(token.toString(), ignoredNonce
|
|
8443
|
+
yield this.createUnsignedTx(await this.tokenBridge.attestToken.populateTransaction(token.toString(), ignoredNonce, {
|
|
8444
|
+
value: messageFee
|
|
8445
|
+
}), "TokenBridge.createAttestation");
|
|
8438
8446
|
}
|
|
8439
8447
|
async *submitAttestation(vaa) {
|
|
8440
8448
|
const func = await this.hasWrappedAsset({
|
|
@@ -8446,8 +8454,9 @@ var EvmTokenBridge = class _EvmTokenBridge {
|
|
|
8446
8454
|
const senderAddr = new EvmAddress2(sender).toString();
|
|
8447
8455
|
const recipientChainId = toChainId(recipient.chain);
|
|
8448
8456
|
const recipientAddress = recipient.address.toUniversalAddress().toUint8Array();
|
|
8457
|
+
const messageFee = await this.core.getMessageFee();
|
|
8449
8458
|
if (isNative(token)) {
|
|
8450
|
-
const txReq = await (payload === void 0 ? this.tokenBridge.wrapAndTransferETH.populateTransaction(recipientChainId, recipientAddress, unusedArbiterFee, unusedNonce, { value: amount }) : this.tokenBridge.wrapAndTransferETHWithPayload.populateTransaction(recipientChainId, recipientAddress, unusedNonce, payload, { value: amount }));
|
|
8459
|
+
const txReq = await (payload === void 0 ? this.tokenBridge.wrapAndTransferETH.populateTransaction(recipientChainId, recipientAddress, unusedArbiterFee, unusedNonce, { value: amount + messageFee }) : this.tokenBridge.wrapAndTransferETHWithPayload.populateTransaction(recipientChainId, recipientAddress, unusedNonce, payload, { value: amount + messageFee }));
|
|
8451
8460
|
yield this.createUnsignedTx(addFrom2(txReq, senderAddr), "TokenBridge.wrapAndTransferETH" + (payload === void 0 ? "" : "WithPayload"));
|
|
8452
8461
|
} else {
|
|
8453
8462
|
const tokenAddr = new EvmAddress2(token).toString();
|
|
@@ -8463,7 +8472,7 @@ var EvmTokenBridge = class _EvmTokenBridge {
|
|
|
8463
8472
|
recipientChainId,
|
|
8464
8473
|
recipientAddress
|
|
8465
8474
|
];
|
|
8466
|
-
const txReq = await (payload === void 0 ? this.tokenBridge.transferTokens.populateTransaction(...sharedParams, unusedArbiterFee, unusedNonce) : this.tokenBridge.transferTokensWithPayload.populateTransaction(...sharedParams, unusedNonce, payload));
|
|
8475
|
+
const txReq = await (payload === void 0 ? this.tokenBridge.transferTokens.populateTransaction(...sharedParams, unusedArbiterFee, unusedNonce, { value: messageFee }) : this.tokenBridge.transferTokensWithPayload.populateTransaction(...sharedParams, unusedNonce, payload, { value: messageFee }));
|
|
8467
8476
|
yield this.createUnsignedTx(addFrom2(txReq, senderAddr), "TokenBridge.transferTokens" + (payload === void 0 ? "" : "WithPayload"));
|
|
8468
8477
|
}
|
|
8469
8478
|
}
|
|
@@ -8475,7 +8484,7 @@ var EvmTokenBridge = class _EvmTokenBridge {
|
|
|
8475
8484
|
throw new Error(`VAA.from (${fromAddr}) does not match sender (${senderAddr})`);
|
|
8476
8485
|
}
|
|
8477
8486
|
if (vaa.payload.token.chain === this.chain) {
|
|
8478
|
-
const wrappedNativeAddr = await this.
|
|
8487
|
+
const wrappedNativeAddr = await this.getWeth();
|
|
8479
8488
|
const tokenAddr = new EvmAddress2(vaa.payload.token.address).unwrap();
|
|
8480
8489
|
if (tokenAddr === wrappedNativeAddr && unwrapNative) {
|
|
8481
8490
|
const txReq2 = await this.tokenBridge.completeTransferAndUnwrapETH.populateTransaction(serialize2(vaa));
|
|
@@ -8487,17 +8496,20 @@ var EvmTokenBridge = class _EvmTokenBridge {
|
|
|
8487
8496
|
yield this.createUnsignedTx(addFrom2(txReq, senderAddr), "TokenBridge.completeTransfer");
|
|
8488
8497
|
}
|
|
8489
8498
|
async getWrappedNative() {
|
|
8490
|
-
const address = await this.
|
|
8499
|
+
const address = await this.getWeth();
|
|
8491
8500
|
return toNative(this.chain, address);
|
|
8492
8501
|
}
|
|
8502
|
+
async getWeth() {
|
|
8503
|
+
return WETH_CONTRACTS[this.network]?.[this.chain] ?? this.tokenBridge.WETH();
|
|
8504
|
+
}
|
|
8493
8505
|
createUnsignedTx(txReq, description, parallelizable = false) {
|
|
8494
8506
|
return new EvmUnsignedTransaction2(addChainId2(txReq, this.chainId), this.network, this.chain, description, parallelizable);
|
|
8495
8507
|
}
|
|
8496
8508
|
};
|
|
8497
8509
|
|
|
8498
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@1.
|
|
8510
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@1.15.0_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-tokenbridge/dist/esm/automaticTokenBridge.js
|
|
8499
8511
|
import { isNative as isNative2, serialize as serialize3, toNative as toNative2, nativeChainIds as nativeChainIds3, toChainId as toChainId2 } from "@wormhole-foundation/sdk-connect";
|
|
8500
|
-
import { EvmAddress as EvmAddress3, EvmPlatform as EvmPlatform3, EvmUnsignedTransaction as EvmUnsignedTransaction3, addChainId as addChainId3, addFrom as addFrom3 } from "@wormhole-foundation/sdk-evm";
|
|
8512
|
+
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";
|
|
8501
8513
|
var EvmAutomaticTokenBridge = class _EvmAutomaticTokenBridge {
|
|
8502
8514
|
network;
|
|
8503
8515
|
chain;
|
|
@@ -8505,6 +8517,7 @@ var EvmAutomaticTokenBridge = class _EvmAutomaticTokenBridge {
|
|
|
8505
8517
|
contracts;
|
|
8506
8518
|
tokenBridgeRelayer;
|
|
8507
8519
|
tokenBridge;
|
|
8520
|
+
core;
|
|
8508
8521
|
chainId;
|
|
8509
8522
|
constructor(network, chain, provider, contracts) {
|
|
8510
8523
|
this.network = network;
|
|
@@ -8522,6 +8535,7 @@ var EvmAutomaticTokenBridge = class _EvmAutomaticTokenBridge {
|
|
|
8522
8535
|
if (!relayerAddress)
|
|
8523
8536
|
throw new Error(`Wormhole Token Bridge Relayer contract for domain ${chain} not found`);
|
|
8524
8537
|
this.tokenBridgeRelayer = ethers_contracts_exports2.TokenBridgeRelayer__factory.connect(relayerAddress, provider);
|
|
8538
|
+
this.core = new EvmWormholeCore(network, chain, provider, contracts);
|
|
8525
8539
|
}
|
|
8526
8540
|
async *redeem(sender, vaa) {
|
|
8527
8541
|
const senderAddr = new EvmAddress3(sender).toString();
|
|
@@ -8539,6 +8553,7 @@ var EvmAutomaticTokenBridge = class _EvmAutomaticTokenBridge {
|
|
|
8539
8553
|
async *transfer(sender, recipient, token, amount, nativeGas) {
|
|
8540
8554
|
const senderAddr = new EvmAddress3(sender).toString();
|
|
8541
8555
|
const recipientChainId = toChainId2(recipient.chain);
|
|
8556
|
+
const messageFee = await this.core.getMessageFee();
|
|
8542
8557
|
const recipientAddress = recipient.address.toUniversalAddress().toUint8Array();
|
|
8543
8558
|
const nativeTokenGas = nativeGas ? nativeGas : 0n;
|
|
8544
8559
|
if (isNative2(token)) {
|
|
@@ -8548,7 +8563,7 @@ var EvmAutomaticTokenBridge = class _EvmAutomaticTokenBridge {
|
|
|
8548
8563
|
recipientAddress,
|
|
8549
8564
|
0,
|
|
8550
8565
|
// skip batching
|
|
8551
|
-
{ value: amount }
|
|
8566
|
+
{ value: amount + messageFee }
|
|
8552
8567
|
);
|
|
8553
8568
|
yield this.createUnsignedTx(addFrom3(txReq, senderAddr), "TokenBridgeRelayer.wrapAndTransferETHWithRelay");
|
|
8554
8569
|
} else {
|
|
@@ -8559,7 +8574,7 @@ var EvmAutomaticTokenBridge = class _EvmAutomaticTokenBridge {
|
|
|
8559
8574
|
const txReq2 = await tokenContract.approve.populateTransaction(this.tokenBridgeRelayer.target, amount);
|
|
8560
8575
|
yield this.createUnsignedTx(addFrom3(txReq2, senderAddr), "AutomaticTokenBridge.Approve");
|
|
8561
8576
|
}
|
|
8562
|
-
const txReq = await this.tokenBridgeRelayer.transferTokensWithRelay.populateTransaction(tokenAddr, amount, nativeTokenGas, recipientChainId, recipientAddress, 0);
|
|
8577
|
+
const txReq = await this.tokenBridgeRelayer.transferTokensWithRelay.populateTransaction(tokenAddr, amount, nativeTokenGas, recipientChainId, recipientAddress, 0, { value: messageFee });
|
|
8563
8578
|
yield this.createUnsignedTx(addFrom3(txReq, senderAddr), "TokenBridgeRelayer.TransferTokensWithRelay");
|
|
8564
8579
|
}
|
|
8565
8580
|
}
|
|
@@ -8590,21 +8605,24 @@ var EvmAutomaticTokenBridge = class _EvmAutomaticTokenBridge {
|
|
|
8590
8605
|
return await this.tokenBridgeRelayer.isAcceptedToken(address);
|
|
8591
8606
|
}
|
|
8592
8607
|
async tokenAddress(token) {
|
|
8593
|
-
return isNative2(token) ? await this.
|
|
8608
|
+
return isNative2(token) ? await this.getWeth() : new EvmAddress3(token).toString();
|
|
8609
|
+
}
|
|
8610
|
+
async getWeth() {
|
|
8611
|
+
return WETH_CONTRACTS2[this.network]?.[this.chain] ?? this.tokenBridge.WETH();
|
|
8594
8612
|
}
|
|
8595
8613
|
createUnsignedTx(txReq, description, parallelizable = false) {
|
|
8596
8614
|
return new EvmUnsignedTransaction3(addChainId3(txReq, this.chainId), this.network, this.chain, description, parallelizable);
|
|
8597
8615
|
}
|
|
8598
8616
|
};
|
|
8599
8617
|
|
|
8600
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@1.
|
|
8618
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@1.15.0_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-tokenbridge/dist/esm/ethers-contracts/index.js
|
|
8601
8619
|
var ethers_contracts_exports2 = {};
|
|
8602
8620
|
__export(ethers_contracts_exports2, {
|
|
8603
8621
|
Bridge__factory: () => Bridge__factory,
|
|
8604
8622
|
TokenBridgeRelayer__factory: () => TokenBridgeRelayer__factory
|
|
8605
8623
|
});
|
|
8606
8624
|
|
|
8607
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@1.
|
|
8625
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@1.15.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
|
|
8608
8626
|
var _abi2 = [
|
|
8609
8627
|
{
|
|
8610
8628
|
anonymous: false,
|
|
@@ -9844,7 +9862,7 @@ var Bridge__factory = class extends ContractFactory {
|
|
|
9844
9862
|
}
|
|
9845
9863
|
};
|
|
9846
9864
|
|
|
9847
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@1.
|
|
9865
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@1.15.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
|
|
9848
9866
|
var _abi3 = [
|
|
9849
9867
|
{
|
|
9850
9868
|
inputs: [
|
|
@@ -10915,7 +10933,7 @@ var TokenBridgeRelayer__factory = class extends ContractFactory {
|
|
|
10915
10933
|
}
|
|
10916
10934
|
};
|
|
10917
10935
|
|
|
10918
|
-
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@1.
|
|
10936
|
+
// ../../node_modules/.pnpm/@wormhole-foundation+sdk-evm-tokenbridge@1.15.0_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/@wormhole-foundation/sdk-evm-tokenbridge/dist/esm/index.js
|
|
10919
10937
|
registerProtocol2(_platform2, "TokenBridge", EvmTokenBridge);
|
|
10920
10938
|
registerProtocol2(_platform2, "AutomaticTokenBridge", EvmAutomaticTokenBridge);
|
|
10921
10939
|
|