@aztec/aztec.js 0.67.1 → 0.68.1

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 (67) 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/contract_function_interaction.d.ts.map +1 -1
  7. package/dest/contract/contract_function_interaction.js +18 -8
  8. package/dest/contract/get_gas_limits.d.ts +12 -2
  9. package/dest/contract/get_gas_limits.d.ts.map +1 -1
  10. package/dest/contract/get_gas_limits.js +1 -1
  11. package/dest/contract/index.d.ts +6 -6
  12. package/dest/contract/index.d.ts.map +1 -1
  13. package/dest/contract/index.js +7 -7
  14. package/dest/fee/fee_juice_payment_method.d.ts +1 -1
  15. package/dest/fee/fee_juice_payment_method.js +2 -2
  16. package/dest/fee/fee_juice_payment_method_with_claim.d.ts.map +1 -1
  17. package/dest/fee/fee_juice_payment_method_with_claim.js +4 -3
  18. package/dest/fee/fee_payment_method.d.ts +1 -1
  19. package/dest/fee/fee_payment_method.d.ts.map +1 -1
  20. package/dest/fee/no_fee_payment_method.d.ts +1 -1
  21. package/dest/fee/no_fee_payment_method.js +2 -2
  22. package/dest/fee/private_fee_payment_method.d.ts +2 -17
  23. package/dest/fee/private_fee_payment_method.d.ts.map +1 -1
  24. package/dest/fee/private_fee_payment_method.js +38 -17
  25. package/dest/fee/public_fee_payment_method.d.ts +2 -9
  26. package/dest/fee/public_fee_payment_method.d.ts.map +1 -1
  27. package/dest/fee/public_fee_payment_method.js +37 -11
  28. package/dest/index.d.ts +5 -4
  29. package/dest/index.d.ts.map +1 -1
  30. package/dest/index.js +7 -5
  31. package/dest/rpc_clients/pxe_client.d.ts +1 -1
  32. package/dest/rpc_clients/pxe_client.d.ts.map +1 -1
  33. package/dest/rpc_clients/pxe_client.js +2 -2
  34. package/dest/utils/anvil_test_watcher.d.ts +3 -1
  35. package/dest/utils/anvil_test_watcher.d.ts.map +1 -1
  36. package/dest/utils/anvil_test_watcher.js +5 -3
  37. package/dest/utils/cheat_codes.d.ts +2 -0
  38. package/dest/utils/cheat_codes.d.ts.map +1 -1
  39. package/dest/utils/cheat_codes.js +14 -6
  40. package/dest/wallet/base_wallet.d.ts +4 -5
  41. package/dest/wallet/base_wallet.d.ts.map +1 -1
  42. package/dest/wallet/base_wallet.js +9 -12
  43. package/dest/wallet/index.d.ts.map +1 -1
  44. package/dest/wallet/index.js +2 -2
  45. package/package.json +16 -13
  46. package/{dest/api/aztec_address.d.ts → src/api/addresses.ts} +1 -1
  47. package/src/contract/base_contract_interaction.ts +16 -3
  48. package/src/contract/contract_function_interaction.ts +22 -8
  49. package/src/contract/get_gas_limits.ts +15 -2
  50. package/src/contract/index.ts +10 -6
  51. package/src/fee/fee_juice_payment_method.ts +1 -1
  52. package/src/fee/fee_juice_payment_method_with_claim.ts +3 -2
  53. package/src/fee/fee_payment_method.ts +1 -1
  54. package/src/fee/no_fee_payment_method.ts +1 -1
  55. package/src/fee/private_fee_payment_method.ts +46 -16
  56. package/src/fee/public_fee_payment_method.ts +45 -10
  57. package/src/index.ts +4 -20
  58. package/src/rpc_clients/pxe_client.ts +1 -1
  59. package/src/utils/anvil_test_watcher.ts +4 -1
  60. package/src/utils/cheat_codes.ts +14 -5
  61. package/src/wallet/base_wallet.ts +16 -10
  62. package/src/wallet/index.ts +3 -1
  63. package/dest/api/aztec_address.d.ts.map +0 -1
  64. package/dest/api/aztec_address.js +0 -2
  65. package/dest/main.js +0 -2
  66. package/dest/main.js.LICENSE.txt +0 -23
  67. package/src/api/aztec_address.ts +0 -1
package/package.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "@aztec/aztec.js",
3
3
  "homepage": "https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/aztec.js",
4
- "version": "0.67.1",
4
+ "version": "0.68.1",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": "./dest/index.js",
8
8
  "./interfaces/pxe": "./dest/api/interfaces/pxe.js",
9
9
  "./abi": "./dest/api/abi.js",
10
10
  "./account": "./dest/api/account.js",
11
- "./aztec_address": "./dest/api/aztec_address.js",
11
+ "./addresses": "./dest/api/addresses.js",
12
+ "./contracts": "./dest/contract/index.js",
12
13
  "./deployment": "./dest/api/deployment.js",
13
14
  "./entrypoint": "./dest/api/entrypoint.js",
14
15
  "./eth_address": "./dest/api/eth_address.js",
@@ -17,8 +18,10 @@
17
18
  "./fields": "./dest/api/fields.js",
18
19
  "./init": "./dest/api/init.js",
19
20
  "./log_id": "./dest/api/log_id.js",
21
+ "./rpc": "./dest/rpc_clients/index.js",
20
22
  "./tx_hash": "./dest/api/tx_hash.js",
21
- "./wallet": "./dest/api/wallet.js"
23
+ "./wallet": "./dest/api/wallet.js",
24
+ "./utils": "./dest/utils/index.js"
22
25
  },
23
26
  "typedocOptions": {
24
27
  "entryPoints": [
@@ -35,7 +38,7 @@
35
38
  "clean": "rm -rf ./dest .tsbuildinfo ./src/account_contract/artifacts",
36
39
  "formatting": "run -T prettier --check ./src && run -T eslint ./src",
37
40
  "formatting:fix": "run -T eslint --fix ./src && run -T prettier -w ./src",
38
- "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests"
41
+ "test": "HARDWARE_CONCURRENCY=${HARDWARE_CONCURRENCY:-16} RAYON_NUM_THREADS=${RAYON_NUM_THREADS:-4} NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
39
42
  },
40
43
  "inherits": [
41
44
  "../package.common.json",
@@ -68,9 +71,9 @@
68
71
  ],
69
72
  "reporters": [
70
73
  [
71
- "default",
74
+ "jest-silent-reporter",
72
75
  {
73
- "summaryThreshold": 9999
76
+ "useDots": true
74
77
  }
75
78
  ]
76
79
  ],
@@ -80,13 +83,13 @@
80
83
  ]
81
84
  },
