-
Notifications
You must be signed in to change notification settings - Fork 41
/
profile.go
150 lines (141 loc) · 3.84 KB
/
profile.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
package sample
import (
"math/rand"
profile "github.com/tendermint/spn/x/profile/types"
)
// MsgCreateCoordinator returns a sample MsgCreateCoordinator
func MsgCreateCoordinator(coordAddress string) profile.MsgCreateCoordinator {
return *profile.NewMsgCreateCoordinator(
coordAddress,
coordAddress,
"https://cosmos.network/"+coordAddress,
coordAddress+" details",
)
}
// MsgDisableCoordinator returns a sample MsgDisableCoordinator
func MsgDisableCoordinator(coordAddress string) profile.MsgDisableCoordinator {
return *profile.NewMsgDisableCoordinator(
coordAddress,
)
}
// MsgUpdateCoordinatorDescription returns a sample MsgUpdateCoordinatorDescription
func MsgUpdateCoordinatorDescription(coordAddress string) profile.MsgUpdateCoordinatorDescription {
return *profile.NewMsgUpdateCoordinatorDescription(
coordAddress,
coordAddress+" update identity",
"https://cosmos.network/update/"+coordAddress,
coordAddress+" update details",
)
}
// ValidatorDescription returns a sample ValidatorDescription
func ValidatorDescription(desc string) profile.ValidatorDescription {
return profile.ValidatorDescription{
Identity: desc,
Moniker: "moniker " + desc,
Website: "https://cosmos.network/" + desc,
SecurityContact: "foo",
Details: desc + " details",
}
}
// Coordinator returns a sample Coordinator
func Coordinator(r *rand.Rand, address string) profile.Coordinator {
return profile.Coordinator{
Address: address,
Description: CoordinatorDescription(r),
Active: true,
}
}
// CoordinatorDescription returns a sample CoordinatorDescription
func CoordinatorDescription(r *rand.Rand) profile.CoordinatorDescription {
return profile.CoordinatorDescription{
Identity: String(r, 10),
Website: String(r, 10),
Details: String(r, 30),
}
}
// ProfileGenesisState returns a sample genesis state for the profile module
func ProfileGenesisState(r *rand.Rand, addresses ...string) profile.GenesisState {
for len(addresses) < 7 {
addresses = append(addresses, Address(r))
}
operatorAddresses := []string{OperatorAddress(r), OperatorAddress(r)}
return profile.GenesisState{
Coordinators: []profile.Coordinator{
{
CoordinatorID: 0,
Address: addresses[0],
Description: CoordinatorDescription(r),
Active: true,
},
{
CoordinatorID: 1,
Address: addresses[1],
Description: CoordinatorDescription(r),
Active: true,
},
{
CoordinatorID: 2,
Address: addresses[2],
Description: CoordinatorDescription(r),
Active: true,
},
{
CoordinatorID: 3,
Address: addresses[3],
Description: CoordinatorDescription(r),
Active: true,
},
{
CoordinatorID: 4,
Address: addresses[4],
Description: CoordinatorDescription(r),
Active: true,
},
},
CoordinatorsByAddress: []profile.CoordinatorByAddress{
{
Address: addresses[0],
CoordinatorID: 0,
},
{
Address: addresses[1],
CoordinatorID: 1,
},
{
Address: addresses[2],
CoordinatorID: 2,
},
{
Address: addresses[3],
CoordinatorID: 3,
},
{
Address: addresses[4],
CoordinatorID: 4,
},
},
CoordinatorCounter: 5,
Validators: []profile.Validator{
{
Address: addresses[5],
Description: ValidatorDescription(String(r, 10)),
OperatorAddresses: []string{operatorAddresses[0]},
},
{
Address: addresses[6],
Description: ValidatorDescription(String(r, 10)),
OperatorAddresses: []string{operatorAddresses[1]},
},
},
ValidatorsByOperatorAddress: []profile.ValidatorByOperatorAddress{
{
OperatorAddress: operatorAddresses[0],
ValidatorAddress: addresses[5],
},
{
OperatorAddress: operatorAddresses[1],
ValidatorAddress: addresses[6],
},
},
}
}