GSNRecipient.sol 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. pragma solidity ^0.5.0;
  2. import "./IRelayRecipient.sol";
  3. import "./GSNContext.sol";
  4. import "./bouncers/GSNBouncerBase.sol";
  5. import "./IRelayHub.sol";
  6. /*
  7. * @dev Base GSN recipient contract, adding the recipient interface and enabling
  8. * GSN support. Not all interface methods are implemented, derived contracts
  9. * must do so themselves.
  10. */
  11. contract GSNRecipient is IRelayRecipient, GSNContext, GSNBouncerBase {
  12. /**
  13. * @dev Returns the RelayHub address for this recipient contract.
  14. */
  15. function getHubAddr() public view returns (address) {
  16. return _relayHub;
  17. }
  18. /**
  19. * @dev This function returns the version string of the RelayHub for which
  20. * this recipient implementation was built. It's not currently used, but
  21. * may be used by tooling.
  22. */
  23. // This function is view for future-proofing, it may require reading from
  24. // storage in the future.
  25. function relayHubVersion() public view returns (string memory) {
  26. this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
  27. return "1.0.0";
  28. }
  29. /**
  30. * @dev Triggers a withdraw of the recipient's deposits in RelayHub. Can
  31. * be used by derived contracts to expose the functionality in an external
  32. * interface.
  33. */
  34. function _withdrawDeposits(uint256 amount, address payable payee) internal {
  35. IRelayHub(_relayHub).withdraw(amount, payee);
  36. }
  37. }