@xyo-network/os-runtime 7.3.1 → 7.4.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.
- package/dist/neutral/index.mjs +642 -976
- package/dist/neutral/index.mjs.map +7 -1
- package/dist/node/index.mjs +642 -976
- package/dist/node/index.mjs.map +7 -1
- package/dist/node/scripts/xyos/index.mjs +367 -487
- package/dist/node/scripts/xyos/index.mjs.map +7 -1
- package/package.json +30 -36
package/dist/neutral/index.mjs
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
1
|
// src/access/Caller.ts
|
|
5
2
|
import { assertEx as assertEx16 } from "@xylabs/sdk-js";
|
|
6
3
|
import { asNodeInstance as asNodeInstance2 } from "@xyo-network/node-model";
|
|
@@ -18,9 +15,6 @@ var DappsArchivistPayloadDivinerModuleName = "DappsArchivistPayloadDiviner";
|
|
|
18
15
|
var DappsArchivistPayloadDevelopmentDivinerModuleName = `${DappsArchivistPayloadDivinerModuleName}Development`;
|
|
19
16
|
var RegisteredDappInterfacesArchivistModuleName = "RegisteredDappInterfacesArchivist";
|
|
20
17
|
var OsCallerBase = class {
|
|
21
|
-
static {
|
|
22
|
-
__name(this, "OsCallerBase");
|
|
23
|
-
}
|
|
24
18
|
context;
|
|
25
19
|
constructor(context) {
|
|
26
20
|
this.context = context;
|
|
@@ -28,37 +22,39 @@ var OsCallerBase = class {
|
|
|
28
22
|
// Get the dapps archivist
|
|
29
23
|
async getDappsArchivist() {
|
|
30
24
|
const mod = assertEx(await this.context.root.resolve(DappsArchivistModuleName), () => `${DappsArchivistModuleName} not found`);
|
|
31
|
-
return asArchivistInstance(mod, () => `${DappsArchivistModuleName} is not an archivist`, {
|
|
32
|
-
required: true
|
|
33
|
-
});
|
|
25
|
+
return asArchivistInstance(mod, () => `${DappsArchivistModuleName} is not an archivist`, { required: true });
|
|
34
26
|
}
|
|
35
27
|
// Get the dapps archivist development
|
|
36
28
|
async getDappsArchivistDevelopment() {
|
|
37
|
-
const mod = assertEx(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
29
|
+
const mod = assertEx(
|
|
30
|
+
await this.context.root.resolve(DappsArchivistDevelopmentModuleName),
|
|
31
|
+
() => `${DappsArchivistDevelopmentModuleName} not found`
|
|
32
|
+
);
|
|
33
|
+
return asArchivistInstance(mod, () => `${DappsArchivistDevelopmentModuleName} is not an archivist`, { required: true });
|
|
41
34
|
}
|
|
42
35
|
// Get the dapps archivist payload diviner
|
|
43
36
|
async getDappsArchivistPayloadDiviner() {
|
|
44
|
-
const mod = assertEx(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
37
|
+
const mod = assertEx(
|
|
38
|
+
await this.context.root.resolve(DappsArchivistPayloadDivinerModuleName),
|
|
39
|
+
() => `${DappsArchivistPayloadDivinerModuleName} not found`
|
|
40
|
+
);
|
|
41
|
+
return asDivinerInstance(mod, () => `${DappsArchivistPayloadDivinerModuleName} is not a diviner`, { required: true });
|
|
48
42
|
}
|
|
49
43
|
// Get the dapps archivist payload diviner development
|
|
50
44
|
async getDappsArchivistPayloadDivinerDevelopment() {
|
|
51
|
-
const mod = assertEx(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
45
|
+
const mod = assertEx(
|
|
46
|
+
await this.context.root.resolve(DappsArchivistPayloadDevelopmentDivinerModuleName),
|
|
47
|
+
() => `${DappsArchivistPayloadDevelopmentDivinerModuleName} not found`
|
|
48
|
+
);
|
|
49
|
+
return asDivinerInstance(mod, () => `${DappsArchivistPayloadDevelopmentDivinerModuleName} is not a diviner`, { required: true });
|
|
55
50
|
}
|
|
56
51
|
// Get the registered dapp interfaces archivist
|
|
57
52
|
async getRegisteredDappInterfacesArchivist() {
|
|
58
|
-
const mod = assertEx(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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 });
|
|
62
58
|
}
|
|
63
59
|
};
|
|
64
60
|
|
|
@@ -76,9 +72,6 @@ import { DappWalletSeedPhraseSchema } from "@xyo-network/os-model";
|
|
|
76
72
|
import { HDWallet } from "@xyo-network/sdk-js";
|
|
77
73
|
import { v4 as uuid } from "uuid";
|
|
78
74
|
var DappSeedPhraseRepository = class extends OsCallerBase {
|
|
79
|
-
static {
|
|
80
|
-
__name(this, "DappSeedPhraseRepository");
|
|
81
|
-
}
|
|
82
75
|
allowedNames;
|
|
83
76
|
// record of all dapps that have requested a seed phrase with the OS
|
|
84
77
|
dappIdRepository = /* @__PURE__ */ new Map();
|
|
@@ -98,9 +91,7 @@ var DappSeedPhraseRepository = class extends OsCallerBase {
|
|
|
98
91
|
seedPhrase,
|
|
99
92
|
walletId
|
|
100
93
|
};
|
|
101
|
-
await archivist.insert([
|
|
102
|
-
payload
|
|
103
|
-
]);
|
|
94
|
+
await archivist.insert([payload]);
|
|
104
95
|
this.dappIdRepository.set(dappId, payload);
|
|
105
96
|
this.walletIdRepository.set(walletId, payload);
|
|
106
97
|
return walletId;
|
|
@@ -116,9 +107,7 @@ var DappSeedPhraseRepository = class extends OsCallerBase {
|
|
|
116
107
|
throw new Error(`failed to add seed phrase: ${dappName}`);
|
|
117
108
|
} catch (e) {
|
|
118
109
|
console.error(e);
|
|
119
|
-
throw new Error(`failed to add seed phrase: ${dappName}`, {
|
|
120
|
-
cause: e
|
|
121
|
-
});
|
|
110
|
+
throw new Error(`failed to add seed phrase: ${dappName}`, { cause: e });
|
|
122
111
|
}
|
|
123
112
|
} else {
|
|
124
113
|
throw new Error(`${dappName} is not allowed to register a seed phase. NOTE: this is a safeguard till 3rd party dApps can be validated`);
|
|
@@ -134,13 +123,9 @@ var DappSeedPhraseRepository = class extends OsCallerBase {
|
|
|
134
123
|
limit: 1,
|
|
135
124
|
order: "desc",
|
|
136
125
|
schema: PayloadDivinerQuerySchema,
|
|
137
|
-
schemas: [
|
|
138
|
-
DappWalletSeedPhraseSchema
|
|
139
|
-
]
|
|
126
|
+
schemas: [DappWalletSeedPhraseSchema]
|
|
140
127
|
};
|
|
141
|
-
const results = await diviner.divine([
|
|
142
|
-
query
|
|
143
|
-
]);
|
|
128
|
+
const results = await diviner.divine([query]);
|
|
144
129
|
return results.length > 0 ? results[0] : void 0;
|
|
145
130
|
}
|
|
146
131
|
async checkWalletId(walletId) {
|
|
@@ -149,14 +134,10 @@ var DappSeedPhraseRepository = class extends OsCallerBase {
|
|
|
149
134
|
limit: 1,
|
|
150
135
|
order: "desc",
|
|
151
136
|
schema: PayloadDivinerQuerySchema,
|
|
152
|
-
schemas: [
|
|
153
|
-
DappWalletSeedPhraseSchema
|
|
154
|
-
],
|
|
137
|
+
schemas: [DappWalletSeedPhraseSchema],
|
|
155
138
|
walletId
|
|
156
139
|
};
|
|
157
|
-
const results = await diviner.divine([
|
|
158
|
-
query
|
|
159
|
-
]);
|
|
140
|
+
const results = await diviner.divine([query]);
|
|
160
141
|
return results.length > 0 ? results[0] : void 0;
|
|
161
142
|
}
|
|
162
143
|
newPhrase() {
|
|
@@ -180,54 +161,50 @@ var IntentArchivistModuleName = "IntentArchivist";
|
|
|
180
161
|
var IntentArchivistPayloadDivinerModuleName = "IntentArchivistPayloadDiviner";
|
|
181
162
|
var DappArchivistPayloadDivinerModuleName = "DappArchivistPayloadDiviner";
|
|
182
163
|
var DappCallerBase = class {
|
|
183
|
-
static {
|
|
184
|
-
__name(this, "DappCallerBase");
|
|
185
|
-
}
|
|
186
164
|
context;
|
|
187
165
|
constructor(context) {
|
|
188
166
|
this.context = context;
|
|
189
167
|
}
|
|
190
168
|
/**
|
|
191
|
-
|
|
192
|
-
|
|
169
|
+
* Get the DappArchivist
|
|
170
|
+
*/
|
|
193
171
|
async getDappArchivist() {
|
|
194
|
-
const mod = assertEx2(
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
172
|
+
const mod = assertEx2(
|
|
173
|
+
await this.context.root.resolve(DappArchivistModuleName),
|
|
174
|
+
() => `${DappArchivistModuleName} not found [${toSafeJsonString(this.context.root.publicChildren())}]`
|
|
175
|
+
);
|
|
176
|
+
return asArchivistInstance2(mod, () => `${DappArchivistModuleName} is not an archivist`, { required: true });
|
|
198
177
|
}
|
|
199
178
|
/**
|
|
200
|
-
|
|
201
|
-
|
|
179
|
+
* Get the DappArchivistPayloadDiviner
|
|
180
|
+
*/
|
|
202
181
|
async getDappArchivistPayloadDiviner() {
|
|
203
|
-
const mod = assertEx2(
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
182
|
+
const mod = assertEx2(
|
|
183
|
+
await this.context.root.resolve(DappArchivistPayloadDivinerModuleName),
|
|
184
|
+
() => `${DappArchivistPayloadDivinerModuleName} not found`
|
|
185
|
+
);
|
|
186
|
+
return asDivinerInstance2(mod, () => `${DappArchivistPayloadDivinerModuleName} is not a diviner`, { required: true });
|
|
207
187
|
}
|
|
208
188
|
/**
|
|
209
|
-
|
|
210
|
-
|
|
189
|
+
* Get the IntentArchivist
|
|
190
|
+
*/
|
|
211
191
|
async getDappIntentArchivist() {
|
|
212
192
|
const mod = assertEx2(await this.context.root.resolve(IntentArchivistModuleName), () => `${IntentArchivistModuleName} not found`);
|
|
213
|
-
return asArchivistInstance2(mod, () => `${IntentArchivistModuleName} is not an archivist`, {
|
|
214
|
-
required: true
|
|
215
|
-
});
|
|
193
|
+
return asArchivistInstance2(mod, () => `${IntentArchivistModuleName} is not an archivist`, { required: true });
|
|
216
194
|
}
|
|
217
195
|
// Get the IntentArchivistPayloadDiviner
|
|
218
196
|
async getDappIntentArchivistPayloadDiviner() {
|
|
219
|
-
const mod = assertEx2(
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
197
|
+
const mod = assertEx2(
|
|
198
|
+
await this.context.root.resolve(IntentArchivistPayloadDivinerModuleName),
|
|
199
|
+
() => `${IntentArchivistPayloadDivinerModuleName} not found`
|
|
200
|
+
);
|
|
201
|
+
return asDivinerInstance2(mod, () => `${IntentArchivistPayloadDivinerModuleName} is not a diviner`, { required: true });
|
|
223
202
|
}
|
|
224
203
|
};
|
|
225
204
|
|
|
226
205
|
// src/manifest/manifestReplacementTokens.ts
|
|
227
206
|
import { getXnsDomain } from "@xyo-network/kernel";
|
|
228
|
-
var manifestReplacementTokens =
|
|
229
|
-
"[REPLACE_WITH_NS_NODE_URL]": getXnsDomain(xnsNodeUrl, xnsNetwork)
|
|
230
|
-
}), "manifestReplacementTokens");
|
|
207
|
+
var manifestReplacementTokens = (xnsNodeUrl, xnsNetwork) => ({ "[REPLACE_WITH_NS_NODE_URL]": getXnsDomain(xnsNodeUrl, xnsNetwork) });
|
|
231
208
|
|
|
232
209
|
// src/manifest/os-node.manifest.json
|
|
233
210
|
var os_node_manifest_default = {
|
|
@@ -367,13 +344,10 @@ var os_node_manifest_default = {
|
|
|
367
344
|
import { PayloadBuilder } from "@xyo-network/payload-builder";
|
|
368
345
|
|
|
369
346
|
// src/classes/lib/Insertable.ts
|
|
370
|
-
var createInsertable =
|
|
347
|
+
var createInsertable = (insertable, ...params) => new insertable(...params);
|
|
371
348
|
|
|
372
349
|
// src/dapp/context/creator/DefaultPayloads/DappAccessPayloads.ts
|
|
373
350
|
var DappAccessPayloads = class {
|
|
374
|
-
static {
|
|
375
|
-
__name(this, "DappAccessPayloads");
|
|
376
|
-
}
|
|
377
351
|
context;
|
|
378
352
|
constructor(context, _dappName) {
|
|
379
353
|
this.context = context;
|
|
@@ -388,9 +362,6 @@ var DappAccessPayloads = class {
|
|
|
388
362
|
// src/dapp/context/creator/DefaultPayloads/NodeInfoPayload.ts
|
|
389
363
|
import { NodeOsInfoSchema } from "@xyo-network/os-model";
|
|
390
364
|
var NodeInfoPayload = class {
|
|
391
|
-
static {
|
|
392
|
-
__name(this, "NodeInfoPayload");
|
|
393
|
-
}
|
|
394
365
|
_context;
|
|
395
366
|
constructor(context, _dappName) {
|
|
396
367
|
this._context = context;
|
|
@@ -407,17 +378,12 @@ var NodeInfoPayload = class {
|
|
|
407
378
|
publicAddress: exposedNode?.address ?? "",
|
|
408
379
|
schema: NodeOsInfoSchema
|
|
409
380
|
};
|
|
410
|
-
return [
|
|
411
|
-
nodeOsInfo
|
|
412
|
-
];
|
|
381
|
+
return [nodeOsInfo];
|
|
413
382
|
}
|
|
414
383
|
};
|
|
415
384
|
|
|
416
385
|
// src/dapp/context/creator/DefaultPayloads/DefaultPayloads.ts
|
|
417
386
|
var DefaultPayloads = class {
|
|
418
|
-
static {
|
|
419
|
-
__name(this, "DefaultPayloads");
|
|
420
|
-
}
|
|
421
387
|
dappArchivist;
|
|
422
388
|
dappName;
|
|
423
389
|
xyOs;
|
|
@@ -427,10 +393,7 @@ var DefaultPayloads = class {
|
|
|
427
393
|
this.dappName = dappName;
|
|
428
394
|
}
|
|
429
395
|
async insert() {
|
|
430
|
-
const insertables = [
|
|
431
|
-
NodeInfoPayload,
|
|
432
|
-
DappAccessPayloads
|
|
433
|
-
];
|
|
396
|
+
const insertables = [NodeInfoPayload, DappAccessPayloads];
|
|
434
397
|
const insertPayloads = [];
|
|
435
398
|
for (const insertable of insertables) {
|
|
436
399
|
const classInstance = createInsertable(insertable, this.xyOs, this.dappName);
|
|
@@ -438,28 +401,16 @@ var DefaultPayloads = class {
|
|
|
438
401
|
insertPayloads.push(...payloads);
|
|
439
402
|
}
|
|
440
403
|
for (const payload of insertPayloads) {
|
|
441
|
-
const [existing] = await this.dappArchivist.get([
|
|
442
|
-
await PayloadBuilder.dataHash(payload)
|
|
443
|
-
]);
|
|
404
|
+
const [existing] = await this.dappArchivist.get([await PayloadBuilder.dataHash(payload)]);
|
|
444
405
|
if (existing) continue;
|
|
445
|
-
await this.dappArchivist.insert([
|
|
446
|
-
payload
|
|
447
|
-
]);
|
|
406
|
+
await this.dappArchivist.insert([payload]);
|
|
448
407
|
}
|
|
449
408
|
}
|
|
450
409
|
};
|
|
451
410
|
|
|
452
411
|
// src/dapp/context/creator/ExternalModulePermissions/ExternalModulePermissions.ts
|
|
453
|
-
var ALLOWED_MODULES_FROM_PARENT = [
|
|
454
|
-
"IntentArchivist",
|
|
455
|
-
"OsSettingsNode",
|
|
456
|
-
"OsPubSubNetworkStackNode",
|
|
457
|
-
"OsXyoPublicNetworkStackNode"
|
|
458
|
-
];
|
|
412
|
+
var ALLOWED_MODULES_FROM_PARENT = ["IntentArchivist", "OsSettingsNode", "OsPubSubNetworkStackNode", "OsXyoPublicNetworkStackNode"];
|
|
459
413
|
var ExternalModulePermissions = class {
|
|
460
|
-
static {
|
|
461
|
-
__name(this, "ExternalModulePermissions");
|
|
462
|
-
}
|
|
463
414
|
context;
|
|
464
415
|
dappName;
|
|
465
416
|
dappWindowNode;
|
|
@@ -500,9 +451,6 @@ var ExternalModulePermissions = class {
|
|
|
500
451
|
|
|
501
452
|
// src/dapp/context/creator/Creator.ts
|
|
502
453
|
var DappContextCreator = class _DappContextCreator {
|
|
503
|
-
static {
|
|
504
|
-
__name(this, "DappContextCreator");
|
|
505
|
-
}
|
|
506
454
|
// Designated offset path for the wallet used by windowed dapps. In the future, other offsets could be used for other dapp modes
|
|
507
455
|
static DAPP_WINDOW_WALLET_PATH = "1";
|
|
508
456
|
context;
|
|
@@ -520,8 +468,18 @@ var DappContextCreator = class _DappContextCreator {
|
|
|
520
468
|
this.sharedLocator = sharedLocator;
|
|
521
469
|
}
|
|
522
470
|
static async create(params, xnsNodeUrl, xnsNetwork) {
|
|
523
|
-
const {
|
|
524
|
-
|
|
471
|
+
const {
|
|
472
|
+
config,
|
|
473
|
+
locator,
|
|
474
|
+
context,
|
|
475
|
+
wallet
|
|
476
|
+
} = params;
|
|
477
|
+
const {
|
|
478
|
+
payload,
|
|
479
|
+
dappName,
|
|
480
|
+
publicChildren,
|
|
481
|
+
privateChildren
|
|
482
|
+
} = config;
|
|
525
483
|
const { external, manifestPayload } = this.parseDappPackageManifestPayload(payload, xnsNodeUrl, xnsNetwork);
|
|
526
484
|
console.debug("[DEBUG] dApp manifest", manifestPayload);
|
|
527
485
|
const dappWallet = await wallet.derivePath(_DappContextCreator.DAPP_WINDOW_WALLET_PATH);
|
|
@@ -556,10 +514,7 @@ var DappContextCreator = class _DappContextCreator {
|
|
|
556
514
|
};
|
|
557
515
|
console.log("DappContextCreator:parseDappPackageManifestPayload", xnsNodeUrl, xnsNetwork);
|
|
558
516
|
const manifestPayload = replaceManifestTokens(manifestPayloadRaw, manifestReplacementTokens(xnsNodeUrl, xnsNetwork));
|
|
559
|
-
return {
|
|
560
|
-
external,
|
|
561
|
-
manifestPayload
|
|
562
|
-
};
|
|
517
|
+
return { external, manifestPayload };
|
|
563
518
|
}
|
|
564
519
|
async loadDappContext(context) {
|
|
565
520
|
console.log("DappNodesCreator:loadDappContext", this.dappId);
|
|
@@ -580,15 +535,13 @@ var DappContextCreator = class _DappContextCreator {
|
|
|
580
535
|
};
|
|
581
536
|
|
|
582
537
|
// src/dapp/context/creator/createDappContext.ts
|
|
583
|
-
var GenericPayloadDivinerTags = {
|
|
584
|
-
|
|
585
|
-
};
|
|
586
|
-
var resolveLocator = /* @__PURE__ */ __name((existingLocator) => {
|
|
538
|
+
var GenericPayloadDivinerTags = { "network.xyo.generic.payload.diviner": "GenericPayloadDiviner" };
|
|
539
|
+
var resolveLocator = (existingLocator) => {
|
|
587
540
|
const locator = existingLocator ?? new ModuleFactoryLocator2();
|
|
588
541
|
locator.register(GenericPayloadDiviner.factory(), GenericPayloadDivinerTags);
|
|
589
542
|
return locator;
|
|
590
|
-
}
|
|
591
|
-
var createDappContext =
|
|
543
|
+
};
|
|
544
|
+
var createDappContext = async (dapp, context, allowedNames, xnsNodeUrl, xnsNetwork) => {
|
|
592
545
|
console.log("createNodes");
|
|
593
546
|
try {
|
|
594
547
|
const dappSeedPhraseRepository = new DappSeedPhraseRepository(context, allowedNames);
|
|
@@ -601,10 +554,7 @@ var createDappContext = /* @__PURE__ */ __name(async (dapp, context, allowedName
|
|
|
601
554
|
const { config: dappConfig, params: dappParams } = dapp;
|
|
602
555
|
const locator = resolveLocator((dappParams.locator ?? new ModuleFactoryLocator2()).merge(context.platformLocator));
|
|
603
556
|
const params = {
|
|
604
|
-
config: {
|
|
605
|
-
dappName,
|
|
606
|
-
payload: dappConfig.manifest
|
|
607
|
-
},
|
|
557
|
+
config: { dappName, payload: dappConfig.manifest },
|
|
608
558
|
context,
|
|
609
559
|
locator,
|
|
610
560
|
wallet
|
|
@@ -619,11 +569,9 @@ var createDappContext = /* @__PURE__ */ __name(async (dapp, context, allowedName
|
|
|
619
569
|
const error = e;
|
|
620
570
|
console.error(`Error creating dappWindow node: ${error.message}`);
|
|
621
571
|
console.error(`Error creating dappWindow node: ${error.stack}`);
|
|
622
|
-
throw new Error(`Error creating dappWindow node: ${error.message}`, {
|
|
623
|
-
cause: e
|
|
624
|
-
});
|
|
572
|
+
throw new Error(`Error creating dappWindow node: ${error.message}`, { cause: e });
|
|
625
573
|
}
|
|
626
|
-
}
|
|
574
|
+
};
|
|
627
575
|
|
|
628
576
|
// src/XyOs.ts
|
|
629
577
|
import { assertEx as assertEx14 } from "@xylabs/sdk-js";
|
|
@@ -634,9 +582,6 @@ import { ModuleFactoryLocator as ModuleFactoryLocator8 } from "@xyo-network/sdk-
|
|
|
634
582
|
// src/event/bus/Connection.ts
|
|
635
583
|
import { assertEx as assertEx4, BaseEmitter } from "@xylabs/sdk-js";
|
|
636
584
|
var EventBusConnection = class extends BaseEmitter {
|
|
637
|
-
static {
|
|
638
|
-
__name(this, "EventBusConnection");
|
|
639
|
-
}
|
|
640
585
|
_id;
|
|
641
586
|
description;
|
|
642
587
|
type;
|
|
@@ -654,18 +599,22 @@ var EventBusConnection = class extends BaseEmitter {
|
|
|
654
599
|
};
|
|
655
600
|
|
|
656
601
|
// src/event/bus/EventBus.ts
|
|
657
|
-
import {
|
|
602
|
+
import {
|
|
603
|
+
assertEx as assertEx5,
|
|
604
|
+
findAs,
|
|
605
|
+
forget
|
|
606
|
+
} from "@xylabs/sdk-js";
|
|
658
607
|
import { asArchivistInstance as asArchivistInstance4 } from "@xyo-network/archivist";
|
|
659
|
-
import {
|
|
608
|
+
import {
|
|
609
|
+
asOptionalEventBusEvent,
|
|
610
|
+
isPubSubConnections
|
|
611
|
+
} from "@xyo-network/os-model";
|
|
660
612
|
import { PayloadBuilder as PayloadBuilder2 } from "@xyo-network/payload-builder";
|
|
661
613
|
import { asSchema } from "@xyo-network/payload-model";
|
|
662
614
|
import { MemoryArchivist, MemoryArchivistConfigSchema } from "@xyo-network/sdk-js";
|
|
663
615
|
import { Mutex } from "async-mutex";
|
|
664
616
|
import { v4 as uuid2 } from "uuid";
|
|
665
617
|
var EventBus = class {
|
|
666
|
-
static {
|
|
667
|
-
__name(this, "EventBus");
|
|
668
|
-
}
|
|
669
618
|
// Internal Archivist to store event data
|
|
670
619
|
_archivist;
|
|
671
620
|
// Store all connections
|
|
@@ -674,9 +623,11 @@ var EventBus = class {
|
|
|
674
623
|
publisherCallbacks = {};
|
|
675
624
|
startMutex = new Mutex();
|
|
676
625
|
get archivist() {
|
|
677
|
-
return asArchivistInstance4(
|
|
678
|
-
|
|
679
|
-
|
|
626
|
+
return asArchivistInstance4(
|
|
627
|
+
assertEx5(this._archivist, () => "Archivist not found. Did you forget to call start()?"),
|
|
628
|
+
"not a valid archivist instance",
|
|
629
|
+
{ required: true }
|
|
630
|
+
);
|
|
680
631
|
}
|
|
681
632
|
addConnection(connection) {
|
|
682
633
|
const id = uuid2();
|
|
@@ -705,12 +656,7 @@ var EventBus = class {
|
|
|
705
656
|
console.warn("EventBus already started");
|
|
706
657
|
return this;
|
|
707
658
|
}
|
|
708
|
-
this._archivist = await MemoryArchivist.create({
|
|
709
|
-
config: {
|
|
710
|
-
name: storeName,
|
|
711
|
-
schema: MemoryArchivistConfigSchema
|
|
712
|
-
}
|
|
713
|
-
});
|
|
659
|
+
this._archivist = await MemoryArchivist.create({ config: { name: storeName, schema: MemoryArchivistConfigSchema } });
|
|
714
660
|
this.archivist.on("inserted", ({ payloads }) => {
|
|
715
661
|
const eventBusEvent = findAs(payloads, asOptionalEventBusEvent);
|
|
716
662
|
if (!eventBusEvent) return;
|
|
@@ -720,9 +666,7 @@ var EventBus = class {
|
|
|
720
666
|
for (const [eventName, callback] of connection.subscribableEvents.entries()) {
|
|
721
667
|
if (eventName !== eventBusEvent.name) continue;
|
|
722
668
|
if (callback) {
|
|
723
|
-
const forgettable =
|
|
724
|
-
payloads
|
|
725
|
-
}), "forgettable");
|
|
669
|
+
const forgettable = async () => await callback({ payloads });
|
|
726
670
|
forget(forgettable());
|
|
727
671
|
}
|
|
728
672
|
}
|
|
@@ -734,22 +678,16 @@ var EventBus = class {
|
|
|
734
678
|
}
|
|
735
679
|
handlePublisherAdd(connection) {
|
|
736
680
|
for (const eventName of connection.publishableEvents ?? []) {
|
|
737
|
-
const connectionPublisherCallback =
|
|
738
|
-
const event = {
|
|
739
|
-
name: eventName,
|
|
740
|
-
schema: asSchema("network.xyo.event.bus.event", true)
|
|
741
|
-
};
|
|
681
|
+
const connectionPublisherCallback = async ({ payloads }) => {
|
|
682
|
+
const event = { name: eventName, schema: asSchema("network.xyo.event.bus.event", true) };
|
|
742
683
|
const eventPayloads = payloads ?? [];
|
|
743
684
|
event.sources = await PayloadBuilder2.dataHashes(eventPayloads);
|
|
744
685
|
try {
|
|
745
|
-
await this.archivist.insert([
|
|
746
|
-
event,
|
|
747
|
-
...payloads ?? []
|
|
748
|
-
]);
|
|
686
|
+
await this.archivist.insert([event, ...payloads ?? []]);
|
|
749
687
|
} catch (e) {
|
|
750
688
|
console.error("Error inserting event into archivist", e);
|
|
751
689
|
}
|
|
752
|
-
}
|
|
690
|
+
};
|
|
753
691
|
connection.on(eventName, connectionPublisherCallback);
|
|
754
692
|
const callbackId = connection.id + eventName;
|
|
755
693
|
this.publisherCallbacks[callbackId] = connectionPublisherCallback;
|
|
@@ -766,9 +704,6 @@ var EventBus = class {
|
|
|
766
704
|
|
|
767
705
|
// src/event/bus/PubSubConnection.ts
|
|
768
706
|
var EventBusPubSubConnection = class extends EventBusConnection {
|
|
769
|
-
static {
|
|
770
|
-
__name(this, "EventBusPubSubConnection");
|
|
771
|
-
}
|
|
772
707
|
publishableEvents;
|
|
773
708
|
subscribableEvents;
|
|
774
709
|
constructor(request) {
|
|
@@ -784,79 +719,65 @@ var EventBusPubSubConnection = class extends EventBusConnection {
|
|
|
784
719
|
// src/event/connections/DappAccessRequest.ts
|
|
785
720
|
var DappAccessRequestEvent = "dappAccessRequest";
|
|
786
721
|
var dappAccessRequestConnectionRequest = {
|
|
787
|
-
publishableEvents: [
|
|
788
|
-
DappAccessRequestEvent
|
|
789
|
-
],
|
|
722
|
+
publishableEvents: [DappAccessRequestEvent],
|
|
790
723
|
type: "PubSub"
|
|
791
724
|
};
|
|
792
|
-
var dappAccessRequestConnection =
|
|
725
|
+
var dappAccessRequestConnection = () => new EventBusPubSubConnection(dappAccessRequestConnectionRequest);
|
|
793
726
|
|
|
794
727
|
// src/event/connections/DappsReady.ts
|
|
795
728
|
var dappsReadyConnectionRequest = {
|
|
796
|
-
publishableEvents: [
|
|
797
|
-
"dappsReady"
|
|
798
|
-
],
|
|
729
|
+
publishableEvents: ["dappsReady"],
|
|
799
730
|
type: "PubSub"
|
|
800
731
|
};
|
|
801
|
-
var dappsReadyConnection =
|
|
732
|
+
var dappsReadyConnection = () => new EventBusPubSubConnection(dappsReadyConnectionRequest);
|
|
802
733
|
|
|
803
734
|
// src/event/connections/ExposeDappRequest.ts
|
|
804
735
|
var ExposeDappRequestEvent = "exposeDappRequest";
|
|
805
736
|
var exposeDappConnectionRequest = {
|
|
806
|
-
publishableEvents: [
|
|
807
|
-
ExposeDappRequestEvent
|
|
808
|
-
],
|
|
737
|
+
publishableEvents: [ExposeDappRequestEvent],
|
|
809
738
|
type: "PubSub"
|
|
810
739
|
};
|
|
811
|
-
var exposeDappRequestConnection =
|
|
740
|
+
var exposeDappRequestConnection = () => new EventBusPubSubConnection(exposeDappConnectionRequest);
|
|
812
741
|
|
|
813
742
|
// src/event/connections/OsPubSubNetworkReady.ts
|
|
814
743
|
var OsPubSubNetworkReadyEvent = "osPubSubNetworkReady";
|
|
815
744
|
var osPubSubNetworkConnectionRequest = {
|
|
816
|
-
publishableEvents: [
|
|
817
|
-
OsPubSubNetworkReadyEvent
|
|
818
|
-
],
|
|
745
|
+
publishableEvents: [OsPubSubNetworkReadyEvent],
|
|
819
746
|
type: "PubSub"
|
|
820
747
|
};
|
|
821
|
-
var osPubSubNetworkReadyConnection =
|
|
748
|
+
var osPubSubNetworkReadyConnection = () => new EventBusPubSubConnection(osPubSubNetworkConnectionRequest);
|
|
822
749
|
|
|
823
750
|
// src/event/connections/OsSettingsReady.ts
|
|
824
751
|
var OsSettingsReadyEvent = "osSettingsReady";
|
|
825
752
|
var osSettingsConnectionRequest = {
|
|
826
|
-
publishableEvents: [
|
|
827
|
-
OsSettingsReadyEvent
|
|
828
|
-
],
|
|
753
|
+
publishableEvents: [OsSettingsReadyEvent],
|
|
829
754
|
type: "PubSub"
|
|
830
755
|
};
|
|
831
|
-
var osSettingsReadyConnection =
|
|
756
|
+
var osSettingsReadyConnection = () => new EventBusPubSubConnection(osSettingsConnectionRequest);
|
|
832
757
|
|
|
833
758
|
// src/event/connections/OsXyoPublicReady.ts
|
|
834
759
|
var OsXyoPublicNetworkReadyEvent = "osXyoPublicNetworkReady";
|
|
835
760
|
var osXyoPublicNetworkConnectionRequest = {
|
|
836
|
-
publishableEvents: [
|
|
837
|
-
OsXyoPublicNetworkReadyEvent
|
|
838
|
-
],
|
|
761
|
+
publishableEvents: [OsXyoPublicNetworkReadyEvent],
|
|
839
762
|
type: "PubSub"
|
|
840
763
|
};
|
|
841
|
-
var osXyoPublicNetworkReadyConnection =
|
|
764
|
+
var osXyoPublicNetworkReadyConnection = () => new EventBusPubSubConnection(osXyoPublicNetworkConnectionRequest);
|
|
842
765
|
|
|
843
766
|
// src/lib/initializeXns.ts
|
|
844
767
|
import { asDivinerInstance as asDivinerInstance3 } from "@xyo-network/diviner-model";
|
|
845
768
|
import { ResolveHelper } from "@xyo-network/module";
|
|
846
769
|
import { NameRegistrarTransformer } from "@xyo-network/module-resolver";
|
|
847
|
-
var initializeXns =
|
|
770
|
+
var initializeXns = async (xnsNode) => {
|
|
848
771
|
if (ResolveHelper.transformers.length === 0) {
|
|
849
772
|
const registrarDiviner = asDivinerInstance3(await xnsNode?.resolve("AddressRecords:AddressRecordIndexDiviner"));
|
|
850
773
|
if (registrarDiviner) {
|
|
851
774
|
const transformer = new NameRegistrarTransformer(registrarDiviner, "xyo");
|
|
852
|
-
ResolveHelper.transformers = [
|
|
853
|
-
transformer
|
|
854
|
-
];
|
|
775
|
+
ResolveHelper.transformers = [transformer];
|
|
855
776
|
return true;
|
|
856
777
|
}
|
|
857
778
|
}
|
|
858
779
|
return false;
|
|
859
|
-
}
|
|
780
|
+
};
|
|
860
781
|
|
|
861
782
|
// src/lib/isEqual.ts
|
|
862
783
|
import { isObject } from "@xylabs/sdk-js";
|
|
@@ -891,26 +812,25 @@ function isEqual(a, b) {
|
|
|
891
812
|
}
|
|
892
813
|
return false;
|
|
893
814
|
}
|
|
894
|
-
__name(isEqual, "isEqual");
|
|
895
815
|
|
|
896
816
|
// src/lib/isPayload.ts
|
|
897
817
|
import { AsObjectFactory } from "@xylabs/sdk-js";
|
|
898
|
-
var isObject2 =
|
|
818
|
+
var isObject2 = (x) => {
|
|
899
819
|
return typeof x === "object" && !Array.isArray(x);
|
|
900
|
-
}
|
|
901
|
-
var isAnyPayload =
|
|
820
|
+
};
|
|
821
|
+
var isAnyPayload = (obj) => {
|
|
902
822
|
if (isObject2(obj)) {
|
|
903
823
|
return typeof obj.schema === "string";
|
|
904
824
|
}
|
|
905
825
|
return false;
|
|
906
|
-
}
|
|
907
|
-
var isPayload =
|
|
826
|
+
};
|
|
827
|
+
var isPayload = (schema) => (obj) => {
|
|
908
828
|
if (isAnyPayload(obj)) {
|
|
909
829
|
return schema.includes(obj.schema);
|
|
910
830
|
}
|
|
911
831
|
return false;
|
|
912
|
-
}
|
|
913
|
-
var asPayload =
|
|
832
|
+
};
|
|
833
|
+
var asPayload = (schema) => AsObjectFactory.create(isPayload(schema));
|
|
914
834
|
|
|
915
835
|
// src/lib/ModuleNames.ts
|
|
916
836
|
var DevelopArchivist = "DevelopArchivist";
|
|
@@ -918,15 +838,9 @@ var NodeSentinel = "NodeSentinel";
|
|
|
918
838
|
|
|
919
839
|
// src/lib/ModuleAccountPaths.ts
|
|
920
840
|
var RemoteNodeArchivistOffsetPaths = {
|
|
921
|
-
Kerplunk: {
|
|
922
|
-
|
|
923
|
-
}
|
|
924
|
-
Local: {
|
|
925
|
-
[DevelopArchivist]: "115"
|
|
926
|
-
},
|
|
927
|
-
Main: {
|
|
928
|
-
[DevelopArchivist]: "121"
|
|
929
|
-
}
|
|
841
|
+
Kerplunk: { [DevelopArchivist]: "118" },
|
|
842
|
+
Local: { [DevelopArchivist]: "115" },
|
|
843
|
+
Main: { [DevelopArchivist]: "121" }
|
|
930
844
|
};
|
|
931
845
|
var ModuleOffsetPaths = {
|
|
932
846
|
IdWitness: "1",
|
|
@@ -946,9 +860,6 @@ var ModuleOffsetPaths = {
|
|
|
946
860
|
|
|
947
861
|
// src/lib/NameTransforms.ts
|
|
948
862
|
var NameTransforms = class _NameTransforms {
|
|
949
|
-
static {
|
|
950
|
-
__name(this, "NameTransforms");
|
|
951
|
-
}
|
|
952
863
|
value;
|
|
953
864
|
constructor(value) {
|
|
954
865
|
this.value = value;
|
|
@@ -975,9 +886,6 @@ var NameTransforms = class _NameTransforms {
|
|
|
975
886
|
|
|
976
887
|
// src/lib/PayloadStore.ts
|
|
977
888
|
var PayloadStore = class {
|
|
978
|
-
static {
|
|
979
|
-
__name(this, "PayloadStore");
|
|
980
|
-
}
|
|
981
889
|
latest = [];
|
|
982
890
|
archivist;
|
|
983
891
|
deleteListeners = [];
|
|
@@ -987,22 +895,26 @@ var PayloadStore = class {
|
|
|
987
895
|
this.archivist = archivist;
|
|
988
896
|
}
|
|
989
897
|
/**
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
static async create({
|
|
898
|
+
* Initialize listeners on the archivist that update class member variables when new payloads are inserted
|
|
899
|
+
*/
|
|
900
|
+
static async create({
|
|
901
|
+
archivist,
|
|
902
|
+
getLatest,
|
|
903
|
+
idFunction
|
|
904
|
+
}) {
|
|
993
905
|
const instance = new this(archivist);
|
|
994
|
-
const insertListener =
|
|
906
|
+
const insertListener = async ({ payloads }) => {
|
|
995
907
|
if (payloads.some(idFunction)) {
|
|
996
908
|
const latest = await getLatest();
|
|
997
909
|
if (isEqual(latest, instance.latest)) return;
|
|
998
910
|
instance.latest = latest;
|
|
999
911
|
instance.emitChange();
|
|
1000
912
|
}
|
|
1001
|
-
}
|
|
1002
|
-
const deleteListener =
|
|
913
|
+
};
|
|
914
|
+
const deleteListener = async () => {
|
|
1003
915
|
instance.latest = await getLatest();
|
|
1004
916
|
instance.emitChange();
|
|
1005
|
-
}
|
|
917
|
+
};
|
|
1006
918
|
const weakRefInsertListener = new WeakRef(insertListener);
|
|
1007
919
|
const weakRefDeleteListener = new WeakRef(deleteListener);
|
|
1008
920
|
const insertListenerRef = weakRefInsertListener.deref();
|
|
@@ -1015,8 +927,8 @@ var PayloadStore = class {
|
|
|
1015
927
|
return instance;
|
|
1016
928
|
}
|
|
1017
929
|
/**
|
|
1018
|
-
|
|
1019
|
-
|
|
930
|
+
* Remove all listeners and reset their class members
|
|
931
|
+
*/
|
|
1020
932
|
cleanupListeners() {
|
|
1021
933
|
this.removeListeners(this.insertListeners, "inserted");
|
|
1022
934
|
this.removeListeners(this.deleteListeners, "deleted");
|
|
@@ -1024,15 +936,15 @@ var PayloadStore = class {
|
|
|
1024
936
|
this.deleteListeners = [];
|
|
1025
937
|
}
|
|
1026
938
|
/**
|
|
1027
|
-
|
|
1028
|
-
|
|
939
|
+
* Get the current value of the store
|
|
940
|
+
*/
|
|
1029
941
|
getSnapshot() {
|
|
1030
942
|
return this.latest;
|
|
1031
943
|
}
|
|
1032
944
|
/**
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
945
|
+
* Add a call back function that is invoked when new Payloads are inserted
|
|
946
|
+
* @param onStoreChange
|
|
947
|
+
*/
|
|
1036
948
|
subscribe(onStoreChange) {
|
|
1037
949
|
this.listeners.push(onStoreChange);
|
|
1038
950
|
return () => {
|
|
@@ -1055,83 +967,78 @@ var PayloadStore = class {
|
|
|
1055
967
|
|
|
1056
968
|
// src/lib/tokenPlacesSplit.ts
|
|
1057
969
|
import { assertEx as assertEx6 } from "@xylabs/sdk-js";
|
|
1058
|
-
var tokenPlacesSplit =
|
|
970
|
+
var tokenPlacesSplit = (value, places) => {
|
|
1059
971
|
assertEx6(places >= 0, () => "Places has to be >= 0");
|
|
1060
972
|
const factor = BigInt(10 ** Math.abs(places));
|
|
1061
973
|
const remainder = value % factor;
|
|
1062
974
|
const wholeValue = value / factor;
|
|
1063
|
-
return [
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
];
|
|
1067
|
-
}, "tokenPlacesSplit");
|
|
1068
|
-
var tokenPlacesSplitString = /* @__PURE__ */ __name((value, places) => {
|
|
975
|
+
return [wholeValue, remainder];
|
|
976
|
+
};
|
|
977
|
+
var tokenPlacesSplitString = (value, places) => {
|
|
1069
978
|
if (value === void 0) {
|
|
1070
979
|
return "-";
|
|
1071
980
|
}
|
|
1072
981
|
const [wholeValue, remainder] = tokenPlacesSplit(value, places);
|
|
1073
982
|
return `${wholeValue}.${remainder.toString().padStart(Math.abs(places), "0")}`;
|
|
1074
|
-
}
|
|
983
|
+
};
|
|
1075
984
|
|
|
1076
985
|
// src/loadOsNode.ts
|
|
1077
986
|
import { IndexedDbArchivist } from "@xyo-network/archivist-indexeddb";
|
|
1078
987
|
import { IndexedDbPayloadDiviner } from "@xyo-network/diviner-payload-indexeddb";
|
|
1079
988
|
import { ManifestWrapper, ModuleFactoryLocator as ModuleFactoryLocator3 } from "@xyo-network/sdk-js";
|
|
1080
989
|
var OS_NODE_PATH = "1'";
|
|
1081
|
-
var getDefaultOsNodeLocator =
|
|
990
|
+
var getDefaultOsNodeLocator = () => {
|
|
1082
991
|
const locator = new ModuleFactoryLocator3();
|
|
1083
|
-
locator.register(IndexedDbArchivist.factory(), {
|
|
1084
|
-
|
|
1085
|
-
});
|
|
1086
|
-
locator.register(IndexedDbPayloadDiviner.factory(), {
|
|
1087
|
-
"network.xyo.archivist.persistence.scope": "device"
|
|
1088
|
-
});
|
|
992
|
+
locator.register(IndexedDbArchivist.factory(), { "network.xyo.archivist.persistence.scope": "device" });
|
|
993
|
+
locator.register(IndexedDbPayloadDiviner.factory(), { "network.xyo.archivist.persistence.scope": "device" });
|
|
1089
994
|
return locator;
|
|
1090
|
-
}
|
|
1091
|
-
var loadOsNode =
|
|
995
|
+
};
|
|
996
|
+
var loadOsNode = async (osWallet, locator) => {
|
|
1092
997
|
try {
|
|
1093
998
|
const osNodeWallet = await osWallet.derivePath(OS_NODE_PATH);
|
|
1094
999
|
const osNodeLocator = locator ?? getDefaultOsNodeLocator();
|
|
1095
1000
|
const manifestWrapper = new ManifestWrapper(os_node_manifest_default, osNodeWallet, osNodeLocator);
|
|
1096
1001
|
const osNode = (await manifestWrapper.loadNodes())[0];
|
|
1097
|
-
return [
|
|
1098
|
-
osNode
|
|
1099
|
-
];
|
|
1002
|
+
return [osNode];
|
|
1100
1003
|
} catch (e) {
|
|
1101
1004
|
const error = e;
|
|
1102
1005
|
console.error(`Error creating os node: ${error.message}`);
|
|
1103
1006
|
console.error(`Error creating os node: ${error.stack}`);
|
|
1104
|
-
throw new Error(`Error creating os node: ${error.message}`, {
|
|
1105
|
-
cause: e
|
|
1106
|
-
});
|
|
1007
|
+
throw new Error(`Error creating os node: ${error.message}`, { cause: e });
|
|
1107
1008
|
}
|
|
1108
|
-
}
|
|
1009
|
+
};
|
|
1109
1010
|
|
|
1110
1011
|
// src/registration/DappRegistrationService.ts
|
|
1111
|
-
import {
|
|
1112
|
-
|
|
1012
|
+
import {
|
|
1013
|
+
forget as forget2,
|
|
1014
|
+
fulfilled,
|
|
1015
|
+
rejected
|
|
1016
|
+
} from "@xylabs/sdk-js";
|
|
1017
|
+
import {
|
|
1018
|
+
DappIntentTypes,
|
|
1019
|
+
DappMode as DappMode2,
|
|
1020
|
+
isRegisteredDappAccessDappSet,
|
|
1021
|
+
isRegisteredDappExposedDappSet
|
|
1022
|
+
} from "@xyo-network/os-model";
|
|
1113
1023
|
import { ModuleFactoryLocator as ModuleFactoryLocator7 } from "@xyo-network/sdk-js";
|
|
1114
1024
|
|
|
1115
1025
|
// src/intent/Caller.ts
|
|
1116
1026
|
import { PayloadDivinerQuerySchema as PayloadDivinerQuerySchema2 } from "@xyo-network/diviner-payload-model";
|
|
1117
1027
|
import { DappIntentSchema, DappMode } from "@xyo-network/os-model";
|
|
1118
1028
|
var DappIntentCaller = class _DappIntentCaller extends DappCallerBase {
|
|
1119
|
-
static {
|
|
1120
|
-
__name(this, "DappIntentCaller");
|
|
1121
|
-
}
|
|
1122
1029
|
static OsDappName = "XyOs";
|
|
1123
1030
|
constructor(context) {
|
|
1124
1031
|
super(context);
|
|
1125
1032
|
}
|
|
1126
1033
|
/**
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1034
|
+
* Build a new intent
|
|
1035
|
+
* @param sourceDappId
|
|
1036
|
+
* @param intent
|
|
1037
|
+
* @param targetDappId
|
|
1038
|
+
* @param targetMode
|
|
1039
|
+
* @param params?
|
|
1040
|
+
* @returns DappIntent
|
|
1041
|
+
*/
|
|
1135
1042
|
static buildIntent(sourceDappId, intent, targetDappId, targetMode = DappMode.Window, params) {
|
|
1136
1043
|
return {
|
|
1137
1044
|
intent,
|
|
@@ -1147,9 +1054,7 @@ var DappIntentCaller = class _DappIntentCaller extends DappCallerBase {
|
|
|
1147
1054
|
async addIntent(id, intent, mode) {
|
|
1148
1055
|
const intentArchivist = await this.getDappIntentArchivist();
|
|
1149
1056
|
const newIntent = _DappIntentCaller.buildIntent(id, intent, mode);
|
|
1150
|
-
await intentArchivist.insert([
|
|
1151
|
-
newIntent
|
|
1152
|
-
]);
|
|
1057
|
+
await intentArchivist.insert([newIntent]);
|
|
1153
1058
|
}
|
|
1154
1059
|
// Get all intents
|
|
1155
1060
|
async allIntents() {
|
|
@@ -1170,9 +1075,7 @@ var DappIntentCaller = class _DappIntentCaller extends DappCallerBase {
|
|
|
1170
1075
|
schema: PayloadDivinerQuerySchema2,
|
|
1171
1076
|
sourceDappId: dappName
|
|
1172
1077
|
};
|
|
1173
|
-
return await diviner.divine([
|
|
1174
|
-
query
|
|
1175
|
-
]);
|
|
1078
|
+
return await diviner.divine([query]);
|
|
1176
1079
|
}
|
|
1177
1080
|
};
|
|
1178
1081
|
|
|
@@ -1181,9 +1084,6 @@ import { assertEx as assertEx7 } from "@xylabs/sdk-js";
|
|
|
1181
1084
|
import { isDappIntent } from "@xyo-network/os-model";
|
|
1182
1085
|
var NO_RESULTS = [];
|
|
1183
1086
|
var DappIntentResource = class extends DappCallerBase {
|
|
1184
|
-
static {
|
|
1185
|
-
__name(this, "DappIntentResource");
|
|
1186
|
-
}
|
|
1187
1087
|
_allDappIntents;
|
|
1188
1088
|
_latestDappIntent;
|
|
1189
1089
|
constructor(context) {
|
|
@@ -1197,14 +1097,14 @@ var DappIntentResource = class extends DappCallerBase {
|
|
|
1197
1097
|
}
|
|
1198
1098
|
get subscriptions() {
|
|
1199
1099
|
return {
|
|
1200
|
-
allDappIntents:
|
|
1201
|
-
latestDappIntent:
|
|
1100
|
+
allDappIntents: (cb) => this.allDappIntents.subscribe(cb),
|
|
1101
|
+
latestDappIntent: (cb) => this.latestDappIntent.subscribe(cb)
|
|
1202
1102
|
};
|
|
1203
1103
|
}
|
|
1204
1104
|
get views() {
|
|
1205
1105
|
return {
|
|
1206
|
-
allDappIntents:
|
|
1207
|
-
latestDappIntent:
|
|
1106
|
+
allDappIntents: () => this.allDappIntents.getSnapshot(),
|
|
1107
|
+
latestDappIntent: () => this.latestDappIntent.getSnapshot()
|
|
1208
1108
|
};
|
|
1209
1109
|
}
|
|
1210
1110
|
cleanupListeners() {
|
|
@@ -1215,18 +1115,16 @@ var DappIntentResource = class extends DappCallerBase {
|
|
|
1215
1115
|
const archivist = await this.getDappIntentArchivist();
|
|
1216
1116
|
this._allDappIntents = await PayloadStore.create({
|
|
1217
1117
|
archivist,
|
|
1218
|
-
getLatest:
|
|
1118
|
+
getLatest: async () => await archivist.all(),
|
|
1219
1119
|
idFunction: isDappIntent
|
|
1220
1120
|
});
|
|
1221
1121
|
this._latestDappIntent = await PayloadStore.create({
|
|
1222
1122
|
archivist,
|
|
1223
|
-
getLatest:
|
|
1123
|
+
getLatest: async () => {
|
|
1224
1124
|
const all = await archivist.all();
|
|
1225
|
-
const result = all.length > 0 ? [
|
|
1226
|
-
all.at(-1)
|
|
1227
|
-
] : NO_RESULTS;
|
|
1125
|
+
const result = all.length > 0 ? [all.at(-1)] : NO_RESULTS;
|
|
1228
1126
|
return result;
|
|
1229
|
-
},
|
|
1127
|
+
},
|
|
1230
1128
|
idFunction: isDappIntent
|
|
1231
1129
|
});
|
|
1232
1130
|
}
|
|
@@ -1238,7 +1136,12 @@ import semver from "semver";
|
|
|
1238
1136
|
|
|
1239
1137
|
// src/system/Queries.ts
|
|
1240
1138
|
import { PayloadDivinerQuerySchema as PayloadDivinerQuerySchema3 } from "@xyo-network/diviner-payload-model";
|
|
1241
|
-
import {
|
|
1139
|
+
import {
|
|
1140
|
+
DappConfigSchema,
|
|
1141
|
+
DappIconSchema,
|
|
1142
|
+
DappWidgetConfigSchema,
|
|
1143
|
+
UnregisteredDappAccessSchema
|
|
1144
|
+
} from "@xyo-network/os-model";
|
|
1242
1145
|
import { PayloadBuilder as PayloadBuilder3 } from "@xyo-network/payload-builder";
|
|
1243
1146
|
var SystemDappQueries = {
|
|
1244
1147
|
async getDappAccess(diviner, name, version) {
|
|
@@ -1246,14 +1149,10 @@ var SystemDappQueries = {
|
|
|
1246
1149
|
order: "desc",
|
|
1247
1150
|
registeringDappId: name,
|
|
1248
1151
|
schema: PayloadDivinerQuerySchema3,
|
|
1249
|
-
schemas: [
|
|
1250
|
-
UnregisteredDappAccessSchema
|
|
1251
|
-
],
|
|
1152
|
+
schemas: [UnregisteredDappAccessSchema],
|
|
1252
1153
|
version
|
|
1253
1154
|
};
|
|
1254
|
-
return await diviner.divine([
|
|
1255
|
-
accessQuery
|
|
1256
|
-
]);
|
|
1155
|
+
return await diviner.divine([accessQuery]);
|
|
1257
1156
|
},
|
|
1258
1157
|
async getLatestConfig(diviner, name) {
|
|
1259
1158
|
const configQuery = {
|
|
@@ -1261,13 +1160,9 @@ var SystemDappQueries = {
|
|
|
1261
1160
|
name,
|
|
1262
1161
|
order: "desc",
|
|
1263
1162
|
schema: PayloadDivinerQuerySchema3,
|
|
1264
|
-
schemas: [
|
|
1265
|
-
DappConfigSchema
|
|
1266
|
-
]
|
|
1163
|
+
schemas: [DappConfigSchema]
|
|
1267
1164
|
};
|
|
1268
|
-
const [dappConfig] = await diviner.divine([
|
|
1269
|
-
configQuery
|
|
1270
|
-
]);
|
|
1165
|
+
const [dappConfig] = await diviner.divine([configQuery]);
|
|
1271
1166
|
return dappConfig;
|
|
1272
1167
|
},
|
|
1273
1168
|
async getLatestIcon(diviner, name, version) {
|
|
@@ -1275,14 +1170,10 @@ var SystemDappQueries = {
|
|
|
1275
1170
|
name,
|
|
1276
1171
|
order: "desc",
|
|
1277
1172
|
schema: PayloadDivinerQuerySchema3,
|
|
1278
|
-
schemas: [
|
|
1279
|
-
DappIconSchema
|
|
1280
|
-
],
|
|
1173
|
+
schemas: [DappIconSchema],
|
|
1281
1174
|
version
|
|
1282
1175
|
};
|
|
1283
|
-
const [dappIcon] = await diviner.divine([
|
|
1284
|
-
iconQuery
|
|
1285
|
-
]);
|
|
1176
|
+
const [dappIcon] = await diviner.divine([iconQuery]);
|
|
1286
1177
|
return dappIcon;
|
|
1287
1178
|
},
|
|
1288
1179
|
async getWidgetConfigs(diviner, name, version) {
|
|
@@ -1290,14 +1181,10 @@ var SystemDappQueries = {
|
|
|
1290
1181
|
dappId: name,
|
|
1291
1182
|
order: "desc",
|
|
1292
1183
|
schema: PayloadDivinerQuerySchema3,
|
|
1293
|
-
schemas: [
|
|
1294
|
-
DappWidgetConfigSchema
|
|
1295
|
-
],
|
|
1184
|
+
schemas: [DappWidgetConfigSchema],
|
|
1296
1185
|
version
|
|
1297
1186
|
};
|
|
1298
|
-
const widgetConfigs = await diviner.divine([
|
|
1299
|
-
widgetConfigQuery
|
|
1300
|
-
]);
|
|
1187
|
+
const widgetConfigs = await diviner.divine([widgetConfigQuery]);
|
|
1301
1188
|
const uniqueConfigs = {};
|
|
1302
1189
|
for (const widgetConfig of widgetConfigs) {
|
|
1303
1190
|
const hash = await PayloadBuilder3.dataHash(widgetConfig);
|
|
@@ -1309,9 +1196,6 @@ var SystemDappQueries = {
|
|
|
1309
1196
|
|
|
1310
1197
|
// src/system/ManageSystemDapps.ts
|
|
1311
1198
|
var ManageSystemDapps = class extends OsCallerBase {
|
|
1312
|
-
static {
|
|
1313
|
-
__name(this, "ManageSystemDapps");
|
|
1314
|
-
}
|
|
1315
1199
|
defaultSystemDappParams;
|
|
1316
1200
|
defaultSystemDapps;
|
|
1317
1201
|
defaultSystemNames;
|
|
@@ -1327,15 +1211,15 @@ var ManageSystemDapps = class extends OsCallerBase {
|
|
|
1327
1211
|
this.developmentMode = developmentMode;
|
|
1328
1212
|
}
|
|
1329
1213
|
/**
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1214
|
+
* Add a callback to listen for errors throwing during system dapp registration
|
|
1215
|
+
* @param errorListener
|
|
1216
|
+
*/
|
|
1333
1217
|
addErrorListener(errorListener) {
|
|
1334
1218
|
this.onErrorCallbacks.push(errorListener);
|
|
1335
1219
|
}
|
|
1336
1220
|
/**
|
|
1337
|
-
|
|
1338
|
-
|
|
1221
|
+
* Installs the dapps into the OS and builds the appropriate DappSet
|
|
1222
|
+
*/
|
|
1339
1223
|
async install() {
|
|
1340
1224
|
await this.insertPayloads();
|
|
1341
1225
|
return await this.latestSets();
|
|
@@ -1359,13 +1243,9 @@ var ManageSystemDapps = class extends OsCallerBase {
|
|
|
1359
1243
|
console.error(`${systemDappPayload.version} does not appear to be a valid semver value`, e);
|
|
1360
1244
|
continue;
|
|
1361
1245
|
}
|
|
1362
|
-
const [existing] = await archivist.get([
|
|
1363
|
-
await PayloadBuilder4.dataHash(systemDappPayload)
|
|
1364
|
-
]);
|
|
1246
|
+
const [existing] = await archivist.get([await PayloadBuilder4.dataHash(systemDappPayload)]);
|
|
1365
1247
|
if (existing) continue;
|
|
1366
|
-
await archivist.insert([
|
|
1367
|
-
systemDappPayload
|
|
1368
|
-
]);
|
|
1248
|
+
await archivist.insert([systemDappPayload]);
|
|
1369
1249
|
}
|
|
1370
1250
|
return true;
|
|
1371
1251
|
} catch (e) {
|
|
@@ -1421,7 +1301,10 @@ var ManageSystemDapps = class extends OsCallerBase {
|
|
|
1421
1301
|
// src/XyOsDapp.ts
|
|
1422
1302
|
import { assertEx as assertEx9 } from "@xylabs/sdk-js";
|
|
1423
1303
|
import { DappPackageManifestPayloadSchema as DappPackageManifestPayloadSchema2 } from "@xyo-network/os-model";
|
|
1424
|
-
import {
|
|
1304
|
+
import {
|
|
1305
|
+
ManifestWrapper as ManifestWrapper2,
|
|
1306
|
+
ModuleFactoryLocator as ModuleFactoryLocator5
|
|
1307
|
+
} from "@xyo-network/sdk-js";
|
|
1425
1308
|
|
|
1426
1309
|
// src/manifests/dapp-window.manifest.json
|
|
1427
1310
|
var dapp_window_manifest_default = {
|
|
@@ -1466,9 +1349,6 @@ import { assertEx as assertEx8, BaseEmitter as BaseEmitter2 } from "@xylabs/sdk-
|
|
|
1466
1349
|
import { ModuleFactoryLocator as ModuleFactoryLocator4 } from "@xyo-network/sdk-js";
|
|
1467
1350
|
import { Mutex as Mutex2 } from "async-mutex";
|
|
1468
1351
|
var XyOsContextBase = class extends BaseEmitter2 {
|
|
1469
|
-
static {
|
|
1470
|
-
__name(this, "XyOsContextBase");
|
|
1471
|
-
}
|
|
1472
1352
|
_bootMutex = new Mutex2();
|
|
1473
1353
|
_platformLocator;
|
|
1474
1354
|
_root;
|
|
@@ -1552,15 +1432,10 @@ var XyOsContextBase = class extends BaseEmitter2 {
|
|
|
1552
1432
|
|
|
1553
1433
|
// src/XyOsDapp.ts
|
|
1554
1434
|
var XyOsDapp = class extends XyOsContextBase {
|
|
1555
|
-
static {
|
|
1556
|
-
__name(this, "XyOsDapp");
|
|
1557
|
-
}
|
|
1558
1435
|
dapp;
|
|
1559
1436
|
constructor(params) {
|
|
1560
1437
|
super(params);
|
|
1561
|
-
this.dapp = {
|
|
1562
|
-
...params.dapp
|
|
1563
|
-
};
|
|
1438
|
+
this.dapp = { ...params.dapp };
|
|
1564
1439
|
}
|
|
1565
1440
|
get eventBus() {
|
|
1566
1441
|
return this.parent.eventBus;
|
|
@@ -1572,12 +1447,12 @@ var XyOsDapp = class extends XyOsContextBase {
|
|
|
1572
1447
|
return this.parent.exposedNodeOuter;
|
|
1573
1448
|
}
|
|
1574
1449
|
/**
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1450
|
+
* @deprecated Dapps should not have access to the bios. This is done for the
|
|
1451
|
+
* settings dapp, but should be refactored out. Bios could possibly be an
|
|
1452
|
+
* optional property of the parent context passed in for dapps that require
|
|
1453
|
+
* elevated permissions.
|
|
1454
|
+
* ^^^ I believe we may want this here in that is a dApp requests access to the bios it will optionally be there
|
|
1455
|
+
*/
|
|
1581
1456
|
get kernel() {
|
|
1582
1457
|
return assertEx9(this.parent.kernel, () => "Missing kernel");
|
|
1583
1458
|
}
|
|
@@ -1596,18 +1471,16 @@ var XyOsDapp = class extends XyOsContextBase {
|
|
|
1596
1471
|
assertEx9(this._root === void 0, () => "Dapp already booted");
|
|
1597
1472
|
const finalLocator = locator ? (this.params.locator ?? new ModuleFactoryLocator5()).merge(locator) : this.params.locator ?? new ModuleFactoryLocator5();
|
|
1598
1473
|
console.log("XyOsDapp:boot:finalLocator", finalLocator);
|
|
1599
|
-
const dappNodesWrapper = new ManifestWrapper2({
|
|
1600
|
-
...this.manifest,
|
|
1601
|
-
schema: DappPackageManifestPayloadSchema2
|
|
1602
|
-
}, wallet, finalLocator);
|
|
1474
|
+
const dappNodesWrapper = new ManifestWrapper2({ ...this.manifest, schema: DappPackageManifestPayloadSchema2 }, wallet, finalLocator);
|
|
1603
1475
|
const dappNodes = await dappNodesWrapper.loadNodes();
|
|
1604
1476
|
const manifest = dapp_window_manifest_default;
|
|
1605
1477
|
const dappManifestWallet = await wallet.derivePath("99999");
|
|
1606
1478
|
manifest.nodes[0].config.name = this.dapp.name + "Root";
|
|
1607
|
-
const wrapper = new ManifestWrapper2(
|
|
1608
|
-
...manifest,
|
|
1609
|
-
|
|
1610
|
-
|
|
1479
|
+
const wrapper = new ManifestWrapper2(
|
|
1480
|
+
{ ...manifest, schema: DappPackageManifestPayloadSchema2 },
|
|
1481
|
+
dappManifestWallet,
|
|
1482
|
+
finalLocator
|
|
1483
|
+
);
|
|
1611
1484
|
const node = await wrapper.loadNodeFromIndex(0);
|
|
1612
1485
|
for (const dappNode of dappNodes) {
|
|
1613
1486
|
await node.register(dappNode);
|
|
@@ -1624,7 +1497,11 @@ var XyOsDapp = class extends XyOsContextBase {
|
|
|
1624
1497
|
};
|
|
1625
1498
|
|
|
1626
1499
|
// src/registration/DappRegistry.ts
|
|
1627
|
-
import {
|
|
1500
|
+
import {
|
|
1501
|
+
DappRegisteredSchema,
|
|
1502
|
+
DappRegisteredState,
|
|
1503
|
+
isRegisteredDappAccess
|
|
1504
|
+
} from "@xyo-network/os-model";
|
|
1628
1505
|
import { HDWallet as HDWallet4 } from "@xyo-network/sdk-js";
|
|
1629
1506
|
|
|
1630
1507
|
// src/registration/ValidateDappAccessDiviner/Config.ts
|
|
@@ -1635,23 +1512,25 @@ var ValidateDappAccessDivinerConfigSchema = asSchema2("network.xyo.os.dapp.acces
|
|
|
1635
1512
|
|
|
1636
1513
|
// src/registration/ValidateDappAccessDiviner/Diviner.ts
|
|
1637
1514
|
import { AbstractDiviner } from "@xyo-network/diviner-abstract";
|
|
1638
|
-
import {
|
|
1639
|
-
|
|
1515
|
+
import {
|
|
1516
|
+
isDappPackageManifestPayload,
|
|
1517
|
+
isUnregisteredDappAccess,
|
|
1518
|
+
RegisteredDappAccessSchema
|
|
1519
|
+
} from "@xyo-network/os-model";
|
|
1520
|
+
import {
|
|
1521
|
+
HDWallet as HDWallet3,
|
|
1522
|
+
ManifestWrapper as ManifestWrapper3,
|
|
1523
|
+
ModuleFactoryLocator as ModuleFactoryLocator6,
|
|
1524
|
+
PackageManifestPayloadSchema
|
|
1525
|
+
} from "@xyo-network/sdk-js";
|
|
1640
1526
|
|
|
1641
1527
|
// src/models/access/ValidDappAccessInterfaces.ts
|
|
1642
1528
|
import { RegisteredNames, RegisteredNamesInterface } from "@xyo-network/os-model";
|
|
1643
|
-
var ValidDappAccessInterfaces = {
|
|
1644
|
-
[RegisteredNames]: RegisteredNamesInterface
|
|
1645
|
-
};
|
|
1529
|
+
var ValidDappAccessInterfaces = { [RegisteredNames]: RegisteredNamesInterface };
|
|
1646
1530
|
|
|
1647
1531
|
// src/registration/ValidateDappAccessDiviner/Diviner.ts
|
|
1648
1532
|
var ValidateDappAccessDiviner = class extends AbstractDiviner {
|
|
1649
|
-
static
|
|
1650
|
-
__name(this, "ValidateDappAccessDiviner");
|
|
1651
|
-
}
|
|
1652
|
-
static configSchemas = [
|
|
1653
|
-
ValidateDappAccessDivinerConfigSchema
|
|
1654
|
-
];
|
|
1533
|
+
static configSchemas = [ValidateDappAccessDivinerConfigSchema];
|
|
1655
1534
|
async divineHandler(payloads) {
|
|
1656
1535
|
const dappManifest = payloads?.filter(isDappPackageManifestPayload) ?? [];
|
|
1657
1536
|
const accessors = payloads?.filter(isUnregisteredDappAccess) ?? [];
|
|
@@ -1693,33 +1572,32 @@ var ValidateDappAccessDiviner = class extends AbstractDiviner {
|
|
|
1693
1572
|
}
|
|
1694
1573
|
}
|
|
1695
1574
|
} catch (e) {
|
|
1696
|
-
failedAccessors.push(
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1575
|
+
failedAccessors.push(
|
|
1576
|
+
{
|
|
1577
|
+
accessor: access,
|
|
1578
|
+
errorMessage: e.message,
|
|
1579
|
+
schema: FailedAccessorSchema
|
|
1580
|
+
}
|
|
1581
|
+
);
|
|
1701
1582
|
}
|
|
1702
1583
|
}
|
|
1703
|
-
return [
|
|
1704
|
-
...registeredAccessors,
|
|
1705
|
-
...failedAccessors
|
|
1706
|
-
];
|
|
1584
|
+
return [...registeredAccessors, ...failedAccessors];
|
|
1707
1585
|
}
|
|
1708
1586
|
};
|
|
1709
|
-
var compareChildren =
|
|
1587
|
+
var compareChildren = (interfaceChildren, dappChildren) => {
|
|
1710
1588
|
return interfaceChildren.every((interfaceChild) => Object.values(interfaceChild).every((interfaceChildName) => dappChildren.some((dappChild) => Object.values(dappChild).includes(interfaceChildName))));
|
|
1711
|
-
}
|
|
1712
|
-
var dappPackageManifestToPackageManifest =
|
|
1589
|
+
};
|
|
1590
|
+
var dappPackageManifestToPackageManifest = (dappPackageManifest) => {
|
|
1713
1591
|
return {
|
|
1714
1592
|
...dappPackageManifest,
|
|
1715
1593
|
schema: PackageManifestPayloadSchema
|
|
1716
1594
|
};
|
|
1717
|
-
}
|
|
1718
|
-
var getChildrenFromNode =
|
|
1595
|
+
};
|
|
1596
|
+
var getChildrenFromNode = async (node) => {
|
|
1719
1597
|
const nodeManifest = (await node.state())?.[0];
|
|
1720
1598
|
return nodeManifest.status?.children;
|
|
1721
|
-
}
|
|
1722
|
-
var getNodeChildren =
|
|
1599
|
+
};
|
|
1600
|
+
var getNodeChildren = async (manifestToTest, dappParams) => {
|
|
1723
1601
|
const testNodes = await getNodeToTest(manifestToTest, dappParams);
|
|
1724
1602
|
const children = [];
|
|
1725
1603
|
for (const node of testNodes) {
|
|
@@ -1729,30 +1607,35 @@ var getNodeChildren = /* @__PURE__ */ __name(async (manifestToTest, dappParams)
|
|
|
1729
1607
|
}
|
|
1730
1608
|
}
|
|
1731
1609
|
return children;
|
|
1732
|
-
}
|
|
1733
|
-
var getNodeToTest =
|
|
1610
|
+
};
|
|
1611
|
+
var getNodeToTest = async (manifestToTest, dappParams) => {
|
|
1734
1612
|
const dappManifestWrapper = new ManifestWrapper3(manifestToTest, await HDWallet3.random(), dappParams.locator ?? new ModuleFactoryLocator6());
|
|
1735
1613
|
return await dappManifestWrapper.loadNodes();
|
|
1736
|
-
}
|
|
1614
|
+
};
|
|
1737
1615
|
|
|
1738
1616
|
// src/registration/DappRegistry.ts
|
|
1739
1617
|
var DappRegistry = class {
|
|
1740
|
-
static {
|
|
1741
|
-
__name(this, "DappRegistry");
|
|
1742
|
-
}
|
|
1743
1618
|
dappRegistry = /* @__PURE__ */ new Map();
|
|
1744
1619
|
dappSeedPhraseRepository;
|
|
1745
1620
|
constructor(dappSeedPhraseRepository) {
|
|
1746
1621
|
this.dappSeedPhraseRepository = dappSeedPhraseRepository;
|
|
1747
1622
|
}
|
|
1748
1623
|
/**
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1624
|
+
* Register a Dapp with window manager and if successful, return its id
|
|
1625
|
+
* @param dapp Manifest and UI of the Dapp to register
|
|
1626
|
+
* @returns dapp with registration fields
|
|
1627
|
+
*/
|
|
1753
1628
|
async registerDapp(dapp) {
|
|
1754
1629
|
if (dapp) {
|
|
1755
|
-
const {
|
|
1630
|
+
const {
|
|
1631
|
+
exposedModuleIds,
|
|
1632
|
+
manifest,
|
|
1633
|
+
modes,
|
|
1634
|
+
name,
|
|
1635
|
+
version,
|
|
1636
|
+
params,
|
|
1637
|
+
widgetConfigs
|
|
1638
|
+
} = this.extractDappProperties(dapp);
|
|
1756
1639
|
try {
|
|
1757
1640
|
const walletId = await this.dappSeedPhraseRepository.findOrCreate(name);
|
|
1758
1641
|
const registeredAccessors = await this.validateDappAccessPayloads(manifest, dapp.accessors, params);
|
|
@@ -1787,15 +1670,26 @@ var DappRegistry = class {
|
|
|
1787
1670
|
}
|
|
1788
1671
|
}
|
|
1789
1672
|
/**
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1673
|
+
* Unregister a dapp so it can no longer be launched
|
|
1674
|
+
* @param dappId
|
|
1675
|
+
*/
|
|
1793
1676
|
unregisterDapp(dappId) {
|
|
1794
1677
|
this.dappRegistry.delete(dappId);
|
|
1795
1678
|
}
|
|
1796
1679
|
extractDappProperties(dapp) {
|
|
1797
|
-
const {
|
|
1798
|
-
|
|
1680
|
+
const {
|
|
1681
|
+
params,
|
|
1682
|
+
config,
|
|
1683
|
+
widgetConfigs
|
|
1684
|
+
} = dapp;
|
|
1685
|
+
const {
|
|
1686
|
+
exposedModuleIds,
|
|
1687
|
+
manifest,
|
|
1688
|
+
modes,
|
|
1689
|
+
name,
|
|
1690
|
+
sources,
|
|
1691
|
+
version
|
|
1692
|
+
} = config;
|
|
1799
1693
|
return {
|
|
1800
1694
|
exposedModuleIds,
|
|
1801
1695
|
manifest,
|
|
@@ -1810,15 +1704,10 @@ var DappRegistry = class {
|
|
|
1810
1704
|
async validateDappAccessPayloads(manifest, accessors = [], params) {
|
|
1811
1705
|
const validateDappAccess = await ValidateDappAccessDiviner.create({
|
|
1812
1706
|
account: await HDWallet4.random(),
|
|
1813
|
-
config: {
|
|
1814
|
-
schema: ValidateDappAccessDivinerConfigSchema
|
|
1815
|
-
},
|
|
1707
|
+
config: { schema: ValidateDappAccessDivinerConfigSchema },
|
|
1816
1708
|
dappParams: params
|
|
1817
1709
|
});
|
|
1818
|
-
const payloads = await validateDappAccess.divine([
|
|
1819
|
-
manifest,
|
|
1820
|
-
...accessors
|
|
1821
|
-
]);
|
|
1710
|
+
const payloads = await validateDappAccess.divine([manifest, ...accessors]);
|
|
1822
1711
|
const failedAccessors = payloads.filter(isFailedAccessor);
|
|
1823
1712
|
const registeredAccessors = payloads.filter(isRegisteredDappAccess);
|
|
1824
1713
|
if (failedAccessors.length > 0) {
|
|
@@ -1830,9 +1719,6 @@ var DappRegistry = class {
|
|
|
1830
1719
|
|
|
1831
1720
|
// src/registration/DappRegistrationService.ts
|
|
1832
1721
|
var DappRegistrationService = class {
|
|
1833
|
-
static {
|
|
1834
|
-
__name(this, "DappRegistrationService");
|
|
1835
|
-
}
|
|
1836
1722
|
// Dapps that have been built with their own context
|
|
1837
1723
|
builtDapps = {};
|
|
1838
1724
|
dappRegistry;
|
|
@@ -1859,17 +1745,21 @@ var DappRegistrationService = class {
|
|
|
1859
1745
|
};
|
|
1860
1746
|
this.locator = locator;
|
|
1861
1747
|
this.developmentMode = developmentMode;
|
|
1862
|
-
this.manageSystemDapps = new ManageSystemDapps(
|
|
1748
|
+
this.manageSystemDapps = new ManageSystemDapps(
|
|
1749
|
+
context,
|
|
1750
|
+
this.params?.dappNames ?? [],
|
|
1751
|
+
this.params?.dappPayloads ?? [],
|
|
1752
|
+
this.params?.dappParams ?? {},
|
|
1753
|
+
this.locator,
|
|
1754
|
+
this.developmentMode
|
|
1755
|
+
);
|
|
1863
1756
|
this.dappSeedPhraseRepository = new DappSeedPhraseRepository(context, this.params?.dappNames ?? []);
|
|
1864
1757
|
this.dappRegistry = new DappRegistry(this.dappSeedPhraseRepository);
|
|
1865
1758
|
this.addConnectionRequests();
|
|
1866
1759
|
}
|
|
1867
1760
|
async buildDapp(manifest, dappId = NameTransforms.slug(manifest.nodes[0]?.config.name), name = NameTransforms.moduleName(manifest.nodes[0]?.config.name)) {
|
|
1868
1761
|
const dapp = new XyOsDapp({
|
|
1869
|
-
dapp: {
|
|
1870
|
-
id: dappId,
|
|
1871
|
-
name
|
|
1872
|
-
},
|
|
1762
|
+
dapp: { id: dappId, name },
|
|
1873
1763
|
locator: this.locator,
|
|
1874
1764
|
manifest,
|
|
1875
1765
|
parent: this.context,
|
|
@@ -1882,46 +1772,40 @@ var DappRegistrationService = class {
|
|
|
1882
1772
|
return this.params?.dappParams[dappId];
|
|
1883
1773
|
}
|
|
1884
1774
|
async start() {
|
|
1885
|
-
const systemDapps = await this.context.monitor(async () => await this.manageSystemDapps.install(), {
|
|
1886
|
-
name: "Install System dApps"
|
|
1887
|
-
});
|
|
1775
|
+
const systemDapps = await this.context.monitor(async () => await this.manageSystemDapps.install(), { name: "Install System dApps" });
|
|
1888
1776
|
const activeDapps = systemDapps.filter(({ dapp }) => dapp.icon.active === true);
|
|
1889
|
-
const results = await Promise.allSettled(
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
dapp: registeredDapp,
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
}));
|
|
1777
|
+
const results = await Promise.allSettled(
|
|
1778
|
+
activeDapps.map(async (dappSet) => {
|
|
1779
|
+
const { dapp } = dappSet;
|
|
1780
|
+
const registeredDapp = await this.dappRegistry.registerDapp(dapp);
|
|
1781
|
+
const result = { dapp: registeredDapp, dappIcon: dapp.icon };
|
|
1782
|
+
const forgetHandlers = async () => {
|
|
1783
|
+
try {
|
|
1784
|
+
await this.postRegistrationHandlers(result);
|
|
1785
|
+
} catch (e) {
|
|
1786
|
+
console.error("Error in post registration handlers", e);
|
|
1787
|
+
}
|
|
1788
|
+
};
|
|
1789
|
+
forget2(forgetHandlers());
|
|
1790
|
+
return result;
|
|
1791
|
+
})
|
|
1792
|
+
);
|
|
1906
1793
|
const failed = results.filter(rejected).map((result) => {
|
|
1907
1794
|
const reason = result.reason;
|
|
1908
1795
|
return reason instanceof Error ? reason.message : String(reason);
|
|
1909
1796
|
});
|
|
1910
1797
|
const succeeded = results.filter(fulfilled).map((result) => result.value);
|
|
1911
1798
|
for (const registeredDapp of succeeded) this.registeredDappSets.add(registeredDapp);
|
|
1912
|
-
return {
|
|
1913
|
-
failed,
|
|
1914
|
-
succeeded
|
|
1915
|
-
};
|
|
1799
|
+
return { failed, succeeded };
|
|
1916
1800
|
}
|
|
1917
1801
|
addConnectionRequests() {
|
|
1918
1802
|
this.context.eventBus.addConnection(this.dappAccessRequestConnection);
|
|
1919
1803
|
this.context.eventBus.addConnection(this.exposeDappRequestConnection);
|
|
1920
1804
|
}
|
|
1921
1805
|
/**
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1806
|
+
* A method to get the user property from context and eventually modify it before handing it to a dapp
|
|
1807
|
+
* i.e. curating user-approved signers
|
|
1808
|
+
*/
|
|
1925
1809
|
getUser() {
|
|
1926
1810
|
return this.context.user;
|
|
1927
1811
|
}
|
|
@@ -1929,19 +1813,17 @@ var DappRegistrationService = class {
|
|
|
1929
1813
|
if (registeredDapp.dapp) {
|
|
1930
1814
|
if (isRegisteredDappExposedDappSet(registeredDapp)) {
|
|
1931
1815
|
this.registeredExposedDappSets.add(registeredDapp);
|
|
1932
|
-
const exposeIntent = DappIntentCaller.buildIntent(
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
});
|
|
1816
|
+
const exposeIntent = DappIntentCaller.buildIntent(
|
|
1817
|
+
DappIntentCaller.OsDappName,
|
|
1818
|
+
DappIntentTypes.Launch,
|
|
1819
|
+
registeredDapp.dapp.config.name,
|
|
1820
|
+
DappMode2.Exposed
|
|
1821
|
+
);
|
|
1822
|
+
await this.exposeDappRequestConnection.emit(ExposeDappRequestEvent, { payloads: [registeredDapp.dapp.config, exposeIntent] });
|
|
1939
1823
|
}
|
|
1940
1824
|
if (isRegisteredDappAccessDappSet(registeredDapp)) {
|
|
1941
1825
|
this.registeredAccessDappSets.add(registeredDapp);
|
|
1942
|
-
await this.dappAccessRequestConnection.emit(DappAccessRequestEvent, {
|
|
1943
|
-
payloads: registeredDapp.dapp.accessors
|
|
1944
|
-
});
|
|
1826
|
+
await this.dappAccessRequestConnection.emit(DappAccessRequestEvent, { payloads: registeredDapp.dapp.accessors });
|
|
1945
1827
|
}
|
|
1946
1828
|
}
|
|
1947
1829
|
}
|
|
@@ -1951,9 +1833,6 @@ var DappRegistrationService = class {
|
|
|
1951
1833
|
import { assertEx as assertEx10 } from "@xylabs/sdk-js";
|
|
1952
1834
|
import { HDWallet as HDWallet5 } from "@xyo-network/sdk-js";
|
|
1953
1835
|
var Signers = class {
|
|
1954
|
-
static {
|
|
1955
|
-
__name(this, "Signers");
|
|
1956
|
-
}
|
|
1957
1836
|
_paths;
|
|
1958
1837
|
_signerAccounts;
|
|
1959
1838
|
_walletStore;
|
|
@@ -1999,13 +1878,14 @@ var Signers = class {
|
|
|
1999
1878
|
};
|
|
2000
1879
|
|
|
2001
1880
|
// src/stack/Base.ts
|
|
2002
|
-
import {
|
|
1881
|
+
import {
|
|
1882
|
+
assertEx as assertEx11,
|
|
1883
|
+
BaseEmitter as BaseEmitter3,
|
|
1884
|
+
forget as forget3
|
|
1885
|
+
} from "@xylabs/sdk-js";
|
|
2003
1886
|
import { isModuleInstance } from "@xyo-network/module-model";
|
|
2004
1887
|
import { asAttachableNodeInstance } from "@xyo-network/node-model";
|
|
2005
1888
|
var StackBase = class extends BaseEmitter3 {
|
|
2006
|
-
static {
|
|
2007
|
-
__name(this, "StackBase");
|
|
2008
|
-
}
|
|
2009
1889
|
// flag to check that all adapters are initialized
|
|
2010
1890
|
initialized = false;
|
|
2011
1891
|
// adapters to initialize into the stack
|
|
@@ -2040,95 +1920,84 @@ var StackBase = class extends BaseEmitter3 {
|
|
|
2040
1920
|
initialize() {
|
|
2041
1921
|
this.assignStack();
|
|
2042
1922
|
for (const adapter of this.adapterSet) {
|
|
2043
|
-
const driverReadyListener =
|
|
1923
|
+
const driverReadyListener = async ({ node }) => await this.handleDriverReady(node);
|
|
2044
1924
|
adapter.on("driverReady", driverReadyListener);
|
|
2045
1925
|
this.listeners.push({
|
|
2046
1926
|
adapter,
|
|
2047
1927
|
eventName: "driverReady",
|
|
2048
1928
|
listener: driverReadyListener
|
|
2049
1929
|
});
|
|
2050
|
-
const driverErrorListener =
|
|
1930
|
+
const driverErrorListener = async ({ error }) => {
|
|
2051
1931
|
console.error(`Error updating ${this.stackNodeModuleId} stack node`, error);
|
|
2052
|
-
await this.emit("driverError", {
|
|
2053
|
-
|
|
2054
|
-
});
|
|
2055
|
-
}, "driverErrorListener");
|
|
1932
|
+
await this.emit("driverError", { error });
|
|
1933
|
+
};
|
|
2056
1934
|
adapter.on("driverError", driverErrorListener);
|
|
2057
1935
|
this.listeners.push({
|
|
2058
1936
|
adapter,
|
|
2059
1937
|
eventName: "driverError",
|
|
2060
1938
|
listener: driverErrorListener
|
|
2061
1939
|
});
|
|
2062
|
-
const startAdapter =
|
|
1940
|
+
const startAdapter = async () => await adapter.start();
|
|
2063
1941
|
forget3(startAdapter());
|
|
2064
1942
|
}
|
|
2065
1943
|
}
|
|
2066
1944
|
/**
|
|
2067
|
-
|
|
2068
|
-
|
|
1945
|
+
* Stops the stack
|
|
1946
|
+
*/
|
|
2069
1947
|
stop() {
|
|
2070
|
-
for (const {
|
|
1948
|
+
for (const {
|
|
1949
|
+
eventName,
|
|
1950
|
+
listener,
|
|
1951
|
+
adapter
|
|
1952
|
+
} of this.listeners) {
|
|
2071
1953
|
adapter.off(eventName, listener);
|
|
2072
1954
|
}
|
|
2073
1955
|
}
|
|
2074
1956
|
/**
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
1957
|
+
* Adds a node to the stack. Idempotent to avoid adding the
|
|
1958
|
+
* same node multiple times
|
|
1959
|
+
* @param node The node to add to the stack
|
|
1960
|
+
* @returns
|
|
1961
|
+
*/
|
|
2080
1962
|
async addNodeToStackNode(node) {
|
|
2081
1963
|
const stackNode = await this.getStackNode();
|
|
2082
|
-
const existingModule = await stackNode.resolve(node.address, {
|
|
2083
|
-
direction: "down"
|
|
2084
|
-
});
|
|
1964
|
+
const existingModule = await stackNode.resolve(node.address, { direction: "down" });
|
|
2085
1965
|
if (isModuleInstance(existingModule)) return;
|
|
2086
1966
|
await stackNode.register?.(node);
|
|
2087
1967
|
await stackNode.attach?.(node.address, true);
|
|
2088
1968
|
}
|
|
2089
1969
|
assignStack() {
|
|
2090
|
-
const assign =
|
|
1970
|
+
const assign = async () => {
|
|
2091
1971
|
const stackNode = await this.getStackNode();
|
|
2092
1972
|
this._stack = stackNode;
|
|
2093
|
-
}
|
|
1973
|
+
};
|
|
2094
1974
|
forget3(assign());
|
|
2095
1975
|
}
|
|
2096
1976
|
async getStackNode() {
|
|
2097
1977
|
const mod = assertEx11(await this.context.root.resolve(this.stackNodeModuleId), () => `${this.stackNodeModuleId} not found`);
|
|
2098
|
-
return asAttachableNodeInstance(mod, () => `${this.stackNodeModuleId} not a NodeInstance`, {
|
|
2099
|
-
required: true
|
|
2100
|
-
});
|
|
1978
|
+
return asAttachableNodeInstance(mod, () => `${this.stackNodeModuleId} not a NodeInstance`, { required: true });
|
|
2101
1979
|
}
|
|
2102
1980
|
async handleDriverReady(node) {
|
|
2103
1981
|
try {
|
|
2104
|
-
await this.emit("driverReady", {
|
|
2105
|
-
node
|
|
2106
|
-
});
|
|
1982
|
+
await this.emit("driverReady", { node });
|
|
2107
1983
|
await this.addNodeToStackNode(node);
|
|
2108
1984
|
await this.updateInitializationState(node);
|
|
2109
1985
|
} catch (error) {
|
|
2110
1986
|
console.error(`Error updating ${this.stackNodeModuleId} stack node`, node.id, error);
|
|
2111
|
-
await this.emit("stackError", {
|
|
2112
|
-
error
|
|
2113
|
-
});
|
|
1987
|
+
await this.emit("stackError", { error });
|
|
2114
1988
|
}
|
|
2115
1989
|
}
|
|
2116
1990
|
async updateInitializationState(node) {
|
|
2117
1991
|
this.initializedNodes.push(node);
|
|
2118
1992
|
this.initialized = this.adapterSet.every((n) => n.initialized);
|
|
2119
1993
|
if (this.initialized) {
|
|
2120
|
-
await this.emit("initialized", {
|
|
2121
|
-
stack: await this.getStackNode()
|
|
2122
|
-
});
|
|
1994
|
+
await this.emit("initialized", { stack: await this.getStackNode() });
|
|
2123
1995
|
}
|
|
2124
1996
|
}
|
|
2125
1997
|
};
|
|
2126
1998
|
|
|
2127
1999
|
// src/stack/Manager.ts
|
|
2128
2000
|
var StackManager = class {
|
|
2129
|
-
static {
|
|
2130
|
-
__name(this, "StackManager");
|
|
2131
|
-
}
|
|
2132
2001
|
initializedStacksMap = /* @__PURE__ */ new Map();
|
|
2133
2002
|
stackMap;
|
|
2134
2003
|
constructor(stackMap) {
|
|
@@ -2163,15 +2032,18 @@ var StackManager = class {
|
|
|
2163
2032
|
import { ExposedNodeOuterNodeName, PubSubBridgeNodeNodeName } from "@xyo-network/os-model";
|
|
2164
2033
|
|
|
2165
2034
|
// src/adapter/Base.ts
|
|
2166
|
-
import {
|
|
2035
|
+
import {
|
|
2036
|
+
assertEx as assertEx12,
|
|
2037
|
+
BaseEmitter as BaseEmitter4,
|
|
2038
|
+
forget as forget4
|
|
2039
|
+
} from "@xylabs/sdk-js";
|
|
2167
2040
|
import { asArchivistInstance as asArchivistInstance5 } from "@xyo-network/archivist";
|
|
2168
2041
|
import { asAttachableNodeInstance as asAttachableNodeInstance2 } from "@xyo-network/node-model";
|
|
2169
|
-
import {
|
|
2042
|
+
import {
|
|
2043
|
+
asSchema as asSchema3
|
|
2044
|
+
} from "@xyo-network/payload-model";
|
|
2170
2045
|
import { v4 as uuid3 } from "uuid";
|
|
2171
2046
|
var NodeAdapterBase = class extends BaseEmitter4 {
|
|
2172
|
-
static {
|
|
2173
|
-
__name(this, "NodeAdapterBase");
|
|
2174
|
-
}
|
|
2175
2047
|
initialized = false;
|
|
2176
2048
|
_id = "";
|
|
2177
2049
|
driverName;
|
|
@@ -2187,14 +2059,14 @@ var NodeAdapterBase = class extends BaseEmitter4 {
|
|
|
2187
2059
|
}
|
|
2188
2060
|
async start() {
|
|
2189
2061
|
try {
|
|
2190
|
-
const moduleAttachedInsertListener =
|
|
2062
|
+
const moduleAttachedInsertListener = ({ payloads }) => {
|
|
2191
2063
|
const moduleAttachedEvent = this.findModuleEventPayloads(payloads);
|
|
2192
2064
|
for (const payload of moduleAttachedEvent) {
|
|
2193
2065
|
if (payload.name === this.driverName) {
|
|
2194
2066
|
this.validateAndReturnDriver();
|
|
2195
2067
|
}
|
|
2196
2068
|
}
|
|
2197
|
-
}
|
|
2069
|
+
};
|
|
2198
2070
|
const eventsArchivist = await this.getEventsArchivist();
|
|
2199
2071
|
const weakRefInsertListener = new WeakRef(moduleAttachedInsertListener);
|
|
2200
2072
|
const insertListenerRef = weakRefInsertListener.deref();
|
|
@@ -2203,9 +2075,7 @@ var NodeAdapterBase = class extends BaseEmitter4 {
|
|
|
2203
2075
|
if (node) return node;
|
|
2204
2076
|
this.initialized = false;
|
|
2205
2077
|
} catch (error) {
|
|
2206
|
-
await this.emit("driverError", {
|
|
2207
|
-
error
|
|
2208
|
-
});
|
|
2078
|
+
await this.emit("driverError", { error });
|
|
2209
2079
|
}
|
|
2210
2080
|
}
|
|
2211
2081
|
findModuleEventPayloads(payloads) {
|
|
@@ -2216,20 +2086,14 @@ var NodeAdapterBase = class extends BaseEmitter4 {
|
|
|
2216
2086
|
}
|
|
2217
2087
|
async getEventsArchivist() {
|
|
2218
2088
|
const mod = assertEx12(await (await this.kernel.getNode()).resolve("KernelNode:ModuleEvents"), () => "KernelNode:ModuleEvents not found");
|
|
2219
|
-
return asArchivistInstance5(mod, () => `${mod.id} is not an archivist`, {
|
|
2220
|
-
required: true
|
|
2221
|
-
});
|
|
2089
|
+
return asArchivistInstance5(mod, () => `${mod.id} is not an archivist`, { required: true });
|
|
2222
2090
|
}
|
|
2223
2091
|
validateAndReturnDriver() {
|
|
2224
2092
|
const mod = this.kernel.initialized[this.driverName];
|
|
2225
2093
|
if (mod) {
|
|
2226
|
-
const node = asAttachableNodeInstance2(mod, () => `${mod.id} is not a node`, {
|
|
2227
|
-
required: true
|
|
2228
|
-
});
|
|
2094
|
+
const node = asAttachableNodeInstance2(mod, () => `${mod.id} is not a node`, { required: true });
|
|
2229
2095
|
this.initialized = true;
|
|
2230
|
-
const emit =
|
|
2231
|
-
node
|
|
2232
|
-
}), "emit");
|
|
2096
|
+
const emit = async () => await this.emit("driverReady", { node });
|
|
2233
2097
|
forget4(emit());
|
|
2234
2098
|
return node;
|
|
2235
2099
|
}
|
|
@@ -2238,9 +2102,6 @@ var NodeAdapterBase = class extends BaseEmitter4 {
|
|
|
2238
2102
|
|
|
2239
2103
|
// src/adapter/Network.ts
|
|
2240
2104
|
var NetworkAdapter = class extends NodeAdapterBase {
|
|
2241
|
-
static {
|
|
2242
|
-
__name(this, "NetworkAdapter");
|
|
2243
|
-
}
|
|
2244
2105
|
_connection;
|
|
2245
2106
|
constructor(kernel, driverName) {
|
|
2246
2107
|
super(kernel, driverName);
|
|
@@ -2261,9 +2122,6 @@ var NetworkAdapter = class extends NodeAdapterBase {
|
|
|
2261
2122
|
|
|
2262
2123
|
// src/adapter/Settings.ts
|
|
2263
2124
|
var SettingsAdapter = class extends NodeAdapterBase {
|
|
2264
|
-
static {
|
|
2265
|
-
__name(this, "SettingsAdapter");
|
|
2266
|
-
}
|
|
2267
2125
|
_settings = void 0;
|
|
2268
2126
|
constructor(kernel, driverName) {
|
|
2269
2127
|
super(kernel, driverName);
|
|
@@ -2283,31 +2141,26 @@ var SettingsAdapter = class extends NodeAdapterBase {
|
|
|
2283
2141
|
};
|
|
2284
2142
|
|
|
2285
2143
|
// src/adapters/OsPubSubBridgeNetwork.ts
|
|
2286
|
-
var OsPubSubBridgeNetworkAdapters =
|
|
2144
|
+
var OsPubSubBridgeNetworkAdapters = (kernel) => [
|
|
2287
2145
|
new NetworkAdapter(kernel, PubSubBridgeNodeNodeName),
|
|
2288
2146
|
new NetworkAdapter(kernel, ExposedNodeOuterNodeName)
|
|
2289
|
-
]
|
|
2147
|
+
];
|
|
2290
2148
|
|
|
2291
2149
|
// src/adapters/OsSettings.ts
|
|
2292
2150
|
import { OsSettingsNodeName } from "@xyo-network/os-model";
|
|
2293
|
-
var OsSettingsAdapters =
|
|
2294
|
-
new SettingsAdapter(kernel, OsSettingsNodeName)
|
|
2295
|
-
], "OsSettingsAdapters");
|
|
2151
|
+
var OsSettingsAdapters = (kernel) => [new SettingsAdapter(kernel, OsSettingsNodeName)];
|
|
2296
2152
|
|
|
2297
2153
|
// src/adapters/OsXyoPublicNetwork.ts
|
|
2298
2154
|
import { XyoPublicNodeName } from "@xyo-network/os-model";
|
|
2299
|
-
var OsXyoPublicNetworkAdapters =
|
|
2155
|
+
var OsXyoPublicNetworkAdapters = (kernel) => [
|
|
2300
2156
|
new NetworkAdapter(kernel, XyoPublicNodeName)
|
|
2301
|
-
]
|
|
2157
|
+
];
|
|
2302
2158
|
|
|
2303
2159
|
// src/stack/OsPubSubNetworkStack.ts
|
|
2304
2160
|
import { assertEx as assertEx13 } from "@xylabs/sdk-js";
|
|
2305
2161
|
import { asAttachableNodeInstance as asAttachableNodeInstance3, asNodeInstance } from "@xyo-network/node-model";
|
|
2306
2162
|
import { ExposedNodeOuterNodeName as ExposedNodeOuterNodeName2, PubSubBridgeNodeNodeName as PubSubBridgeNodeNodeName2 } from "@xyo-network/os-model";
|
|
2307
2163
|
var OsPubSubNetworkStack = class extends StackBase {
|
|
2308
|
-
static {
|
|
2309
|
-
__name(this, "OsPubSubNetworkStack");
|
|
2310
|
-
}
|
|
2311
2164
|
_exposedNode;
|
|
2312
2165
|
_exposedNodeOuter;
|
|
2313
2166
|
busConnection = osPubSubNetworkReadyConnection();
|
|
@@ -2350,15 +2203,13 @@ var OsPubSubNetworkStack = class extends StackBase {
|
|
|
2350
2203
|
super.stop();
|
|
2351
2204
|
this._exposedNode = void 0;
|
|
2352
2205
|
this._exposedNodeOuter = void 0;
|
|
2353
|
-
if (this.busConnection._id)
|
|
2206
|
+
if (this.busConnection._id)
|
|
2207
|
+
this.context.eventBus.removeConnection(this.busConnection.id);
|
|
2354
2208
|
}
|
|
2355
2209
|
};
|
|
2356
2210
|
|
|
2357
2211
|
// src/stack/OsSettingsStack.ts
|
|
2358
2212
|
var OsSettingsStack = class extends StackBase {
|
|
2359
|
-
static {
|
|
2360
|
-
__name(this, "OsSettingsStack");
|
|
2361
|
-
}
|
|
2362
2213
|
busConnection = osSettingsReadyConnection();
|
|
2363
2214
|
constructor(context, adapters) {
|
|
2364
2215
|
super(context, adapters, "OsSettingsStackNode");
|
|
@@ -2376,9 +2227,6 @@ var OsSettingsStack = class extends StackBase {
|
|
|
2376
2227
|
// src/stack/XyoPublicNetworkStack.ts
|
|
2377
2228
|
import { XyoPublicNodeName as XyoPublicNodeName2 } from "@xyo-network/os-model";
|
|
2378
2229
|
var XyoPublicNetworkStack = class extends StackBase {
|
|
2379
|
-
static {
|
|
2380
|
-
__name(this, "XyoPublicNetworkStack");
|
|
2381
|
-
}
|
|
2382
2230
|
busConnection = osXyoPublicNetworkReadyConnection();
|
|
2383
2231
|
constructor(context, adapters) {
|
|
2384
2232
|
super(context, adapters, "OsXyoPublicNetworkStackNode");
|
|
@@ -2417,9 +2265,6 @@ var OsStackMap = {
|
|
|
2417
2265
|
|
|
2418
2266
|
// src/XyOs.ts
|
|
2419
2267
|
var XyOs = class _XyOs extends XyOsContextBase {
|
|
2420
|
-
static {
|
|
2421
|
-
__name(this, "XyOs");
|
|
2422
|
-
}
|
|
2423
2268
|
_exposedNode;
|
|
2424
2269
|
_exposedNodeOuter;
|
|
2425
2270
|
_kernel;
|
|
@@ -2427,9 +2272,16 @@ var XyOs = class _XyOs extends XyOsContextBase {
|
|
|
2427
2272
|
dappRegistrationService;
|
|
2428
2273
|
signers;
|
|
2429
2274
|
stackManager;
|
|
2430
|
-
constructor({
|
|
2431
|
-
logger
|
|
2432
|
-
|
|
2275
|
+
constructor({
|
|
2276
|
+
logger = console,
|
|
2277
|
+
eventBus = new EventBus(),
|
|
2278
|
+
kernel = new Kernel({ logger }),
|
|
2279
|
+
locator = new ModuleFactoryLocator8(),
|
|
2280
|
+
dappsConfiguration,
|
|
2281
|
+
developmentMode,
|
|
2282
|
+
stackMap = OsStackMap,
|
|
2283
|
+
...params
|
|
2284
|
+
} = {}) {
|
|
2433
2285
|
super({
|
|
2434
2286
|
eventBus,
|
|
2435
2287
|
kernel,
|
|
@@ -2467,19 +2319,14 @@ var XyOs = class _XyOs extends XyOsContextBase {
|
|
|
2467
2319
|
return this.stackManager.stacks;
|
|
2468
2320
|
}
|
|
2469
2321
|
get user() {
|
|
2470
|
-
return {
|
|
2471
|
-
signers: this.signers?.getWalletKindSigner("user")
|
|
2472
|
-
};
|
|
2322
|
+
return { signers: this.signers?.getWalletKindSigner("user") };
|
|
2473
2323
|
}
|
|
2474
2324
|
static async monitor(fn, eventConfig) {
|
|
2475
2325
|
const { name, additionalProperties } = eventConfig;
|
|
2476
2326
|
const monitor = this.monitoring;
|
|
2477
2327
|
monitor?.startTimer(name);
|
|
2478
2328
|
const result = await fn();
|
|
2479
|
-
monitor?.stopTimer({
|
|
2480
|
-
additionalProperties,
|
|
2481
|
-
name
|
|
2482
|
-
});
|
|
2329
|
+
monitor?.stopTimer({ additionalProperties, name });
|
|
2483
2330
|
return result;
|
|
2484
2331
|
}
|
|
2485
2332
|
async boot(wallet, locator = new ModuleFactoryLocator8()) {
|
|
@@ -2488,18 +2335,13 @@ var XyOs = class _XyOs extends XyOsContextBase {
|
|
|
2488
2335
|
return await this._bootMutex.runExclusive(async () => {
|
|
2489
2336
|
await this.eventBus.start();
|
|
2490
2337
|
if (this.kernel?.status === "created") {
|
|
2491
|
-
await this.kernel.boot(await boot(), {
|
|
2492
|
-
locator: fullLocator,
|
|
2493
|
-
kernelDrivers: []
|
|
2494
|
-
});
|
|
2338
|
+
await this.kernel.boot(await boot(), { locator: fullLocator, kernelDrivers: [] });
|
|
2495
2339
|
}
|
|
2496
2340
|
if (this.kernel?.status !== "booted") {
|
|
2497
2341
|
throw new Error("Kernel not booted");
|
|
2498
2342
|
}
|
|
2499
2343
|
assertEx14(this._root === void 0, () => "XyOs already booted");
|
|
2500
|
-
const [root] = await _XyOs.monitor(async () => await loadOsNode(wallet, fullLocator), {
|
|
2501
|
-
name: "Load XyOs"
|
|
2502
|
-
});
|
|
2344
|
+
const [root] = await _XyOs.monitor(async () => await loadOsNode(wallet, fullLocator), { name: "Load XyOs" });
|
|
2503
2345
|
this._root = root;
|
|
2504
2346
|
this.stackManager.initialize(this);
|
|
2505
2347
|
if (this.signers) await this.signers.initialize();
|
|
@@ -2531,30 +2373,25 @@ var XyOs = class _XyOs extends XyOsContextBase {
|
|
|
2531
2373
|
// src/RunningDappCache.ts
|
|
2532
2374
|
var findOrCreateMutex = new Mutex3();
|
|
2533
2375
|
var RunningDappCache = class _RunningDappCache {
|
|
2534
|
-
static {
|
|
2535
|
-
__name(this, "RunningDappCache");
|
|
2536
|
-
}
|
|
2537
2376
|
static _cache = {};
|
|
2538
2377
|
static async findOrCreate(dapp, xyOs, allowedNames, xnsNodeUrl, xnsNetwork) {
|
|
2539
2378
|
const dappId = dapp.config.name;
|
|
2540
|
-
return await XyOs.monitor(
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
name: "Loading dApp"
|
|
2557
|
-
});
|
|
2379
|
+
return await XyOs.monitor(
|
|
2380
|
+
async () => await findOrCreateMutex.runExclusive(async () => {
|
|
2381
|
+
const existingWindowDappSet = _RunningDappCache.get(dappId);
|
|
2382
|
+
if (existingWindowDappSet) {
|
|
2383
|
+
console.debug("[DEBUG]", `RunningDappCache, using existing node for ${dappId}`);
|
|
2384
|
+
const existingDappContext = assertEx15(existingWindowDappSet.context, () => "No context found in existing dapp node");
|
|
2385
|
+
await DappContextCreator.primeDappArchivist(existingDappContext, xyOs, dappId);
|
|
2386
|
+
return existingWindowDappSet;
|
|
2387
|
+
}
|
|
2388
|
+
console.debug("[DEBUG]", "RunningDappCache:creating", dappId);
|
|
2389
|
+
const windowDappSet = await createDappContext(dapp, xyOs, allowedNames, xnsNodeUrl, xnsNetwork);
|
|
2390
|
+
_RunningDappCache.set(dappId, windowDappSet);
|
|
2391
|
+
return windowDappSet;
|
|
2392
|
+
}),
|
|
2393
|
+
{ additionalProperties: { dappId }, name: "Loading dApp" }
|
|
2394
|
+
);
|
|
2558
2395
|
}
|
|
2559
2396
|
static get(key) {
|
|
2560
2397
|
return this._cache[key];
|
|
@@ -2569,9 +2406,6 @@ var RunningDappCache = class _RunningDappCache {
|
|
|
2569
2406
|
|
|
2570
2407
|
// src/access/RunningAccessDappCache.ts
|
|
2571
2408
|
var RunningDappAccessCache = class {
|
|
2572
|
-
static {
|
|
2573
|
-
__name(this, "RunningDappAccessCache");
|
|
2574
|
-
}
|
|
2575
2409
|
static _cache = {};
|
|
2576
2410
|
static get(key) {
|
|
2577
2411
|
return this._cache[key];
|
|
@@ -2586,9 +2420,6 @@ var RunningDappAccessCache = class {
|
|
|
2586
2420
|
|
|
2587
2421
|
// src/access/Caller.ts
|
|
2588
2422
|
var DappAccessCaller = class extends OsCallerBase {
|
|
2589
|
-
static {
|
|
2590
|
-
__name(this, "DappAccessCaller");
|
|
2591
|
-
}
|
|
2592
2423
|
allowedNames;
|
|
2593
2424
|
platformLocator;
|
|
2594
2425
|
registeredDapps;
|
|
@@ -2620,21 +2451,15 @@ var DappAccessCaller = class extends OsCallerBase {
|
|
|
2620
2451
|
async cacheAccessNode(dappAccessor, context) {
|
|
2621
2452
|
const accessNodeId = dappAccessor.rootModuleId;
|
|
2622
2453
|
const accessNodeModule = assertEx16(await context.root.resolve(accessNodeId), () => "Access Node Module not found");
|
|
2623
|
-
const accessNode = asNodeInstance2(accessNodeModule, () => "Access Node Module is not a NodeInstance", {
|
|
2624
|
-
required: true
|
|
2625
|
-
});
|
|
2454
|
+
const accessNode = asNodeInstance2(accessNodeModule, () => "Access Node Module is not a NodeInstance", { required: true });
|
|
2626
2455
|
RunningDappAccessCache.set(dappAccessor.registeringDappId, accessNode);
|
|
2627
2456
|
}
|
|
2628
2457
|
async saveRegisteredDappInterfaces(registeredDappAccess) {
|
|
2629
2458
|
const archivist = await this.getRegisteredDappInterfacesArchivist();
|
|
2630
2459
|
const hash = await PayloadBuilder5.dataHash(registeredDappAccess);
|
|
2631
|
-
const [existing] = await archivist.get([
|
|
2632
|
-
hash
|
|
2633
|
-
]);
|
|
2460
|
+
const [existing] = await archivist.get([hash]);
|
|
2634
2461
|
if (existing) return;
|
|
2635
|
-
await archivist.insert([
|
|
2636
|
-
registeredDappAccess
|
|
2637
|
-
]);
|
|
2462
|
+
await archivist.insert([registeredDappAccess]);
|
|
2638
2463
|
console.debug("[DEBUG] -", `Registered ${registeredDappAccess.registeringDappId} with ${registeredDappAccess.name} interface`);
|
|
2639
2464
|
}
|
|
2640
2465
|
};
|
|
@@ -2643,9 +2468,6 @@ var DappAccessCaller = class extends OsCallerBase {
|
|
|
2643
2468
|
import { assertEx as assertEx17 } from "@xylabs/sdk-js";
|
|
2644
2469
|
import { asArchivistInstance as asArchivistInstance6 } from "@xyo-network/archivist-model";
|
|
2645
2470
|
var AccessNodeQueries = class {
|
|
2646
|
-
static {
|
|
2647
|
-
__name(this, "AccessNodeQueries");
|
|
2648
|
-
}
|
|
2649
2471
|
xyOsContext;
|
|
2650
2472
|
accessRequest;
|
|
2651
2473
|
registeredDappAccess;
|
|
@@ -2673,9 +2495,7 @@ var AccessNodeQueries = class {
|
|
|
2673
2495
|
async getArchivistFromDappNode() {
|
|
2674
2496
|
const archivistPath = this.accessRequest?.destinationArchivist ?? "DappArchivist";
|
|
2675
2497
|
const mod = assertEx17(await this.xyOsContext.root.resolve(archivistPath), () => `Unable to find archivist at ${archivistPath}`);
|
|
2676
|
-
return asArchivistInstance6(mod, () => `Module at ${archivistPath} is not an archivist`, {
|
|
2677
|
-
required: true
|
|
2678
|
-
});
|
|
2498
|
+
return asArchivistInstance6(mod, () => `Module at ${archivistPath} is not an archivist`, { required: true });
|
|
2679
2499
|
}
|
|
2680
2500
|
async getPayloadsFromAccessNode() {
|
|
2681
2501
|
const archivistFromAccessNode = await this.resolveArchivistFromAccessNode();
|
|
@@ -2687,10 +2507,11 @@ var AccessNodeQueries = class {
|
|
|
2687
2507
|
await archivist.insert(payloads);
|
|
2688
2508
|
}
|
|
2689
2509
|
async resolveArchivistFromAccessNode() {
|
|
2690
|
-
const archivist = assertEx17(
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2510
|
+
const archivist = assertEx17(
|
|
2511
|
+
await this.nameServiceNamesAccessNode.resolve("PublicXnsArchivist"),
|
|
2512
|
+
() => "Unable to find archivist at PublicXnsArchivist"
|
|
2513
|
+
);
|
|
2514
|
+
return asArchivistInstance6(archivist, () => "PublicXnsArchivist is not an archivist", { required: true });
|
|
2694
2515
|
}
|
|
2695
2516
|
};
|
|
2696
2517
|
|
|
@@ -2702,42 +2523,33 @@ var XnsArchivistPayloadDivinerModuleName = "XnsArchivistPayloadDiviner";
|
|
|
2702
2523
|
var XnsArchivistModuleName = "XnsArchivist";
|
|
2703
2524
|
var XnsRegistrationsArchivistModuleName = "XnsRegistrationsArchivist";
|
|
2704
2525
|
var AbstractXnsCaller = class {
|
|
2705
|
-
static {
|
|
2706
|
-
__name(this, "AbstractXnsCaller");
|
|
2707
|
-
}
|
|
2708
2526
|
context;
|
|
2709
2527
|
constructor(context) {
|
|
2710
2528
|
this.context = context;
|
|
2711
2529
|
}
|
|
2712
2530
|
/**
|
|
2713
|
-
|
|
2714
|
-
|
|
2531
|
+
* Get the XnsArchivist
|
|
2532
|
+
*/
|
|
2715
2533
|
async getXnsArchivist(pathPrefix) {
|
|
2716
2534
|
const fullyQualifiedPath = pathPrefix ? `${pathPrefix}:${XnsArchivistModuleName}` : XnsArchivistModuleName;
|
|
2717
2535
|
const mod = assertEx18(await this.context.root.resolve(fullyQualifiedPath), () => `${fullyQualifiedPath} not found`);
|
|
2718
|
-
return asArchivistInstance7(mod, () => `${fullyQualifiedPath} is not an archivist`, {
|
|
2719
|
-
required: true
|
|
2720
|
-
});
|
|
2536
|
+
return asArchivistInstance7(mod, () => `${fullyQualifiedPath} is not an archivist`, { required: true });
|
|
2721
2537
|
}
|
|
2722
2538
|
/**
|
|
2723
|
-
|
|
2724
|
-
|
|
2539
|
+
* Get the XnsArchivistPayloadDiviner
|
|
2540
|
+
*/
|
|
2725
2541
|
async getXnsArchivistPayloadDiviner(pathPrefix) {
|
|
2726
2542
|
const fullyQualifiedPath = pathPrefix ? `${pathPrefix}:${XnsArchivistPayloadDivinerModuleName}` : XnsArchivistPayloadDivinerModuleName;
|
|
2727
2543
|
const mod = assertEx18(await this.context.root.resolve(fullyQualifiedPath), () => `${fullyQualifiedPath} not found`);
|
|
2728
|
-
return asDivinerInstance4(mod, () => `${fullyQualifiedPath} is not an diviner`, {
|
|
2729
|
-
required: true
|
|
2730
|
-
});
|
|
2544
|
+
return asDivinerInstance4(mod, () => `${fullyQualifiedPath} is not an diviner`, { required: true });
|
|
2731
2545
|
}
|
|
2732
2546
|
/**
|
|
2733
|
-
|
|
2734
|
-
|
|
2547
|
+
* Get the XnsRegistrationsArchivist
|
|
2548
|
+
*/
|
|
2735
2549
|
async getXnsRegistrationsArchivist(pathPrefix) {
|
|
2736
2550
|
const fullyQualifiedPath = pathPrefix ? `${pathPrefix}:${XnsRegistrationsArchivistModuleName}` : XnsRegistrationsArchivistModuleName;
|
|
2737
2551
|
const mod = assertEx18(await this.context.root.resolve(fullyQualifiedPath), () => `${fullyQualifiedPath} not found`);
|
|
2738
|
-
return asArchivistInstance7(mod, () => `${fullyQualifiedPath} is not an archivist`, {
|
|
2739
|
-
required: true
|
|
2740
|
-
});
|
|
2552
|
+
return asArchivistInstance7(mod, () => `${fullyQualifiedPath} is not an archivist`, { required: true });
|
|
2741
2553
|
}
|
|
2742
2554
|
};
|
|
2743
2555
|
|
|
@@ -2749,29 +2561,22 @@ import { isTemporalIndexingDivinerResultIndex } from "@xyo-network/diviner-tempo
|
|
|
2749
2561
|
import { PayloadDivinerQuerySchema as PayloadDivinerQuerySchema4 } from "@xyo-network/diviner-payload-model";
|
|
2750
2562
|
import { TemporalIndexingDivinerResultIndexSchema } from "@xyo-network/diviner-temporal-indexing-model";
|
|
2751
2563
|
var XnsRegistrationsResourceQueries = {
|
|
2752
|
-
getAllRegistrations:
|
|
2564
|
+
getAllRegistrations: async (diviner) => {
|
|
2753
2565
|
const query = {
|
|
2754
2566
|
limit: 100,
|
|
2755
2567
|
order: "desc",
|
|
2756
2568
|
schema: PayloadDivinerQuerySchema4,
|
|
2757
|
-
schemas: [
|
|
2758
|
-
TemporalIndexingDivinerResultIndexSchema
|
|
2759
|
-
]
|
|
2569
|
+
schemas: [TemporalIndexingDivinerResultIndexSchema]
|
|
2760
2570
|
};
|
|
2761
|
-
return await diviner.divine([
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
}, "getAllRegistrations"),
|
|
2765
|
-
getRecentRegistrations: /* @__PURE__ */ __name(async (archivist) => {
|
|
2571
|
+
return await diviner.divine([query]);
|
|
2572
|
+
},
|
|
2573
|
+
getRecentRegistrations: async (archivist) => {
|
|
2766
2574
|
return (await archivist.all()).toReversed();
|
|
2767
|
-
}
|
|
2575
|
+
}
|
|
2768
2576
|
};
|
|
2769
2577
|
|
|
2770
2578
|
// src/access/interfaces/registered-names/helpers/resource/RegistrationsResource.ts
|
|
2771
2579
|
var XnsRegistrationsResource = class extends AbstractXnsCaller {
|
|
2772
|
-
static {
|
|
2773
|
-
__name(this, "XnsRegistrationsResource");
|
|
2774
|
-
}
|
|
2775
2580
|
_allRegistrations;
|
|
2776
2581
|
pathPrefix;
|
|
2777
2582
|
constructor(context, pathPrefix) {
|
|
@@ -2782,14 +2587,10 @@ var XnsRegistrationsResource = class extends AbstractXnsCaller {
|
|
|
2782
2587
|
return assertEx19(this._allRegistrations);
|
|
2783
2588
|
}
|
|
2784
2589
|
get subscriptions() {
|
|
2785
|
-
return {
|
|
2786
|
-
allRegistrations: /* @__PURE__ */ __name((cb) => this.allRegistrations.subscribe(cb), "allRegistrations")
|
|
2787
|
-
};
|
|
2590
|
+
return { allRegistrations: (cb) => this.allRegistrations.subscribe(cb) };
|
|
2788
2591
|
}
|
|
2789
2592
|
get views() {
|
|
2790
|
-
return {
|
|
2791
|
-
allRegistrations: /* @__PURE__ */ __name(() => this.allRegistrations.getSnapshot(), "allRegistrations")
|
|
2792
|
-
};
|
|
2593
|
+
return { allRegistrations: () => this.allRegistrations.getSnapshot() };
|
|
2793
2594
|
}
|
|
2794
2595
|
cleanupListeners() {
|
|
2795
2596
|
this.allRegistrations.cleanupListeners();
|
|
@@ -2799,7 +2600,7 @@ var XnsRegistrationsResource = class extends AbstractXnsCaller {
|
|
|
2799
2600
|
const xnsArchivist = await this.getXnsArchivist(this.pathPrefix);
|
|
2800
2601
|
this._allRegistrations = await PayloadStore.create({
|
|
2801
2602
|
archivist: xnsArchivist,
|
|
2802
|
-
getLatest:
|
|
2603
|
+
getLatest: async () => await XnsRegistrationsResourceQueries.getAllRegistrations(xnsArchivistPayloadDiviner),
|
|
2803
2604
|
idFunction: isTemporalIndexingDivinerResultIndex
|
|
2804
2605
|
});
|
|
2805
2606
|
}
|
|
@@ -2814,13 +2615,9 @@ var DappAccessRequestQueries = {
|
|
|
2814
2615
|
const query = {
|
|
2815
2616
|
limit: 1,
|
|
2816
2617
|
schema: PayloadDivinerQuerySchema5,
|
|
2817
|
-
schemas: [
|
|
2818
|
-
DappAccessRequestSchema
|
|
2819
|
-
]
|
|
2618
|
+
schemas: [DappAccessRequestSchema]
|
|
2820
2619
|
};
|
|
2821
|
-
const results = await diviner.divine([
|
|
2822
|
-
query
|
|
2823
|
-
]);
|
|
2620
|
+
const results = await diviner.divine([query]);
|
|
2824
2621
|
if (results.length === 0) {
|
|
2825
2622
|
return noResults;
|
|
2826
2623
|
}
|
|
@@ -2830,13 +2627,9 @@ var DappAccessRequestQueries = {
|
|
|
2830
2627
|
const query = {
|
|
2831
2628
|
limit: 1,
|
|
2832
2629
|
schema: PayloadDivinerQuerySchema5,
|
|
2833
|
-
schemas: [
|
|
2834
|
-
RegisteredDappAccessSchema2
|
|
2835
|
-
]
|
|
2630
|
+
schemas: [RegisteredDappAccessSchema2]
|
|
2836
2631
|
};
|
|
2837
|
-
const results = await diviner.divine([
|
|
2838
|
-
query
|
|
2839
|
-
]);
|
|
2632
|
+
const results = await diviner.divine([query]);
|
|
2840
2633
|
if (results.length === 0) {
|
|
2841
2634
|
return noResults;
|
|
2842
2635
|
}
|
|
@@ -2848,9 +2641,6 @@ var DappAccessRequestQueries = {
|
|
|
2848
2641
|
import { assertEx as assertEx20 } from "@xylabs/sdk-js";
|
|
2849
2642
|
import { isDappAccessRequestWithMeta, isRegisteredDappAccess as isRegisteredDappAccess2 } from "@xyo-network/os-model";
|
|
2850
2643
|
var DappAccessRequestResource = class extends DappCallerBase {
|
|
2851
|
-
static {
|
|
2852
|
-
__name(this, "DappAccessRequestResource");
|
|
2853
|
-
}
|
|
2854
2644
|
_accessRequestListener;
|
|
2855
2645
|
_registeredInterfacesListener;
|
|
2856
2646
|
constructor(context) {
|
|
@@ -2864,14 +2654,14 @@ var DappAccessRequestResource = class extends DappCallerBase {
|
|
|
2864
2654
|
}
|
|
2865
2655
|
get subscriptions() {
|
|
2866
2656
|
return {
|
|
2867
|
-
accessRequests:
|
|
2868
|
-
registeredInterfaces:
|
|
2657
|
+
accessRequests: (cb) => this.accessRequestListener.subscribe(cb),
|
|
2658
|
+
registeredInterfaces: (cb) => this.registeredInterfacesListener.subscribe(cb)
|
|
2869
2659
|
};
|
|
2870
2660
|
}
|
|
2871
2661
|
get views() {
|
|
2872
2662
|
return {
|
|
2873
|
-
accessRequests:
|
|
2874
|
-
registeredInterfaces:
|
|
2663
|
+
accessRequests: () => this.accessRequestListener.getSnapshot(),
|
|
2664
|
+
registeredInterfaces: () => this.registeredInterfacesListener.getSnapshot()
|
|
2875
2665
|
};
|
|
2876
2666
|
}
|
|
2877
2667
|
cleanupListeners() {
|
|
@@ -2883,12 +2673,12 @@ var DappAccessRequestResource = class extends DappCallerBase {
|
|
|
2883
2673
|
const diviner = await this.getDappArchivistPayloadDiviner();
|
|
2884
2674
|
this._accessRequestListener = await PayloadStore.create({
|
|
2885
2675
|
archivist,
|
|
2886
|
-
getLatest:
|
|
2676
|
+
getLatest: async () => await DappAccessRequestQueries.getAccessRequests(diviner),
|
|
2887
2677
|
idFunction: isDappAccessRequestWithMeta
|
|
2888
2678
|
});
|
|
2889
2679
|
this._registeredInterfacesListener = await PayloadStore.create({
|
|
2890
2680
|
archivist,
|
|
2891
|
-
getLatest:
|
|
2681
|
+
getLatest: async () => await DappAccessRequestQueries.getRegisteredInterfaces(diviner),
|
|
2892
2682
|
idFunction: isRegisteredDappAccess2
|
|
2893
2683
|
});
|
|
2894
2684
|
}
|
|
@@ -2897,7 +2687,13 @@ var DappAccessRequestResource = class extends DappCallerBase {
|
|
|
2897
2687
|
// src/Caller.ts
|
|
2898
2688
|
import { assertEx as assertEx21 } from "@xylabs/sdk-js";
|
|
2899
2689
|
import { PayloadDivinerQuerySchema as PayloadDivinerQuerySchema7 } from "@xyo-network/diviner-payload-model";
|
|
2900
|
-
import {
|
|
2690
|
+
import {
|
|
2691
|
+
DappAccessRequestSchema as DappAccessRequestSchema2,
|
|
2692
|
+
DappInjectableParamsSchema as DappInjectableParamsSchema2,
|
|
2693
|
+
DappIntentTypes as DappIntentTypes2,
|
|
2694
|
+
DappMode as DappMode3,
|
|
2695
|
+
RegisteredDappAccessSchema as RegisteredDappAccessSchema3
|
|
2696
|
+
} from "@xyo-network/os-model";
|
|
2901
2697
|
import { PayloadBuilder as PayloadBuilder6 } from "@xyo-network/payload-builder";
|
|
2902
2698
|
|
|
2903
2699
|
// src/DefaultsQueries.ts
|
|
@@ -2909,43 +2705,32 @@ var DappDefaultsResourceQueries = {
|
|
|
2909
2705
|
limit: 1,
|
|
2910
2706
|
order: "desc",
|
|
2911
2707
|
schema: PayloadDivinerQuerySchema6,
|
|
2912
|
-
schemas: [
|
|
2913
|
-
DappInjectableParamsSchema
|
|
2914
|
-
],
|
|
2708
|
+
schemas: [DappInjectableParamsSchema],
|
|
2915
2709
|
source: "route"
|
|
2916
2710
|
};
|
|
2917
|
-
return await diviner.divine([
|
|
2918
|
-
query
|
|
2919
|
-
]);
|
|
2711
|
+
return await diviner.divine([query]);
|
|
2920
2712
|
},
|
|
2921
2713
|
async getNodeOsInfo(diviner) {
|
|
2922
2714
|
const query = {
|
|
2923
2715
|
limit: 1,
|
|
2924
2716
|
order: "desc",
|
|
2925
2717
|
schema: PayloadDivinerQuerySchema6,
|
|
2926
|
-
schemas: [
|
|
2927
|
-
NodeOsInfoSchema2
|
|
2928
|
-
]
|
|
2718
|
+
schemas: [NodeOsInfoSchema2]
|
|
2929
2719
|
};
|
|
2930
|
-
return await diviner.divine([
|
|
2931
|
-
query
|
|
2932
|
-
]);
|
|
2720
|
+
return await diviner.divine([query]);
|
|
2933
2721
|
}
|
|
2934
2722
|
};
|
|
2935
2723
|
|
|
2936
2724
|
// src/Caller.ts
|
|
2937
2725
|
var DappCaller = class extends DappCallerBase {
|
|
2938
|
-
static {
|
|
2939
|
-
__name(this, "DappCaller");
|
|
2940
|
-
}
|
|
2941
2726
|
constructor(context) {
|
|
2942
2727
|
super(context);
|
|
2943
2728
|
}
|
|
2944
2729
|
/**
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2730
|
+
* Add payloads to the dapp archivist
|
|
2731
|
+
* @param payloads
|
|
2732
|
+
* @param force
|
|
2733
|
+
*/
|
|
2949
2734
|
async addPayloadsToDappArchivist(payloads = [], force = false) {
|
|
2950
2735
|
const dappArchivist = await this.getDappArchivist();
|
|
2951
2736
|
if (force) {
|
|
@@ -2953,23 +2738,19 @@ var DappCaller = class extends DappCallerBase {
|
|
|
2953
2738
|
} else {
|
|
2954
2739
|
for (const payload of payloads) {
|
|
2955
2740
|
const hash = await PayloadBuilder6.dataHash(payload);
|
|
2956
|
-
const [existing] = await dappArchivist.get([
|
|
2957
|
-
hash
|
|
2958
|
-
]);
|
|
2741
|
+
const [existing] = await dappArchivist.get([hash]);
|
|
2959
2742
|
if (existing) continue;
|
|
2960
|
-
await dappArchivist.insert([
|
|
2961
|
-
payload
|
|
2962
|
-
]);
|
|
2743
|
+
await dappArchivist.insert([payload]);
|
|
2963
2744
|
}
|
|
2964
2745
|
}
|
|
2965
2746
|
}
|
|
2966
2747
|
/**
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2748
|
+
* Build Access Request
|
|
2749
|
+
* @param mode
|
|
2750
|
+
* @param registeredDappAccessHash
|
|
2751
|
+
* @param requestingDappId
|
|
2752
|
+
* @param destinationArchivist
|
|
2753
|
+
*/
|
|
2973
2754
|
buildAccessRequest(mode, registeredDappAccessHash, requestingDappId, destinationArchivist) {
|
|
2974
2755
|
const accessRequest = {
|
|
2975
2756
|
destinationArchivist,
|
|
@@ -2982,51 +2763,43 @@ var DappCaller = class extends DappCallerBase {
|
|
|
2982
2763
|
return accessRequest;
|
|
2983
2764
|
}
|
|
2984
2765
|
/**
|
|
2985
|
-
|
|
2986
|
-
|
|
2766
|
+
* Get all available dapp access requests
|
|
2767
|
+
*/
|
|
2987
2768
|
async getDappAccessPayloads() {
|
|
2988
2769
|
const diviner = await this.getDappArchivistPayloadDiviner();
|
|
2989
2770
|
const query = {
|
|
2990
2771
|
order: "desc",
|
|
2991
2772
|
schema: PayloadDivinerQuerySchema7,
|
|
2992
|
-
schemas: [
|
|
2993
|
-
RegisteredDappAccessSchema3
|
|
2994
|
-
]
|
|
2773
|
+
schemas: [RegisteredDappAccessSchema3]
|
|
2995
2774
|
};
|
|
2996
|
-
return diviner.divine([
|
|
2997
|
-
query
|
|
2998
|
-
]);
|
|
2775
|
+
return diviner.divine([query]);
|
|
2999
2776
|
}
|
|
3000
2777
|
/**
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
2778
|
+
* Get the most recent dapp injectable params
|
|
2779
|
+
* @returns Promise
|
|
2780
|
+
*/
|
|
3004
2781
|
async getDappInjectableParams() {
|
|
3005
2782
|
const diviner = await this.getDappArchivistPayloadDiviner();
|
|
3006
2783
|
return await DappDefaultsResourceQueries.getDappInjectableParamsFromRoute(diviner);
|
|
3007
2784
|
}
|
|
3008
2785
|
/**
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
2786
|
+
* Get the most recent dapp intent
|
|
2787
|
+
* @param name
|
|
2788
|
+
*/
|
|
3012
2789
|
async getRegisteredDappAccessByName(name) {
|
|
3013
2790
|
const diviner = await this.getDappArchivistPayloadDiviner();
|
|
3014
2791
|
const query = {
|
|
3015
2792
|
limit: 1,
|
|
3016
2793
|
name,
|
|
3017
2794
|
schema: PayloadDivinerQuerySchema7,
|
|
3018
|
-
schemas: [
|
|
3019
|
-
RegisteredDappAccessSchema3
|
|
3020
|
-
]
|
|
2795
|
+
schemas: [RegisteredDappAccessSchema3]
|
|
3021
2796
|
};
|
|
3022
|
-
const [payload] = assertEx21(await diviner.divine([
|
|
3023
|
-
query
|
|
3024
|
-
]), () => "Unable to find registered dapp access");
|
|
2797
|
+
const [payload] = assertEx21(await diviner.divine([query]), () => "Unable to find registered dapp access");
|
|
3025
2798
|
return payload;
|
|
3026
2799
|
}
|
|
3027
2800
|
/**
|
|
3028
|
-
|
|
3029
|
-
|
|
2801
|
+
* Get the user wallet
|
|
2802
|
+
*/
|
|
3030
2803
|
getUserAccount(dappName) {
|
|
3031
2804
|
const account = this.context.user.signers?.get(dappName);
|
|
3032
2805
|
if (account) {
|
|
@@ -3036,55 +2809,47 @@ var DappCaller = class extends DappCallerBase {
|
|
|
3036
2809
|
}
|
|
3037
2810
|
}
|
|
3038
2811
|
/**
|
|
3039
|
-
|
|
3040
|
-
|
|
2812
|
+
* Get all wallets for the user
|
|
2813
|
+
*/
|
|
3041
2814
|
getUserAccountsAll() {
|
|
3042
|
-
return [
|
|
3043
|
-
...this.context.user.signers?.values() ?? []
|
|
3044
|
-
];
|
|
2815
|
+
return [...this.context.user.signers?.values() ?? []];
|
|
3045
2816
|
}
|
|
3046
2817
|
/**
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
2818
|
+
* Make Dapp Access Request
|
|
2819
|
+
* @param requestingDappId
|
|
2820
|
+
* @param registeredDappAccessHash
|
|
2821
|
+
* @param mode
|
|
2822
|
+
* @param destinationArchivist
|
|
2823
|
+
*/
|
|
3053
2824
|
async makeDappAccessRequest(requestingDappId, registeredDappAccessHash, mode, destinationArchivist) {
|
|
3054
2825
|
const archivist = await this.getDappArchivist();
|
|
3055
|
-
const registeredDappAccessPayload = await archivist.get([
|
|
3056
|
-
registeredDappAccessHash
|
|
3057
|
-
]);
|
|
2826
|
+
const registeredDappAccessPayload = await archivist.get([registeredDappAccessHash]);
|
|
3058
2827
|
if (!registeredDappAccessPayload) {
|
|
3059
2828
|
throw new Error("No registered dapp access found");
|
|
3060
2829
|
}
|
|
3061
2830
|
const accessRequest = this.buildAccessRequest(mode, registeredDappAccessHash, requestingDappId, destinationArchivist);
|
|
3062
|
-
await archivist.insert([
|
|
3063
|
-
accessRequest
|
|
3064
|
-
]);
|
|
2831
|
+
await archivist.insert([accessRequest]);
|
|
3065
2832
|
}
|
|
3066
2833
|
/**
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
2834
|
+
* Make Dapp Intent Request
|
|
2835
|
+
* @param sourceDappId
|
|
2836
|
+
* @param targetDappId
|
|
2837
|
+
* @param intent
|
|
2838
|
+
* @param mode
|
|
2839
|
+
*/
|
|
3073
2840
|
async makeDappIntentRequest(sourceDappId, targetDappId, intent = DappIntentTypes2.Launch, mode = DappMode3.Window, params) {
|
|
3074
2841
|
if (!sourceDappId) {
|
|
3075
2842
|
throw new Error("No source dapp id provided, dApps must declare a sourceDappId");
|
|
3076
2843
|
}
|
|
3077
2844
|
const archivist = await this.getDappArchivist();
|
|
3078
2845
|
const dappIntent = DappIntentCaller.buildIntent(sourceDappId, intent, targetDappId, mode, params);
|
|
3079
|
-
return await archivist.insert([
|
|
3080
|
-
dappIntent
|
|
3081
|
-
]);
|
|
2846
|
+
return await archivist.insert([dappIntent]);
|
|
3082
2847
|
}
|
|
3083
2848
|
/**
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
2849
|
+
* Set the dapp injectable params
|
|
2850
|
+
* @param searchParams
|
|
2851
|
+
* @param pathname
|
|
2852
|
+
*/
|
|
3088
2853
|
async setDappInjectableRouteParams(searchParams = new URLSearchParams(), pathname) {
|
|
3089
2854
|
const dappArchivist = await this.getDappArchivist();
|
|
3090
2855
|
const params = {};
|
|
@@ -3098,9 +2863,7 @@ var DappCaller = class extends DappCallerBase {
|
|
|
3098
2863
|
source: "route",
|
|
3099
2864
|
timestamp: Date.now()
|
|
3100
2865
|
};
|
|
3101
|
-
await dappArchivist.insert([
|
|
3102
|
-
payload
|
|
3103
|
-
]);
|
|
2866
|
+
await dappArchivist.insert([payload]);
|
|
3104
2867
|
}
|
|
3105
2868
|
};
|
|
3106
2869
|
|
|
@@ -3108,9 +2871,6 @@ var DappCaller = class extends DappCallerBase {
|
|
|
3108
2871
|
import { assertEx as assertEx22 } from "@xylabs/sdk-js";
|
|
3109
2872
|
import { isDappInjectableParams, isNodeOsInfo } from "@xyo-network/os-model";
|
|
3110
2873
|
var DappDefaultsResource = class extends DappCallerBase {
|
|
3111
|
-
static {
|
|
3112
|
-
__name(this, "DappDefaultsResource");
|
|
3113
|
-
}
|
|
3114
2874
|
_dappInjectableParamsFromRouteListener;
|
|
3115
2875
|
_nodeOsInfoListener;
|
|
3116
2876
|
constructor(context) {
|
|
@@ -3124,14 +2884,14 @@ var DappDefaultsResource = class extends DappCallerBase {
|
|
|
3124
2884
|
}
|
|
3125
2885
|
get subscriptions() {
|
|
3126
2886
|
return {
|
|
3127
|
-
dappInjectableParamsFromRoute:
|
|
3128
|
-
nodeOsInfo:
|
|
2887
|
+
dappInjectableParamsFromRoute: (cb) => this.dappInjectableParamsFromRouteListener.subscribe(cb),
|
|
2888
|
+
nodeOsInfo: (cb) => this.nodeOsInfoListener.subscribe(cb)
|
|
3129
2889
|
};
|
|
3130
2890
|
}
|
|
3131
2891
|
get views() {
|
|
3132
2892
|
return {
|
|
3133
|
-
dappInjectableParamsFromRoute:
|
|
3134
|
-
nodeOsInfo:
|
|
2893
|
+
dappInjectableParamsFromRoute: () => this.dappInjectableParamsFromRouteListener.getSnapshot(),
|
|
2894
|
+
nodeOsInfo: () => this.nodeOsInfoListener.getSnapshot()
|
|
3135
2895
|
};
|
|
3136
2896
|
}
|
|
3137
2897
|
cleanupListeners() {
|
|
@@ -3142,12 +2902,12 @@ var DappDefaultsResource = class extends DappCallerBase {
|
|
|
3142
2902
|
const diviner = await this.getDappArchivistPayloadDiviner();
|
|
3143
2903
|
this._nodeOsInfoListener = await PayloadStore.create({
|
|
3144
2904
|
archivist,
|
|
3145
|
-
getLatest:
|
|
2905
|
+
getLatest: async () => await DappDefaultsResourceQueries.getNodeOsInfo(diviner),
|
|
3146
2906
|
idFunction: isNodeOsInfo
|
|
3147
2907
|
});
|
|
3148
2908
|
this._dappInjectableParamsFromRouteListener = await PayloadStore.create({
|
|
3149
2909
|
archivist,
|
|
3150
|
-
getLatest:
|
|
2910
|
+
getLatest: async () => await DappDefaultsResourceQueries.getDappInjectableParamsFromRoute(diviner),
|
|
3151
2911
|
idFunction: isDappInjectableParams
|
|
3152
2912
|
});
|
|
3153
2913
|
}
|
|
@@ -3155,26 +2915,24 @@ var DappDefaultsResource = class extends DappCallerBase {
|
|
|
3155
2915
|
|
|
3156
2916
|
// src/classes/menu/Caller.ts
|
|
3157
2917
|
import { PayloadDivinerQuerySchema as PayloadDivinerQuerySchema8 } from "@xyo-network/diviner-payload-model";
|
|
3158
|
-
import {
|
|
2918
|
+
import {
|
|
2919
|
+
DappInjectableParamsSchema as DappInjectableParamsSchema3,
|
|
2920
|
+
DappNavItemSelectionSchema
|
|
2921
|
+
} from "@xyo-network/os-model";
|
|
3159
2922
|
import { PayloadBuilder as PayloadBuilder7 } from "@xyo-network/payload-builder";
|
|
3160
2923
|
var DappMenuCaller = class extends DappCaller {
|
|
3161
|
-
static {
|
|
3162
|
-
__name(this, "DappMenuCaller");
|
|
3163
|
-
}
|
|
3164
2924
|
constructor(context) {
|
|
3165
2925
|
super(context);
|
|
3166
2926
|
}
|
|
3167
2927
|
/**
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
2928
|
+
* Add new Payloads to the dappArchivist if they haven't already
|
|
2929
|
+
* @param payloads
|
|
2930
|
+
*/
|
|
3171
2931
|
async add(payloads, force = false) {
|
|
3172
2932
|
const dappArchivist = await this.getDappArchivist();
|
|
3173
2933
|
for (const payload of payloads) {
|
|
3174
2934
|
const hash = await PayloadBuilder7.dataHash(payload);
|
|
3175
|
-
const [existing] = await dappArchivist.get([
|
|
3176
|
-
hash
|
|
3177
|
-
]);
|
|
2935
|
+
const [existing] = await dappArchivist.get([hash]);
|
|
3178
2936
|
if (!existing || force) {
|
|
3179
2937
|
await dappArchivist.insert(payloads);
|
|
3180
2938
|
}
|
|
@@ -3186,21 +2944,17 @@ var DappMenuCaller = class extends DappCaller {
|
|
|
3186
2944
|
limit: 1,
|
|
3187
2945
|
order: "desc",
|
|
3188
2946
|
schema: PayloadDivinerQuerySchema8,
|
|
3189
|
-
schemas: [
|
|
3190
|
-
DappNavItemSelectionSchema
|
|
3191
|
-
]
|
|
2947
|
+
schemas: [DappNavItemSelectionSchema]
|
|
3192
2948
|
};
|
|
3193
|
-
return await diviner.divine([
|
|
3194
|
-
query
|
|
3195
|
-
]);
|
|
2949
|
+
return await diviner.divine([query]);
|
|
3196
2950
|
}
|
|
3197
2951
|
/*
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
2952
|
+
* Indicate to the system that a nav item was selected
|
|
2953
|
+
*
|
|
2954
|
+
* @param {string} path
|
|
2955
|
+
* @params {string} injectableParamsPath
|
|
2956
|
+
* @returns Promise
|
|
2957
|
+
*/
|
|
3204
2958
|
async makeNavItemSelection(path, injectableParamsPath) {
|
|
3205
2959
|
const dappArchivist = await this.getDappArchivist();
|
|
3206
2960
|
const payload = {
|
|
@@ -3208,9 +2962,7 @@ var DappMenuCaller = class extends DappCaller {
|
|
|
3208
2962
|
schema: DappNavItemSelectionSchema,
|
|
3209
2963
|
timestamp: Date.now()
|
|
3210
2964
|
};
|
|
3211
|
-
await dappArchivist.insert([
|
|
3212
|
-
payload
|
|
3213
|
-
]);
|
|
2965
|
+
await dappArchivist.insert([payload]);
|
|
3214
2966
|
if (injectableParamsPath) {
|
|
3215
2967
|
const injectableParams = {
|
|
3216
2968
|
params: {},
|
|
@@ -3219,9 +2971,7 @@ var DappMenuCaller = class extends DappCaller {
|
|
|
3219
2971
|
source: "route",
|
|
3220
2972
|
timestamp: Date.now()
|
|
3221
2973
|
};
|
|
3222
|
-
await dappArchivist.insert([
|
|
3223
|
-
injectableParams
|
|
3224
|
-
]);
|
|
2974
|
+
await dappArchivist.insert([injectableParams]);
|
|
3225
2975
|
}
|
|
3226
2976
|
}
|
|
3227
2977
|
};
|
|
@@ -3232,7 +2982,11 @@ import { isDappNavItemSelection, isDappNavMenuConfig } from "@xyo-network/os-mod
|
|
|
3232
2982
|
|
|
3233
2983
|
// src/classes/menu/Queries.ts
|
|
3234
2984
|
import { PayloadDivinerQuerySchema as PayloadDivinerQuerySchema9 } from "@xyo-network/diviner-payload-model";
|
|
3235
|
-
import {
|
|
2985
|
+
import {
|
|
2986
|
+
DappNavItemSchema,
|
|
2987
|
+
DappNavItemSelectionSchema as DappNavItemSelectionSchema2,
|
|
2988
|
+
DappNavMenuConfigSchema
|
|
2989
|
+
} from "@xyo-network/os-model";
|
|
3236
2990
|
var NO_ITEMS = [];
|
|
3237
2991
|
var DappMenuQueries = {
|
|
3238
2992
|
async getMenuConfigs(diviner) {
|
|
@@ -3240,25 +2994,17 @@ var DappMenuQueries = {
|
|
|
3240
2994
|
limit: 1,
|
|
3241
2995
|
order: "desc",
|
|
3242
2996
|
schema: PayloadDivinerQuerySchema9,
|
|
3243
|
-
schemas: [
|
|
3244
|
-
DappNavMenuConfigSchema
|
|
3245
|
-
]
|
|
2997
|
+
schemas: [DappNavMenuConfigSchema]
|
|
3246
2998
|
};
|
|
3247
|
-
return await diviner.divine([
|
|
3248
|
-
query
|
|
3249
|
-
]);
|
|
2999
|
+
return await diviner.divine([query]);
|
|
3250
3000
|
},
|
|
3251
3001
|
async getMenuItems(diviner) {
|
|
3252
3002
|
const query = {
|
|
3253
3003
|
order: "desc",
|
|
3254
3004
|
schema: PayloadDivinerQuerySchema9,
|
|
3255
|
-
schemas: [
|
|
3256
|
-
DappNavItemSchema
|
|
3257
|
-
]
|
|
3005
|
+
schemas: [DappNavItemSchema]
|
|
3258
3006
|
};
|
|
3259
|
-
const results = await diviner.divine([
|
|
3260
|
-
query
|
|
3261
|
-
]);
|
|
3007
|
+
const results = await diviner.divine([query]);
|
|
3262
3008
|
return results.length > 0 ? results : NO_ITEMS;
|
|
3263
3009
|
},
|
|
3264
3010
|
async getNavItemSelections(diviner) {
|
|
@@ -3266,35 +3012,24 @@ var DappMenuQueries = {
|
|
|
3266
3012
|
limit: 1,
|
|
3267
3013
|
order: "desc",
|
|
3268
3014
|
schema: PayloadDivinerQuerySchema9,
|
|
3269
|
-
schemas: [
|
|
3270
|
-
DappNavItemSelectionSchema2
|
|
3271
|
-
]
|
|
3015
|
+
schemas: [DappNavItemSelectionSchema2]
|
|
3272
3016
|
};
|
|
3273
|
-
const results = await diviner.divine([
|
|
3274
|
-
query
|
|
3275
|
-
]);
|
|
3017
|
+
const results = await diviner.divine([query]);
|
|
3276
3018
|
return results.length > 0 ? results : NO_ITEMS;
|
|
3277
3019
|
},
|
|
3278
3020
|
async getVisibleMenuItems(diviner) {
|
|
3279
3021
|
const query = {
|
|
3280
3022
|
order: "desc",
|
|
3281
3023
|
schema: PayloadDivinerQuerySchema9,
|
|
3282
|
-
schemas: [
|
|
3283
|
-
DappNavItemSchema
|
|
3284
|
-
]
|
|
3024
|
+
schemas: [DappNavItemSchema]
|
|
3285
3025
|
};
|
|
3286
|
-
const results = await diviner.divine([
|
|
3287
|
-
query
|
|
3288
|
-
]);
|
|
3026
|
+
const results = await diviner.divine([query]);
|
|
3289
3027
|
return results.filter((menuItem) => menuItem.hidden !== true).toSorted((a, b) => (a.weight ?? 0) > (b.weight ?? 0) ? 1 : -1);
|
|
3290
3028
|
}
|
|
3291
3029
|
};
|
|
3292
3030
|
|
|
3293
3031
|
// src/classes/menu/Resource.ts
|
|
3294
3032
|
var DappMenuResource = class extends DappCaller {
|
|
3295
|
-
static {
|
|
3296
|
-
__name(this, "DappMenuResource");
|
|
3297
|
-
}
|
|
3298
3033
|
_menuConfigListener;
|
|
3299
3034
|
_menuItemListener;
|
|
3300
3035
|
_menuItemSelectionListener;
|
|
@@ -3317,55 +3052,55 @@ var DappMenuResource = class extends DappCaller {
|
|
|
3317
3052
|
/** subscribe to latest set of payloads */
|
|
3318
3053
|
get subscriptions() {
|
|
3319
3054
|
return {
|
|
3320
|
-
menuConfigs:
|
|
3321
|
-
menuItemSelections:
|
|
3322
|
-
menuItems:
|
|
3323
|
-
menuItemsVisible:
|
|
3055
|
+
menuConfigs: (cb) => this.menuConfigListener.subscribe(cb),
|
|
3056
|
+
menuItemSelections: (cb) => this.menuItemSelectionListener.subscribe(cb),
|
|
3057
|
+
menuItems: (cb) => this.menuItemListener.subscribe(cb),
|
|
3058
|
+
menuItemsVisible: (cb) => this.menuItemVisibleListener.subscribe(cb)
|
|
3324
3059
|
};
|
|
3325
3060
|
}
|
|
3326
3061
|
/**
|
|
3327
|
-
|
|
3328
|
-
|
|
3062
|
+
* Return the latest menu payloads from the repository
|
|
3063
|
+
*/
|
|
3329
3064
|
get views() {
|
|
3330
3065
|
return {
|
|
3331
|
-
menuConfigs:
|
|
3332
|
-
menuItemSelections:
|
|
3333
|
-
menuItems:
|
|
3334
|
-
menuItemsVisible:
|
|
3066
|
+
menuConfigs: () => this.menuConfigListener.getSnapshot(),
|
|
3067
|
+
menuItemSelections: () => this.menuItemSelectionListener.getSnapshot(),
|
|
3068
|
+
menuItems: () => this.menuItemListener.getSnapshot(),
|
|
3069
|
+
menuItemsVisible: () => this.menuItemVisibleListener.getSnapshot()
|
|
3335
3070
|
};
|
|
3336
3071
|
}
|
|
3337
3072
|
/**
|
|
3338
|
-
|
|
3339
|
-
|
|
3073
|
+
* Remove all listeners and reset their class members
|
|
3074
|
+
*/
|
|
3340
3075
|
cleanupListeners() {
|
|
3341
3076
|
this.menuConfigListener.cleanupListeners();
|
|
3342
3077
|
this.menuItemListener.cleanupListeners();
|
|
3343
3078
|
this.menuItemSelectionListener.cleanupListeners();
|
|
3344
3079
|
}
|
|
3345
3080
|
/**
|
|
3346
|
-
|
|
3347
|
-
|
|
3081
|
+
* Start the resource
|
|
3082
|
+
*/
|
|
3348
3083
|
async start() {
|
|
3349
3084
|
const dappArchivist = await this.getDappArchivist();
|
|
3350
3085
|
const dappArchivistPayloadDiviner = await this.getDappArchivistPayloadDiviner();
|
|
3351
3086
|
this._menuConfigListener = await PayloadStore.create({
|
|
3352
3087
|
archivist: dappArchivist,
|
|
3353
|
-
getLatest:
|
|
3088
|
+
getLatest: async () => await DappMenuQueries.getMenuConfigs(dappArchivistPayloadDiviner),
|
|
3354
3089
|
idFunction: isDappNavMenuConfig
|
|
3355
3090
|
});
|
|
3356
3091
|
this._menuItemListener = await PayloadStore.create({
|
|
3357
3092
|
archivist: dappArchivist,
|
|
3358
|
-
getLatest:
|
|
3093
|
+
getLatest: async () => await DappMenuQueries.getMenuItems(dappArchivistPayloadDiviner),
|
|
3359
3094
|
idFunction: isDappNavMenuConfig
|
|
3360
3095
|
});
|
|
3361
3096
|
this._menuItemVisibleListener = await PayloadStore.create({
|
|
3362
3097
|
archivist: dappArchivist,
|
|
3363
|
-
getLatest:
|
|
3098
|
+
getLatest: async () => await DappMenuQueries.getVisibleMenuItems(dappArchivistPayloadDiviner),
|
|
3364
3099
|
idFunction: isDappNavMenuConfig
|
|
3365
3100
|
});
|
|
3366
3101
|
this._menuItemSelectionListener = await PayloadStore.create({
|
|
3367
3102
|
archivist: dappArchivist,
|
|
3368
|
-
getLatest:
|
|
3103
|
+
getLatest: async () => await DappMenuQueries.getNavItemSelections(dappArchivistPayloadDiviner),
|
|
3369
3104
|
idFunction: isDappNavItemSelection
|
|
3370
3105
|
});
|
|
3371
3106
|
}
|
|
@@ -3381,24 +3116,20 @@ import { asDivinerInstance as asDivinerInstance5 } from "@xyo-network/diviner-mo
|
|
|
3381
3116
|
var OsSettingsArchivistModuleName = "OsSettingsNode:OsSettingsArchivist";
|
|
3382
3117
|
var OsSettingsArchivistPayloadDivinerModuleName = "OsSettingsNode:OsSettingsArchivistPayloadDiviner";
|
|
3383
3118
|
var OsSettingsCallerBase = class {
|
|
3384
|
-
static {
|
|
3385
|
-
__name(this, "OsSettingsCallerBase");
|
|
3386
|
-
}
|
|
3387
3119
|
context;
|
|
3388
3120
|
constructor(context) {
|
|
3389
3121
|
this.context = context;
|
|
3390
3122
|
}
|
|
3391
3123
|
async getOsSettingsArchivist() {
|
|
3392
3124
|
const mod = assertEx24(await this.context.root.resolve(OsSettingsArchivistModuleName), () => `${OsSettingsArchivistModuleName} not found`);
|
|
3393
|
-
return asArchivistInstance8(mod, () => `${OsSettingsArchivistModuleName} is not an archivist`, {
|
|
3394
|
-
required: true
|
|
3395
|
-
});
|
|
3125
|
+
return asArchivistInstance8(mod, () => `${OsSettingsArchivistModuleName} is not an archivist`, { required: true });
|
|
3396
3126
|
}
|
|
3397
3127
|
async getOsSettingsPayloadDiviner() {
|
|
3398
|
-
const mod = assertEx24(
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3128
|
+
const mod = assertEx24(
|
|
3129
|
+
await this.context.root.resolve(OsSettingsArchivistPayloadDivinerModuleName),
|
|
3130
|
+
() => `${OsSettingsArchivistPayloadDivinerModuleName} not found`
|
|
3131
|
+
);
|
|
3132
|
+
return asDivinerInstance5(mod, () => `${OsSettingsArchivistPayloadDivinerModuleName} is not a diviner`, { required: true });
|
|
3402
3133
|
}
|
|
3403
3134
|
};
|
|
3404
3135
|
|
|
@@ -3406,38 +3137,31 @@ var OsSettingsCallerBase = class {
|
|
|
3406
3137
|
import { PayloadDivinerQuerySchema as PayloadDivinerQuerySchema10 } from "@xyo-network/diviner-payload-model";
|
|
3407
3138
|
import { OsBadgeSchema } from "@xyo-network/os-model";
|
|
3408
3139
|
var OsBadgeQueries = {
|
|
3409
|
-
getBadge:
|
|
3140
|
+
getBadge: async (achievement, diviner) => {
|
|
3410
3141
|
const query = {
|
|
3411
3142
|
achievement,
|
|
3412
3143
|
limit: 1,
|
|
3413
3144
|
order: "desc",
|
|
3414
3145
|
schema: PayloadDivinerQuerySchema10,
|
|
3415
|
-
schemas: [
|
|
3416
|
-
OsBadgeSchema
|
|
3417
|
-
]
|
|
3146
|
+
schemas: [OsBadgeSchema]
|
|
3418
3147
|
};
|
|
3419
|
-
return await diviner.divine([
|
|
3420
|
-
|
|
3421
|
-
]);
|
|
3422
|
-
}, "getBadge")
|
|
3148
|
+
return await diviner.divine([query]);
|
|
3149
|
+
}
|
|
3423
3150
|
};
|
|
3424
3151
|
|
|
3425
3152
|
// src/classes/settings/badge/Caller.ts
|
|
3426
3153
|
var OsBadgeCaller = class extends OsSettingsCallerBase {
|
|
3427
|
-
static {
|
|
3428
|
-
__name(this, "OsBadgeCaller");
|
|
3429
|
-
}
|
|
3430
3154
|
/**
|
|
3431
|
-
|
|
3432
|
-
|
|
3155
|
+
* @param achievement
|
|
3156
|
+
*/
|
|
3433
3157
|
async getBadge(achievement) {
|
|
3434
3158
|
const diviner = await this.getOsSettingsPayloadDiviner();
|
|
3435
3159
|
const results = await OsBadgeQueries.getBadge(achievement, diviner);
|
|
3436
3160
|
return results[0] ?? null;
|
|
3437
3161
|
}
|
|
3438
3162
|
/**
|
|
3439
|
-
|
|
3440
|
-
|
|
3163
|
+
* @param achievement
|
|
3164
|
+
*/
|
|
3441
3165
|
async saveBadge(achievement) {
|
|
3442
3166
|
const badge = {
|
|
3443
3167
|
achievement,
|
|
@@ -3445,9 +3169,7 @@ var OsBadgeCaller = class extends OsSettingsCallerBase {
|
|
|
3445
3169
|
timestamp: Date.now()
|
|
3446
3170
|
};
|
|
3447
3171
|
const archivist = await this.getOsSettingsArchivist();
|
|
3448
|
-
return await archivist.insert([
|
|
3449
|
-
badge
|
|
3450
|
-
]);
|
|
3172
|
+
return await archivist.insert([badge]);
|
|
3451
3173
|
}
|
|
3452
3174
|
};
|
|
3453
3175
|
|
|
@@ -3455,12 +3177,7 @@ var OsBadgeCaller = class extends OsSettingsCallerBase {
|
|
|
3455
3177
|
import { assertEx as assertEx25 } from "@xylabs/sdk-js";
|
|
3456
3178
|
import { isBadgeWithMeta } from "@xyo-network/os-model";
|
|
3457
3179
|
var OsBadgeResource = class extends OsSettingsCallerBase {
|
|
3458
|
-
static
|
|
3459
|
-
__name(this, "OsBadgeResource");
|
|
3460
|
-
}
|
|
3461
|
-
static views = [
|
|
3462
|
-
"savedSeedPhrase"
|
|
3463
|
-
];
|
|
3180
|
+
static views = ["savedSeedPhrase"];
|
|
3464
3181
|
_savedSeedPhrase;
|
|
3465
3182
|
constructor(xyOsContext) {
|
|
3466
3183
|
super(xyOsContext);
|
|
@@ -3469,27 +3186,23 @@ var OsBadgeResource = class extends OsSettingsCallerBase {
|
|
|
3469
3186
|
return assertEx25(this._savedSeedPhrase, () => "Saved seed phrase listener not set");
|
|
3470
3187
|
}
|
|
3471
3188
|
get subscriptions() {
|
|
3472
|
-
return {
|
|
3473
|
-
savedSeedPhrase: /* @__PURE__ */ __name((cb) => this.savedSeedPhrase.subscribe(cb), "savedSeedPhrase")
|
|
3474
|
-
};
|
|
3189
|
+
return { savedSeedPhrase: (cb) => this.savedSeedPhrase.subscribe(cb) };
|
|
3475
3190
|
}
|
|
3476
3191
|
get views() {
|
|
3477
|
-
return {
|
|
3478
|
-
savedSeedPhrase: /* @__PURE__ */ __name(() => this.savedSeedPhrase.latest, "savedSeedPhrase")
|
|
3479
|
-
};
|
|
3192
|
+
return { savedSeedPhrase: () => this.savedSeedPhrase.latest };
|
|
3480
3193
|
}
|
|
3481
3194
|
cleanupListeners() {
|
|
3482
3195
|
this.savedSeedPhrase.cleanupListeners();
|
|
3483
3196
|
}
|
|
3484
3197
|
/**
|
|
3485
|
-
|
|
3486
|
-
|
|
3198
|
+
* start listeners
|
|
3199
|
+
*/
|
|
3487
3200
|
async start() {
|
|
3488
3201
|
const diviner = await this.getOsSettingsPayloadDiviner();
|
|
3489
3202
|
const archivist = await this.getOsSettingsArchivist();
|
|
3490
3203
|
this._savedSeedPhrase = await PayloadStore.create({
|
|
3491
3204
|
archivist,
|
|
3492
|
-
getLatest:
|
|
3205
|
+
getLatest: async () => await OsBadgeQueries.getBadge("savedSeedPhrase", diviner),
|
|
3493
3206
|
idFunction: isBadgeWithMeta
|
|
3494
3207
|
});
|
|
3495
3208
|
}
|
|
@@ -3504,7 +3217,7 @@ import { PayloadBuilder as PayloadBuilder8 } from "@xyo-network/payload-builder"
|
|
|
3504
3217
|
var language = "english";
|
|
3505
3218
|
var standard = "bip-39";
|
|
3506
3219
|
var userWalletLabel = "userWallet";
|
|
3507
|
-
var buildWalletSeedPhrasePayload =
|
|
3220
|
+
var buildWalletSeedPhrasePayload = async (mnemonic, $label) => {
|
|
3508
3221
|
const fields = {
|
|
3509
3222
|
mnemonic: {
|
|
3510
3223
|
language,
|
|
@@ -3514,21 +3227,16 @@ var buildWalletSeedPhrasePayload = /* @__PURE__ */ __name(async (mnemonic, $labe
|
|
|
3514
3227
|
$label,
|
|
3515
3228
|
$timestamp: Date.now()
|
|
3516
3229
|
};
|
|
3517
|
-
const payload = new PayloadBuilder8({
|
|
3518
|
-
schema: WalletSeedPhraseSchema
|
|
3519
|
-
}).fields(fields).build();
|
|
3230
|
+
const payload = new PayloadBuilder8({ schema: WalletSeedPhraseSchema }).fields(fields).build();
|
|
3520
3231
|
const rootHash = await PayloadBuilder8.hash(payload);
|
|
3521
|
-
return {
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
};
|
|
3525
|
-
}, "buildWalletSeedPhrasePayload");
|
|
3526
|
-
var buildUserWalletSeedPhrasePayload = /* @__PURE__ */ __name((mnemonic) => {
|
|
3232
|
+
return { payload, rootHash };
|
|
3233
|
+
};
|
|
3234
|
+
var buildUserWalletSeedPhrasePayload = (mnemonic) => {
|
|
3527
3235
|
return buildWalletSeedPhrasePayload(mnemonic, userWalletLabel);
|
|
3528
|
-
}
|
|
3236
|
+
};
|
|
3529
3237
|
|
|
3530
3238
|
// src/utils/getApiDomain.ts
|
|
3531
|
-
var getApiDomain =
|
|
3239
|
+
var getApiDomain = (scope, apiDomain) => {
|
|
3532
3240
|
if (apiDomain !== void 0) {
|
|
3533
3241
|
return apiDomain;
|
|
3534
3242
|
}
|
|
@@ -3539,21 +3247,24 @@ var getApiDomain = /* @__PURE__ */ __name((scope, apiDomain) => {
|
|
|
3539
3247
|
return "https://beta.archivist.xyo.network";
|
|
3540
3248
|
}
|
|
3541
3249
|
return "https://archivist.xyo.network";
|
|
3542
|
-
}
|
|
3250
|
+
};
|
|
3543
3251
|
|
|
3544
3252
|
// src/utils/renameObjKey.ts
|
|
3545
|
-
var renameObjKey =
|
|
3253
|
+
var renameObjKey = (oldObj, oldKey, newKey) => {
|
|
3546
3254
|
const oldObjKeys = Object.keys(oldObj);
|
|
3547
|
-
const newObj = oldObjKeys.reduce(
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3255
|
+
const newObj = oldObjKeys.reduce(
|
|
3256
|
+
(acc, val) => {
|
|
3257
|
+
if (val === oldKey) {
|
|
3258
|
+
acc[newKey] = oldObj[oldKey];
|
|
3259
|
+
} else {
|
|
3260
|
+
acc[val] = oldObj[val];
|
|
3261
|
+
}
|
|
3262
|
+
return acc;
|
|
3263
|
+
},
|
|
3264
|
+
{}
|
|
3265
|
+
);
|
|
3555
3266
|
return newObj;
|
|
3556
|
-
}
|
|
3267
|
+
};
|
|
3557
3268
|
|
|
3558
3269
|
// src/classes/settings/SettingsQueries.ts
|
|
3559
3270
|
import { PayloadDivinerQuerySchema as PayloadDivinerQuerySchema11 } from "@xyo-network/diviner-payload-model";
|
|
@@ -3566,17 +3277,11 @@ var OsSettingsQueries = {
|
|
|
3566
3277
|
limit: 1,
|
|
3567
3278
|
order: "desc",
|
|
3568
3279
|
schema: PayloadDivinerQuerySchema11,
|
|
3569
|
-
schemas: [
|
|
3570
|
-
WalletSeedPhraseSchema2
|
|
3571
|
-
]
|
|
3280
|
+
schemas: [WalletSeedPhraseSchema2]
|
|
3572
3281
|
};
|
|
3573
|
-
const results = await diviner.divine([
|
|
3574
|
-
query
|
|
3575
|
-
]);
|
|
3282
|
+
const results = await diviner.divine([query]);
|
|
3576
3283
|
const wallet = results.find((payload) => payload.$label === "userWallet");
|
|
3577
|
-
if (wallet) return [
|
|
3578
|
-
wallet
|
|
3579
|
-
];
|
|
3284
|
+
if (wallet) return [wallet];
|
|
3580
3285
|
const legacyWallet = results.find((payload) => payload.$meta?.label === "userWallet");
|
|
3581
3286
|
if (legacyWallet && archivist) {
|
|
3582
3287
|
const legacyMeta = legacyWallet.$meta;
|
|
@@ -3585,15 +3290,9 @@ var OsSettingsQueries = {
|
|
|
3585
3290
|
$label: legacyMeta?.label,
|
|
3586
3291
|
$timestamp: legacyMeta?.$timestamp
|
|
3587
3292
|
};
|
|
3588
|
-
const payload = new PayloadBuilder9({
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
await archivist.insert([
|
|
3592
|
-
payload
|
|
3593
|
-
]);
|
|
3594
|
-
return [
|
|
3595
|
-
payload
|
|
3596
|
-
];
|
|
3293
|
+
const payload = new PayloadBuilder9({ schema: WalletSeedPhraseSchema2 }).fields(newWalletPayloadFields).build();
|
|
3294
|
+
await archivist.insert([payload]);
|
|
3295
|
+
return [payload];
|
|
3597
3296
|
}
|
|
3598
3297
|
return NO_RESULTS2;
|
|
3599
3298
|
},
|
|
@@ -3602,61 +3301,46 @@ var OsSettingsQueries = {
|
|
|
3602
3301
|
limit: 1,
|
|
3603
3302
|
order: "desc",
|
|
3604
3303
|
schema: PayloadDivinerQuerySchema11,
|
|
3605
|
-
schemas: [
|
|
3606
|
-
NodeBackgroundSchema
|
|
3607
|
-
]
|
|
3304
|
+
schemas: [NodeBackgroundSchema]
|
|
3608
3305
|
};
|
|
3609
|
-
return await diviner.divine([
|
|
3610
|
-
query
|
|
3611
|
-
]);
|
|
3306
|
+
return await diviner.divine([query]);
|
|
3612
3307
|
},
|
|
3613
3308
|
async getWallets(diviner) {
|
|
3614
3309
|
const query = {
|
|
3615
3310
|
order: "desc",
|
|
3616
3311
|
schema: PayloadDivinerQuerySchema11,
|
|
3617
|
-
schemas: [
|
|
3618
|
-
WalletSeedPhraseSchema2
|
|
3619
|
-
]
|
|
3312
|
+
schemas: [WalletSeedPhraseSchema2]
|
|
3620
3313
|
};
|
|
3621
|
-
return await diviner.divine([
|
|
3622
|
-
query
|
|
3623
|
-
]);
|
|
3314
|
+
return await diviner.divine([query]);
|
|
3624
3315
|
}
|
|
3625
3316
|
};
|
|
3626
3317
|
|
|
3627
3318
|
// src/classes/settings/Caller.ts
|
|
3628
3319
|
var OsSettingsCaller = class extends OsSettingsCallerBase {
|
|
3629
|
-
static {
|
|
3630
|
-
__name(this, "OsSettingsCaller");
|
|
3631
|
-
}
|
|
3632
3320
|
constructor(context) {
|
|
3633
3321
|
super(context);
|
|
3634
3322
|
}
|
|
3635
3323
|
/**
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3324
|
+
* Add a node background to the settings
|
|
3325
|
+
* @param payload
|
|
3326
|
+
*/
|
|
3639
3327
|
async addNodeBackground(payload) {
|
|
3640
3328
|
const archivist = await this.getOsSettingsArchivist();
|
|
3641
|
-
await archivist.insert([
|
|
3642
|
-
payload
|
|
3643
|
-
]);
|
|
3329
|
+
await archivist.insert([payload]);
|
|
3644
3330
|
}
|
|
3645
3331
|
/**
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3332
|
+
* Add a wallet seed phrase to the settings
|
|
3333
|
+
* @param payload
|
|
3334
|
+
*/
|
|
3649
3335
|
async addWalletSeedPhrase(payload) {
|
|
3650
3336
|
const archivist = await this.getOsSettingsArchivist();
|
|
3651
|
-
await archivist.insert([
|
|
3652
|
-
payload
|
|
3653
|
-
]);
|
|
3337
|
+
await archivist.insert([payload]);
|
|
3654
3338
|
const phrase = payload.mnemonic.mnemonic.join(" ");
|
|
3655
3339
|
await this.context.kernel?.bios?.seedPhraseStore.set("user", phrase);
|
|
3656
3340
|
}
|
|
3657
3341
|
/**
|
|
3658
|
-
|
|
3659
|
-
|
|
3342
|
+
* Get the latest node background
|
|
3343
|
+
*/
|
|
3660
3344
|
async getLatestNodeBackground() {
|
|
3661
3345
|
const diviner = await this.getOsSettingsPayloadDiviner();
|
|
3662
3346
|
const [result] = await OsSettingsQueries.getNodeBackground(diviner);
|
|
@@ -3684,9 +3368,6 @@ var OsSettingsCaller = class extends OsSettingsCallerBase {
|
|
|
3684
3368
|
import { assertEx as assertEx27 } from "@xylabs/sdk-js";
|
|
3685
3369
|
import { isNodeBackground, isWalletSeedPhrase } from "@xyo-network/os-model";
|
|
3686
3370
|
var OsSettingsResource = class extends OsSettingsCallerBase {
|
|
3687
|
-
static {
|
|
3688
|
-
__name(this, "OsSettingsResource");
|
|
3689
|
-
}
|
|
3690
3371
|
_latestUserWalletListener;
|
|
3691
3372
|
_nodeBackgroundListener;
|
|
3692
3373
|
_walletsListener;
|
|
@@ -3701,16 +3382,16 @@ var OsSettingsResource = class extends OsSettingsCallerBase {
|
|
|
3701
3382
|
}
|
|
3702
3383
|
get subscriptions() {
|
|
3703
3384
|
return {
|
|
3704
|
-
latestUserWallet:
|
|
3705
|
-
nodeBackground:
|
|
3706
|
-
wallets:
|
|
3385
|
+
latestUserWallet: (cb) => this.walletsListener.subscribe(cb),
|
|
3386
|
+
nodeBackground: (cb) => this.nodeBackgroundListener.subscribe(cb),
|
|
3387
|
+
wallets: (cb) => this.walletsListener.subscribe(cb)
|
|
3707
3388
|
};
|
|
3708
3389
|
}
|
|
3709
3390
|
get views() {
|
|
3710
3391
|
return {
|
|
3711
|
-
latestUserWallet:
|
|
3712
|
-
nodeBackground:
|
|
3713
|
-
wallets:
|
|
3392
|
+
latestUserWallet: () => this.latestUserWalletListener.latest,
|
|
3393
|
+
nodeBackground: () => this.nodeBackgroundListener.latest,
|
|
3394
|
+
wallets: () => this.walletsListener.latest
|
|
3714
3395
|
};
|
|
3715
3396
|
}
|
|
3716
3397
|
get walletsListener() {
|
|
@@ -3721,24 +3402,24 @@ var OsSettingsResource = class extends OsSettingsCallerBase {
|
|
|
3721
3402
|
this.latestUserWalletListener.cleanupListeners();
|
|
3722
3403
|
}
|
|
3723
3404
|
/**
|
|
3724
|
-
|
|
3725
|
-
|
|
3405
|
+
* start listeners
|
|
3406
|
+
*/
|
|
3726
3407
|
async start() {
|
|
3727
3408
|
const archivist = await this.getOsSettingsArchivist();
|
|
3728
3409
|
const diviner = await this.getOsSettingsPayloadDiviner();
|
|
3729
3410
|
this._walletsListener = await PayloadStore.create({
|
|
3730
3411
|
archivist,
|
|
3731
|
-
getLatest:
|
|
3412
|
+
getLatest: async () => await OsSettingsQueries.getWallets(diviner),
|
|
3732
3413
|
idFunction: isWalletSeedPhrase
|
|
3733
3414
|
});
|
|
3734
3415
|
this._latestUserWalletListener = await PayloadStore.create({
|
|
3735
3416
|
archivist,
|
|
3736
|
-
getLatest:
|
|
3417
|
+
getLatest: async () => await OsSettingsQueries.getLatestUserWallet(diviner),
|
|
3737
3418
|
idFunction: isWalletSeedPhrase
|
|
3738
3419
|
});
|
|
3739
3420
|
this._nodeBackgroundListener = await PayloadStore.create({
|
|
3740
3421
|
archivist,
|
|
3741
|
-
getLatest:
|
|
3422
|
+
getLatest: async () => await OsSettingsQueries.getNodeBackground(diviner),
|
|
3742
3423
|
idFunction: isNodeBackground
|
|
3743
3424
|
});
|
|
3744
3425
|
}
|
|
@@ -3747,17 +3428,10 @@ var OsSettingsResource = class extends OsSettingsCallerBase {
|
|
|
3747
3428
|
// src/helpers/monitor/XyOsMonitor.ts
|
|
3748
3429
|
var DEFAULT_MONITORING_EVENT_NAME = "System Task Duration";
|
|
3749
3430
|
globalThis.getXyOsGlobal = globalThis.getXyOsGlobal ?? (() => {
|
|
3750
|
-
return {
|
|
3751
|
-
tracking: {
|
|
3752
|
-
trackEvent: /* @__PURE__ */ __name((_event, _properties) => void {}, "trackEvent")
|
|
3753
|
-
}
|
|
3754
|
-
};
|
|
3431
|
+
return { tracking: { trackEvent: (_event, _properties) => void {} } };
|
|
3755
3432
|
});
|
|
3756
3433
|
var xyOsGlobal = globalThis.getXyOsGlobal();
|
|
3757
3434
|
var XyOsMonitor = class _XyOsMonitor {
|
|
3758
|
-
static {
|
|
3759
|
-
__name(this, "XyOsMonitor");
|
|
3760
|
-
}
|
|
3761
3435
|
static trackEvent = xyOsGlobal.tracking.trackEvent;
|
|
3762
3436
|
performanceTimers = /* @__PURE__ */ new Map();
|
|
3763
3437
|
startTimer(name) {
|
|
@@ -3786,9 +3460,6 @@ var XyOsMonitor = class _XyOsMonitor {
|
|
|
3786
3460
|
// src/initializer/DappInitializer.ts
|
|
3787
3461
|
import { assertEx as assertEx28 } from "@xylabs/sdk-js";
|
|
3788
3462
|
var DappInitializer = class {
|
|
3789
|
-
static {
|
|
3790
|
-
__name(this, "DappInitializer");
|
|
3791
|
-
}
|
|
3792
3463
|
_config;
|
|
3793
3464
|
constructor(config) {
|
|
3794
3465
|
this._config = config;
|
|
@@ -3801,14 +3472,17 @@ var DappInitializer = class {
|
|
|
3801
3472
|
return await this.initializeDappContext(dappWithWalletId);
|
|
3802
3473
|
}
|
|
3803
3474
|
async initializeDappContext(dappWithWalletId) {
|
|
3804
|
-
const {
|
|
3475
|
+
const {
|
|
3476
|
+
allowedNames,
|
|
3477
|
+
xnsNetwork,
|
|
3478
|
+
xnsNodeUrl,
|
|
3479
|
+
xyOs
|
|
3480
|
+
} = this.config;
|
|
3805
3481
|
return await RunningDappCache.findOrCreate(dappWithWalletId, xyOs, allowedNames ?? [], xnsNodeUrl, xnsNetwork);
|
|
3806
3482
|
}
|
|
3807
3483
|
async installDappWallet() {
|
|
3808
3484
|
const { xyOs, dapp } = this.config;
|
|
3809
|
-
const dappSeedPhraseRepository = new DappSeedPhraseRepository(xyOs, [
|
|
3810
|
-
dapp.config.name
|
|
3811
|
-
]);
|
|
3485
|
+
const dappSeedPhraseRepository = new DappSeedPhraseRepository(xyOs, [dapp.config.name]);
|
|
3812
3486
|
const walletId = await dappSeedPhraseRepository.findOrCreate(dapp.config.name);
|
|
3813
3487
|
return {
|
|
3814
3488
|
...dapp,
|
|
@@ -3824,15 +3498,12 @@ var DappInitializer = class {
|
|
|
3824
3498
|
import { PayloadBuilder as PayloadBuilder10 } from "@xyo-network/payload-builder";
|
|
3825
3499
|
var DISPLAY_EVENT_COUNT_FREQUENCY = 100;
|
|
3826
3500
|
var profileData = {};
|
|
3827
|
-
var profileModuleEvents =
|
|
3501
|
+
var profileModuleEvents = (mod) => {
|
|
3828
3502
|
const modRef = new WeakRef(mod);
|
|
3829
3503
|
mod.onAny(async (eventName, args) => {
|
|
3830
3504
|
const mod2 = modRef.deref();
|
|
3831
3505
|
if (mod2) {
|
|
3832
|
-
const data = profileData[mod2.address] ?? {
|
|
3833
|
-
allEventCount: 0,
|
|
3834
|
-
eventCounts: {}
|
|
3835
|
-
};
|
|
3506
|
+
const data = profileData[mod2.address] ?? { allEventCount: 0, eventCounts: {} };
|
|
3836
3507
|
profileData[mod2.address] = data;
|
|
3837
3508
|
data.allEventCount += 1;
|
|
3838
3509
|
data.eventCounts[eventName] = (data.eventCounts[eventName] ?? 0) + 1;
|
|
@@ -3855,16 +3526,13 @@ var profileModuleEvents = /* @__PURE__ */ __name((mod) => {
|
|
|
3855
3526
|
}
|
|
3856
3527
|
}
|
|
3857
3528
|
});
|
|
3858
|
-
}
|
|
3529
|
+
};
|
|
3859
3530
|
|
|
3860
3531
|
// src/PubSubBridgeCaller.ts
|
|
3861
3532
|
import { assertEx as assertEx29 } from "@xylabs/sdk-js";
|
|
3862
3533
|
import { asBridgeInstance } from "@xyo-network/bridge-model";
|
|
3863
3534
|
import { BridgedPubSubModuleName } from "@xyo-network/os-model";
|
|
3864
3535
|
var PubSubBridgeCaller = class {
|
|
3865
|
-
static {
|
|
3866
|
-
__name(this, "PubSubBridgeCaller");
|
|
3867
|
-
}
|
|
3868
3536
|
node;
|
|
3869
3537
|
constructor(node) {
|
|
3870
3538
|
this.node = node;
|
|
@@ -3884,9 +3552,7 @@ var PubSubBridgeCaller = class {
|
|
|
3884
3552
|
}
|
|
3885
3553
|
async getPubSubBridge() {
|
|
3886
3554
|
const mod = assertEx29(await this.node.resolve(BridgedPubSubModuleName), () => `${BridgedPubSubModuleName} not found`);
|
|
3887
|
-
return asBridgeInstance(mod, () => `${BridgedPubSubModuleName} is not a bridge`, {
|
|
3888
|
-
required: true
|
|
3889
|
-
});
|
|
3555
|
+
return asBridgeInstance(mod, () => `${BridgedPubSubModuleName} is not a bridge`, { required: true });
|
|
3890
3556
|
}
|
|
3891
3557
|
};
|
|
3892
3558
|
export {
|
|
@@ -3991,4 +3657,4 @@ export {
|
|
|
3991
3657
|
tokenPlacesSplitString,
|
|
3992
3658
|
userWalletLabel
|
|
3993
3659
|
};
|
|
3994
|
-
//# sourceMappingURL=index.mjs.map
|
|
3660
|
+
//# sourceMappingURL=index.mjs.map
|