Methods
addAdminToPermissionList()
addAdminToPermissionList(Defined in: src/modules/rules-engine.ts:733 Adds a new address to the permission list for a foreign call.foreignCallAddress
,functionSelector
,policyAdminToAdd
):Promise
<number
>
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
<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
Will log an error to the console if the operation fails.addClosedPolicySubscriber()
addClosedPolicySubscriber(Defined in: src/modules/rules-engine.ts:419 Adds a subscriber to the closed policy.policyId
,subscriber
):Promise
<number
>
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
<number
>
0
if successful, -1
if an error occurs.
addMultipleAdminsToPermissionList()
addMultipleAdminsToPermissionList(Defined in: src/modules/rules-engine.ts:760 Adds multiple addresses to the permission list for a foreign call.foreignCallAddress
,functionSelector
,policyAdminsToAdd
):Promise
<number
>
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
<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
Will log an error to the console if the operation fails.appendPolicy()
appendPolicy(Defined in: src/modules/rules-engine.ts:297 Appends a policy to the list of policies applied to a specific contract address.policyId
,contractAddressForPolicy
):void
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(Defined in: src/modules/rules-engine.ts:1173 Cements a policy on the Rules Engine.policyId
):Promise
<number
>
Parameters
Parameter | Type | Description |
---|---|---|
policyId | number | The ID of the policy to cement. |
Returns
Promise
<number
>
0
if successful, -1
if an error occurs.
closePolicy()
closePolicy(Defined in: src/modules/rules-engine.ts:388 Closes a policy on the Rules Engine.policyId
):Promise
<number
>
Parameters
Parameter | Type | Description |
---|---|---|
policyId | number | The ID of the policy to close. |
Returns
Promise
<number
>
0
if successful, -1
if an error occurs.
confirmNewCallingContractAdmin()
confirmNewCallingContractAdmin(Defined in: src/modules/rules-engine.ts:1067 Confirm a new calling contract admin in the rules engine admin contract. This function confirms a new admin for a specific calling contract.callingContractAddress
):void
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(Defined in: src/modules/rules-engine.ts:1129 Confirm a new foreign call admin in the rules engine admin contract. This function confirms a new admin for a specific foreign call.foreignCallAddress
,foreignCallSelector
):void
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(Defined in: src/modules/rules-engine.ts:1017 Confirm a new admin in the rules engine admin contract. This function confirms a new admin for a specific policy.policyId
):void
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(Defined in: src/modules/rules-engine.ts:951 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.policyId
,callingFunction
,encodedValues
):Promise
<number
>
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. |
encodedValues | string | the encoded values that will be sent along with the rules invocation. |
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.createForeignCall()
createForeignCall(Defined in: src/modules/rules-engine.ts:585 Creates a foreign call in the rules engine component contract.policyId
,fcSyntax
):Promise
<number
>
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
<number
>
A promise that resolves to the foreign call index. Returns -1
if the operation fails.
Remarks
- 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 offcSyntax
fails.
createNewRule()
createNewRule(Defined in: src/modules/rules-engine.ts:459 Asynchronously creates a new rule in the rules engine policy contract.policyId
,ruleS
,foreignCallNameToID
,trackerNameToID
):Promise
<number
>
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 | FCNameToID [] | An array mapping foreign call names to their corresponding IDs. |
trackerNameToID | FCNameToID [] | An array mapping tracker names to their corresponding IDs. |
Returns
Promise
<number
>
A promise that resolves to the result of the rule creation operation. Returns the rule ID if successful, or -1 if the operation fails.
Remarks
- 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(Defined in: src/modules/rules-engine.ts:216 Creates a policy in the Rules Engine.policyJSON
):Promise
<{policyId
:number
; }>
Parameters
Parameter | Type | Description |
---|---|---|
policyJSON | string | Policy defined in a JSON string. |
Returns
Promise
<{ policyId
: number
; }>
The ID of the newly created policy.
createTracker()
createTracker(Defined in: src/modules/rules-engine.ts:833 Asynchronously creates a tracker in the rules engine component contract.policyId
,trSyntax
):Promise
<number
>
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
<number
>
A promise that resolves to the new tracker ID
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.deleteForeignCall()
deleteForeignCall(Defined in: src/modules/rules-engine.ts:637 Deletes a foreign call associated with a specific policy in the rules engine component contract.policyId
,foreignCallId
):Promise
<number
>
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(Defined in: src/modules/rules-engine.ts:313 Deletes a policy from the Rules Engine.policyId
):Promise
<number
>
Parameters
Parameter | Type | Description |
---|---|---|
policyId | number | The ID of the policy to delete. |
Returns
Promise
<number
>
0
if successful, -1
if an error occurs.
deleteRule()
deleteRule(Defined in: src/modules/rules-engine.ts:523 Deletes a rule from the rules engine component contract.policyId
,ruleId
):Promise
<number
>
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(Defined in: src/modules/rules-engine.ts:870 Deletes a tracker associated with a specific policy in the rules engine component contract.policyId
,trackerId
):Promise
<number
>
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.
getAllForeignCalls()
getAllForeignCalls(Defined in: src/modules/rules-engine.ts:670 Retrieves all foreign calls associated with a specific policy ID from the Rules Engine Component Contract.policyId
,blockParams
?):Promise
<Maybe
<any
[]>>
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(Defined in: src/modules/rules-engine.ts:566 Retrieves all rules associated with a specific policy ID from the Rules Engine Policy Contract.policyId
,blockParams
?):Promise
<Maybe
<any
[]>>
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(Defined in: src/modules/rules-engine.ts:897 Retrieves all trackers associated with a specific policy ID from the Rules Engine Component Contract.policyId
,blockParams
?):Promise
<Maybe
<any
[]>>
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(Defined in: src/modules/rules-engine.ts:358 Retrieves the IDs of all of the policies that have been applied to a contract address.address
,blockParams
?):Promise
<number
[]>
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()
getCallingFunctionMetadata(Defined in: src/modules/rules-engine.ts:972 retrieves the metadata for a calling function from the rules engine component contract.policyId
,callingFunctionId
,blockParams
?):Promise
<CallingFunctionHashMapping
>
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.getForeignCall()
getForeignCall(Defined in: src/modules/rules-engine.ts:657 Retrieves the result of a foreign call from the rules engine component contract.policyId
,foreignCallId
,blockParams
?):Promise
<any
>
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()
getForeignCallMetadata(Defined in: src/modules/rules-engine.ts:683 Retrieves the metadata for a foreign call from the rules engine component contract.policyId
,foreignCallId
,blockParams
?):Promise
<any
>
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(Defined in: src/modules/rules-engine.ts:707 Retrieves the permission list for a permissioned foreign call.foreignCallAddress
,functionSelector
,blockParams
?):Promise
<`0x${string}`
[]>
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.getPolicy()
getPolicy(Defined in: src/modules/rules-engine.ts:324 Retrieves the full policy, including rules, trackers, and foreign calls, as a JSON string.policyId
,blockParams
?):Promise
<Maybe
<PolicyResult
>>
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
<PolicyResult
>>
— A PolicyResult object containing both the policy object and JSON string, or an empty string if an error occurs.
getPolicyMetadata()
getPolicyMetadata(Defined in: src/modules/rules-engine.ts:345 Retrieves the metadata for a policy from the Rules Engine Policy Contract based on the provided policy ID.policyId
,blockParams
?):Promise
<Maybe
<PolicyMetadataStruct
>>
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(Defined in: src/modules/rules-engine.ts:535 Retrieves a specific rule from the Rules Engine.policyId
,ruleId
,blockParams
?):Promise
<Maybe
<RuleStruct
>>
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
<RuleStruct
>>
The retrieved rule as a RuleStruct
, or null
if retrieval fails.
getRuleMetadata()
getRuleMetadata(Defined in: src/modules/rules-engine.ts:549 Retrieves the metadata for a rule from the Rules Engine Rules Contract based on the provided policy ID and rule ID.policyId
,ruleId
,blockParams
?):Promise
<Maybe
<RuleMetadataStruct
>>
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:173
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:179
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:170
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:176
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():Defined in: src/modules/rules-engine.ts:228Promise
<string
>
Returns
Promise
<string
>
getTracker()
getTracker(Defined in: src/modules/rules-engine.ts:884 Retrieves a tracker from the Rules Engine Component Contract based on the provided policy ID and tracker ID.policyId
,trackerId
,blockParams
?):Promise
<any
>
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()
getTrackerMetadata(Defined in: src/modules/rules-engine.ts:911 Retrieves the metadata for a tracker from the Rules Engine Component Contract based on the provided policy ID and tracker ID.policyId
,trackerId
,blockParams
?):Promise
<Maybe
<TrackerMetadataStruct
>>
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(Defined in: src/modules/rules-engine.ts:929 Retrieves the rule IDs associated with a specific tracker from the Rules Engine Component Contract based on the provided policy ID and tracker ID.policyId
,trackerId
,blockParams
?):Promise
<Maybe
<number
[]>>
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():Defined in: src/modules/rules-engine.ts:232Promise
<boolean
>
Returns
Promise
<boolean
>
isCallingContractAdmin()
isCallingContractAdmin(Defined in: src/modules/rules-engine.ts:1087 Determine if address is the calling contract admin. This function determines whether or not an address is the admin for a specific calling contract.callingContract
,account
,blockParams
?):Promise
<boolean
>
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(Defined in: src/modules/rules-engine.ts:1183 Retrieves whether a policy is cemented.policyId
,blockParams
?):Promise
<boolean
>
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(Defined in: src/modules/rules-engine.ts:368 Retrieves whether a policy is open or closed.policyId
,blockParams
?):Promise
<boolean
>
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(Defined in: src/modules/rules-engine.ts:399 Retrieves whether an address is a possible subscriber to the closed policy.policyId
,subscriber
,blockParams
?):Promise
<boolean
>
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
isForeignCallAdmin()
isForeignCallAdmin(Defined in: src/modules/rules-engine.ts:1151 Determine if address is the foreign call admin. This function determines whether or not an address is the admin for a specific foreign call.foreignCallAddress
,account
,foreignCallSelector
,blockParams
?):Promise
<boolean
>
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.
isPolicyAdmin()
isPolicyAdmin(Defined in: src/modules/rules-engine.ts:1032 Determine if address is policy admin. This function determines whether or not an address is the admin for a specific policy.policyId
,adminAddress
,blockParams
?):Promise
<boolean
>
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(Defined in: src/modules/rules-engine.ts:378 Opens a policy on the Rules Engine.policyId
):Promise
<number
>
Parameters
Parameter | Type | Description |
---|---|---|
policyId | number | The ID of the policy to open. |
Returns
Promise
<number
>
0
if successful, -1
if an error occurs.
policyExists()
policyExists(Defined in: src/modules/rules-engine.ts:242 Checks if a policy exists in the Rules Engine.policyId
):Promise
<boolean
>
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(Defined in: src/modules/rules-engine.ts:1047 Propose a new calling contract admin in the rules engine admin contract. This function proposes a new admin for a specific calling contract.callingContractAddress
,newAdminAddress
):void
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(Defined in: src/modules/rules-engine.ts:1107 Propose a new foreign call admin in the rules engine admin contract. This function proposes a new admin for a specific foreign call.foreignCallAddress
,newAdminAddress
,foreignCallSelector
):void
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(Defined in: src/modules/rules-engine.ts:997 Propose a new admin in the rules engine admin contract. This function proposes a new admin for a specific policy.policyId
,newAdminAddress
):void
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(Defined in: src/modules/rules-engine.ts:813 Removes all addresses from the permission list for a foreign call.foreignCallAddress
,functionSelector
):Promise
<number
>
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
<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
Will log an error to the console if the operation fails.removeClosedPolicySubscriber()
removeClosedPolicySubscriber(Defined in: src/modules/rules-engine.ts:436 Removes a subscriber from the closed policy.policyId
,subscriber
):Promise
<number
>
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
<number
>
0
if successful, -1
if an error occurs.
removeMultipleAdminsFromPermissionList()
removeMultipleAdminsFromPermissionList(Defined in: src/modules/rules-engine.ts:787 Removes multiple addresses from the permission list for a foreign call.foreignCallAddress
,functionSelector
,policyAdminsToRemove
):Promise
<number
>
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
<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
Will log an error to the console if the operation fails.setPolicies()
setPolicies(Defined in: src/modules/rules-engine.ts:281 Sets the policies appled to a specific contract address.policyIds
,contractAddressForPolicy
):void
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
updateForeignCall()
updateForeignCall(Defined in: src/modules/rules-engine.ts:613 Updates a foreign call in the rules engine component contract.policyId
,foreignCallId
,fcSyntax
):Promise
<number
>
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
<number
>
A promise that resolves to the foreign call index. Returns -1
if the operation fails.
Remarks
- 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 offcSyntax
fails.
updatePolicy()
updatePolicy(Defined in: src/modules/rules-engine.ts:255 Updates an existing policy in the Rules Engine.policyId
,callingFunctions
,ids
,ruleIds
,name
,description
):Promise
<number
>
Parameters
Parameter | Type | Description |
---|---|---|
policyId | number | The ID of the policy to update. |
callingFunctions | any [] | The calling functions associated with the policy. |
ids | number [] | The IDs of the rules associated with the policy. |
ruleIds | any [] | The mapping of rules to calling functions. |
name | string | - |
description | string | - |
Returns
Promise
<number
>
The result of the policy update.
updateRule()
updateRule(Defined in: src/modules/rules-engine.ts:490 Updates an existing rule in the Rules Engine Policy Contract.policyId
,ruleId
,ruleS
,foreignCallNameToID
,trackerNameToID
):Promise
<number
>
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 | FCNameToID [] | A mapping of foreign call names to their corresponding IDs. |
trackerNameToID | FCNameToID [] | A mapping of tracker names to their corresponding IDs. |
Returns
Promise
<number
>
A promise that resolves to the result of the rule update operation. Returns the result ID if successful, or -1 if the operation fails.
updateTracker()
updateTracker(Defined in: src/modules/rules-engine.ts:848 Asynchronously updates a tracker in the rules engine component contract.policyId
,trackerId
,trSyntax
):Promise
<number
>
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
<number
>
A promise that resolves to the existing tracker ID is returned. 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()
Defined in: src/modules/rules-engine.ts:191 Creates a Rules Engine instance using the private constructor if the supplied rules engine address is compatible.static
create(rulesEngineAddress
,localConfig
,client
,localConfirmationCount
):Promise
<Maybe
<RulesEngine
>>
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
>>