Skip to content

Commit

Permalink
Update events
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnGuilding committed May 31, 2024
1 parent 94bb06a commit 314e33b
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 11 deletions.
12 changes: 9 additions & 3 deletions src/ZkEmailRecovery.sol
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,10 @@ contract ZkEmailRecovery is EmailAccountRecovery, IZkEmailRecovery {
}

recoveryConfigs[account] = recoveryConfig;

emit RecoveryConfigUpdated(
account, recoveryConfig.recoveryModule, recoveryConfig.delay, recoveryConfig.expiry
);
}

/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
Expand Down Expand Up @@ -374,6 +378,8 @@ contract ZkEmailRecovery is EmailAccountRecovery, IZkEmailRecovery {
key: guardian,
value: GuardianStorage(GuardianStatus.ACCEPTED, guardianStorage.weight)
});

emit GuardianAccepted(accountInEmail, guardian);
}

/**
Expand Down Expand Up @@ -715,7 +721,7 @@ contract ZkEmailRecovery is EmailAccountRecovery, IZkEmailRecovery {
guardianConfigs[account].guardianCount++;
guardianConfigs[account].totalWeight += weight;

emit AddedGuardian(guardian);
emit AddedGuardian(account, guardian);

// Change threshold if threshold was changed.
if (guardianConfigs[account].threshold != threshold) {
Expand Down Expand Up @@ -751,7 +757,7 @@ contract ZkEmailRecovery is EmailAccountRecovery, IZkEmailRecovery {
guardianConfigs[account].guardianCount--;
guardianConfigs[account].totalWeight -= guardianStorage.weight;

emit RemovedGuardian(guardian);
emit RemovedGuardian(account, guardian);

// Change threshold if threshold was changed.
if (guardianConfig.threshold != threshold) {
Expand Down Expand Up @@ -784,7 +790,7 @@ contract ZkEmailRecovery is EmailAccountRecovery, IZkEmailRecovery {
}

guardianConfigs[account].threshold = threshold;
emit ChangedThreshold(threshold);
emit ChangedThreshold(account, threshold);
}

/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
Expand Down
10 changes: 7 additions & 3 deletions src/interfaces/IZkEmailRecovery.sol
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ interface IZkEmailRecovery {
uint256 guardianCount,
address router
);
event RecoveryConfigUpdated(
address indexed account, address indexed recoveryModule, uint256 delay, uint256 expiry
);
event GuardianAccepted(address indexed account, address indexed guardian);
event RecoveryDeInitialized(address indexed account);
event RecoveryProcessed(address indexed account, uint256 executeAfter, uint256 executeBefore);
event RecoveryCompleted(address indexed account);
Expand All @@ -66,9 +70,9 @@ interface IZkEmailRecovery {
/**
* Guardian logic events
*/
event AddedGuardian(address indexed guardian);
event RemovedGuardian(address indexed guardian);
event ChangedThreshold(uint256 threshold);
event AddedGuardian(address indexed account, address indexed guardian);
event RemovedGuardian(address indexed account, address indexed guardian);
event ChangedThreshold(address indexed account, uint256 threshold);

/*//////////////////////////////////////////////////////////////////////////
ERRORS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ abstract contract OwnableValidatorBase is IntegrationBase {
// console2.log("recoveryModule: ", recoveryModule);

string memory subject =
"Recover account 0x19F55F3fE4c8915F21cc92852CD8E924998fDa38 to new owner 0x7240b687730BE024bcfD084621f794C2e4F8408f using recovery module 0x0f15Be86db5066E895ad53d3b5551251f773b6C0";
"Recover account 0x19F55F3fE4c8915F21cc92852CD8E924998fDa38 to new owner 0x7240b687730BE024bcfD084621f794C2e4F8408f using recovery module 0xE98A1D4388fb2354016e56bFDb8dA7c55cDdae98";
address router = zkEmailRecovery.getRouterForAccount(accountAddress);
bytes32 nullifier = keccak256(abi.encode("nullifier 2"));
uint256 templateIdx = 0;
Expand Down
2 changes: 1 addition & 1 deletion test/unit/UnitBase.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ abstract contract UnitBase is RhinestoneModuleKit, Test {

address router = zkEmailRecovery.getRouterForAccount(accountAddress);
string memory subject =
"Recover account 0x50Bc6f1F08ff752F7F5d687F35a0fA25Ab20EF52 to new owner 0x7240b687730BE024bcfD084621f794C2e4F8408f using recovery module 0x50b1420c451700E5D73B28eC40e4cfAE20B9C58e";
"Recover account 0x50Bc6f1F08ff752F7F5d687F35a0fA25Ab20EF52 to new owner 0x7240b687730BE024bcfD084621f794C2e4F8408f using recovery module 0x0957519DC28b1d289F4721244416C3F00033747c";
bytes32 nullifier = keccak256(abi.encode("nullifier 2"));
EmailProof memory emailProof = generateMockEmailProof(subject, nullifier, accountSalt);

Expand Down
2 changes: 1 addition & 1 deletion test/unit/ZkEmailRecovery/addGuardian.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ contract ZkEmailRecovery_addGuardian_Test is UnitBase {
vm.startPrank(accountAddress);

vm.expectEmit();
emit IZkEmailRecovery.AddedGuardian(newGuardian);
emit IZkEmailRecovery.AddedGuardian(accountAddress, newGuardian);
zkEmailRecovery.addGuardian(newGuardian, newGuardianWeight, threshold);

GuardianStorage memory guardianStorage =
Expand Down
4 changes: 2 additions & 2 deletions test/unit/ZkEmailRecovery/changeThreshold.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ contract ZkEmailRecovery_changeThreshold_Test is UnitBase {

vm.startPrank(accountAddress);
vm.expectEmit();
emit IZkEmailRecovery.ChangedThreshold(newThreshold);
emit IZkEmailRecovery.ChangedThreshold(accountAddress, newThreshold);
zkEmailRecovery.changeThreshold(newThreshold);

IZkEmailRecovery.GuardianConfig memory guardianConfig =
Expand All @@ -88,7 +88,7 @@ contract ZkEmailRecovery_changeThreshold_Test is UnitBase {

vm.startPrank(accountAddress);
vm.expectEmit();
emit IZkEmailRecovery.ChangedThreshold(newThreshold);
emit IZkEmailRecovery.ChangedThreshold(accountAddress, newThreshold);
zkEmailRecovery.changeThreshold(newThreshold);

IZkEmailRecovery.GuardianConfig memory guardianConfig =
Expand Down

0 comments on commit 314e33b

Please sign in to comment.