Skip to content

fix(web): DAO writes target the correct chain + chain-aware SDK snippet#67

Merged
marinom2 merged 1 commit into
mainfrom
fix/dao-write-chain-and-snippet
Jun 10, 2026
Merged

fix(web): DAO writes target the correct chain + chain-aware SDK snippet#67
marinom2 merged 1 commit into
mainfrom
fix/dao-write-chain-and-snippet

Conversation

@marinom2

Copy link
Copy Markdown
Owner

Follow-up fixes to #66, from testing the live panel.

The write bug (primary)

On the Ethereum DAO tab, delegate/vote failed with:

The current chain of the wallet (id: 1) does not match the target chain for the transaction (id: 9200 - LightchainAI)

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() that switchChainAsync to the target chain, then fetches a fresh wallet client bound to it via @wagmi/core getWalletClient({ 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)

  • Treasury 4.56 LCAI is correct - native balance 4559000000000000000 wei = 4.559 LCAI (right units, not billions; the bulk hasn't migrated to that address yet).
  • "Self-delegated" is accurate - delegates(you) returns your own address and getVotes(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 30% - numerator 30 / denominator 100, quorum() ~2.99B LCAI.

Verification

tsc clean, next build clean, ESLint clean, 473/473 tests pass.

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).
@vercel

vercel Bot commented Jun 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lightnode Ready Ready Preview, Comment Jun 10, 2026 11:47am

Request Review

@marinom2 marinom2 merged commit 4c86d0e into main Jun 10, 2026
5 checks passed
@marinom2 marinom2 deleted the fix/dao-write-chain-and-snippet branch June 10, 2026 11:49
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.

1 participant