viz-js-lib 0.11.0 → 0.12.4

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.
Files changed (60) hide show
  1. package/.qoder/docs/spec/viz-dns-nameserver-spec.md +982 -0
  2. package/.qoder/docs/viz-cpp-node-docs/data-types.md +322 -0
  3. package/.qoder/docs/viz-cpp-node-docs/index.md +160 -0
  4. package/.qoder/docs/viz-cpp-node-docs/op-account-market.md +236 -0
  5. package/.qoder/docs/viz-cpp-node-docs/op-account.md +199 -0
  6. package/.qoder/docs/viz-cpp-node-docs/op-award.md +162 -0
  7. package/.qoder/docs/viz-cpp-node-docs/op-committee.md +193 -0
  8. package/.qoder/docs/viz-cpp-node-docs/op-content.md +157 -0
  9. package/.qoder/docs/viz-cpp-node-docs/op-escrow.md +224 -0
  10. package/.qoder/docs/viz-cpp-node-docs/op-invite.md +219 -0
  11. package/.qoder/docs/viz-cpp-node-docs/op-proposal.md +229 -0
  12. package/.qoder/docs/viz-cpp-node-docs/op-recovery.md +188 -0
  13. package/.qoder/docs/viz-cpp-node-docs/op-subscription.md +146 -0
  14. package/.qoder/docs/viz-cpp-node-docs/op-transfer-vesting.md +224 -0
  15. package/.qoder/docs/viz-cpp-node-docs/op-witness.md +252 -0
  16. package/.qoder/docs/viz-cpp-node-docs/plugins.md +887 -0
  17. package/.qoder/docs/viz-cpp-node-docs/virtual-operations.md +513 -0
  18. package/.qoder/repowiki/en/content/API Reference/API Reference.md +724 -0
  19. package/.qoder/repowiki/en/content/API Reference/Configuration Options.md +410 -0
  20. package/.qoder/repowiki/en/content/API Reference/Core API Methods.md +547 -0
  21. package/.qoder/repowiki/en/content/API Reference/Streaming APIs.md +380 -0
  22. package/.qoder/repowiki/en/content/API Reference/Transport Layer.md +341 -0
  23. package/.qoder/repowiki/en/content/API Reference/VIZ Blockchain Operations Coverage Status.md +427 -0
  24. package/.qoder/repowiki/en/content/Authentication & Cryptography/Authentication & Cryptography.md +430 -0
  25. package/.qoder/repowiki/en/content/Authentication & Cryptography/Digital Signatures.md +462 -0
  26. package/.qoder/repowiki/en/content/Authentication & Cryptography/Key Management.md +456 -0
  27. package/.qoder/repowiki/en/content/Authentication & Cryptography/Memo Encryption.md +331 -0
  28. package/.qoder/repowiki/en/content/Authentication & Cryptography/Security Practices.md +488 -0
  29. package/.qoder/repowiki/en/content/Broadcast Transactions/Broadcast Transactions.md +432 -0
  30. package/.qoder/repowiki/en/content/Broadcast Transactions/Network Broadcasting.md +418 -0
  31. package/.qoder/repowiki/en/content/Broadcast Transactions/Operation Construction.md +352 -0
  32. package/.qoder/repowiki/en/content/Broadcast Transactions/Transaction Preparation.md +353 -0
  33. package/.qoder/repowiki/en/content/Broadcast Transactions/Transaction Signing.md +404 -0
  34. package/.qoder/repowiki/en/content/Data Serialization/Data Serialization.md +540 -0
  35. package/.qoder/repowiki/en/content/Data Serialization/Encoding & Decoding.md +463 -0
  36. package/.qoder/repowiki/en/content/Data Serialization/Object Templates.md +413 -0
  37. package/.qoder/repowiki/en/content/Data Serialization/Type System.md +514 -0
  38. package/.qoder/repowiki/en/content/Data Serialization/Validation Rules.md +439 -0
  39. package/.qoder/repowiki/en/content/Examples & Tutorials.md +485 -0
  40. package/.qoder/repowiki/en/content/Getting Started.md +345 -0
  41. package/.qoder/repowiki/en/content/Testing & Development.md +637 -0
  42. package/.qoder/repowiki/en/content/Utilities & Helpers.md +557 -0
  43. package/.qoder/repowiki/en/meta/repowiki-metadata.json +1 -0
  44. package/VIZ-JS-LIB-COVERAGE-STATUS.md +356 -0
  45. package/config.json +3 -1
  46. package/dist/statistics.html +1 -1
  47. package/dist/viz-tests.min.js +32 -42
  48. package/dist/viz-tests.min.js.gz +0 -0
  49. package/dist/viz.min.js +8 -18
  50. package/dist/viz.min.js.gz +0 -0
  51. package/lib/api/methods.js +24 -0
  52. package/lib/auth/serializer/src/ChainTypes.js +2 -1
  53. package/lib/auth/serializer/src/operations.js +35 -2
  54. package/lib/broadcast/index.js +29 -15
  55. package/lib/broadcast/operations.js +4 -0
  56. package/lib/dns.js +658 -0
  57. package/lib/index.js +3 -1
  58. package/package.json +3 -2
  59. package/test/dns.test.js +395 -0
  60. package/webpack/makeConfig.js +3 -0
