@@ -208,22 +208,26 @@ func (c *Client) VerifyDataBlobAtHeight(ctx context.Context, unwrappedDataBlob [
208208 return false , nil
209209}
210210
211- // GetBlockTimestamp retrieves the timestamp of a celestia da block at the given height
212- func (c * Client ) GetBlockTimestamp (ctx context.Context , daHeight uint64 ) (time.Time , error ) {
213- type headerResult struct {
214- Header struct {
215- Time string `json:"time"`
216- } `json:"header"`
217- }
211+ type Header struct {
212+ Time string `json:"time"`
213+ }
218214
219- type rpcResponse struct {
220- Result headerResult `json:"result"`
221- Error * struct {
222- Code int `json:"code"`
223- Message string `json:"message"`
224- } `json:"error"`
225- }
215+ type HeaderResult struct {
216+ Header Header `json:"header"`
217+ }
226218
219+ type RPCError struct {
220+ Code int `json:"code"`
221+ Message string `json:"message"`
222+ }
223+
224+ type RPCResponse struct {
225+ Result HeaderResult `json:"result"`
226+ Error * RPCError `json:"error"`
227+ }
228+
229+ // GetBlockTimestamp retrieves the timestamp of a celestia da block at the given height
230+ func (c * Client ) GetBlockTimestamp (ctx context.Context , daHeight uint64 ) (time.Time , error ) {
227231 payload := map [string ]interface {}{
228232 "jsonrpc" : "2.0" ,
229233 "id" : 1 ,
@@ -257,7 +261,7 @@ func (c *Client) GetBlockTimestamp(ctx context.Context, daHeight uint64) (time.T
257261 return time.Time {}, fmt .Errorf ("failed to read response body: %w" , err )
258262 }
259263
260- var rpcResp rpcResponse
264+ var rpcResp RPCResponse
261265 if err := json .Unmarshal (respBody , & rpcResp ); err != nil {
262266 return time.Time {}, fmt .Errorf ("failed to unmarshal response: %w" , err )
263267 }
0 commit comments