@xyo-network/os-runtime 7.4.0 → 7.4.2
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/dist/neutral/Caller.d.ts +68 -0
- package/dist/neutral/Caller.d.ts.map +1 -0
- package/dist/neutral/DappCallerBase.d.ts +23 -0
- package/dist/neutral/DappCallerBase.d.ts.map +1 -0
- package/dist/neutral/DefaultsQueries.d.ts +8 -0
- package/dist/neutral/DefaultsQueries.d.ts.map +1 -0
- package/dist/neutral/OsCallerBase.d.ts +16 -0
- package/dist/neutral/OsCallerBase.d.ts.map +1 -0
- package/dist/neutral/PubSubBridgeCaller.d.ts +11 -0
- package/dist/neutral/PubSubBridgeCaller.d.ts.map +1 -0
- package/dist/neutral/RunningDappCache.d.ts +12 -0
- package/dist/neutral/RunningDappCache.d.ts.map +1 -0
- package/dist/neutral/XyOs.d.ts +48 -0
- package/dist/neutral/XyOs.d.ts.map +1 -0
- package/dist/neutral/XyOsBase.d.ts +170 -0
- package/dist/neutral/XyOsBase.d.ts.map +1 -0
- package/dist/neutral/XyOsDapp.d.ts +33 -0
- package/dist/neutral/XyOsDapp.d.ts.map +1 -0
- package/dist/neutral/access/Caller.d.ts +23 -0
- package/dist/neutral/access/Caller.d.ts.map +1 -0
- package/dist/neutral/access/Queries.d.ts +8 -0
- package/dist/neutral/access/Queries.d.ts.map +1 -0
- package/dist/neutral/access/Resource.d.ts +23 -0
- package/dist/neutral/access/Resource.d.ts.map +1 -0
- package/dist/neutral/access/RunningAccessDappCache.d.ts +12 -0
- package/dist/neutral/access/RunningAccessDappCache.d.ts.map +1 -0
- package/dist/neutral/access/index.d.ts +5 -0
- package/dist/neutral/access/index.d.ts.map +1 -0
- package/dist/neutral/access/interfaces/index.d.ts +2 -0
- package/dist/neutral/access/interfaces/index.d.ts.map +1 -0
- package/dist/neutral/access/interfaces/registered-names/helpers/AccessNodeQueries.d.ts +16 -0
- package/dist/neutral/access/interfaces/registered-names/helpers/AccessNodeQueries.d.ts.map +1 -0
- package/dist/neutral/access/interfaces/registered-names/helpers/index.d.ts +3 -0
- package/dist/neutral/access/interfaces/registered-names/helpers/index.d.ts.map +1 -0
- package/dist/neutral/access/interfaces/registered-names/helpers/resource/AbstractXnsCaller.d.ts +21 -0
- package/dist/neutral/access/interfaces/registered-names/helpers/resource/AbstractXnsCaller.d.ts.map +1 -0
- package/dist/neutral/access/interfaces/registered-names/helpers/resource/RegistrationsResource.d.ts +22 -0
- package/dist/neutral/access/interfaces/registered-names/helpers/resource/RegistrationsResource.d.ts.map +1 -0
- package/dist/neutral/access/interfaces/registered-names/helpers/resource/RegistrationsResourceQueries.d.ts +9 -0
- package/dist/neutral/access/interfaces/registered-names/helpers/resource/RegistrationsResourceQueries.d.ts.map +1 -0
- package/dist/neutral/access/interfaces/registered-names/helpers/resource/index.d.ts +4 -0
- package/dist/neutral/access/interfaces/registered-names/helpers/resource/index.d.ts.map +1 -0
- package/dist/neutral/access/interfaces/registered-names/index.d.ts +2 -0
- package/dist/neutral/access/interfaces/registered-names/index.d.ts.map +1 -0
- package/dist/neutral/adapter/Base.d.ts +17 -0
- package/dist/neutral/adapter/Base.d.ts.map +1 -0
- package/dist/neutral/adapter/Network.d.ts +15 -0
- package/dist/neutral/adapter/Network.d.ts.map +1 -0
- package/dist/neutral/adapter/Settings.d.ts +14 -0
- package/dist/neutral/adapter/Settings.d.ts.map +1 -0
- package/dist/neutral/adapter/index.d.ts +3 -0
- package/dist/neutral/adapter/index.d.ts.map +1 -0
- package/dist/neutral/adapters/OsPubSubBridgeNetwork.d.ts +3 -0
- package/dist/neutral/adapters/OsPubSubBridgeNetwork.d.ts.map +1 -0
- package/dist/neutral/adapters/OsSettings.d.ts +3 -0
- package/dist/neutral/adapters/OsSettings.d.ts.map +1 -0
- package/dist/neutral/adapters/OsXyoPublicNetwork.d.ts +3 -0
- package/dist/neutral/adapters/OsXyoPublicNetwork.d.ts.map +1 -0
- package/dist/neutral/adapters/index.d.ts +4 -0
- package/dist/neutral/adapters/index.d.ts.map +1 -0
- package/dist/neutral/classes/dapp/DefaultsResource.d.ts +26 -0
- package/dist/neutral/classes/dapp/DefaultsResource.d.ts.map +1 -0
- package/dist/neutral/classes/dapp/index.d.ts +2 -0
- package/dist/neutral/classes/dapp/index.d.ts.map +1 -0
- package/dist/neutral/classes/index.d.ts +5 -0
- package/dist/neutral/classes/index.d.ts.map +1 -0
- package/dist/neutral/classes/lib/DappCreatorParams.d.ts +16 -0
- package/dist/neutral/classes/lib/DappCreatorParams.d.ts.map +1 -0
- package/dist/neutral/classes/lib/Insertable.d.ts +10 -0
- package/dist/neutral/classes/lib/Insertable.d.ts.map +1 -0
- package/dist/neutral/classes/lib/index.d.ts +3 -0
- package/dist/neutral/classes/lib/index.d.ts.map +1 -0
- package/dist/neutral/classes/menu/Caller.d.ts +14 -0
- package/dist/neutral/classes/menu/Caller.d.ts.map +1 -0
- package/dist/neutral/classes/menu/Queries.d.ts +10 -0
- package/dist/neutral/classes/menu/Queries.d.ts.map +1 -0
- package/dist/neutral/classes/menu/Resource.d.ts +46 -0
- package/dist/neutral/classes/menu/Resource.d.ts.map +1 -0
- package/dist/neutral/classes/menu/index.d.ts +3 -0
- package/dist/neutral/classes/menu/index.d.ts.map +1 -0
- package/dist/neutral/classes/settings/Caller.d.ts +21 -0
- package/dist/neutral/classes/settings/Caller.d.ts.map +1 -0
- package/dist/neutral/classes/settings/CallerBase.d.ts +8 -0
- package/dist/neutral/classes/settings/CallerBase.d.ts.map +1 -0
- package/dist/neutral/classes/settings/Resource.d.ts +30 -0
- package/dist/neutral/classes/settings/Resource.d.ts.map +1 -0
- package/dist/neutral/classes/settings/SettingsQueries.d.ts +10 -0
- package/dist/neutral/classes/settings/SettingsQueries.d.ts.map +1 -0
- package/dist/neutral/classes/settings/badge/Caller.d.ts +13 -0
- package/dist/neutral/classes/settings/badge/Caller.d.ts.map +1 -0
- package/dist/neutral/classes/settings/badge/Queries.d.ts +7 -0
- package/dist/neutral/classes/settings/badge/Queries.d.ts.map +1 -0
- package/dist/neutral/classes/settings/badge/Resource.d.ts +23 -0
- package/dist/neutral/classes/settings/badge/Resource.d.ts.map +1 -0
- package/dist/neutral/classes/settings/badge/index.d.ts +3 -0
- package/dist/neutral/classes/settings/badge/index.d.ts.map +1 -0
- package/dist/neutral/classes/settings/index.d.ts +6 -0
- package/dist/neutral/classes/settings/index.d.ts.map +1 -0
- package/dist/neutral/dapp/context/creator/Creator.d.ts +23 -0
- package/dist/neutral/dapp/context/creator/Creator.d.ts.map +1 -0
- package/dist/neutral/dapp/context/creator/DefaultPayloads/DappAccessPayloads.d.ts +8 -0
- package/dist/neutral/dapp/context/creator/DefaultPayloads/DappAccessPayloads.d.ts.map +1 -0
- package/dist/neutral/dapp/context/creator/DefaultPayloads/DefaultPayloads.d.ts +10 -0
- package/dist/neutral/dapp/context/creator/DefaultPayloads/DefaultPayloads.d.ts.map +1 -0
- package/dist/neutral/dapp/context/creator/DefaultPayloads/NodeInfoPayload.d.ts +8 -0
- package/dist/neutral/dapp/context/creator/DefaultPayloads/NodeInfoPayload.d.ts.map +1 -0
- package/dist/neutral/dapp/context/creator/DefaultPayloads/index.d.ts +2 -0
- package/dist/neutral/dapp/context/creator/DefaultPayloads/index.d.ts.map +1 -0
- package/dist/neutral/dapp/context/creator/ExternalModulePermissions/ExternalModulePermissions.d.ts +15 -0
- package/dist/neutral/dapp/context/creator/ExternalModulePermissions/ExternalModulePermissions.d.ts.map +1 -0
- package/dist/neutral/dapp/context/creator/ExternalModulePermissions/index.d.ts +2 -0
- package/dist/neutral/dapp/context/creator/ExternalModulePermissions/index.d.ts.map +1 -0
- package/dist/neutral/dapp/context/creator/createDappContext.d.ts +3 -0
- package/dist/neutral/dapp/context/creator/createDappContext.d.ts.map +1 -0
- package/dist/neutral/dapp/context/creator/index.d.ts +4 -0
- package/dist/neutral/dapp/context/creator/index.d.ts.map +1 -0
- package/dist/neutral/dapp/context/index.d.ts +2 -0
- package/dist/neutral/dapp/context/index.d.ts.map +1 -0
- package/dist/neutral/dapp/index.d.ts +2 -0
- package/dist/neutral/dapp/index.d.ts.map +1 -0
- package/dist/neutral/event/bus/Connection.d.ts +16 -0
- package/dist/neutral/event/bus/Connection.d.ts.map +1 -0
- package/dist/neutral/event/bus/EventBus.d.ts +24 -0
- package/dist/neutral/event/bus/EventBus.d.ts.map +1 -0
- package/dist/neutral/event/bus/PubSubConnection.d.ts +12 -0
- package/dist/neutral/event/bus/PubSubConnection.d.ts.map +1 -0
- package/dist/neutral/event/bus/index.d.ts +4 -0
- package/dist/neutral/event/bus/index.d.ts.map +1 -0
- package/dist/neutral/event/connections/DappAccessRequest.d.ts +4 -0
- package/dist/neutral/event/connections/DappAccessRequest.d.ts.map +1 -0
- package/dist/neutral/event/connections/DappsReady.d.ts +3 -0
- package/dist/neutral/event/connections/DappsReady.d.ts.map +1 -0
- package/dist/neutral/event/connections/ExposeDappRequest.d.ts +4 -0
- package/dist/neutral/event/connections/ExposeDappRequest.d.ts.map +1 -0
- package/dist/neutral/event/connections/OsPubSubNetworkReady.d.ts +4 -0
- package/dist/neutral/event/connections/OsPubSubNetworkReady.d.ts.map +1 -0
- package/dist/neutral/event/connections/OsSettingsReady.d.ts +4 -0
- package/dist/neutral/event/connections/OsSettingsReady.d.ts.map +1 -0
- package/dist/neutral/event/connections/OsXyoPublicReady.d.ts +4 -0
- package/dist/neutral/event/connections/OsXyoPublicReady.d.ts.map +1 -0
- package/dist/neutral/event/connections/index.d.ts +7 -0
- package/dist/neutral/event/connections/index.d.ts.map +1 -0
- package/dist/neutral/event/index.d.ts +3 -0
- package/dist/neutral/event/index.d.ts.map +1 -0
- package/dist/neutral/helpers/index.d.ts +2 -0
- package/dist/neutral/helpers/index.d.ts.map +1 -0
- package/dist/neutral/helpers/monitor/XyOsMonitor.d.ts +14 -0
- package/dist/neutral/helpers/monitor/XyOsMonitor.d.ts.map +1 -0
- package/dist/neutral/helpers/monitor/index.d.ts +3 -0
- package/dist/neutral/helpers/monitor/index.d.ts.map +1 -0
- package/dist/neutral/helpers/monitor/types.d.ts +7 -0
- package/dist/neutral/helpers/monitor/types.d.ts.map +1 -0
- package/dist/neutral/index.d.ts +30 -0
- package/dist/neutral/index.d.ts.map +1 -0
- package/dist/neutral/index.mjs +3660 -0
- package/dist/neutral/index.mjs.map +7 -0
- package/dist/neutral/initializer/DappInitializer.d.ts +18 -0
- package/dist/neutral/initializer/DappInitializer.d.ts.map +1 -0
- package/dist/neutral/initializer/index.d.ts +2 -0
- package/dist/neutral/initializer/index.d.ts.map +1 -0
- package/dist/neutral/intent/Caller.d.ts +23 -0
- package/dist/neutral/intent/Caller.d.ts.map +1 -0
- package/dist/neutral/intent/Resource.d.ts +23 -0
- package/dist/neutral/intent/Resource.d.ts.map +1 -0
- package/dist/neutral/intent/index.d.ts +3 -0
- package/dist/neutral/intent/index.d.ts.map +1 -0
- package/dist/neutral/lib/ExternalStore.d.ts +7 -0
- package/dist/neutral/lib/ExternalStore.d.ts.map +1 -0
- package/dist/neutral/lib/Listener.d.ts +2 -0
- package/dist/neutral/lib/Listener.d.ts.map +1 -0
- package/dist/neutral/lib/ModuleAccountPaths.d.ts +3 -0
- package/dist/neutral/lib/ModuleAccountPaths.d.ts.map +1 -0
- package/dist/neutral/lib/ModuleNames.d.ts +3 -0
- package/dist/neutral/lib/ModuleNames.d.ts.map +1 -0
- package/dist/neutral/lib/NameTransforms.d.ts +11 -0
- package/dist/neutral/lib/NameTransforms.d.ts.map +1 -0
- package/dist/neutral/lib/PayloadStore.d.ts +37 -0
- package/dist/neutral/lib/PayloadStore.d.ts.map +1 -0
- package/dist/neutral/lib/ResourceStores.d.ts +7 -0
- package/dist/neutral/lib/ResourceStores.d.ts.map +1 -0
- package/dist/neutral/lib/index.d.ts +12 -0
- package/dist/neutral/lib/index.d.ts.map +1 -0
- package/dist/neutral/lib/initializeXns.d.ts +3 -0
- package/dist/neutral/lib/initializeXns.d.ts.map +1 -0
- package/dist/neutral/lib/isEqual.d.ts +2 -0
- package/dist/neutral/lib/isEqual.d.ts.map +1 -0
- package/dist/neutral/lib/isPayload.d.ts +6 -0
- package/dist/neutral/lib/isPayload.d.ts.map +1 -0
- package/dist/neutral/lib/tokenPlacesSplit.d.ts +3 -0
- package/dist/neutral/lib/tokenPlacesSplit.d.ts.map +1 -0
- package/dist/neutral/loadOsNode.d.ts +5 -0
- package/dist/neutral/loadOsNode.d.ts.map +1 -0
- package/dist/neutral/manifest/index.d.ts +3 -0
- package/dist/neutral/manifest/index.d.ts.map +1 -0
- package/dist/neutral/manifest/manifestReplacementTokens.d.ts +4 -0
- package/dist/neutral/manifest/manifestReplacementTokens.d.ts.map +1 -0
- package/dist/neutral/manifests/index.d.ts +2 -0
- package/dist/neutral/manifests/index.d.ts.map +1 -0
- package/dist/neutral/models/access/ValidDappAccessInterfaces.d.ts +5 -0
- package/dist/neutral/models/access/ValidDappAccessInterfaces.d.ts.map +1 -0
- package/dist/neutral/models/access/index.d.ts +2 -0
- package/dist/neutral/models/access/index.d.ts.map +1 -0
- package/dist/neutral/models/index.d.ts +2 -0
- package/dist/neutral/models/index.d.ts.map +1 -0
- package/dist/neutral/profileModuleEvents.d.ts +9 -0
- package/dist/neutral/profileModuleEvents.d.ts.map +1 -0
- package/dist/neutral/registration/DappRegistrationService.d.ts +37 -0
- package/dist/neutral/registration/DappRegistrationService.d.ts.map +1 -0
- package/dist/neutral/registration/DappRegistry.d.ts +26 -0
- package/dist/neutral/registration/DappRegistry.d.ts.map +1 -0
- package/dist/neutral/registration/ValidateDappAccessDiviner/Config.d.ts +23 -0
- package/dist/neutral/registration/ValidateDappAccessDiviner/Config.d.ts.map +1 -0
- package/dist/neutral/registration/ValidateDappAccessDiviner/Diviner.d.ts +9 -0
- package/dist/neutral/registration/ValidateDappAccessDiviner/Diviner.d.ts.map +1 -0
- package/dist/neutral/registration/ValidateDappAccessDiviner/index.d.ts +3 -0
- package/dist/neutral/registration/ValidateDappAccessDiviner/index.d.ts.map +1 -0
- package/dist/neutral/registration/index.d.ts +3 -0
- package/dist/neutral/registration/index.d.ts.map +1 -0
- package/dist/neutral/scripts/xyos/command/config.d.ts +3 -0
- package/dist/neutral/scripts/xyos/command/config.d.ts.map +1 -0
- package/dist/neutral/scripts/xyos/command/create.d.ts +3 -0
- package/dist/neutral/scripts/xyos/command/create.d.ts.map +1 -0
- package/dist/neutral/scripts/xyos/command/index.d.ts +6 -0
- package/dist/neutral/scripts/xyos/command/index.d.ts.map +1 -0
- package/dist/neutral/scripts/xyos/command/manifest.d.ts +3 -0
- package/dist/neutral/scripts/xyos/command/manifest.d.ts.map +1 -0
- package/dist/neutral/scripts/xyos/command/start.d.ts +3 -0
- package/dist/neutral/scripts/xyos/command/start.d.ts.map +1 -0
- package/dist/neutral/scripts/xyos/index.d.ts +2 -0
- package/dist/neutral/scripts/xyos/index.d.ts.map +1 -0
- package/dist/neutral/scripts/xyos/lib/createFromTemplate.d.ts +7 -0
- package/dist/neutral/scripts/xyos/lib/createFromTemplate.d.ts.map +1 -0
- package/dist/neutral/scripts/xyos/lib/headless.d.ts +8 -0
- package/dist/neutral/scripts/xyos/lib/headless.d.ts.map +1 -0
- package/dist/neutral/scripts/xyos/lib/index.d.ts +3 -0
- package/dist/neutral/scripts/xyos/lib/index.d.ts.map +1 -0
- package/dist/neutral/signer/Signers.d.ts +17 -0
- package/dist/neutral/signer/Signers.d.ts.map +1 -0
- package/dist/neutral/signer/index.d.ts +2 -0
- package/dist/neutral/signer/index.d.ts.map +1 -0
- package/dist/neutral/stack/Base.d.ts +41 -0
- package/dist/neutral/stack/Base.d.ts.map +1 -0
- package/dist/neutral/stack/Manager.d.ts +19 -0
- package/dist/neutral/stack/Manager.d.ts.map +1 -0
- package/dist/neutral/stack/Map.d.ts +3 -0
- package/dist/neutral/stack/Map.d.ts.map +1 -0
- package/dist/neutral/stack/OsPubSubNetworkStack.d.ts +14 -0
- package/dist/neutral/stack/OsPubSubNetworkStack.d.ts.map +1 -0
- package/dist/neutral/stack/OsSettingsStack.d.ts +9 -0
- package/dist/neutral/stack/OsSettingsStack.d.ts.map +1 -0
- package/dist/neutral/stack/XyoPublicNetworkStack.d.ts +9 -0
- package/dist/neutral/stack/XyoPublicNetworkStack.d.ts.map +1 -0
- package/dist/neutral/stack/index.d.ts +7 -0
- package/dist/neutral/stack/index.d.ts.map +1 -0
- package/dist/neutral/system/ManageSystemDapps.d.ts +33 -0
- package/dist/neutral/system/ManageSystemDapps.d.ts.map +1 -0
- package/dist/neutral/system/Queries.d.ts +9 -0
- package/dist/neutral/system/Queries.d.ts.map +1 -0
- package/dist/neutral/system/index.d.ts +2 -0
- package/dist/neutral/system/index.d.ts.map +1 -0
- package/dist/neutral/utils/buildWalletSeedPhrasePayload.d.ts +30 -0
- package/dist/neutral/utils/buildWalletSeedPhrasePayload.d.ts.map +1 -0
- package/dist/neutral/utils/getApiDomain.d.ts +3 -0
- package/dist/neutral/utils/getApiDomain.d.ts.map +1 -0
- package/dist/neutral/utils/index.d.ts +4 -0
- package/dist/neutral/utils/index.d.ts.map +1 -0
- package/dist/neutral/utils/renameObjKey.d.ts +7 -0
- package/dist/neutral/utils/renameObjKey.d.ts.map +1 -0
- package/dist/neutral/wallet/DappSeedPhraseRepository.d.ts +16 -0
- package/dist/neutral/wallet/DappSeedPhraseRepository.d.ts.map +1 -0
- package/dist/neutral/wallet/SeedPhraseRepository.d.ts +28 -0
- package/dist/neutral/wallet/SeedPhraseRepository.d.ts.map +1 -0
- package/dist/neutral/wallet/index.d.ts +3 -0
- package/dist/neutral/wallet/index.d.ts.map +1 -0
- package/dist/node/Caller.d.ts +68 -0
- package/dist/node/Caller.d.ts.map +1 -0
- package/dist/node/DappCallerBase.d.ts +23 -0
- package/dist/node/DappCallerBase.d.ts.map +1 -0
- package/dist/node/DefaultsQueries.d.ts +8 -0
- package/dist/node/DefaultsQueries.d.ts.map +1 -0
- package/dist/node/OsCallerBase.d.ts +16 -0
- package/dist/node/OsCallerBase.d.ts.map +1 -0
- package/dist/node/PubSubBridgeCaller.d.ts +11 -0
- package/dist/node/PubSubBridgeCaller.d.ts.map +1 -0
- package/dist/node/RunningDappCache.d.ts +12 -0
- package/dist/node/RunningDappCache.d.ts.map +1 -0
- package/dist/node/XyOs.d.ts +48 -0
- package/dist/node/XyOs.d.ts.map +1 -0
- package/dist/node/XyOsBase.d.ts +170 -0
- package/dist/node/XyOsBase.d.ts.map +1 -0
- package/dist/node/XyOsDapp.d.ts +33 -0
- package/dist/node/XyOsDapp.d.ts.map +1 -0
- package/dist/node/access/Caller.d.ts +23 -0
- package/dist/node/access/Caller.d.ts.map +1 -0
- package/dist/node/access/Queries.d.ts +8 -0
- package/dist/node/access/Queries.d.ts.map +1 -0
- package/dist/node/access/Resource.d.ts +23 -0
- package/dist/node/access/Resource.d.ts.map +1 -0
- package/dist/node/access/RunningAccessDappCache.d.ts +12 -0
- package/dist/node/access/RunningAccessDappCache.d.ts.map +1 -0
- package/dist/node/access/index.d.ts +5 -0
- package/dist/node/access/index.d.ts.map +1 -0
- package/dist/node/access/interfaces/index.d.ts +2 -0
- package/dist/node/access/interfaces/index.d.ts.map +1 -0
- package/dist/node/access/interfaces/registered-names/helpers/AccessNodeQueries.d.ts +16 -0
- package/dist/node/access/interfaces/registered-names/helpers/AccessNodeQueries.d.ts.map +1 -0
- package/dist/node/access/interfaces/registered-names/helpers/index.d.ts +3 -0
- package/dist/node/access/interfaces/registered-names/helpers/index.d.ts.map +1 -0
- package/dist/node/access/interfaces/registered-names/helpers/resource/AbstractXnsCaller.d.ts +21 -0
- package/dist/node/access/interfaces/registered-names/helpers/resource/AbstractXnsCaller.d.ts.map +1 -0
- package/dist/node/access/interfaces/registered-names/helpers/resource/RegistrationsResource.d.ts +22 -0
- package/dist/node/access/interfaces/registered-names/helpers/resource/RegistrationsResource.d.ts.map +1 -0
- package/dist/node/access/interfaces/registered-names/helpers/resource/RegistrationsResourceQueries.d.ts +9 -0
- package/dist/node/access/interfaces/registered-names/helpers/resource/RegistrationsResourceQueries.d.ts.map +1 -0
- package/dist/node/access/interfaces/registered-names/helpers/resource/index.d.ts +4 -0
- package/dist/node/access/interfaces/registered-names/helpers/resource/index.d.ts.map +1 -0
- package/dist/node/access/interfaces/registered-names/index.d.ts +2 -0
- package/dist/node/access/interfaces/registered-names/index.d.ts.map +1 -0
- package/dist/node/adapter/Base.d.ts +17 -0
- package/dist/node/adapter/Base.d.ts.map +1 -0
- package/dist/node/adapter/Network.d.ts +15 -0
- package/dist/node/adapter/Network.d.ts.map +1 -0
- package/dist/node/adapter/Settings.d.ts +14 -0
- package/dist/node/adapter/Settings.d.ts.map +1 -0
- package/dist/node/adapter/index.d.ts +3 -0
- package/dist/node/adapter/index.d.ts.map +1 -0
- package/dist/node/adapters/OsPubSubBridgeNetwork.d.ts +3 -0
- package/dist/node/adapters/OsPubSubBridgeNetwork.d.ts.map +1 -0
- package/dist/node/adapters/OsSettings.d.ts +3 -0
- package/dist/node/adapters/OsSettings.d.ts.map +1 -0
- package/dist/node/adapters/OsXyoPublicNetwork.d.ts +3 -0
- package/dist/node/adapters/OsXyoPublicNetwork.d.ts.map +1 -0
- package/dist/node/adapters/index.d.ts +4 -0
- package/dist/node/adapters/index.d.ts.map +1 -0
- package/dist/node/classes/dapp/DefaultsResource.d.ts +26 -0
- package/dist/node/classes/dapp/DefaultsResource.d.ts.map +1 -0
- package/dist/node/classes/dapp/index.d.ts +2 -0
- package/dist/node/classes/dapp/index.d.ts.map +1 -0
- package/dist/node/classes/index.d.ts +5 -0
- package/dist/node/classes/index.d.ts.map +1 -0
- package/dist/node/classes/lib/DappCreatorParams.d.ts +16 -0
- package/dist/node/classes/lib/DappCreatorParams.d.ts.map +1 -0
- package/dist/node/classes/lib/Insertable.d.ts +10 -0
- package/dist/node/classes/lib/Insertable.d.ts.map +1 -0
- package/dist/node/classes/lib/index.d.ts +3 -0
- package/dist/node/classes/lib/index.d.ts.map +1 -0
- package/dist/node/classes/menu/Caller.d.ts +14 -0
- package/dist/node/classes/menu/Caller.d.ts.map +1 -0
- package/dist/node/classes/menu/Queries.d.ts +10 -0
- package/dist/node/classes/menu/Queries.d.ts.map +1 -0
- package/dist/node/classes/menu/Resource.d.ts +46 -0
- package/dist/node/classes/menu/Resource.d.ts.map +1 -0
- package/dist/node/classes/menu/index.d.ts +3 -0
- package/dist/node/classes/menu/index.d.ts.map +1 -0
- package/dist/node/classes/settings/Caller.d.ts +21 -0
- package/dist/node/classes/settings/Caller.d.ts.map +1 -0
- package/dist/node/classes/settings/CallerBase.d.ts +8 -0
- package/dist/node/classes/settings/CallerBase.d.ts.map +1 -0
- package/dist/node/classes/settings/Resource.d.ts +30 -0
- package/dist/node/classes/settings/Resource.d.ts.map +1 -0
- package/dist/node/classes/settings/SettingsQueries.d.ts +10 -0
- package/dist/node/classes/settings/SettingsQueries.d.ts.map +1 -0
- package/dist/node/classes/settings/badge/Caller.d.ts +13 -0
- package/dist/node/classes/settings/badge/Caller.d.ts.map +1 -0
- package/dist/node/classes/settings/badge/Queries.d.ts +7 -0
- package/dist/node/classes/settings/badge/Queries.d.ts.map +1 -0
- package/dist/node/classes/settings/badge/Resource.d.ts +23 -0
- package/dist/node/classes/settings/badge/Resource.d.ts.map +1 -0
- package/dist/node/classes/settings/badge/index.d.ts +3 -0
- package/dist/node/classes/settings/badge/index.d.ts.map +1 -0
- package/dist/node/classes/settings/index.d.ts +6 -0
- package/dist/node/classes/settings/index.d.ts.map +1 -0
- package/dist/node/dapp/context/creator/Creator.d.ts +23 -0
- package/dist/node/dapp/context/creator/Creator.d.ts.map +1 -0
- package/dist/node/dapp/context/creator/DefaultPayloads/DappAccessPayloads.d.ts +8 -0
- package/dist/node/dapp/context/creator/DefaultPayloads/DappAccessPayloads.d.ts.map +1 -0
- package/dist/node/dapp/context/creator/DefaultPayloads/DefaultPayloads.d.ts +10 -0
- package/dist/node/dapp/context/creator/DefaultPayloads/DefaultPayloads.d.ts.map +1 -0
- package/dist/node/dapp/context/creator/DefaultPayloads/NodeInfoPayload.d.ts +8 -0
- package/dist/node/dapp/context/creator/DefaultPayloads/NodeInfoPayload.d.ts.map +1 -0
- package/dist/node/dapp/context/creator/DefaultPayloads/index.d.ts +2 -0
- package/dist/node/dapp/context/creator/DefaultPayloads/index.d.ts.map +1 -0
- package/dist/node/dapp/context/creator/ExternalModulePermissions/ExternalModulePermissions.d.ts +15 -0
- package/dist/node/dapp/context/creator/ExternalModulePermissions/ExternalModulePermissions.d.ts.map +1 -0
- package/dist/node/dapp/context/creator/ExternalModulePermissions/index.d.ts +2 -0
- package/dist/node/dapp/context/creator/ExternalModulePermissions/index.d.ts.map +1 -0
- package/dist/node/dapp/context/creator/createDappContext.d.ts +3 -0
- package/dist/node/dapp/context/creator/createDappContext.d.ts.map +1 -0
- package/dist/node/dapp/context/creator/index.d.ts +4 -0
- package/dist/node/dapp/context/creator/index.d.ts.map +1 -0
- package/dist/node/dapp/context/index.d.ts +2 -0
- package/dist/node/dapp/context/index.d.ts.map +1 -0
- package/dist/node/dapp/index.d.ts +2 -0
- package/dist/node/dapp/index.d.ts.map +1 -0
- package/dist/node/event/bus/Connection.d.ts +16 -0
- package/dist/node/event/bus/Connection.d.ts.map +1 -0
- package/dist/node/event/bus/EventBus.d.ts +24 -0
- package/dist/node/event/bus/EventBus.d.ts.map +1 -0
- package/dist/node/event/bus/PubSubConnection.d.ts +12 -0
- package/dist/node/event/bus/PubSubConnection.d.ts.map +1 -0
- package/dist/node/event/bus/index.d.ts +4 -0
- package/dist/node/event/bus/index.d.ts.map +1 -0
- package/dist/node/event/connections/DappAccessRequest.d.ts +4 -0
- package/dist/node/event/connections/DappAccessRequest.d.ts.map +1 -0
- package/dist/node/event/connections/DappsReady.d.ts +3 -0
- package/dist/node/event/connections/DappsReady.d.ts.map +1 -0
- package/dist/node/event/connections/ExposeDappRequest.d.ts +4 -0
- package/dist/node/event/connections/ExposeDappRequest.d.ts.map +1 -0
- package/dist/node/event/connections/OsPubSubNetworkReady.d.ts +4 -0
- package/dist/node/event/connections/OsPubSubNetworkReady.d.ts.map +1 -0
- package/dist/node/event/connections/OsSettingsReady.d.ts +4 -0
- package/dist/node/event/connections/OsSettingsReady.d.ts.map +1 -0
- package/dist/node/event/connections/OsXyoPublicReady.d.ts +4 -0
- package/dist/node/event/connections/OsXyoPublicReady.d.ts.map +1 -0
- package/dist/node/event/connections/index.d.ts +7 -0
- package/dist/node/event/connections/index.d.ts.map +1 -0
- package/dist/node/event/index.d.ts +3 -0
- package/dist/node/event/index.d.ts.map +1 -0
- package/dist/node/helpers/index.d.ts +2 -0
- package/dist/node/helpers/index.d.ts.map +1 -0
- package/dist/node/helpers/monitor/XyOsMonitor.d.ts +14 -0
- package/dist/node/helpers/monitor/XyOsMonitor.d.ts.map +1 -0
- package/dist/node/helpers/monitor/index.d.ts +3 -0
- package/dist/node/helpers/monitor/index.d.ts.map +1 -0
- package/dist/node/helpers/monitor/types.d.ts +7 -0
- package/dist/node/helpers/monitor/types.d.ts.map +1 -0
- package/dist/node/index.d.ts +30 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.mjs +3660 -0
- package/dist/node/index.mjs.map +7 -0
- package/dist/node/initializer/DappInitializer.d.ts +18 -0
- package/dist/node/initializer/DappInitializer.d.ts.map +1 -0
- package/dist/node/initializer/index.d.ts +2 -0
- package/dist/node/initializer/index.d.ts.map +1 -0
- package/dist/node/intent/Caller.d.ts +23 -0
- package/dist/node/intent/Caller.d.ts.map +1 -0
- package/dist/node/intent/Resource.d.ts +23 -0
- package/dist/node/intent/Resource.d.ts.map +1 -0
- package/dist/node/intent/index.d.ts +3 -0
- package/dist/node/intent/index.d.ts.map +1 -0
- package/dist/node/lib/ExternalStore.d.ts +7 -0
- package/dist/node/lib/ExternalStore.d.ts.map +1 -0
- package/dist/node/lib/Listener.d.ts +2 -0
- package/dist/node/lib/Listener.d.ts.map +1 -0
- package/dist/node/lib/ModuleAccountPaths.d.ts +3 -0
- package/dist/node/lib/ModuleAccountPaths.d.ts.map +1 -0
- package/dist/node/lib/ModuleNames.d.ts +3 -0
- package/dist/node/lib/ModuleNames.d.ts.map +1 -0
- package/dist/node/lib/NameTransforms.d.ts +11 -0
- package/dist/node/lib/NameTransforms.d.ts.map +1 -0
- package/dist/node/lib/PayloadStore.d.ts +37 -0
- package/dist/node/lib/PayloadStore.d.ts.map +1 -0
- package/dist/node/lib/ResourceStores.d.ts +7 -0
- package/dist/node/lib/ResourceStores.d.ts.map +1 -0
- package/dist/node/lib/index.d.ts +12 -0
- package/dist/node/lib/index.d.ts.map +1 -0
- package/dist/node/lib/initializeXns.d.ts +3 -0
- package/dist/node/lib/initializeXns.d.ts.map +1 -0
- package/dist/node/lib/isEqual.d.ts +2 -0
- package/dist/node/lib/isEqual.d.ts.map +1 -0
- package/dist/node/lib/isPayload.d.ts +6 -0
- package/dist/node/lib/isPayload.d.ts.map +1 -0
- package/dist/node/lib/tokenPlacesSplit.d.ts +3 -0
- package/dist/node/lib/tokenPlacesSplit.d.ts.map +1 -0
- package/dist/node/loadOsNode.d.ts +5 -0
- package/dist/node/loadOsNode.d.ts.map +1 -0
- package/dist/node/manifest/index.d.ts +3 -0
- package/dist/node/manifest/index.d.ts.map +1 -0
- package/dist/node/manifest/manifestReplacementTokens.d.ts +4 -0
- package/dist/node/manifest/manifestReplacementTokens.d.ts.map +1 -0
- package/dist/node/manifests/index.d.ts +2 -0
- package/dist/node/manifests/index.d.ts.map +1 -0
- package/dist/node/models/access/ValidDappAccessInterfaces.d.ts +5 -0
- package/dist/node/models/access/ValidDappAccessInterfaces.d.ts.map +1 -0
- package/dist/node/models/access/index.d.ts +2 -0
- package/dist/node/models/access/index.d.ts.map +1 -0
- package/dist/node/models/index.d.ts +2 -0
- package/dist/node/models/index.d.ts.map +1 -0
- package/dist/node/profileModuleEvents.d.ts +9 -0
- package/dist/node/profileModuleEvents.d.ts.map +1 -0
- package/dist/node/registration/DappRegistrationService.d.ts +37 -0
- package/dist/node/registration/DappRegistrationService.d.ts.map +1 -0
- package/dist/node/registration/DappRegistry.d.ts +26 -0
- package/dist/node/registration/DappRegistry.d.ts.map +1 -0
- package/dist/node/registration/ValidateDappAccessDiviner/Config.d.ts +23 -0
- package/dist/node/registration/ValidateDappAccessDiviner/Config.d.ts.map +1 -0
- package/dist/node/registration/ValidateDappAccessDiviner/Diviner.d.ts +9 -0
- package/dist/node/registration/ValidateDappAccessDiviner/Diviner.d.ts.map +1 -0
- package/dist/node/registration/ValidateDappAccessDiviner/index.d.ts +3 -0
- package/dist/node/registration/ValidateDappAccessDiviner/index.d.ts.map +1 -0
- package/dist/node/registration/index.d.ts +3 -0
- package/dist/node/registration/index.d.ts.map +1 -0
- package/dist/node/scripts/xyos/command/config.d.ts +3 -0
- package/dist/node/scripts/xyos/command/config.d.ts.map +1 -0
- package/dist/node/scripts/xyos/command/create.d.ts +3 -0
- package/dist/node/scripts/xyos/command/create.d.ts.map +1 -0
- package/dist/node/scripts/xyos/command/index.d.ts +6 -0
- package/dist/node/scripts/xyos/command/index.d.ts.map +1 -0
- package/dist/node/scripts/xyos/command/manifest.d.ts +3 -0
- package/dist/node/scripts/xyos/command/manifest.d.ts.map +1 -0
- package/dist/node/scripts/xyos/command/start.d.ts +3 -0
- package/dist/node/scripts/xyos/command/start.d.ts.map +1 -0
- package/dist/node/scripts/xyos/index.d.ts +2 -0
- package/dist/node/scripts/xyos/index.d.ts.map +1 -0
- package/dist/node/scripts/xyos/index.mjs +2044 -0
- package/dist/node/scripts/xyos/index.mjs.map +7 -0
- package/dist/node/scripts/xyos/lib/createFromTemplate.d.ts +7 -0
- package/dist/node/scripts/xyos/lib/createFromTemplate.d.ts.map +1 -0
- package/dist/node/scripts/xyos/lib/headless.d.ts +8 -0
- package/dist/node/scripts/xyos/lib/headless.d.ts.map +1 -0
- package/dist/node/scripts/xyos/lib/index.d.ts +3 -0
- package/dist/node/scripts/xyos/lib/index.d.ts.map +1 -0
- package/dist/node/signer/Signers.d.ts +17 -0
- package/dist/node/signer/Signers.d.ts.map +1 -0
- package/dist/node/signer/index.d.ts +2 -0
- package/dist/node/signer/index.d.ts.map +1 -0
- package/dist/node/stack/Base.d.ts +41 -0
- package/dist/node/stack/Base.d.ts.map +1 -0
- package/dist/node/stack/Manager.d.ts +19 -0
- package/dist/node/stack/Manager.d.ts.map +1 -0
- package/dist/node/stack/Map.d.ts +3 -0
- package/dist/node/stack/Map.d.ts.map +1 -0
- package/dist/node/stack/OsPubSubNetworkStack.d.ts +14 -0
- package/dist/node/stack/OsPubSubNetworkStack.d.ts.map +1 -0
- package/dist/node/stack/OsSettingsStack.d.ts +9 -0
- package/dist/node/stack/OsSettingsStack.d.ts.map +1 -0
- package/dist/node/stack/XyoPublicNetworkStack.d.ts +9 -0
- package/dist/node/stack/XyoPublicNetworkStack.d.ts.map +1 -0
- package/dist/node/stack/index.d.ts +7 -0
- package/dist/node/stack/index.d.ts.map +1 -0
- package/dist/node/system/ManageSystemDapps.d.ts +33 -0
- package/dist/node/system/ManageSystemDapps.d.ts.map +1 -0
- package/dist/node/system/Queries.d.ts +9 -0
- package/dist/node/system/Queries.d.ts.map +1 -0
- package/dist/node/system/index.d.ts +2 -0
- package/dist/node/system/index.d.ts.map +1 -0
- package/dist/node/utils/buildWalletSeedPhrasePayload.d.ts +30 -0
- package/dist/node/utils/buildWalletSeedPhrasePayload.d.ts.map +1 -0
- package/dist/node/utils/getApiDomain.d.ts +3 -0
- package/dist/node/utils/getApiDomain.d.ts.map +1 -0
- package/dist/node/utils/index.d.ts +4 -0
- package/dist/node/utils/index.d.ts.map +1 -0
- package/dist/node/utils/renameObjKey.d.ts +7 -0
- package/dist/node/utils/renameObjKey.d.ts.map +1 -0
- package/dist/node/wallet/DappSeedPhraseRepository.d.ts +16 -0
- package/dist/node/wallet/DappSeedPhraseRepository.d.ts.map +1 -0
- package/dist/node/wallet/SeedPhraseRepository.d.ts +28 -0
- package/dist/node/wallet/SeedPhraseRepository.d.ts.map +1 -0
- package/dist/node/wallet/index.d.ts +3 -0
- package/dist/node/wallet/index.d.ts.map +1 -0
- package/package.json +8 -8
|
@@ -0,0 +1,2044 @@
|
|
|
1
|
+
// src/scripts/xyos/index.ts
|
|
2
|
+
import yargs from "yargs";
|
|
3
|
+
import { hideBin } from "yargs/helpers";
|
|
4
|
+
|
|
5
|
+
// src/scripts/xyos/command/config.ts
|
|
6
|
+
var commandConfig = (argv) => {
|
|
7
|
+
return argv.command("config [action] <target>", "Create an xyos project", (yargs2) => {
|
|
8
|
+
return yargs2.positional("action", {
|
|
9
|
+
choices: ["create", "validate", "display"],
|
|
10
|
+
description: "Action to take on config",
|
|
11
|
+
type: "string"
|
|
12
|
+
}).positional("target", {
|
|
13
|
+
description: "Location of config file",
|
|
14
|
+
type: "string"
|
|
15
|
+
});
|
|
16
|
+
}, async ({ action, target }) => {
|
|
17
|
+
console.log(`Taking action [${action}] on manifest at ${target}`);
|
|
18
|
+
return await Promise.resolve();
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// src/scripts/xyos/lib/createFromTemplate.ts
|
|
23
|
+
var createFromTemplate = async ({ target, template }) => {
|
|
24
|
+
console.log("Creating from template", template, "at", target);
|
|
25
|
+
return await Promise.resolve();
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// src/scripts/xyos/lib/headless.ts
|
|
29
|
+
import fs from "node:fs";
|
|
30
|
+
import { boot as boot2 } from "@xyo-network/bios";
|
|
31
|
+
import { Kernel as Kernel2 } from "@xyo-network/kernel";
|
|
32
|
+
import { HDWallet as HDWallet5 } from "@xyo-network/sdk-js";
|
|
33
|
+
import chalk from "chalk";
|
|
34
|
+
import { cosmiconfig } from "cosmiconfig";
|
|
35
|
+
import { TypeScriptLoader } from "cosmiconfig-typescript-loader";
|
|
36
|
+
import tk from "terminal-kit";
|
|
37
|
+
|
|
38
|
+
// src/XyOs.ts
|
|
39
|
+
import { assertEx as assertEx11 } from "@xylabs/sdk-js";
|
|
40
|
+
import { boot } from "@xyo-network/bios";
|
|
41
|
+
import { Kernel } from "@xyo-network/kernel";
|
|
42
|
+
import { ModuleFactoryLocator as ModuleFactoryLocator6 } from "@xyo-network/sdk-js";
|
|
43
|
+
|
|
44
|
+
// src/event/bus/Connection.ts
|
|
45
|
+
import { assertEx, BaseEmitter } from "@xylabs/sdk-js";
|
|
46
|
+
var EventBusConnection = class extends BaseEmitter {
|
|
47
|
+
_id;
|
|
48
|
+
description;
|
|
49
|
+
type;
|
|
50
|
+
constructor(request) {
|
|
51
|
+
super({});
|
|
52
|
+
this.description = request.description;
|
|
53
|
+
this.type = request.type;
|
|
54
|
+
}
|
|
55
|
+
get id() {
|
|
56
|
+
return assertEx(this._id, () => "Connection ID not set. Did you forget to call buildConnection()?");
|
|
57
|
+
}
|
|
58
|
+
buildConnection(id) {
|
|
59
|
+
this._id = id;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// src/event/bus/EventBus.ts
|
|
64
|
+
import {
|
|
65
|
+
assertEx as assertEx2,
|
|
66
|
+
findAs,
|
|
67
|
+
forget
|
|
68
|
+
} from "@xylabs/sdk-js";
|
|
69
|
+
import { asArchivistInstance } from "@xyo-network/archivist";
|
|
70
|
+
import {
|
|
71
|
+
asOptionalEventBusEvent,
|
|
72
|
+
isPubSubConnections
|
|
73
|
+
} from "@xyo-network/os-model";
|
|
74
|
+
import { PayloadBuilder } from "@xyo-network/payload-builder";
|
|
75
|
+
import { asSchema } from "@xyo-network/payload-model";
|
|
76
|
+
import { MemoryArchivist, MemoryArchivistConfigSchema } from "@xyo-network/sdk-js";
|
|
77
|
+
import { Mutex } from "async-mutex";
|
|
78
|
+
import { v4 as uuid } from "uuid";
|
|
79
|
+
var EventBus = class {
|
|
80
|
+
// Internal Archivist to store event data
|
|
81
|
+
_archivist;
|
|
82
|
+
// Store all connections
|
|
83
|
+
connections = {};
|
|
84
|
+
// Store all publisher callbacks for later removal
|
|
85
|
+
publisherCallbacks = {};
|
|
86
|
+
startMutex = new Mutex();
|
|
87
|
+
get archivist() {
|
|
88
|
+
return asArchivistInstance(
|
|
89
|
+
assertEx2(this._archivist, () => "Archivist not found. Did you forget to call start()?"),
|
|
90
|
+
"not a valid archivist instance",
|
|
91
|
+
{ required: true }
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
addConnection(connection) {
|
|
95
|
+
const id = uuid();
|
|
96
|
+
this.connections[id] = connection;
|
|
97
|
+
connection.buildConnection(id);
|
|
98
|
+
if (isPubSubConnections(connection)) {
|
|
99
|
+
this.handlePublisherAdd(connection);
|
|
100
|
+
} else {
|
|
101
|
+
throw new Error("Unsupported connection type. Must be PubSub");
|
|
102
|
+
}
|
|
103
|
+
return connection;
|
|
104
|
+
}
|
|
105
|
+
removeConnection(connectionId) {
|
|
106
|
+
const connection = this.connections[connectionId];
|
|
107
|
+
if (!connection) {
|
|
108
|
+
throw new Error("Connection not found " + connectionId);
|
|
109
|
+
}
|
|
110
|
+
if (connection && isPubSubConnections(connection)) {
|
|
111
|
+
this.handlePublisherRemove(connection);
|
|
112
|
+
}
|
|
113
|
+
delete this.connections[connectionId];
|
|
114
|
+
}
|
|
115
|
+
async start(storeName = "EventBusArchivist") {
|
|
116
|
+
return await this.startMutex.runExclusive(async () => {
|
|
117
|
+
if (this._archivist) {
|
|
118
|
+
console.warn("EventBus already started");
|
|
119
|
+
return this;
|
|
120
|
+
}
|
|
121
|
+
this._archivist = await MemoryArchivist.create({ config: { name: storeName, schema: MemoryArchivistConfigSchema } });
|
|
122
|
+
this.archivist.on("inserted", ({ payloads }) => {
|
|
123
|
+
const eventBusEvent = findAs(payloads, asOptionalEventBusEvent);
|
|
124
|
+
if (!eventBusEvent) return;
|
|
125
|
+
for (const connectionId in this.connections) {
|
|
126
|
+
const connection = this.connections[connectionId];
|
|
127
|
+
if (isPubSubConnections(connection) && connection.subscribableEvents) {
|
|
128
|
+
for (const [eventName, callback] of connection.subscribableEvents.entries()) {
|
|
129
|
+
if (eventName !== eventBusEvent.name) continue;
|
|
130
|
+
if (callback) {
|
|
131
|
+
const forgettable = async () => await callback({ payloads });
|
|
132
|
+
forget(forgettable());
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
return this;
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
handlePublisherAdd(connection) {
|
|
142
|
+
for (const eventName of connection.publishableEvents ?? []) {
|
|
143
|
+
const connectionPublisherCallback = async ({ payloads }) => {
|
|
144
|
+
const event = { name: eventName, schema: asSchema("network.xyo.event.bus.event", true) };
|
|
145
|
+
const eventPayloads = payloads ?? [];
|
|
146
|
+
event.sources = await PayloadBuilder.dataHashes(eventPayloads);
|
|
147
|
+
try {
|
|
148
|
+
await this.archivist.insert([event, ...payloads ?? []]);
|
|
149
|
+
} catch (e) {
|
|
150
|
+
console.error("Error inserting event into archivist", e);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
connection.on(eventName, connectionPublisherCallback);
|
|
154
|
+
const callbackId = connection.id + eventName;
|
|
155
|
+
this.publisherCallbacks[callbackId] = connectionPublisherCallback;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
handlePublisherRemove(connection) {
|
|
159
|
+
for (const [, event] of connection.publishableEvents?.entries() ?? []) {
|
|
160
|
+
const id = connection.id + event;
|
|
161
|
+
const callback = this.publisherCallbacks[id];
|
|
162
|
+
if (callback) connection.off(event, callback);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
// src/event/bus/PubSubConnection.ts
|
|
168
|
+
var EventBusPubSubConnection = class extends EventBusConnection {
|
|
169
|
+
publishableEvents;
|
|
170
|
+
subscribableEvents;
|
|
171
|
+
constructor(request) {
|
|
172
|
+
super(request);
|
|
173
|
+
if (request.type !== "PubSub") {
|
|
174
|
+
throw new Error("Invalid connection type. Must be PubSub");
|
|
175
|
+
}
|
|
176
|
+
this.publishableEvents = request.publishableEvents;
|
|
177
|
+
this.subscribableEvents = request.subscribableEvents;
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
// src/event/connections/DappAccessRequest.ts
|
|
182
|
+
var DappAccessRequestEvent = "dappAccessRequest";
|
|
183
|
+
var dappAccessRequestConnectionRequest = {
|
|
184
|
+
publishableEvents: [DappAccessRequestEvent],
|
|
185
|
+
type: "PubSub"
|
|
186
|
+
};
|
|
187
|
+
var dappAccessRequestConnection = () => new EventBusPubSubConnection(dappAccessRequestConnectionRequest);
|
|
188
|
+
|
|
189
|
+
// src/event/connections/ExposeDappRequest.ts
|
|
190
|
+
var ExposeDappRequestEvent = "exposeDappRequest";
|
|
191
|
+
var exposeDappConnectionRequest = {
|
|
192
|
+
publishableEvents: [ExposeDappRequestEvent],
|
|
193
|
+
type: "PubSub"
|
|
194
|
+
};
|
|
195
|
+
var exposeDappRequestConnection = () => new EventBusPubSubConnection(exposeDappConnectionRequest);
|
|
196
|
+
|
|
197
|
+
// src/event/connections/OsPubSubNetworkReady.ts
|
|
198
|
+
var OsPubSubNetworkReadyEvent = "osPubSubNetworkReady";
|
|
199
|
+
var osPubSubNetworkConnectionRequest = {
|
|
200
|
+
publishableEvents: [OsPubSubNetworkReadyEvent],
|
|
201
|
+
type: "PubSub"
|
|
202
|
+
};
|
|
203
|
+
var osPubSubNetworkReadyConnection = () => new EventBusPubSubConnection(osPubSubNetworkConnectionRequest);
|
|
204
|
+
|
|
205
|
+
// src/event/connections/OsSettingsReady.ts
|
|
206
|
+
var OsSettingsReadyEvent = "osSettingsReady";
|
|
207
|
+
var osSettingsConnectionRequest = {
|
|
208
|
+
publishableEvents: [OsSettingsReadyEvent],
|
|
209
|
+
type: "PubSub"
|
|
210
|
+
};
|
|
211
|
+
var osSettingsReadyConnection = () => new EventBusPubSubConnection(osSettingsConnectionRequest);
|
|
212
|
+
|
|
213
|
+
// src/event/connections/OsXyoPublicReady.ts
|
|
214
|
+
var OsXyoPublicNetworkReadyEvent = "osXyoPublicNetworkReady";
|
|
215
|
+
var osXyoPublicNetworkConnectionRequest = {
|
|
216
|
+
publishableEvents: [OsXyoPublicNetworkReadyEvent],
|
|
217
|
+
type: "PubSub"
|
|
218
|
+
};
|
|
219
|
+
var osXyoPublicNetworkReadyConnection = () => new EventBusPubSubConnection(osXyoPublicNetworkConnectionRequest);
|
|
220
|
+
|
|
221
|
+
// src/lib/initializeXns.ts
|
|
222
|
+
import { asDivinerInstance } from "@xyo-network/diviner-model";
|
|
223
|
+
import { ResolveHelper } from "@xyo-network/module";
|
|
224
|
+
import { NameRegistrarTransformer } from "@xyo-network/module-resolver";
|
|
225
|
+
var initializeXns = async (xnsNode) => {
|
|
226
|
+
if (ResolveHelper.transformers.length === 0) {
|
|
227
|
+
const registrarDiviner = asDivinerInstance(await xnsNode?.resolve("AddressRecords:AddressRecordIndexDiviner"));
|
|
228
|
+
if (registrarDiviner) {
|
|
229
|
+
const transformer = new NameRegistrarTransformer(registrarDiviner, "xyo");
|
|
230
|
+
ResolveHelper.transformers = [transformer];
|
|
231
|
+
return true;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
return false;
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
// src/lib/NameTransforms.ts
|
|
238
|
+
var NameTransforms = class _NameTransforms {
|
|
239
|
+
value;
|
|
240
|
+
constructor(value) {
|
|
241
|
+
this.value = value;
|
|
242
|
+
}
|
|
243
|
+
static deSlug(value) {
|
|
244
|
+
return value.replaceAll("-", " ").split(" ").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
|
|
245
|
+
}
|
|
246
|
+
static moduleName(value) {
|
|
247
|
+
return value.replaceAll(" ", "");
|
|
248
|
+
}
|
|
249
|
+
static slug(value) {
|
|
250
|
+
return value.replaceAll(" ", "-").toLocaleLowerCase();
|
|
251
|
+
}
|
|
252
|
+
deSlug() {
|
|
253
|
+
return _NameTransforms.deSlug(this.value);
|
|
254
|
+
}
|
|
255
|
+
moduleName() {
|
|
256
|
+
return _NameTransforms.moduleName(this.value);
|
|
257
|
+
}
|
|
258
|
+
slug() {
|
|
259
|
+
return _NameTransforms.slug(this.value);
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
// src/loadOsNode.ts
|
|
264
|
+
import { IndexedDbArchivist } from "@xyo-network/archivist-indexeddb";
|
|
265
|
+
import { IndexedDbPayloadDiviner } from "@xyo-network/diviner-payload-indexeddb";
|
|
266
|
+
import { ManifestWrapper, ModuleFactoryLocator } from "@xyo-network/sdk-js";
|
|
267
|
+
|
|
268
|
+
// src/manifest/os-node.manifest.json
|
|
269
|
+
var os_node_manifest_default = {
|
|
270
|
+
$schema: "https://raw.githubusercontent.com/XYOracleNetwork/sdk-xyo-client-js/main/packages/manifest/src/compilations/dapp-package-manifest-schema.json",
|
|
271
|
+
nodes: [
|
|
272
|
+
{
|
|
273
|
+
config: {
|
|
274
|
+
accountPath: "0'",
|
|
275
|
+
name: "OsNode",
|
|
276
|
+
schema: "network.xyo.node.config"
|
|
277
|
+
},
|
|
278
|
+
modules: {
|
|
279
|
+
private: [],
|
|
280
|
+
public: [
|
|
281
|
+
{
|
|
282
|
+
config: {
|
|
283
|
+
accountPath: "1'",
|
|
284
|
+
name: "OSArchivist",
|
|
285
|
+
dbName: "OSArchivist-2025-01-13",
|
|
286
|
+
labels: {
|
|
287
|
+
"network.xyo.archivist.persistence.scope": "device"
|
|
288
|
+
},
|
|
289
|
+
storeName: "payloads",
|
|
290
|
+
parents: {
|
|
291
|
+
read: [
|
|
292
|
+
"Archivist"
|
|
293
|
+
]
|
|
294
|
+
},
|
|
295
|
+
schema: "network.xyo.archivist.config"
|
|
296
|
+
}
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
config: {
|
|
300
|
+
accountPath: "3'",
|
|
301
|
+
name: "DappsArchivist",
|
|
302
|
+
dbName: "DappsArchivist-2025-01-13",
|
|
303
|
+
labels: {
|
|
304
|
+
"network.xyo.archivist.persistence.scope": "device"
|
|
305
|
+
},
|
|
306
|
+
storeName: "payloads",
|
|
307
|
+
schema: "network.xyo.archivist.config"
|
|
308
|
+
}
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
config: {
|
|
312
|
+
archivist: "DappsArchivist",
|
|
313
|
+
dbVersion: 1,
|
|
314
|
+
name: "DappsArchivistPayloadDiviner",
|
|
315
|
+
labels: {
|
|
316
|
+
"network.xyo.archivist.persistence.scope": "device"
|
|
317
|
+
},
|
|
318
|
+
schema: "network.xyo.diviner.payload.generic.config"
|
|
319
|
+
}
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
config: {
|
|
323
|
+
accountPath: "4'",
|
|
324
|
+
dbName: "IntentArchivist-2025-01-13",
|
|
325
|
+
name: "IntentArchivist",
|
|
326
|
+
storeName: "payloads",
|
|
327
|
+
labels: {
|
|
328
|
+
"network.xyo.archivist.persistence.scope": "device"
|
|
329
|
+
},
|
|
330
|
+
schema: "network.xyo.archivist.config"
|
|
331
|
+
}
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
config: {
|
|
335
|
+
accountPath: "7",
|
|
336
|
+
archivist: "IntentArchivist",
|
|
337
|
+
dbVersion: 1,
|
|
338
|
+
name: "IntentArchivistPayloadDiviner",
|
|
339
|
+
labels: {
|
|
340
|
+
"network.xyo.archivist.persistence.scope": "device"
|
|
341
|
+
},
|
|
342
|
+
schema: "network.xyo.diviner.payload.generic.config",
|
|
343
|
+
storeName: "payloads"
|
|
344
|
+
}
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
config: {
|
|
348
|
+
accountPath: "8",
|
|
349
|
+
name: "RegisteredDappInterfacesArchivist",
|
|
350
|
+
schema: "network.xyo.archivist.memory.config"
|
|
351
|
+
}
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
config: {
|
|
355
|
+
accountPath: "9'",
|
|
356
|
+
name: "DappsArchivistDevelopment",
|
|
357
|
+
parents: {
|
|
358
|
+
write: [
|
|
359
|
+
"DappsArchivist"
|
|
360
|
+
]
|
|
361
|
+
},
|
|
362
|
+
schema: "network.xyo.archivist.memory.config"
|
|
363
|
+
}
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
config: {
|
|
367
|
+
accountPath: "10",
|
|
368
|
+
archivist: "DappsArchivistDevelopment",
|
|
369
|
+
dbVersion: 1,
|
|
370
|
+
name: "DappsArchivistPayloadDivinerDevelopment",
|
|
371
|
+
labels: {
|
|
372
|
+
"network.xyo.generic.payload.diviner": "GenericPayloadDiviner"
|
|
373
|
+
},
|
|
374
|
+
schema: "network.xyo.diviner.payload.generic.config"
|
|
375
|
+
}
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
config: {
|
|
379
|
+
name: "OsPubSubNetworkStackNode",
|
|
380
|
+
schema: "network.xyo.node.config"
|
|
381
|
+
}
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
config: {
|
|
385
|
+
name: "OsSettingsStackNode",
|
|
386
|
+
schema: "network.xyo.node.config"
|
|
387
|
+
}
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
config: {
|
|
391
|
+
name: "OsXyoPublicNetworkStackNode",
|
|
392
|
+
schema: "network.xyo.node.config"
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
]
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
],
|
|
399
|
+
schema: "network.xyo.manifest.package.dapp"
|
|
400
|
+
};
|
|
401
|
+
|
|
402
|
+
// src/loadOsNode.ts
|
|
403
|
+
var OS_NODE_PATH = "1'";
|
|
404
|
+
var getDefaultOsNodeLocator = () => {
|
|
405
|
+
const locator = new ModuleFactoryLocator();
|
|
406
|
+
locator.register(IndexedDbArchivist.factory(), { "network.xyo.archivist.persistence.scope": "device" });
|
|
407
|
+
locator.register(IndexedDbPayloadDiviner.factory(), { "network.xyo.archivist.persistence.scope": "device" });
|
|
408
|
+
return locator;
|
|
409
|
+
};
|
|
410
|
+
var loadOsNode = async (osWallet, locator) => {
|
|
411
|
+
try {
|
|
412
|
+
const osNodeWallet = await osWallet.derivePath(OS_NODE_PATH);
|
|
413
|
+
const osNodeLocator = locator ?? getDefaultOsNodeLocator();
|
|
414
|
+
const manifestWrapper = new ManifestWrapper(os_node_manifest_default, osNodeWallet, osNodeLocator);
|
|
415
|
+
const osNode = (await manifestWrapper.loadNodes())[0];
|
|
416
|
+
return [osNode];
|
|
417
|
+
} catch (e) {
|
|
418
|
+
const error = e;
|
|
419
|
+
console.error(`Error creating os node: ${error.message}`);
|
|
420
|
+
console.error(`Error creating os node: ${error.stack}`);
|
|
421
|
+
throw new Error(`Error creating os node: ${error.message}`, { cause: e });
|
|
422
|
+
}
|
|
423
|
+
};
|
|
424
|
+
|
|
425
|
+
// src/registration/DappRegistrationService.ts
|
|
426
|
+
import {
|
|
427
|
+
forget as forget2,
|
|
428
|
+
fulfilled,
|
|
429
|
+
rejected
|
|
430
|
+
} from "@xylabs/sdk-js";
|
|
431
|
+
import {
|
|
432
|
+
DappIntentTypes,
|
|
433
|
+
DappMode as DappMode2,
|
|
434
|
+
isRegisteredDappAccessDappSet,
|
|
435
|
+
isRegisteredDappExposedDappSet
|
|
436
|
+
} from "@xyo-network/os-model";
|
|
437
|
+
import { ModuleFactoryLocator as ModuleFactoryLocator5 } from "@xyo-network/sdk-js";
|
|
438
|
+
|
|
439
|
+
// src/intent/Caller.ts
|
|
440
|
+
import { PayloadDivinerQuerySchema } from "@xyo-network/diviner-payload-model";
|
|
441
|
+
import { DappIntentSchema, DappMode } from "@xyo-network/os-model";
|
|
442
|
+
|
|
443
|
+
// src/DappCallerBase.ts
|
|
444
|
+
import { assertEx as assertEx3, toSafeJsonString } from "@xylabs/sdk-js";
|
|
445
|
+
import { asArchivistInstance as asArchivistInstance2 } from "@xyo-network/archivist-model";
|
|
446
|
+
import { asDivinerInstance as asDivinerInstance2 } from "@xyo-network/diviner-model";
|
|
447
|
+
var DappArchivistModuleName = "DappArchivist";
|
|
448
|
+
var IntentArchivistModuleName = "IntentArchivist";
|
|
449
|
+
var IntentArchivistPayloadDivinerModuleName = "IntentArchivistPayloadDiviner";
|
|
450
|
+
var DappArchivistPayloadDivinerModuleName = "DappArchivistPayloadDiviner";
|
|
451
|
+
var DappCallerBase = class {
|
|
452
|
+
context;
|
|
453
|
+
constructor(context) {
|
|
454
|
+
this.context = context;
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* Get the DappArchivist
|
|
458
|
+
*/
|
|
459
|
+
async getDappArchivist() {
|
|
460
|
+
const mod = assertEx3(
|
|
461
|
+
await this.context.root.resolve(DappArchivistModuleName),
|
|
462
|
+
() => `${DappArchivistModuleName} not found [${toSafeJsonString(this.context.root.publicChildren())}]`
|
|
463
|
+
);
|
|
464
|
+
return asArchivistInstance2(mod, () => `${DappArchivistModuleName} is not an archivist`, { required: true });
|
|
465
|
+
}
|
|
466
|
+
/**
|
|
467
|
+
* Get the DappArchivistPayloadDiviner
|
|
468
|
+
*/
|
|
469
|
+
async getDappArchivistPayloadDiviner() {
|
|
470
|
+
const mod = assertEx3(
|
|
471
|
+
await this.context.root.resolve(DappArchivistPayloadDivinerModuleName),
|
|
472
|
+
() => `${DappArchivistPayloadDivinerModuleName} not found`
|
|
473
|
+
);
|
|
474
|
+
return asDivinerInstance2(mod, () => `${DappArchivistPayloadDivinerModuleName} is not a diviner`, { required: true });
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* Get the IntentArchivist
|
|
478
|
+
*/
|
|
479
|
+
async getDappIntentArchivist() {
|
|
480
|
+
const mod = assertEx3(await this.context.root.resolve(IntentArchivistModuleName), () => `${IntentArchivistModuleName} not found`);
|
|
481
|
+
return asArchivistInstance2(mod, () => `${IntentArchivistModuleName} is not an archivist`, { required: true });
|
|
482
|
+
}
|
|
483
|
+
// Get the IntentArchivistPayloadDiviner
|
|
484
|
+
async getDappIntentArchivistPayloadDiviner() {
|
|
485
|
+
const mod = assertEx3(
|
|
486
|
+
await this.context.root.resolve(IntentArchivistPayloadDivinerModuleName),
|
|
487
|
+
() => `${IntentArchivistPayloadDivinerModuleName} not found`
|
|
488
|
+
);
|
|
489
|
+
return asDivinerInstance2(mod, () => `${IntentArchivistPayloadDivinerModuleName} is not a diviner`, { required: true });
|
|
490
|
+
}
|
|
491
|
+
};
|
|
492
|
+
|
|
493
|
+
// src/intent/Caller.ts
|
|
494
|
+
var DappIntentCaller = class _DappIntentCaller extends DappCallerBase {
|
|
495
|
+
static OsDappName = "XyOs";
|
|
496
|
+
constructor(context) {
|
|
497
|
+
super(context);
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* Build a new intent
|
|
501
|
+
* @param sourceDappId
|
|
502
|
+
* @param intent
|
|
503
|
+
* @param targetDappId
|
|
504
|
+
* @param targetMode
|
|
505
|
+
* @param params?
|
|
506
|
+
* @returns DappIntent
|
|
507
|
+
*/
|
|
508
|
+
static buildIntent(sourceDappId, intent, targetDappId, targetMode = DappMode.Window, params) {
|
|
509
|
+
return {
|
|
510
|
+
intent,
|
|
511
|
+
params: params ?? "",
|
|
512
|
+
schema: DappIntentSchema,
|
|
513
|
+
sourceDappId,
|
|
514
|
+
targetDappId,
|
|
515
|
+
targetMode: targetMode ?? DappMode.Window,
|
|
516
|
+
timestamp: Date.now()
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
// Add a new intent
|
|
520
|
+
async addIntent(id, intent, mode) {
|
|
521
|
+
const intentArchivist = await this.getDappIntentArchivist();
|
|
522
|
+
const newIntent = _DappIntentCaller.buildIntent(id, intent, mode);
|
|
523
|
+
await intentArchivist.insert([newIntent]);
|
|
524
|
+
}
|
|
525
|
+
// Get all intents
|
|
526
|
+
async allIntents() {
|
|
527
|
+
const archivist = await this.getDappIntentArchivist();
|
|
528
|
+
return await archivist.all();
|
|
529
|
+
}
|
|
530
|
+
// Get the latest intent saved to the archivist
|
|
531
|
+
async latestIntent() {
|
|
532
|
+
const archivist = await this.getDappIntentArchivist();
|
|
533
|
+
return (await archivist.all()).at(-1);
|
|
534
|
+
}
|
|
535
|
+
// Get the latest intent for a dapp
|
|
536
|
+
async latestIntentForDappName(dappName) {
|
|
537
|
+
const diviner = await this.getDappIntentArchivistPayloadDiviner();
|
|
538
|
+
const query = {
|
|
539
|
+
limit: 1,
|
|
540
|
+
order: "desc",
|
|
541
|
+
schema: PayloadDivinerQuerySchema,
|
|
542
|
+
sourceDappId: dappName
|
|
543
|
+
};
|
|
544
|
+
return await diviner.divine([query]);
|
|
545
|
+
}
|
|
546
|
+
};
|
|
547
|
+
|
|
548
|
+
// src/system/ManageSystemDapps.ts
|
|
549
|
+
import { PayloadBuilder as PayloadBuilder3 } from "@xyo-network/payload-builder";
|
|
550
|
+
import semver from "semver";
|
|
551
|
+
|
|
552
|
+
// src/OsCallerBase.ts
|
|
553
|
+
import { assertEx as assertEx4 } from "@xylabs/sdk-js";
|
|
554
|
+
import { asArchivistInstance as asArchivistInstance3 } from "@xyo-network/archivist-model";
|
|
555
|
+
import { asDivinerInstance as asDivinerInstance3 } from "@xyo-network/diviner-model";
|
|
556
|
+
var DappsArchivistModuleName = "DappsArchivist";
|
|
557
|
+
var DappsArchivistDevelopmentModuleName = `${DappsArchivistModuleName}Development`;
|
|
558
|
+
var DappsArchivistPayloadDivinerModuleName = "DappsArchivistPayloadDiviner";
|
|
559
|
+
var DappsArchivistPayloadDevelopmentDivinerModuleName = `${DappsArchivistPayloadDivinerModuleName}Development`;
|
|
560
|
+
var RegisteredDappInterfacesArchivistModuleName = "RegisteredDappInterfacesArchivist";
|
|
561
|
+
var OsCallerBase = class {
|
|
562
|
+
context;
|
|
563
|
+
constructor(context) {
|
|
564
|
+
this.context = context;
|
|
565
|
+
}
|
|
566
|
+
// Get the dapps archivist
|
|
567
|
+
async getDappsArchivist() {
|
|
568
|
+
const mod = assertEx4(await this.context.root.resolve(DappsArchivistModuleName), () => `${DappsArchivistModuleName} not found`);
|
|
569
|
+
return asArchivistInstance3(mod, () => `${DappsArchivistModuleName} is not an archivist`, { required: true });
|
|
570
|
+
}
|
|
571
|
+
// Get the dapps archivist development
|
|
572
|
+
async getDappsArchivistDevelopment() {
|
|
573
|
+
const mod = assertEx4(
|
|
574
|
+
await this.context.root.resolve(DappsArchivistDevelopmentModuleName),
|
|
575
|
+
() => `${DappsArchivistDevelopmentModuleName} not found`
|
|
576
|
+
);
|
|
577
|
+
return asArchivistInstance3(mod, () => `${DappsArchivistDevelopmentModuleName} is not an archivist`, { required: true });
|
|
578
|
+
}
|
|
579
|
+
// Get the dapps archivist payload diviner
|
|
580
|
+
async getDappsArchivistPayloadDiviner() {
|
|
581
|
+
const mod = assertEx4(
|
|
582
|
+
await this.context.root.resolve(DappsArchivistPayloadDivinerModuleName),
|
|
583
|
+
() => `${DappsArchivistPayloadDivinerModuleName} not found`
|
|
584
|
+
);
|
|
585
|
+
return asDivinerInstance3(mod, () => `${DappsArchivistPayloadDivinerModuleName} is not a diviner`, { required: true });
|
|
586
|
+
}
|
|
587
|
+
// Get the dapps archivist payload diviner development
|
|
588
|
+
async getDappsArchivistPayloadDivinerDevelopment() {
|
|
589
|
+
const mod = assertEx4(
|
|
590
|
+
await this.context.root.resolve(DappsArchivistPayloadDevelopmentDivinerModuleName),
|
|
591
|
+
() => `${DappsArchivistPayloadDevelopmentDivinerModuleName} not found`
|
|
592
|
+
);
|
|
593
|
+
return asDivinerInstance3(mod, () => `${DappsArchivistPayloadDevelopmentDivinerModuleName} is not a diviner`, { required: true });
|
|
594
|
+
}
|
|
595
|
+
// Get the registered dapp interfaces archivist
|
|
596
|
+
async getRegisteredDappInterfacesArchivist() {
|
|
597
|
+
const mod = assertEx4(
|
|
598
|
+
await this.context.root.resolve(RegisteredDappInterfacesArchivistModuleName),
|
|
599
|
+
() => `${RegisteredDappInterfacesArchivistModuleName} not found`
|
|
600
|
+
);
|
|
601
|
+
return asArchivistInstance3(mod, () => `${RegisteredDappInterfacesArchivistModuleName} is not an archivist`, { required: true });
|
|
602
|
+
}
|
|
603
|
+
};
|
|
604
|
+
|
|
605
|
+
// src/system/Queries.ts
|
|
606
|
+
import { PayloadDivinerQuerySchema as PayloadDivinerQuerySchema2 } from "@xyo-network/diviner-payload-model";
|
|
607
|
+
import {
|
|
608
|
+
DappConfigSchema,
|
|
609
|
+
DappIconSchema,
|
|
610
|
+
DappWidgetConfigSchema,
|
|
611
|
+
UnregisteredDappAccessSchema
|
|
612
|
+
} from "@xyo-network/os-model";
|
|
613
|
+
import { PayloadBuilder as PayloadBuilder2 } from "@xyo-network/payload-builder";
|
|
614
|
+
var SystemDappQueries = {
|
|
615
|
+
async getDappAccess(diviner, name, version) {
|
|
616
|
+
const accessQuery = {
|
|
617
|
+
order: "desc",
|
|
618
|
+
registeringDappId: name,
|
|
619
|
+
schema: PayloadDivinerQuerySchema2,
|
|
620
|
+
schemas: [UnregisteredDappAccessSchema],
|
|
621
|
+
version
|
|
622
|
+
};
|
|
623
|
+
return await diviner.divine([accessQuery]);
|
|
624
|
+
},
|
|
625
|
+
async getLatestConfig(diviner, name) {
|
|
626
|
+
const configQuery = {
|
|
627
|
+
limit: 1,
|
|
628
|
+
name,
|
|
629
|
+
order: "desc",
|
|
630
|
+
schema: PayloadDivinerQuerySchema2,
|
|
631
|
+
schemas: [DappConfigSchema]
|
|
632
|
+
};
|
|
633
|
+
const [dappConfig] = await diviner.divine([configQuery]);
|
|
634
|
+
return dappConfig;
|
|
635
|
+
},
|
|
636
|
+
async getLatestIcon(diviner, name, version) {
|
|
637
|
+
const iconQuery = {
|
|
638
|
+
name,
|
|
639
|
+
order: "desc",
|
|
640
|
+
schema: PayloadDivinerQuerySchema2,
|
|
641
|
+
schemas: [DappIconSchema],
|
|
642
|
+
version
|
|
643
|
+
};
|
|
644
|
+
const [dappIcon] = await diviner.divine([iconQuery]);
|
|
645
|
+
return dappIcon;
|
|
646
|
+
},
|
|
647
|
+
async getWidgetConfigs(diviner, name, version) {
|
|
648
|
+
const widgetConfigQuery = {
|
|
649
|
+
dappId: name,
|
|
650
|
+
order: "desc",
|
|
651
|
+
schema: PayloadDivinerQuerySchema2,
|
|
652
|
+
schemas: [DappWidgetConfigSchema],
|
|
653
|
+
version
|
|
654
|
+
};
|
|
655
|
+
const widgetConfigs = await diviner.divine([widgetConfigQuery]);
|
|
656
|
+
const uniqueConfigs = {};
|
|
657
|
+
for (const widgetConfig of widgetConfigs) {
|
|
658
|
+
const hash = await PayloadBuilder2.dataHash(widgetConfig);
|
|
659
|
+
uniqueConfigs[widgetConfig.mode ?? hash] = widgetConfig;
|
|
660
|
+
}
|
|
661
|
+
return Object.values(uniqueConfigs);
|
|
662
|
+
}
|
|
663
|
+
};
|
|
664
|
+
|
|
665
|
+
// src/system/ManageSystemDapps.ts
|
|
666
|
+
var ManageSystemDapps = class extends OsCallerBase {
|
|
667
|
+
defaultSystemDappParams;
|
|
668
|
+
defaultSystemDapps;
|
|
669
|
+
defaultSystemNames;
|
|
670
|
+
developmentMode;
|
|
671
|
+
locator;
|
|
672
|
+
onErrorCallbacks = [];
|
|
673
|
+
constructor(context, defaultSystemNames, defaultSystemDapps, defaultSystemDappParams, locator, developmentMode) {
|
|
674
|
+
super(context);
|
|
675
|
+
this.defaultSystemNames = defaultSystemNames;
|
|
676
|
+
this.defaultSystemDapps = defaultSystemDapps;
|
|
677
|
+
this.defaultSystemDappParams = defaultSystemDappParams;
|
|
678
|
+
this.locator = locator;
|
|
679
|
+
this.developmentMode = developmentMode;
|
|
680
|
+
}
|
|
681
|
+
/**
|
|
682
|
+
* Add a callback to listen for errors throwing during system dapp registration
|
|
683
|
+
* @param errorListener
|
|
684
|
+
*/
|
|
685
|
+
addErrorListener(errorListener) {
|
|
686
|
+
this.onErrorCallbacks.push(errorListener);
|
|
687
|
+
}
|
|
688
|
+
/**
|
|
689
|
+
* Installs the dapps into the OS and builds the appropriate DappSet
|
|
690
|
+
*/
|
|
691
|
+
async install() {
|
|
692
|
+
await this.insertPayloads();
|
|
693
|
+
return await this.latestSets();
|
|
694
|
+
}
|
|
695
|
+
async freshInstall(archivist) {
|
|
696
|
+
await archivist.insert(this.defaultSystemDapps);
|
|
697
|
+
}
|
|
698
|
+
async insertPayloads() {
|
|
699
|
+
const archivist = this.developmentMode ? await this.getDappsArchivistDevelopment() : await this.getDappsArchivist();
|
|
700
|
+
try {
|
|
701
|
+
const allPayloads = await archivist.all();
|
|
702
|
+
if (allPayloads.length === 0) {
|
|
703
|
+
await this.freshInstall(archivist);
|
|
704
|
+
return true;
|
|
705
|
+
}
|
|
706
|
+
for (const systemDappPayload of this.defaultSystemDapps) {
|
|
707
|
+
try {
|
|
708
|
+
const validSemver = semver.valid(systemDappPayload.version);
|
|
709
|
+
if (!validSemver) throw new Error("semver is a valid type (string) but was not able to be parsed");
|
|
710
|
+
} catch (e) {
|
|
711
|
+
console.error(`${systemDappPayload.version} does not appear to be a valid semver value`, e);
|
|
712
|
+
continue;
|
|
713
|
+
}
|
|
714
|
+
const [existing] = await archivist.get([await PayloadBuilder3.dataHash(systemDappPayload)]);
|
|
715
|
+
if (existing) continue;
|
|
716
|
+
await archivist.insert([systemDappPayload]);
|
|
717
|
+
}
|
|
718
|
+
return true;
|
|
719
|
+
} catch (e) {
|
|
720
|
+
console.error("error installing system dapps");
|
|
721
|
+
throw e;
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
async latestSets() {
|
|
725
|
+
const diviner = this.developmentMode ? await this.getDappsArchivistPayloadDivinerDevelopment() : await this.getDappsArchivistPayloadDiviner();
|
|
726
|
+
const dappSets = [];
|
|
727
|
+
const failedPayloads = [];
|
|
728
|
+
for (const name of this.defaultSystemNames) {
|
|
729
|
+
try {
|
|
730
|
+
const dappConfig = await SystemDappQueries.getLatestConfig(diviner, name);
|
|
731
|
+
if (!dappConfig) {
|
|
732
|
+
console.error(`No config found for dapp ${name}`);
|
|
733
|
+
continue;
|
|
734
|
+
}
|
|
735
|
+
const dappIcon = await SystemDappQueries.getLatestIcon(diviner, name, dappConfig.version);
|
|
736
|
+
if (!dappIcon) {
|
|
737
|
+
console.error(`No icon found for dapp ${dappConfig.name}`);
|
|
738
|
+
failedPayloads.push(dappConfig);
|
|
739
|
+
continue;
|
|
740
|
+
}
|
|
741
|
+
const dappAccess = await SystemDappQueries.getDappAccess(diviner, name, dappConfig.version);
|
|
742
|
+
const dappParams = this.defaultSystemDappParams[dappConfig.name];
|
|
743
|
+
if (!dappParams) {
|
|
744
|
+
console.error(`No params found for dapp ${dappConfig.name}. Did you forget to add it to OsDappParams?`);
|
|
745
|
+
failedPayloads.push(dappConfig);
|
|
746
|
+
continue;
|
|
747
|
+
}
|
|
748
|
+
const dappWidgetConfigs = await SystemDappQueries.getWidgetConfigs(diviner, name, dappConfig.version);
|
|
749
|
+
dappSets.push({
|
|
750
|
+
dapp: {
|
|
751
|
+
accessors: dappAccess,
|
|
752
|
+
config: dappConfig,
|
|
753
|
+
icon: dappIcon,
|
|
754
|
+
params: dappParams,
|
|
755
|
+
widgetConfigs: dappWidgetConfigs
|
|
756
|
+
}
|
|
757
|
+
});
|
|
758
|
+
} catch {
|
|
759
|
+
console.error(`Failed to build dapp ${name}`);
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
if (failedPayloads.length > 0) {
|
|
763
|
+
for (const cb of this.onErrorCallbacks) cb(failedPayloads);
|
|
764
|
+
}
|
|
765
|
+
return dappSets;
|
|
766
|
+
}
|
|
767
|
+
};
|
|
768
|
+
|
|
769
|
+
// src/wallet/DappSeedPhraseRepository.ts
|
|
770
|
+
import { PayloadDivinerQuerySchema as PayloadDivinerQuerySchema3 } from "@xyo-network/diviner-payload-model";
|
|
771
|
+
import { DappWalletSeedPhraseSchema } from "@xyo-network/os-model";
|
|
772
|
+
import { HDWallet } from "@xyo-network/sdk-js";
|
|
773
|
+
import { v4 as uuid2 } from "uuid";
|
|
774
|
+
var DappSeedPhraseRepository = class extends OsCallerBase {
|
|
775
|
+
allowedNames;
|
|
776
|
+
// record of all dapps that have requested a seed phrase with the OS
|
|
777
|
+
dappIdRepository = /* @__PURE__ */ new Map();
|
|
778
|
+
// record of all walletIds that have been issued to registered dapps
|
|
779
|
+
walletIdRepository = /* @__PURE__ */ new Map();
|
|
780
|
+
constructor(xyOs, allowedNames) {
|
|
781
|
+
super(xyOs);
|
|
782
|
+
this.allowedNames = allowedNames;
|
|
783
|
+
}
|
|
784
|
+
async add(dappId) {
|
|
785
|
+
const archivist = await this.getDappsArchivist();
|
|
786
|
+
const seedPhrase = this.newPhrase();
|
|
787
|
+
const walletId = uuid2();
|
|
788
|
+
const payload = {
|
|
789
|
+
dappId,
|
|
790
|
+
schema: DappWalletSeedPhraseSchema,
|
|
791
|
+
seedPhrase,
|
|
792
|
+
walletId
|
|
793
|
+
};
|
|
794
|
+
await archivist.insert([payload]);
|
|
795
|
+
this.dappIdRepository.set(dappId, payload);
|
|
796
|
+
this.walletIdRepository.set(walletId, payload);
|
|
797
|
+
return walletId;
|
|
798
|
+
}
|
|
799
|
+
async findOrCreate(dappName) {
|
|
800
|
+
if (this.allowedNames.includes(dappName)) {
|
|
801
|
+
const existingPayload = await this.checkDappId(dappName);
|
|
802
|
+
if (existingPayload) return existingPayload.walletId;
|
|
803
|
+
try {
|
|
804
|
+
await this.add(dappName);
|
|
805
|
+
const existingPayload2 = await this.checkDappId(dappName);
|
|
806
|
+
if (existingPayload2) return existingPayload2.walletId;
|
|
807
|
+
throw new Error(`failed to add seed phrase: ${dappName}`);
|
|
808
|
+
} catch (e) {
|
|
809
|
+
console.error(e);
|
|
810
|
+
throw new Error(`failed to add seed phrase: ${dappName}`, { cause: e });
|
|
811
|
+
}
|
|
812
|
+
} else {
|
|
813
|
+
throw new Error(`${dappName} is not allowed to register a seed phase. NOTE: this is a safeguard till 3rd party dApps can be validated`);
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
async request(walletId) {
|
|
817
|
+
return (await this.checkWalletId(walletId))?.seedPhrase;
|
|
818
|
+
}
|
|
819
|
+
async checkDappId(dappId) {
|
|
820
|
+
const diviner = await this.getDappsArchivistPayloadDiviner();
|
|
821
|
+
const query = {
|
|
822
|
+
dappId,
|
|
823
|
+
limit: 1,
|
|
824
|
+
order: "desc",
|
|
825
|
+
schema: PayloadDivinerQuerySchema3,
|
|
826
|
+
schemas: [DappWalletSeedPhraseSchema]
|
|
827
|
+
};
|
|
828
|
+
const results = await diviner.divine([query]);
|
|
829
|
+
return results.length > 0 ? results[0] : void 0;
|
|
830
|
+
}
|
|
831
|
+
async checkWalletId(walletId) {
|
|
832
|
+
const diviner = await this.getDappsArchivistPayloadDiviner();
|
|
833
|
+
const query = {
|
|
834
|
+
limit: 1,
|
|
835
|
+
order: "desc",
|
|
836
|
+
schema: PayloadDivinerQuerySchema3,
|
|
837
|
+
schemas: [DappWalletSeedPhraseSchema],
|
|
838
|
+
walletId
|
|
839
|
+
};
|
|
840
|
+
const results = await diviner.divine([query]);
|
|
841
|
+
return results.length > 0 ? results[0] : void 0;
|
|
842
|
+
}
|
|
843
|
+
newPhrase() {
|
|
844
|
+
return HDWallet.generateMnemonic();
|
|
845
|
+
}
|
|
846
|
+
};
|
|
847
|
+
|
|
848
|
+
// src/XyOsDapp.ts
|
|
849
|
+
import { assertEx as assertEx6 } from "@xylabs/sdk-js";
|
|
850
|
+
import { DappPackageManifestPayloadSchema } from "@xyo-network/os-model";
|
|
851
|
+
import {
|
|
852
|
+
ManifestWrapper as ManifestWrapper2,
|
|
853
|
+
ModuleFactoryLocator as ModuleFactoryLocator3
|
|
854
|
+
} from "@xyo-network/sdk-js";
|
|
855
|
+
|
|
856
|
+
// src/manifests/dapp-window.manifest.json
|
|
857
|
+
var dapp_window_manifest_default = {
|
|
858
|
+
$schema: "https://raw.githubusercontent.com/XYOracleNetwork/sdk-xyo-client-js/main/packages/manifest/src/compilations/dapp-package-manifest-schema.json",
|
|
859
|
+
nodes: [
|
|
860
|
+
{
|
|
861
|
+
config: {
|
|
862
|
+
accountPath: "0'",
|
|
863
|
+
name: "Dapp",
|
|
864
|
+
schema: "network.xyo.node.config"
|
|
865
|
+
},
|
|
866
|
+
modules: {
|
|
867
|
+
private: [],
|
|
868
|
+
public: [
|
|
869
|
+
{
|
|
870
|
+
config: {
|
|
871
|
+
accountPath: "0'/0'",
|
|
872
|
+
name: "DappArchivist",
|
|
873
|
+
schema: "network.xyo.archivist.memory.config"
|
|
874
|
+
}
|
|
875
|
+
},
|
|
876
|
+
{
|
|
877
|
+
config: {
|
|
878
|
+
accountPath: "0'/1'",
|
|
879
|
+
archivist: "DappArchivist",
|
|
880
|
+
labels: {
|
|
881
|
+
"network.xyo.generic.payload.diviner": "GenericPayloadDiviner"
|
|
882
|
+
},
|
|
883
|
+
name: "DappArchivistPayloadDiviner",
|
|
884
|
+
schema: "network.xyo.diviner.payload.generic.config"
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
]
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
],
|
|
891
|
+
schema: "network.xyo.manifest.package.dapp"
|
|
892
|
+
};
|
|
893
|
+
|
|
894
|
+
// src/XyOsBase.ts
|
|
895
|
+
import { assertEx as assertEx5, BaseEmitter as BaseEmitter2 } from "@xylabs/sdk-js";
|
|
896
|
+
import { ModuleFactoryLocator as ModuleFactoryLocator2 } from "@xyo-network/sdk-js";
|
|
897
|
+
import { Mutex as Mutex2 } from "async-mutex";
|
|
898
|
+
var XyOsContextBase = class extends BaseEmitter2 {
|
|
899
|
+
_bootMutex = new Mutex2();
|
|
900
|
+
_platformLocator;
|
|
901
|
+
_root;
|
|
902
|
+
get bios() {
|
|
903
|
+
return this.kernel?.bios;
|
|
904
|
+
}
|
|
905
|
+
get eventBus() {
|
|
906
|
+
return assertEx5(this.params.eventBus, () => "Missing event bus");
|
|
907
|
+
}
|
|
908
|
+
get exposedNode() {
|
|
909
|
+
throw new Error("Method not implemented. [exposedNode]");
|
|
910
|
+
}
|
|
911
|
+
get exposedNodeOuter() {
|
|
912
|
+
throw new Error("Method not implemented. [exposedNodeOuter]");
|
|
913
|
+
}
|
|
914
|
+
get installedDapps() {
|
|
915
|
+
return [];
|
|
916
|
+
}
|
|
917
|
+
get kernel() {
|
|
918
|
+
return void 0;
|
|
919
|
+
}
|
|
920
|
+
get manifest() {
|
|
921
|
+
return assertEx5(this.params.manifest, () => "Missing manifest");
|
|
922
|
+
}
|
|
923
|
+
get platformLocator() {
|
|
924
|
+
this._platformLocator = this._platformLocator ?? this.params.platformLocator ?? new ModuleFactoryLocator2();
|
|
925
|
+
return this._platformLocator;
|
|
926
|
+
}
|
|
927
|
+
get possibleRoot() {
|
|
928
|
+
return this._root;
|
|
929
|
+
}
|
|
930
|
+
get root() {
|
|
931
|
+
return assertEx5(this._root, () => "XyOs root not set (probably not yet booted)");
|
|
932
|
+
}
|
|
933
|
+
get runningDapps() {
|
|
934
|
+
return [];
|
|
935
|
+
}
|
|
936
|
+
get signerPaths() {
|
|
937
|
+
return this.params.signerPaths;
|
|
938
|
+
}
|
|
939
|
+
get state() {
|
|
940
|
+
return this._root ? "running" : "stopped";
|
|
941
|
+
}
|
|
942
|
+
get user() {
|
|
943
|
+
throw new Error("Method not implemented. [user]");
|
|
944
|
+
}
|
|
945
|
+
boot(_wallet, _locator) {
|
|
946
|
+
throw new Error("Method not implemented. [boot]");
|
|
947
|
+
}
|
|
948
|
+
buildDapp(_manifest, _dappId) {
|
|
949
|
+
throw new Error("Method not implemented. [buildDapp]");
|
|
950
|
+
}
|
|
951
|
+
dappByName(_dappId) {
|
|
952
|
+
throw new Error("Method not implemented. [runningDapp]");
|
|
953
|
+
}
|
|
954
|
+
getDappParams(_dappId) {
|
|
955
|
+
throw new Error("Method not implemented. [getDappParams]");
|
|
956
|
+
}
|
|
957
|
+
getStack(_stackName) {
|
|
958
|
+
throw new Error("Method not implemented. [getStack]");
|
|
959
|
+
}
|
|
960
|
+
installDapp(_dappId) {
|
|
961
|
+
throw new Error("Method not implemented. [installDapp]");
|
|
962
|
+
}
|
|
963
|
+
monitor(_fn, _eventConfig) {
|
|
964
|
+
throw new Error("Method not implemented. [monitor]");
|
|
965
|
+
}
|
|
966
|
+
shutdown() {
|
|
967
|
+
throw new Error("Method not implemented. [shutdown]");
|
|
968
|
+
}
|
|
969
|
+
startDapp(_dappId) {
|
|
970
|
+
throw new Error("Method not implemented. [startDapp]");
|
|
971
|
+
}
|
|
972
|
+
stopDapp(_dappId) {
|
|
973
|
+
throw new Error("Method not implemented. [stopDapp]");
|
|
974
|
+
}
|
|
975
|
+
uninstallDapp(_dappId) {
|
|
976
|
+
throw new Error("Method not implemented. [uninstallDapp]");
|
|
977
|
+
}
|
|
978
|
+
};
|
|
979
|
+
|
|
980
|
+
// src/XyOsDapp.ts
|
|
981
|
+
var XyOsDapp = class extends XyOsContextBase {
|
|
982
|
+
dapp;
|
|
983
|
+
constructor(params) {
|
|
984
|
+
super(params);
|
|
985
|
+
this.dapp = { ...params.dapp };
|
|
986
|
+
}
|
|
987
|
+
get eventBus() {
|
|
988
|
+
return this.parent.eventBus;
|
|
989
|
+
}
|
|
990
|
+
get exposedNode() {
|
|
991
|
+
return this.parent.exposedNode;
|
|
992
|
+
}
|
|
993
|
+
get exposedNodeOuter() {
|
|
994
|
+
return this.parent.exposedNodeOuter;
|
|
995
|
+
}
|
|
996
|
+
/**
|
|
997
|
+
* @deprecated Dapps should not have access to the bios. This is done for the
|
|
998
|
+
* settings dapp, but should be refactored out. Bios could possibly be an
|
|
999
|
+
* optional property of the parent context passed in for dapps that require
|
|
1000
|
+
* elevated permissions.
|
|
1001
|
+
* ^^^ I believe we may want this here in that is a dApp requests access to the bios it will optionally be there
|
|
1002
|
+
*/
|
|
1003
|
+
get kernel() {
|
|
1004
|
+
return assertEx6(this.parent.kernel, () => "Missing kernel");
|
|
1005
|
+
}
|
|
1006
|
+
get parent() {
|
|
1007
|
+
return this.params.parent;
|
|
1008
|
+
}
|
|
1009
|
+
get stacks() {
|
|
1010
|
+
return [];
|
|
1011
|
+
}
|
|
1012
|
+
get user() {
|
|
1013
|
+
return this.params.user;
|
|
1014
|
+
}
|
|
1015
|
+
async boot(wallet, locator) {
|
|
1016
|
+
return await this._bootMutex.runExclusive(async () => {
|
|
1017
|
+
console.log("XyOsDapp:boot:start", wallet.address, this.dapp.id);
|
|
1018
|
+
assertEx6(this._root === void 0, () => "Dapp already booted");
|
|
1019
|
+
const finalLocator = locator ? (this.params.locator ?? new ModuleFactoryLocator3()).merge(locator) : this.params.locator ?? new ModuleFactoryLocator3();
|
|
1020
|
+
console.log("XyOsDapp:boot:finalLocator", finalLocator);
|
|
1021
|
+
const dappNodesWrapper = new ManifestWrapper2({ ...this.manifest, schema: DappPackageManifestPayloadSchema }, wallet, finalLocator);
|
|
1022
|
+
const dappNodes = await dappNodesWrapper.loadNodes();
|
|
1023
|
+
const manifest = dapp_window_manifest_default;
|
|
1024
|
+
const dappManifestWallet = await wallet.derivePath("99999");
|
|
1025
|
+
manifest.nodes[0].config.name = this.dapp.name + "Root";
|
|
1026
|
+
const wrapper = new ManifestWrapper2(
|
|
1027
|
+
{ ...manifest, schema: DappPackageManifestPayloadSchema },
|
|
1028
|
+
dappManifestWallet,
|
|
1029
|
+
finalLocator
|
|
1030
|
+
);
|
|
1031
|
+
const node = await wrapper.loadNodeFromIndex(0);
|
|
1032
|
+
for (const dappNode of dappNodes) {
|
|
1033
|
+
await node.register(dappNode);
|
|
1034
|
+
await node.attach(dappNode.address, true);
|
|
1035
|
+
}
|
|
1036
|
+
this._root = node;
|
|
1037
|
+
console.log("XyOsDapp:boot:finish", wallet.address, this.dapp.id);
|
|
1038
|
+
return this;
|
|
1039
|
+
});
|
|
1040
|
+
}
|
|
1041
|
+
getStack(stackName) {
|
|
1042
|
+
return this.parent.getStack(stackName);
|
|
1043
|
+
}
|
|
1044
|
+
};
|
|
1045
|
+
|
|
1046
|
+
// src/registration/DappRegistry.ts
|
|
1047
|
+
import {
|
|
1048
|
+
DappRegisteredSchema,
|
|
1049
|
+
DappRegisteredState,
|
|
1050
|
+
isRegisteredDappAccess
|
|
1051
|
+
} from "@xyo-network/os-model";
|
|
1052
|
+
import { HDWallet as HDWallet3 } from "@xyo-network/sdk-js";
|
|
1053
|
+
|
|
1054
|
+
// src/registration/ValidateDappAccessDiviner/Config.ts
|
|
1055
|
+
import { asSchema as asSchema2, isPayloadOfSchemaType } from "@xyo-network/payload-model";
|
|
1056
|
+
var FailedAccessorSchema = asSchema2("network.xyo.os.failed.accessor.registration", true);
|
|
1057
|
+
var isFailedAccessor = isPayloadOfSchemaType(FailedAccessorSchema);
|
|
1058
|
+
var ValidateDappAccessDivinerConfigSchema = asSchema2("network.xyo.os.dapp.access.registration.validate", true);
|
|
1059
|
+
|
|
1060
|
+
// src/registration/ValidateDappAccessDiviner/Diviner.ts
|
|
1061
|
+
import { AbstractDiviner } from "@xyo-network/diviner-abstract";
|
|
1062
|
+
import {
|
|
1063
|
+
isDappPackageManifestPayload,
|
|
1064
|
+
isUnregisteredDappAccess,
|
|
1065
|
+
RegisteredDappAccessSchema
|
|
1066
|
+
} from "@xyo-network/os-model";
|
|
1067
|
+
import {
|
|
1068
|
+
HDWallet as HDWallet2,
|
|
1069
|
+
ManifestWrapper as ManifestWrapper3,
|
|
1070
|
+
ModuleFactoryLocator as ModuleFactoryLocator4,
|
|
1071
|
+
PackageManifestPayloadSchema
|
|
1072
|
+
} from "@xyo-network/sdk-js";
|
|
1073
|
+
|
|
1074
|
+
// src/models/access/ValidDappAccessInterfaces.ts
|
|
1075
|
+
import { RegisteredNames, RegisteredNamesInterface } from "@xyo-network/os-model";
|
|
1076
|
+
var ValidDappAccessInterfaces = { [RegisteredNames]: RegisteredNamesInterface };
|
|
1077
|
+
|
|
1078
|
+
// src/registration/ValidateDappAccessDiviner/Diviner.ts
|
|
1079
|
+
var ValidateDappAccessDiviner = class extends AbstractDiviner {
|
|
1080
|
+
static configSchemas = [ValidateDappAccessDivinerConfigSchema];
|
|
1081
|
+
async divineHandler(payloads) {
|
|
1082
|
+
const dappManifest = payloads?.filter(isDappPackageManifestPayload) ?? [];
|
|
1083
|
+
const accessors = payloads?.filter(isUnregisteredDappAccess) ?? [];
|
|
1084
|
+
const dappParams = this.params.dappParams;
|
|
1085
|
+
if (dappManifest.length > 1) {
|
|
1086
|
+
throw new Error("Only one dapp manifest payload is allowed");
|
|
1087
|
+
}
|
|
1088
|
+
if (dappManifest.length === 0 || accessors.length === 0) {
|
|
1089
|
+
return [];
|
|
1090
|
+
}
|
|
1091
|
+
const registeredAccessors = [];
|
|
1092
|
+
const failedAccessors = [];
|
|
1093
|
+
for (const access of accessors) {
|
|
1094
|
+
try {
|
|
1095
|
+
if (access) {
|
|
1096
|
+
const dappAccessInterface = ValidDappAccessInterfaces[access.name];
|
|
1097
|
+
if (!dappAccessInterface) {
|
|
1098
|
+
console.warn("Invalid dapp access interface", access.name);
|
|
1099
|
+
continue;
|
|
1100
|
+
}
|
|
1101
|
+
const dappManifestToTest = dappPackageManifestToPackageManifest(dappManifest[0]);
|
|
1102
|
+
const dappChildren = await getNodeChildren(dappManifestToTest, dappParams);
|
|
1103
|
+
const interfaceChildren = await getNodeChildren(dappAccessInterface.manifest, dappParams);
|
|
1104
|
+
const valid = compareChildren(interfaceChildren, dappChildren);
|
|
1105
|
+
if (valid) {
|
|
1106
|
+
const payload = {
|
|
1107
|
+
...access,
|
|
1108
|
+
schema: RegisteredDappAccessSchema,
|
|
1109
|
+
timestamp: Date.now()
|
|
1110
|
+
};
|
|
1111
|
+
registeredAccessors.push(payload);
|
|
1112
|
+
} else {
|
|
1113
|
+
const failedRegistration = {
|
|
1114
|
+
accessor: access,
|
|
1115
|
+
errorMessage: "Invalid dapp access interface",
|
|
1116
|
+
schema: FailedAccessorSchema
|
|
1117
|
+
};
|
|
1118
|
+
failedAccessors.push(failedRegistration);
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
} catch (e) {
|
|
1122
|
+
failedAccessors.push(
|
|
1123
|
+
{
|
|
1124
|
+
accessor: access,
|
|
1125
|
+
errorMessage: e.message,
|
|
1126
|
+
schema: FailedAccessorSchema
|
|
1127
|
+
}
|
|
1128
|
+
);
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
return [...registeredAccessors, ...failedAccessors];
|
|
1132
|
+
}
|
|
1133
|
+
};
|
|
1134
|
+
var compareChildren = (interfaceChildren, dappChildren) => {
|
|
1135
|
+
return interfaceChildren.every((interfaceChild) => Object.values(interfaceChild).every((interfaceChildName) => dappChildren.some((dappChild) => Object.values(dappChild).includes(interfaceChildName))));
|
|
1136
|
+
};
|
|
1137
|
+
var dappPackageManifestToPackageManifest = (dappPackageManifest) => {
|
|
1138
|
+
return {
|
|
1139
|
+
...dappPackageManifest,
|
|
1140
|
+
schema: PackageManifestPayloadSchema
|
|
1141
|
+
};
|
|
1142
|
+
};
|
|
1143
|
+
var getChildrenFromNode = async (node) => {
|
|
1144
|
+
const nodeManifest = (await node.state())?.[0];
|
|
1145
|
+
return nodeManifest.status?.children;
|
|
1146
|
+
};
|
|
1147
|
+
var getNodeChildren = async (manifestToTest, dappParams) => {
|
|
1148
|
+
const testNodes = await getNodeToTest(manifestToTest, dappParams);
|
|
1149
|
+
const children = [];
|
|
1150
|
+
for (const node of testNodes) {
|
|
1151
|
+
const nodeChildren = await getChildrenFromNode(node);
|
|
1152
|
+
if (nodeChildren) {
|
|
1153
|
+
children.push(nodeChildren);
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
return children;
|
|
1157
|
+
};
|
|
1158
|
+
var getNodeToTest = async (manifestToTest, dappParams) => {
|
|
1159
|
+
const dappManifestWrapper = new ManifestWrapper3(manifestToTest, await HDWallet2.random(), dappParams.locator ?? new ModuleFactoryLocator4());
|
|
1160
|
+
return await dappManifestWrapper.loadNodes();
|
|
1161
|
+
};
|
|
1162
|
+
|
|
1163
|
+
// src/registration/DappRegistry.ts
|
|
1164
|
+
var DappRegistry = class {
|
|
1165
|
+
dappRegistry = /* @__PURE__ */ new Map();
|
|
1166
|
+
dappSeedPhraseRepository;
|
|
1167
|
+
constructor(dappSeedPhraseRepository) {
|
|
1168
|
+
this.dappSeedPhraseRepository = dappSeedPhraseRepository;
|
|
1169
|
+
}
|
|
1170
|
+
/**
|
|
1171
|
+
* Register a Dapp with window manager and if successful, return its id
|
|
1172
|
+
* @param dapp Manifest and UI of the Dapp to register
|
|
1173
|
+
* @returns dapp with registration fields
|
|
1174
|
+
*/
|
|
1175
|
+
async registerDapp(dapp) {
|
|
1176
|
+
if (dapp) {
|
|
1177
|
+
const {
|
|
1178
|
+
exposedModuleIds,
|
|
1179
|
+
manifest,
|
|
1180
|
+
modes,
|
|
1181
|
+
name,
|
|
1182
|
+
version,
|
|
1183
|
+
params,
|
|
1184
|
+
widgetConfigs
|
|
1185
|
+
} = this.extractDappProperties(dapp);
|
|
1186
|
+
try {
|
|
1187
|
+
const walletId = await this.dappSeedPhraseRepository.findOrCreate(name);
|
|
1188
|
+
const registeredAccessors = await this.validateDappAccessPayloads(manifest, dapp.accessors, params);
|
|
1189
|
+
const registeredDapp = {
|
|
1190
|
+
accessors: registeredAccessors,
|
|
1191
|
+
config: {
|
|
1192
|
+
exposedModuleIds,
|
|
1193
|
+
manifest,
|
|
1194
|
+
modes,
|
|
1195
|
+
name,
|
|
1196
|
+
schema: DappRegisteredSchema,
|
|
1197
|
+
state: DappRegisteredState.Registered,
|
|
1198
|
+
version,
|
|
1199
|
+
// attach the walletId to a registered dapp so it can request it back in the future
|
|
1200
|
+
walletId
|
|
1201
|
+
},
|
|
1202
|
+
params,
|
|
1203
|
+
widgetConfigs
|
|
1204
|
+
};
|
|
1205
|
+
if (this.dappRegistry.get(name)) {
|
|
1206
|
+
console.warn("tried to register two dapps with the same name", name);
|
|
1207
|
+
return null;
|
|
1208
|
+
}
|
|
1209
|
+
this.dappRegistry.set(name, registeredDapp);
|
|
1210
|
+
return registeredDapp;
|
|
1211
|
+
} catch (e) {
|
|
1212
|
+
console.error("Error registeringDapp", e);
|
|
1213
|
+
return null;
|
|
1214
|
+
}
|
|
1215
|
+
} else {
|
|
1216
|
+
return null;
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
/**
|
|
1220
|
+
* Unregister a dapp so it can no longer be launched
|
|
1221
|
+
* @param dappId
|
|
1222
|
+
*/
|
|
1223
|
+
unregisterDapp(dappId) {
|
|
1224
|
+
this.dappRegistry.delete(dappId);
|
|
1225
|
+
}
|
|
1226
|
+
extractDappProperties(dapp) {
|
|
1227
|
+
const {
|
|
1228
|
+
params,
|
|
1229
|
+
config,
|
|
1230
|
+
widgetConfigs
|
|
1231
|
+
} = dapp;
|
|
1232
|
+
const {
|
|
1233
|
+
exposedModuleIds,
|
|
1234
|
+
manifest,
|
|
1235
|
+
modes,
|
|
1236
|
+
name,
|
|
1237
|
+
sources,
|
|
1238
|
+
version
|
|
1239
|
+
} = config;
|
|
1240
|
+
return {
|
|
1241
|
+
exposedModuleIds,
|
|
1242
|
+
manifest,
|
|
1243
|
+
modes,
|
|
1244
|
+
name,
|
|
1245
|
+
params,
|
|
1246
|
+
sources,
|
|
1247
|
+
version,
|
|
1248
|
+
widgetConfigs
|
|
1249
|
+
};
|
|
1250
|
+
}
|
|
1251
|
+
async validateDappAccessPayloads(manifest, accessors = [], params) {
|
|
1252
|
+
const validateDappAccess = await ValidateDappAccessDiviner.create({
|
|
1253
|
+
account: await HDWallet3.random(),
|
|
1254
|
+
config: { schema: ValidateDappAccessDivinerConfigSchema },
|
|
1255
|
+
dappParams: params
|
|
1256
|
+
});
|
|
1257
|
+
const payloads = await validateDappAccess.divine([manifest, ...accessors]);
|
|
1258
|
+
const failedAccessors = payloads.filter(isFailedAccessor);
|
|
1259
|
+
const registeredAccessors = payloads.filter(isRegisteredDappAccess);
|
|
1260
|
+
if (failedAccessors.length > 0) {
|
|
1261
|
+
console.error("Failed to register all dapp accessors", failedAccessors);
|
|
1262
|
+
}
|
|
1263
|
+
return registeredAccessors;
|
|
1264
|
+
}
|
|
1265
|
+
};
|
|
1266
|
+
|
|
1267
|
+
// src/registration/DappRegistrationService.ts
|
|
1268
|
+
var DappRegistrationService = class {
|
|
1269
|
+
// Dapps that have been built with their own context
|
|
1270
|
+
builtDapps = {};
|
|
1271
|
+
dappRegistry;
|
|
1272
|
+
dappSeedPhraseRepository;
|
|
1273
|
+
manageSystemDapps;
|
|
1274
|
+
// Dapps that have been registered with dappAccessRequests
|
|
1275
|
+
registeredAccessDappSets = /* @__PURE__ */ new Set();
|
|
1276
|
+
// Dapps that have been registered with the dapp registry
|
|
1277
|
+
registeredDappSets = /* @__PURE__ */ new Set();
|
|
1278
|
+
// Dapps that have been registered with exposeDappRequests
|
|
1279
|
+
registeredExposedDappSets = /* @__PURE__ */ new Set();
|
|
1280
|
+
context;
|
|
1281
|
+
dappAccessRequestConnection = dappAccessRequestConnection();
|
|
1282
|
+
developmentMode;
|
|
1283
|
+
exposeDappRequestConnection = exposeDappRequestConnection();
|
|
1284
|
+
locator;
|
|
1285
|
+
params;
|
|
1286
|
+
constructor(context, params, locator = new ModuleFactoryLocator5(), developmentMode) {
|
|
1287
|
+
this.context = context;
|
|
1288
|
+
this.params = params ?? {
|
|
1289
|
+
dappNames: [],
|
|
1290
|
+
dappParams: {},
|
|
1291
|
+
dappPayloads: []
|
|
1292
|
+
};
|
|
1293
|
+
this.locator = locator;
|
|
1294
|
+
this.developmentMode = developmentMode;
|
|
1295
|
+
this.manageSystemDapps = new ManageSystemDapps(
|
|
1296
|
+
context,
|
|
1297
|
+
this.params?.dappNames ?? [],
|
|
1298
|
+
this.params?.dappPayloads ?? [],
|
|
1299
|
+
this.params?.dappParams ?? {},
|
|
1300
|
+
this.locator,
|
|
1301
|
+
this.developmentMode
|
|
1302
|
+
);
|
|
1303
|
+
this.dappSeedPhraseRepository = new DappSeedPhraseRepository(context, this.params?.dappNames ?? []);
|
|
1304
|
+
this.dappRegistry = new DappRegistry(this.dappSeedPhraseRepository);
|
|
1305
|
+
this.addConnectionRequests();
|
|
1306
|
+
}
|
|
1307
|
+
async buildDapp(manifest, dappId = NameTransforms.slug(manifest.nodes[0]?.config.name), name = NameTransforms.moduleName(manifest.nodes[0]?.config.name)) {
|
|
1308
|
+
const dapp = new XyOsDapp({
|
|
1309
|
+
dapp: { id: dappId, name },
|
|
1310
|
+
locator: this.locator,
|
|
1311
|
+
manifest,
|
|
1312
|
+
parent: this.context,
|
|
1313
|
+
user: await this.getUser()
|
|
1314
|
+
});
|
|
1315
|
+
this.builtDapps[dappId] = dapp;
|
|
1316
|
+
return dapp;
|
|
1317
|
+
}
|
|
1318
|
+
getParamsForRegisteredDapp(dappId) {
|
|
1319
|
+
return this.params?.dappParams[dappId];
|
|
1320
|
+
}
|
|
1321
|
+
async start() {
|
|
1322
|
+
const systemDapps = await this.context.monitor(async () => await this.manageSystemDapps.install(), { name: "Install System dApps" });
|
|
1323
|
+
const activeDapps = systemDapps.filter(({ dapp }) => dapp.icon.active === true);
|
|
1324
|
+
const results = await Promise.allSettled(
|
|
1325
|
+
activeDapps.map(async (dappSet) => {
|
|
1326
|
+
const { dapp } = dappSet;
|
|
1327
|
+
const registeredDapp = await this.dappRegistry.registerDapp(dapp);
|
|
1328
|
+
const result = { dapp: registeredDapp, dappIcon: dapp.icon };
|
|
1329
|
+
const forgetHandlers = async () => {
|
|
1330
|
+
try {
|
|
1331
|
+
await this.postRegistrationHandlers(result);
|
|
1332
|
+
} catch (e) {
|
|
1333
|
+
console.error("Error in post registration handlers", e);
|
|
1334
|
+
}
|
|
1335
|
+
};
|
|
1336
|
+
forget2(forgetHandlers());
|
|
1337
|
+
return result;
|
|
1338
|
+
})
|
|
1339
|
+
);
|
|
1340
|
+
const failed = results.filter(rejected).map((result) => {
|
|
1341
|
+
const reason = result.reason;
|
|
1342
|
+
return reason instanceof Error ? reason.message : String(reason);
|
|
1343
|
+
});
|
|
1344
|
+
const succeeded = results.filter(fulfilled).map((result) => result.value);
|
|
1345
|
+
for (const registeredDapp of succeeded) this.registeredDappSets.add(registeredDapp);
|
|
1346
|
+
return { failed, succeeded };
|
|
1347
|
+
}
|
|
1348
|
+
addConnectionRequests() {
|
|
1349
|
+
this.context.eventBus.addConnection(this.dappAccessRequestConnection);
|
|
1350
|
+
this.context.eventBus.addConnection(this.exposeDappRequestConnection);
|
|
1351
|
+
}
|
|
1352
|
+
/**
|
|
1353
|
+
* A method to get the user property from context and eventually modify it before handing it to a dapp
|
|
1354
|
+
* i.e. curating user-approved signers
|
|
1355
|
+
*/
|
|
1356
|
+
getUser() {
|
|
1357
|
+
return this.context.user;
|
|
1358
|
+
}
|
|
1359
|
+
async postRegistrationHandlers(registeredDapp) {
|
|
1360
|
+
if (registeredDapp.dapp) {
|
|
1361
|
+
if (isRegisteredDappExposedDappSet(registeredDapp)) {
|
|
1362
|
+
this.registeredExposedDappSets.add(registeredDapp);
|
|
1363
|
+
const exposeIntent = DappIntentCaller.buildIntent(
|
|
1364
|
+
DappIntentCaller.OsDappName,
|
|
1365
|
+
DappIntentTypes.Launch,
|
|
1366
|
+
registeredDapp.dapp.config.name,
|
|
1367
|
+
DappMode2.Exposed
|
|
1368
|
+
);
|
|
1369
|
+
await this.exposeDappRequestConnection.emit(ExposeDappRequestEvent, { payloads: [registeredDapp.dapp.config, exposeIntent] });
|
|
1370
|
+
}
|
|
1371
|
+
if (isRegisteredDappAccessDappSet(registeredDapp)) {
|
|
1372
|
+
this.registeredAccessDappSets.add(registeredDapp);
|
|
1373
|
+
await this.dappAccessRequestConnection.emit(DappAccessRequestEvent, { payloads: registeredDapp.dapp.accessors });
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
};
|
|
1378
|
+
|
|
1379
|
+
// src/signer/Signers.ts
|
|
1380
|
+
import { assertEx as assertEx7 } from "@xylabs/sdk-js";
|
|
1381
|
+
import { HDWallet as HDWallet4 } from "@xyo-network/sdk-js";
|
|
1382
|
+
var Signers = class {
|
|
1383
|
+
_paths;
|
|
1384
|
+
_signerAccounts;
|
|
1385
|
+
_walletStore;
|
|
1386
|
+
constructor(paths, walletStore) {
|
|
1387
|
+
this._paths = paths;
|
|
1388
|
+
this._walletStore = walletStore;
|
|
1389
|
+
this._signerAccounts = /* @__PURE__ */ new Map();
|
|
1390
|
+
}
|
|
1391
|
+
get paths() {
|
|
1392
|
+
return assertEx7(this._paths, () => "Paths not initialized");
|
|
1393
|
+
}
|
|
1394
|
+
get signerAccounts() {
|
|
1395
|
+
return assertEx7(this._signerAccounts, () => "Signer accounts not initialized");
|
|
1396
|
+
}
|
|
1397
|
+
get walletStore() {
|
|
1398
|
+
return assertEx7(this._walletStore, () => "Wallet store not initialized");
|
|
1399
|
+
}
|
|
1400
|
+
getSigner(walletKind, signer) {
|
|
1401
|
+
return this.signerAccounts.get(walletKind)?.get(signer);
|
|
1402
|
+
}
|
|
1403
|
+
getWalletKindSigner(walletKind) {
|
|
1404
|
+
return this.signerAccounts.get(walletKind);
|
|
1405
|
+
}
|
|
1406
|
+
async initialize() {
|
|
1407
|
+
for (const [walletKindName, signerPaths] of this.paths) {
|
|
1408
|
+
for (const [signerName, walletPath] of signerPaths.entries()) {
|
|
1409
|
+
await this.initializeSigners(walletKindName, signerName, walletPath);
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
async initializeSigners(walletKindName, signerName, path) {
|
|
1414
|
+
assertEx7(signerName, () => "Name not found in signer paths");
|
|
1415
|
+
assertEx7(path, () => "Path not found in signer paths");
|
|
1416
|
+
const phrase = assertEx7(await this.walletStore.get(walletKindName), () => `Wallet not found: ${walletKindName}`);
|
|
1417
|
+
if (path) {
|
|
1418
|
+
const signerMap = this.signerAccounts.get(walletKindName) ?? /* @__PURE__ */ new Map();
|
|
1419
|
+
const wallet = await HDWallet4.fromPhrase(phrase);
|
|
1420
|
+
const derivedWallet = await wallet.derivePath(path);
|
|
1421
|
+
signerMap.set(signerName, derivedWallet);
|
|
1422
|
+
this.signerAccounts.set(walletKindName, signerMap);
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1425
|
+
};
|
|
1426
|
+
|
|
1427
|
+
// src/stack/Base.ts
|
|
1428
|
+
import {
|
|
1429
|
+
assertEx as assertEx8,
|
|
1430
|
+
BaseEmitter as BaseEmitter3,
|
|
1431
|
+
forget as forget3
|
|
1432
|
+
} from "@xylabs/sdk-js";
|
|
1433
|
+
import { isModuleInstance } from "@xyo-network/module-model";
|
|
1434
|
+
import { asAttachableNodeInstance } from "@xyo-network/node-model";
|
|
1435
|
+
var StackBase = class extends BaseEmitter3 {
|
|
1436
|
+
// flag to check that all adapters are initialized
|
|
1437
|
+
initialized = false;
|
|
1438
|
+
// adapters to initialize into the stack
|
|
1439
|
+
_adapterSet;
|
|
1440
|
+
_context;
|
|
1441
|
+
// stack node
|
|
1442
|
+
_stack;
|
|
1443
|
+
// stack node module identifier for the stack
|
|
1444
|
+
_stackNodeModuleId;
|
|
1445
|
+
// list of initialized nodes
|
|
1446
|
+
initializedNodes = [];
|
|
1447
|
+
// list of listeners - lister type not important since its only recalled to stop listening
|
|
1448
|
+
listeners = [];
|
|
1449
|
+
constructor(context, adapterSet, stackNodeModuleId) {
|
|
1450
|
+
super({});
|
|
1451
|
+
this._context = context;
|
|
1452
|
+
this._adapterSet = adapterSet(assertEx8(this.context.kernel, () => "Kernel access required"));
|
|
1453
|
+
this._stackNodeModuleId = stackNodeModuleId;
|
|
1454
|
+
}
|
|
1455
|
+
get adapterSet() {
|
|
1456
|
+
return assertEx8(this._adapterSet, () => `${this.stackNodeModuleId} adapters not initialized`);
|
|
1457
|
+
}
|
|
1458
|
+
get context() {
|
|
1459
|
+
return assertEx8(this._context, () => `${this.stackNodeModuleId} stack context not initialized`);
|
|
1460
|
+
}
|
|
1461
|
+
get stack() {
|
|
1462
|
+
return assertEx8(this._stack, () => `${this.stackNodeModuleId} stack node not initialized`);
|
|
1463
|
+
}
|
|
1464
|
+
get stackNodeModuleId() {
|
|
1465
|
+
return assertEx8(this._stackNodeModuleId, () => "Stack node module identifier not initialized");
|
|
1466
|
+
}
|
|
1467
|
+
initialize() {
|
|
1468
|
+
this.assignStack();
|
|
1469
|
+
for (const adapter of this.adapterSet) {
|
|
1470
|
+
const driverReadyListener = async ({ node }) => await this.handleDriverReady(node);
|
|
1471
|
+
adapter.on("driverReady", driverReadyListener);
|
|
1472
|
+
this.listeners.push({
|
|
1473
|
+
adapter,
|
|
1474
|
+
eventName: "driverReady",
|
|
1475
|
+
listener: driverReadyListener
|
|
1476
|
+
});
|
|
1477
|
+
const driverErrorListener = async ({ error }) => {
|
|
1478
|
+
console.error(`Error updating ${this.stackNodeModuleId} stack node`, error);
|
|
1479
|
+
await this.emit("driverError", { error });
|
|
1480
|
+
};
|
|
1481
|
+
adapter.on("driverError", driverErrorListener);
|
|
1482
|
+
this.listeners.push({
|
|
1483
|
+
adapter,
|
|
1484
|
+
eventName: "driverError",
|
|
1485
|
+
listener: driverErrorListener
|
|
1486
|
+
});
|
|
1487
|
+
const startAdapter = async () => await adapter.start();
|
|
1488
|
+
forget3(startAdapter());
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
/**
|
|
1492
|
+
* Stops the stack
|
|
1493
|
+
*/
|
|
1494
|
+
stop() {
|
|
1495
|
+
for (const {
|
|
1496
|
+
eventName,
|
|
1497
|
+
listener,
|
|
1498
|
+
adapter
|
|
1499
|
+
} of this.listeners) {
|
|
1500
|
+
adapter.off(eventName, listener);
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
/**
|
|
1504
|
+
* Adds a node to the stack. Idempotent to avoid adding the
|
|
1505
|
+
* same node multiple times
|
|
1506
|
+
* @param node The node to add to the stack
|
|
1507
|
+
* @returns
|
|
1508
|
+
*/
|
|
1509
|
+
async addNodeToStackNode(node) {
|
|
1510
|
+
const stackNode = await this.getStackNode();
|
|
1511
|
+
const existingModule = await stackNode.resolve(node.address, { direction: "down" });
|
|
1512
|
+
if (isModuleInstance(existingModule)) return;
|
|
1513
|
+
await stackNode.register?.(node);
|
|
1514
|
+
await stackNode.attach?.(node.address, true);
|
|
1515
|
+
}
|
|
1516
|
+
assignStack() {
|
|
1517
|
+
const assign = async () => {
|
|
1518
|
+
const stackNode = await this.getStackNode();
|
|
1519
|
+
this._stack = stackNode;
|
|
1520
|
+
};
|
|
1521
|
+
forget3(assign());
|
|
1522
|
+
}
|
|
1523
|
+
async getStackNode() {
|
|
1524
|
+
const mod = assertEx8(await this.context.root.resolve(this.stackNodeModuleId), () => `${this.stackNodeModuleId} not found`);
|
|
1525
|
+
return asAttachableNodeInstance(mod, () => `${this.stackNodeModuleId} not a NodeInstance`, { required: true });
|
|
1526
|
+
}
|
|
1527
|
+
async handleDriverReady(node) {
|
|
1528
|
+
try {
|
|
1529
|
+
await this.emit("driverReady", { node });
|
|
1530
|
+
await this.addNodeToStackNode(node);
|
|
1531
|
+
await this.updateInitializationState(node);
|
|
1532
|
+
} catch (error) {
|
|
1533
|
+
console.error(`Error updating ${this.stackNodeModuleId} stack node`, node.id, error);
|
|
1534
|
+
await this.emit("stackError", { error });
|
|
1535
|
+
}
|
|
1536
|
+
}
|
|
1537
|
+
async updateInitializationState(node) {
|
|
1538
|
+
this.initializedNodes.push(node);
|
|
1539
|
+
this.initialized = this.adapterSet.every((n) => n.initialized);
|
|
1540
|
+
if (this.initialized) {
|
|
1541
|
+
await this.emit("initialized", { stack: await this.getStackNode() });
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
};
|
|
1545
|
+
|
|
1546
|
+
// src/stack/Manager.ts
|
|
1547
|
+
var StackManager = class {
|
|
1548
|
+
initializedStacksMap = /* @__PURE__ */ new Map();
|
|
1549
|
+
stackMap;
|
|
1550
|
+
constructor(stackMap) {
|
|
1551
|
+
this.stackMap = stackMap;
|
|
1552
|
+
}
|
|
1553
|
+
get stacks() {
|
|
1554
|
+
return Object.keys(this.initializedStacksMap);
|
|
1555
|
+
}
|
|
1556
|
+
get initializedStacks() {
|
|
1557
|
+
return this.initializedStacksMap;
|
|
1558
|
+
}
|
|
1559
|
+
getStack(key) {
|
|
1560
|
+
return this.initializedStacksMap.get(key);
|
|
1561
|
+
}
|
|
1562
|
+
initialize(context) {
|
|
1563
|
+
for (const [key, stackSet] of Object.entries(this.stackMap)) {
|
|
1564
|
+
console.log("stack-initialize", key);
|
|
1565
|
+
const { stack: Stack, adapters: stackNodeModuleId } = stackSet;
|
|
1566
|
+
const initializedStack = new Stack(context, stackNodeModuleId);
|
|
1567
|
+
initializedStack.initialize();
|
|
1568
|
+
this.initializedStacks.set(key, initializedStack);
|
|
1569
|
+
}
|
|
1570
|
+
}
|
|
1571
|
+
stop() {
|
|
1572
|
+
for (const stack of this.initializedStacks.values()) {
|
|
1573
|
+
stack.stop();
|
|
1574
|
+
}
|
|
1575
|
+
}
|
|
1576
|
+
};
|
|
1577
|
+
|
|
1578
|
+
// src/adapters/OsPubSubBridgeNetwork.ts
|
|
1579
|
+
import { ExposedNodeOuterNodeName, PubSubBridgeNodeNodeName } from "@xyo-network/os-model";
|
|
1580
|
+
|
|
1581
|
+
// src/adapter/Base.ts
|
|
1582
|
+
import {
|
|
1583
|
+
assertEx as assertEx9,
|
|
1584
|
+
BaseEmitter as BaseEmitter4,
|
|
1585
|
+
forget as forget4
|
|
1586
|
+
} from "@xylabs/sdk-js";
|
|
1587
|
+
import { asArchivistInstance as asArchivistInstance4 } from "@xyo-network/archivist";
|
|
1588
|
+
import { asAttachableNodeInstance as asAttachableNodeInstance2 } from "@xyo-network/node-model";
|
|
1589
|
+
import {
|
|
1590
|
+
asSchema as asSchema3
|
|
1591
|
+
} from "@xyo-network/payload-model";
|
|
1592
|
+
import { v4 as uuid3 } from "uuid";
|
|
1593
|
+
var NodeAdapterBase = class extends BaseEmitter4 {
|
|
1594
|
+
initialized = false;
|
|
1595
|
+
_id = "";
|
|
1596
|
+
driverName;
|
|
1597
|
+
kernel;
|
|
1598
|
+
constructor(kernel, driverName) {
|
|
1599
|
+
super({});
|
|
1600
|
+
this._id = uuid3();
|
|
1601
|
+
this.kernel = kernel;
|
|
1602
|
+
this.driverName = driverName;
|
|
1603
|
+
}
|
|
1604
|
+
get id() {
|
|
1605
|
+
return assertEx9(this._id, () => "NodeAdapterBase id not initialized");
|
|
1606
|
+
}
|
|
1607
|
+
async start() {
|
|
1608
|
+
try {
|
|
1609
|
+
const moduleAttachedInsertListener = ({ payloads }) => {
|
|
1610
|
+
const moduleAttachedEvent = this.findModuleEventPayloads(payloads);
|
|
1611
|
+
for (const payload of moduleAttachedEvent) {
|
|
1612
|
+
if (payload.name === this.driverName) {
|
|
1613
|
+
this.validateAndReturnDriver();
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1616
|
+
};
|
|
1617
|
+
const eventsArchivist = await this.getEventsArchivist();
|
|
1618
|
+
const weakRefInsertListener = new WeakRef(moduleAttachedInsertListener);
|
|
1619
|
+
const insertListenerRef = weakRefInsertListener.deref();
|
|
1620
|
+
if (insertListenerRef) eventsArchivist.on("inserted", insertListenerRef);
|
|
1621
|
+
const node = this.validateAndReturnDriver();
|
|
1622
|
+
if (node) return node;
|
|
1623
|
+
this.initialized = false;
|
|
1624
|
+
} catch (error) {
|
|
1625
|
+
await this.emit("driverError", { error });
|
|
1626
|
+
}
|
|
1627
|
+
}
|
|
1628
|
+
findModuleEventPayloads(payloads) {
|
|
1629
|
+
return payloads.filter((payload) => {
|
|
1630
|
+
const payloadToTest = payload;
|
|
1631
|
+
return payloadToTest.event === "driverReady" && payloadToTest.schema === asSchema3("network.xyo.kernel.module.event", true);
|
|
1632
|
+
});
|
|
1633
|
+
}
|
|
1634
|
+
async getEventsArchivist() {
|
|
1635
|
+
const mod = assertEx9(await (await this.kernel.getNode()).resolve("KernelNode:ModuleEvents"), () => "KernelNode:ModuleEvents not found");
|
|
1636
|
+
return asArchivistInstance4(mod, () => `${mod.id} is not an archivist`, { required: true });
|
|
1637
|
+
}
|
|
1638
|
+
validateAndReturnDriver() {
|
|
1639
|
+
const mod = this.kernel.initialized[this.driverName];
|
|
1640
|
+
if (mod) {
|
|
1641
|
+
const node = asAttachableNodeInstance2(mod, () => `${mod.id} is not a node`, { required: true });
|
|
1642
|
+
this.initialized = true;
|
|
1643
|
+
const emit = async () => await this.emit("driverReady", { node });
|
|
1644
|
+
forget4(emit());
|
|
1645
|
+
return node;
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
};
|
|
1649
|
+
|
|
1650
|
+
// src/adapter/Network.ts
|
|
1651
|
+
var NetworkAdapter = class extends NodeAdapterBase {
|
|
1652
|
+
_connection;
|
|
1653
|
+
constructor(kernel, driverName) {
|
|
1654
|
+
super(kernel, driverName);
|
|
1655
|
+
this.on("driverReady", ({ node }) => {
|
|
1656
|
+
this._connection = node;
|
|
1657
|
+
});
|
|
1658
|
+
}
|
|
1659
|
+
get connection() {
|
|
1660
|
+
return this._connection;
|
|
1661
|
+
}
|
|
1662
|
+
get hasConnection() {
|
|
1663
|
+
return !!this.connection;
|
|
1664
|
+
}
|
|
1665
|
+
removeConnection() {
|
|
1666
|
+
this._connection = void 0;
|
|
1667
|
+
}
|
|
1668
|
+
};
|
|
1669
|
+
|
|
1670
|
+
// src/adapter/Settings.ts
|
|
1671
|
+
var SettingsAdapter = class extends NodeAdapterBase {
|
|
1672
|
+
_settings = void 0;
|
|
1673
|
+
constructor(kernel, driverName) {
|
|
1674
|
+
super(kernel, driverName);
|
|
1675
|
+
this.on("driverReady", ({ node }) => {
|
|
1676
|
+
this._settings = node;
|
|
1677
|
+
});
|
|
1678
|
+
}
|
|
1679
|
+
get hasSettings() {
|
|
1680
|
+
return !!this.settings;
|
|
1681
|
+
}
|
|
1682
|
+
get settings() {
|
|
1683
|
+
return this._settings;
|
|
1684
|
+
}
|
|
1685
|
+
removeSettings() {
|
|
1686
|
+
this._settings = void 0;
|
|
1687
|
+
}
|
|
1688
|
+
};
|
|
1689
|
+
|
|
1690
|
+
// src/adapters/OsPubSubBridgeNetwork.ts
|
|
1691
|
+
var OsPubSubBridgeNetworkAdapters = (kernel) => [
|
|
1692
|
+
new NetworkAdapter(kernel, PubSubBridgeNodeNodeName),
|
|
1693
|
+
new NetworkAdapter(kernel, ExposedNodeOuterNodeName)
|
|
1694
|
+
];
|
|
1695
|
+
|
|
1696
|
+
// src/adapters/OsSettings.ts
|
|
1697
|
+
import { OsSettingsNodeName } from "@xyo-network/os-model";
|
|
1698
|
+
var OsSettingsAdapters = (kernel) => [new SettingsAdapter(kernel, OsSettingsNodeName)];
|
|
1699
|
+
|
|
1700
|
+
// src/adapters/OsXyoPublicNetwork.ts
|
|
1701
|
+
import { XyoPublicNodeName } from "@xyo-network/os-model";
|
|
1702
|
+
var OsXyoPublicNetworkAdapters = (kernel) => [
|
|
1703
|
+
new NetworkAdapter(kernel, XyoPublicNodeName)
|
|
1704
|
+
];
|
|
1705
|
+
|
|
1706
|
+
// src/stack/OsPubSubNetworkStack.ts
|
|
1707
|
+
import { assertEx as assertEx10 } from "@xylabs/sdk-js";
|
|
1708
|
+
import { asAttachableNodeInstance as asAttachableNodeInstance3, asNodeInstance } from "@xyo-network/node-model";
|
|
1709
|
+
import { ExposedNodeOuterNodeName as ExposedNodeOuterNodeName2, PubSubBridgeNodeNodeName as PubSubBridgeNodeNodeName2 } from "@xyo-network/os-model";
|
|
1710
|
+
var OsPubSubNetworkStack = class extends StackBase {
|
|
1711
|
+
_exposedNode;
|
|
1712
|
+
_exposedNodeOuter;
|
|
1713
|
+
busConnection = osPubSubNetworkReadyConnection();
|
|
1714
|
+
constructor(context, adapters) {
|
|
1715
|
+
super(context, adapters, "OsPubSubNetworkStackNode");
|
|
1716
|
+
}
|
|
1717
|
+
get exposedNode() {
|
|
1718
|
+
return this._exposedNode;
|
|
1719
|
+
}
|
|
1720
|
+
get exposedNodeOuter() {
|
|
1721
|
+
return this._exposedNodeOuter;
|
|
1722
|
+
}
|
|
1723
|
+
initialize() {
|
|
1724
|
+
super.initialize();
|
|
1725
|
+
this.context.eventBus.addConnection(this.busConnection);
|
|
1726
|
+
this.on("initialized", () => this.busConnection.emit(OsPubSubNetworkReadyEvent, {}));
|
|
1727
|
+
super.on("driverReady", async ({ node }) => {
|
|
1728
|
+
if (node.id === PubSubBridgeNodeNodeName2) {
|
|
1729
|
+
const httpBridge = assertEx10(await node.resolve("NsHttpBridge"), () => "HttpBridge not found");
|
|
1730
|
+
const xnsNode = asNodeInstance(await httpBridge.resolve("XNS"));
|
|
1731
|
+
if (xnsNode) {
|
|
1732
|
+
const initializedXns = await initializeXns(xnsNode);
|
|
1733
|
+
console.log(`Xns: ${initializedXns}`);
|
|
1734
|
+
} else {
|
|
1735
|
+
console.log("Xns: Failed to contact Xns Node");
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
});
|
|
1739
|
+
super.on("driverReady", async ({ node }) => {
|
|
1740
|
+
if (node.id === ExposedNodeOuterNodeName2) {
|
|
1741
|
+
this._exposedNodeOuter = node;
|
|
1742
|
+
const mod = assertEx10(await node.resolve("ExposedNode"), () => "ExposedNode not found");
|
|
1743
|
+
const exposedNode = asAttachableNodeInstance3(mod, () => "ExposedNode is not a node");
|
|
1744
|
+
this._exposedNode = exposedNode;
|
|
1745
|
+
}
|
|
1746
|
+
});
|
|
1747
|
+
super.on("driverError", (error) => console.error("Unable to assign exposed node(s) to context", error));
|
|
1748
|
+
}
|
|
1749
|
+
stop() {
|
|
1750
|
+
super.stop();
|
|
1751
|
+
this._exposedNode = void 0;
|
|
1752
|
+
this._exposedNodeOuter = void 0;
|
|
1753
|
+
if (this.busConnection._id)
|
|
1754
|
+
this.context.eventBus.removeConnection(this.busConnection.id);
|
|
1755
|
+
}
|
|
1756
|
+
};
|
|
1757
|
+
|
|
1758
|
+
// src/stack/OsSettingsStack.ts
|
|
1759
|
+
var OsSettingsStack = class extends StackBase {
|
|
1760
|
+
busConnection = osSettingsReadyConnection();
|
|
1761
|
+
constructor(context, adapters) {
|
|
1762
|
+
super(context, adapters, "OsSettingsStackNode");
|
|
1763
|
+
}
|
|
1764
|
+
initialize() {
|
|
1765
|
+
super.initialize();
|
|
1766
|
+
this.context.eventBus.addConnection(this.busConnection);
|
|
1767
|
+
this.on("initialized", () => this.busConnection.emit(OsSettingsReadyEvent, {}));
|
|
1768
|
+
}
|
|
1769
|
+
stop() {
|
|
1770
|
+
super.stop();
|
|
1771
|
+
}
|
|
1772
|
+
};
|
|
1773
|
+
|
|
1774
|
+
// src/stack/XyoPublicNetworkStack.ts
|
|
1775
|
+
import { XyoPublicNodeName as XyoPublicNodeName2 } from "@xyo-network/os-model";
|
|
1776
|
+
var XyoPublicNetworkStack = class extends StackBase {
|
|
1777
|
+
busConnection = osXyoPublicNetworkReadyConnection();
|
|
1778
|
+
constructor(context, adapters) {
|
|
1779
|
+
super(context, adapters, "OsXyoPublicNetworkStackNode");
|
|
1780
|
+
}
|
|
1781
|
+
initialize() {
|
|
1782
|
+
super.initialize();
|
|
1783
|
+
this.context.eventBus.addConnection(this.busConnection);
|
|
1784
|
+
this.on("initialized", () => this.busConnection.emit(OsXyoPublicNetworkReadyEvent, {}));
|
|
1785
|
+
this.on("driverReady", ({ node }) => {
|
|
1786
|
+
if (node.id === XyoPublicNodeName2) {
|
|
1787
|
+
console.log("XyoPublicNode ready");
|
|
1788
|
+
}
|
|
1789
|
+
});
|
|
1790
|
+
this.on("driverError", (error) => console.error("Error loading driver", error));
|
|
1791
|
+
}
|
|
1792
|
+
stop() {
|
|
1793
|
+
super.stop();
|
|
1794
|
+
}
|
|
1795
|
+
};
|
|
1796
|
+
|
|
1797
|
+
// src/stack/Map.ts
|
|
1798
|
+
var OsStackMap = {
|
|
1799
|
+
osPubSubNetworkStack: {
|
|
1800
|
+
stack: OsPubSubNetworkStack,
|
|
1801
|
+
adapters: OsPubSubBridgeNetworkAdapters
|
|
1802
|
+
},
|
|
1803
|
+
xyoPublicNetworkStack: {
|
|
1804
|
+
stack: XyoPublicNetworkStack,
|
|
1805
|
+
adapters: OsXyoPublicNetworkAdapters
|
|
1806
|
+
},
|
|
1807
|
+
osSettingsStack: {
|
|
1808
|
+
stack: OsSettingsStack,
|
|
1809
|
+
adapters: OsSettingsAdapters
|
|
1810
|
+
}
|
|
1811
|
+
};
|
|
1812
|
+
|
|
1813
|
+
// src/XyOs.ts
|
|
1814
|
+
var XyOs = class _XyOs extends XyOsContextBase {
|
|
1815
|
+
_exposedNode;
|
|
1816
|
+
_exposedNodeOuter;
|
|
1817
|
+
_kernel;
|
|
1818
|
+
_locator;
|
|
1819
|
+
dappRegistrationService;
|
|
1820
|
+
signers;
|
|
1821
|
+
stackManager;
|
|
1822
|
+
constructor({
|
|
1823
|
+
logger = console,
|
|
1824
|
+
eventBus = new EventBus(),
|
|
1825
|
+
kernel = new Kernel({ logger }),
|
|
1826
|
+
locator = new ModuleFactoryLocator6(),
|
|
1827
|
+
dappsConfiguration,
|
|
1828
|
+
developmentMode,
|
|
1829
|
+
stackMap = OsStackMap,
|
|
1830
|
+
...params
|
|
1831
|
+
} = {}) {
|
|
1832
|
+
super({
|
|
1833
|
+
eventBus,
|
|
1834
|
+
kernel,
|
|
1835
|
+
locator,
|
|
1836
|
+
...params
|
|
1837
|
+
});
|
|
1838
|
+
this._locator = locator;
|
|
1839
|
+
this._kernel = kernel;
|
|
1840
|
+
this.stackManager = new StackManager(stackMap);
|
|
1841
|
+
this.dappRegistrationService = new DappRegistrationService(this, dappsConfiguration, this.locator, developmentMode);
|
|
1842
|
+
if (this.signerPaths && this.kernel?.bios?.seedPhraseStore) this.signers = new Signers(this.signerPaths, this.kernel?.bios?.seedPhraseStore);
|
|
1843
|
+
}
|
|
1844
|
+
static get monitoring() {
|
|
1845
|
+
return;
|
|
1846
|
+
}
|
|
1847
|
+
static get xyOsGlobal() {
|
|
1848
|
+
return getXyOsGlobal();
|
|
1849
|
+
}
|
|
1850
|
+
get bios() {
|
|
1851
|
+
return assertEx11(this.params.kernel?.bios, () => "Missing bios");
|
|
1852
|
+
}
|
|
1853
|
+
get exposedNode() {
|
|
1854
|
+
return this.stackManager.getStack("osPubSubNetworkStack")?.exposedNode;
|
|
1855
|
+
}
|
|
1856
|
+
get exposedNodeOuter() {
|
|
1857
|
+
return this.stackManager.getStack("osPubSubNetworkStack")?.exposedNodeOuter;
|
|
1858
|
+
}
|
|
1859
|
+
get kernel() {
|
|
1860
|
+
return assertEx11(this.params.kernel, () => "Missing kernel");
|
|
1861
|
+
}
|
|
1862
|
+
get locator() {
|
|
1863
|
+
return this._locator;
|
|
1864
|
+
}
|
|
1865
|
+
get stacks() {
|
|
1866
|
+
return this.stackManager.stacks;
|
|
1867
|
+
}
|
|
1868
|
+
get user() {
|
|
1869
|
+
return { signers: this.signers?.getWalletKindSigner("user") };
|
|
1870
|
+
}
|
|
1871
|
+
static async monitor(fn, eventConfig) {
|
|
1872
|
+
const { name, additionalProperties } = eventConfig;
|
|
1873
|
+
const monitor = this.monitoring;
|
|
1874
|
+
monitor?.startTimer(name);
|
|
1875
|
+
const result = await fn();
|
|
1876
|
+
monitor?.stopTimer({ additionalProperties, name });
|
|
1877
|
+
return result;
|
|
1878
|
+
}
|
|
1879
|
+
async boot(wallet, locator = new ModuleFactoryLocator6()) {
|
|
1880
|
+
console.warn("XyOs:boot", wallet.address);
|
|
1881
|
+
const fullLocator = this._locator.merge(locator);
|
|
1882
|
+
return await this._bootMutex.runExclusive(async () => {
|
|
1883
|
+
await this.eventBus.start();
|
|
1884
|
+
if (this.kernel?.status === "created") {
|
|
1885
|
+
await this.kernel.boot(await boot(), { locator: fullLocator, kernelDrivers: [] });
|
|
1886
|
+
}
|
|
1887
|
+
if (this.kernel?.status !== "booted") {
|
|
1888
|
+
throw new Error("Kernel not booted");
|
|
1889
|
+
}
|
|
1890
|
+
assertEx11(this._root === void 0, () => "XyOs already booted");
|
|
1891
|
+
const [root] = await _XyOs.monitor(async () => await loadOsNode(wallet, fullLocator), { name: "Load XyOs" });
|
|
1892
|
+
this._root = root;
|
|
1893
|
+
this.stackManager.initialize(this);
|
|
1894
|
+
if (this.signers) await this.signers.initialize();
|
|
1895
|
+
return this;
|
|
1896
|
+
});
|
|
1897
|
+
}
|
|
1898
|
+
buildDapp(manifest, dappId = NameTransforms.slug(manifest.nodes[0]?.config.name), name = NameTransforms.moduleName(manifest.nodes[0]?.config.name)) {
|
|
1899
|
+
return this.dappRegistrationService.buildDapp(manifest, dappId, name);
|
|
1900
|
+
}
|
|
1901
|
+
dappByName(dappId) {
|
|
1902
|
+
return this.dappRegistrationService.builtDapps[dappId];
|
|
1903
|
+
}
|
|
1904
|
+
getDappParams(dappId) {
|
|
1905
|
+
return this.dappRegistrationService.getParamsForRegisteredDapp(dappId);
|
|
1906
|
+
}
|
|
1907
|
+
getStack(stackName) {
|
|
1908
|
+
return assertEx11(this.stackManager.getStack(stackName), () => `Stack not found: ${stackName}`);
|
|
1909
|
+
}
|
|
1910
|
+
async monitor(fn, eventConfig) {
|
|
1911
|
+
return await _XyOs.monitor(fn, eventConfig);
|
|
1912
|
+
}
|
|
1913
|
+
shutdown() {
|
|
1914
|
+
assertEx11(this._root !== void 0, () => "XyOs not booted");
|
|
1915
|
+
this._root = void 0;
|
|
1916
|
+
this.stackManager.stop();
|
|
1917
|
+
}
|
|
1918
|
+
};
|
|
1919
|
+
|
|
1920
|
+
// src/scripts/xyos/lib/headless.ts
|
|
1921
|
+
var { terminal } = tk;
|
|
1922
|
+
var terminate = () => {
|
|
1923
|
+
terminal.grabInput(false);
|
|
1924
|
+
setTimeout(function() {
|
|
1925
|
+
process.exit(0);
|
|
1926
|
+
}, 100);
|
|
1927
|
+
};
|
|
1928
|
+
var headless = async ({
|
|
1929
|
+
manifest,
|
|
1930
|
+
config,
|
|
1931
|
+
kernelDrivers
|
|
1932
|
+
} = {}) => {
|
|
1933
|
+
console.log(chalk.green("Starting Headless xyOS..."));
|
|
1934
|
+
const configExplorer = cosmiconfig("xyos", { cache: true, loaders: { ".ts": TypeScriptLoader() } });
|
|
1935
|
+
const configResult = await (config ? configExplorer.load(config) : configExplorer.search());
|
|
1936
|
+
const xyosConfig = configResult?.config ?? {};
|
|
1937
|
+
const manifestToLoad = manifest ?? (typeof xyosConfig.manifest === "string" ? xyosConfig.manifest : void 0);
|
|
1938
|
+
const manifestObject = manifestToLoad ? JSON.parse(fs.readFileSync(manifestToLoad, "utf8")) : typeof xyosConfig.manifest === "object" ? xyosConfig.manifest : void 0;
|
|
1939
|
+
const osWallet = await HDWallet5.random();
|
|
1940
|
+
const kernel = new Kernel2({ logColor: "cyan", logger: console });
|
|
1941
|
+
await kernel.boot(await boot2(), { kernelDrivers });
|
|
1942
|
+
const xyOs = new XyOs({
|
|
1943
|
+
kernel,
|
|
1944
|
+
stackMap: {},
|
|
1945
|
+
manifest: manifestObject,
|
|
1946
|
+
developmentMode: xyosConfig.developmentMode
|
|
1947
|
+
});
|
|
1948
|
+
await xyOs.boot(osWallet);
|
|
1949
|
+
console.log(chalk.green("Started Headless xyOS..."));
|
|
1950
|
+
terminal.grabInput({ mouse: "button" });
|
|
1951
|
+
terminal.on("key", function(name) {
|
|
1952
|
+
console.log("'key' event:", name);
|
|
1953
|
+
if (name === "CTRL_C") {
|
|
1954
|
+
terminate();
|
|
1955
|
+
}
|
|
1956
|
+
});
|
|
1957
|
+
};
|
|
1958
|
+
|
|
1959
|
+
// src/scripts/xyos/command/create.ts
|
|
1960
|
+
var commandCreate = (argv) => {
|
|
1961
|
+
return argv.command("create [template] <target>", "Create an xyos project", (yargs2) => {
|
|
1962
|
+
return yargs2.positional("template", {
|
|
1963
|
+
choices: ["react", "headless", "dapp", "diviner", "witness"],
|
|
1964
|
+
description: "Template to use",
|
|
1965
|
+
type: "string"
|
|
1966
|
+
}).positional("target", {
|
|
1967
|
+
description: "Location into which to create the template project",
|
|
1968
|
+
type: "string"
|
|
1969
|
+
});
|
|
1970
|
+
}, async ({ template, target }) => {
|
|
1971
|
+
console.log(`Using template ${template} at location ${target}`);
|
|
1972
|
+
return await createFromTemplate({ target, template });
|
|
1973
|
+
});
|
|
1974
|
+
};
|
|
1975
|
+
|
|
1976
|
+
// src/scripts/xyos/command/manifest.ts
|
|
1977
|
+
var commandManifest = (argv) => {
|
|
1978
|
+
return argv.command("manifest [action] <target>", "Create an xyos project", (yargs2) => {
|
|
1979
|
+
return yargs2.positional("action", {
|
|
1980
|
+
choices: ["create", "validate", "display"],
|
|
1981
|
+
description: "Action to take on manifest",
|
|
1982
|
+
type: "string"
|
|
1983
|
+
}).positional("target", {
|
|
1984
|
+
description: "Location of manifest file",
|
|
1985
|
+
type: "string"
|
|
1986
|
+
});
|
|
1987
|
+
}, async ({ action, target }) => {
|
|
1988
|
+
console.log(`Taking action [${action}] on manifest at ${target}`);
|
|
1989
|
+
return await Promise.resolve();
|
|
1990
|
+
});
|
|
1991
|
+
};
|
|
1992
|
+
|
|
1993
|
+
// src/scripts/xyos/command/start.ts
|
|
1994
|
+
var commandStart = (argv) => {
|
|
1995
|
+
return argv.command("start", "Start xyOS in headless mode", (yargs2) => {
|
|
1996
|
+
return yargs2.option("config", {
|
|
1997
|
+
alias: "c",
|
|
1998
|
+
description: "Config file to use",
|
|
1999
|
+
type: "string"
|
|
2000
|
+
}).option("manifest", {
|
|
2001
|
+
alias: "m",
|
|
2002
|
+
description: "Manifest file to use",
|
|
2003
|
+
type: "string"
|
|
2004
|
+
}).option("kernelDriver", {
|
|
2005
|
+
alias: "k",
|
|
2006
|
+
description: "Kernel driver to load",
|
|
2007
|
+
type: "string"
|
|
2008
|
+
});
|
|
2009
|
+
}, async ({
|
|
2010
|
+
config,
|
|
2011
|
+
manifest,
|
|
2012
|
+
kernelDriver
|
|
2013
|
+
}) => {
|
|
2014
|
+
if (config) {
|
|
2015
|
+
console.log(`Using config: ${config}`);
|
|
2016
|
+
}
|
|
2017
|
+
if (config) {
|
|
2018
|
+
console.log(`Using manifest: ${manifest}`);
|
|
2019
|
+
}
|
|
2020
|
+
await headless({
|
|
2021
|
+
manifest,
|
|
2022
|
+
config,
|
|
2023
|
+
kernelDrivers: kernelDriver ? [kernelDriver] : []
|
|
2024
|
+
});
|
|
2025
|
+
});
|
|
2026
|
+
};
|
|
2027
|
+
|
|
2028
|
+
// src/scripts/xyos/index.ts
|
|
2029
|
+
commandManifest(
|
|
2030
|
+
commandConfig(
|
|
2031
|
+
commandCreate(
|
|
2032
|
+
commandStart(
|
|
2033
|
+
yargs(
|
|
2034
|
+
hideBin(
|
|
2035
|
+
process.argv
|
|
2036
|
+
)
|
|
2037
|
+
)
|
|
2038
|
+
)
|
|
2039
|
+
)
|
|
2040
|
+
)
|
|
2041
|
+
).usage("Usage: $0 <command> [options]").scriptName("xyos").demandCommand(1).parse().catch(
|
|
2042
|
+
console.error
|
|
2043
|
+
);
|
|
2044
|
+
//# sourceMappingURL=index.mjs.map
|