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.
This commit is contained in:
2026-05-29 17:08:47 -04:00
parent 18ac756d44
commit 621e359817

View File

@@ -121,18 +121,23 @@ type SmartContractExecutionInfo struct {
} }
type Block struct { type Block struct {
Version string `json:"version"` Version string `json:"version"`
ID string `json:"block_id"` Header BlockHeader `json:"header"`
Timestamp string `json:"timestamp"` Transactions []string `json:"transactions"`
PrevID string `json:"prev_id"` Proof BlockProof `json:"proof"`
PrevProof string `json:"prev_proof"` }
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 { type BlockProof struct {
Scheme string `json:"scheme"`
Proof string `json:"proof"` Proof string `json:"proof"`
Scheme string `json:"scheme,omitempty"`
Nonce int64 `json:"nonce,omitempty"` Nonce int64 `json:"nonce,omitempty"`
} }