From 621e35981746875aa2ec67683f8b0cd0d3c654b9 Mon Sep 17 00:00:00 2001 From: Andrew Miller Date: Fri, 29 May 2026 17:08:47 -0400 Subject: [PATCH] Fix Block model to match server: nest header with camelCase keys The block endpoint returns block id / prev / timestamp nested under a "header" object with camelCase keys (blockId, dcId, prevId, prevProof, timestamp) and a proof of just {proof}. The previous flat snake_case Block fields never matched the response and always deserialized empty. Add a BlockHeader struct, nest it in Block, and make Proof.Scheme omitempty. Verified live against a dev chain. --- models/models.go | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/models/models.go b/models/models.go index b14a26e..0231677 100755 --- a/models/models.go +++ b/models/models.go @@ -121,18 +121,23 @@ type SmartContractExecutionInfo struct { } type Block struct { - Version string `json:"version"` - ID string `json:"block_id"` - Timestamp string `json:"timestamp"` - PrevID string `json:"prev_id"` - PrevProof string `json:"prev_proof"` - Transactions []string `json:"transactions"` - Proof BlockProof `json:"proof"` + Version string `json:"version"` + Header BlockHeader `json:"header"` + Transactions []string `json:"transactions"` + Proof BlockProof `json:"proof"` +} + +type BlockHeader struct { + BlockId string `json:"blockId"` + DcId string `json:"dcId"` + PrevId string `json:"prevId"` + PrevProof string `json:"prevProof"` + Timestamp string `json:"timestamp"` } type BlockProof struct { - Scheme string `json:"scheme"` Proof string `json:"proof"` + Scheme string `json:"scheme,omitempty"` Nonce int64 `json:"nonce,omitempty"` }