SequentialCondition
Last updated
Last updated
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.
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
: Any to evaluate, and includes allows nesting of a SequentialCondition
within itself.
For example:
In this example, the sequential condition is evaluated as follows:
conditionA
will invoke methodForA
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 to conditionVariableB
.
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.
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 and can be referenced by using the string :<varName>
i.e. :timeValue
from this example, in subsequent conditions.
conditionVariableA
is assessed by executing conditionA
, which is a .
conditionVariableB
, also a , invokes methodForB
on the relevant contract, using the output from conditionA
(:value_a
) as the argument.
Client-side:
Server-side: