@xyo-network/os-runtime 7.2.1 → 7.3.1

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.
Files changed (249) hide show
  1. package/dist/neutral/Caller.d.ts.map +1 -1
  2. package/dist/neutral/DappCallerBase.d.ts +2 -2
  3. package/dist/neutral/OsCallerBase.d.ts +2 -2
  4. package/dist/neutral/RunningDappCache.d.ts.map +1 -1
  5. package/dist/neutral/XyOs.d.ts +4 -5
  6. package/dist/neutral/XyOs.d.ts.map +1 -1
  7. package/dist/neutral/XyOsBase.d.ts +122 -3
  8. package/dist/neutral/XyOsBase.d.ts.map +1 -1
  9. package/dist/neutral/XyOsDapp.d.ts +3 -3
  10. package/dist/neutral/XyOsDapp.d.ts.map +1 -1
  11. package/dist/neutral/access/Caller.d.ts +1 -1
  12. package/dist/neutral/access/Caller.d.ts.map +1 -1
  13. package/dist/neutral/access/RunningAccessDappCache.d.ts.map +1 -1
  14. package/dist/neutral/access/interfaces/registered-names/helpers/resource/AbstractXnsCaller.d.ts +1 -1
  15. package/dist/neutral/adapter/Base.d.ts.map +1 -1
  16. package/dist/neutral/classes/lib/DappCreatorParams.d.ts +3 -3
  17. package/dist/neutral/classes/lib/DappCreatorParams.d.ts.map +1 -1
  18. package/dist/neutral/classes/lib/Insertable.d.ts +1 -3
  19. package/dist/neutral/classes/lib/Insertable.d.ts.map +1 -1
  20. package/dist/neutral/classes/settings/CallerBase.d.ts +1 -1
  21. package/dist/neutral/classes/settings/SettingsQueries.d.ts.map +1 -1
  22. package/dist/neutral/dapp/context/creator/Creator.d.ts +1 -1
  23. package/dist/neutral/dapp/context/creator/Creator.d.ts.map +1 -1
  24. package/dist/neutral/dapp/context/creator/createDappContext.d.ts.map +1 -1
  25. package/dist/neutral/event/bus/EventBus.d.ts +1 -1
  26. package/dist/neutral/event/bus/EventBus.d.ts.map +1 -1
  27. package/dist/neutral/helpers/monitor/XyOsMonitor.d.ts +2 -2
  28. package/dist/neutral/helpers/monitor/XyOsMonitor.d.ts.map +1 -1
  29. package/dist/neutral/helpers/monitor/types.d.ts +2 -2
  30. package/dist/neutral/helpers/monitor/types.d.ts.map +1 -1
  31. package/dist/neutral/index.mjs +42 -36
  32. package/dist/neutral/index.mjs.map +1 -1
  33. package/dist/neutral/lib/Listener.d.ts +1 -1
  34. package/dist/neutral/lib/Listener.d.ts.map +1 -1
  35. package/dist/neutral/loadOsNode.d.ts.map +1 -1
  36. package/dist/neutral/profileModuleEvents.d.ts +1 -3
  37. package/dist/neutral/profileModuleEvents.d.ts.map +1 -1
  38. package/dist/neutral/registration/DappRegistrationService.d.ts +3 -3
  39. package/dist/neutral/registration/DappRegistrationService.d.ts.map +1 -1
  40. package/dist/neutral/registration/DappRegistry.d.ts.map +1 -1
  41. package/dist/neutral/registration/ValidateDappAccessDiviner/Config.d.ts +1 -1
  42. package/dist/neutral/registration/ValidateDappAccessDiviner/Config.d.ts.map +1 -1
  43. package/dist/neutral/scripts/xyos/lib/headless.d.ts.map +1 -1
  44. package/dist/neutral/signer/Signers.d.ts.map +1 -1
  45. package/dist/neutral/stack/Manager.d.ts +2 -6
  46. package/dist/neutral/stack/Manager.d.ts.map +1 -1
  47. package/dist/neutral/system/ManageSystemDapps.d.ts +2 -2
  48. package/dist/neutral/system/ManageSystemDapps.d.ts.map +1 -1
  49. package/dist/node/Caller.d.ts.map +1 -1
  50. package/dist/node/DappCallerBase.d.ts +2 -2
  51. package/dist/node/OsCallerBase.d.ts +2 -2
  52. package/dist/node/RunningDappCache.d.ts.map +1 -1
  53. package/dist/node/XyOs.d.ts +4 -5
  54. package/dist/node/XyOs.d.ts.map +1 -1
  55. package/dist/node/XyOsBase.d.ts +122 -3
  56. package/dist/node/XyOsBase.d.ts.map +1 -1
  57. package/dist/node/XyOsDapp.d.ts +3 -3
  58. package/dist/node/XyOsDapp.d.ts.map +1 -1
  59. package/dist/node/access/Caller.d.ts +1 -1
  60. package/dist/node/access/Caller.d.ts.map +1 -1
  61. package/dist/node/access/RunningAccessDappCache.d.ts.map +1 -1
  62. package/dist/node/access/interfaces/registered-names/helpers/resource/AbstractXnsCaller.d.ts +1 -1
  63. package/dist/node/adapter/Base.d.ts.map +1 -1
  64. package/dist/node/classes/lib/DappCreatorParams.d.ts +3 -3
  65. package/dist/node/classes/lib/DappCreatorParams.d.ts.map +1 -1
  66. package/dist/node/classes/lib/Insertable.d.ts +1 -3
  67. package/dist/node/classes/lib/Insertable.d.ts.map +1 -1
  68. package/dist/node/classes/settings/CallerBase.d.ts +1 -1
  69. package/dist/node/classes/settings/SettingsQueries.d.ts.map +1 -1
  70. package/dist/node/dapp/context/creator/Creator.d.ts +1 -1
  71. package/dist/node/dapp/context/creator/Creator.d.ts.map +1 -1
  72. package/dist/node/dapp/context/creator/createDappContext.d.ts.map +1 -1
  73. package/dist/node/event/bus/EventBus.d.ts +1 -1
  74. package/dist/node/event/bus/EventBus.d.ts.map +1 -1
  75. package/dist/node/helpers/monitor/XyOsMonitor.d.ts +2 -2
  76. package/dist/node/helpers/monitor/XyOsMonitor.d.ts.map +1 -1
  77. package/dist/node/helpers/monitor/types.d.ts +2 -2
  78. package/dist/node/helpers/monitor/types.d.ts.map +1 -1
  79. package/dist/node/index.mjs +42 -36
  80. package/dist/node/index.mjs.map +1 -1
  81. package/dist/node/lib/Listener.d.ts +1 -1
  82. package/dist/node/lib/Listener.d.ts.map +1 -1
  83. package/dist/node/loadOsNode.d.ts.map +1 -1
  84. package/dist/node/profileModuleEvents.d.ts +1 -3
  85. package/dist/node/profileModuleEvents.d.ts.map +1 -1
  86. package/dist/node/registration/DappRegistrationService.d.ts +3 -3
  87. package/dist/node/registration/DappRegistrationService.d.ts.map +1 -1
  88. package/dist/node/registration/DappRegistry.d.ts.map +1 -1
  89. package/dist/node/registration/ValidateDappAccessDiviner/Config.d.ts +1 -1
  90. package/dist/node/registration/ValidateDappAccessDiviner/Config.d.ts.map +1 -1
  91. package/dist/node/scripts/xyos/index.mjs +27 -24
  92. package/dist/node/scripts/xyos/index.mjs.map +1 -1
  93. package/dist/node/scripts/xyos/lib/headless.d.ts.map +1 -1
  94. package/dist/node/signer/Signers.d.ts.map +1 -1
  95. package/dist/node/stack/Manager.d.ts +2 -6
  96. package/dist/node/stack/Manager.d.ts.map +1 -1
  97. package/dist/node/system/ManageSystemDapps.d.ts +2 -2
  98. package/dist/node/system/ManageSystemDapps.d.ts.map +1 -1
  99. package/package.json +134 -49
  100. package/dist/neutral/signer/Signer.spec.d.ts +0 -2
  101. package/dist/neutral/signer/Signer.spec.d.ts.map +0 -1
  102. package/dist/neutral/spec/boot.spec.d.ts +0 -2
  103. package/dist/neutral/spec/boot.spec.d.ts.map +0 -1
  104. package/dist/node/signer/Signer.spec.d.ts +0 -2
  105. package/dist/node/signer/Signer.spec.d.ts.map +0 -1
  106. package/dist/node/spec/boot.spec.d.ts +0 -2
  107. package/dist/node/spec/boot.spec.d.ts.map +0 -1
  108. package/src/Caller.ts +0 -200
  109. package/src/DappCallerBase.ts +0 -55
  110. package/src/DefaultsQueries.ts +0 -27
  111. package/src/OsCallerBase.ts +0 -59
  112. package/src/PubSubBridgeCaller.ts +0 -33
  113. package/src/RunningDappCache.ts +0 -58
  114. package/src/XyOs.ts +0 -166
  115. package/src/XyOsBase.ts +0 -135
  116. package/src/XyOsDapp.ts +0 -106
  117. package/src/access/Caller.ts +0 -85
  118. package/src/access/Queries.ts +0 -38
  119. package/src/access/Resource.ts +0 -65
  120. package/src/access/RunningAccessDappCache.ts +0 -21
  121. package/src/access/index.ts +0 -4
  122. package/src/access/interfaces/index.ts +0 -1
  123. package/src/access/interfaces/registered-names/helpers/AccessNodeQueries.ts +0 -68
  124. package/src/access/interfaces/registered-names/helpers/index.ts +0 -2
  125. package/src/access/interfaces/registered-names/helpers/resource/AbstractXnsCaller.ts +0 -42
  126. package/src/access/interfaces/registered-names/helpers/resource/RegistrationsResource.ts +0 -52
  127. package/src/access/interfaces/registered-names/helpers/resource/RegistrationsResourceQueries.ts +0 -23
  128. package/src/access/interfaces/registered-names/helpers/resource/index.ts +0 -3
  129. package/src/access/interfaces/registered-names/index.ts +0 -1
  130. package/src/adapter/Base.ts +0 -106
  131. package/src/adapter/Network.ts +0 -31
  132. package/src/adapter/Settings.ts +0 -30
  133. package/src/adapter/index.ts +0 -2
  134. package/src/adapters/OsPubSubBridgeNetwork.ts +0 -10
  135. package/src/adapters/OsSettings.ts +0 -7
  136. package/src/adapters/OsXyoPublicNetwork.ts +0 -9
  137. package/src/adapters/index.ts +0 -3
  138. package/src/classes/dapp/DefaultsResource.ts +0 -67
  139. package/src/classes/dapp/index.ts +0 -1
  140. package/src/classes/index.ts +0 -4
  141. package/src/classes/lib/DappCreatorParams.ts +0 -18
  142. package/src/classes/lib/Insertable.ts +0 -10
  143. package/src/classes/lib/index.ts +0 -2
  144. package/src/classes/menu/Caller.ts +0 -76
  145. package/src/classes/menu/Queries.ts +0 -60
  146. package/src/classes/menu/Resource.ts +0 -105
  147. package/src/classes/menu/index.ts +0 -2
  148. package/src/classes/settings/Caller.ts +0 -78
  149. package/src/classes/settings/CallerBase.ts +0 -27
  150. package/src/classes/settings/Resource.ts +0 -81
  151. package/src/classes/settings/SettingsQueries.ts +0 -56
  152. package/src/classes/settings/badge/Caller.ts +0 -30
  153. package/src/classes/settings/badge/Queries.ts +0 -19
  154. package/src/classes/settings/badge/Resource.ts +0 -50
  155. package/src/classes/settings/badge/index.ts +0 -2
  156. package/src/classes/settings/index.ts +0 -5
  157. package/src/dapp/context/creator/Creator.ts +0 -122
  158. package/src/dapp/context/creator/DefaultPayloads/DappAccessPayloads.ts +0 -20
  159. package/src/dapp/context/creator/DefaultPayloads/DefaultPayloads.ts +0 -40
  160. package/src/dapp/context/creator/DefaultPayloads/NodeInfoPayload.ts +0 -33
  161. package/src/dapp/context/creator/DefaultPayloads/index.ts +0 -1
  162. package/src/dapp/context/creator/ExternalModulePermissions/ExternalModulePermissions.ts +0 -59
  163. package/src/dapp/context/creator/ExternalModulePermissions/index.ts +0 -1
  164. package/src/dapp/context/creator/createDappContext.ts +0 -61
  165. package/src/dapp/context/creator/index.ts +0 -3
  166. package/src/dapp/context/index.ts +0 -1
  167. package/src/dapp/index.ts +0 -1
  168. package/src/event/bus/Connection.ts +0 -31
  169. package/src/event/bus/EventBus.ts +0 -160
  170. package/src/event/bus/PubSubConnection.ts +0 -28
  171. package/src/event/bus/index.ts +0 -3
  172. package/src/event/connections/DappAccessRequest.ts +0 -11
  173. package/src/event/connections/DappsReady.ts +0 -9
  174. package/src/event/connections/ExposeDappRequest.ts +0 -11
  175. package/src/event/connections/OsPubSubNetworkReady.ts +0 -12
  176. package/src/event/connections/OsSettingsReady.ts +0 -12
  177. package/src/event/connections/OsXyoPublicReady.ts +0 -12
  178. package/src/event/connections/index.ts +0 -6
  179. package/src/event/index.ts +0 -2
  180. package/src/helpers/index.ts +0 -1
  181. package/src/helpers/monitor/XyOsMonitor.ts +0 -52
  182. package/src/helpers/monitor/index.ts +0 -2
  183. package/src/helpers/monitor/types.ts +0 -8
  184. package/src/index.ts +0 -29
  185. package/src/initializer/DappInitializer.ts +0 -57
  186. package/src/initializer/index.ts +0 -1
  187. package/src/intent/Caller.ts +0 -74
  188. package/src/intent/Resource.ts +0 -66
  189. package/src/intent/index.ts +0 -2
  190. package/src/lib/ExternalStore.ts +0 -7
  191. package/src/lib/Listener.ts +0 -1
  192. package/src/lib/ModuleAccountPaths.ts +0 -23
  193. package/src/lib/ModuleNames.ts +0 -3
  194. package/src/lib/NameTransforms.ts +0 -34
  195. package/src/lib/PayloadStore.ts +0 -105
  196. package/src/lib/ResourceStores.ts +0 -7
  197. package/src/lib/index.ts +0 -11
  198. package/src/lib/initializeXns.ts +0 -16
  199. package/src/lib/isEqual.ts +0 -42
  200. package/src/lib/isPayload.ts +0 -24
  201. package/src/lib/tokenPlacesSplit.ts +0 -17
  202. package/src/loadOsNode.ts +0 -44
  203. package/src/manifest/index.ts +0 -2
  204. package/src/manifest/manifestReplacementTokens.ts +0 -6
  205. package/src/manifest/os-node.manifest.json +0 -132
  206. package/src/manifests/dapp-window.manifest.json +0 -36
  207. package/src/manifests/index.ts +0 -1
  208. package/src/models/access/ValidDappAccessInterfaces.ts +0 -6
  209. package/src/models/access/index.ts +0 -1
  210. package/src/models/index.ts +0 -1
  211. package/src/profileModuleEvents.ts +0 -43
  212. package/src/registration/DappRegistrationService.ts +0 -180
  213. package/src/registration/DappRegistry.ts +0 -129
  214. package/src/registration/ValidateDappAccessDiviner/Config.ts +0 -24
  215. package/src/registration/ValidateDappAccessDiviner/Diviner.ts +0 -133
  216. package/src/registration/ValidateDappAccessDiviner/index.ts +0 -2
  217. package/src/registration/index.ts +0 -2
  218. package/src/scripts/xyos/command/config.ts +0 -19
  219. package/src/scripts/xyos/command/create.ts +0 -22
  220. package/src/scripts/xyos/command/index.ts +0 -7
  221. package/src/scripts/xyos/command/manifest.ts +0 -19
  222. package/src/scripts/xyos/command/start.ts +0 -35
  223. package/src/scripts/xyos/index.ts +0 -31
  224. package/src/scripts/xyos/lib/createFromTemplate.ts +0 -11
  225. package/src/scripts/xyos/lib/headless.ts +0 -68
  226. package/src/scripts/xyos/lib/index.ts +0 -2
  227. package/src/signer/Signer.spec.ts +0 -65
  228. package/src/signer/Signers.ts +0 -74
  229. package/src/signer/index.ts +0 -1
  230. package/src/spec/boot.spec.ts +0 -89
  231. package/src/stack/Base.ts +0 -165
  232. package/src/stack/Manager.ts +0 -51
  233. package/src/stack/Map.ts +0 -22
  234. package/src/stack/OsPubSubNetworkStack.ts +0 -70
  235. package/src/stack/OsSettingsStack.ts +0 -24
  236. package/src/stack/XyoPublicNetworkStack.ts +0 -32
  237. package/src/stack/index.ts +0 -6
  238. package/src/system/ManageSystemDapps.ts +0 -148
  239. package/src/system/Queries.ts +0 -69
  240. package/src/system/index.ts +0 -1
  241. package/src/types/global.d.ts +0 -9
  242. package/src/types/images.d.ts +0 -5
  243. package/src/utils/buildWalletSeedPhrasePayload.ts +0 -51
  244. package/src/utils/getApiDomain.ts +0 -14
  245. package/src/utils/index.ts +0 -3
  246. package/src/utils/renameObjKey.ts +0 -22
  247. package/src/wallet/DappSeedPhraseRepository.ts +0 -99
  248. package/src/wallet/SeedPhraseRepository.ts +0 -31
  249. package/src/wallet/index.ts +0 -2
