Skip to content

Commit c1edb0a

Browse files
authored
Refactor proto (#209)
* Refactor proto * Fix lint
1 parent ea9badf commit c1edb0a

File tree

5 files changed

+383
-307
lines changed

5 files changed

+383
-307
lines changed
+84-15
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,134 @@
11
syntax = "proto3";
22
package feeabstraction.feeabs.v1beta1;
33

4+
import "amino/amino.proto";
45
import "gogoproto/gogo.proto";
56
import "cosmos/msg/v1/msg.proto";
67
import "cosmos/base/v1beta1/coin.proto";
78
import "cosmos_proto/cosmos.proto";
89
import "feeabstraction/feeabs/v1beta1/params.proto";
9-
import "amino/amino.proto";
10+
import "feeabstraction/feeabs/v1beta1/proposal.proto";
1011

1112
option go_package = "github.com/osmosis-labs/fee-abstraction/v8/x/feeabs/types";
1213

14+
// Msg defines the wasm Msg service.
1315
service Msg {
1416
option (cosmos.msg.v1.service) = true;
1517

18+
// SendQueryIbcDenomTWAP sends a twap query to osmosis
1619
rpc SendQueryIbcDenomTWAP(MsgSendQueryIbcDenomTWAP)
1720
returns (MsgSendQueryIbcDenomTWAPResponse);
21+
22+
// SwapCrossChain submits a swap cross chain request.
1823
rpc SwapCrossChain(MsgSwapCrossChain) returns (MsgSwapCrossChainResponse);
24+
25+
// FundFeeAbsModuleAccount funds to feeabs module account.
1926
rpc FundFeeAbsModuleAccount(MsgFundFeeAbsModuleAccount)
2027
returns (MsgFundFeeAbsModuleAccountResponse);
21-
22-
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse) {
23-
}
28+
29+
// UpdateParams defines a governance operation for updating the x/feeabs
30+
// module parameters. The authority is defined in the keeper.
31+
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse) {}
32+
33+
rpc AddHostZone(MsgAddHostZone) returns (MsgAddHostZoneResponse) {}
34+
rpc UpdateHostZone(MsgUpdateHostZone) returns (MsgUpdateHostZoneResponse) {}
35+
rpc RemoveHostZone(MsgRemoveHostZone) returns (MsgRemoveHostZoneResponse) {}
2436
}
2537

38+
// MsgFundFeeAbsModuleAccount
2639
message MsgFundFeeAbsModuleAccount {
27-
string from_address = 1;
40+
option (cosmos.msg.v1.signer) = "sender";
41+
42+
// sender is the that actor that signed the messages
43+
string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
2844
repeated cosmos.base.v1beta1.Coin amount = 2 [
2945
(gogoproto.nullable) = false,
3046
(gogoproto.moretags) = "yaml:\"amount\"",
3147
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
3248
];
3349
}
3450

51+
// MsgFundFeeAbsModuleAccountResponse
3552
message MsgFundFeeAbsModuleAccountResponse {}
3653

37-
message MsgSendQueryIbcDenomTWAP { string from_address = 1; }
54+
// MsgSendQueryIbcDenomTWAP
55+
message MsgSendQueryIbcDenomTWAP {
56+
option (cosmos.msg.v1.signer) = "sender";
3857

58+
// Sender is the that actor that signed the messages
59+
string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
60+
}
61+
62+
// MsgSendQueryIbcDenomTWAPResponse
3963
message MsgSendQueryIbcDenomTWAPResponse {}
4064

65+
// MsgSwapCrossChain
4166
message MsgSwapCrossChain {
42-
string from_address = 1;
67+
option (cosmos.msg.v1.signer) = "sender";
68+
69+
// Sender is the that actor that signed the messages
70+
string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
4371
string ibc_denom = 2;
4472
}
73+
74+
// MsgSwapCrossChainResponse
4575
message MsgSwapCrossChainResponse {}
4676

4777
// MsgUpdateParams is the Msg/UpdateParams request type.
4878
message MsgUpdateParams {
49-
option (cosmos.msg.v1.signer) = "authority";
50-
51-
// authority is the address that controls the module (defaults to x/gov unless overwritten).
52-
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
53-
option (amino.name) = "cosmos-sdk/x/bank/MsgUpdateParams";
79+
option (cosmos.msg.v1.signer) = "authority";
5480

55-
// params defines the x/bank parameters to update.
81+
// authority is the address of the governance account.
82+
string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
83+
// params defines the x/feeabs parameters to update.
5684
//
5785
// NOTE: All parameters must be supplied.
58-
Params params = 2 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
86+
Params params = 2
87+
[ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ];
5988
}
6089

