Skip to content

Commit

Permalink
Fix build warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnGuilding committed Jun 20, 2024
1 parent 4775e76 commit e377bb5
Show file tree
Hide file tree
Showing 24 changed files with 90 additions and 59 deletions.
2 changes: 0 additions & 2 deletions script/DeploySafeRecovery.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import { EmailRecoveryModule } from "src/modules/EmailRecoveryModule.sol";

contract DeploySafeRecoveryScript is Script {
function run() public {
bytes32 salt = bytes32(uint256(0));

address verifier = 0xEdC642bbaD91E21cCE6cd436Fdc6F040FD0fF998;
address dkimRegistry = 0xC83256CCf7B94d310e49edA05077899ca036eb78;
address emailAuthImpl = 0x1C76Aa365c17B40c7E944DcCdE4dC6e6D2A7b748;
Expand Down
8 changes: 4 additions & 4 deletions src/handlers/EmailRecoverySubjectHandler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ contract EmailRecoverySubjectHandler is IEmailRecoverySubjectHandler {

function extractRecoveredAccountFromAcceptanceSubject(
bytes[] memory subjectParams,
uint256 templateIdx
uint256 /* templateIdx */
)
public
pure
Expand All @@ -57,7 +57,7 @@ contract EmailRecoverySubjectHandler is IEmailRecoverySubjectHandler {

function extractRecoveredAccountFromRecoverySubject(
bytes[] memory subjectParams,
uint256 templateIdx
uint256 /* templateIdx */
)
public
pure
Expand All @@ -67,7 +67,7 @@ contract EmailRecoverySubjectHandler is IEmailRecoverySubjectHandler {
}

function validateAcceptanceSubject(
uint256 templateIdx,
uint256, /* templateIdx */
bytes[] calldata subjectParams
)
external
Expand All @@ -84,7 +84,7 @@ contract EmailRecoverySubjectHandler is IEmailRecoverySubjectHandler {
}

function validateRecoverySubject(
uint256 templateIdx,
uint256, /* templateIdx */
bytes[] calldata subjectParams,
address recoveryManager
)
Expand Down
12 changes: 6 additions & 6 deletions src/handlers/SafeRecoverySubjectHandler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -55,28 +55,28 @@ contract SafeRecoverySubjectHandler is IEmailRecoverySubjectHandler {

function extractRecoveredAccountFromAcceptanceSubject(
bytes[] memory subjectParams,
uint256 templateIdx
uint256 /* templateIdx */
)
public
view
pure
returns (address)
{
return abi.decode(subjectParams[0], (address));
}

function extractRecoveredAccountFromRecoverySubject(
bytes[] memory subjectParams,
uint256 templateIdx
uint256 /* templateIdx */
)
public
view
pure
returns (address)
{
return abi.decode(subjectParams[0], (address));
}

function validateAcceptanceSubject(
uint256 templateIdx,
uint256, /* templateIdx */
bytes[] calldata subjectParams
)
external
Expand All @@ -93,7 +93,7 @@ contract SafeRecoverySubjectHandler is IEmailRecoverySubjectHandler {
}

function validateRecoverySubject(
uint256 templateIdx,
uint256, /* templateIdx */
bytes[] calldata subjectParams,
address recoveryManager
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,13 @@ abstract contract OwnableValidatorRecoveryBase is IntegrationBase {

function handleRecovery(
address recoveryModule,
bytes32 calldataHash,
bytes32 recoveryCalldataHash,
bytes32 accountSalt
)
public
{
string memory accountString = SubjectUtils.addressToChecksumHexString(accountAddress);
string memory calldataHashString = uint256(calldataHash).toHexString(32);
string memory calldataHashString = uint256(recoveryCalldataHash).toHexString(32);
string memory recoveryModuleString = SubjectUtils.addressToChecksumHexString(recoveryModule);

string memory subjectPart1 = string.concat("Recover account ", accountString);
Expand Down
4 changes: 3 additions & 1 deletion test/unit/EmailRecoveryFactory/deployModuleAndManager.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ contract EmailRecoveryManager_deployModuleAndManager_Test is UnitBase {
super.setUp();
}

function test_DeployModuleAndManager_Succeeds() public { }
function test_DeployModuleAndManager_Succeeds() public {
// TODO: test
}
}
2 changes: 1 addition & 1 deletion test/unit/EmailRecoveryManager/constructor.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ contract EmailRecoveryManager_constructor_Test is UnitBase {
function test_Constructor_RevertWhen_InvalidSubjectHandler() public {
address invalidHandler = address(0);
vm.expectRevert(IEmailRecoveryManager.InvalidSubjectHandler.selector);
EmailRecoveryManager emailRecoveryManager = new EmailRecoveryManager(
new EmailRecoveryManager(
address(verifier), address(dkimRegistry), address(emailAuthImpl), invalidHandler
);
}
Expand Down
4 changes: 3 additions & 1 deletion test/unit/EmailRecoveryManager/getGuardian.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ contract EmailRecoveryManager_getGuardian_Test is UnitBase {
super.setUp();
}

function test_GetGuardian_Succeeds() public { }
function test_GetGuardian_Succeeds() public {
// TODO: test
}
}
4 changes: 3 additions & 1 deletion test/unit/EmailRecoveryManager/getGuardianConfig.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ contract EmailRecoveryManager_getGuardianConfig_Test is UnitBase {
super.setUp();
}

function test_GetGuardianConfig_Succeeds() public { }
function test_GetGuardianConfig_Succeeds() public {
// TODO: test
}
}
4 changes: 3 additions & 1 deletion test/unit/EmailRecoveryManager/getRecoveryConfig.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ contract EmailRecoveryManager_getRecoveryConfig_Test is UnitBase {
super.setUp();
}

function test_GetRecoveryConfig_Succeeds() public { }
function test_GetRecoveryConfig_Succeeds() public {
// TODO: test
}
}
4 changes: 3 additions & 1 deletion test/unit/EmailRecoveryManager/getRecoveryRequest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ contract EmailRecoveryManager_getRecoveryRequest_Test is UnitBase {
super.setUp();
}

function test_GetRecoveryRequest_Succeeds() public { }
function test_GetRecoveryRequest_Succeeds() public {
// TODO: test
}
}
1 change: 0 additions & 1 deletion test/unit/EmailRecoveryManager/updateRecoveryConfig.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ contract EmailRecoveryManager_updateRecoveryConfig_Test is UnitBase {
}

function test_UpdateRecoveryConfig_Succeeds() public {
address newRecoveryModule = recoveryModuleAddress;
uint256 newDelay = 1 days;
uint256 newExpiry = 4 weeks;

Expand Down
2 changes: 2 additions & 0 deletions test/unit/EmailRecoveryModuleHarness.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ contract EmailRecoveryModuleHarness is EmailRecoveryModule {
address account
)
external
view
returns (bytes4)
{
return allowedSelectors[validator][account];
Expand All @@ -25,6 +26,7 @@ contract EmailRecoveryModuleHarness is EmailRecoveryModule {
address account
)
external
view
returns (address)
{
return selectorToValidator[selector][account];
Expand Down
1 change: 1 addition & 0 deletions test/unit/SafeRecoverySubjectHandlerHarness.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ contract SafeRecoverySubjectHandlerHarness is SafeRecoverySubjectHandler {
address oldOwner
)
external
view
returns (address)
{
return getPreviousOwnerInLinkedList(safe, oldOwner);
Expand Down
29 changes: 12 additions & 17 deletions test/unit/SafeUnitBase.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { MockValidator } from "module-bases/mocks/MockValidator.sol";
import { EmailAuthMsg, EmailProof } from "ether-email-auth/packages/contracts/src/EmailAuth.sol";
import { SubjectUtils } from "ether-email-auth/packages/contracts/src/libraries/SubjectUtils.sol";
import { Solarray } from "solarray/Solarray.sol";
import { Strings } from "@openzeppelin/contracts/utils/Strings.sol";

import { EmailRecoveryManagerHarness } from "./EmailRecoveryManagerHarness.sol";
import { EmailRecoveryManager } from "src/EmailRecoveryManager.sol";
Expand All @@ -33,6 +34,8 @@ import { MockRegistry } from "../integration/external/MockRegistry.sol";
import { IntegrationBase } from "../integration/IntegrationBase.t.sol";

abstract contract SafeUnitBase is IntegrationBase {
using Strings for uint256;

EmailRecoveryFactory emailRecoveryFactory;
SafeRecoverySubjectHandlerHarness safeRecoverySubjectHandler;
EmailRecoveryManager emailRecoveryManager;
Expand Down Expand Up @@ -276,27 +279,19 @@ abstract contract SafeUnitBase is IntegrationBase {

function handleRecovery(
address recoveryModule,
bytes32 calldataHash,
bytes32 recoveryCalldataHash,
bytes32 accountSalt
)
public
{
// Uncomment if getting "invalid subject" errors. Sometimes the subject needs updating
// after
// certain changes
// console2.log("accountAddress: ", accountAddress);
console2.log("recoveryModule: ", recoveryModule);
console2.log("calldataHash:");
console2.logBytes32(calldataHash);

// TODO: Ideally do this dynamically
string memory calldataHashString =
"0x4e66542ab78fcc7a2341586b67800e82b975078517d7d692e2aa98d2696c51d0";

string memory subject = string.concat(
"Recover account 0xE760ccaE42b4EA7a93A4CfA75BC649aaE1033095 via recovery module 0xD7F74A3A1d35495c1537f5377590e44A2bf44122 using recovery hash ",
calldataHashString
);
string memory accountString = SubjectUtils.addressToChecksumHexString(accountAddress);
string memory calldataHashString = uint256(recoveryCalldataHash).toHexString(32);
string memory recoveryModuleString = SubjectUtils.addressToChecksumHexString(recoveryModule);

string memory subjectPart1 = string.concat("Recover account ", accountString);
string memory subjectPart2 = string.concat(" via recovery module ", recoveryModuleString);
string memory subjectPart3 = string.concat(" using recovery hash ", calldataHashString);
string memory subject = string.concat(subjectPart1, subjectPart2, subjectPart3);
bytes32 nullifier = keccak256(abi.encode("nullifier 2"));
uint256 templateIdx = 0;

Expand Down
4 changes: 2 additions & 2 deletions test/unit/UnitBase.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -263,13 +263,13 @@ abstract contract UnitBase is RhinestoneModuleKit, Test {

function handleRecovery(
address recoveryModule,
bytes32 calldataHash,
bytes32 recoveryCalldataHash,
bytes32 accountSalt
)
public
{
string memory accountString = SubjectUtils.addressToChecksumHexString(accountAddress);
string memory calldataHashString = uint256(calldataHash).toHexString(32);
string memory calldataHashString = uint256(recoveryCalldataHash).toHexString(32);
string memory recoveryModuleString = SubjectUtils.addressToChecksumHexString(recoveryModule);

string memory subjectPart1 = string.concat("Recover account ", accountString);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,11 @@ contract EmailRecoverySubjectHandler_validateRecoverySubject_Test is UnitBase {
);
}

function test_ValidateRecoverySubject_Succeeds() public {
function test_ValidateRecoverySubject_Succeeds() public view {
(address account, string memory calldataHash) = emailRecoveryHandler.validateRecoverySubject(
templateIdx, subjectParams, emailRecoveryManagerAddress
);
assertEq(account, accountAddress);
assertEq(calldataHashString, calldataHash);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ contract SafeRecoverySubjectHandler_getPreviousOwnerInLinkedList_Test is SafeUni
super.setUp();
}

function test_GetPreviousOwnerInLinkedList_InvalidOwner_ReturnsSentinel() public {
function test_GetPreviousOwnerInLinkedList_InvalidOwner_ReturnsSentinel() public view {
address invalidOwner = address(0);

address previousOwner = safeRecoverySubjectHandler.exposed_getPreviousOwnerInLinkedList(
Expand All @@ -21,7 +21,7 @@ contract SafeRecoverySubjectHandler_getPreviousOwnerInLinkedList_Test is SafeUni
assertEq(previousOwner, SENTINEL_OWNERS);
}

function test_GetPreviousOwnerInLinkedList_OwnerIsSentinel_ReturnsSentinel() public {
function test_GetPreviousOwnerInLinkedList_OwnerIsSentinel_ReturnsSentinel() public view {
address invalidOwner = SENTINEL_OWNERS;

address previousOwner = safeRecoverySubjectHandler.exposed_getPreviousOwnerInLinkedList(
Expand All @@ -38,13 +38,15 @@ contract SafeRecoverySubjectHandler_getPreviousOwnerInLinkedList_Test is SafeUni
safeRecoverySubjectHandler.exposed_getPreviousOwnerInLinkedList(invalidAccount, owner);
}

function test_GetPreviousOwnerInLinkedList_Succeeds() public {
function test_GetPreviousOwnerInLinkedList_Succeeds() public view {
address expectedPreviousOwner = address(1);
address previousOwner =
safeRecoverySubjectHandler.exposed_getPreviousOwnerInLinkedList(accountAddress, owner);

assertEq(expectedPreviousOwner, previousOwner);
}

function test_GetPreviousOwnerInLinkedList_SucceedsWithMultipleAccounts() public { }
function test_GetPreviousOwnerInLinkedList_SucceedsWithMultipleAccounts() public {
// TODO: test
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ contract SafeRecoverySubjectHandler_validateRecoverySubject_Test is SafeUnitBase
);
}

function test_ValidateRecoverySubject_Succeeds() public {
function test_ValidateRecoverySubject_Succeeds() public view {
(address account, string memory calldataHash) = safeRecoverySubjectHandler
.validateRecoverySubject(templateIdx, subjectParams, emailRecoveryManagerAddress);
assertEq(account, accountAddress);
Expand Down
8 changes: 6 additions & 2 deletions test/unit/libraries/EnumerableGuardianMap/get.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ contract EnumerableGuardianMap_get_Test is UnitBase {
super.setUp();
}

function test_Get_GetsExistingValue() public view { }
function test_Get_GetsNonExistentValue() public view { }
function test_Get_GetsExistingValue() public view {
// TODO: test
}
function test_Get_GetsNonExistentValue() public view {
// TODO: test
}
}
16 changes: 12 additions & 4 deletions test/unit/libraries/EnumerableGuardianMap/keys.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,16 @@ contract EnumerableGuardianMap_keys_Test is UnitBase {
super.setUp();
}

function test_Keys_StartsEmpty() public view { }
function test_Keys_ReturnsEmptyArrayOfKeys() public view { }
function test_Keys_ReturnsArrayOfKeys() public view { }
function test_Keys_ReturnMaxArrayOfKeys() public view { }
function test_Keys_StartsEmpty() public view {
// TODO: test
}
function test_Keys_ReturnsEmptyArrayOfKeys() public view {
// TODO: test
}
function test_Keys_ReturnsArrayOfKeys() public view {
// TODO: test
}
function test_Keys_ReturnMaxArrayOfKeys() public view {
// TODO: test
}
}
8 changes: 6 additions & 2 deletions test/unit/libraries/EnumerableGuardianMap/remove.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ contract EnumerableGuardianMap_remove_Test is UnitBase {
super.setUp();
}

function test_Remove_ReturnsFalseWhenRemovingKeysNotInTheSet() public view { }
function test_Remove_RemovesAddedKeys() public view { }
function test_Remove_ReturnsFalseWhenRemovingKeysNotInTheSet() public view {
// TODO: test
}
function test_Remove_RemovesAddedKeys() public view {
// TODO: test
}
}
13 changes: 10 additions & 3 deletions test/unit/libraries/EnumerableGuardianMap/removeAll.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@ contract EnumerableGuardianMap_removeAll_Test is UnitBase {
super.setUp();
}

function test_RemoveAll_RevertWhen_TooManyValuesToRemove() public view { }
function test_RemoveAll_Succeeds() public view { }
function test_RemoveAll_RemovesMaxNumberOfValues() public view { }
function test_RemoveAll_RevertWhen_TooManyValuesToRemove() public view {
// TODO: test
}

function test_RemoveAll_Succeeds() public view {
// TODO: test
}
function test_RemoveAll_RemovesMaxNumberOfValues() public view {
// TODO: test
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ contract EmailRecoveryModule_getAllowedSelectors_Test is UnitBase {
super.setUp();
}

function test_GetAllowedSelectors_Succeeds() public {
function test_GetAllowedSelectors_Succeeds() public view {
bytes4[] memory allowedSelectors = emailRecoveryModule.getAllowedSelectors(accountAddress);

assertEq(allowedSelectors.length, 1);
Expand Down
Loading

0 comments on commit e377bb5

Please sign in to comment.