API ReferenceReact provider and hooksFunction
useExtendLOCWorkflow()
function useExtendLOCWorkflow(): UseExtendLOCWorkflowResult;Headless extend-LOC orchestration using the canonical workflow-hook envelope. 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 LOCManagementButtons({ loc,}: { loc: OutstandingLetterOfCredit;}) { const modify = useModifyLOCCollateralWorkflow(); const extend = useExtendLOCWorkflow();
async function addCollateral() { const result = await modify.prepareWorkflow({ locId: loc.reference.id, byAmount: 1_000_000n, }); if (result.status === 'prepared') await result.workflow.execute(); }
async function extendByOneDay() { const tomorrow = loc.expirationTimestamp + 24n * 60n * 60n; const result = await extend.prepareWorkflow({ locID: loc.reference.id, newExpirationTimestampSeconds: tomorrow, }); if (result.status === 'prepared') await result.workflow.execute(); }
return ( <> <button onClick={addCollateral} disabled={modify.isPreparing}> Add collateral </button> <button onClick={extendByOneDay} disabled={extend.isPreparing}> Extend one day </button> {(modify.error ?? extend.error) && ( <p>{(modify.error ?? extend.error)?.message}</p> )} </> );}