@tchain/tcabci-read-js-client 2.7.11 → 2.7.13

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.
package/client.d.ts CHANGED
@@ -1,137 +1,188 @@
1
- import { Transaction, TXType } from './transaction'
1
+ import { Transaction, TXType } from './transaction.js'
2
+ import { TWebSocket } from './websocket.js'
2
3
  import {
3
4
  SuccessCallback,
4
5
  ErrorCallback,
5
6
  CloseCallback,
6
7
  ListenCallback
7
- } from './callback'
8
+ } from './callback.js'
9
+ import {
10
+ ClientOptions,
11
+ RequestOptions,
12
+ WebSocketConstructor,
13
+ JSONValue
14
+ } from './types.js'
15
+
16
+ export type {
17
+ ClientOptions,
18
+ RequestOptions,
19
+ WebSocketConstructor
20
+ } from './types.js'
21
+
22
+ export interface TxQuery {
23
+ recipientAddrs?: readonly string[]
24
+ senderAddrs?: readonly string[]
25
+ signedData?: Readonly<Record<string, string>>
26
+ typ?: TXType
27
+ types?: readonly TXType[] | null
28
+ chainName?: string | null
29
+ chainVersion?: string | null
30
+ }
31
+
32
+ export interface TxSearchQuery extends TxQuery {
33
+ heightOperator?: string
34
+ height?: number
35
+ maxHeight?: number
36
+ lastOrder?: number
37
+ hashes?: readonly string[]
38
+ limit?: number
39
+ offset?: number
40
+ orderField?: string
41
+ orderBy?: string
42
+ }
43
+
44
+ export interface BroadcastInput {
45
+ id: string
46
+ version: number
47
+ type: TXType
48
+ data: JSONValue
49
+ additional_data?: JSONValue
50
+ cipher_data?: JSONValue
51
+ sender_addr: string
52
+ recipient_addr: string
53
+ sign: string
54
+ fee: number
55
+ }
56
+
57
+ export interface ClientStatus {
58
+ readonly chain_name: string
59
+ readonly chain_version: string
60
+ readonly connected: boolean
61
+ readonly subscribed: boolean
62
+ }
8
63
 
