Skip to content

Commit

Permalink
fix ibc error
Browse files Browse the repository at this point in the history
  • Loading branch information
ducphamle2 committed May 18, 2022
1 parent 01413b0 commit a963e77
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

PACKAGES_SIMTEST=$(shell go list ./... | grep '/simulation')
#VERSION := $(shell echo $(shell git describe --always) | sed 's/^v//')
VERSION := v0.40.3_ibc
VERSION := v0.40.4_ibc
COMMIT := $(shell git log -1 --format='%H')
LEDGER_ENABLED ?= false
GOMOD_FLAGS ?= -mod=readonly
Expand Down
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ func initParamsKeeper(appCodec codec.BinaryMarshaler, legacyAmino *codec.LegacyA
}

func (app *OraichainApp) upgradeHandler() {
app.upgradeKeeper.SetUpgradeHandler("v0.40.3_ibc", func(ctx sdk.Context, plan upgradetypes.Plan) {
app.upgradeKeeper.SetUpgradeHandler("v0.40.4_ibc", func(ctx sdk.Context, plan upgradetypes.Plan) {
// upgrade changes here
})
}
10 changes: 7 additions & 3 deletions cosmos-sdk/x/ibc/applications/transfer/keeper/mbt_relay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type TlaBalance struct {
type TlaFungibleTokenPacketData struct {
Sender string `json:"sender"`
Receiver string `json:"receiver"`
Amount int `json:"amount"`
Amount string `json:"amount"`
Denom []string `json:"denom"`
}

Expand Down Expand Up @@ -144,7 +144,7 @@ func FungibleTokenPacketFromTla(packet TlaFungibleTokenPacket) FungibleTokenPack
DestPort: packet.DestPort,
Data: types.NewFungibleTokenPacketData(
DenomFromTla(packet.Data.Denom),
uint64(packet.Data.Amount),
packet.Data.Amount,
AddressFromString(packet.Data.Sender),
AddressFromString(packet.Data.Receiver)),
}
Expand Down Expand Up @@ -350,11 +350,15 @@ func (suite *KeeperTestSuite) TestModelBasedRelay() {
denom := denomTrace.IBCDenom()
err = sdk.ValidateDenom(denom)
if err == nil {
amount, ok := sdk.NewIntFromString(tc.packet.Data.Amount)
if !ok {
panic("MBT failed to parse amount from string")
}
err = suite.chainB.App.TransferKeeper.SendTransfer(
suite.chainB.GetContext(),
tc.packet.SourcePort,
tc.packet.SourceChannel,
sdk.NewCoin(denom, sdk.NewIntFromUint64(tc.packet.Data.Amount)),
sdk.NewCoin(denom, amount),
sender,
tc.packet.Data.Receiver,
clienttypes.NewHeight(0, 110),
Expand Down
6 changes: 4 additions & 2 deletions cosmos-sdk/x/ibc/applications/transfer/keeper/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,13 @@ func (k Keeper) SendTransfer(
}

defer func() {
telemetry.SetGaugeWithLabels(
if token.Amount.IsInt64() {
telemetry.SetGaugeWithLabels(
[]string{"tx", "msg", "ibc", "transfer"},
float32(token.Amount.Int64()),
[]metrics.Label{telemetry.NewLabel(coretypes.LabelDenom, fullDenomPath)},
)
)
}

telemetry.IncrCounterWithLabels(
[]string{"ibc", types.ModuleName, "send"},
Expand Down
2 changes: 1 addition & 1 deletion cosmos-sdk/x/ibc/applications/transfer/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ func (am AppModule) OnTimeoutPacket(
sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName),
sdk.NewAttribute(types.AttributeKeyRefundReceiver, data.Sender),
sdk.NewAttribute(types.AttributeKeyRefundDenom, data.Denom),
sdk.NewAttribute(types.AttributeKeyRefundAmount, fmt.Sprintf("%d", data.Amount)),
sdk.NewAttribute(types.AttributeKeyRefundAmount, data.Amount),
),
)

Expand Down
4 changes: 2 additions & 2 deletions cosmos-sdk/x/ibc/applications/transfer/types/coin.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func GetPrefixedDenom(portID, channelID, baseDenom string) string {

// GetTransferCoin creates a transfer coin with the port ID and channel ID
// prefixed to the base denom.
func GetTransferCoin(portID, channelID, baseDenom string, amount int64) sdk.Coin {
func GetTransferCoin(portID, channelID, baseDenom string, amount sdk.Int) sdk.Coin {
denomTrace := ParseDenomTrace(GetPrefixedDenom(portID, channelID, baseDenom))
return sdk.NewInt64Coin(denomTrace.IBCDenom(), amount)
return sdk.NewCoin(denomTrace.IBCDenom(), amount)
}

0 comments on commit a963e77

Please sign in to comment.