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

v0 state

Back to all declarations

version

int64

// bumps on every admin write, see Version

Value

1

arenas

v0.BPTree

// arena id -> \*arena, with its lobby and its round

Open
OID
0e5ce9…8022:219
arenas details

Inspect ref

results

v0.BPTree

// arena id -> encoded result, see results.gno

Open
OID
0e5ce9…8022:220
results details

Inspect ref

closed

[]string

The whole state of the realm. Everything is unexported and nothing below is ever returned by reference: the trees are /p/ types with mutator methods, so handing one out would be handing out write access to the realm.

Value

<zero>

refundDelay

int64

// seconds after a game's time limit before anyone may refund it

Value

600

escrowed

int64

// ugnot owed to players: the stakes of every lobby and running game, and their unclaimed winnings

Value

0

claims

v0.BPTree

// player address -> encoded credits

Open
OID
0e5ce9…8022:221
claims details

Inspect ref

earnings

v0.BPTree

// player address -> encoded totals, allocated on a first settled game

Open
OID
0e5ce9…8022:222
earnings details

Inspect ref

winners

v0.ranking

// the top players by winnings

Open
OID
0e5ce9…8022:223
winners details

Inspect ref

webPath

string

// "/r/g1t2kg2vtr3fukg43eujkn6x53gfdyakhngt4sfd/gnofly/arena/v0", used to build links in Render

Value

"/r/g1t2kg2vtr3fukg43eujkn6x53gfdyakhngt4sfd/gnofly/arena/v0"

defaultRefundDelay

untyped bigint

// seconds

Value

(600 <untyped> bigint)

bootstrap

func(pkgPath string)

bootstrap (re)creates the initial state. The tests call it to start from a clean slate.

Open
OID
0e5ce9…8022:20
bootstrap details

Inspect func

Version

func() int64

Version returns a counter that bumps on every admin write: the refund delay. Player and referee actions do not bump it.

Open
OID
0e5ce9…8022:21
Version details

Inspect func

now

func() int64

now returns the block time in Unix seconds.

Open
OID
0e5ce9…8022:22
now details

Inspect func

webPathOf

func(pkgPath string) string

webPathOf turns "gno.land/r/..." into "/r/...".

Open
OID
0e5ce9…8022:23
webPathOf details

Inspect func

claimCredit

type

claimCredit is what one game owes one player.

Value

v0.claimCredit

creditsOf

func(addr .uverse.address) []v0.claimCredit
Open
OID
0e5ce9…8022:25
creditsOf details

Inspect func

credit

func(addr .uverse.address, id string, amount int64)

credit owes amount to a player for the game of an arena. The coins are already in the realm: they stay in the escrow until claimed.

Open
OID
0e5ce9…8022:27
credit details

Inspect func

Claim

func() int64

Claim sends the caller everything the realm owes them from settled games, and returns the amount in ugnot. It panics when there is nothing to claim.

Open
OID
0e5ce9…8022:28
Claim details

Inspect func

Claimable

func(addr .uverse.address) int64

Claimable returns what a player can claim, in ugnot.

Open
OID
0e5ce9…8022:29
Claimable details

Inspect func

ClaimsJSON

func(addr .uverse.address) string

ClaimsJSON returns what a player can claim, game by game, oldest first: { "address": "g1...", "total": 19000000, "games": [ { "id": "...", "amount": 19000000 } ] } The output has no whitespace. An address with nothing to claim returns the same shape with a zero total and no game.

Open
OID
0e5ce9…8022:30
ClaimsJSON details

Inspect func

topSize

untyped bigint

topSize is how many players the list of top winners holds.

Value

(10 <untyped> bigint)

totals

type

totals is what the realm remembers about one player.

Value

v0.totals

totalsOf

func(addr .uverse.address) v0.totals

totalsOf returns the totals of a player, zero for a player who never finished a round.

Open
OID
0e5ce9…8022:31
totalsOf details

Inspect func

creditRound

func(stake int64, players [].uverse.address, payouts []v0.Payout)

creditRound records a settled round for each of its players: one more round played, and what they were paid above their stake, if anything.

Open
OID
0e5ce9…8022:33
creditRound details

Inspect func

ranking

type

ranking is the list of top winners: the players who won the most, best first, at most topSize lines and one line per player. With equal winnings, the player who got there first stays ahead. It is the ranking of the game realm. It is kept sorted at write time, so reading it never has to look at every player. Winnings only going up is what makes that exact: a player outside the list can only enter it through raise. The two slices are parallel: slices of plain values are one stored object each, where a slice of structs would be one object per line.

Value

v0.ranking

spliceAddrs

func(list [].uverse.address, from int, to int, v .uverse.address, size int) [].uverse.address
Open
OID
0e5ce9…8022:34
spliceAddrs details

Inspect func

spliceInts

func(list []int64, from int, to int, v int64, size int) []int64

spliceInts is spliceAddrs for a column of numbers.

Open
OID
0e5ce9…8022:35
spliceInts details

