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.
- package/dist/cjs/client/HieroClient.d.ts +70 -0
- package/dist/cjs/client/HieroClient.d.ts.map +1 -0
- package/dist/cjs/client/HieroClient.js +165 -0
- package/dist/cjs/client/HieroClient.js.map +1 -0
- package/dist/cjs/client/rateLimiter.d.ts +33 -0
- package/dist/cjs/client/rateLimiter.d.ts.map +1 -0
- package/dist/cjs/client/rateLimiter.js +68 -0
- package/dist/cjs/client/rateLimiter.js.map +1 -0
- package/dist/cjs/client/types.d.ts +26 -0
- package/dist/cjs/client/types.d.ts.map +1 -0
- package/dist/cjs/client/types.js +11 -0
- package/dist/cjs/client/types.js.map +1 -0
- package/dist/cjs/errors/index.d.ts +95 -0
- package/dist/cjs/errors/index.d.ts.map +1 -0
- package/dist/cjs/errors/index.js +115 -0
- package/dist/cjs/errors/index.js.map +1 -0
- package/dist/cjs/index.d.ts +36 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +55 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/pagination/paginator.d.ts +21 -0
- package/dist/cjs/pagination/paginator.d.ts.map +1 -0
- package/dist/cjs/pagination/paginator.js +89 -0
- package/dist/cjs/pagination/paginator.js.map +1 -0
- package/dist/cjs/resources/accounts.d.ts +43 -0
- package/dist/cjs/resources/accounts.d.ts.map +1 -0
- package/dist/cjs/resources/accounts.js +60 -0
- package/dist/cjs/resources/accounts.js.map +1 -0
- package/dist/cjs/resources/balances.d.ts +25 -0
- package/dist/cjs/resources/balances.d.ts.map +1 -0
- package/dist/cjs/resources/balances.js +33 -0
- package/dist/cjs/resources/balances.js.map +1 -0
- package/dist/cjs/resources/blocks.d.ts +36 -0
- package/dist/cjs/resources/blocks.d.ts.map +1 -0
- package/dist/cjs/resources/blocks.js +58 -0
- package/dist/cjs/resources/blocks.js.map +1 -0
- package/dist/cjs/resources/contracts.d.ts +36 -0
- package/dist/cjs/resources/contracts.d.ts.map +1 -0
- package/dist/cjs/resources/contracts.js +53 -0
- package/dist/cjs/resources/contracts.js.map +1 -0
- package/dist/cjs/resources/nfts.d.ts +39 -0
- package/dist/cjs/resources/nfts.d.ts.map +1 -0
- package/dist/cjs/resources/nfts.js +62 -0
- package/dist/cjs/resources/nfts.js.map +1 -0
- package/dist/cjs/resources/schedules.d.ts +36 -0
- package/dist/cjs/resources/schedules.d.ts.map +1 -0
- package/dist/cjs/resources/schedules.js +53 -0
- package/dist/cjs/resources/schedules.js.map +1 -0
- package/dist/cjs/resources/tokens.d.ts +36 -0
- package/dist/cjs/resources/tokens.d.ts.map +1 -0
- package/dist/cjs/resources/tokens.js +53 -0
- package/dist/cjs/resources/tokens.js.map +1 -0
- package/dist/cjs/resources/topics.d.ts +38 -0
- package/dist/cjs/resources/topics.d.ts.map +1 -0
- package/dist/cjs/resources/topics.js +56 -0
- package/dist/cjs/resources/topics.js.map +1 -0
- package/dist/cjs/resources/transactions.d.ts +35 -0
- package/dist/cjs/resources/transactions.d.ts.map +1 -0
- package/dist/cjs/resources/transactions.js +57 -0
- package/dist/cjs/resources/transactions.js.map +1 -0
- package/dist/cjs/types/api.d.ts +302 -0
- package/dist/cjs/types/api.d.ts.map +1 -0
- package/dist/cjs/types/api.js +4 -0
- package/dist/cjs/types/api.js.map +1 -0
- package/dist/cjs/types/common.d.ts +52 -0
- package/dist/cjs/types/common.d.ts.map +1 -0
- package/dist/cjs/types/common.js +16 -0
- package/dist/cjs/types/common.js.map +1 -0
- package/dist/esm/client/HieroClient.d.ts +70 -0
- package/dist/esm/client/HieroClient.d.ts.map +1 -0
- package/dist/esm/client/HieroClient.js +161 -0
- package/dist/esm/client/HieroClient.js.map +1 -0
- package/dist/esm/client/rateLimiter.d.ts +33 -0
- package/dist/esm/client/rateLimiter.d.ts.map +1 -0
- package/dist/esm/client/rateLimiter.js +64 -0
- package/dist/esm/client/rateLimiter.js.map +1 -0
- package/dist/esm/client/types.d.ts +26 -0
- package/dist/esm/client/types.d.ts.map +1 -0
- package/dist/esm/client/types.js +8 -0
- package/dist/esm/client/types.js.map +1 -0
- package/dist/esm/errors/index.d.ts +95 -0
- package/dist/esm/errors/index.d.ts.map +1 -0
- package/dist/esm/errors/index.js +108 -0
- package/dist/esm/errors/index.js.map +1 -0
- package/dist/esm/index.d.ts +36 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +37 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/pagination/paginator.d.ts +21 -0
- package/dist/esm/pagination/paginator.d.ts.map +1 -0
- package/dist/esm/pagination/paginator.js +86 -0
- package/dist/esm/pagination/paginator.js.map +1 -0
- package/dist/esm/resources/accounts.d.ts +43 -0
- package/dist/esm/resources/accounts.d.ts.map +1 -0
- package/dist/esm/resources/accounts.js +56 -0
- package/dist/esm/resources/accounts.js.map +1 -0
- package/dist/esm/resources/balances.d.ts +25 -0
- package/dist/esm/resources/balances.d.ts.map +1 -0
- package/dist/esm/resources/balances.js +29 -0
- package/dist/esm/resources/balances.js.map +1 -0
- package/dist/esm/resources/blocks.d.ts +36 -0
- package/dist/esm/resources/blocks.d.ts.map +1 -0
- package/dist/esm/resources/blocks.js +54 -0
- package/dist/esm/resources/blocks.js.map +1 -0
- package/dist/esm/resources/contracts.d.ts +36 -0
- package/dist/esm/resources/contracts.d.ts.map +1 -0
- package/dist/esm/resources/contracts.js +49 -0
- package/dist/esm/resources/contracts.js.map +1 -0
- package/dist/esm/resources/nfts.d.ts +39 -0
- package/dist/esm/resources/nfts.d.ts.map +1 -0
- package/dist/esm/resources/nfts.js +58 -0
- package/dist/esm/resources/nfts.js.map +1 -0
- package/dist/esm/resources/schedules.d.ts +36 -0
- package/dist/esm/resources/schedules.d.ts.map +1 -0
- package/dist/esm/resources/schedules.js +49 -0
- package/dist/esm/resources/schedules.js.map +1 -0
- package/dist/esm/resources/tokens.d.ts +36 -0
- package/dist/esm/resources/tokens.d.ts.map +1 -0
- package/dist/esm/resources/tokens.js +49 -0
- package/dist/esm/resources/tokens.js.map +1 -0
- package/dist/esm/resources/topics.d.ts +38 -0
- package/dist/esm/resources/topics.d.ts.map +1 -0
- package/dist/esm/resources/topics.js +52 -0
- package/dist/esm/resources/topics.js.map +1 -0
- package/dist/esm/resources/transactions.d.ts +35 -0
- package/dist/esm/resources/transactions.d.ts.map +1 -0
- package/dist/esm/resources/transactions.js +53 -0
- package/dist/esm/resources/transactions.js.map +1 -0
- package/dist/esm/types/api.d.ts +302 -0
- package/dist/esm/types/api.d.ts.map +1 -0
- package/dist/esm/types/api.js +3 -0
- package/dist/esm/types/api.js.map +1 -0
- package/dist/esm/types/common.d.ts +52 -0
- package/dist/esm/types/common.d.ts.map +1 -0
- package/dist/esm/types/common.js +13 -0
- package/dist/esm/types/common.js.map +1 -0
- package/package.json +52 -0
|
@@ -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,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.SchedulesResource = exports.BlocksResource = exports.BalancesResource = exports.NftsResource = exports.ContractsResource = exports.TopicsResource = exports.TokensResource = exports.TransactionsResource = exports.AccountsResource = exports.PaginationError = exports.ValidationError = exports.MirrorNodeError = exports.HieroError = exports.Networks = exports.HieroClient = void 0;
|
|
5
|
+
/**
|
|
6
|
+
* hiero-sdk-utils — TypeScript utilities for the Hedera/Hiero Mirror Node.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { HieroClient, Networks } from 'hiero-sdk-utils';
|
|
11
|
+
*
|
|
12
|
+
* const client = new HieroClient({ baseUrl: Networks.testnet });
|
|
13
|
+
*
|
|
14
|
+
* // Fetch a single account
|
|
15
|
+
* const account = await client.accounts.getById('0.0.1234');
|
|
16
|
+
*
|
|
17
|
+
* // Iterate through accounts with auto-pagination
|
|
18
|
+
* for await (const a of client.accounts.list({ limit: 10 })) {
|
|
19
|
+
* console.log(a.account, a.balance.balance);
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @packageDocumentation
|
|
24
|
+
*/
|
|
25
|
+
// Client
|
|
26
|
+
var HieroClient_js_1 = require("./client/HieroClient.js");
|
|
27
|
+
Object.defineProperty(exports, "HieroClient", { enumerable: true, get: function () { return HieroClient_js_1.HieroClient; } });
|
|
28
|
+
var types_js_1 = require("./client/types.js");
|
|
29
|
+
Object.defineProperty(exports, "Networks", { enumerable: true, get: function () { return types_js_1.Networks; } });
|
|
30
|
+
// Errors
|
|
31
|
+
var index_js_1 = require("./errors/index.js");
|
|
32
|
+
Object.defineProperty(exports, "HieroError", { enumerable: true, get: function () { return index_js_1.HieroError; } });
|
|
33
|
+
Object.defineProperty(exports, "MirrorNodeError", { enumerable: true, get: function () { return index_js_1.MirrorNodeError; } });
|
|
34
|
+
Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function () { return index_js_1.ValidationError; } });
|
|
35
|
+
Object.defineProperty(exports, "PaginationError", { enumerable: true, get: function () { return index_js_1.PaginationError; } });
|
|
36
|
+
// Resources
|
|
37
|
+
var accounts_js_1 = require("./resources/accounts.js");
|
|
38
|
+
Object.defineProperty(exports, "AccountsResource", { enumerable: true, get: function () { return accounts_js_1.AccountsResource; } });
|
|
39
|
+
var transactions_js_1 = require("./resources/transactions.js");
|
|
40
|
+
Object.defineProperty(exports, "TransactionsResource", { enumerable: true, get: function () { return transactions_js_1.TransactionsResource; } });
|
|
41
|
+
var tokens_js_1 = require("./resources/tokens.js");
|
|
42
|
+
Object.defineProperty(exports, "TokensResource", { enumerable: true, get: function () { return tokens_js_1.TokensResource; } });
|
|
43
|
+
var topics_js_1 = require("./resources/topics.js");
|
|
44
|
+
Object.defineProperty(exports, "TopicsResource", { enumerable: true, get: function () { return topics_js_1.TopicsResource; } });
|
|
45
|
+
var contracts_js_1 = require("./resources/contracts.js");
|
|
46
|
+
Object.defineProperty(exports, "ContractsResource", { enumerable: true, get: function () { return contracts_js_1.ContractsResource; } });
|
|
47
|
+
var nfts_js_1 = require("./resources/nfts.js");
|
|
48
|
+
Object.defineProperty(exports, "NftsResource", { enumerable: true, get: function () { return nfts_js_1.NftsResource; } });
|
|
49
|
+
var balances_js_1 = require("./resources/balances.js");
|
|
50
|
+
Object.defineProperty(exports, "BalancesResource", { enumerable: true, get: function () { return balances_js_1.BalancesResource; } });
|
|
51
|
+
var blocks_js_1 = require("./resources/blocks.js");
|
|
52
|
+
Object.defineProperty(exports, "BlocksResource", { enumerable: true, get: function () { return blocks_js_1.BlocksResource; } });
|
|
53
|
+
var schedules_js_1 = require("./resources/schedules.js");
|
|
54
|
+
Object.defineProperty(exports, "SchedulesResource", { enumerable: true, get: function () { return schedules_js_1.SchedulesResource; } });
|
|
55
|
+
//# 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,0DAAsD;AAA7C,6GAAA,WAAW,OAAA;AACpB,8CAA6C;AAApC,oGAAA,QAAQ,OAAA;AAGjB,SAAS;AACT,8CAK2B;AAJzB,sGAAA,UAAU,OAAA;AACV,2GAAA,eAAe,OAAA;AACf,2GAAA,eAAe,OAAA;AACf,2GAAA,eAAe,OAAA;AAGjB,YAAY;AACZ,uDAA2D;AAAlD,+GAAA,gBAAgB,OAAA;AACzB,+DAAmE;AAA1D,uHAAA,oBAAoB,OAAA;AAC7B,mDAAuD;AAA9C,2GAAA,cAAc,OAAA;AACvB,mDAAuD;AAA9C,2GAAA,cAAc,OAAA;AACvB,yDAA6D;AAApD,iHAAA,iBAAiB,OAAA;AAC1B,+CAAmD;AAA1C,uGAAA,YAAY,OAAA;AACrB,uDAA2D;AAAlD,+GAAA,gBAAgB,OAAA;AACzB,mDAAuD;AAA9C,2GAAA,cAAc,OAAA;AACvB,yDAA6D;AAApD,iHAAA,iBAAiB,OAAA"}
|
|
@@ -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,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.paginate = paginate;
|
|
5
|
+
const index_js_1 = require("../errors/index.js");
|
|
6
|
+
/**
|
|
7
|
+
* Builds a query string from parameters.
|
|
8
|
+
*
|
|
9
|
+
* @param path - The base API path
|
|
10
|
+
* @param params - Optional key-value query parameters
|
|
11
|
+
* @returns The full path with query string appended
|
|
12
|
+
*/
|
|
13
|
+
function buildUrl(path, params) {
|
|
14
|
+
if (!params) {
|
|
15
|
+
return path;
|
|
16
|
+
}
|
|
17
|
+
const searchParams = new URLSearchParams();
|
|
18
|
+
for (const [key, value] of Object.entries(params)) {
|
|
19
|
+
if (value !== undefined) {
|
|
20
|
+
searchParams.set(key, String(value));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const queryString = searchParams.toString();
|
|
24
|
+
return queryString ? `${path}?${queryString}` : path;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Extracts the `links.next` value from a Mirror Node paginated response.
|
|
28
|
+
*
|
|
29
|
+
* @param body - The raw JSON response object
|
|
30
|
+
* @returns The next page URL or null
|
|
31
|
+
*/
|
|
32
|
+
function extractNextLink(body) {
|
|
33
|
+
const links = body['links'];
|
|
34
|
+
if (links !== null && typeof links === 'object' && !Array.isArray(links)) {
|
|
35
|
+
const linksObj = links;
|
|
36
|
+
const next = linksObj['next'];
|
|
37
|
+
if (typeof next === 'string' && next.length > 0) {
|
|
38
|
+
return next;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Creates an async generator that paginates through a Mirror Node list endpoint.
|
|
45
|
+
* Follows the `links.next` field to automatically fetch subsequent pages.
|
|
46
|
+
*
|
|
47
|
+
* @param client - The HieroClient instance to use for HTTP requests
|
|
48
|
+
* @param path - The API path for the list endpoint (e.g., '/api/v1/accounts')
|
|
49
|
+
* @param dataKey - The key in the response object that contains the data array (e.g., 'accounts')
|
|
50
|
+
* @param params - Optional query parameters for filtering/sorting
|
|
51
|
+
* @returns An async generator that yields individual items of type T
|
|
52
|
+
* @throws {PaginationError} If the response shape is unexpected
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts
|
|
56
|
+
* for await (const account of paginate<AccountInfo>(client, '/api/v1/accounts', 'accounts')) {
|
|
57
|
+
* console.log(account.account);
|
|
58
|
+
* }
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
async function* paginate(client, path, dataKey, params) {
|
|
62
|
+
let url = buildUrl(path, params);
|
|
63
|
+
while (url !== null) {
|
|
64
|
+
const body = await client.get(url);
|
|
65
|
+
const items = body[dataKey];
|
|
66
|
+
if (!Array.isArray(items)) {
|
|
67
|
+
throw new index_js_1.PaginationError(`Expected array at key "${dataKey}" in response from ${url}, got ${typeof items}`, 'INVALID_RESPONSE_SHAPE');
|
|
68
|
+
}
|
|
69
|
+
for (const item of items) {
|
|
70
|
+
yield item;
|
|
71
|
+
}
|
|
72
|
+
// If the page was empty, stop regardless of links
|
|
73
|
+
if (items.length === 0) {
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
const nextLink = extractNextLink(body);
|
|
77
|
+
if (nextLink === null) {
|
|
78
|
+
url = null;
|
|
79
|
+
}
|
|
80
|
+
else if (nextLink.startsWith('http')) {
|
|
81
|
+
url = nextLink;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
// Relative URL from the Mirror Node
|
|
85
|
+
url = nextLink.startsWith('/') ? nextLink : `/${nextLink}`;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=paginator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paginator.js","sourceRoot":"","sources":["../../../src/pagination/paginator.ts"],"names":[],"mappings":";AAAA,sCAAsC;;AAmEtC,4BAuCC;AAvGD,iDAAqD;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;AACI,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,0BAAe,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"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.AccountsResource = void 0;
|
|
5
|
+
const paginator_js_1 = require("../pagination/paginator.js");
|
|
6
|
+
const index_js_1 = require("../errors/index.js");
|
|
7
|
+
const common_js_1 = require("../types/common.js");
|
|
8
|
+
/**
|
|
9
|
+
* Provides access to Mirror Node account endpoints.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* const account = await client.accounts.getById('0.0.1234');
|
|
14
|
+
* for await (const a of client.accounts.list({ limit: 10 })) {
|
|
15
|
+
* console.log(a.account);
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
class AccountsResource {
|
|
20
|
+
client;
|
|
21
|
+
constructor(client) {
|
|
22
|
+
this.client = client;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Retrieves a single account by ID.
|
|
26
|
+
*
|
|
27
|
+
* @param accountId - Account in `0.0.X` format
|
|
28
|
+
* @returns The account info including balance, key, and staking data
|
|
29
|
+
* @throws {ValidationError} If accountId format is invalid
|
|
30
|
+
* @throws {MirrorNodeError} If the API request fails
|
|
31
|
+
*/
|
|
32
|
+
async getById(accountId) {
|
|
33
|
+
this.validateAccountId(accountId);
|
|
34
|
+
return this.client.get(`/api/v1/accounts/${accountId}`);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Lists accounts with optional filters. Returns an async iterable
|
|
38
|
+
* that automatically handles pagination.
|
|
39
|
+
*
|
|
40
|
+
* @param params - Optional query parameters for filtering
|
|
41
|
+
* @returns Async iterable of account info objects
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* for await (const account of client.accounts.list({ limit: 5, order: 'desc' })) {
|
|
46
|
+
* console.log(account.account, account.balance.balance);
|
|
47
|
+
* }
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
list(params) {
|
|
51
|
+
return (0, paginator_js_1.paginate)(this.client, '/api/v1/accounts', 'accounts', params);
|
|
52
|
+
}
|
|
53
|
+
validateAccountId(id) {
|
|
54
|
+
if (!common_js_1.ENTITY_ID_PATTERN.test(id)) {
|
|
55
|
+
throw new index_js_1.ValidationError(`Invalid account ID format: "${id}". Expected "shard.realm.num" format (e.g., "0.0.1234").`, 'INVALID_ACCOUNT_ID');
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.AccountsResource = AccountsResource;
|
|
60
|
+
//# sourceMappingURL=accounts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accounts.js","sourceRoot":"","sources":["../../../src/resources/accounts.ts"],"names":[],"mappings":";AAAA,sCAAsC;;;AAItC,6DAAsD;AACtD,iDAAqD;AACrD,kDAAuD;AAEvD;;;;;;;;;;GAUG;AACH,MAAa,gBAAgB;IACE;IAA7B,YAA6B,MAAmB;QAAnB,WAAM,GAAN,MAAM,CAAa;IAAG,CAAC;IAEpD;;;;;;;OAOG;IACH,KAAK,CAAC,OAAO,CAAC,SAAiB;QAC7B,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;QAClC,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAc,oBAAoB,SAAS,EAAE,CAAC,CAAC;IACvE,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,IAAI,CAAC,MAA4B;QAC/B,OAAO,IAAA,uBAAQ,EACb,IAAI,CAAC,MAAM,EACX,kBAAkB,EAClB,UAAU,EACV,MAA+D,CAChE,CAAC;IACJ,CAAC;IAEO,iBAAiB,CAAC,EAAU;QAClC,IAAI,CAAC,6BAAiB,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;YAChC,MAAM,IAAI,0BAAe,CACvB,+BAA+B,EAAE,0DAA0D,EAC3F,oBAAoB,CACrB,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AA/CD,4CA+CC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { HieroClient } from '../client/HieroClient.js';
|
|
2
|
+
import type { BalanceEntry, BalancesQueryParams } from '../types/api.js';
|
|
3
|
+
/**
|
|
4
|
+
* Provides access to Mirror Node balance endpoints.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* for await (const entry of client.balances.list({ limit: 10 })) {
|
|
9
|
+
* console.log(entry.account, entry.balance);
|
|
10
|
+
* }
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare class BalancesResource {
|
|
14
|
+
private readonly client;
|
|
15
|
+
constructor(client: HieroClient);
|
|
16
|
+
/**
|
|
17
|
+
* Lists account balances with optional filters. Returns an async iterable
|
|
18
|
+
* that automatically handles pagination.
|
|
19
|
+
*
|
|
20
|
+
* @param params - Optional query parameters for filtering
|
|
21
|
+
* @returns Async iterable of balance entry objects
|
|
22
|
+
*/
|
|
23
|
+
list(params?: BalancesQueryParams): AsyncIterable<BalanceEntry>;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=balances.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"balances.d.ts","sourceRoot":"","sources":["../../../src/resources/balances.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAGzE;;;;;;;;;GASG;AACH,qBAAa,gBAAgB;IACf,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,WAAW;IAEhD;;;;;;OAMG;IACH,IAAI,CAAC,MAAM,CAAC,EAAE,mBAAmB,GAAG,aAAa,CAAC,YAAY,CAAC;CAQhE"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.BalancesResource = void 0;
|
|
5
|
+
const paginator_js_1 = require("../pagination/paginator.js");
|
|
6
|
+
/**
|
|
7
|
+
* Provides access to Mirror Node balance endpoints.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* for await (const entry of client.balances.list({ limit: 10 })) {
|
|
12
|
+
* console.log(entry.account, entry.balance);
|
|
13
|
+
* }
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
class BalancesResource {
|
|
17
|
+
client;
|
|
18
|
+
constructor(client) {
|
|
19
|
+
this.client = client;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Lists account balances with optional filters. Returns an async iterable
|
|
23
|
+
* that automatically handles pagination.
|
|
24
|
+
*
|
|
25
|
+
* @param params - Optional query parameters for filtering
|
|
26
|
+
* @returns Async iterable of balance entry objects
|
|
27
|
+
*/
|
|
28
|
+
list(params) {
|
|
29
|
+
return (0, paginator_js_1.paginate)(this.client, '/api/v1/balances', 'balances', params);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.BalancesResource = BalancesResource;
|
|
33
|
+
//# sourceMappingURL=balances.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"balances.js","sourceRoot":"","sources":["../../../src/resources/balances.ts"],"names":[],"mappings":";AAAA,sCAAsC;;;AAItC,6DAAsD;AAEtD;;;;;;;;;GASG;AACH,MAAa,gBAAgB;IACE;IAA7B,YAA6B,MAAmB;QAAnB,WAAM,GAAN,MAAM,CAAa;IAAG,CAAC;IAEpD;;;;;;OAMG;IACH,IAAI,CAAC,MAA4B;QAC/B,OAAO,IAAA,uBAAQ,EACb,IAAI,CAAC,MAAM,EACX,kBAAkB,EAClB,UAAU,EACV,MAA+D,CAChE,CAAC;IACJ,CAAC;CACF;AAlBD,4CAkBC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { HieroClient } from '../client/HieroClient.js';
|
|
2
|
+
import type { BlockInfo, BlocksQueryParams } from '../types/api.js';
|
|
3
|
+
/**
|
|
4
|
+
* Provides access to Mirror Node block endpoints.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* const block = await client.blocks.getByHashOrNumber(12345);
|
|
9
|
+
* for await (const b of client.blocks.list()) {
|
|
10
|
+
* console.log(b.number, b.hash);
|
|
11
|
+
* }
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare class BlocksResource {
|
|
15
|
+
private readonly client;
|
|
16
|
+
constructor(client: HieroClient);
|
|
17
|
+
/**
|
|
18
|
+
* Retrieves a single block by hash or number.
|
|
19
|
+
*
|
|
20
|
+
* @param hashOrNumber - Block hash (hex string) or block number
|
|
21
|
+
* @returns The block info including hash, timestamp, and gas used
|
|
22
|
+
* @throws {ValidationError} If the input is neither a valid hash nor a number
|
|
23
|
+
* @throws {MirrorNodeError} If the API request fails
|
|
24
|
+
*/
|
|
25
|
+
getByHashOrNumber(hashOrNumber: string | number): Promise<BlockInfo>;
|
|
26
|
+
/**
|
|
27
|
+
* Lists blocks 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 block info objects
|
|
32
|
+
*/
|
|
33
|
+
list(params?: BlocksQueryParams): AsyncIterable<BlockInfo>;
|
|
34
|
+
private validateHashOrNumber;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=blocks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../../../src/resources/blocks.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAIpE;;;;;;;;;;GAUG;AACH,qBAAa,cAAc;IACb,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,WAAW;IAEhD;;;;;;;OAOG;IACG,iBAAiB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IAK1E;;;;;;OAMG;IACH,IAAI,CAAC,MAAM,CAAC,EAAE,iBAAiB,GAAG,aAAa,CAAC,SAAS,CAAC;IAS1D,OAAO,CAAC,oBAAoB;CAiB7B"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.BlocksResource = void 0;
|
|
5
|
+
const paginator_js_1 = require("../pagination/paginator.js");
|
|
6
|
+
const index_js_1 = require("../errors/index.js");
|
|
7
|
+
/**
|
|
8
|
+
* Provides access to Mirror Node block endpoints.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const block = await client.blocks.getByHashOrNumber(12345);
|
|
13
|
+
* for await (const b of client.blocks.list()) {
|
|
14
|
+
* console.log(b.number, b.hash);
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
class BlocksResource {
|
|
19
|
+
client;
|
|
20
|
+
constructor(client) {
|
|
21
|
+
this.client = client;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Retrieves a single block by hash or number.
|
|
25
|
+
*
|
|
26
|
+
* @param hashOrNumber - Block hash (hex string) or block number
|
|
27
|
+
* @returns The block info including hash, timestamp, and gas used
|
|
28
|
+
* @throws {ValidationError} If the input is neither a valid hash nor a number
|
|
29
|
+
* @throws {MirrorNodeError} If the API request fails
|
|
30
|
+
*/
|
|
31
|
+
async getByHashOrNumber(hashOrNumber) {
|
|
32
|
+
this.validateHashOrNumber(hashOrNumber);
|
|
33
|
+
return this.client.get(`/api/v1/blocks/${hashOrNumber}`);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Lists blocks with optional filters. Returns an async iterable
|
|
37
|
+
* that automatically handles pagination.
|
|
38
|
+
*
|
|
39
|
+
* @param params - Optional query parameters for filtering
|
|
40
|
+
* @returns Async iterable of block info objects
|
|
41
|
+
*/
|
|
42
|
+
list(params) {
|
|
43
|
+
return (0, paginator_js_1.paginate)(this.client, '/api/v1/blocks', 'blocks', params);
|
|
44
|
+
}
|
|
45
|
+
validateHashOrNumber(value) {
|
|
46
|
+
if (typeof value === 'number') {
|
|
47
|
+
if (!Number.isInteger(value) || value < 0) {
|
|
48
|
+
throw new index_js_1.ValidationError(`Invalid block number: ${value}. Must be a non-negative integer.`, 'INVALID_BLOCK_NUMBER');
|
|
49
|
+
}
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (typeof value === 'string' && value.length === 0) {
|
|
53
|
+
throw new index_js_1.ValidationError('Block hash or number must not be empty.', 'INVALID_BLOCK_IDENTIFIER');
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.BlocksResource = BlocksResource;
|
|
58
|
+
//# sourceMappingURL=blocks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blocks.js","sourceRoot":"","sources":["../../../src/resources/blocks.ts"],"names":[],"mappings":";AAAA,sCAAsC;;;AAItC,6DAAsD;AACtD,iDAAqD;AAErD;;;;;;;;;;GAUG;AACH,MAAa,cAAc;IACI;IAA7B,YAA6B,MAAmB;QAAnB,WAAM,GAAN,MAAM,CAAa;IAAG,CAAC;IAEpD;;;;;;;OAOG;IACH,KAAK,CAAC,iBAAiB,CAAC,YAA6B;QACnD,IAAI,CAAC,oBAAoB,CAAC,YAAY,CAAC,CAAC;QACxC,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAY,kBAAkB,YAAY,EAAE,CAAC,CAAC;IACtE,CAAC;IAED;;;;;;OAMG;IACH,IAAI,CAAC,MAA0B;QAC7B,OAAO,IAAA,uBAAQ,EACb,IAAI,CAAC,MAAM,EACX,gBAAgB,EAChB,QAAQ,EACR,MAA+D,CAChE,CAAC;IACJ,CAAC;IAEO,oBAAoB,CAAC,KAAsB;QACjD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;gBAC1C,MAAM,IAAI,0BAAe,CACvB,yBAAyB,KAAK,mCAAmC,EACjE,sBAAsB,CACvB,CAAC;YACJ,CAAC;YACD,OAAO;QACT,CAAC;QACD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACpD,MAAM,IAAI,0BAAe,CACvB,yCAAyC,EACzC,0BAA0B,CAC3B,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAjDD,wCAiDC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { HieroClient } from '../client/HieroClient.js';
|
|
2
|
+
import type { ContractInfo, ContractsQueryParams } from '../types/api.js';
|
|
3
|
+
/**
|
|
4
|
+
* Provides access to Mirror Node contract endpoints.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* const contract = await client.contracts.getById('0.0.1234');
|
|
9
|
+
* for await (const c of client.contracts.list()) {
|
|
10
|
+
* console.log(c.contract_id);
|
|
11
|
+
* }
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare class ContractsResource {
|
|
15
|
+
private readonly client;
|
|
16
|
+
constructor(client: HieroClient);
|
|
17
|
+
/**
|
|
18
|
+
* Retrieves a single contract by ID.
|
|
19
|
+
*
|
|
20
|
+
* @param contractId - Contract in `0.0.X` format
|
|
21
|
+
* @returns The contract info including EVM address and timestamps
|
|
22
|
+
* @throws {ValidationError} If contractId format is invalid
|
|
23
|
+
* @throws {MirrorNodeError} If the API request fails
|
|
24
|
+
*/
|
|
25
|
+
getById(contractId: string): Promise<ContractInfo>;
|
|
26
|
+
/**
|
|
27
|
+
* Lists contracts 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 contract info objects
|
|
32
|
+
*/
|
|
33
|
+
list(params?: ContractsQueryParams): AsyncIterable<ContractInfo>;
|
|
34
|
+
private validateContractId;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=contracts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../../src/resources/contracts.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAK1E;;;;;;;;;;GAUG;AACH,qBAAa,iBAAiB;IAChB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,WAAW;IAEhD;;;;;;;OAOG;IACG,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAKxD;;;;;;OAMG;IACH,IAAI,CAAC,MAAM,CAAC,EAAE,oBAAoB,GAAG,aAAa,CAAC,YAAY,CAAC;IAShE,OAAO,CAAC,kBAAkB;CAQ3B"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.ContractsResource = void 0;
|
|
5
|
+
const paginator_js_1 = require("../pagination/paginator.js");
|
|
6
|
+
const index_js_1 = require("../errors/index.js");
|
|
7
|
+
const common_js_1 = require("../types/common.js");
|
|
8
|
+
/**
|
|
9
|
+
* Provides access to Mirror Node contract endpoints.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* const contract = await client.contracts.getById('0.0.1234');
|
|
14
|
+
* for await (const c of client.contracts.list()) {
|
|
15
|
+
* console.log(c.contract_id);
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
class ContractsResource {
|
|
20
|
+
client;
|
|
21
|
+
constructor(client) {
|
|
22
|
+
this.client = client;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Retrieves a single contract by ID.
|
|
26
|
+
*
|
|
27
|
+
* @param contractId - Contract in `0.0.X` format
|
|
28
|
+
* @returns The contract info including EVM address and timestamps
|
|
29
|
+
* @throws {ValidationError} If contractId format is invalid
|
|
30
|
+
* @throws {MirrorNodeError} If the API request fails
|
|
31
|
+
*/
|
|
32
|
+
async getById(contractId) {
|
|
33
|
+
this.validateContractId(contractId);
|
|
34
|
+
return this.client.get(`/api/v1/contracts/${contractId}`);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Lists contracts with optional filters. Returns an async iterable
|
|
38
|
+
* that automatically handles pagination.
|
|
39
|
+
*
|
|
40
|
+
* @param params - Optional query parameters for filtering
|
|
41
|
+
* @returns Async iterable of contract info objects
|
|
42
|
+
*/
|
|
43
|
+
list(params) {
|
|
44
|
+
return (0, paginator_js_1.paginate)(this.client, '/api/v1/contracts', 'contracts', params);
|
|
45
|
+
}
|
|
46
|
+
validateContractId(id) {
|
|
47
|
+
if (!common_js_1.ENTITY_ID_PATTERN.test(id)) {
|
|
48
|
+
throw new index_js_1.ValidationError(`Invalid contract ID format: "${id}". Expected "shard.realm.num" format (e.g., "0.0.1234").`, 'INVALID_CONTRACT_ID');
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.ContractsResource = ContractsResource;
|
|
53
|
+
//# sourceMappingURL=contracts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contracts.js","sourceRoot":"","sources":["../../../src/resources/contracts.ts"],"names":[],"mappings":";AAAA,sCAAsC;;;AAItC,6DAAsD;AACtD,iDAAqD;AACrD,kDAAuD;AAEvD;;;;;;;;;;GAUG;AACH,MAAa,iBAAiB;IACC;IAA7B,YAA6B,MAAmB;QAAnB,WAAM,GAAN,MAAM,CAAa;IAAG,CAAC;IAEpD;;;;;;;OAOG;IACH,KAAK,CAAC,OAAO,CAAC,UAAkB;QAC9B,IAAI,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC;QACpC,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAe,qBAAqB,UAAU,EAAE,CAAC,CAAC;IAC1E,CAAC;IAED;;;;;;OAMG;IACH,IAAI,CAAC,MAA6B;QAChC,OAAO,IAAA,uBAAQ,EACb,IAAI,CAAC,MAAM,EACX,mBAAmB,EACnB,WAAW,EACX,MAA+D,CAChE,CAAC;IACJ,CAAC;IAEO,kBAAkB,CAAC,EAAU;QACnC,IAAI,CAAC,6BAAiB,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;YAChC,MAAM,IAAI,0BAAe,CACvB,gCAAgC,EAAE,0DAA0D,EAC5F,qBAAqB,CACtB,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAxCD,8CAwCC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { HieroClient } from '../client/HieroClient.js';
|
|
2
|
+
import type { NftInfo, NftsQueryParams } from '../types/api.js';
|
|
3
|
+
/**
|
|
4
|
+
* Provides access to Mirror Node NFT endpoints.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* for await (const nft of client.nfts.listByToken('0.0.1234')) {
|
|
9
|
+
* console.log(nft.serial_number, nft.account_id);
|
|
10
|
+
* }
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare class NftsResource {
|
|
14
|
+
private readonly client;
|
|
15
|
+
constructor(client: HieroClient);
|
|
16
|
+
/**
|
|
17
|
+
* Retrieves a specific NFT by token ID and serial number.
|
|
18
|
+
*
|
|
19
|
+
* @param tokenId - Token in `0.0.X` format
|
|
20
|
+
* @param serialNumber - The NFT serial number
|
|
21
|
+
* @returns The NFT info including metadata and owner
|
|
22
|
+
* @throws {ValidationError} If tokenId format is invalid or serialNumber is not positive
|
|
23
|
+
* @throws {MirrorNodeError} If the API request fails
|
|
24
|
+
*/
|
|
25
|
+
getByTokenAndSerial(tokenId: string, serialNumber: number): Promise<NftInfo>;
|
|
26
|
+
/**
|
|
27
|
+
* Lists NFTs for a token. Returns an async iterable
|
|
28
|
+
* that automatically handles pagination.
|
|
29
|
+
*
|
|
30
|
+
* @param tokenId - Token in `0.0.X` format
|
|
31
|
+
* @param params - Optional query parameters for filtering
|
|
32
|
+
* @returns Async iterable of NFT info objects
|
|
33
|
+
* @throws {ValidationError} If tokenId format is invalid
|
|
34
|
+
*/
|
|
35
|
+
listByToken(tokenId: string, params?: NftsQueryParams): AsyncIterable<NftInfo>;
|
|
36
|
+
private validateTokenId;
|
|
37
|
+
private validateSerialNumber;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=nfts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nfts.d.ts","sourceRoot":"","sources":["../../../src/resources/nfts.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAKhE;;;;;;;;;GASG;AACH,qBAAa,YAAY;IACX,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,WAAW;IAEhD;;;;;;;;OAQG;IACG,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAQlF;;;;;;;;OAQG;IACH,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,eAAe,GAAG,aAAa,CAAC,OAAO,CAAC;IAU9E,OAAO,CAAC,eAAe;IASvB,OAAO,CAAC,oBAAoB;CAQ7B"}
|