-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM golang:1.21.5-alpine3.18 as build | ||
FROM golang:1.21.5-alpine3.19 as build | ||
|
||
WORKDIR /src/app | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
package interchainstaking | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" | ||
Check failure on line 5 in x/interchainstaking/transfer_middleware.go GitHub Actions / build quicksilver (amd64, linux)
Check failure on line 5 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (amd64, windows)
Check failure on line 5 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (amd64, windows)
Check failure on line 5 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (amd64, darwin)
Check failure on line 5 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (amd64, darwin)
Check failure on line 5 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (darwin, arm64)
Check failure on line 5 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (darwin, arm64)
Check failure on line 5 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (amd64, linux)
Check failure on line 5 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (amd64, linux)
Check failure on line 5 in x/interchainstaking/transfer_middleware.go GitHub Actions / build quicksilver (amd64, windows)
Check failure on line 5 in x/interchainstaking/transfer_middleware.go GitHub Actions / build quicksilver (amd64, darwin)
Check failure on line 5 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (amd64, darwin)
Check failure on line 5 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (amd64, darwin)
Check failure on line 5 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (amd64, windows)
Check failure on line 5 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (amd64, windows)
|
||
|
||
transfertypes "github.com/cosmos/ibc-go/v5/modules/apps/transfer/types" | ||
Check failure on line 7 in x/interchainstaking/transfer_middleware.go GitHub Actions / build quicksilver (amd64, linux)
Check failure on line 7 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (amd64, windows)
Check failure on line 7 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (amd64, windows)
Check failure on line 7 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (amd64, darwin)
Check failure on line 7 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (amd64, darwin)
Check failure on line 7 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (darwin, arm64)
Check failure on line 7 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (darwin, arm64)
Check failure on line 7 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (amd64, linux)
Check failure on line 7 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (amd64, linux)
Check failure on line 7 in x/interchainstaking/transfer_middleware.go GitHub Actions / build quicksilver (amd64, windows)
Check failure on line 7 in x/interchainstaking/transfer_middleware.go GitHub Actions / build quicksilver (amd64, darwin)
Check failure on line 7 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (amd64, darwin)
Check failure on line 7 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (amd64, darwin)
Check failure on line 7 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (amd64, windows)
|
||
channeltypes "github.com/cosmos/ibc-go/v5/modules/core/04-channel/types" | ||
Check failure on line 8 in x/interchainstaking/transfer_middleware.go GitHub Actions / build quicksilver (amd64, linux)
Check failure on line 8 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (amd64, windows)
Check failure on line 8 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (amd64, darwin)
Check failure on line 8 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (darwin, arm64)
Check failure on line 8 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (amd64, linux)
Check failure on line 8 in x/interchainstaking/transfer_middleware.go GitHub Actions / build quicksilver (amd64, windows)
Check failure on line 8 in x/interchainstaking/transfer_middleware.go GitHub Actions / build quicksilver (amd64, darwin)
Check failure on line 8 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (amd64, darwin)
|
||
porttypes "github.com/cosmos/ibc-go/v5/modules/core/05-port/types" | ||
Check failure on line 9 in x/interchainstaking/transfer_middleware.go GitHub Actions / build quicksilver (amd64, linux)
Check failure on line 9 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (amd64, windows)
Check failure on line 9 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (amd64, darwin)
Check failure on line 9 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (darwin, arm64)
Check failure on line 9 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (amd64, linux)
Check failure on line 9 in x/interchainstaking/transfer_middleware.go GitHub Actions / build quicksilver (amd64, windows)
Check failure on line 9 in x/interchainstaking/transfer_middleware.go GitHub Actions / build quicksilver (amd64, darwin)
Check failure on line 9 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (amd64, darwin)
|
||
ibcexported "github.com/cosmos/ibc-go/v5/modules/core/exported" | ||
Check failure on line 10 in x/interchainstaking/transfer_middleware.go GitHub Actions / build quicksilver (amd64, linux)
Check failure on line 10 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (amd64, windows)
Check failure on line 10 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (amd64, darwin)
Check failure on line 10 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (darwin, arm64)
Check failure on line 10 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (amd64, linux)
Check failure on line 10 in x/interchainstaking/transfer_middleware.go GitHub Actions / build quicksilver (amd64, windows)
Check failure on line 10 in x/interchainstaking/transfer_middleware.go GitHub Actions / build quicksilver (amd64, darwin)
Check failure on line 10 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (amd64, darwin)
|
||
|
||
"github.com/quicksilver-zone/quicksilver/utils" | ||
Check failure on line 12 in x/interchainstaking/transfer_middleware.go GitHub Actions / build quicksilver (amd64, linux)
Check failure on line 12 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (amd64, windows)
Check failure on line 12 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (amd64, darwin)
Check failure on line 12 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (darwin, arm64)
Check failure on line 12 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (amd64, linux)
Check failure on line 12 in x/interchainstaking/transfer_middleware.go GitHub Actions / build quicksilver (amd64, windows)
Check failure on line 12 in x/interchainstaking/transfer_middleware.go GitHub Actions / build quicksilver (amd64, darwin)
Check failure on line 12 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (amd64, darwin)
|
||
"github.com/quicksilver-zone/quicksilver/x/interchainstaking/keeper" | ||
Check failure on line 13 in x/interchainstaking/transfer_middleware.go GitHub Actions / build quicksilver (amd64, linux)
Check failure on line 13 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (amd64, windows)
Check failure on line 13 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (amd64, darwin)
Check failure on line 13 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (darwin, arm64)
Check failure on line 13 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (amd64, linux)
Check failure on line 13 in x/interchainstaking/transfer_middleware.go GitHub Actions / build quicksilver (amd64, windows)
Check failure on line 13 in x/interchainstaking/transfer_middleware.go GitHub Actions / build quicksilver (amd64, darwin)
Check failure on line 13 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (amd64, darwin)
|
||
"github.com/quicksilver-zone/quicksilver/x/interchainstaking/types" | ||
Check failure on line 14 in x/interchainstaking/transfer_middleware.go GitHub Actions / build quicksilver (amd64, linux)
Check failure on line 14 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (amd64, windows)
Check failure on line 14 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (amd64, darwin)
Check failure on line 14 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (darwin, arm64)
Check failure on line 14 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (amd64, linux)
Check failure on line 14 in x/interchainstaking/transfer_middleware.go GitHub Actions / build quicksilver (amd64, windows)
Check failure on line 14 in x/interchainstaking/transfer_middleware.go GitHub Actions / build quicksilver (amd64, darwin)
Check failure on line 14 in x/interchainstaking/transfer_middleware.go GitHub Actions / test quicksilver (amd64, darwin)
|
||
) | ||
|
||
var _ porttypes.IBCModule = &TransferMiddleware{} | ||
|
||
// IBCModule implements the ICS26 interface for interchain accounts controller chains. | ||
type TransferMiddleware struct { | ||
app porttypes.IBCModule | ||
keeper *keeper.Keeper | ||
} | ||
|
||
// NewIBCModule creates a new IBCModule given the keeper. | ||
func NewTransferMiddleware(app porttypes.IBCModule, k *keeper.Keeper) TransferMiddleware { | ||
return TransferMiddleware{ | ||
app: app, | ||
keeper: k, | ||
} | ||
} | ||
|
||
// OnChanOpenInit implements the IBCModule interface. | ||
func (im TransferMiddleware) OnChanOpenInit( | ||
ctx sdk.Context, | ||
order channeltypes.Order, | ||
connectionHops []string, | ||
portID string, | ||
channelID string, | ||
chanCap *capabilitytypes.Capability, | ||
counterparty channeltypes.Counterparty, | ||
version string, | ||
) (string, error) { | ||
return im.app.OnChanOpenInit(ctx, order, connectionHops, portID, channelID, chanCap, counterparty, version) | ||
} | ||
|
||
// OnChanOpenTry implements the IBCModule interface. | ||
func (im TransferMiddleware) OnChanOpenTry( | ||
ctx sdk.Context, | ||
order channeltypes.Order, | ||
connectionHops []string, | ||
portID, channelID string, | ||
chanCap *capabilitytypes.Capability, | ||
counterparty channeltypes.Counterparty, | ||
counterpartyVersion string, | ||
) (version string, err error) { | ||
return im.app.OnChanOpenTry(ctx, order, connectionHops, portID, channelID, chanCap, counterparty, counterpartyVersion) | ||
} | ||
|
||
// OnChanOpenAck implements the IBCModule interface. | ||
func (im TransferMiddleware) OnChanOpenAck( | ||
ctx sdk.Context, | ||
portID, channelID string, | ||
counterpartyChannelID string, | ||
counterpartyVersion string, | ||
) error { | ||
return im.app.OnChanOpenAck(ctx, portID, channelID, counterpartyChannelID, counterpartyVersion) | ||
} | ||
|
||
// OnChanOpenConfirm implements the IBCModule interface. | ||
func (im TransferMiddleware) OnChanOpenConfirm(ctx sdk.Context, portID, channelID string) error { | ||
return im.app.OnChanOpenConfirm(ctx, portID, channelID) | ||
} | ||
|
||
// OnChanCloseInit implements the IBCModule interface. | ||
func (im TransferMiddleware) OnChanCloseInit(ctx sdk.Context, portID, channelID string) error { | ||
return im.app.OnChanCloseInit(ctx, portID, channelID) | ||
} | ||
|
||
// OnChanCloseConfirm implements the IBCModule interface. | ||
func (im TransferMiddleware) OnChanCloseConfirm(ctx sdk.Context, portID, channelID string) error { | ||
return im.app.OnChanCloseConfirm(ctx, portID, channelID) | ||
} | ||
|
||
// OnRecvPacket checks implements the IBCModule interface. | ||
func (im TransferMiddleware) OnRecvPacket( | ||
ctx sdk.Context, | ||
packet channeltypes.Packet, | ||
relayer sdk.AccAddress, | ||
) ibcexported.Acknowledgement { | ||
var data transfertypes.FungibleTokenPacketData | ||
if err := transfertypes.ModuleCdc.UnmarshalJSON(packet.GetData(), &data); err != nil { | ||
return channeltypes.NewErrorAcknowledgement(err) | ||
} | ||
|
||
_, found := im.keeper.GetZoneForWithdrawalAccount(ctx, data.Sender) | ||
if found { | ||
if data.Receiver == im.keeper.AccountKeeper.GetModuleAddress(types.ModuleName).String() { | ||
im.keeper.Logger(ctx).Info("msgTransfer to ics module account from withdrawal address") | ||
err := im.keeper.HandleMsgTransfer(ctx, data, utils.DeriveIbcDenom(packet.DestinationPort, packet.DestinationChannel, packet.SourcePort, packet.SourceChannel, data.Denom)) | ||
if err != nil { | ||
im.keeper.Logger(ctx).Error("unable to disperse rewards", "error", err.Error()) | ||
} | ||
} | ||
} | ||
|
||
return im.app.OnRecvPacket(ctx, packet, relayer) | ||
} | ||
|
||
// OnAcknowledgementPacket implements the IBCModule interface. | ||
func (im TransferMiddleware) OnAcknowledgementPacket( | ||
ctx sdk.Context, | ||
packet channeltypes.Packet, | ||
acknowledgement []byte, | ||
relayer sdk.AccAddress, | ||
) error { | ||
return im.app.OnAcknowledgementPacket(ctx, packet, acknowledgement, relayer) | ||
} | ||
|
||
// OnTimeoutPacket implements the IBCModule interface. | ||
func (im TransferMiddleware) OnTimeoutPacket(ctx sdk.Context, packet channeltypes.Packet, relayer sdk.AccAddress) error { | ||
return im.app.OnTimeoutPacket(ctx, packet, relayer) | ||
} |