Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
c2ef10c
remove unnecessary code from aztec.js
Thunkar Mar 7, 2025
e160172
more refactoring
Thunkar Mar 7, 2025
36c3d2e
reorg aztec.js
Thunkar Mar 7, 2025
53912cb
more cleanup
Thunkar Mar 7, 2025
5ed100d
fixed docs, renaming
Thunkar Mar 7, 2025
b11999f
updated CODEOWNERS
Thunkar Mar 7, 2025
a2b69dd
cleaner
Thunkar Mar 7, 2025
189439a
save file
Thunkar Mar 7, 2025
751a95b
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Mar 10, 2025
2d5bcf8
cleaner interfaces
Thunkar Mar 10, 2025
df29417
entrypoint cleanup
Thunkar Mar 11, 2025
0cc942d
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Mar 11, 2025
f816487
wip
Thunkar Mar 11, 2025
2412330
added deps
Thunkar Mar 11, 2025
9ce94e4
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Mar 12, 2025
44218ac
kill permanent authwits
Thunkar Mar 12, 2025
b315b54
wip
Thunkar Mar 12, 2025
16f6439
wip
Thunkar Mar 12, 2025
e4741bc
wip
Thunkar Mar 12, 2025
602329c
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Mar 13, 2025
065fb76
wip
Thunkar Mar 13, 2025
226a30c
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Mar 13, 2025
e0b7c4f
fixes
Thunkar Mar 13, 2025
8e850b9
wip
Thunkar Mar 14, 2025
4bce308
wip
Thunkar Mar 17, 2025
a7301f7
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Mar 17, 2025
7e22efa
fixes
Thunkar Mar 17, 2025
dff12eb
saner entrypoint payload building
Thunkar Mar 17, 2025
b43c1d4
yay progress
Thunkar Mar 17, 2025
7c70082
fixes
Thunkar Mar 17, 2025
5b9ad81
fmt
Thunkar Mar 17, 2025
1faeba9
fmt
Thunkar Mar 17, 2025
ce6e3b9
fmt
Thunkar Mar 17, 2025
f4113de
fix
Thunkar Mar 17, 2025
625c2dc
Merge branch 'master' into gj/slim_wallet
Thunkar Mar 17, 2025
517343a
fmt
Thunkar Mar 17, 2025
cd12f83
fix boxes
Thunkar Mar 17, 2025
b5c00b2
make playground not blow up
Thunkar Mar 17, 2025
c570b57
docs
Thunkar Mar 17, 2025
f024ef8
Merge branch 'master' into gj/slim_wallet
Thunkar Mar 17, 2025
d99dabc
test pass
Thunkar Mar 17, 2025
7f5aa72
more e2e
Thunkar Mar 17, 2025
7dcc932
surrender
Thunkar Mar 17, 2025
c731903
fix
Thunkar Mar 17, 2025
b81bcbf
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Mar 18, 2025
d59097b
more fixes
Thunkar Mar 18, 2025
53e3647
fmt
Thunkar Mar 18, 2025
a6151d3
fmt
Thunkar Mar 18, 2025
741d3bf
fixes
Thunkar Mar 18, 2025
d9526d2
fmt
Thunkar Mar 18, 2025
5d82c74
more test fixing
Thunkar Mar 18, 2025
dfe95ca
migration notes
Thunkar Mar 18, 2025
2656753
Merge branch 'master' into gj/slim_wallet
Thunkar Mar 18, 2025
833bad9
Merge branch 'master' into gj/slim_wallet
Thunkar Mar 18, 2025
a37cf66
Apply suggestions from code review
Thunkar Mar 18, 2025
a5c6200
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Mar 18, 2025
8cf030a
bunch of comments
Thunkar Mar 18, 2025
ed7dd5f
more comments
Thunkar Mar 18, 2025
4912ef3
more comments
Thunkar Mar 18, 2025
767fe1f
fix
Thunkar Mar 18, 2025
ea47021
fixed jsdoc
Thunkar Mar 18, 2025
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
16 changes: 2 additions & 14 deletions boxes/boxes/react/tests/node.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,15 @@ describe('BoxReact Contract Tests', () => {
accountCompleteAddress = wallet.getCompleteAddress();
const salt = Fr.random();

contract = await BoxReactContract.deploy(
wallet,
Fr.random(),
accountCompleteAddress.address
)
contract = await BoxReactContract.deploy(wallet, Fr.random(), accountCompleteAddress.address)
.send({ contractAddressSalt: salt })
.deployed();

logger.info(`L2 contract deployed at ${contract.address}`);
}, 60000);

test('Can set a number', async () => {
logger.info(`${await wallet.getRegisteredAccounts()}`);

await contract.methods
.setNumber(
numberToSet,
accountCompleteAddress.address
)
.send()
.wait();
await contract.methods.setNumber(numberToSet, accountCompleteAddress.address).send().wait();
}, 40000);

