fix(nft): collection attributes use CHIP-0007 type, not trait_type#9
Merged
Merged
Conversation
`Collection`/`CollectionRef.attributes` wrongly reused the NFT-item `Attribute` struct (field `trait_type`), so a CHIP-0007-conformant collection.json using the correct `type` field was rejected with "missing field `trait_type`" (dkackman, #187). Add a distinct `CollectionAttribute` (serde field `type`, with a `trait_type` read-alias for already-emitted collection.json). NFT-item attributes are untouched. Fixes the golden test vectors, which had baked in the wrong format, and documents the two shapes in SPEC.md.
Unrelated to the collection-attribute fix, but a new advisory landed on main's transitive crossbeam-epoch 0.9.18 (pulled via ignore/rayon/wasmtime) between the last green main run and this PR, failing the required supply-chain-audit gate. Bump to the patched version per the advisory.
MichaelTaylor3d
added a commit
that referenced
this pull request
Jul 10, 2026
#9) * fix(nft): collection attributes use CHIP-0007 `type`, not `trait_type` `Collection`/`CollectionRef.attributes` wrongly reused the NFT-item `Attribute` struct (field `trait_type`), so a CHIP-0007-conformant collection.json using the correct `type` field was rejected with "missing field `trait_type`" (dkackman, #187). Add a distinct `CollectionAttribute` (serde field `type`, with a `trait_type` read-alias for already-emitted collection.json). NFT-item attributes are untouched. Fixes the golden test vectors, which had baked in the wrong format, and documents the two shapes in SPEC.md. * chore(deps): bump crossbeam-epoch to 0.9.20 (RUSTSEC-2026-0204) Unrelated to the collection-attribute fix, but a new advisory landed on main's transitive crossbeam-epoch 0.9.18 (pulled via ignore/rayon/wasmtime) between the last green main run and this PR, failing the required supply-chain-audit gate. Bump to the patched version per the advisory. Co-Authored-By: Claude <noreply@anthropic.com>
MichaelTaylor3d
added a commit
that referenced
this pull request
Jul 10, 2026
#9) * fix(nft): collection attributes use CHIP-0007 `type`, not `trait_type` `Collection`/`CollectionRef.attributes` wrongly reused the NFT-item `Attribute` struct (field `trait_type`), so a CHIP-0007-conformant collection.json using the correct `type` field was rejected with "missing field `trait_type`" (dkackman, #187). Add a distinct `CollectionAttribute` (serde field `type`, with a `trait_type` read-alias for already-emitted collection.json). NFT-item attributes are untouched. Fixes the golden test vectors, which had baked in the wrong format, and documents the two shapes in SPEC.md. * chore(deps): bump crossbeam-epoch to 0.9.20 (RUSTSEC-2026-0204) Unrelated to the collection-attribute fix, but a new advisory landed on main's transitive crossbeam-epoch 0.9.18 (pulled via ignore/rayon/wasmtime) between the last green main run and this PR, failing the required supply-chain-audit gate. Bump to the patched version per the advisory. Co-Authored-By: Claude <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.
Summary
Fixes DIG-Network/dig_ecosystem#187:
digstore collection mint --collection <collection.json>rejected every CHIP-0007-conformant collection.json witherror: --collection is not a valid definition: missing field 'trait_type'(dkackman, live user, hit this multiple times).Root cause:
Collection.attributes/CollectionRef.attributes(crates/digstore-chain/src/collection.rs/metadata.rs) reused the NFT-itemAttributestruct (serde fieldtrait_type) for collection-level attributes too. Per CHIP-0007, collection attributes (icon/banner/website/etc) use the fieldtype, nottrait_type— NFT item attributes correctly usetrait_type. The golden test vectors baked in the wrong (trait_type) format for collection attributes, so CI stayed green on a non-conformant reader.Fix:
CollectionAttributestruct:#[serde(rename = "type", alias = "trait_type")] pub kind: String+value: String. Serializes astypegoing forward; on READ also accepts the legacytrait_typespelling so already-emitted DIG collection.json keeps parsing (§5.1 back-compat, never reject older input).Collection.attributesandCollectionRef.attributesnow useVec<CollectionAttribute>. NFT-itemAttribute(Chip0007Metadata.attributes,ManifestItem.attributes) is untouched — stilltrait_type.collection.rs/metadata.rs(they previously pinned the wrongtrait_typeshape for collection attributes).SPEC.md§11: new normative section documenting the two attribute shapes byte-level, with examples.Tests (TDD):
digstore-chainunit tests: a conformant{"type":...}collection attribute parses; the legacy{"trait_type":...}alias still parses; a collection.json with thetypefield parses intoCollection; NFT-item attributes still reject atype-only field (still requiretrait_type— the two shapes stay distinct).digstore-cliintegration tests (cli_assets.rs):collection_mint_accepts_chip0007_type_attributereproduces dkackman's exact command shape — before the fix this failed at exit 2 ("not a valid definition"/trait_type); after the fix it parses and fails only on DID ownership (exit 4, no real DID under the offline mock) — proving the parse bug is gone.collection_mint_accepts_legacy_trait_type_collection_attributeproves back-compat.cargo install --path crates/digstore-cli --force --locked) with dkackman's exactcollection mint --collection <conformant> --manifest ... --did ... --dry-runshape: no longer fails on parsing; only fails on DID ownership under the mock (expected, no live chain). Confirmed the legacytrait_typecollection.json also still parses on the installed binary.Version bump: patch (
0.9.0→0.9.1) — backwards-compatible bug fix (fix:), no breaking change; the read side gained a back-compat alias, the write side output shape is corrected but was never conformant/consumed correctly before.Test plan
cargo test -p digstore-chain --lib— 203 passed, 0 failedcargo test -p digstore-cli --test cli_assets— 17 passed, 0 failed (incl. 2 new regression tests)cargo test --workspace(excl. wasm guest target) — all green, 0 failurescargo fmt --all -- --check— cleancargo clippy -p digstore-chain -p digstore-cli --all-targets --all-features -- -D warnings— cleancargo build -p digstore-guest --target wasm32-unknown-unknown --release)cargo install --path crates/digstore-cli --force --locked+ manual installed-binary repro of dkackman's exact command (bothtypeand legacytrait_typecollection.json)Cross-repo follow-up (for the orchestrator — not in this PR)
Per dig_ecosystem#187, checked whether other repos emit collection attributes with the same bug:
trait_type-on-collection-attribute bug — not checked in this digstore-only PR (single-writer per repo).type-vs-trait_typecorrection reflected in the collection-metadata protocol docs (this PR'sSPEC.md§11 is the source text to mirror).