@@ -0,0 +1,410 @@
1
+ # Configuration Options
2
+
3
+ <cite>
4
+ **Referenced Files in This Document**
5
+ - [config.js](file://src/config.js)
6
+ - [config.json](file://config.json)
7
+ - [index.js](file://src/index.js)
8
+ - [browser.js](file://src/browser.js)
9
+ - [api/index.js](file://src/api/index.js)
10
+ - [api/transports/base.js](file://src/api/transports/base.js)
11
+ - [api/transports/ws.js](file://src/api/transports/ws.js)
12
+ - [api/transports/http.js](file://src/api/transports/http.js)
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)
16
+ - [package.json](file://package.json)
17
+ - [examples/index.html](file://examples/index.html)
18
+ - [examples/server.js](file://examples/server.js)
19
+ - [examples/broadcast.html](file://examples/broadcast.html)
20
+ </cite>
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
+
29
+ ## Table of Contents
30
+ 1. [Introduction](#introduction)
31
+ 2. [Project Structure](#project-structure)
32
+ 3. [Core Components](#core-components)
33
+ 4. [Architecture Overview](#architecture-overview)
34
+ 5. [Detailed Component Analysis](#detailed-component-analysis)
35
+ 6. [Dependency Analysis](#dependency-analysis)
36
+ 7. [Performance Considerations](#performance-considerations)
37
+ 8. [Troubleshooting Guide](#troubleshooting-guide)
38
+ 9. [Conclusion](#conclusion)
39
+ 10. [Appendices](#appendices)
40
+
41
+ ## Introduction
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.
43
+
44
+ ## Project Structure
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.
46
+
47
+ ```mermaid
48
+ graph TB
49
+ cfg["config.js<br/>Exports get/set"] --> dflt["config.json<br/>Default values"]
50
+ idx["src/index.js<br/>Library entry"] --> cfg
51
+ br["src/browser.js<br/>Browser globals"] --> idx
52
+ pkg["package.json<br/>Build & env hints"] --> br
53
+ api["api/index.js<br/>VIZ class"] --> cfg
54
+ api --> tr_ws["transports/ws.js"]
55
+ api --> tr_http["transports/http.js"]
56
+ bcast["broadcast/index.js<br/>Broadcast logic"] --> cfg
57
+ ex_b["examples/broadcast.html<br/>Broadcast usage"] --> bcast
58
+ ex_s["examples/server.js<br/>Node usage"] --> idx
59
+ ```
60
+
61
+ **Diagram sources**
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)
73
+
74
+ **Section sources**
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)
82
+
83
+ ## Core Components
84
+ - Configuration module: Provides a simple key-value store with get and set functions backed by defaults loaded from config.json.
85
+ - Defaults: Address prefix, chain ID, broadcast behavior, transaction expiration, and irreversible block reference are defined centrally.
86
+ - API module: Reads the configured endpoint to dynamically select a transport (WebSocket or HTTP) and manages lifecycle.
87
+ - Transports: WebSocket transport uses the configured endpoint; HTTP transport uses the same endpoint for JSON-RPC calls.
88
+ - Broadcast module: Uses configuration flags to choose synchronous or callback-based broadcast and to control transaction preparation strategy.
89
+
90
+ Key configuration parameters:
91
+ - websocket: Endpoint URL for the node (WebSocket or HTTP). Used by both transports.
92
+ - address_prefix: Chain identifier prefix used in address encoding.
93
+ - chain_id: Unique chain identifier for signing and verification.
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.
97
+
98
+ **Section sources**
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)
105
+
106
+ ## Architecture Overview
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.
108
+
109
+ ```mermaid
110
+ sequenceDiagram
111
+ participant App as "Application"
112
+ participant Cfg as "config.get/set"
113
+ participant API as "VIZ.start()"
114
+ participant T_WS as "WsTransport"
115
+ participant T_HTTP as "HttpTransport"
116
+ App->>Cfg : set("websocket", url)
117
+ App->>API : start()
118
+ API->>Cfg : get("websocket")
119
+ API->>API : _setTransport(url)
120
+ alt url starts with ws/wss
121
+ API->>T_WS : new WsTransport()
122
+ T_WS->>Cfg : get("websocket")
123
+ T_WS-->>API : startPromise
124
+ else url starts with http/https
125
+ API->>T_HTTP : new HttpTransport()
126
+ T_HTTP->>Cfg : get("websocket")
127
+ T_HTTP-->>API : send(...)
128
+ else unknown
129
+ API-->>App : throws error
130
+ end
131
+ ```
132
+
133
+ **Diagram sources**
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)
137
+
138
+ ## Detailed Component Analysis
139
+
140
+ ### Configuration Module
141
+ - Purpose: Provide a shared configuration store with get and set.
142
+ - Behavior: Loads defaults from config.json and exposes functions to read/write keys.
143
+ - Scope: Shared across API, transports, and broadcast modules.
144
+
145
+ ```mermaid
146
+ flowchart TD
147
+ Start(["Access config"]) --> Get["config.get(key)"]
148
+ Start --> Set["config.set(key, value)"]
149
+ Set --> Store["Update in-memory config"]
150
+ Get --> Return["Return stored value"]
151
+ ```
152
+
153
+ **Diagram sources**
154
+ - [config.js:3-9](file://src/config.js#L3-L9)
155
+ - [config.json:1-9](file://config.json#L1-L9)
156
+
157
+ **Section sources**
158
+ - [config.js:1-10](file://src/config.js#L1-L10)
159
+ - [config.json:1-9](file://config.json#L1-L9)
160
+
161
+ ### Defaults and Environment
162
+ - Defaults are defined in config.json and consumed by the configuration module.
163
+ - package.json includes browser field entries indicating that certain Node-specific modules are disabled in the browser bundle, which affects transport availability and behavior.
164
+
165
+ Environment-specific notes:
166
+ - Browser builds disable certain Node-specific modules via the browser field, influencing WebSocket availability and polyfills.
167
+ - The WebSocket transport selects the appropriate WebSocket class depending on the environment (Node vs browser).
168
+
169
+ **Section sources**
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)
173
+
174
+ ### API Transport Selection
175
+ - The API module determines the transport based on the configured endpoint:
176
+ - If the URL matches WebSocket protocols, it uses the WebSocket transport.
177
+ - If it matches HTTP protocols, it uses the HTTP transport.
178
+ - Otherwise, it throws an error.
179
+ - The transport instances read the configured endpoint to connect or issue requests.
180
+
181
+ ```mermaid
182
+ flowchart TD
183
+ A["Endpoint from config"] --> B{"Starts with ws/wss?"}
184
+ B --> |Yes| C["Use WsTransport"]
185
+ B --> |No| D{"Starts with http/https?"}
186
+ D --> |Yes| E["Use HttpTransport"]
187
+ D --> |No| F["Throw error: unknown transport"]
188
+ ```
189
+
190
+ **Diagram sources**
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)
194
+
195
+ **Section sources**
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)
198
+
199
+ ### WebSocket Transport
200
+ - Creates a WebSocket connection using the configured endpoint.
201
+ - Manages lifecycle events (open, error, close) and request queuing.
202
+ - Sends JSON-RPC messages and handles responses.
203
+
204
+ ```mermaid
205
+ sequenceDiagram
206
+ participant API as "VIZ"
207
+ participant WS as "WsTransport"
208
+ participant CFG as "config"
209
+ participant NET as "WebSocket Server"
210
+ API->>WS : start()
211
+ WS->>CFG : get("websocket")
212
+ WS->>NET : open connection
213
+ NET-->>WS : onopen
214
+ API->>WS : send(api, data)
215
+ WS->>NET : send JSON-RPC
216
+ NET-->>WS : onmessage
217
+ WS-->>API : resolve/reject
218
+ ```
219
+
220
+ **Diagram sources**
221
+ - [api/transports/ws.js:27-94](file://src/api/transports/ws.js#L27-L94)
222
+
223
+ **Section sources**
224
+ - [api/transports/ws.js:1-136](file://src/api/transports/ws.js#L1-L136)
225
+
226
+ ### HTTP Transport
227
+ - Issues JSON-RPC POST requests against the configured endpoint.
228
+ - Enforces CORS and validates response integrity.
229
+
230
+ ```mermaid
231
+ sequenceDiagram
232
+ participant API as "VIZ"
233
+ participant HTTP as "HttpTransport"
234
+ participant CFG as "config"
235
+ participant SRV as "RPC Server"
236
+ API->>HTTP : send(api, data)
237
+ HTTP->>CFG : get("websocket")
238
+ HTTP->>SRV : POST JSON-RPC
239
+ SRV-->>HTTP : JSON-RPC response
240
+ HTTP-->>API : resolve/reject
241
+ ```
242
+
243
+ **Diagram sources**
244
+ - [api/transports/http.js:43-52](file://src/api/transports/http.js#L43-L52)
245
+
246
+ **Section sources**
247
+ - [api/transports/http.js:1-53](file://src/api/transports/http.js#L1-L53)
248
+
249
+ ### Broadcast Configuration
250
+ - The broadcaster conditionally chooses between two broadcast methods based on a boolean flag.
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
255
+
256
+ ```mermaid
257
+ flowchart TD
258
+ Start(["Broadcast request"]) --> Check["Read flag from config"]
259
+ Check --> |true| CB["Use broadcast with callback"]
260
+ Check --> |false| Sync["Use synchronous broadcast"]
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
267
+ ```
268
+
269
+ **Diagram sources**
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)
272
+
273
+ **Section sources**
274
+ - [broadcast/index.js:1-146](file://src/broadcast/index.js#L1-L146)
275
+
276
+ ### Programmatic Configuration Changes
277
+ - To change the endpoint, use the configuration setter with the key for the endpoint.
278
+ - After changing the endpoint, restart the API to apply the new transport selection.
279
+ - Example usage patterns are shown in the included examples for browser and Node environments.
280
+
281
+ Practical steps:
282
+ - Set the endpoint: configure the endpoint key to the desired URL.
283
+ - Verify transport selection: start the API and observe which transport is used.
284
+ - Restart after changes: stop and start the API to reinitialize the transport.
285
+
286
+ **Section sources**
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)
291
+
292
+ ### Security-Related Settings
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.
294
+ - The endpoint configuration itself does not include TLS settings; however, secure variants (wss, https) should be used to protect communications.
295
+
296
+ **Section sources**
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)
300
+
301
+ ### Environment-Specific Behavior (Browser vs Node.js)
302
+ - The browser build disables certain Node-specific modules via the browser field in package.json.
303
+ - The WebSocket transport selects the appropriate WebSocket class depending on the environment (Node vs browser).
304
+ - The HTTP transport relies on cross-fetch, which is designed to work in both environments.
305
+
306
+ **Section sources**
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)
310
+
311
+ ## Dependency Analysis
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.
313
+
314
+ ```mermaid
315
+ graph LR
316
+ Config["config.js"] --> API["api/index.js"]
317
+ Config --> Bcast["broadcast/index.js"]
318
+ API --> T_WS["transports/ws.js"]
319
+ API --> T_HTTP["transports/http.js"]
320
+ API --> T_Base["transports/base.js"]
321
+ Bcast --> Helpers["broadcast/helpers.js"]
322
+ Bcast --> Ops["broadcast/operations.js"]
323
+ ```
324
+
325
+ **Diagram sources**
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)
334
+
335
+ **Section sources**
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)
342
+
343
+ ## Performance Considerations
344
+ - Transport selection: Using WebSocket (wss) can reduce overhead compared to repeated HTTP requests, especially for streaming or frequent polling scenarios.
345
+ - Endpoint choice: Prefer endpoints that are geographically closer to clients to minimize latency.
346
+ - Request batching: Where applicable, batch operations to reduce round trips.
347
+ - Logging and debugging: The API emits performance tracking events; enable only when needed to avoid overhead.
348
+ - Browser vs Node: In browsers, ensure the WebSocket class is available; in Node, ensure the ws dependency is present.
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.
351
+
352
+ ## Troubleshooting Guide
353
+ Common configuration issues and resolutions:
354
+ - Unknown transport error: Ensure the configured endpoint uses a supported protocol (ws/wss for WebSocket transport, http/https for HTTP transport).
355
+ - Connection failures: Verify the endpoint is reachable and uses secure variants (wss/https) when required by policy.
356
+ - Incorrect broadcast behavior: Confirm the broadcast flag is set appropriately for your needs.
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.
360
+
361
+ Operational checks:
362
+ - Validate endpoint format before setting it.
363
+ - Restart the API after changing the endpoint to ensure the new transport is initialized.
364
+ - Monitor transport logs and performance events to diagnose issues.
365
+ - Test transaction broadcasting with different configuration combinations to verify behavior.
366
+
367
+ **Section sources**
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)
372
+
373
+ ## Conclusion
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.
375
+
376
+ ## Appendices
377
+
378
+ ### Configuration Reference
379
+ - websocket: Endpoint URL for the node. Supports ws/wss (WebSocket) and http/https (HTTP).
380
+ - address_prefix: Chain identifier prefix used in address encoding.
381
+ - chain_id: Unique chain identifier for signing and verification.
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
387
+
388
+ **Section sources**
389
+ - [config.json:1-9](file://config.json#L1-L9)
390
+ - [broadcast/index.js:49-93](file://src/broadcast/index.js#L49-L93)
391
+
392
+ ### Example Usage Patterns
393
+ - Browser usage: Initialize the library and call API methods after configuring the endpoint.
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.
407
+
408
+ **Section sources**
409
+ - [broadcast/index.js:49-93](file://src/broadcast/index.js#L49-L93)
410
+ - [config.json:6-7](file://config.json#L6-L7)