Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: minterOrOwner #72

Merged
merged 2 commits into from
Jun 18, 2024
Merged
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
11 changes: 4 additions & 7 deletions contracts/DLCBTC.sol
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ contract DLCBTC is
__ERC20Permit_init("dlcBTC");
}

modifier onlyCCIPMinter() {
if (msg.sender != _minter) revert NotAuthorized();
modifier onlyOwnerOrCCIPMinter() {
if (msg.sender != _minter && msg.sender != owner())
revert NotAuthorized();
_;
}

Expand All @@ -66,14 +67,10 @@ contract DLCBTC is
return 8;
}

function mint(address to, uint256 amount) external onlyOwner {
function mint(address to, uint256 amount) external onlyOwnerOrCCIPMinter {
_mint(to, amount);
}

function mint(uint256 amount) external onlyCCIPMinter {
_mint(msg.sender, amount);
}

function burn(address from, uint256 amount) external onlyOwner {
_burn(from, amount);
}
Expand Down
5 changes: 2 additions & 3 deletions deploymentFiles/arbitrum/DLCBTC.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"network": "arbitrum",
"updatedAt": "2024-06-13T17:20:24.120Z",
"gitSHA": "2453cea",
"updatedAt": "2024-06-17T14:33:28.663Z",
"gitSHA": "b0905e1",
"contract": {
"name": "DLCBTC",
"address": "0x050C24dBf1eEc17babE5fc585F06116A259CC77A",
Expand Down Expand Up @@ -34,7 +34,6 @@
"function increaseAllowance(address spender, uint256 addedValue) returns (bool)",
"function initialize()",
"function mint(address to, uint256 amount)",
"function mint(uint256 amount)",
"function name() view returns (string)",
"function nonces(address owner) view returns (uint256)",
"function owner() view returns (address)",
Expand Down
5 changes: 2 additions & 3 deletions deploymentFiles/arbsepolia/DLCBTC.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"network": "arbsepolia",
"updatedAt": "2024-06-13T17:34:21.535Z",
"gitSHA": "2453cea",
"updatedAt": "2024-06-17T13:33:28.663Z",
"gitSHA": "b0905e1",
"contract": {
"name": "DLCBTC",
"address": "0xFfb72b5f195F18741101A732e7AfAE72b61D48a4",
Expand Down Expand Up @@ -34,7 +34,6 @@
"function increaseAllowance(address spender, uint256 addedValue) returns (bool)",
"function initialize()",
"function mint(address to, uint256 amount)",
"function mint(uint256 amount)",
"function name() view returns (string)",
"function nonces(address owner) view returns (uint256)",
"function owner() view returns (address)",
Expand Down
5 changes: 2 additions & 3 deletions deploymentFiles/mainnet/DLCBTC.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"network": "mainnet",
"updatedAt": "2024-06-13T17:27:24.120Z",
"gitSHA": "2453cea",
"updatedAt": "2024-06-17T14:29:04.379Z",
"gitSHA": "b0905e1",
"contract": {
"name": "DLCBTC",
"address": "0x20157DBAbb84e3BBFE68C349d0d44E48AE7B5AD2",
Expand Down Expand Up @@ -34,7 +34,6 @@
"function increaseAllowance(address spender, uint256 addedValue) returns (bool)",
"function initialize()",
"function mint(address to, uint256 amount)",
"function mint(uint256 amount)",
"function name() view returns (string)",
"function nonces(address owner) view returns (uint256)",
"function owner() view returns (address)",
Expand Down
4 changes: 2 additions & 2 deletions test/DLCBTC.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ describe('DLCBTC', function () {
it('should revert on unauthorized mint', async () => {
await expect(
dlcBtc.connect(user)['mint(address,uint256)'](user.address, deposit)
).to.be.revertedWith('Ownable: caller is not the owner');
).to.be.revertedWithCustomError(dlcBtc, 'NotAuthorized');
});

it('should revert on unauthorized burn', async () => {
Expand Down Expand Up @@ -111,7 +111,7 @@ describe('DLCBTC', function () {
dlcBtc
.connect(deployer)
['mint(address,uint256)'](user.address, deposit)
).to.be.revertedWith('Ownable: caller is not the owner');
).to.be.revertedWithCustomError(dlcBtc, 'NotAuthorized');
});

it('should revert on burn called by previous owner', async () => {
Expand Down