@xyo-network/react-module 2.56.0 → 2.56.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/cjs/components/Card/Diviner/CardContent.js +2 -2
  2. package/dist/cjs/components/Card/Diviner/CardContent.js.map +1 -1
  3. package/dist/cjs/components/Card/Module/CardActions.js +3 -3
  4. package/dist/cjs/components/Card/Module/CardActions.js.map +1 -1
  5. package/dist/cjs/components/Card/Module/components/DiscoverDialog.js +1 -1
  6. package/dist/cjs/components/Card/Module/components/DiscoverDialog.js.map +1 -1
  7. package/dist/cjs/components/DetailsBox.js +1 -1
  8. package/dist/cjs/components/DetailsBox.js.map +1 -1
  9. package/dist/cjs/hooks/index.js +5 -0
  10. package/dist/cjs/hooks/index.js.map +1 -0
  11. package/dist/cjs/hooks/useWrappedModule.js +37 -0
  12. package/dist/cjs/hooks/useWrappedModule.js.map +1 -0
  13. package/dist/docs.json +379 -2406
  14. package/dist/esm/components/Card/Diviner/CardContent.js +2 -2
  15. package/dist/esm/components/Card/Diviner/CardContent.js.map +1 -1
  16. package/dist/esm/components/Card/Module/CardActions.js +2 -2
  17. package/dist/esm/components/Card/Module/CardActions.js.map +1 -1
  18. package/dist/esm/hooks/index.js +2 -0
  19. package/dist/esm/hooks/index.js.map +1 -0
  20. package/dist/esm/hooks/useWrappedModule.js +33 -0
  21. package/dist/esm/hooks/useWrappedModule.js.map +1 -0
  22. package/dist/types/ModuleRenderProps.d.ts +4 -2
  23. package/dist/types/ModuleRenderProps.d.ts.map +1 -1
  24. package/dist/types/components/Card/Diviner/CardContent.d.ts.map +1 -1
  25. package/dist/types/components/Card/Module/CardActions.d.ts.map +1 -1
  26. package/dist/types/hooks/index.d.ts +2 -0
  27. package/dist/types/hooks/index.d.ts.map +1 -0
  28. package/dist/types/hooks/useWrappedModule.d.ts +6 -0
  29. package/dist/types/hooks/useWrappedModule.d.ts.map +1 -0
  30. package/package.json +14 -11
  31. package/src/ModuleRenderProps.tsx +3 -1
  32. package/src/components/Card/Diviner/CardContent.tsx +2 -6
  33. package/src/components/Card/Module/CardActions.tsx +3 -2
  34. package/src/hooks/index.ts +1 -0
  35. package/src/hooks/useWrappedModule.tsx +40 -0
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { ModuleCardContent } from '../Module';
3
- export const DivinerCardContent = ({ children, module, ...props }) => {
4
- return (_jsx(ModuleCardContent, { module: module, ...props, children: children }));
3
+ export const DivinerCardContent = ({ children, ...props }) => {
4
+ return _jsx(ModuleCardContent, { ...props, children: children });
5
5
  };
6
6
  //# sourceMappingURL=CardContent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CardContent.js","sourceRoot":"","sources":["../../../../../src/components/Card/Diviner/CardContent.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAE7C,MAAM,CAAC,MAAM,kBAAkB,GAAkE,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,EAAE,EAAE;IAClI,OAAO,CACL,KAAC,iBAAiB,IAAC,MAAM,EAAE,MAAM,KAAM,KAAK,YACzC,QAAQ,GACS,CACrB,CAAA;AACH,CAAC,CAAA"}
1
+ {"version":3,"file":"CardContent.js","sourceRoot":"","sources":["../../../../../src/components/Card/Diviner/CardContent.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAE7C,MAAM,CAAC,MAAM,kBAAkB,GAAkE,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,EAAE;IAC1H,OAAO,KAAC,iBAAiB,OAAK,KAAK,YAAG,QAAQ,GAAqB,CAAA;AACrE,CAAC,CAAA"}
@@ -2,12 +2,12 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { CardActions, Chip } from '@mui/material';
3
3
  import { ButtonEx } from '@xylabs/react-button';
4
4
  import { FlexGrowRow } from '@xylabs/react-flexbox';
5
- import { ModuleWrapper } from '@xyo-network/module';
6
5
  import { useState } from 'react';
6
+ import { useWrappedModule } from '../../../hooks';
7
7
  import { DiscoverDialog } from './components';
8
8
  export const ModuleCardActions = ({ children, module, sx, ...props }) => {
9
9
  const [discoverDialogOpen, setDiscoverDialogOpen] = useState(false);
10
- const wrapper = module ? ModuleWrapper.wrap(module) : undefined;
10
+ const [wrapper] = useWrappedModule(module);
11
11
  const config = wrapper?.config;
12
12
  return (_jsxs(CardActions, { sx: { alignItems: 'stretch', flexDirection: 'column', ml: 1, ...sx }, ...props, children: [_jsxs(FlexGrowRow, { justifyContent: "space-between", alignItems: "center", children: [wrapper ? _jsx(Chip, { label: config?.schema, size: 'small' }) : null, _jsx(ButtonEx, { onClick: () => setDiscoverDialogOpen(true), size: 'small', variant: 'outlined', children: "Discover" }), _jsx(DiscoverDialog, { fullWidth: true, maxWidth: 'md', module: module, open: discoverDialogOpen, setOpen: setDiscoverDialogOpen, wrapper: wrapper })] }), children] }));
13
13
  };
@@ -1 +1 @@
1
- {"version":3,"file":"CardActions.js","sourceRoot":"","sources":["../../../../../src/components/Card/Module/CardActions.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAoB,IAAI,EAAE,MAAM,eAAe,CAAA;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAGhC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAE7C,MAAM,CAAC,MAAM,iBAAiB,GAAmD,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,KAAK,EAAE,EAAE,EAAE;IACtH,MAAM,CAAC,kBAAkB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version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA"}
@@ -0,0 +1,33 @@
1
+ import { ModuleWrapper } from '@xyo-network/module';
2
+ import { useWrapperWallet } from '@xyo-network/react-wallet';
3
+ import { useEffect, useState } from 'react';
4
+ export const WrappedModuleHookFactory = (wrapperObject, name) => {
5
+ const useHook = (module, wallet, logger) => {
6
+ logger?.debug(`Render: ${name}`);
7
+ const wrapperWallet = useWrapperWallet();
8
+ const [wrapper, setWrapper] = useState();
9
+ const [error, setError] = useState();
10
+ useEffect(() => {
11
+ const walletToUse = wallet || wrapperWallet;
12
+ if (module && walletToUse) {
13
+ try {
14
+ const wrapper = wrapperObject.wrap(module, walletToUse);
15
+ setWrapper(wrapper);
16
+ setError(undefined);
17
+ }
18
+ catch (ex) {
19
+ setWrapper(undefined);
20
+ setError(ex);
21
+ }
22
+ }
23
+ else {
24
+ setWrapper(undefined);
25
+ setError(undefined);
26
+ }
27
+ }, [module, wallet, wrapperWallet]);
28
+ return [wrapper, error];
29
+ };
30
+ return useHook;
31
+ };
32
+ export const useWrappedModule = WrappedModuleHookFactory(ModuleWrapper, 'useWrappedModule');
33
+ //# sourceMappingURL=useWrappedModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useWrappedModule.js","sourceRoot":"","sources":["../../../src/hooks/useWrappedModule.tsx"],"names":[],"mappings":"AACA,OAAO,EAAsC,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACvF,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAE5D,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAE3C,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,aAAyD,EACzD,IAAa,EACb,EAAE;IACF,MAAM,OAAO,GAAG,CAAC,MAAe,EAAE,MAAuB,EAAE,MAAe,EAAmD,EAAE;QAC7H,MAAM,EAAE,KAAK,CAAC,WAAW,IAAI,EAAE,CAAC,CAAA;QAChC,MAAM,aAAa,GAAG,gBAAgB,EAAE,CAAA;QAExC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,EAAkB,CAAA;QACxD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,EAAS,CAAA;QAE3C,SAAS,CAAC,GAAG,EAAE;YACb,MAAM,WAAW,GAAG,MAAM,IAAI,aAAa,CAAA;YAC3C,IAAI,MAAM,IAAI,WAAW,EAAE;gBACzB,IAAI;oBACF,MAAM,OAAO,GAAG,aAAa,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;oBACvD,UAAU,CAAC,OAAO,CAAC,CAAA;oBACnB,QAAQ,CAAC,SAAS,CAAC,CAAA;iBACpB;gBAAC,OAAO,EAAE,EAAE;oBACX,UAAU,CAAC,SAAS,CAAC,CAAA;oBACrB,QAAQ,CAAC,EAAW,CAAC,CAAA;iBACtB;aACF;iBAAM;gBACL,UAAU,CAAC,SAAS,CAAC,CAAA;gBACrB,QAAQ,CAAC,SAAS,CAAC,CAAA;aACpB;QACH,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC,CAAA;QAEnC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IACzB,CAAC,CAAA;IACD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,wBAAwB,CAAC,aAAa,EAAE,kBAAkB,CAAC,CAAA"}
@@ -1,5 +1,7 @@
1
1
  import { Module } from '@xyo-network/module';
2
- export interface ModuleRenderProps<T extends Module = Module> {
2
+ export type ModuleRenderProps<T extends Module = Module> = {
3
+ address?: string;
3
4
  module?: T;
4
- }
5
+ name?: string;
6
+ };
5
7
  //# sourceMappingURL=ModuleRenderProps.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ModuleRenderProps.d.ts","sourceRoot":"","sources":["../../src/ModuleRenderProps.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAE5C,MAAM,WAAW,iBAAiB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM;IAC1D,MAAM,CAAC,EAAE,CAAC,CAAA;CACX"}
1
+ {"version":3,"file":"ModuleRenderProps.d.ts","sourceRoot":"","sources":["../../src/ModuleRenderProps.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAE5C,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI;IACzD,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,CAAC,CAAA;IACV,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"CardContent.d.ts","sourceRoot":"","sources":["../../../../../src/components/Card/Diviner/CardContent.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAEpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAG9D,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAAC,aAAa,CAAC,GAAG,gBAAgB,CAM5F,CAAA"}
1
+ {"version":3,"file":"CardContent.d.ts","sourceRoot":"","sources":["../../../../../src/components/Card/Diviner/CardContent.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAEpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAG9D,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAAC,aAAa,CAAC,GAAG,gBAAgB,CAE5F,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"CardActions.d.ts","sourceRoot":"","sources":["../../../../../src/components/Card/Module/CardActions.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAe,gBAAgB,EAAQ,MAAM,eAAe,CAAA;AAMnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAG9D,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,GAAG,iBAAiB,CAiB5E,CAAA"}
1
+ {"version":3,"file":"CardActions.d.ts","sourceRoot":"","sources":["../../../../../src/components/Card/Module/CardActions.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAe,gBAAgB,EAAQ,MAAM,eAAe,CAAA;AAMnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAG9D,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,GAAG,iBAAiB,CAkB5E,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './useWrappedModule';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA"}
@@ -0,0 +1,6 @@
1
+ import { Logger } from '@xyo-network/core';
2
+ import { ConstructableModuleWrapper, Module, ModuleWrapper } from '@xyo-network/module';
3
+ import { WalletInstance } from '@xyo-network/wallet-model';
4
+ export declare const WrappedModuleHookFactory: <TModuleWrapper extends ModuleWrapper<Module>>(wrapperObject: ConstructableModuleWrapper<TModuleWrapper>, name?: string) => (module?: Module, wallet?: WalletInstance, logger?: Logger) => [TModuleWrapper | undefined, Error | undefined];
5
+ export declare const useWrappedModule: (module?: Module, wallet?: WalletInstance, logger?: Logger) => [ModuleWrapper<Module> | undefined, Error | undefined];
6
+ //# sourceMappingURL=useWrappedModule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useWrappedModule.d.ts","sourceRoot":"","sources":["../../../src/hooks/useWrappedModule.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC1C,OAAO,EAAE,0BAA0B,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAEvF,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAG1D,eAAO,MAAM,wBAAwB,mHAE5B,MAAM,eAEa,MAAM,WAAW,cAAc,WAAW,MAAM,oDA2B3E,CAAA;AAED,eAAO,MAAM,gBAAgB,YA7BD,MAAM,WAAW,cAAc,WAAW,MAAM,2DA6Be,CAAA"}
package/package.json CHANGED
@@ -15,10 +15,13 @@
15
15
  "@xylabs/react-button": "^2.17.6",
16
16
  "@xylabs/react-crypto": "^2.17.6",
17
17
  "@xylabs/react-flexbox": "^2.17.6",
18
- "@xyo-network/diviner": "^2.64.0",
19
- "@xyo-network/module": "^2.64.0",
20
- "@xyo-network/payload-model": "^2.64.0",
21
- "@xyo-network/react-shared": "^2.56.0"
18
+ "@xyo-network/core": "^2.64.1",
19
+ "@xyo-network/diviner": "^2.64.1",
20
+ "@xyo-network/module": "^2.64.1",
21
+ "@xyo-network/payload-model": "^2.64.1",
22
+ "@xyo-network/react-shared": "^2.56.2",
23
+ "@xyo-network/react-wallet": "^2.56.2",
24
+ "@xyo-network/wallet-model": "^2.64.1"
22
25
  },
23
26
  "devDependencies": {
24
27
  "@ethersproject/address": "^5.7.0",
@@ -30,12 +33,12 @@
30
33
  "@uniswap/sdk": "^3.0.3",
31
34
  "@uniswap/sdk-core": "^3.2.6",
32
35
  "@uniswap/v3-sdk": "^3.9.0",
33
- "@xylabs/ts-scripts-yarn3": "^2.17.17",
34
- "@xylabs/tsconfig-react": "^2.17.17",
35
- "@xyo-network/archivist": "^2.64.0",
36
- "@xyo-network/crypto-asset-plugin": "^2.64.0",
37
- "@xyo-network/diviner-address-history": "^2.64.0",
38
- "@xyo-network/node": "^2.64.0",
36
+ "@xylabs/ts-scripts-yarn3": "^2.18.2",
37
+ "@xylabs/tsconfig-react": "^2.18.2",
38
+ "@xyo-network/archivist": "^2.64.1",
39
+ "@xyo-network/crypto-asset-plugin": "^2.64.1",
40
+ "@xyo-network/diviner-address-history": "^2.64.1",
41
+ "@xyo-network/node": "^2.64.1",
39
42
  "typescript": "^5.1.6"
40
43
  },
41
44
  "peerDependencies": {
@@ -90,5 +93,5 @@
90
93
  },
91
94
  "sideEffects": false,
92
95
  "types": "dist/types/index.d.ts",
93
- "version": "2.56.0"
96
+ "version": "2.56.2"
94
97
  }
@@ -1,5 +1,7 @@
1
1
  import { Module } from '@xyo-network/module'
2
2
 
3
- export interface ModuleRenderProps<T extends Module = Module> {
3
+ export type ModuleRenderProps<T extends Module = Module> = {
4
+ address?: string
4
5
  module?: T
6
+ name?: string
5
7
  }
@@ -4,10 +4,6 @@ import { DivinerModule } from '@xyo-network/diviner'
4
4
  import { ModuleRenderProps } from '../../../ModuleRenderProps'
5
5
  import { ModuleCardContent } from '../Module'
6
6
 
7
- export const DivinerCardContent: React.FC<ModuleRenderProps<DivinerModule> & CardContentProps> = ({ children, module, ...props }) => {
8
- return (
9
- <ModuleCardContent module={module} {...props}>
10
- {children}
11
- </ModuleCardContent>
12
- )
7
+ export const DivinerCardContent: React.FC<ModuleRenderProps<DivinerModule> & CardContentProps> = ({ children, ...props }) => {
8
+ return <ModuleCardContent {...props}>{children}</ModuleCardContent>
13
9
  }
@@ -1,15 +1,16 @@
1
1
  import { CardActions, CardActionsProps, Chip } from '@mui/material'
2
2
  import { ButtonEx } from '@xylabs/react-button'
3
3
  import { FlexGrowRow } from '@xylabs/react-flexbox'
4
- import { ModuleWrapper } from '@xyo-network/module'
5
4
  import { useState } from 'react'
6
5
 
6
+ import { useWrappedModule } from '../../../hooks'
7
7
  import { ModuleRenderProps } from '../../../ModuleRenderProps'
8
8
  import { DiscoverDialog } from './components'
9
9
 
10
10
  export const ModuleCardActions: React.FC<CardActionsProps & ModuleRenderProps> = ({ children, module, sx, ...props }) => {
11
11
  const [discoverDialogOpen, setDiscoverDialogOpen] = useState(false)
12
- const wrapper = module ? ModuleWrapper.wrap(module) : undefined
12
+
13
+ const [wrapper] = useWrappedModule(module)
13
14
  const config = wrapper?.config
14
15
 
15
16
  return (
@@ -0,0 +1 @@
1
+ export * from './useWrappedModule'
@@ -0,0 +1,40 @@
1
+ import { Logger } from '@xyo-network/core'
2
+ import { ConstructableModuleWrapper, Module, ModuleWrapper } from '@xyo-network/module'
3
+ import { useWrapperWallet } from '@xyo-network/react-wallet'
4
+ import { WalletInstance } from '@xyo-network/wallet-model'
5
+ import { useEffect, useState } from 'react'
6
+
7
+ export const WrappedModuleHookFactory = <TModuleWrapper extends ModuleWrapper>(
8
+ wrapperObject: ConstructableModuleWrapper<TModuleWrapper>,
9
+ name?: string,
10
+ ) => {
11
+ const useHook = (module?: Module, wallet?: WalletInstance, logger?: Logger): [TModuleWrapper | undefined, Error | undefined] => {
12
+ logger?.debug(`Render: ${name}`)
13
+ const wrapperWallet = useWrapperWallet()
14
+
15
+ const [wrapper, setWrapper] = useState<TModuleWrapper>()
16
+ const [error, setError] = useState<Error>()
17
+
18
+ useEffect(() => {
19
+ const walletToUse = wallet || wrapperWallet
20
+ if (module && walletToUse) {
21
+ try {
22
+ const wrapper = wrapperObject.wrap(module, walletToUse)
23
+ setWrapper(wrapper)
24
+ setError(undefined)
25
+ } catch (ex) {
26
+ setWrapper(undefined)
27
+ setError(ex as Error)
28
+ }
29
+ } else {
30
+ setWrapper(undefined)
31
+ setError(undefined)
32
+ }
33
+ }, [module, wallet, wrapperWallet])
34
+
35
+ return [wrapper, error]
36
+ }
37
+ return useHook
38
+ }
39
+
40
+ export const useWrappedModule = WrappedModuleHookFactory(ModuleWrapper, 'useWrappedModule')