@hashgraphonline/standards-agent-kit 0.2.154 → 0.2.157

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hashgraphonline/standards-agent-kit",
3
- "version": "0.2.154",
3
+ "version": "0.2.157",
4
4
  "description": "A modular SDK for building on-chain autonomous agents using Hashgraph Online Standards, including HCS-10 for agent discovery and communication.",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/standards-agent-kit.cjs",
@@ -125,12 +125,43 @@ export class InscriberBuilder extends BaseServiceBuilder {
125
125
  }
126
126
 
127
127
  /**
128
- * Get or create Inscription SDK - temporarily returns null since we don't have the actual SDK
128
+ * Get or create Inscription SDK
129
129
  */
130
130
  protected async getInscriptionSDK(
131
131
  _options: InscriptionOptions
132
132
  ): Promise<InscriptionSDK | null> {
133
- return null;
133
+ if (this.inscriptionSDK) {
134
+ return this.inscriptionSDK;
135
+ }
136
+
137
+ const network = this.hederaKit.client.network;
138
+ const networkType: 'mainnet' | 'testnet' = network.toString().includes('mainnet')
139
+ ? 'mainnet'
140
+ : 'testnet';
141
+
142
+ const signer = await this.getSigner();
143
+ const accountId = this.hederaKit.signer.getAccountId().toString();
144
+
145
+ if (signer) {
146
+ this.inscriptionSDK = await InscriptionSDK.createWithAuth({
147
+ type: 'client',
148
+ accountId,
149
+ signer: signer as Parameters<typeof InscriptionSDK.createWithAuth>[0] extends { type: 'client'; signer: infer S } ? S : never,
150
+ network: networkType,
151
+ });
152
+ } else {
153
+ const privateKey = this.hederaKit.signer?.getOperatorPrivateKey();
154
+ if (privateKey) {
155
+ this.inscriptionSDK = await InscriptionSDK.createWithAuth({
156
+ type: 'server',
157
+ accountId,
158
+ privateKey: privateKey.toStringRaw(),
159
+ network: networkType,
160
+ });
161
+ }
162
+ }
163
+
164
+ return this.inscriptionSDK;
134
165
  }
135
166
 
136
167
  /**
@@ -323,39 +354,32 @@ export class InscriberBuilder extends BaseServiceBuilder {
323
354
  const intervalMs =
324
355
  (options as { waitIntervalMs?: number }).waitIntervalMs ?? 5000;
325
356
 
326
- for (let attempt = 0; attempt < maxAttempts; attempt++) {
327
- try {
328
- const retrieved: RetrievedInscriptionResult =
329
- await this.retrieveInscription(transactionId, options);
330
- const topicIdFromInscription: string | undefined = getTopicId(
331
- retrieved as unknown
357
+ const sdk = await this.getInscriptionSDK(options);
358
+ if (sdk) {
359
+ const retrieved: RetrievedInscriptionResult =
360
+ await sdk.waitForInscription(
361
+ transactionId,
362
+ maxAttempts,
363
+ intervalMs,
364
+ true
332
365
  );
333
- const topicId: string | undefined =
334
- topicIdFromInscription ?? startResponse.topic_id;
335
- const status: string | undefined = (
336
- retrieved as { status?: string }
337
- ).status;
338
- const isDone = status === 'completed' || !!topicId;
339
- if (isDone) {
340
- const resultConfirmed: InscriptionResponse = {
341
- quote: false,
342
- confirmed: true,
343
- result: {
344
- jobId: startResponse.tx_id || '',
345
- transactionId,
346
- topicId,
347
- },
348
- inscription: retrieved,
349
- } as unknown as InscriptionResponse;
350
- this.logger.debug(
351
- 'retrieved inscription',
352
- resultConfirmed,
353
- retrieved
354
- );
355
- return resultConfirmed;
356
- }
357
- } catch {}
358
- await new Promise((resolve) => setTimeout(resolve, intervalMs));
366
+ const topicIdFromInscription: string | undefined = getTopicId(
367
+ retrieved as unknown
368
+ );
369
+ const topicId: string | undefined =
370
+ topicIdFromInscription ?? startResponse.topic_id;
371
+ const resultConfirmed: InscriptionResponse = {
372
+ quote: false,
373
+ confirmed: true,
374
+ result: {
375
+ jobId: startResponse.tx_id || '',
376
+ transactionId,
377
+ topicId,
378
+ },
379
+ inscription: retrieved,
380
+ } as unknown as InscriptionResponse;
381
+ this.logger.debug('retrieved inscription', resultConfirmed, retrieved);
382
+ return resultConfirmed;
359
383
  }
360
384
  }
361
385