const KindChain, KindIPFSRaw, KindIPFSUnixFS
Storage kinds of one artwork.
Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.
Package media is the pure half of Sinopia's uploaded collections, version 2 (docs/uploaded-collections.md §5.1, §0a; ...
Package media is the pure half of Sinopia's uploaded collections, version 2 (docs/uploaded-collections.md §5.1, §0a; mainnet plan §2.1, §3.2 WP-F): storage kinds and media types, the typed views of a store (Artwork, StoreInfo), the storage badge and the salt-keyed permutation that assigns tokens to artworks. It has no state.
v2 against v1: the image header checks and the CIDv1 grammar moved into p/safe/v2 (core validates engine media with them, I-15). The functions of the same name here delegate to safe/v2, so the asset store (r/…/assets/v1), the upload engine (r/…/engines/upload) and core apply one implementation. Everything else is v1's code unchanged; the permutation keeps its domain "art|upload|perm|v1|" (same algorithm, same golden vectors). Frontend twins: chain/perm.ts (Permute, PermKey, Slot), chain/cid.ts (CIDv1) and checkImage in chain/upload.ts, pinned by docs/test-vectors/upload-v2.json (docs/test-vectors/gen-upload-v2.py).
Storage kinds of one artwork.
Media types (the record byte of assets/v1). GIF is defined for completeness but refused by ParseMime (decision D5: svg, png, webp, jpeg).
1const (
2 MaxDim = safe.MaxDim // 4096 px per side, decompression-bomb guard
3 MaxSVGBytes = safe.MaxSVGImageBytes // 16,384: on-chain SVG (= engine/v2 MaxMediaSVGBytes)
4 MaxRasterBytes = 262144 // on-chain png/webp/jpeg per artwork (= engine/v2 MaxMediaBytes)
5 MaxIPFSRaw = 1 << 20 // single raw block
6 MaxIPFSUnixFS = 50 << 20 // declared; the frontend enforces it while streaming
7)Limits (decision D4 and design §4).
CID codecs (safe/v2).
IPFSScheme prefixes an IPFS URI ("ipfs://<CIDv1>").
PermDomain separates the permutation key from every other platform hash (under safe.Domain "art"). Unchanged from v1: same algorithm, same keys.
Badge is a store's storage badge from its counters (design §9): "onchain", "ipfs", "mixed", or "empty" for a store without artworks.
CIDFromDigest is the inverse of ParseCIDv1; it panics on an unsupported codec or a digest that is not 64 lower-case hex characters.
CheckImage checks a complete file against its declared type (v1 signature): SVG must pass safe.AssertSVG with MaxSVGBytes (w = h = 0); a raster file must carry its type's magic bytes and header dimensions of 1..MaxDim per side (safe.ImageDims). Error texts are v1's.
IsHex32 reports whether s is exactly 64 lower-case hex characters.
IsIPFSURI reports whether s is "ipfs://" + a CIDv1 ParseCIDv1 accepts.
KindName is "chain" or "ipfs".
MaxBytes is the size cap of one artwork of this kind and type.
MimeName is the short name ParseMime accepts ("svg", "png", …).
MimeType is the IANA type of a media constant ("" for an unknown one).
ParseCIDv1 returns the codec (CodecRaw or CodecDagPB) and the sha2-256 digest as lower-case hex (safe/v2 grammar, unchanged from media/v1).
ParseMime maps "svg" | "png" | "webp" | "jpeg" to its constant and panics on anything else, "gif" included (D5).
PermKey is the permutation key of collection cid with its final salt.
Permute is a bijection on [0, n): a 4-round Feistel network over b bits (b = bitlen(n-1) rounded up to an even number ≥ 2, so 2^b < 4n) with cycle walking. Round function: F = big-endian uint64 of the first 8 bytes of sha256(keyHex + "|" + r + "|" + R), masked to h = b/2 bits, with r and R in decimal. It panics unless 1 ≤ n and 0 ≤ x < n.
Raw32 decodes exactly 64 lower-case hex characters into 32 raw bytes.
Slot is the slot of token tid (1-based) in a store of `artworks` artworks and `slots` slots: the identity tid-1 for a single-artwork store (1/1 and editions: "Edition 3 of 50"), Permute(K, slots, tid-1) otherwise.
1type Artwork struct {
2 Index int64
3 Kind, Mime int
4 Size, Have, Editions, SlotEnd int64
5 SHA256, Digest, CID, Title, Tier string
6 Traits []string // one value per store trait type ("" = none)
7 Complete bool
8 // JSON escaped once by the store (filled by assets/v1 reads, "" otherwise):
9 // TierJSON is the tier name as a JSON string ("" = no tier); TraitsJSON the
10 // creator traits as comma-joined {"trait_type":…,"value":…} items in store
11 // order ("" = none). Lets token reads avoid per-call escaping (review UP-M1).
12 TierJSON, TraitsJSON string
13}Artwork is one record of a store as plain data. It crosses realm boundaries as a copy and never points into store state.
MimeType is the artwork's IANA media type.
MimeVerified reports whether the chain checked the file against its declared type (UP-I6): on-chain bytes passed CheckImage when their last chunk arrived; an IPFS file's type is the creator's claim (the chain never sees the bytes; a raw CID binds the bytes, not the type).
OnChain reports whether the artwork's bytes live in the store.
SlotStart is the first slot of the artwork's range [SlotStart, SlotEnd).
URI is "ipfs://<cid>" for an IPFS artwork, "" for on-chain bytes.
StoreInfo is a store's header as plain data.
Badge is the store's storage badge (see Badge).
HasEditions reports whether some artwork of the store has more than one edition (slots > artworks).