9
- declare class TCaBCIClient {
64
+ /** Call Start to initiate a socket; the success callback reports OPEN. */
65
+ export default class TCaBCIClient {
10
66
  constructor(
11
- readNodeAddresses: string[],
12
- wsLibrary: WebSocket,
13
- chainName: string,
14
- chainVersion: string
67
+ readNodeAddresses?: readonly string[],
68
+ wsLibrary?: WebSocketConstructor,
69
+ chainName?: string | null,
70
+ chainVersion?: string | null,
71
+ options?: ClientOptions
15
72
  )
16
- SetDebug(debug: boolean): TCaBCIClient
17
- SetSuccessCallback(cb: SuccessCallback): TCaBCIClient
18
- SetErrorCallback(cb: ErrorCallback): TCaBCIClient
19
- SetCloseCallback(cb: CloseCallback): TCaBCIClient
20
- SetListenCallback(cb: ListenCallback): TCaBCIClient
73
+
74
+ SetDebug(debug: boolean): this
75
+
76
+ SetSuccessCallback(cb: SuccessCallback | null): this
77
+
78
+ SetErrorCallback(cb: ErrorCallback | null): this
79
+
80
+ SetCloseCallback(cb: CloseCallback | null): this
81
+
82
+ SetListenCallback(cb: ListenCallback | null): this
83
+
21
84
  IsConnected(): boolean
85
+
22
86
  IsSubscribed(): boolean
23
- get SubscribeAddresses(): string[]
24
- get SubscribedSignedData(): Record<string, string> | null
25
- get Socket(): WebSocket
26
- Start(): Awaited<TCaBCIClient>
27
- Stop(code?: number): Awaited<TCaBCIClient>
28
- Reconnect(code?: number): Awaited<TCaBCIClient>
29
- Status(): {
30
- chain_name: string
31
- chain_version: string
32
- connected: boolean
33
- subscribed: boolean
34
- }
87
+
88
+ get SubscribeAddresses(): readonly string[]
89
+
90
+ get SubscribedSignedData(): Readonly<Record<string, string>>
91
+
92
+ get Socket(): TWebSocket | null | undefined
93
+
94
+ Start(): Promise<TWebSocket>
95
+
96
+ /** Idempotently closes the socket, clears subscription state and aborts HTTP. */
97
+ Stop(code?: number): Promise<this>
98
+
99
+ /** Also releases application callback references. */
100
+ Dispose(): Promise<this>
101
+
102
+ Reconnect(code?: number): Promise<this>
103
+
104
+ Status(): Readonly<ClientStatus>
105
+
35
106
  Subscribe(
36
- addresses: string[],
37
- signedData: Record<string, string>,
38
- txTypes?: TXType[]
39
- ): TCaBCIClient
40
- Unsubscribe(): TCaBCIClient
107
+ addresses: readonly string[],
108
+ signedData: Readonly<Record<string, string>>,
109
+ txTypes?: readonly TXType[] | null
110
+ ): this
111
+
112
+ Unsubscribe(): this
113
+
41
114
  LastBlock(
42
- chainName?: null,
43
- chainVersion?: null
115
+ chainName?: string | null,
116
+ chainVersion?: string | null,
117
+ options?: RequestOptions
44
118
  ): Promise<{
45
- blocks: Transaction[]
46
- info: {
47
- chainName: string
48
- chainVersion: string
49
- hash: string
50
- height: number
51
- txs: number
52
- createdAt: Date
119
+ readonly blocks: readonly Transaction[]
120
+ readonly info: {
121
+ readonly chainName: string
122
+ readonly chainVersion: string
123
+ readonly hash: string
124
+ readonly height: number
125
+ readonly txs: number
126
+ readonly createdAt: Date
53
127
  }
54
- total_count: number
128
+ readonly total_count: number
129
+ }>
130
+
131
+ Tx(
132
+ id: string,
133
+ signature: string,
134
+ options?: RequestOptions
135
+ ): Promise<Readonly<{ readonly tx: Transaction }>>
136
+
137
+ TxSummary(
138
+ query: TxQuery,
139
+ options?: RequestOptions
140
+ ): Promise<{
141
+ readonly chain_name: string
142
+ readonly chain_version: string
143
+ readonly first_block_height: number
144
+ readonly first_transaction: Transaction | undefined
145
+ readonly last_block_height: number
146
+ readonly last_transaction: Transaction | undefined
147
+ readonly total_count: number
55
148
  }>
56
- Tx(id: string, signature: string): Promise<{ tx: Transaction }>
57
- TxSummary({
58
- recipientAddrs,
59
- senderAddrs,
60
- signedData,
61
- typ,
62
- types,
63
- chainName,
64
- chainVersion
65
- }: Record<string, any>): Promise<{
66
- chain_name: string
67
- chain_version: string
68
- first_block_height: number
69
- first_transaction: Transaction
70
- last_block_height: number
71
- last_transaction: Transaction
72
- total_count: number
149
+
150
+ TxSearch(
151
+ query: TxSearchQuery,
152
+ options?: RequestOptions
153
+ ): Promise<{
154
+ readonly txs: readonly Transaction[]
155
+ readonly total_count: number
73
156
  }>
74
- TxSearch({
75
- heightOperator,
76
- height,
77
- maxHeight,
78
- lastOrder,
79
- recipientAddrs,
80
- senderAddrs,
81
- signedData,
82
- hashes,
83
- typ,
84
- types,
85
- limit,
86
- offset,
87
- orderField,
88
- orderBy,
89
- chainName,
90
- chainVersion
91
- }: Record<string, any>): Promise<{ txs: Transaction[]; total_count: number }>
92
- BroadcastCommit({
93
- id,
94
- version,
95
- type,
96
- data,
97
- additional_data,
98
- cipher_data,
99
- sender_addr,
100
- recipient_addr,
101
- sign,
102
- fee
103
- }: Record<string, any>): Promise<{ data: Record<string, any> }>
104
- BroadcastSync({
105
- id,
106
- version,
107
- type,
108
- data,
109
- additional_data,
110
- cipher_data,
111
- sender_addr,
112
- recipient_addr,
113
- sign,
114
- fee
115
- }: Record<string, any>): Promise<{ data: Record<string, any> }>
116
- Broadcast({
117
- id,
118
- version,
119
- type,
120
- data,
121
- additional_data,
122
- cipher_data,
123
- sender_addr,
124
- recipient_addr,
125
- sign,
126
- fee
127
- }: Record<string, any>): Promise<{ data: Record<string, any> }>
157
+
158
+ BroadcastCommit(
159
+ input: BroadcastInput,
160
+ options?: RequestOptions
161
+ ): Promise<Readonly<{ readonly data: JSONValue }>>
162
+
163
+ BroadcastSync(
164
+ input: BroadcastInput,
165
+ options?: RequestOptions
166
+ ): Promise<Readonly<{ readonly data: JSONValue }>>
167
+
168
+ Broadcast(
169
+ input: BroadcastInput,
170
+ options?: RequestOptions
171
+ ): Promise<Readonly<{ readonly data: JSONValue }>>
172
+
173
+ broadcast(
174
+ input: BroadcastInput,
175
+ sync?: boolean,
176
+ commit?: boolean,
177
+ options?: RequestOptions
178
+ ): Promise<Readonly<{ readonly data: JSONValue }>>
179
+
128
180
  Bulk(
129
- addresses: string[],
130
- signedData: Record<string, any>,
131
- maxHeight?: number,
132
- chainName?: string,
133
- chainVersion?: string
134
- ): Promise<{ data: Record<string, any> }>
181
+ addresses?: readonly string[],
182
+ signedData?: Readonly<Record<string, string>>,
183
+ maxHeight?: number | null,
184
+ chainName?: string | null,
185
+ chainVersion?: string | null,
186
+ options?: RequestOptions
187
+ ): Promise<JSONValue>
135
188
  }
136
-
137
- export = TCaBCIClient