Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start end approval flows #1394

Merged
merged 9 commits into from
Jun 9, 2023
Prev Previous commit
Next Next commit
jsdoc
  • Loading branch information
bergarces committed May 26, 2023
commit 4f206c156613a3913c8da361f072403ac22345e8
12 changes: 12 additions & 0 deletions packages/approval-controller/src/ApprovalController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,13 @@ export class ApprovalController extends BaseControllerV2<
});
}

/**
* Starts a new approval flow.
*
* @param opts - Options bag.
* @param opts.id - The id of the approval flow.
* @returns The object containing the approval flow id.
*/
startFlow(opts: ApprovalFlowOptions = {}): ApprovalFlowStartResult {
const id = opts.id ?? nanoid();
const finalOptions = { id };
Expand All @@ -528,6 +535,11 @@ export class ApprovalController extends BaseControllerV2<
return { id };
}

/**
* Ends the current approval flow.
*
* @param flowId - The id of the approval flow to end.
*/
endFlow(flowId: string) {
matthewwalsh0 marked this conversation as resolved.
Show resolved Hide resolved
if (!this.state.approvalFlows.length) {
throw new NoApprovalFlowsError();
Expand Down