Skip to content

feat(token-factory): validate create_token params #152

Merged
Ejirowebfi merged 2 commits into
Favourorg:mainfrom
Jayydy:fix
Mar 24, 2026
Merged

feat(token-factory): validate create_token params #152
Ejirowebfi merged 2 commits into
Favourorg:mainfrom
Jayydy:fix

Conversation

@Jayydy

@Jayydy Jayydy commented Mar 24, 2026

Copy link
Copy Markdown
Contributor

Description

Please include a summary of the changes and the "Why" behind them.

Summary

Adds input validation to create_token in the TokenFactory contract,
putting the previously dead Error::InvalidParameters variant to use.

Changes

contracts/token-factory/src/lib.rs

  • Added a validation block at the top of create_token (before auth,
    fee, and storage access) that rejects:
    • empty name
    • empty symbol
    • decimals > 18
    • initial_supply < 0
  • Fixed pre-existing compilation errors: symbol_short! strings
    exceeding the 9-char limit, wrong StellarAssetClient import,
    missing transfer_admin method, invalid deploy_token API call,
    and Error enum missing #[contracterror] / #[repr(u32)].

contracts/token-factory/src/test.rs

  • Added 5 unit tests covering each invalid parameter case:
    • test_create_token_rejects_empty_name
    • test_create_token_rejects_empty_symbol
    • test_create_token_rejects_decimals_19
    • test_create_token_accepts_decimals_18
    • test_create_token_rejects_negative_supply

contracts/token-factory/Cargo.toml

  • Moved proptest from [dependencies] to [dev-dependencies].

Test results

All 22 unit tests pass (cargo test -p token-factory).

Acceptance criteria

  • Empty token name returns InvalidParameters
  • Empty symbol returns InvalidParameters
  • decimals > 18 returns InvalidParameters
  • InvalidParameters error variant is no longer dead code

Related Issue

Link the issue using "Closes #XX" or "Fixes #XX".

Closes #93

Type of Change

Please tick the relevant options:

  • [x ] Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Testing Done

Please describe the tests you ran (unit tests, manual verification, etc.) to verify your changes.

Checklist

  • [ x] My code follows the style guidelines of this project
  • [x ] I have performed a self-review of my own code
  • [x ] I have made corresponding changes to the documentation
  • [ x] My changes generate no new warnings
  • [ x] I have added tests that prove my fix is effective or my feature works
  • [ x] New and existing unit tests pass locally with my changes

@drips-wave

drips-wave Bot commented Mar 24, 2026

Copy link
Copy Markdown

@Jayydy Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Ejirowebfi Ejirowebfi merged commit 0b0680c into Favourorg:main Mar 24, 2026
0 of 2 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.

Add InvalidParameters Usage in Contract

2 participants