Skip to content

Commit c696fa1

Browse files
committed
add lending params update msg
1 parent ab4f78b commit c696fa1

File tree

8 files changed

+1811
-306
lines changed

8 files changed

+1811
-306
lines changed

api/side/lending/tx.pulsar.go

Lines changed: 1205 additions & 224 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/side/lending/tx_grpc.pb.go

Lines changed: 45 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/side/lending/tx.proto

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import "gogoproto/gogo.proto";
55
import "cosmos/msg/v1/msg.proto";
66
import "cosmos/base/v1beta1/coin.proto";
77
import "side/lending/lending.proto";
8+
import "side/lending/params.proto";
89

910
option go_package = "github.com/sideprotocol/side/x/lending/types";
1011

@@ -22,6 +23,12 @@ service Msg {
2223
rpc SubmitRepaymentAdaptorSignature(MsgSubmitRepaymentAdaptorSignature) returns (MsgSubmitRepaymentAdaptorSignatureResponse);
2324
rpc SubmitLiquidationCetSignatures(MsgSubmitLiquidationCetSignatures) returns (MsgSubmitLiquidationCetSignaturesResponse);
2425
rpc Close(MsgClose) returns (MsgCloseResponse);
26+
27+
// UpdateParams defines a governance operation for updating the x/dlc module
28+
// parameters. The authority defaults to the x/gov module account.
29+
//
30+
// Since: cosmos-sdk 0.47
31+
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse);
2532
}
2633

2734
message MsgCreatePool {
@@ -145,3 +152,23 @@ message MsgClose {
145152
}
146153

147154
message MsgCloseResponse{}
155+
156+
// MsgUpdateParams is the Msg/UpdateParams request type.
157+
//
158+
// Since: cosmos-sdk 0.47
159+
message MsgUpdateParams {
160+
option (cosmos.msg.v1.signer) = "authority";
161+
162+
// authority is the address that controls the module (defaults to x/gov unless overwritten).
163+
string authority = 1;
164+
165+
// params defines the x/dlc parameters to be updated.
166+
//
167+
// NOTE: All parameters must be supplied.
168+
Params params = 2 [(gogoproto.nullable) = false];
169+
}
170+
171+
// MsgUpdateParamsResponse defines the Msg/UpdateParams response type.
172+
//
173+
// Since: cosmos-sdk 0.47
174+
message MsgUpdateParamsResponse {}

x/lending/keeper/msg_server.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package keeper
2+
3+
import (
4+
"context"
5+
6+
errorsmod "cosmossdk.io/errors"
7+
sdk "github.com/cosmos/cosmos-sdk/types"
8+
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
9+
10+
"github.com/sideprotocol/side/x/lending/types"
11+
)
12+
13+
type msgServer struct {
14+
Keeper
15+
}
16+
17+
// UpdateParams updates the module params.
18+
func (m msgServer) UpdateParams(goCtx context.Context, msg *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) {
19+
if m.authority != msg.Authority {
20+
return nil, errorsmod.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", m.authority, msg.Authority)
21+
}
22+
23+
if err := msg.ValidateBasic(); err != nil {
24+
return nil, err
25+
}
26+
27+
ctx := sdk.UnwrapSDKContext(goCtx)
28+
m.SetParams(ctx, msg.Params)
29+
30+
return &types.MsgUpdateParamsResponse{}, nil
31+
}
32+
33+
// NewMsgServerImpl returns an implementation of the MsgServer interface
34+
// for the provided Keeper.
35+
func NewMsgServerImpl(keeper Keeper) types.MsgServer {
36+
return &msgServer{Keeper: keeper}
37+
}
38+
39+
var _ types.MsgServer = msgServer{}

x/lending/keeper/msg_server_loan.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ import (
1818
"github.com/sideprotocol/side/x/lending/types"
1919
)
2020

21-
type msgServer struct {
22-
Keeper
23-
}
24-
2521
// CreateLoan implements types.MsgServer.
2622
func (m msgServer) Apply(goCtx context.Context, msg *types.MsgApply) (*types.MsgApplyResponse, error) {
2723
if err := msg.ValidateBasic(); err != nil {
@@ -461,11 +457,3 @@ func (m msgServer) Close(goCtx context.Context, msg *types.MsgClose) (*types.Msg
461457

462458
return &types.MsgCloseResponse{}, nil
463459
}
464-
465-
// NewMsgServerImpl returns an implementation of the MsgServer interface
466-
// for the provided Keeper.
467-
func NewMsgServerImpl(keeper Keeper) types.MsgServer {
468-
return &msgServer{Keeper: keeper}
469-
}
470-
471-
var _ types.MsgServer = msgServer{}

x/lending/types/codec.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ func RegisterCodec(cdc *codec.LegacyAmino) {
1818
cdc.RegisterConcrete(&MsgClose{}, "lending/MsgClose", nil)
1919
cdc.RegisterConcrete(&MsgSubmitRepaymentAdaptorSignature{}, "lending/MsgSubmitRepaymentAdaptorSignature", nil)
2020
cdc.RegisterConcrete(&MsgSubmitLiquidationCetSignatures{}, "lending/MsgSubmitLiquidationCetSignatures", nil)
21+
cdc.RegisterConcrete(&MsgUpdateParams{}, "lending/MsgUpdateParams", nil)
22+
2123
// this line is used by starport scaffolding # 2
2224
}
2325

@@ -32,6 +34,7 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
3234
registry.RegisterImplementations((*sdk.Msg)(nil), &MsgClose{})
3335
registry.RegisterImplementations((*sdk.Msg)(nil), &MsgSubmitRepaymentAdaptorSignature{})
3436
registry.RegisterImplementations((*sdk.Msg)(nil), &MsgSubmitLiquidationCetSignatures{})
37+
registry.RegisterImplementations((*sdk.Msg)(nil), &MsgUpdateParams{})
3538

3639
// this line is used by starport scaffolding # 3
3740

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package types
2+
3+
import (
4+
errorsmod "cosmossdk.io/errors"
5+
sdk "github.com/cosmos/cosmos-sdk/types"
6+
)
7+
8+
var _ sdk.Msg = &MsgUpdateParams{}
9+
10+
// ValidateBasic performs basic MsgUpdateParams message validation.
11+
func (m *MsgUpdateParams) ValidateBasic() error {
12+
if _, err := sdk.AccAddressFromBech32(m.Authority); err != nil {
13+
return errorsmod.Wrap(err, "invalid authority address")
14+
}
15+
16+
if err := m.Params.Validate(); err != nil {
17+
return err
18+
}
19+
20+
return nil
21+
}

0 commit comments

Comments
 (0)