Skip to content

Commit

Permalink
refactor: remove extra dependencies (#13)
Browse files Browse the repository at this point in the history
* refactor: remove extra dependencies

* feat: declare forge-std a dev dependency
  • Loading branch information
gas1cent authored Dec 4, 2023
1 parent 1cdd1a0 commit 4aa14c4
Show file tree
Hide file tree
Showing 10 changed files with 111 additions and 61 deletions.
9 changes: 2 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,15 @@
"*.sol": "solhint --fix 'solidity/contracts/**/*.sol' 'solidity/interfaces/**/*.sol' && solhint --fix -c .solhint.tests.json 'solidity/test/**/*.sol'",
"package.json": "sort-package-json"
},
"dependencies": {
"@defi-wonderland/solidity-utils": "0.0.0-3e9c8e8b",
"@openzeppelin/contracts": "^4.9.3",
"ds-test": "https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0",
"forge-std": "https://github.com/foundry-rs/forge-std.git#f73c73d2018eb6a111f35e4dae7b4f27401e9421",
"solmate": "https://github.com/transmissions11/solmate.git#bfc9c25865a274a7827fea5abf6e4fb64fc64e6c"
},
"devDependencies": {
"@commitlint/cli": "17.0.3",
"@commitlint/config-conventional": "17.0.3",
"@typechain/ethers-v6": "0.3.0",
"@typechain/truffle-v5": "8.0.2",
"@typechain/web3-v1": "6.0.2",
"dotenv-cli": "7.2.1",
"ds-test": "https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0",
"forge-std": "https://github.com/foundry-rs/forge-std.git#v1.7.3",
"fs-extra": "10.1.0",
"husky": "8.0.3",
"lint-staged": "13.2.2",
Expand Down
4 changes: 0 additions & 4 deletions solidity/contracts/Oracle.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import {EnumerableSet} from '@openzeppelin/contracts/utils/structs/EnumerableSet.sol';

import {IOracle} from '../interfaces/IOracle.sol';

import {IRequestModule} from '../interfaces/modules/request/IRequestModule.sol';
Expand All @@ -12,8 +10,6 @@ import {IResolutionModule} from '../interfaces/modules/resolution/IResolutionMod
import {IFinalityModule} from '../interfaces/modules/finality/IFinalityModule.sol';

contract Oracle is IOracle {
using EnumerableSet for EnumerableSet.Bytes32Set;

/// @inheritdoc IOracle
mapping(bytes32 _requestId => uint128 _finalizedAt) public finalizedAt;

Expand Down
12 changes: 6 additions & 6 deletions solidity/test/integration/IntegrationBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ pragma solidity ^0.8.19;
// solhint-disable-next-line no-console
import {console} from 'forge-std/console.sol';

import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol';
import {Helpers} from '../utils/Helpers.sol';
import {IWETH9} from '../../interfaces/external/IWETH9.sol';
import {IDisputeModule} from '../../interfaces/modules/dispute/IDisputeModule.sol';
import {IRequestModule} from '../../interfaces/modules/request/IRequestModule.sol';
import {IResponseModule} from '../../interfaces/modules/response/IResponseModule.sol';
Expand All @@ -24,6 +21,9 @@ import {MockDisputeModule, IMockDisputeModule} from '../mocks/contracts/MockDisp
import {MockResolutionModule, IMockResolutionModule} from '../mocks/contracts/MockResolutionModule.sol';
import {MockFinalityModule, IMockFinalityModule} from '../mocks/contracts/MockFinalityModule.sol';

import {Helpers} from '../utils/Helpers.sol';
import {IWETH9} from '../utils/external/IWETH9.sol';
import {IERC20} from '../utils/external/IERC20.sol';
import {TestConstants} from '../utils/TestConstants.sol';
// solhint-enable no-unused-import

Expand All @@ -44,8 +44,8 @@ contract IntegrationBase is TestConstants, Helpers {
MockFinalityModule internal _finalityModule;
MockCallback internal _mockCallback;

IERC20 public usdc = IERC20(label(USDC_ADDRESS, 'USDC'));
IWETH9 public weth = IWETH9(label(WETH_ADDRESS, 'WETH'));
IERC20 public usdc = IERC20(_label(USDC_ADDRESS, 'USDC'));
IWETH9 public weth = IWETH9(_label(WETH_ADDRESS, 'WETH'));

string internal _expectedUrl = 'https://api.coingecko.com/api/v3/simple/price?';
string internal _expectedBody = 'ids=ethereum&vs_currencies=usd';
Expand Down Expand Up @@ -74,7 +74,7 @@ contract IntegrationBase is TestConstants, Helpers {
vm.startPrank(governance);

oracle = new Oracle();
label(address(oracle), 'Oracle');
_label(address(oracle), 'Oracle');

_accountingExtension = new MockAccounting();
_requestModule = new MockRequestModule(oracle);
Expand Down
2 changes: 1 addition & 1 deletion solidity/test/mocks/interfaces/IMockDisputeModule.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol';
import {IERC20} from '../../utils/external/IERC20.sol';

import {IDisputeModule} from '../../../interfaces/modules/dispute/IDisputeModule.sol';
import {IMockAccounting} from './IMockAccounting.sol';
Expand Down
2 changes: 1 addition & 1 deletion solidity/test/mocks/interfaces/IMockRequestModule.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol';
import {IERC20} from '../../utils/external/IERC20.sol';

import {IRequestModule} from '../../../interfaces/modules/request/IRequestModule.sol';
import {IMockAccounting} from './IMockAccounting.sol';
Expand Down
2 changes: 1 addition & 1 deletion solidity/test/mocks/interfaces/IMockResponseModule.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol';
import {IERC20} from '../../utils/external/IERC20.sol';

import {IMockAccounting} from './IMockAccounting.sol';
import {IResponseModule} from '../../../interfaces/modules/response/IResponseModule.sol';
Expand Down
23 changes: 18 additions & 5 deletions solidity/test/utils/Helpers.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import {DSTestPlus} from '@defi-wonderland/solidity-utils/solidity/test/DSTestPlus.sol';
// import {DSTestPlus} from '@defi-wonderland/solidity-utils/solidity/test/DSTestPlus.sol';
import {Test} from 'forge-std/Test.sol';
import {IOracle} from '../../contracts/Oracle.sol';

contract Helpers is DSTestPlus {
contract Helpers is Test {
// 100% random sequence of bytes representing request, response, or dispute id
bytes32 public mockId = bytes32('69');

Expand Down Expand Up @@ -80,11 +81,11 @@ contract Helpers is DSTestPlus {
/**
* @notice Creates a mock contract, labels it and erases the bytecode
*
* @param _label The label to use for the mock contract
* @param _name The label to use for the mock contract
* @return _contract The address of the mock contract
*/
function _mockContract(string memory _label) internal returns (address _contract) {
_contract = makeAddr(_label);
function _mockContract(string memory _name) internal returns (address _contract) {
_contract = makeAddr(_name);
vm.etch(_contract, hex'69');
}

Expand All @@ -96,4 +97,16 @@ contract Helpers is DSTestPlus {
function _expectEmit(address _contract) internal {
vm.expectEmit(true, true, true, true, _contract);
}

/**
* @notice Assigns the given address a name
*
* @param _address The address to label
* @param _name The name to assign to the address
* @return _address The address that was labeled
*/
function _label(address _address, string memory _name) internal returns (address) {
vm.label(_address, _name);
return _address;
}
}
78 changes: 78 additions & 0 deletions solidity/test/utils/external/IERC20.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);

Check warning on line 16 in solidity/test/utils/external/IERC20.sol

View workflow job for this annotation

GitHub Actions / Run Linters (16.x)

'from' should start with _

Check warning on line 16 in solidity/test/utils/external/IERC20.sol

View workflow job for this annotation

GitHub Actions / Run Linters (16.x)

'to' should start with _

Check warning on line 16 in solidity/test/utils/external/IERC20.sol

View workflow job for this annotation

GitHub Actions / Run Linters (16.x)

'value' should start with _

/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);

Check warning on line 22 in solidity/test/utils/external/IERC20.sol

View workflow job for this annotation

GitHub Actions / Run Linters (16.x)

'owner' should start with _

Check warning on line 22 in solidity/test/utils/external/IERC20.sol

View workflow job for this annotation

GitHub Actions / Run Linters (16.x)

'spender' should start with _

Check warning on line 22 in solidity/test/utils/external/IERC20.sol

View workflow job for this annotation

GitHub Actions / Run Linters (16.x)

'value' should start with _

/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);

Check warning on line 27 in solidity/test/utils/external/IERC20.sol

View workflow job for this annotation

GitHub Actions / Run Linters (16.x)

Return value 'uint256' in function 'totalSupply' must be named

/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);

Check warning on line 32 in solidity/test/utils/external/IERC20.sol

View workflow job for this annotation

GitHub Actions / Run Linters (16.x)

Return value 'uint256' in function 'balanceOf' must be named

/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);

/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);

/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);

/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.19;

import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol';
import {IERC20} from './IERC20.sol';

/// @title Interface for WETH9
interface IWETH9 is IERC20 {
Expand Down
38 changes: 3 additions & 35 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,6 @@
dependencies:
"@jridgewell/trace-mapping" "0.3.9"

"@defi-wonderland/[email protected]":
version "0.0.0-3e9c8e8b"
resolved "https://registry.npmjs.org/@defi-wonderland/solidity-utils/-/solidity-utils-0.0.0-3e9c8e8b.tgz#1f9c47506e1679ea36d0854e9aa69bd210af4da0"
integrity sha512-HCN5TTO58jTrLrAcxXwTPm++P0u4dMDnwVkssszoEu0SmVKwegzZOdoA+gNbfOjjYydph+3+9bAZbNXj+UK2rg==
dependencies:
"@openzeppelin/contracts" "4.9.2"
ds-test "https://github.com/dapphub/ds-test"
forge-std "https://github.com/foundry-rs/forge-std"

"@hutson/parse-repository-url@^3.0.0":
version "3.0.2"
resolved "https://registry.yarnpkg.com/@hutson/parse-repository-url/-/parse-repository-url-3.0.2.tgz#98c23c950a3d9b6c8f0daed06da6c3af06981340"
Expand Down Expand Up @@ -244,16 +235,6 @@
"@nodelib/fs.scandir" "2.1.5"
fastq "^1.6.0"

"@openzeppelin/[email protected]":
version "4.9.2"
resolved "https://registry.npmjs.org/@openzeppelin/contracts/-/contracts-4.9.2.tgz#1cb2d5e4d3360141a17dbc45094a8cad6aac16c1"
integrity sha512-mO+y6JaqXjWeMh9glYVzVu8HYPGknAAnWyxTRhGeckOruyXQMNnlcW6w/Dx9ftLeIQk6N+ZJFuVmTwF7lEIFrg==

"@openzeppelin/contracts@^4.9.3":
version "4.9.3"
resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-4.9.3.tgz#00d7a8cf35a475b160b3f0293a6403c511099364"
integrity sha512-He3LieZ1pP2TNt5JbkPA4PNT9WC3gOTOlDcFGJW4Le4QKqwmiNJCRt44APfxMxvq7OugU/cqYuPcSBzOw38DAg==

"@solidity-parser/parser@^0.14.1":
version "0.14.5"
resolved "https://registry.yarnpkg.com/@solidity-parser/parser/-/parser-0.14.5.tgz#87bc3cc7b068e08195c219c91cd8ddff5ef1a804"
Expand Down Expand Up @@ -1108,13 +1089,8 @@ dotgitignore@^2.1.0:
find-up "^3.0.0"
minimatch "^3.0.4"

"ds-test@https://github.com/dapphub/ds-test":
version "1.0.0"
resolved "https://github.com/dapphub/ds-test#e282159d5170298eb2455a6c05280ab5a73a4ef0"

"ds-test@https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0":
version "1.0.0"
uid e282159d5170298eb2455a6c05280ab5a73a4ef0
resolved "https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0"

eastasianwidth@^0.2.0:
Expand Down Expand Up @@ -1415,13 +1391,9 @@ flatted@^2.0.0:
resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.2.tgz#4575b21e2bcee7434aa9be662f4b7b5f9c2b5138"
integrity sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA==

"forge-std@https://github.com/foundry-rs/forge-std":
version "1.5.6"
resolved "https://github.com/foundry-rs/forge-std#e8a047e3f40f13fa37af6fe14e6e06283d9a060e"

"forge-std@https://github.com/foundry-rs/forge-std.git#f73c73d2018eb6a111f35e4dae7b4f27401e9421":
version "1.7.1"
resolved "https://github.com/foundry-rs/forge-std.git#f73c73d2018eb6a111f35e4dae7b4f27401e9421"
"forge-std@https://github.com/foundry-rs/forge-std.git#v1.7.3":
version "1.7.3"
resolved "https://github.com/foundry-rs/forge-std.git#2f112697506eab12d433a65fdc31a639548fe365"

[email protected], fs-extra@^10.0.0:
version "10.1.0"
Expand Down Expand Up @@ -2845,10 +2817,6 @@ [email protected]:
handlebars "^4.7.7"
solidity-ast "^0.4.38"

"solmate@https://github.com/transmissions11/solmate.git#bfc9c25865a274a7827fea5abf6e4fb64fc64e6c":
version "6.1.0"
resolved "https://github.com/transmissions11/solmate.git#bfc9c25865a274a7827fea5abf6e4fb64fc64e6c"

sort-object-keys@^1.1.3:
version "1.1.3"
resolved "https://registry.yarnpkg.com/sort-object-keys/-/sort-object-keys-1.1.3.tgz#bff833fe85cab147b34742e45863453c1e190b45"
Expand Down

0 comments on commit 4aa14c4

Please sign in to comment.