Skip to content

Commit

Permalink
Agregue el sendMoney baby
Browse files Browse the repository at this point in the history
  • Loading branch information
fefocabrera committed Jun 23, 2019
1 parent 02f9279 commit 916d409
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/contracts/auction.sol
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,18 @@ contract Auction {
bids[bidsCount] = newBid;
bidsCount++;
// TODO: first we need to return the actualBid to the last offered.
sendMoneyBidder(actualBid);
actualBid = newBid;
finishedAuction();
}

function sendMoneyBidder () private {
address bidder = b.bidder;
uint256 bid = b.bid;

bidder.transfer(bid);
}

function publishBids() public onlyOwner() isAuctionClose() {
uint count = 0;
for (uint i = 1; i <= bidsCount; i++){
Expand All @@ -109,12 +117,23 @@ contract Auction {
open = false;
publishBids();
emit publishWinner(actualBid.bidder, actualBid.bid);
sendMoneyOwner(actualBid);
// TODO: Pay the amount of the bid to the owner of the auction item (ASK IF auction item owner == auction owner)

}
}

function sendMoneyOwner () private {
uint256 bid = b.bid;

owner.transfer(bid);
}

function closeBid() public onlyOwner() isMinimumReached() {
open = false;
publishBids();
emit publishWinner(actualBid.bidder, actualBid.bid);
sendMoneyOwner(actualBid);
}

/* Getters */
Expand Down

0 comments on commit 916d409

Please sign in to comment.