Skip to content
Merged
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
b93d531
Initial cleanup
PhilWindle Jan 5, 2024
db662e8
Formatting
PhilWindle Jan 5, 2024
7076ee6
Formatting
PhilWindle Jan 5, 2024
3453dce
Cleanup
PhilWindle Jan 5, 2024
a30be6a
Fixes
PhilWindle Jan 5, 2024
28a1ef5
Fixes
PhilWindle Jan 5, 2024
9231590
Extract accounts out of aztecjs into new package and update imports
spalladino Jan 4, 2024
e370f7b
Remove unneeded types in package.common
spalladino Jan 4, 2024
431f72b
Fix sample-dapp tests
spalladino Jan 5, 2024
ef4c2ba
Remove web build from accounts package
spalladino Jan 5, 2024
d8c2892
Build web package specific for e2e tests
spalladino Jan 5, 2024
3378e09
Fix package local json
spalladino Jan 5, 2024
695bccc
Order tsconfig refs
spalladino Jan 5, 2024
1b0a10b
Update readmes
spalladino Jan 5, 2024
b71c0e6
Format
spalladino Jan 5, 2024
88fb559
Fix links in docs
spalladino Jan 5, 2024
2774060
Update docs content
spalladino Jan 5, 2024
4504a69
Fix boxes and format
spalladino Jan 5, 2024
867350a
Remove unused web build entrypoint for account package
spalladino Jan 5, 2024
362f4d8
Add accounts api reference to docsite
spalladino Jan 5, 2024
b9bbe1f
Fixes
PhilWindle Jan 5, 2024
2d942fb
Fixes
PhilWindle Jan 5, 2024
74a2193
Fixes
PhilWindle Jan 5, 2024
6fb4248
Fix
PhilWindle Jan 5, 2024
e8c44ab
Fixes
PhilWindle Jan 5, 2024
74149e2
Fixes
PhilWindle Jan 6, 2024
ea1d635
Formatting
PhilWindle Jan 6, 2024
1896b72
More cleanup
PhilWindle Jan 8, 2024
796a6bd
More cleanup
PhilWindle Jan 8, 2024
940b161
More cleanup
PhilWindle Jan 8, 2024
d96bae8
Merge branch 'palla/accounts-out-of-aztecjs' into pw/cleanup-tests
PhilWindle Jan 8, 2024
c1c5a81
Merge cleanup
PhilWindle Jan 8, 2024
463c858
More cleanup
PhilWindle Jan 8, 2024
a1ac6bc
Merge branch 'master' into pw/cleanup-tests
PhilWindle Jan 8, 2024
8c00e6c
Formatting
PhilWindle Jan 8, 2024
74d179a
Removed debug comment
PhilWindle Jan 8, 2024
4c169f3
Fixes
PhilWindle Jan 8, 2024
2f38742
Merge branch 'master' into pw/cleanup-tests
PhilWindle Jan 8, 2024
848497c
Fixes
PhilWindle Jan 8, 2024
29a2aa7
Merge branch 'pw/cleanup-tests' of github.com:AztecProtocol/aztec-pac…
PhilWindle Jan 8, 2024
9247064
Formatting
PhilWindle Jan 8, 2024
2b01828
Fixes
PhilWindle Jan 8, 2024
53ecc7c
Formatting
PhilWindle Jan 8, 2024
2e7d550
Formatting
PhilWindle Jan 8, 2024
3f68a96
More cleanup
PhilWindle Jan 8, 2024
b5334bd
Fixes
PhilWindle Jan 8, 2024
c237ea1
Another fix
PhilWindle Jan 8, 2024
b54ec49
More cleanup
PhilWindle Jan 8, 2024
1881d06
Cleanup
PhilWindle Jan 8, 2024
0c3355c
Formatting
PhilWindle Jan 8, 2024
0d36628
Cleanup
PhilWindle Jan 8, 2024
b011582
Fixes
PhilWindle Jan 9, 2024
224c50b
More cleanup
PhilWindle Jan 9, 2024
7003e5a
Merge branch 'master' into pw/cleanup-tests
PhilWindle Jan 9, 2024
5a01b07
Formatting
PhilWindle Jan 9, 2024
df057ed
Fix
PhilWindle Jan 9, 2024
2cde2bd
Formatting
PhilWindle Jan 9, 2024
a3b13f1
Fixes
PhilWindle Jan 9, 2024
9a54b82
Formatting
PhilWindle Jan 9, 2024
bdaae06
Merge branch 'master' into pw/cleanup-tests
PhilWindle Jan 9, 2024
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
12 changes: 6 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ jobs:
name: "Test"
command: cond_spot_run_compose end-to-end 4 ./scripts/docker-compose-no-sandbox.yml TEST=e2e_p2p_network.test.ts

