@xyo-network/dapp-template 7.2.1 → 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/Params.d.ts.map +1 -1
- package/dist/neutral/components/host/XyOsHost.d.ts +1 -1
- package/dist/neutral/components/host/XyOsHost.d.ts.map +1 -1
- package/dist/neutral/index.mjs +2 -3
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/node/Params.d.ts.map +1 -1
- package/dist/node/components/host/XyOsHost.d.ts +1 -1
- package/dist/node/components/host/XyOsHost.d.ts.map +1 -1
- package/dist/node/index.mjs +2 -3
- package/dist/node/index.mjs.map +1 -1
- package/package.json +322 -39
- package/dist/neutral/dapp.stories.d.ts +0 -8
- package/dist/neutral/dapp.stories.d.ts.map +0 -1
- package/dist/node/dapp.stories.d.ts +0 -8
- package/dist/node/dapp.stories.d.ts.map +0 -1
- package/src/CustomDappPathToComponent.tsx +0 -10
- package/src/Dapp.tsx +0 -19
- package/src/Params.ts +0 -13
- package/src/Payloads.ts +0 -73
- package/src/ReactDapp.ts +0 -13
- package/src/UiParams.ts +0 -11
- package/src/components/host/DappHost.tsx +0 -36
- package/src/components/host/Routable.tsx +0 -15
- package/src/components/host/Routes.tsx +0 -33
- package/src/components/host/XyOsHost.tsx +0 -61
- package/src/components/host/index.ts +0 -4
- package/src/components/index.ts +0 -1
- package/src/dapp.manifest.json +0 -25
- package/src/dapp.stories.tsx +0 -37
- package/src/helpers/index.ts +0 -1
- package/src/helpers/registration/index.ts +0 -1
- package/src/helpers/registration/useInitializeDappAdHoc.tsx +0 -43
- package/src/icon/Icon.tsx +0 -45
- package/src/icon/index.ts +0 -2
- package/src/index.ts +0 -6
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { Typography } from '@mui/material'
|
|
2
|
-
import { FlexCol } from '@xylabs/react-flexbox'
|
|
3
|
-
import { usePromise } from '@xylabs/react-promise'
|
|
4
|
-
import { Kernel } from '@xyo-network/kernel'
|
|
5
|
-
import type { KernelExternal } from '@xyo-network/kernel-model'
|
|
6
|
-
import { ModuleFactoryLocator } from '@xyo-network/module-factory-locator'
|
|
7
|
-
import { XyOsUiContextProvider } from '@xyo-network/os-react-runtime'
|
|
8
|
-
import { EventBus, XyOs } from '@xyo-network/os-runtime'
|
|
9
|
-
import { HDWallet } from '@xyo-network/wallet'
|
|
10
|
-
import type { WalletInstance } from '@xyo-network/wallet-model'
|
|
11
|
-
import React, { useMemo } from 'react'
|
|
12
|
-
|
|
13
|
-
export interface XyOsHostProps {
|
|
14
|
-
children?: React.ReactNode
|
|
15
|
-
eventBus?: EventBus
|
|
16
|
-
kernel?: KernelExternal
|
|
17
|
-
locator?: ModuleFactoryLocator
|
|
18
|
-
wallet?: WalletInstance
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export const XyOsHost: React.FC<XyOsHostProps> = ({
|
|
22
|
-
children, eventBus, kernel, locator, wallet,
|
|
23
|
-
}) => {
|
|
24
|
-
const [walletToUse] = usePromise(async () => wallet ?? await HDWallet.random(), [wallet])
|
|
25
|
-
const eventBusToUse: EventBus = useMemo(() => eventBus ?? new EventBus(), [kernel])
|
|
26
|
-
const kernelToUse: KernelExternal = useMemo(() => kernel ?? new Kernel(), [kernel])
|
|
27
|
-
const locatorToUse = useMemo(() => locator ?? new ModuleFactoryLocator(), [locator])
|
|
28
|
-
|
|
29
|
-
const [os, error] = usePromise(async () => {
|
|
30
|
-
if (walletToUse && kernelToUse && eventBusToUse && locatorToUse) {
|
|
31
|
-
const os = new XyOs({
|
|
32
|
-
kernel: kernelToUse, eventBus: new EventBus(), locator: locatorToUse,
|
|
33
|
-
})
|
|
34
|
-
await os.boot(walletToUse, locatorToUse)
|
|
35
|
-
return os
|
|
36
|
-
}
|
|
37
|
-
}, [kernelToUse, walletToUse, locator, eventBusToUse, locatorToUse])
|
|
38
|
-
|
|
39
|
-
return os
|
|
40
|
-
? <XyOsUiContextProvider value={os}>{children}</XyOsUiContextProvider>
|
|
41
|
-
: (
|
|
42
|
-
<FlexCol>
|
|
43
|
-
<Typography>
|
|
44
|
-
wallet:
|
|
45
|
-
{walletToUse ? 'ready' : 'loading'}
|
|
46
|
-
</Typography>
|
|
47
|
-
<Typography>
|
|
48
|
-
kernel:
|
|
49
|
-
{kernelToUse ? 'ready' : 'loading'}
|
|
50
|
-
</Typography>
|
|
51
|
-
<Typography>
|
|
52
|
-
os:
|
|
53
|
-
{os ? 'ready' : 'loading'}
|
|
54
|
-
</Typography>
|
|
55
|
-
<Typography>
|
|
56
|
-
os-error:
|
|
57
|
-
{error?.message}
|
|
58
|
-
</Typography>
|
|
59
|
-
</FlexCol>
|
|
60
|
-
)
|
|
61
|
-
}
|
package/src/components/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './host/index.ts'
|
package/src/dapp.manifest.json
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://raw.githubusercontent.com/XYOracleNetwork/sdk-xyo-client-js/main/packages/manifest/src/compilations/dapp-package-manifest-schema.json",
|
|
3
|
-
"nodes": [
|
|
4
|
-
{
|
|
5
|
-
"config": {
|
|
6
|
-
"accountPath": "0'",
|
|
7
|
-
"name": "CustomDappNode",
|
|
8
|
-
"schema": "network.xyo.node.config"
|
|
9
|
-
},
|
|
10
|
-
"modules": {
|
|
11
|
-
"private": [],
|
|
12
|
-
"public": [
|
|
13
|
-
{
|
|
14
|
-
"config": {
|
|
15
|
-
"accountPath": "1'",
|
|
16
|
-
"name": "DappArchivist",
|
|
17
|
-
"schema": "network.xyo.archivist.config"
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
]
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
],
|
|
24
|
-
"schema": "network.xyo.manifest.package.dapp"
|
|
25
|
-
}
|
package/src/dapp.stories.tsx
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryFn } from '@storybook/react-vite'
|
|
2
|
-
import { DappRegisteredSchema, DappRegisteredState } from '@xyo-network/os-model'
|
|
3
|
-
import type { RegisteredReactDapp } from '@xyo-network/os-react-model'
|
|
4
|
-
import React from 'react'
|
|
5
|
-
|
|
6
|
-
import type { DappHostProps } from './components/index.ts'
|
|
7
|
-
import { RoutableDapp } from './components/index.ts'
|
|
8
|
-
import { CustomDappConfig } from './Payloads.ts'
|
|
9
|
-
import { CustomDappUiParams } from './ReactDapp.ts'
|
|
10
|
-
|
|
11
|
-
const StorybookEntry = {
|
|
12
|
-
argTypes: {},
|
|
13
|
-
component: RoutableDapp,
|
|
14
|
-
parameters: { layout: 'fullscreen' },
|
|
15
|
-
title: 'dapps/customDapp',
|
|
16
|
-
} as Meta<typeof RoutableDapp>
|
|
17
|
-
|
|
18
|
-
const Template: StoryFn<typeof RoutableDapp> = (args: DappHostProps) => <RoutableDapp {...args} />
|
|
19
|
-
|
|
20
|
-
const dapp: RegisteredReactDapp = {
|
|
21
|
-
config: {
|
|
22
|
-
...CustomDappConfig,
|
|
23
|
-
state: DappRegisteredState.Registered,
|
|
24
|
-
schema: DappRegisteredSchema,
|
|
25
|
-
walletId: 'Accounts',
|
|
26
|
-
},
|
|
27
|
-
accessors: [],
|
|
28
|
-
params: CustomDappUiParams,
|
|
29
|
-
widgetConfigs: [],
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const Default = Template.bind({})
|
|
33
|
-
Default.args = { dapp }
|
|
34
|
-
|
|
35
|
-
export { Default }
|
|
36
|
-
|
|
37
|
-
export default StorybookEntry
|
package/src/helpers/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './registration/index.ts'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './useInitializeDappAdHoc.tsx'
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { usePromise } from '@xylabs/react-promise'
|
|
2
|
-
import type { RegisteredReactDapp } from '@xyo-network/os-react-model'
|
|
3
|
-
import {
|
|
4
|
-
useDappMenu, useManageDappInjectableParamsFromRoute, useManageDappPathFromRoute, useXyOsUiContext,
|
|
5
|
-
} from '@xyo-network/os-react-runtime'
|
|
6
|
-
import { DappInitializer } from '@xyo-network/os-runtime'
|
|
7
|
-
|
|
8
|
-
const dappState = {
|
|
9
|
-
active: true, minimized: false, closed: false,
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const useInitializeDappAdHoc = (dapp: RegisteredReactDapp) => {
|
|
13
|
-
const xyOs = useXyOsUiContext()
|
|
14
|
-
|
|
15
|
-
const [installedDapp, nodeCreateError] = usePromise(async () => {
|
|
16
|
-
if (xyOs && dapp) {
|
|
17
|
-
const installer = new DappInitializer({
|
|
18
|
-
allowedNames: [dapp.config.name],
|
|
19
|
-
dapp,
|
|
20
|
-
xnsNetwork: undefined,
|
|
21
|
-
xnsNodeUrl: undefined,
|
|
22
|
-
xyOs,
|
|
23
|
-
})
|
|
24
|
-
return await installer.install()
|
|
25
|
-
}
|
|
26
|
-
}, [xyOs, dapp])
|
|
27
|
-
|
|
28
|
-
const { dappWallet, context } = installedDapp ?? {}
|
|
29
|
-
|
|
30
|
-
// support for routing
|
|
31
|
-
const routingError = useManageDappPathFromRoute(context, dapp.config.name)
|
|
32
|
-
const injectableErrors = useManageDappInjectableParamsFromRoute(context)
|
|
33
|
-
|
|
34
|
-
const dappMenu = useDappMenu(context, dapp.config.name)
|
|
35
|
-
|
|
36
|
-
return {
|
|
37
|
-
context,
|
|
38
|
-
dappMenu,
|
|
39
|
-
dappState,
|
|
40
|
-
dappWallet,
|
|
41
|
-
errors: [routingError, nodeCreateError, ...injectableErrors].filter(Boolean),
|
|
42
|
-
}
|
|
43
|
-
}
|
package/src/icon/Icon.tsx
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @stylistic/max-len */
|
|
2
|
-
export const CustomDappIconSvg = `
|
|
3
|
-
<svg id="Layer_1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 40">
|
|
4
|
-
<path
|
|
5
|
-
fill="transparent"
|
|
6
|
-
d="M6.44,27.12c-.78,0-1.44.28-2,.83-.55.55-.83,1.21-.83,1.99s.28,1.44.83,2c.55.55,1.21.83,1.99.83s1.44-.28,2-.83c.55-.55.83-1.21.83-1.99s-.28-1.44-.83-2c-.55-.55-1.21-.83-1.99-.83Z"
|
|
7
|
-
/>
|
|
8
|
-
<path
|
|
9
|
-
fill="transparent"
|
|
10
|
-
d="M18.01,27.91c-.55.55-.83,1.22-.83,1.99s.28,1.44.83,2c.55.55,1.21.83,1.99.83s1.44-.28,2-.83c.55-.55.83-1.21.83-1.99s-.28-1.44-.83-2c-.55-.55-1.21-.83-1.99-.83s-1.44.28-2,.83Z"
|
|
11
|
-
/>
|
|
12
|
-
<path
|
|
13
|
-
fill="transparent"
|
|
14
|
-
d="M33.56,27.12c-.78,0-1.44.28-2,.83-.55.55-.83,1.21-.83,1.99s.28,1.44.83,2c.55.55,1.21.83,1.99.83s1.44-.28,2-.83c.55-.55.83-1.21.83-1.99s-.28-1.44-.83-2c-.55-.55-1.21-.83-1.99-.83Z"
|
|
15
|
-
/>
|
|
16
|
-
<path
|
|
17
|
-
fill="currentColor"
|
|
18
|
-
d="M36.55,26.94c-.82-.82-1.82-1.23-3-1.23-.32,0-.63.04-.93.11-.3.07-.59.17-.87.31l-5.87-8.09c-.18.03-.36.05-.56.05h-1.13l6.42,8.83c-.39.4-.7.85-.93,1.36-.23.51-.35,1.06-.35,1.66,0,1.18.41,2.17,1.23,3s1.82,1.23,3,1.23,2.17-.41,3-1.23,1.23-1.82,1.23-3-.41-2.17-1.23-3ZM35.55,31.93c-.55.55-1.22.83-2,.83s-1.44-.28-1.99-.83c-.55-.55-.83-1.22-.83-2s.28-1.44.83-1.99c.55-.55,1.22-.83,2-.83s1.44.28,1.99.83c.55.55.83,1.22.83,2s-.28,1.44-.83,1.99Z"
|
|
19
|
-
/>
|
|
20
|
-
<path
|
|
21
|
-
fill="currentColor"
|
|
22
|
-
d="M19.29,25.73c-1,.16-1.84.64-2.52,1.42-.67.79-1.01,1.7-1.01,2.75,0,1.18.41,2.17,1.23,3,.82.82,1.82,1.23,3,1.23s2.17-.41,3-1.23c.82-.82,1.23-1.82,1.23-3,0-1.05-.34-1.97-1.01-2.74-.67-.78-1.51-1.25-2.52-1.43v-7.65h-1.41v7.65ZM22,27.91c.55.55.83,1.22.83,2s-.28,1.44-.83,1.99c-.55.55-1.22.83-2,.83s-1.44-.28-1.99-.83c-.55-.55-.83-1.22-.83-2s.28-1.44.83-1.99c.55-.55,1.22-.83,2-.83s1.44.28,1.99.83Z"
|
|
23
|
-
/>
|
|
24
|
-
<path
|
|
25
|
-
fill="currentColor"
|
|
26
|
-
d="M14.1,18l-5.89,8.08c-.28-.13-.56-.22-.86-.28-.29-.06-.6-.09-.91-.09-1.18,0-2.17.41-3,1.23-.82.82-1.23,1.82-1.23,3s.41,2.17,1.23,3,1.82,1.23,3,1.23,2.17-.41,3-1.23,1.23-1.82,1.23-3c0-.6-.12-1.15-.36-1.66s-.56-.96-.95-1.36l6.45-8.83h-1c-.25,0-.48-.03-.7-.08ZM8.44,31.93c-.55.55-1.22.83-2,.83s-1.44-.28-1.99-.83c-.55-.55-.83-1.22-.83-2s.28-1.44.83-1.99c.55-.55,1.22-.83,2-.83s1.44.28,1.99.83c.55.55.83,1.22.83,2s-.28,1.44-.83,1.99Z"
|
|
27
|
-
/>
|
|
28
|
-
<path
|
|
29
|
-
fill="transparent"
|
|
30
|
-
d="M20,12.91c1.26,0,2.46.19,3.61.56,1.15.37,2.23.88,3.23,1.54V4.86c0-.44-.15-.82-.46-1.12s-.68-.46-1.12-.46h-10.52c-.44,0-.82.15-1.12.46s-.46.68-.46,1.12v10.15c1-.66,2.08-1.17,3.23-1.54s2.36-.56,3.61-.56ZM17.7,5.83c.63-.63,1.4-.95,2.3-.95s1.66.32,2.3.95.95,1.4.95,2.3-.32,1.66-.95,2.3-1.4.95-2.3.95-1.66-.32-2.3-.95-.95-1.4-.95-2.3.32-1.66.95-2.3Z"
|
|
31
|
-
/>
|
|
32
|
-
<path
|
|
33
|
-
fill="transparent"
|
|
34
|
-
d="M20,10.32c.6,0,1.12-.21,1.55-.64.43-.43.65-.94.65-1.55s-.22-1.12-.65-1.55c-.43-.43-.95-.65-1.55-.65s-1.12.22-1.55.65-.64.95-.64,1.55.21,1.12.64,1.55.94.64,1.55.64Z"
|
|
35
|
-
/>
|
|
36
|
-
<path
|
|
37
|
-
fill="currentColor"
|
|
38
|
-
d="M20,11.37c.9,0,1.66-.32,2.3-.95s.95-1.4.95-2.3-.32-1.66-.95-2.3-1.4-.95-2.3-.95-1.66.32-2.3.95-.95,1.4-.95,2.3.32,1.66.95,2.3,1.4.95,2.3.95ZM18.45,6.58c.43-.43.95-.65,1.55-.65s1.12.22,1.55.65c.43.43.65.95.65,1.55s-.22,1.12-.65,1.55c-.43.43-.95.64-1.55.64s-1.12-.21-1.55-.64-.64-.95-.64-1.55.21-1.12.64-1.55Z"
|
|
39
|
-
/>
|
|
40
|
-
<path
|
|
41
|
-
fill="currentColor"
|
|
42
|
-
d="M27.21,2.9c-.5-.5-1.15-.75-1.95-.75h-10.52c-.8,0-1.45.25-1.95.75-.5.5-.75,1.15-.75,1.95v10.52c0,.8.25,1.45.75,1.95.35.35.77.56,1.25.67.22.05.45.08.7.08h10.52c.2,0,.38-.02.56-.05.55-.09,1.01-.33,1.39-.71.5-.5.75-1.15.75-1.95V4.86c0-.8-.25-1.45-.75-1.95ZM25.93,16.74c-.26.14-.55.22-.86.22h-10.15s-.08-.01-.12-.01c-.25-.02-.5-.08-.74-.2-.28-.14-.45-.35-.5-.63.99-.7,2.03-1.22,3.12-1.57s2.19-.52,3.31-.52,2.27.18,3.4.55c1.13.36,2.18.88,3.16,1.54-.15.27-.36.48-.63.63ZM26.84,15.01c-1-.66-2.08-1.17-3.23-1.54-1.15-.37-2.36-.56-3.61-.56s-2.46.19-3.61.56-2.23.88-3.23,1.54V4.86c0-.44.15-.82.46-1.12s.68-.46,1.12-.46h10.52c.44,0,.82.15,1.12.46s.46.68.46,1.12v10.15Z"
|
|
43
|
-
/>
|
|
44
|
-
</svg>
|
|
45
|
-
`
|
package/src/icon/index.ts
DELETED
package/src/index.ts
DELETED