Skip to content

Commit

Permalink
fix: use the downcall's partial Packet as arguments where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Apr 27, 2020
1 parent ea5ba38 commit 3befb25
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
11 changes: 9 additions & 2 deletions packages/cosmic-swingset/lib/ag-solo/vats/ibc.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,11 @@ export function makeIBCProtocolHandler(
},
onReceive,
async onClose(_conn, _reason, _handler) {
await callIBCDevice('channelCloseInit', { channelID, portID });
const packet = {
source_port: portID,
source_channel: channelID,
};
await callIBCDevice('channelCloseInit', { packet });
usedChannels.delete(channelID);
usedChannels.delete(rChannelID);
},
Expand Down Expand Up @@ -251,7 +255,10 @@ export function makeIBCProtocolHandler(
},
async onBind(_port, localAddr, _protocolHandler) {
const portID = localAddrToPortID(localAddr);
return callIBCDevice('bindPort', { portID });
const packet = {
source_port: portID,
};
return callIBCDevice('bindPort', { packet });
},
async onConnect(_port, localAddr, remoteAddr, _protocolHandler) {
console.warn('IBC onConnect', localAddr, remoteAddr);
Expand Down
6 changes: 2 additions & 4 deletions packages/cosmic-swingset/x/swingset/ibc.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ type channelHandler struct {
type channelMessage struct { // comes from swingset's IBC handler
Type string `json:"type"` // IBC_METHOD
Method string `json:"method"`
PortID string `json:"portID"`
ChannelID string `json:"channelID"`
Packet channeltypes.Packet `json:"packet"`
RelativeTimeout uint64 `json:"relativeTimeout"`
Order channelexported.Order `json:"order"`
Expand Down Expand Up @@ -110,13 +108,13 @@ func (ch channelHandler) Receive(ctx *ControllerContext, str string) (ret string
}

case "channelCloseInit":
err = ctx.Keeper.ChanCloseInit(ctx.Context, msg.PortID, msg.ChannelID)
err = ctx.Keeper.ChanCloseInit(ctx.Context, msg.Packet.SourcePort, msg.Packet.SourceChannel)
if err == nil {
ret = "true"
}

case "bindPort":
err = ctx.Keeper.BindPort(ctx.Context, msg.PortID)
err = ctx.Keeper.BindPort(ctx.Context, msg.Packet.SourcePort)
if err == nil {
ret = "true"
}
Expand Down

0 comments on commit 3befb25

Please sign in to comment.