feat(token-factory): validate create_token params #152
Merged
Conversation
|
@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! 🚀 |
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.
Description
Please include a summary of the changes and the "Why" behind them.
Summary
Adds input validation to
create_tokenin the TokenFactory contract,putting the previously dead
Error::InvalidParametersvariant to use.Changes
contracts/token-factory/src/lib.rs
create_token(before auth,fee, and storage access) that rejects:
namesymboldecimals > 18initial_supply < 0symbol_short!stringsexceeding the 9-char limit, wrong
StellarAssetClientimport,missing
transfer_adminmethod, invaliddeploy_tokenAPI call,and
Errorenum missing#[contracterror]/#[repr(u32)].contracts/token-factory/src/test.rs
test_create_token_rejects_empty_nametest_create_token_rejects_empty_symboltest_create_token_rejects_decimals_19test_create_token_accepts_decimals_18test_create_token_rejects_negative_supplycontracts/token-factory/Cargo.toml
proptestfrom[dependencies]to[dev-dependencies].Test results
All 22 unit tests pass (
cargo test -p token-factory).Acceptance criteria
InvalidParametersInvalidParametersdecimals > 18returnsInvalidParametersInvalidParameterserror variant is no longer dead codeRelated Issue
Link the issue using "Closes #XX" or "Fixes #XX".
Closes #93
Type of Change
Please tick the relevant options:
Testing Done
Please describe the tests you ran (unit tests, manual verification, etc.) to verify your changes.
Checklist