@xyo-network/react-payload 2.26.9 → 2.26.10
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/cjs/components/Details/DataDetails.d.ts +1 -1
- package/dist/cjs/components/Details/DataDetails.js +2 -2
- package/dist/cjs/components/Details/DataDetails.js.map +1 -1
- package/dist/cjs/components/Details/Details.d.ts +1 -1
- package/dist/cjs/components/Details/HashSourceDetails.d.ts +1 -1
- package/dist/cjs/components/Details/HashSourceDetails.js +4 -4
- package/dist/cjs/components/Details/HashSourceDetails.js.map +1 -1
- package/dist/cjs/components/Details/JsonDetails.d.ts +1 -1
- package/dist/cjs/components/Details/MetaDetails.d.ts +2 -2
- package/dist/cjs/components/Details/ValidationDetails/ValidationDetails.js +4 -4
- package/dist/cjs/components/Details/ValidationDetails/ValidationDetails.js.map +1 -1
- package/dist/cjs/components/Details/ValidationDetails/ValidationDetailsProps.d.ts +2 -2
- package/dist/cjs/components/Table/Table.d.ts +2 -2
- package/dist/cjs/components/Table/TableRow.d.ts +2 -2
- package/dist/cjs/components/Table/TableRow.js +3 -3
- package/dist/cjs/components/Table/TableRow.js.map +1 -1
- package/dist/cjs/hooks/lib/findHuriNetwork.d.ts +1 -1
- package/dist/cjs/hooks/useGetSchema.d.ts +2 -3
- package/dist/cjs/hooks/useGetSchema.js +2 -2
- package/dist/cjs/hooks/useGetSchema.js.map +1 -1
- package/dist/cjs/hooks/useHuriHash.d.ts +1 -1
- package/dist/cjs/hooks/useHuriHash.js +2 -2
- package/dist/cjs/hooks/useHuriHash.js.map +1 -1
- package/dist/cjs/hooks/usePayload.d.ts +1 -1
- package/dist/cjs/hooks/usePayload.js +3 -8
- package/dist/cjs/hooks/usePayload.js.map +1 -1
- package/dist/cjs/hooks/useResolveHuri.d.ts +1 -1
- package/dist/cjs/hooks/useResolveHuri.js +2 -2
- package/dist/cjs/hooks/useResolveHuri.js.map +1 -1
- package/dist/esm/hooks/useHuriHash.d.ts +4 -1
- package/dist/esm/hooks/useHuriHash.js +9 -3
- package/dist/esm/hooks/useHuriHash.js.map +1 -1
- package/dist/esm/hooks/usePayload.d.ts +1 -1
- package/dist/esm/hooks/usePayload.js +3 -3
- package/dist/esm/hooks/usePayload.js.map +1 -1
- package/dist/esm/hooks/useResolveHuri.d.ts +1 -1
- package/dist/esm/hooks/useResolveHuri.js +14 -7
- package/dist/esm/hooks/useResolveHuri.js.map +1 -1
- package/package.json +8 -8
- package/src/hooks/useHuriHash.stories.tsx +36 -11
- package/src/hooks/useHuriHash.tsx +16 -4
- package/src/hooks/usePayload.tsx +4 -4
- package/src/hooks/useResolveHuri.tsx +17 -9
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { XyoPayload } from '@xyo-network/
|
|
2
|
+
import { XyoPayload } from '@xyo-network/core';
|
|
3
3
|
import { PropertyProps } from '@xyo-network/react-property';
|
|
4
4
|
import { SizeProp } from '@xyo-network/react-shared';
|
|
5
5
|
export declare type PayloadDataDetailsProps = PropertyProps & {
|
|
@@ -7,14 +7,14 @@ const ContentCopy_1 = tslib_1.__importDefault(require("@mui/icons-material/Conte
|
|
|
7
7
|
const Visibility_1 = tslib_1.__importDefault(require("@mui/icons-material/Visibility"));
|
|
8
8
|
const material_1 = require("@mui/material");
|
|
9
9
|
const react_button_1 = require("@xylabs/react-button");
|
|
10
|
-
const
|
|
10
|
+
const core_1 = require("@xyo-network/core");
|
|
11
11
|
const react_property_1 = require("@xyo-network/react-property");
|
|
12
12
|
const react_1 = require("react");
|
|
13
13
|
const HashSourceDetails_1 = require("./HashSourceDetails");
|
|
14
14
|
const PayloadDataDetails = (_a) => {
|
|
15
15
|
var _b;
|
|
16
16
|
var { size, badge, payload } = _a, props = tslib_1.__rest(_a, ["size", "badge", "payload"]);
|
|
17
|
-
const wrapper = payload ? new
|
|
17
|
+
const wrapper = payload ? new core_1.XyoPayloadWrapper(payload) : undefined;
|
|
18
18
|
const [viewSourceOpen, setViewSourceOpen] = (0, react_1.useState)(false);
|
|
19
19
|
const hash = wrapper === null || wrapper === void 0 ? void 0 : wrapper.hash;
|
|
20
20
|
let elevation = 2;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataDetails.js","sourceRoot":"","sources":["../../../../src/components/Details/DataDetails.tsx"],"names":[],"mappings":";;;;;AAAA,0FAA6D;AAC7D,wFAA2D;AAC3D,4CAAiF;AACjF,uDAA+C;AAC/C,
|
|
1
|
+
{"version":3,"file":"DataDetails.js","sourceRoot":"","sources":["../../../../src/components/Details/DataDetails.tsx"],"names":[],"mappings":";;;;;AAAA,0FAA6D;AAC7D,wFAA2D;AAC3D,4CAAiF;AACjF,uDAA+C;AAC/C,4CAAiE;AACjE,gEAAqF;AAErF,iCAAgC;AAEhC,2DAA8D;AAQvD,MAAM,kBAAkB,GAAsC,CAAC,EAAkC,EAAE,EAAE;;QAAtC,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,OAAY,EAAP,KAAK,sBAAhC,4BAAkC,CAAF;IACpG,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,wBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IAEpE,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAA;IAC3D,MAAM,IAAI,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,CAAA;IAE1B,IAAI,SAAS,GAAG,CAAC,CAAA;IACjB,IAAI,KAAK,CAAC,KAAK,EAAE;QACf,SAAS,IAAI,MAAA,KAAK,CAAC,SAAS,mCAAI,CAAC,CAAA;KAClC;IAED,MAAM,OAAO,GAAqB;QAChC;YACE,IAAI,EAAE,uBAAC,oBAAc,KAAG;YACxB,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC;SACvC;QACD;YAC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@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { FlexBoxProps } from '@xylabs/react-flexbox';
|
|
3
|
-
import { XyoPayload } from '@xyo-network/
|
|
3
|
+
import { XyoPayload } from '@xyo-network/core';
|
|
4
4
|
export interface PayloadHashSourceDetailsProps extends FlexBoxProps {
|
|
5
5
|
noTitle?: boolean;
|
|
6
6
|
payload?: XyoPayload;
|
|
@@ -5,15 +5,15 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
6
|
const ContentCopy_1 = tslib_1.__importDefault(require("@mui/icons-material/ContentCopy"));
|
|
7
7
|
const material_1 = require("@mui/material");
|
|
8
|
+
const react_common_1 = require("@xylabs/react-common");
|
|
8
9
|
const react_flexbox_1 = require("@xylabs/react-flexbox");
|
|
9
|
-
const
|
|
10
|
-
const payload_1 = require("@xyo-network/payload");
|
|
10
|
+
const core_1 = require("@xyo-network/core");
|
|
11
11
|
const PayloadHashSourceDetails = (_a) => {
|
|
12
12
|
var _b;
|
|
13
13
|
var { noTitle = false, payload } = _a, props = tslib_1.__rest(_a, ["noTitle", "payload"]);
|
|
14
14
|
const theme = (0, material_1.useTheme)();
|
|
15
|
-
const payloadWrapper = payload ? new
|
|
16
|
-
return ((0, jsx_runtime_1.jsxs)(react_flexbox_1.FlexCol, Object.assign({ alignItems: "stretch" }, props, { children: [noTitle ? null : ((0, jsx_runtime_1.jsxs)(react_flexbox_1.FlexRow, Object.assign({ margin: 1, justifyContent: "flex-start" }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { children: "Hash Source" }), (0, jsx_runtime_1.jsx)(
|
|
15
|
+
const payloadWrapper = payload ? new core_1.XyoPayloadWrapper(payload) : null;
|
|
16
|
+
return ((0, jsx_runtime_1.jsxs)(react_flexbox_1.FlexCol, Object.assign({ alignItems: "stretch" }, props, { children: [noTitle ? null : ((0, jsx_runtime_1.jsxs)(react_flexbox_1.FlexRow, Object.assign({ margin: 1, justifyContent: "flex-start" }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { children: "Hash Source" }), (0, jsx_runtime_1.jsx)(react_common_1.QuickTipButton, Object.assign({ title: "Hash Source" }, { children: "The actual string used to generate the hash (SHA256)" }))] }))), (0, jsx_runtime_1.jsxs)(react_flexbox_1.FlexRow, { children: [(0, jsx_runtime_1.jsx)(react_flexbox_1.FlexGrowRow, Object.assign({ background: true, border: 1, borderColor: theme.palette.divider, justifyContent: "start" }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ padding: 2, fontFamily: "monospace", variant: "body1", sx: { overflowWrap: 'break-word', wordBreak: 'break-all' } }, { children: (_b = payloadWrapper === null || payloadWrapper === void 0 ? void 0 : payloadWrapper.stringified) !== null && _b !== void 0 ? _b : '' })) })), (0, jsx_runtime_1.jsx)(material_1.IconButton, { children: (0, jsx_runtime_1.jsx)(ContentCopy_1.default, {}) })] }), noTitle ? ((0, jsx_runtime_1.jsx)(react_flexbox_1.FlexRow, Object.assign({ margin: 1, justifyContent: "flex-start" }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: "The actual string used to generate the hash (SHA256). This can be used to validate the hash manually." })) }))) : null] })));
|
|
17
17
|
};
|
|
18
18
|
exports.PayloadHashSourceDetails = PayloadHashSourceDetails;
|
|
19
19
|
//# sourceMappingURL=HashSourceDetails.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HashSourceDetails.js","sourceRoot":"","sources":["../../../../src/components/Details/HashSourceDetails.tsx"],"names":[],"mappings":";;;;;AAAA,0FAA6D;AAC7D,4CAAgE;AAChE,yDAAmF;AACnF,
|
|
1
|
+
{"version":3,"file":"HashSourceDetails.js","sourceRoot":"","sources":["../../../../src/components/Details/HashSourceDetails.tsx"],"names":[],"mappings":";;;;;AAAA,0FAA6D;AAC7D,4CAAgE;AAChE,uDAAqD;AACrD,yDAAmF;AACnF,4CAAiE;A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,CACX,CAAA;AACH,CAAC,CAAA;AA7BY,QAAA,wBAAwB,4BA6BpC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { XyoPayload } from '@xyo-network/
|
|
2
|
+
import { XyoPayload } from '@xyo-network/core';
|
|
3
3
|
import { PropertyGroupProps } from '@xyo-network/react-property';
|
|
4
4
|
import { ReactJsonViewProps } from 'react-json-view';
|
|
5
5
|
export declare type PayloadJsonDetailsProps = PropertyGroupProps & {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
2
|
+
import { XyoPayload } from '@xyo-network/core';
|
|
3
3
|
import { PropertyGroupProps } from '@xyo-network/react-property';
|
|
4
4
|
export declare type PayloadMetaDetailsProps = PropertyGroupProps & {
|
|
5
|
-
value?:
|
|
5
|
+
value?: XyoPayload;
|
|
6
6
|
archivePath?: string;
|
|
7
7
|
};
|
|
8
8
|
export declare const PayloadMetaDetails: React.FC<PayloadMetaDetailsProps>;
|
|
@@ -5,15 +5,15 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
6
|
const material_1 = require("@mui/material");
|
|
7
7
|
const react_flexbox_1 = require("@xylabs/react-flexbox");
|
|
8
|
-
const
|
|
8
|
+
const core_1 = require("@xyo-network/core");
|
|
9
9
|
const react_property_1 = require("@xyo-network/react-property");
|
|
10
10
|
const react_schema_1 = require("@xyo-network/react-schema");
|
|
11
11
|
const PayloadValidationDetails = (_a) => {
|
|
12
12
|
var _b, _c, _d;
|
|
13
13
|
var { viewSchemaUrl, skipMeta = false, skipBody = false, value } = _a, props = tslib_1.__rest(_a, ["viewSchemaUrl", "skipMeta", "skipBody", "value"]);
|
|
14
|
-
const validator = value ? new
|
|
15
|
-
const bodyErrors = skipBody ? [] : (_b = validator === null || validator === void 0 ? void 0 : validator.body.
|
|
16
|
-
const metaErrors = skipMeta ? [] : (_c = validator === null || validator === void 0 ? void 0 : validator.meta.
|
|
14
|
+
const validator = value ? new core_1.XyoPayloadValidator(value) : undefined;
|
|
15
|
+
const bodyErrors = skipBody ? [] : (_b = validator === null || validator === void 0 ? void 0 : validator.body.all()) !== null && _b !== void 0 ? _b : [];
|
|
16
|
+
const metaErrors = skipMeta ? [] : (_c = validator === null || validator === void 0 ? void 0 : validator.meta.all()) !== null && _c !== void 0 ? _c : [];
|
|
17
17
|
const errors = [...bodyErrors, ...metaErrors];
|
|
18
18
|
let elevation = 2;
|
|
19
19
|
if (props.paper) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ValidationDetails.js","sourceRoot":"","sources":["../../../../../src/components/Details/ValidationDetails/ValidationDetails.tsx"],"names":[],"mappings":";;;;;AAAA,4CAA0C;AAC1C,yDAA+C;AAC/C,
|
|
1
|
+
{"version":3,"file":"ValidationDetails.js","sourceRoot":"","sources":["../../../../../src/components/Details/ValidationDetails/ValidationDetails.tsx"],"names":[],"mappings":";;;;;AAAA,4CAA0C;AAC1C,yDAA+C;AAC/C,4CAAuD;AACvD,gEAAqE;AACrE,4DAA0D;AAInD,MAAM,wBAAwB,GAA4C,CAAC,EAAsE,EAAE,EAAE;;QAA1E,EAAE,aAAa,EAAE,QAAQ,GAAG,KAAK,EAAE,QAAQ,GAAG,KAAK,EAAE,KAAK,OAAY,EAAP,KAAK,sBAApE,kDAAsE,CAAF;IACpJ,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,0BAAmB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IAEpE,MAAM,UAAU,GAAG,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,IAAI,CAAC,GAAG,EAAE,mCAAI,EAAE,CAAA;IAC9D,MAAM,UAAU,GAAG,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,M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-1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { XyoPayload } from '@xyo-network/core';
|
|
2
2
|
import { PropertyGroupProps } from '@xyo-network/react-property';
|
|
3
3
|
export declare type PayloadValidationDetailsProps = PropertyGroupProps & {
|
|
4
4
|
skipBody?: boolean;
|
|
5
5
|
skipMeta?: boolean;
|
|
6
|
-
value?:
|
|
6
|
+
value?: XyoPayload;
|
|
7
7
|
viewSchemaUrl?: string;
|
|
8
8
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { TableProps } from '@mui/material';
|
|
3
|
-
import { XyoPayload
|
|
3
|
+
import { XyoPayload } from '@xyo-network/core';
|
|
4
4
|
import { PayloadTableColumnConfig } from './PayloadTableColumnConfig';
|
|
5
5
|
export interface PayloadTableProps extends TableProps {
|
|
6
6
|
exploreDomain?: string;
|
|
7
7
|
onRowClick?: (value: XyoPayload) => void;
|
|
8
|
-
payloads?:
|
|
8
|
+
payloads?: XyoPayload[] | null;
|
|
9
9
|
columns?: PayloadTableColumnConfig;
|
|
10
10
|
}
|
|
11
11
|
export declare const PayloadTable: React.FC<PayloadTableProps>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { TableRowProps } from '@mui/material';
|
|
3
|
-
import {
|
|
3
|
+
import { XyoPayload } from '@xyo-network/core';
|
|
4
4
|
import { PayloadTableColumnConfig } from './PayloadTableColumnConfig';
|
|
5
5
|
export interface PayloadTableRowProps extends TableRowProps {
|
|
6
|
-
payload?:
|
|
6
|
+
payload?: XyoPayload;
|
|
7
7
|
exploreDomain?: string;
|
|
8
8
|
columns?: PayloadTableColumnConfig;
|
|
9
9
|
network?: string;
|
|
@@ -5,7 +5,7 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
6
|
const material_1 = require("@mui/material");
|
|
7
7
|
const react_shared_1 = require("@xylabs/react-shared");
|
|
8
|
-
const
|
|
8
|
+
const core_1 = require("@xyo-network/core");
|
|
9
9
|
const react_network_1 = require("@xyo-network/react-network");
|
|
10
10
|
const react_shared_2 = require("@xyo-network/react-shared");
|
|
11
11
|
const luxon_1 = require("luxon");
|
|
@@ -16,7 +16,7 @@ const PayloadTableRow = (_a) => {
|
|
|
16
16
|
var { exploreDomain, network: networkProp, payload, columns = (0, PayloadTableColumnConfig_1.payloadTableColumnConfigDefaults)() } = _a, props = tslib_1.__rest(_a, ["exploreDomain", "network", "payload", "columns"]);
|
|
17
17
|
const breakPoint = (0, react_shared_1.useBreakpoint)();
|
|
18
18
|
const timeStamp = (payload === null || payload === void 0 ? void 0 : payload._timestamp) ? luxon_1.DateTime.fromMillis(payload === null || payload === void 0 ? void 0 : payload._timestamp) : undefined;
|
|
19
|
-
const wrapper = payload ? new
|
|
19
|
+
const wrapper = payload ? new core_1.XyoPayloadWrapper(payload) : undefined;
|
|
20
20
|
const { network } = (0, react_network_1.useNetwork)();
|
|
21
21
|
const archive = (props) => ((0, jsx_runtime_1.jsx)(material_1.TableCell, Object.assign({ align: "center" }, props, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontFamily: "monospace", variant: "body2", noWrap: true }, { children: payload === null || payload === void 0 ? void 0 : payload._archive })) }), "archive"));
|
|
22
22
|
const client = (props) => ((0, jsx_runtime_1.jsx)(material_1.TableCell, Object.assign({ align: "center" }, props, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontFamily: "monospace", variant: "body2", noWrap: true }, { children: payload === null || payload === void 0 ? void 0 : payload._client })) }), "client"));
|
|
@@ -24,7 +24,7 @@ const PayloadTableRow = (_a) => {
|
|
|
24
24
|
const hash = (props) => ((0, jsx_runtime_1.jsx)(react_shared_2.HashTableCell, Object.assign({ width: "100%", value: payload === null || payload === void 0 ? void 0 : payload._hash, archive: payload === null || payload === void 0 ? void 0 : payload._archive, dataType: "payload", exploreDomain: exploreDomain, network: networkProp !== null && networkProp !== void 0 ? networkProp : network === null || network === void 0 ? void 0 : network.slug }, props), "hash"));
|
|
25
25
|
const schema = (props) => ((0, jsx_runtime_1.jsx)(material_1.TableCell, Object.assign({ align: "center" }, props, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontFamily: "monospace", variant: "body2", noWrap: true }, { children: payload === null || payload === void 0 ? void 0 : payload.schema })) }), "payloads"));
|
|
26
26
|
const time = (props) => ((0, jsx_runtime_1.jsx)(material_1.TableCell, Object.assign({ align: "center" }, props, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontFamily: "monospace", variant: "body2", noWrap: true }, { children: timeStamp === null || timeStamp === void 0 ? void 0 : timeStamp.toLocaleString(luxon_1.DateTime.TIME_SIMPLE) })) }), "time"));
|
|
27
|
-
const isValid = wrapper ? new
|
|
27
|
+
const isValid = wrapper ? new core_1.XyoPayloadWrapperValidator(wrapper).all().length === 0 : undefined;
|
|
28
28
|
const valid = (props) => ((0, jsx_runtime_1.jsx)(material_1.TableCell, Object.assign({ align: "center" }, props, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontFamily: "monospace", variant: "body2", noWrap: true }, { children: isValid === undefined ? (0, jsx_runtime_1.jsx)(md_1.MdDone, { fontSize: 18, color: "yellow" }) : isValid ? (0, jsx_runtime_1.jsx)(md_1.MdDone, { fontSize: 18, color: "green" }) : (0, jsx_runtime_1.jsx)(md_1.MdClear, { color: "red", fontSize: 18 }) })) }), "valid"));
|
|
29
29
|
const tableCells = {
|
|
30
30
|
archive,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableRow.js","sourceRoot":"","sources":["../../../../src/components/Table/TableRow.tsx"],"names":[],"mappings":";;;;;AAAA,4CAA8F;AAC9F,uDAAoD;AACpD,
|
|
1
|
+
{"version":3,"file":"TableRow.js","sourceRoot":"","sources":["../../../../src/components/Table/TableRow.tsx"],"names":[],"mappings":";;;;;AAAA,4CAA8F;AA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CACZ,CAAC,CAAC,CAAC,IAAI,CAAA;AACV,CAAC,CAAA;AAtFY,QAAA,eAAe,mBAsF3B"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
+
import { Huri } from '@xyo-network/core';
|
|
1
2
|
import { XyoNetworkPayload } from '@xyo-network/network';
|
|
2
|
-
import { Huri } from '@xyo-network/payload';
|
|
3
3
|
export declare const findHuriNetwork: (huriInstance: Huri, networks?: XyoNetworkPayload[]) => XyoNetworkPayload | undefined;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { XyoApiError } from '@xyo-network/api';
|
|
2
|
-
import { XyoSchemaPayload } from '@xyo-network/payload';
|
|
3
2
|
/**
|
|
4
3
|
* Gets a Huri and schema payload from a schema string
|
|
5
4
|
*/
|
|
6
5
|
declare const useGetSchemaPayload: (schema?: string) => {
|
|
7
6
|
apiError: XyoApiError<any, any> | undefined;
|
|
8
7
|
notFound: boolean;
|
|
9
|
-
schemaHuri: import("@xyo-network/
|
|
10
|
-
schemaPayload:
|
|
8
|
+
schemaHuri: import("@xyo-network/core").Huri | undefined;
|
|
9
|
+
schemaPayload: import("@xyo-network/core").XyoPayloadFull | null | undefined;
|
|
11
10
|
};
|
|
12
11
|
export { useGetSchemaPayload };
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useGetSchemaPayload = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_shared_1 = require("@xylabs/react-shared");
|
|
6
|
-
const
|
|
6
|
+
const core_1 = require("@xyo-network/core");
|
|
7
7
|
const utils_1 = require("@xyo-network/utils");
|
|
8
8
|
const react_1 = require("react");
|
|
9
9
|
/**
|
|
@@ -42,7 +42,7 @@ const useGetSchemaPayload = (schema) => {
|
|
|
42
42
|
apiError,
|
|
43
43
|
notFound,
|
|
44
44
|
schemaHuri: schemaCacheEntry === null || schemaCacheEntry === void 0 ? void 0 : schemaCacheEntry.huri,
|
|
45
|
-
schemaPayload: schemaCacheEntry ? new
|
|
45
|
+
schemaPayload: schemaCacheEntry ? new core_1.XyoPayloadBuilder(schemaCacheEntry === null || schemaCacheEntry === void 0 ? void 0 : schemaCacheEntry.payload).fields(schemaCacheEntry.payload).build() : schemaCacheEntry,
|
|
46
46
|
};
|
|
47
47
|
};
|
|
48
48
|
exports.useGetSchemaPayload = useGetSchemaPayload;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGetSchema.js","sourceRoot":"","sources":["../../../src/hooks/useGetSchema.tsx"],"names":[],"mappings":";;;;AAAA,uDAAqD;AAErD,
|
|
1
|
+
{"version":3,"file":"useGetSchema.js","sourceRoot":"","sources":["../../../src/hooks/useGetSchema.tsx"],"names":[],"mappings":";;;;AAAA,uDAAqD;AAErD,4CAAqD;AACrD,8CAAwE;AACxE,iCAAgC;AAEhC;;GAEG;AACH,MAAM,mBAAmB,GAAG,CAAC,MAAe,EAAE,EAAE;IAC9C,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAA;IAC/C,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,IAAA,gBAAQ,GAAe,CAAA;IACvD,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,IAAA,gBAAQ,GAA0C,CAAA;IAClG,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,IAAA,gBAAQ,GAAU,CAAA;IAExD,IAAA,6BAAc;IACZ,uDAAuD;IACvD,CAAO,OAAO,EAAE,EAAE;QAChB,MAAM,YAAY,GAAG,CAAC,QAAQ,IAAI,CAAC,gBAAgB,IAAI,CAAC,QAAQ,CAAA;QAChE,MAAM,aAAa,GAAG,MAAM,KAAK,WAAW,CAAA;QAE5C,IAAI,CAAC,MAAM,IAAI,YAAY,CAAC,IAAI,CAAC,MAAM,IAAI,aAAa,CAAC,EAAE;YACzD,IAAI;gBACF,MAAM,gBAAgB,GAAG,MAAM,sBAAc,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;gBAClE,IAAI,OAAO,EAAE,EAAE;oBACb,mBAAmB,CAAC,gBAAgB,CAAC,CAAA;oBACrC,WAAW,CAAC,gBAAgB,KAAK,IAAI,IAAI,gBAAgB,KAAK,SAAS,CAAC,CAAA;iBACzE;aACF;YAAC,OAAO,CAAC,EAAE;gBACV,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;gBAChB,IAAI,OAAO,EAAE,EAAE;oBACb,WAAW,CAAC,CAAgB,CAAC,CAAA;iBAC9B;aACF;SACF;QACD,IAAI,aAAa,EAAE;YACjB,cAAc,CAAC,MAAM,CAAC,CAAA;SACvB;IACH,CAAC,CAAA,EACD,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,gBAAgB,CAAC,CAC5D,CAAA;IAED,OAAO;QACL,QAAQ;QACR,QAAQ;QACR,UAAU,EAAE,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,IAAI;QAClC,aAAa,EAAE,gBAAgB,CAAC,CAAC,CAAC,IAAI,wBAAiB,CAAC,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,OAAO,CAAC,CAAC,MAAM,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,gBAAgB;KAC/I,CAAA;AACH,CAAC,CAAA;AAEQ,kDAAmB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { XyoApiError } from '@xyo-network/api';
|
|
2
|
-
import { Huri, XyoPayload } from '@xyo-network/
|
|
2
|
+
import { Huri, XyoPayload } from '@xyo-network/core';
|
|
3
3
|
import { FetchHuriHashOptions } from './lib';
|
|
4
4
|
declare const useHuriHash: (huriOrHash?: string | Huri, huriUri?: string, options?: FetchHuriHashOptions) => [XyoPayload | undefined, boolean, XyoApiError | undefined];
|
|
5
5
|
export { useHuriHash };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useHuriHash = void 0;
|
|
4
|
-
const
|
|
4
|
+
const core_1 = require("@xyo-network/core");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const usePayload_1 = require("./usePayload");
|
|
7
7
|
const useResolveHuri_1 = require("./useResolveHuri");
|
|
@@ -11,7 +11,7 @@ const useHuriHash = (huriOrHash, huriUri, options) => {
|
|
|
11
11
|
if (typeof huriOrHash === 'string') {
|
|
12
12
|
return huriOrHash;
|
|
13
13
|
}
|
|
14
|
-
if (huriOrHash instanceof
|
|
14
|
+
if (huriOrHash instanceof core_1.Huri) {
|
|
15
15
|
return huriOrHash.hash;
|
|
16
16
|
}
|
|
17
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useHuriHash.js","sourceRoot":"","sources":["../../../src/hooks/useHuriHash.tsx"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"useHuriHash.js","sourceRoot":"","sources":["../../../src/hooks/useHuriHash.tsx"],"names":[],"mappings":";;;AACA,4CAAoD;AACpD,iCAAmC;AAGnC,6CAAyC;AACzC,qDAAiD;AAEjD,MAAM,WAAW,GAAG,CAAC,UAA0B,EAAE,OAAgB,EAAE,OAA8B,EAA8D,EAAE;IAC/J,MAAM,IAAI,GAAG,IAAA,mBAAW,EAAC,CAAC,UAA0B,EAAE,EAAE;QACtD,IAAI,UAAU,EAAE;YACd,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE;gBAClC,OAAO,UAAU,CAAA;aAClB;YACD,IAAI,UAAU,YAAY,WAAI,EAAE;gBAC9B,OAAO,UAAU,CAAC,IAAI,CAAA;aACvB;SACF;IACH,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,GAAG,IAAA,uBAAU,EAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAA;IAClE,MAAM,CAAC,WAAW,EAAE,mBAAmB,EAAE,YAAY,CAAC,GAAG,IAAA,+BAAc,EAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAA;IAEnG,OAAO,CAAC,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,WAAW,EAAE,mBAAmB,EAAE,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,YAAY,CAAC,CAAA;AAChF,CAAC,CAAA;AAEQ,kCAAW"}
|
|
@@ -12,19 +12,14 @@ const usePayload = (hash) => {
|
|
|
12
12
|
const [notFound, setNotFound] = (0, react_1.useState)(false);
|
|
13
13
|
const [apiError, setApiError] = (0, react_1.useState)();
|
|
14
14
|
const [payload, setPayload] = (0, react_1.useState)();
|
|
15
|
-
const reset = () => {
|
|
16
|
-
setPayload(undefined);
|
|
17
|
-
setApiError(undefined);
|
|
18
|
-
setNotFound(false);
|
|
19
|
-
};
|
|
20
15
|
(0, react_shared_1.useAsyncEffect)(
|
|
21
16
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
22
17
|
(mounted) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
-
if (
|
|
18
|
+
if (hash && hash.length > 0) {
|
|
24
19
|
try {
|
|
25
20
|
const result = yield (api === null || api === void 0 ? void 0 : api.archive(archive).payload.hash(hash).get());
|
|
26
21
|
if (mounted()) {
|
|
27
|
-
|
|
22
|
+
setApiError(undefined);
|
|
28
23
|
if (result === null || result === void 0 ? void 0 : result.length) {
|
|
29
24
|
setPayload(result[0]);
|
|
30
25
|
}
|
|
@@ -35,8 +30,8 @@ const usePayload = (hash) => {
|
|
|
35
30
|
}
|
|
36
31
|
}
|
|
37
32
|
catch (e) {
|
|
38
|
-
reset();
|
|
39
33
|
setApiError(e);
|
|
34
|
+
setPayload(undefined);
|
|
40
35
|
console.error(e);
|
|
41
36
|
}
|
|
42
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePayload.js","sourceRoot":"","sources":["../../../src/hooks/usePayload.tsx"],"names":[],"mappings":";;;;AAAA,uDAAqD;AAGrD,8DAAuD;AACvD,0EAAkE;AAClE,iCAAgC;AAEzB,MAAM,UAAU,GAAG,CAAC,IAAa,EAA8D,EAAE;IACtG,MAAM,EAAE,GAAG,EAAE,GAAG,IAAA,qCAAe,GAAE,CAAA;IACjC,MAAM,EAAE,OAAO,EAAE,GAAG,IAAA,0BAAU,GAAE,CAAA;IAChC,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAA;IAC/C,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,IAAA,gBAAQ,GAAe,CAAA;IACvD,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,IAAA,gBAAQ,GAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"usePayload.js","sourceRoot":"","sources":["../../../src/hooks/usePayload.tsx"],"names":[],"mappings":";;;;AAAA,uDAAqD;AAGrD,8DAAuD;AACvD,0EAAkE;AAClE,iCAAgC;AAEzB,MAAM,UAAU,GAAG,CAAC,IAAa,EAA8D,EAAE;IACtG,MAAM,EAAE,GAAG,EAAE,GAAG,IAAA,qCAAe,GAAE,CAAA;IACjC,MAAM,EAAE,OAAO,EAAE,GAAG,IAAA,0BAAU,GAAE,CAAA;IAChC,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAA;IAC/C,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,IAAA,gBAAQ,GAAe,CAAA;IACvD,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,IAAA,gBAAQ,GAAc,CAAA;IACpD,IAAA,6BAAc;IACZ,uDAAuD;IACvD,CAAO,OAAO,EAAE,EAAE;QAChB,IAAI,IAAI,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;YAC3B,IAAI;gBACF,MAAM,MAAM,GAAG,MAAM,CAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,CAAA,CAAA;gBACnE,IAAI,OAAO,EAAE,EAAE;oBACb,WAAW,CAAC,SAAS,CAAC,CAAA;oBACtB,IAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,EAAE;wBAClB,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;qBACtB;yBAAM,IAAI,MAAM,EAAE;wBACjB,WAAW,CAAC,IAAI,CAAC,CAAA;wBACjB,UAAU,CAAC,SAAS,CAAC,CAAA;qBACtB;iBACF;aACF;YAAC,OAAO,CAAC,EAAE;gBACV,WAAW,CAAC,CAAgB,CAAC,CAAA;gBAC7B,UAAU,CAAC,SAAS,CAAC,CAAA;gBACrB,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;aACjB;SACF;IACH,CAAC,CAAA,EACD,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,CACrB,CAAA;IACD,OAAO,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAA;AACtC,CAAC,CAAA;AA/BY,QAAA,UAAU,cA+BtB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { XyoApiError } from '@xyo-network/api';
|
|
2
|
-
import { XyoPayload } from '@xyo-network/
|
|
2
|
+
import { XyoPayload } from '@xyo-network/core';
|
|
3
3
|
import { FetchHuriHashOptions } from './lib';
|
|
4
4
|
declare const useResolveHuri: (huriUri?: string, dependentNotFound?: boolean, options?: FetchHuriHashOptions) => [XyoPayload | undefined, boolean, XyoApiError | undefined];
|
|
5
5
|
export { useResolveHuri };
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useResolveHuri = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_shared_1 = require("@xylabs/react-shared");
|
|
6
|
-
const
|
|
6
|
+
const core_1 = require("@xyo-network/core");
|
|
7
7
|
const react_network_1 = require("@xyo-network/react-network");
|
|
8
8
|
const react_1 = require("react");
|
|
9
9
|
const lib_1 = require("./lib");
|
|
@@ -18,7 +18,7 @@ const useResolveHuri = (huriUri, dependentNotFound, options) => {
|
|
|
18
18
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
19
19
|
(mounted) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
20
20
|
if ((dependentNotFound === undefined || dependentNotFound) && huriUri && network !== huriNetwork) {
|
|
21
|
-
const huriInstance = new
|
|
21
|
+
const huriInstance = new core_1.Huri(huriUri);
|
|
22
22
|
const foundHuriNetwork = (0, lib_1.findHuriNetwork)(huriInstance, networks);
|
|
23
23
|
// Update when we found a huri network and it doesn't match the current one
|
|
24
24
|
if (foundHuriNetwork && mounted()) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useResolveHuri.js","sourceRoot":"","sources":["../../../src/hooks/useResolveHuri.tsx"],"names":[],"mappings":";;;;AAAA,uDAAqD;
|
|
1
|
+
{"version":3,"file":"useResolveHuri.js","sourceRoot":"","sources":["../../../src/hooks/useResolveHuri.tsx"],"names":[],"mappings":";;;;AAAA,uDAAqD;AAErD,4CAAoD;AAEpD,8DAAuD;AACvD,iCAAgC;AAEhC,+BAA6D;AAE7D,MAAM,cAAc,GAAG,CAAC,OAAgB,EAAE,iBAA2B,EAAE,OAA8B,EAA8D,EAAE;IACnK,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,IAAA,0BAAU,GAAE,CAAA;IACtD,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,IAAA,gBAAQ,GAAqB,CAAA;IACnE,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,IAAA,gBAAQ,GAAc,C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EAAE,QAAQ,EAAE,iBAAiB,EAAE,UAAU,EAAE,mBAAmB,CAAC,CAC9F,CAAA;IAED,OAAO,CAAC,WAAW,EAAE,mBAAmB,EAAE,YAAY,CAAC,CAAA;AACzD,CAAC,CAAA;AAEQ,wCAAc"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { XyoApiError } from '@xyo-network/api';
|
|
2
2
|
import { Huri, XyoPayload } from '@xyo-network/payload';
|
|
3
3
|
import { FetchHuriHashOptions } from './lib';
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Resolve a hash or a huri regardless of network
|
|
6
|
+
*/
|
|
7
|
+
declare const useHuriHash: (huriOrHash?: string | Huri, huriUri?: string, options?: FetchHuriHashOptions) => [XyoPayload | undefined, boolean, XyoApiError | undefined, boolean | undefined];
|
|
5
8
|
export { useHuriHash };
|
|
@@ -2,6 +2,9 @@ import { Huri } from '@xyo-network/payload';
|
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
3
|
import { usePayload } from './usePayload';
|
|
4
4
|
import { useResolveHuri } from './useResolveHuri';
|
|
5
|
+
/**
|
|
6
|
+
* Resolve a hash or a huri regardless of network
|
|
7
|
+
*/
|
|
5
8
|
const useHuriHash = (huriOrHash, huriUri, options) => {
|
|
6
9
|
const hash = useCallback((huriOrHash) => {
|
|
7
10
|
if (huriOrHash) {
|
|
@@ -13,9 +16,12 @@ const useHuriHash = (huriOrHash, huriUri, options) => {
|
|
|
13
16
|
}
|
|
14
17
|
}
|
|
15
18
|
}, []);
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
const foundHash = hash(huriOrHash);
|
|
20
|
+
// Optimistically try to grab the has from the current network and archive
|
|
21
|
+
const [payload, notFound, apiError] = usePayload(foundHash);
|
|
22
|
+
// If payload isn't found, fallback to the huriUri
|
|
23
|
+
const [huriPayload, huriPayloadNotFound, huriApiError, networkNotFound] = useResolveHuri(huriUri, notFound, options);
|
|
24
|
+
return [payload ?? huriPayload, huriPayloadNotFound, apiError ?? huriApiError, networkNotFound];
|
|
19
25
|
};
|
|
20
26
|
export { useHuriHash };
|
|
21
27
|
//# sourceMappingURL=useHuriHash.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useHuriHash.js","sourceRoot":"","sources":["../../../src/hooks/useHuriHash.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAc,MAAM,sBAAsB,CAAA;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AAGnC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEjD,MAAM,WAAW,GAAG,
|
|
1
|
+
{"version":3,"file":"useHuriHash.js","sourceRoot":"","sources":["../../../src/hooks/useHuriHash.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAc,MAAM,sBAAsB,CAAA;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AAGnC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEjD;;GAEG;AACH,MAAM,WAAW,GAAG,CAClB,UAA0B,EAC1B,OAAgB,EAChB,OAA8B,EACmD,EAAE;IACnF,MAAM,IAAI,GAAG,WAAW,CAAC,CAAC,UAA0B,EAAE,EAAE;QACtD,IAAI,UAAU,EAAE;YACd,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE;gBAClC,OAAO,UAAU,CAAA;aAClB;YACD,IAAI,UAAU,YAAY,IAAI,EAAE;gBAC9B,OAAO,UAAU,CAAC,IAAI,CAAA;aACvB;SACF;IACH,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,CAAA;IAElC,0EAA0E;IAC1E,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,GAAG,UAAU,CAAC,SAAS,CAAC,CAAA;IAE3D,kDAAkD;IAClD,MAAM,CAAC,WAAW,EAAE,mBAAmB,EAAE,YAAY,EAAE,eAAe,CAAC,GAAG,cAAc,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAA;IAEpH,OAAO,CAAC,OAAO,IAAI,WAAW,EAAE,mBAAmB,EAAE,QAAQ,IAAI,YAAY,EAAE,eAAe,CAAC,CAAA;AACjG,CAAC,CAAA;AAED,OAAO,EAAE,WAAW,EAAE,CAAA"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { XyoApiError } from '@xyo-network/api';
|
|
2
2
|
import { XyoPayload } from '@xyo-network/payload';
|
|
3
|
-
export declare const usePayload: (hash?: string) => [XyoPayload | undefined, boolean, XyoApiError | undefined];
|
|
3
|
+
export declare const usePayload: (hash?: string) => [XyoPayload | undefined, boolean | undefined, XyoApiError | undefined];
|
|
@@ -5,22 +5,22 @@ import { useState } from 'react';
|
|
|
5
5
|
export const usePayload = (hash) => {
|
|
6
6
|
const { api } = useArchivistApi();
|
|
7
7
|
const { archive } = useArchive();
|
|
8
|
-
const [notFound, setNotFound] = useState(
|
|
8
|
+
const [notFound, setNotFound] = useState();
|
|
9
9
|
const [apiError, setApiError] = useState();
|
|
10
10
|
const [payload, setPayload] = useState();
|
|
11
11
|
const reset = () => {
|
|
12
12
|
setPayload(undefined);
|
|
13
13
|
setApiError(undefined);
|
|
14
|
-
setNotFound(
|
|
14
|
+
setNotFound(undefined);
|
|
15
15
|
};
|
|
16
16
|
useAsyncEffect(
|
|
17
17
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
18
18
|
async (mounted) => {
|
|
19
19
|
if (api && hash && hash.length > 0) {
|
|
20
20
|
try {
|
|
21
|
+
reset();
|
|
21
22
|
const result = await api?.archive(archive).payload.hash(hash).get();
|
|
22
23
|
if (mounted()) {
|
|
23
|
-
reset();
|
|
24
24
|
if (result?.length) {
|
|
25
25
|
setPayload(result[0]);
|
|
26
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePayload.js","sourceRoot":"","sources":["../../../src/hooks/usePayload.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAGrD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAA;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEhC,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAa,
|
|
1
|
+
{"version":3,"file":"usePayload.js","sourceRoot":"","sources":["../../../src/hooks/usePayload.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAGrD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAA;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEhC,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAa,EAA0E,EAAE;IAClH,MAAM,EAAE,GAAG,EAAE,GAAG,eAAe,EAAE,CAAA;IACjC,MAAM,EAAE,OAAO,EAAE,GAAG,UAAU,EAAE,CAAA;IAChC,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,EAAW,CAAA;IACnD,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,EAAe,CAAA;IACvD,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,EAAc,CAAA;IAEpD,MAAM,KAAK,GAAG,GAAG,EAAE;QACjB,UAAU,CAAC,SAAS,CAAC,CAAA;QACrB,WAAW,CAAC,SAAS,CAAC,CAAA;QACtB,WAAW,CAAC,SAAS,CAAC,CAAA;IACxB,CAAC,CAAA;IAED,cAAc;IACZ,uDAAuD;IACvD,KAAK,EAAE,OAAO,EAAE,EAAE;QAChB,IAAI,GAAG,IAAI,IAAI,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;YAClC,IAAI;gBACF,KAAK,EAAE,CAAA;gBACP,MAAM,MAAM,GAAG,MAAM,GAAG,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,CAAA;gBACnE,IAAI,OAAO,EAAE,EAAE;oBACb,IAAI,MAAM,EAAE,MAAM,EAAE;wBAClB,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;qBACtB;yBAAM,IAAI,MAAM,EAAE;wBACjB,WAAW,CAAC,IAAI,CAAC,CAAA;wBACjB,UAAU,CAAC,SAAS,CAAC,CAAA;qBACtB;iBACF;aACF;YAAC,OAAO,CAAC,EAAE;gBACV,KAAK,EAAE,CAAA;gBACP,WAAW,CAAC,CAAgB,CAAC,CAAA;gBAC7B,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;aACjB;SACF;IACH,CAAC,EACD,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,CACrB,CAAA;IACD,OAAO,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAA;AACtC,CAAC,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { XyoApiError } from '@xyo-network/api';
|
|
2
2
|
import { XyoPayload } from '@xyo-network/payload';
|
|
3
3
|
import { FetchHuriHashOptions } from './lib';
|
|
4
|
-
declare const useResolveHuri: (huriUri?: string, dependentNotFound?: boolean, options?: FetchHuriHashOptions) => [XyoPayload | undefined, boolean, XyoApiError | undefined];
|
|
4
|
+
declare const useResolveHuri: (huriUri?: string, dependentNotFound?: boolean, options?: FetchHuriHashOptions) => [XyoPayload | undefined, boolean, XyoApiError | undefined, boolean | undefined];
|
|
5
5
|
export { useResolveHuri };
|
|
@@ -5,30 +5,28 @@ import { useState } from 'react';
|
|
|
5
5
|
import { findHuriNetwork } from './lib';
|
|
6
6
|
const useResolveHuri = (huriUri, dependentNotFound, options) => {
|
|
7
7
|
const { network, networks, setNetwork } = useNetwork();
|
|
8
|
-
const [huriNetwork, setHuriNetwork] = useState();
|
|
9
8
|
const [huriPayload, setHuriPayload] = useState();
|
|
10
9
|
const [huriPayloadNotFound, setHuriPayloadNotFound] = useState(false);
|
|
10
|
+
const [huriNetworkNotFound, setHuriNetworkNotFound] = useState();
|
|
11
11
|
const [huriApiError, setHuriApiError] = useState();
|
|
12
12
|
const { changeActiveNetwork } = options ?? {};
|
|
13
13
|
useAsyncEffect(
|
|
14
14
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
15
15
|
async (mounted) => {
|
|
16
|
-
if ((dependentNotFound === undefined || dependentNotFound) && huriUri
|
|
16
|
+
if ((dependentNotFound === undefined || dependentNotFound) && huriUri) {
|
|
17
17
|
const huriInstance = new Huri(huriUri);
|
|
18
18
|
const foundHuriNetwork = findHuriNetwork(huriInstance, networks);
|
|
19
|
-
// Update when we found a huri network and it doesn't match the current one
|
|
20
19
|
if (foundHuriNetwork && mounted()) {
|
|
21
|
-
setHuriNetwork(huriNetwork);
|
|
22
20
|
if (network !== foundHuriNetwork && changeActiveNetwork) {
|
|
23
21
|
setNetwork?.(foundHuriNetwork);
|
|
24
22
|
return;
|
|
25
23
|
}
|
|
26
|
-
// If no matching network try to resolve the huri itself
|
|
27
24
|
try {
|
|
28
25
|
const huriPayload = await huriInstance.fetch();
|
|
29
26
|
if (mounted()) {
|
|
30
27
|
if (huriPayload) {
|
|
31
28
|
setHuriPayload(huriPayload);
|
|
29
|
+
setHuriPayloadNotFound(false);
|
|
32
30
|
}
|
|
33
31
|
else {
|
|
34
32
|
setHuriPayloadNotFound(true);
|
|
@@ -41,9 +39,18 @@ const useResolveHuri = (huriUri, dependentNotFound, options) => {
|
|
|
41
39
|
}
|
|
42
40
|
}
|
|
43
41
|
}
|
|
42
|
+
else {
|
|
43
|
+
setHuriNetworkNotFound(true);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
// If the dependent is not found, then assume not found till proven otherwise
|
|
48
|
+
if (dependentNotFound) {
|
|
49
|
+
setHuriPayloadNotFound(true);
|
|
50
|
+
}
|
|
44
51
|
}
|
|
45
|
-
}, [
|
|
46
|
-
return [huriPayload, huriPayloadNotFound, huriApiError];
|
|
52
|
+
}, [huriUri, network, networks, dependentNotFound, setNetwork, changeActiveNetwork]);
|
|
53
|
+
return [huriPayload, huriPayloadNotFound, huriApiError, huriNetworkNotFound];
|
|
47
54
|
};
|
|
48
55
|
export { useResolveHuri };
|
|
49
56
|
//# sourceMappingURL=useResolveHuri.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useResolveHuri.js","sourceRoot":"","sources":["../../../src/hooks/useResolveHuri.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"useResolveHuri.js","sourceRoot":"","sources":["../../../src/hooks/useResolveHuri.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAErD,OAAO,EAAE,IAAI,EAAc,MAAM,sBAAsB,CAAA;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEhC,OAAO,EAAwB,eAAe,EAAE,MAAM,OAAO,CAAA;AAE7D,MAAM,cAAc,GAAG,CACrB,OAAgB,EAChB,iBAA2B,EAC3B,OAA8B,EACmD,EAAE;IACnF,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,UAAU,EAAE,CAAA;IACtD,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,EAAc,CAAA;IAC5D,MAAM,CAAC,mBAAmB,EAAE,sBA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SACF;IACH,CAAC,EACD,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,UAAU,EAAE,mBAAmB,CAAC,CACjF,CAAA;IAED,OAAO,CAAC,WAAW,EAAE,mBAAmB,EAAE,YAAY,EAAE,mBAAmB,CAAC,CAAA;AAC9E,CAAC,CAAA;AAED,OAAO,EAAE,cAAc,EAAE,CAAA"}
|
package/package.json
CHANGED
|
@@ -21,13 +21,13 @@
|
|
|
21
21
|
"@xyo-network/api": "^2.21.14",
|
|
22
22
|
"@xyo-network/network": "^2.21.14",
|
|
23
23
|
"@xyo-network/payload": "^2.21.14",
|
|
24
|
-
"@xyo-network/react-archive": "^2.26.
|
|
25
|
-
"@xyo-network/react-archivist-api": "^2.26.
|
|
26
|
-
"@xyo-network/react-auth-service": "^2.26.
|
|
27
|
-
"@xyo-network/react-network": "^2.26.
|
|
28
|
-
"@xyo-network/react-property": "^2.26.
|
|
29
|
-
"@xyo-network/react-schema": "^2.26.
|
|
30
|
-
"@xyo-network/react-shared": "^2.26.
|
|
24
|
+
"@xyo-network/react-archive": "^2.26.10",
|
|
25
|
+
"@xyo-network/react-archivist-api": "^2.26.10",
|
|
26
|
+
"@xyo-network/react-auth-service": "^2.26.10",
|
|
27
|
+
"@xyo-network/react-network": "^2.26.10",
|
|
28
|
+
"@xyo-network/react-property": "^2.26.10",
|
|
29
|
+
"@xyo-network/react-schema": "^2.26.10",
|
|
30
|
+
"@xyo-network/react-shared": "^2.26.10",
|
|
31
31
|
"@xyo-network/utils": "^2.21.14",
|
|
32
32
|
"luxon": "^2.4.0",
|
|
33
33
|
"react": "^18.2.0",
|
|
@@ -94,6 +94,6 @@
|
|
|
94
94
|
},
|
|
95
95
|
"sideEffects": false,
|
|
96
96
|
"types": "dist/esm/index.d.ts",
|
|
97
|
-
"version": "2.26.
|
|
97
|
+
"version": "2.26.10",
|
|
98
98
|
"packageManager": "yarn@3.1.1"
|
|
99
99
|
}
|
|
@@ -1,32 +1,41 @@
|
|
|
1
1
|
/* eslint-disable import/no-internal-modules */
|
|
2
|
-
import { Typography } from '@mui/material'
|
|
2
|
+
import { Alert, Typography } from '@mui/material'
|
|
3
3
|
import { ComponentStory, Meta } from '@storybook/react'
|
|
4
4
|
import { FlexCol } from '@xylabs/react-flexbox'
|
|
5
5
|
import { Huri } from '@xyo-network/payload'
|
|
6
|
+
import { ArchivistApiProvider } from '@xyo-network/react-archivist-api'
|
|
7
|
+
import { NetworkMemoryProvider } from '@xyo-network/react-network'
|
|
6
8
|
import { XyoSchemaCache } from '@xyo-network/utils'
|
|
7
9
|
import { lazy, Suspense } from 'react'
|
|
8
10
|
|
|
9
|
-
import {
|
|
11
|
+
import { FetchHuriHashOptions } from './lib'
|
|
10
12
|
import { useHuriHash } from './useHuriHash'
|
|
11
13
|
|
|
12
14
|
const JsonView = lazy(() => import(/* webpackChunkName: "jsonView" */ 'react-json-view'))
|
|
13
15
|
|
|
14
16
|
interface UseHuriHashComponentProps {
|
|
15
17
|
huriOrHash: string | Huri
|
|
18
|
+
huriUri?: string
|
|
19
|
+
options?: FetchHuriHashOptions
|
|
16
20
|
}
|
|
17
21
|
|
|
18
22
|
const apiDomain = 'https://beta.api.archivist.xyo.network'
|
|
19
23
|
const hash = '5605fabad11b10bb5fb86b309ca0970894eda8f22362dda1a489817723bca992'
|
|
20
24
|
XyoSchemaCache.instance.proxy = `${apiDomain}/domain`
|
|
21
25
|
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
const mainApiDomain = 'https://api.archivist.xyo.network'
|
|
27
|
+
const mainHash = 'd3a3936e31ba1d835c528784ab77c1eaaeedd6e16b7aad68a88241ce539853cb'
|
|
28
|
+
|
|
29
|
+
const Wrapper: React.FC<UseHuriHashComponentProps> = (props) => (
|
|
30
|
+
<NetworkMemoryProvider>
|
|
31
|
+
<ArchivistApiProvider apiDomain={apiDomain}>
|
|
32
|
+
<UseHuriHashComponent {...props} />
|
|
33
|
+
</ArchivistApiProvider>
|
|
34
|
+
</NetworkMemoryProvider>
|
|
26
35
|
)
|
|
27
36
|
|
|
28
|
-
const UseHuriHashComponent: React.FC<UseHuriHashComponentProps> = ({ huriOrHash }) => {
|
|
29
|
-
const [payload] = useHuriHash(huriOrHash)
|
|
37
|
+
const UseHuriHashComponent: React.FC<UseHuriHashComponentProps> = ({ huriOrHash, huriUri, options }) => {
|
|
38
|
+
const [payload, notFound, _, networkNotFound] = useHuriHash(huriOrHash, huriUri, options)
|
|
30
39
|
|
|
31
40
|
return (
|
|
32
41
|
<>
|
|
@@ -34,6 +43,8 @@ const UseHuriHashComponent: React.FC<UseHuriHashComponentProps> = ({ huriOrHash
|
|
|
34
43
|
Fetches the payload for a huriOrHash.
|
|
35
44
|
</Typography>
|
|
36
45
|
<FlexCol my={3}>
|
|
46
|
+
{notFound ? <Alert severity="warning">Not Found</Alert> : null}
|
|
47
|
+
{networkNotFound ? <Alert severity="warning">Network Not Found</Alert> : null}
|
|
37
48
|
<Suspense fallback={<FlexCol busy />}>
|
|
38
49
|
<JsonView src={payload || {}} />
|
|
39
50
|
</Suspense>
|
|
@@ -53,17 +64,31 @@ const StorybookEntry: Meta = {
|
|
|
53
64
|
title: 'payload/useHuriHash',
|
|
54
65
|
}
|
|
55
66
|
|
|
56
|
-
const Template: ComponentStory<typeof UseHuriHashComponent> = (
|
|
57
|
-
return <Wrapper
|
|
67
|
+
const Template: ComponentStory<typeof UseHuriHashComponent> = (props) => {
|
|
68
|
+
return <Wrapper {...props} />
|
|
58
69
|
}
|
|
59
70
|
|
|
60
71
|
const Default = Template.bind({})
|
|
61
72
|
Default.args = { huriOrHash: hash }
|
|
62
73
|
|
|
74
|
+
const NotFound = Template.bind({})
|
|
75
|
+
NotFound.args = { huriOrHash: 'foo' }
|
|
76
|
+
|
|
63
77
|
const WithHuri = Template.bind({})
|
|
64
78
|
WithHuri.args = { huriOrHash: new Huri(`${apiDomain}/${hash}`) }
|
|
65
79
|
|
|
66
|
-
|
|
80
|
+
const WithHuriUri = Template.bind({})
|
|
81
|
+
WithHuriUri.args = { huriUri: `${mainApiDomain}/${mainHash}` }
|
|
82
|
+
|
|
83
|
+
const WithHuriUriNetworkNotFound = Template.bind({})
|
|
84
|
+
WithHuriUriNetworkNotFound.args = { huriUri: `http://badarchivisturl.com/${mainHash}` }
|
|
85
|
+
|
|
86
|
+
// Note - story will work correctly once main net return 200 instead of 404 when payloads aren't found
|
|
87
|
+
// Resolve huriUri when network is different from the current network
|
|
88
|
+
const WithHuriUriNotFound = Template.bind({})
|
|
89
|
+
WithHuriUriNotFound.args = { huriUri: `${mainApiDomain}/foo` }
|
|
90
|
+
|
|
91
|
+
export { Default, NotFound, WithHuri, WithHuriUri, WithHuriUriNetworkNotFound, WithHuriUriNotFound }
|
|
67
92
|
|
|
68
93
|
// eslint-disable-next-line import/no-default-export
|
|
69
94
|
export default StorybookEntry
|
|
@@ -6,7 +6,14 @@ import { FetchHuriHashOptions } from './lib'
|
|
|
6
6
|
import { usePayload } from './usePayload'
|
|
7
7
|
import { useResolveHuri } from './useResolveHuri'
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Resolve a hash or a huri regardless of network
|
|
11
|
+
*/
|
|
12
|
+
const useHuriHash = (
|
|
13
|
+
huriOrHash?: string | Huri,
|
|
14
|
+
huriUri?: string,
|
|
15
|
+
options?: FetchHuriHashOptions
|
|
16
|
+
): [XyoPayload | undefined, boolean, XyoApiError | undefined, boolean | undefined] => {
|
|
10
17
|
const hash = useCallback((huriOrHash?: string | Huri) => {
|
|
11
18
|
if (huriOrHash) {
|
|
12
19
|
if (typeof huriOrHash === 'string') {
|
|
@@ -18,10 +25,15 @@ const useHuriHash = (huriOrHash?: string | Huri, huriUri?: string, options?: Fet
|
|
|
18
25
|
}
|
|
19
26
|
}, [])
|
|
20
27
|
|
|
21
|
-
const
|
|
22
|
-
const [huriPayload, huriPayloadNotFound, huriApiError] = useResolveHuri(huriUri, notFound, options)
|
|
28
|
+
const foundHash = hash(huriOrHash)
|
|
23
29
|
|
|
24
|
-
|
|
30
|
+
// Optimistically try to grab the has from the current network and archive
|
|
31
|
+
const [payload, notFound, apiError] = usePayload(foundHash)
|
|
32
|
+
|
|
33
|
+
// If payload isn't found, fallback to the huriUri
|
|
34
|
+
const [huriPayload, huriPayloadNotFound, huriApiError, networkNotFound] = useResolveHuri(huriUri, notFound, options)
|
|
35
|
+
|
|
36
|
+
return [payload ?? huriPayload, huriPayloadNotFound, apiError ?? huriApiError, networkNotFound]
|
|
25
37
|
}
|
|
26
38
|
|
|
27
39
|
export { useHuriHash }
|
package/src/hooks/usePayload.tsx
CHANGED
|
@@ -5,17 +5,17 @@ import { useArchive } from '@xyo-network/react-archive'
|
|
|
5
5
|
import { useArchivistApi } from '@xyo-network/react-archivist-api'
|
|
6
6
|
import { useState } from 'react'
|
|
7
7
|
|
|
8
|
-
export const usePayload = (hash?: string): [XyoPayload | undefined, boolean, XyoApiError | undefined] => {
|
|
8
|
+
export const usePayload = (hash?: string): [XyoPayload | undefined, boolean | undefined, XyoApiError | undefined] => {
|
|
9
9
|
const { api } = useArchivistApi()
|
|
10
10
|
const { archive } = useArchive()
|
|
11
|
-
const [notFound, setNotFound] = useState(
|
|
11
|
+
const [notFound, setNotFound] = useState<boolean>()
|
|
12
12
|
const [apiError, setApiError] = useState<XyoApiError>()
|
|
13
13
|
const [payload, setPayload] = useState<XyoPayload>()
|
|
14
14
|
|
|
15
15
|
const reset = () => {
|
|
16
16
|
setPayload(undefined)
|
|
17
17
|
setApiError(undefined)
|
|
18
|
-
setNotFound(
|
|
18
|
+
setNotFound(undefined)
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
useAsyncEffect(
|
|
@@ -23,9 +23,9 @@ export const usePayload = (hash?: string): [XyoPayload | undefined, boolean, Xyo
|
|
|
23
23
|
async (mounted) => {
|
|
24
24
|
if (api && hash && hash.length > 0) {
|
|
25
25
|
try {
|
|
26
|
+
reset()
|
|
26
27
|
const result = await api?.archive(archive).payload.hash(hash).get()
|
|
27
28
|
if (mounted()) {
|
|
28
|
-
reset()
|
|
29
29
|
if (result?.length) {
|
|
30
30
|
setPayload(result[0])
|
|
31
31
|
} else if (result) {
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import { useAsyncEffect } from '@xylabs/react-shared'
|
|
2
2
|
import { XyoApiError } from '@xyo-network/api'
|
|
3
|
-
import { XyoNetworkPayload } from '@xyo-network/network'
|
|
4
3
|
import { Huri, XyoPayload } from '@xyo-network/payload'
|
|
5
4
|
import { useNetwork } from '@xyo-network/react-network'
|
|
6
5
|
import { useState } from 'react'
|
|
7
6
|
|
|
8
7
|
import { FetchHuriHashOptions, findHuriNetwork } from './lib'
|
|
9
8
|
|
|
10
|
-
const useResolveHuri = (
|
|
9
|
+
const useResolveHuri = (
|
|
10
|
+
huriUri?: string,
|
|
11
|
+
dependentNotFound?: boolean,
|
|
12
|
+
options?: FetchHuriHashOptions
|
|
13
|
+
): [XyoPayload | undefined, boolean, XyoApiError | undefined, boolean | undefined] => {
|
|
11
14
|
const { network, networks, setNetwork } = useNetwork()
|
|
12
|
-
const [huriNetwork, setHuriNetwork] = useState<XyoNetworkPayload>()
|
|
13
15
|
const [huriPayload, setHuriPayload] = useState<XyoPayload>()
|
|
14
16
|
const [huriPayloadNotFound, setHuriPayloadNotFound] = useState(false)
|
|
17
|
+
const [huriNetworkNotFound, setHuriNetworkNotFound] = useState<boolean>()
|
|
15
18
|
const [huriApiError, setHuriApiError] = useState<XyoApiError>()
|
|
16
19
|
|
|
17
20
|
const { changeActiveNetwork } = options ?? {}
|
|
@@ -19,25 +22,23 @@ const useResolveHuri = (huriUri?: string, dependentNotFound?: boolean, options?:
|
|
|
19
22
|
useAsyncEffect(
|
|
20
23
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
21
24
|
async (mounted) => {
|
|
22
|
-
if ((dependentNotFound === undefined || dependentNotFound) && huriUri
|
|
25
|
+
if ((dependentNotFound === undefined || dependentNotFound) && huriUri) {
|
|
23
26
|
const huriInstance = new Huri(huriUri)
|
|
24
27
|
|
|
25
28
|
const foundHuriNetwork = findHuriNetwork(huriInstance, networks)
|
|
26
29
|
|
|
27
|
-
// Update when we found a huri network and it doesn't match the current one
|
|
28
30
|
if (foundHuriNetwork && mounted()) {
|
|
29
|
-
setHuriNetwork(huriNetwork)
|
|
30
31
|
if (network !== foundHuriNetwork && changeActiveNetwork) {
|
|
31
32
|
setNetwork?.(foundHuriNetwork)
|
|
32
33
|
return
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
// If no matching network try to resolve the huri itself
|
|
36
36
|
try {
|
|
37
37
|
const huriPayload = await huriInstance.fetch()
|
|
38
38
|
if (mounted()) {
|
|
39
39
|
if (huriPayload) {
|
|
40
40
|
setHuriPayload(huriPayload)
|
|
41
|
+
setHuriPayloadNotFound(false)
|
|
41
42
|
} else {
|
|
42
43
|
setHuriPayloadNotFound(true)
|
|
43
44
|
}
|
|
@@ -47,13 +48,20 @@ const useResolveHuri = (huriUri?: string, dependentNotFound?: boolean, options?:
|
|
|
47
48
|
setHuriApiError(e as XyoApiError)
|
|
48
49
|
}
|
|
49
50
|
}
|
|
51
|
+
} else {
|
|
52
|
+
setHuriNetworkNotFound(true)
|
|
53
|
+
}
|
|
54
|
+
} else {
|
|
55
|
+
// If the dependent is not found, then assume not found till proven otherwise
|
|
56
|
+
if (dependentNotFound) {
|
|
57
|
+
setHuriPayloadNotFound(true)
|
|
50
58
|
}
|
|
51
59
|
}
|
|
52
60
|
},
|
|
53
|
-
[
|
|
61
|
+
[huriUri, network, networks, dependentNotFound, setNetwork, changeActiveNetwork]
|
|
54
62
|
)
|
|
55
63
|
|
|
56
|
-
return [huriPayload, huriPayloadNotFound, huriApiError]
|
|
64
|
+
return [huriPayload, huriPayloadNotFound, huriApiError, huriNetworkNotFound]
|
|
57
65
|
}
|
|
58
66
|
|
|
59
67
|
export { useResolveHuri }
|