@aztec/aztec.js 0.41.0 → 0.43.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 (99) hide show
  1. package/dest/account/index.d.ts +2 -2
  2. package/dest/account/index.d.ts.map +1 -1
  3. package/dest/account_manager/deploy_account_method.d.ts.map +1 -1
  4. package/dest/account_manager/deploy_account_method.js +7 -5
  5. package/dest/account_manager/index.d.ts +1 -2
  6. package/dest/account_manager/index.d.ts.map +1 -1
  7. package/dest/account_manager/index.js +5 -11
  8. package/dest/api/abi.d.ts +2 -2
  9. package/dest/api/abi.d.ts.map +1 -1
  10. package/dest/api/abi.js +1 -1
  11. package/dest/api/fee.d.ts +2 -0
  12. package/dest/api/fee.d.ts.map +1 -1
  13. package/dest/api/fee.js +3 -1
  14. package/dest/contract/base_contract_interaction.d.ts +7 -6
  15. package/dest/contract/base_contract_interaction.d.ts.map +1 -1
  16. package/dest/contract/base_contract_interaction.js +20 -9
  17. package/dest/contract/batch_call.d.ts +11 -0
  18. package/dest/contract/batch_call.d.ts.map +1 -1
  19. package/dest/contract/batch_call.js +50 -2
  20. package/dest/contract/contract_function_interaction.d.ts.map +1 -1
  21. package/dest/contract/contract_function_interaction.js +14 -10
  22. package/dest/contract/deploy_method.d.ts +5 -1
  23. package/dest/contract/deploy_method.d.ts.map +1 -1
  24. package/dest/contract/deploy_method.js +22 -6
  25. package/dest/contract/get_gas_limits.d.ts +1 -1
  26. package/dest/contract/get_gas_limits.d.ts.map +1 -1
  27. package/dest/contract/get_gas_limits.js +5 -3
  28. package/dest/contract/sent_tx.d.ts.map +1 -1
  29. package/dest/contract/sent_tx.js +7 -5
  30. package/dest/entrypoint/default_entrypoint.d.ts.map +1 -1
  31. package/dest/entrypoint/default_entrypoint.js +6 -2
  32. package/dest/entrypoint/default_multi_call_entrypoint.d.ts.map +1 -1
  33. package/dest/entrypoint/default_multi_call_entrypoint.js +4 -4
  34. package/dest/entrypoint/payload.d.ts +24 -9
  35. package/dest/entrypoint/payload.d.ts.map +1 -1
  36. package/dest/entrypoint/payload.js +50 -29
  37. package/dest/fee/fee_payment_method.d.ts +6 -7
  38. package/dest/fee/fee_payment_method.d.ts.map +1 -1
  39. package/dest/fee/native_fee_payment_method.d.ts +5 -25
  40. package/dest/fee/native_fee_payment_method.d.ts.map +1 -1
  41. package/dest/fee/native_fee_payment_method.js +9 -46
  42. package/dest/fee/native_fee_payment_method_with_claim.d.ts +17 -0
  43. package/dest/fee/native_fee_payment_method_with_claim.d.ts.map +1 -0
  44. package/dest/fee/native_fee_payment_method_with_claim.js +32 -0
  45. package/dest/fee/no_fee_payment_method.d.ts +13 -0
  46. package/dest/fee/no_fee_payment_method.d.ts.map +1 -0
  47. package/dest/fee/no_fee_payment_method.js +17 -0
  48. package/dest/fee/private_fee_payment_method.d.ts +1 -5
  49. package/dest/fee/private_fee_payment_method.d.ts.map +1 -1
  50. package/dest/fee/private_fee_payment_method.js +13 -14
  51. package/dest/fee/public_fee_payment_method.d.ts +1 -5
  52. package/dest/fee/public_fee_payment_method.d.ts.map +1 -1
  53. package/dest/fee/public_fee_payment_method.js +13 -14
  54. package/dest/index.d.ts +12 -13
  55. package/dest/index.d.ts.map +1 -1
  56. package/dest/index.js +10 -11
  57. package/dest/rpc_clients/pxe_client.d.ts.map +1 -1
  58. package/dest/rpc_clients/pxe_client.js +3 -3
  59. package/dest/utils/account.js +3 -3
  60. package/dest/utils/authwit.d.ts.map +1 -1
  61. package/dest/utils/authwit.js +2 -6
  62. package/dest/utils/cheat_codes.d.ts.map +1 -1
  63. package/dest/utils/cheat_codes.js +9 -5
  64. package/dest/wallet/account_wallet.d.ts +17 -1
  65. package/dest/wallet/account_wallet.d.ts.map +1 -1
  66. package/dest/wallet/account_wallet.js +45 -31
  67. package/dest/wallet/base_wallet.d.ts +12 -3
  68. package/dest/wallet/base_wallet.d.ts.map +1 -1
  69. package/dest/wallet/base_wallet.js +21 -3
  70. package/dest/wallet/signerless_wallet.js +7 -7
  71. package/package.json +7 -7
  72. package/src/account/index.ts +2 -2
  73. package/src/account_manager/deploy_account_method.ts +10 -3
  74. package/src/account_manager/index.ts +11 -9
  75. package/src/api/abi.ts +2 -2
  76. package/src/api/fee.ts +2 -0
  77. package/src/contract/base_contract_interaction.ts +32 -8
  78. package/src/contract/batch_call.ts +77 -1
  79. package/src/contract/contract_function_interaction.ts +20 -10
  80. package/src/contract/deploy_method.ts +23 -6
  81. package/src/contract/get_gas_limits.ts +4 -3
  82. package/src/contract/sent_tx.ts +6 -4
  83. package/src/entrypoint/default_entrypoint.ts +7 -1
  84. package/src/entrypoint/default_multi_call_entrypoint.ts +3 -3
  85. package/src/entrypoint/payload.ts +58 -26
  86. package/src/fee/fee_payment_method.ts +6 -8
  87. package/src/fee/native_fee_payment_method.ts +8 -47
  88. package/src/fee/native_fee_payment_method_with_claim.ts +33 -0
  89. package/src/fee/no_fee_payment_method.ts +23 -0
  90. package/src/fee/private_fee_payment_method.ts +13 -17
  91. package/src/fee/public_fee_payment_method.ts +13 -18
  92. package/src/index.ts +38 -34
  93. package/src/rpc_clients/pxe_client.ts +3 -3
  94. package/src/utils/account.ts +2 -2
  95. package/src/utils/authwit.ts +1 -5
  96. package/src/utils/cheat_codes.ts +8 -4
  97. package/src/wallet/account_wallet.ts +67 -29
  98. package/src/wallet/base_wallet.ts +38 -4
  99. package/src/wallet/signerless_wallet.ts +6 -6
