Skip to content

Commit

Permalink
Monorepo - add protocol rewards (#255)
Browse files Browse the repository at this point in the history
* added protocol-rewards

* ignore other packages in coverage report

* added protocol rewards coverage

* rename coverage tasks

* make project specific files to ignore

* fix escape chars

* try to wrap with single quoates

* added protocol rewards to readme

* fix protocol rewards url
  • Loading branch information
oveddan authored Oct 12, 2023
1 parent 22eadd1 commit 38fc9af
Show file tree
Hide file tree
Showing 37 changed files with 5,093 additions and 9 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ on:
package:
required: true
type: string
files_to_ignore:
required: false
type: string
default: ""

env:
# Setting an environment variable with the value of a configuration variable
Expand Down Expand Up @@ -35,7 +39,7 @@ jobs:
run: |
cd ./${{ env.package_folder }} && lcov --rc lcov_branch_coverage=1 \
--remove lcov.info \
--output-file lcov.info "*node_modules*" "*test*" "*script*" "*DeploymentConfig*" "*Redeem*" "*deployment*"
--output-file lcov.info "*node_modules*" "*test*" "*script*" ${{ inputs.files_to_ignore }}
- name: Report code coverage
uses: zgosalvez/github-actions-report-lcov@v2
Expand Down
13 changes: 11 additions & 2 deletions .github/workflows/foundry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,15 @@ jobs:
coverage-1155:
uses: ./.github/workflows/coverage.yml
name: "1155 contracts coverage"
name: "Test coverage - 1155"
with:
package: "1155-contracts"
package: "1155-contracts"
files_to_ignore: '"*DeploymentConfig*" "*Redeem*" "*deployment*" "*packages*"'

coverage-protocol-rewards:
uses: ./.github/workflows/coverage.yml
name: "Test coverage - protocol rewards"
with:
package: "protocol-rewards"
files_to_ignore: '"*lib*"'

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ This repository is a monorepo for the Zora Protocol
In it you will find:

- [Zora 1155 Contracts](./packages/1155-contracts)
- [Protocol Rewards](./packages/protocol-rewards)

## Official docs

Expand Down
1 change: 1 addition & 0 deletions packages/1155-contracts/foundry.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[profile.default]
fs_permissions = [{access = "read", path = "./addresses"}, {access = "read", path = "./chainConfigs"}, {access = "read", path = "./package.json"}, {access = "readwrite", path = "./deterministicConfig"}]
libs = ['_imagine', 'node_modules', 'script']
allow_paths = ["node_modules/@zoralabs/protocol-rewards"]
optimizer = true
optimizer_runs = 50
out = 'out'
Expand Down
2 changes: 1 addition & 1 deletion packages/1155-contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"@openzeppelin/contracts": "4.9.2",
"@wagmi/cli": "^1.0.1",
"@zoralabs/openzeppelin-contracts-upgradeable": "4.8.4",
"@zoralabs/protocol-rewards": "1.2.1",
"@zoralabs/protocol-rewards": "*",
"abitype": "^0.8.7",
"ds-test": "https://github.com/dapphub/ds-test#cd98eff28324bfac652e63a239a60632a761790b",
"es-main": "^1.2.0",
Expand Down
39 changes: 39 additions & 0 deletions packages/protocol-rewards/_imagine/Enjoy.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

/*
░░░░░░░░░░░░░░
░░▒▒░░░░░░░░░░░░░░░░░░░░
░░▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░
░░▒▒▒▒░░░░░░░░░░░░░░ ░░░░░░░░
░▓▓▒▒▒▒░░░░░░░░░░░░ ░░░░░░░
░▓▓▓▒▒▒▒░░░░░░░░░░░░ ░░░░░░░░
░▓▓▓▒▒▒▒░░░░░░░░░░░░░░ ░░░░░░░░░░
░▓▓▓▒▒▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░
░▓▓▓▓▓▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░
░▓▓▓▓▒▒▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░░
░░▓▓▓▓▒▒▒▒▒▒░░░░░░░░░░░░░░░░░░░░
░░▓▓▓▓▓▓▒▒▒▒▒▒▒▒░░░░░░░░░▒▒▒▒▒░░
░░▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░
░░▓▓▓▓▓▓▓▓▓▓▓▓▒▒░░░
OURS TRULY,
*/

interface Enjoy { }
37 changes: 37 additions & 0 deletions packages/protocol-rewards/foundry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[profile.default]
auto_detect_solc = true
fs_permissions = [{access = "read", path = "./addresses"}, {access = "read", path = "./package.json"}]
fuzz_runs = 500
libs = ['_imagine', 'node_modules', 'script']
optimizer = true
optimizer_runs = 500000
out = 'out'
script = 'script'
src = 'src'
via_ir = true

[profile.optimized]
auto_detect_solc = true
optimizer = true
optimizer_runs = 500000
out = 'out'
script = 'src'
src = 'src'
test = 'src'
via_ir = true

[fmt]
bracket_spacing = true
func_attrs_with_params_multiline = true
int_types = "long"
line_length = 120
quote_style = "double"
tab_width = 4

[invariant]
call_override = false
depth = 20
fail_on_revert = true
runs = 1000

# See more config options https://github.com/foundry-rs/foundry/tree/master/config
26 changes: 26 additions & 0 deletions packages/protocol-rewards/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "@zoralabs/protocol-rewards",
"version": "1.2.1",
"repository": "https://github.com/ourzora/zora-protocol.git",
"license": "MIT",
"files": [
"src/",
"_imagine"
],
"scripts": {
"build": "forge build",
"build:sizes": "forge build --sizes",
"test": "forge test",
"build:contracts": "forge build",
"prettier:check": "prettier --check 'src/**/*.sol' 'test/**/*.sol' 'script/**/*.sol'",
"prettier": "prettier --write 'src/**/*.sol' 'test/**/*.sol' 'script/**/*.sol'",
"lint": "yarn run prettier"
},
"dependencies": {
"ds-test": "https://github.com/dapphub/ds-test#cd98eff28324bfac652e63a239a60632a761790b",
"forge-std": "https://github.com/foundry-rs/forge-std#705263c95892a906d7af65f0f73ce8a4a0c80b80"
},
"devDependencies": {
"@types/node": "^20.3.2"
}
}
2 changes: 2 additions & 0 deletions packages/protocol-rewards/remappings.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ds-test/=node_modules/ds-test/src/
forge-std/=node_modules/forge-std/src/
37 changes: 37 additions & 0 deletions packages/protocol-rewards/script/Deploy.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.17;

