@aztec/aztec.js 0.0.1-commit.27d773e65 → 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 (71) 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 +3 -3
  4. package/dest/api/contract.d.ts.map +1 -1
  5. package/dest/api/contract.js +1 -1
  6. package/dest/api/events.d.ts +11 -3
  7. package/dest/api/events.d.ts.map +1 -1
  8. package/dest/api/events.js +11 -6
  9. package/dest/contract/base_contract_interaction.d.ts +3 -3
  10. package/dest/contract/base_contract_interaction.d.ts.map +1 -1
  11. package/dest/contract/batch_call.d.ts +1 -1
  12. package/dest/contract/batch_call.d.ts.map +1 -1
  13. package/dest/contract/batch_call.js +9 -3
  14. package/dest/contract/contract_function_interaction.d.ts +5 -5
  15. package/dest/contract/contract_function_interaction.d.ts.map +1 -1
  16. package/dest/contract/contract_function_interaction.js +98 -12
  17. package/dest/contract/deploy_method.d.ts +20 -8
  18. package/dest/contract/deploy_method.d.ts.map +1 -1
  19. package/dest/contract/deploy_method.js +17 -11
  20. package/dest/contract/interaction_options.d.ts +55 -21
  21. package/dest/contract/interaction_options.d.ts.map +1 -1
  22. package/dest/contract/interaction_options.js +33 -0
  23. package/dest/contract/protocol_contracts/auth-registry.d.ts +1 -1
  24. package/dest/contract/protocol_contracts/auth-registry.d.ts.map +1 -1
  25. package/dest/contract/protocol_contracts/auth-registry.js +8 -0
  26. package/dest/contract/protocol_contracts/fee-juice.d.ts +1 -1
  27. package/dest/contract/protocol_contracts/fee-juice.d.ts.map +1 -1
  28. package/dest/contract/protocol_contracts/fee-juice.js +8 -0
  29. package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts +1 -1
  30. package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts.map +1 -1
  31. package/dest/contract/protocol_contracts/multi-call-entrypoint.js +8 -0
  32. package/dest/contract/protocol_contracts/public-checks.d.ts +1 -1
  33. package/dest/contract/protocol_contracts/public-checks.d.ts.map +1 -1
  34. package/dest/contract/protocol_contracts/public-checks.js +8 -0
  35. package/dest/fee/private_fee_payment_method.d.ts +2 -1
  36. package/dest/fee/private_fee_payment_method.d.ts.map +1 -1
  37. package/dest/fee/private_fee_payment_method.js +1 -0
  38. package/dest/fee/public_fee_payment_method.d.ts +2 -1
  39. package/dest/fee/public_fee_payment_method.d.ts.map +1 -1
  40. package/dest/fee/public_fee_payment_method.js +1 -0
  41. package/dest/utils/abi_types.d.ts +6 -1
  42. package/dest/utils/abi_types.d.ts.map +1 -1
  43. package/dest/utils/abi_types.js +1 -1
  44. package/dest/utils/authwit.d.ts +5 -5
  45. package/dest/utils/authwit.d.ts.map +1 -1
  46. package/dest/utils/authwit.js +10 -6
  47. package/dest/utils/cross_chain.d.ts +3 -8
  48. package/dest/utils/cross_chain.d.ts.map +1 -1
  49. package/dest/utils/cross_chain.js +8 -15
  50. package/dest/wallet/wallet.d.ts +75 -2
  51. package/dest/wallet/wallet.d.ts.map +1 -1
  52. package/dest/wallet/wallet.js +22 -3
  53. package/package.json +9 -9
  54. package/src/api/abi.ts +1 -0
  55. package/src/api/contract.ts +8 -1
  56. package/src/api/events.ts +16 -6
  57. package/src/contract/base_contract_interaction.ts +3 -2
  58. package/src/contract/batch_call.ts +10 -2
  59. package/src/contract/contract_function_interaction.ts +97 -19
  60. package/src/contract/deploy_method.ts +37 -26
  61. package/src/contract/interaction_options.ts +89 -23
  62. package/src/contract/protocol_contracts/auth-registry.ts +2 -0
  63. package/src/contract/protocol_contracts/fee-juice.ts +2 -0
  64. package/src/contract/protocol_contracts/multi-call-entrypoint.ts +2 -0
  65. package/src/contract/protocol_contracts/public-checks.ts +2 -0
  66. package/src/fee/private_fee_payment_method.ts +1 -0
  67. package/src/fee/public_fee_payment_method.ts +1 -0
  68. package/src/utils/abi_types.ts +7 -0
  69. package/src/utils/authwit.ts +20 -22
  70. package/src/utils/cross_chain.ts +9 -18
  71. package/src/wallet/wallet.ts +26 -1
