bech32Value
[256]uint8bech32Value holds, for each character of the bech32 alphabet "qpzry9x8gf2tvdw0s3jn54khce6mua7l", its 5-bit value plus one. Zero marks every other byte, capitals included.
- OID
- 016c93…41f1:4
bech32Value details
bech32Gen
[32]uint32bech32Gen\[t] is the XOR of the BIP-173 generators selected by the five bits of t: one table read per character instead of five tests.
- OID
- 016c93…41f1:6
bech32Gen details
bech32PrefixState
uint32The checksum state once the address prefix "g" has been absorbed, which BIP-173 expands to the values 3, 0, 7.
Value
35847
canonical
func(a .uverse.address) boolcanonical reports whether a is "g1", then 38 lowercase bech32 characters whose checksum is the original bech32 one: the form a caller's address has.
- OID
- 016c93…41f1:7
canonical details
cols
untyped bigintValue
(7 <untyped> bigint)
rows
untyped bigintValue
(6 <untyped> bigint)
board
typeboard is indexed \[column]\[row]; row 0 is the bottom. 0 = empty, 1/2 = player.
Value
connect4.board
moveTimeout
time.DurationValue
<zero>
maxOfferTTL
untyped bigint// minutes
Value
(60 <untyped> bigint)
feeCap
untyped bigintValue
(500000 <untyped> bigint)
minStake
untyped bigint// ugnot
Value
(1000000 <untyped> bigint)
denom
untyped stringValue
"ugnot"
Status
typeValue
connect4.Status
Open
connect4.StatusValue
<zero>
Playing
connect4.StatusValue
<zero>
Won
connect4.StatusValue
<zero>
Draw
connect4.StatusValue
<zero>
Void
connect4.StatusValue
<zero>
Cancelled
connect4.StatusValue
<zero>
Game
typeValue
connect4.Game
Stats
typeValue
connect4.Stats
games
v0.Tree// key(id) -> \*Game
- OID
- 016c93…41f1:10
games details
active
v0.Tree// key(id) -> \*Game, only Open and Playing
- OID
- 016c93…41f1:12
active details
stats
v0.Tree// address -> \*Stats
- OID
- 016c93…41f1:14
stats details
nextID
intValue
2
fee
int64// ugnot per decisive game
Value
100000
feesCollected
int64Value
0
owner
*v0.Ownable// the deployer; nil (no owner) if deployed some other way
- OID
- 016c93…41f1:90
owner details
pendingOwner
.uverse.address// set by TransferOwnership, made owner by AcceptOwnership
Value
<zero>
used
v0.Tree// address + ":" + commitment -> true, both kinds
- OID
- 016c93…41f1:21
used details
testSession
boolValue
false
init.31
func()- OID
- 016c93…41f1:23
init.31 details
Offer
func(opponent .uverse.address, validFor int, commitment string, maxFee int64) intOffer posts a game open for validFor minutes. The stake is the ugnot sent with the call. A non-empty opponent makes the offer private. commitment is the lowercase hex sha256 of a secret passphrase, revealed after Accept.
- OID
- 016c93…41f1:25
Offer details
validateOffer
func(stake int64, validFor int, opponent .uverse.address, commitment string) []stringvalidateOffer returns every rule an offer breaks. Offer panics with the first; the "new" page lists them all before anyone signs.
- OID
- 016c93…41f1:26
validateOffer details
Accept
func(id int, seedCommitment string)Accept joins an open offer by sending exactly its stake. seedCommitment is the lowercase hex sha256 of a secret seed, revealed after the creator's passphrase. The creator then has 90s to Reveal.
- OID
- 016c93…41f1:27
Accept details
Reveal
func(id int, passphrase string)Reveal discloses the creator's passphrase. It must come within 90s of Accept; the acceptor then has 90s to RevealSeed.
- OID
- 016c93…41f1:28
Reveal details
RevealSeed
func(id int, seed string)RevealSeed discloses the acceptor's seed, which with the creator's passphrase picks the first mover. It must come within 90s of Reveal.
- OID
- 016c93…41f1:29
RevealSeed details
firstMover
func(passphrase string, seed string, g *connect4.Game) uint8firstMover draws 1 (creator) or 2 (acceptor) from both secrets.
- OID
- 016c93…41f1:30
firstMover details
Play
func(id int, column int, move int)Play drops a piece in column (1-7). move is the game's move count the player saw (Moves before this piece): a resent or delayed move that the game has moved past is refused instead of being played on a later turn.
- OID
- 016c93…41f1:31
Play details
ClaimTimeout
func(id int)ClaimTimeout settles a game whose move clock ran out. Anyone may call it.
- OID
- 016c93…41f1:32
ClaimTimeout details
Resign
func(id int)Resign concedes a game in progress.
- OID
- 016c93…41f1:33
Resign details
Cancel
func(id int)Cancel withdraws an open offer and refunds the creator. The creator may cancel at any time; anyone may once the offer has expired.
- OID
- 016c93…41f1:34
Cancel details
SetFee
func(amount int64)SetFee changes the flat house fee, in ugnot, for new offers. Games already offered keep the fee they were created with.
- OID
- 016c93…41f1:35
SetFee details
WithdrawFees
func(to .uverse.address)WithdrawFees sends all collected fees to to.
- OID
- 016c93…41f1:36
WithdrawFees details
TransferOwnership
func(newOwner .uverse.address)TransferOwnership names the next owner, who becomes owner by calling AcceptOwnership. Two steps, so a mistyped or non-canonical address can never strand ownership (and the fees): only an address that signs can accept, and it is recorded as it signs.
- OID
- 016c93…41f1:37
TransferOwnership details
AcceptOwnership
func()AcceptOwnership completes a TransferOwnership; only the named address may call it.
- OID
- 016c93…41f1:38
AcceptOwnership details
useCommitment
func(addr .uverse.address, commitment string)useCommitment records a commitment for addr, refusing one it already used: a revealed secret is public, so reusing it hands the other side the draw. Keyed by address, so nobody can block another player's commitment.
- OID
- 016c93…41f1:39
useCommitment details
received
func() int64received returns the ugnot sent with a direct user call. OriginSend only describes a real payment to this realm when the caller is an EOA using maketx call; see docs/resources/effective-gno.md.
- OID
- 016c93…41f1:40
received details
noCoins
func()noCoins guards calls that take no payment: coins sent with them would be stuck in the realm.
- OID
- 016c93…41f1:41
noCoins details
noSession
func(action string)noSession refuses calls signed by an account session key.
- OID
- 016c93…41f1:42
noSession details
sha256Hex
func(s string) string- OID
- 016c93…41f1:43
sha256Hex details
isHexSHA256
func(s string) bool- OID
- 016c93…41f1:44
isHexSHA256 details
settleWin
func(g *connect4.Game, winner .uverse.address)- OID
- 016c93…41f1:45
settleWin details
settleDraw
func(g *connect4.Game)- OID
- 016c93…41f1:46
settleDraw details
settleVoid
func(g *connect4.Game)- OID
- 016c93…41f1:47
settleVoid details
leader
typeleader is one leaderboard row. The boards are kept at settlement so Render never walks every player's stats.
Value
connect4.leader
topWins
[]connect4.leader// highest first, at most topN
Value
<zero>
topGnot
[]connect4.leader// highest first, at most topN
Value
<zero>
topN
untyped bigintValue
(10 <untyped> bigint)
bump
func(board []connect4.leader, addr .uverse.address, score int64) []connect4.leaderbump moves addr to its new score in board. Scores only grow, so a player already listed can only move up; ties keep the earlier holder first.
- OID
- 016c93…41f1:50
bump details
finish
func(g *connect4.Game, s connect4.Status)- OID
- 016c93…41f1:51
finish details
send
func(to .uverse.address, amount int64)- OID
- 016c93…41f1:52
send details
statsOf
func(addr .uverse.address) *connect4.Stats- OID
- 016c93…41f1:53
statsOf details
key
func(id int) stringkey zero-pads ids so avl iteration order matches creation order.
- OID
- 016c93…41f1:54
key details
get
func(id int) *connect4.Game- OID
- 016c93…41f1:55
get details
mustGet
func(id int) *connect4.Game- OID
- 016c93…41f1:56
mustGet details
GameJSON
func(id int) stringGameJSON returns {"now":\<unix>,"game":\<game>|null}. It is a read-only accessor for clients querying over vm/qeval; now is the block time.
- OID
- 016c93…41f1:57
GameJSON details
ActiveJSON
func(offset int, limit int) stringActiveJSON returns {"now":\<unix>,"fee":\<ugnot>,"games":\[...]}: the house fee for new offers, then Open and Playing games in id order, skipping offset and returning at most limit (clamped to 1-100).
- OID
- 016c93…41f1:59
ActiveJSON details
writeNow
func(b *strings.Builder)- OID
- 016c93…41f1:60
writeNow details
writeGame
func(b *strings.Builder, g *connect4.Game)writeGame emits one game. Every stored string is validated on write (addresses by IsValid, the commitment as hex), so Quote is defence in depth.
- OID
- 016c93…41f1:61
writeGame details
writeStr
func(b *strings.Builder, k string, v string)writeStr and writeNum append \`,"k":v\`; the caller writes the first field.
- OID
- 016c93…41f1:62
writeStr details
writeNum
func(b *strings.Builder, k string, v int64)- OID
- 016c93…41f1:63
writeNum details
LeadersJSON
func() stringLeadersJSON returns {"wins":\[...],"gnot":\[...]}: the top-10 boards (most games won, most ugnot won) kept at settlement, highest first. Each entry is {"addr":\<address>,"score":\<int>}.
- OID
- 016c93…41f1:64
LeadersJSON details
writeLeaders
func(b *strings.Builder, board []connect4.leader)- OID
- 016c93…41f1:65
writeLeaders details
lobbyRows
untyped bigintlobbyRows caps the games the lobby lists, so Render stays within query gas however many games are open; clients page through ActiveJSON instead.
Value
(50 <untyped> bigint)
red
untyped stringBoard colours. gnoweb only embeds SVG as data-URI images, so each column is its own image, wrapped in its Play link while the game is being played.
Value
"#e53935"
yellow
untyped stringBoard colours. gnoweb only embeds SVG as data-URI images, so each column is its own image, wrapped in its Play link while the game is being played.
Value
"#fdd835"
hole
untyped stringBoard colours. gnoweb only embeds SVG as data-URI images, so each column is its own image, wrapped in its Play link while the game is being played.
Value
"#ffffff"
boardBlue
untyped stringBoard colours. gnoweb only embeds SVG as data-URI images, so each column is its own image, wrapped in its Play link while the game is being played.
Value
"#1565c0"
lastMoveStroke
untyped stringBoard colours. gnoweb only embeds SVG as data-URI images, so each column is its own image, wrapped in its Play link while the game is being played.
Value
"#212121"
winStroke
untyped stringBoard colours. gnoweb only embeds SVG as data-URI images, so each column is its own image, wrapped in its Play link while the game is being played.
Value
"#00e676"
cellPx
untyped bigintBoard colours. gnoweb only embeds SVG as data-URI images, so each column is its own image, wrapped in its Play link while the game is being played.
Value
(48 <untyped> bigint)
headerPx
untyped bigintBoard colours. gnoweb only embeds SVG as data-URI images, so each column is its own image, wrapped in its Play link while the game is being played.
Value
(20 <untyped> bigint)
pieceColor
[3]string- OID
- 016c93…41f1:67
pieceColor details
pieceName
[3]string- OID
- 016c93…41f1:69
pieceName details
Render
func(path string) stringRender serves "" (lobby and leaderboards), "new" (offer form) and "game/\<id>" (one game with every action its state allows). Everything written comes from realm state or from query values that have been validated and re-formatted; raw path input is never echoed.
- OID
- 016c93…41f1:70
Render details
pageURL
func(page string) stringpageURL links to one of this realm's Render pages. The realm path is read at runtime, like txlink does, so links work wherever the realm is deployed.
- OID
- 016c93…41f1:72
pageURL details
gameLink
func(base string, id int) string- OID
- 016c93…41f1:73
gameLink details
renderLobby
func() string- OID
- 016c93…41f1:74
renderLobby details
renderNew
func(query string) stringrenderNew shows the offer form and, once submitted, a single Offer link with the stake and every argument prefilled (gnoweb cannot edit .send).
- OID
- 016c93…41f1:75
renderNew details
renderGame
func(g *connect4.Game) string- OID
- 016c93…41f1:76
renderGame details
boardView
func(g *connect4.Game, now time.Time) stringboardView draws the board. While a move can be played it is 7 column images, each wrapped in its Play link (gnoweb lays linked images out side by side). Otherwise it is one image of all 7 columns, since gnoweb stacks bare images vertically. The last move gets a dark ring, a winning line a green one.
- OID
- 016c93…41f1:77
boardView details
drawColumn
func(canvas *v0.Canvas, g *connect4.Game, win *[7][6]bool, c int, x int) stringdrawColumn draws column c at horizontal offset x and returns its alt text.
- OID
- 016c93…41f1:78
drawColumn details
onTurn
func(g *connect4.Game) stringonTurn names who the game waits for.
- OID
- 016c93…41f1:79
onTurn details
clockLeft
func(g *connect4.Game, now time.Time) stringclockLeft is the time left on the move clock, or "clock ran out". Play is still accepted in the deadline block itself, so zero left is not expired.
- OID
- 016c93…41f1:80
clockLeft details
acceptURL
func(g *connect4.Game) string- OID
- 016c93…41f1:81
acceptURL details
digits
func(s string) bool- OID
- 016c93…41f1:82
digits details
openTo
func(g *connect4.Game) string- OID
- 016c93…41f1:83
openTo details
parseGNOT
func(s string) (int64, bool)parseGNOT parses a decimal GNOT amount ("10", "2.5") into ugnot.
- OID
- 016c93…41f1:84
parseGNOT details
leaderboard
func(board []connect4.leader, format func(...)) stringleaderboard renders a board kept at settlement (topWins, topGnot).
- OID
- 016c93…41f1:85
leaderboard details
gnot
func(ugnot int64) stringgnot formats ugnot as GNOT with up to 6 decimals.
- OID
- 016c93…41f1:86
gnot details
remaining
func(d time.Duration) string- OID
- 016c93…41f1:87
remaining details
orNone
func(a .uverse.address) string- OID
- 016c93…41f1:88