@xyo-network/react-chain-blockchain 1.20.15 → 1.20.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (196) hide show
  1. package/README.md +9 -8854
  2. package/dist/browser/components/block/table/cell/NumberChip.d.ts.map +1 -1
  3. package/dist/browser/components/chain/controls/PulseSvgIcon.d.ts +5 -2
  4. package/dist/browser/components/chain/controls/PulseSvgIcon.d.ts.map +1 -1
  5. package/dist/browser/components/chain/hooks/useOnBlock.d.ts +7 -7
  6. package/dist/browser/components/chain/styled/BlockListWrapperFlexbox.d.ts +6 -1
  7. package/dist/browser/components/chain/styled/BlockListWrapperFlexbox.d.ts.map +1 -1
  8. package/dist/browser/components/table/StyledLinkableTableRow.d.ts +5 -4
  9. package/dist/browser/components/table/StyledLinkableTableRow.d.ts.map +1 -1
  10. package/dist/browser/context/analyzer/context.d.ts +3 -3
  11. package/dist/browser/context/analyzer/use.d.ts +1 -1
  12. package/dist/browser/context/chain/Context.d.ts +3 -3
  13. package/dist/browser/context/chain/use.d.ts +1 -1
  14. package/dist/browser/hooks/useBaseContext.d.ts +2 -8
  15. package/dist/browser/hooks/useBaseContext.d.ts.map +1 -1
  16. package/dist/browser/hooks/useTxsFromBlock.d.ts +1 -1
  17. package/dist/browser/hooks/useTxsFromBlock.d.ts.map +1 -1
  18. package/dist/browser/index.mjs.map +1 -1
  19. package/package.json +167 -58
  20. package/src/components/FeatureNotAvailable.tsx +0 -20
  21. package/src/components/account/BalanceHistoryFlexbox.stories.tsx +0 -25
  22. package/src/components/account/BalanceHistoryFlexbox.tsx +0 -53
  23. package/src/components/account/helpers/formatBalanceMagnitude.ts +0 -14
  24. package/src/components/account/helpers/index.ts +0 -1
  25. package/src/components/account/hooks/index.ts +0 -1
  26. package/src/components/account/hooks/usePagedAccountBalanceHistory.ts +0 -39
  27. package/src/components/account/index.ts +0 -4
  28. package/src/components/account/table/BalanceHistoryTableEx.stories.tsx +0 -111
  29. package/src/components/account/table/BalanceHistoryTableEx.tsx +0 -37
  30. package/src/components/account/table/BalanceHistoryTableRow.stories.tsx +0 -53
  31. package/src/components/account/table/BalanceHistoryTableRow.tsx +0 -60
  32. package/src/components/account/table/RawAmountTableCell.tsx +0 -53
  33. package/src/components/account/table/cell/AddressTableCell.tsx +0 -27
  34. package/src/components/account/table/cell/BlockNumber.tsx +0 -39
  35. package/src/components/account/table/cell/HashTableCell.tsx +0 -46
  36. package/src/components/account/table/cell/index.ts +0 -3
  37. package/src/components/account/table/hooks/index.ts +0 -1
  38. package/src/components/account/table/hooks/useLinkedBalanceHistoryItem.tsx +0 -29
  39. package/src/components/account/table/index.ts +0 -5
  40. package/src/components/account/table/types/index.ts +0 -18
  41. package/src/components/block/BlockHeadingFlexbox.stories.tsx +0 -75
  42. package/src/components/block/BlockHeadingFlexbox.tsx +0 -56
  43. package/src/components/block/ChipSkeleton.tsx +0 -7
  44. package/src/components/block/LinkedDivider.tsx +0 -27
  45. package/src/components/block/ProducerChip.tsx +0 -45
  46. package/src/components/block/helpers/blockProducer.ts +0 -5
  47. package/src/components/block/helpers/buildBlockChainRenderComponent.tsx +0 -32
  48. package/src/components/block/helpers/index.ts +0 -3
  49. package/src/components/block/helpers/payloadCountsFromBlock.ts +0 -10
  50. package/src/components/block/hooks/index.ts +0 -4
  51. package/src/components/block/hooks/useAnchorElement.ts +0 -19
  52. package/src/components/block/hooks/useBlockHeadingEvents.ts +0 -11
  53. package/src/components/block/hooks/useBlockProducer.ts +0 -11
  54. package/src/components/block/hooks/usePayloadCountsFromBlock.ts +0 -13
  55. package/src/components/block/index.ts +0 -6
  56. package/src/components/block/menu/Expanded.tsx +0 -34
  57. package/src/components/block/menu/index.ts +0 -1
  58. package/src/components/block/table/Ex.stories.tsx +0 -64
  59. package/src/components/block/table/Ex.tsx +0 -21
  60. package/src/components/block/table/cell/BlockNumber.tsx +0 -35
  61. package/src/components/block/table/cell/Epoch.tsx +0 -46
  62. package/src/components/block/table/cell/Hash.tsx +0 -46
  63. package/src/components/block/table/cell/JsonView.tsx +0 -44
  64. package/src/components/block/table/cell/NumberChip.tsx +0 -12
  65. package/src/components/block/table/cell/PayloadCounts.tsx +0 -65
  66. package/src/components/block/table/cell/Producer.tsx +0 -63
  67. package/src/components/block/table/cell/TransactionCount.tsx +0 -56
  68. package/src/components/block/table/cell/Verification.tsx +0 -25
  69. package/src/components/block/table/cell/helpers/index.ts +0 -1
  70. package/src/components/block/table/cell/helpers/timeFunctions.ts +0 -44
  71. package/src/components/block/table/cell/hooks/index.ts +0 -1
  72. package/src/components/block/table/cell/hooks/useLinkedBlockItem.tsx +0 -25
  73. package/src/components/block/table/cell/index.ts +0 -8
  74. package/src/components/block/table/cell/lib/BlockTableCellProps.ts +0 -7
  75. package/src/components/block/table/cell/lib/index.ts +0 -1
  76. package/src/components/block/table/head/TableHead.tsx +0 -48
  77. package/src/components/block/table/head/index.ts +0 -1
  78. package/src/components/block/table/index.ts +0 -4
  79. package/src/components/block/table/row/TableRow.stories.tsx +0 -34
  80. package/src/components/block/table/row/TableRow.tsx +0 -46
  81. package/src/components/block/table/row/index.ts +0 -1
  82. package/src/components/chain/controls/PollingControlsFlexbox.tsx +0 -76
  83. package/src/components/chain/controls/PulseSvgIcon.tsx +0 -71
  84. package/src/components/chain/controls/index.ts +0 -2
  85. package/src/components/chain/dialog/Dialog.tsx +0 -20
  86. package/src/components/chain/dialog/index.ts +0 -1
  87. package/src/components/chain/hooks/index.ts +0 -1
  88. package/src/components/chain/hooks/useOnBlock.ts +0 -55
  89. package/src/components/chain/index.ts +0 -6
  90. package/src/components/chain/list/Animated.tsx +0 -19
  91. package/src/components/chain/list/TableEx.tsx +0 -12
  92. package/src/components/chain/list/index.ts +0 -2
  93. package/src/components/chain/pagination/BlockChainPagination.tsx +0 -11
  94. package/src/components/chain/pagination/hooks/index.ts +0 -1
  95. package/src/components/chain/pagination/hooks/usePagination.tsx +0 -22
  96. package/src/components/chain/pagination/index.ts +0 -2
  97. package/src/components/chain/stats/Dialog.tsx +0 -49
  98. package/src/components/chain/stats/index.ts +0 -1
  99. package/src/components/chain/stats/producer/ProducerFlexbox.tsx +0 -32
  100. package/src/components/chain/stats/producer/Table.tsx +0 -39
  101. package/src/components/chain/stats/producer/index.ts +0 -2
  102. package/src/components/chain/styled/BlockListWrapperFlexbox.tsx +0 -15
  103. package/src/components/chain/styled/index.ts +0 -1
  104. package/src/components/index.ts +0 -7
  105. package/src/components/payload/builder/BuilderComponentProps.ts +0 -5
  106. package/src/components/payload/builder/Flexbox.tsx +0 -30
  107. package/src/components/payload/builder/index.ts +0 -4
  108. package/src/components/payload/builder/producer-intent/Flexbox.stories.tsx +0 -14
  109. package/src/components/payload/builder/producer-intent/Flexbox.tsx +0 -15
  110. package/src/components/payload/builder/producer-intent/Form.tsx +0 -69
  111. package/src/components/payload/builder/producer-intent/index.ts +0 -1
  112. package/src/components/payload/builder/transfer/Flexbox.stories.tsx +0 -14
  113. package/src/components/payload/builder/transfer/Flexbox.tsx +0 -15
  114. package/src/components/payload/builder/transfer/Form.tsx +0 -82
  115. package/src/components/payload/builder/transfer/Transfer.ts +0 -3
  116. package/src/components/payload/builder/transfer/builder/SingleFlexbox.tsx +0 -51
  117. package/src/components/payload/builder/transfer/builder/index.ts +0 -1
  118. package/src/components/payload/builder/transfer/index.ts +0 -2
  119. package/src/components/payload/fields/BlockNumberTextField.tsx +0 -40
  120. package/src/components/payload/fields/XyoAddressTextField.tsx +0 -71
  121. package/src/components/payload/fields/index.ts +0 -2
  122. package/src/components/payload/index.ts +0 -2
  123. package/src/components/rate/SpanTypography.tsx +0 -20
  124. package/src/components/rate/SpeedTypography.tsx +0 -17
  125. package/src/components/rate/TimeTypography.tsx +0 -17
  126. package/src/components/rate/flexbox/FlexBox.stories.tsx +0 -46
  127. package/src/components/rate/flexbox/FlexBox.tsx +0 -31
  128. package/src/components/rate/flexbox/index.ts +0 -1
  129. package/src/components/rate/gauge/Container.stories.tsx +0 -80
  130. package/src/components/rate/gauge/Container.tsx +0 -75
  131. package/src/components/rate/gauge/Pointer.tsx +0 -67
  132. package/src/components/rate/gauge/Ticks.tsx +0 -122
  133. package/src/components/rate/gauge/WithLabel.stories.tsx +0 -73
  134. package/src/components/rate/gauge/WithLabel.tsx +0 -20
  135. package/src/components/rate/gauge/helpers/blockRateConversions.ts +0 -104
  136. package/src/components/rate/gauge/helpers/index.ts +0 -1
  137. package/src/components/rate/gauge/index.ts +0 -4
  138. package/src/components/rate/index.ts +0 -6
  139. package/src/components/rate/support/MetricTypography.tsx +0 -78
  140. package/src/components/rate/support/index.ts +0 -1
  141. package/src/components/table/StyledLinkableTableRow.tsx +0 -12
  142. package/src/components/table/index.ts +0 -1
  143. package/src/components/transactions/TransactionCountChip.tsx +0 -34
  144. package/src/components/transactions/TransactionsQuickTipButton.tsx +0 -86
  145. package/src/components/transactions/index.ts +0 -3
  146. package/src/components/transactions/submit/Builder.tsx +0 -55
  147. package/src/components/transactions/submit/Network.tsx +0 -36
  148. package/src/components/transactions/submit/SubmitChain.stories.tsx +0 -14
  149. package/src/components/transactions/submit/SubmitChain.tsx +0 -91
  150. package/src/components/transactions/submit/index.ts +0 -3
  151. package/src/context/analyzer/Provider.tsx +0 -41
  152. package/src/context/analyzer/context.ts +0 -5
  153. package/src/context/analyzer/index.ts +0 -5
  154. package/src/context/analyzer/state.ts +0 -13
  155. package/src/context/analyzer/use.ts +0 -6
  156. package/src/context/chain/Context.ts +0 -5
  157. package/src/context/chain/Provider.tsx +0 -49
  158. package/src/context/chain/State.ts +0 -8
  159. package/src/context/chain/index.ts +0 -4
  160. package/src/context/chain/use.ts +0 -6
  161. package/src/context/index.ts +0 -3
  162. package/src/context/polling/Provider.tsx +0 -27
  163. package/src/context/polling/context.ts +0 -5
  164. package/src/context/polling/index.ts +0 -4
  165. package/src/context/polling/state.ts +0 -8
  166. package/src/context/polling/use.ts +0 -5
  167. package/src/helpers/index.ts +0 -1
  168. package/src/helpers/rate/index.ts +0 -1
  169. package/src/helpers/rate/rateUnitToLabel.ts +0 -27
  170. package/src/helpers/txsFromBlock.ts +0 -12
  171. package/src/hooks/chain-iterator/index.ts +0 -1
  172. package/src/hooks/chain-iterator/useChainIteratorParams.ts +0 -55
  173. package/src/hooks/index.ts +0 -3
  174. package/src/hooks/useBaseContext.ts +0 -8
  175. package/src/hooks/useTxsFromBlock.ts +0 -12
  176. package/src/index.ts +0 -3
  177. package/src/lib/getChainArchivist.ts +0 -20
  178. package/src/lib/getChainId.ts +0 -8
  179. package/src/lib/index.ts +0 -2
  180. package/src/stories/ChainArchivistDecorator.tsx +0 -43
  181. package/src/stories/ChainArchivistDelayedInsertDecorator.tsx +0 -71
  182. package/src/stories/index.ts +0 -2
  183. package/src/types/BlockComponentProps.ts +0 -13
  184. package/src/types/BlockComponents.ts +0 -7
  185. package/src/types/BlockListComponentProps.ts +0 -6
  186. package/src/types/global.d.ts +0 -1
  187. package/src/types/index.ts +0 -4
  188. package/src/types/render/BlockChainRenderProps.ts +0 -28
  189. package/src/types/render/RemoteArchivistProps.ts +0 -5
  190. package/src/types/render/flexbox/BlockChainRenderFlexboxProps.ts +0 -8
  191. package/src/types/render/flexbox/RenderFlexboxProps.ts +0 -5
  192. package/src/types/render/flexbox/index.ts +0 -2
  193. package/src/types/render/index.ts +0 -4
  194. package/src/types/render/table/BlockChainRenderTableExProps.ts +0 -8
  195. package/src/types/render/table/RenderTableProps.ts +0 -5
  196. package/src/types/render/table/index.ts +0 -2
