@xyo-network/react-chain-boundwitness 1.3.19 → 1.3.21
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/browser/index.mjs +81 -43
- package/dist/browser/index.mjs.map +1 -1
- package/dist/types/components/BlockBoundWitnessDetails.d.ts +1 -4
- package/dist/types/components/BlockBoundWitnessDetails.d.ts.map +1 -1
- package/dist/types/components/BwPayloadTable.d.ts +13 -0
- package/dist/types/components/BwPayloadTable.d.ts.map +1 -0
- package/dist/types/components/index.d.ts +1 -0
- package/dist/types/components/index.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types/CustomBWEvents.d.ts +3 -0
- package/dist/types/types/CustomBWEvents.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +2 -0
- package/dist/types/types/index.d.ts.map +1 -0
- package/package.json +4 -3
- package/src/components/BlockBoundWitnessDetails.stories.tsx +25 -41
- package/src/components/BlockBoundWitnessDetails.tsx +42 -54
- package/src/components/BwPayloadTable.tsx +38 -0
- package/src/components/index.ts +1 -0
- package/src/index.ts +1 -0
- package/src/types/CustomBWEvents.ts +2 -0
- package/src/types/index.ts +1 -0
package/dist/browser/index.mjs
CHANGED
|
@@ -2,100 +2,138 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
|
|
4
4
|
// src/components/BlockBoundWitnessDetails.tsx
|
|
5
|
-
import { Divider
|
|
5
|
+
import { Divider } from "@mui/material";
|
|
6
6
|
import { filterAs } from "@xylabs/array";
|
|
7
7
|
import { ErrorRender } from "@xylabs/react-error";
|
|
8
|
-
import { FlexCol } from "@xylabs/react-flexbox";
|
|
8
|
+
import { FlexCol as FlexCol2 } from "@xylabs/react-flexbox";
|
|
9
9
|
import { usePromise } from "@xylabs/react-promise";
|
|
10
10
|
import { isBoundWitness } from "@xyo-network/boundwitness-model";
|
|
11
11
|
import { PayloadBuilder } from "@xyo-network/payload-builder";
|
|
12
|
-
import { BoundWitnessPayloadsTable, BoundWitnessSignatureTable, BWActions, HashHeadingPaper, HeadingPaper } from "@xyo-network/react-boundwitness-plugin";
|
|
12
|
+
import { BoundWitnessPayloadsTable, BoundWitnessSignatureTable, BWActions, HashHeadingPaper, HeadingPaper as HeadingPaper2 } from "@xyo-network/react-boundwitness-plugin";
|
|
13
13
|
import { useTxsFromBlock } from "@xyo-network/react-chain-blockchain";
|
|
14
|
-
import {
|
|
15
|
-
import { TableEx } from "@xyo-network/react-table";
|
|
14
|
+
import { usePayloadHash } from "@xyo-network/react-shared";
|
|
16
15
|
import { isTransactionBoundWitness } from "@xyo-network/xl1-protocol";
|
|
17
|
-
import
|
|
16
|
+
import React2, { useMemo } from "react";
|
|
18
17
|
import { FaSignature } from "react-icons/fa";
|
|
19
18
|
import { GrTransaction } from "react-icons/gr";
|
|
20
|
-
import { VscSymbolMethod, VscSymbolNamespace } from "react-icons/vsc";
|
|
21
|
-
|
|
19
|
+
import { VscSymbolMethod as VscSymbolMethod2, VscSymbolNamespace } from "react-icons/vsc";
|
|
20
|
+
|
|
21
|
+
// src/components/BwPayloadTable.tsx
|
|
22
|
+
import { FlexCol } from "@xylabs/react-flexbox";
|
|
23
|
+
import { BoundWitnessPayloadTableBody, BoundWitnessPayloadTableHead, HeadingPaper } from "@xyo-network/react-boundwitness-plugin";
|
|
24
|
+
import { TableEx } from "@xyo-network/react-table";
|
|
25
|
+
import React from "react";
|
|
26
|
+
import { VscSymbolMethod } from "react-icons/vsc";
|
|
27
|
+
var BWPayloadTableFlexbox = /* @__PURE__ */ __name(({ IconComponent, eventNoun, hashes, schemas, headingTitle, ...props }) => {
|
|
28
|
+
const resolvedIconComponent = IconComponent ?? /* @__PURE__ */ React.createElement(VscSymbolMethod, null);
|
|
29
|
+
return /* @__PURE__ */ React.createElement(FlexCol, {
|
|
30
|
+
alignItems: "stretch",
|
|
31
|
+
rowGap: 1,
|
|
32
|
+
...props
|
|
33
|
+
}, /* @__PURE__ */ React.createElement(HeadingPaper, {
|
|
34
|
+
IconComponent: resolvedIconComponent,
|
|
35
|
+
heading: headingTitle
|
|
36
|
+
}), /* @__PURE__ */ React.createElement(TableEx, null, /* @__PURE__ */ React.createElement(BoundWitnessPayloadTableHead, null), /* @__PURE__ */ React.createElement(BoundWitnessPayloadTableBody, {
|
|
37
|
+
payloadHashes: hashes,
|
|
38
|
+
payloadSchemas: schemas,
|
|
39
|
+
eventNoun
|
|
40
|
+
})));
|
|
41
|
+
}, "BWPayloadTableFlexbox");
|
|
42
|
+
|
|
43
|
+
// src/components/BlockBoundWitnessDetails.tsx
|
|
44
|
+
var formatBwsForTable = /* @__PURE__ */ __name((pairs) => {
|
|
45
|
+
let hashes = [];
|
|
46
|
+
let schemas = [];
|
|
47
|
+
for (const [bw, hash] of pairs ?? []) {
|
|
48
|
+
hashes.push(hash);
|
|
49
|
+
schemas.push(bw?.schema ?? "");
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
hashes,
|
|
53
|
+
schemas
|
|
54
|
+
};
|
|
55
|
+
}, "formatBwsForTable");
|
|
56
|
+
var BlockBoundWitnessDetails = /* @__PURE__ */ __name(({ block, paper, children, ...props }) => {
|
|
22
57
|
const boundWitness = block?.[0];
|
|
23
58
|
const payloads = block?.[1];
|
|
24
59
|
const hash = usePayloadHash(boundWitness);
|
|
25
60
|
const [transactions, txFromBlockError] = useTxsFromBlock(block);
|
|
61
|
+
const { hashes: txHashes, schemas: txSchemas } = useMemo(() => formatBwsForTable(transactions ?? []), [
|
|
62
|
+
transactions
|
|
63
|
+
]);
|
|
26
64
|
const [nonTxBoundWitnesses, bwsFromBlockError] = usePromise(async () => {
|
|
27
65
|
const bws = filterAs(payloads ?? [], (payload) => !isTransactionBoundWitness(payload) && isBoundWitness(payload) ? payload : void 0);
|
|
28
66
|
return await PayloadBuilder.hashPairs(bws);
|
|
29
67
|
}, [
|
|
30
68
|
payloads
|
|
31
69
|
]);
|
|
70
|
+
const { hashes: nonTxBwHashes, schemas: nonTxBwSchemas } = useMemo(() => formatBwsForTable(nonTxBoundWitnesses ?? []), [
|
|
71
|
+
nonTxBoundWitnesses
|
|
72
|
+
]);
|
|
32
73
|
const hasNonTxBoundWitnesses = (nonTxBoundWitnesses?.length ?? 0) > 0;
|
|
33
|
-
return /* @__PURE__ */
|
|
74
|
+
return /* @__PURE__ */ React2.createElement(FlexCol2, {
|
|
34
75
|
alignItems: "stretch",
|
|
35
76
|
rowGap: 4,
|
|
36
77
|
...props
|
|
37
|
-
}, /* @__PURE__ */
|
|
78
|
+
}, /* @__PURE__ */ React2.createElement(ErrorRender, {
|
|
38
79
|
error: txFromBlockError ?? bwsFromBlockError,
|
|
39
80
|
scope: "BlockBoundWitnessDetails.tsx"
|
|
40
|
-
}), /* @__PURE__ */
|
|
81
|
+
}), /* @__PURE__ */ React2.createElement(HashHeadingPaper, {
|
|
41
82
|
hash,
|
|
42
83
|
paperProps: {
|
|
43
84
|
sx: {
|
|
44
85
|
p: 2
|
|
45
86
|
}
|
|
46
87
|
},
|
|
47
|
-
AdornmentEnd: /* @__PURE__ */
|
|
88
|
+
AdornmentEnd: /* @__PURE__ */ React2.createElement(BWActions, {
|
|
48
89
|
boundwitness: boundWitness
|
|
49
90
|
}),
|
|
50
91
|
identiconProps: {
|
|
51
92
|
p: 0.75,
|
|
52
93
|
size: 24
|
|
53
94
|
}
|
|
54
|
-
}), /* @__PURE__ */
|
|
95
|
+
}), /* @__PURE__ */ React2.createElement(Divider, {
|
|
55
96
|
flexItem: true
|
|
56
|
-
}), (transactions?.length ?? 0) > 0 && /* @__PURE__ */
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}, /* @__PURE__ */
|
|
66
|
-
title: hash
|
|
67
|
-
}, hash))))), /* @__PURE__ */ React.createElement(FlexCol, {
|
|
97
|
+
}), (transactions?.length ?? 0) > 0 && /* @__PURE__ */ React2.createElement(BWPayloadTableFlexbox, {
|
|
98
|
+
IconComponent: /* @__PURE__ */ React2.createElement(GrTransaction, null),
|
|
99
|
+
eventNoun: "transaction",
|
|
100
|
+
hashes: txHashes,
|
|
101
|
+
headingTitle: "Transactions",
|
|
102
|
+
schemas: txSchemas,
|
|
103
|
+
sx: {
|
|
104
|
+
mb: 1
|
|
105
|
+
}
|
|
106
|
+
}), /* @__PURE__ */ React2.createElement(FlexCol2, {
|
|
68
107
|
alignItems: "stretch",
|
|
69
108
|
rowGap: 1,
|
|
70
109
|
mb: 1
|
|
71
|
-
}, /* @__PURE__ */
|
|
72
|
-
IconComponent: /* @__PURE__ */
|
|
110
|
+
}, /* @__PURE__ */ React2.createElement(HeadingPaper2, {
|
|
111
|
+
IconComponent: /* @__PURE__ */ React2.createElement(VscSymbolNamespace, null),
|
|
73
112
|
heading: "Payloads"
|
|
74
|
-
}), /* @__PURE__ */
|
|
113
|
+
}), /* @__PURE__ */ React2.createElement(BoundWitnessPayloadsTable, {
|
|
75
114
|
boundwitness: boundWitness
|
|
76
|
-
})), hasNonTxBoundWitnesses ? /* @__PURE__ */
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}, /* @__PURE__ */
|
|
86
|
-
title: hash
|
|
87
|
-
}, hash))))) : null, /* @__PURE__ */ React.createElement(FlexCol, {
|
|
115
|
+
})), hasNonTxBoundWitnesses ? /* @__PURE__ */ React2.createElement(BWPayloadTableFlexbox, {
|
|
116
|
+
IconComponent: /* @__PURE__ */ React2.createElement(VscSymbolMethod2, null),
|
|
117
|
+
eventNoun: "boundwitness",
|
|
118
|
+
hashes: nonTxBwHashes,
|
|
119
|
+
headingTitle: "Bound Witnesses",
|
|
120
|
+
schemas: nonTxBwSchemas,
|
|
121
|
+
sx: {
|
|
122
|
+
mb: 1
|
|
123
|
+
}
|
|
124
|
+
}) : null, /* @__PURE__ */ React2.createElement(FlexCol2, {
|
|
88
125
|
alignItems: "stretch",
|
|
89
126
|
rowGap: 1,
|
|
90
127
|
mb: 1
|
|
91
|
-
}, /* @__PURE__ */
|
|
92
|
-
IconComponent: /* @__PURE__ */
|
|
128
|
+
}, /* @__PURE__ */ React2.createElement(HeadingPaper2, {
|
|
129
|
+
IconComponent: /* @__PURE__ */ React2.createElement(FaSignature, null),
|
|
93
130
|
heading: "Signatures"
|
|
94
|
-
}), /* @__PURE__ */
|
|
131
|
+
}), /* @__PURE__ */ React2.createElement(BoundWitnessSignatureTable, {
|
|
95
132
|
block: boundWitness
|
|
96
133
|
})));
|
|
97
134
|
}, "BlockBoundWitnessDetails");
|
|
98
135
|
export {
|
|
136
|
+
BWPayloadTableFlexbox,
|
|
99
137
|
BlockBoundWitnessDetails
|
|
100
138
|
};
|
|
101
139
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
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 ?? 0) > 0 && (\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,SAASC,WAAWC,WAAWC,gBAC1B;AACP,SAASC,gBAAgB;AACzB,SAASC,mBAAmB;AAE5B,SAASC,eAAe;AACxB,SAASC,kBAAkB;AAC3B,SAASC,sBAAsB;AAC/B,SAASC,sBAAsB;AAC/B,SACEC,2BACAC,4BACAC,WACAC,kBACAC,oBACK;AACP,SAASC,uBAAuB;AAChC,SAASC,eAAeC,sBAAsB;AAC9C,SAASC,eAAe;AACxB,SAASC,iCAA2D;AACpE,OAAOC,WAAW;AAClB,SAASC,mBAAmB;AAC5B,SAASC,qBAAqB;AAC9B,SAASC,iBAAiBC,0BAA0B;AAM7C,IAAMC,2BAA2B,wBAAC,EACvCC,KAAKC,OAAOC,OAAOC,UAAU,GAAGC,MAAAA,MAC+B;AAC/D,QAAMC,eAAeJ,QAAQ,CAAA;AAC7B,QAAMK,WAAWL,QAAQ,CAAA;AAEzB,QAAMM,OAAOC,eAAeH,YAAAA;AAE5B,QAAM,CAACI,cAAcC,gBAAAA,IAAoB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Q;IAAGe,IAAI;KAC3C,sBAAA,cAACC,cAAAA;IAAaC,eAAe,sBAAA,cAACY,oBAAAA,IAAAA;IAAuBV,SAAQ;MAC7D,sBAAA,cAACW,2BAAAA;IAA0BpB,cAAchC;OAE1CkB,yBAEK,sBAAA,cAACE,SAAAA;IAAQC,YAAW;IAAUC,QAAQ;IAAGe,IAAI;KAC3C,sBAAA,cAACC,cAAAA;IAAaC,eAAe,sBAAA,cAACc,iBAAAA,IAAAA;IAAoBZ,SAAQ;MAC1D,sBAAA,cAACC,SAAAA,MACC,sBAAA,cAACC,WAAAA,MACC,sBAAA,cAACC,UAAAA,MACC,sBAAA,cAACC,WAAAA,MAAU,QAAA,CAAA,CAAA,GAMbtC,qBAAqBuC,IAAI,CAAC,CAAA,EAAGQ,MAAAA,MAC3B,sBAAA,cAACV,UAAAA;IACCI,KAAK9C,OAAOoD;KAGZ,sBAAA,cAACL,eAAAA;IAAcC,OAAOhD;KAAOA,IAAAA,CAAAA,CAAAA,CAAAA,CAAAA,IAOzC,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"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/BlockBoundWitnessDetails.tsx","../../src/components/BwPayloadTable.tsx"],"sourcesContent":["import { Divider } from '@mui/material'\nimport { filterAs } from '@xylabs/array'\nimport type { Hash } from '@xylabs/hex'\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 type { BoundWitness } from '@xyo-network/boundwitness-model'\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 { useEvent } from '@xyo-network/react-event'\nimport { usePayloadHash } from '@xyo-network/react-shared'\nimport { isTransactionBoundWitness, type SignedHydratedBlock } from '@xyo-network/xl1-protocol'\nimport React, { useMemo } from 'react'\nimport { FaSignature } from 'react-icons/fa'\nimport { GrTransaction } from 'react-icons/gr'\nimport { VscSymbolMethod, VscSymbolNamespace } from 'react-icons/vsc'\n\nimport type { TransactionBoundWitnessEvents } from '../types/index.ts'\nimport { BWPayloadTableFlexbox } from './BwPayloadTable.tsx'\n\nconst formatBwsForTable = (pairs: [BoundWitness, Hash][]) => {\n let hashes: Hash[] = []\n let schemas: string[] = []\n for (const [bw, hash] of pairs ?? []) {\n hashes.push(hash)\n schemas.push(bw?.schema ?? '')\n }\n return { hashes, schemas }\n}\n\nexport interface BoundWitnessDetailsProps extends FlexBoxProps {\n block?: SignedHydratedBlock\n}\n\nexport const BlockBoundWitnessDetails = ({\n block, paper, children, ...props\n}: BoundWitnessDetailsProps) => {\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 { hashes: txHashes, schemas: txSchemas } = useMemo(() => formatBwsForTable(transactions ?? []), [transactions])\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 { hashes: nonTxBwHashes, schemas: nonTxBwSchemas } = useMemo(() => formatBwsForTable(nonTxBoundWitnesses ?? []), [nonTxBoundWitnesses])\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 ?? 0) > 0 && (\n <BWPayloadTableFlexbox<TransactionBoundWitnessEvents>\n IconComponent={<GrTransaction />}\n eventNoun=\"transaction\"\n hashes={txHashes}\n headingTitle=\"Transactions\"\n schemas={txSchemas}\n sx={{ mb: 1 }}\n />\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 <BWPayloadTableFlexbox<TransactionBoundWitnessEvents>\n IconComponent={<VscSymbolMethod />}\n eventNoun=\"boundwitness\"\n hashes={nonTxBwHashes}\n headingTitle=\"Bound Witnesses\"\n schemas={nonTxBwSchemas}\n sx={{ mb: 1 }}\n />\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","import type { Hash } from '@xylabs/hex'\nimport type { FlexBoxProps } from '@xylabs/react-flexbox'\nimport { FlexCol } from '@xylabs/react-flexbox'\nimport {\n BoundWitnessPayloadTableBody, BoundWitnessPayloadTableHead, HeadingPaper,\n} from '@xyo-network/react-boundwitness-plugin'\nimport type { EventNoun, ExtendEventNoun } from '@xyo-network/react-event'\nimport { TableEx } from '@xyo-network/react-table'\nimport React from 'react'\nimport { VscSymbolMethod } from 'react-icons/vsc'\n\nexport interface BWPayloadTableFlexboxProps<TNoun extends ExtendEventNoun = EventNoun> extends FlexBoxProps {\n IconComponent?: React.ReactNode\n eventNoun?: TNoun\n hashes?: Hash[]\n headingTitle?: string\n schemas?: string[]\n}\n\nexport const BWPayloadTableFlexbox = <TNoun extends ExtendEventNoun = EventNoun>({\n IconComponent,\n eventNoun,\n hashes,\n schemas,\n headingTitle,\n ...props\n}: BWPayloadTableFlexboxProps<TNoun>) => {\n const resolvedIconComponent = IconComponent ?? <VscSymbolMethod />\n return (\n <FlexCol alignItems=\"stretch\" rowGap={1} {...props}>\n <HeadingPaper IconComponent={resolvedIconComponent} heading={headingTitle} />\n <TableEx>\n <BoundWitnessPayloadTableHead />\n <BoundWitnessPayloadTableBody<TNoun> payloadHashes={hashes} payloadSchemas={schemas} eventNoun={eventNoun} />\n </TableEx>\n </FlexCol>\n )\n}\n"],"mappings":";;;;AAAA,SAASA,eAAe;AACxB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cAACoB,eAAAA,IAAAA;IAChBC,WAAU;IACVxD,QAAQiB;IACRwC,cAAa;IACbxD,SAASiB;IACT0B,IAAI;MAAEc,IAAI;IAAE;MAGhB,gBAAAvB,OAAA,cAACC,UAAAA;IAAQC,YAAW;IAAUC,QAAQ;IAAGoB,IAAI;KAC3C,gBAAAvB,OAAA,cAACwB,eAAAA;IAAaL,eAAe,gBAAAnB,OAAA,cAACyB,oBAAAA,IAAAA;IAAuBC,SAAQ;MAC7D,gBAAA1B,OAAA,cAAC2B,2BAAAA;IAA0Bd,cAAcrC;OAE1CsB,yBAEG,gBAAAE,OAAA,cAACkB,uBAAAA;IACCC,eAAe,gBAAAnB,OAAA,cAAC4B,kBAAAA,IAAAA;IAChBP,WAAU;IACVxD,QAAQ+B;IACR0B,cAAa;IACbxD,SAAS+B;IACTY,IAAI;MAAEc,IAAI;IAAE;OAGd,MACJ,gBAAAvB,OAAA,cAACC,UAAAA;IAAQC,YAAW;IAAUC,QAAQ;IAAGoB,IAAI;KAC3C,gBAAAvB,OAAA,cAACwB,eAAAA;IAAaL,eAAe,gBAAAnB,OAAA,cAAC6B,aAAAA,IAAAA;IAAgBH,SAAQ;MACtD,gBAAA1B,OAAA,cAAC8B,4BAAAA;IAA2B1D,OAAOI;;AAI3C,GA/DwC;","names":["Divider","filterAs","ErrorRender","FlexCol","usePromise","isBoundWitness","PayloadBuilder","BoundWitnessPayloadsTable","BoundWitnessSignatureTable","BWActions","HashHeadingPaper","HeadingPaper","useTxsFromBlock","usePayloadHash","isTransactionBoundWitness","React","useMemo","FaSignature","GrTransaction","VscSymbolMethod","VscSymbolNamespace","FlexCol","BoundWitnessPayloadTableBody","BoundWitnessPayloadTableHead","HeadingPaper","TableEx","React","VscSymbolMethod","BWPayloadTableFlexbox","IconComponent","eventNoun","hashes","schemas","headingTitle","props","resolvedIconComponent","VscSymbolMethod","FlexCol","alignItems","rowGap","HeadingPaper","heading","TableEx","BoundWitnessPayloadTableHead","BoundWitnessPayloadTableBody","payloadHashes","payloadSchemas","formatBwsForTable","pairs","hashes","schemas","bw","hash","push","schema","BlockBoundWitnessDetails","block","paper","children","props","boundWitness","payloads","usePayloadHash","transactions","txFromBlockError","useTxsFromBlock","txHashes","txSchemas","useMemo","nonTxBoundWitnesses","bwsFromBlockError","usePromise","bws","filterAs","payload","isTransactionBoundWitness","isBoundWitness","undefined","PayloadBuilder","hashPairs","nonTxBwHashes","nonTxBwSchemas","hasNonTxBoundWitnesses","length","React","FlexCol","alignItems","rowGap","ErrorRender","error","scope","HashHeadingPaper","paperProps","sx","p","AdornmentEnd","BWActions","boundwitness","identiconProps","size","Divider","flexItem","BWPayloadTableFlexbox","IconComponent","GrTransaction","eventNoun","headingTitle","mb","HeadingPaper","VscSymbolNamespace","heading","BoundWitnessPayloadsTable","VscSymbolMethod","FaSignature","BoundWitnessSignatureTable"]}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import type { FlexBoxProps } from '@xylabs/react-flexbox';
|
|
2
2
|
import { type SignedHydratedBlock } from '@xyo-network/xl1-protocol';
|
|
3
|
-
import React from 'react';
|
|
4
3
|
export interface BoundWitnessDetailsProps extends FlexBoxProps {
|
|
5
4
|
block?: SignedHydratedBlock;
|
|
6
5
|
}
|
|
7
|
-
export declare const BlockBoundWitnessDetails: ({
|
|
8
|
-
ref?: React.Ref<unknown | null>;
|
|
9
|
-
}) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare const BlockBoundWitnessDetails: ({ block, paper, children, ...props }: BoundWitnessDetailsProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
7
|
//# sourceMappingURL=BlockBoundWitnessDetails.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlockBoundWitnessDetails.d.ts","sourceRoot":"","sources":["../../../src/components/BlockBoundWitnessDetails.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BlockBoundWitnessDetails.d.ts","sourceRoot":"","sources":["../../../src/components/BlockBoundWitnessDetails.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAgBzD,OAAO,EAA6B,KAAK,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AAmB/F,MAAM,WAAW,wBAAyB,SAAQ,YAAY;IAC5D,KAAK,CAAC,EAAE,mBAAmB,CAAA;CAC5B;AAED,eAAO,MAAM,wBAAwB,GAAI,sCAEtC,wBAAwB,4CA6D1B,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Hash } from '@xylabs/hex';
|
|
2
|
+
import type { FlexBoxProps } from '@xylabs/react-flexbox';
|
|
3
|
+
import type { EventNoun, ExtendEventNoun } from '@xyo-network/react-event';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
export interface BWPayloadTableFlexboxProps<TNoun extends ExtendEventNoun = EventNoun> extends FlexBoxProps {
|
|
6
|
+
IconComponent?: React.ReactNode;
|
|
7
|
+
eventNoun?: TNoun;
|
|
8
|
+
hashes?: Hash[];
|
|
9
|
+
headingTitle?: string;
|
|
10
|
+
schemas?: string[];
|
|
11
|
+
}
|
|
12
|
+
export declare const BWPayloadTableFlexbox: <TNoun extends ExtendEventNoun = EventNoun>({ IconComponent, eventNoun, hashes, schemas, headingTitle, ...props }: BWPayloadTableFlexboxProps<TNoun>) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
//# sourceMappingURL=BwPayloadTable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BwPayloadTable.d.ts","sourceRoot":"","sources":["../../../src/components/BwPayloadTable.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAKzD,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAE1E,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,MAAM,WAAW,0BAA0B,CAAC,KAAK,SAAS,eAAe,GAAG,SAAS,CAAE,SAAQ,YAAY;IACzG,aAAa,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC/B,SAAS,CAAC,EAAE,KAAK,CAAA;IACjB,MAAM,CAAC,EAAE,IAAI,EAAE,CAAA;IACf,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CACnB;AAED,eAAO,MAAM,qBAAqB,GAAI,KAAK,SAAS,eAAe,GAAG,SAAS,EAAE,uEAO9E,0BAA0B,CAAC,KAAK,CAAC,4CAWnC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAA;AAC9C,cAAc,sBAAsB,CAAA"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,kBAAkB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomBWEvents.d.ts","sourceRoot":"","sources":["../../../src/types/CustomBWEvents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC/D,MAAM,MAAM,6BAA6B,GAAG,eAAe,CAAC,aAAa,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,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.21",
|
|
5
5
|
"description": "XYO Layer One React SDK BoundWitness",
|
|
6
6
|
"homepage": "https://xylabs.com",
|
|
7
7
|
"bugs": {
|
|
@@ -41,7 +41,8 @@
|
|
|
41
41
|
"@xyo-network/boundwitness-model": "^3.15.5",
|
|
42
42
|
"@xyo-network/payload-builder": "^3.15.5",
|
|
43
43
|
"@xyo-network/react-boundwitness-plugin": "^5.3.2",
|
|
44
|
-
"@xyo-network/react-chain-blockchain": "^1.3.
|
|
44
|
+
"@xyo-network/react-chain-blockchain": "^1.3.21",
|
|
45
|
+
"@xyo-network/react-event": "^5.3.2",
|
|
45
46
|
"@xyo-network/react-shared": "^5.3.2",
|
|
46
47
|
"@xyo-network/react-table": "^5.3.2",
|
|
47
48
|
"@xyo-network/xl1-protocol": "^1.3.13",
|
|
@@ -54,7 +55,7 @@
|
|
|
54
55
|
"@mui/material": "^7.1.0",
|
|
55
56
|
"@xylabs/ts-scripts-yarn3": "^6.5.5",
|
|
56
57
|
"@xylabs/tsconfig-react": "^6.5.5",
|
|
57
|
-
"@xyo-network/react-chain-shared": "^1.3.
|
|
58
|
+
"@xyo-network/react-chain-shared": "^1.3.21",
|
|
58
59
|
"knip": "^5.55.1",
|
|
59
60
|
"react": "^19.1.0",
|
|
60
61
|
"react-dom": "^19.1.0",
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
-
Alert, AlertTitle,
|
|
2
|
+
Alert, AlertTitle,
|
|
3
|
+
Snackbar,
|
|
3
4
|
} from '@mui/material'
|
|
4
5
|
import type { Meta, StoryFn } from '@storybook/react'
|
|
5
6
|
import { type BlockHeaderEventNouns, useBlockHeadingEvents } from '@xyo-network/react-chain-blockchain'
|
|
6
7
|
import { buildRandomBlockChain } from '@xyo-network/react-chain-shared'
|
|
8
|
+
import type { Event } from '@xyo-network/react-event'
|
|
7
9
|
import React, { useState } from 'react'
|
|
8
10
|
|
|
9
11
|
import { BlockBoundWitnessDetails } from './BlockBoundWitnessDetails.tsx'
|
|
@@ -17,46 +19,26 @@ const blocks = await buildRandomBlockChain()
|
|
|
17
19
|
|
|
18
20
|
const Template: StoryFn<typeof BlockBoundWitnessDetails> = args => <BlockBoundWitnessDetails {...args} />
|
|
19
21
|
|
|
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
22
|
const TemplateWithEvents: StoryFn<typeof BlockBoundWitnessDetails> = (args) => {
|
|
29
|
-
const [
|
|
30
|
-
const [ref] = useBlockHeadingEvents
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}])
|
|
34
|
-
})
|
|
23
|
+
const [event, setEvent] = useState<Event<BlockHeaderEventNouns>>()
|
|
24
|
+
const [ref] = useBlockHeadingEvents((noun, verb, data) => setEvent({
|
|
25
|
+
noun, verb, data,
|
|
26
|
+
}))
|
|
35
27
|
|
|
36
28
|
return (
|
|
37
|
-
|
|
38
|
-
<BlockBoundWitnessDetails {...args} />
|
|
39
|
-
<
|
|
40
|
-
|
|
41
|
-
<
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
{event.verb}
|
|
51
|
-
</ListItem>
|
|
52
|
-
</List>
|
|
53
|
-
<pre>
|
|
54
|
-
<code>{event.data}</code>
|
|
55
|
-
</pre>
|
|
56
|
-
</Alert>
|
|
57
|
-
))}
|
|
58
|
-
</Stack>
|
|
59
|
-
</div>
|
|
29
|
+
<>
|
|
30
|
+
<BlockBoundWitnessDetails ref={ref} {...args} />
|
|
31
|
+
<Snackbar open={!!event} onClose={() => setEvent(undefined)}>
|
|
32
|
+
<Alert>
|
|
33
|
+
<AlertTitle>
|
|
34
|
+
Event -
|
|
35
|
+
{' '}
|
|
36
|
+
{event?.noun}
|
|
37
|
+
</AlertTitle>
|
|
38
|
+
<pre>{JSON.stringify(event, null, 2)}</pre>
|
|
39
|
+
</Alert>
|
|
40
|
+
</Snackbar>
|
|
41
|
+
</>
|
|
60
42
|
)
|
|
61
43
|
}
|
|
62
44
|
|
|
@@ -66,7 +48,9 @@ Default.args = {}
|
|
|
66
48
|
const WithData = Template.bind({})
|
|
67
49
|
WithData.args = { block: blocks[3] }
|
|
68
50
|
|
|
69
|
-
|
|
70
|
-
|
|
51
|
+
const WithDataEvents = TemplateWithEvents.bind({})
|
|
52
|
+
WithDataEvents.args = { block: blocks[3] }
|
|
71
53
|
|
|
72
|
-
export {
|
|
54
|
+
export {
|
|
55
|
+
Default, WithData, WithDataEvents,
|
|
56
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Divider, TableCell, TableHead, TableRow,
|
|
3
|
-
} from '@mui/material'
|
|
1
|
+
import { Divider } from '@mui/material'
|
|
4
2
|
import { filterAs } from '@xylabs/array'
|
|
3
|
+
import type { Hash } from '@xylabs/hex'
|
|
5
4
|
import { ErrorRender } from '@xylabs/react-error'
|
|
6
5
|
import type { FlexBoxProps } from '@xylabs/react-flexbox'
|
|
7
6
|
import { FlexCol } from '@xylabs/react-flexbox'
|
|
8
7
|
import { usePromise } from '@xylabs/react-promise'
|
|
8
|
+
import type { BoundWitness } from '@xyo-network/boundwitness-model'
|
|
9
9
|
import { isBoundWitness } from '@xyo-network/boundwitness-model'
|
|
10
10
|
import { PayloadBuilder } from '@xyo-network/payload-builder'
|
|
11
11
|
import {
|
|
@@ -16,21 +16,34 @@ import {
|
|
|
16
16
|
HeadingPaper,
|
|
17
17
|
} from '@xyo-network/react-boundwitness-plugin'
|
|
18
18
|
import { useTxsFromBlock } from '@xyo-network/react-chain-blockchain'
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
19
|
+
import { useEvent } from '@xyo-network/react-event'
|
|
20
|
+
import { usePayloadHash } from '@xyo-network/react-shared'
|
|
21
21
|
import { isTransactionBoundWitness, type SignedHydratedBlock } from '@xyo-network/xl1-protocol'
|
|
22
|
-
import React from 'react'
|
|
22
|
+
import React, { useMemo } from 'react'
|
|
23
23
|
import { FaSignature } from 'react-icons/fa'
|
|
24
24
|
import { GrTransaction } from 'react-icons/gr'
|
|
25
25
|
import { VscSymbolMethod, VscSymbolNamespace } from 'react-icons/vsc'
|
|
26
26
|
|
|
27
|
+
import type { TransactionBoundWitnessEvents } from '../types/index.ts'
|
|
28
|
+
import { BWPayloadTableFlexbox } from './BwPayloadTable.tsx'
|
|
29
|
+
|
|
30
|
+
const formatBwsForTable = (pairs: [BoundWitness, Hash][]) => {
|
|
31
|
+
let hashes: Hash[] = []
|
|
32
|
+
let schemas: string[] = []
|
|
33
|
+
for (const [bw, hash] of pairs ?? []) {
|
|
34
|
+
hashes.push(hash)
|
|
35
|
+
schemas.push(bw?.schema ?? '')
|
|
36
|
+
}
|
|
37
|
+
return { hashes, schemas }
|
|
38
|
+
}
|
|
39
|
+
|
|
27
40
|
export interface BoundWitnessDetailsProps extends FlexBoxProps {
|
|
28
41
|
block?: SignedHydratedBlock
|
|
29
42
|
}
|
|
30
43
|
|
|
31
44
|
export const BlockBoundWitnessDetails = ({
|
|
32
|
-
|
|
33
|
-
}: BoundWitnessDetailsProps
|
|
45
|
+
block, paper, children, ...props
|
|
46
|
+
}: BoundWitnessDetailsProps) => {
|
|
34
47
|
const boundWitness = block?.[0]
|
|
35
48
|
const payloads = block?.[1]
|
|
36
49
|
|
|
@@ -38,13 +51,16 @@ export const BlockBoundWitnessDetails = ({
|
|
|
38
51
|
|
|
39
52
|
const [transactions, txFromBlockError] = useTxsFromBlock(block)
|
|
40
53
|
|
|
54
|
+
const { hashes: txHashes, schemas: txSchemas } = useMemo(() => formatBwsForTable(transactions ?? []), [transactions])
|
|
55
|
+
|
|
41
56
|
const [nonTxBoundWitnesses, bwsFromBlockError] = usePromise(async () => {
|
|
42
57
|
const bws = filterAs(payloads ?? [], payload =>
|
|
43
58
|
(!isTransactionBoundWitness(payload) && isBoundWitness(payload)) ? payload : undefined)
|
|
44
59
|
return await PayloadBuilder.hashPairs(bws)
|
|
45
60
|
}, [payloads])
|
|
46
61
|
|
|
47
|
-
|
|
62
|
+
const { hashes: nonTxBwHashes, schemas: nonTxBwSchemas } = useMemo(() => formatBwsForTable(nonTxBoundWitnesses ?? []), [nonTxBoundWitnesses])
|
|
63
|
+
const hasNonTxBoundWitnesses = (nonTxBoundWitnesses?.length ?? 0) > 0
|
|
48
64
|
|
|
49
65
|
return (
|
|
50
66
|
<FlexCol alignItems="stretch" rowGap={4} {...props}>
|
|
@@ -57,57 +73,29 @@ export const BlockBoundWitnessDetails = ({
|
|
|
57
73
|
/>
|
|
58
74
|
<Divider flexItem />
|
|
59
75
|
{(transactions?.length ?? 0) > 0 && (
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
-
)}
|
|
76
|
+
<BWPayloadTableFlexbox<TransactionBoundWitnessEvents>
|
|
77
|
+
IconComponent={<GrTransaction />}
|
|
78
|
+
eventNoun="transaction"
|
|
79
|
+
hashes={txHashes}
|
|
80
|
+
headingTitle="Transactions"
|
|
81
|
+
schemas={txSchemas}
|
|
82
|
+
sx={{ mb: 1 }}
|
|
83
|
+
/>
|
|
84
|
+
)}
|
|
83
85
|
<FlexCol alignItems="stretch" rowGap={1} mb={1}>
|
|
84
86
|
<HeadingPaper IconComponent={<VscSymbolNamespace />} heading="Payloads" />
|
|
85
87
|
<BoundWitnessPayloadsTable boundwitness={boundWitness} />
|
|
86
88
|
</FlexCol>
|
|
87
89
|
{hasNonTxBoundWitnesses
|
|
88
90
|
? (
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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>
|
|
91
|
+
<BWPayloadTableFlexbox<TransactionBoundWitnessEvents>
|
|
92
|
+
IconComponent={<VscSymbolMethod />}
|
|
93
|
+
eventNoun="boundwitness"
|
|
94
|
+
hashes={nonTxBwHashes}
|
|
95
|
+
headingTitle="Bound Witnesses"
|
|
96
|
+
schemas={nonTxBwSchemas}
|
|
97
|
+
sx={{ mb: 1 }}
|
|
98
|
+
/>
|
|
111
99
|
)
|
|
112
100
|
: null}
|
|
113
101
|
<FlexCol alignItems="stretch" rowGap={1} mb={1}>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Hash } from '@xylabs/hex'
|
|
2
|
+
import type { FlexBoxProps } from '@xylabs/react-flexbox'
|
|
3
|
+
import { FlexCol } from '@xylabs/react-flexbox'
|
|
4
|
+
import {
|
|
5
|
+
BoundWitnessPayloadTableBody, BoundWitnessPayloadTableHead, HeadingPaper,
|
|
6
|
+
} from '@xyo-network/react-boundwitness-plugin'
|
|
7
|
+
import type { EventNoun, ExtendEventNoun } from '@xyo-network/react-event'
|
|
8
|
+
import { TableEx } from '@xyo-network/react-table'
|
|
9
|
+
import React from 'react'
|
|
10
|
+
import { VscSymbolMethod } from 'react-icons/vsc'
|
|
11
|
+
|
|
12
|
+
export interface BWPayloadTableFlexboxProps<TNoun extends ExtendEventNoun = EventNoun> extends FlexBoxProps {
|
|
13
|
+
IconComponent?: React.ReactNode
|
|
14
|
+
eventNoun?: TNoun
|
|
15
|
+
hashes?: Hash[]
|
|
16
|
+
headingTitle?: string
|
|
17
|
+
schemas?: string[]
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const BWPayloadTableFlexbox = <TNoun extends ExtendEventNoun = EventNoun>({
|
|
21
|
+
IconComponent,
|
|
22
|
+
eventNoun,
|
|
23
|
+
hashes,
|
|
24
|
+
schemas,
|
|
25
|
+
headingTitle,
|
|
26
|
+
...props
|
|
27
|
+
}: BWPayloadTableFlexboxProps<TNoun>) => {
|
|
28
|
+
const resolvedIconComponent = IconComponent ?? <VscSymbolMethod />
|
|
29
|
+
return (
|
|
30
|
+
<FlexCol alignItems="stretch" rowGap={1} {...props}>
|
|
31
|
+
<HeadingPaper IconComponent={resolvedIconComponent} heading={headingTitle} />
|
|
32
|
+
<TableEx>
|
|
33
|
+
<BoundWitnessPayloadTableHead />
|
|
34
|
+
<BoundWitnessPayloadTableBody<TNoun> payloadHashes={hashes} payloadSchemas={schemas} eventNoun={eventNoun} />
|
|
35
|
+
</TableEx>
|
|
36
|
+
</FlexCol>
|
|
37
|
+
)
|
|
38
|
+
}
|
package/src/components/index.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './CustomBWEvents.ts'
|