🔴 Critical · contracts/token-factory/src/lib.rs:253-385 vs :34-41,387-473
Description
BatchTokenParams (used only by create_tokens_batch) includes pub max_supply: Option<i128>, enforced both at creation time (validate_batch_params rejects initial_supply > cap) and at mint time (mint_tokens checks MaxSupplyExceeded). The single-token path, create_token, has no equivalent parameter — every token created through it has max_supply: None hardcoded at line 358, meaning it is uncappable for the lifetime of the token. A creator who wants a supply-capped token is forced through the batch API even for a single token, which is a confusing, undocumented requirement, and any UI or integration built naively against create_token alone can never offer this safety feature to end users.
Tasks
Acceptance Criteria
🔴 Critical ·
contracts/token-factory/src/lib.rs:253-385vs:34-41,387-473Description
BatchTokenParams(used only bycreate_tokens_batch) includespub max_supply: Option<i128>, enforced both at creation time (validate_batch_paramsrejectsinitial_supply > cap) and at mint time (mint_tokenschecksMaxSupplyExceeded). The single-token path,create_token, has no equivalent parameter — every token created through it hasmax_supply: Nonehardcoded at line 358, meaning it is uncappable for the lifetime of the token. A creator who wants a supply-capped token is forced through the batch API even for a single token, which is a confusing, undocumented requirement, and any UI or integration built naively againstcreate_tokenalone can never offer this safety feature to end users.Tasks
Option<i128>max_supplyparameter tocreate_token(andcreate_token_inner), applying the samecap <= 0 || initial_supply > capvalidation currently duplicated invalidate_batch_params.create_token_innerandvalidate_batch_paramsinto one function to eliminate the current logic duplication and prevent the two paths from drifting further apart.frontend/src/components/CreateToken.tsxand the corresponding service call infrontend/src/services/stellar-impl.tsto expose an optional max-supply field on the single-token creation form.docs/contract-abi.md'screate_tokensignature and the README's Contract Functions section to reflect the new parameter.upgrade+ client-version coordination in the PR description (old clients calling the new contract will fail argument decoding).Acceptance Criteria
create_tokenaccepts an optionalmax_supplyand stores it in the resultingTokenInfo, verified by a newtest.rscase.mint_tokensalready enforcesMaxSupplyExceededoffTokenInfo.max_supply— a test confirms this now also triggers correctly for tokens created via the single-token path (not just batch).create_tokenrejectsinitial_supply > max_supplywithInvalidParameters, mirroringvalidate_batch_params.CreateTokenform round-trips a max-supply value end-to-end against a local/testnet deployment.