package upload import ( "strconv" "strings" "gno.land/p/g1jz6j9hj6rdf5ltl2kcrpa4jwtdh3w30z0yul06/sinopia4/media/v2" "gno.land/p/g1jz6j9hj6rdf5ltl2kcrpa4jwtdh3w30z0yul06/sinopia4/safe/v2" ) // cardSVG is the generic card (v2): the registration sample (its sha256 is // the engine's fingerprint, reserved in core's config.gno, I-14), the // RenderWith output, and the answer to any call that is not core's real // render of a revealed, bound token. Changing one byte changes the // fingerprint: update CardFingerprint, docs/test-vectors (gen-upload-v2.py) // and core's reserved entry together. const cardSVG = `` + `` + `` + `Sinopia Upload` + `art from a sealed asset store` + `media engine v2` + `` // CardFingerprint = sha256(cardSVG) = the engine's sample fingerprint // (TestCardFingerprint checks it against core's registration). const CardFingerprint = "0e414b46db68c64891aadfb4e1fc18ef63d9711907538b659b61b41c7d34efd1" // certificateSVG is the card of a raster or IPFS artwork: what // core.TokenCard returns (SVG-only clients, gnoweb) while core.TokenURI // serves the file itself. Every text is XML-escaped; the document stays far // below MaxSVGBytes. func certificateSVG(r resolved) string { a := r.art title := a.Title if title == "" { title = "Artwork #" + strconv.FormatInt(a.Index+1, 10) } tier := "no tier" if a.Tier != "" { tier = a.Tier + " — creator tier" } where := strings.ToUpper(media.MimeName(a.Mime)) + " · " + sizeLabel(a.Size) + " · stored on-chain" if a.Kind != media.KindChain { where = "IPFS · " + strings.ToUpper(media.MimeName(a.Mime)) + " · " + sizeLabel(a.Size) } var b strings.Builder b.WriteString(``) b.WriteString(``) b.WriteString(``) line := func(y int, size int, fill, text string) { b.WriteString(`` + safe.XMLEscape(text) + ``) } line(78, 24, "#eeeeee", r.info.Name) line(116, 20, "#cccccc", "#"+r.tid) line(196, 20, "#eeeeee", title) line(232, 16, "#d9a441", tier) if a.Editions > 1 { line(262, 14, "#aaaaaa", "edition "+editionLabel(r.edition, a.Editions)) } line(316, 14, "#aaaaaa", where) if a.CID != "" { line(340, 11, "#888888", a.CID) } line(364, 12, "#888888", "sha256 "+a.SHA256[:16]+"…") line(452, 11, "#777777", "full image: core TokenURI") b.WriteString(``) return b.String() } func sizeLabel(n int64) string { if n < 1024 { return strconv.FormatInt(n, 10) + " B" } tenths := (n*10 + 512) / 1024 return strconv.FormatInt(tenths/10, 10) + "." + strconv.FormatInt(tenths%10, 10) + " KB" }