github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/docs/assets/how-to-guides/porting-solidity-to-gno/porting-10.sol (about) 1 /// End the auction and send the highest bid 2 /// to the beneficiary. 3 function auctionEnd() external { 4 // It is a good guideline to structure functions that interact 5 // with other contracts (i.e. they call functions or send Ether) 6 // into three phases: 7 // 1. checking conditions 8 // 2. performing actions (potentially changing conditions) 9 // 3. interacting with other contracts 10 // If these phases are mixed up, the other contract could call 11 // back into the current contract and modify the state or cause 12 // effects (ether payout) to be performed multiple times. 13 // If functions called internally include interaction with external 14 // contracts, they also have to be considered interaction with 15 // external contracts. 16 17 // 1. Conditions 18 if (block.timestamp < auctionEndTime) 19 revert AuctionNotYetEnded(); 20 if (ended) 21 revert AuctionEndAlreadyCalled(); 22 23 // 2. Effects 24 ended = true; 25 emit AuctionEnded(highestBidder, highestBid); 26 27 // 3. Interaction 28 beneficiary.transfer(highestBid); 29 }