Documentation Index
Fetch the complete documentation index at: https://docs.forterulesengine.io/llms.txt
Use this file to discover all available pages before exploring further.
Defined in: src/modules/rules-engine.ts:139
Methods
addAdminToPermissionList()
addAdminToPermissionList(foreignCallAddress, functionSelector, policyAdminToAdd): Promise<{ result: number; transactionHash: `0x${string}`; }>
Defined in: src/modules/rules-engine.ts:789
Adds a new address to the permission list for a foreign call.
Parameters
| Parameter | Type | Description |
|---|
foreignCallAddress | `0x${string}` | the address of the contract the foreign call belongs to. |
functionSelector | string | The selector for the specific foreign call |
policyAdminToAdd | `0x${string}` | The address of the admin to add to the list |
Returns
Promise<{ result: number; transactionHash: `0x${string}`; }>
Object with result (0 if successful, -1 if error) and transactionHash.
Throws
Will log an error to the console if the operation fails.
addClosedPolicySubscriber()
addClosedPolicySubscriber(policyId, subscriber): Promise<{ result: number; transactionHash: `0x${string}`; }>
Defined in: src/modules/rules-engine.ts:477
Adds a subscriber to the closed policy.
Parameters
| Parameter | Type | Description |
|---|
policyId | number | The ID of the policy to add to. |
subscriber | `0x${string}` | The address of the subscriber to add. |
Returns
Promise<{ result: number; transactionHash: `0x${string}`; }>
Object with result (0 if successful, -1 if error) and transactionHash.
addMultipleAdminsToPermissionList()
addMultipleAdminsToPermissionList(foreignCallAddress, functionSelector, policyAdminsToAdd): Promise<{ result: number; transactionHash: `0x${string}`; }>
Defined in: src/modules/rules-engine.ts:814
Adds multiple addresses to the permission list for a foreign call.
Parameters
| Parameter | Type | Description |
|---|
foreignCallAddress | `0x${string}` | the address of the contract the foreign call belongs to. |
functionSelector | string | The selector for the specific foreign call |
policyAdminsToAdd | `0x${string}`[] | The addresses of the admins to add to the list |
Returns
Promise<{ result: number; transactionHash: `0x${string}`; }>
Object with result (0 if successful, -1 if error) and transactionHash.
Throws
Will log an error to the console if the operation fails.
appendPolicy()
appendPolicy(policyId, contractAddressForPolicy): void
Defined in: src/modules/rules-engine.ts:335
Appends a policy to the list of policies applied to a specific contract address.
Parameters
| Parameter | Type | Description |
|---|
policyId | number | The ID of the policy to apply. |
contractAddressForPolicy | `0x${string}` | The address of the contract to which the policy will be applied. |
Returns
void
cementPolicy()
cementPolicy(policyId): Promise<{ result: number; transactionHash: `0x${string}`; }>
Defined in: src/modules/rules-engine.ts:1502
Cements a policy on the Rules Engine.
Parameters
| Parameter | Type | Description |
|---|
policyId | number | The ID of the policy to cement. |
Returns
Promise<{ result: number; transactionHash: `0x${string}`; }>
Object with result (0 if successful, -1 if error) and transactionHash.
closePolicy()
closePolicy(policyId): Promise<{ result: number; transactionHash: `0x${string}`; }>
Defined in: src/modules/rules-engine.ts:446
Closes a policy on the Rules Engine.
Parameters
| Parameter | Type | Description |
|---|
policyId | number | The ID of the policy to close. |
Returns
Promise<{ result: number; transactionHash: `0x${string}`; }>
Object with result (0 if successful, -1 if error) and transactionHash.
confirmNewCallingContractAdmin()
confirmNewCallingContractAdmin(callingContractAddress): void
Defined in: src/modules/rules-engine.ts:1353
Confirm a new calling contract admin in the rules engine admin contract.
This function confirms a new admin for a specific calling contract.
Parameters
| Parameter | Type | Description |
|---|
callingContractAddress | `0x${string}` | The address of the calling contract to set the admin for. |
Returns
void
A promise that resolves to the result of the contract interaction, or -1 if unsuccessful.
Throws
Will retry indefinitely on contract interaction failure, with a delay between attempts.
confirmNewForeignCallAdmin()
confirmNewForeignCallAdmin(foreignCallAddress, foreignCallSelector): void
Defined in: src/modules/rules-engine.ts:1436
Confirm a new foreign call admin in the rules engine admin contract.
This function confirms a new admin for a specific foreign call.
Parameters
| Parameter | Type | Description |
|---|
foreignCallAddress | `0x${string}` | The address of the foreign call to set the admin for. |
foreignCallSelector | string | - |
Returns
void
A promise.
Throws
Will retry indefinitely on contract interaction failure, with a delay between attempts.
confirmNewPolicyAdmin()
confirmNewPolicyAdmin(policyId): void
Defined in: src/modules/rules-engine.ts:1282
Confirm a new admin in the rules engine admin contract.
This function confirms a new admin for a specific policy.
Parameters
| Parameter | Type | Description |
|---|
policyId | number | The ID of the policy to set the admin for. |
Returns
void
A promise that resolves to the result of the contract interaction, or -1 if unsuccessful.
Throws
Will retry indefinitely on contract interaction failure, with a delay between attempts.
createCallingFunction()
createCallingFunction(policyId, callingFunction, name, encodedValues): Promise<{ functionId: number; transactionHash: `0x${string}`; }>
Defined in: src/modules/rules-engine.ts:1148
Creates a calling function in the rules engine component contract.
This function parses the provided calling function, maps its arguments to their respective
types, and interacts with the smart contract to create the calling function. If the contract
interaction fails, it retries with a delay until successful.
Parameters
| Parameter | Type | Description |
|---|
policyId | number | The ID of the policy for which the calling contract is being created. |
callingFunction | string | The calling function string to be parsed and added to the contract. |
name | string | Name of the Calling Function instance |
encodedValues | string | the encoded values that will be sent along with the rules invocation. |
Returns
Promise<{ functionId: number; transactionHash: `0x${string}`; }>
A promise that resolves to object with functionId and transactionHash, or -1 if unsuccessful.
Throws
Will retry indefinitely on contract interaction failure, with a delay between attempts.
createForeignCall()
createForeignCall(policyId, fcSyntax): Promise<{ foreignCallId: number; transactionHash: `0x${string}`; }>
Defined in: src/modules/rules-engine.ts:643
Creates a foreign call in the rules engine component contract.
Parameters
| Parameter | Type | Description |
|---|
policyId | number | The ID of the policy to associate with the foreign call. |
fcSyntax | string | A JSON string representing the foreign call definition. |
Returns
Promise<{ foreignCallId: number; transactionHash: `0x${string}`; }>
A promise that resolves to object with foreignCallId and transactionHash. Returns -1 if the operation fails.
- The function retries the contract interaction in case of failure, with a delay of 1 second between attempts.
- The
simulateContract function is used to simulate the contract interaction before writing to the blockchain.
- The
writeContract function is used to execute the contract interaction on the blockchain.
- The function returns the
foreignCallIndex for an updated foreign call or the result of the newly created foreign call.
Throws
Will throw an error if the JSON parsing of fcSyntax fails.
createMappedTracker()
createMappedTracker(policyId, mappedTrackerSyntax): Promise<{ trackerId: number; transactionHash: `0x${string}`; }>
Defined in: src/modules/rules-engine.ts:984
Asynchronously creates a mapped tracker in the rules engine component contract.
Parameters
| Parameter | Type | Description |
|---|
policyId | number | The ID of the policy associated with the tracker. |
mappedTrackerSyntax | string | A JSON string representing the tracker syntax. |
Returns
Promise<{ trackerId: number; transactionHash: `0x${string}`; }>
Object with trackerId and transactionHash.
createNewRule()
createNewRule(policyId, ruleS, foreignCallNameToID, trackerNameToID): Promise<{ ruleId: number; transactionHash: `0x${string}`; }>
Defined in: src/modules/rules-engine.ts:517
Asynchronously creates a new rule in the rules engine policy contract.
Parameters
| Parameter | Type | Description |
|---|
policyId | number | The ID of the policy to which the rule belongs. |
ruleS | string | A JSON string representing the rule to be created. |
foreignCallNameToID | NameToID[] | An array mapping foreign call names to their corresponding IDs. |
trackerNameToID | NameToID[] | An array mapping tracker names to their corresponding IDs. |
Returns
Promise<{ ruleId: number; transactionHash: `0x${string}`; }>
A promise that resolves to the result of the rule creation operation. Returns the rule ID if successful, or -1 if the operation fails.
- The function parses the rule JSON string to build the rule and effect structures.
- It uses a retry mechanism with a delay to handle potential failures during contract simulation.
createPolicy()
createPolicy(policyJSON): Promise<{ callingFunctions: object[]; foreignCalls: object[]; policyId: number; rules: object[]; trackers: object[]; transactionHash: `0x${string}`; }>
Defined in: src/modules/rules-engine.ts:234
Creates a policy in the Rules Engine.
Parameters
| Parameter | Type | Description |
|---|
policyJSON | string | Policy defined in a JSON string. |
Returns
Promise<{ callingFunctions: object[]; foreignCalls: object[]; policyId: number; rules: object[]; trackers: object[]; transactionHash: `0x${string}`; }>
An object containing the policy ID, transaction hash, and individual transaction hashes for all created components.
createTracker()
createTracker(policyId, trSyntax): Promise<{ trackerId: number; transactionHash: `0x${string}`; }>
Defined in: src/modules/rules-engine.ts:973
Asynchronously creates a tracker in the rules engine component contract.
Parameters
| Parameter | Type | Description |
|---|
policyId | number | The ID of the policy associated with the tracker. |
trSyntax | string | A JSON string representing the tracker syntax. |
Returns
Promise<{ trackerId: number; transactionHash: `0x${string}`; }>
A promise that resolves to object with trackerId and transactionHash.
Throws
Will retry indefinitely with a 1-second delay between attempts if an error occurs during the contract simulation.
Ensure proper error handling or timeout mechanisms are implemented to avoid infinite loops.
deleteCallingFunction()
deleteCallingFunction(policyId, callingFunctionId): Promise<number>
Defined in: src/modules/rules-engine.ts:1205
Delete a calling function from the rules engine component contract.
Parameters
| Parameter | Type | Description |
|---|
policyId | number | The ID of the policy for which the calling function is being deleted. |
callingFunctionId | string | The calling function ID to be deleted. |
Returns
Promise<number>
A promise that resolves to the result of the contract interaction, or -1 if unsuccessful.
Throws
Will retry indefinitely on contract interaction failure, with a delay between attempts.
deleteForeignCall()
deleteForeignCall(policyId, foreignCallId): Promise<number>
Defined in: src/modules/rules-engine.ts:695
Deletes a foreign call associated with a specific policy in the rules engine component contract.
Parameters
| Parameter | Type | Description |
|---|
policyId | number | The ID of the policy to which the foreign call belongs. |
foreignCallId | number | The ID of the foreign call to be deleted. |
Returns
Promise<number>
A promise that resolves to a number: - 0 if the operation is successful. - -1 if an error occurs during the simulation of the contract interaction.
Throws
This function does not explicitly throw errors but will return -1 if an error occurs during the simulation phase.
deletePolicy()
deletePolicy(policyId): Promise<{ result: number; transactionHash: `0x${string}`; }>
Defined in: src/modules/rules-engine.ts:351
Deletes a policy from the Rules Engine.
Parameters
| Parameter | Type | Description |
|---|
policyId | number | The ID of the policy to delete. |
Returns
Promise<{ result: number; transactionHash: `0x${string}`; }>
Object with result (0 if successful, -1 if error) and transactionHash.
deleteRule()
deleteRule(policyId, ruleId): Promise<number>
Defined in: src/modules/rules-engine.ts:581
Deletes a rule from the rules engine component contract.
Parameters
| Parameter | Type | Description |
|---|
policyId | number | The ID of the policy to which the rule belongs. |
ruleId | number | The ID of the rule to be deleted. |
Returns
Promise<number>
A promise that resolves to a number: - 0 if the rule was successfully deleted. - -1 if an error occurred during the deletion process.
Throws
This function does not throw errors directly but returns -1 in case of an exception.
deleteTracker()
deleteTracker(policyId, trackerId): Promise<number>
Defined in: src/modules/rules-engine.ts:1046
Deletes a tracker associated with a specific policy in the rules engine component contract.
Parameters
| Parameter | Type | Description |
|---|
policyId | number | The ID of the policy to which the tracker belongs. |
trackerId | number | The ID of the tracker to be deleted. |
Returns
Promise<number>
A promise that resolves to a number: - 0 if the tracker was successfully deleted. - -1 if an error occurred during the simulation of the contract interaction.
Throws
This function does not explicitly throw errors but will return -1 if an error occurs during the simulation phase.
disablePolicy()
disablePolicy(policyId): Promise<{ result: number; transactionHash: `0x${string}`; }>
Defined in: src/modules/rules-engine.ts:426
Disable a policy on the Rules Engine.
Parameters
| Parameter | Type | Description |
|---|
policyId | number | The ID of the policy to disable. |
Returns
Promise<{ result: number; transactionHash: `0x${string}`; }>
Object with result (0 if successful, -1 if error) and transactionHash.
getAllForeignCalls()
getAllForeignCalls(policyId, blockParams?): Promise<Maybe<any[]>>
Defined in: src/modules/rules-engine.ts:728
Retrieves all foreign calls associated with a specific policy ID from the Rules Engine Component Contract.
Parameters
| Parameter | Type | Description |
|---|
policyId | number | The ID of the policy for which foreign calls are to be retrieved. |
blockParams? | ContractBlockParameters | Optional parameters to specify block number or tag for the contract read operation. |
Returns
Promise<Maybe<any[]>>
A promise that resolves to an array of foreign calls if successful, or null if an error occurs.
Throws
Will log an error to the console if the operation fails.
getAllRules()
getAllRules(policyId, blockParams?): Promise<Maybe<any[]>>
Defined in: src/modules/rules-engine.ts:624
Retrieves all rules associated with a specific policy ID from the Rules Engine Policy Contract.
Parameters
| Parameter | Type | Description |
|---|
policyId | number | The unique identifier of the policy for which rules are to be retrieved. |
blockParams? | ContractBlockParameters | Optional parameters to specify block number or tag for the contract read operation. |
Returns
Promise<Maybe<any[]>>
A promise that resolves to an array of rules if successful, or null if an error occurs.
Throws
Will log an error to the console if the operation fails.
getAllTrackers()
getAllTrackers(policyId, blockParams?): Promise<Maybe<any[]>>
Defined in: src/modules/rules-engine.ts:1093
Retrieves all trackers associated with a specific policy ID from the Rules Engine Component Contract.
Parameters
| Parameter | Type | Description |
|---|
policyId | number | The unique identifier of the policy for which trackers are to be retrieved. |
blockParams? | ContractBlockParameters | Optional parameters to specify block number or tag for the contract read operation. |
Returns
Promise<Maybe<any[]>>
A promise that resolves to an array of trackers if successful, or null if an error occurs.
Throws
Will log an error to the console if the operation fails.
getAppliedPolicyIds()
getAppliedPolicyIds(address, blockParams?): Promise<number[]>
Defined in: src/modules/rules-engine.ts:396
Retrieves the IDs of all of the policies that have been applied to a contract address.
Parameters
| Parameter | Type | Description |
|---|
address | string | The address to check. |
blockParams? | ContractBlockParameters | Optional parameters to specify block number or tag for the contract read operation. |
Returns
Promise<number[]>
array of all of the policy ids applied to the contract
getCallingFunctionMetadata(policyId, callingFunctionId, blockParams?): Promise<CallingFunctionHashMapping>
Defined in: src/modules/rules-engine.ts:1225
retrieves the metadata for a xscalling function from the rules engine component contract.
Parameters
| Parameter | Type | Description |
|---|
policyId | number | The ID of the policy which the calling function belongs to. |
callingFunctionId | string | The Calling Function ID. |
blockParams? | ContractBlockParameters | Optional parameters to specify block number or tag for the contract read operation. |
Returns
Promise<CallingFunctionHashMapping>
A promise that resolves to the result of the contract interaction.
Throws
Will retry indefinitely on contract interaction failure, with a delay between attempts.
getCallingFunctions()
getCallingFunctions(policyId, blockParams?): Promise<CallingFunctionOnChain[]>
Defined in: src/modules/rules-engine.ts:1247
retrieves calling functions for a policy from the rules engine component contract.
Parameters
| Parameter | Type | Description |
|---|
policyId | number | The ID of the policy which the calling function belongs to. |
blockParams? | ContractBlockParameters | Optional parameters to specify block number or tag for the contract read operation. |
Returns
Promise<CallingFunctionOnChain[]>
A promise that resolves to CallingFunctionHashMapping.
getForeignCall()
getForeignCall(policyId, foreignCallId, blockParams?): Promise<any>
Defined in: src/modules/rules-engine.ts:715
Retrieves the result of a foreign call from the rules engine component contract.
Parameters
| Parameter | Type | Description |
|---|
policyId | number | The ID of the policy associated with the foreign call. |
foreignCallId | number | The ID of the foreign call to retrieve. |
blockParams? | ContractBlockParameters | Optional parameters to specify block number or tag for the contract read operation. |
Returns
Promise<any>
A promise that resolves to the result of the foreign call, or null if an error occurs.
Throws
Will log an error to the console if the contract interaction fails.
getForeignCallMetadata(policyId, foreignCallId, blockParams?): Promise<any>
Defined in: src/modules/rules-engine.ts:741
Retrieves the metadata for a foreign call from the rules engine component contract.
Parameters
| Parameter | Type | Description |
|---|
policyId | number | The ID of the policy associated with the foreign call. |
foreignCallId | number | The ID of the foreign call to retrieve. |
blockParams? | ContractBlockParameters | - |
Returns
Promise<any>
A promise that resolves to the result of the foreign call, or null if an error occurs.
Throws
Will log an error to the console if the contract interaction fails.
getForeignCallPermissionList()
getForeignCallPermissionList(foreignCallAddress, functionSelector, blockParams?): Promise<`0x${string}`[]>
Defined in: src/modules/rules-engine.ts:765
Retrieves the permission list for a permissioned foreign call.
Parameters
| Parameter | Type | Description |
|---|
foreignCallAddress | `0x${string}` | the address of the contract the foreign call belongs to. |
functionSelector | string | The selector for the specific foreign call |
blockParams? | ContractBlockParameters | Optional parameters to specify block number or tag for the contract read operation. |
Returns
Promise<`0x${string}`[]>
Array of addresses that make up the permission list
Throws
Will log an error to the console if the operation fails.
getMappedTrackerValue()
getMappedTrackerValue(policyId, index, key, blockParams?): Promise<any>
Defined in: src/modules/rules-engine.ts:1075
Retrieves a mapped tracker value from the Rules Engine Component Contract based on the provided policy ID, tracker ID, and key.
Parameters
| Parameter | Type | Description |
|---|
policyId | number | The ID of the policy associated with the tracker. |
index | number | The index of the tracker to retrieve. |
key | string | The key of the mapped tracker value to retrieve. |
blockParams? | ContractBlockParameters | Optional parameters to specify block number or tag for the contract read operation. |
Returns
Promise<any>
A promise that resolves to the tracker result if successful, or null if an error occurs.
Throws
Will log an error to the console if the contract interaction fails.
getPermissionedForeignCallsForPolicy()
getPermissionedForeignCallsForPolicy(policyId, blockParams?): Promise<ForeignCallOnChain[]>
Defined in: src/modules/rules-engine.ts:882
Gets permissioned foreign calls for a specific policy ID.
Parameters
| Parameter | Type | Description |
|---|
policyId | number | the ID of the policy the foreign call belongs to. |
blockParams? | ContractBlockParameters | Optional parameters to specify block number or tag for the contract read operation. |
Returns
Promise<ForeignCallOnChain[]>
A promise that resolves to ForeignCallOnChain[]:
Throws
Will log an error to the console if the operation fails.
getPolicy()
getPolicy(policyId, blockParams?): Promise<Maybe<PolicyJSON>>
Defined in: src/modules/rules-engine.ts:362
Retrieves the full policy, including rules, trackers, and foreign calls, as a JSON string.
Parameters
| Parameter | Type | Description |
|---|
policyId | number | The ID of the policy to retrieve. |
blockParams? | ContractBlockParameters | Optional parameters to specify block number or tag for the contract read operation. |
Returns
Promise<Maybe<PolicyJSON>>
— A PolicyResult object containing both the policy object and JSON string, or an empty string if an error occurs.
getPolicyMetadata(policyId, blockParams?): Promise<Maybe<PolicyMetadataStruct>>
Defined in: src/modules/rules-engine.ts:383
Retrieves the metadata for a policy from the Rules Engine Policy Contract based on the provided policy ID.
Parameters
| Parameter | Type | Description |
|---|
policyId | number | The ID of the policy. |
blockParams? | ContractBlockParameters | Optional parameters to specify block number or tag for the contract read operation. |
Returns
Promise<Maybe<PolicyMetadataStruct>>
A promise that resolves to the policy metadata result if successful, or null if an error occurs.
Throws
Will log an error to the console if the contract interaction fails.
getRule()
getRule(policyId, ruleId, blockParams?): Promise<Maybe<RuleOnChain>>
Defined in: src/modules/rules-engine.ts:593
Retrieves a specific rule from the Rules Engine.
Parameters
| Parameter | Type | Description |
|---|
policyId | number | The ID of the policy containing the rule. |
ruleId | number | The ID of the rule to retrieve. |
blockParams? | ContractBlockParameters | Optional parameters to specify block number or tag for the contract read operation. |
Returns
Promise<Maybe<RuleOnChain>>
The retrieved rule as a RuleOnChain, or null if retrieval fails.
getRuleMetadata(policyId, ruleId, blockParams?): Promise<Maybe<RuleMetadataStruct>>
Defined in: src/modules/rules-engine.ts:607
Retrieves the metadata for a rule from the Rules Engine Rules Contract based on the provided policy ID and rule ID.
Parameters
| Parameter | Type | Description |
|---|
policyId | number | The ID of the policy associated with the rule. |
ruleId | number | The ID of the rule to retrieve. |
blockParams? | ContractBlockParameters | Optional parameters to specify block number or tag for the contract read operation. |
Returns
Promise<Maybe<RuleMetadataStruct>>
A promise that resolves to the rule metadata result if successful, or null if an error occurs.
Throws
Will log an error to the console if the contract interaction fails.
getRulesEngineComponentContract()
getRulesEngineComponentContract(): object
Defined in: src/modules/rules-engine.ts:191
Returns
object
abi
abi: ({ anonymous: undefined; inputs: ({ components: undefined; internalType: string; name: string; type: string; } | { components: object[]; internalType: string; name: string; type: string; })[]; name: string; outputs: object[]; stateMutability: string; type: string; } | { anonymous: undefined; inputs: object[]; name: string; outputs: object[]; stateMutability: string; type: string; } | { anonymous: boolean; inputs: object[]; name: string; outputs: undefined; stateMutability: undefined; type: string; })[]
address
address: `0x${string}`
getRulesEngineForeignCallContract()
getRulesEngineForeignCallContract(): object
Defined in: src/modules/rules-engine.ts:197
Returns
object
abi
abi: ({ anonymous: undefined; inputs: ({ components: undefined; internalType: string; name: string; type: string; } | { components: ({ components: undefined; internalType: string; name: string; type: string; } | { components: …[]; internalType: string; name: string; type: string; })[]; internalType: string; name: string; type: string; })[]; name: string; outputs: object[]; stateMutability: string; type: string; } | { anonymous: undefined; inputs: ({ components: undefined; internalType: string; name: string; type: string; } | { components: ({ components: undefined; internalType: string; name: string; type: string; } | { components: …[]; internalType: string; name: string; type: string; })[]; internalType: string; name: string; type: string; })[]; name: string; outputs: object[]; stateMutability: string; type: string; } | { anonymous: boolean; inputs: object[]; name: string; outputs: undefined; stateMutability: undefined; type: string; })[]
address
address: `0x${string}`
getRulesEnginePolicyContract()
getRulesEnginePolicyContract(): object
Defined in: src/modules/rules-engine.ts:188
Returns
object
abi
abi: ({ anonymous: undefined; inputs: object[]; name: string; outputs: object[]; stateMutability: string; type: string; } | { anonymous: undefined; inputs: object[]; name: string; outputs: object[]; stateMutability: string; type: string; } | { anonymous: boolean; inputs: object[]; name: string; outputs: undefined; stateMutability: undefined; type: string; })[]
address
address: `0x${string}`
getRulesEngineRulesContract()
getRulesEngineRulesContract(): object
Defined in: src/modules/rules-engine.ts:194
Returns
object
abi
abi: ({ anonymous: undefined; inputs: ({ components: undefined; internalType: string; name: string; type: string; } | { components: ({ components: undefined; internalType: string; name: string; type: string; } | { components: …[]; internalType: string; name: string; type: string; })[]; internalType: string; name: string; type: string; })[]; name: string; outputs: object[]; stateMutability: string; type: string; } | { anonymous: undefined; inputs: object[]; name: string; outputs: object[]; stateMutability: string; type: string; } | { anonymous: boolean; inputs: object[]; name: string; outputs: undefined; stateMutability: undefined; type: string; })[]
address
address: `0x${string}`
getRulesEngineVersion()
getRulesEngineVersion(): Promise<string>
Defined in: src/modules/rules-engine.ts:253
Returns
Promise<string>
getTracker()
getTracker(policyId, trackerId, blockParams?): Promise<any>
Defined in: src/modules/rules-engine.ts:1060
Retrieves a tracker from the Rules Engine Component Contract based on the provided policy ID and tracker ID.
Parameters
| Parameter | Type | Description |
|---|
policyId | number | The ID of the policy associated with the tracker. |
trackerId | number | The ID of the tracker to retrieve. |
blockParams? | ContractBlockParameters | Optional parameters to specify block number or tag for the contract read operation. |
Returns
Promise<any>
A promise that resolves to the tracker result if successful, or null if an error occurs.
Throws
Will log an error to the console if the contract interaction fails.
getTrackerMetadata(policyId, trackerId, blockParams?): Promise<Maybe<TrackerMetadataStruct>>
Defined in: src/modules/rules-engine.ts:1107
Retrieves the metadata for a tracker from the Rules Engine Component Contract based on the provided policy ID and tracker ID.
Parameters
| Parameter | Type | Description |
|---|
policyId | number | The ID of the policy associated with the tracker. |
trackerId | number | The ID of the tracker to retrieve. |
blockParams? | ContractBlockParameters | Optional parameters to specify block number or tag for the contract read operation. |
Returns
Promise<Maybe<TrackerMetadataStruct>>
A promise that resolves to the tracker metadata result if successful, or null if an error occurs.
Throws
Will log an error to the console if the contract interaction fails.
getTrackerToRuleIds()
getTrackerToRuleIds(policyId, trackerId, blockParams?): Promise<Maybe<number[]>>
Defined in: src/modules/rules-engine.ts:1125
Retrieves the rule IDs associated with a specific tracker from the Rules Engine Component Contract
based on the provided policy ID and tracker ID.
Parameters
| Parameter | Type | Description |
|---|
policyId | number | The ID of the policy associated with the tracker. |
trackerId | number | The ID of the tracker for which rule IDs are to be retrieved. |
blockParams? | ContractBlockParameters | - |
Returns
Promise<Maybe<number[]>>
A promise that resolves to an array of rule IDs if successful, or an empty array if an error occurs.
Throws
Will log an error to the console if the contract interaction fails.
getVersionCompatible()
getVersionCompatible(): Promise<boolean>
Defined in: src/modules/rules-engine.ts:257
Returns
Promise<boolean>
isCallingContractAdmin()
isCallingContractAdmin(callingContract, account, blockParams?): Promise<boolean>
Defined in: src/modules/rules-engine.ts:1394
Determine if address is the calling contract admin.
This function determines whether or not an address is the admin for a specific calling contract.
Parameters
| Parameter | Type | Description |
|---|
callingContract | `0x${string}` | The address of the contract to check the admin for. |
account | `0x${string}` | The address to check |
blockParams? | ContractBlockParameters | Optional parameters to specify block number or tag for the contract read operation. |
Returns
Promise<boolean>
whether or not the address is the calling contract admin.
isCementedPolicy()
isCementedPolicy(policyId, blockParams?): Promise<boolean>
Defined in: src/modules/rules-engine.ts:1512
Retrieves whether a policy is cemented.
Parameters
| Parameter | Type | Description |
|---|
policyId | number | The ID of the policy to check. |
blockParams? | ContractBlockParameters | Optional parameters to specify block number or tag for the contract read operation. |
Returns
Promise<boolean>
True if the policy is cemented, false otherwise
isClosedPolicy()
isClosedPolicy(policyId, blockParams?): Promise<boolean>
Defined in: src/modules/rules-engine.ts:406
Retrieves whether a policy is open or closed.
Parameters
| Parameter | Type | Description |
|---|
policyId | number | The ID of the policy to check. |
blockParams? | ContractBlockParameters | Optional parameters to specify block number or tag for the contract read operation. |
Returns
Promise<boolean>
True if the policy is closed, false otherwise
isClosedPolicySubscriber()
isClosedPolicySubscriber(policyId, subscriber, blockParams?): Promise<boolean>
Defined in: src/modules/rules-engine.ts:457
Retrieves whether an address is a possible subscriber to the closed policy.
Parameters
| Parameter | Type | Description |
|---|
policyId | number | The ID of the policy to check. |
subscriber | `0x${string}` | The address to check |
blockParams? | ContractBlockParameters | Optional parameters to specify block number or tag for the contract read operation. |
Returns
Promise<boolean>
True if the address is a subscriber to the closed policy, false otherwise
isDisabledPolicy()
isDisabledPolicy(policyId, blockParams?): Promise<boolean>
Defined in: src/modules/rules-engine.ts:416
Retrieves whether a policy is disabled.
Parameters
| Parameter | Type | Description |
|---|
policyId | number | The ID of the policy to check. |
blockParams? | ContractBlockParameters | Optional parameters to specify block number or tag for the contract read operation. |
Returns
Promise<boolean>
True if the policy is disabled, false otherwise
isForeignCallAdmin()
isForeignCallAdmin(foreignCallAddress, account, foreignCallSelector, blockParams?): Promise<boolean>
Defined in: src/modules/rules-engine.ts:1480
Determine if address is the foreign call admin.
This function determines whether or not an address is the admin for a specific foreign call.
Parameters
| Parameter | Type | Description |
|---|
foreignCallAddress | `0x${string}` | - |
account | `0x${string}` | The address to check |
foreignCallSelector | string | - |
blockParams? | ContractBlockParameters | Optional parameters to specify block number or tag for the contract read operation. |
Returns
Promise<boolean>
whether or not the address is the foreign call admin.
isPermissionedAdmin()
isPermissionedAdmin(foreignCallAddress, signature, adminAddress, blockParams?): Promise<boolean>
Defined in: src/modules/rules-engine.ts:905
Determines if a user is a permissioned admin for a specific policy ID.
Parameters
| Parameter | Type | Description |
|---|
foreignCallAddress | `0x${string}` | the address of the foreign call. |
signature | string | the signature of the function being called. |
adminAddress | `0x${string}` | the address of the admin to check. |
blockParams? | ContractBlockParameters | Optional parameters to specify block number or tag for the contract read operation. |
Returns
Promise<boolean>
A promise that resolves to a boolean indicating if the user is a permissioned admin.
Throws
Will log an error to the console if the operation fails.
isPolicyAdmin()
isPolicyAdmin(policyId, adminAddress, blockParams?): Promise<boolean>
Defined in: src/modules/rules-engine.ts:1318
Determine if address is policy admin.
This function determines whether or not an address is the admin for a specific policy.
Parameters
| Parameter | Type | Description |
|---|
policyId | number | The ID of the policy to check the admin for. |
adminAddress | `0x${string}` | The address to check |
blockParams? | ContractBlockParameters | Optional parameters to specify block number or tag for the contract read operation. |
Returns
Promise<boolean>
whether or not the address is the policy admin.
openPolicy()
openPolicy(policyId): Promise<{ result: number; transactionHash: `0x${string}`; }>
Defined in: src/modules/rules-engine.ts:436
Opens a policy on the Rules Engine.
Parameters
| Parameter | Type | Description |
|---|
policyId | number | The ID of the policy to open. |
Returns
Promise<{ result: number; transactionHash: `0x${string}`; }>
Object with result (0 if successful, -1 if error) and transactionHash.
policyExists()
policyExists(policyId): Promise<boolean>
Defined in: src/modules/rules-engine.ts:267
Checks if a policy exists in the Rules Engine.
Parameters
| Parameter | Type | Description |
|---|
policyId | number | The ID of the policy to check. |
Returns
Promise<boolean>
True if the policy exists, false otherwise.
proposeCallingContractAdmin()
proposeCallingContractAdmin(callingContractAddress, newAdminAddress): void
Defined in: src/modules/rules-engine.ts:1333
Propose a new calling contract admin in the rules engine admin contract.
This function proposes a new admin for a specific calling contract.
Parameters
| Parameter | Type | Description |
|---|
callingContractAddress | `0x${string}` | The address of the calling contract to set the admin for. |
newAdminAddress | `0x${string}` | The address to propose as the new admin |
Returns
void
A promise that resolves to the result of the contract interaction, or -1 if unsuccessful.
Throws
Will retry indefinitely on contract interaction failure, with a delay between attempts.
proposeForeignCallAdmin()
proposeForeignCallAdmin(foreignCallAddress, newAdminAddress, foreignCallSelector): void
Defined in: src/modules/rules-engine.ts:1414
Propose a new foreign call admin in the rules engine admin contract.
This function proposes a new admin for a specific foreign call.
Parameters
| Parameter | Type | Description |
|---|
foreignCallAddress | `0x${string}` | The address of the foreign call contract to set the admin for. |
newAdminAddress | `0x${string}` | The address to propose as the new admin |
foreignCallSelector | string | - |
Returns
void
A promise.
Throws
Will retry indefinitely on contract interaction failure, with a delay between attempts.
proposeNewPolicyAdmin()
proposeNewPolicyAdmin(policyId, newAdminAddress): void
Defined in: src/modules/rules-engine.ts:1262
Propose a new admin in the rules engine admin contract.
This function proposes a new admin for a specific policy.
Parameters
| Parameter | Type | Description |
|---|
policyId | number | The ID of the policy to set the admin for. |
newAdminAddress | `0x${string}` | The address to propose as the new admin |
Returns
void
A promise that resolves to the result of the contract interaction, or -1 if unsuccessful.
Throws
Will retry indefinitely on contract interaction failure, with a delay between attempts.
removeAllFromPermissionList()
removeAllFromPermissionList(foreignCallAddress, functionSelector): Promise<{ result: number; transactionHash: `0x${string}`; }>
Defined in: src/modules/rules-engine.ts:863
Removes all addresses from the permission list for a foreign call.
Parameters
| Parameter | Type | Description |
|---|
foreignCallAddress | `0x${string}` | the address of the contract the foreign call belongs to. |
functionSelector | string | The selector for the specific foreign call |
Returns
Promise<{ result: number; transactionHash: `0x${string}`; }>
Object with result (0 if successful, -1 if error) and transactionHash.
Throws
Will log an error to the console if the operation fails.
removeClosedPolicySubscriber()
removeClosedPolicySubscriber(policyId, subscriber): Promise<{ result: number; transactionHash: `0x${string}`; }>
Defined in: src/modules/rules-engine.ts:494
Removes a subscriber from the closed policy.
Parameters
| Parameter | Type | Description |
|---|
policyId | number | The ID of the policy to remove from. |
subscriber | `0x${string}` | The address of the subscriber to remove. |
Returns
Promise<{ result: number; transactionHash: `0x${string}`; }>
Object with result (0 if successful, -1 if error) and transactionHash.
removeForeignCallPermissions()
removeForeignCallPermissions(foreignCallAddress, signature): Promise<{ result: number; transactionHash: `0x${string}`; }>
Defined in: src/modules/rules-engine.ts:953
Removes all permissions for a specific foreign call.
Parameters
| Parameter | Type | Description |
|---|
foreignCallAddress | `0x${string}` | The address of the foreign call contract. |
signature | string | The function signature. |
Returns
Promise<{ result: number; transactionHash: `0x${string}`; }>
Object with result (0 if successful, -1 if error) and transactionHash.
Throws
Will retry indefinitely with a 1-second delay between attempts if an error occurs during the contract simulation.
Ensure proper error handling or timeout mechanisms are implemented to avoid infinite loops.
removeFromPermissionList()
removeFromPermissionList(foreignCallAddress, signature, adminAddress): Promise<{ result: number; transactionHash: `0x${string}`; }>
Defined in: src/modules/rules-engine.ts:932
Removes admin from the permission list for a specific foreign call.
Parameters
| Parameter | Type | Description |
|---|
foreignCallAddress | `0x${string}` | The address of the foreign call contract. |
signature | string | The function signature. |
adminAddress | `0x${string}` | The address of the admin to remove. |
Returns
Promise<{ result: number; transactionHash: `0x${string}`; }>
Object with result (0 if successful, -1 if error) and transactionHash.
Throws
Will retry indefinitely with a 1-second delay between attempts if an error occurs during the contract simulation.
Ensure proper error handling or timeout mechanisms are implemented to avoid infinite loops.
removeMultipleAdminsFromPermissionList()
removeMultipleAdminsFromPermissionList(foreignCallAddress, functionSelector, policyAdminsToRemove): Promise<{ result: number; transactionHash: `0x${string}`; }>
Defined in: src/modules/rules-engine.ts:839
Removes multiple addresses from the permission list for a foreign call.
Parameters
| Parameter | Type | Description |
|---|
foreignCallAddress | `0x${string}` | the address of the contract the foreign call belongs to. |
functionSelector | string | The selector for the specific foreign call |
policyAdminsToRemove | `0x${string}`[] | The address of the admins to remove from the list |
Returns
Promise<{ result: number; transactionHash: `0x${string}`; }>
Object with result (0 if successful, -1 if error) and transactionHash.
Throws
Will log an error to the console if the operation fails.
renounceCallingContractAdminRoleInternal()
renounceCallingContractAdminRoleInternal(renounceAddress, callingContractAddress): Promise<void>
Defined in: src/modules/rules-engine.ts:1373
Renounce a calling contract admin in the rules engine admin contract.
This function renounces the admin role for a specific calling contract.
Parameters
| Parameter | Type | Description |
|---|
renounceAddress | `0x${string}` | The address of the calling contract to renounce the admin for. |
callingContractAddress | `0x${string}` | The address of the calling contract to renounce the admin for. |
Returns
Promise<void>
A promise that resolves to the result of the contract interaction, or -1 if unsuccessful.
Throws
Will retry indefinitely on contract interaction failure, with a delay between attempts.
renounceForeignCallAdmin()
renounceForeignCallAdmin(foreignCallAddress, functionSignature, renounceAddress): void
Defined in: src/modules/rules-engine.ts:1457
Renounce foreign call admin in the rules engine admin contract.
This function confirms a new admin for a specific foreign call.
Parameters
| Parameter | Type | Description |
|---|
foreignCallAddress | `0x${string}` | The address of the foreign call to set the admin for. |
functionSignature | string | - |
renounceAddress | `0x${string}` | - |
Returns
void
A promise.
Throws
Will retry indefinitely on contract interaction failure, with a delay between attempts.
renouncePolicyAdminRole()
renouncePolicyAdminRole(role, renounceAddress, policyId): void
Defined in: src/modules/rules-engine.ts:1296
Renounce an admin role in the rules engine admin contract.
This function confirms a new admin for a specific policy.
Parameters
| Parameter | Type | Description |
|---|
role | string | - |
renounceAddress | `0x${string}` | - |
policyId | number | The ID of the policy to set the admin for. |
Returns
void
A promise that resolves to the result of the contract interaction, or -1 if unsuccessful.
Throws
Will retry indefinitely on contract interaction failure, with a delay between attempts.
setPolicies()
setPolicies(policyIds, contractAddressForPolicy): void
Defined in: src/modules/rules-engine.ts:303
Sets the policies appled to a specific contract address.
Parameters
| Parameter | Type | Description |
|---|
policyIds | [number] | The list of IDs of all of the policies that will be applied to the contract |
contractAddressForPolicy | `0x${string}` | The address of the contract to which the policy will be applied. |
Returns
void
unsetPolicies()
unsetPolicies(policyIds, contractAddressForPolicy): void
Defined in: src/modules/rules-engine.ts:319
Unsets the policies appled to a specific contract address.
Parameters
| Parameter | Type | Description |
|---|
policyIds | [number] | The list of IDs of all of the policies that will be unapplied to the contract |
contractAddressForPolicy | `0x${string}` | The address of the contract to which the policy will be unapplied. |
Returns
void
updateCallingFunction()
updateCallingFunction(policyId, callingFunction, name, encodedValues): Promise<{ functionId: number; transactionHash: `0x${string}`; }>
Defined in: src/modules/rules-engine.ts:1179
Updates a Calling Function in the rules engine component contract.
Parameters
| Parameter | Type | Description |
|---|
policyId | number | The ID of the policy for which the calling function is being created. |
callingFunction | string | The calling function string to be parsed and updated. of the rules engine component. |
name | string | Name of the Calling Function instance |
encodedValues | string | The encoded values string for the calling function. |
Returns
Promise<{ functionId: number; transactionHash: `0x${string}`; }>
A promise that resolves to object with functionId and transactionHash, or -1 if unsuccessful.
Throws
Will retry indefinitely on contract interaction failure, with a delay between attempts.
updateForeignCall()
updateForeignCall(policyId, foreignCallId, fcSyntax): Promise<{ foreignCallId: number; transactionHash: `0x${string}`; }>
Defined in: src/modules/rules-engine.ts:671
Updates a foreign call in the rules engine component contract.
Parameters
| Parameter | Type | Description |
|---|
policyId | number | The ID of the policy to associate with the foreign call. |
foreignCallId | number | The ID of the foreign call to update. |
fcSyntax | string | A JSON string representing the foreign call definition. |
Returns
Promise<{ foreignCallId: number; transactionHash: `0x${string}`; }>
A promise that resolves to object with foreignCallId and transactionHash. Returns -1 if the operation fails.
- The function retries the contract interaction in case of failure, with a delay of 1 second between attempts.
- The
simulateContract function is used to simulate the contract interaction before writing to the blockchain.
- The
writeContract function is used to execute the contract interaction on the blockchain.
- The function returns the
foreignCallIndex for an updated foreign call or the result of the newly created foreign call.
Throws
Will throw an error if the JSON parsing of fcSyntax fails.
updateMappedTracker()
updateMappedTracker(policyId, mappedTrackerId, mappedTrackerSyntax): Promise<{ trackerId: number; transactionHash: `0x${string}`; }>
Defined in: src/modules/rules-engine.ts:1002
Asynchronously updates a mapped tracker in the rules engine component contract.
Parameters
| Parameter | Type | Description |
|---|
policyId | number | The ID of the policy associated with the tracker. |
mappedTrackerId | number | The ID of the tracker to update. |
mappedTrackerSyntax | string | A JSON string representing the tracker syntax. |
Returns
Promise<{ trackerId: number; transactionHash: `0x${string}`; }>
Object with trackerId and transactionHash.
updatePolicy()
updatePolicy(policySyntax, policyId): Promise<{ callingFunctions: object[]; foreignCalls: object[]; policyId: number; rules: object[]; trackers: object[]; }>
Defined in: src/modules/rules-engine.ts:278
Updates an existing policy in the Rules Engine.
Parameters
| Parameter | Type |
|---|
policySyntax | string |
policyId | number |
Returns
Promise<{ callingFunctions: object[]; foreignCalls: object[]; policyId: number; rules: object[]; trackers: object[]; }>
The ID of the updated policy and the transaction hashes of the updated components.
updateRule()
updateRule(policyId, ruleId, ruleS, foreignCallNameToID, trackerNameToID): Promise<{ ruleId: number; transactionHash: `0x${string}`; }>
Defined in: src/modules/rules-engine.ts:548
Updates an existing rule in the Rules Engine Policy Contract.
Parameters
| Parameter | Type | Description |
|---|
policyId | number | The ID of the policy to which the rule belongs. |
ruleId | number | The ID of the rule to be updated. |
ruleS | string | A JSON string representing the rule’s structure and logic. |
foreignCallNameToID | NameToID[] | A mapping of foreign call names to their corresponding IDs. |
trackerNameToID | NameToID[] | A mapping of tracker names to their corresponding IDs. |
Returns
Promise<{ ruleId: number; transactionHash: `0x${string}`; }>
A promise that resolves to object with ruleId and transactionHash. Returns the ruleId if successful, or -1 if the operation fails.
updateTracker()
updateTracker(policyId, trackerId, trSyntax): Promise<{ trackerId: number; transactionHash: `0x${string}`; }>
Defined in: src/modules/rules-engine.ts:1024
Asynchronously updates a tracker in the rules engine component contract.
Parameters
| Parameter | Type | Description |
|---|
policyId | number | The ID of the policy associated with the tracker. |
trackerId | number | The ID of the tracker to update. |
trSyntax | string | A JSON string representing the tracker syntax. |
Returns
Promise<{ trackerId: number; transactionHash: `0x${string}`; }>
A promise that resolves to object with trackerId and transactionHash. Returns -1 if the operation fails.
Throws
Will retry indefinitely with a 1-second delay between attempts if an error occurs during the contract simulation.
Ensure proper error handling or timeout mechanisms are implemented to avoid infinite loops.
create()
static create(rulesEngineAddress, localConfig, client, localConfirmationCount): Promise<Maybe<RulesEngine>>
Defined in: src/modules/rules-engine.ts:209
Creates a Rules Engine instance using the private constructor if the supplied rules engine address is compatible.
Parameters
| Parameter | Type | Default value | Description |
|---|
rulesEngineAddress | `0x${string}` | undefined | The address of the deployed Rules Engine smart contract. |
localConfig | Config | undefined | The configuration object containing network and wallet information. |
client | any | undefined | The client instance for interacting with the blockchain. |
localConfirmationCount | number | 1 | The number of confirmations (blocks that have passed) to wait before resolving transaction receipts (default is 1). |
Returns
Promise<Maybe<RulesEngine>>