github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/libs/cosmos-sdk/x/auth/simulation/decoder.go (about)

     1  package simulation
     2  
     3  import (
     4  	"bytes"
     5  	"fmt"
     6  
     7  	tmkv "github.com/fibonacci-chain/fbc/libs/tendermint/libs/kv"
     8  
     9  	"github.com/fibonacci-chain/fbc/libs/cosmos-sdk/codec"
    10  	"github.com/fibonacci-chain/fbc/libs/cosmos-sdk/x/auth/exported"
    11  	"github.com/fibonacci-chain/fbc/libs/cosmos-sdk/x/auth/types"
    12  )
    13  
    14  // DecodeStore unmarshals the KVPair's Value to the corresponding auth type
    15  func DecodeStore(cdc *codec.Codec, kvA, kvB tmkv.Pair) string {
    16  	switch {
    17  	case bytes.Equal(kvA.Key[:1], types.AddressStoreKeyPrefix):
    18  		var accA, accB exported.Account
    19  		cdc.MustUnmarshalBinaryBare(kvA.Value, &accA)
    20  		cdc.MustUnmarshalBinaryBare(kvB.Value, &accB)
    21  		return fmt.Sprintf("%v\n%v", accA, accB)
    22  	case bytes.Equal(kvA.Key, types.GlobalAccountNumberKey):
    23  		var globalAccNumberA, globalAccNumberB uint64
    24  		cdc.MustUnmarshalBinaryLengthPrefixed(kvA.Value, &globalAccNumberA)
    25  		cdc.MustUnmarshalBinaryLengthPrefixed(kvB.Value, &globalAccNumberB)
    26  		return fmt.Sprintf("GlobalAccNumberA: %d\nGlobalAccNumberB: %d", globalAccNumberA, globalAccNumberB)
    27  	default:
    28  		panic(fmt.Sprintf("invalid account key %X", kvA.Key))
    29  	}
    30  }