Skip to content
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

ICS 02 Implementation #4516

Merged
merged 228 commits into from
Nov 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
228 commits
Select commit Hold shift + click to select a range
9375649
add mapping
mossid Jun 7, 2019
16eea68
rm unused mapping/*, rm interfaces
mossid Jun 11, 2019
f73215e
rm unused code
mossid Jun 11, 2019
cf0b8f2
mv mapping -> state, rm x/ibc
mossid Jun 11, 2019
e25f652
Merge branch 'master' of github.com:cosmos/cosmos-sdk into joon/store…
mossid Jun 17, 2019
2b17a39
rm GetIfExists
mossid Jun 25, 2019
dc84e1e
add key
mossid Jun 25, 2019
19d7155
rm custom encoding/decoding in enum/bool
mossid Jun 26, 2019
6764bc4
Merge branch 'master' of github.com:cosmos/cosmos-sdk into joon/store…
mossid Jun 29, 2019
8affaa7
fix lint
mossid Jun 29, 2019
a7898b4
rm tests
mossid Jul 7, 2019
afcca90
add commitment
mossid Jun 7, 2019
d29b601
newtyped remote values
mossid Jun 11, 2019
dd86fa9
newtyped context
mossid Jun 11, 2019
6aad15f
revert context newtype
mossid Jun 11, 2019
088836d
add README, keypath
mossid Jun 11, 2019
cd6f1f2
reflect downstream ics
mossid Jun 11, 2019
d0777cd
add merkle
mossid Jun 11, 2019
df8c05e
add test for proving
mossid Jun 12, 2019
47c33f0
soft coded root keypath
mossid Jun 25, 2019
12ef402
add update
mossid Jun 25, 2019
03d5d17
remove RootUpdate
mossid Jun 25, 2019
0b79b1d
separate keypath and keuprefix
mossid Jun 25, 2019
7046953
add codec
mossid Jun 26, 2019
3939bd4
Merge branch 'master' of github.com:cosmos/cosmos-sdk into joon/store…
mossid Jul 9, 2019
db93a8a
separate root/path
mossid Jul 11, 2019
37387bf
add path to codec
mossid Jul 13, 2019
5266fc9
add client
mossid Jun 7, 2019
06257bd
add counterpartymanager
mossid Jun 11, 2019
5b089e7
fix manager
mossid Jun 11, 2019
d0f61b0
add Is() to counterobject
mossid Jun 11, 2019
a7b866f
add readme, reflect ICS02 revision
mossid Jun 11, 2019
392e3ab
reflect downstream ics
mossid Jun 11, 2019
5d46c96
test in progress
mossid Jun 13, 2019
b934d57
add test
mossid Jun 13, 2019
2ac7d8c
in progres
mossid Jun 19, 2019
a5d86b7
fin rebase
mossid Jun 25, 2019
acd44f3
in progress
mossid Jun 25, 2019
582fd6d
fin rebase
mossid Jun 25, 2019
cb3081d
add CLIObject in progress
mossid Jun 25, 2019
e48fd1c
cli in progress
mossid Jun 26, 2019
a372f56
add CLIObject
mossid Jun 26, 2019
67b1d73
separate testing from tendermint
mossid Jun 26, 2019
ee95a83
add key to node
mossid Jun 26, 2019
b6865aa
add root and storekey to tests/node, add codec
mossid Jun 26, 2019
631b72d
rm cli/query.go
mossid Jul 7, 2019
b9d8929
fix test
mossid Jul 7, 2019
dbd6b83
fix lint
mossid Jul 7, 2019
f6e5f90
fix lint
mossid Jul 7, 2019
892a120
add handler/msgs/client
mossid Jul 9, 2019
dce1148
rm relay
mossid Jul 9, 2019
26e8038
finalize rebase on 23 root/path sep
mossid Jul 11, 2019
812bea4
fix lint, fix syntax
mossid Jul 11, 2019
dbd47aa
rm freebase, reformat query
mossid Jul 15, 2019
f609249
add docs in progre
mossid Jul 24, 2019
7da69c1
add comments
mossid Jul 25, 2019
600445a
add comments
mossid Jul 25, 2019
98720bb
Apply suggestions from code review
mossid Jul 25, 2019
cdee396
add comments in progress
mossid Jul 25, 2019
ce588a4
Merge branch 'joon/store-mapping' into joon/ics-23-implementation
mossid Jul 25, 2019
39dca11
Merge branch 'joon/ics-23-implementation' of github.com:cosmos/cosmos…
mossid Jul 25, 2019
94e2cdc
Merge branch 'master' of github.com:cosmos/cosmos-sdk into joon/store…
mossid Jul 26, 2019
8d9e779
add comments
mossid Jul 26, 2019
92d0fb4
fix comment
mossid Jul 26, 2019
d896152
Merge branch 'joon/store-mapping' into joon/ics-23-implementation
mossid Jul 26, 2019
f70d3bd
add comments in progress
mossid Jul 27, 2019
5d913b7
recover IntEncoding scheme for integer
mossid Jul 29, 2019
699b0ba
add uint tests, don't use codec in custom types
mossid Jul 29, 2019
323818f
Merge branch 'joon/store-mapping' into joon/ics-23-implementation
mossid Jul 29, 2019
9a077eb
finalize merge
mossid Jul 29, 2019
a4a20d6
add godoc
mossid Jul 30, 2019
02a9ba5
add godoc in progress
mossid Jul 30, 2019
a9adb58
reformat test
mossid Jul 30, 2019
abb2f51
rm XXX
mossid Jul 30, 2019
361aa42
add godoc
mossid Jul 30, 2019
97edd89
Merge branch 'master' of github.com:cosmos/cosmos-sdk into joon/store…
mossid Jul 30, 2019
23debb9
Merge branch 'joon/store-mapping' into joon/ics-23-implementation
mossid Jul 30, 2019
b0ca51a
Merge branch 'joon/ics-23-implementation' into joon/ics-02-implementa…
mossid Jul 30, 2019
54a67b0
modify store
mossid Jul 31, 2019
24e621a
add query
mossid Jul 31, 2019
64c0381
update query.go
mossid Jul 31, 2019
971a642
update query.go
mossid Jul 31, 2019
2968dd3
Merge branch 'joon/store-mapping' into joon/ics-23-implementation
mossid Jul 31, 2019
6be03df
Merge branch 'joon/ics-23-implementation' into joon/ics-02-implementa…
mossid Jul 31, 2019
e7f6708
cli refactor in progress
mossid Jul 31, 2019
0d134d5
cli refactor in progress
mossid Jul 31, 2019
fcad487
add Query to boolean.go
mossid Aug 1, 2019
3142d4b
Merge branch 'joon/store-mapping' into joon/ics-23-implementation
mossid Aug 1, 2019
6de0ed5
fix key
mossid Aug 1, 2019
05d39a1
Merge branch 'joon/store-mapping' into joon/ics-23-implementation
mossid Aug 1, 2019
811b384
Merge branch 'joon/ics-23-implementation' into joon/ics-02-implementa…
mossid Aug 1, 2019
62b7d75
fix cli / merkle test
mossid Aug 1, 2019
6dc912f
godoc cleanup
alexanderbez Aug 7, 2019
63c6f3c
godoc cleanup
alexanderbez Aug 7, 2019
b6441c0
godoc cleanup
alexanderbez Aug 7, 2019
4d723ae
godoc cleanup
alexanderbez Aug 7, 2019
244d2c2
godoc cleanup
alexanderbez Aug 7, 2019
7bf4d57
merge from ics04 branch
mossid Aug 15, 2019
7471bdf
Merge branch 'joon/store-mapping' of github.com:cosmos/cosmos-sdk int…
mossid Aug 15, 2019
3c86363
Merge branch 'joon/store-mapping' into joon/ics-23-implementation
mossid Aug 15, 2019
32cb0ca
merge from ics04 branch
mossid Aug 15, 2019
af260c8
Merge branch 'joon/ics-23-implementation' into joon/ics-02-implementa…
mossid Aug 15, 2019
17f18d7
merge from ics04 branch
mossid Aug 15, 2019
71d2620
fix lint
mossid Aug 15, 2019
073a67a
Merge branch 'joon/ics-23-implementation' into joon/ics-02-implementa…
mossid Aug 15, 2019
04543f8
Merge branch 'master' of github.com:cosmos/cosmos-sdk into joon/store…
mossid Sep 2, 2019
59d2b3e
Merge branch 'joon/store-mapping' into joon/ics-23-implementation
mossid Sep 2, 2019
6d1088f
Merge branch 'joon/ics-23-implementation' into joon/ics-02-implementa…
mossid Sep 2, 2019
10d1c46
Apply suggestions from code review
mossid Sep 10, 2019
09e6600
applying review in progress
mossid Sep 11, 2019
6f5f633
Merge branch 'joon/store-mapping' of github.com:cosmos/cosmos-sdk int…
mossid Sep 11, 2019
4116bb7
apply review - make querier interface
mossid Sep 11, 2019
8040c81
Merge branch 'master' of github.com:cosmos/cosmos-sdk into joon/store…
mossid Sep 17, 2019
48bb32d
Merge branch 'joon/store-mapping' into joon/ics-23-implementation
mossid Sep 17, 2019
9b63a6b
fix dependency
mossid Sep 17, 2019
a7df43c
Merge branch 'joon/ics-23-implementation' into joon/ics-02-implementa…
mossid Sep 17, 2019
acaaaf2
fix dependency
mossid Sep 17, 2019
828badd
revise querier interface to work both on cli & store
mossid Sep 18, 2019
1e64e92
revise querier interface to work both on cli & store
mossid Sep 18, 2019
b4d7491
reflect downstream change
mossid Sep 18, 2019
a59d1e7
Merge branch 'joon/store-mapping' into joon/ics-23-implementation
mossid Sep 18, 2019
bb09ad9
Merge branch 'joon/ics-23-implementation' into joon/ics-02-implementa…
mossid Sep 18, 2019
de1a045
fix cli
mossid Sep 18, 2019
9f63629
rm commented lines
mossid Sep 28, 2019
b4e71e1
address review in progress
mossid Sep 28, 2019
6b966a3
rename Path -> Prefix
mossid Oct 1, 2019
21bd8d0
Store accessor upstream changes (#5119)
fedekunze Oct 1, 2019
af2564b
Merge branch 'joon/store-mapping' of https://github.com/cosmos/cosmos…
fedekunze Oct 1, 2019
303ebf3
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into jo…
fedekunze Oct 1, 2019
9b3b120
Merge branch 'master' into joon/store-mapping
fedekunze Oct 1, 2019
18f8d70
Merge branch 'joon/store-mapping' of https://github.com/cosmos/cosmos…
fedekunze Oct 1, 2019
df5b21a
add comments, reformat merkle querier
mossid Oct 1, 2019
7afe221
Merge branch 'joon/ics-23-implementation' of github.com:cosmos/cosmos…
mossid Oct 1, 2019
1ac982c
rm merkle/utils
mossid Oct 1, 2019
fa04419
ICS 23 upstream changes (#5120)
fedekunze Oct 1, 2019
0d5a317
downstream changes
fedekunze Oct 1, 2019
db8d382
update Value
fedekunze Oct 1, 2019
02b31a5
Merge branch 'joon/ics-23-implementation' of https://github.com/cosmo…
fedekunze Oct 1, 2019
4d518f2
update test
fedekunze Oct 1, 2019
8a3e5ea
fix
fedekunze Oct 1, 2019
9975a1d
ICS 02 upstream changes (#5122)
fedekunze Oct 1, 2019
cc404a0
cleanup types and submodule
fedekunze Oct 2, 2019
d93a0ae
more cleanup and godocs
fedekunze Oct 2, 2019
9b6afe9
remove counterPartyManager/State and cleanup
fedekunze Oct 2, 2019
c8a0ab4
implement SubmitMisbehaviour and refactor
fedekunze Oct 2, 2019
4483182
errors
fedekunze Oct 4, 2019
23fbb5d
events
fedekunze Oct 4, 2019
ebecbce
fix test
fedekunze Oct 4, 2019
0e85ed0
refactors
fedekunze Oct 4, 2019
a7d2d98
remove Mapping
fedekunze Oct 7, 2019
1b7e466
remove store accessors
fedekunze Oct 7, 2019
c09a84c
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into jo…
fedekunze Oct 7, 2019
99c586b
Merge branch 'joon/ics-23-implementation' of https://github.com/cosmo…
fedekunze Oct 7, 2019
02bd6f7
proposed refactor
fedekunze Oct 7, 2019
0e37d75
remove store accessors from ICS02
fedekunze Oct 7, 2019
8dec96f
refactor queriers, handler and clean keeper
fedekunze Oct 8, 2019
83f4c1b
logger and tx long description
fedekunze Oct 8, 2019
178912f
ineffassign
fedekunze Oct 8, 2019
9a225e9
Apply suggestions from code review
fedekunze Oct 8, 2019
fe7da5f
Apply suggestions from code review
fedekunze Oct 8, 2019
21f7d2c
add verification functions
fedekunze Oct 9, 2019
cf347bf
ICS02 module.go
fedekunze Oct 9, 2019
5514e9e
top level x/ibc structure
fedekunze Oct 9, 2019
a1c22e9
Merge branch 'master' into joon/ics-23-implementation
fedekunze Oct 15, 2019
a8ceb45
Update x/ibc/02-client/client/cli/query.go
fedekunze Oct 15, 2019
956eb5c
Update x/ibc/02-client/types/tendermint/consensus_state.go
fedekunze Oct 15, 2019
2cc23b2
Merge branch 'joon/ics-23-implementation' of https://github.com/cosmo…
fedekunze Oct 15, 2019
2e1e894
Merge branch 'joon/ics-02-implementation' of https://github.com/cosmo…
fedekunze Oct 15, 2019
c573d57
address some of the review comments
fedekunze Oct 15, 2019
6af2ce7
minor UX improvements
fedekunze Oct 16, 2019
8be3af7
rename pkg
fedekunze Oct 16, 2019
53ab47d
fixes
fedekunze Oct 16, 2019
d3a533a
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into jo…
fedekunze Oct 16, 2019
7ba777e
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into jo…
fedekunze Oct 18, 2019
499abb4
refactor ICS23
fedekunze Oct 18, 2019
a925d88
cleanup types
fedekunze Oct 18, 2019
53f5fad
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into jo…
fedekunze Oct 21, 2019
c12c298
implement batch verification
fedekunze Oct 21, 2019
a34b741
gosimple suggestion
fedekunze Oct 21, 2019
bf4f096
Merge branch 'master' into joon/ics-23-implementation
fedekunze Oct 21, 2019
386489b
Merge branch 'joon/ics-23-implementation' of https://github.com/cosmo…
fedekunze Oct 21, 2019
383ba49
merge ICS23
fedekunze Oct 21, 2019
9b77275
various fixes; remove legacy tests; remove commitment path query
fedekunze Oct 22, 2019
40fca1a
alias
fedekunze Oct 22, 2019
1eaf55e
Merge branch 'joon/ics-23-implementation' of https://github.com/cosmo…
fedekunze Oct 22, 2019
deceeb8
minor updates from ICS23
fedekunze Oct 22, 2019
2a1a144
renaming
fedekunze Oct 22, 2019
714e6e2
update verification and rename root funcs
fedekunze Oct 22, 2019
de13f5a
move querier to x/ibc
fedekunze Oct 22, 2019
aae117f
update query.go to use 'custom/...' query path
fedekunze Oct 22, 2019
f8fd580
add tests
AdityaSripal Oct 22, 2019
cbc1106
ICS 24 Implementation (#5229)
AdityaSripal Oct 22, 2019
f8d99ca
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into jo…
fedekunze Oct 23, 2019
23ae994
flatten ICS23 structure
fedekunze Oct 23, 2019
e1fa5f8
fix ApplyPrefix
fedekunze Oct 23, 2019
7222642
Merge branch 'joon/ics-23-implementation' of https://github.com/cosmo…
fedekunze Oct 23, 2019
4f89602
updates from ICS23 and ICS24
fedekunze Oct 23, 2019
22f874a
msg.ValidateBasic and ADR09 evidence interface
fedekunze Oct 23, 2019
2edb03f
complete types testing
AdityaSripal Oct 23, 2019
5783b03
merge
AdityaSripal Oct 23, 2019
696db2e
delete empty test file
AdityaSripal Oct 23, 2019
69db1f2
remove ibc errors from core error package
AdityaSripal Oct 23, 2019
102ab3d
custom JSON marshaling
fedekunze Oct 24, 2019
33312c2
start batch-verify tests
AdityaSripal Oct 24, 2019
49d08e3
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into jo…
fedekunze Oct 25, 2019
5239720
minor changes on commitment types
fedekunze Oct 25, 2019
e048a6c
R4R - Store consensus state correctly (#5242)
chengwenxi Oct 25, 2019
093c004
Merge branch 'joon/ics-23-implementation' of https://github.com/cosmo…
fedekunze Oct 25, 2019
3965928
Merge branch 'joon/ics-02-implementation' of https://github.com/cosmo…
fedekunze Oct 25, 2019
0c187bf
update alias
fedekunze Oct 25, 2019
d1f71dd
Merge branch 'master' into joon/ics-23-implementation
fedekunze Oct 30, 2019
0a461b5
use testsuite
AdityaSripal Oct 30, 2019
dac68df
Merge branch 'joon/ics-23-implementation' of https://github.com/cosmo…
AdityaSripal Oct 30, 2019
7f9c166
Integrate Evidence Implementation into ICS-02 (#5258)
AdityaSripal Nov 4, 2019
a74ebf3
Merge branch 'master' into joon/ics-23-implementation
fedekunze Nov 4, 2019
6d580aa
finish tendermint tests
AdityaSripal Nov 5, 2019
0dd779e
Merge branch 'joon/ics-02-implementation' of https://github.com/cosmo…
AdityaSripal Nov 5, 2019
e875ca7
complete merge
AdityaSripal Nov 5, 2019
cd0aa22
Add tests for msgs
AdityaSripal Nov 5, 2019
0c8b759
upstream changes
fedekunze Nov 5, 2019
c6fa07b
fix
fedekunze Nov 5, 2019
17abbda
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into jo…
fedekunze Nov 5, 2019
820482f
upstream changes
fedekunze Nov 5, 2019
962979d
ICS23 changes
fedekunze Nov 5, 2019
b5442d3
fix cons state
fedekunze Nov 5, 2019
7c67236
context changes
fedekunze Nov 5, 2019
4866753
Merge branch 'joon/ics-23-implementation' of https://github.com/cosmo…
fedekunze Nov 5, 2019
928b1de
conflicts
fedekunze Nov 5, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions x/ibc/02-client/alias.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package client

// nolint
// autogenerated code using github.com/rigelrozanski/multitool
// aliases generated for the following subdirectories:
// ALIASGEN: github.com/cosmos/cosmos-sdk/x/ibc/02-client/keeper
// ALIASGEN: github.com/cosmos/cosmos-sdk/x/ibc/02-client/types

import (
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/keeper"
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/types"
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/types/errors"
)

const (
DefaultCodespace = errors.DefaultCodespace
CodeClientExists = errors.CodeClientExists
CodeClientNotFound = errors.CodeClientNotFound
CodeClientFrozen = errors.CodeClientFrozen
CodeConsensusStateNotFound = errors.CodeConsensusStateNotFound
CodeInvalidConsensusState = errors.CodeInvalidConsensusState
CodeClientTypeNotFound = errors.CodeClientTypeNotFound
CodeInvalidClientType = errors.CodeInvalidClientType
CodeRootNotFound = errors.CodeRootNotFound
CodeInvalidHeader = errors.CodeInvalidHeader
CodeInvalidEvidence = errors.CodeInvalidEvidence
AttributeKeyClientID = types.AttributeKeyClientID
SubModuleName = types.SubModuleName
StoreKey = types.StoreKey
RouterKey = types.RouterKey
QuerierRoute = types.QuerierRoute
QueryClientState = types.QueryClientState
QueryConsensusState = types.QueryConsensusState
QueryVerifiedRoot = types.QueryVerifiedRoot
)

var (
// functions aliases
NewKeeper = keeper.NewKeeper
QuerierClientState = keeper.QuerierClientState
QuerierConsensusState = keeper.QuerierConsensusState
QuerierVerifiedRoot = keeper.QuerierVerifiedRoot
RegisterCodec = types.RegisterCodec
ErrClientExists = errors.ErrClientExists
ErrClientNotFound = errors.ErrClientNotFound
ErrClientFrozen = errors.ErrClientFrozen
ErrConsensusStateNotFound = errors.ErrConsensusStateNotFound
ErrInvalidConsensus = errors.ErrInvalidConsensus
ErrClientTypeNotFound = errors.ErrClientTypeNotFound
ErrInvalidClientType = errors.ErrInvalidClientType
ErrRootNotFound = errors.ErrRootNotFound
ErrInvalidHeader = errors.ErrInvalidHeader
ErrInvalidEvidence = errors.ErrInvalidEvidence
ClientStatePath = types.ClientStatePath
ClientTypePath = types.ClientTypePath
ConsensusStatePath = types.ConsensusStatePath
RootPath = types.RootPath
KeyClientState = types.KeyClientState
KeyClientType = types.KeyClientType
KeyConsensusState = types.KeyConsensusState
KeyRoot = types.KeyRoot
NewMsgCreateClient = types.NewMsgCreateClient
NewMsgUpdateClient = types.NewMsgUpdateClient
NewMsgSubmitMisbehaviour = types.NewMsgSubmitMisbehaviour
NewQueryClientStateParams = types.NewQueryClientStateParams
NewQueryCommitmentRootParams = types.NewQueryCommitmentRootParams
NewClientState = types.NewClientState

// variable aliases
SubModuleCdc = types.SubModuleCdc
EventTypeCreateClient = types.EventTypeCreateClient
EventTypeUpdateClient = types.EventTypeUpdateClient
EventTypeSubmitMisbehaviour = types.EventTypeSubmitMisbehaviour
AttributeValueCategory = types.AttributeValueCategory
)

type (
Keeper = keeper.Keeper
MsgCreateClient = types.MsgCreateClient
MsgUpdateClient = types.MsgUpdateClient
MsgSubmitMisbehaviour = types.MsgSubmitMisbehaviour
QueryClientStateParams = types.QueryClientStateParams
QueryCommitmentRootParams = types.QueryCommitmentRootParams
State = types.State
)
258 changes: 258 additions & 0 deletions x/ibc/02-client/client/cli/query.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,258 @@
package cli

import (
"errors"
"fmt"
"strconv"
"strings"

"github.com/spf13/cobra"

tmtypes "github.com/tendermint/tendermint/types"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/context"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/client/utils"
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported"
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/types"
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/types/tendermint"
commitment "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment"
)

// GetQueryCmd returns the query commands for IBC clients
func GetQueryCmd(queryRoute string, cdc *codec.Codec) *cobra.Command {
ics02ClientQueryCmd := &cobra.Command{
Use: "client",
Short: "IBC client query subcommands",
DisableFlagParsing: true,
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
SuggestionsMinimumDistance: 2,
}

ics02ClientQueryCmd.AddCommand(client.GetCommands(
GetCmdQueryConsensusState(queryRoute, cdc),
GetCmdQueryHeader(cdc),
GetCmdQueryClientState(queryRoute, cdc),
GetCmdQueryRoot(queryRoute, cdc),
GetCmdNodeConsensusState(queryRoute, cdc),
GetCmdQueryPath(queryRoute, cdc),
)...)
return ics02ClientQueryCmd
}

// GetCmdQueryClientState defines the command to query the state of a client with
// a given id as defined in https://github.com/cosmos/ics/tree/master/spec/ics-002-client-semantics#query
func GetCmdQueryClientState(queryRoute string, cdc *codec.Codec) *cobra.Command {
return &cobra.Command{
Use: "state [client-id]",
Short: "Query a client state",
Long: strings.TrimSpace(
fmt.Sprintf(`Query stored client state

Example:
$ %s query ibc client state [client-id]
`, version.ClientName),
),
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
cliCtx := context.NewCLIContext().WithCodec(cdc)
clientID := args[0]
if strings.TrimSpace(clientID) == "" {
return errors.New("client ID can't be blank")
}

bz, err := cdc.MarshalJSON(types.NewQueryClientStateParams(clientID))
if err != nil {
return err
}

res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryClientState), bz)
if err != nil {
return err
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
}

var clientState types.State
if err := cdc.UnmarshalJSON(res, &clientState); err != nil {
return err
}

return cliCtx.PrintOutput(clientState)
},
}
}

// GetCmdQueryRoot defines the command to query
func GetCmdQueryRoot(queryRoute string, cdc *codec.Codec) *cobra.Command {
return &cobra.Command{
Use: "root [client-id] [height]",
Short: "Query a verified commitment root",
Long: strings.TrimSpace(
fmt.Sprintf(`Query an already verified commitment root at a specific height for a particular client

Example:
$ %s query ibc client root [client-id] [height]
`, version.ClientName),
),
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
cliCtx := context.NewCLIContext().WithCodec(cdc)
clientID := args[0]
if strings.TrimSpace(clientID) == "" {
return errors.New("client ID can't be blank")
}

height, err := strconv.ParseUint(args[1], 10, 64)
if err != nil {
return fmt.Errorf("expected integer height, got: %v", args[1])
}

bz, err := cdc.MarshalJSON(types.NewQueryCommitmentRootParams(clientID, height))
if err != nil {
return err
}

res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryVerifiedRoot), bz)
if err != nil {
return err
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
}

var root commitment.RootI
if err := cdc.UnmarshalJSON(res, &root); err != nil {
return err
}

return cliCtx.PrintOutput(root)
},
}
}

// GetCmdQueryConsensusState defines the command to query the consensus state of
// the chain as defined in https://github.com/cosmos/ics/tree/master/spec/ics-002-client-semantics#query
func GetCmdQueryConsensusState(queryRoute string, cdc *codec.Codec) *cobra.Command {
return &cobra.Command{
Use: "consensus-state [client-id]",
Short: "Query the latest consensus state of the client",
Long: strings.TrimSpace(
fmt.Sprintf(`Query the consensus state for a particular client

Example:
$ %s query ibc client consensus-state [client-id]
`, version.ClientName),
),
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
cliCtx := context.NewCLIContext().WithCodec(cdc)
clientID := args[0]
if strings.TrimSpace(clientID) == "" {
return errors.New("client ID can't be blank")
}

bz, err := cdc.MarshalJSON(types.NewQueryClientStateParams(clientID))
if err != nil {
return err
}

res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryConsensusState), bz)
if err != nil {
return err
}

var consensusState exported.ConsensusState
if err := cdc.UnmarshalJSON(res, &consensusState); err != nil {
return err
}

return cliCtx.PrintOutput(consensusState)
},
}
}

// GetCmdQueryHeader defines the command to query the latest header on the chain
func GetCmdQueryHeader(cdc *codec.Codec) *cobra.Command {
return &cobra.Command{
Use: "header",
Short: "Query the latest header of the running chain",
Long: strings.TrimSpace(fmt.Sprintf(`Query the latest Tendermint header

Example:
$ %s query ibc client header
`, version.ClientName),
),
RunE: func(cmd *cobra.Command, args []string) error {
cliCtx := context.NewCLIContext().WithCodec(cdc)

header, err := utils.GetTendermintHeader(cliCtx)
if err != nil {
return err
}

return cliCtx.PrintOutput(header)
},
}
}

// GetCmdNodeConsensusState defines the command to query the latest consensus state of a node
// The result is feed to client creation
func GetCmdNodeConsensusState(queryRoute string, cdc *codec.Codec) *cobra.Command {
return &cobra.Command{
Use: "node-state",
Short: "Query a node consensus state",
Long: strings.TrimSpace(
fmt.Sprintf(`Query a node consensus state. This result is feed to the client creation transaction.

Example:
$ %s query ibc client node-state
`, version.ClientName),
),
Args: cobra.ExactArgs(0),
RunE: func(cmd *cobra.Command, args []string) error {
cliCtx := context.NewCLIContext().WithCodec(cdc)

node, err := cliCtx.GetNode()
if err != nil {
return err
}

info, err := node.ABCIInfo()
if err != nil {
return err
}

height := info.Response.LastBlockHeight
prevHeight := height - 1

commit, err := node.Commit(&height)
if err != nil {
return err
}

validators, err := node.Validators(&prevHeight)
if err != nil {
return err
}

state := tendermint.ConsensusState{
ChainID: commit.ChainID,
Height: uint64(commit.Height),
Root: commitment.NewRoot(commit.AppHash),
NextValidatorSet: tmtypes.NewValidatorSet(validators.Validators),
}

return cliCtx.PrintOutput(state)
},
}
}

// GetCmdQueryPath defines the command to query the commitment path.
func GetCmdQueryPath(storeName string, cdc *codec.Codec) *cobra.Command {
return &cobra.Command{
Use: "path",
Short: "Query the commitment path of the running chain",
RunE: func(cmd *cobra.Command, args []string) error {
ctx := context.NewCLIContext().WithCodec(cdc)
path := commitment.NewPrefix([]byte("ibc"))
return ctx.PrintOutput(path)
},
}
}
Loading