Skip to content

API ReferenceTransactions, wallets, and signaturesFunction

isIndeterminateWithoutHash()

function isIndeterminateWithoutHash(operation): boolean;

Returns whether an operation is Indeterminate without a recorded transactionHash: its send failed in transit, so there is nothing to observe and re-running execute() leaves it unchanged.

An Indeterminate operation that carries a hash is the other case: its confirmation timed out, and re-running execute() re-checks the hash.

Parameters

ParameterTypeDescription
operationWalletOperation<AnvilWalletOperationType>The operation from an executed workflow’s snapshot.

Returns

boolean

True when the send failed in transit and the transaction may or may not have landed; check wallet activity before building a new workflow.

Example

// Builders read chain state and prepend any ERC-20 approve the vault
// needs.
const workflow = await sdk.vault.buildDepositWorkflow({
tokenAmounts: [{ tokenAddress: USDC, amount: 1_000_000_000n }], // 1,000
});
// e.g. approve, deposit
console.log(workflow.operations.map(op => op.type));
let cancelled = false;
const execution = await workflow.execute(
update => {
for (const op of update)
console.log(op.type, op.status, op.transactionHash);
},
() => cancelled // checked between steps; flip to stop before next prompt
);
if (execution.status !== 'executed') {
if (execution.status === 'invalid') {
throw new Error(JSON.stringify(execution.issues));
}
if (execution.status === 'failed') throw execution.error;
return false;
}
const finalOps = execution.operations;
const failed = finalOps.find(
op => op.status === WalletOperationStatus.Failed
);
if (failed) {
throw new Error(JSON.stringify(failed.validationErrorResponse));
}
const parked = finalOps.find(isIndeterminateWithoutHash);
if (parked) {
// The send failed in transit: it may or may not have landed, and
// execute() will not resend it. Check wallet activity before rebuilding.
throw new Error(`${parked.type} may have been sent`);
}
return finalOps.every(op => isTerminalOperationStatus(op.status));