test('Can read a number', async () => {
Expand Down
37 changes: 20 additions & 17 deletions boxes/boxes/vite/tests/node.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import { AccountWallet, CompleteAddress, Contract, Fr, createLogger } from '@aztec/aztec.js';
import { BoxReactContract } from '../artifacts/BoxReact.js';
import { deployerEnv } from '../src/config.js';

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

describe('BoxReact Contract Tests', () => {
import {
AccountWallet,
CompleteAddress,
Contract,
Fr,
createLogger,
} from "@aztec/aztec.js";
import { BoxReactContract } from "../artifacts/BoxReact.js";
import { deployerEnv } from "../src/config.js";

const logger = createLogger("aztec:http-pxe-client");

describe("BoxReact Contract Tests", () => {
let wallet: AccountWallet;
let contract: Contract;
const numberToSet = Fr.random();
Expand All @@ -18,28 +24,25 @@ describe('BoxReact Contract Tests', () => {
contract = await BoxReactContract.deploy(
wallet,
Fr.random(),
accountCompleteAddress.address
accountCompleteAddress.address,
)
.send({ contractAddressSalt: salt })
.deployed();

logger.info(`L2 contract deployed at ${contract.address}`);
}, 60000);

test('Can set a number', async () => {
logger.info(`${await wallet.getRegisteredAccounts()}`);

test("Can set a number", async () => {
await contract.methods
.setNumber(
numberToSet,
accountCompleteAddress.address
)
.setNumber(numberToSet, accountCompleteAddress.address)
.send()
.wait();
}, 40000);

test('Can read a number', async () => {
const viewTxReceipt = await contract.methods.getNumber(accountCompleteAddress.address).simulate();
test("Can read a number", async () => {
const viewTxReceipt = await contract.methods
.getNumber(accountCompleteAddress.address)
.simulate();
expect(numberToSet.toBigInt()).toEqual(viewTxReceipt.value);
}, 40000);
});
2 changes: 1 addition & 1 deletion docs/docs/developers/guides/js_apps/pay_fees.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ A fee paying contract (FPC) is created and nominates a token that it accepts to

Functions pertaining to sending a transaction, such as `deploy` and `send`, each include a `fee` variable defined with the following (optional) parameters:

#include_code user_fee_options yarn-project/aztec.js/src/entrypoint/payload.ts javascript
#include_code user_fee_options yarn-project/entrypoints/src/interfaces.ts javascript


### Fee Payment Method
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ A side-effect of not having nonces at the protocol level is that it is not possi

Now that we have a valid account contract, we need to write the typescript glue code that will take care of formatting and authenticating transactions so they can be processed by our contract, as well as deploying the contract during account setup. This takes the form of implementing the `AccountContract` interface from `@aztec/aztec.js`:

#include_code account-contract-interface yarn-project/aztec.js/src/account/contract.ts typescript
#include_code account-contract-interface yarn-project/aztec.js/src/account/account_contract.ts typescript

However, if you are using the default `AccountActions` module, then you can leverage the `DefaultAccountContract` class from `@aztec/accounts` and just implement the logic for generating an auth witness that matches the one you wrote in Noir:

Expand Down
89 changes: 88 additions & 1 deletion docs/docs/migration_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,93 @@ Aztec is in full-speed development. Literally every version breaks compatibility

## TBD

## [aztec.js] Wallet interface and Authwit management

The `Wallet` interface in `aztec.js` is undergoing transformations, trying to be friendlier to wallet builders and reducing the surface of its API. This means `Wallet` no longer extends `PXE`, and instead just implements a subset of the methods of the former. This is NOT going to be its final form, but paves the way towards better interfaces and starts to clarify what the responsibilities of the wallet are:

``` typescript
/**
* The wallet interface.
*/
export type Wallet = AccountInterface &
Pick<
PXE,
// Simulation
| 'simulateTx'
| 'simulateUnconstrained'
| 'profileTx'
// Sending
| 'sendTx'
// Contract management (will probably be collapsed in the future to avoid instance and class versions)
| 'getContractClassMetadata'
| 'getContractMetadata'
| 'registerContract'
| 'registerContractClass'
// Likely to be removed
| 'proveTx'
// Will probably be collapsed
| 'getNodeInfo'
| 'getPXEInfo'
// Fee info
| 'getCurrentBaseFees'
// Still undecided, kept for the time being
| 'updateContract'
// Sender management
| 'registerSender'
| 'getSenders'
| 'removeSender'
// Tx status
| 'getTxReceipt'
// Events. Kept since events are going to be reworked and changes will come when that's done
| 'getPrivateEvents'
| 'getPublicEvents'
> & {
createAuthWit(intent: IntentInnerHash | IntentAction): Promise<AuthWitness>;
};
```

As a side effect, a few debug only features have been removed

```diff
// Obtain tx effects
const { txHash, debugInfo } = await contract.methods
.set_constant(value)
.send()
-- .wait({ interval: 0.1, debug: true });
++ .wait({ interval: 0.1 })

-- // check that 1 note hash was created
-- expect(debugInfo!.noteHashes.length).toBe(1);
++ const txEffect = await aztecNode.getTxEffect(txHash);
++ const noteHashes = txEffect?.data.noteHashes;
++ // check that 1 note hash was created
++ expect(noteHashes?.length).toBe(1);

// Wait for a tx to be proven
-- tx.wait({ timeout: 300, interval: 10, proven: true, provenTimeout: 3000 })));
++ const receipt = await tx.wait({ timeout: 300, interval: 10 });
++ await waitForProven(aztecNode, receipt, { provenTimeout: 3000 });
```

Authwit management has changed, and PXE no longer stores them. This is unnecessary because now they can be externally provided to simulations and transactions, making sure no stale authorizations are kept inside PXE's db.

```diff
const witness = await wallet.createAuthWit({ caller, action });
--await callerWallet.addAuthWitness(witness);
--await action.send().wait();
++await action.send({ authWitnesses: [witness] }).wait();
```

Another side effect of this is that the interface of the `lookupValidity` method has changed, and now the authwitness has to be provided:

```diff
const witness = await wallet.createAuthWit({ caller, action });
--await callerWallet.addAuthWitness(witness);
--await wallet.lookupValidity(wallet.getAddress(), { caller, action });
++await wallet.lookupValidity(wallet.getAddress(), { caller, action }, witness);
```


### [PXE] Concurrent contract function simulation disabled

PXE is no longer be able to execute contract functions concurrently (e.g. by collecting calls to `simulateTx` and then using `await Promise.all`). They will instead be put in a job queue and executed sequentially in order of arrival.
Expand All @@ -24,7 +111,7 @@ class BatchCall extends BaseContractInteraction {
}
```

The `request` method of `BaseContractInteraction` now returns `ExecutionRequestInit` without the fee (`Omit<ExecutionRequestInit, 'fee'>`). This object includes all the necessary data to execute one or more functions. `BatchCall` invokes this method on all interactions to aggregate the required information. It is also used internally in simulations for fee estimation.
The `request` method of `BaseContractInteraction` now returns `ExecutionPayload`. This object includes all the necessary data to execute one or more functions. `BatchCall` invokes this method on all interactions to aggregate the required information. It is also used internally in simulations for fee estimation.

Declaring a `BatchCall`:

Expand Down
1 change: 0 additions & 1 deletion playground/src/components/contract/contract.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ export function ContractComponent() {

const handleAuthwitCreation = async (witness?: AuthWitness, alias?: string) => {
if (witness && alias) {
await wallet.addAuthWitness(witness);
await walletDB.storeAuthwitness(witness, undefined, alias);
}
setAuthwitFnData({ name: '', parameters: [], isPrivate: false });
Expand Down
11 changes: 8 additions & 3 deletions yarn-project/accounts/src/defaults/account_interface.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { AccountInterface, AuthWitnessProvider } from '@aztec/aztec.js/account';
import type { EntrypointInterface, ExecutionRequestInit } from '@aztec/aztec.js/entrypoint';
import { DefaultAccountEntrypoint } from '@aztec/entrypoints/account';
import type { EntrypointInterface, FeeOptions, TxExecutionOptions } from '@aztec/entrypoints/interfaces';
import type { ExecutionPayload } from '@aztec/entrypoints/payload';
import { Fr } from '@aztec/foundation/fields';
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
Expand Down Expand Up @@ -33,8 +34,12 @@ export class DefaultAccountInterface implements AccountInterface {
this.version = new Fr(nodeInfo.protocolVersion);
}

createTxExecutionRequest(execution: ExecutionRequestInit): Promise<TxExecutionRequest> {
return this.entrypoint.createTxExecutionRequest(execution);
createTxExecutionRequest(
exec: ExecutionPayload,
fee: FeeOptions,
options: TxExecutionOptions,
): Promise<TxExecutionRequest> {
return this.entrypoint.createTxExecutionRequest(exec, fee, options);
}

createAuthWit(messageHash: Fr): Promise<AuthWitness> {
Expand Down
30 changes: 24 additions & 6 deletions yarn-project/accounts/src/testing/create_account.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { type AccountManager, FeeJuicePaymentMethod, type PXE, type WaitOpts } from '@aztec/aztec.js';
import {
type AccountManager,
FeeJuicePaymentMethod,
type PXE,
type WaitForProvenOpts,
type WaitOpts,
waitForProven,
} from '@aztec/aztec.js';
import { Fr } from '@aztec/foundation/fields';
import { deriveSigningKey } from '@aztec/stdlib/keys';

Expand Down Expand Up @@ -46,6 +53,7 @@ export async function deployFundedSchnorrAccount(
*/
skipClassRegistration?: boolean;
} = { interval: 0.1, skipClassRegistration: false },
waitForProvenOptions?: WaitForProvenOpts,
): Promise<AccountManager> {
const signingKey = account.signingKey ?? deriveSigningKey(account.secret);
const accountManager = await getSchnorrAccount(pxe, account.secret, signingKey, account.salt);
Expand All @@ -54,14 +62,18 @@ export async function deployFundedSchnorrAccount(
// This only works when the world state is prefilled with the balance for the account in test environment.
const paymentMethod = new FeeJuicePaymentMethod(accountManager.getAddress());

await accountManager
const receipt = await accountManager
.deploy({
skipClassRegistration: opts.skipClassRegistration,
skipPublicDeployment: true,
fee: { paymentMethod },
})
.wait(opts);

if (waitForProvenOptions !== undefined) {
await waitForProven(pxe, receipt, waitForProvenOptions);
}

return accountManager;
}

Expand All @@ -78,15 +90,21 @@ export async function deployFundedSchnorrAccounts(
*/
skipClassRegistration?: boolean;
} = { interval: 0.1, skipClassRegistration: false },
waitForProvenOptions?: WaitForProvenOpts,
): Promise<AccountManager[]> {
const accountManagers: AccountManager[] = [];
// Serial due to https://github.com/AztecProtocol/aztec-packages/issues/12045
for (let i = 0; i < accounts.length; i++) {
accountManagers.push(
await deployFundedSchnorrAccount(pxe, accounts[i], {
...opts,
skipClassRegistration: i !== 0 || opts.skipClassRegistration, // Register the contract class at most once.
}),
await deployFundedSchnorrAccount(
pxe,
accounts[i],
{
...opts,
skipClassRegistration: i !== 0 || opts.skipClassRegistration, // Register the contract class at most once.
},
waitForProvenOptions,
),
);
}
return accountManagers;
Expand Down
1 change: 1 addition & 0 deletions yarn-project/aztec.js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
},
"dependencies": {
"@aztec/constants": "workspace:^",
"@aztec/entrypoints": "workspace:^",
"@aztec/ethereum": "workspace:^",
"@aztec/foundation": "workspace:^",
"@aztec/l1-artifacts": "workspace:^",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import type { AuthWitnessProvider } from '@aztec/entrypoints/interfaces';
import { Fr } from '@aztec/foundation/fields';
import type { ContractArtifact } from '@aztec/stdlib/abi';
import type { CompleteAddress, NodeInfo } from '@aztec/stdlib/contract';
import { getContractInstanceFromDeployParams } from '@aztec/stdlib/contract';
import { deriveKeys } from '@aztec/stdlib/keys';

import type { AccountInterface, AuthWitnessProvider } from './interface.js';
import type { AccountInterface } from './interface.js';

// docs:start:account-contract-interface
/**
Expand Down
5 changes: 2 additions & 3 deletions yarn-project/aztec.js/src/account/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
*/
import type { Fr } from '@aztec/foundation/fields';

export { type AccountContract, getAccountContractAddress } from './contract.js';
export { type AccountInterface, type AuthWitnessProvider } from './interface.js';
export * from './wallet.js';
export { type AccountContract, getAccountContractAddress } from './account_contract.js';
export { type AccountInterface } from './interface.js';

/** A contract deployment salt. */
export type Salt = Fr | number | bigint;
13 changes: 1 addition & 12 deletions yarn-project/aztec.js/src/account/interface.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,9 @@
import type { AuthWitnessProvider, EntrypointInterface } from '@aztec/entrypoints/interfaces';
import type { Fr } from '@aztec/foundation/fields';
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
import type { CompleteAddress } from '@aztec/stdlib/contract';

import type { EntrypointInterface } from '../entrypoint/entrypoint.js';

// docs:start:account-interface
/** Creates authorization witnesses. */
export interface AuthWitnessProvider {
/**
* Computes an authentication witness from either a message hash
* @param messageHash - The message hash to approve
* @returns The authentication witness
*/
createAuthWit(messageHash: Fr | Buffer): Promise<AuthWitness>;
}

/**
* Handler for interfacing with an account. Knows how to create transaction execution
Expand Down
13 changes: 0 additions & 13 deletions yarn-project/aztec.js/src/account/wallet.ts

This file was deleted.

Loading