preregister.gno

2.06 Kb ยท 77 lines
 1package users
 2
 3import (
 4	"std"
 5
 6	"gno.land/p/demo/users"
 7)
 8
 9// pre-restricted names
10var preRestrictedNames = []string{
11	"bitcoin", "cosmos", "newtendermint", "ethereum",
12}
13
14// pre-registered users
15var preRegisteredUsers = []struct {
16	Name    string
17	Address std.Address
18}{
19	// system name
20	{"archives", "g1xlnyjrnf03ju82v0f98ruhpgnquk28knmjfe5k"}, // -> @r_archives
21	{"demo", "g13ek2zz9qurzynzvssyc4sthwppnruhnp0gdz8n"},     // -> @r_demo
22	{"gno", "g19602kd9tfxrfd60sgreadt9zvdyyuudcyxsz8a"},      // -> @r_gno
23	{"gnoland", "g1g3lsfxhvaqgdv4ccemwpnms4fv6t3aq3p5z6u7"},  // -> @r_gnoland
24	{"gnolang", "g1yjlnm3z2630gg5mryjd79907e0zx658wxs9hnd"},  // -> @r_gnolang
25	{"gov", "g1g73v2anukg4ej7axwqpthsatzrxjsh0wk797da"},      // -> @r_gov
26	{"nt", "g15ge0ae9077eh40erwrn2eq0xw6wupwqthpv34l"},       // -> @r_nt
27	{"sys", "g1r929wt2qplfawe4lvqv9zuwfdcz4vxdun7qh8l"},      // -> @r_sys
28	{"x", "g164sdpew3c2t3rvxj3kmfv7c7ujlvcw2punzzuz"},        // -> @r_x
29
30	// test1 user
31	{"test1", "g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5"}, // -> @test1
32
33	// Onbloc
34	{"gnoswap", "g1lmvrrrr4er2us84h2732sru76c9zl2nvknha8c"}, // -> @r_gnoswap
35	{"onbloc", "g12vx7dn3dqq89mz550zwunvg4qw6epq73d9csay"},  // -> @r_onbloc
36
37	// Dragos
38	{"flippando", "g1z82x8mxa0pz5s9u7csy6zya4x0ut9uw6p7d8dk"},  // -> @r_flippando
39	{"zentasktic", "g1paxgmwy2wzhx0l6qvav2p8thvphc5c030xz35c"}, // -> @r_zentasktic
40}
41
42func init() {
43	// add pre-registered users
44	for _, res := range preRegisteredUsers {
45		// assert not already registered.
46		_, ok := name2User.Get(res.Name)
47		if ok {
48			panic("name already registered")
49		}
50
51		_, ok = addr2User.Get(res.Address.String())
52		if ok {
53			panic("address already registered")
54		}
55
56		counter++
57		user := &users.User{
58			Address: res.Address,
59			Name:    res.Name,
60			Profile: "",
61			Number:  counter,
62			Invites: int(0),
63			Inviter: admin,
64		}
65		name2User.Set(res.Name, user)
66		addr2User.Set(res.Address.String(), user)
67	}
68
69	// add pre-restricted names
70	for _, name := range preRestrictedNames {
71		if _, ok := name2User.Get(name); ok {
72			panic("name already registered")
73		}
74
75		restricted.Set(name, true)
76	}
77}