// src/primitives.ts
import { ByteVectorType, UintBigintType } from "@chainsafe/ssz";
var ADDRESS_BYTES = 20;
var HASH_BYTES = 32;
var DILITHIUM3_PUBLIC_KEY_BYTES = 1952;
var DILITHIUM3_SIGNATURE_BYTES = 3309;
var ZERO_ADDRESS_BYTES = new Uint8Array(ADDRESS_BYTES);
var ZERO_HASH = new Uint8Array(HASH_BYTES);
var AddressBytesSchema = new ByteVectorType(ADDRESS_BYTES);
var HashSchema = new ByteVectorType(HASH_BYTES);
var Uint256Schema = new UintBigintType(32);
var Uint64Schema = new UintBigintType(8);

// src/account.ts
import { ContainerType } from "@chainsafe/ssz";
var AccountSchema = new ContainerType({
  balance: Uint256Schema,
  nonce: Uint64Schema,
  codeHash: HashSchema,
  storageRoot: HashSchema
});
function emptyAccount() {
  return {
    balance: 0n,
    nonce: 0n,
    codeHash: new Uint8Array(ZERO_HASH),
    storageRoot: new Uint8Array(ZERO_HASH)
  };
}

// src/transaction.ts
import { ByteListType, ByteVectorType as ByteVectorType2, ContainerType as ContainerType2 } from "@chainsafe/ssz";
var MAX_TX_DATA_BYTES = 1048576;
var TransactionBodySchema = new ContainerType2({
  chainId: Uint64Schema,
  nonce: Uint64Schema,
  maxPriorityFeePerGas: Uint256Schema,
  maxFeePerGas: Uint256Schema,
  gasLimit: Uint64Schema,
  to: AddressBytesSchema,
  value: Uint256Schema,
  data: new ByteListType(MAX_TX_DATA_BYTES)
});
var SignedTransactionSchema = new ContainerType2({
  body: TransactionBodySchema,
  publicKey: new ByteVectorType2(DILITHIUM3_PUBLIC_KEY_BYTES),
  signature: new ByteVectorType2(DILITHIUM3_SIGNATURE_BYTES)
});

// src/block.ts
import { ByteVectorType as ByteVectorType3, ContainerType as ContainerType3, ListCompositeType, UintNumberType } from "@chainsafe/ssz";
var MAX_TRANSACTIONS_PER_BLOCK = 1e4;
var LAST_COMMIT_BITMAP_BYTES = 16;
var LAST_COMMIT_BITMAP_SLOTS = LAST_COMMIT_BITMAP_BYTES * 8;
var LastCommitBitmapSchema = new ByteVectorType3(LAST_COMMIT_BITMAP_BYTES);
var LAST_COMMIT_MAX_SIGS = LAST_COMMIT_BITMAP_SLOTS;
var LastCommitSigSchema = new ContainerType3({
  /** Index into the h-1 committee (deterministic committee order). */
  validatorIdx: new UintNumberType(1),
  /** Dilithium3 public key of the signing validator. Verifiers use it directly rather than
   *  incurring a per-block staking-contract state read. Bloat is real (1952 B per slot) but
   *  acceptable at v1 committee cap; sig aggregation is a separate design. */
  publicKey: new ByteVectorType3(DILITHIUM3_PUBLIC_KEY_BYTES),
  /** Dilithium3 signature over the (precommit, chainId, h-1, round, blockHash, validator) vote body. */
  signature: new ByteVectorType3(DILITHIUM3_SIGNATURE_BYTES)
});
var LastCommitSchema = new ContainerType3({
  /** Block hash of h-1 that the signatures below commit to. */
  blockHash: HashSchema,
  /** Round at which h-1 was finalized (part of the vote-signing domain). */
  round: Uint64Schema,
  /** Per-signer precommit signatures. Sparse — only present signers. */
  signatures: new ListCompositeType(LastCommitSigSchema, LAST_COMMIT_MAX_SIGS)
});
var BlockHeaderSchema = new ContainerType3({
  parentHash: HashSchema,
  stateRoot: HashSchema,
  transactionsRoot: HashSchema,
  receiptsRoot: HashSchema,
  number: Uint64Schema,
  timestamp: Uint64Schema,
  gasLimit: Uint64Schema,
  gasUsed: Uint64Schema,
  baseFeePerGas: Uint256Schema,
  proposer: AddressBytesSchema,
  /**
   * Bitmap of which validators in the PRIOR block's committee precommitted
   * the prior block. Bit `i` is 1 iff committee[i] (in deterministic order)
   * had a precommit observed by this block's producer. Used by the rewards
   * distributor to credit only validators who actually signed — the
   * "auto-liveness" mechanism. Empty (all-zero) for block 1, since there
   * is no prior block.
   *
   * TRANSITIONAL (2026-07-02): kept in the header while the block-builder
   * and apply-path migrate to reading signers from `block.lastCommit`.
   * Slated for removal once every caller reads from `lastCommit` — see
   * task #315 / notes/last-commit-cert-design-2026-07-01.md.
   */
  lastCommitBitmap: LastCommitBitmapSchema,
  /**
   * hashTreeRoot of the `lastCommit` field on the block. Binds the
   * signature set into the block header so that a block with the wrong
   * `lastCommit` fails hash verification.
   */
  lastCommitHash: HashSchema
});
var BlockSchema = new ContainerType3({
  header: BlockHeaderSchema,
  transactions: new ListCompositeType(SignedTransactionSchema, MAX_TRANSACTIONS_PER_BLOCK),
  lastCommit: LastCommitSchema
});
function emptyLastCommit() {
  return {
    blockHash: new Uint8Array(32),
    round: 0n,
    signatures: []
  };
}
var AuraBlockHeaderSchema = new ContainerType3({
  parentHash: HashSchema,
  stateRoot: HashSchema,
  transactionsRoot: HashSchema,
  receiptsRoot: HashSchema,
  number: Uint64Schema,
  slot: Uint64Schema,
  timestamp: Uint64Schema,
  gasLimit: Uint64Schema,
  gasUsed: Uint64Schema,
  baseFeePerGas: Uint256Schema,
  proposer: AddressBytesSchema
});
var AuraBlockSchema = new ContainerType3({
  header: AuraBlockHeaderSchema,
  transactions: new ListCompositeType(SignedTransactionSchema, MAX_TRANSACTIONS_PER_BLOCK)
});

