@hashgraphonline/standards-sdk 0.0.95 → 0.0.96

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (264) hide show
  1. package/dist/es/hcs-10/base-client.d.ts +14 -3
  2. package/dist/es/hcs-10/base-client.d.ts.map +1 -1
  3. package/dist/es/hcs-10/connections-manager.d.ts +51 -0
  4. package/dist/es/hcs-10/connections-manager.d.ts.map +1 -1
  5. package/dist/es/hcs-10/sdk.d.ts +38 -1
  6. package/dist/es/hcs-10/sdk.d.ts.map +1 -1
  7. package/dist/es/hcs-10/types.d.ts +9 -0
  8. package/dist/es/hcs-10/types.d.ts.map +1 -1
  9. package/dist/es/services/mirror-node.d.ts +17 -1
  10. package/dist/es/services/mirror-node.d.ts.map +1 -1
  11. package/dist/es/services/types.d.ts +24 -0
  12. package/dist/es/services/types.d.ts.map +1 -1
  13. package/dist/es/standards-sdk.es.js +6 -4
  14. package/dist/es/standards-sdk.es.js.map +1 -1
  15. package/dist/es/standards-sdk.es10.js +66 -0
  16. package/dist/es/standards-sdk.es10.js.map +1 -1
  17. package/dist/es/standards-sdk.es100.js +22 -12
  18. package/dist/es/standards-sdk.es100.js.map +1 -1
  19. package/dist/es/standards-sdk.es101.js +793 -13
  20. package/dist/es/standards-sdk.es101.js.map +1 -1
  21. package/dist/es/standards-sdk.es102.js +172 -30
  22. package/dist/es/standards-sdk.es102.js.map +1 -1
  23. package/dist/es/standards-sdk.es103.js +142 -14
  24. package/dist/es/standards-sdk.es103.js.map +1 -1
  25. package/dist/es/standards-sdk.es104.js +13 -4
  26. package/dist/es/standards-sdk.es104.js.map +1 -1
  27. package/dist/es/standards-sdk.es105.js +13 -4
  28. package/dist/es/standards-sdk.es105.js.map +1 -1
  29. package/dist/es/standards-sdk.es106.js +31 -15
  30. package/dist/es/standards-sdk.es106.js.map +1 -1
  31. package/dist/es/standards-sdk.es107.js +14 -4
  32. package/dist/es/standards-sdk.es107.js.map +1 -1
  33. package/dist/es/standards-sdk.es108.js +4 -39
  34. package/dist/es/standards-sdk.es108.js.map +1 -1
  35. package/dist/es/standards-sdk.es109.js +4 -40
  36. package/dist/es/standards-sdk.es109.js.map +1 -1
  37. package/dist/es/standards-sdk.es110.js +15 -36
  38. package/dist/es/standards-sdk.es110.js.map +1 -1
  39. package/dist/es/standards-sdk.es111.js +5 -78
  40. package/dist/es/standards-sdk.es111.js.map +1 -1
  41. package/dist/es/standards-sdk.es112.js +39 -3
  42. package/dist/es/standards-sdk.es112.js.map +1 -1
  43. package/dist/es/standards-sdk.es113.js +40 -2
  44. package/dist/es/standards-sdk.es113.js.map +1 -1
  45. package/dist/es/standards-sdk.es114.js +37 -2
  46. package/dist/es/standards-sdk.es114.js.map +1 -1
  47. package/dist/es/standards-sdk.es115.js +75 -31
  48. package/dist/es/standards-sdk.es115.js.map +1 -1
  49. package/dist/es/standards-sdk.es116.js +20 -32
  50. package/dist/es/standards-sdk.es116.js.map +1 -1
  51. package/dist/es/standards-sdk.es117.js +27 -9
  52. package/dist/es/standards-sdk.es117.js.map +1 -1
  53. package/dist/es/standards-sdk.es118.js +25 -33
  54. package/dist/es/standards-sdk.es118.js.map +1 -1
  55. package/dist/es/standards-sdk.es119.js +41 -0
  56. package/dist/es/standards-sdk.es119.js.map +1 -0
  57. package/dist/es/standards-sdk.es120.js +6 -0
  58. package/dist/es/standards-sdk.es120.js.map +1 -0
  59. package/dist/es/standards-sdk.es121.js +5 -0
  60. package/dist/es/standards-sdk.es121.js.map +1 -0
  61. package/dist/es/standards-sdk.es122.js +5 -0
  62. package/dist/es/standards-sdk.es122.js.map +1 -0
  63. package/dist/es/standards-sdk.es123.js +37 -0
  64. package/dist/es/standards-sdk.es123.js.map +1 -0
  65. package/dist/es/standards-sdk.es124.js +36 -0
  66. package/dist/es/standards-sdk.es124.js.map +1 -0
  67. package/dist/es/standards-sdk.es125.js +12 -0
  68. package/dist/es/standards-sdk.es125.js.map +1 -0
  69. package/dist/es/standards-sdk.es126.js +37 -0
  70. package/dist/es/standards-sdk.es126.js.map +1 -0
  71. package/dist/es/standards-sdk.es13.js +3 -3
  72. package/dist/es/standards-sdk.es15.js +1 -1
  73. package/dist/es/standards-sdk.es16.js +1 -1
  74. package/dist/es/standards-sdk.es18.js +2 -2
  75. package/dist/es/standards-sdk.es19.js +393 -387
  76. package/dist/es/standards-sdk.es19.js.map +1 -1
  77. package/dist/es/standards-sdk.es20.js +385 -314
  78. package/dist/es/standards-sdk.es20.js.map +1 -1
  79. package/dist/es/standards-sdk.es21.js +357 -128
  80. package/dist/es/standards-sdk.es21.js.map +1 -1
  81. package/dist/es/standards-sdk.es22.js +155 -7
  82. package/dist/es/standards-sdk.es22.js.map +1 -1
  83. package/dist/es/standards-sdk.es23.js +7 -1041
  84. package/dist/es/standards-sdk.es23.js.map +1 -1
  85. package/dist/es/standards-sdk.es24.js +2 -0
  86. package/dist/es/standards-sdk.es24.js.map +1 -1
  87. package/dist/es/standards-sdk.es25.js +1 -1
  88. package/dist/es/standards-sdk.es26.js +1 -1
  89. package/dist/es/standards-sdk.es27.js +9 -2
  90. package/dist/es/standards-sdk.es27.js.map +1 -1
  91. package/dist/es/standards-sdk.es28.js +2 -4167
  92. package/dist/es/standards-sdk.es28.js.map +1 -1
  93. package/dist/es/standards-sdk.es29.js +1041 -36
  94. package/dist/es/standards-sdk.es29.js.map +1 -1
  95. package/dist/es/standards-sdk.es30.js +5 -48
  96. package/dist/es/standards-sdk.es30.js.map +1 -1
  97. package/dist/es/standards-sdk.es31.js +36 -5
  98. package/dist/es/standards-sdk.es31.js.map +1 -1
  99. package/dist/es/standards-sdk.es32.js +48 -2
  100. package/dist/es/standards-sdk.es32.js.map +1 -1
  101. package/dist/es/standards-sdk.es33.js +9 -100
  102. package/dist/es/standards-sdk.es33.js.map +1 -1
  103. package/dist/es/standards-sdk.es34.js +4167 -2
  104. package/dist/es/standards-sdk.es34.js.map +1 -1
  105. package/dist/es/standards-sdk.es35.js +96 -11
  106. package/dist/es/standards-sdk.es35.js.map +1 -1
  107. package/dist/es/standards-sdk.es36.js +2 -409
  108. package/dist/es/standards-sdk.es36.js.map +1 -1
  109. package/dist/es/standards-sdk.es37.js +15 -194
  110. package/dist/es/standards-sdk.es37.js.map +1 -1
  111. package/dist/es/standards-sdk.es38.js +389 -418
  112. package/dist/es/standards-sdk.es38.js.map +1 -1
  113. package/dist/es/standards-sdk.es39.js +2282 -25
  114. package/dist/es/standards-sdk.es39.js.map +1 -1
  115. package/dist/es/standards-sdk.es4.js +1 -1
  116. package/dist/es/standards-sdk.es40.js +150 -125
  117. package/dist/es/standards-sdk.es40.js.map +1 -1
  118. package/dist/es/standards-sdk.es41.js +7130 -12
  119. package/dist/es/standards-sdk.es41.js.map +1 -1
  120. package/dist/es/standards-sdk.es42.js +9 -28
  121. package/dist/es/standards-sdk.es42.js.map +1 -1
  122. package/dist/es/standards-sdk.es43.js +8 -26
  123. package/dist/es/standards-sdk.es43.js.map +1 -1
  124. package/dist/es/standards-sdk.es44.js +15 -18
  125. package/dist/es/standards-sdk.es44.js.map +1 -1
  126. package/dist/es/standards-sdk.es45.js +4 -42
  127. package/dist/es/standards-sdk.es45.js.map +1 -1
  128. package/dist/es/standards-sdk.es46.js +8 -17
  129. package/dist/es/standards-sdk.es46.js.map +1 -1
  130. package/dist/es/standards-sdk.es47.js +3 -61
  131. package/dist/es/standards-sdk.es47.js.map +1 -1
  132. package/dist/es/standards-sdk.es48.js +384 -1254
  133. package/dist/es/standards-sdk.es48.js.map +1 -1
  134. package/dist/es/standards-sdk.es49.js +2 -148
  135. package/dist/es/standards-sdk.es49.js.map +1 -1
  136. package/dist/es/standards-sdk.es5.js +31 -8
  137. package/dist/es/standards-sdk.es5.js.map +1 -1
  138. package/dist/es/standards-sdk.es50.js +115 -86
  139. package/dist/es/standards-sdk.es50.js.map +1 -1
  140. package/dist/es/standards-sdk.es51.js +3 -83
  141. package/dist/es/standards-sdk.es51.js.map +1 -1
  142. package/dist/es/standards-sdk.es52.js +360 -28
  143. package/dist/es/standards-sdk.es52.js.map +1 -1
  144. package/dist/es/standards-sdk.es53.js +5 -5
  145. package/dist/es/standards-sdk.es53.js.map +1 -1
  146. package/dist/es/standards-sdk.es54.js +167 -147
  147. package/dist/es/standards-sdk.es54.js.map +1 -1
  148. package/dist/es/standards-sdk.es55.js +80 -22
  149. package/dist/es/standards-sdk.es55.js.map +1 -1
  150. package/dist/es/standards-sdk.es56.js +102 -781
  151. package/dist/es/standards-sdk.es56.js.map +1 -1
  152. package/dist/es/standards-sdk.es57.js +44 -166
  153. package/dist/es/standards-sdk.es57.js.map +1 -1
  154. package/dist/es/standards-sdk.es58.js +10 -2282
  155. package/dist/es/standards-sdk.es58.js.map +1 -1
  156. package/dist/es/standards-sdk.es59.js +85 -152
  157. package/dist/es/standards-sdk.es59.js.map +1 -1
  158. package/dist/es/standards-sdk.es60.js +3 -142
  159. package/dist/es/standards-sdk.es60.js.map +1 -1
  160. package/dist/es/standards-sdk.es61.js +2 -7136
  161. package/dist/es/standards-sdk.es61.js.map +1 -1
  162. package/dist/es/standards-sdk.es62.js +108 -16
  163. package/dist/es/standards-sdk.es62.js.map +1 -1
  164. package/dist/es/standards-sdk.es63.js +72 -25
  165. package/dist/es/standards-sdk.es63.js.map +1 -1
  166. package/dist/es/standards-sdk.es64.js +5 -25
  167. package/dist/es/standards-sdk.es64.js.map +1 -1
  168. package/dist/es/standards-sdk.es65.js +4 -37
  169. package/dist/es/standards-sdk.es65.js.map +1 -1
  170. package/dist/es/standards-sdk.es66.js +187 -385
  171. package/dist/es/standards-sdk.es66.js.map +1 -1
  172. package/dist/es/standards-sdk.es67.js +58 -2
  173. package/dist/es/standards-sdk.es67.js.map +1 -1
  174. package/dist/es/standards-sdk.es68.js +69 -120
  175. package/dist/es/standards-sdk.es68.js.map +1 -1
  176. package/dist/es/standards-sdk.es69.js +2 -3
  177. package/dist/es/standards-sdk.es69.js.map +1 -1
  178. package/dist/es/standards-sdk.es7.js +103 -2
  179. package/dist/es/standards-sdk.es7.js.map +1 -1
  180. package/dist/es/standards-sdk.es70.js +31 -3
  181. package/dist/es/standards-sdk.es70.js.map +1 -1
  182. package/dist/es/standards-sdk.es71.js +54 -355
  183. package/dist/es/standards-sdk.es71.js.map +1 -1
  184. package/dist/es/standards-sdk.es72.js +49 -5
  185. package/dist/es/standards-sdk.es72.js.map +1 -1
  186. package/dist/es/standards-sdk.es73.js +9 -178
  187. package/dist/es/standards-sdk.es73.js.map +1 -1
  188. package/dist/es/standards-sdk.es74.js +57 -73
  189. package/dist/es/standards-sdk.es74.js.map +1 -1
  190. package/dist/es/standards-sdk.es75.js +5 -113
  191. package/dist/es/standards-sdk.es75.js.map +1 -1
  192. package/dist/es/standards-sdk.es76.js +12 -49
  193. package/dist/es/standards-sdk.es76.js.map +1 -1
  194. package/dist/es/standards-sdk.es77.js +7 -10
  195. package/dist/es/standards-sdk.es77.js.map +1 -1
  196. package/dist/es/standards-sdk.es78.js +41 -93
  197. package/dist/es/standards-sdk.es78.js.map +1 -1
  198. package/dist/es/standards-sdk.es79.js +2 -4
  199. package/dist/es/standards-sdk.es79.js.map +1 -1
  200. package/dist/es/standards-sdk.es8.js +1 -1
  201. package/dist/es/standards-sdk.es80.js +136 -2
  202. package/dist/es/standards-sdk.es80.js.map +1 -1
  203. package/dist/es/standards-sdk.es81.js +162 -103
  204. package/dist/es/standards-sdk.es81.js.map +1 -1
  205. package/dist/es/standards-sdk.es82.js +190 -69
  206. package/dist/es/standards-sdk.es82.js.map +1 -1
  207. package/dist/es/standards-sdk.es83.js +437 -5
  208. package/dist/es/standards-sdk.es83.js.map +1 -1
  209. package/dist/es/standards-sdk.es84.js +24 -4
  210. package/dist/es/standards-sdk.es84.js.map +1 -1
  211. package/dist/es/standards-sdk.es85.js +122 -204
  212. package/dist/es/standards-sdk.es85.js.map +1 -1
  213. package/dist/es/standards-sdk.es86.js +17 -57
  214. package/dist/es/standards-sdk.es86.js.map +1 -1
  215. package/dist/es/standards-sdk.es87.js +29 -69
  216. package/dist/es/standards-sdk.es87.js.map +1 -1
  217. package/dist/es/standards-sdk.es88.js +24 -27
  218. package/dist/es/standards-sdk.es88.js.map +1 -1
  219. package/dist/es/standards-sdk.es89.js +15 -57
  220. package/dist/es/standards-sdk.es89.js.map +1 -1
  221. package/dist/es/standards-sdk.es9.js +1 -1
  222. package/dist/es/standards-sdk.es90.js +39 -45
  223. package/dist/es/standards-sdk.es90.js.map +1 -1
  224. package/dist/es/standards-sdk.es91.js +17 -9
  225. package/dist/es/standards-sdk.es91.js.map +1 -1
  226. package/dist/es/standards-sdk.es92.js +57 -61
  227. package/dist/es/standards-sdk.es92.js.map +1 -1
  228. package/dist/es/standards-sdk.es93.js +1288 -5
  229. package/dist/es/standards-sdk.es93.js.map +1 -1
  230. package/dist/es/standards-sdk.es94.js +145 -12
  231. package/dist/es/standards-sdk.es94.js.map +1 -1
  232. package/dist/es/standards-sdk.es95.js +91 -7
  233. package/dist/es/standards-sdk.es95.js.map +1 -1
  234. package/dist/es/standards-sdk.es96.js +82 -43
  235. package/dist/es/standards-sdk.es96.js.map +1 -1
  236. package/dist/es/standards-sdk.es97.js +32 -2
  237. package/dist/es/standards-sdk.es97.js.map +1 -1
  238. package/dist/es/standards-sdk.es98.js +6 -136
  239. package/dist/es/standards-sdk.es98.js.map +1 -1
  240. package/dist/es/standards-sdk.es99.js +148 -161
  241. package/dist/es/standards-sdk.es99.js.map +1 -1
  242. package/dist/es/utils/index.d.ts +1 -0
  243. package/dist/es/utils/index.d.ts.map +1 -1
  244. package/dist/es/utils/transaction-parser.d.ts +103 -0
  245. package/dist/es/utils/transaction-parser.d.ts.map +1 -0
  246. package/dist/umd/hcs-10/base-client.d.ts +14 -3
  247. package/dist/umd/hcs-10/base-client.d.ts.map +1 -1
  248. package/dist/umd/hcs-10/connections-manager.d.ts +51 -0
  249. package/dist/umd/hcs-10/connections-manager.d.ts.map +1 -1
  250. package/dist/umd/hcs-10/sdk.d.ts +38 -1
  251. package/dist/umd/hcs-10/sdk.d.ts.map +1 -1
  252. package/dist/umd/hcs-10/types.d.ts +9 -0
  253. package/dist/umd/hcs-10/types.d.ts.map +1 -1
  254. package/dist/umd/services/mirror-node.d.ts +17 -1
  255. package/dist/umd/services/mirror-node.d.ts.map +1 -1
  256. package/dist/umd/services/types.d.ts +24 -0
  257. package/dist/umd/services/types.d.ts.map +1 -1
  258. package/dist/umd/standards-sdk.umd.js +8 -8
  259. package/dist/umd/standards-sdk.umd.js.map +1 -1
  260. package/dist/umd/utils/index.d.ts +1 -0
  261. package/dist/umd/utils/index.d.ts.map +1 -1
  262. package/dist/umd/utils/transaction-parser.d.ts +103 -0
  263. package/dist/umd/utils/transaction-parser.d.ts.map +1 -0
  264. package/package.json +6 -2
