cinar.gno
2.44 Kb · 58 lines
1// Package cinar is the thin adapter that registers the Cinar engine
2// (p/…/sinopia/art/cinar/v1), Sinopia's first living engine, with core.
3// Core knows the engine only as this realm's package path plus an interface
4// value; on every read core passes the token's chain state (MintHeight,
5// LastMoveHeight, Moves, Height) in engine.Input and the art follows it.
6//
7// The adapter is stateless and has no admin: what it renders is fixed by
8// the p/ package it imports, which can never change. Never mark this realm
9// private (design §5.4: a re-deployable adapter could swap the art).
10// Per-chain values (author key, fee) live in config.gno.
11package cinar
12
13import (
14 art "gno.land/p/g1jz6j9hj6rdf5ltl2kcrpa4jwtdh3w30z0yul06/sinopia4/art/cinar/v1"
15 "gno.land/p/g1jz6j9hj6rdf5ltl2kcrpa4jwtdh3w30z0yul06/sinopia4/engine/v2"
16 "gno.land/r/g1jz6j9hj6rdf5ltl2kcrpa4jwtdh3w30z0yul06/sinopia4/core"
17)
18
19// Author is the engine-author key that registers, claims and may deprecate
20// this engine in core.
21func Author() address { return author }
22
23// impl is zero-size and declared here, so core runs it with this realm's
24// authority (interrealm v2 borrow rule #1).
25type impl struct{}
26
27func (impl) Manifest() engine.Manifest {
28 m := art.Manifest()
29 m.Author = author
30 m.FeeBps = AuthorFeeBps
31 return m
32}
33
34func (impl) ValidateParams(params string) error { return art.ValidateParams(params) }
35
36// TraitTypes: a static trait list (the values of Season, Stage, Roots and
37// Notches change with chain time; the types do not).
38func (impl) TraitTypes(params string) []string { return art.Manifest().TraitTypes }
39
40// CheckLaunch: a generative engine has no launch precondition.
41func (impl) CheckLaunch(cid, params string, maxSupply int64) error { return nil }
42
43func (impl) Traits(in engine.Input) []engine.Trait { return art.Traits(in) }
44
45func (impl) Render(in engine.Input) string { return art.Render(in) }
46
47// Media: an svg engine; Render is the art.
48func (impl) Media(in engine.Input) engine.Media { return engine.Media{} }
49
50// Register is an explicit call, not init: under the inert package policy
51// init runs inside the approver's transaction (RA B-1). It registers this
52// realm, once, and must be signed by the manifest author (author, config.gno).
53// The fingerprint is in core's in-source reserved table, so only that key
54// can register this art anywhere; no commit reservation is
55// used, so the salt is "".
56func Register(cur realm) string {
57 return core.RegisterEngine(cross(cur), impl{}, "")
58}