holosphere 2.0.0-alpha8 → 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.
- package/CHANGELOG.md +446 -0
- package/FEATURES.md +431 -0
- package/LICENSE +29 -166
- package/LICENSE-AGPL.md +180 -0
- package/dist/cdn/holosphere.min.js +55 -0
- package/dist/cdn/holosphere.min.js.map +1 -0
- package/dist/cjs/holosphere.cjs +1 -1
- package/dist/esm/holosphere.js +1 -1
- package/dist/{index-CKffQDmQ.cjs → index-DDGt_V9o.cjs} +2 -2
- package/dist/{index-CKffQDmQ.cjs.map → index-DDGt_V9o.cjs.map} +1 -1
- package/dist/{index-4XHHKe6S.js → index-DJXftyvB.js} +1905 -337
- package/dist/index-DJXftyvB.js.map +1 -0
- package/dist/{index-Dz5kOZMI.cjs → index-DMbdcMtK.cjs} +17 -4
- package/dist/index-DMbdcMtK.cjs.map +1 -0
- package/dist/{index-BjP1TXGz.js → index-DeZ1xz_s.js} +2 -2
- package/dist/{index-BjP1TXGz.js.map → index-DeZ1xz_s.js.map} +1 -1
- package/dist/{indexeddb-storage-lExjjFlV.js → indexeddb-storage-BFt6hMeF.js} +48 -4
- package/dist/indexeddb-storage-BFt6hMeF.js.map +1 -0
- package/dist/{indexeddb-storage-DD7EFBVc.cjs → indexeddb-storage-BK5tv4Sh.cjs} +2 -2
- package/dist/indexeddb-storage-BK5tv4Sh.cjs.map +1 -0
- package/dist/{memory-storage-C68adso2.js → memory-storage-C9HuoL2E.js} +44 -4
- package/dist/memory-storage-C9HuoL2E.js.map +1 -0
- package/dist/{memory-storage-DD_6yyXT.cjs → memory-storage-Dao7jfYG.cjs} +2 -2
- package/dist/memory-storage-Dao7jfYG.cjs.map +1 -0
- package/dist/{secp256k1-DYELiqgx.cjs → secp256k1-BbKzbLtD.cjs} +2 -2
- package/dist/{secp256k1-DYELiqgx.cjs.map → secp256k1-BbKzbLtD.cjs.map} +1 -1
- package/dist/{secp256k1-OM8siPyy.js → secp256k1-CreY7Pcl.js} +2 -2
- package/dist/{secp256k1-OM8siPyy.js.map → secp256k1-CreY7Pcl.js.map} +1 -1
- package/docs/api/ai_aggregation.js.html +333 -0
- package/docs/api/ai_breakdown.js.html +524 -0
- package/docs/api/ai_classifier.js.html +231 -0
- package/docs/api/ai_council.js.html +246 -0
- package/docs/api/ai_embeddings.js.html +304 -0
- package/docs/api/ai_federation-ai.js.html +338 -0
- package/docs/api/ai_h3-ai.js.html +970 -0
- package/docs/api/ai_index.js.html +124 -0
- package/docs/api/ai_json-ops.js.html +241 -0
- package/docs/api/ai_llm-service.js.html +239 -0
- package/docs/api/ai_nl-query.js.html +236 -0
- package/docs/api/ai_relationships.js.html +367 -0
- package/docs/api/ai_schema-extractor.js.html +235 -0
- package/docs/api/ai_spatial.js.html +307 -0
- package/docs/api/ai_tts.js.html +214 -0
- package/docs/api/content_social-protocols.js.html +180 -0
- package/docs/api/core_holosphere.js.html +757 -0
- package/docs/api/crypto_nostr-utils.js.html +306 -0
- package/docs/api/crypto_secp256k1.js.html +267 -0
- package/docs/api/data/search.json +1 -0
- package/docs/api/federation_discovery.js.html +337 -0
- package/docs/api/federation_handshake.js.html +478 -0
- package/docs/api/federation_hologram.js.html +1053 -0
- package/docs/api/federation_registry.js.html +389 -0
- package/docs/api/fonts/Inconsolata-Regular.ttf +0 -0
- package/docs/api/fonts/OpenSans-Regular.ttf +0 -0
- package/docs/api/fonts/WorkSans-Bold.ttf +0 -0
- package/docs/api/global.html +3 -0
- package/docs/api/hierarchical_upcast.js.html +128 -0
- package/docs/api/index.html +265 -0
- package/docs/api/index.js.html +1868 -0
- package/docs/api/lib_ai-methods.js.html +660 -0
- package/docs/api/lib_contract-methods.js.html +445 -0
- package/docs/api/lib_errors.js.html +56 -0
- package/docs/api/lib_federation-methods.js.html +348 -0
- package/docs/api/lib_index.js.html +33 -0
- package/docs/api/module-ai.html +5 -0
- package/docs/api/module-ai_aggregation-SmartAggregation.html +6 -0
- package/docs/api/module-ai_aggregation.SmartAggregation.html +3 -0
- package/docs/api/module-ai_aggregation.html +3 -0
- package/docs/api/module-ai_breakdown-TaskBreakdown.html +5 -0
- package/docs/api/module-ai_breakdown.TaskBreakdown.html +3 -0
- package/docs/api/module-ai_breakdown.html +3 -0
- package/docs/api/module-ai_classifier-Classifier.html +6 -0
- package/docs/api/module-ai_classifier.Classifier.html +3 -0
- package/docs/api/module-ai_classifier.html +3 -0
- package/docs/api/module-ai_council-Council.html +6 -0
- package/docs/api/module-ai_council.Council.html +3 -0
- package/docs/api/module-ai_council.html +3 -0
- package/docs/api/module-ai_embeddings-Embeddings.html +5 -0
- package/docs/api/module-ai_embeddings.Embeddings.html +3 -0
- package/docs/api/module-ai_embeddings.html +3 -0
- package/docs/api/module-ai_federation-ai-FederationAdvisor.html +6 -0
- package/docs/api/module-ai_federation-ai.FederationAdvisor.html +3 -0
- package/docs/api/module-ai_federation-ai.html +3 -0
- package/docs/api/module-ai_h3-ai-H3AI.html +6 -0
- package/docs/api/module-ai_h3-ai.H3AI.html +3 -0
- package/docs/api/module-ai_h3-ai.html +3 -0
- package/docs/api/module-ai_json-ops-JSONOps.html +5 -0
- package/docs/api/module-ai_json-ops.JSONOps.html +3 -0
- package/docs/api/module-ai_json-ops.html +3 -0
- package/docs/api/module-ai_llm-service-LLMService.html +5 -0
- package/docs/api/module-ai_llm-service.LLMService.html +3 -0
- package/docs/api/module-ai_llm-service.html +3 -0
- package/docs/api/module-ai_nl-query-NLQuery.html +5 -0
- package/docs/api/module-ai_nl-query.NLQuery.html +3 -0
- package/docs/api/module-ai_nl-query.html +3 -0
- package/docs/api/module-ai_relationships-RelationshipDiscovery.html +6 -0
- package/docs/api/module-ai_relationships.RelationshipDiscovery.html +3 -0
- package/docs/api/module-ai_relationships.html +3 -0
- package/docs/api/module-ai_schema-extractor-SchemaExtractor.html +5 -0
- package/docs/api/module-ai_schema-extractor.SchemaExtractor.html +3 -0
- package/docs/api/module-ai_schema-extractor.html +3 -0
- package/docs/api/module-ai_spatial-SpatialAnalysis.html +6 -0
- package/docs/api/module-ai_spatial.SpatialAnalysis.html +3 -0
- package/docs/api/module-ai_spatial.html +3 -0
- package/docs/api/module-ai_tts-TTS.html +5 -0
- package/docs/api/module-ai_tts.TTS.html +3 -0
- package/docs/api/module-ai_tts.html +3 -0
- package/docs/api/module-content_social-protocols.html +3 -0
- package/docs/api/module-core_holosphere-HoloSphere.html +6 -0
- package/docs/api/module-core_holosphere.HoloSphere.html +3 -0
- package/docs/api/module-core_holosphere.html +3 -0
- package/docs/api/module-crypto_nostr-utils.html +3 -0
- package/docs/api/module-crypto_secp256k1.html +3 -0
- package/docs/api/module-federation_hologram.html +3 -0
- package/docs/api/module-hierarchical_upcast.html +3 -0
- package/docs/api/module-holosphere-HoloSphereBase.html +3 -0
- package/docs/api/module-holosphere.html +3 -0
- package/docs/api/module-lib_ai-methods.html +3 -0
- package/docs/api/module-lib_contract-methods.html +3 -0
- package/docs/api/module-lib_errors-AuthorizationError.html +3 -0
- package/docs/api/module-lib_errors-ValidationError.html +3 -0
- package/docs/api/module-lib_errors.AuthorizationError.html +3 -0
- package/docs/api/module-lib_errors.ValidationError.html +3 -0
- package/docs/api/module-lib_errors.html +3 -0
- package/docs/api/module-lib_federation-methods.html +3 -0
- package/docs/api/module-lib_index.html +3 -0
- package/docs/api/module-schema_validator-ValidationError.html +3 -0
- package/docs/api/module-schema_validator.ValidationError.html +3 -0
- package/docs/api/module-schema_validator.html +3 -0
- package/docs/api/module-spatial_h3-operations.html +4 -0
- package/docs/api/module-storage_backend-factory.BackendFactory.html +3 -0
- package/docs/api/module-storage_backend-factory.html +3 -0
- package/docs/api/module-storage_backend-interface-StorageBackend.html +3 -0
- package/docs/api/module-storage_backend-interface.StorageBackend.html +3 -0
- package/docs/api/module-storage_backend-interface.html +3 -0
- package/docs/api/module-storage_backends_activitypub-backend-ActivityPubBackend.html +7 -0
- package/docs/api/module-storage_backends_activitypub-backend.ActivityPubBackend.html +3 -0
- package/docs/api/module-storage_backends_activitypub-backend.html +3 -0
- package/docs/api/module-storage_backends_activitypub_server-ActivityPubServer.html +8 -0
- package/docs/api/module-storage_backends_activitypub_server.ActivityPubServer.html +3 -0
- package/docs/api/module-storage_backends_activitypub_server.html +3 -0
- package/docs/api/module-storage_backends_gundb-backend-GunDBBackend.html +7 -0
- package/docs/api/module-storage_backends_gundb-backend.GunDBBackend.html +3 -0
- package/docs/api/module-storage_backends_gundb-backend.html +3 -0
- package/docs/api/module-storage_backends_nostr-backend-NostrBackend.html +8 -0
- package/docs/api/module-storage_backends_nostr-backend.NostrBackend.html +3 -0
- package/docs/api/module-storage_backends_nostr-backend.html +3 -0
- package/docs/api/module-storage_filesystem-storage-FileSystemStorage.html +5 -0
- package/docs/api/module-storage_filesystem-storage-browser-FileSystemStorage.html +3 -0
- package/docs/api/module-storage_filesystem-storage-browser.FileSystemStorage.html +3 -0
- package/docs/api/module-storage_filesystem-storage-browser.html +3 -0
- package/docs/api/module-storage_filesystem-storage.FileSystemStorage.html +3 -0
- package/docs/api/module-storage_filesystem-storage.html +3 -0
- package/docs/api/module-storage_global-tables.html +3 -0
- package/docs/api/module-storage_gun-async.html +3 -0
- package/docs/api/module-storage_gun-auth-GunAuth.html +5 -0
- package/docs/api/module-storage_gun-auth.GunAuth.html +3 -0
- package/docs/api/module-storage_gun-auth.html +3 -0
- package/docs/api/module-storage_gun-federation.html +3 -0
- package/docs/api/module-storage_gun-references-GunReferenceHandler.html +5 -0
- package/docs/api/module-storage_gun-references.GunReferenceHandler.html +3 -0
- package/docs/api/module-storage_gun-references.html +3 -0
- package/docs/api/module-storage_gun-schema-GunSchemaValidator.html +5 -0
- package/docs/api/module-storage_gun-schema.GunSchemaValidator.html +3 -0
- package/docs/api/module-storage_gun-schema.html +3 -0
- package/docs/api/module-storage_gun-wrapper.html +11 -0
- package/docs/api/module-storage_indexeddb-storage-IndexedDBStorage.html +5 -0
- package/docs/api/module-storage_indexeddb-storage.IndexedDBStorage.html +3 -0
- package/docs/api/module-storage_indexeddb-storage.html +3 -0
- package/docs/api/module-storage_key-storage-simple.html +3 -0
- package/docs/api/module-storage_key-storage.html +4 -0
- package/docs/api/module-storage_memory-storage-MemoryStorage.html +5 -0
- package/docs/api/module-storage_memory-storage.MemoryStorage.html +3 -0
- package/docs/api/module-storage_memory-storage.html +3 -0
- package/docs/api/module-storage_migration-MigrationTool.html +6 -0
- package/docs/api/module-storage_migration.MigrationTool.html +3 -0
- package/docs/api/module-storage_migration.html +3 -0
- package/docs/api/module-storage_nostr-async.html +18 -0
- package/docs/api/module-storage_nostr-client-LRUCache.html +3 -0
- package/docs/api/module-storage_nostr-client-NostrClient.html +7 -0
- package/docs/api/module-storage_nostr-client.NostrClient.html +15 -0
- package/docs/api/module-storage_nostr-client.html +6 -0
- package/docs/api/module-storage_nostr-wrapper.html +3 -0
- package/docs/api/module-storage_outbox-queue-OutboxQueue.html +4 -0
- package/docs/api/module-storage_outbox-queue.OutboxQueue.html +3 -0
- package/docs/api/module-storage_outbox-queue.html +3 -0
- package/docs/api/module-storage_persistent-storage-PersistentStorage.html +3 -0
- package/docs/api/module-storage_persistent-storage.html +4 -0
- package/docs/api/module-storage_sync-service-SyncService.html +5 -0
- package/docs/api/module-storage_sync-service.SyncService.html +3 -0
- package/docs/api/module-storage_sync-service.html +3 -0
- package/docs/api/module-storage_unified-storage.html +3 -0
- package/docs/api/module-subscriptions_manager.SubscriptionRegistry.html +3 -0
- package/docs/api/module-subscriptions_manager.html +3 -0
- package/docs/api/schema_validator.js.html +113 -0
- package/docs/api/scripts/core.js +726 -0
- package/docs/api/scripts/core.min.js +23 -0
- package/docs/api/scripts/resize.js +90 -0
- package/docs/api/scripts/search.js +265 -0
- package/docs/api/scripts/search.min.js +6 -0
- package/docs/api/scripts/third-party/Apache-License-2.0.txt +202 -0
- package/docs/api/scripts/third-party/fuse.js +9 -0
- package/docs/api/scripts/third-party/hljs-line-num-original.js +369 -0
- package/docs/api/scripts/third-party/hljs-line-num.js +1 -0
- package/docs/api/scripts/third-party/hljs-original.js +5171 -0
- package/docs/api/scripts/third-party/hljs.js +1 -0
- package/docs/api/scripts/third-party/popper.js +5 -0
- package/docs/api/scripts/third-party/tippy.js +1 -0
- package/docs/api/scripts/third-party/tocbot.js +672 -0
- package/docs/api/scripts/third-party/tocbot.min.js +1 -0
- package/docs/api/spatial_h3-operations.js.html +129 -0
- package/docs/api/storage_backend-factory.js.html +133 -0
- package/docs/api/storage_backend-interface.js.html +164 -0
- package/docs/api/storage_backends_activitypub-backend.js.html +298 -0
- package/docs/api/storage_backends_activitypub_server.js.html +678 -0
- package/docs/api/storage_backends_gundb-backend.js.html +878 -0
- package/docs/api/storage_backends_nostr-backend.js.html +254 -0
- package/docs/api/storage_filesystem-storage-browser.js.html +83 -0
- package/docs/api/storage_filesystem-storage.js.html +207 -0
- package/docs/api/storage_global-tables.js.html +116 -0
- package/docs/api/storage_gun-async.js.html +344 -0
- package/docs/api/storage_gun-auth.js.html +376 -0
- package/docs/api/storage_gun-federation.js.html +788 -0
- package/docs/api/storage_gun-references.js.html +212 -0
- package/docs/api/storage_gun-schema.js.html +309 -0
- package/docs/api/storage_gun-wrapper.js.html +645 -0
- package/docs/api/storage_indexeddb-storage.js.html +224 -0
- package/docs/api/storage_key-storage-simple.js.html +102 -0
- package/docs/api/storage_key-storage.js.html +171 -0
- package/docs/api/storage_memory-storage.js.html +128 -0
- package/docs/api/storage_migration.js.html +354 -0
- package/docs/api/storage_nostr-async.js.html +1076 -0
- package/docs/api/storage_nostr-client.js.html +1598 -0
- package/docs/api/storage_nostr-wrapper.js.html +218 -0
- package/docs/api/storage_outbox-queue.js.html +248 -0
- package/docs/api/storage_persistent-storage.js.html +160 -0
- package/docs/api/storage_sync-service.js.html +201 -0
- package/docs/api/storage_unified-storage.js.html +157 -0
- package/docs/api/styles/clean-jsdoc-theme-base.css +1159 -0
- package/docs/api/styles/clean-jsdoc-theme-dark.css +412 -0
- package/docs/api/styles/clean-jsdoc-theme-light.css +482 -0
- package/docs/api/styles/clean-jsdoc-theme-scrollbar.css +30 -0
- package/docs/api/styles/clean-jsdoc-theme-without-scrollbar.min.css +1 -0
- package/docs/api/styles/clean-jsdoc-theme.min.css +1 -0
- package/docs/api/subscriptions_manager.js.html +162 -0
- package/jsdoc.json +26 -0
- package/package.json +14 -3
- package/src/ai/aggregation.js +13 -2
- package/src/ai/breakdown.js +12 -2
- package/src/ai/classifier.js +14 -3
- package/src/ai/council.js +22 -7
- package/src/ai/embeddings.js +37 -15
- package/src/ai/federation-ai.js +13 -2
- package/src/ai/h3-ai.js +14 -2
- package/src/ai/index.js +16 -7
- package/src/ai/json-ops.js +18 -5
- package/src/ai/llm-service.js +62 -31
- package/src/ai/nl-query.js +12 -2
- package/src/ai/relationships.js +13 -2
- package/src/ai/schema-extractor.js +24 -10
- package/src/ai/spatial.js +13 -2
- package/src/ai/tts.js +25 -8
- package/src/content/social-protocols.js +34 -25
- package/src/contracts/chain-manager.js +68 -40
- package/src/contracts/deployer.js +70 -42
- package/src/contracts/event-listener.js +61 -29
- package/src/contracts/holon-contracts.js +46 -31
- package/src/contracts/index.js +5 -6
- package/src/contracts/networks.js +19 -14
- package/src/contracts/operations.js +58 -41
- package/src/contracts/queries.js +54 -20
- package/src/core/holosphere.js +35 -6
- package/src/crypto/nostr-utils.js +82 -76
- package/src/crypto/secp256k1.js +7 -2
- package/src/federation/handshake.js +7 -7
- package/src/federation/hologram.js +9 -1
- package/src/hierarchical/upcast.js +34 -20
- package/src/index.js +655 -5
- package/src/lib/ai-methods.js +352 -3
- package/src/lib/contract-methods.js +152 -3
- package/src/lib/errors.js +31 -1
- package/src/lib/federation-methods.js +110 -3
- package/src/lib/index.js +9 -5
- package/src/schema/validator.js +22 -3
- package/src/spatial/h3-operations.js +17 -1
- package/src/storage/backend-factory.js +7 -2
- package/src/storage/backend-interface.js +21 -2
- package/src/storage/backends/activitypub/server.js +25 -3
- package/src/storage/backends/activitypub-backend.js +25 -2
- package/src/storage/backends/gundb-backend.js +29 -2
- package/src/storage/backends/nostr-backend.js +116 -1
- package/src/storage/filesystem-storage-browser.js +42 -2
- package/src/storage/filesystem-storage.js +72 -5
- package/src/storage/global-tables.js +7 -2
- package/src/storage/gun-async.js +20 -11
- package/src/storage/gun-auth.js +15 -4
- package/src/storage/gun-federation.js +14 -5
- package/src/storage/gun-references.js +16 -5
- package/src/storage/gun-schema.js +25 -10
- package/src/storage/gun-wrapper.js +99 -36
- package/src/storage/indexeddb-storage.js +65 -4
- package/src/storage/key-storage-simple.js +32 -9
- package/src/storage/key-storage.js +45 -13
- package/src/storage/memory-storage.js +65 -4
- package/src/storage/migration.js +20 -7
- package/src/storage/nostr-async.js +157 -67
- package/src/storage/nostr-client.js +173 -49
- package/src/storage/nostr-wrapper.js +6 -2
- package/src/storage/outbox-queue.js +55 -18
- package/src/storage/persistent-storage.js +56 -13
- package/src/storage/sync-service.js +51 -17
- package/src/storage/unified-storage.js +7 -2
- package/src/subscriptions/manager.js +33 -16
- package/dist/index-4XHHKe6S.js.map +0 -1
- package/dist/index-Dz5kOZMI.cjs.map +0 -1
- package/dist/indexeddb-storage-DD7EFBVc.cjs.map +0 -1
- package/dist/indexeddb-storage-lExjjFlV.js.map +0 -1
- package/dist/memory-storage-C68adso2.js.map +0 -1
- package/dist/memory-storage-DD_6yyXT.cjs.map +0 -1
- /package/{cleanup-test-data.js → scripts/cleanup-test-data.js} +0 -0
- /package/{test-ai-real-api.js → scripts/test-ai-real-api.js} +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Event
|
|
3
|
-
*
|
|
4
|
-
*
|
|
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
|
|
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
|
-
*
|
|
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 -
|
|
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 -
|
|
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
|
-
* @
|
|
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
|
|
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 -
|
|
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 -
|
|
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 -
|
|
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
|
-
*
|
|
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 {
|
|
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
|
|
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);
|
package/src/contracts/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Holosphere Contracts Module
|
|
3
|
-
*
|
|
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<
|
|
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);
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Multi-chain network configurations for Holosphere contracts
|
|
3
|
-
* Supports Ethereum, Polygon, Arbitrum, Base, Optimism and testnets
|
|
2
|
+
* @fileoverview Multi-chain network configurations for Holosphere contracts.
|
|
3
|
+
* Supports Ethereum, Polygon, Arbitrum, Base, Optimism, and their testnets.
|
|
4
|
+
* @module contracts/networks
|
|
4
5
|
*/
|
|
5
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Network configurations for all supported EVM chains.
|
|
9
|
+
* @constant {Object}
|
|
10
|
+
*/
|
|
6
11
|
export const NETWORKS = {
|
|
7
12
|
// ========== MAINNETS ==========
|
|
8
13
|
ethereum: {
|
|
@@ -152,9 +157,9 @@ export const NETWORKS = {
|
|
|
152
157
|
};
|
|
153
158
|
|
|
154
159
|
/**
|
|
155
|
-
* Get network configuration by name or chain ID
|
|
156
|
-
* @param {string|number} networkOrChainId - Network name or chain ID
|
|
157
|
-
* @returns {Object|null} Network configuration or null if not found
|
|
160
|
+
* Get network configuration by name or chain ID.
|
|
161
|
+
* @param {string|number} networkOrChainId - Network name (e.g., 'sepolia') or chain ID (e.g., 11155111)
|
|
162
|
+
* @returns {Object|null} Network configuration object or null if not found
|
|
158
163
|
*/
|
|
159
164
|
export function getNetwork(networkOrChainId) {
|
|
160
165
|
if (typeof networkOrChainId === 'string') {
|
|
@@ -170,9 +175,9 @@ export function getNetwork(networkOrChainId) {
|
|
|
170
175
|
}
|
|
171
176
|
|
|
172
177
|
/**
|
|
173
|
-
* Get all networks of a specific type
|
|
178
|
+
* Get all networks of a specific type.
|
|
174
179
|
* @param {'mainnet'|'testnet'|'local'} type - Network type
|
|
175
|
-
* @returns {Object}
|
|
180
|
+
* @returns {Object} Map of networks matching the specified type
|
|
176
181
|
*/
|
|
177
182
|
export function getNetworksByType(type) {
|
|
178
183
|
return Object.fromEntries(
|
|
@@ -181,7 +186,7 @@ export function getNetworksByType(type) {
|
|
|
181
186
|
}
|
|
182
187
|
|
|
183
188
|
/**
|
|
184
|
-
* List all available network names
|
|
189
|
+
* List all available network names.
|
|
185
190
|
* @returns {string[]} Array of network names
|
|
186
191
|
*/
|
|
187
192
|
export function listNetworks() {
|
|
@@ -189,19 +194,19 @@ export function listNetworks() {
|
|
|
189
194
|
}
|
|
190
195
|
|
|
191
196
|
/**
|
|
192
|
-
* Check if a network is supported
|
|
197
|
+
* Check if a network is supported.
|
|
193
198
|
* @param {string} network - Network name
|
|
194
|
-
* @returns {boolean}
|
|
199
|
+
* @returns {boolean} True if network is supported
|
|
195
200
|
*/
|
|
196
201
|
export function isNetworkSupported(network) {
|
|
197
202
|
return network in NETWORKS;
|
|
198
203
|
}
|
|
199
204
|
|
|
200
205
|
/**
|
|
201
|
-
* Get explorer URL for a transaction
|
|
206
|
+
* Get block explorer URL for a transaction.
|
|
202
207
|
* @param {string} network - Network name
|
|
203
208
|
* @param {string} txHash - Transaction hash
|
|
204
|
-
* @returns {string|null} Explorer URL or null
|
|
209
|
+
* @returns {string|null} Explorer URL or null if network has no explorer
|
|
205
210
|
*/
|
|
206
211
|
export function getTxUrl(network, txHash) {
|
|
207
212
|
const config = NETWORKS[network];
|
|
@@ -210,10 +215,10 @@ export function getTxUrl(network, txHash) {
|
|
|
210
215
|
}
|
|
211
216
|
|
|
212
217
|
/**
|
|
213
|
-
* Get explorer URL for an address
|
|
218
|
+
* Get block explorer URL for an address.
|
|
214
219
|
* @param {string} network - Network name
|
|
215
220
|
* @param {string} address - Contract or wallet address
|
|
216
|
-
* @returns {string|null} Explorer URL or null
|
|
221
|
+
* @returns {string|null} Explorer URL or null if network has no explorer
|
|
217
222
|
*/
|
|
218
223
|
export function getAddressUrl(network, address) {
|
|
219
224
|
const config = NETWORKS[network];
|