Skip to content

Conversation

@LeoSlrRf
Copy link
Contributor

@LeoSlrRf LeoSlrRf commented Nov 13, 2025

Description

Validate Sui address format

Summary by CodeRabbit

  • New Features
    • Added Sui support: currency types and chain registry now recognize Sui, and address validation now validates Sui addresses as part of the standard flow.
  • Chores
    • Added a runtime dependency required for Sui blockchain integration to enable the new validation and chain support.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 13, 2025

Walkthrough

Adds Sui network support: adds runtime dependency @mysten/sui, includes 'sui' in declarative chain names, registers a sui declarative chain entry, and adds Sui address validation plus validateSuiAddress used when currency.network === 'sui'.

Changes

Cohort / File(s) Change Summary
Dependency
packages/currency/package.json
Added runtime dependency @mysten/sui with version ^1.45.0.
Types
packages/types/src/currency-types.ts
Extended DeclarativeChainName union to include 'sui'.
Declarative chains
packages/currency/src/chains/declarative/*
packages/currency/src/chains/declarative/data/sui.ts, packages/currency/src/chains/declarative/index.ts
Added chainId = 'sui' file and registered sui in the exported chains map.
Address validation / Logic
packages/currency/src/currencyManager.ts
Imported isValidSuiAddress from @mysten/sui/utils; added branch for currency.network === 'sui'; introduced validateSuiAddress(address: string): boolean that wraps isValidSuiAddress in try/catch and returns false on errors.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant CurrencyManager
  participant SuiUtils as "@mysten/sui/utils"

  Client->>CurrencyManager: validateAddress(address, currency)
  alt currency.network == "sui"
    CurrencyManager->>SuiUtils: isValidSuiAddress(address)
    note right of SuiUtils `#DFF2E1`: may return boolean or throw
    SuiUtils-->>CurrencyManager: true / false (or error)
    CurrencyManager-->>Client: boolean (false on error)
  else other networks
    CurrencyManager-->>Client: existing validation flow
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Check dependency addition and version in packages/currency/package.json.
  • Validate TypeScript union change in packages/types/src/currency-types.ts for downstream impacts.
  • Inspect new validateSuiAddress error handling and import usage in packages/currency/src/currencyManager.ts.
  • Verify declarative chain file and registration follow existing conventions.

Possibly related PRs

Suggested reviewers

  • leoslr
  • alexandre-abrioux
  • aimensahnoun

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The description 'Validate Sui address format' is extremely minimal and lacks detail about the implementation, scope, and testing approach required by typical standards. Expand the description to explain what was changed, why Sui support was added, how the validation works, and any testing performed. Reference the template structure if one is required.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: sui address validation' clearly and concisely describes the main change: adding Sui address validation support to the codebase.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/sui-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 338221d and f799798.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (1)
  • packages/currency/package.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/currency/package.json
⏰ 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

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/currency/src/currencyManager.ts (1)

356-367: Fix JSDoc parameter description.

The JSDoc comment for the address parameter is missing a description. While the implementation correctly follows the established pattern and validates addresses without preprocessing (as per coding guidelines), the documentation should be complete.

Apply this diff to add the parameter description:

   /**
    * Validate a Sui address.
-   * @param address 
+   * @param address - The address to validate
    * @returns True if the address is valid, false otherwise
    */

Based on learnings

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5210d8c and b45b7f8.

📒 Files selected for processing (2)
  • packages/currency/package.json (1 hunks)
  • packages/currency/src/currencyManager.ts (3 hunks)
🧰 Additional context used
🧠 Learnings (7)
📓 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-18T12:33:47.986Z
Learnt from: rodrigopavezi
Repo: RequestNetwork/requestNetwork PR: 1475
File: packages/epk-cypher/package.json:49-67
Timestamp: 2024-11-18T12:33:47.986Z
Learning: In the `packages/epk-cypher/package.json` file, avoid suggesting updates to development dependencies unless essential, as the maintainer prefers to prevent potential instability.

Applied to files:

  • packages/currency/package.json
📚 Learning: 2024-11-04T12:18:18.615Z
Learnt from: giorgi-kiknavelidze
Repo: RequestNetwork/requestNetwork PR: 1482
File: packages/usage-examples/package.json:42-42
Timestamp: 2024-11-04T12:18:18.615Z
Learning: In the RequestNetwork project, the `dotenv` package version is maintained at `10.0.0` across packages, including `packages/smart-contracts/package.json`, to ensure consistency.

Applied to files:

  • packages/currency/package.json
📚 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-04T14:30:34.835Z
Learnt from: giorgi-kiknavelidze
Repo: RequestNetwork/requestNetwork PR: 1482
File: packages/usage-examples/src/hinkal/hinkalRequestData.ts:5-6
Timestamp: 2024-11-04T14:30:34.835Z
Learning: In `packages/usage-examples/src/hinkal/hinkalRequestData.ts`, it's acceptable to hardcode the USDC contract address without creating a mapping of USDC assets on specific networks.

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
📚 Learning: 2025-08-11T13:41:19.609Z
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.

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 (3)
packages/currency/src/currencyManager.ts (2)

276-277: LGTM!

The integration of Sui address validation follows the established pattern for other networks (TON, Starknet, Aleo) and is correctly placed in the validation flow.


14-14: Import path is correct.

The isValidSuiAddress function is correctly exported from @mysten/sui/utils in version 1.45.0. No changes needed.

packages/currency/package.json (1)

46-46: Dependency version verified and approved.

The @mysten/sui package version ^1.45.0 is appropriate—it matches the latest stable release on npm with no security vulnerabilities detected. The caret version constraint follows standard npm practices for patch and minor updates.

@MantisClone
Copy link
Member

Feel free to merge @LeoSlrRf

@LeoSlrRf LeoSlrRf merged commit 734baa2 into master Nov 17, 2025
10 checks passed
@LeoSlrRf LeoSlrRf deleted the feat/sui-address-validation branch November 17, 2025 09:48
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