Skip to content

API ReferenceReact provider and hooksFunction

getUnconfirmedSend()

function getUnconfirmedSend(settlement): UnconfirmedSend | undefined;

Beta

What to tell the user about a settlement whose send outcome is unknown, or undefined when the settlement is not one.

A wallet-indeterminate settlement is parked on the first operation that is Indeterminate with no transaction hash. This finds that operation and describes it against the whole run, so every host shows the screen for the same settlements the LOC flow components do. Spread the result into the unconfirmed-send screen’s props.

Parameters

ParameterTypeDescription
settlement| WorkflowSettlement | undefinedThe settlement a run reported, if it has reported one.

Returns

UnconfirmedSend | undefined

The parked step’s name and retry effect. undefined when there is no settlement, when its status is not wallet-indeterminate, or when no operation in it is parked without a hash.

Example

import {
getUnconfirmedSend,
TransactionsView,
UnconfirmedTransaction,
useAnvilSDK,
useWorkflowLifecycle,
} from '@anvil/sdk';
import type { Address, WalletOperationWorkflow } from '@anvil/sdk/core';
export function SigningStep({
workflow,
sender,
onBackToForm,
onLeave,
}: {
workflow: WalletOperationWorkflow;
// Read when the run starts. The user can switch accounts while the
// screen is up, and the link has to keep pointing at the sender.
sender: Address;
onBackToForm: () => void;
onLeave: () => void;
}) {
const sdk = useAnvilSDK();
const { operations, settlement } = useWorkflowLifecycle(workflow);
// The send failed in transit: it may be on chain. Replace the signing
// view rather than returning to a form with a live submit button.
const unconfirmedSend = getUnconfirmedSend(settlement);
if (unconfirmedSend) {
// Undefined when viem knows no explorer for the chain: no link then.
const explorer = sdk.deps.publicClient.chain?.blockExplorers?.default;
return (
<UnconfirmedTransaction
{...unconfirmedSend}
explorer={explorer && { name: explorer.name, url: explorer.url }}
address={sender}
// Fires only once the user says the first send did not land.
onRetry={onBackToForm}
// For a user who found that it did land. Say where this goes.
onClose={onLeave}
closeLabel="Back to your LOCs"
/>
);
}
return <TransactionsView operations={operations} />;
}