-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add provider info query #1164
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
ee5c6f6
feat: add provider info query
8ddb410
feat: refactor query providerInfo
81f2952
feat: query provider info
aeba225
feat: query all provider info
9c235c6
feat: add provider info query cli
bcd1ac6
feat: add consumer info to provider info query
c1e8c3f
feat: add consumer chain-id to provider info query
d8edc2a
fix: return err when client, channel not found
94d9144
fix: lint
9ece874
chore: fix lint
326a88c
chore: lint fix
14d98c5
chore: add nonlint
1354837
chore: add nonlint to the right place
d739877
chore: add nolint nolintlint
ed67f9f
chore: nolint all
a4bd742
chore: nolint:golint
4b6fdbe
chore: fix package import order
02b0338
chore: update queryProviderChainInfo to queryProviderInfo
8a904ee
chore: update proto
856ce9e
update query.go
8971455
docs: update changelog
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) | ||
yaruwangway marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yaruwangway please include a PR link next time