Skip to content
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
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 2

[*.{sol,sh,toml}]
indent_size = 4
37 changes: 37 additions & 0 deletions .github/actions/setup-foundry/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Set up Foundry
description: >-
Install a pinned Foundry version, reusing a cached copy so a GitHub releases
outage doesn't fail the job.

inputs:
version:
description: The Foundry version to install, such as v1.9.0.
required: true

runs:
using: composite
steps:
- name: Restore Foundry
id: cache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
# foundryup installs the binaries under versions/ and links them
# from bin/, so both are cached.
path: |
~/.foundry/bin
~/.foundry/versions
key: foundry-install-${{ runner.os }}-${{ inputs.version }}

- name: Install Foundry
if: steps.cache.outputs.cache-hit != 'true'
uses: foundry-rs/foundry-toolchain@dba66c27052e63476d886f22216e119ba7e615bf # v1.9.2
with:
version: ${{ inputs.version }}

- name: Add Foundry to PATH
shell: bash
run: echo "$HOME/.foundry/bin" >>"$GITHUB_PATH"

- name: Print Foundry version
shell: bash
run: forge --version
28 changes: 28 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!--
Borrowed from foundry.

Thank you for your Pull Request. Please provide a description above and review
the requirements below.

Bug fixes and new features should include tests.

Do not report security vulnerabilities in a public pull request or issue. Use
https://bugcrowd.com/engagements/opensea instead.
-->

## Motivation

<!--
Explain the context and why you're making that change. What is the problem
you're trying to solve? In some cases there is not a problem and this can be
thought of as being the motivation for your change.

If your PR solves a particular issue, tag that issue.
-->

## Solution

<!--
Summarize the solution and provide any necessary context needed to understand
the code change.
-->
22 changes: 17 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
name: Publish Package to npmjs

on:
release:
types: [created]

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
id-token: write # npm provenance
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
node-version: "16.x"
persist-credentials: false
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version-file: .nvmrc
registry-url: "https://registry.npmjs.org"
- run: yarn
- run: npm publish --access public
# Installs seaport-types from npm, pinned by yarn.lock.
- run: yarn install --frozen-lockfile
- run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
38 changes: 23 additions & 15 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,40 @@ on:
- main
- dev

# Pushes to the same branch tag in order, so the newest commit gets the tag.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false

permissions:
contents: write
contents: read

jobs:
jobs:
tag-commit:
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Get current date
run: echo "::set-output name=date::$(date +%y-%m-%d)"
id: date
- name: Get branch name
run: echo "::set-output name=branch::${GITHUB_REF#refs/heads/}"
id: branch
- name: Create tag string
run: echo "::set-output name=tag::${{ steps.date.outputs.date }}-${{ steps.branch.outputs.branch }}"
id: tag
run: echo "tag=$(date +%y-%m-%d)-${GITHUB_REF#refs/heads/}" >> "$GITHUB_OUTPUT"

- name: Delete tag if exists
env:
TAG: ${{ steps.tag.outputs.tag }}
run: |
if git rev-parse --verify --quiet ${{ steps.tag.outputs.tag }}; then
git tag -d ${{ steps.tag.outputs.tag }}
git push --delete origin ${{ steps.tag.outputs.tag }}
if git rev-parse --verify --quiet "$TAG"; then
git tag -d "$TAG"
git push --delete origin "$TAG"
fi

- name: Tag commit with YY-MM-DD-branchname
env:
TAG: ${{ steps.tag.outputs.tag }}
run: |
git tag ${{ steps.tag.outputs.tag }}
git push --tags --force
git tag "$TAG"
git push --force origin "refs/tags/$TAG"
90 changes: 73 additions & 17 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,90 @@
name: test

on: workflow_dispatch
on:
push:
branches: [main]
pull_request:
workflow_dispatch:

# A new push to a pull request cancels its older run. Every other run gets
# its own group, so no run on a branch is cancelled while it waits.
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.ref || github.run_id }}
cancel-in-progress: true

permissions:
contents: read

env:
FOUNDRY_PROFILE: ci
FOUNDRY_VERSION: v1.9.0

jobs:
check:
strategy:
fail-fast: true
build:
name: Build and check deployed bytecode
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
submodules: recursive
persist-credentials: false

- uses: ./.github/actions/setup-foundry
with:
version: ${{ env.FOUNDRY_VERSION }}

- name: Build
run: forge build --sizes

name: Foundry project
- name: Check the build matches deployed Seaport 1.6
run: scripts/check-deployed-bytecode.sh

lint:
name: Run linters
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
submodules: recursive
persist-credentials: false

- uses: ./.github/actions/setup-foundry
with:
version: ${{ env.FOUNDRY_VERSION }}

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
# The tools are pinned by version and SHA-256 in the install script, so
# the cache only skips downloads.
- name: Restore tools
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
version: nightly
path: .tools
key: tools-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('scripts/install-tools.sh') }}

