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

@@ -122,17 +122,22 @@ 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"`
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"`
}