@@ -56,13 +56,13 @@ contract SimpleAccountTest is BaseTest {
5656
5757 event AccountCreated (address indexed account , address indexed accountAdmin );
5858
59- function _signSignerPermissionRequest (IAccountPermissions.SignerPermissionRequest memory _req )
59+ function _prepareSignature (IAccountPermissions.SignerPermissionRequest memory _req )
6060 internal
6161 view
62- returns (bytes memory signature )
62+ returns (bytes32 typedDataHash )
6363 {
6464 bytes32 typehashSignerPermissionRequest = keccak256 (
65- "SignerPermissionRequest(address signer,address[] approvedTargets,uint256 nativeTokenLimitPerTransaction,uint128 permissionStartTimestamp,uint128 permissionEndTimestamp,uint128 reqValidityStartTimestamp,uint128 reqValidityEndTimestamp,bytes32 uid) "
65+ "SignerPermissionRequest(address signer,uint8 isAdmin, address[] approvedTargets,uint256 nativeTokenLimitPerTransaction,uint128 permissionStartTimestamp,uint128 permissionEndTimestamp,uint128 reqValidityStartTimestamp,uint128 reqValidityEndTimestamp,bytes32 uid) "
6666 );
6767 bytes32 nameHash = keccak256 (bytes ("Account " ));
6868 bytes32 versionHash = keccak256 (bytes ("1 " ));
@@ -71,20 +71,32 @@ contract SimpleAccountTest is BaseTest {
7171 );
7272 bytes32 domainSeparator = keccak256 (abi.encode (typehashEip712, nameHash, versionHash, block .chainid , sender));
7373
74- bytes memory encodedRequest = abi.encode (
74+ bytes memory encodedRequestStart = abi.encode (
7575 typehashSignerPermissionRequest,
7676 _req.signer,
77+ _req.isAdmin,
7778 keccak256 (abi.encodePacked (_req.approvedTargets)),
78- _req.nativeTokenLimitPerTransaction,
79+ _req.nativeTokenLimitPerTransaction
80+ );
81+
82+ bytes memory encodedRequestEnd = abi.encode (
7983 _req.permissionStartTimestamp,
8084 _req.permissionEndTimestamp,
8185 _req.reqValidityStartTimestamp,
8286 _req.reqValidityEndTimestamp,
8387 _req.uid
8488 );
85- bytes32 structHash = keccak256 (encodedRequest);
86- bytes32 typedDataHash = keccak256 (abi.encodePacked ("\x19\x01 " , domainSeparator, structHash));
8789
90+ bytes32 structHash = keccak256 (bytes .concat (encodedRequestStart, encodedRequestEnd));
91+ typedDataHash = keccak256 (abi.encodePacked ("\x19\x01 " , domainSeparator, structHash));
92+ }
93+
94+ function _signSignerPermissionRequest (IAccountPermissions.SignerPermissionRequest memory _req )
95+ internal
96+ view
97+ returns (bytes memory signature )
98+ {
99+ bytes32 typedDataHash = _prepareSignature (_req);
88100 (uint8 v , bytes32 r , bytes32 s ) = vm.sign (accountAdminPKey, typedDataHash);
89101 signature = abi.encodePacked (r, s, v);
90102 }
@@ -360,14 +372,14 @@ contract SimpleAccountTest is BaseTest {
360372
361373 IAccountPermissions.SignerPermissionRequest memory permissionsReq = IAccountPermissions.SignerPermissionRequest (
362374 accountSigner,
375+ 0 ,
363376 approvedTargets,
364377 1 ether,
365378 0 ,
366379 type (uint128 ).max,
367380 0 ,
368381 type (uint128 ).max,
369- uidCache,
370- 0
382+ uidCache
371383 );
372384
373385 vm.prank (accountAdmin);
@@ -398,14 +410,14 @@ contract SimpleAccountTest is BaseTest {
398410
399411 IAccountPermissions.SignerPermissionRequest memory permissionsReq = IAccountPermissions.SignerPermissionRequest (
400412 accountSigner,
413+ 0 ,
401414 approvedTargets,
402415 1 ether,
403416 0 ,
404417 type (uint128 ).max,
405418 0 ,
406419 type (uint128 ).max,
407- uidCache,
408- 0
420+ uidCache
409421 );
410422
411423 vm.prank (accountAdmin);
@@ -454,14 +466,14 @@ contract SimpleAccountTest is BaseTest {
454466 approvedTargets[0 ] = address (numberContract);
455467 IAccountPermissions.SignerPermissionRequest memory permissionsReq = IAccountPermissions.SignerPermissionRequest (
456468 accountSigner,
469+ 0 ,
457470 approvedTargets,
458471 1 ether,
459472 0 ,
460473 type (uint128 ).max,
461474 0 ,
462475 type (uint128 ).max,
463- uidCache,
464- 0
476+ uidCache
465477 );
466478
467479 vm.prank (accountAdmin);
@@ -603,14 +615,14 @@ contract SimpleAccountTest is BaseTest {
603615
604616 IAccountPermissions.SignerPermissionRequest memory permissionsReq = IAccountPermissions.SignerPermissionRequest (
605617 accountSigner,
618+ 0 ,
606619 approvedTargets,
607620 1 ether,
608621 0 ,
609622 type (uint128 ).max,
610623 0 ,
611624 type (uint128 ).max,
612- uidCache,
613- 0
625+ uidCache
614626 );
615627
616628 vm.prank (accountAdmin);
0 commit comments