• Mark Tyneway's avatar
    contracts-bedrock: bump oz to latest release (#3308) · cdf2163e
    Mark Tyneway authored
    This bumps the open zeppelin contracts used in bedrock to the
    latest release. This bump is happening because `Ownable` becomes
    more flexible, allowing you to overwrite the logic for `onlyOwner`.
    This would enable writing a `CrossDomainOwnable` contract like so:
    
    ```solidity
    // SPDX-License-Identifier: MIT
    pragma solidity 0.8.15;
    
    import { AddressAliasHelper } from "../vendor/AddressAliasHelper.sol";
    import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
    
    abstract contract CrossDomainOwnable is Ownable {
        /**
         * @dev Throws if the sender is not the owner.
         */
        function _checkOwner() internal view {
            address sender = AddressAliasHelper.undoL1ToL2Alias(msg.sender);
            require(owner() == sender, "Ownable: caller is not the owner");
        }
    }
    ```
    
    The main diff to the `Ownable` contract is that is now looks like this:
    
    ```solidity
        /**
         * @dev Throws if called by any account other than the owner.
         */
        modifier onlyOwner() {
            _checkOwner();
            _;
        }
    
        /**
         * @dev Returns the address of the current owner.
         */
        function owner() public view virtual returns (address) {
            return _owner;
        }
    
        /**
         * @dev Throws if the sender is not the owner.
         */
        function _checkOwner() internal view virtual {
            require(owner() == _msgSender(), "Ownable: caller is not the owner");
        }
    ```
    
    The older version of the contracts doesn't have the `virtual`
    `_checkOwner` function. This does add some additional gas overhead
    as seen in the `.gas-snapshot`.
    cdf2163e
Name
Last commit
Last update
..
README.md Loading commit data...
big-ways-push.md Loading commit data...
breezy-wasps-applaud.md Loading commit data...
config.json Loading commit data...
curvy-chefs-relax.md Loading commit data...
curvy-pillows-boil.md Loading commit data...
eight-socks-hope.md Loading commit data...
fast-ligers-fry.md Loading commit data...
fifty-books-remain.md Loading commit data...
hot-cups-impress.md Loading commit data...
large-pets-teach.md Loading commit data...
lazy-singers-sing.md Loading commit data...
lemon-houses-chew.md Loading commit data...
lovely-gorillas-destroy.md Loading commit data...
moody-yaks-listen.md Loading commit data...
ninety-experts-wave.md Loading commit data...
polite-flies-shop.md Loading commit data...
poor-jobs-glow.md Loading commit data...
pretty-clocks-repeat.md Loading commit data...
real-ravens-clean.md Loading commit data...
rude-ducks-cry.md Loading commit data...
silent-comics-flash.md Loading commit data...
sixty-cougars-design.md Loading commit data...
thick-books-fail.md Loading commit data...
wet-monkeys-tap.md Loading commit data...