@hashgraphonline/standards-sdk 0.0.115 → 0.0.117

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/dist/cjs/hcs-10/base-client.d.ts +2 -0
  2. package/dist/cjs/hcs-10/base-client.d.ts.map +1 -1
  3. package/dist/cjs/hcs-10/sdk.d.ts +9 -1
  4. package/dist/cjs/hcs-10/sdk.d.ts.map +1 -1
  5. package/dist/cjs/hcs-10/types.d.ts +2 -0
  6. package/dist/cjs/hcs-10/types.d.ts.map +1 -1
  7. package/dist/cjs/hcs-11/client.d.ts +4 -0
  8. package/dist/cjs/hcs-11/client.d.ts.map +1 -1
  9. package/dist/cjs/hcs-11/types.d.ts +1 -0
  10. package/dist/cjs/hcs-11/types.d.ts.map +1 -1
  11. package/dist/cjs/index-CHS2J8pS.cjs +11 -0
  12. package/dist/cjs/index-CHS2J8pS.cjs.map +1 -0
  13. package/dist/cjs/{index-CHar8dVv-SvZhHmF3.cjs → index-CHar8dVv-B2IK-7-2.cjs} +2 -2
  14. package/dist/cjs/{index-CHar8dVv-SvZhHmF3.cjs.map → index-CHar8dVv-B2IK-7-2.cjs.map} +1 -1
  15. package/dist/cjs/standards-sdk.cjs +1 -1
  16. package/dist/cjs/utils/index.d.ts +1 -0
  17. package/dist/cjs/utils/index.d.ts.map +1 -1
  18. package/dist/cjs/utils/key-type-detector.d.ts +14 -0
  19. package/dist/cjs/utils/key-type-detector.d.ts.map +1 -0
  20. package/dist/es/hcs-10/base-client.d.ts +2 -0
  21. package/dist/es/hcs-10/base-client.d.ts.map +1 -1
  22. package/dist/es/hcs-10/sdk.d.ts +9 -1
  23. package/dist/es/hcs-10/sdk.d.ts.map +1 -1
  24. package/dist/es/hcs-10/types.d.ts +2 -0
  25. package/dist/es/hcs-10/types.d.ts.map +1 -1
  26. package/dist/es/hcs-11/client.d.ts +4 -0
  27. package/dist/es/hcs-11/client.d.ts.map +1 -1
  28. package/dist/es/hcs-11/types.d.ts +1 -0
  29. package/dist/es/hcs-11/types.d.ts.map +1 -1
  30. package/dist/es/standards-sdk.es.js +6 -4
  31. package/dist/es/standards-sdk.es.js.map +1 -1
  32. package/dist/es/standards-sdk.es13.js +42 -5
  33. package/dist/es/standards-sdk.es13.js.map +1 -1
  34. package/dist/es/standards-sdk.es14.js.map +1 -1
  35. package/dist/es/standards-sdk.es16.js +1 -1
  36. package/dist/es/standards-sdk.es19.js +6 -6
  37. package/dist/es/standards-sdk.es20.js +23 -400
  38. package/dist/es/standards-sdk.es20.js.map +1 -1
  39. package/dist/es/standards-sdk.es21.js +380 -1506
  40. package/dist/es/standards-sdk.es21.js.map +1 -1
  41. package/dist/es/standards-sdk.es22.js +1511 -133
  42. package/dist/es/standards-sdk.es22.js.map +1 -1
  43. package/dist/es/standards-sdk.es23.js +155 -7
  44. package/dist/es/standards-sdk.es23.js.map +1 -1
  45. package/dist/es/standards-sdk.es24.js +7 -7190
  46. package/dist/es/standards-sdk.es24.js.map +1 -1
  47. package/dist/es/standards-sdk.es25.js +7190 -2
  48. package/dist/es/standards-sdk.es25.js.map +1 -1
  49. package/dist/es/standards-sdk.es26.js +2 -501
  50. package/dist/es/standards-sdk.es26.js.map +1 -1
  51. package/dist/es/standards-sdk.es27.js +457 -65
  52. package/dist/es/standards-sdk.es27.js.map +1 -1
  53. package/dist/es/standards-sdk.es28.js +80 -37
  54. package/dist/es/standards-sdk.es28.js.map +1 -1
  55. package/dist/es/standards-sdk.es29.js +33 -223
  56. package/dist/es/standards-sdk.es29.js.map +1 -1
  57. package/dist/es/standards-sdk.es30.js +184 -101
  58. package/dist/es/standards-sdk.es30.js.map +1 -1
  59. package/dist/es/standards-sdk.es31.js +167 -5
  60. package/dist/es/standards-sdk.es31.js.map +1 -1
  61. package/dist/es/standards-sdk.es32.js +8 -7132
  62. package/dist/es/standards-sdk.es32.js.map +1 -1
  63. package/dist/es/standards-sdk.es33.js +7134 -41
  64. package/dist/es/standards-sdk.es33.js.map +1 -1
  65. package/dist/es/standards-sdk.es34.js +45 -0
  66. package/dist/es/standards-sdk.es34.js.map +1 -0
  67. package/dist/es/standards-sdk.es5.js +4 -1
  68. package/dist/es/standards-sdk.es5.js.map +1 -1
  69. package/dist/es/standards-sdk.es7.js +71 -14
  70. package/dist/es/standards-sdk.es7.js.map +1 -1
  71. package/dist/es/standards-sdk.es8.js +2 -2
  72. package/dist/es/standards-sdk.es9.js +1 -1
  73. package/dist/es/utils/index.d.ts +1 -0
  74. package/dist/es/utils/index.d.ts.map +1 -1
  75. package/dist/es/utils/key-type-detector.d.ts +14 -0
  76. package/dist/es/utils/key-type-detector.d.ts.map +1 -0
  77. package/dist/umd/hcs-10/base-client.d.ts +2 -0
  78. package/dist/umd/hcs-10/base-client.d.ts.map +1 -1
  79. package/dist/umd/hcs-10/sdk.d.ts +9 -1
  80. package/dist/umd/hcs-10/sdk.d.ts.map +1 -1
  81. package/dist/umd/hcs-10/types.d.ts +2 -0
  82. package/dist/umd/hcs-10/types.d.ts.map +1 -1
  83. package/dist/umd/hcs-11/client.d.ts +4 -0
  84. package/dist/umd/hcs-11/client.d.ts.map +1 -1
  85. package/dist/umd/hcs-11/types.d.ts +1 -0
  86. package/dist/umd/hcs-11/types.d.ts.map +1 -1
  87. package/dist/umd/standards-sdk.umd.js +8 -8
  88. package/dist/umd/standards-sdk.umd.js.map +1 -1
  89. package/dist/umd/utils/index.d.ts +1 -0
  90. package/dist/umd/utils/index.d.ts.map +1 -1
  91. package/dist/umd/utils/key-type-detector.d.ts +14 -0
  92. package/dist/umd/utils/key-type-detector.d.ts.map +1 -0
  93. package/package.json +3 -4
  94. package/dist/cjs/index-CtGN9edr.cjs +0 -11
  95. package/dist/cjs/index-CtGN9edr.cjs.map +0 -1
