-
Notifications
You must be signed in to change notification settings - Fork 28
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
support 4bytes or similar db #278
Comments
Just spelunking through some iron-wallet issues. WhatsABI doesn't have calldata decoding yet (hmm should I add it, or is that too out of scope?), but we do have some nice 4byte db loaders: import { whatsabi } from "@shazow/whatsabi";
const signatureLookup = new whatsabi.loaders.OpenChainSignatureLookup();
const signatures = await signatureLookup.loadFunctions("0x06fdde03");
... Also support 4byte.directory and also compound loaders (try each one until a result is found). |
hi there 👋🏼 hmm, I'm not familiar enough to know if it would be out of scope. but (correct if I'm wrong), using your snippet above I should just be able to load the resulting signature into viem to handle calldata decoding? |
Yea! You'd use something like parseAbiItem on the first result (it'll give you all the candidates, but first one is usually most common), that gives you the abi that you can parse the rest of the calldata from. Would be a nice recipe to add to the WhatsABI docs... 🤔 |
Haven't tested it but I imagine it something like this: import { whatsabi } from "@shazow/whatsabi";
import { decodeFunctionData, parseAbi } from "viem";
const calldata = "...";
const selector = calldata.slice(0, 10);
const signatureLookup = new whatsabi.loaders.OpenChainSignatureLookup();
const signatures = await signatureLookup.loadFunctions(selector);
if (signatures.length === 0) { throw "/shrug"; }
const abi = parseAbi([signatures[0]]);
const { functionName, decodedArgs } = decodeFunctionData({
abi,
data: calldata,
}) |
title self explanatory. we want to decode transaction calldata without relying solely on known ABIs
The text was updated successfully, but these errors were encountered: