SequentialCondition
Sequential conditions allow the execution of multiple conditions in order, where the outcome of one condition execution can be used by subsequent conditions. This concept is especially useful in workflows where intermediate results influence subsequent steps.
Each condition is evaluated in sequence, and if any condition in the sequence fails, the overall condition is considered as having failed.
ConditionVariable
A sequential condition is comprised of a list of ConditionVariable
objects.
The ConditionVariable
object represents a condition whose result is tied to a specific variable name, which stores the result of the execution of the condition. This variable name can be referenced by subsequent conditions in the sequence.
ConditionVariables
have two mandatory attributes:
varName
: The name of the variable used to store the execution result of the condition.condition
: AnyCondition
to evaluate, and includes allows nesting of aSequentialCondition
within itself.
For example:
In this case, the condition variable will store the current block time obtained and used by the timeCondition
in the timeValue
variable. Variable names are considered Custom Context Variables and can be referenced by using the string :<varName>
i.e. :timeValue
from this example, in subsequent conditions.
Example
In this example, the sequential condition is evaluated as follows:
conditionVariableA
is assessed by executingconditionA
, which is aContractCondition
.conditionA
will invokemethodForA
on the relevant contract, passing the validated user address as an argument.The result of this function is then checked to ensure it is not an empty byte.
If
conditionA
fails, the sequential condition is immediately marked as failed, and no further conditions are evaluated. If it succeeds, the result is stored as:value_a
, and the evaluation proceeds toconditionVariableB
.
conditionVariableB
, also aContractCondition
, invokesmethodForB
on the relevant contract, using the output fromconditionA
(:value_a
) as the argument.The result is verified to ensure it is not equal to 0.
If
conditionB
fails, the entire sequential condition is marked as failed. If it passes, the result is stored as:value_b
.
Since no further condition variables remain and both conditionA
and conditionB
have passed, the sequential condition is considered satisfied.
Individual conditions within the SequentialCondition
can use different chain IDs as long as the chain IDs are supported by the domain
network being used.
Development References
Client-side: https://github.com/nucypher/taco-web/pull/581
Server-side: https://github.com/nucypher/nucypher/pull/3500
Last updated