new RulesEngine(rulesEngineAddress
,localConfig
,client
):RulesEngine
Parameter | Type | Description |
---|---|---|
rulesEngineAddress | `0x${string}` | The address of the deployed Rules Engine smart contract. |
localConfig | Config | The configuration object containing network and wallet information. |
client | any | The client instance for interacting with the blockchain. |
RulesEngine
addAdminToPermissionList(Adds a new address to the permission list for a foreign call.foreignCallAddress
,functionSelector
,policyAdminToAdd
):Promise
<number
>
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 |
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.
addClosedPolicySubscriber(Adds a subscriber to the closed policy.policyId
,subscriber
):Promise
<number
>
Parameter | Type | Description |
---|---|---|
policyId | number | The ID of the policy to add to. |
subscriber | `0x${string}` | The address of the subscriber to add. |
Promise
<number
>
0
if successful, -1
if an error occurs.
addMultipleAdminsToPermissionList(Adds multiple addresses to the permission list for a foreign call.foreignCallAddress
,functionSelector
,policyAdminsToAdd
):Promise
<number
>
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 address of the admins to remove from the list |
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.
appendPolicy(Appends a policy to the list of policies applied to a specific contract address.policyId
,contractAddressForPolicy
):void
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. |
void
cementPolicy(Cements a policy on the Rules Engine.policyId
):Promise
<number
>
Parameter | Type | Description |
---|---|---|
policyId | number | The ID of the policy to cement. |
Promise
<number
>
0
if successful, -1
if an error occurs.
closePolicy(Closes a policy on the Rules Engine.policyId
):Promise
<number
>
Parameter | Type | Description |
---|---|---|
policyId | number | The ID of the policy to close. |
Promise
<number
>
0
if successful, -1
if an error occurs.
confirmNewCallingContractAdmin(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
Parameter | Type | Description |
---|---|---|
callingContractAddress | `0x${string}` | The address of the calling contract to set the admin for. |
void
A promise that resolves to the result of the contract interaction, or -1 if unsuccessful.
confirmNewForeignCallAdmin(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
Parameter | Type | Description |
---|---|---|
foreignCallAddress | `0x${string}` | The address of the foreign call to set the admin for. |
foreignCallSelector | string | - |
void
A promise.
confirmNewPolicyAdmin(Confirm a new admin in the rules engine admin contract. This function confirms a new admin for a specific policy.policyId
):void
Parameter | Type | Description |
---|---|---|
policyId | number | The ID of the policy to set the admin for. |
void
A promise that resolves to the result of the contract interaction, or -1 if unsuccessful.
createCallingFunction(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
>
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. |
Promise
<number
>
A promise that resolves to the result of the contract interaction, or -1 if unsuccessful.
createForeignCall(Creates a foreign call in the rules engine component contract.policyId
,fcSyntax
):Promise
<number
>
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. |
Promise
<number
>
A promise that resolves to the foreign call index. Returns -1
if the operation fails.
simulateContract
function is used to simulate the contract interaction before writing to the blockchain.writeContract
function is used to execute the contract interaction on the blockchain.foreignCallIndex
for an updated foreign call or the result of the newly created foreign call.fcSyntax
fails.
createNewRule(Asynchronously creates a new rule in the rules engine policy contract.policyId
,ruleS
,foreignCallNameToID
,trackerNameToID
):Promise
<number
>
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. |
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.
createPolicy(Creates a policy in the Rules Engine.policyJSON
):Promise
<object
>
Parameter | Type | Description |
---|---|---|
policyJSON | string | Policy defined in a JSON string. |
Promise
<object
>
The ID of the newly created policy.
policyId: number
createTracker(Asynchronously creates a tracker in the rules engine component contract.policyId
,trSyntax
):Promise
<number
>
Parameter | Type | Description |
---|---|---|
policyId | number | The ID of the policy associated with the tracker. |
trSyntax | string | A JSON string representing the tracker syntax. |
Promise
<number
>
A promise that resolves to the new tracker ID
deleteForeignCall(Deletes a foreign call associated with a specific policy in the rules engine component contract.policyId
,foreignCallId
):Promise
<number
>
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. |
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.
-1
if an error occurs during the simulation phase.
deletePolicy(Deletes a policy from the Rules Engine.policyId
):Promise
<number
>
Parameter | Type | Description |
---|---|---|
policyId | number | The ID of the policy to delete. |
Promise
<number
>
0
if successful, -1
if an error occurs.
deleteRule(Deletes a rule from the rules engine component contract.policyId
,ruleId
):Promise
<number
>
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. |
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.
-1
in case of an exception.
deleteTracker(Deletes a tracker associated with a specific policy in the rules engine component contract.policyId
,trackerId
):Promise
<number
>
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. |
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.
-1
if an error occurs during the simulation phase.
getAllForeignCalls(Retrieves all foreign calls associated with a specific policy ID from the Rules Engine Component Contract.policyId
):Promise
<Maybe
<any
[]>>
Parameter | Type | Description |
---|---|---|
policyId | number | The ID of the policy for which foreign calls are to be retrieved. |
Promise
<Maybe
<any
[]>>
A promise that resolves to an array of foreign calls if successful, or null
if an error occurs.
getAllRules(Retrieves all rules associated with a specific policy ID from the Rules Engine Policy Contract.policyId
):Promise
<Maybe
<any
[]>>
Parameter | Type | Description |
---|---|---|
policyId | number | The unique identifier of the policy for which rules are to be retrieved. |
Promise
<Maybe
<any
[]>>
A promise that resolves to an array of rules if successful, or null
if an error occurs.
getAllTrackers(Retrieves all trackers associated with a specific policy ID from the Rules Engine Component Contract.policyId
):Promise
<Maybe
<any
[]>>
Parameter | Type | Description |
---|---|---|
policyId | number | The unique identifier of the policy for which trackers are to be retrieved. including its address and ABI. |
Promise
<Maybe
<any
[]>>
A promise that resolves to an array of trackers if successful, or null
if an error occurs.
getAppliedPolicyIds(Retrieves the IDs of all of the policies that have been applied to a contract address.address
):Promise
<number
[]>
Parameter | Type | Description |
---|---|---|
address | string | The ID of the policy to check. |
Promise
<number
[]>
array of all of the policy ids applied to the contract
getCallingFunctionMetadata(retrieves the metadata for a calling function from the rules engine component contract.policyId
,callingFunctionId
):Promise
<CallingFunctionHashMapping
>
Parameter | Type | Description |
---|---|---|
policyId | number | The ID of the policy which the calling function belongs to. |
callingFunctionId | number | The Calling Function ID. |
Promise
<CallingFunctionHashMapping
>
A promise that resolves to the result of the contract interaction.
getForeignCall(Retrieves the result of a foreign call from the rules engine component contract.policyId
,foreignCallId
):Promise
<any
>
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. |
Promise
<any
>
A promise that resolves to the result of the foreign call, or null
if an error occurs.
getForeignCallMetadata(Retrieves the metadata for a foreign call from the rules engine component contract.policyId
,foreignCallId
):Promise
<any
>
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. |
Promise
<any
>
A promise that resolves to the result of the foreign call, or null
if an error occurs.
getForeignCallPermissionList(Retrieves the permission list for a permissioned foreign call.foreignCallAddress
,functionSelector
):Promise
<`0x${string}`[]>
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 |
Promise
<`0x${string}`[]>
Array of addresses that make up the permission list
getPolicy(Retrieves the full policy, including rules, trackers, and foreign calls, as a JSON string.policyId
):Promise
<string
>
Parameter | Type | Description |
---|---|---|
policyId | number | The ID of the policy to retrieve. |
Promise
<string
>
A JSON string representing the full policy.
getRule(Retrieves a specific rule from the Rules Engine.policyId
,ruleId
):Promise
<Maybe
<RuleStruct
>>
Parameter | Type | Description |
---|---|---|
policyId | number | The ID of the policy containing the rule. |
ruleId | number | The ID of the rule to retrieve. |
Promise
<Maybe
<RuleStruct
>>
The retrieved rule as a RuleStruct
, or null
if retrieval fails.
getRulesEngineComponentContract(): object
object
abi: (object
|object
|object
)[]
address: `0x${string}`
getRulesEngineForeignCallContract(): object
object
abi: (object
|object
|object
)[]
address: `0x${string}`
getRulesEnginePolicyContract(): object
object
abi: (object
|object
)[]
address: `0x${string}`
getRulesEngineRulesContract(): object
object
abi: (object
|object
|object
)[]
address: `0x${string}`
getTracker(Retrieves a tracker from the Rules Engine Component Contract based on the provided policy ID and tracker ID.policyId
,trackerId
):Promise
<any
>
Parameter | Type | Description |
---|---|---|
policyId | number | The ID of the policy associated with the tracker. |
trackerId | number | The ID of the tracker to retrieve. |
Promise
<any
>
A promise that resolves to the tracker result if successful, or null
if an error occurs.
getTrackerMetadata(Retrieves the metadata for a tracker from the Rules Engine Component Contract based on the provided policy ID and tracker ID.policyId
,trackerId
):Promise
<Maybe
<string
>>
Parameter | Type | Description |
---|---|---|
policyId | number | The ID of the policy associated with the tracker. |
trackerId | number | The ID of the tracker to retrieve. |
Promise
<Maybe
<string
>>
A promise that resolves to the tracker metadata result if successful, or null
if an error occurs.
isCallingContractAdmin(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
):Promise
<boolean
>
Parameter | Type | Description |
---|---|---|
callingContract | `0x${string}` | The address of the contract to check the admin for. |
account | `0x${string}` | The address to check |
Promise
<boolean
>
whether or not the address is the calling contract admin.
isCementedPolicy(Retrieves whether a policy is cemented.policyId
):Promise
<boolean
>
Parameter | Type | Description |
---|---|---|
policyId | number | The ID of the policy to check. |
Promise
<boolean
>
whether or not the policy is cemented
isClosedPolicy(Retrieves whether a policy is open or closed.policyId
):Promise
<boolean
>
Parameter | Type | Description |
---|---|---|
policyId | number | The ID of the policy to check. |
Promise
<boolean
>
array of all of the policy ids applied to the contract
isClosedPolicySubscriber(Retrieves whether an address is a possible subscriber to the closed policy.policyId
,subscriber
):Promise
<boolean
>
Parameter | Type | Description |
---|---|---|
policyId | number | The ID of the policy to check. |
subscriber | `0x${string}` | The address to check |
Promise
<boolean
>
array of all of the policy ids applied to the contract
isForeignCallAdmin(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
):Promise
<boolean
>
Parameter | Type | Description |
---|---|---|
foreignCallAddress | `0x${string}` | - |
account | `0x${string}` | The address to check |
foreignCallSelector | string | - |
Promise
<boolean
>
whether or not the address is the foreign call admin.
isPolicyAdmin(Determine if address is policy admin. This function determines whether or not an address is the admin for a specific policy.policyId
,adminAddress
):Promise
<boolean
>
Parameter | Type | Description |
---|---|---|
policyId | number | The ID of the policy to check the admin for. |
adminAddress | `0x${string}` | The address to check |
Promise
<boolean
>
whether or not the address is the policy admin.
openPolicy(Opens a policy on the Rules Engine.policyId
):Promise
<number
>
Parameter | Type | Description |
---|---|---|
policyId | number | The ID of the policy to open. |
Promise
<number
>
0
if successful, -1
if an error occurs.
policyExists(Checks if a policy exists in the Rules Engine.policyId
):Promise
<boolean
>
Parameter | Type | Description |
---|---|---|
policyId | number | The ID of the policy to check. |
Promise
<boolean
>
True if the policy exists, false otherwise.
proposeCallingContractAdmin(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
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 |
void
A promise that resolves to the result of the contract interaction, or -1 if unsuccessful.
proposeForeignCallAdmin(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
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 | - |
void
A promise.
proposeNewPolicyAdmin(Propose a new admin in the rules engine admin contract. This function proposes a new admin for a specific policy.policyId
,newAdminAddress
):void
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 |
void
A promise that resolves to the result of the contract interaction, or -1 if unsuccessful.
removeAllFromPermissionList(Removes all addresses from the permission list for a foreign call.foreignCallAddress
,functionSelector
):Promise
<number
>
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 |
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.
removeClosedPolicySubscriber(Removes a subscriber from the closed policy.policyId
,subscriber
):Promise
<number
>
Parameter | Type | Description |
---|---|---|
policyId | number | The ID of the policy to remove from. |
subscriber | `0x${string}` | The address of the subscriber to remove. |
Promise
<number
>
0
if successful, -1
if an error occurs.
removeMultipleAdminsFromPermissionList(Removes multiple addresses from the permission list for a foreign call.foreignCallAddress
,functionSelector
,policyAdminsToRemove
):Promise
<number
>
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 |
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.
setPolicies(Sets the policies appled to a specific contract address.policyIds
,contractAddressForPolicy
):void
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. |
void
updateForeignCall(Updates a foreign call in the rules engine component contract.policyId
,foreignCallId
,fcSyntax
):Promise
<number
>
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. |
Promise
<number
>
A promise that resolves to the foreign call index. Returns -1
if the operation fails.
simulateContract
function is used to simulate the contract interaction before writing to the blockchain.writeContract
function is used to execute the contract interaction on the blockchain.foreignCallIndex
for an updated foreign call or the result of the newly created foreign call.fcSyntax
fails.
updatePolicy(Updates an existing policy in the Rules Engine.policyId
,callingFunctions
,ids
,ruleIds
):Promise
<number
>
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. |
Promise
<number
>
The result of the policy update.
updateRule(Updates an existing rule in the Rules Engine Policy Contract.policyId
,ruleId
,ruleS
,foreignCallNameToID
,trackerNameToID
):Promise
<number
>
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. |
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(Asynchronously updates a tracker in the rules engine component contract.policyId
,trackerId
,trSyntax
):Promise
<number
>
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. |
Promise
<number
>
A promise that resolves to the existing tracker ID is returned. Returns -1 if the operation fails.