Skip to content

Commit 74cdffb

Browse files
committed
prototype
1 parent e3408ab commit 74cdffb

9 files changed

+137
-152
lines changed

foundry.toml

+1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
src = "src"
33
out = "out"
44
libs = ["lib"]
5+
via_ir = true
56

67
# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options

script/DeployBartering.s.sol

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.26;
3+
4+
import {Script} from "../lib/forge-std/src/Script.sol";
5+
import {Bartering} from "../src/Bartering.sol";
6+
7+
contract DeployBartering is Script {
8+
function run(address _initialOwner) external returns (Bartering) {
9+
vm.startBroadcast(); // Start transaction
10+
Bartering _bartering = new Bartering(_initialOwner); // Deploy new contract
11+
vm.stopBroadcast(); // End transaction
12+
return (_bartering); // Return deployed contract
13+
}
14+
}

src/Bartering.sol

+53-152
Large diffs are not rendered by default.

test/fuzz/ContinueOnRevert/ContinueOnRevertHandler.t.sol

Whitespace-only changes.

test/fuzz/ContinueOnRevert/ContinueOnRevertInvariants.t.sol

Whitespace-only changes.

test/fuzz/StopOnRevert/StopOnRevertHandler.t.sol

Whitespace-only changes.

test/fuzz/StopOnRevert/StopOnRevertInvariants.t.sol

Whitespace-only changes.

test/mocks/TokensMocks.sol

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.19;
3+
4+
import "lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol";
5+
import "lib/openzeppelin-contracts/contracts/token/ERC721/ERC721.sol";
6+
7+
contract MockERC20 is ERC20 {
8+
constructor() ERC20("MockERC20", "M20") {}
9+
10+
function mint(address to, uint256 amount) external {
11+
_mint(to, amount);
12+
}
13+
}
14+
15+
contract MockERC721 is ERC721 {
16+
uint256 private _currentTokenId;
17+
18+
constructor() ERC721("MockERC721", "M721") {}
19+
20+
function mint(address to) external {
21+
_currentTokenId++;
22+
_mint(to, _currentTokenId);
23+
}
24+
}

test/unit/BarteringTest.t.sol

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// SPDX-License-Identifier: MIT
2+
3+
pragma solidity ^0.8.26;
4+
5+
import {DeployBartering} from "../../script/DeployBartering.s.sol";
6+
import {Bartering} from "../../src/Bartering.sol";
7+
import {Test, console} from "../../lib/forge-std/src/Test.sol";
8+
import {Vm} from "../../lib/forge-std/src/Vm.sol";
9+
import {StdCheats} from "../../lib/forge-std/src/StdCheats.sol";
10+
import {MockERC20} from "../mocks/TokensMocks.sol";
11+
import {MockERC721} from "../mocks/TokensMocks.sol";
12+
13+
contract BarteringTest is StdCheats, Test {
14+
Bartering public bartering;
15+
16+
address public REQUESTER = makeAddr("requester");
17+
address public ACCEPTER = makeAddr("accepter");
18+
address public OWNER = makeAddr("owner");
19+
uint256 public constant STARTING_USER_BALANCE = 10 ether;
20+
21+
function setUp() external {
22+
DeployBartering deployer = new DeployBartering();
23+
(bartering) = deployer.run(OWNER);
24+
vm.deal(REQUESTER, STARTING_USER_BALANCE);
25+
vm.deal(ACCEPTER, STARTING_USER_BALANCE);
26+
vm.deal(OWNER, STARTING_USER_BALANCE);
27+
}
28+
29+
function testChangeFee(uint256 newFee) external {
30+
uint256 initialFee = bartering.getCurrentFee();
31+
vm.prank(OWNER);
32+
bartering.changeFee(newFee);
33+
if (initialFee != newFee) {
34+
assertEq(newFee, bartering.getCurrentFee());
35+
}
36+
}
37+
38+
function testCreateBarterRequest() external {}
39+
40+
// acceptBarterRequest
41+
// cancelBarterRequest
42+
// withdrawAllTokens
43+
// withdrawTokensByIndices
44+
// ownerWithdrawal
45+
}

0 commit comments

Comments
 (0)