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

Denom

untyped string

Value

"ugnot"

Path

untyped string

Value

"gno.land/r/moul/faucet/v0"

Owner

.uverse.address

Owner funds the faucet, approves by default, and is the only account that can change who else approves or take the float back. Hardcoded rather than captured from the deployer: inside a plain \`func Test(t \*testing.T)\` the gno test runner reports OriginCaller() as the EMPTY address, so an owner seeded from it is empty in every test and something else on chain. That divergence is where an authorization bug hides, so the address is written down.

Value

<gnolang.StringValue>

StatusPending

untyped string

The three states a request can be in. A request is decided exactly once.

Value

"pending"

StatusSent

untyped string

The three states a request can be in. A request is decided exactly once.

Value

"sent"

StatusDenied

untyped string

The three states a request can be in. A request is decided exactly once.

Value

"denied"

DefaultMaxPerRequest

untyped bigint

Value

(200000000 <untyped> bigint)

MaxReasonLen

untyped bigint

Value

(280 <untyped> bigint)

idWidth

untyped bigint

Value

(12 <untyped> bigint)

request

type

request is one ask. It is unexported because avl stores \`any\` and the readable surface of this realm is its views and its page, not a struct another realm would have to depend on.

Value

v0.request

requests

v0.Tree

// padded id -> \*request

Open
OID
0b3cd8…35a5:50
requests details

Inspect ref

paid

v0.Tree

// recipient address -> int64 ugnot received in total

Open
OID
0b3cd8…35a5:51
paid details

Inspect ref

approvers

v0.Tree

// approver address -> bool

Open
OID
0b3cd8…35a5:52
approvers details

Inspect ref

nextID

int64

Value

3

maxPerRequest

int64

Value

200000000

totalSent

int64

Value

110000000

sentCount

int64

Value

2

deniedCount

int64

Value

0

pendingN

int64

Value

0

reset

func()

reset installs an empty faucet. Also called by the tests: realm globals persist for a whole test binary and examples run after every Test, so a pinned Render has to start from a known state.

Open
OID
0b3cd8…35a5:17
reset details

Inspect func

Balance

func() int64

Balance is what the faucet can actually pay out right now.

Open
OID
0b3cd8…35a5:19
Balance details

Inspect func

NextID

func() int64

NextID is the id the next [Request](#Request) will be given. Read it to build the [Approve](#Approve) half of a two-message transaction, and pass the recipient and amount to Approve so that a request landing in between fails the transaction instead of being paid by it.

Open
OID
0b3cd8…35a5:20
NextID details

Inspect func

MaxPerRequest

func() int64

MaxPerRequest is the current cap on a single payout, in ugnot.

Open
OID
0b3cd8…35a5:21
MaxPerRequest details

Inspect func

TotalSent

func() int64

TotalSent, SentCount, DeniedCount and Pending are the running tallies.

Open
OID
0b3cd8…35a5:22
TotalSent details

Inspect func

Requests

func() int

Requests is how many requests have ever been filed.

Open
OID
0b3cd8…35a5:26
Requests details

Inspect func

IsApprover

func(addr string) bool

IsApprover reports whether addr may approve or deny.

Open
OID
0b3cd8…35a5:27
IsApprover details

Inspect func

ReceivedBy

func(addr string) int64

ReceivedBy is everything this faucet has ever paid to addr.

Open
OID
0b3cd8…35a5:28
ReceivedBy details

Inspect func

Status

func(id int64) string

Status is the state of request id: "pending", "sent", "denied", or "" when no such request exists.

Open
OID
0b3cd8…35a5:29
Status details

Inspect func

Fund

func()

Fund credits the ugnot sent with the call to the float. Coins sent straight to \[Address] land there too; they just do not emit an event.

Open
OID
0b3cd8…35a5:30
Fund details

Inspect func

Request

func(to string, amount int64, reason string) int64

Request files an ask for amount ugnot to be paid to \`to\`, and returns its id. Anyone may file, for anyone, which is the point: the account that needs the coins is the one that cannot pay to ask for them. Filing costs the filer gas and nothing else, and moves no money.

Open
OID
0b3cd8…35a5:31
Request details

Inspect func

Approve

func(id int64, wantTo string, wantAmount int64)

Approve pays request id out of the float. Approvers only. wantTo and wantAmount are not redundant: they are what makes it safe to put Approve in the same transaction as the Request it settles. The id has to be guessed from [NextID](#NextID) before either message is signed, and this call refuses when the request sitting at that id is not the one the caller described.

Open
OID
0b3cd8…35a5:32
Approve details

Inspect func

Deny

func(id int64, why string)

Deny closes a request unpaid, with a reason that goes on the page. The reason is the whole value of denying in public rather than ignoring it.

Open
OID
0b3cd8…35a5:33
Deny details

Inspect func

AddApprover

func(addr string)

AddApprover lets addr approve and deny. Owner only.

Open
OID
0b3cd8…35a5:34
AddApprover details

Inspect func

RemoveApprover

func(addr string)

RemoveApprover revokes addr. Owner only, and the Owner cannot be removed: a faucet with no approver is a faucet with a locked float.

Open
OID
0b3cd8…35a5:35
RemoveApprover details

Inspect func

SetMaxPerRequest

func(amount int64)

SetMaxPerRequest changes the per-request cap, in ugnot. Owner only.

Open
OID
0b3cd8…35a5:36
SetMaxPerRequest details

Inspect func

Withdraw

func(amount int64)

Withdraw returns amount ugnot of the float to the Owner. Owner only. This is what makes funding the faucet reversible, and it is deliberately not payable to an arbitrary address: an approver who wanted to move money somewhere has to file a request for it like everyone else.

Open
OID
0b3cd8…35a5:37
Withdraw details

Inspect func

mustOwn

func(caller .uverse.address)
Open
OID
0b3cd8…35a5:38
mustOwn details

Inspect func

mustApprove

func(caller .uverse.address)
Open
OID
0b3cd8…35a5:39
mustApprove details

Inspect func

key

func(id int64) string

key pads an id to idWidth digits so the avl tree iterates in filing order.

Open
OID
0b3cd8…35a5:41
key details

Inspect func

Render

func(path string) string

Render shows the float, the open asks and everything already decided. Two paths: "" is the whole board, "req/\<id>" is one request. Every string on this page that a caller typed goes through sanitize before it is concatenated. A reason is arbitrary text from an arbitrary account and Render output is markdown that gnoweb parses, so an unescaped one can plant a link, an image beacon or gnoweb chrome on a page the realm is signing for. This realm's path is permanent, so that bug could only ever be fixed at a new path.

Open
OID
0b3cd8…35a5:42
Render details

Inspect func

table

func(want string) string

table lists requests in filing order, keeping only those in \`want\`, or everything already decided when want is empty.

Open
OID
0b3cd8…35a5:45
table details

Inspect func

renderOne

func(id int64) string
Open
OID
0b3cd8…35a5:46
renderOne details

Inspect func

reqPath

func(path string) (int64, bool)

reqPath parses "req/\<id>".

Open
OID
0b3cd8…35a5:47
reqPath details

Inspect func

excerpt

func(s string, width int) string

excerpt cuts to width RUNES, never bytes: slicing a multi-byte character in half puts invalid UTF-8 on the page, and one emoji in a reason is enough. It cuts before escaping, because escaping inserts backslashes and cutting an already-escaped string can strand a lone one that escapes the chrome after it.

Open
OID
0b3cd8…35a5:48
excerpt details

Inspect func

gnot

func(ugnot int64) string

gnot renders ugnot as GNOT with the trailing zeros of the fraction trimmed, so 100000000 reads as 100 and 1500000 as 1.5.

Open
OID
0b3cd8…35a5:49
gnot details

Inspect func

intro

untyped string

Value

"Somebody you trust has no GNOT and cannot use the public faucet. File a\nrequest on their behalf, an approver releases it, and both halves stay on\nthis page with a reason attached. The faucet only ever spends what has been\nsent to its own address."

howto

untyped string

Value

"## How\n\n`Request(to, amount, reason)` is open to anyone and moves no money.\n`Approve(id, to, amount)` pays it, and only an approver can call it.\n\nSend both in **one transaction**: a tm2 transaction stops at the first\nmessage that fails and writes none of t"...
Denom : untyped string ="ugnot"
Path : untyped string ="gno.land/r/moul/faucet/v0"
Owner : .uverse.address =<gnolang.StringValue>
StatusPending : untyped string ="pending"
StatusSent : untyped string ="sent"
StatusDenied : untyped string ="denied"
DefaultMaxPerRequest : untyped bigint =(200000000 <untyped> bigint)
MaxReasonLen : untyped bigint =(280 <untyped> bigint)
idWidth : untyped bigint =(12 <untyped> bigint)
request : type =v0.request
requests : v0.Tree Inspect
paid : v0.Tree Inspect
approvers : v0.Tree Inspect
nextID : int64 =3
maxPerRequest : int64 =200000000
totalSent : int64 =110000000
sentCount : int64 =2
deniedCount : int64 =0
pendingN : int64 =0
init.20 : func() Inspect
reset : func() Inspect
Address : func() .uverse.address Inspect
Balance : func() int64 Inspect
NextID : func() int64 Inspect
MaxPerRequest : func() int64 Inspect
TotalSent : func() int64 Inspect
SentCount : func() int64 Inspect
DeniedCount : func() int64 Inspect
Pending : func() int64 Inspect
Requests : func() int Inspect
IsApprover : func(addr string) bool Inspect
ReceivedBy : func(addr string) int64 Inspect
Status : func(id int64) string Inspect
Fund : func() Inspect
Request : func(to string, amount int64, reason string) int64 Inspect
Approve : func(id int64, wantTo string, wantAmount int64) Inspect
Deny : func(id int64, why string) Inspect
AddApprover : func(addr string) Inspect
RemoveApprover : func(addr string) Inspect
SetMaxPerRequest : func(amount int64) Inspect
Withdraw : func(amount int64) Inspect
mustOwn : func(caller .uverse.address) Inspect
mustApprove : func(caller .uverse.address) Inspect
find : func(id int64) *v0.request Inspect
key : func(id int64) string Inspect
Render : func(path string) string Inspect
renderBoard : func() string Inspect
table : func(want string) string Inspect
renderOne : func(id int64) string Inspect
reqPath : func(path string) (int64, bool) Inspect
excerpt : func(s string, width int) string Inspect
gnot : func(ugnot int64) string Inspect
intro : untyped string ="Somebody you trust has no GNOT and cannot use the public faucet. File a\nrequest on their behalf, an approver releases it, and both halves stay on\nthis page with a reason attached. The faucet only ever spends what has been\nsent to its own address."
howto : untyped string ="## How\n\n`Request(to, amount, reason)` is open to anyone and moves no money.\n`Approve(id, to, amount)` pays it, and only an approver can call it.\n\nSend both in **one transaction**: a tm2 transaction stops at the first\nmessage that fails and writes none of t"...