@hashgraphonline/standards-sdk 0.0.57 → 0.0.58

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 (127) hide show
  1. package/dist/es/hcs-10/agent-builder.d.ts +1 -2
  2. package/dist/es/hcs-10/agent-builder.d.ts.map +1 -1
  3. package/dist/es/hcs-10/index.d.ts +1 -0
  4. package/dist/es/hcs-10/index.d.ts.map +1 -1
  5. package/dist/es/hcs-10/registrations.d.ts +1 -60
  6. package/dist/es/hcs-10/registrations.d.ts.map +1 -1
  7. package/dist/es/hcs-10/sdk.d.ts +1 -30
  8. package/dist/es/hcs-10/sdk.d.ts.map +1 -1
  9. package/dist/es/hcs-10/types.d.ts +106 -6
  10. package/dist/es/hcs-10/types.d.ts.map +1 -1
  11. package/dist/es/hcs-11/index.d.ts +1 -1
  12. package/dist/es/hcs-11/index.d.ts.map +1 -1
  13. package/dist/es/inscribe/types.d.ts +1 -1
  14. package/dist/es/inscribe/types.d.ts.map +1 -1
  15. package/dist/es/standards-sdk.es.js +7 -7
  16. package/dist/es/standards-sdk.es10.js +3 -3
  17. package/dist/es/standards-sdk.es100.js +13 -36
  18. package/dist/es/standards-sdk.es100.js.map +1 -1
  19. package/dist/es/standards-sdk.es101.js +36 -10
  20. package/dist/es/standards-sdk.es101.js.map +1 -1
  21. package/dist/es/standards-sdk.es102.js +10 -53
  22. package/dist/es/standards-sdk.es102.js.map +1 -1
  23. package/dist/es/standards-sdk.es103.js +47 -1275
  24. package/dist/es/standards-sdk.es103.js.map +1 -1
  25. package/dist/es/standards-sdk.es104.js +1282 -25
  26. package/dist/es/standards-sdk.es104.js.map +1 -1
  27. package/dist/es/standards-sdk.es105.js +31 -5
  28. package/dist/es/standards-sdk.es105.js.map +1 -1
  29. package/dist/es/standards-sdk.es106.js +5 -158
  30. package/dist/es/standards-sdk.es106.js.map +1 -1
  31. package/dist/es/standards-sdk.es107.js +147 -781
  32. package/dist/es/standards-sdk.es107.js.map +1 -1
  33. package/dist/es/standards-sdk.es108.js +785 -166
  34. package/dist/es/standards-sdk.es108.js.map +1 -1
  35. package/dist/es/standards-sdk.es110.js +25 -19
  36. package/dist/es/standards-sdk.es110.js.map +1 -1
  37. package/dist/es/standards-sdk.es111.js +23 -24
  38. package/dist/es/standards-sdk.es111.js.map +1 -1
  39. package/dist/es/standards-sdk.es112.js +35 -23
  40. package/dist/es/standards-sdk.es112.js.map +1 -1
  41. package/dist/es/standards-sdk.es113.js +19 -36
  42. package/dist/es/standards-sdk.es113.js.map +1 -1
  43. package/dist/es/standards-sdk.es12.js +7 -739
  44. package/dist/es/standards-sdk.es12.js.map +1 -1
  45. package/dist/es/standards-sdk.es13.js +722 -52
  46. package/dist/es/standards-sdk.es13.js.map +1 -1
  47. package/dist/es/standards-sdk.es14.js +67 -20
  48. package/dist/es/standards-sdk.es14.js.map +1 -1
  49. package/dist/es/standards-sdk.es15.js +18 -156
  50. package/dist/es/standards-sdk.es15.js.map +1 -1
  51. package/dist/es/standards-sdk.es16.js +138 -385
  52. package/dist/es/standards-sdk.es16.js.map +1 -1
  53. package/dist/es/standards-sdk.es17.js +385 -211
  54. package/dist/es/standards-sdk.es17.js.map +1 -1
  55. package/dist/es/standards-sdk.es18.js +233 -7
  56. package/dist/es/standards-sdk.es18.js.map +1 -1
  57. package/dist/es/standards-sdk.es2.js +1 -1
  58. package/dist/es/standards-sdk.es26.js +7 -7
  59. package/dist/es/standards-sdk.es27.js +1 -1
  60. package/dist/es/standards-sdk.es3.js +1 -1
  61. package/dist/es/standards-sdk.es4.js +1 -1
  62. package/dist/es/standards-sdk.es5.js +4 -4
  63. package/dist/es/standards-sdk.es5.js.map +1 -1
  64. package/dist/es/standards-sdk.es65.js +3 -3
  65. package/dist/es/standards-sdk.es7.js +1 -1
  66. package/dist/es/standards-sdk.es7.js.map +1 -1
  67. package/dist/es/standards-sdk.es73.js +2 -2
  68. package/dist/es/standards-sdk.es74.js +2 -2
  69. package/dist/es/standards-sdk.es77.js +34 -3
  70. package/dist/es/standards-sdk.es77.js.map +1 -1
  71. package/dist/es/standards-sdk.es78.js +33 -2
  72. package/dist/es/standards-sdk.es78.js.map +1 -1
  73. package/dist/es/standards-sdk.es79.js +9 -2
  74. package/dist/es/standards-sdk.es79.js.map +1 -1
  75. package/dist/es/standards-sdk.es8.js +3 -3
  76. package/dist/es/standards-sdk.es80.js +32 -32
  77. package/dist/es/standards-sdk.es80.js.map +1 -1
  78. package/dist/es/standards-sdk.es81.js +3 -33
  79. package/dist/es/standards-sdk.es81.js.map +1 -1
  80. package/dist/es/standards-sdk.es82.js +2 -9
  81. package/dist/es/standards-sdk.es82.js.map +1 -1
  82. package/dist/es/standards-sdk.es83.js +2 -34
  83. package/dist/es/standards-sdk.es83.js.map +1 -1
  84. package/dist/es/standards-sdk.es84.js +2 -419
  85. package/dist/es/standards-sdk.es84.js.map +1 -1
  86. package/dist/es/standards-sdk.es85.js +419 -2
  87. package/dist/es/standards-sdk.es85.js.map +1 -1
  88. package/dist/es/standards-sdk.es86.js +2 -120
  89. package/dist/es/standards-sdk.es86.js.map +1 -1
  90. package/dist/es/standards-sdk.es87.js +120 -2
  91. package/dist/es/standards-sdk.es87.js.map +1 -1
  92. package/dist/es/standards-sdk.es89.js +1 -1
  93. package/dist/es/standards-sdk.es9.js +1 -1
  94. package/dist/es/standards-sdk.es9.js.map +1 -1
  95. package/dist/es/standards-sdk.es90.js +2 -2
  96. package/dist/es/standards-sdk.es92.js +158 -179
  97. package/dist/es/standards-sdk.es92.js.map +1 -1
  98. package/dist/es/standards-sdk.es93.js +163 -406
  99. package/dist/es/standards-sdk.es93.js.map +1 -1
  100. package/dist/es/standards-sdk.es94.js +432 -19
  101. package/dist/es/standards-sdk.es94.js.map +1 -1
  102. package/dist/es/standards-sdk.es95.js +16 -130
  103. package/dist/es/standards-sdk.es95.js.map +1 -1
  104. package/dist/es/standards-sdk.es96.js +131 -10
  105. package/dist/es/standards-sdk.es96.js.map +1 -1
  106. package/dist/es/standards-sdk.es97.js +11 -22
  107. package/dist/es/standards-sdk.es97.js.map +1 -1
  108. package/dist/es/standards-sdk.es98.js +22 -22
  109. package/dist/es/standards-sdk.es98.js.map +1 -1
  110. package/dist/es/standards-sdk.es99.js +21 -13
  111. package/dist/es/standards-sdk.es99.js.map +1 -1
  112. package/dist/umd/hcs-10/agent-builder.d.ts +1 -2
  113. package/dist/umd/hcs-10/agent-builder.d.ts.map +1 -1
  114. package/dist/umd/hcs-10/index.d.ts +1 -0
  115. package/dist/umd/hcs-10/index.d.ts.map +1 -1
  116. package/dist/umd/hcs-10/registrations.d.ts +1 -60
  117. package/dist/umd/hcs-10/registrations.d.ts.map +1 -1
  118. package/dist/umd/hcs-10/sdk.d.ts +1 -30
  119. package/dist/umd/hcs-10/sdk.d.ts.map +1 -1
  120. package/dist/umd/hcs-10/types.d.ts +106 -6
  121. package/dist/umd/hcs-10/types.d.ts.map +1 -1
  122. package/dist/umd/hcs-11/index.d.ts +1 -1
  123. package/dist/umd/hcs-11/index.d.ts.map +1 -1
  124. package/dist/umd/inscribe/types.d.ts +1 -1
  125. package/dist/umd/inscribe/types.d.ts.map +1 -1
  126. package/dist/umd/standards-sdk.umd.js.map +1 -1
  127. package/package.json +1 -1
