Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions docs/examples/ts/example_swap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { SetPublicAuthwitContractInteraction } from "@aztec/aztec.js/authorizati
import { Fr } from "@aztec/aztec.js/fields";
import { createAztecNodeClient, waitForNode } from "@aztec/aztec.js/node";
import { createExtendedL1Client } from "@aztec/ethereum/client";
import { RollupContract } from "@aztec/ethereum/contracts";
import { deployL1Contract } from "@aztec/ethereum/deploy-l1-contract";
import { sha256ToField } from "@aztec/foundation/crypto/sha256";
import { TokenContract } from "@aztec/noir-contracts.js/Token";
Expand Down Expand Up @@ -47,8 +46,6 @@ const nodeInfo = await node.getNodeInfo();
const registryAddress =
nodeInfo.l1ContractAddresses.registryAddress.toString();
const inboxAddress = nodeInfo.l1ContractAddresses.inboxAddress.toString();
const rollupAddress = nodeInfo.l1ContractAddresses.rollupAddress.toString();
const rollup = new RollupContract(l1Client, rollupAddress);
// docs:end:setup

// docs:start:deploy_l1
Expand Down Expand Up @@ -438,10 +435,6 @@ const withdrawContentHash = sha256ToField([
Buffer.from(withdrawContentEncoded.slice(2), "hex"),
]);

// Get epoch for the swap receipt block
const swapBlock = await node.getBlock(swapReceipt.blockNumber!);
const swapEpoch = await rollup.getEpochNumberForCheckpoint(swapBlock!.checkpointNumber);

// Message 1: Token bridge exit message
const exitMsgLeaf = computeL2ToL1MessageHash({
l2Sender: l2WethBridge.address,
Expand All @@ -455,8 +448,8 @@ const exitMsgLeaf = computeL2ToL1MessageHash({
// docs:start:consume_l1_messages_witnesses
const exitWitness = await computeL2ToL1MembershipWitness(
node,
swapEpoch,
exitMsgLeaf,
swapReceipt.txHash,
);
const exitSiblingPath = exitWitness!.siblingPath
.toBufferArray()
Expand Down Expand Up @@ -507,8 +500,8 @@ const swapMsgLeaf = computeL2ToL1MessageHash({

const swapWitness = await computeL2ToL1MembershipWitness(
node,
swapEpoch,
swapMsgLeaf,
swapReceipt.txHash,
);
const swapSiblingPath = swapWitness!.siblingPath
.toBufferArray()
Expand All @@ -533,7 +526,7 @@ const l1SwapHash = await l1Client.writeContract({
dir: "left",
size: 32,
}),
[BigInt(swapEpoch), BigInt(swapEpoch)],
[BigInt(exitWitness!.epochNumber), BigInt(swapWitness!.epochNumber)],
[BigInt(exitWitness!.leafIndex), BigInt(swapWitness!.leafIndex)],
[exitSiblingPath, swapSiblingPath],
],
Expand Down
Loading