From 41b8c26b7fe4b11947309d0b205fc1c4a2034b04 Mon Sep 17 00:00:00 2001 From: Sai Kumar Date: Thu, 4 Apr 2024 14:06:58 +0530 Subject: [PATCH] ++ --- x/oracle/keeper/historic_price.go | 2 +- x/uibc/gmp/gmp_middleware.go | 10 +++++----- x/uibc/gmp/gmp_middleware_test.go | 8 ++++---- x/uibc/gmp/types.go | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/x/oracle/keeper/historic_price.go b/x/oracle/keeper/historic_price.go index 0ddde0db2e..c09903dc0b 100644 --- a/x/oracle/keeper/historic_price.go +++ b/x/oracle/keeper/historic_price.go @@ -45,7 +45,7 @@ func (k Keeper) CalcAndSetHistoricMedian( median, err := decmath.Median(historicPrices) if err != nil { - return errors.Wrap(err, "denom: "+denom) //nolint: goconst + return errors.Wrap(err, "denom: "+denom) } block := uint64(ctx.BlockHeight()) diff --git a/x/uibc/gmp/gmp_middleware.go b/x/uibc/gmp/gmp_middleware.go index d990402f98..dd9746138d 100644 --- a/x/uibc/gmp/gmp_middleware.go +++ b/x/uibc/gmp/gmp_middleware.go @@ -8,20 +8,20 @@ import ( ) // PaseMemo will parse the incoming gmp memo -func ParseMemo(ctx sdk.Context, coinReceived sdk.Coin, memo string, receiver sdk.AccAddress) (GMPMemo, error) { +func ParseMemo(ctx sdk.Context, coinReceived sdk.Coin, memo string, receiver sdk.AccAddress) (Memo, error) { if len(memo) == 0 { - return GMPMemo{}, nil + return Memo{}, nil } - var msg GMPMemo + var msg Memo if err := json.Unmarshal([]byte(memo), &msg); err != nil { return msg, err } switch msg.Type { case TypeGeneralMessage: - return msg, fmt.Errorf("only msg.type=%d (TypeGeneralMessageWithToken) is supported", - TypeGeneralMessageWithToken) + return msg, fmt.Errorf("msg.type=%d (TypeGeneralMessage) is not supported. Supported types include: %d", + TypeGeneralMessage, TypeGeneralMessageWithToken) case TypeGeneralMessageWithToken: return msg, nil default: diff --git a/x/uibc/gmp/gmp_middleware_test.go b/x/uibc/gmp/gmp_middleware_test.go index b2429ade21..8101c750ad 100644 --- a/x/uibc/gmp/gmp_middleware_test.go +++ b/x/uibc/gmp/gmp_middleware_test.go @@ -36,7 +36,7 @@ func TestGmpMemoHandler(t *testing.T) { { name: "unsupport msg", memo: func() string { - validMemo := GMPMemo{ + validMemo := Memo{ SourceChain: "source_chain", SourceAddress: "source_addr", Payload: nil, @@ -51,7 +51,7 @@ func TestGmpMemoHandler(t *testing.T) { { name: "unsupport msg", memo: func() string { - validMemo := GMPMemo{ + validMemo := Memo{ SourceChain: "source_chain", SourceAddress: "source_addr", Payload: nil, @@ -61,12 +61,12 @@ func TestGmpMemoHandler(t *testing.T) { assert.NilError(t, err) return string(m) }, - errMsg: "only msg.type=2 (TypeGeneralMessageWithToken) is supported", + errMsg: "msg.type=1 (TypeGeneralMessage) is not supported. Supported types include: 2", }, { name: "valid memo", memo: func() string { - validMemo := GMPMemo{ + validMemo := Memo{ SourceChain: "source_chain", SourceAddress: "source_addr", Payload: nil, diff --git a/x/uibc/gmp/types.go b/x/uibc/gmp/types.go index 4da7eb77b9..65e20a2361 100644 --- a/x/uibc/gmp/types.go +++ b/x/uibc/gmp/types.go @@ -15,8 +15,8 @@ const ( TypeSendToken ) -// GMPMemo is attached in ICS20 packet memo field -type GMPMemo struct { +// Memo is attached in ICS20 packet memo field +type Memo struct { SourceChain string `json:"source_chain"` SourceAddress string `json:"source_address"` Payload []byte `json:"payload"`