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