Skip to content

Commit

Permalink
chore: use RFC3339 for bundles timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
mbreithecker committed Jul 13, 2023
1 parent c5183cf commit 38e755d
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 97 deletions.
2 changes: 1 addition & 1 deletion proto/kyve/query/v1beta1/bundles.proto
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ message FinalizedAt {
// height is the block height in which the bundle got finalized.
string height = 1 [(gogoproto.customtype) = "cosmossdk.io/math.Int"];
// timestamp is the UNIX timestamp of the block in which the bundle got finalized.
string timestamp = 2 [(gogoproto.customtype) = "cosmossdk.io/math.Int"];
string timestamp = 2;
}

// StakeSecurity represents the relative security of a finalized bundle
Expand Down
6 changes: 5 additions & 1 deletion testutil/integration/checks.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package integration

import (
"time"

"github.com/KYVENetwork/chain/x/bundles"
bundlesTypes "github.com/KYVENetwork/chain/x/bundles/types"
"github.com/KYVENetwork/chain/x/delegation"
Expand Down Expand Up @@ -274,7 +276,9 @@ func checkFinalizedBundle(queryBundle querytypes.FinalizedBundle, rawBundle bund
Expect(queryBundle.BundleSummary).To(Equal(rawBundle.BundleSummary))
Expect(queryBundle.DataHash).To(Equal(rawBundle.DataHash))
Expect(queryBundle.FinalizedAt.Height.Uint64()).To(Equal(rawBundle.FinalizedAt.Height))
Expect(queryBundle.FinalizedAt.Timestamp.Uint64()).To(Equal(rawBundle.FinalizedAt.Timestamp))
date, dateErr := time.Parse(time.RFC3339, queryBundle.FinalizedAt.Timestamp)
Expect(dateErr).To(BeNil())
Expect(uint64(date.Unix())).To(Equal(rawBundle.FinalizedAt.Timestamp))
Expect(queryBundle.FromKey).To(Equal(rawBundle.FromKey))
Expect(queryBundle.StorageProviderId).To(Equal(uint64(rawBundle.StorageProviderId)))
Expect(queryBundle.CompressionId).To(Equal(uint64(rawBundle.CompressionId)))
Expand Down
4 changes: 2 additions & 2 deletions x/bundles/keeper/getters_bundles.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package keeper
import (
"encoding/binary"
"fmt"
"time"

cosmossdk_io_math "cosmossdk.io/math"

Expand Down Expand Up @@ -120,7 +121,6 @@ func (k Keeper) GetFinalizedBundle(ctx sdk.Context, poolId, id uint64) (val type

func RawBundleToQueryBundle(rawFinalizedBundle types.FinalizedBundle, versionMap map[int32]uint64) (queryBundle queryTypes.FinalizedBundle) {
finalizedHeight := cosmossdk_io_math.NewInt(int64(rawFinalizedBundle.FinalizedAt.Height))
finalizedTimestamp := cosmossdk_io_math.NewInt(int64(rawFinalizedBundle.FinalizedAt.Timestamp))

finalizedBundle := queryTypes.FinalizedBundle{
PoolId: rawFinalizedBundle.PoolId,
Expand All @@ -134,7 +134,7 @@ func RawBundleToQueryBundle(rawFinalizedBundle types.FinalizedBundle, versionMap
DataHash: rawFinalizedBundle.DataHash,
FinalizedAt: &queryTypes.FinalizedAt{
Height: &finalizedHeight,
Timestamp: &finalizedTimestamp,
Timestamp: time.Unix(int64(rawFinalizedBundle.FinalizedAt.Timestamp), 0).Format(time.RFC3339),
},
FromKey: rawFinalizedBundle.FromKey,
StorageProviderId: uint64(rawFinalizedBundle.StorageProviderId),
Expand Down
2 changes: 1 addition & 1 deletion x/query/spec/01_concept.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ returned. The different version are explained below.
"data_hash": "string",
"finalized_at": {
"height": "number",
"timestamp": "number"
"timestamp": "RFC3339 date string"
},
"from_key": "number",
"storage_provider_id": "number",
Expand Down
182 changes: 90 additions & 92 deletions x/query/types/bundles.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 38e755d

Please sign in to comment.