Skip to content

Commit

Permalink
something is funky with codec registrations
Browse files Browse the repository at this point in the history
  • Loading branch information
mvid committed Jun 27, 2023
1 parent 90db919 commit 06340a7
Show file tree
Hide file tree
Showing 12 changed files with 349 additions and 336 deletions.
16 changes: 8 additions & 8 deletions proto/axelar-cork/v1/proposal.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ option go_package = "github.com/peggyjv/sommelier/x/axelarcork/types";

// note: current plan is to accept either chain name or chain ID. if both and they dont match, error.

message AddManagedCellarIDsProposal {
message AddAxelarManagedCellarIDsProposal {
string title = 1;
string description = 2;
string chain_name = 3;
Expand All @@ -18,7 +18,7 @@ message AddManagedCellarIDsProposal {
}

// AddManagedCellarIDsProposalWithDeposit is a specific definition for CLI commands
message AddManagedCellarIDsProposalWithDeposit {
message AddAxelarManagedCellarIDsProposalWithDeposit {
string title = 1;
string description = 2;
string chain_name = 3;
Expand All @@ -27,7 +27,7 @@ message AddManagedCellarIDsProposalWithDeposit {
string deposit = 6;
}

message RemoveManagedCellarIDsProposal {
message RemoveAxelarManagedCellarIDsProposal {
string title = 1;
string description = 2;
string chain_name = 3;
Expand All @@ -36,7 +36,7 @@ message RemoveManagedCellarIDsProposal {
}

// RemoveManagedCellarIDsProposalWithDeposit is a specific definition for CLI commands
message RemoveManagedCellarIDsProposalWithDeposit {
message RemoveAxelarManagedCellarIDsProposalWithDeposit {
string title = 1;
string description = 2;
string chain_name = 3;
Expand All @@ -45,7 +45,7 @@ message RemoveManagedCellarIDsProposalWithDeposit {
string deposit = 6;
}

message ScheduledCorkProposal {
message AxelarScheduledCorkProposal {
string title = 1;
string description = 2;
uint64 block_height = 3;
Expand Down Expand Up @@ -75,7 +75,7 @@ message ScheduledCorkProposal {
}

// ScheduledCorkProposalWithDeposit is a specific definition for CLI commands
message ScheduledCorkProposalWithDeposit {
message AxelarScheduledCorkProposalWithDeposit {
string title = 1;
string description = 2;
uint64 block_height = 3;
Expand All @@ -86,7 +86,7 @@ message ScheduledCorkProposalWithDeposit {
string deposit = 8;
}

message CommunityPoolSpendProposal {
message AxelarCommunityPoolSpendProposal {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = true;
option (gogoproto.goproto_stringer) = true;
Expand All @@ -101,7 +101,7 @@ message CommunityPoolSpendProposal {

// This format of the community spend Ethereum proposal is specifically for
// the CLI to allow simple text serialization.
message CommunityPoolSpendProposalForCLI {
message AxelarCommunityPoolSpendProposalForCLI {
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = true;

Expand Down
6 changes: 3 additions & 3 deletions x/axelarcork/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Where proposal.json contains:
return err
}

proposal := types.AddManagedCellarIDsProposalWithDeposit{}
proposal := types.AddAxelarManagedCellarIDsProposalWithDeposit{}
contents, err := os.ReadFile(args[0])
if err != nil {
return err
Expand Down Expand Up @@ -141,7 +141,7 @@ Where proposal.json contains:
return err
}

proposal := types.RemoveManagedCellarIDsProposalWithDeposit{}
proposal := types.RemoveAxelarManagedCellarIDsProposalWithDeposit{}
contents, err := os.ReadFile(args[0])
if err != nil {
return err
Expand Down Expand Up @@ -226,7 +226,7 @@ The contract_call_proto_json field must be the JSON representation of a Schedule
return err
}

proposal := types.ScheduledCorkProposalWithDeposit{}
proposal := types.AxelarScheduledCorkProposalWithDeposit{}
contents, err := os.ReadFile(args[0])
if err != nil {
return err
Expand Down
6 changes: 3 additions & 3 deletions x/axelarcork/client/cli/tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestParseAddManagedCellarsProposal(t *testing.T) {
}
`)

proposal := types.AddManagedCellarIDsProposalWithDeposit{}
proposal := types.AddAxelarManagedCellarIDsProposalWithDeposit{}
contents, err := ioutil.ReadFile(okJSON.Name())
require.NoError(t, err)

Expand All @@ -49,7 +49,7 @@ func TestParseRemoveManagedCellarsProposal(t *testing.T) {
}
`)

proposal := types.RemoveManagedCellarIDsProposalWithDeposit{}
proposal := types.RemoveAxelarManagedCellarIDsProposalWithDeposit{}
contents, err := ioutil.ReadFile(okJSON.Name())
require.NoError(t, err)

Expand All @@ -75,7 +75,7 @@ func TestParseSubmitScheduledCorkProposal(t *testing.T) {
}
`)

proposal := types.ScheduledCorkProposalWithDeposit{}
proposal := types.AxelarScheduledCorkProposalWithDeposit{}
contents, err := ioutil.ReadFile(okJSON.Name())
require.NoError(t, err)

Expand Down
4 changes: 2 additions & 2 deletions x/axelarcork/client/cli/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ func GetChainInfoFromFlags(cmd *cobra.Command) (string, uint64, error) {
}

// ParseCommunityPoolSpendProposal reads and parses a CommunityPoolEthereumSpendProposalForCLI from a file.
func ParseCommunityPoolSpendProposal(cdc codec.JSONCodec, proposalFile string) (types.CommunityPoolSpendProposalForCLI, error) {
proposal := types.CommunityPoolSpendProposalForCLI{}
func ParseCommunityPoolSpendProposal(cdc codec.JSONCodec, proposalFile string) (types.AxelarCommunityPoolSpendProposalForCLI, error) {
proposal := types.AxelarCommunityPoolSpendProposalForCLI{}

contents, err := os.ReadFile(proposalFile)
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions x/axelarcork/client/rest/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ func postAddProposalHandlerFn(clientCtx client.Context) http.HandlerFunc {
content := types.NewAddManagedCellarIDsProposal(
req.Title,
req.Description,
"",
req.ChainID,
&types.CellarIDSet{
Ids: req.CellarIDs,
})
Expand Down Expand Up @@ -81,6 +83,8 @@ func postRemoveProposalHandlerFn(clientCtx client.Context) http.HandlerFunc {
content := types.NewRemoveManagedCellarIDsProposal(
req.Title,
req.Description,
"",
req.ChainID,
&types.CellarIDSet{
Ids: req.CellarIDs,
})
Expand Down
2 changes: 2 additions & 0 deletions x/axelarcork/client/rest/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type (

Title string `json:"title" yaml:"title"`
Description string `json:"description" yaml:"description"`
ChainID uint64 `json:"chain_id" yaml:"chain_id"`
CellarIDs []string `json:"cellar_ids" yaml:"cellar_ids"`
Proposer sdk.AccAddress `json:"proposer" yaml:"proposer"`
Deposit sdk.Coins `json:"deposit" yaml:"deposit"`
Expand All @@ -23,6 +24,7 @@ type (

Title string `json:"title" yaml:"title"`
Description string `json:"description" yaml:"description"`
ChainID uint64 `json:"chain_id" yaml:"chain_id"`
CellarIDs []string `json:"cellar_ids" yaml:"cellar_ids"`
Proposer sdk.AccAddress `json:"proposer" yaml:"proposer"`
Deposit sdk.Coins `json:"deposit" yaml:"deposit"`
Expand Down
8 changes: 4 additions & 4 deletions x/axelarcork/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ func NewHandler(k keeper.Keeper) sdk.Handler {
func NewProposalHandler(k keeper.Keeper) govtypes.Handler {
return func(ctx sdk.Context, content govtypes.Content) error {
switch c := content.(type) {
case *types.AddManagedCellarIDsProposal:
case *types.AddAxelarManagedCellarIDsProposal:
return keeper.HandleAddManagedCellarsProposal(ctx, k, *c)
case *types.RemoveManagedCellarIDsProposal:
case *types.RemoveAxelarManagedCellarIDsProposal:
return keeper.HandleRemoveManagedCellarsProposal(ctx, k, *c)
case *types.ScheduledCorkProposal:
case *types.AxelarScheduledCorkProposal:
return keeper.HandleScheduledCorkProposal(ctx, k, *c)
case *types.CommunityPoolSpendProposal:
case *types.AxelarCommunityPoolSpendProposal:
return keeper.HandleCommunityPoolSpendProposal(ctx, k, *c)
case *types.AddChainConfigurationProposal:
return keeper.HandleAddChainConfigurationProposal(ctx, k, *c)
Expand Down
8 changes: 4 additions & 4 deletions x/axelarcork/keeper/proposal_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
)

// HandleAddManagedCellarsProposal is a handler for executing a passed community cellar addition proposal
func HandleAddManagedCellarsProposal(ctx sdk.Context, k Keeper, p types.AddManagedCellarIDsProposal) error {
func HandleAddManagedCellarsProposal(ctx sdk.Context, k Keeper, p types.AddAxelarManagedCellarIDsProposal) error {
config, err := k.GetChainConfigurationByNameAndID(ctx, p.ChainName, p.ChainId)
if err != nil {
return err
Expand Down Expand Up @@ -48,7 +48,7 @@ func HandleAddManagedCellarsProposal(ctx sdk.Context, k Keeper, p types.AddManag
}

// HandleRemoveManagedCellarsProposal is a handler for executing a passed community cellar removal proposal
func HandleRemoveManagedCellarsProposal(ctx sdk.Context, k Keeper, p types.RemoveManagedCellarIDsProposal) error {
func HandleRemoveManagedCellarsProposal(ctx sdk.Context, k Keeper, p types.RemoveAxelarManagedCellarIDsProposal) error {
config, err := k.GetChainConfigurationByNameAndID(ctx, p.ChainName, p.ChainId)
if err != nil {
return err
Expand All @@ -74,7 +74,7 @@ func HandleRemoveManagedCellarsProposal(ctx sdk.Context, k Keeper, p types.Remov
}

// HandleScheduledCorkProposal is a handler for executing a passed scheduled cork proposal
func HandleScheduledCorkProposal(ctx sdk.Context, k Keeper, p types.ScheduledCorkProposal) error {
func HandleScheduledCorkProposal(ctx sdk.Context, k Keeper, p types.AxelarScheduledCorkProposal) error {
config, err := k.GetChainConfigurationByNameAndID(ctx, p.ChainName, p.ChainId)
if err != nil {
return err
Expand All @@ -87,7 +87,7 @@ func HandleScheduledCorkProposal(ctx sdk.Context, k Keeper, p types.ScheduledCor
return nil
}

func HandleCommunityPoolSpendProposal(ctx sdk.Context, k Keeper, p types.CommunityPoolSpendProposal) error {
func HandleCommunityPoolSpendProposal(ctx sdk.Context, k Keeper, p types.AxelarCommunityPoolSpendProposal) error {
feePool := k.distributionKeeper.GetFeePool(ctx)

// NOTE the community pool isn't a module account, however its coins
Expand Down
6 changes: 3 additions & 3 deletions x/axelarcork/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
)

registry.RegisterImplementations((*govtypes.Content)(nil),
&AddManagedCellarIDsProposal{},
&RemoveManagedCellarIDsProposal{},
&ScheduledCorkProposal{},
&AddAxelarManagedCellarIDsProposal{},
&RemoveAxelarManagedCellarIDsProposal{},
&AxelarScheduledCorkProposal{},
)

msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
Expand Down
54 changes: 27 additions & 27 deletions x/axelarcork/types/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@ const (
ProposalTypeRemoveChainConfiguration = "RemoveAxelarChainConfiguration"
)

var _ govtypes.Content = &AddManagedCellarIDsProposal{}
var _ govtypes.Content = &RemoveManagedCellarIDsProposal{}
var _ govtypes.Content = &ScheduledCorkProposal{}
var _ govtypes.Content = &CommunityPoolSpendProposal{}
var _ govtypes.Content = &AddAxelarManagedCellarIDsProposal{}
var _ govtypes.Content = &RemoveAxelarManagedCellarIDsProposal{}
var _ govtypes.Content = &AxelarScheduledCorkProposal{}
var _ govtypes.Content = &AxelarCommunityPoolSpendProposal{}
var _ govtypes.Content = &AddChainConfigurationProposal{}
var _ govtypes.Content = &RemoveChainConfigurationProposal{}

func init() {
govtypes.RegisterProposalType(ProposalTypeAddManagedCellarIDs)
govtypes.RegisterProposalTypeCodec(&AddManagedCellarIDsProposal{}, "sommelier/AddAxelarManagedCellarIDsProposal")
govtypes.RegisterProposalTypeCodec(&AddAxelarManagedCellarIDsProposal{}, "sommelier/AddAxelarManagedCellarIDsProposal")

govtypes.RegisterProposalType(ProposalTypeRemoveManagedCellarIDs)
govtypes.RegisterProposalTypeCodec(&RemoveManagedCellarIDsProposal{}, "sommelier/RemoveAxelarManagedCellarIDsProposal")
govtypes.RegisterProposalTypeCodec(&RemoveAxelarManagedCellarIDsProposal{}, "sommelier/RemoveAxelarManagedCellarIDsProposal")

govtypes.RegisterProposalType(ProposalTypeScheduledCork)
govtypes.RegisterProposalTypeCodec(&ScheduledCorkProposal{}, "sommelier/AxelarScheduledCorkProposal")
govtypes.RegisterProposalTypeCodec(&AxelarScheduledCorkProposal{}, "sommelier/AxelarScheduledCorkProposal")

govtypes.RegisterProposalType(ProposalTypeAddChainConfiguration)
govtypes.RegisterProposalTypeCodec(&AddChainConfigurationProposal{}, "sommelier/AddAxelarChainConfigurationProposal")
Expand All @@ -45,8 +45,8 @@ func init() {

}

func NewAddManagedCellarIDsProposal(title string, description string, chainName string, chainID uint64, cellarIds *CellarIDSet) *AddManagedCellarIDsProposal {
return &AddManagedCellarIDsProposal{
func NewAddManagedCellarIDsProposal(title string, description string, chainName string, chainID uint64, cellarIds *CellarIDSet) *AddAxelarManagedCellarIDsProposal {
return &AddAxelarManagedCellarIDsProposal{
Title: title,
Description: description,
CellarIds: cellarIds,
Expand All @@ -55,15 +55,15 @@ func NewAddManagedCellarIDsProposal(title string, description string, chainName
}
}

func (m *AddManagedCellarIDsProposal) ProposalRoute() string {
func (m *AddAxelarManagedCellarIDsProposal) ProposalRoute() string {
return RouterKey
}

func (m *AddManagedCellarIDsProposal) ProposalType() string {
func (m *AddAxelarManagedCellarIDsProposal) ProposalType() string {
return ProposalTypeAddManagedCellarIDs
}

func (m *AddManagedCellarIDsProposal) ValidateBasic() error {
func (m *AddAxelarManagedCellarIDsProposal) ValidateBasic() error {
if err := govtypes.ValidateAbstract(m); err != nil {
return err
}
Expand All @@ -75,8 +75,8 @@ func (m *AddManagedCellarIDsProposal) ValidateBasic() error {
return nil
}

func NewRemoveManagedCellarIDsProposal(title string, description string, chainName string, chainID uint64, cellarIds *CellarIDSet) *RemoveManagedCellarIDsProposal {
return &RemoveManagedCellarIDsProposal{
func NewRemoveManagedCellarIDsProposal(title string, description string, chainName string, chainID uint64, cellarIds *CellarIDSet) *RemoveAxelarManagedCellarIDsProposal {
return &RemoveAxelarManagedCellarIDsProposal{
Title: title,
Description: description,
CellarIds: cellarIds,
Expand All @@ -85,15 +85,15 @@ func NewRemoveManagedCellarIDsProposal(title string, description string, chainNa
}
}

func (m *RemoveManagedCellarIDsProposal) ProposalRoute() string {
func (m *RemoveAxelarManagedCellarIDsProposal) ProposalRoute() string {
return RouterKey
}

func (m *RemoveManagedCellarIDsProposal) ProposalType() string {
func (m *RemoveAxelarManagedCellarIDsProposal) ProposalType() string {
return ProposalTypeRemoveManagedCellarIDs
}

func (m *RemoveManagedCellarIDsProposal) ValidateBasic() error {
func (m *RemoveAxelarManagedCellarIDsProposal) ValidateBasic() error {
if err := govtypes.ValidateAbstract(m); err != nil {
return err
}
Expand All @@ -105,8 +105,8 @@ func (m *RemoveManagedCellarIDsProposal) ValidateBasic() error {
return nil
}

func NewScheduledCorkProposal(title string, description string, blockHeight uint64, chainName string, chainID uint64, targetContractAddress string, contractCallProtoJSON string) *ScheduledCorkProposal {
return &ScheduledCorkProposal{
func NewScheduledCorkProposal(title string, description string, blockHeight uint64, chainName string, chainID uint64, targetContractAddress string, contractCallProtoJSON string) *AxelarScheduledCorkProposal {
return &AxelarScheduledCorkProposal{
Title: title,
Description: description,
BlockHeight: blockHeight,
Expand All @@ -117,15 +117,15 @@ func NewScheduledCorkProposal(title string, description string, blockHeight uint
}
}

func (m *ScheduledCorkProposal) ProposalRoute() string {
func (m *AxelarScheduledCorkProposal) ProposalRoute() string {
return RouterKey
}

func (m *ScheduledCorkProposal) ProposalType() string {
func (m *AxelarScheduledCorkProposal) ProposalType() string {
return ProposalTypeScheduledCork
}

func (m *ScheduledCorkProposal) ValidateBasic() error {
func (m *AxelarScheduledCorkProposal) ValidateBasic() error {
if err := govtypes.ValidateAbstract(m); err != nil {
return err
}
Expand All @@ -145,8 +145,8 @@ func (m *ScheduledCorkProposal) ValidateBasic() error {
return nil
}

func NewCommunitySpendProposal(title string, description string, recipient string, chainID uint64, chainName string, amount sdk.Coin) *CommunityPoolSpendProposal {
return &CommunityPoolSpendProposal{
func NewCommunitySpendProposal(title string, description string, recipient string, chainID uint64, chainName string, amount sdk.Coin) *AxelarCommunityPoolSpendProposal {
return &AxelarCommunityPoolSpendProposal{
Title: title,
Description: description,
Recipient: recipient,
Expand All @@ -156,15 +156,15 @@ func NewCommunitySpendProposal(title string, description string, recipient strin
}
}

func (m *CommunityPoolSpendProposal) ProposalRoute() string {
func (m *AxelarCommunityPoolSpendProposal) ProposalRoute() string {
return RouterKey
}

func (m *CommunityPoolSpendProposal) ProposalType() string {
func (m *AxelarCommunityPoolSpendProposal) ProposalType() string {
return ProposalTypeCommunitySpend
}

func (m *CommunityPoolSpendProposal) ValidateBasic() error {
func (m *AxelarCommunityPoolSpendProposal) ValidateBasic() error {
if err := govtypes.ValidateAbstract(m); err != nil {
return err
}
Expand Down
Loading

0 comments on commit 06340a7

Please sign in to comment.