From dee36d886f35af4caaae0a97ad259d2b294a85fc Mon Sep 17 00:00:00 2001 From: Petr Ivanov Date: Tue, 2 Jul 2024 17:52:19 +0400 Subject: [PATCH] rename mint/burn to grant/revoke --- app/app.go | 4 +- proto/haqq/shariahoracle/v1/cac.proto | 6 +- x/shariahoracle/client/cli/tx.go | 12 +- x/shariahoracle/client/proposal_handler.go | 4 +- x/shariahoracle/keeper/proposals.go | 8 +- x/shariahoracle/keeper/proposals_test.go | 12 +- x/shariahoracle/proposal_handler.go | 28 ++-- x/shariahoracle/types/cac.pb.go | 145 +++++++++++---------- x/shariahoracle/types/codec.go | 4 +- x/shariahoracle/types/errors.go | 4 +- x/shariahoracle/types/proposal.go | 42 +++--- x/shariahoracle/types/proposal_test.go | 40 +++--- 12 files changed, 155 insertions(+), 154 deletions(-) diff --git a/app/app.go b/app/app.go index 1659a24a..43cfc0f2 100644 --- a/app/app.go +++ b/app/app.go @@ -231,8 +231,8 @@ var ( erc20client.RegisterCoinProposalHandler, erc20client.RegisterERC20ProposalHandler, erc20client.ToggleTokenConversionProposalHandler, - shariahoracleclient.MintCACProposalHandler, - shariahoracleclient.BurnCACProposalHandler, + shariahoracleclient.GrantCACProposalHandler, + shariahoracleclient.RevokeCACProposalHandler, shariahoracleclient.UpdateCACContractProposalHandler, }, ), diff --git a/proto/haqq/shariahoracle/v1/cac.proto b/proto/haqq/shariahoracle/v1/cac.proto index 69f0f53b..a296903d 100644 --- a/proto/haqq/shariahoracle/v1/cac.proto +++ b/proto/haqq/shariahoracle/v1/cac.proto @@ -4,8 +4,8 @@ package haqq.shariahoracle.v1; import "gogoproto/gogo.proto"; option go_package = "github.com/haqq-network/haqq/x/shariahoracle/types"; -// RegisterMintCACProposal -message MintCACProposal { +// RegisterGrantCACProposal +message GrantCACProposal { option (gogoproto.equal) = false; // title of the proposal string title = 1; @@ -15,7 +15,7 @@ message MintCACProposal { repeated string grantees = 3; } -message BurnCACProposal { +message RevokeCACProposal { option (gogoproto.equal) = false; // title of the proposal string title = 1; diff --git a/x/shariahoracle/client/cli/tx.go b/x/shariahoracle/client/cli/tx.go index aac19a78..602b5a22 100644 --- a/x/shariahoracle/client/cli/tx.go +++ b/x/shariahoracle/client/cli/tx.go @@ -10,8 +10,8 @@ import ( "github.com/spf13/cobra" ) -// NewMintCACProposalCmd returns a command handler for submitting a mint community approval certificates proposal -func NewMintCACProposalCmd() *cobra.Command { +// NewGrantCACProposalCmd returns a command handler for submitting a mint community approval certificates proposal +func NewGrantCACProposalCmd() *cobra.Command { cmd := &cobra.Command{ Use: "mint-cac GRANTEES...", Short: "Submit a new mint community approval certificates proposal", @@ -45,7 +45,7 @@ func NewMintCACProposalCmd() *cobra.Command { grantees := args - content := types.NewMintCACProposal(title, description, grantees...) + content := types.NewGrantCACProposal(title, description, grantees...) msg, err := govv1beta1.NewMsgSubmitProposal(content, deposit, from) if err != nil { @@ -71,8 +71,8 @@ func NewMintCACProposalCmd() *cobra.Command { return cmd } -// NewBurnCACProposalCmd returns a command handler for submitting a burn community approval certificates proposal -func NewBurnCACProposalCmd() *cobra.Command { +// NewRevokeCACProposalCmd returns a command handler for submitting a burn community approval certificates proposal +func NewRevokeCACProposalCmd() *cobra.Command { cmd := &cobra.Command{ Use: "burn-cac GRANTEES...", Short: "Submit a new burn community approval certificates proposal", @@ -106,7 +106,7 @@ func NewBurnCACProposalCmd() *cobra.Command { grantees := args - content := types.NewBurnCACProposal(title, description, grantees...) + content := types.NewRevokeCACProposal(title, description, grantees...) msg, err := govv1beta1.NewMsgSubmitProposal(content, deposit, from) if err != nil { diff --git a/x/shariahoracle/client/proposal_handler.go b/x/shariahoracle/client/proposal_handler.go index 6e85cce1..78c1b52d 100644 --- a/x/shariahoracle/client/proposal_handler.go +++ b/x/shariahoracle/client/proposal_handler.go @@ -6,7 +6,7 @@ import ( ) var ( - MintCACProposalHandler = govclient.NewProposalHandler(cli.NewMintCACProposalCmd) - BurnCACProposalHandler = govclient.NewProposalHandler(cli.NewBurnCACProposalCmd) + GrantCACProposalHandler = govclient.NewProposalHandler(cli.NewGrantCACProposalCmd) + RevokeCACProposalHandler = govclient.NewProposalHandler(cli.NewRevokeCACProposalCmd) UpdateCACContractProposalHandler = govclient.NewProposalHandler(cli.NewUpdateCACContractProposalCmd) ) diff --git a/x/shariahoracle/keeper/proposals.go b/x/shariahoracle/keeper/proposals.go index bdf0d393..66e2b9c3 100644 --- a/x/shariahoracle/keeper/proposals.go +++ b/x/shariahoracle/keeper/proposals.go @@ -7,8 +7,8 @@ import ( "github.com/haqq-network/haqq/x/shariahoracle/types" ) -// MintCAC mints CAC -func (k Keeper) MintCAC(ctx sdk.Context, to string) error { +// GrantCAC mints CAC +func (k Keeper) GrantCAC(ctx sdk.Context, to string) error { // mint CAC contract := common.HexToAddress(k.GetCACContractAddress(ctx)) @@ -27,8 +27,8 @@ func (k Keeper) MintCAC(ctx sdk.Context, to string) error { return nil } -// BurnCAC burns CAC -func (k Keeper) BurnCAC(ctx sdk.Context, from string) error { +// RevokeCAC burns CAC +func (k Keeper) RevokeCAC(ctx sdk.Context, from string) error { // burn CAC contract := common.HexToAddress(k.GetCACContractAddress(ctx)) diff --git a/x/shariahoracle/keeper/proposals_test.go b/x/shariahoracle/keeper/proposals_test.go index 440f8907..c7e6a1b0 100644 --- a/x/shariahoracle/keeper/proposals_test.go +++ b/x/shariahoracle/keeper/proposals_test.go @@ -11,7 +11,7 @@ import ( "github.com/stretchr/testify/mock" ) -func (suite *KeeperTestSuite) TestMintCAC() { //nolint:govet // we can copy locks here because it is a test +func (suite *KeeperTestSuite) TestGrantCAC() { //nolint:govet // we can copy locks here because it is a test testCases := []struct { name string @@ -45,7 +45,7 @@ func (suite *KeeperTestSuite) TestMintCAC() { //nolint:govet // we can copy lock suite.Require().NoError(err) params := types.NewParams(cacAddr.String()) suite.app.ShariahOracleKeeper.SetParams(suite.ctx, params) //nolint:errcheck - err = suite.app.ShariahOracleKeeper.MintCAC(suite.ctx, types.ModuleAddress.String()) + err = suite.app.ShariahOracleKeeper.GrantCAC(suite.ctx, types.ModuleAddress.String()) suite.Require().NoError(err) }, false, @@ -74,7 +74,7 @@ func (suite *KeeperTestSuite) TestMintCAC() { //nolint:govet // we can copy lock tc.malleate() - err := suite.app.ShariahOracleKeeper.MintCAC(suite.ctx, types.ModuleAddress.String()) + err := suite.app.ShariahOracleKeeper.GrantCAC(suite.ctx, types.ModuleAddress.String()) suite.Commit() if tc.expPass { @@ -89,7 +89,7 @@ func (suite *KeeperTestSuite) TestMintCAC() { //nolint:govet // we can copy lock } } -func (suite *KeeperTestSuite) TestBurnCAC() { //nolint:govet // we can copy locks here because it is a test +func (suite *KeeperTestSuite) TestRevokeCAC() { //nolint:govet // we can copy locks here because it is a test testCases := []struct { name string @@ -108,7 +108,7 @@ func (suite *KeeperTestSuite) TestBurnCAC() { //nolint:govet // we can copy lock suite.Require().NoError(err) params := types.NewParams(cacAddr.String()) suite.app.ShariahOracleKeeper.SetParams(suite.ctx, params) //nolint:errcheck - err = suite.app.ShariahOracleKeeper.MintCAC(suite.ctx, types.ModuleAddress.String()) + err = suite.app.ShariahOracleKeeper.GrantCAC(suite.ctx, types.ModuleAddress.String()) suite.Require().NoError(err) }, true, @@ -152,7 +152,7 @@ func (suite *KeeperTestSuite) TestBurnCAC() { //nolint:govet // we can copy lock tc.malleate() - err := suite.app.ShariahOracleKeeper.BurnCAC(suite.ctx, types.ModuleAddress.String()) + err := suite.app.ShariahOracleKeeper.RevokeCAC(suite.ctx, types.ModuleAddress.String()) suite.Commit() if tc.expPass { diff --git a/x/shariahoracle/proposal_handler.go b/x/shariahoracle/proposal_handler.go index 113813cd..0e3bda04 100644 --- a/x/shariahoracle/proposal_handler.go +++ b/x/shariahoracle/proposal_handler.go @@ -13,10 +13,10 @@ import ( func NewShariahOracleProposalHandler(k *keeper.Keeper) govv1beta1.Handler { return func(ctx sdk.Context, content govv1beta1.Content) error { switch c := content.(type) { - case *types.MintCACProposal: - return handleMintCACProposal(ctx, k, c) - case *types.BurnCACProposal: - return handleBurnCACProposal(ctx, k, c) + case *types.GrantCACProposal: + return handleGrantCACProposal(ctx, k, c) + case *types.RevokeCACProposal: + return handleRevokeCACProposal(ctx, k, c) case *types.UpdateCACContractProposal: return handleUpdateCACContractProposal(ctx, k, c) default: @@ -25,11 +25,11 @@ func NewShariahOracleProposalHandler(k *keeper.Keeper) govv1beta1.Handler { } } -// handleMintCACProposal -func handleMintCACProposal( +// handleGrantCACProposal +func handleGrantCACProposal( ctx sdk.Context, k *keeper.Keeper, - p *types.MintCACProposal, + p *types.GrantCACProposal, ) error { for _, grantee := range p.Grantees { cacMinted, err := k.DoesAddressHaveCAC(ctx, grantee) @@ -38,10 +38,10 @@ func handleMintCACProposal( } if cacMinted { - return errorsmod.Wrapf(types.ErrCACAlreadyMinted, "CAC already minted for address %s", grantee) + return errorsmod.Wrapf(types.ErrCACAlreadyGranted, "CAC already minted for address %s", grantee) } - err = k.MintCAC(ctx, grantee) + err = k.GrantCAC(ctx, grantee) if err != nil { return err } @@ -50,11 +50,11 @@ func handleMintCACProposal( return nil } -// handleBurnCACProposal -func handleBurnCACProposal( +// handleRevokeCACProposal +func handleRevokeCACProposal( ctx sdk.Context, k *keeper.Keeper, - p *types.BurnCACProposal, + p *types.RevokeCACProposal, ) error { for _, grantee := range p.Grantees { cacMinted, err := k.DoesAddressHaveCAC(ctx, grantee) @@ -63,10 +63,10 @@ func handleBurnCACProposal( } if !cacMinted { - return errorsmod.Wrapf(types.ErrCACNotMinted, "CAC not minted for address %s", grantee) + return errorsmod.Wrapf(types.ErrCACNotGranted, "CAC not minted for address %s", grantee) } - err = k.BurnCAC(ctx, grantee) + err = k.RevokeCAC(ctx, grantee) if err != nil { return err } diff --git a/x/shariahoracle/types/cac.pb.go b/x/shariahoracle/types/cac.pb.go index 668139c3..be5c977f 100644 --- a/x/shariahoracle/types/cac.pb.go +++ b/x/shariahoracle/types/cac.pb.go @@ -24,7 +24,7 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // RegisterMintCACProposal -type MintCACProposal struct { +type GrantCACProposal struct { // title of the proposal Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` // description of the proposal @@ -33,18 +33,18 @@ type MintCACProposal struct { Grantees []string `protobuf:"bytes,3,rep,name=grantees,proto3" json:"grantees,omitempty"` } -func (m *MintCACProposal) Reset() { *m = MintCACProposal{} } -func (m *MintCACProposal) String() string { return proto.CompactTextString(m) } -func (*MintCACProposal) ProtoMessage() {} -func (*MintCACProposal) Descriptor() ([]byte, []int) { +func (m *GrantCACProposal) Reset() { *m = GrantCACProposal{} } +func (m *GrantCACProposal) String() string { return proto.CompactTextString(m) } +func (*GrantCACProposal) ProtoMessage() {} +func (*GrantCACProposal) Descriptor() ([]byte, []int) { return fileDescriptor_c8d2931d9601696d, []int{0} } -func (m *MintCACProposal) XXX_Unmarshal(b []byte) error { +func (m *GrantCACProposal) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MintCACProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *GrantCACProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MintCACProposal.Marshal(b, m, deterministic) + return xxx_messageInfo_GrantCACProposal.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -54,40 +54,40 @@ func (m *MintCACProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, err return b[:n], nil } } -func (m *MintCACProposal) XXX_Merge(src proto.Message) { - xxx_messageInfo_MintCACProposal.Merge(m, src) +func (m *GrantCACProposal) XXX_Merge(src proto.Message) { + xxx_messageInfo_GrantCACProposal.Merge(m, src) } -func (m *MintCACProposal) XXX_Size() int { +func (m *GrantCACProposal) XXX_Size() int { return m.Size() } -func (m *MintCACProposal) XXX_DiscardUnknown() { - xxx_messageInfo_MintCACProposal.DiscardUnknown(m) +func (m *GrantCACProposal) XXX_DiscardUnknown() { + xxx_messageInfo_GrantCACProposal.DiscardUnknown(m) } -var xxx_messageInfo_MintCACProposal proto.InternalMessageInfo +var xxx_messageInfo_GrantCACProposal proto.InternalMessageInfo -func (m *MintCACProposal) GetTitle() string { +func (m *GrantCACProposal) GetTitle() string { if m != nil { return m.Title } return "" } -func (m *MintCACProposal) GetDescription() string { +func (m *GrantCACProposal) GetDescription() string { if m != nil { return m.Description } return "" } -func (m *MintCACProposal) GetGrantees() []string { +func (m *GrantCACProposal) GetGrantees() []string { if m != nil { return m.Grantees } return nil } -type BurnCACProposal struct { +type RevokeCACProposal struct { // title of the proposal Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` // description of the proposal @@ -96,18 +96,18 @@ type BurnCACProposal struct { Grantees []string `protobuf:"bytes,3,rep,name=grantees,proto3" json:"grantees,omitempty"` } -func (m *BurnCACProposal) Reset() { *m = BurnCACProposal{} } -func (m *BurnCACProposal) String() string { return proto.CompactTextString(m) } -func (*BurnCACProposal) ProtoMessage() {} -func (*BurnCACProposal) Descriptor() ([]byte, []int) { +func (m *RevokeCACProposal) Reset() { *m = RevokeCACProposal{} } +func (m *RevokeCACProposal) String() string { return proto.CompactTextString(m) } +func (*RevokeCACProposal) ProtoMessage() {} +func (*RevokeCACProposal) Descriptor() ([]byte, []int) { return fileDescriptor_c8d2931d9601696d, []int{1} } -func (m *BurnCACProposal) XXX_Unmarshal(b []byte) error { +func (m *RevokeCACProposal) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *BurnCACProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *RevokeCACProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_BurnCACProposal.Marshal(b, m, deterministic) + return xxx_messageInfo_RevokeCACProposal.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -117,33 +117,33 @@ func (m *BurnCACProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, err return b[:n], nil } } -func (m *BurnCACProposal) XXX_Merge(src proto.Message) { - xxx_messageInfo_BurnCACProposal.Merge(m, src) +func (m *RevokeCACProposal) XXX_Merge(src proto.Message) { + xxx_messageInfo_RevokeCACProposal.Merge(m, src) } -func (m *BurnCACProposal) XXX_Size() int { +func (m *RevokeCACProposal) XXX_Size() int { return m.Size() } -func (m *BurnCACProposal) XXX_DiscardUnknown() { - xxx_messageInfo_BurnCACProposal.DiscardUnknown(m) +func (m *RevokeCACProposal) XXX_DiscardUnknown() { + xxx_messageInfo_RevokeCACProposal.DiscardUnknown(m) } -var xxx_messageInfo_BurnCACProposal proto.InternalMessageInfo +var xxx_messageInfo_RevokeCACProposal proto.InternalMessageInfo -func (m *BurnCACProposal) GetTitle() string { +func (m *RevokeCACProposal) GetTitle() string { if m != nil { return m.Title } return "" } -func (m *BurnCACProposal) GetDescription() string { +func (m *RevokeCACProposal) GetDescription() string { if m != nil { return m.Description } return "" } -func (m *BurnCACProposal) GetGrantees() []string { +func (m *RevokeCACProposal) GetGrantees() []string { if m != nil { return m.Grantees } @@ -214,37 +214,38 @@ func (m *UpdateCACContractProposal) GetNewImplementationAddress() string { } func init() { - proto.RegisterType((*MintCACProposal)(nil), "haqq.shariahoracle.v1.MintCACProposal") - proto.RegisterType((*BurnCACProposal)(nil), "haqq.shariahoracle.v1.BurnCACProposal") + proto.RegisterType((*GrantCACProposal)(nil), "haqq.shariahoracle.v1.GrantCACProposal") + proto.RegisterType((*RevokeCACProposal)(nil), "haqq.shariahoracle.v1.RevokeCACProposal") proto.RegisterType((*UpdateCACContractProposal)(nil), "haqq.shariahoracle.v1.UpdateCACContractProposal") } func init() { proto.RegisterFile("haqq/shariahoracle/v1/cac.proto", fileDescriptor_c8d2931d9601696d) } var fileDescriptor_c8d2931d9601696d = []byte{ - // 304 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x91, 0x31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 0x08, 0xc9, 0x20, 0x49, 0x94, 0x44, 0xc3, 0x38, 0xfe, 0x39, 0xf7, 0x8a, - 0xb4, 0x25, 0xac, 0xc6, 0x62, 0xa6, 0x0b, 0x98, 0x81, 0x44, 0xe6, 0xae, 0x63, 0x96, 0xa6, 0x06, - 0xac, 0x6b, 0xe2, 0x3e, 0x84, 0x12, 0x56, 0xd7, 0x5b, 0xc0, 0xa0, 0xf6, 0xeb, 0x66, 0xc3, 0x9b, - 0xb7, 0x4d, 0xe4, 0xaf, 0x37, 0x91, 0xff, 0xb1, 0x89, 0xfc, 0xe7, 0x32, 0xf2, 0xd6, 0x65, 0xe4, - 0xbd, 0x97, 0x91, 0xf7, 0x70, 0x9e, 0x09, 0xcc, 0x17, 0x93, 0x98, 0xab, 0x19, 0x75, 0x2b, 0x9e, - 0x49, 0xc0, 0x95, 0x32, 0xd3, 0x4a, 0xd0, 0xc7, 0x5f, 0xab, 0xe3, 0x93, 0x06, 0x3b, 0xd9, 0xaf, - 0x86, 0xbc, 0xf8, 0x0a, 0x00, 0x00, 0xff, 0xff, 0x97, 0x44, 0x8a, 0xbd, 0x18, 0x02, 0x00, 0x00, -} - -func (m *MintCACProposal) Marshal() (dAtA []byte, err error) { + // 307 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x91, 0xb1, 0x4b, 0xc3, 0x40, + 0x14, 0xc6, 0x13, 0xab, 0x62, 0xcf, 0x45, 0x43, 0x85, 0xd8, 0x21, 0x2d, 0x9d, 0xba, 0x98, 0x50, + 0xdd, 0xc4, 0xa5, 0x76, 0x10, 0xc1, 0x41, 0x0a, 0x2e, 0x2e, 0xe5, 0x9a, 0x3c, 0x92, 0xa3, 0xc9, + 0xbd, 0xeb, 0xdd, 0xb3, 0xd5, 0xff, 0xc2, 0xcd, 0xd5, 0x3f, 0xc7, 0xb1, 0xa3, 0xa3, 0x34, 0x8b, + 0x7f,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, 0x07, 0xee, 0xc7, 0x3a, 0x70, 0x9f, 0xcb, 0xc0, 0x59, + 0x95, 0x81, 0xf3, 0x5e, 0x06, 0xce, 0xfd, 0x69, 0x2a, 0x28, 0x7b, 0x98, 0x86, 0x31, 0x16, 0x91, + 0x2d, 0xf2, 0x44, 0x02, 0x2d, 0x51, 0xcf, 0x2a, 0x11, 0x3d, 0xfe, 0x2a, 0x9e, 0x9e, 0x14, 0x98, + 0xe9, 0x6e, 0xd5, 0xe5, 0xd9, 0x57, 0x00, 0x00, 0x00, 0xff, 0xff, 0x29, 0xdb, 0xe6, 0x7a, 0x1b, + 0x02, 0x00, 0x00, +} + +func (m *GrantCACProposal) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -254,12 +255,12 @@ func (m *MintCACProposal) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MintCACProposal) MarshalTo(dAtA []byte) (int, error) { +func (m *GrantCACProposal) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MintCACProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *GrantCACProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -290,7 +291,7 @@ func (m *MintCACProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *BurnCACProposal) Marshal() (dAtA []byte, err error) { +func (m *RevokeCACProposal) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -300,12 +301,12 @@ func (m *BurnCACProposal) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *BurnCACProposal) MarshalTo(dAtA []byte) (int, error) { +func (m *RevokeCACProposal) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *BurnCACProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *RevokeCACProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -391,7 +392,7 @@ func encodeVarintCac(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *MintCACProposal) Size() (n int) { +func (m *GrantCACProposal) Size() (n int) { if m == nil { return 0 } @@ -414,7 +415,7 @@ func (m *MintCACProposal) Size() (n int) { return n } -func (m *BurnCACProposal) Size() (n int) { +func (m *RevokeCACProposal) Size() (n int) { if m == nil { return 0 } @@ -464,7 +465,7 @@ func sovCac(x uint64) (n int) { func sozCac(x uint64) (n int) { return sovCac(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *MintCACProposal) Unmarshal(dAtA []byte) error { +func (m *GrantCACProposal) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -487,10 +488,10 @@ func (m *MintCACProposal) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MintCACProposal: wiretype end group for non-group") + return fmt.Errorf("proto: GrantCACProposal: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MintCACProposal: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: GrantCACProposal: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -610,7 +611,7 @@ func (m *MintCACProposal) Unmarshal(dAtA []byte) error { } return nil } -func (m *BurnCACProposal) Unmarshal(dAtA []byte) error { +func (m *RevokeCACProposal) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -633,10 +634,10 @@ func (m *BurnCACProposal) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: BurnCACProposal: wiretype end group for non-group") + return fmt.Errorf("proto: RevokeCACProposal: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: BurnCACProposal: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: RevokeCACProposal: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: diff --git a/x/shariahoracle/types/codec.go b/x/shariahoracle/types/codec.go index 6fb1933a..21d9d3a0 100644 --- a/x/shariahoracle/types/codec.go +++ b/x/shariahoracle/types/codec.go @@ -19,8 +19,8 @@ func init() { func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { registry.RegisterImplementations( (*govv1beta1.Content)(nil), - &MintCACProposal{}, - &BurnCACProposal{}, + &GrantCACProposal{}, + &RevokeCACProposal{}, &UpdateCACContractProposal{}, ) } diff --git a/x/shariahoracle/types/errors.go b/x/shariahoracle/types/errors.go index 3f2b29a3..643481e7 100644 --- a/x/shariahoracle/types/errors.go +++ b/x/shariahoracle/types/errors.go @@ -8,7 +8,7 @@ import ( var ( ErrABIPack = errorsmod.Register(ModuleName, 9, "contract ABI pack failed") - ErrCACAlreadyMinted = errorsmod.Register(ModuleName, 10, "CAC already minted") - ErrCACNotMinted = errorsmod.Register(ModuleName, 11, "CAC is not minted") + ErrCACAlreadyGranted = errorsmod.Register(ModuleName, 10, "CAC already granted") + ErrCACNotGranted = errorsmod.Register(ModuleName, 11, "CAC is not granted") ErrInvalidEVMResponse = errorsmod.Register(ModuleName, 12, "invalid EVM response") ) diff --git a/x/shariahoracle/types/proposal.go b/x/shariahoracle/types/proposal.go index e684962b..5c6db704 100644 --- a/x/shariahoracle/types/proposal.go +++ b/x/shariahoracle/types/proposal.go @@ -10,30 +10,30 @@ import ( // constants const ( - ProposalTypeMintCAC string = "MintCAC" - ProposalTypeBurnCAC string = "BurnCAC" + ProposalTypeGrantCAC string = "GrantCAC" + ProposalTypeRevokeCAC string = "RevokeCAC" ProposalTypeUpdateCACContract string = "UpdateCACContract" ) // Implements Proposal Interface var ( - _ v1beta1.Content = &MintCACProposal{} - _ v1beta1.Content = &BurnCACProposal{} + _ v1beta1.Content = &GrantCACProposal{} + _ v1beta1.Content = &RevokeCACProposal{} _ v1beta1.Content = &UpdateCACContractProposal{} ) func init() { - v1beta1.RegisterProposalType(ProposalTypeMintCAC) - v1beta1.RegisterProposalType(ProposalTypeBurnCAC) + v1beta1.RegisterProposalType(ProposalTypeGrantCAC) + v1beta1.RegisterProposalType(ProposalTypeRevokeCAC) v1beta1.RegisterProposalType(ProposalTypeUpdateCACContract) - govcdc.ModuleCdc.Amino.RegisterConcrete(&MintCACProposal{}, "shariahoracle/MintCACProposal", nil) - govcdc.ModuleCdc.Amino.RegisterConcrete(&BurnCACProposal{}, "shariahoracle/BurnCACProposal", nil) + govcdc.ModuleCdc.Amino.RegisterConcrete(&GrantCACProposal{}, "shariahoracle/GrantCACProposal", nil) + govcdc.ModuleCdc.Amino.RegisterConcrete(&RevokeCACProposal{}, "shariahoracle/RevokeCACProposal", nil) govcdc.ModuleCdc.Amino.RegisterConcrete(&UpdateCACContractProposal{}, "shariahoracle/UpdateCACContractProposal", nil) } // NewRegisterCoinProposal returns new instance of RegisterCoinProposal -func NewMintCACProposal(title, description string, granteeAddress ...string) v1beta1.Content { - return &MintCACProposal{ +func NewGrantCACProposal(title, description string, granteeAddress ...string) v1beta1.Content { + return &GrantCACProposal{ Title: title, Description: description, Grantees: granteeAddress, @@ -41,15 +41,15 @@ func NewMintCACProposal(title, description string, granteeAddress ...string) v1b } // ProposalRoute returns router key for this proposal -func (*MintCACProposal) ProposalRoute() string { return RouterKey } +func (*GrantCACProposal) ProposalRoute() string { return RouterKey } // ProposalType returns proposal type for this proposal -func (*MintCACProposal) ProposalType() string { - return ProposalTypeMintCAC +func (*GrantCACProposal) ProposalType() string { + return ProposalTypeGrantCAC } // ValidateBasic performs a stateless check of the proposal fields -func (rtbp *MintCACProposal) ValidateBasic() error { +func (rtbp *GrantCACProposal) ValidateBasic() error { for _, grantee := range rtbp.Grantees { if !common.IsHexAddress(grantee) { return errorsmod.Wrap(types.ErrInvalidProposalContent, "invalid contract address") @@ -59,9 +59,9 @@ func (rtbp *MintCACProposal) ValidateBasic() error { return v1beta1.ValidateAbstract(rtbp) } -// NewBurnCACProposal returns new instance of RegisterCoinProposal -func NewBurnCACProposal(title, description string, granteeAddress ...string) v1beta1.Content { - return &BurnCACProposal{ +// NewRevokeCACProposal returns new instance of RegisterCoinProposal +func NewRevokeCACProposal(title, description string, granteeAddress ...string) v1beta1.Content { + return &RevokeCACProposal{ Title: title, Description: description, Grantees: granteeAddress, @@ -69,15 +69,15 @@ func NewBurnCACProposal(title, description string, granteeAddress ...string) v1b } // ProposalRoute returns router key for this proposal -func (*BurnCACProposal) ProposalRoute() string { return RouterKey } +func (*RevokeCACProposal) ProposalRoute() string { return RouterKey } // ProposalType returns proposal type for this proposal -func (*BurnCACProposal) ProposalType() string { - return ProposalTypeBurnCAC +func (*RevokeCACProposal) ProposalType() string { + return ProposalTypeRevokeCAC } // ValidateBasic performs a stateless check of the proposal fields -func (rtbp *BurnCACProposal) ValidateBasic() error { +func (rtbp *RevokeCACProposal) ValidateBasic() error { for _, grantee := range rtbp.Grantees { if !common.IsHexAddress(grantee) { return errorsmod.Wrap(types.ErrInvalidProposalContent, "invalid contract address") diff --git a/x/shariahoracle/types/proposal_test.go b/x/shariahoracle/types/proposal_test.go index 699ff6eb..e5315c5f 100644 --- a/x/shariahoracle/types/proposal_test.go +++ b/x/shariahoracle/types/proposal_test.go @@ -19,15 +19,15 @@ func TestProposalTestSuite(t *testing.T) { } func (suite *ProposalTestSuite) TestKeysTypes() { - suite.Require().Equal("shariahoracle", (&types.MintCACProposal{}).ProposalRoute()) - suite.Require().Equal("MintCAC", (&types.MintCACProposal{}).ProposalType()) - suite.Require().Equal("shariahoracle", (&types.BurnCACProposal{}).ProposalRoute()) - suite.Require().Equal("BurnCAC", (&types.BurnCACProposal{}).ProposalType()) + suite.Require().Equal("shariahoracle", (&types.GrantCACProposal{}).ProposalRoute()) + suite.Require().Equal("GrantCAC", (&types.GrantCACProposal{}).ProposalType()) + suite.Require().Equal("shariahoracle", (&types.RevokeCACProposal{}).ProposalRoute()) + suite.Require().Equal("RevokeCAC", (&types.RevokeCACProposal{}).ProposalType()) suite.Require().Equal("shariahoracle", (&types.UpdateCACContractProposal{}).ProposalRoute()) suite.Require().Equal("UpdateCACContract", (&types.UpdateCACContractProposal{}).ProposalType()) } -func (suite *ProposalTestSuite) TestMintCACProposal() { +func (suite *ProposalTestSuite) TestGrantCACProposal() { testCases := []struct { msg string title string @@ -36,18 +36,18 @@ func (suite *ProposalTestSuite) TestMintCACProposal() { expectPass bool }{ // Valid tests - {msg: "Mint CAC - valid grantee address", title: "test", description: "test desc", grantees: []string{utiltx.GenerateAddress().String()}, expectPass: true}, + {msg: "Grant CAC - valid grantee address", title: "test", description: "test desc", grantees: []string{utiltx.GenerateAddress().String()}, expectPass: true}, // Missing params valid - {msg: "Mint CAC - invalid missing title ", title: "", description: "test desc", grantees: []string{utiltx.GenerateAddress().String()}, expectPass: false}, - {msg: "Mint CAC - invalid missing description ", title: "test", description: "", grantees: []string{utiltx.GenerateAddress().String()}, expectPass: false}, + {msg: "Grant CAC - invalid missing title ", title: "", description: "test desc", grantees: []string{utiltx.GenerateAddress().String()}, expectPass: false}, + {msg: "Grant CAC - invalid missing description ", title: "test", description: "", grantees: []string{utiltx.GenerateAddress().String()}, expectPass: false}, // Invalid address - {msg: "Mint CAC - invalid address (no hex)", title: "test", description: "test desc", grantees: []string{""}, expectPass: false}, - {msg: "Mint CAC - invalid address (invalid length 1)", title: "test", description: "test desc", grantees: []string{"0x5dCA2483280D9727c80b5518faC4556617fb194FFF"}, expectPass: false}, - {msg: "Mint CAC - invalid address (invalid prefix)", title: "test", description: "test desc", grantees: []string{"1x5dCA2483280D9727c80b5518faC4556617fb19F"}, expectPass: false}, + {msg: "Grant CAC - invalid address (no hex)", title: "test", description: "test desc", grantees: []string{""}, expectPass: false}, + {msg: "Grant CAC - invalid address (invalid length 1)", title: "test", description: "test desc", grantees: []string{"0x5dCA2483280D9727c80b5518faC4556617fb194FFF"}, expectPass: false}, + {msg: "Grant CAC - invalid address (invalid prefix)", title: "test", description: "test desc", grantees: []string{"1x5dCA2483280D9727c80b5518faC4556617fb19F"}, expectPass: false}, } for i, tc := range testCases { - tx := types.NewMintCACProposal(tc.title, tc.description, tc.grantees...) + tx := types.NewGrantCACProposal(tc.title, tc.description, tc.grantees...) err := tx.ValidateBasic() if tc.expectPass { @@ -58,7 +58,7 @@ func (suite *ProposalTestSuite) TestMintCACProposal() { } } -func (suite *ProposalTestSuite) TestBurnCACProposal() { +func (suite *ProposalTestSuite) TestRevokeCACProposal() { testCases := []struct { msg string title string @@ -67,18 +67,18 @@ func (suite *ProposalTestSuite) TestBurnCACProposal() { expectPass bool }{ // Valid tests - {msg: "Burn CAC - valid grantee address", title: "test", description: "test desc", grantees: []string{utiltx.GenerateAddress().String()}, expectPass: true}, + {msg: "Revoke CAC - valid grantee address", title: "test", description: "test desc", grantees: []string{utiltx.GenerateAddress().String()}, expectPass: true}, // Missing params valid - {msg: "Burn CAC - invalid missing title ", title: "", description: "test desc", grantees: []string{utiltx.GenerateAddress().String()}, expectPass: false}, - {msg: "Burn CAC - invalid missing description ", title: "test", description: "", grantees: []string{utiltx.GenerateAddress().String()}, expectPass: false}, + {msg: "Revoke CAC - invalid missing title ", title: "", description: "test desc", grantees: []string{utiltx.GenerateAddress().String()}, expectPass: false}, + {msg: "Revoke CAC - invalid missing description ", title: "test", description: "", grantees: []string{utiltx.GenerateAddress().String()}, expectPass: false}, // Invalid address - {msg: "Burn CAC - invalid address (no hex)", title: "test", description: "test desc", grantees: []string{""}, expectPass: false}, - {msg: "Burn CAC - invalid address (invalid length 1)", title: "test", description: "test desc", grantees: []string{"0x5dCA2483280D9727c80b5518faC4556617fb194FFF"}, expectPass: false}, - {msg: "Burn CAC - invalid address (invalid prefix)", title: "test", description: "test desc", grantees: []string{"1x5dCA2483280D9727c80b5518faC4556617fb19F"}, expectPass: false}, + {msg: "Revoke CAC - invalid address (no hex)", title: "test", description: "test desc", grantees: []string{""}, expectPass: false}, + {msg: "Revoke CAC - invalid address (invalid length 1)", title: "test", description: "test desc", grantees: []string{"0x5dCA2483280D9727c80b5518faC4556617fb194FFF"}, expectPass: false}, + {msg: "Revoke CAC - invalid address (invalid prefix)", title: "test", description: "test desc", grantees: []string{"1x5dCA2483280D9727c80b5518faC4556617fb19F"}, expectPass: false}, } for i, tc := range testCases { - tx := types.NewBurnCACProposal(tc.title, tc.description, tc.grantees...) + tx := types.NewRevokeCACProposal(tc.title, tc.description, tc.grantees...) err := tx.ValidateBasic() if tc.expectPass {