Realm detail
test3
gno.land/r/nym-encapsulate001/test3
Indexed deployment identity with independently loaded latest RPC source, functions, and Render.
Indexed deployment
Identity
- Package path
- gno.land/r/nym-encapsulate001/test3
- Block
- 270468
- Deployed (UTC)
- Transaction
- r1NsRPtWGA4t+rU8+sXOpyXqgJyiho2ZlO5YuSOlk8E=
Latest RPC state
Source
package test3
import (
"gno.land/p/nt/avl/v0"
"gno.land/p/nt/ownable/v0"
"gno.land/p/nt/seqid/v0"
)
// FieldKind is the input type a field renders as, and the validation it gets.
type FieldKind string
const (
KindText FieldKind = "text"
KindTextarea FieldKind = "textarea"
KindNumber FieldKind = "number"
KindSelect FieldKind = "select"
)
// Limits. Answers are stored on chain and the respondent pays the storage
// deposit for them, so the caps exist to keep that cost predictable rather
// than to save the realm anything.
const (
MaxFields = 8
MaxTitleLen = 120
MaxDescriptionLen = 2048
MaxLabelLen = 120
MaxOptionLen = 120
MaxTextLen = 256
MaxTextareaLen = 2048
MaxNumberLen = 64
)
// Field is one question on a form.
type Field struct {
Label string
Kind FieldKind
Required bool
Options []string // select only
}
// MaxLen is the longest answer the field accepts.
func (f Field) MaxLen() int {
switch f.Kind {
case KindTextarea:
return MaxTextareaLen
case KindNumber:
return MaxNumberLen
case KindSelect:
return MaxOptionLen
default:
return MaxTextLen
}
}
// Slug rules. A slug is the form's ID and its URL segment, chosen at creation:
// lowercase letters and digits, single hyphens between words, 3–48 characters.
const (
MinSlugLen = 3
MaxSlugLen = 48
)
// Form is a published questionnaire and its responses.
type Form struct {
ID string // the slug
Title string
Description string
Fields []Field
OnePerAddr bool
Deadline int64 // chain height; 0 means none
Closed bool
CreatedAt int64
owner *ownable.Ownable
responses *avl.Tree // response id -> *Response
byAddr *avl.Tree // author address -> response id
}
// Owner returns the form owner's address.
func (f *Form) Owner() address {
return f.owner.Owner()
}
// ResponseCount returns how many responses the form currently holds.
func (f *Form) ResponseCount() int {
return f.responses.Size()
}
// IsOpen reports whether the form accepts submissions at the given height.
func (f *Form) IsOpen(height int64) bool {
if f.Closed {
return false
}
return f.Deadline == 0 || height < f.Deadline
}
// Response is one submission to a form. Answers align with Form.Fields.
type Response struct {
ID seqid.ID
Form string // the form slug
Author address
Height int64
Answers []string
}
Latest RPC state
Exported functions
- Create(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, slug string, title string, description string, labels string, kinds string, required string, options string, onePerAddr bool, deadline int64) string
- CreateForm(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, slug string, title string, description string, l1 string, k1 string, r1 string, o1 string, l2 string, k2 string, r2 string, o2 string, l3 string, k3 string, r3 string, o3 string, l4 string, k4 string, r4 string, o4 string, l5 string, k5 string, r5 string, o5 string, l6 string, k6 string, r6 string, o6 string, l7 string, k7 string, r7 string, o7 string, l8 string, k8 string, r8 string, o8 string, onePerAddr string, deadline string) string
- Close(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, id string)
- Reopen(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, id string)
- TransferOwnership(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, id string, to string)
- GetForm(id string) (*gno.land/r/nym-encapsulate001/test3.Form, bool)
- ResponseCount(id string) int
- FormCount() int
- Render(path string) string
Forms
Publish a form, collect responses on chain, read them back here. Respondents fill it in on this page and pay their own storage deposit; withdrawing a response refunds it.
| Form | Status | Responses | Fields | Owner | | --- | --- | --- | --- | --- | | dwefweqdfeq | open | 0 | 2 | g1lyj99a…6u5q | | What would you use an on-chain form for? | open | 0 | 5 | g1eyr3hf…x2v0 |
Create a form
Up to 8 fields. Blank rows are skipped. Submitting opens your wallet with the call already filled in.
From a terminal, Create takes the same thing as pipe-separated field specs — see the realm source.