Skip to content

Commit

Permalink
potentially fix sandbox timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
rahul-kothari committed Sep 28, 2023
1 parent 8010217 commit 9c96b8c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 48 deletions.
49 changes: 5 additions & 44 deletions yarn-project/aztec.js/src/utils/l1_contracts.ts
Original file line number Diff line number Diff line change
@@ -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<L1ContractAddresses> => {
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
}
Expand All @@ -53,8 +17,5 @@ export const getL1ContractAddresses = async (url: string): Promise<L1ContractAdd
120,
1,
);
const result = Object.fromEntries(
Object.entries(response).map(([key, value]) => [key, EthAddress.fromString(value)]),
);
return result as L1ContractAddresses;
return response;
};
8 changes: 4 additions & 4 deletions yarn-project/canary/src/uniswap_trade_on_l1_from_l2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ async function deployAllContracts(
ownerWallet,
walletClient,
publicClient,
l1ContractsAddresses!.registry,
l1ContractsAddresses!.registryAddress,
ownerAddress,
DAI_ADDRESS,
);
Expand All @@ -85,7 +85,7 @@ async function deployAllContracts(
ownerWallet,
walletClient,
publicClient,
l1ContractsAddresses!.registry,
l1ContractsAddresses!.registryAddress,
ownerAddress,
WETH9_ADDRESS,
);
Expand Down Expand Up @@ -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,
);

Expand Down Expand Up @@ -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}`);
Expand Down

0 comments on commit 9c96b8c

Please sign in to comment.