Area: Smart contract · lib.rs (create_token_inner, validate_batch_params, create_token)
Description
The two creation paths have drifted:
- Error codes differ for identical faults: single-path returns
InvalidTokenParams for bad
name/symbol but InvalidParameters for bad decimals; the batch path returns InvalidParameters
for all of them. Client error mapping (utils/contractErrors.ts) can't render consistent
messages, and documented ABI behavior differs by entrypoint for the same user mistake.
- Type asymmetry: single-path
initial_supply is u128 (with two duplicated > i128::MAX
guards at lib.rs:383 and lib.rs:396 — dead code from a merge), batch initial_supply is
i128 (negative rejected at validation). Same concept, two types, two validation shapes.
- Feature asymmetry: only the batch path supports
max_supply; a single-token creator cannot cap
supply at all (the README documents this as a caveat rather than it being fixed), and the
single-path always writes max_supply: None.
- Fee-check ordering differs: batch validates all params before charging; single-path interleaves.
These asymmetries are where bugs like Issue 2 breed — the paths must share one validation and one
bookkeeping routine.
Tasks
Acceptance criteria
- For every invalid parameter set, both creation paths return the identical error code, proven by a
shared property-based test matrix.
- Single-token creation supports
max_supply with the Issue 2-corrected accounting.
- No duplicated validation logic remains (one shared routine, verified by review).
Issue 18 of 20 from the codebase audit tracked in ISSUES.md.
Area: Smart contract ·
lib.rs(create_token_inner,validate_batch_params,create_token)Description
The two creation paths have drifted:
InvalidTokenParamsfor badname/symbol but
InvalidParametersfor bad decimals; the batch path returnsInvalidParametersfor all of them. Client error mapping (
utils/contractErrors.ts) can't render consistentmessages, and documented ABI behavior differs by entrypoint for the same user mistake.
initial_supplyisu128(with two duplicated> i128::MAXguards at
lib.rs:383andlib.rs:396— dead code from a merge), batchinitial_supplyisi128(negative rejected at validation). Same concept, two types, two validation shapes.max_supply; a single-token creator cannot capsupply at all (the README documents this as a caveat rather than it being fixed), and the
single-path always writes
max_supply: None.These asymmetries are where bugs like Issue 2 breed — the paths must share one validation and one
bookkeeping routine.
Tasks
validate_token_params+record_tokenused by both paths; delete theduplicated
i128::MAXguard.initial_supplytyping (recommendi128with>= 0validation to match the batch pathand the SDK's mint signature) — note this is an ABI change; coordinate with the frontend
(Issue 5's audit) and bump documented ABI.
max_supply: Option<i128>to singlecreate_tokenfor parity.docs/contract-abi.mdandfrontend/src/utils/contractErrors.ts.sets with the same error codes.
Acceptance criteria
shared property-based test matrix.
max_supplywith the Issue 2-corrected accounting.Issue 18 of 20 from the codebase audit tracked in
ISSUES.md.