@xyo-network/react-chain-boundwitness 1.3.13 → 1.3.15
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/README.md +11 -1
- package/dist/browser/index.mjs +98 -3
- package/dist/browser/index.mjs.map +1 -1
- package/dist/types/components/BlockBoundWitnessDetails.d.ts +10 -0
- package/dist/types/components/BlockBoundWitnessDetails.d.ts.map +1 -0
- package/dist/types/components/index.d.ts +2 -0
- package/dist/types/components/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -2
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +21 -1
- package/src/components/BlockBoundWitnessDetails.stories.tsx +72 -0
- package/src/components/BlockBoundWitnessDetails.tsx +119 -0
- package/src/components/index.ts +1 -0
- package/src/index.ts +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
|
+
# @xyo-network/react-chain-boundwitness
|
|
2
|
+
|
|
1
3
|
[![logo][]](https://xyo.network)
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
Version: 1.3.13
|
|
6
|
+
|
|
7
|
+
XYO Layer One React SDK BoundWitness
|
|
8
|
+
|
|
9
|
+
## Documentation
|
|
10
|
+
|
|
11
|
+
[TypeDoc Generated Documentation](https://gitbook.xyo.network/xyo-data-lab/xyo-reference/package-documentation/xyo-network__react-chain-boundwitness)
|
|
12
|
+
|
|
13
|
+
Part of [sdk-xyo-client-js](https://www.npmjs.com/package/@xyo-network/sdk-xyo-client-js)
|
|
4
14
|
|
|
5
15
|
## License
|
|
6
16
|
|
package/dist/browser/index.mjs
CHANGED
|
@@ -1,6 +1,101 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// src/components/BlockBoundWitnessDetails.tsx
|
|
5
|
+
import { Divider, TableCell, TableHead, TableRow } from "@mui/material";
|
|
6
|
+
import { filterAs } from "@xylabs/array";
|
|
7
|
+
import { ErrorRender } from "@xylabs/react-error";
|
|
8
|
+
import { FlexCol } from "@xylabs/react-flexbox";
|
|
9
|
+
import { usePromise } from "@xylabs/react-promise";
|
|
10
|
+
import { isBoundWitness } from "@xyo-network/boundwitness-model";
|
|
11
|
+
import { PayloadBuilder } from "@xyo-network/payload-builder";
|
|
12
|
+
import { BoundWitnessPayloadsTable, BoundWitnessSignatureTable, BWActions, HashHeadingPaper, HeadingPaper } from "@xyo-network/react-boundwitness-plugin";
|
|
13
|
+
import { useTxsFromBlock } from "@xyo-network/react-chain-blockchain";
|
|
14
|
+
import { HashTableCell, usePayloadHash } from "@xyo-network/react-shared";
|
|
15
|
+
import { TableEx } from "@xyo-network/react-table";
|
|
16
|
+
import { isTransactionBoundWitness } from "@xyo-network/xl1-protocol";
|
|
17
|
+
import React from "react";
|
|
18
|
+
import { FaSignature } from "react-icons/fa";
|
|
19
|
+
import { GrTransaction } from "react-icons/gr";
|
|
20
|
+
import { VscSymbolMethod, VscSymbolNamespace } from "react-icons/vsc";
|
|
21
|
+
var BlockBoundWitnessDetails = /* @__PURE__ */ __name(({ ref, block, paper, children, ...props }) => {
|
|
22
|
+
const boundWitness = block?.[0];
|
|
23
|
+
const payloads = block?.[1];
|
|
24
|
+
const hash = usePayloadHash(boundWitness);
|
|
25
|
+
const [transactions, txFromBlockError] = useTxsFromBlock(block);
|
|
26
|
+
const [nonTxBoundWitnesses, bwsFromBlockError] = usePromise(async () => {
|
|
27
|
+
const bws = filterAs(payloads ?? [], (payload) => !isTransactionBoundWitness(payload) && isBoundWitness(payload) ? payload : void 0);
|
|
28
|
+
return await PayloadBuilder.hashPairs(bws);
|
|
29
|
+
}, [
|
|
30
|
+
payloads
|
|
31
|
+
]);
|
|
32
|
+
const hasNonTxBoundWitnesses = (nonTxBoundWitnesses?.length ?? 0) > 0;
|
|
33
|
+
return /* @__PURE__ */ React.createElement(FlexCol, {
|
|
34
|
+
alignItems: "stretch",
|
|
35
|
+
rowGap: 4,
|
|
36
|
+
...props
|
|
37
|
+
}, /* @__PURE__ */ React.createElement(ErrorRender, {
|
|
38
|
+
error: txFromBlockError ?? bwsFromBlockError,
|
|
39
|
+
scope: "BlockBoundWitnessDetails.tsx"
|
|
40
|
+
}), /* @__PURE__ */ React.createElement(HashHeadingPaper, {
|
|
41
|
+
hash,
|
|
42
|
+
paperProps: {
|
|
43
|
+
sx: {
|
|
44
|
+
p: 2
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
AdornmentEnd: /* @__PURE__ */ React.createElement(BWActions, {
|
|
48
|
+
boundwitness: boundWitness
|
|
49
|
+
}),
|
|
50
|
+
identiconProps: {
|
|
51
|
+
p: 0.75,
|
|
52
|
+
size: 24
|
|
53
|
+
}
|
|
54
|
+
}), /* @__PURE__ */ React.createElement(Divider, {
|
|
55
|
+
flexItem: true
|
|
56
|
+
}), transactions?.length && /* @__PURE__ */ React.createElement(FlexCol, {
|
|
57
|
+
alignItems: "stretch",
|
|
58
|
+
rowGap: 1,
|
|
59
|
+
mb: 1
|
|
60
|
+
}, /* @__PURE__ */ React.createElement(HeadingPaper, {
|
|
61
|
+
IconComponent: /* @__PURE__ */ React.createElement(GrTransaction, null),
|
|
62
|
+
heading: "Transactions"
|
|
63
|
+
}), /* @__PURE__ */ React.createElement(TableEx, null, /* @__PURE__ */ React.createElement(TableHead, null, /* @__PURE__ */ React.createElement(TableRow, null, /* @__PURE__ */ React.createElement(TableCell, null, "Hash"))), transactions?.map(([, txHash]) => /* @__PURE__ */ React.createElement(TableRow, {
|
|
64
|
+
key: hash + txHash
|
|
65
|
+
}, /* @__PURE__ */ React.createElement(HashTableCell, {
|
|
66
|
+
title: hash
|
|
67
|
+
}, hash))))), /* @__PURE__ */ React.createElement(FlexCol, {
|
|
68
|
+
alignItems: "stretch",
|
|
69
|
+
rowGap: 1,
|
|
70
|
+
mb: 1
|
|
71
|
+
}, /* @__PURE__ */ React.createElement(HeadingPaper, {
|
|
72
|
+
IconComponent: /* @__PURE__ */ React.createElement(VscSymbolNamespace, null),
|
|
73
|
+
heading: "Payloads"
|
|
74
|
+
}), /* @__PURE__ */ React.createElement(BoundWitnessPayloadsTable, {
|
|
75
|
+
boundwitness: boundWitness
|
|
76
|
+
})), hasNonTxBoundWitnesses ? /* @__PURE__ */ React.createElement(FlexCol, {
|
|
77
|
+
alignItems: "stretch",
|
|
78
|
+
rowGap: 1,
|
|
79
|
+
mb: 1
|
|
80
|
+
}, /* @__PURE__ */ React.createElement(HeadingPaper, {
|
|
81
|
+
IconComponent: /* @__PURE__ */ React.createElement(VscSymbolMethod, null),
|
|
82
|
+
heading: "Bound Witnesses"
|
|
83
|
+
}), /* @__PURE__ */ React.createElement(TableEx, null, /* @__PURE__ */ React.createElement(TableHead, null, /* @__PURE__ */ React.createElement(TableRow, null, /* @__PURE__ */ React.createElement(TableCell, null, "Schema"))), nonTxBoundWitnesses?.map(([, bwHash]) => /* @__PURE__ */ React.createElement(TableRow, {
|
|
84
|
+
key: hash + bwHash
|
|
85
|
+
}, /* @__PURE__ */ React.createElement(HashTableCell, {
|
|
86
|
+
title: hash
|
|
87
|
+
}, hash))))) : null, /* @__PURE__ */ React.createElement(FlexCol, {
|
|
88
|
+
alignItems: "stretch",
|
|
89
|
+
rowGap: 1,
|
|
90
|
+
mb: 1
|
|
91
|
+
}, /* @__PURE__ */ React.createElement(HeadingPaper, {
|
|
92
|
+
IconComponent: /* @__PURE__ */ React.createElement(FaSignature, null),
|
|
93
|
+
heading: "Signatures"
|
|
94
|
+
}), /* @__PURE__ */ React.createElement(BoundWitnessSignatureTable, {
|
|
95
|
+
block: boundWitness
|
|
96
|
+
})));
|
|
97
|
+
}, "BlockBoundWitnessDetails");
|
|
3
98
|
export {
|
|
4
|
-
|
|
99
|
+
BlockBoundWitnessDetails
|
|
5
100
|
};
|
|
6
101
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/
|
|
1
|
+
{"version":3,"sources":["../../src/components/BlockBoundWitnessDetails.tsx"],"sourcesContent":["import {\n Divider, TableCell, TableHead, TableRow,\n} from '@mui/material'\nimport { filterAs } from '@xylabs/array'\nimport { ErrorRender } from '@xylabs/react-error'\nimport type { FlexBoxProps } from '@xylabs/react-flexbox'\nimport { FlexCol } from '@xylabs/react-flexbox'\nimport { usePromise } from '@xylabs/react-promise'\nimport { isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport {\n BoundWitnessPayloadsTable,\n BoundWitnessSignatureTable,\n BWActions,\n HashHeadingPaper,\n HeadingPaper,\n} from '@xyo-network/react-boundwitness-plugin'\nimport { useTxsFromBlock } from '@xyo-network/react-chain-blockchain'\nimport { HashTableCell, usePayloadHash } from '@xyo-network/react-shared'\nimport { TableEx } from '@xyo-network/react-table'\nimport { isTransactionBoundWitness, type SignedHydratedBlock } from '@xyo-network/xl1-protocol'\nimport React from 'react'\nimport { FaSignature } from 'react-icons/fa'\nimport { GrTransaction } from 'react-icons/gr'\nimport { VscSymbolMethod, VscSymbolNamespace } from 'react-icons/vsc'\n\nexport interface BoundWitnessDetailsProps extends FlexBoxProps {\n block?: SignedHydratedBlock\n}\n\nexport const BlockBoundWitnessDetails = ({\n ref, block, paper, children, ...props\n}: BoundWitnessDetailsProps & { ref?: React.Ref<unknown | null> }) => {\n const boundWitness = block?.[0]\n const payloads = block?.[1]\n\n const hash = usePayloadHash(boundWitness)\n\n const [transactions, txFromBlockError] = useTxsFromBlock(block)\n\n const [nonTxBoundWitnesses, bwsFromBlockError] = usePromise(async () => {\n const bws = filterAs(payloads ?? [], payload =>\n (!isTransactionBoundWitness(payload) && isBoundWitness(payload)) ? payload : undefined)\n return await PayloadBuilder.hashPairs(bws)\n }, [payloads])\n\n const hasNonTxBoundWitnesses = (nonTxBoundWitnesses?.length ?? 0) > 0\n\n return (\n <FlexCol alignItems=\"stretch\" rowGap={4} {...props}>\n <ErrorRender error={txFromBlockError ?? bwsFromBlockError} scope=\"BlockBoundWitnessDetails.tsx\" />\n <HashHeadingPaper\n hash={hash}\n paperProps={{ sx: { p: 2 } }}\n AdornmentEnd={<BWActions boundwitness={boundWitness} />}\n identiconProps={{ p: 0.75, size: 24 }}\n />\n <Divider flexItem />\n {transactions?.length && (\n <FlexCol alignItems=\"stretch\" rowGap={1} mb={1}>\n <HeadingPaper IconComponent={<GrTransaction />} heading=\"Transactions\" />\n <TableEx>\n <TableHead>\n <TableRow>\n <TableCell>\n Hash\n </TableCell>\n </TableRow>\n </TableHead>\n {\n transactions?.map(([, txHash]) => (\n <TableRow\n key={hash + txHash}\n // onClick={() => handleOnClick(hash)} sx={{ cursor: 'pointer' }}\n >\n <HashTableCell title={hash}>{hash}</HashTableCell>\n </TableRow>\n ))\n }\n </TableEx>\n </FlexCol>\n )}\n <FlexCol alignItems=\"stretch\" rowGap={1} mb={1}>\n <HeadingPaper IconComponent={<VscSymbolNamespace />} heading=\"Payloads\" />\n <BoundWitnessPayloadsTable boundwitness={boundWitness} />\n </FlexCol>\n {hasNonTxBoundWitnesses\n ? (\n <FlexCol alignItems=\"stretch\" rowGap={1} mb={1}>\n <HeadingPaper IconComponent={<VscSymbolMethod />} heading=\"Bound Witnesses\" />\n <TableEx>\n <TableHead>\n <TableRow>\n <TableCell>\n Schema\n </TableCell>\n </TableRow>\n </TableHead>\n {\n nonTxBoundWitnesses?.map(([, bwHash]) => (\n <TableRow\n key={hash + bwHash}\n // onClick={() => handleOnClick(hash)} sx={{ cursor: 'pointer' }}\n >\n <HashTableCell title={hash}>{hash}</HashTableCell>\n </TableRow>\n ))\n }\n </TableEx>\n </FlexCol>\n )\n : null}\n <FlexCol alignItems=\"stretch\" rowGap={1} mb={1}>\n <HeadingPaper IconComponent={<FaSignature />} heading=\"Signatures\" />\n <BoundWitnessSignatureTable block={boundWitness} />\n </FlexCol>\n </FlexCol>\n )\n}\n"],"mappings":";;;;AAAA,SACEA,S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C,MACJ,sBAAA,cAACkB,SAAAA;IAAQC,YAAW;IAAUC,QAAQ;IAAGe,IAAI;KAC3C,sBAAA,cAACC,cAAAA;IAAaC,eAAe,sBAAA,cAACgB,aAAAA,IAAAA;IAAgBd,SAAQ;MACtD,sBAAA,cAACe,4BAAAA;IAA2B5D,OAAOI;;AAI3C,GAxFwC;","names":["Divider","TableCell","TableHead","TableRow","filterAs","ErrorRender","FlexCol","usePromise","isBoundWitness","PayloadBuilder","BoundWitnessPayloadsTable","BoundWitnessSignatureTable","BWActions","HashHeadingPaper","HeadingPaper","useTxsFromBlock","HashTableCell","usePayloadHash","TableEx","isTransactionBoundWitness","React","FaSignature","GrTransaction","VscSymbolMethod","VscSymbolNamespace","BlockBoundWitnessDetails","ref","block","paper","children","props","boundWitness","payloads","hash","usePayloadHash","transactions","txFromBlockError","useTxsFromBlock","nonTxBoundWitnesses","bwsFromBlockError","usePromise","bws","filterAs","payload","isTransactionBoundWitness","isBoundWitness","undefined","PayloadBuilder","hashPairs","hasNonTxBoundWitnesses","length","FlexCol","alignItems","rowGap","ErrorRender","error","scope","HashHeadingPaper","paperProps","sx","p","AdornmentEnd","BWActions","boundwitness","identiconProps","size","Divider","flexItem","mb","HeadingPaper","IconComponent","GrTransaction","heading","TableEx","TableHead","TableRow","TableCell","map","txHash","key","HashTableCell","title","VscSymbolNamespace","BoundWitnessPayloadsTable","VscSymbolMethod","bwHash","FaSignature","BoundWitnessSignatureTable"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { FlexBoxProps } from '@xylabs/react-flexbox';
|
|
2
|
+
import { type SignedHydratedBlock } from '@xyo-network/xl1-protocol';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
export interface BoundWitnessDetailsProps extends FlexBoxProps {
|
|
5
|
+
block?: SignedHydratedBlock;
|
|
6
|
+
}
|
|
7
|
+
export declare const BlockBoundWitnessDetails: ({ ref, block, paper, children, ...props }: BoundWitnessDetailsProps & {
|
|
8
|
+
ref?: React.Ref<unknown | null>;
|
|
9
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
//# sourceMappingURL=BlockBoundWitnessDetails.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BlockBoundWitnessDetails.d.ts","sourceRoot":"","sources":["../../../src/components/BlockBoundWitnessDetails.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAezD,OAAO,EAA6B,KAAK,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AAC/F,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,MAAM,WAAW,wBAAyB,SAAQ,YAAY;IAC5D,KAAK,CAAC,EAAE,mBAAmB,CAAA;CAC5B;AAED,eAAO,MAAM,wBAAwB,GAAI,2CAEtC,wBAAwB,GAAG;IAAE,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,CAAA;CAAE,4CAsFhE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAA"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@xyo-network/react-chain-boundwitness",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.15",
|
|
5
5
|
"description": "XYO Layer One React SDK BoundWitness",
|
|
6
6
|
"homepage": "https://xylabs.com",
|
|
7
7
|
"bugs": {
|
|
@@ -33,10 +33,30 @@
|
|
|
33
33
|
},
|
|
34
34
|
"module": "dist/browser/index.mjs",
|
|
35
35
|
"types": "dist/types/index.d.ts",
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@xylabs/array": "^4.8.9",
|
|
38
|
+
"@xylabs/react-error": "^6.2.19",
|
|
39
|
+
"@xylabs/react-promise": "^6.2.19",
|
|
40
|
+
"@xyo-network/payload-builder": "^3.14.16",
|
|
41
|
+
"@xyo-network/react-boundwitness-plugin": "^5.2.7",
|
|
42
|
+
"@xyo-network/react-chain-blockchain": "^1.3.15",
|
|
43
|
+
"@xyo-network/react-payload-details": "^5.2.7",
|
|
44
|
+
"@xyo-network/react-shared": "^5.2.7",
|
|
45
|
+
"@xyo-network/react-table": "^5.2.7",
|
|
46
|
+
"@xyo-network/xl1-protocol": "^1.3.11",
|
|
47
|
+
"react-icons": "^5.5.0"
|
|
48
|
+
},
|
|
36
49
|
"devDependencies": {
|
|
50
|
+
"@emotion/react": "^11",
|
|
51
|
+
"@emotion/styled": "^11",
|
|
52
|
+
"@mui/icons-material": ">=6 <8",
|
|
53
|
+
"@mui/material": ">=6 <8",
|
|
37
54
|
"@xylabs/ts-scripts-yarn3": "^6.5.5",
|
|
38
55
|
"@xylabs/tsconfig-react": "^6.5.5",
|
|
39
56
|
"knip": "^5.52.0",
|
|
57
|
+
"react": "^19",
|
|
58
|
+
"react-dom": "^19",
|
|
59
|
+
"react-router-dom": "^7",
|
|
40
60
|
"typescript": "^5.8.3"
|
|
41
61
|
},
|
|
42
62
|
"peerDependencies": {
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Alert, AlertTitle, List, ListItem, Stack,
|
|
3
|
+
} from '@mui/material'
|
|
4
|
+
import type { Meta, StoryFn } from '@storybook/react'
|
|
5
|
+
import { type BlockHeaderEventNouns, useBlockHeadingEvents } from '@xyo-network/react-chain-blockchain'
|
|
6
|
+
import { buildRandomBlockChain } from '@xyo-network/react-chain-shared'
|
|
7
|
+
import React, { useState } from 'react'
|
|
8
|
+
|
|
9
|
+
import { BlockBoundWitnessDetails } from './BlockBoundWitnessDetails.tsx'
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
title: 'BoundWitness/Block/Details/Flexbox',
|
|
13
|
+
component: BlockBoundWitnessDetails,
|
|
14
|
+
} as Meta
|
|
15
|
+
|
|
16
|
+
const blocks = await buildRandomBlockChain()
|
|
17
|
+
|
|
18
|
+
const Template: StoryFn<typeof BlockBoundWitnessDetails> = args => <BlockBoundWitnessDetails {...args} />
|
|
19
|
+
|
|
20
|
+
type EventData = {
|
|
21
|
+
data: string | undefined
|
|
22
|
+
noun: BlockHeaderEventNouns
|
|
23
|
+
verb: string
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// TODO - bring back once we add events to the BlockBoundWitnessDetails tx table
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
28
|
+
const TemplateWithEvents: StoryFn<typeof BlockBoundWitnessDetails> = (args) => {
|
|
29
|
+
const [eventData, setEventData] = useState<EventData[]>([])
|
|
30
|
+
const [ref] = useBlockHeadingEvents<HTMLDivElement>((noun, verb, data) => {
|
|
31
|
+
setEventData(previous => [...previous, {
|
|
32
|
+
noun, verb, data,
|
|
33
|
+
}])
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<div ref={ref}>
|
|
38
|
+
<BlockBoundWitnessDetails {...args} />
|
|
39
|
+
<Stack gap={2} flexDirection="column">
|
|
40
|
+
{eventData.length > 0 && eventData.map(event => (
|
|
41
|
+
<Alert key={event.data} sx={{ display: 'flex' }}>
|
|
42
|
+
<AlertTitle>Event Data</AlertTitle>
|
|
43
|
+
<List>
|
|
44
|
+
<ListItem>
|
|
45
|
+
Noun:
|
|
46
|
+
{event.noun}
|
|
47
|
+
</ListItem>
|
|
48
|
+
<ListItem>
|
|
49
|
+
Verb:
|
|
50
|
+
{event.verb}
|
|
51
|
+
</ListItem>
|
|
52
|
+
</List>
|
|
53
|
+
<pre>
|
|
54
|
+
<code>{event.data}</code>
|
|
55
|
+
</pre>
|
|
56
|
+
</Alert>
|
|
57
|
+
))}
|
|
58
|
+
</Stack>
|
|
59
|
+
</div>
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const Default = Template.bind({})
|
|
64
|
+
Default.args = {}
|
|
65
|
+
|
|
66
|
+
const WithData = Template.bind({})
|
|
67
|
+
WithData.args = { block: blocks[3] }
|
|
68
|
+
|
|
69
|
+
// const WithDataEvents = TemplateWithEvents.bind({})
|
|
70
|
+
// WithDataEvents.args = { block: blocks[0], transactions: undefined }
|
|
71
|
+
|
|
72
|
+
export { Default, WithData }
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Divider, TableCell, TableHead, TableRow,
|
|
3
|
+
} from '@mui/material'
|
|
4
|
+
import { filterAs } from '@xylabs/array'
|
|
5
|
+
import { ErrorRender } from '@xylabs/react-error'
|
|
6
|
+
import type { FlexBoxProps } from '@xylabs/react-flexbox'
|
|
7
|
+
import { FlexCol } from '@xylabs/react-flexbox'
|
|
8
|
+
import { usePromise } from '@xylabs/react-promise'
|
|
9
|
+
import { isBoundWitness } from '@xyo-network/boundwitness-model'
|
|
10
|
+
import { PayloadBuilder } from '@xyo-network/payload-builder'
|
|
11
|
+
import {
|
|
12
|
+
BoundWitnessPayloadsTable,
|
|
13
|
+
BoundWitnessSignatureTable,
|
|
14
|
+
BWActions,
|
|
15
|
+
HashHeadingPaper,
|
|
16
|
+
HeadingPaper,
|
|
17
|
+
} from '@xyo-network/react-boundwitness-plugin'
|
|
18
|
+
import { useTxsFromBlock } from '@xyo-network/react-chain-blockchain'
|
|
19
|
+
import { HashTableCell, usePayloadHash } from '@xyo-network/react-shared'
|
|
20
|
+
import { TableEx } from '@xyo-network/react-table'
|
|
21
|
+
import { isTransactionBoundWitness, type SignedHydratedBlock } from '@xyo-network/xl1-protocol'
|
|
22
|
+
import React from 'react'
|
|
23
|
+
import { FaSignature } from 'react-icons/fa'
|
|
24
|
+
import { GrTransaction } from 'react-icons/gr'
|
|
25
|
+
import { VscSymbolMethod, VscSymbolNamespace } from 'react-icons/vsc'
|
|
26
|
+
|
|
27
|
+
export interface BoundWitnessDetailsProps extends FlexBoxProps {
|
|
28
|
+
block?: SignedHydratedBlock
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const BlockBoundWitnessDetails = ({
|
|
32
|
+
ref, block, paper, children, ...props
|
|
33
|
+
}: BoundWitnessDetailsProps & { ref?: React.Ref<unknown | null> }) => {
|
|
34
|
+
const boundWitness = block?.[0]
|
|
35
|
+
const payloads = block?.[1]
|
|
36
|
+
|
|
37
|
+
const hash = usePayloadHash(boundWitness)
|
|
38
|
+
|
|
39
|
+
const [transactions, txFromBlockError] = useTxsFromBlock(block)
|
|
40
|
+
|
|
41
|
+
const [nonTxBoundWitnesses, bwsFromBlockError] = usePromise(async () => {
|
|
42
|
+
const bws = filterAs(payloads ?? [], payload =>
|
|
43
|
+
(!isTransactionBoundWitness(payload) && isBoundWitness(payload)) ? payload : undefined)
|
|
44
|
+
return await PayloadBuilder.hashPairs(bws)
|
|
45
|
+
}, [payloads])
|
|
46
|
+
|
|
47
|
+
const hasNonTxBoundWitnesses = (nonTxBoundWitnesses?.length ?? 0) > 0
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<FlexCol alignItems="stretch" rowGap={4} {...props}>
|
|
51
|
+
<ErrorRender error={txFromBlockError ?? bwsFromBlockError} scope="BlockBoundWitnessDetails.tsx" />
|
|
52
|
+
<HashHeadingPaper
|
|
53
|
+
hash={hash}
|
|
54
|
+
paperProps={{ sx: { p: 2 } }}
|
|
55
|
+
AdornmentEnd={<BWActions boundwitness={boundWitness} />}
|
|
56
|
+
identiconProps={{ p: 0.75, size: 24 }}
|
|
57
|
+
/>
|
|
58
|
+
<Divider flexItem />
|
|
59
|
+
{transactions?.length && (
|
|
60
|
+
<FlexCol alignItems="stretch" rowGap={1} mb={1}>
|
|
61
|
+
<HeadingPaper IconComponent={<GrTransaction />} heading="Transactions" />
|
|
62
|
+
<TableEx>
|
|
63
|
+
<TableHead>
|
|
64
|
+
<TableRow>
|
|
65
|
+
<TableCell>
|
|
66
|
+
Hash
|
|
67
|
+
</TableCell>
|
|
68
|
+
</TableRow>
|
|
69
|
+
</TableHead>
|
|
70
|
+
{
|
|
71
|
+
transactions?.map(([, txHash]) => (
|
|
72
|
+
<TableRow
|
|
73
|
+
key={hash + txHash}
|
|
74
|
+
// onClick={() => handleOnClick(hash)} sx={{ cursor: 'pointer' }}
|
|
75
|
+
>
|
|
76
|
+
<HashTableCell title={hash}>{hash}</HashTableCell>
|
|
77
|
+
</TableRow>
|
|
78
|
+
))
|
|
79
|
+
}
|
|
80
|
+
</TableEx>
|
|
81
|
+
</FlexCol>
|
|
82
|
+
)}
|
|
83
|
+
<FlexCol alignItems="stretch" rowGap={1} mb={1}>
|
|
84
|
+
<HeadingPaper IconComponent={<VscSymbolNamespace />} heading="Payloads" />
|
|
85
|
+
<BoundWitnessPayloadsTable boundwitness={boundWitness} />
|
|
86
|
+
</FlexCol>
|
|
87
|
+
{hasNonTxBoundWitnesses
|
|
88
|
+
? (
|
|
89
|
+
<FlexCol alignItems="stretch" rowGap={1} mb={1}>
|
|
90
|
+
<HeadingPaper IconComponent={<VscSymbolMethod />} heading="Bound Witnesses" />
|
|
91
|
+
<TableEx>
|
|
92
|
+
<TableHead>
|
|
93
|
+
<TableRow>
|
|
94
|
+
<TableCell>
|
|
95
|
+
Schema
|
|
96
|
+
</TableCell>
|
|
97
|
+
</TableRow>
|
|
98
|
+
</TableHead>
|
|
99
|
+
{
|
|
100
|
+
nonTxBoundWitnesses?.map(([, bwHash]) => (
|
|
101
|
+
<TableRow
|
|
102
|
+
key={hash + bwHash}
|
|
103
|
+
// onClick={() => handleOnClick(hash)} sx={{ cursor: 'pointer' }}
|
|
104
|
+
>
|
|
105
|
+
<HashTableCell title={hash}>{hash}</HashTableCell>
|
|
106
|
+
</TableRow>
|
|
107
|
+
))
|
|
108
|
+
}
|
|
109
|
+
</TableEx>
|
|
110
|
+
</FlexCol>
|
|
111
|
+
)
|
|
112
|
+
: null}
|
|
113
|
+
<FlexCol alignItems="stretch" rowGap={1} mb={1}>
|
|
114
|
+
<HeadingPaper IconComponent={<FaSignature />} heading="Signatures" />
|
|
115
|
+
<BoundWitnessSignatureTable block={boundWitness} />
|
|
116
|
+
</FlexCol>
|
|
117
|
+
</FlexCol>
|
|
118
|
+
)
|
|
119
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './BlockBoundWitnessDetails.tsx'
|
package/src/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from './components/index.ts'
|