-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add provider info query (#1164)
* feat: add provider info query * feat: refactor query providerInfo * feat: query provider info * feat: query all provider info * feat: add provider info query cli * feat: add consumer info to provider info query * feat: add consumer chain-id to provider info query * fix: return err when client, channel not found * fix: lint * chore: fix lint * chore: lint fix * chore: add nonlint * chore: add nonlint to the right place * chore: add nolint nolintlint * chore: nolint all * chore: nolint:golint * chore: fix package import order * chore: update queryProviderChainInfo to queryProviderInfo * chore: update proto * update query.go * docs: update changelog
- Loading branch information
1 parent
006680a
commit aaa545d
Showing
9 changed files
with
940 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package keeper | ||
|
||
import ( | ||
ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" //nolint:golint | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
"github.com/cosmos/interchain-security/v3/x/ccv/consumer/types" | ||
ccvtypes "github.com/cosmos/interchain-security/v3/x/ccv/types" | ||
) | ||
|
||
func (k Keeper) GetProviderInfo(ctx sdk.Context) (*types.QueryProviderInfoResponse, error) { //nolint:golint | ||
consumerChannelID, found := k.GetProviderChannel(ctx) | ||
if !found { | ||
return nil, ccvtypes.ErrChannelNotFound | ||
} | ||
consumerChannel, found := k.channelKeeper.GetChannel(ctx, ccvtypes.ConsumerPortID, consumerChannelID) | ||
if !found { | ||
return nil, ccvtypes.ErrChannelNotFound | ||
} | ||
|
||
// from channel get connection | ||
consumerConnectionID, consumerConnection, err := k.channelKeeper.GetChannelConnection(ctx, ccvtypes.ConsumerPortID, consumerChannelID) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
providerChannelID := consumerChannel.GetCounterparty().GetChannelID() | ||
providerConnection := consumerConnection.GetCounterparty() | ||
|
||
consumerClientState, found := k.clientKeeper.GetClientState(ctx, consumerConnection.GetClientID()) | ||
if !found { | ||
return nil, ccvtypes.ErrClientNotFound | ||
} | ||
providerChainID := consumerClientState.(*ibctm.ClientState).ChainId | ||
|
||
resp := types.QueryProviderInfoResponse{ | ||
Consumer: types.ChainInfo{ | ||
ChainID: ctx.ChainID(), | ||
ClientID: consumerConnection.GetClientID(), | ||
ConnectionID: consumerConnectionID, | ||
ChannelID: consumerChannelID, | ||
}, | ||
|
||
Provider: types.ChainInfo{ | ||
ChainID: providerChainID, | ||
ClientID: providerConnection.GetClientID(), | ||
ConnectionID: providerConnection.GetConnectionID(), | ||
ChannelID: providerChannelID, | ||
}, | ||
} | ||
|
||
return &resp, nil | ||
} |
Oops, something went wrong.