@aztec/aztec.js 0.0.1-commit.29c6b1a3 → 0.0.1-commit.2c85e299c

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 (116) hide show
  1. package/dest/api/abi.d.ts +2 -2
  2. package/dest/api/abi.d.ts.map +1 -1
  3. package/dest/api/contract.d.ts +5 -5
  4. package/dest/api/contract.d.ts.map +1 -1
  5. package/dest/api/contract.js +3 -3
  6. package/dest/api/deployment.d.ts +1 -2
  7. package/dest/api/deployment.d.ts.map +1 -1
  8. package/dest/api/deployment.js +0 -1
  9. package/dest/api/events.d.ts +18 -6
  10. package/dest/api/events.d.ts.map +1 -1
  11. package/dest/api/events.js +37 -22
  12. package/dest/api/fields.d.ts +2 -1
  13. package/dest/api/fields.d.ts.map +1 -1
  14. package/dest/api/fields.js +1 -0
  15. package/dest/api/keys.d.ts +1 -1
  16. package/dest/api/keys.js +1 -1
  17. package/dest/api/wallet.d.ts +3 -2
  18. package/dest/api/wallet.d.ts.map +1 -1
  19. package/dest/api/wallet.js +2 -1
  20. package/dest/contract/base_contract_interaction.d.ts +3 -3
  21. package/dest/contract/base_contract_interaction.d.ts.map +1 -1
  22. package/dest/contract/batch_call.d.ts +3 -3
  23. package/dest/contract/batch_call.d.ts.map +1 -1
  24. package/dest/contract/batch_call.js +17 -8
  25. package/dest/contract/contract_function_interaction.d.ts +7 -16
  26. package/dest/contract/contract_function_interaction.d.ts.map +1 -1
  27. package/dest/contract/contract_function_interaction.js +107 -18
  28. package/dest/contract/deploy_method.d.ts +37 -12
  29. package/dest/contract/deploy_method.d.ts.map +1 -1
  30. package/dest/contract/deploy_method.js +42 -21
  31. package/dest/contract/get_gas_limits.js +3 -3
  32. package/dest/contract/interaction_options.d.ts +62 -21
  33. package/dest/contract/interaction_options.d.ts.map +1 -1
  34. package/dest/contract/interaction_options.js +33 -0
  35. package/dest/contract/protocol_contracts/auth-registry.d.ts +1 -1
  36. package/dest/contract/protocol_contracts/auth-registry.d.ts.map +1 -1
  37. package/dest/contract/protocol_contracts/auth-registry.js +48 -6
  38. package/dest/contract/protocol_contracts/contract-class-registry.d.ts +2 -22
  39. package/dest/contract/protocol_contracts/contract-class-registry.d.ts.map +1 -1
  40. package/dest/contract/protocol_contracts/contract-class-registry.js +13 -658
  41. package/dest/contract/protocol_contracts/contract-instance-registry.d.ts +2 -11
  42. package/dest/contract/protocol_contracts/contract-instance-registry.d.ts.map +1 -1
  43. package/dest/contract/protocol_contracts/contract-instance-registry.js +76 -473
  44. package/dest/contract/protocol_contracts/fee-juice.d.ts +1 -10
  45. package/dest/contract/protocol_contracts/fee-juice.d.ts.map +1 -1
  46. package/dest/contract/protocol_contracts/fee-juice.js +7 -400
  47. package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts +1 -1
  48. package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts.map +1 -1
  49. package/dest/contract/protocol_contracts/multi-call-entrypoint.js +39 -1
  50. package/dest/contract/protocol_contracts/public-checks.d.ts +1 -1
  51. package/dest/contract/protocol_contracts/public-checks.d.ts.map +1 -1
  52. package/dest/contract/protocol_contracts/public-checks.js +39 -9
  53. package/dest/fee/fee_juice_payment_method_with_claim.js +6 -6
  54. package/dest/fee/private_fee_payment_method.d.ts +2 -1
  55. package/dest/fee/private_fee_payment_method.d.ts.map +1 -1
  56. package/dest/fee/private_fee_payment_method.js +11 -10
  57. package/dest/fee/public_fee_payment_method.d.ts +2 -1
  58. package/dest/fee/public_fee_payment_method.d.ts.map +1 -1
  59. package/dest/fee/public_fee_payment_method.js +11 -10
  60. package/dest/fee/sponsored_fee_payment.js +3 -3
  61. package/dest/utils/abi_types.d.ts +6 -1
  62. package/dest/utils/abi_types.d.ts.map +1 -1
  63. package/dest/utils/abi_types.js +1 -1
  64. package/dest/utils/authwit.d.ts +5 -5
  65. package/dest/utils/authwit.d.ts.map +1 -1
  66. package/dest/utils/authwit.js +10 -6
  67. package/dest/utils/cross_chain.d.ts +3 -8
  68. package/dest/utils/cross_chain.d.ts.map +1 -1
  69. package/dest/utils/cross_chain.js +8 -15
  70. package/dest/wallet/capabilities.d.ts +452 -0
  71. package/dest/wallet/capabilities.d.ts.map +1 -0
  72. package/dest/wallet/capabilities.js +3 -0
  73. package/dest/wallet/deploy_account_method.d.ts +15 -4
  74. package/dest/wallet/deploy_account_method.d.ts.map +1 -1
  75. package/dest/wallet/deploy_account_method.js +26 -0
  76. package/dest/wallet/index.d.ts +2 -1
  77. package/dest/wallet/index.d.ts.map +1 -1
  78. package/dest/wallet/index.js +1 -0
  79. package/dest/wallet/wallet.d.ts +1663 -89
  80. package/dest/wallet/wallet.d.ts.map +1 -1
  81. package/dest/wallet/wallet.js +175 -27
  82. package/package.json +20 -11
  83. package/src/api/abi.ts +1 -0
  84. package/src/api/contract.ts +10 -3
  85. package/src/api/deployment.ts +0 -1
  86. package/src/api/events.ts +50 -32
  87. package/src/api/fields.ts +1 -0
  88. package/src/api/keys.ts +2 -2
  89. package/src/api/wallet.ts +43 -1
  90. package/src/contract/base_contract_interaction.ts +3 -2
  91. package/src/contract/batch_call.ts +17 -14
  92. package/src/contract/contract_function_interaction.ts +114 -26
  93. package/src/contract/deploy_method.ts +77 -32
  94. package/src/contract/get_gas_limits.ts +3 -3
  95. package/src/contract/interaction_options.ts +96 -23
  96. package/src/contract/protocol_contracts/auth-registry.ts +10 -2
  97. package/src/contract/protocol_contracts/contract-class-registry.ts +4 -338
  98. package/src/contract/protocol_contracts/contract-instance-registry.ts +33 -225
  99. package/src/contract/protocol_contracts/fee-juice.ts +2 -193
  100. package/src/contract/protocol_contracts/multi-call-entrypoint.ts +8 -1
  101. package/src/contract/protocol_contracts/public-checks.ts +8 -3
  102. package/src/fee/fee_juice_payment_method_with_claim.ts +5 -5
  103. package/src/fee/private_fee_payment_method.ts +8 -7
  104. package/src/fee/public_fee_payment_method.ts +9 -8
  105. package/src/fee/sponsored_fee_payment.ts +3 -3
  106. package/src/utils/abi_types.ts +7 -0
  107. package/src/utils/authwit.ts +20 -22
  108. package/src/utils/cross_chain.ts +9 -18
  109. package/src/wallet/capabilities.ts +500 -0
  110. package/src/wallet/deploy_account_method.ts +39 -2
  111. package/src/wallet/index.ts +1 -0
  112. package/src/wallet/wallet.ts +230 -39
  113. package/dest/deployment/broadcast_function.d.ts +0 -24
  114. package/dest/deployment/broadcast_function.d.ts.map +0 -1
  115. package/dest/deployment/broadcast_function.js +0 -74
  116. package/src/deployment/broadcast_function.ts +0 -148