@@ -0,0 +1,33 @@
1
+ import { type FunctionCall } from '@aztec/circuit-types';
2
+ import { type AztecAddress, Fr, FunctionSelector } from '@aztec/circuits.js';
3
+ import { FunctionType } from '@aztec/foundation/abi';
4
+ import { GasTokenAddress } from '@aztec/protocol-contracts/gas-token';
5
+
6
+ import { NativeFeePaymentMethod } from './native_fee_payment_method.js';
7
+
8
+ /**
9
+ * Pay fee directly with native gas token claimed on the same tx.
10
+ */
11
+ export class NativeFeePaymentMethodWithClaim extends NativeFeePaymentMethod {
12
+ constructor(sender: AztecAddress, private claimAmount: bigint | Fr, private claimSecret: Fr) {
13
+ super(sender);
14
+ }
15
+
16
+ /**
17
+ * Creates a function call to pay the fee in gas token.
18
+ * @returns A function call
19
+ */
20
+ override getFunctionCalls(): Promise<FunctionCall[]> {
21
+ return Promise.resolve([
22
+ {
23
+ to: GasTokenAddress,
24
+ name: 'claim',
25
+ selector: FunctionSelector.fromSignature('claim((Field),Field,Field)'),
26
+ isStatic: false,
27
+ args: [this.sender, new Fr(this.claimAmount), this.claimSecret],
28
+ returnTypes: [],
29
+ type: FunctionType.PRIVATE,
30
+ },
31
+ ]);
32
+ }
33
+ }
@@ -0,0 +1,23 @@
1
+ import { type FunctionCall } from '@aztec/circuit-types';
2
+ import { AztecAddress } from '@aztec/circuits.js';
3
+
4
+ import { type FeePaymentMethod } from './fee_payment_method.js';
5
+
6
+ /**
7
+ * Does not pay fees. Will work until we enforce fee payment for all txs.
8
+ */
9
+ export class NoFeePaymentMethod implements FeePaymentMethod {
10
+ constructor() {}
11
+
12
+ getAsset() {
13
+ return AztecAddress.ZERO;
14
+ }
15
+
16
+ getFunctionCalls(): Promise<FunctionCall[]> {
17
+ return Promise.resolve([]);
18
+ }
19
+
20
+ getFeePayer(): Promise<AztecAddress> {
21
+ return Promise.resolve(AztecAddress.ZERO);
22
+ }
23
+ }
@@ -1,7 +1,7 @@
1
1
  import { type FunctionCall } from '@aztec/circuit-types';
2
- import { FunctionData, type GasSettings } from '@aztec/circuits.js';
2
+ import { type GasSettings } from '@aztec/circuits.js';
3
3
  import { computeSecretHash } from '@aztec/circuits.js/hash';
