Skip to content

Commit

Permalink
review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
adamewozniak committed Nov 9, 2023
1 parent 0d3fec6 commit 4810ae9
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 113 deletions.
6 changes: 3 additions & 3 deletions proto/ojo/gmp/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ service Msg {
rpc SetParams(MsgSetParams) returns (MsgSetParamsResponse);

// Relay relays Ojo data via GMP.
rpc Relay(MsgRelay) returns (MsgRelayResponse);
rpc RelayPrice(MsgRelayPrice) returns (MsgRelayPriceResponse);
}

// MsgSetParams defines the SetParams message type.
Expand All @@ -35,7 +35,7 @@ message MsgSetParams {
message MsgSetParamsResponse {}

// MsgRelay defines the Relay message type.
message MsgRelay {
message MsgRelayPrice {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
option (cosmos.msg.v1.signer) = "relayer";
Expand All @@ -60,4 +60,4 @@ message MsgRelay {
}

// MsgRelay defines the Relay response type.
message MsgRelayResponse {}
message MsgRelayPriceResponse {}
14 changes: 7 additions & 7 deletions x/gmp/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ func (ms msgServer) SetParams(goCtx context.Context, msg *types.MsgSetParams) (*

// Relay implements MsgServer.Relay method.
// It defines a method to relay over GMP to recipient chains.
func (ms msgServer) Relay(
func (ms msgServer) RelayPrice(
goCtx context.Context,
msg *types.MsgRelay,
) (*types.MsgRelayResponse, error) {
msg *types.MsgRelayPrice,
) (*types.MsgRelayPriceResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)
params := ms.keeper.GetParams(ctx)

Expand All @@ -61,7 +61,7 @@ func (ms msgServer) Relay(
for _, denom := range msg.Denoms {
rate, err := ms.keeper.oracleKeeper.GetExchangeRate(ctx, denom)
if err != nil {
return &types.MsgRelayResponse{}, err
return &types.MsgRelayPriceResponse{}, err
}

priceFeed, err := types.NewPriceFeedData(
Expand All @@ -73,7 +73,7 @@ func (ms msgServer) Relay(
big.NewInt(1),
)
if err != nil {
ms.keeper.Logger(ctx).With(err).Error("asset name is too long to relay!")
ms.keeper.Logger(ctx).With(err).Error("unable to relay price to gmp")
continue
}

Expand Down Expand Up @@ -113,8 +113,8 @@ func (ms msgServer) Relay(

_, err = ms.keeper.ibcKeeper.Transfer(ctx, transferMsg)
if err != nil {
return &types.MsgRelayResponse{}, err
return &types.MsgRelayPriceResponse{}, err
}

return &types.MsgRelayResponse{}, nil
return &types.MsgRelayPriceResponse{}, nil
}
3 changes: 3 additions & 0 deletions x/gmp/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import (
"github.com/ojo-network/ojo/x/gmp/types"
)

// TODO: Add tests for RelayPrice
// Ref: https://github.com/ojo-network/ojo/issues/313

func (s *IntegrationTestSuite) TestMsgServer_SetParams() {
gmpChannel := "channel-1"
gmpAddress := "axelar1dv4u5k73pzqrxlzujxg3qp8kvc3pje7jtdvu72npnt5zhq05ejcsn5qme5"
Expand Down
4 changes: 1 addition & 3 deletions x/gmp/types/abi_encoding_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package types

import (
"fmt"
"math/big"
"testing"

Expand All @@ -22,7 +21,6 @@ func TestEncodeABI(t *testing.T) {
},
}
disableResolve := false
r, err := EncodeABI("postPrices", rates, disableResolve)
_, err := EncodeABI("postPrices", rates, disableResolve)
require.NoError(t, err)
fmt.Println(r)
}
4 changes: 2 additions & 2 deletions x/gmp/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ func init() {
// RegisterLegacyAminoCodec registers the necessary x/gmp interfaces and concrete types
// on the provided LegacyAmino codec. These types are used for Amino JSON serialization.
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(&MsgRelay{}, "ojo/gmp/MsgRelay", nil)
cdc.RegisterConcrete(&MsgRelayPrice{}, "ojo/gmp/MsgRelayPrice", nil)
cdc.RegisterConcrete(&MsgSetParams{}, "ojo/gmp/MsgSetParams", nil)
}

// RegisterInterfaces registers the x/gmp interfaces types with the interface registry
func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
registry.RegisterImplementations((*sdk.Msg)(nil),
&MsgRelay{},
&MsgRelayPrice{},
&MsgSetParams{},
)

Expand Down
12 changes: 6 additions & 6 deletions x/gmp/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ func NewMsgRelay(
destinationAddress string,
token sdk.Coin,
denoms []string,
) *MsgRelay {
return &MsgRelay{
) *MsgRelayPrice {
return &MsgRelayPrice{
Relayer: relayer,
DestinationChain: destinationChain,
DestinationAddress: destinationAddress,
Expand All @@ -61,20 +61,20 @@ func NewMsgRelay(
}

// Type implements LegacyMsg interface
func (msg MsgRelay) Type() string { return sdk.MsgTypeURL(&msg) }
func (msg MsgRelayPrice) Type() string { return sdk.MsgTypeURL(&msg) }

// GetSignBytes implements sdk.Msg
func (msg MsgRelay) GetSignBytes() []byte {
func (msg MsgRelayPrice) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg))
}

// GetSigners implements sdk.Msg
func (msg MsgRelay) GetSigners() []sdk.AccAddress {
func (msg MsgRelayPrice) GetSigners() []sdk.AccAddress {
return checkers.Signers(msg.Relayer)
}

// ValidateBasic Implements sdk.Msg
func (msg MsgRelay) ValidateBasic() error {
func (msg MsgRelayPrice) ValidateBasic() error {
// TODO validate relay msg
return nil
}
Loading

0 comments on commit 4810ae9

Please sign in to comment.