Skip to content

Commit

Permalink
Refactor proto (#209)
Browse files Browse the repository at this point in the history
* Refactor proto

* Fix lint
  • Loading branch information
tnv1 authored Jun 15, 2024
1 parent ea9badf commit c1edb0a
Show file tree
Hide file tree
Showing 5 changed files with 383 additions and 307 deletions.
99 changes: 84 additions & 15 deletions proto/feeabstraction/feeabs/v1beta1/tx.proto
Original file line number Diff line number Diff line change
@@ -1,65 +1,134 @@
syntax = "proto3";
package feeabstraction.feeabs.v1beta1;

import "amino/amino.proto";
import "gogoproto/gogo.proto";
import "cosmos/msg/v1/msg.proto";
import "cosmos/base/v1beta1/coin.proto";
import "cosmos_proto/cosmos.proto";
import "feeabstraction/feeabs/v1beta1/params.proto";
import "amino/amino.proto";
import "feeabstraction/feeabs/v1beta1/proposal.proto";

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

// Msg defines the wasm Msg service.
service Msg {
option (cosmos.msg.v1.service) = true;

// SendQueryIbcDenomTWAP sends a twap query to osmosis
rpc SendQueryIbcDenomTWAP(MsgSendQueryIbcDenomTWAP)
returns (MsgSendQueryIbcDenomTWAPResponse);

// SwapCrossChain submits a swap cross chain request.
rpc SwapCrossChain(MsgSwapCrossChain) returns (MsgSwapCrossChainResponse);

// FundFeeAbsModuleAccount funds to feeabs module account.
rpc FundFeeAbsModuleAccount(MsgFundFeeAbsModuleAccount)
returns (MsgFundFeeAbsModuleAccountResponse);

rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse) {
}

// UpdateParams defines a governance operation for updating the x/feeabs
// module parameters. The authority is defined in the keeper.
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse) {}

rpc AddHostZone(MsgAddHostZone) returns (MsgAddHostZoneResponse) {}
rpc UpdateHostZone(MsgUpdateHostZone) returns (MsgUpdateHostZoneResponse) {}
rpc RemoveHostZone(MsgRemoveHostZone) returns (MsgRemoveHostZoneResponse) {}
}

// MsgFundFeeAbsModuleAccount
message MsgFundFeeAbsModuleAccount {
string from_address = 1;
option (cosmos.msg.v1.signer) = "sender";

// sender is the that actor that signed the messages
string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
repeated cosmos.base.v1beta1.Coin amount = 2 [
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"amount\"",
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}

// MsgFundFeeAbsModuleAccountResponse
message MsgFundFeeAbsModuleAccountResponse {}

message MsgSendQueryIbcDenomTWAP { string from_address = 1; }
// MsgSendQueryIbcDenomTWAP
message MsgSendQueryIbcDenomTWAP {
option (cosmos.msg.v1.signer) = "sender";

// Sender is the that actor that signed the messages
string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
}

// MsgSendQueryIbcDenomTWAPResponse
message MsgSendQueryIbcDenomTWAPResponse {}

// MsgSwapCrossChain
message MsgSwapCrossChain {
string from_address = 1;
option (cosmos.msg.v1.signer) = "sender";

// Sender is the that actor that signed the messages
string sender = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
string ibc_denom = 2;
}

// MsgSwapCrossChainResponse
message MsgSwapCrossChainResponse {}

// MsgUpdateParams is the Msg/UpdateParams request type.
message MsgUpdateParams {
option (cosmos.msg.v1.signer) = "authority";

// authority is the address that controls the module (defaults to x/gov unless overwritten).
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
option (amino.name) = "cosmos-sdk/x/bank/MsgUpdateParams";
option (cosmos.msg.v1.signer) = "authority";

// params defines the x/bank parameters to update.
// authority is the address of the governance account.
string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
// params defines the x/feeabs parameters to update.
//
// NOTE: All parameters must be supplied.
Params params = 2 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
Params params = 2
[ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ];
}

// MsgUpdateParamsResponse defines the response structure for executing a
// MsgUpdateParams message.
message MsgUpdateParamsResponse {
message MsgUpdateParamsResponse {}

// MsgAddHostZone is the Msg/AddHostZone request type.
message MsgAddHostZone {
option (cosmos.msg.v1.signer) = "authority";

// authority is the address of the governance account.
string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];

// the host chain config
HostChainFeeAbsConfig host_chain_config = 2
[ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ];
}

// MsgAddHostZoneResponse
message MsgAddHostZoneResponse {}

// MsgUpdateHostZone is the Msg/UpdateHostZone request type.
message MsgUpdateHostZone {
option (cosmos.msg.v1.signer) = "authority";

// authority is the address of the governance account.
string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];

// the host chain config
HostChainFeeAbsConfig host_chain_config = 2
[ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ];
}

// MsgUpdateHostZoneResponse
message MsgUpdateHostZoneResponse {}

// MsgRemoveHostZone is the Msg/RemoveHostZone request type.
message MsgRemoveHostZone {
option (cosmos.msg.v1.signer) = "authority";

// authority is the address of the governance account.
string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
string ibc_denom = 2;
}

