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,352 @@
|
|
|
1
|
+
# Operation Construction
|
|
2
|
+
|
|
3
|
+
<cite>
|
|
4
|
+
**Referenced Files in This Document**
|
|
5
|
+
- [src/broadcast/operations.js](file://src/broadcast/operations.js)
|
|
6
|
+
- [src/broadcast/index.js](file://src/broadcast/index.js)
|
|
7
|
+
- [src/broadcast/helpers.js](file://src/broadcast/helpers.js)
|
|
8
|
+
- [src/formatter.js](file://src/formatter.js)
|
|
9
|
+
- [src/utils.js](file://src/utils.js)
|
|
10
|
+
- [src/auth/serializer/src/operations.js](file://src/auth/serializer/src/operations.js)
|
|
11
|
+
- [test/broadcast.test.js](file://test/broadcast.test.js)
|
|
12
|
+
- [examples/broadcast.html](file://examples/broadcast.html)
|
|
13
|
+
</cite>
|
|
14
|
+
|
|
15
|
+
## Table of Contents
|
|
16
|
+
1. [Introduction](#introduction)
|
|
17
|
+
2. [Project Structure](#project-structure)
|
|
18
|
+
3. [Core Components](#core-components)
|
|
19
|
+
4. [Architecture Overview](#architecture-overview)
|
|
20
|
+
5. [Detailed Component Analysis](#detailed-component-analysis)
|
|
21
|
+
6. [Dependency Analysis](#dependency-analysis)
|
|
22
|
+
7. [Performance Considerations](#performance-considerations)
|
|
23
|
+
8. [Troubleshooting Guide](#troubleshooting-guide)
|
|
24
|
+
9. [Conclusion](#conclusion)
|
|
25
|
+
10. [Appendices](#appendices)
|
|
26
|
+
|
|
27
|
+
## Introduction
|
|
28
|
+
This document explains how the broadcast system constructs and wraps operations for submission to the blockchain. It covers the operations configuration, automatic wrapper generation, parameter mapping, metadata handling, camelCase conversion for operation names, role-based key assignment, and permlink generation for comments. It also demonstrates how to construct different operation types, handle optional parameters, and integrate with the formatter system for content operations.
|
|
29
|
+
|
|
30
|
+
## Project Structure
|
|
31
|
+
The broadcast system is organized around a declarative configuration that defines supported operations, their parameters, and authorization roles. The runtime generates specialized wrapper functions that validate and assemble transactions, sign them, and broadcast them to the network.
|
|
32
|
+
|
|
33
|
+
```mermaid
|
|
34
|
+
graph TB
|
|
35
|
+
subgraph "Broadcast Layer"
|
|
36
|
+
O["operations.js<br/>Declarative operation config"]
|
|
37
|
+
I["index.js<br/>Wrapper generator"]
|
|
38
|
+
H["helpers.js<br/>Account authority helpers"]
|
|
39
|
+
end
|
|
40
|
+
subgraph "Formatter Layer"
|
|
41
|
+
F["formatter.js<br/>Formatting utilities"]
|
|
42
|
+
end
|
|
43
|
+
subgraph "Utils Layer"
|
|
44
|
+
U["utils.js<br/>camelCase conversion"]
|
|
45
|
+
end
|
|
46
|
+
subgraph "Serialization Layer"
|
|
47
|
+
S["auth/serializer/src/operations.js<br/>Operation serializers"]
|
|
48
|
+
end
|
|
49
|
+
O --> I
|
|
50
|
+
U --> I
|
|
51
|
+
F --> I
|
|
52
|
+
I --> H
|
|
53
|
+
I --> S
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**Diagram sources**
|
|
57
|
+
- [src/broadcast/operations.js](file://src/broadcast/operations.js#L1-L475)
|
|
58
|
+
- [src/broadcast/index.js](file://src/broadcast/index.js#L1-L137)
|
|
59
|
+
- [src/broadcast/helpers.js](file://src/broadcast/helpers.js#L1-L82)
|
|
60
|
+
- [src/formatter.js](file://src/formatter.js#L1-L87)
|
|
61
|
+
- [src/utils.js](file://src/utils.js#L1-L348)
|
|
62
|
+
- [src/auth/serializer/src/operations.js](file://src/auth/serializer/src/operations.js#L1-L922)
|
|
63
|
+
|
|
64
|
+
**Section sources**
|
|
65
|
+
- [src/broadcast/operations.js](file://src/broadcast/operations.js#L1-L475)
|
|
66
|
+
- [src/broadcast/index.js](file://src/broadcast/index.js#L1-L137)
|
|
67
|
+
- [src/broadcast/helpers.js](file://src/broadcast/helpers.js#L1-L82)
|
|
68
|
+
- [src/formatter.js](file://src/formatter.js#L1-L87)
|
|
69
|
+
- [src/utils.js](file://src/utils.js#L1-L348)
|
|
70
|
+
- [src/auth/serializer/src/operations.js](file://src/auth/serializer/src/operations.js#L1-L922)
|
|
71
|
+
|
|
72
|
+
## Core Components
|
|
73
|
+
- Operations configuration: Defines operation names, parameter lists, and required roles.
|
|
74
|
+
- Wrapper generator: Reads the configuration and creates convenience functions for each operation.
|
|
75
|
+
- Formatter: Provides utilities like permlink generation for content operations.
|
|
76
|
+
- Utils: Supplies camelCase conversion for operation names.
|
|
77
|
+
- Helpers: Adds and removes account authorities for delegated posting.
|
|
78
|
+
- Serialization: Defines operation schemas used by the underlying protocol.
|
|
79
|
+
|
|
80
|
+
**Section sources**
|
|
81
|
+
- [src/broadcast/operations.js](file://src/broadcast/operations.js#L1-L475)
|
|
82
|
+
- [src/broadcast/index.js](file://src/broadcast/index.js#L86-L137)
|
|
83
|
+
- [src/formatter.js](file://src/formatter.js#L69-L76)
|
|
84
|
+
- [src/utils.js](file://src/utils.js#L4-L8)
|
|
85
|
+
- [src/broadcast/helpers.js](file://src/broadcast/helpers.js#L5-L82)
|
|
86
|
+
- [src/auth/serializer/src/operations.js](file://src/auth/serializer/src/operations.js#L172-L195)
|
|
87
|
+
|
|
88
|
+
## Architecture Overview
|
|
89
|
+
The broadcast system builds wrappers around a small set of operations. Each wrapper:
|
|
90
|
+
- Converts the operation name to camelCase.
|
|
91
|
+
- Accepts either positional arguments or an options object.
|
|
92
|
+
- Automatically sets required keys based on roles.
|
|
93
|
+
- Applies metadata transformations (e.g., JSON metadata serialization).
|
|
94
|
+
- Generates permlinks for comment-like operations when missing.
|
|
95
|
+
- Prepares and signs the transaction, then broadcasts it.
|
|
96
|
+
|
|
97
|
+
```mermaid
|
|
98
|
+
sequenceDiagram
|
|
99
|
+
participant App as "Application"
|
|
100
|
+
participant BC as "Broadcaster"
|
|
101
|
+
participant CFG as "operations.js"
|
|
102
|
+
participant FMT as "formatter.js"
|
|
103
|
+
participant SER as "serializer"
|
|
104
|
+
participant NET as "Network"
|
|
105
|
+
App->>BC : "vote(wif, voter, author, permlink, weight)"
|
|
106
|
+
BC->>CFG : "Lookup operation definition"
|
|
107
|
+
BC->>BC : "Map params to options object"
|
|
108
|
+
BC->>BC : "Assign keys by role"
|
|
109
|
+
BC->>FMT : "Generate permlink if needed"
|
|
110
|
+
BC->>BC : "Prepare transaction"
|
|
111
|
+
BC->>SER : "Sign transaction"
|
|
112
|
+
SER-->>BC : "Signed transaction"
|
|
113
|
+
BC->>NET : "Broadcast transaction"
|
|
114
|
+
NET-->>BC : "Result"
|
|
115
|
+
BC-->>App : "Transaction result"
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
**Diagram sources**
|
|
119
|
+
- [src/broadcast/index.js](file://src/broadcast/index.js#L88-L129)
|
|
120
|
+
- [src/broadcast/operations.js](file://src/broadcast/operations.js#L1-L475)
|
|
121
|
+
- [src/formatter.js](file://src/formatter.js#L69-L76)
|
|
122
|
+
- [src/auth/serializer/src/operations.js](file://src/auth/serializer/src/operations.js#L116-L125)
|
|
123
|
+
|
|
124
|
+
## Detailed Component Analysis
|
|
125
|
+
|
|
126
|
+
### Operations Configuration
|
|
127
|
+
The configuration file enumerates supported operations with:
|
|
128
|
+
- operation: The snake_case operation name used in the protocol.
|
|
129
|
+
- params: Ordered parameter names expected by the operation.
|
|
130
|
+
- roles: Authorization roles required to sign the operation.
|
|
131
|
+
|
|
132
|
+
Examples include voting, content creation, transfers, and governance operations.
|
|
133
|
+
|
|
134
|
+
Key characteristics:
|
|
135
|
+
- Parameter ordering determines positional argument mapping.
|
|
136
|
+
- Roles drive automatic key assignment in wrapper generation.
|
|
137
|
+
- Some operations imply special handling (e.g., comment permlink generation).
|
|
138
|
+
|
|
139
|
+
**Section sources**
|
|
140
|
+
- [src/broadcast/operations.js](file://src/broadcast/operations.js#L1-L475)
|
|
141
|
+
|
|
142
|
+
### Automatic Wrapper Generation
|
|
143
|
+
The wrapper generator reads the configuration and produces:
|
|
144
|
+
- operationName: camelCase version of the operation name.
|
|
145
|
+
- operationNameWith: Accepts an options object and optional callback.
|
|
146
|
+
- operationName: Accepts positional arguments and converts them to an options object.
|
|
147
|
+
|
|
148
|
+
Behavior highlights:
|
|
149
|
+
- Role-based key assignment: Uses the first role as the key name for signing.
|
|
150
|
+
- JSON metadata normalization: Serializes objects to strings.
|
|
151
|
+
- Comment permlink generation: When parent_author and parent_permlink are present and permlink is missing, a permlink is generated using the formatter.
|
|
152
|
+
|
|
153
|
+
```mermaid
|
|
154
|
+
flowchart TD
|
|
155
|
+
Start(["Wrapper invoked"]) --> Parse["Parse parameters"]
|
|
156
|
+
Parse --> AssignRole["Assign private key by role"]
|
|
157
|
+
AssignRole --> NormalizeMeta["Normalize JSON metadata"]
|
|
158
|
+
NormalizeMeta --> CheckPermlink{"Comment operation<br/>with missing permlink?"}
|
|
159
|
+
CheckPermlink --> |Yes| GenPermlink["Generate permlink via formatter"]
|
|
160
|
+
CheckPermlink --> |No| SkipGen["Skip permlink generation"]
|
|
161
|
+
GenPermlink --> BuildTx["Build transaction"]
|
|
162
|
+
SkipGen --> BuildTx
|
|
163
|
+
BuildTx --> Sign["Sign transaction"]
|
|
164
|
+
Sign --> Broadcast["Broadcast to network"]
|
|
165
|
+
Broadcast --> End(["Return result"])
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
**Diagram sources**
|
|
169
|
+
- [src/broadcast/index.js](file://src/broadcast/index.js#L88-L129)
|
|
170
|
+
- [src/formatter.js](file://src/formatter.js#L69-L76)
|
|
171
|
+
|
|
172
|
+
**Section sources**
|
|
173
|
+
- [src/broadcast/index.js](file://src/broadcast/index.js#L88-L129)
|
|
174
|
+
|
|
175
|
+
### Parameter Mapping and Validation
|
|
176
|
+
- Positional mapping: The wrapper maps arguments to parameter names in order.
|
|
177
|
+
- Options object: operationNameWith accepts an options object directly.
|
|
178
|
+
- Validation: The configuration itself defines required parameters. The wrapper enforces presence by building the options object from arguments or passed options.
|
|
179
|
+
|
|
180
|
+
Optional parameters:
|
|
181
|
+
- Handled by passing undefined or omitting from the options object.
|
|
182
|
+
- The underlying serializer handles optional fields according to the operation schema.
|
|
183
|
+
|
|
184
|
+
**Section sources**
|
|
185
|
+
- [src/broadcast/index.js](file://src/broadcast/index.js#L119-L128)
|
|
186
|
+
- [src/broadcast/operations.js](file://src/broadcast/operations.js#L1-L475)
|
|
187
|
+
|
|
188
|
+
### Metadata Handling
|
|
189
|
+
- JSON metadata normalization: Objects are serialized to strings before inclusion in the operation payload.
|
|
190
|
+
- Extensions: The wrapper sets an empty extensions array by default, which can be overridden in operationNameWith.
|
|
191
|
+
|
|
192
|
+
**Section sources**
|
|
193
|
+
- [src/broadcast/index.js](file://src/broadcast/index.js#L104-L116)
|
|
194
|
+
|
|
195
|
+
### CamelCase Conversion for Operation Names
|
|
196
|
+
- The generator converts snake_case operation names to camelCase for method naming.
|
|
197
|
+
- Example: "content" becomes "content", "transfer_to_vesting" becomes "transferToVesting".
|
|
198
|
+
|
|
199
|
+
**Section sources**
|
|
200
|
+
- [src/utils.js](file://src/utils.js#L4-L8)
|
|
201
|
+
- [src/broadcast/index.js](file://src/broadcast/index.js#L90)
|
|
202
|
+
|
|
203
|
+
### Role-Based Key Assignment
|
|
204
|
+
- The wrapper assigns the private key under the first role listed in the configuration.
|
|
205
|
+
- This enables operations requiring posting, active, or master authority to be signed appropriately.
|
|
206
|
+
|
|
207
|
+
**Section sources**
|
|
208
|
+
- [src/broadcast/index.js](file://src/broadcast/index.js#L101-L103)
|
|
209
|
+
- [src/broadcast/operations.js](file://src/broadcast/operations.js#L1-L475)
|
|
210
|
+
|
|
211
|
+
### Permlink Generation for Comments
|
|
212
|
+
- For operations that include parent_author and parent_permlink, the wrapper can automatically generate a permlink if none is provided.
|
|
213
|
+
- The formatter constructs a deterministic permlink using the parent author/permlink and a timestamp.
|
|
214
|
+
|
|
215
|
+
```mermaid
|
|
216
|
+
sequenceDiagram
|
|
217
|
+
participant W as "Wrapper"
|
|
218
|
+
participant F as "Formatter"
|
|
219
|
+
participant T as "Transaction"
|
|
220
|
+
W->>F : "contentPermlink(parent_author, parent_permlink)"
|
|
221
|
+
F-->>W : "Generated permlink"
|
|
222
|
+
W->>T : "Attach permlink to operation"
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
**Diagram sources**
|
|
226
|
+
- [src/broadcast/index.js](file://src/broadcast/index.js#L112-L114)
|
|
227
|
+
- [src/formatter.js](file://src/formatter.js#L69-L76)
|
|
228
|
+
|
|
229
|
+
**Section sources**
|
|
230
|
+
- [src/broadcast/index.js](file://src/broadcast/index.js#L93-L95)
|
|
231
|
+
- [src/broadcast/index.js](file://src/broadcast/index.js#L112-L114)
|
|
232
|
+
- [src/formatter.js](file://src/formatter.js#L69-L76)
|
|
233
|
+
|
|
234
|
+
### Operation-Specific Helper Functions
|
|
235
|
+
- Account authority helpers: addAccountAuth and removeAccountAuth update account authorities for a given role and resubmit an account_update operation.
|
|
236
|
+
|
|
237
|
+
```mermaid
|
|
238
|
+
flowchart TD
|
|
239
|
+
AStart(["add/remove authority"]) --> Fetch["Fetch account"]
|
|
240
|
+
Fetch --> Update["Update role authority"]
|
|
241
|
+
Update --> HasChanged{"Authority changed?"}
|
|
242
|
+
HasChanged --> |No| ReturnNull["Return null"]
|
|
243
|
+
HasChanged --> |Yes| CallAU["Call accountUpdate with updated authority"]
|
|
244
|
+
CallAU --> AEnd(["Done"])
|
|
245
|
+
ReturnNull --> AEnd
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
**Diagram sources**
|
|
249
|
+
- [src/broadcast/helpers.js](file://src/broadcast/helpers.js#L6-L80)
|
|
250
|
+
|
|
251
|
+
**Section sources**
|
|
252
|
+
- [src/broadcast/helpers.js](file://src/broadcast/helpers.js#L5-L82)
|
|
253
|
+
|
|
254
|
+
### Constructing Different Operation Types
|
|
255
|
+
- Voting: Pass voter, author, permlink, and weight. The wrapper maps these to the options object and signs with the posting key.
|
|
256
|
+
- Content: Pass parent_author, parent_permlink, author, permlink, title, body, and optional json_metadata. If permlink is omitted for comment-like operations, it is generated automatically.
|
|
257
|
+
- Transfer: Pass from, to, amount, and memo.
|
|
258
|
+
- Governance: Operations like custom, proposal_create/update/delete, and account_update follow the same wrapper pattern.
|
|
259
|
+
|
|
260
|
+
Integration with formatter:
|
|
261
|
+
- For content operations, the formatter’s contentPermlink is used to generate permlinks when missing.
|
|
262
|
+
|
|
263
|
+
**Section sources**
|
|
264
|
+
- [src/broadcast/index.js](file://src/broadcast/index.js#L119-L128)
|
|
265
|
+
- [src/broadcast/index.js](file://src/broadcast/index.js#L112-L114)
|
|
266
|
+
- [src/formatter.js](file://src/formatter.js#L69-L76)
|
|
267
|
+
- [test/broadcast.test.js](file://test/broadcast.test.js#L16-L31)
|
|
268
|
+
- [examples/broadcast.html](file://examples/broadcast.html#L15-L60)
|
|
269
|
+
|
|
270
|
+
### Handling Optional Parameters
|
|
271
|
+
- Optional parameters are omitted from the options object or passed as undefined.
|
|
272
|
+
- The underlying serializer handles optional fields according to the operation schema.
|
|
273
|
+
|
|
274
|
+
**Section sources**
|
|
275
|
+
- [src/broadcast/index.js](file://src/broadcast/index.js#L122-L125)
|
|
276
|
+
- [src/auth/serializer/src/operations.js](file://src/auth/serializer/src/operations.js#L172-L195)
|
|
277
|
+
|
|
278
|
+
### Integrating with the Formatter System
|
|
279
|
+
- The formatter provides contentPermlink for comment-like operations.
|
|
280
|
+
- JSON metadata is normalized to strings before inclusion in operations.
|
|
281
|
+
|
|
282
|
+
**Section sources**
|
|
283
|
+
- [src/broadcast/index.js](file://src/broadcast/index.js#L109-L111)
|
|
284
|
+
- [src/broadcast/index.js](file://src/broadcast/index.js#L112-L114)
|
|
285
|
+
- [src/formatter.js](file://src/formatter.js#L69-L76)
|
|
286
|
+
|
|
287
|
+
## Dependency Analysis
|
|
288
|
+
The broadcast layer depends on:
|
|
289
|
+
- Configuration for operation definitions.
|
|
290
|
+
- Utils for camelCase conversion.
|
|
291
|
+
- Formatter for permlink generation.
|
|
292
|
+
- Serializer for transaction signing and structure.
|
|
293
|
+
- Helpers for account authority management.
|
|
294
|
+
|
|
295
|
+
```mermaid
|
|
296
|
+
graph LR
|
|
297
|
+
CFG["operations.js"] --> GEN["Wrapper Generator"]
|
|
298
|
+
UTIL["utils.js"] --> GEN
|
|
299
|
+
FMT["formatter.js"] --> GEN
|
|
300
|
+
GEN --> TX["Transaction Builder"]
|
|
301
|
+
TX --> SER["Serializer"]
|
|
302
|
+
GEN --> HELP["Helpers"]
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
**Diagram sources**
|
|
306
|
+
- [src/broadcast/operations.js](file://src/broadcast/operations.js#L1-L475)
|
|
307
|
+
- [src/broadcast/index.js](file://src/broadcast/index.js#L88-L129)
|
|
308
|
+
- [src/utils.js](file://src/utils.js#L4-L8)
|
|
309
|
+
- [src/formatter.js](file://src/formatter.js#L69-L76)
|
|
310
|
+
- [src/auth/serializer/src/operations.js](file://src/auth/serializer/src/operations.js#L116-L125)
|
|
311
|
+
|
|
312
|
+
**Section sources**
|
|
313
|
+
- [src/broadcast/index.js](file://src/broadcast/index.js#L1-L137)
|
|
314
|
+
- [src/broadcast/operations.js](file://src/broadcast/operations.js#L1-L475)
|
|
315
|
+
- [src/utils.js](file://src/utils.js#L4-L8)
|
|
316
|
+
- [src/formatter.js](file://src/formatter.js#L69-L76)
|
|
317
|
+
- [src/auth/serializer/src/operations.js](file://src/auth/serializer/src/operations.js#L116-L125)
|
|
318
|
+
|
|
319
|
+
## Performance Considerations
|
|
320
|
+
- Wrapper generation is static and occurs once at load time, minimizing runtime overhead.
|
|
321
|
+
- Transaction preparation fetches dynamic global properties and optionally a block header; caching or reusing these values can reduce latency.
|
|
322
|
+
- JSON metadata serialization is performed only when needed.
|
|
323
|
+
|
|
324
|
+
[No sources needed since this section provides general guidance]
|
|
325
|
+
|
|
326
|
+
## Troubleshooting Guide
|
|
327
|
+
Common issues and resolutions:
|
|
328
|
+
- Missing permlink for comment-like operations: Ensure parent_author and parent_permlink are provided so the formatter can generate a permlink.
|
|
329
|
+
- Incorrect parameter order: Use the options object form (operationNameWith) to avoid positional mapping errors.
|
|
330
|
+
- Role mismatch: Verify the operation’s roles match the provided key’s role.
|
|
331
|
+
- JSON metadata format: Provide a string or an object that serializes to a valid JSON string.
|
|
332
|
+
|
|
333
|
+
**Section sources**
|
|
334
|
+
- [src/broadcast/index.js](file://src/broadcast/index.js#L112-L114)
|
|
335
|
+
- [src/broadcast/index.js](file://src/broadcast/index.js#L122-L125)
|
|
336
|
+
- [src/broadcast/operations.js](file://src/broadcast/operations.js#L1-L475)
|
|
337
|
+
|
|
338
|
+
## Conclusion
|
|
339
|
+
The broadcast system’s declarative configuration and automatic wrapper generation provide a clean, consistent interface for constructing and submitting blockchain operations. By leveraging camelCase conversion, role-based key assignment, and formatter-driven permlink generation, it simplifies operation construction while maintaining flexibility for optional parameters and metadata.
|
|
340
|
+
|
|
341
|
+
[No sources needed since this section summarizes without analyzing specific files]
|
|
342
|
+
|
|
343
|
+
## Appendices
|
|
344
|
+
|
|
345
|
+
### Appendix A: Example Workflows
|
|
346
|
+
- Voting: Use the vote wrapper with posting key and positional parameters.
|
|
347
|
+
- Content: Use the content wrapper; omit permlink to auto-generate it.
|
|
348
|
+
- Custom JSON: Use the custom wrapper with required authorities and JSON payload.
|
|
349
|
+
|
|
350
|
+
**Section sources**
|
|
351
|
+
- [test/broadcast.test.js](file://test/broadcast.test.js#L54-L120)
|
|
352
|
+
- [examples/broadcast.html](file://examples/broadcast.html#L15-L103)
|