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,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.NftsResource = 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 NFT endpoints.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* for await (const nft of client.nfts.listByToken('0.0.1234')) {
|
|
14
|
+
* console.log(nft.serial_number, nft.account_id);
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
class NftsResource {
|
|
19
|
+
client;
|
|
20
|
+
constructor(client) {
|
|
21
|
+
this.client = client;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Retrieves a specific NFT by token ID and serial number.
|
|
25
|
+
*
|
|
26
|
+
* @param tokenId - Token in `0.0.X` format
|
|
27
|
+
* @param serialNumber - The NFT serial number
|
|
28
|
+
* @returns The NFT info including metadata and owner
|
|
29
|
+
* @throws {ValidationError} If tokenId format is invalid or serialNumber is not positive
|
|
30
|
+
* @throws {MirrorNodeError} If the API request fails
|
|
31
|
+
*/
|
|
32
|
+
async getByTokenAndSerial(tokenId, serialNumber) {
|
|
33
|
+
this.validateTokenId(tokenId);
|
|
34
|
+
this.validateSerialNumber(serialNumber);
|
|
35
|
+
return this.client.get(`/api/v1/tokens/${tokenId}/nfts/${serialNumber}`);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Lists NFTs for a token. Returns an async iterable
|
|
39
|
+
* that automatically handles pagination.
|
|
40
|
+
*
|
|
41
|
+
* @param tokenId - Token in `0.0.X` format
|
|
42
|
+
* @param params - Optional query parameters for filtering
|
|
43
|
+
* @returns Async iterable of NFT info objects
|
|
44
|
+
* @throws {ValidationError} If tokenId format is invalid
|
|
45
|
+
*/
|
|
46
|
+
listByToken(tokenId, params) {
|
|
47
|
+
this.validateTokenId(tokenId);
|
|
48
|
+
return (0, paginator_js_1.paginate)(this.client, `/api/v1/tokens/${tokenId}/nfts`, 'nfts', params);
|
|
49
|
+
}
|
|
50
|
+
validateTokenId(id) {
|
|
51
|
+
if (!common_js_1.ENTITY_ID_PATTERN.test(id)) {
|
|
52
|
+
throw new index_js_1.ValidationError(`Invalid token ID format: "${id}". Expected "shard.realm.num" format (e.g., "0.0.1234").`, 'INVALID_TOKEN_ID');
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
validateSerialNumber(serial) {
|
|
56
|
+
if (!Number.isInteger(serial) || serial <= 0) {
|
|
57
|
+
throw new index_js_1.ValidationError(`Invalid serial number: ${serial}. Must be a positive integer.`, 'INVALID_SERIAL_NUMBER');
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.NftsResource = NftsResource;
|
|
62
|
+
//# sourceMappingURL=nfts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nfts.js","sourceRoot":"","sources":["../../../src/resources/nfts.ts"],"names":[],"mappings":";AAAA,sCAAsC;;;AAItC,6DAAsD;AACtD,iDAAqD;AACrD,kDAAuD;AAEvD;;;;;;;;;GASG;AACH,MAAa,YAAY;IACM;IAA7B,YAA6B,MAAmB;QAAnB,WAAM,GAAN,MAAM,CAAa;IAAG,CAAC;IAEpD;;;;;;;;OAQG;IACH,KAAK,CAAC,mBAAmB,CAAC,OAAe,EAAE,YAAoB;QAC7D,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QAC9B,IAAI,CAAC,oBAAoB,CAAC,YAAY,CAAC,CAAC;QACxC,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CACpB,kBAAkB,OAAO,SAAS,YAAY,EAAE,CACjD,CAAC;IACJ,CAAC;IAED;;;;;;;;OAQG;IACH,WAAW,CAAC,OAAe,EAAE,MAAwB;QACnD,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QAC9B,OAAO,IAAA,uBAAQ,EACb,IAAI,CAAC,MAAM,EACX,kBAAkB,OAAO,OAAO,EAChC,MAAM,EACN,MAA+D,CAChE,CAAC;IACJ,CAAC;IAEO,eAAe,CAAC,EAAU;QAChC,IAAI,CAAC,6BAAiB,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;YAChC,MAAM,IAAI,0BAAe,CACvB,6BAA6B,EAAE,0DAA0D,EACzF,kBAAkB,CACnB,CAAC;QACJ,CAAC;IACH,CAAC;IAEO,oBAAoB,CAAC,MAAc;QACzC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,MAAM,IAAI,CAAC,EAAE,CAAC;YAC7C,MAAM,IAAI,0BAAe,CACvB,0BAA0B,MAAM,+BAA+B,EAC/D,uBAAuB,CACxB,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAxDD,oCAwDC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { HieroClient } from '../client/HieroClient.js';
|
|
2
|
+
import type { ScheduleInfo, SchedulesQueryParams } from '../types/api.js';
|
|
3
|
+
/**
|
|
4
|
+
* Provides access to Mirror Node schedule endpoints.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* const schedule = await client.schedules.getById('0.0.1234');
|
|
9
|
+
* for await (const s of client.schedules.list()) {
|
|
10
|
+
* console.log(s.schedule_id);
|
|
11
|
+
* }
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare class SchedulesResource {
|
|
15
|
+
private readonly client;
|
|
16
|
+
constructor(client: HieroClient);
|
|
17
|
+
/**
|
|
18
|
+
* Retrieves a single schedule by ID.
|
|
19
|
+
*
|
|
20
|
+
* @param scheduleId - Schedule in `0.0.X` format
|
|
21
|
+
* @returns The schedule info including signatures and execution status
|
|
22
|
+
* @throws {ValidationError} If scheduleId format is invalid
|
|
23
|
+
* @throws {MirrorNodeError} If the API request fails
|
|
24
|
+
*/
|
|
25
|
+
getById(scheduleId: string): Promise<ScheduleInfo>;
|
|
26
|
+
/**
|
|
27
|
+
* Lists schedules 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 schedule info objects
|
|
32
|
+
*/
|
|
33
|
+
list(params?: SchedulesQueryParams): AsyncIterable<ScheduleInfo>;
|
|
34
|
+
private validateScheduleId;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=schedules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schedules.d.ts","sourceRoot":"","sources":["../../../src/resources/schedules.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.SchedulesResource = 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 schedule endpoints.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* const schedule = await client.schedules.getById('0.0.1234');
|
|
14
|
+
* for await (const s of client.schedules.list()) {
|
|
15
|
+
* console.log(s.schedule_id);
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
class SchedulesResource {
|
|
20
|
+
client;
|
|
21
|
+
constructor(client) {
|
|
22
|
+
this.client = client;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Retrieves a single schedule by ID.
|
|
26
|
+
*
|
|
27
|
+
* @param scheduleId - Schedule in `0.0.X` format
|
|
28
|
+
* @returns The schedule info including signatures and execution status
|
|
29
|
+
* @throws {ValidationError} If scheduleId format is invalid
|
|
30
|
+
* @throws {MirrorNodeError} If the API request fails
|
|
31
|
+
*/
|
|
32
|
+
async getById(scheduleId) {
|
|
33
|
+
this.validateScheduleId(scheduleId);
|
|
34
|
+
return this.client.get(`/api/v1/schedules/${scheduleId}`);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Lists schedules 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 schedule info objects
|
|
42
|
+
*/
|
|
43
|
+
list(params) {
|
|
44
|
+
return (0, paginator_js_1.paginate)(this.client, '/api/v1/schedules', 'schedules', params);
|
|
45
|
+
}
|
|
46
|
+
validateScheduleId(id) {
|
|
47
|
+
if (!common_js_1.ENTITY_ID_PATTERN.test(id)) {
|
|
48
|
+
throw new index_js_1.ValidationError(`Invalid schedule ID format: "${id}". Expected "shard.realm.num" format (e.g., "0.0.1234").`, 'INVALID_SCHEDULE_ID');
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.SchedulesResource = SchedulesResource;
|
|
53
|
+
//# sourceMappingURL=schedules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schedules.js","sourceRoot":"","sources":["../../../src/resources/schedules.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,36 @@
|
|
|
1
|
+
import type { HieroClient } from '../client/HieroClient.js';
|
|
2
|
+
import type { TokenInfo, TokensQueryParams } from '../types/api.js';
|
|
3
|
+
/**
|
|
4
|
+
* Provides access to Mirror Node token endpoints.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* const token = await client.tokens.getById('0.0.1234');
|
|
9
|
+
* for await (const t of client.tokens.list({ type: 'FUNGIBLE_COMMON' })) {
|
|
10
|
+
* console.log(t.name, t.symbol);
|
|
11
|
+
* }
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare class TokensResource {
|
|
15
|
+
private readonly client;
|
|
16
|
+
constructor(client: HieroClient);
|
|
17
|
+
/**
|
|
18
|
+
* Retrieves a single token by ID.
|
|
19
|
+
*
|
|
20
|
+
* @param tokenId - Token in `0.0.X` format
|
|
21
|
+
* @returns The token info including supply, keys, and custom fees
|
|
22
|
+
* @throws {ValidationError} If tokenId format is invalid
|
|
23
|
+
* @throws {MirrorNodeError} If the API request fails
|
|
24
|
+
*/
|
|
25
|
+
getById(tokenId: string): Promise<TokenInfo>;
|
|
26
|
+
/**
|
|
27
|
+
* Lists tokens 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 token info objects
|
|
32
|
+
*/
|
|
33
|
+
list(params?: TokensQueryParams): AsyncIterable<TokenInfo>;
|
|
34
|
+
private validateTokenId;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=tokens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../../src/resources/tokens.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAKpE;;;;;;;;;;GAUG;AACH,qBAAa,cAAc;IACb,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,WAAW;IAEhD;;;;;;;OAOG;IACG,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IAKlD;;;;;;OAMG;IACH,IAAI,CAAC,MAAM,CAAC,EAAE,iBAAiB,GAAG,aAAa,CAAC,SAAS,CAAC;IAS1D,OAAO,CAAC,eAAe;CAQxB"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.TokensResource = 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 token endpoints.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* const token = await client.tokens.getById('0.0.1234');
|
|
14
|
+
* for await (const t of client.tokens.list({ type: 'FUNGIBLE_COMMON' })) {
|
|
15
|
+
* console.log(t.name, t.symbol);
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
class TokensResource {
|
|
20
|
+
client;
|
|
21
|
+
constructor(client) {
|
|
22
|
+
this.client = client;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Retrieves a single token by ID.
|
|
26
|
+
*
|
|
27
|
+
* @param tokenId - Token in `0.0.X` format
|
|
28
|
+
* @returns The token info including supply, keys, and custom fees
|
|
29
|
+
* @throws {ValidationError} If tokenId format is invalid
|
|
30
|
+
* @throws {MirrorNodeError} If the API request fails
|
|
31
|
+
*/
|
|
32
|
+
async getById(tokenId) {
|
|
33
|
+
this.validateTokenId(tokenId);
|
|
34
|
+
return this.client.get(`/api/v1/tokens/${tokenId}`);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Lists tokens 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 token info objects
|
|
42
|
+
*/
|
|
43
|
+
list(params) {
|
|
44
|
+
return (0, paginator_js_1.paginate)(this.client, '/api/v1/tokens', 'tokens', params);
|
|
45
|
+
}
|
|
46
|
+
validateTokenId(id) {
|
|
47
|
+
if (!common_js_1.ENTITY_ID_PATTERN.test(id)) {
|
|
48
|
+
throw new index_js_1.ValidationError(`Invalid token ID format: "${id}". Expected "shard.realm.num" format (e.g., "0.0.1234").`, 'INVALID_TOKEN_ID');
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.TokensResource = TokensResource;
|
|
53
|
+
//# sourceMappingURL=tokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../../src/resources/tokens.ts"],"names":[],"mappings":";AAAA,sCAAsC;;;AAItC,6DAAsD;AACtD,iDAAqD;AACrD,kDAAuD;AAEvD;;;;;;;;;;GAUG;AACH,MAAa,cAAc;IACI;IAA7B,YAA6B,MAAmB;QAAnB,WAAM,GAAN,MAAM,CAAa;IAAG,CAAC;IAEpD;;;;;;;OAOG;IACH,KAAK,CAAC,OAAO,CAAC,OAAe;QAC3B,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QAC9B,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAY,kBAAkB,OAAO,EAAE,CAAC,CAAC;IACjE,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,eAAe,CAAC,EAAU;QAChC,IAAI,CAAC,6BAAiB,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;YAChC,MAAM,IAAI,0BAAe,CACvB,6BAA6B,EAAE,0DAA0D,EACzF,kBAAkB,CACnB,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAxCD,wCAwCC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { HieroClient } from '../client/HieroClient.js';
|
|
2
|
+
import type { TopicInfo, TopicMessage, TopicMessagesQueryParams } from '../types/api.js';
|
|
3
|
+
/**
|
|
4
|
+
* Provides access to Mirror Node topic endpoints.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* const topic = await client.topics.getById('0.0.1234');
|
|
9
|
+
* for await (const msg of client.topics.listMessages('0.0.1234')) {
|
|
10
|
+
* console.log(msg.message);
|
|
11
|
+
* }
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare class TopicsResource {
|
|
15
|
+
private readonly client;
|
|
16
|
+
constructor(client: HieroClient);
|
|
17
|
+
/**
|
|
18
|
+
* Retrieves topic info by ID.
|
|
19
|
+
*
|
|
20
|
+
* @param topicId - Topic in `0.0.X` format
|
|
21
|
+
* @returns The topic info including keys and memo
|
|
22
|
+
* @throws {ValidationError} If topicId format is invalid
|
|
23
|
+
* @throws {MirrorNodeError} If the API request fails
|
|
24
|
+
*/
|
|
25
|
+
getById(topicId: string): Promise<TopicInfo>;
|
|
26
|
+
/**
|
|
27
|
+
* Lists messages for a topic. Returns an async iterable
|
|
28
|
+
* that automatically handles pagination.
|
|
29
|
+
*
|
|
30
|
+
* @param topicId - Topic in `0.0.X` format
|
|
31
|
+
* @param params - Optional query parameters for filtering
|
|
32
|
+
* @returns Async iterable of topic message objects
|
|
33
|
+
* @throws {ValidationError} If topicId format is invalid
|
|
34
|
+
*/
|
|
35
|
+
listMessages(topicId: string, params?: TopicMessagesQueryParams): AsyncIterable<TopicMessage>;
|
|
36
|
+
private validateTopicId;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=topics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"topics.d.ts","sourceRoot":"","sources":["../../../src/resources/topics.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAKzF;;;;;;;;;;GAUG;AACH,qBAAa,cAAc;IACb,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,WAAW;IAEhD;;;;;;;OAOG;IACG,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IAKlD;;;;;;;;OAQG;IACH,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,wBAAwB,GAAG,aAAa,CAAC,YAAY,CAAC;IAU7F,OAAO,CAAC,eAAe;CAQxB"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.TopicsResource = 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 topic endpoints.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* const topic = await client.topics.getById('0.0.1234');
|
|
14
|
+
* for await (const msg of client.topics.listMessages('0.0.1234')) {
|
|
15
|
+
* console.log(msg.message);
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
class TopicsResource {
|
|
20
|
+
client;
|
|
21
|
+
constructor(client) {
|
|
22
|
+
this.client = client;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Retrieves topic info by ID.
|
|
26
|
+
*
|
|
27
|
+
* @param topicId - Topic in `0.0.X` format
|
|
28
|
+
* @returns The topic info including keys and memo
|
|
29
|
+
* @throws {ValidationError} If topicId format is invalid
|
|
30
|
+
* @throws {MirrorNodeError} If the API request fails
|
|
31
|
+
*/
|
|
32
|
+
async getById(topicId) {
|
|
33
|
+
this.validateTopicId(topicId);
|
|
34
|
+
return this.client.get(`/api/v1/topics/${topicId}`);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Lists messages for a topic. Returns an async iterable
|
|
38
|
+
* that automatically handles pagination.
|
|
39
|
+
*
|
|
40
|
+
* @param topicId - Topic in `0.0.X` format
|
|
41
|
+
* @param params - Optional query parameters for filtering
|
|
42
|
+
* @returns Async iterable of topic message objects
|
|
43
|
+
* @throws {ValidationError} If topicId format is invalid
|
|
44
|
+
*/
|
|
45
|
+
listMessages(topicId, params) {
|
|
46
|
+
this.validateTopicId(topicId);
|
|
47
|
+
return (0, paginator_js_1.paginate)(this.client, `/api/v1/topics/${topicId}/messages`, 'messages', params);
|
|
48
|
+
}
|
|
49
|
+
validateTopicId(id) {
|
|
50
|
+
if (!common_js_1.ENTITY_ID_PATTERN.test(id)) {
|
|
51
|
+
throw new index_js_1.ValidationError(`Invalid topic ID format: "${id}". Expected "shard.realm.num" format (e.g., "0.0.1234").`, 'INVALID_TOPIC_ID');
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.TopicsResource = TopicsResource;
|
|
56
|
+
//# sourceMappingURL=topics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"topics.js","sourceRoot":"","sources":["../../../src/resources/topics.ts"],"names":[],"mappings":";AAAA,sCAAsC;;;AAItC,6DAAsD;AACtD,iDAAqD;AACrD,kDAAuD;AAEvD;;;;;;;;;;GAUG;AACH,MAAa,cAAc;IACI;IAA7B,YAA6B,MAAmB;QAAnB,WAAM,GAAN,MAAM,CAAa;IAAG,CAAC;IAEpD;;;;;;;OAOG;IACH,KAAK,CAAC,OAAO,CAAC,OAAe;QAC3B,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QAC9B,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAY,kBAAkB,OAAO,EAAE,CAAC,CAAC;IACjE,CAAC;IAED;;;;;;;;OAQG;IACH,YAAY,CAAC,OAAe,EAAE,MAAiC;QAC7D,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QAC9B,OAAO,IAAA,uBAAQ,EACb,IAAI,CAAC,MAAM,EACX,kBAAkB,OAAO,WAAW,EACpC,UAAU,EACV,MAA+D,CAChE,CAAC;IACJ,CAAC;IAEO,eAAe,CAAC,EAAU;QAChC,IAAI,CAAC,6BAAiB,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;YAChC,MAAM,IAAI,0BAAe,CACvB,6BAA6B,EAAE,0DAA0D,EACzF,kBAAkB,CACnB,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AA3CD,wCA2CC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { HieroClient } from '../client/HieroClient.js';
|
|
2
|
+
import type { TransactionInfo, TransactionsQueryParams } from '../types/api.js';
|
|
3
|
+
/**
|
|
4
|
+
* Provides access to Mirror Node transaction endpoints.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* for await (const tx of client.transactions.list({ limit: 10 })) {
|
|
9
|
+
* console.log(tx.transaction_id, tx.result);
|
|
10
|
+
* }
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare class TransactionsResource {
|
|
14
|
+
private readonly client;
|
|
15
|
+
constructor(client: HieroClient);
|
|
16
|
+
/**
|
|
17
|
+
* Retrieves a single transaction by its transaction ID.
|
|
18
|
+
*
|
|
19
|
+
* @param transactionId - Transaction ID in `shard.realm.num-ssssssssss-nnnnnnnnn` format
|
|
20
|
+
* @returns The transaction info including transfers and result
|
|
21
|
+
* @throws {ValidationError} If the transaction ID format is invalid
|
|
22
|
+
* @throws {MirrorNodeError} If the API request fails
|
|
23
|
+
*/
|
|
24
|
+
getById(transactionId: string): Promise<TransactionInfo>;
|
|
25
|
+
/**
|
|
26
|
+
* Lists transactions with optional filters. Returns an async iterable
|
|
27
|
+
* that automatically handles pagination.
|
|
28
|
+
*
|
|
29
|
+
* @param params - Optional query parameters for filtering
|
|
30
|
+
* @returns Async iterable of transaction info objects
|
|
31
|
+
*/
|
|
32
|
+
list(params?: TransactionsQueryParams): AsyncIterable<TransactionInfo>;
|
|
33
|
+
private validateTransactionId;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=transactions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transactions.d.ts","sourceRoot":"","sources":["../../../src/resources/transactions.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAIhF;;;;;;;;;GASG;AACH,qBAAa,oBAAoB;IACnB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,WAAW;IAEhD;;;;;;;OAOG;IACG,OAAO,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAe9D;;;;;;OAMG;IACH,IAAI,CAAC,MAAM,CAAC,EAAE,uBAAuB,GAAG,aAAa,CAAC,eAAe,CAAC;IAStE,OAAO,CAAC,qBAAqB;CAS9B"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.TransactionsResource = 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 transaction endpoints.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* for await (const tx of client.transactions.list({ limit: 10 })) {
|
|
13
|
+
* console.log(tx.transaction_id, tx.result);
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
class TransactionsResource {
|
|
18
|
+
client;
|
|
19
|
+
constructor(client) {
|
|
20
|
+
this.client = client;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Retrieves a single transaction by its transaction ID.
|
|
24
|
+
*
|
|
25
|
+
* @param transactionId - Transaction ID in `shard.realm.num-ssssssssss-nnnnnnnnn` format
|
|
26
|
+
* @returns The transaction info including transfers and result
|
|
27
|
+
* @throws {ValidationError} If the transaction ID format is invalid
|
|
28
|
+
* @throws {MirrorNodeError} If the API request fails
|
|
29
|
+
*/
|
|
30
|
+
async getById(transactionId) {
|
|
31
|
+
this.validateTransactionId(transactionId);
|
|
32
|
+
const response = await this.client.get(`/api/v1/transactions/${transactionId}`);
|
|
33
|
+
const first = response.transactions[0];
|
|
34
|
+
if (!first) {
|
|
35
|
+
throw new index_js_1.ValidationError(`No transaction found for ID: "${transactionId}"`, 'TRANSACTION_NOT_FOUND');
|
|
36
|
+
}
|
|
37
|
+
return first;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Lists transactions with optional filters. Returns an async iterable
|
|
41
|
+
* that automatically handles pagination.
|
|
42
|
+
*
|
|
43
|
+
* @param params - Optional query parameters for filtering
|
|
44
|
+
* @returns Async iterable of transaction info objects
|
|
45
|
+
*/
|
|
46
|
+
list(params) {
|
|
47
|
+
return (0, paginator_js_1.paginate)(this.client, '/api/v1/transactions', 'transactions', params);
|
|
48
|
+
}
|
|
49
|
+
validateTransactionId(id) {
|
|
50
|
+
// Format: 0.0.XXXX-SSSSSSSSSS-NNNNNNNNN
|
|
51
|
+
if (!/^\d+\.\d+\.\d+-\d+-\d+$/.test(id)) {
|
|
52
|
+
throw new index_js_1.ValidationError(`Invalid transaction ID format: "${id}". Expected "shard.realm.num-seconds-nanos" format.`, 'INVALID_TRANSACTION_ID');
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.TransactionsResource = TransactionsResource;
|
|
57
|
+
//# sourceMappingURL=transactions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transactions.js","sourceRoot":"","sources":["../../../src/resources/transactions.ts"],"names":[],"mappings":";AAAA,sCAAsC;;;AAItC,6DAAsD;AACtD,iDAAqD;AAErD;;;;;;;;;GASG;AACH,MAAa,oBAAoB;IACF;IAA7B,YAA6B,MAAmB;QAAnB,WAAM,GAAN,MAAM,CAAa;IAAG,CAAC;IAEpD;;;;;;;OAOG;IACH,KAAK,CAAC,OAAO,CAAC,aAAqB;QACjC,IAAI,CAAC,qBAAqB,CAAC,aAAa,CAAC,CAAC;QAC1C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CACpC,wBAAwB,aAAa,EAAE,CACxC,CAAC;QACF,MAAM,KAAK,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;QACvC,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,IAAI,0BAAe,CACvB,iCAAiC,aAAa,GAAG,EACjD,uBAAuB,CACxB,CAAC;QACJ,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;;;OAMG;IACH,IAAI,CAAC,MAAgC;QACnC,OAAO,IAAA,uBAAQ,EACb,IAAI,CAAC,MAAM,EACX,sBAAsB,EACtB,cAAc,EACd,MAA+D,CAChE,CAAC;IACJ,CAAC;IAEO,qBAAqB,CAAC,EAAU;QACtC,wCAAwC;QACxC,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;YACxC,MAAM,IAAI,0BAAe,CACvB,mCAAmC,EAAE,qDAAqD,EAC1F,wBAAwB,CACzB,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAnDD,oDAmDC"}
|