Skip to content

Conversation

shivam-bitgo
Copy link
Contributor

Ticket: COIN-5352

This pull request refactors and centralizes validation logic for Aptos custom transaction module and function names, ensuring stricter compliance with expected formats (hex addresses only for module names). It also updates usage throughout the codebase to leverage the new validation utilities, improves test coverage for valid and invalid cases, and adds new tests for custom token mint and burn transactions.

Validation logic refactor and enforcement:

  • Introduced new validation utilities in utils/validation.ts for module and function names, providing both throwing (validateModuleName, validateFunctionName) and non-throwing (isValidModuleName, isValidFunctionName) variants. These utilities enforce module names to use only hex addresses and valid function identifiers.
  • Removed inline regex validation methods from CustomTransaction and replaced their usage with calls to the centralized validation utilities.

Transaction builder validation updates:

  • Updated CustomTransactionBuilder to use the new validation utilities for checking module and function name formats, removing previous regex and address checks.

Testing improvements:

  • Modified unit tests to reject named addresses for module names, ensuring only hex addresses are accepted, and updated error expectations accordingly.
  • Added new tests for building custom token mint and burn transactions at deployed hex addresses, verifying correct construction and validation of these transaction types.

@shivam-bitgo shivam-bitgo self-assigned this Sep 9, 2025
@shivam-bitgo shivam-bitgo marked this pull request as ready for review September 9, 2025 13:33
@shivam-bitgo shivam-bitgo requested a review from a team as a code owner September 9, 2025 13:33
mukeshsp
mukeshsp previously approved these changes Sep 10, 2025
baltiyal
baltiyal previously approved these changes Sep 12, 2025
@shivam-bitgo
Copy link
Contributor Author

rebased as there were merge conflicts

Copy link
Contributor

@sampras-saha sampras-saha left a comment

Choose a reason for hiding this comment

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

LGTM

@shivam-bitgo shivam-bitgo merged commit ddcc7e2 into master Sep 12, 2025
12 checks passed
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.

4 participants