API ReferenceTransactions, wallets, and signaturesInterface
WalletOperationWorkflow
A workflow of multiple ordered WalletOperations to execute in order to accomplish some logical function. For instance, depositing into the CollateralVault may entail
- ERC20.approve(…)
- CollateralVault.depositToAccount(…)
Remarks
A workflow is pinned to the logical account present while it is prepared. If the connected account
changes before or between wallet operations, the next operation fails with WalletNotConnected and
the workflow must be rebuilt. This keeps balance, allowance, signature, and transaction planning
tied to one signer.
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, depositconsole.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));Properties
execute
execute: WorkflowExecuteFunction;Revalidates the preserved intent, then runs the operations in order through the connected wallet when valid, reporting progress to the optional handler. See WorkflowExecuteFunction for concurrency and cancellation semantics.
operations
operations: WalletOperation < AnvilWalletOperationType > [];The ordered list of operations to be executed.