Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions contracts/gas-snapshots/shared.gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ AuthorizedCallers_applyAuthorizedCallerUpdates:test_SkipRemove_Success() (gas: 3
AuthorizedCallers_applyAuthorizedCallerUpdates:test_ZeroAddressNotAllowed_Revert() (gas: 64406)
AuthorizedCallers_constructor:test_ZeroAddressNotAllowed_Revert() (gas: 64383)
AuthorizedCallers_constructor:test_constructor_Success() (gas: 683090)
BaseERC20_approve:test_approve() (gas: 56136)
BaseERC20_constructor:test_Constructor() (gas: 1088581)
BaseERC20_getCCIPAdmin:test_getCCIPAdmin() (gas: 10548)
BaseERC20_getCCIPAdmin:test_setCCIPAdmin() (gas: 21584)
BaseERC20_supportsInterface:test_SupportsInterface() (gas: 11167)
BaseERC20_transfer:test_transfer() (gas: 42320)
BurnMintERC20PausableFreezableTransparentTest:test_Freeze() (gas: 46647)
BurnMintERC20PausableFreezableTransparentTest:test_Freeze_EvenWhenImplementationIsPaused() (gas: 77916)
BurnMintERC20PausableFreezableTransparentTest:test_Unfreeze() (gas: 176325)
Expand Down Expand Up @@ -43,17 +49,12 @@ BurnMintERC20UUPSTest:test_Mint() (gas: 75473)
BurnMintERC20UUPSTest:test_ProxiableUUID() (gas: 2820627)
BurnMintERC20UUPSTest:test_SetCCIPAdmin() (gas: 29807)
BurnMintERC20UUPSTest:test_SupportsInterface() (gas: 22038)
BurnMintERC20_approve:test_approve() (gas: 57656)
BurnMintERC20_burn:test_BasicBurn() (gas: 153602)
BurnMintERC20_burnFrom:test_BurnFrom() (gas: 57995)
BurnMintERC20_burnFromAlias:test_burn() (gas: 58039)
BurnMintERC20_constructor:test_Constructor() (gas: 1694947)
BurnMintERC20_getCCIPAdmin:test_getCCIPAdmin() (gas: 10548)
BurnMintERC20_getCCIPAdmin:test_setCCIPAdmin() (gas: 21584)
BurnMintERC20_grantMintAndBurnRoles:test_GrantMintAndBurnRoles() (gas: 79130)
BurnMintERC20_mint:test_mint() (gas: 101843)
BurnMintERC20_supportsInterface:test_SupportsInterface() (gas: 11218)
BurnMintERC20_transfer:test_transfer() (gas: 42338)
BurnMintERC20_burn:test_BasicBurn() (gas: 153615)
BurnMintERC20_burnFrom:test_BurnFrom() (gas: 56742)
BurnMintERC20_burnFromAlias:test_burn() (gas: 56786)
BurnMintERC20_grantMintAndBurnRoles:test_GrantMintAndBurnRoles() (gas: 78868)
BurnMintERC20_mint:test_mint() (gas: 101988)
BurnMintERC20_supportsInterface:test_SupportsInterface() (gas: 12764)
BurnMintERC677_approve:testApproveSuccess() (gas: 55516)
BurnMintERC677_approve:testInvalidAddressReverts() (gas: 10657)
BurnMintERC677_burn:testBasicBurnSuccess() (gas: 172096)
Expand Down
1 change: 1 addition & 0 deletions contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"@openzeppelin/contracts-4.9.6": "npm:@openzeppelin/contracts@4.9.6",
"@openzeppelin/contracts-5.0.2": "npm:@openzeppelin/contracts@5.0.2",
"@openzeppelin/contracts-5.1.0": "npm:@openzeppelin/contracts@5.1.0",
"@openzeppelin/contracts-5.3.0": "npm:@openzeppelin/contracts@5.3.0",
"@openzeppelin/contracts-upgradeable": "4.9.6",
"@scroll-tech/contracts": "2.0.0",
"@zksync/contracts": "github:matter-labs/era-contracts#446d391d34bdb48255d5f8fef8a8248925fc98b9"
Expand Down
8 changes: 8 additions & 0 deletions contracts/pnpm-lock.yaml

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

1 change: 1 addition & 0 deletions contracts/remappings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ forge-std/=src/v0.8/vendor/forge-std/src/
@openzeppelin/contracts@4.9.6=node_modules/@openzeppelin/contracts-4.9.6
@openzeppelin/contracts@5.0.2=node_modules/@openzeppelin/contracts-5.0.2
@openzeppelin/contracts@5.1.0=node_modules/@openzeppelin/contracts-5.1.0
@openzeppelin/contracts@5.3.0=node_modules/@openzeppelin/contracts-5.3.0
@openzeppelin/contracts-upgradeable/=node_modules/@openzeppelin/contracts-upgradeable/


Expand Down
4 changes: 2 additions & 2 deletions contracts/scripts/native_solc_compile_all_shared
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ compileContract interfaces/ITypeAndVersion 0.8.19
compileContract token/ERC677/ERC677 0.8.19
compileContract token/ERC677/BurnMintERC677 0.8.19
compileContract token/ERC677/LinkToken 0.8.19
compileContract token/ERC20/BurnMintERC20 0.8.19
compileContract token/ERC20/BurnMintERC20

compileContract token/ERC20/upgradeable/BurnMintERC20PausableFreezableTransparent
compileContract token/ERC20/upgradeable/BurnMintERC20PausableFreezableUUPS
Expand All @@ -66,7 +66,7 @@ compileContract token/ERC20/upgradeable/BurnMintERC20Transparent
compileContract token/ERC20/upgradeable/BurnMintERC20UUPS
compileContract token/ERC20/upgradeable/IBurnMintERC20Upgradeable

compileContract test/helpers/BurnMintERC20WithDrip 0.8.19
compileContract test/helpers/BurnMintERC20WithDrip
compileContract test/helpers/ChainReaderTester 0.8.19
compileContract test/helpers/LogEmitter 0.8.19
compileContract test/helpers/VRFLogEmitter 0.8.19
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity ^0.8.4;
import {BurnMintERC20} from "../../token/ERC20/BurnMintERC20.sol";

contract BurnMintERC20WithDrip is BurnMintERC20 {
constructor(string memory name, string memory symbol) BurnMintERC20(name, symbol, 18, 0, 0) {}
constructor(string memory name, string memory symbol) BurnMintERC20(name, symbol, 18, 0, 0, address(0)) {}

// Gives one full token to any given address.
function drip(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

import {BaseERC20} from "../../../../token/ERC20/BaseERC20.sol";
import {BaseERC20Setup} from "./BaseERC20Setup.t.sol";

contract BaseERC20_approve is BaseERC20Setup {
function test_approve() public {
uint256 balancePre = s_baseERC20.balanceOf(STRANGER);
uint256 sendingAmount = s_amount / 2;

s_baseERC20.approve(STRANGER, sendingAmount);

uint256 ownerBalancePre = s_baseERC20.balanceOf(OWNER);

changePrank(STRANGER);

s_baseERC20.transferFrom(OWNER, STRANGER, sendingAmount);

assertEq(sendingAmount + balancePre, s_baseERC20.balanceOf(STRANGER));
assertEq(ownerBalancePre - sendingAmount, s_baseERC20.balanceOf(OWNER));
}

// Reverts

function test_approve_RevertWhen_InvalidAddress() public {
vm.expectRevert(abi.encodeWithSelector(BaseERC20.InvalidRecipient.selector, address(s_baseERC20)));

s_baseERC20.approve(address(s_baseERC20), s_amount);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

import {BaseERC20} from "../../../../token/ERC20/BaseERC20.sol";
import {BaseERC20Setup} from "./BaseERC20Setup.t.sol";

contract BaseERC20_getCCIPAdmin is BaseERC20Setup {
function test_getCCIPAdmin() public view {
assertEq(OWNER, s_baseERC20.getCCIPAdmin());
}

function test_setCCIPAdmin() public {
address newAdmin = makeAddr("newAdmin");

vm.expectEmit();
emit BaseERC20.CCIPAdminTransferred(OWNER, newAdmin);

s_baseERC20.setCCIPAdmin(newAdmin);

assertEq(newAdmin, s_baseERC20.getCCIPAdmin());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

import {BaseERC20} from "../../../../token/ERC20/BaseERC20.sol";
import {BaseERC20Setup} from "./BaseERC20Setup.t.sol";

contract BaseERC20_constructor is BaseERC20Setup {
function test_Constructor() public {
vm.startPrank(s_alice);

string memory name = "Chainlink token v2";
string memory symbol = "LINK2";
uint8 decimals = 19;
uint256 maxSupply = 1e33;

s_baseERC20 = new BaseERC20(name, symbol, decimals, maxSupply, 1e18, address(0));

assertEq(name, s_baseERC20.name());
assertEq(symbol, s_baseERC20.symbol());
assertEq(decimals, s_baseERC20.decimals());
assertEq(maxSupply, s_baseERC20.maxSupply());

assertTrue(s_baseERC20.hasRole(s_baseERC20.DEFAULT_ADMIN_ROLE(), s_alice));
assertEq(s_baseERC20.balanceOf(s_alice), 1e18);
assertEq(s_baseERC20.totalSupply(), 1e18);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

import {BaseERC20Setup} from "./BaseERC20Setup.t.sol";

import {IAccessControl} from "@openzeppelin/contracts@5.3.0/access/IAccessControl.sol";
import {IERC20} from "@openzeppelin/contracts@5.3.0/token/ERC20/IERC20.sol";
import {IERC165} from "@openzeppelin/contracts@5.3.0/utils/introspection/IERC165.sol";

contract BaseERC20_supportsInterface is BaseERC20Setup {
function test_SupportsInterface() public view {
assertTrue(s_baseERC20.supportsInterface(type(IERC20).interfaceId));
assertTrue(s_baseERC20.supportsInterface(type(IERC165).interfaceId));
assertTrue(s_baseERC20.supportsInterface(type(IAccessControl).interfaceId));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

import {BaseERC20} from "../../../../token/ERC20/BaseERC20.sol";
import {BaseERC20Setup} from "./BaseERC20Setup.t.sol";

contract BaseERC20_transfer is BaseERC20Setup {
function test_transfer() public {
uint256 balancePre = s_baseERC20.balanceOf(STRANGER);
uint256 sendingAmount = s_amount / 2;

s_baseERC20.transfer(STRANGER, sendingAmount);

assertEq(sendingAmount + balancePre, s_baseERC20.balanceOf(STRANGER));
}

// Reverts

function test_transfer_RevertWhen_InvalidAddress() public {
vm.expectRevert(abi.encodeWithSelector(BaseERC20.InvalidRecipient.selector, address(s_baseERC20)));

s_baseERC20.transfer(address(s_baseERC20), s_amount);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

import {BaseERC20} from "../../../../token/ERC20/BaseERC20.sol";
import {BaseTest} from "../../../BaseTest.t.sol";

contract BaseERC20Setup is BaseTest {
BaseERC20 internal s_baseERC20;

uint256 internal s_amount = 1e18;

address internal s_alice;

function setUp() public virtual override {
BaseTest.setUp();

s_alice = makeAddr("alice");

s_baseERC20 = new BaseERC20("Chainlink Token", "LINK", 18, 1e27, 0, address(0));
deal(address(s_baseERC20), OWNER, s_amount);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ pragma solidity ^0.8.24;
import {BurnMintERC20} from "../../../../token/ERC20/BurnMintERC20.sol";
import {BurnMintERC20Setup} from "./BurnMintERC20Setup.t.sol";

import {IERC20} from "@openzeppelin/contracts@4.8.3/token/ERC20/IERC20.sol";
import {Strings} from "@openzeppelin/contracts@4.8.3/utils/Strings.sol";
import {IAccessControl} from "@openzeppelin/contracts@5.3.0/access/IAccessControl.sol";
import {IERC20Errors} from "@openzeppelin/contracts@5.3.0/interfaces/draft-IERC6093.sol";
import {IERC20} from "@openzeppelin/contracts@5.3.0/token/ERC20/IERC20.sol";

contract BurnMintERC20_burn is BurnMintERC20Setup {
function test_BasicBurn() public {
Expand All @@ -23,14 +24,9 @@ contract BurnMintERC20_burn is BurnMintERC20Setup {
// Revert

function test_burn_RevertWhen_SenderNotBurner() public {
// OZ Access Control v4.8.3 inherited by BurnMintERC20 does not use custom errors, but the revert message is still
// useful and should be checked
vm.expectRevert(
abi.encodePacked(
"AccessControl: account ",
Strings.toHexString(OWNER),
" is missing role ",
Strings.toHexString(uint256(s_burnMintERC20.BURNER_ROLE()), 32)
abi.encodeWithSelector(
IAccessControl.AccessControlUnauthorizedAccount.selector, OWNER, s_burnMintERC20.BURNER_ROLE()
)
);

Expand All @@ -40,7 +36,7 @@ contract BurnMintERC20_burn is BurnMintERC20Setup {
function test_burn_RevertWhen_ExceedsBalance() public {
changePrank(s_mockPool);

vm.expectRevert("ERC20: burn amount exceeds balance");
vm.expectRevert(abi.encodeWithSelector(IERC20Errors.ERC20InsufficientBalance.selector, s_mockPool, 0, s_amount * 2));

s_burnMintERC20.burn(s_amount * 2);
}
Expand All @@ -49,7 +45,7 @@ contract BurnMintERC20_burn is BurnMintERC20Setup {
s_burnMintERC20.grantRole(s_burnMintERC20.BURNER_ROLE(), address(0));
changePrank(address(0));

vm.expectRevert("ERC20: burn from the zero address");
vm.expectRevert(abi.encodeWithSelector(IERC20Errors.ERC20InvalidSender.selector, address(0)));

s_burnMintERC20.burn(0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ pragma solidity ^0.8.24;
import {BurnMintERC20} from "../../../../token/ERC20/BurnMintERC20.sol";
import {BurnMintERC20Setup} from "./BurnMintERC20Setup.t.sol";

import {Strings} from "@openzeppelin/contracts@4.8.3/utils/Strings.sol";
import {IAccessControl} from "@openzeppelin/contracts@5.3.0/access/IAccessControl.sol";
import {IERC20Errors} from "@openzeppelin/contracts@5.3.0/interfaces/draft-IERC6093.sol";

contract BurnMintERC20_burnFrom is BurnMintERC20Setup {
function setUp() public virtual override {
Expand All @@ -24,15 +25,9 @@ contract BurnMintERC20_burnFrom is BurnMintERC20Setup {
// Reverts

function test_burnFrom_RevertWhen_SenderNotBurner() public {
// OZ Access Control v4.8.3 inherited by BurnMintERC20 does not use custom errors, but the revert message is still
// useful
// and should be checked
vm.expectRevert(
abi.encodePacked(
"AccessControl: account ",
Strings.toHexString(OWNER),
" is missing role ",
Strings.toHexString(uint256(s_burnMintERC20.BURNER_ROLE()), 32)
abi.encodeWithSelector(
IAccessControl.AccessControlUnauthorizedAccount.selector, OWNER, s_burnMintERC20.BURNER_ROLE()
)
);

Expand All @@ -42,7 +37,7 @@ contract BurnMintERC20_burnFrom is BurnMintERC20Setup {
function test_burnFrom_RevertWhen_InsufficientAllowance() public {
changePrank(s_mockPool);

vm.expectRevert("ERC20: insufficient allowance");
vm.expectRevert(abi.encodeWithSelector(IERC20Errors.ERC20InsufficientAllowance.selector, s_mockPool, 0, s_amount));

s_burnMintERC20.burnFrom(OWNER, s_amount);
}
Expand All @@ -52,7 +47,9 @@ contract BurnMintERC20_burnFrom is BurnMintERC20Setup {

changePrank(s_mockPool);

vm.expectRevert("ERC20: burn amount exceeds balance");
vm.expectRevert(
abi.encodeWithSelector(IERC20Errors.ERC20InsufficientBalance.selector, OWNER, s_amount, s_amount * 2)
);

s_burnMintERC20.burnFrom(OWNER, s_amount * 2);
}
Expand Down
Loading
Loading