import "./ScriptBase.sol";

import {console2} from "forge-std/console2.sol";

import {ProtocolRewards} from "../src/ProtocolRewards.sol";

contract DeployScript is ScriptBase {
function run() public {
vm.startBroadcast(deployer);

// ProtocolRewards protocolRewards = new ProtocolRewards();

bytes memory creationCode = type(ProtocolRewards).creationCode;

bytes32 salt = bytes32(0x0000000000000000000000000000000000000000668d7f9eb18e35000dbaaa0f);

console2.log("creation code hash");
bytes32 creationCodeHash = keccak256(creationCode);
console2.logBytes32(creationCodeHash);

// Assert to ensure bytecode has not changed
assert(bytes32(0xfa8c14fa41eb1f11f85062d699fe173e7ae3c1e988f0fa4c1846ac7948b6c471) == creationCodeHash);

// Sanity check for address
assert(IMMUTABLE_CREATE2_FACTORY.findCreate2Address(salt, creationCode) == address(0x7777777F279eba3d3Ad8F4E708545291A6fDBA8B));

address result = IMMUTABLE_CREATE2_FACTORY.safeCreate2(salt, creationCode);

console2.log("PROTOCOL REWARDS DEPLOYED:");
console2.logAddress(address(result));

vm.stopBroadcast();
}
}
24 changes: 24 additions & 0 deletions packages/protocol-rewards/script/ScriptBase.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import {Script} from "forge-std/Script.sol";

interface ImmutableCreate2Factory {
function findCreate2Address(bytes32 salt, bytes memory initCode) external view returns (address deploymentAddress);

function findCreate2AddressViaHash(bytes32 salt, bytes32 initCodeHash) external view returns (address deploymentAddress);

function hasBeenDeployed(address deploymentAddress) external view returns (bool);

function safeCreate2(bytes32 salt, bytes memory initializationCode) external payable returns (address deploymentAddress);
}

contract ScriptBase is Script {
address deployer;

ImmutableCreate2Factory constant IMMUTABLE_CREATE2_FACTORY = ImmutableCreate2Factory(0x0000000000FFe8B47B3e2130213B802212439497);

function setUp() public {
deployer = vm.envAddress("deployer");
}
}
Loading

0 comments on commit 38fc9af

Please sign in to comment.