82
85
  "dependencies": {
83
- "@aztec/circuit-types": "0.67.1",
84
- "@aztec/circuits.js": "0.67.1",
85
- "@aztec/ethereum": "0.67.1",
86
- "@aztec/foundation": "0.67.1",
87
- "@aztec/l1-artifacts": "0.67.1",
88
- "@aztec/protocol-contracts": "0.67.1",
89
- "@aztec/types": "0.67.1",
86
+ "@aztec/circuit-types": "0.68.1",
87
+ "@aztec/circuits.js": "0.68.1",
88
+ "@aztec/ethereum": "0.68.1",
89
+ "@aztec/foundation": "0.68.1",
90
+ "@aztec/l1-artifacts": "0.68.1",
91
+ "@aztec/protocol-contracts": "0.68.1",
92
+ "@aztec/types": "0.68.1",
90
93
  "axios": "^1.7.2",
91
94
  "tslib": "^2.4.0",
92
95
  "viem": "^2.7.15"
@@ -1,2 +1,2 @@
1
1
  export { AztecAddress } from '@aztec/foundation/aztec-address';
2
- //# sourceMappingURL=aztec_address.d.ts.map
2
+ export { CompleteAddress } from '@aztec/circuits.js';
@@ -91,7 +91,13 @@ export abstract class BaseContractInteraction {
91
91
  opts?: Omit<SendMethodOptions, 'estimateGas' | 'skipPublicSimulation'>,
92
92
  ): Promise<Pick<GasSettings, 'gasLimits' | 'teardownGasLimits'>> {
93
93
  const txRequest = await this.create({ ...opts, fee: { ...opts?.fee, estimateGas: false } });
94
- const simulationResult = await this.wallet.simulateTx(txRequest, true);
94
+ const simulationResult = await this.wallet.simulateTx(
95
+ txRequest,
96
+ true /*simulatePublic*/,
97
+ undefined /* msgSender */,
98
+ undefined /* skipTxValidation */,
99
+ false /* enforceFeePayment */,
100
+ );
95
101
  const { totalGas: gasLimits, teardownGas: teardownGasLimits } = getGasLimits(
96
102
  simulationResult,
97
103
  opts?.fee?.estimatedGasPadding,
@@ -122,17 +128,24 @@ export abstract class BaseContractInteraction {
122
128
  const defaultFeeOptions = await this.getDefaultFeeOptions(request.fee);
123
129
  const paymentMethod = defaultFeeOptions.paymentMethod;
124
130
  const maxFeesPerGas = defaultFeeOptions.gasSettings.maxFeesPerGas;
131
+ const maxPriorityFeesPerGas = defaultFeeOptions.gasSettings.maxPriorityFeesPerGas;
125
132
 
126
133
  let gasSettings = defaultFeeOptions.gasSettings;
127
134
  if (request.fee?.estimateGas) {
128
135
  const feeForEstimation: FeeOptions = { paymentMethod, gasSettings };
129
136
  const txRequest = await this.wallet.createTxExecutionRequest({ ...request, fee: feeForEstimation });
130
- const simulationResult = await this.wallet.simulateTx(txRequest, true);
137
+ const simulationResult = await this.wallet.simulateTx(
138
+ txRequest,
139
+ true /*simulatePublic*/,
140
+ undefined /* msgSender */,
141
+ undefined /* skipTxValidation */,
142
+ false /* enforceFeePayment */,
143
+ );
131
144
  const { totalGas: gasLimits, teardownGas: teardownGasLimits } = getGasLimits(
132
145
  simulationResult,
133
146
  request.fee?.estimatedGasPadding,
134
147
  );
135
- gasSettings = GasSettings.from({ maxFeesPerGas, gasLimits, teardownGasLimits });
148
+ gasSettings = GasSettings.from({ maxFeesPerGas, maxPriorityFeesPerGas, gasLimits, teardownGasLimits });
136
149
  this.log.verbose(
137
150
  `Estimated gas limits for tx: DA=${gasLimits.daGas} L2=${gasLimits.l2Gas} teardownDA=${teardownGasLimits.daGas} teardownL2=${teardownGasLimits.l2Gas}`,
138
151
  );
@@ -103,13 +103,20 @@ export class ContractFunctionInteraction extends BaseContractInteraction {
103
103
  const txRequest = await this.create();
104
104
  const simulatedTx = await this.wallet.simulateTx(txRequest, true, options?.from, options?.skipTxValidation);
105
105
 
106
- // As account entrypoints are private, for private functions we retrieve the return values from the first nested call
107
- // since we're interested in the first set of values AFTER the account entrypoint
108
- // For public functions we retrieve the first values directly from the public output.
109
- const rawReturnValues =
110
- this.functionDao.functionType == FunctionType.PRIVATE
111
- ? simulatedTx.getPrivateReturnValues().nested?.[0].values
112
- : simulatedTx.getPublicReturnValues()?.[0].values;
106
+ let rawReturnValues;
107
+ if (this.functionDao.functionType == FunctionType.PRIVATE) {
108
+ if (simulatedTx.getPrivateReturnValues().nested.length > 0) {
109
+ // The function invoked is private and it was called via an account contract
110
+ // TODO(#10631): There is a bug here: this branch might be triggered when there is no-account contract as well
111
+ rawReturnValues = simulatedTx.getPrivateReturnValues().nested[0].values;
112
+ } else {
113
+ // The function invoked is private and it was called directly (without account contract)
114
+ rawReturnValues = simulatedTx.getPrivateReturnValues().values;
115
+ }
116
+ } else {
117
+ // For public functions we retrieve the first values directly from the public output.
118
+ rawReturnValues = simulatedTx.getPublicReturnValues()?.[0].values;
119
+ }
113
120
 
114
121
  return rawReturnValues ? decodeFromAbi(this.functionDao.returnTypes, rawReturnValues) : [];
115
122
  }
@@ -126,7 +133,14 @@ export class ContractFunctionInteraction extends BaseContractInteraction {
126
133
  }
127
134
 
128
135
  const txRequest = await this.create();
129
- const simulatedTx = await this.wallet.simulateTx(txRequest, true, options?.from, options?.skipTxValidation, true);
136
+ const simulatedTx = await this.wallet.simulateTx(
137
+ txRequest,
138
+ true,
139
+ options?.from,
140
+ options?.skipTxValidation,
141
+ undefined,
142
+ true,
143
+ );
130
144
 
131
145
  const rawReturnValues =
132
146
  this.functionDao.functionType == FunctionType.PRIVATE
@@ -1,11 +1,24 @@
1
- import { type GasUsed, type TxSimulationResult } from '@aztec/circuit-types';
1
+ import { type TxSimulationResult } from '@aztec/circuit-types';
2
+ import { type Gas } from '@aztec/circuits.js';
2
3
 
3
4
  /**
4
5
  * Returns suggested total and teardown gas limits for a simulated tx.
5
6
  * Note that public gas usage is only accounted for if the publicOutput is present.
6
7
  * @param pad - Percentage to pad the suggested gas limits by, (as decimal, e.g., 0.10 for 10%).
7
8
  */
8
- export function getGasLimits(simulationResult: TxSimulationResult, pad = 0.1): GasUsed {
9
+ export function getGasLimits(
10
+ simulationResult: TxSimulationResult,
11
+ pad = 0.1,
12
+ ): {
13
+ /**
14
+ * Total gas used across private and public
15
+ */
16
+ totalGas: Gas;
17
+ /**
18
+ * Teardown gas used
19
+ */
20
+ teardownGas: Gas;
21
+ } {
9
22
  return {
10
23
  totalGas: simulationResult.gasUsed.totalGas.mul(1 + pad),
11
24
  teardownGas: simulationResult.gasUsed.teardownGas.mul(1 + pad),
@@ -35,10 +35,14 @@
35
35
  *
36
36
  * @packageDocumentation
37
37
  */
38
- export * from './contract.js';
39
- export * from './contract_function_interaction.js';
40
- export * from './sent_tx.js';
41
- export * from './contract_base.js';
42
- export * from './batch_call.js';
38
+ export { Contract } from './contract.js';
39
+ export {
40
+ ContractFunctionInteraction,
41
+ type ProfileResult,
42
+ type SendMethodOptions,
43
+ } from './contract_function_interaction.js';
44
+ export { DefaultWaitOpts, SentTx, type WaitOpts } from './sent_tx.js';
45
+ export { ContractBase, type ContractMethod, type ContractNotes, type ContractStorageLayout } from './contract_base.js';
46
+ export { BatchCall } from './batch_call.js';
43
47
  export { type DeployOptions, DeployMethod } from './deploy_method.js';
44
- export * from './deploy_sent_tx.js';
48
+ export { DeploySentTx } from './deploy_sent_tx.js';
@@ -11,7 +11,7 @@ export class FeeJuicePaymentMethod implements FeePaymentMethod {
11
11
  constructor(protected sender: AztecAddress) {}
12
12
 
13
13
  getAsset() {
14
- return ProtocolContractAddress.FeeJuice;
14
+ return Promise.resolve(ProtocolContractAddress.FeeJuice);
15
15
  }
16
16
 
17
17
  getFunctionCalls(): Promise<FunctionCall[]> {
@@ -1,7 +1,8 @@
1
1
  import { type FunctionCall } from '@aztec/circuit-types';
2
2
  import { type AztecAddress, Fr, FunctionSelector } from '@aztec/circuits.js';
3
3
  import { FunctionType } from '@aztec/foundation/abi';
4
- import { ProtocolContractAddress, ProtocolContractArtifact } from '@aztec/protocol-contracts';
4
+ import { ProtocolContractAddress } from '@aztec/protocol-contracts';
5
+ import { getCanonicalFeeJuice } from '@aztec/protocol-contracts/fee-juice';
5
6
 
6
7
  import { type L2AmountClaim } from '../utils/portal_manager.js';
7
8
  import { FeeJuicePaymentMethod } from './fee_juice_payment_method.js';
@@ -23,7 +24,7 @@ export class FeeJuicePaymentMethodWithClaim extends FeeJuicePaymentMethod {
23
24
  */
24
25
  override getFunctionCalls(): Promise<FunctionCall[]> {
25
26
  const selector = FunctionSelector.fromNameAndParameters(
26
- ProtocolContractArtifact.FeeJuice.functions.find(f => f.name === 'claim')!,
27
+ getCanonicalFeeJuice().artifact.functions.find(f => f.name === 'claim')!,
27
28
  );
28
29
 
29
30
  return Promise.resolve([
@@ -7,7 +7,7 @@ import { type AztecAddress } from '@aztec/foundation/aztec-address';
7
7
  */
8
8
  export interface FeePaymentMethod {
9
9
  /** The asset used to pay the fee. */
10
- getAsset(): AztecAddress;
10
+ getAsset(): Promise<AztecAddress>;
11
11
  /**
12
12
  * Creates a function call to pay the fee in the given asset.
13
13
  * @param gasSettings - The gas limits and max fees.
@@ -10,7 +10,7 @@ export class NoFeePaymentMethod implements FeePaymentMethod {
10
10
  constructor() {}
11
11
 
12
12
  getAsset() {
13
- return AztecAddress.ZERO;
13
+ return Promise.resolve(AztecAddress.ZERO);
14
14
  }
15
15
 
16
16
  getFunctionCalls(): Promise<FunctionCall[]> {
@@ -5,17 +5,17 @@ import { type AztecAddress } from '@aztec/foundation/aztec-address';
5
5
  import { Fr } from '@aztec/foundation/fields';
6
6
 
7
7
  import { type Wallet } from '../account/wallet.js';
8
+ import { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
9
+ import { SignerlessWallet } from '../wallet/signerless_wallet.js';
8
10
  import { type FeePaymentMethod } from './fee_payment_method.js';
9
11
 
10
12
  /**
11
13
  * Holds information about how the fee for a transaction is to be paid.
12
14
  */
13
15
  export class PrivateFeePaymentMethod implements FeePaymentMethod {
16
+ private assetPromise: Promise<AztecAddress> | null = null;
17
+
14
18
  constructor(
15
- /**
16
- * The asset used to pay the fee.
17
- */
18
- private asset: AztecAddress,
19
19
  /**
20
20
  * Address which will hold the fee payment.
21
21
  */
@@ -26,11 +26,6 @@ export class PrivateFeePaymentMethod implements FeePaymentMethod {
26
26
  */
27
27
  private wallet: Wallet,
28
28
 
29
- /**
30
- * Address that the FPC sends notes it receives to.
31
- */
32
- private feeRecipient: AztecAddress,
33
-
34
29
  /**
35
30
  * If true, the max fee will be set to 1.
36
31
  * TODO(#7694): Remove this param once the lacking feature in TXE is implemented.
@@ -42,8 +37,43 @@ export class PrivateFeePaymentMethod implements FeePaymentMethod {
42
37
  * The asset used to pay the fee.
43
38
  * @returns The asset used to pay the fee.
44
39
  */
45
- getAsset() {
46
- return this.asset;
40
+ getAsset(): Promise<AztecAddress> {
41
+ if (!this.assetPromise) {
42
+ // We use signer-less wallet because this function could be triggered before the associated account is deployed.
43
+ const signerlessWallet = new SignerlessWallet(this.wallet);
44
+
45
+ const interaction = new ContractFunctionInteraction(
46
+ signerlessWallet,
47
+ this.paymentContract,
48
+ {
49
+ name: 'get_accepted_asset',
50
+ functionType: FunctionType.PRIVATE,
51
+ isInternal: false,
52
+ isStatic: false,
53
+ parameters: [],
54
+ returnTypes: [
55
+ {
56
+ kind: 'struct',
57
+ path: 'authwit::aztec::protocol_types::address::aztec_address::AztecAddress',
58
+ fields: [
59
+ {
60
+ name: 'inner',
61
+ type: {
62
+ kind: 'field',
63
+ },
64
+ },
65
+ ],
66
+ },
67
+ ],
68
+ errorTypes: {},
69
+ isInitializer: false,
70
+ },
71
+ [],
72
+ );
73
+
74
+ this.assetPromise = interaction.simulate();
75
+ }
76
+ return this.assetPromise!;
47
77
  }
48
78
 
49
79
  getFeePayer(): Promise<AztecAddress> {
@@ -65,11 +95,11 @@ export class PrivateFeePaymentMethod implements FeePaymentMethod {
65
95
  caller: this.paymentContract,
66
96
  action: {
67
97
  name: 'setup_refund',
68
- args: [this.feeRecipient.toField(), this.wallet.getAddress().toField(), maxFee, nonce],
69
- selector: FunctionSelector.fromSignature('setup_refund((Field),(Field),Field,Field)'),
98
+ args: [this.wallet.getAddress().toField(), maxFee, nonce],
99
+ selector: FunctionSelector.fromSignature('setup_refund((Field),Field,Field)'),
70
100
  type: FunctionType.PRIVATE,
71
101
  isStatic: false,
72
- to: this.asset,
102
+ to: await this.getAsset(),
73
103
  returnTypes: [],
74
104
  },
75
105
  });
@@ -78,10 +108,10 @@ export class PrivateFeePaymentMethod implements FeePaymentMethod {
78
108
  {
79
109
  name: 'fee_entrypoint_private',
80
110
  to: this.paymentContract,
81
- selector: FunctionSelector.fromSignature('fee_entrypoint_private(Field,(Field),Field)'),
111
+ selector: FunctionSelector.fromSignature('fee_entrypoint_private(Field,Field)'),
82
112
  type: FunctionType.PRIVATE,
83
113
  isStatic: false,
84
- args: [maxFee, this.asset.toField(), nonce],
114
+ args: [maxFee, nonce],
85
115
  returnTypes: [],
86
116
  },
87
117
  ];
@@ -4,18 +4,18 @@ 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
 
7
+ import { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
7
8
  import { type AccountWallet } from '../wallet/account_wallet.js';
9
+ import { SignerlessWallet } from '../wallet/signerless_wallet.js';
8
10
  import { type FeePaymentMethod } from './fee_payment_method.js';
9
11
 
10
12
  /**
11
13
  * Holds information about how the fee for a transaction is to be paid.
12
14
  */
13
15
  export class PublicFeePaymentMethod implements FeePaymentMethod {
16
+ private assetPromise: Promise<AztecAddress> | null = null;
17
+
14
18
  constructor(
15
- /**
16
- * The asset used to pay the fee.
17
- */
18
- protected asset: AztecAddress,
19
19
  /**
20
20
  * Address which will hold the fee payment.
21
21
  */
@@ -30,8 +30,43 @@ export class PublicFeePaymentMethod implements FeePaymentMethod {
30
30
  * The asset used to pay the fee.
31
31
  * @returns The asset used to pay the fee.
32
32
  */
33
- getAsset() {
34
- return this.asset;
33
+ getAsset(): Promise<AztecAddress> {
34
+ if (!this.assetPromise) {
35
+ // We use signer-less wallet because this function could be triggered before the associated account is deployed.
36
+ const signerlessWallet = new SignerlessWallet(this.wallet);
37
+
38
+ const interaction = new ContractFunctionInteraction(
39
+ signerlessWallet,
40
+ this.paymentContract,
41
+ {
42
+ name: 'get_accepted_asset',
43
+ functionType: FunctionType.PRIVATE,
44
+ isInternal: false,
45
+ isStatic: false,
46
+ parameters: [],
47
+ returnTypes: [
48
+ {
49
+ kind: 'struct',
50
+ path: 'authwit::aztec::protocol_types::address::aztec_address::AztecAddress',
51
+ fields: [
52
+ {
53
+ name: 'inner',
54
+ type: {
55
+ kind: 'field',
56
+ },
57
+ },
58
+ ],
59
+ },
60
+ ],
61
+ errorTypes: {},
62
+ isInitializer: false,
63
+ },
64
+ [],
65
+ );
66
+
67
+ this.assetPromise = interaction.simulate();
68
+ }
69
+ return this.assetPromise!;
35
70
  }
36
71
 
37
72
  getFeePayer(): Promise<AztecAddress> {
@@ -43,7 +78,7 @@ export class PublicFeePaymentMethod implements FeePaymentMethod {
43
78
  * @param gasSettings - The gas settings.
44
79
  * @returns The function call to pay the fee.
45
80
  */
46
- getFunctionCalls(gasSettings: GasSettings): Promise<FunctionCall[]> {
81
+ async getFunctionCalls(gasSettings: GasSettings): Promise<FunctionCall[]> {
47
82
  const nonce = Fr.random();
48
83
  const maxFee = gasSettings.getFeeLimit();
49
84
 
@@ -58,7 +93,7 @@ export class PublicFeePaymentMethod implements FeePaymentMethod {
58
93
  selector: FunctionSelector.fromSignature('transfer_in_public((Field),(Field),Field,Field)'),
59
94
  type: FunctionType.PUBLIC,
60
95
  isStatic: false,
61
- to: this.asset,
96
+ to: await this.getAsset(),
62
97
  returnTypes: [],
63
98
  },
64
99
  },
@@ -68,10 +103,10 @@ export class PublicFeePaymentMethod implements FeePaymentMethod {
68
103
  {
69
104
  name: 'fee_entrypoint_public',
70
105
  to: this.paymentContract,
71
- selector: FunctionSelector.fromSignature('fee_entrypoint_public(Field,(Field),Field)'),
106
+ selector: FunctionSelector.fromSignature('fee_entrypoint_public(Field,Field)'),
72
107
  type: FunctionType.PRIVATE,
73
108
  isStatic: false,
74
- args: [maxFee, this.asset.toField(), nonce],
109
+ args: [maxFee, nonce],
75
110
  returnTypes: [],
76
111
  },
77
112
  ]);
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
 
@@ -79,7 +62,6 @@ export { AccountWallet, AccountWalletWithSecretKey, SignerlessWallet, type Walle
79
62
  // // TODO https://github.com/AztecProtocol/aztec-packages/issues/2632 --> FunctionSelector might not need to be exposed
80
63
  // // here once the issue is resolved.
81
64
  export {
82
- AztecAddress,
83
65
  ContractClassWithId,
84
66
  ContractInstanceWithAddress,
85
67
  EthAddress,
@@ -110,7 +92,6 @@ export {
110
92
  AuthWitness,
111
93
  Body,
112
94
  Comparator,
113
- CompleteAddress,
114
95
  ContractClass2BlockL2Logs,
115
96
  EncryptedLogPayload,
116
97
  EpochProofQuote,
@@ -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,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,6 +1,7 @@
1
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
+ import { type TestDateProvider } from '@aztec/foundation/timer';
4
5
  import { RollupAbi } from '@aztec/l1-artifacts';
5
6
 
6
7
  import { type GetContractReturnType, type HttpTransport, type PublicClient, getAddress, getContract } from 'viem';
@@ -24,6 +25,7 @@ export class AnvilTestWatcher {
24
25
  private cheatcodes: EthCheatCodes,
25
26
  rollupAddress: EthAddress,
26
27
  publicClient: PublicClient<HttpTransport, chains.Chain>,
28
+ private dateProvider?: TestDateProvider,
27
29
  ) {
28
30
  this.rollup = getContract({
29
31
  address: getAddress(rollupAddress.toString()),
@@ -46,7 +48,7 @@ export class AnvilTestWatcher {
46
48
  const isAutoMining = await this.cheatcodes.isAutoMining();
47
49
 
48
50
  if (isAutoMining) {
49
- this.filledRunningPromise = new RunningPromise(() => this.mineIfSlotFilled(), 1000);
51
+ this.filledRunningPromise = new RunningPromise(() => this.mineIfSlotFilled(), this.logger, 1000);
50
52
  this.filledRunningPromise.start();
51
53
  this.logger.info(`Watcher started for rollup at ${this.rollup.address}`);
52
54
  } else {
@@ -69,6 +71,7 @@ export class AnvilTestWatcher {
69
71
  const timestamp = await this.rollup.read.getTimestampForSlot([currentSlot + 1n]);
70
72
  try {
71
73
  await this.cheatcodes.warp(Number(timestamp));
74
+ this.dateProvider?.setTime(Number(timestamp) * 1000);
72
75
  } catch (e) {
73
76
  this.logger.error(`Failed to warp to timestamp ${timestamp}: ${e}`);
74
77
  }
@@ -108,8 +108,17 @@ export class RollupCheatCodes {
108
108
  const slotsUntilNextEpoch = epochDuration - (slot % epochDuration) + 1n;
109
109
  const timeToNextEpoch = slotsUntilNextEpoch * slotDuration;
110
110
  const l1Timestamp = BigInt((await this.client.getBlock()).timestamp);
111
- await this.ethCheatCodes.warp(Number(l1Timestamp + timeToNextEpoch));
112
- this.logger.verbose(`Advanced to next epoch`);
111
+ await this.ethCheatCodes.warp(Number(l1Timestamp + timeToNextEpoch), true);
112
+ this.logger.warn(`Advanced to next epoch`);
113
+ }
114
+
115
+ /** Warps time in L1 until the beginning of the next slot. */
116
+ public async advanceToNextSlot() {
117
+ const currentSlot = await this.getSlot();
118
+ const timestamp = await this.rollup.read.getTimestampForSlot([currentSlot + 1n]);
119
+ await this.ethCheatCodes.warp(Number(timestamp));
120
+ this.logger.warn(`Advanced to slot ${currentSlot + 1n}`);
121
+ return [timestamp, currentSlot + 1n];
113
122
  }
114
123
 
115
124
  /**
@@ -120,9 +129,9 @@ export class RollupCheatCodes {
120
129
  const l1Timestamp = (await this.client.getBlock()).timestamp;
121
130
  const slotDuration = await this.rollup.read.SLOT_DURATION();
122
131
  const timeToWarp = BigInt(howMany) * slotDuration;
123
- await this.ethCheatCodes.warp(l1Timestamp + timeToWarp);
132
+ await this.ethCheatCodes.warp(l1Timestamp + timeToWarp, true);
124
133
  const [slot, epoch] = await Promise.all([this.getSlot(), this.getEpoch()]);
125
- this.logger.verbose(`Advanced ${howMany} slots up to slot ${slot} in epoch ${epoch}`);
134
+ this.logger.warn(`Advanced ${howMany} slots up to slot ${slot} in epoch ${epoch}`);
126
135
  }
127
136
 
128
137
  /** Returns the current proof claim (if any) */
@@ -163,7 +172,7 @@ export class RollupCheatCodes {
163
172
 
164
173
  await this.asOwner(async account => {
165
174
  await this.rollup.write.setAssumeProvenThroughBlockNumber([blockNumber], { account, chain: this.client.chain });
166
- this.logger.verbose(`Marked ${blockNumber} as proven`);
175
+ this.logger.warn(`Marked ${blockNumber} as proven`);
167
176
  });
168
177
  }
169
178
 
@@ -83,17 +83,14 @@ export abstract class BaseWallet implements Wallet {
83
83
  getRegisteredAccounts(): Promise<CompleteAddress[]> {
84
84
  return this.pxe.getRegisteredAccounts();
85
85
  }
86
- getRegisteredAccount(address: AztecAddress): Promise<CompleteAddress | undefined> {
87
- return this.pxe.getRegisteredAccount(address);
86
+ registerSender(address: AztecAddress): Promise<AztecAddress> {
87
+ return this.pxe.registerSender(address);
88
88
  }
89
- registerContact(address: AztecAddress): Promise<AztecAddress> {
90
- return this.pxe.registerContact(address);
89
+ getSenders(): Promise<AztecAddress[]> {
90
+ return this.pxe.getSenders();
91
91
  }
92
- getContacts(): Promise<AztecAddress[]> {
93
- return this.pxe.getContacts();
94
- }
95
- async removeContact(address: AztecAddress): Promise<void> {
96
- await this.pxe.removeContact(address);
92
+ async removeSender(address: AztecAddress): Promise<void> {
93
+ await this.pxe.removeSender(address);
97
94
  }
98
95
  registerContract(contract: {
99
96
  /** Instance */ instance: ContractInstanceWithAddress;
@@ -115,9 +112,18 @@ export abstract class BaseWallet implements Wallet {
115
112
  simulatePublic: boolean,
116
113
  msgSender?: AztecAddress,
117
114
  skipTxValidation?: boolean,
115
+ enforceFeePayment?: boolean,
118
116
  profile?: boolean,
119
117
  ): Promise<TxSimulationResult> {
120
- return this.pxe.simulateTx(txRequest, simulatePublic, msgSender, skipTxValidation, profile, this.scopes);
118
+ return this.pxe.simulateTx(
119
+ txRequest,
120
+ simulatePublic,
121
+ msgSender,
122
+ skipTxValidation,
123
+ enforceFeePayment,
124
+ profile,
125
+ this.scopes,
126
+ );
121
127
  }
122
128
  sendTx(tx: Tx): Promise<TxHash> {
123
129
  return this.pxe.sendTx(tx);
@@ -21,7 +21,9 @@ export async function getWallet(
21
21
  address: AztecAddress,
22
22
  accountContract: AccountContract,
23
23
  ): Promise<AccountWallet> {
24
- const completeAddress = await pxe.getRegisteredAccount(address);
24
+ const completeAddress = (await pxe.getRegisteredAccounts()).find(completeAddress =>
25
+ completeAddress.address.equals(address),
26
+ );
25
27
  if (!completeAddress) {
26
28
  throw new Error(`Account ${address} not found`);
27
29
  }
@@ -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"}