Skip to content

Commit

Permalink
Merge pull request #172 from EmmanuelAR/feat/171
Browse files Browse the repository at this point in the history
Fix withdraw asserts and add approve method.
  • Loading branch information
EmmanuelAR authored Oct 31, 2024
2 parents 723d1b1 + a86956b commit 72ff78f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions contracts/src/fund.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,16 @@ pub mod Fund {
let caller = get_caller_address();
assert!(self.owner.read() == caller, "You are not the owner");
assert(self.state.read() == FundStates::CLOSED, 'Fund not close goal yet.');
assert(self.get_current_goal_state() > 0, 'Fund hasnt reached its goal yet');
assert(
self.get_current_goal_state() >= self.getGoal(), 'Fund hasnt reached its goal yet'
);
// Withdraw
let withdrawn_amount = self.get_current_goal_state();
// TODO: Calculate balance to deposit in owner address and in fund manager address (95%
// and 5%), also transfer the amount to fund manager address.
self.token_dispatcher().approve(self.getOwner(), withdrawn_amount);
self.token_dispatcher().transfer(self.getOwner(), withdrawn_amount);
assert(self.get_current_goal_state() != 0, 'Fund hasnt reached its goal yet');
assert(self.get_current_goal_state() == 0, 'Pending stks to withdraw');
self.setState(4);
self
.emit(
Expand Down

0 comments on commit 72ff78f

Please sign in to comment.