@@ -1,133 +0,0 @@
1
- import type { Address } from '@xylabs/sdk-js'
2
- import { AbstractDiviner } from '@xyo-network/diviner-abstract'
3
- import type { NodeManifestPayload, PackageManifestPayload } from '@xyo-network/manifest'
4
- import { ManifestWrapper, PackageManifestPayloadSchema } from '@xyo-network/manifest'
5
- import { ModuleFactoryLocator } from '@xyo-network/module-factory-locator'
6
- import type { NodeInstance } from '@xyo-network/node-model'
7
- import type {
8
- DappPackageManifestPayload,
9
- DappParams,
10
- RegisteredDappAccess,
11
- UnregisteredDappAccess,
12
- } from '@xyo-network/os-model'
13
- import {
14
- isDappPackageManifestPayload,
15
- isUnregisteredDappAccess,
16
- RegisteredDappAccessSchema,
17
- } from '@xyo-network/os-model'
18
- import { HDWallet } from '@xyo-network/wallet'
19
-
20
- import { ValidDappAccessInterfaces } from '../../models/index.ts'
21
- import type {
22
- FailedAccessor,
23
- ValidateDappAccessDivinerIn,
24
- ValidateDappAccessDivinerOut,
25
- ValidateDappAccessDivinerParams,
26
- } from './Config.ts'
27
- import {
28
- FailedAccessorSchema,
29
- ValidateDappAccessDivinerConfigSchema,
30
- } from './Config.ts'
31
-
32
- // Validate the accessors of a dapp against the dapp access interfaces
33
- export class ValidateDappAccessDiviner<TParams extends ValidateDappAccessDivinerParams = ValidateDappAccessDivinerParams> extends AbstractDiviner<
34
- TParams,
35
- ValidateDappAccessDivinerIn,
36
- ValidateDappAccessDivinerOut
37
- > {
38
- static override configSchemas = [ValidateDappAccessDivinerConfigSchema]
39
-
40
- protected override async divineHandler(payloads?: ValidateDappAccessDivinerIn[]): Promise<ValidateDappAccessDivinerOut[]> {
41
- const dappManifest = payloads?.filter(isDappPackageManifestPayload) as DappPackageManifestPayload[]
42
- const accessors = payloads?.filter(isUnregisteredDappAccess) as UnregisteredDappAccess[]
43
- const dappParams = this.params.dappParams
44
-
45
- if (dappManifest.length > 1) {
46
- throw new Error('Only one dapp manifest payload is allowed')
47
- }
48
-
49
- if (!dappManifest || dappManifest.length === 0 || accessors?.length === 0) {
50
- return []
51
- }
52
-
53
- const registeredAccessors: RegisteredDappAccess[] = []
54
- const failedAccessors: FailedAccessor[] = []
55
-
56
- for (const access of accessors) {
57
- try {
58
- if (access) {
59
- const dappAccessInterface = ValidDappAccessInterfaces[access.name]
60
- if (!dappAccessInterface) {
61
- console.warn('Invalid dapp access interface', access.name)
62
- continue
63
- }
64
-
65
- const dappManifestToTest = dappPackageManifestToPackageManifest(dappManifest[0])
66
- const dappChildren = await getNodeChildren(dappManifestToTest, dappParams)
67
- const interfaceChildren = await getNodeChildren(dappAccessInterface.manifest, dappParams)
68
- const valid = compareChildren(interfaceChildren, dappChildren)
69
- if (valid) {
70
- const payload: RegisteredDappAccess = {
71
- ...access,
72
- schema: RegisteredDappAccessSchema,
73
- timestamp: Date.now(),
74
- }
75
- registeredAccessors.push(payload)
76
- } else {
77
- const failedRegistration: FailedAccessor = {
78
- accessor: access,
79
- errorMessage: 'Invalid dapp access interface',
80
- schema: FailedAccessorSchema,
81
- }
82
- failedAccessors.push(failedRegistration)
83
- }
84
- }
85
- } catch (e) {
86
- failedAccessors.push(
87
- {
88
- accessor: access, errorMessage: (e as Error).message, schema: FailedAccessorSchema,
89
- } as FailedAccessor,
90
- )
91
- }
92
- }
93
-
94
- return [...registeredAccessors, ...failedAccessors]
95
- }
96
- }
97
-
98
- const compareChildren = (interfaceChildren: Record<Address, string | null>[], dappChildren: Record<Address, string | null>[]) => {
99
- return interfaceChildren.every(interfaceChild =>
100
- Object.values(interfaceChild).every(interfaceChildName =>
101
- dappChildren.some(dappChild => Object.values(dappChild).includes(interfaceChildName))))
102
- }
103
-
104
- const dappPackageManifestToPackageManifest = (dappPackageManifest: DappPackageManifestPayload): PackageManifestPayload => {
105
- return {
106
- ...dappPackageManifest,
107
- schema: PackageManifestPayloadSchema,
108
- }
109
- }
110
-
111
- const getChildrenFromNode = async (node: NodeInstance) => {
112
- const nodeManifest = (await node.state())?.[0] as NodeManifestPayload
113
- return nodeManifest.status?.children
114
- }
115
-
116
- const getNodeChildren = async (manifestToTest: PackageManifestPayload, dappParams: DappParams) => {
117
- const testNodes = await getNodeToTest(manifestToTest, dappParams)
118
-
119
- const children: Record<Address, string | null>[] = []
120
- for (const node of testNodes) {
121
- const nodeChildren = await getChildrenFromNode(node)
122
- if (nodeChildren) {
123
- children.push(nodeChildren)
124
- }
125
- }
126
-
127
- return children
128
- }
129
-
130
- const getNodeToTest = async (manifestToTest: PackageManifestPayload, dappParams: DappParams) => {
131
- const dappManifestWrapper = new ManifestWrapper(manifestToTest, await HDWallet.random(), dappParams.locator ?? new ModuleFactoryLocator())
132
- return await dappManifestWrapper.loadNodes()
133
- }
@@ -1,2 +0,0 @@
1
- export * from './Config.ts'
2
- export * from './Diviner.ts'
@@ -1,2 +0,0 @@
1
- export * from './DappRegistrationService.ts'
2
- export * from './DappRegistry.ts'
@@ -1,19 +0,0 @@
1
- import type { Argv } from 'yargs'
2
-
3
- export const commandConfig = (argv: Argv) => {
4
- return argv.command('config [action] <target>', 'Create an xyos project', (yargs) => {
5
- return yargs
6
- .positional('action', {
7
- choices: ['create', 'validate', 'display'],
8
- description: 'Action to take on config',
9
- type: 'string',
10
- })
11
- .positional('target', {
12
- description: 'Location of config file',
13
- type: 'string',
14
- })
15
- }, async ({ action, target }) => {
16
- console.log(`Taking action [${action}] on manifest at ${target}`)
17
- return await Promise.resolve()
18
- })
19
- }
@@ -1,22 +0,0 @@
1
- import type { Argv } from 'yargs'
2
-
3
- import type { TemplateName } from '../lib/index.ts'
4
- import { createFromTemplate } from '../lib/index.ts'
5
-
6
- export const commandCreate = (argv: Argv) => {
7
- return argv.command('create [template] <target>', 'Create an xyos project', (yargs) => {
8
- return yargs
9
- .positional('template', {
10
- choices: ['react', 'headless', 'dapp', 'diviner', 'witness'] as TemplateName[],
11
- description: 'Template to use',
12
- type: 'string',
13
- })
14
- .positional('target', {
15
- description: 'Location into which to create the template project',
16
- type: 'string',
17
- })
18
- }, async ({ template, target }) => {
19
- console.log(`Using template ${template} at location ${target}`)
20
- return await createFromTemplate({ target, template })
21
- })
22
- }
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env node
2
- // TODO - figure out how to keep the above line from being removed by the build process
3
-
4
- export * from './config.ts'
5
- export * from './create.ts'
6
- export * from './manifest.ts'
7
- export * from './start.ts'
@@ -1,19 +0,0 @@
1
- import type { Argv } from 'yargs'
2
-
3
- export const commandManifest = (argv: Argv) => {
4
- return argv.command('manifest [action] <target>', 'Create an xyos project', (yargs) => {
5
- return yargs
6
- .positional('action', {
7
- choices: ['create', 'validate', 'display'],
8
- description: 'Action to take on manifest',
9
- type: 'string',
10
- })
11
- .positional('target', {
12
- description: 'Location of manifest file',
13
- type: 'string',
14
- })
15
- }, async ({ action, target }) => {
16
- console.log(`Taking action [${action}] on manifest at ${target}`)
17
- return await Promise.resolve()
18
- })
19
- }
@@ -1,35 +0,0 @@
1
- import type { NativeKernelDrivers } from '@xyo-network/kernel-model'
2
- import type { Argv } from 'yargs'
3
-
4
- import { headless } from '../lib/index.ts'
5
-
6
- export const commandStart = (argv: Argv) => {
7
- return argv.command('start', 'Start xyOS in headless mode', (yargs) => {
8
- return yargs
9
- .option('config', {
10
- alias: 'c',
11
- description: 'Config file to use',
12
- type: 'string',
13
- }).option('manifest', {
14
- alias: 'm',
15
- description: 'Manifest file to use',
16
- type: 'string',
17
- }).option('kernelDriver', {
18
- alias: 'k',
19
- description: 'Kernel driver to load',
20
- type: 'string',
21
- })
22
- }, async ({
23
- config, manifest, kernelDriver,
24
- }) => {
25
- if (config) {
26
- console.log(`Using config: ${config}`)
27
- }
28
- if (config) {
29
- console.log(`Using manifest: ${manifest}`)
30
- }
31
- await headless({
32
- manifest, config, kernelDrivers: kernelDriver ? [kernelDriver as NativeKernelDrivers] : [],
33
- })
34
- })
35
- }
@@ -1,31 +0,0 @@
1
- import yargs from 'yargs'
2
- import { hideBin } from 'yargs/helpers'
3
-
4
- import {
5
- commandConfig, commandCreate, commandManifest, commandStart,
6
- } from './command/index.ts'
7
-
8
- (
9
- (
10
- commandManifest(
11
- commandConfig(
12
- commandCreate(
13
- commandStart(
14
- yargs(
15
- hideBin(
16
- process.argv,
17
- ),
18
- ),
19
- ),
20
- ),
21
- ),
22
- )
23
- .usage('Usage: $0 <command> [options]')
24
- .scriptName('xyos')
25
- .demandCommand(1)
26
- .parse()
27
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
28
- ) as Promise<any>
29
- ).catch(
30
- console.error,
31
- )
@@ -1,11 +0,0 @@
1
- export type TemplateName = 'react' | 'headless' | 'dapp' | 'diviner' | 'witness'
2
-
3
- export interface CreateFromTemplateParams {
4
- target?: string
5
- template?: TemplateName
6
- }
7
-
8
- export const createFromTemplate = async ({ target, template }: CreateFromTemplateParams) => {
9
- console.log('Creating from template', template, 'at', target)
10
- return await Promise.resolve()
11
- }
@@ -1,68 +0,0 @@
1
- import fs from 'node:fs'
2
-
3
- import { boot } from '@xyo-network/bios'
4
- import { Kernel } from '@xyo-network/kernel'
5
- import type { NativeKernelDrivers } from '@xyo-network/kernel-model'
6
- import type { PackageManifest } from '@xyo-network/manifest'
7
- import { HDWallet } from '@xyo-network/wallet'
8
- import chalk from 'chalk'
9
- import { cosmiconfig } from 'cosmiconfig'
10
- import { TypeScriptLoader } from 'cosmiconfig-typescript-loader'
11
- import tk from 'terminal-kit'
12
-
13
- const { terminal } = tk
14
-
15
- import { XyOs } from '../../../XyOs.ts'
16
-
17
- const terminate = () => {
18
- terminal.grabInput(false)
19
- setTimeout(function () {
20
- // eslint-disable-next-line unicorn/no-process-exit
21
- process.exit(0)
22
- }, 100)
23
- }
24
-
25
- interface XyOsConfig {
26
- developmentMode?: boolean
27
- manifest?: string | PackageManifest
28
- }
29
-
30
- export interface HeadlessParams {
31
- config?: string
32
- kernelDrivers?: NativeKernelDrivers[]
33
- manifest?: string
34
- }
35
-
36
- export const headless = async ({
37
- manifest, config, kernelDrivers,
38
- }: HeadlessParams = {}) => {
39
- console.log(chalk.green('Starting Headless xyOS...'))
40
- const configExplorer = cosmiconfig('xyos', { cache: true, loaders: { '.ts': TypeScriptLoader() } })
41
- const configResult = await (config ? configExplorer.load(config) : configExplorer.search())
42
- const xyosConfig: XyOsConfig = (configResult?.config ?? {}) as XyOsConfig
43
- const manifestToLoad: string | undefined = manifest ?? (typeof xyosConfig.manifest === 'string' ? xyosConfig.manifest : undefined)
44
- const manifestObject: PackageManifest | undefined = manifestToLoad
45
- ? JSON.parse(fs.readFileSync(manifestToLoad, 'utf8')) as PackageManifest
46
- : typeof xyosConfig.manifest === 'object' ? xyosConfig.manifest : undefined
47
-
48
- const osWallet = await HDWallet.random()
49
- const kernel = new Kernel({ logColor: 'cyan', logger: console })
50
- await kernel.boot(await boot(), { kernelDrivers })
51
- const xyOs = new XyOs({
52
- kernel,
53
- stackMap: {},
54
- manifest: manifestObject,
55
- developmentMode: xyosConfig.developmentMode,
56
- })
57
- await xyOs.boot(osWallet)
58
- console.log(chalk.green('Started Headless xyOS...'))
59
-
60
- terminal.grabInput({ mouse: 'button' })
61
-
62
- terminal.on('key', function (name: string) {
63
- console.log("'key' event:", name)
64
- if (name === 'CTRL_C') {
65
- terminate()
66
- }
67
- })
68
- }
@@ -1,2 +0,0 @@
1
- export * from './createFromTemplate.ts'
2
- export * from './headless.ts'
@@ -1,65 +0,0 @@
1
- import type { WalletKindSignerPaths } from '@xyo-network/os-model'
2
- import type { WalletKind, WalletSeedPhraseStore } from '@xyo-network/storage-model'
3
- import { HDWallet } from '@xyo-network/wallet'
4
- import {
5
- beforeEach,
6
- describe,
7
- expect,
8
- it,
9
- vi,
10
- } from 'vitest'
11
-
12
- import { Signers } from './Signers.ts'
13
-
14
- describe('Signer', () => {
15
- let osWallet: string
16
- let userWallet: string
17
- let seedPhraseStore: WalletSeedPhraseStore
18
-
19
- const testSigner1Path = '0/0'
20
- const testSigner2Path = '0/1'
21
- const testSigner3Path = '0/2'
22
- const testSigner4Path = '0/3'
23
-
24
- const osPaths = new Map([['testSigner0', testSigner1Path], ['testSigner1', testSigner2Path]])
25
- const userPaths = new Map([['testSigner2', testSigner3Path], ['testSigner3', testSigner4Path]])
26
- const paths: WalletKindSignerPaths = new Map([['os', osPaths], ['user', userPaths]])
27
-
28
- let signers: Signers
29
-
30
- beforeEach(async () => {
31
- osWallet = HDWallet.generateMnemonic()
32
- userWallet = HDWallet.generateMnemonic()
33
- seedPhraseStore = {
34
- get: vi.fn().mockImplementation((key: WalletKind) => {
35
- if (key === 'os') {
36
- return osWallet
37
- }
38
- if (key === 'user') {
39
- return userWallet
40
- }
41
- return
42
- }),
43
- set: vi.fn(),
44
- delete: vi.fn(),
45
- }
46
- signers = new Signers(paths, seedPhraseStore)
47
- await signers.initialize()
48
- })
49
-
50
- it('should initialize signers', () => {
51
- expect(signers.getSigner('os', 'testSigner0')).toBeDefined()
52
- expect(signers.getSigner('os', 'testSigner1')).toBeDefined()
53
- expect(signers.getSigner('user', 'testSigner2')).toBeDefined()
54
- expect(signers.getSigner('user', 'testSigner3')).toBeDefined()
55
- })
56
-
57
- it('should return undefined for non-existent signer', () => {
58
- expect(signers.getSigner('os', 'nonExistentSigner')).toBeUndefined()
59
- })
60
-
61
- it('should use paths correctly', async () => {
62
- const osWalletAddress = (await (await HDWallet.fromPhrase(osWallet)).derivePath(testSigner1Path)).address
63
- expect(signers.getSigner('os', 'testSigner0')?.address).toBe(osWalletAddress)
64
- })
65
- })
@@ -1,74 +0,0 @@
1
- import { assertEx } from '@xylabs/sdk-js'
2
- import { type AccountInstance } from '@xyo-network/account-model'
3
- import type {
4
- SignerAccounts, SignersExternal, WalletKindSignerPaths,
5
- } from '@xyo-network/os-model'
6
- import type {
7
- WalletKind,
8
- WalletSeedPhraseStore,
9
- } from '@xyo-network/storage-model'
10
- import { HDWallet } from '@xyo-network/wallet'
11
-
12
- export class Signers implements SignersExternal {
13
- private _paths: WalletKindSignerPaths
14
- private _signerAccounts: Map<WalletKind, SignerAccounts>
15
- private _walletStore: WalletSeedPhraseStore
16
-
17
- constructor(paths: WalletKindSignerPaths, walletStore: WalletSeedPhraseStore) {
18
- this._paths = paths
19
- this._walletStore = walletStore
20
- this._signerAccounts = new Map()
21
- }
22
-
23
- private get paths(): WalletKindSignerPaths {
24
- return assertEx(this._paths, () => 'Paths not initialized')
25
- }
26
-
27
- private get signerAccounts(): Map<WalletKind, SignerAccounts> {
28
- return assertEx(this._signerAccounts, () => 'Signer accounts not initialized')
29
- }
30
-
31
- private get walletStore(): WalletSeedPhraseStore {
32
- return assertEx(this._walletStore, () => 'Wallet store not initialized')
33
- }
34
-
35
- getSigner(walletKind: WalletKind, signer: string): AccountInstance | undefined {
36
- return this.signerAccounts.get(walletKind)?.get(signer)
37
- }
38
-
39
- getWalletKindSigner(walletKind: WalletKind): SignerAccounts | undefined {
40
- return this.signerAccounts.get(walletKind)
41
- }
42
-
43
- async initialize() {
44
- for (const [walletKindName, signerPaths] of this.paths) {
45
- for (const [signerName, walletPath] of signerPaths.entries()) {
46
- await this.initializeSigners(walletKindName, signerName, walletPath)
47
- }
48
- }
49
- }
50
-
51
- private async initializeSigners(walletKindName: WalletKind, signerName: string, path: string) {
52
- // test if the name and path are valid
53
- assertEx(signerName, () => 'Name not found in signer paths')
54
- assertEx(path, () => 'Path not found in signer paths')
55
-
56
- // test if the wallet exists
57
- const phrase = assertEx(await this.walletStore.get(walletKindName), () => `Wallet not found: ${walletKindName}`)
58
-
59
- if (path) {
60
- // get the signer map for the wallet kind or create a new one
61
- const signerMap = this.signerAccounts.get(walletKindName) ?? new Map()
62
-
63
- // derive the wallet from the path
64
- const wallet = await HDWallet.fromPhrase(phrase)
65
- const derivedWallet = await wallet.derivePath(path)
66
-
67
- // add the derived wallet to the signer map
68
- signerMap.set(signerName, derivedWallet)
69
-
70
- // set the signer map for the wallet kind
71
- this.signerAccounts.set(walletKindName, signerMap)
72
- }
73
- }
74
- }
@@ -1 +0,0 @@
1
- export * from './Signers.ts'
@@ -1,89 +0,0 @@
1
- import type { BiosExternalInterface } from '@xyo-network/bios-model'
2
- import { boot } from '@xyo-network/bios-nodejs'
3
- import { Kernel } from '@xyo-network/kernel'
4
- import type { KernelExternal } from '@xyo-network/kernel-model'
5
- import type { WalletKindSignerPaths } from '@xyo-network/os-model'
6
- import { HDWallet } from '@xyo-network/wallet'
7
- import type { WalletInstance } from '@xyo-network/wallet-model'
8
- import {
9
- beforeEach,
10
- describe, expect, test,
11
- } from 'vitest'
12
-
13
- import type { DappRegistrationServiceParams } from '../registration/index.ts'
14
- import { XyOs } from '../XyOs.ts'
15
-
16
- describe('os', () => {
17
- let bios: BiosExternalInterface
18
- let osWallet: WalletInstance
19
- let kernel: KernelExternal
20
-
21
- const testSigner0Path = '0/0'
22
- const testSigner1Path = '0/1'
23
- const userPaths = new Map([['testSigner0', testSigner0Path], ['testSigner1', testSigner1Path]])
24
- const paths: WalletKindSignerPaths = new Map([['user', userPaths]])
25
-
26
- beforeEach(async () => {
27
- bios = await boot()
28
- const osWalletSeedPhrase = await bios.seedPhraseStore.get('os')
29
- osWallet = await HDWallet.fromPhrase(osWalletSeedPhrase as string)
30
- kernel = new Kernel({ bios })
31
- })
32
-
33
- describe('boot', () => {
34
- test('with default params', async () => {
35
- const xyOs = new XyOs()
36
- await xyOs.boot(osWallet)
37
- expect(xyOs).toBeDefined()
38
- })
39
-
40
- test('with dapps', async () => {
41
- const dappsConfiguration: DappRegistrationServiceParams = {
42
- dappNames: ['testDapp'],
43
- dappParams: {},
44
- dappPayloads: [],
45
- }
46
-
47
- const xyOs = new XyOs({ dappsConfiguration })
48
- await xyOs.boot(osWallet)
49
- expect(xyOs).toBeDefined()
50
- })
51
-
52
- test('default stacks', async () => {
53
- const bios = await boot()
54
- const kernel = new Kernel()
55
- await kernel.boot(bios)
56
- const xyOs = new XyOs({ kernel })
57
- expect(xyOs).toBeDefined()
58
- if (xyOs) {
59
- const osWalletSeedPhrase = await bios.seedPhraseStore.get('os')
60
- expect(osWalletSeedPhrase).toBeDefined()
61
- const osWallet = await HDWallet.fromPhrase(osWalletSeedPhrase as string)
62
- expect(osWallet).toBeDefined()
63
- await xyOs.boot(osWallet)
64
- }
65
- })
66
-
67
- test('no stacks', async () => {
68
- const xyOs = new XyOs({ stackMap: {} })
69
- expect(xyOs).toBeDefined()
70
- if (xyOs) {
71
- await xyOs.boot(osWallet)
72
- }
73
- })
74
-
75
- test('supports users signing', async () => {
76
- const params = { kernel, signerPaths: paths }
77
-
78
- const xyOs = new XyOs(params)
79
-
80
- expect(xyOs).toBeDefined()
81
-
82
- if (xyOs) {
83
- await xyOs.boot(osWallet)
84
- expect(xyOs.user).toBeDefined()
85
- expect(xyOs.user.signers).toBeDefined()
86
- }
87
- })
88
- })
89
- })