Skip to content

Commit

Permalink
refactor part 3 - almost final
Browse files Browse the repository at this point in the history
  • Loading branch information
sofinico committed May 12, 2024
1 parent c492188 commit 407dec6
Show file tree
Hide file tree
Showing 17 changed files with 39 additions and 24 deletions.
4 changes: 0 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
[submodule "lib/openzeppelin-contracts-06"]
path = lib/openzeppelin-contracts-06
url = https://github.com/OpenZeppelin/openzeppelin-contracts

# openzeppelin contracts versions
# forge install openzeppelin-contracts-06=OpenZeppelin/openzeppelin-contracts@v3.4.2
# forge install openzeppelin-contracts-08=OpenZeppelin/openzeppelin-contracts@v4.7.3
[submodule "lib/openzeppelin-contracts-08"]
path = lib/openzeppelin-contracts-08
url = https://github.com/OpenZeppelin/openzeppelin-contracts
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,20 @@ Custom "test" with typescript + ethers.js
```zsh
npm test <file-path>
```

## Additional notes

### openzeppelin-contracts

OpenZeppelin contracts versions

- `openzeppelin-contracts-06` corresponds to `v3.4.2`;
- `openzeppelin-contracts-08` corresponds to `v4.7.3`.

This is analogous as how it is done in [ethernaut](https://github.com/OpenZeppelin/ethernaut/tree/master) repo. This versioning install is done via

```bash
forge install openzeppelin-contracts-06=OpenZeppelin/openzeppelin-contracts@v3.4.2
```

respectively.
7 changes: 4 additions & 3 deletions remappings.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@forge-std/=lib/forge-std/src/
@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/
@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/
forge-std/=lib/forge-std/src/
openzeppelin-contracts-06/=lib/openzeppelin-contracts-06/contracts/
openzeppelin-contracts-08/=lib/openzeppelin-contracts-08/contracts/
openzeppelin-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/
2 changes: 1 addition & 1 deletion src/Ethernaut.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/access/Ownable.sol";
import "openzeppelin-contracts-08/access/Ownable.sol";
import "./levels/base/Level.sol";

interface IStatistics {
Expand Down
2 changes: 1 addition & 1 deletion src/attacks/NaughtCoinAttack.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "openzeppelin-contracts-08/token/ERC20/IERC20.sol";

contract NaughtCoinAttack {
IERC20 public token;
Expand Down
2 changes: 1 addition & 1 deletion src/levels/NaughtCoin.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

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

contract NaughtCoin is ERC20 {
// string public constant name = 'NaughtCoin';
Expand Down
2 changes: 1 addition & 1 deletion src/levels/base/Level.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/access/Ownable.sol";
import "openzeppelin-contracts-08/access/Ownable.sol";

abstract contract Level is Ownable {
function createInstance(address _player) public payable virtual returns (address);
Expand Down
2 changes: 1 addition & 1 deletion src/metrics/Statistics.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "openzeppelin-upgradeable/proxy/utils/Initializable.sol";

contract Statistics is Initializable {
address public ethernaut;
Expand Down
4 changes: 2 additions & 2 deletions src/metrics/StatisticsLevelSuperseder.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "openzeppelin-upgradeable/proxy/utils/Initializable.sol";
import "openzeppelin-contracts-08/access/Ownable.sol";

contract StatisticsLevelSuperseder is Initializable {
address public ethernaut;
Expand Down
4 changes: 2 additions & 2 deletions src/proxy/ProxyAdmin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

pragma solidity ^0.8.0;

import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "openzeppelin-contracts-08/proxy/transparent/TransparentUpgradeableProxy.sol";
import "openzeppelin-contracts-08/access/Ownable.sol";

/**
* @dev This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an
Expand Down
2 changes: 1 addition & 1 deletion src/proxy/ProxyStats.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import "openzeppelin-contracts-08/proxy/transparent/TransparentUpgradeableProxy.sol";

contract ProxyStats is TransparentUpgradeableProxy {
constructor(address _impl, address _admin, address _ethernautAddress)
Expand Down
2 changes: 1 addition & 1 deletion test/GatekeeperOne.t.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

import {Test, console} from "@forge-std/Test.sol";
import {Test, console} from "forge-std/Test.sol";
import {Utils} from "./utils/Utils.sol";

import {GatekeeperOne} from "../src/levels/GatekeeperOne.sol";
Expand Down
2 changes: 1 addition & 1 deletion test/GatekeeperOneOld.t.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

import {Test, console} from "@forge-std/Test.sol";
import {Test, console} from "forge-std/Test.sol";
import {Utils} from "./utils/Utils.sol";

import {GatekeeperOne} from "../src/levels/GatekeeperOne.sol";
Expand Down
2 changes: 1 addition & 1 deletion test/GatekeeperTwo.t.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import {Test, console} from "@forge-std/Test.sol";
import {Test, console} from "forge-std/Test.sol";
import {Utils} from "./utils/Utils.sol";

import {GatekeeperTwo} from "../src/levels/GatekeeperTwo.sol";
Expand Down
2 changes: 1 addition & 1 deletion test/NaughtCoin.t.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import {Test, console} from "@forge-std/Test.sol";
import {Test, console} from "forge-std/Test.sol";
import {Utils} from "./utils/Utils.sol";

import {NaughtCoin} from "../src/levels/NaughtCoin.sol";
Expand Down
4 changes: 2 additions & 2 deletions test/Preservation.t.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import {Test, console} from "@forge-std/Test.sol";
import "forge-std/Test.sol";
import {Utils} from "./utils/Utils.sol";

import {Preservation} from "../src/levels/Preservation.sol";
import {Preservation, LibraryContract} from "../src/levels/Preservation.sol";
import {PreservationFactory} from "../src/levels/PreservationFactory.sol";
import {PreservationAttack} from "../src/attacks/PreservationAttack.sol";

Expand Down
3 changes: 2 additions & 1 deletion test/utils/Utils.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {Test, console} from "@forge-std/Test.sol";
import "forge-std/Test.sol";
import "forge-std/StdJson.sol";

import {Ethernaut} from "src/Ethernaut.sol";
import {Statistics} from "src/metrics/Statistics.sol";
Expand Down

0 comments on commit 407dec6

Please sign in to comment.