@aztec/aztec.js 0.66.0 → 0.67.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dest/contract/base_contract_interaction.d.ts.map +1 -1
  2. package/dest/contract/base_contract_interaction.js +3 -3
  3. package/dest/contract/deploy_sent_tx.d.ts.map +1 -1
  4. package/dest/contract/deploy_sent_tx.js +3 -3
  5. package/dest/contract/sent_tx.d.ts +0 -5
  6. package/dest/contract/sent_tx.d.ts.map +1 -1
  7. package/dest/contract/sent_tx.js +2 -12
  8. package/dest/index.d.ts +3 -3
  9. package/dest/index.d.ts.map +1 -1
  10. package/dest/index.js +3 -3
  11. package/dest/main.js +1 -1
  12. package/dest/main.js.LICENSE.txt +0 -2
  13. package/dest/rpc_clients/node/index.d.ts +2 -2
  14. package/dest/rpc_clients/node/index.d.ts.map +1 -1
  15. package/dest/rpc_clients/node/index.js +1 -1
  16. package/dest/utils/anvil_test_watcher.d.ts.map +1 -1
  17. package/dest/utils/anvil_test_watcher.js +5 -5
  18. package/dest/utils/cheat_codes.d.ts.map +1 -1
  19. package/dest/utils/cheat_codes.js +4 -4
  20. package/dest/utils/index.d.ts +1 -0
  21. package/dest/utils/index.d.ts.map +1 -1
  22. package/dest/utils/index.js +2 -1
  23. package/dest/utils/node.d.ts +4 -0
  24. package/dest/utils/node.d.ts.map +1 -0
  25. package/dest/utils/node.js +16 -0
  26. package/dest/utils/portal_manager.d.ts +8 -8
  27. package/dest/utils/portal_manager.d.ts.map +1 -1
  28. package/dest/utils/portal_manager.js +1 -1
  29. package/dest/utils/pxe.d.ts +2 -2
  30. package/dest/utils/pxe.d.ts.map +1 -1
  31. package/dest/utils/pxe.js +1 -1
  32. package/dest/wallet/base_wallet.d.ts +1 -4
  33. package/dest/wallet/base_wallet.d.ts.map +1 -1
  34. package/dest/wallet/base_wallet.js +2 -14
  35. package/package.json +12 -8
  36. package/src/contract/base_contract_interaction.ts +2 -2
  37. package/src/contract/deploy_sent_tx.ts +2 -2
  38. package/src/contract/sent_tx.ts +1 -16
  39. package/src/index.ts +2 -2
  40. package/src/rpc_clients/node/index.ts +2 -2
  41. package/src/utils/anvil_test_watcher.ts +4 -4
  42. package/src/utils/cheat_codes.ts +3 -3
  43. package/src/utils/index.ts +1 -0
  44. package/src/utils/node.ts +17 -0
  45. package/src/utils/portal_manager.ts +7 -7
  46. package/src/utils/pxe.ts +2 -2
  47. package/src/wallet/base_wallet.ts +1 -15
