Feat: Payments Module & Fix Pre-existing Workspace Test Failures - #61
Merged
Conversation
added 16 commits
August 30, 2026 06:15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-contractdemonstrating 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 emissioncalculate_fee/calculate_fee_split— basis-point fee math with overflow protectiondeduct_fee— atomic fee + net split to two recipientscreate_escrow/release_escrow/refund_escrow— pull-based escrow with expiry, checks-effects-interactions pattern, state-transition guardsmulti_transfer_all/execute_multi_transfer— re-exports from batch moduleNew: Example Contract (
contracts/payments-contract/— 19 integration tests)New: Error & Event Definitions (shared crate)
PaymentInvalidAmountthroughPaymentEscrowIdOverflow)PAYMENT_TRANSFER,PAYMENT_FEE,PAYMENT_ESCROW_*)Fixes across existing crates:
shared/test_authenv.as_contract(); separate grant/revoke into distinct contract frames to avoidAuth, ExistingValueshared/test_storageenv.as_contract()for instance/persistent storage accessshared/batchDummyBatchContractwith wrapper methods for proper auth propagationaid-contractcreate_aid, fixstorage.rssyntaxaccess-controlResultunwrap assertionsupgradeabilityfake_hashto use correctEnv, wrapauth::/storage calls inas_contract, fix shadowed variable namingregistry-contractupdated_at > 0assertion passesgovernance-contractActionExecuted, notParameterChanged)referral-contractValidation
cargo check --workspace— clean, 0 warningscargo test --workspace— 300 passed, 0 failed, 5 ignored (pre-existing)Files committed (21 files, +2,682 / -361):
`