@hashgraphonline/standards-agent-kit 0.2.136 → 0.2.138
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/README.md +3 -4
- package/dist/cjs/builders/hcs10/hcs10-builder.d.ts +1 -0
- package/dist/cjs/builders/hcs2/hcs2-builder.d.ts +8 -7
- package/dist/cjs/builders/hcs6/hcs6-builder.d.ts +5 -4
- package/dist/cjs/builders/inscriber/inscriber-builder.d.ts +32 -1
- package/dist/cjs/index.d.ts +4 -0
- package/dist/cjs/signing/bytes-registry.d.ts +17 -0
- package/dist/cjs/signing/signer-provider.d.ts +45 -0
- package/dist/cjs/standards-agent-kit.cjs +1 -1
- package/dist/cjs/standards-agent-kit.cjs.map +1 -1
- package/dist/cjs/tools/hcs10/InitiateConnectionTool.d.ts +4 -4
- package/dist/cjs/tools/hcs2/CreateRegistryTool.d.ts +2 -2
- package/dist/cjs/tools/hcs2/DeleteEntryTool.d.ts +2 -2
- package/dist/cjs/tools/hcs2/UpdateEntryTool.d.ts +2 -2
- package/dist/cjs/tools/hcs6/RegisterDynamicHashinalTool.d.ts +10 -10
- package/dist/cjs/tools/hcs6/UpdateDynamicHashinalTool.d.ts +8 -8
- package/dist/cjs/tools/inscriber/InscribeFromBufferTool.d.ts +5 -4
- package/dist/cjs/tools/inscriber/InscribeFromFileTool.d.ts +2 -2
- package/dist/cjs/tools/inscriber/InscribeFromUrlTool.d.ts +4 -4
- package/dist/cjs/tools/inscriber/InscribeHashinalTool.d.ts +3 -3
- package/dist/cjs/types/inscription-response.d.ts +8 -0
- package/dist/cjs/types/tx-results.d.ts +15 -0
- package/dist/cjs/utils/CodedError.d.ts +4 -0
- package/dist/cjs/utils/inscription-utils.d.ts +21 -0
- package/dist/cjs/validation/hip412-schemas.d.ts +2 -2
- package/dist/es/builders/hcs10/hcs10-builder.d.ts +1 -0
- package/dist/es/builders/hcs2/hcs2-builder.d.ts +8 -7
- package/dist/es/builders/hcs6/hcs6-builder.d.ts +5 -4
- package/dist/es/builders/inscriber/inscriber-builder.d.ts +32 -1
- package/dist/es/index.d.ts +4 -0
- package/dist/es/signing/bytes-registry.d.ts +17 -0
- package/dist/es/signing/signer-provider.d.ts +45 -0
- package/dist/es/standards-agent-kit.es.js +46 -42
- package/dist/es/standards-agent-kit.es.js.map +1 -1
- package/dist/es/standards-agent-kit.es10.js +24 -83
- package/dist/es/standards-agent-kit.es10.js.map +1 -1
- package/dist/es/standards-agent-kit.es11.js +224 -20
- package/dist/es/standards-agent-kit.es11.js.map +1 -1
- package/dist/es/standards-agent-kit.es12.js +78 -27
- package/dist/es/standards-agent-kit.es12.js.map +1 -1
- package/dist/es/standards-agent-kit.es13.js +26 -36
- package/dist/es/standards-agent-kit.es13.js.map +1 -1
- package/dist/es/standards-agent-kit.es14.js +17 -39
- package/dist/es/standards-agent-kit.es14.js.map +1 -1
- package/dist/es/standards-agent-kit.es15.js +36 -58
- package/dist/es/standards-agent-kit.es15.js.map +1 -1
- package/dist/es/standards-agent-kit.es16.js +45 -18
- package/dist/es/standards-agent-kit.es16.js.map +1 -1
- package/dist/es/standards-agent-kit.es17.js +53 -16
- package/dist/es/standards-agent-kit.es17.js.map +1 -1
- package/dist/es/standards-agent-kit.es18.js +18 -28
- package/dist/es/standards-agent-kit.es18.js.map +1 -1
- package/dist/es/standards-agent-kit.es19.js +26 -12
- package/dist/es/standards-agent-kit.es19.js.map +1 -1
- package/dist/es/standards-agent-kit.es20.js +38 -136
- package/dist/es/standards-agent-kit.es20.js.map +1 -1
- package/dist/es/standards-agent-kit.es21.js +13 -24
- package/dist/es/standards-agent-kit.es21.js.map +1 -1
- package/dist/es/standards-agent-kit.es22.js +136 -39
- package/dist/es/standards-agent-kit.es22.js.map +1 -1
- package/dist/es/standards-agent-kit.es23.js +25 -41
- package/dist/es/standards-agent-kit.es23.js.map +1 -1
- package/dist/es/standards-agent-kit.es24.js +49 -31
- package/dist/es/standards-agent-kit.es24.js.map +1 -1
- package/dist/es/standards-agent-kit.es25.js +34 -18
- package/dist/es/standards-agent-kit.es25.js.map +1 -1
- package/dist/es/standards-agent-kit.es26.js +35 -19
- package/dist/es/standards-agent-kit.es26.js.map +1 -1
- package/dist/es/standards-agent-kit.es27.js +45 -32
- package/dist/es/standards-agent-kit.es27.js.map +1 -1
- package/dist/es/standards-agent-kit.es28.js +54 -25
- package/dist/es/standards-agent-kit.es28.js.map +1 -1
- package/dist/es/standards-agent-kit.es29.js +35 -23
- package/dist/es/standards-agent-kit.es29.js.map +1 -1
- package/dist/es/standards-agent-kit.es3.js +41 -1545
- package/dist/es/standards-agent-kit.es3.js.map +1 -1
- package/dist/es/standards-agent-kit.es30.js +23 -39
- package/dist/es/standards-agent-kit.es30.js.map +1 -1
- package/dist/es/standards-agent-kit.es31.js +30 -28
- package/dist/es/standards-agent-kit.es31.js.map +1 -1
- package/dist/es/standards-agent-kit.es32.js +45 -32
- package/dist/es/standards-agent-kit.es32.js.map +1 -1
- package/dist/es/standards-agent-kit.es33.js +50 -89
- package/dist/es/standards-agent-kit.es33.js.map +1 -1
- package/dist/es/standards-agent-kit.es34.js +35 -228
- package/dist/es/standards-agent-kit.es34.js.map +1 -1
- package/dist/es/standards-agent-kit.es35.js +87 -212
- package/dist/es/standards-agent-kit.es35.js.map +1 -1
- package/dist/es/standards-agent-kit.es36.js +188 -128
- package/dist/es/standards-agent-kit.es36.js.map +1 -1
- package/dist/es/standards-agent-kit.es37.js +167 -561
- package/dist/es/standards-agent-kit.es37.js.map +1 -1
- package/dist/es/standards-agent-kit.es38.js +236 -31
- package/dist/es/standards-agent-kit.es38.js.map +1 -1
- package/dist/es/standards-agent-kit.es39.js +483 -206
- package/dist/es/standards-agent-kit.es39.js.map +1 -1
- package/dist/es/standards-agent-kit.es4.js +359 -81
- package/dist/es/standards-agent-kit.es4.js.map +1 -1
- package/dist/es/standards-agent-kit.es40.js +39 -135
- package/dist/es/standards-agent-kit.es40.js.map +1 -1
- package/dist/es/standards-agent-kit.es41.js +244 -28
- package/dist/es/standards-agent-kit.es41.js.map +1 -1
- package/dist/es/standards-agent-kit.es42.js +132 -418
- package/dist/es/standards-agent-kit.es42.js.map +1 -1
- package/dist/es/standards-agent-kit.es43.js +28 -184
- package/dist/es/standards-agent-kit.es43.js.map +1 -1
- package/dist/es/standards-agent-kit.es44.js +423 -3
- package/dist/es/standards-agent-kit.es44.js.map +1 -1
- package/dist/es/standards-agent-kit.es45.js +185 -24
- package/dist/es/standards-agent-kit.es45.js.map +1 -1
- package/dist/es/standards-agent-kit.es46.js +3 -3
- package/dist/es/standards-agent-kit.es46.js.map +1 -1
- package/dist/es/standards-agent-kit.es47.js +21 -50
- package/dist/es/standards-agent-kit.es47.js.map +1 -1
- package/dist/es/standards-agent-kit.es48.js +8 -3
- package/dist/es/standards-agent-kit.es48.js.map +1 -1
- package/dist/es/standards-agent-kit.es49.js +3 -39
- package/dist/es/standards-agent-kit.es49.js.map +1 -1
- package/dist/es/standards-agent-kit.es5.js +1747 -73
- package/dist/es/standards-agent-kit.es5.js.map +1 -1
- package/dist/es/standards-agent-kit.es50.js +18 -16
- package/dist/es/standards-agent-kit.es50.js.map +1 -1
- package/dist/es/standards-agent-kit.es51.js +49 -49
- package/dist/es/standards-agent-kit.es51.js.map +1 -1
- package/dist/es/standards-agent-kit.es52.js +6 -0
- package/dist/es/standards-agent-kit.es52.js.map +1 -0
- package/dist/es/standards-agent-kit.es53.js +43 -0
- package/dist/es/standards-agent-kit.es53.js.map +1 -0
- package/dist/es/standards-agent-kit.es54.js +22 -0
- package/dist/es/standards-agent-kit.es54.js.map +1 -0
- package/dist/es/standards-agent-kit.es55.js +77 -0
- package/dist/es/standards-agent-kit.es55.js.map +1 -0
- package/dist/es/standards-agent-kit.es56.js +7 -0
- package/dist/es/standards-agent-kit.es56.js.map +1 -0
- package/dist/es/standards-agent-kit.es6.js +347 -32
- package/dist/es/standards-agent-kit.es6.js.map +1 -1
- package/dist/es/standards-agent-kit.es7.js +142 -293
- package/dist/es/standards-agent-kit.es7.js.map +1 -1
- package/dist/es/standards-agent-kit.es8.js +201 -21
- package/dist/es/standards-agent-kit.es8.js.map +1 -1
- package/dist/es/standards-agent-kit.es9.js +301 -213
- package/dist/es/standards-agent-kit.es9.js.map +1 -1
- package/dist/es/tools/hcs10/InitiateConnectionTool.d.ts +4 -4
- package/dist/es/tools/hcs2/CreateRegistryTool.d.ts +2 -2
- package/dist/es/tools/hcs2/DeleteEntryTool.d.ts +2 -2
- package/dist/es/tools/hcs2/UpdateEntryTool.d.ts +2 -2
- package/dist/es/tools/hcs6/RegisterDynamicHashinalTool.d.ts +10 -10
- package/dist/es/tools/hcs6/UpdateDynamicHashinalTool.d.ts +8 -8
- package/dist/es/tools/inscriber/InscribeFromBufferTool.d.ts +5 -4
- package/dist/es/tools/inscriber/InscribeFromFileTool.d.ts +2 -2
- package/dist/es/tools/inscriber/InscribeFromUrlTool.d.ts +4 -4
- package/dist/es/tools/inscriber/InscribeHashinalTool.d.ts +3 -3
- package/dist/es/types/inscription-response.d.ts +8 -0
- package/dist/es/types/tx-results.d.ts +15 -0
- package/dist/es/utils/CodedError.d.ts +4 -0
- package/dist/es/utils/inscription-utils.d.ts +21 -0
- package/dist/es/validation/hip412-schemas.d.ts +2 -2
- package/dist/umd/builders/hcs10/hcs10-builder.d.ts +1 -0
- package/dist/umd/builders/hcs2/hcs2-builder.d.ts +8 -7
- package/dist/umd/builders/hcs6/hcs6-builder.d.ts +5 -4
- package/dist/umd/builders/inscriber/inscriber-builder.d.ts +32 -1
- package/dist/umd/index.d.ts +4 -0
- package/dist/umd/signing/bytes-registry.d.ts +17 -0
- package/dist/umd/signing/signer-provider.d.ts +45 -0
- package/dist/umd/standards-agent-kit.umd.js +1 -1
- package/dist/umd/standards-agent-kit.umd.js.map +1 -1
- package/dist/umd/tools/hcs10/InitiateConnectionTool.d.ts +4 -4
- package/dist/umd/tools/hcs2/CreateRegistryTool.d.ts +2 -2
- package/dist/umd/tools/hcs2/DeleteEntryTool.d.ts +2 -2
- package/dist/umd/tools/hcs2/UpdateEntryTool.d.ts +2 -2
- package/dist/umd/tools/hcs6/RegisterDynamicHashinalTool.d.ts +10 -10
- package/dist/umd/tools/hcs6/UpdateDynamicHashinalTool.d.ts +8 -8
- package/dist/umd/tools/inscriber/InscribeFromBufferTool.d.ts +5 -4
- package/dist/umd/tools/inscriber/InscribeFromFileTool.d.ts +2 -2
- package/dist/umd/tools/inscriber/InscribeFromUrlTool.d.ts +4 -4
- package/dist/umd/tools/inscriber/InscribeHashinalTool.d.ts +3 -3
- package/dist/umd/types/inscription-response.d.ts +8 -0
- package/dist/umd/types/tx-results.d.ts +15 -0
- package/dist/umd/utils/CodedError.d.ts +4 -0
- package/dist/umd/utils/inscription-utils.d.ts +21 -0
- package/dist/umd/validation/hip412-schemas.d.ts +2 -2
- package/package.json +10 -5
- package/src/builders/hcs10/hcs10-builder.ts +239 -6
- package/src/builders/hcs2/hcs2-builder.ts +302 -9
- package/src/builders/hcs6/hcs6-builder.ts +79 -4
- package/src/builders/inscriber/inscriber-builder.ts +235 -2
- package/src/hcs10/HCS10Client.ts +1 -1
- package/src/index.ts +5 -1
- package/src/lib/zod-render/schema-extension.ts +0 -1
- package/src/signing/bytes-registry.ts +501 -0
- package/src/signing/signer-provider.ts +120 -0
- package/src/tools/hcs2/CreateRegistryTool.ts +30 -5
- package/src/tools/hcs2/DeleteEntryTool.ts +16 -2
- package/src/tools/hcs2/MigrateRegistryTool.ts +16 -2
- package/src/tools/hcs2/QueryRegistryTool.ts +11 -2
- package/src/tools/hcs2/RegisterEntryTool.ts +17 -3
- package/src/tools/hcs2/UpdateEntryTool.ts +16 -2
- package/src/tools/hcs6/CreateDynamicRegistryTool.ts +17 -3
- package/src/tools/hcs6/RegisterDynamicHashinalTool.ts +17 -3
- package/src/tools/hcs6/UpdateDynamicHashinalTool.ts +17 -3
- package/src/tools/inscriber/InscribeFromBufferTool.ts +126 -21
- package/src/tools/inscriber/InscribeFromFileTool.ts +10 -13
- package/src/tools/inscriber/InscribeFromUrlTool.ts +15 -11
- package/src/tools/inscriber/InscribeHashinalTool.ts +40 -168
- package/src/tools/inscriber/RetrieveInscriptionTool.ts +15 -16
- package/src/types/inscription-response.ts +27 -0
- package/src/types/tx-results.ts +18 -0
- package/src/utils/CodedError.ts +8 -0
- package/src/utils/Encryption.ts +0 -2
- package/src/utils/ensure-agent-has-hbar.ts +4 -5
- package/src/utils/inscription-utils.ts +53 -0
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
1
|
import { z } from 'zod';
|
|
3
2
|
import { BaseInscriberQueryTool } from './base-inscriber-tools';
|
|
4
3
|
import {
|
|
@@ -6,6 +5,7 @@ import {
|
|
|
6
5
|
InscriptionInput,
|
|
7
6
|
ContentResolverRegistry,
|
|
8
7
|
Logger,
|
|
8
|
+
InscriptionResult,
|
|
9
9
|
} from '@hashgraphonline/standards-sdk';
|
|
10
10
|
import { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';
|
|
11
11
|
import { validateHIP412Metadata } from '../../validation/hip412-schemas';
|
|
@@ -19,9 +19,14 @@ import {
|
|
|
19
19
|
createInscriptionSuccess,
|
|
20
20
|
createInscriptionQuote,
|
|
21
21
|
createInscriptionError,
|
|
22
|
+
createInscriptionPending,
|
|
22
23
|
InscriptionResponse,
|
|
23
24
|
} from '../../types/inscription-response';
|
|
24
25
|
import { FormValidatable } from '../../interfaces/FormValidatable';
|
|
26
|
+
import {
|
|
27
|
+
extractTopicIds,
|
|
28
|
+
buildInscriptionLinks,
|
|
29
|
+
} from '../../utils/inscription-utils';
|
|
25
30
|
|
|
26
31
|
/**
|
|
27
32
|
* Network-specific Hashinal block configuration for HashLink blocks
|
|
@@ -46,8 +51,9 @@ const HASHLINK_BLOCK_CONFIG = {
|
|
|
46
51
|
* @param network The network type to get configuration for
|
|
47
52
|
* @returns Network-specific block configuration with blockId, hashLink, and template
|
|
48
53
|
*/
|
|
49
|
-
|
|
50
|
-
|
|
54
|
+
function getHashLinkBlockId(
|
|
55
|
+
network: 'mainnet' | 'testnet',
|
|
56
|
+
): { blockId: string; hashLink: string; template: string } {
|
|
51
57
|
const config =
|
|
52
58
|
network === 'mainnet'
|
|
53
59
|
? HASHLINK_BLOCK_CONFIG.mainnet
|
|
@@ -58,8 +64,6 @@ function getHashLinkBlockId(network) {
|
|
|
58
64
|
return config;
|
|
59
65
|
}
|
|
60
66
|
|
|
61
|
-
// Note: Using inline return type annotations to avoid parser issues with interface declarations
|
|
62
|
-
|
|
63
67
|
/**
|
|
64
68
|
* Schema for inscribing Hashinal NFT
|
|
65
69
|
*/
|
|
@@ -205,7 +209,6 @@ export class InscribeHashinalTool
|
|
|
205
209
|
description =
|
|
206
210
|
'Tool for inscribing Hashinal NFTs. CRITICAL: When user provides content (url/contentRef/base64Data), call with ONLY the content parameters - DO NOT auto-generate name, description, creator, or attributes. A form will be automatically shown to collect metadata from the user. Only include metadata parameters if the user explicitly provided them in their message.';
|
|
207
211
|
|
|
208
|
-
// Declare entity resolution preferences to preserve user-specified literal fields
|
|
209
212
|
getEntityResolutionPreferences(): Record<string, string> {
|
|
210
213
|
return {
|
|
211
214
|
name: 'literal',
|
|
@@ -350,20 +353,17 @@ export class InscribeHashinalTool
|
|
|
350
353
|
.describe('Trait name (e.g., "Rarity", "Color", "Style")'),
|
|
351
354
|
value: z
|
|
352
355
|
.union([z.string(), z.number()])
|
|
353
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
354
356
|
.describe('Trait value (e.g., "Epic", "Blue", 85)'),
|
|
355
357
|
})
|
|
356
358
|
)
|
|
357
359
|
)
|
|
358
360
|
.withRender(renderConfigs.array('NFT Attributes', 'Attribute'))
|
|
359
361
|
.optional()
|
|
360
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
361
362
|
.describe('Collectible traits and characteristics.'),
|
|
362
363
|
|
|
363
364
|
type: z
|
|
364
365
|
.string()
|
|
365
366
|
.optional()
|
|
366
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
367
367
|
.describe(
|
|
368
368
|
'Category or genre of the NFT (e.g., "Digital Art", "Photography", "Collectible Card)'
|
|
369
369
|
),
|
|
@@ -523,173 +523,54 @@ export class InscribeHashinalTool
|
|
|
523
523
|
});
|
|
524
524
|
|
|
525
525
|
result = await Promise.race([
|
|
526
|
-
this.inscriberBuilder.
|
|
526
|
+
this.inscriberBuilder.inscribeAuto
|
|
527
|
+
? this.inscriberBuilder.inscribeAuto(inscriptionData, options)
|
|
528
|
+
: this.inscriberBuilder.inscribe(inscriptionData, options),
|
|
527
529
|
timeoutPromise,
|
|
528
530
|
]);
|
|
529
531
|
} else {
|
|
530
|
-
result =
|
|
532
|
+
result = this.inscriberBuilder.inscribeAuto
|
|
533
|
+
? await this.inscriberBuilder.inscribeAuto(inscriptionData, options)
|
|
534
|
+
: await this.inscriberBuilder.inscribe(inscriptionData, options);
|
|
531
535
|
}
|
|
532
536
|
|
|
533
537
|
if (result.confirmed && !result.quote) {
|
|
534
|
-
const
|
|
535
|
-
|
|
536
|
-
)?.topic_id;
|
|
537
|
-
const jsonTopicId = (
|
|
538
|
-
result.inscription as { topic_id?: string; jsonTopicId?: string }
|
|
539
|
-
)?.jsonTopicId;
|
|
540
|
-
const network = options.network || 'testnet';
|
|
541
|
-
|
|
542
|
-
const cdnUrl = jsonTopicId
|
|
543
|
-
? `https://kiloscribe.com/api/inscription-cdn/${jsonTopicId}?network=${network}`
|
|
544
|
-
: null;
|
|
545
|
-
|
|
538
|
+
const ids = extractTopicIds(result.inscription, result.result);
|
|
539
|
+
const network = (options.network || 'testnet') as 'mainnet' | 'testnet';
|
|
546
540
|
const fileStandard = params.fileStandard || '1';
|
|
547
|
-
const hrl
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
const inscriptionResponse = createInscriptionSuccess({
|
|
562
|
-
hrl,
|
|
563
|
-
topicId: jsonTopicId || imageTopicId || 'unknown',
|
|
564
|
-
standard: standardType as 'Static' | 'Dynamic',
|
|
565
|
-
cdnUrl: cdnUrl || undefined,
|
|
566
|
-
transactionId: (result.result as { transactionId?: string })
|
|
567
|
-
?.transactionId,
|
|
541
|
+
const { hrl, topicId, cdnUrl } = buildInscriptionLinks(
|
|
542
|
+
ids,
|
|
543
|
+
network,
|
|
544
|
+
fileStandard
|
|
545
|
+
);
|
|
546
|
+
|
|
547
|
+
const txId = (result.result as InscriptionResult)?.transactionId ?? 'unknown';
|
|
548
|
+
return createInscriptionSuccess({
|
|
549
|
+
hrl: hrl || 'hcs://1/unknown',
|
|
550
|
+
topicId: topicId || 'unknown',
|
|
551
|
+
standard: fileStandard === '6' ? 'Dynamic' : 'Static',
|
|
552
|
+
cdnUrl,
|
|
553
|
+
transactionId: txId,
|
|
568
554
|
metadata: {
|
|
569
555
|
name: params.name,
|
|
570
556
|
creator: params.creator,
|
|
571
557
|
description: params.description,
|
|
572
558
|
type: params.type,
|
|
573
|
-
attributes: params.attributes,
|
|
559
|
+
attributes: Array.isArray(params.attributes) ? params.attributes : [],
|
|
574
560
|
},
|
|
575
561
|
});
|
|
576
|
-
|
|
577
|
-
this.onEntityCreated?.({
|
|
578
|
-
entityId: jsonTopicId || imageTopicId || 'unknown',
|
|
579
|
-
entityName: params.name || 'Unnamed Inscription',
|
|
580
|
-
entityType: 'topicId',
|
|
581
|
-
transactionId: (result.result as { transactionId?: string })
|
|
582
|
-
?.transactionId,
|
|
583
|
-
});
|
|
584
|
-
|
|
585
|
-
if (params.withHashLinkBlocks) {
|
|
586
|
-
try {
|
|
587
|
-
const blockData = await this.createHashLinkBlock(
|
|
588
|
-
inscriptionResponse,
|
|
589
|
-
inscriptionData.type === 'buffer'
|
|
590
|
-
? inscriptionData.mimeType
|
|
591
|
-
: undefined
|
|
592
|
-
);
|
|
593
|
-
|
|
594
|
-
inscriptionResponse.hashLinkBlock = blockData;
|
|
595
|
-
} catch (blockError) {
|
|
596
|
-
// Log error but don't fail the inscription
|
|
597
|
-
const logger = new Logger({ module: 'InscribeHashinalTool' });
|
|
598
|
-
logger.error('Failed to create HashLink block', {
|
|
599
|
-
error: blockError,
|
|
600
|
-
});
|
|
601
|
-
}
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
return inscriptionResponse;
|
|
605
562
|
} else if (!result.quote && !result.confirmed) {
|
|
606
|
-
const
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
)?.jsonTopicId;
|
|
612
|
-
|
|
613
|
-
if (jsonTopicId || imageTopicId) {
|
|
614
|
-
const network = options.network || 'testnet';
|
|
615
|
-
const cdnUrl = jsonTopicId
|
|
616
|
-
? `https://kiloscribe.com/api/inscription-cdn/${jsonTopicId}?network=${network}`
|
|
617
|
-
: null;
|
|
618
|
-
|
|
619
|
-
const fileStandard = params.fileStandard || '1';
|
|
620
|
-
const hrl = jsonTopicId
|
|
621
|
-
? `hcs://${fileStandard}/${jsonTopicId}`
|
|
622
|
-
: null;
|
|
623
|
-
const standardType = fileStandard === '6' ? 'Dynamic' : 'Static';
|
|
624
|
-
|
|
625
|
-
if (hrl) {
|
|
626
|
-
const inscriptionResponse = createInscriptionSuccess({
|
|
627
|
-
hrl,
|
|
628
|
-
topicId: jsonTopicId || imageTopicId || 'unknown',
|
|
629
|
-
standard: standardType as 'Static' | 'Dynamic',
|
|
630
|
-
cdnUrl: cdnUrl || undefined,
|
|
631
|
-
transactionId: (result.result as { transactionId?: string })
|
|
632
|
-
?.transactionId,
|
|
633
|
-
metadata: {
|
|
634
|
-
name: params.name,
|
|
635
|
-
creator: params.creator,
|
|
636
|
-
description: params.description,
|
|
637
|
-
type: params.type,
|
|
638
|
-
attributes: params.attributes,
|
|
639
|
-
},
|
|
640
|
-
});
|
|
641
|
-
|
|
642
|
-
this.onEntityCreated?.({
|
|
643
|
-
entityId: jsonTopicId || imageTopicId || 'unknown',
|
|
644
|
-
entityName: params.name || 'Unnamed Inscription',
|
|
645
|
-
entityType: 'topicId',
|
|
646
|
-
transactionId: (result.result as { transactionId?: string })
|
|
647
|
-
?.transactionId,
|
|
648
|
-
});
|
|
649
|
-
|
|
650
|
-
if (params.withHashLinkBlocks) {
|
|
651
|
-
try {
|
|
652
|
-
const blockData = await this.createHashLinkBlock(
|
|
653
|
-
inscriptionResponse,
|
|
654
|
-
inscriptionData.type === 'buffer'
|
|
655
|
-
? inscriptionData.mimeType
|
|
656
|
-
: undefined
|
|
657
|
-
);
|
|
658
|
-
|
|
659
|
-
inscriptionResponse.hashLinkBlock = blockData;
|
|
660
|
-
} catch (blockError) {
|
|
661
|
-
// Log error but don't fail the inscription
|
|
662
|
-
const logger = new Logger({ module: 'InscribeHashinalTool' });
|
|
663
|
-
logger.error('Failed to create HashLink block', {
|
|
664
|
-
error: blockError,
|
|
665
|
-
});
|
|
666
|
-
}
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
return inscriptionResponse;
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
const transactionId =
|
|
674
|
-
(result.result as { transactionId?: string })?.transactionId ||
|
|
675
|
-
'unknown';
|
|
676
|
-
return createInscriptionError({
|
|
677
|
-
code: 'INSCRIPTION_PENDING',
|
|
678
|
-
details: `Inscription submitted but not yet confirmed. Transaction ID: ${transactionId}`,
|
|
679
|
-
suggestions: [
|
|
680
|
-
'Wait a few moments for confirmation',
|
|
681
|
-
'Check the transaction status on a Hedera explorer',
|
|
682
|
-
"Try the inscription again if it doesn't confirm within 5 minutes",
|
|
683
|
-
],
|
|
563
|
+
const txId = (result.result as InscriptionResult)?.transactionId ?? 'unknown';
|
|
564
|
+
return createInscriptionPending({
|
|
565
|
+
transactionId: txId,
|
|
566
|
+
details:
|
|
567
|
+
'Successfully submitted Hashinal inscription. Waiting for network confirmation...'
|
|
684
568
|
});
|
|
685
569
|
} else {
|
|
686
570
|
return createInscriptionError({
|
|
687
|
-
code: '
|
|
688
|
-
details: '
|
|
689
|
-
suggestions: [
|
|
690
|
-
'Check if the inscription was successful manually',
|
|
691
|
-
'Try the inscription again',
|
|
692
|
-
],
|
|
571
|
+
code: 'UNEXPECTED_RESULT',
|
|
572
|
+
details: 'Received an unexpected inscription result state',
|
|
573
|
+
suggestions: ['Try again or verify network status']
|
|
693
574
|
});
|
|
694
575
|
}
|
|
695
576
|
} catch (error) {
|
|
@@ -697,16 +578,7 @@ export class InscribeHashinalTool
|
|
|
697
578
|
error instanceof Error
|
|
698
579
|
? error.message
|
|
699
580
|
: 'Failed to inscribe Hashinal NFT';
|
|
700
|
-
|
|
701
|
-
code: 'INSCRIPTION_FAILED',
|
|
702
|
-
details: `Inscription failed: ${errorMessage}`,
|
|
703
|
-
suggestions: [
|
|
704
|
-
'Check network connectivity',
|
|
705
|
-
'Verify you have sufficient HBAR balance',
|
|
706
|
-
'Ensure content is accessible and valid',
|
|
707
|
-
'Try again in a moment',
|
|
708
|
-
],
|
|
709
|
-
});
|
|
581
|
+
throw new Error(`Inscription failed: ${errorMessage}`);
|
|
710
582
|
}
|
|
711
583
|
}
|
|
712
584
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { BaseInscriberQueryTool } from './base-inscriber-tools';
|
|
3
3
|
import { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';
|
|
4
|
+
import type { RetrievedInscriptionResult } from '@hashgraphonline/standards-sdk';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Schema for retrieving inscription
|
|
@@ -51,7 +52,7 @@ export class RetrieveInscriptionTool extends BaseInscriberQueryTool<typeof retri
|
|
|
51
52
|
params: z.infer<typeof retrieveInscriptionSchema>,
|
|
52
53
|
_runManager?: CallbackManagerForToolRun
|
|
53
54
|
): Promise<InscriptionRetrievalResult> {
|
|
54
|
-
const result = await this.inscriberBuilder.retrieveInscription(
|
|
55
|
+
const result: RetrievedInscriptionResult = await this.inscriberBuilder.retrieveInscription(
|
|
55
56
|
params.transactionId,
|
|
56
57
|
{
|
|
57
58
|
apiKey: params.apiKey,
|
|
@@ -59,23 +60,21 @@ export class RetrieveInscriptionTool extends BaseInscriberQueryTool<typeof retri
|
|
|
59
60
|
}
|
|
60
61
|
);
|
|
61
62
|
|
|
62
|
-
const typedResult = result as unknown as Record<string, unknown>;
|
|
63
|
-
|
|
64
63
|
return {
|
|
65
|
-
inscriptionId:
|
|
66
|
-
transactionId: result.transactionId || 'unknown',
|
|
67
|
-
topicId:
|
|
68
|
-
status: result.status || 'unknown',
|
|
69
|
-
holderId:
|
|
64
|
+
inscriptionId: (result as unknown as { inscriptionId?: string }).inscriptionId,
|
|
65
|
+
transactionId: (result as unknown as { transactionId?: string }).transactionId || 'unknown',
|
|
66
|
+
topicId: (result as unknown as { topic_id?: string; topicId?: string }).topic_id || (result as unknown as { topicId?: string }).topicId,
|
|
67
|
+
status: (result as unknown as { status?: string }).status || 'unknown',
|
|
68
|
+
holderId: (result as unknown as { holderId?: string }).holderId,
|
|
70
69
|
metadata: result.metadata,
|
|
71
|
-
tags:
|
|
72
|
-
mode: result.mode,
|
|
73
|
-
chunks:
|
|
74
|
-
createdAt:
|
|
75
|
-
completedAt: (
|
|
76
|
-
fileUrl: result.fileUrl,
|
|
77
|
-
mimeType:
|
|
78
|
-
fileSize:
|
|
70
|
+
tags: (result as unknown as { tags?: unknown }).tags,
|
|
71
|
+
mode: (result as unknown as { mode?: string }).mode,
|
|
72
|
+
chunks: (result as unknown as { chunks?: unknown }).chunks,
|
|
73
|
+
createdAt: (result as unknown as { createdAt?: string }).createdAt,
|
|
74
|
+
completedAt: (result as unknown as { completed?: string; completedAt?: string }).completed || (result as unknown as { completedAt?: string }).completedAt,
|
|
75
|
+
fileUrl: (result as unknown as { fileUrl?: string }).fileUrl,
|
|
76
|
+
mimeType: (result as unknown as { mimeType?: string }).mimeType,
|
|
77
|
+
fileSize: (result as unknown as { fileSize?: number }).fileSize,
|
|
79
78
|
};
|
|
80
79
|
}
|
|
81
80
|
}
|
|
@@ -232,3 +232,30 @@ export function createInscriptionError(params: {
|
|
|
232
232
|
},
|
|
233
233
|
};
|
|
234
234
|
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Helper for pending inscription state (submitted but not yet confirmed)
|
|
238
|
+
*/
|
|
239
|
+
export function createInscriptionPending(params: {
|
|
240
|
+
transactionId: string;
|
|
241
|
+
details?: string;
|
|
242
|
+
suggestions?: string[];
|
|
243
|
+
}): InscriptionErrorResponse {
|
|
244
|
+
const { transactionId, details, suggestions } = params;
|
|
245
|
+
const d = details || `Inscription submitted but not yet confirmed. Transaction ID: ${transactionId}`;
|
|
246
|
+
return {
|
|
247
|
+
success: false,
|
|
248
|
+
type: 'error',
|
|
249
|
+
title: 'Inscription Submitted (Pending)',
|
|
250
|
+
message: d,
|
|
251
|
+
error: {
|
|
252
|
+
code: 'INSCRIPTION_PENDING',
|
|
253
|
+
details: d,
|
|
254
|
+
suggestions: suggestions || [
|
|
255
|
+
'Wait a few moments for confirmation',
|
|
256
|
+
'Check the transaction status on a Hedera explorer',
|
|
257
|
+
"Try the inscription again if it doesn't confirm within 5 minutes",
|
|
258
|
+
],
|
|
259
|
+
},
|
|
260
|
+
};
|
|
261
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { TopicRegistrationResponse, RegistryOperationResponse, HCS6TopicRegistrationResponse, HCS6RegistryOperationResponse, HCS6CreateHashinalResponse } from '@hashgraphonline/standards-sdk';
|
|
2
|
+
|
|
3
|
+
export interface WalletBytesResponse {
|
|
4
|
+
success: true;
|
|
5
|
+
transactionBytes: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function isWalletBytesResponse(value: unknown): value is WalletBytesResponse {
|
|
9
|
+
return !!value && typeof (value as any).transactionBytes === 'string';
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type TopicRegistrationResult = TopicRegistrationResponse | WalletBytesResponse;
|
|
13
|
+
export type RegistryOperationResult = RegistryOperationResponse | WalletBytesResponse;
|
|
14
|
+
export type SubmitMessageResult = { success: true; transactionId?: string } | WalletBytesResponse;
|
|
15
|
+
|
|
16
|
+
export type HCS6TopicRegistrationResult = HCS6TopicRegistrationResponse | WalletBytesResponse;
|
|
17
|
+
export type HCS6RegistryOperationResult = HCS6RegistryOperationResponse | WalletBytesResponse;
|
|
18
|
+
export type HCS6CreateHashinalResult = HCS6CreateHashinalResponse | WalletBytesResponse;
|
package/src/utils/Encryption.ts
CHANGED
|
@@ -6,11 +6,9 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
export function encryptMessage(message: string): string {
|
|
9
|
-
// TODO: Add encryption logic here if useEncryption flag is true.
|
|
10
9
|
return message; // currently returns plaintext.
|
|
11
10
|
}
|
|
12
11
|
|
|
13
12
|
export function decryptMessage(encryptedMessage: string): string {
|
|
14
|
-
// TODO: Add decryption logic here.
|
|
15
13
|
return encryptedMessage;
|
|
16
14
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Hbar, TransferTransaction
|
|
1
|
+
import { Hbar, TransferTransaction } from "@hashgraph/sdk";
|
|
2
2
|
import { Logger, HCS10Client, HederaMirrorNode } from "@hashgraphonline/standards-sdk";
|
|
3
3
|
|
|
4
4
|
export const MIN_REQUIRED_USD = 2.0;
|
|
@@ -58,10 +58,9 @@ export async function ensureAgentHasEnoughHbar(
|
|
|
58
58
|
)} HBAR from ${funder.accountId}`
|
|
59
59
|
);
|
|
60
60
|
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
);
|
|
64
|
-
await fundTxResponse.getReceipt(baseClient.getClient() as Client);
|
|
61
|
+
const clientAny: any = baseClient.getClient();
|
|
62
|
+
const fundTxResponse = await transferTx.execute(clientAny);
|
|
63
|
+
await fundTxResponse.getReceipt(clientAny);
|
|
65
64
|
logger.info(
|
|
66
65
|
`Successfully funded ${agentName} account ${accountId}.`
|
|
67
66
|
);
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export type NetworkType = 'mainnet' | 'testnet';
|
|
2
|
+
|
|
3
|
+
export interface TopicIds {
|
|
4
|
+
jsonTopicId?: string;
|
|
5
|
+
topicId?: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function getStringProp(obj: unknown, key: string): string | undefined {
|
|
9
|
+
if (!obj || typeof obj !== 'object') return undefined;
|
|
10
|
+
const val = (obj as Record<string, unknown>)[key];
|
|
11
|
+
return typeof val === 'string' && val.trim() ? val : undefined;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Extract topic ids from an inscription and/or result object without using any.
|
|
16
|
+
* - Prefers jsonTopicId when present (for CDN linking)
|
|
17
|
+
* - Collects topic_id/topicId from either inscription or result
|
|
18
|
+
*/
|
|
19
|
+
export function extractTopicIds(
|
|
20
|
+
inscription: unknown,
|
|
21
|
+
result?: unknown
|
|
22
|
+
): TopicIds {
|
|
23
|
+
const jsonTopicId = getStringProp(inscription, 'jsonTopicId');
|
|
24
|
+
|
|
25
|
+
const imageTopicId =
|
|
26
|
+
getStringProp(inscription, 'topic_id') ||
|
|
27
|
+
getStringProp(inscription, 'topicId') ||
|
|
28
|
+
getStringProp(result, 'topicId') ||
|
|
29
|
+
getStringProp(result, 'topic_id');
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
jsonTopicId: jsonTopicId,
|
|
33
|
+
topicId: imageTopicId,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Build HRL/CDN URLs from extracted topic ids.
|
|
39
|
+
* - HRL prefers jsonTopicId, falls back to topicId
|
|
40
|
+
* - CDN URL only provided when jsonTopicId is present
|
|
41
|
+
*/
|
|
42
|
+
export function buildInscriptionLinks(
|
|
43
|
+
ids: TopicIds,
|
|
44
|
+
network: NetworkType,
|
|
45
|
+
fileStandard: string = '1'
|
|
46
|
+
): { hrl?: string; cdnUrl?: string; topicId?: string } {
|
|
47
|
+
const chosen = ids.jsonTopicId || ids.topicId;
|
|
48
|
+
const hrl = chosen ? `hcs://${fileStandard}/${chosen}` : undefined;
|
|
49
|
+
const cdnUrl = ids.jsonTopicId
|
|
50
|
+
? `https://kiloscribe.com/api/inscription-cdn/${ids.jsonTopicId}?network=${network}`
|
|
51
|
+
: undefined;
|
|
52
|
+
return { hrl, cdnUrl, topicId: chosen };
|
|
53
|
+
}
|