@@ -1,34 +0,0 @@
1
- import { MoreVert } from '@mui/icons-material'
2
- import { IconButton, Menu } from '@mui/material'
3
- import { BWJsonMenuItem, BWPreviousHashMenuItem } from '@xyo-network/react-boundwitness-plugin'
4
- import type { HydratedBlock } from '@xyo-network/xl1-sdk'
5
- import React from 'react'
6
-
7
- import { useAnchorElement } from '../hooks/index.ts'
8
-
9
- export interface BlockExpandedMenuProps {
10
- block?: HydratedBlock
11
- }
12
-
13
- export const BlockMenuExpanded: React.FC<BlockExpandedMenuProps> = ({ block }) => {
14
- const {
15
- anchorEl, anchorRef, open, handleClick, handleClose,
16
- } = useAnchorElement()
17
-
18
- return (
19
- <>
20
- <IconButton ref={anchorRef} size="small" onClick={handleClick}>
21
- <MoreVert fontSize="inherit" />
22
- </IconButton>
23
- <Menu
24
- open={open}
25
- anchorEl={anchorEl}
26
- anchorOrigin={{ horizontal: 'left', vertical: 'bottom' }}
27
- onClose={handleClose}
28
- >
29
- <BWPreviousHashMenuItem boundwitness={block?.[0]} dense onDialogClose={handleClose} />
30
- <BWJsonMenuItem boundwitness={block?.[0]} dense onDialogClose={handleClose} />
31
- </Menu>
32
- </>
33
- )
34
- }
@@ -1 +0,0 @@
1
- export * from './Expanded.tsx'
@@ -1,64 +0,0 @@
1
- import {
2
- Alert, AlertTitle, Snackbar,
3
- } from '@mui/material'
4
- import type { Meta, StoryFn } from '@storybook/react-vite'
5
- import { buildRandomBlockChain } from '@xyo-network/react-chain-shared'
6
- import type { Event } from '@xyo-network/react-event'
7
- import React, { useState } from 'react'
8
-
9
- import { type BlockHeaderEventNouns, useBlockHeadingEvents } from '../hooks/index.ts'
10
- import { BlockchainTableEx } from './Ex.tsx'
11
- import { BlockChainTableRow } from './row/index.ts'
12
-
13
- const blocks = await buildRandomBlockChain()
14
-
15
- export default {
16
- title: 'Block/TableEx',
17
- component: BlockchainTableEx,
18
- parameters: { layout: 'fullscreen' },
19
- } as Meta
20
-
21
- const Template: StoryFn<typeof BlockchainTableEx> = args => <BlockchainTableEx {...args} />
22
-
23
- const TemplateLinked: StoryFn<typeof BlockchainTableEx> = (args) => {
24
- const [event, setEvent] = useState<Event<BlockHeaderEventNouns>>()
25
- const [ref] = useBlockHeadingEvents<HTMLTableElement>((noun, verb, data) => setEvent({
26
- noun, verb, data,
27
- }))
28
- return (
29
- <>
30
- <BlockchainTableEx ref={ref} {...args} />
31
- <Snackbar open={!!event} autoHideDuration={5000} 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
- </>
42
- )
43
- }
44
-
45
- const Default = Template.bind({})
46
- Default.args = {}
47
-
48
- const WithData = Template.bind({})
49
- WithData.args = {
50
- children: blocks.map((block) => {
51
- return <BlockChainTableRow key={block[0].block} block={block} />
52
- }),
53
- }
54
-
55
- const WithLinked = TemplateLinked.bind({})
56
- WithLinked.args = {
57
- children: blocks.map((block) => {
58
- return <BlockChainTableRow key={block[0].block} block={block} linked />
59
- }),
60
- }
61
-
62
- export {
63
- Default, WithData, WithLinked,
64
- }
@@ -1,21 +0,0 @@
1
- import { TableBody } from '@mui/material'
2
- import type { TableExProps } from '@xyo-network/react-table'
3
- import { TableEx } from '@xyo-network/react-table'
4
- import React from 'react'
5
-
6
- import { BlockchainTableHead } from './head/index.ts'
7
-
8
- export const BlockchainTableEx = ({
9
- ref, children, ...props
10
- }: TableExProps) => {
11
- return (
12
- <TableEx ref={ref} {...props}>
13
- <BlockchainTableHead />
14
- <TableBody>
15
- {children}
16
- </TableBody>
17
- </TableEx>
18
- )
19
- }
20
-
21
- BlockchainTableEx.displayName = 'BlockchainTableEx'
@@ -1,35 +0,0 @@
1
- import {
2
- Link, TableCell, Tooltip, Typography,
3
- } from '@mui/material'
4
- import React from 'react'
5
-
6
- import type { BlockHeaderEventNouns } from '../../hooks/index.ts'
7
- import { useLinkedBlockItem } from './hooks/index.ts'
8
- import type { BlockTableCellProps } from './lib/index.ts'
9
-
10
- export interface BlockNumberTableCellProps extends BlockTableCellProps {
11
- eventNoun?: BlockHeaderEventNouns
12
- }
13
-
14
- export const BlockNumberTableCell: React.FC<BlockNumberTableCellProps> = ({
15
- block, eventNoun = 'block-number', linked, ...props
16
- }) => {
17
- const blockNumber = block?.[0].block
18
-
19
- return <BlockNumberTableCellInner blockNumber={blockNumber} eventNoun={eventNoun} linked={linked} {...props} />
20
- }
21
-
22
- export const BlockNumberTableCellInner: React.FC<BlockNumberTableCellProps & { blockNumber?: number; linked?: boolean }> = ({
23
- blockNumber, eventNoun = 'block-number', linked, ...props
24
- }) => {
25
- const [ref, handleClick] = useLinkedBlockItem(eventNoun, blockNumber?.toLocaleString())
26
- return (
27
- <TableCell ref={ref} {...props}>
28
- <Tooltip title={`Block Number: ${blockNumber}`}>
29
- <Typography component="span" variant="body1">
30
- {linked ? <Link onClick={handleClick} sx={{ cursor: 'pointer' }}>{blockNumber}</Link> : blockNumber}
31
- </Typography>
32
- </Tooltip>
33
- </TableCell>
34
- )
35
- }
@@ -1,46 +0,0 @@
1
- import {
2
- Skeleton, TableCell, Tooltip, Typography,
3
- } from '@mui/material'
4
- import { isDefined } from '@xylabs/sdk-js'
5
- import React from 'react'
6
-
7
- import { dateFormat, timeAgo } from './helpers/index.ts'
8
- import { type BlockTableCellProps } from './lib/index.ts'
9
-
10
- export interface BlockEpochTableCellProps extends BlockTableCellProps {}
11
-
12
- export const BlockEpochTableCell: React.FC<BlockEpochTableCellProps> = ({
13
- block, linked, ...props
14
- }) => {
15
- const epoch = block?.[0]?.$epoch
16
-
17
- const dateTime = dateFormat.format(epoch)
18
- const age = isDefined(epoch) ? timeAgo(epoch) : undefined
19
-
20
- return (
21
- <TableCell {...props}>
22
- <Tooltip title={`Block Epoch: ${dateTime}`}>
23
- <Typography component="span" variant="body1">
24
- {age ?? <Skeleton width={115} /> }
25
- </Typography>
26
- </Tooltip>
27
- </TableCell>
28
- )
29
- }
30
-
31
- export const BlockEpochTableCellInner: React.FC<BlockEpochTableCellProps & { epoch?: number }> = ({
32
- epoch, linked, ...props
33
- }) => {
34
- const dateTime = dateFormat.format(epoch)
35
- const age = isDefined(epoch) ? timeAgo(epoch) : undefined
36
-
37
- return (
38
- <TableCell {...props}>
39
- <Tooltip title={`Block Epoch: ${dateTime}`}>
40
- <Typography component="span" variant="body1">
41
- {age ?? <Skeleton width={115} /> }
42
- </Typography>
43
- </Tooltip>
44
- </TableCell>
45
- )
46
- }
@@ -1,46 +0,0 @@
1
- import {
2
- Link, TableCell, Tooltip,
3
- } from '@mui/material'
4
- import { isHash } from '@xylabs/sdk-js'
5
- import { usePayloadRootHash } from '@xyo-network/react-shared'
6
- import React, { useState } from 'react'
7
-
8
- import { FeatureNotAvailable } from '../../../FeatureNotAvailable.tsx'
9
- import { ChipSkeleton } from '../../ChipSkeleton.tsx'
10
- import { useLinkedBlockItem } from './hooks/index.ts'
11
- import type { BlockTableCellProps } from './lib/index.ts'
12
-
13
- export interface BlockHashTableCellProps extends BlockTableCellProps {
14
- notAvailableDialog?: boolean
15
- }
16
-
17
- export const BlockHashTableCell: React.FC<BlockHashTableCellProps> = ({
18
- block, notAvailableDialog, linked, ...props
19
- }) => {
20
- const hash = usePayloadRootHash(block?.[0])
21
-
22
- const [ref, handleClick] = useLinkedBlockItem('block-hash', hash)
23
- const [notAvailable, setNotAvailable] = useState(false)
24
-
25
- const shortenedHash = isHash(hash) ? `${hash.slice(0, 4)}...${hash.slice(-5, -1)}` : undefined
26
-
27
- return (
28
- <TableCell ref={ref} {...props}>
29
- <Tooltip title={`Block Hash: ${hash}`}>
30
- {linked
31
- ? (
32
- <Link
33
- sx={{ cursor: 'pointer' }}
34
- onClick={linked ? handleClick : () => setNotAvailable(true)}
35
- >
36
- {shortenedHash ?? <ChipSkeleton />}
37
- </Link>
38
- )
39
- : <span>{shortenedHash ?? <ChipSkeleton />}</span>}
40
- </Tooltip>
41
- {(notAvailableDialog && notAvailable)
42
- ? <FeatureNotAvailable featureName="Block Details" open={notAvailable} onClick={() => setNotAvailable(false)} />
43
- : null}
44
- </TableCell>
45
- )
46
- }
@@ -1,44 +0,0 @@
1
- import { DataObject } from '@mui/icons-material'
2
- import {
3
- Button,
4
- Dialog, DialogActions, DialogContent, DialogTitle, IconButton, TableCell,
5
- } from '@mui/material'
6
- import { FlexRow } from '@xylabs/react-flexbox'
7
- import { ellipsize, isHash } from '@xylabs/sdk-js'
8
- import { JsonViewerEx } from '@xyo-network/react-payload-raw-info'
9
- import { usePayloadRootHash } from '@xyo-network/react-shared'
10
- import React, { useState } from 'react'
11
-
12
- import type { BlockTableCellProps } from './lib/index.ts'
13
-
14
- export interface BlockJsonViewTableCellProps extends BlockTableCellProps {}
15
-
16
- export const BlockJsonViewTableCell: React.FC<BlockJsonViewTableCellProps> = ({ block, ...props }) => {
17
- const [open, setOpen] = useState(false)
18
- const onClose = () => setOpen(false)
19
-
20
- const hash = usePayloadRootHash(block?.[0])
21
- const title = isHash(hash) ? `JSON for ${ellipsize(hash, 5)}` : 'JSON'
22
-
23
- return (
24
- <TableCell {...props}>
25
- <FlexRow onClick={e => e.stopPropagation()} sx={{ width: '100%' }}>
26
- <IconButton onClick={() => setOpen(true)}>
27
- <DataObject />
28
- </IconButton>
29
- <Dialog open={open} onClose={onClose}>
30
- <DialogTitle>{title}</DialogTitle>
31
- <DialogContent>
32
- <JsonViewerEx value={block} />
33
- </DialogContent>
34
- <DialogActions sx={{
35
- display: 'flex', flexDirection: 'row', justifyContent: 'end',
36
- }}
37
- >
38
- <Button variant="contained" onClick={onClose}>Close</Button>
39
- </DialogActions>
40
- </Dialog>
41
- </FlexRow>
42
- </TableCell>
43
- )
44
- }
@@ -1,12 +0,0 @@
1
- import type { ChipProps } from '@mui/material'
2
- import { Chip } from '@mui/material'
3
- import React from 'react'
4
-
5
- export interface BlockNumberChipProps extends ChipProps {
6
- blockNumber?: number
7
- }
8
-
9
- export const BlockNumberChip: React.FC<BlockNumberChipProps> = ({ blockNumber, ...props }) => {
10
- // eslint-disable-next-line react-x/no-useless-fragment
11
- return <Chip avatar={<></>} label={blockNumber} {...props} />
12
- }
@@ -1,65 +0,0 @@
1
- import { Error } from '@mui/icons-material'
2
- import {
3
- Link, TableCell, Tooltip,
4
- } from '@mui/material'
5
- import type { Hash } from '@xylabs/sdk-js'
6
- import React from 'react'
7
-
8
- import { usePayloadCountsFromBlock } from '../../hooks/index.ts'
9
- import { useLinkedBlockItem } from './hooks/index.ts'
10
- import type { BlockTableCellProps } from './lib/index.ts'
11
-
12
- export interface BlockPayloadCountsTableCellProps extends BlockTableCellProps {}
13
-
14
- export interface BlockPayloadCountsEventData {
15
- block: Hash
16
- privatePayloads: number
17
- publicPayloads: number
18
- }
19
-
20
- export const BlockPayloadCountsTableCell: React.FC<BlockPayloadCountsTableCellProps> = ({
21
- block, linked, ...props
22
- }) => {
23
- const [publicPayloads, privatePayloads, error] = usePayloadCountsFromBlock(block)
24
- const data: BlockPayloadCountsEventData | undefined = (block && privatePayloads !== undefined && publicPayloads !== undefined)
25
- ? {
26
- publicPayloads,
27
- privatePayloads,
28
- block: block[0]._hash,
29
- }
30
- : undefined
31
- const payloadCount = (publicPayloads ?? 0) + (privatePayloads ?? 0)
32
- const [ref, handleClick] = useLinkedBlockItem('payload-counts', data)
33
-
34
- return (
35
- <TableCell ref={ref} {...props}>
36
- <span>
37
- {error
38
- ? (
39
- <Tooltip title={error.message}>
40
- <Error color="error" />
41
- </Tooltip>
42
- )
43
- : null}
44
- {linked
45
- ? (
46
- <Tooltip title={`Public Payloads: ${publicPayloads ?? '--'} Private Payloads: ${privatePayloads ?? '--'}`}>
47
- <Link
48
- onClick={handleClick}
49
- sx={{ cursor: 'pointer' }}
50
- >
51
- {payloadCount}
52
- </Link>
53
- </Tooltip>
54
- )
55
- : (
56
- <Tooltip title={`Public Payloads: ${publicPayloads ?? '--'} Private Payloads: ${privatePayloads ?? '--'}`}>
57
- <span>
58
- {payloadCount}
59
- </span>
60
- </Tooltip>
61
- )}
62
- </span>
63
- </TableCell>
64
- )
65
- }
@@ -1,63 +0,0 @@
1
- import { TableCell, Tooltip } from '@mui/material'
2
- import type { MouseEvent } from 'react'
3
- import React, { useState } from 'react'
4
-
5
- import { FeatureNotAvailable } from '../../../FeatureNotAvailable.tsx'
6
- import { useBlockProducer } from '../../hooks/index.ts'
7
- import type { BlockProducerChipProps } from '../../ProducerChip.tsx'
8
- import { BlockAddressChip } from '../../ProducerChip.tsx'
9
- import { useLinkedBlockItem } from './hooks/index.ts'
10
- import type { BlockTableCellProps } from './lib/index.ts'
11
-
12
- export interface BlockProducerTableCell extends BlockTableCellProps {
13
- notAvailableDialog?: boolean
14
- producerChipProps?: BlockProducerChipProps
15
- }
16
-
17
- export const BlockProducerTableCell: React.FC<BlockProducerTableCell> = ({
18
- block, linked, notAvailableDialog, producerChipProps, ...props
19
- }) => {
20
- const [ref, handleClick] = useLinkedBlockItem('block-producer', JSON.stringify(block))
21
- const producer = useBlockProducer(block)
22
-
23
- return (
24
- <BlockProducerTableCellInner
25
- address={producer}
26
- handleClick={handleClick}
27
- linked={linked}
28
- notAvailableDialog={notAvailableDialog}
29
- producerChipProps={producerChipProps}
30
- {...props}
31
- ref={ref}
32
- />
33
- )
34
- }
35
-
36
- export interface BlockProducerTableCellInner extends BlockTableCellProps {
37
- address?: string
38
- handleClick?: (event: MouseEvent) => void
39
- notAvailableDialog?: boolean
40
- producerChipProps?: BlockProducerChipProps
41
- }
42
-
43
- export const BlockProducerTableCellInner: React.FC<BlockProducerTableCell & BlockProducerTableCellInner> = ({
44
- address, handleClick, linked, notAvailableDialog, producerChipProps, ...props
45
- }) => {
46
- const [notAvailable, setNotAvailable] = useState(false)
47
- return (
48
- <TableCell {...props}>
49
- <Tooltip title={`Block Producer: ${address}`}>
50
- <BlockAddressChip
51
- sx={{ cursor: 'pointer' }}
52
- onClick={linked ? handleClick : () => setNotAvailable(true)}
53
- address={address}
54
- toolTipTitle={`Block Producer: ${address}`}
55
- {...producerChipProps}
56
- />
57
- </Tooltip>
58
- {(notAvailableDialog && notAvailable)
59
- ? <FeatureNotAvailable featureName="Producer Details" open={notAvailable} onClick={() => setNotAvailable(false)} />
60
- : null}
61
- </TableCell>
62
- )
63
- }
@@ -1,56 +0,0 @@
1
- import { Error } from '@mui/icons-material'
2
- import {
3
- Link, TableCell, Tooltip,
4
- } from '@mui/material'
5
- import type { Hash } from '@xylabs/sdk-js'
6
- import React, { useMemo } from 'react'
7
-
8
- import { useTxsFromBlock } from '../../../../hooks/index.ts'
9
- import { useLinkedBlockItem } from './hooks/index.ts'
10
- import type { BlockTableCellProps } from './lib/index.ts'
11
-
12
- export interface BlockTransactionCountTableCellProps extends BlockTableCellProps {}
13
-
14
- export interface BlockTransactionCountEventData {
15
- block: Hash
16
- transactions: number
17
- }
18
-
19
- export const BlockTransactionCountTableCell: React.FC<BlockTransactionCountTableCellProps> = ({
20
- block, linked, ...props
21
- }) => {
22
- const [transactions, error] = useTxsFromBlock(block)
23
- const txHashes = useMemo(() => transactions?.map(([,hash]) => hash), [transactions])
24
-
25
- const data: BlockTransactionCountEventData | undefined = (block && transactions !== undefined)
26
- ? {
27
- transactions: transactions.length,
28
- block: block[0]._hash,
29
- }
30
- : undefined
31
-
32
- const [ref, handleClick] = useLinkedBlockItem('transaction-count', data)
33
-
34
- return (
35
- <TableCell ref={ref} {...props}>
36
- <span>
37
- {error
38
- ? (
39
- <Tooltip title={error.message}>
40
- <Error color="error" />
41
- </Tooltip>
42
- )
43
- : null}
44
- {linked
45
- ? (
46
- <Link onClick={handleClick} sx={{ cursor: 'pointer' }}>
47
- {txHashes?.length}
48
- </Link>
49
- )
50
- : (
51
- txHashes?.length
52
- )}
53
- </span>
54
- </TableCell>
55
- )
56
- }
@@ -1,25 +0,0 @@
1
- import { CheckCircleOutlineRounded } from '@mui/icons-material'
2
- import { TableCell } from '@mui/material'
3
- import { FlexRow } from '@xylabs/react-flexbox'
4
- import { BWVerification } from '@xyo-network/react-boundwitness-plugin'
5
- import React from 'react'
6
-
7
- import type { BlockTableCellProps } from './lib/index.ts'
8
-
9
- export interface BlockVerificationTableCellProps extends BlockTableCellProps {
10
- deepValidation?: boolean
11
- }
12
-
13
- export const BlockVerificationTableCell: React.FC<BlockVerificationTableCellProps> = ({
14
- block, linked, deepValidation, ...props
15
- }) => {
16
- return (
17
- <TableCell {...props}>
18
- <FlexRow onClick={e => e.stopPropagation()} sx={{ width: '100%' }}>
19
- {deepValidation
20
- ? <BWVerification iconColors boundwitness={block?.[0]} />
21
- : <CheckCircleOutlineRounded color="success" />}
22
- </FlexRow>
23
- </TableCell>
24
- )
25
- }
@@ -1 +0,0 @@
1
- export * from './timeFunctions.ts'
@@ -1,44 +0,0 @@
1
- export const dateFormat = Intl.DateTimeFormat(globalThis.navigator.language ?? 'en-US', {
2
- year: 'numeric',
3
- month: '2-digit',
4
- day: '2-digit',
5
- hour: '2-digit',
6
- minute: '2-digit',
7
- second: '2-digit',
8
- })
9
-
10
- export const timeAgo = (epoch: number, locale = navigator.language ?? 'en-US') => {
11
- const now = Date.now()
12
- const diffInSeconds = Math.floor((now - epoch) / 1000)
13
-
14
- const units: { max: number; name: Intl.RelativeTimeFormatUnit; value: number }[] = [
15
- {
16
- max: 60, value: 1, name: 'second',
17
- },
18
- {
19
- max: 3600, value: 60, name: 'minute',
20
- },
21
- {
22
- max: 86_400, value: 3600, name: 'hour',
23
- },
24
- {
25
- max: 604_800, value: 86_400, name: 'day',
26
- },
27
- {
28
- max: 2_620_800, value: 604_800, name: 'week',
29
- },
30
- {
31
- max: 31_449_600, value: 2_620_800, name: 'month',
32
- },
33
- {
34
- max: Infinity, value: 31_449_600, name: 'year',
35
- },
36
- ]
37
-
38
- for (const unit of units) {
39
- if (Math.abs(diffInSeconds) < unit.max) {
40
- const value = Math.round(diffInSeconds / unit.value)
41
- return new Intl.RelativeTimeFormat(locale, { numeric: 'auto' }).format(-value, unit.name)
42
- }
43
- }
44
- }
@@ -1 +0,0 @@
1
- export * from './useLinkedBlockItem.tsx'
@@ -1,25 +0,0 @@
1
- import { useEvent } from '@xyo-network/react-event'
2
- import type { Ref } from 'react'
3
-
4
- import type { BlockHeaderEventNouns } from '../../../hooks/index.ts'
5
-
6
- export const useLinkedBlockItem = (noun?: BlockHeaderEventNouns, data?: string | object): [Ref<HTMLElement | null>, (event: React.MouseEvent) => void] => {
7
- const [ref, dispatch] = useEvent<HTMLAnchorElement, BlockHeaderEventNouns, string, string | object>()
8
-
9
- const handleClick = (event: React.MouseEvent) => {
10
- event.preventDefault()
11
- event.stopPropagation()
12
- if (noun === undefined) {
13
- console.warn('useLinkedBlockItem: noun is required')
14
- return
15
- }
16
- const selection = globalThis.getSelection()
17
- const isTextSelected = selection && selection.toString().length > 0
18
-
19
- if (!isTextSelected) {
20
- dispatch(noun, 'click', data, event.nativeEvent)
21
- }
22
- }
23
-
24
- return [ref, handleClick]
25
- }
@@ -1,8 +0,0 @@
1
- export * from './BlockNumber.tsx'
2
- export * from './Epoch.tsx'
3
- export * from './Hash.tsx'
4
- export * from './JsonView.tsx'
5
- export * from './PayloadCounts.tsx'
6
- export * from './Producer.tsx'
7
- export * from './TransactionCount.tsx'
8
- export * from './Verification.tsx'
@@ -1,7 +0,0 @@
1
- import type { TableCellProps } from '@mui/material'
2
- import type { HydratedBlockWithHashMeta } from '@xyo-network/xl1-sdk'
3
-
4
- export interface BlockTableCellProps extends TableCellProps {
5
- block?: HydratedBlockWithHashMeta
6
- linked?: boolean
7
- }
@@ -1 +0,0 @@
1
- export * from './BlockTableCellProps.ts'
@@ -1,48 +0,0 @@
1
- import { InfoOutline } from '@mui/icons-material'
2
- import type { TableCellProps } from '@mui/material'
3
- import {
4
- TableCell, TableHead, TableRow,
5
- Tooltip,
6
- Typography,
7
- } from '@mui/material'
8
- import { FlexRow } from '@xylabs/react-flexbox'
9
- import React from 'react'
10
-
11
- const ToolTipTableCell: React.FC<TableCellProps> = ({
12
- children, align, title, ...props
13
- }) => {
14
- return (
15
- <TableCell title={title} {...props}>
16
- <FlexRow justifyContent={align}>
17
- <Typography variant="body2">{children}</Typography>
18
- &nbsp;
19
- <Tooltip title={title}>
20
- <InfoOutline fontSize="small" />
21
- </Tooltip>
22
- </FlexRow>
23
- </TableCell>
24
- )
25
- }
26
-
27
- export const BlockchainTableHead: React.FC = () => {
28
- return (
29
- <TableHead>
30
- <TableRow>
31
- <ToolTipTableCell align="left" title="The block number that is included in the block">Block</ToolTipTableCell>
32
- <ToolTipTableCell title="The hash of the block" sx={{ width: '20%' }}>Hash</ToolTipTableCell>
33
- <ToolTipTableCell title="The epoch of the block" sx={{ width: '20%' }}>Epoch</ToolTipTableCell>
34
- <ToolTipTableCell
35
- align="left"
36
- title="The address of the block producer that produced the block"
37
- sx={{ width: '20%' }}
38
- >
39
- Block Producer
40
- </ToolTipTableCell>
41
- <ToolTipTableCell align="left" title="Count of transactions that are included in the block">Transactions</ToolTipTableCell>
42
- <ToolTipTableCell align="left" title="Count of public and private payload counts for the block">Payloads</ToolTipTableCell>
43
- <ToolTipTableCell align="center" title="The result of the local validation check for the block">Valid</ToolTipTableCell>
44
- <ToolTipTableCell align="center" title="Link to display the raw JSON of the block">JSON</ToolTipTableCell>
45
- </TableRow>
46
- </TableHead>
47
- )
48
- }