hive-stream 3.0.3 → 3.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DOCUMENTATION.md +693 -1
- package/README.md +251 -1
- package/dist/adapters/mongodb.adapter.js +21 -30
- package/dist/adapters/mongodb.adapter.js.map +1 -1
- package/dist/adapters/postgresql.adapter.js +16 -16
- package/dist/adapters/postgresql.adapter.js.map +1 -1
- package/dist/adapters/sqlite.adapter.js +17 -17
- package/dist/adapters/sqlite.adapter.js.map +1 -1
- package/dist/api.js +2 -0
- package/dist/api.js.map +1 -1
- package/dist/builders.d.ts +444 -0
- package/dist/builders.js +1609 -0
- package/dist/builders.js.map +1 -0
- package/dist/config.d.ts +10 -1
- package/dist/config.js +90 -4
- package/dist/config.js.map +1 -1
- package/dist/contracts/coinflip.contract.js +18 -21
- package/dist/contracts/coinflip.contract.js.map +1 -1
- package/dist/contracts/dice.contract.js +18 -21
- package/dist/contracts/dice.contract.js.map +1 -1
- package/dist/contracts/helpers.d.ts +2 -0
- package/dist/contracts/helpers.js +18 -11
- package/dist/contracts/helpers.js.map +1 -1
- package/dist/contracts/nft.contract.js +5 -10
- package/dist/contracts/nft.contract.js.map +1 -1
- package/dist/contracts/rps.contract.js +35 -23
- package/dist/contracts/rps.contract.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/metadata.d.ts +13 -0
- package/dist/metadata.js +256 -0
- package/dist/metadata.js.map +1 -1
- package/dist/streamer.d.ts +148 -12
- package/dist/streamer.js +1102 -53
- package/dist/streamer.js.map +1 -1
- package/dist/types/hive-stream.d.ts +623 -0
- package/dist/utils.d.ts +475 -0
- package/dist/utils.js +1618 -8
- package/dist/utils.js.map +1 -1
- package/package.json +4 -5
package/dist/builders.js
ADDED
|
@@ -0,0 +1,1609 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HiveCommunityOperationBuilder = exports.HiveEngineDelegateBuilder = exports.HiveEngineCancelOrderBuilder = exports.HiveEngineMarketOrderBuilder = exports.HiveEngineUnstakeBuilder = exports.HiveEngineStakeBuilder = exports.HiveBatchBuilder = exports.HivePostBuilder = exports.HiveCommentOptionsBuilder = exports.HiveWithdrawRouteBuilder = exports.HiveCancelOrderBuilder = exports.HiveLimitOrderBuilder = exports.HiveDeleteCommentBuilder = exports.HiveCollateralizedConvertBuilder = exports.HiveConvertBuilder = exports.HiveSavingsTransferBuilder = exports.HiveUpdateProfileBuilder = exports.HiveSetProxyBuilder = exports.HiveWitnessVoteBuilder = exports.HiveClaimRewardsBuilder = exports.HiveDelegateBuilder = exports.HivePowerDownBuilder = exports.HivePowerUpBuilder = exports.HiveReblogBuilder = exports.HiveFollowBuilder = exports.HiveVoteBuilder = exports.HiveRemoveProposalsBuilder = exports.HiveProposalVotesBuilder = exports.HiveEngineTokenIssueBuilder = exports.HiveEngineTokenBurnBuilder = exports.HiveEngineTokenTransferBuilder = exports.HiveProposalBuilder = exports.HiveRecurrentTransferBuilder = exports.HiveEscrowTransferBuilder = exports.HiveBurnBuilder = exports.HiveTransferBuilder = exports.IncomingTransfersBuilder = void 0;
|
|
4
|
+
const utils_1 = require("./utils");
|
|
5
|
+
function normalizeAllocationInput(input, context) {
|
|
6
|
+
if (typeof input === 'number') {
|
|
7
|
+
return { percentage: input };
|
|
8
|
+
}
|
|
9
|
+
if (typeof input === 'string') {
|
|
10
|
+
const value = input.trim();
|
|
11
|
+
if (!/^-?\d+(\.\d+)?$/.test(value)) {
|
|
12
|
+
throw new Error(`${context} allocation string must be numeric`);
|
|
13
|
+
}
|
|
14
|
+
return { percentage: value };
|
|
15
|
+
}
|
|
16
|
+
if (!input || typeof input !== 'object') {
|
|
17
|
+
throw new Error(`${context} allocation is required`);
|
|
18
|
+
}
|
|
19
|
+
const percentage = input.percentage ?? input.percent;
|
|
20
|
+
const basisPoints = input.basisPoints;
|
|
21
|
+
if (percentage !== undefined && basisPoints !== undefined) {
|
|
22
|
+
throw new Error(`${context} accepts either percentage or basisPoints, not both`);
|
|
23
|
+
}
|
|
24
|
+
if (percentage === undefined && basisPoints === undefined) {
|
|
25
|
+
throw new Error(`${context} allocation is required`);
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
percentage: input.percentage,
|
|
29
|
+
percent: input.percent,
|
|
30
|
+
basisPoints: input.basisPoints
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function resolveRouteMemo(stepMemo, defaultMemo) {
|
|
34
|
+
return stepMemo !== undefined ? stepMemo : defaultMemo;
|
|
35
|
+
}
|
|
36
|
+
function normalizeGroupRecipients(recipients, context) {
|
|
37
|
+
if (!Array.isArray(recipients) || recipients.length === 0) {
|
|
38
|
+
throw new Error(`${context} requires at least one group recipient`);
|
|
39
|
+
}
|
|
40
|
+
return recipients.map((recipient, index) => {
|
|
41
|
+
if (!recipient || typeof recipient !== 'object') {
|
|
42
|
+
throw new Error(`${context} recipient ${index + 1} is invalid`);
|
|
43
|
+
}
|
|
44
|
+
if (typeof recipient.account === 'string') {
|
|
45
|
+
const account = recipient.account.trim();
|
|
46
|
+
if (!account) {
|
|
47
|
+
throw new Error(`${context} recipient ${index + 1} account is required`);
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
account,
|
|
51
|
+
weight: recipient.weight
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
if (typeof recipient.account !== 'function') {
|
|
55
|
+
throw new Error(`${context} recipient ${index + 1} account is required`);
|
|
56
|
+
}
|
|
57
|
+
return recipient;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
function parseAssetInput(amount, symbol) {
|
|
61
|
+
if (symbol) {
|
|
62
|
+
return {
|
|
63
|
+
amount: utils_1.Utils.formatAmount(amount),
|
|
64
|
+
symbol: symbol.trim()
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
if (typeof amount === 'string' && amount.includes(' ')) {
|
|
68
|
+
const parsed = utils_1.Utils.parseAssetAmount(amount);
|
|
69
|
+
return {
|
|
70
|
+
amount: utils_1.Utils.formatAmount(parsed.amount),
|
|
71
|
+
symbol: parsed.asset
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
throw new Error('Provide a symbol or an asset amount string like "1.000 HIVE"');
|
|
75
|
+
}
|
|
76
|
+
function buildAssetAmount(amount, symbol) {
|
|
77
|
+
const parsed = parseAssetInput(amount, symbol);
|
|
78
|
+
return utils_1.Utils.formatAssetAmount(parsed.amount, parsed.symbol);
|
|
79
|
+
}
|
|
80
|
+
function normalizeEngineQuantity(quantity) {
|
|
81
|
+
const normalized = String(quantity).trim();
|
|
82
|
+
if (!normalized) {
|
|
83
|
+
throw new Error('Quantity is required');
|
|
84
|
+
}
|
|
85
|
+
return normalized;
|
|
86
|
+
}
|
|
87
|
+
class IncomingTransfersBuilder {
|
|
88
|
+
streamer;
|
|
89
|
+
account;
|
|
90
|
+
allowedSymbols;
|
|
91
|
+
dedupeStore;
|
|
92
|
+
ignoreZeroAmountValue;
|
|
93
|
+
errorHandler;
|
|
94
|
+
defaultMemo;
|
|
95
|
+
steps = [];
|
|
96
|
+
constructor(streamer, account) {
|
|
97
|
+
this.streamer = streamer;
|
|
98
|
+
this.account = account;
|
|
99
|
+
}
|
|
100
|
+
forAccount(account) {
|
|
101
|
+
this.account = account;
|
|
102
|
+
return this;
|
|
103
|
+
}
|
|
104
|
+
allowSymbols(...symbols) {
|
|
105
|
+
this.allowedSymbols = symbols.map((symbol) => symbol.trim()).filter(Boolean);
|
|
106
|
+
return this;
|
|
107
|
+
}
|
|
108
|
+
memo(memo) {
|
|
109
|
+
this.defaultMemo = memo;
|
|
110
|
+
return this;
|
|
111
|
+
}
|
|
112
|
+
dedupeWith(store) {
|
|
113
|
+
this.dedupeStore = store;
|
|
114
|
+
return this;
|
|
115
|
+
}
|
|
116
|
+
ignoreZeroAmount(ignore = true) {
|
|
117
|
+
this.ignoreZeroAmountValue = ignore;
|
|
118
|
+
return this;
|
|
119
|
+
}
|
|
120
|
+
onError(handler) {
|
|
121
|
+
this.errorHandler = handler;
|
|
122
|
+
return this;
|
|
123
|
+
}
|
|
124
|
+
burn(allocation, memo) {
|
|
125
|
+
this.steps.push({
|
|
126
|
+
type: 'burn',
|
|
127
|
+
...normalizeAllocationInput(allocation, 'burn()'),
|
|
128
|
+
memo
|
|
129
|
+
});
|
|
130
|
+
return this;
|
|
131
|
+
}
|
|
132
|
+
burnOnTop(allocation, memo) {
|
|
133
|
+
this.steps.push({
|
|
134
|
+
type: 'burn',
|
|
135
|
+
mode: 'onTop',
|
|
136
|
+
...normalizeAllocationInput(allocation, 'burnOnTop()'),
|
|
137
|
+
memo
|
|
138
|
+
});
|
|
139
|
+
return this;
|
|
140
|
+
}
|
|
141
|
+
forwardTo(to, allocation, memo) {
|
|
142
|
+
if (typeof to !== 'string' || to.trim().length === 0) {
|
|
143
|
+
throw new Error('forwardTo() requires a destination account');
|
|
144
|
+
}
|
|
145
|
+
this.steps.push({
|
|
146
|
+
type: 'transfer',
|
|
147
|
+
to: to.trim(),
|
|
148
|
+
...(allocation === undefined ? {} : normalizeAllocationInput(allocation, 'forwardTo()')),
|
|
149
|
+
memo
|
|
150
|
+
});
|
|
151
|
+
return this;
|
|
152
|
+
}
|
|
153
|
+
forwardOnTop(to, allocation, memo) {
|
|
154
|
+
if (typeof to !== 'string' || to.trim().length === 0) {
|
|
155
|
+
throw new Error('forwardOnTop() requires a destination account');
|
|
156
|
+
}
|
|
157
|
+
this.steps.push({
|
|
158
|
+
type: 'transfer',
|
|
159
|
+
mode: 'onTop',
|
|
160
|
+
to: to.trim(),
|
|
161
|
+
...normalizeAllocationInput(allocation, 'forwardOnTop()'),
|
|
162
|
+
memo
|
|
163
|
+
});
|
|
164
|
+
return this;
|
|
165
|
+
}
|
|
166
|
+
donateOnTop(to, allocation, memo) {
|
|
167
|
+
return this.forwardOnTop(to, allocation, memo);
|
|
168
|
+
}
|
|
169
|
+
forwardGroup(recipients, allocation, options = {}) {
|
|
170
|
+
this.steps.push({
|
|
171
|
+
type: 'transfer',
|
|
172
|
+
group: normalizeGroupRecipients(recipients, 'forwardGroup()'),
|
|
173
|
+
split: options.split,
|
|
174
|
+
...normalizeAllocationInput(allocation, 'forwardGroup()'),
|
|
175
|
+
memo: options.memo
|
|
176
|
+
});
|
|
177
|
+
return this;
|
|
178
|
+
}
|
|
179
|
+
forwardGroupOnTop(recipients, allocation, options = {}) {
|
|
180
|
+
this.steps.push({
|
|
181
|
+
type: 'transfer',
|
|
182
|
+
mode: 'onTop',
|
|
183
|
+
group: normalizeGroupRecipients(recipients, 'forwardGroupOnTop()'),
|
|
184
|
+
split: options.split,
|
|
185
|
+
...normalizeAllocationInput(allocation, 'forwardGroupOnTop()'),
|
|
186
|
+
memo: options.memo
|
|
187
|
+
});
|
|
188
|
+
return this;
|
|
189
|
+
}
|
|
190
|
+
remainderTo(to, memo) {
|
|
191
|
+
return this.forwardTo(to, undefined, memo);
|
|
192
|
+
}
|
|
193
|
+
remainderToGroup(recipients, options = {}) {
|
|
194
|
+
this.steps.push({
|
|
195
|
+
type: 'transfer',
|
|
196
|
+
group: normalizeGroupRecipients(recipients, 'remainderToGroup()'),
|
|
197
|
+
split: options.split,
|
|
198
|
+
memo: options.memo
|
|
199
|
+
});
|
|
200
|
+
return this;
|
|
201
|
+
}
|
|
202
|
+
refund(memo) {
|
|
203
|
+
this.steps.push({
|
|
204
|
+
type: 'refund',
|
|
205
|
+
memo
|
|
206
|
+
});
|
|
207
|
+
return this;
|
|
208
|
+
}
|
|
209
|
+
refundPortion(allocation, memo) {
|
|
210
|
+
this.steps.push({
|
|
211
|
+
type: 'refund',
|
|
212
|
+
...normalizeAllocationInput(allocation, 'refundPortion()'),
|
|
213
|
+
memo
|
|
214
|
+
});
|
|
215
|
+
return this;
|
|
216
|
+
}
|
|
217
|
+
remainderToSender(memo) {
|
|
218
|
+
return this.refund(memo);
|
|
219
|
+
}
|
|
220
|
+
plan(transfer) {
|
|
221
|
+
const commonOptions = {
|
|
222
|
+
routes: this.buildRoutes(),
|
|
223
|
+
allowedSymbols: this.allowedSymbols
|
|
224
|
+
};
|
|
225
|
+
return this.streamer.planIncomingTransferRoutes(transfer, commonOptions);
|
|
226
|
+
}
|
|
227
|
+
start() {
|
|
228
|
+
if (this.steps.length === 0) {
|
|
229
|
+
throw new Error('Add at least one builder step before calling start()');
|
|
230
|
+
}
|
|
231
|
+
const commonOptions = {
|
|
232
|
+
account: this.account,
|
|
233
|
+
allowedSymbols: this.allowedSymbols,
|
|
234
|
+
dedupeStore: this.dedupeStore,
|
|
235
|
+
ignoreZeroAmount: this.ignoreZeroAmountValue,
|
|
236
|
+
onError: this.errorHandler
|
|
237
|
+
};
|
|
238
|
+
if (this.steps.length === 1 && !this.steps[0].group && this.steps[0].mode !== 'onTop') {
|
|
239
|
+
const step = this.steps[0];
|
|
240
|
+
const memo = resolveRouteMemo(step.memo, this.defaultMemo);
|
|
241
|
+
if (step.type === 'burn') {
|
|
242
|
+
return this.streamer.autoBurnIncomingTransfers({
|
|
243
|
+
...commonOptions,
|
|
244
|
+
percentage: step.percentage,
|
|
245
|
+
percent: step.percent,
|
|
246
|
+
basisPoints: step.basisPoints,
|
|
247
|
+
memo
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
if (step.type === 'refund') {
|
|
251
|
+
return this.streamer.autoRefundIncomingTransfers({
|
|
252
|
+
...commonOptions,
|
|
253
|
+
percentage: step.percentage,
|
|
254
|
+
percent: step.percent,
|
|
255
|
+
basisPoints: step.basisPoints,
|
|
256
|
+
memo
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
return this.streamer.autoForwardIncomingTransfers({
|
|
260
|
+
...commonOptions,
|
|
261
|
+
to: step.to,
|
|
262
|
+
percentage: step.percentage,
|
|
263
|
+
percent: step.percent,
|
|
264
|
+
basisPoints: step.basisPoints,
|
|
265
|
+
memo
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
const options = {
|
|
269
|
+
...commonOptions,
|
|
270
|
+
routes: this.buildRoutes()
|
|
271
|
+
};
|
|
272
|
+
return this.streamer.autoRouteIncomingTransfers(options);
|
|
273
|
+
}
|
|
274
|
+
buildRoutes() {
|
|
275
|
+
if (this.steps.length === 0) {
|
|
276
|
+
throw new Error('Add at least one builder step before planning or starting a flow');
|
|
277
|
+
}
|
|
278
|
+
return this.steps.map((step) => {
|
|
279
|
+
const memo = resolveRouteMemo(step.memo, this.defaultMemo);
|
|
280
|
+
if (step.type === 'burn') {
|
|
281
|
+
return {
|
|
282
|
+
type: 'burn',
|
|
283
|
+
mode: step.mode,
|
|
284
|
+
percentage: step.percentage,
|
|
285
|
+
percent: step.percent,
|
|
286
|
+
basisPoints: step.basisPoints,
|
|
287
|
+
memo
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
if (step.type === 'refund') {
|
|
291
|
+
return {
|
|
292
|
+
mode: step.mode,
|
|
293
|
+
to: (event) => event.transfer.from,
|
|
294
|
+
percentage: step.percentage,
|
|
295
|
+
percent: step.percent,
|
|
296
|
+
basisPoints: step.basisPoints,
|
|
297
|
+
memo
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
if (step.group) {
|
|
301
|
+
return {
|
|
302
|
+
mode: step.mode,
|
|
303
|
+
group: step.group,
|
|
304
|
+
split: step.split,
|
|
305
|
+
percentage: step.percentage,
|
|
306
|
+
percent: step.percent,
|
|
307
|
+
basisPoints: step.basisPoints,
|
|
308
|
+
memo
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
return {
|
|
312
|
+
mode: step.mode,
|
|
313
|
+
to: step.to,
|
|
314
|
+
percentage: step.percentage,
|
|
315
|
+
percent: step.percent,
|
|
316
|
+
basisPoints: step.basisPoints,
|
|
317
|
+
memo
|
|
318
|
+
};
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
exports.IncomingTransfersBuilder = IncomingTransfersBuilder;
|
|
323
|
+
class HiveTransferBuilder {
|
|
324
|
+
streamer;
|
|
325
|
+
state = {};
|
|
326
|
+
constructor(streamer) {
|
|
327
|
+
this.streamer = streamer;
|
|
328
|
+
}
|
|
329
|
+
from(account) {
|
|
330
|
+
this.state.from = account;
|
|
331
|
+
return this;
|
|
332
|
+
}
|
|
333
|
+
to(account) {
|
|
334
|
+
this.state.to = account;
|
|
335
|
+
return this;
|
|
336
|
+
}
|
|
337
|
+
amount(amount, symbol) {
|
|
338
|
+
const parsed = parseAssetInput(amount, symbol);
|
|
339
|
+
this.state.amount = parsed.amount;
|
|
340
|
+
this.state.symbol = parsed.symbol;
|
|
341
|
+
return this;
|
|
342
|
+
}
|
|
343
|
+
hive(amount) {
|
|
344
|
+
return this.amount(amount, 'HIVE');
|
|
345
|
+
}
|
|
346
|
+
hbd(amount) {
|
|
347
|
+
return this.amount(amount, 'HBD');
|
|
348
|
+
}
|
|
349
|
+
memo(memo) {
|
|
350
|
+
this.state.memo = memo;
|
|
351
|
+
return this;
|
|
352
|
+
}
|
|
353
|
+
send() {
|
|
354
|
+
if (!this.state.from || !this.state.to || !this.state.amount || !this.state.symbol) {
|
|
355
|
+
throw new Error('transfer() builder requires from, to, and amount before send()');
|
|
356
|
+
}
|
|
357
|
+
return this.streamer.transferHiveTokens(this.state.from, this.state.to, this.state.amount, this.state.symbol, this.state.memo || '');
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
exports.HiveTransferBuilder = HiveTransferBuilder;
|
|
361
|
+
class HiveBurnBuilder {
|
|
362
|
+
streamer;
|
|
363
|
+
state = {};
|
|
364
|
+
constructor(streamer) {
|
|
365
|
+
this.streamer = streamer;
|
|
366
|
+
}
|
|
367
|
+
from(account) {
|
|
368
|
+
this.state.from = account;
|
|
369
|
+
return this;
|
|
370
|
+
}
|
|
371
|
+
amount(amount, symbol) {
|
|
372
|
+
const parsed = parseAssetInput(amount, symbol);
|
|
373
|
+
this.state.amount = parsed.amount;
|
|
374
|
+
this.state.symbol = parsed.symbol;
|
|
375
|
+
return this;
|
|
376
|
+
}
|
|
377
|
+
hive(amount) {
|
|
378
|
+
return this.amount(amount, 'HIVE');
|
|
379
|
+
}
|
|
380
|
+
hbd(amount) {
|
|
381
|
+
return this.amount(amount, 'HBD');
|
|
382
|
+
}
|
|
383
|
+
memo(memo) {
|
|
384
|
+
this.state.memo = memo;
|
|
385
|
+
return this;
|
|
386
|
+
}
|
|
387
|
+
send() {
|
|
388
|
+
if (!this.state.from || !this.state.amount || !this.state.symbol) {
|
|
389
|
+
throw new Error('burn() builder requires from and amount before send()');
|
|
390
|
+
}
|
|
391
|
+
return this.streamer.burnHiveTokens(this.state.from, this.state.amount, this.state.symbol, this.state.memo || '');
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
exports.HiveBurnBuilder = HiveBurnBuilder;
|
|
395
|
+
class HiveEscrowTransferBuilder {
|
|
396
|
+
streamer;
|
|
397
|
+
state = {};
|
|
398
|
+
constructor(streamer) {
|
|
399
|
+
this.streamer = streamer;
|
|
400
|
+
}
|
|
401
|
+
from(account) {
|
|
402
|
+
this.state.from = account;
|
|
403
|
+
return this;
|
|
404
|
+
}
|
|
405
|
+
to(account) {
|
|
406
|
+
this.state.to = account;
|
|
407
|
+
return this;
|
|
408
|
+
}
|
|
409
|
+
agent(account) {
|
|
410
|
+
this.state.agent = account;
|
|
411
|
+
return this;
|
|
412
|
+
}
|
|
413
|
+
id(escrowId) {
|
|
414
|
+
this.state.escrow_id = escrowId;
|
|
415
|
+
return this;
|
|
416
|
+
}
|
|
417
|
+
hive(amount) {
|
|
418
|
+
this.state.hive_amount = buildAssetAmount(amount, 'HIVE');
|
|
419
|
+
return this;
|
|
420
|
+
}
|
|
421
|
+
hbd(amount) {
|
|
422
|
+
this.state.hbd_amount = buildAssetAmount(amount, 'HBD');
|
|
423
|
+
return this;
|
|
424
|
+
}
|
|
425
|
+
fee(amount, symbol) {
|
|
426
|
+
this.state.fee = buildAssetAmount(amount, symbol);
|
|
427
|
+
return this;
|
|
428
|
+
}
|
|
429
|
+
ratificationDeadline(value) {
|
|
430
|
+
this.state.ratification_deadline = value;
|
|
431
|
+
return this;
|
|
432
|
+
}
|
|
433
|
+
expiration(value) {
|
|
434
|
+
this.state.escrow_expiration = value;
|
|
435
|
+
return this;
|
|
436
|
+
}
|
|
437
|
+
jsonMeta(meta) {
|
|
438
|
+
this.state.json_meta = meta;
|
|
439
|
+
return this;
|
|
440
|
+
}
|
|
441
|
+
send(signingKeys) {
|
|
442
|
+
return this.streamer.escrowTransfer({
|
|
443
|
+
from: this.state.from,
|
|
444
|
+
to: this.state.to,
|
|
445
|
+
agent: this.state.agent,
|
|
446
|
+
escrow_id: this.state.escrow_id,
|
|
447
|
+
hive_amount: this.state.hive_amount,
|
|
448
|
+
hbd_amount: this.state.hbd_amount,
|
|
449
|
+
fee: this.state.fee,
|
|
450
|
+
ratification_deadline: this.state.ratification_deadline,
|
|
451
|
+
escrow_expiration: this.state.escrow_expiration,
|
|
452
|
+
json_meta: this.state.json_meta
|
|
453
|
+
}, signingKeys);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
exports.HiveEscrowTransferBuilder = HiveEscrowTransferBuilder;
|
|
457
|
+
class HiveRecurrentTransferBuilder {
|
|
458
|
+
streamer;
|
|
459
|
+
state = {};
|
|
460
|
+
constructor(streamer) {
|
|
461
|
+
this.streamer = streamer;
|
|
462
|
+
}
|
|
463
|
+
from(account) {
|
|
464
|
+
this.state.from = account;
|
|
465
|
+
return this;
|
|
466
|
+
}
|
|
467
|
+
to(account) {
|
|
468
|
+
this.state.to = account;
|
|
469
|
+
return this;
|
|
470
|
+
}
|
|
471
|
+
amount(amount, symbol) {
|
|
472
|
+
this.state.amount = buildAssetAmount(amount, symbol);
|
|
473
|
+
return this;
|
|
474
|
+
}
|
|
475
|
+
hive(amount) {
|
|
476
|
+
return this.amount(amount, 'HIVE');
|
|
477
|
+
}
|
|
478
|
+
hbd(amount) {
|
|
479
|
+
return this.amount(amount, 'HBD');
|
|
480
|
+
}
|
|
481
|
+
memo(memo) {
|
|
482
|
+
this.state.memo = memo;
|
|
483
|
+
return this;
|
|
484
|
+
}
|
|
485
|
+
recurrence(value) {
|
|
486
|
+
this.state.recurrence = value;
|
|
487
|
+
return this;
|
|
488
|
+
}
|
|
489
|
+
executions(value) {
|
|
490
|
+
this.state.executions = value;
|
|
491
|
+
return this;
|
|
492
|
+
}
|
|
493
|
+
send(signingKeys) {
|
|
494
|
+
return this.streamer.recurrentTransfer({
|
|
495
|
+
from: this.state.from,
|
|
496
|
+
to: this.state.to,
|
|
497
|
+
amount: this.state.amount,
|
|
498
|
+
memo: this.state.memo,
|
|
499
|
+
recurrence: this.state.recurrence,
|
|
500
|
+
executions: this.state.executions
|
|
501
|
+
}, signingKeys);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
exports.HiveRecurrentTransferBuilder = HiveRecurrentTransferBuilder;
|
|
505
|
+
class HiveProposalBuilder {
|
|
506
|
+
streamer;
|
|
507
|
+
state = {};
|
|
508
|
+
constructor(streamer) {
|
|
509
|
+
this.streamer = streamer;
|
|
510
|
+
}
|
|
511
|
+
creator(account) {
|
|
512
|
+
this.state.creator = account;
|
|
513
|
+
return this;
|
|
514
|
+
}
|
|
515
|
+
receiver(account) {
|
|
516
|
+
this.state.receiver = account;
|
|
517
|
+
return this;
|
|
518
|
+
}
|
|
519
|
+
startDate(value) {
|
|
520
|
+
this.state.start_date = value;
|
|
521
|
+
return this;
|
|
522
|
+
}
|
|
523
|
+
endDate(value) {
|
|
524
|
+
this.state.end_date = value;
|
|
525
|
+
return this;
|
|
526
|
+
}
|
|
527
|
+
dailyPay(amount, symbol) {
|
|
528
|
+
this.state.daily_pay = buildAssetAmount(amount, symbol);
|
|
529
|
+
return this;
|
|
530
|
+
}
|
|
531
|
+
dailyHive(amount) {
|
|
532
|
+
return this.dailyPay(amount, 'HIVE');
|
|
533
|
+
}
|
|
534
|
+
dailyHbd(amount) {
|
|
535
|
+
return this.dailyPay(amount, 'HBD');
|
|
536
|
+
}
|
|
537
|
+
subject(value) {
|
|
538
|
+
this.state.subject = value;
|
|
539
|
+
return this;
|
|
540
|
+
}
|
|
541
|
+
permlink(value) {
|
|
542
|
+
this.state.permlink = value;
|
|
543
|
+
return this;
|
|
544
|
+
}
|
|
545
|
+
send(signingKeys) {
|
|
546
|
+
return this.streamer.createProposal({
|
|
547
|
+
creator: this.state.creator,
|
|
548
|
+
receiver: this.state.receiver,
|
|
549
|
+
start_date: this.state.start_date,
|
|
550
|
+
end_date: this.state.end_date,
|
|
551
|
+
daily_pay: this.state.daily_pay,
|
|
552
|
+
subject: this.state.subject,
|
|
553
|
+
permlink: this.state.permlink
|
|
554
|
+
}, signingKeys);
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
exports.HiveProposalBuilder = HiveProposalBuilder;
|
|
558
|
+
class HiveEngineTokenTransferBuilder {
|
|
559
|
+
streamer;
|
|
560
|
+
state = {};
|
|
561
|
+
constructor(streamer) {
|
|
562
|
+
this.streamer = streamer;
|
|
563
|
+
}
|
|
564
|
+
from(account) {
|
|
565
|
+
this.state.from = account;
|
|
566
|
+
return this;
|
|
567
|
+
}
|
|
568
|
+
to(account) {
|
|
569
|
+
this.state.to = account;
|
|
570
|
+
return this;
|
|
571
|
+
}
|
|
572
|
+
symbol(symbol) {
|
|
573
|
+
this.state.symbol = symbol.trim();
|
|
574
|
+
return this;
|
|
575
|
+
}
|
|
576
|
+
quantity(quantity) {
|
|
577
|
+
this.state.quantity = normalizeEngineQuantity(quantity);
|
|
578
|
+
return this;
|
|
579
|
+
}
|
|
580
|
+
memo(memo) {
|
|
581
|
+
this.state.memo = memo;
|
|
582
|
+
return this;
|
|
583
|
+
}
|
|
584
|
+
send() {
|
|
585
|
+
return this.streamer.transferHiveEngineTokens(this.state.from, this.state.to, this.state.symbol, this.state.quantity, this.state.memo || '');
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
exports.HiveEngineTokenTransferBuilder = HiveEngineTokenTransferBuilder;
|
|
589
|
+
class HiveEngineTokenBurnBuilder {
|
|
590
|
+
streamer;
|
|
591
|
+
state = {};
|
|
592
|
+
constructor(streamer) {
|
|
593
|
+
this.streamer = streamer;
|
|
594
|
+
}
|
|
595
|
+
from(account) {
|
|
596
|
+
this.state.from = account;
|
|
597
|
+
return this;
|
|
598
|
+
}
|
|
599
|
+
symbol(symbol) {
|
|
600
|
+
this.state.symbol = symbol.trim();
|
|
601
|
+
return this;
|
|
602
|
+
}
|
|
603
|
+
quantity(quantity) {
|
|
604
|
+
this.state.quantity = normalizeEngineQuantity(quantity);
|
|
605
|
+
return this;
|
|
606
|
+
}
|
|
607
|
+
memo(memo) {
|
|
608
|
+
this.state.memo = memo;
|
|
609
|
+
return this;
|
|
610
|
+
}
|
|
611
|
+
send() {
|
|
612
|
+
return this.streamer.burnHiveEngineTokens(this.state.from, this.state.symbol, this.state.quantity, this.state.memo || '');
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
exports.HiveEngineTokenBurnBuilder = HiveEngineTokenBurnBuilder;
|
|
616
|
+
class HiveEngineTokenIssueBuilder {
|
|
617
|
+
streamer;
|
|
618
|
+
state = {};
|
|
619
|
+
constructor(streamer) {
|
|
620
|
+
this.streamer = streamer;
|
|
621
|
+
}
|
|
622
|
+
from(account) {
|
|
623
|
+
this.state.from = account;
|
|
624
|
+
return this;
|
|
625
|
+
}
|
|
626
|
+
to(account) {
|
|
627
|
+
this.state.to = account;
|
|
628
|
+
return this;
|
|
629
|
+
}
|
|
630
|
+
symbol(symbol) {
|
|
631
|
+
this.state.symbol = symbol.trim();
|
|
632
|
+
return this;
|
|
633
|
+
}
|
|
634
|
+
quantity(quantity) {
|
|
635
|
+
this.state.quantity = normalizeEngineQuantity(quantity);
|
|
636
|
+
return this;
|
|
637
|
+
}
|
|
638
|
+
memo(memo) {
|
|
639
|
+
this.state.memo = memo;
|
|
640
|
+
return this;
|
|
641
|
+
}
|
|
642
|
+
send() {
|
|
643
|
+
return this.streamer.issueHiveEngineTokens(this.state.from, this.state.to, this.state.symbol, this.state.quantity, this.state.memo || '');
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
exports.HiveEngineTokenIssueBuilder = HiveEngineTokenIssueBuilder;
|
|
647
|
+
class HiveProposalVotesBuilder {
|
|
648
|
+
streamer;
|
|
649
|
+
state = {};
|
|
650
|
+
constructor(streamer) {
|
|
651
|
+
this.streamer = streamer;
|
|
652
|
+
}
|
|
653
|
+
voter(account) {
|
|
654
|
+
this.state.voter = account;
|
|
655
|
+
return this;
|
|
656
|
+
}
|
|
657
|
+
ids(...proposalIds) {
|
|
658
|
+
this.state.proposal_ids = proposalIds;
|
|
659
|
+
return this;
|
|
660
|
+
}
|
|
661
|
+
approve(value = true) {
|
|
662
|
+
this.state.approve = value;
|
|
663
|
+
return this;
|
|
664
|
+
}
|
|
665
|
+
reject() {
|
|
666
|
+
return this.approve(false);
|
|
667
|
+
}
|
|
668
|
+
send(signingKeys) {
|
|
669
|
+
return this.streamer.updateProposalVotes({
|
|
670
|
+
voter: this.state.voter,
|
|
671
|
+
proposal_ids: this.state.proposal_ids,
|
|
672
|
+
approve: this.state.approve
|
|
673
|
+
}, signingKeys);
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
exports.HiveProposalVotesBuilder = HiveProposalVotesBuilder;
|
|
677
|
+
class HiveRemoveProposalsBuilder {
|
|
678
|
+
streamer;
|
|
679
|
+
state = {};
|
|
680
|
+
constructor(streamer) {
|
|
681
|
+
this.streamer = streamer;
|
|
682
|
+
}
|
|
683
|
+
owner(account) {
|
|
684
|
+
this.state.proposal_owner = account;
|
|
685
|
+
return this;
|
|
686
|
+
}
|
|
687
|
+
ids(...proposalIds) {
|
|
688
|
+
this.state.proposal_ids = proposalIds;
|
|
689
|
+
return this;
|
|
690
|
+
}
|
|
691
|
+
send(signingKeys) {
|
|
692
|
+
return this.streamer.removeProposals({
|
|
693
|
+
proposal_owner: this.state.proposal_owner,
|
|
694
|
+
proposal_ids: this.state.proposal_ids
|
|
695
|
+
}, signingKeys);
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
exports.HiveRemoveProposalsBuilder = HiveRemoveProposalsBuilder;
|
|
699
|
+
class HiveVoteBuilder {
|
|
700
|
+
streamer;
|
|
701
|
+
direction;
|
|
702
|
+
state = {};
|
|
703
|
+
constructor(streamer, direction) {
|
|
704
|
+
this.streamer = streamer;
|
|
705
|
+
this.direction = direction;
|
|
706
|
+
}
|
|
707
|
+
author(account) {
|
|
708
|
+
this.state.username = account;
|
|
709
|
+
return this;
|
|
710
|
+
}
|
|
711
|
+
permlink(value) {
|
|
712
|
+
this.state.permlink = value;
|
|
713
|
+
return this;
|
|
714
|
+
}
|
|
715
|
+
weight(value) {
|
|
716
|
+
this.state.weight = String(value);
|
|
717
|
+
return this;
|
|
718
|
+
}
|
|
719
|
+
send() {
|
|
720
|
+
if (this.direction === 'upvote') {
|
|
721
|
+
return this.streamer.upvote(this.state.weight || '100.0', this.state.username, this.state.permlink);
|
|
722
|
+
}
|
|
723
|
+
return this.streamer.downvote(this.state.weight || '100.0', this.state.username, this.state.permlink);
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
exports.HiveVoteBuilder = HiveVoteBuilder;
|
|
727
|
+
class HiveFollowBuilder {
|
|
728
|
+
streamer;
|
|
729
|
+
mode;
|
|
730
|
+
state = {};
|
|
731
|
+
constructor(streamer, mode) {
|
|
732
|
+
this.streamer = streamer;
|
|
733
|
+
this.mode = mode;
|
|
734
|
+
}
|
|
735
|
+
follower(account) {
|
|
736
|
+
this.state.follower = account;
|
|
737
|
+
return this;
|
|
738
|
+
}
|
|
739
|
+
following(account) {
|
|
740
|
+
this.state.following = account;
|
|
741
|
+
return this;
|
|
742
|
+
}
|
|
743
|
+
send() {
|
|
744
|
+
if (!this.state.follower || !this.state.following) {
|
|
745
|
+
throw new Error(`${this.mode}() builder requires follower and following before send()`);
|
|
746
|
+
}
|
|
747
|
+
if (this.mode === 'follow') {
|
|
748
|
+
return this.streamer.follow(this.state.follower, this.state.following);
|
|
749
|
+
}
|
|
750
|
+
if (this.mode === 'mute') {
|
|
751
|
+
return this.streamer.mute(this.state.follower, this.state.following);
|
|
752
|
+
}
|
|
753
|
+
return this.streamer.unfollow(this.state.follower, this.state.following);
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
exports.HiveFollowBuilder = HiveFollowBuilder;
|
|
757
|
+
class HiveReblogBuilder {
|
|
758
|
+
streamer;
|
|
759
|
+
state = {};
|
|
760
|
+
constructor(streamer) {
|
|
761
|
+
this.streamer = streamer;
|
|
762
|
+
}
|
|
763
|
+
account(account) {
|
|
764
|
+
this.state.account = account;
|
|
765
|
+
return this;
|
|
766
|
+
}
|
|
767
|
+
author(account) {
|
|
768
|
+
this.state.author = account;
|
|
769
|
+
return this;
|
|
770
|
+
}
|
|
771
|
+
permlink(value) {
|
|
772
|
+
this.state.permlink = value;
|
|
773
|
+
return this;
|
|
774
|
+
}
|
|
775
|
+
send() {
|
|
776
|
+
if (!this.state.account || !this.state.author || !this.state.permlink) {
|
|
777
|
+
throw new Error('reblog() builder requires account, author, and permlink before send()');
|
|
778
|
+
}
|
|
779
|
+
return this.streamer.reblog(this.state.account, this.state.author, this.state.permlink);
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
exports.HiveReblogBuilder = HiveReblogBuilder;
|
|
783
|
+
class HivePowerUpBuilder {
|
|
784
|
+
streamer;
|
|
785
|
+
state = {};
|
|
786
|
+
constructor(streamer) {
|
|
787
|
+
this.streamer = streamer;
|
|
788
|
+
}
|
|
789
|
+
from(account) {
|
|
790
|
+
this.state.from = account;
|
|
791
|
+
return this;
|
|
792
|
+
}
|
|
793
|
+
to(account) {
|
|
794
|
+
this.state.to = account;
|
|
795
|
+
return this;
|
|
796
|
+
}
|
|
797
|
+
amount(amount) {
|
|
798
|
+
this.state.amount = utils_1.Utils.formatAmount(amount);
|
|
799
|
+
return this;
|
|
800
|
+
}
|
|
801
|
+
send() {
|
|
802
|
+
if (!this.state.from || !this.state.amount) {
|
|
803
|
+
throw new Error('powerUp() builder requires from and amount before send()');
|
|
804
|
+
}
|
|
805
|
+
return this.streamer.powerUp(this.state.from, this.state.to || this.state.from, this.state.amount);
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
exports.HivePowerUpBuilder = HivePowerUpBuilder;
|
|
809
|
+
class HivePowerDownBuilder {
|
|
810
|
+
streamer;
|
|
811
|
+
cancel;
|
|
812
|
+
state = {};
|
|
813
|
+
constructor(streamer, cancel = false) {
|
|
814
|
+
this.streamer = streamer;
|
|
815
|
+
this.cancel = cancel;
|
|
816
|
+
}
|
|
817
|
+
account(account) {
|
|
818
|
+
this.state.account = account;
|
|
819
|
+
return this;
|
|
820
|
+
}
|
|
821
|
+
vestingShares(amount) {
|
|
822
|
+
this.state.vestingShares = amount;
|
|
823
|
+
return this;
|
|
824
|
+
}
|
|
825
|
+
send() {
|
|
826
|
+
if (!this.state.account) {
|
|
827
|
+
throw new Error('powerDown() builder requires account before send()');
|
|
828
|
+
}
|
|
829
|
+
if (this.cancel) {
|
|
830
|
+
return this.streamer.cancelPowerDown(this.state.account);
|
|
831
|
+
}
|
|
832
|
+
if (!this.state.vestingShares) {
|
|
833
|
+
throw new Error('powerDown() builder requires vestingShares before send()');
|
|
834
|
+
}
|
|
835
|
+
return this.streamer.powerDown(this.state.account, this.state.vestingShares);
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
exports.HivePowerDownBuilder = HivePowerDownBuilder;
|
|
839
|
+
class HiveDelegateBuilder {
|
|
840
|
+
streamer;
|
|
841
|
+
undelegate;
|
|
842
|
+
state = {};
|
|
843
|
+
constructor(streamer, undelegate = false) {
|
|
844
|
+
this.streamer = streamer;
|
|
845
|
+
this.undelegate = undelegate;
|
|
846
|
+
}
|
|
847
|
+
delegator(account) {
|
|
848
|
+
this.state.delegator = account;
|
|
849
|
+
return this;
|
|
850
|
+
}
|
|
851
|
+
delegatee(account) {
|
|
852
|
+
this.state.delegatee = account;
|
|
853
|
+
return this;
|
|
854
|
+
}
|
|
855
|
+
vestingShares(amount) {
|
|
856
|
+
this.state.vestingShares = amount;
|
|
857
|
+
return this;
|
|
858
|
+
}
|
|
859
|
+
send() {
|
|
860
|
+
if (!this.state.delegator || !this.state.delegatee) {
|
|
861
|
+
throw new Error('delegate() builder requires delegator and delegatee before send()');
|
|
862
|
+
}
|
|
863
|
+
if (this.undelegate) {
|
|
864
|
+
return this.streamer.undelegateVestingShares(this.state.delegator, this.state.delegatee);
|
|
865
|
+
}
|
|
866
|
+
if (!this.state.vestingShares) {
|
|
867
|
+
throw new Error('delegate() builder requires vestingShares before send()');
|
|
868
|
+
}
|
|
869
|
+
return this.streamer.delegateVestingShares(this.state.delegator, this.state.delegatee, this.state.vestingShares);
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
exports.HiveDelegateBuilder = HiveDelegateBuilder;
|
|
873
|
+
class HiveClaimRewardsBuilder {
|
|
874
|
+
streamer;
|
|
875
|
+
state = {};
|
|
876
|
+
constructor(streamer) {
|
|
877
|
+
this.streamer = streamer;
|
|
878
|
+
}
|
|
879
|
+
account(account) {
|
|
880
|
+
this.state.account = account;
|
|
881
|
+
return this;
|
|
882
|
+
}
|
|
883
|
+
rewardHive(amount) {
|
|
884
|
+
this.state.rewardHive = amount;
|
|
885
|
+
return this;
|
|
886
|
+
}
|
|
887
|
+
rewardHbd(amount) {
|
|
888
|
+
this.state.rewardHbd = amount;
|
|
889
|
+
return this;
|
|
890
|
+
}
|
|
891
|
+
rewardVests(amount) {
|
|
892
|
+
this.state.rewardVests = amount;
|
|
893
|
+
return this;
|
|
894
|
+
}
|
|
895
|
+
send() {
|
|
896
|
+
if (!this.state.account) {
|
|
897
|
+
throw new Error('claimRewards() builder requires account before send()');
|
|
898
|
+
}
|
|
899
|
+
return this.streamer.claimRewards(this.state.account, this.state.rewardHive || '0.000 HIVE', this.state.rewardHbd || '0.000 HBD', this.state.rewardVests || '0.000000 VESTS');
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
exports.HiveClaimRewardsBuilder = HiveClaimRewardsBuilder;
|
|
903
|
+
class HiveWitnessVoteBuilder {
|
|
904
|
+
streamer;
|
|
905
|
+
state = {};
|
|
906
|
+
constructor(streamer) {
|
|
907
|
+
this.streamer = streamer;
|
|
908
|
+
}
|
|
909
|
+
account(account) {
|
|
910
|
+
this.state.account = account;
|
|
911
|
+
return this;
|
|
912
|
+
}
|
|
913
|
+
witness(account) {
|
|
914
|
+
this.state.witness = account;
|
|
915
|
+
return this;
|
|
916
|
+
}
|
|
917
|
+
approve(value = true) {
|
|
918
|
+
this.state.approve = value;
|
|
919
|
+
return this;
|
|
920
|
+
}
|
|
921
|
+
unapprove() {
|
|
922
|
+
return this.approve(false);
|
|
923
|
+
}
|
|
924
|
+
send() {
|
|
925
|
+
if (!this.state.account || !this.state.witness) {
|
|
926
|
+
throw new Error('witnessVote() builder requires account and witness before send()');
|
|
927
|
+
}
|
|
928
|
+
return this.streamer.witnessVote(this.state.account, this.state.witness, this.state.approve !== false);
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
exports.HiveWitnessVoteBuilder = HiveWitnessVoteBuilder;
|
|
932
|
+
class HiveSetProxyBuilder {
|
|
933
|
+
streamer;
|
|
934
|
+
clear;
|
|
935
|
+
state = {};
|
|
936
|
+
constructor(streamer, clear = false) {
|
|
937
|
+
this.streamer = streamer;
|
|
938
|
+
this.clear = clear;
|
|
939
|
+
}
|
|
940
|
+
account(account) {
|
|
941
|
+
this.state.account = account;
|
|
942
|
+
return this;
|
|
943
|
+
}
|
|
944
|
+
proxy(account) {
|
|
945
|
+
this.state.proxy = account;
|
|
946
|
+
return this;
|
|
947
|
+
}
|
|
948
|
+
send() {
|
|
949
|
+
if (!this.state.account) {
|
|
950
|
+
throw new Error('setProxy() builder requires account before send()');
|
|
951
|
+
}
|
|
952
|
+
if (this.clear) {
|
|
953
|
+
return this.streamer.clearProxy(this.state.account);
|
|
954
|
+
}
|
|
955
|
+
if (!this.state.proxy) {
|
|
956
|
+
throw new Error('setProxy() builder requires proxy before send()');
|
|
957
|
+
}
|
|
958
|
+
return this.streamer.setProxy(this.state.account, this.state.proxy);
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
exports.HiveSetProxyBuilder = HiveSetProxyBuilder;
|
|
962
|
+
class HiveUpdateProfileBuilder {
|
|
963
|
+
streamer;
|
|
964
|
+
state = { profile: {} };
|
|
965
|
+
constructor(streamer) {
|
|
966
|
+
this.streamer = streamer;
|
|
967
|
+
}
|
|
968
|
+
account(account) {
|
|
969
|
+
this.state.account = account;
|
|
970
|
+
return this;
|
|
971
|
+
}
|
|
972
|
+
name(value) {
|
|
973
|
+
this.state.profile.name = value;
|
|
974
|
+
return this;
|
|
975
|
+
}
|
|
976
|
+
about(value) {
|
|
977
|
+
this.state.profile.about = value;
|
|
978
|
+
return this;
|
|
979
|
+
}
|
|
980
|
+
location(value) {
|
|
981
|
+
this.state.profile.location = value;
|
|
982
|
+
return this;
|
|
983
|
+
}
|
|
984
|
+
website(value) {
|
|
985
|
+
this.state.profile.website = value;
|
|
986
|
+
return this;
|
|
987
|
+
}
|
|
988
|
+
profileImage(url) {
|
|
989
|
+
this.state.profile.profile_image = url;
|
|
990
|
+
return this;
|
|
991
|
+
}
|
|
992
|
+
coverImage(url) {
|
|
993
|
+
this.state.profile.cover_image = url;
|
|
994
|
+
return this;
|
|
995
|
+
}
|
|
996
|
+
set(key, value) {
|
|
997
|
+
this.state.profile[key] = value;
|
|
998
|
+
return this;
|
|
999
|
+
}
|
|
1000
|
+
send() {
|
|
1001
|
+
if (!this.state.account) {
|
|
1002
|
+
throw new Error('updateProfile() builder requires account before send()');
|
|
1003
|
+
}
|
|
1004
|
+
if (Object.keys(this.state.profile).length === 0) {
|
|
1005
|
+
throw new Error('updateProfile() builder requires at least one profile field before send()');
|
|
1006
|
+
}
|
|
1007
|
+
return this.streamer.updateProfile(this.state.account, this.state.profile);
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
exports.HiveUpdateProfileBuilder = HiveUpdateProfileBuilder;
|
|
1011
|
+
class HiveSavingsTransferBuilder {
|
|
1012
|
+
streamer;
|
|
1013
|
+
direction;
|
|
1014
|
+
state = {};
|
|
1015
|
+
constructor(streamer, direction) {
|
|
1016
|
+
this.streamer = streamer;
|
|
1017
|
+
this.direction = direction;
|
|
1018
|
+
}
|
|
1019
|
+
from(account) {
|
|
1020
|
+
this.state.from = account;
|
|
1021
|
+
return this;
|
|
1022
|
+
}
|
|
1023
|
+
to(account) {
|
|
1024
|
+
this.state.to = account;
|
|
1025
|
+
return this;
|
|
1026
|
+
}
|
|
1027
|
+
amount(amount, symbol) {
|
|
1028
|
+
const parsed = parseAssetInput(amount, symbol);
|
|
1029
|
+
this.state.amount = parsed.amount;
|
|
1030
|
+
this.state.symbol = parsed.symbol;
|
|
1031
|
+
return this;
|
|
1032
|
+
}
|
|
1033
|
+
hive(amount) {
|
|
1034
|
+
return this.amount(amount, 'HIVE');
|
|
1035
|
+
}
|
|
1036
|
+
hbd(amount) {
|
|
1037
|
+
return this.amount(amount, 'HBD');
|
|
1038
|
+
}
|
|
1039
|
+
memo(memo) {
|
|
1040
|
+
this.state.memo = memo;
|
|
1041
|
+
return this;
|
|
1042
|
+
}
|
|
1043
|
+
requestId(id) {
|
|
1044
|
+
this.state.requestId = id;
|
|
1045
|
+
return this;
|
|
1046
|
+
}
|
|
1047
|
+
send() {
|
|
1048
|
+
if (!this.state.from || !this.state.amount || !this.state.symbol) {
|
|
1049
|
+
throw new Error(`${this.direction === 'to' ? 'transferToSavings' : 'transferFromSavings'}() builder requires from and amount before send()`);
|
|
1050
|
+
}
|
|
1051
|
+
const to = this.state.to || this.state.from;
|
|
1052
|
+
if (this.direction === 'to') {
|
|
1053
|
+
return this.streamer.transferToSavings(this.state.from, to, this.state.amount, this.state.symbol, this.state.memo || '');
|
|
1054
|
+
}
|
|
1055
|
+
return this.streamer.transferFromSavings(this.state.from, to, this.state.amount, this.state.symbol, this.state.requestId || 0, this.state.memo || '');
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
exports.HiveSavingsTransferBuilder = HiveSavingsTransferBuilder;
|
|
1059
|
+
class HiveConvertBuilder {
|
|
1060
|
+
streamer;
|
|
1061
|
+
state = {};
|
|
1062
|
+
constructor(streamer) {
|
|
1063
|
+
this.streamer = streamer;
|
|
1064
|
+
}
|
|
1065
|
+
from(account) {
|
|
1066
|
+
this.state.from = account;
|
|
1067
|
+
return this;
|
|
1068
|
+
}
|
|
1069
|
+
amount(amount, symbol) {
|
|
1070
|
+
this.state.amount = buildAssetAmount(amount, symbol || 'HBD');
|
|
1071
|
+
return this;
|
|
1072
|
+
}
|
|
1073
|
+
hbd(amount) {
|
|
1074
|
+
return this.amount(amount, 'HBD');
|
|
1075
|
+
}
|
|
1076
|
+
requestId(id) {
|
|
1077
|
+
this.state.requestId = id;
|
|
1078
|
+
return this;
|
|
1079
|
+
}
|
|
1080
|
+
send() {
|
|
1081
|
+
if (!this.state.from || !this.state.amount) {
|
|
1082
|
+
throw new Error('convert() builder requires from and amount before send()');
|
|
1083
|
+
}
|
|
1084
|
+
return this.streamer.convert(this.state.from, this.state.amount, this.state.requestId || 0);
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
exports.HiveConvertBuilder = HiveConvertBuilder;
|
|
1088
|
+
class HiveCollateralizedConvertBuilder {
|
|
1089
|
+
streamer;
|
|
1090
|
+
state = {};
|
|
1091
|
+
constructor(streamer) {
|
|
1092
|
+
this.streamer = streamer;
|
|
1093
|
+
}
|
|
1094
|
+
from(account) {
|
|
1095
|
+
this.state.from = account;
|
|
1096
|
+
return this;
|
|
1097
|
+
}
|
|
1098
|
+
amount(amount, symbol) {
|
|
1099
|
+
this.state.amount = buildAssetAmount(amount, symbol || 'HIVE');
|
|
1100
|
+
return this;
|
|
1101
|
+
}
|
|
1102
|
+
hive(amount) {
|
|
1103
|
+
return this.amount(amount, 'HIVE');
|
|
1104
|
+
}
|
|
1105
|
+
requestId(id) {
|
|
1106
|
+
this.state.requestId = id;
|
|
1107
|
+
return this;
|
|
1108
|
+
}
|
|
1109
|
+
send() {
|
|
1110
|
+
if (!this.state.from || !this.state.amount) {
|
|
1111
|
+
throw new Error('collateralizedConvert() builder requires from and amount before send()');
|
|
1112
|
+
}
|
|
1113
|
+
return this.streamer.collateralizedConvert(this.state.from, this.state.amount, this.state.requestId || 0);
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
exports.HiveCollateralizedConvertBuilder = HiveCollateralizedConvertBuilder;
|
|
1117
|
+
class HiveDeleteCommentBuilder {
|
|
1118
|
+
streamer;
|
|
1119
|
+
state = {};
|
|
1120
|
+
constructor(streamer) {
|
|
1121
|
+
this.streamer = streamer;
|
|
1122
|
+
}
|
|
1123
|
+
author(account) {
|
|
1124
|
+
this.state.author = account;
|
|
1125
|
+
return this;
|
|
1126
|
+
}
|
|
1127
|
+
permlink(value) {
|
|
1128
|
+
this.state.permlink = value;
|
|
1129
|
+
return this;
|
|
1130
|
+
}
|
|
1131
|
+
send() {
|
|
1132
|
+
if (!this.state.author || !this.state.permlink) {
|
|
1133
|
+
throw new Error('deleteComment() builder requires author and permlink before send()');
|
|
1134
|
+
}
|
|
1135
|
+
return this.streamer.deleteComment(this.state.author, this.state.permlink);
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
exports.HiveDeleteCommentBuilder = HiveDeleteCommentBuilder;
|
|
1139
|
+
class HiveLimitOrderBuilder {
|
|
1140
|
+
streamer;
|
|
1141
|
+
state = {};
|
|
1142
|
+
constructor(streamer) {
|
|
1143
|
+
this.streamer = streamer;
|
|
1144
|
+
}
|
|
1145
|
+
owner(account) {
|
|
1146
|
+
this.state.owner = account;
|
|
1147
|
+
return this;
|
|
1148
|
+
}
|
|
1149
|
+
orderId(id) {
|
|
1150
|
+
this.state.orderId = id;
|
|
1151
|
+
return this;
|
|
1152
|
+
}
|
|
1153
|
+
amountToSell(amount, symbol) {
|
|
1154
|
+
this.state.amountToSell = buildAssetAmount(amount, symbol);
|
|
1155
|
+
return this;
|
|
1156
|
+
}
|
|
1157
|
+
minToReceive(amount, symbol) {
|
|
1158
|
+
this.state.minToReceive = buildAssetAmount(amount, symbol);
|
|
1159
|
+
return this;
|
|
1160
|
+
}
|
|
1161
|
+
fillOrKill(value = true) {
|
|
1162
|
+
this.state.fillOrKill = value;
|
|
1163
|
+
return this;
|
|
1164
|
+
}
|
|
1165
|
+
expiration(value) {
|
|
1166
|
+
this.state.expiration = value;
|
|
1167
|
+
return this;
|
|
1168
|
+
}
|
|
1169
|
+
send(signingKeys) {
|
|
1170
|
+
if (!this.state.owner || !this.state.amountToSell || !this.state.minToReceive) {
|
|
1171
|
+
throw new Error('limitOrder() builder requires owner, amountToSell, and minToReceive before send()');
|
|
1172
|
+
}
|
|
1173
|
+
return this.streamer.limitOrderCreate(this.state.owner, this.state.orderId || Math.floor(Date.now() / 1000), this.state.amountToSell, this.state.minToReceive, this.state.fillOrKill || false, this.state.expiration, signingKeys);
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
exports.HiveLimitOrderBuilder = HiveLimitOrderBuilder;
|
|
1177
|
+
class HiveCancelOrderBuilder {
|
|
1178
|
+
streamer;
|
|
1179
|
+
state = {};
|
|
1180
|
+
constructor(streamer) {
|
|
1181
|
+
this.streamer = streamer;
|
|
1182
|
+
}
|
|
1183
|
+
owner(account) {
|
|
1184
|
+
this.state.owner = account;
|
|
1185
|
+
return this;
|
|
1186
|
+
}
|
|
1187
|
+
orderId(id) {
|
|
1188
|
+
this.state.orderId = id;
|
|
1189
|
+
return this;
|
|
1190
|
+
}
|
|
1191
|
+
send(signingKeys) {
|
|
1192
|
+
if (!this.state.owner || this.state.orderId === undefined) {
|
|
1193
|
+
throw new Error('cancelOrder() builder requires owner and orderId before send()');
|
|
1194
|
+
}
|
|
1195
|
+
return this.streamer.limitOrderCancel(this.state.owner, this.state.orderId, signingKeys);
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
exports.HiveCancelOrderBuilder = HiveCancelOrderBuilder;
|
|
1199
|
+
class HiveWithdrawRouteBuilder {
|
|
1200
|
+
streamer;
|
|
1201
|
+
state = {};
|
|
1202
|
+
constructor(streamer) {
|
|
1203
|
+
this.streamer = streamer;
|
|
1204
|
+
}
|
|
1205
|
+
from(account) {
|
|
1206
|
+
this.state.from = account;
|
|
1207
|
+
return this;
|
|
1208
|
+
}
|
|
1209
|
+
to(account) {
|
|
1210
|
+
this.state.to = account;
|
|
1211
|
+
return this;
|
|
1212
|
+
}
|
|
1213
|
+
percent(value) {
|
|
1214
|
+
this.state.percent = value;
|
|
1215
|
+
return this;
|
|
1216
|
+
}
|
|
1217
|
+
autoVest(value = true) {
|
|
1218
|
+
this.state.autoVest = value;
|
|
1219
|
+
return this;
|
|
1220
|
+
}
|
|
1221
|
+
send(signingKeys) {
|
|
1222
|
+
if (!this.state.from || !this.state.to || this.state.percent === undefined) {
|
|
1223
|
+
throw new Error('withdrawRoute() builder requires from, to, and percent before send()');
|
|
1224
|
+
}
|
|
1225
|
+
return this.streamer.setWithdrawVestingRoute(this.state.from, this.state.to, this.state.percent, this.state.autoVest || false, signingKeys);
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
exports.HiveWithdrawRouteBuilder = HiveWithdrawRouteBuilder;
|
|
1229
|
+
class HiveCommentOptionsBuilder {
|
|
1230
|
+
streamer;
|
|
1231
|
+
state = { beneficiaries: [] };
|
|
1232
|
+
constructor(streamer) {
|
|
1233
|
+
this.streamer = streamer;
|
|
1234
|
+
}
|
|
1235
|
+
author(account) {
|
|
1236
|
+
this.state.author = account;
|
|
1237
|
+
return this;
|
|
1238
|
+
}
|
|
1239
|
+
permlink(value) {
|
|
1240
|
+
this.state.permlink = value;
|
|
1241
|
+
return this;
|
|
1242
|
+
}
|
|
1243
|
+
maxAcceptedPayout(amount, symbol) {
|
|
1244
|
+
this.state.maxAcceptedPayout = buildAssetAmount(amount, symbol || 'HBD');
|
|
1245
|
+
return this;
|
|
1246
|
+
}
|
|
1247
|
+
percentHbd(value) {
|
|
1248
|
+
this.state.percentHbd = value;
|
|
1249
|
+
return this;
|
|
1250
|
+
}
|
|
1251
|
+
allowVotes(value = true) {
|
|
1252
|
+
this.state.allowVotes = value;
|
|
1253
|
+
return this;
|
|
1254
|
+
}
|
|
1255
|
+
allowCurationRewards(value = true) {
|
|
1256
|
+
this.state.allowCurationRewards = value;
|
|
1257
|
+
return this;
|
|
1258
|
+
}
|
|
1259
|
+
beneficiary(account, weight) {
|
|
1260
|
+
this.state.beneficiaries.push({ account, weight });
|
|
1261
|
+
return this;
|
|
1262
|
+
}
|
|
1263
|
+
send() {
|
|
1264
|
+
if (!this.state.author || !this.state.permlink) {
|
|
1265
|
+
throw new Error('commentOptions() builder requires author and permlink before send()');
|
|
1266
|
+
}
|
|
1267
|
+
const extensions = [];
|
|
1268
|
+
if (this.state.beneficiaries.length > 0) {
|
|
1269
|
+
extensions.push([0, { beneficiaries: this.state.beneficiaries }]);
|
|
1270
|
+
}
|
|
1271
|
+
return this.streamer.commentOptions(this.state.author, this.state.permlink, {
|
|
1272
|
+
max_accepted_payout: this.state.maxAcceptedPayout,
|
|
1273
|
+
percent_hbd: this.state.percentHbd,
|
|
1274
|
+
allow_votes: this.state.allowVotes,
|
|
1275
|
+
allow_curation_rewards: this.state.allowCurationRewards,
|
|
1276
|
+
extensions
|
|
1277
|
+
});
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
exports.HiveCommentOptionsBuilder = HiveCommentOptionsBuilder;
|
|
1281
|
+
class HivePostBuilder {
|
|
1282
|
+
streamer;
|
|
1283
|
+
state = {
|
|
1284
|
+
tags: [],
|
|
1285
|
+
parentAuthor: '',
|
|
1286
|
+
parentPermlink: '',
|
|
1287
|
+
beneficiaries: [],
|
|
1288
|
+
appName: 'hive-stream',
|
|
1289
|
+
formatType: 'markdown',
|
|
1290
|
+
images: [],
|
|
1291
|
+
extraMetadata: {}
|
|
1292
|
+
};
|
|
1293
|
+
constructor(streamer) {
|
|
1294
|
+
this.streamer = streamer;
|
|
1295
|
+
}
|
|
1296
|
+
author(account) {
|
|
1297
|
+
this.state.author = account;
|
|
1298
|
+
return this;
|
|
1299
|
+
}
|
|
1300
|
+
title(value) {
|
|
1301
|
+
this.state.title = value;
|
|
1302
|
+
return this;
|
|
1303
|
+
}
|
|
1304
|
+
body(value) {
|
|
1305
|
+
this.state.body = value;
|
|
1306
|
+
return this;
|
|
1307
|
+
}
|
|
1308
|
+
permlink(value) {
|
|
1309
|
+
this.state.permlink = value;
|
|
1310
|
+
return this;
|
|
1311
|
+
}
|
|
1312
|
+
tags(...tags) {
|
|
1313
|
+
this.state.tags = tags.map(t => t.trim().toLowerCase()).filter(Boolean);
|
|
1314
|
+
return this;
|
|
1315
|
+
}
|
|
1316
|
+
community(name) {
|
|
1317
|
+
this.state.communityName = name;
|
|
1318
|
+
return this;
|
|
1319
|
+
}
|
|
1320
|
+
parentAuthor(account) {
|
|
1321
|
+
this.state.parentAuthor = account;
|
|
1322
|
+
return this;
|
|
1323
|
+
}
|
|
1324
|
+
parentPermlink(value) {
|
|
1325
|
+
this.state.parentPermlink = value;
|
|
1326
|
+
return this;
|
|
1327
|
+
}
|
|
1328
|
+
beneficiary(account, weight) {
|
|
1329
|
+
this.state.beneficiaries.push({ account, weight });
|
|
1330
|
+
return this;
|
|
1331
|
+
}
|
|
1332
|
+
maxAcceptedPayout(amount, symbol) {
|
|
1333
|
+
this.state.maxAcceptedPayout = buildAssetAmount(amount, symbol || 'HBD');
|
|
1334
|
+
return this;
|
|
1335
|
+
}
|
|
1336
|
+
percentHbd(value) {
|
|
1337
|
+
this.state.percentHbd = value;
|
|
1338
|
+
return this;
|
|
1339
|
+
}
|
|
1340
|
+
allowVotes(value = true) {
|
|
1341
|
+
this.state.allowVotes = value;
|
|
1342
|
+
return this;
|
|
1343
|
+
}
|
|
1344
|
+
allowCurationRewards(value = true) {
|
|
1345
|
+
this.state.allowCurationRewards = value;
|
|
1346
|
+
return this;
|
|
1347
|
+
}
|
|
1348
|
+
app(name) {
|
|
1349
|
+
this.state.appName = name;
|
|
1350
|
+
return this;
|
|
1351
|
+
}
|
|
1352
|
+
format(value) {
|
|
1353
|
+
this.state.formatType = value;
|
|
1354
|
+
return this;
|
|
1355
|
+
}
|
|
1356
|
+
description(value) {
|
|
1357
|
+
this.state.descriptionText = value;
|
|
1358
|
+
return this;
|
|
1359
|
+
}
|
|
1360
|
+
image(...urls) {
|
|
1361
|
+
this.state.images.push(...urls);
|
|
1362
|
+
return this;
|
|
1363
|
+
}
|
|
1364
|
+
metadata(key, value) {
|
|
1365
|
+
this.state.extraMetadata[key] = value;
|
|
1366
|
+
return this;
|
|
1367
|
+
}
|
|
1368
|
+
send() {
|
|
1369
|
+
if (!this.state.author) {
|
|
1370
|
+
throw new Error('post() builder requires author before send()');
|
|
1371
|
+
}
|
|
1372
|
+
if (!this.state.body) {
|
|
1373
|
+
throw new Error('post() builder requires body before send()');
|
|
1374
|
+
}
|
|
1375
|
+
const isReply = !!this.state.parentAuthor;
|
|
1376
|
+
// Generate permlink if not provided
|
|
1377
|
+
const permlink = this.state.permlink
|
|
1378
|
+
|| (isReply
|
|
1379
|
+
? utils_1.Utils.generateReplyPermlink(this.state.parentPermlink)
|
|
1380
|
+
: utils_1.Utils.generatePermlink(this.state.title || 'untitled'));
|
|
1381
|
+
// Determine parent_permlink for top-level posts
|
|
1382
|
+
let parentPermlink = this.state.parentPermlink;
|
|
1383
|
+
if (!isReply) {
|
|
1384
|
+
if (this.state.communityName) {
|
|
1385
|
+
parentPermlink = this.state.communityName;
|
|
1386
|
+
}
|
|
1387
|
+
else if (this.state.tags.length > 0) {
|
|
1388
|
+
parentPermlink = this.state.tags[0];
|
|
1389
|
+
}
|
|
1390
|
+
else {
|
|
1391
|
+
parentPermlink = 'hive-stream';
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
// Build json_metadata
|
|
1395
|
+
const jsonMetadata = utils_1.Utils.createPostMetadata({
|
|
1396
|
+
tags: this.state.tags,
|
|
1397
|
+
image: this.state.images.length > 0 ? this.state.images : utils_1.Utils.extractImagesFromBody(this.state.body),
|
|
1398
|
+
app: this.state.appName,
|
|
1399
|
+
format: this.state.formatType,
|
|
1400
|
+
description: this.state.descriptionText,
|
|
1401
|
+
...this.state.extraMetadata
|
|
1402
|
+
});
|
|
1403
|
+
// Build the comment operation
|
|
1404
|
+
const commentOp = ['comment', {
|
|
1405
|
+
parent_author: this.state.parentAuthor,
|
|
1406
|
+
parent_permlink: parentPermlink,
|
|
1407
|
+
author: this.state.author,
|
|
1408
|
+
permlink,
|
|
1409
|
+
title: this.state.title || '',
|
|
1410
|
+
body: this.state.body,
|
|
1411
|
+
json_metadata: jsonMetadata
|
|
1412
|
+
}];
|
|
1413
|
+
// Check if we need comment_options
|
|
1414
|
+
const needsOptions = this.state.beneficiaries.length > 0
|
|
1415
|
+
|| this.state.maxAcceptedPayout !== undefined
|
|
1416
|
+
|| this.state.percentHbd !== undefined
|
|
1417
|
+
|| this.state.allowVotes !== undefined
|
|
1418
|
+
|| this.state.allowCurationRewards !== undefined;
|
|
1419
|
+
if (!needsOptions) {
|
|
1420
|
+
return this.streamer.broadcastOperations([commentOp]);
|
|
1421
|
+
}
|
|
1422
|
+
// Build comment_options operation
|
|
1423
|
+
const extensions = [];
|
|
1424
|
+
if (this.state.beneficiaries.length > 0) {
|
|
1425
|
+
const sorted = [...this.state.beneficiaries].sort((a, b) => a.account.localeCompare(b.account));
|
|
1426
|
+
extensions.push([0, { beneficiaries: sorted }]);
|
|
1427
|
+
}
|
|
1428
|
+
const commentOptionsOp = ['comment_options', {
|
|
1429
|
+
author: this.state.author,
|
|
1430
|
+
permlink,
|
|
1431
|
+
max_accepted_payout: this.state.maxAcceptedPayout || '1000000.000 HBD',
|
|
1432
|
+
percent_hbd: this.state.percentHbd !== undefined ? this.state.percentHbd : 10000,
|
|
1433
|
+
allow_votes: this.state.allowVotes !== false,
|
|
1434
|
+
allow_curation_rewards: this.state.allowCurationRewards !== false,
|
|
1435
|
+
extensions
|
|
1436
|
+
}];
|
|
1437
|
+
// Broadcast both atomically
|
|
1438
|
+
return this.streamer.broadcastOperations([commentOp, commentOptionsOp]);
|
|
1439
|
+
}
|
|
1440
|
+
}
|
|
1441
|
+
exports.HivePostBuilder = HivePostBuilder;
|
|
1442
|
+
class HiveBatchBuilder {
|
|
1443
|
+
streamer;
|
|
1444
|
+
operations = [];
|
|
1445
|
+
constructor(streamer) {
|
|
1446
|
+
this.streamer = streamer;
|
|
1447
|
+
}
|
|
1448
|
+
add(operation) {
|
|
1449
|
+
this.operations.push(operation);
|
|
1450
|
+
return this;
|
|
1451
|
+
}
|
|
1452
|
+
transfer(from, to, amount, memo = '') {
|
|
1453
|
+
this.operations.push(['transfer', { from, to, amount, memo }]);
|
|
1454
|
+
return this;
|
|
1455
|
+
}
|
|
1456
|
+
vote(voter, author, permlink, weight) {
|
|
1457
|
+
this.operations.push(['vote', { voter, author, permlink, weight }]);
|
|
1458
|
+
return this;
|
|
1459
|
+
}
|
|
1460
|
+
customJson(id, json, postingAuth, activeAuth) {
|
|
1461
|
+
const jsonStr = typeof json === 'string' ? json : JSON.stringify(json);
|
|
1462
|
+
this.operations.push(['custom_json', {
|
|
1463
|
+
required_auths: activeAuth ? [activeAuth] : [],
|
|
1464
|
+
required_posting_auths: postingAuth ? [postingAuth] : [],
|
|
1465
|
+
id,
|
|
1466
|
+
json: jsonStr
|
|
1467
|
+
}]);
|
|
1468
|
+
return this;
|
|
1469
|
+
}
|
|
1470
|
+
comment(author, permlink, parentAuthor, parentPermlink, title, body, jsonMetadata = '{}') {
|
|
1471
|
+
this.operations.push(['comment', {
|
|
1472
|
+
parent_author: parentAuthor,
|
|
1473
|
+
parent_permlink: parentPermlink,
|
|
1474
|
+
author,
|
|
1475
|
+
permlink,
|
|
1476
|
+
title,
|
|
1477
|
+
body,
|
|
1478
|
+
json_metadata: jsonMetadata
|
|
1479
|
+
}]);
|
|
1480
|
+
return this;
|
|
1481
|
+
}
|
|
1482
|
+
send(signingKeys) {
|
|
1483
|
+
if (this.operations.length === 0) {
|
|
1484
|
+
throw new Error('batch() builder requires at least one operation before send()');
|
|
1485
|
+
}
|
|
1486
|
+
return this.streamer.broadcastOperations(this.operations, signingKeys);
|
|
1487
|
+
}
|
|
1488
|
+
}
|
|
1489
|
+
exports.HiveBatchBuilder = HiveBatchBuilder;
|
|
1490
|
+
class HiveEngineStakeBuilder {
|
|
1491
|
+
streamer;
|
|
1492
|
+
state = {};
|
|
1493
|
+
constructor(streamer) {
|
|
1494
|
+
this.streamer = streamer;
|
|
1495
|
+
}
|
|
1496
|
+
from(account) { this.state.from = account; return this; }
|
|
1497
|
+
to(account) { this.state.to = account; return this; }
|
|
1498
|
+
symbol(symbol) { this.state.symbol = symbol; return this; }
|
|
1499
|
+
quantity(quantity) { this.state.quantity = String(quantity); return this; }
|
|
1500
|
+
send() {
|
|
1501
|
+
if (!this.state.from || !this.state.symbol || !this.state.quantity) {
|
|
1502
|
+
throw new Error('stakeEngine() builder requires from, symbol, and quantity before send()');
|
|
1503
|
+
}
|
|
1504
|
+
return this.streamer.stakeEngineTokens(this.state.from, this.state.to || this.state.from, this.state.symbol, this.state.quantity);
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
exports.HiveEngineStakeBuilder = HiveEngineStakeBuilder;
|
|
1508
|
+
class HiveEngineUnstakeBuilder {
|
|
1509
|
+
streamer;
|
|
1510
|
+
state = {};
|
|
1511
|
+
constructor(streamer) {
|
|
1512
|
+
this.streamer = streamer;
|
|
1513
|
+
}
|
|
1514
|
+
from(account) { this.state.from = account; return this; }
|
|
1515
|
+
symbol(symbol) { this.state.symbol = symbol; return this; }
|
|
1516
|
+
quantity(quantity) { this.state.quantity = String(quantity); return this; }
|
|
1517
|
+
send() {
|
|
1518
|
+
if (!this.state.from || !this.state.symbol || !this.state.quantity) {
|
|
1519
|
+
throw new Error('unstakeEngine() builder requires from, symbol, and quantity before send()');
|
|
1520
|
+
}
|
|
1521
|
+
return this.streamer.unstakeEngineTokens(this.state.from, this.state.symbol, this.state.quantity);
|
|
1522
|
+
}
|
|
1523
|
+
}
|
|
1524
|
+
exports.HiveEngineUnstakeBuilder = HiveEngineUnstakeBuilder;
|
|
1525
|
+
class HiveEngineMarketOrderBuilder {
|
|
1526
|
+
streamer;
|
|
1527
|
+
side;
|
|
1528
|
+
state = {};
|
|
1529
|
+
constructor(streamer, side) {
|
|
1530
|
+
this.streamer = streamer;
|
|
1531
|
+
this.side = side;
|
|
1532
|
+
}
|
|
1533
|
+
from(account) { this.state.from = account; return this; }
|
|
1534
|
+
symbol(symbol) { this.state.symbol = symbol; return this; }
|
|
1535
|
+
quantity(quantity) { this.state.quantity = String(quantity); return this; }
|
|
1536
|
+
price(price) { this.state.price = String(price); return this; }
|
|
1537
|
+
send() {
|
|
1538
|
+
if (!this.state.from || !this.state.symbol || !this.state.quantity || !this.state.price) {
|
|
1539
|
+
throw new Error(`${this.side}Engine() builder requires from, symbol, quantity, and price before send()`);
|
|
1540
|
+
}
|
|
1541
|
+
if (this.side === 'buy') {
|
|
1542
|
+
return this.streamer.buyEngineTokens(this.state.from, this.state.symbol, this.state.quantity, this.state.price);
|
|
1543
|
+
}
|
|
1544
|
+
return this.streamer.sellEngineTokens(this.state.from, this.state.symbol, this.state.quantity, this.state.price);
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1547
|
+
exports.HiveEngineMarketOrderBuilder = HiveEngineMarketOrderBuilder;
|
|
1548
|
+
class HiveEngineCancelOrderBuilder {
|
|
1549
|
+
streamer;
|
|
1550
|
+
state = {};
|
|
1551
|
+
constructor(streamer) {
|
|
1552
|
+
this.streamer = streamer;
|
|
1553
|
+
}
|
|
1554
|
+
from(account) { this.state.from = account; return this; }
|
|
1555
|
+
type(type) { this.state.type = type; return this; }
|
|
1556
|
+
orderId(id) { this.state.orderId = id; return this; }
|
|
1557
|
+
send() {
|
|
1558
|
+
if (!this.state.from || !this.state.type || !this.state.orderId) {
|
|
1559
|
+
throw new Error('cancelEngineOrder() builder requires from, type, and orderId before send()');
|
|
1560
|
+
}
|
|
1561
|
+
return this.streamer.cancelEngineOrder(this.state.from, this.state.type, this.state.orderId);
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
exports.HiveEngineCancelOrderBuilder = HiveEngineCancelOrderBuilder;
|
|
1565
|
+
class HiveEngineDelegateBuilder {
|
|
1566
|
+
streamer;
|
|
1567
|
+
undelegate;
|
|
1568
|
+
state = {};
|
|
1569
|
+
constructor(streamer, undelegate = false) {
|
|
1570
|
+
this.streamer = streamer;
|
|
1571
|
+
this.undelegate = undelegate;
|
|
1572
|
+
}
|
|
1573
|
+
from(account) { this.state.from = account; return this; }
|
|
1574
|
+
to(account) { this.state.to = account; return this; }
|
|
1575
|
+
symbol(symbol) { this.state.symbol = symbol; return this; }
|
|
1576
|
+
quantity(quantity) { this.state.quantity = String(quantity); return this; }
|
|
1577
|
+
send() {
|
|
1578
|
+
if (!this.state.from || !this.state.to || !this.state.symbol || !this.state.quantity) {
|
|
1579
|
+
throw new Error(`${this.undelegate ? 'undelegateEngine' : 'delegateEngine'}() builder requires from, to, symbol, and quantity before send()`);
|
|
1580
|
+
}
|
|
1581
|
+
if (this.undelegate) {
|
|
1582
|
+
return this.streamer.undelegateEngineTokens(this.state.from, this.state.to, this.state.symbol, this.state.quantity);
|
|
1583
|
+
}
|
|
1584
|
+
return this.streamer.delegateEngineTokens(this.state.from, this.state.to, this.state.symbol, this.state.quantity);
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1587
|
+
exports.HiveEngineDelegateBuilder = HiveEngineDelegateBuilder;
|
|
1588
|
+
class HiveCommunityOperationBuilder {
|
|
1589
|
+
streamer;
|
|
1590
|
+
action;
|
|
1591
|
+
state = {};
|
|
1592
|
+
constructor(streamer, action) {
|
|
1593
|
+
this.streamer = streamer;
|
|
1594
|
+
this.action = action;
|
|
1595
|
+
}
|
|
1596
|
+
account(account) { this.state.account = account; return this; }
|
|
1597
|
+
community(name) { this.state.community = name; return this; }
|
|
1598
|
+
send() {
|
|
1599
|
+
if (!this.state.account || !this.state.community) {
|
|
1600
|
+
throw new Error(`${this.action}Community() builder requires account and community before send()`);
|
|
1601
|
+
}
|
|
1602
|
+
if (this.action === 'subscribe') {
|
|
1603
|
+
return this.streamer.subscribeCommunity(this.state.account, this.state.community);
|
|
1604
|
+
}
|
|
1605
|
+
return this.streamer.unsubscribeCommunity(this.state.account, this.state.community);
|
|
1606
|
+
}
|
|
1607
|
+
}
|
|
1608
|
+
exports.HiveCommunityOperationBuilder = HiveCommunityOperationBuilder;
|
|
1609
|
+
//# sourceMappingURL=builders.js.map
|