Inspect func

errSpoofedRealm

*errors.errorString

Errors are values created once, at package init: a panic with one of them costs no allocation. Messages that need a value are built at the call.

Open
OID
0e5ce9…8022:37
errSpoofedRealm details

Inspect pointer

errNotOwner

*errors.errorString

Errors are values created once, at package init: a panic with one of them costs no allocation. Messages that need a value are built at the call.

Open
OID
0e5ce9…8022:40
errNotOwner details

Inspect pointer

errNotAdmin

*errors.errorString

Errors are values created once, at package init: a panic with one of them costs no allocation. Messages that need a value are built at the call.

Open
OID
0e5ce9…8022:43
errNotAdmin details

Inspect pointer

errNotReferee

*errors.errorString

Errors are values created once, at package init: a panic with one of them costs no allocation. Messages that need a value are built at the call.

Open
OID
0e5ce9…8022:46
errNotReferee details

Inspect pointer

errInvalidSpec

*errors.errorString

Errors are values created once, at package init: a panic with one of them costs no allocation. Messages that need a value are built at the call.

Open
OID
0e5ce9…8022:49
errInvalidSpec details

Inspect pointer

errInvalidMode

*errors.errorString

Errors are values created once, at package init: a panic with one of them costs no allocation. Messages that need a value are built at the call.

Open
OID
0e5ce9…8022:52
errInvalidMode details

Inspect pointer

errInvalidStake

*errors.errorString

Errors are values created once, at package init: a panic with one of them costs no allocation. Messages that need a value are built at the call.

Open
OID
0e5ce9…8022:55
errInvalidStake details

Inspect pointer

errInvalidSeats

*errors.errorString

Errors are values created once, at package init: a panic with one of them costs no allocation. Messages that need a value are built at the call.

Open
OID
0e5ce9…8022:58
errInvalidSeats details

Inspect pointer

errInvalidLives

*errors.errorString

Errors are values created once, at package init: a panic with one of them costs no allocation. Messages that need a value are built at the call.

Open
OID
0e5ce9…8022:61
errInvalidLives details

Inspect pointer

errInvalidSeconds

*errors.errorString

Errors are values created once, at package init: a panic with one of them costs no allocation. Messages that need a value are built at the call.

Open
OID
0e5ce9…8022:64
errInvalidSeconds details

Inspect pointer

errInvalidKillTarget

*errors.errorString

Errors are values created once, at package init: a panic with one of them costs no allocation. Messages that need a value are built at the call.

Open
OID
0e5ce9…8022:67
errInvalidKillTarget details

Inspect pointer

errRoyaleTarget

*errors.errorString

Errors are values created once, at package init: a panic with one of them costs no allocation. Messages that need a value are built at the call.

Open
OID
0e5ce9…8022:70
errRoyaleTarget details

Inspect pointer

errInvalidAddress

*errors.errorString

Errors are values created once, at package init: a panic with one of them costs no allocation. Messages that need a value are built at the call.

Open
OID
0e5ce9…8022:73
errInvalidAddress details

Inspect pointer

errInvalidRefundDelay

*errors.errorString

Errors are values created once, at package init: a panic with one of them costs no allocation. Messages that need a value are built at the call.

Open
OID
0e5ce9…8022:76
errInvalidRefundDelay details

Inspect pointer

errUnknownArena

*errors.errorString

Errors are values created once, at package init: a panic with one of them costs no allocation. Messages that need a value are built at the call.

Open
OID
0e5ce9…8022:79
errUnknownArena details

Inspect pointer

errNotUserCall

*errors.errorString

Errors are values created once, at package init: a panic with one of them costs no allocation. Messages that need a value are built at the call.

Open
OID
0e5ce9…8022:82
errNotUserCall details

Inspect pointer

errEntryClosed

*errors.errorString

Errors are values created once, at package init: a panic with one of them costs no allocation. Messages that need a value are built at the call.

Open
OID
0e5ce9…8022:85
errEntryClosed details

Inspect pointer

errNotYetCreated

*errors.errorString

Errors are values created once, at package init: a panic with one of them costs no allocation. Messages that need a value are built at the call.

Open
OID
0e5ce9…8022:88
errNotYetCreated details

Inspect pointer

errInvalidTicket

*errors.errorString

Errors are values created once, at package init: a panic with one of them costs no allocation. Messages that need a value are built at the call.

Open
OID
0e5ce9…8022:91
errInvalidTicket details

Inspect pointer

errAlreadyInLobby

*errors.errorString

Errors are values created once, at package init: a panic with one of them costs no allocation. Messages that need a value are built at the call.

Open
OID
0e5ce9…8022:94
errAlreadyInLobby details

Inspect pointer

errLobbyFull

*errors.errorString

Errors are values created once, at package init: a panic with one of them costs no allocation. Messages that need a value are built at the call.

Open
OID
0e5ce9…8022:97
errLobbyFull details

Inspect pointer

errNotInLobby

*errors.errorString

