@hashgraphonline/standards-sdk 0.1.141-canary.2 → 0.1.141-canary.21

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 (251) hide show
  1. package/README.md +13 -1
  2. package/dist/cjs/hcs-16/base-client.d.ts.map +1 -1
  3. package/dist/cjs/hcs-17/types.d.ts.map +1 -1
  4. package/dist/cjs/hcs-20/sdk.d.ts.map +1 -1
  5. package/dist/cjs/hcs-20/types.d.ts +1 -0
  6. package/dist/cjs/hcs-20/types.d.ts.map +1 -1
  7. package/dist/cjs/hcs-21/base-client.d.ts +4 -3
  8. package/dist/cjs/hcs-21/base-client.d.ts.map +1 -1
  9. package/dist/cjs/hcs-21/index.d.ts +1 -0
  10. package/dist/cjs/hcs-21/index.d.ts.map +1 -1
  11. package/dist/cjs/hcs-21/sdk.d.ts.map +1 -1
  12. package/dist/cjs/hcs-21/tx.d.ts.map +1 -1
  13. package/dist/cjs/hcs-21/types.d.ts +135 -64
  14. package/dist/cjs/hcs-21/types.d.ts.map +1 -1
  15. package/dist/cjs/hcs-21/verify.d.ts +6 -0
  16. package/dist/cjs/hcs-21/verify.d.ts.map +1 -0
  17. package/dist/cjs/inscribe/inscriber.d.ts +1 -0
  18. package/dist/cjs/inscribe/inscriber.d.ts.map +1 -1
  19. package/dist/cjs/inscribe/quote-cache.d.ts.map +1 -1
  20. package/dist/cjs/services/registry-broker/client.d.ts +4 -3
  21. package/dist/cjs/services/registry-broker/client.d.ts.map +1 -1
  22. package/dist/cjs/services/registry-broker/private-key-signer.d.ts.map +1 -1
  23. package/dist/cjs/services/registry-broker/schemas.d.ts +38 -38
  24. package/dist/cjs/services/registry-broker/schemas.d.ts.map +1 -1
  25. package/dist/cjs/standards-sdk.cjs +2 -2
  26. package/dist/cjs/standards-sdk.cjs.map +1 -1
  27. package/dist/cjs/utils/dynamic-import.d.ts +1 -0
  28. package/dist/cjs/utils/dynamic-import.d.ts.map +1 -1
  29. package/dist/es/hcs-16/base-client.d.ts.map +1 -1
  30. package/dist/es/hcs-17/types.d.ts.map +1 -1
  31. package/dist/es/hcs-20/sdk.d.ts.map +1 -1
  32. package/dist/es/hcs-20/types.d.ts +1 -0
  33. package/dist/es/hcs-20/types.d.ts.map +1 -1
  34. package/dist/es/hcs-21/base-client.d.ts +4 -3
  35. package/dist/es/hcs-21/base-client.d.ts.map +1 -1
  36. package/dist/es/hcs-21/index.d.ts +1 -0
  37. package/dist/es/hcs-21/index.d.ts.map +1 -1
  38. package/dist/es/hcs-21/sdk.d.ts.map +1 -1
  39. package/dist/es/hcs-21/tx.d.ts.map +1 -1
  40. package/dist/es/hcs-21/types.d.ts +135 -64
  41. package/dist/es/hcs-21/types.d.ts.map +1 -1
  42. package/dist/es/hcs-21/verify.d.ts +6 -0
  43. package/dist/es/hcs-21/verify.d.ts.map +1 -0
  44. package/dist/es/inscribe/inscriber.d.ts +1 -0
  45. package/dist/es/inscribe/inscriber.d.ts.map +1 -1
  46. package/dist/es/inscribe/quote-cache.d.ts.map +1 -1
  47. package/dist/es/services/registry-broker/client.d.ts +4 -3
  48. package/dist/es/services/registry-broker/client.d.ts.map +1 -1
  49. package/dist/es/services/registry-broker/private-key-signer.d.ts.map +1 -1
  50. package/dist/es/services/registry-broker/schemas.d.ts +38 -38
  51. package/dist/es/services/registry-broker/schemas.d.ts.map +1 -1
  52. package/dist/es/standards-sdk.es.js +58 -50
  53. package/dist/es/standards-sdk.es.js.map +1 -1
  54. package/dist/es/standards-sdk.es10.js +2 -2
  55. package/dist/es/standards-sdk.es100.js +26 -229
  56. package/dist/es/standards-sdk.es100.js.map +1 -1
  57. package/dist/es/standards-sdk.es101.js +228 -109
  58. package/dist/es/standards-sdk.es101.js.map +1 -1
  59. package/dist/es/standards-sdk.es102.js +94 -15
  60. package/dist/es/standards-sdk.es102.js.map +1 -1
  61. package/dist/es/standards-sdk.es103.js +30 -80
  62. package/dist/es/standards-sdk.es103.js.map +1 -1
  63. package/dist/es/standards-sdk.es104.js +80 -27
  64. package/dist/es/standards-sdk.es104.js.map +1 -1
  65. package/dist/es/standards-sdk.es105.js +25 -136
  66. package/dist/es/standards-sdk.es105.js.map +1 -1
  67. package/dist/es/standards-sdk.es106.js +140 -27
  68. package/dist/es/standards-sdk.es106.js.map +1 -1
  69. package/dist/es/standards-sdk.es107.js +27 -20
  70. package/dist/es/standards-sdk.es107.js.map +1 -1
  71. package/dist/es/standards-sdk.es108.js +18 -156
  72. package/dist/es/standards-sdk.es108.js.map +1 -1
  73. package/dist/es/standards-sdk.es109.js +148 -196
  74. package/dist/es/standards-sdk.es109.js.map +1 -1
  75. package/dist/es/standards-sdk.es110.js +160 -747
  76. package/dist/es/standards-sdk.es110.js.map +1 -1
  77. package/dist/es/standards-sdk.es111.js +786 -9
  78. package/dist/es/standards-sdk.es111.js.map +1 -1
  79. package/dist/es/standards-sdk.es112.js +13 -567
  80. package/dist/es/standards-sdk.es112.js.map +1 -1
  81. package/dist/es/standards-sdk.es113.js +541 -576
  82. package/dist/es/standards-sdk.es113.js.map +1 -1
  83. package/dist/es/standards-sdk.es114.js +601 -12
  84. package/dist/es/standards-sdk.es114.js.map +1 -1
  85. package/dist/es/standards-sdk.es115.js +13 -2
  86. package/dist/es/standards-sdk.es115.js.map +1 -1
  87. package/dist/es/standards-sdk.es116.js +2 -83
  88. package/dist/es/standards-sdk.es116.js.map +1 -1
  89. package/dist/es/standards-sdk.es117.js +80 -36
  90. package/dist/es/standards-sdk.es117.js.map +1 -1
  91. package/dist/es/standards-sdk.es118.js +39 -2
  92. package/dist/es/standards-sdk.es118.js.map +1 -1
  93. package/dist/es/standards-sdk.es119.js +2 -223
  94. package/dist/es/standards-sdk.es119.js.map +1 -1
  95. package/dist/es/standards-sdk.es12.js +1 -1
  96. package/dist/es/standards-sdk.es120.js +193 -1110
  97. package/dist/es/standards-sdk.es120.js.map +1 -1
  98. package/dist/es/standards-sdk.es121.js +1059 -225
  99. package/dist/es/standards-sdk.es121.js.map +1 -1
  100. package/dist/es/standards-sdk.es122.js +303 -419
  101. package/dist/es/standards-sdk.es122.js.map +1 -1
  102. package/dist/es/standards-sdk.es123.js +418 -351
  103. package/dist/es/standards-sdk.es123.js.map +1 -1
  104. package/dist/es/standards-sdk.es124.js +348 -785
  105. package/dist/es/standards-sdk.es124.js.map +1 -1
  106. package/dist/es/standards-sdk.es125.js +748 -183
  107. package/dist/es/standards-sdk.es125.js.map +1 -1
  108. package/dist/es/standards-sdk.es126.js +153 -1512
  109. package/dist/es/standards-sdk.es126.js.map +1 -1
  110. package/dist/es/standards-sdk.es127.js +1373 -1977
  111. package/dist/es/standards-sdk.es127.js.map +1 -1
  112. package/dist/es/standards-sdk.es128.js +2206 -50
  113. package/dist/es/standards-sdk.es128.js.map +1 -1
  114. package/dist/es/standards-sdk.es129.js +59 -79
  115. package/dist/es/standards-sdk.es129.js.map +1 -1
  116. package/dist/es/standards-sdk.es13.js +1 -1
  117. package/dist/es/standards-sdk.es130.js +80 -152
  118. package/dist/es/standards-sdk.es130.js.map +1 -1
  119. package/dist/es/standards-sdk.es131.js +159 -7
  120. package/dist/es/standards-sdk.es131.js.map +1 -1
  121. package/dist/es/standards-sdk.es132.js +7 -86
  122. package/dist/es/standards-sdk.es132.js.map +1 -1
  123. package/dist/es/standards-sdk.es133.js +65 -44
  124. package/dist/es/standards-sdk.es133.js.map +1 -1
  125. package/dist/es/standards-sdk.es134.js +65 -28
  126. package/dist/es/standards-sdk.es134.js.map +1 -1
  127. package/dist/es/standards-sdk.es135.js +69 -125
  128. package/dist/es/standards-sdk.es135.js.map +1 -1
  129. package/dist/es/standards-sdk.es136.js +28 -42
  130. package/dist/es/standards-sdk.es136.js.map +1 -1
  131. package/dist/es/standards-sdk.es137.js +54 -15
  132. package/dist/es/standards-sdk.es137.js.map +1 -1
  133. package/dist/es/standards-sdk.es138.js +8 -2
  134. package/dist/es/standards-sdk.es138.js.map +1 -1
  135. package/dist/es/standards-sdk.es139.js +105 -12241
  136. package/dist/es/standards-sdk.es139.js.map +1 -1
  137. package/dist/es/standards-sdk.es14.js +1 -1
  138. package/dist/es/standards-sdk.es140.js +38 -168
  139. package/dist/es/standards-sdk.es140.js.map +1 -1
  140. package/dist/es/standards-sdk.es141.js +12215 -263
  141. package/dist/es/standards-sdk.es141.js.map +1 -1
  142. package/dist/es/standards-sdk.es142.js +120 -294
  143. package/dist/es/standards-sdk.es142.js.map +1 -1
  144. package/dist/es/standards-sdk.es143.js +191 -322
  145. package/dist/es/standards-sdk.es143.js.map +1 -1
  146. package/dist/es/standards-sdk.es144.js +294 -279
  147. package/dist/es/standards-sdk.es144.js.map +1 -1
  148. package/dist/es/standards-sdk.es145.js +440 -63
  149. package/dist/es/standards-sdk.es145.js.map +1 -1
  150. package/dist/es/standards-sdk.es146.js +330 -55
  151. package/dist/es/standards-sdk.es146.js.map +1 -1
  152. package/dist/es/standards-sdk.es147.js +62 -50
  153. package/dist/es/standards-sdk.es147.js.map +1 -1
  154. package/dist/es/standards-sdk.es148.js +20 -0
  155. package/dist/es/standards-sdk.es148.js.map +1 -0
  156. package/dist/es/standards-sdk.es15.js +1 -1
  157. package/dist/es/standards-sdk.es16.js +1 -1
  158. package/dist/es/standards-sdk.es17.js +4 -9
  159. package/dist/es/standards-sdk.es17.js.map +1 -1
  160. package/dist/es/standards-sdk.es19.js +11 -15
  161. package/dist/es/standards-sdk.es19.js.map +1 -1
  162. package/dist/es/standards-sdk.es2.js +26 -72
  163. package/dist/es/standards-sdk.es2.js.map +1 -1
  164. package/dist/es/standards-sdk.es20.js +8 -12
  165. package/dist/es/standards-sdk.es20.js.map +1 -1
  166. package/dist/es/standards-sdk.es21.js +1 -1
  167. package/dist/es/standards-sdk.es22.js +1 -1
  168. package/dist/es/standards-sdk.es23.js +1 -1
  169. package/dist/es/standards-sdk.es24.js +1 -1
  170. package/dist/es/standards-sdk.es25.js +1 -1
  171. package/dist/es/standards-sdk.es26.js +1 -1
  172. package/dist/es/standards-sdk.es27.js +1 -1
  173. package/dist/es/standards-sdk.es28.js +11 -15
  174. package/dist/es/standards-sdk.es28.js.map +1 -1
  175. package/dist/es/standards-sdk.es3.js +2 -2
  176. package/dist/es/standards-sdk.es31.js +2 -2
  177. package/dist/es/standards-sdk.es32.js +4 -4
  178. package/dist/es/standards-sdk.es33.js +1 -1
  179. package/dist/es/standards-sdk.es36.js +6 -11
  180. package/dist/es/standards-sdk.es36.js.map +1 -1
  181. package/dist/es/standards-sdk.es37.js +4 -4
  182. package/dist/es/standards-sdk.es38.js +2 -2
  183. package/dist/es/standards-sdk.es39.js +2 -2
  184. package/dist/es/standards-sdk.es40.js +1 -1
  185. package/dist/es/standards-sdk.es41.js +1 -1
  186. package/dist/es/standards-sdk.es42.js +2 -2
  187. package/dist/es/standards-sdk.es47.js +1 -1
  188. package/dist/es/standards-sdk.es5.js +2 -2
  189. package/dist/es/standards-sdk.es52.js +1 -1
  190. package/dist/es/standards-sdk.es54.js +1 -1
  191. package/dist/es/standards-sdk.es57.js +2 -2
  192. package/dist/es/standards-sdk.es59.js +1 -1
  193. package/dist/es/standards-sdk.es6.js +2 -2
  194. package/dist/es/standards-sdk.es60.js +1 -1
  195. package/dist/es/standards-sdk.es61.js +6 -10
  196. package/dist/es/standards-sdk.es61.js.map +1 -1
  197. package/dist/es/standards-sdk.es63.js +1 -1
  198. package/dist/es/standards-sdk.es65.js +2 -2
  199. package/dist/es/standards-sdk.es66.js +3 -3
  200. package/dist/es/standards-sdk.es69.js +2 -2
  201. package/dist/es/standards-sdk.es7.js +2 -2
  202. package/dist/es/standards-sdk.es70.js +3 -3
  203. package/dist/es/standards-sdk.es71.js +2 -2
  204. package/dist/es/standards-sdk.es72.js +1 -1
  205. package/dist/es/standards-sdk.es73.js.map +1 -1
  206. package/dist/es/standards-sdk.es75.js +2 -2
  207. package/dist/es/standards-sdk.es77.js +5 -3
  208. package/dist/es/standards-sdk.es77.js.map +1 -1
  209. package/dist/es/standards-sdk.es78.js +3 -9
  210. package/dist/es/standards-sdk.es78.js.map +1 -1
  211. package/dist/es/standards-sdk.es79.js +1 -1
  212. package/dist/es/standards-sdk.es8.js +1 -1
  213. package/dist/es/standards-sdk.es80.js +26 -15
  214. package/dist/es/standards-sdk.es80.js.map +1 -1
  215. package/dist/es/standards-sdk.es82.js +12 -4
  216. package/dist/es/standards-sdk.es82.js.map +1 -1
  217. package/dist/es/standards-sdk.es83.js +7 -6
  218. package/dist/es/standards-sdk.es83.js.map +1 -1
  219. package/dist/es/standards-sdk.es84.js +7 -5
  220. package/dist/es/standards-sdk.es84.js.map +1 -1
  221. package/dist/es/standards-sdk.es86.js +55 -21
  222. package/dist/es/standards-sdk.es86.js.map +1 -1
  223. package/dist/es/standards-sdk.es87.js +22 -75
  224. package/dist/es/standards-sdk.es87.js.map +1 -1
  225. package/dist/es/standards-sdk.es88.js +45 -30
  226. package/dist/es/standards-sdk.es88.js.map +1 -1
  227. package/dist/es/standards-sdk.es89.js +57 -22
  228. package/dist/es/standards-sdk.es89.js.map +1 -1
  229. package/dist/es/standards-sdk.es90.js +28 -23
  230. package/dist/es/standards-sdk.es90.js.map +1 -1
  231. package/dist/es/standards-sdk.es91.js +23 -167
  232. package/dist/es/standards-sdk.es91.js.map +1 -1
  233. package/dist/es/standards-sdk.es92.js +158 -119
  234. package/dist/es/standards-sdk.es92.js.map +1 -1
  235. package/dist/es/standards-sdk.es93.js +68 -95
  236. package/dist/es/standards-sdk.es93.js.map +1 -1
  237. package/dist/es/standards-sdk.es94.js +136 -119
  238. package/dist/es/standards-sdk.es94.js.map +1 -1
  239. package/dist/es/standards-sdk.es95.js +139 -39
  240. package/dist/es/standards-sdk.es95.js.map +1 -1
  241. package/dist/es/standards-sdk.es96.js +42 -257
  242. package/dist/es/standards-sdk.es96.js.map +1 -1
  243. package/dist/es/standards-sdk.es97.js +243 -80
  244. package/dist/es/standards-sdk.es97.js.map +1 -1
  245. package/dist/es/standards-sdk.es98.js +47 -48
  246. package/dist/es/standards-sdk.es98.js.map +1 -1
  247. package/dist/es/standards-sdk.es99.js +100 -28
  248. package/dist/es/standards-sdk.es99.js.map +1 -1
  249. package/dist/es/utils/dynamic-import.d.ts +1 -0
  250. package/dist/es/utils/dynamic-import.d.ts.map +1 -1
  251. package/package.json +63 -61