e2e-browser-sandbox:
e2e-browser:
docker:
- image: aztecprotocol/alpine-build-image
resource_class: small
Expand All @@ -791,7 +791,7 @@ jobs:
name: "Test"
command: cond_spot_run_compose end-to-end 4 ./scripts/docker-compose.yml TEST=e2e_card_game.test.ts

pxe-sandbox:
pxe:
docker:
- image: aztecprotocol/alpine-build-image
resource_class: small
Expand Down Expand Up @@ -1206,9 +1206,9 @@ workflows:
- integration-l1-publisher: *e2e_test
- integration-archiver-l1-to-l2: *e2e_test
- e2e-p2p: *e2e_test
- e2e-browser-sandbox: *e2e_test
- e2e-browser: *e2e_test
- e2e-card-game: *e2e_test
- pxe-sandbox: *e2e_test
- pxe: *e2e_test
- cli-docs-sandbox: *e2e_test
- guides-writing-an-account-contract: *e2e_test
- guides-dapp-testing: *e2e_test
Expand Down Expand Up @@ -1242,9 +1242,9 @@ workflows:
- integration-l1-publisher
- integration-archiver-l1-to-l2
- e2e-p2p
- e2e-browser-sandbox
- e2e-browser
- e2e-card-game
- pxe-sandbox
- pxe
- cli-docs-sandbox
- guides-writing-an-account-contract
- guides-dapp-testing
Expand Down
11 changes: 11 additions & 0 deletions boxes/blank-react/src/sandbox/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { createPXEClient, waitForPXE } from '@aztec/aztec.js';

const { PXE_URL = 'http://localhost:8080' } = process.env;

// assumes sandbox is running locally, which this script does not trigger
// as well as anvil. anvil can be started with yarn test:integration
export const setupSandbox = async () => {
const pxe = createPXEClient(PXE_URL);
await waitForPXE(pxe);
return pxe;
};
4 changes: 2 additions & 2 deletions boxes/blank-react/src/scripts/util.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AccountWallet, CompleteAddress, Fr, FunctionArtifact, PXE, encodeArguments } from '@aztec/aztec.js';

import { getSandboxAccountsWallets } from '@aztec/accounts/testing';
import { getInitialSandboxAccountsWallets } from '@aztec/accounts/testing';

