Skip to content

Validate schedule params at proposal-creation time: amount_per_period >= MIN_AMOUNT, interval_secs within range, recipient != contract address, token passes validate_token #439

Description

@thegreatfeez

Smart Contract — New Feature

Summary

A recurring schedule's parameters must be validated before a proposal is accepted. This adds creation-time checks for amount, interval, recipient, and token, following the existing validation patterns.

Background

create_proposal in contracts/accord/src/lib.rs validates the recipient address, amount, and token before creating a proposal. The validate.rs module holds reusable validation helpers. The new recurring-payment proposal entrypoint must validate the schedule-specific parameters: amount per period, interval, recipient, and token.

What Needs to Be Done

  1. Validate that amount_per_period is at least MIN_AMOUNT, following the existing amount check pattern.
  2. Validate that interval_secs is within the range [MIN_INTERVAL_SECS, MAX_INTERVAL_SECS].
  3. Validate that the recipient address is not the contract's own address.
  4. Validate the token address through the existing validate_token helper.
  5. Return the appropriate contract error for each validation failure.

Acceptance Criteria

  • The proposal entrypoint rejects an amount below the minimum.
  • It rejects intervals outside the allowed range.
  • It rejects the contract's own address as recipient.
  • It rejects an invalid token address.
  • Each rejection returns a distinct error.
  • The contract compiles.

Files to Look At

  • contracts/accord/src/lib.rs — the proposal entrypoint with validation logic
  • contracts/accord/src/validate.rs — existing validation helpers

Difficulty: Medium

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions