/* auto-generated by NAPI-RS */ /* eslint-disable */ /** Decoder for Ethereum function calls */ export declare class CallDecoder { /** Create call decoder from function signatures */ static fromSignatures(signatures: Array): CallDecoder /** Create call decoder from function signatures with checksum option */ static fromSignaturesWithChecksum(signatures: Array, checksum: boolean): CallDecoder /** Decode function call inputs asynchronously */ decodeInputs(inputs: Array): Promise | undefined | null>> /** Decode transaction inputs asynchronously */ decodeTransactionsInput(txs: Array): Promise | undefined | null>> /** Decode trace inputs asynchronously */ decodeTracesInput(traces: Array): Promise | undefined | null>> /** Decode function call inputs synchronously */ decodeInputsSync(inputs: Array): Array | undefined | null> /** Decode transaction inputs synchronously */ decodeTransactionsInputSync(txs: Array): Array | undefined | null> /** Decode trace inputs synchronously */ decodeTracesInputSync(traces: Array): Array | undefined | null> /** Decode a single input string */ decodeImpl(input: string): Array | null } /** Decoder for Ethereum events and function calls */ export declare class Decoder { /** Create decoder from event signatures */ static fromSignatures(signatures: Array): Decoder /** Create decoder from event signatures with checksum option */ static fromSignaturesWithChecksum(signatures: Array, checksum: boolean): Decoder /** Enable checksummed addresses in decoded output */ enableChecksummedAddresses(): void /** Disable checksummed addresses in decoded output */ disableChecksummedAddresses(): void /** Decode logs asynchronously */ decodeLogs(logs: Array): Promise> /** Decode logs synchronously */ decodeLogsSync(logs: Array): Array /** Decode events asynchronously */ decodeEvents(events: Array): Promise> /** Decode events synchronously */ decodeEventsSync(events: Array): Array } /** Stream for receiving event responses */ export declare class EventStream { /** Close the event stream */ close(): Promise /** Receive the next event response from the stream */ recv(): Promise } /** * Stream for receiving height stream events * yields the immediate height of the chain and then * continues to yield height updates as they are received */ export declare class HeightStream { /** Close the height stream */ close(): Promise /** Receive the next height stream event from the stream */ recv(): Promise } /** HyperSync client for querying blockchain data */ export declare class HypersyncClient { /** Create a new client with given config */ constructor(cfg: ClientConfig) /** * Create a new client with custom user agent * * This method is intended for internal use when you need to customize the user agent string. * Most users should use `new()` instead. * * @internal */ static newWithAgent(cfg: ClientConfig, userAgent: string): HypersyncClient /** Get the height of the source hypersync instance */ getHeight(): Promise /** Get the chain_id of the source hypersync instance */ getChainId(): Promise /** Collect blockchain data from the given query */ collect(query: Query, config: StreamConfig): Promise /** Collect blockchain events from the given query */ collectEvents(query: Query, config: StreamConfig): Promise /** Collect blockchain data and save to parquet format */ collectParquet(path: string, query: Query, config: StreamConfig): Promise /** Get blockchain data for a single query */ get(query: Query): Promise /** Get blockchain events for a single query */ getEvents(query: Query): Promise /** Stream chain height events */ streamHeight(): Promise /** Stream blockchain data from the given query */ stream(query: Query, config: StreamConfig): Promise /** Get blockchain data for a single query, with rate limit info */ getWithRateLimit(query: Query): Promise /** * Get the most recently observed rate limit information. * Returns null if no requests have been made yet. */ rateLimitInfo(): RateLimitInfo | null /** * Wait until the current rate limit window resets. * Returns immediately if no rate limit info observed or quota available. */ waitForRateLimit(): Promise /** Stream blockchain events from the given query */ streamEvents(query: Query, config: StreamConfig): Promise } /** Stream for receiving query responses */ export declare class QueryResponseStream { /** Close the response stream */ close(): Promise /** Receive the next query response from the stream */ recv(): Promise } /** * Evm access list object * * See ethereum rpc spec for the meaning of fields */ export interface AccessList { address?: string storageKeys?: Array } /** * Evm authorization object * * See ethereum rpc spec for the meaning of fields */ export interface Authorization { /** uint256 */ chainId: bigint /** 20-byte hex */ address: string /** uint64 */ nonce: number /** 0 | 1 */ yParity: number /** 32-byte hex */ r: string /** 32-byte hex */ s: string } /** Selection criteria for transaction authorization lists */ export interface AuthorizationSelection { /** List of chain ids to match in the transaction authorizationList */ chainId?: Array /** List of addresses to match in the transaction authorizationList */ address?: Array } /** * Evm block header object * * See ethereum rpc spec for the meaning of fields */ export interface Block { number?: number hash?: string parentHash?: string nonce?: bigint sha3Uncles?: string logsBloom?: string transactionsRoot?: string stateRoot?: string receiptsRoot?: string miner?: string difficulty?: bigint totalDifficulty?: bigint extraData?: string size?: bigint gasLimit?: bigint gasUsed?: bigint timestamp?: number uncles?: Array baseFeePerGas?: bigint blobGasUsed?: bigint excessBlobGas?: bigint parentBeaconBlockRoot?: string withdrawalsRoot?: string withdrawals?: Array l1BlockNumber?: number sendCount?: string sendRoot?: string mixHash?: string } /** Available fields for block data */ export type BlockField = 'Number'| 'Hash'| 'ParentHash'| 'Nonce'| 'Sha3Uncles'| 'LogsBloom'| 'TransactionsRoot'| 'StateRoot'| 'ReceiptsRoot'| 'Miner'| 'Difficulty'| 'TotalDifficulty'| 'ExtraData'| 'Size'| 'GasLimit'| 'GasUsed'| 'Timestamp'| 'Uncles'| 'BaseFeePerGas'| 'BlobGasUsed'| 'ExcessBlobGas'| 'ParentBeaconBlockRoot'| 'WithdrawalsRoot'| 'Withdrawals'| 'L1BlockNumber'| 'SendCount'| 'SendRoot'| 'MixHash'; /** Filter for selecting blocks based on hash and miner */ export interface BlockFilter { /** * Hash of a block, any blocks that have one of these hashes will be returned. * Empty means match all. */ hash?: Array /** * Miner address of a block, any blocks that have one of these miners will be returned. * Empty means match all. */ miner?: Array } /** Selection criteria for blocks with include and exclude filters */ export interface BlockSelection { /** Blocks that match this filter will be included */ include: BlockFilter /** Blocks that match this filter will be excluded */ exclude?: BlockFilter } /** Configuration for the hypersync client. */ export interface ClientConfig { /** HyperSync server URL. */ url: string /** HyperSync server api token. */ apiToken: string /** Milliseconds to wait for a response before timing out. Default: 30000. */ httpReqTimeoutMillis?: number /** Number of retries to attempt before returning error. Default: 12. */ maxNumRetries?: number /** Milliseconds that would be used for retry backoff increasing. Default: 500. */ retryBackoffMs?: number /** Initial wait time for request backoff. Default: 200. */ retryBaseMs?: number /** Ceiling time for request backoff. Default: 5000. */ retryCeilingMs?: number /** Enable checksum addresses in responses. */ enableChecksumAddresses?: boolean /** Query serialization format to use for HTTP requests. Default: Json. */ serializationFormat?: SerializationFormat /** Whether to use query caching when using CapnProto serialization format. */ enableQueryCaching?: boolean /** * Whether to proactively sleep when the rate limit is exhausted instead of * sending requests that will be rejected with 429. Default: true. */ proactiveRateLimitSleep?: boolean } /** * Column mapping for stream function output. * It lets you map columns you want into the DataTypes you want. */ export interface ColumnMapping { /** Mapping for block data. */ block?: Record /** Mapping for transaction data. */ transaction?: Record /** Mapping for log data. */ log?: Record /** Mapping for trace data. */ trace?: Record /** Mapping for decoded log data. */ decodedLog?: Record } export type ConnectedTag = 'Connected'; /** * DataType is an enumeration representing the different data types that can be used in the column mapping. * Each variant corresponds to a specific data type. */ export type DataType = 'Float64'| 'Float32'| 'UInt64'| 'UInt32'| 'Int64'| 'Int32'; /** Decoded EVM log */ export interface DecodedEvent { indexed: Array body: Array } export interface DecodedSolValue { val: boolean | bigint | string | Array } /** Data relating to a single event (log) */ export interface Event { /** Transaction that triggered this event */ transaction?: Transaction /** Block that this event happened in */ block?: Block /** Evm log data */ log: Log } /** Response from an event query */ export interface EventResponse { /** Current height of the source hypersync instance */ archiveHeight?: number /** * Next block to query for, the responses are paginated so, * the caller should continue the query from this block if they * didn't get responses up to the to_block they specified in the Query. */ nextBlock: number /** Total time it took the hypersync instance to execute the query. */ totalExecutionTime: number /** Response data */ data: Array /** Rollback guard, supposed to be used to detect rollbacks */ rollbackGuard?: RollbackGuard } /** Collection of events from a blockchain query */ export interface Events { /** Current height of the source hypersync instance */ archiveHeight?: number /** * Next block to query for, the responses are paginated so, * the caller should continue the query from this block if they * didn't get responses up to the to_block they specified in the Query. */ nextBlock: number /** Total time it took the hypersync instance to execute the query. */ totalExecutionTime: number /** Response data */ events: Array /** Rollback guard, supposed to be used to detect rollbacks */ rollbackGuard?: RollbackGuard } /** Selection of specific fields to return for each data type */ export interface FieldSelection { /** Block fields to include in the response */ block?: Array /** Transaction fields to include in the response */ transaction?: Array /** Log fields to include in the response */ log?: Array /** Trace fields to include in the response */ trace?: Array } export interface HeightStreamConnectedEvent { type: ConnectedTag } /** * Height stream event, switch on 'event.type' to get different payload options * * switch (event.type) { * case "Height": * console.log("Height:", event.height); * break; * case "Connected": * console.log("Connected to stream"); * break; * case "Reconnecting": * console.log("Reconnecting in", event.delayMillis, "ms", "due to error:", event.errorMsg); * break; * } */ export type HeightStreamEvent = HeightStreamHeightEvent | HeightStreamConnectedEvent | HeightStreamReconnectingEvent export interface HeightStreamHeightEvent { type: HeightTag height: number } export interface HeightStreamReconnectingEvent { type: ReconnectingTag delayMillis: number errorMsg: string } export type HeightTag = 'Height'; /** Determines format of Binary column */ export type HexOutput = /** Binary column won't be formatted as hex */ 'NoEncode'| /** Binary column would be formatted as prefixed hex i.e. 0xdeadbeef */ 'Prefixed'| /** Binary column would be formatted as non prefixed hex i.e. deadbeef */ 'NonPrefixed'; /** Mode for joining blockchain data */ export declare enum JoinMode { /** Default join mode */ Default = 0, /** Join all available data */ JoinAll = 1, /** Join no additional data */ JoinNothing = 2 } /** * Evm log object * * See ethereum rpc spec for the meaning of fields */ export interface Log { removed?: boolean logIndex?: number transactionIndex?: number transactionHash?: string blockHash?: string blockNumber?: number address?: string data?: string topics: Array } /** Available fields for log data */ export type LogField = 'Removed'| 'LogIndex'| 'TransactionIndex'| 'TransactionHash'| 'BlockHash'| 'BlockNumber'| 'Address'| 'Data'| 'Topic0'| 'Topic1'| 'Topic2'| 'Topic3'; /** Filter for selecting logs based on address and topics */ export interface LogFilter { /** * Address of the contract, any logs that has any of these addresses will be returned. * Empty means match all. */ address?: Array /** * Topics to match, each member of the top level array is another array, if the nth topic matches any * topic specified in topics[n] the log will be returned. Empty means match all. */ topics?: Array> } /** Selection criteria for logs with include and exclude filters */ export interface LogSelection { /** Logs that match this filter will be included */ include: LogFilter /** Logs that match this filter will be excluded */ exclude?: LogFilter } /** * Returns a query object for all Blocks and hashes of the Transactions within the block range * (from_block, to_block]. Also returns the block_hash and block_number fields on each Transaction * so it can be mapped to a block. If to_block is None then query runs to the head of the chain. */ export declare function presetQueryBlocksAndTransactionHashes(fromBlock: number, toBlock?: number | undefined | null): Query /** * Returns a query for all Blocks and Transactions within the block range (from_block, to_block] * If to_block is None then query runs to the head of the chain. */ export declare function presetQueryBlocksAndTransactions(fromBlock: number, toBlock?: number | undefined | null): Query /** * Returns a query object for all Logs within the block range from the given address. * If to_block is None then query runs to the head of the chain. */ export declare function presetQueryLogs(contractAddress: string, fromBlock: number, toBlock?: number | undefined | null): Query /** * Returns a query for all Logs within the block range from the given address with a * matching topic0 event signature. Topic0 is the keccak256 hash of the event signature. * If to_block is None then query runs to the head of the chain. */ export declare function presetQueryLogsOfEvent(contractAddress: string, topic0: string, fromBlock: number, toBlock?: number | undefined | null): Query /** Query for retrieving blockchain data */ export interface Query { /** The block to start the query from */ fromBlock: number /** * The block to end the query at. If not specified, the query will go until the * end of data. Exclusive, the returned range will be [from_block..to_block). * * The query will return before it reaches this target block if it hits the time limit * configured on the server. The user should continue their query by putting the * next_block field in the response into from_block field of their next query. This implements * pagination. */ toBlock?: number /** * List of log selections, these have an or relationship between them, so the query will return logs * that match any of these selections. */ logs?: Array /** * List of transaction selections, the query will return transactions that match any of these selections and * it will return transactions that are related to the returned logs. */ transactions?: Array /** * List of trace selections, the query will return traces that match any of these selections and * it will re turn traces that are related to the returned logs. */ traces?: Array /** List of block selections, the query will return blocks that match any of these selections */ blocks?: Array /** * Weather to include all blocks regardless of if they are related to a returned transaction or log. Normally * the server will return only the blocks that are related to the transaction or logs in the response. But if this * is set to true, the server will return data for all blocks in the requested range [from_block, to_block). */ includeAllBlocks?: boolean /** * Field selection. The user can select which fields they are interested in, requesting less fields will improve * query execution time and reduce the payload size so the user should always use a minimal number of fields. */ fieldSelection: FieldSelection /** * Maximum number of blocks that should be returned, the server might return more blocks than this number but * it won't overshoot by too much. */ maxNumBlocks?: number /** * Maximum number of transactions that should be returned, the server might return more transactions than this number but * it won't overshoot by too much. */ maxNumTransactions?: number /** * Maximum number of logs that should be returned, the server might return more logs than this number but * it won't overshoot by too much. */ maxNumLogs?: number /** * Maximum number of traces that should be returned, the server might return more traces than this number but * it won't overshoot by too much. */ maxNumTraces?: number /** * Selects join mode for the query, * Default: join in this order logs -> transactions -> traces -> blocks * JoinAll: join everything to everything. For example if logSelection matches log0, we get the * associated transaction of log0 and then we get associated logs of that transaction as well. Applites similarly * to blocks, traces. * JoinNothing: join nothing. */ joinMode?: JoinMode } /** Response from a blockchain query */ export interface QueryResponse { /** Current height of the source hypersync instance */ archiveHeight?: number /** * Next block to query for, the responses are paginated so, * the caller should continue the query from this block if they * didn't get responses up to the to_block they specified in the Query. */ nextBlock: number /** Total time it took the hypersync instance to execute the query. */ totalExecutionTime: number /** Response data */ data: QueryResponseData /** Rollback guard, supposed to be used to detect rollbacks */ rollbackGuard?: RollbackGuard } /** Data returned from a query response */ export interface QueryResponseData { /** Blocks returned by the query */ blocks: Array /** Transactions returned by the query */ transactions: Array /** Logs returned by the query */ logs: Array /** Traces returned by the query */ traces: Array } /** Response from a query that includes rate limit information. */ export interface QueryResponseWithRateLimit { /** * The query response data. `null` when the request was rate limited * (HTTP 429) — in that case inspect `rate_limit` and retry later. */ response?: QueryResponse /** Rate limit information from response headers. */ rateLimit: RateLimitInfo } /** Rate limit information from server response headers. */ export interface RateLimitInfo { /** Total request quota for the current window. */ limit?: number /** Remaining budget in the current window. */ remaining?: number /** Seconds until the rate limit window resets. */ resetSecs?: number /** Budget consumed per request. */ cost?: number } export type ReconnectingTag = 'Reconnecting'; export interface RollbackGuard { /** Block number of the last scanned block */ blockNumber: number /** Block timestamp of the last scanned block */ timestamp: number /** Block hash of the last scanned block */ hash: string /** * Block number of the first scanned block in memory. * * This might not be the first scanned block. It only includes blocks that are in memory (possible to be rolled back). */ firstBlockNumber: number /** * Parent hash of the first scanned block in memory. * * This might not be the first scanned block. It only includes blocks that are in memory (possible to be rolled back). */ firstParentHash: string } /** Determines query serialization format for HTTP requests. */ export type SerializationFormat = /** Use JSON serialization (default) */ 'Json'| /** Use Cap'n Proto binary serialization */ 'CapnProto'; /** * Set the log level for the underlying Rust logger. * * Accepts values like "info", "warn", "debug", "trace", "error", * or a full filter directive like "hypersync_client=debug". * If RUST_LOG env var is set, it takes precedence. * Must be called before creating any HypersyncClient. * Only the first call takes effect (logger can only init once per process). */ export declare function setLogLevel(level: string): void /** Config for hypersync event streaming. */ export interface StreamConfig { /** * Column mapping for stream function output. * It lets you map columns you want into the DataTypes you want. */ columnMapping?: ColumnMapping /** Event signature used to populate decode logs. Decode logs would be empty if set to None. */ eventSignature?: string /** Determines formatting of binary columns numbers into utf8 hex. Default: NoEncode. */ hexOutput?: HexOutput /** * Initial, deliberately-overestimated batch size used for the first wave of * requests and as a fallback before any response density is measured. Default: 1000. */ batchSize?: number /** * Optional hard cap on the number of blocks per request. Leave unset (the * default) for no cap: an over-large request is truncated by the server and * the remainder is backfilled in parallel, so overshoot self-corrects. */ maxBatchSize?: number /** Hard lower clamp on the projected block count, to avoid tiny ranges. Default: 200. */ minBatchSize?: number /** Number of async threads that would be spawned to execute different block ranges of queries. Default: 10. */ concurrency?: number /** Max number of blocks to fetch in a single request. */ maxNumBlocks?: number /** Max number of transactions to fetch in a single request. */ maxNumTransactions?: number /** Max number of logs to fetch in a single request. */ maxNumLogs?: number /** Max number of traces to fetch in a single request. */ maxNumTraces?: number /** * Target response size in bytes. Each request's block span is projected from * the most recently observed byte-density to aim each response at this size. Default: 400000. */ responseBytesTarget?: number /** * Optional cap on the bytes of fetched-but-undelivered chunks held in the * reorder buffer (consumer backpressure). Leave unset (the default) for an * adaptive cap that grows with the largest response seen. */ maxBufferedBytes?: number /** Stream data in reverse order. Default: false. */ reverse?: boolean } /** * Evm trace object * * See ethereum rpc spec for the meaning of fields */ export interface Trace { from?: string to?: string callType?: string gas?: bigint input?: string init?: string value?: bigint author?: string rewardType?: string blockHash?: string blockNumber?: number address?: string code?: string gasUsed?: bigint output?: string subtraces?: number traceAddress?: Array transactionHash?: string transactionPosition?: number type?: string error?: string actionAddress?: string balance?: bigint refundAddress?: string sighash?: string } /** Available fields for trace data */ export type TraceField = 'ActionAddress'| 'Balance'| 'RefundAddress'| 'Sighash'| 'From'| 'To'| 'CallType'| 'Gas'| 'Input'| 'Init'| 'Value'| 'Author'| 'RewardType'| 'BlockHash'| 'BlockNumber'| 'Address'| 'Code'| 'GasUsed'| 'Output'| 'Subtraces'| 'TraceAddress'| 'TransactionHash'| 'TransactionPosition'| 'Type'| 'Error'; /** Filter for selecting traces based on various criteria */ export interface TraceFilter { from?: Array to?: Array address?: Array callType?: Array rewardType?: Array type?: Array sighash?: Array } /** Selection criteria for traces with include and exclude filters */ export interface TraceSelection { /** Traces that match this filter will be included */ include: TraceFilter /** Traces that match this filter will be excluded */ exclude?: TraceFilter } /** * Evm transaction object * * See ethereum rpc spec for the meaning of fields */ export interface Transaction { blockHash?: string blockNumber?: number from?: string gas?: bigint gasPrice?: bigint hash?: string input?: string nonce?: bigint to?: string transactionIndex?: number value?: bigint v?: string r?: string s?: string yParity?: string maxPriorityFeePerGas?: bigint maxFeePerGas?: bigint chainId?: number accessList?: Array authorizationList?: Array maxFeePerBlobGas?: bigint blobVersionedHashes?: Array cumulativeGasUsed?: bigint effectiveGasPrice?: bigint gasUsed?: bigint contractAddress?: string logsBloom?: string type?: number root?: string status?: number l1Fee?: bigint l1GasPrice?: bigint l1GasUsed?: bigint l1FeeScalar?: number gasUsedForL1?: bigint blobGasPrice?: bigint blobGasUsed?: bigint depositNonce?: bigint depositReceiptVersion?: bigint l1BaseFeeScalar?: bigint l1BlobBaseFee?: bigint l1BlobBaseFeeScalar?: bigint l1BlockNumber?: number mint?: bigint sighash?: string sourceHash?: string } /** Available fields for transaction data */ export type TransactionField = 'BlockHash'| 'BlockNumber'| 'From'| 'Gas'| 'GasPrice'| 'Hash'| 'Input'| 'Nonce'| 'To'| 'TransactionIndex'| 'Value'| 'V'| 'R'| 'S'| 'YParity'| 'MaxPriorityFeePerGas'| 'MaxFeePerGas'| 'ChainId'| 'AccessList'| 'AuthorizationList'| 'MaxFeePerBlobGas'| 'BlobVersionedHashes'| 'CumulativeGasUsed'| 'EffectiveGasPrice'| 'GasUsed'| 'ContractAddress'| 'LogsBloom'| 'Type'| 'Root'| 'Status'| 'L1Fee'| 'L1BlockNumber'| 'L1GasPrice'| 'L1GasUsed'| 'L1FeeScalar'| 'L1BaseFeeScalar'| 'L1BlobBaseFee'| 'L1BlobBaseFeeScalar'| 'GasUsedForL1'| 'Sighash'| 'BlobGasPrice'| 'BlobGasUsed'| 'DepositNonce'| 'DepositReceiptVersion'| 'Mint'| 'SourceHash'; /** Filter for selecting transactions based on various criteria */ export interface TransactionFilter { /** * Address the transaction should originate from. If transaction.from matches any of these, the transaction * will be returned. Keep in mind that this has an and relationship with to filter, so each transaction should * match both of them. Empty means match all. */ from?: Array /** * Address the transaction should go to. If transaction.to matches any of these, the transaction will * be returned. Keep in mind that this has an and relationship with from filter, so each transaction should * match both of them. Empty means match all. */ to?: Array /** If first 4 bytes of transaction input matches any of these, transaction will be returned. Empty means match all. */ sighash?: Array /** If tx.status matches this it will be returned. */ status?: number /** If transaction.type matches any of these values, the transaction will be returned */ type?: Array contractAddress?: Array /** * If transaction.hash matches any of these values, the transaction will be returned. * Empty means match all. */ hash?: Array /** If transaction.authorization_list matches any of these values, the transaction will be returned. */ authorizationList?: Array } /** Selection criteria for transactions with include and exclude filters */ export interface TransactionSelection { /** Transactions that match this filter will be included */ include: TransactionFilter /** Transactions that match this filter will be excluded */ exclude?: TransactionFilter } /** * Evm withdrawal object * * See ethereum rpc spec for the meaning of fields */ export interface Withdrawal { index?: string validatorIndex?: string address?: string amount?: string }