Skip to content

Commit

Permalink
fix: comment out conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
tuantran1702 committed Jan 24, 2024
1 parent 0e3ef7a commit 1388c7c
Show file tree
Hide file tree
Showing 3 changed files with 134 additions and 134 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.21

require (
cosmossdk.io/client/v2 v2.0.0-beta.1
cosmossdk.io/collections v0.4.0
cosmossdk.io/core v0.12.0
cosmossdk.io/errors v1.0.1
cosmossdk.io/log v1.3.0
Expand Down Expand Up @@ -63,7 +64,6 @@ require (
cloud.google.com/go/iam v1.1.5 // indirect
cloud.google.com/go/storage v1.35.1 // indirect
cosmossdk.io/api v0.7.2 // indirect
cosmossdk.io/collections v0.4.0 // indirect
cosmossdk.io/depinject v1.0.0-alpha.4 // indirect
cosmossdk.io/x/circuit v0.1.0 // indirect
filippo.io/edwards25519 v1.0.0 // indirect
Expand Down
24 changes: 12 additions & 12 deletions utils/proofs.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func ValidateProofOps(

// TODO: ibc v8 remove the GetRoot method of ConsensusState, so can not verify MerkleProof

Check notice

Code scanning / devskim

A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note

Suspicious comment

path := commitmenttypes.NewMerklePath([]string{module, url.PathEscape(string(key))}...)
// path := commitmenttypes.NewMerklePath([]string{module, url.PathEscape(string(key))}...)

_, err := commitmenttypes.ConvertProofs(proofOps)
if err != nil {
Expand All @@ -64,19 +64,19 @@ func ValidateProofOps(
return errors.New("error unmarshaling client state")
}

if len(data) != 0 {
// if we got a non-nil response, verify inclusion proof.
if err := merkleProof.VerifyMembership(tmClientState.ProofSpecs, consensusState.GetRoot(), path, data); err != nil {
return fmt.Errorf("unable to verify inclusion proof: %w", err)
}
return nil
// if len(data) != 0 {
// // if we got a non-nil response, verify inclusion proof.
// if err := merkleProof.VerifyMembership(tmClientState.ProofSpecs, consensusState.GetRoot(), path, data); err != nil {
// return fmt.Errorf("unable to verify inclusion proof: %w", err)
// }
// return nil

}
// if we got a nil response, verify non inclusion proof.
// }
// // if we got a nil response, verify non inclusion proof.

if err := merkleProof.VerifyNonMembership(tmClientState.ProofSpecs, consensusState.Root, path); err != nil {
return fmt.Errorf("unable to verify non-inclusion proof: %w", err)
}
// if err := merkleProof.VerifyNonMembership(tmClientState.ProofSpecs, consensusState.Root, path); err != nil {
// return fmt.Errorf("unable to verify non-inclusion proof: %w", err)
// }
return nil
}

Expand Down
242 changes: 121 additions & 121 deletions x/interchainstaking/transfer_middleware.go
Original file line number Diff line number Diff line change
@@ -1,123 +1,123 @@
package interchainstaking

import (
sdk "github.com/cosmos/cosmos-sdk/types"
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"

transfertypes "github.com/cosmos/ibc-go/v5/modules/apps/transfer/types"
channeltypes "github.com/cosmos/ibc-go/v5/modules/core/04-channel/types"
porttypes "github.com/cosmos/ibc-go/v5/modules/core/05-port/types"
ibcexported "github.com/cosmos/ibc-go/v5/modules/core/exported"

"github.com/quicksilver-zone/quicksilver/utils"
"github.com/quicksilver-zone/quicksilver/x/interchainstaking/keeper"
"github.com/quicksilver-zone/quicksilver/x/interchainstaking/types"
)

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)
}
// import (
// sdk "github.com/cosmos/cosmos-sdk/types"
// capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"

// transfertypes "github.com/cosmos/ibc-go/v5/modules/apps/transfer/types"
// channeltypes "github.com/cosmos/ibc-go/v5/modules/core/04-channel/types"
// porttypes "github.com/cosmos/ibc-go/v5/modules/core/05-port/types"
// ibcexported "github.com/cosmos/ibc-go/v5/modules/core/exported"

// "github.com/quicksilver-zone/quicksilver/utils"
// "github.com/quicksilver-zone/quicksilver/x/interchainstaking/keeper"
// "github.com/quicksilver-zone/quicksilver/x/interchainstaking/types"
// )

// 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)
// }

0 comments on commit 1388c7c

Please sign in to comment.