Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

LogUtils

Git Source

Title: LogUtils

Author: Phylax Systems

Pure utility library for matching, filtering, and decoding EVM logs returned by getLogs() or getLogsQuery(). All functions operate on in-memory PhEvm.Log structs and do not call any precompiles.

Implemented with internal functions so they inline at the call site and avoid external call overhead.

Functions

sig

Returns topic[0] of the log, or bytes32(0) if no topics.

function sig(PhEvm.Log memory log) internal pure returns (bytes32);

isSig

True if log.topics[0] == eventSig.

function isSig(PhEvm.Log memory log, bytes32 eventSig) internal pure returns (bool);

isFrom

True if log.emitter == emitter.

function isFrom(PhEvm.Log memory log, address emitter) internal pure returns (bool);

isEvent

True if log matches both emitter and eventSig.

function isEvent(PhEvm.Log memory log, address emitter, bytes32 eventSig) internal pure returns (bool);

indexedTopic

Returns topics[indexedIdx + 1] as raw bytes32. Reverts if out of bounds.

The +1 skips topic[0] (the event signature).

function indexedTopic(PhEvm.Log memory log, uint256 indexedIdx) internal pure returns (bytes32);

indexedAddress

Decodes indexed param as address.

function indexedAddress(PhEvm.Log memory log, uint256 indexedIdx) internal pure returns (address);

indexedUint

Decodes indexed param as uint256.

function indexedUint(PhEvm.Log memory log, uint256 indexedIdx) internal pure returns (uint256);

indexedBool

Decodes indexed param as bool.

function indexedBool(PhEvm.Log memory log, uint256 indexedIdx) internal pure returns (bool);

topic

Encodes address as topic-compatible bytes32 (left-pads 20 bytes to 32).

function topic(address value) internal pure returns (bytes32);

topic

Encodes uint256 as topic-compatible bytes32.

function topic(uint256 value) internal pure returns (bytes32);

first

Returns the first log matching (emitter, eventSig).

function first(PhEvm.Log[] memory logs, address emitter, bytes32 eventSig)
    internal
    pure
    returns (bool found, PhEvm.Log memory log);

Returns

NameTypeDescription
foundboolTrue if a matching log was found.
logPhEvm.LogThe first matching log, or an empty log if none found.

count

Counts logs matching (emitter, eventSig).

function count(PhEvm.Log[] memory logs, address emitter, bytes32 eventSig) internal pure returns (uint256 n);