@@ -567,4 +567,61 @@ contract SimpleAccountTest is BaseTest {
567567
568568 assertEq (erc1155.balanceOf (account, 0 ), 1 );
569569 }
570+
571+ /*///////////////////////////////////////////////////////////////
572+ Test: setting contract metadata
573+ //////////////////////////////////////////////////////////////*/
574+
575+ /// @dev Set contract metadata via admin or entrypoint.
576+ function test_state_contractMetadata () public {
577+ _setup_executeTransaction ();
578+ address account = accountFactory.getAddress (accountAdmin, bytes ("" ));
579+
580+ vm.prank (accountAdmin);
581+ SimpleAccount (payable (account)).setContractURI ("https://example.com " );
582+ assertEq (SimpleAccount (payable (account)).contractURI (), "https://example.com " );
583+
584+ UserOperation[] memory userOp = _setupUserOpExecute (
585+ accountAdminPKey,
586+ bytes ("" ),
587+ address (account),
588+ 0 ,
589+ abi.encodeWithSignature ("setContractURI(string) " , "https://thirdweb.com " )
590+ );
591+
592+ EntryPoint (entrypoint).handleOps (userOp, beneficiary);
593+ assertEq (SimpleAccount (payable (account)).contractURI (), "https://thirdweb.com " );
594+
595+ address [] memory targets = new address [](0 );
596+ uint256 [] memory values = new uint256 [](0 );
597+ bytes [] memory callData = new bytes [](0 );
598+
599+ address [] memory approvedTargets = new address [](0 );
600+
601+ IAccountPermissions.SignerPermissionRequest memory permissionsReq = IAccountPermissions.SignerPermissionRequest (
602+ accountSigner,
603+ approvedTargets,
604+ 1 ether,
605+ 0 ,
606+ type (uint128 ).max,
607+ 0 ,
608+ type (uint128 ).max,
609+ uidCache
610+ );
611+
612+ vm.prank (accountAdmin);
613+ bytes memory sig = _signSignerPermissionRequest (permissionsReq);
614+ SimpleAccount (payable (account)).setPermissionsForSigner (permissionsReq, sig);
615+
616+ UserOperation[] memory userOpViaSigner = _setupUserOpExecute (
617+ accountSignerPKey,
618+ bytes ("" ),
619+ address (account),
620+ 0 ,
621+ abi.encodeWithSignature ("setContractURI(string) " , "https://thirdweb.com " )
622+ );
623+
624+ vm.expectRevert ();
625+ EntryPoint (entrypoint).handleOps (userOpViaSigner, beneficiary);
626+ }
570627}
0 commit comments