-
Notifications
You must be signed in to change notification settings - Fork 10
/
tgrade_oc_proposals.go
113 lines (99 loc) · 3.44 KB
/
tgrade_oc_proposals.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
package contract
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/confio/tgrade/x/poe/types"
)
type OCProposalsContractAdapter struct {
VotingContractAdapter
}
// NewOCProposalsContractAdapter constructor
func NewOCProposalsContractAdapter(contractAddr sdk.AccAddress, twasmKeeper types.TWasmKeeper, addressLookupErr error) *OCProposalsContractAdapter {
return &OCProposalsContractAdapter{
VotingContractAdapter: NewVotingContractAdapter(
contractAddr,
twasmKeeper,
addressLookupErr,
),
}
}
// ProposeSlash creates a proposal to slash this account
// Use LatestProposal after to get the ProposalID
func (v OCProposalsContractAdapter) ProposeSlash(ctx sdk.Context, member sdk.AccAddress, portion sdk.Dec, sender sdk.AccAddress) error {
msg := OCProposalsExecuteMsg{
Propose: &ProposalMsg{
Title: "Slash them",
Description: "Slash them harder!",
Proposal: OversightProposal{
Slash: &SlashProposal{
Member: member.String(),
Portion: portion,
},
},
},
}
return v.doExecute(ctx, msg, sender)
}
// ProposeGrant creates a proposal to grant engagement to this account
// Use LatestProposal after to get the ProposalID
func (v OCProposalsContractAdapter) ProposeGrant(ctx sdk.Context, grantee sdk.AccAddress, points uint64, sender sdk.AccAddress) error {
msg := OCProposalsExecuteMsg{
Propose: &ProposalMsg{
Title: "Slash them",
Description: "Slash them harder!",
Proposal: OversightProposal{
GrantEngagement: &GrantEngagementProposal{
Member: grantee.String(),
Points: points,
},
},
},
}
return v.doExecute(ctx, msg, sender)
}
// OCProposalsInitMsg instantiation message
type OCProposalsInitMsg struct {
VotingRules VotingRules `json:"rules"`
// GroupContractAddress is the group contract that contains the member list
GroupContractAddress string `json:"group_addr"`
// EngagementContractAddress is the engagement contract that contains list for engagement rewards
EngagementContractAddress string `json:"engagement_addr"`
// ValsetContractAddress is the valset contract that we execute slashing on
ValsetContractAddress string `json:"valset_addr"`
}
type OCProposalsExecuteMsg struct {
Propose *ProposalMsg `json:"propose,omitempty"`
Vote *VoteMsg `json:"vote,omitempty"`
Execute *ProposalID `json:"execute,omitempty"`
Close *ProposalID `json:"close,omitempty"`
}
type ProposalMsg struct {
Title string `json:"title"`
Description string `json:"description"`
Proposal OversightProposal `json:"proposal"`
}
type OversightProposal struct {
GrantEngagement *GrantEngagementProposal `json:"grant_engagement,omitempty"`
Slash *SlashProposal `json:"punish,omitempty"`
}
type GrantEngagementProposal struct {
Member string `json:"member"`
Points uint64 `json:"points"`
}
type SlashProposal struct {
Member string `json:"member"`
Portion sdk.Dec `json:"portion"`
}
type OCProposalResponse struct {
ID uint64 `json:"id"`
Title string `json:"title"`
Description string `json:"description"`
Proposal OversightProposal `json:"proposal"`
Status ProposalStatus `json:"status"`
CreatedBy string `json:"created_by"`
Rules VotingRules `json:"rules"`
TotalPoints uint64 `json:"total_points"`
Votes Votes `json:"votes"`
}
type OCProposalListResponse struct {
Proposals []OCProposalResponse `json:"proposals"`
}