Per-call batch: false for ENS actions (getEnsText, getEnsAddress, …)
#4840
Unanswered
Rinse12
asked this question in
Idea / Feature Request
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Description
Client-level
batch.multicallcan be bypassed per-call incall/readContract: thecallaction readsbatch = Boolean(client.batch?.multicall)from its arguments, so passingbatch: falseon a single call skips the multicall scheduler and sends a standaloneeth_call.However, the ENS actions (
getEnsText,getEnsAddress,getEnsName,getEnsResolver) construct theirreadContractParametersobject explicitly and only forwardblockNumber/blockTag:https://github.com/wevm/viem/blob/main/src/actions/ens/getEnsText.ts
So on a client created with
batch: { multicall: true }there is no way to opt a single ENS lookup out of batching. The only workarounds are keeping a second unbatched client, or re-implementing the universal-resolverreadContractcall manually.Relatedly,
ReadContractParametersdoesn't includebatchin its type —readContractforwards it tocallat runtime via its rest spread, but TypeScript rejects it.Proposal
batch?: booleanto the ENS action parameter types and forward it into the builtreadContractParameters.batch?: booleantoReadContractParameters(the runtime already forwards it; this just types the existing behavior).Use case
We enable
batch.multicall(with awaitwindow) on a sharedPublicClientto coalesce bursts of concurrent ENS text-record lookups into oneaggregate3call. Occasionally a single latency-sensitive lookup should skip thewaitwindow and go out immediately — today that isn't expressible through the ENS actions.Happy to open a PR if this is welcome.
All reactions