Skip to content

Commit 06a086b

Browse files
committed
Fix
1 parent 17a5e7a commit 06a086b

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

x/wasm/ibc_integration_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,10 +288,10 @@ func TestIBCAsyncAck(t *testing.T) {
288288
path = wasmibctesting.NewPath(chainA, chainB)
289289
)
290290
path.EndpointA.ChannelConfig = &ibctesting.ChannelConfig{
291-
PortID: sourcePortID, Version: "ibc-reflect-v1", Order: channeltypes.UNORDERED,
291+
PortID: sourcePortID, Version: "ibc-reflect-v1", Order: channeltypes.ORDERED,
292292
}
293293
path.EndpointB.ChannelConfig = &ibctesting.ChannelConfig{
294-
PortID: counterpartPortID, Version: "ibc-reflect-v1", Order: channeltypes.UNORDERED,
294+
PortID: counterpartPortID, Version: "ibc-reflect-v1", Order: channeltypes.ORDERED,
295295
}
296296

297297
coord.SetupConnections(path)

x/wasm/keeper/relay.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,19 @@ func (k Keeper) OnOpenChannel(
4040
gasLeft := k.runtimeGasForContract(ctx)
4141
res, gasUsed, execErr := k.wasmVM.IBCChannelOpen(codeInfo.CodeHash, env, msg, prefixStore, cosmwasmAPI, querier, ctx.GasMeter(), gasLeft, costJSONDeserialization)
4242
k.consumeRuntimeGas(ctx, gasUsed)
43-
if execErr != nil {
43+
switch {
44+
case execErr != nil:
4445
return "", errorsmod.Wrap(types.ErrExecuteFailed, execErr.Error())
45-
}
46-
if res != nil && res.Ok != nil {
47-
return res.Ok.Version, nil
48-
}
49-
return "", nil
46+
case res == nil:
47+
return "", errorsmod.Wrap(types.ErrVMError, "empty response from contract")
48+
case res.Err != "":
49+
return "", types.MarkErrorDeterministic(errorsmod.Wrap(types.ErrExecuteFailed, res.Err))
50+
case res.Ok == nil:
51+
// a nil "ok" value is a valid response and means the contract accepts the incoming channel version
52+
// see https://docs.rs/cosmwasm-std/2.2.2/cosmwasm_std/type.IbcChannelOpenResponse.html
53+
return "", nil
54+
}
55+
return res.Ok.Version, nil
5056
}
5157

5258
// OnConnectChannel calls the contract to let it know the IBC channel was established.

0 commit comments

Comments
 (0)