Skip to content

API ReferenceReact provider and hooksFunction

useCancelLOCAuthorizationWorkflow()

function useCancelLOCAuthorizationWorkflow(): UseCancelLOCAuthorizationWorkflowResult;

Validates and prepares the beneficiary’s signed cancellation authorization — the EIP-712 payload that lets someone other than the beneficiary cancel an unexpired LOC.

The prepared workflow signs; it broadcasts no transaction. Its typed data is readable before the wallet prompt, for consent UI and audit logging.

Returns

UseCancelLOCAuthorizationWorkflowResult

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 AuthorizeCancelButton({ locId }: { locId: bigint }) {
const authorization = useCancelLOCAuthorizationWorkflow();
async function authorize() {
const result = await authorization.prepareWorkflow({ id: locId });
if (result.status !== 'prepared') return;
// Inspectable before the wallet prompt, for consent UI and audit logs.
console.log(result.workflow.operations[0]?.authorization?.typedData);
await result.workflow.execute();
}
return (
<button onClick={authorize} disabled={authorization.isPreparing}>
Authorize cancellation
</button>
);
}