-
-
Notifications
You must be signed in to change notification settings - Fork 268
feat: create utility func #7677
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
base: main
Are you sure you want to change the base?
Conversation
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
Caution MetaMask internal reviewing guidelines:
Ignoring alerts on:
|
|
@SocketSecurity ignore npm/@scure/[email protected] This is a well-trusted cryptographic library by @paulmillr for BIP39 mnemonic generation. The network access alert refers to an optional fetch for wordlist loading, which is not used in our implementation - we only use viem for ABI encoding/decoding via |
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.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
packages/assets-controller/src/data-sources/rpc-datasource/clients/MulticallClient.ts
Show resolved
Hide resolved
packages/assets-controller/src/data-sources/rpc-datasource/utils/batch.ts
Show resolved
Hide resolved
ef60fe4 to
fe79249
Compare
|
@salimtb scure bip39 does not use any fetch inside, what’s going on here? |
Explanation
This PR introduces foundational infrastructure for a new RPC-based data source in the
assets-controllerpackage. The current architecture relies on centralized APIs for fetching token balances, which can be a bottleneck and single point of failure. This change adds the ability to fetch data directly from the blockchain via RPC calls.Key additions:
MulticallClient- A client that batches multiple ERC-20balanceOfcalls into a single RPC request using the Multicall3 contract. This significantly reduces the number of RPC calls needed when checking balances for many tokens. The client:Batch utilities - Generic helper functions (
divideIntoBatches,reduceInBatchesSerially) for processing large arrays in smaller chunks, useful for rate-limiting and memory management.Type definitions - Core types (
Address,ChainId,Provider, etc.) that establish the foundation for the RPC datasource layer.References
Checklist
Note
Establishes RPC-based balance fetching with efficient batching and strong test coverage.
MulticallClientusing Multicall3aggregate3andgetEthBalanceto batch ERC‑20/nativebalanceOfcalls; configurablemaxCallsPerBatch, chain address map, and automatic fallback to individual RPC callsviem(encodeFunctionData,decodeFunctionResult) and export helpersencodeAggregate3/decodeAggregate3ResponsedivideIntoBatches,reduceInBatchesSeriallyAddress,ChainId,Provider, etc.) and index exportsMulticallClient, ABI helpers, and batch utilsviem; update changelogWritten by Cursor Bugbot for commit fe79249. This will update automatically on new commits. Configure here.