@@ -0,0 +1,45 @@
1
+ import { ContractId } from "@hashgraph/sdk";
2
+ import { Buffer } from "buffer";
3
+ function parseKey(key) {
4
+ if (!key) {
5
+ return void 0;
6
+ }
7
+ if (key.contractID) {
8
+ return `ContractID: ${new ContractId(
9
+ key.contractID.shardNum ?? 0,
10
+ key.contractID.realmNum ?? 0,
11
+ key.contractID.contractNum ?? 0
12
+ ).toString()}`;
13
+ }
14
+ if (key.ed25519) {
15
+ return `ED25519: ${Buffer.from(key.ed25519).toString("hex")}`;
16
+ }
17
+ if (key.ECDSASecp256k1) {
18
+ return `ECDSA_secp256k1: ${Buffer.from(key.ECDSASecp256k1).toString(
19
+ "hex"
20
+ )}`;
21
+ }
22
+ if (key?.keyList?.keys?.length > 0) {
23
+ const keys = key.keyList.keys.map((k) => parseKey(k)).filter(Boolean);
24
+ return `KeyList (${keys.length} keys): [${keys.join(", ")}]`;
25
+ }
26
+ if (key?.thresholdKey?.keys?.keys?.length > 0) {
27
+ const keys = key.thresholdKey.keys.keys.map((k) => parseKey(k)).filter(Boolean);
28
+ return `ThresholdKey (${key.thresholdKey.threshold} of ${keys.length}): [${keys.join(", ")}]`;
29
+ }
30
+ if (key.delegatableContractId) {
31
+ return `DelegatableContractID: ${new ContractId(
32
+ key.delegatableContractId.shardNum ?? 0,
33
+ key.delegatableContractId.realmNum ?? 0,
34
+ key.delegatableContractId.contractNum ?? 0
35
+ ).toString()}`;
36
+ }
37
+ if (Object.keys(key).length === 0) {
38
+ return "Empty Key Structure";
39
+ }
40
+ return "Unknown or Unset Key Type";
41
+ }
42
+ export {
43
+ parseKey
44
+ };
45
+ //# sourceMappingURL=standards-sdk.es34.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"standards-sdk.es34.js","sources":["../../src/utils/parsers/parser-utils.ts"],"sourcesContent":["import { proto } from '@hashgraph/proto';\nimport { ContractId } from '@hashgraph/sdk';\nimport { Buffer } from 'buffer';\n\nexport function parseKey(\n key: proto.IKey | null | undefined,\n): string | undefined {\n if (!key) {\n return undefined;\n }\n\n if (key.contractID) {\n return `ContractID: ${new ContractId(\n key.contractID.shardNum ?? 0,\n key.contractID.realmNum ?? 0,\n key.contractID.contractNum ?? 0,\n ).toString()}`;\n }\n if (key.ed25519) {\n return `ED25519: ${Buffer.from(key.ed25519).toString('hex')}`;\n }\n if (key.ECDSASecp256k1) {\n return `ECDSA_secp256k1: ${Buffer.from(key.ECDSASecp256k1).toString(\n 'hex',\n )}`;\n }\n if (key?.keyList?.keys?.length > 0) {\n const keys = key.keyList.keys.map(k => parseKey(k)).filter(Boolean);\n return `KeyList (${keys.length} keys): [${keys.join(', ')}]`;\n }\n if (key?.thresholdKey?.keys?.keys?.length > 0) {\n const keys = key.thresholdKey.keys.keys\n .map(k => parseKey(k))\n .filter(Boolean);\n return `ThresholdKey (${key.thresholdKey.threshold} of ${\n keys.length\n }): [${keys.join(', ')}]`;\n }\n if (key.delegatableContractId) {\n return `DelegatableContractID: ${new ContractId(\n key.delegatableContractId.shardNum ?? 0,\n key.delegatableContractId.realmNum ?? 0,\n key.delegatableContractId.contractNum ?? 0,\n ).toString()}`;\n }\n if (Object.keys(key).length === 0) {\n return 'Empty Key Structure';\n }\n\n return 'Unknown or Unset Key Type';\n}\n"],"names":[],"mappings":";;AAIO,SAAS,SACd,KACoB;AACpB,MAAI,CAAC,KAAK;AACD,WAAA;AAAA,EAAA;AAGT,MAAI,IAAI,YAAY;AAClB,WAAO,eAAe,IAAI;AAAA,MACxB,IAAI,WAAW,YAAY;AAAA,MAC3B,IAAI,WAAW,YAAY;AAAA,MAC3B,IAAI,WAAW,eAAe;AAAA,IAAA,EAC9B,SAAU,CAAA;AAAA,EAAA;AAEd,MAAI,IAAI,SAAS;AACR,WAAA,YAAY,OAAO,KAAK,IAAI,OAAO,EAAE,SAAS,KAAK,CAAC;AAAA,EAAA;AAE7D,MAAI,IAAI,gBAAgB;AACtB,WAAO,oBAAoB,OAAO,KAAK,IAAI,cAAc,EAAE;AAAA,MACzD;AAAA,IAAA,CACD;AAAA,EAAA;AAEH,MAAI,KAAK,SAAS,MAAM,SAAS,GAAG;AAC5B,UAAA,OAAO,IAAI,QAAQ,KAAK,IAAI,CAAK,MAAA,SAAS,CAAC,CAAC,EAAE,OAAO,OAAO;AAClE,WAAO,YAAY,KAAK,MAAM,YAAY,KAAK,KAAK,IAAI,CAAC;AAAA,EAAA;AAE3D,MAAI,KAAK,cAAc,MAAM,MAAM,SAAS,GAAG;AAC7C,UAAM,OAAO,IAAI,aAAa,KAAK,KAChC,IAAI,CAAK,MAAA,SAAS,CAAC,CAAC,EACpB,OAAO,OAAO;AACV,WAAA,iBAAiB,IAAI,aAAa,SAAS,OAChD,KAAK,MACP,OAAO,KAAK,KAAK,IAAI,CAAC;AAAA,EAAA;AAExB,MAAI,IAAI,uBAAuB;AAC7B,WAAO,0BAA0B,IAAI;AAAA,MACnC,IAAI,sBAAsB,YAAY;AAAA,MACtC,IAAI,sBAAsB,YAAY;AAAA,MACtC,IAAI,sBAAsB,eAAe;AAAA,IAAA,EACzC,SAAU,CAAA;AAAA,EAAA;AAEd,MAAI,OAAO,KAAK,GAAG,EAAE,WAAW,GAAG;AAC1B,WAAA;AAAA,EAAA;AAGF,SAAA;AACT;"}
@@ -2,7 +2,7 @@ import { Logger } from "./standards-sdk.es15.js";
2
2
  import { Registration } from "./standards-sdk.es9.js";
