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
34func init() {
35 // add pre-registered users
36 for _, res := range preRegisteredUsers {
37 // assert not already registered.
38 _, ok := name2User.Get(res.Name)
39 if ok {
40 panic("name already registered")
41 }
42
43 _, ok = addr2User.Get(res.Address.String())
44 if ok {
45 panic("address already registered")
46 }
47
48 counter++
49 user := &users.User{
50 Address: res.Address,
51 Name: res.Name,
52 Profile: "",
53 Number: counter,
54 Invites: int(0),
55 Inviter: admin,
56 }
57 name2User.Set(res.Name, user)
58 addr2User.Set(res.Address.String(), user)
59 }
60
61 // add pre-restricted names
62 for _, name := range preRestrictedNames {
63 if _, ok := name2User.Get(name); ok {
64 panic("name already registered")
65 }
66
67 restricted.Set(name, true)
68 }
69}
preregister.gno
1.73 Kb ยท 69 lines