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
22 changes: 22 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!--
Thank you for your pull request. Please describe it below.

The Solidity in src/ is compiled into the deployed Seaport 1.6 bytecode, so
changes to it are not accepted.

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 the change. If your PR solves a
particular issue, tag that issue.
-->

## Solution

<!--
Summarize the solution and provide any context needed to understand the change.
-->
25 changes: 19 additions & 6 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
name: Publish Package to npmjs
name: Publish package to npm

on:
release:
types: [created]

permissions:
contents: read

jobs:
build:
publish:
runs-on: ubuntu-latest
timeout-minutes: 10
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: 26
registry-url: "https://registry.npmjs.org"
- run: npm publish --access public

- run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
45 changes: 23 additions & 22 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
name: Auto-tag commit with YY-MM-DD/branchname
name: Tag commit with YY-MM-DD-branch

on:
push:
branches:
- main
- dev

# One tag push per branch at a time. Runs can still start out of order, so the
# step below also skips any commit that is no longer the branch tip.
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 # push the tag
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
- name: Delete tag if exists
# A second push to the branch on the same day moves the tag to the
# newer commit.
- name: Tag commit
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 }}
tip="$(git ls-remote origin "refs/heads/${GITHUB_REF_NAME}" | cut -f1)"
if [ "$tip" != "$GITHUB_SHA" ]; then
echo "$GITHUB_SHA is no longer the tip of $GITHUB_REF_NAME ($tip); skipping."
exit 0
fi
- name: Tag commit with YY-MM-DD-branchname
run: |
git tag ${{ steps.tag.outputs.tag }}
git push --tags --force
tag="$(date -u +%y-%m-%d)-${GITHUB_REF_NAME}"
git tag --force "$tag"
git push --force origin "refs/tags/$tag"
87 changes: 69 additions & 18 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,85 @@
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 main 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
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

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

- name: Run forge build
run: forge build --sizes

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

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
- uses: ./.github/actions/setup-foundry
with:
version: nightly
version: ${{ env.FOUNDRY_VERSION }}

- name: Run Forge build
# 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:
path: .tools
key: tools-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('scripts/install-tools.sh') }}

- 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-contracts.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
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@ docs/

# Dotenv file
.env
.*

# Pinned lint tools from scripts/install-tools.sh
.tools/

.DS_Store
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 = " "
21 changes: 21 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# seaport-types

Structs, enums, interfaces, errors, and constants for Seaport 1.6. [seaport-core](https://github.com/ProjectOpenSea/seaport-core) and [seaport](https://github.com/ProjectOpenSea/seaport) import them, and they are published to npm as `seaport-types`.

## Rule

Never change a `.sol` file in `src/`, not even whitespace. seaport-core compiles this source into the deployed Seaport 1.6 bytecode, and `scripts/frozen-contracts.sha256` fails CI if any of it changes. `foundry.toml` and `lefthook.yml` keep `forge fmt` and `forge lint` off `src/`.

## Commands

Foundry v1.9.0.

```bash
forge build
scripts/install-tools.sh # pinned Biome, taplo, lefthook, shellcheck, shfmt, actionlint
scripts/lint.sh check # or fix
```

## Publishing

Creating a GitHub release runs `.github/workflows/publish.yml`, which publishes the package to npm with provenance. Bump `version` in `package.json` first. The package has no dependencies; keep it that way.
48 changes: 39 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,52 @@
# seaport-types

[![Version][version-badge]][version-link]
[![npm][npm-badge]][npm-link]

This repo contains the core Seaport structs, enums, and interfaces for use in other Seaport repos.
Structs, enums, interfaces, errors, and constants for [Seaport][seaport] 1.6. [seaport-core][seaport-core] compiles them into the deployed Seaport contract, and other Seaport repos and integrations import them.

For more information on Seaport, see the [main Seaport repo][seaport].
The source in `src/` matches the deployed Seaport 1.6 bytecode and does not change.

Related repositories:
## Install

- [seaport-core][seaport-core]
- [seaport-sol][seaport-sol]
With npm:

```bash
npm install seaport-types
```

Then import from `seaport-types/src/...`.

As a Foundry submodule:

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

Then add the remapping `seaport-types/=lib/seaport-types/`.

## Development

Install [Foundry](https://getfoundry.sh) v1.9.0, then:

```bash
forge build
scripts/install-tools.sh # once: pinned lint tools into .tools/bin
scripts/lint.sh check # or fix
.tools/bin/lefthook install # optional pre-commit hook
```

`scripts/install-tools.sh` downloads each tool from its GitHub release and checks it against a pinned SHA-256, so linting needs nothing from npm.

## Related repositories

- [seaport][seaport]: tests, docs, and the deployed `Seaport` wrapper
- [seaport-core][seaport-core]: the core Seaport 1.6 contracts
- [seaport-js][seaport-js]: TypeScript library for Seaport
- [seaport-sol][seaport-sol]: Solidity helpers for building Seaport orders in Forge scripts and tests

[seaport]: https://github.com/ProjectOpenSea/seaport
[seaport-core]: https://github.com/ProjectOpenSea/seaport-core
[seaport-types]: https://github.com/ProjectOpenSea/seaport-types
[seaport-js]: https://github.com/ProjectOpenSea/seaport-js
[seaport-sol]: https://github.com/ProjectOpenSea/seaport-sol
[version-badge]: https://img.shields.io/github/package-json/v/ProjectOpenSea/seaport-types
[version-link]: https://github.com/ProjectOpenSea/seaport-types/releases
[npm-badge]: https://img.shields.io/npm/v/seaport-types?color=red
[npm-link]: https://www.npmjs.com/package/seaport-types
20 changes: 20 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"$schema": "https://biomejs.dev/schemas/2.6.3/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"includes": ["**", "!!**/lib", "!!**/out", "!!**/cache", "!!**/broadcast"]
},
"formatter": {
"indentStyle": "space",
"indentWidth": 2
},
"linter": {
"rules": {
"preset": "recommended"
}
}
}
Loading
Loading