@@ -1,236 +1,410 @@
1
1
  import Buffer from "./standards-sdk.es19.js";
2
- import { PublicKey, Timestamp } from "@hashgraph/sdk";
3
- import "./standards-sdk.es23.js";
4
- import { proto } from "@hashgraph/proto";
5
- import axios from "./standards-sdk.es24.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
- async getPublicKey(accountId) {
20
- this.logger.info(`Getting public key for account ${accountId}`);
21
- const accountInfo = await this.requestAccount(accountId);
22
- try {
23
- if (!accountInfo || !accountInfo.key) {
24
- throw new Error(
25
- `Failed to retrieve public key for account ID: ${accountId}`
26
- );
27
- }
28
- return PublicKey.fromString(accountInfo.key.key);
29
- } catch (error) {
30
- throw new Error(
31
- `Error fetching public key from Mirror Node: ${error.message}`
32
- );
2
+ import { InscriptionSDK } from "./standards-sdk.es22.js";
3
+ import { Logger } from "./standards-sdk.es14.js";
4
+ import { ProgressReporter } from "./standards-sdk.es16.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);
33
20
  }
34
- }
35
- async getAccountMemo(accountId) {
36
- const maxRetries = 3;
37
- for (let attempt = 0; attempt < maxRetries; attempt++) {
38
- try {
39
- const accountInfoUrl = `${this.baseUrl}/api/v1/accounts/${accountId}`;
40
- const response = await axios.get(accountInfoUrl);
41
- const accountInfo = response.data;
42
- if (accountInfo && accountInfo.memo) {
43
- return accountInfo.memo;
44
- }
45
- this.logger.error(`No memo found for account ${accountId}`);
46
- if (attempt < maxRetries - 1) {
47
- await new Promise((resolve) => setTimeout(resolve, 2e3));
48
- }
49
- } catch (error) {
50
- this.logger.error(
51
- `Error getting account memo (attempt ${attempt + 1}): ${error.message}`
52
- );
53
- if (attempt < maxRetries - 1) {
54
- await new Promise((resolve) => setTimeout(resolve, 2e3));
55
- }
56
- }
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
+ });
57
39
  }
