Skip to content

API ReferenceReact provider and hooksFunction

getWorkflowSettlementMessage()

function getWorkflowSettlementMessage(settlement?): string | undefined;

Beta

Returns the one line of user-facing copy a settlement warrants, or undefined when it warrants none.

A succeeded settlement has nothing to say, and so does an absent one — the shape that lets a caller pass a settlement straight through without first testing whether the run settled at all.

Parameters

ParameterTypeDescription
settlement?WorkflowSettlementHow the run ended, straight from useWorkflowLifecycle. undefined is accepted and yields undefined.

Returns

string | undefined

One line of user-facing copy, or undefined when the settlement warrants none. A preflight-invalid settlement joins its issue messages; wallet-indeterminate always returns the unknown-outcome line; the remaining failing statuses fall back to generic copy when they carry no message of their own.

Example

export function SettlementBanner({
workflow,
}: {
workflow: WalletOperationWorkflow;
}) {
const { settlement } = useWorkflowLifecycle(workflow);
// `undefined` for a run that succeeded and for one that has not
// settled -- pass the settlement straight through either way.
const message = getWorkflowSettlementMessage(settlement);
return message === undefined ? null : <p role="alert">{message}</p>;
}