@@ -1,211 +1,776 @@
1
- import { InscriptionSDK } from "./standards-sdk.es139.js";
2
- class QuoteCache {
3
- constructor() {
4
- this.cache = /* @__PURE__ */ new Map();
5
- this.maxSize = 100;
6
- this.defaultTtlMs = 5 * 60 * 1e3;
1
+ import { InscriptionSDK } from "./standards-sdk.es141.js";
2
+ import { Logger } from "./standards-sdk.es106.js";
3
+ import { ProgressReporter } from "./standards-sdk.es109.js";
4
+ import { TransactionParser } from "./standards-sdk.es111.js";
5
+ import { isBrowser } from "./standards-sdk.es119.js";
6
+ import { fileTypeFromBuffer } from "file-type";
7
+ import { validateQuoteParameters, getCachedQuote, getOrCreateSDK, cacheQuote } from "./standards-sdk.es126.js";
8
+ let nodeModules = {};
9
+ const normalizeTransactionId = (txId) => {
10
+ if (!txId.includes("@")) {
11
+ return txId;
7
12
  }
8
- // 5 minutes
9
- /**
10
- * Generate cache key from input parameters
11
- */
12
- generateKey(key) {
13
- return `${key.inputHash}-${key.clientConfigHash}-${key.optionsHash}`;
13
+ const txParts = txId?.split("@");
14
+ return `${txParts[0]}-${txParts[1].replace(".", "-")}`;
15
+ };
16
+ async function loadNodeModules() {
17
+ if (isBrowser || nodeModules.readFileSync) {
18
+ return;
14
19
  }
15
- /**
16
- * Hash object to string for cache key
17
- */
18
- hashObject(obj) {
19
- return Buffer.from(JSON.stringify(obj)).toString("base64").slice(0, 16);
20
+ try {
21
+ const globalObj = typeof global !== "undefined" ? global : globalThis;
22
+ const req = globalObj.process?.mainModule?.require || globalObj.require;
23
+ if (typeof req === "function") {
24
+ const fs = req("fs");
25
+ const path = req("path");
26
+ nodeModules.readFileSync = fs.readFileSync;
27
+ nodeModules.basename = path.basename;
28
+ nodeModules.extname = path.extname;
29
+ } else {
30
+ throw new Error("require function not available");
31
+ }
32
+ } catch (error) {
33
+ console.warn(
34
+ "Node.js modules not available, file path operations will be disabled"
35
+ );
20
36
  }
21
- /**
22
- * Create cache key from parameters
23
- */
24
- createCacheKey(input, clientConfig, options) {
25
- return {
26
- inputHash: this.hashObject(input),
27
- clientConfigHash: this.hashObject({
28
- accountId: clientConfig.accountId,
29
- network: clientConfig.network
30
- }),
31
- optionsHash: this.hashObject({
32
- mode: options.mode,
33
- apiKey: options.apiKey ? "present" : "absent",
34
- network: options.network,
35
- metadata: options.metadata
36
- })
37
- };
37
+ }
38
+ async function convertFileToBase64(filePath) {
39
+ if (isBrowser) {
40
+ throw new Error(
41
+ "File path operations are not supported in browser environment. Use buffer input type instead."
42
+ );
38
43
  }
39
- /**
40
- * Get cached quote if available and not expired
41
- */
42
- get(key) {
43
- const cacheKey = this.generateKey(key);
44
- const entry = this.cache.get(cacheKey);
45
- if (!entry) {
46
- return null;
47
- }
48
- const now = Date.now();
49
- if (now - entry.timestamp > entry.ttlMs) {
50
- this.cache.delete(cacheKey);
51
- return null;
52
- }
53
- this.cache.delete(cacheKey);
54
- this.cache.set(cacheKey, entry);
55
- return entry.quote;
44
+ await loadNodeModules();
45
+ if (!nodeModules.readFileSync || !nodeModules.basename || !nodeModules.extname) {
46
+ throw new Error(
47
+ "Node.js file system modules are not available. Cannot read file from path."
48
+ );
56
49
  }
57
- /**
58
- * Store quote in cache
59
- */
60
- set(key, quote, ttlMs = this.defaultTtlMs) {
61
- const cacheKey = this.generateKey(key);
62
- if (this.cache.size >= this.maxSize) {
63
- const firstKey = this.cache.keys().next().value;
64
- if (firstKey) {
65
- this.cache.delete(firstKey);
50
+ try {
51
+ const buffer = nodeModules.readFileSync(filePath);
52
+ const base64 = buffer.toString("base64");
53
+ const fileName = nodeModules.basename(filePath);
54
+ let mimeType = "application/octet-stream";
55
+ try {
56
+ const fileTypeResult = await fileTypeFromBuffer(buffer);
57
+ if (fileTypeResult) {
58
+ mimeType = fileTypeResult.mime;
66
59
  }
60
+ } catch (error) {
61
+ const ext = nodeModules.extname(filePath).toLowerCase();
62
+ const mimeMap = {
63
+ ".txt": "text/plain",
64
+ ".json": "application/json",
65
+ ".html": "text/html",
66
+ ".css": "text/css",
67
+ ".js": "application/javascript",
68
+ ".png": "image/png",
69
+ ".jpg": "image/jpeg",
70
+ ".jpeg": "image/jpeg",
71
+ ".gif": "image/gif",
72
+ ".svg": "image/svg+xml",
73
+ ".pdf": "application/pdf"
74
+ };
75
+ mimeType = mimeMap[ext] || "application/octet-stream";
67
76
  }
68
- this.cache.set(cacheKey, {
69
- quote,
70
- timestamp: Date.now(),
71
- ttlMs
72
- });
73
- }
74
- /**
75
- * Clear all cached entries
76
- */
77
- clear() {
78
- this.cache.clear();
77
+ return { base64, fileName, mimeType };
78
+ } catch (error) {
79
+ throw new Error(
80
+ `Failed to read file ${filePath}: ${error.message}`
81
+ );
79
82
  }
80
83
  }
81
- class SDKCache {
82
- constructor() {
83
- this.cache = /* @__PURE__ */ new Map();
84
- this.maxSize = 10;
85
- this.defaultTtlMs = 30 * 60 * 1e3;
86
- }
87
- // 30 minutes
88
- /**
89
- * Generate config key for SDK instance
90
- */
91
- generateConfigKey(config) {
92
- return Buffer.from(JSON.stringify(config)).toString("base64");
93
- }
94
- /**
95
- * Get cached SDK instance
96
- */
97
- get(config) {
98
- const configKey = this.generateConfigKey(config);
99
- const entry = this.cache.get(configKey);
100
- if (!entry) {
101
- return null;
102
- }
103
- const now = Date.now();
104
- if (now - entry.timestamp > this.defaultTtlMs) {
105
- this.cache.delete(configKey);
106
- return null;
107
- }
108
- return entry.sdk;
109
- }
110
- /**
111
- * Store SDK instance in cache
112
- */
113
- set(config, sdk) {
114
- const configKey = this.generateConfigKey(config);
115
- if (this.cache.size >= this.maxSize) {
116
- const firstKey = this.cache.keys().next().value;
117
- if (firstKey) {
118
- this.cache.delete(firstKey);
84
+ function normalizeClientConfig(cfg) {
85
+ return {
86
+ accountId: cfg.accountId,
87
+ privateKey: typeof cfg.privateKey === "string" ? cfg.privateKey : cfg.privateKey.toString(),
88
+ network: cfg.network
89
+ };
90
+ }
91
+ async function inscribe(input, clientConfig, options, existingSDK) {
92
+ const logger = Logger.getInstance({
93
+ module: "Inscriber",
94
+ ...options.logging
95
+ });
96
+ logger.info("Starting inscription process", {
97
+ type: input.type,
98
+ mode: options.mode || "file",
99
+ quoteOnly: options.quoteOnly || false,
100
+ ...input.type === "url" ? { url: input.url } : {},
101
+ ...input.type === "file" ? { path: input.path } : {},
102
+ ...input.type === "buffer" ? { fileName: input.fileName, bufferSize: input.buffer.byteLength } : {}
103
+ });
104
+ try {
105
+ if (options.quoteOnly) {
106
+ logger.debug("Quote-only mode requested, generating quote");
107
+ return await generateQuote(input, clientConfig, options, existingSDK);
108
+ }
109
+ if (options.mode === "hashinal" && options.metadata) {
110
+ validateHashinalMetadata(options.metadata, logger);
111
+ }
112
+ let sdk;
113
+ if (existingSDK) {
114
+ logger.debug("Using existing InscriptionSDK instance");
115
+ sdk = existingSDK;
116
+ } else if (options.apiKey) {
117
+ logger.debug("Initializing InscriptionSDK with API key");
118
+ sdk = new InscriptionSDK({
119
+ apiKey: options.apiKey,
120
+ network: clientConfig.network || "mainnet",
121
+ connectionMode: "auto"
122
+ });
123
+ } else {
124
+ logger.debug("Initializing InscriptionSDK with server auth");
125
+ const normalized = normalizeClientConfig(clientConfig);
126
+ sdk = await InscriptionSDK.createWithAuth({
127
+ type: "server",
128
+ accountId: normalized.accountId,
129
+ privateKey: normalized.privateKey,
130
+ network: normalized.network || "mainnet",
131
+ connectionMode: "auto"
132
+ });
133
+ }
134
+ const baseRequest = {
135
+ holderId: clientConfig.accountId,
136
+ metadata: options.metadata || {},
137
+ tags: options.tags || [],
138
+ mode: options.mode || "file",
139
+ fileStandard: options.fileStandard,
140
+ chunkSize: options.chunkSize
141
+ };
142
+ let request;
143
+ switch (input.type) {
144
+ case "url":
145
+ request = {
146
+ ...baseRequest,
147
+ file: {
148
+ type: "url",
149
+ url: input.url
150
+ }
151
+ };
152
+ break;
153
+ case "file": {
154
+ const fileData = await convertFileToBase64(input.path);
155
+ request = {
156
+ ...baseRequest,
157
+ file: {
158
+ type: "base64",
159
+ base64: fileData.base64,
160
+ fileName: fileData.fileName,
161
+ mimeType: fileData.mimeType
162
+ }
163
+ };
164
+ break;
165
+ }
166
+ case "buffer":
167
+ request = {
168
+ ...baseRequest,
169
+ file: {
170
+ type: "base64",
171
+ base64: Buffer.from(
172
+ input.buffer instanceof ArrayBuffer ? new Uint8Array(input.buffer) : input.buffer
173
+ ).toString("base64"),
174
+ fileName: input.fileName,
175
+ mimeType: input.mimeType
176
+ }
177
+ };
178
+ break;
179
+ }
180
+ if (options.mode === "hashinal") {
181
+ request.metadataObject = options.metadata;
182
+ request.creator = options.metadata?.creator || clientConfig.accountId;
183
+ request.description = options.metadata?.description;
184
+ if (options.jsonFileURL) {
185
+ request.jsonFileURL = options.jsonFileURL;
119
186
  }
120
187
  }
121
- this.cache.set(configKey, {
122
- sdk,
123
- timestamp: Date.now(),
124
- config: configKey
188
+ logger.debug("Preparing to inscribe content", {
189
+ type: input.type,
190
+ mode: options.mode || "file",
191
+ holderId: clientConfig.accountId
125
192
  });
126
- }
127
- /**
128
- * Clear all cached SDK instances
129
- */
130
- clear() {
131
- this.cache.clear();
193
+ const normalizedCfg = normalizeClientConfig(clientConfig);
194
+ const result = await sdk.inscribeAndExecute(request, normalizedCfg);
195
+ logger.info("Starting to inscribe.", {
196
+ type: input.type,
197
+ mode: options.mode || "file",
198
+ transactionId: result.jobId
199
+ });
200
+ if (options.waitForConfirmation) {
201
+ logger.debug("Waiting for inscription confirmation", {
202
+ transactionId: result.jobId,
203
+ maxAttempts: options.waitMaxAttempts,
204
+ intervalMs: options.waitIntervalMs
205
+ });
206
+ const inscription = await waitForInscriptionConfirmation(
207
+ sdk,
208
+ result.jobId,
209
+ options.waitMaxAttempts,
210
+ options.waitIntervalMs,
211
+ options.progressCallback
212
+ );
213
+ logger.info("Inscription confirmation received", {
214
+ transactionId: result.jobId
215
+ });
216
+ return {
217
+ confirmed: true,
218
+ result,
219
+ inscription,
220
+ sdk
221
+ };
222
+ }
223
+ return {
224
+ confirmed: false,
225
+ result,
226
+ sdk
227
+ };
228
+ } catch (error) {
229
+ logger.error("Error during inscription process", error);
230
+ throw error;
132
231
  }
133
232
  }
134
- const quoteCache = new QuoteCache();
135
- const sdkCache = new SDKCache();
136
- async function getOrCreateSDK(clientConfig, options, existingSDK) {
137
- if (existingSDK) {
138
- return existingSDK;
139
- }
140
- const connectionMode = options.connectionMode || (options.websocket === false ? "http" : "auto");
141
- const cacheConfig = {
142
- apiKey: options.apiKey,
143
- accountId: clientConfig.accountId,
144
- network: clientConfig.network || "mainnet",
145
- authType: options.apiKey ? "api" : "server",
146
- connectionMode
147
- };
148
- const cachedSDK = sdkCache.get(cacheConfig);
149
- if (cachedSDK) {
150
- return cachedSDK;
151
- }
152
- let sdk;
153
- if (options.apiKey) {
154
- sdk = new InscriptionSDK({
155
- apiKey: options.apiKey,
156
- network: clientConfig.network || "mainnet",
157
- connectionMode
158
- });
159
- } else {
160
- sdk = await InscriptionSDK.createWithAuth({
161
- type: "server",
162
- accountId: clientConfig.accountId,
163
- privateKey: typeof clientConfig.privateKey === "string" ? clientConfig.privateKey : clientConfig.privateKey.toString(),
164
- network: clientConfig.network || "mainnet",
165
- connectionMode
233
+ async function inscribeWithSigner(input, signer, options, existingSDK) {
234
+ const logger = Logger.getInstance({
235
+ module: "Inscriber",
236
+ ...options.logging
237
+ });
238
+ logger.info("Starting inscription process with signer", {
239
+ type: input.type,
240
+ mode: options.mode || "file",
241
+ quoteOnly: options.quoteOnly || false,
242
+ ...input.type === "url" ? { url: input.url } : {},
243
+ ...input.type === "file" ? { path: input.path } : {},
244
+ ...input.type === "buffer" ? { fileName: input.fileName, bufferSize: input.buffer.byteLength } : {}
245
+ });
246
+ try {
247
+ if (options.quoteOnly) {
248
+ logger.debug("Quote-only mode requested with signer, generating quote");
249
+ const clientConfig = {
250
+ accountId: signer.getAccountId().toString(),
251
+ privateKey: "",
252
+ network: options.network || "mainnet"
253
+ };
254
+ return await generateQuote(input, clientConfig, options, existingSDK);
255
+ }
256
+ if (options.mode === "hashinal" && options.metadata) {
257
+ validateHashinalMetadata(options.metadata, logger);
258
+ }
259
+ const accountId = signer.getAccountId().toString();
260
+ logger.debug("Using account ID from signer", { accountId });
261
+ let sdk;
262
+ if (existingSDK) {
263
+ logger.debug("Using existing InscriptionSDK instance");
264
+ sdk = existingSDK;
265
+ } else if (options.apiKey) {
266
+ logger.debug("Initializing InscriptionSDK with API key");
267
+ sdk = new InscriptionSDK({
268
+ apiKey: options.apiKey,
269
+ network: options.network || "mainnet",
270
+ connectionMode: "websocket"
271
+ });
272
+ } else {
273
+ logger.debug("Initializing InscriptionSDK with client auth (websocket)");
274
+ sdk = await InscriptionSDK.createWithAuth({
275
+ type: "client",
276
+ accountId,
277
+ signer,
278
+ network: options.network || "mainnet",
279
+ connectionMode: "websocket"
280
+ });
281
+ }
282
+ const baseRequest = {
283
+ holderId: accountId,
284
+ metadata: options.metadata || {},
285
+ tags: options.tags || [],
286
+ mode: options.mode || "file",
287
+ fileStandard: options.fileStandard,
288
+ chunkSize: options.chunkSize
289
+ };
290
+ let request;
291
+ switch (input.type) {
292
+ case "url":
293
+ request = {
294
+ ...baseRequest,
295
+ file: {
296
+ type: "url",
297
+ url: input.url
298
+ }
299
+ };
300
+ break;
301
+ case "file": {
302
+ const fileData = await convertFileToBase64(input.path);
303
+ request = {
304
+ ...baseRequest,
305
+ file: {
306
+ type: "base64",
307
+ base64: fileData.base64,
308
+ fileName: fileData.fileName,
309
+ mimeType: fileData.mimeType
310
+ }
311
+ };
312
+ break;
313
+ }
314
+ case "buffer":
315
+ request = {
316
+ ...baseRequest,
317
+ file: {
318
+ type: "base64",
319
+ base64: Buffer.from(
320
+ input.buffer instanceof ArrayBuffer ? new Uint8Array(input.buffer) : input.buffer
321
+ ).toString("base64"),
322
+ fileName: input.fileName,
323
+ mimeType: input.mimeType
324
+ }
325
+ };
326
+ break;
327
+ }
328
+ if (options.mode === "hashinal") {
329
+ request.metadataObject = options.metadata;
330
+ request.creator = options.metadata?.creator || accountId;
331
+ request.description = options.metadata?.description;
332
+ if (options.jsonFileURL) {
333
+ request.jsonFileURL = options.jsonFileURL;
334
+ }
335
+ }
336
+ logger.debug("Starting inscription via startInscription (websocket)", {
337
+ type: input.type,
338
+ mode: options.mode || "file",
339
+ holderId: accountId,
340
+ usesStartInscription: true
341
+ });
342
+ const startResult = await sdk.startInscription({
343
+ ...request,
344
+ holderId: accountId,
345
+ network: options.network || "mainnet"
346
+ });
347
+ logger.info("about to start inscription", {
348
+ type: input.type,
349
+ mode: options.mode || "file",
350
+ jobId: startResult.id || startResult.tx_id,
351
+ ...startResult
166
352
  });
353
+ if (typeof startResult?.transactionBytes === "string") {
354
+ logger.debug("Executing inscription transaction with signer from bytes");
355
+ await sdk.executeTransactionWithSigner(
356
+ startResult.transactionBytes,
357
+ signer
358
+ );
359
+ } else if (startResult?.transactionBytes?.type === "Buffer") {
360
+ logger.debug("Executing inscription transaction with signer from buffer");
361
+ await sdk.executeTransactionWithSigner(
362
+ Buffer.from(startResult.transactionBytes.data).toString("base64"),
363
+ signer
364
+ );
365
+ }
366
+ if (options.waitForConfirmation) {
367
+ logger.debug("Waiting for inscription confirmation (websocket)", {
368
+ jobId: startResult.id || startResult.tx_id,
369
+ maxAttempts: options.waitMaxAttempts,
370
+ intervalMs: options.waitIntervalMs
371
+ });
372
+ const trackingId = normalizeTransactionId(
373
+ startResult.tx_id || startResult.id || ""
374
+ );
375
+ const inscription = await waitForInscriptionConfirmation(
376
+ sdk,
377
+ trackingId,
378
+ options.waitMaxAttempts,
379
+ options.waitIntervalMs,
380
+ options.progressCallback
381
+ );
382
+ logger.info("Inscription confirmation received", {
383
+ jobId: trackingId
384
+ });
385
+ return {
386
+ confirmed: true,
387
+ result: {
388
+ jobId: startResult.id || startResult.tx_id,
389
+ transactionId: trackingId,
390
+ topic_id: startResult.topic_id,
391
+ status: startResult.status,
392
+ completed: startResult.completed
393
+ },
394
+ inscription,
395
+ sdk
396
+ };
397
+ }
398
+ return {
399
+ confirmed: false,
400
+ result: {
401
+ jobId: startResult.id || startResult.tx_id,
402
+ transactionId: normalizeTransactionId(startResult.tx_id || ""),
403
+ topic_id: startResult.topic_id,
404
+ status: startResult.status,
405
+ completed: startResult.completed
406
+ },
407
+ sdk
408
+ };
409
+ } catch (error) {
410
+ logger.error("Error during inscription process", error);
411
+ throw error;
167
412
  }
168
- sdkCache.set(cacheConfig, sdk);
169
- return sdk;
170
413
  }
171
- function getCachedQuote(input, clientConfig, options) {
172
- const cacheKey = quoteCache.createCacheKey(input, clientConfig, options);
173
- return quoteCache.get(cacheKey);
174
- }
175
- function cacheQuote(input, clientConfig, options, quote) {
176
- const cacheKey = quoteCache.createCacheKey(input, clientConfig, options);
177
- const quoteTtlMs = 10 * 60 * 1e3;
178
- quoteCache.set(cacheKey, quote, quoteTtlMs);
179
- }
180
- function validateQuoteParameters(input, clientConfig, options) {
181
- if (!input || typeof input !== "object" || !("type" in input)) {
182
- throw new Error("Invalid inscription input: type is required");
183
- }
184
- if (!clientConfig || !clientConfig.accountId) {
185
- throw new Error("Invalid client config: accountId is required");
414
+ async function retrieveInscription(transactionId, options) {
415
+ const logger = Logger.getInstance({
416
+ module: "Inscriber",
417
+ ...options?.logging || {}
418
+ });
419
+ const formattedTransactionId = transactionId.includes("@") ? `${transactionId.split("@")[0]}-${transactionId.split("@")[1].replace(/\./g, "-")}` : transactionId;
420
+ logger.info("Retrieving inscription", {
421
+ originalTransactionId: transactionId,
422
+ formattedTransactionId
423
+ });
424
+ try {
425
+ let sdk;
426
+ if (options?.apiKey) {
427
+ logger.debug("Initializing InscriptionSDK with API key");
428
+ sdk = new InscriptionSDK({
429
+ apiKey: options.apiKey,
430
+ network: options.network || "mainnet"
431
+ });
432
+ } else if (options?.accountId && options?.privateKey) {
433
+ logger.debug("Initializing InscriptionSDK with server auth");
434
+ sdk = await InscriptionSDK.createWithAuth({
435
+ type: "server",
436
+ accountId: options.accountId,
437
+ privateKey: options.privateKey,
438
+ network: options.network || "mainnet"
439
+ });
440
+ } else {
441
+ const error = new Error(
442
+ "Either API key or account ID and private key are required for retrieving inscriptions"
443
+ );
444
+ logger.error("Missing authentication credentials", {
445
+ hasApiKey: Boolean(options?.apiKey),
446
+ hasAccountId: Boolean(options?.accountId),
447
+ hasPrivateKey: Boolean(options?.privateKey)
448
+ });
449
+ throw error;
450
+ }
451
+ logger.debug("Initialized SDK for inscription retrieval", {
452
+ formattedTransactionId,
453
+ network: options.network || "mainnet"
454
+ });
455
+ const result = await sdk.retrieveInscription(formattedTransactionId);
456
+ logger.info("Successfully retrieved inscription", {
457
+ formattedTransactionId
458
+ });
459
+ return result;
460
+ } catch (error) {
461
+ logger.error("Error retrieving inscription", {
462
+ formattedTransactionId,
463
+ error
464
+ });
465
+ throw error;
186
466
  }
187
- if (!options) {
188
- throw new Error("Options are required");
467
+ }
468
+ function validateHashinalMetadata(metadata, logger) {
469
+ const requiredFields = ["name", "creator", "description", "type"];
470
+ const missingFields = requiredFields.filter((field) => !metadata[field]);
471
+ if (missingFields.length > 0) {
472
+ const error = new Error(
473
+ `Missing required Hashinal metadata fields: ${missingFields.join(", ")}`
474
+ );
475
+ logger.error("Hashinal metadata validation failed", { missingFields });
476
+ throw error;
189
477
  }
190
- if (options.mode === "hashinal") {
191
- if (!options.metadata) {
192
- throw new Error("Hashinal mode requires metadata");
478
+ logger.debug("Hashinal metadata validation passed", {
479
+ name: metadata.name,
480
+ creator: metadata.creator,
481
+ description: metadata.description,
482
+ type: metadata.type,
483
+ hasAttributes: !!metadata.attributes,
484
+ hasProperties: !!metadata.properties
485
+ });
486
+ }
487
+ async function generateQuote(input, clientConfig, options, existingSDK) {
488
+ const logger = Logger.getInstance({
489
+ module: "Inscriber",
490
+ ...options.logging
491
+ });
492
+ logger.info("Generating inscription quote", {
493
+ type: input.type,
494
+ mode: options.mode || "file",
495
+ ...input.type === "url" ? { url: input.url } : {},
496
+ ...input.type === "file" ? { path: input.path } : {},
497
+ ...input.type === "buffer" ? { fileName: input.fileName, bufferSize: input.buffer.byteLength } : {}
498
+ });
499
+ try {
500
+ validateQuoteParameters(input, clientConfig, options);
501
+ const cachedQuote = getCachedQuote(input, clientConfig, options);
502
+ if (cachedQuote) {
503
+ logger.debug("Returning cached quote");
504
+ return {
505
+ confirmed: false,
506
+ quote: true,
507
+ result: cachedQuote
508
+ };
193
509
  }
194
- const requiredFields = ["name", "creator", "description", "type"];
195
- const missingFields = requiredFields.filter(
196
- (field) => !options.metadata || !options.metadata[field]
510
+ if (options.mode === "hashinal" && options.metadata) {
511
+ validateHashinalMetadata(options.metadata, logger);
512
+ }
513
+ const sdk = await getOrCreateSDK(clientConfig, options, existingSDK);
514
+ const baseRequest = {
515
+ holderId: clientConfig.accountId,
516
+ metadata: options.metadata || {},
517
+ tags: options.tags || [],
518
+ mode: options.mode || "file",
519
+ fileStandard: options.fileStandard,
520
+ chunkSize: options.chunkSize
521
+ };
522
+ let request;
523
+ switch (input.type) {
524
+ case "url":
525
+ request = {
526
+ ...baseRequest,
527
+ file: {
528
+ type: "url",
529
+ url: input.url
530
+ }
531
+ };
532
+ break;
533
+ case "file": {
534
+ const fileData = await convertFileToBase64(input.path);
535
+ request = {
536
+ ...baseRequest,
537
+ file: {
538
+ type: "base64",
539
+ base64: fileData.base64,
540
+ fileName: fileData.fileName,
541
+ mimeType: fileData.mimeType
542
+ }
543
+ };
544
+ break;
545
+ }
546
+ case "buffer":
547
+ request = {
548
+ ...baseRequest,
549
+ file: {
550
+ type: "base64",
551
+ base64: Buffer.from(
552
+ input.buffer instanceof ArrayBuffer ? new Uint8Array(input.buffer) : input.buffer
553
+ ).toString("base64"),
554
+ fileName: input.fileName,
555
+ mimeType: input.mimeType
556
+ }
557
+ };
558
+ break;
559
+ }
560
+ if (options.mode === "hashinal") {
561
+ request.metadataObject = options.metadata;
562
+ request.creator = options.metadata?.creator || clientConfig.accountId;
563
+ request.description = options.metadata?.description;
564
+ if (options.jsonFileURL) {
565
+ request.jsonFileURL = options.jsonFileURL;
566
+ }
567
+ }
568
+ logger.debug("Calling inscription SDK startInscription for quote", {
569
+ type: input.type,
570
+ mode: options.mode || "file",
571
+ holderId: clientConfig.accountId
572
+ });
573
+ const inscriptionResponse = await sdk.startInscription(request);
574
+ logger.debug("Received inscription response for quote parsing", {
575
+ hasTransactionBytes: !!inscriptionResponse.transactionBytes,
576
+ bytesLength: inscriptionResponse.transactionBytes?.length || 0,
577
+ transactionBytesType: typeof inscriptionResponse.transactionBytes,
578
+ totalCost: inscriptionResponse.totalCost
579
+ });
580
+ const quote = await parseTransactionForQuote(
581
+ inscriptionResponse,
582
+ logger
197
583
  );
198
- if (missingFields.length > 0) {
199
- throw new Error(
200
- `Missing required Hashinal metadata fields: ${missingFields.join(", ")}`
584
+ cacheQuote(input, clientConfig, options, quote);
585
+ logger.info("Successfully generated inscription quote", {
586
+ totalCostHbar: quote.totalCostHbar
587
+ });
588
+ return {
589
+ confirmed: false,
590
+ quote: true,
591
+ result: quote
592
+ };
593
+ } catch (error) {
594
+ logger.error("Error generating inscription quote", error);
595
+ throw error;
596
+ }
597
+ }
598
+ async function parseTransactionForQuote(inscriptionResponse, logger) {
599
+ try {
600
+ let totalCostHbar = "0.001";
601
+ if (inscriptionResponse.totalCost && typeof inscriptionResponse.totalCost === "number") {
602
+ const hbarAmount = inscriptionResponse.totalCost / 1e8;
603
+ totalCostHbar = hbarAmount.toString();
604
+ logger.debug("Using totalCost from inscription response", {
605
+ totalCostTinybars: inscriptionResponse.totalCost,
606
+ totalCostHbar
607
+ });
608
+ } else if (inscriptionResponse.transactionBytes) {
609
+ logger.debug("Parsing transaction bytes for cost information");
610
+ try {
611
+ let transactionBytesString;
612
+ if (typeof inscriptionResponse.transactionBytes === "string") {
613
+ transactionBytesString = inscriptionResponse.transactionBytes;
614
+ } else if (inscriptionResponse.transactionBytes && typeof inscriptionResponse.transactionBytes === "object" && "data" in inscriptionResponse.transactionBytes) {
615
+ const buffer = Buffer.from(inscriptionResponse.transactionBytes.data);
616
+ transactionBytesString = buffer.toString("base64");
617
+ } else {
618
+ throw new Error("Invalid transactionBytes format");
619
+ }
620
+ logger.debug("About to parse transaction bytes", {
621
+ bytesLength: transactionBytesString.length,
622
+ bytesPreview: transactionBytesString.slice(0, 100)
623
+ });
624
+ const parsedTransaction = await TransactionParser.parseTransactionBytes(
625
+ transactionBytesString,
626
+ { includeRaw: false }
627
+ );
628
+ logger.debug("Parsed transaction for quote", {
629
+ type: parsedTransaction.type,
630
+ hasTransfers: !!parsedTransaction.transfers,
631
+ transferCount: parsedTransaction.transfers?.length || 0,
632
+ transfers: parsedTransaction.transfers
633
+ });
634
+ let totalTransferAmount = 0;
635
+ if (parsedTransaction.transfers && parsedTransaction.transfers.length > 0) {
636
+ for (const transfer of parsedTransaction.transfers) {
637
+ const transferAmount = typeof transfer.amount === "string" ? parseFloat(transfer.amount) : transfer.amount;
638
+ if (transferAmount < 0) {
639
+ const amountHbar = Math.abs(transferAmount);
640
+ totalTransferAmount += amountHbar;
641
+ logger.debug("Found HBAR transfer", {
642
+ from: transfer.accountId,
643
+ to: "service",
644
+ amount: amountHbar
645
+ });
646
+ }
647
+ }
648
+ }
649
+ if (totalTransferAmount > 0) {
650
+ totalCostHbar = totalTransferAmount.toString();
651
+ logger.debug("Using parsed transaction transfer amount", {
652
+ totalTransferAmount,
653
+ totalCostHbar
654
+ });
655
+ }
656
+ } catch (parseError) {
657
+ logger.warn(
658
+ "Could not parse transaction bytes, using totalCost fallback",
659
+ {
660
+ error: parseError,
661
+ errorMessage: parseError instanceof Error ? parseError.message : String(parseError)
662
+ }
663
+ );
664
+ }
665
+ }
666
+ const transfers = [
667
+ {
668
+ to: "Inscription Service",
669
+ amount: totalCostHbar,
670
+ description: `Inscription fee (${totalCostHbar} HBAR)`
671
+ }
672
+ ];
673
+ const validUntil = new Date(Date.now() + 15 * 60 * 1e3).toISOString();
674
+ const quote = {
675
+ totalCostHbar,
676
+ validUntil,
677
+ breakdown: {
678
+ transfers
679
+ }
680
+ };
681
+ logger.debug("Successfully parsed transaction for quote", {
682
+ totalCostHbar: quote.totalCostHbar,
683
+ transferCount: transfers.length,
684
+ hasTransactionBytes: !!inscriptionResponse.transactionBytes,
685
+ hasTotalCost: !!inscriptionResponse.totalCost
686
+ });
687
+ return quote;
688
+ } catch (error) {
689
+ logger.error("Error parsing transaction for quote", error);
690
+ throw error;
691
+ }
692
+ }
693
+ async function waitForInscriptionConfirmation(sdk, transactionId, maxAttempts = 30, intervalMs = 4e3, progressCallback) {
694
+ const logger = Logger.getInstance({ module: "Inscriber" });
695
+ const progressReporter = new ProgressReporter({
696
+ module: "Inscriber",
697
+ logger,
698
+ callback: progressCallback
699
+ });
700
+ try {
701
+ logger.debug("Waiting for inscription confirmation", {
702
+ transactionId,
703
+ maxAttempts,
704
+ intervalMs
705
+ });
706
+ progressReporter.preparing("Preparing for inscription confirmation", 5, {
707
+ transactionId,
708
+ maxAttempts,
709
+ intervalMs
710
+ });
711
+ try {
712
+ const waitMethod = sdk.waitForInscription.bind(sdk);
713
+ const wrappedCallback = (data) => {
714
+ const stageRaw = data.stage || "confirming";
715
+ const allowedStages = [
716
+ "preparing",
717
+ "submitting",
718
+ "confirming",
719
+ "verifying",
720
+ "completed",
721
+ "failed"
722
+ ];
723
+ const stage = allowedStages.includes(stageRaw) ? stageRaw : "confirming";
724
+ const message = data.message || "Processing inscription";
725
+ const percent = data.progressPercent || 50;
726
+ progressReporter.report({
727
+ stage,
728
+ message,
729
+ progressPercent: percent,
730
+ details: data.details
731
+ });
732
+ };
733
+ return await waitMethod(
734
+ transactionId,
735
+ maxAttempts,
736
+ intervalMs,
737
+ true,
738
+ wrappedCallback
739
+ );
740
+ } catch (e) {
741
+ logger.debug("Falling back to standard waitForInscription method", {
742
+ error: e
743
+ });
744
+ progressReporter.verifying("Verifying inscription status", 50, {
745
+ error: e
746
+ });
747
+ return await sdk.waitForInscription(
748
+ transactionId,
749
+ maxAttempts,
750
+ intervalMs,
751
+ true
201
752
  );
202
753
  }
754
+ } catch (error) {
755
+ logger.error("Error waiting for inscription confirmation", {
756
+ transactionId,
757
+ maxAttempts,
758
+ intervalMs,
759
+ error
760
+ });
761
+ progressReporter.failed("Inscription confirmation failed", {
762
+ transactionId,
763
+ error
764
+ });
765
+ throw error;
203
766
  }
204
767
  }
205
768
  export {
206
- cacheQuote,
207
- getCachedQuote,
208
- getOrCreateSDK,
209
- validateQuoteParameters
769
+ generateQuote,
770
+ inscribe,
771
+ inscribeWithSigner,
772
+ normalizeTransactionId,
773
+ retrieveInscription,
774
+ waitForInscriptionConfirmation
210
775
  };
211
776
  //# sourceMappingURL=standards-sdk.es125.js.map