Skip to content

Conversation

@Bakobiibizo
Copy link
Contributor

Automated Payment System Implementation

Overview

This PR implements an automated payment system within the governance pallet, enabling scheduled recurring payments from the DAO treasury using block-based timing for deterministic execution.

Key Changes

  1. Added new payment system in governance pallet:

    • ScheduledPayment struct for payment configuration
    • Block-based timing with next_payment_block and payment_interval
    • Configurable payment counts (finite or infinite)
    • Default 10-day payment cycle (108,000 blocks)
  2. Storage and Events:

    • Added PaymentSchedules storage for active schedules
    • Added NextPaymentScheduleId counter
    • New events for payment lifecycle tracking
  3. User Interface Parameters:

    • Amount: In nano'd currency (e.g., 1 token = 1,000,000,000)
    • Next Payment Block: Absolute block number for first payment
    • Payment Interval: Blocks between payments (default: 108,000)
    • Remaining Payments: Count of payments (0 for indefinite)

Testing

  • Comprehensive test coverage in payments_tests.rs
  • Mock runtime setup for treasury integration
  • Block progression simulation
  • Payment schedule validation
  • Error handling scenarios

Security

  • Treasury balance verification
  • Governance-controlled schedule management
  • Fail-safe payment processing
  • Schedule cancellation support

Documentation

  • Updated governance pallet documentation
  • Added usage examples and parameter explanations
  • Technical architecture documentation

Breaking Changes

None. This is a new feature addition that maintains compatibility with existing functionality.

Checklist

  • Implemented core payment scheduling logic
  • Added comprehensive tests
  • Updated documentation
  • Removed experimental pallet
  • Fixed all clippy warnings
  • Verified treasury integration

@jzanecook jzanecook changed the base branch from main to dev June 23, 2025 00:43
- Removed integration tests since they were completely unused
- Pre-existing governance tests have been moved to
  /tests/src/governance/proposals
- Payment-related tests have been merged and moved to
  /tests/src/governance/payments
- Some payment-related tests were either unused or unfinished, so I
  completed them. All tests should be accurate now.
@jzanecook jzanecook merged commit 78367bf into commune-ai:dev Jun 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants