You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR fixes address-format handling issues in the bridge flow for Initia/EVM chain pairs.
Users could trigger a transient state where the bridge queried balances with a mismatched address format during source/destination chain transitions:
querying an EVM chain with an Initia bech32 address, or
querying an Initia chain with a hex address.
That first request failed, then a second request succeeded after form state settled.
Root Cause
Bridge form updates were not fully atomic across chain and address fields. During chain switching, query hooks could execute with new chain IDs but stale sender/recipient values from the previous chain context.
In addition, route query keys included full form values, which introduced unnecessary refetches from fields unrelated to route computation.
Changes
Strict Initia address validation
Enforce bech32+prefix validation for Initia chains.
Keep explicit EVM hex validation and prefix-based Cosmos validation.
No actionable comments were generated in the recent review. 🎉
Walkthrough
Introduces a bech32-prefix address helper and tightens address checks; adds address validation gating to balance queries and a helper to fetch a single denom; consolidates simulated-route params into a single object; and narrows skip query key typing to a RouteParams subset.
Adds address validation to useSkipBalancesQuery (disables query/select when invalid) and exports useSkipBalance(address, chainId, denom) to read a single denom.
Introduces internal RouteParams type and updates skipQueryKeys.route signature to accept RouteParams (runtime behavior unchanged).
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~25 minutes
Poem
🐰 I hopped through code with careful paws,
Counting bech32 bits and checking clause,
I bundled params in one neat sack,
Pulled balances only when valid—no flack,
A tiny hop, a tidy bridge, applause! 🎉
🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (2 warnings)
Check name
Status
Explanation
Resolution
Title check
⚠️ Warning
The PR title references preventing invalid balance queries on chain switch, but the main focus is enforcing strict bech32 validation for Initia addresses and consolidating validation logic.
Update the title to reflect the primary change: e.g., 'fix(bridge): enforce strict initia bech32 validation and consolidate address checks'.
Docstring Coverage
⚠️ Warning
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.
Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name
Status
Explanation
Description Check
✅ Passed
Check skipped - CodeRabbit’s high-level summary is enabled.
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing Touches
📝 Generate docstrings
🧪 Generate unit tests (beta)
Create PR with unit tests
Post copyable unit tests in a comment
Commit unit tests in branch fix/bridge-initia-bech32-validation
Warning
Tools execution failed with the following error:
Failed to run tools: 13 INTERNAL: Received RST_STREAM with code 2 (Internal server error)
Comment @coderabbitai help to get the list of available commands and usage tips.
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
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.
Summary
This PR fixes address-format handling issues in the bridge flow for Initia/EVM chain pairs.
Users could trigger a transient state where the bridge queried balances with a mismatched address format during source/destination chain transitions:
That first request failed, then a second request succeeded after form state settled.
Root Cause
Bridge form updates were not fully atomic across chain and address fields. During chain switching, query hooks could execute with new chain IDs but stale sender/recipient values from the previous chain context.
In addition, route query keys included full form values, which introduced unnecessary refetches from fields unrelated to route computation.
Changes
Strict Initia address validation
packages/interwovenkit-react/src/pages/bridge/data/address.tsPrevent invalid balance requests during chain/address transitions
enablednow requires a valid address for the selected chain)./balancescall.packages/interwovenkit-react/src/pages/bridge/data/balance.tsTighten route query key inputs
srcChainId,srcDenom,dstChainId,dstDenom,quantity.queryFnwith the samerouteParamsobject used byqueryKeyfor clarity and exhaustive-deps correctness.packages/interwovenkit-react/src/pages/bridge/data/skip.tspackages/interwovenkit-react/src/pages/bridge/data/simulate.tsUser Impact
Validation
pnpm --filter @initia/interwovenkit-react exec eslint src/pages/bridge/data/address.ts src/pages/bridge/data/balance.ts src/pages/bridge/data/skip.ts src/pages/bridge/data/simulate.tspnpm --filter @initia/interwovenkit-react typecheckpnpm --filter @initia/interwovenkit-react testSummary by CodeRabbit
New Features
Bug Fixes