hiero-sdk-utils 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 (137) hide show
  1. package/dist/cjs/client/HieroClient.d.ts +70 -0
  2. package/dist/cjs/client/HieroClient.d.ts.map +1 -0
  3. package/dist/cjs/client/HieroClient.js +165 -0
  4. package/dist/cjs/client/HieroClient.js.map +1 -0
  5. package/dist/cjs/client/rateLimiter.d.ts +33 -0
  6. package/dist/cjs/client/rateLimiter.d.ts.map +1 -0
  7. package/dist/cjs/client/rateLimiter.js +68 -0
  8. package/dist/cjs/client/rateLimiter.js.map +1 -0
  9. package/dist/cjs/client/types.d.ts +26 -0
  10. package/dist/cjs/client/types.d.ts.map +1 -0
  11. package/dist/cjs/client/types.js +11 -0
  12. package/dist/cjs/client/types.js.map +1 -0
  13. package/dist/cjs/errors/index.d.ts +95 -0
  14. package/dist/cjs/errors/index.d.ts.map +1 -0
  15. package/dist/cjs/errors/index.js +115 -0
  16. package/dist/cjs/errors/index.js.map +1 -0
  17. package/dist/cjs/index.d.ts +36 -0
  18. package/dist/cjs/index.d.ts.map +1 -0
  19. package/dist/cjs/index.js +55 -0
  20. package/dist/cjs/index.js.map +1 -0
  21. package/dist/cjs/pagination/paginator.d.ts +21 -0
  22. package/dist/cjs/pagination/paginator.d.ts.map +1 -0
  23. package/dist/cjs/pagination/paginator.js +89 -0
  24. package/dist/cjs/pagination/paginator.js.map +1 -0
  25. package/dist/cjs/resources/accounts.d.ts +43 -0
  26. package/dist/cjs/resources/accounts.d.ts.map +1 -0
  27. package/dist/cjs/resources/accounts.js +60 -0
  28. package/dist/cjs/resources/accounts.js.map +1 -0
  29. package/dist/cjs/resources/balances.d.ts +25 -0
  30. package/dist/cjs/resources/balances.d.ts.map +1 -0
  31. package/dist/cjs/resources/balances.js +33 -0
  32. package/dist/cjs/resources/balances.js.map +1 -0
  33. package/dist/cjs/resources/blocks.d.ts +36 -0
  34. package/dist/cjs/resources/blocks.d.ts.map +1 -0
  35. package/dist/cjs/resources/blocks.js +58 -0
  36. package/dist/cjs/resources/blocks.js.map +1 -0
  37. package/dist/cjs/resources/contracts.d.ts +36 -0
  38. package/dist/cjs/resources/contracts.d.ts.map +1 -0
  39. package/dist/cjs/resources/contracts.js +53 -0
  40. package/dist/cjs/resources/contracts.js.map +1 -0
  41. package/dist/cjs/resources/nfts.d.ts +39 -0
  42. package/dist/cjs/resources/nfts.d.ts.map +1 -0
  43. package/dist/cjs/resources/nfts.js +62 -0
  44. package/dist/cjs/resources/nfts.js.map +1 -0
  45. package/dist/cjs/resources/schedules.d.ts +36 -0
  46. package/dist/cjs/resources/schedules.d.ts.map +1 -0
  47. package/dist/cjs/resources/schedules.js +53 -0
  48. package/dist/cjs/resources/schedules.js.map +1 -0
  49. package/dist/cjs/resources/tokens.d.ts +36 -0
  50. package/dist/cjs/resources/tokens.d.ts.map +1 -0
  51. package/dist/cjs/resources/tokens.js +53 -0
  52. package/dist/cjs/resources/tokens.js.map +1 -0
  53. package/dist/cjs/resources/topics.d.ts +38 -0
  54. package/dist/cjs/resources/topics.d.ts.map +1 -0
  55. package/dist/cjs/resources/topics.js +56 -0
  56. package/dist/cjs/resources/topics.js.map +1 -0
  57. package/dist/cjs/resources/transactions.d.ts +35 -0
  58. package/dist/cjs/resources/transactions.d.ts.map +1 -0
  59. package/dist/cjs/resources/transactions.js +57 -0
  60. package/dist/cjs/resources/transactions.js.map +1 -0
  61. package/dist/cjs/types/api.d.ts +302 -0
  62. package/dist/cjs/types/api.d.ts.map +1 -0
  63. package/dist/cjs/types/api.js +4 -0
  64. package/dist/cjs/types/api.js.map +1 -0
  65. package/dist/cjs/types/common.d.ts +52 -0
  66. package/dist/cjs/types/common.d.ts.map +1 -0
  67. package/dist/cjs/types/common.js +16 -0
  68. package/dist/cjs/types/common.js.map +1 -0
  69. package/dist/esm/client/HieroClient.d.ts +70 -0
  70. package/dist/esm/client/HieroClient.d.ts.map +1 -0
  71. package/dist/esm/client/HieroClient.js +161 -0
  72. package/dist/esm/client/HieroClient.js.map +1 -0
  73. package/dist/esm/client/rateLimiter.d.ts +33 -0
  74. package/dist/esm/client/rateLimiter.d.ts.map +1 -0
  75. package/dist/esm/client/rateLimiter.js +64 -0
  76. package/dist/esm/client/rateLimiter.js.map +1 -0
  77. package/dist/esm/client/types.d.ts +26 -0
  78. package/dist/esm/client/types.d.ts.map +1 -0
  79. package/dist/esm/client/types.js +8 -0
  80. package/dist/esm/client/types.js.map +1 -0
  81. package/dist/esm/errors/index.d.ts +95 -0
  82. package/dist/esm/errors/index.d.ts.map +1 -0
  83. package/dist/esm/errors/index.js +108 -0
  84. package/dist/esm/errors/index.js.map +1 -0
  85. package/dist/esm/index.d.ts +36 -0
  86. package/dist/esm/index.d.ts.map +1 -0
  87. package/dist/esm/index.js +37 -0
  88. package/dist/esm/index.js.map +1 -0
  89. package/dist/esm/pagination/paginator.d.ts +21 -0
  90. package/dist/esm/pagination/paginator.d.ts.map +1 -0
  91. package/dist/esm/pagination/paginator.js +86 -0
  92. package/dist/esm/pagination/paginator.js.map +1 -0
  93. package/dist/esm/resources/accounts.d.ts +43 -0
  94. package/dist/esm/resources/accounts.d.ts.map +1 -0
  95. package/dist/esm/resources/accounts.js +56 -0
  96. package/dist/esm/resources/accounts.js.map +1 -0
  97. package/dist/esm/resources/balances.d.ts +25 -0
  98. package/dist/esm/resources/balances.d.ts.map +1 -0
  99. package/dist/esm/resources/balances.js +29 -0
  100. package/dist/esm/resources/balances.js.map +1 -0
  101. package/dist/esm/resources/blocks.d.ts +36 -0
  102. package/dist/esm/resources/blocks.d.ts.map +1 -0
  103. package/dist/esm/resources/blocks.js +54 -0
  104. package/dist/esm/resources/blocks.js.map +1 -0
  105. package/dist/esm/resources/contracts.d.ts +36 -0
  106. package/dist/esm/resources/contracts.d.ts.map +1 -0
  107. package/dist/esm/resources/contracts.js +49 -0
  108. package/dist/esm/resources/contracts.js.map +1 -0
  109. package/dist/esm/resources/nfts.d.ts +39 -0
  110. package/dist/esm/resources/nfts.d.ts.map +1 -0
  111. package/dist/esm/resources/nfts.js +58 -0
  112. package/dist/esm/resources/nfts.js.map +1 -0
  113. package/dist/esm/resources/schedules.d.ts +36 -0
  114. package/dist/esm/resources/schedules.d.ts.map +1 -0
  115. package/dist/esm/resources/schedules.js +49 -0
  116. package/dist/esm/resources/schedules.js.map +1 -0
  117. package/dist/esm/resources/tokens.d.ts +36 -0
  118. package/dist/esm/resources/tokens.d.ts.map +1 -0
  119. package/dist/esm/resources/tokens.js +49 -0
  120. package/dist/esm/resources/tokens.js.map +1 -0
  121. package/dist/esm/resources/topics.d.ts +38 -0
  122. package/dist/esm/resources/topics.d.ts.map +1 -0
  123. package/dist/esm/resources/topics.js +52 -0
  124. package/dist/esm/resources/topics.js.map +1 -0
  125. package/dist/esm/resources/transactions.d.ts +35 -0
  126. package/dist/esm/resources/transactions.d.ts.map +1 -0
  127. package/dist/esm/resources/transactions.js +53 -0
  128. package/dist/esm/resources/transactions.js.map +1 -0
  129. package/dist/esm/types/api.d.ts +302 -0
  130. package/dist/esm/types/api.d.ts.map +1 -0
  131. package/dist/esm/types/api.js +3 -0
  132. package/dist/esm/types/api.js.map +1 -0
  133. package/dist/esm/types/common.d.ts +52 -0
  134. package/dist/esm/types/common.d.ts.map +1 -0
  135. package/dist/esm/types/common.js +13 -0
  136. package/dist/esm/types/common.js.map +1 -0
  137. package/package.json +52 -0
@@ -0,0 +1,33 @@
1
+ /**
2
+ * A simple token-bucket rate limiter that throttles requests
3
+ * to stay within a specified requests-per-second limit.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * const limiter = new RateLimiter(10); // 10 req/s
8
+ * await limiter.acquire(); // waits if needed
9
+ * ```
10
+ */
11
+ export declare class RateLimiter {
12
+ private tokens;
13
+ private lastRefill;
14
+ private readonly maxTokens;
15
+ private readonly refillRateMs;
16
+ /**
17
+ * Creates a new rate limiter.
18
+ *
19
+ * @param maxRequestsPerSecond - Maximum number of requests allowed per second
20
+ * @throws {Error} If maxRequestsPerSecond is not a positive number
21
+ */
22
+ constructor(maxRequestsPerSecond: number);
23
+ /**
24
+ * Acquires a token, waiting if necessary until one becomes available.
25
+ * Call this before each HTTP request.
26
+ *
27
+ * @returns A promise that resolves when a token is acquired
28
+ */
29
+ acquire(): Promise<void>;
30
+ private refill;
31
+ private sleep;
32
+ }
33
+ //# sourceMappingURL=rateLimiter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rateLimiter.d.ts","sourceRoot":"","sources":["../../../src/client/rateLimiter.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IAEtC;;;;;OAKG;gBACS,oBAAoB,EAAE,MAAM;IAYxC;;;;;OAKG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAiB9B,OAAO,CAAC,MAAM;IAQd,OAAO,CAAC,KAAK;CAKd"}
@@ -0,0 +1,64 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ /**
3
+ * A simple token-bucket rate limiter that throttles requests
4
+ * to stay within a specified requests-per-second limit.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * const limiter = new RateLimiter(10); // 10 req/s
9
+ * await limiter.acquire(); // waits if needed
10
+ * ```
11
+ */
12
+ export class RateLimiter {
13
+ tokens;
14
+ lastRefill;
15
+ maxTokens;
16
+ refillRateMs;
17
+ /**
18
+ * Creates a new rate limiter.
19
+ *
20
+ * @param maxRequestsPerSecond - Maximum number of requests allowed per second
21
+ * @throws {Error} If maxRequestsPerSecond is not a positive number
22
+ */
23
+ constructor(maxRequestsPerSecond) {
24
+ if (maxRequestsPerSecond <= 0) {
25
+ throw new Error(`maxRequestsPerSecond must be positive, got ${maxRequestsPerSecond}`);
26
+ }
27
+ this.maxTokens = maxRequestsPerSecond;
28
+ this.tokens = maxRequestsPerSecond;
29
+ this.lastRefill = Date.now();
30
+ this.refillRateMs = 1000 / maxRequestsPerSecond;
31
+ }
32
+ /**
33
+ * Acquires a token, waiting if necessary until one becomes available.
34
+ * Call this before each HTTP request.
35
+ *
36
+ * @returns A promise that resolves when a token is acquired
37
+ */
38
+ async acquire() {
39
+ this.refill();
40
+ if (this.tokens >= 1) {
41
+ this.tokens -= 1;
42
+ return;
43
+ }
44
+ const waitMs = this.refillRateMs - (Date.now() - this.lastRefill);
45
+ if (waitMs > 0) {
46
+ await this.sleep(waitMs);
47
+ }
48
+ this.refill();
49
+ this.tokens = Math.max(0, this.tokens - 1);
50
+ }
51
+ refill() {
52
+ const now = Date.now();
53
+ const elapsed = now - this.lastRefill;
54
+ const tokensToAdd = elapsed / this.refillRateMs;
55
+ this.tokens = Math.min(this.maxTokens, this.tokens + tokensToAdd);
56
+ this.lastRefill = now;
57
+ }
58
+ sleep(ms) {
59
+ return new Promise((resolve) => {
60
+ setTimeout(resolve, ms);
61
+ });
62
+ }
63
+ }
64
+ //# sourceMappingURL=rateLimiter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rateLimiter.js","sourceRoot":"","sources":["../../../src/client/rateLimiter.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;;;;;;;GASG;AACH,MAAM,OAAO,WAAW;IACd,MAAM,CAAS;IACf,UAAU,CAAS;IACV,SAAS,CAAS;IAClB,YAAY,CAAS;IAEtC;;;;;OAKG;IACH,YAAY,oBAA4B;QACtC,IAAI,oBAAoB,IAAI,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CACb,8CAA8C,oBAAoB,EAAE,CACrE,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,SAAS,GAAG,oBAAoB,CAAC;QACtC,IAAI,CAAC,MAAM,GAAG,oBAAoB,CAAC;QACnC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC7B,IAAI,CAAC,YAAY,GAAG,IAAI,GAAG,oBAAoB,CAAC;IAClD,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,OAAO;QACX,IAAI,CAAC,MAAM,EAAE,CAAC;QAEd,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;YACrB,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC;YACjB,OAAO;QACT,CAAC;QAED,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC;QAClE,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;YACf,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC3B,CAAC;QAED,IAAI,CAAC,MAAM,EAAE,CAAC;QACd,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC7C,CAAC;IAEO,MAAM;QACZ,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvB,MAAM,OAAO,GAAG,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC;QACtC,MAAM,WAAW,GAAG,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC;QAChD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,GAAG,WAAW,CAAC,CAAC;QAClE,IAAI,CAAC,UAAU,GAAG,GAAG,CAAC;IACxB,CAAC;IAEO,KAAK,CAAC,EAAU;QACtB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC7B,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAC1B,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Configuration for the HieroClient.
3
+ */
4
+ export interface HieroClientConfig {
5
+ /** The Mirror Node base URL (no trailing slash) */
6
+ baseUrl: string;
7
+ /** Maximum requests per second for rate limiting (default: 20) */
8
+ maxRequestsPerSecond?: number;
9
+ /** Custom fetch implementation — useful for testing */
10
+ fetch?: typeof globalThis.fetch;
11
+ /** Default headers to include in all requests */
12
+ headers?: Record<string, string>;
13
+ /** Request timeout in milliseconds (default: 30000) */
14
+ timeoutMs?: number;
15
+ /** Maximum number of retries for retriable errors (default: 3) */
16
+ maxRetries?: number;
17
+ }
18
+ /** Pre-configured network endpoints for the Hedera Mirror Node */
19
+ export declare const Networks: {
20
+ readonly mainnet: "https://mainnet.mirrornode.hedera.com";
21
+ readonly testnet: "https://testnet.mirrornode.hedera.com";
22
+ readonly previewnet: "https://previewnet.mirrornode.hedera.com";
23
+ };
24
+ /** Network name keys */
25
+ export type NetworkName = keyof typeof Networks;
26
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/client/types.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,mDAAmD;IACnD,OAAO,EAAE,MAAM,CAAC;IAChB,kEAAkE;IAClE,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,uDAAuD;IACvD,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IAChC,iDAAiD;IACjD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,uDAAuD;IACvD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kEAAkE;IAClE,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,kEAAkE;AAClE,eAAO,MAAM,QAAQ;;;;CAIsB,CAAC;AAE5C,wBAAwB;AACxB,MAAM,MAAM,WAAW,GAAG,MAAM,OAAO,QAAQ,CAAC"}
@@ -0,0 +1,8 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ /** Pre-configured network endpoints for the Hedera Mirror Node */
3
+ export const Networks = {
4
+ mainnet: 'https://mainnet.mirrornode.hedera.com',
5
+ testnet: 'https://testnet.mirrornode.hedera.com',
6
+ previewnet: 'https://previewnet.mirrornode.hedera.com',
7
+ };
8
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/client/types.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAoBtC,kEAAkE;AAClE,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,OAAO,EAAE,uCAAuC;IAChD,OAAO,EAAE,uCAAuC;IAChD,UAAU,EAAE,0CAA0C;CACb,CAAC"}
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Base error class for all hiero-sdk-utils errors.
3
+ * All errors thrown by this library extend this class.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * try {
8
+ * await client.accounts.getById('invalid');
9
+ * } catch (error) {
10
+ * if (error instanceof HieroError) {
11
+ * console.log(error.code); // e.g., 'INVALID_ACCOUNT_ID'
12
+ * }
13
+ * }
14
+ * ```
15
+ */
16
+ export declare class HieroError extends Error {
17
+ readonly code: string;
18
+ /**
19
+ * @param message - Human-readable error description
20
+ * @param code - Machine-readable error code (e.g., 'ACCOUNT_NOT_FOUND')
21
+ * @param options - Standard ErrorOptions including cause chain
22
+ */
23
+ constructor(message: string, code: string, options?: ErrorOptions);
24
+ }
25
+ /**
26
+ * Error thrown when the Mirror Node API returns an error response.
27
+ * Includes the HTTP status code for programmatic handling.
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * try {
32
+ * await client.accounts.getById('0.0.99999999999');
33
+ * } catch (error) {
34
+ * if (error instanceof MirrorNodeError) {
35
+ * console.log(error.status); // 404
36
+ * console.log(error.code); // 'MIRROR_NODE_ERROR'
37
+ * }
38
+ * }
39
+ * ```
40
+ */
41
+ export declare class MirrorNodeError extends HieroError {
42
+ readonly status: number;
43
+ /**
44
+ * @param message - Human-readable error description
45
+ * @param code - Machine-readable error code
46
+ * @param status - HTTP status code from the Mirror Node response
47
+ * @param options - Standard ErrorOptions including cause chain
48
+ */
49
+ constructor(message: string, code: string, status: number, options?: ErrorOptions);
50
+ }
51
+ /**
52
+ * Error thrown when input validation fails before making a network request.
53
+ *
54
+ * @example
55
+ * ```ts
56
+ * try {
57
+ * await client.accounts.getById('not-an-id');
58
+ * } catch (error) {
59
+ * if (error instanceof ValidationError) {
60
+ * console.log(error.code); // 'INVALID_ACCOUNT_ID'
61
+ * }
62
+ * }
63
+ * ```
64
+ */
65
+ export declare class ValidationError extends HieroError {
66
+ /**
67
+ * @param message - Human-readable description of what was invalid
68
+ * @param code - Machine-readable error code
69
+ * @param options - Standard ErrorOptions including cause chain
70
+ */
71
+ constructor(message: string, code: string, options?: ErrorOptions);
72
+ }
73
+ /**
74
+ * Error thrown when pagination encounters an unexpected state.
75
+ *
76
+ * @example
77
+ * ```ts
78
+ * try {
79
+ * for await (const item of client.accounts.list()) { ... }
80
+ * } catch (error) {
81
+ * if (error instanceof PaginationError) {
82
+ * console.log(error.code); // 'INVALID_RESPONSE_SHAPE'
83
+ * }
84
+ * }
85
+ * ```
86
+ */
87
+ export declare class PaginationError extends HieroError {
88
+ /**
89
+ * @param message - Human-readable description of the pagination failure
90
+ * @param code - Machine-readable error code
91
+ * @param options - Standard ErrorOptions including cause chain
92
+ */
93
+ constructor(message: string, code: string, options?: ErrorOptions);
94
+ }
95
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/errors/index.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AACH,qBAAa,UAAW,SAAQ,KAAK;aAQjB,IAAI,EAAE,MAAM;IAP9B;;;;OAIG;gBAED,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,MAAM,EAC5B,OAAO,CAAC,EAAE,YAAY;CAMzB;AAED;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,eAAgB,SAAQ,UAAU;aAU3B,MAAM,EAAE,MAAM;IAThC;;;;;OAKG;gBAED,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACI,MAAM,EAAE,MAAM,EAC9B,OAAO,CAAC,EAAE,YAAY;CAIzB;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,eAAgB,SAAQ,UAAU;IAC7C;;;;OAIG;gBACS,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAGlE;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,eAAgB,SAAQ,UAAU;IAC7C;;;;OAIG;gBACS,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAGlE"}
@@ -0,0 +1,108 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ /**
3
+ * Base error class for all hiero-sdk-utils errors.
4
+ * All errors thrown by this library extend this class.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * try {
9
+ * await client.accounts.getById('invalid');
10
+ * } catch (error) {
11
+ * if (error instanceof HieroError) {
12
+ * console.log(error.code); // e.g., 'INVALID_ACCOUNT_ID'
13
+ * }
14
+ * }
15
+ * ```
16
+ */
17
+ export class HieroError extends Error {
18
+ code;
19
+ /**
20
+ * @param message - Human-readable error description
21
+ * @param code - Machine-readable error code (e.g., 'ACCOUNT_NOT_FOUND')
22
+ * @param options - Standard ErrorOptions including cause chain
23
+ */
24
+ constructor(message, code, options) {
25
+ super(message, options);
26
+ this.code = code;
27
+ this.name = this.constructor.name;
28
+ Object.setPrototypeOf(this, new.target.prototype);
29
+ }
30
+ }
31
+ /**
32
+ * Error thrown when the Mirror Node API returns an error response.
33
+ * Includes the HTTP status code for programmatic handling.
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * try {
38
+ * await client.accounts.getById('0.0.99999999999');
39
+ * } catch (error) {
40
+ * if (error instanceof MirrorNodeError) {
41
+ * console.log(error.status); // 404
42
+ * console.log(error.code); // 'MIRROR_NODE_ERROR'
43
+ * }
44
+ * }
45
+ * ```
46
+ */
47
+ export class MirrorNodeError extends HieroError {
48
+ status;
49
+ /**
50
+ * @param message - Human-readable error description
51
+ * @param code - Machine-readable error code
52
+ * @param status - HTTP status code from the Mirror Node response
53
+ * @param options - Standard ErrorOptions including cause chain
54
+ */
55
+ constructor(message, code, status, options) {
56
+ super(message, code, options);
57
+ this.status = status;
58
+ }
59
+ }
60
+ /**
61
+ * Error thrown when input validation fails before making a network request.
62
+ *
63
+ * @example
64
+ * ```ts
65
+ * try {
66
+ * await client.accounts.getById('not-an-id');
67
+ * } catch (error) {
68
+ * if (error instanceof ValidationError) {
69
+ * console.log(error.code); // 'INVALID_ACCOUNT_ID'
70
+ * }
71
+ * }
72
+ * ```
73
+ */
74
+ export class ValidationError extends HieroError {
75
+ /**
76
+ * @param message - Human-readable description of what was invalid
77
+ * @param code - Machine-readable error code
78
+ * @param options - Standard ErrorOptions including cause chain
79
+ */
80
+ constructor(message, code, options) {
81
+ super(message, code, options);
82
+ }
83
+ }
84
+ /**
85
+ * Error thrown when pagination encounters an unexpected state.
86
+ *
87
+ * @example
88
+ * ```ts
89
+ * try {
90
+ * for await (const item of client.accounts.list()) { ... }
91
+ * } catch (error) {
92
+ * if (error instanceof PaginationError) {
93
+ * console.log(error.code); // 'INVALID_RESPONSE_SHAPE'
94
+ * }
95
+ * }
96
+ * ```
97
+ */
98
+ export class PaginationError extends HieroError {
99
+ /**
100
+ * @param message - Human-readable description of the pagination failure
101
+ * @param code - Machine-readable error code
102
+ * @param options - Standard ErrorOptions including cause chain
103
+ */
104
+ constructor(message, code, options) {
105
+ super(message, code, options);
106
+ }
107
+ }
108
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/errors/index.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,UAAW,SAAQ,KAAK;IAQjB;IAPlB;;;;OAIG;IACH,YACE,OAAe,EACC,IAAY,EAC5B,OAAsB;QAEtB,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAHR,SAAI,GAAJ,IAAI,CAAQ;QAI5B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;QAClC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACpD,CAAC;CACF;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,eAAgB,SAAQ,UAAU;IAU3B;IATlB;;;;;OAKG;IACH,YACE,OAAe,EACf,IAAY,EACI,MAAc,EAC9B,OAAsB;QAEtB,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QAHd,WAAM,GAAN,MAAM,CAAQ;IAIhC,CAAC;CACF;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,eAAgB,SAAQ,UAAU;IAC7C;;;;OAIG;IACH,YAAY,OAAe,EAAE,IAAY,EAAE,OAAsB;QAC/D,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAChC,CAAC;CACF;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,eAAgB,SAAQ,UAAU;IAC7C;;;;OAIG;IACH,YAAY,OAAe,EAAE,IAAY,EAAE,OAAsB;QAC/D,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAChC,CAAC;CACF"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * hiero-sdk-utils — TypeScript utilities for the Hedera/Hiero Mirror Node.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * import { HieroClient, Networks } from 'hiero-sdk-utils';
7
+ *
8
+ * const client = new HieroClient({ baseUrl: Networks.testnet });
9
+ *
10
+ * // Fetch a single account
11
+ * const account = await client.accounts.getById('0.0.1234');
12
+ *
13
+ * // Iterate through accounts with auto-pagination
14
+ * for await (const a of client.accounts.list({ limit: 10 })) {
15
+ * console.log(a.account, a.balance.balance);
16
+ * }
17
+ * ```
18
+ *
19
+ * @packageDocumentation
20
+ */
21
+ export { HieroClient } from './client/HieroClient.js';
22
+ export { Networks } from './client/types.js';
23
+ export type { HieroClientConfig, NetworkName } from './client/types.js';
24
+ export { HieroError, MirrorNodeError, ValidationError, PaginationError, } from './errors/index.js';
25
+ export { AccountsResource } from './resources/accounts.js';
26
+ export { TransactionsResource } from './resources/transactions.js';
27
+ export { TokensResource } from './resources/tokens.js';
28
+ export { TopicsResource } from './resources/topics.js';
29
+ export { ContractsResource } from './resources/contracts.js';
30
+ export { NftsResource } from './resources/nfts.js';
31
+ export { BalancesResource } from './resources/balances.js';
32
+ export { BlocksResource } from './resources/blocks.js';
33
+ export { SchedulesResource } from './resources/schedules.js';
34
+ export type { AccountInfo, AccountBalance, AccountsQueryParams, TransactionInfo, TransactionsQueryParams, Transfer, TokenTransfer, NftTransfer, TokenInfo, TokensQueryParams, TokenBalance, TopicInfo, TopicMessage, TopicMessagesQueryParams, ContractInfo, ContractsQueryParams, CustomFee, FixedFee, FractionalFee, FractionalAmount, RoyaltyFee, NftInfo, NftsQueryParams, BalanceEntry, BalancesQueryParams, BlockInfo, BlocksQueryParams, ScheduleInfo, SchedulesQueryParams, Key, } from './types/api.js';
35
+ export type { BaseQueryParams, TimestampFilter, PaginationLinks, } from './types/common.js';
36
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGxE,OAAO,EACL,UAAU,EACV,eAAe,EACf,eAAe,EACf,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAG7D,YAAY,EACV,WAAW,EACX,cAAc,EACd,mBAAmB,EACnB,eAAe,EACf,uBAAuB,EACvB,QAAQ,EACR,aAAa,EACb,WAAW,EACX,SAAS,EACT,iBAAiB,EACjB,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,wBAAwB,EACxB,YAAY,EACZ,oBAAoB,EACpB,SAAS,EACT,QAAQ,EACR,aAAa,EACb,gBAAgB,EAChB,UAAU,EACV,OAAO,EACP,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,SAAS,EACT,iBAAiB,EACjB,YAAY,EACZ,oBAAoB,EACpB,GAAG,GACJ,MAAM,gBAAgB,CAAC;AAExB,YAAY,EACV,eAAe,EACf,eAAe,EACf,eAAe,GAChB,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,37 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ /**
3
+ * hiero-sdk-utils — TypeScript utilities for the Hedera/Hiero Mirror Node.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * import { HieroClient, Networks } from 'hiero-sdk-utils';
8
+ *
9
+ * const client = new HieroClient({ baseUrl: Networks.testnet });
10
+ *
11
+ * // Fetch a single account
12
+ * const account = await client.accounts.getById('0.0.1234');
13
+ *
14
+ * // Iterate through accounts with auto-pagination
15
+ * for await (const a of client.accounts.list({ limit: 10 })) {
16
+ * console.log(a.account, a.balance.balance);
17
+ * }
18
+ * ```
19
+ *
20
+ * @packageDocumentation
21
+ */
22
+ // Client
23
+ export { HieroClient } from './client/HieroClient.js';
24
+ export { Networks } from './client/types.js';
25
+ // Errors
26
+ export { HieroError, MirrorNodeError, ValidationError, PaginationError, } from './errors/index.js';
27
+ // Resources
28
+ export { AccountsResource } from './resources/accounts.js';
29
+ export { TransactionsResource } from './resources/transactions.js';
30
+ export { TokensResource } from './resources/tokens.js';
31
+ export { TopicsResource } from './resources/topics.js';
32
+ export { ContractsResource } from './resources/contracts.js';
33
+ export { NftsResource } from './resources/nfts.js';
34
+ export { BalancesResource } from './resources/balances.js';
35
+ export { BlocksResource } from './resources/blocks.js';
36
+ export { SchedulesResource } from './resources/schedules.js';
37
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,SAAS;AACT,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAG7C,SAAS;AACT,OAAO,EACL,UAAU,EACV,eAAe,EACf,eAAe,EACf,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAE3B,YAAY;AACZ,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { HieroClient } from '../client/HieroClient.js';
2
+ /**
3
+ * Creates an async generator that paginates through a Mirror Node list endpoint.
4
+ * Follows the `links.next` field to automatically fetch subsequent pages.
5
+ *
6
+ * @param client - The HieroClient instance to use for HTTP requests
7
+ * @param path - The API path for the list endpoint (e.g., '/api/v1/accounts')
8
+ * @param dataKey - The key in the response object that contains the data array (e.g., 'accounts')
9
+ * @param params - Optional query parameters for filtering/sorting
10
+ * @returns An async generator that yields individual items of type T
11
+ * @throws {PaginationError} If the response shape is unexpected
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * for await (const account of paginate<AccountInfo>(client, '/api/v1/accounts', 'accounts')) {
16
+ * console.log(account.account);
17
+ * }
18
+ * ```
19
+ */
20
+ export declare function paginate<T>(client: HieroClient, path: string, dataKey: string, params?: Record<string, string | number | boolean | undefined>): AsyncGenerator<T, void, undefined>;
21
+ //# sourceMappingURL=paginator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paginator.d.ts","sourceRoot":"","sources":["../../../src/pagination/paginator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AA+C5D;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAuB,QAAQ,CAAC,CAAC,EAC/B,MAAM,EAAE,WAAW,EACnB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,GAC7D,cAAc,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,CAkCpC"}
@@ -0,0 +1,86 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ import { PaginationError } from '../errors/index.js';
3
+ /**
4
+ * Builds a query string from parameters.
5
+ *
6
+ * @param path - The base API path
7
+ * @param params - Optional key-value query parameters
8
+ * @returns The full path with query string appended
9
+ */
10
+ function buildUrl(path, params) {
11
+ if (!params) {
12
+ return path;
13
+ }
14
+ const searchParams = new URLSearchParams();
15
+ for (const [key, value] of Object.entries(params)) {
16
+ if (value !== undefined) {
17
+ searchParams.set(key, String(value));
18
+ }
19
+ }
20
+ const queryString = searchParams.toString();
21
+ return queryString ? `${path}?${queryString}` : path;
22
+ }
23
+ /**
24
+ * Extracts the `links.next` value from a Mirror Node paginated response.
25
+ *
26
+ * @param body - The raw JSON response object
27
+ * @returns The next page URL or null
28
+ */
29
+ function extractNextLink(body) {
30
+ const links = body['links'];
31
+ if (links !== null && typeof links === 'object' && !Array.isArray(links)) {
32
+ const linksObj = links;
33
+ const next = linksObj['next'];
34
+ if (typeof next === 'string' && next.length > 0) {
35
+ return next;
36
+ }
37
+ }
38
+ return null;
39
+ }
40
+ /**
41
+ * Creates an async generator that paginates through a Mirror Node list endpoint.
42
+ * Follows the `links.next` field to automatically fetch subsequent pages.
43
+ *
44
+ * @param client - The HieroClient instance to use for HTTP requests
45
+ * @param path - The API path for the list endpoint (e.g., '/api/v1/accounts')
46
+ * @param dataKey - The key in the response object that contains the data array (e.g., 'accounts')
47
+ * @param params - Optional query parameters for filtering/sorting
48
+ * @returns An async generator that yields individual items of type T
49
+ * @throws {PaginationError} If the response shape is unexpected
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * for await (const account of paginate<AccountInfo>(client, '/api/v1/accounts', 'accounts')) {
54
+ * console.log(account.account);
55
+ * }
56
+ * ```
57
+ */
58
+ export async function* paginate(client, path, dataKey, params) {
59
+ let url = buildUrl(path, params);
60
+ while (url !== null) {
61
+ const body = await client.get(url);
62
+ const items = body[dataKey];
63
+ if (!Array.isArray(items)) {
64
+ throw new PaginationError(`Expected array at key "${dataKey}" in response from ${url}, got ${typeof items}`, 'INVALID_RESPONSE_SHAPE');
65
+ }
66
+ for (const item of items) {
67
+ yield item;
68
+ }
69
+ // If the page was empty, stop regardless of links
70
+ if (items.length === 0) {
71
+ break;
72
+ }
73
+ const nextLink = extractNextLink(body);
74
+ if (nextLink === null) {
75
+ url = null;
76
+ }
77
+ else if (nextLink.startsWith('http')) {
78
+ url = nextLink;
79
+ }
80
+ else {
81
+ // Relative URL from the Mirror Node
82
+ url = nextLink.startsWith('/') ? nextLink : `/${nextLink}`;
83
+ }
84
+ }
85
+ }
86
+ //# sourceMappingURL=paginator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paginator.js","sourceRoot":"","sources":["../../../src/pagination/paginator.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAGtC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD;;;;;;GAMG;AACH,SAAS,QAAQ,CACf,IAAY,EACZ,MAA8D;IAE9D,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,YAAY,GAAG,IAAI,eAAe,EAAE,CAAC;IAC3C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAClD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;IAED,MAAM,WAAW,GAAG,YAAY,CAAC,QAAQ,EAAE,CAAC;IAC5C,OAAO,WAAW,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,WAAW,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AACvD,CAAC;AAED;;;;;GAKG;AACH,SAAS,eAAe,CAAC,IAA6B;IACpD,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;IAC5B,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzE,MAAM,QAAQ,GAAG,KAAgC,CAAC;QAClD,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;QAC9B,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAChD,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,QAAQ,CAC7B,MAAmB,EACnB,IAAY,EACZ,OAAe,EACf,MAA8D;IAE9D,IAAI,GAAG,GAAkB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAEhD,OAAO,GAAG,KAAK,IAAI,EAAE,CAAC;QACpB,MAAM,IAAI,GAA4B,MAAM,MAAM,CAAC,GAAG,CAA0B,GAAG,CAAC,CAAC;QACrF,MAAM,KAAK,GAAY,IAAI,CAAC,OAAO,CAAC,CAAC;QAErC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAC1B,MAAM,IAAI,eAAe,CACvB,0BAA0B,OAAO,sBAAsB,GAAG,SAAS,OAAO,KAAK,EAAE,EACjF,wBAAwB,CACzB,CAAC;QACJ,CAAC;QAED,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,IAAS,CAAC;QAClB,CAAC;QAED,kDAAkD;QAClD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvB,MAAM;QACR,CAAC;QAED,MAAM,QAAQ,GAAkB,eAAe,CAAC,IAAI,CAAC,CAAC;QAEtD,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;YACtB,GAAG,GAAG,IAAI,CAAC;QACb,CAAC;aAAM,IAAI,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;YACvC,GAAG,GAAG,QAAQ,CAAC;QACjB,CAAC;aAAM,CAAC;YACN,oCAAoC;YACpC,GAAG,GAAG,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,QAAQ,EAAE,CAAC;QAC7D,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,43 @@
1
+ import type { HieroClient } from '../client/HieroClient.js';
2
+ import type { AccountInfo, AccountsQueryParams } from '../types/api.js';
3
+ /**
4
+ * Provides access to Mirror Node account endpoints.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * const account = await client.accounts.getById('0.0.1234');
9
+ * for await (const a of client.accounts.list({ limit: 10 })) {
10
+ * console.log(a.account);
11
+ * }
12
+ * ```
13
+ */
14
+ export declare class AccountsResource {
15
+ private readonly client;
16
+ constructor(client: HieroClient);
17
+ /**
18
+ * Retrieves a single account by ID.
19
+ *
20
+ * @param accountId - Account in `0.0.X` format
21
+ * @returns The account info including balance, key, and staking data
22
+ * @throws {ValidationError} If accountId format is invalid
23
+ * @throws {MirrorNodeError} If the API request fails
24
+ */
25
+ getById(accountId: string): Promise<AccountInfo>;
26
+ /**
27
+ * Lists accounts with optional filters. Returns an async iterable
28
+ * that automatically handles pagination.
29
+ *
30
+ * @param params - Optional query parameters for filtering
31
+ * @returns Async iterable of account info objects
32
+ *
33
+ * @example
34
+ * ```ts
35
+ * for await (const account of client.accounts.list({ limit: 5, order: 'desc' })) {
36
+ * console.log(account.account, account.balance.balance);
37
+ * }
38
+ * ```
39
+ */
40
+ list(params?: AccountsQueryParams): AsyncIterable<AccountInfo>;
41
+ private validateAccountId;
42
+ }
43
+ //# sourceMappingURL=accounts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../../src/resources/accounts.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAKxE;;;;;;;;;;GAUG;AACH,qBAAa,gBAAgB;IACf,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,WAAW;IAEhD;;;;;;;OAOG;IACG,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAKtD;;;;;;;;;;;;;OAaG;IACH,IAAI,CAAC,MAAM,CAAC,EAAE,mBAAmB,GAAG,aAAa,CAAC,WAAW,CAAC;IAS9D,OAAO,CAAC,iBAAiB;CAQ1B"}