export function convertArgs(functionAbi: FunctionArtifact, args: any): Fr[] {
const untypedArgs = functionAbi.parameters.map(param => {
Expand All @@ -27,7 +27,7 @@ export function convertArgs(functionAbi: FunctionArtifact, args: any): Fr[] {
* @returns
*/
export async function getWallet(account: CompleteAddress, pxe: PXE): Promise<AccountWallet> {
const accountWallets: AccountWallet[] = await getSandboxAccountsWallets(pxe);
const accountWallets: AccountWallet[] = await getInitialSandboxAccountsWallets(pxe);
const selectedWallet: AccountWallet = accountWallets.find(w => w.getAddress().equals(account.address))!;
if (!selectedWallet) {
throw new Error(`Wallet for account ${account.address.toShortString()} not found in the PXE.`);
Expand Down
12 changes: 1 addition & 11 deletions boxes/blank-react/src/tests/blank.contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,11 @@ import {
TxStatus,
Wallet,
createDebugLogger,
createPXEClient,
waitForSandbox,
} from '@aztec/aztec.js';
import { setupSandbox } from '../sandbox/index.js';

const logger = createDebugLogger('aztec:http-pxe-client');

// assumes sandbox is running locally, which this script does not trigger
// as well as anvil. anvil can be started with yarn test:integration
const setupSandbox = async () => {
const { PXE_URL = 'http://localhost:8080' } = process.env;
const pxe = createPXEClient(PXE_URL);
await waitForSandbox(pxe);

return pxe;
};

async function deployZKContract(owner: CompleteAddress, wallet: Wallet, pxe: PXE) {
logger('Deploying Blank contract...');
Expand Down
8 changes: 4 additions & 4 deletions boxes/blank/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
encodeArguments,
} from '@aztec/aztec.js';

import { getSandboxAccountsWallets } from '@aztec/accounts/testing';
import { getInitialSandboxAccountsWallets } from '@aztec/accounts/testing';

// docs:end:imports

Expand Down Expand Up @@ -45,7 +45,7 @@ if (typeof document !== 'undefined') {
export async function handleDeployClick(): Promise<string> {
// eslint-disable-next-line no-console
console.log('Deploying Contract');
const [wallet, ..._rest] = await getSandboxAccountsWallets(pxe);
const [wallet, ..._rest] = await getInitialSandboxAccountsWallets(pxe);

const contractAztecAddress = await deployContract(
wallet.getCompleteAddress(),
Expand All @@ -60,7 +60,7 @@ export async function handleDeployClick(): Promise<string> {
// docs:end:deploy
// docs:start:interact
export async function handleInteractClick(contractAddress: string) {
const [wallet, ..._rest] = await getSandboxAccountsWallets(pxe);
const [wallet, ..._rest] = await getInitialSandboxAccountsWallets(pxe);
const callArgs = { address: wallet.getCompleteAddress().address };
const getPkAbi = getFunctionAbi(BlankContractArtifact, 'getPublicKey');
const typedArgs = convertArgs(getPkAbi, callArgs);
Expand Down Expand Up @@ -115,7 +115,7 @@ export async function callContractFunction(
* @returns
*/
export async function getWallet(account: CompleteAddress, pxe: PXE): Promise<AccountWallet> {
const accountWallets: AccountWallet[] = await getSandboxAccountsWallets(pxe);
const accountWallets: AccountWallet[] = await getInitialSandboxAccountsWallets(pxe);
const selectedWallet: AccountWallet = accountWallets.find(w => w.getAddress().equals(account.address))!;
if (!selectedWallet) {
throw new Error(`Wallet for account ${account.address.toShortString()} not found in the PXE.`);
Expand Down
11 changes: 11 additions & 0 deletions boxes/blank/src/sandbox/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { createPXEClient, waitForPXE } from '@aztec/aztec.js';

const { PXE_URL = 'http://localhost:8080' } = process.env;

// assumes sandbox is running locally, which this script does not trigger
// as well as anvil. anvil can be started with yarn test:integration
export const setupSandbox = async () => {
const pxe = createPXEClient(PXE_URL);
await waitForPXE(pxe);
return pxe;
};
12 changes: 1 addition & 11 deletions boxes/blank/src/tests/blank.contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,11 @@ import {
TxStatus,
Wallet,
createDebugLogger,
createPXEClient,
waitForSandbox,
} from '@aztec/aztec.js';
import { setupSandbox } from '../sandbox/index.js';

const logger = createDebugLogger('aztec:blank-box-test');

// assumes sandbox is running locally, which this script does not trigger
// as well as anvil. anvil can be started with yarn test:integration
const setupSandbox = async () => {
const { PXE_URL = 'http://localhost:8080' } = process.env;
const pxe = createPXEClient(PXE_URL);
await waitForSandbox(pxe);
return pxe;
};

async function deployZKContract(owner: CompleteAddress, wallet: Wallet, pxe: PXE) {
logger('Deploying Blank contract...');
const contractAddress = await deployContract(owner, BlankContract.artifact, [], Fr.random(), pxe);
Expand Down
11 changes: 11 additions & 0 deletions boxes/token/src/sandbox/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { createPXEClient, waitForPXE } from '@aztec/aztec.js';

const { PXE_URL = 'http://localhost:8080' } = process.env;

// assumes sandbox is running locally, which this script does not trigger
// as well as anvil. anvil can be started with yarn test:integration
export const setupSandbox = async () => {
const pxe = createPXEClient(PXE_URL);
await waitForPXE(pxe);
return pxe;
};
4 changes: 2 additions & 2 deletions boxes/token/src/scripts/util.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AccountWallet, CompleteAddress, Fr, FunctionArtifact, PXE, encodeArguments } from '@aztec/aztec.js';

import { getSandboxAccountsWallets } from '@aztec/accounts/testing';
import { getInitialSandboxAccountsWallets } from '@aztec/accounts/testing';

function convertBasicArg(paramType: string, value: any) {
switch (paramType) {
Expand Down Expand Up @@ -42,7 +42,7 @@ export function convertArgs(functionAbi: FunctionArtifact, args: any): Fr[] {
* @returns
*/
export async function getWallet(account: CompleteAddress, pxe: PXE): Promise<AccountWallet> {
const accountWallets: AccountWallet[] = await getSandboxAccountsWallets(pxe);
const accountWallets: AccountWallet[] = await getInitialSandboxAccountsWallets(pxe);
const selectedWallet: AccountWallet = accountWallets.find(w => w.getAddress().equals(account.address))!;
if (!selectedWallet) {
throw new Error(`Wallet for account ${account.address.toShortString()} not found in the PXE.`);
Expand Down
16 changes: 3 additions & 13 deletions boxes/token/src/tests/token.contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,12 @@ import {
computeAuthWitMessageHash,
computeMessageSecretHash,
createDebugLogger,
createPXEClient,
waitForSandbox,
} from '@aztec/aztec.js';

import { getSandboxAccountsWallets } from '@aztec/accounts/testing';
import { getInitialSandboxAccountsWallets } from '@aztec/accounts/testing';

import { afterEach, beforeAll, expect, jest } from '@jest/globals';

// assumes sandbox is running locally, which this script does not trigger
// as well as anvil. anvil can be started with yarn test:integration
const setupSandbox = async () => {
const { PXE_URL = 'http://localhost:8080' } = process.env;
const pxe = createPXEClient(PXE_URL);
await waitForSandbox(pxe);
return pxe;
};
import { setupSandbox } from '../sandbox/index.js';

const TIMEOUT = 60_000;

Expand Down Expand Up @@ -56,7 +46,7 @@ describe('e2e_token_contract', () => {
pxe = await setupSandbox();
// wallets = await createAccounts(pxe, 3);
accounts = await pxe.getRegisteredAccounts();
wallets = await getSandboxAccountsWallets(pxe);
wallets = await getInitialSandboxAccountsWallets(pxe);

logger(`Accounts: ${accounts.map(a => a.toReadableString())}`);
logger(`Wallets: ${wallets.map(w => w.getAddress().toString())}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Open `cross_chain_messaging.test.ts` and paste the initial description of the te

```typescript
import { expect, jest} from '@jest/globals'
import { AccountWallet, AztecAddress, DebugLogger, EthAddress, Fr, computeAuthWitMessageHash, createDebugLogger, createPXEClient, waitForSandbox } from '@aztec/aztec.js';
import { AccountWallet, AztecAddress, DebugLogger, EthAddress, Fr, computeAuthWitMessageHash, createDebugLogger, createPXEClient, waitForPXE } from '@aztec/aztec.js';
import { getSandboxAccountsWallets } from '@aztec/accounts/testing';
import { TokenContract } from '@aztec/noir-contracts/Token';
import { TokenBridgeContract } from '@aztec/noir-contracts/TokenBridge';
Expand Down Expand Up @@ -120,7 +120,7 @@ describe('e2e_cross_chain_messaging', () => {
beforeEach(async () => {
logger = createDebugLogger('aztec:e2e_uniswap');
const pxe = createPXEClient(PXE_URL);
await waitForSandbox(pxe);
await waitForPXE(pxe);
const wallets = await getSandboxAccountsWallets(pxe);

const walletClient = createWalletClient({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ import {
computeAuthWitMessageHash,
createDebugLogger,
createPXEClient,
waitForSandbox,
waitForPXE,
} from "@aztec/aztec.js";
import { getSandboxAccountsWallets } from '@aztec/accounts/testing';
import {
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/dev_docs/tutorials/writing_dapp/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
computeMessageSecretHash,
createAccount,
createPXEClient,
waitForSandbox,
waitForPXE,
} from "@aztec/aztec.js";
import { TokenContractArtifact } from "@aztec/noir-contracts/Token";

Expand Down
18 changes: 14 additions & 4 deletions yarn-project/accounts/src/testing/sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,22 @@ export const INITIAL_SANDBOX_ENCRYPTION_KEYS = [

export const INITIAL_SANDBOX_SIGNING_KEYS = INITIAL_SANDBOX_ENCRYPTION_KEYS;

export const INITIAL_SANDBOX_SALTS = [Fr.ZERO, Fr.ZERO, Fr.ZERO];
export const INITIAL_SANDBOX_ACCOUNT_SALTS = [Fr.ZERO, Fr.ZERO, Fr.ZERO];

/**
* Gets a collection of wallets for the Aztec accounts that are initially stored in the sandbox.
* @param pxe - PXE instance.
* @returns A set of AccountWallet implementations for each of the initial accounts.
*/
export function getSandboxAccountsWallets(pxe: PXE): Promise<AccountWalletWithPrivateKey[]> {
export function getInitialSandboxAccountsWallets(pxe: PXE): Promise<AccountWalletWithPrivateKey[]> {
return Promise.all(
INITIAL_SANDBOX_ENCRYPTION_KEYS.map((encryptionKey, i) =>
getSchnorrAccount(pxe, encryptionKey!, INITIAL_SANDBOX_SIGNING_KEYS[i]!, INITIAL_SANDBOX_SALTS[i]).getWallet(),
getSchnorrAccount(
pxe,
encryptionKey!,
INITIAL_SANDBOX_SIGNING_KEYS[i]!,
INITIAL_SANDBOX_ACCOUNT_SALTS[i],
).getWallet(),
),
);
}
Expand All @@ -34,7 +39,12 @@ export function getSandboxAccountsWallets(pxe: PXE): Promise<AccountWalletWithPr
*/
export async function deployInitialSandboxAccounts(pxe: PXE) {
const accounts = INITIAL_SANDBOX_ENCRYPTION_KEYS.map((privateKey, i) => {
const account = getSchnorrAccount(pxe, privateKey, INITIAL_SANDBOX_SIGNING_KEYS[i], INITIAL_SANDBOX_SALTS[i]);
const account = getSchnorrAccount(
pxe,
privateKey,
INITIAL_SANDBOX_SIGNING_KEYS[i],
INITIAL_SANDBOX_ACCOUNT_SALTS[i],
);
return {
account,
privateKey,
Expand Down
3 changes: 1 addition & 2 deletions yarn-project/aztec.js/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export {
isContractDeployed,
EthCheatCodes,
computeAuthWitMessageHash,
waitForPXE,
} from './utils/index.js';

export { createPXEClient } from './pxe_client.js';
Expand All @@ -53,8 +54,6 @@ export { AuthWitnessProvider } from './account/index.js';
export { AccountContract } from './account/index.js';
export { AccountManager } from './account_manager/index.js';

export { waitForSandbox } from './sandbox/index.js';

export { AccountWalletWithPrivateKey, AccountWallet, Wallet, SignerlessWallet } from './wallet/index.js';

// // TODO https://github.com/AztecProtocol/aztec-packages/issues/2632 --> FunctionSelector might not need to be exposed
Expand Down
22 changes: 0 additions & 22 deletions yarn-project/aztec.js/src/sandbox/index.ts

This file was deleted.

1 change: 1 addition & 0 deletions yarn-project/aztec.js/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ export * from './l2_contracts.js';
export * from './abi_types.js';
export * from './cheat_codes.js';
export * from './authwit.js';
export * from './pxe.js';
16 changes: 16 additions & 0 deletions yarn-project/aztec.js/src/utils/pxe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { DebugLogger } from '@aztec/foundation/log';
import { retryUntil } from '@aztec/foundation/retry';
import { PXE } from '@aztec/types';

export const waitForPXE = async (pxe: PXE, logger?: DebugLogger) => {
await retryUntil(async () => {
try {
logger?.('Attempting to contact PXE...');
await pxe.getNodeInfo();
return true;
} catch (error) {
logger?.('Failed to contact PXE!');
}
return undefined;
}, 'RPC Get Node Info');
};
2 changes: 1 addition & 1 deletion yarn-project/end-to-end/src/benchmarks/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { join } from 'path';
import { EndToEndContext, setup } from '../fixtures/utils.js';

/**
* Setup for benchmarks. Initializes a sandbox node with a single account and deploys a benchmark contract.
* Setup for benchmarks. Initializes a remote node with a single account and deploys a benchmark contract.
*/
export async function benchmarkSetup(opts: Partial<AztecNodeConfig>) {
const context = await setup(1, { ...opts });
Expand Down
Loading