@aztec/stdlib 5.0.0-nightly.20260414 → 5.0.0-nightly.20260416

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 (93) hide show
  1. package/dest/abi/authorization_selector.d.ts +3 -6
  2. package/dest/abi/authorization_selector.d.ts.map +1 -1
  3. package/dest/abi/event_selector.d.ts +3 -6
  4. package/dest/abi/event_selector.d.ts.map +1 -1
  5. package/dest/abi/function_selector.d.ts +3 -6
  6. package/dest/abi/function_selector.d.ts.map +1 -1
  7. package/dest/abi/function_selector.js +1 -3
  8. package/dest/abi/note_selector.d.ts +3 -6
  9. package/dest/abi/note_selector.d.ts.map +1 -1
  10. package/dest/abi/note_selector.js +1 -3
  11. package/dest/aztec-address/index.d.ts +3 -6
  12. package/dest/aztec-address/index.d.ts.map +1 -1
  13. package/dest/aztec-address/index.js +2 -4
  14. package/dest/block/block_data.d.ts +8 -8
  15. package/dest/block/block_data.d.ts.map +1 -1
  16. package/dest/block/block_data.js +2 -2
  17. package/dest/block/block_hash.d.ts +11 -10
  18. package/dest/block/block_hash.d.ts.map +1 -1
  19. package/dest/block/block_hash.js +10 -9
  20. package/dest/block/l2_block_info.d.ts +6 -5
  21. package/dest/block/l2_block_info.d.ts.map +1 -1
  22. package/dest/block/l2_block_info.js +6 -5
  23. package/dest/block/l2_block_stream/interfaces.d.ts +6 -3
  24. package/dest/block/l2_block_stream/interfaces.d.ts.map +1 -1
  25. package/dest/block/l2_block_stream/l2_tips_store_base.d.ts +1 -1
  26. package/dest/block/l2_block_stream/l2_tips_store_base.d.ts.map +1 -1
  27. package/dest/block/l2_block_stream/l2_tips_store_base.js +1 -1
  28. package/dest/block/test/l2_tips_store_test_suite.js +1 -1
  29. package/dest/config/chain-config.d.ts +1 -1
  30. package/dest/config/chain-config.d.ts.map +1 -1
  31. package/dest/config/chain-config.js +7 -1
  32. package/dest/config/sequencer-config.js +4 -4
  33. package/dest/ha-signing/local_config.js +1 -1
  34. package/dest/interfaces/merkle_tree_operations.d.ts +4 -3
  35. package/dest/interfaces/merkle_tree_operations.d.ts.map +1 -1
  36. package/dest/interfaces/prover-client.d.ts +1 -1
  37. package/dest/interfaces/prover-client.d.ts.map +1 -1
  38. package/dest/interfaces/prover-client.js +0 -3
  39. package/dest/logs/log_id.d.ts +1 -1
  40. package/dest/logs/log_id.d.ts.map +1 -1
  41. package/dest/logs/log_id.js +1 -2
  42. package/dest/logs/siloed_tag.d.ts +5 -7
  43. package/dest/logs/siloed_tag.d.ts.map +1 -1
  44. package/dest/logs/siloed_tag.js +4 -0
  45. package/dest/logs/tag.d.ts +5 -6
  46. package/dest/logs/tag.d.ts.map +1 -1
  47. package/dest/logs/tag.js +4 -0
  48. package/dest/p2p/block_proposal.d.ts +4 -6
  49. package/dest/p2p/block_proposal.d.ts.map +1 -1
  50. package/dest/p2p/block_proposal.js +2 -8
  51. package/dest/p2p/checkpoint_attestation.d.ts +4 -6
  52. package/dest/p2p/checkpoint_attestation.d.ts.map +1 -1
  53. package/dest/p2p/checkpoint_attestation.js +2 -7
  54. package/dest/p2p/checkpoint_proposal.d.ts +4 -6
  55. package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
  56. package/dest/p2p/checkpoint_proposal.js +2 -9
  57. package/dest/p2p/gossipable.d.ts +4 -4
  58. package/dest/p2p/gossipable.d.ts.map +1 -1
  59. package/dest/tx/block_header.d.ts +2 -2
  60. package/dest/tx/block_header.d.ts.map +1 -1
  61. package/dest/tx/block_header.js +1 -1
  62. package/dest/tx/indexed_tx_effect.d.ts +1 -1
  63. package/dest/tx/indexed_tx_effect.d.ts.map +1 -1
  64. package/dest/tx/indexed_tx_effect.js +1 -2
  65. package/dest/tx/tx.d.ts +3 -3
  66. package/dest/tx/tx.d.ts.map +1 -1
  67. package/package.json +8 -8
  68. package/src/abi/authorization_selector.ts +2 -8
  69. package/src/abi/event_selector.ts +2 -8
  70. package/src/abi/function_selector.ts +3 -12
  71. package/src/abi/note_selector.ts +3 -12
  72. package/src/aztec-address/index.ts +4 -10
  73. package/src/block/block_data.ts +3 -4
  74. package/src/block/block_hash.ts +21 -14
  75. package/src/block/l2_block_info.ts +8 -6
  76. package/src/block/l2_block_stream/interfaces.ts +6 -2
  77. package/src/block/l2_block_stream/l2_tips_store_base.ts +1 -1
  78. package/src/block/test/l2_tips_store_test_suite.ts +1 -1
  79. package/src/config/chain-config.ts +7 -1
  80. package/src/config/sequencer-config.ts +4 -4
  81. package/src/ha-signing/local_config.ts +1 -1
  82. package/src/interfaces/merkle_tree_operations.ts +3 -2
  83. package/src/interfaces/prover-client.ts +2 -5
  84. package/src/logs/log_id.ts +1 -2
  85. package/src/logs/siloed_tag.ts +8 -9
  86. package/src/logs/tag.ts +8 -8
  87. package/src/p2p/block_proposal.ts +11 -9
  88. package/src/p2p/checkpoint_attestation.ts +5 -9
  89. package/src/p2p/checkpoint_proposal.ts +10 -10
  90. package/src/p2p/gossipable.ts +4 -4
  91. package/src/tx/block_header.ts +2 -2
  92. package/src/tx/indexed_tx_effect.ts +1 -2
  93. package/src/tx/tx.ts +2 -2
