Feat/mock contract crowdfunding #35
Open
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.
Overview
This PR implements a comprehensive mock token contract to support testing of crowdfunding campaigns and payment distributions in the Nevo platform. The mock token follows Soroban standards and provides all essential token functionality needed for development and testing.
Changes
Core Contract Implementation
New Files:
contract/contract/src/mock_token.rs- Main mock token contract implementationcontract/contract/test/mock_token_test.rs- Comprehensive test suite (16 test cases)Modified Files:
contract/contract/src/base/errors.rs- Added token-specific errorscontract/contract/src/base/events.rs- Added token operation eventscontract/contract/src/base/types.rs- Extended StorageKey enum for token datacontract/contract/src/lib.rs- Added mock_token module declarationcontract/contract/test/mod.rs- Included mock_token_test moduleToken Features Implemented
Token Initialization
Token Minting
Token Transfers
Token Queries
Error Handling
Added three new error types to handle token operations:
InsufficientBalance- Transfer attempts with inadequate fundsInvalidAmount- Negative or zero amount operationsUnauthorizedMinting- Mint attempts by non-admin addressesEvents
Implemented two token event types:
token_minted- Emitted on successful token mintingtoken_transferred- Emitted on successful token transfersTesting Coverage
Comprehensive test suite covering:
Technical Details
Storage Design
The contract uses Soroban's instance storage for:
Security Features
Compliance
The mock token follows Soroban contract patterns and integrates seamlessly with the existing Nevo crowdfunding infrastructure.
Testing Results
All tests pass successfully:
Usage
The mock token contract can be used for:
Acceptance Criteria Met
src/mock_token.rsFuture Considerations
This mock token provides a foundation for more advanced token features that may be needed as the Nevo platform evolves, such as: