auradefi 0.1.2
PyPI GitHub

EvmContractReader

auradefi.sources.evm.reader · source

One eth_call per read, pinned at a block chosen at construction.

Binds the adapter seam structurally: call's name, parameter names, order and default match the protocol exactly, and this module never names that package.

__init__

__init__(self, rpc: EvmRpc, block_number: int | None = None) -> None

Bind the transport and the block pin. Performs NO I/O.

The pin is refused here even though nothing reads it until a call. A reader built around a bad pin is already wrong, and the alternative surfaces it one method later with a builtin from hex(), which is the wrong exception at the wrong moment.

Parameters

rpcrequired, EvmRpc

The EvmRpc every read goes through. One eth_call per call.

block_numberoptional, int | None, default None

The block every read is pinned at. None means latest. A report at two blocks builds two readers.

call

call(self, address: str, fn: str, args: tuple[object, ...] = ()) -> object

Return the decoded result of fn(*args) at address.

Resolves (arg_types, return_types) from SIGNATURES, falling back to () -> uint256 for an unknown zero-argument name. Builds the calldata as abi.selector(abi.function_signature(fn, arg_types)) + abi.encode(arg_types, args), posts it through rpc.eth_call(address.lower(), data, rpc.block_tag(block)), and decodes the result with abi.decode(return_types, ...). Returns the bare value when len(return_types) == 1, else the tuple.

Raises: ValidationError: on an address that is not a string, on an unknown name called with arguments, and on a known name called with the wrong number of arguments. All three are refused before any HTTP. SourceError: on a node error (a reverting call), an empty or short or over-long result, and any word that does not fit its declared type.

Parameters

addressrequired, str

The contract, lowercased on the wire.

fnrequired, str

The function NAME, not a signature. Its ABI types come from the reader's registry, and an unknown name with arguments is refused before any HTTP.

argsoptional, tuple[object, ...], default ()

The arguments, as a tuple, in declaration order.

Raises

SourceError, ValidationError