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.
- package/.qoder/docs/spec/viz-dns-nameserver-spec.md +982 -0
- package/.qoder/docs/viz-cpp-node-docs/data-types.md +322 -0
- package/.qoder/docs/viz-cpp-node-docs/index.md +160 -0
- package/.qoder/docs/viz-cpp-node-docs/op-account-market.md +236 -0
- package/.qoder/docs/viz-cpp-node-docs/op-account.md +199 -0
- package/.qoder/docs/viz-cpp-node-docs/op-award.md +162 -0
- package/.qoder/docs/viz-cpp-node-docs/op-committee.md +193 -0
- package/.qoder/docs/viz-cpp-node-docs/op-content.md +157 -0
- package/.qoder/docs/viz-cpp-node-docs/op-escrow.md +224 -0
- package/.qoder/docs/viz-cpp-node-docs/op-invite.md +219 -0
- package/.qoder/docs/viz-cpp-node-docs/op-proposal.md +229 -0
- package/.qoder/docs/viz-cpp-node-docs/op-recovery.md +188 -0
- package/.qoder/docs/viz-cpp-node-docs/op-subscription.md +146 -0
- package/.qoder/docs/viz-cpp-node-docs/op-transfer-vesting.md +224 -0
- package/.qoder/docs/viz-cpp-node-docs/op-witness.md +252 -0
- package/.qoder/docs/viz-cpp-node-docs/plugins.md +887 -0
- package/.qoder/docs/viz-cpp-node-docs/virtual-operations.md +513 -0
- package/.qoder/repowiki/en/content/API Reference/API Reference.md +724 -0
- package/.qoder/repowiki/en/content/API Reference/Configuration Options.md +410 -0
- package/.qoder/repowiki/en/content/API Reference/Core API Methods.md +547 -0
- package/.qoder/repowiki/en/content/API Reference/Streaming APIs.md +380 -0
- package/.qoder/repowiki/en/content/API Reference/Transport Layer.md +341 -0
- package/.qoder/repowiki/en/content/API Reference/VIZ Blockchain Operations Coverage Status.md +427 -0
- package/.qoder/repowiki/en/content/Authentication & Cryptography/Authentication & Cryptography.md +430 -0
- package/.qoder/repowiki/en/content/Authentication & Cryptography/Digital Signatures.md +462 -0
- package/.qoder/repowiki/en/content/Authentication & Cryptography/Key Management.md +456 -0
- package/.qoder/repowiki/en/content/Authentication & Cryptography/Memo Encryption.md +331 -0
- package/.qoder/repowiki/en/content/Authentication & Cryptography/Security Practices.md +488 -0
- package/.qoder/repowiki/en/content/Broadcast Transactions/Broadcast Transactions.md +432 -0
- package/.qoder/repowiki/en/content/Broadcast Transactions/Network Broadcasting.md +418 -0
- package/.qoder/repowiki/en/content/Broadcast Transactions/Operation Construction.md +352 -0
- package/.qoder/repowiki/en/content/Broadcast Transactions/Transaction Preparation.md +353 -0
- package/.qoder/repowiki/en/content/Broadcast Transactions/Transaction Signing.md +404 -0
- package/.qoder/repowiki/en/content/Data Serialization/Data Serialization.md +540 -0
- package/.qoder/repowiki/en/content/Data Serialization/Encoding & Decoding.md +463 -0
- package/.qoder/repowiki/en/content/Data Serialization/Object Templates.md +413 -0
- package/.qoder/repowiki/en/content/Data Serialization/Type System.md +514 -0
- package/.qoder/repowiki/en/content/Data Serialization/Validation Rules.md +439 -0
- package/.qoder/repowiki/en/content/Examples & Tutorials.md +485 -0
- package/.qoder/repowiki/en/content/Getting Started.md +345 -0
- package/.qoder/repowiki/en/content/Testing & Development.md +637 -0
- package/.qoder/repowiki/en/content/Utilities & Helpers.md +557 -0
- package/.qoder/repowiki/en/meta/repowiki-metadata.json +1 -0
- package/VIZ-JS-LIB-COVERAGE-STATUS.md +356 -0
- package/config.json +3 -1
- package/dist/statistics.html +1 -1
- package/dist/viz-tests.min.js +32 -42
- package/dist/viz-tests.min.js.gz +0 -0
- package/dist/viz.min.js +8 -18
- package/dist/viz.min.js.gz +0 -0
- package/lib/api/methods.js +24 -0
- package/lib/auth/serializer/src/ChainTypes.js +2 -1
- package/lib/auth/serializer/src/operations.js +35 -2
- package/lib/broadcast/index.js +29 -15
- package/lib/broadcast/operations.js +4 -0
- package/lib/dns.js +658 -0
- package/lib/index.js +3 -1
- package/package.json +3 -2
- package/test/dns.test.js +395 -0
- package/webpack/makeConfig.js +3 -0
|
@@ -0,0 +1,724 @@
|
|
|
1
|
+
# API Reference
|
|
2
|
+
|
|
3
|
+
<cite>
|
|
4
|
+
**Referenced Files in This Document**
|
|
5
|
+
- [src/index.js](file://src/index.js)
|
|
6
|
+
- [src/api/index.js](file://src/api/index.js)
|
|
7
|
+
- [src/api/methods.js](file://src/api/methods.js)
|
|
8
|
+
- [src/api/transports/index.js](file://src/api/transports/index.js)
|
|
9
|
+
- [src/api/transports/base.js](file://src/api/transports/base.js)
|
|
10
|
+
- [src/api/transports/http.js](file://src/api/transports/http.js)
|
|
11
|
+
- [src/api/transports/ws.js](file://src/api/transports/ws.js)
|
|
12
|
+
- [src/broadcast/index.js](file://src/broadcast/index.js)
|
|
13
|
+
- [src/broadcast/operations.js](file://src/broadcast/operations.js)
|
|
14
|
+
- [src/config.js](file://src/config.js)
|
|
15
|
+
- [config.json](file://config.json)
|
|
16
|
+
- [examples/get-post-content.js](file://examples/get-post-content.js)
|
|
17
|
+
- [examples/test-vote.js](file://examples/test-vote.js)
|
|
18
|
+
- [test/api.test.js](file://test/api.test.js)
|
|
19
|
+
- [test/broadcast.test.js](file://test/broadcast.test.js)
|
|
20
|
+
- [VIZ-JS-LIB-COVERAGE-STATUS.md](file://VIZ-JS-LIB-COVERAGE-STATUS.md)
|
|
21
|
+
- [src/auth/serializer/src/operations.js](file://src/auth/serializer/src/operations.js)
|
|
22
|
+
- [src/auth/serializer/src/types.js](file://src/auth/serializer/src/types.js)
|
|
23
|
+
</cite>
|
|
24
|
+
|
|
25
|
+
## Update Summary
|
|
26
|
+
**Changes Made**
|
|
27
|
+
- Added comprehensive reference to VIZ-JS-LIB-COVERAGE-STATUS.md for detailed blockchain operations coverage
|
|
28
|
+
- Enhanced documentation with complete coverage statistics and operation specifications
|
|
29
|
+
- Updated API method index to reflect all supported operations and plugins
|
|
30
|
+
- Added detailed coverage status for regular operations, virtual operations, and plugin APIs
|
|
31
|
+
|
|
32
|
+
## Table of Contents
|
|
33
|
+
1. [Introduction](#introduction)
|
|
34
|
+
2. [Project Structure](#project-structure)
|
|
35
|
+
3. [Core Components](#core-components)
|
|
36
|
+
4. [Architecture Overview](#architecture-overview)
|
|
37
|
+
5. [Detailed Component Analysis](#detailed-component-analysis)
|
|
38
|
+
6. [Comprehensive Operations Coverage](#comprehensive-operations-coverage)
|
|
39
|
+
7. [Dependency Analysis](#dependency-analysis)
|
|
40
|
+
8. [Performance Considerations](#performance-considerations)
|
|
41
|
+
9. [Troubleshooting Guide](#troubleshooting-guide)
|
|
42
|
+
10. [Conclusion](#conclusion)
|
|
43
|
+
11. [Appendices](#appendices)
|
|
44
|
+
|
|
45
|
+
## Introduction
|
|
46
|
+
This document provides a comprehensive API reference for the VIZ JavaScript library. It covers public API methods for querying blockchain data and broadcasting transactions, transport implementations for HTTP and WebSocket, configuration and connection management, error handling, and best practices. The library maintains **100% coverage** of all VIZ blockchain operations as documented in the comprehensive operations coverage specification.
|
|
47
|
+
|
|
48
|
+
**Updated** Added reference to the comprehensive VIZ blockchain operations coverage document that provides detailed specifications for all supported blockchain operations and API methods.
|
|
49
|
+
|
|
50
|
+
## Project Structure
|
|
51
|
+
The VIZ library exposes a singleton API client and a broadcaster for signing and submitting transactions. Public APIs are dynamically generated from a method catalog. Transports encapsulate communication over HTTP or WebSocket. Configuration is centralized via a small config module.
|
|
52
|
+
|
|
53
|
+
```mermaid
|
|
54
|
+
graph TB
|
|
55
|
+
A["src/index.js<br/>Exports: api, broadcast, config, utils, ..."] --> B["src/api/index.js<br/>VIZ class, dynamic API generation, streaming"]
|
|
56
|
+
B --> C["src/api/methods.js<br/>Method catalog"]
|
|
57
|
+
B --> D["src/api/transports/index.js<br/>Transports registry"]
|
|
58
|
+
D --> E["src/api/transports/base.js<br/>Base transport"]
|
|
59
|
+
D --> F["src/api/transports/http.js<br/>HTTP transport"]
|
|
60
|
+
D --> G["src/api/transports/ws.js<br/>WebSocket transport"]
|
|
61
|
+
A --> H["src/broadcast/index.js<br/>Broadcasting and transaction prep"]
|
|
62
|
+
H --> I["src/broadcast/operations.js<br/>Operation definitions"]
|
|
63
|
+
A --> J["src/config.js<br/>Config getter/setter"]
|
|
64
|
+
J --> K["config.json<br/>Default config"]
|
|
65
|
+
L["VIZ-JS-LIB-COVERAGE-STATUS.md<br/>Comprehensive operations coverage"] --> M["Detailed operation specifications"]
|
|
66
|
+
M --> N["Regular operations (31/31 implemented)"]
|
|
67
|
+
M --> O["Virtual operations (22/22 implemented)"]
|
|
68
|
+
M --> P["Plugin API methods (88/88 implemented)"]
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**Diagram sources**
|
|
72
|
+
- [src/index.js](file://src/index.js#L1-L20)
|
|
73
|
+
- [src/api/index.js](file://src/api/index.js#L1-L271)
|
|
74
|
+
- [src/api/methods.js](file://src/api/methods.js#L1-L465)
|
|
75
|
+
- [src/api/transports/index.js](file://src/api/transports/index.js#L1-L8)
|
|
76
|
+
- [src/api/transports/base.js](file://src/api/transports/base.js#L1-L34)
|
|
77
|
+
- [src/api/transports/http.js](file://src/api/transports/http.js#L1-L53)
|
|
78
|
+
- [src/api/transports/ws.js](file://src/api/transports/ws.js#L1-L136)
|
|
79
|
+
- [src/broadcast/index.js](file://src/broadcast/index.js#L1-L137)
|
|
80
|
+
- [src/broadcast/operations.js](file://src/broadcast/operations.js#L1-L475)
|
|
81
|
+
- [src/config.js](file://src/config.js#L1-L10)
|
|
82
|
+
- [config.json](file://config.json#L1-L7)
|
|
83
|
+
- [VIZ-JS-LIB-COVERAGE-STATUS.md](file://VIZ-JS-LIB-COVERAGE-STATUS.md#L1-L357)
|
|
84
|
+
|
|
85
|
+
**Section sources**
|
|
86
|
+
- [src/index.js](file://src/index.js#L1-L20)
|
|
87
|
+
- [src/api/index.js](file://src/api/index.js#L1-L271)
|
|
88
|
+
- [src/api/transports/index.js](file://src/api/transports/index.js#L1-L8)
|
|
89
|
+
- [src/config.js](file://src/config.js#L1-L10)
|
|
90
|
+
- [config.json](file://config.json#L1-L7)
|
|
91
|
+
- [VIZ-JS-LIB-COVERAGE-STATUS.md](file://VIZ-JS-LIB-COVERAGE-STATUS.md#L1-L357)
|
|
92
|
+
|
|
93
|
+
## Core Components
|
|
94
|
+
- VIZ API client: Provides dynamic API methods, transport selection, connection lifecycle, and streaming utilities.
|
|
95
|
+
- HTTP transport: Sends JSON-RPC calls over HTTP to the configured endpoint.
|
|
96
|
+
- WebSocket transport: Manages a persistent connection for real-time updates and bidirectional messaging.
|
|
97
|
+
- Broadcast module: Prepares transactions, signs them, and submits them via the configured broadcast method.
|
|
98
|
+
- Config module: Centralized getter/setter for runtime configuration (e.g., websocket URL, chain settings).
|
|
99
|
+
|
|
100
|
+
Key capabilities:
|
|
101
|
+
- Dynamic API method generation from a method catalog.
|
|
102
|
+
- Automatic transport selection based on the configured URL scheme.
|
|
103
|
+
- Streaming helpers for blocks, transactions, and operations.
|
|
104
|
+
- Promise-based and callback-based invocation patterns.
|
|
105
|
+
|
|
106
|
+
**Section sources**
|
|
107
|
+
- [src/api/index.js](file://src/api/index.js#L21-L271)
|
|
108
|
+
- [src/api/methods.js](file://src/api/methods.js#L1-L465)
|
|
109
|
+
- [src/api/transports/http.js](file://src/api/transports/http.js#L1-L53)
|
|
110
|
+
- [src/api/transports/ws.js](file://src/api/transports/ws.js#L1-L136)
|
|
111
|
+
- [src/broadcast/index.js](file://src/broadcast/index.js#L1-L137)
|
|
112
|
+
- [src/config.js](file://src/config.js#L1-L10)
|
|
113
|
+
- [config.json](file://config.json#L1-L7)
|
|
114
|
+
|
|
115
|
+
## Architecture Overview
|
|
116
|
+
The VIZ client composes a transport layer (HTTP or WebSocket) with a method catalog to expose a fluent API. Broadcasting leverages the API client to fetch chain props and block data, then signs and submits transactions.
|
|
117
|
+
|
|
118
|
+
```mermaid
|
|
119
|
+
sequenceDiagram
|
|
120
|
+
participant App as "Application"
|
|
121
|
+
participant API as "VIZ API"
|
|
122
|
+
participant T_HTTP as "HTTP Transport"
|
|
123
|
+
participant T_WS as "WebSocket Transport"
|
|
124
|
+
participant Node as "VIZ Node"
|
|
125
|
+
App->>API : Call getDynamicGlobalProperties()
|
|
126
|
+
alt HTTP transport
|
|
127
|
+
API->>T_HTTP : send(api, method, params)
|
|
128
|
+
T_HTTP->>Node : POST JSON-RPC
|
|
129
|
+
Node-->>T_HTTP : JSON-RPC result
|
|
130
|
+
T_HTTP-->>API : result
|
|
131
|
+
else WebSocket transport
|
|
132
|
+
API->>T_WS : send(api, method, params)
|
|
133
|
+
T_WS->>Node : send JSON-RPC
|
|
134
|
+
Node-->>T_WS : message
|
|
135
|
+
T_WS-->>API : result
|
|
136
|
+
end
|
|
137
|
+
API-->>App : resolved result
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
**Diagram sources**
|
|
141
|
+
- [src/api/index.js](file://src/api/index.js#L98-L119)
|
|
142
|
+
- [src/api/transports/http.js](file://src/api/transports/http.js#L43-L52)
|
|
143
|
+
- [src/api/transports/ws.js](file://src/api/transports/ws.js#L64-L94)
|
|
144
|
+
|
|
145
|
+
## Detailed Component Analysis
|
|
146
|
+
|
|
147
|
+
### VIZ API Client
|
|
148
|
+
Responsibilities:
|
|
149
|
+
- Dynamically generates API methods from the method catalog.
|
|
150
|
+
- Selects transport based on the configured websocket URL scheme.
|
|
151
|
+
- Starts/stops transport connections and manages in-flight requests.
|
|
152
|
+
- Emits performance metrics and handles errors from transport messages.
|
|
153
|
+
- Provides streaming helpers for block numbers, blocks, transactions, and operations.
|
|
154
|
+
|
|
155
|
+
Public methods (selected):
|
|
156
|
+
- getAccounts(accountNames): Returns account objects by names.
|
|
157
|
+
- getDynamicGlobalProperties(): Returns global chain properties.
|
|
158
|
+
- getAccountVotes(voter, from, voteLimit): Returns votes by an account.
|
|
159
|
+
- streamBlockNumber(mode, callback, interval): Streams block numbers.
|
|
160
|
+
- streamBlock(mode, callback): Streams full blocks.
|
|
161
|
+
- streamTransactions(mode, callback): Streams transactions.
|
|
162
|
+
- streamOperations(mode, callback): Streams operations.
|
|
163
|
+
|
|
164
|
+
Usage patterns:
|
|
165
|
+
- Callback-based: viz.getAccounts(names, cb)
|
|
166
|
+
- Promise-based: viz.getAccountsAsync(names)
|
|
167
|
+
- Streaming: viz.streamBlockNumber(cb) with returned release function.
|
|
168
|
+
|
|
169
|
+
Error handling:
|
|
170
|
+
- Transport errors propagate as JavaScript Error instances.
|
|
171
|
+
- WebSocket transport rejects inflight requests on close or error.
|
|
172
|
+
|
|
173
|
+
**Section sources**
|
|
174
|
+
- [src/api/index.js](file://src/api/index.js#L21-L271)
|
|
175
|
+
- [src/api/methods.js](file://src/api/methods.js#L253-L274)
|
|
176
|
+
- [test/api.test.js](file://test/api.test.js#L42-L78)
|
|
177
|
+
|
|
178
|
+
### HTTP Transport
|
|
179
|
+
Behavior:
|
|
180
|
+
- Sends JSON-RPC 2.0 calls via POST to the configured websocket URL (used as a generic RPC endpoint).
|
|
181
|
+
- Validates response ID and propagates RPC errors.
|
|
182
|
+
- Returns results via callback.
|
|
183
|
+
|
|
184
|
+
Parameters:
|
|
185
|
+
- api: API namespace (e.g., database_api).
|
|
186
|
+
- method: Method name (e.g., get_accounts).
|
|
187
|
+
- params: Array of parameters.
|
|
188
|
+
|
|
189
|
+
Returns:
|
|
190
|
+
- Callback receives (error, result).
|
|
191
|
+
|
|
192
|
+
Errors:
|
|
193
|
+
- Network errors mapped to Error with HTTP status text.
|
|
194
|
+
- RPC errors mapped to Error with code/data.
|
|
195
|
+
|
|
196
|
+
**Section sources**
|
|
197
|
+
- [src/api/transports/http.js](file://src/api/transports/http.js#L17-L41)
|
|
198
|
+
- [src/api/transports/http.js](file://src/api/transports/http.js#L43-L52)
|
|
199
|
+
|
|
200
|
+
### WebSocket Transport
|
|
201
|
+
Behavior:
|
|
202
|
+
- Establishes a WebSocket connection on demand.
|
|
203
|
+
- Tracks in-flight requests by message ID.
|
|
204
|
+
- Handles open, message, error, and close events.
|
|
205
|
+
- Emits performance metrics and resolves/rejects promises accordingly.
|
|
206
|
+
|
|
207
|
+
Parameters:
|
|
208
|
+
- api: API namespace.
|
|
209
|
+
- method: Method name.
|
|
210
|
+
- params: Array of parameters.
|
|
211
|
+
|
|
212
|
+
Returns:
|
|
213
|
+
- Promise resolving to result or rejecting on error.
|
|
214
|
+
|
|
215
|
+
Errors:
|
|
216
|
+
- Connection close triggers rejection of pending requests.
|
|
217
|
+
- RPC errors propagate with payload attached.
|
|
218
|
+
|
|
219
|
+
**Section sources**
|
|
220
|
+
- [src/api/transports/ws.js](file://src/api/transports/ws.js#L18-L136)
|
|
221
|
+
|
|
222
|
+
### Broadcast Module
|
|
223
|
+
Responsibilities:
|
|
224
|
+
- Prepares transactions with chain props and expiration.
|
|
225
|
+
- Signs transactions using private keys.
|
|
226
|
+
- Submits transactions via broadcast_transaction or broadcast_transaction_with_callback depending on config.
|
|
227
|
+
- Generates convenience wrappers for operations (e.g., vote, content, transfer).
|
|
228
|
+
|
|
229
|
+
Key methods:
|
|
230
|
+
- send(tx, privKeys, callback): Signs and broadcasts a prepared transaction.
|
|
231
|
+
- _prepareTransaction(tx): Injects expiration, ref_block_num, and ref_block_prefix.
|
|
232
|
+
- voteWith(wif, options, callback), contentWith(wif, options, callback), transferWith(wif, options, callback), etc.
|
|
233
|
+
|
|
234
|
+
Parameters:
|
|
235
|
+
- privKeys: Object mapping roles to private keys (WIF).
|
|
236
|
+
- options: Operation-specific parameters (e.g., voter, author, permlink, weight).
|
|
237
|
+
|
|
238
|
+
Returns:
|
|
239
|
+
- Transaction object with signatures on success.
|
|
240
|
+
|
|
241
|
+
**Section sources**
|
|
242
|
+
- [src/broadcast/index.js](file://src/broadcast/index.js#L24-L84)
|
|
243
|
+
- [src/broadcast/index.js](file://src/broadcast/index.js#L97-L129)
|
|
244
|
+
- [src/broadcast/operations.js](file://src/broadcast/operations.js#L1-L475)
|
|
245
|
+
- [test/broadcast.test.js](file://test/broadcast.test.js#L33-L120)
|
|
246
|
+
|
|
247
|
+
### Configuration and Connection Management
|
|
248
|
+
Configuration:
|
|
249
|
+
- websocket: Target endpoint URL (scheme determines transport).
|
|
250
|
+
- address_prefix: Chain address prefix.
|
|
251
|
+
- chain_id: Chain identifier.
|
|
252
|
+
- broadcast_transaction_with_callback: Toggle broadcast mode.
|
|
253
|
+
|
|
254
|
+
Runtime management:
|
|
255
|
+
- setWebSocket(url): Deprecated; sets websocket URL and resets transport.
|
|
256
|
+
- start(): Initializes transport based on current websocket URL.
|
|
257
|
+
- stop(): Closes transport and clears state.
|
|
258
|
+
|
|
259
|
+
Defaults:
|
|
260
|
+
- config.json provides default values.
|
|
261
|
+
|
|
262
|
+
**Section sources**
|
|
263
|
+
- [src/config.js](file://src/config.js#L1-L10)
|
|
264
|
+
- [config.json](file://config.json#L1-L7)
|
|
265
|
+
- [src/api/index.js](file://src/api/index.js#L44-L62)
|
|
266
|
+
- [src/api/index.js](file://src/api/index.js#L52-L62)
|
|
267
|
+
|
|
268
|
+
### Relationship Between Endpoints
|
|
269
|
+
- getDynamicGlobalProperties is used by the broadcaster to set transaction expiration and reference block fields.
|
|
270
|
+
- getAccounts and getAccountVotes are used to validate identities and voting power before broadcasting.
|
|
271
|
+
- Streaming endpoints (blocks, transactions, operations) rely on getDynamicGlobalProperties to determine head vs irreversible block modes.
|
|
272
|
+
|
|
273
|
+
**Section sources**
|
|
274
|
+
- [src/broadcast/index.js](file://src/broadcast/index.js#L50-L84)
|
|
275
|
+
- [src/api/methods.js](file://src/api/methods.js#L253-L274)
|
|
276
|
+
- [src/api/index.js](file://src/api/index.js#L121-L191)
|
|
277
|
+
|
|
278
|
+
## Comprehensive Operations Coverage
|
|
279
|
+
|
|
280
|
+
**Updated** The VIZ JavaScript library maintains comprehensive coverage of all VIZ blockchain operations as documented in the detailed operations coverage specification.
|
|
281
|
+
|
|
282
|
+
### Full Coverage Statistics
|
|
283
|
+
The library achieves **100% coverage** across all operation categories:
|
|
284
|
+
|
|
285
|
+
- **Regular Operations**: 31/31 implemented (100%)
|
|
286
|
+
- **Virtual Operations**: 22/22 implemented (100%)
|
|
287
|
+
- **Plugin API Methods**: 88/88 implemented (100%)
|
|
288
|
+
|
|
289
|
+
### Regular Operations (Broadcastable)
|
|
290
|
+
All user-broadcastable operations are fully implemented with complete serializer support:
|
|
291
|
+
|
|
292
|
+
| ID | Operation | Auth | Status | Serializer | Broadcast |
|
|
293
|
+
|----|-----------|------|--------|------------|-----------|
|
|
294
|
+
| 0 | `vote` *(deprecated)* | regular | ✅ Complete | ✅ | ✅ |
|
|
295
|
+
| 1 | `content` *(deprecated)* | regular | ✅ Complete | ✅ | ✅ |
|
|
296
|
+
| 2 | `transfer` | active/master | ✅ Complete | ✅ | ✅ |
|
|
297
|
+
| 3 | `transfer_to_vesting` | active | ✅ Complete | ✅ | ✅ |
|
|
298
|
+
| 4 | `withdraw_vesting` | active | ✅ Complete | ✅ | ✅ |
|
|
299
|
+
| 5 | `account_update` | master/active | ✅ Complete | ✅ | ✅ |
|
|
300
|
+
| 6 | `witness_update` | active | ✅ Complete | ✅ | ✅ |
|
|
301
|
+
| 7 | `account_witness_vote` | active | ✅ Complete | ✅ | ✅ |
|
|
302
|
+
| 8 | `account_witness_proxy` | active | ✅ Complete | ✅ | ✅ |
|
|
303
|
+
| 9 | `delete_content` *(deprecated)* | regular | ✅ Complete | ✅ | ✅ |
|
|
304
|
+
| 10 | `custom` | active/regular | ✅ Complete | ✅ | ✅ |
|
|
305
|
+
| 11 | `set_withdraw_vesting_route` | active | ✅ Complete | ✅ | ✅ |
|
|
306
|
+
| 12 | `request_account_recovery` | active | ✅ Complete | ✅ | ✅ |
|
|
307
|
+
| 13 | `recover_account` | master×2 | ✅ Complete | ✅ | ✅ |
|
|
308
|
+
| 14 | `change_recovery_account` | master | ✅ Complete | ✅ | ✅ |
|
|
309
|
+
| 15 | `escrow_transfer` | active | ✅ Complete | ✅ | ✅ |
|
|
310
|
+
| 16 | `escrow_dispute` | active | ✅ Complete | ✅ | ✅ |
|
|
311
|
+
| 17 | `escrow_release` | active | ✅ Complete | ✅ | ✅ |
|
|
312
|
+
| 18 | `escrow_approve` | active | ✅ Complete | ✅ | ✅ |
|
|
313
|
+
| 19 | `delegate_vesting_shares` | active | ✅ Complete | ✅ | ✅ |
|
|
314
|
+
| 20 | `account_create` | active | ✅ Complete | ✅ | ✅ |
|
|
315
|
+
| 21 | `account_metadata` | regular | ✅ Complete | ✅ | ✅ |
|
|
316
|
+
| 22 | `proposal_create` | active | ✅ Complete | ✅ | ✅ |
|
|
317
|
+
| 23 | `proposal_update` | varies | ✅ Complete | ✅ | ✅ |
|
|
318
|
+
| 24 | `proposal_delete` | active | ✅ Complete | ✅ | ✅ |
|
|
319
|
+
| 25 | `chain_properties_update` | active | ✅ Complete | ✅ | ✅ |
|
|
320
|
+
| 35 | `committee_worker_create_request` | regular | ✅ Complete | ✅ | ✅ |
|
|
321
|
+
| 36 | `committee_worker_cancel_request` | regular | ✅ Complete | ✅ | ✅ |
|
|
322
|
+
| 37 | `committee_vote_request` | regular | ✅ Complete | ✅ | ✅ |
|
|
323
|
+
| 43 | `create_invite` | active | ✅ Complete | ✅ | ✅ |
|
|
324
|
+
| 44 | `claim_invite_balance` | active | ✅ Complete | ✅ | ✅ |
|
|
325
|
+
| 45 | `invite_registration` | active | ✅ Complete | ✅ | ✅ |
|
|
326
|
+
| 46 | `versioned_chain_properties_update` | active | ✅ Complete | ✅ | ✅ |
|
|
327
|
+
| 47 | `award` | regular | ✅ Complete | ✅ | ✅ |
|
|
328
|
+
| 50 | `set_paid_subscription` | active | ✅ Complete | ✅ | ✅ |
|
|
329
|
+
| 51 | `paid_subscribe` | active | ✅ Complete | ✅ | ✅ |
|
|
330
|
+
| 54 | `set_account_price` | master | ✅ Complete | ✅ | ✅ |
|
|
331
|
+
| 55 | `set_subaccount_price` | master | ✅ Complete | ✅ | ✅ |
|
|
332
|
+
| 56 | `buy_account` | active | ✅ Complete | ✅ | ✅ |
|
|
333
|
+
| 58 | `use_invite_balance` | active | ✅ Complete | ✅ | ✅ |
|
|
334
|
+
| 60 | `fixed_award` | regular | ✅ Complete | ✅ | ✅ |
|
|
335
|
+
| 61 | `target_account_sale` | master | ✅ Complete | ✅ | ✅ |
|
|
336
|
+
|
|
337
|
+
### Virtual Operations (Read-Only)
|
|
338
|
+
All virtual operations have complete serializer definitions for parsing:
|
|
339
|
+
|
|
340
|
+
| ID | Operation | Trigger | Status | Serializer |
|
|
341
|
+
|----|-----------|---------|--------|------------|
|
|
342
|
+
| 26 | `author_reward` | Content payout | ✅ Complete | ✅ |
|
|
343
|
+
| 27 | `curation_reward` | Content payout | ✅ Complete | ✅ |
|
|
344
|
+
| 28 | `content_reward` | Content payout | ✅ Complete | ✅ |
|
|
345
|
+
| 29 | `fill_vesting_withdraw` | Withdrawal interval | ✅ Complete | ✅ |
|
|
346
|
+
| 30 | `shutdown_witness` | Witness deactivated | ✅ Complete | ✅ |
|
|
347
|
+
| 31 | `hardfork` | Hardfork activation | ✅ Complete | ✅ |
|
|
348
|
+
| 32 | `content_payout_update` | Content payout update | ✅ Complete | ✅ |
|
|
349
|
+
| 33 | `content_benefactor_reward` | Content payout | ✅ Complete | ✅ |
|
|
350
|
+
| 34 | `return_vesting_delegation` | Delegation limbo ends | ✅ Complete | ✅ |
|
|
351
|
+
| 38 | `committee_cancel_request` | Request expires | ✅ Complete | ✅ |
|
|
352
|
+
| 39 | `committee_approve_request` | Request approved | ✅ Complete | ✅ |
|
|
353
|
+
| 40 | `committee_payout_request` | Payout processed | ✅ Complete | ✅ |
|
|
354
|
+
| 41 | `committee_pay_request` | Worker paid | ✅ Complete | ✅ |
|
|
355
|
+
| 42 | `witness_reward` | Block produced | ✅ Complete | ✅ |
|
|
356
|
+
| 48 | `receive_award` | Award given | ✅ Complete | ✅ |
|
|
357
|
+
| 49 | `benefactor_award` | Award with beneficiary | ✅ Complete | ✅ |
|
|
358
|
+
| 52 | `paid_subscription_action` | Subscription payment | ✅ Complete | ✅ |
|
|
359
|
+
| 53 | `cancel_paid_subscription` | Subscription ends | ✅ Complete | ✅ |
|
|
360
|
+
| 57 | `account_sale` | Account sold | ✅ Complete | ✅ |
|
|
361
|
+
| 59 | `expire_escrow_ratification` | Escrow deadline missed | ✅ Complete | ✅ |
|
|
362
|
+
| 62 | `bid` | Bid placed (HF11) | ✅ Complete | ✅ |
|
|
363
|
+
| 63 | `outbid` | Outbid (HF11) | ✅ Complete | ✅ |
|
|
364
|
+
|
|
365
|
+
### Plugin API Coverage
|
|
366
|
+
The library provides comprehensive coverage of all VIZ plugin APIs:
|
|
367
|
+
|
|
368
|
+
#### database_api (Active)
|
|
369
|
+
- `get_block_header` ✅
|
|
370
|
+
- `get_block` ✅
|
|
371
|
+
- `get_irreversible_block_header` ✅
|
|
372
|
+
- `get_irreversible_block` ✅
|
|
373
|
+
- `set_block_applied_callback` ✅ (WebSocket subscription)
|
|
374
|
+
- `get_config` ✅
|
|
375
|
+
- `get_dynamic_global_properties` ✅
|
|
376
|
+
- `get_chain_properties` ✅
|
|
377
|
+
- `get_hardfork_version` ✅
|
|
378
|
+
- `get_next_scheduled_hardfork` ✅
|
|
379
|
+
- `get_accounts` ✅
|
|
380
|
+
- `lookup_account_names` ✅
|
|
381
|
+
- `lookup_accounts` ✅
|
|
382
|
+
- `get_account_count` ✅
|
|
383
|
+
- `get_owner_history` ✅ (Legacy naming)
|
|
384
|
+
- `get_master_history` ✅ (Current naming)
|
|
385
|
+
- `get_recovery_request` ✅
|
|
386
|
+
- `get_escrow` ✅
|
|
387
|
+
- `get_withdraw_routes` ✅
|
|
388
|
+
- `get_vesting_delegations` ✅
|
|
389
|
+
- `get_expiring_vesting_delegations` ✅
|
|
390
|
+
- `get_transaction_hex` ✅
|
|
391
|
+
- `get_required_signatures` ✅
|
|
392
|
+
- `get_potential_signatures` ✅
|
|
393
|
+
- `verify_authority` ✅
|
|
394
|
+
- `verify_account_authority` ✅
|
|
395
|
+
- `get_database_info` ✅
|
|
396
|
+
- `get_proposed_transaction` ✅
|
|
397
|
+
- `get_proposed_transactions` ✅
|
|
398
|
+
- `get_accounts_on_sale` ✅
|
|
399
|
+
- `get_accounts_on_auction` ✅
|
|
400
|
+
- `get_subaccounts_on_sale` ✅
|
|
401
|
+
|
|
402
|
+
#### network_broadcast_api (Active)
|
|
403
|
+
- `broadcast_transaction` ✅ (Async broadcast)
|
|
404
|
+
- `broadcast_transaction_synchronous` ✅ (Wait for inclusion)
|
|
405
|
+
- `broadcast_transaction_with_callback` ✅ (Callback on confirm)
|
|
406
|
+
- `broadcast_block` ✅ (For witnesses)
|
|
407
|
+
|
|
408
|
+
#### witness_api (Active)
|
|
409
|
+
- `get_active_witnesses` ✅
|
|
410
|
+
- `get_witness_schedule` ✅
|
|
411
|
+
- `get_witnesses` ✅
|
|
412
|
+
- `get_witness_by_account` ✅
|
|
413
|
+
- `get_witnesses_by_vote` ✅
|
|
414
|
+
- `get_witnesses_by_counted_vote` ✅
|
|
415
|
+
- `get_witness_count` ✅
|
|
416
|
+
- `lookup_witness_accounts` ✅
|
|
417
|
+
- `get_miner_queue` ✅
|
|
418
|
+
|
|
419
|
+
#### Other Active Plugins
|
|
420
|
+
- **account_by_key**: `get_key_references` ✅
|
|
421
|
+
- **account_history**: `get_account_history` ✅
|
|
422
|
+
- **operation_history**: `get_ops_in_block` ✅, `get_transaction` ✅
|
|
423
|
+
- **committee_api**: `get_committee_request` ✅, `get_committee_request_votes` ✅, `get_committee_requests_list` ✅
|
|
424
|
+
- **invite_api**: `get_invites_list` ✅, `get_invite_by_id` ✅, `get_invite_by_key` ✅
|
|
425
|
+
- **paid_subscription_api**: `get_paid_subscriptions` ✅, `get_paid_subscription_options` ✅, `get_paid_subscription_status` ✅, `get_active_paid_subscriptions` ✅, `get_inactive_paid_subscriptions` ✅
|
|
426
|
+
- **custom_protocol_api**: `get_account` ✅
|
|
427
|
+
- **auth_util**: `check_authority_signature` ✅
|
|
428
|
+
- **block_info**: `get_block_info` ✅, `get_blocks_with_info` ✅
|
|
429
|
+
- **raw_block**: `get_raw_block` ✅
|
|
430
|
+
|
|
431
|
+
#### Deprecated Plugins
|
|
432
|
+
- **follow**: 9 methods (Deprecated)
|
|
433
|
+
- **tags**: 15 methods (Deprecated)
|
|
434
|
+
- **social_network**: 6 methods (Deprecated)
|
|
435
|
+
- **private_message**: 0 methods (Deprecated - Not Implemented)
|
|
436
|
+
|
|
437
|
+
**Section sources**
|
|
438
|
+
- [VIZ-JS-LIB-COVERAGE-STATUS.md](file://VIZ-JS-LIB-COVERAGE-STATUS.md#L1-L357)
|
|
439
|
+
- [src/broadcast/operations.js](file://src/broadcast/operations.js#L1-L475)
|
|
440
|
+
- [src/api/methods.js](file://src/api/methods.js#L1-L465)
|
|
441
|
+
|
|
442
|
+
## Architecture Overview
|
|
443
|
+
|
|
444
|
+
```mermaid
|
|
445
|
+
classDiagram
|
|
446
|
+
class VIZ {
|
|
447
|
+
+constructor(options)
|
|
448
|
+
+start()
|
|
449
|
+
+stop()
|
|
450
|
+
+send(api, data, callback)
|
|
451
|
+
+onMessage(message, request)
|
|
452
|
+
+streamBlockNumber(mode, callback, ts)
|
|
453
|
+
+streamBlock(mode, callback)
|
|
454
|
+
+streamTransactions(mode, callback)
|
|
455
|
+
+streamOperations(mode, callback)
|
|
456
|
+
}
|
|
457
|
+
class Transport {
|
|
458
|
+
+setOptions(options)
|
|
459
|
+
+listenTo(target, eventName, callback)
|
|
460
|
+
+send()
|
|
461
|
+
+start()
|
|
462
|
+
+stop()
|
|
463
|
+
}
|
|
464
|
+
class HttpTransport {
|
|
465
|
+
+send(api, data, callback)
|
|
466
|
+
}
|
|
467
|
+
class WsTransport {
|
|
468
|
+
+start()
|
|
469
|
+
+stop()
|
|
470
|
+
+send(api, data, callback)
|
|
471
|
+
+onMessage(msg)
|
|
472
|
+
}
|
|
473
|
+
class Broadcaster {
|
|
474
|
+
+send(tx, privKeys, callback)
|
|
475
|
+
+_prepareTransaction(tx)
|
|
476
|
+
+voteWith(...)
|
|
477
|
+
+contentWith(...)
|
|
478
|
+
+transferWith(...)
|
|
479
|
+
}
|
|
480
|
+
class OperationsCoverage {
|
|
481
|
+
+RegularOperations : 31/31
|
|
482
|
+
+VirtualOperations : 22/22
|
|
483
|
+
+PluginAPIs : 88/88
|
|
484
|
+
}
|
|
485
|
+
VIZ --> Transport : "uses"
|
|
486
|
+
HttpTransport --|> Transport
|
|
487
|
+
WsTransport --|> Transport
|
|
488
|
+
Broadcaster --> VIZ : "uses"
|
|
489
|
+
OperationsCoverage --> VIZ : "documents"
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
**Diagram sources**
|
|
493
|
+
- [src/api/index.js](file://src/api/index.js#L21-L271)
|
|
494
|
+
- [src/api/transports/base.js](file://src/api/transports/base.js#L4-L31)
|
|
495
|
+
- [src/api/transports/http.js](file://src/api/transports/http.js#L43-L52)
|
|
496
|
+
- [src/api/transports/ws.js](file://src/api/transports/ws.js#L18-L136)
|
|
497
|
+
- [src/broadcast/index.js](file://src/broadcast/index.js#L24-L129)
|
|
498
|
+
- [VIZ-JS-LIB-COVERAGE-STATUS.md](file://VIZ-JS-LIB-COVERAGE-STATUS.md#L8-L16)
|
|
499
|
+
|
|
500
|
+
## Detailed Component Analysis
|
|
501
|
+
|
|
502
|
+
### API Methods Catalog and Generation
|
|
503
|
+
The VIZ client dynamically creates API methods from a catalog. Each entry defines:
|
|
504
|
+
- api: API namespace (e.g., database_api).
|
|
505
|
+
- method: Method name (e.g., get_accounts).
|
|
506
|
+
- params: Ordered parameter names used to build typed method signatures.
|
|
507
|
+
|
|
508
|
+
Generated methods:
|
|
509
|
+
- fooWith(options, callback): Accepts an options object with named parameters.
|
|
510
|
+
- foo(...args, callback): Accepts positional arguments matching the method's params.
|
|
511
|
+
|
|
512
|
+
Examples of generated methods:
|
|
513
|
+
- getAccounts(accountNames)
|
|
514
|
+
- getDynamicGlobalProperties()
|
|
515
|
+
- getAccountVotes(voter, from, voteLimit)
|
|
516
|
+
|
|
517
|
+
**Section sources**
|
|
518
|
+
- [src/api/methods.js](file://src/api/methods.js#L1-L465)
|
|
519
|
+
- [src/api/index.js](file://src/api/index.js#L239-L262)
|
|
520
|
+
|
|
521
|
+
### HTTP Transport Flow
|
|
522
|
+
```mermaid
|
|
523
|
+
sequenceDiagram
|
|
524
|
+
participant API as "VIZ API"
|
|
525
|
+
participant HTTP as "HttpTransport"
|
|
526
|
+
participant Node as "VIZ Node"
|
|
527
|
+
API->>HTTP : send(api, method, params)
|
|
528
|
+
HTTP->>Node : POST JSON-RPC {method : "call", params : [api, method, params]}
|
|
529
|
+
Node-->>HTTP : {id, result|error}
|
|
530
|
+
HTTP-->>API : callback(error, result)
|
|
531
|
+
```
|
|
532
|
+
|
|
533
|
+
**Diagram sources**
|
|
534
|
+
- [src/api/transports/http.js](file://src/api/transports/http.js#L17-L41)
|
|
535
|
+
- [src/api/transports/http.js](file://src/api/transports/http.js#L43-L52)
|
|
536
|
+
|
|
537
|
+
### WebSocket Transport Flow
|
|
538
|
+
```mermaid
|
|
539
|
+
sequenceDiagram
|
|
540
|
+
participant API as "VIZ API"
|
|
541
|
+
participant WS as "WsTransport"
|
|
542
|
+
participant Node as "VIZ Node"
|
|
543
|
+
API->>WS : send(api, method, params)
|
|
544
|
+
WS->>Node : send JSON-RPC
|
|
545
|
+
Node-->>WS : message {id, result|error}
|
|
546
|
+
WS-->>API : resolve(result) or reject(error)
|
|
547
|
+
```
|
|
548
|
+
|
|
549
|
+
**Diagram sources**
|
|
550
|
+
- [src/api/transports/ws.js](file://src/api/transports/ws.js#L64-L94)
|
|
551
|
+
- [src/api/transports/ws.js](file://src/api/transports/ws.js#L111-L134)
|
|
552
|
+
|
|
553
|
+
### Streaming Utilities
|
|
554
|
+
- streamBlockNumber(mode, callback, interval): Periodically queries getDynamicGlobalProperties and emits new block numbers.
|
|
555
|
+
- streamBlock(mode, callback): Streams full blocks by polling streamBlockNumber and fetching blocks.
|
|
556
|
+
- streamTransactions(mode, callback): Streams transactions from blocks.
|
|
557
|
+
- streamOperations(mode, callback): Streams operations from transactions.
|
|
558
|
+
|
|
559
|
+
Implementation notes:
|
|
560
|
+
- mode supports "head" and "irreversible".
|
|
561
|
+
- Polling interval defaults to 200 ms.
|
|
562
|
+
|
|
563
|
+
**Section sources**
|
|
564
|
+
- [src/api/index.js](file://src/api/index.js#L121-L191)
|
|
565
|
+
- [src/api/index.js](file://src/api/index.js#L193-L235)
|
|
566
|
+
|
|
567
|
+
### Broadcast Workflow
|
|
568
|
+
```mermaid
|
|
569
|
+
flowchart TD
|
|
570
|
+
Start(["Prepare Transaction"]) --> GetProps["Fetch getDynamicGlobalProperties()"]
|
|
571
|
+
GetProps --> DecideRef{"Has irreversible ref?"}
|
|
572
|
+
DecideRef --> |Yes| UseIrrev["Use last_irreversible_block_ref_num/prefix"]
|
|
573
|
+
DecideRef --> |No| FetchBlock["Fetch getBlock(head_block_number - 2)"]
|
|
574
|
+
FetchBlock --> ComputeRef["Compute ref_block_num and ref_block_prefix"]
|
|
575
|
+
UseIrrev --> ComputeRef
|
|
576
|
+
ComputeRef --> Sign["Sign transaction with private keys"]
|
|
577
|
+
Sign --> Submit{"broadcast_transaction_with_callback?"}
|
|
578
|
+
Submit --> |Yes| CallWithCb["Call broadcast_transaction_with_callback"]
|
|
579
|
+
Submit --> |No| CallStd["Call broadcast_transaction"]
|
|
580
|
+
CallWithCb --> Done(["Return signed transaction"])
|
|
581
|
+
CallStd --> Done
|
|
582
|
+
```
|
|
583
|
+
|
|
584
|
+
**Diagram sources**
|
|
585
|
+
- [src/broadcast/index.js](file://src/broadcast/index.js#L49-L84)
|
|
586
|
+
- [src/broadcast/index.js](file://src/broadcast/index.js#L24-L47)
|
|
587
|
+
|
|
588
|
+
### Authentication and Keys
|
|
589
|
+
- Private keys are provided as WIF strings keyed by role (e.g., regular, active, master).
|
|
590
|
+
- Signing is delegated to the auth module; the broadcaster constructs operations and attaches metadata as needed.
|
|
591
|
+
|
|
592
|
+
**Section sources**
|
|
593
|
+
- [src/broadcast/index.js](file://src/broadcast/index.js#L97-L129)
|
|
594
|
+
- [src/broadcast/operations.js](file://src/broadcast/operations.js#L1-L475)
|
|
595
|
+
|
|
596
|
+
### Rate Limiting and Best Practices
|
|
597
|
+
- Prefer WebSocket transport for frequent or real-time usage to reduce overhead.
|
|
598
|
+
- Batch requests where possible; use streaming helpers for continuous monitoring.
|
|
599
|
+
- Respect node rate limits; avoid flooding with rapid successive calls.
|
|
600
|
+
- Use irreversible mode for non-critical reads to minimize reorg impact.
|
|
601
|
+
|
|
602
|
+
## Dependency Analysis
|
|
603
|
+
```mermaid
|
|
604
|
+
graph LR
|
|
605
|
+
IDX["src/index.js"] --> API["src/api/index.js"]
|
|
606
|
+
IDX --> BR["src/broadcast/index.js"]
|
|
607
|
+
IDX --> CFG["src/config.js"]
|
|
608
|
+
API --> MTH["src/api/methods.js"]
|
|
609
|
+
API --> TRIDX["src/api/transports/index.js"]
|
|
610
|
+
TRIDX --> THR["src/api/transports/http.js"]
|
|
611
|
+
TRIDX --> TWS["src/api/transports/ws.js"]
|
|
612
|
+
THR --> BASE["src/api/transports/base.js"]
|
|
613
|
+
TWS --> BASE
|
|
614
|
+
BR --> OPS["src/broadcast/operations.js"]
|
|
615
|
+
BR --> API
|
|
616
|
+
BR --> CFG
|
|
617
|
+
CFG --> DEF["config.json"]
|
|
618
|
+
OPS --> SER["src/auth/serializer/src/operations.js"]
|
|
619
|
+
OPS --> TYPES["src/auth/serializer/src/types.js"]
|
|
620
|
+
COV["VIZ-JS-LIB-COVERAGE-STATUS.md"] --> OPS
|
|
621
|
+
COV --> MTH
|
|
622
|
+
```
|
|
623
|
+
|
|
624
|
+
**Diagram sources**
|
|
625
|
+
- [src/index.js](file://src/index.js#L1-L20)
|
|
626
|
+
- [src/api/index.js](file://src/api/index.js#L1-L271)
|
|
627
|
+
- [src/api/methods.js](file://src/api/methods.js#L1-L465)
|
|
628
|
+
- [src/api/transports/index.js](file://src/api/transports/index.js#L1-L8)
|
|
629
|
+
- [src/api/transports/http.js](file://src/api/transports/http.js#L1-L53)
|
|
630
|
+
- [src/api/transports/ws.js](file://src/api/transports/ws.js#L1-L136)
|
|
631
|
+
- [src/api/transports/base.js](file://src/api/transports/base.js#L1-L34)
|
|
632
|
+
- [src/broadcast/index.js](file://src/broadcast/index.js#L1-L137)
|
|
633
|
+
- [src/broadcast/operations.js](file://src/broadcast/operations.js#L1-L475)
|
|
634
|
+
- [src/config.js](file://src/config.js#L1-L10)
|
|
635
|
+
- [config.json](file://config.json#L1-L7)
|
|
636
|
+
- [src/auth/serializer/src/operations.js](file://src/auth/serializer/src/operations.js#L1-L55)
|
|
637
|
+
- [src/auth/serializer/src/types.js](file://src/auth/serializer/src/types.js#L478-L719)
|
|
638
|
+
- [VIZ-JS-LIB-COVERAGE-STATUS.md](file://VIZ-JS-LIB-COVERAGE-STATUS.md#L1-L357)
|
|
639
|
+
|
|
640
|
+
**Section sources**
|
|
641
|
+
- [src/index.js](file://src/index.js#L1-L20)
|
|
642
|
+
- [src/api/transports/index.js](file://src/api/transports/index.js#L1-L8)
|
|
643
|
+
|
|
644
|
+
## Performance Considerations
|
|
645
|
+
- WebSocket transport reduces latency and overhead compared to repeated HTTP requests.
|
|
646
|
+
- Streaming utilities poll at fixed intervals; adjust interval based on needs.
|
|
647
|
+
- Use Promise-based APIs for easier composition and error handling.
|
|
648
|
+
- Cache frequently accessed chain properties locally to minimize round trips.
|
|
649
|
+
|
|
650
|
+
## Troubleshooting Guide
|
|
651
|
+
Common issues and resolutions:
|
|
652
|
+
- Unknown transport URL: Ensure the websocket URL starts with http/https for HTTP or ws/wss for WebSocket.
|
|
653
|
+
- Connection errors: Verify node availability and network connectivity; WebSocket errors trigger rejections of in-flight requests.
|
|
654
|
+
- Missing or invalid credentials: Broadcasting requires valid private keys for the required roles.
|
|
655
|
+
- Rate limiting: Reduce request frequency or switch to WebSocket for efficient updates.
|
|
656
|
+
|
|
657
|
+
Operational checks:
|
|
658
|
+
- Confirm websocket URL is set before invoking methods.
|
|
659
|
+
- Monitor emitted performance events for slow endpoints.
|
|
660
|
+
- Use streaming helpers to validate connectivity and data flow.
|
|
661
|
+
|
|
662
|
+
**Section sources**
|
|
663
|
+
- [src/api/index.js](file://src/api/index.js#L34-L42)
|
|
664
|
+
- [src/api/transports/ws.js](file://src/api/transports/ws.js#L96-L109)
|
|
665
|
+
- [test/api.test.js](file://test/api.test.js#L168-L200)
|
|
666
|
+
|
|
667
|
+
## Conclusion
|
|
668
|
+
The VIZ JavaScript library offers a robust, transport-agnostic API for querying blockchain data and broadcasting transactions. With **100% coverage** of all VIZ blockchain operations, the library provides comprehensive support for both regular and virtual operations, along with complete plugin API coverage. By leveraging dynamic method generation, configurable transports, and streaming utilities, applications can efficiently integrate with the VIZ blockchain. The comprehensive operations coverage documentation ensures developers have detailed specifications for all supported blockchain operations and API methods.
|
|
669
|
+
|
|
670
|
+
## Appendices
|
|
671
|
+
|
|
672
|
+
### API Method Index
|
|
673
|
+
- getAccounts(accountNames)
|
|
674
|
+
- getDynamicGlobalProperties()
|
|
675
|
+
- getAccountVotes(voter, from, voteLimit)
|
|
676
|
+
- getContent(author, permlink)
|
|
677
|
+
- getFollowers(following, startFollower, followType, limit)
|
|
678
|
+
- getBlog(account, entryId, limit)
|
|
679
|
+
- getFeed(account, entryId, limit)
|
|
680
|
+
- getActiveVotes(author, permlink, voteLimit)
|
|
681
|
+
- getBlockHeader(blockNum)
|
|
682
|
+
- getBlock(blockNum)
|
|
683
|
+
- broadcast_transaction(trx)
|
|
684
|
+
- broadcast_transaction_with_callback(confirmationCallback, trx)
|
|
685
|
+
- broadcast_transaction_synchronous(trx)
|
|
686
|
+
- broadcast_block(block)
|
|
687
|
+
|
|
688
|
+
**Section sources**
|
|
689
|
+
- [src/api/methods.js](file://src/api/methods.js#L253-L274)
|
|
690
|
+
- [src/api/methods.js](file://src/api/methods.js#L139-L161)
|
|
691
|
+
- [src/api/methods.js](file://src/api/methods.js#L138-L156)
|
|
692
|
+
- [src/api/methods.js](file://src/api/methods.js#L163-L181)
|
|
693
|
+
- [src/api/methods.js](file://src/api/methods.js#L356-L374)
|
|
694
|
+
|
|
695
|
+
### Transport Selection Logic
|
|
696
|
+
```mermaid
|
|
697
|
+
flowchart TD
|
|
698
|
+
A["Set websocket URL"] --> B{"URL starts with http/https?"}
|
|
699
|
+
B --> |Yes| C["Use HTTP transport"]
|
|
700
|
+
B --> |No| D{"URL starts with ws/wss?"}
|
|
701
|
+
D --> |Yes| E["Use WebSocket transport"]
|
|
702
|
+
D --> |No| F["Throw unknown transport error"]
|
|
703
|
+
```
|
|
704
|
+
|
|
705
|
+
**Diagram sources**
|
|
706
|
+
- [src/api/index.js](file://src/api/index.js#L34-L42)
|
|
707
|
+
|
|
708
|
+
### Practical Examples
|
|
709
|
+
- Query post content:
|
|
710
|
+
- See [examples/get-post-content.js](file://examples/get-post-content.js#L1-L5)
|
|
711
|
+
- Upvote via broadcast:
|
|
712
|
+
- See [examples/test-vote.js](file://examples/test-vote.js#L1-L19)
|
|
713
|
+
|
|
714
|
+
**Section sources**
|
|
715
|
+
- [examples/get-post-content.js](file://examples/get-post-content.js#L1-L5)
|
|
716
|
+
- [examples/test-vote.js](file://examples/test-vote.js#L1-L19)
|
|
717
|
+
|
|
718
|
+
### Operations Coverage Reference
|
|
719
|
+
For detailed specifications of all supported blockchain operations and API methods, refer to the comprehensive operations coverage documentation:
|
|
720
|
+
|
|
721
|
+
**Section sources**
|
|
722
|
+
- [VIZ-JS-LIB-COVERAGE-STATUS.md](file://VIZ-JS-LIB-COVERAGE-STATUS.md#L1-L357)
|
|
723
|
+
- [src/broadcast/operations.js](file://src/broadcast/operations.js#L1-L475)
|
|
724
|
+
- [src/api/methods.js](file://src/api/methods.js#L1-L465)
|