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 stops on the first operation that is Indeterminate with no transaction hash. This finds that operation and describes it in the context of the whole run, the same way “@anvilresearchlabs/sdk/components”!CreateLOCFlow and “@anvilresearchlabs/sdk/components”!RedeemLOCFlow do. Spread the result into “@anvilresearchlabs/sdk/components”!UnconfirmedTransaction’s props.

Parameters

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

Returns

UnconfirmedSend | undefined

step, the name of the step whose outcome is unknown, and retryEffect, what sending it again would do (absent when a repeat is harmless). undefined when there is no settlement, when its status is not wallet-indeterminate, or when no operation in it is Indeterminate without a hash.

Example

import {
getUnconfirmedSend,
useAnvilSDK,
useWorkflowLifecycle,
} from '@anvilresearchlabs/sdk/react';
import {
TransactionsView,
UnconfirmedTransaction,
} from '@anvilresearchlabs/sdk/components';
import type {
Address,
WalletOperationWorkflow,
} from '@anvilresearchlabs/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} />;
}