@@ -14,11 +14,6 @@ export type WaitOpts = {
14
14
  interval?: number;
15
15
  /** Whether to wait for the tx to be proven. */
16
16
  proven?: boolean;
17
- /**
18
- * Whether to wait for the node to notify that the block in which this tx was mined is available to fetch notes from.
19
- * If false, then any queries that depend on state set by this transaction may return stale data. Defaults to true.
20
- **/
21
- waitForNotesAvailable?: boolean;
22
17
  /** Whether to include information useful for debugging/testing in the receipt. */
23
18
  debug?: boolean;
24
19
  /** Whether to accept a revert as a status code for the tx when waiting for it. If false, will throw if the tx reverts. */
@@ -31,7 +26,6 @@ export const DefaultWaitOpts: WaitOpts = {
31
26
  provenTimeout: 600,
32
27
  interval: 1,
33
28
  debug: false,
34
- waitForNotesAvailable: true,
35
29
  };
36
30
 
37
31
  /**
@@ -124,16 +118,7 @@ export class SentTx {
124
118
  }
125
119
  return undefined;
126
120
  }
127
- // If we don't care about waiting for notes to be synced, return the receipt
128
- const waitForNotesAvailable = opts?.waitForNotesAvailable ?? DefaultWaitOpts.waitForNotesAvailable;
129
- if (!waitForNotesAvailable) {
130
- return txReceipt;
131
- }
132
- // Check if all sync blocks on the PXE Service are greater or equal than the block in which the tx was mined
133
- const { blocks } = await this.pxe.getSyncStatus();
134
- const targetBlock = txReceipt.blockNumber!;
135
- const areNotesAvailable = blocks >= targetBlock;
136
- return areNotesAvailable ? txReceipt : undefined;
121
+ return txReceipt;
137
122
  },
138
123
  'isMined',
139
124
  opts?.timeout ?? DefaultWaitOpts.timeout,
package/src/index.ts CHANGED
@@ -53,6 +53,7 @@ export {
53
53
  generatePublicKey,
54
54
  readFieldCompressedString,
55
55
  waitForPXE,
56
+ waitForNode,
56
57
  type AztecAddressLike,
57
58
  type EthAddressLike,
58
59
  type EventSelectorLike,
@@ -148,7 +149,6 @@ export {
148
149
  type PXE,
149
150
  type PartialAddress,
150
151
  type PublicKey,
151
- type SyncStatus,
152
152
  } from '@aztec/circuit-types';
153
153
 
154
154
  // TODO: These kinds of things have no place on our public api.
@@ -158,7 +158,7 @@ export { decodeFromAbi, encodeArguments, type AbiType } from '@aztec/foundation/
158
158
  export { toBigIntBE } from '@aztec/foundation/bigint-buffer';
159
159
  export { sha256 } from '@aztec/foundation/crypto';
160
160
  export { makeFetch } from '@aztec/foundation/json-rpc/client';
161
- export { createDebugLogger, type DebugLogger } from '@aztec/foundation/log';
161
+ export { createLogger, type Logger } from '@aztec/foundation/log';
162
162
  export { retry, retryUntil } from '@aztec/foundation/retry';
163
163
  export { to2Fields, toBigInt } from '@aztec/foundation/serialize';
164
164
  export { sleep } from '@aztec/foundation/sleep';
@@ -1,6 +1,6 @@
1
1
  import { type PXE } from '@aztec/circuit-types';
2
2
  import { jsonStringify } from '@aztec/foundation/json-rpc';
3
- import { type DebugLogger } from '@aztec/foundation/log';
3
+ import { type Logger } from '@aztec/foundation/log';
4
4
  import { NoRetryError, makeBackoff, retry } from '@aztec/foundation/retry';
5
5
 
6
6
  import { Axios, type AxiosError } from 'axios';
@@ -51,7 +51,7 @@ async function axiosFetch(host: string, rpcMethod: string, body: any, useApiEndp
51
51
  * @param _logger - Debug logger to warn version incompatibilities.
52
52
  * @returns A PXE client.
53
53
  */
54
- export function createCompatibleClient(rpcUrl: string, logger: DebugLogger): Promise<PXE> {
54
+ export function createCompatibleClient(rpcUrl: string, logger: Logger): Promise<PXE> {
55
55
  // Use axios due to timeout issues with fetch when proving TXs.
56
56
  const fetch = async (host: string, rpcMethod: string, body: any, useApiEndpoints: boolean) => {
57
57
  return await retry(
@@ -1,4 +1,4 @@
1
- import { type DebugLogger, type EthCheatCodes, createDebugLogger } from '@aztec/aztec.js';
1
+ import { type EthCheatCodes, type Logger, createLogger } from '@aztec/aztec.js';
2
2
  import { type EthAddress } from '@aztec/circuits.js';
3
3
  import { RunningPromise } from '@aztec/foundation/running-promise';
4
4
  import { RollupAbi } from '@aztec/l1-artifacts';
@@ -18,7 +18,7 @@ export class AnvilTestWatcher {
18
18
 
19
19
  private filledRunningPromise?: RunningPromise;
20
20
 
21
- private logger: DebugLogger = createDebugLogger(`aztec:utils:watcher`);
21
+ private logger: Logger = createLogger(`aztecjs:utils:watcher`);
22
22
 
23
23
  constructor(
24
24
  private cheatcodes: EthCheatCodes,
@@ -31,7 +31,7 @@ export class AnvilTestWatcher {
31
31
  client: publicClient,
32
32
  });
33
33
 
34
- this.logger.info(`Watcher created for rollup at ${rollupAddress}`);
34
+ this.logger.debug(`Watcher created for rollup at ${rollupAddress}`);
35
35
  }
36
36
 
37
37
  async start() {
@@ -48,7 +48,7 @@ export class AnvilTestWatcher {
48
48
  if (isAutoMining) {
49
49
  this.filledRunningPromise = new RunningPromise(() => this.mineIfSlotFilled(), 1000);
50
50
  this.filledRunningPromise.start();
51
- this.logger.info(`Watcher started`);
51
+ this.logger.info(`Watcher started for rollup at ${this.rollup.address}`);
52
52
  } else {
53
53
  this.logger.info(`Watcher not started because not auto mining`);
54
54
  }
@@ -2,7 +2,7 @@ import { type EpochProofClaim, type Note, type PXE } from '@aztec/circuit-types'
2
2
  import { type AztecAddress, EthAddress, Fr } from '@aztec/circuits.js';
3
3
  import { deriveStorageSlotInMap } from '@aztec/circuits.js/hash';
4
4
  import { EthCheatCodes, type L1ContractAddresses } from '@aztec/ethereum';
5
- import { createDebugLogger } from '@aztec/foundation/log';
5
+ import { createLogger } from '@aztec/foundation/log';
6
6
  import { RollupAbi } from '@aztec/l1-artifacts';
7
7
 
8
8
  import {
@@ -51,7 +51,7 @@ export class RollupCheatCodes {
51
51
  private client: WalletClient & PublicClient;
52
52
  private rollup: GetContractReturnType<typeof RollupAbi, WalletClient>;
53
53
 
54
- private logger = createDebugLogger('aztec:js:cheat_codes');
54
+ private logger = createLogger('aztecjs:cheat_codes');
55
55
 
56
56
  constructor(private ethCheatCodes: EthCheatCodes, addresses: Pick<L1ContractAddresses, 'rollupAddress'>) {
57
57
  this.client = createWalletClient({ chain: foundry, transport: http(ethCheatCodes.rpcUrl) }).extend(publicActions);
@@ -197,7 +197,7 @@ export class AztecCheatCodes {
197
197
  /**
198
198
  * The logger to use for the aztec cheatcodes
199
199
  */
200
- public logger = createDebugLogger('aztec:cheat_codes:aztec'),
200
+ public logger = createLogger('aztecjs:cheat_codes'),
201
201
  ) {}
202
202
 
203
203
  /**
@@ -4,6 +4,7 @@ export * from './abi_types.js';
4
4
  export * from './cheat_codes.js';
5
5
  export * from './authwit.js';
6
6
  export * from './pxe.js';
7
+ export * from './node.js';
7
8
  export * from './anvil_test_watcher.js';
8
9
  export * from './field_compressed_string.js';
9
10
  export * from './portal_manager.js';
@@ -0,0 +1,17 @@
1
+ import { type AztecNode } from '@aztec/circuit-types';
2
+ import { type Logger } from '@aztec/foundation/log';
3
+ import { retryUntil } from '@aztec/foundation/retry';
4
+
5
+ export const waitForNode = async (node: AztecNode, logger?: Logger) => {
6
+ await retryUntil(async () => {
7
+ try {
8
+ logger?.verbose('Attempting to contact Aztec node...');
9
+ await node.getNodeInfo();
10
+ logger?.verbose('Contacted Aztec node');
11
+ return true;
12
+ } catch (error) {
13
+ logger?.verbose('Failed to contact Aztec Node');
14
+ }
15
+ return undefined;
16
+ }, 'RPC Get Node Info');
17
+ };
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  type AztecAddress,
3
- type DebugLogger,
4
3
  EthAddress,
5
4
  Fr,
5
+ type Logger,
6
6
  type PXE,
7
7
  type SiblingPath,
8
8
  computeSecretHash,
@@ -49,7 +49,7 @@ function stringifyEthAddress(address: EthAddress | Hex, name?: string) {
49
49
  }
50
50
 
51
51
  /** Generates a pair secret and secret hash */
52
- export function generateClaimSecret(logger?: DebugLogger): [Fr, Fr] {
52
+ export function generateClaimSecret(logger?: Logger): [Fr, Fr] {
53
53
  const secret = Fr.random();
54
54
  const secretHash = computeSecretHash(secret);
55
55
  logger?.verbose(`Generated claim secret=${secret.toString()} hash=${secretHash.toString()}`);
@@ -65,7 +65,7 @@ export class L1TokenManager {
65
65
  public readonly address: EthAddress,
66
66
  private publicClient: PublicClient<HttpTransport, Chain>,
67
67
  private walletClient: WalletClient<HttpTransport, Chain, Account>,
68
- private logger: DebugLogger,
68
+ private logger: Logger,
69
69
  ) {
70
70
  this.contract = getContract({
71
71
  address: this.address.toString(),
@@ -122,7 +122,7 @@ export class L1FeeJuicePortalManager {
122
122
  tokenAddress: EthAddress,
123
123
  private readonly publicClient: PublicClient<HttpTransport, Chain>,
124
124
  private readonly walletClient: WalletClient<HttpTransport, Chain, Account>,
125
- private readonly logger: DebugLogger,
125
+ private readonly logger: Logger,
126
126
  ) {
127
127
  this.tokenManager = new L1TokenManager(tokenAddress, publicClient, walletClient, logger);
128
128
  this.contract = getContract({
@@ -192,7 +192,7 @@ export class L1FeeJuicePortalManager {
192
192
  pxe: PXE,
193
193
  publicClient: PublicClient<HttpTransport, Chain>,
194
194
  walletClient: WalletClient<HttpTransport, Chain, Account>,
195
- logger: DebugLogger,
195
+ logger: Logger,
196
196
  ): Promise<L1FeeJuicePortalManager> {
197
197
  const {
198
198
  l1ContractAddresses: { feeJuiceAddress, feeJuicePortalAddress },
@@ -216,7 +216,7 @@ export class L1ToL2TokenPortalManager {
216
216
  tokenAddress: EthAddress,
217
217
  protected publicClient: PublicClient<HttpTransport, Chain>,
218
218
  protected walletClient: WalletClient<HttpTransport, Chain, Account>,
219
- protected logger: DebugLogger,
219
+ protected logger: Logger,
220
220
  ) {
221
221
  this.tokenManager = new L1TokenManager(tokenAddress, publicClient, walletClient, logger);
222
222
  this.portal = getContract({
@@ -334,7 +334,7 @@ export class L1TokenPortalManager extends L1ToL2TokenPortalManager {
334
334
  outboxAddress: EthAddress,
335
335
  publicClient: PublicClient<HttpTransport, Chain>,
336
336
  walletClient: WalletClient<HttpTransport, Chain, Account>,
337
- logger: DebugLogger,
337
+ logger: Logger,
338
338
  ) {
339
339
  super(portalAddress, tokenAddress, publicClient, walletClient, logger);
340
340
  this.outbox = getContract({
package/src/utils/pxe.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { type PXE } from '@aztec/circuit-types';
2
- import { type DebugLogger } from '@aztec/foundation/log';
2
+ import { type Logger } from '@aztec/foundation/log';
3
3
  import { retryUntil } from '@aztec/foundation/retry';
4
4
 
5
- export const waitForPXE = async (pxe: PXE, logger?: DebugLogger) => {
5
+ export const waitForPXE = async (pxe: PXE, logger?: Logger) => {
6
6
  await retryUntil(async () => {
7
7
  try {
8
8
  logger?.verbose('Attempting to contact PXE...');
@@ -6,12 +6,10 @@ import {
6
6
  type IncomingNotesFilter,
7
7
  type L2Block,
8
8
  type LogFilter,
9
- type OutgoingNotesFilter,
10
9
  type PXE,
11
10
  type PXEInfo,
12
11
  type PrivateExecutionResult,
13
12
  type SiblingPath,
14
- type SyncStatus,
15
13
  type Tx,
16
14
  type TxExecutionRequest,
17
15
  type TxHash,
@@ -133,9 +131,6 @@ export abstract class BaseWallet implements Wallet {
133
131
  getIncomingNotes(filter: IncomingNotesFilter): Promise<UniqueNote[]> {
134
132
  return this.pxe.getIncomingNotes(filter);
135
133
  }
136
- getOutgoingNotes(filter: OutgoingNotesFilter): Promise<UniqueNote[]> {
137
- return this.pxe.getOutgoingNotes(filter);
138
- }
139
134
  getPublicStorageAt(contract: AztecAddress, storageSlot: Fr): Promise<any> {
140
135
  return this.pxe.getPublicStorageAt(contract, storageSlot);
141
136
  }
@@ -174,12 +169,6 @@ export abstract class BaseWallet implements Wallet {
174
169
  getNodeInfo(): Promise<NodeInfo> {
175
170
  return this.pxe.getNodeInfo();
176
171
  }
177
- isGlobalStateSynchronized() {
178
- return this.pxe.isGlobalStateSynchronized();
179
- }
180
- getSyncStatus(): Promise<SyncStatus> {
181
- return this.pxe.getSyncStatus();
182
- }
183
172
  addAuthWitness(authWitness: AuthWitness) {
184
173
  return this.pxe.addAuthWitness(authWitness);
185
174
  }
@@ -202,10 +191,7 @@ export abstract class BaseWallet implements Wallet {
202
191
  event: EventMetadataDefinition,
203
192
  from: number,
204
193
  limit: number,
205
- vpks: Point[] = [
206
- this.getCompleteAddress().publicKeys.masterIncomingViewingPublicKey,
207
- this.getCompleteAddress().publicKeys.masterOutgoingViewingPublicKey,
208
- ],
194
+ vpks: Point[] = [this.getCompleteAddress().publicKeys.masterIncomingViewingPublicKey],
209
195
  ): Promise<T[]> {
210
196
  return this.pxe.getEncryptedEvents(event, from, limit, vpks);
211
197
  }