-
-
Notifications
You must be signed in to change notification settings - Fork 838
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: eth_call
multicall aggregation
#387
Conversation
🦋 Changeset detectedLatest commit: b6a80fb The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
0caaf53
to
3010d16
Compare
|
||
const schedulerCache = new Map<number | string, SchedulerItem[]>() | ||
|
||
export function createBatchScheduler< |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/codex what does this function do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does this function do?
@jxom This code snippet defines a TypeScript module that exports a function called createBatchScheduler
. This function returns a batch scheduler that allows you to group multiple function calls and execute them together in a batch. The batch scheduler is useful when you have multiple function calls that can be combined into one call to improve performance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you so smart
Size Change: +4.37 kB (+2%) Total Size: 251 kB
ℹ️ View Unchanged
|
eth_call
multicall aggregationeth_call
multicall aggregation
Codecov Report
@@ Coverage Diff @@
## main #387 +/- ##
========================================
Coverage 99.89% 99.90%
========================================
Files 265 267 +2
Lines 21811 22060 +249
Branches 1849 1891 +42
========================================
+ Hits 21789 22038 +249
+ Misses 20 19 -1
- Partials 2 3 +1
... and 2 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
wait, | ||
shouldSplitBatch(args) { | ||
const size = args.reduce((size, { data }) => size + (data.length - 2), 0) | ||
return size > batchSize * 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is batchSize
multiplied by 2
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Converting to hex size!
@@ -115,6 +115,7 @@ export async function simulateContract< | |||
} as unknown as EncodeFunctionDataParameters<TAbi, TFunctionName>) | |||
try { | |||
const { data } = await call(client, { | |||
batch: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh no, it’s not okay. Good catch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be better to Pick<CallParameters, ...>
versus Omit<CallParameters, ...>
src/utils/promise/index.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some pretty nice utils we have here :)
Adds support for
eth_call
batch aggregation via multicallaggregate3
.PR-Codex overview
This PR introduces support for batch aggregation via multicall
aggregate3
, adds a new error type, and makes several updates and fixes across multiple files.Detailed summary
eth_call
batch aggregation via multicallaggregate3
ClientChainNotConfiguredError
error typecontract.ts
exportspromise
andpromise.test.ts
fileseip1193.ts
.env.example
index.ts
andindex.test.ts
getEnsName.test.ts
,getEnsText.test.ts
,getEnsAddress.test.ts
,getEnsResolver.test.ts
,readContract.test.ts
,estimateContractGas.test.ts
,simulateContract.ts
, andsimulateContract.test.ts
utils.ts
chain.ts
andchain.test.ts
getContract.test.ts
getContractError.ts
createPublicClient.test.ts
andcreatePublicClient.ts
PR-Codex overview
This PR introduces support for
eth_call
batch aggregation via multicallaggregate3
. It also adds a newbatch
parameter toCallParameters
to enable and configure the multicall feature.Detailed summary
eth_call
batch aggregation via multicallaggregate3
.batch
parameter toCallParameters
to enable and configure the multicall feature.batchSize
andwait
to thebatch.multicall
object.scheduleMulticall
function to handle multicall requests.shouldPerformMulticall
to only perform a scheduled multicall if the request has calldata, has a target address, is not the aggregate3 signature, and has no other properties.call
to useshouldPerformMulticall
andscheduleMulticall
when appropriate.createPublicClient
test to include the new batch parameter.