addresses.gno
1.83 Kb · 45 lines
1package bolo
2
3import (
4 "chain"
5
6 "gno.land/p/nt/seqid/v0"
7)
8
9// The paths Bolo's addresses derive from. pkgPath is this realm's own; a test
10// checks it against the realm.
11const (
12 pkgPath = "gno.land/r/g12yg9nh4ncma44emgm8msxe8aavzywt0p95tanv/bolo/v0"
13 registryPath = "gno.land/r/g12yg9nh4ncma44emgm8msxe8aavzywt0p95tanv/bolo"
14 slashedPath = "slashed" // where slashed bonds go; nothing ever spends it (INV-8)
15)
16
17// escrowPath and bondPath are a campaign's sub-paths (API §1): one escrow and one
18// bond address per campaign, so a bug in one campaign can't spend another's.
19func escrowPath(id seqid.ID) string { return "c/" + idString(id) }
20
21func bondPath(id seqid.ID) string { return "b/" + idString(id) }
22
23// escrowSub and bondSub are the only places Bolo derives a sub-realm, and so the
24// only way to a banker for a campaign's addresses (API C9, INV-8, INV-18). They
25// take the stored campaign itself, never an ID: an ID parsed from an argument has
26// to find its campaign first.
27func escrowSub(cur realm, c *campaign) realm { return cur.Sub(escrowPath(c.id)) }
28
29func bondSub(cur realm, c *campaign) realm { return cur.Sub(bondPath(c.id)) }
30
31// The same addresses for queries and Render, which have no cur, and the other
32// addresses Bolo never pays a campaign to (API §1).
33func escrowAddr(id seqid.ID) address { return chain.DerivePkgSubAddr(pkgPath, escrowPath(id)) }
34
35func bondAddr(id seqid.ID) address { return chain.DerivePkgSubAddr(pkgPath, bondPath(id)) }
36
37func slashedAddr() address { return chain.DerivePkgSubAddr(pkgPath, slashedPath) }
38
39func realmAddr() address { return chain.PackageAddress(pkgPath) }
40
41func depositAddr() address { return chain.DeriveStorageDepositAddr(pkgPath) }
42
43func registryAddr() address { return chain.PackageAddress(registryPath) }
44
45func registryDepositAddr() address { return chain.DeriveStorageDepositAddr(registryPath) }