Skip to content

Commit

Permalink
MX-15033: clearEndedProposals implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
dragos-rebegea committed Feb 5, 2024
1 parent 0e1940d commit c5103a0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions vm/gasCost.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type MetaChainSystemSCsCost struct {
DelegateVote uint64
RevokeVote uint64
CloseProposal uint64
ClearProposal uint64
DelegationOps uint64
UnStakeTokens uint64
UnBondTokens uint64
Expand Down
21 changes: 19 additions & 2 deletions vm/systemSmartContracts/governance.go
Original file line number Diff line number Diff line change
Expand Up @@ -728,8 +728,25 @@ func (g *governanceContract) closeProposal(args *vmcommon.ContractCallInput) vmc
return vmcommon.Ok
}

func (g *governanceContract) clearEndedProposals(args *vmcommon.ContractCallInput) vmcommon.ReturnCode {
// TODO: implement
func (g *governanceContract) clearEndedProposals(addresses [][]byte) vmcommon.ReturnCode {
numAddresses := uint64(len(addresses))
if numAddresses == 0 {
return vmcommon.Ok
}

err := g.eei.UseGas(numAddresses * g.gasCost.MetaChainSystemSCsCost.ClearProposal)
if err != nil {
g.eei.AddReturnMessage("not enough gas")
return vmcommon.OutOfGas
}
for i := uint64(0); i < numAddresses; i++ {
voter := addresses[i]
if len(voter) != len(args.CallerAddr) {
g.eei.AddReturnMessage("invalid delegator address")
return vmcommon.UserError
}
err = g.clearUserVotes(voter)
}
return vmcommon.Ok
}

Expand Down

0 comments on commit c5103a0

Please sign in to comment.