zattera-js 0.1.0

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 (57) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +694 -0
  3. package/dist/browser/index.js +2466 -0
  4. package/dist/browser/index.js.map +1 -0
  5. package/dist/node/auth/index.js +188 -0
  6. package/dist/node/auth/index.js.map +1 -0
  7. package/dist/node/auth/keys.js +264 -0
  8. package/dist/node/auth/keys.js.map +1 -0
  9. package/dist/node/auth/memo.js +79 -0
  10. package/dist/node/auth/memo.js.map +1 -0
  11. package/dist/node/auth/serializer.js +162 -0
  12. package/dist/node/auth/serializer.js.map +1 -0
  13. package/dist/node/client/index.js +838 -0
  14. package/dist/node/client/index.js.map +1 -0
  15. package/dist/node/index.js +30 -0
  16. package/dist/node/index.js.map +1 -0
  17. package/dist/node/node_modules/@noble/ciphers/aes.js +254 -0
  18. package/dist/node/node_modules/@noble/ciphers/aes.js.map +1 -0
  19. package/dist/node/node_modules/@noble/ciphers/utils.js +113 -0
  20. package/dist/node/node_modules/@noble/ciphers/utils.js.map +1 -0
  21. package/dist/node/node_modules/@noble/hashes/esm/_md.js +146 -0
  22. package/dist/node/node_modules/@noble/hashes/esm/_md.js.map +1 -0
  23. package/dist/node/node_modules/@noble/hashes/esm/_u64.js +51 -0
  24. package/dist/node/node_modules/@noble/hashes/esm/_u64.js.map +1 -0
  25. package/dist/node/node_modules/@noble/hashes/esm/legacy.js +123 -0
  26. package/dist/node/node_modules/@noble/hashes/esm/legacy.js.map +1 -0
  27. package/dist/node/node_modules/@noble/hashes/esm/sha2.js +346 -0
  28. package/dist/node/node_modules/@noble/hashes/esm/sha2.js.map +1 -0
  29. package/dist/node/node_modules/@noble/hashes/esm/utils.js +73 -0
  30. package/dist/node/node_modules/@noble/hashes/esm/utils.js.map +1 -0
  31. package/dist/node/node_modules/@noble/secp256k1/index.js +578 -0
  32. package/dist/node/node_modules/@noble/secp256k1/index.js.map +1 -0
  33. package/dist/node/node_modules/bs58/node_modules/base-x/src/esm/index.js +132 -0
  34. package/dist/node/node_modules/bs58/node_modules/base-x/src/esm/index.js.map +1 -0
  35. package/dist/node/node_modules/bs58/src/esm/index.js +7 -0
  36. package/dist/node/node_modules/bs58/src/esm/index.js.map +1 -0
  37. package/dist/node/types/index.js +48 -0
  38. package/dist/node/types/index.js.map +1 -0
  39. package/dist/node/utils/chain-id.js +9 -0
  40. package/dist/node/utils/chain-id.js.map +1 -0
  41. package/dist/types/auth/index.d.ts +134 -0
  42. package/dist/types/auth/index.d.ts.map +1 -0
  43. package/dist/types/auth/keys.d.ts +112 -0
  44. package/dist/types/auth/keys.d.ts.map +1 -0
  45. package/dist/types/auth/memo.d.ts +51 -0
  46. package/dist/types/auth/memo.d.ts.map +1 -0
  47. package/dist/types/auth/serializer.d.ts +57 -0
  48. package/dist/types/auth/serializer.d.ts.map +1 -0
  49. package/dist/types/client/index.d.ts +360 -0
  50. package/dist/types/client/index.d.ts.map +1 -0
  51. package/dist/types/index.d.ts +16 -0
  52. package/dist/types/index.d.ts.map +1 -0
  53. package/dist/types/types/index.d.ts +593 -0
  54. package/dist/types/types/index.d.ts.map +1 -0
  55. package/dist/types/utils/chain-id.d.ts +10 -0
  56. package/dist/types/utils/chain-id.d.ts.map +1 -0
  57. package/package.json +63 -0
@@ -0,0 +1,838 @@
1
+ import { generateChainId } from "../utils/chain-id.js";
2
+ class ZatteraClient {
3
+ endpoint;
4
+ chainId;
5
+ timeout;
6
+ retries;
7
+ requestId;
8
+ constructor(config) {
9
+ this.endpoint = config.endpoint;
10
+ this.chainId = generateChainId(config.networkName || "zattera");
11
+ this.timeout = config.timeout ?? 3e4;
12
+ this.retries = config.retries ?? 3;
13
+ this.requestId = 0;
14
+ }
15
+ getNextId() {
16
+ return ++this.requestId;
17
+ }
18
+ /**
19
+ * Get the configured chain ID
20
+ */
21
+ getChainId() {
22
+ return this.chainId;
23
+ }
24
+ /**
25
+ * Internal method to make JSON-RPC 2.0 requests with retry logic
26
+ */
27
+ async request(method, params = {}) {
28
+ const request = {
29
+ jsonrpc: "2.0",
30
+ method,
31
+ params,
32
+ id: this.getNextId()
33
+ };
34
+ let lastError = null;
35
+ for (let attempt = 0; attempt <= this.retries; attempt++) {
36
+ try {
37
+ const controller = new AbortController();
38
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
39
+ const response = await fetch(this.endpoint, {
40
+ method: "POST",
41
+ headers: {
42
+ "Content-Type": "application/json"
43
+ },
44
+ body: JSON.stringify(request),
45
+ signal: controller.signal
46
+ });
47
+ clearTimeout(timeoutId);
48
+ if (!response.ok) {
49
+ throw new Error(`HTTP error! status: ${response.status}`);
50
+ }
51
+ const data = await response.json();
52
+ if (data.error) {
53
+ throw new Error(
54
+ `RPC error ${data.error.code}: ${data.error.message}`
55
+ );
56
+ }
57
+ if (data.result === void 0) {
58
+ throw new Error("No result in RPC response");
59
+ }
60
+ return data.result;
61
+ } catch (error) {
62
+ lastError = error instanceof Error ? error : new Error(String(error));
63
+ if (attempt < this.retries) {
64
+ await new Promise(
65
+ (resolve) => setTimeout(resolve, 1e3 * Math.pow(2, attempt))
66
+ );
67
+ }
68
+ }
69
+ }
70
+ throw lastError ?? new Error("Request failed");
71
+ }
72
+ /**
73
+ * Make batch JSON-RPC requests
74
+ */
75
+ async batch(requests) {
76
+ const batchRequest = requests.map((req) => ({
77
+ jsonrpc: "2.0",
78
+ method: req.method,
79
+ params: req.params ?? {},
80
+ id: this.getNextId()
81
+ }));
82
+ let lastError = null;
83
+ for (let attempt = 0; attempt <= this.retries; attempt++) {
84
+ try {
85
+ const controller = new AbortController();
86
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
87
+ const response = await fetch(this.endpoint, {
88
+ method: "POST",
89
+ headers: {
90
+ "Content-Type": "application/json"
91
+ },
92
+ body: JSON.stringify(batchRequest),
93
+ signal: controller.signal
94
+ });
95
+ clearTimeout(timeoutId);
96
+ if (!response.ok) {
97
+ throw new Error(`HTTP error! status: ${response.status}`);
98
+ }
99
+ const data = await response.json();
100
+ return data.map((item) => {
101
+ if (item.error) {
102
+ throw new Error(
103
+ `RPC error ${item.error.code}: ${item.error.message}`
104
+ );
105
+ }
106
+ if (item.result === void 0) {
107
+ throw new Error("No result in RPC response");
108
+ }
109
+ return item.result;
110
+ });
111
+ } catch (error) {
112
+ lastError = error instanceof Error ? error : new Error(String(error));
113
+ if (attempt < this.retries) {
114
+ await new Promise(
115
+ (resolve) => setTimeout(resolve, 1e3 * Math.pow(2, attempt))
116
+ );
117
+ }
118
+ }
119
+ }
120
+ throw lastError ?? new Error("Batch request failed");
121
+ }
122
+ // ============================================================================
123
+ // Generic RPC Call
124
+ // ============================================================================
125
+ /**
126
+ * Generic RPC call method for custom or new API methods
127
+ */
128
+ async call(method, params = {}) {
129
+ return this.request(method, params);
130
+ }
131
+ // ============================================================================
132
+ // Database API - Global Properties
133
+ // ============================================================================
134
+ /**
135
+ * Get compile-time chain configuration constants
136
+ */
137
+ async getConfig() {
138
+ return this.request("database_api.get_config", {});
139
+ }
140
+ /**
141
+ * Get current dynamic global properties (head block, supply, etc.)
142
+ */
143
+ async getDynamicGlobalProperties() {
144
+ return this.request(
145
+ "database_api.get_dynamic_global_properties",
146
+ {}
147
+ );
148
+ }
149
+ /**
150
+ * Get active witness schedule
151
+ */
152
+ async getWitnessSchedule() {
153
+ return this.request(
154
+ "database_api.get_witness_schedule",
155
+ {}
156
+ );
157
+ }
158
+ /**
159
+ * Get hardfork properties and version information
160
+ */
161
+ async getHardforkProperties() {
162
+ return this.request(
163
+ "database_api.get_hardfork_properties",
164
+ {}
165
+ );
166
+ }
167
+ /**
168
+ * Get reward fund details
169
+ */
170
+ async getRewardFunds() {
171
+ const result = await this.request("database_api.get_reward_funds", {});
172
+ return result.funds;
173
+ }
174
+ /**
175
+ * Get current median price feed
176
+ */
177
+ async getCurrentPriceFeed() {
178
+ return this.request(
179
+ "database_api.get_current_price_feed",
180
+ {}
181
+ );
182
+ }
183
+ /**
184
+ * Get price feed history
185
+ */
186
+ async getFeedHistory() {
187
+ return this.request("database_api.get_feed_history", {});
188
+ }
189
+ // ============================================================================
190
+ // Database API - Witnesses
191
+ // ============================================================================
192
+ /**
193
+ * List witnesses by specified order
194
+ */
195
+ async listWitnesses(params) {
196
+ const result = await this.request("database_api.list_witnesses", params);
197
+ return result.witnesses;
198
+ }
199
+ /**
200
+ * Find specific witnesses by account names
201
+ */
202
+ async findWitnesses(owners) {
203
+ const result = await this.request("database_api.find_witnesses", {
204
+ owners
205
+ });
206
+ return result.witnesses;
207
+ }
208
+ /**
209
+ * List witness votes
210
+ */
211
+ async listWitnessVotes(start, limit, order) {
212
+ return this.request("database_api.list_witness_votes", {
213
+ start,
214
+ limit,
215
+ order
216
+ });
217
+ }
218
+ /**
219
+ * Get currently active witnesses
220
+ */
221
+ async getActiveWitnesses() {
222
+ const result = await this.request(
223
+ "database_api.get_active_witnesses",
224
+ {}
225
+ );
226
+ return result.witnesses;
227
+ }
228
+ // ============================================================================
229
+ // Database API - Accounts
230
+ // ============================================================================
231
+ /**
232
+ * List accounts by specified order
233
+ */
234
+ async listAccounts(params) {
235
+ const result = await this.request("database_api.list_accounts", params);
236
+ return result.accounts;
237
+ }
238
+ /**
239
+ * Find specific accounts by names
240
+ */
241
+ async findAccounts(params) {
242
+ const result = await this.request("database_api.find_accounts", params);
243
+ return result.accounts;
244
+ }
245
+ /**
246
+ * List account owner authority change history
247
+ */
248
+ async listOwnerHistories(start, limit) {
249
+ return this.request(
250
+ "database_api.list_owner_histories",
251
+ { start, limit }
252
+ );
253
+ }
254
+ /**
255
+ * Find owner history for specific account
256
+ */
257
+ async findOwnerHistories(owner) {
258
+ return this.request(
259
+ "database_api.find_owner_histories",
260
+ { owner }
261
+ );
262
+ }
263
+ /**
264
+ * List account recovery requests
265
+ */
266
+ async listAccountRecoveryRequests(start, limit, order) {
267
+ return this.request(
268
+ "database_api.list_account_recovery_requests",
269
+ { start, limit, order }
270
+ );
271
+ }
272
+ /**
273
+ * Find account recovery requests
274
+ */
275
+ async findAccountRecoveryRequests(accounts) {
276
+ return this.request(
277
+ "database_api.find_account_recovery_requests",
278
+ { accounts }
279
+ );
280
+ }
281
+ /**
282
+ * List escrows
283
+ */
284
+ async listEscrows(start, limit, order) {
285
+ return this.request("database_api.list_escrows", {
286
+ start,
287
+ limit,
288
+ order
289
+ });
290
+ }
291
+ /**
292
+ * Find escrows
293
+ */
294
+ async findEscrows(from) {
295
+ return this.request("database_api.find_escrows", { from });
296
+ }
297
+ /**
298
+ * List vesting delegations
299
+ */
300
+ async listVestingDelegations(start, limit, order) {
301
+ return this.request(
302
+ "database_api.list_vesting_delegations",
303
+ { start, limit, order }
304
+ );
305
+ }
306
+ /**
307
+ * Find vesting delegations
308
+ */
309
+ async findVestingDelegations(account) {
310
+ return this.request(
311
+ "database_api.find_vesting_delegations",
312
+ { account }
313
+ );
314
+ }
315
+ /**
316
+ * List SBD conversion requests
317
+ */
318
+ async listDollarConversionRequests(start, limit, order) {
319
+ return this.request(
320
+ "database_api.list_dollar_conversion_requests",
321
+ { start, limit, order }
322
+ );
323
+ }
324
+ /**
325
+ * Find SBD conversion requests
326
+ */
327
+ async findDollarConversionRequests(account) {
328
+ return this.request(
329
+ "database_api.find_dollar_conversion_requests",
330
+ { account }
331
+ );
332
+ }
333
+ // ============================================================================
334
+ // Database API - Comments
335
+ // ============================================================================
336
+ /**
337
+ * List comments by specified order
338
+ */
339
+ async listComments(start, limit, order) {
340
+ return this.request("database_api.list_comments", {
341
+ start,
342
+ limit,
343
+ order
344
+ });
345
+ }
346
+ /**
347
+ * Find specific comments
348
+ */
349
+ async findComments(comments) {
350
+ return this.request("database_api.find_comments", {
351
+ comments
352
+ });
353
+ }
354
+ /**
355
+ * List votes
356
+ */
357
+ async listVotes(start, limit, order) {
358
+ return this.request("database_api.list_votes", {
359
+ start,
360
+ limit,
361
+ order
362
+ });
363
+ }
364
+ /**
365
+ * Find specific votes
366
+ */
367
+ async findVotes(author, permlink) {
368
+ return this.request("database_api.find_votes", {
369
+ author,
370
+ permlink
371
+ });
372
+ }
373
+ // ============================================================================
374
+ // Database API - Market
375
+ // ============================================================================
376
+ /**
377
+ * List limit orders
378
+ */
379
+ async listLimitOrders(start, limit, order) {
380
+ return this.request("database_api.list_limit_orders", {
381
+ start,
382
+ limit,
383
+ order
384
+ });
385
+ }
386
+ /**
387
+ * Find limit orders
388
+ */
389
+ async findLimitOrders(account) {
390
+ return this.request("database_api.find_limit_orders", {
391
+ account
392
+ });
393
+ }
394
+ /**
395
+ * Get current order book
396
+ */
397
+ async getOrderBook(limit = 50) {
398
+ return this.request("database_api.get_order_book", {
399
+ limit
400
+ });
401
+ }
402
+ // ============================================================================
403
+ // Database API - Authority & Validation
404
+ // ============================================================================
405
+ /**
406
+ * Get transaction as hex string
407
+ */
408
+ async getTransactionHex(trx) {
409
+ return this.request("database_api.get_transaction_hex", { trx });
410
+ }
411
+ /**
412
+ * Get required signatures for transaction
413
+ */
414
+ async getRequiredSignatures(trx, availableKeys) {
415
+ return this.request(
416
+ "database_api.get_required_signatures",
417
+ { trx, available_keys: availableKeys }
418
+ );
419
+ }
420
+ /**
421
+ * Get all potential signatures for transaction
422
+ */
423
+ async getPotentialSignatures(trx) {
424
+ return this.request(
425
+ "database_api.get_potential_signatures",
426
+ { trx }
427
+ );
428
+ }
429
+ /**
430
+ * Verify transaction has required authority
431
+ */
432
+ async verifyAuthority(trx) {
433
+ return this.request(
434
+ "database_api.verify_authority",
435
+ { trx }
436
+ );
437
+ }
438
+ /**
439
+ * Verify account has authority from signers
440
+ */
441
+ async verifyAccountAuthority(account, signers) {
442
+ return this.request(
443
+ "database_api.verify_account_authority",
444
+ { account, signers }
445
+ );
446
+ }
447
+ /**
448
+ * Verify arbitrary signatures
449
+ */
450
+ async verifySignatures(hash, signatures, requiredOwner, requiredActive, requiredPosting, requiredOther) {
451
+ return this.request(
452
+ "database_api.verify_signatures",
453
+ {
454
+ hash,
455
+ signatures,
456
+ required_owner: requiredOwner,
457
+ required_active: requiredActive,
458
+ required_posting: requiredPosting,
459
+ required_other: requiredOther
460
+ }
461
+ );
462
+ }
463
+ // ============================================================================
464
+ // Network Broadcast API
465
+ // ============================================================================
466
+ /**
467
+ * Broadcast transaction to the network
468
+ */
469
+ async broadcastTransaction(trx, maxBlockAge = -1) {
470
+ return this.request(
471
+ "network_broadcast_api.broadcast_transaction",
472
+ { trx, max_block_age: maxBlockAge }
473
+ );
474
+ }
475
+ /**
476
+ * Broadcast block to the network
477
+ */
478
+ async broadcastBlock(block) {
479
+ return this.request("network_broadcast_api.broadcast_block", {
480
+ block
481
+ });
482
+ }
483
+ // ============================================================================
484
+ // Block API
485
+ // ============================================================================
486
+ /**
487
+ * Get block header by block number
488
+ */
489
+ async getBlockHeader(blockNum) {
490
+ const result = await this.request("block_api.get_block_header", {
491
+ block_num: blockNum
492
+ });
493
+ return result.header;
494
+ }
495
+ /**
496
+ * Get full block by block number
497
+ */
498
+ async getBlock(blockNum) {
499
+ const result = await this.request("block_api.get_block", {
500
+ block_num: blockNum
501
+ });
502
+ return result.block;
503
+ }
504
+ // ============================================================================
505
+ // Account History API
506
+ // ============================================================================
507
+ /**
508
+ * Get operations in a specific block
509
+ */
510
+ async getOpsInBlock(params) {
511
+ return this.request("account_history_api.get_ops_in_block", params);
512
+ }
513
+ /**
514
+ * Get transaction by ID
515
+ */
516
+ async getTransaction(id) {
517
+ return this.request(
518
+ "account_history.get_transaction",
519
+ { id }
520
+ );
521
+ }
522
+ /**
523
+ * Get account operation history
524
+ */
525
+ async getAccountHistory(params) {
526
+ return this.request(
527
+ "account_history.get_account_history",
528
+ params
529
+ );
530
+ }
531
+ /**
532
+ * Enumerate virtual operations in block range
533
+ */
534
+ async enumVirtualOps(blockRangeBegin, blockRangeEnd) {
535
+ return this.request("account_history_api.enum_virtual_ops", {
536
+ block_range_begin: blockRangeBegin,
537
+ block_range_end: blockRangeEnd
538
+ });
539
+ }
540
+ // ============================================================================
541
+ // Tags/Discussion API
542
+ // ============================================================================
543
+ /**
544
+ * Get trending tags
545
+ */
546
+ async getTrendingTags(startTag = "", limit = 100) {
547
+ const result = await this.request("tags_api.get_trending_tags", {
548
+ start_tag: startTag,
549
+ limit
550
+ });
551
+ return result.tags;
552
+ }
553
+ /**
554
+ * Get tags used by author
555
+ */
556
+ async getTagsUsedByAuthor(author) {
557
+ return this.request("tags_api.get_tags_used_by_author", {
558
+ author
559
+ });
560
+ }
561
+ /**
562
+ * Get single discussion/post
563
+ */
564
+ async getDiscussion(author, permlink) {
565
+ return this.request("tags_api.get_discussion", {
566
+ author,
567
+ permlink
568
+ });
569
+ }
570
+ /**
571
+ * Get replies to a post
572
+ */
573
+ async getContentReplies(author, permlink) {
574
+ const result = await this.request("tags_api.get_content_replies", {
575
+ author,
576
+ permlink
577
+ });
578
+ return result.discussions;
579
+ }
580
+ /**
581
+ * Get discussions by trending
582
+ */
583
+ async getDiscussionsByTrending(query) {
584
+ return this.request("tags_api.get_discussions_by_trending", query);
585
+ }
586
+ /**
587
+ * Get discussions by creation time
588
+ */
589
+ async getDiscussionsByCreated(query) {
590
+ return this.request("tags_api.get_discussions_by_created", query);
591
+ }
592
+ /**
593
+ * Get discussions by activity
594
+ */
595
+ async getDiscussionsByActive(query) {
596
+ return this.request("tags_api.get_discussions_by_active", query);
597
+ }
598
+ /**
599
+ * Get discussions by cashout time
600
+ */
601
+ async getDiscussionsByCashout(query) {
602
+ return this.request("tags_api.get_discussions_by_cashout", query);
603
+ }
604
+ /**
605
+ * Get discussions by votes
606
+ */
607
+ async getDiscussionsByVotes(query) {
608
+ return this.request("tags_api.get_discussions_by_votes", query);
609
+ }
610
+ /**
611
+ * Get discussions by children count
612
+ */
613
+ async getDiscussionsByChildren(query) {
614
+ return this.request("tags_api.get_discussions_by_children", query);
615
+ }
616
+ /**
617
+ * Get hot discussions
618
+ */
619
+ async getDiscussionsByHot(query) {
620
+ return this.request("tags_api.get_discussions_by_hot", query);
621
+ }
622
+ /**
623
+ * Get discussions from follower feed
624
+ */
625
+ async getDiscussionsByFeed(query) {
626
+ return this.request("tags_api.get_discussions_by_feed", query);
627
+ }
628
+ /**
629
+ * Get discussions from blog
630
+ */
631
+ async getDiscussionsByBlog(query) {
632
+ return this.request("tags_api.get_discussions_by_blog", query);
633
+ }
634
+ /**
635
+ * Get discussions by comment count
636
+ */
637
+ async getDiscussionsByComments(query) {
638
+ return this.request("tags_api.get_discussions_by_comments", query);
639
+ }
640
+ /**
641
+ * Get promoted discussions
642
+ */
643
+ async getDiscussionsByPromoted(query) {
644
+ return this.request("tags_api.get_discussions_by_promoted", query);
645
+ }
646
+ /**
647
+ * Get active votes on a post
648
+ */
649
+ async getActiveVotes(author, permlink) {
650
+ return this.request("tags_api.get_active_votes", {
651
+ author,
652
+ permlink
653
+ });
654
+ }
655
+ // ============================================================================
656
+ // Follow API
657
+ // ============================================================================
658
+ /**
659
+ * Get followers of an account
660
+ */
661
+ async getFollowers(params) {
662
+ const result = await this.request("follow_api.get_followers", params);
663
+ return result.followers;
664
+ }
665
+ /**
666
+ * Get accounts that an account is following
667
+ */
668
+ async getFollowing(params) {
669
+ const result = await this.request("follow_api.get_following", params);
670
+ return result.following;
671
+ }
672
+ /**
673
+ * Get follower and following counts
674
+ */
675
+ async getFollowCount(account) {
676
+ return this.request("follow_api.get_follow_count", { account });
677
+ }
678
+ /**
679
+ * Get feed entries
680
+ */
681
+ async getFeedEntries(account, startEntryId = 0, limit = 100) {
682
+ return this.request("follow_api.get_feed_entries", {
683
+ account,
684
+ start_entry_id: startEntryId,
685
+ limit
686
+ });
687
+ }
688
+ /**
689
+ * Get feed with full comments
690
+ */
691
+ async getFeed(account, startEntryId = 0, limit = 100) {
692
+ return this.request("follow_api.get_feed", {
693
+ account,
694
+ start_entry_id: startEntryId,
695
+ limit
696
+ });
697
+ }
698
+ /**
699
+ * Get blog entries
700
+ */
701
+ async getBlogEntries(account, startEntryId = 0, limit = 100) {
702
+ return this.request("follow_api.get_blog_entries", {
703
+ account,
704
+ start_entry_id: startEntryId,
705
+ limit
706
+ });
707
+ }
708
+ /**
709
+ * Get blog with full comments
710
+ */
711
+ async getBlog(account, startEntryId = 0, limit = 100) {
712
+ return this.request("follow_api.get_blog", {
713
+ account,
714
+ start_entry_id: startEntryId,
715
+ limit
716
+ });
717
+ }
718
+ /**
719
+ * Get account reputation scores
720
+ */
721
+ async getAccountReputations(accountLowerBound = "", limit = 100) {
722
+ return this.request("follow_api.get_account_reputations", {
723
+ account_lower_bound: accountLowerBound,
724
+ limit
725
+ });
726
+ }
727
+ /**
728
+ * Get accounts that reblogged a post
729
+ */
730
+ async getRebloggedBy(author, permlink) {
731
+ return this.request("follow_api.get_reblogged_by", {
732
+ author,
733
+ permlink
734
+ });
735
+ }
736
+ /**
737
+ * Get blog author statistics
738
+ */
739
+ async getBlogAuthors(blogAccount) {
740
+ return this.request("follow_api.get_blog_authors", {
741
+ blog_account: blogAccount
742
+ });
743
+ }
744
+ // ============================================================================
745
+ // Market History API
746
+ // ============================================================================
747
+ /**
748
+ * Get market ticker
749
+ */
750
+ async getTicker() {
751
+ return this.request("market_history_api.get_ticker", {});
752
+ }
753
+ /**
754
+ * Get market volume
755
+ */
756
+ async getVolume() {
757
+ return this.request("market_history_api.get_volume", {});
758
+ }
759
+ /**
760
+ * Get market order book
761
+ */
762
+ async getMarketOrderBook(limit = 50) {
763
+ return this.request("market_history_api.get_order_book", {
764
+ limit
765
+ });
766
+ }
767
+ /**
768
+ * Get trade history
769
+ */
770
+ async getTradeHistory(start, end, limit = 100) {
771
+ return this.request("market_history_api.get_trade_history", {
772
+ start,
773
+ end,
774
+ limit
775
+ });
776
+ }
777
+ /**
778
+ * Get recent trades
779
+ */
780
+ async getRecentTrades(limit = 100) {
781
+ return this.request("market_history_api.get_recent_trades", {
782
+ limit
783
+ });
784
+ }
785
+ /**
786
+ * Get market history buckets
787
+ */
788
+ async getMarketHistory(bucketSeconds, start, end) {
789
+ return this.request(
790
+ "market_history_api.get_market_history",
791
+ {
792
+ bucket_seconds: bucketSeconds,
793
+ start,
794
+ end
795
+ }
796
+ );
797
+ }
798
+ /**
799
+ * Get available bucket sizes
800
+ */
801
+ async getMarketHistoryBuckets() {
802
+ const result = await this.request(
803
+ "market_history_api.get_market_history_buckets",
804
+ {}
805
+ );
806
+ return result.bucket_sizes;
807
+ }
808
+ // ============================================================================
809
+ // Account By Key API
810
+ // ============================================================================
811
+ /**
812
+ * Get accounts that can sign with given public keys
813
+ */
814
+ async getKeyReferences(keys) {
815
+ return this.request("account_by_key_api.get_key_references", {
816
+ keys
817
+ });
818
+ }
819
+ // ============================================================================
820
+ // JSON-RPC Meta API
821
+ // ============================================================================
822
+ /**
823
+ * Get list of all available RPC methods
824
+ */
825
+ async getMethods() {
826
+ return this.request("jsonrpc.get_methods", {});
827
+ }
828
+ /**
829
+ * Get signature (parameters and return type) for an RPC method
830
+ */
831
+ async getSignature(method) {
832
+ return this.request("jsonrpc.get_signature", { method });
833
+ }
834
+ }
835
+ export {
836
+ ZatteraClient
837
+ };
838
+ //# sourceMappingURL=index.js.map