3
3
  import { HCS11Client } from "./standards-sdk.es13.js";
4
4
  import { PublicKey } from "@hashgraph/sdk";
5
- import { HederaMirrorNode } from "./standards-sdk.es21.js";
5
+ import { HederaMirrorNode } from "./standards-sdk.es22.js";
6
6
  import { HRLResolver } from "./standards-sdk.es18.js";
7
7
  var Hcs10MemoType = /* @__PURE__ */ ((Hcs10MemoType2) => {
8
8
  Hcs10MemoType2["INBOUND"] = "inbound";
@@ -220,6 +220,9 @@ class HCS10BaseClient extends Registration {
220
220
  */
221
221
  async requestAccount(account) {
222
222
  try {
223
+ if (!account) {
224
+ throw new Error("Account ID is required");
225
+ }
223
226
  return await this.mirrorNode.requestAccount(account);
224
227
  } catch (e) {
225
228
  this.logger.error("Failed to fetch account", e);
@@ -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 /** Whether to run logger in silent mode */\n silent?: boolean;\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 silent: config.silent,\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 =\n await this.retrieveCommunicationTopics(agentAccountId);\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 =\n await this.retrieveInboundAccountId(inboundTopicId);\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;AAyFL,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,MACpB,QAAQ,OAAO;AAAA,IAAA,CAChB;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,I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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
+ {"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 /** Whether to run logger in silent mode */\n silent?: boolean;\n /** The key type to use for the operator */\n keyType?: 'ed25519' | 'ecdsa';\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 silent: config.silent,\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 if (!account) {\n throw new Error('Account ID is required');\n }\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 =\n await this.retrieveCommunicationTopics(agentAccountId);\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 =\n await this.retrieveInboundAccountId(inboundTopicId);\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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AA;AAEtB,WAAA;AAAA,EAAA;AAAA,EAGT,QAAc;AACZ,SAAK,MAAM,MAAM;AACjB,SAAK,YAAY,MAAM;AAAA,EAAA;AAE3B;"}
@@ -1,13 +1,18 @@
1
1
  import { Client, PrivateKey, AccountCreateTransaction, Hbar, CustomFixedFee, AccountId, TokenId, KeyList, TopicCreateTransaction, PublicKey, TopicMessageSubmitTransaction, TopicId, Transaction, ScheduleCreateTransaction, Timestamp } from "@hashgraph/sdk";
2
2
  import { AccountCreationError, TopicCreationError, ConnectionConfirmationError, PayloadSizeError } from "./standards-sdk.es6.js";
3
- import { I as InscriptionSDK } from "./standards-sdk.es24.js";
3
+ import { I as InscriptionSDK } from "./standards-sdk.es25.js";
4
4
  import { Logger } from "./standards-sdk.es15.js";
5
+ import { accountIdsToExemptKeys } from "./standards-sdk.es16.js";
6
+ import "axios";
7
+ import "@hashgraph/proto";
8
+ import "buffer";
9
+ import "ethers";
10
+ import { detectKeyTypeFromString } from "./standards-sdk.es20.js";
5
11
  import { HCS10BaseClient, Hcs10MemoType } from "./standards-sdk.es5.js";
6
12
  import * as mime from "mime-types";
7
13
  import { InboundTopicType } from "./standards-sdk.es14.js";
8
14
  import { HCS11Client } from "./standards-sdk.es13.js";
9
- import { accountIdsToExemptKeys } from "./standards-sdk.es16.js";
10
- import { inscribe } from "./standards-sdk.es20.js";
15
+ import { inscribe } from "./standards-sdk.es21.js";
11
16
  import { addSeconds } from "date-fns";
12
17
  class HCS10Client extends HCS10BaseClient {
13
18
  constructor(config) {
@@ -17,15 +22,30 @@ class HCS10Client extends HCS10BaseClient {
17
22
  prettyPrint: config.prettyPrint,
18
23
  feeAmount: config.feeAmount,
19
24
  mirrorNode: config.mirrorNode,
20
- silent: config.silent
25
+ silent: config.silent,
26
+ keyType: config.keyType
21
27
  });
22
28
  this.client = config.network === "mainnet" ? Client.forMainnet() : Client.forTestnet();
23
- this.operatorPrivateKey = PrivateKey.fromString(config.operatorPrivateKey);
29
+ this.operatorPrivateKey = config.operatorPrivateKey;
30
+ this.operatorAccountId = config.operatorId;
31
+ if (config.keyType) {
32
+ this.keyType = config.keyType;
33
+ const PK = this.keyType === "ecdsa" ? PrivateKey.fromStringECDSA(this.operatorPrivateKey) : PrivateKey.fromStringED25519(this.operatorPrivateKey);
34
+ this.client.setOperator(config.operatorId, PK);
35
+ } else {
36
+ try {
37
+ const keyDetection = detectKeyTypeFromString(this.operatorPrivateKey);
38
+ this.client.setOperator(config.operatorId, keyDetection.privateKey);
39
+ this.keyType = keyDetection.detectedType;
40
+ } catch (error) {
41
+ this.logger.warn(
42
+ "Failed to detect key type from private key format, will query mirror node"
43
+ );
44
+ this.keyType = "ed25519";
45
+ }
46
+ this.initializeOperator();
47
+ }
24
48
  this.network = config.network;
25
- this.client.setOperator(
26
- config.operatorId,
27
- this.operatorPrivateKey.toString()
28
- );
29
49
  this.logger = Logger.getInstance({
30
50
  level: config.logLevel || "info",
31
51
  module: "HCS-SDK",
@@ -39,9 +59,32 @@ class HCS10Client extends HCS10BaseClient {
39
59
  privateKey: config.operatorPrivateKey
40
60
  },
41
61
  logLevel: config.logLevel,
42
- silent: config.silent
62
+ silent: config.silent,
63
+ keyType: config.keyType
43
64
  });
44
65
  }
66
+ async initializeOperator() {
67
+ const account = await this.requestAccount(this.operatorAccountId);
68
+ const keyType = account?.key?._type;
69
+ if (keyType.includes("ECDSA")) {
70
+ this.keyType = "ecdsa";
71
+ } else if (keyType.includes("ED25519")) {
72
+ this.keyType = "ed25519";
73
+ } else {
74
+ this.keyType = "ed25519";
75
+ }
76
+ const PK = this.keyType === "ecdsa" ? PrivateKey.fromStringECDSA(this.operatorPrivateKey) : PrivateKey.fromStringED25519(this.operatorPrivateKey);
77
+ this.logger.debug(
78
+ `Setting operator: ${this.operatorId} with key type: ${this.keyType}`
79
+ );
80
+ this.client.setOperator(this.operatorAccountId, PK);
81
+ return {
82
+ accountId: this.operatorAccountId,
83
+ privateKey: this.operatorPrivateKey,
84
+ keyType: this.keyType,
85
+ client: this.client
86
+ };
87
+ }
45
88
  getClient() {
46
89
  return this.client;
47
90
  }
@@ -51,11 +94,14 @@ class HCS10Client extends HCS10BaseClient {
51
94
  * @returns Object with account ID and private key
52
95
  */
53
96
  async createAccount(initialBalance = 50) {
97
+ if (!this.keyType) {
98
+ await this.initializeOperator();
99
+ }
54
100
  this.logger.info(
55
101
  `Creating new account with ${initialBalance} HBAR initial balance`
56
102
  );
57
- const newKey = PrivateKey.generate();
58
- const accountTransaction = new AccountCreateTransaction().setKey(newKey.publicKey).setInitialBalance(new Hbar(initialBalance));
103
+ const newKey = PrivateKey.generateED25519();
104
+ const accountTransaction = new AccountCreateTransaction().setKeyWithoutAlias(newKey.publicKey).setInitialBalance(new Hbar(initialBalance));
59
105
  this.logger.debug("Executing account creation transaction");
60
106
  const accountResponse = await accountTransaction.execute(this.client);
61
107
  const accountReceipt = await accountResponse.getReceipt(this.client);
@@ -83,6 +129,9 @@ class HCS10Client extends HCS10BaseClient {
83
129
  * @returns The topic ID of the created inbound topic
84
130
  */
85
131
  async createInboundTopic(accountId, topicType, ttl = 60, feeConfigBuilder) {
132
+ if (!this.keyType) {
133
+ await this.initializeOperator();
134
+ }
86
135
  const memo = this._generateHcs10Memo(Hcs10MemoType.INBOUND, {
87
136
  accountId,
88
137
  ttl
@@ -127,6 +176,9 @@ class HCS10Client extends HCS10BaseClient {
127
176
  * @returns Object with topic IDs
128
177
  */
129
178
  async createAgent(builder, ttl = 60, existingState) {
179
+ if (!this.keyType) {
180
+ await this.initializeOperator();
181
+ }
130
182
  const config = builder.build();
131
183
  let outboundTopicId = existingState?.outboundTopicId || "";
132
184
  let inboundTopicId = existingState?.inboundTopicId || "";
@@ -752,9 +804,10 @@ class HCS10Client extends HCS10BaseClient {
752
804
  );
753
805
  }
754
806
  getAccountAndSigner() {
807
+ const PK = this.keyType === "ecdsa" ? PrivateKey.fromStringECDSA(this.operatorPrivateKey) : PrivateKey.fromStringED25519(this.operatorPrivateKey);
755
808
  return {
756
809
  accountId: this.client.operatorAccountId.toString(),
757
- signer: this.operatorPrivateKey
810
+ signer: PK
758
811
  };
759
812
  }
760
813
  /**
@@ -848,7 +901,11 @@ class HCS10Client extends HCS10BaseClient {
848
901
  if (pfpTopicId) {
849
902
  builder.setExistingProfilePicture(pfpTopicId);
850
903
  }
851
- const createResult = await agentClient.createAgent(builder, 60, state);
904
+ const createResult = await agentClient.createAgent(
905
+ builder,
906
+ 60,
907
+ state
908
+ );
852
909
  outboundTopicId = createResult.outboundTopicId;
853
910
  inboundTopicId = createResult.inboundTopicId;
854
911
  pfpTopicId = createResult.pfpTopicId;