Impact
The type declaration for AbiFunction is as follows:
export type ABIFunction = {
type: "function"; // TODO: constructor, receive, fallback
selector: string;
name?: string;
outputs?: ABIOutput[];
inputs?: ABIInput[];
sig?: string;
sigAlts?: string[];
payable?: boolean;
stateMutability?: StateMutability;
};
Which led me to believe that you'd always get the selector
However, it seems like when whatsabi can determine the "real" abi, it will not return the selector
POC
Address is 0xF576e1f09e2eb4992d5FFDF68bec4Ea489FA417d, basically one for which the tool is able to grab the ABI correctly
async function makeRepro() {
const result = await whatsabi.autoload(address, { provider });
console.log("result.abi", result.abi)
const fns: ABIFunction[] = result.abi.filter(abi => abi.type === "function") as undefined as ABIFunction[]
console.log("result.abi", fns[0].selector)
}
makeRepro()
Logs
/// omitted
},
{
inputs: [ [Object], [Object] ],
name: 'totalUltiAllocated',
outputs: [ [Object] ],
stateMutability: 'view',
type: 'function'
},
... 8 more items
]
result.abi undefined
Mitigation
I believe the tool should always return the selector or the declaration should be changed to have a conditional value
Impact
The type declaration for
AbiFunctionis as follows:Which led me to believe that you'd always get the selector
However, it seems like when whatsabi can determine the "real" abi, it will not return the selector
POC
Address is
0xF576e1f09e2eb4992d5FFDF68bec4Ea489FA417d, basically one for which the tool is able to grab the ABI correctlyLogs
Mitigation
I believe the tool should always return the selector or the declaration should be changed to have a conditional value