@aztec/aztec.js 0.66.0 → 0.67.1-devnet

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 (65) hide show
  1. package/dest/api/addresses.d.ts +3 -0
  2. package/dest/api/addresses.d.ts.map +1 -0
  3. package/dest/api/addresses.js +3 -0
  4. package/dest/contract/base_contract_interaction.d.ts.map +1 -1
  5. package/dest/contract/base_contract_interaction.js +5 -4
  6. package/dest/contract/deploy_sent_tx.d.ts.map +1 -1
  7. package/dest/contract/deploy_sent_tx.js +3 -3
  8. package/dest/contract/index.d.ts +6 -6
  9. package/dest/contract/index.d.ts.map +1 -1
  10. package/dest/contract/index.js +7 -7
  11. package/dest/contract/sent_tx.d.ts +0 -5
  12. package/dest/contract/sent_tx.d.ts.map +1 -1
  13. package/dest/contract/sent_tx.js +2 -12
  14. package/dest/fee/fee_juice_payment_method_with_claim.d.ts.map +1 -1
  15. package/dest/fee/fee_juice_payment_method_with_claim.js +4 -3
  16. package/dest/index.d.ts +7 -6
  17. package/dest/index.d.ts.map +1 -1
  18. package/dest/index.js +9 -7
  19. package/dest/rpc_clients/node/index.d.ts +2 -2
  20. package/dest/rpc_clients/node/index.d.ts.map +1 -1
  21. package/dest/rpc_clients/node/index.js +1 -1
  22. package/dest/rpc_clients/pxe_client.d.ts +1 -1
  23. package/dest/rpc_clients/pxe_client.d.ts.map +1 -1
  24. package/dest/rpc_clients/pxe_client.js +2 -2
  25. package/dest/utils/anvil_test_watcher.d.ts.map +1 -1
  26. package/dest/utils/anvil_test_watcher.js +6 -6
  27. package/dest/utils/cheat_codes.d.ts.map +1 -1
  28. package/dest/utils/cheat_codes.js +4 -4
  29. package/dest/utils/index.d.ts +1 -0
  30. package/dest/utils/index.d.ts.map +1 -1
  31. package/dest/utils/index.js +2 -1
  32. package/dest/utils/node.d.ts +4 -0
  33. package/dest/utils/node.d.ts.map +1 -0
  34. package/dest/utils/node.js +16 -0
  35. package/dest/utils/portal_manager.d.ts +8 -8
  36. package/dest/utils/portal_manager.d.ts.map +1 -1
  37. package/dest/utils/portal_manager.js +1 -1
  38. package/dest/utils/pxe.d.ts +2 -2
  39. package/dest/utils/pxe.d.ts.map +1 -1
  40. package/dest/utils/pxe.js +1 -1
  41. package/dest/wallet/base_wallet.d.ts +1 -4
  42. package/dest/wallet/base_wallet.d.ts.map +1 -1
  43. package/dest/wallet/base_wallet.js +2 -14
  44. package/package.json +17 -10
  45. package/{dest/api/aztec_address.d.ts → src/api/addresses.ts} +1 -1
  46. package/src/contract/base_contract_interaction.ts +4 -3
  47. package/src/contract/deploy_sent_tx.ts +2 -2
  48. package/src/contract/index.ts +10 -6
  49. package/src/contract/sent_tx.ts +1 -16
  50. package/src/fee/fee_juice_payment_method_with_claim.ts +3 -2
  51. package/src/index.ts +6 -22
  52. package/src/rpc_clients/node/index.ts +2 -2
  53. package/src/rpc_clients/pxe_client.ts +1 -1
  54. package/src/utils/anvil_test_watcher.ts +5 -5
  55. package/src/utils/cheat_codes.ts +3 -3
  56. package/src/utils/index.ts +1 -0
  57. package/src/utils/node.ts +17 -0
  58. package/src/utils/portal_manager.ts +7 -7
  59. package/src/utils/pxe.ts +2 -2
  60. package/src/wallet/base_wallet.ts +1 -15
  61. package/dest/api/aztec_address.d.ts.map +0 -1
  62. package/dest/api/aztec_address.js +0 -2
  63. package/dest/main.js +0 -2
  64. package/dest/main.js.LICENSE.txt +0 -25
  65. package/src/api/aztec_address.ts +0 -1
package/src/index.ts CHANGED
@@ -13,29 +13,12 @@
13
13
  * ```typescript
14
14
  * import { TxHash } from '@aztec.js/tx_hash'
15
15
  * import { type ContractArtifact, type FunctionArtifact, FunctionSelector } from '@aztec/aztec.js/abi';
16
- * import { AztecAddress } from '@aztec/aztec.js/aztec_address';
16
+ * import { AztecAddress } from '@aztec/aztec.js/addresses';
17
17
  * import { EthAddress } from '@aztec/aztec.js/eth_address';
18
18
  * ```
19
19
  *
20
20
  * TODO: Ultimately reimplement this mega exporter by mega exporting a granular api (then deprecate it).
21
21
  */
22
- export {
23
- BatchCall,
24
- Contract,
25
- ContractBase,
26
- ContractFunctionInteraction,
27
- DefaultWaitOpts,
28
- DeployMethod,
29
- DeploySentTx,
30
- SentTx,
31
- type ContractMethod,
32
- type ContractNotes,
33
- type ContractStorageLayout,
34
- type DeployOptions,
35
- type ProfileResult,
36
- type SendMethodOptions,
37
- type WaitOpts,
38
- } from './contract/index.js';
39
22
 
40
23
  export { ContractDeployer } from './deployment/index.js';
41
24
 
@@ -53,6 +36,7 @@ export {
53
36
  generatePublicKey,
54
37
  readFieldCompressedString,
55
38
  waitForPXE,
39
+ waitForNode,
56
40
  type AztecAddressLike,
57
41
  type EthAddressLike,
58
42
  type EventSelectorLike,
@@ -78,7 +62,6 @@ export { AccountWallet, AccountWalletWithSecretKey, SignerlessWallet, type Walle
78
62
  // // TODO https://github.com/AztecProtocol/aztec-packages/issues/2632 --> FunctionSelector might not need to be exposed
79
63
  // // here once the issue is resolved.
80
64
  export {
81
- AztecAddress,
82
65
  ContractClassWithId,
83
66
  ContractInstanceWithAddress,
84
67
  EthAddress,
@@ -109,7 +92,6 @@ export {
109
92
  AuthWitness,
110
93
  Body,
111
94
  Comparator,
112
- CompleteAddress,
113
95
  ContractClass2BlockL2Logs,
114
96
  EncryptedLogPayload,
115
97
  EpochProofQuote,
@@ -148,7 +130,6 @@ export {
148
130
  type PXE,
149
131
  type PartialAddress,
150
132
  type PublicKey,
151
- type SyncStatus,
152
133
  } from '@aztec/circuit-types';
153
134
 
154
135
  // TODO: These kinds of things have no place on our public api.
@@ -158,7 +139,7 @@ export { decodeFromAbi, encodeArguments, type AbiType } from '@aztec/foundation/
158
139
  export { toBigIntBE } from '@aztec/foundation/bigint-buffer';
159
140
  export { sha256 } from '@aztec/foundation/crypto';
160
141
  export { makeFetch } from '@aztec/foundation/json-rpc/client';
161
- export { createDebugLogger, type DebugLogger } from '@aztec/foundation/log';
142
+ export { createLogger, type Logger } from '@aztec/foundation/log';
162
143
  export { retry, retryUntil } from '@aztec/foundation/retry';
163
144
  export { to2Fields, toBigInt } from '@aztec/foundation/serialize';
164
145
  export { sleep } from '@aztec/foundation/sleep';
@@ -174,3 +155,6 @@ export { EthCheatCodes, deployL1Contract, deployL1Contracts, type DeployL1Contra
174
155
  export * from './api/abi.js';
175
156
  export * from './api/fee.js';
176
157
  export * from './api/init.js';
158
+ // Granular export, even if not in the api folder
159
+ export * from './contract/index.js';
160
+ export * from './api/addresses.js';
@@ -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 PXE, PXESchema } from '@aztec/circuit-types';
1
+ import { type PXE, PXESchema } from '@aztec/circuit-types/interfaces';
2
2
  import { createSafeJsonRpcClient, makeFetch } from '@aztec/foundation/json-rpc/client';
3
3
 
4
4
  /**
@@ -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() {
@@ -46,9 +46,9 @@ export class AnvilTestWatcher {
46
46
  const isAutoMining = await this.cheatcodes.isAutoMining();
47
47
 
48
48
  if (isAutoMining) {
49
- this.filledRunningPromise = new RunningPromise(() => this.mineIfSlotFilled(), 1000);
49
+ this.filledRunningPromise = new RunningPromise(() => this.mineIfSlotFilled(), this.logger, 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
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"aztec_address.d.ts","sourceRoot":"","sources":["../../src/api/aztec_address.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC"}
@@ -1,2 +0,0 @@
1
- export { AztecAddress } from '@aztec/foundation/aztec-address';
2
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXp0ZWNfYWRkcmVzcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9hcGkvYXp0ZWNfYWRkcmVzcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0saUNBQWlDLENBQUMifQ==