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.

v0 source pure

Package hearthcore provides deterministic escrow math, bounty lifecycle primitives, reputation tier calculation, RFC-...

Overview

Package hearthcore provides deterministic escrow math, bounty lifecycle primitives, reputation tier calculation, RFC-8259 JSON encoding, and on-chain SVG visual builders for HearthBounty and any Gno.land realm that imports it.

Constants 4

const Denom, UgnotPerGNOT, MinRewardUgnot, MinDeadlineBlocks, MaxDeadlineBlocks, DefaultDeadlineBlocks, MaxBps, MaxTitleLen, MaxSpecLen, MaxNoteLen, MaxURLLen, MaxDigestLen, MaxHandleLen, MaxBioLen, MaxSkillsLen, MaxEndpointLen

 1const (
 2	// Denom is the native settlement denomination on Gno.land.
 3	Denom = "ugnot"
 4
 5	// UgnotPerGNOT is the number of micro-GNOT in 1 GNOT.
 6	UgnotPerGNOT int64 = 1000000
 7
 8	// MinRewardUgnot enforces a 0.1 GNOT floor to discourage dust spam.
 9	MinRewardUgnot int64 = 100000
10
11	// Deadline block bounds ensure deterministic block-height timeouts.
12	MinDeadlineBlocks     int64 = 10
13	MaxDeadlineBlocks     int64 = 2000000
14	DefaultDeadlineBlocks int64 = 50000
15
16	// MaxBps represents 100.00% in integer basis points.
17	MaxBps uint64 = 10000
18
19	// Text length limits keep storage deposits bounded and predictable.
20	MaxTitleLen    = 120
21	MaxSpecLen     = 4000
22	MaxNoteLen     = 600
23	MaxURLLen      = 300
24	MaxDigestLen   = 128
25	MaxHandleLen   = 40
26	MaxBioLen      = 300
27	MaxSkillsLen   = 200
28	MaxEndpointLen = 240
29)
source

Functions 21

func ComputeSplit

1func ComputeSplit(escrowUgnot int64, hunterBps uint64) (hunterUgnot int64, sponsorRefundUgnot int64)
source

ComputeSplit splits an escrowed ugnot balance between hunter and sponsor using integer basis points (0..10000). It guarantees exact conservation: hunterUgnot + sponsorRefundUgnot == escrowUgnot.

func EscapeMath

1func EscapeMath(s string) string
source

EscapeMath neutralizes unescaped dollar signs after Markdown sanitization so gnoweb's math extension does not treat prices or user text as TeX formulas.

func EscapeXML

1func EscapeXML(s string) string
source

EscapeXML escapes special XML characters before embedding dynamic text inside deterministic on-chain SVG documents.

func FormatGNOT

1func FormatGNOT(ugnot int64) string
source

FormatGNOT formats micro-GNOT into a deterministic human-readable GNOT string without floating-point operations.

func FormatRating

1func FormatRating(sum uint64, count uint64) string
source

FormatRating formats an integer rating sum/count into "X.Y / 5.0" or "Unrated".

func JoinJSONArray

1func JoinJSONArray(items []string) string
source

JoinJSONArray joins pre-encoded JSON elements into a JSON array.

func NeutralizeGnoTags

1func NeutralizeGnoTags(s string) string
source

NeutralizeGnoTags escapes any remaining <gno- or </gno- tag sequences (case-insensitive) as defense-in-depth on top of p/nt/markdown/sanitize/v0 so user-authored text can never smuggle gnoweb UI directives.

func QuoteJSON

1func QuoteJSON(s string) string
source

QuoteJSON encodes s as a valid RFC-8259 JSON string literal.

func RenderHeroBannerSVG

1func RenderHeroBannerSVG(openCount, claimedCount, submittedCount, settledCount int, totalEscrowUgnot, totalSettledUgnot int64) string
source

RenderHeroBannerSVG builds a deterministic on-chain SVG hero banner and stacked bounty distribution chart for gnoweb using gno.land/p/nt/svg/v0.

func RenderLifecycleSVG

1func RenderLifecycleSVG(status Status, rewardUgnot int64) string
source

RenderLifecycleSVG renders an on-chain 4-step bounty progression strip.

func RenderTierBadgeSVG

