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 (docs/uploaded-collections.md §5.1, §0a): media kind...
Package media is the pure half of Sinopia's uploaded collections (docs/uploaded-collections.md §5.1, §0a): media kinds and types, the CIDv1 grammar the platform accepts, image header checks, and the salt-keyed permutation that assigns tokens to artworks. It has no state; the asset store (r/…/assets/v1), the upload engine (r/…/engines/upload) and the frontend (chain/cid.ts, chain/perm.ts) share these definitions, pinned by the golden vectors in docs/test-vectors/upload-v1.json.
Storage kinds of one artwork.
Media types. GIF is defined for completeness but refused by ParseMime (decision D5: svg, png, webp, jpeg only).
1const (
2 MaxDim = 4096 // px per side, decompression-bomb guard
3 MaxSVGBytes = 16384 // on-chain SVG: AssertSVG costs ~30-50k gas/B (WP0)
4 MaxRasterBytes = 262144 // on-chain png/webp/jpeg per artwork
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.
PermDomain separates the permutation key from every other platform hash (under safe.Domain "art").
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: the magic bytes and the header's pixel dimensions (each 1..MaxDim, the decompression-bomb guard). SVG has no header dimensions (w, h = 0) and must pass safe.AssertSVG with the on-chain cap MaxSVGBytes (§0a), the same allowlist core applies to every render. Nothing else of a raster file is parsed: raster bytes are only ever shown through <img> (SA-M3).
IsHex32 reports whether s is exactly 64 lower-case hex characters.
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.
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 (one pass, table lookups: VM loops cost ~5k gas per character).
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.
StoreInfo is a store's header as plain data.