@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/stack/Base.ts
DELETED
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import type { BaseParams, Promisable } from '@xylabs/sdk-js'
|
|
2
|
-
import {
|
|
3
|
-
assertEx, BaseEmitter, forget,
|
|
4
|
-
} from '@xylabs/sdk-js'
|
|
5
|
-
import type { ModuleIdentifier } from '@xyo-network/module-model'
|
|
6
|
-
import { isModuleInstance } from '@xyo-network/module-model'
|
|
7
|
-
import type { AttachableNodeInstance } from '@xyo-network/node-model'
|
|
8
|
-
import { asAttachableNodeInstance } from '@xyo-network/node-model'
|
|
9
|
-
import type {
|
|
10
|
-
AdapterSetCreator, NodeAdapter, NodeAdapterBaseEvents, StackBaseEvents, StackInitializer, XyOsContext,
|
|
11
|
-
} from '@xyo-network/os-model'
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Stack Base Class
|
|
15
|
-
*
|
|
16
|
-
* Listens for changes in adapter connections, update the stack node, and emits events when the stack is ready
|
|
17
|
-
*/
|
|
18
|
-
export class StackBase extends BaseEmitter<BaseParams, StackBaseEvents> implements StackInitializer {
|
|
19
|
-
// flag to check that all adapters are initialized
|
|
20
|
-
initialized = false
|
|
21
|
-
|
|
22
|
-
// adapters to initialize into the stack
|
|
23
|
-
private _adapterSet: NodeAdapter[]
|
|
24
|
-
|
|
25
|
-
private _context: XyOsContext
|
|
26
|
-
|
|
27
|
-
// stack node
|
|
28
|
-
private _stack: AttachableNodeInstance | undefined
|
|
29
|
-
|
|
30
|
-
// stack node module identifier for the stack
|
|
31
|
-
private _stackNodeModuleId: ModuleIdentifier
|
|
32
|
-
|
|
33
|
-
// list of initialized nodes
|
|
34
|
-
private initializedNodes: AttachableNodeInstance[] = []
|
|
35
|
-
|
|
36
|
-
// list of listeners - lister type not important since its only recalled to stop listening
|
|
37
|
-
|
|
38
|
-
private listeners: {
|
|
39
|
-
adapter: NodeAdapter
|
|
40
|
-
eventName: string
|
|
41
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
42
|
-
listener: (args: any) => Promisable<void>
|
|
43
|
-
}[] = []
|
|
44
|
-
|
|
45
|
-
constructor(context: XyOsContext, adapterSet: AdapterSetCreator, stackNodeModuleId: ModuleIdentifier) {
|
|
46
|
-
super({})
|
|
47
|
-
this._context = context
|
|
48
|
-
this._adapterSet = adapterSet(assertEx(this.context.kernel, () => 'Kernel access required'))
|
|
49
|
-
this._stackNodeModuleId = stackNodeModuleId
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
get adapterSet(): NodeAdapter[] {
|
|
53
|
-
return assertEx(this._adapterSet, () => `${this.stackNodeModuleId} adapters not initialized`)
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
get context(): XyOsContext {
|
|
57
|
-
return assertEx(this._context, () => `${this.stackNodeModuleId} stack context not initialized`)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
get stack(): AttachableNodeInstance {
|
|
61
|
-
return assertEx(this._stack, () => `${this.stackNodeModuleId} stack node not initialized`)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
get stackNodeModuleId(): ModuleIdentifier {
|
|
65
|
-
return assertEx(this._stackNodeModuleId, () => 'Stack node module identifier not initialized')
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
initialize() {
|
|
69
|
-
this.assignStack()
|
|
70
|
-
// watch for adapter connection changes
|
|
71
|
-
for (const adapter of this.adapterSet) {
|
|
72
|
-
// listen for driver ready events
|
|
73
|
-
const driverReadyListener = async ({ node }: NodeAdapterBaseEvents['driverReady']) => await this.handleDriverReady(node)
|
|
74
|
-
adapter.on('driverReady', driverReadyListener)
|
|
75
|
-
this.listeners.push({
|
|
76
|
-
adapter: adapter, eventName: 'driverReady', listener: driverReadyListener,
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
// listen for driver error events
|
|
80
|
-
const driverErrorListener = async ({ error }: NodeAdapterBaseEvents['driverError']) => {
|
|
81
|
-
console.error(`Error updating ${this.stackNodeModuleId} stack node`, error)
|
|
82
|
-
await this.emit('driverError', { error })
|
|
83
|
-
}
|
|
84
|
-
adapter.on('driverError', driverErrorListener)
|
|
85
|
-
this.listeners.push({
|
|
86
|
-
adapter: adapter, eventName: 'driverError', listener: driverErrorListener,
|
|
87
|
-
})
|
|
88
|
-
|
|
89
|
-
// start the adapter
|
|
90
|
-
const startAdapter = async () => await adapter.start()
|
|
91
|
-
forget(startAdapter())
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Stops the stack
|
|
97
|
-
*/
|
|
98
|
-
stop() {
|
|
99
|
-
for (const {
|
|
100
|
-
eventName, listener, adapter,
|
|
101
|
-
} of this.listeners) {
|
|
102
|
-
// stop the adapter
|
|
103
|
-
adapter.off(eventName, listener)
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Adds a node to the stack. Idempotent to avoid adding the
|
|
109
|
-
* same node multiple times
|
|
110
|
-
* @param node The node to add to the stack
|
|
111
|
-
* @returns
|
|
112
|
-
*/
|
|
113
|
-
private async addNodeToStackNode(node: AttachableNodeInstance) {
|
|
114
|
-
// Locate the stack node
|
|
115
|
-
const stackNode = await this.getStackNode()
|
|
116
|
-
|
|
117
|
-
// If the node is already attached as there's no need to re-attach
|
|
118
|
-
const existingModule = await stackNode.resolve(node.address, { direction: 'down' })
|
|
119
|
-
if (isModuleInstance(existingModule)) return
|
|
120
|
-
|
|
121
|
-
// Register & attach the new node
|
|
122
|
-
await stackNode.register?.(node)
|
|
123
|
-
await stackNode.attach?.(node.address, true)
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
private assignStack() {
|
|
127
|
-
const assign = async () => {
|
|
128
|
-
const stackNode = await this.getStackNode()
|
|
129
|
-
this._stack = stackNode
|
|
130
|
-
}
|
|
131
|
-
forget(assign())
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
private async getStackNode() {
|
|
135
|
-
const mod = assertEx(await this.context.root.resolve(this.stackNodeModuleId), () => `${this.stackNodeModuleId} not found`)
|
|
136
|
-
return asAttachableNodeInstance(mod, () => `${this.stackNodeModuleId} not a NodeInstance`, { required: true })
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
private async handleDriverReady(node: AttachableNodeInstance) {
|
|
140
|
-
try {
|
|
141
|
-
// eagerly emit that the driver is ready
|
|
142
|
-
await this.emit('driverReady', { node })
|
|
143
|
-
|
|
144
|
-
await this.addNodeToStackNode(node)
|
|
145
|
-
|
|
146
|
-
await this.updateInitializationState(node)
|
|
147
|
-
} catch (error) {
|
|
148
|
-
console.error(`Error updating ${this.stackNodeModuleId} stack node`, node.id, error)
|
|
149
|
-
await this.emit('stackError', { error: error as Error })
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
private async updateInitializationState(node: AttachableNodeInstance) {
|
|
154
|
-
// update the initialized nodes list
|
|
155
|
-
this.initializedNodes.push(node)
|
|
156
|
-
|
|
157
|
-
// update the initialized flag
|
|
158
|
-
this.initialized = this.adapterSet.every(n => n.initialized)
|
|
159
|
-
|
|
160
|
-
// notify all initialized listeners
|
|
161
|
-
if (this.initialized) {
|
|
162
|
-
await this.emit('initialized', { stack: await this.getStackNode() })
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
package/src/stack/Manager.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
AdapterSetCreator, StackInitializer, XyOsContext,
|
|
3
|
-
} from '@xyo-network/os-model'
|
|
4
|
-
|
|
5
|
-
import type { StackBase } from './Base.ts'
|
|
6
|
-
|
|
7
|
-
export interface StackConstructor { new (context: XyOsContext, adapters: AdapterSetCreator): StackBase }
|
|
8
|
-
|
|
9
|
-
export interface UninitializedStackSet {
|
|
10
|
-
adapters: AdapterSetCreator
|
|
11
|
-
stack: StackConstructor
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface UninitializedStackMap { [key: string]: UninitializedStackSet }
|
|
15
|
-
|
|
16
|
-
export class StackManager {
|
|
17
|
-
private initializedStacksMap: Map<string, StackInitializer> = new Map()
|
|
18
|
-
private stackMap: UninitializedStackMap
|
|
19
|
-
|
|
20
|
-
constructor(stackMap: UninitializedStackMap) {
|
|
21
|
-
this.stackMap = stackMap
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
get stacks() {
|
|
25
|
-
return Object.keys(this.initializedStacksMap)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
private get initializedStacks() {
|
|
29
|
-
return this.initializedStacksMap
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
getStack<TStack = StackBase>(key: string) {
|
|
33
|
-
return this.initializedStacksMap.get(key) as TStack | undefined
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
initialize(context: XyOsContext) {
|
|
37
|
-
for (const [key, stackSet] of Object.entries(this.stackMap)) {
|
|
38
|
-
console.log('stack-initialize', key)
|
|
39
|
-
const { stack: Stack, adapters: stackNodeModuleId } = stackSet
|
|
40
|
-
const initializedStack = new Stack(context, stackNodeModuleId)
|
|
41
|
-
initializedStack.initialize()
|
|
42
|
-
this.initializedStacks.set(key, initializedStack)
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
stop() {
|
|
47
|
-
for (const stack of this.initializedStacks.values()) {
|
|
48
|
-
stack.stop()
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
package/src/stack/Map.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
OsPubSubBridgeNetworkAdapters, OsSettingsAdapters, OsXyoPublicNetworkAdapters,
|
|
3
|
-
} from '../adapters/index.ts'
|
|
4
|
-
import type { UninitializedStackMap } from './Manager.ts'
|
|
5
|
-
import { OsPubSubNetworkStack } from './OsPubSubNetworkStack.ts'
|
|
6
|
-
import { OsSettingsStack } from './OsSettingsStack.ts'
|
|
7
|
-
import { XyoPublicNetworkStack } from './XyoPublicNetworkStack.ts'
|
|
8
|
-
|
|
9
|
-
export const OsStackMap: UninitializedStackMap = {
|
|
10
|
-
osPubSubNetworkStack: {
|
|
11
|
-
stack: OsPubSubNetworkStack,
|
|
12
|
-
adapters: OsPubSubBridgeNetworkAdapters,
|
|
13
|
-
},
|
|
14
|
-
xyoPublicNetworkStack: {
|
|
15
|
-
stack: XyoPublicNetworkStack,
|
|
16
|
-
adapters: OsXyoPublicNetworkAdapters,
|
|
17
|
-
},
|
|
18
|
-
osSettingsStack: {
|
|
19
|
-
stack: OsSettingsStack,
|
|
20
|
-
adapters: OsSettingsAdapters,
|
|
21
|
-
},
|
|
22
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { assertEx } from '@xylabs/sdk-js'
|
|
2
|
-
import type { NodeInstance } from '@xyo-network/node-model'
|
|
3
|
-
import { asAttachableNodeInstance, asNodeInstance } from '@xyo-network/node-model'
|
|
4
|
-
import type { AdapterSetCreator, XyOsContext } from '@xyo-network/os-model'
|
|
5
|
-
import { ExposedNodeOuterNodeName, PubSubBridgeNodeNodeName } from '@xyo-network/os-model'
|
|
6
|
-
|
|
7
|
-
import type { EventBusPubSubConnection } from '../event/index.ts'
|
|
8
|
-
import { osPubSubNetworkReadyConnection, OsPubSubNetworkReadyEvent } from '../event/index.ts'
|
|
9
|
-
import { initializeXns } from '../lib/index.ts'
|
|
10
|
-
import { StackBase } from './Base.ts'
|
|
11
|
-
|
|
12
|
-
export class OsPubSubNetworkStack extends StackBase {
|
|
13
|
-
protected _exposedNode: NodeInstance | undefined
|
|
14
|
-
protected _exposedNodeOuter: NodeInstance | undefined
|
|
15
|
-
|
|
16
|
-
private busConnection: EventBusPubSubConnection = osPubSubNetworkReadyConnection()
|
|
17
|
-
|
|
18
|
-
constructor(context: XyOsContext, adapters: AdapterSetCreator) {
|
|
19
|
-
super(context, adapters, 'OsPubSubNetworkStackNode')
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
get exposedNode() {
|
|
23
|
-
return this._exposedNode
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
get exposedNodeOuter() {
|
|
27
|
-
return this._exposedNodeOuter
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
override initialize() {
|
|
31
|
-
super.initialize()
|
|
32
|
-
// connect to the bus
|
|
33
|
-
this.context.eventBus.addConnection(this.busConnection)
|
|
34
|
-
this.on('initialized', () => this.busConnection.emit(OsPubSubNetworkReadyEvent, {}))
|
|
35
|
-
|
|
36
|
-
// listen for drivers
|
|
37
|
-
super.on('driverReady', async ({ node }) => {
|
|
38
|
-
if (node.id === PubSubBridgeNodeNodeName) {
|
|
39
|
-
const httpBridge = assertEx(await node.resolve('NsHttpBridge'), () => 'HttpBridge not found')
|
|
40
|
-
const xnsNode = asNodeInstance(await httpBridge.resolve('XNS'))
|
|
41
|
-
|
|
42
|
-
if (xnsNode) {
|
|
43
|
-
const initializedXns = await initializeXns(xnsNode)
|
|
44
|
-
console.log(`Xns: ${initializedXns}`)
|
|
45
|
-
} else {
|
|
46
|
-
console.log('Xns: Failed to contact Xns Node')
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
super.on('driverReady', async ({ node }) => {
|
|
52
|
-
if (node.id === ExposedNodeOuterNodeName) {
|
|
53
|
-
this._exposedNodeOuter = node
|
|
54
|
-
const mod = assertEx(await node.resolve('ExposedNode'), () => 'ExposedNode not found')
|
|
55
|
-
const exposedNode = asAttachableNodeInstance(mod, () => 'ExposedNode is not a node')
|
|
56
|
-
this._exposedNode = exposedNode
|
|
57
|
-
}
|
|
58
|
-
})
|
|
59
|
-
super.on('driverError', error => console.error('Unable to assign exposed node(s) to context', error))
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
override stop() {
|
|
63
|
-
super.stop()
|
|
64
|
-
this._exposedNode = undefined
|
|
65
|
-
this._exposedNodeOuter = undefined
|
|
66
|
-
// prevent throwing an error if the connection is not initialized
|
|
67
|
-
if (this.busConnection._id)
|
|
68
|
-
this.context.eventBus.removeConnection(this.busConnection.id)
|
|
69
|
-
}
|
|
70
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { AdapterSetCreator, XyOsContext } from '@xyo-network/os-model'
|
|
2
|
-
|
|
3
|
-
import type { EventBusPubSubConnection } from '../event/index.ts'
|
|
4
|
-
import { osSettingsReadyConnection, OsSettingsReadyEvent } from '../event/index.ts'
|
|
5
|
-
import { StackBase } from './Base.ts'
|
|
6
|
-
|
|
7
|
-
export class OsSettingsStack extends StackBase {
|
|
8
|
-
private busConnection: EventBusPubSubConnection = osSettingsReadyConnection()
|
|
9
|
-
|
|
10
|
-
constructor(context: XyOsContext, adapters: AdapterSetCreator) {
|
|
11
|
-
super(context, adapters, 'OsSettingsStackNode')
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
override initialize() {
|
|
15
|
-
super.initialize()
|
|
16
|
-
// connect to the bus
|
|
17
|
-
this.context.eventBus.addConnection(this.busConnection)
|
|
18
|
-
this.on('initialized', () => this.busConnection.emit(OsSettingsReadyEvent, {}))
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
override stop() {
|
|
22
|
-
super.stop()
|
|
23
|
-
}
|
|
24
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { AdapterSetCreator, XyOsContext } from '@xyo-network/os-model'
|
|
2
|
-
import { XyoPublicNodeName } from '@xyo-network/os-model'
|
|
3
|
-
|
|
4
|
-
import type { EventBusPubSubConnection } from '../event/index.ts'
|
|
5
|
-
import { osXyoPublicNetworkReadyConnection, OsXyoPublicNetworkReadyEvent } from '../event/index.ts'
|
|
6
|
-
import { StackBase } from './Base.ts'
|
|
7
|
-
|
|
8
|
-
export class XyoPublicNetworkStack extends StackBase {
|
|
9
|
-
private busConnection: EventBusPubSubConnection = osXyoPublicNetworkReadyConnection()
|
|
10
|
-
|
|
11
|
-
constructor(context: XyOsContext, adapters: AdapterSetCreator) {
|
|
12
|
-
super(context, adapters, 'OsXyoPublicNetworkStackNode')
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
override initialize() {
|
|
16
|
-
super.initialize()
|
|
17
|
-
// connect to the bus
|
|
18
|
-
this.context.eventBus.addConnection(this.busConnection)
|
|
19
|
-
this.on('initialized', () => this.busConnection.emit(OsXyoPublicNetworkReadyEvent, {}))
|
|
20
|
-
|
|
21
|
-
this.on('driverReady', ({ node }) => {
|
|
22
|
-
if (node.id === XyoPublicNodeName) {
|
|
23
|
-
console.log('XyoPublicNode ready')
|
|
24
|
-
}
|
|
25
|
-
})
|
|
26
|
-
this.on('driverError', error => console.error('Error loading driver', error))
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
override stop() {
|
|
30
|
-
super.stop()
|
|
31
|
-
}
|
|
32
|
-
}
|
package/src/stack/index.ts
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import type { ArchivistInstance } from '@xyo-network/archivist-model'
|
|
2
|
-
import type { ModuleFactoryLocator } from '@xyo-network/module-factory-locator'
|
|
3
|
-
import type { ModuleFactoryLocatorInstance } from '@xyo-network/module-model'
|
|
4
|
-
import type {
|
|
5
|
-
DappConfig, DappIcon, DappParams, DappSet, PayloadWithVersion, XyOsContext,
|
|
6
|
-
} from '@xyo-network/os-model'
|
|
7
|
-
import { PayloadBuilder } from '@xyo-network/payload-builder'
|
|
8
|
-
import type { WithStorageMeta } from '@xyo-network/payload-model'
|
|
9
|
-
import semver from 'semver'
|
|
10
|
-
|
|
11
|
-
import { OsCallerBase } from '../OsCallerBase.ts'
|
|
12
|
-
import { SystemDappQueries } from './Queries.ts'
|
|
13
|
-
|
|
14
|
-
export type ErrorListener = (failedPayloads: DappConfig[]) => void
|
|
15
|
-
export type DappSetsAndPayloads = {
|
|
16
|
-
dappPayloads: (DappConfig | DappIcon)[]
|
|
17
|
-
dappSets: DappSet[]
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Manage the installation of system dapps from payloads and return the built sets
|
|
22
|
-
*/
|
|
23
|
-
export class ManageSystemDapps extends OsCallerBase {
|
|
24
|
-
private defaultSystemDappParams: Record<string, DappParams>
|
|
25
|
-
private defaultSystemDapps: PayloadWithVersion[]
|
|
26
|
-
private defaultSystemNames: string[]
|
|
27
|
-
private developmentMode?: boolean
|
|
28
|
-
private locator?: ModuleFactoryLocatorInstance
|
|
29
|
-
|
|
30
|
-
private onErrorCallbacks: ErrorListener[] = []
|
|
31
|
-
|
|
32
|
-
constructor(
|
|
33
|
-
context: XyOsContext,
|
|
34
|
-
defaultSystemNames: string[],
|
|
35
|
-
defaultSystemDapps: PayloadWithVersion[],
|
|
36
|
-
defaultSystemDappParams: Record<string, DappParams>,
|
|
37
|
-
locator?: ModuleFactoryLocatorInstance,
|
|
38
|
-
developmentMode?: boolean,
|
|
39
|
-
) {
|
|
40
|
-
super(context)
|
|
41
|
-
this.defaultSystemNames = defaultSystemNames
|
|
42
|
-
this.defaultSystemDapps = defaultSystemDapps
|
|
43
|
-
this.defaultSystemDappParams = defaultSystemDappParams
|
|
44
|
-
this.locator = locator
|
|
45
|
-
this.developmentMode = developmentMode
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Add a callback to listen for errors throwing during system dapp registration
|
|
50
|
-
* @param errorListener
|
|
51
|
-
*/
|
|
52
|
-
addErrorListener(errorListener: ErrorListener) {
|
|
53
|
-
this.onErrorCallbacks.push(errorListener)
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Installs the dapps into the OS and builds the appropriate DappSet
|
|
58
|
-
*/
|
|
59
|
-
async install(): Promise<DappSet[]> {
|
|
60
|
-
await this.insertPayloads()
|
|
61
|
-
return await this.latestSets()
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
private async freshInstall(archivist: ArchivistInstance): Promise<void> {
|
|
65
|
-
await archivist.insert(this.defaultSystemDapps)
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
private async insertPayloads(): Promise<boolean> {
|
|
69
|
-
const archivist = this.developmentMode ? await this.getDappsArchivistDevelopment() : await this.getDappsArchivist()
|
|
70
|
-
try {
|
|
71
|
-
const allPayloads = (await archivist.all()) as WithStorageMeta<(DappIcon | DappConfig)>[]
|
|
72
|
-
if (allPayloads.length === 0) {
|
|
73
|
-
await this.freshInstall(archivist)
|
|
74
|
-
return true
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// only insert unseen system dapp payloads
|
|
78
|
-
for (const systemDappPayload of this.defaultSystemDapps) {
|
|
79
|
-
try {
|
|
80
|
-
const validSemver = semver.valid(systemDappPayload.version)
|
|
81
|
-
if (!validSemver) throw new Error('semver is a valid type (string) but was not able to be parsed')
|
|
82
|
-
} catch (e) {
|
|
83
|
-
console.error(`${systemDappPayload.version} does not appear to be a valid semver value`, e)
|
|
84
|
-
continue
|
|
85
|
-
}
|
|
86
|
-
const [existing] = await archivist.get([await PayloadBuilder.dataHash(systemDappPayload)])
|
|
87
|
-
if (existing) continue
|
|
88
|
-
await archivist.insert([systemDappPayload])
|
|
89
|
-
}
|
|
90
|
-
return true
|
|
91
|
-
} catch (e) {
|
|
92
|
-
console.error('error installing system dapps')
|
|
93
|
-
throw e
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
private async latestSets() {
|
|
98
|
-
const diviner = this.developmentMode ? await this.getDappsArchivistPayloadDivinerDevelopment() : await this.getDappsArchivistPayloadDiviner()
|
|
99
|
-
const dappSets: DappSet[] = []
|
|
100
|
-
const failedPayloads: DappConfig[] = []
|
|
101
|
-
|
|
102
|
-
for (const name of this.defaultSystemNames) {
|
|
103
|
-
try {
|
|
104
|
-
const dappConfig = await SystemDappQueries.getLatestConfig(diviner, name)
|
|
105
|
-
if (!dappConfig) {
|
|
106
|
-
console.error(`No config found for dapp ${name}`)
|
|
107
|
-
continue
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
const dappIcon = await SystemDappQueries.getLatestIcon(diviner, name, dappConfig.version)
|
|
111
|
-
if (!dappIcon) {
|
|
112
|
-
console.error(`No icon found for dapp ${dappConfig.name}`)
|
|
113
|
-
failedPayloads.push(dappConfig)
|
|
114
|
-
continue
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const dappAccess = await SystemDappQueries.getDappAccess(diviner, name, dappConfig.version)
|
|
118
|
-
|
|
119
|
-
const dappParams = this.defaultSystemDappParams[dappConfig.name]
|
|
120
|
-
if (!dappParams) {
|
|
121
|
-
console.error(`No params found for dapp ${dappConfig.name}. Did you forget to add it to OsDappParams?`)
|
|
122
|
-
failedPayloads.push(dappConfig)
|
|
123
|
-
continue
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
const dappWidgetConfigs = await SystemDappQueries.getWidgetConfigs(diviner, name, dappConfig.version)
|
|
127
|
-
|
|
128
|
-
dappSets.push({
|
|
129
|
-
dapp: {
|
|
130
|
-
accessors: dappAccess,
|
|
131
|
-
config: dappConfig,
|
|
132
|
-
icon: dappIcon,
|
|
133
|
-
params: dappParams,
|
|
134
|
-
widgetConfigs: dappWidgetConfigs,
|
|
135
|
-
},
|
|
136
|
-
})
|
|
137
|
-
} catch {
|
|
138
|
-
console.error(`Failed to build dapp ${name}`)
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
if (failedPayloads.length > 0) {
|
|
143
|
-
for (const cb of this.onErrorCallbacks) cb(failedPayloads)
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
return dappSets
|
|
147
|
-
}
|
|
148
|
-
}
|
package/src/system/Queries.ts
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import type { DivinerInstance } from '@xyo-network/diviner-model'
|
|
2
|
-
import { PayloadDivinerQuerySchema } from '@xyo-network/diviner-payload-model'
|
|
3
|
-
import type {
|
|
4
|
-
DappConfig,
|
|
5
|
-
DappIcon,
|
|
6
|
-
DappId,
|
|
7
|
-
DappWidgetConfig,
|
|
8
|
-
UnregisteredDappAccess,
|
|
9
|
-
} from '@xyo-network/os-model'
|
|
10
|
-
import {
|
|
11
|
-
DappConfigSchema,
|
|
12
|
-
DappIconSchema,
|
|
13
|
-
DappWidgetConfigSchema,
|
|
14
|
-
UnregisteredDappAccessSchema,
|
|
15
|
-
} from '@xyo-network/os-model'
|
|
16
|
-
import { PayloadBuilder } from '@xyo-network/payload-builder'
|
|
17
|
-
|
|
18
|
-
export const SystemDappQueries = {
|
|
19
|
-
async getDappAccess(diviner: DivinerInstance, name: string, version: string) {
|
|
20
|
-
const accessQuery = {
|
|
21
|
-
order: 'desc',
|
|
22
|
-
registeringDappId: name,
|
|
23
|
-
schema: PayloadDivinerQuerySchema,
|
|
24
|
-
schemas: [UnregisteredDappAccessSchema],
|
|
25
|
-
version: version,
|
|
26
|
-
}
|
|
27
|
-
return (await diviner.divine([accessQuery])) as UnregisteredDappAccess[]
|
|
28
|
-
},
|
|
29
|
-
async getLatestConfig(diviner: DivinerInstance, name: string) {
|
|
30
|
-
const configQuery = {
|
|
31
|
-
limit: 1,
|
|
32
|
-
name,
|
|
33
|
-
order: 'desc',
|
|
34
|
-
schema: PayloadDivinerQuerySchema,
|
|
35
|
-
schemas: [DappConfigSchema],
|
|
36
|
-
}
|
|
37
|
-
const [dappConfig] = (await diviner.divine([configQuery])) as DappConfig[]
|
|
38
|
-
return dappConfig
|
|
39
|
-
},
|
|
40
|
-
async getLatestIcon(diviner: DivinerInstance, name: string, version: string) {
|
|
41
|
-
const iconQuery = {
|
|
42
|
-
name,
|
|
43
|
-
order: 'desc',
|
|
44
|
-
schema: PayloadDivinerQuerySchema,
|
|
45
|
-
schemas: [DappIconSchema],
|
|
46
|
-
version,
|
|
47
|
-
}
|
|
48
|
-
const [dappIcon] = (await diviner.divine([iconQuery])) as DappIcon[]
|
|
49
|
-
return dappIcon
|
|
50
|
-
},
|
|
51
|
-
async getWidgetConfigs(diviner: DivinerInstance, name: DappId, version: string): Promise<DappWidgetConfig[]> {
|
|
52
|
-
const widgetConfigQuery = {
|
|
53
|
-
dappId: name,
|
|
54
|
-
order: 'desc',
|
|
55
|
-
schema: PayloadDivinerQuerySchema,
|
|
56
|
-
schemas: [DappWidgetConfigSchema],
|
|
57
|
-
version,
|
|
58
|
-
}
|
|
59
|
-
const widgetConfigs = (await diviner.divine([widgetConfigQuery])) as DappWidgetConfig[]
|
|
60
|
-
|
|
61
|
-
const uniqueConfigs: Record<string, DappWidgetConfig> = {}
|
|
62
|
-
for (const widgetConfig of widgetConfigs) {
|
|
63
|
-
const hash = await PayloadBuilder.dataHash(widgetConfig)
|
|
64
|
-
uniqueConfigs[widgetConfig.mode ?? hash] = widgetConfig
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return Object.values(uniqueConfigs)
|
|
68
|
-
},
|
|
69
|
-
}
|
package/src/system/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './ManageSystemDapps.ts'
|
package/src/types/global.d.ts
DELETED
package/src/types/images.d.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import type { Hash } from '@xylabs/sdk-js'
|
|
2
|
-
import type { WalletSeedPhrase } from '@xyo-network/os-model'
|
|
3
|
-
import { WalletSeedPhraseSchema } from '@xyo-network/os-model'
|
|
4
|
-
import { PayloadBuilder } from '@xyo-network/payload-builder'
|
|
5
|
-
|
|
6
|
-
const language = 'english'
|
|
7
|
-
const standard = 'bip-39'
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* The label for the user wallet
|
|
11
|
-
*/
|
|
12
|
-
export const userWalletLabel = 'userWallet'
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* The valid wallet labels
|
|
16
|
-
*/
|
|
17
|
-
export type WalletLabel = typeof userWalletLabel // TODO: More wallet types 'osWallet' | 'deviceWalletBackup' | ...
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Builds a WalletSeedPhrase payload from the supplied mnemonic seed phrase and label
|
|
21
|
-
* @param mnemonic The mnemonic seed phrase
|
|
22
|
-
* @param $label The wallet label
|
|
23
|
-
* @returns A WalletSeedPhrase payload and its root hash
|
|
24
|
-
*/
|
|
25
|
-
export const buildWalletSeedPhrasePayload = async (mnemonic: string, $label: WalletLabel): Promise<{
|
|
26
|
-
payload: WalletSeedPhrase
|
|
27
|
-
rootHash: Hash
|
|
28
|
-
}> => {
|
|
29
|
-
const fields = {
|
|
30
|
-
mnemonic: {
|
|
31
|
-
language, mnemonic: mnemonic.split(' '), standard,
|
|
32
|
-
},
|
|
33
|
-
$label,
|
|
34
|
-
$timestamp: Date.now(),
|
|
35
|
-
}
|
|
36
|
-
const payload = new PayloadBuilder<WalletSeedPhrase>({ schema: WalletSeedPhraseSchema }).fields(fields).build()
|
|
37
|
-
const rootHash = await PayloadBuilder.hash(payload)
|
|
38
|
-
return { payload, rootHash }
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Builds a user WalletSeedPhrase payload from the supplied mnemonic seed phrase and label
|
|
43
|
-
* @param mnemonic The mnemonic seed phrase
|
|
44
|
-
* @returns A user WalletSeedPhrase payload and its root hash
|
|
45
|
-
*/
|
|
46
|
-
export const buildUserWalletSeedPhrasePayload = (mnemonic: string): Promise<{
|
|
47
|
-
payload: WalletSeedPhrase
|
|
48
|
-
rootHash: Hash
|
|
49
|
-
}> => {
|
|
50
|
-
return buildWalletSeedPhrasePayload(mnemonic, userWalletLabel)
|
|
51
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
const getApiDomain = (scope: 'localhost' | 'beta' | 'prod' | undefined, apiDomain: string | undefined) => {
|
|
2
|
-
if (apiDomain !== undefined) {
|
|
3
|
-
return apiDomain as string
|
|
4
|
-
}
|
|
5
|
-
if (scope === 'localhost') {
|
|
6
|
-
return 'http://localhost:8080'
|
|
7
|
-
}
|
|
8
|
-
if (scope === 'beta') {
|
|
9
|
-
return 'https://beta.archivist.xyo.network'
|
|
10
|
-
}
|
|
11
|
-
return 'https://archivist.xyo.network'
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export { getApiDomain }
|
package/src/utils/index.ts
DELETED