Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

/semver package

Overview

Package semver is an on-chain port of the core of golang.org/x/mod/semver (and the spirit of github.com/Masterminds/semver): parse "vMAJOR.MINOR.PATCH [-prerelease][+build]" strings and compare them with correct Semantic Versioning 2.0.0 precedence. Pure and deterministic — no time, randomness, goroutines, or I/O.

Functions

Compare

func Compare(a, b string) int

Compare returns -1, 0, or +1 as a < b, a == b, or a > b under semver precedence. Unparseable inputs sort after everything valid (and equal to each other), so Compare never panics.

Params

Command

gnokey query vm/qeval -remote "https://rpc.topaz.testnets.gno.land" -data "gno.land/r/g12cs4cehujpffpjpywmkqj43m6u5ya53nj69sjz/semver.Compare(,)"

Result

Render

func Render(path string) string

Param

Command

gnokey query vm/qeval -remote "https://rpc.topaz.testnets.gno.land" -data "gno.land/r/g12cs4cehujpffpjpywmkqj43m6u5ya53nj69sjz/semver.Render()"

Result

Submit

func Submit(cur realm, version string)

Submit stores a valid version on-chain, tagged with the caller's address, so Render("/sorted") can list everyone's submissions in precedence order.

Param

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/g12cs4cehujpffpjpywmkqj43m6u5ya53nj69sjz/semver" -func "Submit" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "topaz-1" -remote "https://rpc.topaz.testnets.gno.land" ADDRESSgnokey query -remote "https://rpc.topaz.testnets.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/g12cs4cehujpffpjpywmkqj43m6u5ya53nj69sjz/semver" -func "Submit" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "topaz-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.topaz.testnets.gno.land" call.tx
  

Parse

func Parse(s string) (Version, error)

Parse reads "vMAJOR.MINOR.PATCH[-prerelease][+build]". The leading 'v' is optional. Numeric fields must be non-empty digit runs without leading zeros.

Param

Command

gnokey query vm/qeval -remote "https://rpc.topaz.testnets.gno.land" -data "gno.land/r/g12cs4cehujpffpjpywmkqj43m6u5ya53nj69sjz/semver.Parse()"

Result