Errors are values created once, at package init: a panic with one of them costs no allocation. Messages that need a value are built at the call.

Open
OID
0e5ce9…8022:100
errNotInLobby details

Inspect pointer

errNotExpired

*errors.errorString

Errors are values created once, at package init: a panic with one of them costs no allocation. Messages that need a value are built at the call.

Open
OID
0e5ce9…8022:103
errNotExpired details

Inspect pointer

errRoundRunning

*errors.errorString

Errors are values created once, at package init: a panic with one of them costs no allocation. Messages that need a value are built at the call.

Open
OID
0e5ce9…8022:106
errRoundRunning details

Inspect pointer

errTooFewPlayers

*errors.errorString

Errors are values created once, at package init: a panic with one of them costs no allocation. Messages that need a value are built at the call.

Open
OID
0e5ce9…8022:109
errTooFewPlayers details

Inspect pointer

errNoRound

*errors.errorString

Errors are values created once, at package init: a panic with one of them costs no allocation. Messages that need a value are built at the call.

Open
OID
0e5ce9…8022:112
errNoRound details

Inspect pointer

errRefundTooEarly

*errors.errorString

Errors are values created once, at package init: a panic with one of them costs no allocation. Messages that need a value are built at the call.

Open
OID
0e5ce9…8022:115
errRefundTooEarly details

Inspect pointer

errBadSettlement

*errors.errorString

Errors are values created once, at package init: a panic with one of them costs no allocation. Messages that need a value are built at the call.

Open
OID
0e5ce9…8022:118
errBadSettlement details

Inspect pointer

errNotConserved

*errors.errorString

Errors are values created once, at package init: a panic with one of them costs no allocation. Messages that need a value are built at the call.

Open
OID
0e5ce9…8022:121
errNotConserved details

Inspect pointer

errEscrow

*errors.errorString

Errors are values created once, at package init: a panic with one of them costs no allocation. Messages that need a value are built at the call.

Open
OID
0e5ce9…8022:124
errEscrow details

Inspect pointer

errInsolvent

*errors.errorString

Errors are values created once, at package init: a panic with one of them costs no allocation. Messages that need a value are built at the call.

Open
OID
0e5ce9…8022:127
errInsolvent details

Inspect pointer

errNothingToClaim

*errors.errorString

Errors are values created once, at package init: a panic with one of them costs no allocation. Messages that need a value are built at the call.

Open
OID
0e5ce9…8022:130
errNothingToClaim details

Inspect pointer

errCorruptClaims

*errors.errorString

Errors are values created once, at package init: a panic with one of them costs no allocation. Messages that need a value are built at the call.

Open
OID
0e5ce9…8022:133
errCorruptClaims details

Inspect pointer

errCorruptResult

*errors.errorString

Errors are values created once, at package init: a panic with one of them costs no allocation. Messages that need a value are built at the call.

Open
OID
0e5ce9…8022:136
errCorruptResult details

Inspect pointer

errCorruptEarnings

*errors.errorString

Errors are values created once, at package init: a panic with one of them costs no allocation. Messages that need a value are built at the call.

Open
OID
0e5ce9…8022:139
errCorruptEarnings details

Inspect pointer

payDenom

untyped string

payDenom is the only coin the realm deals in.

Value

"ugnot"

hold

func(amount int64)

hold records that the realm received amount in stakes.

Open
OID
0e5ce9…8022:141
hold details

Inspect func

release

func(amount int64)

release takes amount out of what the realm owes. It is called before the coins are sent, and it panics rather than let the counter go below zero.

Open
OID
0e5ce9…8022:143
release details

Inspect func

pay

func(int, rlm .uverse.realm, to .uverse.address, amount int64)

pay sends amount ugnot from the realm's own balance to an address. A RealmSend banker can spend everything the realm holds, which is why it is built here and only here, from the live cur of the crossing function (rlm), and never kept. The bank aborts the transaction if the realm does not have the coins.

Open
OID
0e5ce9…8022:144
pay details

Inspect func

assertSolvent

func(int, rlm .uverse.realm)

assertSolvent panics unless the realm holds at least what it owes.

Open
OID
0e5ce9…8022:145
assertSolvent details

Inspect func

Escrowed

func() int64

Escrowed returns what the realm owes to players, in ugnot: the stakes of every lobby and of every running round. The balance of the realm's address is never below it.

Open
OID
0e5ce9…8022:146
Escrowed details

Inspect func

ArenasJSON

func() string

ArenasJSON returns every arena someone paid into and whose game is not over, as a JSON array sorted by id: [ { "id": "3f2a...", "mode": "deathmatch", "stake": 10000000, "minSeats": 2, "maxSeats": 8, "lives": 3, "seconds": 900, "killTarget": 5, "creator": "g1...", "created": 1790950000, "nonce": "k3x9", "lobby": [ { "address": "g1...", "ticket": "9f86d0...00a08" } ], "round": { "startedAt": 1790950300, "players": [ "g1...", "g1..." ] } } ] The output has no whitespace. "round" is null until the game starts. The fields from "mode" to "nonce" are the arena's spec: the game server rebuilds the spec string, and so the id, from them.

