37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
import type { FlowContext, StepType } from "../types.js";
|
|
import { WizardFlow } from "./WizardFlow.js";
|
|
|
|
/**
|
|
* Flow strategy for transaction-based actions.
|
|
*
|
|
* Handles both single-role actions (sendSatoshis, burn) where the
|
|
* creator provides inputs and signs locally, and multi-role actions
|
|
* (receive, request) where the creator publishes an invitation for
|
|
* another party to complete.
|
|
*/
|
|
export class TransactionWizardFlow extends WizardFlow {
|
|
readonly type = "transaction" as const;
|
|
|
|
getStepTypes(context: FlowContext): StepType[] {
|
|
const steps: StepType[] = [];
|
|
if (context.availableRoles.length > 1) steps.push("role-select");
|
|
if (context.hasVariables) steps.push("variables");
|
|
if (context.shouldCollectInputs) steps.push("inputs");
|
|
steps.push("review");
|
|
steps.push("publish");
|
|
return steps;
|
|
}
|
|
|
|
canFinalize(context: FlowContext): boolean {
|
|
return (
|
|
context.requirementsComplete &&
|
|
context.wizardCollectedInputs &&
|
|
!context.hasSignedAndBroadcasted
|
|
);
|
|
}
|
|
|
|
getFinalActionLabel(context: FlowContext): string {
|
|
return this.canFinalize(context) ? "Sign & Broadcast" : "Done";
|
|
}
|
|
}
|