IERC20LogUtils
Title: IERC20LogUtils
Author: Phylax Systems
Helpers for querying and decoding standard ERC20 logs returned by PhEvm.
Constants
TRANSFER_EVENT_SIGNATURE
Standard ERC20 Transfer event signature.
bytes32 internal constant TRANSFER_EVENT_SIGNATURE = keccak256("Transfer(address,address,uint256)")
APPROVAL_EVENT_SIGNATURE
Standard ERC20 Approval event signature.
bytes32 internal constant APPROVAL_EVENT_SIGNATURE = keccak256("Approval(address,address,uint256)")
Functions
transferQuery
Builds a PhEvm query for ERC20 Transfer logs emitted by token.
Pass address(0) to match Transfer logs from any emitter.
function transferQuery(address token) internal pure returns (PhEvm.LogQuery memory query);
approvalQuery
Builds a PhEvm query for ERC20 Approval logs emitted by token.
Pass address(0) to match Approval logs from any emitter.
function approvalQuery(address token) internal pure returns (PhEvm.LogQuery memory query);
isTransfer
Returns true when log has the canonical ERC20 Transfer event shape.
function isTransfer(PhEvm.Log memory log) internal pure returns (bool);
isApproval
Returns true when log has the canonical ERC20 Approval event shape.
function isApproval(PhEvm.Log memory log) internal pure returns (bool);
decodeTransfer
Decodes a canonical ERC20 Transfer log.
function decodeTransfer(PhEvm.Log memory log) internal pure returns (PhEvm.Erc20TransferData memory transfer);
decodeApproval
Decodes a canonical ERC20 Approval log.
function decodeApproval(PhEvm.Log memory log) internal pure returns (ApprovalData memory approval);
decodeTransfers
Decodes all logs as ERC20 Transfer events.
Reverts if any log is not a canonical Transfer event.
function decodeTransfers(PhEvm.Log[] memory logs)
internal
pure
returns (PhEvm.Erc20TransferData[] memory transfers);
decodeApprovals
Decodes all logs as ERC20 Approval events.
Reverts if any log is not a canonical Approval event.
function decodeApprovals(PhEvm.Log[] memory logs) internal pure returns (ApprovalData[] memory approvals);
_topicAddress
function _topicAddress(bytes32 topic) private pure returns (address);
Structs
ApprovalData
Decoded ERC20 Approval event data.
struct ApprovalData {
/// @notice The token contract that emitted the Approval event.
address token_addr;
/// @notice The token owner indexed in topic1.
address owner;
/// @notice The approved spender indexed in topic2.
address spender;
/// @notice The approved amount decoded from log data.
uint256 value;
}