@@ -1,340 +1,411 @@
1
1
  import Buffer from "./standards-sdk.es24.js";
2
- import { PublicKey, Timestamp } from "@hashgraph/sdk";
3
- import "./standards-sdk.es29.js";
4
- import { proto } from "@hashgraph/proto";
5
- import axios from "./standards-sdk.es30.js";
6
- class HederaMirrorNode {
7
- constructor(network, logger) {
8
- this.network = network;
9
- this.baseUrl = this.getMirrorNodeUrl();
10
- this.logger = logger;
11
- this.isServerEnvironment = typeof window === "undefined";
12
- }
13
- getMirrorNodeUrl() {
14
- return this.network === "mainnet" ? "https://mainnet-public.mirrornode.hedera.com" : "https://testnet.mirrornode.hedera.com";
15
- }
16
- getBaseUrl() {
17
- return this.baseUrl;
18
- }
19
- /**
20
- * Retrieves the public key for a given account ID from the mirror node.
21
- * @param accountId The ID of the account to retrieve the public key for.
22
- * @returns A promise that resolves to the public key for the given account.
23
- * @throws An error if the account ID is invalid or the public key cannot be retrieved.
24
- */
25
- async getPublicKey(accountId) {
26
- this.logger.info(`Getting public key for account ${accountId}`);
27
- const accountInfo = await this.requestAccount(accountId);
28
- try {
29
- if (!accountInfo || !accountInfo.key) {
30
- throw new Error(
31
- `Failed to retrieve public key for account ID: ${accountId}`
32
- );
33
- }
34
- return PublicKey.fromString(accountInfo.key.key);
35
- } catch (e) {
36
- const error = e;
37
- const logMessage = `Error fetching public key from Mirror Node: ${error.message}`;
38
- this.logger.error(logMessage);
39
- throw new Error(logMessage);
2
+ import { I as InscriptionSDK } from "./standards-sdk.es25.js";
3
+ import { Logger } from "./standards-sdk.es15.js";
4
+ import { ProgressReporter } from "./standards-sdk.es17.js";
5
+ async function inscribe(input, clientConfig, options, existingSDK) {
6
+ const logger = Logger.getInstance({
7
+ module: "Inscriber",
8
+ ...options.logging
9
+ });
10
+ logger.info("Starting inscription process", {
11
+ type: input.type,
12
+ mode: options.mode || "file",
13
+ ...input.type === "url" ? { url: input.url } : {},
14
+ ...input.type === "file" ? { path: input.path } : {},
15
+ ...input.type === "buffer" ? { fileName: input.fileName, bufferSize: input.buffer.byteLength } : {}
16
+ });
17
+ try {
18
+ if (options.mode === "hashinal" && options.metadata) {
19
+ validateHashinalMetadata(options.metadata, logger);
40
20
  }
41
- }
42
- /**
43
- * Retrieves the memo for a given account ID from the mirror node.
44
- * @param accountId The ID of the account to retrieve the memo for.
45
- * @returns A promise that resolves to the memo for the given account.
46
- * @throws An error if the account ID is invalid or the memo cannot be retrieved.
47
- */
48
- async getAccountMemo(accountId) {
49
- const maxRetries = 3;
50
- for (let attempt = 0; attempt < maxRetries; attempt++) {
51
- try {
52
- const accountInfoUrl = `${this.baseUrl}/api/v1/accounts/${accountId}`;
53
- const response = await axios.get(accountInfoUrl);
54
- const accountInfo = response.data;
55
- if (accountInfo && accountInfo.memo) {
56
- return accountInfo.memo;
57
- }
58
- this.logger.error(`No memo found for account ${accountId}`);
59
- if (attempt < maxRetries - 1) {
60
- await new Promise((resolve) => setTimeout(resolve, 2e3));
61
- }
62
- } catch (e) {
63
- const error = e;
64
- const logMessage = `Error getting account memo (attempt ${attempt + 1}): ${error.message}`;
65
- this.logger.error(logMessage);
66
- if (attempt < maxRetries - 1) {
67
- await new Promise((resolve) => setTimeout(resolve, 2e3));
68
- }
69
- }
21
+ let sdk;
22
+ if (existingSDK) {
23
+ logger.debug("Using existing InscriptionSDK instance");
24
+ sdk = existingSDK;
25
+ } else if (options.apiKey) {
26
+ logger.debug("Initializing InscriptionSDK with API key");
27
+ sdk = new InscriptionSDK({
28
+ apiKey: options.apiKey,
29
+ network: clientConfig.network || "mainnet"
30
+ });
31
+ } else {
32
+ logger.debug("Initializing InscriptionSDK with server auth");
33
+ sdk = await InscriptionSDK.createWithAuth({
34
+ type: "server",
35
+ accountId: clientConfig.accountId,
36
+ privateKey: clientConfig.privateKey,
37
+ network: clientConfig.network || "mainnet"
38
+ });
70
39
  }
71
- return null;
72
- }
73
- /**
74
- * Retrieves topic information for a given topic ID from the mirror node.
75
- * @param topicId The ID of the topic to retrieve information for.
76
- * @returns A promise that resolves to the topic information.
77
- * @throws An error if the topic ID is invalid or the information cannot be retrieved.
78
- */
79
- async getTopicInfo(topicId) {
80
- try {
81
- const topicInfoUrl = `${this.baseUrl}/api/v1/topics/${topicId}`;
82
- const response = await axios.get(topicInfoUrl);
83
- return response.data;
84
- } catch (e) {
85
- const error = e;
86
- const logMessage = `Error retrieving topic information: ${error.message}`;
87
- this.logger.error(logMessage);
88
- throw new Error(logMessage);
40
+ const baseRequest = {
41
+ holderId: clientConfig.accountId,
42
+ metadata: options.metadata || {},
43
+ tags: options.tags || [],
44
+ mode: options.mode || "file",
45
+ chunkSize: options.chunkSize
46
+ };
47
+ let request;
48
+ switch (input.type) {
49
+ case "url":
50
+ request = {
51
+ ...baseRequest,
52
+ file: {
53
+ type: "url",
54
+ url: input.url
55
+ }
56
+ };
57
+ break;
58
+ case "file":
59
+ request = {
60
+ ...baseRequest,
61
+ file: {
62
+ type: "path",
63
+ path: input.path
64
+ }
65
+ };
66
+ break;
67
+ case "buffer":
68
+ request = {
69
+ ...baseRequest,
70
+ file: {
71
+ type: "base64",
72
+ base64: Buffer.from(input.buffer).toString("base64"),
73
+ fileName: input.fileName,
74
+ mimeType: input.mimeType
75
+ }
76
+ };
77
+ break;
89
78
  }
90
- }
91
- /**
92
- * Retrieves custom fees for a given topic ID from the mirror node.
93
- * @param topicId The ID of the topic to retrieve custom fees for.
94
- * @returns A promise that resolves to the custom fees for the given topic.
95
- * @throws An error if the topic ID is invalid or the custom fees cannot be retrieved.
96
- */
97
- async getTopicFees(topicId) {
98
- try {
99
- const topicInfo = await this.getTopicInfo(topicId);
100
- return topicInfo.custom_fees;
101
- } catch (e) {
102
- const error = e;
103
- const logMessage = `Error retrieving topic fees: ${error.message}`;
104
- this.logger.error(logMessage);
105
- return null;
79
+ if (options.mode === "hashinal") {
80
+ request.metadataObject = options.metadata;
81
+ request.creator = options.metadata?.creator || clientConfig.accountId;
82
+ request.description = options.metadata?.description;
83
+ if (options.jsonFileURL) {
84
+ request.jsonFileURL = options.jsonFileURL;
85
+ }
106
86
  }
107
- }
108
- /**
109
- * Retrieves the current HBAR price from the mirror node.
110
- * @param date The date to retrieve the HBAR price for.
111
- * @returns A promise that resolves to the HBAR price for the given date.
112
- * @throws An error if the date is invalid or the price cannot be retrieved.
113
- */
114
- async getHBARPrice(date) {
115
- try {
116
- const timestamp = Timestamp.fromDate(date).toString();
117
- const request = await fetch(
118
- `https://mainnet-public.mirrornode.hedera.com/api/v1/network/exchangerate?timestamp=${timestamp}`
87
+ logger.debug("Preparing to inscribe content", {
88
+ type: input.type,
89
+ mode: options.mode || "file",
90
+ holderId: clientConfig.accountId
91
+ });
92
+ const result = await sdk.inscribeAndExecute(request, clientConfig);
93
+ logger.info("Starting to inscribe.", {
94
+ type: input.type,
95
+ mode: options.mode || "file",
96
+ transactionId: result.jobId
97
+ });
98
+ if (options.waitForConfirmation) {
99
+ logger.debug("Waiting for inscription confirmation", {
100
+ transactionId: result.jobId,
101
+ maxAttempts: options.waitMaxAttempts,
102
+ intervalMs: options.waitIntervalMs
103
+ });
104
+ const inscription = await waitForInscriptionConfirmation(
105
+ sdk,
106
+ result.jobId,
107
+ options.waitMaxAttempts,
108
+ options.waitIntervalMs,
109
+ options.progressCallback
119
110
  );
120
- const response = await request.json();
121
- const usdPrice = Number(response?.current_rate?.cent_equivalent) / Number(response?.current_rate?.hbar_equivalent) / 100;
122
- return usdPrice;
123
- } catch (e) {
124
- const error = e;
125
- const logMessage = `Error retrieving HBAR price: ${error.message}`;
126
- this.logger.error(logMessage);
127
- return null;
111
+ logger.info("Inscription confirmation received", {
112
+ transactionId: result.jobId
113
+ });
114
+ return {
115
+ confirmed: true,
116
+ result,
117
+ inscription,
118
+ sdk
119
+ };
128
120
  }
121
+ return {
122
+ confirmed: false,
123
+ result,
124
+ sdk
125
+ };
126
+ } catch (error) {
127
+ logger.error("Error during inscription process", error);
128
+ throw error;
129
129
  }
130
- /**
131
- * Retrieves token information for a given token ID from the mirror node.
132
- * @param tokenId The ID of the token to retrieve information for.
133
- * @returns A promise that resolves to the token information.
134
- * @throws An error if the token ID is invalid or the information cannot be retrieved.
135
- */
136
- async getTokenInfo(tokenId) {
137
- this.logger.debug(`Fetching token info for ${tokenId}`);
138
- try {
139
- const tokenInfoUrl = `${this.baseUrl}/api/v1/tokens/${tokenId}`;
140
- const response = await axios.get(tokenInfoUrl);
141
- if (response.data) {
142
- this.logger.trace(`Token info found for ${tokenId}:`, response.data);
143
- return response.data;
144
- }
145
- this.logger.warn(`No token info found for ${tokenId}`);
146
- return null;
147
- } catch (e) {
148
- const error = e;
149
- const logMessage = `Error fetching token info for ${tokenId}: ${error.message}`;
150
- this.logger.error(logMessage);
151
- return null;
130
+ }
131
+ async function inscribeWithSigner(input, signer, options, existingSDK) {
132
+ const logger = Logger.getInstance({
133
+ module: "Inscriber",
134
+ ...options.logging
135
+ });
136
+ logger.info("Starting inscription process with signer", {
137
+ type: input.type,
138
+ mode: options.mode || "file",
139
+ ...input.type === "url" ? { url: input.url } : {},
140
+ ...input.type === "file" ? { path: input.path } : {},
141
+ ...input.type === "buffer" ? { fileName: input.fileName, bufferSize: input.buffer.byteLength } : {}
142
+ });
143
+ try {
144
+ if (options.mode === "hashinal" && options.metadata) {
145
+ validateHashinalMetadata(options.metadata, logger);
152
146
  }
153
- }
154
- /**
155
- * Retrieves messages for a given topic ID from the mirror node.
156
- * @param topicId The ID of the topic to retrieve messages for.
157
- * @returns A promise that resolves to the messages for the given topic.
158
- * @throws An error if the topic ID is invalid or the messages cannot be retrieved.
159
- */
160
- async getTopicMessages(topicId) {
161
- this.logger.trace(`Querying messages for topic ${topicId}`);
162
- let nextUrl = `${this.baseUrl}/api/v1/topics/${topicId}/messages`;
163
- const messages = [];
164
- while (nextUrl) {
165
- try {
166
- const response = await axios.get(nextUrl);
167
- const data = response.data;
168
- if (data.messages && data.messages.length > 0) {
169
- for (const message of data.messages) {
170
- try {
171
- if (!message.message) {
172
- continue;
173
- }
174
- let messageContent;
175
- try {
176
- if (this.isServerEnvironment) {
177
- messageContent = Buffer.from(
178
- message.message,
179
- "base64"
180
- ).toString("utf-8");
181
- } else {
182
- messageContent = new TextDecoder().decode(
183
- Uint8Array.from(
184
- atob(message.message),
185
- (c) => c.charCodeAt(0)
186
- )
187
- );
188
- }
189
- } catch (error) {
190
- const logMessage = `Error decoding message: ${error}`;
191
- this.logger.error(logMessage);
192
- continue;
193
- }
194
- let messageJson;
195
- try {
196
- messageJson = JSON.parse(messageContent);
197
- } catch (error) {
198
- const logMessage = `Invalid JSON message content: ${messageContent}`;
199
- this.logger.error(logMessage);
200
- return;
201
- }
202
- messageJson.sequence_number = message.sequence_number;
203
- messages.push({
204
- ...messageJson,
205
- consensus_timestamp: message.consensus_timestamp,
206
- sequence_number: message.sequence_number,
207
- created: new Date(Number(message.consensus_timestamp) * 1e3)
208
- });
209
- } catch (error) {
210
- const logMessage = `Error processing message: ${error.message}`;
211
- this.logger.error(logMessage);
212
- }
147
+ const accountId = signer.getAccountId().toString();
148
+ logger.debug("Using account ID from signer", { accountId });
149
+ let sdk;
150
+ if (existingSDK) {
151
+ logger.debug("Using existing InscriptionSDK instance");
152
+ sdk = existingSDK;
153
+ } else if (options.apiKey) {
154
+ logger.debug("Initializing InscriptionSDK with API key");
155
+ sdk = new InscriptionSDK({
156
+ apiKey: options.apiKey,
157
+ network: options.network || "mainnet"
158
+ });
159
+ } else {
160
+ logger.debug("Initializing InscriptionSDK with client auth");
161
+ sdk = await InscriptionSDK.createWithAuth({
162
+ type: "client",
163
+ accountId,
164
+ signer,
165
+ network: options.network || "mainnet"
166
+ });
167
+ }
168
+ const baseRequest = {
169
+ holderId: accountId,
170
+ metadata: options.metadata || {},
171
+ tags: options.tags || [],
172
+ mode: options.mode || "file",
173
+ chunkSize: options.chunkSize
174
+ };
175
+ let request;
176
+ switch (input.type) {
177
+ case "url":
178
+ request = {
179
+ ...baseRequest,
180
+ file: {
181
+ type: "url",
182
+ url: input.url
213
183
  }
214
- }
215
- nextUrl = data.links?.next ? `${this.baseUrl}${data.links.next}` : "";
216
- } catch (e) {
217
- const error = e;
218
- const logMessage = `Error querying topic messages: ${error.message} on ${topicId}`;
219
- this.logger.error(logMessage);
220
- throw new Error(logMessage);
221
- }
184
+ };
185
+ break;
186
+ case "file":
187
+ request = {
188
+ ...baseRequest,
189
+ file: {
190
+ type: "path",
191
+ path: input.path
192
+ }
193
+ };
194
+ break;
195
+ case "buffer":
196
+ request = {
197
+ ...baseRequest,
198
+ file: {
199
+ type: "base64",
200
+ base64: Buffer.from(input.buffer).toString("base64"),
201
+ fileName: input.fileName,
202
+ mimeType: input.mimeType
203
+ }
204
+ };
205
+ break;
222
206
  }
223
- return messages;
224
- }
225
- /**
226
- * Requests account information for a given account ID from the mirror node.
227
- * @param accountId The ID of the account to retrieve information for.
228
- * @returns A promise that resolves to the account information.
229
- * @throws An error if the account ID is invalid or the information cannot be retrieved.
230
- */
231
- async requestAccount(accountId) {
232
- try {
233
- const accountInfoUrl = `${this.baseUrl}/api/v1/accounts/${accountId}`;
234
- const response = await axios.get(accountInfoUrl);
235
- if (!response.data) {
236
- throw new Error(
237
- `Failed to make request to mirror node for account: ${accountId}`
238
- );
207
+ if (options.mode === "hashinal") {
208
+ request.metadataObject = options.metadata;
209
+ request.creator = options.metadata?.creator || accountId;
210
+ request.description = options.metadata?.description;
211
+ if (options.jsonFileURL) {
212
+ request.jsonFileURL = options.jsonFileURL;
239
213
  }
240
- return response.data;
241
- } catch (e) {
242
- const error = e;
243
- const logMessage = `Failed to fetch account: ${error.message}`;
244
- this.logger.error(logMessage);
245
- throw new Error(logMessage);
246
214
  }
247
- }
248
- /**
249
- * Checks if a user has access to a given key list.
250
- * @param keyBytes The key list to check access for.
251
- * @param userPublicKey The public key of the user to check access for.
252
- * @returns A promise that resolves to true if the user has access, false otherwise.
253
- */
254
- async checkKeyListAccess(keyBytes, userPublicKey) {
255
- try {
256
- const key = proto.Key.decode(keyBytes);
257
- return this.evaluateKeyAccess(key, userPublicKey);
258
- } catch (e) {
259
- const error = e;
260
- const logMessage = `Error decoding protobuf key: ${error.message}`;
261
- this.logger.error(logMessage);
262
- throw new Error(logMessage);
215
+ logger.debug("Preparing to inscribe content with signer", {
216
+ type: input.type,
217
+ mode: options.mode || "file",
218
+ holderId: accountId
219
+ });
220
+ const result = await sdk.inscribe(
221
+ {
222
+ ...request,
223
+ holderId: accountId
224
+ },
225
+ signer
226
+ );
227
+ logger.info("Inscription started", {
228
+ type: input.type,
229
+ mode: options.mode || "file",
230
+ transactionId: result.jobId
231
+ });
232
+ if (options.waitForConfirmation) {
233
+ logger.debug("Waiting for inscription confirmation", {
234
+ transactionId: result.jobId,
235
+ maxAttempts: options.waitMaxAttempts,
236
+ intervalMs: options.waitIntervalMs
237
+ });
238
+ const inscription = await waitForInscriptionConfirmation(
239
+ sdk,
240
+ result.jobId,
241
+ options.waitMaxAttempts,
242
+ options.waitIntervalMs,
243
+ options.progressCallback
244
+ );
245
+ logger.info("Inscription confirmation received", {
246
+ transactionId: result.jobId
247
+ });
248
+ return {
249
+ confirmed: true,
250
+ result,
251
+ inscription,
252
+ sdk
253
+ };
263
254
  }
255
+ return {
256
+ confirmed: false,
257
+ result,
258
+ sdk
259
+ };
260
+ } catch (error) {
261
+ logger.error("Error during inscription process", error);
262
+ throw error;
264
263
  }
265
- /**
266
- * Evaluates the access of a given key to a user's public key.
267
- * @param key The key to evaluate access for.
268
- * @param userPublicKey The public key of the user to evaluate access for.
269
- * @returns A promise that resolves to true if the key has access, false otherwise.
270
- */
271
- async evaluateKeyAccess(key, userPublicKey) {
272
- if (key.ed25519) {
273
- return this.compareEd25519Key(key.ed25519, userPublicKey);
274
- }
275
- if (key.keyList) {
276
- return this.evaluateKeyList(key.keyList, userPublicKey);
277
- }
278
- if (key.thresholdKey && key.thresholdKey.keys) {
279
- return this.evaluateKeyList(key.thresholdKey.keys, userPublicKey);
264
+ }
265
+ async function retrieveInscription(transactionId, options) {
266
+ const logger = Logger.getInstance({
267
+ module: "Inscriber",
268
+ ...options?.logging || {}
269
+ });
270
+ const formattedTransactionId = transactionId.includes("@") ? `${transactionId.split("@")[0]}-${transactionId.split("@")[1].replace(/\./g, "-")}` : transactionId;
271
+ logger.info("Retrieving inscription", {
272
+ originalTransactionId: transactionId,
273
+ formattedTransactionId
274
+ });
275
+ try {
276
+ let sdk;
277
+ if (options?.apiKey) {
278
+ logger.debug("Initializing InscriptionSDK with API key");
279
+ sdk = new InscriptionSDK({
280
+ apiKey: options.apiKey,
281
+ network: options.network || "mainnet"
282
+ });
283
+ } else if (options?.accountId && options?.privateKey) {
284
+ logger.debug("Initializing InscriptionSDK with server auth");
285
+ sdk = await InscriptionSDK.createWithAuth({
286
+ type: "server",
287
+ accountId: options.accountId,
288
+ privateKey: options.privateKey,
289
+ network: options.network || "mainnet"
290
+ });
291
+ } else {
292
+ const error = new Error(
293
+ "Either API key or account ID and private key are required for retrieving inscriptions"
294
+ );
295
+ logger.error("Missing authentication credentials", {
296
+ hasApiKey: Boolean(options?.apiKey),
297
+ hasAccountId: Boolean(options?.accountId),
298
+ hasPrivateKey: Boolean(options?.privateKey)
299
+ });
300
+ throw error;
280
301
  }
281
- return false;
302
+ logger.debug("Initialized SDK for inscription retrieval", {
303
+ formattedTransactionId,
304
+ network: options.network || "mainnet"
305
+ });
306
+ const result = await sdk.retrieveInscription(formattedTransactionId);
307
+ logger.info("Successfully retrieved inscription", {
308
+ formattedTransactionId
309
+ });
310
+ return result;
311
+ } catch (error) {
312
+ logger.error("Error retrieving inscription", {
313
+ formattedTransactionId,
314
+ error
315
+ });
316
+ throw error;
282
317
  }
283
- /**
284
- * Evaluates the access of a given key list to a user's public key.
285
- * @param keyList The key list to evaluate access for.
286
- * @param userPublicKey The public key of the user to evaluate access for.
287
- * @returns A promise that resolves to true if the key list has access, false otherwise.
288
- */
289
- async evaluateKeyList(keyList, userPublicKey) {
290
- const keys = keyList.keys || [];
291
- for (const listKey of keys) {
292
- if (!listKey) continue;
293
- if (listKey.ed25519) {
294
- if (this.compareEd25519Key(listKey.ed25519, userPublicKey)) {
295
- return true;
296
- }
297
- } else if (listKey.keyList || listKey.thresholdKey) {
298
- try {
299
- const nestedKeyBytes = proto.Key.encode({
300
- ...listKey.keyList ? { keyList: listKey.keyList } : {},
301
- ...listKey.thresholdKey ? { thresholdKey: listKey.thresholdKey } : {}
302
- }).finish();
303
- const hasNestedAccess = await this.checkKeyListAccess(
304
- Buffer.from(nestedKeyBytes),
305
- userPublicKey
306
- );
307
- if (hasNestedAccess) {
308
- return true;
309
- }
310
- } catch (e) {
311
- const error = e;
312
- const logMessage = `Error in nested key: ${error.message}`;
313
- this.logger.debug(logMessage);
314
- }
315
- }
316
- }
317
- return false;
318
+ }
319
+ function validateHashinalMetadata(metadata, logger) {
320
+ const requiredFields = ["name", "creator", "description", "type"];
321
+ const missingFields = requiredFields.filter((field) => !metadata[field]);
322
+ if (missingFields.length > 0) {
323
+ const error = new Error(
324
+ `Missing required Hashinal metadata fields: ${missingFields.join(", ")}`
325
+ );
326
+ logger.error("Hashinal metadata validation failed", { missingFields });
327
+ throw error;
318
328
  }
319
- /**
320
- * Compares an Ed25519 key with a user's public key.
321
- * @param keyData The Ed25519 key data to compare.
322
- * @param userPublicKey The public key of the user to compare with.
323
- * @returns A boolean indicating whether the key matches the user's public key.
324
- */
325
- compareEd25519Key(keyData, userPublicKey) {
329
+ logger.debug("Hashinal metadata validation passed", {
330
+ name: metadata.name,
331
+ creator: metadata.creator,
332
+ description: metadata.description,
333
+ type: metadata.type,
334
+ hasAttributes: !!metadata.attributes,
335
+ hasProperties: !!metadata.properties
336
+ });
337
+ }
338
+ async function waitForInscriptionConfirmation(sdk, transactionId, maxAttempts = 30, intervalMs = 4e3, progressCallback) {
339
+ const logger = Logger.getInstance({ module: "Inscriber" });
340
+ const progressReporter = new ProgressReporter({
341
+ module: "Inscriber",
342
+ logger,
343
+ callback: progressCallback
344
+ });
345
+ try {
346
+ logger.debug("Waiting for inscription confirmation", {
347
+ transactionId,
348
+ maxAttempts,
349
+ intervalMs
350
+ });
351
+ progressReporter.preparing("Preparing for inscription confirmation", 5, {
352
+ transactionId,
353
+ maxAttempts,
354
+ intervalMs
355
+ });
326
356
  try {
327
- const decodedKey = PublicKey.fromBytes(Buffer.from(keyData));
328
- return decodedKey.toString() === userPublicKey.toString();
357
+ const waitMethod = sdk.waitForInscription.bind(sdk);
358
+ const wrappedCallback = (data) => {
359
+ const stage = data.stage || "confirming";
360
+ const message = data.message || "Processing inscription";
361
+ const percent = data.progressPercent || 50;
362
+ progressReporter.report({
363
+ stage,
364
+ message,
365
+ progressPercent: percent,
366
+ details: {}
367
+ });
368
+ };
369
+ return await waitMethod(
370
+ transactionId,
371
+ maxAttempts,
372
+ intervalMs,
373
+ true,
374
+ wrappedCallback
375
+ );
329
376
  } catch (e) {
330
- const error = e;
331
- const logMessage = `Error comparing Ed25519 key: ${error.message}`;
332
- this.logger.debug(logMessage);
333
- return false;
377
+ console.log(e);
378
+ logger.debug("Falling back to standard waitForInscription method", {
379
+ error: e
380
+ });
381
+ progressReporter.verifying("Verifying inscription status", 50, {
382
+ error: e
383
+ });
384
+ return await sdk.waitForInscription(
385
+ transactionId,
386
+ maxAttempts,
387
+ intervalMs,
388
+ true
389
+ );
334
390
  }
391
+ } catch (error) {
392
+ logger.error("Error waiting for inscription confirmation", {
393
+ transactionId,
394
+ maxAttempts,
395
+ intervalMs,
396
+ error
397
+ });
398
+ progressReporter.failed("Inscription confirmation failed", {
399
+ transactionId,
400
+ error
401
+ });
402
+ throw error;
335
403
  }
336
404
  }
337
405
  export {
338
- HederaMirrorNode
406
+ inscribe,
407
+ inscribeWithSigner,
408
+ retrieveInscription,
409
+ waitForInscriptionConfirmation
339
410
  };
340
411
  //# sourceMappingURL=standards-sdk.es20.js.map