@xyo-network/os-runtime 7.2.1 → 7.3.0
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.map +1 -1
- package/dist/neutral/DappCallerBase.d.ts +2 -2
- package/dist/neutral/OsCallerBase.d.ts +2 -2
- package/dist/neutral/RunningDappCache.d.ts.map +1 -1
- package/dist/neutral/XyOs.d.ts +4 -5
- package/dist/neutral/XyOs.d.ts.map +1 -1
- package/dist/neutral/XyOsBase.d.ts +122 -3
- package/dist/neutral/XyOsBase.d.ts.map +1 -1
- package/dist/neutral/XyOsDapp.d.ts +3 -3
- package/dist/neutral/XyOsDapp.d.ts.map +1 -1
- package/dist/neutral/access/Caller.d.ts +1 -1
- package/dist/neutral/access/Caller.d.ts.map +1 -1
- package/dist/neutral/access/RunningAccessDappCache.d.ts.map +1 -1
- package/dist/neutral/access/interfaces/registered-names/helpers/resource/AbstractXnsCaller.d.ts +1 -1
- package/dist/neutral/adapter/Base.d.ts.map +1 -1
- package/dist/neutral/classes/lib/DappCreatorParams.d.ts +3 -3
- package/dist/neutral/classes/lib/DappCreatorParams.d.ts.map +1 -1
- package/dist/neutral/classes/lib/Insertable.d.ts +1 -3
- package/dist/neutral/classes/lib/Insertable.d.ts.map +1 -1
- package/dist/neutral/classes/settings/CallerBase.d.ts +1 -1
- package/dist/neutral/classes/settings/SettingsQueries.d.ts.map +1 -1
- package/dist/neutral/dapp/context/creator/Creator.d.ts +1 -1
- package/dist/neutral/dapp/context/creator/Creator.d.ts.map +1 -1
- package/dist/neutral/dapp/context/creator/createDappContext.d.ts.map +1 -1
- package/dist/neutral/event/bus/EventBus.d.ts +1 -1
- package/dist/neutral/event/bus/EventBus.d.ts.map +1 -1
- package/dist/neutral/helpers/monitor/XyOsMonitor.d.ts +2 -2
- package/dist/neutral/helpers/monitor/XyOsMonitor.d.ts.map +1 -1
- package/dist/neutral/helpers/monitor/types.d.ts +2 -2
- package/dist/neutral/helpers/monitor/types.d.ts.map +1 -1
- package/dist/neutral/index.mjs +42 -36
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/neutral/lib/Listener.d.ts +1 -1
- package/dist/neutral/lib/Listener.d.ts.map +1 -1
- package/dist/neutral/loadOsNode.d.ts.map +1 -1
- package/dist/neutral/profileModuleEvents.d.ts +1 -3
- package/dist/neutral/profileModuleEvents.d.ts.map +1 -1
- package/dist/neutral/registration/DappRegistrationService.d.ts +3 -3
- package/dist/neutral/registration/DappRegistrationService.d.ts.map +1 -1
- package/dist/neutral/registration/DappRegistry.d.ts.map +1 -1
- package/dist/neutral/registration/ValidateDappAccessDiviner/Config.d.ts +1 -1
- package/dist/neutral/registration/ValidateDappAccessDiviner/Config.d.ts.map +1 -1
- package/dist/neutral/scripts/xyos/lib/headless.d.ts.map +1 -1
- package/dist/neutral/signer/Signers.d.ts.map +1 -1
- package/dist/neutral/stack/Manager.d.ts +2 -6
- package/dist/neutral/stack/Manager.d.ts.map +1 -1
- package/dist/neutral/system/ManageSystemDapps.d.ts +2 -2
- package/dist/neutral/system/ManageSystemDapps.d.ts.map +1 -1
- package/dist/node/Caller.d.ts.map +1 -1
- package/dist/node/DappCallerBase.d.ts +2 -2
- package/dist/node/OsCallerBase.d.ts +2 -2
- package/dist/node/RunningDappCache.d.ts.map +1 -1
- package/dist/node/XyOs.d.ts +4 -5
- package/dist/node/XyOs.d.ts.map +1 -1
- package/dist/node/XyOsBase.d.ts +122 -3
- package/dist/node/XyOsBase.d.ts.map +1 -1
- package/dist/node/XyOsDapp.d.ts +3 -3
- package/dist/node/XyOsDapp.d.ts.map +1 -1
- package/dist/node/access/Caller.d.ts +1 -1
- package/dist/node/access/Caller.d.ts.map +1 -1
- package/dist/node/access/RunningAccessDappCache.d.ts.map +1 -1
- package/dist/node/access/interfaces/registered-names/helpers/resource/AbstractXnsCaller.d.ts +1 -1
- package/dist/node/adapter/Base.d.ts.map +1 -1
- package/dist/node/classes/lib/DappCreatorParams.d.ts +3 -3
- package/dist/node/classes/lib/DappCreatorParams.d.ts.map +1 -1
- package/dist/node/classes/lib/Insertable.d.ts +1 -3
- package/dist/node/classes/lib/Insertable.d.ts.map +1 -1
- package/dist/node/classes/settings/CallerBase.d.ts +1 -1
- package/dist/node/classes/settings/SettingsQueries.d.ts.map +1 -1
- package/dist/node/dapp/context/creator/Creator.d.ts +1 -1
- package/dist/node/dapp/context/creator/Creator.d.ts.map +1 -1
- package/dist/node/dapp/context/creator/createDappContext.d.ts.map +1 -1
- package/dist/node/event/bus/EventBus.d.ts +1 -1
- package/dist/node/event/bus/EventBus.d.ts.map +1 -1
- package/dist/node/helpers/monitor/XyOsMonitor.d.ts +2 -2
- package/dist/node/helpers/monitor/XyOsMonitor.d.ts.map +1 -1
- package/dist/node/helpers/monitor/types.d.ts +2 -2
- package/dist/node/helpers/monitor/types.d.ts.map +1 -1
- package/dist/node/index.mjs +42 -36
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/lib/Listener.d.ts +1 -1
- package/dist/node/lib/Listener.d.ts.map +1 -1
- package/dist/node/loadOsNode.d.ts.map +1 -1
- package/dist/node/profileModuleEvents.d.ts +1 -3
- package/dist/node/profileModuleEvents.d.ts.map +1 -1
- package/dist/node/registration/DappRegistrationService.d.ts +3 -3
- package/dist/node/registration/DappRegistrationService.d.ts.map +1 -1
- package/dist/node/registration/DappRegistry.d.ts.map +1 -1
- package/dist/node/registration/ValidateDappAccessDiviner/Config.d.ts +1 -1
- package/dist/node/registration/ValidateDappAccessDiviner/Config.d.ts.map +1 -1
- package/dist/node/scripts/xyos/index.mjs +27 -24
- package/dist/node/scripts/xyos/index.mjs.map +1 -1
- package/dist/node/scripts/xyos/lib/headless.d.ts.map +1 -1
- package/dist/node/signer/Signers.d.ts.map +1 -1
- package/dist/node/stack/Manager.d.ts +2 -6
- package/dist/node/stack/Manager.d.ts.map +1 -1
- package/dist/node/system/ManageSystemDapps.d.ts +2 -2
- package/dist/node/system/ManageSystemDapps.d.ts.map +1 -1
- package/package.json +166 -49
- package/dist/neutral/signer/Signer.spec.d.ts +0 -2
- package/dist/neutral/signer/Signer.spec.d.ts.map +0 -1
- package/dist/neutral/spec/boot.spec.d.ts +0 -2
- package/dist/neutral/spec/boot.spec.d.ts.map +0 -1
- package/dist/node/signer/Signer.spec.d.ts +0 -2
- package/dist/node/signer/Signer.spec.d.ts.map +0 -1
- package/dist/node/spec/boot.spec.d.ts +0 -2
- package/dist/node/spec/boot.spec.d.ts.map +0 -1
- package/src/Caller.ts +0 -200
- package/src/DappCallerBase.ts +0 -55
- package/src/DefaultsQueries.ts +0 -27
- package/src/OsCallerBase.ts +0 -59
- package/src/PubSubBridgeCaller.ts +0 -33
- package/src/RunningDappCache.ts +0 -58
- package/src/XyOs.ts +0 -166
- package/src/XyOsBase.ts +0 -135
- package/src/XyOsDapp.ts +0 -106
- package/src/access/Caller.ts +0 -85
- package/src/access/Queries.ts +0 -38
- package/src/access/Resource.ts +0 -65
- package/src/access/RunningAccessDappCache.ts +0 -21
- package/src/access/index.ts +0 -4
- package/src/access/interfaces/index.ts +0 -1
- package/src/access/interfaces/registered-names/helpers/AccessNodeQueries.ts +0 -68
- package/src/access/interfaces/registered-names/helpers/index.ts +0 -2
- package/src/access/interfaces/registered-names/helpers/resource/AbstractXnsCaller.ts +0 -42
- package/src/access/interfaces/registered-names/helpers/resource/RegistrationsResource.ts +0 -52
- package/src/access/interfaces/registered-names/helpers/resource/RegistrationsResourceQueries.ts +0 -23
- package/src/access/interfaces/registered-names/helpers/resource/index.ts +0 -3
- package/src/access/interfaces/registered-names/index.ts +0 -1
- package/src/adapter/Base.ts +0 -106
- package/src/adapter/Network.ts +0 -31
- package/src/adapter/Settings.ts +0 -30
- package/src/adapter/index.ts +0 -2
- package/src/adapters/OsPubSubBridgeNetwork.ts +0 -10
- package/src/adapters/OsSettings.ts +0 -7
- package/src/adapters/OsXyoPublicNetwork.ts +0 -9
- package/src/adapters/index.ts +0 -3
- package/src/classes/dapp/DefaultsResource.ts +0 -67
- package/src/classes/dapp/index.ts +0 -1
- package/src/classes/index.ts +0 -4
- package/src/classes/lib/DappCreatorParams.ts +0 -18
- package/src/classes/lib/Insertable.ts +0 -10
- package/src/classes/lib/index.ts +0 -2
- package/src/classes/menu/Caller.ts +0 -76
- package/src/classes/menu/Queries.ts +0 -60
- package/src/classes/menu/Resource.ts +0 -105
- package/src/classes/menu/index.ts +0 -2
- package/src/classes/settings/Caller.ts +0 -78
- package/src/classes/settings/CallerBase.ts +0 -27
- package/src/classes/settings/Resource.ts +0 -81
- package/src/classes/settings/SettingsQueries.ts +0 -56
- package/src/classes/settings/badge/Caller.ts +0 -30
- package/src/classes/settings/badge/Queries.ts +0 -19
- package/src/classes/settings/badge/Resource.ts +0 -50
- package/src/classes/settings/badge/index.ts +0 -2
- package/src/classes/settings/index.ts +0 -5
- package/src/dapp/context/creator/Creator.ts +0 -122
- package/src/dapp/context/creator/DefaultPayloads/DappAccessPayloads.ts +0 -20
- package/src/dapp/context/creator/DefaultPayloads/DefaultPayloads.ts +0 -40
- package/src/dapp/context/creator/DefaultPayloads/NodeInfoPayload.ts +0 -33
- package/src/dapp/context/creator/DefaultPayloads/index.ts +0 -1
- package/src/dapp/context/creator/ExternalModulePermissions/ExternalModulePermissions.ts +0 -59
- package/src/dapp/context/creator/ExternalModulePermissions/index.ts +0 -1
- package/src/dapp/context/creator/createDappContext.ts +0 -61
- package/src/dapp/context/creator/index.ts +0 -3
- package/src/dapp/context/index.ts +0 -1
- package/src/dapp/index.ts +0 -1
- package/src/event/bus/Connection.ts +0 -31
- package/src/event/bus/EventBus.ts +0 -160
- package/src/event/bus/PubSubConnection.ts +0 -28
- package/src/event/bus/index.ts +0 -3
- package/src/event/connections/DappAccessRequest.ts +0 -11
- package/src/event/connections/DappsReady.ts +0 -9
- package/src/event/connections/ExposeDappRequest.ts +0 -11
- package/src/event/connections/OsPubSubNetworkReady.ts +0 -12
- package/src/event/connections/OsSettingsReady.ts +0 -12
- package/src/event/connections/OsXyoPublicReady.ts +0 -12
- package/src/event/connections/index.ts +0 -6
- package/src/event/index.ts +0 -2
- package/src/helpers/index.ts +0 -1
- package/src/helpers/monitor/XyOsMonitor.ts +0 -52
- package/src/helpers/monitor/index.ts +0 -2
- package/src/helpers/monitor/types.ts +0 -8
- package/src/index.ts +0 -29
- package/src/initializer/DappInitializer.ts +0 -57
- package/src/initializer/index.ts +0 -1
- package/src/intent/Caller.ts +0 -74
- package/src/intent/Resource.ts +0 -66
- package/src/intent/index.ts +0 -2
- package/src/lib/ExternalStore.ts +0 -7
- package/src/lib/Listener.ts +0 -1
- package/src/lib/ModuleAccountPaths.ts +0 -23
- package/src/lib/ModuleNames.ts +0 -3
- package/src/lib/NameTransforms.ts +0 -34
- package/src/lib/PayloadStore.ts +0 -105
- package/src/lib/ResourceStores.ts +0 -7
- package/src/lib/index.ts +0 -11
- package/src/lib/initializeXns.ts +0 -16
- package/src/lib/isEqual.ts +0 -42
- package/src/lib/isPayload.ts +0 -24
- package/src/lib/tokenPlacesSplit.ts +0 -17
- package/src/loadOsNode.ts +0 -44
- package/src/manifest/index.ts +0 -2
- package/src/manifest/manifestReplacementTokens.ts +0 -6
- package/src/manifest/os-node.manifest.json +0 -132
- package/src/manifests/dapp-window.manifest.json +0 -36
- package/src/manifests/index.ts +0 -1
- package/src/models/access/ValidDappAccessInterfaces.ts +0 -6
- package/src/models/access/index.ts +0 -1
- package/src/models/index.ts +0 -1
- package/src/profileModuleEvents.ts +0 -43
- package/src/registration/DappRegistrationService.ts +0 -180
- package/src/registration/DappRegistry.ts +0 -129
- package/src/registration/ValidateDappAccessDiviner/Config.ts +0 -24
- package/src/registration/ValidateDappAccessDiviner/Diviner.ts +0 -133
- package/src/registration/ValidateDappAccessDiviner/index.ts +0 -2
- package/src/registration/index.ts +0 -2
- package/src/scripts/xyos/command/config.ts +0 -19
- package/src/scripts/xyos/command/create.ts +0 -22
- package/src/scripts/xyos/command/index.ts +0 -7
- package/src/scripts/xyos/command/manifest.ts +0 -19
- package/src/scripts/xyos/command/start.ts +0 -35
- package/src/scripts/xyos/index.ts +0 -31
- package/src/scripts/xyos/lib/createFromTemplate.ts +0 -11
- package/src/scripts/xyos/lib/headless.ts +0 -68
- package/src/scripts/xyos/lib/index.ts +0 -2
- package/src/signer/Signer.spec.ts +0 -65
- package/src/signer/Signers.ts +0 -74
- package/src/signer/index.ts +0 -1
- package/src/spec/boot.spec.ts +0 -89
- package/src/stack/Base.ts +0 -165
- package/src/stack/Manager.ts +0 -51
- package/src/stack/Map.ts +0 -22
- package/src/stack/OsPubSubNetworkStack.ts +0 -70
- package/src/stack/OsSettingsStack.ts +0 -24
- package/src/stack/XyoPublicNetworkStack.ts +0 -32
- package/src/stack/index.ts +0 -6
- package/src/system/ManageSystemDapps.ts +0 -148
- package/src/system/Queries.ts +0 -69
- package/src/system/index.ts +0 -1
- package/src/types/global.d.ts +0 -9
- package/src/types/images.d.ts +0 -5
- package/src/utils/buildWalletSeedPhrasePayload.ts +0 -51
- package/src/utils/getApiDomain.ts +0 -14
- package/src/utils/index.ts +0 -3
- package/src/utils/renameObjKey.ts +0 -22
- package/src/wallet/DappSeedPhraseRepository.ts +0 -99
- package/src/wallet/SeedPhraseRepository.ts +0 -31
- package/src/wallet/index.ts +0 -2
package/src/OsCallerBase.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { assertEx } from '@xylabs/sdk-js'
|
|
2
|
-
import { asArchivistInstance } from '@xyo-network/archivist-model'
|
|
3
|
-
import { asDivinerInstance } from '@xyo-network/diviner-model'
|
|
4
|
-
import type { XyOsContext } from '@xyo-network/os-model'
|
|
5
|
-
|
|
6
|
-
export const DappsArchivistModuleName = 'DappsArchivist'
|
|
7
|
-
export const DappsArchivistDevelopmentModuleName = `${DappsArchivistModuleName}Development`
|
|
8
|
-
export const DappsArchivistPayloadDivinerModuleName = 'DappsArchivistPayloadDiviner'
|
|
9
|
-
export const DappsArchivistPayloadDevelopmentDivinerModuleName = `${DappsArchivistPayloadDivinerModuleName}Development`
|
|
10
|
-
export const RegisteredDappInterfacesArchivistModuleName = 'RegisteredDappInterfacesArchivist'
|
|
11
|
-
|
|
12
|
-
export class OsCallerBase {
|
|
13
|
-
protected context: XyOsContext
|
|
14
|
-
constructor(context: XyOsContext) {
|
|
15
|
-
this.context = context
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// Get the dapps archivist
|
|
19
|
-
async getDappsArchivist() {
|
|
20
|
-
const mod = assertEx(await this.context.root.resolve(DappsArchivistModuleName), () => `${DappsArchivistModuleName} not found`)
|
|
21
|
-
return asArchivistInstance(mod, () => `${DappsArchivistModuleName} is not an archivist`, { required: true })
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// Get the dapps archivist development
|
|
25
|
-
async getDappsArchivistDevelopment() {
|
|
26
|
-
const mod = assertEx(
|
|
27
|
-
await this.context.root.resolve(DappsArchivistDevelopmentModuleName),
|
|
28
|
-
() => `${DappsArchivistDevelopmentModuleName} not found`,
|
|
29
|
-
)
|
|
30
|
-
return asArchivistInstance(mod, () => `${DappsArchivistDevelopmentModuleName} is not an archivist`, { required: true })
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// Get the dapps archivist payload diviner
|
|
34
|
-
async getDappsArchivistPayloadDiviner() {
|
|
35
|
-
const mod = assertEx(
|
|
36
|
-
await this.context.root.resolve(DappsArchivistPayloadDivinerModuleName),
|
|
37
|
-
() => `${DappsArchivistPayloadDivinerModuleName} not found`,
|
|
38
|
-
)
|
|
39
|
-
return asDivinerInstance(mod, () => `${DappsArchivistPayloadDivinerModuleName} is not a diviner`, { required: true })
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Get the dapps archivist payload diviner development
|
|
43
|
-
async getDappsArchivistPayloadDivinerDevelopment() {
|
|
44
|
-
const mod = assertEx(
|
|
45
|
-
await this.context.root.resolve(DappsArchivistPayloadDevelopmentDivinerModuleName),
|
|
46
|
-
() => `${DappsArchivistPayloadDevelopmentDivinerModuleName} not found`,
|
|
47
|
-
)
|
|
48
|
-
return asDivinerInstance(mod, () => `${DappsArchivistPayloadDevelopmentDivinerModuleName} is not a diviner`, { required: true })
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// Get the registered dapp interfaces archivist
|
|
52
|
-
async getRegisteredDappInterfacesArchivist() {
|
|
53
|
-
const mod = assertEx(
|
|
54
|
-
await this.context.root.resolve(RegisteredDappInterfacesArchivistModuleName),
|
|
55
|
-
() => `${RegisteredDappInterfacesArchivistModuleName} not found`,
|
|
56
|
-
)
|
|
57
|
-
return asArchivistInstance(mod, () => `${RegisteredDappInterfacesArchivistModuleName} is not an archivist`, { required: true })
|
|
58
|
-
}
|
|
59
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { Address } from '@xylabs/sdk-js'
|
|
2
|
-
import { assertEx } from '@xylabs/sdk-js'
|
|
3
|
-
import type { BridgeExposeOptions } from '@xyo-network/bridge-model'
|
|
4
|
-
import { asBridgeInstance } from '@xyo-network/bridge-model'
|
|
5
|
-
import type { NodeInstance } from '@xyo-network/node-model'
|
|
6
|
-
import { BridgedPubSubModuleName } from '@xyo-network/os-model'
|
|
7
|
-
|
|
8
|
-
export class PubSubBridgeCaller {
|
|
9
|
-
private node: NodeInstance
|
|
10
|
-
constructor(node: NodeInstance) {
|
|
11
|
-
this.node = node
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
async exposeAddresses(addresses: Address[], options?: BridgeExposeOptions) {
|
|
15
|
-
const pubSubBridge = await this.getPubSubBridge()
|
|
16
|
-
for (const address of addresses) {
|
|
17
|
-
console.log(`Exposing: ${address}`)
|
|
18
|
-
await pubSubBridge.expose(address, options)
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
async unExposeAddresses(addresses: Address[]) {
|
|
23
|
-
const pubSubBridge = await this.getPubSubBridge()
|
|
24
|
-
for (const address of addresses) {
|
|
25
|
-
await pubSubBridge.unexpose?.(address)
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
private async getPubSubBridge() {
|
|
30
|
-
const mod = assertEx(await this.node.resolve(BridgedPubSubModuleName), () => `${BridgedPubSubModuleName} not found`)
|
|
31
|
-
return asBridgeInstance(mod, () => `${BridgedPubSubModuleName} is not a bridge`, { required: true })
|
|
32
|
-
}
|
|
33
|
-
}
|
package/src/RunningDappCache.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { assertEx } from '@xylabs/sdk-js'
|
|
2
|
-
import type {
|
|
3
|
-
DappId, RegisteredDapp, WindowDappNodeSet, XyOsContext,
|
|
4
|
-
} from '@xyo-network/os-model'
|
|
5
|
-
import { Mutex } from 'async-mutex'
|
|
6
|
-
|
|
7
|
-
import { createDappContext, DappContextCreator } from './dapp/index.ts'
|
|
8
|
-
import { XyOs } from './XyOs.ts'
|
|
9
|
-
|
|
10
|
-
const findOrCreateMutex = new Mutex()
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* A cache for running node instances
|
|
14
|
-
*/
|
|
15
|
-
export class RunningDappCache {
|
|
16
|
-
private static _cache: { [key: DappId]: WindowDappNodeSet } = {}
|
|
17
|
-
|
|
18
|
-
static async findOrCreate(
|
|
19
|
-
dapp: RegisteredDapp,
|
|
20
|
-
xyOs: XyOsContext,
|
|
21
|
-
allowedNames: string[],
|
|
22
|
-
xnsNodeUrl: string | undefined,
|
|
23
|
-
xnsNetwork: string | undefined,
|
|
24
|
-
): Promise<WindowDappNodeSet> {
|
|
25
|
-
const dappId = dapp.config.name
|
|
26
|
-
|
|
27
|
-
return await XyOs.monitor<WindowDappNodeSet>(
|
|
28
|
-
async () =>
|
|
29
|
-
await findOrCreateMutex.runExclusive(async () => {
|
|
30
|
-
const existingWindowDappSet = RunningDappCache.get(dappId)
|
|
31
|
-
if (existingWindowDappSet) {
|
|
32
|
-
console.debug('[DEBUG]', `RunningDappCache, using existing node for ${dappId}`)
|
|
33
|
-
const existingDappContext = assertEx(existingWindowDappSet.context, () => 'No context found in existing dapp node')
|
|
34
|
-
await DappContextCreator.primeDappArchivist(existingDappContext, xyOs, dappId)
|
|
35
|
-
return existingWindowDappSet
|
|
36
|
-
}
|
|
37
|
-
console.debug('[DEBUG]', 'RunningDappCache:creating', dappId)
|
|
38
|
-
const windowDappSet = await createDappContext(dapp, xyOs, allowedNames, xnsNodeUrl, xnsNetwork)
|
|
39
|
-
RunningDappCache.set(dappId, windowDappSet)
|
|
40
|
-
|
|
41
|
-
return windowDappSet
|
|
42
|
-
}),
|
|
43
|
-
{ additionalProperties: { dappId }, name: 'Loading dApp' },
|
|
44
|
-
)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
static get(key: DappId): WindowDappNodeSet | undefined {
|
|
48
|
-
return this._cache[key]
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
static has(key?: DappId) {
|
|
52
|
-
return key ? !!this._cache[key] : false
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
static set(key: DappId, value: WindowDappNodeSet) {
|
|
56
|
-
this._cache[key] = value
|
|
57
|
-
}
|
|
58
|
-
}
|
package/src/XyOs.ts
DELETED
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import type { Promisable } from '@xylabs/sdk-js'
|
|
2
|
-
import { assertEx } from '@xylabs/sdk-js'
|
|
3
|
-
import { boot } from '@xyo-network/bios'
|
|
4
|
-
import { Kernel } from '@xyo-network/kernel'
|
|
5
|
-
import type { KernelExternal } from '@xyo-network/kernel-model'
|
|
6
|
-
import type { PackageManifest } from '@xyo-network/manifest'
|
|
7
|
-
import { ModuleFactoryLocator } from '@xyo-network/module-factory-locator'
|
|
8
|
-
import type { ModuleFactoryLocatorInstance } from '@xyo-network/module-model'
|
|
9
|
-
import type { NodeInstance } from '@xyo-network/node-model'
|
|
10
|
-
import type {
|
|
11
|
-
DappId,
|
|
12
|
-
DappPackageManifestPayload,
|
|
13
|
-
DappParams,
|
|
14
|
-
SignersExternal,
|
|
15
|
-
StackInitializer,
|
|
16
|
-
XyOsContext,
|
|
17
|
-
XyOsDappContext,
|
|
18
|
-
XyOsGlobal,
|
|
19
|
-
} from '@xyo-network/os-model'
|
|
20
|
-
import type { WalletInstance } from '@xyo-network/wallet-model'
|
|
21
|
-
|
|
22
|
-
import { EventBus } from './event/index.ts'
|
|
23
|
-
import type { MonitorEventConfig, XyOsMonitor } from './helpers/index.ts'
|
|
24
|
-
import { NameTransforms } from './lib/index.ts'
|
|
25
|
-
import { loadOsNode } from './loadOsNode.ts'
|
|
26
|
-
import type { DappRegistrationServiceParams } from './registration/index.ts'
|
|
27
|
-
import { DappRegistrationService } from './registration/index.ts'
|
|
28
|
-
import { Signers } from './signer/index.ts'
|
|
29
|
-
import type { OsPubSubNetworkStack, UninitializedStackMap } from './stack/index.ts'
|
|
30
|
-
import { OsStackMap, StackManager } from './stack/index.ts'
|
|
31
|
-
import type { XyOsContextParams } from './XyOsBase.ts'
|
|
32
|
-
import { XyOsContextBase } from './XyOsBase.ts'
|
|
33
|
-
|
|
34
|
-
export interface XyOsParams<TManifest extends PackageManifest = PackageManifest> extends XyOsContextParams<TManifest> {
|
|
35
|
-
dappsConfiguration?: DappRegistrationServiceParams
|
|
36
|
-
developmentMode?: boolean
|
|
37
|
-
kernel?: XyOsContext['kernel']
|
|
38
|
-
stackMap?: UninitializedStackMap
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export class XyOs extends XyOsContextBase<XyOsParams> implements XyOsContext {
|
|
42
|
-
protected _exposedNode: NodeInstance | undefined
|
|
43
|
-
protected _exposedNodeOuter: NodeInstance | undefined
|
|
44
|
-
protected _kernel: KernelExternal
|
|
45
|
-
protected _locator: ModuleFactoryLocatorInstance
|
|
46
|
-
protected dappRegistrationService: DappRegistrationService
|
|
47
|
-
protected signers: SignersExternal | undefined
|
|
48
|
-
private stackManager: StackManager
|
|
49
|
-
|
|
50
|
-
constructor({
|
|
51
|
-
logger = console,
|
|
52
|
-
eventBus = new EventBus(),
|
|
53
|
-
kernel = new Kernel({ logger }),
|
|
54
|
-
locator = new ModuleFactoryLocator(),
|
|
55
|
-
dappsConfiguration,
|
|
56
|
-
developmentMode,
|
|
57
|
-
stackMap = OsStackMap,
|
|
58
|
-
...params
|
|
59
|
-
}: XyOsParams = {}) {
|
|
60
|
-
super({
|
|
61
|
-
eventBus, kernel, locator, ...params,
|
|
62
|
-
})
|
|
63
|
-
this._locator = locator
|
|
64
|
-
this._kernel = kernel
|
|
65
|
-
this.stackManager = new StackManager(stackMap)
|
|
66
|
-
this.dappRegistrationService = new DappRegistrationService(this, dappsConfiguration, this.locator, developmentMode)
|
|
67
|
-
if (this.signerPaths && this.kernel?.bios?.seedPhraseStore) this.signers = new Signers(this.signerPaths, this.kernel?.bios?.seedPhraseStore)
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
static get monitoring(): XyOsMonitor | undefined {
|
|
71
|
-
return
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
static get xyOsGlobal(): XyOsGlobal {
|
|
75
|
-
return getXyOsGlobal()
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
override get bios(): KernelExternal['bios'] | undefined {
|
|
79
|
-
return assertEx(this.params.kernel?.bios, () => 'Missing bios')
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
override get exposedNode() {
|
|
83
|
-
return this.stackManager.getStack<OsPubSubNetworkStack>('osPubSubNetworkStack')?.exposedNode
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
override get exposedNodeOuter() {
|
|
87
|
-
return this.stackManager.getStack<OsPubSubNetworkStack>('osPubSubNetworkStack')?.exposedNodeOuter
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
override get kernel(): XyOsContext['kernel'] | undefined {
|
|
91
|
-
return assertEx(this.params.kernel, () => 'Missing kernel')
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
get locator() {
|
|
95
|
-
return this._locator
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
get stacks() {
|
|
99
|
-
return this.stackManager.stacks
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
override get user() {
|
|
103
|
-
return { signers: this.signers?.getWalletKindSigner('user') }
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
static async monitor<T>(fn: () => Promise<T>, eventConfig: MonitorEventConfig): Promise<T> {
|
|
107
|
-
const { name, additionalProperties } = eventConfig
|
|
108
|
-
const monitor = this.monitoring
|
|
109
|
-
monitor?.startTimer(name)
|
|
110
|
-
const result = await fn()
|
|
111
|
-
monitor?.stopTimer({ additionalProperties, name })
|
|
112
|
-
|
|
113
|
-
return result
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
override async boot(wallet: WalletInstance, locator: ModuleFactoryLocatorInstance = new ModuleFactoryLocator()) {
|
|
117
|
-
console.warn('XyOs:boot', wallet.address)
|
|
118
|
-
const fullLocator = this._locator.merge(locator)
|
|
119
|
-
return await this._bootMutex.runExclusive(async () => {
|
|
120
|
-
await this.eventBus.start()
|
|
121
|
-
if (this.kernel?.status === 'created') {
|
|
122
|
-
await this.kernel.boot(await boot(), { locator: fullLocator, kernelDrivers: [] })
|
|
123
|
-
}
|
|
124
|
-
if (this.kernel?.status !== 'booted') {
|
|
125
|
-
throw new Error('Kernel not booted')
|
|
126
|
-
}
|
|
127
|
-
assertEx(this._root === undefined, () => 'XyOs already booted')
|
|
128
|
-
const [root] = await XyOs.monitor(async () => await loadOsNode(wallet, fullLocator), { name: 'Load XyOs' })
|
|
129
|
-
this._root = root
|
|
130
|
-
|
|
131
|
-
this.stackManager.initialize(this)
|
|
132
|
-
if (this.signers) await this.signers.initialize()
|
|
133
|
-
return this
|
|
134
|
-
})
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
override buildDapp(
|
|
138
|
-
manifest: DappPackageManifestPayload,
|
|
139
|
-
dappId = NameTransforms.slug(manifest.nodes[0]?.config.name),
|
|
140
|
-
name = NameTransforms.moduleName(manifest.nodes[0]?.config.name),
|
|
141
|
-
): Promisable<XyOsDappContext> {
|
|
142
|
-
return this.dappRegistrationService.buildDapp(manifest, dappId, name)
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
override dappByName(dappId: DappId): Promisable<XyOsDappContext | undefined> {
|
|
146
|
-
return this.dappRegistrationService.builtDapps[dappId]
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
override getDappParams(dappId: DappId): DappParams {
|
|
150
|
-
return this.dappRegistrationService.getParamsForRegisteredDapp(dappId)
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
override getStack(stackName: string): StackInitializer {
|
|
154
|
-
return assertEx(this.stackManager.getStack(stackName), () => `Stack not found: ${stackName}`)
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
override async monitor<T>(fn: () => Promise<T>, eventConfig: MonitorEventConfig): Promise<T> {
|
|
158
|
-
return await XyOs.monitor<T>(fn, eventConfig)
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
override shutdown() {
|
|
162
|
-
assertEx(this._root !== undefined, () => 'XyOs not booted')
|
|
163
|
-
this._root = undefined
|
|
164
|
-
this.stackManager.stop()
|
|
165
|
-
}
|
|
166
|
-
}
|
package/src/XyOsBase.ts
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
BaseParams, JsonObject, Promisable,
|
|
3
|
-
} from '@xylabs/sdk-js'
|
|
4
|
-
import { assertEx, BaseEmitter } from '@xylabs/sdk-js'
|
|
5
|
-
import type { KernelExternal } from '@xyo-network/kernel-model'
|
|
6
|
-
import type { PackageManifest } from '@xyo-network/manifest'
|
|
7
|
-
import { ModuleFactoryLocator } from '@xyo-network/module-factory-locator'
|
|
8
|
-
import type { ModuleFactoryLocatorInstance } from '@xyo-network/module-model'
|
|
9
|
-
import type { NodeInstance } from '@xyo-network/node-model'
|
|
10
|
-
import type {
|
|
11
|
-
DappId, DappPackageManifestPayload, DappParams, EventBusInterface, OsUser,
|
|
12
|
-
StackInitializer, WalletKindSignerPaths, XyOsContext, XyOsDappContext,
|
|
13
|
-
} from '@xyo-network/os-model'
|
|
14
|
-
import type { WalletInstance } from '@xyo-network/wallet-model'
|
|
15
|
-
import { Mutex } from 'async-mutex'
|
|
16
|
-
|
|
17
|
-
export interface XyOsContextParams<TManifest extends PackageManifest = PackageManifest> extends BaseParams {
|
|
18
|
-
eventBus?: EventBusInterface
|
|
19
|
-
locator?: ModuleFactoryLocatorInstance
|
|
20
|
-
manifest?: TManifest
|
|
21
|
-
platformLocator?: ModuleFactoryLocator
|
|
22
|
-
signerPaths?: WalletKindSignerPaths
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export class XyOsContextBase<TParams extends XyOsContextParams | void = void> extends BaseEmitter<
|
|
26
|
-
TParams extends XyOsContextParams ? TParams : XyOsContextParams
|
|
27
|
-
> {
|
|
28
|
-
protected _bootMutex = new Mutex()
|
|
29
|
-
protected _platformLocator: ModuleFactoryLocator | undefined
|
|
30
|
-
protected _root: NodeInstance | undefined
|
|
31
|
-
|
|
32
|
-
get bios(): KernelExternal['bios'] | undefined {
|
|
33
|
-
return this.kernel?.bios
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
get eventBus(): XyOsContext['eventBus'] {
|
|
37
|
-
return assertEx(this.params.eventBus, () => 'Missing event bus')
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
get exposedNode(): NodeInstance | undefined {
|
|
41
|
-
throw new Error('Method not implemented. [exposedNode]')
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
get exposedNodeOuter(): NodeInstance | undefined {
|
|
45
|
-
throw new Error('Method not implemented. [exposedNodeOuter]')
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
get installedDapps(): DappId[] {
|
|
49
|
-
return []
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
get kernel(): XyOsContext['kernel'] | undefined {
|
|
53
|
-
return undefined
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
get manifest() {
|
|
57
|
-
return assertEx(this.params.manifest, () => 'Missing manifest')
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
get platformLocator(): ModuleFactoryLocator {
|
|
61
|
-
this._platformLocator = this._platformLocator ?? this.params.platformLocator ?? new ModuleFactoryLocator()
|
|
62
|
-
return this._platformLocator
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
get possibleRoot(): NodeInstance | undefined {
|
|
66
|
-
return this._root
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
get root(): NodeInstance {
|
|
70
|
-
return assertEx(this._root, () => 'XyOs root not set (probably not yet booted)')
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
get runningDapps(): DappId[] {
|
|
74
|
-
return []
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
get signerPaths() {
|
|
78
|
-
return this.params.signerPaths
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
get state() {
|
|
82
|
-
return this._root ? 'running' : 'stopped'
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
get user(): OsUser {
|
|
86
|
-
throw new Error('Method not implemented. [user]')
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
boot(_wallet: WalletInstance, _locator: ModuleFactoryLocator): Promisable<XyOsContext> {
|
|
90
|
-
throw new Error('Method not implemented. [boot]')
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
buildDapp(_manifest: DappPackageManifestPayload, _dappId?: DappId): Promisable<XyOsDappContext> {
|
|
94
|
-
throw new Error('Method not implemented. [buildDapp]')
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
dappByName(_dappId: DappId): Promisable<XyOsDappContext | undefined> {
|
|
98
|
-
throw new Error('Method not implemented. [runningDapp]')
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
getDappParams(_dappId: DappId): DappParams | undefined {
|
|
102
|
-
throw new Error('Method not implemented. [getDappParams]')
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
getStack(_stackName: string): StackInitializer {
|
|
106
|
-
throw new Error('Method not implemented. [getStack]')
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
installDapp(_dappId: DappId) {
|
|
110
|
-
throw new Error('Method not implemented. [installDapp]')
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
monitor<T>(_fn: () => Promise<T>, _eventConfig: {
|
|
114
|
-
additionalProperties?: JsonObject
|
|
115
|
-
name: string
|
|
116
|
-
}): Promise<T> {
|
|
117
|
-
throw new Error('Method not implemented. [monitor]')
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
shutdown() {
|
|
121
|
-
throw new Error('Method not implemented. [shutdown]')
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
startDapp(_dappId: DappId): Promisable<XyOsDappContext> {
|
|
125
|
-
throw new Error('Method not implemented. [startDapp]')
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
stopDapp(_dappId: DappId) {
|
|
129
|
-
throw new Error('Method not implemented. [stopDapp]')
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
uninstallDapp(_dappId: DappId) {
|
|
133
|
-
throw new Error('Method not implemented. [uninstallDapp]')
|
|
134
|
-
}
|
|
135
|
-
}
|
package/src/XyOsDapp.ts
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { assertEx } from '@xylabs/sdk-js'
|
|
2
|
-
import type { PackageManifestPayload } from '@xyo-network/manifest'
|
|
3
|
-
import { NodeManifestPayload } from '@xyo-network/manifest'
|
|
4
|
-
import { ManifestWrapper } from '@xyo-network/manifest-wrapper'
|
|
5
|
-
import { ModuleFactoryLocator } from '@xyo-network/module-factory-locator'
|
|
6
|
-
import type { ModuleFactoryLocatorInstance } from '@xyo-network/module-model'
|
|
7
|
-
import type {
|
|
8
|
-
DappPackageManifestPayload, OsUser, XyOsContext, XyOsDappContext, XyOsDappDetails,
|
|
9
|
-
} from '@xyo-network/os-model'
|
|
10
|
-
import { DappPackageManifestPayloadSchema } from '@xyo-network/os-model'
|
|
11
|
-
import type { WalletInstance } from '@xyo-network/wallet-model'
|
|
12
|
-
|
|
13
|
-
import { DappWindowManifest } from './manifests/index.ts'
|
|
14
|
-
import type { XyOsContextParams } from './XyOsBase.ts'
|
|
15
|
-
import { XyOsContextBase } from './XyOsBase.ts'
|
|
16
|
-
|
|
17
|
-
export interface XyOsDappContextParams extends XyOsContextParams<DappPackageManifestPayload> {
|
|
18
|
-
dapp: XyOsDappDetails
|
|
19
|
-
locator: ModuleFactoryLocatorInstance
|
|
20
|
-
parent: XyOsContext
|
|
21
|
-
user: OsUser
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export class XyOsDapp extends XyOsContextBase<XyOsDappContextParams> implements XyOsDappContext {
|
|
25
|
-
dapp: XyOsDappDetails
|
|
26
|
-
|
|
27
|
-
constructor(params: XyOsDappContextParams) {
|
|
28
|
-
super(params)
|
|
29
|
-
this.dapp = { ...params.dapp }
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
override get eventBus() {
|
|
33
|
-
return this.parent.eventBus
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
override get exposedNode() {
|
|
37
|
-
return this.parent.exposedNode
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
override get exposedNodeOuter() {
|
|
41
|
-
return this.parent.exposedNodeOuter
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* @deprecated Dapps should not have access to the bios. This is done for the
|
|
46
|
-
* settings dapp, but should be refactored out. Bios could possibly be an
|
|
47
|
-
* optional property of the parent context passed in for dapps that require
|
|
48
|
-
* elevated permissions.
|
|
49
|
-
* ^^^ I believe we may want this here in that is a dApp requests access to the bios it will optionally be there
|
|
50
|
-
*/
|
|
51
|
-
override get kernel(): XyOsContextBase['kernel'] {
|
|
52
|
-
return assertEx(this.parent.kernel, () => 'Missing kernel')
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
get parent() {
|
|
56
|
-
return this.params.parent
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
get stacks() {
|
|
60
|
-
return []
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
override get user() {
|
|
64
|
-
return this.params.user
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
override async boot(wallet: WalletInstance, locator?: ModuleFactoryLocator): Promise<XyOsDappContext> {
|
|
68
|
-
return await this._bootMutex.runExclusive(async () => {
|
|
69
|
-
console.log('XyOsDapp:boot:start', wallet.address, this.dapp.id)
|
|
70
|
-
assertEx(this._root === undefined, () => 'Dapp already booted')
|
|
71
|
-
|
|
72
|
-
const finalLocator
|
|
73
|
-
= locator ? (this.params.locator ?? new ModuleFactoryLocator()).merge(locator) : (this.params.locator ?? new ModuleFactoryLocator())
|
|
74
|
-
|
|
75
|
-
console.log('XyOsDapp:boot:finalLocator', finalLocator)
|
|
76
|
-
|
|
77
|
-
const dappNodesWrapper = new ManifestWrapper({ ...this.manifest, schema: DappPackageManifestPayloadSchema }, wallet, finalLocator)
|
|
78
|
-
const dappNodes = await dappNodesWrapper.loadNodes()
|
|
79
|
-
const manifest = DappWindowManifest as unknown as PackageManifestPayload
|
|
80
|
-
|
|
81
|
-
// Derive a specific wallet for the dappManifestWrapper.
|
|
82
|
-
// If the dappNodes and dappManifest wrappers get the same wallet, there will be collisions.
|
|
83
|
-
const dappManifestWallet = await wallet.derivePath('99999')
|
|
84
|
-
manifest.nodes[0].config.name = this.dapp.name + 'Root'
|
|
85
|
-
const wrapper = new ManifestWrapper<DappPackageManifestPayload>(
|
|
86
|
-
{ ...manifest, schema: DappPackageManifestPayloadSchema },
|
|
87
|
-
dappManifestWallet,
|
|
88
|
-
finalLocator,
|
|
89
|
-
)
|
|
90
|
-
|
|
91
|
-
const node = await wrapper.loadNodeFromIndex(0)
|
|
92
|
-
for (const dappNode of dappNodes) {
|
|
93
|
-
await node.register(dappNode)
|
|
94
|
-
await node.attach(dappNode.address, true)
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
this._root = node
|
|
98
|
-
console.log('XyOsDapp:boot:finish', wallet.address, this.dapp.id)
|
|
99
|
-
return this
|
|
100
|
-
})
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
override getStack(stackName: string) {
|
|
104
|
-
return this.parent.getStack(stackName)
|
|
105
|
-
}
|
|
106
|
-
}
|
package/src/access/Caller.ts
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { assertEx } from '@xylabs/sdk-js'
|
|
2
|
-
import { ModuleFactoryLocator } from '@xyo-network/module-factory-locator'
|
|
3
|
-
import type { ModuleFactoryLocatorInstance } from '@xyo-network/module-model'
|
|
4
|
-
import { asNodeInstance } from '@xyo-network/node-model'
|
|
5
|
-
import type {
|
|
6
|
-
PostRegistrationHandler,
|
|
7
|
-
RegisteredDappAccess,
|
|
8
|
-
RegisteredDappSet,
|
|
9
|
-
RegisteredDappSetResult,
|
|
10
|
-
XyOsContext,
|
|
11
|
-
} from '@xyo-network/os-model'
|
|
12
|
-
import { isRegisteredDappAccessDappSet } from '@xyo-network/os-model'
|
|
13
|
-
import { PayloadBuilder } from '@xyo-network/payload-builder'
|
|
14
|
-
|
|
15
|
-
import { OsCallerBase } from '../OsCallerBase.ts'
|
|
16
|
-
import { RunningDappCache } from '../RunningDappCache.ts'
|
|
17
|
-
import { RunningDappAccessCache } from './RunningAccessDappCache.ts'
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Caller for managing Dapp Access Nodes
|
|
21
|
-
* Start nodes that have been registered as accessible
|
|
22
|
-
* Grab their Access Node(s)
|
|
23
|
-
* Put RegisteredDappAccess payloads in RegisteredDappInterfacesArchivist
|
|
24
|
-
* Keep Service running that can service requests for Access Nodes
|
|
25
|
-
*/
|
|
26
|
-
export class DappAccessCaller extends OsCallerBase implements PostRegistrationHandler {
|
|
27
|
-
private allowedNames: string[]
|
|
28
|
-
private platformLocator: ModuleFactoryLocatorInstance
|
|
29
|
-
private registeredDapps: RegisteredDappSetResult[]
|
|
30
|
-
private xnsNetwork: string | undefined
|
|
31
|
-
private xnsNodeUrl: string | undefined
|
|
32
|
-
|
|
33
|
-
constructor(
|
|
34
|
-
context: XyOsContext,
|
|
35
|
-
registeredDapps: RegisteredDappSetResult[],
|
|
36
|
-
allowedNames: string[],
|
|
37
|
-
xnsNodeUrl: string | undefined,
|
|
38
|
-
xnsNetwork: string | undefined,
|
|
39
|
-
platformLocator = new ModuleFactoryLocator(),
|
|
40
|
-
) {
|
|
41
|
-
super(context)
|
|
42
|
-
this.registeredDapps = registeredDapps
|
|
43
|
-
this.allowedNames = allowedNames
|
|
44
|
-
this.xnsNodeUrl = xnsNodeUrl
|
|
45
|
-
this.xnsNetwork = xnsNetwork
|
|
46
|
-
this.platformLocator = platformLocator
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
async start() {
|
|
50
|
-
const registeredDappAccessDappSets = this.registeredDapps.filter(isRegisteredDappAccessDappSet)
|
|
51
|
-
for (const registeredDappSet of registeredDappAccessDappSets) {
|
|
52
|
-
const context = await this.buildRunningDappCache(registeredDappSet, this.allowedNames)
|
|
53
|
-
|
|
54
|
-
for (const dappAccessor of registeredDappSet.dapp.accessors) {
|
|
55
|
-
await this.cacheAccessNode(dappAccessor, context)
|
|
56
|
-
await this.saveRegisteredDappInterfaces(dappAccessor)
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
private async buildRunningDappCache(registeredDappSet: RegisteredDappSet, allowedNames: string[]) {
|
|
62
|
-
const { context } = await RunningDappCache.findOrCreate(registeredDappSet.dapp, this.context, allowedNames, this.xnsNodeUrl, this.xnsNetwork)
|
|
63
|
-
if (!context) throw new Error('Dapp context not found')
|
|
64
|
-
return context
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
private async cacheAccessNode(dappAccessor: RegisteredDappAccess, context: XyOsContext) {
|
|
68
|
-
const accessNodeId = dappAccessor.rootModuleId
|
|
69
|
-
const accessNodeModule = assertEx(await context.root.resolve(accessNodeId), () => 'Access Node Module not found')
|
|
70
|
-
const accessNode = asNodeInstance(accessNodeModule, () => 'Access Node Module is not a NodeInstance', { required: true })
|
|
71
|
-
|
|
72
|
-
RunningDappAccessCache.set(dappAccessor.registeringDappId, accessNode)
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
private async saveRegisteredDappInterfaces(registeredDappAccess: RegisteredDappAccess) {
|
|
76
|
-
const archivist = await this.getRegisteredDappInterfacesArchivist()
|
|
77
|
-
|
|
78
|
-
const hash = await PayloadBuilder.dataHash(registeredDappAccess)
|
|
79
|
-
const [existing] = await archivist.get([hash])
|
|
80
|
-
if (existing) return
|
|
81
|
-
|
|
82
|
-
await archivist.insert([registeredDappAccess])
|
|
83
|
-
console.debug('[DEBUG] -', `Registered ${registeredDappAccess.registeringDappId} with ${registeredDappAccess.name} interface`)
|
|
84
|
-
}
|
|
85
|
-
}
|
package/src/access/Queries.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { DivinerInstance } from '@xyo-network/diviner-model'
|
|
2
|
-
import { PayloadDivinerQuerySchema } from '@xyo-network/diviner-payload-model'
|
|
3
|
-
import type { DappAccessRequest, RegisteredDappAccess } from '@xyo-network/os-model'
|
|
4
|
-
import { DappAccessRequestSchema, RegisteredDappAccessSchema } from '@xyo-network/os-model'
|
|
5
|
-
import type { WithSources } from '@xyo-network/payload-model'
|
|
6
|
-
|
|
7
|
-
const noResults: unknown[] = []
|
|
8
|
-
|
|
9
|
-
export const DappAccessRequestQueries = {
|
|
10
|
-
async getAccessRequests(diviner: DivinerInstance) {
|
|
11
|
-
const query = {
|
|
12
|
-
limit: 1,
|
|
13
|
-
schema: PayloadDivinerQuerySchema,
|
|
14
|
-
schemas: [DappAccessRequestSchema],
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const results = (await diviner.divine([query])) as WithSources<DappAccessRequest>[]
|
|
18
|
-
|
|
19
|
-
if (results.length === 0) {
|
|
20
|
-
return noResults as WithSources<DappAccessRequest>[]
|
|
21
|
-
}
|
|
22
|
-
return results
|
|
23
|
-
},
|
|
24
|
-
async getRegisteredInterfaces(diviner: DivinerInstance) {
|
|
25
|
-
const query = {
|
|
26
|
-
limit: 1,
|
|
27
|
-
schema: PayloadDivinerQuerySchema,
|
|
28
|
-
schemas: [RegisteredDappAccessSchema],
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const results = (await diviner.divine([query])) as WithSources<RegisteredDappAccess>[]
|
|
32
|
-
|
|
33
|
-
if (results.length === 0) {
|
|
34
|
-
return noResults as WithSources<RegisteredDappAccess>[]
|
|
35
|
-
}
|
|
36
|
-
return results
|
|
37
|
-
},
|
|
38
|
-
}
|