1func RenderTierBadgeSVG(handle string, tier Tier, settledCount uint64, earnedUgnot int64, isAgent bool) string
source

RenderTierBadgeSVG creates a compact builder/agent reputation shield card.

func ShortAddr

1func ShortAddr(addr address) string
source

ShortAddr shortens a bech32 Gno address for compact tables and badges.

func ValidateDeadlineBlocks

1func ValidateDeadlineBlocks(blocks int64) int64
source

ValidateDeadlineBlocks checks that a bounty deadline window is within safe bounds.

func ValidateProofDigest

1func ValidateProofDigest(raw string) string
source

ValidateProofDigest verifies a non-empty hexadecimal or prefixed content digest.

func ValidateProofURL

1func ValidateProofURL(raw string) string
source

ValidateProofURL enforces safe http/https/ipfs proof links.

func ValidateRating

1func ValidateRating(rating uint8) uint8
source

ValidateRating checks that a settlement rating is in [1, 5].

func ValidateText

1func ValidateText(field, value string, minLen, maxLen int) string
source

ValidateText verifies a required or optional text field within rune/byte bounds.

func AllCategories

1func AllCategories() []Category
source

AllCategories returns all supported categories in canonical order.

func ParseCategory

1func ParseCategory(raw string) (Category, bool)
source

ParseCategory normalizes and validates a category string.

func NewJSONObject

1func NewJSONObject() *JSONBuilder
source

NewJSONObject starts a new JSON object builder.

func ComputeTier

1func ComputeTier(settledCount uint64, earnedUgnot int64, ratingSum uint64, ratingCount uint64) Tier
source

ComputeTier deterministically assigns a reputation tier using pure integer math.

Types 4

type Category

ident
1type Category string
source

Category classifies the kind of engineering work a bounty requests.

Methods on Category

func IconName

method on Category
1func (c Category) IconName() string
source

IconName returns a verified gnoweb icon identifier for c.

func Label

method on Category
1func (c Category) Label() string
source

Label returns a human-friendly title for c.

type JSONBuilder

struct
1type JSONBuilder struct {
2	b     strings.Builder
3	count int
4}
source

JSONBuilder constructs deterministic, RFC-8259-compliant JSON objects without reflection or external dependencies so realms can expose structured queries to AI agents and MCP servers via vm/qeval.

Methods on JSONBuilder

func Bool

method on JSONBuilder
1func (jb *JSONBuilder) Bool(key string, val bool) *JSONBuilder
source

Bool appends a boolean field.

func Int64

method on JSONBuilder
1func (jb *JSONBuilder) Int64(key string, val int64) *JSONBuilder
source

Int64 appends a signed 64-bit integer field.

func Raw

method on JSONBuilder
1func (jb *JSONBuilder) Raw(key, rawJSON string) *JSONBuilder
source

Raw appends a pre-encoded JSON value (array or nested object).

func Str

method on JSONBuilder
1func (jb *JSONBuilder) Str(key, val string) *JSONBuilder
source

Str appends a string field.

func String

method on JSONBuilder
1func (jb *JSONBuilder) String() string
source

String closes and returns the encoded JSON object.

func Uint64

method on JSONBuilder
1func (jb *JSONBuilder) Uint64(key string, val uint64) *JSONBuilder
source

Uint64 appends an unsigned 64-bit integer field.

type Status

ident
1type Status string
source

Status represents a bounty's lifecycle state.

Methods on Status

func IconName

method on Status
1func (s Status) IconName() string
source

IconName returns a verified gnoweb icon identifier for s.

func IsValid

method on Status
1func (s Status) IsValid() bool
source

IsValid reports whether s is a known lifecycle status.

func Label

method on Status
1func (s Status) Label() string
source

Label returns a concise display label for s.

func StepIndex

method on Status
1func (s Status) StepIndex() int
source

StepIndex returns the 0-based progression index for active lifecycle steps.

type Tier

ident
1type Tier string
source

Tier represents a builder or agent's earned on-chain reputation rank.

Methods on Tier

func Color

method on Tier
1func (t Tier) Color() string
source

TierColor returns a high-contrast hex accent color for SVG badges.

Dependencies

Imports 3

/p/g1x582angdzrqadgv4382j6y7ju6fj5wll6yuuq4/hearthcore/v0

Imported by indexer

Source Files 5