Skip to content
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: Voucher payload auto decoding #246

Merged
merged 8 commits into from
Oct 21, 2024
Merged

Conversation

brunomenezes
Copy link
Collaborator

Summary

Code changes to support auto-decoding the voucher payload. As the voucher contains information on the destination (contract address) and the payload (4-byte selector + arguments), we request the destination's ABI and try to decode it using our Specification on the fly. In any failures while hopping into the network or during the decoding attempt, it will gracefully continue to work by just returning and rendering the original raw payload (i.e. Hex). Other changes and refactorings were done along the way.

Changes summary:

  • apps/web
    • Added a new hook to handle voucher payload automatically where possible.
    • Refactored the function to get the configured chain ID to be self-contained.
    • Improved meta for decoded payloads with JSON-ABI spec type.
    • Improve error handling in the VoucherExecution component.
      • The call to the CartesiDapp#wasExecuted method; Now, the chainId prop is set instead of relying on underneath logic. That avoids unnecessary error notifications when switching between CartesiScan networks and the wallet is disconnected.
      • It will only start the simulated call once the contract call to check whether a voucher was executed has a response and the voucher has its proof.
      • Changed the text's precedence for the execution button.
  • packages/ui
    • Refactored the InputDetails -> Content component to fix an internal react error. It loses access to an expected static flag, which causes odd behaviours: it re-renders the previous state of the component (as a perceived fallback).
    • Modified how to identify what type of PageableContentit is by passing a param value rather than relying on static function property (PageableContent is shared by the output types, i.e. Notices / Reports / Vouchers)

@brunomenezes brunomenezes linked an issue Sep 20, 2024 that may be closed by this pull request
7 tasks
Copy link

vercel bot commented Sep 20, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
rollups-explorer-base-mainnet ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 23, 2024 4:29pm
rollups-explorer-base-sepolia ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 23, 2024 4:29pm
rollups-explorer-mainnet ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 23, 2024 4:29pm
rollups-explorer-optimism-mainnet ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 23, 2024 4:29pm
rollups-explorer-optimism-sepolia ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 23, 2024 4:29pm
rollups-explorer-sepolia ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 23, 2024 4:29pm
rollups-explorer-workshop ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 23, 2024 4:29pm

@brunomenezes brunomenezes force-pushed the 156-voucher-content-decoding branch from 3b0b396 to 6748e5c Compare September 20, 2024 12:52
…d of PageableContent it is rather than trust on static function property.
…en switching between RAW and As-JSON

Mantine JsonInput throw an silent internal error when switching between raw and as-json mode causing the rendered component to be in its previous state, ignoring the new data passed down.
…input-details supporting destination contract link
ref.current.blur();
}
}, [value]);
useEffect(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This effect will be invoked on each render, if this is desired, we can remove the effect altogether and just run the code at the top-level of that component. Otherwise, we should include an empty array for its dependencies.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My first option is always not to use a useEffect. The goal is to have a <JsonInput> content formatted, and it does not work when the blur is triggered in the top level. Thus, a "microtask" must run after the content is visible and in-focus.

@brunomenezes brunomenezes merged commit 175df83 into main Oct 21, 2024
21 checks passed
@brunomenezes brunomenezes deleted the 156-voucher-content-decoding branch October 21, 2024 03:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Voucher content decoding
2 participants