Open
OID
0e5ce9…8022:147
ArenasJSON details

Inspect func

ArenaJSON

func(id string) string

ArenaJSON returns one arena in the shape of ArenasJSON, or null.

Open
OID
0e5ce9…8022:149
ArenaJSON details

Inspect func

writeArena

func(b *strings.Builder, id string, a *v0.arena)
Open
OID
0e5ce9…8022:150
writeArena details

Inspect func

ResultsJSON

func() string

ResultsJSON returns the last closed games, newest first, at most 50: [ { "id": "3f2a...", "mode": "deathmatch", "stake": 10000000, "outcome": "settled", "players": 2, "pot": 20000000, "fee": 500000, "closedAt": 1790951000, "payouts": [ { "address": "g1...", "amount": 19500000 } ] } ]

Open
OID
0e5ce9…8022:151
ResultsJSON details

Inspect func

ResultJSON

func(id string) string

ResultJSON returns the result of one closed game in the shape of ResultsJSON, or null when the realm does not have it (still running, or too old).

Open
OID
0e5ce9…8022:152
ResultJSON details

Inspect func

writeResult

func(b *strings.Builder, id string, r v0.result)
Open
OID
0e5ce9…8022:153
writeResult details

Inspect func

EarningsJSON

func() string

EarningsJSON returns the top winners as a JSON array, best first, at most 10 entries: [ { "address": "g1...", "won": 19000000, "rounds": 3 } ] The output has no whitespace. "won" adds up, round after round, what the player was paid above their own stake, never less than zero for a round. "rounds" is how many settled rounds they played. With equal winnings, the player who got there first stays ahead.

Open
OID
0e5ce9…8022:154
EarningsJSON details

Inspect func

PlayerJSON

func(addr .uverse.address) string

PlayerJSON returns one player's totals as a JSON object: { "address": "g1...", "won": 19000000, "rounds": 3 } The output has no whitespace. An unknown address returns the same shape with zero won and zero rounds.

Open
OID
0e5ce9…8022:155
PlayerJSON details

Inspect func

writeTotals

func(b *strings.Builder, quoted string, t v0.totals)

writeTotals writes the totals of a player. quoted is the player's address as a JSON string literal, quotes included.

Open
OID
0e5ce9…8022:156
writeTotals details

Inspect func

quote

func(s string) string

quote returns s as a JSON string literal, quotes included. It is for the strings the realm did not validate. Quotes and backslashes are escaped and anything outside printable ASCII is replaced by "?", so the result is valid JSON whatever s holds.

Open
OID
0e5ce9…8022:157
quote details

Inspect func

arena

type

arena is one game: its spec, the players who paid and wait, and once it started, its round. It is stored from the first paid entry and deleted when its round is closed or its lobby empties.

Value

v0.arena

getArena

func(id string) *v0.arena
Open
OID
0e5ce9…8022:158
getArena details

Inspect func

mustArena

func(id string) *v0.arena
Open
OID
0e5ce9…8022:160
mustArena details

Inspect func

Enter

func(spec string, ticket string) string

Enter puts the caller in the lobby of the arena that spec describes, and returns its id. The exact stake must be attached to the transaction (-send "\<stake>ugnot") and stays in the realm until the player leaves or the game is over. The first entry creates the arena, the next ones join it: the realm recomputes the id from the spec every time. An arena takes entries for an hour after it was created, and until its game starts. ticket is 64 lowercase hex characters, the SHA-256 of a secret the player's client made up: the game server gives the seat to whoever shows the secret. It must be called directly by a user (maketx call): a call relayed by another realm or by a maketx run script is refused.

Open
OID
0e5ce9…8022:161
Enter details

Inspect func

Leave

func(id string)

Leave takes the caller out of the lobby of an arena and sends their stake back. It works until the game starts. The last player out deletes the arena: nothing is left on chain of a game nobody played.

Open
OID
0e5ce9…8022:162
Leave details

Inspect func

ExpireLobby

func(id string)

ExpireLobby closes an arena whose game never started: every player in the lobby gets their stake back, and the arena is deleted. Anyone can call it once the arena stopped taking entries, an hour after it was created.

Open
OID
0e5ce9…8022:163
ExpireLobby details

Inspect func

withAddr

func(list [].uverse.address, v .uverse.address) [].uverse.address
Open
OID
0e5ce9…8022:164
withAddr details

Inspect func

withString

func(list []string, v string) []string

withString returns list with v added at the end.

Open
OID
0e5ce9…8022:165
withString details

Inspect func

withoutAddr

func(list [].uverse.address, at int) [].uverse.address
Open
OID
0e5ce9…8022:166
withoutAddr details

Inspect func

withoutString

func(list []string, at int) []string

withoutString returns list without the element at index at.

Open
OID
0e5ce9…8022:167
withoutString details

Inspect func

Render

func(path string) string

