From cd8cd001fa937feefb003bf5ecb313ac6b2831c4 Mon Sep 17 00:00:00 2001 From: Gonzalo Date: Sat, 19 Oct 2024 14:53:21 -0300 Subject: [PATCH] update-solidity-version-pragma (#2) * chore: Update Solidity version to 0.8.4 in WrappedNativeToken contract * feat: Update pragma solidity version and add ERC20Permit extension to WrappedNativeToken * feat: Update solidity version to 0.8.4 and add Ownable contract for ERC20Token * feature: Add support for token owner parameter in ERC20Token constructor. --- script/Tokens.s.sol | 2 +- src/ERC20Token.sol | 8 +++++--- src/WrappedNativeToken.sol | 7 ++++--- test/WrappedNativeToken.t.sol | 2 +- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/script/Tokens.s.sol b/script/Tokens.s.sol index 00d0192..118604b 100644 --- a/script/Tokens.s.sol +++ b/script/Tokens.s.sol @@ -11,7 +11,7 @@ contract TokensScript is Script { function run() public { vm.startBroadcast(); - new ERC20Token("Dummy USD", "dUSD", 1_000_000_000_000 ether, msg.sender); + new ERC20Token("Dummy USD", "dUSD", 1_000_000_000_000 ether, msg.sender, msg.sender); new WrappedNativeToken("Wrapped ETH", "wETH"); vm.stopBroadcast(); diff --git a/src/ERC20Token.sol b/src/ERC20Token.sol index 0c5df93..5475bc9 100644 --- a/src/ERC20Token.sol +++ b/src/ERC20Token.sol @@ -1,10 +1,12 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.4; import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; +import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; -contract ERC20Token is ERC20 { - constructor(string memory _name, string memory _symbol, uint256 _supply, address _supplyReceiver) +contract ERC20Token is ERC20, Ownable { + constructor(string memory _name, string memory _symbol, uint256 _supply, address _supplyReceiver, address _owner) + Ownable(_owner) ERC20(_name, _symbol) { _mint(_supplyReceiver, _supply); diff --git a/src/WrappedNativeToken.sol b/src/WrappedNativeToken.sol index 0756af8..2119ab8 100644 --- a/src/WrappedNativeToken.sol +++ b/src/WrappedNativeToken.sol @@ -1,15 +1,16 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.4; import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; +import {ERC20Permit} from "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol"; -contract WrappedNativeToken is ERC20 { +contract WrappedNativeToken is ERC20Permit { event Deposit(address indexed _sender, uint256 _amount); event Withdrawal(address indexed _sender, uint256 _amount); error NotEnoughBalance(); - constructor(string memory _name, string memory _symbol) ERC20(_name, _symbol) {} + constructor(string memory _name, string memory _symbol) ERC20Permit(_name) ERC20(_name, _symbol) {} function deposit() public payable { _mint(msg.sender, msg.value); diff --git a/test/WrappedNativeToken.t.sol b/test/WrappedNativeToken.t.sol index b3108ac..a1e8e7b 100644 --- a/test/WrappedNativeToken.t.sol +++ b/test/WrappedNativeToken.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.27; +pragma solidity ^0.8.4; import {Test} from "forge-std/Test.sol";