import type { Address } from 'abitype' import type { Block, BlockIdentifier, BlockNumber, BlockTag, Uncle, } from './block.js' import type { FeeHistory, FeeValues } from './fee.js' import type { Log } from './log.js' import type { Hex } from './misc.js' import type { Proof } from './proof.js' import type { TransactionEIP1559, TransactionEIP2930, TransactionEIP4844, TransactionLegacy, TransactionReceipt, TransactionRequestEIP1559, TransactionRequestEIP2930, TransactionRequestEIP4844, TransactionRequestLegacy, } from './transaction.js' import type { Omit, OneOf, PartialBy } from './utils.js' export type Index = `0x${string}` export type Quantity = `0x${string}` export type Status = '0x0' | '0x1' export type TransactionType = '0x0' | '0x1' | '0x2' | (string & {}) export type RpcBlock< blockTag extends BlockTag = BlockTag, includeTransactions extends boolean = boolean, transaction = RpcTransaction, > = Block export type RpcBlockNumber = BlockNumber export type RpcBlockIdentifier = BlockIdentifier export type RpcUncle = Uncle export type RpcFeeHistory = FeeHistory export type RpcFeeValues = FeeValues export type RpcLog = Log export type RpcProof = Proof export type RpcTransactionReceipt = TransactionReceipt< Quantity, Index, Status, TransactionType > export type RpcTransactionRequest = OneOf< | TransactionRequestLegacy | TransactionRequestEIP2930 | TransactionRequestEIP1559 | TransactionRequestEIP4844 > // `yParity` is optional on the RPC type as some nodes do not return it // for 1559 & 2930 transactions (they should!). export type RpcTransaction = OneOf< | Omit, 'typeHex'> | PartialBy< Omit, 'typeHex'>, 'yParity' > | PartialBy< Omit, 'typeHex'>, 'yParity' > | PartialBy< Omit, 'typeHex'>, 'yParity' > > type SuccessResult = { method?: undefined result: result error?: undefined } type ErrorResult = { method?: undefined result?: undefined error: error } type Subscription = { method: 'eth_subscription' error?: undefined result?: undefined params: | { subscription: string result: result error?: undefined } | { subscription: string result?: undefined error: error } } export type RpcRequest = { jsonrpc?: '2.0' | undefined method: string params?: any | undefined id?: number | undefined } export type RpcResponse = { jsonrpc: `${number}` id: number } & (SuccessResult | ErrorResult | Subscription) /** A key-value mapping of slot and storage values (supposedly 32 bytes each) */ export type RpcStateMapping = { [slots: Hex]: Hex } export type RpcAccountStateOverride = { /** Fake balance to set for the account before executing the call. <32 bytes */ balance?: Hex | undefined /** Fake nonce to set for the account before executing the call. <8 bytes */ nonce?: Hex | undefined /** Fake EVM bytecode to inject into the account before executing the call. */ code?: Hex | undefined /** Fake key-value mapping to override all slots in the account storage before executing the call. */ state?: RpcStateMapping | undefined /** Fake key-value mapping to override individual slots in the account storage before executing the call. */ stateDiff?: RpcStateMapping | undefined } export type RpcStateOverride = { [address: Address]: RpcAccountStateOverride }