@aztec/stdlib 0.82.3 → 0.83.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 (129) hide show
  1. package/dest/avm/avm.d.ts +3889 -382
  2. package/dest/avm/avm.d.ts.map +1 -1
  3. package/dest/avm/avm.js +64 -18
  4. package/dest/avm/avm_proving_request.d.ts +1610 -66
  5. package/dest/avm/avm_proving_request.d.ts.map +1 -1
  6. package/dest/block/l2_block_downloader/l2_block_stream.d.ts +9 -12
  7. package/dest/block/l2_block_downloader/l2_block_stream.d.ts.map +1 -1
  8. package/dest/block/l2_block_downloader/l2_block_stream.js +39 -11
  9. package/dest/config/config.d.ts +2 -2
  10. package/dest/config/config.d.ts.map +1 -1
  11. package/dest/config/config.js +4 -5
  12. package/dest/contract/interfaces/node-info.d.ts +2 -2
  13. package/dest/contract/interfaces/node-info.d.ts.map +1 -1
  14. package/dest/contract/interfaces/node-info.js +1 -1
  15. package/dest/interfaces/prover-client.d.ts +3 -3
  16. package/dest/interfaces/prover-client.d.ts.map +1 -1
  17. package/dest/interfaces/prover-client.js +6 -4
  18. package/dest/interfaces/proving-job.d.ts +1610 -66
  19. package/dest/interfaces/proving-job.d.ts.map +1 -1
  20. package/dest/interfaces/pxe.d.ts +7 -6
  21. package/dest/interfaces/pxe.d.ts.map +1 -1
  22. package/dest/interfaces/pxe.js +1 -1
  23. package/dest/keys/derivation.d.ts +1 -1
  24. package/dest/keys/derivation.d.ts.map +1 -1
  25. package/dest/keys/derivation.js +10 -2
  26. package/dest/logs/index.d.ts +2 -1
  27. package/dest/logs/index.d.ts.map +1 -1
  28. package/dest/logs/index.js +2 -1
  29. package/dest/logs/pending_tagged_log.d.ts +17 -0
  30. package/dest/logs/pending_tagged_log.d.ts.map +1 -0
  31. package/dest/logs/pending_tagged_log.js +45 -0
  32. package/dest/logs/{l1_payload/shared_secret_derivation.d.ts → shared_secret_derivation.d.ts} +4 -3
  33. package/dest/logs/shared_secret_derivation.d.ts.map +1 -0
  34. package/dest/logs/{l1_payload/shared_secret_derivation.js → shared_secret_derivation.js} +3 -5
  35. package/dest/logs/tx_scoped_l2_log.d.ts +6 -1
  36. package/dest/logs/tx_scoped_l2_log.d.ts.map +1 -1
  37. package/dest/logs/tx_scoped_l2_log.js +12 -4
  38. package/dest/note/note.d.ts +45 -4
  39. package/dest/note/note.d.ts.map +1 -1
  40. package/dest/note/note.js +51 -4
  41. package/dest/proofs/proof.d.ts.map +1 -1
  42. package/dest/proofs/proof.js +33 -7
  43. package/dest/snapshots/download.js +1 -1
  44. package/dest/snapshots/types.d.ts +4 -4
  45. package/dest/snapshots/types.d.ts.map +1 -1
  46. package/dest/snapshots/types.js +1 -1
  47. package/dest/snapshots/upload.d.ts +1 -1
  48. package/dest/snapshots/upload.d.ts.map +1 -1
  49. package/dest/snapshots/upload.js +1 -1
  50. package/dest/tests/factories.d.ts +10 -2
  51. package/dest/tests/factories.d.ts.map +1 -1
  52. package/dest/tests/factories.js +42 -6
  53. package/dest/tests/mocks.d.ts +2 -1
  54. package/dest/tests/mocks.d.ts.map +1 -1
  55. package/dest/tests/mocks.js +5 -1
  56. package/dest/trees/nullifier_leaf.d.ts +46 -21
  57. package/dest/trees/nullifier_leaf.d.ts.map +1 -1
  58. package/dest/trees/nullifier_leaf.js +48 -30
  59. package/dest/trees/nullifier_membership_witness.d.ts +28 -12
  60. package/dest/trees/nullifier_membership_witness.d.ts.map +1 -1
  61. package/dest/trees/protocol_contract_leaf.d.ts +0 -1
  62. package/dest/trees/protocol_contract_leaf.d.ts.map +1 -1
  63. package/dest/trees/protocol_contract_leaf.js +0 -3
  64. package/dest/trees/public_data_leaf.d.ts +46 -25
  65. package/dest/trees/public_data_leaf.d.ts.map +1 -1
  66. package/dest/trees/public_data_leaf.js +35 -30
  67. package/dest/trees/public_data_witness.d.ts +36 -18
  68. package/dest/trees/public_data_witness.d.ts.map +1 -1
  69. package/dest/trees/public_data_witness.js +6 -6
  70. package/dest/versioning/versioning.d.ts +1 -1
  71. package/dest/versioning/versioning.d.ts.map +1 -1
  72. package/dest/versioning/versioning.js +6 -6
  73. package/package.json +6 -7
  74. package/src/avm/avm.ts +74 -20
  75. package/src/block/l2_block_downloader/l2_block_stream.ts +58 -29
  76. package/src/config/config.ts +6 -6
  77. package/src/contract/interfaces/node-info.ts +3 -3
  78. package/src/interfaces/prover-client.ts +9 -7
  79. package/src/interfaces/pxe.ts +14 -7
  80. package/src/keys/derivation.ts +12 -6
  81. package/src/logs/index.ts +2 -1
  82. package/src/logs/pending_tagged_log.ts +43 -0
  83. package/src/logs/{l1_payload/shared_secret_derivation.ts → shared_secret_derivation.ts} +4 -11
  84. package/src/logs/tx_scoped_l2_log.ts +13 -4
  85. package/src/note/note.ts +61 -5
  86. package/src/proofs/proof.ts +39 -5
  87. package/src/snapshots/download.ts +1 -1
  88. package/src/snapshots/types.ts +2 -2
  89. package/src/snapshots/upload.ts +5 -3
  90. package/src/tests/factories.ts +72 -8
  91. package/src/tests/mocks.ts +7 -0
  92. package/src/trees/nullifier_leaf.ts +49 -26
  93. package/src/trees/protocol_contract_leaf.ts +0 -4
  94. package/src/trees/public_data_leaf.ts +31 -29
  95. package/src/trees/public_data_witness.ts +6 -6
  96. package/src/versioning/versioning.ts +8 -14
  97. package/dest/event/event.d.ts +0 -24
  98. package/dest/event/event.d.ts.map +0 -1
  99. package/dest/event/event.js +0 -13
  100. package/dest/event/event_metadata.d.ts +0 -38
  101. package/dest/event/event_metadata.d.ts.map +0 -1
  102. package/dest/event/event_metadata.js +0 -45
  103. package/dest/event/index.d.ts +0 -4
  104. package/dest/event/index.d.ts.map +0 -1
  105. package/dest/event/index.js +0 -3
  106. package/dest/event/l1_event_payload.d.ts +0 -52
  107. package/dest/event/l1_event_payload.d.ts.map +0 -1
  108. package/dest/event/l1_event_payload.js +0 -64
  109. package/dest/logs/l1_payload/encrypted_log_payload.d.ts +0 -50
  110. package/dest/logs/l1_payload/encrypted_log_payload.d.ts.map +0 -1
  111. package/dest/logs/l1_payload/encrypted_log_payload.js +0 -140
  112. package/dest/logs/l1_payload/encryption_util.d.ts +0 -24
  113. package/dest/logs/l1_payload/encryption_util.d.ts.map +0 -1
  114. package/dest/logs/l1_payload/encryption_util.js +0 -46
  115. package/dest/logs/l1_payload/index.d.ts +0 -3
  116. package/dest/logs/l1_payload/index.d.ts.map +0 -1
  117. package/dest/logs/l1_payload/index.js +0 -2
  118. package/dest/logs/l1_payload/payload.d.ts +0 -60
  119. package/dest/logs/l1_payload/payload.d.ts.map +0 -1
  120. package/dest/logs/l1_payload/payload.js +0 -61
  121. package/dest/logs/l1_payload/shared_secret_derivation.d.ts.map +0 -1
  122. package/src/event/event.ts +0 -16
  123. package/src/event/event_metadata.ts +0 -56
  124. package/src/event/index.ts +0 -3
  125. package/src/event/l1_event_payload.ts +0 -87
  126. package/src/logs/l1_payload/encrypted_log_payload.ts +0 -202
  127. package/src/logs/l1_payload/encryption_util.ts +0 -54
  128. package/src/logs/l1_payload/index.ts +0 -2
  129. package/src/logs/l1_payload/payload.ts +0 -73
