diff --git a/examples/gno.land/p/demo/simpledao/dao.gno b/examples/gno.land/p/demo/simpledao/dao.gno index b6aed37dcf7..74d3e4f16e1 100644 --- a/examples/gno.land/p/demo/simpledao/dao.gno +++ b/examples/gno.land/p/demo/simpledao/dao.gno @@ -93,7 +93,8 @@ func (s *SimpleDAO) VoteOnProposal(id uint64, option dao.VoteOption) error { prop := propRaw.(*proposal) // Check the proposal status - if prop.GetStatus() == dao.Executed { + if prop.GetStatus() == dao.ExecutionSuccessful || + prop.GetStatus() == dao.ExecutionFailed { // Proposal was already executed, nothing to vote on anymore. // // In fact, the proposal should stop accepting @@ -159,7 +160,8 @@ func (s *SimpleDAO) ExecuteProposal(id uint64) error { } // Check if the proposal is executed - if prop.GetStatus() == dao.Executed { + if prop.GetStatus() == dao.ExecutionSuccessful || + prop.GetStatus() == dao.ExecutionFailed { // Proposal is already executed return errProposalExecuted } @@ -169,14 +171,16 @@ func (s *SimpleDAO) ExecuteProposal(id uint64) error { return errProposalExpired } - // Update the proposal status - prop.status = dao.Executed - // Attempt to execute the proposal if err = prop.executor.Execute(); err != nil { + prop.status = dao.ExecutionFailed + return ufmt.Errorf("error during proposal %d execution, %s", id, err) } + // Update the proposal status + prop.status = dao.ExecutionSuccessful + return nil } diff --git a/examples/gno.land/p/demo/simpledao/propstore.gno b/examples/gno.land/p/demo/simpledao/propstore.gno index 99f584888fe..670dc68e2cb 100644 --- a/examples/gno.land/p/demo/simpledao/propstore.gno +++ b/examples/gno.land/p/demo/simpledao/propstore.gno @@ -25,7 +25,7 @@ type proposal struct { description string // description of the proposal executor pproposal.Executor // executor for the proposal - status dao.Status // status of the proposal + status dao.ProposalStatus // status of the proposal votes *votes // voting mechanism } @@ -38,7 +38,7 @@ func (p *proposal) GetDescription() string { return p.description } -func (p *proposal) GetStatus() dao.Status { +func (p *proposal) GetStatus() dao.ProposalStatus { return p.status } diff --git a/examples/gno.land/p/demo/simpledao/propstore_test.gno b/examples/gno.land/p/demo/simpledao/propstore_test.gno index efc8ebc1fe6..aca39fb9707 100644 --- a/examples/gno.land/p/demo/simpledao/propstore_test.gno +++ b/examples/gno.land/p/demo/simpledao/propstore_test.gno @@ -104,7 +104,7 @@ func TestProposal_Data(t *testing.T) { t.Parallel() p := &proposal{ - status: dao.Executed, + status: dao.ExecutionSuccessful, } uassert.Equal(t, p.status.String(), p.GetStatus().String()) diff --git a/examples/gno.land/p/gov/dao/proposal.gno b/examples/gno.land/p/gov/dao/proposal.gno index 855ce387b7e..13eff2c0f17 100644 --- a/examples/gno.land/p/gov/dao/proposal.gno +++ b/examples/gno.land/p/gov/dao/proposal.gno @@ -2,18 +2,19 @@ package dao import "std" -type Status string +type ProposalStatus string -// ACTIVE -> ACCEPTED -> EXECUTED +// ACTIVE -> ACCEPTED -> EXECUTION(SUCCEEDED/FAILED) // ACTIVE -> NOT ACCEPTED var ( - Active Status = "active" // proposal is still active - Accepted Status = "accepted" // proposal gathered quorum - NotAccepted Status = "not accepted" // proposal failed to gather quorum - Executed Status = "executed" // proposal is executed + Active ProposalStatus = "active" // proposal is still active + Accepted ProposalStatus = "accepted" // proposal gathered quorum + NotAccepted ProposalStatus = "not accepted" // proposal failed to gather quorum + ExecutionSuccessful ProposalStatus = "execution successful" // proposal is executed successfully + ExecutionFailed ProposalStatus = "execution failed" // proposal is failed during execution ) -func (s Status) String() string { +func (s ProposalStatus) String() string { return string(s) } @@ -40,7 +41,7 @@ type Proposal interface { GetDescription() string // GetStatus returns the status of the proposal - GetStatus() Status + GetStatus() ProposalStatus // GetVotes returns the votes of the proposal GetVotes() []Vote