@@ -1,5 +1,5 @@
1
1
  import { Fr } from '@aztec/foundation/curves/bn254';
2
- import { type FunctionAbi, FunctionSelector, FunctionType, decodeFromAbi } from '@aztec/stdlib/abi';
2
+ import { type FunctionAbi, FunctionCall, FunctionSelector, FunctionType, decodeFromAbi } from '@aztec/stdlib/abi';
3
3
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
4
4
  import type { GasSettings } from '@aztec/stdlib/gas';
5
5
  import { ExecutionPayload } from '@aztec/stdlib/tx';
@@ -10,6 +10,7 @@ import type { FeePaymentMethod } from './fee_payment_method.js';
10
10
 
11
11
  /**
12
12
  * Holds information about how the fee for a transaction is to be paid.
13
+ * @deprecated Is not supported on mainnet. Use {@link FeeJuicePaymentMethodWithClaim} or `SponsoredFeePaymentMethod` instead.
13
14
  */
14
15
  export class PrivateFeePaymentMethod implements FeePaymentMethod {
15
16
  private assetPromise: Promise<AztecAddress> | null = null;
@@ -102,21 +103,21 @@ export class PrivateFeePaymentMethod implements FeePaymentMethod {
102
103
 
103
104
  const witness = await this.wallet.createAuthWit(this.sender, {
104
105
  caller: this.paymentContract,
105
- call: {
106
+ call: FunctionCall.from({
106
107
  name: 'transfer_to_public',
107
- args: [this.sender.toField(), this.paymentContract.toField(), maxFee, txNonce],
108
+ to: await this.getAsset(),
108
109
  selector: await FunctionSelector.fromSignature('transfer_to_public((Field),(Field),u128,Field)'),
109
110
  type: FunctionType.PRIVATE,
110
111
  hideMsgSender: false,
111
112
  isStatic: false,
112
- to: await this.getAsset(),
113
+ args: [this.sender.toField(), this.paymentContract.toField(), maxFee, txNonce],
113
114
  returnTypes: [],
114
- },
115
+ }),
115
116
  });
116
117
 
117
118
  return new ExecutionPayload(
118
119
  [
119
- {
120
+ FunctionCall.from({
120
121
  name: 'fee_entrypoint_private',
121
122
  to: this.paymentContract,
122
123
  selector: await FunctionSelector.fromSignature('fee_entrypoint_private(u128,Field)'),
@@ -125,7 +126,7 @@ export class PrivateFeePaymentMethod implements FeePaymentMethod {
125
126
  isStatic: false,
126
127
  args: [maxFee, txNonce],
127
128
  returnTypes: [],
128
- },
129
+ }),
129
130
  ],
130
131
  [witness],
131
132
  [],
@@ -1,5 +1,5 @@
1
1
  import { Fr } from '@aztec/foundation/curves/bn254';
2
- import { type FunctionAbi, FunctionSelector, FunctionType, decodeFromAbi } from '@aztec/stdlib/abi';
2
+ import { type FunctionAbi, FunctionCall, FunctionSelector, FunctionType, decodeFromAbi } from '@aztec/stdlib/abi';
3
3
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
4
4
  import { GasSettings } from '@aztec/stdlib/gas';
5
5
  import { ExecutionPayload } from '@aztec/stdlib/tx';
@@ -11,6 +11,7 @@ import type { FeePaymentMethod } from './fee_payment_method.js';
11
11
 
12
12
  /**
13
13
  * Holds information about how the fee for a transaction is to be paid.
14
+ * @deprecated Is not supported on mainnet. Use {@link FeeJuicePaymentMethodWithClaim} or `SponsoredFeePaymentMethod` instead.
14
15
  */
15
16
  export class PublicFeePaymentMethod implements FeePaymentMethod {
16
17
  private assetPromise: Promise<AztecAddress> | null = null;
@@ -94,16 +95,16 @@ export class PublicFeePaymentMethod implements FeePaymentMethod {
94
95
 
95
96
  const intent = {
96
97
  caller: this.paymentContract,
97
- call: {
98
+ call: FunctionCall.from({
98
99
  name: 'transfer_in_public',
99
- args: [this.sender.toField(), this.paymentContract.toField(), maxFee, txNonce],
100
+ to: await this.getAsset(),
100
101
  selector: await FunctionSelector.fromSignature('transfer_in_public((Field),(Field),u128,Field)'),
101
102
  type: FunctionType.PUBLIC,
102
- isStatic: false,
103
103
  hideMsgSender: false /** The target function performs an authwit check, so msg_sender is needed */,
104
- to: await this.getAsset(),
104
+ isStatic: false,
105
+ args: [this.sender.toField(), this.paymentContract.toField(), maxFee, txNonce],
105
106
  returnTypes: [],
106
- },
107
+ }),
107
108
  };
108
109
 
109
110
  const setPublicAuthWitInteraction = await SetPublicAuthwitContractInteraction.create(
@@ -116,7 +117,7 @@ export class PublicFeePaymentMethod implements FeePaymentMethod {
116
117
  return new ExecutionPayload(
117
118
  [
118
119
  ...(await setPublicAuthWitInteraction.request()).calls,
119
- {
120
+ FunctionCall.from({
120
121
  name: 'fee_entrypoint_public',
121
122
  to: this.paymentContract,
122
123
  selector: await FunctionSelector.fromSignature('fee_entrypoint_public(u128,Field)'),
@@ -125,7 +126,7 @@ export class PublicFeePaymentMethod implements FeePaymentMethod {
125
126
  isStatic: false,
126
127
  args: [maxFee, txNonce],
127
128
  returnTypes: [],
128
- },
129
+ }),
129
130
  ],
130
131
  [],
131
132
  [],
@@ -1,5 +1,5 @@
1
1
  import type { FeePaymentMethod } from '@aztec/aztec.js/fee';
2
- import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
2
+ import { FunctionCall, FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
3
3
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
4
4
  import type { GasSettings } from '@aztec/stdlib/gas';
5
5
  import { ExecutionPayload } from '@aztec/stdlib/tx';
@@ -22,7 +22,7 @@ export class SponsoredFeePaymentMethod implements FeePaymentMethod {
22
22
  async getExecutionPayload(): Promise<ExecutionPayload> {
23
23
  return new ExecutionPayload(
24
24
  [
25
- {
25
+ FunctionCall.from({
26
26
  name: 'sponsor_unconditionally',
27
27
  to: this.paymentContract,
28
28
  selector: await FunctionSelector.fromSignature('sponsor_unconditionally()'),
@@ -31,7 +31,7 @@ export class SponsoredFeePaymentMethod implements FeePaymentMethod {
31
31
  isStatic: false,
32
32
  args: [],
33
33
  returnTypes: [],
34
- },
34
+ }),
35
35
  ],
36
36
  [],
37
37
  [],
@@ -23,3 +23,10 @@ export type U128Like = bigint | number;
23
23
 
24
24
  /** Any type that can be converted into a struct with a single `inner` field. */
25
25
  export type WrappedFieldLike = { /** Wrapped value */ inner: FieldLike } | FieldLike;
26
+
27
+ /** Noir `Option<T>` lowered ABI shape, plus ergonomic direct `T | null | undefined` inputs. */
28
+ export type OptionLike<T> =
29
+ | T
30
+ | null
31
+ | undefined
32
+ | { /** Whether the option is populated */ _is_some: boolean; /** Wrapped value */ _value: T };
@@ -5,7 +5,7 @@ import { type ABIParameterVisibility, type FunctionAbi, type FunctionCall, Funct
5
5
  import { AuthWitness, computeInnerAuthWitHash, computeOuterAuthWitHash } from '@aztec/stdlib/auth-witness';
6
6
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
7
7
  import { computeVarArgsHash } from '@aztec/stdlib/hash';
8
- import type { TxHash, TxProfileResult, TxReceipt } from '@aztec/stdlib/tx';
8
+ import type { TxProfileResult } from '@aztec/stdlib/tx';
9
9
 
10
10
  import { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
11
11
  import type {
@@ -15,7 +15,8 @@ import type {
15
15
  SendInteractionOptionsWithoutWait,
16
16
  SendReturn,
17
17
  SimulateInteractionOptions,
18
- SimulationReturn,
18
+ SimulationResult,
19
+ TxSendResultMined,
19
20
  } from '../contract/interaction_options.js';
20
21
  import type { Wallet } from '../wallet/index.js';
21
22
 
@@ -189,10 +190,12 @@ export async function lookupValidity(
189
190
  errorTypes: {},
190
191
  } as FunctionAbi;
191
192
  try {
192
- results.isValidInPrivate = (await new ContractFunctionInteraction(wallet, onBehalfOf, lookupValidityAbi, [
193
- consumer,
194
- innerHash,
195
- ]).simulate({ from: onBehalfOf, authWitnesses: [witness] })) as boolean;
193
+ results.isValidInPrivate = (
194
+ await new ContractFunctionInteraction(wallet, onBehalfOf, lookupValidityAbi, [consumer, innerHash]).simulate({
195
+ from: onBehalfOf,
196
+ authWitnesses: [witness],
197
+ })
198
+ ).result as boolean;
196
199
  // TODO: Narrow down the error to make sure simulation failed due to an invalid authwit
197
200
  // eslint-disable-next-line no-empty
198
201
  } catch {}
@@ -219,12 +222,12 @@ export async function lookupValidity(
219
222
  returnTypes: [{ kind: 'boolean' }],
220
223
  errorTypes: {},
221
224
  } as FunctionAbi;
222
- results.isValidInPublic = (await new ContractFunctionInteraction(
223
- wallet,
224
- ProtocolContractAddress.AuthRegistry,
225
- isConsumableAbi,
226
- [onBehalfOf, messageHash],
227
- ).simulate({ from: onBehalfOf })) as boolean;
225
+ results.isValidInPublic = (
226
+ await new ContractFunctionInteraction(wallet, ProtocolContractAddress.AuthRegistry, isConsumableAbi, [
227
+ onBehalfOf,
228
+ messageHash,
229
+ ]).simulate({ from: onBehalfOf })
230
+ ).result as boolean;
228
231
 
229
232
  return results;
230
233
  }
@@ -262,14 +265,10 @@ export class SetPublicAuthwitContractInteraction extends ContractFunctionInterac
262
265
  * @param options - An optional object containing additional configuration for the transaction.
263
266
  * @returns The result of the transaction as returned by the contract function.
264
267
  */
265
- public override simulate<T extends SimulateInteractionOptions>(
266
- options: Omit<T, 'from'>,
267
- ): Promise<SimulationReturn<T['includeMetadata']>>;
268
- // eslint-disable-next-line jsdoc/require-jsdoc
269
268
  public override simulate(
270
- options: Omit<SimulateInteractionOptions, 'from'> = {},
271
- ): Promise<SimulationReturn<typeof options.includeMetadata>> {
272
- return super.simulate({ ...options, from: this.from });
269
+ options: Omit<SimulateInteractionOptions, 'from'> = {} as Omit<SimulateInteractionOptions, 'from'>,
270
+ ): Promise<SimulationResult> {
271
+ return super.simulate({ ...options, from: this.from } as SimulateInteractionOptions);
273
272
  }
274
273
 
275
274
  /**
@@ -290,8 +289,7 @@ export class SetPublicAuthwitContractInteraction extends ContractFunctionInterac
290
289
  * @param options - An optional object containing 'fee' options information
291
290
  * @returns A TxReceipt (if wait is true/undefined) or TxHash (if wait is false)
292
291
  */
293
- // Overload for when wait is not specified at all - returns TxReceipt
294
- public override send(options?: Omit<SendInteractionOptionsWithoutWait, 'from'>): Promise<TxReceipt>;
292
+ public override send(options?: Omit<SendInteractionOptionsWithoutWait, 'from'>): Promise<TxSendResultMined>;
295
293
  // Generic overload for explicit wait values
296
294
  // eslint-disable-next-line jsdoc/require-jsdoc
297
295
  public override send<W extends InteractionWaitOptions>(
@@ -300,7 +298,7 @@ export class SetPublicAuthwitContractInteraction extends ContractFunctionInterac
300
298
  // eslint-disable-next-line jsdoc/require-jsdoc
301
299
  public override send(
302
300
  options?: Omit<SendInteractionOptions<InteractionWaitOptions>, 'from'>,
303
- ): Promise<TxReceipt | TxHash> {
301
+ ): Promise<SendReturn<InteractionWaitOptions>> {
304
302
  return super.send({ ...options, from: this.from });
305
303
  }
306
304
 
@@ -8,17 +8,15 @@ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
8
8
  * @param l1ToL2MessageHash - Hash of the L1 to L2 message
9
9
  * @param opts - Options
10
10
  */
11
- export async function waitForL1ToL2MessageReady(
12
- node: Pick<AztecNode, 'getBlockNumber' | 'getL1ToL2MessageBlock'>,
11
+ export function waitForL1ToL2MessageReady(
12
+ node: Pick<AztecNode, 'getBlock' | 'getL1ToL2MessageCheckpoint'>,
13
13
  l1ToL2MessageHash: Fr,
14
14
  opts: {
15
15
  /** Timeout for the operation in seconds */ timeoutSeconds: number;
16
- /** True if the message is meant to be consumed from a public function */ forPublicConsumption: boolean;
17
16
  },
18
17
  ) {
19
- const messageBlockNumber = await node.getL1ToL2MessageBlock(l1ToL2MessageHash);
20
18
  return retryUntil(
21
- () => isL1ToL2MessageReady(node, l1ToL2MessageHash, { ...opts, messageBlockNumber }),
19
+ () => isL1ToL2MessageReady(node, l1ToL2MessageHash),
22
20
  `L1 to L2 message ${l1ToL2MessageHash.toString()} ready`,
23
21
  opts.timeoutSeconds,
24
22
  1,
@@ -29,25 +27,18 @@ export async function waitForL1ToL2MessageReady(
29
27
  * Returns whether the L1 to L2 message is ready to be consumed.
30
28
  * @param node - Aztec node instance used to obtain the information about the message
31
29
  * @param l1ToL2MessageHash - Hash of the L1 to L2 message
32
- * @param opts - Options
33
30
  * @returns True if the message is ready to be consumed, false otherwise
34
31
  */
35
32
  export async function isL1ToL2MessageReady(
36
- node: Pick<AztecNode, 'getBlockNumber' | 'getL1ToL2MessageBlock'>,
33
+ node: Pick<AztecNode, 'getBlock' | 'getL1ToL2MessageCheckpoint'>,
37
34
  l1ToL2MessageHash: Fr,
38
- opts: {
39
- /** True if the message is meant to be consumed from a public function */ forPublicConsumption: boolean;
40
- /** Cached synced block number for the message (will be fetched from PXE otherwise) */ messageBlockNumber?: number;
41
- },
42
35
  ): Promise<boolean> {
43
- const blockNumber = await node.getBlockNumber();
44
- const messageBlockNumber = opts.messageBlockNumber ?? (await node.getL1ToL2MessageBlock(l1ToL2MessageHash));
45
- if (messageBlockNumber === undefined) {
36
+ const messageCheckpointNumber = await node.getL1ToL2MessageCheckpoint(l1ToL2MessageHash);
37
+ if (messageCheckpointNumber === undefined) {
46
38
  return false;
47
39
  }
48
40
 
49
- // Note that public messages can be consumed 1 block earlier, since the sequencer will include the messages
50
- // in the L1 to L2 message tree before executing the txs for the block. In private, however, we need to wait
51
- // until the message is included so we can make use of the membership witness.
52
- return opts.forPublicConsumption ? blockNumber + 1 >= messageBlockNumber : blockNumber >= messageBlockNumber;
41
+ // L1 to L2 messages are included in the first block of a checkpoint
42
+ const latestBlock = await node.getBlock('latest');
43
+ return latestBlock !== undefined && latestBlock.checkpointNumber >= messageCheckpointNumber;
53
44
  }