utils

package
v0.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2026 License: UNKNOWN not legal advice Imports: 0 Imported by: 0

Documentation

Overview

Package utils holds the response types of the vm/*_json ABCI queries and helpers for presenting the decoded gno values.

The response types must be decoded with amino.UnmarshalJSON. The keeper encodes them with amino, and their gno.Type and gno.Value interface fields carry amino type tags that encoding/json cannot resolve. Amino rejects unknown fields, so a response from a newer node with an added field fails to decode instead of being partially read, and it can panic on malformed input, so callers decoding bytes from an untrusted node should recover.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClampSliceWindow

func ClampSliceWindow(offset, length, listLen int) (int, int)

ClampSliceWindow returns a safe [offset:end] window into a backing list of the given length, guarding against chain-supplied negative or out-of-range Offset/Length and against offset+length overflow. listLen must be >= 0, as from len(); a negative listLen is not guarded and yields a window that would panic when sliced.

func PrimitiveString

func PrimitiveString(pt gno.PrimitiveType, tv gno.TypedValue) string

PrimitiveString formats the bool or numeric value in tv.N as the primitive type pt, for example "true", "-42" or "1.5". For other types, just return tv.String().

It panics if pt is not a valid PrimitiveType, because tv.String() does. A pt decoded from an untrusted or newer-version RPC response can be invalid, so callers in that position must recover (as gnoweb does), unlike PrimitiveTypeName, which returns a placeholder for unknown values.

func PrimitiveTypeName

func PrimitiveTypeName(pt gno.PrimitiveType) string

PrimitiveTypeName returns the name of the primitive type pt, for example "int" or "untyped bool".

func ResolveTypeID

func ResolveTypeID(t gno.Type) string

ResolveTypeID returns the TypeID string for qtype_json lookup, drilling through PointerType so `*foo.Bar` resolves to Bar's TypeID.

Types

type EvalResponse

type EvalResponse struct {
	Results []gno.TypedValue `json:"results"`
	Error   *string          `json:"@error,omitempty"`
}

EvalResponse is the response of the "vm/qeval_json" query.

type ObjectResponse

type ObjectResponse struct {
	ObjectID string    `json:"objectid"`
	Value    gno.Value `json:"value"`
}

ObjectResponse is the response of the "vm/qobject_json" query.

type PkgResponse

type PkgResponse struct {
	Names  []string         `json:"names"`
	Values []gno.TypedValue `json:"values"`
}

PkgResponse is the response of the "vm/qpkg_json" query.

type TypeResponse

type TypeResponse struct {
	TypeID string   `json:"typeid"`
	Type   gno.Type `json:"type"`
}

TypeResponse is the response of the "vm/qtype_json" query.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL