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.

util.gno

0.71 Kb · 43 lines
 1package grc721v2
 2
 3const (
 4	MaxNameLen   = 64
 5	MaxSymbolLen = 11
 6)
 7
 8var zeroAddress = address("")
 9
10func isValidAddress(addr address) error {
11	if !addr.IsValid() {
12		return ErrInvalidAddress
13	}
14	return nil
15}
16
17func validName(name string) bool {
18	if name == "" || len(name) > MaxNameLen {
19		return false
20	}
21	for _, c := range name {
22		if c < 0x20 || c == 0x7f {
23			return false
24		}
25	}
26	return true
27}
28
29func validSymbol(symbol string) bool {
30	if symbol == "" || len(symbol) > MaxSymbolLen {
31		return false
32	}
33	for _, c := range symbol {
34		if !isAlnum(c) && c != '_' && c != '-' {
35			return false
36		}
37	}
38	return true
39}
40
41func isAlnum(c rune) bool {
42	return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9')
43}