- name: Run Forge build
- name: Install tools
run: |
forge --version
forge build --sizes
id: build
scripts/install-tools.sh
echo "$PWD/.tools/bin" >> "$GITHUB_PATH"

- name: Check src is unchanged
run: shasum -a 256 --check --quiet scripts/frozen-src.sha256

- name: Check Solidity formatting
run: forge fmt --check

- name: Run Forge tests
- name: Lint Solidity
run: forge lint --deny warnings

- name: Check formatting and lint with Biome
run: biome ci .

- name: Check TOML formatting
run: taplo fmt --check

- name: Lint shell scripts
run: |
forge test -vvv
id: test
shellcheck scripts/*.sh
shfmt -d scripts/*.sh

- name: Lint workflows
run: actionlint
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Dependencies, installed for npm publishing
node_modules/

# Compiler files
cache/
out/
Expand All @@ -13,4 +16,7 @@ docs/
# Dotenv file
.env

.DS_Store
.DS_Store

# Pinned lint tools from scripts/install-tools.sh
.tools/
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
26
4 changes: 4 additions & 0 deletions .taplo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include = ["*.toml"]

[formatting]
indent_string = " "
24 changes: 24 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# seaport-core

The Seaport 1.6 contracts, without tests or helpers. Canonical Seaport 1.6 at `0x0000000000000068F116a894984e2DB1123eB395` was built from `src/` with the settings in `foundry.toml`. Tests, docs, and deployment steps live in [seaport](https://github.com/ProjectOpenSea/seaport), which pulls this repo in as `lib/seaport-core`.

## Rule

The source must keep building the deployed bytecode. Don't change any file under `src/` (not even whitespace), the `lib/seaport-types` pin, or any compiler setting in `foundry.toml`. `scripts/check-deployed-bytecode.sh` fails if the build stops matching the canonical init code, and `scripts/frozen-src.sha256` fails lint if a file in `src/` changes.

`src/conduit/ConduitController.sol` differs from the deployed ConduitController at `0x00000000F9490004C11Cef243f5400493c00Ad63`, which was built from seaport 1.1. Leave it as is.

## Commands

Foundry v1.9.0, submodules checked out recursively.

```bash
forge build
scripts/check-deployed-bytecode.sh # needs jq
scripts/install-tools.sh # pinned Biome, taplo, lefthook, shellcheck, shfmt, actionlint
scripts/lint.sh check
```

## npm

The package is published to npm as `seaport-core` when a GitHub release is created (`.github/workflows/publish.yml`). It ships `src/` and depends on the `seaport-types` npm package, whose version matches the `lib/seaport-types` pin. Bump `version` in `package.json` before a release, and keep `files` as it is so the published layout stays the same.
41 changes: 34 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,46 @@
[![Version][version-badge]][version-link]
[![npm][npm-badge]][npm-link]

This repo contains the core Seaport smart contracts (with no reference contracts, helpers, or tests) and is meant to facilitate building on Seaport without needing to grapple with long compile times or other complications.
The core Seaport 1.6 contracts, with no reference contracts, helpers, or tests. Build on Seaport from here without the long compile times of the [main Seaport repo][seaport].

For more information on Seaport, see the [main Seaport repo][seaport].
Canonical Seaport 1.6 is deployed at `0x0000000000000068F116a894984e2DB1123eB395` on every supported chain, built from `src/` with the settings in `foundry.toml`. CI checks that the build still matches the deployed init code.

Related repositories:
## Install

- [seaport-types][seaport-types]
- [seaport-sol][seaport-sol]
With Foundry:

```bash
forge install ProjectOpenSea/seaport-core
```

With npm:

```bash
npm install seaport-core
```

## Development

```bash
git submodule update --init --recursive
forge build
scripts/check-deployed-bytecode.sh
scripts/install-tools.sh && scripts/lint.sh check
```

The source in `src/` is frozen. See [AGENTS.md](AGENTS.md).

## More

- [Seaport docs][seaport-docs]
- [Deployments][seaport-deployments], and [deploying to a new chain][seaport-deploying]
- [seaport-types][seaport-types], the interfaces, structs, and constants Seaport uses

[seaport]: https://github.com/ProjectOpenSea/seaport
[seaport-core]: https://github.com/ProjectOpenSea/seaport-core
[seaport-docs]: https://github.com/ProjectOpenSea/seaport/blob/main/docs/SeaportDocumentation.md
[seaport-deployments]: https://github.com/ProjectOpenSea/seaport/blob/main/docs/Deployments.md
[seaport-deploying]: https://github.com/ProjectOpenSea/seaport/blob/main/docs/Deploying.md
[seaport-types]: https://github.com/ProjectOpenSea/seaport-types
[seaport-sol]: https://github.com/ProjectOpenSea/seaport-sol
[version-badge]: https://img.shields.io/github/package-json/v/ProjectOpenSea/seaport-core
[version-link]: https://github.com/ProjectOpenSea/seaport-core/releases
[npm-badge]: https://img.shields.io/npm/v/seaport-core?color=red
Expand Down
Loading
Loading