// MsgRemoveHostZoneResponse
message MsgRemoveHostZoneResponse {}
2 changes: 1 addition & 1 deletion tests/interchaintest/query_osmosis_twap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func AddHostZoneProposal(t *testing.T, ctx context.Context, feeabs *cosmos.Cosmo
require.NotEmpty(t, govAddr)

addHostZoneMsg := feeabstypes.MsgAddHostZone{
HostChainConfig: &feeabstypes.HostChainFeeAbsConfig{
HostChainConfig: feeabstypes.HostChainFeeAbsConfig{
IbcDenom: fakeIBCDenom,
OsmosisPoolTokenDenomIn: "uosmo",
PoolId: 1,
Expand Down
10 changes: 5 additions & 5 deletions x/feeabs/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var _ types.MsgServer = msgServer{}

func (k Keeper) SendQueryIbcDenomTWAP(goCtx context.Context, msg *types.MsgSendQueryIbcDenomTWAP) (*types.MsgSendQueryIbcDenomTWAPResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)
_, err := sdk.AccAddressFromBech32(msg.FromAddress)
_, err := sdk.AccAddressFromBech32(msg.Sender)
if err != nil {
return nil, err
}
Expand All @@ -41,7 +41,7 @@ func (k Keeper) SendQueryIbcDenomTWAP(goCtx context.Context, msg *types.MsgSendQ
func (k Keeper) SwapCrossChain(goCtx context.Context, msg *types.MsgSwapCrossChain) (*types.MsgSwapCrossChainResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)

_, err := sdk.AccAddressFromBech32(msg.FromAddress)
_, err := sdk.AccAddressFromBech32(msg.Sender)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -74,7 +74,7 @@ func (k Keeper) FundFeeAbsModuleAccount(
// Unwrap context
ctx := sdk.UnwrapSDKContext(goCtx)
// Check sender address
sender, err := sdk.AccAddressFromBech32(msg.FromAddress)
sender, err := sdk.AccAddressFromBech32(msg.Sender)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -111,7 +111,7 @@ func (k msgServer) AddHostZone(ctx context.Context, req *types.MsgAddHostZone) (
return nil, errors.Wrapf(types.ErrDuplicateHostZoneConfig, "duplicate host ibc denom")
}

if err := k.SetHostZoneConfig(sdkContext, *req.HostChainConfig); err != nil {
if err := k.SetHostZoneConfig(sdkContext, req.HostChainConfig); err != nil {
return nil, err
}

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

if err := k.SetHostZoneConfig(sdkContext, *req.HostChainConfig); err != nil {
if err := k.SetHostZoneConfig(sdkContext, req.HostChainConfig); err != nil {
return nil, err
}

Expand Down
28 changes: 14 additions & 14 deletions x/feeabs/types/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func (m MsgSendQueryIbcDenomTWAP) Type() string { return sdk.MsgTypeURL(&m) }

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

// ValidateBasic does a sanity check on the provided data.
func (m MsgSendQueryIbcDenomTWAP) ValidateBasic() error {
_, err := sdk.AccAddressFromBech32(m.FromAddress)
_, err := sdk.AccAddressFromBech32(m.Sender)
if err != nil {
return err
}
return nil
}

func NewMsgSendQueryIbcDenomTWAP(fromAddr sdk.AccAddress) *MsgSendQueryIbcDenomTWAP {
func NewMsgSendQueryIbcDenomTWAP(sender sdk.AccAddress) *MsgSendQueryIbcDenomTWAP {
return &MsgSendQueryIbcDenomTWAP{
FromAddress: fromAddr.String(),
Sender: sender.String(),
}
}

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

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

// ValidateBasic does a sanity check on the provided data.
func (m MsgSwapCrossChain) ValidateBasic() error {
_, err := sdk.AccAddressFromBech32(m.FromAddress)
_, err := sdk.AccAddressFromBech32(m.Sender)
if err != nil {
return err
}
return nil
}

func NewMsgSwapCrossChain(fromAddr sdk.AccAddress, ibcDenom string) *MsgSwapCrossChain {
func NewMsgSwapCrossChain(sender sdk.AccAddress, ibcDenom string) *MsgSwapCrossChain {
return &MsgSwapCrossChain{
FromAddress: fromAddr.String(),
IbcDenom: ibcDenom,
Sender: sender.String(),
IbcDenom: ibcDenom,
}
}

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

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

// ValidateBasic does a sanity check on the provided data.
func (m MsgFundFeeAbsModuleAccount) ValidateBasic() error {
_, err := sdk.AccAddressFromBech32(m.FromAddress)
_, err := sdk.AccAddressFromBech32(m.Sender)
if err != nil {
return err
}
return nil
}

func NewMsgFundFeeAbsModuleAccount(fromAddr sdk.AccAddress, amount sdk.Coins) *MsgFundFeeAbsModuleAccount {
func NewMsgFundFeeAbsModuleAccount(sender sdk.AccAddress, amount sdk.Coins) *MsgFundFeeAbsModuleAccount {
return &MsgFundFeeAbsModuleAccount{
FromAddress: fromAddr.String(),
Amount: amount,
Sender: sender.String(),
Amount: amount,
}
}
Loading

0 comments on commit c1edb0a

Please sign in to comment.