-
Notifications
You must be signed in to change notification settings - Fork 2
Module-II #102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Majormaxx
wants to merge
27
commits into
collabberry:main
Choose a base branch
from
Majormaxx:Module-II
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Module-II #102
Conversation
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
- Added validateMintingPermission method to check MINTER_ROLE, ADMIN_ROLE, and owner patterns - Enhanced recognition token validation for MINT mode with comprehensive role checking - Added support for TeamPoints contracts using ADMIN_ROLE instead of MINTER_ROLE - Added detailed error messages and logging for debugging minting permission issues - Fixed linting issues in organization and user controllers
…osals, and status tracking
… proposal tracking
Add comprehensive validation endpoint that returns detailed metadata: - Safe info: owners list and threshold - Token info: name, symbol, decimals for both stablecoin and recognition token - Minting role status for mint mode - Token balance for transfer mode Extract validation logic into separate method to support validation endpoint without persisting changes.
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.
Module-II: Round-based Payouts Implementation
Summary
This PR implements Module-II: Round-based Payouts for the CollabBerry Token Payment Automation system, delivering the complete workflow for preview, propose, sign, and execute functionality for round-based stablecoin and recognition token distributions via Gnosis Safe multisig.
Additionally, this PR includes completion of Module-I (Admin Configuration) features to ensure a clean build with zero TypeScript errors and full compliance with both modules' acceptance criteria.
Module-II Acceptance Criteria
Core Requirements
GET /api/v1/payouts/preview?roundId=POST /api/v1/payouts/proposeGET /api/v1/payouts/status?roundId=PayoutServiceethers.parseUnits()with token decimalsPayoutRouterfollows established patternModule-I Completion
To achieve a clean build and ensure Module-II has a solid foundation, this PR also completes missing Module-I features:
Implemented Features
GET /api/v1/organization/configuration/chainsPOST /api/v1/organization/configuration/validateorganization-configuration.service.tsandsafe.service.tsethers.parseUnits()Technical Implementation
Architecture Decisions
Safe SDK v5 Integration
await import()) to avoid TypeScript namespace errorsSafeTransactionServiceas a wrapper for Protocol Kit and API KitJoi Validation Pattern
Class-based Router Pattern
PayoutRouterto use InversifyJS dependency injectionUserRouter,OrgRouter,RoundsRouterEntity Definite Assignment
!assertions to all payout entity propertiesChunking Logic
tx_proposalswithpartIndex/partCountKey Files Modified
Module-II Implementation:
src/services/safe/safe-transaction.service.ts- Safe SDK wrapper (new)src/services/payout.service.ts- Payout business logic with Safe integrationsrc/controllers/payout.controller.ts- Payout endpoints with Joi validationsrc/routers/payout.router.ts- Class-based router with dependency injectionsrc/entities/payout/*.ts- Payout, TxProposal, PayoutRecipient entitiessrc/models/payout/*.ts- Joi validation schemas (new)src/inversify.config.ts- Added Module-II service bindingssrc/inversify.types.ts- Added Module-II type symbolsModule-I Completion:
src/services/org/organization-configuration.service.ts- AddedgetSupportedChains()andvalidateSafeConfig()methods, migrated to Safe SDK v5src/controllers/organization-configuration.controller.ts- Implemented validation and chains endpointssrc/services/safe.service.ts- Migrated to Safe SDK v5src/controllers/organization.controller.ts- FixedUser.walletAddress→User.address(7 instances)src/controllers/rounds.controller.ts- FixedUser.walletAddress→User.address(7 instances), fixededitAssessmentandaddTokenMintTxmethodssrc/controllers/user.controller.ts- FixedUser.walletAddress→User.address(2 instances)src/models/rounds/addTokenMintTx.model.ts- Created missing Joi schema (new)Testing & Verification
Build Verification
npx tsc --noEmit # Result: 0 errorsCommits by Category
Module-II Core Features:
c7cddb3- build: add Safe API Kit dependency for transaction service integrationb9e4816- feat: implement Safe transaction service wrapper for multisig operations1c8e5d1- feat: add Joi validation schemas for payout endpointsfe542a0- feat: apply Joi validation to payout controller endpoints1586f21- feat: integrate Safe SDK for transaction creation and status pollinga7ce3be- refactor: convert payout router to class-based dependency injection pattern2ca4e9a- fix: resolve TypeScript compilation errors in Module-II implementationModule-I Completion:
7aa2b87- fix: resolve Module-I TypeScript errors to enable clean buildd8566fb- feat: implement getSupportedChains and validateSafeConfig methodsEarlier Foundation Work:
baba04c- Added database entities for payout recipients, transactions, and Safe proposal trackingac1f9b1- Integrated payout management routes for rounds listing, preview, proposals, and status trackingd62b876- Added rounds listing and preview APIs with validation warningsd6614b1- Added rounds listing API with incomplete round filtering5634c9a- Added dependency injection configuration for Module II servicesAPI Endpoints
Module-II Endpoints
GET
/api/v1/payouts/rounds?orgId={orgId}List incomplete rounds for an organization.
Response:
{ "rounds": [ { "id": "uuid", "name": "Round 1", "status": "INCOMPLETE", "participantCount": 10 } ] }GET
/api/v1/payouts/preview?roundId={roundId}Preview payout details with preflight checks.
Response:
{ "recipients": [ { "address": "0x...", "stablecoinAmount": "100.00", "recognitionTokenAmount": "50.00" } ], "totals": { "stablecoin": "1000.00", "recognitionToken": "500.00" }, "warnings": ["Safe has insufficient stablecoin balance"], "chunkPlan": { "totalChunks": 2, "recipientsPerChunk": [50, 25] } }POST
/api/v1/payouts/proposeCreate Safe transaction proposals for a round.
Request:
{ "roundId": "uuid", "signerPrivateKey": "optional-for-auto-sign" }Response:
{ "proposals": [ { "safeTxHash": "0x...", "partIndex": 1, "partCount": 2, "status": "PROPOSED" } ] }GET
/api/v1/payouts/status?roundId={roundId}Poll transaction status for a round.
Response:
{ "proposals": [ { "safeTxHash": "0x...", "status": "EXECUTED", "confirmations": 2, "threshold": 2, "executedAt": "2025-10-16T12:00:00Z" } ] }Module-I Endpoints
GET
/api/v1/organization/configuration/chainsGet supported blockchain networks.
Response:
{ "chains": [ { "chainId": 42161, "name": "Arbitrum One", "rpcUrl": "https://arb1.arbitrum.io/rpc" } ] }POST
/api/v1/organization/configuration/validateValidate Safe configuration without saving.
Request:
{ "safeAddress": "0x...", "safeChainId": 42161, "stablecoinAddress": "0x...", "stablecoinDecimals": 6, "recognitionTokenAddress": "0x...", "recognitionTokenDecimals": 18, "recognitionTokenMode": "MINT" }Response:
{ "isValid": true, "errors": [], "warnings": ["Safe has low stablecoin balance"], "safeInfo": { "owners": ["0x...", "0x..."], "threshold": 2 }, "tokenInfo": { "stablecoin": { "name": "USD Coin", "symbol": "USDC", "decimals": 6 }, "recognition": { "name": "TeamPoints", "symbol": "TP", "decimals": 18, "hasMintingRole": true } } }Dependencies Added
{ "@safe-global/api-kit": "^2.4.6", "@safe-global/protocol-kit": "^5.2.17" }Breaking Changes
None. This PR is additive and completes existing functionality.
Reviewer Notes