Demoswork
DemosWork is a module that helps you create a script (DemosScript) that can be executed on the omniweb. ADemosScript is made up of these components:
- Work steps - A step is a single action that can be executed on the omniweb.
- Operations - An operation is a group of steps or a conditional.
- The operation order - This is an ordered list of operation UIDs. It dictates the order in which the operations in a script are supposed to be executed.
push method adds an operation to the DemoScript.
API Reference: https://kynesyslabs.github.io/demosdk-api-ref/classes/demoswork.DemosWork.html
Work steps
A work step is a single action that can be executed on the omniweb. It can either be a web2, xm or a native transaction. Say for example, sending tokens on Ethereum or calling a web2 API. A work step is implemented as follows:critical property is used to stop the execution of the DemoScript if this step fails. The depends_on array is a list of work steps or operations that should be executed successfully before this step is executed.
The output of a workstep indicated above is not the result of executing the step. Since we don’t have that value yet, the output is represented as objects that operations can use to refer to the future/actual output of the step.
The output of a workstep indicated above is not the result of executing the step. Since we don’t have that value yet, the output is represented as objects that operations can use to refer to the future/actual output of the step.
When executing an operation that needs an output of a step, that step will be executed and its result parsed using the key specified to get the value.
API Reference: https://kynesyslabs.github.io/demosdk-api-ref/classes/demoswork.WorkStep.html
Operations
An operation controls the execution of steps therefore enabling scripting on the omniweb. An operation can be a group of steps or a conditional. An operation is implemented as follows:critical property is used to stop the execution of the DemoScript if a step fails. The depends_on array is a list of worksteps or operations that should be executed successfully before an operation is executed.
The operation class indexes the steps and operations it contains in the steps and operations fields. The operationScript field is specific to the operation type and is copied into the main script when the operation is added to the work instance.
The
addWork method is used to add steps and operations to the operation (where applicable). If the work passed is an operation, its steps and operations are copied into the current operation.Conditional Operation
A conditional operation now builds on top of that: @/demoswork/operations/conditional/index.tsif, then and else methods are helpers that can be used to build a conditional operation by chaining them together.
API Reference: https://kynesyslabs.github.io/demosdk-api-ref/classes/demoswork.ConditionalOperation.html
Base Operation
The base operation groups steps and operations together without any additional logic. The base operation is implemented as follows: @/demoswork/operations/baseoperation.tsaddWork method.
API Reference: https://kynesyslabs.github.io/demosdk-api-ref/classes/demoswork.BaseOperation.html