Skip to content

Commit

Permalink
fixing build
Browse files Browse the repository at this point in the history
  • Loading branch information
sklppy88 committed Aug 16, 2024
1 parent bfe896e commit 05ec97e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ contract TokenBridge {
// Storage structure, containing all storage, and specifying what slots they use.
#[aztec(storage)]
struct Storage {
token: PublicMutable<AztecAddress>,
token: SharedImmutable<AztecAddress>,
portal_address: SharedImmutable<EthAddress>,
}

// Constructs the contract.
#[aztec(public)]
#[aztec(initializer)]
fn constructor(token: AztecAddress, portal_address: EthAddress) {
storage.token.write(token);
storage.token.initialize(token);
storage.portal_address.initialize(portal_address);
}
// docs:end:token_bridge_storage_and_constructor
Expand Down Expand Up @@ -55,7 +55,7 @@ contract TokenBridge {
);

// Mint tokens
Token::at(storage.token.read()).mint_public(to, amount).call(&mut context);
Token::at(storage.token.read_public()).mint_public(to, amount).call(&mut context);
}
// docs:end:claim_public

Expand All @@ -74,7 +74,7 @@ contract TokenBridge {
context.message_portal(storage.portal_address.read_public(), content);

// Burn tokens
Token::at(storage.token.read()).burn_public(context.msg_sender(), amount, nonce).call(&mut context);
Token::at(storage.token.read_public()).burn_public(context.msg_sender(), amount, nonce).call(&mut context);
}
// docs:end:exit_to_l1_public
// docs:start:claim_private
Expand Down Expand Up @@ -147,7 +147,7 @@ contract TokenBridge {
#[aztec(public)]
#[aztec(view)]
fn get_token() -> AztecAddress {
storage.token.read()
storage.token.read_public()
}
// docs:end:get_token

Expand All @@ -158,15 +158,15 @@ contract TokenBridge {
#[aztec(public)]
#[aztec(internal)]
fn _call_mint_on_token(amount: Field, secret_hash: Field) {
Token::at(storage.token.read()).mint_private(amount, secret_hash).call(&mut context);
Token::at(storage.token.read_public()).mint_private(amount, secret_hash).call(&mut context);
}
// docs:end:call_mint_on_token

// docs:start:assert_token_is_same
#[aztec(public)]
#[aztec(internal)]
fn _assert_token_is_same(token: AztecAddress) {
assert(storage.token.read().eq(token), "Token address is not the same as seen in storage");
assert(storage.token.read_public().eq(token), "Token address is not the same as seen in storage");
}
// docs:end:assert_token_is_same
}
16 changes: 8 additions & 8 deletions yarn-project/cli-wallet/src/cmds/bridge_fee_juice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,23 @@ export async function bridgeL1FeeJuice(
const client = await createCompatibleClient(rpcUrl, debugLogger);

// Setup portal manager
const portal = await FeeJuicePortalManager.create(client, publicClient, walletClient, debugLogger);
const { secret } = await portal.prepareTokensOnL1(amount, amount, recipient, mint);
const portal = await FeeJuicePortalManager.new(client, publicClient, walletClient, debugLogger);
const { claimAmount, claimSecret } = await portal.bridgeTokensPublic(recipient, amount, mint);

if (json) {
const out = {
claimAmount: amount,
claimSecret: secret,
claimAmount,
claimSecret,
};
log(prettyPrintJSON(out));
} else {
if (mint) {
log(`Minted ${amount} fee juice on L1 and pushed to L2 portal`);
log(`Minted ${claimAmount} fee juice on L1 and pushed to L2 portal`);
} else {
log(`Bridged ${amount} fee juice to L2 portal`);
log(`Bridged ${claimAmount} fee juice to L2 portal`);
}
log(`claimAmount=${amount},claimSecret=${secret}\n`);
log(`claimAmount=${claimAmount},claimSecret=${claimSecret}\n`);
log(`Note: You need to wait for two L2 blocks before pulling them from the L2 side`);
}
return secret;
return claimSecret;
}
6 changes: 3 additions & 3 deletions yarn-project/cli/src/cmds/devnet/bootstrap_network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,15 +243,15 @@ async function fundFPC(

const feeJuiceContract = await FeeJuiceContract.at(feeJuice, wallet);

const feeJuicePortal = await FeeJuicePortalManager.create(
const feeJuicePortal = await FeeJuicePortalManager.new(
wallet,
l1Clients.publicClient,
l1Clients.walletClient,
debugLog,
);

const amount = 10n ** 21n;
const { secret } = await feeJuicePortal.prepareTokensOnL1(amount, amount, fpcAddress, true);
const { claimAmount, claimSecret } = await feeJuicePortal.bridgeTokensPublic(fpcAddress, amount, true);

const counter = await CounterContract.at(counterAddress, wallet);

Expand All @@ -260,5 +260,5 @@ async function fundFPC(
await counter.methods.increment(wallet.getAddress(), wallet.getAddress()).send().wait();
await counter.methods.increment(wallet.getAddress(), wallet.getAddress()).send().wait();

await feeJuiceContract.methods.claim(fpcAddress, amount, secret).send().wait();
await feeJuiceContract.methods.claim(fpcAddress, claimAmount, claimSecret).send().wait();
}
2 changes: 2 additions & 0 deletions yarn-project/cli/src/cmds/l1/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export function injectCommands(program: Command, log: LogFn, debugLogger: DebugL
'test test test test test test test test test test test junk',
)
.option('--mint', 'Mint the tokens on L1', false)
.option('--private', 'If the bridge should use the private flow', true)
.addOption(l1ChainIdOption)
.requiredOption('-t, --token <string>', 'The address of the token to bridge', parseEthereumAddress)
.requiredOption('-p, --portal <string>', 'The address of the portal contract', parseEthereumAddress)
Expand All @@ -117,6 +118,7 @@ export function injectCommands(program: Command, log: LogFn, debugLogger: DebugL
options.mnemonic,
options.token,
options.portal,
options.private,
options.mint,
options.json,
log,
Expand Down

0 comments on commit 05ec97e

Please sign in to comment.