kilim.gno
2.35 Kb · 63 lines
1// Package kilim is the thin adapter that registers the Kilim engine
2// (p/…/sinopia/art/kilim/v1) with core. Core knows the engine only as this
3// realm's package path plus an interface value.
4//
5// The adapter is stateless and has no admin: what it renders is fixed by
6// the p/ package it imports, which can never change. Never mark this realm
7// private (design §5.4: a re-deployable adapter could swap the art).
8package kilim
9
10import (
11 art "gno.land/p/g1jz6j9hj6rdf5ltl2kcrpa4jwtdh3w30z0yul06/sinopia/art/kilim/v1"
12 "gno.land/p/g1jz6j9hj6rdf5ltl2kcrpa4jwtdh3w30z0yul06/sinopia/engine/v1"
13 "gno.land/r/g1jz6j9hj6rdf5ltl2kcrpa4jwtdh3w30z0yul06/sinopia3/core"
14)
15
16// author is the address that claims the engine in core (ClaimEngine).
17// TODO(mainnet): the engine author's own key, not the deployer.
18var author = address("g1jz6j9hj6rdf5ltl2kcrpa4jwtdh3w30z0yul06")
19
20func Author() address { return author }
21
22// AuthorFeeBps is the author's fee on sales of collections by other
23// creators (engine.Manifest.FeeBps; 0 for the author's own collections).
24// TODO(mainnet): product decision; 1% here so Onyx exercises the path.
25const AuthorFeeBps = 100
26
27// impl is zero-size and declared here, so core runs it with this realm's
28// authority (interrealm v2 borrow rule #1).
29type impl struct{}
30
31func (impl) Manifest() engine.Manifest {
32 m := art.Manifest()
33 m.Author = author
34 m.FeeBps = AuthorFeeBps
35 return m
36}
37
38func (impl) ValidateParams(params string) error { return art.ValidateParams(params) }
39
40func (impl) Traits(in engine.Input) []engine.Trait { return art.Traits(in) }
41
42func (impl) Render(in engine.Input) string { return art.Render(in) }
43
44// Register is an explicit call, not init: under the inert package policy
45// init runs inside the approver's transaction (RA B-1). Anyone may call it;
46// it can only ever register this realm, once.
47func Register(cur realm) string {
48 return core.RegisterEngine(cross(cur), impl{})
49}
50
51// RenderSeed and TraitsSeed are the plan-B surface (design §5.6): if
52// dynamic registration fails on chain, readers call the engine directly.
53func RenderSeed(seed, params string) string {
54 in := engine.SampleInput()
55 in.Seed, in.Params = seed, params
56 return art.Render(in) // panics on invalid params
57}
58
59func TraitsSeed(seed, params string) []engine.Trait {
60 in := engine.SampleInput()
61 in.Seed, in.Params = seed, params
62 return art.Traits(in) // panics on invalid params
63}