@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/README.md +62 -46
- package/block.d.ts +19 -10
- package/block.js +39 -41
- package/breaker.d.ts +5 -1
- package/breaker.js +47 -44
- package/bytea.d.ts +1 -0
- package/bytea.js +16 -0
- package/callback.d.ts +12 -7
- package/client.d.ts +170 -119
- package/client.js +465 -315
- package/errors.d.ts +16 -2
- package/errors.js +5 -1
- package/http.d.ts +31 -6
- package/http.js +285 -51
- package/message.d.ts +48 -45
- package/message.js +77 -53
- package/package.json +16 -10
- package/transaction.d.ts +178 -92
- package/transaction.js +96 -69
- package/types.d.ts +60 -0
- package/util.d.ts +4 -0
- package/util.js +20 -6
- package/validation.d.ts +28 -0
- package/validation.js +155 -0
- package/websocket.d.ts +35 -15
- package/websocket.js +129 -43
- package/websocketOptions.d.ts +48 -10
- package/websocketOptions.js +53 -23
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
|
-
|
|
64
|
+
/** Call Start to initiate a socket; the success callback reports OPEN. */
|
|
65
|
+
export default class TCaBCIClient {
|
|
10
66
|
constructor(
|
|
11
|
-
readNodeAddresses
|
|
12
|
-
wsLibrary
|
|
13
|
-
chainName
|
|
14
|
-
chainVersion
|
|
67
|
+
readNodeAddresses?: readonly string[],
|
|
68
|
+
wsLibrary?: WebSocketConstructor,
|
|
69
|
+
chainName?: string | null,
|
|
70
|
+
chainVersion?: string | null,
|
|
71
|
+
options?: ClientOptions
|
|
15
72
|
)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
24
|
-
get
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
):
|
|
40
|
-
|
|
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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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
|
|
130
|
-
signedData
|
|
131
|
-
maxHeight?: number,
|
|
132
|
-
chainName?: string,
|
|
133
|
-
chainVersion?: string
|
|
134
|
-
|
|
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
|