Skip to content

Add parameter conditions to function trigger#219

Merged
skypper merged 2 commits intomasterfrom
feat/sec-1116-function-params
Mar 4, 2026
Merged

Add parameter conditions to function trigger#219
skypper merged 2 commits intomasterfrom
feat/sec-1116-function-params

Conversation

@skypper
Copy link
Contributor

@skypper skypper commented Feb 27, 2026

Summary

  • Add typed parameters array to the function trigger filter, replacing the old unsupported
    parameter map field. Supports string (exact match) and int (eq/gt/gte/lt/lte)
    comparisons against decoded function arguments.
  • Remove the TODO and "Parameter not yet supported" error block — parameters are now fully wired
    through Validate() and ToRequest().
  • Parameters are mutually exclusive with signature (enforced via the existing
    MsgSignatureAndParameterForbidden constraint); they require name-based matching only.
  • Update the generated Conjure struct FunctionFilter to include a Parameters []ParameterCondition
    field.

Example YAML

function:
  contract:
    address: "0x..."
  name: transfer
  not: true
  parameters:
    - name: recipient
      string: "0x0000000000000000000000000000000000000000"
    - name: amount
      int:
        gte: 1000

Test plan

  • TestFunctionWithName — validates a name-only function filter round-trips correctly through
    ToRequest()
  • TestFunctionWithSignature — validates a signature-only function filter, asserts Name is nil
  • TestFunctionWithParameters — validates string and int parameters are mapped correctly in
    ToRequest()
  • TestFunctionNot — validates not: true is preserved alongside parameters
  • TestFunctionSignatureAndNameForbidden — asserts validation rejects signature + name together
  • TestFunctionSignatureAndParametersForbidden — asserts validation rejects signature + parameters
    together
  • TestFunctionMissingNameOrSignature — asserts validation rejects a function block with neither field
  • TestFunctionParameterMissingName — asserts validation rejects a parameter entry with an empty name
  • TestTransactionNot — extended to cover function parameters round-trip alongside the existing not
    assertions for all filter types

Replace the untyped Parameter field on FunctionValue with a typed
Parameters []ParameterCondValue slice, mirroring the EventEmitted
pattern. Wire parameters through ToRequest() and Validate(), and
add the Parameters field to the generated FunctionFilter struct.

Add tests covering valid configurations (name, signature, parameters,
not flag) and invalid ones (signature+name, signature+parameters,
missing name/signature, parameter without name).
@skypper skypper requested a review from g4zyn February 27, 2026 14:08
Add StrValue type with custom JSON/YAML unmarshalers to support both
plain string shorthand and expanded {exact, not} format for parameter
string comparisons.
@skypper skypper merged commit b2672ae into master Mar 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants