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,9 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* Provides a
|
|
2
|
+
* @fileoverview Unified operations interface for all Holosphere contract types.
|
|
3
|
+
* Provides a clean API for member management, fund distribution, and contract-specific operations.
|
|
4
|
+
* @module contracts/operations
|
|
4
5
|
*/
|
|
5
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Provides a unified interface for interacting with all Holosphere contract types.
|
|
9
|
+
* Wraps contract functions with clear parameters and type checking.
|
|
10
|
+
* @class
|
|
11
|
+
*/
|
|
6
12
|
export class ContractOperations {
|
|
13
|
+
/**
|
|
14
|
+
* Create a new ContractOperations instance.
|
|
15
|
+
* @param {Object} contract - Ethers.js Contract instance
|
|
16
|
+
* @param {string} type - Contract type (Splitter, Managed, Zoned, Appreciative, Bundle)
|
|
17
|
+
* @param {ChainManager} chainManager - Chain manager instance
|
|
18
|
+
*/
|
|
7
19
|
constructor(contract, type, chainManager) {
|
|
8
20
|
this.contract = contract;
|
|
9
21
|
this.type = type;
|
|
@@ -12,8 +24,9 @@ export class ContractOperations {
|
|
|
12
24
|
}
|
|
13
25
|
|
|
14
26
|
/**
|
|
15
|
-
* Load ethers dynamically
|
|
27
|
+
* Load ethers.js library dynamically.
|
|
16
28
|
* @private
|
|
29
|
+
* @returns {Promise<Object>} Ethers.js module
|
|
17
30
|
*/
|
|
18
31
|
async _loadEthers() {
|
|
19
32
|
if (!this.ethers) {
|
|
@@ -27,9 +40,9 @@ export class ContractOperations {
|
|
|
27
40
|
// ========================================================================
|
|
28
41
|
|
|
29
42
|
/**
|
|
30
|
-
* Add a single member to the contract
|
|
43
|
+
* Add a single member to the contract.
|
|
31
44
|
* @param {string} userId - User identifier (string-based, e.g., 'alice', 'telegram_12345')
|
|
32
|
-
* @returns {Promise<{txHash, receipt}>}
|
|
45
|
+
* @returns {Promise<{txHash: string, receipt: Object}>} Transaction details
|
|
33
46
|
*/
|
|
34
47
|
async addMember(userId) {
|
|
35
48
|
const tx = await this.contract.addMember(userId);
|
|
@@ -38,9 +51,9 @@ export class ContractOperations {
|
|
|
38
51
|
}
|
|
39
52
|
|
|
40
53
|
/**
|
|
41
|
-
* Add multiple members at once (batch operation)
|
|
54
|
+
* Add multiple members at once (batch operation).
|
|
42
55
|
* @param {string[]} userIds - Array of user identifiers
|
|
43
|
-
* @returns {Promise<{txHash, receipt}>}
|
|
56
|
+
* @returns {Promise<{txHash: string, receipt: Object}>} Transaction details
|
|
44
57
|
*/
|
|
45
58
|
async addMembers(userIds) {
|
|
46
59
|
const tx = await this.contract.addMembers(userIds);
|
|
@@ -49,8 +62,8 @@ export class ContractOperations {
|
|
|
49
62
|
}
|
|
50
63
|
|
|
51
64
|
/**
|
|
52
|
-
* Get all member user IDs
|
|
53
|
-
* @returns {Promise<string[]>}
|
|
65
|
+
* Get all member user IDs.
|
|
66
|
+
* @returns {Promise<string[]>} Array of user IDs
|
|
54
67
|
*/
|
|
55
68
|
async getMembers() {
|
|
56
69
|
const userIds = await this.contract.userIds();
|
|
@@ -75,9 +88,9 @@ export class ContractOperations {
|
|
|
75
88
|
}
|
|
76
89
|
|
|
77
90
|
/**
|
|
78
|
-
* Check if a user is a member
|
|
91
|
+
* Check if a user is a member.
|
|
79
92
|
* @param {string} userId - User identifier
|
|
80
|
-
* @returns {Promise<boolean>}
|
|
93
|
+
* @returns {Promise<boolean>} True if user is a member
|
|
81
94
|
*/
|
|
82
95
|
async isMember(userId) {
|
|
83
96
|
try {
|
|
@@ -92,7 +105,7 @@ export class ContractOperations {
|
|
|
92
105
|
}
|
|
93
106
|
|
|
94
107
|
/**
|
|
95
|
-
* Get the address associated with a user ID
|
|
108
|
+
* Get the Ethereum address associated with a user ID.
|
|
96
109
|
* @param {string} userId - User identifier
|
|
97
110
|
* @returns {Promise<string>} Ethereum address (or zero address if not set)
|
|
98
111
|
*/
|
|
@@ -105,10 +118,10 @@ export class ContractOperations {
|
|
|
105
118
|
// ========================================================================
|
|
106
119
|
|
|
107
120
|
/**
|
|
108
|
-
* Trigger reward distribution for ERC20 tokens
|
|
121
|
+
* Trigger reward distribution for ERC20 tokens.
|
|
109
122
|
* @param {string} tokenAddress - ERC20 token contract address
|
|
110
123
|
* @param {string|bigint} amount - Amount in wei (or token's smallest unit)
|
|
111
|
-
* @returns {Promise<{txHash, receipt}>}
|
|
124
|
+
* @returns {Promise<{txHash: string, receipt: Object}>} Transaction details
|
|
112
125
|
*/
|
|
113
126
|
async reward(tokenAddress, amount) {
|
|
114
127
|
const ethers = await this._loadEthers();
|
|
@@ -119,9 +132,9 @@ export class ContractOperations {
|
|
|
119
132
|
}
|
|
120
133
|
|
|
121
134
|
/**
|
|
122
|
-
* Trigger reward distribution for ETH
|
|
135
|
+
* Trigger reward distribution for ETH.
|
|
123
136
|
* @param {string} amount - Amount in ETH (e.g., '1.5' for 1.5 ETH)
|
|
124
|
-
* @returns {Promise<{txHash, receipt}>}
|
|
137
|
+
* @returns {Promise<{txHash: string, receipt: Object}>} Transaction details
|
|
125
138
|
*/
|
|
126
139
|
async rewardEth(amount) {
|
|
127
140
|
const ethers = await this._loadEthers();
|
|
@@ -136,9 +149,9 @@ export class ContractOperations {
|
|
|
136
149
|
}
|
|
137
150
|
|
|
138
151
|
/**
|
|
139
|
-
* Send ETH directly to contract (triggers receive/fallback)
|
|
152
|
+
* Send ETH directly to contract (triggers receive/fallback).
|
|
140
153
|
* @param {string} amount - Amount in ETH
|
|
141
|
-
* @returns {Promise<{txHash, receipt}>}
|
|
154
|
+
* @returns {Promise<{txHash: string, receipt: Object}>} Transaction details
|
|
142
155
|
*/
|
|
143
156
|
async sendEth(amount) {
|
|
144
157
|
const ethers = await this._loadEthers();
|
|
@@ -153,10 +166,10 @@ export class ContractOperations {
|
|
|
153
166
|
}
|
|
154
167
|
|
|
155
168
|
/**
|
|
156
|
-
* Claim accumulated rewards for a user
|
|
169
|
+
* Claim accumulated rewards for a user.
|
|
157
170
|
* @param {string} userId - User identifier
|
|
158
171
|
* @param {string} beneficiaryAddress - Ethereum address to receive funds
|
|
159
|
-
* @returns {Promise<{txHash, receipt}>}
|
|
172
|
+
* @returns {Promise<{txHash: string, receipt: Object}>} Transaction details
|
|
160
173
|
*/
|
|
161
174
|
async claim(userId, beneficiaryAddress) {
|
|
162
175
|
const tx = await this.contract.claim(userId, beneficiaryAddress);
|
|
@@ -165,9 +178,9 @@ export class ContractOperations {
|
|
|
165
178
|
}
|
|
166
179
|
|
|
167
180
|
/**
|
|
168
|
-
* Get ETH balance for a user
|
|
181
|
+
* Get ETH balance for a user.
|
|
169
182
|
* @param {string} userId - User identifier
|
|
170
|
-
* @returns {Promise<string>} Balance in ETH
|
|
183
|
+
* @returns {Promise<string>} Balance in ETH as decimal string
|
|
171
184
|
*/
|
|
172
185
|
async getEthBalance(userId) {
|
|
173
186
|
const ethers = await this._loadEthers();
|
|
@@ -176,10 +189,10 @@ export class ContractOperations {
|
|
|
176
189
|
}
|
|
177
190
|
|
|
178
191
|
/**
|
|
179
|
-
* Get ERC20 token balance for a user
|
|
192
|
+
* Get ERC20 token balance for a user.
|
|
180
193
|
* @param {string} userId - User identifier
|
|
181
194
|
* @param {string} tokenAddress - ERC20 token address
|
|
182
|
-
* @returns {Promise<string>} Balance in tokens (18 decimals assumed)
|
|
195
|
+
* @returns {Promise<string>} Balance in tokens (18 decimals assumed) as decimal string
|
|
183
196
|
*/
|
|
184
197
|
async getTokenBalance(userId, tokenAddress) {
|
|
185
198
|
const ethers = await this._loadEthers();
|
|
@@ -188,18 +201,18 @@ export class ContractOperations {
|
|
|
188
201
|
}
|
|
189
202
|
|
|
190
203
|
/**
|
|
191
|
-
* Check if user has already claimed
|
|
204
|
+
* Check if user has already claimed rewards.
|
|
192
205
|
* @param {string} userId - User identifier
|
|
193
|
-
* @returns {Promise<boolean>}
|
|
206
|
+
* @returns {Promise<boolean>} True if user has claimed
|
|
194
207
|
*/
|
|
195
208
|
async hasClaimed(userId) {
|
|
196
209
|
return this.contract.hasClaimed(userId);
|
|
197
210
|
}
|
|
198
211
|
|
|
199
212
|
/**
|
|
200
|
-
* Get total deposited amount for a token
|
|
213
|
+
* Get total deposited amount for a token.
|
|
201
214
|
* @param {string} tokenAddress - Token address (use zero address for ETH)
|
|
202
|
-
* @returns {Promise<string>}
|
|
215
|
+
* @returns {Promise<string>} Total deposited as decimal string
|
|
203
216
|
*/
|
|
204
217
|
async getTotalDeposited(tokenAddress) {
|
|
205
218
|
const ethers = await this._loadEthers();
|
|
@@ -212,10 +225,11 @@ export class ContractOperations {
|
|
|
212
225
|
// ========================================================================
|
|
213
226
|
|
|
214
227
|
/**
|
|
215
|
-
* Set the internal/external split percentages (Splitter only)
|
|
228
|
+
* Set the internal/external split percentages (Splitter only).
|
|
216
229
|
* @param {number} internalPct - Internal percentage (0-100)
|
|
217
230
|
* @param {number} externalPct - External percentage (0-100, must sum to 100 with internal)
|
|
218
|
-
* @returns {Promise<{txHash, receipt}>}
|
|
231
|
+
* @returns {Promise<{txHash: string, receipt: Object}>} Transaction details
|
|
232
|
+
* @throws {Error} If percentages don't sum to 100 or not a Splitter contract
|
|
219
233
|
*/
|
|
220
234
|
async setContractSplit(internalPct, externalPct) {
|
|
221
235
|
this._requireType(['Splitter']);
|
|
@@ -228,8 +242,9 @@ export class ContractOperations {
|
|
|
228
242
|
}
|
|
229
243
|
|
|
230
244
|
/**
|
|
231
|
-
* Get current split percentages (Splitter only)
|
|
232
|
-
* @returns {Promise<{internal: number, external: number}>}
|
|
245
|
+
* Get current split percentages (Splitter only).
|
|
246
|
+
* @returns {Promise<{internal: number, external: number}>} Split percentages
|
|
247
|
+
* @throws {Error} If not a Splitter contract
|
|
233
248
|
*/
|
|
234
249
|
async getContractSplit() {
|
|
235
250
|
this._requireType(['Splitter']);
|
|
@@ -627,8 +642,10 @@ export class ContractOperations {
|
|
|
627
642
|
// ========================================================================
|
|
628
643
|
|
|
629
644
|
/**
|
|
630
|
-
* Require specific contract type(s)
|
|
645
|
+
* Require specific contract type(s).
|
|
631
646
|
* @private
|
|
647
|
+
* @param {string[]} allowedTypes - Array of allowed contract types
|
|
648
|
+
* @throws {Error} If contract type doesn't match
|
|
632
649
|
*/
|
|
633
650
|
_requireType(allowedTypes) {
|
|
634
651
|
if (!allowedTypes.includes(this.type)) {
|
|
@@ -637,28 +654,28 @@ export class ContractOperations {
|
|
|
637
654
|
}
|
|
638
655
|
|
|
639
656
|
/**
|
|
640
|
-
* Get raw contract instance for advanced usage
|
|
641
|
-
* @returns {Contract
|
|
657
|
+
* Get raw contract instance for advanced usage.
|
|
658
|
+
* @returns {Object} Ethers.js Contract instance
|
|
642
659
|
*/
|
|
643
660
|
getRawContract() {
|
|
644
661
|
return this.contract;
|
|
645
662
|
}
|
|
646
663
|
|
|
647
664
|
/**
|
|
648
|
-
* Execute a raw contract call
|
|
665
|
+
* Execute a raw contract call.
|
|
649
666
|
* @param {string} method - Method name
|
|
650
|
-
* @param {
|
|
651
|
-
* @returns {Promise
|
|
667
|
+
* @param {...*} args - Method arguments
|
|
668
|
+
* @returns {Promise<*>} Method return value
|
|
652
669
|
*/
|
|
653
670
|
async call(method, ...args) {
|
|
654
671
|
return this.contract[method](...args);
|
|
655
672
|
}
|
|
656
673
|
|
|
657
674
|
/**
|
|
658
|
-
* Execute a raw contract transaction
|
|
675
|
+
* Execute a raw contract transaction.
|
|
659
676
|
* @param {string} method - Method name
|
|
660
|
-
* @param {
|
|
661
|
-
* @returns {Promise<{txHash, receipt}>}
|
|
677
|
+
* @param {...*} args - Method arguments
|
|
678
|
+
* @returns {Promise<{txHash: string, receipt: Object}>} Transaction details
|
|
662
679
|
*/
|
|
663
680
|
async send(method, ...args) {
|
|
664
681
|
const tx = await this.contract[method](...args);
|
package/src/contracts/queries.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Contract
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* zones, splits, appreciation, members, balances, etc.
|
|
2
|
+
* @fileoverview Contract query utilities for reading contract state.
|
|
3
|
+
* Provides read-only queries for zones, splits, appreciation, members, balances, and more.
|
|
4
|
+
* @module contracts/queries
|
|
6
5
|
*/
|
|
7
6
|
|
|
8
7
|
import { ethers } from 'ethers';
|
|
@@ -24,35 +23,45 @@ const ContractABIs = {
|
|
|
24
23
|
};
|
|
25
24
|
|
|
26
25
|
/**
|
|
27
|
-
* Helper to format wei to ETH
|
|
26
|
+
* Helper to format wei to ETH.
|
|
27
|
+
* @private
|
|
28
|
+
* @param {bigint} wei - Wei amount
|
|
29
|
+
* @returns {string} ETH as decimal string
|
|
28
30
|
*/
|
|
29
31
|
function formatEth(wei) {
|
|
30
32
|
return ethers.formatEther(wei);
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
/**
|
|
34
|
-
* Helper to format wei to ETH as number
|
|
36
|
+
* Helper to format wei to ETH as number.
|
|
37
|
+
* @private
|
|
38
|
+
* @param {bigint} wei - Wei amount
|
|
39
|
+
* @returns {number} ETH as number
|
|
35
40
|
*/
|
|
36
41
|
function formatEthNumber(wei) {
|
|
37
42
|
return Number(ethers.formatEther(wei));
|
|
38
43
|
}
|
|
39
44
|
|
|
40
45
|
/**
|
|
41
|
-
*
|
|
46
|
+
* Query utilities for all Holosphere contract types.
|
|
47
|
+
* Provides read-only access to contract state without requiring a signer.
|
|
48
|
+
* @class
|
|
42
49
|
*/
|
|
43
50
|
export class ContractQueries {
|
|
44
51
|
/**
|
|
45
|
-
*
|
|
52
|
+
* Create a new ContractQueries instance.
|
|
53
|
+
* @param {Object} provider - Ethers.js provider instance
|
|
46
54
|
*/
|
|
47
55
|
constructor(provider) {
|
|
48
56
|
this.provider = provider;
|
|
49
57
|
}
|
|
50
58
|
|
|
51
59
|
/**
|
|
52
|
-
* Get a contract instance with the appropriate ABI
|
|
60
|
+
* Get a contract instance with the appropriate ABI.
|
|
53
61
|
* @param {string} address - Contract address
|
|
54
|
-
* @param {string} flavor - Contract flavor (Splitter, Managed, Zoned, Appreciative, Bundle)
|
|
55
|
-
* @returns {
|
|
62
|
+
* @param {string} flavor - Contract flavor (Splitter, Managed, Zoned, Appreciative, Bundle, Holons)
|
|
63
|
+
* @returns {Object} Ethers.js Contract instance
|
|
64
|
+
* @throws {Error} If unknown contract flavor
|
|
56
65
|
*/
|
|
57
66
|
getContract(address, flavor) {
|
|
58
67
|
const abi = ContractABIs[flavor];
|
|
@@ -63,9 +72,9 @@ export class ContractQueries {
|
|
|
63
72
|
}
|
|
64
73
|
|
|
65
74
|
/**
|
|
66
|
-
* Auto-detect contract flavor by calling flavor()
|
|
75
|
+
* Auto-detect contract flavor by calling flavor() method.
|
|
67
76
|
* @param {string} address - Contract address
|
|
68
|
-
* @returns {Promise<string>} Contract flavor
|
|
77
|
+
* @returns {Promise<string>} Contract flavor or 'Unknown'
|
|
69
78
|
*/
|
|
70
79
|
async detectFlavor(address) {
|
|
71
80
|
// Try with a minimal ABI that has flavor()
|
|
@@ -84,7 +93,10 @@ export class ContractQueries {
|
|
|
84
93
|
// ==================== COMMON QUERIES ====================
|
|
85
94
|
|
|
86
95
|
/**
|
|
87
|
-
* Get basic contract
|
|
96
|
+
* Get basic contract information.
|
|
97
|
+
* @param {string} address - Contract address
|
|
98
|
+
* @param {string} flavor - Contract flavor
|
|
99
|
+
* @returns {Promise<{address: string, name: string, flavor: string, version: string, creator: string, memberCount: number}>} Contract info
|
|
88
100
|
*/
|
|
89
101
|
async getContractInfo(address, flavor) {
|
|
90
102
|
const contract = this.getContract(address, flavor);
|
|
@@ -107,7 +119,10 @@ export class ContractQueries {
|
|
|
107
119
|
}
|
|
108
120
|
|
|
109
121
|
/**
|
|
110
|
-
* Get all
|
|
122
|
+
* Get all member user IDs.
|
|
123
|
+
* @param {string} address - Contract address
|
|
124
|
+
* @param {string} flavor - Contract flavor
|
|
125
|
+
* @returns {Promise<string[]>} Array of user IDs
|
|
111
126
|
*/
|
|
112
127
|
async getMembers(address, flavor) {
|
|
113
128
|
const contract = this.getContract(address, flavor);
|
|
@@ -121,7 +136,11 @@ export class ContractQueries {
|
|
|
121
136
|
}
|
|
122
137
|
|
|
123
138
|
/**
|
|
124
|
-
* Get user's ETH balance
|
|
139
|
+
* Get user's ETH balance in the contract.
|
|
140
|
+
* @param {string} address - Contract address
|
|
141
|
+
* @param {string} flavor - Contract flavor
|
|
142
|
+
* @param {string} userId - User identifier
|
|
143
|
+
* @returns {Promise<{wei: string, eth: number}>} Balance in wei and ETH
|
|
125
144
|
*/
|
|
126
145
|
async getUserEthBalance(address, flavor, userId) {
|
|
127
146
|
const contract = this.getContract(address, flavor);
|
|
@@ -133,7 +152,12 @@ export class ContractQueries {
|
|
|
133
152
|
}
|
|
134
153
|
|
|
135
154
|
/**
|
|
136
|
-
* Get user's token balance
|
|
155
|
+
* Get user's ERC20 token balance in the contract.
|
|
156
|
+
* @param {string} address - Contract address
|
|
157
|
+
* @param {string} flavor - Contract flavor
|
|
158
|
+
* @param {string} userId - User identifier
|
|
159
|
+
* @param {string} tokenAddress - ERC20 token address
|
|
160
|
+
* @returns {Promise<{wei: string, formatted: number}>} Token balance
|
|
137
161
|
*/
|
|
138
162
|
async getUserTokenBalance(address, flavor, userId, tokenAddress) {
|
|
139
163
|
const contract = this.getContract(address, flavor);
|
|
@@ -145,7 +169,11 @@ export class ContractQueries {
|
|
|
145
169
|
}
|
|
146
170
|
|
|
147
171
|
/**
|
|
148
|
-
* Get total deposited for a token
|
|
172
|
+
* Get total deposited amount for a token.
|
|
173
|
+
* @param {string} address - Contract address
|
|
174
|
+
* @param {string} flavor - Contract flavor
|
|
175
|
+
* @param {string} [tokenAddress] - Token address (defaults to ETH/zero address)
|
|
176
|
+
* @returns {Promise<{wei: string, formatted: number}>} Total deposited
|
|
149
177
|
*/
|
|
150
178
|
async getTotalDeposited(address, flavor, tokenAddress) {
|
|
151
179
|
const contract = this.getContract(address, flavor);
|
|
@@ -159,7 +187,11 @@ export class ContractQueries {
|
|
|
159
187
|
}
|
|
160
188
|
|
|
161
189
|
/**
|
|
162
|
-
* Check if user has claimed
|
|
190
|
+
* Check if user has claimed their rewards.
|
|
191
|
+
* @param {string} address - Contract address
|
|
192
|
+
* @param {string} flavor - Contract flavor
|
|
193
|
+
* @param {string} userId - User identifier
|
|
194
|
+
* @returns {Promise<boolean>} True if claimed
|
|
163
195
|
*/
|
|
164
196
|
async hasClaimed(address, flavor, userId) {
|
|
165
197
|
const contract = this.getContract(address, flavor);
|
|
@@ -539,7 +571,9 @@ export class ContractQueries {
|
|
|
539
571
|
// ==================== FULL SNAPSHOT ====================
|
|
540
572
|
|
|
541
573
|
/**
|
|
542
|
-
* Get complete contract state snapshot
|
|
574
|
+
* Get complete contract state snapshot including all members and configuration.
|
|
575
|
+
* @param {string} address - Contract address
|
|
576
|
+
* @returns {Promise<Object>} Complete contract state
|
|
543
577
|
*/
|
|
544
578
|
async getFullSnapshot(address) {
|
|
545
579
|
const flavor = await this.detectFlavor(address);
|
package/src/core/holosphere.js
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Core HoloSphere class providing the foundational infrastructure
|
|
3
|
+
* for holonic geospatial communication.
|
|
4
|
+
*
|
|
5
|
+
* This module implements the core HoloSphere class that supports multiple storage
|
|
6
|
+
* backends (Nostr, GunDB, ActivityPub) and provides essential operations for
|
|
7
|
+
* distributed P2P communication and data management.
|
|
8
|
+
*
|
|
9
|
+
* @module core/holosphere
|
|
10
|
+
*/
|
|
11
|
+
|
|
1
12
|
import { createClient } from '../storage/nostr-client.js';
|
|
2
13
|
import { BackendFactory } from '../storage/backend-factory.js';
|
|
3
14
|
import * as gunWrapper from '../storage/gun-wrapper.js';
|
|
@@ -5,12 +16,16 @@ import * as gunFederation from '../storage/gun-federation.js';
|
|
|
5
16
|
import { GunDBBackend } from '../storage/backends/gundb-backend.js';
|
|
6
17
|
import pkg from '../../package.json' with { type: 'json' };
|
|
7
18
|
|
|
8
|
-
|
|
19
|
+
/** @type {Function|null} Gun constructor, loaded dynamically */
|
|
9
20
|
let Gun = null;
|
|
21
|
+
/** @type {Promise<Function>|null} Promise for Gun loading */
|
|
10
22
|
let gunLoadPromise = null;
|
|
11
23
|
|
|
12
24
|
/**
|
|
13
|
-
*
|
|
25
|
+
* Dynamically loads the Gun module.
|
|
26
|
+
* Uses lazy loading to reduce initial bundle size and improve startup time.
|
|
27
|
+
*
|
|
28
|
+
* @private
|
|
14
29
|
* @returns {Promise<Function>} Gun constructor
|
|
15
30
|
*/
|
|
16
31
|
async function loadGun() {
|
|
@@ -50,9 +65,20 @@ function getDefaultRelays() {
|
|
|
50
65
|
}
|
|
51
66
|
|
|
52
67
|
/**
|
|
53
|
-
* HoloSphere - Holonic Geospatial Communication Infrastructure
|
|
54
|
-
*
|
|
55
|
-
*
|
|
68
|
+
* HoloSphere - Holonic Geospatial Communication Infrastructure.
|
|
69
|
+
*
|
|
70
|
+
* The core class that combines H3 hexagonal indexing with distributed P2P storage.
|
|
71
|
+
* Supports multiple storage backends including Nostr, GunDB, and ActivityPub.
|
|
72
|
+
*
|
|
73
|
+
* @class HoloSphere
|
|
74
|
+
* @example
|
|
75
|
+
* // Create with Nostr backend (default)
|
|
76
|
+
* const hs = new HoloSphere({ appName: 'myapp', relays: ['wss://relay.example.com'] });
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* // Create with GunDB backend
|
|
80
|
+
* const hs = new HoloSphere({ appName: 'myapp', backend: 'gundb' });
|
|
81
|
+
* await hs.ready(); // Wait for async initialization
|
|
56
82
|
*/
|
|
57
83
|
export class HoloSphere {
|
|
58
84
|
/**
|
|
@@ -712,7 +738,10 @@ export class HoloSphere {
|
|
|
712
738
|
// ============================================================================
|
|
713
739
|
|
|
714
740
|
/**
|
|
715
|
-
*
|
|
741
|
+
* Closes the backend and cleans up resources.
|
|
742
|
+
* Should be called when done using the HoloSphere instance.
|
|
743
|
+
*
|
|
744
|
+
* @returns {void}
|
|
716
745
|
*/
|
|
717
746
|
close() {
|
|
718
747
|
if (this._backend) {
|