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

sugarproxy source realm

Package sugarproxy holds the rules of sugar proxy (sugar repo, PROXY.md): which sites sharers' home connections may c...

Overview

Package sugarproxy holds the rules of sugar proxy (sugar repo, PROXY.md): which sites sharers' home connections may carry, for which customers and why; which app releases they may run; which hubs they may connect to; who pays them. Sharers' apps read these rules through a light client, from one parameter this realm writes on every change (params "doc": the canonical JSON of everything below), so no hub can change what a sharer's connection does.

Who decides:

  • Holders of the SUGAR token, through kourt's governor (govern.gno): they add and remove anything.
  • A delegate realm, if they name one (gno.security's, say): it adds and removes sites, nothing else.
  • GovDAO (govdao.gno), above both: it adds and removes anything at once, vetoes, pauses, and names the delegate and the guardian. A guardian it names (the deployer, at first) may veto and pause, never approve.

Anything added by the token or the delegate waits out a veto window before it counts; GovDAO's own additions count at once. A veto or a removal counts at once, whoever makes it.

Constants 3

const KindSite, KindRelease, KindHub, KindCustomer, KindPayer, StateApproved, StateVetoed, StateRevoked

 1const (
 2	KindSite     = "site"     // fields: pattern, customer, purpose
 3	KindRelease  = "release"  // fields: version, platform, sha256, url
 4	KindHub      = "hub"      // fields: host:port, pin (hex sha256 of its certificate's public key)
 5	KindCustomer = "customer" // fields: name, purpose
 6	KindPayer    = "payer"    // fields: address (may call Pay)
 7
 8	StateApproved = "approved"
 9	StateVetoed   = "vetoed"
10	StateRevoked  = "revoked"
11)
source

const InitialSupply

1const InitialSupply = int64(1_000_000_000_000)
source

InitialSupply is minted to the deployer at init: 1,000,000 SUGAR of 6 decimals.

Functions 43

func Approve

crossing Action
1func Approve(cur realm, spender address, amount int64)
source

Approve lets spender move up to amount of the caller's SUGAR.

func Cancel

crossing Action
1func Cancel(cur realm, id int64)
source

Cancel withdraws the caller's own open proposal.

func Delegate

Action
1func Delegate() string
source

Delegate is the realm that may add and remove sites ("" is none); Guardian may veto and pause.

func DelegateAdd

crossing Action
1func DelegateAdd(cur realm, payload string) int
source

DelegateAdd adds a site ("site|pattern|customer|purpose"), from the delegate realm only; it waits out the site veto window.

func DelegateRemove

crossing Action
1func DelegateRemove(cur realm, id int)
source

DelegateRemove removes a site, from the delegate realm only.

func DelegateVotes

crossing Action
1func DelegateVotes(cur realm, to address)
source

DelegateVotes gives the caller's voting weight to another address (its own, to take it back).

func Doc

Action
1func Doc() string
source

Doc is the canonical JSON the apps read (the same bytes as params "doc"); Digest is its hex sha256.

func Execute

crossing Action
1func Execute(cur realm, id int64)
source

Execute carries out a proposal that passed, once its delay is over.

func GuardianRemove

crossing Action
1func GuardianRemove(cur realm, id int)
source

GuardianRemove removes a site, at once: the safe direction, so the guardian may (the launcher's sites count at once, so there is no window to veto them in).

func GuardianVeto

crossing Action
1func GuardianVeto(cur realm, id int)
source

GuardianVeto vetoes an item still in its veto window.

func ItemID

Action
1func ItemID(payload string) int
source

ItemID is the number of the approved item that says exactly payload ("kind|field|..."), or 0.

func KindAdd

Action
1func KindAdd() string
source

KindAdd and KindRemove are the names to propose under.

func LauncherAdd

crossing Action
1func LauncherAdd(cur realm, payload string) int
source

LauncherAdd adds a site ("site|pattern|customer|purpose"), counting at once, from the launcher during its window.

func LauncherRemove

crossing Action
1func LauncherRemove(cur realm, id int)
source

LauncherRemove removes a site, from the launcher during its window.

func PaidTo

Action
1func PaidTo(a address) (ugnot, bytes int64, count int)
source

PaidTo is what a sharer has been paid, all told.

func Paused

Action
1func Paused() bool
source

Paused reports whether sugar proxy is paused: apps carry nothing while it is.

func Pay

crossing Action
1func Pay(cur realm, period, receipts, lines string)
source

Pay pays sharers with the GNOT sent along. lines has one sharer a line: "address ugnot bytes"; the amounts must add up to what was sent, and a payout is at most 500 lines. period names what it pays for ("2026-11-01", say); receipts is the hex sha256 of the payer's receipts for it (one line per confirmed download: its tag, the file's sha256 and size, who carried how much), recorded here so the receipts can be checked against it later. Only an approved payer may call it; pausing doesn't stop it (sharers are owed for what they carried).

func Propose

crossing Action
1func Propose(cur realm, kind, payload, title string) int64
source

Propose opens a proposal: kind is KindAdd() with a payload "kind|field|...", or KindRemove() with an item's number. It needs the governor's share of the supply to propose.

func ProposeAdd

crossing Action
1func ProposeAdd(cur realm, payload string) dao.ProposalRequest
source

ProposeAdd adds an item at once, with no veto window: GovDAO is the veto.

func ProposeDelegate

crossing Action
1func ProposeDelegate(cur realm, path string) dao.ProposalRequest
source

ProposeDelegate names the realm that may add and remove sites ("" for none).

func ProposeGuardian

crossing Action
1func ProposeGuardian(cur realm, a address) dao.ProposalRequest
source

ProposeGuardian names the address that may veto and pause ("" for none).

func ProposePause

crossing Action
1func ProposePause(cur realm, on bool) dao.ProposalRequest
source

ProposePause pauses sugar proxy (on) or resumes it: while paused, apps carry nothing and nothing new is added except by GovDAO.

func ProposeRemove

crossing Action
1func ProposeRemove(cur realm, id int) dao.ProposalRequest
source

ProposeRemove removes an item at once.

func ProposeVeto

crossing Action
1func ProposeVeto(cur realm, id int) dao.ProposalRequest
source

ProposeVeto vetoes an item still in its veto window.

func ProposeVetoWindow

crossing Action
1func ProposeVetoWindow(cur realm, kind string, seconds int64) dao.ProposalRequest
source

ProposeVetoWindow sets how long an added item of a kind waits before it counts, in seconds (one hour to 60 days).

func Render

1func Render(path string) string
source

Render shows the rules as people read them on gno.land.

func Settle

crossing Action
1func Settle(cur realm, id int64)
source

Settle closes a proposal whose voting is over.

func State

Action
1func State(id int64) string
source

State, Describe and Tally read a proposal.

func Suggest

crossing Action
1func Suggest(cur realm, payload, reason string) int
source

Suggest records a suggestion of an item ("kind|field|..."), for the token holders or the delegate to consider. It changes nothing. Each address may have three open at a time.

func Transfer

crossing Action
1func Transfer(cur realm, to address, amount int64)
source

Transfer sends SUGAR from the caller.

func TransferFrom

crossing Action
1func TransferFrom(cur realm, from, to address, amount int64)
source

TransferFrom moves SUGAR the owner approved the caller to move.

func VetoWindow

Action
1func VetoWindow(kind string) int64
source

VetoWindow is how long an added item of a kind waits before it counts, in seconds.

func Vote

crossing Action
1func Vote(cur realm, id int64, choice string)
source

Vote casts the caller's weight: "yes", "no" or "abstain".

Types 4

type Item

struct
 1type Item struct {
 2	ID       int
 3	Kind     string // KindSite, KindRelease, KindHub, KindCustomer, KindPayer
 4	Fields   []string
 5	State    string // StateApproved, StateVetoed, StateRevoked
 6	By       string // who added it: "init", "token", "delegate", "govdao"
 7	Approved int64  // unix seconds
 8	After    int64  // unix seconds: when its veto window ends and it counts
 9	Note     string // who vetoed or removed it, and when
10}
source

Item is one entry of the rules: a site, a release, a hub, a customer or a payer.

type Payout

struct
1type Payout struct {
2	Time     int64
3	Payer    address
4	Period   string
5	Receipts string // the hex sha256 of the payer's receipts for the period: the confirmed downloads it paid for
6	Count    int
7	Ugnot    int64
8	Bytes    int64
9}
source

Payout is one call to Pay.

type Request

struct
1type Request struct {
2	ID      int
3	By      address
4	Payload string
5	Reason  string
6	Time    int64
7	Done    bool
8}
source

Request is anyone's suggestion of an item, for the token holders or the delegate to consider. It changes nothing.

type Totals

struct
1type Totals struct {
2	Paid    int64 // ugnot
3	Bytes   int64
4	Payouts int
5	Last    int64 // unix seconds
6}
source

Totals is what a sharer has been paid, all told.

Dependencies

Source Files 7