Threshold Access Control (TACo)
  • TACo (Threshold Access Control)
    • How TACo works
    • Value Propositions
  • Use cases
    • Seed phrase recovery & transfer
    • Digital Rights Management for on-chain assets
    • Trustless channels for journalists, archivists & whistleblowers
    • Crowdsourcing real-world data with trustless contribution
  • Quickstart (Testnet)
  • Integrate TACo into apps
    • Testnets
    • Mainnet Access
    • Mainnet Deployment
  • Ecosystem Integrations
    • OrbisDB
    • Waku
    • Irys
    • ComposeDB
    • Turbo
  • Encrypt & Decrypt API
  • Authentication
    • Condition Context
  • Access Control
    • TimeCondition
    • RpcCondition
    • ContractCondition
      • Use custom contract calls
      • Implement access revocation via smart contract
    • JSON Endpoint Conditions
      • JsonApiCondition
      • JsonRpcCondition
    • JWT Conditions
    • Logical Conditions
      • CompoundCondition
      • IfThenElseCondition
      • SequentialCondition
    • WIP / Feature Requests
      • Any (Major) EVM Chain Condition Support
  • Fees & Allowlists
    • Mainnet Fees
    • Encryptor Allowlist
  • Trust Assumptions
    • Mainnet Trust Disclosure (Provider Answers)
    • Mainnet Trust Model Foundation
    • Trust levers & parameter packages
  • Architecture
    • Porter
    • Contract Addresses
  • Extensions
  • API References
  • NODE OPERATOR
    • Duties, Compensation & Penalties
    • Minimum System Requirements
    • Stake Authorization
    • Run a TACo Node with Docker
    • TACo Node Management
    • TACo Node Recovery
    • Run a Porter Instance
Powered by GitBook
On this page
  • ConditionVariable
  • Example
  • Development References
  1. Access Control
  2. Logical Conditions

SequentialCondition

PreviousIfThenElseConditionNextWIP / Feature Requests

Last updated 7 months ago

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: Any to evaluate, and includes allows nesting of a SequentialCondition within itself.

For example:

import { conditions } from '@nucypher/taco';

const timeCondition = new conditions.base.time.TimeCondition({
  chain: 1,
  returnValueTest: {
    comparator: '>=',
    value: 1701428400,
  },
});

const conditionVariable = {
  varName: 'timeValue',
  condition: timeCondition,
};

Example

import { conditions } from '@nucypher/taco';

// first condition variable
const conditionA = new conditions.base.contract.ContractCondition({
  contractAddress: '0x1e988106FCe9647Bdf1E7877BF73cE8B0BAD5f97',
  method: 'methodForA',
  parameters: [':userAddress'],
  functionAbi: ...,
  chain: 1,
  returnValueTest: {
    comparator: '!=',
    value: "0x",
  },
});
const conditionVariableA = {
    varName: 'value_a',
    condition: conditionA,
};

// second condition variable
const conditionB = new conditions.base.contract.ContractCondition({
  contractAddress: '0x4838B106FCe9647Bdf1E7877BF73cE8Bc48AaD77',
  method: 'methodForB',
  parameters: [':value_a'],
  functionAbi: ...,
  chain: 1,
  returnValueTest: {
    comparator: '>',
    value: 0,
  },
});
const conditionVariableB = {
    varName: 'value_b',
    condition: conditionB,
};

// sequential condition
const sequentialCondition = new conditions.sequential.SequentialCondition({
  conditionVariables: [
     conditionVariableA,
     conditionVariableB,
  ],
});

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.

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

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:

Condition
ContractCondition
ContractCondition
https://github.com/nucypher/taco-web/pull/581
https://github.com/nucypher/nucypher/pull/3500
Custom Context Variables