Render returns the state of the arenas as markdown, for gnoweb: "" the open arenas and the last games played "arena/<id>" one arena: its rules, lobby and game, or its result "earnings" the top winners Everything printed here was validated against a narrow charset when it was written (see spec.gno and validate.gno), or is an address the chain gave the realm. The only caller-supplied value, the id of an arena page, is printed only if it is a valid id. Nothing needs markdown escaping.

Open
OID
0e5ce9…8022:168
Render details

Inspect func

renderArena

func(id string, a *v0.arena) string
Open
OID
0e5ce9…8022:172
renderArena details

Inspect func

renderResult

func(id string, r v0.result) string
Open
OID
0e5ce9…8022:173
renderResult details

Inspect func

targetCell

func(n int64) string

targetCell formats a kill target: most arenas end on the clock only.

Open
OID
0e5ce9…8022:174
targetCell details

Inspect func

paidCell

func(r v0.result) string

paidCell lists who was paid what in a round, for a table cell.

Open
OID
0e5ce9…8022:175
paidCell details

Inspect func

renderEarnings

func() string
Open
OID
0e5ce9…8022:176
renderEarnings details

Inspect func

modeDoc

func(mode string) string

modeDoc is one sentence about the payout rule of a mode.

Open
OID
0e5ce9…8022:177
modeDoc details

Inspect func

gnot

func(ugnot int64) string

gnot formats an amount of ugnot in GNOT, without trailing zeros: 10000000 gives "10 GNOT", 9500000 gives "9.5 GNOT", 1 gives "0.000001 GNOT".

Open
OID
0e5ce9…8022:178
gnot details

Inspect func

percent

func(bps int64) string

percent formats basis points as a percentage, without trailing zeros: 500 gives "5%", 250 gives "2.5%", 1 gives "0.01%".

Open
OID
0e5ce9…8022:179
percent details

Inspect func

clock

func(unix int64) string

clock formats a block time in Unix seconds, in UTC.

Open
OID
0e5ce9…8022:180
clock details

Inspect func

result

type

result is how a game ended, kept for readers: no payment is ever computed from it.

Value

v0.result

outcomeSettled

untyped string

Value

"settled"

outcomeCancelled

untyped string

Value

"cancelled"

outcomeRefunded

untyped string

Value

"refunded"

maxResults

untyped bigint

maxResults is how many closed games the realm remembers.

Value

(50 <untyped> bigint)

decodeResult

func(s string) v0.result
Open
OID
0e5ce9…8022:181
decodeResult details

Inspect func

record

func(id string, r v0.result)

record keeps the result of a closed game, and forgets the oldest one past maxResults.

Open
OID
0e5ce9…8022:183
record details

Inspect func

resultOf

func(id string) (v0.result, bool)

resultOf returns the result of a closed game, if the realm still has it.

Open
OID
0e5ce9…8022:184
resultOf details

Inspect func

indexFrom

func(s string, i int, c uint8) int

indexFrom returns the index of the first c in s at or after i, or len(s).

Open
OID
0e5ce9…8022:185
indexFrom details

Inspect func

digits

func(s string) (int64, bool)

digits parses a non-negative decimal of at most 18 digits.

Open
OID
0e5ce9…8022:186
digits details

Inspect func

authority

type

authority is the set of questions this realm asks about roles.

Value

v0.authority

gameRoles

type

gameRoles answers with the roles of the game realm.

Value

v0.gameRoles

roles

v0.gameRoles

roles is the authority of this realm: the game realm, always. It is a variable for one reason. Under \`gno test\` an imported realm is initialized without a deployer, and a test of this package has no way to become the owner of the game realm, so the tests put their own answers here. Nothing outside the test files assigns it, and there is no setter.

Open
OID
0e5ce9…8022:188
roles details

Inspect ref

callerOf

func(int, rlm .uverse.realm) .uverse.address
Open
OID
0e5ce9…8022:189
callerOf details

Inspect func

assertOwner

func(int, rlm .uverse.realm) .uverse.address
Open
OID
0e5ce9…8022:191
assertOwner details

Inspect func

assertAdmin

func(int, rlm .uverse.realm) .uverse.address
Open
OID
0e5ce9…8022:192
assertAdmin details

Inspect func

assertReferee

func(int, rlm .uverse.realm) .uverse.address
Open
OID
0e5ce9…8022:193
assertReferee details

Inspect func

round

type

round is the started game of an arena. Its players are fixed at start, and each of them has one stake in it.

Value

v0.round

StartRound

func(id string) int64

StartRound starts the game of an arena with every player of its lobby. Referee only. The lobby must hold at least minSeats players; it holds at most maxSeats, Enter sees to that. No coin moves: the stakes that were owed to the lobby are now owed to the round. It returns how many play.

Open
OID
0e5ce9…8022:194
StartRound details

Inspect func

SettleRound

func(id string, deaths string)

SettleRound closes the game of an arena: it applies the rule of its mode to what happened, pays the players, and pays the fee to the treasury. Referee only. deaths is "victim:killer" entries separated by ";", in the order they happened, "victim:" when nobody shot the victim down, and the empty string when nobody died. A player dies at most as often as the arena has lives. The referee is trusted for these facts and for nothing else. The rule refuses a victim or a killer who is not a player of the round, and decides the amounts. The realm then checks them (see settle) before it pays.

Open
OID
0e5ce9…8022:196
SettleRound details

Inspect func

settle

func(int, rlm .uverse.realm, id string, a *v0.arena, res v0.Result, referee .uverse.address)

settle closes the game of an arena with the result of its rule. It trusts nothing about the result. Before a counter or a coin moves, checkResult verifies that only players of the round are paid and that the payouts and the fee add up to the pot, to the ugnot.

Open
OID
0e5ce9…8022:197
settle details

Inspect func

withFeeShared

func(players [].uverse.address, payouts []v0.Payout, fee int64) []v0.Payout

withFeeShared returns payouts with fee added, shared between every player of the round, in their order: the remainder goes to the first.

Open
OID
0e5ce9…8022:198
withFeeShared details

Inspect func

checkResult

func(pot int64, players [].uverse.address, res v0.Result)

checkResult panics unless a result can be paid out of a pot: every payout goes to a player of the round, a player is paid at most once and never zero or less, the fee is not negative, and all of it adds up to the pot exactly. The built-in rules guarantee all of this. The check is here so that the realm does not depend on it: whatever a rule returns, the realm never sends more than the pot, and never to a stranger.

Open
OID
0e5ce9…8022:199
checkResult details

Inspect func

CancelRound

func(id string)

CancelRound closes the game of an arena without a result: every player gets their stake back in full. Referee only. The game server uses it for a game it cannot referee, for example one it finds running when it starts.

Open
OID
0e5ce9…8022:200
CancelRound details

Inspect func

RefundRound

func(id string)

RefundRound closes the game of an arena without a result, like CancelRound, and can be called by anyone, once startedAt + seconds + RefundDelay() has passed on the block clock. It is the players' way out when the referee never settles: no stake depends on a server staying up.

Open
OID
0e5ce9…8022:201
RefundRound details

Inspect func

refund

func(int, rlm .uverse.realm, id string, a *v0.arena, outcome string, event string, caller .uverse.address)

refund closes the game of an arena and sends every player their stake back. No fee is taken.

Open
OID
0e5ce9…8022:202
refund details

Inspect func

runningArena

func(id string) *v0.arena

runningArena returns an arena whose game is running. It panics for an unknown arena and for one whose game has not started.

Open
OID
0e5ce9…8022:203
runningArena details

Inspect func

minRefundDelay

untyped bigint

Refund delay bounds, in seconds.

Value

(60 <untyped> bigint)

maxRefundDelay

untyped bigint

Refund delay bounds, in seconds.

Value

(86400 <untyped> bigint)

SetRefundDelay

func(seconds int64)

SetRefundDelay sets how long after a game's time limit anyone may refund it. Admin only.

Open
OID
0e5ce9…8022:204
SetRefundDelay details

Inspect func

RefundDelay

func() int64

RefundDelay returns the refund delay, in seconds.

Open
OID
0e5ce9…8022:205
RefundDelay details

Inspect func

joinAddrs

func(list [].uverse.address) string

joinAddrs writes addresses separated by commas, for an event.

Open
OID
0e5ce9…8022:206
joinAddrs details

Inspect func

joinPayouts

func(list []v0.Payout) string

joinPayouts writes payouts as "address:amount" separated by commas, for an event and for the stored results.

Open
OID
0e5ce9…8022:207
joinPayouts details

Inspect func

specVersion

untyped string

Bounds of a spec, the same as the game server's.

Value

"v1"

idLen

untyped bigint

Bounds of a spec, the same as the game server's.

Value

(24 <untyped> bigint)

minStake

untyped bigint

// ugnot, 1 GNOT

Value

(1000000 <untyped> bigint)

maxStake

untyped bigint

// ugnot, 1000 GNOT

Value

(1000000000 <untyped> bigint)

minSeconds

untyped bigint

// 5 minutes

Value

(300 <untyped> bigint)

maxSeconds

untyped bigint

// 30 minutes

Value

(1800 <untyped> bigint)

entryWindow

untyped bigint

// seconds an arena takes entries after it was created

Value

(3600 <untyped> bigint)

clockSkew

untyped bigint

// seconds a server clock may run ahead of the chain

Value

(300 <untyped> bigint)

maxNonceLen

untyped bigint

Bounds of a spec, the same as the game server's.

Value

(16 <untyped> bigint)

maxSpecLength

untyped bigint

Bounds of a spec, the same as the game server's.

Value

(160 <untyped> bigint)

feeBps

untyped bigint

Bounds of a spec, the same as the game server's.

Value

(500 <untyped> bigint)

spec

type

spec is a parsed arena spec.

Value

v0.spec

idOf

func(s string) string

idOf returns the id of a spec string.

Open
OID
0e5ce9…8022:208
idOf details

Inspect func

parseSpec

func(s string) v0.spec

parseSpec reads and checks a spec string. It panics on anything the realm would not play.

Open
OID
0e5ce9…8022:210
parseSpec details

Inspect func

validNonce

func(s string) bool

validNonce reports whether s is 1 to 16 characters of \[a-z0-9].

Open
OID
0e5ce9…8022:211
validNonce details

Inspect func

validID

func(s string) bool

validID reports whether s can be an arena id: 24 lowercase hex characters.

Open
OID
0e5ce9…8022:212
validID details

Inspect func

ticketLen

untyped bigint

// a SHA-256 in hex

Value

(64 <untyped> bigint)

validTicket

func(s string) bool

validTicket reports whether s is 64 lowercase hex characters, the SHA-256 of the secret a player's client keeps.

Open
OID
0e5ce9…8022:213
validTicket details

Inspect func

validAddress

func(addr .uverse.address) bool

validAddress reports whether addr is a valid address in its canonical, lowercase form. Bech32 can also be written in all capitals, and address.IsValid accepts that. Bech32 does not allow mixing cases, so looking at the first character is enough.

Open
OID
0e5ce9…8022:215
validAddress details

Inspect func

indexOfAddr

func(list [].uverse.address, addr .uverse.address) int

indexOfAddr returns the index of addr in list, -1 when it is not there. The lists of this realm hold at most 16 addresses.

Open
OID
0e5ce9…8022:216
indexOfAddr details

Inspect func
version : int64 =1
arenas : v0.BPTree Inspect
results : v0.BPTree Inspect
closed : []string =<zero>
refundDelay : int64 =600
escrowed : int64 =0
claims : v0.BPTree Inspect
earnings : v0.BPTree Inspect
winners : v0.ranking Inspect
webPath : string ="/r/g1t2kg2vtr3fukg43eujkn6x53gfdyakhngt4sfd/gnofly/arena/v0"
defaultRefundDelay : untyped bigint =(600 <untyped> bigint)
init.11 : func() Inspect
bootstrap : func(pkgPath string) Inspect
Version : func() int64 Inspect
now : func() int64 Inspect
webPathOf : func(pkgPath string) string Inspect
itoa : func(n int64) string Inspect
claimCredit : type =v0.claimCredit
creditsOf : func(addr .uverse.address) []v0.claimCredit Inspect
credit : func(addr .uverse.address, id string, amount int64) Inspect
Claim : func() int64 Inspect
Claimable : func(addr .uverse.address) int64 Inspect
ClaimsJSON : func(addr .uverse.address) string Inspect
topSize : untyped bigint =(10 <untyped> bigint)
totals : type =v0.totals
totalsOf : func(addr .uverse.address) v0.totals Inspect
creditRound : func(stake int64, players [].uverse.address, payouts []v0.Payout) Inspect
ranking : type =v0.ranking
spliceAddrs : func(list [].uverse.address, from int, to int, v .uverse.address, size int) [].uverse.address Inspect
spliceInts : func(list []int64, from int, to int, v int64, size int) []int64 Inspect
errSpoofedRealm : *errors.errorString Inspect
errNotOwner : *errors.errorString Inspect
errNotAdmin : *errors.errorString Inspect
errNotReferee : *errors.errorString Inspect
errInvalidSpec : *errors.errorString Inspect
errInvalidMode : *errors.errorString Inspect
errInvalidStake : *errors.errorString Inspect
errInvalidSeats : *errors.errorString Inspect
errInvalidLives : *errors.errorString Inspect
errInvalidSeconds : *errors.errorString Inspect
errInvalidKillTarget : *errors.errorString Inspect
errRoyaleTarget : *errors.errorString Inspect
errInvalidAddress : *errors.errorString Inspect
errInvalidRefundDelay : *errors.errorString Inspect
errUnknownArena : *errors.errorString Inspect
errNotUserCall : *errors.errorString Inspect
errEntryClosed : *errors.errorString Inspect
errNotYetCreated : *errors.errorString Inspect
errInvalidTicket : *errors.errorString Inspect
errAlreadyInLobby : *errors.errorString Inspect
errLobbyFull : *errors.errorString Inspect
errNotInLobby : *errors.errorString Inspect
errNotExpired : *errors.errorString Inspect
errRoundRunning : *errors.errorString Inspect
errTooFewPlayers : *errors.errorString Inspect
errNoRound : *errors.errorString Inspect
errRefundTooEarly : *errors.errorString Inspect
errBadSettlement : *errors.errorString Inspect
errNotConserved : *errors.errorString Inspect
errEscrow : *errors.errorString Inspect
errInsolvent : *errors.errorString Inspect
errNothingToClaim : *errors.errorString Inspect
errCorruptClaims : *errors.errorString Inspect
errCorruptResult : *errors.errorString Inspect
errCorruptEarnings : *errors.errorString Inspect
payDenom : untyped string ="ugnot"
hold : func(amount int64) Inspect
release : func(amount int64) Inspect
pay : func(int, rlm .uverse.realm, to .uverse.address, amount int64) Inspect
assertSolvent : func(int, rlm .uverse.realm) Inspect
Escrowed : func() int64 Inspect
ArenasJSON : func() string Inspect
ArenaJSON : func(id string) string Inspect
writeArena : func(b *strings.Builder, id string, a *v0.arena) Inspect
ResultsJSON : func() string Inspect
ResultJSON : func(id string) string Inspect
writeResult : func(b *strings.Builder, id string, r v0.result) Inspect
EarningsJSON : func() string Inspect
PlayerJSON : func(addr .uverse.address) string Inspect
writeTotals : func(b *strings.Builder, quoted string, t v0.totals) Inspect
quote : func(s string) string Inspect
arena : type =v0.arena
getArena : func(id string) *v0.arena Inspect
mustArena : func(id string) *v0.arena Inspect
Enter : func(spec string, ticket string) string Inspect
Leave : func(id string) Inspect
ExpireLobby : func(id string) Inspect
withAddr : func(list [].uverse.address, v .uverse.address) [].uverse.address Inspect
withString : func(list []string, v string) []string Inspect
withoutAddr : func(list [].uverse.address, at int) [].uverse.address Inspect
withoutString : func(list []string, at int) []string Inspect
Render : func(path string) string Inspect
renderHome : func() string Inspect
renderArena : func(id string, a *v0.arena) string Inspect
renderResult : func(id string, r v0.result) string Inspect
targetCell : func(n int64) string Inspect
paidCell : func(r v0.result) string Inspect
renderEarnings : func() string Inspect
modeDoc : func(mode string) string Inspect
gnot : func(ugnot int64) string Inspect
percent : func(bps int64) string Inspect
clock : func(unix int64) string Inspect
result : type =v0.result
outcomeSettled : untyped string ="settled"
outcomeCancelled : untyped string ="cancelled"
outcomeRefunded : untyped string ="refunded"
maxResults : untyped bigint =(50 <untyped> bigint)
decodeResult : func(s string) v0.result Inspect
record : func(id string, r v0.result) Inspect
resultOf : func(id string) (v0.result, bool) Inspect
indexFrom : func(s string, i int, c uint8) int Inspect
digits : func(s string) (int64, bool) Inspect
authority : type =v0.authority
gameRoles : type =v0.gameRoles
roles : v0.gameRoles Inspect
callerOf : func(int, rlm .uverse.realm) .uverse.address Inspect
assertOwner : func(int, rlm .uverse.realm) .uverse.address Inspect
assertAdmin : func(int, rlm .uverse.realm) .uverse.address Inspect
assertReferee : func(int, rlm .uverse.realm) .uverse.address Inspect
round : type =v0.round
StartRound : func(id string) int64 Inspect
SettleRound : func(id string, deaths string) Inspect
settle : func(int, rlm .uverse.realm, id string, a *v0.arena, res v0.Result, referee .uverse.address) Inspect
withFeeShared : func(players [].uverse.address, payouts []v0.Payout, fee int64) []v0.Payout Inspect
checkResult : func(pot int64, players [].uverse.address, res v0.Result) Inspect
CancelRound : func(id string) Inspect
RefundRound : func(id string) Inspect
refund : func(int, rlm .uverse.realm, id string, a *v0.arena, outcome string, event string, caller .uverse.address) Inspect
runningArena : func(id string) *v0.arena Inspect
minRefundDelay : untyped bigint =(60 <untyped> bigint)
maxRefundDelay : untyped bigint =(86400 <untyped> bigint)
SetRefundDelay : func(seconds int64) Inspect
RefundDelay : func() int64 Inspect
joinAddrs : func(list [].uverse.address) string Inspect
joinPayouts : func(list []v0.Payout) string Inspect
specVersion : untyped string ="v1"
idLen : untyped bigint =(24 <untyped> bigint)
minStake : untyped bigint =(1000000 <untyped> bigint)
maxStake : untyped bigint =(1000000000 <untyped> bigint)
minSeconds : untyped bigint =(300 <untyped> bigint)
maxSeconds : untyped bigint =(1800 <untyped> bigint)
entryWindow : untyped bigint =(3600 <untyped> bigint)
clockSkew : untyped bigint =(300 <untyped> bigint)
maxNonceLen : untyped bigint =(16 <untyped> bigint)
maxSpecLength : untyped bigint =(160 <untyped> bigint)
feeBps : untyped bigint =(500 <untyped> bigint)
spec : type =v0.spec
idOf : func(s string) string Inspect
parseSpec : func(s string) v0.spec Inspect
validNonce : func(s string) bool Inspect
validID : func(s string) bool Inspect
ticketLen : untyped bigint =(64 <untyped> bigint)
validTicket : func(s string) bool Inspect
validAddress : func(addr .uverse.address) bool Inspect
indexOfAddr : func(list [].uverse.address, addr .uverse.address) int Inspect