rosetta-sdk-typescript
Version:
Typescript SDK to create and interact with Rosetta API implementations.
88 lines (82 loc) • 2.81 kB
text/typescript
/* tslint:disable */
/* eslint-disable */
/**
* Rosetta
* Build Once. Integrate Your Blockchain Everywhere.
*
* The version of the OpenAPI document: 1.4.10
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import { exists } from '../runtime';
import { BlockIdentifier, BlockIdentifierFromJSON, BlockIdentifierToJSON, Transaction, TransactionFromJSON, TransactionToJSON } from './';
/**
* Blocks contain an array of Transactions that occurred at a particular BlockIdentifier. A hard requirement for blocks returned by Rosetta implementations is that they MUST be _inalterable_: once a client has requested and received a block identified by a specific BlockIndentifier, all future calls for that same BlockIdentifier must return the same block contents.
* @export
* @interface Block
*/
export interface Block {
/**
*
* @type {BlockIdentifier}
* @memberof Block
*/
block_identifier: BlockIdentifier;
/**
*
* @type {BlockIdentifier}
* @memberof Block
*/
parent_block_identifier: BlockIdentifier;
/**
* The timestamp of the block in milliseconds since the Unix Epoch. The timestamp is stored in milliseconds because some blockchains produce blocks more often than once a second.
* @type {number}
* @memberof Block
*/
timestamp: number;
/**
*
* @type {Array<Transaction>}
* @memberof Block
*/
transactions: Array<Transaction>;
/**
*
* @type {object}
* @memberof Block
*/
metadata?: object;
}
export function BlockFromJSON(json: any): Block {
return BlockFromJSONTyped(json, false);
}
export function BlockFromJSONTyped(json: any, ignoreDiscriminator: boolean): Block {
if (json === undefined || json === null) {
return json;
}
return {
block_identifier: BlockIdentifierFromJSON(json['block_identifier']),
parent_block_identifier: BlockIdentifierFromJSON(json['parent_block_identifier']),
timestamp: json['timestamp'],
transactions: (json['transactions'] as Array<any>).map(TransactionFromJSON),
metadata: !exists(json, 'metadata') ? undefined : json['metadata'],
};
}
export function BlockToJSON(value?: Block | null): any {
if (value === undefined) {
return undefined;
}
if (value === null) {
return null;
}
return {
block_identifier: BlockIdentifierToJSON(value.block_identifier),
parent_block_identifier: BlockIdentifierToJSON(value.parent_block_identifier),
timestamp: value.timestamp,
transactions: (value.transactions as Array<any>).map(TransactionToJSON),
metadata: value.metadata,
};
}