6190
// MsgUpdateParamsResponse defines the response structure for executing a
6291
// MsgUpdateParams message.
63-
message MsgUpdateParamsResponse {
92+
message MsgUpdateParamsResponse {}
93+
94+
// MsgAddHostZone is the Msg/AddHostZone request type.
95+
message MsgAddHostZone {
96+
option (cosmos.msg.v1.signer) = "authority";
97+
98+
// authority is the address of the governance account.
99+
string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
100+
101+
// the host chain config
102+
HostChainFeeAbsConfig host_chain_config = 2
103+
[ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ];
104+
}
105+
106+
// MsgAddHostZoneResponse
107+
message MsgAddHostZoneResponse {}
108+
109+
// MsgUpdateHostZone is the Msg/UpdateHostZone request type.
110+
message MsgUpdateHostZone {
111+
option (cosmos.msg.v1.signer) = "authority";
112+
113+
// authority is the address of the governance account.
114+
string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
115+
116+
// the host chain config
117+
HostChainFeeAbsConfig host_chain_config = 2
118+
[ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ];
119+
}
120+
121+
// MsgUpdateHostZoneResponse
122+
message MsgUpdateHostZoneResponse {}
123+
124+
// MsgRemoveHostZone is the Msg/RemoveHostZone request type.
125+
message MsgRemoveHostZone {
126+
option (cosmos.msg.v1.signer) = "authority";
127+
128+
// authority is the address of the governance account.
129+
string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
130+
string ibc_denom = 2;
64131
}
65132

133+
// MsgRemoveHostZoneResponse
134+
message MsgRemoveHostZoneResponse {}

tests/interchaintest/query_osmosis_twap_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ func AddHostZoneProposal(t *testing.T, ctx context.Context, feeabs *cosmos.Cosmo
179179
require.NotEmpty(t, govAddr)
180180

181181
addHostZoneMsg := feeabstypes.MsgAddHostZone{
182-
HostChainConfig: &feeabstypes.HostChainFeeAbsConfig{
182+
HostChainConfig: feeabstypes.HostChainFeeAbsConfig{
183183
IbcDenom: fakeIBCDenom,
184184
OsmosisPoolTokenDenomIn: "uosmo",
185185
PoolId: 1,

x/feeabs/keeper/msg_server.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ var _ types.MsgServer = msgServer{}
2626

2727
func (k Keeper) SendQueryIbcDenomTWAP(goCtx context.Context, msg *types.MsgSendQueryIbcDenomTWAP) (*types.MsgSendQueryIbcDenomTWAPResponse, error) {
2828
ctx := sdk.UnwrapSDKContext(goCtx)
29-
_, err := sdk.AccAddressFromBech32(msg.FromAddress)
29+
_, err := sdk.AccAddressFromBech32(msg.Sender)
3030
if err != nil {
3131
return nil, err
3232
}
@@ -41,7 +41,7 @@ func (k Keeper) SendQueryIbcDenomTWAP(goCtx context.Context, msg *types.MsgSendQ
4141
func (k Keeper) SwapCrossChain(goCtx context.Context, msg *types.MsgSwapCrossChain) (*types.MsgSwapCrossChainResponse, error) {
4242
ctx := sdk.UnwrapSDKContext(goCtx)
4343

44-
_, err := sdk.AccAddressFromBech32(msg.FromAddress)
44+
_, err := sdk.AccAddressFromBech32(msg.Sender)
4545
if err != nil {
4646
return nil, err
4747
}
@@ -74,7 +74,7 @@ func (k Keeper) FundFeeAbsModuleAccount(
7474
// Unwrap context
7575
ctx := sdk.UnwrapSDKContext(goCtx)
7676
// Check sender address
77-
sender, err := sdk.AccAddressFromBech32(msg.FromAddress)
77+
sender, err := sdk.AccAddressFromBech32(msg.Sender)
7878
if err != nil {
7979
return nil, err
8080
}
@@ -111,7 +111,7 @@ func (k msgServer) AddHostZone(ctx context.Context, req *types.MsgAddHostZone) (
111111
return nil, errors.Wrapf(types.ErrDuplicateHostZoneConfig, "duplicate host ibc denom")
112112
}
113113

114-
if err := k.SetHostZoneConfig(sdkContext, *req.HostChainConfig); err != nil {
114+
if err := k.SetHostZoneConfig(sdkContext, req.HostChainConfig); err != nil {
115115
return nil, err
116116
}
117117

@@ -137,7 +137,7 @@ func (k msgServer) UpdateHostZone(ctx context.Context, req *types.MsgUpdateHostZ
137137
return nil, errors.Wrapf(types.ErrHostZoneConfigNotFound, "host zone config not found")
138138
}
139139

140-
if err := k.SetHostZoneConfig(sdkContext, *req.HostChainConfig); err != nil {
140+
if err := k.SetHostZoneConfig(sdkContext, req.HostChainConfig); err != nil {
141141
return nil, err
142142
}
143143

x/feeabs/types/msg.go

+14-14
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func (m MsgSendQueryIbcDenomTWAP) Type() string { return sdk.MsgTypeURL(&m) }
1515

1616
// GetSigners returns the expected signers for a MsgMintAndAllocateExp .
1717
func (m MsgSendQueryIbcDenomTWAP) GetSigners() []sdk.AccAddress {
18-
daoAccount, err := sdk.AccAddressFromBech32(m.FromAddress)
18+
daoAccount, err := sdk.AccAddressFromBech32(m.Sender)
1919
if err != nil {
2020
panic(err)
2121
}
@@ -29,16 +29,16 @@ func (m MsgSendQueryIbcDenomTWAP) GetSignBytes() []byte {
2929

3030
// ValidateBasic does a sanity check on the provided data.
3131
func (m MsgSendQueryIbcDenomTWAP) ValidateBasic() error {
32-
_, err := sdk.AccAddressFromBech32(m.FromAddress)
32+
_, err := sdk.AccAddressFromBech32(m.Sender)
3333
if err != nil {
3434
return err
3535
}
3636
return nil
3737
}
3838

39-
func NewMsgSendQueryIbcDenomTWAP(fromAddr sdk.AccAddress) *MsgSendQueryIbcDenomTWAP {
39+
func NewMsgSendQueryIbcDenomTWAP(sender sdk.AccAddress) *MsgSendQueryIbcDenomTWAP {
4040
return &MsgSendQueryIbcDenomTWAP{
41-
FromAddress: fromAddr.String(),
41+
Sender: sender.String(),
4242
}
4343
}
4444

@@ -52,7 +52,7 @@ func (m MsgSwapCrossChain) Type() string { return sdk.MsgTypeURL(&m) }
5252

5353
// GetSigners returns the expected signers for a MsgMintAndAllocateExp .
5454
func (m MsgSwapCrossChain) GetSigners() []sdk.AccAddress {
55-
daoAccount, err := sdk.AccAddressFromBech32(m.FromAddress)
55+
daoAccount, err := sdk.AccAddressFromBech32(m.Sender)
5656
if err != nil {
5757
panic(err)
5858
}
@@ -66,17 +66,17 @@ func (m MsgSwapCrossChain) GetSignBytes() []byte {
6666

6767
// ValidateBasic does a sanity check on the provided data.
6868
func (m MsgSwapCrossChain) ValidateBasic() error {
69-
_, err := sdk.AccAddressFromBech32(m.FromAddress)
69+
_, err := sdk.AccAddressFromBech32(m.Sender)
7070
if err != nil {
7171
return err
7272
}
7373
return nil
7474
}
7575

76-
func NewMsgSwapCrossChain(fromAddr sdk.AccAddress, ibcDenom string) *MsgSwapCrossChain {
76+
func NewMsgSwapCrossChain(sender sdk.AccAddress, ibcDenom string) *MsgSwapCrossChain {
7777
return &MsgSwapCrossChain{
78-
FromAddress: fromAddr.String(),
79-
IbcDenom: ibcDenom,
78+
Sender: sender.String(),
79+
IbcDenom: ibcDenom,
8080
}
8181
}
8282

@@ -90,7 +90,7 @@ func (m MsgFundFeeAbsModuleAccount) Type() string { return sdk.MsgTypeURL(&m) }
9090

9191
// GetSigners returns the expected signers for a MsgMintAndAllocateExp .
9292
func (m MsgFundFeeAbsModuleAccount) GetSigners() []sdk.AccAddress {
93-
daoAccount, err := sdk.AccAddressFromBech32(m.FromAddress)
93+
daoAccount, err := sdk.AccAddressFromBech32(m.Sender)
9494
if err != nil {
9595
panic(err)
9696
}
@@ -104,16 +104,16 @@ func (m MsgFundFeeAbsModuleAccount) GetSignBytes() []byte {
104104

105105
// ValidateBasic does a sanity check on the provided data.
106106
func (m MsgFundFeeAbsModuleAccount) ValidateBasic() error {
107-
_, err := sdk.AccAddressFromBech32(m.FromAddress)
107+
_, err := sdk.AccAddressFromBech32(m.Sender)
108108
if err != nil {
109109
return err
110110
}
111111
return nil
112112
}
113113

114-
func NewMsgFundFeeAbsModuleAccount(fromAddr sdk.AccAddress, amount sdk.Coins) *MsgFundFeeAbsModuleAccount {
114+
func NewMsgFundFeeAbsModuleAccount(sender sdk.AccAddress, amount sdk.Coins) *MsgFundFeeAbsModuleAccount {
115115
return &MsgFundFeeAbsModuleAccount{
116-
FromAddress: fromAddr.String(),
117-
Amount: amount,
116+
Sender: sender.String(),
117+
Amount: amount,
118118
}
119119
}

0 commit comments

Comments
 (0)