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

add GetChainID #19

Merged
merged 1 commit into from
Nov 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions modules/core/02-client/legacy/v100/solomachine.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ func (cs ClientState) ClientType() string {
panic("legacy solo machine is deprecated!")
}

// GetChainID panics!
func (cs ClientState) GetChainID() string {
panic("legacy solo machine is deprecated!")
}

// GetLatestHeight panics!
func (cs ClientState) GetLatestHeight() exported.Height {
panic("legacy solo machine is deprecated!")
Expand Down
3 changes: 3 additions & 0 deletions modules/core/exported/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type ClientState interface {
proto.Message

ClientType() string
GetChainID() string
GetLatestHeight() Height
Validate() error

Expand Down Expand Up @@ -204,6 +205,7 @@ type Misbehaviour interface {
proto.Message

ClientType() string
GetChainID() string
GetClientID() string
ValidateBasic() error
}
Expand All @@ -213,6 +215,7 @@ type Header interface {
proto.Message

ClientType() string
GetChainID() string
GetHeight() Height
ValidateBasic() error
}
Expand Down
5 changes: 5 additions & 0 deletions modules/light-clients/01-dymint/types/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ func (h Header) ClientType() string {
return exported.Dymint
}

// GetChainID returns the chain-id
func (h Header) GetChainID() string {
return h.Header.ChainID
}

// GetHeight returns the current height. It returns 0 if the dymint
// header is nil.
// NOTE: the header.Header is checked to be non nil in ValidateBasic.
Expand Down
6 changes: 6 additions & 0 deletions modules/light-clients/01-dymint/types/misbehaviour.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ func (misbehaviour Misbehaviour) ClientType() string {
return exported.Dymint
}

// GetChainID returns the chain-id
func (misbehaviour Misbehaviour) GetChainID() string {
// assuming Header1.hainID and Header2.hainID are same as checked in ValidateBasic
return misbehaviour.Header1.GetChainID()
}

// GetClientID returns the ID of the client that committed a misbehaviour.
func (misbehaviour Misbehaviour) GetClientID() string {
return misbehaviour.ClientId
Expand Down
5 changes: 5 additions & 0 deletions modules/light-clients/06-solomachine/types/client_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ func (cs ClientState) ClientType() string {
return exported.Solomachine
}

// GetChainID returns the chain-id
func (cs ClientState) GetChainID() string {
return ""
}

// GetLatestHeight returns the latest sequence number.
// Return exported.Height to satisfy ClientState interface
// Revision number is always 0 for a solo-machine.
Expand Down
5 changes: 5 additions & 0 deletions modules/light-clients/06-solomachine/types/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ func (Header) ClientType() string {
return exported.Solomachine
}

// GetChainID returns the chain-id
func (h Header) GetChainID() string {
return ""
}

// GetHeight returns the current sequence number as the height.
// Return clientexported.Height to satisfy interface
// Revision number is always 0 for a solo-machine
Expand Down
5 changes: 5 additions & 0 deletions modules/light-clients/06-solomachine/types/misbehaviour.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ func (misbehaviour Misbehaviour) ClientType() string {
return exported.Solomachine
}

// GetChainID returns the chain-id
func (misbehaviour Misbehaviour) GetChainID() string {
return ""
}

// GetClientID returns the ID of the client that committed a misbehaviour.
func (misbehaviour Misbehaviour) GetClientID() string {
return misbehaviour.ClientId
Expand Down
5 changes: 5 additions & 0 deletions modules/light-clients/07-tendermint/types/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ func (h Header) ClientType() string {
return exported.Tendermint
}

// GetChainID returns the chain-id
func (h Header) GetChainID() string {
return h.Header.ChainID
}

// GetHeight returns the current height. It returns 0 if the tendermint
// header is nil.
// NOTE: the header.Header is checked to be non nil in ValidateBasic.
Expand Down
6 changes: 6 additions & 0 deletions modules/light-clients/07-tendermint/types/misbehaviour.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ func (misbehaviour Misbehaviour) ClientType() string {
return exported.Tendermint
}

// GetChainID returns the chain-id
func (misbehaviour Misbehaviour) GetChainID() string {
// assuming Header1.hainID and Header2.hainID are same as checked in ValidateBasic
return misbehaviour.Header1.GetChainID()
}

// GetClientID returns the ID of the client that committed a misbehaviour.
func (misbehaviour Misbehaviour) GetClientID() string {
return misbehaviour.ClientId
Expand Down