Constructors

new RulesEngine()

new RulesEngine(rulesEngineAddress, localConfig, client): RulesEngine

Parameters

ParameterTypeDescription
rulesEngineAddress`0x${string}`The address of the deployed Rules Engine smart contract.
localConfigConfigThe configuration object containing network and wallet information.
clientanyThe client instance for interacting with the blockchain.

Returns

RulesEngine

Defined in

src/modules/rules-engine.ts:124

Methods

addAdminToPermissionList()

addAdminToPermissionList(foreignCallAddress, functionSelector, policyAdminToAdd): Promise<number>
Adds a new address to the permission list for a foreign call.

Parameters

ParameterTypeDescription
foreignCallAddress`0x${string}`the address of the contract the foreign call belongs to.
functionSelectorstringThe 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:664

addClosedPolicySubscriber()

addClosedPolicySubscriber(policyId, subscriber): Promise<number>
Adds a subscriber to the closed policy.

Parameters

ParameterTypeDescription
policyIdnumberThe 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:355

addMultipleAdminsToPermissionList()

addMultipleAdminsToPermissionList(foreignCallAddress, functionSelector, policyAdminsToAdd): Promise<number>
Adds multiple addresses to the permission list for a foreign call.

Parameters

ParameterTypeDescription
foreignCallAddress`0x${string}`the address of the contract the foreign call belongs to.
functionSelectorstringThe 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:690

appendPolicy()

appendPolicy(policyId, contractAddressForPolicy): void
Appends a policy to the list of policies applied to a specific contract address.

Parameters

ParameterTypeDescription
policyIdnumberThe 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:241

cementPolicy()

cementPolicy(policyId): Promise<number>
Cements a policy on the Rules Engine.

Parameters

ParameterTypeDescription
policyIdnumberThe ID of the policy to cement.

Returns

Promise<number> 0 if successful, -1 if an error occurs.

Defined in

src/modules/rules-engine.ts:1122

closePolicy()

closePolicy(policyId): Promise<number>
Closes a policy on the Rules Engine.

Parameters

ParameterTypeDescription
policyIdnumberThe ID of the policy to close.

Returns

Promise<number> 0 if successful, -1 if an error occurs.

Defined in

src/modules/rules-engine.ts:323

confirmNewCallingContractAdmin()

confirmNewCallingContractAdmin(callingContractAddress): void
Confirm a new calling contract admin in the rules engine admin contract. This function confirms a new admin for a specific calling contract.

Parameters

ParameterTypeDescription
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:1012

confirmNewForeignCallAdmin()

confirmNewForeignCallAdmin(foreignCallAddress, foreignCallSelector): void
Confirm a new foreign call admin in the rules engine admin contract. This function confirms a new admin for a specific foreign call.

Parameters

ParameterTypeDescription
foreignCallAddress`0x${string}`The address of the foreign call to set the admin for.
foreignCallSelectorstring-

Returns

void A promise.

Throws

Will retry indefinitely on contract interaction failure, with a delay between attempts.

Defined in

src/modules/rules-engine.ts:1079

confirmNewPolicyAdmin()

confirmNewPolicyAdmin(policyId): void
Confirm a new admin in the rules engine admin contract. This function confirms a new admin for a specific policy.

Parameters

ParameterTypeDescription
policyIdnumberThe 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:952

createCallingFunction()

createCallingFunction(policyId, callingFunction, encodedValues): Promise<number>
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

ParameterTypeDescription
policyIdnumberThe ID of the policy for which the calling contract is being created.
callingFunctionstringThe calling function string to be parsed and added to the contract.
encodedValuesstringthe 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:887

createForeignCall()

createForeignCall(policyId, fcSyntax): Promise<number>
Creates a foreign call in the rules engine component contract.

Parameters

ParameterTypeDescription
policyIdnumberThe ID of the policy to associate with the foreign call.
fcSyntaxstringA 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 of fcSyntax fails.

Defined in

src/modules/rules-engine.ts:513

createNewRule()

createNewRule(policyId, ruleS, foreignCallNameToID, trackerNameToID): Promise<number>
Asynchronously creates a new rule in the rules engine policy contract.

Parameters

