-
Notifications
You must be signed in to change notification settings - Fork 26
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
3b0b396
to
6748e5c
Compare
…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.
…tely retrieve the destination contract ABI.
…nment variable is not set.
…or supported chains.
…input-details supporting destination contract link
c9e00f6
to
4e1c148
Compare
ref.current.blur(); | ||
} | ||
}, [value]); | ||
useEffect(() => { |
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.
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.
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.
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.
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:
JSON-ABI
spec type.VoucherExecution
component.CartesiDapp#wasExecuted
method; Now, thechainId
prop is set instead of relying on underneath logic. That avoids unnecessary error notifications when switching between CartesiScan networks and the wallet is disconnected.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).PageableContent
it 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)