@aztec/aztec.js 0.71.0 → 0.72.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 (80) hide show
  1. package/dest/account/contract.d.ts +1 -1
  2. package/dest/account/contract.d.ts.map +1 -1
  3. package/dest/account_manager/deploy_account_method.js +2 -2
  4. package/dest/account_manager/index.d.ts +8 -5
  5. package/dest/account_manager/index.d.ts.map +1 -1
  6. package/dest/account_manager/index.js +27 -17
  7. package/dest/contract/base_contract_interaction.d.ts.map +1 -1
  8. package/dest/contract/base_contract_interaction.js +3 -2
  9. package/dest/contract/deploy_method.d.ts +1 -1
  10. package/dest/contract/deploy_method.d.ts.map +1 -1
  11. package/dest/contract/deploy_method.js +14 -15
  12. package/dest/contract/deploy_proven_tx.d.ts +2 -2
  13. package/dest/contract/deploy_proven_tx.d.ts.map +1 -1
  14. package/dest/contract/deploy_proven_tx.js +4 -4
  15. package/dest/contract/deploy_sent_tx.d.ts +4 -4
  16. package/dest/contract/deploy_sent_tx.d.ts.map +1 -1
  17. package/dest/contract/deploy_sent_tx.js +9 -7
  18. package/dest/contract/proven_tx.d.ts.map +1 -1
  19. package/dest/contract/proven_tx.js +3 -3
  20. package/dest/contract/sent_tx.d.ts +3 -3
  21. package/dest/contract/sent_tx.d.ts.map +1 -1
  22. package/dest/contract/sent_tx.js +4 -4
  23. package/dest/deployment/broadcast_function.js +3 -3
  24. package/dest/deployment/deploy_instance.d.ts +1 -1
  25. package/dest/deployment/deploy_instance.d.ts.map +1 -1
  26. package/dest/deployment/deploy_instance.js +3 -3
  27. package/dest/deployment/protocol_contracts.d.ts +2 -2
  28. package/dest/deployment/protocol_contracts.d.ts.map +1 -1
  29. package/dest/deployment/protocol_contracts.js +5 -5
  30. package/dest/deployment/register_class.js +2 -2
  31. package/dest/entrypoint/payload.d.ts +2 -0
  32. package/dest/entrypoint/payload.d.ts.map +1 -1
  33. package/dest/entrypoint/payload.js +1 -1
  34. package/dest/fee/fee_juice_payment_method_with_claim.d.ts.map +1 -1
  35. package/dest/fee/fee_juice_payment_method_with_claim.js +6 -5
  36. package/dest/fee/private_fee_payment_method.js +7 -7
  37. package/dest/fee/public_fee_payment_method.js +7 -7
  38. package/dest/index.d.ts +2 -2
  39. package/dest/index.d.ts.map +1 -1
  40. package/dest/index.js +2 -2
  41. package/dest/rpc_clients/pxe_client.d.ts +1 -1
  42. package/dest/rpc_clients/pxe_client.d.ts.map +1 -1
  43. package/dest/utils/abi_types.d.ts +3 -1
  44. package/dest/utils/abi_types.d.ts.map +1 -1
  45. package/dest/utils/cheat_codes.d.ts +2 -0
  46. package/dest/utils/cheat_codes.d.ts.map +1 -1
  47. package/dest/utils/cheat_codes.js +8 -1
  48. package/dest/utils/portal_manager.d.ts +1 -1
  49. package/dest/utils/portal_manager.d.ts.map +1 -1
  50. package/dest/utils/portal_manager.js +4 -4
  51. package/dest/utils/pub_key.d.ts +1 -1
  52. package/dest/utils/pub_key.d.ts.map +1 -1
  53. package/dest/wallet/account_wallet_with_private_key.d.ts +1 -1
  54. package/dest/wallet/base_wallet.d.ts +5 -5
  55. package/dest/wallet/base_wallet.d.ts.map +1 -1
  56. package/dest/wallet/base_wallet.js +7 -7
  57. package/package.json +9 -9
  58. package/src/account/contract.ts +1 -1
  59. package/src/account_manager/deploy_account_method.ts +1 -1
  60. package/src/account_manager/index.ts +33 -24
  61. package/src/contract/base_contract_interaction.ts +3 -1
  62. package/src/contract/deploy_method.ts +15 -16
  63. package/src/contract/deploy_proven_tx.ts +2 -2
  64. package/src/contract/deploy_sent_tx.ts +7 -5
  65. package/src/contract/proven_tx.ts +0 -2
  66. package/src/contract/sent_tx.ts +4 -4
  67. package/src/deployment/broadcast_function.ts +2 -2
  68. package/src/deployment/deploy_instance.ts +5 -2
  69. package/src/deployment/protocol_contracts.ts +4 -4
  70. package/src/deployment/register_class.ts +1 -1
  71. package/src/entrypoint/payload.ts +2 -0
  72. package/src/fee/fee_juice_payment_method_with_claim.ts +5 -4
  73. package/src/fee/private_fee_payment_method.ts +6 -6
  74. package/src/fee/public_fee_payment_method.ts +6 -6
  75. package/src/index.ts +1 -1
  76. package/src/utils/abi_types.ts +4 -1
  77. package/src/utils/cheat_codes.ts +8 -0
  78. package/src/utils/portal_manager.ts +4 -4
  79. package/src/utils/pub_key.ts +1 -1
  80. package/src/wallet/base_wallet.ts +9 -8
