fix(web): DAO writes target the correct chain + chain-aware SDK snippet#67
Merged
Conversation
On the Ethereum DAO tab, delegate/vote failed with "wallet chain (id: 1) does not match target chain (id: 9200)": the app's network toggle drives wagmi's tracked chain (LightChain 9200) independently of the wallet's real chain, so the reactive useWalletClient() stayed bound to 9200 while the wallet was on Ethereum. Replace it with an imperative getSigner() that switches to the target chain and fetches a fresh wallet client bound to it (@wagmi/core getWalletClient), so the write always targets the right chain. - Voting-power card: drop the misleading "you hold 0 X but 0 power, delegate to activate" prompt when the balance is genuinely 0; show a neutral "you hold no X on this chain" line and hide the delegate button. - SDK snippet is now chain-aware (correct RPC + token note per chain) and shows the full surface we added: proposal, quorum, getVotes, hasVoted, getDelegate, delegate, castVote. Verified against the live contracts (no code change needed): the LightChain treasury really holds 4.56 LCAI native (correct units, not billions - mid migration), and "self-delegated" is accurate (delegates(you) == you and getVotes == your native balance; the native predeploy self-delegates).
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up fixes to #66, from testing the live panel.
The write bug (primary)
On the Ethereum DAO tab, delegate/vote failed with:
Root cause: the app's network toggle ("Mainnet" = LightChain 9200) drives wagmi's tracked chain independently of the wallet's real chain. The reactive
useWalletClient()stayed bound to 9200 while MetaMask was actually on Ethereum (1), so viem rejected the write. Switching via the stale hook client didn't realign it.Fix: an imperative
getSigner()thatswitchChainAsyncto the target chain, then fetches a fresh wallet client bound to it via@wagmi/coregetWalletClient({ chainId })- so the write always targets the chain the wallet is on. Applied to both delegate and cast-vote.Copy fix
The voting-power card showed "you hold 0 LCAIB but 0 voting power, delegate to activate" with a Delegate button even when the balance was genuinely 0 (nothing to delegate). Now shows a neutral "you hold no X on this chain" line and hides the button.
Chain-aware SDK snippet
"The SDK behind it" was a single Ethereum-only block that didn't reflect the features we added. It's now generated per selected chain (correct RPC + token note) and shows the full surface:
proposal,quorum,getVotes,hasVoted,getDelegate,delegate,castVote.Verified against live contracts (no code change needed)
4559000000000000000wei = 4.559 LCAI (right units, not billions; the bulk hasn't migrated to that address yet).delegates(you)returns your own address andgetVotes(you)== your native balance (2097.10 LCAI), so your stake is fully self-delegated and active. LightChain's native predeploy self-delegates by default (no delegate tx needed), unlike Ethereum's ERC20Votes.quorum()~2.99B LCAI.Verification
tscclean,next buildclean, ESLint clean, 473/473 tests pass.