github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/docs/assets/how-to-guides/porting-solidity-to-gno/porting-2.sol (about) 1 // Parameters of the auction. Times are either 2 // absolute unix timestamps (seconds since 1970-01-01) 3 // or time periods in seconds. 4 address payable public beneficiary; 5 uint public auctionEndTime; 6 7 // Current state of the auction. 8 address public highestBidder; 9 uint public highestBid; 10 11 // Allowed withdrawals of previous bids 12 mapping(address => uint) pendingReturns; 13 14 // Set to true at the end, disallows any change. 15 // By default initialized to `false`. 16 bool ended; 17 18 // Events that will be emitted on changes. 19 event HighestBidIncreased(address bidder, uint amount); 20 event AuctionEnded(address winner, uint amount); 21 22 // Errors that describe failures. 23 24 // The triple-slash comments are so-called natspec 25 // comments. They will be shown when the user 26 // is asked to confirm a transaction or 27 // when an error is displayed. 28 29 /// The auction has already ended. 30 error AuctionAlreadyEnded(); 31 /// There is already a higher or equal bid. 32 error BidNotHighEnough(uint highestBid); 33 /// The auction has not ended yet. 34 error AuctionNotYetEnded(); 35 /// The function auctionEnd has already been called. 36 error AuctionEndAlreadyCalled(); 37 38 /// Create a simple auction with `biddingTime` 39 /// seconds bidding time on behalf of the 40 /// beneficiary address `beneficiaryAddress`. 41 constructor( 42 uint biddingTime, 43 address payable beneficiaryAddress 44 ) { 45 beneficiary = beneficiaryAddress; 46 auctionEndTime = block.timestamp + biddingTime; 47 }