@hashgraphonline/standards-sdk 0.0.112-canary.0 → 0.0.112-canary.2

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