ParameterTypeDescription
policyIdnumberThe ID of the policy to which the rule belongs.
ruleSstringA JSON string representing the rule to be created.
foreignCallNameToIDFCNameToID[]An array mapping foreign call names to their corresponding IDs.
trackerNameToIDFCNameToID[]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:399

createPolicy()

createPolicy(policyJSON): Promise<object>
Creates a policy in the Rules Engine.

Parameters

ParameterTypeDescription
policyJSONstringPolicy 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:170

createTracker()

createTracker(policyId, trSyntax): Promise<number>
Asynchronously creates a tracker in the rules engine component contract.

Parameters

ParameterTypeDescription
policyIdnumberThe ID of the policy associated with the tracker.
trSyntaxstringA 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:763

deleteForeignCall()

deleteForeignCall(policyId, foreignCallId): Promise<number>
Deletes a foreign call associated with a specific policy in the rules engine component contract.

Parameters

ParameterTypeDescription
policyIdnumberThe ID of the policy to which the foreign call belongs.
foreignCallIdnumberThe 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:567

deletePolicy()

deletePolicy(policyId): Promise<number>
Deletes a policy from the Rules Engine.

Parameters

ParameterTypeDescription
policyIdnumberThe ID of the policy to delete.

Returns

Promise<number> 0 if successful, -1 if an error occurs.

Defined in

src/modules/rules-engine.ts:256

deleteRule()

deleteRule(policyId, ruleId): Promise<number>
Deletes a rule from the rules engine component contract.

Parameters

ParameterTypeDescription
policyIdnumberThe ID of the policy to which the rule belongs.
ruleIdnumberThe 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:461

deleteTracker()

deleteTracker(policyId, trackerId): Promise<number>
Deletes a tracker associated with a specific policy in the rules engine component contract.

Parameters

ParameterTypeDescription
policyIdnumberThe ID of the policy to which the tracker belongs.
trackerIdnumberThe 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:808

getAllForeignCalls()

getAllForeignCalls(policyId): Promise<Maybe<any[]>>
Retrieves all foreign calls associated with a specific policy ID from the Rules Engine Component Contract.

Parameters

ParameterTypeDescription
policyIdnumberThe 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:602

getAllRules()

getAllRules(policyId): Promise<Maybe<any[]>>
Retrieves all rules associated with a specific policy ID from the Rules Engine Policy Contract.

Parameters

ParameterTypeDescription
policyIdnumberThe 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:494

getAllTrackers()

getAllTrackers(policyId): Promise<Maybe<any[]>>
Retrieves all trackers associated with a specific policy ID from the Rules Engine Component Contract.

Parameters

ParameterTypeDescription
policyIdnumberThe 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:844

getAppliedPolicyIds()

getAppliedPolicyIds(address): Promise<number[]>
Retrieves the IDs of all of the policies that have been applied to a contract address.

Parameters

ParameterTypeDescription
addressstringThe 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:286

getCallingFunctionMetadata()

getCallingFunctionMetadata(policyId, callingFunctionId): Promise<CallingFunctionHashMapping>
retrieves the metadata for a calling function from the rules engine component contract.

Parameters

ParameterTypeDescription
policyIdnumberThe ID of the policy which the calling function belongs to.
callingFunctionIdnumberThe 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:910

getForeignCall()

getForeignCall(policyId, foreignCallId): Promise<any>
Retrieves the result of a foreign call from the rules engine component contract.

Parameters

ParameterTypeDescription
policyIdnumberThe ID of the policy associated with the foreign call.
foreignCallIdnumberThe 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:585

getForeignCallMetadata()

getForeignCallMetadata(policyId, foreignCallId): Promise<any>
Retrieves the metadata for a foreign call from the rules engine component contract.

Parameters

ParameterTypeDescription
policyIdnumberThe ID of the policy associated with the foreign call.
foreignCallIdnumberThe 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:619

getForeignCallPermissionList()

getForeignCallPermissionList(foreignCallAddress, functionSelector): Promise<`0x${string}`[]>
Retrieves the permission list for a permissioned foreign call.

Parameters

ParameterTypeDescription
foreignCallAddress`0x${string}`the address of the contract the foreign call belongs to.
functionSelectorstringThe 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:640

getPolicy()

getPolicy(policyId): Promise<string>
Retrieves the full policy, including rules, trackers, and foreign calls, as a JSON string.

Parameters

ParameterTypeDescription
policyIdnumberThe ID of the policy to retrieve.

Returns

Promise<string> A JSON string representing the full policy.

Defined in

src/modules/rules-engine.ts:270

getRule()

getRule(policyId, ruleId): Promise<Maybe<RuleStruct>>
Retrieves a specific rule from the Rules Engine.

Parameters

ParameterTypeDescription
policyIdnumberThe ID of the policy containing the rule.
ruleIdnumberThe 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:477

getRulesEngineComponentContract()

getRulesEngineComponentContract(): object

Returns

object
abi
abi: (object | object | object)[]
address
address: `0x${string}`

Defined in

src/modules/rules-engine.ts:155

getRulesEngineForeignCallContract()

getRulesEngineForeignCallContract(): object

Returns

object
abi
abi: (object | object | object)[]
address
address: `0x${string}`

Defined in

src/modules/rules-engine.ts:161

getRulesEnginePolicyContract()

getRulesEnginePolicyContract(): object

Returns

object
abi
abi: (object | object)[]
address
address: `0x${string}`

Defined in

src/modules/rules-engine.ts:152

getRulesEngineRulesContract()

getRulesEngineRulesContract(): object

Returns

object
abi
abi: (object | object | object)[]
address
address: `0x${string}`

Defined in

src/modules/rules-engine.ts:158

getTracker()

getTracker(policyId, trackerId): Promise<any>
Retrieves a tracker from the Rules Engine Component Contract based on the provided policy ID and tracker ID.

Parameters

ParameterTypeDescription
policyIdnumberThe ID of the policy associated with the tracker.
trackerIdnumberThe 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:826

getTrackerMetadata()

getTrackerMetadata(policyId, trackerId): Promise<Maybe<string>>
Retrieves the metadata for a tracker from the Rules Engine Component Contract based on the provided policy ID and tracker ID.

Parameters

ParameterTypeDescription
policyIdnumberThe ID of the policy associated with the tracker.
trackerIdnumberThe 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:861

isCallingContractAdmin()

isCallingContractAdmin(callingContract, account): Promise<boolean>
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

ParameterTypeDescription
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:1030

isCementedPolicy()

isCementedPolicy(policyId): Promise<boolean>
Retrieves whether a policy is cemented.

Parameters

ParameterTypeDescription
policyIdnumberThe ID of the policy to check.

Returns

Promise<boolean> whether or not the policy is cemented

Defined in

src/modules/rules-engine.ts:1135

isClosedPolicy()

isClosedPolicy(policyId): Promise<boolean>
Retrieves whether a policy is open or closed.

Parameters

ParameterTypeDescription
policyIdnumberThe 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:299

isClosedPolicySubscriber()

isClosedPolicySubscriber(policyId, subscriber): Promise<boolean>
Retrieves whether an address is a possible subscriber to the closed policy.

Parameters

ParameterTypeDescription
policyIdnumberThe 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:337

isForeignCallAdmin()

isForeignCallAdmin(foreignCallAddress, account, foreignCallSelector): Promise<boolean>
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

ParameterTypeDescription
foreignCallAddress`0x${string}`-
account`0x${string}`The address to check
foreignCallSelectorstring-

Returns

Promise<boolean> whether or not the address is the foreign call admin.

Defined in

src/modules/rules-engine.ts:1102

isPolicyAdmin()

isPolicyAdmin(policyId, adminAddress): Promise<boolean>
Determine if address is policy admin. This function determines whether or not an address is the admin for a specific policy.

Parameters

ParameterTypeDescription
policyIdnumberThe 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:970

openPolicy()

openPolicy(policyId): Promise<number>
Opens a policy on the Rules Engine.

Parameters

ParameterTypeDescription
policyIdnumberThe ID of the policy to open.

Returns

Promise<number> 0 if successful, -1 if an error occurs.

Defined in

src/modules/rules-engine.ts:313

policyExists()

policyExists(policyId): Promise<boolean>
Checks if a policy exists in the Rules Engine.

Parameters

