Skip to content

Conversation

@LeoSlrRf
Copy link
Contributor

@LeoSlrRf LeoSlrRf commented Nov 18, 2025

Description of the changes

Follow up on #1658

On sui, erc20 addresses commonly have the following format:
0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC

Update the validation method so it's taken into account when validating an SUI address

Summary by CodeRabbit

  • Bug Fixes
    • Improved address validation to properly handle namespaced addresses. Addresses containing "::" are now validated correctly by checking the portion before the delimiter.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 18, 2025

Walkthrough

Extended validateSuiAddress to handle namespaced addresses by extracting and validating only the portion before "::" delimiter, while maintaining original full validation for non-namespaced addresses.

Changes

Cohort / File(s) Change Summary
Namespaced Sui address validation
packages/currency/src/currencyManager.ts
Enhanced validateSuiAddress to handle namespaced addresses: validates the substring before "::" if present, otherwise validates the full address. Error handling preserved.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Verify the namespaced address parsing logic correctly handles edge cases (empty strings before/after "::", multiple "::" occurrences)
  • Confirm backward compatibility with existing non-namespaced address validation

Possibly related PRs

Suggested reviewers

  • MantisClone
  • alexandre-abrioux-rf
  • dave-rf

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: updating SUI address validation to handle ERC20 address formats with namespaced addresses.
Description check ✅ Passed The description includes the required section and provides clear context about the change, including a reference to the related PR and specific examples of the address format being validated.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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/sui-erc20-address-validation

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 734baa2 and 36e95b7.

📒 Files selected for processing (1)
  • packages/currency/src/currencyManager.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: PaulvanMotman
Repo: RequestNetwork/requestNetwork PR: 1642
File: packages/currency/src/currencyManager.ts:270-276
Timestamp: 2025-08-11T13:41:19.609Z
Learning: In the RequestNetwork codebase, address validation functions should validate addresses exactly as provided without preprocessing (e.g., no trimming of whitespace). The raw address input should be validated directly to ensure strict validation and place responsibility on the caller to provide properly formatted addresses.
📚 Learning: 2024-11-20T18:59:38.738Z
Learnt from: rodrigopavezi
Repo: RequestNetwork/requestNetwork PR: 1475
File: packages/request-client.js/src/http-data-access.ts:214-216
Timestamp: 2024-11-20T18:59:38.738Z
Learning: When validating Ethereum addresses in TypeScript code, prefer using `ethers.utils.isAddress` function from the `ethers` library instead of regex patterns.

Applied to files:

  • packages/currency/src/currencyManager.ts
📚 Learning: 2024-11-20T18:59:39.982Z
Learnt from: rodrigopavezi
Repo: RequestNetwork/requestNetwork PR: 1475
File: packages/request-client.js/src/http-data-access.ts:214-216
Timestamp: 2024-11-20T18:59:39.982Z
Learning: For validating Ethereum addresses, use `ethers.utils.isAddress` instead of custom regex patterns.

Applied to files:

  • packages/currency/src/currencyManager.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build-and-test
🔇 Additional comments (1)
packages/currency/src/currencyManager.ts (1)

363-365: Code is correct—no changes needed.

Sui/Move represents token types as fully-qualified type names in the form packageId::module::Type, and when validating the account/address portion, you should extract the leading address before the first "::" and validate that as a Sui address. Your implementation correctly extracts and validates the base address using isValidSuiAddress. The @mysten/sui package version 1.45.0 is current.

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@LeoSlrRf LeoSlrRf merged commit ab86156 into master Nov 20, 2025
15 checks passed
@LeoSlrRf LeoSlrRf deleted the fix/sui-erc20-address-validation branch November 20, 2025 11:33
@MantisClone
Copy link
Member

Looks good 👍 Sorry I missed this.

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.

5 participants