Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add bounty capabilities and some tests #1

Merged
merged 9 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
[submodule "lib/openzeppelin-contracts-upgradeable"]
path = lib/openzeppelin-contracts-upgradeable
url = https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

# .SILENT:

LIVENET_DEPLOY_COMMAND = forge script script/PizzaFactory.s.sol:DeployPizzaFactory --private-key ${PRIVATE_KEY} -vvvv

.PHONY: all test clean

all: clean update build
all:; forge test -vvv -w

# Clean the repo
clean :; forge clean
Expand Down Expand Up @@ -34,13 +36,11 @@ abi:
# 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-mainnet :; @forge script script/PizzaFactory.s.sol:DeployPizzaFactory --rpc-url mainnet --private-key ${PRIVATE_KEY} -vvvv
deploy-mainnet-dryrun :; @${LIVENET_DEPLOY_COMMAND} --rpc-url mainnet
deploy-sepolia-dryrun :; @${LIVENET_DEPLOY_COMMAND} --rpc-url sepolia

# use the "@" to hide the command from your shell
deploy-sepolia :; @forge script script/PizzaFactory.s.sol:DeployPizzaFactory --rpc-url sepolia --private-key ${PRIVATE_KEY} -vvvv
deploy-mainnet :; @${LIVENET_DEPLOY_COMMAND} --rpc-url mainnet --broadcast --verify
deploy-sepolia :; @${LIVENET_DEPLOY_COMMAND} --rpc-url sepolia --broadcast --verify

# anvil deploy with the default user
deploy-anvil :; @forge script script/PizzaFactory.s.sol:DeployPizzaFactory --rpc-url http://localhost:8545 --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 --broadcast
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Copy the `.env.example` file to `.env` and fill in your own values.

## Testing

For this project I've gone ahead and just created a Makefile for common build targets. You can run tests with the bare `make` command:

```
make
```
Expand All @@ -29,5 +31,12 @@ See Foundry docs for more testing options.
Check out the [Makefile](./Makefile) for build/deploy targets. Example:

```
make deploy-sepolia-dryrun
make deploy-sepolia
```

## Private key management

The private key is only used for deployment.

Depending on your development needs and risk tolerance, your key can be managed any way you like. My recommended approach is to use some kind of encrypted key storage. Check out [Foundry's encrypted keystore](https://book.getfoundry.sh/reference/cast/cast-wallet-import), or use something like [1Password's `op` CLI](https://developer.1password.com/docs/cli/get-started/).
6 changes: 3 additions & 3 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
src = "src"
out = "out"
libs = ["lib"]

# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
via_ir = true
solc = "0.8.23"

[profile.forked]
fork_block_number = 18814000
Expand All @@ -15,4 +15,4 @@ sepolia = "${SEPOLIA_RPC_URL}"

[etherscan]
mainnet = { key = "${ETHERSCAN_API_KEY}" }
goerli = { key = "${ETHERSCAN_API_KEY}", chain = "goerli"}
sepolia = { key = "${ETHERSCAN_API_KEY}", chain = "sepolia"}
2 changes: 1 addition & 1 deletion lib/forge-std
Submodule forge-std updated 1 files
+1 −1 scripts/vm.py
1 change: 1 addition & 0 deletions lib/openzeppelin-contracts-upgradeable
4 changes: 4 additions & 0 deletions script/PizzaFactory.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import {Script} from "forge-std/Script.sol";
import {Pizza} from "../src/Pizza.sol";
import {PizzaFactory} from "../src/PizzaFactory.sol";

/**
* @title DeployPizzaFactory
* @dev A script contract for deploying the PizzaFactory contract.
*/
contract DeployPizzaFactory is Script {
function setUp() public {}

Expand Down
6 changes: 5 additions & 1 deletion script/SamplePizza.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ pragma solidity ^0.8.13;
import {Script} from "forge-std/Script.sol";
import {PizzaFactory} from "../src/PizzaFactory.sol";

/**
* @title DeploySamplePizza
* @dev A contract for deploying a sample pizza contract.
*/
contract DeploySamplePizza is Script {
function setUp() public {}

Expand All @@ -17,6 +21,6 @@ contract DeploySamplePizza is Script {
uint256[] memory shares = new uint256[](2);
shares[0] = 100;
shares[1] = 100;
return address(f.create(payees, shares));
return address(f.create(payees, shares, 0));
}
}
24 changes: 23 additions & 1 deletion src/IPizzaInitializer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,27 @@ pragma solidity 0.8.23;
* @dev Interface for initializing a pizza contract.
*/
interface IPizzaInitializer {
function initialize(address[] memory _payees, uint256[] memory _shares) external;
/**
* @dev Initializes the contract.
* @param _payees The addresses of the payees.
* @param _shares The shares of each payee.
* @param _bounty The bounty amount.
*/
function initialize(address[] memory _payees, uint256[] memory _shares, uint256 _bounty) external;

/**
* @dev Initializes the contract.
* @param _payees The addresses of the payees.
* @param _shares The shares of each payee.
* @param _bounty The bounty amount.
* @param _bountyTokens The tokens to be used for the bounty.
* @param _bountyReceiver The address of the bounty receiver.
*/
function initializeWithBountyRelease(
address[] calldata _payees,
uint256[] calldata _shares,
uint256 _bounty,
address[] calldata _bountyTokens,
address _bountyReceiver
) external;
}
Loading
Loading