Threshold Access Control (TACo)
  • Getting Started
    • Introduction to TACo
    • How TACo Works
    • Quickstart (Testnet)
  • For Developers
    • Integrate TACo Into Apps
      • Testnets
      • Mainnet Access
      • Mainnet Deployment
    • Ecosystem Integrations
      • OrbisDB
      • Waku
      • Waku + Codex
      • Irys
      • ComposeDB
      • Turbo
    • API
      • Encryptor Allowlist
      • Encrypt & Decrypt
      • 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
    • Blueprints & Inspiration
      • Seed phrase recovery & transfer
      • Digital Rights Management for on-chain assets
      • Trustless channels for journalists, archivists & whistleblowers
      • Crowdsourcing real-world data with trustless contribution
  • For Product Leads
    • Value Propositions
    • Capabilities & Extensions
    • 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
    • Mainnet Fees
    • Trust Assumptions
      • Mainnet Trust Disclosure (Provider Answers)
      • Mainnet Trust Model Foundation
      • Trust levers & parameter packages
  • Reference
    • Contract Addresses
    • Architecture
      • Protocol Architecture
      • Protocol Flow
      • UML Use Case Diagram
      • Porter
    • Github
    • TACo Playground
    • TACo Scan
  • For Node Operators
    • Getting Set Up
      • Minimum System Requirements
      • Run a TACo Node with Docker
    • Operations
      • TACo Node Management
      • TACo Node Recovery
      • Stake Authorization
    • Duties, Compensation & Penalties
    • Run a Porter Instance
Powered by GitBook
On this page
  • or/and operators
  • not operator
  • Nested Combinations
  • Learn more
  1. For Developers
  2. API
  3. Access Control
  4. Logical Conditions

CompoundCondition

CompoundConditon allow conditions to be combined into more complex logical statements. The logical operators allowed are or, and, and not.

or/and operators

or & and operators require >= 2 operands to be specified.

Let's take a look at this abbreviated condition example:

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

const conditionA = ...
const conditionB = ...

const aAndB = new conditions.compound.CompoundCondition({
  operator: 'and',
  operands: [conditionA, conditionB],
});

Here, we define two conditions conditionA and conditionB, and combine them into a single condition using and operator. So now, our new condition will "trigger" only when both conditionA and conditionB "trigger".

We can use two or more conditions when using and and or operators:

const allMustPass = new conditions.compound.CompoundCondition({
  operator: 'and',
  operands: [conditionA, conditionB, ..., conditionX],
});

const anyOneMustPass = new conditions.compound.CompoundCondition({
  operator: 'or',
  operands: [conditionA, conditionB, ..., conditionX],
});

Alternatively, we can use CompoundCondition.or and CompoundCondition.and short-hand methods

const allMustMatch = new conditions.compound.CompoundCondition.and([
    conditionA, conditionB, ..., conditionX],
]);

const atLeastOneMustMatch = new conditions.compound.CompoundCondition.or([
    conditionA, conditionB, ..., conditionX],
]);

not operator

The not operator only allows one operand.

For example:

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

const conditionA = ...

const notA = new conditions.compound.CompoundCondition({
  operator: 'not',
  operands: [conditionA],
});

Nested Combinations

CompoundCondition objects can be nested on itself i.e. you can create compound conditions of compound conditions.

For example:

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

const conditionA = ...
const conditionB = ...
const conditionC = ...
const conditionD = ...
const conditionE = ...

const cOrD = new conditions.compound.CompoundCondition({
  operator: 'or',
  operands: [conditionC, conditionD],
});

const notE = new conditions.compound.CompoundCondition({
  operator: 'not',
  operands: [conditionE],
});

// conditionA AND conditionB AND cOrD AND notE
overallCondition = new conditions.compound.CompoundCondition({
  operator: 'and',
  operands: [conditionA, conditionB, cOrD, notE],
});

Individual conditions within the CompoundConditioncan use different chain IDs as long as the chain IDs are supported by the domain network being used.

Learn more

  • API

PreviousLogical ConditionsNextIfThenElseCondition

Last updated 8 months ago