GSNRecipient.sol 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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: includes the {IRelayRecipient} interface and enables GSN support on all contracts
  8. * in the inheritance tree.
  9. *
  10. * Not all interface methods are implemented (e.g. {acceptRelayedCall}, derived contracts must provide one themselves.
  11. */
  12. contract GSNRecipient is IRelayRecipient, GSNContext, GSNBouncerBase {
  13. /**
  14. * @dev Returns the `RelayHub` address for this recipient contract.
  15. */
  16. function getHubAddr() public view returns (address) {
  17. return _relayHub;
  18. }
  19. /**
  20. * @dev Returns the version string of the `RelayHub` for which this recipient implementation was built.
  21. */
  22. // This function is view for future-proofing, it may require reading from
  23. // storage in the future.
  24. function relayHubVersion() public view returns (string memory) {
  25. this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
  26. return "1.0.0";
  27. }
  28. /**
  29. * @dev Withdraws the recipient's deposits in `RelayHub`.
  30. *
  31. * Derived contracts should expose this in an external interface with proper access control.
  32. */
  33. function _withdrawDeposits(uint256 amount, address payable payee) internal {
  34. IRelayHub(_relayHub).withdraw(amount, payee);
  35. }
  36. }