// src/genesis-helpers.ts
function emptyTransactionBody() {
  return {
    chainId: 0n,
    nonce: 0n,
    maxPriorityFeePerGas: 0n,
    maxFeePerGas: 0n,
    gasLimit: 0n,
    to: new Uint8Array(ZERO_ADDRESS_BYTES),
    value: 0n,
    data: new Uint8Array(0)
  };
}
function emptyBlockHeader() {
  return {
    parentHash: new Uint8Array(ZERO_HASH),
    stateRoot: new Uint8Array(ZERO_HASH),
    transactionsRoot: new Uint8Array(ZERO_HASH),
    receiptsRoot: new Uint8Array(ZERO_HASH),
    number: 0n,
    timestamp: 0n,
    gasLimit: 0n,
    gasUsed: 0n,
    baseFeePerGas: 0n,
    proposer: new Uint8Array(ZERO_ADDRESS_BYTES),
    lastCommitBitmap: new Uint8Array(16),
    lastCommitHash: new Uint8Array(32)
  };
}

// src/vote.ts
import { ByteVectorType as ByteVectorType4, ContainerType as ContainerType4, UintNumberType as UintNumberType2 } from "@chainsafe/ssz";
var VOTE_KIND_PREVOTE = 0;
var VOTE_KIND_PRECOMMIT = 1;
var VoteBodySchema = new ContainerType4({
  /** 0 = PreVote, 1 = PreCommit. uint8 so a single byte differentiates the two phases. */
  kind: new UintNumberType2(1),
  /** Chain ID, to prevent cross-chain vote replay. */
  chainId: Uint64Schema,
  /** Block number being voted on. */
  height: Uint64Schema,
  /** Consensus round within the height — increments on timeout or nil-block. */
  round: Uint64Schema,
  /**
   * Hash of the proposed block header. 32 bytes of zero is a "nil" vote,
   * meaning "I'm voting to advance the round without committing any block".
   */
  blockHash: HashSchema,
  /** Validator's 20-byte address, derivable from their public key. */
  validator: AddressBytesSchema
});
var SignedVoteSchema = new ContainerType4({
  body: VoteBodySchema,
  publicKey: new ByteVectorType4(DILITHIUM3_PUBLIC_KEY_BYTES),
  signature: new ByteVectorType4(DILITHIUM3_SIGNATURE_BYTES)
});
export {
  ADDRESS_BYTES,
  AccountSchema,
  AddressBytesSchema,
  AuraBlockHeaderSchema,
  AuraBlockSchema,
  BlockHeaderSchema,
  BlockSchema,
  DILITHIUM3_PUBLIC_KEY_BYTES,
  DILITHIUM3_SIGNATURE_BYTES,
  HASH_BYTES,
  HashSchema,
  LAST_COMMIT_BITMAP_BYTES,
  LAST_COMMIT_BITMAP_SLOTS,
  LAST_COMMIT_MAX_SIGS,
  LastCommitBitmapSchema,
  LastCommitSchema,
  LastCommitSigSchema,
  MAX_TRANSACTIONS_PER_BLOCK,
  SignedTransactionSchema,
  SignedVoteSchema,
  TransactionBodySchema,
  Uint256Schema,
  Uint64Schema,
  VOTE_KIND_PRECOMMIT,
  VOTE_KIND_PREVOTE,
  VoteBodySchema,
  ZERO_ADDRESS_BYTES,
  ZERO_HASH,
  emptyAccount,
  emptyBlockHeader,
  emptyLastCommit,
  emptyTransactionBody
};
//# sourceMappingURL=index.js.map