cartesi / rollups-explorer

Cartesi Rollups Explorer Web Application
https://cartesiscan.io
Apache License 2.0
7 stars 26 forks source link

Voucher content decoding #156

Open brunomenezes opened 5 months ago

brunomenezes commented 5 months ago

πŸ“„ Context

Given that a voucher has a destination (Address) and the payload (Encoded arguments), we can recover the ABI of this destination address and use it to try to parse the encoded payload (i.e. the input for the destination) for this type of output.

Ref Rollups Contracts: CartesiDApp#executeVoucher

βœ”οΈ Solution

We can leverage two tools here. We could experiment with WhatsAbi to retrieve the ABI from an Address (Check the documentation for more details on usage), and then use Viem to decode the payload and display it in the Input-details box.

PS: The first option is more sensible in the decoding success section above. Given the number of unrelated changes and checks required by the second option. It can be a separate refactor issue if necessary.

πŸ“ˆ Subtasks

🎯 Definition of Done

brunomenezes commented 5 months ago

Hey @tuler, am I missing anything from our conversation? For that first version, I don't think we need to include the Loaders for Sourcify and/or EtherScan, maybe later? but we need to check how WhatsAbi would work when the Provider added in the setup is fetching data on a dev-net setup.

tuler commented 5 months ago

AFAIK WhatsABI can fetch from etherscan and sourceify automatically. For devnet it won't work. That's ok.

One possible enhancement, that can be left for another issue, is to allow the user to input the ABI in a Textarea manually, and let the decoding works. That could be used in the devnet scenario.

brunomenezes commented 5 months ago

AFAIK WhatsABI can fetch from etherscan and sourceify automatically. For devnet it won't work. That's ok.

One possible enhancement, that can be left for another issue, is to allow the user to input the ABI in a Textarea manually, and let the decoding works. That could be used in the devnet scenario.

When using the autoload() it will use both even though the EtherScan loader needs an API key, so it will actually rely only on sourcify in that case. I don't see it as a problem for now, but I think defining them for EtherScan sake is better so the baseUrl can also be changed based on chain-id Etherscan endpoints

lines: L268 and then L65