@hashgraphonline/standards-sdk 0.0.112-canary.0 → 0.0.112-canary.3
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/index-CHar8dVv-SclbHQNq.cjs +11 -0
- package/dist/cjs/{index-CHar8dVv-CUVf-if8.cjs.map → index-CHar8dVv-SclbHQNq.cjs.map} +1 -1
- package/dist/cjs/index-CcE0yY9g.cjs +11 -0
- package/dist/cjs/index-CcE0yY9g.cjs.map +1 -0
- package/dist/cjs/services/mirror-node.d.ts +35 -16
- package/dist/cjs/services/mirror-node.d.ts.map +1 -1
- package/dist/cjs/services/types.d.ts +3 -3
- package/dist/cjs/services/types.d.ts.map +1 -1
- package/dist/cjs/standards-sdk.cjs +1 -1
- package/dist/es/services/mirror-node.d.ts +35 -16
- package/dist/es/services/mirror-node.d.ts.map +1 -1
- package/dist/es/services/types.d.ts +3 -3
- package/dist/es/services/types.d.ts.map +1 -1
- package/dist/es/standards-sdk.es13.js +0 -1
- package/dist/es/standards-sdk.es13.js.map +1 -1
- package/dist/es/standards-sdk.es20.js +0 -1
- package/dist/es/standards-sdk.es20.js.map +1 -1
- package/dist/es/standards-sdk.es21.js +170 -103
- package/dist/es/standards-sdk.es21.js.map +1 -1
- package/dist/es/standards-sdk.es29.js +0 -1
- package/dist/es/standards-sdk.es29.js.map +1 -1
- package/dist/es/standards-sdk.es32.js +0 -1
- package/dist/es/standards-sdk.es32.js.map +1 -1
- package/dist/es/standards-sdk.es5.js +0 -1
- package/dist/es/standards-sdk.es5.js.map +1 -1
- package/dist/es/standards-sdk.es7.js +0 -1
- package/dist/es/standards-sdk.es7.js.map +1 -1
- package/dist/es/standards-sdk.es8.js +0 -1
- package/dist/es/standards-sdk.es8.js.map +1 -1
- package/dist/umd/services/mirror-node.d.ts +35 -16
- package/dist/umd/services/mirror-node.d.ts.map +1 -1
- package/dist/umd/services/types.d.ts +3 -3
- package/dist/umd/services/types.d.ts.map +1 -1
- package/dist/umd/standards-sdk.umd.js +1 -1
- package/dist/umd/standards-sdk.umd.js.map +1 -1
- package/package.json +1 -1
- package/dist/cjs/index-BmPzMkW9.cjs +0 -11
- package/dist/cjs/index-BmPzMkW9.cjs.map +0 -1
- package/dist/cjs/index-CHar8dVv-CUVf-if8.cjs +0 -11
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import Buffer from "vite-plugin-node-polyfills/shims/buffer";
|
|
2
1
|
import { PublicKey, Timestamp, AccountId } from "@hashgraph/sdk";
|
|
3
2
|
import axios from "axios";
|
|
4
3
|
import { Logger } from "./standards-sdk.es15.js";
|
|
@@ -105,10 +104,9 @@ class HederaMirrorNode {
|
|
|
105
104
|
*/
|
|
106
105
|
async getAccountMemo(accountId) {
|
|
107
106
|
this.logger.info(`Getting account memo for account ID: ${accountId}`);
|
|
108
|
-
const accountInfoUrl = this.constructUrl(`/api/v1/accounts/${accountId}`);
|
|
109
107
|
try {
|
|
110
108
|
const accountInfo = await this._requestWithRetry(
|
|
111
|
-
|
|
109
|
+
`/api/v1/accounts/${accountId}`
|
|
112
110
|
);
|
|
113
111
|
if (accountInfo?.memo) {
|
|
114
112
|
return accountInfo.memo;
|
|
@@ -131,9 +129,10 @@ class HederaMirrorNode {
|
|
|
131
129
|
*/
|
|
132
130
|
async getTopicInfo(topicId) {
|
|
133
131
|
try {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
132
|
+
this.logger.debug(`Fetching topic info for ${topicId}`);
|
|
133
|
+
const data = await this._requestWithRetry(
|
|
134
|
+
`/api/v1/topics/${topicId}`
|
|
135
|
+
);
|
|
137
136
|
return data;
|
|
138
137
|
} catch (e) {
|
|
139
138
|
const error = e;
|
|
@@ -168,9 +167,10 @@ class HederaMirrorNode {
|
|
|
168
167
|
async getHBARPrice(date) {
|
|
169
168
|
try {
|
|
170
169
|
const timestamp = Timestamp.fromDate(date).toString();
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
170
|
+
this.logger.debug(`Fetching HBAR price for timestamp ${timestamp}`);
|
|
171
|
+
const response = await this._requestWithRetry(
|
|
172
|
+
`/api/v1/network/exchangerate?timestamp=${timestamp}`
|
|
173
|
+
);
|
|
174
174
|
const usdPrice = Number(response?.current_rate?.cent_equivalent) / Number(response?.current_rate?.hbar_equivalent) / 100;
|
|
175
175
|
return usdPrice;
|
|
176
176
|
} catch (e) {
|
|
@@ -189,9 +189,8 @@ class HederaMirrorNode {
|
|
|
189
189
|
async getTokenInfo(tokenId) {
|
|
190
190
|
this.logger.debug(`Fetching token info for ${tokenId}`);
|
|
191
191
|
try {
|
|
192
|
-
const tokenInfoUrl = this.constructUrl(`/api/v1/tokens/${tokenId}`);
|
|
193
192
|
const data = await this._requestWithRetry(
|
|
194
|
-
|
|
193
|
+
`/api/v1/tokens/${tokenId}`
|
|
195
194
|
);
|
|
196
195
|
if (data) {
|
|
197
196
|
this.logger.trace(`Token info found for ${tokenId}:`, data);
|
|
@@ -214,12 +213,12 @@ class HederaMirrorNode {
|
|
|
214
213
|
*/
|
|
215
214
|
async getTopicMessages(topicId) {
|
|
216
215
|
this.logger.trace(`Querying messages for topic ${topicId}`);
|
|
217
|
-
let
|
|
216
|
+
let nextEndpoint = `/api/v1/topics/${topicId}/messages`;
|
|
218
217
|
const messages = [];
|
|
219
|
-
while (
|
|
218
|
+
while (nextEndpoint) {
|
|
220
219
|
try {
|
|
221
220
|
const data = await this._requestWithRetry(
|
|
222
|
-
|
|
221
|
+
nextEndpoint
|
|
223
222
|
);
|
|
224
223
|
if (data.messages && data.messages.length > 0) {
|
|
225
224
|
for (const message of data.messages) {
|
|
@@ -268,10 +267,10 @@ class HederaMirrorNode {
|
|
|
268
267
|
}
|
|
269
268
|
}
|
|
270
269
|
}
|
|
271
|
-
|
|
270
|
+
nextEndpoint = data.links?.next || "";
|
|
272
271
|
} catch (e) {
|
|
273
272
|
const error = e;
|
|
274
|
-
const logMessage = `Error querying topic messages for topic ${topicId} (
|
|
273
|
+
const logMessage = `Error querying topic messages for topic ${topicId} (endpoint: ${nextEndpoint}) after retries: ${error.message}`;
|
|
275
274
|
this.logger.error(logMessage);
|
|
276
275
|
throw new Error(logMessage);
|
|
277
276
|
}
|
|
@@ -286,10 +285,9 @@ class HederaMirrorNode {
|
|
|
286
285
|
*/
|
|
287
286
|
async requestAccount(accountId) {
|
|
288
287
|
try {
|
|
289
|
-
|
|
290
|
-
this.logger.debug(`Requesting account info from ${accountInfoUrl}`);
|
|
288
|
+
this.logger.debug(`Requesting account info for ${accountId}`);
|
|
291
289
|
const data = await this._requestWithRetry(
|
|
292
|
-
|
|
290
|
+
`/api/v1/accounts/${accountId}`
|
|
293
291
|
);
|
|
294
292
|
if (!data) {
|
|
295
293
|
throw new Error(
|
|
@@ -402,8 +400,9 @@ class HederaMirrorNode {
|
|
|
402
400
|
this.logger.info(
|
|
403
401
|
`Getting information for scheduled transaction ${scheduleId}`
|
|
404
402
|
);
|
|
405
|
-
const
|
|
406
|
-
|
|
403
|
+
const data = await this._requestWithRetry(
|
|
404
|
+
`/api/v1/schedules/${scheduleId}`
|
|
405
|
+
);
|
|
407
406
|
if (data) {
|
|
408
407
|
return data;
|
|
409
408
|
}
|
|
@@ -454,10 +453,8 @@ class HederaMirrorNode {
|
|
|
454
453
|
this.logger.info(
|
|
455
454
|
`Getting transaction details for ID/hash: ${transactionIdOrHash}`
|
|
456
455
|
);
|
|
457
|
-
const endpoint = transactionIdOrHash.includes("-") ? `transactions/${transactionIdOrHash}` : `transactions/${transactionIdOrHash}`;
|
|
458
|
-
const transactionDetailsUrl = `${this.baseUrl}/api/v1/${endpoint}`;
|
|
459
456
|
try {
|
|
460
|
-
const response = await this._requestWithRetry(
|
|
457
|
+
const response = await this._requestWithRetry(`/api/v1/transactions/${transactionIdOrHash}`);
|
|
461
458
|
if (response?.transactions?.length > 0) {
|
|
462
459
|
this.logger.trace(
|
|
463
460
|
`Transaction details found for ${transactionIdOrHash}:`,
|
|
@@ -480,9 +477,10 @@ class HederaMirrorNode {
|
|
|
480
477
|
/**
|
|
481
478
|
* Private helper to make GET requests with retry logic using Axios.
|
|
482
479
|
*/
|
|
483
|
-
async _requestWithRetry(
|
|
480
|
+
async _requestWithRetry(endpoint, axiosConfig) {
|
|
484
481
|
let attempt = 0;
|
|
485
482
|
let delay = this.initialDelayMs;
|
|
483
|
+
const url = this.constructUrl(endpoint);
|
|
486
484
|
const config = {
|
|
487
485
|
...axiosConfig,
|
|
488
486
|
headers: {
|
|
@@ -634,7 +632,7 @@ class HederaMirrorNode {
|
|
|
634
632
|
options
|
|
635
633
|
)}`
|
|
636
634
|
);
|
|
637
|
-
let nextUrl =
|
|
635
|
+
let nextUrl = `/api/v1/topics/${topicId}/messages`;
|
|
638
636
|
const params = new URLSearchParams();
|
|
639
637
|
if (options?.limit) {
|
|
640
638
|
params.append("limit", options.limit.toString());
|
|
@@ -714,7 +712,7 @@ class HederaMirrorNode {
|
|
|
714
712
|
}
|
|
715
713
|
}
|
|
716
714
|
if (options?.limit && messages.length >= options.limit) break;
|
|
717
|
-
nextUrl = data.links?.next ? `${
|
|
715
|
+
nextUrl = data.links?.next ? `${data.links.next}` : "";
|
|
718
716
|
}
|
|
719
717
|
return messages;
|
|
720
718
|
} catch (e) {
|
|
@@ -734,17 +732,17 @@ class HederaMirrorNode {
|
|
|
734
732
|
async getAccountTokens(accountId, limit = 100) {
|
|
735
733
|
this.logger.info(`Getting tokens for account ${accountId}`);
|
|
736
734
|
let allTokens = [];
|
|
737
|
-
let
|
|
735
|
+
let endpoint = `/api/v1/accounts/${accountId}/tokens?limit=${limit}`;
|
|
738
736
|
try {
|
|
739
|
-
for (let i = 0; i < 10 &&
|
|
737
|
+
for (let i = 0; i < 10 && endpoint; i++) {
|
|
740
738
|
const response = await this._requestWithRetry(
|
|
741
|
-
|
|
739
|
+
endpoint
|
|
742
740
|
);
|
|
743
741
|
if (response && response.tokens) {
|
|
744
742
|
allTokens = allTokens.concat(response.tokens);
|
|
745
743
|
}
|
|
746
|
-
|
|
747
|
-
if (!
|
|
744
|
+
endpoint = response.links?.next || "";
|
|
745
|
+
if (!endpoint || limit && allTokens.length >= limit) {
|
|
748
746
|
if (limit && allTokens.length > limit) {
|
|
749
747
|
allTokens = allTokens.slice(0, limit);
|
|
750
748
|
}
|
|
@@ -766,9 +764,8 @@ class HederaMirrorNode {
|
|
|
766
764
|
*/
|
|
767
765
|
async getTransactionByTimestamp(timestamp) {
|
|
768
766
|
this.logger.info(`Getting transaction by timestamp: ${timestamp}`);
|
|
769
|
-
const url = `${this.baseUrl}/api/v1/transactions?timestamp=${timestamp}&limit=1`;
|
|
770
767
|
try {
|
|
771
|
-
const response = await this._requestWithRetry(
|
|
768
|
+
const response = await this._requestWithRetry(`/api/v1/transactions?timestamp=${timestamp}&limit=1`);
|
|
772
769
|
return response.transactions;
|
|
773
770
|
} catch (error) {
|
|
774
771
|
this.logger.error(
|
|
@@ -789,13 +786,15 @@ class HederaMirrorNode {
|
|
|
789
786
|
`Getting NFTs for account ${accountId}${tokenId ? ` for token ${tokenId}` : ""}`
|
|
790
787
|
);
|
|
791
788
|
let allNfts = [];
|
|
792
|
-
let
|
|
789
|
+
let endpoint = `/api/v1/accounts/${accountId}/nfts?limit=${limit}`;
|
|
793
790
|
if (tokenId) {
|
|
794
|
-
|
|
791
|
+
endpoint += `&token.id=${tokenId}`;
|
|
795
792
|
}
|
|
796
793
|
try {
|
|
797
|
-
for (let i = 0; i < 10 &&
|
|
798
|
-
const response = await this._requestWithRetry(
|
|
794
|
+
for (let i = 0; i < 10 && endpoint; i++) {
|
|
795
|
+
const response = await this._requestWithRetry(
|
|
796
|
+
endpoint
|
|
797
|
+
);
|
|
799
798
|
if (response && response.nfts) {
|
|
800
799
|
const nftsWithUri = response.nfts.map((nft) => {
|
|
801
800
|
let tokenUri = void 0;
|
|
@@ -820,8 +819,8 @@ class HederaMirrorNode {
|
|
|
820
819
|
});
|
|
821
820
|
allNfts = allNfts.concat(nftsWithUri);
|
|
822
821
|
}
|
|
823
|
-
|
|
824
|
-
if (!
|
|
822
|
+
endpoint = response.links?.next || "";
|
|
823
|
+
if (!endpoint) break;
|
|
825
824
|
}
|
|
826
825
|
return allNfts;
|
|
827
826
|
} catch (error) {
|
|
@@ -870,7 +869,6 @@ class HederaMirrorNode {
|
|
|
870
869
|
this.logger.info(
|
|
871
870
|
`Reading smart contract ${contractIdOrAddress} with selector ${functionSelector}`
|
|
872
871
|
);
|
|
873
|
-
const url = `${this.baseUrl}/api/v1/contracts/call`;
|
|
874
872
|
const toAddress = contractIdOrAddress.startsWith("0x") ? contractIdOrAddress : `0x${AccountId.fromString(contractIdOrAddress).toSolidityAddress()}`;
|
|
875
873
|
const fromAddress = payerAccountId.startsWith("0x") ? payerAccountId : `0x${AccountId.fromString(payerAccountId).toSolidityAddress()}`;
|
|
876
874
|
const body = {
|
|
@@ -890,6 +888,7 @@ class HederaMirrorNode {
|
|
|
890
888
|
}
|
|
891
889
|
});
|
|
892
890
|
try {
|
|
891
|
+
const url = this.constructUrl("/api/v1/contracts/call");
|
|
893
892
|
const response = await this._fetchWithRetry(
|
|
894
893
|
url,
|
|
895
894
|
{
|
|
@@ -909,20 +908,87 @@ class HederaMirrorNode {
|
|
|
909
908
|
}
|
|
910
909
|
}
|
|
911
910
|
/**
|
|
912
|
-
* Retrieves token airdrops
|
|
913
|
-
* @param accountId The ID of the account
|
|
914
|
-
* @param
|
|
911
|
+
* Retrieves outstanding token airdrops sent by an account.
|
|
912
|
+
* @param accountId The ID of the account that sent the airdrops.
|
|
913
|
+
* @param options Optional parameters for filtering airdrops.
|
|
915
914
|
* @returns A promise that resolves to an array of TokenAirdrop or null.
|
|
916
915
|
*/
|
|
917
|
-
async
|
|
918
|
-
this.logger.info(
|
|
919
|
-
|
|
916
|
+
async getOutstandingTokenAirdrops(accountId, options) {
|
|
917
|
+
this.logger.info(
|
|
918
|
+
`Getting outstanding token airdrops sent by account ${accountId}`
|
|
919
|
+
);
|
|
920
|
+
let endpoint = `/api/v1/accounts/${accountId}/airdrops/outstanding`;
|
|
921
|
+
const params = new URLSearchParams();
|
|
922
|
+
if (options?.limit) {
|
|
923
|
+
params.append("limit", options.limit.toString());
|
|
924
|
+
}
|
|
925
|
+
if (options?.order) {
|
|
926
|
+
params.append("order", options.order);
|
|
927
|
+
}
|
|
928
|
+
if (options?.receiverId) {
|
|
929
|
+
params.append("receiver.id", options.receiverId);
|
|
930
|
+
}
|
|
931
|
+
if (options?.serialNumber) {
|
|
932
|
+
params.append("serialnumber", options.serialNumber);
|
|
933
|
+
}
|
|
934
|
+
if (options?.tokenId) {
|
|
935
|
+
params.append("token.id", options.tokenId);
|
|
936
|
+
}
|
|
937
|
+
const queryString = params.toString();
|
|
938
|
+
if (queryString) {
|
|
939
|
+
endpoint += `?${queryString}`;
|
|
940
|
+
}
|
|
920
941
|
try {
|
|
921
|
-
const response = await this._requestWithRetry(
|
|
942
|
+
const response = await this._requestWithRetry(
|
|
943
|
+
endpoint
|
|
944
|
+
);
|
|
945
|
+
return response.airdrops || [];
|
|
946
|
+
} catch (error) {
|
|
947
|
+
this.logger.error(
|
|
948
|
+
`Error fetching outstanding token airdrops for account ${accountId}: ${error.message}`
|
|
949
|
+
);
|
|
950
|
+
return null;
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
/**
|
|
954
|
+
* Retrieves pending token airdrops received by an account.
|
|
955
|
+
* @param accountId The ID of the account that received the airdrops.
|
|
956
|
+
* @param options Optional parameters for filtering airdrops.
|
|
957
|
+
* @returns A promise that resolves to an array of TokenAirdrop or null.
|
|
958
|
+
*/
|
|
959
|
+
async getPendingTokenAirdrops(accountId, options) {
|
|
960
|
+
this.logger.info(
|
|
961
|
+
`Getting pending token airdrops received by account ${accountId}`
|
|
962
|
+
);
|
|
963
|
+
let endpoint = `/api/v1/accounts/${accountId}/airdrops/pending`;
|
|
964
|
+
const params = new URLSearchParams();
|
|
965
|
+
if (options?.limit) {
|
|
966
|
+
params.append("limit", options.limit.toString());
|
|
967
|
+
}
|
|
968
|
+
if (options?.order) {
|
|
969
|
+
params.append("order", options.order);
|
|
970
|
+
}
|
|
971
|
+
if (options?.senderId) {
|
|
972
|
+
params.append("sender.id", options.senderId);
|
|
973
|
+
}
|
|
974
|
+
if (options?.serialNumber) {
|
|
975
|
+
params.append("serialnumber", options.serialNumber);
|
|
976
|
+
}
|
|
977
|
+
if (options?.tokenId) {
|
|
978
|
+
params.append("token.id", options.tokenId);
|
|
979
|
+
}
|
|
980
|
+
const queryString = params.toString();
|
|
981
|
+
if (queryString) {
|
|
982
|
+
endpoint += `?${queryString}`;
|
|
983
|
+
}
|
|
984
|
+
try {
|
|
985
|
+
const response = await this._requestWithRetry(
|
|
986
|
+
endpoint
|
|
987
|
+
);
|
|
922
988
|
return response.airdrops || [];
|
|
923
989
|
} catch (error) {
|
|
924
990
|
this.logger.error(
|
|
925
|
-
`Error fetching token airdrops for account ${accountId}: ${error.message}`
|
|
991
|
+
`Error fetching pending token airdrops for account ${accountId}: ${error.message}`
|
|
926
992
|
);
|
|
927
993
|
return null;
|
|
928
994
|
}
|
|
@@ -934,7 +1000,7 @@ class HederaMirrorNode {
|
|
|
934
1000
|
*/
|
|
935
1001
|
async getBlocks(options) {
|
|
936
1002
|
this.logger.info("Getting blocks from the network");
|
|
937
|
-
let
|
|
1003
|
+
let endpoint = `/api/v1/blocks`;
|
|
938
1004
|
const params = new URLSearchParams();
|
|
939
1005
|
if (options?.limit) {
|
|
940
1006
|
params.append("limit", options.limit.toString());
|
|
@@ -950,10 +1016,10 @@ class HederaMirrorNode {
|
|
|
950
1016
|
}
|
|
951
1017
|
const queryString = params.toString();
|
|
952
1018
|
if (queryString) {
|
|
953
|
-
|
|
1019
|
+
endpoint += `?${queryString}`;
|
|
954
1020
|
}
|
|
955
1021
|
try {
|
|
956
|
-
const response = await this._requestWithRetry(
|
|
1022
|
+
const response = await this._requestWithRetry(endpoint);
|
|
957
1023
|
return response.blocks || [];
|
|
958
1024
|
} catch (error) {
|
|
959
1025
|
this.logger.error(`Error fetching blocks: ${error.message}`);
|
|
@@ -967,9 +1033,10 @@ class HederaMirrorNode {
|
|
|
967
1033
|
*/
|
|
968
1034
|
async getBlock(blockNumberOrHash) {
|
|
969
1035
|
this.logger.info(`Getting block ${blockNumberOrHash}`);
|
|
970
|
-
const url = `${this.baseUrl}/api/v1/blocks/${blockNumberOrHash}`;
|
|
971
1036
|
try {
|
|
972
|
-
const response = await this._requestWithRetry(
|
|
1037
|
+
const response = await this._requestWithRetry(
|
|
1038
|
+
`/api/v1/blocks/${blockNumberOrHash}`
|
|
1039
|
+
);
|
|
973
1040
|
return response;
|
|
974
1041
|
} catch (error) {
|
|
975
1042
|
this.logger.error(
|
|
@@ -985,7 +1052,7 @@ class HederaMirrorNode {
|
|
|
985
1052
|
*/
|
|
986
1053
|
async getContracts(options) {
|
|
987
1054
|
this.logger.info("Getting contracts from the network");
|
|
988
|
-
let url =
|
|
1055
|
+
let url = `/api/v1/contracts`;
|
|
989
1056
|
const params = new URLSearchParams();
|
|
990
1057
|
if (options?.contractId) {
|
|
991
1058
|
params.append("contract.id", options.contractId);
|
|
@@ -1016,7 +1083,7 @@ class HederaMirrorNode {
|
|
|
1016
1083
|
*/
|
|
1017
1084
|
async getContract(contractIdOrAddress, timestamp) {
|
|
1018
1085
|
this.logger.info(`Getting contract ${contractIdOrAddress}`);
|
|
1019
|
-
let url =
|
|
1086
|
+
let url = `/api/v1/contracts/${contractIdOrAddress}`;
|
|
1020
1087
|
if (timestamp) {
|
|
1021
1088
|
url += `?timestamp=${timestamp}`;
|
|
1022
1089
|
}
|
|
@@ -1037,7 +1104,7 @@ class HederaMirrorNode {
|
|
|
1037
1104
|
*/
|
|
1038
1105
|
async getContractResults(options) {
|
|
1039
1106
|
this.logger.info("Getting contract results from the network");
|
|
1040
|
-
let url =
|
|
1107
|
+
let url = `/api/v1/contracts/results`;
|
|
1041
1108
|
const params = new URLSearchParams();
|
|
1042
1109
|
if (options?.from) {
|
|
1043
1110
|
params.append("from", options.from);
|
|
@@ -1085,7 +1152,7 @@ class HederaMirrorNode {
|
|
|
1085
1152
|
*/
|
|
1086
1153
|
async getContractResult(transactionIdOrHash, nonce) {
|
|
1087
1154
|
this.logger.info(`Getting contract result for ${transactionIdOrHash}`);
|
|
1088
|
-
let url =
|
|
1155
|
+
let url = `/api/v1/contracts/results/${transactionIdOrHash}`;
|
|
1089
1156
|
if (nonce !== void 0) {
|
|
1090
1157
|
url += `?nonce=${nonce}`;
|
|
1091
1158
|
}
|
|
@@ -1109,7 +1176,7 @@ class HederaMirrorNode {
|
|
|
1109
1176
|
this.logger.info(
|
|
1110
1177
|
`Getting contract results for contract ${contractIdOrAddress}`
|
|
1111
1178
|
);
|
|
1112
|
-
let url =
|
|
1179
|
+
let url = `/api/v1/contracts/${contractIdOrAddress}/results`;
|
|
1113
1180
|
const params = new URLSearchParams();
|
|
1114
1181
|
if (options?.blockHash) {
|
|
1115
1182
|
params.append("block.hash", options.blockHash);
|
|
@@ -1159,7 +1226,7 @@ class HederaMirrorNode {
|
|
|
1159
1226
|
*/
|
|
1160
1227
|
async getContractState(contractIdOrAddress, options) {
|
|
1161
1228
|
this.logger.info(`Getting contract state for ${contractIdOrAddress}`);
|
|
1162
|
-
let url =
|
|
1229
|
+
let url = `/api/v1/contracts/${contractIdOrAddress}/state`;
|
|
1163
1230
|
const params = new URLSearchParams();
|
|
1164
1231
|
if (options?.limit) {
|
|
1165
1232
|
params.append("limit", options.limit.toString());
|
|
@@ -1195,7 +1262,7 @@ class HederaMirrorNode {
|
|
|
1195
1262
|
*/
|
|
1196
1263
|
async getContractActions(transactionIdOrHash, options) {
|
|
1197
1264
|
this.logger.info(`Getting contract actions for ${transactionIdOrHash}`);
|
|
1198
|
-
let url =
|
|
1265
|
+
let url = `/api/v1/contracts/results/${transactionIdOrHash}/actions`;
|
|
1199
1266
|
const params = new URLSearchParams();
|
|
1200
1267
|
if (options?.index) {
|
|
1201
1268
|
params.append("index", options.index);
|
|
@@ -1229,7 +1296,7 @@ class HederaMirrorNode {
|
|
|
1229
1296
|
*/
|
|
1230
1297
|
async getContractLogs(options) {
|
|
1231
1298
|
this.logger.info("Getting contract logs from the network");
|
|
1232
|
-
let url =
|
|
1299
|
+
let url = `/api/v1/contracts/results/logs`;
|
|
1233
1300
|
const params = new URLSearchParams();
|
|
1234
1301
|
if (options?.index) {
|
|
1235
1302
|
params.append("index", options.index);
|
|
@@ -1280,7 +1347,7 @@ class HederaMirrorNode {
|
|
|
1280
1347
|
this.logger.info(
|
|
1281
1348
|
`Getting contract logs for contract ${contractIdOrAddress}`
|
|
1282
1349
|
);
|
|
1283
|
-
let url =
|
|
1350
|
+
let url = `/api/v1/contracts/${contractIdOrAddress}/results/logs`;
|
|
1284
1351
|
const params = new URLSearchParams();
|
|
1285
1352
|
if (options?.index) {
|
|
1286
1353
|
params.append("index", options.index);
|
|
@@ -1320,39 +1387,6 @@ class HederaMirrorNode {
|
|
|
1320
1387
|
return null;
|
|
1321
1388
|
}
|
|
1322
1389
|
}
|
|
1323
|
-
/**
|
|
1324
|
-
* Retrieves opcode traces for a specific transaction.
|
|
1325
|
-
* @param transactionIdOrHash The transaction ID or hash.
|
|
1326
|
-
* @param options Optional parameters for trace details.
|
|
1327
|
-
* @returns A promise that resolves to an OpcodeTraceResponse or null.
|
|
1328
|
-
*/
|
|
1329
|
-
async getOpcodeTraces(transactionIdOrHash, options) {
|
|
1330
|
-
this.logger.info(`Getting opcode traces for ${transactionIdOrHash}`);
|
|
1331
|
-
let url = `${this.baseUrl}/api/v1/contracts/results/${transactionIdOrHash}/opcodes`;
|
|
1332
|
-
const params = new URLSearchParams();
|
|
1333
|
-
if (options?.stack !== void 0) {
|
|
1334
|
-
params.append("stack", options.stack.toString());
|
|
1335
|
-
}
|
|
1336
|
-
if (options?.memory !== void 0) {
|
|
1337
|
-
params.append("memory", options.memory.toString());
|
|
1338
|
-
}
|
|
1339
|
-
if (options?.storage !== void 0) {
|
|
1340
|
-
params.append("storage", options.storage.toString());
|
|
1341
|
-
}
|
|
1342
|
-
const queryString = params.toString();
|
|
1343
|
-
if (queryString) {
|
|
1344
|
-
url += `?${queryString}`;
|
|
1345
|
-
}
|
|
1346
|
-
try {
|
|
1347
|
-
const response = await this._requestWithRetry(url);
|
|
1348
|
-
return response;
|
|
1349
|
-
} catch (error) {
|
|
1350
|
-
this.logger.error(
|
|
1351
|
-
`Error fetching opcode traces for ${transactionIdOrHash}: ${error.message}`
|
|
1352
|
-
);
|
|
1353
|
-
return null;
|
|
1354
|
-
}
|
|
1355
|
-
}
|
|
1356
1390
|
/**
|
|
1357
1391
|
* Retrieves NFT information by token ID and serial number.
|
|
1358
1392
|
* @param tokenId The token ID.
|
|
@@ -1361,10 +1395,10 @@ class HederaMirrorNode {
|
|
|
1361
1395
|
*/
|
|
1362
1396
|
async getNftInfo(tokenId, serialNumber) {
|
|
1363
1397
|
this.logger.info(`Getting NFT info for ${tokenId}/${serialNumber}`);
|
|
1364
|
-
const url =
|
|
1398
|
+
const url = `/api/v1/tokens/${tokenId}/nfts/${serialNumber}`;
|
|
1365
1399
|
try {
|
|
1366
1400
|
const response = await this._requestWithRetry(url);
|
|
1367
|
-
return response
|
|
1401
|
+
return response;
|
|
1368
1402
|
} catch (error) {
|
|
1369
1403
|
this.logger.error(
|
|
1370
1404
|
`Error fetching NFT info for ${tokenId}/${serialNumber}: ${error.message}`
|
|
@@ -1380,7 +1414,7 @@ class HederaMirrorNode {
|
|
|
1380
1414
|
*/
|
|
1381
1415
|
async getNftsByToken(tokenId, options) {
|
|
1382
1416
|
this.logger.info(`Getting NFTs for token ${tokenId}`);
|
|
1383
|
-
let url =
|
|
1417
|
+
let url = `/api/v1/tokens/${tokenId}/nfts`;
|
|
1384
1418
|
const params = new URLSearchParams();
|
|
1385
1419
|
if (options?.accountId) {
|
|
1386
1420
|
params.append("account.id", options.accountId);
|
|
@@ -1414,7 +1448,7 @@ class HederaMirrorNode {
|
|
|
1414
1448
|
*/
|
|
1415
1449
|
async getNetworkInfo() {
|
|
1416
1450
|
this.logger.info("Getting network information");
|
|
1417
|
-
const url =
|
|
1451
|
+
const url = `/api/v1/network/nodes`;
|
|
1418
1452
|
try {
|
|
1419
1453
|
const response = await this._requestWithRetry(url);
|
|
1420
1454
|
return response;
|
|
@@ -1430,7 +1464,7 @@ class HederaMirrorNode {
|
|
|
1430
1464
|
*/
|
|
1431
1465
|
async getNetworkFees(timestamp) {
|
|
1432
1466
|
this.logger.info("Getting network fees");
|
|
1433
|
-
let url =
|
|
1467
|
+
let url = `/api/v1/network/fees`;
|
|
1434
1468
|
if (timestamp) {
|
|
1435
1469
|
url += `?timestamp=${timestamp}`;
|
|
1436
1470
|
}
|
|
@@ -1449,7 +1483,7 @@ class HederaMirrorNode {
|
|
|
1449
1483
|
*/
|
|
1450
1484
|
async getNetworkSupply(timestamp) {
|
|
1451
1485
|
this.logger.info("Getting network supply");
|
|
1452
|
-
let url =
|
|
1486
|
+
let url = `/api/v1/network/supply`;
|
|
1453
1487
|
if (timestamp) {
|
|
1454
1488
|
url += `?timestamp=${timestamp}`;
|
|
1455
1489
|
}
|
|
@@ -1468,7 +1502,7 @@ class HederaMirrorNode {
|
|
|
1468
1502
|
*/
|
|
1469
1503
|
async getNetworkStake(timestamp) {
|
|
1470
1504
|
this.logger.info("Getting network stake");
|
|
1471
|
-
let url =
|
|
1505
|
+
let url = `/api/v1/network/stake`;
|
|
1472
1506
|
if (timestamp) {
|
|
1473
1507
|
url += `?timestamp=${timestamp}`;
|
|
1474
1508
|
}
|
|
@@ -1480,6 +1514,39 @@ class HederaMirrorNode {
|
|
|
1480
1514
|
return null;
|
|
1481
1515
|
}
|
|
1482
1516
|
}
|
|
1517
|
+
/**
|
|
1518
|
+
* Retrieves opcode traces for a specific transaction.
|
|
1519
|
+
* @param transactionIdOrHash The transaction ID or hash.
|
|
1520
|
+
* @param options Optional parameters for trace details.
|
|
1521
|
+
* @returns A promise that resolves to an OpcodesResponse or null.
|
|
1522
|
+
*/
|
|
1523
|
+
async getOpcodeTraces(transactionIdOrHash, options) {
|
|
1524
|
+
this.logger.info(`Getting opcode traces for ${transactionIdOrHash}`);
|
|
1525
|
+
let url = `/api/v1/contracts/results/${transactionIdOrHash}/opcodes`;
|
|
1526
|
+
const params = new URLSearchParams();
|
|
1527
|
+
if (options?.stack !== void 0) {
|
|
1528
|
+
params.append("stack", options.stack.toString());
|
|
1529
|
+
}
|
|
1530
|
+
if (options?.memory !== void 0) {
|
|
1531
|
+
params.append("memory", options.memory.toString());
|
|
1532
|
+
}
|
|
1533
|
+
if (options?.storage !== void 0) {
|
|
1534
|
+
params.append("storage", options.storage.toString());
|
|
1535
|
+
}
|
|
1536
|
+
const queryString = params.toString();
|
|
1537
|
+
if (queryString) {
|
|
1538
|
+
url += `?${queryString}`;
|
|
1539
|
+
}
|
|
1540
|
+
try {
|
|
1541
|
+
const response = await this._requestWithRetry(url);
|
|
1542
|
+
return response;
|
|
1543
|
+
} catch (error) {
|
|
1544
|
+
this.logger.error(
|
|
1545
|
+
`Error fetching opcode traces for ${transactionIdOrHash}: ${error.message}`
|
|
1546
|
+
);
|
|
1547
|
+
return null;
|
|
1548
|
+
}
|
|
1549
|
+
}
|
|
1483
1550
|
}
|
|
1484
1551
|
export {
|
|
1485
1552
|
HederaMirrorNode
|