Skip to content Search Apps Documentation Source Content 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.

v1 source pure

Package engine is the "art as code" contract (design §5.2): what a generative engine implements, what core hands it, ...

Overview

Package engine is the "art as code" contract (design §5.2): what a generative engine implements, what core hands it, and the conformance rules both core and engine authors check against.

An engine is registered from its own /r/ adapter realm. Because the adapter's methods are declared in that realm, core calling them runs the engine with the adapter's authority, never core's (interrealm v2 borrow rule #1). Methods receive and return plain values only: an engine never gets a reference into core state.

Constants 1

Functions 6

func CheckSVG

1func CheckSVG(m Manifest, svg string) error
source

CheckSVG is the output rule core applies to every render.

func Conformance

1func Conformance(e Engine, samples int) error
source

Conformance is the self-test engine authors run in their _test.gno before registering: manifest, default params, determinism, size, SVG hygiene, traits, and — for non-living engines — independence from the living fields.

func SampleSeed

1func SampleSeed(i int) string
source

SampleSeed returns the i-th Studio/conformance sample seed.

func ValidateManifest

1func ValidateManifest(m Manifest) error
source

ValidateManifest checks sizes, text hygiene and the author address.

func ValidateTraits

1func ValidateTraits(m Manifest, ts []Trait) error
source

ValidateTraits checks one Traits() result against the manifest.

func SampleInput

1func SampleInput() Input
source

SampleInput is the fixed input of an engine's fingerprint: core renders it at registration and stores sha256(svg); anyone can recompute it later.

Types 4

type Engine

interface
1type Engine interface {
2	Manifest() Manifest
3	ValidateParams(params string) error
4	Traits(in Input) []Trait
5	Render(in Input) string
6}
source

Engine is implemented by a stateless value declared in the adapter realm.

Contract: deterministic in Input; ValidateParams("") must accept the engine's defaults; Render returns raw SVG (core does the base64); Traits only uses types listed in the manifest, each at most once.

type Input

struct
 1type Input struct {
 2	Seed           string // 64-hex final seed (sample seeds in Studio)
 3	Params         string // collection params, in the engine's own format
 4	CollectionID   string
 5	TokenID        string
 6	MintHeight     int64
 7	LastMoveHeight int64 // patina: holding time = Height - LastMoveHeight
 8	Moves          int64 // transfers so far
 9	Height         int64 // height of the read (fixed by Verify)
10}
source

Input is everything an engine may depend on. p/ packages are frozen once deployed, so the fields "living" engines will need later (phase 2) are here from day one.

type Manifest

struct
1type Manifest struct {
2	Name, Version, Description, License string
3	Author                              address // proven by core.ClaimEngine
4	ParamsSchema                        string  // JSON Schema subset; Studio builds its form from it
5	TraitTypes                          []string
6	Living                              bool  // Render depends on LastMoveHeight/Moves/Height
7	MaxSVGBytes                         int64 // <= MaxSVGBytes
8}
source

type Trait

struct
1type Trait struct {
2	Type, Value string
3}
source

Dependencies

Source Files 2