@@ -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
  }
@@ -13,6 +13,7 @@ import { AuthWitness } from '@aztec/stdlib/auth-witness';
13
13
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
14
14
  import { type ContractInstanceWithAddress, ContractInstanceWithAddressSchema } from '@aztec/stdlib/contract';
15
15
  import { Gas } from '@aztec/stdlib/gas';
16
+ import { LogId } from '@aztec/stdlib/logs';
16
17
  import { AbiDecodedSchema, type ApiSchemaFor, optional, schemas, zodFor } from '@aztec/stdlib/schemas';
17
18
  import type { ExecutionPayload, InTx } from '@aztec/stdlib/tx';
18
19
  import {
@@ -153,6 +154,8 @@ export type EventFilterBase = {
153
154
  * Optional. If provided, it must be greater than fromBlock.
154
155
  */
155
156
  toBlock?: BlockNumber;
157
+ /** Log id after which to start fetching logs. Used for pagination. */
158
+ afterLog?: LogId;
156
159
  };
157
160
 
158
161
  /**
@@ -340,6 +343,7 @@ const EventFilterBaseSchema = z.object({
340
343
  txHash: optional(TxHash.schema),
341
344
  fromBlock: optional(BlockNumberPositiveSchema),
342
345
  toBlock: optional(BlockNumberPositiveSchema),
346
+ afterLog: optional(LogId.schema),
343
347
  });
344
348
 
345
349
  export const PrivateEventFilterSchema = EventFilterBaseSchema.extend({
@@ -492,6 +496,22 @@ export const WalletCapabilitiesSchema = z.object({
492
496
  expiresAt: optional(z.number()),
493
497
  });
494
498
 
499
+ const OffchainEffectSchema = z.object({
500
+ data: z.array(schemas.Fr),
501
+ contractAddress: schemas.AztecAddress,
502
+ });
503
+
504
+ const OffchainMessageSchema = z.object({
505
+ recipient: schemas.AztecAddress,
506
+ payload: z.array(schemas.Fr),
507
+ contractAddress: schemas.AztecAddress,
508
+ });
509
+
510
+ const OffchainOutputSchema = z.object({
511
+ offchainEffects: z.array(OffchainEffectSchema),
512
+ offchainMessages: z.array(OffchainMessageSchema),
513
+ });
514
+
495
515
  /**
496
516
  * Record of all wallet method schemas (excluding batch).
497
517
  * This is the single source of truth for method schemas - batch schemas are derived from this.
@@ -535,7 +555,12 @@ const WalletMethodSchemas = {
535
555
  sendTx: z
536
556
  .function()
537
557
  .args(ExecutionPayloadSchema, SendOptionsSchema)
538
- .returns(z.union([TxHash.schema, TxReceipt.schema])),
558
+ .returns(
559
+ z.union([
560
+ z.object({ txHash: TxHash.schema }).merge(OffchainOutputSchema),
561
+ z.object({ receipt: TxReceipt.schema }).merge(OffchainOutputSchema),
562
+ ]),
563
+ ),
539
564
  createAuthWit: z.function().args(schemas.AztecAddress, MessageHashOrIntentSchema).returns(AuthWitness.schema),
540
565
  requestCapabilities: z.function().args(AppCapabilitiesSchema).returns(WalletCapabilitiesSchema),
541
566
  };