Skip to content

Commit

Permalink
Merge branch 'main' into minor-improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
dimpar authored May 10, 2024
2 parents 182bc02 + 330b37c commit 548a0fc
Show file tree
Hide file tree
Showing 21 changed files with 190 additions and 400 deletions.
501 changes: 154 additions & 347 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion solidity/contracts/BitcoinDepositor.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.21;
pragma solidity 0.8.24;

import "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
Expand Down
9 changes: 8 additions & 1 deletion solidity/contracts/BitcoinRedeemer.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.21;
pragma solidity 0.8.24;

import "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol";

Expand Down Expand Up @@ -61,6 +61,9 @@ contract BitcoinRedeemer is Ownable2StepUpgradeable, IReceiveApproval {
/// Reverts when approveAndCall to tBTC contract fails.
error ApproveAndCallFailed();

/// Reverts if the new TBTCVault contract is not tBTC token owner.
error NotTbtcTokenOwner();

/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
_disableInitializers();
Expand Down Expand Up @@ -118,6 +121,10 @@ contract BitcoinRedeemer is Ownable2StepUpgradeable, IReceiveApproval {
revert ZeroAddress();
}

if (newTbtcVault != tbtcToken.owner()) {
revert NotTbtcTokenOwner();
}

emit TbtcVaultUpdated(tbtcVault, newTbtcVault);

tbtcVault = newTbtcVault;
Expand Down
2 changes: 1 addition & 1 deletion solidity/contracts/MezoAllocator.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.21;
pragma solidity 0.8.24;

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
Expand Down
2 changes: 1 addition & 1 deletion solidity/contracts/PausableOwnable.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.21;
pragma solidity 0.8.24;

import "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol";
Expand Down
2 changes: 1 addition & 1 deletion solidity/contracts/bridge/ITBTCToken.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.21;
pragma solidity 0.8.24;

/// @title Interface of TBTC token contract.
/// @notice This interface defines functions of TBTC token contract used by Acre
Expand Down
2 changes: 1 addition & 1 deletion solidity/contracts/interfaces/IDispatcher.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.21;
pragma solidity 0.8.24;

/// @title IDispatcher
/// @notice Interface for the Dispatcher contract.
Expand Down
2 changes: 1 addition & 1 deletion solidity/contracts/lib/ERC4626Fees.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// Inspired by https://docs.openzeppelin.com/contracts/5.x/erc4626#fees

pragma solidity ^0.8.21;
pragma solidity 0.8.24;

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {ERC4626Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC4626Upgradeable.sol";
Expand Down
17 changes: 1 addition & 16 deletions solidity/contracts/stBTC.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.21;
pragma solidity 0.8.24;

import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

Expand Down Expand Up @@ -357,21 +357,6 @@ contract stBTC is ERC4626Fees, PausableOwnable {
return convertToAssets(balanceOf(account));
}

/// @dev Transfers a `value` amount of tokens from `from` to `to`, or
/// alternatively mints (or burns) if `from` (or `to`) is the zero
/// address. All customizations to transfers, mints, and burns should
/// be done by overriding this function.
/// @param from Sender of tokens.
/// @param to Receiver of tokens.
/// @param value Amount of tokens to transfer.
function _update(
address from,
address to,
uint256 value
) internal override whenNotPaused {
super._update(from, to, value);
}

/// @return Returns entry fee basis point used in deposits.
function _entryFeeBasisPoints() internal view override returns (uint256) {
return entryFeeBasisPoints;
Expand Down
2 changes: 1 addition & 1 deletion solidity/contracts/test/BitcoinDepositorHarness.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
/* solhint-disable func-name-mixedcase */
pragma solidity ^0.8.21;
pragma solidity 0.8.24;

import {BitcoinDepositor} from "../BitcoinDepositor.sol";
import {MockBridge, MockTBTCVault} from "@keep-network/tbtc-v2/contracts/test/TestTBTCDepositor.sol";
Expand Down
2 changes: 1 addition & 1 deletion solidity/contracts/test/MezoPortalStub.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.21;
pragma solidity 0.8.24;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
Expand Down
2 changes: 1 addition & 1 deletion solidity/contracts/test/TestERC20.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.21;
pragma solidity 0.8.24;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

Expand Down
2 changes: 1 addition & 1 deletion solidity/contracts/test/TestTBTC.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.21;
pragma solidity 0.8.24;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "../bridge/ITBTCToken.sol";
Expand Down
2 changes: 1 addition & 1 deletion solidity/contracts/test/upgrades/BitcoinDepositorV2.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.21;
pragma solidity 0.8.24;

import "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
Expand Down
2 changes: 1 addition & 1 deletion solidity/contracts/test/upgrades/MezoAllocatorV2.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.21;
pragma solidity 0.8.24;

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
Expand Down
2 changes: 1 addition & 1 deletion solidity/contracts/test/upgrades/stBTCV2.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.21;
pragma solidity 0.8.24;

import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

Expand Down
2 changes: 1 addition & 1 deletion solidity/contracts/utils/Errors.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only

pragma solidity ^0.8.21;
pragma solidity 0.8.24;

/// @notice Reverts if a checked address is zero. Used by various contracts.
error ZeroAddress();
2 changes: 1 addition & 1 deletion solidity/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const config: HardhatUserConfig = {
solidity: {
compilers: [
{
version: "0.8.21",
version: "0.8.24",
settings: {
optimizer: {
enabled: true,
Expand Down
2 changes: 1 addition & 1 deletion solidity/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"dotenv-safer": "^1.0.0",
"eslint": "^8.54.0",
"ethers": "^6.8.1",
"hardhat": "^2.19.1",
"hardhat": "^2.22.3",
"hardhat-contract-sizer": "^2.10.0",
"hardhat-deploy": "^0.11.43",
"hardhat-gas-reporter": "^1.0.9",
Expand Down
12 changes: 11 additions & 1 deletion solidity/test/BitcoinRedeemer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -442,14 +442,24 @@ describe("BitcoinRedeemer", () => {
})
})

context("when a new treasury is an allowed address", () => {
context("when a new tbtc vault is not tBTC token owner", () => {
it("should revert", async () => {
const newTbtcVault = await ethers.Wallet.createRandom().getAddress()
await expect(
bitcoinRedeemer.connect(governance).updateTbtcVault(newTbtcVault),
).to.be.revertedWithCustomError(bitcoinRedeemer, "NotTbtcTokenOwner")
})
})

context("when a new tbtc vault is an allowed address", () => {
let oldTbtcVault: string
let newTbtcVault: string
let tx: ContractTransactionResponse

before(async () => {
oldTbtcVault = await bitcoinRedeemer.tbtcVault()
newTbtcVault = await ethers.Wallet.createRandom().getAddress()
await tbtc.setOwner(newTbtcVault)

tx = await bitcoinRedeemer
.connect(governance)
Expand Down
19 changes: 0 additions & 19 deletions solidity/test/stBTC.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1868,25 +1868,6 @@ describe("stBTC", () => {
it("should return 0 when calling maxWithdraw", async () => {
expect(await stbtc.maxWithdraw(depositor1)).to.be.eq(0)
})

it("should pause transfers", async () => {
await expect(
stbtc.connect(depositor1).transfer(depositor2, amount),
).to.be.revertedWithCustomError(stbtc, "EnforcedPause")
})

it("should pause transfersFrom", async () => {
await expect(
stbtc
.connect(depositor1)
.approve(depositor2.address, amount)
.then(() =>
stbtc
.connect(depositor2)
.transferFrom(depositor1, depositor2, amount),
),
).to.be.revertedWithCustomError(stbtc, "EnforcedPause")
})
})
})

Expand Down

0 comments on commit 548a0fc

Please sign in to comment.