From 319acd470c42f8b4ad373a48fba78d835044f1f5 Mon Sep 17 00:00:00 2001 From: Alan Lu Date: Mon, 28 Dec 2020 16:12:11 -0600 Subject: [PATCH] Add immutable to properties --- contracts/solc-0.8/CPKFactory.sol | 23 ++++++++++------------- contracts/solc-0.8/CPKFactoryFacade.sol | 8 ++++---- contracts/solc-0.8/ProxyImplSetter.sol | 4 ++-- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/contracts/solc-0.8/CPKFactory.sol b/contracts/solc-0.8/CPKFactory.sol index d4c6672f..4b8600cf 100644 --- a/contracts/solc-0.8/CPKFactory.sol +++ b/contracts/solc-0.8/CPKFactory.sol @@ -18,26 +18,23 @@ contract CPKFactory { ); uint256 public constant version = 2; - ProxyImplSetter public proxyImplSetter; - IGnosisSafeProxyFactory public gnosisSafeProxyFactory; + ProxyImplSetter public immutable proxyImplSetter; + IGnosisSafeProxyFactory public immutable gnosisSafeProxyFactory; + address public immutable proxyExtCodeHash; constructor(IGnosisSafeProxyFactory _gnosisSafeProxyFactory) { proxyImplSetter = new ProxyImplSetter(address(this)); gnosisSafeProxyFactory = _gnosisSafeProxyFactory; + proxyExtCodeHash = keccak256(gnosisSafeProxyFactory.proxyRuntimeCode()); } - // Accessors removed until something is figured out about the fact that these depend on the compiler - // but really should depend instead on the specific gnosisSafeProxyFactory instance used - - // function proxyCreationCode() external pure returns (bytes memory) { - // return type(GnosisSafeProxy).creationCode; - // } - - // function proxyRuntimeCode() external pure returns (bytes memory) { - // return type(GnosisSafeProxy).runtimeCode; - // } + function proxyCreationCode() external pure returns (bytes memory) { + return gnosisSafeProxyFactory.proxyCreationCode(); + } - // bytes32 public constant proxyExtCodeHash = keccak256(type(GnosisSafeProxy).runtimeCode); + function proxyRuntimeCode() external pure returns (bytes memory) { + return gnosisSafeProxyFactory.proxyRuntimeCode(); + } function createProxyAndExecTransaction( address owner, diff --git a/contracts/solc-0.8/CPKFactoryFacade.sol b/contracts/solc-0.8/CPKFactoryFacade.sol index 9a1b32b3..28e70623 100644 --- a/contracts/solc-0.8/CPKFactoryFacade.sol +++ b/contracts/solc-0.8/CPKFactoryFacade.sol @@ -5,10 +5,10 @@ import { Enum } from "./dep-ports/Enum.sol"; import { CPKFactory, CPKFactoryTx } from "./CPKFactory.sol"; contract CPKFactoryFacade { - CPKFactory cpkFactory; - address safeVersion; - uint256 salt; - address fallbackHandler; + CPKFactory immutable cpkFactory; + address immutable safeVersion; + uint256 immutable salt; + address immutable fallbackHandler; constructor( CPKFactory _cpkFactory, diff --git a/contracts/solc-0.8/ProxyImplSetter.sol b/contracts/solc-0.8/ProxyImplSetter.sol index 8014ceb3..83112639 100644 --- a/contracts/solc-0.8/ProxyImplSetter.sol +++ b/contracts/solc-0.8/ProxyImplSetter.sol @@ -2,9 +2,9 @@ pragma solidity >=0.8.0; contract ProxyImplSetter { + address public immutable initialSetter; + address implementation; - // KLUDGE: make this immutable after solc versions get fixed - address public initialSetter; constructor(address _initialSetter) { initialSetter = _initialSetter;