diff --git a/yarn-project/aztec.js/src/utils/l1_contracts.ts b/yarn-project/aztec.js/src/utils/l1_contracts.ts index 4ee7ef38739..7275756a579 100644 --- a/yarn-project/aztec.js/src/utils/l1_contracts.ts +++ b/yarn-project/aztec.js/src/utils/l1_contracts.ts @@ -1,50 +1,14 @@ -import { EthAddress } from '@aztec/circuits.js'; +import { L1ContractAddresses } from '@aztec/ethereum'; import { retryUntil } from '@aztec/foundation/retry'; -/** - * A dictionary of the Aztec-deployed L1 contracts. - */ -export type L1ContractAddresses = { - /** - * Address fo the main Aztec rollup contract. - */ - rollup: EthAddress; - /** - * Address of the contract that emits events on public contract deployment. - */ - contractDeploymentEmitter: EthAddress; - /** - * Address of the L1/L2 messaging inbox contract. - */ - inbox: EthAddress; - /** - * Address of the L1/L2 messaging outbox contract. - */ - outbox: EthAddress; - /** - * Address of the decoder helper contract - */ - decoderHelper?: EthAddress; - - /** - * Registry Address. - */ - registry: EthAddress; -}; - -/** - * string dictionary of aztec contract addresses that we receive over http. - */ -type L1ContractAddressesResp = { - [K in keyof L1ContractAddresses]: string; -}; +import { createPXEClient } from '../pxe_client.js'; export const getL1ContractAddresses = async (url: string): Promise => { - const reqUrl = new URL(`${url}/api/l1-contract-addresses`); + const pxeClient = createPXEClient(url); const response = await retryUntil( async () => { try { - return (await (await fetch(reqUrl.toString())).json()) as unknown as L1ContractAddressesResp; + return (await pxeClient.getNodeInfo()).l1ContractAddresses; } catch (err) { // do nothing } @@ -53,8 +17,5 @@ export const getL1ContractAddresses = async (url: string): Promise [key, EthAddress.fromString(value)]), - ); - return result as L1ContractAddresses; + return response; }; diff --git a/yarn-project/canary/src/uniswap_trade_on_l1_from_l2.test.ts b/yarn-project/canary/src/uniswap_trade_on_l1_from_l2.test.ts index 56c30bbf037..97f754f61df 100644 --- a/yarn-project/canary/src/uniswap_trade_on_l1_from_l2.test.ts +++ b/yarn-project/canary/src/uniswap_trade_on_l1_from_l2.test.ts @@ -71,7 +71,7 @@ async function deployAllContracts( ownerWallet, walletClient, publicClient, - l1ContractsAddresses!.registry, + l1ContractsAddresses!.registryAddress, ownerAddress, DAI_ADDRESS, ); @@ -85,7 +85,7 @@ async function deployAllContracts( ownerWallet, walletClient, publicClient, - l1ContractsAddresses!.registry, + l1ContractsAddresses!.registryAddress, ownerAddress, WETH9_ADDRESS, ); @@ -116,7 +116,7 @@ async function deployAllContracts( await uniswapL2Contract.attach(uniswapPortalAddress); await uniswapPortal.write.initialize( - [l1ContractsAddresses!.registry.toString(), uniswapL2Contract.address.toString()], + [l1ContractsAddresses!.registryAddress.toString(), uniswapL2Contract.address.toString()], {} as any, ); @@ -286,7 +286,7 @@ describe('uniswap_trade_on_l1_from_l2', () => { const { result: messageKeyHex } = await wethTokenPortal.simulate.depositToAztecPrivate(args, { account: ownerEthAddress.toString(), } as any); - await wethTokenPortal.write.depositToAztecPublic(args, {} as any); + await wethTokenPortal.write.depositToAztecPrivate(args, {} as any); const currentL1Balance = await wethContract.read.balanceOf([ownerEthAddress.toString()]); logger(`Initial Balance: ${currentL1Balance}. Should be: ${wethL1BeforeBalance - wethAmountToBridge}`);