@@ -71,7 +71,7 @@ export const proverConfigMappings: ConfigMappingsType<ProverConfig> = {
71
71
  },
72
72
  proverId: {
73
73
  env: 'PROVER_ID',
74
- parseEnv: (val?: string) => parseProverId(val),
74
+ parseEnv: (val: string) => parseProverId(val),
75
75
  description: 'Hex value that identifies the prover. Defaults to the address used for submitting proofs if not set.',
76
76
  },
77
77
  proverTestDelayType: {
@@ -117,10 +117,7 @@ export const proverConfigMappings: ConfigMappingsType<ProverConfig> = {
117
117
  },
118
118
  };
119
119
 
120
- function parseProverId(str?: string) {
121
- if (!str) {
122
- return undefined;
123
- }
120
+ function parseProverId(str: string) {
124
121
  return EthAddress.fromString(str);
125
122
  }
126
123
 
@@ -1,7 +1,6 @@
1
1
  import { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
2
2
  import { toBufferBE } from '@aztec/foundation/bigint-buffer';
3
3
  import { BlockNumber, BlockNumberSchema } from '@aztec/foundation/branded-types';
4
- import { Fr } from '@aztec/foundation/curves/bn254';
5
4
  import { BufferReader } from '@aztec/foundation/serialize';
6
5
 
7
6
  import { z } from 'zod';
@@ -83,7 +82,7 @@ export class LogId {
83
82
  const reader = BufferReader.asReader(buffer);
84
83
 
85
84
  const blockNumber = BlockNumber(reader.readNumber());
86
- const blockHash = new BlockHash(reader.readObject(Fr));
85
+ const blockHash = BlockHash.fromBuffer(reader);
87
86
  const txHash = reader.readObject(TxHash);
88
87
  const txIndex = reader.readNumber();
89
88
  const logIndex = reader.readNumber();
@@ -1,5 +1,5 @@
1
1
  import { DomainSeparator } from '@aztec/constants';
2
- import type { Fr } from '@aztec/foundation/curves/bn254';
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
3
3
  import type { ZodFor } from '@aztec/foundation/schemas';
4
4
 
5
5
  import type { AztecAddress } from '../aztec-address/index.js';
@@ -8,19 +8,14 @@ import { schemas } from '../schemas/schemas.js';
8
8
  import type { PreTag } from './pre_tag.js';
9
9
  import { Tag } from './tag.js';
10
10
 
11
- /* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */
12
-
13
- /** Branding to ensure fields are not interchangeable types. */
14
- export interface SiloedTag {
15
- /** Brand. */
16
- _branding: 'SiloedTag';
17
- }
18
-
19
11
  /**
20
12
  * Represents a tag used in private log as it "appears on the chain" - that is the tag is siloed with a contract
21
13
  * address that emitted the log.
22
14
  */
23
15
  export class SiloedTag {
16
+ /** Branding for nominal typing. */
17
+ declare private readonly _branding: 'SiloedTag';
18
+
24
19
  constructor(public readonly value: Fr) {}
25
20
 
26
21
  static async compute(preTag: PreTag): Promise<SiloedTag> {
@@ -49,6 +44,10 @@ export class SiloedTag {
49
44
  return this.value.equals(other.value);
50
45
  }
51
46
 
47
+ static random(): SiloedTag {
48
+ return new SiloedTag(Fr.random());
49
+ }
50
+
52
51
  static get schema(): ZodFor<SiloedTag> {
53
52
  return schemas.Fr.transform((fr: Fr) => new SiloedTag(fr));
54
53
  }
package/src/logs/tag.ts CHANGED
@@ -1,22 +1,18 @@
1
1
  import { poseidon2Hash } from '@aztec/foundation/crypto/poseidon';
2
- import type { Fr } from '@aztec/foundation/curves/bn254';
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
3
3
  import type { ZodFor } from '@aztec/foundation/schemas';
4
4
 
5
5
  import { schemas } from '../schemas/schemas.js';
6
6
  import type { PreTag } from './pre_tag.js';
7
7
 
8
- /* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */
9
-
10
- export interface Tag {
11
- /** Brand. */
12
- _branding: 'Tag';
13
- }
14
-
15
8
  /**
16
9
  * Represents a tag of a private log. This is not the tag that "appears" on the chain as this tag is first siloed
17
10
  * with a contract address by kernels before being included in the final log.
18
11
  */
19
12
  export class Tag {
13
+ /** Branding for nominal typing. */
14
+ declare private readonly _branding: 'Tag';
15
+
20
16
  constructor(public readonly value: Fr) {}
21
17
 
22
18
  static async compute(preTag: PreTag): Promise<Tag> {
@@ -36,6 +32,10 @@ export class Tag {
36
32
  return this.value.equals(other.value);
37
33
  }
38
34
 
35
+ static random(): Tag {
36
+ return new Tag(Fr.random());
37
+ }
38
+
39
39
  static get schema(): ZodFor<Tag> {
40
40
  return schemas.Fr.transform((fr: Fr) => new Tag(fr));
41
41
  }
@@ -1,5 +1,11 @@
1
- import { BlockNumber, type CheckpointNumber, IndexWithinCheckpoint, SlotNumber } from '@aztec/foundation/branded-types';
2
- import { Buffer32 } from '@aztec/foundation/buffer';
1
+ import {
2
+ BlockNumber,
3
+ BlockProposalHash,
4
+ type CheckpointNumber,
5
+ IndexWithinCheckpoint,
6
+ SlotNumber,
7
+ } from '@aztec/foundation/branded-types';
8
+ import { type BaseBuffer32, Buffer32 } from '@aztec/foundation/buffer';
3
9
  import { keccak256 } from '@aztec/foundation/crypto/keccak';
4
10
  import { tryRecoverAddress } from '@aztec/foundation/crypto/secp256k1-signer';
5
11
  import { Fr } from '@aztec/foundation/curves/bn254';
@@ -23,11 +29,7 @@ import {
23
29
  import { SignedTxs } from './signed_txs.js';
24
30
  import { TopicType } from './topic_type.js';
25
31
 
26
- export class BlockProposalHash extends Buffer32 {
27
- constructor(hash: Buffer) {
28
- super(hash);
29
- }
30
- }
32
+ export type { BlockProposalHash } from '@aztec/foundation/branded-types';
31
33
 
32
34
  export type BlockProposalOptions = {
33
35
  /**
@@ -77,8 +79,8 @@ export class BlockProposal extends Gossipable {
77
79
  super();
78
80
  }
79
81
 
80
- override generateP2PMessageIdentifier(): Promise<Buffer32> {
81
- return Promise.resolve(new BlockProposalHash(keccak256(this.signature.toBuffer())));
82
+ override generateP2PMessageIdentifier(): Promise<BaseBuffer32> {
83
+ return Promise.resolve(BlockProposalHash.fromBuffer(keccak256(this.signature.toBuffer())));
82
84
  }
83
85
 
84
86
  get archive(): Fr {
@@ -1,5 +1,5 @@
1
- import { SlotNumber } from '@aztec/foundation/branded-types';
2
- import { Buffer32 } from '@aztec/foundation/buffer';
1
+ import { CheckpointAttestationHash, SlotNumber } from '@aztec/foundation/branded-types';
2
+ import type { BaseBuffer32 } from '@aztec/foundation/buffer';
3
3
  import { keccak256 } from '@aztec/foundation/crypto/keccak';
4
4
  import { tryRecoverAddress } from '@aztec/foundation/crypto/secp256k1-signer';
5
5
  import type { Fr } from '@aztec/foundation/curves/bn254';
@@ -16,11 +16,7 @@ import { Gossipable } from './gossipable.js';
16
16
  import { SignatureDomainSeparator, getHashedSignaturePayloadEthSignedMessage } from './signature_utils.js';
17
17
  import { TopicType } from './topic_type.js';
18
18
 
19
- export class CheckpointAttestationHash extends Buffer32 {
20
- constructor(hash: Buffer) {
21
- super(hash);
22
- }
23
- }
19
+ export type { CheckpointAttestationHash } from '@aztec/foundation/branded-types';
24
20
 
25
21
  /**
26
22
  * CheckpointAttestation
@@ -57,8 +53,8 @@ export class CheckpointAttestation extends Gossipable {
57
53
  .transform(obj => new CheckpointAttestation(obj.payload, obj.signature, obj.proposerSignature));
58
54
  }
59
55
 
60
- override generateP2PMessageIdentifier(): Promise<Buffer32> {
61
- return Promise.resolve(new CheckpointAttestationHash(keccak256(this.signature.toBuffer())));
56
+ override generateP2PMessageIdentifier(): Promise<BaseBuffer32> {
57
+ return Promise.resolve(CheckpointAttestationHash.fromBuffer(keccak256(this.signature.toBuffer())));
62
58
  }
63
59
 
64
60
  get archive(): Fr {
@@ -1,5 +1,10 @@
1
- import { type CheckpointNumber, IndexWithinCheckpoint, SlotNumber } from '@aztec/foundation/branded-types';
2
- import { Buffer32 } from '@aztec/foundation/buffer';
1
+ import {
2
+ type CheckpointNumber,
3
+ CheckpointProposalHash,
4
+ IndexWithinCheckpoint,
5
+ SlotNumber,
6
+ } from '@aztec/foundation/branded-types';
7
+ import { type BaseBuffer32, Buffer32 } from '@aztec/foundation/buffer';
3
8
  import { keccak256 } from '@aztec/foundation/crypto/keccak';
4
9
  import { tryRecoverAddress } from '@aztec/foundation/crypto/secp256k1-signer';
5
10
  import { Fr } from '@aztec/foundation/curves/bn254';
@@ -24,12 +29,7 @@ import {
24
29
  import { SignedTxs } from './signed_txs.js';
25
30
  import { TopicType } from './topic_type.js';
26
31
 
27
- // REFACTOR(palla): Use a branded type instead of a subclass of Buffer32
28
- export class CheckpointProposalHash extends Buffer32 {
29
- constructor(hash: Buffer) {
30
- super(hash);
31
- }
32
- }
32
+ export type { CheckpointProposalHash } from '@aztec/foundation/branded-types';
33
33
 
34
34
  export type CheckpointProposalOptions = {
35
35
  /**
@@ -93,8 +93,8 @@ export class CheckpointProposal extends Gossipable {
93
93
  super();
94
94
  }
95
95
 
96
- override generateP2PMessageIdentifier(): Promise<Buffer32> {
97
- return Promise.resolve(new CheckpointProposalHash(keccak256(this.signature.toBuffer())));
96
+ override generateP2PMessageIdentifier(): Promise<BaseBuffer32> {
97
+ return Promise.resolve(CheckpointProposalHash.fromBuffer(keccak256(this.signature.toBuffer())));
98
98
  }
99
99
 
100
100
  get slotNumber(): SlotNumber {
@@ -1,4 +1,4 @@
1
- import { Buffer32 } from '@aztec/foundation/buffer';
1
+ import { BaseBuffer32 } from '@aztec/foundation/buffer';
2
2
  import { BufferReader, bigintToUInt64BE, serializeToBuffer } from '@aztec/foundation/serialize';
3
3
 
4
4
  import type { TopicType } from './topic_type.js';
@@ -46,7 +46,7 @@ export class P2PMessage {
46
46
  * Any class which extends gossipable will be able to be Gossiped over the p2p network
47
47
  */
48
48
  export abstract class Gossipable {
49
- private cachedId: Buffer32 | undefined;
49
+ private cachedId: BaseBuffer32 | undefined;
50
50
  /** The p2p topic identifier, this determines how the message is handled */
51
51
  static p2pTopic: TopicType;
52
52
 
@@ -54,7 +54,7 @@ export abstract class Gossipable {
54
54
  * A digest of the message information **used for logging only**.
55
55
  * The identifier used for deduplication is `getMsgIdFn` as defined in `encoding.ts` which is a hash over topic and data.
56
56
  */
57
- async p2pMessageLoggingIdentifier(): Promise<Buffer32> {
57
+ async p2pMessageLoggingIdentifier(): Promise<BaseBuffer32> {
58
58
  if (this.cachedId) {
59
59
  return this.cachedId;
60
60
  }
@@ -62,7 +62,7 @@ export abstract class Gossipable {
62
62
  return this.cachedId;
63
63
  }
64
64
 
65
- abstract generateP2PMessageIdentifier(): Promise<Buffer32>;
65
+ abstract generateP2PMessageIdentifier(): Promise<BaseBuffer32>;
66
66
 
67
67
  abstract toBuffer(): Buffer;
68
68
 
@@ -172,8 +172,8 @@ export class BlockHeader {
172
172
  }
173
173
 
174
174
  /** Manually set the hash for this block header if already computed */
175
- setHash(hashed: Fr) {
176
- this._cachedHash = Promise.resolve(new BlockHash(hashed));
175
+ setHash(hashed: BlockHash) {
176
+ this._cachedHash = Promise.resolve(hashed);
177
177
  }
178
178
 
179
179
  /** Recomputes the cached hash. Used for testing when header fields are mutated via unfreeze. */
@@ -1,5 +1,4 @@
1
1
  import { BlockNumber } from '@aztec/foundation/branded-types';
2
- import { Fr } from '@aztec/foundation/curves/bn254';
3
2
  import { schemas } from '@aztec/foundation/schemas';
4
3
  import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
5
4
 
@@ -27,7 +26,7 @@ export function serializeIndexedTxEffect(effect: IndexedTxEffect): Buffer {
27
26
  export function deserializeIndexedTxEffect(buffer: Buffer): IndexedTxEffect {
28
27
  const reader = BufferReader.asReader(buffer);
29
28
 
30
- const l2BlockHash = new BlockHash(reader.readObject(Fr));
29
+ const l2BlockHash = BlockHash.fromBuffer(reader);
31
30
  const l2BlockNumber = BlockNumber(reader.readNumber());
32
31
  const txIndexInBlock = reader.readNumber();
33
32
  const data = reader.readObject(TxEffect);
package/src/tx/tx.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { DA_GAS_PER_FIELD, TX_DA_GAS_OVERHEAD } from '@aztec/constants';
2
- import { Buffer32 } from '@aztec/foundation/buffer';
2
+ import { type BaseBuffer32, Buffer32 } from '@aztec/foundation/buffer';
3
3
  import { Fr } from '@aztec/foundation/curves/bn254';
4
4
  import type { ZodFor } from '@aztec/foundation/schemas';
5
5
  import { BufferReader, serializeArrayOfBufferableToVector, serializeToBuffer } from '@aztec/foundation/serialize';
@@ -64,7 +64,7 @@ export class Tx extends Gossipable {
64
64
  // docs:end:tx_class
65
65
 
66
66
  // Gossipable method
67
- override generateP2PMessageIdentifier(): Promise<Buffer32> {
67
+ override generateP2PMessageIdentifier(): Promise<BaseBuffer32> {
68
68
  return Promise.resolve(new Buffer32(this.getTxHash().toBuffer()));
69
69
  }
70
70