diff --git a/collections/codec/time_test.go b/collections/codec/time_test.go index 60ba75b23a878..f6df1fc7f6b66 100644 --- a/collections/codec/time_test.go +++ b/collections/codec/time_test.go @@ -1,9 +1,10 @@ package codec import ( - "github.com/stretchr/testify/require" "testing" "time" + + "github.com/stretchr/testify/require" ) func TestTimeKey(t *testing.T) { diff --git a/types/collections.go b/types/collections.go index 54a27417dd5de..b7e9144ae0c9d 100644 --- a/types/collections.go +++ b/types/collections.go @@ -3,7 +3,6 @@ package types import ( "encoding/binary" "fmt" - "time" "cosmossdk.io/collections" collcodec "cosmossdk.io/collections/codec" @@ -239,49 +238,6 @@ func (i uintValueCodec) ValueType() string { return Uint } -type timeKeyCodec struct{} - -func (timeKeyCodec) Encode(buffer []byte, key time.Time) (int, error) { - return copy(buffer, FormatTimeBytes(key)), nil -} - -var timeSize = len(FormatTimeBytes(time.Time{})) - -func (timeKeyCodec) Decode(buffer []byte) (int, time.Time, error) { - if len(buffer) != timeSize { - return 0, time.Time{}, fmt.Errorf("invalid time buffer buffer size") - } - t, err := ParseTimeBytes(buffer) - if err != nil { - return 0, time.Time{}, err - } - return timeSize, t, nil -} - -func (timeKeyCodec) Size(key time.Time) int { return timeSize } - -func (timeKeyCodec) EncodeJSON(value time.Time) ([]byte, error) { return value.MarshalJSON() } - -func (timeKeyCodec) DecodeJSON(b []byte) (time.Time, error) { - t := time.Time{} - err := t.UnmarshalJSON(b) - return t, err -} - -func (timeKeyCodec) Stringify(key time.Time) string { return key.String() } -func (timeKeyCodec) KeyType() string { return "sdk/time.Time" } -func (t timeKeyCodec) EncodeNonTerminal(buffer []byte, key time.Time) (int, error) { - return t.Encode(buffer, key) -} - -func (t timeKeyCodec) DecodeNonTerminal(buffer []byte) (int, time.Time, error) { - if len(buffer) < timeSize { - return 0, time.Time{}, fmt.Errorf("invalid time buffer size, wanted: %d at least, got: %d", timeSize, len(buffer)) - } - return t.Decode(buffer[:timeSize]) -} -func (t timeKeyCodec) SizeNonTerminal(key time.Time) int { return t.Size(key) } - type leUint64Key struct{} func (l leUint64Key) Encode(buffer []byte, key uint64) (int, error) { diff --git a/x/accounts/defaults/lockup/lockup.go b/x/accounts/defaults/lockup/lockup.go index 9eeed974d802f..7fe6b8e502f5a 100644 --- a/x/accounts/defaults/lockup/lockup.go +++ b/x/accounts/defaults/lockup/lockup.go @@ -6,6 +6,8 @@ import ( "fmt" "time" + "github.com/cosmos/gogoproto/proto" + "cosmossdk.io/collections" collcodec "cosmossdk.io/collections/codec" "cosmossdk.io/core/address" @@ -15,9 +17,8 @@ import ( "cosmossdk.io/x/accounts/accountstd" lockuptypes "cosmossdk.io/x/accounts/lockup/types" banktypes "cosmossdk.io/x/bank/types" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - "github.com/cosmos/gogoproto/proto" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) diff --git a/x/accounts/defaults/lockup/protov2_wrapper.go b/x/accounts/defaults/lockup/protov2_wrapper.go index 782f9e301594b..caee0c60398f6 100644 --- a/x/accounts/defaults/lockup/protov2_wrapper.go +++ b/x/accounts/defaults/lockup/protov2_wrapper.go @@ -1,12 +1,14 @@ package lockup import ( + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/runtime/protoiface" + bankv1beta1 "cosmossdk.io/api/cosmos/bank/v1beta1" v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" stakingv1beta1 "cosmossdk.io/api/cosmos/staking/v1beta1" + sdk "github.com/cosmos/cosmos-sdk/types" - "google.golang.org/protobuf/proto" - "google.golang.org/protobuf/runtime/protoiface" ) type ProtoMsg = protoiface.MessageV1