Improve create proposal code (#8586)

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
Prathyusha Lakkireddy 2021-02-15 21:13:09 +05:30 committed by GitHub
parent adbf5a71e6
commit d3e51cf8a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 9 deletions

View File

@ -18,15 +18,6 @@ const DefaultStartingProposalID uint64 = 1
// NewProposal creates a new Proposal instance
func NewProposal(content Content, id uint64, submitTime, depositEndTime time.Time) (Proposal, error) {
p := Proposal{
ProposalId: id,
Status: StatusDepositPeriod,
FinalTallyResult: EmptyTallyResult(),
TotalDeposit: sdk.NewCoins(),
SubmitTime: submitTime,
DepositEndTime: depositEndTime,
}
msg, ok := content.(proto.Message)
if !ok {
return Proposal{}, fmt.Errorf("%T does not implement proto.Message", content)
@ -37,6 +28,15 @@ func NewProposal(content Content, id uint64, submitTime, depositEndTime time.Tim
return Proposal{}, err
}
p := Proposal{
ProposalId: id,
Status: StatusDepositPeriod,
FinalTallyResult: EmptyTallyResult(),
TotalDeposit: sdk.NewCoins(),
SubmitTime: submitTime,
DepositEndTime: depositEndTime,
}
p.Content = any
return p, nil