// 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 } 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 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.
   */
  lastCommitBitmap: LastCommitBitmapSchema
});
var BlockSchema = new ContainerType3({
  header: BlockHeaderSchema,
  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)
  };
}

// src/vote.ts
import { ByteVectorType as ByteVectorType4, ContainerType as ContainerType4, UintNumberType } 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 UintNumberType(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,
  BlockHeaderSchema,
  BlockSchema,
  DILITHIUM3_PUBLIC_KEY_BYTES,
  DILITHIUM3_SIGNATURE_BYTES,
  HASH_BYTES,
  HashSchema,
  LAST_COMMIT_BITMAP_BYTES,
  LAST_COMMIT_BITMAP_SLOTS,
  LastCommitBitmapSchema,
  MAX_TRANSACTIONS_PER_BLOCK,
  SignedTransactionSchema,
  SignedVoteSchema,
  TransactionBodySchema,
  Uint256Schema,
  Uint64Schema,
  VOTE_KIND_PRECOMMIT,
  VOTE_KIND_PREVOTE,
  VoteBodySchema,
  ZERO_ADDRESS_BYTES,
  ZERO_HASH,
  emptyAccount,
  emptyBlockHeader,
  emptyTransactionBody
};
//# sourceMappingURL=index.js.map