@@ -164,13 +164,13 @@ contract MeeK1Validator_SafeAcc_Mode_Test_Fork is MeeK1Validator_Base_Test {
164164 assertEq (erc20.balanceOf (receiver), amountToTransfer * (numOfClones + 1 ));
165165 }
166166
167- /*
168- function test_superTxFlow_safeAcc_mode_1271_and_WithData_success(uint256 numOfObjs) public {
167+ function test_superTxFlow_safeAcc_mode_1271_and_WithData_success ( /*uint256 numOfObjs*/ ) public {
169168 // Test isValidSignature and validateSignatureWithData flows for Safe Account mode
170169 // Similar to the permit mode test but using Safe Account signatures
171170 vm.selectFork (baseSepolia);
172171
173- numOfObjs = bound(numOfObjs, 2, 25);
172+ //numOfObjs = bound(numOfObjs, 2, 25);
173+ uint256 numOfObjs = 8 ;
174174
175175 bytes [] memory meeSigs = new bytes [](numOfObjs);
176176 bytes32 baseHash = keccak256 (abi.encode ("test " ));
@@ -180,38 +180,27 @@ contract MeeK1Validator_SafeAcc_Mode_Test_Fork is MeeK1Validator_Base_Test {
180180 total: numOfObjs,
181181 signers: _getSigners (),
182182 safeAccount: safe,
183- safeTxnCalldata: abi.encodeWithSelector(
184- erc20.transfer.selector,
185- address(orchestrator),
186- 1 ether
187- )
183+ safeTxnCalldata: abi.encodeWithSelector (erc20.transfer.selector , address (orchestrator), 1 ether)
188184 });
189185
190186 // Test both isValidSignature (ERC-1271) and validateSignatureWithData flows
191- for (uint256 i = 0 ; i < numOfObjs; i++) {
187+ for (uint256 i; i < numOfObjs; i++ ) {
192188 bytes32 includedLeafHash = keccak256 (abi.encode (baseHash, i));
193189
194190 if (i % 2 == 0 ) {
195191 // Test validateSignatureWithData (stateless validator interface)
196- // For validateSignatureWithData, we use the raw hash without smart account address
197192 assertTrue (
198193 orchestrator.validateSignatureWithData (
199- includedLeafHash,
200- meeSigs[i],
201- abi.encodePacked(address(safe))
194+ includedLeafHash, meeSigs[i], abi.encodePacked (address (safe))
202195 )
203196 );
204197 } else {
205198 // Test isValidSignature (ERC-1271 interface)
206- // For isValidSignature with Safe Account mode, we need to hash with the smart account address
207- // as per K1MeeValidator line 239-244
208- bytes32 safeHash = keccak256(abi.encodePacked(includedLeafHash, address(orchestrator)));
209- bytes4 result = orchestrator.isValidSignature(safeHash, meeSigs[i]);
199+ bytes4 result = orchestrator.isValidSignature (includedLeafHash, meeSigs[i]);
210200 assertTrue (result == ERC1271_SUCCESS );
211201 }
212202 }
213203 }
214- */
215204
216205 // ================================ UTILS ================================
217206
@@ -342,7 +331,6 @@ contract MeeK1Validator_SafeAcc_Mode_Test_Fork is MeeK1Validator_Base_Test {
342331 return superTxUserOps;
343332 }
344333
345- /*
346334 function _makeSafeAccSuperTxSignatures (
347335 bytes32 baseHash ,
348336 uint256 total ,
@@ -359,14 +347,12 @@ contract MeeK1Validator_SafeAcc_Mode_Test_Fork is MeeK1Validator_Base_Test {
359347
360348 bytes32 [] memory leaves = new bytes32 [](total);
361349
362- // Build leaves with different hashing schemes similar to permit mode
363- for (uint256 i = 0; i < total; i++) {
350+ for (uint256 i; i < total; i++ ) {
364351 if (i % 2 == 0 ) {
365352 // For validateSignatureWithData (even indices)
366353 leaves[i] = keccak256 (abi.encode (baseHash, i));
367354 } else {
368355 // For isValidSignature (odd indices) - hash with smart account address
369- // This mimics the safe hash preparation for ERC-1271
370356 leaves[i] = keccak256 (abi.encodePacked (keccak256 (abi.encode (baseHash, i)), address (orchestrator)));
371357 }
372358 }
@@ -380,6 +366,7 @@ contract MeeK1Validator_SafeAcc_Mode_Test_Fork is MeeK1Validator_Base_Test {
380366 bytes32 domainSeparator = safeAccount.domainSeparator ();
381367
382368 // Create safe txn data
369+ /*
383370 SafeTxnData memory safeTxnData = SafeTxnData({
384371 ogDomainSeparator: domainSeparator,
385372 to: address(erc20),
@@ -394,38 +381,56 @@ contract MeeK1Validator_SafeAcc_Mode_Test_Fork is MeeK1Validator_Base_Test {
394381 nonce: curNonce,
395382 signatures: ""
396383 });
384+ */
397385
398386 // Add the super tx root hash to the data
399- safeTxnData.data = abi.encodePacked(safeTxnData.data, root);
400-
401- // Get safe transaction hash
402- bytes32 safeTxHash = ISafe(safeAccount).getTransactionHash({
403- to: safeTxnData.to,
404- value: safeTxnData.value,
405- data: safeTxnData.data,
406- operation: safeTxnData.operation,
407- safeTxGas: safeTxnData.safeTxGas,
408- baseGas: safeTxnData.baseGas,
409- gasPrice: safeTxnData.gasPrice,
410- gasToken: safeTxnData.gasToken,
411- refundReceiver: safeTxnData.refundReceiver,
412- _nonce: safeTxnData.nonce
413- });
387+ safeTxnCalldata = abi.encodePacked (safeTxnCalldata, root);
414388
415- // Sign with all safe signers
416- for (uint256 i = 0; i < signers.length; i++) {
417- (uint8 v, bytes32 r, bytes32 s) = vm.sign(signers[i].privateKey, safeTxHash);
418- safeTxnData.signatures = abi.encodePacked(safeTxnData.signatures, r, s, v);
389+ bytes memory signatures = "" ;
390+ {
391+ // Get safe transaction hash
392+ bytes32 safeTxHash = ISafe (safeAccount)
393+ .getTransactionHash ({
394+ to: address (erc20),
395+ value: 0 ,
396+ data: safeTxnCalldata,
397+ operation: SafeEnumLib.Operation.Call,
398+ safeTxGas: 0 ,
399+ baseGas: 0 ,
400+ gasPrice: 0 ,
401+ gasToken: address (0 ),
402+ refundReceiver: payable (address (0 )),
403+ _nonce: curNonce
404+ });
405+
406+ // Sign with all safe signers
407+ for (uint256 i = 0 ; i < signers.length ; i++ ) {
408+ (uint8 v , bytes32 r , bytes32 s ) = vm.sign (signers[i].privateKey, safeTxHash);
409+ signatures = abi.encodePacked (signatures, r, s, v);
410+ }
419411 }
420412
421- // Build signatures for each leaf
422- for (uint256 i = 0 ; i < total; i++) {
413+ // Encode signatures for each leaf
414+ for (uint256 i; i < total; i++ ) {
423415 bytes32 [] memory proof = tree.leafProof (i);
424416 bytes memory signature = abi.encodePacked (
425417 SIG_TYPE_SAFE_ACCOUNT,
426418 abi.encode (
427419 DecodedSafeAccountSignatureShort ({
428- safeTxnData: safeTxnData,
420+ safeTxnData: SafeTxnData ({
421+ ogDomainSeparator: domainSeparator,
422+ to: address (erc20),
423+ value: 0 ,
424+ data: safeTxnCalldata,
425+ operation: SafeEnumLib.Operation.Call,
426+ safeTxGas: 0 ,
427+ baseGas: 0 ,
428+ gasPrice: 0 ,
429+ gasToken: address (0 ),
430+ refundReceiver: payable (address (0 )),
431+ nonce: curNonce,
432+ signatures: signatures
433+ }),
429434 proof: proof
430435 })
431436 )
@@ -434,5 +439,4 @@ contract MeeK1Validator_SafeAcc_Mode_Test_Fork is MeeK1Validator_Base_Test {
434439 }
435440 return meeSigs;
436441 }
437- */
438442}
0 commit comments