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