Skip to content

Feat: Payments Module & Fix Pre-existing Workspace Test Failures - #61

Merged
memplethee-lab merged 16 commits into
SourceXXL:mainfrom
devIKargi:feat/Token
Aug 30, 2026
Merged

Feat: Payments Module & Fix Pre-existing Workspace Test Failures#61
memplethee-lab merged 16 commits into
SourceXXL:mainfrom
devIKargi:feat/Token

Conversation

@devIKargi

Copy link
Copy Markdown

Closes #45

Summary

Adds a standardized Payments module to the shared crate with safe token transfers, fee handling, pull-based escrow, and batch payout utilities — plus an example payments-contract demonstrating the full lifecycle. Also fixes all pre-existing test failures across the workspace, bringing the full test suite from ~80 failures to 300 passing / 0 failing.

Changes

New: Payments Module (shared/src/payments.rs — 1,388 LOC + 33 unit tests)

  • safe_transfer / safe_transfer_from_contract — validated token transfers with event emission
  • calculate_fee / calculate_fee_split — basis-point fee math with overflow protection
  • deduct_fee — atomic fee + net split to two recipients
  • create_escrow / release_escrow / refund_escrow — pull-based escrow with expiry, checks-effects-interactions pattern, state-transition guards
  • multi_transfer_all / execute_multi_transfer — re-exports from batch module

New: Example Contract (contracts/payments-contract/ — 19 integration tests)

  • Deposit, fee-deducted withdrawals, escrow create/release/refund, batch payouts, admin-only fee config

New: Error & Event Definitions (shared crate)

  • 11 payment error codes (PaymentInvalidAmount through PaymentEscrowIdOverflow)
  • 5 event topic constants (PAYMENT_TRANSFER, PAYMENT_FEE, PAYMENT_ESCROW_*)

Fixes across existing crates:

Crate Fix
shared/test_auth Wrap storage-touching tests in env.as_contract(); separate grant/revoke into distinct contract frames to avoid Auth, ExistingValue
shared/test_storage Wrap all tests in env.as_contract() for instance/persistent storage access
shared/batch Create DummyBatchContract with wrapper methods for proper auth propagation
aid-contract Remove merge conflict artifacts, fix double-counter bug in create_aid, fix storage.rs syntax
access-control Fix Soroban client Result unwrap assertions
upgradeability Fix fake_hash to use correct Env, wrap auth::/storage calls in as_contract, fix shadowed variable naming
registry-contract Set ledger timestamp in test so updated_at > 0 assertion passes
governance-contract Fix event topic assertion (ActionExecuted, not ParameterChanged)
referral-contract Fix reward cap value in overflow test to pass validation

Validation

  • cargo check --workspace — clean, 0 warnings
  • cargo test --workspace300 passed, 0 failed, 5 ignored (pre-existing)

Files committed (21 files, +2,682 / -361):

 contracts/payments-contract/Cargo.toml
 contracts/payments-contract/src/lib.rs
 contracts/payments-contract/src/test.rs
 shared/src/payments.rs
 shared/src/errors.rs
 shared/src/events.rs
 shared/src/lib.rs
 shared/src/batch.rs
 shared/src/test_auth.rs
 shared/src/test_storage.rs
 contracts/access-control/src/lib.rs
 contracts/aid-contract/src/lib.rs
 contracts/aid-contract/src/storage.rs
 contracts/aid-contract/src/tests.rs
 contracts/governance-contract/src/lib.rs
 contracts/referral-contract/src/lib.rs
 contracts/registry-contract/src/lib.rs
 contracts/upgradeability/src/lib.rs
 Cargo.toml
 Cargo.lock
 .freebuff/project-id

`

@memplethee-lab
memplethee-lab merged commit 9fb6051 into SourceXXL:main Aug 30, 2026
3 checks passed
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.

Module: Payments (Token & Native Transfer Utilities)

2 participants