From d4c168e53a899654261f8bea6f9a0600acc4bf02 Mon Sep 17 00:00:00 2001 From: Thomas van Dam Date: Thu, 28 Nov 2024 11:06:41 +0100 Subject: [PATCH] feat(plugin): update result attributes Part-of: #424 --- plugins/indexing/batching/module.go | 30 +++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/plugins/indexing/batching/module.go b/plugins/indexing/batching/module.go index 1990ca3b..2b3e2104 100644 --- a/plugins/indexing/batching/module.go +++ b/plugins/indexing/batching/module.go @@ -4,6 +4,7 @@ import ( "bytes" "encoding/hex" "strconv" + "time" // "cosmossdk.io/collections" "cosmossdk.io/collections" @@ -31,19 +32,24 @@ func ExtractUpdate(ctx *types.BlockContext, cdc codec.Codec, logger *log.Logger, } data := struct { - ID string `json:"result_id"` - DrID string `json:"dr_id"` - Version string `json:"version"` - BlockHeight string `json:"block_height"` - ExitCode uint32 `json:"exit_code"` - GasUsed string `json:"gas_used"` - Result []byte `json:"result"` - PaybackAddress string `json:"payback_address"` - SedaPayload string `json:"seda_payload"` - Consensus bool `json:"consensus"` + ID string `json:"result_id"` + DrID string `json:"dr_id"` + DrBlockHeight string `json:"dr_block_height"` + Timestamp time.Time `json:"timestamp"` + Version string `json:"version"` + BlockHeight string `json:"block_height"` + ExitCode uint32 `json:"exit_code"` + GasUsed string `json:"gas_used"` + Result []byte `json:"result"` + PaybackAddress string `json:"payback_address"` + SedaPayload string `json:"seda_payload"` + Consensus bool `json:"consensus"` }{ - ID: val.Id, - DrID: val.DrId, + ID: val.Id, + DrID: val.DrId, + DrBlockHeight: strconv.FormatUint(val.DrBlockHeight, 10), + //nolint:gosec // G115: When storing the timestamp we converted from int64 to uint64, so the reverse should be safe. + Timestamp: time.Unix(int64(val.BlockTimestamp), 0), Version: val.Version, BlockHeight: strconv.FormatUint(val.BlockHeight, 10), ExitCode: val.ExitCode,