-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathGsnModule.sol
More file actions
28 lines (20 loc) · 1.11 KB
/
GsnModule.sol
File metadata and controls
28 lines (20 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
pragma solidity >=0.5.0 <0.7.0;
import { GnosisSafe } from "@gnosis.pm/safe-contracts/contracts/GnosisSafe.sol";
import { Module } from "@gnosis.pm/safe-contracts/contracts/base/Module.sol";
import { Enum } from "@gnosis.pm/safe-contracts/contracts/common/Enum.sol";
import { BaseRelayRecipient } from "./gsn/BaseRelayRecipient.sol";
contract GsnModule is Module, BaseRelayRecipient {
function setForwarder(address forwarder) public {
require(trustedForwarder==address(0), "Forwrader already set");
trustedForwarder=forwarder;
}
function execCall(GnosisSafe proxy, address to, bytes calldata data,Enum.Operation operation) external {
require( proxy.isOwner(_msgSender()), "execCall: not owner");
proxy.execTransactionFromModule(to, 0, data, operation);
}
//called as delegatecall during setup, to add this GsnModule as a module.
// since its a delegateCall, "this" is the GnosisSafe itself, and the module (real this) is a parameter...
function setup(GsnModule gsnModule) external {
GnosisSafe(address(uint160(address(this)))).enableModule(gsnModule);
}
}