@@ -52,7 +52,7 @@ export async function broadcastPrivateFunction(
52
52
 
53
53
  await wallet.addCapsule(bytecode);
54
54
 
55
- const registerer = getRegistererContract(wallet);
55
+ const registerer = await getRegistererContract(wallet);
56
56
  return Promise.resolve(
57
57
  registerer.methods.broadcast_private_function(
58
58
  contractClass.id,
@@ -103,7 +103,7 @@ export async function broadcastUnconstrainedFunction(
103
103
 
104
104
  await wallet.addCapsule(bytecode);
105
105
 
106
- const registerer = getRegistererContract(wallet);
106
+ const registerer = await getRegistererContract(wallet);
107
107
  return registerer.methods.broadcast_unconstrained_function(
108
108
  contractClass.id,
109
109
  artifactMetadataHash,
@@ -9,8 +9,11 @@ import { getDeployerContract } from './protocol_contracts.js';
9
9
  * @param wallet - The wallet to use for the deployment.
10
10
  * @param instance - The instance to deploy.
11
11
  */
12
- export function deployInstance(wallet: Wallet, instance: ContractInstanceWithAddress): ContractFunctionInteraction {
13
- const deployerContract = getDeployerContract(wallet);
12
+ export async function deployInstance(
13
+ wallet: Wallet,
14
+ instance: ContractInstanceWithAddress,
15
+ ): Promise<ContractFunctionInteraction> {
16
+ const deployerContract = await getDeployerContract(wallet);
14
17
  const { salt, contractClassId, publicKeys, deployer } = instance;
15
18
  const isUniversalDeploy = deployer.isZero();
16
19
  if (!isUniversalDeploy && !wallet.getAddress().equals(deployer)) {
@@ -5,13 +5,13 @@ import { UnsafeContract } from '../contract/unsafe_contract.js';
5
5
  import { type Wallet } from '../wallet/index.js';
6
6
 
7
7
  /** Returns a Contract wrapper for the class registerer. */
8
- export function getRegistererContract(wallet: Wallet) {
9
- const { artifact, instance } = getCanonicalClassRegisterer();
8
+ export async function getRegistererContract(wallet: Wallet) {
9
+ const { artifact, instance } = await getCanonicalClassRegisterer();
10
10
  return new UnsafeContract(instance, artifact, wallet);
11
11
  }
12
12
 
13
13
  /** Returns a Contract wrapper for the instance deployer. */
14
- export function getDeployerContract(wallet: Wallet) {
15
- const { artifact, instance } = getCanonicalInstanceDeployer();
14
+ export async function getDeployerContract(wallet: Wallet) {
15
+ const { artifact, instance } = await getCanonicalInstanceDeployer();
16
16
  return new UnsafeContract(instance, artifact, wallet);
17
17
  }
@@ -20,7 +20,7 @@ export async function registerContractClass(
20
20
  const { artifactHash, privateFunctionsRoot, publicBytecodeCommitment, packedBytecode } =
21
21
  getContractClassFromArtifact(artifact);
22
22
  const encodedBytecode = bufferAsFields(packedBytecode, MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS);
23
- const registerer = getRegistererContract(wallet);
23
+ const registerer = await getRegistererContract(wallet);
24
24
  await wallet.addCapsule(encodedBytecode);
25
25
  return registerer.methods.register(artifactHash, privateFunctionsRoot, publicBytecodeCommitment, emitPublicBytecode);
26
26
  }
@@ -24,6 +24,8 @@ export type UserFeeOptions = {
24
24
  paymentMethod?: FeePaymentMethod;
25
25
  /** The gas settings */
26
26
  gasSettings?: Partial<FieldsOf<GasSettings>>;
27
+ /** Percentage to pad the base fee by, if empty, defaults to 0.5 */
28
+ baseFeePadding?: number;
27
29
  /** Whether to run an initial simulation of the tx with high gas limit to figure out actual gas settings. */
28
30
  estimateGas?: boolean;
29
31
  /** Percentage to pad the estimated gas limits by, if empty, defaults to 0.1. Only relevant if estimateGas is set. */
@@ -1,6 +1,6 @@
1
1
  import { type FunctionCall } from '@aztec/circuit-types';
2
2
  import { type AztecAddress, Fr, FunctionSelector } from '@aztec/circuits.js';
3
- import { FunctionType } from '@aztec/foundation/abi';
3
+ import { FunctionType, U128 } from '@aztec/foundation/abi';
4
4
  import { ProtocolContractAddress } from '@aztec/protocol-contracts';
5
5
  import { getCanonicalFeeJuice } from '@aztec/protocol-contracts/fee-juice';
6
6
 
@@ -22,9 +22,10 @@ export class FeeJuicePaymentMethodWithClaim extends FeeJuicePaymentMethod {
22
22
  * Creates a function call to pay the fee in Fee Juice.
23
23
  * @returns A function call
24
24
  */
25
- override getFunctionCalls(): Promise<FunctionCall[]> {
25
+ override async getFunctionCalls(): Promise<FunctionCall[]> {
26
+ const canonicalFeeJuice = await getCanonicalFeeJuice();
26
27
  const selector = FunctionSelector.fromNameAndParameters(
27
- getCanonicalFeeJuice().artifact.functions.find(f => f.name === 'claim')!,
28
+ canonicalFeeJuice.artifact.functions.find(f => f.name === 'claim')!,
28
29
  );
29
30
 
30
31
  return Promise.resolve([
@@ -35,7 +36,7 @@ export class FeeJuicePaymentMethodWithClaim extends FeeJuicePaymentMethod {
35
36
  isStatic: false,
36
37
  args: [
37
38
  this.sender.toField(),
38
- this.claim.claimAmount,
39
+ ...new U128(this.claim.claimAmount).toFields(),
39
40
  this.claim.claimSecret,
40
41
  new Fr(this.claim.messageLeafIndex),
41
42
  ],
@@ -1,6 +1,6 @@
1
1
  import { type FunctionCall } from '@aztec/circuit-types';
2
2
  import { type GasSettings } from '@aztec/circuits.js';
3
- import { FunctionSelector, FunctionType } from '@aztec/foundation/abi';
3
+ import { FunctionSelector, FunctionType, U128 } from '@aztec/foundation/abi';
4
4
  import { type AztecAddress } from '@aztec/foundation/aztec-address';
5
5
  import { Fr } from '@aztec/foundation/fields';
6
6
 
@@ -88,15 +88,15 @@ export class PrivateFeePaymentMethod implements FeePaymentMethod {
88
88
  async getFunctionCalls(gasSettings: GasSettings): Promise<FunctionCall[]> {
89
89
  // We assume 1:1 exchange rate between fee juice and token. But in reality you would need to convert feeLimit
90
90
  // (maxFee) to be in token denomination.
91
- const maxFee = this.setMaxFeeToOne ? Fr.ONE : gasSettings.getFeeLimit();
91
+ const maxFee = new U128(this.setMaxFeeToOne ? 1n : gasSettings.getFeeLimit().toBigInt());
92
92
  const nonce = Fr.random();
93
93
 
94
94
  await this.wallet.createAuthWit({
95
95
  caller: this.paymentContract,
96
96
  action: {
97
97
  name: 'setup_refund',
98
- args: [this.wallet.getAddress().toField(), maxFee, nonce],
99
- selector: FunctionSelector.fromSignature('setup_refund((Field),Field,Field)'),
98
+ args: [this.wallet.getAddress().toField(), ...maxFee.toFields(), nonce],
99
+ selector: FunctionSelector.fromSignature('setup_refund((Field),(Field,Field),Field)'),
100
100
  type: FunctionType.PRIVATE,
101
101
  isStatic: false,
102
102
  to: await this.getAsset(),
@@ -108,10 +108,10 @@ export class PrivateFeePaymentMethod implements FeePaymentMethod {
108
108
  {
109
109
  name: 'fee_entrypoint_private',
110
110
  to: this.paymentContract,
111
- selector: FunctionSelector.fromSignature('fee_entrypoint_private(Field,Field)'),
111
+ selector: FunctionSelector.fromSignature('fee_entrypoint_private((Field,Field),Field)'),
112
112
  type: FunctionType.PRIVATE,
113
113
  isStatic: false,
114
- args: [maxFee, nonce],
114
+ args: [...maxFee.toFields(), nonce],
115
115
  returnTypes: [],
116
116
  },
117
117
  ];
@@ -1,6 +1,6 @@
1
1
  import { type FunctionCall } from '@aztec/circuit-types';
2
2
  import { type GasSettings } from '@aztec/circuits.js';
3
- import { FunctionSelector, FunctionType } from '@aztec/foundation/abi';
3
+ import { FunctionSelector, FunctionType, U128 } from '@aztec/foundation/abi';
4
4
  import { type AztecAddress } from '@aztec/foundation/aztec-address';
5
5
  import { Fr } from '@aztec/foundation/fields';
6
6
 
@@ -80,7 +80,7 @@ export class PublicFeePaymentMethod implements FeePaymentMethod {
80
80
  */
81
81
  async getFunctionCalls(gasSettings: GasSettings): Promise<FunctionCall[]> {
82
82
  const nonce = Fr.random();
83
- const maxFee = gasSettings.getFeeLimit();
83
+ const maxFee = new U128(gasSettings.getFeeLimit().toBigInt());
84
84
 
85
85
  return Promise.resolve([
86
86
  this.wallet
@@ -89,8 +89,8 @@ export class PublicFeePaymentMethod implements FeePaymentMethod {
89
89
  caller: this.paymentContract,
90
90
  action: {
91
91
  name: 'transfer_in_public',
92
- args: [this.wallet.getAddress().toField(), this.paymentContract.toField(), maxFee, nonce],
93
- selector: FunctionSelector.fromSignature('transfer_in_public((Field),(Field),Field,Field)'),
92
+ args: [this.wallet.getAddress().toField(), this.paymentContract.toField(), ...maxFee.toFields(), nonce],
93
+ selector: FunctionSelector.fromSignature('transfer_in_public((Field),(Field),(Field,Field),Field)'),
94
94
  type: FunctionType.PUBLIC,
95
95
  isStatic: false,
96
96
  to: await this.getAsset(),
@@ -103,10 +103,10 @@ export class PublicFeePaymentMethod implements FeePaymentMethod {
103
103
  {
104
104
  name: 'fee_entrypoint_public',
105
105
  to: this.paymentContract,
106
- selector: FunctionSelector.fromSignature('fee_entrypoint_public(Field,Field)'),
106
+ selector: FunctionSelector.fromSignature('fee_entrypoint_public((Field,Field),Field)'),
107
107
  type: FunctionType.PRIVATE,
108
108
  isStatic: false,
109
- args: [maxFee, nonce],
109
+ args: [...maxFee.toFields(), nonce],
110
110
  returnTypes: [],
111
111
  },
112
112
  ]);
package/src/index.ts CHANGED
@@ -45,6 +45,7 @@ export {
45
45
  type L2AmountClaim,
46
46
  type L2AmountClaimWithRecipient,
47
47
  type L2Claim,
48
+ type U128Like,
48
49
  type WrappedFieldLike,
49
50
  type IntentAction,
50
51
  } from './utils/index.js';
@@ -117,7 +118,6 @@ export {
117
118
  TxHash,
118
119
  TxReceipt,
119
120
  TxStatus,
120
- UnencryptedL2BlockL2Logs,
121
121
  UnencryptedL2Log,
122
122
  UniqueNote,
123
123
  createAztecNodeClient,
@@ -13,7 +13,7 @@ export type FieldLike = Fr | Buffer | bigint | number | { /** Converts to field
13
13
  export type EthAddressLike = { /** Wrapped address */ address: FieldLike } | EthAddress;
14
14
 
15
15
  /** Any type that can be converted into an AztecAddress Aztec.nr struct. */
16
- export type AztecAddressLike = { /** Wrapped address */ address: FieldLike } | AztecAddress | Fr;
16
+ export type AztecAddressLike = { /** Wrapped address */ address: FieldLike } | AztecAddress;
17
17
 
18
18
  /** Any type that can be converted into a FunctionSelector Aztec.nr struct. */
19
19
  export type FunctionSelectorLike = FieldLike | FunctionSelector;
@@ -21,5 +21,8 @@ export type FunctionSelectorLike = FieldLike | FunctionSelector;
21
21
  /** Any type that can be converted into an EventSelector Aztec.nr struct. */
22
22
  export type EventSelectorLike = FieldLike | EventSelector;
23
23
 
24
+ /** Any type that can be converted into a U128. */
25
+ export type U128Like = bigint | number;
26
+
24
27
  /** Any type that can be converted into a struct with a single `inner` field. */
25
28
  export type WrappedFieldLike = { /** Wrapped value */ inner: FieldLike } | FieldLike;
@@ -188,6 +188,14 @@ export class RollupCheatCodes {
188
188
  await action(owner, this.rollup);
189
189
  await this.ethCheatCodes.stopImpersonating(owner);
190
190
  }
191
+
192
+ /** Directly calls the L1 gas fee oracle. */
193
+ public async updateL1GasFeeOracle() {
194
+ await this.asOwner(async (account, rollup) => {
195
+ await rollup.write.updateL1GasFeeOracle({ account, chain: this.client.chain });
196
+ this.logger.warn(`Updated L1 gas fee oracle`);
197
+ });
198
+ }
191
199
  }
192
200
 
193
201
  /**
@@ -36,7 +36,7 @@ export type L2Claim = {
36
36
  };
37
37
 
38
38
  /** L1 to L2 message info that corresponds to an amount to claim. */
39
- export type L2AmountClaim = L2Claim & { /** Amount to claim */ claimAmount: Fr };
39
+ export type L2AmountClaim = L2Claim & { /** Amount to claim */ claimAmount: bigint };
40
40
 
41
41
  /** L1 to L2 message info that corresponds to an amount to claim with associated recipient. */
42
42
  export type L2AmountClaimWithRecipient = L2AmountClaim & {
@@ -173,7 +173,7 @@ export class L1FeeJuicePortalManager {
173
173
  );
174
174
 
175
175
  return {
176
- claimAmount: new Fr(amount),
176
+ claimAmount: amount,
177
177
  claimSecret,
178
178
  claimSecretHash,
179
179
  messageHash: log.args.key,
@@ -264,7 +264,7 @@ export class L1ToL2TokenPortalManager {
264
264
  );
265
265
 
266
266
  return {
267
- claimAmount: new Fr(amount),
267
+ claimAmount: amount,
268
268
  claimSecret,
269
269
  claimSecretHash,
270
270
  messageHash: log.args.key,
@@ -306,7 +306,7 @@ export class L1ToL2TokenPortalManager {
306
306
  );
307
307
 
308
308
  return {
309
- claimAmount: new Fr(amount),
309
+ claimAmount: amount,
310
310
  claimSecret,
311
311
  claimSecretHash,
312
312
  recipient: to,
@@ -6,7 +6,7 @@ import { Grumpkin } from '@aztec/circuits.js/barretenberg';
6
6
  * @param privateKey - The private key.
7
7
  * @returns The generated public key.
8
8
  */
9
- export function generatePublicKey(privateKey: GrumpkinScalar): PublicKey {
9
+ export function generatePublicKey(privateKey: GrumpkinScalar): Promise<PublicKey> {
10
10
  const grumpkin = new Grumpkin();
11
11
  return grumpkin.mul(grumpkin.generator(), privateKey);
12
12
  }
@@ -2,7 +2,8 @@ import {
2
2
  type AuthWitness,
3
3
  type EventMetadataDefinition,
4
4
  type ExtendedNote,
5
- type GetUnencryptedLogsResponse,
5
+ type GetContractClassLogsResponse,
6
+ type GetPublicLogsResponse,
6
7
  type L2Block,
7
8
  type LogFilter,
8
9
  type NotesFilter,
@@ -160,10 +161,10 @@ export abstract class BaseWallet implements Wallet {
160
161
  ): Promise<AbiDecoded> {
161
162
  return this.pxe.simulateUnconstrained(functionName, args, to, from);
162
163
  }
163
- getUnencryptedLogs(filter: LogFilter): Promise<GetUnencryptedLogsResponse> {
164
- return this.pxe.getUnencryptedLogs(filter);
164
+ getPublicLogs(filter: LogFilter): Promise<GetPublicLogsResponse> {
165
+ return this.pxe.getPublicLogs(filter);
165
166
  }
166
- getContractClassLogs(filter: LogFilter): Promise<GetUnencryptedLogsResponse> {
167
+ getContractClassLogs(filter: LogFilter): Promise<GetContractClassLogsResponse> {
167
168
  return this.pxe.getContractClassLogs(filter);
168
169
  }
169
170
  getBlockNumber(): Promise<number> {
@@ -193,16 +194,16 @@ export abstract class BaseWallet implements Wallet {
193
194
  getPXEInfo(): Promise<PXEInfo> {
194
195
  return this.pxe.getPXEInfo();
195
196
  }
196
- getEncryptedEvents<T>(
197
+ getPrivateEvents<T>(
197
198
  event: EventMetadataDefinition,
198
199
  from: number,
199
200
  limit: number,
200
201
  vpks: Point[] = [this.getCompleteAddress().publicKeys.masterIncomingViewingPublicKey],
201
202
  ): Promise<T[]> {
202
- return this.pxe.getEncryptedEvents(event, from, limit, vpks);
203
+ return this.pxe.getPrivateEvents(event, from, limit, vpks);
203
204
  }
204
- getUnencryptedEvents<T>(event: EventMetadataDefinition, from: number, limit: number): Promise<T[]> {
205
- return this.pxe.getUnencryptedEvents(event, from, limit);
205
+ getPublicEvents<T>(event: EventMetadataDefinition, from: number, limit: number): Promise<T[]> {
206
+ return this.pxe.getPublicEvents(event, from, limit);
206
207
  }
207
208
  public getL1ToL2MembershipWitness(
208
209
  contractAddress: AztecAddress,