Conversation
Adds a batch fetch function that retrieves holdings for multiple tokens in parallel, reusing the existing fetchHolding primitive. This enables consumers to refresh user holdings at the point of use (e.g. before encoding transactions) without depending on React Query cache freshness. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c11dfe4312
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Avoids N redundant getChainId RPC calls when fetching holdings for N tokens in parallel. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@codex review |
No need for a separate file — fetchHoldings is a thin wrapper over fetchHolding and belongs in the same module. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Codex Review: Didn't find any major issues. Chef's kiss. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Closing — fetchHoldings is trivial consumer-side code, no need to add it to the SDK. The real fix for stale nonces belongs in consumer-sdk's encodeErc20Permit. |
Summary
fetchHoldings(user, tokens, client, parameters?)to@morpho-org/blue-sdk-viem— a batch function that fetches holdings for multiple tokens in parallel, reusing the existingfetchHoldingprimitive.Why
Today in consumer apps, holdings are fetched at render time (via React Query) but consumed later at click time (for encoding/signing). Nothing guarantees data freshness at the moment of usage.
This is particularly problematic for ERC-2612 permit nonces:
erc2612Nonceis captured whengetRequirements()runs, but the user may click "Continue" minutes later. By then, the nonce can be stale (e.g. if the user signed another permit in another tab), causing the transaction to revert.fetchHoldingsgives consumers a simple way to re-fetch holdings right before encoding, without any React dependency:This decouples data freshness from React Query cache timing and fixes the stale-nonce class of bugs at the architectural level.
Test plan
pnpm --filter @morpho-org/blue-sdk-viem buildpasses (type-check + build)fetchHoldingsbefore encoding to get fresherc2612Nonce🤖 Generated with Claude Code