holosphere 2.0.0-alpha7 → 2.0.0-alpha9

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 (327) hide show
  1. package/CHANGELOG.md +446 -0
  2. package/FEATURES.md +431 -0
  3. package/LICENSE +29 -166
  4. package/LICENSE-AGPL.md +180 -0
  5. package/dist/cdn/holosphere.min.js +55 -0
  6. package/dist/cdn/holosphere.min.js.map +1 -0
  7. package/dist/cjs/holosphere.cjs +1 -1
  8. package/dist/esm/holosphere.js +1 -1
  9. package/dist/{index-C-IlLYlk.cjs → index-DDGt_V9o.cjs} +2 -2
  10. package/dist/{index-C-IlLYlk.cjs.map → index-DDGt_V9o.cjs.map} +1 -1
  11. package/dist/{index-d6f4RJBM.js → index-DJXftyvB.js} +2253 -387
  12. package/dist/index-DJXftyvB.js.map +1 -0
  13. package/dist/index-DMbdcMtK.cjs +18 -0
  14. package/dist/index-DMbdcMtK.cjs.map +1 -0
  15. package/dist/{index-jmTHEbR2.js → index-DeZ1xz_s.js} +2 -2
  16. package/dist/{index-jmTHEbR2.js.map → index-DeZ1xz_s.js.map} +1 -1
  17. package/dist/{indexeddb-storage-D8kOl0oK.js → indexeddb-storage-BFt6hMeF.js} +48 -4
  18. package/dist/indexeddb-storage-BFt6hMeF.js.map +1 -0
  19. package/dist/{indexeddb-storage-a8GipaDr.cjs → indexeddb-storage-BK5tv4Sh.cjs} +2 -2
  20. package/dist/indexeddb-storage-BK5tv4Sh.cjs.map +1 -0
  21. package/dist/{memory-storage-DBQK622V.js → memory-storage-C9HuoL2E.js} +44 -4
  22. package/dist/memory-storage-C9HuoL2E.js.map +1 -0
  23. package/dist/{memory-storage-gfRovk2O.cjs → memory-storage-Dao7jfYG.cjs} +2 -2
  24. package/dist/memory-storage-Dao7jfYG.cjs.map +1 -0
  25. package/dist/{secp256k1-BCAPF45D.cjs → secp256k1-BbKzbLtD.cjs} +2 -2
  26. package/dist/{secp256k1-BCAPF45D.cjs.map → secp256k1-BbKzbLtD.cjs.map} +1 -1
  27. package/dist/{secp256k1-DYm_CMqW.js → secp256k1-CreY7Pcl.js} +2 -2
  28. package/dist/{secp256k1-DYm_CMqW.js.map → secp256k1-CreY7Pcl.js.map} +1 -1
  29. package/docs/api/ai_aggregation.js.html +333 -0
  30. package/docs/api/ai_breakdown.js.html +524 -0
  31. package/docs/api/ai_classifier.js.html +231 -0
  32. package/docs/api/ai_council.js.html +246 -0
  33. package/docs/api/ai_embeddings.js.html +304 -0
  34. package/docs/api/ai_federation-ai.js.html +338 -0
  35. package/docs/api/ai_h3-ai.js.html +970 -0
  36. package/docs/api/ai_index.js.html +124 -0
  37. package/docs/api/ai_json-ops.js.html +241 -0
  38. package/docs/api/ai_llm-service.js.html +239 -0
  39. package/docs/api/ai_nl-query.js.html +236 -0
  40. package/docs/api/ai_relationships.js.html +367 -0
  41. package/docs/api/ai_schema-extractor.js.html +235 -0
  42. package/docs/api/ai_spatial.js.html +307 -0
  43. package/docs/api/ai_tts.js.html +214 -0
  44. package/docs/api/content_social-protocols.js.html +180 -0
  45. package/docs/api/core_holosphere.js.html +757 -0
  46. package/docs/api/crypto_nostr-utils.js.html +306 -0
  47. package/docs/api/crypto_secp256k1.js.html +267 -0
  48. package/docs/api/data/search.json +1 -0
  49. package/docs/api/federation_discovery.js.html +337 -0
  50. package/docs/api/federation_handshake.js.html +478 -0
  51. package/docs/api/federation_hologram.js.html +1053 -0
  52. package/docs/api/federation_registry.js.html +389 -0
  53. package/docs/api/fonts/Inconsolata-Regular.ttf +0 -0
  54. package/docs/api/fonts/OpenSans-Regular.ttf +0 -0
  55. package/docs/api/fonts/WorkSans-Bold.ttf +0 -0
  56. package/docs/api/global.html +3 -0
  57. package/docs/api/hierarchical_upcast.js.html +128 -0
  58. package/docs/api/index.html +265 -0
  59. package/docs/api/index.js.html +1868 -0
  60. package/docs/api/lib_ai-methods.js.html +660 -0
  61. package/docs/api/lib_contract-methods.js.html +445 -0
  62. package/docs/api/lib_errors.js.html +56 -0
  63. package/docs/api/lib_federation-methods.js.html +348 -0
  64. package/docs/api/lib_index.js.html +33 -0
  65. package/docs/api/module-ai.html +5 -0
  66. package/docs/api/module-ai_aggregation-SmartAggregation.html +6 -0
  67. package/docs/api/module-ai_aggregation.SmartAggregation.html +3 -0
  68. package/docs/api/module-ai_aggregation.html +3 -0
  69. package/docs/api/module-ai_breakdown-TaskBreakdown.html +5 -0
  70. package/docs/api/module-ai_breakdown.TaskBreakdown.html +3 -0
  71. package/docs/api/module-ai_breakdown.html +3 -0
  72. package/docs/api/module-ai_classifier-Classifier.html +6 -0
  73. package/docs/api/module-ai_classifier.Classifier.html +3 -0
  74. package/docs/api/module-ai_classifier.html +3 -0
  75. package/docs/api/module-ai_council-Council.html +6 -0
  76. package/docs/api/module-ai_council.Council.html +3 -0
  77. package/docs/api/module-ai_council.html +3 -0
  78. package/docs/api/module-ai_embeddings-Embeddings.html +5 -0
  79. package/docs/api/module-ai_embeddings.Embeddings.html +3 -0
  80. package/docs/api/module-ai_embeddings.html +3 -0
  81. package/docs/api/module-ai_federation-ai-FederationAdvisor.html +6 -0
  82. package/docs/api/module-ai_federation-ai.FederationAdvisor.html +3 -0
  83. package/docs/api/module-ai_federation-ai.html +3 -0
  84. package/docs/api/module-ai_h3-ai-H3AI.html +6 -0
  85. package/docs/api/module-ai_h3-ai.H3AI.html +3 -0
  86. package/docs/api/module-ai_h3-ai.html +3 -0
  87. package/docs/api/module-ai_json-ops-JSONOps.html +5 -0
  88. package/docs/api/module-ai_json-ops.JSONOps.html +3 -0
  89. package/docs/api/module-ai_json-ops.html +3 -0
  90. package/docs/api/module-ai_llm-service-LLMService.html +5 -0
  91. package/docs/api/module-ai_llm-service.LLMService.html +3 -0
  92. package/docs/api/module-ai_llm-service.html +3 -0
  93. package/docs/api/module-ai_nl-query-NLQuery.html +5 -0
  94. package/docs/api/module-ai_nl-query.NLQuery.html +3 -0
  95. package/docs/api/module-ai_nl-query.html +3 -0
  96. package/docs/api/module-ai_relationships-RelationshipDiscovery.html +6 -0
  97. package/docs/api/module-ai_relationships.RelationshipDiscovery.html +3 -0
  98. package/docs/api/module-ai_relationships.html +3 -0
  99. package/docs/api/module-ai_schema-extractor-SchemaExtractor.html +5 -0
  100. package/docs/api/module-ai_schema-extractor.SchemaExtractor.html +3 -0
  101. package/docs/api/module-ai_schema-extractor.html +3 -0
  102. package/docs/api/module-ai_spatial-SpatialAnalysis.html +6 -0
  103. package/docs/api/module-ai_spatial.SpatialAnalysis.html +3 -0
  104. package/docs/api/module-ai_spatial.html +3 -0
  105. package/docs/api/module-ai_tts-TTS.html +5 -0
  106. package/docs/api/module-ai_tts.TTS.html +3 -0
  107. package/docs/api/module-ai_tts.html +3 -0
  108. package/docs/api/module-content_social-protocols.html +3 -0
  109. package/docs/api/module-core_holosphere-HoloSphere.html +6 -0
  110. package/docs/api/module-core_holosphere.HoloSphere.html +3 -0
  111. package/docs/api/module-core_holosphere.html +3 -0
  112. package/docs/api/module-crypto_nostr-utils.html +3 -0
  113. package/docs/api/module-crypto_secp256k1.html +3 -0
  114. package/docs/api/module-federation_hologram.html +3 -0
  115. package/docs/api/module-hierarchical_upcast.html +3 -0
  116. package/docs/api/module-holosphere-HoloSphereBase.html +3 -0
  117. package/docs/api/module-holosphere.html +3 -0
  118. package/docs/api/module-lib_ai-methods.html +3 -0
  119. package/docs/api/module-lib_contract-methods.html +3 -0
  120. package/docs/api/module-lib_errors-AuthorizationError.html +3 -0
  121. package/docs/api/module-lib_errors-ValidationError.html +3 -0
  122. package/docs/api/module-lib_errors.AuthorizationError.html +3 -0
  123. package/docs/api/module-lib_errors.ValidationError.html +3 -0
  124. package/docs/api/module-lib_errors.html +3 -0
  125. package/docs/api/module-lib_federation-methods.html +3 -0
  126. package/docs/api/module-lib_index.html +3 -0
  127. package/docs/api/module-schema_validator-ValidationError.html +3 -0
  128. package/docs/api/module-schema_validator.ValidationError.html +3 -0
  129. package/docs/api/module-schema_validator.html +3 -0
  130. package/docs/api/module-spatial_h3-operations.html +4 -0
  131. package/docs/api/module-storage_backend-factory.BackendFactory.html +3 -0
  132. package/docs/api/module-storage_backend-factory.html +3 -0
  133. package/docs/api/module-storage_backend-interface-StorageBackend.html +3 -0
  134. package/docs/api/module-storage_backend-interface.StorageBackend.html +3 -0
  135. package/docs/api/module-storage_backend-interface.html +3 -0
  136. package/docs/api/module-storage_backends_activitypub-backend-ActivityPubBackend.html +7 -0
  137. package/docs/api/module-storage_backends_activitypub-backend.ActivityPubBackend.html +3 -0
  138. package/docs/api/module-storage_backends_activitypub-backend.html +3 -0
  139. package/docs/api/module-storage_backends_activitypub_server-ActivityPubServer.html +8 -0
  140. package/docs/api/module-storage_backends_activitypub_server.ActivityPubServer.html +3 -0
  141. package/docs/api/module-storage_backends_activitypub_server.html +3 -0
  142. package/docs/api/module-storage_backends_gundb-backend-GunDBBackend.html +7 -0
  143. package/docs/api/module-storage_backends_gundb-backend.GunDBBackend.html +3 -0
  144. package/docs/api/module-storage_backends_gundb-backend.html +3 -0
  145. package/docs/api/module-storage_backends_nostr-backend-NostrBackend.html +8 -0
  146. package/docs/api/module-storage_backends_nostr-backend.NostrBackend.html +3 -0
  147. package/docs/api/module-storage_backends_nostr-backend.html +3 -0
  148. package/docs/api/module-storage_filesystem-storage-FileSystemStorage.html +5 -0
  149. package/docs/api/module-storage_filesystem-storage-browser-FileSystemStorage.html +3 -0
  150. package/docs/api/module-storage_filesystem-storage-browser.FileSystemStorage.html +3 -0
  151. package/docs/api/module-storage_filesystem-storage-browser.html +3 -0
  152. package/docs/api/module-storage_filesystem-storage.FileSystemStorage.html +3 -0
  153. package/docs/api/module-storage_filesystem-storage.html +3 -0
  154. package/docs/api/module-storage_global-tables.html +3 -0
  155. package/docs/api/module-storage_gun-async.html +3 -0
  156. package/docs/api/module-storage_gun-auth-GunAuth.html +5 -0
  157. package/docs/api/module-storage_gun-auth.GunAuth.html +3 -0
  158. package/docs/api/module-storage_gun-auth.html +3 -0
  159. package/docs/api/module-storage_gun-federation.html +3 -0
  160. package/docs/api/module-storage_gun-references-GunReferenceHandler.html +5 -0
  161. package/docs/api/module-storage_gun-references.GunReferenceHandler.html +3 -0
  162. package/docs/api/module-storage_gun-references.html +3 -0
  163. package/docs/api/module-storage_gun-schema-GunSchemaValidator.html +5 -0
  164. package/docs/api/module-storage_gun-schema.GunSchemaValidator.html +3 -0
  165. package/docs/api/module-storage_gun-schema.html +3 -0
  166. package/docs/api/module-storage_gun-wrapper.html +11 -0
  167. package/docs/api/module-storage_indexeddb-storage-IndexedDBStorage.html +5 -0
  168. package/docs/api/module-storage_indexeddb-storage.IndexedDBStorage.html +3 -0
  169. package/docs/api/module-storage_indexeddb-storage.html +3 -0
  170. package/docs/api/module-storage_key-storage-simple.html +3 -0
  171. package/docs/api/module-storage_key-storage.html +4 -0
  172. package/docs/api/module-storage_memory-storage-MemoryStorage.html +5 -0
  173. package/docs/api/module-storage_memory-storage.MemoryStorage.html +3 -0
  174. package/docs/api/module-storage_memory-storage.html +3 -0
  175. package/docs/api/module-storage_migration-MigrationTool.html +6 -0
  176. package/docs/api/module-storage_migration.MigrationTool.html +3 -0
  177. package/docs/api/module-storage_migration.html +3 -0
  178. package/docs/api/module-storage_nostr-async.html +18 -0
  179. package/docs/api/module-storage_nostr-client-LRUCache.html +3 -0
  180. package/docs/api/module-storage_nostr-client-NostrClient.html +7 -0
  181. package/docs/api/module-storage_nostr-client.NostrClient.html +15 -0
  182. package/docs/api/module-storage_nostr-client.html +6 -0
  183. package/docs/api/module-storage_nostr-wrapper.html +3 -0
  184. package/docs/api/module-storage_outbox-queue-OutboxQueue.html +4 -0
  185. package/docs/api/module-storage_outbox-queue.OutboxQueue.html +3 -0
  186. package/docs/api/module-storage_outbox-queue.html +3 -0
  187. package/docs/api/module-storage_persistent-storage-PersistentStorage.html +3 -0
  188. package/docs/api/module-storage_persistent-storage.html +4 -0
  189. package/docs/api/module-storage_sync-service-SyncService.html +5 -0
  190. package/docs/api/module-storage_sync-service.SyncService.html +3 -0
  191. package/docs/api/module-storage_sync-service.html +3 -0
  192. package/docs/api/module-storage_unified-storage.html +3 -0
  193. package/docs/api/module-subscriptions_manager.SubscriptionRegistry.html +3 -0
  194. package/docs/api/module-subscriptions_manager.html +3 -0
  195. package/docs/api/schema_validator.js.html +113 -0
  196. package/docs/api/scripts/core.js +726 -0
  197. package/docs/api/scripts/core.min.js +23 -0
  198. package/docs/api/scripts/resize.js +90 -0
  199. package/docs/api/scripts/search.js +265 -0
  200. package/docs/api/scripts/search.min.js +6 -0
  201. package/docs/api/scripts/third-party/Apache-License-2.0.txt +202 -0
  202. package/docs/api/scripts/third-party/fuse.js +9 -0
  203. package/docs/api/scripts/third-party/hljs-line-num-original.js +369 -0
  204. package/docs/api/scripts/third-party/hljs-line-num.js +1 -0
  205. package/docs/api/scripts/third-party/hljs-original.js +5171 -0
  206. package/docs/api/scripts/third-party/hljs.js +1 -0
  207. package/docs/api/scripts/third-party/popper.js +5 -0
  208. package/docs/api/scripts/third-party/tippy.js +1 -0
  209. package/docs/api/scripts/third-party/tocbot.js +672 -0
  210. package/docs/api/scripts/third-party/tocbot.min.js +1 -0
  211. package/docs/api/spatial_h3-operations.js.html +129 -0
  212. package/docs/api/storage_backend-factory.js.html +133 -0
  213. package/docs/api/storage_backend-interface.js.html +164 -0
  214. package/docs/api/storage_backends_activitypub-backend.js.html +298 -0
  215. package/docs/api/storage_backends_activitypub_server.js.html +678 -0
  216. package/docs/api/storage_backends_gundb-backend.js.html +878 -0
  217. package/docs/api/storage_backends_nostr-backend.js.html +254 -0
  218. package/docs/api/storage_filesystem-storage-browser.js.html +83 -0
  219. package/docs/api/storage_filesystem-storage.js.html +207 -0
  220. package/docs/api/storage_global-tables.js.html +116 -0
  221. package/docs/api/storage_gun-async.js.html +344 -0
  222. package/docs/api/storage_gun-auth.js.html +376 -0
  223. package/docs/api/storage_gun-federation.js.html +788 -0
  224. package/docs/api/storage_gun-references.js.html +212 -0
  225. package/docs/api/storage_gun-schema.js.html +309 -0
  226. package/docs/api/storage_gun-wrapper.js.html +645 -0
  227. package/docs/api/storage_indexeddb-storage.js.html +224 -0
  228. package/docs/api/storage_key-storage-simple.js.html +102 -0
  229. package/docs/api/storage_key-storage.js.html +171 -0
  230. package/docs/api/storage_memory-storage.js.html +128 -0
  231. package/docs/api/storage_migration.js.html +354 -0
  232. package/docs/api/storage_nostr-async.js.html +1076 -0
  233. package/docs/api/storage_nostr-client.js.html +1598 -0
  234. package/docs/api/storage_nostr-wrapper.js.html +218 -0
  235. package/docs/api/storage_outbox-queue.js.html +248 -0
  236. package/docs/api/storage_persistent-storage.js.html +160 -0
  237. package/docs/api/storage_sync-service.js.html +201 -0
  238. package/docs/api/storage_unified-storage.js.html +157 -0
  239. package/docs/api/styles/clean-jsdoc-theme-base.css +1159 -0
  240. package/docs/api/styles/clean-jsdoc-theme-dark.css +412 -0
  241. package/docs/api/styles/clean-jsdoc-theme-light.css +482 -0
  242. package/docs/api/styles/clean-jsdoc-theme-scrollbar.css +30 -0
  243. package/docs/api/styles/clean-jsdoc-theme-without-scrollbar.min.css +1 -0
  244. package/docs/api/styles/clean-jsdoc-theme.min.css +1 -0
  245. package/docs/api/subscriptions_manager.js.html +162 -0
  246. package/examples/holosphere-widget.js +1242 -0
  247. package/examples/widget-demo.html +274 -0
  248. package/examples/widget.html +703 -0
  249. package/jsdoc.json +26 -0
  250. package/package.json +16 -3
  251. package/src/ai/aggregation.js +13 -2
  252. package/src/ai/breakdown.js +12 -2
  253. package/src/ai/classifier.js +14 -3
  254. package/src/ai/council.js +22 -7
  255. package/src/ai/embeddings.js +37 -15
  256. package/src/ai/federation-ai.js +13 -2
  257. package/src/ai/h3-ai.js +14 -2
  258. package/src/ai/index.js +16 -7
  259. package/src/ai/json-ops.js +18 -5
  260. package/src/ai/llm-service.js +62 -31
  261. package/src/ai/nl-query.js +12 -2
  262. package/src/ai/relationships.js +13 -2
  263. package/src/ai/schema-extractor.js +24 -10
  264. package/src/ai/spatial.js +13 -2
  265. package/src/ai/tts.js +25 -8
  266. package/src/cdn-entry.js +22 -0
  267. package/src/content/social-protocols.js +34 -25
  268. package/src/contracts/chain-manager.js +68 -40
  269. package/src/contracts/deployer.js +70 -42
  270. package/src/contracts/event-listener.js +61 -29
  271. package/src/contracts/holon-contracts.js +46 -31
  272. package/src/contracts/index.js +5 -6
  273. package/src/contracts/networks.js +19 -14
  274. package/src/contracts/operations.js +58 -41
  275. package/src/contracts/queries.js +70 -21
  276. package/src/core/holosphere.js +37 -8
  277. package/src/crypto/nostr-utils.js +105 -65
  278. package/src/crypto/secp256k1.js +7 -2
  279. package/src/federation/handshake.js +23 -11
  280. package/src/federation/hologram.js +9 -1
  281. package/src/hierarchical/upcast.js +34 -20
  282. package/src/index.js +671 -7
  283. package/src/lib/ai-methods.js +352 -3
  284. package/src/lib/contract-methods.js +152 -3
  285. package/src/lib/errors.js +31 -1
  286. package/src/lib/federation-methods.js +110 -3
  287. package/src/lib/index.js +9 -5
  288. package/src/schema/validator.js +22 -3
  289. package/src/spatial/h3-operations.js +17 -1
  290. package/src/storage/backend-factory.js +7 -2
  291. package/src/storage/backend-interface.js +21 -2
  292. package/src/storage/backends/activitypub/server.js +25 -3
  293. package/src/storage/backends/activitypub-backend.js +25 -2
  294. package/src/storage/backends/gundb-backend.js +322 -11
  295. package/src/storage/backends/nostr-backend.js +116 -1
  296. package/src/storage/filesystem-storage-browser.js +42 -2
  297. package/src/storage/filesystem-storage.js +72 -5
  298. package/src/storage/global-tables.js +7 -2
  299. package/src/storage/gun-async.js +20 -11
  300. package/src/storage/gun-auth.js +15 -4
  301. package/src/storage/gun-federation.js +14 -5
  302. package/src/storage/gun-references.js +16 -5
  303. package/src/storage/gun-schema.js +25 -10
  304. package/src/storage/gun-wrapper.js +160 -49
  305. package/src/storage/indexeddb-storage.js +65 -4
  306. package/src/storage/key-storage-simple.js +32 -9
  307. package/src/storage/key-storage.js +45 -13
  308. package/src/storage/memory-storage.js +65 -4
  309. package/src/storage/migration.js +20 -7
  310. package/src/storage/nostr-async.js +195 -90
  311. package/src/storage/nostr-client.js +173 -49
  312. package/src/storage/nostr-wrapper.js +6 -2
  313. package/src/storage/outbox-queue.js +55 -18
  314. package/src/storage/persistent-storage.js +56 -13
  315. package/src/storage/sync-service.js +51 -17
  316. package/src/storage/unified-storage.js +38 -3
  317. package/src/subscriptions/manager.js +33 -16
  318. package/vite.config.cdn.js +60 -0
  319. package/dist/index-Bvwyvd0T.cjs +0 -5
  320. package/dist/index-Bvwyvd0T.cjs.map +0 -1
  321. package/dist/index-d6f4RJBM.js.map +0 -1
  322. package/dist/indexeddb-storage-D8kOl0oK.js.map +0 -1
  323. package/dist/indexeddb-storage-a8GipaDr.cjs.map +0 -1
  324. package/dist/memory-storage-DBQK622V.js.map +0 -1
  325. package/dist/memory-storage-gfRovk2O.cjs.map +0 -1
  326. /package/{cleanup-test-data.js → scripts/cleanup-test-data.js} +0 -0
  327. /package/{test-ai-real-api.js → scripts/test-ai-real-api.js} +0 -0
@@ -1,6 +1,7 @@
1
1
  /**
2
- * ContractDeployer - 1-Click deployment for Holosphere smart contracts
3
- * Deploys all factories, registry, and individual holon contracts
2
+ * @fileoverview Contract deployment utilities for Holosphere smart contracts.
3
+ * Provides 1-click deployment for all factories, registry, and individual holon contracts.
4
+ * @module contracts/deployer
4
5
  */
5
6
 
6
7
  // Import ABIs
@@ -35,7 +36,16 @@ export const ABIs = {
35
36
  TestToken: TestTokenABI
36
37
  };
37
38
 
39
+ /**
40
+ * Contract deployment manager for Holosphere contracts.
41
+ * Handles deployment of all contract types and factory infrastructure.
42
+ * @class
43
+ */
38
44
  export class ContractDeployer {
45
+ /**
46
+ * Create a new ContractDeployer instance.
47
+ * @param {ChainManager} chainManager - Chain manager instance
48
+ */
39
49
  constructor(chainManager) {
40
50
  this.chainManager = chainManager;
41
51
  this.deployedContracts = {};
@@ -43,8 +53,9 @@ export class ContractDeployer {
43
53
  }
44
54
 
45
55
  /**
46
- * Load ethers from chain manager
56
+ * Load ethers.js library.
47
57
  * @private
58
+ * @returns {Promise<Object>} Ethers.js module
48
59
  */
49
60
  async _loadEthers() {
50
61
  if (!this.ethers) {
@@ -54,15 +65,15 @@ export class ContractDeployer {
54
65
  }
55
66
 
56
67
  /**
57
- * 1-CLICK DEPLOY: Deploy entire Holosphere contract infrastructure
58
- * Deploys: All factories + Holons registry + optional TestToken
59
- *
60
- * @param {Object} options - Deployment options
68
+ * 1-CLICK DEPLOY: Deploy entire Holosphere contract infrastructure.
69
+ * Deploys all factories, Holons registry, and optional TestToken.
70
+ * @param {Object} [options={}] - Deployment options
61
71
  * @param {string} [options.botAddress] - Bot address for managed operations (defaults to deployer)
62
72
  * @param {string} [options.testTokenSupply='1000000'] - Initial supply for test token (in whole tokens)
63
73
  * @param {boolean} [options.deployTestToken=true] - Whether to deploy test token
64
- * @param {Function} [options.onProgress] - Callback for deployment progress
65
- * @returns {Promise<Object>} Deployed contract addresses and instances
74
+ * @param {Function} [options.onProgress] - Callback for deployment progress updates
75
+ * @returns {Promise<Object>} Deployment details including contract addresses, explorer URLs, and metadata
76
+ * @throws {Error} If deployment fails
66
77
  */
67
78
  async deployAll(options = {}) {
68
79
  const ethers = await this._loadEthers();
@@ -190,12 +201,16 @@ export class ContractDeployer {
190
201
  }
191
202
 
192
203
  /**
193
- * Deploy a Splitter contract for a holon (fractal ownership)
204
+ * Deploy a Splitter contract for fractal ownership distribution.
194
205
  * @param {string} holonId - Holon identifier
195
206
  * @param {string} name - Contract display name
196
207
  * @param {number} [splitPercentage=70] - Internal/External split (e.g., 70 = 70% internal, 30% external)
197
- * @param {Object} [options] - Additional options
198
- * @returns {Promise<{contract, address, txHash}>}
208
+ * @param {Object} [options={}] - Additional deployment options
209
+ * @param {string} [options.creatorUserId] - Creator user ID (defaults to holonId)
210
+ * @param {string} [options.managedFactory] - Managed factory address
211
+ * @param {string} [options.zonedFactory] - Zoned factory address
212
+ * @returns {Promise<{contract: Object, address: string, txHash: string, holonId: string, type: string, splitPercentage: number}>} Deployment details
213
+ * @throws {Error} If factories not deployed
199
214
  */
200
215
  async deploySplitter(holonId, name, splitPercentage = 70, options = {}) {
201
216
  const signer = this.chainManager.getSigner();
@@ -231,10 +246,11 @@ export class ContractDeployer {
231
246
  }
232
247
 
233
248
  /**
234
- * Deploy a Managed contract (appreciation-based distribution)
249
+ * Deploy a Managed contract for appreciation-based distribution.
235
250
  * @param {string} name - Contract name
236
- * @param {Object} [options] - Additional options
237
- * @returns {Promise<{contract, address, txHash}>}
251
+ * @param {Object} [options={}] - Additional deployment options
252
+ * @param {string} [options.botAddress] - Bot address for managing appreciation (defaults to deployer)
253
+ * @returns {Promise<{contract: Object, address: string, txHash: string, type: string}>} Deployment details
238
254
  */
239
255
  async deployManaged(name, options = {}) {
240
256
  const signer = this.chainManager.getSigner();
@@ -254,11 +270,13 @@ export class ContractDeployer {
254
270
  }
255
271
 
256
272
  /**
257
- * Deploy a Zoned contract (tier-based distribution)
273
+ * Deploy a Zoned contract for tier-based distribution.
258
274
  * @param {string} name - Contract name
259
275
  * @param {number} [nZones=6] - Number of zones
260
- * @param {Object} [options] - Additional options
261
- * @returns {Promise<{contract, address, txHash}>}
276
+ * @param {Object} [options={}] - Additional deployment options
277
+ * @param {string} [options.botAddress] - Bot address for managing zones (defaults to deployer)
278
+ * @param {string} [options.creatorUserId] - Creator user ID (defaults to 'creator')
279
+ * @returns {Promise<{contract: Object, address: string, txHash: string, type: string, nZones: number}>} Deployment details
262
280
  */
263
281
  async deployZoned(name, nZones = 6, options = {}) {
264
282
  const signer = this.chainManager.getSigner();
@@ -280,11 +298,11 @@ export class ContractDeployer {
280
298
  }
281
299
 
282
300
  /**
283
- * Deploy an Appreciative contract (peer-to-peer appreciation)
301
+ * Deploy an Appreciative contract for peer-to-peer appreciation.
284
302
  * @param {string} name - Contract name
285
303
  * @param {string} creatorUserId - Creator's user ID
286
- * @param {Object} [options] - Additional options
287
- * @returns {Promise<{contract, address, txHash}>}
304
+ * @param {Object} [options={}] - Additional deployment options
305
+ * @returns {Promise<{contract: Object, address: string, txHash: string, type: string}>} Deployment details
288
306
  */
289
307
  async deployAppreciative(name, creatorUserId, options = {}) {
290
308
  const signer = this.chainManager.getSigner();
@@ -303,13 +321,15 @@ export class ContractDeployer {
303
321
  }
304
322
 
305
323
  /**
306
- * Deploy a Bundle contract (2-way split with steepness)
307
- * This is the simplest way to deploy a holon - no registry needed!
324
+ * Deploy a Bundle contract for 2-way split with steepness-based zone decay.
325
+ * This is the simplest way to deploy a holon - no registry needed.
308
326
  * @param {string} name - Contract name
309
- * @param {number} [steepness=500000000000000000n] - Steepness factor (0.5e18 = 50% decay)
327
+ * @param {bigint|string} [steepness] - Steepness factor (e.g., 0.5e18 = 50% decay, defaults to 0.5e18)
310
328
  * @param {number} [nZones=6] - Number of zones
311
- * @param {Object} [options] - Additional options
312
- * @returns {Promise<{contract, address, txHash}>}
329
+ * @param {Object} [options={}] - Additional deployment options
330
+ * @param {string} [options.creatorUserId] - Creator user ID (defaults to 'creator')
331
+ * @returns {Promise<{contract: Object, address: string, txHash: string, type: string, steepness: bigint, nZones: number, creatorUserId: string, name: string}>} Deployment details
332
+ * @throws {Error} If bytecode is not available
313
333
  */
314
334
  async deployBundle(name, steepness, nZones = 6, options = {}) {
315
335
  const ethers = await this._loadEthers();
@@ -345,12 +365,14 @@ export class ContractDeployer {
345
365
  }
346
366
 
347
367
  /**
348
- * Deploy a Bundle contract directly (simplified 1-click deployment)
349
- * No registry needed - just deploys and returns the address
368
+ * Deploy a Bundle contract directly (simplified 1-click deployment).
369
+ * No registry needed - just deploys and returns the address.
350
370
  * @param {string} holonId - Unique identifier for the holon
351
371
  * @param {string} name - Display name for the holon
352
- * @param {Object} [options] - Options { steepness, nZones }
353
- * @returns {Promise<{address, txHash, contract}>}
372
+ * @param {Object} [options={}] - Deployment options
373
+ * @param {bigint|string} [options.steepness] - Steepness factor
374
+ * @param {number} [options.nZones=6] - Number of zones
375
+ * @returns {Promise<{contract: Object, address: string, txHash: string, type: string, steepness: bigint, nZones: number, creatorUserId: string, name: string}>} Deployment details
354
376
  */
355
377
  async deployBundleDirect(holonId, name, options = {}) {
356
378
  const steepness = options.steepness;
@@ -363,9 +385,9 @@ export class ContractDeployer {
363
385
  }
364
386
 
365
387
  /**
366
- * Deploy a TestToken (ERC20 for testing)
388
+ * Deploy a TestToken ERC20 for testing.
367
389
  * @param {string} [initialSupply='1000000'] - Initial supply in whole tokens
368
- * @returns {Promise<{contract, address, txHash}>}
390
+ * @returns {Promise<{contract: Object, address: string, txHash: string, type: string, initialSupply: string}>} Deployment details
369
391
  */
370
392
  async deployTestToken(initialSupply = '1000000') {
371
393
  const ethers = await this._loadEthers();
@@ -385,11 +407,12 @@ export class ContractDeployer {
385
407
  }
386
408
 
387
409
  /**
388
- * Create a holon bundle through the Holons registry
410
+ * Create a holon bundle through the Holons registry.
389
411
  * @param {string} creatorUserId - Creator's user ID
390
412
  * @param {string} name - Bundle name
391
413
  * @param {number} [parameter=70] - Split parameter
392
- * @returns {Promise<{address, txHash}>}
414
+ * @returns {Promise<{address: string, txHash: string, name: string, creatorUserId: string}>} Created holon details
415
+ * @throws {Error} If Holons registry not deployed
393
416
  */
394
417
  async createHolonBundle(creatorUserId, name, parameter = 70) {
395
418
  if (!this.deployedContracts.holons) {
@@ -425,10 +448,11 @@ export class ContractDeployer {
425
448
  }
426
449
 
427
450
  /**
428
- * Get contract instance by address
451
+ * Get contract instance by address and type.
429
452
  * @param {string} address - Contract address
430
- * @param {string} type - Contract type (Splitter, Managed, Zoned, etc.)
431
- * @returns {Promise<Contract>}
453
+ * @param {string} type - Contract type (Splitter, Managed, Zoned, Appreciative, Bundle, Holons, TestToken)
454
+ * @returns {Promise<Object>} Ethers.js Contract instance
455
+ * @throws {Error} If unknown contract type
432
456
  */
433
457
  async getContract(address, type) {
434
458
  const abi = ABIs[type];
@@ -439,24 +463,28 @@ export class ContractDeployer {
439
463
  }
440
464
 
441
465
  /**
442
- * Get deployed contract addresses
443
- * @returns {Object}
466
+ * Get deployed contract addresses.
467
+ * @returns {Object} Map of contract names to addresses
444
468
  */
445
469
  getDeployedAddresses() {
446
470
  return { ...this.deployedContracts };
447
471
  }
448
472
 
449
473
  /**
450
- * Load previously deployed contracts
451
- * @param {Object} addresses - Contract addresses
474
+ * Load previously deployed contract addresses.
475
+ * @param {Object} addresses - Map of contract names to addresses
452
476
  */
453
477
  loadDeployedAddresses(addresses) {
454
478
  this.deployedContracts = { ...addresses };
455
479
  }
456
480
 
457
481
  /**
458
- * Internal: Deploy a contract
482
+ * Internal helper to deploy a contract.
459
483
  * @private
484
+ * @param {Array} abi - Contract ABI
485
+ * @param {string} bytecode - Contract bytecode
486
+ * @param {Array} constructorArgs - Constructor arguments
487
+ * @returns {Promise<{contract: Object, address: string, txHash: string, explorerUrl: string|null}>} Deployment result
460
488
  */
461
489
  async _deployContract(abi, bytecode, constructorArgs) {
462
490
  const result = await this.chainManager.deployContract(abi, bytecode, constructorArgs);
@@ -1,12 +1,12 @@
1
1
  /**
2
- * Event Listener for Sankey Flow Visualization
3
- *
4
- * Listens to contract events and transforms them into a format
5
- * suitable for Sankey diagram visualization of fund flows.
2
+ * @fileoverview Event listener for Sankey flow visualization.
3
+ * Listens to contract events and transforms them into Sankey diagram format for visualizing fund flows.
4
+ * @module contracts/event-listener
6
5
  */
7
6
 
8
7
  /**
9
- * Standard Sankey event types emitted by our contracts
8
+ * Standard Sankey event types emitted by Holosphere contracts.
9
+ * @constant {Object}
10
10
  */
11
11
  export const SANKEY_EVENTS = {
12
12
  // Fund flow events
@@ -38,9 +38,15 @@ export const SANKEY_EVENTS = {
38
38
  };
39
39
 
40
40
  /**
41
- * EventListener class for tracking contract events
41
+ * Tracks contract events and transforms them into Sankey diagram format.
42
+ * Maintains event history and provides real-time flow visualization data.
43
+ * @class
42
44
  */
43
45
  export class EventListener {
46
+ /**
47
+ * Create a new EventListener instance.
48
+ * @param {ChainManager} chainManager - Chain manager instance
49
+ */
44
50
  constructor(chainManager) {
45
51
  this.chainManager = chainManager;
46
52
  this.listeners = new Map();
@@ -50,10 +56,10 @@ export class EventListener {
50
56
  }
51
57
 
52
58
  /**
53
- * Start listening to all Sankey-relevant events on a contract
54
- * @param {string} contractAddress - The contract address
59
+ * Start listening to all Sankey-relevant events on a contract.
60
+ * @param {string} contractAddress - Contract address
55
61
  * @param {string} holonId - Human-readable holon identifier
56
- * @param {Object} contract - ethers.js contract instance
62
+ * @param {Object} contract - Ethers.js contract instance
57
63
  */
58
64
  async listenToContract(contractAddress, holonId, contract) {
59
65
  const eventFilters = [
@@ -86,7 +92,8 @@ export class EventListener {
86
92
  }
87
93
 
88
94
  /**
89
- * Stop listening to a contract
95
+ * Stop listening to a specific contract.
96
+ * @param {string} contractAddress - Contract address
90
97
  */
91
98
  stopListening(contractAddress) {
92
99
  const listener = this.listeners.get(contractAddress);
@@ -97,7 +104,7 @@ export class EventListener {
97
104
  }
98
105
 
99
106
  /**
100
- * Stop all listeners
107
+ * Stop all active listeners.
101
108
  */
102
109
  stopAll() {
103
110
  for (const [address, listener] of this.listeners) {
@@ -107,7 +114,12 @@ export class EventListener {
107
114
  }
108
115
 
109
116
  /**
110
- * Handle incoming event and transform to Sankey data
117
+ * Handle incoming event and transform to Sankey data.
118
+ * @private
119
+ * @param {string} eventName - Event name
120
+ * @param {Array} args - Event arguments
121
+ * @param {string} contractAddress - Contract address
122
+ * @param {string} holonId - Holon identifier
111
123
  */
112
124
  _handleEvent(eventName, args, contractAddress, holonId) {
113
125
  const event = args[args.length - 1]; // Last arg is the event object
@@ -133,7 +145,11 @@ export class EventListener {
133
145
  }
134
146
 
135
147
  /**
136
- * Parse event data based on event type
148
+ * Parse event data based on event type.
149
+ * @private
150
+ * @param {string} eventName - Event name
151
+ * @param {Array} args - Event arguments
152
+ * @returns {Object} Parsed event data
137
153
  */
138
154
  _parseEventData(eventName, args) {
139
155
  switch (eventName) {
@@ -237,7 +253,9 @@ export class EventListener {
237
253
  }
238
254
 
239
255
  /**
240
- * Update Sankey nodes and links based on event
256
+ * Update Sankey nodes and links based on event.
257
+ * @private
258
+ * @param {Object} event - Parsed event object
241
259
  */
242
260
  _updateSankeyData(event) {
243
261
  const { type, data } = event;
@@ -303,7 +321,11 @@ export class EventListener {
303
321
  }
304
322
 
305
323
  /**
306
- * Ensure a node exists in the Sankey graph
324
+ * Ensure a node exists in the Sankey graph.
325
+ * @private
326
+ * @param {string} id - Node ID
327
+ * @param {string} type - Node type (external, contract, user, wallet)
328
+ * @param {string} label - Display label
307
329
  */
308
330
  _ensureNode(id, type, label) {
309
331
  if (!this.sankeyNodes.has(id)) {
@@ -312,9 +334,13 @@ export class EventListener {
312
334
  }
313
335
 
314
336
  /**
315
- * Get Sankey-compatible data for visualization
316
- * @param {Object} options - Filter options
317
- * @returns {Object} { nodes: [], links: [] }
337
+ * Get Sankey-compatible data for visualization.
338
+ * @param {Object} [options={}] - Filter options
339
+ * @param {string} [options.tokenAddress] - Filter by token address
340
+ * @param {number} [options.fromBlock] - Filter from block number
341
+ * @param {number} [options.toBlock] - Filter to block number
342
+ * @param {string} [options.minValue] - Minimum value to include
343
+ * @returns {Object} Sankey data with nodes and links arrays
318
344
  */
319
345
  getSankeyData(options = {}) {
320
346
  const { tokenAddress, fromBlock, toBlock, minValue } = options;
@@ -371,8 +397,8 @@ export class EventListener {
371
397
  }
372
398
 
373
399
  /**
374
- * Get aggregated flow summary
375
- * @returns {Object} Summary statistics
400
+ * Get aggregated flow summary statistics.
401
+ * @returns {Object} Summary with inflow/outflow totals and distribution breakdown
376
402
  */
377
403
  getFlowSummary() {
378
404
  const summary = {
@@ -414,10 +440,13 @@ export class EventListener {
414
440
  }
415
441
 
416
442
  /**
417
- * Query historical events from blockchain
418
- * @param {Object} contract - ethers.js contract instance
443
+ * Query historical events from blockchain.
444
+ * @param {Object} contract - Ethers.js contract instance
419
445
  * @param {string} eventName - Event name to query
420
- * @param {Object} options - { fromBlock, toBlock }
446
+ * @param {Object} [options={}] - Query options
447
+ * @param {number} [options.fromBlock=0] - Starting block number
448
+ * @param {number|string} [options.toBlock='latest'] - Ending block number
449
+ * @returns {Promise<Array>} Array of parsed events
421
450
  */
422
451
  async queryPastEvents(contract, eventName, options = {}) {
423
452
  const { fromBlock = 0, toBlock = 'latest' } = options;
@@ -441,10 +470,11 @@ export class EventListener {
441
470
  }
442
471
 
443
472
  /**
444
- * Build Sankey data from historical events
445
- * @param {Object} contract - ethers.js contract instance
473
+ * Build Sankey data from historical blockchain events.
474
+ * @param {Object} contract - Ethers.js contract instance
446
475
  * @param {string} holonId - Holon identifier
447
- * @param {Object} options - Query options
476
+ * @param {Object} [options={}] - Query options (fromBlock, toBlock)
477
+ * @returns {Promise<Object>} Sankey data with nodes and links
448
478
  */
449
479
  async buildFromHistory(contract, holonId, options = {}) {
450
480
  const eventTypes = [
@@ -469,7 +499,7 @@ export class EventListener {
469
499
  }
470
500
 
471
501
  /**
472
- * Clear all stored data
502
+ * Clear all stored event data.
473
503
  */
474
504
  clear() {
475
505
  this.eventHistory = [];
@@ -478,7 +508,8 @@ export class EventListener {
478
508
  }
479
509
 
480
510
  /**
481
- * Export data for persistence
511
+ * Export data for persistence.
512
+ * @returns {Object} Serializable event data
482
513
  */
483
514
  export() {
484
515
  return {
@@ -492,7 +523,8 @@ export class EventListener {
492
523
  }
493
524
 
494
525
  /**
495
- * Import previously exported data
526
+ * Import previously exported data.
527
+ * @param {Object} data - Previously exported data
496
528
  */
497
529
  import(data) {
498
530
  this.eventHistory = data.events || [];
@@ -1,12 +1,23 @@
1
1
  /**
2
- * HolonContracts - Per-holon contract management
3
- * Links holons to their smart contracts for fractal fund distribution
2
+ * @fileoverview Per-holon contract management for Holosphere.
3
+ * Links holons to their smart contracts for fractal fund distribution.
4
+ * @module contracts/holon-contracts
4
5
  */
5
6
 
6
7
  import { ContractDeployer, ABIs } from './deployer.js';
7
8
  import { ContractOperations } from './operations.js';
8
9
 
10
+ /**
11
+ * Manages the mapping between holons and their deployed contracts.
12
+ * Provides deployment, linking, and retrieval operations.
13
+ * @class
14
+ */
9
15
  export class HolonContracts {
16
+ /**
17
+ * Create a new HolonContracts instance.
18
+ * @param {ChainManager} chainManager - Chain manager instance
19
+ * @param {ContractDeployer} [deployer] - Contract deployer instance (auto-created if not provided)
20
+ */
10
21
  constructor(chainManager, deployer) {
11
22
  this.chainManager = chainManager;
12
23
  this.deployer = deployer || new ContractDeployer(chainManager);
@@ -19,19 +30,20 @@ export class HolonContracts {
19
30
  }
20
31
 
21
32
  /**
22
- * Set storage adapter for persisting holon-contract mappings
23
- * @param {Object} storage - Storage adapter with get/set methods
33
+ * Set storage adapter for persisting holon-contract mappings.
34
+ * @param {Object} storage - Storage adapter with get/set/delete methods
24
35
  */
25
36
  setStorage(storage) {
26
37
  this.storage = storage;
27
38
  }
28
39
 
29
40
  /**
30
- * Deploy a new contract for a holon
41
+ * Deploy a new contract for a holon.
31
42
  * @param {string} holonId - Holon identifier
32
43
  * @param {string} [type='Splitter'] - Contract type (Splitter, Managed, Zoned, Appreciative, Bundle)
33
- * @param {Object} [options] - Deployment options
34
- * @returns {Promise<{contract, address, operations}>}
44
+ * @param {Object} [options={}] - Deployment options (varies by contract type)
45
+ * @returns {Promise<{contract: Object, address: string, operations: ContractOperations, txHash: string, type: string}>} Deployment details
46
+ * @throws {Error} If holon already has a contract
35
47
  */
36
48
  async deploy(holonId, type = 'Splitter', options = {}) {
37
49
  if (this.holonContracts.has(holonId)) {
@@ -106,11 +118,12 @@ export class HolonContracts {
106
118
  }
107
119
 
108
120
  /**
109
- * Link a holon to an existing contract
121
+ * Link a holon to an existing deployed contract.
110
122
  * @param {string} holonId - Holon identifier
111
123
  * @param {string} contractAddress - Existing contract address
112
124
  * @param {string} [type='Splitter'] - Contract type
113
- * @returns {Promise<{contract, address, operations}>}
125
+ * @returns {Promise<{contract: Object, address: string, operations: ContractOperations, type: string}>} Link details
126
+ * @throws {Error} If holon already has a contract or contract is invalid
114
127
  */
115
128
  async link(holonId, contractAddress, type = 'Splitter') {
116
129
  if (this.holonContracts.has(holonId)) {
@@ -159,9 +172,9 @@ export class HolonContracts {
159
172
  }
160
173
 
161
174
  /**
162
- * Unlink a holon from its contract
175
+ * Unlink a holon from its contract.
163
176
  * @param {string} holonId - Holon identifier
164
- * @returns {boolean} True if unlinked, false if no contract was linked
177
+ * @returns {Promise<boolean>} True if unlinked, false if no contract was linked
165
178
  */
166
179
  async unlink(holonId) {
167
180
  if (!this.holonContracts.has(holonId)) {
@@ -179,9 +192,9 @@ export class HolonContracts {
179
192
  }
180
193
 
181
194
  /**
182
- * Get contract for a holon
195
+ * Get contract instance for a holon.
183
196
  * @param {string} holonId - Holon identifier
184
- * @returns {Contract|null}
197
+ * @returns {Object|null} Ethers.js Contract instance or null if not found
185
198
  */
186
199
  getContract(holonId) {
187
200
  const data = this.holonContracts.get(holonId);
@@ -189,9 +202,9 @@ export class HolonContracts {
189
202
  }
190
203
 
191
204
  /**
192
- * Get contract address for a holon
205
+ * Get contract address for a holon.
193
206
  * @param {string} holonId - Holon identifier
194
- * @returns {string|null}
207
+ * @returns {string|null} Contract address or null if not found
195
208
  */
196
209
  getAddress(holonId) {
197
210
  const data = this.holonContracts.get(holonId);
@@ -199,9 +212,9 @@ export class HolonContracts {
199
212
  }
200
213
 
201
214
  /**
202
- * Get operations wrapper for a holon
215
+ * Get operations wrapper for a holon.
203
216
  * @param {string} holonId - Holon identifier
204
- * @returns {ContractOperations|null}
217
+ * @returns {ContractOperations|null} Operations wrapper or null if not found
205
218
  */
206
219
  getOperations(holonId) {
207
220
  const data = this.holonContracts.get(holonId);
@@ -209,9 +222,9 @@ export class HolonContracts {
209
222
  }
210
223
 
211
224
  /**
212
- * Get contract type for a holon
225
+ * Get contract type for a holon.
213
226
  * @param {string} holonId - Holon identifier
214
- * @returns {string|null}
227
+ * @returns {string|null} Contract type or null if not found
215
228
  */
216
229
  getType(holonId) {
217
230
  const data = this.holonContracts.get(holonId);
@@ -219,17 +232,17 @@ export class HolonContracts {
219
232
  }
220
233
 
221
234
  /**
222
- * Check if a holon has a contract
235
+ * Check if a holon has a linked contract.
223
236
  * @param {string} holonId - Holon identifier
224
- * @returns {boolean}
237
+ * @returns {boolean} True if holon has a contract
225
238
  */
226
239
  hasContract(holonId) {
227
240
  return this.holonContracts.has(holonId);
228
241
  }
229
242
 
230
243
  /**
231
- * Get all holon-contract mappings
232
- * @returns {Array<{holonId, address, type}>}
244
+ * Get all holon-contract mappings.
245
+ * @returns {Array<{holonId: string, address: string, type: string, deployedAt?: string, linkedAt?: string}>} Array of mappings
233
246
  */
234
247
  listAll() {
235
248
  const result = [];
@@ -246,9 +259,9 @@ export class HolonContracts {
246
259
  }
247
260
 
248
261
  /**
249
- * Get holons by contract type
262
+ * Get holons by contract type.
250
263
  * @param {string} type - Contract type
251
- * @returns {Array<{holonId, address}>}
264
+ * @returns {Array<{holonId: string, address: string}>} Array of holons with matching type
252
265
  */
253
266
  getByType(type) {
254
267
  const result = [];
@@ -264,8 +277,8 @@ export class HolonContracts {
264
277
  }
265
278
 
266
279
  /**
267
- * Load holon-contract mappings from storage
268
- * @returns {Promise<number>} Number of mappings loaded
280
+ * Load holon-contract mappings from storage.
281
+ * @returns {Promise<number>} Number of mappings successfully loaded
269
282
  */
270
283
  async loadFromStorage() {
271
284
  if (!this.storage) {
@@ -302,8 +315,10 @@ export class HolonContracts {
302
315
  }
303
316
 
304
317
  /**
305
- * Save a holon-contract mapping to storage
318
+ * Save a holon-contract mapping to storage.
306
319
  * @private
320
+ * @param {string} holonId - Holon identifier
321
+ * @param {Object} data - Holon contract data
307
322
  */
308
323
  async _saveMapping(holonId, data) {
309
324
  if (!this.storage) return;
@@ -327,10 +342,10 @@ export class HolonContracts {
327
342
  }
328
343
 
329
344
  /**
330
- * Get required holon operations (throws if not linked)
345
+ * Get required holon operations, throwing if not linked.
331
346
  * @param {string} holonId - Holon identifier
332
- * @returns {ContractOperations}
333
- * @throws {Error} If holon has no contract
347
+ * @returns {ContractOperations} Operations wrapper
348
+ * @throws {Error} If holon has no linked contract
334
349
  */
335
350
  requireOperations(holonId) {
336
351
  const ops = this.getOperations(holonId);
@@ -1,7 +1,6 @@
1
1
  /**
2
- * Holosphere Contracts Module
3
- * Smart contract integration for fractal fund distribution
4
- *
2
+ * @fileoverview Holosphere Contracts Module - Smart contract integration for fractal fund distribution.
3
+ * Provides a complete toolkit for deploying, managing, and interacting with Holosphere smart contracts.
5
4
  * @module contracts
6
5
  */
7
6
 
@@ -53,9 +52,9 @@ import { ContractQueries } from './queries.js';
53
52
  import { NETWORKS } from './networks.js';
54
53
 
55
54
  /**
56
- * Create a complete contracts module instance
57
- * @param {Object} [config] - Configuration options
58
- * @returns {Promise<Object>} Contracts module with all components
55
+ * Create a complete contracts module instance with all components initialized.
56
+ * @param {Object} [config={}] - Configuration options for ChainManager
57
+ * @returns {Promise<{chainManager: ChainManager, deployer: ContractDeployer, holonContracts: HolonContracts}>} Initialized contracts module
59
58
  */
60
59
  export async function createContractsModule(config = {}) {
61
60
  const chainManager = new ChainManager(config);