@xyo-network/os-runtime 4.1.0 → 4.1.2
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/DappCallerBase.d.ts +2 -2
- package/dist/neutral/OsCallerBase.d.ts +2 -2
- package/dist/neutral/XyOs.d.ts +2 -2
- package/dist/neutral/XyOsDapp.d.ts +2 -2
- package/dist/neutral/access-interfaces/registered-names/helpers/AccessNodeQueries.d.ts +1 -1
- package/dist/neutral/access-interfaces/registered-names/helpers/resource/AbstractXnsCaller.d.ts +1 -1
- package/dist/neutral/adapter/Network.d.ts +1 -1
- package/dist/neutral/adapter/Settings.d.ts +1 -1
- package/dist/neutral/classes/cache/RunningAccessDappCache.d.ts +1 -1
- package/dist/neutral/classes/registration/ValidateDappAccessDiviner/Diviner.d.ts.map +1 -1
- package/dist/neutral/classes/settings/CallerBase.d.ts +1 -1
- package/dist/neutral/index.mjs +989 -640
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/neutral/stack/OsPubSubNetworkStack.d.ts +2 -2
- package/dist/node/DappCallerBase.d.ts +2 -2
- package/dist/node/OsCallerBase.d.ts +2 -2
- package/dist/node/XyOs.d.ts +2 -2
- package/dist/node/XyOsDapp.d.ts +2 -2
- package/dist/node/access-interfaces/registered-names/helpers/AccessNodeQueries.d.ts +1 -1
- package/dist/node/access-interfaces/registered-names/helpers/resource/AbstractXnsCaller.d.ts +1 -1
- package/dist/node/adapter/Network.d.ts +1 -1
- package/dist/node/adapter/Settings.d.ts +1 -1
- package/dist/node/classes/cache/RunningAccessDappCache.d.ts +1 -1
- package/dist/node/classes/registration/ValidateDappAccessDiviner/Diviner.d.ts.map +1 -1
- package/dist/node/classes/settings/CallerBase.d.ts +1 -1
- package/dist/node/index.mjs +989 -640
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/scripts/xyos/command/index.mjs +486 -345
- package/dist/node/scripts/xyos/command/index.mjs.map +1 -1
- package/dist/node/scripts/xyos/index.mjs +487 -360
- package/dist/node/scripts/xyos/index.mjs.map +1 -1
- package/dist/node/scripts/xyos/lib/index.mjs +453 -327
- package/dist/node/scripts/xyos/lib/index.mjs.map +1 -1
- package/dist/node/stack/OsPubSubNetworkStack.d.ts +2 -2
- package/package.json +36 -37
- package/src/classes/registration/ValidateDappAccessDiviner/Diviner.ts +6 -7
package/dist/neutral/index.mjs
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
1
4
|
// src/access-interfaces/registered-names/helpers/AccessNodeQueries.ts
|
|
2
5
|
import { assertEx as assertEx25 } from "@xylabs/assert";
|
|
3
6
|
import { asArchivistInstance as asArchivistInstance7 } from "@xyo-network/archivist-model";
|
|
4
7
|
|
|
5
8
|
// src/classes/cache/RunningAccessDappCache.ts
|
|
6
9
|
var RunningDappAccessCache = class {
|
|
10
|
+
static {
|
|
11
|
+
__name(this, "RunningDappAccessCache");
|
|
12
|
+
}
|
|
7
13
|
static _cache = {};
|
|
8
14
|
static get(key) {
|
|
9
15
|
return this._cache[key];
|
|
@@ -43,6 +49,10 @@ var DappsArchivistPayloadDivinerModuleName = "DappsArchivistPayloadDiviner";
|
|
|
43
49
|
var DappsArchivistPayloadDevelopmentDivinerModuleName = `${DappsArchivistPayloadDivinerModuleName}Development`;
|
|
44
50
|
var RegisteredDappInterfacesArchivistModuleName = "RegisteredDappInterfacesArchivist";
|
|
45
51
|
var OsCallerBase = class {
|
|
52
|
+
static {
|
|
53
|
+
__name(this, "OsCallerBase");
|
|
54
|
+
}
|
|
55
|
+
context;
|
|
46
56
|
constructor(context) {
|
|
47
57
|
this.context = context;
|
|
48
58
|
}
|
|
@@ -53,47 +63,38 @@ var OsCallerBase = class {
|
|
|
53
63
|
}
|
|
54
64
|
// Get the dapps archivist development
|
|
55
65
|
async getDappsArchivistDevelopment() {
|
|
56
|
-
const mod = assertEx(
|
|
57
|
-
await this.context.root.resolve(DappsArchivistDevelopmentModuleName),
|
|
58
|
-
() => `${DappsArchivistDevelopmentModuleName} not found`
|
|
59
|
-
);
|
|
66
|
+
const mod = assertEx(await this.context.root.resolve(DappsArchivistDevelopmentModuleName), () => `${DappsArchivistDevelopmentModuleName} not found`);
|
|
60
67
|
return asArchivistInstance(mod, () => `${DappsArchivistDevelopmentModuleName} is not an archivist`);
|
|
61
68
|
}
|
|
62
69
|
// Get the dapps archivist payload diviner
|
|
63
70
|
async getDappsArchivistPayloadDiviner() {
|
|
64
|
-
const mod = assertEx(
|
|
65
|
-
await this.context.root.resolve(DappsArchivistPayloadDivinerModuleName),
|
|
66
|
-
() => `${DappsArchivistPayloadDivinerModuleName} not found`
|
|
67
|
-
);
|
|
71
|
+
const mod = assertEx(await this.context.root.resolve(DappsArchivistPayloadDivinerModuleName), () => `${DappsArchivistPayloadDivinerModuleName} not found`);
|
|
68
72
|
return asDivinerInstance(mod, () => `${DappsArchivistPayloadDivinerModuleName} is not a diviner`);
|
|
69
73
|
}
|
|
70
74
|
// Get the dapps archivist payload diviner development
|
|
71
75
|
async getDappsArchivistPayloadDivinerDevelopment() {
|
|
72
|
-
const mod = assertEx(
|
|
73
|
-
await this.context.root.resolve(DappsArchivistPayloadDevelopmentDivinerModuleName),
|
|
74
|
-
() => `${DappsArchivistPayloadDevelopmentDivinerModuleName} not found`
|
|
75
|
-
);
|
|
76
|
+
const mod = assertEx(await this.context.root.resolve(DappsArchivistPayloadDevelopmentDivinerModuleName), () => `${DappsArchivistPayloadDevelopmentDivinerModuleName} not found`);
|
|
76
77
|
return asDivinerInstance(mod, () => `${DappsArchivistPayloadDevelopmentDivinerModuleName} is not a diviner`);
|
|
77
78
|
}
|
|
78
79
|
// Get the registered dapp interfaces archivist
|
|
79
80
|
async getRegisteredDappInterfacesArchivist() {
|
|
80
|
-
const mod = assertEx(
|
|
81
|
-
await this.context.root.resolve(RegisteredDappInterfacesArchivistModuleName),
|
|
82
|
-
() => `${RegisteredDappInterfacesArchivistModuleName} not found`
|
|
83
|
-
);
|
|
81
|
+
const mod = assertEx(await this.context.root.resolve(RegisteredDappInterfacesArchivistModuleName), () => `${RegisteredDappInterfacesArchivistModuleName} not found`);
|
|
84
82
|
return asArchivistInstance(mod, () => `${RegisteredDappInterfacesArchivistModuleName} is not an archivist`);
|
|
85
83
|
}
|
|
86
84
|
};
|
|
87
85
|
|
|
88
86
|
// src/classes/dapp/access/Caller.ts
|
|
89
87
|
var DappAccessCaller = class extends OsCallerBase {
|
|
88
|
+
static {
|
|
89
|
+
__name(this, "DappAccessCaller");
|
|
90
|
+
}
|
|
91
|
+
registeredDapps;
|
|
92
|
+
allowedNames;
|
|
93
|
+
xnsNodeUrl;
|
|
94
|
+
xnsNetwork;
|
|
95
|
+
platformLocator;
|
|
90
96
|
constructor(context, registeredDapps, allowedNames, xnsNodeUrl, xnsNetwork, platformLocator = new ModuleFactoryLocator()) {
|
|
91
|
-
super(context);
|
|
92
|
-
this.registeredDapps = registeredDapps;
|
|
93
|
-
this.allowedNames = allowedNames;
|
|
94
|
-
this.xnsNodeUrl = xnsNodeUrl;
|
|
95
|
-
this.xnsNetwork = xnsNetwork;
|
|
96
|
-
this.platformLocator = platformLocator;
|
|
97
|
+
super(context), this.registeredDapps = registeredDapps, this.allowedNames = allowedNames, this.xnsNodeUrl = xnsNodeUrl, this.xnsNetwork = xnsNetwork, this.platformLocator = platformLocator;
|
|
97
98
|
}
|
|
98
99
|
async start() {
|
|
99
100
|
const registeredDappAccessDappSets = this.registeredDapps.filter(isRegisteredDappAccessDappSet);
|
|
@@ -119,9 +120,13 @@ var DappAccessCaller = class extends OsCallerBase {
|
|
|
119
120
|
async saveRegisteredDappInterfaces(registeredDappAccess) {
|
|
120
121
|
const archivist = await this.getRegisteredDappInterfacesArchivist();
|
|
121
122
|
const hash = await PayloadBuilder.dataHash(registeredDappAccess);
|
|
122
|
-
const [existing] = await archivist.get([
|
|
123
|
+
const [existing] = await archivist.get([
|
|
124
|
+
hash
|
|
125
|
+
]);
|
|
123
126
|
if (existing) return;
|
|
124
|
-
await archivist.insert([
|
|
127
|
+
await archivist.insert([
|
|
128
|
+
registeredDappAccess
|
|
129
|
+
]);
|
|
125
130
|
console.debug("[DEBUG] -", `Registered ${registeredDappAccess.registeringDappId} with ${registeredDappAccess.name} interface`);
|
|
126
131
|
}
|
|
127
132
|
};
|
|
@@ -135,9 +140,13 @@ var DappAccessRequestQueries = {
|
|
|
135
140
|
const query = {
|
|
136
141
|
limit: 1,
|
|
137
142
|
schema: PayloadDivinerQuerySchema,
|
|
138
|
-
schemas: [
|
|
143
|
+
schemas: [
|
|
144
|
+
DappAccessRequestSchema
|
|
145
|
+
]
|
|
139
146
|
};
|
|
140
|
-
const results = await diviner.divine([
|
|
147
|
+
const results = await diviner.divine([
|
|
148
|
+
query
|
|
149
|
+
]);
|
|
141
150
|
if (results.length === 0) {
|
|
142
151
|
return noResults;
|
|
143
152
|
}
|
|
@@ -147,9 +156,13 @@ var DappAccessRequestQueries = {
|
|
|
147
156
|
const query = {
|
|
148
157
|
limit: 1,
|
|
149
158
|
schema: PayloadDivinerQuerySchema,
|
|
150
|
-
schemas: [
|
|
159
|
+
schemas: [
|
|
160
|
+
RegisteredDappAccessSchema
|
|
161
|
+
]
|
|
151
162
|
};
|
|
152
|
-
const results = await diviner.divine([
|
|
163
|
+
const results = await diviner.divine([
|
|
164
|
+
query
|
|
165
|
+
]);
|
|
153
166
|
if (results.length === 0) {
|
|
154
167
|
return noResults;
|
|
155
168
|
}
|
|
@@ -171,42 +184,37 @@ var IntentArchivistModuleName = "IntentArchivist";
|
|
|
171
184
|
var IntentArchivistPayloadDivinerModuleName = "IntentArchivistPayloadDiviner";
|
|
172
185
|
var DappArchivistPayloadDivinerModuleName = "DappArchivistPayloadDiviner";
|
|
173
186
|
var DappCallerBase = class {
|
|
187
|
+
static {
|
|
188
|
+
__name(this, "DappCallerBase");
|
|
189
|
+
}
|
|
190
|
+
context;
|
|
174
191
|
constructor(context) {
|
|
175
192
|
this.context = context;
|
|
176
193
|
}
|
|
177
194
|
/**
|
|
178
|
-
|
|
179
|
-
|
|
195
|
+
* Get the DappArchivist
|
|
196
|
+
*/
|
|
180
197
|
async getDappArchivist() {
|
|
181
|
-
const mod = assertEx3(
|
|
182
|
-
await this.context.root.resolve(DappArchivistModuleName),
|
|
183
|
-
() => `${DappArchivistModuleName} not found [${toJsonString(this.context.root.publicChildren())}]`
|
|
184
|
-
);
|
|
198
|
+
const mod = assertEx3(await this.context.root.resolve(DappArchivistModuleName), () => `${DappArchivistModuleName} not found [${toJsonString(this.context.root.publicChildren())}]`);
|
|
185
199
|
return asArchivistInstance2(mod, () => `${DappArchivistModuleName} is not an archivist`);
|
|
186
200
|
}
|
|
187
201
|
/**
|
|
188
|
-
|
|
189
|
-
|
|
202
|
+
* Get the DappArchivistPayloadDiviner
|
|
203
|
+
*/
|
|
190
204
|
async getDappArchivistPayloadDiviner() {
|
|
191
|
-
const mod = assertEx3(
|
|
192
|
-
await this.context.root.resolve(DappArchivistPayloadDivinerModuleName),
|
|
193
|
-
() => `${DappArchivistPayloadDivinerModuleName} not found`
|
|
194
|
-
);
|
|
205
|
+
const mod = assertEx3(await this.context.root.resolve(DappArchivistPayloadDivinerModuleName), () => `${DappArchivistPayloadDivinerModuleName} not found`);
|
|
195
206
|
return asDivinerInstance2(mod, () => `${DappArchivistPayloadDivinerModuleName} is not a diviner`);
|
|
196
207
|
}
|
|
197
208
|
/**
|
|
198
|
-
|
|
199
|
-
|
|
209
|
+
* Get the IntentArchivist
|
|
210
|
+
*/
|
|
200
211
|
async getDappIntentArchivist() {
|
|
201
212
|
const mod = assertEx3(await this.context.root.resolve(IntentArchivistModuleName), () => `${IntentArchivistModuleName} not found`);
|
|
202
213
|
return asArchivistInstance2(mod, () => `${IntentArchivistModuleName} is not an archivist`);
|
|
203
214
|
}
|
|
204
215
|
// Get the IntentArchivistPayloadDiviner
|
|
205
216
|
async getDappIntentArchivistPayloadDiviner() {
|
|
206
|
-
const mod = assertEx3(
|
|
207
|
-
await this.context.root.resolve(IntentArchivistPayloadDivinerModuleName),
|
|
208
|
-
() => `${IntentArchivistPayloadDivinerModuleName} not found`
|
|
209
|
-
);
|
|
217
|
+
const mod = assertEx3(await this.context.root.resolve(IntentArchivistPayloadDivinerModuleName), () => `${IntentArchivistPayloadDivinerModuleName} not found`);
|
|
210
218
|
return asDivinerInstance2(mod, () => `${IntentArchivistPayloadDivinerModuleName} is not a diviner`);
|
|
211
219
|
}
|
|
212
220
|
};
|
|
@@ -215,36 +223,38 @@ var DappCallerBase = class {
|
|
|
215
223
|
import { asDivinerInstance as asDivinerInstance3 } from "@xyo-network/diviner-model";
|
|
216
224
|
import { ResolveHelper } from "@xyo-network/module-model";
|
|
217
225
|
import { NameRegistrarTransformer } from "@xyo-network/module-resolver";
|
|
218
|
-
var initializeXns = async (xnsNode) => {
|
|
226
|
+
var initializeXns = /* @__PURE__ */ __name(async (xnsNode) => {
|
|
219
227
|
if (ResolveHelper.transformers.length === 0) {
|
|
220
228
|
const registrarDiviner = asDivinerInstance3(await xnsNode?.resolve("AddressRecords:AddressRecordIndexDiviner"));
|
|
221
229
|
if (registrarDiviner) {
|
|
222
230
|
const transformer = new NameRegistrarTransformer(registrarDiviner, "xyo");
|
|
223
|
-
ResolveHelper.transformers = [
|
|
231
|
+
ResolveHelper.transformers = [
|
|
232
|
+
transformer
|
|
233
|
+
];
|
|
224
234
|
return true;
|
|
225
235
|
}
|
|
226
236
|
}
|
|
227
237
|
return false;
|
|
228
|
-
};
|
|
238
|
+
}, "initializeXns");
|
|
229
239
|
|
|
230
240
|
// src/lib/isPayload.ts
|
|
231
241
|
import { AsObjectFactory } from "@xylabs/object";
|
|
232
|
-
var isObject = (x) => {
|
|
242
|
+
var isObject = /* @__PURE__ */ __name((x) => {
|
|
233
243
|
return typeof x === "object" && !Array.isArray(x);
|
|
234
|
-
};
|
|
235
|
-
var isAnyPayload = (obj) => {
|
|
244
|
+
}, "isObject");
|
|
245
|
+
var isAnyPayload = /* @__PURE__ */ __name((obj) => {
|
|
236
246
|
if (isObject(obj)) {
|
|
237
247
|
return typeof obj.schema === "string";
|
|
238
248
|
}
|
|
239
249
|
return false;
|
|
240
|
-
};
|
|
241
|
-
var isPayload = (schema) => (obj) => {
|
|
250
|
+
}, "isAnyPayload");
|
|
251
|
+
var isPayload = /* @__PURE__ */ __name((schema) => (obj) => {
|
|
242
252
|
if (isAnyPayload(obj)) {
|
|
243
253
|
return schema.includes(obj.schema);
|
|
244
254
|
}
|
|
245
255
|
return false;
|
|
246
|
-
};
|
|
247
|
-
var asPayload = (schema) => AsObjectFactory.create(isPayload(schema));
|
|
256
|
+
}, "isPayload");
|
|
257
|
+
var asPayload = /* @__PURE__ */ __name((schema) => AsObjectFactory.create(isPayload(schema)), "asPayload");
|
|
248
258
|
|
|
249
259
|
// src/lib/ModuleNames.ts
|
|
250
260
|
var DevelopArchivist = "DevelopArchivist";
|
|
@@ -252,9 +262,15 @@ var NodeSentinel = "NodeSentinel";
|
|
|
252
262
|
|
|
253
263
|
// src/lib/ModuleAccountPaths.ts
|
|
254
264
|
var RemoteNodeArchivistOffsetPaths = {
|
|
255
|
-
Kerplunk: {
|
|
256
|
-
|
|
257
|
-
|
|
265
|
+
Kerplunk: {
|
|
266
|
+
[DevelopArchivist]: "118"
|
|
267
|
+
},
|
|
268
|
+
Local: {
|
|
269
|
+
[DevelopArchivist]: "115"
|
|
270
|
+
},
|
|
271
|
+
Main: {
|
|
272
|
+
[DevelopArchivist]: "121"
|
|
273
|
+
}
|
|
258
274
|
};
|
|
259
275
|
var ModuleOffsetPaths = {
|
|
260
276
|
IdWitness: "1",
|
|
@@ -274,6 +290,10 @@ var ModuleOffsetPaths = {
|
|
|
274
290
|
|
|
275
291
|
// src/lib/NameTransforms.ts
|
|
276
292
|
var NameTransforms = class _NameTransforms {
|
|
293
|
+
static {
|
|
294
|
+
__name(this, "NameTransforms");
|
|
295
|
+
}
|
|
296
|
+
value;
|
|
277
297
|
constructor(value) {
|
|
278
298
|
this.value = value;
|
|
279
299
|
}
|
|
@@ -299,32 +319,36 @@ var NameTransforms = class _NameTransforms {
|
|
|
299
319
|
|
|
300
320
|
// src/lib/PayloadStore.ts
|
|
301
321
|
var PayloadStore = class {
|
|
322
|
+
static {
|
|
323
|
+
__name(this, "PayloadStore");
|
|
324
|
+
}
|
|
325
|
+
archivist;
|
|
326
|
+
latest;
|
|
327
|
+
deleteListeners;
|
|
328
|
+
insertListeners;
|
|
329
|
+
listeners;
|
|
302
330
|
constructor(archivist) {
|
|
303
331
|
this.archivist = archivist;
|
|
332
|
+
this.latest = [];
|
|
333
|
+
this.deleteListeners = [];
|
|
334
|
+
this.insertListeners = [];
|
|
335
|
+
this.listeners = [];
|
|
304
336
|
}
|
|
305
|
-
latest = [];
|
|
306
|
-
deleteListeners = [];
|
|
307
|
-
insertListeners = [];
|
|
308
|
-
listeners = [];
|
|
309
337
|
/**
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
static async create({
|
|
313
|
-
archivist,
|
|
314
|
-
getLatest,
|
|
315
|
-
idFunction
|
|
316
|
-
}) {
|
|
338
|
+
* Initialize listeners on the archivist that update class member variables when new payloads are inserted
|
|
339
|
+
*/
|
|
340
|
+
static async create({ archivist, getLatest, idFunction }) {
|
|
317
341
|
const instance = new this(archivist);
|
|
318
|
-
const insertListener = async ({ payloads }) => {
|
|
342
|
+
const insertListener = /* @__PURE__ */ __name(async ({ payloads }) => {
|
|
319
343
|
if (payloads.some(idFunction)) {
|
|
320
344
|
instance.latest = await getLatest();
|
|
321
345
|
instance.emitChange();
|
|
322
346
|
}
|
|
323
|
-
};
|
|
324
|
-
const deleteListener = async () => {
|
|
347
|
+
}, "insertListener");
|
|
348
|
+
const deleteListener = /* @__PURE__ */ __name(async () => {
|
|
325
349
|
instance.latest = await getLatest();
|
|
326
350
|
instance.emitChange();
|
|
327
|
-
};
|
|
351
|
+
}, "deleteListener");
|
|
328
352
|
const weakRefInsertListener = new WeakRef(insertListener);
|
|
329
353
|
const weakRefDeleteListener = new WeakRef(deleteListener);
|
|
330
354
|
const insertListenerRef = weakRefInsertListener.deref();
|
|
@@ -337,8 +361,8 @@ var PayloadStore = class {
|
|
|
337
361
|
return instance;
|
|
338
362
|
}
|
|
339
363
|
/**
|
|
340
|
-
|
|
341
|
-
|
|
364
|
+
* Remove all listeners and reset their class members
|
|
365
|
+
*/
|
|
342
366
|
cleanupListeners() {
|
|
343
367
|
this.removeListeners(this.insertListeners, "inserted");
|
|
344
368
|
this.removeListeners(this.deleteListeners, "deleted");
|
|
@@ -346,16 +370,16 @@ var PayloadStore = class {
|
|
|
346
370
|
this.deleteListeners = [];
|
|
347
371
|
}
|
|
348
372
|
/**
|
|
349
|
-
|
|
350
|
-
|
|
373
|
+
* Get the current value of the store
|
|
374
|
+
*/
|
|
351
375
|
getSnapshot() {
|
|
352
376
|
return this.latest;
|
|
353
377
|
}
|
|
354
378
|
/**
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
379
|
+
* Add a call back function that is invoked when new Payloads are inserted
|
|
380
|
+
*
|
|
381
|
+
* @param {PayloadListener} onStoreChange
|
|
382
|
+
*/
|
|
359
383
|
subscribe(onStoreChange) {
|
|
360
384
|
this.listeners.push(onStoreChange);
|
|
361
385
|
return () => {
|
|
@@ -378,23 +402,29 @@ var PayloadStore = class {
|
|
|
378
402
|
|
|
379
403
|
// src/lib/tokenPlacesSplit.ts
|
|
380
404
|
import { assertEx as assertEx4 } from "@xylabs/assert";
|
|
381
|
-
var tokenPlacesSplit = (value, places) => {
|
|
405
|
+
var tokenPlacesSplit = /* @__PURE__ */ __name((value, places) => {
|
|
382
406
|
assertEx4(places >= 0, () => "Places has to be >= 0");
|
|
383
407
|
const factor = BigInt(10 ** Math.abs(places));
|
|
384
408
|
const remainder = value % factor;
|
|
385
409
|
const wholeValue = value / factor;
|
|
386
|
-
return [
|
|
387
|
-
|
|
388
|
-
|
|
410
|
+
return [
|
|
411
|
+
wholeValue,
|
|
412
|
+
remainder
|
|
413
|
+
];
|
|
414
|
+
}, "tokenPlacesSplit");
|
|
415
|
+
var tokenPlacesSplitString = /* @__PURE__ */ __name((value, places) => {
|
|
389
416
|
if (value === void 0) {
|
|
390
417
|
return "-";
|
|
391
418
|
}
|
|
392
419
|
const [wholeValue, remainder] = tokenPlacesSplit(value, places);
|
|
393
420
|
return `${wholeValue}.${remainder.toString().padStart(Math.abs(places), "0")}`;
|
|
394
|
-
};
|
|
421
|
+
}, "tokenPlacesSplitString");
|
|
395
422
|
|
|
396
423
|
// src/classes/dapp/access/Resource.ts
|
|
397
424
|
var DappAccessRequestResource = class extends DappCallerBase {
|
|
425
|
+
static {
|
|
426
|
+
__name(this, "DappAccessRequestResource");
|
|
427
|
+
}
|
|
398
428
|
_accessRequestListener;
|
|
399
429
|
_registeredInterfacesListener;
|
|
400
430
|
constructor(context) {
|
|
@@ -408,14 +438,14 @@ var DappAccessRequestResource = class extends DappCallerBase {
|
|
|
408
438
|
}
|
|
409
439
|
get subscriptions() {
|
|
410
440
|
return {
|
|
411
|
-
accessRequests: (cb) => this.accessRequestListener.subscribe(cb),
|
|
412
|
-
registeredInterfaces: (cb) => this.registeredInterfacesListener.subscribe(cb)
|
|
441
|
+
accessRequests: /* @__PURE__ */ __name((cb) => this.accessRequestListener.subscribe(cb), "accessRequests"),
|
|
442
|
+
registeredInterfaces: /* @__PURE__ */ __name((cb) => this.registeredInterfacesListener.subscribe(cb), "registeredInterfaces")
|
|
413
443
|
};
|
|
414
444
|
}
|
|
415
445
|
get views() {
|
|
416
446
|
return {
|
|
417
|
-
accessRequests: () => this.accessRequestListener.getSnapshot(),
|
|
418
|
-
registeredInterfaces: () => this.registeredInterfacesListener.getSnapshot()
|
|
447
|
+
accessRequests: /* @__PURE__ */ __name(() => this.accessRequestListener.getSnapshot(), "accessRequests"),
|
|
448
|
+
registeredInterfaces: /* @__PURE__ */ __name(() => this.registeredInterfacesListener.getSnapshot(), "registeredInterfaces")
|
|
419
449
|
};
|
|
420
450
|
}
|
|
421
451
|
cleanupListeners() {
|
|
@@ -427,12 +457,12 @@ var DappAccessRequestResource = class extends DappCallerBase {
|
|
|
427
457
|
const diviner = await this.getDappArchivistPayloadDiviner();
|
|
428
458
|
this._accessRequestListener = await PayloadStore.create({
|
|
429
459
|
archivist,
|
|
430
|
-
getLatest: async () => await DappAccessRequestQueries.getAccessRequests(diviner),
|
|
460
|
+
getLatest: /* @__PURE__ */ __name(async () => await DappAccessRequestQueries.getAccessRequests(diviner), "getLatest"),
|
|
431
461
|
idFunction: isDappAccessRequestWithMeta
|
|
432
462
|
});
|
|
433
463
|
this._registeredInterfacesListener = await PayloadStore.create({
|
|
434
464
|
archivist,
|
|
435
|
-
getLatest: async () => await DappAccessRequestQueries.getRegisteredInterfaces(diviner),
|
|
465
|
+
getLatest: /* @__PURE__ */ __name(async () => await DappAccessRequestQueries.getRegisteredInterfaces(diviner), "getLatest"),
|
|
436
466
|
idFunction: isRegisteredDappAccess
|
|
437
467
|
});
|
|
438
468
|
}
|
|
@@ -451,24 +481,35 @@ var DappDefaultsResourceQueries = {
|
|
|
451
481
|
limit: 1,
|
|
452
482
|
order: "desc",
|
|
453
483
|
schema: PayloadDivinerQuerySchema2,
|
|
454
|
-
schemas: [
|
|
484
|
+
schemas: [
|
|
485
|
+
DappInjectableParamsSchema
|
|
486
|
+
],
|
|
455
487
|
source: "route"
|
|
456
488
|
};
|
|
457
|
-
return await diviner.divine([
|
|
489
|
+
return await diviner.divine([
|
|
490
|
+
query
|
|
491
|
+
]);
|
|
458
492
|
},
|
|
459
493
|
async getNodeOsInfo(diviner) {
|
|
460
494
|
const query = {
|
|
461
495
|
limit: 1,
|
|
462
496
|
order: "desc",
|
|
463
497
|
schema: PayloadDivinerQuerySchema2,
|
|
464
|
-
schemas: [
|
|
498
|
+
schemas: [
|
|
499
|
+
NodeOsInfoSchema
|
|
500
|
+
]
|
|
465
501
|
};
|
|
466
|
-
return await diviner.divine([
|
|
502
|
+
return await diviner.divine([
|
|
503
|
+
query
|
|
504
|
+
]);
|
|
467
505
|
}
|
|
468
506
|
};
|
|
469
507
|
|
|
470
508
|
// src/classes/dapp/DefaultsResource.ts
|
|
471
509
|
var DappDefaultsResource = class extends DappCallerBase {
|
|
510
|
+
static {
|
|
511
|
+
__name(this, "DappDefaultsResource");
|
|
512
|
+
}
|
|
472
513
|
_dappInjectableParamsFromRouteListener;
|
|
473
514
|
_nodeOsInfoListener;
|
|
474
515
|
constructor(context) {
|
|
@@ -482,14 +523,14 @@ var DappDefaultsResource = class extends DappCallerBase {
|
|
|
482
523
|
}
|
|
483
524
|
get subscriptions() {
|
|
484
525
|
return {
|
|
485
|
-
dappInjectableParamsFromRoute: (cb) => this.dappInjectableParamsFromRouteListener.subscribe(cb),
|
|
486
|
-
nodeOsInfo: (cb) => this.nodeOsInfoListener.subscribe(cb)
|
|
526
|
+
dappInjectableParamsFromRoute: /* @__PURE__ */ __name((cb) => this.dappInjectableParamsFromRouteListener.subscribe(cb), "dappInjectableParamsFromRoute"),
|
|
527
|
+
nodeOsInfo: /* @__PURE__ */ __name((cb) => this.nodeOsInfoListener.subscribe(cb), "nodeOsInfo")
|
|
487
528
|
};
|
|
488
529
|
}
|
|
489
530
|
get views() {
|
|
490
531
|
return {
|
|
491
|
-
dappInjectableParamsFromRoute: () => this.dappInjectableParamsFromRouteListener.getSnapshot(),
|
|
492
|
-
nodeOsInfo: () => this.nodeOsInfoListener.getSnapshot()
|
|
532
|
+
dappInjectableParamsFromRoute: /* @__PURE__ */ __name(() => this.dappInjectableParamsFromRouteListener.getSnapshot(), "dappInjectableParamsFromRoute"),
|
|
533
|
+
nodeOsInfo: /* @__PURE__ */ __name(() => this.nodeOsInfoListener.getSnapshot(), "nodeOsInfo")
|
|
493
534
|
};
|
|
494
535
|
}
|
|
495
536
|
cleanupListeners() {
|
|
@@ -500,57 +541,51 @@ var DappDefaultsResource = class extends DappCallerBase {
|
|
|
500
541
|
const diviner = await this.getDappArchivistPayloadDiviner();
|
|
501
542
|
this._nodeOsInfoListener = await PayloadStore.create({
|
|
502
543
|
archivist,
|
|
503
|
-
getLatest: async () => await DappDefaultsResourceQueries.getNodeOsInfo(diviner),
|
|
544
|
+
getLatest: /* @__PURE__ */ __name(async () => await DappDefaultsResourceQueries.getNodeOsInfo(diviner), "getLatest"),
|
|
504
545
|
idFunction: isNodeOsInfo
|
|
505
546
|
});
|
|
506
547
|
this._dappInjectableParamsFromRouteListener = await PayloadStore.create({
|
|
507
548
|
archivist,
|
|
508
|
-
getLatest: async () => await DappDefaultsResourceQueries.getDappInjectableParamsFromRoute(diviner),
|
|
549
|
+
getLatest: /* @__PURE__ */ __name(async () => await DappDefaultsResourceQueries.getDappInjectableParamsFromRoute(diviner), "getLatest"),
|
|
509
550
|
idFunction: isDappInjectableParams
|
|
510
551
|
});
|
|
511
552
|
}
|
|
512
553
|
};
|
|
513
554
|
|
|
514
555
|
// src/classes/lib/Insertable.ts
|
|
515
|
-
var createInsertable = (insertable, ...params) => new insertable(...params);
|
|
556
|
+
var createInsertable = /* @__PURE__ */ __name((insertable, ...params) => new insertable(...params), "createInsertable");
|
|
516
557
|
|
|
517
558
|
// src/classes/menu/Caller.ts
|
|
518
559
|
import { PayloadDivinerQuerySchema as PayloadDivinerQuerySchema5 } from "@xyo-network/diviner-payload-model";
|
|
519
|
-
import {
|
|
520
|
-
DappInjectableParamsSchema as DappInjectableParamsSchema3,
|
|
521
|
-
DappNavItemSelectionSchema
|
|
522
|
-
} from "@xyo-network/os-model";
|
|
560
|
+
import { DappInjectableParamsSchema as DappInjectableParamsSchema3, DappNavItemSelectionSchema } from "@xyo-network/os-model";
|
|
523
561
|
import { PayloadBuilder as PayloadBuilder3 } from "@xyo-network/payload-builder";
|
|
524
562
|
|
|
525
563
|
// src/Caller.ts
|
|
526
564
|
import { assertEx as assertEx8 } from "@xylabs/assert";
|
|
527
565
|
import { PayloadDivinerQuerySchema as PayloadDivinerQuerySchema4 } from "@xyo-network/diviner-payload-model";
|
|
528
|
-
import {
|
|
529
|
-
DappAccessRequestSchema as DappAccessRequestSchema2,
|
|
530
|
-
DappInjectableParamsSchema as DappInjectableParamsSchema2,
|
|
531
|
-
DappIntentTypes,
|
|
532
|
-
DappMode as DappMode2,
|
|
533
|
-
RegisteredDappAccessSchema as RegisteredDappAccessSchema2
|
|
534
|
-
} from "@xyo-network/os-model";
|
|
566
|
+
import { DappAccessRequestSchema as DappAccessRequestSchema2, DappInjectableParamsSchema as DappInjectableParamsSchema2, DappIntentTypes, DappMode as DappMode2, RegisteredDappAccessSchema as RegisteredDappAccessSchema2 } from "@xyo-network/os-model";
|
|
535
567
|
import { PayloadBuilder as PayloadBuilder2 } from "@xyo-network/payload-builder";
|
|
536
568
|
|
|
537
569
|
// src/intent/Caller.ts
|
|
538
570
|
import { PayloadDivinerQuerySchema as PayloadDivinerQuerySchema3 } from "@xyo-network/diviner-payload-model";
|
|
539
571
|
import { DappIntentSchema, DappMode } from "@xyo-network/os-model";
|
|
540
572
|
var DappIntentCaller = class _DappIntentCaller extends DappCallerBase {
|
|
573
|
+
static {
|
|
574
|
+
__name(this, "DappIntentCaller");
|
|
575
|
+
}
|
|
541
576
|
static OsDappName = "XyOs";
|
|
542
577
|
constructor(context) {
|
|
543
578
|
super(context);
|
|
544
579
|
}
|
|
545
580
|
/**
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
581
|
+
* Build a new intent
|
|
582
|
+
* @param {DappId} sourceDappId
|
|
583
|
+
* @param {DappIntentTypes} intent
|
|
584
|
+
* @param {DappId} targetDappId
|
|
585
|
+
* @param {DappMode} targetMode
|
|
586
|
+
* @param {DappIntent['params']} params?
|
|
587
|
+
* @returns DappIntent
|
|
588
|
+
*/
|
|
554
589
|
static buildIntent(sourceDappId, intent, targetDappId, targetMode = DappMode.Window, params) {
|
|
555
590
|
return {
|
|
556
591
|
intent,
|
|
@@ -566,7 +601,9 @@ var DappIntentCaller = class _DappIntentCaller extends DappCallerBase {
|
|
|
566
601
|
async addIntent(id, intent, mode) {
|
|
567
602
|
const intentArchivist = await this.getDappIntentArchivist();
|
|
568
603
|
const newIntent = _DappIntentCaller.buildIntent(id, intent, mode);
|
|
569
|
-
await intentArchivist.insert([
|
|
604
|
+
await intentArchivist.insert([
|
|
605
|
+
newIntent
|
|
606
|
+
]);
|
|
570
607
|
}
|
|
571
608
|
// Get all intents
|
|
572
609
|
async allIntents() {
|
|
@@ -587,7 +624,9 @@ var DappIntentCaller = class _DappIntentCaller extends DappCallerBase {
|
|
|
587
624
|
schema: PayloadDivinerQuerySchema3,
|
|
588
625
|
sourceDappId: dappName
|
|
589
626
|
};
|
|
590
|
-
return await diviner.divine([
|
|
627
|
+
return await diviner.divine([
|
|
628
|
+
query
|
|
629
|
+
]);
|
|
591
630
|
}
|
|
592
631
|
};
|
|
593
632
|
|
|
@@ -596,6 +635,9 @@ import { assertEx as assertEx7 } from "@xylabs/assert";
|
|
|
596
635
|
import { isDappIntent } from "@xyo-network/os-model";
|
|
597
636
|
var NO_RESULTS = [];
|
|
598
637
|
var DappIntentResource = class extends DappCallerBase {
|
|
638
|
+
static {
|
|
639
|
+
__name(this, "DappIntentResource");
|
|
640
|
+
}
|
|
599
641
|
_allDappIntents;
|
|
600
642
|
_latestDappIntent;
|
|
601
643
|
constructor(context) {
|
|
@@ -609,14 +651,14 @@ var DappIntentResource = class extends DappCallerBase {
|
|
|
609
651
|
}
|
|
610
652
|
get subscriptions() {
|
|
611
653
|
return {
|
|
612
|
-
allDappIntents: (cb) => this.allDappIntents.subscribe(cb),
|
|
613
|
-
latestDappIntent: (cb) => this.latestDappIntent.subscribe(cb)
|
|
654
|
+
allDappIntents: /* @__PURE__ */ __name((cb) => this.allDappIntents.subscribe(cb), "allDappIntents"),
|
|
655
|
+
latestDappIntent: /* @__PURE__ */ __name((cb) => this.latestDappIntent.subscribe(cb), "latestDappIntent")
|
|
614
656
|
};
|
|
615
657
|
}
|
|
616
658
|
get views() {
|
|
617
659
|
return {
|
|
618
|
-
allDappIntents: () => this.allDappIntents.getSnapshot(),
|
|
619
|
-
latestDappIntent: () => this.latestDappIntent.getSnapshot()
|
|
660
|
+
allDappIntents: /* @__PURE__ */ __name(() => this.allDappIntents.getSnapshot(), "allDappIntents"),
|
|
661
|
+
latestDappIntent: /* @__PURE__ */ __name(() => this.latestDappIntent.getSnapshot(), "latestDappIntent")
|
|
620
662
|
};
|
|
621
663
|
}
|
|
622
664
|
cleanupListeners() {
|
|
@@ -627,16 +669,18 @@ var DappIntentResource = class extends DappCallerBase {
|
|
|
627
669
|
const archivist = await this.getDappIntentArchivist();
|
|
628
670
|
this._allDappIntents = await PayloadStore.create({
|
|
629
671
|
archivist,
|
|
630
|
-
getLatest: async () => await archivist.all(),
|
|
672
|
+
getLatest: /* @__PURE__ */ __name(async () => await archivist.all(), "getLatest"),
|
|
631
673
|
idFunction: isDappIntent
|
|
632
674
|
});
|
|
633
675
|
this._latestDappIntent = await PayloadStore.create({
|
|
634
676
|
archivist,
|
|
635
|
-
getLatest: async () => {
|
|
677
|
+
getLatest: /* @__PURE__ */ __name(async () => {
|
|
636
678
|
const all = await archivist.all();
|
|
637
|
-
const result = all.length > 0 ? [
|
|
679
|
+
const result = all.length > 0 ? [
|
|
680
|
+
all.at(-1)
|
|
681
|
+
] : NO_RESULTS;
|
|
638
682
|
return result;
|
|
639
|
-
},
|
|
683
|
+
}, "getLatest"),
|
|
640
684
|
idFunction: isDappIntent
|
|
641
685
|
});
|
|
642
686
|
}
|
|
@@ -644,14 +688,17 @@ var DappIntentResource = class extends DappCallerBase {
|
|
|
644
688
|
|
|
645
689
|
// src/Caller.ts
|
|
646
690
|
var DappCaller = class extends DappCallerBase {
|
|
691
|
+
static {
|
|
692
|
+
__name(this, "DappCaller");
|
|
693
|
+
}
|
|
647
694
|
constructor(context) {
|
|
648
695
|
super(context);
|
|
649
696
|
}
|
|
650
697
|
/**
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
698
|
+
* Add payloads to the dapp archivist
|
|
699
|
+
* @param {Payload[]} payloads
|
|
700
|
+
* @param {Boolean} force
|
|
701
|
+
*/
|
|
655
702
|
async addPayloadsToDappArchivist(payloads = [], force = false) {
|
|
656
703
|
const dappArchivist = await this.getDappArchivist();
|
|
657
704
|
if (force) {
|
|
@@ -659,19 +706,23 @@ var DappCaller = class extends DappCallerBase {
|
|
|
659
706
|
} else {
|
|
660
707
|
for (const payload of payloads) {
|
|
661
708
|
const hash = await PayloadBuilder2.dataHash(payload);
|
|
662
|
-
const [existing] = await dappArchivist.get([
|
|
709
|
+
const [existing] = await dappArchivist.get([
|
|
710
|
+
hash
|
|
711
|
+
]);
|
|
663
712
|
if (existing) continue;
|
|
664
|
-
await dappArchivist.insert([
|
|
713
|
+
await dappArchivist.insert([
|
|
714
|
+
payload
|
|
715
|
+
]);
|
|
665
716
|
}
|
|
666
717
|
}
|
|
667
718
|
}
|
|
668
719
|
/**
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
720
|
+
* Build Access Request
|
|
721
|
+
* @param {DappAccessRequest['mode']} mode
|
|
722
|
+
* @param {Hash} registeredDappAccessHash
|
|
723
|
+
* @param {string} requestingDappId
|
|
724
|
+
* @param {string | undefined} destinationArchivist
|
|
725
|
+
*/
|
|
675
726
|
buildAccessRequest(mode, registeredDappAccessHash, requestingDappId, destinationArchivist) {
|
|
676
727
|
const accessRequest = {
|
|
677
728
|
destinationArchivist,
|
|
@@ -684,43 +735,51 @@ var DappCaller = class extends DappCallerBase {
|
|
|
684
735
|
return accessRequest;
|
|
685
736
|
}
|
|
686
737
|
/**
|
|
687
|
-
|
|
688
|
-
|
|
738
|
+
* Get all available dapp access requests
|
|
739
|
+
*/
|
|
689
740
|
async getDappAccessPayloads() {
|
|
690
741
|
const diviner = await this.getDappArchivistPayloadDiviner();
|
|
691
742
|
const query = {
|
|
692
743
|
order: "desc",
|
|
693
744
|
schema: PayloadDivinerQuerySchema4,
|
|
694
|
-
schemas: [
|
|
745
|
+
schemas: [
|
|
746
|
+
RegisteredDappAccessSchema2
|
|
747
|
+
]
|
|
695
748
|
};
|
|
696
|
-
return diviner.divine([
|
|
749
|
+
return diviner.divine([
|
|
750
|
+
query
|
|
751
|
+
]);
|
|
697
752
|
}
|
|
698
753
|
/**
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
754
|
+
* Get the most recent dapp injectable params
|
|
755
|
+
* @returns Promise
|
|
756
|
+
*/
|
|
702
757
|
async getDappInjectableParams() {
|
|
703
758
|
const diviner = await this.getDappArchivistPayloadDiviner();
|
|
704
759
|
return await DappDefaultsResourceQueries.getDappInjectableParamsFromRoute(diviner);
|
|
705
760
|
}
|
|
706
761
|
/**
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
762
|
+
* Get the most recent dapp intent
|
|
763
|
+
* @param {string} name
|
|
764
|
+
*/
|
|
710
765
|
async getRegisteredDappAccessByName(name) {
|
|
711
766
|
const diviner = await this.getDappArchivistPayloadDiviner();
|
|
712
767
|
const query = {
|
|
713
768
|
limit: 1,
|
|
714
769
|
name,
|
|
715
770
|
schema: PayloadDivinerQuerySchema4,
|
|
716
|
-
schemas: [
|
|
771
|
+
schemas: [
|
|
772
|
+
RegisteredDappAccessSchema2
|
|
773
|
+
]
|
|
717
774
|
};
|
|
718
|
-
const [payload] = assertEx8(await diviner.divine([
|
|
775
|
+
const [payload] = assertEx8(await diviner.divine([
|
|
776
|
+
query
|
|
777
|
+
]), () => "Unable to find registered dapp access");
|
|
719
778
|
return payload;
|
|
720
779
|
}
|
|
721
780
|
/**
|
|
722
|
-
|
|
723
|
-
|
|
781
|
+
* Get the user wallet
|
|
782
|
+
*/
|
|
724
783
|
getUserAccount(dappName) {
|
|
725
784
|
const account = this.context.user.signers?.get(dappName);
|
|
726
785
|
if (account) {
|
|
@@ -730,48 +789,56 @@ var DappCaller = class extends DappCallerBase {
|
|
|
730
789
|
}
|
|
731
790
|
}
|
|
732
791
|
/**
|
|
733
|
-
|
|
734
|
-
|
|
792
|
+
* Get all wallets for the user
|
|
793
|
+
*/
|
|
735
794
|
getUserAccountsAll() {
|
|
736
|
-
return [
|
|
795
|
+
return [
|
|
796
|
+
...this.context.user.signers?.values() ?? []
|
|
797
|
+
];
|
|
737
798
|
}
|
|
738
799
|
/**
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
800
|
+
* Make Dapp Access Request
|
|
801
|
+
* @param {string} requestingDappId
|
|
802
|
+
* @param {string} registeredDappAccessHash
|
|
803
|
+
* @param {string} mode
|
|
804
|
+
* @param {string} destinationArchivist
|
|
805
|
+
*/
|
|
745
806
|
async makeDappAccessRequest(requestingDappId, registeredDappAccessHash, mode, destinationArchivist) {
|
|
746
807
|
const archivist = await this.getDappArchivist();
|
|
747
|
-
const registeredDappAccessPayload = await archivist.get([
|
|
808
|
+
const registeredDappAccessPayload = await archivist.get([
|
|
809
|
+
registeredDappAccessHash
|
|
810
|
+
]);
|
|
748
811
|
if (!registeredDappAccessPayload) {
|
|
749
812
|
throw new Error("No registered dapp access found");
|
|
750
813
|
}
|
|
751
814
|
const accessRequest = this.buildAccessRequest(mode, registeredDappAccessHash, requestingDappId, destinationArchivist);
|
|
752
|
-
await archivist.insert([
|
|
815
|
+
await archivist.insert([
|
|
816
|
+
accessRequest
|
|
817
|
+
]);
|
|
753
818
|
}
|
|
754
819
|
/**
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
820
|
+
* Make Dapp Intent Request
|
|
821
|
+
* @param {DappId} sourceDappId
|
|
822
|
+
* @param {DappId} targetDappId
|
|
823
|
+
* @param {DappIntentTypes=DappIntentTypes.Launch} intent
|
|
824
|
+
* @param {DappIntent['params']} mode
|
|
825
|
+
*/
|
|
761
826
|
async makeDappIntentRequest(sourceDappId, targetDappId, intent = DappIntentTypes.Launch, mode = DappMode2.Window, params) {
|
|
762
827
|
if (!sourceDappId) {
|
|
763
828
|
throw new Error("No source dapp id provided, dApps must declare a sourceDappId");
|
|
764
829
|
}
|
|
765
830
|
const archivist = await this.getDappArchivist();
|
|
766
831
|
const dappIntent = DappIntentCaller.buildIntent(sourceDappId, intent, targetDappId, mode, params);
|
|
767
|
-
return await archivist.insert([
|
|
832
|
+
return await archivist.insert([
|
|
833
|
+
dappIntent
|
|
834
|
+
]);
|
|
768
835
|
}
|
|
769
836
|
/**
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
837
|
+
* Set the dapp injectable params
|
|
838
|
+
*
|
|
839
|
+
* @param {URLSearchParams} searchParams
|
|
840
|
+
* @param {string} pathname
|
|
841
|
+
*/
|
|
775
842
|
async setDappInjectableRouteParams(searchParams = new URLSearchParams(), pathname) {
|
|
776
843
|
const dappArchivist = await this.getDappArchivist();
|
|
777
844
|
const params = {};
|
|
@@ -785,25 +852,32 @@ var DappCaller = class extends DappCallerBase {
|
|
|
785
852
|
source: "route",
|
|
786
853
|
timestamp: Date.now()
|
|
787
854
|
};
|
|
788
|
-
await dappArchivist.insert([
|
|
855
|
+
await dappArchivist.insert([
|
|
856
|
+
payload
|
|
857
|
+
]);
|
|
789
858
|
}
|
|
790
859
|
};
|
|
791
860
|
|
|
792
861
|
// src/classes/menu/Caller.ts
|
|
793
862
|
var DappMenuCaller = class extends DappCaller {
|
|
863
|
+
static {
|
|
864
|
+
__name(this, "DappMenuCaller");
|
|
865
|
+
}
|
|
794
866
|
constructor(context) {
|
|
795
867
|
super(context);
|
|
796
868
|
}
|
|
797
869
|
/**
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
870
|
+
* Add new Payloads to the dappArchivist if they haven't already
|
|
871
|
+
*
|
|
872
|
+
* @param {Payload[]} payloads
|
|
873
|
+
*/
|
|
802
874
|
async add(payloads, force = false) {
|
|
803
875
|
const dappArchivist = await this.getDappArchivist();
|
|
804
876
|
for (const payload of payloads) {
|
|
805
877
|
const hash = await PayloadBuilder3.dataHash(payload);
|
|
806
|
-
const [existing] = await dappArchivist.get([
|
|
878
|
+
const [existing] = await dappArchivist.get([
|
|
879
|
+
hash
|
|
880
|
+
]);
|
|
807
881
|
if (!existing || force) {
|
|
808
882
|
await dappArchivist.insert(payloads);
|
|
809
883
|
}
|
|
@@ -815,17 +889,21 @@ var DappMenuCaller = class extends DappCaller {
|
|
|
815
889
|
limit: 1,
|
|
816
890
|
order: "desc",
|
|
817
891
|
schema: PayloadDivinerQuerySchema5,
|
|
818
|
-
schemas: [
|
|
892
|
+
schemas: [
|
|
893
|
+
DappNavItemSelectionSchema
|
|
894
|
+
]
|
|
819
895
|
};
|
|
820
|
-
return await diviner.divine([
|
|
896
|
+
return await diviner.divine([
|
|
897
|
+
query
|
|
898
|
+
]);
|
|
821
899
|
}
|
|
822
900
|
/*
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
901
|
+
* Indicate to the system that a nav item was selected
|
|
902
|
+
*
|
|
903
|
+
* @param {string} path
|
|
904
|
+
* @params {string} injectableParamsPath
|
|
905
|
+
* @returns Promise
|
|
906
|
+
*/
|
|
829
907
|
async makeNavItemSelection(path, injectableParamsPath) {
|
|
830
908
|
const dappArchivist = await this.getDappArchivist();
|
|
831
909
|
const payload = {
|
|
@@ -833,7 +911,9 @@ var DappMenuCaller = class extends DappCaller {
|
|
|
833
911
|
schema: DappNavItemSelectionSchema,
|
|
834
912
|
timestamp: Date.now()
|
|
835
913
|
};
|
|
836
|
-
await dappArchivist.insert([
|
|
914
|
+
await dappArchivist.insert([
|
|
915
|
+
payload
|
|
916
|
+
]);
|
|
837
917
|
if (injectableParamsPath) {
|
|
838
918
|
const injectableParams = {
|
|
839
919
|
params: {},
|
|
@@ -842,7 +922,9 @@ var DappMenuCaller = class extends DappCaller {
|
|
|
842
922
|
source: "route",
|
|
843
923
|
timestamp: Date.now()
|
|
844
924
|
};
|
|
845
|
-
await dappArchivist.insert([
|
|
925
|
+
await dappArchivist.insert([
|
|
926
|
+
injectableParams
|
|
927
|
+
]);
|
|
846
928
|
}
|
|
847
929
|
}
|
|
848
930
|
};
|
|
@@ -853,11 +935,7 @@ import { isDappNavItemSelection, isDappNavMenuConfig } from "@xyo-network/os-mod
|
|
|
853
935
|
|
|
854
936
|
// src/classes/menu/Queries.ts
|
|
855
937
|
import { PayloadDivinerQuerySchema as PayloadDivinerQuerySchema6 } from "@xyo-network/diviner-payload-model";
|
|
856
|
-
import {
|
|
857
|
-
DappNavItemSchema,
|
|
858
|
-
DappNavItemSelectionSchema as DappNavItemSelectionSchema2,
|
|
859
|
-
DappNavMenuConfigSchema
|
|
860
|
-
} from "@xyo-network/os-model";
|
|
938
|
+
import { DappNavItemSchema, DappNavItemSelectionSchema as DappNavItemSelectionSchema2, DappNavMenuConfigSchema } from "@xyo-network/os-model";
|
|
861
939
|
var NO_ITEMS = [];
|
|
862
940
|
var DappMenuQueries = {
|
|
863
941
|
async getMenuConfigs(diviner) {
|
|
@@ -865,17 +943,25 @@ var DappMenuQueries = {
|
|
|
865
943
|
limit: 1,
|
|
866
944
|
order: "desc",
|
|
867
945
|
schema: PayloadDivinerQuerySchema6,
|
|
868
|
-
schemas: [
|
|
946
|
+
schemas: [
|
|
947
|
+
DappNavMenuConfigSchema
|
|
948
|
+
]
|
|
869
949
|
};
|
|
870
|
-
return await diviner.divine([
|
|
950
|
+
return await diviner.divine([
|
|
951
|
+
query
|
|
952
|
+
]);
|
|
871
953
|
},
|
|
872
954
|
async getMenuItems(diviner) {
|
|
873
955
|
const query = {
|
|
874
956
|
order: "desc",
|
|
875
957
|
schema: PayloadDivinerQuerySchema6,
|
|
876
|
-
schemas: [
|
|
958
|
+
schemas: [
|
|
959
|
+
DappNavItemSchema
|
|
960
|
+
]
|
|
877
961
|
};
|
|
878
|
-
const results = await diviner.divine([
|
|
962
|
+
const results = await diviner.divine([
|
|
963
|
+
query
|
|
964
|
+
]);
|
|
879
965
|
return results.length > 0 ? results : NO_ITEMS;
|
|
880
966
|
},
|
|
881
967
|
async getNavItemSelections(diviner) {
|
|
@@ -883,24 +969,35 @@ var DappMenuQueries = {
|
|
|
883
969
|
limit: 1,
|
|
884
970
|
order: "desc",
|
|
885
971
|
schema: PayloadDivinerQuerySchema6,
|
|
886
|
-
schemas: [
|
|
972
|
+
schemas: [
|
|
973
|
+
DappNavItemSelectionSchema2
|
|
974
|
+
]
|
|
887
975
|
};
|
|
888
|
-
const results = await diviner.divine([
|
|
976
|
+
const results = await diviner.divine([
|
|
977
|
+
query
|
|
978
|
+
]);
|
|
889
979
|
return results.length > 0 ? results : NO_ITEMS;
|
|
890
980
|
},
|
|
891
981
|
async getVisibleMenuItems(diviner) {
|
|
892
982
|
const query = {
|
|
893
983
|
order: "desc",
|
|
894
984
|
schema: PayloadDivinerQuerySchema6,
|
|
895
|
-
schemas: [
|
|
985
|
+
schemas: [
|
|
986
|
+
DappNavItemSchema
|
|
987
|
+
]
|
|
896
988
|
};
|
|
897
|
-
const results = await diviner.divine([
|
|
989
|
+
const results = await diviner.divine([
|
|
990
|
+
query
|
|
991
|
+
]);
|
|
898
992
|
return results.filter((menuItem) => menuItem.hidden !== true).sort((a, b) => (a.weight ?? 0) > (b.weight ?? 0) ? 1 : -1);
|
|
899
993
|
}
|
|
900
994
|
};
|
|
901
995
|
|
|
902
996
|
// src/classes/menu/Resource.ts
|
|
903
997
|
var DappMenuResource = class extends DappCaller {
|
|
998
|
+
static {
|
|
999
|
+
__name(this, "DappMenuResource");
|
|
1000
|
+
}
|
|
904
1001
|
_menuConfigListener;
|
|
905
1002
|
_menuItemListener;
|
|
906
1003
|
_menuItemSelectionListener;
|
|
@@ -923,55 +1020,55 @@ var DappMenuResource = class extends DappCaller {
|
|
|
923
1020
|
/** subscribe to latest set of payloads */
|
|
924
1021
|
get subscriptions() {
|
|
925
1022
|
return {
|
|
926
|
-
menuConfigs: (cb) => this.menuConfigListener.subscribe(cb),
|
|
927
|
-
menuItemSelections: (cb) => this.menuItemSelectionListener.subscribe(cb),
|
|
928
|
-
menuItems: (cb) => this.menuItemListener.subscribe(cb),
|
|
929
|
-
menuItemsVisible: (cb) => this.menuItemVisibleListener.subscribe(cb)
|
|
1023
|
+
menuConfigs: /* @__PURE__ */ __name((cb) => this.menuConfigListener.subscribe(cb), "menuConfigs"),
|
|
1024
|
+
menuItemSelections: /* @__PURE__ */ __name((cb) => this.menuItemSelectionListener.subscribe(cb), "menuItemSelections"),
|
|
1025
|
+
menuItems: /* @__PURE__ */ __name((cb) => this.menuItemListener.subscribe(cb), "menuItems"),
|
|
1026
|
+
menuItemsVisible: /* @__PURE__ */ __name((cb) => this.menuItemVisibleListener.subscribe(cb), "menuItemsVisible")
|
|
930
1027
|
};
|
|
931
1028
|
}
|
|
932
1029
|
/**
|
|
933
|
-
|
|
934
|
-
|
|
1030
|
+
* Return the latest menu payloads from the repository
|
|
1031
|
+
*/
|
|
935
1032
|
get views() {
|
|
936
1033
|
return {
|
|
937
|
-
menuConfigs: () => this.menuConfigListener.getSnapshot(),
|
|
938
|
-
menuItemSelections: () => this.menuItemSelectionListener.getSnapshot(),
|
|
939
|
-
menuItems: () => this.menuItemListener.getSnapshot(),
|
|
940
|
-
menuItemsVisible: () => this.menuItemVisibleListener.getSnapshot()
|
|
1034
|
+
menuConfigs: /* @__PURE__ */ __name(() => this.menuConfigListener.getSnapshot(), "menuConfigs"),
|
|
1035
|
+
menuItemSelections: /* @__PURE__ */ __name(() => this.menuItemSelectionListener.getSnapshot(), "menuItemSelections"),
|
|
1036
|
+
menuItems: /* @__PURE__ */ __name(() => this.menuItemListener.getSnapshot(), "menuItems"),
|
|
1037
|
+
menuItemsVisible: /* @__PURE__ */ __name(() => this.menuItemVisibleListener.getSnapshot(), "menuItemsVisible")
|
|
941
1038
|
};
|
|
942
1039
|
}
|
|
943
1040
|
/**
|
|
944
|
-
|
|
945
|
-
|
|
1041
|
+
* Remove all listeners and reset their class members
|
|
1042
|
+
*/
|
|
946
1043
|
cleanupListeners() {
|
|
947
1044
|
this.menuConfigListener.cleanupListeners();
|
|
948
1045
|
this.menuItemListener.cleanupListeners();
|
|
949
1046
|
this.menuItemSelectionListener.cleanupListeners();
|
|
950
1047
|
}
|
|
951
1048
|
/**
|
|
952
|
-
|
|
953
|
-
|
|
1049
|
+
* Start the resource
|
|
1050
|
+
*/
|
|
954
1051
|
async start() {
|
|
955
1052
|
const dappArchivist = await this.getDappArchivist();
|
|
956
1053
|
const dappArchivistPayloadDiviner = await this.getDappArchivistPayloadDiviner();
|
|
957
1054
|
this._menuConfigListener = await PayloadStore.create({
|
|
958
1055
|
archivist: dappArchivist,
|
|
959
|
-
getLatest: async () => await DappMenuQueries.getMenuConfigs(dappArchivistPayloadDiviner),
|
|
1056
|
+
getLatest: /* @__PURE__ */ __name(async () => await DappMenuQueries.getMenuConfigs(dappArchivistPayloadDiviner), "getLatest"),
|
|
960
1057
|
idFunction: isDappNavMenuConfig
|
|
961
1058
|
});
|
|
962
1059
|
this._menuItemListener = await PayloadStore.create({
|
|
963
1060
|
archivist: dappArchivist,
|
|
964
|
-
getLatest: async () => await DappMenuQueries.getMenuItems(dappArchivistPayloadDiviner),
|
|
1061
|
+
getLatest: /* @__PURE__ */ __name(async () => await DappMenuQueries.getMenuItems(dappArchivistPayloadDiviner), "getLatest"),
|
|
965
1062
|
idFunction: isDappNavMenuConfig
|
|
966
1063
|
});
|
|
967
1064
|
this._menuItemVisibleListener = await PayloadStore.create({
|
|
968
1065
|
archivist: dappArchivist,
|
|
969
|
-
getLatest: async () => await DappMenuQueries.getVisibleMenuItems(dappArchivistPayloadDiviner),
|
|
1066
|
+
getLatest: /* @__PURE__ */ __name(async () => await DappMenuQueries.getVisibleMenuItems(dappArchivistPayloadDiviner), "getLatest"),
|
|
970
1067
|
idFunction: isDappNavMenuConfig
|
|
971
1068
|
});
|
|
972
1069
|
this._menuItemSelectionListener = await PayloadStore.create({
|
|
973
1070
|
archivist: dappArchivist,
|
|
974
|
-
getLatest: async () => await DappMenuQueries.getNavItemSelections(dappArchivistPayloadDiviner),
|
|
1071
|
+
getLatest: /* @__PURE__ */ __name(async () => await DappMenuQueries.getNavItemSelections(dappArchivistPayloadDiviner), "getLatest"),
|
|
975
1072
|
idFunction: isDappNavItemSelection
|
|
976
1073
|
});
|
|
977
1074
|
}
|
|
@@ -988,14 +1085,17 @@ import { PayloadDivinerQuerySchema as PayloadDivinerQuerySchema7 } from "@xyo-ne
|
|
|
988
1085
|
import { DappWalletSeedPhraseSchema } from "@xyo-network/os-model";
|
|
989
1086
|
import { v4 as uuid } from "uuid";
|
|
990
1087
|
var DappSeedPhraseRepository = class extends OsCallerBase {
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
this.allowedNames = allowedNames;
|
|
1088
|
+
static {
|
|
1089
|
+
__name(this, "DappSeedPhraseRepository");
|
|
994
1090
|
}
|
|
1091
|
+
allowedNames;
|
|
995
1092
|
// record of all dapps that have requested a seed phrase with the OS
|
|
996
|
-
dappIdRepository
|
|
1093
|
+
dappIdRepository;
|
|
997
1094
|
// record of all walletIds that have been issued to registered dapps
|
|
998
|
-
walletIdRepository
|
|
1095
|
+
walletIdRepository;
|
|
1096
|
+
constructor(xyOs, allowedNames) {
|
|
1097
|
+
super(xyOs), this.allowedNames = allowedNames, this.dappIdRepository = /* @__PURE__ */ new Map(), this.walletIdRepository = /* @__PURE__ */ new Map();
|
|
1098
|
+
}
|
|
999
1099
|
async add(dappId) {
|
|
1000
1100
|
const archivist = await this.getDappsArchivist();
|
|
1001
1101
|
const seedPhrase = this.newPhrase();
|
|
@@ -1006,7 +1106,9 @@ var DappSeedPhraseRepository = class extends OsCallerBase {
|
|
|
1006
1106
|
seedPhrase,
|
|
1007
1107
|
walletId
|
|
1008
1108
|
};
|
|
1009
|
-
await archivist.insert([
|
|
1109
|
+
await archivist.insert([
|
|
1110
|
+
payload
|
|
1111
|
+
]);
|
|
1010
1112
|
this.dappIdRepository.set(dappId, payload);
|
|
1011
1113
|
this.walletIdRepository.set(walletId, payload);
|
|
1012
1114
|
return walletId;
|
|
@@ -1038,9 +1140,13 @@ var DappSeedPhraseRepository = class extends OsCallerBase {
|
|
|
1038
1140
|
limit: 1,
|
|
1039
1141
|
order: "desc",
|
|
1040
1142
|
schema: PayloadDivinerQuerySchema7,
|
|
1041
|
-
schemas: [
|
|
1143
|
+
schemas: [
|
|
1144
|
+
DappWalletSeedPhraseSchema
|
|
1145
|
+
]
|
|
1042
1146
|
};
|
|
1043
|
-
const results = await diviner.divine([
|
|
1147
|
+
const results = await diviner.divine([
|
|
1148
|
+
query
|
|
1149
|
+
]);
|
|
1044
1150
|
return results.length > 0 ? results[0] : void 0;
|
|
1045
1151
|
}
|
|
1046
1152
|
async checkWalletId(walletId) {
|
|
@@ -1049,10 +1155,14 @@ var DappSeedPhraseRepository = class extends OsCallerBase {
|
|
|
1049
1155
|
limit: 1,
|
|
1050
1156
|
order: "desc",
|
|
1051
1157
|
schema: PayloadDivinerQuerySchema7,
|
|
1052
|
-
schemas: [
|
|
1158
|
+
schemas: [
|
|
1159
|
+
DappWalletSeedPhraseSchema
|
|
1160
|
+
],
|
|
1053
1161
|
walletId
|
|
1054
1162
|
};
|
|
1055
|
-
const results = await diviner.divine([
|
|
1163
|
+
const results = await diviner.divine([
|
|
1164
|
+
query
|
|
1165
|
+
]);
|
|
1056
1166
|
return results.length > 0 ? results[0] : void 0;
|
|
1057
1167
|
}
|
|
1058
1168
|
newPhrase() {
|
|
@@ -1068,7 +1178,9 @@ import { DappPackageManifestPayloadSchema } from "@xyo-network/manifest";
|
|
|
1068
1178
|
|
|
1069
1179
|
// src/manifest/manifestReplacementTokens.ts
|
|
1070
1180
|
import { getXnsDomain } from "@xyo-network/kernel";
|
|
1071
|
-
var manifestReplacementTokens = (xnsNodeUrl, xnsNetwork) => ({
|
|
1181
|
+
var manifestReplacementTokens = /* @__PURE__ */ __name((xnsNodeUrl, xnsNetwork) => ({
|
|
1182
|
+
"[REPLACE_WITH_NS_NODE_URL]": getXnsDomain(xnsNodeUrl, xnsNetwork)
|
|
1183
|
+
}), "manifestReplacementTokens");
|
|
1072
1184
|
|
|
1073
1185
|
// src/manifest/os-node.manifest.json
|
|
1074
1186
|
var os_node_manifest_default = {
|
|
@@ -1209,6 +1321,10 @@ import { PayloadBuilder as PayloadBuilder4 } from "@xyo-network/payload-builder"
|
|
|
1209
1321
|
|
|
1210
1322
|
// src/classes/node/DefaultPayloads/DappAccessPayloads.ts
|
|
1211
1323
|
var DappAccessPayloads = class {
|
|
1324
|
+
static {
|
|
1325
|
+
__name(this, "DappAccessPayloads");
|
|
1326
|
+
}
|
|
1327
|
+
context;
|
|
1212
1328
|
constructor(context, _dappName) {
|
|
1213
1329
|
this.context = context;
|
|
1214
1330
|
}
|
|
@@ -1222,6 +1338,10 @@ var DappAccessPayloads = class {
|
|
|
1222
1338
|
// src/classes/node/DefaultPayloads/NodeInfoPayload.ts
|
|
1223
1339
|
import { NodeOsInfoSchema as NodeOsInfoSchema2 } from "@xyo-network/os-model";
|
|
1224
1340
|
var NodeInfoPayload = class {
|
|
1341
|
+
static {
|
|
1342
|
+
__name(this, "NodeInfoPayload");
|
|
1343
|
+
}
|
|
1344
|
+
_context;
|
|
1225
1345
|
constructor(_context, _dappName) {
|
|
1226
1346
|
this._context = _context;
|
|
1227
1347
|
}
|
|
@@ -1237,19 +1357,30 @@ var NodeInfoPayload = class {
|
|
|
1237
1357
|
publicAddress: exposedNode?.address ?? "",
|
|
1238
1358
|
schema: NodeOsInfoSchema2
|
|
1239
1359
|
};
|
|
1240
|
-
return [
|
|
1360
|
+
return [
|
|
1361
|
+
nodeOsInfo
|
|
1362
|
+
];
|
|
1241
1363
|
}
|
|
1242
1364
|
};
|
|
1243
1365
|
|
|
1244
1366
|
// src/classes/node/DefaultPayloads/DefaultPayloads.ts
|
|
1245
1367
|
var DefaultPayloads = class {
|
|
1368
|
+
static {
|
|
1369
|
+
__name(this, "DefaultPayloads");
|
|
1370
|
+
}
|
|
1371
|
+
dappArchivist;
|
|
1372
|
+
xyOs;
|
|
1373
|
+
dappName;
|
|
1246
1374
|
constructor(dappArchivist, xyOs, dappName) {
|
|
1247
1375
|
this.dappArchivist = dappArchivist;
|
|
1248
1376
|
this.xyOs = xyOs;
|
|
1249
1377
|
this.dappName = dappName;
|
|
1250
1378
|
}
|
|
1251
1379
|
async insert() {
|
|
1252
|
-
const insertables = [
|
|
1380
|
+
const insertables = [
|
|
1381
|
+
NodeInfoPayload,
|
|
1382
|
+
DappAccessPayloads
|
|
1383
|
+
];
|
|
1253
1384
|
const insertPayloads = [];
|
|
1254
1385
|
for (const insertable of insertables) {
|
|
1255
1386
|
const classInstance = createInsertable(insertable, this.xyOs, this.dappName);
|
|
@@ -1257,16 +1388,32 @@ var DefaultPayloads = class {
|
|
|
1257
1388
|
insertPayloads.push(...payloads);
|
|
1258
1389
|
}
|
|
1259
1390
|
for (const payload of insertPayloads) {
|
|
1260
|
-
const [existing] = await this.dappArchivist.get([
|
|
1391
|
+
const [existing] = await this.dappArchivist.get([
|
|
1392
|
+
await PayloadBuilder4.dataHash(payload)
|
|
1393
|
+
]);
|
|
1261
1394
|
if (existing) continue;
|
|
1262
|
-
await this.dappArchivist.insert([
|
|
1395
|
+
await this.dappArchivist.insert([
|
|
1396
|
+
payload
|
|
1397
|
+
]);
|
|
1263
1398
|
}
|
|
1264
1399
|
}
|
|
1265
1400
|
};
|
|
1266
1401
|
|
|
1267
1402
|
// src/classes/node/ExternalModulePermissions/ExternalModulePermissions.ts
|
|
1268
|
-
var ALLOWED_MODULES_FROM_PARENT = [
|
|
1403
|
+
var ALLOWED_MODULES_FROM_PARENT = [
|
|
1404
|
+
"IntentArchivist",
|
|
1405
|
+
"OsSettingsNode",
|
|
1406
|
+
"OsPubSubNetworkStackNode",
|
|
1407
|
+
"OsXyoPublicNetworkStackNode"
|
|
1408
|
+
];
|
|
1269
1409
|
var ExternalModulePermissions = class {
|
|
1410
|
+
static {
|
|
1411
|
+
__name(this, "ExternalModulePermissions");
|
|
1412
|
+
}
|
|
1413
|
+
context;
|
|
1414
|
+
dappWindowNode;
|
|
1415
|
+
dappName;
|
|
1416
|
+
externalPermissions;
|
|
1270
1417
|
constructor(context, dappWindowNode, dappName, externalPermissions) {
|
|
1271
1418
|
this.context = context;
|
|
1272
1419
|
this.dappWindowNode = dappWindowNode;
|
|
@@ -1303,6 +1450,17 @@ var ExternalModulePermissions = class {
|
|
|
1303
1450
|
|
|
1304
1451
|
// src/classes/node/Creator.ts
|
|
1305
1452
|
var DappContextCreator = class _DappContextCreator {
|
|
1453
|
+
static {
|
|
1454
|
+
__name(this, "DappContextCreator");
|
|
1455
|
+
}
|
|
1456
|
+
targetDappManifestParams;
|
|
1457
|
+
dappId;
|
|
1458
|
+
context;
|
|
1459
|
+
rootWallet;
|
|
1460
|
+
externalPermissions;
|
|
1461
|
+
sharedLocator;
|
|
1462
|
+
// Designated offset path for the wallet used by windowed dapps. In the future, other offsets could be used for other dapp modes
|
|
1463
|
+
static DAPP_WINDOW_WALLET_PATH = "1";
|
|
1306
1464
|
constructor(targetDappManifestParams, dappId, context, rootWallet, externalPermissions, sharedLocator) {
|
|
1307
1465
|
this.targetDappManifestParams = targetDappManifestParams;
|
|
1308
1466
|
this.dappId = dappId;
|
|
@@ -1311,25 +1469,19 @@ var DappContextCreator = class _DappContextCreator {
|
|
|
1311
1469
|
this.externalPermissions = externalPermissions;
|
|
1312
1470
|
this.sharedLocator = sharedLocator;
|
|
1313
1471
|
}
|
|
1314
|
-
// Designated offset path for the wallet used by windowed dapps. In the future, other offsets could be used for other dapp modes
|
|
1315
|
-
static DAPP_WINDOW_WALLET_PATH = "1";
|
|
1316
1472
|
static async create(params, xnsNodeUrl, xnsNetwork) {
|
|
1317
|
-
const {
|
|
1318
|
-
|
|
1319
|
-
locator,
|
|
1320
|
-
context,
|
|
1321
|
-
wallet
|
|
1322
|
-
} = params;
|
|
1323
|
-
const {
|
|
1324
|
-
payload,
|
|
1325
|
-
dappName,
|
|
1326
|
-
publicChildren,
|
|
1327
|
-
privateChildren
|
|
1328
|
-
} = config;
|
|
1473
|
+
const { config, locator, context, wallet } = params;
|
|
1474
|
+
const { payload, dappName, publicChildren, privateChildren } = config;
|
|
1329
1475
|
const { external, manifestPayload } = this.parseDappPackageManifestPayload(payload, xnsNodeUrl, xnsNetwork);
|
|
1330
1476
|
console.debug("[DEBUG] dApp manifest", manifestPayload);
|
|
1331
1477
|
const dappWallet = await wallet.derivePath(_DappContextCreator.DAPP_WINDOW_WALLET_PATH);
|
|
1332
|
-
const targetDappManifestParams = [
|
|
1478
|
+
const targetDappManifestParams = [
|
|
1479
|
+
manifestPayload,
|
|
1480
|
+
dappWallet,
|
|
1481
|
+
locator,
|
|
1482
|
+
publicChildren,
|
|
1483
|
+
privateChildren
|
|
1484
|
+
];
|
|
1333
1485
|
const instance = new this(targetDappManifestParams, dappName, context, wallet, external?.modules, locator);
|
|
1334
1486
|
return instance;
|
|
1335
1487
|
}
|
|
@@ -1354,7 +1506,10 @@ var DappContextCreator = class _DappContextCreator {
|
|
|
1354
1506
|
};
|
|
1355
1507
|
console.log("DappContextCreator:parseDappPackageManifestPayload", xnsNodeUrl, xnsNetwork);
|
|
1356
1508
|
const manifestPayload = replaceManifestTokens(manifestPayloadRaw, manifestReplacementTokens(xnsNodeUrl, xnsNetwork));
|
|
1357
|
-
return {
|
|
1509
|
+
return {
|
|
1510
|
+
external,
|
|
1511
|
+
manifestPayload
|
|
1512
|
+
};
|
|
1358
1513
|
}
|
|
1359
1514
|
async loadDappContext(context) {
|
|
1360
1515
|
console.log("DappNodesCreator:loadDappContext", this.dappId);
|
|
@@ -1375,13 +1530,15 @@ var DappContextCreator = class _DappContextCreator {
|
|
|
1375
1530
|
};
|
|
1376
1531
|
|
|
1377
1532
|
// src/classes/node/createDappContext.ts
|
|
1378
|
-
var GenericPayloadDivinerTags = {
|
|
1379
|
-
|
|
1533
|
+
var GenericPayloadDivinerTags = {
|
|
1534
|
+
"network.xyo.generic.payload.diviner": "GenericPayloadDiviner"
|
|
1535
|
+
};
|
|
1536
|
+
var resolveLocator = /* @__PURE__ */ __name((existingLocator) => {
|
|
1380
1537
|
const locator = existingLocator ?? new ModuleFactoryLocator2();
|
|
1381
1538
|
locator.register(GenericPayloadDiviner, GenericPayloadDivinerTags);
|
|
1382
1539
|
return locator;
|
|
1383
|
-
};
|
|
1384
|
-
var createDappContext = async (dapp, context, allowedNames, xnsNodeUrl, xnsNetwork) => {
|
|
1540
|
+
}, "resolveLocator");
|
|
1541
|
+
var createDappContext = /* @__PURE__ */ __name(async (dapp, context, allowedNames, xnsNodeUrl, xnsNetwork) => {
|
|
1385
1542
|
console.log("createNodes");
|
|
1386
1543
|
try {
|
|
1387
1544
|
const dappSeedPhraseRepository = new DappSeedPhraseRepository(context, allowedNames);
|
|
@@ -1394,7 +1551,10 @@ var createDappContext = async (dapp, context, allowedNames, xnsNodeUrl, xnsNetwo
|
|
|
1394
1551
|
const { config: dappConfig, params: dappParams } = dapp;
|
|
1395
1552
|
const locator = resolveLocator((dappParams.locator ?? new ModuleFactoryLocator2()).merge(context.platformLocator));
|
|
1396
1553
|
const params = {
|
|
1397
|
-
config: {
|
|
1554
|
+
config: {
|
|
1555
|
+
dappName,
|
|
1556
|
+
payload: dappConfig.manifest
|
|
1557
|
+
},
|
|
1398
1558
|
context,
|
|
1399
1559
|
locator,
|
|
1400
1560
|
wallet
|
|
@@ -1411,23 +1571,21 @@ var createDappContext = async (dapp, context, allowedNames, xnsNodeUrl, xnsNetwo
|
|
|
1411
1571
|
console.error(`Error creating dappWindow node: ${error.stack}`);
|
|
1412
1572
|
throw new Error(`Error creating dappWindow node: ${error.message}`);
|
|
1413
1573
|
}
|
|
1414
|
-
};
|
|
1574
|
+
}, "createDappContext");
|
|
1415
1575
|
|
|
1416
1576
|
// src/classes/registration/DappRegistrationService.ts
|
|
1417
1577
|
import { forget as forget2 } from "@xylabs/forget";
|
|
1418
1578
|
import { fulfilled, rejected } from "@xylabs/promise";
|
|
1419
1579
|
import { ModuleFactoryLocator as ModuleFactoryLocator5 } from "@xyo-network/module-factory-locator";
|
|
1420
|
-
import {
|
|
1421
|
-
DappIntentTypes as DappIntentTypes2,
|
|
1422
|
-
DappMode as DappMode3,
|
|
1423
|
-
isRegisteredDappAccessDappSet as isRegisteredDappAccessDappSet2,
|
|
1424
|
-
isRegisteredDappExposedDappSet
|
|
1425
|
-
} from "@xyo-network/os-model";
|
|
1580
|
+
import { DappIntentTypes as DappIntentTypes2, DappMode as DappMode3, isRegisteredDappAccessDappSet as isRegisteredDappAccessDappSet2, isRegisteredDappExposedDappSet } from "@xyo-network/os-model";
|
|
1426
1581
|
|
|
1427
1582
|
// src/event/bus/Connection.ts
|
|
1428
1583
|
import { assertEx as assertEx11 } from "@xylabs/assert";
|
|
1429
1584
|
import { BaseEmitter } from "@xyo-network/module-event-emitter";
|
|
1430
1585
|
var EventBusConnection = class extends BaseEmitter {
|
|
1586
|
+
static {
|
|
1587
|
+
__name(this, "EventBusConnection");
|
|
1588
|
+
}
|
|
1431
1589
|
_id;
|
|
1432
1590
|
description;
|
|
1433
1591
|
type;
|
|
@@ -1447,19 +1605,15 @@ var EventBusConnection = class extends BaseEmitter {
|
|
|
1447
1605
|
// src/event/bus/EventBus.ts
|
|
1448
1606
|
import { assertEx as assertEx12 } from "@xylabs/assert";
|
|
1449
1607
|
import { forget } from "@xylabs/forget";
|
|
1450
|
-
import {
|
|
1451
|
-
|
|
1452
|
-
MemoryArchivist,
|
|
1453
|
-
MemoryArchivistConfigSchema
|
|
1454
|
-
} from "@xyo-network/archivist";
|
|
1455
|
-
import {
|
|
1456
|
-
isEventBusEvent,
|
|
1457
|
-
isPubSubConnections
|
|
1458
|
-
} from "@xyo-network/os-model";
|
|
1608
|
+
import { asArchivistInstance as asArchivistInstance4, MemoryArchivist, MemoryArchivistConfigSchema } from "@xyo-network/archivist";
|
|
1609
|
+
import { isEventBusEvent, isPubSubConnections } from "@xyo-network/os-model";
|
|
1459
1610
|
import { PayloadBuilder as PayloadBuilder5 } from "@xyo-network/payload-builder";
|
|
1460
1611
|
import { Mutex } from "async-mutex";
|
|
1461
1612
|
import { v4 as uuid2 } from "uuid";
|
|
1462
1613
|
var EventBus = class {
|
|
1614
|
+
static {
|
|
1615
|
+
__name(this, "EventBus");
|
|
1616
|
+
}
|
|
1463
1617
|
// Internal Archivist to store event data
|
|
1464
1618
|
_archivist;
|
|
1465
1619
|
// Store all connections
|
|
@@ -1468,10 +1622,7 @@ var EventBus = class {
|
|
|
1468
1622
|
publisherCallbacks = {};
|
|
1469
1623
|
startMutex = new Mutex();
|
|
1470
1624
|
get archivist() {
|
|
1471
|
-
return asArchivistInstance4(
|
|
1472
|
-
assertEx12(this._archivist, () => "Archivist not found. Did you forget to call start()?"),
|
|
1473
|
-
"not a valid archivist instance"
|
|
1474
|
-
);
|
|
1625
|
+
return asArchivistInstance4(assertEx12(this._archivist, () => "Archivist not found. Did you forget to call start()?"), "not a valid archivist instance");
|
|
1475
1626
|
}
|
|
1476
1627
|
addConnection(connection) {
|
|
1477
1628
|
const id = uuid2();
|
|
@@ -1500,7 +1651,12 @@ var EventBus = class {
|
|
|
1500
1651
|
console.warn("EventBus already started");
|
|
1501
1652
|
return this;
|
|
1502
1653
|
}
|
|
1503
|
-
this._archivist = await MemoryArchivist.create({
|
|
1654
|
+
this._archivist = await MemoryArchivist.create({
|
|
1655
|
+
config: {
|
|
1656
|
+
name: storeName,
|
|
1657
|
+
schema: MemoryArchivistConfigSchema
|
|
1658
|
+
}
|
|
1659
|
+
});
|
|
1504
1660
|
this.archivist.on("inserted", ({ payloads }) => {
|
|
1505
1661
|
const eventBusEvent = payloads.find(isEventBusEvent);
|
|
1506
1662
|
if (!eventBusEvent) return;
|
|
@@ -1510,7 +1666,9 @@ var EventBus = class {
|
|
|
1510
1666
|
for (const [eventName, callback] of connection.subscribableEvents.entries()) {
|
|
1511
1667
|
if (eventName !== eventBusEvent.name) continue;
|
|
1512
1668
|
if (callback) {
|
|
1513
|
-
const forgettable = async () => await callback({
|
|
1669
|
+
const forgettable = /* @__PURE__ */ __name(async () => await callback({
|
|
1670
|
+
payloads
|
|
1671
|
+
}), "forgettable");
|
|
1514
1672
|
forget(forgettable());
|
|
1515
1673
|
}
|
|
1516
1674
|
}
|
|
@@ -1522,16 +1680,22 @@ var EventBus = class {
|
|
|
1522
1680
|
}
|
|
1523
1681
|
handlePublisherAdd(connection) {
|
|
1524
1682
|
for (const eventName of connection.publishableEvents ?? []) {
|
|
1525
|
-
const connectionPublisherCallback = async ({ payloads }) => {
|
|
1526
|
-
const event = {
|
|
1683
|
+
const connectionPublisherCallback = /* @__PURE__ */ __name(async ({ payloads }) => {
|
|
1684
|
+
const event = {
|
|
1685
|
+
name: eventName,
|
|
1686
|
+
schema: "network.xyo.event.bus.event"
|
|
1687
|
+
};
|
|
1527
1688
|
const eventPayloads = payloads ?? [];
|
|
1528
1689
|
event.sources = await PayloadBuilder5.dataHashes(eventPayloads);
|
|
1529
1690
|
try {
|
|
1530
|
-
await this.archivist.insert([
|
|
1691
|
+
await this.archivist.insert([
|
|
1692
|
+
event,
|
|
1693
|
+
...payloads ?? []
|
|
1694
|
+
]);
|
|
1531
1695
|
} catch (e) {
|
|
1532
1696
|
console.error("Error inserting event into archivist", e);
|
|
1533
1697
|
}
|
|
1534
|
-
};
|
|
1698
|
+
}, "connectionPublisherCallback");
|
|
1535
1699
|
connection.on(eventName, connectionPublisherCallback);
|
|
1536
1700
|
const callbackId = connection.id + eventName;
|
|
1537
1701
|
this.publisherCallbacks[callbackId] = connectionPublisherCallback;
|
|
@@ -1548,6 +1712,9 @@ var EventBus = class {
|
|
|
1548
1712
|
|
|
1549
1713
|
// src/event/bus/PubSubConnection.ts
|
|
1550
1714
|
var EventBusPubSubConnection = class extends EventBusConnection {
|
|
1715
|
+
static {
|
|
1716
|
+
__name(this, "EventBusPubSubConnection");
|
|
1717
|
+
}
|
|
1551
1718
|
publishableEvents;
|
|
1552
1719
|
subscribableEvents;
|
|
1553
1720
|
constructor(request) {
|
|
@@ -1563,49 +1730,61 @@ var EventBusPubSubConnection = class extends EventBusConnection {
|
|
|
1563
1730
|
// src/event/connections/DappAccessRequest.ts
|
|
1564
1731
|
var DappAccessRequestEvent = "dappAccessRequest";
|
|
1565
1732
|
var dappAccessRequestConnectionRequest = {
|
|
1566
|
-
publishableEvents: [
|
|
1733
|
+
publishableEvents: [
|
|
1734
|
+
DappAccessRequestEvent
|
|
1735
|
+
],
|
|
1567
1736
|
type: "PubSub"
|
|
1568
1737
|
};
|
|
1569
|
-
var dappAccessRequestConnection = () => new EventBusPubSubConnection(dappAccessRequestConnectionRequest);
|
|
1738
|
+
var dappAccessRequestConnection = /* @__PURE__ */ __name(() => new EventBusPubSubConnection(dappAccessRequestConnectionRequest), "dappAccessRequestConnection");
|
|
1570
1739
|
|
|
1571
1740
|
// src/event/connections/DappsReady.ts
|
|
1572
1741
|
var dappsReadyConnectionRequest = {
|
|
1573
|
-
publishableEvents: [
|
|
1742
|
+
publishableEvents: [
|
|
1743
|
+
"dappsReady"
|
|
1744
|
+
],
|
|
1574
1745
|
type: "PubSub"
|
|
1575
1746
|
};
|
|
1576
|
-
var dappsReadyConnection = () => new EventBusPubSubConnection(dappsReadyConnectionRequest);
|
|
1747
|
+
var dappsReadyConnection = /* @__PURE__ */ __name(() => new EventBusPubSubConnection(dappsReadyConnectionRequest), "dappsReadyConnection");
|
|
1577
1748
|
|
|
1578
1749
|
// src/event/connections/ExposeDappRequest.ts
|
|
1579
1750
|
var ExposeDappRequestEvent = "exposeDappRequest";
|
|
1580
1751
|
var exposeDappConnectionRequest = {
|
|
1581
|
-
publishableEvents: [
|
|
1752
|
+
publishableEvents: [
|
|
1753
|
+
ExposeDappRequestEvent
|
|
1754
|
+
],
|
|
1582
1755
|
type: "PubSub"
|
|
1583
1756
|
};
|
|
1584
|
-
var exposeDappRequestConnection = () => new EventBusPubSubConnection(exposeDappConnectionRequest);
|
|
1757
|
+
var exposeDappRequestConnection = /* @__PURE__ */ __name(() => new EventBusPubSubConnection(exposeDappConnectionRequest), "exposeDappRequestConnection");
|
|
1585
1758
|
|
|
1586
1759
|
// src/event/connections/OsPubSubNetworkReady.ts
|
|
1587
1760
|
var OsPubSubNetworkReadyEvent = "osPubSubNetworkReady";
|
|
1588
1761
|
var osPubSubNetworkConnectionRequest = {
|
|
1589
|
-
publishableEvents: [
|
|
1762
|
+
publishableEvents: [
|
|
1763
|
+
OsPubSubNetworkReadyEvent
|
|
1764
|
+
],
|
|
1590
1765
|
type: "PubSub"
|
|
1591
1766
|
};
|
|
1592
|
-
var osPubSubNetworkReadyConnection = () => new EventBusPubSubConnection(osPubSubNetworkConnectionRequest);
|
|
1767
|
+
var osPubSubNetworkReadyConnection = /* @__PURE__ */ __name(() => new EventBusPubSubConnection(osPubSubNetworkConnectionRequest), "osPubSubNetworkReadyConnection");
|
|
1593
1768
|
|
|
1594
1769
|
// src/event/connections/OsSettingsReady.ts
|
|
1595
1770
|
var OsSettingsReadyEvent = "osSettingsReady";
|
|
1596
1771
|
var osSettingsConnectionRequest = {
|
|
1597
|
-
publishableEvents: [
|
|
1772
|
+
publishableEvents: [
|
|
1773
|
+
OsSettingsReadyEvent
|
|
1774
|
+
],
|
|
1598
1775
|
type: "PubSub"
|
|
1599
1776
|
};
|
|
1600
|
-
var osSettingsReadyConnection = () => new EventBusPubSubConnection(osSettingsConnectionRequest);
|
|
1777
|
+
var osSettingsReadyConnection = /* @__PURE__ */ __name(() => new EventBusPubSubConnection(osSettingsConnectionRequest), "osSettingsReadyConnection");
|
|
1601
1778
|
|
|
1602
1779
|
// src/event/connections/OsXyoPublicReady.ts
|
|
1603
1780
|
var OsXyoPublicNetworkReadyEvent = "osXyoPublicNetworkReady";
|
|
1604
1781
|
var osXyoPublicNetworkConnectionRequest = {
|
|
1605
|
-
publishableEvents: [
|
|
1782
|
+
publishableEvents: [
|
|
1783
|
+
OsXyoPublicNetworkReadyEvent
|
|
1784
|
+
],
|
|
1606
1785
|
type: "PubSub"
|
|
1607
1786
|
};
|
|
1608
|
-
var osXyoPublicNetworkReadyConnection = () => new EventBusPubSubConnection(osXyoPublicNetworkConnectionRequest);
|
|
1787
|
+
var osXyoPublicNetworkReadyConnection = /* @__PURE__ */ __name(() => new EventBusPubSubConnection(osXyoPublicNetworkConnectionRequest), "osXyoPublicNetworkReadyConnection");
|
|
1609
1788
|
|
|
1610
1789
|
// src/XyOsDapp.ts
|
|
1611
1790
|
import { assertEx as assertEx14 } from "@xylabs/assert";
|
|
@@ -1657,6 +1836,9 @@ import { BaseEmitter as BaseEmitter2 } from "@xyo-network/module-event-emitter";
|
|
|
1657
1836
|
import { ModuleFactoryLocator as ModuleFactoryLocator3 } from "@xyo-network/module-factory-locator";
|
|
1658
1837
|
import { Mutex as Mutex2 } from "async-mutex";
|
|
1659
1838
|
var XyOsContextBase = class extends BaseEmitter2 {
|
|
1839
|
+
static {
|
|
1840
|
+
__name(this, "XyOsContextBase");
|
|
1841
|
+
}
|
|
1660
1842
|
_bootMutex = new Mutex2();
|
|
1661
1843
|
_platformLocator;
|
|
1662
1844
|
_root;
|
|
@@ -1740,10 +1922,15 @@ var XyOsContextBase = class extends BaseEmitter2 {
|
|
|
1740
1922
|
|
|
1741
1923
|
// src/XyOsDapp.ts
|
|
1742
1924
|
var XyOsDapp = class extends XyOsContextBase {
|
|
1925
|
+
static {
|
|
1926
|
+
__name(this, "XyOsDapp");
|
|
1927
|
+
}
|
|
1743
1928
|
dapp;
|
|
1744
1929
|
constructor(params) {
|
|
1745
1930
|
super(params);
|
|
1746
|
-
this.dapp = {
|
|
1931
|
+
this.dapp = {
|
|
1932
|
+
...params.dapp
|
|
1933
|
+
};
|
|
1747
1934
|
}
|
|
1748
1935
|
get eventBus() {
|
|
1749
1936
|
return this.parent.eventBus;
|
|
@@ -1755,12 +1942,12 @@ var XyOsDapp = class extends XyOsContextBase {
|
|
|
1755
1942
|
return this.parent.exposedNodeOuter;
|
|
1756
1943
|
}
|
|
1757
1944
|
/**
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1945
|
+
* @deprecated Dapps should not have access to the bios. This is done for the
|
|
1946
|
+
* settings dapp, but should be refactored out. Bios could possibly be an
|
|
1947
|
+
* optional property of the parent context passed in for dapps that require
|
|
1948
|
+
* elevated permissions.
|
|
1949
|
+
* ^^^ I believe we may want this here in that is a dApp requests access to the bios it will optionally be there
|
|
1950
|
+
*/
|
|
1764
1951
|
get kernel() {
|
|
1765
1952
|
return assertEx14(this.parent.kernel, () => "Missing kernel");
|
|
1766
1953
|
}
|
|
@@ -1779,15 +1966,17 @@ var XyOsDapp = class extends XyOsContextBase {
|
|
|
1779
1966
|
assertEx14(this._root === void 0, () => "Dapp already booted");
|
|
1780
1967
|
const finalLocator = locator ? (this.params.locator ?? new ModuleFactoryLocator4()).merge(locator) : this.params.locator ?? new ModuleFactoryLocator4();
|
|
1781
1968
|
console.log("XyOsDapp:boot:finalLocator", finalLocator);
|
|
1782
|
-
const dappNodesWrapper = new ManifestWrapper({
|
|
1969
|
+
const dappNodesWrapper = new ManifestWrapper({
|
|
1970
|
+
...this.manifest,
|
|
1971
|
+
schema: DappPackageManifestPayloadSchema2
|
|
1972
|
+
}, wallet, finalLocator);
|
|
1783
1973
|
const dappNodes = await dappNodesWrapper.loadNodes();
|
|
1784
1974
|
const dappManifestWallet = await wallet.derivePath("99999");
|
|
1785
1975
|
dapp_window_manifest_default.nodes[0].config.name = this.dapp.name + "Root";
|
|
1786
|
-
const wrapper = new ManifestWrapper(
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
);
|
|
1976
|
+
const wrapper = new ManifestWrapper({
|
|
1977
|
+
...dapp_window_manifest_default,
|
|
1978
|
+
schema: DappPackageManifestPayloadSchema2
|
|
1979
|
+
}, dappManifestWallet, finalLocator);
|
|
1791
1980
|
const node = await wrapper.loadNodeFromIndex(0);
|
|
1792
1981
|
for (const dappNode of dappNodes) {
|
|
1793
1982
|
await node.register(dappNode);
|
|
@@ -1809,12 +1998,7 @@ import semver from "semver";
|
|
|
1809
1998
|
|
|
1810
1999
|
// src/classes/system/Queries.ts
|
|
1811
2000
|
import { PayloadDivinerQuerySchema as PayloadDivinerQuerySchema8 } from "@xyo-network/diviner-payload-model";
|
|
1812
|
-
import {
|
|
1813
|
-
DappConfigSchema,
|
|
1814
|
-
DappIconSchema,
|
|
1815
|
-
DappWidgetConfigSchema,
|
|
1816
|
-
UnregisteredDappAccessSchema
|
|
1817
|
-
} from "@xyo-network/os-model";
|
|
2001
|
+
import { DappConfigSchema, DappIconSchema, DappWidgetConfigSchema, UnregisteredDappAccessSchema } from "@xyo-network/os-model";
|
|
1818
2002
|
import { PayloadBuilder as PayloadBuilder6 } from "@xyo-network/payload-builder";
|
|
1819
2003
|
var SystemDappQueries = {
|
|
1820
2004
|
async getDappAccess(diviner, name, version) {
|
|
@@ -1822,10 +2006,14 @@ var SystemDappQueries = {
|
|
|
1822
2006
|
order: "desc",
|
|
1823
2007
|
registeringDappId: name,
|
|
1824
2008
|
schema: PayloadDivinerQuerySchema8,
|
|
1825
|
-
schemas: [
|
|
2009
|
+
schemas: [
|
|
2010
|
+
UnregisteredDappAccessSchema
|
|
2011
|
+
],
|
|
1826
2012
|
version
|
|
1827
2013
|
};
|
|
1828
|
-
return await diviner.divine([
|
|
2014
|
+
return await diviner.divine([
|
|
2015
|
+
accessQuery
|
|
2016
|
+
]);
|
|
1829
2017
|
},
|
|
1830
2018
|
async getLatestConfig(diviner, name) {
|
|
1831
2019
|
const configQuery = {
|
|
@@ -1833,9 +2021,13 @@ var SystemDappQueries = {
|
|
|
1833
2021
|
name,
|
|
1834
2022
|
order: "desc",
|
|
1835
2023
|
schema: PayloadDivinerQuerySchema8,
|
|
1836
|
-
schemas: [
|
|
2024
|
+
schemas: [
|
|
2025
|
+
DappConfigSchema
|
|
2026
|
+
]
|
|
1837
2027
|
};
|
|
1838
|
-
const [dappConfig] = await diviner.divine([
|
|
2028
|
+
const [dappConfig] = await diviner.divine([
|
|
2029
|
+
configQuery
|
|
2030
|
+
]);
|
|
1839
2031
|
return dappConfig;
|
|
1840
2032
|
},
|
|
1841
2033
|
async getLatestIcon(diviner, name, version) {
|
|
@@ -1843,10 +2035,14 @@ var SystemDappQueries = {
|
|
|
1843
2035
|
name,
|
|
1844
2036
|
order: "desc",
|
|
1845
2037
|
schema: PayloadDivinerQuerySchema8,
|
|
1846
|
-
schemas: [
|
|
2038
|
+
schemas: [
|
|
2039
|
+
DappIconSchema
|
|
2040
|
+
],
|
|
1847
2041
|
version
|
|
1848
2042
|
};
|
|
1849
|
-
const [dappIcon] = await diviner.divine([
|
|
2043
|
+
const [dappIcon] = await diviner.divine([
|
|
2044
|
+
iconQuery
|
|
2045
|
+
]);
|
|
1850
2046
|
return dappIcon;
|
|
1851
2047
|
},
|
|
1852
2048
|
async getWidgetConfigs(diviner, name, version) {
|
|
@@ -1854,10 +2050,14 @@ var SystemDappQueries = {
|
|
|
1854
2050
|
dappId: name,
|
|
1855
2051
|
order: "desc",
|
|
1856
2052
|
schema: PayloadDivinerQuerySchema8,
|
|
1857
|
-
schemas: [
|
|
2053
|
+
schemas: [
|
|
2054
|
+
DappWidgetConfigSchema
|
|
2055
|
+
],
|
|
1858
2056
|
version
|
|
1859
2057
|
};
|
|
1860
|
-
const widgetConfigs = await diviner.divine([
|
|
2058
|
+
const widgetConfigs = await diviner.divine([
|
|
2059
|
+
widgetConfigQuery
|
|
2060
|
+
]);
|
|
1861
2061
|
const uniqueConfigs = {};
|
|
1862
2062
|
for (const widgetConfig of widgetConfigs) {
|
|
1863
2063
|
const hash = await PayloadBuilder6.dataHash(widgetConfig);
|
|
@@ -1869,25 +2069,28 @@ var SystemDappQueries = {
|
|
|
1869
2069
|
|
|
1870
2070
|
// src/classes/system/ManageSystemDapps.ts
|
|
1871
2071
|
var ManageSystemDapps = class extends OsCallerBase {
|
|
2072
|
+
static {
|
|
2073
|
+
__name(this, "ManageSystemDapps");
|
|
2074
|
+
}
|
|
2075
|
+
defaultSystemNames;
|
|
2076
|
+
defaultSystemDapps;
|
|
2077
|
+
defaultSystemDappParams;
|
|
2078
|
+
locator;
|
|
2079
|
+
developmentMode;
|
|
2080
|
+
onErrorCallbacks;
|
|
1872
2081
|
constructor(context, defaultSystemNames, defaultSystemDapps, defaultSystemDappParams, locator, developmentMode) {
|
|
1873
|
-
super(context);
|
|
1874
|
-
this.defaultSystemNames = defaultSystemNames;
|
|
1875
|
-
this.defaultSystemDapps = defaultSystemDapps;
|
|
1876
|
-
this.defaultSystemDappParams = defaultSystemDappParams;
|
|
1877
|
-
this.locator = locator;
|
|
1878
|
-
this.developmentMode = developmentMode;
|
|
2082
|
+
super(context), this.defaultSystemNames = defaultSystemNames, this.defaultSystemDapps = defaultSystemDapps, this.defaultSystemDappParams = defaultSystemDappParams, this.locator = locator, this.developmentMode = developmentMode, this.onErrorCallbacks = [];
|
|
1879
2083
|
}
|
|
1880
|
-
onErrorCallbacks = [];
|
|
1881
2084
|
/**
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
2085
|
+
* Add a callback to listen for errors throwing during system dapp registration
|
|
2086
|
+
* @param {ErrorListener} errorListener
|
|
2087
|
+
*/
|
|
1885
2088
|
addErrorListener(errorListener) {
|
|
1886
2089
|
this.onErrorCallbacks.push(errorListener);
|
|
1887
2090
|
}
|
|
1888
2091
|
/**
|
|
1889
|
-
|
|
1890
|
-
|
|
2092
|
+
* Installs the dapps into the OS and builds the appropriate DappSet
|
|
2093
|
+
*/
|
|
1891
2094
|
async install() {
|
|
1892
2095
|
await this.insertPayloads();
|
|
1893
2096
|
return await this.latestSets();
|
|
@@ -1911,9 +2114,13 @@ var ManageSystemDapps = class extends OsCallerBase {
|
|
|
1911
2114
|
console.error(`${systemDappPayload.version} does not appear to be a valid semver value`, e);
|
|
1912
2115
|
continue;
|
|
1913
2116
|
}
|
|
1914
|
-
const [existing] = await archivist.get([
|
|
2117
|
+
const [existing] = await archivist.get([
|
|
2118
|
+
await PayloadBuilder7.dataHash(systemDappPayload)
|
|
2119
|
+
]);
|
|
1915
2120
|
if (existing) continue;
|
|
1916
|
-
await archivist.insert([
|
|
2121
|
+
await archivist.insert([
|
|
2122
|
+
systemDappPayload
|
|
2123
|
+
]);
|
|
1917
2124
|
}
|
|
1918
2125
|
return true;
|
|
1919
2126
|
} catch (e) {
|
|
@@ -1968,11 +2175,7 @@ var ManageSystemDapps = class extends OsCallerBase {
|
|
|
1968
2175
|
|
|
1969
2176
|
// src/classes/registration/DappRegistry.ts
|
|
1970
2177
|
import { HDWallet as HDWallet4 } from "@xyo-network/account";
|
|
1971
|
-
import {
|
|
1972
|
-
DappRegisteredSchema,
|
|
1973
|
-
DappRegisteredState,
|
|
1974
|
-
isRegisteredDappAccess as isRegisteredDappAccess2
|
|
1975
|
-
} from "@xyo-network/os-model";
|
|
2178
|
+
import { DappRegisteredSchema, DappRegisteredState, isRegisteredDappAccess as isRegisteredDappAccess2 } from "@xyo-network/os-model";
|
|
1976
2179
|
|
|
1977
2180
|
// src/classes/registration/ValidateDappAccessDiviner/Config.ts
|
|
1978
2181
|
import { isPayloadOfSchemaType } from "@xyo-network/payload-model";
|
|
@@ -1984,14 +2187,14 @@ var ValidateDappAccessDivinerConfigSchema = "network.xyo.os.dapp.access.registra
|
|
|
1984
2187
|
import { HDWallet as HDWallet3 } from "@xyo-network/account";
|
|
1985
2188
|
import { AbstractDiviner } from "@xyo-network/diviner-abstract";
|
|
1986
2189
|
import { ManifestWrapper as ManifestWrapper2, PackageManifestPayloadSchema } from "@xyo-network/manifest";
|
|
1987
|
-
import {
|
|
1988
|
-
isDappPackageManifestPayload,
|
|
1989
|
-
isUnregisteredDappAccess,
|
|
1990
|
-
RegisteredDappAccessSchema as RegisteredDappAccessSchema3
|
|
1991
|
-
} from "@xyo-network/os-model";
|
|
1992
|
-
import { PayloadBuilder as PayloadBuilder8 } from "@xyo-network/payload-builder";
|
|
2190
|
+
import { isDappPackageManifestPayload, isUnregisteredDappAccess, RegisteredDappAccessSchema as RegisteredDappAccessSchema3 } from "@xyo-network/os-model";
|
|
1993
2191
|
var ValidateDappAccessDiviner = class extends AbstractDiviner {
|
|
1994
|
-
static
|
|
2192
|
+
static {
|
|
2193
|
+
__name(this, "ValidateDappAccessDiviner");
|
|
2194
|
+
}
|
|
2195
|
+
static configSchemas = [
|
|
2196
|
+
ValidateDappAccessDivinerConfigSchema
|
|
2197
|
+
];
|
|
1995
2198
|
async divineHandler(payloads) {
|
|
1996
2199
|
const dappManifest = payloads?.filter(isDappPackageManifestPayload);
|
|
1997
2200
|
const accessors = payloads?.filter(isUnregisteredDappAccess);
|
|
@@ -2017,48 +2220,49 @@ var ValidateDappAccessDiviner = class extends AbstractDiviner {
|
|
|
2017
2220
|
const interfaceChildren = await getNodeChildren(dappAccessInterface.manifest, dappParams);
|
|
2018
2221
|
const valid = compareChildren(interfaceChildren, dappChildren);
|
|
2019
2222
|
if (valid) {
|
|
2020
|
-
const payload =
|
|
2223
|
+
const payload = {
|
|
2021
2224
|
...access,
|
|
2022
2225
|
schema: RegisteredDappAccessSchema3,
|
|
2023
2226
|
timestamp: Date.now()
|
|
2024
|
-
}
|
|
2227
|
+
};
|
|
2025
2228
|
registeredAccessors.push(payload);
|
|
2026
2229
|
} else {
|
|
2027
|
-
const failedRegistration =
|
|
2230
|
+
const failedRegistration = {
|
|
2028
2231
|
accessor: access,
|
|
2029
2232
|
errorMessage: "Invalid dapp access interface",
|
|
2030
2233
|
schema: FailedAccessorSchema
|
|
2031
|
-
}
|
|
2234
|
+
};
|
|
2032
2235
|
failedAccessors.push(failedRegistration);
|
|
2033
2236
|
}
|
|
2034
2237
|
}
|
|
2035
2238
|
} catch (e) {
|
|
2036
|
-
failedAccessors.push(
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
})
|
|
2042
|
-
);
|
|
2239
|
+
failedAccessors.push({
|
|
2240
|
+
accessor: access,
|
|
2241
|
+
errorMessage: e.message,
|
|
2242
|
+
schema: FailedAccessorSchema
|
|
2243
|
+
});
|
|
2043
2244
|
}
|
|
2044
2245
|
}
|
|
2045
|
-
return [
|
|
2246
|
+
return [
|
|
2247
|
+
...registeredAccessors,
|
|
2248
|
+
...failedAccessors
|
|
2249
|
+
];
|
|
2046
2250
|
}
|
|
2047
2251
|
};
|
|
2048
|
-
var compareChildren = (interfaceChildren, dappChildren) => {
|
|
2252
|
+
var compareChildren = /* @__PURE__ */ __name((interfaceChildren, dappChildren) => {
|
|
2049
2253
|
return interfaceChildren.every((interfaceChild) => Object.values(interfaceChild).every((interfaceChildName) => dappChildren.some((dappChild) => Object.values(dappChild).includes(interfaceChildName))));
|
|
2050
|
-
};
|
|
2051
|
-
var dappPackageManifestToPackageManifest = (dappPackageManifest) => {
|
|
2254
|
+
}, "compareChildren");
|
|
2255
|
+
var dappPackageManifestToPackageManifest = /* @__PURE__ */ __name((dappPackageManifest) => {
|
|
2052
2256
|
return {
|
|
2053
2257
|
...dappPackageManifest,
|
|
2054
2258
|
schema: PackageManifestPayloadSchema
|
|
2055
2259
|
};
|
|
2056
|
-
};
|
|
2057
|
-
var getChildrenFromNode = async (node) => {
|
|
2260
|
+
}, "dappPackageManifestToPackageManifest");
|
|
2261
|
+
var getChildrenFromNode = /* @__PURE__ */ __name(async (node) => {
|
|
2058
2262
|
const nodeManifest = (await node.state())?.[0];
|
|
2059
2263
|
return nodeManifest.status?.children;
|
|
2060
|
-
};
|
|
2061
|
-
var getNodeChildren = async (manifestToTest, dappParams) => {
|
|
2264
|
+
}, "getChildrenFromNode");
|
|
2265
|
+
var getNodeChildren = /* @__PURE__ */ __name(async (manifestToTest, dappParams) => {
|
|
2062
2266
|
const testNodes = await getNodeToTest(manifestToTest, dappParams);
|
|
2063
2267
|
const children = [];
|
|
2064
2268
|
for (const node of testNodes) {
|
|
@@ -2068,35 +2272,32 @@ var getNodeChildren = async (manifestToTest, dappParams) => {
|
|
|
2068
2272
|
}
|
|
2069
2273
|
}
|
|
2070
2274
|
return children;
|
|
2071
|
-
};
|
|
2072
|
-
var getNodeToTest = async (manifestToTest, dappParams) => {
|
|
2275
|
+
}, "getNodeChildren");
|
|
2276
|
+
var getNodeToTest = /* @__PURE__ */ __name(async (manifestToTest, dappParams) => {
|
|
2073
2277
|
const dappManifestWrapper = new ManifestWrapper2(manifestToTest, await HDWallet3.random(), dappParams.locator);
|
|
2074
2278
|
return await dappManifestWrapper.loadNodes();
|
|
2075
|
-
};
|
|
2279
|
+
}, "getNodeToTest");
|
|
2076
2280
|
|
|
2077
2281
|
// src/classes/registration/DappRegistry.ts
|
|
2078
2282
|
var DappRegistry = class {
|
|
2283
|
+
static {
|
|
2284
|
+
__name(this, "DappRegistry");
|
|
2285
|
+
}
|
|
2286
|
+
dappSeedPhraseRepository;
|
|
2287
|
+
dappRegistry;
|
|
2079
2288
|
constructor(dappSeedPhraseRepository) {
|
|
2080
2289
|
this.dappSeedPhraseRepository = dappSeedPhraseRepository;
|
|
2290
|
+
this.dappRegistry = /* @__PURE__ */ new Map();
|
|
2081
2291
|
}
|
|
2082
|
-
dappRegistry = /* @__PURE__ */ new Map();
|
|
2083
2292
|
/**
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2293
|
+
* Register a Dapp with window manager and if successful, return its id
|
|
2294
|
+
*
|
|
2295
|
+
* @param {UnregisteredDapp} dapp Manifest and UI of the Dapp to register
|
|
2296
|
+
* @returns {RegisteredDapp} dapp with registration fields
|
|
2297
|
+
**/
|
|
2089
2298
|
async registerDapp(dapp) {
|
|
2090
2299
|
if (dapp) {
|
|
2091
|
-
const {
|
|
2092
|
-
exposedModuleIds,
|
|
2093
|
-
manifest,
|
|
2094
|
-
modes,
|
|
2095
|
-
name,
|
|
2096
|
-
version,
|
|
2097
|
-
params,
|
|
2098
|
-
widgetConfigs
|
|
2099
|
-
} = this.extractDappProperties(dapp);
|
|
2300
|
+
const { exposedModuleIds, manifest, modes, name, version, params, widgetConfigs } = this.extractDappProperties(dapp);
|
|
2100
2301
|
try {
|
|
2101
2302
|
const walletId = await this.dappSeedPhraseRepository.findOrCreate(name);
|
|
2102
2303
|
const registeredAccessors = await this.validateDappAccessPayloads(manifest, dapp.accessors, params);
|
|
@@ -2131,27 +2332,16 @@ var DappRegistry = class {
|
|
|
2131
2332
|
}
|
|
2132
2333
|
}
|
|
2133
2334
|
/**
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2335
|
+
* Unregister a dapp so it can no longer be launched
|
|
2336
|
+
*
|
|
2337
|
+
* @param dappId
|
|
2338
|
+
*/
|
|
2138
2339
|
unregisterDapp(dappId) {
|
|
2139
2340
|
this.dappRegistry.delete(dappId);
|
|
2140
2341
|
}
|
|
2141
2342
|
extractDappProperties(dapp) {
|
|
2142
|
-
const {
|
|
2143
|
-
|
|
2144
|
-
config,
|
|
2145
|
-
widgetConfigs
|
|
2146
|
-
} = dapp;
|
|
2147
|
-
const {
|
|
2148
|
-
exposedModuleIds,
|
|
2149
|
-
manifest,
|
|
2150
|
-
modes,
|
|
2151
|
-
name,
|
|
2152
|
-
sources,
|
|
2153
|
-
version
|
|
2154
|
-
} = config;
|
|
2343
|
+
const { params, config, widgetConfigs } = dapp;
|
|
2344
|
+
const { exposedModuleIds, manifest, modes, name, sources, version } = config;
|
|
2155
2345
|
return {
|
|
2156
2346
|
exposedModuleIds,
|
|
2157
2347
|
manifest,
|
|
@@ -2166,10 +2356,15 @@ var DappRegistry = class {
|
|
|
2166
2356
|
async validateDappAccessPayloads(manifest, accessors = [], params) {
|
|
2167
2357
|
const validateDappAccess = await ValidateDappAccessDiviner.create({
|
|
2168
2358
|
account: await HDWallet4.random(),
|
|
2169
|
-
config: {
|
|
2359
|
+
config: {
|
|
2360
|
+
schema: ValidateDappAccessDivinerConfigSchema
|
|
2361
|
+
},
|
|
2170
2362
|
dappParams: params
|
|
2171
2363
|
});
|
|
2172
|
-
const payloads = await validateDappAccess.divine([
|
|
2364
|
+
const payloads = await validateDappAccess.divine([
|
|
2365
|
+
manifest,
|
|
2366
|
+
...accessors
|
|
2367
|
+
]);
|
|
2173
2368
|
const failedAccessors = payloads.filter(isFailedAccessor);
|
|
2174
2369
|
const registeredAccessors = payloads.filter(isRegisteredDappAccess2);
|
|
2175
2370
|
if (failedAccessors.length > 0) {
|
|
@@ -2181,6 +2376,26 @@ var DappRegistry = class {
|
|
|
2181
2376
|
|
|
2182
2377
|
// src/classes/registration/DappRegistrationService.ts
|
|
2183
2378
|
var DappRegistrationService = class {
|
|
2379
|
+
static {
|
|
2380
|
+
__name(this, "DappRegistrationService");
|
|
2381
|
+
}
|
|
2382
|
+
context;
|
|
2383
|
+
params;
|
|
2384
|
+
locator;
|
|
2385
|
+
developmentMode;
|
|
2386
|
+
// Dapps that have been built with their own context
|
|
2387
|
+
builtDapps;
|
|
2388
|
+
dappRegistry;
|
|
2389
|
+
dappSeedPhraseRepository;
|
|
2390
|
+
manageSystemDapps;
|
|
2391
|
+
// Dapps that have been registered with dappAccessRequests
|
|
2392
|
+
registeredAccessDappSets;
|
|
2393
|
+
// Dapps that have been registered with the dapp registry
|
|
2394
|
+
registeredDappSets;
|
|
2395
|
+
// Dapps that have been registered with exposeDappRequests
|
|
2396
|
+
registeredExposedDappSets;
|
|
2397
|
+
dappAccessRequestConnection;
|
|
2398
|
+
exposeDappRequestConnection;
|
|
2184
2399
|
constructor(context, params = {
|
|
2185
2400
|
dappNames: [],
|
|
2186
2401
|
dappParams: {},
|
|
@@ -2190,34 +2405,23 @@ var DappRegistrationService = class {
|
|
|
2190
2405
|
this.params = params;
|
|
2191
2406
|
this.locator = locator;
|
|
2192
2407
|
this.developmentMode = developmentMode;
|
|
2193
|
-
this.
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
);
|
|
2408
|
+
this.builtDapps = {};
|
|
2409
|
+
this.registeredAccessDappSets = /* @__PURE__ */ new Set();
|
|
2410
|
+
this.registeredDappSets = /* @__PURE__ */ new Set();
|
|
2411
|
+
this.registeredExposedDappSets = /* @__PURE__ */ new Set();
|
|
2412
|
+
this.dappAccessRequestConnection = dappAccessRequestConnection();
|
|
2413
|
+
this.exposeDappRequestConnection = exposeDappRequestConnection();
|
|
2414
|
+
this.manageSystemDapps = new ManageSystemDapps(context, this.params?.dappNames ?? [], this.params?.dappPayloads ?? [], this.params?.dappParams ?? {}, this.locator, this.developmentMode);
|
|
2201
2415
|
this.dappSeedPhraseRepository = new DappSeedPhraseRepository(context, this.params?.dappNames ?? []);
|
|
2202
2416
|
this.dappRegistry = new DappRegistry(this.dappSeedPhraseRepository);
|
|
2203
2417
|
this.addConnectionRequests();
|
|
2204
2418
|
}
|
|
2205
|
-
// Dapps that have been built with their own context
|
|
2206
|
-
builtDapps = {};
|
|
2207
|
-
dappRegistry;
|
|
2208
|
-
dappSeedPhraseRepository;
|
|
2209
|
-
manageSystemDapps;
|
|
2210
|
-
// Dapps that have been registered with dappAccessRequests
|
|
2211
|
-
registeredAccessDappSets = /* @__PURE__ */ new Set();
|
|
2212
|
-
// Dapps that have been registered with the dapp registry
|
|
2213
|
-
registeredDappSets = /* @__PURE__ */ new Set();
|
|
2214
|
-
// Dapps that have been registered with exposeDappRequests
|
|
2215
|
-
registeredExposedDappSets = /* @__PURE__ */ new Set();
|
|
2216
|
-
dappAccessRequestConnection = dappAccessRequestConnection();
|
|
2217
|
-
exposeDappRequestConnection = exposeDappRequestConnection();
|
|
2218
2419
|
async buildDapp(manifest, dappId = NameTransforms.slug(manifest.nodes[0]?.config.name), name = NameTransforms.moduleName(manifest.nodes[0]?.config.name)) {
|
|
2219
2420
|
const dapp = new XyOsDapp({
|
|
2220
|
-
dapp: {
|
|
2421
|
+
dapp: {
|
|
2422
|
+
id: dappId,
|
|
2423
|
+
name
|
|
2424
|
+
},
|
|
2221
2425
|
locator: this.locator,
|
|
2222
2426
|
manifest,
|
|
2223
2427
|
parent: this.context,
|
|
@@ -2230,37 +2434,43 @@ var DappRegistrationService = class {
|
|
|
2230
2434
|
return this.params?.dappParams[dappId];
|
|
2231
2435
|
}
|
|
2232
2436
|
async start() {
|
|
2233
|
-
const systemDapps = await this.context.monitor(async () => await this.manageSystemDapps.install(), {
|
|
2437
|
+
const systemDapps = await this.context.monitor(async () => await this.manageSystemDapps.install(), {
|
|
2438
|
+
name: "Install System dApps"
|
|
2439
|
+
});
|
|
2234
2440
|
const activeDapps = systemDapps.filter(({ dapp }) => dapp.icon.active === true);
|
|
2235
|
-
const results = await Promise.allSettled(
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2441
|
+
const results = await Promise.allSettled(activeDapps.map(async (dappSet) => {
|
|
2442
|
+
const { dapp } = dappSet;
|
|
2443
|
+
const registeredDapp = await this.dappRegistry.registerDapp(dapp);
|
|
2444
|
+
const result = {
|
|
2445
|
+
dapp: registeredDapp,
|
|
2446
|
+
dappIcon: dapp.icon
|
|
2447
|
+
};
|
|
2448
|
+
const forgetHandlers = /* @__PURE__ */ __name(async () => {
|
|
2449
|
+
try {
|
|
2450
|
+
await this.postRegistrationHandlers(result);
|
|
2451
|
+
} catch (e) {
|
|
2452
|
+
console.error("Error in post registration handlers", e);
|
|
2453
|
+
}
|
|
2454
|
+
}, "forgetHandlers");
|
|
2455
|
+
forget2(forgetHandlers());
|
|
2456
|
+
return result;
|
|
2457
|
+
}));
|
|
2251
2458
|
const failed = results.filter(rejected).map((result) => result.reason);
|
|
2252
2459
|
const succeeded = results.filter(fulfilled).map((result) => result.value);
|
|
2253
2460
|
for (const registeredDapp of succeeded) this.registeredDappSets.add(registeredDapp);
|
|
2254
|
-
return {
|
|
2461
|
+
return {
|
|
2462
|
+
failed,
|
|
2463
|
+
succeeded
|
|
2464
|
+
};
|
|
2255
2465
|
}
|
|
2256
2466
|
addConnectionRequests() {
|
|
2257
2467
|
this.context.eventBus.addConnection(this.dappAccessRequestConnection);
|
|
2258
2468
|
this.context.eventBus.addConnection(this.exposeDappRequestConnection);
|
|
2259
2469
|
}
|
|
2260
2470
|
/**
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2471
|
+
* A method to get the user property from context and eventually modify it before handing it to a dapp
|
|
2472
|
+
* i.e. curating user-approved signers
|
|
2473
|
+
*/
|
|
2264
2474
|
getUser() {
|
|
2265
2475
|
return this.context.user;
|
|
2266
2476
|
}
|
|
@@ -2268,17 +2478,19 @@ var DappRegistrationService = class {
|
|
|
2268
2478
|
if (registeredDapp.dapp) {
|
|
2269
2479
|
if (isRegisteredDappExposedDappSet(registeredDapp)) {
|
|
2270
2480
|
this.registeredExposedDappSets.add(registeredDapp);
|
|
2271
|
-
const exposeIntent = DappIntentCaller.buildIntent(
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2481
|
+
const exposeIntent = DappIntentCaller.buildIntent(DappIntentCaller.OsDappName, DappIntentTypes2.Launch, registeredDapp.dapp.config.name, DappMode3.Exposed);
|
|
2482
|
+
await this.exposeDappRequestConnection.emit(ExposeDappRequestEvent, {
|
|
2483
|
+
payloads: [
|
|
2484
|
+
registeredDapp.dapp.config,
|
|
2485
|
+
exposeIntent
|
|
2486
|
+
]
|
|
2487
|
+
});
|
|
2278
2488
|
}
|
|
2279
2489
|
if (isRegisteredDappAccessDappSet2(registeredDapp)) {
|
|
2280
2490
|
this.registeredAccessDappSets.add(registeredDapp);
|
|
2281
|
-
await this.dappAccessRequestConnection.emit(DappAccessRequestEvent, {
|
|
2491
|
+
await this.dappAccessRequestConnection.emit(DappAccessRequestEvent, {
|
|
2492
|
+
payloads: registeredDapp.dapp.accessors
|
|
2493
|
+
});
|
|
2282
2494
|
}
|
|
2283
2495
|
}
|
|
2284
2496
|
}
|
|
@@ -2294,6 +2506,10 @@ import { asDivinerInstance as asDivinerInstance4 } from "@xyo-network/diviner-mo
|
|
|
2294
2506
|
var OsSettingsArchivistModuleName = "OsSettingsNode:OsSettingsArchivist";
|
|
2295
2507
|
var OsSettingsArchivistPayloadDivinerModuleName = "OsSettingsNode:OsSettingsArchivistPayloadDiviner";
|
|
2296
2508
|
var OsSettingsCallerBase = class {
|
|
2509
|
+
static {
|
|
2510
|
+
__name(this, "OsSettingsCallerBase");
|
|
2511
|
+
}
|
|
2512
|
+
context;
|
|
2297
2513
|
constructor(context) {
|
|
2298
2514
|
this.context = context;
|
|
2299
2515
|
}
|
|
@@ -2302,10 +2518,7 @@ var OsSettingsCallerBase = class {
|
|
|
2302
2518
|
return asArchivistInstance5(mod, () => `${OsSettingsArchivistModuleName} is not an archivist`);
|
|
2303
2519
|
}
|
|
2304
2520
|
async getOsSettingsPayloadDiviner() {
|
|
2305
|
-
const mod = assertEx15(
|
|
2306
|
-
await this.context.root.resolve(OsSettingsArchivistPayloadDivinerModuleName),
|
|
2307
|
-
() => `${OsSettingsArchivistPayloadDivinerModuleName} not found`
|
|
2308
|
-
);
|
|
2521
|
+
const mod = assertEx15(await this.context.root.resolve(OsSettingsArchivistPayloadDivinerModuleName), () => `${OsSettingsArchivistPayloadDivinerModuleName} not found`);
|
|
2309
2522
|
return asDivinerInstance4(mod, () => `${OsSettingsArchivistPayloadDivinerModuleName} is not a diviner`);
|
|
2310
2523
|
}
|
|
2311
2524
|
};
|
|
@@ -2314,31 +2527,38 @@ var OsSettingsCallerBase = class {
|
|
|
2314
2527
|
import { PayloadDivinerQuerySchema as PayloadDivinerQuerySchema9 } from "@xyo-network/diviner-payload-model";
|
|
2315
2528
|
import { OsBadgeSchema } from "@xyo-network/os-model";
|
|
2316
2529
|
var OsBadgeQueries = {
|
|
2317
|
-
getBadge: async (achievement, diviner) => {
|
|
2530
|
+
getBadge: /* @__PURE__ */ __name(async (achievement, diviner) => {
|
|
2318
2531
|
const query = {
|
|
2319
2532
|
achievement,
|
|
2320
2533
|
limit: 1,
|
|
2321
2534
|
order: "desc",
|
|
2322
2535
|
schema: PayloadDivinerQuerySchema9,
|
|
2323
|
-
schemas: [
|
|
2536
|
+
schemas: [
|
|
2537
|
+
OsBadgeSchema
|
|
2538
|
+
]
|
|
2324
2539
|
};
|
|
2325
|
-
return await diviner.divine([
|
|
2326
|
-
|
|
2540
|
+
return await diviner.divine([
|
|
2541
|
+
query
|
|
2542
|
+
]);
|
|
2543
|
+
}, "getBadge")
|
|
2327
2544
|
};
|
|
2328
2545
|
|
|
2329
2546
|
// src/classes/settings/badge/Caller.ts
|
|
2330
2547
|
var OsBadgeCaller = class extends OsSettingsCallerBase {
|
|
2548
|
+
static {
|
|
2549
|
+
__name(this, "OsBadgeCaller");
|
|
2550
|
+
}
|
|
2331
2551
|
/**
|
|
2332
|
-
|
|
2333
|
-
|
|
2552
|
+
* @param {ValidOsAchievements} achievement
|
|
2553
|
+
*/
|
|
2334
2554
|
async getBadge(achievement) {
|
|
2335
2555
|
const diviner = await this.getOsSettingsPayloadDiviner();
|
|
2336
2556
|
const results = await OsBadgeQueries.getBadge(achievement, diviner);
|
|
2337
2557
|
return results[0] ?? null;
|
|
2338
2558
|
}
|
|
2339
2559
|
/**
|
|
2340
|
-
|
|
2341
|
-
|
|
2560
|
+
* @param {ValidOsAchievements} achievement
|
|
2561
|
+
*/
|
|
2342
2562
|
async saveBadge(achievement) {
|
|
2343
2563
|
const badge = {
|
|
2344
2564
|
achievement,
|
|
@@ -2346,7 +2566,9 @@ var OsBadgeCaller = class extends OsSettingsCallerBase {
|
|
|
2346
2566
|
timestamp: Date.now()
|
|
2347
2567
|
};
|
|
2348
2568
|
const archivist = await this.getOsSettingsArchivist();
|
|
2349
|
-
return await archivist.insert([
|
|
2569
|
+
return await archivist.insert([
|
|
2570
|
+
badge
|
|
2571
|
+
]);
|
|
2350
2572
|
}
|
|
2351
2573
|
};
|
|
2352
2574
|
|
|
@@ -2354,7 +2576,12 @@ var OsBadgeCaller = class extends OsSettingsCallerBase {
|
|
|
2354
2576
|
import { assertEx as assertEx16 } from "@xylabs/assert";
|
|
2355
2577
|
import { isBadgeWithMeta } from "@xyo-network/os-model";
|
|
2356
2578
|
var OsBadgeResource = class extends OsSettingsCallerBase {
|
|
2357
|
-
static
|
|
2579
|
+
static {
|
|
2580
|
+
__name(this, "OsBadgeResource");
|
|
2581
|
+
}
|
|
2582
|
+
static views = [
|
|
2583
|
+
"savedSeedPhrase"
|
|
2584
|
+
];
|
|
2358
2585
|
_savedSeedPhrase;
|
|
2359
2586
|
constructor(xyOsContext) {
|
|
2360
2587
|
super(xyOsContext);
|
|
@@ -2363,23 +2590,27 @@ var OsBadgeResource = class extends OsSettingsCallerBase {
|
|
|
2363
2590
|
return assertEx16(this._savedSeedPhrase, () => "Saved seed phrase listener not set");
|
|
2364
2591
|
}
|
|
2365
2592
|
get subscriptions() {
|
|
2366
|
-
return {
|
|
2593
|
+
return {
|
|
2594
|
+
savedSeedPhrase: /* @__PURE__ */ __name((cb) => this.savedSeedPhrase.subscribe(cb), "savedSeedPhrase")
|
|
2595
|
+
};
|
|
2367
2596
|
}
|
|
2368
2597
|
get views() {
|
|
2369
|
-
return {
|
|
2598
|
+
return {
|
|
2599
|
+
savedSeedPhrase: /* @__PURE__ */ __name(() => this.savedSeedPhrase.latest, "savedSeedPhrase")
|
|
2600
|
+
};
|
|
2370
2601
|
}
|
|
2371
2602
|
cleanupListeners() {
|
|
2372
2603
|
this.savedSeedPhrase.cleanupListeners();
|
|
2373
2604
|
}
|
|
2374
2605
|
/**
|
|
2375
|
-
|
|
2376
|
-
|
|
2606
|
+
* start listeners
|
|
2607
|
+
**/
|
|
2377
2608
|
async start() {
|
|
2378
2609
|
const diviner = await this.getOsSettingsPayloadDiviner();
|
|
2379
2610
|
const archivist = await this.getOsSettingsArchivist();
|
|
2380
2611
|
this._savedSeedPhrase = await PayloadStore.create({
|
|
2381
2612
|
archivist,
|
|
2382
|
-
getLatest: async () => await OsBadgeQueries.getBadge("savedSeedPhrase", diviner),
|
|
2613
|
+
getLatest: /* @__PURE__ */ __name(async () => await OsBadgeQueries.getBadge("savedSeedPhrase", diviner), "getLatest"),
|
|
2383
2614
|
idFunction: isBadgeWithMeta
|
|
2384
2615
|
});
|
|
2385
2616
|
}
|
|
@@ -2391,11 +2622,11 @@ import { isEqual } from "@xylabs/lodash";
|
|
|
2391
2622
|
|
|
2392
2623
|
// src/utils/buildWalletSeedPhrasePayload.ts
|
|
2393
2624
|
import { WalletSeedPhraseSchema } from "@xyo-network/os-model";
|
|
2394
|
-
import { PayloadBuilder as
|
|
2625
|
+
import { PayloadBuilder as PayloadBuilder8 } from "@xyo-network/payload-builder";
|
|
2395
2626
|
var language = "english";
|
|
2396
2627
|
var standard = "bip-39";
|
|
2397
2628
|
var userWalletLabel = "userWallet";
|
|
2398
|
-
var buildWalletSeedPhrasePayload = async (mnemonic, $label) => {
|
|
2629
|
+
var buildWalletSeedPhrasePayload = /* @__PURE__ */ __name(async (mnemonic, $label) => {
|
|
2399
2630
|
const fields = {
|
|
2400
2631
|
mnemonic: {
|
|
2401
2632
|
language,
|
|
@@ -2403,17 +2634,25 @@ var buildWalletSeedPhrasePayload = async (mnemonic, $label) => {
|
|
|
2403
2634
|
standard
|
|
2404
2635
|
}
|
|
2405
2636
|
};
|
|
2406
|
-
const meta = {
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2637
|
+
const meta = {
|
|
2638
|
+
$label,
|
|
2639
|
+
$timestamp: Date.now()
|
|
2640
|
+
};
|
|
2641
|
+
const payload = new PayloadBuilder8({
|
|
2642
|
+
schema: WalletSeedPhraseSchema
|
|
2643
|
+
}).fields(fields).meta(meta).build();
|
|
2644
|
+
const rootHash = await PayloadBuilder8.hash(payload);
|
|
2645
|
+
return {
|
|
2646
|
+
payload,
|
|
2647
|
+
rootHash
|
|
2648
|
+
};
|
|
2649
|
+
}, "buildWalletSeedPhrasePayload");
|
|
2650
|
+
var buildUserWalletSeedPhrasePayload = /* @__PURE__ */ __name((mnemonic) => {
|
|
2412
2651
|
return buildWalletSeedPhrasePayload(mnemonic, userWalletLabel);
|
|
2413
|
-
};
|
|
2652
|
+
}, "buildUserWalletSeedPhrasePayload");
|
|
2414
2653
|
|
|
2415
2654
|
// src/utils/getApiDomain.ts
|
|
2416
|
-
var getApiDomain = (scope, apiDomain) => {
|
|
2655
|
+
var getApiDomain = /* @__PURE__ */ __name((scope, apiDomain) => {
|
|
2417
2656
|
if (apiDomain !== void 0) {
|
|
2418
2657
|
return apiDomain;
|
|
2419
2658
|
}
|
|
@@ -2424,24 +2663,21 @@ var getApiDomain = (scope, apiDomain) => {
|
|
|
2424
2663
|
return "https://beta.archivist.xyo.network";
|
|
2425
2664
|
}
|
|
2426
2665
|
return "https://archivist.xyo.network";
|
|
2427
|
-
};
|
|
2666
|
+
}, "getApiDomain");
|
|
2428
2667
|
|
|
2429
2668
|
// src/utils/renameObjKey.ts
|
|
2430
|
-
var renameObjKey = (oldObj, oldKey, newKey) => {
|
|
2669
|
+
var renameObjKey = /* @__PURE__ */ __name((oldObj, oldKey, newKey) => {
|
|
2431
2670
|
const oldObjKeys = Object.keys(oldObj);
|
|
2432
|
-
const newObj = oldObjKeys.reduce(
|
|
2433
|
-
(
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
},
|
|
2441
|
-
{}
|
|
2442
|
-
);
|
|
2671
|
+
const newObj = oldObjKeys.reduce((acc, val) => {
|
|
2672
|
+
if (val === oldKey) {
|
|
2673
|
+
acc[newKey] = oldObj[oldKey];
|
|
2674
|
+
} else {
|
|
2675
|
+
acc[val] = oldObj[val];
|
|
2676
|
+
}
|
|
2677
|
+
return acc;
|
|
2678
|
+
}, {});
|
|
2443
2679
|
return newObj;
|
|
2444
|
-
};
|
|
2680
|
+
}, "renameObjKey");
|
|
2445
2681
|
|
|
2446
2682
|
// src/classes/settings/SettingsQueries.ts
|
|
2447
2683
|
import { PayloadDivinerQuerySchema as PayloadDivinerQuerySchema10 } from "@xyo-network/diviner-payload-model";
|
|
@@ -2453,57 +2689,78 @@ var OsSettingsQueries = {
|
|
|
2453
2689
|
limit: 1,
|
|
2454
2690
|
order: "desc",
|
|
2455
2691
|
schema: PayloadDivinerQuerySchema10,
|
|
2456
|
-
schemas: [
|
|
2692
|
+
schemas: [
|
|
2693
|
+
WalletSeedPhraseSchema2
|
|
2694
|
+
]
|
|
2457
2695
|
};
|
|
2458
|
-
const results = await diviner.divine([
|
|
2696
|
+
const results = await diviner.divine([
|
|
2697
|
+
query
|
|
2698
|
+
]);
|
|
2459
2699
|
const wallet = results.find((payload) => payload.$label === "userWallet");
|
|
2460
|
-
return wallet ? [
|
|
2700
|
+
return wallet ? [
|
|
2701
|
+
wallet
|
|
2702
|
+
] : NO_RESULTS2;
|
|
2461
2703
|
},
|
|
2462
2704
|
async getNodeBackground(diviner) {
|
|
2463
2705
|
const query = {
|
|
2464
2706
|
limit: 1,
|
|
2465
2707
|
order: "desc",
|
|
2466
2708
|
schema: PayloadDivinerQuerySchema10,
|
|
2467
|
-
schemas: [
|
|
2709
|
+
schemas: [
|
|
2710
|
+
NodeBackgroundSchema
|
|
2711
|
+
]
|
|
2468
2712
|
};
|
|
2469
|
-
return await diviner.divine([
|
|
2713
|
+
return await diviner.divine([
|
|
2714
|
+
query
|
|
2715
|
+
]);
|
|
2470
2716
|
},
|
|
2471
2717
|
async getWallets(diviner) {
|
|
2472
2718
|
const query = {
|
|
2473
2719
|
order: "desc",
|
|
2474
2720
|
schema: PayloadDivinerQuerySchema10,
|
|
2475
|
-
schemas: [
|
|
2721
|
+
schemas: [
|
|
2722
|
+
WalletSeedPhraseSchema2
|
|
2723
|
+
]
|
|
2476
2724
|
};
|
|
2477
|
-
return await diviner.divine([
|
|
2725
|
+
return await diviner.divine([
|
|
2726
|
+
query
|
|
2727
|
+
]);
|
|
2478
2728
|
}
|
|
2479
2729
|
};
|
|
2480
2730
|
|
|
2481
2731
|
// src/classes/settings/Caller.ts
|
|
2482
2732
|
var OsSettingsCaller = class extends OsSettingsCallerBase {
|
|
2733
|
+
static {
|
|
2734
|
+
__name(this, "OsSettingsCaller");
|
|
2735
|
+
}
|
|
2483
2736
|
constructor(context) {
|
|
2484
2737
|
super(context);
|
|
2485
2738
|
}
|
|
2486
2739
|
/**
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2740
|
+
* Add a node background to the settings
|
|
2741
|
+
* @param {NodeBackground} payload
|
|
2742
|
+
*/
|
|
2490
2743
|
async addNodeBackground(payload) {
|
|
2491
2744
|
const archivist = await this.getOsSettingsArchivist();
|
|
2492
|
-
await archivist.insert([
|
|
2745
|
+
await archivist.insert([
|
|
2746
|
+
payload
|
|
2747
|
+
]);
|
|
2493
2748
|
}
|
|
2494
2749
|
/**
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2750
|
+
* Add a wallet seed phrase to the settings
|
|
2751
|
+
* @param {WalletSeedPhrase} payload
|
|
2752
|
+
*/
|
|
2498
2753
|
async addWalletSeedPhrase(payload) {
|
|
2499
2754
|
const archivist = await this.getOsSettingsArchivist();
|
|
2500
|
-
await archivist.insert([
|
|
2755
|
+
await archivist.insert([
|
|
2756
|
+
payload
|
|
2757
|
+
]);
|
|
2501
2758
|
const phrase = payload.mnemonic.mnemonic.join(" ");
|
|
2502
2759
|
await this.context.kernel?.bios?.seedPhraseStore.set("user", phrase);
|
|
2503
2760
|
}
|
|
2504
2761
|
/**
|
|
2505
|
-
|
|
2506
|
-
|
|
2762
|
+
* Get the latest node background
|
|
2763
|
+
*/
|
|
2507
2764
|
async getLatestNodeBackground() {
|
|
2508
2765
|
const diviner = await this.getOsSettingsPayloadDiviner();
|
|
2509
2766
|
const [result] = await OsSettingsQueries.getNodeBackground(diviner);
|
|
@@ -2530,6 +2787,9 @@ var OsSettingsCaller = class extends OsSettingsCallerBase {
|
|
|
2530
2787
|
import { assertEx as assertEx18 } from "@xylabs/assert";
|
|
2531
2788
|
import { isNodeBackground, isWalletSeedPhrase } from "@xyo-network/os-model";
|
|
2532
2789
|
var OsSettingsResource = class extends OsSettingsCallerBase {
|
|
2790
|
+
static {
|
|
2791
|
+
__name(this, "OsSettingsResource");
|
|
2792
|
+
}
|
|
2533
2793
|
_latestUserWalletListener;
|
|
2534
2794
|
_nodeBackgroundListener;
|
|
2535
2795
|
_walletsListener;
|
|
@@ -2544,16 +2804,16 @@ var OsSettingsResource = class extends OsSettingsCallerBase {
|
|
|
2544
2804
|
}
|
|
2545
2805
|
get subscriptions() {
|
|
2546
2806
|
return {
|
|
2547
|
-
latestUserWallet: (cb) => this.walletsListener.subscribe(cb),
|
|
2548
|
-
nodeBackground: (cb) => this.nodeBackgroundListener.subscribe(cb),
|
|
2549
|
-
wallets: (cb) => this.walletsListener.subscribe(cb)
|
|
2807
|
+
latestUserWallet: /* @__PURE__ */ __name((cb) => this.walletsListener.subscribe(cb), "latestUserWallet"),
|
|
2808
|
+
nodeBackground: /* @__PURE__ */ __name((cb) => this.nodeBackgroundListener.subscribe(cb), "nodeBackground"),
|
|
2809
|
+
wallets: /* @__PURE__ */ __name((cb) => this.walletsListener.subscribe(cb), "wallets")
|
|
2550
2810
|
};
|
|
2551
2811
|
}
|
|
2552
2812
|
get views() {
|
|
2553
2813
|
return {
|
|
2554
|
-
latestUserWallet: () => this.latestUserWalletListener.latest,
|
|
2555
|
-
nodeBackground: () => this.nodeBackgroundListener.latest,
|
|
2556
|
-
wallets: () => this.walletsListener.latest
|
|
2814
|
+
latestUserWallet: /* @__PURE__ */ __name(() => this.latestUserWalletListener.latest, "latestUserWallet"),
|
|
2815
|
+
nodeBackground: /* @__PURE__ */ __name(() => this.nodeBackgroundListener.latest, "nodeBackground"),
|
|
2816
|
+
wallets: /* @__PURE__ */ __name(() => this.walletsListener.latest, "wallets")
|
|
2557
2817
|
};
|
|
2558
2818
|
}
|
|
2559
2819
|
get walletsListener() {
|
|
@@ -2564,24 +2824,24 @@ var OsSettingsResource = class extends OsSettingsCallerBase {
|
|
|
2564
2824
|
this.latestUserWalletListener.cleanupListeners();
|
|
2565
2825
|
}
|
|
2566
2826
|
/**
|
|
2567
|
-
|
|
2568
|
-
|
|
2827
|
+
* start listeners
|
|
2828
|
+
*/
|
|
2569
2829
|
async start() {
|
|
2570
2830
|
const archivist = await this.getOsSettingsArchivist();
|
|
2571
2831
|
const diviner = await this.getOsSettingsPayloadDiviner();
|
|
2572
2832
|
this._walletsListener = await PayloadStore.create({
|
|
2573
2833
|
archivist,
|
|
2574
|
-
getLatest: async () => await OsSettingsQueries.getWallets(diviner),
|
|
2834
|
+
getLatest: /* @__PURE__ */ __name(async () => await OsSettingsQueries.getWallets(diviner), "getLatest"),
|
|
2575
2835
|
idFunction: isWalletSeedPhrase
|
|
2576
2836
|
});
|
|
2577
2837
|
this._latestUserWalletListener = await PayloadStore.create({
|
|
2578
2838
|
archivist,
|
|
2579
|
-
getLatest: async () => await OsSettingsQueries.getLatestUserWallet(diviner),
|
|
2839
|
+
getLatest: /* @__PURE__ */ __name(async () => await OsSettingsQueries.getLatestUserWallet(diviner), "getLatest"),
|
|
2580
2840
|
idFunction: isWalletSeedPhrase
|
|
2581
2841
|
});
|
|
2582
2842
|
this._nodeBackgroundListener = await PayloadStore.create({
|
|
2583
2843
|
archivist,
|
|
2584
|
-
getLatest: async () => await OsSettingsQueries.getNodeBackground(diviner),
|
|
2844
|
+
getLatest: /* @__PURE__ */ __name(async () => await OsSettingsQueries.getNodeBackground(diviner), "getLatest"),
|
|
2585
2845
|
idFunction: isNodeBackground
|
|
2586
2846
|
});
|
|
2587
2847
|
}
|
|
@@ -2591,6 +2851,9 @@ var OsSettingsResource = class extends OsSettingsCallerBase {
|
|
|
2591
2851
|
import { assertEx as assertEx19 } from "@xylabs/assert";
|
|
2592
2852
|
import { HDWallet as HDWallet5 } from "@xyo-network/account";
|
|
2593
2853
|
var Signers = class {
|
|
2854
|
+
static {
|
|
2855
|
+
__name(this, "Signers");
|
|
2856
|
+
}
|
|
2594
2857
|
_paths;
|
|
2595
2858
|
_signerAccounts;
|
|
2596
2859
|
_walletStore;
|
|
@@ -2641,26 +2904,32 @@ import { IndexedDbPayloadDiviner } from "@xyo-network/diviner-payload-indexeddb"
|
|
|
2641
2904
|
import { ManifestWrapper as ManifestWrapper3 } from "@xyo-network/manifest-wrapper";
|
|
2642
2905
|
import { ModuleFactoryLocator as ModuleFactoryLocator6 } from "@xyo-network/module-factory-locator";
|
|
2643
2906
|
var OS_NODE_PATH = "1'";
|
|
2644
|
-
var getDefaultOsNodeLocator = () => {
|
|
2907
|
+
var getDefaultOsNodeLocator = /* @__PURE__ */ __name(() => {
|
|
2645
2908
|
const locator = new ModuleFactoryLocator6();
|
|
2646
|
-
locator.register(IndexedDbArchivist, {
|
|
2647
|
-
|
|
2909
|
+
locator.register(IndexedDbArchivist, {
|
|
2910
|
+
"network.xyo.archivist.persistence.scope": "device"
|
|
2911
|
+
});
|
|
2912
|
+
locator.register(IndexedDbPayloadDiviner, {
|
|
2913
|
+
"network.xyo.archivist.persistence.scope": "device"
|
|
2914
|
+
});
|
|
2648
2915
|
return locator;
|
|
2649
|
-
};
|
|
2650
|
-
var loadOsNode = async (osWallet, locator) => {
|
|
2916
|
+
}, "getDefaultOsNodeLocator");
|
|
2917
|
+
var loadOsNode = /* @__PURE__ */ __name(async (osWallet, locator) => {
|
|
2651
2918
|
try {
|
|
2652
2919
|
const osNodeWallet = await osWallet.derivePath(OS_NODE_PATH);
|
|
2653
2920
|
const osNodeLocator = locator ?? getDefaultOsNodeLocator();
|
|
2654
2921
|
const manifestWrapper = new ManifestWrapper3(os_node_manifest_default, osNodeWallet, osNodeLocator);
|
|
2655
2922
|
const osNode = (await manifestWrapper.loadNodes())[0];
|
|
2656
|
-
return [
|
|
2923
|
+
return [
|
|
2924
|
+
osNode
|
|
2925
|
+
];
|
|
2657
2926
|
} catch (e) {
|
|
2658
2927
|
const error = e;
|
|
2659
2928
|
console.error(`Error creating os node: ${error.message}`);
|
|
2660
2929
|
console.error(`Error creating os node: ${error.stack}`);
|
|
2661
2930
|
throw new Error(`Error creating os node: ${error.message}`);
|
|
2662
2931
|
}
|
|
2663
|
-
};
|
|
2932
|
+
}, "loadOsNode");
|
|
2664
2933
|
|
|
2665
2934
|
// src/stack/Base.ts
|
|
2666
2935
|
import { assertEx as assertEx20 } from "@xylabs/assert";
|
|
@@ -2669,6 +2938,9 @@ import { BaseEmitter as BaseEmitter3 } from "@xyo-network/module-event-emitter";
|
|
|
2669
2938
|
import { isModuleInstance } from "@xyo-network/module-model";
|
|
2670
2939
|
import { asAttachableNodeInstance } from "@xyo-network/node-model";
|
|
2671
2940
|
var StackBase = class extends BaseEmitter3 {
|
|
2941
|
+
static {
|
|
2942
|
+
__name(this, "StackBase");
|
|
2943
|
+
}
|
|
2672
2944
|
// flag to check that all adapters are initialized
|
|
2673
2945
|
initialized = false;
|
|
2674
2946
|
// adapters to initialize into the stack
|
|
@@ -2703,57 +2975,57 @@ var StackBase = class extends BaseEmitter3 {
|
|
|
2703
2975
|
initialize() {
|
|
2704
2976
|
this.assignStack();
|
|
2705
2977
|
for (const adapter of this.adapterSet) {
|
|
2706
|
-
const driverReadyListener = async ({ node }) => await this.handleDriverReady(node);
|
|
2978
|
+
const driverReadyListener = /* @__PURE__ */ __name(async ({ node }) => await this.handleDriverReady(node), "driverReadyListener");
|
|
2707
2979
|
adapter.on("driverReady", driverReadyListener);
|
|
2708
2980
|
this.listeners.push({
|
|
2709
2981
|
adapter,
|
|
2710
2982
|
eventName: "driverReady",
|
|
2711
2983
|
listener: driverReadyListener
|
|
2712
2984
|
});
|
|
2713
|
-
const driverErrorListener = async ({ error }) => {
|
|
2985
|
+
const driverErrorListener = /* @__PURE__ */ __name(async ({ error }) => {
|
|
2714
2986
|
console.error(`Error updating ${this.stackNodeModuleId} stack node`, error);
|
|
2715
|
-
await this.emit("driverError", {
|
|
2716
|
-
|
|
2987
|
+
await this.emit("driverError", {
|
|
2988
|
+
error
|
|
2989
|
+
});
|
|
2990
|
+
}, "driverErrorListener");
|
|
2717
2991
|
adapter.on("driverError", driverErrorListener);
|
|
2718
2992
|
this.listeners.push({
|
|
2719
2993
|
adapter,
|
|
2720
2994
|
eventName: "driverError",
|
|
2721
2995
|
listener: driverErrorListener
|
|
2722
2996
|
});
|
|
2723
|
-
const startAdapter = async () => await adapter.start();
|
|
2997
|
+
const startAdapter = /* @__PURE__ */ __name(async () => await adapter.start(), "startAdapter");
|
|
2724
2998
|
forget3(startAdapter());
|
|
2725
2999
|
}
|
|
2726
3000
|
}
|
|
2727
3001
|
/**
|
|
2728
|
-
|
|
2729
|
-
|
|
3002
|
+
* Stops the stack
|
|
3003
|
+
*/
|
|
2730
3004
|
stop() {
|
|
2731
|
-
for (const {
|
|
2732
|
-
eventName,
|
|
2733
|
-
listener,
|
|
2734
|
-
adapter
|
|
2735
|
-
} of this.listeners) {
|
|
3005
|
+
for (const { eventName, listener, adapter } of this.listeners) {
|
|
2736
3006
|
adapter.off(eventName, listener);
|
|
2737
3007
|
}
|
|
2738
3008
|
}
|
|
2739
3009
|
/**
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
3010
|
+
* Adds a node to the stack. Idempotent to avoid adding the
|
|
3011
|
+
* same node multiple times
|
|
3012
|
+
* @param node The node to add to the stack
|
|
3013
|
+
* @returns
|
|
3014
|
+
*/
|
|
2745
3015
|
async addNodeToStackNode(node) {
|
|
2746
3016
|
const stackNode = await this.getStackNode();
|
|
2747
|
-
const existingModule = await stackNode.resolve(node.address, {
|
|
3017
|
+
const existingModule = await stackNode.resolve(node.address, {
|
|
3018
|
+
direction: "down"
|
|
3019
|
+
});
|
|
2748
3020
|
if (isModuleInstance(existingModule)) return;
|
|
2749
3021
|
await stackNode.register?.(node);
|
|
2750
3022
|
await stackNode.attach?.(node.address, true);
|
|
2751
3023
|
}
|
|
2752
3024
|
assignStack() {
|
|
2753
|
-
const assign = async () => {
|
|
3025
|
+
const assign = /* @__PURE__ */ __name(async () => {
|
|
2754
3026
|
const stackNode = await this.getStackNode();
|
|
2755
3027
|
this._stack = stackNode;
|
|
2756
|
-
};
|
|
3028
|
+
}, "assign");
|
|
2757
3029
|
forget3(assign());
|
|
2758
3030
|
}
|
|
2759
3031
|
async getStackNode() {
|
|
@@ -2762,25 +3034,34 @@ var StackBase = class extends BaseEmitter3 {
|
|
|
2762
3034
|
}
|
|
2763
3035
|
async handleDriverReady(node) {
|
|
2764
3036
|
try {
|
|
2765
|
-
await this.emit("driverReady", {
|
|
3037
|
+
await this.emit("driverReady", {
|
|
3038
|
+
node
|
|
3039
|
+
});
|
|
2766
3040
|
await this.addNodeToStackNode(node);
|
|
2767
3041
|
await this.updateInitializationState(node);
|
|
2768
3042
|
} catch (error) {
|
|
2769
3043
|
console.error(`Error updating ${this.stackNodeModuleId} stack node`, node.id, error);
|
|
2770
|
-
await this.emit("stackError", {
|
|
3044
|
+
await this.emit("stackError", {
|
|
3045
|
+
error
|
|
3046
|
+
});
|
|
2771
3047
|
}
|
|
2772
3048
|
}
|
|
2773
3049
|
async updateInitializationState(node) {
|
|
2774
3050
|
this.initializedNodes.push(node);
|
|
2775
3051
|
this.initialized = this.adapterSet.every((n) => n.initialized);
|
|
2776
3052
|
if (this.initialized) {
|
|
2777
|
-
await this.emit("initialized", {
|
|
3053
|
+
await this.emit("initialized", {
|
|
3054
|
+
stack: await this.getStackNode()
|
|
3055
|
+
});
|
|
2778
3056
|
}
|
|
2779
3057
|
}
|
|
2780
3058
|
};
|
|
2781
3059
|
|
|
2782
3060
|
// src/stack/Manager.ts
|
|
2783
3061
|
var StackManager = class {
|
|
3062
|
+
static {
|
|
3063
|
+
__name(this, "StackManager");
|
|
3064
|
+
}
|
|
2784
3065
|
initializedStacksMap = /* @__PURE__ */ new Map();
|
|
2785
3066
|
stackMap;
|
|
2786
3067
|
constructor(stackMap) {
|
|
@@ -2822,27 +3103,30 @@ import { BaseEmitter as BaseEmitter4 } from "@xyo-network/module-event-emitter";
|
|
|
2822
3103
|
import { asAttachableNodeInstance as asAttachableNodeInstance2 } from "@xyo-network/node-model";
|
|
2823
3104
|
import { v4 as uuid3 } from "uuid";
|
|
2824
3105
|
var NodeAdapterBase = class extends BaseEmitter4 {
|
|
3106
|
+
static {
|
|
3107
|
+
__name(this, "NodeAdapterBase");
|
|
3108
|
+
}
|
|
3109
|
+
kernel;
|
|
3110
|
+
driverName;
|
|
3111
|
+
initialized;
|
|
3112
|
+
_id;
|
|
2825
3113
|
constructor(kernel, driverName) {
|
|
2826
|
-
super({});
|
|
2827
|
-
this.kernel = kernel;
|
|
2828
|
-
this.driverName = driverName;
|
|
3114
|
+
super({}), this.kernel = kernel, this.driverName = driverName, this.initialized = false, this._id = "";
|
|
2829
3115
|
this._id = uuid3();
|
|
2830
3116
|
}
|
|
2831
|
-
initialized = false;
|
|
2832
|
-
_id = "";
|
|
2833
3117
|
get id() {
|
|
2834
3118
|
return assertEx21(this._id, () => "NodeAdapterBase id not initialized");
|
|
2835
3119
|
}
|
|
2836
3120
|
async start() {
|
|
2837
3121
|
try {
|
|
2838
|
-
const moduleAttachedInsertListener = ({ payloads }) => {
|
|
3122
|
+
const moduleAttachedInsertListener = /* @__PURE__ */ __name(({ payloads }) => {
|
|
2839
3123
|
const moduleAttachedEvent = this.findModuleEventPayloads(payloads);
|
|
2840
3124
|
for (const payload of moduleAttachedEvent) {
|
|
2841
3125
|
if (payload.name === this.driverName) {
|
|
2842
3126
|
this.validateAndReturnDriver();
|
|
2843
3127
|
}
|
|
2844
3128
|
}
|
|
2845
|
-
};
|
|
3129
|
+
}, "moduleAttachedInsertListener");
|
|
2846
3130
|
const eventsArchivist = await this.getEventsArchivist();
|
|
2847
3131
|
const weakRefInsertListener = new WeakRef(moduleAttachedInsertListener);
|
|
2848
3132
|
const insertListenerRef = weakRefInsertListener.deref();
|
|
@@ -2851,7 +3135,9 @@ var NodeAdapterBase = class extends BaseEmitter4 {
|
|
|
2851
3135
|
if (node) return node;
|
|
2852
3136
|
this.initialized = false;
|
|
2853
3137
|
} catch (error) {
|
|
2854
|
-
await this.emit("driverError", {
|
|
3138
|
+
await this.emit("driverError", {
|
|
3139
|
+
error
|
|
3140
|
+
});
|
|
2855
3141
|
}
|
|
2856
3142
|
}
|
|
2857
3143
|
findModuleEventPayloads(payloads) {
|
|
@@ -2869,7 +3155,9 @@ var NodeAdapterBase = class extends BaseEmitter4 {
|
|
|
2869
3155
|
if (mod) {
|
|
2870
3156
|
const node = asAttachableNodeInstance2(mod, () => `${mod.id} is not a node`);
|
|
2871
3157
|
this.initialized = true;
|
|
2872
|
-
const emit = async () => await this.emit("driverReady", {
|
|
3158
|
+
const emit = /* @__PURE__ */ __name(async () => await this.emit("driverReady", {
|
|
3159
|
+
node
|
|
3160
|
+
}), "emit");
|
|
2873
3161
|
forget4(emit());
|
|
2874
3162
|
return node;
|
|
2875
3163
|
}
|
|
@@ -2878,6 +3166,9 @@ var NodeAdapterBase = class extends BaseEmitter4 {
|
|
|
2878
3166
|
|
|
2879
3167
|
// src/adapter/Network.ts
|
|
2880
3168
|
var NetworkAdapter = class extends NodeAdapterBase {
|
|
3169
|
+
static {
|
|
3170
|
+
__name(this, "NetworkAdapter");
|
|
3171
|
+
}
|
|
2881
3172
|
_connection;
|
|
2882
3173
|
constructor(kernel, driverName) {
|
|
2883
3174
|
super(kernel, driverName);
|
|
@@ -2898,6 +3189,9 @@ var NetworkAdapter = class extends NodeAdapterBase {
|
|
|
2898
3189
|
|
|
2899
3190
|
// src/adapter/Settings.ts
|
|
2900
3191
|
var SettingsAdapter = class extends NodeAdapterBase {
|
|
3192
|
+
static {
|
|
3193
|
+
__name(this, "SettingsAdapter");
|
|
3194
|
+
}
|
|
2901
3195
|
_settings = void 0;
|
|
2902
3196
|
constructor(kernel, driverName) {
|
|
2903
3197
|
super(kernel, driverName);
|
|
@@ -2917,26 +3211,31 @@ var SettingsAdapter = class extends NodeAdapterBase {
|
|
|
2917
3211
|
};
|
|
2918
3212
|
|
|
2919
3213
|
// src/adapters/OsPubSubBridgeNetwork.ts
|
|
2920
|
-
var OsPubSubBridgeNetworkAdapters = (kernel) => [
|
|
3214
|
+
var OsPubSubBridgeNetworkAdapters = /* @__PURE__ */ __name((kernel) => [
|
|
2921
3215
|
new NetworkAdapter(kernel, PubSubBridgeNodeNodeName),
|
|
2922
3216
|
new NetworkAdapter(kernel, ExposedNodeOuterNodeName)
|
|
2923
|
-
];
|
|
3217
|
+
], "OsPubSubBridgeNetworkAdapters");
|
|
2924
3218
|
|
|
2925
3219
|
// src/adapters/OsSettings.ts
|
|
2926
3220
|
import { OsSettingsNodeName } from "@xyo-network/os-model";
|
|
2927
|
-
var OsSettingsAdapters = (kernel) => [
|
|
3221
|
+
var OsSettingsAdapters = /* @__PURE__ */ __name((kernel) => [
|
|
3222
|
+
new SettingsAdapter(kernel, OsSettingsNodeName)
|
|
3223
|
+
], "OsSettingsAdapters");
|
|
2928
3224
|
|
|
2929
3225
|
// src/adapters/OsXyoPublicNetwork.ts
|
|
2930
3226
|
import { XyoPublicNodeName } from "@xyo-network/os-model";
|
|
2931
|
-
var OsXyoPublicNetworkAdapters = (kernel) => [
|
|
3227
|
+
var OsXyoPublicNetworkAdapters = /* @__PURE__ */ __name((kernel) => [
|
|
2932
3228
|
new NetworkAdapter(kernel, XyoPublicNodeName)
|
|
2933
|
-
];
|
|
3229
|
+
], "OsXyoPublicNetworkAdapters");
|
|
2934
3230
|
|
|
2935
3231
|
// src/stack/OsPubSubNetworkStack.ts
|
|
2936
3232
|
import { assertEx as assertEx22 } from "@xylabs/assert";
|
|
2937
3233
|
import { asAttachableNodeInstance as asAttachableNodeInstance3, asNodeInstance as asNodeInstance2 } from "@xyo-network/node-model";
|
|
2938
3234
|
import { ExposedNodeOuterNodeName as ExposedNodeOuterNodeName2, PubSubBridgeNodeNodeName as PubSubBridgeNodeNodeName2 } from "@xyo-network/os-model";
|
|
2939
3235
|
var OsPubSubNetworkStack = class extends StackBase {
|
|
3236
|
+
static {
|
|
3237
|
+
__name(this, "OsPubSubNetworkStack");
|
|
3238
|
+
}
|
|
2940
3239
|
_exposedNode;
|
|
2941
3240
|
_exposedNodeOuter;
|
|
2942
3241
|
busConnection = osPubSubNetworkReadyConnection();
|
|
@@ -2979,13 +3278,15 @@ var OsPubSubNetworkStack = class extends StackBase {
|
|
|
2979
3278
|
super.stop();
|
|
2980
3279
|
this._exposedNode = void 0;
|
|
2981
3280
|
this._exposedNodeOuter = void 0;
|
|
2982
|
-
if (this.busConnection._id)
|
|
2983
|
-
this.context.eventBus.removeConnection(this.busConnection.id);
|
|
3281
|
+
if (this.busConnection._id) this.context.eventBus.removeConnection(this.busConnection.id);
|
|
2984
3282
|
}
|
|
2985
3283
|
};
|
|
2986
3284
|
|
|
2987
3285
|
// src/stack/OsSettingsStack.ts
|
|
2988
3286
|
var OsSettingsStack = class extends StackBase {
|
|
3287
|
+
static {
|
|
3288
|
+
__name(this, "OsSettingsStack");
|
|
3289
|
+
}
|
|
2989
3290
|
busConnection = osSettingsReadyConnection();
|
|
2990
3291
|
constructor(context, adapters) {
|
|
2991
3292
|
super(context, adapters, "OsSettingsStackNode");
|
|
@@ -3003,6 +3304,9 @@ var OsSettingsStack = class extends StackBase {
|
|
|
3003
3304
|
// src/stack/XyoPublicNetworkStack.ts
|
|
3004
3305
|
import { XyoPublicNodeName as XyoPublicNodeName2 } from "@xyo-network/os-model";
|
|
3005
3306
|
var XyoPublicNetworkStack = class extends StackBase {
|
|
3307
|
+
static {
|
|
3308
|
+
__name(this, "XyoPublicNetworkStack");
|
|
3309
|
+
}
|
|
3006
3310
|
busConnection = osXyoPublicNetworkReadyConnection();
|
|
3007
3311
|
constructor(context, adapters) {
|
|
3008
3312
|
super(context, adapters, "OsXyoPublicNetworkStackNode");
|
|
@@ -3041,6 +3345,9 @@ var OsStackMap = {
|
|
|
3041
3345
|
|
|
3042
3346
|
// src/XyOs.ts
|
|
3043
3347
|
var XyOs = class _XyOs extends XyOsContextBase {
|
|
3348
|
+
static {
|
|
3349
|
+
__name(this, "XyOs");
|
|
3350
|
+
}
|
|
3044
3351
|
_exposedNode;
|
|
3045
3352
|
_exposedNodeOuter;
|
|
3046
3353
|
_kernel;
|
|
@@ -3048,16 +3355,9 @@ var XyOs = class _XyOs extends XyOsContextBase {
|
|
|
3048
3355
|
dappRegistrationService;
|
|
3049
3356
|
signers;
|
|
3050
3357
|
stackManager;
|
|
3051
|
-
constructor({
|
|
3052
|
-
logger
|
|
3053
|
-
|
|
3054
|
-
kernel = new Kernel({ logger }),
|
|
3055
|
-
locator = new ModuleFactoryLocator7(),
|
|
3056
|
-
dappsConfiguration,
|
|
3057
|
-
developmentMode,
|
|
3058
|
-
stackMap = OsStackMap,
|
|
3059
|
-
...params
|
|
3060
|
-
} = {}) {
|
|
3358
|
+
constructor({ logger = console, eventBus = new EventBus(), kernel = new Kernel({
|
|
3359
|
+
logger
|
|
3360
|
+
}), locator = new ModuleFactoryLocator7(), dappsConfiguration, developmentMode, stackMap = OsStackMap, ...params } = {}) {
|
|
3061
3361
|
super({
|
|
3062
3362
|
eventBus,
|
|
3063
3363
|
kernel,
|
|
@@ -3095,14 +3395,19 @@ var XyOs = class _XyOs extends XyOsContextBase {
|
|
|
3095
3395
|
return this.stackManager.stacks;
|
|
3096
3396
|
}
|
|
3097
3397
|
get user() {
|
|
3098
|
-
return {
|
|
3398
|
+
return {
|
|
3399
|
+
signers: this.signers?.getWalletKindSigner("user")
|
|
3400
|
+
};
|
|
3099
3401
|
}
|
|
3100
3402
|
static async monitor(fn, eventConfig) {
|
|
3101
3403
|
const { name, additionalProperties } = eventConfig;
|
|
3102
3404
|
const monitor = this.monitoring;
|
|
3103
3405
|
monitor?.startTimer(name);
|
|
3104
3406
|
const result = await fn();
|
|
3105
|
-
monitor?.stopTimer({
|
|
3407
|
+
monitor?.stopTimer({
|
|
3408
|
+
additionalProperties,
|
|
3409
|
+
name
|
|
3410
|
+
});
|
|
3106
3411
|
return result;
|
|
3107
3412
|
}
|
|
3108
3413
|
async boot(wallet, locator = new ModuleFactoryLocator7()) {
|
|
@@ -3111,13 +3416,18 @@ var XyOs = class _XyOs extends XyOsContextBase {
|
|
|
3111
3416
|
return await this._bootMutex.runExclusive(async () => {
|
|
3112
3417
|
await this.eventBus.start();
|
|
3113
3418
|
if (this.kernel?.status === "created") {
|
|
3114
|
-
await this.kernel.boot(await boot(), {
|
|
3419
|
+
await this.kernel.boot(await boot(), {
|
|
3420
|
+
locator: fullLocator,
|
|
3421
|
+
kernelDrivers: []
|
|
3422
|
+
});
|
|
3115
3423
|
}
|
|
3116
3424
|
if (this.kernel?.status !== "booted") {
|
|
3117
3425
|
throw new Error("Kernel not booted");
|
|
3118
3426
|
}
|
|
3119
3427
|
assertEx23(this._root === void 0, () => "XyOs already booted");
|
|
3120
|
-
const [root] = await _XyOs.monitor(async () => await loadOsNode(wallet, fullLocator), {
|
|
3428
|
+
const [root] = await _XyOs.monitor(async () => await loadOsNode(wallet, fullLocator), {
|
|
3429
|
+
name: "Load XyOs"
|
|
3430
|
+
});
|
|
3121
3431
|
this._root = root;
|
|
3122
3432
|
this.stackManager.initialize(this);
|
|
3123
3433
|
if (this.signers) await this.signers.initialize();
|
|
@@ -3149,25 +3459,30 @@ var XyOs = class _XyOs extends XyOsContextBase {
|
|
|
3149
3459
|
// src/classes/cache/RunningDappCache.ts
|
|
3150
3460
|
var findOrCreateMutex = new Mutex3();
|
|
3151
3461
|
var RunningDappCache = class _RunningDappCache {
|
|
3462
|
+
static {
|
|
3463
|
+
__name(this, "RunningDappCache");
|
|
3464
|
+
}
|
|
3152
3465
|
static _cache = {};
|
|
3153
3466
|
static async findOrCreate(dapp, xyOs, allowedNames, xnsNodeUrl, xnsNetwork) {
|
|
3154
3467
|
const dappId = dapp.config.name;
|
|
3155
|
-
return await XyOs.monitor(
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3468
|
+
return await XyOs.monitor(async () => await findOrCreateMutex.runExclusive(async () => {
|
|
3469
|
+
const existingWindowDappSet = _RunningDappCache.get(dappId);
|
|
3470
|
+
if (existingWindowDappSet) {
|
|
3471
|
+
console.debug("[DEBUG]", `RunningDappCache, using existing node for ${dappId}`);
|
|
3472
|
+
const existingDappContext = assertEx24(existingWindowDappSet.context, () => "No context found in existing dapp node");
|
|
3473
|
+
await DappContextCreator.primeDappArchivist(existingDappContext, xyOs, dappId);
|
|
3474
|
+
return existingWindowDappSet;
|
|
3475
|
+
}
|
|
3476
|
+
console.debug("[DEBUG]", "RunningDappCache:creating", dappId);
|
|
3477
|
+
const windowDappSet = await createDappContext(dapp, xyOs, allowedNames, xnsNodeUrl, xnsNetwork);
|
|
3478
|
+
_RunningDappCache.set(dappId, windowDappSet);
|
|
3479
|
+
return windowDappSet;
|
|
3480
|
+
}), {
|
|
3481
|
+
additionalProperties: {
|
|
3482
|
+
dappId
|
|
3483
|
+
},
|
|
3484
|
+
name: "Loading dApp"
|
|
3485
|
+
});
|
|
3171
3486
|
}
|
|
3172
3487
|
static get(key) {
|
|
3173
3488
|
return this._cache[key];
|
|
@@ -3182,6 +3497,12 @@ var RunningDappCache = class _RunningDappCache {
|
|
|
3182
3497
|
|
|
3183
3498
|
// src/access-interfaces/registered-names/helpers/AccessNodeQueries.ts
|
|
3184
3499
|
var AccessNodeQueries = class {
|
|
3500
|
+
static {
|
|
3501
|
+
__name(this, "AccessNodeQueries");
|
|
3502
|
+
}
|
|
3503
|
+
xyOsContext;
|
|
3504
|
+
accessRequest;
|
|
3505
|
+
registeredDappAccess;
|
|
3185
3506
|
constructor(xyOsContext, accessRequest, registeredDappAccess) {
|
|
3186
3507
|
this.xyOsContext = xyOsContext;
|
|
3187
3508
|
this.accessRequest = accessRequest;
|
|
@@ -3218,10 +3539,7 @@ var AccessNodeQueries = class {
|
|
|
3218
3539
|
await archivist.insert(payloads);
|
|
3219
3540
|
}
|
|
3220
3541
|
async resolveArchivistFromAccessNode() {
|
|
3221
|
-
const archivist = assertEx25(
|
|
3222
|
-
await this.nameServiceNamesAccessNode.resolve("PublicXnsArchivist"),
|
|
3223
|
-
() => "Unable to find archivist at PublicXnsArchivist"
|
|
3224
|
-
);
|
|
3542
|
+
const archivist = assertEx25(await this.nameServiceNamesAccessNode.resolve("PublicXnsArchivist"), () => "Unable to find archivist at PublicXnsArchivist");
|
|
3225
3543
|
return asArchivistInstance7(archivist, () => "PublicXnsArchivist is not an archivist");
|
|
3226
3544
|
}
|
|
3227
3545
|
};
|
|
@@ -3234,28 +3552,32 @@ var XnsArchivistPayloadDivinerModuleName = "XnsArchivistPayloadDiviner";
|
|
|
3234
3552
|
var XnsArchivistModuleName = "XnsArchivist";
|
|
3235
3553
|
var XnsRegistrationsArchivistModuleName = "XnsRegistrationsArchivist";
|
|
3236
3554
|
var AbstractXnsCaller = class {
|
|
3555
|
+
static {
|
|
3556
|
+
__name(this, "AbstractXnsCaller");
|
|
3557
|
+
}
|
|
3558
|
+
context;
|
|
3237
3559
|
constructor(context) {
|
|
3238
3560
|
this.context = context;
|
|
3239
3561
|
}
|
|
3240
3562
|
/**
|
|
3241
|
-
|
|
3242
|
-
|
|
3563
|
+
* Get the XnsArchivist
|
|
3564
|
+
*/
|
|
3243
3565
|
async getXnsArchivist(pathPrefix) {
|
|
3244
3566
|
const fullyQualifiedPath = pathPrefix ? `${pathPrefix}:${XnsArchivistModuleName}` : XnsArchivistModuleName;
|
|
3245
3567
|
const mod = assertEx26(await this.context.root.resolve(fullyQualifiedPath), () => `${fullyQualifiedPath} not found`);
|
|
3246
3568
|
return asArchivistInstance8(mod, () => `${fullyQualifiedPath} is not an archivist`);
|
|
3247
3569
|
}
|
|
3248
3570
|
/**
|
|
3249
|
-
|
|
3250
|
-
|
|
3571
|
+
* Get the XnsArchivistPayloadDiviner
|
|
3572
|
+
*/
|
|
3251
3573
|
async getXnsArchivistPayloadDiviner(pathPrefix) {
|
|
3252
3574
|
const fullyQualifiedPath = pathPrefix ? `${pathPrefix}:${XnsArchivistPayloadDivinerModuleName}` : XnsArchivistPayloadDivinerModuleName;
|
|
3253
3575
|
const mod = assertEx26(await this.context.root.resolve(fullyQualifiedPath), () => `${fullyQualifiedPath} not found`);
|
|
3254
3576
|
return asDivinerInstance5(mod, () => `${fullyQualifiedPath} is not an diviner`);
|
|
3255
3577
|
}
|
|
3256
3578
|
/**
|
|
3257
|
-
|
|
3258
|
-
|
|
3579
|
+
* Get the XnsRegistrationsArchivist
|
|
3580
|
+
*/
|
|
3259
3581
|
async getXnsRegistrationsArchivist(pathPrefix) {
|
|
3260
3582
|
const fullyQualifiedPath = pathPrefix ? `${pathPrefix}:${XnsRegistrationsArchivistModuleName}` : XnsRegistrationsArchivistModuleName;
|
|
3261
3583
|
const mod = assertEx26(await this.context.root.resolve(fullyQualifiedPath), () => `${fullyQualifiedPath} not found`);
|
|
@@ -3271,35 +3593,46 @@ import { isTemporalIndexingDivinerResultIndex } from "@xyo-network/diviner-tempo
|
|
|
3271
3593
|
import { PayloadDivinerQuerySchema as PayloadDivinerQuerySchema11 } from "@xyo-network/diviner-payload-model";
|
|
3272
3594
|
import { TemporalIndexingDivinerResultIndexSchema } from "@xyo-network/diviner-temporal-indexing-model";
|
|
3273
3595
|
var XnsRegistrationsResourceQueries = {
|
|
3274
|
-
getAllRegistrations: async (diviner) => {
|
|
3596
|
+
getAllRegistrations: /* @__PURE__ */ __name(async (diviner) => {
|
|
3275
3597
|
const query = {
|
|
3276
3598
|
limit: 100,
|
|
3277
3599
|
order: "desc",
|
|
3278
3600
|
schema: PayloadDivinerQuerySchema11,
|
|
3279
|
-
schemas: [
|
|
3601
|
+
schemas: [
|
|
3602
|
+
TemporalIndexingDivinerResultIndexSchema
|
|
3603
|
+
]
|
|
3280
3604
|
};
|
|
3281
|
-
return await diviner.divine([
|
|
3282
|
-
|
|
3283
|
-
|
|
3605
|
+
return await diviner.divine([
|
|
3606
|
+
query
|
|
3607
|
+
]);
|
|
3608
|
+
}, "getAllRegistrations"),
|
|
3609
|
+
getRecentRegistrations: /* @__PURE__ */ __name(async (archivist) => {
|
|
3284
3610
|
return (await archivist.all()).reverse();
|
|
3285
|
-
}
|
|
3611
|
+
}, "getRecentRegistrations")
|
|
3286
3612
|
};
|
|
3287
3613
|
|
|
3288
3614
|
// src/access-interfaces/registered-names/helpers/resource/RegistrationsResource.ts
|
|
3289
3615
|
var XnsRegistrationsResource = class extends AbstractXnsCaller {
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
this.pathPrefix = pathPrefix;
|
|
3616
|
+
static {
|
|
3617
|
+
__name(this, "XnsRegistrationsResource");
|
|
3293
3618
|
}
|
|
3619
|
+
pathPrefix;
|
|
3294
3620
|
_allRegistrations;
|
|
3621
|
+
constructor(context, pathPrefix) {
|
|
3622
|
+
super(context), this.pathPrefix = pathPrefix;
|
|
3623
|
+
}
|
|
3295
3624
|
get allRegistrations() {
|
|
3296
3625
|
return assertEx27(this._allRegistrations);
|
|
3297
3626
|
}
|
|
3298
3627
|
get subscriptions() {
|
|
3299
|
-
return {
|
|
3628
|
+
return {
|
|
3629
|
+
allRegistrations: /* @__PURE__ */ __name((cb) => this.allRegistrations.subscribe(cb), "allRegistrations")
|
|
3630
|
+
};
|
|
3300
3631
|
}
|
|
3301
3632
|
get views() {
|
|
3302
|
-
return {
|
|
3633
|
+
return {
|
|
3634
|
+
allRegistrations: /* @__PURE__ */ __name(() => this.allRegistrations.getSnapshot(), "allRegistrations")
|
|
3635
|
+
};
|
|
3303
3636
|
}
|
|
3304
3637
|
cleanupListeners() {
|
|
3305
3638
|
this.allRegistrations.cleanupListeners();
|
|
@@ -3309,7 +3642,7 @@ var XnsRegistrationsResource = class extends AbstractXnsCaller {
|
|
|
3309
3642
|
const xnsArchivist = await this.getXnsArchivist(this.pathPrefix);
|
|
3310
3643
|
this._allRegistrations = await PayloadStore.create({
|
|
3311
3644
|
archivist: xnsArchivist,
|
|
3312
|
-
getLatest: async () => await XnsRegistrationsResourceQueries.getAllRegistrations(xnsArchivistPayloadDiviner),
|
|
3645
|
+
getLatest: /* @__PURE__ */ __name(async () => await XnsRegistrationsResourceQueries.getAllRegistrations(xnsArchivistPayloadDiviner), "getLatest"),
|
|
3313
3646
|
idFunction: isTemporalIndexingDivinerResultIndex
|
|
3314
3647
|
});
|
|
3315
3648
|
}
|
|
@@ -3317,15 +3650,24 @@ var XnsRegistrationsResource = class extends AbstractXnsCaller {
|
|
|
3317
3650
|
|
|
3318
3651
|
// src/access-interfaces/ValidDappAccessInterfaces.ts
|
|
3319
3652
|
import { RegisteredNames, RegisteredNamesInterface } from "@xyo-network/os-model";
|
|
3320
|
-
var ValidDappAccessInterfaces = {
|
|
3653
|
+
var ValidDappAccessInterfaces = {
|
|
3654
|
+
[RegisteredNames]: RegisteredNamesInterface
|
|
3655
|
+
};
|
|
3321
3656
|
|
|
3322
3657
|
// src/helpers/monitor/XyOsMonitor.ts
|
|
3323
3658
|
var DEFAULT_MONITORING_EVENT_NAME = "System Task Duration";
|
|
3324
3659
|
globalThis.getXyOsGlobal = globalThis.getXyOsGlobal ?? (() => {
|
|
3325
|
-
return {
|
|
3660
|
+
return {
|
|
3661
|
+
tracking: {
|
|
3662
|
+
trackEvent: /* @__PURE__ */ __name((_event, _properties) => void 0, "trackEvent")
|
|
3663
|
+
}
|
|
3664
|
+
};
|
|
3326
3665
|
});
|
|
3327
3666
|
var xyOsGlobal = globalThis.getXyOsGlobal();
|
|
3328
3667
|
var XyOsMonitor = class _XyOsMonitor {
|
|
3668
|
+
static {
|
|
3669
|
+
__name(this, "XyOsMonitor");
|
|
3670
|
+
}
|
|
3329
3671
|
static trackEvent = xyOsGlobal.tracking.trackEvent;
|
|
3330
3672
|
performanceTimers = /* @__PURE__ */ new Map();
|
|
3331
3673
|
startTimer(name) {
|
|
@@ -3352,21 +3694,24 @@ var XyOsMonitor = class _XyOsMonitor {
|
|
|
3352
3694
|
};
|
|
3353
3695
|
|
|
3354
3696
|
// src/profileModuleEvents.ts
|
|
3355
|
-
import { PayloadBuilder as
|
|
3697
|
+
import { PayloadBuilder as PayloadBuilder9 } from "@xyo-network/payload-builder";
|
|
3356
3698
|
var DISPLAY_EVENT_COUNT_FREQUENCY = 100;
|
|
3357
3699
|
var profileData = {};
|
|
3358
|
-
var profileModuleEvents = (mod) => {
|
|
3700
|
+
var profileModuleEvents = /* @__PURE__ */ __name((mod) => {
|
|
3359
3701
|
const modRef = new WeakRef(mod);
|
|
3360
3702
|
mod.onAny(async (eventName, args) => {
|
|
3361
3703
|
const mod2 = modRef.deref();
|
|
3362
3704
|
if (mod2) {
|
|
3363
|
-
const data = profileData[mod2.address] ?? {
|
|
3705
|
+
const data = profileData[mod2.address] ?? {
|
|
3706
|
+
allEventCount: 0,
|
|
3707
|
+
eventCounts: {}
|
|
3708
|
+
};
|
|
3364
3709
|
profileData[mod2.address] = data;
|
|
3365
3710
|
data.allEventCount += 1;
|
|
3366
3711
|
data.eventCounts[eventName] = (data.eventCounts[eventName] ?? 0) + 1;
|
|
3367
3712
|
if (eventName === "querySendStarted") {
|
|
3368
3713
|
const { query, payloads = [] } = args;
|
|
3369
|
-
const pairs = await
|
|
3714
|
+
const pairs = await PayloadBuilder9.dataHashPairs(payloads);
|
|
3370
3715
|
const foundPair = pairs.find(([, hash]) => hash === query.query);
|
|
3371
3716
|
if (foundPair) {
|
|
3372
3717
|
const [payload] = foundPair;
|
|
@@ -3383,13 +3728,17 @@ var profileModuleEvents = (mod) => {
|
|
|
3383
3728
|
}
|
|
3384
3729
|
}
|
|
3385
3730
|
});
|
|
3386
|
-
};
|
|
3731
|
+
}, "profileModuleEvents");
|
|
3387
3732
|
|
|
3388
3733
|
// src/PubSubBridgeCaller.ts
|
|
3389
3734
|
import { assertEx as assertEx28 } from "@xylabs/assert";
|
|
3390
3735
|
import { asBridgeInstance } from "@xyo-network/bridge-model";
|
|
3391
3736
|
import { BridgedPubSubModuleName } from "@xyo-network/os-model";
|
|
3392
3737
|
var PubSubBridgeCaller = class {
|
|
3738
|
+
static {
|
|
3739
|
+
__name(this, "PubSubBridgeCaller");
|
|
3740
|
+
}
|
|
3741
|
+
node;
|
|
3393
3742
|
constructor(node) {
|
|
3394
3743
|
this.node = node;
|
|
3395
3744
|
}
|