feat: implement foundation for emission splits in claim API #3
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.
Code Contribution
What Code Did You Write?
Implemented emission splits enforcement in the claim API, allowing configured splits to be automatically distributed when tokens are claimed.
Key Changes
1. Original Implementation: Emission Splits in Claims
Updated
createMintTransactionendpointgetEmissionSplits()to check for configured splitsUpdated
confirmClaimendpointhasClaimRights()Updated Response Types (
types/server.ts)MintClaimResponseBodynow includessplitRecipientsarrayConfirmClaimResponseBodynow includessplitRecipientsarrayuserTokenAccount(replaced with splitRecipients)adminAmountto show protocol fee2. Refactoring: Route Extraction (Commit: b2757f6)
🎯 Goal: Improve code organization and maintainability without changing any logic.
Impact: api-server.ts reduced from 2,427 → 427 lines (-82% reduction)
New Files Created:
lib/claimService.ts(182 lines) - Claim business logic and storagelib/presaleService.ts(139 lines) - Presale business logic and storageroutes/claims.ts(929 lines) - 3 claim endpointsroutes/presale.ts(1,232 lines) - 8 presale endpointsREFACTORING_VERIFICATION.md- Comprehensive verification reportWhat Was Moved:
Verification Completed:
See
REFACTORING_VERIFICATION.mdfor detailed line-by-line verification.How It Works
Example: Token with 70/30 Split
User claims 1,000 tokens:
Transaction Structure:
Backwards Compatibility:
hasClaimRights()fallback tocreator_walletAuthorization Flow
Before (PR #1 merged):
After (PR #3):
Security Considerations
✅ Authorization: Only wallets with claim rights can initiate claims
✅ Distribution: Claims distribute to ALL recipients regardless of who initiates
✅ Validation: Split percentages validated at database level (PR #1 trigger)
✅ Immutable: Once transaction is created, splits are fixed in metadata
✅ Atomic: All recipients receive tokens in single transaction
✅ Refactoring: Zero logic changes - code moved verbatim with structural changes only
Testing Strategy
Manual Testing Required:
Test Scenarios:
Why Does This Matter?
Enables Collaborative Claims:
Improved Code Organization (Refactoring):
User Experience:
Technical Benefits:
Commits in This PR
da8deb5 -
feat: implement emission splits in claim logicb2757f6 -
refactor: extract claims and presale routes to separate modulesChecklist
feat:,refactor:prefixes)Dependencies
Requires: PR #1 (Database Foundation) - ✅ MERGED
Enables: PR #4 (Claim UI) - Shows splits to users
Related Issues
Part of emission splits feature implementation.
Previous PRs:
Upcoming PRs:
Note: The ZC team currently reviews PRs and determines rewards. In the future, decision markets will determine merges and rewards.
🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com