From 155301224c20c4aa77cb4f397b0e7cce05b62644 Mon Sep 17 00:00:00 2001 From: Kevin Yang <5478483+k-yang@users.noreply.github.com> Date: Tue, 19 Mar 2024 17:17:12 +0900 Subject: [PATCH 1/4] feat(inflation): add burn method --- app/keepers.go | 2 +- proto/nibiru/inflation/v1/tx.proto | 31 +- x/inflation/keeper/keeper.go | 10 + x/inflation/keeper/keeper_test.go | 48 +++ x/inflation/keeper/msg_server.go | 14 + x/inflation/keeper/msg_server_test.go | 17 + x/inflation/types/interfaces.go | 3 + x/inflation/types/msgs.go | 62 +++- x/inflation/types/tx.pb.go | 462 +++++++++++++++++++++++--- x/inflation/types/tx.pb.gw.go | 83 +++++ 10 files changed, 675 insertions(+), 57 deletions(-) create mode 100644 x/inflation/keeper/keeper_test.go diff --git a/app/keepers.go b/app/keepers.go index 63350526f..b6b54243f 100644 --- a/app/keepers.go +++ b/app/keepers.go @@ -794,7 +794,7 @@ func ModuleAccPerms() map[string][]string { return map[string][]string{ authtypes.FeeCollectorName: nil, distrtypes.ModuleName: nil, - inflationtypes.ModuleName: {authtypes.Minter}, + inflationtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, govtypes.ModuleName: {authtypes.Burner}, diff --git a/proto/nibiru/inflation/v1/tx.proto b/proto/nibiru/inflation/v1/tx.proto index a63b5299d..da0a31b05 100644 --- a/proto/nibiru/inflation/v1/tx.proto +++ b/proto/nibiru/inflation/v1/tx.proto @@ -4,10 +4,10 @@ package nibiru.inflation.v1; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; import "nibiru/inflation/v1/inflation.proto"; +import "cosmos/base/v1beta1/coin.proto"; option go_package = "github.com/NibiruChain/nibiru/x/inflation/types"; - service Msg { // ToggleInflation defines a method to enable or disable inflation. rpc ToggleInflation(MsgToggleInflation) returns (MsgToggleInflationResponse) { @@ -15,10 +15,14 @@ service Msg { }; // EditInflationParams defines a method to edit the inflation params. - rpc EditInflationParams(MsgEditInflationParams) - returns (MsgEditInflationParamsResponse) { + rpc EditInflationParams(MsgEditInflationParams) + returns (MsgEditInflationParamsResponse) { option (google.api.http).post = "/nibiru/inflation/edit-inflation-params"; - }; + }; + + rpc Burn(MsgBurn) returns (MsgBurnResponse) { + option (google.api.http).post = "/nibiru/inflation/v1/burn"; + }; } // MsgToggleInflation defines a message to enable or disable inflation. @@ -33,16 +37,16 @@ message MsgToggleInflation { message MsgEditInflationParams { option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; - + string sender = 1; bool inflation_enabled = 2; - repeated string polynomial_factors = 3[ + repeated string polynomial_factors = 3 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = true ]; InflationDistribution inflation_distribution = 4 [ (gogoproto.nullable) = true ]; - + string epochs_per_period = 5 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = true @@ -57,8 +61,15 @@ message MsgEditInflationParams { ]; } -message MsgToggleInflationResponse { -} +message MsgToggleInflationResponse {} -message MsgEditInflationParamsResponse { +message MsgEditInflationParamsResponse {} + +// MsgBurn: allows burning of any token +message MsgBurn { + string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; + cosmos.base.v1beta1.Coin coin = 2 + [ (gogoproto.moretags) = "yaml:\"coin\"", (gogoproto.nullable) = false ]; } + +message MsgBurnResponse {} \ No newline at end of file diff --git a/x/inflation/keeper/keeper.go b/x/inflation/keeper/keeper.go index 03327ac46..43742b843 100644 --- a/x/inflation/keeper/keeper.go +++ b/x/inflation/keeper/keeper.go @@ -89,3 +89,13 @@ func NewKeeper( func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", "x/"+types.ModuleName) } + +func (k Keeper) Burn(ctx sdk.Context, coins sdk.Coins, sender sdk.AccAddress) error { + if err := k.bankKeeper.SendCoinsFromAccountToModule( + ctx, sender, types.ModuleName, coins, + ); err != nil { + return err + } + + return k.bankKeeper.BurnCoins(ctx, types.ModuleName, coins) +} diff --git a/x/inflation/keeper/keeper_test.go b/x/inflation/keeper/keeper_test.go new file mode 100644 index 000000000..d844931ff --- /dev/null +++ b/x/inflation/keeper/keeper_test.go @@ -0,0 +1,48 @@ +package keeper_test + +import ( + "fmt" + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + + "github.com/NibiruChain/nibiru/x/common/testutil" + "github.com/NibiruChain/nibiru/x/common/testutil/testapp" + "github.com/NibiruChain/nibiru/x/inflation/types" +) + +func init() { + testapp.EnsureNibiruPrefix() +} + +func TestBurn(t *testing.T) { + testCases := []struct { + name string + sender sdk.AccAddress + burnCoin sdk.Coin + expectedErr error + }{ + { + name: "pass", + sender: testutil.AccAddress(), + burnCoin: sdk.NewCoin("nibiru", sdk.NewInt(100)), + expectedErr: nil, + }, + } + for _, tc := range testCases { + t.Run(fmt.Sprintf("Case %s", tc.name), func(t *testing.T) { + nibiruApp, ctx := testapp.NewNibiruTestAppAndContext() + nibiruApp.BankKeeper.MintCoins(ctx, types.ModuleName, sdk.NewCoins(tc.burnCoin)) + nibiruApp.BankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, tc.sender, sdk.NewCoins(tc.burnCoin)) + + // Burn coins + err := nibiruApp.InflationKeeper.Burn(ctx, sdk.NewCoins(tc.burnCoin), tc.sender) + if tc.expectedErr != nil { + require.EqualError(t, err, tc.expectedErr.Error()) + } else { + require.NoError(t, err) + } + }) + } +} diff --git a/x/inflation/keeper/msg_server.go b/x/inflation/keeper/msg_server.go index b1cc8048a..c72725bd6 100644 --- a/x/inflation/keeper/msg_server.go +++ b/x/inflation/keeper/msg_server.go @@ -46,3 +46,17 @@ func (ms msgServer) ToggleInflation( resp = &types.MsgToggleInflationResponse{} return resp, err } + +func (ms msgServer) Burn( + goCtx context.Context, msg *types.MsgBurn, +) (resp *types.MsgBurnResponse, err error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + sender, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + return nil, err + } + + err = ms.Keeper.Burn(ctx, sdk.NewCoins(msg.Coin), sender) + return &types.MsgBurnResponse{}, err +} diff --git a/x/inflation/keeper/msg_server_test.go b/x/inflation/keeper/msg_server_test.go index 2f1e1483f..aa33f939a 100644 --- a/x/inflation/keeper/msg_server_test.go +++ b/x/inflation/keeper/msg_server_test.go @@ -70,3 +70,20 @@ func TestMsgEditInflationParams(t *testing.T) { params = app.InflationKeeper.GetParams(ctx) require.EqualValues(t, params.EpochsPerPeriod, 42) } + +func TestMsgBurn(t *testing.T) { + app, ctx := testapp.NewNibiruTestAppAndContext() + sender := testutil.AccAddress() + app.BankKeeper.MintCoins(ctx, types.ModuleName, sdk.NewCoins(sdk.NewCoin("unibi", sdk.NewInt(100)))) + app.BankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, sender, sdk.NewCoins(sdk.NewCoin("unibi", sdk.NewInt(100)))) + + msgServer := keeper.NewMsgServerImpl(app.InflationKeeper) + + msg := types.MsgBurn{ + Sender: sender.String(), + Coin: sdk.NewCoin("unibi", sdk.NewInt(100)), + } + + _, err := msgServer.Burn(ctx, &msg) + require.NoError(t, err) +} diff --git a/x/inflation/types/interfaces.go b/x/inflation/types/interfaces.go index 2233ac4e0..1fccafed4 100644 --- a/x/inflation/types/interfaces.go +++ b/x/inflation/types/interfaces.go @@ -21,6 +21,9 @@ type BankKeeper interface { GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error SendCoinsFromModuleToModule(ctx sdk.Context, senderModule, recipientModule string, amt sdk.Coins) error + SendCoinsFromAccountToModule( + ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins, + ) error MintCoins(ctx sdk.Context, name string, amt sdk.Coins) error BurnCoins(ctx sdk.Context, name string, amt sdk.Coins) error HasSupply(ctx sdk.Context, denom string) bool diff --git a/x/inflation/types/msgs.go b/x/inflation/types/msgs.go index 18496542e..69f574799 100644 --- a/x/inflation/types/msgs.go +++ b/x/inflation/types/msgs.go @@ -4,27 +4,30 @@ import ( "fmt" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" ) // ensure Msg interface compliance at compile time var ( - _ sdk.Msg = &MsgEditInflationParams{} - _ sdk.Msg = &MsgToggleInflation{} + _ legacytx.LegacyMsg = &MsgEditInflationParams{} + _ legacytx.LegacyMsg = &MsgToggleInflation{} + _ legacytx.LegacyMsg = &MsgBurn{} ) // oracle message types const ( TypeMsgEditInflationParams = "edit_inflation_params" TypeMsgToggleInflation = "toggle_inflation" + TypeMsgBurn = "msg_burn" ) -// Route implements sdk.Msg +// Route implements legacytx.LegacyMsg func (msg MsgEditInflationParams) Route() string { return RouterKey } -// Type implements sdk.Msg +// Type implements legacytx.LegacyMsg func (msg MsgEditInflationParams) Type() string { return TypeMsgEditInflationParams } -// GetSignBytes implements sdk.Msg +// GetSignBytes implements legacytx.LegacyMsg func (msg MsgEditInflationParams) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) } @@ -75,13 +78,13 @@ func (m MsgEditInflationParams) ValidateBasic() error { // ------------------------------------------------- // MsgToggleInflation -// Route implements sdk.Msg +// Route implements legacytx.LegacyMsg func (msg MsgToggleInflation) Route() string { return RouterKey } -// Type implements sdk.Msg +// Type implements legacytx.LegacyMsg func (msg MsgToggleInflation) Type() string { return TypeMsgToggleInflation } -// GetSignBytes implements sdk.Msg +// GetSignBytes implements legacytx.LegacyMsg func (msg MsgToggleInflation) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) } @@ -102,3 +105,46 @@ func (m MsgToggleInflation) ValidateBasic() error { } return nil } + +// ------------------------------------------------- +// MsgBurn +// Route implements legacytx.LegacyMsg +func (msg MsgBurn) Route() string { return RouterKey } + +// Type implements legacytx.LegacyMsg +func (msg MsgBurn) Type() string { return TypeMsgBurn } + +// GetSignBytes implements legacytx.LegacyMsg +func (msg MsgBurn) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) +} + +// GetSigners implements legacytx.LegacyMsg +func (msg MsgBurn) GetSigners() []sdk.AccAddress { + feeder, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + panic(err) + } + + return []sdk.AccAddress{feeder} +} + +func (m MsgBurn) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(m.Sender); err != nil { + return err + } + + if m.Coin.Denom == "" { + return fmt.Errorf("coin denom should not be empty") + } + + if m.Coin.Amount.IsZero() { + return fmt.Errorf("coin amount should not be zero") + } + + if m.Coin.IsNil() { + return fmt.Errorf("coin should not be nil") + } + + return nil +} diff --git a/x/inflation/types/tx.pb.go b/x/inflation/types/tx.pb.go index 806fe9c66..8d8a555fd 100644 --- a/x/inflation/types/tx.pb.go +++ b/x/inflation/types/tx.pb.go @@ -7,6 +7,7 @@ import ( context "context" fmt "fmt" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" @@ -184,54 +185,151 @@ func (m *MsgEditInflationParamsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgEditInflationParamsResponse proto.InternalMessageInfo +// MsgBurn: allows burning of any token +type MsgBurn struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` + Coin types.Coin `protobuf:"bytes,2,opt,name=coin,proto3" json:"coin" yaml:"coin"` +} + +func (m *MsgBurn) Reset() { *m = MsgBurn{} } +func (m *MsgBurn) String() string { return proto.CompactTextString(m) } +func (*MsgBurn) ProtoMessage() {} +func (*MsgBurn) Descriptor() ([]byte, []int) { + return fileDescriptor_9f6843f876608d76, []int{4} +} +func (m *MsgBurn) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgBurn) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgBurn.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgBurn) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgBurn.Merge(m, src) +} +func (m *MsgBurn) XXX_Size() int { + return m.Size() +} +func (m *MsgBurn) XXX_DiscardUnknown() { + xxx_messageInfo_MsgBurn.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgBurn proto.InternalMessageInfo + +func (m *MsgBurn) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgBurn) GetCoin() types.Coin { + if m != nil { + return m.Coin + } + return types.Coin{} +} + +type MsgBurnResponse struct { +} + +func (m *MsgBurnResponse) Reset() { *m = MsgBurnResponse{} } +func (m *MsgBurnResponse) String() string { return proto.CompactTextString(m) } +func (*MsgBurnResponse) ProtoMessage() {} +func (*MsgBurnResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_9f6843f876608d76, []int{5} +} +func (m *MsgBurnResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgBurnResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgBurnResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgBurnResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgBurnResponse.Merge(m, src) +} +func (m *MsgBurnResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgBurnResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgBurnResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgBurnResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgToggleInflation)(nil), "nibiru.inflation.v1.MsgToggleInflation") proto.RegisterType((*MsgEditInflationParams)(nil), "nibiru.inflation.v1.MsgEditInflationParams") proto.RegisterType((*MsgToggleInflationResponse)(nil), "nibiru.inflation.v1.MsgToggleInflationResponse") proto.RegisterType((*MsgEditInflationParamsResponse)(nil), "nibiru.inflation.v1.MsgEditInflationParamsResponse") + proto.RegisterType((*MsgBurn)(nil), "nibiru.inflation.v1.MsgBurn") + proto.RegisterType((*MsgBurnResponse)(nil), "nibiru.inflation.v1.MsgBurnResponse") } func init() { proto.RegisterFile("nibiru/inflation/v1/tx.proto", fileDescriptor_9f6843f876608d76) } var fileDescriptor_9f6843f876608d76 = []byte{ - // 579 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0x41, 0x6f, 0x12, 0x4f, - 0x18, 0xc6, 0xd9, 0xc2, 0x9f, 0x7f, 0x19, 0xa3, 0x2d, 0x53, 0x25, 0x1b, 0xc4, 0x85, 0x6c, 0x13, - 0x4b, 0x6d, 0xd8, 0x49, 0xdb, 0x5b, 0x8f, 0xd8, 0x9a, 0x70, 0xc0, 0x90, 0x8d, 0x07, 0x6d, 0x62, - 0xc8, 0xc0, 0x4e, 0x97, 0x89, 0xbb, 0x3b, 0x9b, 0x99, 0xa1, 0x81, 0xab, 0x27, 0x8f, 0x4d, 0xfc, - 0x02, 0x3d, 0xfa, 0x01, 0xfc, 0x06, 0x5e, 0x7a, 0x6c, 0xe2, 0xc5, 0x78, 0x20, 0x06, 0x3c, 0x78, - 0xf6, 0x13, 0x18, 0x76, 0x60, 0x21, 0xb2, 0x4d, 0x6c, 0x0f, 0x04, 0x66, 0x9f, 0x67, 0x7e, 0xef, - 0x33, 0xbc, 0xef, 0x2c, 0x28, 0x05, 0x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0xe8, 0x1f, 0x8d, 0x71, 0xae, 0xed, 0xf7, 0x5f, 0x7f, 0x7e, 0x5c, 0x7b, 0x62, 0x3e, - 0x46, 0x89, 0x97, 0x3c, 0xda, 0x05, 0x3f, 0x69, 0x60, 0x2b, 0xe9, 0x3a, 0xec, 0xdd, 0x54, 0x2d, - 0xc1, 0x5c, 0x3c, 0xbc, 0x85, 0x39, 0x8e, 0x87, 0xa2, 0x78, 0xbb, 0xe6, 0xce, 0x6a, 0x3c, 0xe2, - 0x50, 0x59, 0x8b, 0x97, 0xb5, 0x30, 0xda, 0x58, 0x6f, 0x5c, 0x8d, 0x0d, 0xed, 0x7a, 0x6c, 0x68, - 0x3f, 0xc6, 0x86, 0x76, 0x31, 0x31, 0x52, 0xd7, 0x13, 0x23, 0xf5, 0x6d, 0x62, 0xa4, 0x4e, 0xd1, - 0x52, 0x73, 0x5f, 0x46, 0xb0, 0xe7, 0x3d, 0x4c, 0x83, 0x39, 0x78, 0xb0, 0x84, 0x8e, 0x3a, 0xdd, - 0xc9, 0x46, 0x6f, 0x9c, 0xc3, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xb3, 0x1b, 0xc3, 0x86, 0xff, - 0x04, 0x00, 0x00, + // 686 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0x31, 0x4f, 0xdb, 0x4e, + 0x1c, 0x8d, 0x49, 0xfe, 0x01, 0x0e, 0xfd, 0x0b, 0x31, 0x2d, 0x0a, 0x21, 0xb5, 0x53, 0x53, 0x95, + 0x50, 0x84, 0x4f, 0x81, 0x8d, 0xd1, 0x40, 0x25, 0x86, 0x54, 0x91, 0xd5, 0xa1, 0x45, 0xaa, 0xd0, + 0x39, 0x3e, 0xcc, 0xa9, 0xf6, 0x9d, 0x75, 0xe7, 0xa0, 0x64, 0xed, 0xd4, 0x11, 0xa9, 0x5f, 0x80, + 0xb1, 0x73, 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e, 0xfe, 0x0d, 0xcd, 0xc4, 0x9f, 0x24, 0xe2, 0x4b, 0xc6, 0x62, 0xee, 0xdd, 0x38, + 0x3d, 0x4e, 0xad, 0xbd, 0xb3, 0x0b, 0x4d, 0x39, 0xbf, 0xd0, 0x94, 0x1f, 0x17, 0x9a, 0x72, 0x72, + 0xa9, 0x15, 0xce, 0x2f, 0xb5, 0xc2, 0xb7, 0x4b, 0xad, 0xb0, 0x0f, 0xc7, 0x82, 0xfd, 0x32, 0x69, + 0xdf, 0x3e, 0x42, 0x84, 0x8e, 0xa8, 0xfa, 0x63, 0x64, 0x49, 0xca, 0x9d, 0x72, 0xf2, 0xb5, 0xdd, + 0xfc, 0x1d, 0x00, 0x00, 0xff, 0xff, 0xc1, 0xc6, 0x47, 0x4d, 0x1b, 0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -250,6 +348,7 @@ type MsgClient interface { ToggleInflation(ctx context.Context, in *MsgToggleInflation, opts ...grpc.CallOption) (*MsgToggleInflationResponse, error) // EditInflationParams defines a method to edit the inflation params. EditInflationParams(ctx context.Context, in *MsgEditInflationParams, opts ...grpc.CallOption) (*MsgEditInflationParamsResponse, error) + Burn(ctx context.Context, in *MsgBurn, opts ...grpc.CallOption) (*MsgBurnResponse, error) } type msgClient struct { @@ -278,12 +377,22 @@ func (c *msgClient) EditInflationParams(ctx context.Context, in *MsgEditInflatio return out, nil } +func (c *msgClient) Burn(ctx context.Context, in *MsgBurn, opts ...grpc.CallOption) (*MsgBurnResponse, error) { + out := new(MsgBurnResponse) + err := c.cc.Invoke(ctx, "/nibiru.inflation.v1.Msg/Burn", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { // ToggleInflation defines a method to enable or disable inflation. ToggleInflation(context.Context, *MsgToggleInflation) (*MsgToggleInflationResponse, error) // EditInflationParams defines a method to edit the inflation params. EditInflationParams(context.Context, *MsgEditInflationParams) (*MsgEditInflationParamsResponse, error) + Burn(context.Context, *MsgBurn) (*MsgBurnResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -296,6 +405,9 @@ func (*UnimplementedMsgServer) ToggleInflation(ctx context.Context, req *MsgTogg func (*UnimplementedMsgServer) EditInflationParams(ctx context.Context, req *MsgEditInflationParams) (*MsgEditInflationParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method EditInflationParams not implemented") } +func (*UnimplementedMsgServer) Burn(ctx context.Context, req *MsgBurn) (*MsgBurnResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Burn not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -337,6 +449,24 @@ func _Msg_EditInflationParams_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } +func _Msg_Burn_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgBurn) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).Burn(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/nibiru.inflation.v1.Msg/Burn", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).Burn(ctx, req.(*MsgBurn)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "nibiru.inflation.v1.Msg", HandlerType: (*MsgServer)(nil), @@ -349,6 +479,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "EditInflationParams", Handler: _Msg_EditInflationParams_Handler, }, + { + MethodName: "Burn", + Handler: _Msg_Burn_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "nibiru/inflation/v1/tx.proto", @@ -542,6 +676,69 @@ func (m *MsgEditInflationParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } +func (m *MsgBurn) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgBurn) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgBurn) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Coin.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgBurnResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgBurnResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgBurnResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -625,6 +822,30 @@ func (m *MsgEditInflationParamsResponse) Size() (n int) { return n } +func (m *MsgBurn) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Coin.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgBurnResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1115,6 +1336,171 @@ func (m *MsgEditInflationParamsResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgBurn) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgBurn: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgBurn: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Coin", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Coin.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgBurnResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgBurnResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgBurnResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/inflation/types/tx.pb.gw.go b/x/inflation/types/tx.pb.gw.go index 0d122966c..0a75000c6 100644 --- a/x/inflation/types/tx.pb.gw.go +++ b/x/inflation/types/tx.pb.gw.go @@ -105,6 +105,42 @@ func local_request_Msg_EditInflationParams_0(ctx context.Context, marshaler runt } +var ( + filter_Msg_Burn_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Msg_Burn_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq MsgBurn + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Burn_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.Burn(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Msg_Burn_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq MsgBurn + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_Burn_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.Burn(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterMsgHandlerServer registers the http handlers for service Msg to "mux". // UnaryRPC :call MsgServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -157,6 +193,29 @@ func RegisterMsgHandlerServer(ctx context.Context, mux *runtime.ServeMux, server }) + mux.Handle("POST", pattern_Msg_Burn_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Msg_Burn_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Msg_Burn_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -238,6 +297,26 @@ func RegisterMsgHandlerClient(ctx context.Context, mux *runtime.ServeMux, client }) + mux.Handle("POST", pattern_Msg_Burn_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Msg_Burn_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Msg_Burn_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -245,10 +324,14 @@ var ( pattern_Msg_ToggleInflation_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"nibiru", "inflation", "v1", "toggle"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Msg_EditInflationParams_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"nibiru", "inflation", "edit-inflation-params"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Msg_Burn_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"nibiru", "inflation", "v1", "burn"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( forward_Msg_ToggleInflation_0 = runtime.ForwardResponseMessage forward_Msg_EditInflationParams_0 = runtime.ForwardResponseMessage + + forward_Msg_Burn_0 = runtime.ForwardResponseMessage ) From 595c976c4321927b0a12e7f129f281df58b8a61e Mon Sep 17 00:00:00 2001 From: Kevin Yang <5478483+k-yang@users.noreply.github.com> Date: Tue, 19 Mar 2024 17:20:45 +0900 Subject: [PATCH 2/4] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 57081d185..9a141025f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -64,6 +64,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [#1797](https://github.com/NibiruChain/nibiru/pull/1797) - fix(inflation): fix num skipped epoch updates logic - [#1804](https://github.com/NibiruChain/nibiru/pull/1804) - fix(inflation): update default parameters - [#1816](https://github.com/NibiruChain/nibiru/pull/1816) - fix(ibc): fix ibc transaction from wasm contract +- [#1823](https://github.com/NibiruChain/nibiru/pull/1823) - feat(inflation): add burn method #### Dapp modules: perp, spot, etc @@ -117,7 +118,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Bump `robinraju/release-downloader` from 1.8 to 1.9 ([#1783](https://github.com/NibiruChain/nibiru/pull/1783)) - Bump `codecov/codecov-action` from 3 to 4 ([#1784](https://github.com/NibiruChain/nibiru/pull/1784)) - Bump `golangci/golangci-lint-action` from 3 to 4 ([#1791](https://github.com/NibiruChain/nibiru/pull/1791)) - - Bump `github.com/prometheus/client_golang` from 1.17.0 to 1.18.0 ([#1750](https://github.com/NibiruChain/nibiru/pull/1750)) - Bump `google.golang.org/protobuf` from 1.31.0 to 1.32.0 ([#1756](https://github.com/NibiruChain/nibiru/pull/1756)) - Bump `google.golang.org/grpc` from 1.59.0 to 1.60.0 ([#1720](https://github.com/NibiruChain/nibiru/pull/1720)) From 2e99e3fee437389efd84b87dde5a3168e65f5315 Mon Sep 17 00:00:00 2001 From: Unique-Divine Date: Tue, 19 Mar 2024 14:16:33 -0500 Subject: [PATCH 3/4] chore: linter --- x/inflation/keeper/keeper_test.go | 9 +++++++-- x/inflation/keeper/msg_server_test.go | 8 +++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/x/inflation/keeper/keeper_test.go b/x/inflation/keeper/keeper_test.go index d844931ff..4100e13c8 100644 --- a/x/inflation/keeper/keeper_test.go +++ b/x/inflation/keeper/keeper_test.go @@ -33,8 +33,13 @@ func TestBurn(t *testing.T) { for _, tc := range testCases { t.Run(fmt.Sprintf("Case %s", tc.name), func(t *testing.T) { nibiruApp, ctx := testapp.NewNibiruTestAppAndContext() - nibiruApp.BankKeeper.MintCoins(ctx, types.ModuleName, sdk.NewCoins(tc.burnCoin)) - nibiruApp.BankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, tc.sender, sdk.NewCoins(tc.burnCoin)) + require.NoError(t, + nibiruApp.BankKeeper.MintCoins( + ctx, types.ModuleName, sdk.NewCoins(tc.burnCoin))) + require.NoError(t, + nibiruApp.BankKeeper.SendCoinsFromModuleToAccount( + ctx, types.ModuleName, tc.sender, sdk.NewCoins(tc.burnCoin)), + ) // Burn coins err := nibiruApp.InflationKeeper.Burn(ctx, sdk.NewCoins(tc.burnCoin), tc.sender) diff --git a/x/inflation/keeper/msg_server_test.go b/x/inflation/keeper/msg_server_test.go index aa33f939a..49cfa1620 100644 --- a/x/inflation/keeper/msg_server_test.go +++ b/x/inflation/keeper/msg_server_test.go @@ -74,8 +74,10 @@ func TestMsgEditInflationParams(t *testing.T) { func TestMsgBurn(t *testing.T) { app, ctx := testapp.NewNibiruTestAppAndContext() sender := testutil.AccAddress() - app.BankKeeper.MintCoins(ctx, types.ModuleName, sdk.NewCoins(sdk.NewCoin("unibi", sdk.NewInt(100)))) - app.BankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, sender, sdk.NewCoins(sdk.NewCoin("unibi", sdk.NewInt(100)))) + err := app.BankKeeper.MintCoins(ctx, types.ModuleName, sdk.NewCoins(sdk.NewCoin("unibi", sdk.NewInt(100)))) + require.NoError(t, err) + err = app.BankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, sender, sdk.NewCoins(sdk.NewCoin("unibi", sdk.NewInt(100)))) + require.NoError(t, err) msgServer := keeper.NewMsgServerImpl(app.InflationKeeper) @@ -84,6 +86,6 @@ func TestMsgBurn(t *testing.T) { Coin: sdk.NewCoin("unibi", sdk.NewInt(100)), } - _, err := msgServer.Burn(ctx, &msg) + _, err = msgServer.Burn(ctx, &msg) require.NoError(t, err) } From d91a509f5367c7ba94946781e24383e38990810b Mon Sep 17 00:00:00 2001 From: Unique-Divine Date: Tue, 19 Mar 2024 14:20:19 -0500 Subject: [PATCH 4/4] refactor: use coin.Validate() --- x/inflation/types/msgs.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/x/inflation/types/msgs.go b/x/inflation/types/msgs.go index 69f574799..1cb387041 100644 --- a/x/inflation/types/msgs.go +++ b/x/inflation/types/msgs.go @@ -134,17 +134,13 @@ func (m MsgBurn) ValidateBasic() error { return err } - if m.Coin.Denom == "" { - return fmt.Errorf("coin denom should not be empty") + if err := m.Coin.Validate(); err != nil { + return err } if m.Coin.Amount.IsZero() { return fmt.Errorf("coin amount should not be zero") } - if m.Coin.IsNil() { - return fmt.Errorf("coin should not be nil") - } - return nil }