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,432 @@
1
+ # Broadcast Transactions
2
+
3
+ <cite>
4
+ **Referenced Files in This Document**
5
+ - [src/broadcast/index.js](file://src/broadcast/index.js)
6
+ - [src/broadcast/operations.js](file://src/broadcast/operations.js)
7
+ - [src/broadcast/helpers.js](file://src/broadcast/helpers.js)
8
+ - [src/auth/index.js](file://src/auth/index.js)
9
+ - [src/auth/serializer/src/operations.js](file://src/auth/serializer/src/operations.js)
10
+ - [src/auth/serializer/src/types.js](file://src/auth/serializer/src/types.js)
11
+ - [src/api/methods.js](file://src/api/methods.js)
12
+ - [src/api/transports/ws.js](file://src/api/transports/ws.js)
13
+ - [src/api/transports/base.js](file://src/api/transports/base.js)
14
+ - [src/formatter.js](file://src/formatter.js)
15
+ - [src/config.js](file://src/config.js)
16
+ - [config.json](file://config.json)
17
+ - [examples/broadcast.html](file://examples/broadcast.html)
18
+ - [test/broadcast.test.js](file://test/broadcast.test.js)
19
+ </cite>
20
+
21
+ ## Update Summary
22
+ **Changes Made**
23
+ - Enhanced transaction preparation with new configuration options for reference block handling
24
+ - Added support for configurable transaction expiration times
25
+ - Improved reference block selection logic with irreversible block support
26
+ - Updated configuration system to support runtime customization of broadcast behavior
27
+ - Added comprehensive documentation for 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. [Configuration Options](#configuration-options)
36
+ 7. [Dependency Analysis](#dependency-analysis)
37
+ 8. [Performance Considerations](#performance-considerations)
38
+ 9. [Troubleshooting Guide](#troubleshooting-guide)
39
+ 10. [Conclusion](#conclusion)
40
+ 11. [Appendices](#appendices)
41
+
42
+ ## Introduction
43
+ This document explains the transaction broadcasting functionality in the VIZ JavaScript library. It covers the broadcast system architecture, operation construction, transaction signing, and network submission. It documents supported operation types (including transfers, votes, comments, and custom JSON), transaction building blocks, fee calculation, expiration handling, and broadcast verification. Practical examples, error handling strategies, debugging techniques, batch operations, transaction simulation, and integration with the authentication system are included.
44
+
45
+ **Updated** Enhanced with new configuration options for reference block handling and transaction expiration control, providing improved flexibility for different network conditions and use cases.
46
+
47
+ ## Project Structure
48
+ The broadcast subsystem is composed of:
49
+ - Broadcast orchestrator that prepares, signs, and submits transactions
50
+ - Operation registry enumerating supported operations and their parameters
51
+ - Authentication module handling cryptographic signing
52
+ - API transport layer for network communication
53
+ - Formatter utilities for common tasks like permlink generation
54
+ - Configuration system for chain ID, address prefix, broadcast mode, and advanced options
55
+
56
+ ```mermaid
57
+ graph TB
58
+ subgraph "Broadcast Layer"
59
+ BIDX["src/broadcast/index.js"]
60
+ BOPS["src/broadcast/operations.js"]
61
+ BHELP["src/broadcast/helpers.js"]
62
+ end
63
+ subgraph "Auth & Serialization"
64
+ AIDX["src/auth/index.js"]
65
+ OPSER["src/auth/serializer/src/operations.js"]
66
+ TYP["src/auth/serializer/src/types.js"]
67
+ end
68
+ subgraph "API & Transport"
69
+ AMETH["src/api/methods.js"]
70
+ WS["src/api/transports/ws.js"]
71
+ BASE["src/api/transports/base.js"]
72
+ end
73
+ subgraph "Utilities & Config"
74
+ FMT["src/formatter.js"]
75
+ CFG["src/config.js"]
76
+ CJSON["config.json"]
77
+ end
78
+ BIDX --> AIDX
79
+ BIDX --> AMETH
80
+ BIDX --> FMT
81
+ BIDX --> CFG
82
+ AIDX --> OPSER
83
+ AIDX --> TYP
84
+ AMETH --> WS
85
+ WS --> BASE
86
+ CFG --> CJSON
87
+ BOPS --> BIDX
88
+ BHELP --> BIDX
89
+ ```
90
+
91
+ **Diagram sources**
92
+ - [src/broadcast/index.js:1-146](file://src/broadcast/index.js#L1-L146)
93
+ - [src/broadcast/operations.js:1-475](file://src/broadcast/operations.js#L1-L475)
94
+ - [src/broadcast/helpers.js:1-82](file://src/broadcast/helpers.js#L1-L82)
95
+ - [src/auth/index.js:1-133](file://src/auth/index.js#L1-L133)
96
+ - [src/auth/serializer/src/operations.js:73-125](file://src/auth/serializer/src/operations.js#L73-L125)
97
+ - [src/auth/serializer/src/types.js:30-69](file://src/auth/serializer/src/types.js#L30-L69)
98
+ - [src/api/methods.js:356-374](file://src/api/methods.js#L356-L374)
99
+ - [src/api/transports/ws.js:1-136](file://src/api/transports/ws.js#L1-L136)
100
+ - [src/api/transports/base.js:1-34](file://src/api/transports/base.js#L1-L34)
101
+ - [src/formatter.js:69-76](file://src/formatter.js#L69-L76)
102
+ - [src/config.js:1-10](file://src/config.js#L1-L10)
103
+ - [config.json:1-9](file://config.json#L1-L9)
104
+
105
+ **Section sources**
106
+ - [src/broadcast/index.js:1-146](file://src/broadcast/index.js#L1-L146)
107
+ - [src/broadcast/operations.js:1-475](file://src/broadcast/operations.js#L1-L475)
108
+ - [src/broadcast/helpers.js:1-82](file://src/broadcast/helpers.js#L1-L82)
109
+ - [src/auth/index.js:1-133](file://src/auth/index.js#L1-L133)
110
+ - [src/auth/serializer/src/operations.js:73-125](file://src/auth/serializer/src/operations.js#L73-L125)
111
+ - [src/auth/serializer/src/types.js:30-69](file://src/auth/serializer/src/types.js#L30-L69)
112
+ - [src/api/methods.js:356-374](file://src/api/methods.js#L356-L374)
113
+ - [src/api/transports/ws.js:1-136](file://src/api/transports/ws.js#L1-L136)
114
+ - [src/api/transports/base.js:1-34](file://src/api/transports/base.js#L1-L34)
115
+ - [src/formatter.js:69-76](file://src/formatter.js#L69-L76)
116
+ - [src/config.js:1-10](file://src/config.js#L1-L10)
117
+ - [config.json:1-9](file://config.json#L1-L9)
118
+
119
+ ## Core Components
120
+ - Broadcaster: Orchestrates transaction preparation, signing, and submission. It fetches dynamic global properties, sets reference block and expiration based on configuration, signs with private keys, and broadcasts via network broadcast API.
121
+ - Operations registry: Declares supported operations, parameter lists, and required roles for each operation.
122
+ - Authentication: Provides signing functions, key derivation, and WIF utilities.
123
+ - API methods: Exposes network broadcast APIs and other endpoints used by the broadcaster.
124
+ - Transport: WebSocket transport for API communication with connection lifecycle and error handling.
125
+ - Formatter: Utility functions for common tasks such as generating permlinks for comments.
126
+ - Config: Centralized configuration including chain ID, address prefix, broadcast mode, and advanced options for reference block handling and transaction expiration.
127
+
128
+ **Updated** Enhanced configuration system now supports runtime customization of reference block behavior and transaction expiration timing.
129
+
130
+ **Section sources**
131
+ - [src/broadcast/index.js:24-84](file://src/broadcast/index.js#L24-L84)
132
+ - [src/broadcast/operations.js:1-475](file://src/broadcast/operations.js#L1-L475)
133
+ - [src/auth/index.js:107-130](file://src/auth/index.js#L107-L130)
134
+ - [src/api/methods.js:356-374](file://src/api/methods.js#L356-L374)
135
+ - [src/api/transports/ws.js:27-94](file://src/api/transports/ws.js#L27-L94)
136
+ - [src/formatter.js:69-76](file://src/formatter.js#L69-L76)
137
+ - [src/config.js:1-10](file://src/config.js#L1-L10)
138
+ - [config.json:1-9](file://config.json#L1-L9)
139
+
140
+ ## Architecture Overview
141
+ End-to-end flow for broadcasting a transaction:
142
+ 1. Prepare transaction: Fetch dynamic global properties, compute reference block and expiration based on configuration.
143
+ 2. Sign transaction: Compute chain ID concatenated with serialized transaction buffer; sign with provided private keys.
144
+ 3. Submit transaction: Choose broadcast method based on configuration; submit to network broadcast API.
145
+
146
+ ```mermaid
147
+ sequenceDiagram
148
+ participant App as "Application"
149
+ participant Br as "Broadcaster"
150
+ participant API as "Network Broadcast API"
151
+ participant Auth as "Auth.signTransaction"
152
+ App->>Br : "send(tx, privKeys, callback)"
153
+ Br->>API : "getDynamicGlobalPropertiesAsync()"
154
+ API-->>Br : "dynamic properties"
155
+ Br->>Br : "_prepareTransaction(tx)<br/>Check config options<br/>Set ref_block_num/prefix<br/>Set expiration"
156
+ Br->>Auth : "signTransaction(transaction, privKeys)"
157
+ Auth-->>Br : "signed_transaction"
158
+ Br->>API : "broadcastTransactionWithCallbackAsync / broadcastTransactionAsync"
159
+ API-->>Br : "result"
160
+ Br-->>App : "signed transaction"
161
+ ```
162
+
163
+ **Diagram sources**
164
+ - [src/broadcast/index.js:24-47](file://src/broadcast/index.js#L24-L47)
165
+ - [src/broadcast/index.js:49-84](file://src/broadcast/index.js#L49-L84)
166
+ - [src/auth/index.js:107-130](file://src/auth/index.js#L107-L130)
167
+ - [src/api/methods.js:356-374](file://src/api/methods.js#L356-L374)
168
+
169
+ ## Detailed Component Analysis
170
+
171
+ ### Transaction Preparation and Submission
172
+ - Dynamic properties: Retrieves chain time and last irreversible block reference to compute expiration and reference fields.
173
+ - Reference block selection: Uses last irreversible block if available and configured; otherwise derives from head block number and block header.
174
+ - Expiration: Adds configurable offset to chain time to ensure reasonable validity window.
175
+ - Broadcasting modes: Supports synchronous and callback-based broadcast depending on configuration.
176
+
177
+ **Updated** Enhanced with configurable reference block handling and transaction expiration control.
178
+
179
+ ```mermaid
180
+ flowchart TD
181
+ Start(["Prepare Transaction"]) --> GetProps["getDynamicGlobalPropertiesAsync()"]
182
+ GetProps --> CheckConfig["Check config options:<br/>reference_irreversible_block<br/>tx_expiration_seconds"]
183
+ CheckConfig --> HasLIB{"Has LIB info AND<br/>reference_irreversible_block?"}
184
+ HasLIB --> |Yes| UseLIB["Set ref_block_num/prefix from LIB<br/>Compute expiration from config"]
185
+ HasLIB --> |No| HeadBlk["Compute ref_block_num from head block<br/>Fetch block header"]
186
+ HeadBlk --> SetRef["Set ref_block_num/prefix from block header<br/>Compute expiration from config"]
187
+ UseLIB --> BuildTx["Merge defaults into tx"]
188
+ SetRef --> BuildTx
189
+ BuildTx --> Sign["Auth.signTransaction()"]
190
+ Sign --> Mode{"Broadcast with callback?"}
191
+ Mode --> |Yes| BCastCB["broadcastTransactionWithCallbackAsync()"]
192
+ Mode --> |No| BCast["broadcastTransactionAsync()"]
193
+ BCastCB --> Done(["Return signed transaction"])
194
+ BCast --> Done
195
+ ```
196
+
197
+ **Diagram sources**
198
+ - [src/broadcast/index.js:49-93](file://src/broadcast/index.js#L49-L93)
199
+ - [src/auth/index.js:107-130](file://src/auth/index.js#L107-L130)
200
+ - [src/api/methods.js:356-374](file://src/api/methods.js#L356-L374)
201
+
202
+ **Section sources**
203
+ - [src/broadcast/index.js:49-93](file://src/broadcast/index.js#L49-L93)
204
+ - [src/config.js:1-10](file://src/config.js#L1-L10)
205
+ - [config.json:6-8](file://config.json#L6-L8)
206
+
207
+ ### Operation Construction and Generation
208
+ - Operation registry defines supported operations, parameter names, and required roles.
209
+ - Broadcaster dynamically generates convenience methods for each operation, mapping parameters to operation objects.
210
+ - Specialized helpers handle metadata serialization and permlink generation for comments.
211
+
212
+ ```mermaid
213
+ classDiagram
214
+ class OperationsRegistry {
215
+ +operation
216
+ +params
217
+ +roles
218
+ }
219
+ class Broadcaster {
220
+ +send(tx, privKeys, callback)
221
+ +_prepareTransaction(tx)
222
+ +voteWith()
223
+ +contentWith()
224
+ +transferWith()
225
+ +customWith()
226
+ }
227
+ class Formatter {
228
+ +contentPermlink(parentAuthor, parentPermlink)
229
+ }
230
+ OperationsRegistry --> Broadcaster : "drives generation"
231
+ Broadcaster --> Formatter : "uses for permlink"
232
+ ```
233
+
234
+ **Diagram sources**
235
+ - [src/broadcast/operations.js:1-475](file://src/broadcast/operations.js#L1-L475)
236
+ - [src/broadcast/index.js:89-129](file://src/broadcast/index.js#L89-L129)
237
+ - [src/formatter.js:69-76](file://src/formatter.js#L69-L76)
238
+
239
+ **Section sources**
240
+ - [src/broadcast/operations.js:1-475](file://src/broadcast/operations.js#L1-L475)
241
+ - [src/broadcast/index.js:89-129](file://src/broadcast/index.js#L89-L129)
242
+ - [src/formatter.js:69-76](file://src/formatter.js#L69-L76)
243
+
244
+ ### Signing and Serialization
245
+ - Transaction serialization: Uses generated serializers for transaction and signed_transaction structures.
246
+ - Chain ID concatenation: Signs chain_id + digest of serialized transaction buffer.
247
+ - Signature aggregation: Collects signatures per provided private key and returns a signed transaction object.
248
+
249
+ ```mermaid
250
+ sequenceDiagram
251
+ participant Br as "Broadcaster"
252
+ participant Auth as "Auth.signTransaction"
253
+ participant Ser as "Serializer"
254
+ participant Conf as "Config"
255
+ Br->>Ser : "transaction.toBuffer(trx)"
256
+ Br->>Conf : "get('chain_id')"
257
+ Conf-->>Br : "chain_id"
258
+ Br->>Auth : "Sign(chain_id + buffer, key)"
259
+ Auth-->>Br : "signature"
260
+ Br->>Ser : "signed_transaction.toObject(trx + signatures)"
261
+ Ser-->>Br : "signed_transaction"
262
+ ```
263
+
264
+ **Diagram sources**
265
+ - [src/auth/index.js:107-130](file://src/auth/index.js#L107-L130)
266
+ - [src/auth/serializer/src/operations.js:73-125](file://src/auth/serializer/src/operations.js#L73-L125)
267
+ - [src/config.js:5-6](file://src/config.js#L5-L6)
268
+ - [config.json:4-4](file://config.json#L4-L4)
269
+
270
+ **Section sources**
271
+ - [src/auth/index.js:107-130](file://src/auth/index.js#L107-L130)
272
+ - [src/auth/serializer/src/operations.js:73-125](file://src/auth/serializer/src/operations.js#L73-L125)
273
+ - [src/auth/serializer/src/types.js:30-69](file://src/auth/serializer/src/types.js#L30-L69)
274
+
275
+ ### Supported Operations and Examples
276
+ Common operations and their typical usage:
277
+ - Vote: Cast or update a vote on content.
278
+ - Content: Create or edit a post/comment.
279
+ - Transfer: Move tokens between accounts.
280
+ - Custom: Execute custom JSON operations with required authorities.
281
+
282
+ Examples are provided in the example page and tests demonstrating usage patterns and callback handling.
283
+
284
+ **Section sources**
285
+ - [src/broadcast/operations.js:2-36](file://src/broadcast/operations.js#L2-L36)
286
+ - [examples/broadcast.html:15-25](file://examples/broadcast.html#L15-L25)
287
+ - [examples/broadcast.html:27-60](file://examples/broadcast.html#L27-L60)
288
+ - [examples/broadcast.html:74-83](file://examples/broadcast.html#L74-L83)
289
+ - [test/broadcast.test.js:16-31](file://test/broadcast.test.js#L16-L31)
290
+ - [test/broadcast.test.js:80-97](file://test/broadcast.test.js#L80-L97)
291
+ - [test/broadcast.test.js:127-141](file://test/broadcast.test.js#L127-L141)
292
+
293
+ ### Authority Management Helpers
294
+ - Add/remove account authorizations for delegated posting or active permissions.
295
+ - Updates account authority structures and triggers an account update transaction.
296
+
297
+ **Section sources**
298
+ - [src/broadcast/helpers.js:6-80](file://src/broadcast/helpers.js#L6-L80)
299
+
300
+ ### Network Transport and API Methods
301
+ - WebSocket transport manages connection lifecycle, request queuing, and response/error handling.
302
+ - API methods expose network broadcast endpoints used by the broadcaster.
303
+
304
+ **Section sources**
305
+ - [src/api/transports/ws.js:27-94](file://src/api/transports/ws.js#L27-L94)
306
+ - [src/api/methods.js:356-374](file://src/api/methods.js#L356-L374)
307
+
308
+ ## Configuration Options
309
+
310
+ The VIZ JavaScript broadcast system now supports advanced configuration options for fine-tuning transaction behavior:
311
+
312
+ ### Reference Block Configuration
313
+ - `reference_irreversible_block`: Boolean flag controlling whether to use the last irreversible block (LIB) as the reference block
314
+ - When enabled: Uses `last_irreversible_block_ref_num` and `last_irreversible_block_ref_prefix` from dynamic properties
315
+ - When disabled: Falls back to head block reference using `head_block_number` and `head_block_id`
316
+
317
+ ### Transaction Expiration Configuration
318
+ - `tx_expiration_seconds`: Configurable expiration time in seconds (defaults to 60 if not specified)
319
+ - Controls how long transactions remain valid after creation
320
+ - Can be adjusted based on network conditions and application requirements
321
+
322
+ ### Configuration Usage Examples
323
+
324
+ ```javascript
325
+ // Enable irreversible block references and custom expiration
326
+ viz.config.set('reference_irreversible_block', true);
327
+ viz.config.set('tx_expiration_seconds', 120); // 2 minutes
328
+
329
+ // Disable irreversible block references (default behavior)
330
+ viz.config.set('reference_irreversible_block', false);
331
+
332
+ // Set custom expiration time
333
+ viz.config.set('tx_expiration_seconds', 300); // 5 minutes
334
+ ```
335
+
336
+ **New Section** Added comprehensive documentation for the new configuration system that enhances broadcast transaction functionality.
337
+
338
+ **Section sources**
339
+ - [src/broadcast/index.js:55-67](file://src/broadcast/index.js#L55-L67)
340
+ - [src/config.js:1-10](file://src/config.js#L1-L10)
341
+ - [config.json:6-8](file://config.json#L6-L8)
342
+
343
+ ## Dependency Analysis
344
+ High-level dependencies among broadcast components:
345
+
346
+ ```mermaid
347
+ graph LR
348
+ Br["src/broadcast/index.js"] --> OpsReg["src/broadcast/operations.js"]
349
+ Br --> Auth["src/auth/index.js"]
350
+ Br --> API["src/api/methods.js"]
351
+ Br --> Fmt["src/formatter.js"]
352
+ Br --> Cfg["src/config.js"]
353
+ Auth --> SerOps["src/auth/serializer/src/operations.js"]
354
+ Auth --> SerTypes["src/auth/serializer/src/types.js"]
355
+ API --> WS["src/api/transports/ws.js"]
356
+ WS --> Base["src/api/transports/base.js"]
357
+ Cfg --> CJSON["config.json"]
358
+ ```
359
+
360
+ **Diagram sources**
361
+ - [src/broadcast/index.js:1-11](file://src/broadcast/index.js#L1-L11)
362
+ - [src/broadcast/operations.js:1-10](file://src/broadcast/operations.js#L1-L10)
363
+ - [src/auth/index.js:1-11](file://src/auth/index.js#L1-L11)
364
+ - [src/auth/serializer/src/operations.js:20-52](file://src/auth/serializer/src/operations.js#L20-L52)
365
+ - [src/auth/serializer/src/types.js:10-14](file://src/auth/serializer/src/types.js#L10-L14)
366
+ - [src/api/methods.js:1-10](file://src/api/methods.js#L1-L10)
367
+ - [src/api/transports/ws.js:1-14](file://src/api/transports/ws.js#L1-L14)
368
+ - [src/api/transports/base.js:1-9](file://src/api/transports/base.js#L1-L9)
369
+ - [src/config.js:1-10](file://src/config.js#L1-L10)
370
+ - [config.json:1-9](file://config.json#L1-L9)
371
+
372
+ **Section sources**
373
+ - [src/broadcast/index.js:1-11](file://src/broadcast/index.js#L1-L11)
374
+ - [src/auth/index.js:1-11](file://src/auth/index.js#L1-L11)
375
+ - [src/auth/serializer/src/operations.js:20-52](file://src/auth/serializer/src/operations.js#L20-L52)
376
+ - [src/auth/serializer/src/types.js:10-14](file://src/auth/serializer/src/types.js#L10-L14)
377
+ - [src/api/methods.js:1-10](file://src/api/methods.js#L1-L10)
378
+ - [src/api/transports/ws.js:1-14](file://src/api/transports/ws.js#L1-L14)
379
+ - [src/api/transports/base.js:1-9](file://src/api/transports/base.js#L1-L9)
380
+ - [src/config.js:1-10](file://src/config.js#L1-L10)
381
+ - [config.json:1-9](file://config.json#L1-L9)
382
+
383
+ ## Performance Considerations
384
+ - Transaction validity window: Expiration is set to configurable offset; ensure clock synchronization to avoid premature expiration.
385
+ - Reference block freshness: Using last irreversible block improves finality guarantees; fallback to head block requires careful handling of reorg risks.
386
+ - Batch operations: Group multiple operations into a single transaction to reduce fees and latency.
387
+ - Simulation: Use potential/signature verification APIs to estimate required keys and validate transactions before submission.
388
+ - Network optimization: Configurable reference block selection allows adaptation to different network conditions and latency requirements.
389
+
390
+ **Updated** Enhanced performance considerations now include configurable reference block handling and transaction expiration optimization.
391
+
392
+ ## Troubleshooting Guide
393
+ - Transaction rejected due to expiration: Verify dynamic properties retrieval and local time alignment; adjust `tx_expiration_seconds` as needed.
394
+ - Invalid reference block: Confirm head block and LIB availability; handle fallback logic based on `reference_irreversible_block` setting.
395
+ - Missing signatures: Ensure correct private keys are provided and chain ID matches the network.
396
+ - WebSocket connectivity: Inspect transport error handling and reconnection behavior.
397
+ - Authority issues: Use helper methods to add/remove delegated authorizations and verify account authority structures.
398
+ - Configuration issues: Verify that configuration options are properly set and accessible via the config system.
399
+
400
+ **Updated** Added troubleshooting guidance for the new configuration options and their impact on transaction behavior.
401
+
402
+ **Section sources**
403
+ - [src/broadcast/index.js:49-93](file://src/broadcast/index.js#L49-L93)
404
+ - [src/api/transports/ws.js:96-134](file://src/api/transports/ws.js#L96-L134)
405
+ - [src/broadcast/helpers.js:6-80](file://src/broadcast/helpers.js#L6-L80)
406
+ - [test/broadcast.test.js:33-52](file://test/broadcast.test.js#L33-L52)
407
+
408
+ ## Conclusion
409
+ The VIZ JavaScript broadcast system provides a robust, modular pipeline for constructing, signing, and submitting transactions. It supports a wide range of operations, integrates tightly with the authentication and serialization layers, and offers flexible transport and configuration options. The enhanced configuration system now provides fine-grained control over reference block handling and transaction expiration, enabling reliable transaction broadcasting across diverse applications and network conditions.
410
+
411
+ **Updated** Enhanced conclusion reflects the new configuration capabilities that improve the system's flexibility and adaptability to different use cases.
412
+
413
+ ## Appendices
414
+
415
+ ### Practical Examples Index
416
+ - Voting: [examples/broadcast.html:15-25](file://examples/broadcast.html#L15-L25)
417
+ - Comment creation: [examples/broadcast.html:27-60](file://examples/broadcast.html#L27-L60)
418
+ - Post creation: [examples/broadcast.html:44-60](file://examples/broadcast.html#L44-L60)
419
+ - Custom JSON: [examples/broadcast.html:74-83](file://examples/broadcast.html#L74-L83)
420
+
421
+ ### Testing References
422
+ - Generated methods existence: [test/broadcast.test.js:16-31](file://test/broadcast.test.js#L16-L31)
423
+ - Transaction preparation: [test/broadcast.test.js:33-52](file://test/broadcast.test.js#L33-L52)
424
+ - Downvote and vote flows: [test/broadcast.test.js:54-120](file://test/broadcast.test.js#L54-L120)
425
+ - Custom JSON flow: [test/broadcast.test.js:122-152](file://test/broadcast.test.js#L122-L152)
426
+
427
+ ### Configuration Examples
428
+ - Enabling irreversible block references: [config.json:6-6](file://config.json#L6-L6)
429
+ - Setting custom expiration: [config.json:7-7](file://config.json#L7-L7)
430
+ - Runtime configuration updates: [src/broadcast/index.js:55-57](file://src/broadcast/index.js#L55-L57)
431
+
432
+ **New Section** Added configuration examples and references for the new broadcast options.