github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/x/icamauth/ibc_module.go (about) 1 package icamauth 2 3 import ( 4 sdk "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/types" 5 sdkerrors "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/types/errors" 6 capabilitytypes "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/x/capability/types" 7 channeltypes "github.com/fibonacci-chain/fbc/libs/ibc-go/modules/core/04-channel/types" 8 porttypes "github.com/fibonacci-chain/fbc/libs/ibc-go/modules/core/05-port/types" 9 host "github.com/fibonacci-chain/fbc/libs/ibc-go/modules/core/24-host" 10 ibcexported "github.com/fibonacci-chain/fbc/libs/ibc-go/modules/core/exported" 11 "github.com/fibonacci-chain/fbc/x/icamauth/keeper" 12 ) 13 14 var _ porttypes.IBCModule = IBCModule{} 15 16 // IBCModule implements the ICS26 interface for interchain accounts controller chains 17 type IBCModule struct { 18 keeper keeper.Keeper 19 } 20 21 // NewIBCModule creates a new IBCModule given the keeper 22 func NewIBCModule(k keeper.Keeper) IBCModule { 23 return IBCModule{ 24 keeper: k, 25 } 26 } 27 28 // OnChanOpenInit implements the IBCModule interface 29 func (im IBCModule) OnChanOpenInit( 30 ctx sdk.Context, 31 order channeltypes.Order, 32 connectionHops []string, 33 portID string, 34 channelID string, 35 chanCap *capabilitytypes.Capability, 36 counterparty channeltypes.Counterparty, 37 version string, 38 ) (string, error) { 39 // Claim channel capability passed back by IBC module 40 if err := im.keeper.ClaimCapability(ctx, chanCap, host.ChannelCapabilityPath(portID, channelID)); err != nil { 41 return "", err 42 } 43 44 return version, nil 45 } 46 47 // OnChanOpenTry implements the IBCModule interface 48 func (im IBCModule) OnChanOpenTry(ctx sdk.Context, order channeltypes.Order, connectionHops []string, portID, channelID string, channelCap *capabilitytypes.Capability, counterparty channeltypes.Counterparty, version, counterpartyVersion string) (string, error) { 49 return "", nil 50 } 51 52 // OnChanOpenAck implements the IBCModule interface 53 func (im IBCModule) OnChanOpenAck( 54 ctx sdk.Context, 55 portID, 56 channelID string, 57 counterpartyChannelID string, 58 counterpartyVersion string, 59 ) error { 60 return nil 61 } 62 63 // OnChanOpenConfirm implements the IBCModule interface 64 func (im IBCModule) OnChanOpenConfirm( 65 ctx sdk.Context, 66 portID, 67 channelID string, 68 ) error { 69 return nil 70 } 71 72 // OnChanCloseInit implements the IBCModule interface 73 func (im IBCModule) OnChanCloseInit( 74 ctx sdk.Context, 75 portID, 76 channelID string, 77 ) error { 78 return nil 79 } 80 81 // OnChanCloseConfirm implements the IBCModule interface 82 func (im IBCModule) OnChanCloseConfirm( 83 ctx sdk.Context, 84 portID, 85 channelID string, 86 ) error { 87 return nil 88 } 89 90 // OnRecvPacket implements the IBCModule interface. A successful acknowledgement 91 // is returned if the packet data is successfully decoded and the receive application 92 // logic returns without error. 93 func (im IBCModule) OnRecvPacket( 94 ctx sdk.Context, 95 packet channeltypes.Packet, 96 relayer sdk.AccAddress, 97 ) ibcexported.Acknowledgement { 98 return channeltypes.NewErrorAcknowledgementV4(sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "cannot receive packet via interchain accounts authentication module")) 99 } 100 101 // the controller does not check the tx error in hostchain 102 // OnAcknowledgementPacket implements the IBCModule interface 103 func (im IBCModule) OnAcknowledgementPacket( 104 ctx sdk.Context, 105 packet channeltypes.Packet, 106 acknowledgement []byte, 107 relayer sdk.AccAddress, 108 ) error { 109 return nil 110 } 111 112 // OnTimeoutPacket implements the IBCModule interface. 113 func (im IBCModule) OnTimeoutPacket( 114 ctx sdk.Context, 115 packet channeltypes.Packet, 116 relayer sdk.AccAddress, 117 ) error { 118 return nil 119 } 120 121 // NegotiateAppVersion implements the IBCModule interface 122 func (im IBCModule) NegotiateAppVersion( 123 ctx sdk.Context, 124 order channeltypes.Order, 125 connectionID string, 126 portID string, 127 counterparty channeltypes.Counterparty, 128 proposedVersion string, 129 ) (string, error) { 130 return "", nil 131 }