Constructors
new RulesEngine()
new RulesEngine(rulesEngineAddress
,localConfig
,client
):RulesEngine
Parameters
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. |
Returns
RulesEngine
Defined in
src/modules/rules-engine.ts:124Methods
addAdminToPermissionList()
addAdminToPermissionList(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.Defined in
src/modules/rules-engine.ts:664addClosedPolicySubscriber()
addClosedPolicySubscriber(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.
Defined in
src/modules/rules-engine.ts:355addMultipleAdminsToPermissionList()
addMultipleAdminsToPermissionList(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 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.Defined in
src/modules/rules-engine.ts:690appendPolicy()
appendPolicy(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
Defined in
src/modules/rules-engine.ts:241cementPolicy()
cementPolicy(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.
Defined in
src/modules/rules-engine.ts:1122closePolicy()
closePolicy(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.
Defined in
src/modules/rules-engine.ts:323confirmNewCallingContractAdmin()
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
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.Defined in
src/modules/rules-engine.ts:1012confirmNewForeignCallAdmin()
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
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.Defined in
src/modules/rules-engine.ts:1079confirmNewPolicyAdmin()
confirmNewPolicyAdmin(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.Defined in
src/modules/rules-engine.ts:952createCallingFunction()
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
>
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.Defined in
src/modules/rules-engine.ts:887createForeignCall()
createForeignCall(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.
Defined in
src/modules/rules-engine.ts:513createNewRule()
createNewRule(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.
Defined in
src/modules/rules-engine.ts:399createPolicy()
createPolicy(Creates a policy in the Rules Engine.policyJSON
):Promise
<object
>
Parameters
Parameter | Type | Description |
---|---|---|
policyJSON | string | Policy defined in a JSON string. |
Returns
Promise
<object
>
The ID of the newly created policy.
policyId
policyId: number
Defined in
src/modules/rules-engine.ts:170createTracker()
createTracker(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.Defined in
src/modules/rules-engine.ts:763deleteForeignCall()
deleteForeignCall(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.
Defined in
src/modules/rules-engine.ts:567deletePolicy()
deletePolicy(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.
Defined in
src/modules/rules-engine.ts:256deleteRule()
deleteRule(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.
Defined in
src/modules/rules-engine.ts:461deleteTracker()
deleteTracker(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.
Defined in
src/modules/rules-engine.ts:808getAllForeignCalls()
getAllForeignCalls(Retrieves all foreign calls associated with a specific policy ID from the Rules Engine Component Contract.policyId
):Promise
<Maybe
<any
[]>>
Parameters
Parameter | Type | Description |
---|---|---|
policyId | number | The ID of the policy for which foreign calls are to be retrieved. |
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.Defined in
src/modules/rules-engine.ts:602getAllRules()
getAllRules(Retrieves all rules associated with a specific policy ID from the Rules Engine Policy Contract.policyId
):Promise
<Maybe
<any
[]>>
Parameters
Parameter | Type | Description |
---|---|---|
policyId | number | The unique identifier of the policy for which rules are to be retrieved. |
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.Defined in
src/modules/rules-engine.ts:494getAllTrackers()
getAllTrackers(Retrieves all trackers associated with a specific policy ID from the Rules Engine Component Contract.policyId
):Promise
<Maybe
<any
[]>>
Parameters
Parameter | Type | Description |
---|---|---|
policyId | number | The unique identifier of the policy for which trackers are to be retrieved. including its address and ABI. |
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.Defined in
src/modules/rules-engine.ts:844getAppliedPolicyIds()
getAppliedPolicyIds(Retrieves the IDs of all of the policies that have been applied to a contract address.address
):Promise
<number
[]>
Parameters
Parameter | Type | Description |
---|---|---|
address | string | The ID of the policy to check. |
Returns
Promise
<number
[]>
array of all of the policy ids applied to the contract
Defined in
src/modules/rules-engine.ts:286getCallingFunctionMetadata()
getCallingFunctionMetadata(retrieves the metadata for a calling function from the rules engine component contract.policyId
,callingFunctionId
):Promise
<CallingFunctionHashMapping
>
Parameters
Parameter | Type | Description |
---|---|---|
policyId | number | The ID of the policy which the calling function belongs to. |
callingFunctionId | number | The Calling Function ID. |
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.Defined in
src/modules/rules-engine.ts:910getForeignCall()
getForeignCall(Retrieves the result of a foreign call from the rules engine component contract.policyId
,foreignCallId
):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. |
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.Defined in
src/modules/rules-engine.ts:585getForeignCallMetadata()
getForeignCallMetadata(Retrieves the metadata for a foreign call from the rules engine component contract.policyId
,foreignCallId
):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. |
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.Defined in
src/modules/rules-engine.ts:619getForeignCallPermissionList()
getForeignCallPermissionList(Retrieves the permission list for a permissioned foreign call.foreignCallAddress
,functionSelector
):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 |
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.Defined in
src/modules/rules-engine.ts:640getPolicy()
getPolicy(Retrieves the full policy, including rules, trackers, and foreign calls, as a JSON string.policyId
):Promise
<string
>
Parameters
Parameter | Type | Description |
---|---|---|
policyId | number | The ID of the policy to retrieve. |
Returns
Promise
<string
>
A JSON string representing the full policy.
Defined in
src/modules/rules-engine.ts:270getRule()
getRule(Retrieves a specific rule from the Rules Engine.policyId
,ruleId
):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. |
Returns
Promise
<Maybe
<RuleStruct
>>
The retrieved rule as a RuleStruct
, or null
if retrieval fails.
Defined in
src/modules/rules-engine.ts:477getRulesEngineComponentContract()
getRulesEngineComponentContract(): object
Returns
object
abi
abi: (object
|object
|object
)[]
address
address: `0x${string}`
Defined in
src/modules/rules-engine.ts:155getRulesEngineForeignCallContract()
getRulesEngineForeignCallContract(): object
Returns
object
abi
abi: (object
|object
|object
)[]
address
address: `0x${string}`
Defined in
src/modules/rules-engine.ts:161getRulesEnginePolicyContract()
getRulesEnginePolicyContract(): object
Returns
object
abi
abi: (object
|object
)[]
address
address: `0x${string}`
Defined in
src/modules/rules-engine.ts:152getRulesEngineRulesContract()
getRulesEngineRulesContract(): object
Returns
object
abi
abi: (object
|object
|object
)[]
address
address: `0x${string}`
Defined in
src/modules/rules-engine.ts:158getTracker()
getTracker(Retrieves a tracker from the Rules Engine Component Contract based on the provided policy ID and tracker ID.policyId
,trackerId
):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. |
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.Defined in
src/modules/rules-engine.ts:826getTrackerMetadata()
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
>>
Parameters
Parameter | Type | Description |
---|---|---|
policyId | number | The ID of the policy associated with the tracker. |
trackerId | number | The ID of the tracker to retrieve. |
Returns
Promise
<Maybe
<string
>>
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.Defined in
src/modules/rules-engine.ts:861isCallingContractAdmin()
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
>
Parameters
Parameter | Type | Description |
---|---|---|
callingContract | `0x${string}` | The address of the contract to check the admin for. |
account | `0x${string}` | The address to check |
Returns
Promise
<boolean
>
whether or not the address is the calling contract admin.
Defined in
src/modules/rules-engine.ts:1030isCementedPolicy()
isCementedPolicy(Retrieves whether a policy is cemented.policyId
):Promise
<boolean
>
Parameters
Parameter | Type | Description |
---|---|---|
policyId | number | The ID of the policy to check. |
Returns
Promise
<boolean
>
whether or not the policy is cemented
Defined in
src/modules/rules-engine.ts:1135isClosedPolicy()
isClosedPolicy(Retrieves whether a policy is open or closed.policyId
):Promise
<boolean
>
Parameters
Parameter | Type | Description |
---|---|---|
policyId | number | The ID of the policy to check. |
Returns
Promise
<boolean
>
array of all of the policy ids applied to the contract
Defined in
src/modules/rules-engine.ts:299isClosedPolicySubscriber()
isClosedPolicySubscriber(Retrieves whether an address is a possible subscriber to the closed policy.policyId
,subscriber
):Promise
<boolean
>
Parameters
Parameter | Type | Description |
---|---|---|
policyId | number | The ID of the policy to check. |
subscriber | `0x${string}` | The address to check |
Returns
Promise
<boolean
>
array of all of the policy ids applied to the contract
Defined in
src/modules/rules-engine.ts:337isForeignCallAdmin()
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
>
Parameters
Parameter | Type | Description |
---|---|---|
foreignCallAddress | `0x${string}` | - |
account | `0x${string}` | The address to check |
foreignCallSelector | string | - |
Returns
Promise
<boolean
>
whether or not the address is the foreign call admin.
Defined in
src/modules/rules-engine.ts:1102isPolicyAdmin()
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
>
Parameters
Parameter | Type | Description |
---|---|---|
policyId | number | The ID of the policy to check the admin for. |
adminAddress | `0x${string}` | The address to check |
Returns
Promise
<boolean
>
whether or not the address is the policy admin.
Defined in
src/modules/rules-engine.ts:970openPolicy()
openPolicy(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.
Defined in
src/modules/rules-engine.ts:313policyExists()
policyExists(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.
Defined in
src/modules/rules-engine.ts:187proposeCallingContractAdmin()
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
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.Defined in
src/modules/rules-engine.ts:990proposeForeignCallAdmin()
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
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.Defined in
src/modules/rules-engine.ts:1054proposeNewPolicyAdmin()
proposeNewPolicyAdmin(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.Defined in
src/modules/rules-engine.ts:933removeAllFromPermissionList()
removeAllFromPermissionList(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.Defined in
src/modules/rules-engine.ts:741removeClosedPolicySubscriber()
removeClosedPolicySubscriber(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.
Defined in
src/modules/rules-engine.ts:374removeMultipleAdminsFromPermissionList()
removeMultipleAdminsFromPermissionList(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.Defined in
src/modules/rules-engine.ts:716setPolicies()
setPolicies(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
Defined in
src/modules/rules-engine.ts:226updateForeignCall()
updateForeignCall(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.
Defined in
src/modules/rules-engine.ts:540updatePolicy()
updatePolicy(Updates an existing policy in the Rules Engine.policyId
,callingFunctions
,ids
,ruleIds
):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. |
Returns
Promise
<number
>
The result of the policy update.
Defined in
src/modules/rules-engine.ts:204updateRule()
updateRule(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.
Defined in
src/modules/rules-engine.ts:429updateTracker()
updateTracker(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.