viz-js-lib 0.12.3 → 0.12.5
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/.qoder/repowiki/en/content/API Reference/Configuration Options.md +129 -86
- package/.qoder/repowiki/en/content/Broadcast Transactions/Broadcast Transactions.md +180 -118
- package/.qoder/repowiki/en/content/Testing & Development.md +209 -140
- package/.qoder/repowiki/en/content/Utilities & Helpers.md +81 -81
- package/.qoder/repowiki/en/meta/repowiki-metadata.json +1 -1
- package/dist/statistics.html +1 -1
- package/dist/viz-tests.min.js.gz +0 -0
- package/dist/viz.min.js +6 -6
- package/dist/viz.min.js.gz +0 -0
- package/lib/auth/serializer/src/ChainTypes.js +2 -1
- package/lib/auth/serializer/src/operations.js +35 -2
- package/lib/broadcast/operations.js +4 -0
- package/package.json +3 -2
- package/webpack/makeConfig.js +3 -0
|
@@ -11,11 +11,21 @@
|
|
|
11
11
|
- [api/transports/ws.js](file://src/api/transports/ws.js)
|
|
12
12
|
- [api/transports/http.js](file://src/api/transports/http.js)
|
|
13
13
|
- [broadcast/index.js](file://src/broadcast/index.js)
|
|
14
|
+
- [broadcast/helpers.js](file://src/broadcast/helpers.js)
|
|
15
|
+
- [broadcast/operations.js](file://src/broadcast/operations.js)
|
|
14
16
|
- [package.json](file://package.json)
|
|
15
17
|
- [examples/index.html](file://examples/index.html)
|
|
16
18
|
- [examples/server.js](file://examples/server.js)
|
|
19
|
+
- [examples/broadcast.html](file://examples/broadcast.html)
|
|
17
20
|
</cite>
|
|
18
21
|
|
|
22
|
+
## Update Summary
|
|
23
|
+
**Changes Made**
|
|
24
|
+
- Added documentation for new configuration options: `reference_irreversible_block` and `tx_expiration_seconds`
|
|
25
|
+
- Updated Configuration Reference section with comprehensive details about the new options
|
|
26
|
+
- Enhanced Broadcast Configuration section to explain the impact of these new options
|
|
27
|
+
- Updated Troubleshooting Guide to include guidance for the new configuration options
|
|
28
|
+
|
|
19
29
|
## Table of Contents
|
|
20
30
|
1. [Introduction](#introduction)
|
|
21
31
|
2. [Project Structure](#project-structure)
|
|
@@ -32,7 +42,7 @@
|
|
|
32
42
|
This document explains the configuration system of the VIZ JavaScript library. It covers all configurable parameters, default values, and how they are resolved and applied across transports and broadcasting. It also documents environment-specific behavior (browser vs Node.js), security-related settings, and provides practical guidance for programmatic configuration changes, validation, and performance tuning.
|
|
33
43
|
|
|
34
44
|
## Project Structure
|
|
35
|
-
The configuration system centers around a small, shared configuration module that exposes getter/setter functions. Defaults are loaded from a JSON file and can be overridden at runtime. The API module reads the configured endpoint to select a transport (WebSocket or HTTP), while the broadcaster consults
|
|
45
|
+
The configuration system centers around a small, shared configuration module that exposes getter/setter functions. Defaults are loaded from a JSON file and can be overridden at runtime. The API module reads the configured endpoint to select a transport (WebSocket or HTTP), while the broadcaster consults configuration flags to choose the appropriate broadcast method and transaction preparation strategy.
|
|
36
46
|
|
|
37
47
|
```mermaid
|
|
38
48
|
graph TB
|
|
@@ -44,55 +54,57 @@ api["api/index.js<br/>VIZ class"] --> cfg
|
|
|
44
54
|
api --> tr_ws["transports/ws.js"]
|
|
45
55
|
api --> tr_http["transports/http.js"]
|
|
46
56
|
bcast["broadcast/index.js<br/>Broadcast logic"] --> cfg
|
|
47
|
-
ex_b["examples/
|
|
57
|
+
ex_b["examples/broadcast.html<br/>Broadcast usage"] --> bcast
|
|
48
58
|
ex_s["examples/server.js<br/>Node usage"] --> idx
|
|
49
59
|
```
|
|
50
60
|
|
|
51
61
|
**Diagram sources**
|
|
52
|
-
- [config.js](file://src/config.js#L1-L10)
|
|
53
|
-
- [config.json](file://config.json#L1-
|
|
54
|
-
- [index.js](file://src/index.js#L1-L20)
|
|
55
|
-
- [browser.js](file://src/browser.js#L1-L30)
|
|
56
|
-
- [package.json](file://package.json#L15-L18)
|
|
57
|
-
- [api/index.js](file://src/api/index.js#L1-L271)
|
|
58
|
-
- [api/transports/ws.js](file://src/api/transports/ws.js#L1-L136)
|
|
59
|
-
- [api/transports/http.js](file://src/api/transports/http.js#L1-L53)
|
|
60
|
-
- [broadcast/index.js](file://src/broadcast/index.js#L1-
|
|
61
|
-
- [examples/
|
|
62
|
-
- [examples/server.js](file://examples/server.js#L1-L34)
|
|
62
|
+
- [config.js:1-10](file://src/config.js#L1-L10)
|
|
63
|
+
- [config.json:1-9](file://config.json#L1-L9)
|
|
64
|
+
- [index.js:1-20](file://src/index.js#L1-L20)
|
|
65
|
+
- [browser.js:1-30](file://src/browser.js#L1-L30)
|
|
66
|
+
- [package.json:15-18](file://package.json#L15-L18)
|
|
67
|
+
- [api/index.js:1-271](file://src/api/index.js#L1-L271)
|
|
68
|
+
- [api/transports/ws.js:1-136](file://src/api/transports/ws.js#L1-L136)
|
|
69
|
+
- [api/transports/http.js:1-53](file://src/api/transports/http.js#L1-L53)
|
|
70
|
+
- [broadcast/index.js:1-146](file://src/broadcast/index.js#L1-L146)
|
|
71
|
+
- [examples/broadcast.html:1-108](file://examples/broadcast.html#L1-L108)
|
|
72
|
+
- [examples/server.js:1-34](file://examples/server.js#L1-L34)
|
|
63
73
|
|
|
64
74
|
**Section sources**
|
|
65
|
-
- [config.js](file://src/config.js#L1-L10)
|
|
66
|
-
- [config.json](file://config.json#L1-
|
|
67
|
-
- [index.js](file://src/index.js#L1-L20)
|
|
68
|
-
- [browser.js](file://src/browser.js#L1-L30)
|
|
69
|
-
- [package.json](file://package.json#L15-L18)
|
|
70
|
-
- [examples/
|
|
71
|
-
- [examples/server.js](file://examples/server.js#L1-L34)
|
|
75
|
+
- [config.js:1-10](file://src/config.js#L1-L10)
|
|
76
|
+
- [config.json:1-9](file://config.json#L1-L9)
|
|
77
|
+
- [index.js:1-20](file://src/index.js#L1-L20)
|
|
78
|
+
- [browser.js:1-30](file://src/browser.js#L1-L30)
|
|
79
|
+
- [package.json:15-18](file://package.json#L15-L18)
|
|
80
|
+
- [examples/broadcast.html:1-108](file://examples/broadcast.html#L1-L108)
|
|
81
|
+
- [examples/server.js:1-34](file://examples/server.js#L1-L34)
|
|
72
82
|
|
|
73
83
|
## Core Components
|
|
74
84
|
- Configuration module: Provides a simple key-value store with get and set functions backed by defaults loaded from config.json.
|
|
75
|
-
- Defaults: Address prefix, chain ID,
|
|
85
|
+
- Defaults: Address prefix, chain ID, broadcast behavior, transaction expiration, and irreversible block reference are defined centrally.
|
|
76
86
|
- API module: Reads the configured endpoint to dynamically select a transport (WebSocket or HTTP) and manages lifecycle.
|
|
77
87
|
- Transports: WebSocket transport uses the configured endpoint; HTTP transport uses the same endpoint for JSON-RPC calls.
|
|
78
|
-
- Broadcast module: Uses
|
|
88
|
+
- Broadcast module: Uses configuration flags to choose synchronous or callback-based broadcast and to control transaction preparation strategy.
|
|
79
89
|
|
|
80
90
|
Key configuration parameters:
|
|
81
91
|
- websocket: Endpoint URL for the node (WebSocket or HTTP). Used by both transports.
|
|
82
92
|
- address_prefix: Chain identifier prefix used in address encoding.
|
|
83
93
|
- chain_id: Unique chain identifier for signing and verification.
|
|
84
94
|
- broadcast_transaction_with_callback: Boolean switch controlling broadcast method selection.
|
|
95
|
+
- reference_irreversible_block: Boolean flag controlling whether to reference irreversible blocks for transaction validity.
|
|
96
|
+
- tx_expiration_seconds: Number of seconds after which transactions expire.
|
|
85
97
|
|
|
86
98
|
**Section sources**
|
|
87
|
-
- [config.js](file://src/config.js#L1-L10)
|
|
88
|
-
- [config.json](file://config.json#L1-
|
|
89
|
-
- [api/index.js](file://src/api/index.js#L34-L62)
|
|
90
|
-
- [api/transports/ws.js](file://src/api/transports/ws.js#L34-L48)
|
|
91
|
-
- [api/transports/http.js](file://src/api/transports/http.js#L48-L51)
|
|
92
|
-
- [broadcast/index.js](file://src/broadcast/index.js#L41-L43)
|
|
99
|
+
- [config.js:1-10](file://src/config.js#L1-L10)
|
|
100
|
+
- [config.json:1-9](file://config.json#L1-L9)
|
|
101
|
+
- [api/index.js:34-62](file://src/api/index.js#L34-L62)
|
|
102
|
+
- [api/transports/ws.js:34-48](file://src/api/transports/ws.js#L34-L48)
|
|
103
|
+
- [api/transports/http.js:48-51](file://src/api/transports/http.js#L48-L51)
|
|
104
|
+
- [broadcast/index.js:41-43](file://src/broadcast/index.js#L41-L43)
|
|
93
105
|
|
|
94
106
|
## Architecture Overview
|
|
95
|
-
The configuration system is intentionally minimal and centralized. Defaults are loaded once and can be overridden at runtime. The API module inspects the configured endpoint to determine the transport type and delegates all communication to the selected transport. Broadcasting logic reads
|
|
107
|
+
The configuration system is intentionally minimal and centralized. Defaults are loaded once and can be overridden at runtime. The API module inspects the configured endpoint to determine the transport type and delegates all communication to the selected transport. Broadcasting logic reads configuration flags to decide which broadcast method to use and how to prepare transactions.
|
|
96
108
|
|
|
97
109
|
```mermaid
|
|
98
110
|
sequenceDiagram
|
|
@@ -119,9 +131,9 @@ end
|
|
|
119
131
|
```
|
|
120
132
|
|
|
121
133
|
**Diagram sources**
|
|
122
|
-
- [api/index.js](file://src/api/index.js#L34-L62)
|
|
123
|
-
- [api/transports/ws.js](file://src/api/transports/ws.js#L34-L48)
|
|
124
|
-
- [api/transports/http.js](file://src/api/transports/http.js#L48-L51)
|
|
134
|
+
- [api/index.js:34-62](file://src/api/index.js#L34-L62)
|
|
135
|
+
- [api/transports/ws.js:34-48](file://src/api/transports/ws.js#L34-L48)
|
|
136
|
+
- [api/transports/http.js:48-51](file://src/api/transports/http.js#L48-L51)
|
|
125
137
|
|
|
126
138
|
## Detailed Component Analysis
|
|
127
139
|
|
|
@@ -139,12 +151,12 @@ Get --> Return["Return stored value"]
|
|
|
139
151
|
```
|
|
140
152
|
|
|
141
153
|
**Diagram sources**
|
|
142
|
-
- [config.js](file://src/config.js#L3-L9)
|
|
143
|
-
- [config.json](file://config.json#L1-
|
|
154
|
+
- [config.js:3-9](file://src/config.js#L3-L9)
|
|
155
|
+
- [config.json:1-9](file://config.json#L1-L9)
|
|
144
156
|
|
|
145
157
|
**Section sources**
|
|
146
|
-
- [config.js](file://src/config.js#L1-L10)
|
|
147
|
-
- [config.json](file://config.json#L1-
|
|
158
|
+
- [config.js:1-10](file://src/config.js#L1-L10)
|
|
159
|
+
- [config.json:1-9](file://config.json#L1-L9)
|
|
148
160
|
|
|
149
161
|
### Defaults and Environment
|
|
150
162
|
- Defaults are defined in config.json and consumed by the configuration module.
|
|
@@ -155,9 +167,9 @@ Environment-specific notes:
|
|
|
155
167
|
- The WebSocket transport selects the appropriate WebSocket class depending on the environment (Node vs browser).
|
|
156
168
|
|
|
157
169
|
**Section sources**
|
|
158
|
-
- [config.json](file://config.json#L1-
|
|
159
|
-
- [package.json](file://package.json#L15-L18)
|
|
160
|
-
- [api/transports/ws.js](file://src/api/transports/ws.js#L8-L14)
|
|
170
|
+
- [config.json:1-9](file://config.json#L1-L9)
|
|
171
|
+
- [package.json:15-18](file://package.json#L15-L18)
|
|
172
|
+
- [api/transports/ws.js:8-14](file://src/api/transports/ws.js#L8-L14)
|
|
161
173
|
|
|
162
174
|
### API Transport Selection
|
|
163
175
|
- The API module determines the transport based on the configured endpoint:
|
|
@@ -176,13 +188,13 @@ D --> |No| F["Throw error: unknown transport"]
|
|
|
176
188
|
```
|
|
177
189
|
|
|
178
190
|
**Diagram sources**
|
|
179
|
-
- [api/index.js](file://src/api/index.js#L34-L42)
|
|
180
|
-
- [api/transports/ws.js](file://src/api/transports/ws.js#L34-L48)
|
|
181
|
-
- [api/transports/http.js](file://src/api/transports/http.js#L48-L51)
|
|
191
|
+
- [api/index.js:34-42](file://src/api/index.js#L34-L42)
|
|
192
|
+
- [api/transports/ws.js:34-48](file://src/api/transports/ws.js#L34-L48)
|
|
193
|
+
- [api/transports/http.js:48-51](file://src/api/transports/http.js#L48-L51)
|
|
182
194
|
|
|
183
195
|
**Section sources**
|
|
184
|
-
- [api/index.js](file://src/api/index.js#L34-L62)
|
|
185
|
-
- [api/transports/base.js](file://src/api/transports/base.js#L1-L34)
|
|
196
|
+
- [api/index.js:34-62](file://src/api/index.js#L34-L62)
|
|
197
|
+
- [api/transports/base.js:1-34](file://src/api/transports/base.js#L1-L34)
|
|
186
198
|
|
|
187
199
|
### WebSocket Transport
|
|
188
200
|
- Creates a WebSocket connection using the configured endpoint.
|
|
@@ -206,10 +218,10 @@ WS-->>API : resolve/reject
|
|
|
206
218
|
```
|
|
207
219
|
|
|
208
220
|
**Diagram sources**
|
|
209
|
-
- [api/transports/ws.js](file://src/api/transports/ws.js#L27-L94)
|
|
221
|
+
- [api/transports/ws.js:27-94](file://src/api/transports/ws.js#L27-L94)
|
|
210
222
|
|
|
211
223
|
**Section sources**
|
|
212
|
-
- [api/transports/ws.js](file://src/api/transports/ws.js#L1-L136)
|
|
224
|
+
- [api/transports/ws.js:1-136](file://src/api/transports/ws.js#L1-L136)
|
|
213
225
|
|
|
214
226
|
### HTTP Transport
|
|
215
227
|
- Issues JSON-RPC POST requests against the configured endpoint.
|
|
@@ -229,29 +241,37 @@ HTTP-->>API : resolve/reject
|
|
|
229
241
|
```
|
|
230
242
|
|
|
231
243
|
**Diagram sources**
|
|
232
|
-
- [api/transports/http.js](file://src/api/transports/http.js#L43-L52)
|
|
244
|
+
- [api/transports/http.js:43-52](file://src/api/transports/http.js#L43-L52)
|
|
233
245
|
|
|
234
246
|
**Section sources**
|
|
235
|
-
- [api/transports/http.js](file://src/api/transports/http.js#L1-L53)
|
|
247
|
+
- [api/transports/http.js:1-53](file://src/api/transports/http.js#L1-L53)
|
|
236
248
|
|
|
237
249
|
### Broadcast Configuration
|
|
238
250
|
- The broadcaster conditionally chooses between two broadcast methods based on a boolean flag.
|
|
239
251
|
- The flag is read from configuration, enabling or disabling callback-based broadcasting.
|
|
252
|
+
- Transaction preparation uses configuration values to set expiration and reference blocks.
|
|
253
|
+
|
|
254
|
+
**Updated** Enhanced to include new configuration options for transaction preparation
|
|
240
255
|
|
|
241
256
|
```mermaid
|
|
242
257
|
flowchart TD
|
|
243
258
|
Start(["Broadcast request"]) --> Check["Read flag from config"]
|
|
244
259
|
Check --> |true| CB["Use broadcast with callback"]
|
|
245
260
|
Check --> |false| Sync["Use synchronous broadcast"]
|
|
246
|
-
CB -->
|
|
247
|
-
Sync -->
|
|
261
|
+
CB --> Prep["Prepare transaction with config"]
|
|
262
|
+
Sync --> Prep
|
|
263
|
+
Prep --> Exp["Set expiration from tx_expiration_seconds"]
|
|
264
|
+
Prep --> Ref["Set reference block from reference_irreversible_block"]
|
|
265
|
+
Exp --> Done(["Return signed transaction"])
|
|
266
|
+
Ref --> Done
|
|
248
267
|
```
|
|
249
268
|
|
|
250
269
|
**Diagram sources**
|
|
251
|
-
- [broadcast/index.js](file://src/broadcast/index.js#L41-L43)
|
|
270
|
+
- [broadcast/index.js:41-43](file://src/broadcast/index.js#L41-L43)
|
|
271
|
+
- [broadcast/index.js:49-93](file://src/broadcast/index.js#L49-L93)
|
|
252
272
|
|
|
253
273
|
**Section sources**
|
|
254
|
-
- [broadcast/index.js](file://src/broadcast/index.js#L1-
|
|
274
|
+
- [broadcast/index.js:1-146](file://src/broadcast/index.js#L1-L146)
|
|
255
275
|
|
|
256
276
|
### Programmatic Configuration Changes
|
|
257
277
|
- To change the endpoint, use the configuration setter with the key for the endpoint.
|
|
@@ -264,19 +284,19 @@ Practical steps:
|
|
|
264
284
|
- Restart after changes: stop and start the API to reinitialize the transport.
|
|
265
285
|
|
|
266
286
|
**Section sources**
|
|
267
|
-
- [config.js](file://src/config.js#L5-L8)
|
|
268
|
-
- [api/index.js](file://src/api/index.js#L44-L62)
|
|
269
|
-
- [examples/
|
|
270
|
-
- [examples/server.js](file://examples/server.js#L1-L34)
|
|
287
|
+
- [config.js:5-8](file://src/config.js#L5-L8)
|
|
288
|
+
- [api/index.js:44-62](file://src/api/index.js#L44-L62)
|
|
289
|
+
- [examples/broadcast.html:1-108](file://examples/broadcast.html#L1-L108)
|
|
290
|
+
- [examples/server.js:1-34](file://examples/server.js#L1-L34)
|
|
271
291
|
|
|
272
292
|
### Security-Related Settings
|
|
273
293
|
- address_prefix and chain_id are part of the default configuration and are used during signing and verification routines elsewhere in the library. They ensure signatures are bound to the correct chain and address format.
|
|
274
294
|
- The endpoint configuration itself does not include TLS settings; however, secure variants (wss, https) should be used to protect communications.
|
|
275
295
|
|
|
276
296
|
**Section sources**
|
|
277
|
-
- [config.json](file://config.json#L3-L4)
|
|
278
|
-
- [api/transports/ws.js](file://src/api/transports/ws.js#L34-L48)
|
|
279
|
-
- [api/transports/http.js](file://src/api/transports/http.js#L19-L27)
|
|
297
|
+
- [config.json:3-4](file://config.json#L3-L4)
|
|
298
|
+
- [api/transports/ws.js:34-48](file://src/api/transports/ws.js#L34-L48)
|
|
299
|
+
- [api/transports/http.js:19-27](file://src/api/transports/http.js#L19-L27)
|
|
280
300
|
|
|
281
301
|
### Environment-Specific Behavior (Browser vs Node.js)
|
|
282
302
|
- The browser build disables certain Node-specific modules via the browser field in package.json.
|
|
@@ -284,12 +304,12 @@ Practical steps:
|
|
|
284
304
|
- The HTTP transport relies on cross-fetch, which is designed to work in both environments.
|
|
285
305
|
|
|
286
306
|
**Section sources**
|
|
287
|
-
- [package.json](file://package.json#L15-L18)
|
|
288
|
-
- [api/transports/ws.js](file://src/api/transports/ws.js#L8-L14)
|
|
289
|
-
- [api/transports/http.js](file://src/api/transports/http.js#L1-L2)
|
|
307
|
+
- [package.json:15-18](file://package.json#L15-L18)
|
|
308
|
+
- [api/transports/ws.js:8-14](file://src/api/transports/ws.js#L8-L14)
|
|
309
|
+
- [api/transports/http.js:1-2](file://src/api/transports/http.js#L1-L2)
|
|
290
310
|
|
|
291
311
|
## Dependency Analysis
|
|
292
|
-
The configuration module is a thin layer that underpins the API and broadcast modules. The API module depends on configuration for transport selection and lifecycle management. The transport modules depend on configuration for the endpoint. The broadcast module depends on configuration for the broadcast method.
|
|
312
|
+
The configuration module is a thin layer that underpins the API and broadcast modules. The API module depends on configuration for transport selection and lifecycle management. The transport modules depend on configuration for the endpoint. The broadcast module depends on configuration for the broadcast method and transaction preparation.
|
|
293
313
|
|
|
294
314
|
```mermaid
|
|
295
315
|
graph LR
|
|
@@ -298,21 +318,27 @@ Config --> Bcast["broadcast/index.js"]
|
|
|
298
318
|
API --> T_WS["transports/ws.js"]
|
|
299
319
|
API --> T_HTTP["transports/http.js"]
|
|
300
320
|
API --> T_Base["transports/base.js"]
|
|
321
|
+
Bcast --> Helpers["broadcast/helpers.js"]
|
|
322
|
+
Bcast --> Ops["broadcast/operations.js"]
|
|
301
323
|
```
|
|
302
324
|
|
|
303
325
|
**Diagram sources**
|
|
304
|
-
- [config.js](file://src/config.js#L1-L10)
|
|
305
|
-
- [api/index.js](file://src/api/index.js#L1-L271)
|
|
306
|
-
- [broadcast/index.js](file://src/broadcast/index.js#L1-
|
|
307
|
-
- [
|
|
308
|
-
- [
|
|
309
|
-
- [api/transports/
|
|
326
|
+
- [config.js:1-10](file://src/config.js#L1-L10)
|
|
327
|
+
- [api/index.js:1-271](file://src/api/index.js#L1-L271)
|
|
328
|
+
- [broadcast/index.js:1-146](file://src/broadcast/index.js#L1-L146)
|
|
329
|
+
- [broadcast/helpers.js:1-82](file://src/broadcast/helpers.js#L1-L82)
|
|
330
|
+
- [broadcast/operations.js:1-475](file://src/broadcast/operations.js#L1-L475)
|
|
331
|
+
- [api/transports/base.js:1-34](file://src/api/transports/base.js#L1-L34)
|
|
332
|
+
- [api/transports/ws.js:1-136](file://src/api/transports/ws.js#L1-L136)
|
|
333
|
+
- [api/transports/http.js:1-53](file://src/api/transports/http.js#L1-L53)
|
|
310
334
|
|
|
311
335
|
**Section sources**
|
|
312
|
-
- [config.js](file://src/config.js#L1-L10)
|
|
313
|
-
- [api/index.js](file://src/api/index.js#L1-L271)
|
|
314
|
-
- [broadcast/index.js](file://src/broadcast/index.js#L1-
|
|
315
|
-
- [
|
|
336
|
+
- [config.js:1-10](file://src/config.js#L1-L10)
|
|
337
|
+
- [api/index.js:1-271](file://src/api/index.js#L1-L271)
|
|
338
|
+
- [broadcast/index.js:1-146](file://src/broadcast/index.js#L1-L146)
|
|
339
|
+
- [broadcast/helpers.js:1-82](file://src/broadcast/helpers.js#L1-L82)
|
|
340
|
+
- [broadcast/operations.js:1-475](file://src/broadcast/operations.js#L1-L475)
|
|
341
|
+
- [api/transports/base.js:1-34](file://src/api/transports/base.js#L1-L34)
|
|
316
342
|
|
|
317
343
|
## Performance Considerations
|
|
318
344
|
- Transport selection: Using WebSocket (wss) can reduce overhead compared to repeated HTTP requests, especially for streaming or frequent polling scenarios.
|
|
@@ -320,8 +346,8 @@ API --> T_Base["transports/base.js"]
|
|
|
320
346
|
- Request batching: Where applicable, batch operations to reduce round trips.
|
|
321
347
|
- Logging and debugging: The API emits performance tracking events; enable only when needed to avoid overhead.
|
|
322
348
|
- Browser vs Node: In browsers, ensure the WebSocket class is available; in Node, ensure the ws dependency is present.
|
|
323
|
-
|
|
324
|
-
|
|
349
|
+
- Transaction expiration: Adjust tx_expiration_seconds based on network conditions and expected confirmation times.
|
|
350
|
+
- Irreversible block reference: Enable reference_irreversible_block for higher transaction safety at the cost of slower confirmation times.
|
|
325
351
|
|
|
326
352
|
## Troubleshooting Guide
|
|
327
353
|
Common configuration issues and resolutions:
|
|
@@ -329,22 +355,23 @@ Common configuration issues and resolutions:
|
|
|
329
355
|
- Connection failures: Verify the endpoint is reachable and uses secure variants (wss/https) when required by policy.
|
|
330
356
|
- Incorrect broadcast behavior: Confirm the broadcast flag is set appropriately for your needs.
|
|
331
357
|
- Environment mismatch: In browsers, confirm that Node-specific modules are disabled and that the WebSocket class is available.
|
|
358
|
+
- Transaction expiration errors: Adjust tx_expiration_seconds based on network conditions and expected confirmation times.
|
|
359
|
+
- Irreversible block reference issues: Disable reference_irreversible_block if the node doesn't support irreversible block references.
|
|
332
360
|
|
|
333
361
|
Operational checks:
|
|
334
362
|
- Validate endpoint format before setting it.
|
|
335
363
|
- Restart the API after changing the endpoint to ensure the new transport is initialized.
|
|
336
364
|
- Monitor transport logs and performance events to diagnose issues.
|
|
365
|
+
- Test transaction broadcasting with different configuration combinations to verify behavior.
|
|
337
366
|
|
|
338
367
|
**Section sources**
|
|
339
|
-
- [api/index.js](file://src/api/index.js#L34-L42)
|
|
340
|
-
- [api/transports/ws.js](file://src/api/transports/ws.js#L34-L48)
|
|
341
|
-
- [api/transports/http.js](file://src/api/transports/http.js#L48-L51)
|
|
342
|
-
- [broadcast/index.js](file://src/broadcast/index.js#L41-L43)
|
|
368
|
+
- [api/index.js:34-42](file://src/api/index.js#L34-L42)
|
|
369
|
+
- [api/transports/ws.js:34-48](file://src/api/transports/ws.js#L34-L48)
|
|
370
|
+
- [api/transports/http.js:48-51](file://src/api/transports/http.js#L48-L51)
|
|
371
|
+
- [broadcast/index.js:41-43](file://src/broadcast/index.js#L41-L43)
|
|
343
372
|
|
|
344
373
|
## Conclusion
|
|
345
|
-
The VIZ JavaScript library
|
|
346
|
-
|
|
347
|
-
[No sources needed since this section summarizes without analyzing specific files]
|
|
374
|
+
The VIZ JavaScript library's configuration system is intentionally simple and centralized. Defaults are loaded from a JSON file and can be overridden at runtime. The API module uses the configured endpoint to select the appropriate transport, while the broadcast module uses configuration flags to choose the broadcast method and control transaction preparation. Understanding these mechanisms enables safe and efficient configuration across environments and deployment scenarios.
|
|
348
375
|
|
|
349
376
|
## Appendices
|
|
350
377
|
|
|
@@ -353,15 +380,31 @@ The VIZ JavaScript library’s configuration system is intentionally simple and
|
|
|
353
380
|
- address_prefix: Chain identifier prefix used in address encoding.
|
|
354
381
|
- chain_id: Unique chain identifier for signing and verification.
|
|
355
382
|
- broadcast_transaction_with_callback: Boolean flag controlling broadcast method selection.
|
|
383
|
+
- reference_irreversible_block: **New** Boolean flag controlling whether to reference irreversible blocks for transaction validity. When true, transactions reference the last irreversible block; when false, they reference the head block.
|
|
384
|
+
- tx_expiration_seconds: **New** Number of seconds after which transactions expire. Controls how long transactions remain valid for submission to the network.
|
|
385
|
+
|
|
386
|
+
**Updated** Added documentation for new configuration options
|
|
356
387
|
|
|
357
388
|
**Section sources**
|
|
358
|
-
- [config.json](file://config.json#L1-
|
|
359
|
-
- [broadcast/index.js](file://src/broadcast/index.js#
|
|
389
|
+
- [config.json:1-9](file://config.json#L1-L9)
|
|
390
|
+
- [broadcast/index.js:49-93](file://src/broadcast/index.js#L49-L93)
|
|
360
391
|
|
|
361
392
|
### Example Usage Patterns
|
|
362
393
|
- Browser usage: Initialize the library and call API methods after configuring the endpoint.
|
|
363
394
|
- Node.js usage: Require the library and call API methods after configuring the endpoint.
|
|
395
|
+
- Transaction configuration: Set reference_irreversible_block to true for higher safety or false for faster confirmation times.
|
|
396
|
+
- Expiration configuration: Adjust tx_expiration_seconds based on network conditions and expected confirmation targets.
|
|
397
|
+
|
|
398
|
+
**Section sources**
|
|
399
|
+
- [examples/broadcast.html:1-108](file://examples/broadcast.html#L1-L108)
|
|
400
|
+
- [examples/server.js:1-34](file://examples/server.js#L1-L34)
|
|
401
|
+
|
|
402
|
+
### Best Practices for Configuration
|
|
403
|
+
- Production environments: Set reference_irreversible_block to true for maximum transaction safety, adjust tx_expiration_seconds based on expected confirmation times.
|
|
404
|
+
- Development environments: Set reference_irreversible_block to false for faster testing cycles, use shorter tx_expiration_seconds.
|
|
405
|
+
- High-frequency operations: Consider enabling reference_irreversible_block to prevent transaction reverts due to fork conflicts.
|
|
406
|
+
- Network reliability: Increase tx_expiration_seconds on unreliable networks to accommodate longer confirmation times.
|
|
364
407
|
|
|
365
408
|
**Section sources**
|
|
366
|
-
- [
|
|
367
|
-
- [
|
|
409
|
+
- [broadcast/index.js:49-93](file://src/broadcast/index.js#L49-L93)
|
|
410
|
+
- [config.json:6-7](file://config.json#L6-L7)
|