@@ -13,17 +13,13 @@ import { z } from 'zod';
13
13
  export class PublicDataTreeLeafPreimage implements IndexedTreeLeafPreimage {
14
14
  constructor(
15
15
  /**
16
- * The slot of the leaf
16
+ * The leaf (slot, value).
17
17
  */
18
- public slot: Fr,
18
+ public leaf: PublicDataTreeLeaf,
19
19
  /**
20
- * The value of the leaf
20
+ * Next key (slot) inside the indexed tree's linked list.
21
21
  */
22
- public value: Fr,
23
- /**
24
- * Next value inside the indexed tree's linked list.
25
- */
26
- public nextSlot: Fr,
22
+ public nextKey: Fr,
27
23
  /**
28
24
  * Index of the next leaf in the indexed tree's linked list.
29
25
  */
@@ -33,22 +29,23 @@ export class PublicDataTreeLeafPreimage implements IndexedTreeLeafPreimage {
33
29
  static get schema() {
34
30
  return z
35
31
  .object({
36
- slot: schemas.Fr,
37
- value: schemas.Fr,
38
- nextSlot: schemas.Fr,
32
+ leaf: PublicDataTreeLeaf.schema,
33
+ nextKey: schemas.Fr,
39
34
  nextIndex: schemas.BigInt,
40
35
  })
41
- .transform(
42
- ({ slot, value, nextSlot, nextIndex }) => new PublicDataTreeLeafPreimage(slot, value, nextSlot, nextIndex),
43
- );
36
+ .transform(({ leaf, nextKey, nextIndex }) => new PublicDataTreeLeafPreimage(leaf, nextKey, nextIndex));
37
+ }
38
+
39
+ static get leafSchema() {
40
+ return PublicDataTreeLeaf.schema;
44
41
  }
45
42
 
46
43
  getKey(): bigint {
47
- return this.slot.toBigInt();
44
+ return this.leaf.getKey();
48
45
  }
49
46
 
50
47
  getNextKey(): bigint {
51
- return this.nextSlot.toBigInt();
48
+ return this.nextKey.toBigInt();
52
49
  }
53
50
 
54
51
  getNextIndex(): bigint {
@@ -56,7 +53,7 @@ export class PublicDataTreeLeafPreimage implements IndexedTreeLeafPreimage {
56
53
  }
57
54
 
58
55
  asLeaf(): PublicDataTreeLeaf {
59
- return new PublicDataTreeLeaf(this.slot, this.value);
56
+ return this.leaf;
60
57
  }
61
58
 
62
59
  toBuffer(): Buffer {
@@ -65,45 +62,42 @@ export class PublicDataTreeLeafPreimage implements IndexedTreeLeafPreimage {
65
62
 
66
63
  toHashInputs(): Buffer[] {
67
64
  return [
68
- Buffer.from(this.slot.toBuffer()),
69
- Buffer.from(this.value.toBuffer()),
65
+ ...this.leaf.toHashInputs(),
70
66
  Buffer.from(toBufferBE(this.nextIndex, 32)),
71
- Buffer.from(this.nextSlot.toBuffer()),
67
+ Buffer.from(this.nextKey.toBuffer()),
72
68
  ];
73
69
  }
74
70
 
75
71
  clone(): PublicDataTreeLeafPreimage {
76
- return new PublicDataTreeLeafPreimage(this.slot, this.value, this.nextSlot, this.nextIndex);
72
+ return new PublicDataTreeLeafPreimage(this.leaf.clone(), this.nextKey, this.nextIndex);
77
73
  }
78
74
 
79
75
  static random() {
80
76
  return new PublicDataTreeLeafPreimage(
81
- Fr.random(),
82
- Fr.random(),
77
+ PublicDataTreeLeaf.buildDummy(BigInt(Math.floor(Math.random() * 1000))),
83
78
  Fr.random(),
84
79
  BigInt(Math.floor(Math.random() * 1000)),
85
80
  );
86
81
  }
87
82
 
88
83
  static empty(): PublicDataTreeLeafPreimage {
89
- return new PublicDataTreeLeafPreimage(Fr.ZERO, Fr.ZERO, Fr.ZERO, 0n);
84
+ return new PublicDataTreeLeafPreimage(PublicDataTreeLeaf.empty(), Fr.ZERO, 0n);
90
85
  }
91
86
 
92
87
  static fromBuffer(buffer: Buffer | BufferReader): PublicDataTreeLeafPreimage {
93
88
  const reader = BufferReader.asReader(buffer);
94
- const slot = Fr.fromBuffer(reader);
95
- const value = Fr.fromBuffer(reader);
89
+ const value = PublicDataTreeLeaf.fromBuffer(reader);
96
90
  const nextIndex = toBigIntBE(reader.readBytes(32));
97
91
  const nextSlot = Fr.fromBuffer(reader);
98
- return new PublicDataTreeLeafPreimage(slot, value, nextSlot, nextIndex);
92
+ return new PublicDataTreeLeafPreimage(value, nextSlot, nextIndex);
99
93
  }
100
94
 
101
95
  static fromLeaf(leaf: PublicDataTreeLeaf, nextKey: bigint, nextIndex: bigint): PublicDataTreeLeafPreimage {
102
- return new PublicDataTreeLeafPreimage(leaf.slot, leaf.value, new Fr(nextKey), nextIndex);
96
+ return new PublicDataTreeLeafPreimage(leaf, new Fr(nextKey), nextIndex);
103
97
  }
104
98
 
105
99
  static clone(preimage: PublicDataTreeLeafPreimage): PublicDataTreeLeafPreimage {
106
- return new PublicDataTreeLeafPreimage(preimage.slot, preimage.value, preimage.nextSlot, preimage.nextIndex);
100
+ return preimage.clone();
107
101
  }
108
102
  }
109
103
 
@@ -130,6 +124,14 @@ export class PublicDataTreeLeaf implements IndexedTreeLeaf {
130
124
  return serializeToBuffer([this.slot, this.value]);
131
125
  }
132
126
 
127
+ clone(): PublicDataTreeLeaf {
128
+ return new PublicDataTreeLeaf(this.slot, this.value);
129
+ }
130
+
131
+ toHashInputs(): Buffer[] {
132
+ return [this.slot.toBuffer(), this.value.toBuffer()];
133
+ }
134
+
133
135
  static fromBuffer(buffer: Buffer | BufferReader) {
134
136
  const reader = BufferReader.asReader(buffer);
135
137
  return new PublicDataTreeLeaf(Fr.fromBuffer(reader), Fr.fromBuffer(reader));
@@ -50,10 +50,10 @@ export class PublicDataWitness {
50
50
  public toFields(): Fr[] {
51
51
  return [
52
52
  new Fr(this.index),
53
- new Fr(this.leafPreimage.slot),
54
- new Fr(this.leafPreimage.value),
53
+ new Fr(this.leafPreimage.leaf.slot),
54
+ new Fr(this.leafPreimage.leaf.value),
55
55
  new Fr(this.leafPreimage.nextIndex),
56
- new Fr(this.leafPreimage.nextSlot),
56
+ new Fr(this.leafPreimage.nextKey),
57
57
  ...this.siblingPath.toFields(),
58
58
  ];
59
59
  }
@@ -65,9 +65,9 @@ export class PublicDataWitness {
65
65
  // TODO(#12874): remove the stupid as string conversion by modifying ForeignCallOutput type in acvm.js
66
66
  return [
67
67
  new Fr(this.index).toString() as string,
68
- new Fr(this.leafPreimage.slot).toString() as string,
69
- new Fr(this.leafPreimage.value).toString() as string,
70
- new Fr(this.leafPreimage.nextSlot).toString() as string,
68
+ new Fr(this.leafPreimage.leaf.slot).toString() as string,
69
+ new Fr(this.leafPreimage.leaf.value).toString() as string,
70
+ new Fr(this.leafPreimage.nextKey).toString() as string,
71
71
  new Fr(this.leafPreimage.nextIndex).toString() as string,
72
72
  this.siblingPath.toFields().map(fr => fr.toString()) as string[],
73
73
  ];
@@ -16,7 +16,7 @@ export type ComponentsVersions = {
16
16
  // Note that we are using the rollup address as identifier in multiple places
17
17
  // such as the keystore, we need to change it so we can handle updates.
18
18
  l1RollupAddress: EthAddress;
19
- l2ChainVersion: number;
19
+ rollupVersion: number;
20
20
  l2ProtocolContractsTreeRoot: string;
21
21
  l2CircuitsVkTreeRoot: string;
22
22
  };
@@ -30,7 +30,7 @@ export function getComponentsVersionsFromConfig(
30
30
  return {
31
31
  l1ChainId: config.l1ChainId,
32
32
  l1RollupAddress: config.l1Contracts?.rollupAddress, // This should not be undefined, but sometimes the config lies to us and it is...
33
- l2ChainVersion: config.version,
33
+ rollupVersion: config.rollupVersion,
34
34
  l2ProtocolContractsTreeRoot: l2ProtocolContractsTreeRoot.toString(),
35
35
  l2CircuitsVkTreeRoot: l2CircuitsVkTreeRoot.toString(),
36
36
  };
@@ -50,7 +50,7 @@ export function compressComponentVersions(versions: ComponentsVersions): string
50
50
  '00',
51
51
  versions.l1ChainId,
52
52
  versions.l1RollupAddress.toString().slice(2, 10),
53
- versions.l2ChainVersion,
53
+ versions.rollupVersion,
54
54
  versions.l2ProtocolContractsTreeRoot.toString().slice(2, 10),
55
55
  versions.l2CircuitsVkTreeRoot.toString().slice(2, 10),
56
56
  ].join('-');
@@ -65,14 +65,8 @@ export class ComponentsVersionsError extends Error {
65
65
 
66
66
  /** Checks if the compressed string matches against the expected versions. Throws on mismatch. */
67
67
  export function checkCompressedComponentVersion(compressed: string, expected: ComponentsVersions) {
68
- const [
69
- versionVersion,
70
- l1ChainId,
71
- l1RollupAddress,
72
- l2ChainVersion,
73
- l2ProtocolContractsTreeRoot,
74
- l2CircuitsVkTreeRoot,
75
- ] = compressed.split('-');
68
+ const [versionVersion, l1ChainId, l1RollupAddress, rollupVersion, l2ProtocolContractsTreeRoot, l2CircuitsVkTreeRoot] =
69
+ compressed.split('-');
76
70
  if (versionVersion !== '00') {
77
71
  throw new ComponentsVersionsError('version', '00', versionVersion);
78
72
  }
@@ -82,8 +76,8 @@ export function checkCompressedComponentVersion(compressed: string, expected: Co
82
76
  if (l1RollupAddress !== expected.l1RollupAddress.toString().slice(2, 10)) {
83
77
  throw new ComponentsVersionsError(`L1 address`, expected.l1RollupAddress.toString(), l1RollupAddress);
84
78
  }
85
- if (l2ChainVersion !== expected.l2ChainVersion.toString()) {
86
- throw new ComponentsVersionsError('L2 chain version', expected.l2ChainVersion.toString(), l2ChainVersion);
79
+ if (rollupVersion !== expected.rollupVersion.toString()) {
80
+ throw new ComponentsVersionsError('L2 chain version', expected.rollupVersion.toString(), rollupVersion);
87
81
  }
88
82
  if (l2ProtocolContractsTreeRoot !== expected.l2ProtocolContractsTreeRoot.toString().slice(2, 10)) {
89
83
  throw new ComponentsVersionsError(
@@ -111,7 +105,7 @@ export function validatePartialComponentVersionsMatch(
111
105
  'l2ProtocolContractsTreeRoot',
112
106
  'l2CircuitsVkTreeRoot',
113
107
  'l1ChainId',
114
- 'l2ChainVersion',
108
+ 'rollupVersion',
115
109
  ] as const) {
116
110
  const actualValue = actual[key];
117
111
  const expectedValue = expected[key];
@@ -1,24 +0,0 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /// <reference types="node" resolution-mode="require"/>
3
- import { BufferReader } from '@aztec/foundation/serialize';
4
- import { Payload } from '../logs/l1_payload/payload.js';
5
- export declare class Event extends Payload {
6
- static get schema(): import("zod").ZodEffects<import("zod").ZodUnion<[import("zod").ZodEffects<import("zod").ZodEffects<import("zod").ZodString, string, string>, Buffer, string>, import("zod").ZodEffects<import("zod").ZodObject<{
7
- type: import("zod").ZodLiteral<"Buffer">;
8
- data: import("zod").ZodArray<import("zod").ZodNumber, "many">;
9
- }, "strip", import("zod").ZodTypeAny, {
10
- type: "Buffer";
11
- data: number[];
12
- }, {
13
- type: "Buffer";
14
- data: number[];
15
- }>, Buffer, {
16
- type: "Buffer";
17
- data: number[];
18
- }>]>, Event, string | {
19
- type: "Buffer";
20
- data: number[];
21
- }>;
22
- static fromBuffer(buffer: Buffer | BufferReader): Event;
23
- }
24
- //# sourceMappingURL=event.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../src/event/event.ts"],"names":[],"mappings":";;AACA,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAGxD,qBAAa,KAAM,SAAQ,OAAO;IAChC,WAAoB,MAAM;;;;;;;;;;;;;;;OAEzB;WAEe,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY;CAIzD"}
@@ -1,13 +0,0 @@
1
- import { Fr } from '@aztec/foundation/fields';
2
- import { BufferReader } from '@aztec/foundation/serialize';
3
- import { Payload } from '../logs/l1_payload/payload.js';
4
- import { schemas } from '../schemas/schemas.js';
5
- export class Event extends Payload {
6
- static get schema() {
7
- return schemas.Buffer.transform(Event.fromBuffer);
8
- }
9
- static fromBuffer(buffer) {
10
- const reader = BufferReader.asReader(buffer);
11
- return new Event(reader.readVector(Fr));
12
- }
13
- }
@@ -1,38 +0,0 @@
1
- import { z } from 'zod';
2
- import { type AbiType } from '../abi/abi.js';
3
- import type { EventSelector } from '../abi/event_selector.js';
4
- import type { PublicLog } from '../logs/public_log.js';
5
- import { L1EventPayload } from './l1_event_payload.js';
6
- /**
7
- * Represents metadata for an event decoder, including all information needed to reconstruct it.
8
- */
9
- export declare class EventMetadata<T> {
10
- readonly decode: (payload: L1EventPayload | PublicLog) => T | undefined;
11
- readonly eventSelector: EventSelector;
12
- readonly abiType: AbiType;
13
- readonly fieldNames: string[];
14
- constructor(event: {
15
- eventSelector: EventSelector;
16
- abiType: AbiType;
17
- fieldNames: string[];
18
- });
19
- static decodeEvent<T>(eventSelector: EventSelector, abiType: AbiType): (payload: L1EventPayload | PublicLog | undefined) => T | undefined;
20
- static get schema(): z.ZodEffects<z.ZodObject<{
21
- eventSelector: z.ZodType<EventSelector, any, string>;
22
- abiType: z.ZodType<AbiType, z.ZodTypeDef, AbiType>;
23
- fieldNames: z.ZodArray<z.ZodString, "many">;
24
- }, "strip", z.ZodTypeAny, {
25
- eventSelector: EventSelector;
26
- abiType: AbiType;
27
- fieldNames: string[];
28
- }, {
29
- eventSelector: string;
30
- abiType: AbiType;
31
- fieldNames: string[];
32
- }>, EventMetadata<unknown>, {
33
- eventSelector: string;
34
- abiType: AbiType;
35
- fieldNames: string[];
36
- }>;
37
- }
38
- //# sourceMappingURL=event_metadata.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"event_metadata.d.ts","sourceRoot":"","sources":["../../src/event/event_metadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,KAAK,OAAO,EAAiB,MAAM,eAAe,CAAC;AAE5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD;;GAEG;AACH,qBAAa,aAAa,CAAC,CAAC;IAC1B,SAAgB,MAAM,EAAE,CAAC,OAAO,EAAE,cAAc,GAAG,SAAS,KAAK,CAAC,GAAG,SAAS,CAAC;IAE/E,SAAgB,aAAa,EAAE,aAAa,CAAC;IAC7C,SAAgB,OAAO,EAAE,OAAO,CAAC;IACjC,SAAgB,UAAU,EAAE,MAAM,EAAE,CAAC;gBAEzB,KAAK,EAAE;QAAE,aAAa,EAAE,aAAa,CAAC;QAAC,OAAO,EAAE,OAAO,CAAC;QAAC,UAAU,EAAE,MAAM,EAAE,CAAA;KAAE;WAO7E,WAAW,CAAC,CAAC,EACzB,aAAa,EAAE,aAAa,EAC5B,OAAO,EAAE,OAAO,GACf,CAAC,OAAO,EAAE,cAAc,GAAG,SAAS,GAAG,SAAS,KAAK,CAAC,GAAG,SAAS;IAiBrE,MAAM,KAAK,MAAM;;;;;;;;;;;;;;;;OAQhB;CACF"}
@@ -1,45 +0,0 @@
1
- import { z } from 'zod';
2
- import { AbiTypeSchema } from '../abi/abi.js';
3
- import { decodeFromAbi } from '../abi/decoder.js';
4
- import { schemas } from '../schemas/index.js';
5
- import { L1EventPayload } from './l1_event_payload.js';
6
- /**
7
- * Represents metadata for an event decoder, including all information needed to reconstruct it.
8
- */ export class EventMetadata {
9
- decode;
10
- eventSelector;
11
- abiType;
12
- fieldNames;
13
- constructor(event){
14
- this.eventSelector = event.eventSelector;
15
- this.abiType = event.abiType;
16
- this.fieldNames = event.fieldNames;
17
- this.decode = EventMetadata.decodeEvent(event.eventSelector, event.abiType);
18
- }
19
- static decodeEvent(eventSelector, abiType) {
20
- return (payload)=>{
21
- if (payload === undefined) {
22
- return undefined;
23
- }
24
- if (payload instanceof L1EventPayload) {
25
- if (!eventSelector.equals(payload.eventTypeId)) {
26
- return undefined;
27
- }
28
- return decodeFromAbi([
29
- abiType
30
- ], payload.event.items);
31
- } else {
32
- return decodeFromAbi([
33
- abiType
34
- ], payload.log);
35
- }
36
- };
37
- }
38
- static get schema() {
39
- return z.object({
40
- eventSelector: schemas.EventSelector,
41
- abiType: AbiTypeSchema,
42
- fieldNames: z.array(z.string())
43
- }).transform((obj)=>new EventMetadata(obj));
44
- }
45
- }
@@ -1,4 +0,0 @@
1
- export * from './event.js';
2
- export * from './event_metadata.js';
3
- export * from './l1_event_payload.js';
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/event/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC"}
@@ -1,3 +0,0 @@
1
- export * from './event.js';
2
- export * from './event_metadata.js';
3
- export * from './l1_event_payload.js';
@@ -1,52 +0,0 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /// <reference types="node" resolution-mode="require"/>
3
- import { type Fq } from '@aztec/foundation/fields';
4
- import { EventSelector } from '../abi/event_selector.js';
5
- import { AztecAddress } from '../aztec-address/index.js';
6
- import type { PrivateLog } from '../logs/private_log.js';
7
- import { Event } from './event.js';
8
- /**
9
- * A class which wraps event data which is pushed on L1.
10
- */
11
- export declare class L1EventPayload {
12
- #private;
13
- /**
14
- * A event as emitted from Noir contract. Can be used along with private key to compute nullifier.
15
- */
16
- event: Event;
17
- /**
18
- * Address of the contract this tx is interacting with.
19
- */
20
- contractAddress: AztecAddress;
21
- /**
22
- * Type identifier for the underlying event, required to determine how to compute its hash and nullifier.
23
- */
24
- eventTypeId: EventSelector;
25
- constructor(
26
- /**
27
- * A event as emitted from Noir contract. Can be used along with private key to compute nullifier.
28
- */
29
- event: Event,
30
- /**
31
- * Address of the contract this tx is interacting with.
32
- */
33
- contractAddress: AztecAddress,
34
- /**
35
- * Type identifier for the underlying event, required to determine how to compute its hash and nullifier.
36
- */
37
- eventTypeId: EventSelector);
38
- static decryptAsIncoming(log: PrivateLog, sk: Fq): Promise<L1EventPayload | undefined>;
39
- /**
40
- * Serializes the L1EventPayload object into a Buffer.
41
- * @returns Buffer representation of the L1EventPayload object.
42
- */
43
- toIncomingBodyPlaintext(): Buffer;
44
- /**
45
- * Create a random L1EventPayload object (useful for testing purposes).
46
- * @param contract - The address of a contract the event was emitted from.
47
- * @returns A random L1EventPayload object.
48
- */
49
- static random(contract?: AztecAddress): Promise<L1EventPayload>;
50
- equals(other: L1EventPayload): boolean;
51
- }
52
- //# sourceMappingURL=l1_event_payload.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"l1_event_payload.d.ts","sourceRoot":"","sources":["../../src/event/l1_event_payload.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,KAAK,EAAE,EAAM,MAAM,0BAA0B,CAAC;AAGvD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC;;GAEG;AACH,qBAAa,cAAc;;IAEvB;;OAEG;IACI,KAAK,EAAE,KAAK;IACnB;;OAEG;IACI,eAAe,EAAE,YAAY;IACpC;;OAEG;IACI,WAAW,EAAE,aAAa;;IAXjC;;OAEG;IACI,KAAK,EAAE,KAAK;IACnB;;OAEG;IACI,eAAe,EAAE,YAAY;IACpC;;OAEG;IACI,WAAW,EAAE,aAAa;WAwBtB,iBAAiB,CAAC,GAAG,EAAE,UAAU,EAAE,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC;IAY5F;;;OAGG;IACH,uBAAuB;IAKvB;;;;OAIG;WACU,MAAM,CAAC,QAAQ,CAAC,EAAE,YAAY;IAIpC,MAAM,CAAC,KAAK,EAAE,cAAc;CAOpC"}
@@ -1,64 +0,0 @@
1
- import { Fr } from '@aztec/foundation/fields';
2
- import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
3
- import { EventSelector } from '../abi/event_selector.js';
4
- import { AztecAddress } from '../aztec-address/index.js';
5
- import { EncryptedLogPayload } from '../logs/l1_payload/encrypted_log_payload.js';
6
- import { Event } from './event.js';
7
- /**
8
- * A class which wraps event data which is pushed on L1.
9
- */ export class L1EventPayload {
10
- event;
11
- contractAddress;
12
- eventTypeId;
13
- constructor(/**
14
- * A event as emitted from Noir contract. Can be used along with private key to compute nullifier.
15
- */ event, /**
16
- * Address of the contract this tx is interacting with.
17
- */ contractAddress, /**
18
- * Type identifier for the underlying event, required to determine how to compute its hash and nullifier.
19
- */ eventTypeId){
20
- this.event = event;
21
- this.contractAddress = contractAddress;
22
- this.eventTypeId = eventTypeId;
23
- }
24
- static #fromIncomingBodyPlaintextAndContractAddress(plaintext, contractAddress) {
25
- let payload;
26
- try {
27
- const reader = BufferReader.asReader(plaintext);
28
- const fields = reader.readArray(plaintext.length / Fr.SIZE_IN_BYTES, Fr);
29
- const eventTypeId = EventSelector.fromField(fields[0]);
30
- const event = new Event(fields.slice(1));
31
- payload = new L1EventPayload(event, contractAddress, eventTypeId);
32
- } catch (e) {
33
- return undefined;
34
- }
35
- return payload;
36
- }
37
- static async decryptAsIncoming(log, sk) {
38
- const decryptedLog = await EncryptedLogPayload.decryptAsIncoming(log.fields, sk);
39
- if (!decryptedLog) {
40
- return undefined;
41
- }
42
- return this.#fromIncomingBodyPlaintextAndContractAddress(decryptedLog.incomingBodyPlaintext, decryptedLog.contractAddress);
43
- }
44
- /**
45
- * Serializes the L1EventPayload object into a Buffer.
46
- * @returns Buffer representation of the L1EventPayload object.
47
- */ toIncomingBodyPlaintext() {
48
- const fields = [
49
- this.eventTypeId.toField(),
50
- ...this.event.items
51
- ];
52
- return serializeToBuffer(fields);
53
- }
54
- /**
55
- * Create a random L1EventPayload object (useful for testing purposes).
56
- * @param contract - The address of a contract the event was emitted from.
57
- * @returns A random L1EventPayload object.
58
- */ static async random(contract) {
59
- return new L1EventPayload(Event.random(), contract ?? await AztecAddress.random(), EventSelector.random());
60
- }
61
- equals(other) {
62
- return this.event.equals(other.event) && this.contractAddress.equals(other.contractAddress) && this.eventTypeId.equals(other.eventTypeId);
63
- }
64
- }
@@ -1,50 +0,0 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /// <reference types="node" resolution-mode="require"/>
3
- import { Fr, type GrumpkinScalar } from '@aztec/foundation/fields';
4
- import { AztecAddress } from '../../aztec-address/index.js';
5
- import { PrivateLog } from '../private_log.js';
6
- /**
7
- * Encrypted log payload with a tag used for retrieval by clients.
8
- */
9
- export declare class EncryptedLogPayload {
10
- /**
11
- * Note discovery tag.
12
- */
13
- readonly tag: Fr;
14
- /**
15
- * Address of a contract that emitted the log.
16
- */
17
- readonly contractAddress: AztecAddress;
18
- /**
19
- * Decrypted incoming body.
20
- */
21
- readonly incomingBodyPlaintext: Buffer;
22
- constructor(
23
- /**
24
- * Note discovery tag.
25
- */
26
- tag: Fr,
27
- /**
28
- * Address of a contract that emitted the log.
29
- */
30
- contractAddress: AztecAddress,
31
- /**
32
- * Decrypted incoming body.
33
- */
34
- incomingBodyPlaintext: Buffer);
35
- generatePayload(ephSk: GrumpkinScalar, recipient: AztecAddress, rand?: (len: number) => Buffer): Promise<PrivateLog>;
36
- /**
37
- * Decrypts a ciphertext as an incoming log.
38
- *
39
- * This is executable by the recipient of the note, and uses the addressSecret to decrypt the payload.
40
- *
41
- * @param payload - The payload for the log
42
- * @param addressSecret - The address secret, used to decrypt the logs
43
- * @param ciphertextLength - Optionally supply the ciphertext length (see trimCiphertext())
44
- * @returns The decrypted log payload
45
- */
46
- static decryptAsIncoming(payload: Fr[], addressSecret: GrumpkinScalar): Promise<EncryptedLogPayload | undefined>;
47
- private static isAcceptableError;
48
- toBuffer(): Buffer;
49
- }
50
- //# sourceMappingURL=encrypted_log_payload.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"encrypted_log_payload.d.ts","sourceRoot":"","sources":["../../../src/logs/l1_payload/encrypted_log_payload.ts"],"names":[],"mappings":";;AAEA,OAAO,EAAE,EAAE,EAAE,KAAK,cAAc,EAA0B,MAAM,0BAA0B,CAAC;AAG3F,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE5D,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAuC/C;;GAEG;AACH,qBAAa,mBAAmB;IAE5B;;OAEG;aACa,GAAG,EAAE,EAAE;IACvB;;OAEG;aACa,eAAe,EAAE,YAAY;IAC7C;;OAEG;aACa,qBAAqB,EAAE,MAAM;;IAX7C;;OAEG;IACa,GAAG,EAAE,EAAE;IACvB;;OAEG;IACa,eAAe,EAAE,YAAY;IAC7C;;OAEG;IACa,qBAAqB,EAAE,MAAM;IAKlC,eAAe,CAC1B,KAAK,EAAE,cAAc,EACrB,SAAS,EAAE,YAAY,EACvB,IAAI,GAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAoB,GAC1C,OAAO,CAAC,UAAU,CAAC;IAsDtB;;;;;;;;;OASG;WACiB,iBAAiB,CACnC,OAAO,EAAE,EAAE,EAAE,EACb,aAAa,EAAE,cAAc,GAC5B,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC;IAiD3C,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAWzB,QAAQ;CAGhB"}