Rename all methods IsEmpty to Empty to be consistent with all codebase (#6409)
Co-authored-by: Alessio Treglia <alessio@tendermint.com>
This commit is contained in:
parent
49597b19ec
commit
b09d6728ec
|
@ -61,6 +61,7 @@ older clients.
|
|||
|
||||
### API Breaking Changes
|
||||
|
||||
* [\#6409](https://github.com/cosmos/cosmos-sdk/pull/6409) Rename all IsEmpty methods to Empty across the codebase and enforce consistency.
|
||||
* [\#6231](https://github.com/cosmos/cosmos-sdk/pull/6231) Simplify `AppModule` interface, `Route` and `NewHandler` methods become only `Route`
|
||||
and returns a new `Route` type.
|
||||
* [\#6212](https://github.com/cosmos/cosmos-sdk/pull/6212) Remove `Get*` prefixes from key construction functions
|
||||
|
|
|
@ -48,8 +48,8 @@ func (data GenesisState) Equal(other GenesisState) bool {
|
|||
data.VotingParams.Equal(other.VotingParams)
|
||||
}
|
||||
|
||||
// IsEmpty returns true if a GenesisState is empty
|
||||
func (data GenesisState) IsEmpty() bool {
|
||||
// Empty returns true if a GenesisState is empty
|
||||
func (data GenesisState) Empty() bool {
|
||||
return data.Equal(GenesisState{})
|
||||
}
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ func (c Counterparty) ValidateBasic() error {
|
|||
if err := host.ClientIdentifierValidator(c.ClientID); err != nil {
|
||||
return sdkerrors.Wrap(err, "invalid counterparty client ID")
|
||||
}
|
||||
if c.Prefix.IsEmpty() {
|
||||
if c.Prefix.Empty() {
|
||||
return sdkerrors.Wrap(ErrInvalidCounterparty, "counterparty prefix cannot be empty")
|
||||
}
|
||||
return nil
|
||||
|
|
|
@ -109,7 +109,7 @@ func (msg MsgConnectionOpenTry) ValidateBasic() error {
|
|||
return sdkerrors.Wrap(sdkerrors.ErrInvalidVersion, "version can't be blank")
|
||||
}
|
||||
}
|
||||
if msg.ProofInit.IsEmpty() || msg.ProofConsensus.IsEmpty() {
|
||||
if msg.ProofInit.Empty() || msg.ProofConsensus.Empty() {
|
||||
return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof")
|
||||
}
|
||||
if err := msg.ProofInit.ValidateBasic(); err != nil {
|
||||
|
@ -177,7 +177,7 @@ func (msg MsgConnectionOpenAck) ValidateBasic() error {
|
|||
if strings.TrimSpace(msg.Version) == "" {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidVersion, "version can't be blank")
|
||||
}
|
||||
if msg.ProofTry.IsEmpty() || msg.ProofConsensus.IsEmpty() {
|
||||
if msg.ProofTry.Empty() || msg.ProofConsensus.Empty() {
|
||||
return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof")
|
||||
}
|
||||
if err := msg.ProofTry.ValidateBasic(); err != nil {
|
||||
|
@ -238,7 +238,7 @@ func (msg MsgConnectionOpenConfirm) ValidateBasic() error {
|
|||
if err := host.ConnectionIdentifierValidator(msg.ConnectionID); err != nil {
|
||||
return sdkerrors.Wrap(err, "invalid connection ID")
|
||||
}
|
||||
if msg.ProofAck.IsEmpty() {
|
||||
if msg.ProofAck.Empty() {
|
||||
return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof")
|
||||
}
|
||||
if err := msg.ProofAck.ValidateBasic(); err != nil {
|
||||
|
|
|
@ -101,7 +101,7 @@ func (msg MsgChannelOpenTry) ValidateBasic() error {
|
|||
if strings.TrimSpace(msg.CounterpartyVersion) == "" {
|
||||
return sdkerrors.Wrap(ErrInvalidCounterparty, "counterparty version cannot be blank")
|
||||
}
|
||||
if msg.ProofInit.IsEmpty() {
|
||||
if msg.ProofInit.Empty() {
|
||||
return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof")
|
||||
}
|
||||
if err := msg.ProofInit.ValidateBasic(); err != nil {
|
||||
|
@ -162,7 +162,7 @@ func (msg MsgChannelOpenAck) ValidateBasic() error {
|
|||
if strings.TrimSpace(msg.CounterpartyVersion) == "" {
|
||||
return sdkerrors.Wrap(ErrInvalidCounterparty, "counterparty version cannot be blank")
|
||||
}
|
||||
if msg.ProofTry.IsEmpty() {
|
||||
if msg.ProofTry.Empty() {
|
||||
return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof")
|
||||
}
|
||||
if err := msg.ProofTry.ValidateBasic(); err != nil {
|
||||
|
@ -219,7 +219,7 @@ func (msg MsgChannelOpenConfirm) ValidateBasic() error {
|
|||
if err := host.ChannelIdentifierValidator(msg.ChannelID); err != nil {
|
||||
return sdkerrors.Wrap(err, "invalid channel ID")
|
||||
}
|
||||
if msg.ProofAck.IsEmpty() {
|
||||
if msg.ProofAck.Empty() {
|
||||
return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof")
|
||||
}
|
||||
if err := msg.ProofAck.ValidateBasic(); err != nil {
|
||||
|
@ -321,7 +321,7 @@ func (msg MsgChannelCloseConfirm) ValidateBasic() error {
|
|||
if err := host.ChannelIdentifierValidator(msg.ChannelID); err != nil {
|
||||
return sdkerrors.Wrap(err, "invalid channel ID")
|
||||
}
|
||||
if msg.ProofInit.IsEmpty() {
|
||||
if msg.ProofInit.Empty() {
|
||||
return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof")
|
||||
}
|
||||
if err := msg.ProofInit.ValidateBasic(); err != nil {
|
||||
|
@ -366,7 +366,7 @@ func (msg MsgPacket) Route() string {
|
|||
|
||||
// ValidateBasic implements sdk.Msg
|
||||
func (msg MsgPacket) ValidateBasic() error {
|
||||
if msg.Proof.IsEmpty() {
|
||||
if msg.Proof.Empty() {
|
||||
return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof")
|
||||
}
|
||||
if err := msg.Proof.ValidateBasic(); err != nil {
|
||||
|
@ -427,7 +427,7 @@ func (msg MsgTimeout) Route() string {
|
|||
|
||||
// ValidateBasic implements sdk.Msg
|
||||
func (msg MsgTimeout) ValidateBasic() error {
|
||||
if msg.Proof.IsEmpty() {
|
||||
if msg.Proof.Empty() {
|
||||
return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof")
|
||||
}
|
||||
if err := msg.Proof.ValidateBasic(); err != nil {
|
||||
|
@ -479,7 +479,7 @@ func (msg MsgAcknowledgement) Route() string {
|
|||
|
||||
// ValidateBasic implements sdk.Msg
|
||||
func (msg MsgAcknowledgement) ValidateBasic() error {
|
||||
if msg.Proof.IsEmpty() {
|
||||
if msg.Proof.Empty() {
|
||||
return sdkerrors.Wrap(commitmenttypes.ErrInvalidProof, "cannot submit an empty proof")
|
||||
}
|
||||
if err := msg.Proof.ValidateBasic(); err != nil {
|
||||
|
|
|
@ -54,7 +54,7 @@ func (cs ConsensusState) GetTimestamp() uint64 {
|
|||
|
||||
// ValidateBasic defines a basic validation for the tendermint consensus state.
|
||||
func (cs ConsensusState) ValidateBasic() error {
|
||||
if cs.Root == nil || cs.Root.IsEmpty() {
|
||||
if cs.Root == nil || cs.Root.Empty() {
|
||||
return sdkerrors.Wrap(clienttypes.ErrInvalidConsensus, "root cannot be empty")
|
||||
}
|
||||
if cs.ValidatorSet == nil {
|
||||
|
|
|
@ -14,7 +14,7 @@ package exported
|
|||
type Root interface {
|
||||
GetCommitmentType() Type
|
||||
GetHash() []byte
|
||||
IsEmpty() bool
|
||||
Empty() bool
|
||||
}
|
||||
|
||||
// Prefix implements spec:CommitmentPrefix.
|
||||
|
@ -22,7 +22,7 @@ type Root interface {
|
|||
type Prefix interface {
|
||||
GetCommitmentType() Type
|
||||
Bytes() []byte
|
||||
IsEmpty() bool
|
||||
Empty() bool
|
||||
}
|
||||
|
||||
// Path implements spec:CommitmentPath.
|
||||
|
@ -30,7 +30,7 @@ type Prefix interface {
|
|||
type Path interface {
|
||||
GetCommitmentType() Type
|
||||
String() string
|
||||
IsEmpty() bool
|
||||
Empty() bool
|
||||
}
|
||||
|
||||
// Proof implements spec:CommitmentProof.
|
||||
|
@ -41,7 +41,7 @@ type Proof interface {
|
|||
GetCommitmentType() Type
|
||||
VerifyMembership(Root, Path, []byte) error
|
||||
VerifyNonMembership(Root, Path) error
|
||||
IsEmpty() bool
|
||||
Empty() bool
|
||||
|
||||
ValidateBasic() error
|
||||
}
|
||||
|
|
|
@ -36,8 +36,8 @@ func (MerkleRoot) GetCommitmentType() exported.Type {
|
|||
return exported.Merkle
|
||||
}
|
||||
|
||||
// IsEmpty returns true if the root is empty
|
||||
func (mr MerkleRoot) IsEmpty() bool {
|
||||
// Empty returns true if the root is empty
|
||||
func (mr MerkleRoot) Empty() bool {
|
||||
return len(mr.GetHash()) == 0
|
||||
}
|
||||
|
||||
|
@ -60,8 +60,8 @@ func (mp MerklePrefix) Bytes() []byte {
|
|||
return mp.KeyPrefix
|
||||
}
|
||||
|
||||
// IsEmpty returns true if the prefix is empty
|
||||
func (mp MerklePrefix) IsEmpty() bool {
|
||||
// Empty returns true if the prefix is empty
|
||||
func (mp MerklePrefix) Empty() bool {
|
||||
return len(mp.Bytes()) == 0
|
||||
}
|
||||
|
||||
|
@ -98,8 +98,8 @@ func (mp MerklePath) Pretty() string {
|
|||
return path
|
||||
}
|
||||
|
||||
// IsEmpty returns true if the path is empty
|
||||
func (mp MerklePath) IsEmpty() bool {
|
||||
// Empty returns true if the path is empty
|
||||
func (mp MerklePath) Empty() bool {
|
||||
return len(mp.KeyPath.Keys) == 0
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,7 @@ func ApplyPrefix(prefix exported.Prefix, path string) (MerklePath, error) {
|
|||
return MerklePath{}, err
|
||||
}
|
||||
|
||||
if prefix == nil || prefix.IsEmpty() {
|
||||
if prefix == nil || prefix.Empty() {
|
||||
return MerklePath{}, sdkerrors.Wrap(ErrInvalidPrefix, "prefix can't be empty")
|
||||
}
|
||||
return NewMerklePath([]string{string(prefix.Bytes()), path}), nil
|
||||
|
@ -129,7 +129,7 @@ func (MerkleProof) GetCommitmentType() exported.Type {
|
|||
|
||||
// VerifyMembership verifies the membership pf a merkle proof against the given root, path, and value.
|
||||
func (proof MerkleProof) VerifyMembership(root exported.Root, path exported.Path, value []byte) error {
|
||||
if proof.IsEmpty() || root == nil || root.IsEmpty() || path == nil || path.IsEmpty() || len(value) == 0 {
|
||||
if proof.Empty() || root == nil || root.Empty() || path == nil || path.Empty() || len(value) == 0 {
|
||||
return sdkerrors.Wrap(ErrInvalidMerkleProof, "empty params or proof")
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,7 @@ func (proof MerkleProof) VerifyMembership(root exported.Root, path exported.Path
|
|||
|
||||
// VerifyNonMembership verifies the absence of a merkle proof against the given root and path.
|
||||
func (proof MerkleProof) VerifyNonMembership(root exported.Root, path exported.Path) error {
|
||||
if proof.IsEmpty() || root == nil || root.IsEmpty() || path == nil || path.IsEmpty() {
|
||||
if proof.Empty() || root == nil || root.Empty() || path == nil || path.Empty() {
|
||||
return sdkerrors.Wrap(ErrInvalidMerkleProof, "empty params or proof")
|
||||
}
|
||||
|
||||
|
@ -147,14 +147,14 @@ func (proof MerkleProof) VerifyNonMembership(root exported.Root, path exported.P
|
|||
return runtime.VerifyAbsence(proof.Proof, root.GetHash(), path.String())
|
||||
}
|
||||
|
||||
// IsEmpty returns true if the root is empty
|
||||
func (proof MerkleProof) IsEmpty() bool {
|
||||
// Empty returns true if the root is empty
|
||||
func (proof MerkleProof) Empty() bool {
|
||||
return proof.Proof.Equal(nil) || proof.Equal(MerkleProof{}) || proof.Proof.Equal(nil) || proof.Proof.Equal(merkle.Proof{})
|
||||
}
|
||||
|
||||
// ValidateBasic checks if the proof is empty.
|
||||
func (proof MerkleProof) ValidateBasic() error {
|
||||
if proof.IsEmpty() {
|
||||
if proof.Empty() {
|
||||
return ErrInvalidProof
|
||||
}
|
||||
return nil
|
||||
|
|
Loading…
Reference in New Issue