IntersectMBO / IntersectMBO/evolution-sdk
feat(builder): lazy UTxO resolvers for retry-safe buildEffect
- Dominant language
- TypeScript
- Stars
- 22
- Forks
- 30
- Avg merge
- 5h 29m
- Merged PRs (30d)
- 12
Description
## Problem
`BuildOptions.availableUtxos` and `collectFrom` inputs are static arrays resolved before `buildEffect()` runs. When an action is retried via `Effect.retry`, the same stale UTxO arrays are reused — the provider is never queried again.
## Proposed Solution
Allow `availableUtxos` and `collectFrom.inputs` to also accept a lazy resolver `() => Effect>` evaluated at build time:
```ts
client.newTx()
.collectFrom({ inputs: () => client.Effect.getUtxos(scriptAddress), redeemer })
.buildEffect({ availableUtxos: () => client.Effect.getWalletUtxos() })
.pipe(Effect.flatMap(s => s.Effect.signAndSubmit()))
.pipe(Effect.retry(Schedule.recurs(3)))
```
Each retry calls the resolver fresh, so UTxOs are always up to date with no extra boilerplate required from the user.
## Affected Areas
- `BuildOptions.availableUtxos` — extend type to accept `() => Effect>`
- `resolveAvailableUtxos` in `TransactionBuilder.ts` — yield the Effect at build time when lazy
- `CollectFromParams.inputs` — same lazy extension
- `createCollectFromProgram` in `Collect.ts` — evaluate resolver at program execution time
Non-breaking — static arrays continue to work as-is.
Contributor guide
Assessment
This issue has not been assessed yet.