Skip to content

Instantly share code, notes, and snippets.

@auryn-macmillan
Last active January 31, 2022 04:15
Show Gist options
  • Save auryn-macmillan/841906d0bc6c2624e83598cdfac17de8 to your computer and use it in GitHub Desktop.
Save auryn-macmillan/841906d0bc6c2624e83598cdfac17de8 to your computer and use it in GitHub Desktop.
MyModule.sol
pragma solidity ^0.8.6;
import "@gnosis.pm/zodiac/contracts/core/Module.sol";
import "./Button.sol";
contract MyModule is Module {
address public button;
function pushButton() external {
exec(
button,
0,
abi.encodePacked(bytes4(keccak256("pushButton()"))),
Enum.Operation.Call
);
}
constructor(address _owner, address _button) {
bytes memory initializeParams = abi.encode(_owner, _button);
setUp(initializeParams);
}
/// @dev Initialize function, will be triggered when a new proxy is deployed
/// @param initializeParams Parameters of initialization encoded
function setUp(bytes memory initializeParams) public override initializer {
__Ownable_init();
(address _owner, address _button) = abi.decode(initializeParams, (address, address));
setAvatar(_owner);
setTarget(_owner);
button = _button;
transferOwnership(_owner);
}
}
@Geimaj
Copy link

Geimaj commented Jan 27, 2022

Deploying this contract fails with the error reverted with reason string 'Initializable: contract is not initializing' unless the initializer modifier is added to the setUp function on line 26.

@auryn-macmillan
Copy link
Author

Thanks, @Geimaj! Have updated the gist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment