Skip to content

Commit f7a77b2

Browse files
authored
feat: add to fund reward pool (#143)
1 parent ac13f0f commit f7a77b2

File tree

9 files changed

+148
-150
lines changed

9 files changed

+148
-150
lines changed

docs/proto/proto-docs.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
- [Query](#xpla.reward.v1beta1.Query)
2020

2121
- [xpla/reward/v1beta1/tx.proto](#xpla/reward/v1beta1/tx.proto)
22-
- [MsgFundFeeCollector](#xpla.reward.v1beta1.MsgFundFeeCollector)
23-
- [MsgFundFeeCollectorResponse](#xpla.reward.v1beta1.MsgFundFeeCollectorResponse)
22+
- [MsgFundRewardPool](#xpla.reward.v1beta1.MsgFundRewardPool)
23+
- [MsgFundRewardPoolResponse](#xpla.reward.v1beta1.MsgFundRewardPoolResponse)
2424
- [MsgUpdateParams](#xpla.reward.v1beta1.MsgUpdateParams)
2525
- [MsgUpdateParamsResponse](#xpla.reward.v1beta1.MsgUpdateParamsResponse)
2626

@@ -200,11 +200,11 @@ Query defines the gRPC querier service for reward module.
200200

201201

202202

203-
<a name="xpla.reward.v1beta1.MsgFundFeeCollector"></a>
203+
<a name="xpla.reward.v1beta1.MsgFundRewardPool"></a>
204204

205-
### MsgFundFeeCollector
206-
MsgFundFeeCollector allows an account to directly
207-
fund the fee collector.
205+
### MsgFundRewardPool
206+
MsgFundRewardPool allows an account to directly
207+
fund the reward pool.
208208

209209

210210
| Field | Type | Label | Description |
@@ -217,10 +217,10 @@ fund the fee collector.
217217

218218

219219

220-
<a name="xpla.reward.v1beta1.MsgFundFeeCollectorResponse"></a>
220+
<a name="xpla.reward.v1beta1.MsgFundRewardPoolResponse"></a>
221221

222-
### MsgFundFeeCollectorResponse
223-
MsgFundFeeCollectorResponse defines the Msg/FundFeeCollector response type.
222+
### MsgFundRewardPoolResponse
223+
MsgFundRewardPoolResponse defines the Msg/FundRewardPool response type.
224224

225225

226226

@@ -269,7 +269,7 @@ Msg defines the reawrd Msg service.
269269

270270
| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint |
271271
| ----------- | ------------ | ------------- | ------------| ------- | -------- |
272-
| `FundFeeCollector` | [MsgFundFeeCollector](#xpla.reward.v1beta1.MsgFundFeeCollector) | [MsgFundFeeCollectorResponse](#xpla.reward.v1beta1.MsgFundFeeCollectorResponse) | FundFeeCollector defines a method to allow an account to directly fund the fee collector. | |
272+
| `FundRewardPool` | [MsgFundRewardPool](#xpla.reward.v1beta1.MsgFundRewardPool) | [MsgFundRewardPoolResponse](#xpla.reward.v1beta1.MsgFundRewardPoolResponse) | MsgFundRewardPool defines a method to allow an account to directly fund the reward pool. | |
273273
| `UpdateParams` | [MsgUpdateParams](#xpla.reward.v1beta1.MsgUpdateParams) | [MsgUpdateParamsResponse](#xpla.reward.v1beta1.MsgUpdateParamsResponse) | UpdateParams defined a governance operation for updating the x/reward module parameters. The authority is hard-coded to the Cosmos SDK x/gov module account | |
274274

275275
<!-- end services -->

proto/xpla/reward/v1beta1/tx.proto

+9-10
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,20 @@ import "amino/amino.proto";
1212

1313
// Msg defines the reawrd Msg service.
1414
service Msg {
15-
// FundFeeCollector defines a method to allow an account to directly
16-
// fund the fee collector.
17-
rpc FundFeeCollector(MsgFundFeeCollector)
18-
returns (MsgFundFeeCollectorResponse);
15+
// MsgFundRewardPool defines a method to allow an account to directly
16+
// fund the reward pool.
17+
rpc FundRewardPool(MsgFundRewardPool) returns (MsgFundRewardPoolResponse);
1918

2019
// UpdateParams defined a governance operation for updating the x/reward
2120
// module parameters. The authority is hard-coded to the Cosmos SDK x/gov
2221
// module account
2322
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse);
2423
}
2524

26-
// MsgFundFeeCollector allows an account to directly
27-
// fund the fee collector.
28-
message MsgFundFeeCollector {
29-
option (amino.name) = "xpladev/MsgFundFeeCollector";
25+
// MsgFundRewardPool allows an account to directly
26+
// fund the reward pool.
27+
message MsgFundRewardPool {
28+
option (amino.name) = "xpladev/MsgFundRewardPool";
3029
option (gogoproto.equal) = false;
3130
option (gogoproto.goproto_getters) = false;
3231

@@ -37,8 +36,8 @@ message MsgFundFeeCollector {
3736
string depositor = 2;
3837
}
3938

40-
// MsgFundFeeCollectorResponse defines the Msg/FundFeeCollector response type.
41-
message MsgFundFeeCollectorResponse {}
39+
// MsgFundRewardPoolResponse defines the Msg/FundRewardPool response type.
40+
message MsgFundRewardPoolResponse {}
4241

4342
// MsgUpdateParams is the Msg/UpdateParams request type for reward parameters.
4443
// Since: cosmos-sdk 0.47

x/reward/client/cli/tx.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,24 @@ func NewTxCmd() *cobra.Command {
3030
}
3131

3232
distTxCmd.AddCommand(
33-
NewFundFeeCollectorCmd(),
33+
NewFundRewardPoolCmd(),
3434
)
3535

3636
return distTxCmd
3737
}
3838

3939
type newGenerateOrBroadcastFunc func(client.Context, *pflag.FlagSet, ...sdk.Msg) error
4040

41-
func NewFundFeeCollectorCmd() *cobra.Command {
41+
func NewFundRewardPoolCmd() *cobra.Command {
4242
cmd := &cobra.Command{
43-
Use: "fund-fee-collector [amount]",
43+
Use: "fund-reward-pool [amount]",
4444
Args: cobra.ExactArgs(1),
45-
Short: "Funds the fee collector with the specified amount",
45+
Short: "Funds the reward pool with the specified amount",
4646
Long: strings.TrimSpace(
47-
fmt.Sprintf(`Funds the fee collector with the specified amount
47+
fmt.Sprintf(`Funds the reward pool with the specified amount
4848
4949
Example:
50-
$ %s tx reward fund-fee-collector 100axpla --from mykey
50+
$ %s tx reward fund-reward-pool 100axpla --from mykey
5151
`,
5252
version.AppName,
5353
),
@@ -63,7 +63,7 @@ $ %s tx reward fund-fee-collector 100axpla --from mykey
6363
return err
6464
}
6565

66-
msg := types.NewMsgFundFeeCollector(amount, depositorAddr)
66+
msg := types.NewMsgFundRewardPool(amount, depositorAddr)
6767

6868
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
6969
},

x/reward/keeper/keeper.go

+4-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"github.com/cosmos/cosmos-sdk/codec"
99
storetypes "github.com/cosmos/cosmos-sdk/store/types"
1010
sdk "github.com/cosmos/cosmos-sdk/types"
11-
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
1211

1312
"github.com/xpladev/xpla/x/reward/types"
1413
)
@@ -59,11 +58,11 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger {
5958
return ctx.Logger().With("module", "x/"+types.ModuleName)
6059
}
6160

62-
// FundFeeCollector allows an account to directly fund the fee collector fund.
63-
// The amount is added to the fee collector account
61+
// FundRewardPool allows an account to directly fund the reward pool fund.
62+
// The amount is added to the reward pool account
6463
// An error is returned if the amount cannot be sent to the module account.
65-
func (k Keeper) FundFeeCollector(ctx sdk.Context, amount sdk.Coins, sender sdk.AccAddress) error {
66-
if err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, sender, authtypes.FeeCollectorName, amount); err != nil {
64+
func (k Keeper) FundRewardPool(ctx sdk.Context, amount sdk.Coins, sender sdk.AccAddress) error {
65+
if err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, sender, types.ModuleName, amount); err != nil {
6766
return err
6867
}
6968

x/reward/keeper/msg_server.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ func NewMsgServerImpl(keeper Keeper) types.MsgServer {
2121

2222
var _ types.MsgServer = msgServer{}
2323

24-
func (k msgServer) FundFeeCollector(goCtx context.Context, msg *types.MsgFundFeeCollector) (*types.MsgFundFeeCollectorResponse, error) {
24+
func (k msgServer) FundRewardPool(goCtx context.Context, msg *types.MsgFundRewardPool) (*types.MsgFundRewardPoolResponse, error) {
2525
ctx := sdk.UnwrapSDKContext(goCtx)
2626

2727
depositer, err := sdk.AccAddressFromBech32(msg.Depositor)
2828
if err != nil {
2929
return nil, err
3030
}
3131

32-
err = k.Keeper.FundFeeCollector(ctx, msg.Amount, depositer)
32+
err = k.Keeper.FundRewardPool(ctx, msg.Amount, depositer)
3333
if err != nil {
3434
return nil, err
3535
}
@@ -42,7 +42,7 @@ func (k msgServer) FundFeeCollector(goCtx context.Context, msg *types.MsgFundFee
4242
),
4343
)
4444

45-
return &types.MsgFundFeeCollectorResponse{}, nil
45+
return &types.MsgFundRewardPoolResponse{}, nil
4646
}
4747

4848
// UpdateParams implements the gRPC MsgServer interface. After a successful governance vote

x/reward/types/codec.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ import (
99
)
1010

1111
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
12-
cdc.RegisterConcrete(&MsgFundFeeCollector{}, "xpladev/MsgFundFeeCollector", nil)
12+
cdc.RegisterConcrete(&MsgFundRewardPool{}, "xpladev/MsgFundRewardPool", nil)
1313
cdc.RegisterConcrete(&MsgUpdateParams{}, "xpladev/reward/MsgUpdateParams", nil)
1414
}
1515

1616
func RegisterInterfaces(registry types.InterfaceRegistry) {
1717
registry.RegisterImplementations(
1818
(*sdk.Msg)(nil),
19-
&MsgFundFeeCollector{},
19+
&MsgFundRewardPool{},
2020
&MsgUpdateParams{},
2121
)
2222

x/reward/types/msg.go

+14-14
Original file line numberDiff line numberDiff line change
@@ -6,44 +6,44 @@ import (
66
)
77

88
const (
9-
TypeMsgFundFeeCollector = "fund_fee_collector"
10-
TypeMsgUpdateParams = "update_params"
9+
TypeMsgFundRewardPool = "fund_reward_pool"
10+
TypeMsgUpdateParams = "update_params"
1111
)
1212

13-
// NewMsgFundFeeCollector returns a new MsgFundFeeCollector with a sender and
13+
// NewMsgFundRewardPool returns a new MsgFundRewardPool with a sender and
1414
// a funding amount.
15-
func NewMsgFundFeeCollector(amount sdk.Coins, depositor sdk.AccAddress) *MsgFundFeeCollector {
16-
return &MsgFundFeeCollector{
15+
func NewMsgFundRewardPool(amount sdk.Coins, depositor sdk.AccAddress) *MsgFundRewardPool {
16+
return &MsgFundRewardPool{
1717
Amount: amount,
1818
Depositor: depositor.String(),
1919
}
2020
}
2121

22-
// Route returns the MsgFundFeeCollector message route.
23-
func (msg MsgFundFeeCollector) Route() string { return ModuleName }
22+
// Route returns the MsgFundRewardPool message route.
23+
func (msg MsgFundRewardPool) Route() string { return ModuleName }
2424

25-
// Type returns the MsgFundFeeCollector message type.
26-
func (msg MsgFundFeeCollector) Type() string { return TypeMsgFundFeeCollector }
25+
// Type returns the MsgFundRewardPool message type.
26+
func (msg MsgFundRewardPool) Type() string { return TypeMsgFundRewardPool }
2727

2828
// GetSigners returns the signer addresses that are expected to sign the result
2929
// of GetSignBytes.
30-
func (msg MsgFundFeeCollector) GetSigners() []sdk.AccAddress {
30+
func (msg MsgFundRewardPool) GetSigners() []sdk.AccAddress {
3131
depoAddr, err := sdk.AccAddressFromBech32(msg.Depositor)
3232
if err != nil {
3333
panic(err)
3434
}
3535
return []sdk.AccAddress{depoAddr}
3636
}
3737

38-
// GetSignBytes returns the raw bytes for a MsgFundFeeCollector message that
38+
// GetSignBytes returns the raw bytes for a MsgFundRewardPool message that
3939
// the expected signer needs to sign.
40-
func (msg MsgFundFeeCollector) GetSignBytes() []byte {
40+
func (msg MsgFundRewardPool) GetSignBytes() []byte {
4141
bz := ModuleCdc.MustMarshalJSON(&msg)
4242
return sdk.MustSortJSON(bz)
4343
}
4444

45-
// ValidateBasic performs basic MsgFundFeeCollector message validation.
46-
func (msg MsgFundFeeCollector) ValidateBasic() error {
45+
// ValidateBasic performs basic MsgFundRewardPool message validation.
46+
func (msg MsgFundRewardPool) ValidateBasic() error {
4747
if !msg.Amount.IsValid() {
4848
return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, msg.Amount.String())
4949
}

x/reward/types/msg_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"github.com/xpladev/xpla/x/reward/types"
1111
)
1212

13-
func TestMsgFundFeeCollector(t *testing.T) {
13+
func TestMsgFundRewardPool(t *testing.T) {
1414
tests := []struct {
1515
amount sdk.Coins
1616
depositorAddr sdk.AccAddress
@@ -22,7 +22,7 @@ func TestMsgFundFeeCollector(t *testing.T) {
2222
}
2323

2424
for i, tc := range tests {
25-
msg := types.NewMsgFundFeeCollector(tc.amount, tc.depositorAddr)
25+
msg := types.NewMsgFundRewardPool(tc.amount, tc.depositorAddr)
2626
if tc.expectPass {
2727
require.Nil(t, msg.ValidateBasic(), "test index: %v", i)
2828
} else {

0 commit comments

Comments
 (0)