hive-stream 3.0.2 → 3.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. package/DOCUMENTATION.md +50 -2
  2. package/README.md +282 -4
  3. package/dist/adapters/base.adapter.d.ts +5 -0
  4. package/dist/adapters/base.adapter.js +9 -0
  5. package/dist/adapters/base.adapter.js.map +1 -1
  6. package/dist/adapters/mongodb.adapter.d.ts +6 -6
  7. package/dist/adapters/mongodb.adapter.js +36 -21
  8. package/dist/adapters/mongodb.adapter.js.map +1 -1
  9. package/dist/adapters/postgresql.adapter.d.ts +7 -0
  10. package/dist/adapters/postgresql.adapter.js +46 -19
  11. package/dist/adapters/postgresql.adapter.js.map +1 -1
  12. package/dist/adapters/sqlite.adapter.d.ts +4 -0
  13. package/dist/adapters/sqlite.adapter.js +10 -0
  14. package/dist/adapters/sqlite.adapter.js.map +1 -1
  15. package/dist/api.d.ts +13 -3
  16. package/dist/api.js +96 -62
  17. package/dist/api.js.map +1 -1
  18. package/dist/builders.d.ts +176 -0
  19. package/dist/builders.js +727 -0
  20. package/dist/builders.js.map +1 -0
  21. package/dist/config.d.ts +16 -1
  22. package/dist/config.js +95 -3
  23. package/dist/config.js.map +1 -1
  24. package/dist/contracts/auctionhouse.contract.d.ts +4 -0
  25. package/dist/contracts/auctionhouse.contract.js +234 -0
  26. package/dist/contracts/auctionhouse.contract.js.map +1 -0
  27. package/dist/contracts/booking.contract.d.ts +4 -0
  28. package/dist/contracts/booking.contract.js +225 -0
  29. package/dist/contracts/booking.contract.js.map +1 -0
  30. package/dist/contracts/bountyboard.contract.d.ts +4 -0
  31. package/dist/contracts/bountyboard.contract.js +233 -0
  32. package/dist/contracts/bountyboard.contract.js.map +1 -0
  33. package/dist/contracts/bundlemarketplace.contract.d.ts +4 -0
  34. package/dist/contracts/bundlemarketplace.contract.js +195 -0
  35. package/dist/contracts/bundlemarketplace.contract.js.map +1 -0
  36. package/dist/contracts/charitymatch.contract.d.ts +4 -0
  37. package/dist/contracts/charitymatch.contract.js +172 -0
  38. package/dist/contracts/charitymatch.contract.js.map +1 -0
  39. package/dist/contracts/coinflip.contract.js +25 -22
  40. package/dist/contracts/coinflip.contract.js.map +1 -1
  41. package/dist/contracts/crowdfund.contract.d.ts +4 -0
  42. package/dist/contracts/crowdfund.contract.js +290 -0
  43. package/dist/contracts/crowdfund.contract.js.map +1 -0
  44. package/dist/contracts/dcabot.contract.d.ts +4 -0
  45. package/dist/contracts/dcabot.contract.js +217 -0
  46. package/dist/contracts/dcabot.contract.js.map +1 -0
  47. package/dist/contracts/dice.contract.js +25 -22
  48. package/dist/contracts/dice.contract.js.map +1 -1
  49. package/dist/contracts/domainregistry.contract.d.ts +4 -0
  50. package/dist/contracts/domainregistry.contract.js +232 -0
  51. package/dist/contracts/domainregistry.contract.js.map +1 -0
  52. package/dist/contracts/exchange.contract.js +209 -168
  53. package/dist/contracts/exchange.contract.js.map +1 -1
  54. package/dist/contracts/fanclub.contract.d.ts +4 -0
  55. package/dist/contracts/fanclub.contract.js +193 -0
  56. package/dist/contracts/fanclub.contract.js.map +1 -0
  57. package/dist/contracts/giftcard.contract.d.ts +4 -0
  58. package/dist/contracts/giftcard.contract.js +158 -0
  59. package/dist/contracts/giftcard.contract.js.map +1 -0
  60. package/dist/contracts/grantrounds.contract.d.ts +4 -0
  61. package/dist/contracts/grantrounds.contract.js +265 -0
  62. package/dist/contracts/grantrounds.contract.js.map +1 -0
  63. package/dist/contracts/groupbuy.contract.d.ts +4 -0
  64. package/dist/contracts/groupbuy.contract.js +198 -0
  65. package/dist/contracts/groupbuy.contract.js.map +1 -0
  66. package/dist/contracts/helpers.d.ts +66 -0
  67. package/dist/contracts/helpers.js +166 -0
  68. package/dist/contracts/helpers.js.map +1 -0
  69. package/dist/contracts/insurancepool.contract.d.ts +4 -0
  70. package/dist/contracts/insurancepool.contract.js +281 -0
  71. package/dist/contracts/insurancepool.contract.js.map +1 -0
  72. package/dist/contracts/invoice.contract.d.ts +4 -0
  73. package/dist/contracts/invoice.contract.js +193 -0
  74. package/dist/contracts/invoice.contract.js.map +1 -0
  75. package/dist/contracts/launchpad.contract.d.ts +4 -0
  76. package/dist/contracts/launchpad.contract.js +225 -0
  77. package/dist/contracts/launchpad.contract.js.map +1 -0
  78. package/dist/contracts/lotto.contract.js +53 -37
  79. package/dist/contracts/lotto.contract.js.map +1 -1
  80. package/dist/contracts/multisigtreasury.contract.d.ts +4 -0
  81. package/dist/contracts/multisigtreasury.contract.js +245 -0
  82. package/dist/contracts/multisigtreasury.contract.js.map +1 -0
  83. package/dist/contracts/nft.contract.d.ts +1 -0
  84. package/dist/contracts/nft.contract.js +234 -195
  85. package/dist/contracts/nft.contract.js.map +1 -1
  86. package/dist/contracts/oraclebounty.contract.d.ts +4 -0
  87. package/dist/contracts/oraclebounty.contract.js +250 -0
  88. package/dist/contracts/oraclebounty.contract.js.map +1 -0
  89. package/dist/contracts/payroll.contract.d.ts +4 -0
  90. package/dist/contracts/payroll.contract.js +232 -0
  91. package/dist/contracts/payroll.contract.js.map +1 -0
  92. package/dist/contracts/paywall.contract.d.ts +4 -0
  93. package/dist/contracts/paywall.contract.js +185 -0
  94. package/dist/contracts/paywall.contract.js.map +1 -0
  95. package/dist/contracts/poll.contract.js +2 -0
  96. package/dist/contracts/poll.contract.js.map +1 -1
  97. package/dist/contracts/predictionmarket.contract.d.ts +4 -0
  98. package/dist/contracts/predictionmarket.contract.js +213 -0
  99. package/dist/contracts/predictionmarket.contract.js.map +1 -0
  100. package/dist/contracts/proposaltimelock.contract.d.ts +4 -0
  101. package/dist/contracts/proposaltimelock.contract.js +250 -0
  102. package/dist/contracts/proposaltimelock.contract.js.map +1 -0
  103. package/dist/contracts/questpass.contract.d.ts +4 -0
  104. package/dist/contracts/questpass.contract.js +214 -0
  105. package/dist/contracts/questpass.contract.js.map +1 -0
  106. package/dist/contracts/referral.contract.d.ts +4 -0
  107. package/dist/contracts/referral.contract.js +238 -0
  108. package/dist/contracts/referral.contract.js.map +1 -0
  109. package/dist/contracts/rental.contract.d.ts +4 -0
  110. package/dist/contracts/rental.contract.js +221 -0
  111. package/dist/contracts/rental.contract.js.map +1 -0
  112. package/dist/contracts/revenuesplit.contract.d.ts +4 -0
  113. package/dist/contracts/revenuesplit.contract.js +211 -0
  114. package/dist/contracts/revenuesplit.contract.js.map +1 -0
  115. package/dist/contracts/rps.contract.js +48 -20
  116. package/dist/contracts/rps.contract.js.map +1 -1
  117. package/dist/contracts/savings.contract.d.ts +4 -0
  118. package/dist/contracts/savings.contract.js +208 -0
  119. package/dist/contracts/savings.contract.js.map +1 -0
  120. package/dist/contracts/subscription.contract.d.ts +4 -0
  121. package/dist/contracts/subscription.contract.js +241 -0
  122. package/dist/contracts/subscription.contract.js.map +1 -0
  123. package/dist/contracts/sweepstakes.contract.d.ts +4 -0
  124. package/dist/contracts/sweepstakes.contract.js +209 -0
  125. package/dist/contracts/sweepstakes.contract.js.map +1 -0
  126. package/dist/contracts/ticketing.contract.d.ts +4 -0
  127. package/dist/contracts/ticketing.contract.js +185 -0
  128. package/dist/contracts/ticketing.contract.js.map +1 -0
  129. package/dist/contracts/tipjar.contract.js +2 -0
  130. package/dist/contracts/tipjar.contract.js.map +1 -1
  131. package/dist/contracts/token.contract.js +135 -125
  132. package/dist/contracts/token.contract.js.map +1 -1
  133. package/dist/index.d.ts +40 -0
  134. package/dist/index.js +72 -1
  135. package/dist/index.js.map +1 -1
  136. package/dist/metadata.d.ts +20 -0
  137. package/dist/metadata.js +320 -1
  138. package/dist/metadata.js.map +1 -1
  139. package/dist/providers/block-provider.d.ts +22 -0
  140. package/dist/providers/block-provider.js +3 -0
  141. package/dist/providers/block-provider.js.map +1 -0
  142. package/dist/providers/haf-client.d.ts +30 -0
  143. package/dist/providers/haf-client.js +119 -0
  144. package/dist/providers/haf-client.js.map +1 -0
  145. package/dist/providers/haf-provider.d.ts +49 -0
  146. package/dist/providers/haf-provider.js +256 -0
  147. package/dist/providers/haf-provider.js.map +1 -0
  148. package/dist/providers/hive-provider.d.ts +13 -0
  149. package/dist/providers/hive-provider.js +25 -0
  150. package/dist/providers/hive-provider.js.map +1 -0
  151. package/dist/providers/index.d.ts +4 -0
  152. package/dist/providers/index.js +21 -0
  153. package/dist/providers/index.js.map +1 -0
  154. package/dist/streamer.d.ts +65 -4
  155. package/dist/streamer.js +768 -72
  156. package/dist/streamer.js.map +1 -1
  157. package/dist/types/hive-stream.d.ts +317 -0
  158. package/dist/utils.d.ts +33 -0
  159. package/dist/utils.js +198 -2
  160. package/dist/utils.js.map +1 -1
  161. package/package.json +16 -1
  162. package/.claude/settings.local.json +0 -12
  163. package/.env.example +0 -3
  164. package/.travis.yml +0 -11
  165. package/AGENTS.md +0 -35
  166. package/CLAUDE.md +0 -75
  167. package/ecosystem.config.js +0 -17
  168. package/examples/contracts/README.md +0 -8
  169. package/examples/contracts/exchange.ts +0 -38
  170. package/examples/contracts/poll.ts +0 -21
  171. package/examples/contracts/rps.ts +0 -19
  172. package/examples/contracts/tipjar.ts +0 -19
  173. package/jest.config.js +0 -9
  174. package/test-contract-block.md +0 -19
  175. package/tests/actions.spec.ts +0 -252
  176. package/tests/adapters/actions-persistence.spec.ts +0 -144
  177. package/tests/adapters/postgresql.adapter.spec.ts +0 -127
  178. package/tests/adapters/sqlite.adapter.spec.ts +0 -181
  179. package/tests/config-input.spec.ts +0 -90
  180. package/tests/contracts/coinflip.contract.spec.ts +0 -94
  181. package/tests/contracts/dice.contract.spec.ts +0 -87
  182. package/tests/contracts/entrants.json +0 -729
  183. package/tests/contracts/exchange.contract.spec.ts +0 -84
  184. package/tests/contracts/lotto.contract.spec.ts +0 -59
  185. package/tests/contracts/nft.contract.spec.ts +0 -948
  186. package/tests/contracts/token.contract.spec.ts +0 -90
  187. package/tests/exchanges/coingecko.exchange.spec.ts +0 -169
  188. package/tests/exchanges/exchange.base.spec.ts +0 -246
  189. package/tests/helpers/mock-adapter.ts +0 -214
  190. package/tests/helpers/mock-fetch.ts +0 -165
  191. package/tests/hive-chain-features.spec.ts +0 -319
  192. package/tests/hive-rates.spec.ts +0 -443
  193. package/tests/integration/hive-rates.integration.spec.ts +0 -35
  194. package/tests/metadata.spec.ts +0 -63
  195. package/tests/setup.ts +0 -30
  196. package/tests/streamer-actions.spec.ts +0 -274
  197. package/tests/streamer.spec.ts +0 -342
  198. package/tests/types/rates.spec.ts +0 -216
  199. package/tests/utils.spec.ts +0 -113
  200. package/tsconfig.build.json +0 -4
  201. package/tslint.json +0 -21
  202. package/wallaby.js +0 -26
@@ -0,0 +1,727 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ 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
+ //# sourceMappingURL=builders.js.map