@hashgraphonline/standards-sdk 0.1.141-canary.8 → 0.1.141-feat-hcs-21-flora-adapter.canary.cff94ea.45

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