Skip to content

Commit

Permalink
fix: deployment of token contracts in canary e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
alexghr committed Oct 2, 2023
1 parent 8c53c1a commit fd2f7c0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 21 deletions.
27 changes: 7 additions & 20 deletions yarn-project/canary/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,40 +66,27 @@ export async function deployAndInitializeTokenAndBridgeContracts(
});

// deploy l2 token
const deployTx = TokenContract.deploy(wallet, wallet.getCompleteAddress()).send();

// deploy l2 token bridge and attach to the portal
const bridgeTx = TokenBridgeContract.deploy(wallet, wallet.getCompleteAddress()).send({
portalContract: tokenPortalAddress,
contractAddressSalt: Fr.random(),
});
const deployTx = TokenContract.deploy(wallet, owner).send();

// now wait for the deploy txs to be mined. This way we send all tx in the same rollup.
const deployReceipt = await deployTx.wait();
if (deployReceipt.status !== TxStatus.MINED) throw new Error(`Deploy token tx status is ${deployReceipt.status}`);
const token = await TokenContract.at(deployReceipt.contractAddress!, wallet);

// deploy l2 token bridge and attach to the portal
const bridgeTx = TokenBridgeContract.deploy(wallet, token.address).send({
portalContract: tokenPortalAddress,
contractAddressSalt: Fr.random(),
});

const bridgeReceipt = await bridgeTx.wait();
if (bridgeReceipt.status !== TxStatus.MINED) throw new Error(`Deploy bridge tx status is ${bridgeReceipt.status}`);
const bridge = await TokenBridgeContract.at(bridgeReceipt.contractAddress!, wallet);
await bridge.attach(tokenPortalAddress);
const bridgeAddress = bridge.address.toString() as `0x${string}`;

// initialize l2 token
const initializeTx = token.methods._initialize(owner).send();

// initialize bridge
const initializeBridgeTx = bridge.methods._initialize(token.address).send();

// now we wait for the txs to be mined. This way we send all tx in the same rollup.
const initializeReceipt = await initializeTx.wait();
if (initializeReceipt.status !== TxStatus.MINED)
throw new Error(`Initialize token tx status is ${initializeReceipt.status}`);
if ((await token.methods.admin().view()) !== owner.toBigInt()) throw new Error(`Token admin is not ${owner}`);

const initializeBridgeReceipt = await initializeBridgeTx.wait();
if (initializeBridgeReceipt.status !== TxStatus.MINED)
throw new Error(`Initialize token bridge tx status is ${initializeBridgeReceipt.status}`);
if ((await bridge.methods.token().view()) !== token.address.toBigInt())
throw new Error(`Bridge token is not ${token.address}`);

Expand Down
2 changes: 1 addition & 1 deletion yarn-project/end-to-end/src/fixtures/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ export async function deployAndInitializeTokenAndBridgeContracts(
});

// deploy l2 token
const deployTx = TokenContract.deploy(wallet, wallet.getCompleteAddress()).send();
const deployTx = TokenContract.deploy(wallet, owner).send();

// now wait for the deploy txs to be mined. This way we send all tx in the same rollup.
const deployReceipt = await deployTx.wait();
Expand Down

0 comments on commit fd2f7c0

Please sign in to comment.