import type { Address } from 'abitype' import type { transactionType } from '../utils/formatters/transaction.js' import type { FeeValuesEIP1559, FeeValuesLegacy } from './fee.js' import type { Log } from './log.js' import type { Hash, Hex, Signature } from './misc.js' import type { ValueOf } from './utils.js' export type AccessList = { address: Address; storageKeys: Hex[] }[] export type TransactionType = ValueOf | (string & {}) export type TransactionReceipt< TQuantity = bigint, TIndex = number, TStatus = 'success' | 'reverted', TType = TransactionType, > = { /** Hash of block containing this transaction */ blockHash: Hash /** Number of block containing this transaction */ blockNumber: TQuantity /** Address of new contract or `null` if no contract was created */ contractAddress: Address | null /** Gas used by this and all preceding transactions in this block */ cumulativeGasUsed: TQuantity /** Pre-London, it is equal to the transaction's gasPrice. Post-London, it is equal to the actual gas price paid for inclusion. */ effectiveGasPrice: TQuantity /** Transaction sender */ from: Address /** Gas used by this transaction */ gasUsed: TQuantity /** List of log objects generated by this transaction */ logs: Log[] /** Logs bloom filter */ logsBloom: Hex /** `success` if this transaction was successful or `reverted` if it failed */ status: TStatus /** Transaction recipient or `null` if deploying a contract */ to: Address | null /** Hash of this transaction */ transactionHash: Hash /** Index of this transaction in the block */ transactionIndex: TIndex /** Transaction type */ type: TType } export type TransactionBase< TQuantity = bigint, TIndex = number, TPending extends boolean = boolean, > = { /** Hash of block containing this transaction or `null` if pending */ blockHash: TPending extends true ? null : Hash /** Number of block containing this transaction or `null` if pending */ blockNumber: TPending extends true ? null : TQuantity /** Transaction sender */ from: Address /** Gas provided for transaction execution */ gas: TQuantity /** Hash of this transaction */ hash: Hash /** Contract code or a hashed method call */ input: Hex /** Unique number identifying this transaction */ nonce: TIndex /** ECDSA signature r */ r: Hex /** ECDSA signature s */ s: Hex /** Transaction recipient or `null` if deploying a contract */ to: Address | null /** Index of this transaction in the block or `null` if pending */ transactionIndex: TPending extends true ? null : TIndex /** The type represented as hex. */ typeHex: Hex | null /** ECDSA recovery ID */ v: TQuantity /** Value in wei sent with this transaction */ value: TQuantity } export type TransactionLegacy< TQuantity = bigint, TIndex = number, TPending extends boolean = boolean, TType = 'legacy', > = TransactionBase & FeeValuesLegacy & { accessList?: never chainId?: TIndex type: TType } export type TransactionEIP2930< TQuantity = bigint, TIndex = number, TPending extends boolean = boolean, TType = 'eip2930', > = TransactionBase & FeeValuesLegacy & { accessList: AccessList chainId: TIndex type: TType } export type TransactionEIP1559< TQuantity = bigint, TIndex = number, TPending extends boolean = boolean, TType = 'eip1559', > = TransactionBase & FeeValuesEIP1559 & { accessList: AccessList chainId: TIndex type: TType } export type Transaction< TQuantity = bigint, TIndex = number, TPending extends boolean = boolean, > = | TransactionLegacy | TransactionEIP2930 | TransactionEIP1559 export type TransactionRequestBase = { /** Contract code or a hashed method call with encoded args */ data?: Hex /** Transaction sender */ from: Address /** Gas provided for transaction execution */ gas?: TQuantity /** Unique number identifying this transaction */ nonce?: TIndex /** Transaction recipient */ to?: Address /** Value in wei sent with this transaction */ value?: TQuantity } export type TransactionRequestLegacy< TQuantity = bigint, TIndex = number, TTransactionType = 'legacy', > = TransactionRequestBase & Partial> & { accessList?: never type?: TTransactionType } export type TransactionRequestEIP2930< TQuantity = bigint, TIndex = number, TTransactionType = 'eip2930', > = TransactionRequestBase & Partial> & { accessList?: AccessList type?: TTransactionType } export type TransactionRequestEIP1559< TQuantity = bigint, TIndex = number, TTransactionType = 'eip1559', > = TransactionRequestBase & Partial> & { accessList?: AccessList type?: TTransactionType } export type TransactionRequest = | TransactionRequestLegacy | TransactionRequestEIP2930 | TransactionRequestEIP1559 export type TransactionSerializedEIP1559 = `0x02${string}` export type TransactionSerializedEIP2930 = `0x01${string}` export type TransactionSerializedLegacy = Hex export type TransactionSerializedGeneric = Hex export type TransactionSerialized = TType extends 'eip1559' ? TransactionSerializedEIP1559 : TType extends 'eip2930' ? TransactionSerializedEIP2930 : TType extends 'legacy' ? TransactionSerializedLegacy : TransactionSerializedGeneric export type TransactionSerializableBase< TQuantity = bigint, TIndex = number, > = Omit, 'from'> & Partial export type TransactionSerializableLegacy< TQuantity = bigint, TIndex = number, > = TransactionSerializableBase & Partial> & { accessList?: never chainId?: number type?: 'legacy' } export type TransactionSerializableEIP2930< TQuantity = bigint, TIndex = number, > = TransactionSerializableBase & Partial> & { accessList?: AccessList chainId: number type?: 'eip2930' yParity?: number } export type TransactionSerializableEIP1559< TQuantity = bigint, TIndex = number, > = TransactionSerializableBase & Partial> & { accessList?: AccessList chainId: number type?: 'eip1559' yParity?: number } export type TransactionSerializableGeneric< TQuantity = bigint, TIndex = number, > = TransactionSerializableBase & { accessList?: AccessList chainId?: number gasPrice?: TQuantity maxFeePerGas?: TQuantity maxPriorityFeePerGas?: TQuantity type: string } export type TransactionSerializable = | TransactionSerializableLegacy | TransactionSerializableEIP2930 | TransactionSerializableEIP1559 | TransactionSerializableGeneric