github.com/cwntr/go-defi@v0.0.0-20210629134751-07f9ec2f7e66/contracts/handlers/HandlerBase.sol (about)

     1  pragma solidity ^0.5.0;
     2  
     3  import "../Config.sol";
     4  import "../Cache.sol";
     5  
     6  
     7  contract HandlerBase is Cache, Config {
     8      function postProcess() external payable {
     9          revert("Invalid post process");
    10          /* Implementation template
    11          bytes4 sig = cache.getSig();
    12          if (sig == bytes4(keccak256(bytes("handlerFunction_1()")))) {
    13              // Do something
    14          } else if (sig == bytes4(keccak256(bytes("handlerFunction_2()")))) {
    15              bytes32 temp = cache.get();
    16              // Do something
    17          } else revert("Invalid post process");
    18          */
    19      }
    20  
    21      function _updateToken(address token) internal {
    22          cache.setAddress(token);
    23          // Ignore token type to fit old handlers
    24          // cache.setHandlerType(uint256(HandlerType.Token));
    25      }
    26  
    27      function _updatePostProcess(bytes32[] memory params) internal {
    28          for (uint256 i = params.length; i > 0; i--) {
    29              cache.set(params[i - 1]);
    30          }
    31          cache.set(msg.sig);
    32          cache.setHandlerType(uint256(HandlerType.Custom));
    33      }
    34  }