UNPKG

@symbioticfi/relay-stats-ts

Version:

TypeScript library for deriving validator sets from Symbiotic network contracts

116 lines 3.7 kB
import { BooleanType, ByteVectorType, ContainerType, ListCompositeType, UintNumberType } from '@chainsafe/ssz'; import { type Hex } from 'viem'; import type { ValidatorKey, ValidatorSet } from './types.js'; declare const SszKey: ContainerType<{ Tag: UintNumberType; PayloadHash: ByteVectorType; }>; declare const SszVault: ContainerType<{ ChainId: UintNumberType; Vault: ByteVectorType; VotingPower: ByteVectorType; }>; declare const SszValidator: ContainerType<{ Operator: ByteVectorType; VotingPower: ByteVectorType; IsActive: BooleanType; Keys: ListCompositeType<ContainerType<{ Tag: UintNumberType; PayloadHash: ByteVectorType; }>>; Vaults: ListCompositeType<ContainerType<{ ChainId: UintNumberType; Vault: ByteVectorType; VotingPower: ByteVectorType; }>>; }>; declare const SszValidatorSet: ContainerType<{ Validators: ListCompositeType<ContainerType<{ Operator: ByteVectorType; VotingPower: ByteVectorType; IsActive: BooleanType; Keys: ListCompositeType<ContainerType<{ Tag: UintNumberType; PayloadHash: ByteVectorType; }>>; Vaults: ListCompositeType<ContainerType<{ ChainId: UintNumberType; Vault: ByteVectorType; VotingPower: ByteVectorType; }>>; }>>; }>; export { SszKey, SszVault, SszValidator, SszValidatorSet }; export interface ISszKey { Tag: number; PayloadHash: Uint8Array; } export interface ISszVault { ChainId: number; Vault: Uint8Array; VotingPower: Uint8Array; } export interface ISszValidator { Operator: Uint8Array; VotingPower: Uint8Array; IsActive: boolean; Keys: ISszKey[]; Vaults: ISszVault[]; } export interface ISszValidatorSet { Validators: ISszValidator[]; } /** * Convert hex string address to Uint8Array */ export declare function addressToBytes(address: string): Uint8Array; /** * Convert Uint8Array to hex string address */ export declare function bytesToAddress(bytes: Uint8Array): string; /** * Convert BigInt to 32-byte Uint8Array (big-endian) */ export declare function bigIntToBytes32(value: bigint): Uint8Array; /** * Convert 32-byte Uint8Array to BigInt */ export declare function bytes32ToBigInt(bytes: Uint8Array): bigint; /** * Convert hex string to Uint8Array */ export declare function hexToBytes(hex: string): Uint8Array; /** * Convert Uint8Array to hex string */ export declare function bytesToHex(bytes: Uint8Array): string; /** * Serialize a validator set to SSZ bytes */ export declare function serializeValidatorSet(validatorSet: ISszValidatorSet): Uint8Array; /** * Deserialize SSZ bytes to a validator set */ export declare function deserializeValidatorSet(bytes: Uint8Array): ISszValidatorSet; /** * Get the hash tree root of a validator set */ export declare function getValidatorSetRoot(validatorSet: ISszValidatorSet): Uint8Array; /** * Create a Merkle proof for a specific validator */ export declare function proveValidator(_validatorSet: ISszValidatorSet, _validatorIndex: number): Uint8Array[]; /** * Calculate key payload hash using Keccak256 (matches Go implementation) * Go equivalent: crypto.Keccak256Hash(k.Payload) */ export declare function keyPayloadHash(key: ValidatorKey): Uint8Array; /** * Convert ValidatorSet to SszValidatorSet (equivalent to validatorSetToSszValidators) */ export declare function validatorSetToSszValidators(v: ValidatorSet): ISszValidatorSet; /** * Calculate SSZ tree root and return as hex string (equivalent to sszTreeRoot) */ export declare function sszTreeRoot(v: ValidatorSet): Hex; //# sourceMappingURL=ssz.d.ts.map