-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add deploy scripts, makefile, updated tests
- Loading branch information
Showing
10 changed files
with
196 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,5 @@ docs/ | |
|
||
# Dotenv file | ||
.env | ||
|
||
artifacts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Adapted from https://github.com/smartcontractkit/foundry-starter-kit/blob/main/Makefile | ||
|
||
# -include .env | ||
|
||
# .SILENT: | ||
|
||
.PHONY: all test clean | ||
|
||
all: clean update build | ||
|
||
# Clean the repo | ||
clean :; forge clean | ||
|
||
# Remove modules | ||
remove :; rm -rf .gitmodules && rm -rf .git/modules/* && rm -rf lib && touch .gitmodules && git add . && git commit -m "modules" | ||
|
||
# install :; forge install smartcontractkit/chainlink-brownie-contracts && forge install rari-capital/solmate && forge install foundry-rs/forge-std | ||
|
||
# Update Dependencies | ||
update:; forge update | ||
|
||
build:; forge build | ||
|
||
test :; forge test | ||
|
||
snapshot :; forge snapshot | ||
|
||
slither :; slither ./src | ||
|
||
format :; forge fmt | ||
|
||
abi: | ||
mkdir -p artifacts | ||
forge inspect PizzaFactory abi > artifacts/PizzaFactory.abi.json && forge inspect Pizza abi > artifacts/Pizza.abi.json | ||
|
||
# solhint should be installed globally | ||
lint :; solhint src/**/*.sol && solhint src/*.sol | ||
|
||
anvil :; anvil -m 'test test test test test test test test test test test junk' | ||
|
||
# use the "@" to hide the command from your shell | ||
deploy-sepolia :; @forge script script/${contract}.s.sol:Deploy${contract} --rpc-url ${SEPOLIA_RPC_URL} --private-key ${PRIVATE_KEY} --broadcast --verify --etherscan-api-key ${ETHERSCAN_API_KEY} -vvvv | ||
|
||
# anvil deploy with the default user | ||
deploy-anvil :; @forge script script/PizzaFactory.s.sol:DeployPizzaFactory --rpc-url http://localhost:8545 --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 --broadcast | ||
|
||
# anvil deploy with the default user | ||
deploy-anvil-sample-pizza :; @forge script script/PizzaFactory.s.sol:DeploySamplePizza --rpc-url http://localhost:8545 --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 --broadcast -vvvv | ||
|
||
|
||
# deploy-all :; make deploy-${network} contract=APIConsumer && make deploy-${network} contract=KeepersCounter && make deploy-${network} contract=PriceFeedConsumer && make deploy-${network} contract=VRFConsumerV2 | ||
|
||
-include ${FCT_PLUGIN_PATH}/makefile-external |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule openzeppelin-contracts
updated
240 files
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.13; | ||
|
||
import {Script, console2} from "forge-std/Script.sol"; | ||
import {Pizza} from "../src/Pizza.sol"; | ||
import {PizzaFactory} from "../src/PizzaFactory.sol"; | ||
|
||
contract DeployPizzaFactory is Script { | ||
function setUp() public {} | ||
|
||
function run() public returns (Pizza implementation, PizzaFactory factory) { | ||
vm.startBroadcast(); | ||
bytes32 salt = bytes32(vm.envUint("DEPLOY_SALT")); | ||
implementation = new Pizza{salt: salt}(); | ||
factory = new PizzaFactory{salt: salt}(address(implementation)); | ||
} | ||
} | ||
|
||
contract DeploySamplePizza is Script { | ||
function setUp() public {} | ||
|
||
function run(address factory) public returns (address) { | ||
PizzaFactory f = PizzaFactory(factory); | ||
vm.startBroadcast(); | ||
|
||
address[] memory payees = new address[](2); | ||
payees[0] = vm.createWallet("wallet a").addr; | ||
payees[1] = vm.createWallet("wallet b").addr; | ||
uint256[] memory shares = new uint256[](2); | ||
shares[0] = 100; | ||
shares[1] = 100; | ||
return address(f.create(payees, shares)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity 0.8.23; | ||
|
||
import {Test, console2} from "forge-std/Test.sol"; | ||
import {PizzaFactory, PizzaCreated} from "../src/PizzaFactory.sol"; | ||
import {Pizza} from "../src/Pizza.sol"; | ||
import {Address} from "openzeppelin-contracts/utils/Address.sol"; | ||
import {IERC20} from "openzeppelin-contracts/token/ERC20/IERC20.sol"; | ||
import {Clones} from "openzeppelin-contracts/proxy/Clones.sol"; | ||
|
||
event PaymentReceived(address from, uint256 amount); | ||
|
||
contract PizzaFactoryForkTest is Test { | ||
PizzaFactory public f; | ||
address[] payees; | ||
uint256[] shares; | ||
|
||
function setUp() public { | ||
vm.createSelectFork("mainnet", 18814000); | ||
|
||
f = new PizzaFactory(address(new Pizza())); | ||
|
||
payees.push(vm.createWallet("wallet a").addr); | ||
payees.push(vm.createWallet("wallet b").addr); | ||
shares.push(2); | ||
shares.push(3); | ||
} | ||
|
||
function test_cloneReceive() public { | ||
Pizza p = Pizza(payable(address(f.create(payees, shares)))); | ||
|
||
address sender = address(0x3); | ||
vm.deal(sender, 3 ether); | ||
|
||
vm.startPrank(sender); | ||
|
||
vm.expectEmit(true, true, false, true); | ||
emit PaymentReceived(sender, 1 ether); | ||
payable(p).transfer(1 ether); | ||
|
||
vm.expectEmit(true, true, false, true); | ||
emit PaymentReceived(sender, 1 ether); | ||
bool ok = payable(p).send(1 ether); | ||
assertTrue(ok); | ||
|
||
vm.expectEmit(true, true, false, true); | ||
emit PaymentReceived(sender, 1 ether); | ||
(ok,) = payable(p).call{value: 1 ether}(""); | ||
assertTrue(ok); | ||
} | ||
|
||
function test_release() public { | ||
Pizza p = Pizza(payable(address(f.create(payees, shares)))); | ||
|
||
address sender = address(0x3); | ||
vm.deal(sender, 1 ether); | ||
vm.expectEmit(true, true, false, true); | ||
emit PaymentReceived(sender, 1 ether); | ||
vm.prank(sender); | ||
Address.sendValue(payable(p), 1 ether); | ||
|
||
assertEq(payable(payees[0]).balance, 0); | ||
assertEq(payable(payees[1]).balance, 0); | ||
|
||
p.release(); | ||
assertEq(payable(payees[0]).balance, 0.4 ether); | ||
assertEq(payable(payees[1]).balance, 0.6 ether); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters