github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/docs/assets/how-to-guides/porting-solidity-to-gno/porting-7.sol (about)

     1  /// Withdraw a bid that was overbid.
     2  function withdraw() external returns (bool) {
     3      uint amount = pendingReturns[msg.sender];
     4      if (amount > 0) {
     5          // It is important to set this to zero because the recipient
     6          // can call this function again as part of the receiving call
     7          // before `send` returns.
     8          pendingReturns[msg.sender] = 0;
     9  
    10          // msg.sender is not of type `address payable` and must be
    11          // explicitly converted using `payable(msg.sender)` in order
    12          // use the member function `send()`.
    13          if (!payable(msg.sender).send(amount)) {
    14              // No need to call throw here, just reset the amount owing
    15              pendingReturns[msg.sender] = amount;
    16              return false;
    17          }
    18      }
    19      return true;
    20  }