ParameterTypeDescription
policyIdnumberThe ID of the policy to check.

Returns

Promise<boolean> True if the policy exists, false otherwise.

Defined in

src/modules/rules-engine.ts:187

proposeCallingContractAdmin()

proposeCallingContractAdmin(callingContractAddress, newAdminAddress): void
Propose a new calling contract admin in the rules engine admin contract. This function proposes a new admin for a specific calling contract.

Parameters

ParameterTypeDescription
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:990

proposeForeignCallAdmin()

proposeForeignCallAdmin(foreignCallAddress, newAdminAddress, foreignCallSelector): void
Propose a new foreign call admin in the rules engine admin contract. This function proposes a new admin for a specific foreign call.

Parameters

ParameterTypeDescription
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
foreignCallSelectorstring-

Returns

void A promise.

Throws

Will retry indefinitely on contract interaction failure, with a delay between attempts.

Defined in

src/modules/rules-engine.ts:1054

proposeNewPolicyAdmin()

proposeNewPolicyAdmin(policyId, newAdminAddress): void
Propose a new admin in the rules engine admin contract. This function proposes a new admin for a specific policy.

Parameters

ParameterTypeDescription
policyIdnumberThe 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:933

removeAllFromPermissionList()

removeAllFromPermissionList(foreignCallAddress, functionSelector): Promise<number>
Removes all addresses from the permission list for a foreign call.

Parameters

ParameterTypeDescription
foreignCallAddress`0x${string}`the address of the contract the foreign call belongs to.
functionSelectorstringThe 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:741

removeClosedPolicySubscriber()

removeClosedPolicySubscriber(policyId, subscriber): Promise<number>
Removes a subscriber from the closed policy.

Parameters

ParameterTypeDescription
policyIdnumberThe 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:374

removeMultipleAdminsFromPermissionList()

removeMultipleAdminsFromPermissionList(foreignCallAddress, functionSelector, policyAdminsToRemove): Promise<number>
Removes multiple addresses from the permission list for a foreign call.

Parameters

ParameterTypeDescription
foreignCallAddress`0x${string}`the address of the contract the foreign call belongs to.
functionSelectorstringThe 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:716

setPolicies()

setPolicies(policyIds, contractAddressForPolicy): void
Sets the policies appled to a specific contract address.

Parameters

ParameterTypeDescription
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:226

updateForeignCall()

updateForeignCall(policyId, foreignCallId, fcSyntax): Promise<number>
Updates a foreign call in the rules engine component contract.

Parameters

ParameterTypeDescription
policyIdnumberThe ID of the policy to associate with the foreign call.
foreignCallIdnumberThe ID of the foreign call to update.
fcSyntaxstringA 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 of fcSyntax fails.

Defined in

src/modules/rules-engine.ts:540

updatePolicy()

updatePolicy(policyId, callingFunctions, ids, ruleIds): Promise<number>
Updates an existing policy in the Rules Engine.

Parameters

ParameterTypeDescription
policyIdnumberThe ID of the policy to update.
callingFunctionsany[]The calling functions associated with the policy.
idsnumber[]The IDs of the rules associated with the policy.
ruleIdsany[]The mapping of rules to calling functions.

Returns

Promise<number> The result of the policy update.

Defined in

src/modules/rules-engine.ts:204

updateRule()

updateRule(policyId, ruleId, ruleS, foreignCallNameToID, trackerNameToID): Promise<number>
Updates an existing rule in the Rules Engine Policy Contract.

Parameters

ParameterTypeDescription
policyIdnumberThe ID of the policy to which the rule belongs.
ruleIdnumberThe ID of the rule to be updated.
ruleSstringA JSON string representing the rule’s structure and logic.
foreignCallNameToIDFCNameToID[]A mapping of foreign call names to their corresponding IDs.
trackerNameToIDFCNameToID[]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:429

updateTracker()

updateTracker(policyId, trackerId, trSyntax): Promise<number>
Asynchronously updates a tracker in the rules engine component contract.

Parameters

ParameterTypeDescription
policyIdnumberThe ID of the policy associated with the tracker.
trackerIdnumberThe ID of the tracker to update.
trSyntaxstringA 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.

Defined in

src/modules/rules-engine.ts:783