Skip to content
Open
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
21 changes: 8 additions & 13 deletions yarn-project/aztec.js/src/ethereum/portal_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export class L1FeeJuicePortalManager {
constructor(
portalAddress: EthAddress,
tokenAddress: EthAddress,
handlerAddress: EthAddress,
handlerAddress: EthAddress | undefined,
private readonly extendedClient: ExtendedViemWalletClient,
private readonly logger: Logger,
) {
Expand All @@ -157,9 +157,9 @@ export class L1FeeJuicePortalManager {
*/
public async bridgeTokensPublic(to: AztecAddress, amount: bigint | undefined, mint = false): Promise<L2AmountClaim> {
const [claimSecret, claimSecretHash] = await generateClaimSecret();
const mintableAmount = await this.tokenManager.getMintAmount();
const amountToBridge = amount ?? mintableAmount;
const amountToBridge = amount ?? (await this.tokenManager.getMintAmount());
if (mint) {
const mintableAmount = await this.tokenManager.getMintAmount();
if (amountToBridge !== mintableAmount) {
throw new Error(`Minting amount must be ${mintableAmount}`);
}
Expand Down Expand Up @@ -233,17 +233,12 @@ export class L1FeeJuicePortalManager {
if (feeJuiceAddress.isZero() || feeJuicePortalAddress.isZero()) {
throw new Error('Portal or token not deployed on L1');
}
if (!feeAssetHandlerAddress || feeAssetHandlerAddress.isZero()) {
throw new Error('Handler not deployed on L1, or handler address is zero');
}

return new L1FeeJuicePortalManager(
feeJuicePortalAddress,
feeJuiceAddress,
feeAssetHandlerAddress,
extendedClient,
logger,
);
// Handler is optional - it's only needed for minting tokens during testing
const handlerAddress =
feeAssetHandlerAddress && !feeAssetHandlerAddress.isZero() ? feeAssetHandlerAddress : undefined;

return new L1FeeJuicePortalManager(feeJuicePortalAddress, feeJuiceAddress, handlerAddress, extendedClient, logger);
}
}

Expand Down
Loading