@hashgraphonline/standards-sdk 0.0.68 → 0.0.70

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 (219) hide show
  1. package/README.md +13 -0
  2. package/dist/es/fees/fee-config-builder.d.ts +93 -45
  3. package/dist/es/fees/fee-config-builder.d.ts.map +1 -1
  4. package/dist/es/fees/types.d.ts +14 -12
  5. package/dist/es/fees/types.d.ts.map +1 -1
  6. package/dist/es/hcs-10/base-client.d.ts +8 -1
  7. package/dist/es/hcs-10/base-client.d.ts.map +1 -1
  8. package/dist/es/hcs-10/browser.d.ts.map +1 -1
  9. package/dist/es/hcs-10/sdk.d.ts +9 -1
  10. package/dist/es/hcs-10/sdk.d.ts.map +1 -1
  11. package/dist/es/services/mirror-node.d.ts +74 -1
  12. package/dist/es/services/mirror-node.d.ts.map +1 -1
  13. package/dist/es/services/types.d.ts +29 -0
  14. package/dist/es/services/types.d.ts.map +1 -1
  15. package/dist/es/standards-sdk.es.js +2 -0
  16. package/dist/es/standards-sdk.es.js.map +1 -1
  17. package/dist/es/standards-sdk.es100.js +60 -3
  18. package/dist/es/standards-sdk.es100.js.map +1 -1
  19. package/dist/es/standards-sdk.es101.js +1286 -13
  20. package/dist/es/standards-sdk.es101.js.map +1 -1
  21. package/dist/es/standards-sdk.es102.js +147 -4
  22. package/dist/es/standards-sdk.es102.js.map +1 -1
  23. package/dist/es/standards-sdk.es103.js +91 -39
  24. package/dist/es/standards-sdk.es103.js.map +1 -1
  25. package/dist/es/standards-sdk.es104.js +80 -36
  26. package/dist/es/standards-sdk.es104.js.map +1 -1
  27. package/dist/es/standards-sdk.es105.js +31 -36
  28. package/dist/es/standards-sdk.es105.js.map +1 -1
  29. package/dist/es/standards-sdk.es106.js +6 -78
  30. package/dist/es/standards-sdk.es106.js.map +1 -1
  31. package/dist/es/standards-sdk.es107.js +159 -2282
  32. package/dist/es/standards-sdk.es107.js.map +1 -1
  33. package/dist/es/standards-sdk.es108.js +23 -3
  34. package/dist/es/standards-sdk.es108.js.map +1 -1
  35. package/dist/es/standards-sdk.es109.js +793 -2
  36. package/dist/es/standards-sdk.es109.js.map +1 -1
  37. package/dist/es/standards-sdk.es110.js +174 -2
  38. package/dist/es/standards-sdk.es110.js.map +1 -1
  39. package/dist/es/standards-sdk.es111.js +142 -33
  40. package/dist/es/standards-sdk.es111.js.map +1 -1
  41. package/dist/es/standards-sdk.es112.js +20 -32
  42. package/dist/es/standards-sdk.es112.js.map +1 -1
  43. package/dist/es/standards-sdk.es113.js +27 -9
  44. package/dist/es/standards-sdk.es113.js.map +1 -1
  45. package/dist/es/standards-sdk.es114.js +25 -33
  46. package/dist/es/standards-sdk.es114.js.map +1 -1
  47. package/dist/es/standards-sdk.es115.js +41 -0
  48. package/dist/es/standards-sdk.es115.js.map +1 -0
  49. package/dist/es/standards-sdk.es12.js +3 -3
  50. package/dist/es/standards-sdk.es14.js +1 -1
  51. package/dist/es/standards-sdk.es17.js +2 -2
  52. package/dist/es/standards-sdk.es18.js +94 -6
  53. package/dist/es/standards-sdk.es18.js.map +1 -1
  54. package/dist/es/standards-sdk.es19.js +127 -67
  55. package/dist/es/standards-sdk.es19.js.map +1 -1
  56. package/dist/es/standards-sdk.es20.js +7 -1767
  57. package/dist/es/standards-sdk.es20.js.map +1 -1
  58. package/dist/es/standards-sdk.es21.js +1767 -3
  59. package/dist/es/standards-sdk.es21.js.map +1 -1
  60. package/dist/es/standards-sdk.es22.js +36 -4167
  61. package/dist/es/standards-sdk.es22.js.map +1 -1
  62. package/dist/es/standards-sdk.es23.js +48 -5
  63. package/dist/es/standards-sdk.es23.js.map +1 -1
  64. package/dist/es/standards-sdk.es24.js +6627 -36
  65. package/dist/es/standards-sdk.es24.js.map +1 -1
  66. package/dist/es/standards-sdk.es25.js +3 -48
  67. package/dist/es/standards-sdk.es25.js.map +1 -1
  68. package/dist/es/standards-sdk.es26.js +2 -6627
  69. package/dist/es/standards-sdk.es26.js.map +1 -1
  70. package/dist/es/standards-sdk.es27.js +1041 -2
  71. package/dist/es/standards-sdk.es27.js.map +1 -1
  72. package/dist/es/standards-sdk.es28.js +4086 -960
  73. package/dist/es/standards-sdk.es28.js.map +1 -1
  74. package/dist/es/standards-sdk.es29.js +5 -419
  75. package/dist/es/standards-sdk.es29.js.map +1 -1
  76. package/dist/es/standards-sdk.es30.js +419 -2
  77. package/dist/es/standards-sdk.es30.js.map +1 -1
  78. package/dist/es/standards-sdk.es31.js +2 -120
  79. package/dist/es/standards-sdk.es31.js.map +1 -1
  80. package/dist/es/standards-sdk.es32.js +119 -3
  81. package/dist/es/standards-sdk.es32.js.map +1 -1
  82. package/dist/es/standards-sdk.es33.js +3 -2
  83. package/dist/es/standards-sdk.es33.js.map +1 -1
  84. package/dist/es/standards-sdk.es34.js +164 -3
  85. package/dist/es/standards-sdk.es34.js.map +1 -1
  86. package/dist/es/standards-sdk.es35.js +1 -161
  87. package/dist/es/standards-sdk.es35.js.map +1 -1
  88. package/dist/es/standards-sdk.es36.js +2 -2
  89. package/dist/es/standards-sdk.es38.js +5 -5
  90. package/dist/es/standards-sdk.es4.js +1 -1
  91. package/dist/es/standards-sdk.es40.js +3 -3
  92. package/dist/es/standards-sdk.es46.js +1 -1
  93. package/dist/es/standards-sdk.es5.js +20 -3
  94. package/dist/es/standards-sdk.es5.js.map +1 -1
  95. package/dist/es/standards-sdk.es50.js +1 -1
  96. package/dist/es/standards-sdk.es51.js +3 -3
  97. package/dist/es/standards-sdk.es53.js +100 -22
  98. package/dist/es/standards-sdk.es53.js.map +1 -1
  99. package/dist/es/standards-sdk.es54.js +2 -174
  100. package/dist/es/standards-sdk.es54.js.map +1 -1
  101. package/dist/es/standards-sdk.es55.js +15 -90
  102. package/dist/es/standards-sdk.es55.js.map +1 -1
  103. package/dist/es/standards-sdk.es56.js +408 -5
  104. package/dist/es/standards-sdk.es56.js.map +1 -1
  105. package/dist/es/standards-sdk.es57.js +25 -136
  106. package/dist/es/standards-sdk.es57.js.map +1 -1
  107. package/dist/es/standards-sdk.es58.js +44 -176
  108. package/dist/es/standards-sdk.es58.js.map +1 -1
  109. package/dist/es/standards-sdk.es59.js +47 -435
  110. package/dist/es/standards-sdk.es59.js.map +1 -1
  111. package/dist/es/standards-sdk.es60.js +9 -24
  112. package/dist/es/standards-sdk.es60.js.map +1 -1
  113. package/dist/es/standards-sdk.es61.js +57 -131
  114. package/dist/es/standards-sdk.es61.js.map +1 -1
  115. package/dist/es/standards-sdk.es62.js +6 -18
  116. package/dist/es/standards-sdk.es62.js.map +1 -1
  117. package/dist/es/standards-sdk.es63.js +14 -28
  118. package/dist/es/standards-sdk.es63.js.map +1 -1
  119. package/dist/es/standards-sdk.es64.js +7 -29
  120. package/dist/es/standards-sdk.es64.js.map +1 -1
  121. package/dist/es/standards-sdk.es65.js +44 -20
  122. package/dist/es/standards-sdk.es65.js.map +1 -1
  123. package/dist/es/standards-sdk.es66.js +2 -44
  124. package/dist/es/standards-sdk.es66.js.map +1 -1
  125. package/dist/es/standards-sdk.es67.js +136 -18
  126. package/dist/es/standards-sdk.es67.js.map +1 -1
  127. package/dist/es/standards-sdk.es68.js +165 -54
  128. package/dist/es/standards-sdk.es68.js.map +1 -1
  129. package/dist/es/standards-sdk.es69.js +2281 -1288
  130. package/dist/es/standards-sdk.es69.js.map +1 -1
  131. package/dist/es/standards-sdk.es7.js +96 -40
  132. package/dist/es/standards-sdk.es7.js.map +1 -1
  133. package/dist/es/standards-sdk.es70.js +13 -148
  134. package/dist/es/standards-sdk.es70.js.map +1 -1
  135. package/dist/es/standards-sdk.es71.js +13 -84
  136. package/dist/es/standards-sdk.es71.js.map +1 -1
  137. package/dist/es/standards-sdk.es72.js +30 -30
  138. package/dist/es/standards-sdk.es72.js.map +1 -1
  139. package/dist/es/standards-sdk.es73.js +13 -157
  140. package/dist/es/standards-sdk.es73.js.map +1 -1
  141. package/dist/es/standards-sdk.es74.js +3 -792
  142. package/dist/es/standards-sdk.es74.js.map +1 -1
  143. package/dist/es/standards-sdk.es75.js +3 -31
  144. package/dist/es/standards-sdk.es75.js.map +1 -1
  145. package/dist/es/standards-sdk.es76.js +14 -61
  146. package/dist/es/standards-sdk.es76.js.map +1 -1
  147. package/dist/es/standards-sdk.es77.js +4 -49
  148. package/dist/es/standards-sdk.es77.js.map +1 -1
  149. package/dist/es/standards-sdk.es78.js +39 -10
  150. package/dist/es/standards-sdk.es78.js.map +1 -1
  151. package/dist/es/standards-sdk.es79.js +33 -58
  152. package/dist/es/standards-sdk.es79.js.map +1 -1
  153. package/dist/es/standards-sdk.es8.js +17 -4
  154. package/dist/es/standards-sdk.es8.js.map +1 -1
  155. package/dist/es/standards-sdk.es80.js +36 -5
  156. package/dist/es/standards-sdk.es80.js.map +1 -1
  157. package/dist/es/standards-sdk.es81.js +76 -13
  158. package/dist/es/standards-sdk.es81.js.map +1 -1
  159. package/dist/es/standards-sdk.es82.js +3 -7
  160. package/dist/es/standards-sdk.es82.js.map +1 -1
  161. package/dist/es/standards-sdk.es83.js +2 -45
  162. package/dist/es/standards-sdk.es83.js.map +1 -1
  163. package/dist/es/standards-sdk.es84.js +2 -2
  164. package/dist/es/standards-sdk.es84.js.map +1 -1
  165. package/dist/es/standards-sdk.es85.js +2 -136
  166. package/dist/es/standards-sdk.es85.js.map +1 -1
  167. package/dist/es/standards-sdk.es86.js +30 -168
  168. package/dist/es/standards-sdk.es86.js.map +1 -1
  169. package/dist/es/standards-sdk.es87.js +32 -26
  170. package/dist/es/standards-sdk.es87.js.map +1 -1
  171. package/dist/es/standards-sdk.es88.js +9 -26
  172. package/dist/es/standards-sdk.es88.js.map +1 -1
  173. package/dist/es/standards-sdk.es89.js +33 -37
  174. package/dist/es/standards-sdk.es89.js.map +1 -1
  175. package/dist/es/standards-sdk.es9.js +1 -1
  176. package/dist/es/standards-sdk.es90.js +191 -97
  177. package/dist/es/standards-sdk.es90.js.map +1 -1
  178. package/dist/es/standards-sdk.es91.js +438 -2
  179. package/dist/es/standards-sdk.es91.js.map +1 -1
  180. package/dist/es/standards-sdk.es92.js +24 -15
  181. package/dist/es/standards-sdk.es92.js.map +1 -1
  182. package/dist/es/standards-sdk.es93.js +131 -401
  183. package/dist/es/standards-sdk.es93.js.map +1 -1
  184. package/dist/es/standards-sdk.es94.js +11 -14
  185. package/dist/es/standards-sdk.es94.js.map +1 -1
  186. package/dist/es/standards-sdk.es95.js +29 -13
  187. package/dist/es/standards-sdk.es95.js.map +1 -1
  188. package/dist/es/standards-sdk.es96.js +29 -13
  189. package/dist/es/standards-sdk.es96.js.map +1 -1
  190. package/dist/es/standards-sdk.es97.js +20 -31
  191. package/dist/es/standards-sdk.es97.js.map +1 -1
  192. package/dist/es/standards-sdk.es98.js +43 -14
  193. package/dist/es/standards-sdk.es98.js.map +1 -1
  194. package/dist/es/standards-sdk.es99.js +17 -3
  195. package/dist/es/standards-sdk.es99.js.map +1 -1
  196. package/dist/es/utils/index.d.ts +1 -0
  197. package/dist/es/utils/index.d.ts.map +1 -1
  198. package/dist/es/utils/types.d.ts +3 -0
  199. package/dist/es/utils/types.d.ts.map +1 -1
  200. package/dist/umd/fees/fee-config-builder.d.ts +93 -45
  201. package/dist/umd/fees/fee-config-builder.d.ts.map +1 -1
  202. package/dist/umd/fees/types.d.ts +14 -12
  203. package/dist/umd/fees/types.d.ts.map +1 -1
  204. package/dist/umd/hcs-10/base-client.d.ts +8 -1
  205. package/dist/umd/hcs-10/base-client.d.ts.map +1 -1
  206. package/dist/umd/hcs-10/browser.d.ts.map +1 -1
  207. package/dist/umd/hcs-10/sdk.d.ts +9 -1
  208. package/dist/umd/hcs-10/sdk.d.ts.map +1 -1
  209. package/dist/umd/services/mirror-node.d.ts +74 -1
  210. package/dist/umd/services/mirror-node.d.ts.map +1 -1
  211. package/dist/umd/services/types.d.ts +29 -0
  212. package/dist/umd/services/types.d.ts.map +1 -1
  213. package/dist/umd/standards-sdk.umd.js +1 -1
  214. package/dist/umd/standards-sdk.umd.js.map +1 -1
  215. package/dist/umd/utils/index.d.ts +1 -0
  216. package/dist/umd/utils/index.d.ts.map +1 -1
  217. package/dist/umd/utils/types.d.ts +3 -0
  218. package/dist/umd/utils/types.d.ts.map +1 -1
  219. package/package.json +2 -1
