postchain-client 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,8 @@
1
- import { RestClient } from "../restclient/interfaces";
2
- import { ChromiaClientProvider } from "./interfaces";
3
- export declare function chromiaClientProvider(chain0BRID: string, rest: RestClient): ChromiaClientProvider;
1
+ import type { RestClient } from "../restclient/interfaces";
2
+ import type { ChromiaClient } from "./interfaces";
3
+ /**
4
+ * Provides postchain clients that can be used to communicate with dapps within the chromia network
5
+ * @param chain0BRID brid of chain0
6
+ * @param rest rest client configured to node running chain0
7
+ */
8
+ export declare function chromiaClientProvider(chain0BRID: string, rest: RestClient): ChromiaClient;
@@ -1,4 +1,4 @@
1
1
  import { RestClient } from "../restclient/interfaces";
2
- export interface ChromiaClientProvider {
2
+ export interface ChromiaClient {
3
3
  blockchainConnection: (blockchainRid: string) => Promise<RestClient>;
4
4
  }
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- export declare type KeyPair = {
2
+ export type KeyPair = {
3
3
  pubKey: Buffer;
4
4
  privKey: Buffer;
5
5
  };
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" />
2
+ import { GTX, RawGtx } from "./gtx/types";
2
3
  export declare function pgBytes(buffer: Buffer): string;
3
4
  /**
4
5
  * Converts hex string to Buffer
@@ -16,4 +17,7 @@ export declare class PgBytesInputException extends Error {
16
17
  constructor(buffer: Buffer);
17
18
  }
18
19
  export declare function ensureBuffer(value: string | Buffer): Buffer;
20
+ export declare function checkGtvType(value: any): boolean;
21
+ export declare function rawGtxToGtx(rawGtx: RawGtx): GTX;
22
+ export declare function checkGtxType(value: any): boolean;
19
23
  export declare function removeDuplicateSigners(signers: Buffer[]): Buffer[];
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
- export declare type RawGtv = null | Buffer | string | number | DictPair | Array<RawGtv> | bigint;
3
- export declare type DictPair = {
2
+ export type RawGtv = null | Buffer | string | number | DictPair | Array<RawGtv> | bigint;
3
+ export type DictPair = {
4
4
  name: string;
5
5
  value: RawGtv;
6
6
  };
@@ -1,28 +1,28 @@
1
1
  /// <reference types="node" />
2
2
  import { RawGtv } from "../gtv/types";
3
- export declare type RawGtxOp = [opName: string, args: RawGtv[]];
4
- export declare type RawGtxBody = [
3
+ export type RawGtxOp = [opName: string, args: RawGtv[]];
4
+ export type RawGtxBody = [
5
5
  blockchainRID: Buffer,
6
6
  operations: RawGtxOp[],
7
7
  signers: Buffer[]
8
8
  ];
9
- export declare type RawGtx = [transaction: RawGtxBody, signatures: Buffer[]];
10
- export declare type GTX = {
9
+ export type RawGtx = [transaction: RawGtxBody, signatures: Buffer[]];
10
+ export type GTX = {
11
11
  [x: string]: any;
12
12
  blockchainRID: Buffer;
13
13
  operations: RellOperation[];
14
14
  signers: Buffer[];
15
15
  signatures?: Buffer[];
16
16
  };
17
- export declare type RellOperation = {
17
+ export type RellOperation = {
18
18
  opName: string;
19
19
  args: RawGtv[];
20
20
  };
21
- export declare type SignerPair = {
21
+ export type SignerPair = {
22
22
  pubKey: string;
23
23
  signature: string;
24
24
  };
25
- export declare type BufferSignerPair = {
25
+ export type BufferSignerPair = {
26
26
  pubKey: Buffer;
27
27
  signature: Buffer;
28
28
  };
@@ -1,11 +1,11 @@
1
1
  /// <reference types="node" />
2
- export declare type Step = {
2
+ export type Step = {
3
3
  side: number;
4
4
  hash: Buffer;
5
5
  };
6
- export declare type StringStep = {
6
+ export type StringStep = {
7
7
  side: number;
8
8
  hash: string;
9
9
  };
10
- export declare type Path = Step[];
11
- export declare type StringPath = StringStep[];
10
+ export type Path = Step[];
11
+ export type StringPath = StringStep[];
@@ -2,7 +2,7 @@
2
2
  import { RawGtv } from "../gtv/types";
3
3
  import { BufferSignerPair, SignerPair } from "../gtx/types";
4
4
  import { Path, StringPath } from "../merkle/types";
5
- export declare type RestClientConfig = {
5
+ export type RestClientConfig = {
6
6
  endpointPool: readonly string[];
7
7
  pool: {
8
8
  maxSockets: number;
@@ -11,7 +11,7 @@ export declare type RestClientConfig = {
11
11
  attemptsPerEndpoint: number;
12
12
  attemptInterval: number;
13
13
  };
14
- export declare type RequestOptions = {
14
+ export type RequestOptions = {
15
15
  method: string;
16
16
  url: string;
17
17
  json: boolean;
@@ -20,17 +20,17 @@ export declare type RequestOptions = {
20
20
  maxSockets: number;
21
21
  };
22
22
  };
23
- export declare type QueryObject = {
23
+ export type QueryObject = {
24
24
  type: string;
25
25
  [arg: string]: RawGtv;
26
26
  };
27
- export declare type ServerReturnProof = {
27
+ export type ServerReturnProof = {
28
28
  hash: string;
29
29
  blockHeader: string;
30
30
  signatures: SignerPair[];
31
31
  merklePath: StringPath;
32
32
  };
33
- export declare type ResponseObjectProof = {
33
+ export type ResponseObjectProof = {
34
34
  hash: Buffer;
35
35
  blockHeader: Buffer;
36
36
  signatures: BufferSignerPair[];
@@ -42,20 +42,20 @@ export declare enum ResponseStatus {
42
42
  Unknown = "unknown",
43
43
  Waiting = "waiting"
44
44
  }
45
- export declare type TransactionObject = {
45
+ export type TransactionObject = {
46
46
  tx: string;
47
47
  };
48
- export declare type StatusObject = {
48
+ export type StatusObject = {
49
49
  status: ResponseStatus;
50
50
  rejectReason?: string;
51
51
  };
52
- export declare type PostRequestObjects = TransactionObject | QueryObject;
53
- export declare type GetResponseObjects = StatusObject | TransactionObject | ServerReturnProof;
54
- export declare type FailOverConfig = {
52
+ export type PostRequestObjects = TransactionObject | QueryObject;
53
+ export type GetResponseObjects = StatusObject | TransactionObject | ServerReturnProof;
54
+ export type FailOverConfig = {
55
55
  attemptsPerEndpoint?: number;
56
56
  attemptInterval?: number;
57
57
  };
58
- export declare type ResponseObject = {
58
+ export type ResponseObject = {
59
59
  error: Error;
60
60
  statusCode: number;
61
61
  rspBody: any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postchain-client",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Client library for accessing a Postchain node through REST.",
5
5
  "repository": {
6
6
  "type": "git",