Skip to content

Commit 896e757

Browse files
chore: use RFC3339 for bundles timestamp (backport #110) (#111)
Co-authored-by: Maximilian Breithecker <72022235+mbreithecker@users.noreply.github.com>
1 parent 5e8866f commit 896e757

5 files changed

Lines changed: 99 additions & 97 deletions

File tree

proto/kyve/query/v1beta1/bundles.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ message FinalizedAt {
7979
// height is the block height in which the bundle got finalized.
8080
string height = 1 [(gogoproto.customtype) = "cosmossdk.io/math.Int"];
8181
// timestamp is the UNIX timestamp of the block in which the bundle got finalized.
82-
string timestamp = 2 [(gogoproto.customtype) = "cosmossdk.io/math.Int"];
82+
string timestamp = 2;
8383
}
8484

8585
// StakeSecurity represents the relative security of a finalized bundle

testutil/integration/checks.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package integration
22

33
import (
4+
"time"
5+
46
"github.com/KYVENetwork/chain/x/bundles"
57
bundlesTypes "github.com/KYVENetwork/chain/x/bundles/types"
68
"github.com/KYVENetwork/chain/x/delegation"
@@ -272,7 +274,9 @@ func checkFinalizedBundle(queryBundle querytypes.FinalizedBundle, rawBundle bund
272274
Expect(queryBundle.BundleSummary).To(Equal(rawBundle.BundleSummary))
273275
Expect(queryBundle.DataHash).To(Equal(rawBundle.DataHash))
274276
Expect(queryBundle.FinalizedAt.Height.Uint64()).To(Equal(rawBundle.FinalizedAt.Height))
275-
Expect(queryBundle.FinalizedAt.Timestamp.Uint64()).To(Equal(rawBundle.FinalizedAt.Timestamp))
277+
date, dateErr := time.Parse(time.RFC3339, queryBundle.FinalizedAt.Timestamp)
278+
Expect(dateErr).To(BeNil())
279+
Expect(uint64(date.Unix())).To(Equal(rawBundle.FinalizedAt.Timestamp))
276280
Expect(queryBundle.FromKey).To(Equal(rawBundle.FromKey))
277281
Expect(queryBundle.StorageProviderId).To(Equal(uint64(rawBundle.StorageProviderId)))
278282
Expect(queryBundle.CompressionId).To(Equal(uint64(rawBundle.CompressionId)))

x/bundles/keeper/getters_bundles.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package keeper
33
import (
44
"encoding/binary"
55
"fmt"
6+
"time"
67

78
cosmossdk_io_math "cosmossdk.io/math"
89

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

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

125125
finalizedBundle := queryTypes.FinalizedBundle{
126126
PoolId: rawFinalizedBundle.PoolId,
@@ -134,7 +134,7 @@ func RawBundleToQueryBundle(rawFinalizedBundle types.FinalizedBundle, versionMap
134134
DataHash: rawFinalizedBundle.DataHash,
135135
FinalizedAt: &queryTypes.FinalizedAt{
136136
Height: &finalizedHeight,
137-
Timestamp: &finalizedTimestamp,
137+
Timestamp: time.Unix(int64(rawFinalizedBundle.FinalizedAt.Timestamp), 0).Format(time.RFC3339),
138138
},
139139
FromKey: rawFinalizedBundle.FromKey,
140140
StorageProviderId: uint64(rawFinalizedBundle.StorageProviderId),

x/query/spec/01_concept.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ returned. The different version are explained below.
6464
"data_hash": "string",
6565
"finalized_at": {
6666
"height": "number",
67-
"timestamp": "number"
67+
"timestamp": "RFC3339 date string"
6868
},
6969
"from_key": "number",
7070
"storage_provider_id": "number",

x/query/types/bundles.pb.go

Lines changed: 90 additions & 92 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)