@@ -93,6 +93,24 @@ def eip712Domain() -> (
9393 )
9494
9595
96+ @view
97+ def _DOMAIN_SEPARATOR () -> bytes32 :
98+ return keccak256 (
99+ abi_encode (EIP712_DOMAIN_TYPEHASH, NAMEHASH, VERSIONHASH, chain.id, self )
100+ )
101+
102+
103+ @view
104+ @external
105+ def DOMAIN_SEPARATOR () -> bytes32 :
106+ return self ._DOMAIN_SEPARATOR ()
107+
108+
109+ @view
110+ def _hash_typed_data_v4 (struct_hash: bytes32 ) -> bytes32 :
111+ return keccak256 (concat (x"1901 " , self ._DOMAIN_SEPARATOR (), struct_hash))
112+
113+
96114@external
97115def initialize (signers: DynArray[address , 11 ], threshold: uint256 ):
98116 assert self .IMPLEMENTATION != empty (address ) # dev: only Proxy can initialize
@@ -102,6 +120,23 @@ def initialize(signers: DynArray[address, 11], threshold: uint256):
102120 self ._signers = signers
103121 self .threshold = threshold
104122
123+ # NOTE: Initialize head to non-zero, network-specific value as if this action was performed
124+ self .head = self ._hash_typed_data_v4 (
125+ keccak256 (
126+ abi_encode (
127+ MODIFY_TYPEHASH,
128+ empty (bytes32 ),
129+ ICaravan.ActionType.ROTATE_SIGNERS,
130+ # NOTE: Per EIP712, Dynamic structures are encoded as the hash of their contents
131+ keccak256 (
132+ abi_encode (
133+ signers, empty (DynArray[address , 11 ]), threshold
134+ )
135+ ),
136+ )
137+ )
138+ )
139+
105140
106141@view
107142@external
@@ -148,24 +183,6 @@ def _verify_signatures(msghash: bytes32, signatures: DynArray[Bytes[65], 11]):
148183 already_approved.append (signer)
149184
150185
151- @view
152- def _DOMAIN_SEPARATOR () -> bytes32 :
153- return keccak256 (
154- abi_encode (EIP712_DOMAIN_TYPEHASH, NAMEHASH, VERSIONHASH, chain.id, self )
155- )
156-
157-
158- @view
159- @external
160- def DOMAIN_SEPARATOR () -> bytes32 :
161- return self ._DOMAIN_SEPARATOR ()
162-
163-
164- @view
165- def _hash_typed_data_v4 (struct_hash: bytes32 ) -> bytes32 :
166- return keccak256 (concat (x"1901 " , self ._DOMAIN_SEPARATOR (), struct_hash))
167-
168-
169186def _rotate_signers (
170187 signers_to_add: DynArray[address , 11 ],
171188 signers_to_rm: DynArray[address , 11 ],
0 commit comments