UNPKG

@hyperlane-xyz/utils

Version:

General utilities and types for the Hyperlane network

147 lines 4.54 kB
import type { SignatureLike } from '@ethersproject/bytes'; import type { BigNumber, ethers } from 'ethers'; export declare enum ProtocolType { Ethereum = "ethereum", Sealevel = "sealevel", Cosmos = "cosmos", CosmosNative = "cosmosnative", Starknet = "starknet", Radix = "radix", Aleo = "aleo", Tron = "tron", Unknown = "unknown" } export type ProtocolTypeValue = `${ProtocolType}`; export type KnownProtocolType = Exclude<ProtocolType, ProtocolType.Unknown>; export declare function isEVMLike(protocol: ProtocolType): boolean; export declare const ProtocolSmallestUnit: { ethereum: string; sealevel: string; cosmos: string; cosmosnative: string; starknet: string; radix: string; aleo: string; tron: string; unknown: string; }; /********* BASIC TYPES *********/ export type Domain = number; export type EvmChainId = number; export type ChainId = string | number; export type Address = string; export type AddressBytes32 = string; export type ChainCaip2Id = `${string}:${string}`; export type TokenCaip19Id = `${string}:${string}/${string}:${string}`; export type HexString = string; export type Numberish = number | string | bigint; export type WithAddress<T> = T & { address: Address; }; export type MerkleProof = { branch: ethers.utils.BytesLike[]; leaf: ethers.utils.BytesLike; index: number; }; /********* HYPERLANE CORE *********/ export type Announcement = { mailbox_domain: Domain; mailbox_address: Address; validator: Address; storage_location: string; }; export type Checkpoint = { root: string; index: number; mailbox_domain: Domain; merkle_tree_hook_address: Address; }; export type CheckpointWithId = { checkpoint: Checkpoint; message_id: HexString; }; export { SignatureLike }; /** * Shape of a checkpoint in S3 as published by the agent. */ export type S3CheckpointWithId = { value: CheckpointWithId; signature: SignatureLike; }; export type S3Announcement = { value: Announcement; signature: SignatureLike; }; export type S3Checkpoint = { value: Checkpoint; signature: SignatureLike; }; export type CallData = { to: Address; data: string; value?: BigNumber; }; export declare enum MessageStatus { NONE = 0, PROCESSED = 1 } export type ParsedMessage = { version: number; nonce: number; origin: number; originChain?: string; sender: string; destination: number; destinationChain?: string; recipient: string; body: string; }; export type ParsedWarpRouteMessage = { recipient: string; amount: bigint; }; export type ParsedLegacyMultisigIsmMetadata = { checkpointRoot: string; checkpointIndex: number; originMailbox: string; proof: ethers.utils.BytesLike[]; signatures: ethers.utils.BytesLike[]; validators: ethers.utils.BytesLike[]; }; export type Annotated<T> = T & { annotation?: string; }; export type ValidatorMetadataRpcEntry = { url_hash: string; host_hash: string; }; export type ValidatorMetadata = { git_sha: string; /** Current validators (agents-v1.6.0+) publish `{ url_hash, host_hash }` * entries; pre-v1.6.0 validators published a flat array of URL hash * strings. Metadata blobs are unversioned, so a rolling fleet or * historical blob can be in either shape -- narrow before use, e.g. via * `validatorMetadataRpcUrlHash`. */ rpcs?: Array<string | ValidatorMetadataRpcEntry>; /** The `additionalQuorumRpcUrls` set, reported separately from `rpcs`. */ additional_quorum_rpcs?: ValidatorMetadataRpcEntry[]; allows_public_rpcs?: boolean; }; /** The URL hash of a `ValidatorMetadata.rpcs` entry, regardless of which of the * two historical wire shapes (bare hash string, or `{ url_hash, host_hash }`) * it was serialized in. */ export declare function validatorMetadataRpcUrlHash(entry: string | ValidatorMetadataRpcEntry): string; export type ReorgEvent = { /** the merkle root built from this agent's indexed events */ localMerkleRoot: string; /** the onchain merkle root */ canonicalMerkleRoot: string; /** the index of the checkpoint when the reorg was detected * (due to a mismatch between local and canonical merkle roots) */ checkpointIndex: number; /** the timestamp when the reorg was detected, in seconds since the Unix epoch */ unixTimestamp: number; /** the reorg period configured for the agent */ reorgPeriod: string; }; //# sourceMappingURL=types.d.ts.map