4
- import { FunctionSelector } from '@aztec/foundation/abi';
4
+ import { FunctionSelector, FunctionType } from '@aztec/foundation/abi';
5
5
  import { type AztecAddress } from '@aztec/foundation/aztec-address';
6
6
  import { Fr } from '@aztec/foundation/fields';
7
7
 
@@ -43,12 +43,8 @@ export class PrivateFeePaymentMethod implements FeePaymentMethod {
43
43
  return this.asset;
44
44
  }
45
45
 
46
- /**
47
- * The address which will facilitate the fee payment.
48
- * @returns The contract address responsible for holding the fee payment.
49
- */
50
- getPaymentContract() {
51
- return this.paymentContract;
46
+ getFeePayer(): Promise<AztecAddress> {
47
+ return Promise.resolve(this.paymentContract);
52
48
  }
53
49
 
54
50
  /**
@@ -64,13 +60,13 @@ export class PrivateFeePaymentMethod implements FeePaymentMethod {
64
60
  this.wallet.getChainId(),
65
61
  this.wallet.getVersion(),
66
62
  {
63
+ name: 'unshield',
67
64
  args: [this.wallet.getCompleteAddress().address, this.paymentContract, maxFee, nonce],
68
- functionData: new FunctionData(
69
- FunctionSelector.fromSignature('unshield((Field),(Field),Field,Field)'),
70
- /*isPrivate=*/ true,
71
- ),
65
+ selector: FunctionSelector.fromSignature('unshield((Field),(Field),Field,Field)'),
66
+ type: FunctionType.PRIVATE,
72
67
  isStatic: false,
73
68
  to: this.asset,
69
+ returnTypes: [],
74
70
  },
75
71
  );
76
72
  await this.wallet.createAuthWit(messageHash);
@@ -79,13 +75,13 @@ export class PrivateFeePaymentMethod implements FeePaymentMethod {
79
75
 
80
76
  return [
81
77
  {
82
- to: this.getPaymentContract(),
83
- functionData: new FunctionData(
84
- FunctionSelector.fromSignature('fee_entrypoint_private(Field,(Field),Field,Field)'),
85
- /*isPrivate=*/ true,
86
- ),
78
+ name: 'fee_entrypoint_private',
79
+ to: this.paymentContract,
80
+ selector: FunctionSelector.fromSignature('fee_entrypoint_private(Field,(Field),Field,Field)'),
81
+ type: FunctionType.PRIVATE,
87
82
  isStatic: false,
88
83
  args: [maxFee, this.asset, secretHashForRebate, nonce],
84
+ returnTypes: [],
89
85
  },
90
86
  ];
91
87
  }
@@ -1,6 +1,6 @@
1
1
  import { type FunctionCall } from '@aztec/circuit-types';
2
- import { FunctionData, type GasSettings } from '@aztec/circuits.js';
3
- import { FunctionSelector } from '@aztec/foundation/abi';
2
+ import { type GasSettings } from '@aztec/circuits.js';
3
+ import { FunctionSelector, FunctionType } from '@aztec/foundation/abi';
4
4
  import { type AztecAddress } from '@aztec/foundation/aztec-address';
5
5
  import { Fr } from '@aztec/foundation/fields';
6
6
 
@@ -21,7 +21,6 @@ export class PublicFeePaymentMethod implements FeePaymentMethod {
21
21
  * Address which will hold the fee payment.
22
22
  */
23
23
  protected paymentContract: AztecAddress,
24
-
25
24
  /**
26
25
  * An auth witness provider to authorize fee payments
27
26
  */
@@ -36,12 +35,8 @@ export class PublicFeePaymentMethod implements FeePaymentMethod {
36
35
  return this.asset;
37
36
  }
38
37
 
39
- /**
40
- * The address which will facilitate the fee payment.
41
- * @returns The contract address responsible for holding the fee payment.
42
- */
43
- getPaymentContract() {
44
- return this.paymentContract;
38
+ getFeePayer(): Promise<AztecAddress> {
39
+ return Promise.resolve(this.paymentContract);
45
40
  }
46
41
 
47
42
  /**
@@ -57,26 +52,26 @@ export class PublicFeePaymentMethod implements FeePaymentMethod {
57
52
  this.wallet.getChainId(),
58
53
  this.wallet.getVersion(),
59
54
  {
55
+ name: 'transfer_public',
60
56
  args: [this.wallet.getAddress(), this.paymentContract, maxFee, nonce],
61
- functionData: new FunctionData(
62
- FunctionSelector.fromSignature('transfer_public((Field),(Field),Field,Field)'),
63
- /*isPrivate=*/ false,
64
- ),
57
+ selector: FunctionSelector.fromSignature('transfer_public((Field),(Field),Field,Field)'),
58
+ type: FunctionType.PUBLIC,
65
59
  isStatic: false,
66
60
  to: this.asset,
61
+ returnTypes: [],
67
62
  },
68
63
  );
69
64
 
70
65
  return Promise.resolve([
71
66
  this.wallet.setPublicAuthWit(messageHash, true).request(),
72
67
  {
73
- to: this.getPaymentContract(),
74
- functionData: new FunctionData(
75
- FunctionSelector.fromSignature('fee_entrypoint_public(Field,(Field),Field)'),
76
- /*isPrivate=*/ true,
77
- ),
68
+ name: 'fee_entrypoint_public',
69
+ to: this.paymentContract,
70
+ selector: FunctionSelector.fromSignature('fee_entrypoint_public(Field,(Field),Field)'),
71
+ type: FunctionType.PRIVATE,
78
72
  isStatic: false,
79
73
  args: [maxFee, this.asset, nonce],
74
+ returnTypes: [],
80
75
  },
81
76
  ]);
82
77
  }
package/src/index.ts CHANGED
@@ -20,35 +20,36 @@
20
20
  * TODO: Ultimately reimplement this mega exporter by mega exporting a granular api (then deprecate it).
21
21
  */
22
22
  export {
23
- WaitOpts,
24
- ContractFunctionInteraction,
23
+ BatchCall,
25
24
  Contract,
26
25
  ContractBase,
27
- ContractMethod,
28
- ContractStorageLayout,
29
- ContractNotes,
30
- SentTx,
31
- BatchCall,
26
+ ContractFunctionInteraction,
27
+ type ContractMethod,
28
+ type ContractNotes,
29
+ type ContractStorageLayout,
32
30
  DeployMethod,
33
31
  DeploySentTx,
32
+ type SendMethodOptions,
33
+ SentTx,
34
+ type WaitOpts,
34
35
  } from './contract/index.js';
35
36
 
36
37
  export { ContractDeployer } from './deployment/index.js';
37
38
 
38
39
  export {
39
- generatePublicKey,
40
- FieldLike,
41
- EthAddressLike,
42
- CheatCodes,
43
40
  AztecAddressLike,
41
+ CheatCodes,
42
+ EthAddressLike,
43
+ EthCheatCodes,
44
+ FieldLike,
44
45
  FunctionSelectorLike,
45
46
  WrappedFieldLike,
46
- EthCheatCodes,
47
47
  computeAuthWitMessageHash,
48
48
  computeInnerAuthWitHash,
49
49
  computeOuterAuthWitHash,
50
- waitForPXE,
50
+ generatePublicKey,
51
51
  waitForAccountSynch,
52
+ waitForPXE,
52
53
  } from './utils/index.js';
53
54
 
54
55
  export { createPXEClient } from './rpc_clients/index.js';
@@ -56,23 +57,23 @@ export { createPXEClient } from './rpc_clients/index.js';
56
57
  export { AuthWitnessProvider } from './account/index.js';
57
58
 
58
59
  export { AccountContract } from './account/index.js';
59
- export { AccountManager } from './account_manager/index.js';
60
+ export { AccountManager, DeployAccountOptions } from './account_manager/index.js';
60
61
 
61
- export { AccountWalletWithSecretKey, AccountWallet, Wallet, SignerlessWallet } from './wallet/index.js';
62
+ export { AccountWallet, AccountWalletWithSecretKey, SignerlessWallet, Wallet } from './wallet/index.js';
62
63
 
63
64
  // // TODO https://github.com/AztecProtocol/aztec-packages/issues/2632 --> FunctionSelector might not need to be exposed
64
65
  // // here once the issue is resolved.
65
66
  export {
66
67
  AztecAddress,
67
68
  EthAddress,
68
- Fr,
69
69
  Fq,
70
+ Fr,
70
71
  GlobalVariables,
71
72
  GrumpkinScalar,
73
+ INITIAL_L2_BLOCK_NUM,
72
74
  Point,
73
- getContractInstanceFromDeployParams, // TODO(@spalladino) This method should be used from within the DeployMethod but not exposed in aztec.js
74
75
  getContractClassFromArtifact,
75
- INITIAL_L2_BLOCK_NUM,
76
+ getContractInstanceFromDeployParams,
76
77
  } from '@aztec/circuits.js';
77
78
 
78
79
  export { computeSecretHash } from '@aztec/circuits.js/hash';
