Skip to content

Validate ContractMeta inputs in register_contract and update_contract #29

Description

@priscaenoch

Problem

register_contract (and the corresponding update_contract) in explorer/src/lib.rs store the caller-supplied ContractMeta after checking pause state, admin authorization, and existence, but they do not validate the contents of meta. Fields such as names, symbols, or ABI strings are written to persistent storage without length or emptiness bounds, allowing malformed or oversized metadata that bloats persistent storage (and its rent) and can produce nonsensical registry entries the indexer must then handle.

What needs to be done

  • Define and enforce bounds on ContractMeta fields: reject empty required fields and enforce maximum lengths for strings/collections.
  • Return typed Error variants for invalid metadata (add variants as needed).
  • Apply the same validation in both register_contract and update_contract.
  • Document the accepted field constraints alongside the interface/event documentation.

Files

  • explorer/src/lib.rs

Acceptance deliverables

  • Malformed or oversized metadata is rejected with a typed error at write time.
  • Registered/updated entries always satisfy the documented constraints.
  • All CI checks pass; the change cannot be merged until CI is green.

Tests to pass

  • Test: registering with an empty required field returns a typed error.
  • Test: registering with an over-length field returns a typed error.
  • Test: valid metadata registers successfully and reads back unchanged.

Metadata

Metadata

Assignees

No one assigned

    Labels

    GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardThird CampaignCampaign: Third CampaignbugSomething isn't workingenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions