Skip to content

API ReferenceReact provider and hooksInterface

UseWorkflowPreparationResult\<TParams\>

What every workflow hook returns, such as useCreateLOCWorkflow: methods to check and build a WalletOperationWorkflow from the operation’s params, plus React state that mirrors the latest request.

Both methods resolve with a result object rather than throwing, so a caller can branch on status. Only the most recent call publishes state. Starting a new call, calling reset, or unmounting makes an older call resolve cancelled with reason superseded, and aborting its signal makes it resolve cancelled with reason aborted. Nothing here prompts the wallet: that starts when you call the workflow’s execute().

Type Parameters

Type ParameterDescription
TParamsThe operation’s input, such as CreateLOCWorkflowParams for useCreateLOCWorkflow.

Properties

error

error: Error | undefined;

Why the latest request could not complete, such as a failed chain read. undefined when the latest request finished as valid, invalid, or prepared.


isPreparing

isPreparing: boolean;

true while a validate or prepareWorkflow request is in flight.


issues

issues: ValidationIssue[];

Validation issues from the latest completed request. Empty when that request passed or failed, and after reset.


prepareWorkflow

prepareWorkflow: (params, signal?) => Promise<PrepareWorkflowResult>;

Validates params and, when they pass, builds the workflow. Resolves prepared with the workflow, invalid with the issues found, failed with an error when validation or the build could not complete, or cancelled. Pass an AbortSignal to cancel the request.

Parameters

ParameterType
paramsTParams
signal?AbortSignal

Returns

Promise<PrepareWorkflowResult>


reset

reset: () => void;

Clears workflow, issues, error, and isPreparing, and makes any request still in flight resolve cancelled without updating state.

Returns

void


validate

validate: (params, signal?) => Promise<ValidateWorkflowResult>;

Runs the operation’s validation on params without building a workflow. Resolves valid, invalid with the issues found, failed with an error when the check itself could not complete, or cancelled. The hook keeps its own copy of params, so a later change to the object does not affect the running check. Starting it clears any previously prepared workflow.

Parameters

ParameterType
paramsTParams
signal?AbortSignal

Returns

Promise<ValidateWorkflowResult>


workflow

workflow:
| WalletOperationWorkflow
| undefined;

The workflow the latest prepareWorkflow call built, ready to execute(). undefined until one succeeds, and cleared when a new request starts or reset runs.