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 interface, nest it in Block, and make proof.scheme
optional. Verified live against a dev chain.
This commit is contained in:
15
src/types.ts
15
src/types.ts
@@ -122,17 +122,22 @@ export interface SmartContract {
|
||||
|
||||
// Block Types
|
||||
export interface BlockProof {
|
||||
scheme: string;
|
||||
proof: string;
|
||||
scheme?: string; // absent on trust-scheme chains; present on PoW
|
||||
nonce?: number;
|
||||
}
|
||||
|
||||
export interface BlockHeader {
|
||||
blockId: string;
|
||||
dcId: string;
|
||||
prevId: string;
|
||||
prevProof: string;
|
||||
timestamp: string;
|
||||
}
|
||||
|
||||
export interface Block {
|
||||
version: string;
|
||||
block_id: string;
|
||||
timestamp: string;
|
||||
prev_id: string;
|
||||
prev_proof: string;
|
||||
header: BlockHeader;
|
||||
transactions: string[];
|
||||
proof: BlockProof;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user