API ReferenceReact provider and hooksFunction
useCancelLOCWorkflow()
function useCancelLOCWorkflow(): UseCancelLOCWorkflowResult;Validates and prepares a direct LOC cancellation.
Before expiration only the beneficiary, or a holder of the beneficiary’s signed cancellation
authorization, may cancel; after expiration anyone may. Domain validation and construction stay
owned by sdk.loc.
Returns
The canonical preparation envelope. validate reports a verdict without building anything;
prepareWorkflow validates and then builds, resolving to prepared, invalid, failed, or
cancelled; workflow, issues, error, and isPreparing mirror the latest request; and reset
discards it. No wallet is prompted until workflow.execute().
Throws
Error when rendered outside <AnvilProvider>, by way of useAnvilSDK. Nothing else
throws: a rejected validation or build is reported as a failed result, not as an exception.
Example
export function CancelLOCButton({ locId }: { locId: bigint }) { const { prepareWorkflow, issues, isPreparing } = useCancelLOCWorkflow();
async function cancel() { const result = await prepareWorkflow({ id: locId }); // `invalid` is a domain verdict (not the beneficiary, not expired); // `failed` means validation could not complete at all. if (result.status !== 'prepared') return; await result.workflow.execute(); }
return ( <> <button onClick={cancel} disabled={isPreparing}> Cancel LOC </button> {issues.map(issue => ( <p key={issue.field}>{issue.message}</p> ))} </> );}