Composing Modules
Last updated
Last updated
The following functions support the usage Eligibility/Toggle modules that compose other existing modules with "and"/"or" logical operations. Check out the documentation to learn more.
Create a new eligibilities chain module.
Arguments:
account
- Viem account (Address for JSON-RPC accounts or Account for other types).
hatId
- The hat ID for which the module is created.
numClauses
- Number of conjunction clauses.
clausesLengths
- Length of each clause.
modules
- Array of module instances to chain, at the order corresponding to the provided clauses.
saltNonce
- Optional salt nonce to use. If not provided, will be randomly generated.
Response:
status
- "success" if transaction was successful, "reverted" if transaction reverted.
transactionHash
- transaction's hash.
newInstance
- In case of success, the address of the new chain module instance.
Create a new toggles chain module.
Arguments:
account
- Viem account (Address for JSON-RPC accounts or Account for other types).
hatId
- The hat ID for which the module is created.
numClauses
- Number of conjunction clauses.
clausesLengths
- Length of each clause.
modules
- Array of module instances to chain, at the order corresponding to the provided clauses.
saltNonce
- Optional salt nonce to use. If not provided, will be randomly generated.
Response:
status
- "success" if transaction was successful, "reverted" if transaction reverted.
transactionHash
- transaction's hash.
newInstance
- In case of success, the address of the new chain module instance.
The following functions support reading from chain module instances.
Get the rulesets of a module instance.
A ruleset is an array of modules which are chained together with an "AND" logical operator. If the module is a chain with multiple rulesets, then these rulesets are chained together with an "OR" logical operator.
If the provided address is a single module instance (not a chain), then the result will be a single ruleset, which will consist of the single module instance.
Arguments:
Instance address.
Response:
Get the rulesets of multiple module instances.
A ruleset is an array of modules which are chained together with an "AND" logical operator. If the module is a chain with multiple rulesets, then these rulesets are chained together with an "OR" logical operator.
If the provided address is a single module instance (not a chain), then the result will be a single ruleset, which will consist of the single module instance.
Arguments:
Array of instance addresses.
Response:
Check whether a module instance is a modules chain.
Arguments:
Instance address.
Response:
true
if the instance is a chain, false
otherwise.
Check whether multiple module instances are modules chains.
Arguments:
Instance addresses.
Response:
For each instance, true
if the instance is a chain, false
otherwise.
The module's , or undefined
if the provided address is not a module.
For each module instance, returns the module's , or undefined
if the provided address is not a module.