Demoswork
Last updated
Last updated
DemosWork is a module that helps you create a script (DemosScript) that can be executed on the omniweb.
A DemosScript
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.
DemosWork is implemented as a class that looks like this:
@/demoswork/work.ts
The push
method adds an operation to the DemoScript.
API Reference:
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:
The 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.
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:
The 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.
A conditional operation now builds on top of that:
@/demoswork/operations/conditional/index.ts
A conditional operation is created by passing in conditions to the constructor. The if
, then
and else
methods are helpers that can be used to build a conditional operation by chaining them together.
The base operation groups steps and operations together without any additional logic.
The base operation is implemented as follows:
@/demoswork/operations/baseoperation.ts
Work can be added to the base operation by passing in the work to the constructor or using the addWork
method.
This is an ordered list of Operation UID strings. It dictates the order in which the operations in a script are supposed to be executed.
API Reference:
API Reference:
API Reference: