@hashgraphonline/standards-sdk 0.0.112-canary.2 → 0.0.112-canary.3
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/dist/cjs/index-CHar8dVv-SclbHQNq.cjs +11 -0
- package/dist/cjs/{index-CHar8dVv-CRh6n7ac.cjs.map → index-CHar8dVv-SclbHQNq.cjs.map} +1 -1
- package/dist/cjs/{index-BjSZGzAb.cjs → index-CcE0yY9g.cjs} +2 -2
- package/dist/cjs/{index-BjSZGzAb.cjs.map → index-CcE0yY9g.cjs.map} +1 -1
- package/dist/cjs/standards-sdk.cjs +1 -1
- package/dist/es/standards-sdk.es13.js +0 -1
- package/dist/es/standards-sdk.es13.js.map +1 -1
- package/dist/es/standards-sdk.es20.js +0 -1
- package/dist/es/standards-sdk.es20.js.map +1 -1
- package/dist/es/standards-sdk.es21.js +0 -1
- package/dist/es/standards-sdk.es21.js.map +1 -1
- package/dist/es/standards-sdk.es29.js +0 -1
- package/dist/es/standards-sdk.es29.js.map +1 -1
- package/dist/es/standards-sdk.es32.js +0 -1
- package/dist/es/standards-sdk.es32.js.map +1 -1
- package/dist/es/standards-sdk.es5.js +0 -1
- package/dist/es/standards-sdk.es5.js.map +1 -1
- package/dist/es/standards-sdk.es7.js +0 -1
- package/dist/es/standards-sdk.es7.js.map +1 -1
- package/dist/es/standards-sdk.es8.js +0 -1
- package/dist/es/standards-sdk.es8.js.map +1 -1
- package/package.json +1 -1
- package/dist/cjs/index-CHar8dVv-CRh6n7ac.cjs +0 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-sdk.es5.js","sources":["../../src/hcs-10/base-client.ts"],"sourcesContent":["import { Logger, LogLevel } from '../utils/logger';\nimport { Registration } from './registrations';\nimport { HCS11Client } from '../hcs-11/client';\nimport {\n AccountResponse,\n TopicResponse,\n ScheduleInfo,\n} from '../services/types';\nimport { TopicInfo } from '../services/types';\nimport { TransactionReceipt, PrivateKey, PublicKey } from '@hashgraph/sdk';\nimport axios from 'axios';\nimport { NetworkType } from '../utils/types';\nimport { HederaMirrorNode, MirrorNodeConfig } from '../services';\nimport {\n WaitForConnectionConfirmationResponse,\n TransactMessage,\n} from './types';\nimport { HRLResolver } from '../utils/hrl-resolver';\n\nexport enum Hcs10MemoType {\n INBOUND = 'inbound',\n OUTBOUND = 'outbound',\n CONNECTION = 'connection',\n}\n\n/**\n * Configuration for HCS-10 client.\n * \n * @example\n * // Using default Hedera mirror nodes\n * const config = {\n * network: 'testnet',\n * logLevel: 'info'\n * };\n * \n * @example\n * // Using HGraph custom mirror node provider\n * const config = {\n * network: 'mainnet',\n * logLevel: 'info',\n * mirrorNode: {\n * customUrl: 'https://mainnet.hedera.api.hgraph.dev/v1/<API-KEY>',\n * apiKey: 'your-hgraph-api-key'\n * }\n * };\n * \n * @example\n * // Using custom mirror node with headers\n * const config = {\n * network: 'testnet',\n * mirrorNode: {\n * customUrl: 'https://custom-mirror.example.com',\n * apiKey: 'your-api-key',\n * headers: {\n * 'X-Custom-Header': 'value'\n * }\n * }\n * };\n */\nexport interface HCS10Config {\n /** The Hedera network to connect to */\n network: 'mainnet' | 'testnet';\n /** Log level for the client */\n logLevel?: LogLevel;\n /** Whether to pretty print logs */\n prettyPrint?: boolean;\n /** Fee amount for transactions that require fees */\n feeAmount?: number;\n /** Custom mirror node configuration */\n mirrorNode?: MirrorNodeConfig;\n}\n\nexport interface HCSMessage {\n p: 'hcs-10';\n op:\n | 'connection_request'\n | 'connection_created'\n | 'message'\n | 'close_connection'\n | 'transaction';\n data?: string;\n created?: Date;\n consensus_timestamp?: string;\n m?: string;\n payer: string;\n outbound_topic_id?: string;\n connection_request_id?: number;\n confirmed_request_id?: number;\n connection_topic_id?: string;\n connected_account_id?: string;\n requesting_account_id?: string;\n connection_id?: number;\n sequence_number: number;\n operator_id?: string;\n reason?: string;\n close_method?: string;\n schedule_id?: string;\n}\n\nexport interface ProfileResponse {\n profile: any;\n topicInfo?: TopicInfo;\n success: boolean;\n error?: string;\n}\n\nexport abstract class HCS10BaseClient extends Registration {\n protected network: string;\n protected logger: Logger;\n protected feeAmount: number;\n public mirrorNode: HederaMirrorNode;\n\n protected operatorId: string;\n\n constructor(config: HCS10Config) {\n super();\n this.network = config.network;\n this.logger = Logger.getInstance({\n level: config.logLevel || 'info',\n module: 'HCS10-BaseClient',\n prettyPrint: config.prettyPrint,\n });\n this.mirrorNode = new HederaMirrorNode(\n config.network as NetworkType,\n this.logger,\n config.mirrorNode\n );\n this.feeAmount = config.feeAmount || 0.001;\n }\n\n abstract submitPayload(\n topicId: string,\n payload: object | string,\n submitKey?: PrivateKey,\n requiresFee?: boolean\n ): Promise<TransactionReceipt>;\n\n abstract getAccountAndSigner(): { accountId: string; signer: any };\n\n /**\n * Updates the mirror node configuration.\n * @param config The new mirror node configuration.\n */\n public configureMirrorNode(config: MirrorNodeConfig): void {\n this.mirrorNode.configureMirrorNode(config);\n this.logger.info('Mirror node configuration updated');\n }\n\n public extractTopicFromOperatorId(operatorId: string): string {\n if (!operatorId) {\n return '';\n }\n const parts = operatorId.split('@');\n if (parts.length > 0) {\n return parts[0];\n }\n return '';\n }\n\n public extractAccountFromOperatorId(operatorId: string): string {\n if (!operatorId) {\n return '';\n }\n const parts = operatorId.split('@');\n if (parts.length > 1) {\n return parts[1];\n }\n return '';\n }\n\n /**\n * Get a stream of messages from a connection topic\n * @param topicId The connection topic ID to get messages from\n * @returns A stream of filtered messages valid for connection topics\n */\n public async getMessageStream(\n topicId: string\n ): Promise<{ messages: HCSMessage[] }> {\n try {\n const messages = await this.mirrorNode.getTopicMessages(topicId);\n const validOps = ['message', 'close_connection', 'transaction'];\n\n const filteredMessages = messages.filter((msg) => {\n if (msg.p !== 'hcs-10' || !validOps.includes(msg.op)) {\n return false;\n }\n\n if (msg.op === 'message' || msg.op === 'close_connection') {\n if (!msg.operator_id) {\n return false;\n }\n\n if (!this.isValidOperatorId(msg.operator_id)) {\n return false;\n }\n\n if (msg.op === 'message' && !msg.data) {\n return false;\n }\n }\n\n if (msg.op === 'transaction') {\n if (!msg.operator_id || !msg.schedule_id) {\n return false;\n }\n\n if (!this.isValidOperatorId(msg.operator_id)) {\n return false;\n }\n }\n\n return true;\n });\n\n return {\n messages: filteredMessages,\n };\n } catch (error: any) {\n if (this.logger) {\n this.logger.error(`Error fetching messages: ${error.message}`);\n }\n return { messages: [] };\n }\n }\n\n /**\n * Public method to retrieve topic information using the internal mirror node client.\n *\n * @param topicId The ID of the topic to query.\n * @returns Topic information or null if not found or an error occurs.\n */\n async getPublicTopicInfo(topicId: string): Promise<TopicResponse | null> {\n try {\n return await this.mirrorNode.getTopicInfo(topicId);\n } catch (error) {\n this.logger.error(\n `Error getting public topic info for ${topicId}:`,\n error\n );\n return null;\n }\n }\n\n /**\n * Checks if a user can submit to a topic and determines if a fee is required\n * @param topicId The topic ID to check\n * @param userAccountId The account ID of the user attempting to submit\n * @returns Object with canSubmit, requiresFee, and optional reason\n */\n public async canSubmitToTopic(\n topicId: string,\n userAccountId: string\n ): Promise<{ canSubmit: boolean; requiresFee: boolean; reason?: string }> {\n try {\n const topicInfo = await this.mirrorNode.getTopicInfo(topicId);\n\n if (!topicInfo) {\n return {\n canSubmit: false,\n requiresFee: false,\n reason: 'Topic does not exist',\n };\n }\n\n if (!topicInfo.submit_key?.key) {\n return { canSubmit: true, requiresFee: false };\n }\n\n try {\n const userPublicKey = await this.mirrorNode.getPublicKey(userAccountId);\n\n if (topicInfo.submit_key._type === 'ProtobufEncoded') {\n const keyBytes = Buffer.from(topicInfo.submit_key.key, 'hex');\n const hasAccess = await this.mirrorNode.checkKeyListAccess(\n keyBytes,\n userPublicKey\n );\n\n if (hasAccess) {\n return { canSubmit: true, requiresFee: false };\n }\n } else {\n const topicSubmitKey = PublicKey.fromString(topicInfo.submit_key.key);\n if (userPublicKey.toString() === topicSubmitKey.toString()) {\n return { canSubmit: true, requiresFee: false };\n }\n }\n } catch (error) {\n this.logger.error(\n `Key validation error: ${\n error instanceof Error ? error.message : String(error)\n }`\n );\n }\n\n if (\n topicInfo.fee_schedule_key?.key &&\n topicInfo.custom_fees?.fixed_fees?.length > 0\n ) {\n return {\n canSubmit: true,\n requiresFee: true,\n reason: 'Requires fee payment via HIP-991',\n };\n }\n\n return {\n canSubmit: false,\n requiresFee: false,\n reason: 'User does not have submit permission for this topic',\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : String(error);\n this.logger.error(`Topic submission validation error: ${errorMessage}`);\n return {\n canSubmit: false,\n requiresFee: false,\n reason: `Error: ${errorMessage}`,\n };\n }\n }\n\n /**\n * Get all messages from a topic\n * @param topicId The topic ID to get messages from\n * @returns All messages from the topic\n */\n public async getMessages(\n topicId: string\n ): Promise<{ messages: HCSMessage[] }> {\n try {\n const messages = await this.mirrorNode.getTopicMessages(topicId);\n\n const validatedMessages = messages.filter((msg) => {\n if (msg.p !== 'hcs-10') {\n return false;\n }\n\n if (msg.op === 'message') {\n if (!msg.data) {\n return false;\n }\n\n if (msg.operator_id) {\n if (!this.isValidOperatorId(msg.operator_id)) {\n return false;\n }\n }\n }\n\n return true;\n });\n\n return {\n messages: validatedMessages,\n };\n } catch (error: any) {\n if (this.logger) {\n this.logger.error(`Error fetching messages: ${error.message}`);\n }\n return { messages: [] };\n }\n }\n\n /**\n * Requests an account from the mirror node\n * @param account The account ID to request\n * @returns The account response\n */\n public async requestAccount(account: string): Promise<AccountResponse> {\n try {\n return await this.mirrorNode.requestAccount(account);\n } catch (e) {\n this.logger.error('Failed to fetch account', e);\n throw e;\n }\n }\n\n /**\n * Retrieves the memo for an account\n * @param accountId The account ID to retrieve the memo for\n * @returns The memo\n */\n public async getAccountMemo(accountId: string): Promise<string | null> {\n return await this.mirrorNode.getAccountMemo(accountId);\n }\n\n /**\n * Retrieves the profile for an account\n * @param accountId The account ID to retrieve the profile for\n * @param disableCache Whether to disable caching of the result\n * @returns The profile\n */\n public async retrieveProfile(\n accountId: string,\n disableCache?: boolean\n ): Promise<ProfileResponse> {\n this.logger.debug(`Retrieving profile for account: ${accountId}`);\n\n const cacheKey = `${accountId}-${this.network}`;\n\n if (!disableCache) {\n const cachedProfileResponse = HCS10Cache.getInstance().get(cacheKey);\n if (cachedProfileResponse) {\n this.logger.debug(`Cache hit for profile: ${accountId}`);\n return cachedProfileResponse;\n }\n }\n try {\n const hcs11Client = new HCS11Client({\n network: this.network as 'mainnet' | 'testnet',\n auth: {\n operatorId: '0.0.0', // Read-only operations only\n },\n logLevel: 'info',\n });\n\n const profileResult = await hcs11Client.fetchProfileByAccountId(\n accountId,\n this.network\n );\n\n if (!profileResult?.success) {\n this.logger.error(\n `Failed to retrieve profile for account ID: ${accountId}`,\n profileResult?.error\n );\n return {\n profile: null,\n success: false,\n error:\n profileResult?.error ||\n `Failed to retrieve profile for account ID: ${accountId}`,\n };\n }\n\n const profile = profileResult.profile;\n let topicInfo: TopicInfo | null = null;\n\n if (\n profileResult.topicInfo?.inboundTopic &&\n profileResult.topicInfo?.outboundTopic &&\n profileResult.topicInfo?.profileTopicId\n ) {\n topicInfo = {\n inboundTopic: profileResult.topicInfo.inboundTopic,\n outboundTopic: profileResult.topicInfo.outboundTopic,\n profileTopicId: profileResult.topicInfo.profileTopicId,\n };\n }\n\n const responseToCache: ProfileResponse = {\n profile,\n topicInfo,\n success: true,\n };\n HCS10Cache.getInstance().set(cacheKey, responseToCache);\n return responseToCache;\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Failed to retrieve profile: ${error.message}`;\n this.logger.error(logMessage);\n return {\n profile: null,\n success: false,\n error: logMessage,\n };\n }\n }\n\n /**\n * @deprecated Use retrieveCommunicationTopics instead\n * @param accountId The account ID to retrieve the outbound connect topic for\n * @returns {TopicInfo} Topic Info from target profile.\n */\n public async retrieveOutboundConnectTopic(\n accountId: string\n ): Promise<TopicInfo> {\n return await this.retrieveCommunicationTopics(accountId, true);\n }\n\n /**\n * Retrieves the communication topics for an account\n * @param accountId The account ID to retrieve the communication topics for\n * @param disableCache Whether to disable caching of the result\n * @returns {TopicInfo} Topic Info from target profile.\n */\n public async retrieveCommunicationTopics(\n accountId: string,\n disableCache?: boolean\n ): Promise<TopicInfo> {\n try {\n const profileResponse = await this.retrieveProfile(\n accountId,\n disableCache\n );\n\n if (!profileResponse?.success) {\n throw new Error(profileResponse.error || 'Failed to retrieve profile');\n }\n\n const profile = profileResponse.profile;\n\n if (!profile.inboundTopicId || !profile.outboundTopicId) {\n throw new Error(\n `Invalid HCS-11 profile for HCS-10 agent: missing inboundTopicId or outboundTopicId`\n );\n }\n\n if (!profileResponse.topicInfo) {\n throw new Error(\n `TopicInfo is missing in the profile for account ${accountId}`\n );\n }\n\n return profileResponse.topicInfo;\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Failed to retrieve topic info: ${error.message}`;\n this.logger.error(logMessage);\n throw error;\n }\n }\n\n /**\n * Retrieves outbound messages for an agent\n * @param agentAccountId The account ID of the agent\n * @returns The outbound messages\n */\n public async retrieveOutboundMessages(\n agentAccountId: string\n ): Promise<HCSMessage[]> {\n try {\n const topicInfo = await this.retrieveCommunicationTopics(agentAccountId);\n if (!topicInfo) {\n this.logger.warn(\n `No outbound connect topic found for agentAccountId: ${agentAccountId}`\n );\n return [];\n }\n const response = await this.getMessages(topicInfo.outboundTopic);\n return response.messages.filter(\n (msg) =>\n msg.p === 'hcs-10' &&\n (msg.op === 'connection_request' ||\n msg.op === 'connection_created' ||\n msg.op === 'message')\n );\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Failed to retrieve outbound messages: ${error.message}`;\n this.logger.error(logMessage);\n return [];\n }\n }\n\n /**\n * Checks if a connection has been created for an agent\n * @param agentAccountId The account ID of the agent\n * @param connectionId The ID of the connection\n * @returns True if the connection has been created, false otherwise\n */\n public async hasConnectionCreated(\n agentAccountId: string,\n connectionId: number\n ): Promise<boolean> {\n try {\n const outBoundTopic = await this.retrieveCommunicationTopics(\n agentAccountId\n );\n const messages = await this.retrieveOutboundMessages(\n outBoundTopic.outboundTopic\n );\n return messages.some(\n (msg) =>\n msg.op === 'connection_created' && msg.connection_id === connectionId\n );\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Failed to check connection created: ${error.message}`;\n this.logger.error(logMessage);\n return false;\n }\n }\n\n /**\n * Gets message content, resolving any HRL references if needed\n * @param data The data string that may contain an HRL reference\n * @param forceRaw Whether to force returning raw binary data\n * @returns The resolved content\n */\n async getMessageContent(\n data: string,\n forceRaw = false\n ): Promise<string | ArrayBuffer> {\n if (!data.match(/^hcs:\\/\\/(\\d+)\\/([0-9]+\\.[0-9]+\\.[0-9]+)$/)) {\n return data;\n }\n\n try {\n const resolver = new HRLResolver(this.logger.getLevel());\n\n if (!resolver.isValidHRL(data)) {\n return data;\n }\n\n const result = await resolver.resolveHRL(data, {\n network: this.network as 'mainnet' | 'testnet',\n returnRaw: forceRaw,\n });\n\n return result.content;\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Error resolving HRL reference: ${error.message}`;\n this.logger.error(logMessage);\n throw new Error(logMessage);\n }\n }\n\n /**\n * Gets message content with its content type, resolving any HRL references if needed\n * @param data The data string that may contain an HRL reference\n * @param forceRaw Whether to force returning raw binary data\n * @returns The resolved content along with content type information\n */\n async getMessageContentWithType(\n data: string,\n forceRaw = false\n ): Promise<{\n content: string | ArrayBuffer;\n contentType: string;\n isBinary: boolean;\n }> {\n if (!data.match(/^hcs:\\/\\/(\\d+)\\/([0-9]+\\.[0-9]+\\.[0-9]+)$/)) {\n return {\n content: data,\n contentType: 'text/plain',\n isBinary: false,\n };\n }\n\n try {\n const resolver = new HRLResolver(this.logger.getLevel());\n\n return await resolver.getContentWithType(data, {\n network: this.network as 'mainnet' | 'testnet',\n returnRaw: forceRaw,\n });\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Error resolving HRL reference with type: ${error.message}`;\n this.logger.error(logMessage);\n throw new Error(logMessage);\n }\n }\n\n /**\n * Submits a connection request to an inbound topic\n * @param inboundTopicId The ID of the inbound topic\n * @param memo An optional memo for the message\n * @returns The transaction receipt\n */\n async submitConnectionRequest(\n inboundTopicId: string,\n memo: string\n ): Promise<TransactionReceipt> {\n const accountResponse = this.getAccountAndSigner();\n if (!accountResponse?.accountId) {\n throw new Error('Operator account ID is not set');\n }\n const operatorId = await this.getOperatorId();\n const accountId = accountResponse.accountId;\n\n const submissionCheck = await this.canSubmitToTopic(\n inboundTopicId,\n accountId\n );\n\n if (!submissionCheck?.canSubmit) {\n throw new Error(`Cannot submit to topic: ${submissionCheck.reason}`);\n }\n\n const inboundAccountOwner = await this.retrieveInboundAccountId(\n inboundTopicId\n );\n\n if (!inboundAccountOwner) {\n throw new Error('Failed to retrieve topic info account ID');\n }\n\n const connectionRequestMessage = {\n p: 'hcs-10',\n op: 'connection_request',\n operator_id: operatorId,\n m: memo,\n };\n\n const requiresFee = submissionCheck.requiresFee;\n const response = await this.submitPayload(\n inboundTopicId,\n connectionRequestMessage,\n undefined,\n requiresFee\n );\n\n this.logger.info(\n `Submitted connection request to topic ID: ${inboundTopicId}`\n );\n\n const outboundTopic = await this.retrieveCommunicationTopics(accountId);\n\n if (!outboundTopic) {\n throw new Error('Failed to retrieve outbound topic');\n }\n\n const responseSequenceNumber = response.topicSequenceNumber?.toNumber();\n\n if (!responseSequenceNumber) {\n throw new Error('Failed to get response sequence number');\n }\n\n const requestorOperatorId = `${inboundTopicId}@${inboundAccountOwner}`;\n\n await this.submitPayload(outboundTopic.outboundTopic, {\n ...connectionRequestMessage,\n outbound_topic_id: outboundTopic.outboundTopic,\n connection_request_id: responseSequenceNumber,\n operator_id: requestorOperatorId,\n });\n\n return response;\n }\n\n /**\n * Records an outbound connection confirmation\n * @param outboundTopicId The ID of the outbound topic\n * @param connectionRequestId The ID of the connection request\n * @param confirmedRequestId The ID of the confirmed request\n * @param connectionTopicId The ID of the connection topic\n * @param operatorId The operator ID of the original message sender.\n * @param memo An optional memo for the message\n */\n public async recordOutboundConnectionConfirmation({\n outboundTopicId,\n requestorOutboundTopicId,\n connectionRequestId,\n confirmedRequestId,\n connectionTopicId,\n operatorId,\n memo,\n }: {\n outboundTopicId: string;\n requestorOutboundTopicId: string;\n connectionRequestId: number;\n confirmedRequestId: number;\n connectionTopicId: string;\n operatorId: string;\n memo: string;\n }): Promise<TransactionReceipt> {\n const payload = {\n p: 'hcs-10',\n op: 'connection_created',\n connection_topic_id: connectionTopicId,\n outbound_topic_id: outboundTopicId,\n requestor_outbound_topic_id: requestorOutboundTopicId,\n confirmed_request_id: confirmedRequestId,\n connection_request_id: connectionRequestId,\n operator_id: operatorId,\n m: memo,\n };\n return await this.submitPayload(outboundTopicId, payload);\n }\n\n /**\n * Waits for confirmation of a connection request\n * @param inboundTopicId Inbound topic ID\n * @param connectionRequestId Connection request ID\n * @param maxAttempts Maximum number of attempts\n * @param delayMs Delay between attempts in milliseconds\n * @returns Connection confirmation details\n */\n async waitForConnectionConfirmation(\n inboundTopicId: string,\n connectionRequestId: number,\n maxAttempts = 60,\n delayMs = 2000,\n recordConfirmation = true\n ): Promise<WaitForConnectionConfirmationResponse> {\n this.logger.info(\n `Waiting for connection confirmation on inbound topic ${inboundTopicId} for request ID ${connectionRequestId}`\n );\n\n for (let attempt = 0; attempt < maxAttempts; attempt++) {\n this.logger.info(\n `Attempt ${attempt + 1}/${maxAttempts} to find connection confirmation`\n );\n const messages = await this.mirrorNode.getTopicMessages(inboundTopicId);\n\n const connectionCreatedMessages = messages.filter(\n (m) => m.op === 'connection_created'\n );\n\n this.logger.info(\n `Found ${connectionCreatedMessages.length} connection_created messages`\n );\n\n if (connectionCreatedMessages.length > 0) {\n for (const message of connectionCreatedMessages) {\n if (Number(message.connection_id) === Number(connectionRequestId)) {\n const confirmationResult = {\n connectionTopicId: message.connection_topic_id,\n sequence_number: Number(message.sequence_number),\n confirmedBy: message.operator_id,\n memo: message.m,\n };\n\n const confirmedByAccountId = this.extractAccountFromOperatorId(\n confirmationResult.confirmedBy\n );\n\n const account = this.getAccountAndSigner();\n const confirmedByConnectionTopics =\n await this.retrieveCommunicationTopics(confirmedByAccountId);\n\n const agentConnectionTopics =\n await this.retrieveCommunicationTopics(account.accountId);\n\n this.logger.info(\n 'Connection confirmation found',\n confirmationResult\n );\n\n if (recordConfirmation) {\n /**\n * Record's the confirmation of the connection request from the\n * confirmedBy account to the agent account.\n */\n await this.recordOutboundConnectionConfirmation({\n requestorOutboundTopicId:\n confirmedByConnectionTopics.outboundTopic,\n outboundTopicId: agentConnectionTopics.outboundTopic,\n connectionRequestId,\n confirmedRequestId: confirmationResult.sequence_number,\n connectionTopicId: confirmationResult.connectionTopicId,\n operatorId: confirmationResult.confirmedBy,\n memo: confirmationResult.memo || 'Connection confirmed',\n });\n }\n\n return confirmationResult;\n }\n }\n }\n\n if (attempt < maxAttempts - 1) {\n this.logger.info(\n `No matching confirmation found, waiting ${delayMs}ms before retrying...`\n );\n await new Promise((resolve) => setTimeout(resolve, delayMs));\n }\n }\n\n throw new Error(\n `Connection confirmation not found after ${maxAttempts} attempts for request ID ${connectionRequestId}`\n );\n }\n\n /**\n * Retrieves the operator ID for the current agent\n * @param disableCache Whether to disable caching of the result\n * @returns The operator ID\n */\n public async getOperatorId(disableCache?: boolean): Promise<string> {\n if (this.operatorId && !disableCache) {\n return this.operatorId;\n }\n\n const accountResponse = this.getAccountAndSigner();\n\n if (!accountResponse.accountId) {\n throw new Error('Operator ID not found');\n }\n\n const profile = await this.retrieveProfile(accountResponse.accountId);\n\n if (!profile.success) {\n throw new Error('Failed to retrieve profile');\n }\n\n const operatorId = `${profile.topicInfo?.inboundTopic}@${accountResponse.accountId}`;\n this.operatorId = operatorId;\n return operatorId;\n }\n\n /**\n * Retrieves the account ID of the owner of an inbound topic\n * @param inboundTopicId The ID of the inbound topic\n * @returns The account ID of the owner of the inbound topic\n */\n public async retrieveInboundAccountId(\n inboundTopicId: string\n ): Promise<string> {\n const topicInfo = await this.mirrorNode.getTopicInfo(inboundTopicId);\n\n if (!topicInfo?.memo) {\n throw new Error('Failed to retrieve topic info');\n }\n\n const topicInfoMemo = topicInfo.memo.toString();\n const topicInfoParts = topicInfoMemo.split(':');\n const inboundAccountOwner = topicInfoParts?.[4];\n\n if (!inboundAccountOwner) {\n throw new Error('Failed to retrieve topic info account ID');\n }\n\n return inboundAccountOwner;\n }\n\n public clearCache(): void {\n HCS10Cache.getInstance().clear();\n }\n\n /**\n * Generates a standard HCS-10 memo string.\n * @param type The type of topic memo ('inbound', 'outbound', 'connection').\n * @param options Configuration options for the memo.\n * @returns The formatted memo string.\n * @protected\n */\n protected _generateHcs10Memo(\n type: Hcs10MemoType,\n options: {\n ttl?: number;\n accountId?: string;\n inboundTopicId?: string;\n connectionId?: number;\n }\n ): string {\n const ttl = options.ttl ?? 60;\n\n switch (type) {\n case Hcs10MemoType.INBOUND:\n if (!options.accountId) {\n throw new Error('accountId is required for inbound memo');\n }\n return `hcs-10:0:${ttl}:0:${options.accountId}`;\n case Hcs10MemoType.OUTBOUND:\n return `hcs-10:0:${ttl}:1`;\n case Hcs10MemoType.CONNECTION:\n if (!options.inboundTopicId || options.connectionId === undefined) {\n throw new Error(\n 'inboundTopicId and connectionId are required for connection memo'\n );\n }\n return `hcs-10:1:${ttl}:2:${options.inboundTopicId}:${options.connectionId}`;\n default:\n throw new Error(`Invalid HCS-10 memo type: ${type}`);\n }\n }\n\n protected async checkRegistrationStatus(\n transactionId: string,\n network: string,\n baseUrl: string\n ): Promise<{ status: 'pending' | 'success' | 'failed' }> {\n try {\n const response = await fetch(`${baseUrl}/api/request-confirm`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'X-Network': network,\n },\n body: JSON.stringify({ transaction_id: transactionId }),\n });\n\n if (!response.ok) {\n throw new Error(\n `Failed to confirm registration: ${response.statusText}`\n );\n }\n\n return await response.json();\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Error checking registration status: ${error.message}`;\n this.logger.error(logMessage);\n throw error;\n }\n }\n\n /**\n * Validates if an operator_id follows the correct format (agentTopicId@accountId)\n * @param operatorId The operator ID to validate\n * @returns True if the format is valid, false otherwise\n */\n protected isValidOperatorId(operatorId: string): boolean {\n if (!operatorId) {\n return false;\n }\n\n const parts = operatorId.split('@');\n\n if (parts.length !== 2) {\n return false;\n }\n\n const agentTopicId = parts[0];\n const accountId = parts[1];\n\n if (!agentTopicId) {\n return false;\n }\n\n if (!accountId) {\n return false;\n }\n\n const hederaIdPattern = /^[0-9]+\\.[0-9]+\\.[0-9]+$/;\n\n if (!hederaIdPattern.test(accountId)) {\n return false;\n }\n\n if (!hederaIdPattern.test(agentTopicId)) {\n return false;\n }\n\n return true;\n }\n\n /**\n * Retrieves all transaction requests from a topic\n * @param topicId The topic ID to retrieve transactions from\n * @param limit Optional maximum number of messages to retrieve\n * @returns Array of transaction requests sorted by timestamp (newest first)\n */\n public async getTransactionRequests(\n topicId: string,\n limit?: number\n ): Promise<TransactMessage[]> {\n this.logger.debug(`Retrieving transaction requests from topic ${topicId}`);\n\n const { messages } = await this.getMessageStream(topicId);\n\n const transactOperations = (\n messages\n .filter((m) => m.op === 'transaction' && m.schedule_id)\n .map((m) => ({\n operator_id: m.operator_id || '',\n schedule_id: m.schedule_id || '',\n data: m.data || '',\n memo: m.m,\n sequence_number: Number(m.sequence_number),\n })) as unknown as TransactMessage[]\n ).sort((a, b) => {\n if (a.sequence_number && b.sequence_number) {\n return b.sequence_number - a.sequence_number;\n }\n return 0;\n });\n\n const result = limit\n ? transactOperations.slice(0, limit)\n : transactOperations;\n\n return result;\n }\n}\n\nexport class HCS10Cache {\n private static instance: HCS10Cache;\n private cache: Map<string, ProfileResponse>;\n private cacheExpiry: Map<string, number>;\n private readonly CACHE_TTL = 3600000;\n\n private constructor() {\n this.cache = new Map();\n this.cacheExpiry = new Map();\n }\n\n static getInstance(): HCS10Cache {\n if (!HCS10Cache.instance) {\n HCS10Cache.instance = new HCS10Cache();\n }\n return HCS10Cache.instance;\n }\n\n set(key: string, value: ProfileResponse): void {\n this.cache.set(key, value);\n this.cacheExpiry.set(key, Date.now() + this.CACHE_TTL);\n }\n\n get(key: string): ProfileResponse | undefined {\n const expiry = this.cacheExpiry.get(key);\n if (expiry && expiry > Date.now()) {\n return this.cache.get(key);\n }\n if (expiry) {\n this.cache.delete(key);\n this.cacheExpiry.delete(key);\n }\n return undefined;\n }\n\n clear(): void {\n this.cache.clear();\n this.cacheExpiry.clear();\n }\n}\n"],"names":["Hcs10MemoType"],"mappings":";;;;;;;AAmBY,IAAA,kCAAAA,mBAAL;AACLA,iBAAA,SAAU,IAAA;AACVA,iBAAA,UAAW,IAAA;AACXA,iBAAA,YAAa,IAAA;AAHHA,SAAAA;AAAA,GAAA,iBAAA,CAAA,CAAA;AAuFL,MAAe,wBAAwB,aAAa;AAAA,EAQzD,YAAY,QAAqB;AACzB,UAAA;AACN,SAAK,UAAU,OAAO;AACjB,SAAA,SAAS,OAAO,YAAY;AAAA,MAC/B,OAAO,OAAO,YAAY;AAAA,MAC1B,QAAQ;AAAA,MACR,aAAa,OAAO;AAAA,IAAA,CACrB;AACD,SAAK,aAAa,IAAI;AAAA,MACpB,OAAO;AAAA,MACP,KAAK;AAAA,MACL,OAAO;AAAA,IACT;AACK,SAAA,YAAY,OAAO,aAAa;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAgBhC,oBAAoB,QAAgC;AACpD,SAAA,WAAW,oBAAoB,MAAM;AACrC,SAAA,OAAO,KAAK,mCAAmC;AAAA,EAAA;AAAA,EAG/C,2BAA2B,YAA4B;AAC5D,QAAI,CAAC,YAAY;AACR,aAAA;AAAA,IAAA;AAEH,UAAA,QAAQ,WAAW,MAAM,GAAG;AAC9B,QAAA,MAAM,SAAS,GAAG;AACpB,aAAO,MAAM,CAAC;AAAA,IAAA;AAET,WAAA;AAAA,EAAA;AAAA,EAGF,6BAA6B,YAA4B;AAC9D,QAAI,CAAC,YAAY;AACR,aAAA;AAAA,IAAA;AAEH,UAAA,QAAQ,WAAW,MAAM,GAAG;AAC9B,QAAA,MAAM,SAAS,GAAG;AACpB,aAA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Y,IAAI,GAAG;AACvC,QAAI,UAAU,SAAS,KAAK,IAAA,GAAO;AAC1B,aAAA,KAAK,MAAM,IAAI,GAAG;AAAA,IAAA;AAE3B,QAAI,QAAQ;AACL,WAAA,MAAM,OAAO,GAAG;AAChB,WAAA,YAAY,OAAO,GAAG;AAAA,IAAA;AAEtB,WAAA;AAAA,EAAA;AAAA,EAGT,QAAc;AACZ,SAAK,MAAM,MAAM;AACjB,SAAK,YAAY,MAAM;AAAA,EAAA;AAE3B;"}
|
|
1
|
+
{"version":3,"file":"standards-sdk.es5.js","sources":["../../src/hcs-10/base-client.ts"],"sourcesContent":["import { Logger, LogLevel } from '../utils/logger';\nimport { Registration } from './registrations';\nimport { HCS11Client } from '../hcs-11/client';\nimport {\n AccountResponse,\n TopicResponse,\n ScheduleInfo,\n} from '../services/types';\nimport { TopicInfo } from '../services/types';\nimport { TransactionReceipt, PrivateKey, PublicKey } from '@hashgraph/sdk';\nimport axios from 'axios';\nimport { NetworkType } from '../utils/types';\nimport { HederaMirrorNode, MirrorNodeConfig } from '../services';\nimport {\n WaitForConnectionConfirmationResponse,\n TransactMessage,\n} from './types';\nimport { HRLResolver } from '../utils/hrl-resolver';\n\nexport enum Hcs10MemoType {\n INBOUND = 'inbound',\n OUTBOUND = 'outbound',\n CONNECTION = 'connection',\n}\n\n/**\n * Configuration for HCS-10 client.\n * \n * @example\n * // Using default Hedera mirror nodes\n * const config = {\n * network: 'testnet',\n * logLevel: 'info'\n * };\n * \n * @example\n * // Using HGraph custom mirror node provider\n * const config = {\n * network: 'mainnet',\n * logLevel: 'info',\n * mirrorNode: {\n * customUrl: 'https://mainnet.hedera.api.hgraph.dev/v1/<API-KEY>',\n * apiKey: 'your-hgraph-api-key'\n * }\n * };\n * \n * @example\n * // Using custom mirror node with headers\n * const config = {\n * network: 'testnet',\n * mirrorNode: {\n * customUrl: 'https://custom-mirror.example.com',\n * apiKey: 'your-api-key',\n * headers: {\n * 'X-Custom-Header': 'value'\n * }\n * }\n * };\n */\nexport interface HCS10Config {\n /** The Hedera network to connect to */\n network: 'mainnet' | 'testnet';\n /** Log level for the client */\n logLevel?: LogLevel;\n /** Whether to pretty print logs */\n prettyPrint?: boolean;\n /** Fee amount for transactions that require fees */\n feeAmount?: number;\n /** Custom mirror node configuration */\n mirrorNode?: MirrorNodeConfig;\n}\n\nexport interface HCSMessage {\n p: 'hcs-10';\n op:\n | 'connection_request'\n | 'connection_created'\n | 'message'\n | 'close_connection'\n | 'transaction';\n data?: string;\n created?: Date;\n consensus_timestamp?: string;\n m?: string;\n payer: string;\n outbound_topic_id?: string;\n connection_request_id?: number;\n confirmed_request_id?: number;\n connection_topic_id?: string;\n connected_account_id?: string;\n requesting_account_id?: string;\n connection_id?: number;\n sequence_number: number;\n operator_id?: string;\n reason?: string;\n close_method?: string;\n schedule_id?: string;\n}\n\nexport interface ProfileResponse {\n profile: any;\n topicInfo?: TopicInfo;\n success: boolean;\n error?: string;\n}\n\nexport abstract class HCS10BaseClient extends Registration {\n protected network: string;\n protected logger: Logger;\n protected feeAmount: number;\n public mirrorNode: HederaMirrorNode;\n\n protected operatorId: string;\n\n constructor(config: HCS10Config) {\n super();\n this.network = config.network;\n this.logger = Logger.getInstance({\n level: config.logLevel || 'info',\n module: 'HCS10-BaseClient',\n prettyPrint: config.prettyPrint,\n });\n this.mirrorNode = new HederaMirrorNode(\n config.network as NetworkType,\n this.logger,\n config.mirrorNode\n );\n this.feeAmount = config.feeAmount || 0.001;\n }\n\n abstract submitPayload(\n topicId: string,\n payload: object | string,\n submitKey?: PrivateKey,\n requiresFee?: boolean\n ): Promise<TransactionReceipt>;\n\n abstract getAccountAndSigner(): { accountId: string; signer: any };\n\n /**\n * Updates the mirror node configuration.\n * @param config The new mirror node configuration.\n */\n public configureMirrorNode(config: MirrorNodeConfig): void {\n this.mirrorNode.configureMirrorNode(config);\n this.logger.info('Mirror node configuration updated');\n }\n\n public extractTopicFromOperatorId(operatorId: string): string {\n if (!operatorId) {\n return '';\n }\n const parts = operatorId.split('@');\n if (parts.length > 0) {\n return parts[0];\n }\n return '';\n }\n\n public extractAccountFromOperatorId(operatorId: string): string {\n if (!operatorId) {\n return '';\n }\n const parts = operatorId.split('@');\n if (parts.length > 1) {\n return parts[1];\n }\n return '';\n }\n\n /**\n * Get a stream of messages from a connection topic\n * @param topicId The connection topic ID to get messages from\n * @returns A stream of filtered messages valid for connection topics\n */\n public async getMessageStream(\n topicId: string\n ): Promise<{ messages: HCSMessage[] }> {\n try {\n const messages = await this.mirrorNode.getTopicMessages(topicId);\n const validOps = ['message', 'close_connection', 'transaction'];\n\n const filteredMessages = messages.filter((msg) => {\n if (msg.p !== 'hcs-10' || !validOps.includes(msg.op)) {\n return false;\n }\n\n if (msg.op === 'message' || msg.op === 'close_connection') {\n if (!msg.operator_id) {\n return false;\n }\n\n if (!this.isValidOperatorId(msg.operator_id)) {\n return false;\n }\n\n if (msg.op === 'message' && !msg.data) {\n return false;\n }\n }\n\n if (msg.op === 'transaction') {\n if (!msg.operator_id || !msg.schedule_id) {\n return false;\n }\n\n if (!this.isValidOperatorId(msg.operator_id)) {\n return false;\n }\n }\n\n return true;\n });\n\n return {\n messages: filteredMessages,\n };\n } catch (error: any) {\n if (this.logger) {\n this.logger.error(`Error fetching messages: ${error.message}`);\n }\n return { messages: [] };\n }\n }\n\n /**\n * Public method to retrieve topic information using the internal mirror node client.\n *\n * @param topicId The ID of the topic to query.\n * @returns Topic information or null if not found or an error occurs.\n */\n async getPublicTopicInfo(topicId: string): Promise<TopicResponse | null> {\n try {\n return await this.mirrorNode.getTopicInfo(topicId);\n } catch (error) {\n this.logger.error(\n `Error getting public topic info for ${topicId}:`,\n error\n );\n return null;\n }\n }\n\n /**\n * Checks if a user can submit to a topic and determines if a fee is required\n * @param topicId The topic ID to check\n * @param userAccountId The account ID of the user attempting to submit\n * @returns Object with canSubmit, requiresFee, and optional reason\n */\n public async canSubmitToTopic(\n topicId: string,\n userAccountId: string\n ): Promise<{ canSubmit: boolean; requiresFee: boolean; reason?: string }> {\n try {\n const topicInfo = await this.mirrorNode.getTopicInfo(topicId);\n\n if (!topicInfo) {\n return {\n canSubmit: false,\n requiresFee: false,\n reason: 'Topic does not exist',\n };\n }\n\n if (!topicInfo.submit_key?.key) {\n return { canSubmit: true, requiresFee: false };\n }\n\n try {\n const userPublicKey = await this.mirrorNode.getPublicKey(userAccountId);\n\n if (topicInfo.submit_key._type === 'ProtobufEncoded') {\n const keyBytes = Buffer.from(topicInfo.submit_key.key, 'hex');\n const hasAccess = await this.mirrorNode.checkKeyListAccess(\n keyBytes,\n userPublicKey\n );\n\n if (hasAccess) {\n return { canSubmit: true, requiresFee: false };\n }\n } else {\n const topicSubmitKey = PublicKey.fromString(topicInfo.submit_key.key);\n if (userPublicKey.toString() === topicSubmitKey.toString()) {\n return { canSubmit: true, requiresFee: false };\n }\n }\n } catch (error) {\n this.logger.error(\n `Key validation error: ${\n error instanceof Error ? error.message : String(error)\n }`\n );\n }\n\n if (\n topicInfo.fee_schedule_key?.key &&\n topicInfo.custom_fees?.fixed_fees?.length > 0\n ) {\n return {\n canSubmit: true,\n requiresFee: true,\n reason: 'Requires fee payment via HIP-991',\n };\n }\n\n return {\n canSubmit: false,\n requiresFee: false,\n reason: 'User does not have submit permission for this topic',\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : String(error);\n this.logger.error(`Topic submission validation error: ${errorMessage}`);\n return {\n canSubmit: false,\n requiresFee: false,\n reason: `Error: ${errorMessage}`,\n };\n }\n }\n\n /**\n * Get all messages from a topic\n * @param topicId The topic ID to get messages from\n * @returns All messages from the topic\n */\n public async getMessages(\n topicId: string\n ): Promise<{ messages: HCSMessage[] }> {\n try {\n const messages = await this.mirrorNode.getTopicMessages(topicId);\n\n const validatedMessages = messages.filter((msg) => {\n if (msg.p !== 'hcs-10') {\n return false;\n }\n\n if (msg.op === 'message') {\n if (!msg.data) {\n return false;\n }\n\n if (msg.operator_id) {\n if (!this.isValidOperatorId(msg.operator_id)) {\n return false;\n }\n }\n }\n\n return true;\n });\n\n return {\n messages: validatedMessages,\n };\n } catch (error: any) {\n if (this.logger) {\n this.logger.error(`Error fetching messages: ${error.message}`);\n }\n return { messages: [] };\n }\n }\n\n /**\n * Requests an account from the mirror node\n * @param account The account ID to request\n * @returns The account response\n */\n public async requestAccount(account: string): Promise<AccountResponse> {\n try {\n return await this.mirrorNode.requestAccount(account);\n } catch (e) {\n this.logger.error('Failed to fetch account', e);\n throw e;\n }\n }\n\n /**\n * Retrieves the memo for an account\n * @param accountId The account ID to retrieve the memo for\n * @returns The memo\n */\n public async getAccountMemo(accountId: string): Promise<string | null> {\n return await this.mirrorNode.getAccountMemo(accountId);\n }\n\n /**\n * Retrieves the profile for an account\n * @param accountId The account ID to retrieve the profile for\n * @param disableCache Whether to disable caching of the result\n * @returns The profile\n */\n public async retrieveProfile(\n accountId: string,\n disableCache?: boolean\n ): Promise<ProfileResponse> {\n this.logger.debug(`Retrieving profile for account: ${accountId}`);\n\n const cacheKey = `${accountId}-${this.network}`;\n\n if (!disableCache) {\n const cachedProfileResponse = HCS10Cache.getInstance().get(cacheKey);\n if (cachedProfileResponse) {\n this.logger.debug(`Cache hit for profile: ${accountId}`);\n return cachedProfileResponse;\n }\n }\n try {\n const hcs11Client = new HCS11Client({\n network: this.network as 'mainnet' | 'testnet',\n auth: {\n operatorId: '0.0.0', // Read-only operations only\n },\n logLevel: 'info',\n });\n\n const profileResult = await hcs11Client.fetchProfileByAccountId(\n accountId,\n this.network\n );\n\n if (!profileResult?.success) {\n this.logger.error(\n `Failed to retrieve profile for account ID: ${accountId}`,\n profileResult?.error\n );\n return {\n profile: null,\n success: false,\n error:\n profileResult?.error ||\n `Failed to retrieve profile for account ID: ${accountId}`,\n };\n }\n\n const profile = profileResult.profile;\n let topicInfo: TopicInfo | null = null;\n\n if (\n profileResult.topicInfo?.inboundTopic &&\n profileResult.topicInfo?.outboundTopic &&\n profileResult.topicInfo?.profileTopicId\n ) {\n topicInfo = {\n inboundTopic: profileResult.topicInfo.inboundTopic,\n outboundTopic: profileResult.topicInfo.outboundTopic,\n profileTopicId: profileResult.topicInfo.profileTopicId,\n };\n }\n\n const responseToCache: ProfileResponse = {\n profile,\n topicInfo,\n success: true,\n };\n HCS10Cache.getInstance().set(cacheKey, responseToCache);\n return responseToCache;\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Failed to retrieve profile: ${error.message}`;\n this.logger.error(logMessage);\n return {\n profile: null,\n success: false,\n error: logMessage,\n };\n }\n }\n\n /**\n * @deprecated Use retrieveCommunicationTopics instead\n * @param accountId The account ID to retrieve the outbound connect topic for\n * @returns {TopicInfo} Topic Info from target profile.\n */\n public async retrieveOutboundConnectTopic(\n accountId: string\n ): Promise<TopicInfo> {\n return await this.retrieveCommunicationTopics(accountId, true);\n }\n\n /**\n * Retrieves the communication topics for an account\n * @param accountId The account ID to retrieve the communication topics for\n * @param disableCache Whether to disable caching of the result\n * @returns {TopicInfo} Topic Info from target profile.\n */\n public async retrieveCommunicationTopics(\n accountId: string,\n disableCache?: boolean\n ): Promise<TopicInfo> {\n try {\n const profileResponse = await this.retrieveProfile(\n accountId,\n disableCache\n );\n\n if (!profileResponse?.success) {\n throw new Error(profileResponse.error || 'Failed to retrieve profile');\n }\n\n const profile = profileResponse.profile;\n\n if (!profile.inboundTopicId || !profile.outboundTopicId) {\n throw new Error(\n `Invalid HCS-11 profile for HCS-10 agent: missing inboundTopicId or outboundTopicId`\n );\n }\n\n if (!profileResponse.topicInfo) {\n throw new Error(\n `TopicInfo is missing in the profile for account ${accountId}`\n );\n }\n\n return profileResponse.topicInfo;\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Failed to retrieve topic info: ${error.message}`;\n this.logger.error(logMessage);\n throw error;\n }\n }\n\n /**\n * Retrieves outbound messages for an agent\n * @param agentAccountId The account ID of the agent\n * @returns The outbound messages\n */\n public async retrieveOutboundMessages(\n agentAccountId: string\n ): Promise<HCSMessage[]> {\n try {\n const topicInfo = await this.retrieveCommunicationTopics(agentAccountId);\n if (!topicInfo) {\n this.logger.warn(\n `No outbound connect topic found for agentAccountId: ${agentAccountId}`\n );\n return [];\n }\n const response = await this.getMessages(topicInfo.outboundTopic);\n return response.messages.filter(\n (msg) =>\n msg.p === 'hcs-10' &&\n (msg.op === 'connection_request' ||\n msg.op === 'connection_created' ||\n msg.op === 'message')\n );\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Failed to retrieve outbound messages: ${error.message}`;\n this.logger.error(logMessage);\n return [];\n }\n }\n\n /**\n * Checks if a connection has been created for an agent\n * @param agentAccountId The account ID of the agent\n * @param connectionId The ID of the connection\n * @returns True if the connection has been created, false otherwise\n */\n public async hasConnectionCreated(\n agentAccountId: string,\n connectionId: number\n ): Promise<boolean> {\n try {\n const outBoundTopic = await this.retrieveCommunicationTopics(\n agentAccountId\n );\n const messages = await this.retrieveOutboundMessages(\n outBoundTopic.outboundTopic\n );\n return messages.some(\n (msg) =>\n msg.op === 'connection_created' && msg.connection_id === connectionId\n );\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Failed to check connection created: ${error.message}`;\n this.logger.error(logMessage);\n return false;\n }\n }\n\n /**\n * Gets message content, resolving any HRL references if needed\n * @param data The data string that may contain an HRL reference\n * @param forceRaw Whether to force returning raw binary data\n * @returns The resolved content\n */\n async getMessageContent(\n data: string,\n forceRaw = false\n ): Promise<string | ArrayBuffer> {\n if (!data.match(/^hcs:\\/\\/(\\d+)\\/([0-9]+\\.[0-9]+\\.[0-9]+)$/)) {\n return data;\n }\n\n try {\n const resolver = new HRLResolver(this.logger.getLevel());\n\n if (!resolver.isValidHRL(data)) {\n return data;\n }\n\n const result = await resolver.resolveHRL(data, {\n network: this.network as 'mainnet' | 'testnet',\n returnRaw: forceRaw,\n });\n\n return result.content;\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Error resolving HRL reference: ${error.message}`;\n this.logger.error(logMessage);\n throw new Error(logMessage);\n }\n }\n\n /**\n * Gets message content with its content type, resolving any HRL references if needed\n * @param data The data string that may contain an HRL reference\n * @param forceRaw Whether to force returning raw binary data\n * @returns The resolved content along with content type information\n */\n async getMessageContentWithType(\n data: string,\n forceRaw = false\n ): Promise<{\n content: string | ArrayBuffer;\n contentType: string;\n isBinary: boolean;\n }> {\n if (!data.match(/^hcs:\\/\\/(\\d+)\\/([0-9]+\\.[0-9]+\\.[0-9]+)$/)) {\n return {\n content: data,\n contentType: 'text/plain',\n isBinary: false,\n };\n }\n\n try {\n const resolver = new HRLResolver(this.logger.getLevel());\n\n return await resolver.getContentWithType(data, {\n network: this.network as 'mainnet' | 'testnet',\n returnRaw: forceRaw,\n });\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Error resolving HRL reference with type: ${error.message}`;\n this.logger.error(logMessage);\n throw new Error(logMessage);\n }\n }\n\n /**\n * Submits a connection request to an inbound topic\n * @param inboundTopicId The ID of the inbound topic\n * @param memo An optional memo for the message\n * @returns The transaction receipt\n */\n async submitConnectionRequest(\n inboundTopicId: string,\n memo: string\n ): Promise<TransactionReceipt> {\n const accountResponse = this.getAccountAndSigner();\n if (!accountResponse?.accountId) {\n throw new Error('Operator account ID is not set');\n }\n const operatorId = await this.getOperatorId();\n const accountId = accountResponse.accountId;\n\n const submissionCheck = await this.canSubmitToTopic(\n inboundTopicId,\n accountId\n );\n\n if (!submissionCheck?.canSubmit) {\n throw new Error(`Cannot submit to topic: ${submissionCheck.reason}`);\n }\n\n const inboundAccountOwner = await this.retrieveInboundAccountId(\n inboundTopicId\n );\n\n if (!inboundAccountOwner) {\n throw new Error('Failed to retrieve topic info account ID');\n }\n\n const connectionRequestMessage = {\n p: 'hcs-10',\n op: 'connection_request',\n operator_id: operatorId,\n m: memo,\n };\n\n const requiresFee = submissionCheck.requiresFee;\n const response = await this.submitPayload(\n inboundTopicId,\n connectionRequestMessage,\n undefined,\n requiresFee\n );\n\n this.logger.info(\n `Submitted connection request to topic ID: ${inboundTopicId}`\n );\n\n const outboundTopic = await this.retrieveCommunicationTopics(accountId);\n\n if (!outboundTopic) {\n throw new Error('Failed to retrieve outbound topic');\n }\n\n const responseSequenceNumber = response.topicSequenceNumber?.toNumber();\n\n if (!responseSequenceNumber) {\n throw new Error('Failed to get response sequence number');\n }\n\n const requestorOperatorId = `${inboundTopicId}@${inboundAccountOwner}`;\n\n await this.submitPayload(outboundTopic.outboundTopic, {\n ...connectionRequestMessage,\n outbound_topic_id: outboundTopic.outboundTopic,\n connection_request_id: responseSequenceNumber,\n operator_id: requestorOperatorId,\n });\n\n return response;\n }\n\n /**\n * Records an outbound connection confirmation\n * @param outboundTopicId The ID of the outbound topic\n * @param connectionRequestId The ID of the connection request\n * @param confirmedRequestId The ID of the confirmed request\n * @param connectionTopicId The ID of the connection topic\n * @param operatorId The operator ID of the original message sender.\n * @param memo An optional memo for the message\n */\n public async recordOutboundConnectionConfirmation({\n outboundTopicId,\n requestorOutboundTopicId,\n connectionRequestId,\n confirmedRequestId,\n connectionTopicId,\n operatorId,\n memo,\n }: {\n outboundTopicId: string;\n requestorOutboundTopicId: string;\n connectionRequestId: number;\n confirmedRequestId: number;\n connectionTopicId: string;\n operatorId: string;\n memo: string;\n }): Promise<TransactionReceipt> {\n const payload = {\n p: 'hcs-10',\n op: 'connection_created',\n connection_topic_id: connectionTopicId,\n outbound_topic_id: outboundTopicId,\n requestor_outbound_topic_id: requestorOutboundTopicId,\n confirmed_request_id: confirmedRequestId,\n connection_request_id: connectionRequestId,\n operator_id: operatorId,\n m: memo,\n };\n return await this.submitPayload(outboundTopicId, payload);\n }\n\n /**\n * Waits for confirmation of a connection request\n * @param inboundTopicId Inbound topic ID\n * @param connectionRequestId Connection request ID\n * @param maxAttempts Maximum number of attempts\n * @param delayMs Delay between attempts in milliseconds\n * @returns Connection confirmation details\n */\n async waitForConnectionConfirmation(\n inboundTopicId: string,\n connectionRequestId: number,\n maxAttempts = 60,\n delayMs = 2000,\n recordConfirmation = true\n ): Promise<WaitForConnectionConfirmationResponse> {\n this.logger.info(\n `Waiting for connection confirmation on inbound topic ${inboundTopicId} for request ID ${connectionRequestId}`\n );\n\n for (let attempt = 0; attempt < maxAttempts; attempt++) {\n this.logger.info(\n `Attempt ${attempt + 1}/${maxAttempts} to find connection confirmation`\n );\n const messages = await this.mirrorNode.getTopicMessages(inboundTopicId);\n\n const connectionCreatedMessages = messages.filter(\n (m) => m.op === 'connection_created'\n );\n\n this.logger.info(\n `Found ${connectionCreatedMessages.length} connection_created messages`\n );\n\n if (connectionCreatedMessages.length > 0) {\n for (const message of connectionCreatedMessages) {\n if (Number(message.connection_id) === Number(connectionRequestId)) {\n const confirmationResult = {\n connectionTopicId: message.connection_topic_id,\n sequence_number: Number(message.sequence_number),\n confirmedBy: message.operator_id,\n memo: message.m,\n };\n\n const confirmedByAccountId = this.extractAccountFromOperatorId(\n confirmationResult.confirmedBy\n );\n\n const account = this.getAccountAndSigner();\n const confirmedByConnectionTopics =\n await this.retrieveCommunicationTopics(confirmedByAccountId);\n\n const agentConnectionTopics =\n await this.retrieveCommunicationTopics(account.accountId);\n\n this.logger.info(\n 'Connection confirmation found',\n confirmationResult\n );\n\n if (recordConfirmation) {\n /**\n * Record's the confirmation of the connection request from the\n * confirmedBy account to the agent account.\n */\n await this.recordOutboundConnectionConfirmation({\n requestorOutboundTopicId:\n confirmedByConnectionTopics.outboundTopic,\n outboundTopicId: agentConnectionTopics.outboundTopic,\n connectionRequestId,\n confirmedRequestId: confirmationResult.sequence_number,\n connectionTopicId: confirmationResult.connectionTopicId,\n operatorId: confirmationResult.confirmedBy,\n memo: confirmationResult.memo || 'Connection confirmed',\n });\n }\n\n return confirmationResult;\n }\n }\n }\n\n if (attempt < maxAttempts - 1) {\n this.logger.info(\n `No matching confirmation found, waiting ${delayMs}ms before retrying...`\n );\n await new Promise((resolve) => setTimeout(resolve, delayMs));\n }\n }\n\n throw new Error(\n `Connection confirmation not found after ${maxAttempts} attempts for request ID ${connectionRequestId}`\n );\n }\n\n /**\n * Retrieves the operator ID for the current agent\n * @param disableCache Whether to disable caching of the result\n * @returns The operator ID\n */\n public async getOperatorId(disableCache?: boolean): Promise<string> {\n if (this.operatorId && !disableCache) {\n return this.operatorId;\n }\n\n const accountResponse = this.getAccountAndSigner();\n\n if (!accountResponse.accountId) {\n throw new Error('Operator ID not found');\n }\n\n const profile = await this.retrieveProfile(accountResponse.accountId);\n\n if (!profile.success) {\n throw new Error('Failed to retrieve profile');\n }\n\n const operatorId = `${profile.topicInfo?.inboundTopic}@${accountResponse.accountId}`;\n this.operatorId = operatorId;\n return operatorId;\n }\n\n /**\n * Retrieves the account ID of the owner of an inbound topic\n * @param inboundTopicId The ID of the inbound topic\n * @returns The account ID of the owner of the inbound topic\n */\n public async retrieveInboundAccountId(\n inboundTopicId: string\n ): Promise<string> {\n const topicInfo = await this.mirrorNode.getTopicInfo(inboundTopicId);\n\n if (!topicInfo?.memo) {\n throw new Error('Failed to retrieve topic info');\n }\n\n const topicInfoMemo = topicInfo.memo.toString();\n const topicInfoParts = topicInfoMemo.split(':');\n const inboundAccountOwner = topicInfoParts?.[4];\n\n if (!inboundAccountOwner) {\n throw new Error('Failed to retrieve topic info account ID');\n }\n\n return inboundAccountOwner;\n }\n\n public clearCache(): void {\n HCS10Cache.getInstance().clear();\n }\n\n /**\n * Generates a standard HCS-10 memo string.\n * @param type The type of topic memo ('inbound', 'outbound', 'connection').\n * @param options Configuration options for the memo.\n * @returns The formatted memo string.\n * @protected\n */\n protected _generateHcs10Memo(\n type: Hcs10MemoType,\n options: {\n ttl?: number;\n accountId?: string;\n inboundTopicId?: string;\n connectionId?: number;\n }\n ): string {\n const ttl = options.ttl ?? 60;\n\n switch (type) {\n case Hcs10MemoType.INBOUND:\n if (!options.accountId) {\n throw new Error('accountId is required for inbound memo');\n }\n return `hcs-10:0:${ttl}:0:${options.accountId}`;\n case Hcs10MemoType.OUTBOUND:\n return `hcs-10:0:${ttl}:1`;\n case Hcs10MemoType.CONNECTION:\n if (!options.inboundTopicId || options.connectionId === undefined) {\n throw new Error(\n 'inboundTopicId and connectionId are required for connection memo'\n );\n }\n return `hcs-10:1:${ttl}:2:${options.inboundTopicId}:${options.connectionId}`;\n default:\n throw new Error(`Invalid HCS-10 memo type: ${type}`);\n }\n }\n\n protected async checkRegistrationStatus(\n transactionId: string,\n network: string,\n baseUrl: string\n ): Promise<{ status: 'pending' | 'success' | 'failed' }> {\n try {\n const response = await fetch(`${baseUrl}/api/request-confirm`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'X-Network': network,\n },\n body: JSON.stringify({ transaction_id: transactionId }),\n });\n\n if (!response.ok) {\n throw new Error(\n `Failed to confirm registration: ${response.statusText}`\n );\n }\n\n return await response.json();\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Error checking registration status: ${error.message}`;\n this.logger.error(logMessage);\n throw error;\n }\n }\n\n /**\n * Validates if an operator_id follows the correct format (agentTopicId@accountId)\n * @param operatorId The operator ID to validate\n * @returns True if the format is valid, false otherwise\n */\n protected isValidOperatorId(operatorId: string): boolean {\n if (!operatorId) {\n return false;\n }\n\n const parts = operatorId.split('@');\n\n if (parts.length !== 2) {\n return false;\n }\n\n const agentTopicId = parts[0];\n const accountId = parts[1];\n\n if (!agentTopicId) {\n return false;\n }\n\n if (!accountId) {\n return false;\n }\n\n const hederaIdPattern = /^[0-9]+\\.[0-9]+\\.[0-9]+$/;\n\n if (!hederaIdPattern.test(accountId)) {\n return false;\n }\n\n if (!hederaIdPattern.test(agentTopicId)) {\n return false;\n }\n\n return true;\n }\n\n /**\n * Retrieves all transaction requests from a topic\n * @param topicId The topic ID to retrieve transactions from\n * @param limit Optional maximum number of messages to retrieve\n * @returns Array of transaction requests sorted by timestamp (newest first)\n */\n public async getTransactionRequests(\n topicId: string,\n limit?: number\n ): Promise<TransactMessage[]> {\n this.logger.debug(`Retrieving transaction requests from topic ${topicId}`);\n\n const { messages } = await this.getMessageStream(topicId);\n\n const transactOperations = (\n messages\n .filter((m) => m.op === 'transaction' && m.schedule_id)\n .map((m) => ({\n operator_id: m.operator_id || '',\n schedule_id: m.schedule_id || '',\n data: m.data || '',\n memo: m.m,\n sequence_number: Number(m.sequence_number),\n })) as unknown as TransactMessage[]\n ).sort((a, b) => {\n if (a.sequence_number && b.sequence_number) {\n return b.sequence_number - a.sequence_number;\n }\n return 0;\n });\n\n const result = limit\n ? transactOperations.slice(0, limit)\n : transactOperations;\n\n return result;\n }\n}\n\nexport class HCS10Cache {\n private static instance: HCS10Cache;\n private cache: Map<string, ProfileResponse>;\n private cacheExpiry: Map<string, number>;\n private readonly CACHE_TTL = 3600000;\n\n private constructor() {\n this.cache = new Map();\n this.cacheExpiry = new Map();\n }\n\n static getInstance(): HCS10Cache {\n if (!HCS10Cache.instance) {\n HCS10Cache.instance = new HCS10Cache();\n }\n return HCS10Cache.instance;\n }\n\n set(key: string, value: ProfileResponse): void {\n this.cache.set(key, value);\n this.cacheExpiry.set(key, Date.now() + this.CACHE_TTL);\n }\n\n get(key: string): ProfileResponse | undefined {\n const expiry = this.cacheExpiry.get(key);\n if (expiry && expiry > Date.now()) {\n return this.cache.get(key);\n }\n if (expiry) {\n this.cache.delete(key);\n this.cacheExpiry.delete(key);\n }\n return undefined;\n }\n\n clear(): void {\n this.cache.clear();\n this.cacheExpiry.clear();\n }\n}\n"],"names":["Hcs10MemoType"],"mappings":";;;;;;AAmBY,IAAA,kCAAAA,mBAAL;AACLA,iBAAA,SAAU,IAAA;AACVA,iBAAA,UAAW,IAAA;AACXA,iBAAA,YAAa,IAAA;AAHHA,SAAAA;AAAA,GAAA,iBAAA,CAAA,CAAA;AAuFL,MAAe,wBAAwB,aAAa;AAAA,EAQzD,YAAY,QAAqB;AACzB,UAAA;AACN,SAAK,UAAU,OAAO;AACjB,SAAA,SAAS,OAAO,YAAY;AAAA,MAC/B,OAAO,OAAO,YAAY;AAAA,MAC1B,QAAQ;AAAA,MACR,aAAa,OAAO;AAAA,IAAA,CACrB;AACD,SAAK,aAAa,IAAI;AAAA,MACpB,OAAO;AAAA,MACP,KAAK;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B,aAAA;AAAA,IAAA,CACR;AAED,UAAM,SAAS,QACX,mBAAmB,MAAM,GAAG,KAAK,IACjC;AAEG,WAAA;AAAA,EAAA;AAEX;AAEO,MAAM,WAAW;AAAA,EAMd,cAAc;AAFtB,SAAiB,YAAY;AAGtB,SAAA,4BAAY,IAAI;AAChB,SAAA,kCAAkB,IAAI;AAAA,EAAA;AAAA,EAG7B,OAAO,cAA0B;AAC3B,QAAA,CAAC,WAAW,UAAU;AACb,iBAAA,WAAW,IAAI,WAAW;AAAA,IAAA;AAEvC,WAAO,WAAW;AAAA,EAAA;AAAA,EAGpB,IAAI,KAAa,OAA8B;AACxC,SAAA,MAAM,IAAI,KAAK,KAAK;AACzB,SAAK,YAAY,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,SAAS;AAAA,EAAA;AAAA,EAGvD,IAAI,KAA0C;AAC5C,UAAM,SAAS,KAAK,YAAY,IAAI,GAAG;AACvC,QAAI,UAAU,SAAS,KAAK,IAAA,GAAO;AAC1B,aAAA,KAAK,MAAM,IAAI,GAAG;AAAA,IAAA;AAE3B,QAAI,QAAQ;AACL,WAAA,MAAM,OAAO,GAAG;AAChB,WAAA,YAAY,OAAO,GAAG;AAAA,IAAA;AAEtB,WAAA;AAAA,EAAA;AAAA,EAGT,QAAc;AACZ,SAAK,MAAM,MAAM;AACjB,SAAK,YAAY,MAAM;AAAA,EAAA;AAE3B;"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import Buffer from "vite-plugin-node-polyfills/shims/buffer";
|
|
2
1
|
import { Client, PrivateKey, AccountCreateTransaction, Hbar, CustomFixedFee, AccountId, TokenId, KeyList, TopicCreateTransaction, PublicKey, TopicMessageSubmitTransaction, TopicId, Transaction, ScheduleCreateTransaction, Timestamp } from "@hashgraph/sdk";
|
|
3
2
|
import { AccountCreationError, TopicCreationError, ConnectionConfirmationError, PayloadSizeError } from "./standards-sdk.es6.js";
|
|
4
3
|
import { I as InscriptionSDK } from "./standards-sdk.es24.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-sdk.es7.js","sources":["../../src/hcs-10/sdk.ts"],"sourcesContent":["import {\n Client,\n AccountCreateTransaction,\n PrivateKey,\n Hbar,\n KeyList,\n TopicCreateTransaction,\n TopicMessageSubmitTransaction,\n TopicId,\n Transaction,\n TransactionResponse,\n TransactionReceipt,\n PublicKey,\n AccountId,\n CustomFixedFee,\n TokenId,\n ScheduleCreateTransaction,\n Timestamp,\n} from '@hashgraph/sdk';\nimport {\n PayloadSizeError,\n AccountCreationError,\n TopicCreationError,\n ConnectionConfirmationError,\n} from './errors';\nimport {\n InscriptionSDK,\n RetrievedInscriptionResult,\n} from '@kiloscribe/inscription-sdk';\nimport { Logger, LogLevel } from '../utils/logger';\nimport { HCS10BaseClient } from './base-client';\nimport * as mime from 'mime-types';\nimport {\n HCSClientConfig,\n CreateAccountResponse,\n CreateAgentResponse,\n StoreHCS11ProfileResponse,\n AgentRegistrationResult,\n HandleConnectionRequestResponse,\n WaitForConnectionConfirmationResponse,\n GetAccountAndSignerResponse,\n AgentCreationState,\n RegistrationProgressCallback,\n InscribePfpResponse,\n} from './types';\nimport { MirrorNodeConfig } from '../services';\nimport {\n HCS11Client,\n AgentMetadata as HCS11AgentMetadata,\n SocialLink,\n SocialPlatform,\n InboundTopicType,\n AgentMetadata,\n} from '../hcs-11';\nimport { FeeConfigBuilderInterface, TopicFeeConfig } from '../fees';\nimport { TopicResponse } from '../services/types';\nimport { accountIdsToExemptKeys } from '../utils/topic-fee-utils';\nimport { Hcs10MemoType } from './base-client';\nimport { AgentBuilder } from '../hcs-11/agent-builder';\nimport { inscribe } from '../inscribe/inscriber';\nimport { TokenFeeConfig } from '../fees/types';\nimport { addSeconds } from 'date-fns';\n\nexport class HCS10Client extends HCS10BaseClient {\n private client: Client;\n private operatorPrivateKey: PrivateKey;\n protected declare network: string;\n protected declare logger: Logger;\n protected guardedRegistryBaseUrl: string;\n private hcs11Client: HCS11Client;\n\n constructor(config: HCSClientConfig) {\n super({\n network: config.network,\n logLevel: config.logLevel,\n prettyPrint: config.prettyPrint,\n feeAmount: config.feeAmount,\n mirrorNode: config.mirrorNode,\n });\n this.client =\n config.network === 'mainnet' ? Client.forMainnet() : Client.forTestnet();\n this.operatorPrivateKey = PrivateKey.fromString(config.operatorPrivateKey);\n this.network = config.network;\n this.client.setOperator(\n config.operatorId,\n this.operatorPrivateKey.toString()\n );\n this.logger = Logger.getInstance({\n level: config.logLevel || 'info',\n module: 'HCS-SDK',\n });\n this.guardedRegistryBaseUrl =\n config.guardedRegistryBaseUrl || 'https://moonscape.tech';\n\n this.hcs11Client = new HCS11Client({\n network: config.network,\n auth: {\n operatorId: config.operatorId,\n privateKey: config.operatorPrivateKey,\n },\n logLevel: config.logLevel,\n });\n }\n\n public getClient() {\n return this.client;\n }\n\n /**\n * Creates a new Hedera account\n * @param initialBalance Optional initial balance in HBAR (default: 50)\n * @returns Object with account ID and private key\n */\n async createAccount(\n initialBalance: number = 50\n ): Promise<CreateAccountResponse> {\n this.logger.info(\n `Creating new account with ${initialBalance} HBAR initial balance`\n );\n const newKey = PrivateKey.generate();\n\n const accountTransaction = new AccountCreateTransaction()\n .setKey(newKey.publicKey)\n .setInitialBalance(new Hbar(initialBalance));\n\n this.logger.debug('Executing account creation transaction');\n const accountResponse = await accountTransaction.execute(this.client);\n const accountReceipt = await accountResponse.getReceipt(this.client);\n const newAccountId = accountReceipt.accountId;\n\n if (!newAccountId) {\n this.logger.error('Account creation failed: accountId is null');\n throw new AccountCreationError(\n 'Failed to create account: accountId is null'\n );\n }\n\n this.logger.info(\n `Account created successfully: ${newAccountId.toString()}`\n );\n return {\n accountId: newAccountId.toString(),\n privateKey: newKey.toString(),\n };\n }\n\n /**\n * Creates an inbound topic for an agent\n * @param accountId The account ID associated with the inbound topic\n * @param topicType Type of inbound topic (public, controlled, or fee-based)\n * @param ttl Optional Time-To-Live for the topic memo, defaults to 60\n * @param feeConfigBuilder Optional fee configuration builder for fee-based topics\n * @returns The topic ID of the created inbound topic\n */\n async createInboundTopic(\n accountId: string,\n topicType: InboundTopicType,\n ttl: number = 60,\n feeConfigBuilder?: FeeConfigBuilderInterface\n ): Promise<string> {\n const memo = this._generateHcs10Memo(Hcs10MemoType.INBOUND, {\n accountId,\n ttl,\n });\n\n let submitKey: boolean | PublicKey | KeyList | undefined;\n let finalFeeConfig: TopicFeeConfig | undefined;\n\n switch (topicType) {\n case InboundTopicType.PUBLIC:\n submitKey = false;\n break;\n case InboundTopicType.CONTROLLED:\n submitKey = true;\n break;\n case InboundTopicType.FEE_BASED:\n submitKey = false;\n if (!feeConfigBuilder) {\n throw new Error(\n 'Fee configuration builder is required for fee-based topics'\n );\n }\n\n const internalFees = (feeConfigBuilder as any)\n .customFees as TokenFeeConfig[];\n internalFees.forEach((fee) => {\n if (!fee.feeCollectorAccountId) {\n this.logger.debug(\n `Defaulting fee collector for token ${\n fee.feeTokenId || 'HBAR'\n } to agent ${accountId}`\n );\n fee.feeCollectorAccountId = accountId;\n }\n });\n\n finalFeeConfig = feeConfigBuilder.build();\n break;\n default:\n throw new Error(`Unsupported inbound topic type: ${topicType}`);\n }\n\n return this.createTopic(memo, true, submitKey, finalFeeConfig);\n }\n\n /**\n * Creates a new agent with inbound and outbound topics\n * @param builder The agent builder object\n * @param ttl Optional Time-To-Live for the topic memos, defaults to 60\n * @returns Object with topic IDs\n */\n async createAgent(\n builder: AgentBuilder,\n ttl: number = 60\n ): Promise<CreateAgentResponse> {\n const config = builder.build();\n const outboundMemo = this._generateHcs10Memo(Hcs10MemoType.OUTBOUND, {\n ttl,\n });\n const outboundTopicId = await this.createTopic(outboundMemo, true, true);\n this.logger.info(`Created new outbound topic ID: ${outboundTopicId}`);\n\n const accountId = this.client.operatorAccountId?.toString();\n if (!accountId) {\n throw new Error('Failed to retrieve operator account ID');\n }\n\n const inboundTopicId = await this.createInboundTopic(\n accountId,\n config.inboundTopicType,\n ttl,\n config.inboundTopicType === InboundTopicType.FEE_BASED\n ? config.feeConfig\n : undefined\n );\n\n let pfpTopicId = config.existingPfpTopicId || '';\n\n if (!pfpTopicId && config.pfpBuffer && config.pfpBuffer.length > 0) {\n this.logger.info('Inscribing new profile picture');\n const pfpResult = await this.inscribePfp(\n config.pfpBuffer,\n config.pfpFileName\n );\n pfpTopicId = pfpResult.pfpTopicId;\n this.logger.info(\n `Profile picture inscribed with topic ID: ${pfpTopicId}`\n );\n } else if (config.existingPfpTopicId) {\n this.logger.info(\n `Using existing profile picture with topic ID: ${config.existingPfpTopicId}`\n );\n }\n\n const profileResult = await this.storeHCS11Profile(\n config.name,\n config.bio,\n inboundTopicId,\n outboundTopicId,\n config.capabilities,\n config.metadata,\n config.pfpBuffer && config.pfpBuffer.length > 0\n ? config.pfpBuffer\n : undefined,\n config.pfpFileName,\n config.existingPfpTopicId\n );\n const profileTopicId = profileResult.profileTopicId;\n this.logger.info(`Profile stored with topic ID: ${profileTopicId}`);\n\n return {\n inboundTopicId,\n outboundTopicId,\n pfpTopicId,\n profileTopicId,\n };\n }\n\n /**\n * Inscribes a profile picture to Hedera\n * @param buffer Profile picture buffer\n * @param fileName Filename\n * @returns Response with topic ID and transaction ID\n */\n async inscribePfp(\n buffer: Buffer,\n fileName: string\n ): Promise<InscribePfpResponse> {\n try {\n this.logger.info('Inscribing profile picture using HCS-11 client');\n\n const imageResult = await this.hcs11Client.inscribeImage(\n buffer,\n fileName\n );\n\n if (!imageResult.success) {\n this.logger.error(\n `Failed to inscribe profile picture: ${imageResult.error}`\n );\n throw new Error(\n imageResult?.error || 'Failed to inscribe profile picture'\n );\n }\n\n this.logger.info(\n `Successfully inscribed profile picture with topic ID: ${imageResult.imageTopicId}`\n );\n return {\n pfpTopicId: imageResult.imageTopicId,\n transactionId: imageResult.transactionId,\n success: true,\n };\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Error inscribing profile picture: ${error.message}`;\n this.logger.error(logMessage);\n return {\n pfpTopicId: '',\n transactionId: '',\n success: false,\n error: error.message,\n };\n }\n }\n\n /**\n * Stores an HCS-11 profile for an agent\n * @param agentName Agent name\n * @param agentBio Agent description\n * @param inboundTopicId Inbound topic ID\n * @param outboundTopicId Outbound topic ID\n * @param capabilities Agent capability tags\n * @param metadata Additional metadata\n * @param pfpBuffer Optional profile picture buffer\n * @param pfpFileName Optional profile picture filename\n * @returns Response with topic IDs and transaction ID\n */\n async storeHCS11Profile(\n agentName: string,\n agentBio: string,\n inboundTopicId: string,\n outboundTopicId: string,\n capabilities: number[] = [],\n metadata: AgentMetadata,\n pfpBuffer?: Buffer,\n pfpFileName?: string,\n existingPfpTopicId?: string\n ): Promise<StoreHCS11ProfileResponse> {\n try {\n let pfpTopicId = existingPfpTopicId || '';\n\n if (!pfpTopicId && pfpBuffer && pfpFileName) {\n this.logger.info('Inscribing profile picture for HCS-11 profile');\n const pfpResult = await this.inscribePfp(pfpBuffer, pfpFileName);\n if (!pfpResult.success) {\n this.logger.warn(\n `Failed to inscribe profile picture: ${pfpResult.error}, proceeding without pfp`\n );\n } else {\n pfpTopicId = pfpResult.pfpTopicId;\n }\n } else if (existingPfpTopicId) {\n this.logger.info(\n `Using existing profile picture with topic ID: ${existingPfpTopicId} for HCS-11 profile`\n );\n pfpTopicId = existingPfpTopicId;\n }\n\n const agentType = this.hcs11Client.getAgentTypeFromMetadata({\n type: metadata.type || 'autonomous',\n } as HCS11AgentMetadata);\n\n const formattedSocials: SocialLink[] | undefined = metadata.socials\n ? (Object.entries(metadata.socials)\n .filter(([_, handle]) => handle)\n .map(([platform, handle]) => ({\n platform: platform as SocialPlatform,\n handle: handle as string,\n })) as SocialLink[])\n : undefined;\n\n const profile = this.hcs11Client.createAIAgentProfile(\n agentName,\n agentType,\n capabilities,\n metadata.model || 'unknown',\n {\n alias: agentName.toLowerCase().replace(/\\s+/g, '_'),\n bio: agentBio,\n profileImage: pfpTopicId ? `hcs://1/${pfpTopicId}` : undefined,\n socials: formattedSocials,\n properties: metadata.properties,\n inboundTopicId,\n outboundTopicId,\n creator: metadata.creator,\n }\n );\n\n const profileResult = await this.hcs11Client.createAndInscribeProfile(\n profile,\n true\n );\n\n if (!profileResult.success) {\n this.logger.error(`Failed to inscribe profile: ${profileResult.error}`);\n throw new Error(profileResult.error || 'Failed to inscribe profile');\n }\n\n this.logger.info(\n `Profile inscribed with topic ID: ${profileResult.profileTopicId}, transaction ID: ${profileResult.transactionId}`\n );\n\n return {\n profileTopicId: profileResult.profileTopicId,\n pfpTopicId,\n transactionId: profileResult.transactionId,\n success: true,\n };\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Error storing HCS-11 profile: ${error.message}`;\n this.logger.error(logMessage);\n return {\n profileTopicId: '',\n pfpTopicId: '',\n transactionId: '',\n success: false,\n error: error.message,\n };\n }\n }\n\n private async setupFees(\n transaction: TopicCreateTransaction,\n feeConfig: TopicFeeConfig,\n additionalExemptAccounts: string[] = []\n ): Promise<TopicCreateTransaction> {\n let modifiedTransaction = transaction;\n if (!this.client.operatorPublicKey) {\n return modifiedTransaction;\n }\n\n if (!feeConfig.customFees || feeConfig.customFees.length === 0) {\n this.logger.warn('No custom fees provided in fee config for setupFees');\n return modifiedTransaction;\n }\n\n if (feeConfig.customFees.length > 10) {\n this.logger.warn(\n 'More than 10 custom fees provided, only the first 10 will be used'\n );\n feeConfig.customFees = feeConfig.customFees.slice(0, 10);\n }\n\n const customFees = feeConfig.customFees\n .map((fee) => {\n if (!fee.feeCollectorAccountId) {\n this.logger.error(\n 'Internal Error: Fee collector ID missing in setupFees'\n );\n return null;\n }\n if (fee.type === 'FIXED_FEE') {\n const customFee = new CustomFixedFee()\n .setAmount(Number(fee.feeAmount.amount))\n .setFeeCollectorAccountId(\n AccountId.fromString(fee.feeCollectorAccountId)\n );\n\n if (fee.feeTokenId) {\n customFee.setDenominatingTokenId(\n TokenId.fromString(fee.feeTokenId)\n );\n }\n\n return customFee;\n }\n return null;\n })\n .filter(Boolean) as CustomFixedFee[];\n\n if (customFees.length === 0) {\n this.logger.warn('No valid custom fees to apply in setupFees');\n return modifiedTransaction;\n }\n\n const exemptAccountIds = [\n ...(feeConfig.exemptAccounts || []),\n ...additionalExemptAccounts,\n ];\n\n if (exemptAccountIds.length > 0) {\n modifiedTransaction = await this.setupExemptKeys(\n transaction,\n exemptAccountIds\n );\n }\n\n return modifiedTransaction\n .setFeeScheduleKey(this.client.operatorPublicKey)\n .setCustomFees(customFees);\n }\n\n private async setupExemptKeys(\n transaction: TopicCreateTransaction,\n exemptAccountIds: string[]\n ): Promise<TopicCreateTransaction> {\n let modifiedTransaction = transaction;\n const uniqueExemptAccountIds = Array.from(new Set(exemptAccountIds));\n const filteredExemptAccounts = uniqueExemptAccountIds.filter(\n (account) => account !== this.client.operatorAccountId?.toString()\n );\n\n let exemptKeys: PublicKey[] = [];\n if (filteredExemptAccounts.length > 0) {\n try {\n exemptKeys = await accountIdsToExemptKeys(\n filteredExemptAccounts,\n this.network,\n this.logger\n );\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Error getting exempt keys: ${error.message}, continuing without exempt keys`;\n this.logger.warn(logMessage);\n }\n }\n\n if (exemptKeys.length > 0) {\n modifiedTransaction = modifiedTransaction.setFeeExemptKeys(exemptKeys);\n }\n\n return modifiedTransaction;\n }\n\n /**\n * Handles a connection request from another account\n * @param inboundTopicId Inbound topic ID of your agent\n * @param requestingAccountId Requesting account ID\n * @param connectionRequestId Connection request ID\n * @param connectionFeeConfig Optional fee configuration for the connection topic\n * @param ttl Optional ttl parameter with default\n * @returns Response with connection details\n */\n async handleConnectionRequest(\n inboundTopicId: string,\n requestingAccountId: string,\n connectionRequestId: number,\n connectionFeeConfig?: FeeConfigBuilderInterface,\n ttl: number = 60\n ): Promise<HandleConnectionRequestResponse> {\n const memo = this._generateHcs10Memo(Hcs10MemoType.CONNECTION, {\n ttl,\n inboundTopicId,\n connectionId: connectionRequestId,\n });\n this.logger.info(\n `Handling connection request ${connectionRequestId} from ${requestingAccountId}`\n );\n\n const accountId = this.getClient().operatorAccountId?.toString();\n if (!accountId) {\n throw new Error('Failed to retrieve operator account ID');\n }\n\n let requesterKey = await this.mirrorNode.getPublicKey(requestingAccountId);\n const accountKey = await this.mirrorNode.getPublicKey(accountId);\n\n if (!accountKey) {\n throw new Error('Failed to retrieve public key');\n }\n\n const thresholdKey = new KeyList([accountKey, requesterKey], 1);\n\n let connectionTopicId: string;\n\n try {\n if (connectionFeeConfig) {\n const feeConfig = connectionFeeConfig.build();\n const modifiedFeeConfig = {\n ...feeConfig,\n exemptAccounts: [...(feeConfig.exemptAccounts || [])],\n };\n\n connectionTopicId = await this.createTopic(\n memo,\n thresholdKey,\n thresholdKey,\n modifiedFeeConfig\n );\n } else {\n connectionTopicId = await this.createTopic(\n memo,\n thresholdKey,\n thresholdKey\n );\n }\n\n this.logger.info(`Created new connection topic ID: ${connectionTopicId}`);\n } catch (error) {\n const logMessage = `Failed to create connection topic: ${error}`;\n this.logger.error(logMessage);\n throw new TopicCreationError(logMessage);\n }\n\n const operatorId = `${inboundTopicId}@${accountId}`;\n\n const confirmedConnectionSequenceNumber = await this.confirmConnection(\n inboundTopicId,\n connectionTopicId,\n requestingAccountId,\n connectionRequestId,\n 'Connection accepted. Looking forward to collaborating!'\n );\n\n const accountTopics = await this.retrieveCommunicationTopics(accountId);\n\n const requestingAccountTopics = await this.retrieveCommunicationTopics(\n requestingAccountId\n );\n\n const requestingAccountOperatorId = `${requestingAccountTopics.inboundTopic}@${requestingAccountId}`;\n\n await this.recordOutboundConnectionConfirmation({\n outboundTopicId: accountTopics.outboundTopic,\n requestorOutboundTopicId: requestingAccountTopics.outboundTopic,\n connectionRequestId: connectionRequestId,\n confirmedRequestId: confirmedConnectionSequenceNumber,\n connectionTopicId,\n operatorId: requestingAccountOperatorId,\n memo: `Connection established with ${requestingAccountId}`,\n });\n\n return {\n connectionTopicId,\n confirmedConnectionSequenceNumber,\n operatorId,\n };\n }\n\n /**\n * Confirms a connection request from another account\n * @param inboundTopicId Inbound topic ID\n * @param connectionTopicId Connection topic ID\n * @param connectedAccountId Connected account ID\n * @param connectionId Connection ID\n * @param memo Memo for the connection request\n * @param submitKey Optional submit key\n * @returns Sequence number of the confirmed connection\n */\n async confirmConnection(\n inboundTopicId: string,\n connectionTopicId: string,\n connectedAccountId: string,\n connectionId: number,\n memo: string,\n submitKey?: PrivateKey\n ): Promise<number> {\n const operatorId = await this.getOperatorId();\n this.logger.info(`Confirming connection with ID ${connectionId}`);\n const payload = {\n p: 'hcs-10',\n op: 'connection_created',\n connection_topic_id: connectionTopicId,\n connected_account_id: connectedAccountId,\n operator_id: operatorId,\n connection_id: connectionId,\n m: memo,\n };\n\n const submissionCheck = await this.canSubmitToTopic(\n inboundTopicId,\n this.client.operatorAccountId?.toString() || ''\n );\n\n const result = await this.submitPayload(\n inboundTopicId,\n payload,\n submitKey,\n submissionCheck.requiresFee\n );\n\n const sequenceNumber = result.topicSequenceNumber?.toNumber();\n\n if (!sequenceNumber) {\n throw new ConnectionConfirmationError(\n 'Failed to confirm connection: sequence number is null'\n );\n }\n\n return sequenceNumber;\n }\n\n async sendMessage(\n connectionTopicId: string,\n data: string,\n memo?: string,\n submitKey?: PrivateKey,\n options?: {\n progressCallback?: RegistrationProgressCallback;\n waitMaxAttempts?: number;\n waitIntervalMs?: number;\n }\n ): Promise<TransactionReceipt> {\n const submissionCheck = await this.canSubmitToTopic(\n connectionTopicId,\n this.client.operatorAccountId?.toString() || ''\n );\n\n const operatorId = await this.getOperatorId();\n\n const payload = {\n p: 'hcs-10',\n op: 'message',\n operator_id: operatorId,\n data,\n m: memo,\n };\n\n const payloadString = JSON.stringify(payload);\n const isLargePayload = Buffer.from(payloadString).length > 1000;\n\n if (isLargePayload) {\n this.logger.info(\n 'Message payload exceeds 1000 bytes, storing via inscription'\n );\n try {\n const contentBuffer = Buffer.from(data);\n const fileName = `message-${Date.now()}.json`;\n const inscriptionResult = await this.inscribeFile(\n contentBuffer,\n fileName,\n {\n progressCallback: options?.progressCallback,\n waitMaxAttempts: options?.waitMaxAttempts,\n waitIntervalMs: options?.waitIntervalMs,\n }\n );\n\n if (inscriptionResult?.topic_id) {\n payload.data = `hcs://1/${inscriptionResult.topic_id}`;\n this.logger.info(\n `Large message inscribed with topic ID: ${inscriptionResult.topic_id}`\n );\n } else {\n throw new Error('Failed to inscribe large message content');\n }\n } catch (error: any) {\n const logMessage = `Error inscribing large message: ${error.message}`;\n this.logger.error(logMessage);\n throw new Error(logMessage);\n }\n }\n\n this.logger.info('Submitting message to connection topic', payload);\n return await this.submitPayload(\n connectionTopicId,\n payload,\n submitKey,\n submissionCheck.requiresFee\n );\n }\n\n async createTopic(\n memo: string,\n adminKey?: boolean | PublicKey | KeyList,\n submitKey?: boolean | PublicKey | KeyList,\n feeConfig?: TopicFeeConfig\n ): Promise<string> {\n this.logger.info('Creating topic');\n const transaction = new TopicCreateTransaction().setTopicMemo(memo);\n\n if (adminKey) {\n if (\n typeof adminKey === 'boolean' &&\n adminKey &&\n this.client.operatorPublicKey\n ) {\n transaction.setAdminKey(this.client.operatorPublicKey);\n transaction.setAutoRenewAccountId(this.client.operatorAccountId!);\n } else if (adminKey instanceof PublicKey || adminKey instanceof KeyList) {\n transaction.setAdminKey(adminKey);\n if (this.client.operatorAccountId) {\n transaction.setAutoRenewAccountId(this.client.operatorAccountId);\n }\n }\n }\n\n if (submitKey) {\n if (\n typeof submitKey === 'boolean' &&\n submitKey &&\n this.client.operatorPublicKey\n ) {\n transaction.setSubmitKey(this.client.operatorPublicKey);\n } else if (\n submitKey instanceof PublicKey ||\n submitKey instanceof KeyList\n ) {\n transaction.setSubmitKey(submitKey);\n }\n }\n\n if (feeConfig) {\n await this.setupFees(transaction, feeConfig);\n }\n\n this.logger.debug('Executing topic creation transaction');\n const txResponse = await transaction.execute(this.client);\n const receipt = await txResponse.getReceipt(this.client);\n\n if (!receipt.topicId) {\n this.logger.error('Failed to create topic: topicId is null');\n throw new Error('Failed to create topic: topicId is null');\n }\n\n const topicId = receipt.topicId.toString();\n return topicId;\n }\n\n public async submitPayload(\n topicId: string,\n payload: object | string,\n submitKey?: PrivateKey,\n requiresFee: boolean = false\n ): Promise<TransactionReceipt> {\n const message =\n typeof payload === 'string' ? payload : JSON.stringify(payload);\n\n const payloadSizeInBytes = Buffer.byteLength(message, 'utf8');\n if (payloadSizeInBytes > 1000) {\n throw new PayloadSizeError(\n 'Payload size exceeds 1000 bytes limit',\n payloadSizeInBytes\n );\n }\n\n const transaction = new TopicMessageSubmitTransaction()\n .setTopicId(TopicId.fromString(topicId))\n .setMessage(message);\n\n if (requiresFee) {\n this.logger.info(\n 'Topic requires fee payment, setting max transaction fee'\n );\n transaction.setMaxTransactionFee(new Hbar(this.feeAmount));\n }\n\n let transactionResponse: TransactionResponse;\n if (submitKey) {\n const frozenTransaction = transaction.freezeWith(this.client);\n const signedTransaction = await frozenTransaction.sign(submitKey);\n transactionResponse = await signedTransaction.execute(this.client);\n } else {\n transactionResponse = await transaction.execute(this.client);\n }\n\n const receipt = await transactionResponse.getReceipt(this.client);\n if (!receipt) {\n this.logger.error('Failed to submit message: receipt is null');\n throw new Error('Failed to submit message: receipt is null');\n }\n this.logger.info('Message submitted successfully');\n return receipt;\n }\n\n async inscribeFile(\n buffer: Buffer,\n fileName: string,\n options?: {\n progressCallback?: RegistrationProgressCallback;\n waitMaxAttempts?: number;\n waitIntervalMs?: number;\n }\n ): Promise<RetrievedInscriptionResult> {\n this.logger.info('Inscribing file');\n if (!this.client.operatorAccountId) {\n this.logger.error('Operator account ID is not set');\n throw new Error('Operator account ID is not set');\n }\n\n if (!this.operatorPrivateKey) {\n this.logger.error('Operator private key is not set');\n throw new Error('Operator private key is not set');\n }\n\n const mimeType = mime.lookup(fileName) || 'application/octet-stream';\n\n const sdk = await InscriptionSDK.createWithAuth({\n type: 'server',\n accountId: this.client.operatorAccountId.toString(),\n privateKey: this.operatorPrivateKey.toString(),\n network: this.network as 'testnet' | 'mainnet',\n });\n\n const inscriptionOptions = {\n mode: 'file' as const,\n waitForConfirmation: true,\n waitMaxAttempts: options?.waitMaxAttempts || 30,\n waitIntervalMs: options?.waitIntervalMs || 4000,\n progressCallback: options?.progressCallback,\n logging: {\n level: this.logger.getLevel ? this.logger.getLevel() : 'info',\n },\n };\n\n const response = await inscribe(\n {\n type: 'buffer',\n buffer,\n fileName,\n mimeType,\n },\n {\n accountId: this.client.operatorAccountId.toString(),\n privateKey: this.operatorPrivateKey.toString(),\n network: this.network as 'testnet' | 'mainnet',\n },\n inscriptionOptions,\n sdk\n );\n\n if (!response.confirmed || !response.inscription) {\n throw new Error('Inscription was not confirmed');\n }\n\n return response.inscription;\n }\n\n /**\n * Waits for confirmation of a connection request\n * @param inboundTopicId Inbound topic ID\n * @param connectionRequestId Connection request ID\n * @param maxAttempts Maximum number of attempts\n * @param delayMs Delay between attempts in milliseconds\n * @returns Connection confirmation details\n */\n async waitForConnectionConfirmation(\n inboundTopicId: string,\n connectionRequestId: number,\n maxAttempts = 60,\n delayMs = 2000,\n recordConfirmation = true\n ): Promise<WaitForConnectionConfirmationResponse> {\n this.logger.info(\n `Waiting for connection confirmation on inbound topic ${inboundTopicId} for request ID ${connectionRequestId}`\n );\n\n for (let attempt = 0; attempt < maxAttempts; attempt++) {\n this.logger.info(\n `Attempt ${attempt + 1}/${maxAttempts} to find connection confirmation`\n );\n const messages = await this.mirrorNode.getTopicMessages(inboundTopicId);\n\n const connectionCreatedMessages = messages.filter(\n (m) => m.op === 'connection_created'\n );\n\n this.logger.info(\n `Found ${connectionCreatedMessages.length} connection_created messages`\n );\n\n if (connectionCreatedMessages.length > 0) {\n for (const message of connectionCreatedMessages) {\n if (Number(message.connection_id) === Number(connectionRequestId)) {\n const confirmationResult = {\n connectionTopicId: message.connection_topic_id,\n sequence_number: Number(message.sequence_number),\n confirmedBy: message.operator_id,\n memo: message.m,\n };\n\n const confirmedByAccountId = this.extractAccountFromOperatorId(\n confirmationResult.confirmedBy\n );\n\n const account = this.getAccountAndSigner();\n const confirmedByConnectionTopics =\n await this.retrieveCommunicationTopics(confirmedByAccountId);\n\n const agentConnectionTopics =\n await this.retrieveCommunicationTopics(account.accountId);\n\n this.logger.info(\n 'Connection confirmation found',\n confirmationResult\n );\n\n if (recordConfirmation) {\n /**\n * Record's the confirmation of the connection request from the\n * confirmedBy account to the agent account.\n */\n await this.recordOutboundConnectionConfirmation({\n requestorOutboundTopicId:\n confirmedByConnectionTopics.outboundTopic,\n outboundTopicId: agentConnectionTopics.outboundTopic,\n connectionRequestId,\n confirmedRequestId: confirmationResult.sequence_number,\n connectionTopicId: confirmationResult.connectionTopicId,\n operatorId: confirmationResult.confirmedBy,\n memo: confirmationResult.memo || 'Connection confirmed',\n });\n }\n\n return confirmationResult;\n }\n }\n }\n\n if (attempt < maxAttempts - 1) {\n this.logger.info(\n `No matching confirmation found, waiting ${delayMs}ms before retrying...`\n );\n await new Promise((resolve) => setTimeout(resolve, delayMs));\n }\n }\n\n throw new Error(\n `Connection confirmation not found after ${maxAttempts} attempts for request ID ${connectionRequestId}`\n );\n }\n\n getAccountAndSigner(): GetAccountAndSignerResponse {\n return {\n accountId: this.client.operatorAccountId!.toString()!,\n signer: this.operatorPrivateKey,\n };\n }\n\n /**\n * Creates and registers an agent with a Guarded registry.\n *\n * This function performs the following steps:\n * 1. Creates a new account if no existing account is provided.\n * 2. Initializes an HCS10 client with the new account.\n * 3. Creates an agent on the client.\n * 4. Registers the agent with the Hashgraph Online Guarded Registry.\n *\n * @param builder The agent builder object\n * @param options Optional configuration including progress callback and state management\n * @returns Agent registration result\n */\n async createAndRegisterAgent(\n builder: AgentBuilder,\n options?: {\n baseUrl?: string;\n progressCallback?: RegistrationProgressCallback;\n existingState?: AgentCreationState;\n initialBalance?: number;\n }\n ): Promise<AgentRegistrationResult> {\n try {\n const config = builder.build();\n const progressCallback = options?.progressCallback;\n const baseUrl = options?.baseUrl || this.guardedRegistryBaseUrl;\n let state = options?.existingState || undefined;\n\n if (progressCallback) {\n progressCallback({\n stage: 'preparing',\n message: 'Preparing agent registration',\n progressPercent: 10,\n details: { state },\n });\n }\n\n const account =\n config.existingAccount ||\n (await this.createAccount(options?.initialBalance));\n\n if (progressCallback) {\n progressCallback({\n stage: 'preparing',\n message: 'Created account or using existing account',\n progressPercent: 20,\n details: { state, account },\n });\n }\n\n const agentClient = new HCS10Client({\n network: config.network,\n operatorId: account.accountId,\n operatorPrivateKey: account.privateKey,\n operatorPublicKey: PrivateKey.fromString(\n account.privateKey\n ).publicKey.toString(),\n logLevel: 'info' as LogLevel,\n guardedRegistryBaseUrl: baseUrl,\n });\n\n if (progressCallback) {\n progressCallback({\n stage: 'preparing',\n message: 'Initialized agent client',\n progressPercent: 30,\n details: { state },\n });\n }\n\n const { outboundTopicId, inboundTopicId, pfpTopicId, profileTopicId } =\n await agentClient.createAgent(builder);\n\n if (progressCallback) {\n progressCallback({\n stage: 'submitting',\n message: 'Created agent with topics and profile',\n progressPercent: 60,\n details: {\n state,\n outboundTopicId,\n inboundTopicId,\n pfpTopicId,\n profileTopicId,\n },\n });\n }\n\n const operatorId = `${inboundTopicId}@${account.accountId}`;\n\n const registrationResult =\n await agentClient.registerAgentWithGuardedRegistry(\n account.accountId,\n config.network,\n {\n progressCallback: (data) => {\n const adjustedPercent = 60 + (data.progressPercent || 0) * 0.4;\n if (progressCallback) {\n progressCallback({\n stage: data.stage,\n message: data.message,\n progressPercent: adjustedPercent,\n details: {\n ...data.details,\n outboundTopicId,\n inboundTopicId,\n pfpTopicId,\n profileTopicId,\n operatorId,\n state: data.details?.state || state,\n },\n });\n }\n },\n existingState: state,\n }\n );\n\n if (!registrationResult.success) {\n return registrationResult;\n }\n\n if (progressCallback) {\n progressCallback({\n stage: 'completed',\n message: 'Agent creation and registration complete',\n progressPercent: 100,\n details: {\n outboundTopicId,\n inboundTopicId,\n pfpTopicId,\n profileTopicId,\n operatorId,\n state: registrationResult.state,\n },\n });\n }\n\n return {\n ...registrationResult,\n metadata: {\n accountId: account.accountId,\n privateKey: account.privateKey,\n operatorId,\n inboundTopicId,\n outboundTopicId,\n profileTopicId,\n pfpTopicId,\n },\n };\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Failed to create and register agent: ${error.message}`;\n this.logger.error(logMessage);\n return {\n error: error.message,\n success: false,\n };\n }\n }\n\n /**\n * Registers an agent with the guarded registry\n * @param accountId Account ID to register\n * @param inboundTopicId Inbound topic ID for the agent\n * @param network Network type ('mainnet' or 'testnet')\n * @param options Optional configuration including progress callback and confirmation settings\n * @returns Registration result\n */\n async registerAgentWithGuardedRegistry(\n accountId: string,\n network: string = this.network,\n options?: {\n progressCallback?: RegistrationProgressCallback;\n maxAttempts?: number;\n delayMs?: number;\n existingState?: AgentCreationState;\n }\n ): Promise<AgentRegistrationResult> {\n try {\n this.logger.info('Registering agent with guarded registry');\n\n const maxAttempts = options?.maxAttempts ?? 60;\n const delayMs = options?.delayMs ?? 2000;\n const progressCallback = options?.progressCallback;\n let state =\n options?.existingState ||\n ({\n currentStage: 'registration',\n completedPercentage: 0,\n createdResources: [],\n } as AgentCreationState);\n\n if (progressCallback) {\n progressCallback({\n stage: 'preparing',\n message: 'Preparing agent registration',\n progressPercent: 10,\n details: {\n state,\n },\n });\n }\n\n const registrationResult = await this.executeRegistration(\n accountId,\n network,\n this.guardedRegistryBaseUrl,\n this.logger\n );\n\n if (!registrationResult.success) {\n return {\n ...registrationResult,\n state,\n };\n }\n\n if (progressCallback) {\n progressCallback({\n stage: 'submitting',\n message: 'Submitting registration to registry',\n progressPercent: 30,\n details: {\n transactionId: registrationResult.transactionId,\n state,\n },\n });\n }\n\n if (registrationResult.transaction) {\n const transaction = Transaction.fromBytes(\n Buffer.from(registrationResult.transaction, 'base64')\n );\n\n this.logger.info(`Processing registration transaction`);\n await transaction.execute(this.client);\n this.logger.info(`Successfully processed registration transaction`);\n }\n\n if (progressCallback) {\n progressCallback({\n stage: 'confirming',\n message: 'Confirming registration transaction',\n progressPercent: 60,\n details: {\n accountId,\n transactionId: registrationResult.transactionId,\n state,\n },\n });\n }\n\n const confirmed = await this.waitForRegistrationConfirmation(\n registrationResult.transactionId!,\n network,\n this.guardedRegistryBaseUrl,\n maxAttempts,\n delayMs,\n this.logger\n );\n\n state.currentStage = 'complete';\n state.completedPercentage = 100;\n if (!state.createdResources) {\n state.createdResources = [];\n }\n if (registrationResult.transactionId) {\n state.createdResources.push(\n `registration:${registrationResult.transactionId}`\n );\n }\n\n if (progressCallback) {\n progressCallback({\n stage: 'completed',\n message: 'Agent registration complete',\n progressPercent: 100,\n details: {\n confirmed,\n transactionId: registrationResult.transactionId,\n state,\n },\n });\n }\n\n return {\n ...registrationResult,\n confirmed,\n state,\n };\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Failed to register agent: ${error.message}`;\n this.logger.error(logMessage);\n return {\n error: error.message,\n success: false,\n };\n }\n }\n\n /**\n * Registers an agent with the guarded registry. Should be called by a registry.\n * @param registryTopicId - The topic ID of the guarded registry.\n * @param accountId - The account ID of the agent\n * @param inboundTopicId - The topic ID of the inbound topic\n * @param memo - The memo of the agent\n * @param submitKey - The submit key of the agent\n */\n async registerAgent(\n registryTopicId: string,\n accountId: string,\n inboundTopicId: string,\n memo: string,\n submitKey?: PrivateKey\n ): Promise<void> {\n this.logger.info('Registering agent');\n const payload = {\n p: 'hcs-10',\n op: 'register',\n account_id: accountId,\n inbound_topic_id: inboundTopicId,\n m: memo,\n };\n\n await this.submitPayload(registryTopicId, payload, submitKey);\n }\n\n async getInboundTopicType(topicId: string): Promise<InboundTopicType> {\n try {\n const topicInfo = await this.mirrorNode.getTopicInfo(topicId);\n\n if (!topicInfo) {\n throw new Error('Topic does not exist');\n }\n\n const hasSubmitKey = topicInfo.submit_key && topicInfo.submit_key.key;\n\n if (!hasSubmitKey) {\n return InboundTopicType.PUBLIC;\n }\n\n const hasFeeScheduleKey =\n topicInfo.fee_schedule_key && topicInfo.fee_schedule_key.key;\n\n if (hasFeeScheduleKey && topicInfo.custom_fees) {\n const customFees = topicInfo.custom_fees;\n\n if (\n customFees &&\n customFees.fixed_fees &&\n customFees.fixed_fees.length > 0\n ) {\n this.logger.info(\n `Topic ${topicId} is fee-based with ${customFees.fixed_fees.length} custom fees`\n );\n return InboundTopicType.FEE_BASED;\n }\n }\n\n return InboundTopicType.CONTROLLED;\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Error determining topic type: ${error.message}`;\n this.logger.error(logMessage);\n throw new Error(logMessage);\n }\n }\n\n getNetwork(): string {\n return this.network;\n }\n\n getLogger(): Logger {\n return this.logger;\n }\n\n /**\n * Public method to get the operator account ID configured for this client instance.\n * @returns The operator account ID string, or null if not set.\n */\n getOperatorAccountId(): string | null {\n return this.client.operatorAccountId?.toString() ?? null;\n }\n\n /**\n * Creates a scheduled transaction from a transaction object\n * @param transaction The transaction to schedule\n * @param memo Optional memo to include with the scheduled transaction\n * @param expirationTime Optional expiration time in seconds from now\n * @returns Object with schedule ID and transaction ID\n */\n private async createScheduledTransaction(\n transaction: Transaction,\n memo?: string,\n expirationTime?: number,\n schedulePayerAccountId?: string\n ): Promise<{\n scheduleId: string;\n transactionId: string;\n }> {\n this.logger.info('Creating scheduled transaction');\n\n const scheduleTransaction = new ScheduleCreateTransaction()\n .setScheduledTransaction(transaction)\n .setPayerAccountId(\n schedulePayerAccountId\n ? AccountId.fromString(schedulePayerAccountId)\n : this.client.operatorAccountId\n );\n\n if (memo) {\n scheduleTransaction.setScheduleMemo(memo);\n }\n\n if (expirationTime) {\n const expirationDate = addSeconds(new Date(), expirationTime);\n const timestamp = Timestamp.fromDate(expirationDate);\n scheduleTransaction.setExpirationTime(timestamp);\n }\n\n this.logger.debug('Executing schedule create transaction');\n const scheduleResponse = await scheduleTransaction.execute(this.client);\n const scheduleReceipt = await scheduleResponse.getReceipt(this.client);\n\n if (!scheduleReceipt.scheduleId) {\n this.logger.error(\n 'Failed to create scheduled transaction: scheduleId is null'\n );\n throw new Error(\n 'Failed to create scheduled transaction: scheduleId is null'\n );\n }\n\n const scheduleId = scheduleReceipt.scheduleId.toString();\n const transactionId = scheduleResponse.transactionId.toString();\n\n this.logger.info(\n `Scheduled transaction created successfully: ${scheduleId}`\n );\n\n return {\n scheduleId,\n transactionId,\n };\n }\n\n /**\n * Sends a transaction operation on a connection topic\n * @param connectionTopicId Connection topic ID\n * @param scheduleId Schedule ID of the scheduled transaction\n * @param data Human-readable description of the transaction, can also be a JSON string or HRL\n * @param submitKey Optional submit key\n * @param options Optional parameters including memo (timestamp is no longer used here)\n * @returns Transaction receipt\n */\n private async sendTransactionOperation(\n connectionTopicId: string,\n scheduleId: string,\n data: string,\n submitKey?: PrivateKey,\n options?: {\n memo?: string;\n }\n ): Promise<TransactionReceipt> {\n const submissionCheck = await this.canSubmitToTopic(\n connectionTopicId,\n this.client.operatorAccountId?.toString() || ''\n );\n\n const operatorId = await this.getOperatorId();\n\n const payload = {\n p: 'hcs-10',\n op: 'transaction',\n operator_id: operatorId,\n schedule_id: scheduleId,\n data,\n m: options?.memo,\n };\n\n this.logger.info(\n 'Submitting transaction operation to connection topic',\n payload\n );\n return await this.submitPayload(\n connectionTopicId,\n payload,\n submitKey,\n submissionCheck.requiresFee\n );\n }\n\n /**\n * Creates and sends a transaction operation in one call\n * @param connectionTopicId Connection topic ID for sending the transaction operation\n * @param transaction The transaction to schedule\n * @param data Human-readable description of the transaction, can also be a JSON string or HRL\n * @param options Optional parameters for schedule creation and operation memo\n * @returns Object with schedule details (including scheduleId and its transactionId) and HCS-10 operation receipt\n */\n async sendTransaction(\n connectionTopicId: string,\n transaction: Transaction,\n data: string,\n options?: {\n scheduleMemo?: string;\n expirationTime?: number;\n submitKey?: PrivateKey;\n operationMemo?: string;\n schedulePayerAccountId?: string;\n }\n ): Promise<{\n scheduleId: string;\n transactionId: string;\n receipt: TransactionReceipt;\n }> {\n this.logger.info(\n 'Creating scheduled transaction and sending transaction operation'\n );\n\n const { scheduleId, transactionId } = await this.createScheduledTransaction(\n transaction,\n options?.scheduleMemo,\n options?.expirationTime,\n options?.schedulePayerAccountId\n );\n\n const receipt = await this.sendTransactionOperation(\n connectionTopicId,\n scheduleId,\n data,\n options?.submitKey,\n {\n memo: options?.operationMemo,\n }\n );\n\n return {\n scheduleId,\n transactionId,\n receipt,\n };\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AA+DO,MAAM,oBAAoB,gBAAgB;AAAA,EAQ/C,YAAY,QAAyB;AAC7B,UAAA;AAAA,MACJ,SAAS,OAAO;AAAA,MAChB,UAAU,OAAO;AAAA,MACjB,aAAa,OAAO;AAAA,MACpB,WAAW,OAAO;AAAA,MAClB,YAAY,OAAO;AAAA,IAAA,CACpB;AACI,SAAA,SACH,OAAO,YAAY,YAAY,OAAO,WAAW,IAAI,OAAO,WAAW;AACzE,SAAK,qBAAqB,WAAW,WAAW,OAAO,kBAAkB;AACzE,SAAK,UAAU,OAAO;AACtB,SAAK,OAAO;AAAA,MACV,OAAO;AAAA,MACP,KAAK,mBAAmB,SAAS;AAAA,IACnC;AACK,SAAA,SAAS,OAAO,YAAY;AAAA,MAC/B,OAAO,OAAO,YAAY;AAAA,MAC1B,QAAQ;AAAA,IAAA,CACT;AACI,SAAA,yBACH,OAAO,0BAA0B;AAE9B,SAAA,cAAc,IAAI,YAAY;AAAA,MACjC,SAAS,OAAO;AAAA,MAChB,MAAM;AAAA,QACJ,YAAY,OAAO;AAAA,QACnB,YAAY,OAAO;AAAA,MACrB;AAAA,MACA,UAAU,OAAO;AAAA,IAAA,CAClB;AAAA,EAAA;AAAA,EAGI,YAAY;AACjB,WAAO,KAAK;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQd,MAAM,cACJ,iBAAyB,IACO;AAChC,SAAK,OAAO;AAAA,MACV,6BAA6B,cAAc;AAAA,IAC7C;AACM,UAAA,SAAS,WAAW,SAAS;AAEnC,UAAM,qBAAqB,IAAI,yBAAyB,EACrD,OAAO,OAAO,SAAS,EACvB,kBAAkB,IAAI,KAAK,cAAc,CAAC;AAExC,SAAA,OAAO,MAAM,wCAAwC;AAC1D,UAAM,kBAAkB,MAAM,m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AAAA,IAC/C;AAEM,UAAA,aAAa,MAAM,KAAK,cAAc;AAE5C,UAAM,UAAU;AAAA,MACd,GAAG;AAAA,MACH,IAAI;AAAA,MACJ,aAAa;AAAA,MACb,aAAa;AAAA,MACb;AAAA,MACA,GAAG,SAAS;AAAA,IACd;AAEA,SAAK,OAAO;AAAA,MACV;AAAA,MACA;AAAA,IACF;AACA,WAAO,MAAM,KAAK;AAAA,MAChB;AAAA,MACA;AAAA,MACA;AAAA,MACA,gBAAgB;AAAA,IAClB;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWF,MAAM,gBACJ,mBACA,aACA,MACA,SAWC;AACD,SAAK,OAAO;AAAA,MACV;AAAA,IACF;AAEA,UAAM,EAAE,YAAY,kBAAkB,MAAM,KAAK;AAAA,MAC/C;AAAA,MACA,SAAS;AAAA,MACT,SAAS;AAAA,MACT,SAAS;AAAA,IACX;AAEM,UAAA,UAAU,MAAM,KAAK;AAAA,MACzB;AAAA,MACA;AAAA,MACA;AAAA,MACA,SAAS;AAAA,MACT;AAAA,QACE,MAAM,SAAS;AAAA,MAAA;AAAA,IAEnB;AAEO,WAAA;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EAAA;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"standards-sdk.es7.js","sources":["../../src/hcs-10/sdk.ts"],"sourcesContent":["import {\n Client,\n AccountCreateTransaction,\n PrivateKey,\n Hbar,\n KeyList,\n TopicCreateTransaction,\n TopicMessageSubmitTransaction,\n TopicId,\n Transaction,\n TransactionResponse,\n TransactionReceipt,\n PublicKey,\n AccountId,\n CustomFixedFee,\n TokenId,\n ScheduleCreateTransaction,\n Timestamp,\n} from '@hashgraph/sdk';\nimport {\n PayloadSizeError,\n AccountCreationError,\n TopicCreationError,\n ConnectionConfirmationError,\n} from './errors';\nimport {\n InscriptionSDK,\n RetrievedInscriptionResult,\n} from '@kiloscribe/inscription-sdk';\nimport { Logger, LogLevel } from '../utils/logger';\nimport { HCS10BaseClient } from './base-client';\nimport * as mime from 'mime-types';\nimport {\n HCSClientConfig,\n CreateAccountResponse,\n CreateAgentResponse,\n StoreHCS11ProfileResponse,\n AgentRegistrationResult,\n HandleConnectionRequestResponse,\n WaitForConnectionConfirmationResponse,\n GetAccountAndSignerResponse,\n AgentCreationState,\n RegistrationProgressCallback,\n InscribePfpResponse,\n} from './types';\nimport { MirrorNodeConfig } from '../services';\nimport {\n HCS11Client,\n AgentMetadata as HCS11AgentMetadata,\n SocialLink,\n SocialPlatform,\n InboundTopicType,\n AgentMetadata,\n} from '../hcs-11';\nimport { FeeConfigBuilderInterface, TopicFeeConfig } from '../fees';\nimport { TopicResponse } from '../services/types';\nimport { accountIdsToExemptKeys } from '../utils/topic-fee-utils';\nimport { Hcs10MemoType } from './base-client';\nimport { AgentBuilder } from '../hcs-11/agent-builder';\nimport { inscribe } from '../inscribe/inscriber';\nimport { TokenFeeConfig } from '../fees/types';\nimport { addSeconds } from 'date-fns';\n\nexport class HCS10Client extends HCS10BaseClient {\n private client: Client;\n private operatorPrivateKey: PrivateKey;\n protected declare network: string;\n protected declare logger: Logger;\n protected guardedRegistryBaseUrl: string;\n private hcs11Client: HCS11Client;\n\n constructor(config: HCSClientConfig) {\n super({\n network: config.network,\n logLevel: config.logLevel,\n prettyPrint: config.prettyPrint,\n feeAmount: config.feeAmount,\n mirrorNode: config.mirrorNode,\n });\n this.client =\n config.network === 'mainnet' ? Client.forMainnet() : Client.forTestnet();\n this.operatorPrivateKey = PrivateKey.fromString(config.operatorPrivateKey);\n this.network = config.network;\n this.client.setOperator(\n config.operatorId,\n this.operatorPrivateKey.toString()\n );\n this.logger = Logger.getInstance({\n level: config.logLevel || 'info',\n module: 'HCS-SDK',\n });\n this.guardedRegistryBaseUrl =\n config.guardedRegistryBaseUrl || 'https://moonscape.tech';\n\n this.hcs11Client = new HCS11Client({\n network: config.network,\n auth: {\n operatorId: config.operatorId,\n privateKey: config.operatorPrivateKey,\n },\n logLevel: config.logLevel,\n });\n }\n\n public getClient() {\n return this.client;\n }\n\n /**\n * Creates a new Hedera account\n * @param initialBalance Optional initial balance in HBAR (default: 50)\n * @returns Object with account ID and private key\n */\n async createAccount(\n initialBalance: number = 50\n ): Promise<CreateAccountResponse> {\n this.logger.info(\n `Creating new account with ${initialBalance} HBAR initial balance`\n );\n const newKey = PrivateKey.generate();\n\n const accountTransaction = new AccountCreateTransaction()\n .setKey(newKey.publicKey)\n .setInitialBalance(new Hbar(initialBalance));\n\n this.logger.debug('Executing account creation transaction');\n const accountResponse = await accountTransaction.execute(this.client);\n const accountReceipt = await accountResponse.getReceipt(this.client);\n const newAccountId = accountReceipt.accountId;\n\n if (!newAccountId) {\n this.logger.error('Account creation failed: accountId is null');\n throw new AccountCreationError(\n 'Failed to create account: accountId is null'\n );\n }\n\n this.logger.info(\n `Account created successfully: ${newAccountId.toString()}`\n );\n return {\n accountId: newAccountId.toString(),\n privateKey: newKey.toString(),\n };\n }\n\n /**\n * Creates an inbound topic for an agent\n * @param accountId The account ID associated with the inbound topic\n * @param topicType Type of inbound topic (public, controlled, or fee-based)\n * @param ttl Optional Time-To-Live for the topic memo, defaults to 60\n * @param feeConfigBuilder Optional fee configuration builder for fee-based topics\n * @returns The topic ID of the created inbound topic\n */\n async createInboundTopic(\n accountId: string,\n topicType: InboundTopicType,\n ttl: number = 60,\n feeConfigBuilder?: FeeConfigBuilderInterface\n ): Promise<string> {\n const memo = this._generateHcs10Memo(Hcs10MemoType.INBOUND, {\n accountId,\n ttl,\n });\n\n let submitKey: boolean | PublicKey | KeyList | undefined;\n let finalFeeConfig: TopicFeeConfig | undefined;\n\n switch (topicType) {\n case InboundTopicType.PUBLIC:\n submitKey = false;\n break;\n case InboundTopicType.CONTROLLED:\n submitKey = true;\n break;\n case InboundTopicType.FEE_BASED:\n submitKey = false;\n if (!feeConfigBuilder) {\n throw new Error(\n 'Fee configuration builder is required for fee-based topics'\n );\n }\n\n const internalFees = (feeConfigBuilder as any)\n .customFees as TokenFeeConfig[];\n internalFees.forEach((fee) => {\n if (!fee.feeCollectorAccountId) {\n this.logger.debug(\n `Defaulting fee collector for token ${\n fee.feeTokenId || 'HBAR'\n } to agent ${accountId}`\n );\n fee.feeCollectorAccountId = accountId;\n }\n });\n\n finalFeeConfig = feeConfigBuilder.build();\n break;\n default:\n throw new Error(`Unsupported inbound topic type: ${topicType}`);\n }\n\n return this.createTopic(memo, true, submitKey, finalFeeConfig);\n }\n\n /**\n * Creates a new agent with inbound and outbound topics\n * @param builder The agent builder object\n * @param ttl Optional Time-To-Live for the topic memos, defaults to 60\n * @returns Object with topic IDs\n */\n async createAgent(\n builder: AgentBuilder,\n ttl: number = 60\n ): Promise<CreateAgentResponse> {\n const config = builder.build();\n const outboundMemo = this._generateHcs10Memo(Hcs10MemoType.OUTBOUND, {\n ttl,\n });\n const outboundTopicId = await this.createTopic(outboundMemo, true, true);\n this.logger.info(`Created new outbound topic ID: ${outboundTopicId}`);\n\n const accountId = this.client.operatorAccountId?.toString();\n if (!accountId) {\n throw new Error('Failed to retrieve operator account ID');\n }\n\n const inboundTopicId = await this.createInboundTopic(\n accountId,\n config.inboundTopicType,\n ttl,\n config.inboundTopicType === InboundTopicType.FEE_BASED\n ? config.feeConfig\n : undefined\n );\n\n let pfpTopicId = config.existingPfpTopicId || '';\n\n if (!pfpTopicId && config.pfpBuffer && config.pfpBuffer.length > 0) {\n this.logger.info('Inscribing new profile picture');\n const pfpResult = await this.inscribePfp(\n config.pfpBuffer,\n config.pfpFileName\n );\n pfpTopicId = pfpResult.pfpTopicId;\n this.logger.info(\n `Profile picture inscribed with topic ID: ${pfpTopicId}`\n );\n } else if (config.existingPfpTopicId) {\n this.logger.info(\n `Using existing profile picture with topic ID: ${config.existingPfpTopicId}`\n );\n }\n\n const profileResult = await this.storeHCS11Profile(\n config.name,\n config.bio,\n inboundTopicId,\n outboundTopicId,\n config.capabilities,\n config.metadata,\n config.pfpBuffer && config.pfpBuffer.length > 0\n ? config.pfpBuffer\n : undefined,\n config.pfpFileName,\n config.existingPfpTopicId\n );\n const profileTopicId = profileResult.profileTopicId;\n this.logger.info(`Profile stored with topic ID: ${profileTopicId}`);\n\n return {\n inboundTopicId,\n outboundTopicId,\n pfpTopicId,\n profileTopicId,\n };\n }\n\n /**\n * Inscribes a profile picture to Hedera\n * @param buffer Profile picture buffer\n * @param fileName Filename\n * @returns Response with topic ID and transaction ID\n */\n async inscribePfp(\n buffer: Buffer,\n fileName: string\n ): Promise<InscribePfpResponse> {\n try {\n this.logger.info('Inscribing profile picture using HCS-11 client');\n\n const imageResult = await this.hcs11Client.inscribeImage(\n buffer,\n fileName\n );\n\n if (!imageResult.success) {\n this.logger.error(\n `Failed to inscribe profile picture: ${imageResult.error}`\n );\n throw new Error(\n imageResult?.error || 'Failed to inscribe profile picture'\n );\n }\n\n this.logger.info(\n `Successfully inscribed profile picture with topic ID: ${imageResult.imageTopicId}`\n );\n return {\n pfpTopicId: imageResult.imageTopicId,\n transactionId: imageResult.transactionId,\n success: true,\n };\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Error inscribing profile picture: ${error.message}`;\n this.logger.error(logMessage);\n return {\n pfpTopicId: '',\n transactionId: '',\n success: false,\n error: error.message,\n };\n }\n }\n\n /**\n * Stores an HCS-11 profile for an agent\n * @param agentName Agent name\n * @param agentBio Agent description\n * @param inboundTopicId Inbound topic ID\n * @param outboundTopicId Outbound topic ID\n * @param capabilities Agent capability tags\n * @param metadata Additional metadata\n * @param pfpBuffer Optional profile picture buffer\n * @param pfpFileName Optional profile picture filename\n * @returns Response with topic IDs and transaction ID\n */\n async storeHCS11Profile(\n agentName: string,\n agentBio: string,\n inboundTopicId: string,\n outboundTopicId: string,\n capabilities: number[] = [],\n metadata: AgentMetadata,\n pfpBuffer?: Buffer,\n pfpFileName?: string,\n existingPfpTopicId?: string\n ): Promise<StoreHCS11ProfileResponse> {\n try {\n let pfpTopicId = existingPfpTopicId || '';\n\n if (!pfpTopicId && pfpBuffer && pfpFileName) {\n this.logger.info('Inscribing profile picture for HCS-11 profile');\n const pfpResult = await this.inscribePfp(pfpBuffer, pfpFileName);\n if (!pfpResult.success) {\n this.logger.warn(\n `Failed to inscribe profile picture: ${pfpResult.error}, proceeding without pfp`\n );\n } else {\n pfpTopicId = pfpResult.pfpTopicId;\n }\n } else if (existingPfpTopicId) {\n this.logger.info(\n `Using existing profile picture with topic ID: ${existingPfpTopicId} for HCS-11 profile`\n );\n pfpTopicId = existingPfpTopicId;\n }\n\n const agentType = this.hcs11Client.getAgentTypeFromMetadata({\n type: metadata.type || 'autonomous',\n } as HCS11AgentMetadata);\n\n const formattedSocials: SocialLink[] | undefined = metadata.socials\n ? (Object.entries(metadata.socials)\n .filter(([_, handle]) => handle)\n .map(([platform, handle]) => ({\n platform: platform as SocialPlatform,\n handle: handle as string,\n })) as SocialLink[])\n : undefined;\n\n const profile = this.hcs11Client.createAIAgentProfile(\n agentName,\n agentType,\n capabilities,\n metadata.model || 'unknown',\n {\n alias: agentName.toLowerCase().replace(/\\s+/g, '_'),\n bio: agentBio,\n profileImage: pfpTopicId ? `hcs://1/${pfpTopicId}` : undefined,\n socials: formattedSocials,\n properties: metadata.properties,\n inboundTopicId,\n outboundTopicId,\n creator: metadata.creator,\n }\n );\n\n const profileResult = await this.hcs11Client.createAndInscribeProfile(\n profile,\n true\n );\n\n if (!profileResult.success) {\n this.logger.error(`Failed to inscribe profile: ${profileResult.error}`);\n throw new Error(profileResult.error || 'Failed to inscribe profile');\n }\n\n this.logger.info(\n `Profile inscribed with topic ID: ${profileResult.profileTopicId}, transaction ID: ${profileResult.transactionId}`\n );\n\n return {\n profileTopicId: profileResult.profileTopicId,\n pfpTopicId,\n transactionId: profileResult.transactionId,\n success: true,\n };\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Error storing HCS-11 profile: ${error.message}`;\n this.logger.error(logMessage);\n return {\n profileTopicId: '',\n pfpTopicId: '',\n transactionId: '',\n success: false,\n error: error.message,\n };\n }\n }\n\n private async setupFees(\n transaction: TopicCreateTransaction,\n feeConfig: TopicFeeConfig,\n additionalExemptAccounts: string[] = []\n ): Promise<TopicCreateTransaction> {\n let modifiedTransaction = transaction;\n if (!this.client.operatorPublicKey) {\n return modifiedTransaction;\n }\n\n if (!feeConfig.customFees || feeConfig.customFees.length === 0) {\n this.logger.warn('No custom fees provided in fee config for setupFees');\n return modifiedTransaction;\n }\n\n if (feeConfig.customFees.length > 10) {\n this.logger.warn(\n 'More than 10 custom fees provided, only the first 10 will be used'\n );\n feeConfig.customFees = feeConfig.customFees.slice(0, 10);\n }\n\n const customFees = feeConfig.customFees\n .map((fee) => {\n if (!fee.feeCollectorAccountId) {\n this.logger.error(\n 'Internal Error: Fee collector ID missing in setupFees'\n );\n return null;\n }\n if (fee.type === 'FIXED_FEE') {\n const customFee = new CustomFixedFee()\n .setAmount(Number(fee.feeAmount.amount))\n .setFeeCollectorAccountId(\n AccountId.fromString(fee.feeCollectorAccountId)\n );\n\n if (fee.feeTokenId) {\n customFee.setDenominatingTokenId(\n TokenId.fromString(fee.feeTokenId)\n );\n }\n\n return customFee;\n }\n return null;\n })\n .filter(Boolean) as CustomFixedFee[];\n\n if (customFees.length === 0) {\n this.logger.warn('No valid custom fees to apply in setupFees');\n return modifiedTransaction;\n }\n\n const exemptAccountIds = [\n ...(feeConfig.exemptAccounts || []),\n ...additionalExemptAccounts,\n ];\n\n if (exemptAccountIds.length > 0) {\n modifiedTransaction = await this.setupExemptKeys(\n transaction,\n exemptAccountIds\n );\n }\n\n return modifiedTransaction\n .setFeeScheduleKey(this.client.operatorPublicKey)\n .setCustomFees(customFees);\n }\n\n private async setupExemptKeys(\n transaction: TopicCreateTransaction,\n exemptAccountIds: string[]\n ): Promise<TopicCreateTransaction> {\n let modifiedTransaction = transaction;\n const uniqueExemptAccountIds = Array.from(new Set(exemptAccountIds));\n const filteredExemptAccounts = uniqueExemptAccountIds.filter(\n (account) => account !== this.client.operatorAccountId?.toString()\n );\n\n let exemptKeys: PublicKey[] = [];\n if (filteredExemptAccounts.length > 0) {\n try {\n exemptKeys = await accountIdsToExemptKeys(\n filteredExemptAccounts,\n this.network,\n this.logger\n );\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Error getting exempt keys: ${error.message}, continuing without exempt keys`;\n this.logger.warn(logMessage);\n }\n }\n\n if (exemptKeys.length > 0) {\n modifiedTransaction = modifiedTransaction.setFeeExemptKeys(exemptKeys);\n }\n\n return modifiedTransaction;\n }\n\n /**\n * Handles a connection request from another account\n * @param inboundTopicId Inbound topic ID of your agent\n * @param requestingAccountId Requesting account ID\n * @param connectionRequestId Connection request ID\n * @param connectionFeeConfig Optional fee configuration for the connection topic\n * @param ttl Optional ttl parameter with default\n * @returns Response with connection details\n */\n async handleConnectionRequest(\n inboundTopicId: string,\n requestingAccountId: string,\n connectionRequestId: number,\n connectionFeeConfig?: FeeConfigBuilderInterface,\n ttl: number = 60\n ): Promise<HandleConnectionRequestResponse> {\n const memo = this._generateHcs10Memo(Hcs10MemoType.CONNECTION, {\n ttl,\n inboundTopicId,\n connectionId: connectionRequestId,\n });\n this.logger.info(\n `Handling connection request ${connectionRequestId} from ${requestingAccountId}`\n );\n\n const accountId = this.getClient().operatorAccountId?.toString();\n if (!accountId) {\n throw new Error('Failed to retrieve operator account ID');\n }\n\n let requesterKey = await this.mirrorNode.getPublicKey(requestingAccountId);\n const accountKey = await this.mirrorNode.getPublicKey(accountId);\n\n if (!accountKey) {\n throw new Error('Failed to retrieve public key');\n }\n\n const thresholdKey = new KeyList([accountKey, requesterKey], 1);\n\n let connectionTopicId: string;\n\n try {\n if (connectionFeeConfig) {\n const feeConfig = connectionFeeConfig.build();\n const modifiedFeeConfig = {\n ...feeConfig,\n exemptAccounts: [...(feeConfig.exemptAccounts || [])],\n };\n\n connectionTopicId = await this.createTopic(\n memo,\n thresholdKey,\n thresholdKey,\n modifiedFeeConfig\n );\n } else {\n connectionTopicId = await this.createTopic(\n memo,\n thresholdKey,\n thresholdKey\n );\n }\n\n this.logger.info(`Created new connection topic ID: ${connectionTopicId}`);\n } catch (error) {\n const logMessage = `Failed to create connection topic: ${error}`;\n this.logger.error(logMessage);\n throw new TopicCreationError(logMessage);\n }\n\n const operatorId = `${inboundTopicId}@${accountId}`;\n\n const confirmedConnectionSequenceNumber = await this.confirmConnection(\n inboundTopicId,\n connectionTopicId,\n requestingAccountId,\n connectionRequestId,\n 'Connection accepted. Looking forward to collaborating!'\n );\n\n const accountTopics = await this.retrieveCommunicationTopics(accountId);\n\n const requestingAccountTopics = await this.retrieveCommunicationTopics(\n requestingAccountId\n );\n\n const requestingAccountOperatorId = `${requestingAccountTopics.inboundTopic}@${requestingAccountId}`;\n\n await this.recordOutboundConnectionConfirmation({\n outboundTopicId: accountTopics.outboundTopic,\n requestorOutboundTopicId: requestingAccountTopics.outboundTopic,\n connectionRequestId: connectionRequestId,\n confirmedRequestId: confirmedConnectionSequenceNumber,\n connectionTopicId,\n operatorId: requestingAccountOperatorId,\n memo: `Connection established with ${requestingAccountId}`,\n });\n\n return {\n connectionTopicId,\n confirmedConnectionSequenceNumber,\n operatorId,\n };\n }\n\n /**\n * Confirms a connection request from another account\n * @param inboundTopicId Inbound topic ID\n * @param connectionTopicId Connection topic ID\n * @param connectedAccountId Connected account ID\n * @param connectionId Connection ID\n * @param memo Memo for the connection request\n * @param submitKey Optional submit key\n * @returns Sequence number of the confirmed connection\n */\n async confirmConnection(\n inboundTopicId: string,\n connectionTopicId: string,\n connectedAccountId: string,\n connectionId: number,\n memo: string,\n submitKey?: PrivateKey\n ): Promise<number> {\n const operatorId = await this.getOperatorId();\n this.logger.info(`Confirming connection with ID ${connectionId}`);\n const payload = {\n p: 'hcs-10',\n op: 'connection_created',\n connection_topic_id: connectionTopicId,\n connected_account_id: connectedAccountId,\n operator_id: operatorId,\n connection_id: connectionId,\n m: memo,\n };\n\n const submissionCheck = await this.canSubmitToTopic(\n inboundTopicId,\n this.client.operatorAccountId?.toString() || ''\n );\n\n const result = await this.submitPayload(\n inboundTopicId,\n payload,\n submitKey,\n submissionCheck.requiresFee\n );\n\n const sequenceNumber = result.topicSequenceNumber?.toNumber();\n\n if (!sequenceNumber) {\n throw new ConnectionConfirmationError(\n 'Failed to confirm connection: sequence number is null'\n );\n }\n\n return sequenceNumber;\n }\n\n async sendMessage(\n connectionTopicId: string,\n data: string,\n memo?: string,\n submitKey?: PrivateKey,\n options?: {\n progressCallback?: RegistrationProgressCallback;\n waitMaxAttempts?: number;\n waitIntervalMs?: number;\n }\n ): Promise<TransactionReceipt> {\n const submissionCheck = await this.canSubmitToTopic(\n connectionTopicId,\n this.client.operatorAccountId?.toString() || ''\n );\n\n const operatorId = await this.getOperatorId();\n\n const payload = {\n p: 'hcs-10',\n op: 'message',\n operator_id: operatorId,\n data,\n m: memo,\n };\n\n const payloadString = JSON.stringify(payload);\n const isLargePayload = Buffer.from(payloadString).length > 1000;\n\n if (isLargePayload) {\n this.logger.info(\n 'Message payload exceeds 1000 bytes, storing via inscription'\n );\n try {\n const contentBuffer = Buffer.from(data);\n const fileName = `message-${Date.now()}.json`;\n const inscriptionResult = await this.inscribeFile(\n contentBuffer,\n fileName,\n {\n progressCallback: options?.progressCallback,\n waitMaxAttempts: options?.waitMaxAttempts,\n waitIntervalMs: options?.waitIntervalMs,\n }\n );\n\n if (inscriptionResult?.topic_id) {\n payload.data = `hcs://1/${inscriptionResult.topic_id}`;\n this.logger.info(\n `Large message inscribed with topic ID: ${inscriptionResult.topic_id}`\n );\n } else {\n throw new Error('Failed to inscribe large message content');\n }\n } catch (error: any) {\n const logMessage = `Error inscribing large message: ${error.message}`;\n this.logger.error(logMessage);\n throw new Error(logMessage);\n }\n }\n\n this.logger.info('Submitting message to connection topic', payload);\n return await this.submitPayload(\n connectionTopicId,\n payload,\n submitKey,\n submissionCheck.requiresFee\n );\n }\n\n async createTopic(\n memo: string,\n adminKey?: boolean | PublicKey | KeyList,\n submitKey?: boolean | PublicKey | KeyList,\n feeConfig?: TopicFeeConfig\n ): Promise<string> {\n this.logger.info('Creating topic');\n const transaction = new TopicCreateTransaction().setTopicMemo(memo);\n\n if (adminKey) {\n if (\n typeof adminKey === 'boolean' &&\n adminKey &&\n this.client.operatorPublicKey\n ) {\n transaction.setAdminKey(this.client.operatorPublicKey);\n transaction.setAutoRenewAccountId(this.client.operatorAccountId!);\n } else if (adminKey instanceof PublicKey || adminKey instanceof KeyList) {\n transaction.setAdminKey(adminKey);\n if (this.client.operatorAccountId) {\n transaction.setAutoRenewAccountId(this.client.operatorAccountId);\n }\n }\n }\n\n if (submitKey) {\n if (\n typeof submitKey === 'boolean' &&\n submitKey &&\n this.client.operatorPublicKey\n ) {\n transaction.setSubmitKey(this.client.operatorPublicKey);\n } else if (\n submitKey instanceof PublicKey ||\n submitKey instanceof KeyList\n ) {\n transaction.setSubmitKey(submitKey);\n }\n }\n\n if (feeConfig) {\n await this.setupFees(transaction, feeConfig);\n }\n\n this.logger.debug('Executing topic creation transaction');\n const txResponse = await transaction.execute(this.client);\n const receipt = await txResponse.getReceipt(this.client);\n\n if (!receipt.topicId) {\n this.logger.error('Failed to create topic: topicId is null');\n throw new Error('Failed to create topic: topicId is null');\n }\n\n const topicId = receipt.topicId.toString();\n return topicId;\n }\n\n public async submitPayload(\n topicId: string,\n payload: object | string,\n submitKey?: PrivateKey,\n requiresFee: boolean = false\n ): Promise<TransactionReceipt> {\n const message =\n typeof payload === 'string' ? payload : JSON.stringify(payload);\n\n const payloadSizeInBytes = Buffer.byteLength(message, 'utf8');\n if (payloadSizeInBytes > 1000) {\n throw new PayloadSizeError(\n 'Payload size exceeds 1000 bytes limit',\n payloadSizeInBytes\n );\n }\n\n const transaction = new TopicMessageSubmitTransaction()\n .setTopicId(TopicId.fromString(topicId))\n .setMessage(message);\n\n if (requiresFee) {\n this.logger.info(\n 'Topic requires fee payment, setting max transaction fee'\n );\n transaction.setMaxTransactionFee(new Hbar(this.feeAmount));\n }\n\n let transactionResponse: TransactionResponse;\n if (submitKey) {\n const frozenTransaction = transaction.freezeWith(this.client);\n const signedTransaction = await frozenTransaction.sign(submitKey);\n transactionResponse = await signedTransaction.execute(this.client);\n } else {\n transactionResponse = await transaction.execute(this.client);\n }\n\n const receipt = await transactionResponse.getReceipt(this.client);\n if (!receipt) {\n this.logger.error('Failed to submit message: receipt is null');\n throw new Error('Failed to submit message: receipt is null');\n }\n this.logger.info('Message submitted successfully');\n return receipt;\n }\n\n async inscribeFile(\n buffer: Buffer,\n fileName: string,\n options?: {\n progressCallback?: RegistrationProgressCallback;\n waitMaxAttempts?: number;\n waitIntervalMs?: number;\n }\n ): Promise<RetrievedInscriptionResult> {\n this.logger.info('Inscribing file');\n if (!this.client.operatorAccountId) {\n this.logger.error('Operator account ID is not set');\n throw new Error('Operator account ID is not set');\n }\n\n if (!this.operatorPrivateKey) {\n this.logger.error('Operator private key is not set');\n throw new Error('Operator private key is not set');\n }\n\n const mimeType = mime.lookup(fileName) || 'application/octet-stream';\n\n const sdk = await InscriptionSDK.createWithAuth({\n type: 'server',\n accountId: this.client.operatorAccountId.toString(),\n privateKey: this.operatorPrivateKey.toString(),\n network: this.network as 'testnet' | 'mainnet',\n });\n\n const inscriptionOptions = {\n mode: 'file' as const,\n waitForConfirmation: true,\n waitMaxAttempts: options?.waitMaxAttempts || 30,\n waitIntervalMs: options?.waitIntervalMs || 4000,\n progressCallback: options?.progressCallback,\n logging: {\n level: this.logger.getLevel ? this.logger.getLevel() : 'info',\n },\n };\n\n const response = await inscribe(\n {\n type: 'buffer',\n buffer,\n fileName,\n mimeType,\n },\n {\n accountId: this.client.operatorAccountId.toString(),\n privateKey: this.operatorPrivateKey.toString(),\n network: this.network as 'testnet' | 'mainnet',\n },\n inscriptionOptions,\n sdk\n );\n\n if (!response.confirmed || !response.inscription) {\n throw new Error('Inscription was not confirmed');\n }\n\n return response.inscription;\n }\n\n /**\n * Waits for confirmation of a connection request\n * @param inboundTopicId Inbound topic ID\n * @param connectionRequestId Connection request ID\n * @param maxAttempts Maximum number of attempts\n * @param delayMs Delay between attempts in milliseconds\n * @returns Connection confirmation details\n */\n async waitForConnectionConfirmation(\n inboundTopicId: string,\n connectionRequestId: number,\n maxAttempts = 60,\n delayMs = 2000,\n recordConfirmation = true\n ): Promise<WaitForConnectionConfirmationResponse> {\n this.logger.info(\n `Waiting for connection confirmation on inbound topic ${inboundTopicId} for request ID ${connectionRequestId}`\n );\n\n for (let attempt = 0; attempt < maxAttempts; attempt++) {\n this.logger.info(\n `Attempt ${attempt + 1}/${maxAttempts} to find connection confirmation`\n );\n const messages = await this.mirrorNode.getTopicMessages(inboundTopicId);\n\n const connectionCreatedMessages = messages.filter(\n (m) => m.op === 'connection_created'\n );\n\n this.logger.info(\n `Found ${connectionCreatedMessages.length} connection_created messages`\n );\n\n if (connectionCreatedMessages.length > 0) {\n for (const message of connectionCreatedMessages) {\n if (Number(message.connection_id) === Number(connectionRequestId)) {\n const confirmationResult = {\n connectionTopicId: message.connection_topic_id,\n sequence_number: Number(message.sequence_number),\n confirmedBy: message.operator_id,\n memo: message.m,\n };\n\n const confirmedByAccountId = this.extractAccountFromOperatorId(\n confirmationResult.confirmedBy\n );\n\n const account = this.getAccountAndSigner();\n const confirmedByConnectionTopics =\n await this.retrieveCommunicationTopics(confirmedByAccountId);\n\n const agentConnectionTopics =\n await this.retrieveCommunicationTopics(account.accountId);\n\n this.logger.info(\n 'Connection confirmation found',\n confirmationResult\n );\n\n if (recordConfirmation) {\n /**\n * Record's the confirmation of the connection request from the\n * confirmedBy account to the agent account.\n */\n await this.recordOutboundConnectionConfirmation({\n requestorOutboundTopicId:\n confirmedByConnectionTopics.outboundTopic,\n outboundTopicId: agentConnectionTopics.outboundTopic,\n connectionRequestId,\n confirmedRequestId: confirmationResult.sequence_number,\n connectionTopicId: confirmationResult.connectionTopicId,\n operatorId: confirmationResult.confirmedBy,\n memo: confirmationResult.memo || 'Connection confirmed',\n });\n }\n\n return confirmationResult;\n }\n }\n }\n\n if (attempt < maxAttempts - 1) {\n this.logger.info(\n `No matching confirmation found, waiting ${delayMs}ms before retrying...`\n );\n await new Promise((resolve) => setTimeout(resolve, delayMs));\n }\n }\n\n throw new Error(\n `Connection confirmation not found after ${maxAttempts} attempts for request ID ${connectionRequestId}`\n );\n }\n\n getAccountAndSigner(): GetAccountAndSignerResponse {\n return {\n accountId: this.client.operatorAccountId!.toString()!,\n signer: this.operatorPrivateKey,\n };\n }\n\n /**\n * Creates and registers an agent with a Guarded registry.\n *\n * This function performs the following steps:\n * 1. Creates a new account if no existing account is provided.\n * 2. Initializes an HCS10 client with the new account.\n * 3. Creates an agent on the client.\n * 4. Registers the agent with the Hashgraph Online Guarded Registry.\n *\n * @param builder The agent builder object\n * @param options Optional configuration including progress callback and state management\n * @returns Agent registration result\n */\n async createAndRegisterAgent(\n builder: AgentBuilder,\n options?: {\n baseUrl?: string;\n progressCallback?: RegistrationProgressCallback;\n existingState?: AgentCreationState;\n initialBalance?: number;\n }\n ): Promise<AgentRegistrationResult> {\n try {\n const config = builder.build();\n const progressCallback = options?.progressCallback;\n const baseUrl = options?.baseUrl || this.guardedRegistryBaseUrl;\n let state = options?.existingState || undefined;\n\n if (progressCallback) {\n progressCallback({\n stage: 'preparing',\n message: 'Preparing agent registration',\n progressPercent: 10,\n details: { state },\n });\n }\n\n const account =\n config.existingAccount ||\n (await this.createAccount(options?.initialBalance));\n\n if (progressCallback) {\n progressCallback({\n stage: 'preparing',\n message: 'Created account or using existing account',\n progressPercent: 20,\n details: { state, account },\n });\n }\n\n const agentClient = new HCS10Client({\n network: config.network,\n operatorId: account.accountId,\n operatorPrivateKey: account.privateKey,\n operatorPublicKey: PrivateKey.fromString(\n account.privateKey\n ).publicKey.toString(),\n logLevel: 'info' as LogLevel,\n guardedRegistryBaseUrl: baseUrl,\n });\n\n if (progressCallback) {\n progressCallback({\n stage: 'preparing',\n message: 'Initialized agent client',\n progressPercent: 30,\n details: { state },\n });\n }\n\n const { outboundTopicId, inboundTopicId, pfpTopicId, profileTopicId } =\n await agentClient.createAgent(builder);\n\n if (progressCallback) {\n progressCallback({\n stage: 'submitting',\n message: 'Created agent with topics and profile',\n progressPercent: 60,\n details: {\n state,\n outboundTopicId,\n inboundTopicId,\n pfpTopicId,\n profileTopicId,\n },\n });\n }\n\n const operatorId = `${inboundTopicId}@${account.accountId}`;\n\n const registrationResult =\n await agentClient.registerAgentWithGuardedRegistry(\n account.accountId,\n config.network,\n {\n progressCallback: (data) => {\n const adjustedPercent = 60 + (data.progressPercent || 0) * 0.4;\n if (progressCallback) {\n progressCallback({\n stage: data.stage,\n message: data.message,\n progressPercent: adjustedPercent,\n details: {\n ...data.details,\n outboundTopicId,\n inboundTopicId,\n pfpTopicId,\n profileTopicId,\n operatorId,\n state: data.details?.state || state,\n },\n });\n }\n },\n existingState: state,\n }\n );\n\n if (!registrationResult.success) {\n return registrationResult;\n }\n\n if (progressCallback) {\n progressCallback({\n stage: 'completed',\n message: 'Agent creation and registration complete',\n progressPercent: 100,\n details: {\n outboundTopicId,\n inboundTopicId,\n pfpTopicId,\n profileTopicId,\n operatorId,\n state: registrationResult.state,\n },\n });\n }\n\n return {\n ...registrationResult,\n metadata: {\n accountId: account.accountId,\n privateKey: account.privateKey,\n operatorId,\n inboundTopicId,\n outboundTopicId,\n profileTopicId,\n pfpTopicId,\n },\n };\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Failed to create and register agent: ${error.message}`;\n this.logger.error(logMessage);\n return {\n error: error.message,\n success: false,\n };\n }\n }\n\n /**\n * Registers an agent with the guarded registry\n * @param accountId Account ID to register\n * @param inboundTopicId Inbound topic ID for the agent\n * @param network Network type ('mainnet' or 'testnet')\n * @param options Optional configuration including progress callback and confirmation settings\n * @returns Registration result\n */\n async registerAgentWithGuardedRegistry(\n accountId: string,\n network: string = this.network,\n options?: {\n progressCallback?: RegistrationProgressCallback;\n maxAttempts?: number;\n delayMs?: number;\n existingState?: AgentCreationState;\n }\n ): Promise<AgentRegistrationResult> {\n try {\n this.logger.info('Registering agent with guarded registry');\n\n const maxAttempts = options?.maxAttempts ?? 60;\n const delayMs = options?.delayMs ?? 2000;\n const progressCallback = options?.progressCallback;\n let state =\n options?.existingState ||\n ({\n currentStage: 'registration',\n completedPercentage: 0,\n createdResources: [],\n } as AgentCreationState);\n\n if (progressCallback) {\n progressCallback({\n stage: 'preparing',\n message: 'Preparing agent registration',\n progressPercent: 10,\n details: {\n state,\n },\n });\n }\n\n const registrationResult = await this.executeRegistration(\n accountId,\n network,\n this.guardedRegistryBaseUrl,\n this.logger\n );\n\n if (!registrationResult.success) {\n return {\n ...registrationResult,\n state,\n };\n }\n\n if (progressCallback) {\n progressCallback({\n stage: 'submitting',\n message: 'Submitting registration to registry',\n progressPercent: 30,\n details: {\n transactionId: registrationResult.transactionId,\n state,\n },\n });\n }\n\n if (registrationResult.transaction) {\n const transaction = Transaction.fromBytes(\n Buffer.from(registrationResult.transaction, 'base64')\n );\n\n this.logger.info(`Processing registration transaction`);\n await transaction.execute(this.client);\n this.logger.info(`Successfully processed registration transaction`);\n }\n\n if (progressCallback) {\n progressCallback({\n stage: 'confirming',\n message: 'Confirming registration transaction',\n progressPercent: 60,\n details: {\n accountId,\n transactionId: registrationResult.transactionId,\n state,\n },\n });\n }\n\n const confirmed = await this.waitForRegistrationConfirmation(\n registrationResult.transactionId!,\n network,\n this.guardedRegistryBaseUrl,\n maxAttempts,\n delayMs,\n this.logger\n );\n\n state.currentStage = 'complete';\n state.completedPercentage = 100;\n if (!state.createdResources) {\n state.createdResources = [];\n }\n if (registrationResult.transactionId) {\n state.createdResources.push(\n `registration:${registrationResult.transactionId}`\n );\n }\n\n if (progressCallback) {\n progressCallback({\n stage: 'completed',\n message: 'Agent registration complete',\n progressPercent: 100,\n details: {\n confirmed,\n transactionId: registrationResult.transactionId,\n state,\n },\n });\n }\n\n return {\n ...registrationResult,\n confirmed,\n state,\n };\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Failed to register agent: ${error.message}`;\n this.logger.error(logMessage);\n return {\n error: error.message,\n success: false,\n };\n }\n }\n\n /**\n * Registers an agent with the guarded registry. Should be called by a registry.\n * @param registryTopicId - The topic ID of the guarded registry.\n * @param accountId - The account ID of the agent\n * @param inboundTopicId - The topic ID of the inbound topic\n * @param memo - The memo of the agent\n * @param submitKey - The submit key of the agent\n */\n async registerAgent(\n registryTopicId: string,\n accountId: string,\n inboundTopicId: string,\n memo: string,\n submitKey?: PrivateKey\n ): Promise<void> {\n this.logger.info('Registering agent');\n const payload = {\n p: 'hcs-10',\n op: 'register',\n account_id: accountId,\n inbound_topic_id: inboundTopicId,\n m: memo,\n };\n\n await this.submitPayload(registryTopicId, payload, submitKey);\n }\n\n async getInboundTopicType(topicId: string): Promise<InboundTopicType> {\n try {\n const topicInfo = await this.mirrorNode.getTopicInfo(topicId);\n\n if (!topicInfo) {\n throw new Error('Topic does not exist');\n }\n\n const hasSubmitKey = topicInfo.submit_key && topicInfo.submit_key.key;\n\n if (!hasSubmitKey) {\n return InboundTopicType.PUBLIC;\n }\n\n const hasFeeScheduleKey =\n topicInfo.fee_schedule_key && topicInfo.fee_schedule_key.key;\n\n if (hasFeeScheduleKey && topicInfo.custom_fees) {\n const customFees = topicInfo.custom_fees;\n\n if (\n customFees &&\n customFees.fixed_fees &&\n customFees.fixed_fees.length > 0\n ) {\n this.logger.info(\n `Topic ${topicId} is fee-based with ${customFees.fixed_fees.length} custom fees`\n );\n return InboundTopicType.FEE_BASED;\n }\n }\n\n return InboundTopicType.CONTROLLED;\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Error determining topic type: ${error.message}`;\n this.logger.error(logMessage);\n throw new Error(logMessage);\n }\n }\n\n getNetwork(): string {\n return this.network;\n }\n\n getLogger(): Logger {\n return this.logger;\n }\n\n /**\n * Public method to get the operator account ID configured for this client instance.\n * @returns The operator account ID string, or null if not set.\n */\n getOperatorAccountId(): string | null {\n return this.client.operatorAccountId?.toString() ?? null;\n }\n\n /**\n * Creates a scheduled transaction from a transaction object\n * @param transaction The transaction to schedule\n * @param memo Optional memo to include with the scheduled transaction\n * @param expirationTime Optional expiration time in seconds from now\n * @returns Object with schedule ID and transaction ID\n */\n private async createScheduledTransaction(\n transaction: Transaction,\n memo?: string,\n expirationTime?: number,\n schedulePayerAccountId?: string\n ): Promise<{\n scheduleId: string;\n transactionId: string;\n }> {\n this.logger.info('Creating scheduled transaction');\n\n const scheduleTransaction = new ScheduleCreateTransaction()\n .setScheduledTransaction(transaction)\n .setPayerAccountId(\n schedulePayerAccountId\n ? AccountId.fromString(schedulePayerAccountId)\n : this.client.operatorAccountId\n );\n\n if (memo) {\n scheduleTransaction.setScheduleMemo(memo);\n }\n\n if (expirationTime) {\n const expirationDate = addSeconds(new Date(), expirationTime);\n const timestamp = Timestamp.fromDate(expirationDate);\n scheduleTransaction.setExpirationTime(timestamp);\n }\n\n this.logger.debug('Executing schedule create transaction');\n const scheduleResponse = await scheduleTransaction.execute(this.client);\n const scheduleReceipt = await scheduleResponse.getReceipt(this.client);\n\n if (!scheduleReceipt.scheduleId) {\n this.logger.error(\n 'Failed to create scheduled transaction: scheduleId is null'\n );\n throw new Error(\n 'Failed to create scheduled transaction: scheduleId is null'\n );\n }\n\n const scheduleId = scheduleReceipt.scheduleId.toString();\n const transactionId = scheduleResponse.transactionId.toString();\n\n this.logger.info(\n `Scheduled transaction created successfully: ${scheduleId}`\n );\n\n return {\n scheduleId,\n transactionId,\n };\n }\n\n /**\n * Sends a transaction operation on a connection topic\n * @param connectionTopicId Connection topic ID\n * @param scheduleId Schedule ID of the scheduled transaction\n * @param data Human-readable description of the transaction, can also be a JSON string or HRL\n * @param submitKey Optional submit key\n * @param options Optional parameters including memo (timestamp is no longer used here)\n * @returns Transaction receipt\n */\n private async sendTransactionOperation(\n connectionTopicId: string,\n scheduleId: string,\n data: string,\n submitKey?: PrivateKey,\n options?: {\n memo?: string;\n }\n ): Promise<TransactionReceipt> {\n const submissionCheck = await this.canSubmitToTopic(\n connectionTopicId,\n this.client.operatorAccountId?.toString() || ''\n );\n\n const operatorId = await this.getOperatorId();\n\n const payload = {\n p: 'hcs-10',\n op: 'transaction',\n operator_id: operatorId,\n schedule_id: scheduleId,\n data,\n m: options?.memo,\n };\n\n this.logger.info(\n 'Submitting transaction operation to connection topic',\n payload\n );\n return await this.submitPayload(\n connectionTopicId,\n payload,\n submitKey,\n submissionCheck.requiresFee\n );\n }\n\n /**\n * Creates and sends a transaction operation in one call\n * @param connectionTopicId Connection topic ID for sending the transaction operation\n * @param transaction The transaction to schedule\n * @param data Human-readable description of the transaction, can also be a JSON string or HRL\n * @param options Optional parameters for schedule creation and operation memo\n * @returns Object with schedule details (including scheduleId and its transactionId) and HCS-10 operation receipt\n */\n async sendTransaction(\n connectionTopicId: string,\n transaction: Transaction,\n data: string,\n options?: {\n scheduleMemo?: string;\n expirationTime?: number;\n submitKey?: PrivateKey;\n operationMemo?: string;\n schedulePayerAccountId?: string;\n }\n ): Promise<{\n scheduleId: string;\n transactionId: string;\n receipt: TransactionReceipt;\n }> {\n this.logger.info(\n 'Creating scheduled transaction and sending transaction operation'\n );\n\n const { scheduleId, transactionId } = await this.createScheduledTransaction(\n transaction,\n options?.scheduleMemo,\n options?.expirationTime,\n options?.schedulePayerAccountId\n );\n\n const receipt = await this.sendTransactionOperation(\n connectionTopicId,\n scheduleId,\n data,\n options?.submitKey,\n {\n memo: options?.operationMemo,\n }\n );\n\n return {\n scheduleId,\n transactionId,\n receipt,\n };\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;AA+DO,MAAM,oBAAoB,gBAAgB;AAAA,EAQ/C,YAAY,QAAyB;AAC7B,UAAA;AAAA,MACJ,SAAS,OAAO;AAAA,MAChB,UAAU,OAAO;AAAA,MACjB,aAAa,OAAO;AAAA,MACpB,WAAW,OAAO;AAAA,MAClB,YAAY,OAAO;AAAA,IAAA,CACpB;AACI,SAAA,SACH,OAAO,YAAY,YAAY,OAAO,WAAW,IAAI,OAAO,WAAW;AACzE,SAAK,qBAAqB,WAAW,WAAW,OAAO,kBAAkB;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;AAAA,IACF;AAEA,UAAM,EAAE,YAAY,kBAAkB,MAAM,KAAK;AAAA,MAC/C;AAAA,MACA,SAAS;AAAA,MACT,SAAS;AAAA,MACT,SAAS;AAAA,IACX;AAEM,UAAA,UAAU,MAAM,KAAK;AAAA,MACzB;AAAA,MACA;AAAA,MACA;AAAA,MACA,SAAS;AAAA,MACT;AAAA,QACE,MAAM,SAAS;AAAA,MAAA;AAAA,IAEnB;AAEO,WAAA;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EAAA;AAEJ;"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import Buffer from "vite-plugin-node-polyfills/shims/buffer";
|
|
2
1
|
import { KeyList, TopicCreateTransaction, AccountId, Transaction, TopicMessageSubmitTransaction, Hbar } from "@hashgraph/sdk";
|
|
3
2
|
import { Logger } from "./standards-sdk.es15.js";
|
|
4
3
|
import { I as InscriptionSDK } from "./standards-sdk.es24.js";
|