@@ -90,17 +91,21 @@ export {
90
91
  AuthWitness,
91
92
  AztecNode,
92
93
  Body,
94
+ Comparator,
93
95
  CompleteAddress,
96
+ EncryptedL2BlockL2Logs,
97
+ EncryptedLogHeader,
98
+ EncryptedNoteLogIncomingBody,
99
+ EncryptedLogOutgoingBody,
94
100
  ExtendedNote,
95
- type FunctionCall,
101
+ FunctionCall,
96
102
  GrumpkinPrivateKey,
97
- L1ToL2Message,
98
103
  L1Actor,
104
+ L1ToL2Message,
99
105
  L2Actor,
100
106
  L2Block,
101
107
  L2BlockL2Logs,
102
- EncryptedL2BlockL2Logs,
103
- UnencryptedL2BlockL2Logs,
108
+ EncryptedNoteL2BlockL2Logs,
104
109
  LogFilter,
105
110
  LogId,
106
111
  LogType,
@@ -110,41 +115,40 @@ export {
110
115
  PackedValues,
111
116
  PartialAddress,
112
117
  PublicKey,
118
+ SiblingPath,
113
119
  SyncStatus,
114
120
  Tx,
115
121
  TxExecutionRequest,
116
122
  TxHash,
117
123
  TxReceipt,
118
124
  TxStatus,
125
+ UnencryptedL2BlockL2Logs,
119
126
  UnencryptedL2Log,
120
127
  createAztecNodeClient,
121
- emptyFunctionCall,
122
128
  merkleTreeIds,
123
129
  mockTx,
124
- Comparator,
125
- SiblingPath,
126
- EncryptedLogHeader,
127
- EncryptedLogIncomingBody,
128
- EncryptedLogOutgoingBody,
130
+ TaggedLog,
131
+ L1NotePayload,
132
+ L1EventPayload,
129
133
  } from '@aztec/circuit-types';
130
134
  export { NodeInfo } from '@aztec/types/interfaces';
131
135
 
132
- export { ContractInstanceWithAddress, ContractClassWithId } from '@aztec/types/contracts';
136
+ export { ContractClassWithId, ContractInstanceWithAddress } from '@aztec/types/contracts';
133
137
 
134
138
  // TODO: These kinds of things have no place on our public api.
135
139
  // External devs will almost certainly have their own methods of doing these things.
136
140
  // If we want to use them in our own "aztec.js consuming code", import them from foundation as needed.
137
141
  export { encodeArguments } from '@aztec/foundation/abi';
142
+ export { toBigIntBE } from '@aztec/foundation/bigint-buffer';
138
143
  export { sha256 } from '@aztec/foundation/crypto';
144
+ export { makeFetch } from '@aztec/foundation/json-rpc/client';
139
145
  export { DebugLogger, createDebugLogger, onLog } from '@aztec/foundation/log';
140
146
  export { retry, retryUntil } from '@aztec/foundation/retry';
147
+ export { to2Fields, toBigInt } from '@aztec/foundation/serialize';
141
148
  export { sleep } from '@aztec/foundation/sleep';
142
149
  export { elapsed } from '@aztec/foundation/timer';
143
- export { fileURLToPath } from '@aztec/foundation/url';
144
- export { to2Fields, toBigInt } from '@aztec/foundation/serialize';
145
- export { toBigIntBE } from '@aztec/foundation/bigint-buffer';
146
- export { makeFetch } from '@aztec/foundation/json-rpc/client';
147
150
  export { FieldsOf } from '@aztec/foundation/types';
151
+ export { fileURLToPath } from '@aztec/foundation/url';
148
152
 
149
153
  export {
150
154
  DeployL1Contracts,
@@ -156,6 +160,6 @@ export {
156
160
  // Start of section that exports public api via granular api.
157
161
  // Here you *can* do `export *` as the granular api defacto exports things explicitly.
158
162
  // This entire index file will be deprecated at some point after we're satisfied.
159
- export * from './api/init.js';
160
163
  export * from './api/abi.js';
161
164
  export * from './api/fee.js';
165
+ export * from './api/init.js';
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  AuthWitness,
3
- EncryptedL2BlockL2Logs,
3
+ EncryptedNoteL2BlockL2Logs,
4
4
  ExtendedNote,
5
5
  ExtendedUnencryptedL2Log,
6
6
  L2Block,
@@ -54,8 +54,8 @@ export const createPXEClient = (url: string, fetch = makeFetch([1, 2, 3], false)
54
54
  TxExecutionRequest,
55
55
  TxHash,
56
56
  },
57
- { Tx, SimulatedTx, TxReceipt, EncryptedL2BlockL2Logs, UnencryptedL2BlockL2Logs, NullifierMembershipWitness },
57
+ { Tx, SimulatedTx, TxReceipt, EncryptedNoteL2BlockL2Logs, UnencryptedL2BlockL2Logs, NullifierMembershipWitness },
58
58
  false,
59
59
  'pxe',
60
60
  fetch,
61
- );
61
+ ) as PXE;
@@ -14,11 +14,11 @@ export async function waitForAccountSynch(
14
14
  address: CompleteAddress,
15
15
  { interval, timeout }: WaitOpts = DefaultWaitOpts,
16
16
  ): Promise<void> {
17
- const publicKey = address.publicKeys.masterIncomingViewingPublicKey.toString();
17
+ const accountAddress = address.address.toString();
18
18
  await retryUntil(
19
19
  async () => {
20
20
  const status = await pxe.getSyncStatus();
21
- const accountSynchedToBlock = status.notes[publicKey];
21
+ const accountSynchedToBlock = status.notes[accountAddress];
22
22
  if (typeof accountSynchedToBlock === 'undefined') {
23
23
  return false;
24
24
  } else {
@@ -22,11 +22,7 @@ export const computeAuthWitMessageHash = (caller: AztecAddress, chainId: Fr, ver
22
22
  action.to.toField(),
23
23
  chainId,
24
24
  version,
25
- computeInnerAuthWitHash([
26
- caller.toField(),
27
- action.functionData.selector.toField(),
28
- PackedValues.fromValues(action.args).hash,
29
- ]),
25
+ computeInnerAuthWitHash([caller.toField(), action.selector.toField(), PackedValues.fromValues(action.args).hash]),
30
26
  );
31
27
  };
32
28
  // docs:end:authwit_computeAuthWitMessageHash
@@ -265,11 +265,11 @@ export class AztecCheatCodes {
265
265
  public async warp(to: number): Promise<void> {
266
266
  const rollupContract = (await this.pxe.getNodeInfo()).l1ContractAddresses.rollupAddress;
267
267
  await this.eth.setNextBlockTimestamp(to);
268
- // also store this time on the rollup contract (slot 1 tracks `lastBlockTs`).
268
+ // also store this time on the rollup contract (slot 2 tracks `lastBlockTs`).
269
269
  // This is because when the sequencer executes public functions, it uses the timestamp stored in the rollup contract.
270
- await this.eth.store(rollupContract, 1n, BigInt(to));
271
- // also store this on slot 2 of the rollup contract (`lastWarpedBlockTs`) which tracks the last time warp was used.
272
270
  await this.eth.store(rollupContract, 2n, BigInt(to));
271
+ // also store this on slot 3 of the rollup contract (`lastWarpedBlockTs`) which tracks the last time warp was used.
272
+ await this.eth.store(rollupContract, 3n, BigInt(to));
273
273
  }
274
274
 
275
275
  /**
@@ -291,7 +291,11 @@ export class AztecCheatCodes {
291
291
  * @returns The notes stored at the given slot
292
292
  */
293
293
  public async loadPrivate(owner: AztecAddress, contract: AztecAddress, slot: Fr | bigint): Promise<Note[]> {
294
- const extendedNotes = await this.pxe.getNotes({ owner, contractAddress: contract, storageSlot: new Fr(slot) });
294
+ const extendedNotes = await this.pxe.getIncomingNotes({
295
+ owner,
296
+ contractAddress: contract,
297
+ storageSlot: new Fr(slot),
298
+ });
295
299
  return extendedNotes.map(extendedNote => extendedNote.note);
296
300
  }
297
301
  }
@@ -1,6 +1,7 @@
1
1
  import { type AuthWitness, type FunctionCall, type PXE, type TxExecutionRequest } from '@aztec/circuit-types';
2
2
  import { AztecAddress, CANONICAL_KEY_REGISTRY_ADDRESS, Fq, Fr, derivePublicKeyFromSecretKey } from '@aztec/circuits.js';
3
3
  import { type ABIParameterVisibility, type FunctionAbi, FunctionType } from '@aztec/foundation/abi';
4
+ import { AuthRegistryAddress } from '@aztec/protocol-contracts/auth-registry';
4
5
 
5
6
  import { type AccountInterface } from '../account/interface.js';
6
7
  import { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
@@ -80,11 +81,33 @@ export class AccountWallet extends BaseWallet {
80
81
  authorized: boolean,
81
82
  ): ContractFunctionInteraction {
82
83
  const message = this.getMessageHash(messageHashOrIntent);
83
- if (authorized) {
84
- return new ContractFunctionInteraction(this, this.getAddress(), this.getApprovePublicAuthwitAbi(), [message]);
85
- } else {
86
- return this.cancelAuthWit(message);
87
- }
84
+ return new ContractFunctionInteraction(this, AuthRegistryAddress, this.getSetAuthorizedAbi(), [
85
+ message,
86
+ authorized,
87
+ ]);
88
+ }
89
+
90
+ /**
91
+ * Returns a function interaction to cancel a message hash as authorized or revoked.
92
+ * @param messageHashOrIntent - The message or the caller and action to revoke
93
+ * @returns - A function interaction.
94
+ */
95
+ public cancelPublicAuthWit(
96
+ messageHashOrIntent:
97
+ | Fr
98
+ | Buffer
99
+ | {
100
+ /** The caller to approve */
101
+ caller: AztecAddress;
102
+ /** The action to approve */
103
+ action: ContractFunctionInteraction | FunctionCall;
104
+ /** The chain id to approve */
105
+ chainId?: Fr;
106
+ /** The version to approve */
107
+ version?: Fr;
108
+ },
109
+ ): ContractFunctionInteraction {
110
+ return this.setPublicAuthWit(messageHashOrIntent, false);
88
111
  }
89
112
 
90
113
  /**
@@ -152,17 +175,25 @@ export class AccountWallet extends BaseWallet {
152
175
  isValidInPublic: boolean;
153
176
  }> {
154
177
  const messageHash = this.getMessageHash(messageHashOrIntent);
178
+ const results = { isValidInPrivate: false, isValidInPublic: false };
179
+
180
+ // Check private
155
181
  const witness = await this.getAuthWitness(messageHash);
156
- const blockNumber = await this.getBlockNumber();
157
- const interaction = new ContractFunctionInteraction(this, target, this.getLookupValidityAbi(), [
158
- target,
159
- blockNumber,
160
- witness != undefined,
161
- messageHash,
162
- ]);
182
+ if (witness !== undefined) {
183
+ results.isValidInPrivate = (await new ContractFunctionInteraction(this, target, this.getLookupValidityAbi(), [
184
+ messageHash,
185
+ ]).simulate()) as boolean;
186
+ }
163
187
 
164
- const [isValidInPrivate, isValidInPublic] = (await interaction.simulate()) as [boolean, boolean];
165
- return { isValidInPrivate, isValidInPublic };
188
+ // check public
189
+ results.isValidInPublic = (await new ContractFunctionInteraction(
190
+ this,
191
+ AuthRegistryAddress,
192
+ this.getIsConsumableAbi(),
193
+ [target, messageHash],
194
+ ).simulate()) as boolean;
195
+
196
+ return results;
166
197
  }
167
198
 
168
199
  /**
@@ -224,9 +255,9 @@ export class AccountWallet extends BaseWallet {
224
255
  return this.getCompleteAddress().address;
225
256
  }
226
257
 
227
- private getApprovePublicAuthwitAbi(): FunctionAbi {
258
+ private getSetAuthorizedAbi(): FunctionAbi {
228
259
  return {
229
- name: 'approve_public_authwit',
260
+ name: 'set_authorized',
230
261
  isInitializer: false,
231
262
  functionType: FunctionType.PUBLIC,
232
263
  isInternal: true,
@@ -237,6 +268,11 @@ export class AccountWallet extends BaseWallet {
237
268
  type: { kind: 'field' },
238
269
  visibility: 'private' as ABIParameterVisibility,
239
270
  },
271
+ {
272
+ name: 'authorize',
273
+ type: { kind: 'boolean' },
274
+ visibility: 'private' as ABIParameterVisibility,
275
+ },
240
276
  ],
241
277
  returnTypes: [],
242
278
  };
@@ -267,29 +303,31 @@ export class AccountWallet extends BaseWallet {
267
303
  functionType: FunctionType.UNCONSTRAINED,
268
304
  isInternal: false,
269
305
  isStatic: false,
306
+ parameters: [{ name: 'message_hash', type: { kind: 'field' }, visibility: 'private' as ABIParameterVisibility }],
307
+ returnTypes: [{ kind: 'boolean' }],
308
+ };
309
+ }
310
+
311
+ private getIsConsumableAbi(): FunctionAbi {
312
+ return {
313
+ name: 'unconstrained_is_consumable',
314
+ isInitializer: false,
315
+ functionType: FunctionType.UNCONSTRAINED,
316
+ isInternal: false,
317
+ isStatic: false,
270
318
  parameters: [
271
319
  {
272
- name: 'myself',
320
+ name: 'address',
273
321
  type: {
322
+ fields: [{ name: 'inner', type: { kind: 'field' } }],
274
323
  kind: 'struct',
275
324
  path: 'authwit::aztec::protocol_types::address::aztec_address::AztecAddress',
276
- fields: [{ name: 'inner', type: { kind: 'field' } }],
277
325
  },
278
326
  visibility: 'private' as ABIParameterVisibility,
279
327
  },
280
- {
281
- name: 'block_number',
282
- type: { kind: 'integer', sign: 'unsigned', width: 32 },
283
- visibility: 'private' as ABIParameterVisibility,
284
- },
285
- {
286
- name: 'check_private',
287
- type: { kind: 'boolean' },
288
- visibility: 'private' as ABIParameterVisibility,
289
- },
290
328
  { name: 'message_hash', type: { kind: 'field' }, visibility: 'private' as ABIParameterVisibility },
291
329
  ],
292
- returnTypes: [{ kind: 'array', length: 2, type: { kind: 'boolean' } }],
330
+ returnTypes: [{ kind: 'boolean' }],
293
331
  };
294
332
  }
295
333
 
@@ -1,12 +1,15 @@
1
1
  import {
2
2
  type AuthWitness,
3
+ type EventMetadata,
3
4
  type ExtendedNote,
4
5
  type FunctionCall,
5
6
  type GetUnencryptedLogsResponse,
7
+ type IncomingNotesFilter,
6
8
  type L2Block,
7
9
  type LogFilter,
8
- type NoteFilter,
10
+ type OutgoingNotesFilter,
9
11
  type PXE,
12
+ type PXEInfo,
10
13
  type SimulatedTx,
11
14
  type SyncStatus,
12
15
  type Tx,
@@ -15,7 +18,15 @@ import {
15
18
  type TxHash,
16
19
  type TxReceipt,
17
20
  } from '@aztec/circuit-types';
18
- import { type AztecAddress, type CompleteAddress, type Fq, type Fr, type PartialAddress } from '@aztec/circuits.js';
21
+ import { type NoteProcessorStats } from '@aztec/circuit-types/stats';
22
+ import {
23
+ type AztecAddress,
24
+ type CompleteAddress,
25
+ type Fq,
26
+ type Fr,
27
+ type PartialAddress,
28
+ type Point,
29
+ } from '@aztec/circuits.js';
19
30
  import { type ContractArtifact } from '@aztec/foundation/abi';
20
31
  import { type ContractClassWithId, type ContractInstanceWithAddress } from '@aztec/types/contracts';
21
32
  import { type NodeInfo } from '@aztec/types/interfaces';
@@ -65,6 +76,9 @@ export abstract class BaseWallet implements Wallet {
65
76
  getContractClass(id: Fr): Promise<ContractClassWithId | undefined> {
66
77
  return this.pxe.getContractClass(id);
67
78
  }
79
+ getContractArtifact(id: Fr): Promise<ContractArtifact | undefined> {
80
+ return this.pxe.getContractArtifact(id);
81
+ }
68
82
  addCapsule(capsule: Fr[]): Promise<void> {
69
83
  return this.pxe.addCapsule(capsule);
70
84
  }
@@ -116,8 +130,11 @@ export abstract class BaseWallet implements Wallet {
116
130
  getTxReceipt(txHash: TxHash): Promise<TxReceipt> {
117
131
  return this.pxe.getTxReceipt(txHash);
118
132
  }
119
- getNotes(filter: NoteFilter): Promise<ExtendedNote[]> {
120
- return this.pxe.getNotes(filter);
133
+ getIncomingNotes(filter: IncomingNotesFilter): Promise<ExtendedNote[]> {
134
+ return this.pxe.getIncomingNotes(filter);
135
+ }
136
+ getOutgoingNotes(filter: OutgoingNotesFilter): Promise<ExtendedNote[]> {
137
+ return this.pxe.getOutgoingNotes(filter);
121
138
  }
122
139
  // TODO(#4956): Un-expose this
123
140
  getNoteNonces(note: ExtendedNote): Promise<Fr[]> {
@@ -129,6 +146,9 @@ export abstract class BaseWallet implements Wallet {
129
146
  addNote(note: ExtendedNote): Promise<void> {
130
147
  return this.pxe.addNote(note);
131
148
  }
149
+ addNullifiedNote(note: ExtendedNote): Promise<void> {
150
+ return this.pxe.addNullifiedNote(note);
151
+ }
132
152
  getBlock(number: number): Promise<L2Block | undefined> {
133
153
  return this.pxe.getBlock(number);
134
154
  }
@@ -158,6 +178,9 @@ export abstract class BaseWallet implements Wallet {
158
178
  getSyncStatus(): Promise<SyncStatus> {
159
179
  return this.pxe.getSyncStatus();
160
180
  }
181
+ getSyncStats(): Promise<{ [key: string]: NoteProcessorStats }> {
182
+ return this.pxe.getSyncStats();
183
+ }
161
184
  addAuthWitness(authWitness: AuthWitness) {
162
185
  return this.pxe.addAuthWitness(authWitness);
163
186
  }
@@ -170,4 +193,15 @@ export abstract class BaseWallet implements Wallet {
170
193
  isContractPubliclyDeployed(address: AztecAddress): Promise<boolean> {
171
194
  return this.pxe.isContractPubliclyDeployed(address);
172
195
  }
196
+ getPXEInfo(): Promise<PXEInfo> {
197
+ return this.pxe.getPXEInfo();
198
+ }
199
+ getEvents<T>(
200
+ from: number,
201
+ limit: number,
202
+ eventMetadata: EventMetadata<T>,
203
+ ivpk: Point = this.getCompleteAddress().publicKeys.masterIncomingViewingPublicKey,
204
+ ): Promise<T[]> {
205
+ return this.pxe.getEvents(from, limit, eventMetadata, ivpk);
206
+ }
173
207
  }