Skip to content

PredicateLibrary

State Variables

PREDICATE_TYPE

string constant PREDICATE_TYPE = "Predicate(uint8 predicateType,bytes data)";

PREDICATE_TYPEHASH

bytes32 constant PREDICATE_TYPEHASH = keccak256(bytes(PREDICATE_TYPE));

Functions

createDigestMatchPredicate

Creates a digest match predicate.

function createDigestMatchPredicate(bytes32 hash) internal pure returns (Predicate memory);
Parameters
NameTypeDescription
hashbytes32The hash to match.
Returns
NameTypeDescription
<none>PredicateA Predicate struct with type DigestMatch and the provided hash.

createPrefixMatchPredicate

Creates a prefix match predicate.

function createPrefixMatchPredicate(bytes memory prefix) internal pure returns (Predicate memory);
Parameters
NameTypeDescription
prefixbytesThe prefix to match.
Returns
NameTypeDescription
<none>PredicateA Predicate struct with type PrefixMatch and the provided prefix.

eval

Evaluates the predicate against the given journal and journal digest.

function eval(Predicate memory predicate, bytes memory journal, bytes32 journalDigest) internal pure returns (bool);
Parameters
NameTypeDescription
predicatePredicateThe predicate to evaluate.
journalbytesThe journal to evaluate against.
journalDigestbytes32The digest of the journal.
Returns
NameTypeDescription
<none>boolTrue if the predicate is satisfied, false otherwise.

startsWith

Checks if the journal starts with the given prefix.

function startsWith(bytes memory journal, bytes memory prefix) internal pure returns (bool);
Parameters
NameTypeDescription
journalbytesThe journal to check.
prefixbytesThe prefix to check for.
Returns
NameTypeDescription
<none>boolTrue if the journal starts with the prefix, false otherwise.

eip712Digest

Computes the EIP-712 digest for the given predicate.

function eip712Digest(Predicate memory predicate) internal pure returns (bytes32);
Parameters
NameTypeDescription
predicatePredicateThe predicate to compute the digest for.
Returns
NameTypeDescription
<none>bytes32The EIP-712 digest of the predicate.