Skip to content

Commit f52afd9

Browse files
authored
refactor!: nuking remaining Aztec Node proxy methods from PXE (#17109)
Continuation of the work from the PR down the sack and nuking the remaining Aztec Node proxy methods from PXE. These are the changes: 1. Dropepd `getCurrentBaseFee`, 2. moved `getTxReceipt` on `Wallet`, 3. drop `sendTx` and moved the implementation to `BaseWallet`, 4. dropped `getNodeInfo` (this was super ugly because we had essentially a copy of implementation from AztecNode in PXE). The cluttering of wallet inputs is only temporary because PXE is supposed to be a lib used by the wallet and hence the wallet itself should "set it up". This makes me realize that the PXEService naming is stale as it's transforming to not be a service. Will rename that once I nuke the PXE JSON RPC server.
2 parents a885b60 + 5732b20 commit f52afd9

File tree

86 files changed

+449
-626
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+449
-626
lines changed

boxes/boxes/react/src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export class PrivateEnv {
2222
l1Contracts,
2323
} as PXEServiceConfig;
2424
const pxe = await createPXEService(aztecNode, configWithContracts);
25-
const wallet = new TestWallet(pxe);
25+
const wallet = new TestWallet(pxe, aztecNode);
2626

2727
const [accountData] = await getInitialTestAccountsData();
2828
if (!accountData) {

boxes/boxes/vanilla/app/embedded-wallet.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,9 @@ export class EmbeddedWallet extends BaseWallet {
4343
): Promise<Account> {
4444
let account: Account | undefined;
4545
if (address.equals(AztecAddress.ZERO)) {
46-
const { l1ChainId: chainId, rollupVersion } =
47-
await this.pxe.getNodeInfo();
46+
const {chainId, version} = await this.getChainInfo();
4847
account = new SignerlessAccount(
49-
new DefaultMultiCallEntrypoint(chainId, rollupVersion)
48+
new DefaultMultiCallEntrypoint(chainId.toNumber(), version.toNumber())
5049
);
5150
} else {
5251
account = this.accounts.get(address?.toString() ?? '');
@@ -70,7 +69,7 @@ export class EmbeddedWallet extends BaseWallet {
7069

7170
static async initialize(nodeUrl: string) {
7271
// Create Aztec Node Client
73-
const aztecNode = await createAztecNodeClient(nodeUrl);
72+
const aztecNode = createAztecNodeClient(nodeUrl);
7473

7574
// Create PXE Service
7675
const config = getPXEServiceConfig();
@@ -84,9 +83,9 @@ export class EmbeddedWallet extends BaseWallet {
8483
await pxe.registerContract(await EmbeddedWallet.#getSponsoredPFCContract());
8584

8685
// Log the Node Info
87-
const nodeInfo = await pxe.getNodeInfo();
86+
const nodeInfo = await aztecNode.getNodeInfo();
8887
logger.info('PXE Connected to node', nodeInfo);
89-
return new EmbeddedWallet(pxe);
88+
return new EmbeddedWallet(pxe, aztecNode);
9089
}
9190

9291
// Internal method to use the Sponsored FPC Contract for fee payment
@@ -229,7 +228,7 @@ export class EmbeddedWallet extends BaseWallet {
229228
}
230229

231230
private async getFakeAccountDataFor(address: AztecAddress) {
232-
const nodeInfo = await this.pxe.getNodeInfo();
231+
const chainInfo = await this.getChainInfo();
233232
const originalAccount = await this.getAccountFromAddress(address);
234233
const originalAddress = await originalAccount.getCompleteAddress();
235234
const { contractInstance } = await this.pxe.getContractMetadata(
@@ -240,7 +239,7 @@ export class EmbeddedWallet extends BaseWallet {
240239
`No contract instance found for address: ${originalAddress.address}`
241240
);
242241
}
243-
const stubAccount = createStubAccount(originalAddress, nodeInfo);
242+
const stubAccount = createStubAccount(originalAddress, chainInfo);
244243
const StubAccountContractArtifact = await getStubAccountContractArtifact();
245244
const instance = await getContractInstanceFromInstantiationParams(
246245
StubAccountContractArtifact,

boxes/boxes/vanilla/scripts/deploy.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import {
77
Fr,
88
getContractInstanceFromInstantiationParams,
99
PublicKeys,
10-
type PXE,
1110
SponsoredFeePaymentMethod,
1211
type Wallet,
1312
} from '@aztec/aztec.js';
13+
import { type AztecNode } from '@aztec/aztec.js/interfaces';
1414
import { createPXEService, getPXEServiceConfig } from '@aztec/pxe/server';
1515
import { createStore } from '@aztec/kv-store/lmdb';
1616
import { getDefaultInitializer } from '@aztec/stdlib/abi';
@@ -26,9 +26,7 @@ const WRITE_ENV_FILE = process.env.WRITE_ENV_FILE === 'false' ? false : true;
2626

2727
const PXE_STORE_DIR = path.join(import.meta.dirname, '.store');
2828

29-
async function setupPXE() {
30-
const aztecNode = createAztecNodeClient(AZTEC_NODE_URL);
31-
29+
async function setupPXE(aztecNode: AztecNode) {
3230
fs.rmSync(PXE_STORE_DIR, { recursive: true, force: true });
3331

3432
const store = await createStore('pxe', {
@@ -159,8 +157,9 @@ async function writeEnvFile(deploymentInfo) {
159157
}
160158

161159
async function createAccountAndDeployContract() {
162-
const pxe = await setupPXE();
163-
const wallet = new TestWallet(pxe);
160+
const aztecNode = createAztecNodeClient(AZTEC_NODE_URL);
161+
const pxe = await setupPXE(aztecNode);
162+
const wallet = new TestWallet(pxe, aztecNode);
164163

165164
// Register the SponsoredFPC contract (for sponsored fee payments)
166165
await wallet.registerContract(

boxes/boxes/vite/src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export class PrivateEnv {
2626
l1Contracts,
2727
} as PXEServiceConfig;
2828
const pxe = await createPXEService(aztecNode, configWithContracts);
29-
const wallet = new TestWallet(pxe);
29+
const wallet = new TestWallet(pxe, aztecNode);
3030

3131
const [accountData] = await getInitialTestAccountsData();
3232
if (!accountData) {

playground/src/wallet/embedded_wallet.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
type PXE,
1313
createAztecNodeClient,
1414
type Aliased,
15+
type AztecNode,
1516
} from '@aztec/aztec.js';
1617
import { getPXEServiceConfig, type PXEServiceConfig } from '@aztec/pxe/config';
1718
import { createPXEService } from '@aztec/pxe/client/lazy';
@@ -48,13 +49,14 @@ export interface AccountData {
4849
export class EmbeddedWallet extends BaseWallet {
4950
constructor(
5051
pxe: PXE,
52+
aztecNode: AztecNode,
5153
private walletDB: WalletDB,
5254
) {
53-
super(pxe);
55+
super(pxe, aztecNode);
5456
}
5557

5658
static async create(nodeURL: string) {
57-
const aztecNode = await createAztecNodeClient(nodeURL);
59+
const aztecNode = createAztecNodeClient(nodeURL);
5860

5961
const l1Contracts = await aztecNode.getL1ContractAddresses();
6062
const rollupAddress = l1Contracts.rollupAddress;
@@ -83,13 +85,13 @@ export class EmbeddedWallet extends BaseWallet {
8385
walletLogger,
8486
);
8587
const db = WalletDB.init(walletDBStore, walletLogger.info);
86-
return new EmbeddedWallet(pxe, db);
88+
return new EmbeddedWallet(pxe, aztecNode, db);
8789
}
8890

8991
protected async getAccountFromAddress(address: AztecAddress): Promise<Account> {
9092
let account: Account | undefined;
9193
if (address.equals(AztecAddress.ZERO)) {
92-
const { l1ChainId: chainId, rollupVersion } = await this.pxe.getNodeInfo();
94+
const { l1ChainId: chainId, rollupVersion } = await this.aztecNode.getNodeInfo();
9395
account = new SignerlessAccount(new DefaultMultiCallEntrypoint(chainId, rollupVersion));
9496
} else {
9597
const { secretKey, salt, signingKey, type } = await this.walletDB.retrieveAccount(address);
@@ -205,14 +207,14 @@ export class EmbeddedWallet extends BaseWallet {
205207
}
206208

207209
private async getFakeAccountDataFor(address: AztecAddress) {
208-
const nodeInfo = await this.pxe.getNodeInfo();
210+
const chainInfo = await this.getChainInfo();
209211
const originalAccount = await this.getAccountFromAddress(address);
210212
const originalAddress = await originalAccount.getCompleteAddress();
211213
const { contractInstance } = await this.pxe.getContractMetadata(originalAddress.address);
212214
if (!contractInstance) {
213215
throw new Error(`No contract instance found for address: ${originalAddress.address}`);
214216
}
215-
const stubAccount = createStubAccount(originalAddress, nodeInfo);
217+
const stubAccount = createStubAccount(originalAddress, chainInfo);
216218
const StubAccountContractArtifact = await getStubAccountContractArtifact();
217219
const instance = await getContractInstanceFromInstantiationParams(StubAccountContractArtifact, {
218220
salt: Fr.random(),

yarn-project/accounts/src/defaults/account_contract.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { AccountContract, AccountInterface, AuthWitnessProvider } from '@aztec/aztec.js/account';
2+
import type { ChainInfo } from '@aztec/aztec.js/wallet';
23
import type { ContractArtifact } from '@aztec/stdlib/abi';
3-
import type { CompleteAddress, NodeInfo } from '@aztec/stdlib/contract';
4+
import type { CompleteAddress } from '@aztec/stdlib/contract';
45

56
import { DefaultAccountInterface } from '../defaults/account_interface.js';
67

@@ -23,7 +24,7 @@ export abstract class DefaultAccountContract implements AccountContract {
2324

2425
constructor() {}
2526

26-
getInterface(address: CompleteAddress, nodeInfo: NodeInfo): AccountInterface {
27-
return new DefaultAccountInterface(this.getAuthWitnessProvider(address), address, nodeInfo);
27+
getInterface(address: CompleteAddress, chainInfo: ChainInfo): AccountInterface {
28+
return new DefaultAccountInterface(this.getAuthWitnessProvider(address), address, chainInfo);
2829
}
2930
}

yarn-project/accounts/src/defaults/account_interface.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import type { AccountInterface, AuthWitnessProvider } from '@aztec/aztec.js/account';
2+
import type { ChainInfo } from '@aztec/aztec.js/wallet';
23
import { DefaultAccountEntrypoint } from '@aztec/entrypoints/account';
34
import type { EntrypointInterface, FeeOptions, TxExecutionOptions } from '@aztec/entrypoints/interfaces';
45
import type { ExecutionPayload } from '@aztec/entrypoints/payload';
56
import { Fr } from '@aztec/foundation/fields';
67
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
78
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
89
import { CompleteAddress } from '@aztec/stdlib/contract';
9-
import type { NodeInfo } from '@aztec/stdlib/contract';
1010
import type { TxExecutionRequest } from '@aztec/stdlib/tx';
1111

1212
/**
@@ -22,16 +22,16 @@ export class DefaultAccountInterface implements AccountInterface {
2222
constructor(
2323
private authWitnessProvider: AuthWitnessProvider,
2424
private address: CompleteAddress,
25-
nodeInfo: Pick<NodeInfo, 'l1ChainId' | 'rollupVersion'>,
25+
chainInfo: ChainInfo,
2626
) {
2727
this.entrypoint = new DefaultAccountEntrypoint(
2828
address.address,
2929
authWitnessProvider,
30-
nodeInfo.l1ChainId,
31-
nodeInfo.rollupVersion,
30+
chainInfo.chainId.toNumber(),
31+
chainInfo.version.toNumber(),
3232
);
33-
this.chainId = new Fr(nodeInfo.l1ChainId);
34-
this.version = new Fr(nodeInfo.rollupVersion);
33+
this.chainId = chainInfo.chainId;
34+
this.version = chainInfo.version;
3535
}
3636

3737
createTxExecutionRequest(

yarn-project/accounts/src/stub/index.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BaseAccount, type CompleteAddress, type NodeInfo } from '@aztec/aztec.js';
1+
import { BaseAccount, type ChainInfo, type CompleteAddress } from '@aztec/aztec.js';
22
import type { ContractArtifact } from '@aztec/stdlib/abi';
33
import { loadContractArtifact } from '@aztec/stdlib/abi';
44
import type { NoirCompiledContract } from '@aztec/stdlib/noir';
@@ -26,15 +26,12 @@ export class StubAccountContract extends StubBaseAccountContract {
2626
/**
2727
*
2828
*/
29-
export function createStubAccount(
30-
originalAddress: CompleteAddress,
31-
nodeInfo: Pick<NodeInfo, 'l1ChainId' | 'rollupVersion'>,
32-
) {
29+
export function createStubAccount(originalAddress: CompleteAddress, chainInfo: ChainInfo) {
3330
const accountContract = new StubAccountContract();
3431
const accountInterface = new DefaultAccountInterface(
3532
accountContract.getAuthWitnessProvider(originalAddress),
3633
originalAddress,
37-
nodeInfo,
34+
chainInfo,
3835
);
3936
return new BaseAccount(accountInterface);
4037
}

yarn-project/accounts/src/stub/lazy.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BaseAccount, type CompleteAddress, type NodeInfo } from '@aztec/aztec.js';
1+
import { BaseAccount, type ChainInfo, type CompleteAddress } from '@aztec/aztec.js';
22
import type { ContractArtifact } from '@aztec/stdlib/abi';
33
import { loadContractArtifact } from '@aztec/stdlib/abi';
44

@@ -37,15 +37,12 @@ export class StubAccountContract extends StubBaseAccountContract {
3737
/**
3838
*
3939
*/
40-
export function createStubAccount(
41-
originalAddress: CompleteAddress,
42-
nodeInfo: Pick<NodeInfo, 'l1ChainId' | 'rollupVersion'>,
43-
) {
40+
export function createStubAccount(originalAddress: CompleteAddress, chainInfo: ChainInfo) {
4441
const accountContract = new StubAccountContract();
4542
const accountInterface = new DefaultAccountInterface(
4643
accountContract.getAuthWitnessProvider(originalAddress),
4744
originalAddress,
48-
nodeInfo,
45+
chainInfo,
4946
);
5047
return new BaseAccount(accountInterface);
5148
}

yarn-project/aztec.js/src/account/account_contract.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import type { AuthWitnessProvider } from '@aztec/entrypoints/interfaces';
22
import { Fr } from '@aztec/foundation/fields';
33
import type { ContractArtifact } from '@aztec/stdlib/abi';
4-
import type { CompleteAddress, NodeInfo } from '@aztec/stdlib/contract';
4+
import type { CompleteAddress } from '@aztec/stdlib/contract';
55
import { getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
66
import { deriveKeys } from '@aztec/stdlib/keys';
77

8+
import type { ChainInfo } from '../wallet/index.js';
89
import type { AccountInterface } from './interface.js';
910

1011
// docs:start:account-contract-interface
@@ -36,10 +37,10 @@ export interface AccountContract {
3637
* The account interface is responsible for assembling tx requests given requested function calls, and
3738
* for creating signed auth witnesses given action identifiers (message hashes).
3839
* @param address - Address of this account contract.
39-
* @param nodeInfo - Info on the chain where it is initialized / published.
40+
* @param chainInfo - Chain id and version of the rollup where the account contract is initialized / published.
4041
* @returns An account interface instance for creating tx requests and authorizing actions.
4142
*/
42-
getInterface(address: CompleteAddress, nodeInfo: NodeInfo): AccountInterface;
43+
getInterface(address: CompleteAddress, chainInfo: ChainInfo): AccountInterface;
4344

4445
/**
4546
* Returns the auth witness provider for the given address.

0 commit comments

Comments
 (0)