← Back to Realms

Realm

gno.land/r/samcrew/validator_scores

Overview

Realm Path
gno.land/r/samcrew/validator_scores
Exported Functions
12
State Entries
15
Source Files
7
Total Package Entries
50

Exported Functions

12 exported functions

State

15 state entries

Source Code

FILES
admin.gno
go
1package validator_scores
2
3import "strings"
4
5// admin is the samcrew 2-of-3 multisig. Its only power is SetPublisher.
6const admin address = "g136j0m08pkm2lwwde9dmlx8uee26llent9s5cpf"
7
8var publisher address = initialPublisher
9
10// caller returns the frame-verified caller of a crossing function.
11func caller(cur realm) address {
12	if !cur.IsCurrent() {
13		panic("validator_scores: stale realm")
14	}
15	return cur.Previous().Address()
16}
17
18func requirePublisher(cur realm) {
19	if caller(cur) != publisher {
20		panic("validator_scores: publisher only")
21	}
22}
23
24// isCanonicalAddress accepts only a lowercase, checksummed g1 address.
25func isCanonicalAddress(s string) bool {
26	if len(s) != 40 || !strings.HasPrefix(s, "g1") || strings.ToLower(s) != s {
27		return false
28	}
29	return address(s).IsValid()
30}
31
32// SetPublisher replaces the publisher. Admin only.
33func SetPublisher(cur realm, addr address) {
34	if caller(cur) != admin {
35		panic("validator_scores: admin only")
36	}
37	if !isCanonicalAddress(string(addr)) {
38		panic("validator_scores: invalid publisher address")
39	}
40	publisher = addr
41}
42
43// GetAdmin returns the admin address, for post-deployment checks.
44func GetAdmin() string { return string(admin) }
45
46// GetPublisher returns the current publisher address.
47func GetPublisher() string { return string(publisher) }
48

Raw Package Data

Raw JSON data