feat: wrote smart contract for fund request for project milestone #104
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.
🎯 Implement Standalone FundRequest Smart Contract
closes #99
📚 Overview
This PR implements a comprehensive standalone FundRequest smart contract in Cairo for the BudgetChain project. The contract manages fund requests tied to project milestones with robust validation, access controls, and automatic budget updates.
✅ Issue Requirements Satisfied
1. Data Structures & Storage
FundRequeststruct with all required fields:project_id: u64milestone_id: u64amount: u128requester: ContractAddressstatus: FundRequestStatus (Pending, Approved, Rejected)Events defined:
FundsRequested(project_id, request_id, milestone_id)FundsReleased(project_id, request_id, milestone_id, amount)FundsReturned(project_id, amount, project_owner)Storage setup includes:
2. Function Implementation
create_fund_request: Project owners can create requests only for completed milestonesapprove_fund_request: Authorized approvers can approve requests and release fundsreject_fund_request: Authorized approvers can reject pending requests3. Validation & Access Control
4. Event Emission
FundsRequested: Emitted when a request is createdFundsReleased: Emitted when funds are releasedFundsReturned: Defined and ready for future use🏗️ Technical Implementation
Core Architecture
Security Features
Key Technical Decisions
request_existsmapping🧪 Testing Coverage
Core Functionality
Security Tests
Access Control
Edge Cases
Test Results:
📁 Files Added/Modified
New Files:
src/fund_request.cairo: Main contractsrc/lib.cairo: Interfaces & exportstests/test_fund_request.cairo: Full test suitescripts/deploy.sh: Deployment automationConfiguration:
Scarb.toml: Cairo project setupsnfoundry.toml: Test configuration🚀 Integration Points
External Dependencies
IProjectContractEvent Integration
🛡️ Security Considerations
Access Control Matrix
Validation Layers
📋 Deployment Instructions
Build the contract:
cd budgetchain-app/onchain/budget_contract scarb buildRun tests:
snforge test🔄 Future Enhancements
FundsReturnedevent prepared)✅ Checklist
🎯 Impact
This implementation provides BudgetChain with:
##Screenshots