Skip to content

Commit

Permalink
Monorepo (#244)
Browse files Browse the repository at this point in the history
First step of migrating to a monorepo:
* 1155 contracts moved into a yarn workspace, at `packages/1155-contracts`
* Added turborepo for the build/test/other ci task pipelines
* Updated github workflows to account for running tasks using turborepo pipelines
* added readme to root
  • Loading branch information
oveddan authored Oct 12, 2023
1 parent 00108ed commit 0b66e9d
Show file tree
Hide file tree
Showing 175 changed files with 913 additions and 140 deletions.
20 changes: 12 additions & 8 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,23 +26,22 @@ jobs:
uses: ./.github/actions/setup_deps

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

- name: Setup LCOV
uses: hrishikesh-kadam/setup-lcov@v1

- name: Filter files to ignore
run: |
lcov --rc lcov_branch_coverage=1 \
cd ./${{ env.package_folder }} && lcov --rc lcov_branch_coverage=1 \
--remove lcov.info \
--output-file lcov.info "*node_modules*" "*test*" "*script*" "*DeploymentConfig*" "*Redeem*" "*deployment*"
- name: Report code coverage
uses: zgosalvez/github-actions-report-lcov@v2
with:
coverage-files: lcov.info
coverage-files: ./${{ env.package_folder }}/lcov.info
minimum-coverage: 89
artifact-name: code-coverage-report
github-token: ${{ secrets.GITHUB_TOKEN }}
working-directory: ./
working-directory: ./${{ env.package_folder }}
54 changes: 32 additions & 22 deletions .github/workflows/foundry.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
name: Foundry
name: "Foundry"

on: push
on: "push"

env:
# Setting an environment variable with the value of a configuration variable
$build_artifact: foundry_artifact

jobs:
build:
name: Build and cache
name: Build contracts and cache output
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -14,23 +18,23 @@ jobs:

- name: Build contracts
run: |
forge build
npx turbo run build:contracts
- name: Archive built artifacts
uses: actions/upload-artifact@v3
with:
name: foundry-built-artifacts
name: $build_artifact
path: |
cache
out
**/*/cache
**/*/out
retention-days: 1

contract_size_check:
needs: build
strategy:
fail-fast: true

name: Contract Size Check
name: Check contract sizes
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -41,18 +45,18 @@ 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
npx turbo run build:sizes
test:
needs: build
strategy:
fail-fast: true

name: Test
name: Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -63,18 +67,18 @@ jobs:
- name: Download foundry artifacts
uses: actions/download-artifact@v3
with:
name: foundry-built-artifacts
name: $build_artifact

- name: Run Forge tests
- name: Run tests
run: |
forge test -vvv
npx turbo run test
test_fork:
needs: build
strategy:
fail-fast: true

name: Fork Tests
name: Fork tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -85,11 +89,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
npx turbo run 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,18 +114,18 @@ 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: npx turbo run storage-inspect:check

build_js:
needs: build
strategy:
fail-fast: true

name: Build JS Package
name: Build js package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -132,8 +136,14 @@ 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
npx turbo run prepack
coverage-1155:
uses: ./.github/workflows/coverage.yml
name: "1155 contracts coverage"
with:
package: "1155-contracts"
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
9 changes: 7 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ out/
docs/

# Dotenv file
.env
**/*.env

# yarn error
yarn-error.log
Expand All @@ -23,7 +23,7 @@ yarn-error.log
.DS_Store

# npm
node_modules/
**/*node_modules/

# coverage info
lcov.info
Expand All @@ -40,3 +40,8 @@ package/chainConfigs.ts

# not currently using pnpm
pnpm-lock.yaml

# turbo
.turbo

**/*wagmiGenerated.ts
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
auto-install-peers = true
23 changes: 3 additions & 20 deletions DEVELOPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Deploying to a new chain

Within a contracts package folder (i.e. `packages/1155-contracts`):

1. Setup new `chainConfigs` file setting 1. fee recipient, and 2. owner for factory contracts
2. Generate signatures for deploying upgrade gate at a deterministic address and transfering ownership to the factory owner:

Expand All @@ -27,16 +29,8 @@
8. Add a changeset with `npx changeset`
9. Make PR with new addresses json files and changeset.

# Whats bundled in the published package

* `/package/wagmiGenerated.ts` - smart contract abis and deployment addresses
* `./package/chainConfigs.ts` - configuration of smart contracts by chainId

# Publishing the package; Generating changesets, versioning, building and Publishing.

Diagram of the deploying + publishing workflow:
![Deploying & Publishing Workflow](uml/generated/deployment.svg)

Publishing happens in the following steps:

* Some changes are made to the repo; this can include smart contract changes or additions, if smart contracts are changed, tests should be created or updated to reflect the changes.
Expand All @@ -50,15 +44,4 @@ Publishing happens in the following steps:

7. That version is merged into main along with the new versions.

8. The package is then published to npm with the command: `yarn publish-packages` and the package is published.

In a future version, the when the version branch is merged into main, it can publish the new repos to github.

Some active questions:

* How do we ensure the contract version matches the package version? Or does it need to match? Sometimes there is a js package update without a smart contract update.

Future ideas:

* Allow deployment to happen via github actions:
* Deployments can be added to changesets through some command. If a changeset is pushed to main and a deployment is detected in it, a deployment task is added to the PR that's created. When that PR is merged, the deployment happens, and a new package is built and published to npm with the new versions.
8. The package is then published to npm with the command: `yarn publish-packages` and the package is published.
47 changes: 28 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,42 @@
# ZORA 1155 Contracts
# Zora Protcool

The Zora Creator 1155 Contracts are the 1155 complement to the Zora 721 Drops Contracts. While the 721 Drops Contracts enable creators to mint unique, non-fungible tokens (NFTs), the 1155 Contracts allow creators to mint semi-fungible tokens with a set of flexible properties.
This repository is a monorepo for the Protcol

The main implementation of the Zora Creator 1155 Contracts includes the following modules:
In it you will find:

- Metadata Control
- Royalties Control
- Minting Control
- Permissions Control
- Royalties Controls

Most controls exist on a per-contract and per-token level. Per contract level is defined as any configuration existing in the pre-reserved 0 token space.
- [Zora 1155 Contracts](./packages/1155-contracts)

## Official docs

[View the official docs](https://docs.zora.co/docs/smart-contracts/creator-tools/Deploy1155Contract)
[View the official docs](https://docs.zora.co/docs/smart-contracts/creator-tools/intro)

## Bug Bounty
## Setup

5 ETH for any critical bugs that could result in loss of funds. Rewards will be given for smaller bugs or ideas.
Install prerequisites:

* [Node.js and yarn](https://classic.yarnpkg.com/lang/en/docs/install/#mac-stable)
* [Foundry](https://book.getfoundry.sh/getting-started/installation)

Install dependencies:

yarn

## Publishing a new version to npm
Build contracts:

Generate a new changeset in your branch with:
yarn build

npx changeset
Run tests:

When the branch is merged to main, the versions will be automatically updated in the corresponding packages.
yarn test

Run in development mode (watch tests):

yarn dev

## Bug Bounty

5 ETH for any critical bugs that could result in loss of funds. Rewards will be given for smaller bugs or ideas.

To publish the updated version:
## Development workflow

yarn publish-packages
See [DEVELOPMENT.md](./DEVELOPMENT.md)
Loading

0 comments on commit 0b66e9d

Please sign in to comment.