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
|
// Block Types
|
||||||
export interface BlockProof {
|
export interface BlockProof {
|
||||||
scheme: string;
|
|
||||||
proof: string;
|
proof: string;
|
||||||
|
scheme?: string; // absent on trust-scheme chains; present on PoW
|
||||||
nonce?: number;
|
nonce?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface BlockHeader {
|
||||||
|
blockId: string;
|
||||||
|
dcId: string;
|
||||||
|
prevId: string;
|
||||||
|
prevProof: string;
|
||||||
|
timestamp: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface Block {
|
export interface Block {
|
||||||
version: string;
|
version: string;
|
||||||
block_id: string;
|
header: BlockHeader;
|
||||||
timestamp: string;
|
|
||||||
prev_id: string;
|
|
||||||
prev_proof: string;
|
|
||||||
transactions: string[];
|
transactions: string[];
|
||||||
proof: BlockProof;
|
proof: BlockProof;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user