Skip to content Search Apps Documentation Source Content Run Reset Eval Playground File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

strata.gno

2.41 Kb · 67 lines
 1// Package strata is the thin adapter that registers the Strata engine
 2// (p/…/sinopia/art/strata/v1) with core: cross-sections of an invented
 3// earth, with an optional params form (era, section, bedding, folding).
 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 strata
 9
10import (
11	art "gno.land/p/g1jz6j9hj6rdf5ltl2kcrpa4jwtdh3w30z0yul06/sinopia/art/strata/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 platform's engine-author 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	if err := art.ValidateParams(params); err != nil {
55		panic(err)
56	}
57	return art.SVGWith(seed, params)
58}
59
60func TraitsSeed(seed, params string) []engine.Trait {
61	in := engine.SampleInput()
62	in.Seed, in.Params = seed, params
63	if err := art.ValidateParams(params); err != nil {
64		panic(err)
65	}
66	return art.Traits(in)
67}