Skip to content Search Apps Documentation Source Content Run Reset Eval Playground 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.

admin.gno

2.09 Kb · 48 lines
 1package vs
 2
 3import (
 4	mimir "gno.land/p/g12dcsmwccgdxasqde2eumua88tlrkw83kqf6tcz/mimir"
 5)
 6
 7// Role administration. The rules live in mimir.Roles; see its doc.
 8
 9func TransferOwnership(cur realm, next address) { roles.TransferOwnership(caller(cur), next, now()) }
10func CancelOwnershipTransfer(cur realm)         { roles.CancelOwnershipTransfer(caller(cur)) }
11func AcceptOwnership(cur realm)                 { roles.AcceptOwnership(caller(cur), now()) }
12func QueueOracle(cur realm, next address)       { roles.QueueOracle(caller(cur), next, now()) }
13func RevokeOracle(cur realm)                    { roles.RevokeOracle(caller(cur)) }
14func CancelOracle(cur realm)                    { roles.CancelOracle(caller(cur)) }
15func ExecuteOracle(cur realm)                   { roles.ExecuteOracle(now()) }
16func SetArbiter(cur realm, next address)        { roles.SetArbiter(caller(cur), next) }
17func QueueFeeRecipient(cur realm, next address) { roles.QueueFeeRecipient(caller(cur), next, now()) }
18func CancelFeeRecipient(cur realm)              { roles.CancelFeeRecipient(caller(cur)) }
19func ExecuteFeeRecipient(cur realm)             { roles.ExecuteFeeRecipient(now()) }
20func SetPaused(cur realm, p bool)               { roles.SetPaused(caller(cur), p) }
21func SetCaps(cur realm, market, account int64)  { roles.SetCaps(caller(cur), market, account) }
22
23// SetAuditAgent appoints the reviewer that may dispute with a bond; "" disables it.
24func SetAuditAgent(cur realm, next string) {
25	roles.SetAuditAgent(caller(cur), mimir.ParseOptional(next))
26}
27
28// ClaimFees pays the caller's accrued fees (entry fees, copy fees, forfeited bonds).
29func ClaimFees(cur realm) { claimFeesTo(cur, caller(cur)) }
30
31func ClaimFeesTo(cur realm, to address) {
32	if !to.IsValid() {
33		panic("ZeroRecipient")
34	}
35	claimFeesTo(cur, to)
36}
37
38func claimFeesTo(cur realm, to address) {
39	u := caller(cur)
40	amount := counter(&accruedFees, u)
41	if amount <= 0 {
42		panic("NoFees")
43	}
44	accruedFees.Set(u.String(), int64(0))
45	lifetimeFeesClaimed = mimir.Add(lifetimeFeesClaimed, amount)
46	emit("FeeClaimed", "recipient", u.String(), "to", to.String(), "amount", itoa(amount))
47	push(cur, to, amount)
48}