Skip to content

Commit

Permalink
fix applyChange2FA operation did not check whether pending2FAAddr exi…
Browse files Browse the repository at this point in the history
…sted
  • Loading branch information
CodeExplorer29 committed Jun 1, 2024
1 parent 4213c37 commit b70cdec
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion contracts/hooks/2fa/Crypto2FAHook.sol
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ contract Crypto2FAHook is IHook {

function applyChange2FA() external {
User2FA storage _user2fa = user2FA[msg.sender];
require(block.timestamp >= _user2fa.effectiveTime, "Time lock not expired");
require(_user2fa.pending2FAAddr != address(0), "No pending change");
require(_user2fa.effectiveTime > 0 && block.timestamp >= _user2fa.effectiveTime, "Time lock not expired");
_user2fa.wallet2FAAddr = _user2fa.pending2FAAddr;
_user2fa.pending2FAAddr = address(0);
_user2fa.effectiveTime = 0;
Expand Down
6 changes: 6 additions & 0 deletions test/hooks/2fa/Crypto2FAHook.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,10 @@ contract Crypto2FAHookTest is Test, UserOpHelper {
ops[0] = userOperation;
soulWalletInstence.entryPoint().handleOps(ops, payable(walletOwner));
}

function test_applyChange2faWithoutInitiateChange2FA() public {
vm.startPrank(address(soulWallet));
vm.expectRevert("No pending change");
crypto2FAHook.applyChange2FA();
}
}

0 comments on commit b70cdec

Please sign in to comment.