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 = ``
// 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(``)
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"
}