58
- return null;
59
- }
60
- async getTopicInfo(topicId) {
61
- try {
62
- const topicInfoUrl = `${this.baseUrl}/api/v1/topics/${topicId}`;
63
- const response = await axios.get(topicInfoUrl);
64
- return response.data;
65
- } catch (error) {
66
- this.logger.error(`Error retrieving topic information: ${error.message}`);
67
- throw new Error(`Failed to retrieve topic information: ${error.message}`);
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;
68
78
  }
69
- }
70
- async getTopicFees(topicId) {
71
- try {
72
- const topicInfo = await this.getTopicInfo(topicId);
73
- return topicInfo.custom_fees;
74
- } catch (error) {
75
- this.logger.error(`Error retrieving topic fees: ${error.message}`);
76
- 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
+ }
77
86
  }
78
- }
79
- async getHBARPrice(date) {
80
- try {
81
- const timestamp = Timestamp.fromDate(date).toString();
82
- const request = await fetch(
83
- `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
84
110
  );
85
- const response = await request.json();
86
- const usdPrice = Number(response?.current_rate?.cent_equivalent) / Number(response?.current_rate?.hbar_equivalent) / 100;
87
- return usdPrice;
88
- } catch (e) {
89
- 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
+ };
90
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;
91
129
  }
92
- async getTopicMessages(topicId) {
93
- this.logger.info(`Querying messages for topic ${topicId}`);
94
- let nextUrl = `${this.baseUrl}/api/v1/topics/${topicId}/messages`;
95
- const messages = [];
96
- while (nextUrl) {
97
- try {
98
- const response = await axios.get(nextUrl);
99
- const data = response.data;
100
- if (data.messages && data.messages.length > 0) {
101
- for (const message of data.messages) {
102
- try {
103
- if (!message.message) {
104
- continue;
105
- }
106
- let messageContent;
107
- try {
108
- if (this.isServerEnvironment) {
109
- messageContent = Buffer.from(
110
- message.message,
111
- "base64"
112
- ).toString("utf-8");
113
- } else {
114
- messageContent = new TextDecoder().decode(
115
- Uint8Array.from(
116
- atob(message.message),
117
- (c) => c.charCodeAt(0)
118
- )
119
- );
120
- }
121
- } catch (error) {
122
- this.logger.error(`Error decoding message: ${error}`);
123
- continue;
124
- }
125
- let messageJson;
126
- try {
127
- messageJson = JSON.parse(messageContent);
128
- } catch (error) {
129
- this.logger.error(
130
- `Invalid JSON message content: ${messageContent}`
131
- );
132
- return;
133
- }
134
- messageJson.sequence_number = message.sequence_number;
135
- messages.push({
136
- ...messageJson,
137
- consensus_timestamp: message.consensus_timestamp,
138
- sequence_number: message.sequence_number,
139
- created: new Date(
140
- Number(message.consensus_timestamp) * 1e3
141
- )
142
- });
143
- } catch (error) {
144
- this.logger.error(`Error processing message: ${error.message}`);
145
- }
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);
146
+ }
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
146
183
  }
147
- }
148
- nextUrl = data.links?.next ? `${this.baseUrl}${data.links.next}` : "";
149
- } catch (error) {
150
- this.logger.error(`Error querying topic messages: ${error.message}`);
151
- throw new Error(`Failed to query topic messages: ${error.message}`);
152
- }
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;
153
206
  }
154
- return messages;
155
- }
156
- async requestAccount(accountId) {
157
- try {
158
- const accountInfoUrl = `${this.baseUrl}/api/v1/accounts/${accountId}`;
159
- const response = await axios.get(accountInfoUrl);
160
- if (!response.data) {
161
- throw new Error(
162
- `Failed to make request to mirror node for account: ${accountId}`
163
- );
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;
164
213
  }
165
- return response.data;
166
- } catch (error) {
167
- this.logger.error(`Failed to fetch account: ${error.message}`);
168
- throw new Error(`Failed to fetch account: ${error.message}`);
169
214
  }
170
- }
171
- async checkKeyListAccess(keyBytes, userPublicKey) {
172
- try {
173
- const key = proto.Key.decode(keyBytes);
174
- return this.evaluateKeyAccess(key, userPublicKey);
175
- } catch (error) {
176
- this.logger.error(
177
- `Error decoding protobuf key: ${error instanceof Error ? error.message : String(error)}`
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
178
244
  );
179
- return false;
245
+ logger.info("Inscription confirmation received", {
246
+ transactionId: result.jobId
247
+ });
248
+ return {
249
+ confirmed: true,
250
+ result,
251
+ inscription,
252
+ sdk
253
+ };
180
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;
181
263
  }
182
- async evaluateKeyAccess(key, userPublicKey) {
183
- if (key.ed25519) {
184
- return this.compareEd25519Key(key.ed25519, userPublicKey);
185
- }
186
- if (key.keyList) {
187
- return this.evaluateKeyList(key.keyList, userPublicKey);
188
- }
189
- if (key.thresholdKey && key.thresholdKey.keys) {
190
- 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;
191
301
  }
192
- 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;
193
317
  }
194
- async evaluateKeyList(keyList, userPublicKey) {
195
- const keys = keyList.keys || [];
196
- for (const listKey of keys) {
197
- if (!listKey) continue;
198
- if (listKey.ed25519) {
199
- if (this.compareEd25519Key(listKey.ed25519, userPublicKey)) {
200
- return true;
201
- }
202
- } else if (listKey.keyList || listKey.thresholdKey) {
203
- try {
204
- const nestedKeyBytes = proto.Key.encode({
205
- ...listKey.keyList ? { keyList: listKey.keyList } : {},
206
- ...listKey.thresholdKey ? { thresholdKey: listKey.thresholdKey } : {}
207
- }).finish();
208
- const hasNestedAccess = await this.checkKeyListAccess(
209
- Buffer.from(nestedKeyBytes),
210
- userPublicKey
211
- );
212
- if (hasNestedAccess) {
213
- return true;
214
- }
215
- } catch (err) {
216
- this.logger.debug(
217
- `Error in nested key: ${err instanceof Error ? err.message : String(err)}`
218
- );
219
- }
220
- }
221
- }
222
- 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;
223
328
  }
224
- 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
+ });
225
356
  try {
226
- const decodedKey = PublicKey.fromBytes(Buffer.from(keyData));
227
- return decodedKey.toString() === userPublicKey.toString();
228
- } catch (err) {
229
- return false;
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
+ );
376
+ } catch (e) {
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
+ );
230
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;
231
403
  }
232
404
  }
233
405
  export {
234
- HederaMirrorNode
406
+ inscribe,
407
+ inscribeWithSigner,
408
+ retrieveInscription
235
409
  };
236
410
  //# sourceMappingURL=standards-sdk.es17.js.map