cosmos-sdk/x/ibc/03-connection/simulation/decoder.go
Anil Kumar Kammari 3bafd8255a
Remove hybrid codec usage (#6843)
* remove hybrid codec for slashing, staking and upgrade

* Remove hybridcodec from params and mint

* revert staking

* Fix gov

* Fix ibc and evidence

* Fix ibc-transfer

* Fix staking

* remove evidence json marshaling

* Fix tests

Co-authored-by: Aaron Craelius <aaron@regen.network>
Co-authored-by: Aaron Craelius <aaronc@users.noreply.github.com>
Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
2020-07-25 08:03:58 +00:00

34 lines
1.2 KiB
Go

package simulation
import (
"bytes"
"fmt"
tmkv "github.com/tendermint/tendermint/libs/kv"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types"
host "github.com/cosmos/cosmos-sdk/x/ibc/24-host"
)
// NewDecodeStore returns a decoder function closure that unmarshals the KVPair's
// Value to the corresponding connection type.
func NewDecodeStore(cdc codec.BinaryMarshaler, kvA, kvB tmkv.Pair) (string, bool) {
switch {
case bytes.HasPrefix(kvA.Key, host.KeyClientStorePrefix) && bytes.HasSuffix(kvA.Key, host.KeyConnectionPrefix):
var clientConnectionsA, clientConnectionsB types.ClientPaths
cdc.MustUnmarshalBinaryBare(kvA.Value, &clientConnectionsA)
cdc.MustUnmarshalBinaryBare(kvB.Value, &clientConnectionsB)
return fmt.Sprintf("ClientPaths A: %v\nClientPaths B: %v", clientConnectionsA, clientConnectionsB), true
case bytes.HasPrefix(kvA.Key, host.KeyConnectionPrefix):
var connectionA, connectionB types.ConnectionEnd
cdc.MustUnmarshalBinaryBare(kvA.Value, &connectionA)
cdc.MustUnmarshalBinaryBare(kvB.Value, &connectionB)
return fmt.Sprintf("ConnectionEnd A: %v\nConnectionEnd B: %v", connectionA, connectionB), true
default:
return "", false
}
}