@xyo-network/os-runtime 7.2.0 → 7.3.0
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 +2 -2
- package/dist/neutral/DappCallerBase.d.ts.map +1 -1
- package/dist/neutral/OsCallerBase.d.ts +2 -2
- package/dist/neutral/PubSubBridgeCaller.d.ts +1 -1
- package/dist/neutral/PubSubBridgeCaller.d.ts.map +1 -1
- package/dist/neutral/RunningDappCache.d.ts.map +1 -1
- package/dist/neutral/XyOs.d.ts +5 -6
- package/dist/neutral/XyOs.d.ts.map +1 -1
- package/dist/neutral/XyOsBase.d.ts +124 -7
- package/dist/neutral/XyOsBase.d.ts.map +1 -1
- package/dist/neutral/XyOsDapp.d.ts +3 -3
- package/dist/neutral/XyOsDapp.d.ts.map +1 -1
- package/dist/neutral/access/Caller.d.ts +2 -2
- package/dist/neutral/access/Caller.d.ts.map +1 -1
- package/dist/neutral/access/RunningAccessDappCache.d.ts.map +1 -1
- package/dist/neutral/access/interfaces/registered-names/helpers/resource/AbstractXnsCaller.d.ts +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/lib/DappCreatorParams.d.ts +3 -3
- package/dist/neutral/classes/lib/DappCreatorParams.d.ts.map +1 -1
- package/dist/neutral/classes/lib/Insertable.d.ts +1 -3
- package/dist/neutral/classes/lib/Insertable.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/CallerBase.d.ts +1 -1
- package/dist/neutral/classes/settings/SettingsQueries.d.ts.map +1 -1
- 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/dapp/context/creator/Creator.d.ts +1 -1
- package/dist/neutral/dapp/context/creator/Creator.d.ts.map +1 -1
- package/dist/neutral/dapp/context/creator/createDappContext.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 +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/XyOsMonitor.d.ts +2 -2
- package/dist/neutral/helpers/monitor/XyOsMonitor.d.ts.map +1 -1
- package/dist/neutral/helpers/monitor/types.d.ts +3 -3
- package/dist/neutral/helpers/monitor/types.d.ts.map +1 -1
- package/dist/neutral/index.mjs +1042 -694
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/neutral/intent/Caller.d.ts +5 -5
- package/dist/neutral/lib/Listener.d.ts +1 -1
- package/dist/neutral/lib/Listener.d.ts.map +1 -1
- 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/loadOsNode.d.ts.map +1 -1
- package/dist/neutral/profileModuleEvents.d.ts +2 -4
- package/dist/neutral/profileModuleEvents.d.ts.map +1 -1
- package/dist/neutral/registration/DappRegistrationService.d.ts +3 -3
- 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 +7 -3
- 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/scripts/xyos/lib/headless.d.ts.map +1 -1
- package/dist/neutral/signer/Signers.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/stack/Manager.d.ts +2 -6
- package/dist/neutral/stack/Manager.d.ts.map +1 -1
- package/dist/neutral/system/ManageSystemDapps.d.ts +3 -3
- package/dist/neutral/system/ManageSystemDapps.d.ts.map +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 +2 -2
- package/dist/node/DappCallerBase.d.ts.map +1 -1
- package/dist/node/OsCallerBase.d.ts +2 -2
- package/dist/node/PubSubBridgeCaller.d.ts +1 -1
- package/dist/node/PubSubBridgeCaller.d.ts.map +1 -1
- package/dist/node/RunningDappCache.d.ts.map +1 -1
- package/dist/node/XyOs.d.ts +5 -6
- package/dist/node/XyOs.d.ts.map +1 -1
- package/dist/node/XyOsBase.d.ts +124 -7
- package/dist/node/XyOsBase.d.ts.map +1 -1
- package/dist/node/XyOsDapp.d.ts +3 -3
- package/dist/node/XyOsDapp.d.ts.map +1 -1
- package/dist/node/access/Caller.d.ts +2 -2
- package/dist/node/access/Caller.d.ts.map +1 -1
- package/dist/node/access/RunningAccessDappCache.d.ts.map +1 -1
- package/dist/node/access/interfaces/registered-names/helpers/resource/AbstractXnsCaller.d.ts +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/lib/DappCreatorParams.d.ts +3 -3
- package/dist/node/classes/lib/DappCreatorParams.d.ts.map +1 -1
- package/dist/node/classes/lib/Insertable.d.ts +1 -3
- package/dist/node/classes/lib/Insertable.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/CallerBase.d.ts +1 -1
- package/dist/node/classes/settings/SettingsQueries.d.ts.map +1 -1
- 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/dapp/context/creator/Creator.d.ts +1 -1
- package/dist/node/dapp/context/creator/Creator.d.ts.map +1 -1
- package/dist/node/dapp/context/creator/createDappContext.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 +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/XyOsMonitor.d.ts +2 -2
- package/dist/node/helpers/monitor/XyOsMonitor.d.ts.map +1 -1
- package/dist/node/helpers/monitor/types.d.ts +3 -3
- package/dist/node/helpers/monitor/types.d.ts.map +1 -1
- package/dist/node/index.mjs +1042 -694
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/intent/Caller.d.ts +5 -5
- package/dist/node/lib/Listener.d.ts +1 -1
- package/dist/node/lib/Listener.d.ts.map +1 -1
- 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/loadOsNode.d.ts.map +1 -1
- package/dist/node/profileModuleEvents.d.ts +2 -4
- package/dist/node/profileModuleEvents.d.ts.map +1 -1
- package/dist/node/registration/DappRegistrationService.d.ts +3 -3
- 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 +7 -3
- 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 +520 -384
- package/dist/node/scripts/xyos/index.mjs.map +1 -1
- package/dist/node/scripts/xyos/lib/headless.d.ts.map +1 -1
- package/dist/node/signer/Signers.d.ts.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/stack/Manager.d.ts +2 -6
- package/dist/node/stack/Manager.d.ts.map +1 -1
- package/dist/node/system/ManageSystemDapps.d.ts +3 -3
- package/dist/node/system/ManageSystemDapps.d.ts.map +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 +165 -55
- package/dist/neutral/signer/Signer.spec.d.ts +0 -2
- package/dist/neutral/signer/Signer.spec.d.ts.map +0 -1
- package/dist/neutral/spec/boot.spec.d.ts +0 -2
- package/dist/neutral/spec/boot.spec.d.ts.map +0 -1
- package/dist/node/signer/Signer.spec.d.ts +0 -2
- package/dist/node/signer/Signer.spec.d.ts.map +0 -1
- package/dist/node/spec/boot.spec.d.ts +0 -2
- package/dist/node/spec/boot.spec.d.ts.map +0 -1
- package/src/Caller.ts +0 -202
- package/src/DappCallerBase.ts +0 -56
- package/src/DefaultsQueries.ts +0 -27
- package/src/OsCallerBase.ts +0 -59
- package/src/PubSubBridgeCaller.ts +0 -33
- package/src/RunningDappCache.ts +0 -58
- package/src/XyOs.ts +0 -166
- package/src/XyOsBase.ts +0 -136
- package/src/XyOsDapp.ts +0 -103
- package/src/access/Caller.ts +0 -85
- package/src/access/Queries.ts +0 -38
- package/src/access/Resource.ts +0 -65
- package/src/access/RunningAccessDappCache.ts +0 -21
- package/src/access/index.ts +0 -4
- package/src/access/interfaces/index.ts +0 -1
- package/src/access/interfaces/registered-names/helpers/AccessNodeQueries.ts +0 -68
- package/src/access/interfaces/registered-names/helpers/index.ts +0 -2
- package/src/access/interfaces/registered-names/helpers/resource/AbstractXnsCaller.ts +0 -42
- package/src/access/interfaces/registered-names/helpers/resource/RegistrationsResource.ts +0 -52
- package/src/access/interfaces/registered-names/helpers/resource/RegistrationsResourceQueries.ts +0 -23
- package/src/access/interfaces/registered-names/helpers/resource/index.ts +0 -3
- package/src/access/interfaces/registered-names/index.ts +0 -1
- package/src/adapter/Base.ts +0 -104
- package/src/adapter/Network.ts +0 -31
- package/src/adapter/Settings.ts +0 -30
- package/src/adapter/index.ts +0 -2
- package/src/adapters/OsPubSubBridgeNetwork.ts +0 -10
- package/src/adapters/OsSettings.ts +0 -7
- package/src/adapters/OsXyoPublicNetwork.ts +0 -9
- package/src/adapters/index.ts +0 -3
- package/src/classes/dapp/DefaultsResource.ts +0 -67
- package/src/classes/dapp/index.ts +0 -1
- package/src/classes/index.ts +0 -4
- package/src/classes/lib/DappCreatorParams.ts +0 -18
- package/src/classes/lib/Insertable.ts +0 -10
- package/src/classes/lib/index.ts +0 -2
- package/src/classes/menu/Caller.ts +0 -77
- package/src/classes/menu/Queries.ts +0 -60
- package/src/classes/menu/Resource.ts +0 -105
- package/src/classes/menu/index.ts +0 -2
- package/src/classes/settings/Caller.ts +0 -78
- package/src/classes/settings/CallerBase.ts +0 -27
- package/src/classes/settings/Resource.ts +0 -81
- package/src/classes/settings/SettingsQueries.ts +0 -56
- package/src/classes/settings/badge/Caller.ts +0 -30
- package/src/classes/settings/badge/Queries.ts +0 -19
- package/src/classes/settings/badge/Resource.ts +0 -50
- package/src/classes/settings/badge/index.ts +0 -2
- package/src/classes/settings/index.ts +0 -5
- package/src/dapp/context/creator/Creator.ts +0 -122
- package/src/dapp/context/creator/DefaultPayloads/DappAccessPayloads.ts +0 -20
- package/src/dapp/context/creator/DefaultPayloads/DefaultPayloads.ts +0 -40
- package/src/dapp/context/creator/DefaultPayloads/NodeInfoPayload.ts +0 -33
- package/src/dapp/context/creator/DefaultPayloads/index.ts +0 -1
- package/src/dapp/context/creator/ExternalModulePermissions/ExternalModulePermissions.ts +0 -59
- package/src/dapp/context/creator/ExternalModulePermissions/index.ts +0 -1
- package/src/dapp/context/creator/createDappContext.ts +0 -61
- package/src/dapp/context/creator/index.ts +0 -3
- package/src/dapp/context/index.ts +0 -1
- package/src/dapp/index.ts +0 -1
- package/src/event/bus/Connection.ts +0 -33
- package/src/event/bus/EventBus.ts +0 -159
- package/src/event/bus/PubSubConnection.ts +0 -28
- package/src/event/bus/index.ts +0 -3
- package/src/event/connections/DappAccessRequest.ts +0 -11
- package/src/event/connections/DappsReady.ts +0 -9
- package/src/event/connections/ExposeDappRequest.ts +0 -11
- package/src/event/connections/OsPubSubNetworkReady.ts +0 -12
- package/src/event/connections/OsSettingsReady.ts +0 -12
- package/src/event/connections/OsXyoPublicReady.ts +0 -12
- package/src/event/connections/index.ts +0 -6
- package/src/event/index.ts +0 -2
- package/src/helpers/index.ts +0 -1
- package/src/helpers/monitor/XyOsMonitor.ts +0 -52
- package/src/helpers/monitor/index.ts +0 -2
- package/src/helpers/monitor/types.ts +0 -8
- package/src/index.ts +0 -29
- package/src/initializer/DappInitializer.ts +0 -57
- package/src/initializer/index.ts +0 -1
- package/src/intent/Caller.ts +0 -74
- package/src/intent/Resource.ts +0 -66
- package/src/intent/index.ts +0 -2
- package/src/lib/ExternalStore.ts +0 -7
- package/src/lib/Listener.ts +0 -1
- package/src/lib/ModuleAccountPaths.ts +0 -23
- package/src/lib/ModuleNames.ts +0 -3
- package/src/lib/NameTransforms.ts +0 -34
- package/src/lib/PayloadStore.ts +0 -106
- package/src/lib/ResourceStores.ts +0 -7
- package/src/lib/index.ts +0 -11
- package/src/lib/initializeXns.ts +0 -16
- package/src/lib/isEqual.ts +0 -42
- package/src/lib/isPayload.ts +0 -24
- package/src/lib/tokenPlacesSplit.ts +0 -17
- package/src/loadOsNode.ts +0 -44
- package/src/manifest/index.ts +0 -2
- package/src/manifest/manifestReplacementTokens.ts +0 -6
- package/src/manifest/os-node.manifest.json +0 -132
- package/src/manifests/dapp-window.manifest.json +0 -36
- package/src/manifests/index.ts +0 -1
- package/src/models/access/ValidDappAccessInterfaces.ts +0 -6
- package/src/models/access/index.ts +0 -1
- package/src/models/index.ts +0 -1
- package/src/profileModuleEvents.ts +0 -43
- package/src/registration/DappRegistrationService.ts +0 -179
- package/src/registration/DappRegistry.ts +0 -131
- package/src/registration/ValidateDappAccessDiviner/Config.ts +0 -24
- package/src/registration/ValidateDappAccessDiviner/Diviner.ts +0 -133
- package/src/registration/ValidateDappAccessDiviner/index.ts +0 -2
- package/src/registration/index.ts +0 -2
- package/src/scripts/xyos/command/config.ts +0 -19
- package/src/scripts/xyos/command/create.ts +0 -22
- package/src/scripts/xyos/command/index.ts +0 -7
- package/src/scripts/xyos/command/manifest.ts +0 -19
- package/src/scripts/xyos/command/start.ts +0 -35
- package/src/scripts/xyos/index.ts +0 -32
- package/src/scripts/xyos/lib/createFromTemplate.ts +0 -11
- package/src/scripts/xyos/lib/headless.ts +0 -68
- package/src/scripts/xyos/lib/index.ts +0 -2
- package/src/signer/Signer.spec.ts +0 -65
- package/src/signer/Signers.ts +0 -74
- package/src/signer/index.ts +0 -1
- package/src/spec/boot.spec.ts +0 -89
- package/src/stack/Base.ts +0 -166
- package/src/stack/Manager.ts +0 -51
- package/src/stack/Map.ts +0 -22
- package/src/stack/OsPubSubNetworkStack.ts +0 -70
- package/src/stack/OsSettingsStack.ts +0 -24
- package/src/stack/XyoPublicNetworkStack.ts +0 -32
- package/src/stack/index.ts +0 -6
- package/src/system/ManageSystemDapps.ts +0 -148
- package/src/system/Queries.ts +0 -69
- package/src/system/index.ts +0 -1
- package/src/types/global.d.ts +0 -9
- package/src/types/images.d.ts +0 -5
- package/src/utils/buildWalletSeedPhrasePayload.ts +0 -51
- package/src/utils/getApiDomain.ts +0 -14
- package/src/utils/index.ts +0 -3
- package/src/utils/renameObjKey.ts +0 -22
- package/src/wallet/DappSeedPhraseRepository.ts +0 -99
- package/src/wallet/SeedPhraseRepository.ts +0 -32
- package/src/wallet/index.ts +0 -2
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { assertEx } from '@xylabs/assert'
|
|
2
|
-
import type {
|
|
3
|
-
DappInjectableParams, NodeOsInfo, XyOsContext,
|
|
4
|
-
} from '@xyo-network/os-model'
|
|
5
|
-
import { isDappInjectableParams, isNodeOsInfo } from '@xyo-network/os-model'
|
|
6
|
-
|
|
7
|
-
import { DappCallerBase } from '../../DappCallerBase.ts'
|
|
8
|
-
import { DappDefaultsResourceQueries } from '../../DefaultsQueries.ts'
|
|
9
|
-
import type { Listener, ResourceStore } from '../../lib/index.ts'
|
|
10
|
-
import { PayloadStore } from '../../lib/index.ts'
|
|
11
|
-
|
|
12
|
-
export type DappDefaultsResourceViews = 'nodeOsInfo' | 'dappInjectableParamsFromRoute'
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* A resource for interacting with Dapp Defaults
|
|
16
|
-
*/
|
|
17
|
-
export class DappDefaultsResource extends DappCallerBase implements ResourceStore<DappDefaultsResourceViews> {
|
|
18
|
-
private _dappInjectableParamsFromRouteListener: PayloadStore<DappInjectableParams> | undefined
|
|
19
|
-
private _nodeOsInfoListener: PayloadStore<NodeOsInfo> | undefined
|
|
20
|
-
|
|
21
|
-
constructor(context: XyOsContext) {
|
|
22
|
-
super(context)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
get dappInjectableParamsFromRouteListener() {
|
|
26
|
-
return assertEx(this._dappInjectableParamsFromRouteListener, () => 'DappInjectableParams not found')
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
get nodeOsInfoListener() {
|
|
30
|
-
return assertEx(this._nodeOsInfoListener, () => 'NodeOsInfo not found')
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
get subscriptions() {
|
|
34
|
-
return {
|
|
35
|
-
dappInjectableParamsFromRoute: (cb: Listener) => this.dappInjectableParamsFromRouteListener.subscribe(cb),
|
|
36
|
-
nodeOsInfo: (cb: Listener) => this.nodeOsInfoListener.subscribe(cb),
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
get views() {
|
|
41
|
-
return {
|
|
42
|
-
dappInjectableParamsFromRoute: () => this.dappInjectableParamsFromRouteListener.getSnapshot(),
|
|
43
|
-
nodeOsInfo: () => this.nodeOsInfoListener.getSnapshot(),
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
cleanupListeners() {
|
|
48
|
-
this.nodeOsInfoListener.cleanupListeners()
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
async start() {
|
|
52
|
-
const archivist = await this.getDappArchivist()
|
|
53
|
-
const diviner = await this.getDappArchivistPayloadDiviner()
|
|
54
|
-
|
|
55
|
-
this._nodeOsInfoListener = await PayloadStore.create<NodeOsInfo>({
|
|
56
|
-
archivist,
|
|
57
|
-
getLatest: async () => await DappDefaultsResourceQueries.getNodeOsInfo(diviner),
|
|
58
|
-
idFunction: isNodeOsInfo,
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
this._dappInjectableParamsFromRouteListener = await PayloadStore.create<DappInjectableParams>({
|
|
62
|
-
archivist,
|
|
63
|
-
getLatest: async () => await DappDefaultsResourceQueries.getDappInjectableParamsFromRoute(diviner),
|
|
64
|
-
idFunction: isDappInjectableParams,
|
|
65
|
-
})
|
|
66
|
-
}
|
|
67
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './DefaultsResource.ts'
|
package/src/classes/index.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { ModuleManifest } from '@xyo-network/manifest'
|
|
2
|
-
import type { ModuleFactoryLocatorInstance } from '@xyo-network/module-model'
|
|
3
|
-
import type {
|
|
4
|
-
DappName, DappPackageManifestPayload, XyOsContext,
|
|
5
|
-
} from '@xyo-network/os-model'
|
|
6
|
-
import type { WalletInstance } from '@xyo-network/wallet-model'
|
|
7
|
-
|
|
8
|
-
export type DappNodesCreatorParams = {
|
|
9
|
-
config: {
|
|
10
|
-
dappName: DappName
|
|
11
|
-
payload: DappPackageManifestPayload
|
|
12
|
-
privateChildren?: ModuleManifest[]
|
|
13
|
-
publicChildren?: ModuleManifest[]
|
|
14
|
-
}
|
|
15
|
-
context: XyOsContext
|
|
16
|
-
locator?: ModuleFactoryLocatorInstance
|
|
17
|
-
wallet: WalletInstance
|
|
18
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { DappName, XyOsContext } from '@xyo-network/os-model'
|
|
2
|
-
import type { Payload } from '@xyo-network/payload-model'
|
|
3
|
-
|
|
4
|
-
export interface InsertableConstructor { new (_xyOs: XyOsContext, dappName: DappName): DefaultPayloadsInsertable }
|
|
5
|
-
|
|
6
|
-
type InsertableConstructorParams = ConstructorParameters<InsertableConstructor>
|
|
7
|
-
|
|
8
|
-
export interface DefaultPayloadsInsertable { payloads(): Promise<Payload[]> }
|
|
9
|
-
|
|
10
|
-
export const createInsertable = (insertable: InsertableConstructor, ...params: InsertableConstructorParams) => new insertable(...params)
|
package/src/classes/lib/index.ts
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { PayloadDivinerQuerySchema } from '@xyo-network/diviner-payload-model'
|
|
2
|
-
import type {
|
|
3
|
-
DappInjectableParams,
|
|
4
|
-
DappNavItemSelection,
|
|
5
|
-
XyOsContext,
|
|
6
|
-
} from '@xyo-network/os-model'
|
|
7
|
-
import {
|
|
8
|
-
DappInjectableParamsSchema,
|
|
9
|
-
DappNavItemSelectionSchema,
|
|
10
|
-
} from '@xyo-network/os-model'
|
|
11
|
-
import { PayloadBuilder } from '@xyo-network/payload-builder'
|
|
12
|
-
import type { Payload } from '@xyo-network/payload-model'
|
|
13
|
-
|
|
14
|
-
import { DappCaller } from '../../Caller.ts'
|
|
15
|
-
|
|
16
|
-
export class DappMenuCaller extends DappCaller {
|
|
17
|
-
constructor(context: XyOsContext) {
|
|
18
|
-
super(context)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Add new Payloads to the dappArchivist if they haven't already
|
|
23
|
-
*
|
|
24
|
-
* @param {Payload[]} payloads
|
|
25
|
-
*/
|
|
26
|
-
async add(payloads: Payload[], force = false) {
|
|
27
|
-
const dappArchivist = await this.getDappArchivist()
|
|
28
|
-
|
|
29
|
-
for (const payload of payloads) {
|
|
30
|
-
const hash = await PayloadBuilder.dataHash(payload)
|
|
31
|
-
const [existing] = await dappArchivist.get([hash])
|
|
32
|
-
if (!existing || force) {
|
|
33
|
-
await dappArchivist.insert(payloads)
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
async currentNavSelection(): Promise<DappNavItemSelection[] | undefined> {
|
|
39
|
-
const diviner = await this.getDappArchivistPayloadDiviner()
|
|
40
|
-
const query = {
|
|
41
|
-
limit: 1,
|
|
42
|
-
order: 'desc',
|
|
43
|
-
schema: PayloadDivinerQuerySchema,
|
|
44
|
-
schemas: [DappNavItemSelectionSchema],
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return (await diviner.divine([query])) as DappNavItemSelection[]
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/*
|
|
51
|
-
* Indicate to the system that a nav item was selected
|
|
52
|
-
*
|
|
53
|
-
* @param {string} path
|
|
54
|
-
* @params {string} injectableParamsPath
|
|
55
|
-
* @returns Promise
|
|
56
|
-
*/
|
|
57
|
-
async makeNavItemSelection(path: string, injectableParamsPath?: string): Promise<void> {
|
|
58
|
-
const dappArchivist = await this.getDappArchivist()
|
|
59
|
-
const payload: DappNavItemSelection = {
|
|
60
|
-
path,
|
|
61
|
-
schema: DappNavItemSelectionSchema,
|
|
62
|
-
timestamp: Date.now(),
|
|
63
|
-
}
|
|
64
|
-
await dappArchivist.insert([payload])
|
|
65
|
-
|
|
66
|
-
if (injectableParamsPath) {
|
|
67
|
-
const injectableParams: DappInjectableParams = {
|
|
68
|
-
params: {},
|
|
69
|
-
path: injectableParamsPath,
|
|
70
|
-
schema: DappInjectableParamsSchema,
|
|
71
|
-
source: 'route',
|
|
72
|
-
timestamp: Date.now(),
|
|
73
|
-
}
|
|
74
|
-
await dappArchivist.insert([injectableParams])
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import type { DivinerInstance } from '@xyo-network/diviner-model'
|
|
2
|
-
import type { PayloadDivinerQueryPayload } from '@xyo-network/diviner-payload-model'
|
|
3
|
-
import { PayloadDivinerQuerySchema } from '@xyo-network/diviner-payload-model'
|
|
4
|
-
import type {
|
|
5
|
-
DappNavItem,
|
|
6
|
-
DappNavItemSelection,
|
|
7
|
-
DappNavMenuConfig,
|
|
8
|
-
} from '@xyo-network/os-model'
|
|
9
|
-
import {
|
|
10
|
-
DappNavItemSchema,
|
|
11
|
-
DappNavItemSelectionSchema,
|
|
12
|
-
DappNavMenuConfigSchema,
|
|
13
|
-
} from '@xyo-network/os-model'
|
|
14
|
-
import type { WithSources } from '@xyo-network/payload-model'
|
|
15
|
-
|
|
16
|
-
const NO_ITEMS: unknown[] = []
|
|
17
|
-
|
|
18
|
-
export const DappMenuQueries = {
|
|
19
|
-
async getMenuConfigs(diviner: DivinerInstance): Promise<WithSources<DappNavMenuConfig>[]> {
|
|
20
|
-
const query: PayloadDivinerQueryPayload = {
|
|
21
|
-
limit: 1,
|
|
22
|
-
order: 'desc',
|
|
23
|
-
schema: PayloadDivinerQuerySchema,
|
|
24
|
-
schemas: [DappNavMenuConfigSchema],
|
|
25
|
-
}
|
|
26
|
-
return (await diviner.divine([query])) as WithSources<DappNavMenuConfig>[]
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
async getMenuItems(diviner: DivinerInstance) {
|
|
30
|
-
const query: PayloadDivinerQueryPayload = {
|
|
31
|
-
order: 'desc',
|
|
32
|
-
schema: PayloadDivinerQuerySchema,
|
|
33
|
-
schemas: [DappNavItemSchema],
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const results = (await diviner.divine([query])) as WithSources<DappNavItem>[]
|
|
37
|
-
return results.length > 0 ? results : (NO_ITEMS as WithSources<DappNavItem>[])
|
|
38
|
-
},
|
|
39
|
-
|
|
40
|
-
async getNavItemSelections(diviner: DivinerInstance) {
|
|
41
|
-
const query: PayloadDivinerQueryPayload = {
|
|
42
|
-
limit: 1,
|
|
43
|
-
order: 'desc',
|
|
44
|
-
schema: PayloadDivinerQuerySchema,
|
|
45
|
-
schemas: [DappNavItemSelectionSchema],
|
|
46
|
-
}
|
|
47
|
-
const results = (await diviner.divine([query])) as WithSources<DappNavItemSelection>[]
|
|
48
|
-
return results.length > 0 ? results : (NO_ITEMS as WithSources<DappNavItemSelection>[])
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
async getVisibleMenuItems(diviner: DivinerInstance) {
|
|
52
|
-
const query: PayloadDivinerQueryPayload = {
|
|
53
|
-
order: 'desc',
|
|
54
|
-
schema: PayloadDivinerQuerySchema,
|
|
55
|
-
schemas: [DappNavItemSchema],
|
|
56
|
-
}
|
|
57
|
-
const results = (await diviner.divine([query])) as WithSources<DappNavItem>[]
|
|
58
|
-
return results.filter(menuItem => menuItem.hidden !== true).toSorted((a, b) => ((a.weight ?? 0) > (b.weight ?? 0) ? 1 : -1))
|
|
59
|
-
},
|
|
60
|
-
}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { assertEx } from '@xylabs/assert'
|
|
2
|
-
import type {
|
|
3
|
-
DappNavItem, DappNavItemSelection, DappNavMenuConfig, XyOsContext,
|
|
4
|
-
} from '@xyo-network/os-model'
|
|
5
|
-
import { isDappNavItemSelection, isDappNavMenuConfig } from '@xyo-network/os-model'
|
|
6
|
-
import type { Payload, WithSources } from '@xyo-network/payload-model'
|
|
7
|
-
|
|
8
|
-
import { DappCaller } from '../../Caller.ts'
|
|
9
|
-
import type { Listener, ResourceStore } from '../../lib/index.ts'
|
|
10
|
-
import { PayloadStore } from '../../lib/index.ts'
|
|
11
|
-
import { DappMenuQueries } from './Queries.ts'
|
|
12
|
-
|
|
13
|
-
export type DappMenuResourceViews = 'menuConfigs' | 'menuItems' | 'menuItemsVisible' | 'menuItemSelections'
|
|
14
|
-
|
|
15
|
-
export type NavPayloadType<T extends Payload = Payload> = WithSources<T>[]
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* A Repository for interacting with dapp menu items and config
|
|
19
|
-
*/
|
|
20
|
-
export class DappMenuResource extends DappCaller implements ResourceStore<DappMenuResourceViews> {
|
|
21
|
-
private _menuConfigListener: PayloadStore<DappNavMenuConfig> | undefined
|
|
22
|
-
private _menuItemListener: PayloadStore<DappNavItem> | undefined
|
|
23
|
-
private _menuItemSelectionListener: PayloadStore<DappNavItemSelection> | undefined
|
|
24
|
-
private _menuItemVisibleListener: PayloadStore<DappNavItem> | undefined
|
|
25
|
-
|
|
26
|
-
constructor(xyOsContext: XyOsContext) {
|
|
27
|
-
super(xyOsContext)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
get menuConfigListener() {
|
|
31
|
-
return assertEx(this._menuConfigListener, () => 'menuConfigListener note found')
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
get menuItemListener() {
|
|
35
|
-
return assertEx(this._menuItemListener, () => 'menuItemListener note found')
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
get menuItemSelectionListener() {
|
|
39
|
-
return assertEx(this._menuItemSelectionListener, () => 'menuItemSelectionListener note found')
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
get menuItemVisibleListener() {
|
|
43
|
-
return assertEx(this._menuItemVisibleListener, () => 'menuItemVisibleListener note found')
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/** subscribe to latest set of payloads */
|
|
47
|
-
get subscriptions() {
|
|
48
|
-
return {
|
|
49
|
-
menuConfigs: (cb: Listener) => this.menuConfigListener.subscribe(cb),
|
|
50
|
-
menuItemSelections: (cb: Listener) => this.menuItemSelectionListener.subscribe(cb),
|
|
51
|
-
menuItems: (cb: Listener) => this.menuItemListener.subscribe(cb),
|
|
52
|
-
menuItemsVisible: (cb: Listener) => this.menuItemVisibleListener.subscribe(cb),
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Return the latest menu payloads from the repository
|
|
58
|
-
*/
|
|
59
|
-
get views() {
|
|
60
|
-
return {
|
|
61
|
-
menuConfigs: () => this.menuConfigListener.getSnapshot(),
|
|
62
|
-
menuItemSelections: () => this.menuItemSelectionListener.getSnapshot(),
|
|
63
|
-
menuItems: () => this.menuItemListener.getSnapshot(),
|
|
64
|
-
menuItemsVisible: () => this.menuItemVisibleListener.getSnapshot(),
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Remove all listeners and reset their class members
|
|
70
|
-
*/
|
|
71
|
-
cleanupListeners() {
|
|
72
|
-
this.menuConfigListener.cleanupListeners()
|
|
73
|
-
this.menuItemListener.cleanupListeners()
|
|
74
|
-
this.menuItemSelectionListener.cleanupListeners()
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Start the resource
|
|
79
|
-
*/
|
|
80
|
-
async start(): Promise<void> {
|
|
81
|
-
const dappArchivist = await this.getDappArchivist()
|
|
82
|
-
const dappArchivistPayloadDiviner = await this.getDappArchivistPayloadDiviner()
|
|
83
|
-
|
|
84
|
-
this._menuConfigListener = await PayloadStore.create<DappNavMenuConfig>({
|
|
85
|
-
archivist: dappArchivist,
|
|
86
|
-
getLatest: async () => await DappMenuQueries.getMenuConfigs(dappArchivistPayloadDiviner),
|
|
87
|
-
idFunction: isDappNavMenuConfig,
|
|
88
|
-
})
|
|
89
|
-
this._menuItemListener = await PayloadStore.create<DappNavItem>({
|
|
90
|
-
archivist: dappArchivist,
|
|
91
|
-
getLatest: async () => await DappMenuQueries.getMenuItems(dappArchivistPayloadDiviner),
|
|
92
|
-
idFunction: isDappNavMenuConfig,
|
|
93
|
-
})
|
|
94
|
-
this._menuItemVisibleListener = await PayloadStore.create<DappNavItem>({
|
|
95
|
-
archivist: dappArchivist,
|
|
96
|
-
getLatest: async () => await DappMenuQueries.getVisibleMenuItems(dappArchivistPayloadDiviner),
|
|
97
|
-
idFunction: isDappNavMenuConfig,
|
|
98
|
-
})
|
|
99
|
-
this._menuItemSelectionListener = await PayloadStore.create<DappNavItemSelection>({
|
|
100
|
-
archivist: dappArchivist,
|
|
101
|
-
getLatest: async () => await DappMenuQueries.getNavItemSelections(dappArchivistPayloadDiviner),
|
|
102
|
-
idFunction: isDappNavItemSelection,
|
|
103
|
-
})
|
|
104
|
-
}
|
|
105
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { assertEx } from '@xylabs/assert'
|
|
2
|
-
import type {
|
|
3
|
-
NodeBackground, WalletSeedPhrase, XyOsContext,
|
|
4
|
-
} from '@xyo-network/os-model'
|
|
5
|
-
|
|
6
|
-
import { isEqual } from '../../lib/index.ts'
|
|
7
|
-
import { buildUserWalletSeedPhrasePayload } from '../../utils/index.ts'
|
|
8
|
-
import { OsSettingsCallerBase } from './CallerBase.ts'
|
|
9
|
-
import { OsSettingsQueries } from './SettingsQueries.ts'
|
|
10
|
-
|
|
11
|
-
export class OsSettingsCaller extends OsSettingsCallerBase {
|
|
12
|
-
constructor(context: XyOsContext) {
|
|
13
|
-
super(context)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Add a node background to the settings
|
|
18
|
-
* @param {NodeBackground} payload
|
|
19
|
-
*/
|
|
20
|
-
async addNodeBackground(payload: NodeBackground) {
|
|
21
|
-
const archivist = await this.getOsSettingsArchivist()
|
|
22
|
-
await archivist.insert([payload])
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Add a wallet seed phrase to the settings
|
|
27
|
-
* @param {WalletSeedPhrase} payload
|
|
28
|
-
*/
|
|
29
|
-
async addWalletSeedPhrase(payload: WalletSeedPhrase) {
|
|
30
|
-
// NOTE: Since setting the seed phrase in OS takes precedence
|
|
31
|
-
// over the BIOS when the two phrases differ, we'll set the seed
|
|
32
|
-
// phrase in the OS first. That way if the latter saves fail we can
|
|
33
|
-
// still recover on next boot.
|
|
34
|
-
|
|
35
|
-
// Save seed phrase to OS settings
|
|
36
|
-
const archivist = await this.getOsSettingsArchivist()
|
|
37
|
-
await archivist.insert([payload])
|
|
38
|
-
|
|
39
|
-
// Save seed phrase to BIOS
|
|
40
|
-
const phrase = payload.mnemonic.mnemonic.join(' ')
|
|
41
|
-
await this.context.kernel?.bios?.seedPhraseStore.set('user', phrase)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Get the latest node background
|
|
46
|
-
*/
|
|
47
|
-
async getLatestNodeBackground(): Promise<NodeBackground | null> {
|
|
48
|
-
const diviner = await this.getOsSettingsPayloadDiviner()
|
|
49
|
-
const [result] = (await OsSettingsQueries.getNodeBackground(diviner)) as NodeBackground[]
|
|
50
|
-
return result ?? null
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
async getLatestUserWallet(): Promise<WalletSeedPhrase> {
|
|
54
|
-
// Get the seed phrase from the OS settings
|
|
55
|
-
const diviner = await this.getOsSettingsPayloadDiviner()
|
|
56
|
-
const archivist = await this.getOsSettingsArchivist()
|
|
57
|
-
const storedSeedPhrasePayload = (await OsSettingsQueries.getLatestUserWallet(diviner, archivist)).pop()
|
|
58
|
-
// Get the seed phrase from the BIOS
|
|
59
|
-
const biosWalletSeedPhrase = assertEx(await this.context.kernel?.bios?.seedPhraseStore.get('user'), () => 'No user seed phrase found from BIOS')
|
|
60
|
-
const biosWalletSeedPhraseParts = biosWalletSeedPhrase.split(' ')
|
|
61
|
-
// If there is no stored seed phrase in the OS, use the seed phrase from the BIOS
|
|
62
|
-
if (!storedSeedPhrasePayload?.mnemonic?.mnemonic) {
|
|
63
|
-
// Create new wallet payload from BIOS seed phrase
|
|
64
|
-
const { payload: biosSeedPhrasePayload } = await buildUserWalletSeedPhrasePayload(biosWalletSeedPhrase)
|
|
65
|
-
// Store the BIOS seed phrase in the OS settings
|
|
66
|
-
await this.addWalletSeedPhrase(biosSeedPhrasePayload)
|
|
67
|
-
// Return BIOS seed phrase payload
|
|
68
|
-
return biosSeedPhrasePayload
|
|
69
|
-
} else if (!isEqual(storedSeedPhrasePayload.mnemonic.mnemonic, biosWalletSeedPhraseParts)) {
|
|
70
|
-
// If there is a seed phrase in the OS settings that does not match the BIOS seed phrase
|
|
71
|
-
// Update bios with existing user seed phrase
|
|
72
|
-
const updatedBiosSeedPhrase = storedSeedPhrasePayload.mnemonic.mnemonic.join(' ')
|
|
73
|
-
await this.context.kernel?.bios?.seedPhraseStore.set('user', updatedBiosSeedPhrase)
|
|
74
|
-
}
|
|
75
|
-
// Return stored seed phrase
|
|
76
|
-
return storedSeedPhrasePayload
|
|
77
|
-
}
|
|
78
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { assertEx } from '@xylabs/assert'
|
|
2
|
-
import { asArchivistInstance } from '@xyo-network/archivist-model'
|
|
3
|
-
import { asDivinerInstance } from '@xyo-network/diviner-model'
|
|
4
|
-
import type { XyOsContext } from '@xyo-network/os-model'
|
|
5
|
-
|
|
6
|
-
const OsSettingsArchivistModuleName = 'OsSettingsNode:OsSettingsArchivist'
|
|
7
|
-
const OsSettingsArchivistPayloadDivinerModuleName = 'OsSettingsNode:OsSettingsArchivistPayloadDiviner'
|
|
8
|
-
|
|
9
|
-
export class OsSettingsCallerBase {
|
|
10
|
-
protected context: XyOsContext
|
|
11
|
-
constructor(context: XyOsContext) {
|
|
12
|
-
this.context = context
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
async getOsSettingsArchivist() {
|
|
16
|
-
const mod = assertEx(await this.context.root.resolve(OsSettingsArchivistModuleName), () => `${OsSettingsArchivistModuleName} not found`)
|
|
17
|
-
return asArchivistInstance(mod, () => `${OsSettingsArchivistModuleName} is not an archivist`, { required: true })
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
async getOsSettingsPayloadDiviner() {
|
|
21
|
-
const mod = assertEx(
|
|
22
|
-
await this.context.root.resolve(OsSettingsArchivistPayloadDivinerModuleName),
|
|
23
|
-
() => `${OsSettingsArchivistPayloadDivinerModuleName} not found`,
|
|
24
|
-
)
|
|
25
|
-
return asDivinerInstance(mod, () => `${OsSettingsArchivistPayloadDivinerModuleName} is not a diviner`, { required: true })
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { assertEx } from '@xylabs/assert'
|
|
2
|
-
import type {
|
|
3
|
-
NodeBackground, WalletSeedPhrase, XyOsContext,
|
|
4
|
-
} from '@xyo-network/os-model'
|
|
5
|
-
import { isNodeBackground, isWalletSeedPhrase } from '@xyo-network/os-model'
|
|
6
|
-
|
|
7
|
-
import type { Listener, ResourceStore } from '../../lib/index.ts'
|
|
8
|
-
import { PayloadStore } from '../../lib/index.ts'
|
|
9
|
-
import { OsSettingsCallerBase } from './CallerBase.ts'
|
|
10
|
-
import { OsSettingsQueries } from './SettingsQueries.ts'
|
|
11
|
-
|
|
12
|
-
export type OsSettingsResourceViews = 'wallets' | 'latestUserWallet' | 'nodeBackground'
|
|
13
|
-
|
|
14
|
-
export class OsSettingsResource extends OsSettingsCallerBase implements ResourceStore<OsSettingsResourceViews> {
|
|
15
|
-
private _latestUserWalletListener: PayloadStore<WalletSeedPhrase> | undefined
|
|
16
|
-
private _nodeBackgroundListener: PayloadStore<NodeBackground> | undefined
|
|
17
|
-
private _walletsListener: PayloadStore<WalletSeedPhrase> | undefined
|
|
18
|
-
|
|
19
|
-
constructor(context: XyOsContext) {
|
|
20
|
-
super(context)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
get latestUserWalletListener() {
|
|
24
|
-
return assertEx(this._latestUserWalletListener, () => 'Latest user wallet listener not set')
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
get nodeBackgroundListener() {
|
|
28
|
-
return assertEx(this._nodeBackgroundListener, () => 'Node background listener not set')
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
get subscriptions() {
|
|
32
|
-
return {
|
|
33
|
-
latestUserWallet: (cb: Listener) => this.walletsListener.subscribe(cb),
|
|
34
|
-
nodeBackground: (cb: Listener) => this.nodeBackgroundListener.subscribe(cb),
|
|
35
|
-
wallets: (cb: Listener) => this.walletsListener.subscribe(cb),
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
get views() {
|
|
40
|
-
return {
|
|
41
|
-
latestUserWallet: () => this.latestUserWalletListener.latest,
|
|
42
|
-
nodeBackground: () => this.nodeBackgroundListener.latest,
|
|
43
|
-
wallets: () => this.walletsListener.latest,
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
get walletsListener() {
|
|
48
|
-
return assertEx(this._walletsListener, () => 'Wallets listener not set')
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
cleanupListeners() {
|
|
52
|
-
this.walletsListener.cleanupListeners()
|
|
53
|
-
this.latestUserWalletListener.cleanupListeners()
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* start listeners
|
|
58
|
-
*/
|
|
59
|
-
async start() {
|
|
60
|
-
const archivist = await this.getOsSettingsArchivist()
|
|
61
|
-
const diviner = await this.getOsSettingsPayloadDiviner()
|
|
62
|
-
|
|
63
|
-
this._walletsListener = await PayloadStore.create<WalletSeedPhrase>({
|
|
64
|
-
archivist,
|
|
65
|
-
getLatest: async () => await OsSettingsQueries.getWallets(diviner),
|
|
66
|
-
idFunction: isWalletSeedPhrase,
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
this._latestUserWalletListener = await PayloadStore.create<WalletSeedPhrase>({
|
|
70
|
-
archivist,
|
|
71
|
-
getLatest: async () => await OsSettingsQueries.getLatestUserWallet(diviner),
|
|
72
|
-
idFunction: isWalletSeedPhrase,
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
this._nodeBackgroundListener = await PayloadStore.create<NodeBackground>({
|
|
76
|
-
archivist,
|
|
77
|
-
getLatest: async () => await OsSettingsQueries.getNodeBackground(diviner),
|
|
78
|
-
idFunction: isNodeBackground,
|
|
79
|
-
})
|
|
80
|
-
}
|
|
81
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import type { ArchivistInstance } from '@xyo-network/archivist-model'
|
|
2
|
-
import type { DivinerInstance } from '@xyo-network/diviner-model'
|
|
3
|
-
import { PayloadDivinerQuerySchema } from '@xyo-network/diviner-payload-model'
|
|
4
|
-
import type { NodeBackground, WalletSeedPhrase } from '@xyo-network/os-model'
|
|
5
|
-
import { NodeBackgroundSchema, WalletSeedPhraseSchema } from '@xyo-network/os-model'
|
|
6
|
-
import { PayloadBuilder } from '@xyo-network/payload-builder'
|
|
7
|
-
import type { WithSources } from '@xyo-network/payload-model'
|
|
8
|
-
|
|
9
|
-
const NO_RESULTS: WithSources<WalletSeedPhrase>[] = []
|
|
10
|
-
|
|
11
|
-
export const OsSettingsQueries = {
|
|
12
|
-
async getLatestUserWallet(diviner: DivinerInstance, archivist?: ArchivistInstance): Promise<WalletSeedPhrase[]> {
|
|
13
|
-
const query = {
|
|
14
|
-
limit: 1,
|
|
15
|
-
order: 'desc',
|
|
16
|
-
schema: PayloadDivinerQuerySchema,
|
|
17
|
-
schemas: [WalletSeedPhraseSchema],
|
|
18
|
-
}
|
|
19
|
-
const results = (await diviner.divine([query])) as WalletSeedPhrase[]
|
|
20
|
-
const wallet = results.find(payload => payload.$label === 'userWallet')
|
|
21
|
-
if (wallet) return [wallet]
|
|
22
|
-
// Check for legacy payload and optionally migrate by re-minting it in the updates format.
|
|
23
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
|
-
const legacyWallet = results.find(payload => (payload as any).$meta.label === 'userWallet')
|
|
25
|
-
if (legacyWallet && archivist) {
|
|
26
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
|
-
const legacyMeta = (legacyWallet as any).$meta
|
|
28
|
-
const newWalletPayloadFields = {
|
|
29
|
-
mnemonic: legacyWallet.mnemonic,
|
|
30
|
-
$label: legacyMeta.label,
|
|
31
|
-
$timestamp: legacyMeta.$timestamp,
|
|
32
|
-
}
|
|
33
|
-
const payload = new PayloadBuilder<WalletSeedPhrase>({ schema: WalletSeedPhraseSchema }).fields(newWalletPayloadFields).build()
|
|
34
|
-
await archivist.insert([payload])
|
|
35
|
-
return [payload]
|
|
36
|
-
}
|
|
37
|
-
return NO_RESULTS
|
|
38
|
-
},
|
|
39
|
-
async getNodeBackground(diviner: DivinerInstance) {
|
|
40
|
-
const query = {
|
|
41
|
-
limit: 1,
|
|
42
|
-
order: 'desc',
|
|
43
|
-
schema: PayloadDivinerQuerySchema,
|
|
44
|
-
schemas: [NodeBackgroundSchema],
|
|
45
|
-
}
|
|
46
|
-
return (await diviner.divine([query])) as WithSources<NodeBackground>[]
|
|
47
|
-
},
|
|
48
|
-
async getWallets(diviner: DivinerInstance) {
|
|
49
|
-
const query = {
|
|
50
|
-
order: 'desc',
|
|
51
|
-
schema: PayloadDivinerQuerySchema,
|
|
52
|
-
schemas: [WalletSeedPhraseSchema],
|
|
53
|
-
}
|
|
54
|
-
return (await diviner.divine([query])) as WithSources<WalletSeedPhrase>[]
|
|
55
|
-
},
|
|
56
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { ValidOsAchievements } from '@xyo-network/os-model'
|
|
2
|
-
import { OsBadgeSchema } from '@xyo-network/os-model'
|
|
3
|
-
|
|
4
|
-
import { OsSettingsCallerBase } from '../CallerBase.ts'
|
|
5
|
-
import { OsBadgeQueries } from './Queries.ts'
|
|
6
|
-
|
|
7
|
-
export class OsBadgeCaller extends OsSettingsCallerBase {
|
|
8
|
-
/**
|
|
9
|
-
* @param {ValidOsAchievements} achievement
|
|
10
|
-
*/
|
|
11
|
-
async getBadge(achievement: ValidOsAchievements) {
|
|
12
|
-
const diviner = await this.getOsSettingsPayloadDiviner()
|
|
13
|
-
const results = await OsBadgeQueries.getBadge(achievement, diviner)
|
|
14
|
-
return results[0] ?? null
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @param {ValidOsAchievements} achievement
|
|
19
|
-
*/
|
|
20
|
-
async saveBadge(achievement: ValidOsAchievements) {
|
|
21
|
-
const badge = {
|
|
22
|
-
achievement,
|
|
23
|
-
schema: OsBadgeSchema,
|
|
24
|
-
timestamp: Date.now(),
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const archivist = await this.getOsSettingsArchivist()
|
|
28
|
-
return await archivist.insert([badge])
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { DivinerInstance } from '@xyo-network/diviner-model'
|
|
2
|
-
import { PayloadDivinerQuerySchema } from '@xyo-network/diviner-payload-model'
|
|
3
|
-
import type { OsBadge } from '@xyo-network/os-model'
|
|
4
|
-
import { OsBadgeSchema } from '@xyo-network/os-model'
|
|
5
|
-
import type { WithSources } from '@xyo-network/payload-model'
|
|
6
|
-
|
|
7
|
-
export const OsBadgeQueries = {
|
|
8
|
-
getBadge: async (achievement: string, diviner: DivinerInstance) => {
|
|
9
|
-
const query = {
|
|
10
|
-
achievement,
|
|
11
|
-
limit: 1,
|
|
12
|
-
order: 'desc',
|
|
13
|
-
schema: PayloadDivinerQuerySchema,
|
|
14
|
-
schemas: [OsBadgeSchema],
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return (await diviner.divine([query])) as WithSources<OsBadge>[]
|
|
18
|
-
},
|
|
19
|
-
}
|