Skip to content

Commit

Permalink
Merge pull request #678 from UnUniFi/backward-proposal
Browse files Browse the repository at this point in the history
feat: backward-proposal
Senna46 authored Aug 15, 2023
2 parents 29c0bc5 + 3cb2773 commit 4da5b9d
Showing 4 changed files with 527 additions and 35 deletions.
10 changes: 10 additions & 0 deletions proto/ununifi/yieldaggregator/yieldaggregator.proto
Original file line number Diff line number Diff line change
@@ -43,3 +43,13 @@ message Strategy {
string name = 4;
string git_url = 5;
}

// Deprecated: Just for backward compatibility of query proposals
message ProposalAddStrategy {
string title = 1;
string description = 2;
string denom = 3;
string contract_address = 4;
string name = 5;
string git_url = 6;
}
8 changes: 8 additions & 0 deletions x/yieldaggregator/types/codec.go
Original file line number Diff line number Diff line change
@@ -5,6 +5,8 @@ import (
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/msgservice"

govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)

func RegisterCodec(cdc *codec.LegacyAmino) {
@@ -23,6 +25,12 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
&MsgDeleteVault{},
)

// Deprecated: Just for backward compatibility of query proposals
registry.RegisterImplementations(
(*govtypes.Content)(nil),
&ProposalAddStrategy{},
)

msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
}

45 changes: 45 additions & 0 deletions x/yieldaggregator/types/proposal.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package types

import (
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)

const (
// ProposalTypeAddStrategy defines the type for a ProposalAddStrategy
ProposalTypeAddStrategy = "AddStrategy"
)

func init() {
govtypes.RegisterProposalType(ProposalTypeAddStrategy)
}

// Assert ProposalAddStrategy implements govtypes.Content at compile-time
var _ govtypes.Content = &ProposalAddStrategy{}

// Deprecated: Just for backward compatibility
func NewProposalAddStrategy(title, description string, denom, contractAddr, name, gitUrl string) *ProposalAddStrategy {
return &ProposalAddStrategy{
Title: title,
Description: description,
Denom: denom,
ContractAddress: contractAddr,
Name: name,
GitUrl: gitUrl,
}
}

// ProposalRoute returns the routing key of a parameter change proposal.
func (p *ProposalAddStrategy) ProposalRoute() string { return RouterKey }

// ProposalType returns the type of a parameter change proposal.
func (p *ProposalAddStrategy) ProposalType() string { return ProposalTypeAddStrategy }

// ValidateBasic validates the parameter change proposal
func (p *ProposalAddStrategy) ValidateBasic() error {
err := govtypes.ValidateAbstract(p)
if err != nil {
return err
}

return nil
}
499 changes: 464 additions & 35 deletions x/yieldaggregator/types/yieldaggregator.pb.go

0 comments on commit 4da5b9d

Please sign in to comment.