2020-04-24 15:20:34 +00:00
|
|
|
package simulation
|
|
|
|
|
|
|
|
import (
|
2020-04-24 21:55:18 +00:00
|
|
|
"bytes"
|
|
|
|
"fmt"
|
|
|
|
"time"
|
|
|
|
|
2020-04-24 15:20:34 +00:00
|
|
|
"github.com/cosmos/cosmos-sdk/codec"
|
2021-01-18 19:12:37 +00:00
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
2020-04-30 14:23:41 +00:00
|
|
|
|
2020-04-24 15:20:34 +00:00
|
|
|
"github.com/tendermint/tendermint/libs/kv"
|
2020-04-24 21:55:18 +00:00
|
|
|
|
|
|
|
"github.com/kava-labs/kava/x/incentive/types"
|
2020-04-24 15:20:34 +00:00
|
|
|
)
|
|
|
|
|
2020-04-24 21:55:18 +00:00
|
|
|
// DecodeStore unmarshals the KVPair's Value to the module's corresponding type
|
2020-04-24 15:20:34 +00:00
|
|
|
func DecodeStore(cdc *codec.Codec, kvA, kvB kv.Pair) string {
|
2020-04-24 21:55:18 +00:00
|
|
|
switch {
|
|
|
|
|
|
|
|
case bytes.Equal(kvA.Key[:1], types.ClaimKeyPrefix):
|
2021-01-18 19:12:37 +00:00
|
|
|
var claimA, claimB types.USDXMintingClaim
|
|
|
|
cdc.MustUnmarshalBinaryBare(kvA.Value, &claimA)
|
|
|
|
cdc.MustUnmarshalBinaryBare(kvB.Value, &claimB)
|
2020-04-24 21:55:18 +00:00
|
|
|
return fmt.Sprintf("%v\n%v", claimA, claimB)
|
|
|
|
|
2021-01-18 19:12:37 +00:00
|
|
|
case bytes.Equal(kvA.Key[:1], types.BlockTimeKey):
|
2020-04-24 21:55:18 +00:00
|
|
|
var timeA, timeB time.Time
|
2021-01-18 19:12:37 +00:00
|
|
|
cdc.MustUnmarshalBinaryBare(kvA.Value, &timeA)
|
|
|
|
cdc.MustUnmarshalBinaryBare(kvB.Value, &timeB)
|
2020-04-24 21:55:18 +00:00
|
|
|
return fmt.Sprintf("%s\n%s", timeA, timeB)
|
|
|
|
|
2021-01-18 19:12:37 +00:00
|
|
|
case bytes.Equal(kvA.Key[:1], types.RewardFactorKey):
|
|
|
|
var factorA, factorB sdk.Dec
|
|
|
|
cdc.MustUnmarshalBinaryBare(kvA.Value, &factorA)
|
|
|
|
cdc.MustUnmarshalBinaryBare(kvB.Value, &factorB)
|
|
|
|
return fmt.Sprintf("%s\n%s", factorA, factorB)
|
|
|
|
|
2020-04-24 21:55:18 +00:00
|
|
|
default:
|
|
|
|
panic(fmt.Sprintf("invalid %s key prefix %X", types.ModuleName, kvA.Key[:1]))
|
|
|
|
}
|
2020-04-24 15:20:34 +00:00
|
|
|
}
|