-
Notifications
You must be signed in to change notification settings - Fork 15
feat(frontend): badge registry V1/V2 retrocompat #158
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(frontend): badge registry V1/V2 retrocompat #158
Conversation
joelamouche
left a comment
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.
Would be nice to annotate the code saying this retrocompatibility logic should be removed after redeployment, with link to the PR to facilitate future work.
I tested locally and badges were not loading. Did you try it locally with old version?
PUBLIC_BADGE_REGISTRY_ADDRESS=0x94f5F12BE60a338D263882a1A49E81ca8A0c30F4
| import { useReadContract } from "wagmi"; | ||
| import { badgeRegistryAbiV2 } from "@/lib/abis/badgeRegistryAbi"; | ||
|
|
||
| export function useBadgeRegistryVersion(address?: `0x${string}`): { |
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.
Maybe specify that this logic can be removed after redeployment
|
Okay, let's do some checkpoint... Why approach evolvedMy initial idea (described in the issue) relied on a dedicated While conceptually sound, testing this against real registries surfaced two practical issues:
The final solution favors determinism, minimal RPC usage, and real on-chain signals over architectural purity. Final architecture (implemented in my last commit)
No probe, no multicall, no version assumption Otherwise:
This avoids heuristics, avoids address assumptions, and relies purely on observable contract behavior.
No silent fallback on non-decode errors
This ensures predictable behavior even under frequent navigation. In long-term :
The previously introduced useBadgeRegistryVersion hook is no longer needed with this approach and has been removed. I think this approach is closer to our usage and should behave robustly in practice. Let me know what you're thinking about. |
|
Added inline TODOs to clearly mark the temporary V1/V2 BadgeRegistry retro-compat code paths. |
joelamouche
left a comment
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.
Did you test it with v1 deployment? I can't seem to make it work with a v1 contract (try 0xc142ab6b4688b7b81cb4cc8b305f517bba3bfd25)
I tested against the v1 deployment as well. I ran locally with:
In both cases the UI loads fine on my side. If it still fails for you, could you please share the exact page/action that fails and any console error or failing network call? |
|
Not yet 🙂 I’m going to test the create flow against the v1 deployment and dig into it. I’ll get back with findings shortly. |
897ebdf to
3e2ef03
Compare
|
Updating after further testing. I’ve now tested the full createBadge flow against both existing Amoy V1 deployments: 0xc142ab6b4688b7b81cb4cc8b305f517bba3bfd25 (older V1) In both cases, on my side: /badges loads correctly The current implementation detects the ABI on-demand, based on observable on-chain behavior, and routes the write with the correct signature before sending the transaction. The frontend should therefore remain fully retro-compatible with V1 while being ready for the upcoming V2 redeploy. Unless you’d like a different behavior or structure, I think this is ready to merge. Edit (1 hour later ): I’m now intermittently hitting an Internal JSON-RPC error again while re-running the same flow. Separately, once this is fully settled, I’ll do a small follow-up cleanup pass on the previous commit (pure refactor / readability only, no behavior changes). |
|
I pushed a small refactor (helpers extraction only). No behavior change intended. Optional UX follow-up : we could treat Internal JSON-RPC error / transient provider failures as a retryable class and surface a clearer message to users (eg. "RPC/provider hiccup. Please retry in a few seconds or switch RPC") possibly with a simple Retry action. |
There already was an error message. What do you see now? |
joelamouche
left a comment
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.
Tested v1 compat and it works 🥳
Great work on this one 🚀
Regarding error messaging, we previously had a ctach error message with retry message for the frequent case where json rpc errors (amoy behavior). If yyou see it not working anymore please create a ticket with screenshots

Summary
This PR adds frontend retrocompatibility between the legacy badge registry (bytes32 descriptions) and the new version using bytes descriptions.
What’s included
totalBadges → version probe → multicall(no separate version hook)Notes
Related to #157