@@ -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} 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 {\n HCS11Client,\n AgentMetadata as HCS11AgentMetadata,\n SocialLink,\n SocialPlatform,\n InboundTopicType,\n AgentMetadata,\n} from '../hcs-11';\nimport { FeeConfigBuilderInterface, TopicFeeConfig } from '../fees';\nimport { accountIdsToExemptKeys } from '../utils/topic-fee-utils';\nimport { Hcs10MemoType } from './base-client';\nimport { AgentBuilder } from '../hcs-11/agent-builder';\nimport { inscribe } from '../inscribe/inscriber';\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 });\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 * @returns Object with account ID and private key\n */\n async createAccount(): Promise<CreateAccountResponse> {\n this.logger.info('Creating new account');\n const newKey = PrivateKey.generate();\n\n const accountTransaction = new AccountCreateTransaction()\n .setKey(newKey.publicKey)\n .setInitialBalance(new Hbar(10));\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 feeConfig: 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 = true;\n if (!feeConfigBuilder) {\n throw new Error(\n 'Fee configuration builder is required for fee-based topics'\n );\n }\n feeConfig = feeConfigBuilder.build();\n break;\n default:\n throw new Error(`Unsupported inbound topic type: ${topicType}`);\n }\n\n return this.createTopic(memo, true, submitKey, feeConfig);\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 (error: any) {\n this.logger.error(`Error inscribing profile picture: ${error.message}`);\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 (error: any) {\n this.logger.error(`Error storing HCS-11 profile: ${error.message}`);\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<void> {\n if (!this.client.operatorPublicKey) {\n return;\n }\n\n this.logger.info('Setting up topic with custom fees');\n\n const customFee = new CustomFixedFee()\n .setAmount(Number(feeConfig.feeAmount.amount))\n .setFeeCollectorAccountId(\n AccountId.fromString(feeConfig.feeCollectorAccountId)\n );\n\n let exemptAccountIds = [\n ...(feeConfig.exemptAccounts || []),\n ...additionalExemptAccounts,\n ];\n\n console.log('exemptAccountIds', exemptAccountIds);\n\n if (exemptAccountIds.length > 0) {\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 (error) {\n this.logger.warn(\n `Error getting exempt keys: ${error}, continuing without exempt keys`\n );\n }\n }\n\n if (exemptKeys.length > 0) {\n transaction.setFeeExemptKeys(exemptKeys);\n }\n }\n\n transaction\n .setFeeScheduleKey(this.client.operatorPublicKey)\n .setCustomFees([customFee]);\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 this.logger.error(`Failed to create connection topic: ${error}`);\n throw new TopicCreationError(\n `Failed to create connection topic: ${error}`\n );\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) {\n this.logger.error('Error inscribing large message:', error);\n throw new Error(\n `Failed to handle large message: ${\n error instanceof Error ? error.message : 'Unknown error'\n }`\n );\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 transaction.setTransactionMemo('HIP-991 Fee Payment');\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 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 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 const responseSequenceNumber = response.topicSequenceNumber?.toNumber();\n\n if (!responseSequenceNumber) {\n throw new Error('Failed to get response sequence number');\n }\n\n await this.submitPayload(outboundTopic.outboundTopic, {\n ...connectionRequestMessage,\n outbound_topic_id: outboundTopic.outboundTopic,\n connection_request_id: responseSequenceNumber,\n });\n\n return response;\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 }\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 = config.existingAccount || (await this.createAccount());\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 (error: any) {\n this.logger.error(\n `Failed to create and register agent: ${error.message}`\n );\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 (error: any) {\n this.logger.error(`Failed to register agent: ${error.message}`);\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 (error: any) {\n this.logger.error(`Error determining topic type: ${error.message}`);\n throw new Error(`Failed to determine topic type: ${error.message}`);\n }\n }\n\n getNetwork(): string {\n return this.network;\n }\n\n getLogger(): Logger {\n return this.logger;\n }\n}\n"],"names":["mime.lookup"],"mappings":";;;;;;;;;;;AAwDO,MAAM,oBAAoB,gBAAgB;AAAA,EAQ/C,YAAY,QAAyB;AAC7B,UAAA;AAAA,MAC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D,MAAM,oBAAoB,SAA4C;AAChE,QAAA;AACF,YAAM,YAAY,MAAM,KAAK,WAAW,aAAa,OAAO;AAE5D,UAAI,CAAC,WAAW;AACR,cAAA,IAAI,MAAM,sBAAsB;AAAA,MAAA;AAGxC,YAAM,eAAe,UAAU,cAAc,UAAU,WAAW;AAElE,UAAI,CAAC,cAAc;AACjB,eAAO,iBAAiB;AAAA,MAAA;AAG1B,YAAM,oBACJ,UAAU,oBAAoB,UAAU,iBAAiB;AAEvD,UAAA,qBAAqB,UAAU,aAAa;AAC9C,cAAM,aAAa,UAAU;AAE7B,YACE,cACA,WAAW,cACX,WAAW,WAAW,SAAS,GAC/B;AACA,eAAK,OAAO;AAAA,YACV,SAAS,OAAO,sBAAsB,WAAW,WAAW,MAAM;AAAA,UACpE;AACA,iBAAO,iBAAiB;AAAA,QAAA;AAAA,MAC1B;AAGF,aAAO,iBAAiB;AAAA,aACjB,OAAY;AACnB,WAAK,OAAO,MAAM,iCAAiC,MAAM,OAAO,EAAE;AAClE,YAAM,IAAI,MAAM,mCAAmC,MAAM,OAAO,EAAE;AAAA,IAAA;AAAA,EACpE;AAAA,EAGF,aAAqB;AACnB,WAAO,KAAK;AAAA,EAAA;AAAA,EAGd,YAAoB;AAClB,WAAO,KAAK;AAAA,EAAA;AAEhB;"}
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} 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 {\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';\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 });\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 (error: any) {\n this.logger.error(`Error inscribing profile picture: ${error.message}`);\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 (error: any) {\n this.logger.error(`Error storing HCS-11 profile: ${error.message}`);\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 (error) {\n this.logger.warn(\n `Error getting exempt keys: ${error}, continuing without exempt keys`\n );\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 this.logger.error(`Failed to create connection topic: ${error}`);\n throw new TopicCreationError(\n `Failed to create connection topic: ${error}`\n );\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) {\n this.logger.error('Error inscribing large message:', error);\n throw new Error(\n `Failed to handle large message: ${\n error instanceof Error ? error.message : 'Unknown error'\n }`\n );\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 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 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 const responseSequenceNumber = response.topicSequenceNumber?.toNumber();\n\n if (!responseSequenceNumber) {\n throw new Error('Failed to get response sequence number');\n }\n\n await this.submitPayload(outboundTopic.outboundTopic, {\n ...connectionRequestMessage,\n outbound_topic_id: outboundTopic.outboundTopic,\n connection_request_id: responseSequenceNumber,\n });\n\n return response;\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 (error: any) {\n this.logger.error(\n `Failed to create and register agent: ${error.message}`\n );\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 (error: any) {\n this.logger.error(`Failed to register agent: ${error.message}`);\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 (error: any) {\n this.logger.error(`Error determining topic type: ${error.message}`);\n throw new Error(`Failed to determine topic type: ${error.message}`);\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"],"names":["mime.lookup"],"mappings":";;;;;;;;;;;AA2DO,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,IAAA,CACnB;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,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;AACpC,WAAO,KAAK,OAAO,mBAAmB,SAAc,KAAA;AAAA,EAAA;AAExD;"}
@@ -1,151 +1,16 @@
1
- import { version } from "./standards-sdk.es33.js";
2
- import { defineProperties } from "./standards-sdk.es72.js";
3
- function stringify(value) {
4
- if (value == null) {
5
- return "null";
6
- }
7
- if (Array.isArray(value)) {
8
- return "[ " + value.map(stringify).join(", ") + " ]";
9
- }
10
- if (value instanceof Uint8Array) {
11
- const HEX = "0123456789abcdef";
12
- let result = "0x";
13
- for (let i = 0; i < value.length; i++) {
14
- result += HEX[value[i] >> 4];
15
- result += HEX[value[i] & 15];
16
- }
17
- return result;
18
- }
19
- if (typeof value === "object" && typeof value.toJSON === "function") {
20
- return stringify(value.toJSON());
21
- }
22
- switch (typeof value) {
23
- case "boolean":
24
- case "symbol":
25
- return value.toString();
26
- case "bigint":
27
- return BigInt(value).toString();
28
- case "number":
29
- return value.toString();
30
- case "string":
31
- return JSON.stringify(value);
32
- case "object": {
33
- const keys = Object.keys(value);
34
- keys.sort();
35
- return "{ " + keys.map((k) => `${stringify(k)}: ${stringify(value[k])}`).join(", ") + " }";
36
- }
37
- }
38
- return `[ COULD NOT SERIALIZE ]`;
39
- }
40
- function isError(error, code) {
41
- return error && error.code === code;
42
- }
43
- function makeError(message, code, info) {
44
- let shortMessage = message;
45
- {
46
- const details = [];
47
- if (info) {
48
- if ("message" in info || "code" in info || "name" in info) {
49
- throw new Error(`value will overwrite populated values: ${stringify(info)}`);
50
- }
51
- for (const key in info) {
52
- if (key === "shortMessage") {
53
- continue;
54
- }
55
- const value = info[key];
56
- details.push(key + "=" + stringify(value));
57
- }
58
- }
59
- details.push(`code=${code}`);
60
- details.push(`version=${version}`);
61
- if (details.length) {
62
- message += " (" + details.join(", ") + ")";
63
- }
64
- }
65
- let error;
66
- switch (code) {
67
- case "INVALID_ARGUMENT":
68
- error = new TypeError(message);
69
- break;
70
- case "NUMERIC_FAULT":
71
- case "BUFFER_OVERRUN":
72
- error = new RangeError(message);
73
- break;
74
- default:
75
- error = new Error(message);
76
- }
77
- defineProperties(error, { code });
78
- if (info) {
79
- Object.assign(error, info);
80
- }
81
- if (error.shortMessage == null) {
82
- defineProperties(error, { shortMessage });
83
- }
84
- return error;
85
- }
86
- function assert(check, message, code, info) {
87
- if (!check) {
88
- throw makeError(message, code, info);
89
- }
90
- }
91
- function assertArgument(check, message, name, value) {
92
- assert(check, message, "INVALID_ARGUMENT", { argument: name, value });
93
- }
94
- function assertArgumentCount(count, expectedCount, message) {
95
- if (message == null) {
96
- message = "";
97
- }
98
- if (message) {
99
- message = ": " + message;
100
- }
101
- assert(count >= expectedCount, "missing argument" + message, "MISSING_ARGUMENT", {
102
- count,
103
- expectedCount
104
- });
105
- assert(count <= expectedCount, "too many arguments" + message, "UNEXPECTED_ARGUMENT", {
106
- count,
107
- expectedCount
108
- });
109
- }
110
- ["NFD", "NFC", "NFKD", "NFKC"].reduce((accum, form) => {
111
- try {
112
- if ("test".normalize(form) !== "test") {
113
- throw new Error("bad");
114
- }
115
- ;
116
- if (form === "NFD") {
117
- const check = String.fromCharCode(233).normalize("NFD");
118
- const expected = String.fromCharCode(101, 769);
119
- if (check !== expected) {
120
- throw new Error("broken");
121
- }
122
- }
123
- accum.push(form);
124
- } catch (error) {
125
- }
126
- return accum;
127
- }, []);
128
- function assertPrivate(givenGuard, guard, className) {
129
- if (className == null) {
130
- className = "";
131
- }
132
- if (givenGuard !== guard) {
133
- let method = className, operation = "new";
134
- if (className) {
135
- method += ".";
136
- operation += " " + className;
137
- }
138
- assert(false, `private constructor; use ${method}from* methods`, "UNSUPPORTED_OPERATION", {
139
- operation
140
- });
141
- }
142
- }
1
+ import URLSearchParams from "./standards-sdk.es82.js";
2
+ import FormData from "./standards-sdk.es83.js";
3
+ import Blob from "./standards-sdk.es84.js";
4
+ const platform = {
5
+ isBrowser: true,
6
+ classes: {
7
+ URLSearchParams,
8
+ FormData,
9
+ Blob
10
+ },
11
+ protocols: ["http", "https", "file", "blob", "url", "data"]
12
+ };
143
13
  export {
144
- assert,
145
- assertArgument,
146
- assertArgumentCount,
147
- assertPrivate,
148
- isError,
149
- makeError
14
+ platform as default
150
15
  };
151
16
  //# sourceMappingURL=standards-sdk.es70.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"standards-sdk.es70.js","sources":["../../node_modules/ethers/lib.esm/utils/errors.js"],"sourcesContent":["/**\n * All errors in ethers include properties to ensure they are both\n * human-readable (i.e. ``.message``) and machine-readable (i.e. ``.code``).\n *\n * The [[isError]] function can be used to check the error ``code`` and\n * provide a type guard for the properties present on that error interface.\n *\n * @_section: api/utils/errors:Errors [about-errors]\n */\nimport { version } from \"../_version.js\";\nimport { defineProperties } from \"./properties.js\";\nfunction stringify(value) {\n if (value == null) {\n return \"null\";\n }\n if (Array.isArray(value)) {\n return \"[ \" + (value.map(stringify)).join(\", \") + \" ]\";\n }\n if (value instanceof Uint8Array) {\n const HEX = \"0123456789abcdef\";\n let result = \"0x\";\n for (let i = 0; i < value.length; i++) {\n result += HEX[value[i] >> 4];\n result += HEX[value[i] & 0xf];\n }\n return result;\n }\n if (typeof (value) === \"object\" && typeof (value.toJSON) === \"function\") {\n return stringify(value.toJSON());\n }\n switch (typeof (value)) {\n case \"boolean\":\n case \"symbol\":\n return value.toString();\n case \"bigint\":\n return BigInt(value).toString();\n case \"number\":\n return (value).toString();\n case \"string\":\n return JSON.stringify(value);\n case \"object\": {\n const keys = Object.keys(value);\n keys.sort();\n return \"{ \" + keys.map((k) => `${stringify(k)}: ${stringify(value[k])}`).join(\", \") + \" }\";\n }\n }\n return `[ COULD NOT SERIALIZE ]`;\n}\n/**\n * Returns true if the %%error%% matches an error thrown by ethers\n * that matches the error %%code%%.\n *\n * In TypeScript environments, this can be used to check that %%error%%\n * matches an EthersError type, which means the expected properties will\n * be set.\n *\n * @See [ErrorCodes](api:ErrorCode)\n * @example\n * try {\n * // code....\n * } catch (e) {\n * if (isError(e, \"CALL_EXCEPTION\")) {\n * // The Type Guard has validated this object\n * console.log(e.data);\n * }\n * }\n */\nexport function isError(error, code) {\n return (error && error.code === code);\n}\n/**\n * Returns true if %%error%% is a [[CallExceptionError].\n */\nexport function isCallException(error) {\n return isError(error, \"CALL_EXCEPTION\");\n}\n/**\n * Returns a new Error configured to the format ethers emits errors, with\n * the %%message%%, [[api:ErrorCode]] %%code%% and additional properties\n * for the corresponding EthersError.\n *\n * Each error in ethers includes the version of ethers, a\n * machine-readable [[ErrorCode]], and depending on %%code%%, additional\n * required properties. The error message will also include the %%message%%,\n * ethers version, %%code%% and all additional properties, serialized.\n */\nexport function makeError(message, code, info) {\n let shortMessage = message;\n {\n const details = [];\n if (info) {\n if (\"message\" in info || \"code\" in info || \"name\" in info) {\n throw new Error(`value will overwrite populated values: ${stringify(info)}`);\n }\n for (const key in info) {\n if (key === \"shortMessage\") {\n continue;\n }\n const value = (info[key]);\n // try {\n details.push(key + \"=\" + stringify(value));\n // } catch (error: any) {\n // console.log(\"MMM\", error.message);\n // details.push(key + \"=[could not serialize object]\");\n // }\n }\n }\n details.push(`code=${code}`);\n details.push(`version=${version}`);\n if (details.length) {\n message += \" (\" + details.join(\", \") + \")\";\n }\n }\n let error;\n switch (code) {\n case \"INVALID_ARGUMENT\":\n error = new TypeError(message);\n break;\n case \"NUMERIC_FAULT\":\n case \"BUFFER_OVERRUN\":\n error = new RangeError(message);\n break;\n default:\n error = new Error(message);\n }\n defineProperties(error, { code });\n if (info) {\n Object.assign(error, info);\n }\n if (error.shortMessage == null) {\n defineProperties(error, { shortMessage });\n }\n return error;\n}\n/**\n * Throws an EthersError with %%message%%, %%code%% and additional error\n * %%info%% when %%check%% is falsish..\n *\n * @see [[api:makeError]]\n */\nexport function assert(check, message, code, info) {\n if (!check) {\n throw makeError(message, code, info);\n }\n}\n/**\n * A simple helper to simply ensuring provided arguments match expected\n * constraints, throwing if not.\n *\n * In TypeScript environments, the %%check%% has been asserted true, so\n * any further code does not need additional compile-time checks.\n */\nexport function assertArgument(check, message, name, value) {\n assert(check, message, \"INVALID_ARGUMENT\", { argument: name, value: value });\n}\nexport function assertArgumentCount(count, expectedCount, message) {\n if (message == null) {\n message = \"\";\n }\n if (message) {\n message = \": \" + message;\n }\n assert(count >= expectedCount, \"missing argument\" + message, \"MISSING_ARGUMENT\", {\n count: count,\n expectedCount: expectedCount\n });\n assert(count <= expectedCount, \"too many arguments\" + message, \"UNEXPECTED_ARGUMENT\", {\n count: count,\n expectedCount: expectedCount\n });\n}\nconst _normalizeForms = [\"NFD\", \"NFC\", \"NFKD\", \"NFKC\"].reduce((accum, form) => {\n try {\n // General test for normalize\n /* c8 ignore start */\n if (\"test\".normalize(form) !== \"test\") {\n throw new Error(\"bad\");\n }\n ;\n /* c8 ignore stop */\n if (form === \"NFD\") {\n const check = String.fromCharCode(0xe9).normalize(\"NFD\");\n const expected = String.fromCharCode(0x65, 0x0301);\n /* c8 ignore start */\n if (check !== expected) {\n throw new Error(\"broken\");\n }\n /* c8 ignore stop */\n }\n accum.push(form);\n }\n catch (error) { }\n return accum;\n}, []);\n/**\n * Throws if the normalization %%form%% is not supported.\n */\nexport function assertNormalize(form) {\n assert(_normalizeForms.indexOf(form) >= 0, \"platform missing String.prototype.normalize\", \"UNSUPPORTED_OPERATION\", {\n operation: \"String.prototype.normalize\", info: { form }\n });\n}\n/**\n * Many classes use file-scoped values to guard the constructor,\n * making it effectively private. This facilitates that pattern\n * by ensuring the %%givenGaurd%% matches the file-scoped %%guard%%,\n * throwing if not, indicating the %%className%% if provided.\n */\nexport function assertPrivate(givenGuard, guard, className) {\n if (className == null) {\n className = \"\";\n }\n if (givenGuard !== guard) {\n let method = className, operation = \"new\";\n if (className) {\n method += \".\";\n operation += \" \" + className;\n }\n assert(false, `private constructor; use ${method}from* methods`, \"UNSUPPORTED_OPERATION\", {\n operation\n });\n }\n}\n//# sourceMappingURL=errors.js.map"],"names":[],"mappings":";;AAWA,SAAS,UAAU,OAAO;AACtB,MAAI,SAAS,MAAM;AACf,WAAO;AAAA,EACf;AACI,MA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EACR,CAAK;AACL;AACwB,CAAC,OAAO,OAAO,QAAQ,MAAM,EAAE,OAAO,CAAC,OAAO,SAAS;AAC3E,MAAI;AAGA,QAAI,OAAO,UAAU,IAAI,MAAM,QAAQ;AACnC,YAAM,IAAI,MAAM,KAAK;AAAA,IACjC;AACQ;AAEA,QAAI,SAAS,OAAO;AAChB,YAAM,QAAQ,OAAO,aAAa,GAAI,EAAE,UAAU,KAAK;AACvD,YAAM,WAAW,OAAO,aAAa,KAAM,GAAM;AAEjD,UAAI,UAAU,UAAU;AACpB,cAAM,IAAI,MAAM,QAAQ;AAAA,MACxC;AAAA,IAEA;AACQ,UAAM,KAAK,IAAI;AAAA,EACvB,SACW,OAAO;AAAA,EAAA;AACd,SAAO;AACX,GAAG,CAAE,CAAA;AAeE,SAAS,cAAc,YAAY,OAAO,WAAW;AACxD,MAAI,aAAa,MAAM;AACnB,gBAAY;AAAA,EACpB;AACI,MAAI,eAAe,OAAO;AACtB,QAAI,SAAS,WAAW,YAAY;AACpC,QAAI,WAAW;AACX,gBAAU;AACV,mBAAa,MAAM;AAAA,IAC/B;AACQ,WAAO,OAAO,4BAA4B,MAAM,iBAAiB,yBAAyB;AAAA,MACtF;AAAA,IACZ,CAAS;AAAA,EACT;AACA;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"standards-sdk.es70.js","sources":["../../node_modules/axios/lib/platform/browser/index.js"],"sourcesContent":["import URLSearchParams from './classes/URLSearchParams.js'\nimport FormData from './classes/FormData.js'\nimport Blob from './classes/Blob.js'\n\nexport default {\n isBrowser: true,\n classes: {\n URLSearchParams,\n FormData,\n Blob\n },\n protocols: ['http', 'https', 'file', 'blob', 'url', 'data']\n};\n"],"names":[],"mappings":";;;AAIA,MAAe,WAAA;AAAA,EACb,WAAW;AAAA,EACX,SAAS;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAAA,EACD,WAAW,CAAC,QAAQ,SAAS,QAAQ,QAAQ,OAAO,MAAM;AAC5D;","x_google_ignoreList":[0]}
@@ -1,87 +1,16 @@
1
- import { keccak256 } from "./standards-sdk.es53.js";
2
- import { assertArgument } from "./standards-sdk.es70.js";
3
- import { getBytes } from "./standards-sdk.es55.js";
4
- const BN_0 = BigInt(0);
5
- const BN_36 = BigInt(36);
6
- function getChecksumAddress(address) {
7
- address = address.toLowerCase();
8
- const chars = address.substring(2).split("");
9
- const expanded = new Uint8Array(40);
10
- for (let i = 0; i < 40; i++) {
11
- expanded[i] = chars[i].charCodeAt(0);
12
- }
13
- const hashed = getBytes(keccak256(expanded));
14
- for (let i = 0; i < 40; i += 2) {
15
- if (hashed[i >> 1] >> 4 >= 8) {
16
- chars[i] = chars[i].toUpperCase();
17
- }
18
- if ((hashed[i >> 1] & 15) >= 8) {
19
- chars[i + 1] = chars[i + 1].toUpperCase();
20
- }
21
- }
22
- return "0x" + chars.join("");
23
- }
24
- const ibanLookup = {};
25
- for (let i = 0; i < 10; i++) {
26
- ibanLookup[String(i)] = String(i);
27
- }
28
- for (let i = 0; i < 26; i++) {
29
- ibanLookup[String.fromCharCode(65 + i)] = String(10 + i);
30
- }
31
- const safeDigits = 15;
32
- function ibanChecksum(address) {
33
- address = address.toUpperCase();
34
- address = address.substring(4) + address.substring(0, 2) + "00";
35
- let expanded = address.split("").map((c) => {
36
- return ibanLookup[c];
37
- }).join("");
38
- while (expanded.length >= safeDigits) {
39
- let block = expanded.substring(0, safeDigits);
40
- expanded = parseInt(block, 10) % 97 + expanded.substring(block.length);
41
- }
42
- let checksum = String(98 - parseInt(expanded, 10) % 97);
43
- while (checksum.length < 2) {
44
- checksum = "0" + checksum;
45
- }
46
- return checksum;
47
- }
48
- const Base36 = function() {
49
- const result = {};
50
- for (let i = 0; i < 36; i++) {
51
- const key = "0123456789abcdefghijklmnopqrstuvwxyz"[i];
52
- result[key] = BigInt(i);
53
- }
54
- return result;
55
- }();
56
- function fromBase36(value) {
57
- value = value.toLowerCase();
58
- let result = BN_0;
59
- for (let i = 0; i < value.length; i++) {
60
- result = result * BN_36 + Base36[value[i]];
61
- }
62
- return result;
63
- }
64
- function getAddress(address) {
65
- assertArgument(typeof address === "string", "invalid address", "address", address);
66
- if (address.match(/^(0x)?[0-9a-fA-F]{40}$/)) {
67
- if (!address.startsWith("0x")) {
68
- address = "0x" + address;
69
- }
70
- const result = getChecksumAddress(address);
71
- assertArgument(!address.match(/([A-F].*[a-f])|([a-f].*[A-F])/) || result === address, "bad address checksum", "address", address);
72
- return result;
73
- }
74
- if (address.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) {
75
- assertArgument(address.substring(2, 4) === ibanChecksum(address), "bad icap checksum", "address", address);
76
- let result = fromBase36(address.substring(4)).toString(16);
77
- while (result.length < 40) {
78
- result = "0" + result;
79
- }
80
- return getChecksumAddress("0x" + result);
81
- }
82
- assertArgument(false, "invalid address", "address", address);
83
- }
1
+ const hasBrowserEnv = typeof window !== "undefined" && typeof document !== "undefined";
2
+ const _navigator = typeof navigator === "object" && navigator || void 0;
3
+ const hasStandardBrowserEnv = hasBrowserEnv && (!_navigator || ["ReactNative", "NativeScript", "NS"].indexOf(_navigator.product) < 0);
4
+ const hasStandardBrowserWebWorkerEnv = (() => {
5
+ return typeof WorkerGlobalScope !== "undefined" && // eslint-disable-next-line no-undef
6
+ self instanceof WorkerGlobalScope && typeof self.importScripts === "function";
7
+ })();
8
+ const origin = hasBrowserEnv && window.location.href || "http://localhost";
84
9
  export {
85
- getAddress
10
+ hasBrowserEnv,
11
+ hasStandardBrowserEnv,
12
+ hasStandardBrowserWebWorkerEnv,
13
+ _navigator as navigator,
14
+ origin
86
15
  };
87
16
  //# sourceMappingURL=standards-sdk.es71.js.map