UNPKG

postchain-client

Version:

Client library for accessing a Postchain node through REST.

182 lines (181 loc) 4.53 kB
/// <reference types="node" /> import { DictPair, RawGtv } from "../gtv/types"; import { FailOverConfig } from "../restclient/types"; import { FailoverStrategy, ResponseStatus } from "./enums"; import { ResponseObject } from "../restclient/types"; import { RawGtxBody } from "../gtx/types"; import { NodeManager } from "../restclient/nodeManager"; export type KeyPair = { privKey: PrivKey; pubKey: PubKey; }; export type Endpoint = { readonly url: string; whenAvailable: number; }; export type ClientConfig = { endpointPool: Endpoint[]; nodeManager: NodeManager; blockchainRid: string; statusPollInterval: number; statusPollCount: number; failoverStrategy: FailoverStrategy; attemptsPerEndpoint: number; attemptInterval: number; unreachableDuration: number; }; export type NetworkSettings = { nodeUrlPool?: string | string[]; directoryNodeUrlPool?: string | string[]; blockchainRid?: string; blockchainIid?: number; statusPollInterval?: number; statusPollCount?: number; failOverConfig?: FailOverConfig; useStickyNode?: boolean; }; export interface TransactionReceipt { status: ResponseStatus; statusCode: number | null; transactionRid: Buffer; } export type SignedTransaction = Buffer; export interface SignatureProvider { sign(rawGtxBody: RawGtxBody): Promise<Buffer>; readonly pubKey: Buffer; } export type RestClientQueryObject = { type: string; [arg: string]: RawGtv; }; export type QueryObject<TReturn extends RawGtv, TArgs extends DictPair | undefined = DictPair> = { name: string; args?: TArgs; }; export type QueryCallback<TReturn> = (error: Error, response: TReturn) => void; export type PrivKey = Buffer; export type PubKey = Buffer; export type Operation = { name: string; args?: RawGtv[]; }; export interface Transaction { operations: Operation[]; signers: Buffer[]; } export type StatusObject = { status: ResponseStatus; rejectReason?: string; }; export type SignerPair = { pubKey: string; signature: string; }; export type BufferSignerPair = { pubKey: Buffer; signature: Buffer; }; export type Step = { side: number; hash: Buffer; }; export type Path = Step[]; export type ConfirmationProof = { hash: Buffer; blockHeader: Buffer; witness: Buffer; merkleProofTree: RawGtv; txIndex: number; }; export type TransactionInfo = { blockRid: Buffer; blockHeight: number; blockHeader: Buffer; witness: Buffer; timestamp: number; txRid: Buffer; txHash: Buffer; txData: Buffer; }; export type TransactionInfoResponse = { blockRID: string; blockHeight: number; blockHeader: string; witness: string; timestamp: number; txRID: string; txHash: string; txData: string; }; export type BlockInfoResponse = { rid: string; prevBlockRID: string; header: string; height: number; transactions: TransactionInfoInBlockResponse[]; witness: string; witnesses: string[]; timestamp: number; }; export type TransactionInfoInBlockResponse = { rid: string; hash: string; data?: string; }; export type BlockInfo = { rid: Buffer; prevBlockRid: Buffer; header: Buffer; height: number; transactions: TransactionInfoInBlock[]; witness: Buffer; witnesses: Buffer[]; timestamp: number; }; export type TransactionInfoInBlock = { rid: Buffer; hash: Buffer; data?: Buffer; }; export type GetBlocksResponse = Omit<ResponseObject, "rspBody"> & { rspBody: BlockInfoResponse[] | undefined; }; export type GetBlockResponse = Omit<ResponseObject, "rspBody"> & { rspBody: BlockInfoResponse | undefined; }; export interface AppStructure extends DictPair { modules: BlockchainModules; } interface BlockchainModules extends DictPair { [key: string]: RellModule; } interface RellFunction extends DictPair { mount: string; parameters: RellParameter[]; returnType: RawGtv; } interface RellParameter extends DictPair { name: string; type: RawGtv; } interface RellAttribute extends DictPair { type: RawGtv; mutable: number; } interface RellObject extends DictPair { mount: string; attributes: Record<string, RellAttribute>; } interface RellModule extends DictPair { name: string; queries: { [key: string]: RellFunction; }; operations: { [key: string]: RellFunction; }; objects: { [key: string]: RellObject; }; } export {};