Skip to content

Commit

Permalink
moved 1155 stuff into a folder
Browse files Browse the repository at this point in the history
  • Loading branch information
oveddan committed Oct 6, 2023
1 parent 3f838de commit ac82b0c
Show file tree
Hide file tree
Showing 50 changed files with 5,129 additions and 31 deletions.
20 changes: 13 additions & 7 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
name: coverage

on: push
on:
workflow_call:
inputs:
package:
required: true
type: string

env:
# Setting an environment variable with the value of a configuration variable
package_folder: packages/${{ inputs.package }}
FOUNDRY_PROFILE: ci

jobs:
Expand All @@ -21,15 +26,16 @@ jobs:
uses: ./.github/actions/setup_deps

- name: Run Forge coverage
run: yarn run coverage
id: build
run: cd $package_folder && forge coverage

- name: Setup LCOV
uses: hrishikesh-kadam/setup-lcov@v1
with:
working-directory: ./$package_folder

- name: Filter files to ignore
run: |
lcov --rc lcov_branch_coverage=1 \
cd $package_folder && lcov --rc lcov_branch_coverage=1 \
--remove lcov.info \
--output-file lcov.info "*node_modules*" "*test*" "*script*" "*DeploymentConfig*" "*Redeem*" "*deployment*"
Expand All @@ -40,4 +46,4 @@ jobs:
minimum-coverage: 89
artifact-name: code-coverage-report
github-token: ${{ secrets.GITHUB_TOKEN }}
working-directory: ./
working-directory: ./$package_folder
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
name: Foundry

on: push
on:
workflow_call:
inputs:
package:
required: true
type: string

env:
# Setting an environment variable with the value of a configuration variable
package_folder: packages/${{ inputs.package }}
build_artifact: foundry-built-artifacts-${{ inputs.package }}

jobs:
build:
Expand All @@ -14,17 +22,22 @@ jobs:

- name: Build contracts
run: |
forge build
cd $package_folder && forge build
- name: Archive built artifacts
uses: actions/upload-artifact@v3
with:
name: foundry-built-artifacts
name: $build_artifact
path: |
cache
out
packages/${{ inputs.package }}/cache
packages/${{ inputs.package }}/out
retention-days: 1

coverage:
uses: ./.github/workflows/coverage.yml
with:
package: ${{ inputs.package }}

contract_size_check:
needs: build
strategy:
Expand All @@ -41,11 +54,11 @@ jobs:
- name: Download foundry artifacts
uses: actions/download-artifact@v3
with:
name: foundry-built-artifacts
name: $build_artifact

- name: Check contract sizes
run: |
forge build --sizes
cd $package_folder && forge build --sizes
test:
needs: build
Expand All @@ -63,11 +76,11 @@ jobs:
- name: Download foundry artifacts
uses: actions/download-artifact@v3
with:
name: foundry-built-artifacts
name: $build_artifact

- name: Run Forge tests
run: |
forge test -vvv
cd $package_folder && forge test -vvv
test_fork:
needs: build
Expand All @@ -85,11 +98,11 @@ jobs:
- name: Download foundry artifacts
uses: actions/download-artifact@v3
with:
name: foundry-built-artifacts
name: $build_artifact

- name: Run fork tests
run: |
forge test -vvv --match-test fork
cd $package_folder && forge test -vvv --match-test fork
env:
FORK_TEST_CHAINS: mainnet,goerli,optimism,optimism_goerli,zora,zora_goerli,base_goerli,base
ALCHEMY_KEY: ${{ secrets.ALCHEMY_KEY }}
Expand All @@ -110,11 +123,11 @@ jobs:
- name: Download foundry artifacts
uses: actions/download-artifact@v3
with:
name: foundry-built-artifacts
name: $build_artifact

- name: "Inspect Storage Layout"
continue-on-error: false
run: yarn run storage-inspect:check
run: cd $package_folder && yarn run storage-inspect:check

build_js:
needs: build
Expand All @@ -132,8 +145,8 @@ jobs:
- name: Download foundry artifacts
uses: actions/download-artifact@v3
with:
name: foundry-built-artifacts
name: $build_artifact

- name: Build js package
run: |
yarn prepack
cd $package_folder && yarn prepack
14 changes: 14 additions & 0 deletions .github/workflows/foundry-by-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Foundry

on: push

jobs:
# we need to prepend _ to conform to 1155 standards
_1155:
uses: ./.github/workflows/foundry-base.yml
with:
package: "1155-contracts"
protocol-rewards:
uses: ./.github/workflows/foundry-base.yml
with:
package: "protocol-rewards"
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ jobs:
uses: ./.github/actions/setup_deps

- name: Run prettier
run: yarn run prettier:check
run: yarn lint
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
auto-install-peers = true
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"repository": "[email protected]:ourzora/zora-contracts.git",
"scripts": {
"build": "turbo run build",
"test": "turbo run test",
"dev": "turbo run dev",
"lint": "turbo run lint",
"format": "prettier --write \"**/*.{ts,tsx,md}\""
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
4 changes: 3 additions & 1 deletion packages/1155-contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
"test-gas": "forge test --gas-report",
"prettier:check": "prettier --check 'src/**/*.sol' 'test/**/*.sol' 'package/**/*.ts' 'wagmi.config.ts'",
"prettier": "prettier --write 'src/**/*.sol' 'test/**/*.sol' 'package/**/*.ts' 'script/**/*.ts' 'wagmi.config.ts'",
"lint": "yarn run prettier:check",
"coverage": "forge coverage --report lcov",
"write-gas-report": "forge test --gas-report > gasreport.ansi",
"prepack": "yarn wagmi && yarn bundle-configs && yarn build",
"update-new-deployment-addresses": "node script/copy-deployed-contracts.mjs deploy",
"update-contract-version": "node script/update-contract-version.mjs",
"build:contracts": "forge build",
"build": "tsup",
"bundle-configs": "node script/bundle-chainConfigs.mjs && yarn prettier",
"wagmi": "wagmi generate",
Expand All @@ -42,7 +44,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
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
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
24 changes: 24 additions & 0 deletions packages/protocol-rewards/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "@zoralabs/protocol-rewards",
"version": "1.2.1",
"repository": "https://github.com/ourzora/protocol-rewards.git",
"license": "MIT",
"files": [
"src/",
"_imagine"
],
"scripts": {
"build": "forge build",
"test": "forge test",
"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 ac82b0c

Please sign in to comment.