Repository navigation
Fix v2 contract bugs found by the Forge port and restore coverage - #195
Merged
Merged
Conversation
Replace the six overlapping helper files left by the Hardhat port with SeaDropTest (Seaport plumbing, signing, merkle proofs, array helpers), SeaDrop721Test and SeaDrop1155Test (order building, allow lists, signed mints, offerer fixtures). Move the legacy storage-built order tests and the gas snapshots onto the shared builders, assert the SeaDrop error behind each InvalidContractOrder, and drop comments that only described the old Hardhat specs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The error buffer checks shifted left by 254, 252 and 253, which keep several low bits instead of one, so a bad minimumReceived reported UnsupportedExtraDataVersion, a bad substandard reported InvalidExtraDataEncoding, and InvalidSubstandard and MustSpecifyERC1155ConsiderationItemForSeaDropMint were unreachable. Test one bit each, in the order version, encoding, substandard, minimumReceived. Read the version and substandard bytes only when the context holds them, and the 721 minimumReceived item only when there is exactly one, so a context under 2 bytes or an empty minimumReceived reverts with the decoding error instead of an index-out-of-bounds panic. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MintQuantityExceedsMaxMintedPerWalletForTokenId reported the quantity plus the wallet's mints across all token ids, while the check used the wallet's mints of that token id. Report the per-token value. The wallet limit compared each non-final offer item's own quantity and only the last item's running total. Compare the running total of the order's items at every item and report it, so the error names the amount that crossed maxTotalMintableByWallet. Which orders pass is unchanged; only the error and its argument for a failing order differ. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Nothing disabled initialize on the implementation contract, so a standalone deployment could be initialized (and owned) by anyone. The factory initialized its own copy in the constructor, which left the factory as its owner. Call _disableInitializers in the constructor instead; clones don't run it, so they still initialize once. Drop the factory's initialize call, which now reverts, and the unprotected-initializer lint exclusion, which lint no longer needs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tokenURI mapped token t to ((t + offset) % maxSupply) + 1, so an offset of maxSupply - 1 left every token on its own metadata and a shift by 1 was unreachable. Subtract the start token id first, so the stored offset (1 to maxSupply - 1, uniform) is the shift itself and never the identity. A max supply of 1 divided by zero and a max supply of 0 underflowed. Reveal a single token without an offset, and treat a zero max supply as not fully minted, since revealing it would lock the offset. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SeaDropTest inherited Seaport's BaseOrderTest, whose coverage branch compiles seaport-core's OrderCombiner, which is stack too deep without the optimizer, so forge coverage could not build. The tests only used its Seaport deployment, conduit, signOrder, toOrderComponents and bob. Deploy Seaport and the conduit from the optimized artifacts directly, add those helpers and the token receivers, and inherit forge-std's Test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Build the Seaport artifacts the tests deploy, skip Seaport's sources (symlinked into src/) so the coverage build doesn't compile its OrderCombiner, and use --ir-minimum since the 1155 implementation is stack too deep without the optimizer. Upload to Coveralls only from ProjectOpenSea/seadrop, as on main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The owner and configurer mint path minted any quantity, so a collection could end up past its max supply (and a RandomOffset collection could then never reveal). Revert with MintQuantityExceedsMaxSupply, as mint orders and the 1155 token already do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ITransferValidator721.validateTransfer is view and the 1155 one is not, but getTransferValidationFunction reported the opposite. Return true for 721 and false for 1155 (and the 1155 clone), matching ERC721C and ERC1155C. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A public mint order carries its public drop index as one byte, but updatePublicDrop accepted any uint256 index, so a drop above 255 could be configured and never minted. Revert with a new InvalidPublicDropIndex(index) error instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
_decodeOrder only required the 42 bytes every substandard shares (43 for 1155 public mints), so an allow list or signed mint context too short for its mint params, salt or signature reverted with no reason from an out-of-bounds slice. Require each substandard's full length (721: 362 and 458 bytes, 1155: 458 and 554) and revert with InvalidExtraDataEncoding otherwise. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tokenURI wraps at the max supply, so raising it after setRandomOffset reshuffled the revealed metadata. Revert setMaxSupply (directly or through the configurer) with AlreadyRevealed after the reveal. The base setMaxSupply becomes public virtual so the extension can override it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
src/shim only existed to make Hardhat compile structs for typechain, and src/seaport-contracts (a symlink to lib/seaport/contracts) only to compile Seaport for the Hardhat tests. Nothing imports either now that the Forge tests deploy Seaport from its artifacts. Remove them, the fmt, lint and lefthook ignores and the coverage --skip they needed (which also ends forge lint's "AST source not found" warnings), and regenerate .gas-snapshot, which was one stale line and is stable across runs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Same as main: Test CI only reads the repo; the stale job writes to issues and PRs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🔵 Needs a closer look
An owner must resolve the CREATE2 salt/address decision and verify existing chain deployments because the factory bytecode changes while the deployment script still requires the old vanity address.
No open issues 🎉
What changed in this PR
This PR fixes v2 contract issues exposed by the Forge migration in #192 and restores coverage reporting. It also consolidates test helpers and removes obsolete Hardhat support files.
Changes:
- Corrects order-validation errors, wallet-limit reporting, supply enforcement, transfer-validation flags, clone initialization, and random-offset reveals.
- Consolidates Forge helpers and adds regression tests for the corrected behavior.
- Restores Forge coverage uploads, limits workflow permissions, and refreshes gas snapshots.
| File | Description |
|---|---|
test/foundry/utils/SeaDrop721Test.sol |
Consolidates ERC721 mint helpers and offerer fixtures. |
test/foundry/utils/SeaDrop721MintHelpers.sol |
Removes redundant ERC721 mint helpers. |
test/foundry/utils/SeaDrop1155MintHelpers.sol |
Removes redundant ERC1155 mint helpers. |
test/foundry/utils/ContractOfferer721Helpers.sol |
Removes superseded ERC721 offerer helpers. |
test/foundry/utils/ContractOfferer1155Helpers.sol |
Removes superseded ERC1155 offerer helpers. |
test/foundry/TokenTransferValidator.t.sol |
Tests corrected validation flags, including clones. |
test/foundry/SeaDropSnapshot.t.sol |
Migrates gas benchmarks to consolidated helpers. |
test/foundry/ERC721SeaDropRandomOffset.t.sol |
Tests reveal boundaries, rotation, and supply locking. |
test/foundry/ERC721SeaDropMintSigned.t.sol |
Adopts shared signed-mint helpers and assertions. |
test/foundry/ERC721SeaDropMintPublic.t.sol |
Updates error assertions and merges zero-quantity tests. |
test/foundry/ERC721SeaDropMintAllowList.t.sol |
Adopts shared allow-list helpers. |
test/foundry/ERC721SeaDropContractOfferer.t.sol |
Adds owner-mint supply and payer-authorization checks. |
test/foundry/ERC721SeaDrop.t.sol |
Strengthens revert assertions and fixes signed-order reuse. |
test/foundry/ERC721ContractMetadata.t.sol |
Migrates metadata tests to consolidated helpers. |
test/foundry/ERC1155SeaDropMintPublic.t.sol |
Separates fee-recipient and malformed-context cases. |
test/foundry/ERC1155SeaDropCloneFactory.t.sol |
Tests implementation locking and clone initialization. |
test/foundry/ERC1155SeaDrop.t.sol |
Asserts precise mint errors and fixes signed-order reuse. |
test/foundry/ERC1155ContractMetadata.t.sol |
Migrates metadata tests to consolidated helpers. |
src/shim/Shim2.sol |
Removes obsolete ERC1155 type-generation shim. |
src/shim/Shim.sol |
Removes obsolete Hardhat compilation shim. |
src/lib/ERC721SeaDropContractOffererImplementation.sol |
Corrects decoding checks and error precedence. |
src/lib/ERC721SeaDropContractOfferer.sol |
Enforces max supply for owner-configured mints. |
src/lib/ERC721ContractMetadata.sol |
Enables supply overrides and corrects the validator view flag. |
src/lib/ERC1155SeaDropErrorsAndEvents.sol |
Adds the invalid public-drop index error. |
src/lib/ERC1155SeaDropContractOffererImplementation.sol |
Fixes decoding, drop-index validation, and wallet-limit reporting. |
src/lib/ERC1155ContractMetadata.sol |
Corrects the validator’s non-view flag. |
src/interfaces/IERC1155SeaDrop.sol |
Documents the one-byte public-drop index limit. |
src/extensions/ERC721SeaDropRandomOffset.sol |
Fixes metadata rotation and locks supply after reveal. |
src/clones/ERC1155SeaDropCloneFactory.sol |
Stops initializing the locked implementation. |
src/clones/ERC1155SeaDropCloneable.sol |
Disables implementation initialization in its constructor. |
src/clones/ERC1155ContractMetadataCloneable.sol |
Corrects the clone validator’s non-view flag. |
lefthook.yml |
Removes the obsolete Seaport path exclusion. |
foundry.toml |
Removes obsolete ignores and initializer lint suppression. |
.github/workflows/test.yml |
Restores coverage uploads and restricts token permissions. |
.github/workflows/stale.yml |
Sets explicit issue and pull-request permissions. |
.gas-snapshot |
Refreshes gas measurements for the expanded suite. |
Review effort: Balanced
ryanio
added a commit
that referenced
this pull request
Nov 6, 2026
## Motivation Same as the companion `main` PR: bump the libraries that never reach deployed bytecode and drop what nothing uses, ahead of the contract library bumps. ## Solution - **murky:** to v0.1.0, its latest release. - **create2-helpers:** v0.1.3 to v0.2.0, its latest release. forge-std is already v1.17.0. - **ERC721A-Upgradeable removed.** Nothing on `v2` imports this submodule. - **Remappings removed:** - `ds-test`, which forge-std 1.17 no longer bundles - `ERC721A-Upgradeable` - `seaport-sol`, `seaport-core` and `seaport-test-utils`: nothing imports them since #195 moved the tests to Seaport's prebuilt artifacts - **Kept:** `@rari-capital/solmate`, because the tests import Seaport's `TestERC20`, which still uses it. ## Verification - `forge test`: `Ran 20 test suites: 188 tests passed, 0 failed, 0 skipped`. `forge fmt --check`, `forge lint --deny warnings` and `biome ci .` pass. `show_headroom.sh` still prints 9495. - **Bytecode.** I built `src` before and after: all 46 contracts with code are byte-identical. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
ryanio
added a commit
that referenced
this pull request
Nov 7, 2026
## Motivation This prepares for deploying new clone factories and implementations with current contract libraries, as long as os2-core keeps working with them. The test-only libraries were bumped in #200; these are the libraries that compile into deployed bytecode. ## Solution | Library | Old | New | Notes | | --- | --- | --- | --- | | openzeppelin-contracts | 4.8.x master (June 2023) | v4.9.6 | Last 4.x. 5.x moves `Initializable` to an ERC-7201 slot, which would break existing clones, and needs solc 0.8.20+. The files we compile only differ in pragmas. | | openzeppelin-contracts-upgradeable | June 2023 snapshot | v4.9.6 | `Initializable` keeps its storage at slot 0. | | ERC721A | v4.2.3+12 | v4.3.0 | Adds spot minting. Its new `_spotMinted` storage slot shifts the standalone ERC-721 tokens' own variables down one slot; no v2 ERC-721 token is a clone or proxy. | | solady | a2fd11c (about v0.0.107) | v0.1.26 | Still compiles with solc 0.8.19, and the storage seeds for ERC1155, ERC2981 and Ownable are unchanged. | | seaport | 1.5 era main (June 2023) | `1.6` release tag | The version production mints through. `seaport-types` only gains errors we don't use. | What the bumps required: - **solady.** Solady made `ownershipHandoverValidFor()` internal. A small shared base, `src/lib/SeaDropOwnable.sol`, keeps it public with the same signature and value (48 hours), so the token ABIs lose nothing. ECDSA's compact `recover(hash, r, vs)` no longer rejects high-s signatures. Signed mints key replay protection on the digest, not the signature, so that opens no replay. - **Seaport 1.6.** - Its test artifacts use PUSH0, MCOPY and TSTORE, so `foundry.toml` sets `evm_version = 'cancun'` for the test EVM. solc 0.8.19 still compiles `src` for Paris: the artifact metadata says `paris`, and the bytecode is the same with and without the setting. - It bubbles a `generateOrder` revert up instead of wrapping it in `InvalidContractOrder`. The mint-revert helper now expects the SeaDrop error from both `previewOrder` and the fill, and the nested-fill test expects `NestedSeaportCall`. - **ERC721A 4.3.** Its new slot moves the transfer validator and lock flags from slot 8 to slot 9, and the lock-slot test follows. ## Verification - `forge test`: `Ran 26 test suites: 303 tests passed, 0 failed, 0 skipped`. `forge fmt --check`, `forge lint --deny warnings` and `biome ci .` pass. Coverage is 88.65% of lines. - **Storage.** `forge inspect` layouts for the 1155 cloneable, contract offerer and token are unchanged. A temporary differential test deployed the pre-bump factory and ran the same flow on four old/new clone and configurer pairings: init, `multiConfigure` with a mint, a Seaport mint, transfers, burns, approvals and an ownership handover. All 46 storage slots and all 28 events matched. - **ABI.** Nothing is removed and no `stateMutability` changes. All tokens add `AlreadyInitialized()`, and the 721 tokens add five ERC721A errors none of SeaDrop's settings can raise. The factory, both configurers and both implementations are unchanged. `supportsInterface` gives the same result for 20 interface IDs on the 1155 clone, `ERC1155SeaDrop` and `ERC721SeaDrop`. - **Sizes.** Everything stays under EIP-170, with less pressure on the tightest contract: | Contract | Before | After | | --- | --- | --- | | ERC1155SeaDropConfigurer | 24,214 | 24,176 | | ERC1155SeaDropCloneable | 18,014 | 18,068 | | ERC1155SeaDrop | 15,883 | 15,937 | | ERC721SeaDrop | 15,082 | 14,959 | - **os2-core.** Every v2 event topic in `EvmLogTopics` and the `SeaDropERC1155TokenV2` ABI match the new contracts. `createClone`, the configurer's `multiConfigure` and the `DropMintUtils` context encoding are unchanged. After the new factory deploys, `SeaportConfig.kt` needs the new factory address, with `0x00b19A52…` moved to the legacy list, and the new implementation's code hash: `0x092f5bdd…2319` at this commit; confirm it with `cast code | cast keccak` after deploy. ## Not in this PR - **v2 ERC-721 transfers stay `payable`.** `approve`, `transferFrom` and `safeTransferFrom` on v2 ERC-721 tokens were already `payable` before this bump, inherited from ERC721A 4.2.3+, so this PR doesn't change them. Making them non-payable belongs with the v2 ERC-721 prep. - **The 1155 factory deploy script.** `script/DeploySeaDrop1155CloneFactory.s.sol` still targets Seaport 1.5 and the 2023 factory address and salt. It needs updating before the new deploy; see #195's owner decision. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
ryanio
added a commit
that referenced
this pull request
Nov 7, 2026
## Motivation `script/DeploySeaDrop1155CloneFactory.s.sol` deploys the factory for Seaport 1.5 and requires the 2023 factory address `0x000000F2…`. OpenSea's ERC-1155 clones mint through Seaport 1.6, and since #195 no build produces that address. It's needed for the planned redeploy. Stacked on #209. ## Solution - **Seaport.** The script defaults to Seaport 1.6 (`0x0000000000000068F116a894984e2DB1123eB395`), with an optional `SEAPORT` override. Seaport is a constructor argument, so it's part of the init code hash. - **Inputs.** `SALT` (required) and `EXPECTED_ADDRESS` (optional) come from the environment, the same as the `main` script. - **Logging.** It logs the Seaport address, the init code hash and the address `SALT` produces. - **Safety stop.** A mismatched `EXPECTED_ADDRESS` reverts before broadcasting. This settles the script half of #195's "Owner decision needed". The vanity salt itself is still open: mine one against the logged hash at the commit that deploys. ## Verification - **New test.** `DeploySeaDrop1155CloneFactoryTest` runs the script on a local EVM. A mismatched `EXPECTED_ADDRESS` reverts and deploys nothing. Without `SEAPORT` set, it deploys a factory whose `seaport()` is Seaport 1.6 and whose configurer and implementation both have code. - **Checks.** `forge test`: `Ran 27 test suites: 304 tests passed, 0 failed, 0 skipped`. `forge fmt --check`, `forge lint --deny warnings` and `biome ci .` pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Porting the Hardhat suite to Forge in #192 turned up contract bugs that the specs had papered over. The specs asserted generic errors, and some of their comments named the wrong one. This fixes those bugs and a few more found while fixing them. It also cleans up the test helpers the port left behind and gets coverage working on
v2again.Solution
Contract fixes
Each fix has tests that fail on the old code.
1.
_decodeOrdererror reporting (ERC721SeaDropContractOffererImplementation,ERC1155SeaDropContractOffererImplementation)errorBuffer << 254,<< 252and<< 253, which keep several low bits at once. SoInvalidSubstandardandMustSpecifyERC1155ConsiderationItemForSeaDropMintcould never be raised, and most bad orders reportedUnsupportedExtraDataVersion(0)orInvalidExtraDataEncoding(0).minimumReceived.minimumReceived.InvalidExtraDataEncodinginstead of reverting with no data. The minimum lengths are per substandard.MustSpecifyERC1155ConsiderationItemForSeaDropMintname, since the 721 mint item is also an ERC-1155 item and renaming would change the ABI.2. 1155 wallet-limit errors report what was checked
MintQuantityExceedsMaxMintedPerWalletForTokenIdreported the wallet's total across every token id, but the check uses the per-token count. It now reports the per-token count.MintQuantityExceedsMaxMintedPerWalletreported a single offer item's quantity instead of the order's running total. Every item is now checked against the running total, and that total is what gets reported. Which orders pass is unchanged.3. 721 owner mints respect max supply.
_multiConfigureMintminted without checking max supply, so a configurer mint could take the collection past it. It now reverts withMintQuantityExceedsMaxSupply, like the mint path does.4. Transfer validation view flags.
getTransferValidationFunction()reported 721 as non-view and 1155 as view, the reverse of the repo's ownITransferValidator721(view) andITransferValidator1155(non-view), and of Limit Break's convention. Now 721 reportstrueand 1155 reportsfalse, including the 1155 clone copy.5. 1155 public drop indexes above 255. The mint context encodes the drop index in one byte, so a drop configured at index 256 or above could never be minted. Configuring one now reverts
InvalidPublicDropIndex(index), a new error.6. Clone implementation initializer.
ERC1155SeaDropCloneable's implementation could be initialized by anyone. Its constructor now calls_disableInitializers(), and the factory no longer initializes the implementation itself. Clones still initialize normally. Theunprotected-initializerlint exclusion is removed.7. Random offset (
ERC721SeaDropRandomOffset)tokenURInow subtracts the start token id, so the offset is the actual shift, uniform over 1 to N−1.NotFullyMinted.setMaxSupplynow revertsAlreadyRevealed()after the reveal, since raising it reshuffled revealed metadata. To allow the override, the basesetMaxSupplygoes fromexternaltopublic virtual.Tests and tooling
SeaDropTest,SeaDrop721TestandSeaDrop1155Test. Comments that only made sense next to the Hardhat specs are gone.testCannotMintQuantityOfZerois folded intotestCannotMintZeroQuantity. A staletestMintSignedstep that re-sent the old order now sends the new one.src/shim/and thesrc/seaport-contractssymlink are removed, along with their fmt, lint, coverage and lefthook ignores.forge lintno longer prints "AST source not found".forge coverage --ir-minimumwork. Move v2 to Foundry-only tooling and port the Hardhat suite #192 had dropped coverage, and this restores it with a "Run Forge Coverage" job that uploads to Coveralls: 86.46% of lines locally..gas-snapshotis regenerated; it was identical across three runs. Both workflows now limitGITHUB_TOKENpermissions, as Move main to Foundry-only tooling and port the Hardhat suite #193 did onmain.Verification
forge test:Ran 20 test suites: 188 tests passed, 0 failed, 0 skipped.forge fmt --check,forge lint --deny warningsandbiome ci .pass.Owner decision needed
The 1155 clone factory's CREATE2 address.
script/DeploySeaDrop1155CloneFactory.s.soldeploys through the ImmutableCreate2Factory with a mined salt and requires the vanity address0x000000F20032b9e171844B00EA507E11960BD94a. That address only reproduces from the source at0fb9c0e(2023-09-21). The source has changed since, so the script'srequirealready failed onv2before this PR. This PR changes the factory's bytecode again: with the current salt it would now deploy to0x9303995422C75c597C477a8f06Fa3687214ab4dE(init code hash0x3c53bf47…5424). After merge, either mine a new vanity salt against that hash, or accept the plain address. Then update the salt and expected address in the script, and anything that hardcodes0x000000F2…. I didn't check which chains have0x000000F2…deployed.Behavior changes for integrators. The two error arguments in fix 2 now carry different values,
InvalidPublicDropIndexis a new error, and orders that used to panic now revert with a reason. Already-deployed tokens are unaffected; this only changes new deployments.🤖 Generated with Claude Code