@@ -22,7 +22,6 @@ struct ECDSAValidatorStorage {
2222
2323struct FlexCallData {
2424 uint32 offset;
25- uint32 length;
2625 bytes value;
2726}
2827
@@ -81,16 +80,31 @@ contract MultiChainFlexCallDataValidator is IValidator, IHook {
8180 bytes32 merkleRoot = bytes32 (sig[65 :97 ]);
8281 // if the signature is a dummy signature, then use dummyUserOpHash instead of real userOpHash
8382 if (keccak256 (ecdsaSig) == keccak256 (DUMMY_ECDSA_SIG)) {
84- (bytes32 dummyUserOpHash , bytes32 [] memory proof ) = abi.decode (sig[97 :], (bytes32 , bytes32 []));
83+ (bytes32 dummyUserOpHash , bytes32 [] memory proof , FlexCallData[] memory flexCallData ) =
84+ abi.decode (sig[97 :], (bytes32 , bytes32 [], FlexCallData[]));
85+
86+ if (flexCallData.length > 0 ) {
87+ PackedUserOperation memory _userOp = _toMemoryUserOp (userOp);
88+
89+ _userOp.callData = _replaceCallData (userOp.callData, flexCallData);
90+
91+ // just for proper gas estimation
92+ bytes32 _useless = IEntryPoint (0x0000000071727De22E5E9d8BAf0edAc6f37da032 ).getUserOpHash (_userOp);
93+ }
94+
8595 require (MerkleProofLib.verify (proof, merkleRoot, dummyUserOpHash), "hash is not in proof " );
8696 // otherwise, use real userOpHash
8797 } else {
8898 (bytes32 [] memory proof , FlexCallData[] memory flexCallData ) =
8999 abi.decode (sig[97 :], (bytes32 [], FlexCallData[]));
90- PackedUserOperation memory _userOp = _toMemoryUserOp (userOp);
100+ bytes32 modifiedUserOpHash = userOpHash;
101+ if (flexCallData.length > 0 ) {
102+ PackedUserOperation memory _userOp = _toMemoryUserOp (userOp);
91103
92- _userOp.callData = _replaceCallData (userOp.callData, flexCallData);
93- bytes32 modifiedUserOpHash = IEntryPoint (0x0000000071727De22E5E9d8BAf0edAc6f37da032 ).getUserOpHash (_userOp);
104+ _userOp.callData = _replaceCallData (userOp.callData, flexCallData);
105+ _userOp.paymasterAndData = hex "" ;
106+ modifiedUserOpHash = IEntryPoint (0x0000000071727De22E5E9d8BAf0edAc6f37da032 ).getUserOpHash (_userOp);
107+ }
94108 require (MerkleProofLib.verify (proof, merkleRoot, modifiedUserOpHash), "hash is not in proof " );
95109 }
96110 // simple ecdsa verification
@@ -174,10 +188,10 @@ contract MultiChainFlexCallDataValidator is IValidator, IHook {
174188 bytes memory modifiedCallData = originalCallData;
175189 for (uint256 i = 0 ; i < flexCallDataArray.length ; i++ ) {
176190 FlexCallData memory flexData = flexCallDataArray[i];
177- require (flexData.offset + flexData.length <= originalCallData.length , "FlexCallData out of bounds " );
191+ require (flexData.offset + flexData.value. length <= originalCallData.length , "FlexCallData out of bounds " );
178192 // Should not overwrite the first 4 bytes sig of the callData
179193 require (flexData.offset > 4 , "FlexCallData offset too small " );
180- for (uint256 j = 0 ; j < flexData.length && j < flexData.value.length ; j++ ) {
194+ for (uint256 j = 0 ; j < flexData.value. length && j < flexData.value.length ; j++ ) {
181195 modifiedCallData[flexData.offset + j] = flexData.value[j];
182196 }
183197 }
0 commit comments