@xyo-network/os-runtime 3.0.9 → 3.0.10
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/index.d.ts +88 -70
- package/dist/neutral/index.mjs +63 -6
- package/dist/neutral/index.mjs.map +1 -1
- package/package.json +14 -13
- package/src/XyOs.ts +14 -3
- package/src/XyOsDapp.ts +4 -0
- package/src/classes/index.ts +1 -0
- package/src/classes/node/Creator.ts +1 -1
- package/src/classes/signer/Signers.ts +69 -0
- package/src/classes/signer/index.ts +1 -0
- package/src/stack/Manager.ts +8 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/os-runtime",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.10",
|
|
4
4
|
"description": "Primary SDK for using XYO Protocol 2.0",
|
|
5
5
|
"homepage": "https://xyo.network",
|
|
6
6
|
"bugs": {
|
|
@@ -39,16 +39,17 @@
|
|
|
39
39
|
"@xyo-network/archivist": "^3.0.7",
|
|
40
40
|
"@xyo-network/archivist-indexeddb": "^3.0.7",
|
|
41
41
|
"@xyo-network/archivist-model": "^3.0.7",
|
|
42
|
-
"@xyo-network/bios": "^3.0.
|
|
43
|
-
"@xyo-network/
|
|
44
|
-
"@xyo-network/
|
|
45
|
-
"@xyo-network/diviner-
|
|
46
|
-
"@xyo-network/diviner-
|
|
47
|
-
"@xyo-network/diviner-payload-
|
|
48
|
-
"@xyo-network/diviner-payload-
|
|
49
|
-
"@xyo-network/diviner-
|
|
50
|
-
"@xyo-network/
|
|
51
|
-
"@xyo-network/kernel
|
|
42
|
+
"@xyo-network/bios": "^3.0.10",
|
|
43
|
+
"@xyo-network/bios-model": "^3.0.10",
|
|
44
|
+
"@xyo-network/bridge-model": "^3.0.5",
|
|
45
|
+
"@xyo-network/diviner-abstract": "^3.0.5",
|
|
46
|
+
"@xyo-network/diviner-model": "^3.0.5",
|
|
47
|
+
"@xyo-network/diviner-payload-generic": "^3.0.5",
|
|
48
|
+
"@xyo-network/diviner-payload-indexeddb": "^3.0.5",
|
|
49
|
+
"@xyo-network/diviner-payload-model": "^3.0.5",
|
|
50
|
+
"@xyo-network/diviner-temporal-indexing-model": "^3.0.5",
|
|
51
|
+
"@xyo-network/kernel": "^3.0.10",
|
|
52
|
+
"@xyo-network/kernel-model": "^3.0.10",
|
|
52
53
|
"@xyo-network/manifest": "^3.0.7",
|
|
53
54
|
"@xyo-network/manifest-wrapper": "^3.0.7",
|
|
54
55
|
"@xyo-network/module-abstract": "^3.0.7",
|
|
@@ -57,7 +58,7 @@
|
|
|
57
58
|
"@xyo-network/module-model": "^3.0.7",
|
|
58
59
|
"@xyo-network/module-resolver": "^3.0.7",
|
|
59
60
|
"@xyo-network/node-model": "^3.0.7",
|
|
60
|
-
"@xyo-network/os-model": "^3.0.
|
|
61
|
+
"@xyo-network/os-model": "^3.0.10",
|
|
61
62
|
"@xyo-network/payload-builder": "^3.0.7",
|
|
62
63
|
"@xyo-network/payload-model": "^3.0.7",
|
|
63
64
|
"@xyo-network/wallet-model": "^3.0.7",
|
|
@@ -71,7 +72,7 @@
|
|
|
71
72
|
"@types/uuid": "^10.0.0",
|
|
72
73
|
"@xylabs/ts-scripts-yarn3": "^4.0.0",
|
|
73
74
|
"@xylabs/tsconfig": "^4.0.0",
|
|
74
|
-
"@xyo-network/bios-nodejs": "^3.0.
|
|
75
|
+
"@xyo-network/bios-nodejs": "^3.0.10",
|
|
75
76
|
"typescript": "^5.5.4",
|
|
76
77
|
"vitest": "^2.0.5"
|
|
77
78
|
},
|
package/src/XyOs.ts
CHANGED
|
@@ -23,7 +23,7 @@ import { EventBus } from './event/index.ts'
|
|
|
23
23
|
import type { MonitorEventConfig, XyOsMonitor } from './helpers/index.ts'
|
|
24
24
|
import { NameTransforms } from './lib/index.ts'
|
|
25
25
|
import { loadOsNode } from './loadOsNode.ts'
|
|
26
|
-
import type { OsPubSubNetworkStack } from './stack/index.ts'
|
|
26
|
+
import type { OsPubSubNetworkStack, UninitializedStackMap } from './stack/index.ts'
|
|
27
27
|
import { OsStackMap, StackManager } from './stack/index.ts'
|
|
28
28
|
import type { XyOsContextParams } from './XyOsBase.ts'
|
|
29
29
|
import { XyOsContextBase } from './XyOsBase.ts'
|
|
@@ -32,6 +32,7 @@ export interface XyOsParams<TManifest extends PackageManifest = PackageManifest>
|
|
|
32
32
|
dappsConfiguration?: DappRegistrationServiceParams
|
|
33
33
|
developmentMode?: boolean
|
|
34
34
|
kernel?: XyOsContext['kernel']
|
|
35
|
+
stackMap?: UninitializedStackMap
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
export class XyOs extends XyOsContextBase<XyOsParams> implements XyOsContext {
|
|
@@ -43,14 +44,20 @@ export class XyOs extends XyOsContextBase<XyOsParams> implements XyOsContext {
|
|
|
43
44
|
private stackManager: StackManager
|
|
44
45
|
|
|
45
46
|
constructor({
|
|
46
|
-
eventBus = new EventBus(),
|
|
47
|
+
eventBus = new EventBus(),
|
|
48
|
+
kernel = new Kernel(),
|
|
49
|
+
locator = new ModuleFactoryLocator(),
|
|
50
|
+
dappsConfiguration,
|
|
51
|
+
developmentMode,
|
|
52
|
+
stackMap = OsStackMap,
|
|
53
|
+
...params
|
|
47
54
|
}: XyOsParams = {}) {
|
|
48
55
|
super({
|
|
49
56
|
eventBus, kernel, locator, ...params,
|
|
50
57
|
})
|
|
51
58
|
this._locator = locator
|
|
52
59
|
this._kernel = kernel
|
|
53
|
-
this.stackManager = new StackManager(
|
|
60
|
+
this.stackManager = new StackManager(stackMap)
|
|
54
61
|
this.dappRegistrationService = new DappRegistrationService(this, dappsConfiguration, this.locator, developmentMode)
|
|
55
62
|
}
|
|
56
63
|
|
|
@@ -82,6 +89,10 @@ export class XyOs extends XyOsContextBase<XyOsParams> implements XyOsContext {
|
|
|
82
89
|
return this._locator
|
|
83
90
|
}
|
|
84
91
|
|
|
92
|
+
get stacks() {
|
|
93
|
+
return this.stackManager.stacks
|
|
94
|
+
}
|
|
95
|
+
|
|
85
96
|
static async monitor<T>(fn: () => Promise<T>, eventConfig: MonitorEventConfig): Promise<T> {
|
|
86
97
|
const { name, additionalProperties } = eventConfig
|
|
87
98
|
const monitor = this.monitoring
|
package/src/XyOsDapp.ts
CHANGED
|
@@ -52,6 +52,10 @@ export class XyOsDapp extends XyOsContextBase<XyOsDappContextParams> implements
|
|
|
52
52
|
return this.params.parent
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
get stacks() {
|
|
56
|
+
return []
|
|
57
|
+
}
|
|
58
|
+
|
|
55
59
|
override async boot(wallet: WalletInstance, locator?: ModuleFactoryLocator): Promise<void> {
|
|
56
60
|
return await this._bootMutex.runExclusive(async () => {
|
|
57
61
|
console.log('XyOsDapp:boot:start', wallet.address, this.dapp.id)
|
package/src/classes/index.ts
CHANGED
|
@@ -62,7 +62,7 @@ export class DappContextCreator {
|
|
|
62
62
|
// Reset the dapp archivist to remove all payloads
|
|
63
63
|
static async resetDappArchivist(context: XyOsContext) {
|
|
64
64
|
const dappModule = await context.root.resolve('DappArchivist')
|
|
65
|
-
const dappArchivist = assertEx(asArchivistInstance(dappModule), () => 'DappArchivist not found')
|
|
65
|
+
const dappArchivist = assertEx(asArchivistInstance(dappModule), () => 'resetDappArchivist: DappArchivist not found')
|
|
66
66
|
|
|
67
67
|
await dappArchivist.clear()
|
|
68
68
|
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { assertEx } from '@xylabs/assert'
|
|
2
|
+
import { type AccountInstance, HDWallet } from '@xyo-network/account'
|
|
3
|
+
import type {
|
|
4
|
+
WalletKind,
|
|
5
|
+
WalletSeedPhraseStore,
|
|
6
|
+
} from '@xyo-network/bios-model'
|
|
7
|
+
import type {
|
|
8
|
+
SignerAccounts, SignersExternal, WalletKindSignerPaths,
|
|
9
|
+
} from '@xyo-network/os-model'
|
|
10
|
+
|
|
11
|
+
export class Signers implements SignersExternal {
|
|
12
|
+
private _paths: WalletKindSignerPaths
|
|
13
|
+
private _signerAccounts: Map<WalletKind, SignerAccounts>
|
|
14
|
+
private _walletStore: WalletSeedPhraseStore
|
|
15
|
+
|
|
16
|
+
constructor(paths: WalletKindSignerPaths, walletStore: WalletSeedPhraseStore) {
|
|
17
|
+
this._paths = paths
|
|
18
|
+
this._walletStore = walletStore
|
|
19
|
+
this._signerAccounts = new Map()
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
private get paths(): WalletKindSignerPaths {
|
|
23
|
+
return assertEx(this._paths, () => 'Paths not initialized')
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
private get signerAccounts(): Map<WalletKind, SignerAccounts> {
|
|
27
|
+
return assertEx(this._signerAccounts, () => 'Signer accounts not initialized')
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
private get walletStore(): WalletSeedPhraseStore {
|
|
31
|
+
return assertEx(this._walletStore, () => 'Wallet store not initialized')
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
getSigner(walletKind: WalletKind, signer: string): AccountInstance | undefined {
|
|
35
|
+
return this.signerAccounts.get(walletKind)?.get(signer)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async initialize() {
|
|
39
|
+
for (const [walletKindName, signerPaths] of this.paths) {
|
|
40
|
+
for (const [signerName, walletPath] of signerPaths.entries()) {
|
|
41
|
+
await this.initializeSigners(walletKindName, signerName, walletPath)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
private async initializeSigners(walletKindName: WalletKind, signerName: string, path: string) {
|
|
47
|
+
// test if the name and path are valid
|
|
48
|
+
assertEx(signerName, () => 'Name not found in signer paths')
|
|
49
|
+
assertEx(path, () => 'Path not found in signer paths')
|
|
50
|
+
|
|
51
|
+
// test if the wallet exists
|
|
52
|
+
const phrase = assertEx(await this.walletStore.get(walletKindName), () => `Wallet not found: ${walletKindName}`)
|
|
53
|
+
|
|
54
|
+
if (path) {
|
|
55
|
+
// get the signer map for the wallet kind or create a new one
|
|
56
|
+
const signerMap = this.signerAccounts.get(walletKindName) ?? new Map()
|
|
57
|
+
|
|
58
|
+
// derive the wallet from the path
|
|
59
|
+
const wallet = await HDWallet.fromPhrase(phrase)
|
|
60
|
+
const derivedWallet = await wallet.derivePath(path)
|
|
61
|
+
|
|
62
|
+
// add the derived wallet to the signer map
|
|
63
|
+
signerMap.set(signerName, derivedWallet)
|
|
64
|
+
|
|
65
|
+
// set the signer map for the wallet kind
|
|
66
|
+
this.signerAccounts.set(walletKindName, signerMap)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Signers.ts'
|
package/src/stack/Manager.ts
CHANGED
|
@@ -21,7 +21,11 @@ export class StackManager {
|
|
|
21
21
|
this.stackMap = stackMap
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
get stacks() {
|
|
25
|
+
return Object.keys(this.initializedStacksMap)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
private get initializedStacks() {
|
|
25
29
|
return this.initializedStacksMap
|
|
26
30
|
}
|
|
27
31
|
|
|
@@ -31,15 +35,16 @@ export class StackManager {
|
|
|
31
35
|
|
|
32
36
|
initialize(context: XyOsContext) {
|
|
33
37
|
for (const [key, stackSet] of Object.entries(this.stackMap)) {
|
|
38
|
+
console.log('stack-initialize', key)
|
|
34
39
|
const { stack: Stack, adapters: stackNodeModuleId } = stackSet
|
|
35
40
|
const initializedStack = new Stack(context, stackNodeModuleId)
|
|
36
41
|
initializedStack.initialize()
|
|
37
|
-
this.
|
|
42
|
+
this.initializedStacks.set(key, initializedStack)
|
|
38
43
|
}
|
|
39
44
|
}
|
|
40
45
|
|
|
41
46
|
stop() {
|
|
42
|
-
for (const stack of this.
|
|
47
|
+
for (const stack of this.initializedStacks.values()) {
|
|
43
48
|
stack.stop()
|
|
44
49
|
}
|
|
45
50
|
}
|