diff --git a/lib/forge-std b/lib/forge-std new file mode 160000 index 0000000..75f1746 --- /dev/null +++ b/lib/forge-std @@ -0,0 +1 @@ +Subproject commit 75f1746c949ae56377611e5f2128aa93d381431f diff --git a/package.json b/package.json index 10973aa..c3013f0 100644 --- a/package.json +++ b/package.json @@ -1,22 +1,22 @@ { - "name": "forge-proposal-template", - "version": "1.0.0", - "repository": "https://git.tornado.ws/Theo/forge-proposal-template", - "author": "Theo", - "license": "MIT", - "private": false, - "scripts": { - "init": "cd lib && git clone --recurse-submodules https://github.com/foundry-rs/forge-std", - "test:windows": ".\\.env.bat && forge test", - "test:linux": "source .env && forge test" - }, - "dependencies": { - "@ensdomains/ens-contracts": "^0.0.21", - "@openzeppelin/contracts": "^4.9.0", - "@openzeppelin/upgrades-core": "^1.26.2" - }, - "optionalDependencies": { - "@gnosis.pm/ido-contracts": "^0.5.0", - "@gnosis.pm/safe-contracts": "1.3.0" - } + "name": "forge-proposal-template", + "version": "1.0.0", + "repository": "https://git.tornado.ws/Theo/forge-proposal-template", + "author": "Theo", + "license": "MIT", + "private": false, + "scripts": { + "init": "cd lib && git clone --recurse-submodules https://github.com/foundry-rs/forge-std", + "test:windows": ".\\.env.bat && forge test --gas-report", + "test:linux": "source .env && forge test" + }, + "dependencies": { + "@ensdomains/ens-contracts": "^0.0.21", + "@openzeppelin/contracts": "^4.9.0", + "@openzeppelin/upgrades-core": "^1.26.2" + }, + "optionalDependencies": { + "@gnosis.pm/ido-contracts": "^0.5.0", + "@gnosis.pm/safe-contracts": "1.3.0" + } } diff --git a/src/ExampleProposal.sol b/src/ExampleProposal.sol deleted file mode 100644 index 68fd33d..0000000 --- a/src/ExampleProposal.sol +++ /dev/null @@ -1,11 +0,0 @@ -// SPDX-License-Identifier: MIT - -pragma solidity ^0.8.19; - -import { IGovernance } from "@interfaces/IGovernance.sol"; - -contract ExampleProposal { - function executeProposal() public { - /* ... */ - } -} diff --git a/src/PaidListingProposal.sol b/src/PaidListingProposal.sol new file mode 100644 index 0000000..17549f8 --- /dev/null +++ b/src/PaidListingProposal.sol @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: MIT + +pragma solidity ^0.8.19; + +import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; + +contract PaidListingProposal { + address constant tornTokenAddress = 0x77777FeDdddFfC19Ff86DB637967013e6C6A116C; + + function executeProposal() public { + address paymentAddress = 0x9Ff3C1Bea9ffB56a78824FE29f457F066257DD58; + + IERC20(tornTokenAddress).transfer(paymentAddress, 2012 ether); + } +} diff --git a/test/ExampleProposal.t.sol b/test/ExampleProposal.t.sol deleted file mode 100644 index 9efd7bc..0000000 --- a/test/ExampleProposal.t.sol +++ /dev/null @@ -1,24 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.19; - -import { ProposalUtils } from "./utils/ProposalUtils.sol"; -import { ExampleProposal } from "@root/ExampleProposal.sol"; - -import { console2 } from "@forge-std/console2.sol"; - -contract TestExampleProposal is ProposalUtils { - modifier executeCurrentProposalBefore() { - createAndExecuteProposal(); - _; - } - - function createAndExecuteProposal() public { - address proposalAddress = address(new ExampleProposal()); /* your proposal initialization */ - - proposeAndExecute(proposalAddress); - } - - /* your tests */ - - function testProposal() public executeCurrentProposalBefore { } -} diff --git a/test/PaidListingProposal.t.sol b/test/PaidListingProposal.t.sol new file mode 100644 index 0000000..40c49da --- /dev/null +++ b/test/PaidListingProposal.t.sol @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.19; + +import { ProposalUtils } from "./utils/ProposalUtils.sol"; +import { PaidListingProposal } from "@root/PaidListingProposal.sol"; +import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; + +import { console2 } from "@forge-std/console2.sol"; + +contract TestPaidListingProposal is ProposalUtils { + modifier executeCurrentProposalBefore() { + createAndExecuteProposal(); + _; + } + + function createAndExecuteProposal() public { + address proposalAddress = address(new PaidListingProposal()); /* your proposal initialization */ + + proposeAndExecute(proposalAddress); + } + + /* your tests */ + + function testAccrualTokens() public { + IERC20 TORN = IERC20(tornTokenAddress); + address developerAddress = 0x9Ff3C1Bea9ffB56a78824FE29f457F066257DD58; + + uint256 developerBalanceBeforeExecution = TORN.balanceOf(developerAddress); + console2.log("Developer balance before proposal execution: %s TORN", developerBalanceBeforeExecution / 1e18); + + createAndExecuteProposal(); + + uint256 developerBalanceAfterExecution = TORN.balanceOf(developerAddress); + console2.log("Developer balance after proposal execution: %s TORN", developerBalanceAfterExecution / 1e18); + + require(developerBalanceAfterExecution - developerBalanceBeforeExecution == 2012 ether); + } +}