Skip to content

Commit

Permalink
Merge branch 'main' into ci/add-venom-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pcaversaccio authored Sep 28, 2024
2 parents 66d862a + 1ff03b4 commit 693dc06
Show file tree
Hide file tree
Showing 9 changed files with 174 additions and 134 deletions.
207 changes: 104 additions & 103 deletions .gas-snapshot

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/create-util
2 changes: 1 addition & 1 deletion lib/forge-std
2 changes: 1 addition & 1 deletion lib/halmos-cheatcodes
Submodule halmos-cheatcodes updated 1 files
+6 −6 src/SVM.sol
2 changes: 1 addition & 1 deletion lib/openzeppelin-contracts
Submodule openzeppelin-contracts updated 37 files
+2 −0 contracts/access/Ownable2Step.sol
+2 −2 contracts/finance/VestingWallet.sol
+4 −1 contracts/finance/VestingWalletCliff.sol
+1 −1 contracts/governance/Governor.sol
+2 −0 contracts/governance/extensions/GovernorCountingFractional.sol
+16 −6 contracts/governance/extensions/GovernorStorage.sol
+1 −1 contracts/governance/utils/Votes.sol
+1 −1 contracts/metatx/ERC2771Forwarder.sol
+2 −0 contracts/token/ERC1155/utils/ERC1155Utils.sol
+2 −0 contracts/token/ERC20/extensions/ERC1363.sol
+1 −1 contracts/token/ERC20/extensions/ERC4626.sol
+2 −0 contracts/token/ERC20/extensions/draft-ERC20TemporaryApproval.sol
+2 −0 contracts/token/ERC721/utils/ERC721Utils.sol
+4 −1 contracts/token/common/ERC2981.sol
+5 −0 contracts/utils/Comparators.sol
+2 −0 contracts/utils/Errors.sol
+2 −0 contracts/utils/Packing.sol
+2 −0 contracts/utils/Panic.sol
+4 −0 contracts/utils/README.adoc
+2 −0 contracts/utils/ReentrancyGuardTransient.sol
+2 −0 contracts/utils/SlotDerivation.sol
+10 −3 contracts/utils/cryptography/ECDSA.sol
+2 −0 contracts/utils/cryptography/Hashes.sol
+14 −8 contracts/utils/cryptography/P256.sol
+10 −7 contracts/utils/cryptography/RSA.sol
+30 −6 contracts/utils/structs/Checkpoints.sol
+2 −0 contracts/utils/structs/CircularBuffer.sol
+55 −55 contracts/utils/structs/EnumerableMap.sol
+34 −30 contracts/utils/structs/Heap.sol
+10 −10 contracts/utils/structs/MerkleTree.sol
+6 −3 contracts/utils/types/Time.sol
+1 −1 fv-requirements.txt
+10 −2 scripts/generate/templates/Checkpoints.js
+13 −13 scripts/generate/templates/EnumerableMap.js
+2 −0 scripts/generate/templates/Packing.js
+2 −0 scripts/generate/templates/SlotDerivation.js
+17 −0 test/access/Ownable2Step.test.js
2 changes: 1 addition & 1 deletion lib/solady
36 changes: 18 additions & 18 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 9 additions & 8 deletions src/snekmate/auth/ownable_2step.vy
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,15 @@ def transfer_ownership(new_owner: address):
"""
@dev Starts the ownership transfer of the contract
to a new account `new_owner`.
@notice Note that this function can only be
called by the current `owner`. Also, there is
no security risk in setting `new_owner` to the
zero address as the default value of `pending_owner`
is in fact already the zero address and the zero
address cannot call `accept_ownership`. Eventually,
the function replaces the pending transfer if
there is one.
@notice Note that this function can only be called by
the current `owner`. Importantly, there is no
security risk in assigning `new_owner` to the
zero address, as the default value of `pending_owner`
is already set to the zero address, and the zero
address cannot invoke `accept_ownership`. In fact,
this can serve as a method to cancel an ongoing
ownership transfer. Eventually, the function
replaces the pending transfer if there is one.
@param new_owner The 20-byte address of the new owner.
"""
ownable._check_owner()
Expand Down
38 changes: 38 additions & 0 deletions test/auth/Ownable2Step.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,44 @@ contract Ownable2StepTest is Test {
vm.stopPrank();
}

function testCancelTransferOwnership() public {
address oldOwner = deployer;
address newOwner1 = makeAddr("newOwner1");
address newOwner2 = makeAddr("newOwner2");
vm.startPrank(oldOwner);
assertEq(ownable2Step.pending_owner(), zeroAddress);
vm.expectEmit(true, true, false, false);
emit IOwnable2Step.OwnershipTransferStarted(oldOwner, newOwner1);
ownable2Step.transfer_ownership(newOwner1);
assertEq(ownable2Step.owner(), oldOwner);
assertEq(ownable2Step.pending_owner(), newOwner1);

vm.expectEmit(true, true, false, false);
emit IOwnable2Step.OwnershipTransferStarted(oldOwner, newOwner2);
ownable2Step.transfer_ownership(newOwner2);
assertEq(ownable2Step.owner(), oldOwner);
assertEq(ownable2Step.pending_owner(), newOwner2);
vm.stopPrank();

vm.startPrank(newOwner1);
vm.expectRevert(bytes("ownable_2step: caller is not the new owner"));
ownable2Step.accept_ownership();
vm.stopPrank();

vm.startPrank(oldOwner);
vm.expectEmit(true, true, false, false);
emit IOwnable2Step.OwnershipTransferStarted(oldOwner, zeroAddress);
ownable2Step.transfer_ownership(zeroAddress);
assertEq(ownable2Step.owner(), oldOwner);
assertEq(ownable2Step.pending_owner(), zeroAddress);
vm.stopPrank();

vm.startPrank(newOwner2);
vm.expectRevert(bytes("ownable_2step: caller is not the new owner"));
ownable2Step.accept_ownership();
vm.stopPrank();
}

function testRenounceOwnershipSuccess() public {
address oldOwner = deployer;
address newOwner = zeroAddress;
Expand Down

0 comments on commit 693dc06

Please sign in to comment.