github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/libs/ibc-go/modules/core/03-connection/simulation/decoder.go (about) 1 package simulation 2 3 import ( 4 "bytes" 5 "fmt" 6 7 "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/codec" 8 "github.com/fibonacci-chain/fbc/libs/ibc-go/modules/core/03-connection/types" 9 host "github.com/fibonacci-chain/fbc/libs/ibc-go/modules/core/24-host" 10 "github.com/fibonacci-chain/fbc/libs/ibc-go/modules/core/common" 11 "github.com/fibonacci-chain/fbc/libs/tendermint/libs/kv" 12 ) 13 14 // NewDecodeStore returns a decoder function closure that unmarshals the KVPair's 15 // Value to the corresponding connection type. 16 func NewDecodeStore(cdc *codec.CodecProxy, kvA, kvB kv.Pair) (string, bool) { 17 switch { 18 case bytes.HasPrefix(kvA.Key, host.KeyClientStorePrefix) && bytes.HasSuffix(kvA.Key, []byte(host.KeyConnectionPrefix)): 19 var clientConnectionsA, clientConnectionsB types.ClientPaths 20 cdc.GetProtocMarshal().MustUnmarshalBinaryBare(kvA.Value, &clientConnectionsA) 21 cdc.GetProtocMarshal().MustUnmarshalBinaryBare(kvB.Value, &clientConnectionsB) 22 return fmt.Sprintf("ClientPaths A: %v\nClientPaths B: %v", clientConnectionsA, clientConnectionsB), true 23 24 case bytes.HasPrefix(kvA.Key, []byte(host.KeyConnectionPrefix)): 25 var connectionA, connectionB types.ConnectionEnd 26 connectionA = *common.MustUnmarshalConnection(cdc, kvA.Value) 27 connectionB = *common.MustUnmarshalConnection(cdc, kvB.Value) 28 return fmt.Sprintf("ConnectionEnd A: %v\nConnectionEnd B: %v", connectionA, connectionB), true 29 30 default: 31 return "", false 32 } 33 }