Repository navigation
fix(forge): add deposit address format validation - #220
Merged
Merged
Conversation
Problem: - TRON chain requires base58 address format (T...), but API may return EVM format (0x...) causing 'Invalid base58 character: 0' error Solution: - Add validateDepositAddress() to validate address format per chain - Add isValidTronBase58Address(), isTronHexAddress(), isEvmAddress() - Validate deposit address before creating transaction in useForge - Show descriptive error if address format is wrong Tests: - 19 new tests for chain utilities - 2 new tests for TRON address handling in useForge - All 59 tests passing
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.
Problem
When using TRON chain in the Forge miniapp, the "确认锻造" step fails with error:
This happens because:
T, 34 chars)0x...) or hex format (41...)Solution
1. Add address validation utilities (
lib/chain.ts)isValidTronBase58Address()- validate T... formatisTronHexAddress()- detect 41... formatisEvmAddress()- detect 0x... formatvalidateDepositAddress(chain, address)- returns error message if invalid2. Validate before transaction (
useForge.ts)3. Helpful error messages
Invalid TRON address: received EVM format (0x...), expected base58 format (T...)Invalid TRON address: received hex format (41...), expected base58 format (T...)Tests
chain.test.tsuseForge.test.tsRoot Cause Note
The actual fix requires the backend API to return TRON addresses in base58 format. This PR adds client-side validation to catch the error early with a helpful message, rather than failing deep in the transaction signing flow.