@xyo-network/react-chain-blockchain 1.20.14 → 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 (199) hide show
  1. package/README.md +9 -8854
  2. package/dist/browser/components/account/table/types/index.d.ts +1 -1
  3. package/dist/browser/components/account/table/types/index.d.ts.map +1 -1
  4. package/dist/browser/components/block/table/cell/NumberChip.d.ts.map +1 -1
  5. package/dist/browser/components/chain/controls/PulseSvgIcon.d.ts +5 -2
  6. package/dist/browser/components/chain/controls/PulseSvgIcon.d.ts.map +1 -1
  7. package/dist/browser/components/chain/hooks/useOnBlock.d.ts +7 -7
  8. package/dist/browser/components/chain/styled/BlockListWrapperFlexbox.d.ts +6 -1
  9. package/dist/browser/components/chain/styled/BlockListWrapperFlexbox.d.ts.map +1 -1
  10. package/dist/browser/components/table/StyledLinkableTableRow.d.ts +5 -4
  11. package/dist/browser/components/table/StyledLinkableTableRow.d.ts.map +1 -1
  12. package/dist/browser/context/analyzer/context.d.ts +3 -3
  13. package/dist/browser/context/analyzer/use.d.ts +1 -1
  14. package/dist/browser/context/chain/Context.d.ts +3 -3
  15. package/dist/browser/context/chain/use.d.ts +1 -1
  16. package/dist/browser/hooks/useBaseContext.d.ts +2 -8
  17. package/dist/browser/hooks/useBaseContext.d.ts.map +1 -1
  18. package/dist/browser/hooks/useTxsFromBlock.d.ts +1 -1
  19. package/dist/browser/hooks/useTxsFromBlock.d.ts.map +1 -1
  20. package/dist/browser/index.mjs +3 -3
  21. package/dist/browser/index.mjs.map +1 -1
  22. package/package.json +167 -58
  23. package/src/components/FeatureNotAvailable.tsx +0 -20
  24. package/src/components/account/BalanceHistoryFlexbox.stories.tsx +0 -25
  25. package/src/components/account/BalanceHistoryFlexbox.tsx +0 -53
  26. package/src/components/account/helpers/formatBalanceMagnitude.ts +0 -14
  27. package/src/components/account/helpers/index.ts +0 -1
  28. package/src/components/account/hooks/index.ts +0 -1
  29. package/src/components/account/hooks/usePagedAccountBalanceHistory.ts +0 -39
  30. package/src/components/account/index.ts +0 -4
  31. package/src/components/account/table/BalanceHistoryTableEx.stories.tsx +0 -111
  32. package/src/components/account/table/BalanceHistoryTableEx.tsx +0 -37
  33. package/src/components/account/table/BalanceHistoryTableRow.stories.tsx +0 -52
  34. package/src/components/account/table/BalanceHistoryTableRow.tsx +0 -60
  35. package/src/components/account/table/RawAmountTableCell.tsx +0 -53
  36. package/src/components/account/table/cell/AddressTableCell.tsx +0 -27
  37. package/src/components/account/table/cell/BlockNumber.tsx +0 -39
  38. package/src/components/account/table/cell/HashTableCell.tsx +0 -46
  39. package/src/components/account/table/cell/index.ts +0 -3
  40. package/src/components/account/table/hooks/index.ts +0 -1
  41. package/src/components/account/table/hooks/useLinkedBalanceHistoryItem.tsx +0 -29
  42. package/src/components/account/table/index.ts +0 -5
  43. package/src/components/account/table/types/index.ts +0 -18
  44. package/src/components/block/BlockHeadingFlexbox.stories.tsx +0 -75
  45. package/src/components/block/BlockHeadingFlexbox.tsx +0 -56
  46. package/src/components/block/ChipSkeleton.tsx +0 -7
  47. package/src/components/block/LinkedDivider.tsx +0 -27
  48. package/src/components/block/ProducerChip.tsx +0 -45
  49. package/src/components/block/helpers/blockProducer.ts +0 -5
  50. package/src/components/block/helpers/buildBlockChainRenderComponent.tsx +0 -32
  51. package/src/components/block/helpers/index.ts +0 -3
  52. package/src/components/block/helpers/payloadCountsFromBlock.ts +0 -10
  53. package/src/components/block/hooks/index.ts +0 -4
  54. package/src/components/block/hooks/useAnchorElement.ts +0 -19
  55. package/src/components/block/hooks/useBlockHeadingEvents.ts +0 -11
  56. package/src/components/block/hooks/useBlockProducer.ts +0 -11
  57. package/src/components/block/hooks/usePayloadCountsFromBlock.ts +0 -13
  58. package/src/components/block/index.ts +0 -6
  59. package/src/components/block/menu/Expanded.tsx +0 -34
  60. package/src/components/block/menu/index.ts +0 -1
  61. package/src/components/block/table/Ex.stories.tsx +0 -64
  62. package/src/components/block/table/Ex.tsx +0 -21
  63. package/src/components/block/table/cell/BlockNumber.tsx +0 -35
  64. package/src/components/block/table/cell/Epoch.tsx +0 -46
  65. package/src/components/block/table/cell/Hash.tsx +0 -46
  66. package/src/components/block/table/cell/JsonView.tsx +0 -44
  67. package/src/components/block/table/cell/NumberChip.tsx +0 -12
  68. package/src/components/block/table/cell/PayloadCounts.tsx +0 -65
  69. package/src/components/block/table/cell/Producer.tsx +0 -63
  70. package/src/components/block/table/cell/TransactionCount.tsx +0 -56
  71. package/src/components/block/table/cell/Verification.tsx +0 -25
  72. package/src/components/block/table/cell/helpers/index.ts +0 -1
  73. package/src/components/block/table/cell/helpers/timeFunctions.ts +0 -44
  74. package/src/components/block/table/cell/hooks/index.ts +0 -1
  75. package/src/components/block/table/cell/hooks/useLinkedBlockItem.tsx +0 -25
  76. package/src/components/block/table/cell/index.ts +0 -8
  77. package/src/components/block/table/cell/lib/BlockTableCellProps.ts +0 -7
  78. package/src/components/block/table/cell/lib/index.ts +0 -1
  79. package/src/components/block/table/head/TableHead.tsx +0 -48
  80. package/src/components/block/table/head/index.ts +0 -1
  81. package/src/components/block/table/index.ts +0 -4
  82. package/src/components/block/table/row/TableRow.stories.tsx +0 -34
  83. package/src/components/block/table/row/TableRow.tsx +0 -46
  84. package/src/components/block/table/row/index.ts +0 -1
  85. package/src/components/chain/controls/PollingControlsFlexbox.tsx +0 -76
  86. package/src/components/chain/controls/PulseSvgIcon.tsx +0 -71
  87. package/src/components/chain/controls/index.ts +0 -2
  88. package/src/components/chain/dialog/Dialog.tsx +0 -20
  89. package/src/components/chain/dialog/index.ts +0 -1
  90. package/src/components/chain/hooks/index.ts +0 -1
  91. package/src/components/chain/hooks/useOnBlock.ts +0 -55
  92. package/src/components/chain/index.ts +0 -6
  93. package/src/components/chain/list/Animated.tsx +0 -19
  94. package/src/components/chain/list/TableEx.tsx +0 -12
  95. package/src/components/chain/list/index.ts +0 -2
  96. package/src/components/chain/pagination/BlockChainPagination.tsx +0 -11
  97. package/src/components/chain/pagination/hooks/index.ts +0 -1
  98. package/src/components/chain/pagination/hooks/usePagination.tsx +0 -22
  99. package/src/components/chain/pagination/index.ts +0 -2
  100. package/src/components/chain/stats/Dialog.tsx +0 -49
  101. package/src/components/chain/stats/index.ts +0 -1
  102. package/src/components/chain/stats/producer/ProducerFlexbox.tsx +0 -32
  103. package/src/components/chain/stats/producer/Table.tsx +0 -39
  104. package/src/components/chain/stats/producer/index.ts +0 -2
  105. package/src/components/chain/styled/BlockListWrapperFlexbox.tsx +0 -15
  106. package/src/components/chain/styled/index.ts +0 -1
  107. package/src/components/index.ts +0 -7
  108. package/src/components/payload/builder/BuilderComponentProps.ts +0 -5
  109. package/src/components/payload/builder/Flexbox.tsx +0 -30
  110. package/src/components/payload/builder/index.ts +0 -4
  111. package/src/components/payload/builder/producer-intent/Flexbox.stories.tsx +0 -14
  112. package/src/components/payload/builder/producer-intent/Flexbox.tsx +0 -15
  113. package/src/components/payload/builder/producer-intent/Form.tsx +0 -69
  114. package/src/components/payload/builder/producer-intent/index.ts +0 -1
  115. package/src/components/payload/builder/transfer/Flexbox.stories.tsx +0 -14
  116. package/src/components/payload/builder/transfer/Flexbox.tsx +0 -15
  117. package/src/components/payload/builder/transfer/Form.tsx +0 -82
  118. package/src/components/payload/builder/transfer/Transfer.ts +0 -3
  119. package/src/components/payload/builder/transfer/builder/SingleFlexbox.tsx +0 -51
  120. package/src/components/payload/builder/transfer/builder/index.ts +0 -1
  121. package/src/components/payload/builder/transfer/index.ts +0 -2
  122. package/src/components/payload/fields/BlockNumberTextField.tsx +0 -40
  123. package/src/components/payload/fields/XyoAddressTextField.tsx +0 -71
  124. package/src/components/payload/fields/index.ts +0 -2
  125. package/src/components/payload/index.ts +0 -2
  126. package/src/components/rate/SpanTypography.tsx +0 -20
  127. package/src/components/rate/SpeedTypography.tsx +0 -17
  128. package/src/components/rate/TimeTypography.tsx +0 -17
  129. package/src/components/rate/flexbox/FlexBox.stories.tsx +0 -46
  130. package/src/components/rate/flexbox/FlexBox.tsx +0 -31
  131. package/src/components/rate/flexbox/index.ts +0 -1
  132. package/src/components/rate/gauge/Container.stories.tsx +0 -80
  133. package/src/components/rate/gauge/Container.tsx +0 -75
  134. package/src/components/rate/gauge/Pointer.tsx +0 -67
  135. package/src/components/rate/gauge/Ticks.tsx +0 -122
  136. package/src/components/rate/gauge/WithLabel.stories.tsx +0 -73
  137. package/src/components/rate/gauge/WithLabel.tsx +0 -20
  138. package/src/components/rate/gauge/helpers/blockRateConversions.ts +0 -104
  139. package/src/components/rate/gauge/helpers/index.ts +0 -1
  140. package/src/components/rate/gauge/index.ts +0 -4
  141. package/src/components/rate/index.ts +0 -6
  142. package/src/components/rate/support/MetricTypography.tsx +0 -78
  143. package/src/components/rate/support/index.ts +0 -1
  144. package/src/components/table/StyledLinkableTableRow.tsx +0 -12
  145. package/src/components/table/index.ts +0 -1
  146. package/src/components/transactions/TransactionCountChip.tsx +0 -34
  147. package/src/components/transactions/TransactionsQuickTipButton.tsx +0 -86
  148. package/src/components/transactions/index.ts +0 -3
  149. package/src/components/transactions/submit/Builder.tsx +0 -55
  150. package/src/components/transactions/submit/Network.tsx +0 -36
  151. package/src/components/transactions/submit/SubmitChain.stories.tsx +0 -14
  152. package/src/components/transactions/submit/SubmitChain.tsx +0 -91
  153. package/src/components/transactions/submit/index.ts +0 -3
  154. package/src/context/analyzer/Provider.tsx +0 -41
  155. package/src/context/analyzer/context.ts +0 -5
  156. package/src/context/analyzer/index.ts +0 -5
  157. package/src/context/analyzer/state.ts +0 -13
  158. package/src/context/analyzer/use.ts +0 -6
  159. package/src/context/chain/Context.ts +0 -5
  160. package/src/context/chain/Provider.tsx +0 -49
  161. package/src/context/chain/State.ts +0 -8
  162. package/src/context/chain/index.ts +0 -4
  163. package/src/context/chain/use.ts +0 -6
  164. package/src/context/index.ts +0 -3
  165. package/src/context/polling/Provider.tsx +0 -27
  166. package/src/context/polling/context.ts +0 -5
  167. package/src/context/polling/index.ts +0 -4
  168. package/src/context/polling/state.ts +0 -8
  169. package/src/context/polling/use.ts +0 -5
  170. package/src/helpers/index.ts +0 -1
  171. package/src/helpers/rate/index.ts +0 -1
  172. package/src/helpers/rate/rateUnitToLabel.ts +0 -27
  173. package/src/helpers/txsFromBlock.ts +0 -12
  174. package/src/hooks/chain-iterator/index.ts +0 -1
  175. package/src/hooks/chain-iterator/useChainIteratorParams.ts +0 -55
  176. package/src/hooks/index.ts +0 -3
  177. package/src/hooks/useBaseContext.ts +0 -8
  178. package/src/hooks/useTxsFromBlock.ts +0 -12
  179. package/src/index.ts +0 -3
  180. package/src/lib/getChainArchivist.ts +0 -20
  181. package/src/lib/getChainId.ts +0 -8
  182. package/src/lib/index.ts +0 -2
  183. package/src/stories/ChainArchivistDecorator.tsx +0 -43
  184. package/src/stories/ChainArchivistDelayedInsertDecorator.tsx +0 -71
  185. package/src/stories/index.ts +0 -2
  186. package/src/types/BlockComponentProps.ts +0 -13
  187. package/src/types/BlockComponents.ts +0 -7
  188. package/src/types/BlockListComponentProps.ts +0 -6
  189. package/src/types/global.d.ts +0 -1
  190. package/src/types/index.ts +0 -4
  191. package/src/types/render/BlockChainRenderProps.ts +0 -28
  192. package/src/types/render/RemoteArchivistProps.ts +0 -5
  193. package/src/types/render/flexbox/BlockChainRenderFlexboxProps.ts +0 -8
  194. package/src/types/render/flexbox/RenderFlexboxProps.ts +0 -5
  195. package/src/types/render/flexbox/index.ts +0 -2
  196. package/src/types/render/index.ts +0 -4
  197. package/src/types/render/table/BlockChainRenderTableExProps.ts +0 -8
  198. package/src/types/render/table/RenderTableProps.ts +0 -5
  199. package/src/types/render/table/index.ts +0 -2
@@ -1,60 +0,0 @@
1
- import {
2
- TableCell,
3
- type TableRowProps,
4
- } from '@mui/material'
5
- import { isDefined, type JsonValue } from '@xylabs/sdk-js'
6
- import type { AccountBalanceHistoryItemFormatted } from '@xyo-network/react-chain-provider'
7
- import { RawInfoIconButton } from '@xyo-network/react-payload-raw-info'
8
- import type { Ref } from 'react'
9
- import React, { useMemo } from 'react'
10
-
11
- import { BlockEpochTableCellInner } from '../../block/index.ts'
12
- import { StyledLinkableTableRow } from '../../table/index.ts'
13
- import {
14
- AddressTableCell, BalanceHistoryBlockNumberTableCellInner, HashTableCell,
15
- } from './cell/index.ts'
16
- import { useLinkedBalanceHistoryItem } from './hooks/index.ts'
17
- import { RawAmountTableCell } from './RawAmountTableCell.tsx'
18
- import type { BalanceHistoryEventNouns } from './types/index.ts'
19
-
20
- // const TEXT_TX_HASH = '123456789abcdef123456789abcdef123456789abcdef123456789abcdef1234' as Hash
21
-
22
- export interface BalanceHistoryTableRowProps extends TableRowProps {
23
- linked?: boolean
24
- row: AccountBalanceHistoryItemFormatted
25
- }
26
-
27
- export const BalanceHistoryTableRow: React.FC<BalanceHistoryTableRowProps> = ({
28
- linked, row, ...props
29
- }) => {
30
- const {
31
- amount, blockNumber, debug, from, key, timestamp, to, type, txHash, transferHash,
32
- } = row ?? {} as AccountBalanceHistoryItemFormatted
33
-
34
- const linkedTableCallProps = useMemo(() => ({ linked }), [linked])
35
- const [ref, handleClick] = useLinkedBalanceHistoryItem()
36
-
37
- const noun: BalanceHistoryEventNouns = isDefined(txHash) ? 'tx-hash|transfer-hash' : 'block-number|transfer-hash'
38
- const data = isDefined(txHash) ? `${txHash}|${transferHash}` : `${blockNumber}|${transferHash}`
39
-
40
- return (
41
- <StyledLinkableTableRow
42
- linked={linked}
43
- key={key}
44
- onClick={linked ? e => handleClick(e, noun, data) : undefined}
45
- ref={ref as Ref<HTMLTableRowElement> | undefined}
46
- {...props}
47
- >
48
- <HashTableCell hash={txHash} toolTipTitle={`Transaction Hash: ${txHash}`} eventNoun="tx-hash" {...linkedTableCallProps} />
49
- <BalanceHistoryBlockNumberTableCellInner blockNumber={blockNumber} eventNoun="block-number" {...linkedTableCallProps} />
50
- <BlockEpochTableCellInner epoch={timestamp} {...linkedTableCallProps} />
51
- <AddressTableCell address={from} toolTipTitle={`From Address: ${from}`} eventNoun="from-address" {...linkedTableCallProps} />
52
- <AddressTableCell address={to} toolTipTitle={`To Address: ${to}`} eventNoun="to-address" {...linkedTableCallProps} />
53
- <RawAmountTableCell amount={amount} type={type} eventNoun="amount" />
54
- <HashTableCell hash={transferHash} toolTipTitle={`Transfer Hash: ${transferHash}`} eventNoun={noun} eventData={data} {...linkedTableCallProps} />
55
- <TableCell>
56
- <RawInfoIconButton rawValue={debug as JsonValue} />
57
- </TableCell>
58
- </StyledLinkableTableRow>
59
- )
60
- }
@@ -1,53 +0,0 @@
1
- import {
2
- Link,
3
- TableCell, type TableCellProps, Tooltip,
4
- } from '@mui/material'
5
- import { isDefined, toHex } from '@xylabs/sdk-js'
6
- import type { BalanceTransactionType } from '@xyo-network/react-chain-provider'
7
- import { XL1Amount } from '@xyo-network/xl1-sdk'
8
- import React from 'react'
9
-
10
- import { useLinkedBalanceHistoryItem } from './hooks/index.ts'
11
- import type { BalanceHistoryEventNouns } from './types/index.ts'
12
-
13
- export interface RawAmountTableCellProps extends TableCellProps {
14
- amount?: bigint
15
- eventNoun?: BalanceHistoryEventNouns
16
- linked?: boolean
17
- type?: BalanceTransactionType
18
- }
19
-
20
- export const RawAmountTableCell: React.FC<RawAmountTableCellProps> = ({
21
- amount, eventNoun = 'amount', linked, sx, type, ...props
22
- }) => {
23
- const [ref, handleClick] = useLinkedBalanceHistoryItem()
24
-
25
- const formatAmount = (amount?: bigint) => {
26
- if (!isDefined(amount)) {
27
- return 'N/A'
28
- }
29
- const xl1Amount = new XL1Amount(amount)
30
- return xl1Amount.toString(undefined, {
31
- places: 18, maxDecimal: 12, maxCharacters: 12, minDecimals: 1, locale: navigator.language,
32
- })
33
- }
34
- return (
35
- <TableCell ref={ref} {...props}>
36
- <Tooltip title={`Raw Amount: ${amount}`}>
37
- {linked
38
- ? (
39
- <Link onClick={e => handleClick(e, eventNoun, isDefined(amount) ? toHex(amount) : '')} sx={{ cursor: 'pointer' }}>
40
- {type === 'send' ? '-' : ''}
41
- {formatAmount(amount)}
42
- </Link>
43
- )
44
- : (
45
- <span>
46
- {type === 'send' ? '-' : ''}
47
- {formatAmount(amount)}
48
- </span>
49
- )}
50
- </Tooltip>
51
- </TableCell>
52
- )
53
- }
@@ -1,27 +0,0 @@
1
- import type { TableCellProps } from '@mui/material'
2
- import { TableCell, Tooltip } from '@mui/material'
3
- import React from 'react'
4
-
5
- import { BlockAddressChip } from '../../../block/index.ts'
6
- import { useLinkedBalanceHistoryItem } from '../hooks/index.ts'
7
- import type { BalanceHistoryEventNouns } from '../types/index.ts'
8
-
9
- export interface AddressTableCellProps extends TableCellProps {
10
- address?: string
11
- eventNoun?: BalanceHistoryEventNouns
12
- linked?: boolean
13
- toolTipTitle?: string
14
- }
15
-
16
- export const AddressTableCell: React.FC<AddressTableCellProps> = ({
17
- address, eventNoun, linked, toolTipTitle, sx, ...props
18
- }) => {
19
- const [ref, handleClick] = useLinkedBalanceHistoryItem()
20
- return (
21
- <TableCell ref={ref} sx={{ cursor: linked ? 'pointer' : 'default', ...sx }} {...props}>
22
- <Tooltip title={toolTipTitle}>
23
- <BlockAddressChip address={address} onClick={linked ? e => handleClick(e, eventNoun, address) : undefined} />
24
- </Tooltip>
25
- </TableCell>
26
- )
27
- }
@@ -1,39 +0,0 @@
1
- import {
2
- Link,
3
- TableCell, Tooltip,
4
- Typography,
5
- } from '@mui/material'
6
- import type { HydratedBlock } from '@xyo-network/xl1-sdk'
7
- import React from 'react'
8
-
9
- import { useLinkedBalanceHistoryItem } from '../hooks/index.ts'
10
- import type { BalanceHistoryEventNouns } from '../types/index.ts'
11
-
12
- export interface BalanceHistoryBlockNumberTableCellProps {
13
- block?: HydratedBlock
14
- eventNoun?: BalanceHistoryEventNouns
15
- linked?: boolean
16
- }
17
-
18
- export const BalanceHistoryBlockNumberTableCell: React.FC<BalanceHistoryBlockNumberTableCellProps> = ({
19
- block, eventNoun = 'block-number', linked, ...props
20
- }) => {
21
- const blockNumber = block?.[0].block
22
-
23
- return <BalanceHistoryBlockNumberTableCellInner blockNumber={blockNumber} eventNoun={eventNoun} linked={linked} {...props} />
24
- }
25
-
26
- export const BalanceHistoryBlockNumberTableCellInner: React.FC<BalanceHistoryBlockNumberTableCellProps & { blockNumber?: number; linked?: boolean }> = ({
27
- blockNumber, eventNoun = 'block-number', linked, ...props
28
- }) => {
29
- const [ref, handleClick] = useLinkedBalanceHistoryItem()
30
- return (
31
- <TableCell ref={ref} {...props}>
32
- <Tooltip title={`Block Number: ${blockNumber}`}>
33
- <Typography component="span" variant="body1">
34
- {linked ? <Link onClick={e => handleClick(e, eventNoun, blockNumber?.toString() ?? '')} sx={{ cursor: 'pointer' }}>{blockNumber}</Link> : blockNumber}
35
- </Typography>
36
- </Tooltip>
37
- </TableCell>
38
- )
39
- }
@@ -1,46 +0,0 @@
1
- import type { TableCellProps } from '@mui/material'
2
- import {
3
- Link, TableCell, Tooltip,
4
- Typography,
5
- } from '@mui/material'
6
- import {
7
- ellipsize, type Hash, isDefined,
8
- } from '@xylabs/sdk-js'
9
- import React from 'react'
10
-
11
- import { useLinkedBalanceHistoryItem } from '../hooks/index.ts'
12
- import type { BalanceHistoryEventNouns } from '../types/index.ts'
13
-
14
- export interface HashTableCellProps extends TableCellProps {
15
- eventData?: string
16
- eventNoun?: BalanceHistoryEventNouns
17
- hash?: Hash
18
- linked?: boolean
19
- toolTipTitle?: string
20
- }
21
-
22
- export const HashTableCell: React.FC<HashTableCellProps> = ({
23
- eventData, eventNoun = 'tx-hash', hash, linked, toolTipTitle, sx, ...props
24
- }) => {
25
- const [ref, handleClick] = useLinkedBalanceHistoryItem()
26
- const shortenedHash = isDefined(hash) ? ellipsize(hash as string, 6) : 'N/A'
27
- return (
28
- <TableCell ref={ref} {...props}>
29
- {hash
30
- ? (
31
- <Tooltip title={toolTipTitle}>
32
- <Typography component="span" variant="body1">
33
- {linked
34
- ? (
35
- <Link onClick={e => handleClick(e, eventNoun, eventData)} sx={{ cursor: 'pointer' }}>
36
- {shortenedHash}
37
- </Link>
38
- )
39
- : shortenedHash}
40
- </Typography>
41
- </Tooltip>
42
- )
43
- : 'N/A'}
44
- </TableCell>
45
- )
46
- }
@@ -1,3 +0,0 @@
1
- export * from './AddressTableCell.tsx'
2
- export * from './BlockNumber.tsx'
3
- export * from './HashTableCell.tsx'
@@ -1 +0,0 @@
1
- export * from './useLinkedBalanceHistoryItem.tsx'
@@ -1,29 +0,0 @@
1
- import { useEvent } from '@xyo-network/react-event'
2
- import type { Ref } from 'react'
3
- import type React from 'react'
4
-
5
- import type { BalanceHistoryEventNouns } from '../types/index.ts'
6
-
7
- export const useLinkedBalanceHistoryItem = (): [
8
- Ref<HTMLElement | null>,
9
- (event: React.MouseEvent, noun?: BalanceHistoryEventNouns, data?: string | number) => void,
10
- ] => {
11
- const [ref, dispatch] = useEvent<HTMLAnchorElement, BalanceHistoryEventNouns, string, string | number>()
12
-
13
- const handleClick = (event: React.MouseEvent, noun?: BalanceHistoryEventNouns, data?: string | number) => {
14
- event.preventDefault()
15
- event.stopPropagation()
16
- if (noun === undefined) {
17
- console.warn('useLinkedBalanceHistoryItem: noun is required')
18
- return
19
- }
20
- const selection = globalThis.getSelection()
21
- const isTextSelected = selection && selection.toString().length > 0
22
-
23
- if (!isTextSelected) {
24
- dispatch(noun, 'click', data, event.nativeEvent)
25
- }
26
- }
27
-
28
- return [ref, handleClick]
29
- }
@@ -1,5 +0,0 @@
1
- export * from './BalanceHistoryTableEx.tsx'
2
- export * from './BalanceHistoryTableRow.tsx'
3
- export * from './cell/index.ts'
4
- export * from './hooks/index.ts'
5
- export * from './types/index.ts'
@@ -1,18 +0,0 @@
1
- import type { AccountBalanceHistoryItemFormatted } from '@xyo-network/react-chain-provider'
2
- import type { ExtendEventNoun } from '@xyo-network/react-event'
3
-
4
- export type BalanceHistoryEventNouns = ExtendEventNoun<'from-address' | 'to-address' | 'amount' | 'block-number' | 'tx-hash' | 'transfer-hash' | 'tx-hash|transfer-hash' | 'block-number|transfer-hash'>
5
-
6
- export type TableHeadingLabels = 'Tx Hash' | 'BlockNumber' | 'Timestamp' | 'From' | 'To' | 'Amount' | 'Debug' | 'TransferHash'
7
- export type TableHeadings = { [key in keyof AccountBalanceHistoryItemFormatted]: TableHeadingLabels }
8
-
9
- export const TableHeadingLabels: TableHeadingLabels[] = [
10
- 'Tx Hash',
11
- 'BlockNumber',
12
- 'Timestamp',
13
- 'From',
14
- 'To',
15
- 'Amount',
16
- 'TransferHash',
17
- 'Debug',
18
- ] as const
@@ -1,75 +0,0 @@
1
- import {
2
- Alert, AlertTitle, List, ListItem, Stack,
3
- } from '@mui/material'
4
- import type { Meta, StoryFn } from '@storybook/react-vite'
5
- import { buildRandomBlockChainBlocksOnly } from '@xyo-network/react-chain-shared'
6
- import React, { useState } from 'react'
7
-
8
- import { BlockHeadingFlexbox } from './BlockHeadingFlexbox.tsx'
9
- import type { BlockHeaderEventNouns } from './hooks/index.ts'
10
- import { useBlockHeadingEvents } from './hooks/index.ts'
11
-
12
- export default {
13
- title: 'Block/Flexbox',
14
- component: BlockHeadingFlexbox,
15
- } as Meta
16
-
17
- const blocks = await buildRandomBlockChainBlocksOnly()
18
-
19
- const Template: StoryFn<typeof BlockHeadingFlexbox> = args => <BlockHeadingFlexbox {...args} />
20
-
21
- type EventData = {
22
- data: string | undefined
23
- noun: BlockHeaderEventNouns
24
- verb: string
25
- }
26
-
27
- const TemplateWithEvents: StoryFn<typeof BlockHeadingFlexbox> = (args) => {
28
- const [eventData, setEventData] = useState<EventData[]>([])
29
- const [ref] = useBlockHeadingEvents<HTMLDivElement>((noun, verb, data) => {
30
- setEventData(previous => [...previous, {
31
- noun, verb, data,
32
- }])
33
- })
34
-
35
- return (
36
- <div ref={ref}>
37
- <BlockHeadingFlexbox {...args} />
38
- <Stack gap={2} flexDirection="column">
39
- {eventData.length > 0
40
- ? 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
- : null}
59
- </Stack>
60
- </div>
61
- )
62
- }
63
-
64
- const Default = Template.bind({})
65
- Default.args = {}
66
-
67
- const WithData = Template.bind({})
68
- WithData.args = { block: blocks[0], transactions: undefined }
69
-
70
- const WithDataEvents = TemplateWithEvents.bind({})
71
- WithDataEvents.args = { block: blocks[0], transactions: undefined }
72
-
73
- export {
74
- Default, WithData, WithDataEvents,
75
- }
@@ -1,56 +0,0 @@
1
- import { FlexCol, FlexRow } from '@xylabs/react-flexbox'
2
- import type { Hash } from '@xylabs/sdk-js'
3
- import { BWVerification, HashHeadingPaper } from '@xyo-network/react-boundwitness-plugin'
4
- import { usePayloadHash } from '@xyo-network/react-shared'
5
- import React from 'react'
6
-
7
- import { useChainPollingContext } from '../../context/index.ts'
8
- import type { BlockComponentWithTxsProps } from '../../types/index.ts'
9
- import { TransactionCountChip } from '../transactions/index.ts'
10
- import { useBlockHeadingEvents } from './hooks/index.ts'
11
- import { LinkedDivider } from './LinkedDivider.tsx'
12
- import { BlockMenuExpanded } from './menu/index.ts'
13
- import { BlockProducerChip } from './ProducerChip.tsx'
14
-
15
- export const BlockHeadingFlexbox: React.FC<BlockComponentWithTxsProps> = ({
16
- block, defaultExpanded, transactions,
17
- }) => {
18
- const hash = usePayloadHash(block?.[0])
19
- const [blockHeadingRef, blockHeadingListener] = useBlockHeadingEvents<HTMLDivElement>()
20
- const { pollingState } = useChainPollingContext()
21
- const expanded = (pollingState === 'paused') || defaultExpanded
22
-
23
- const handleTransactionCountClick = (event: React.MouseEvent, transactions: Hash[]) => {
24
- event.stopPropagation()
25
- blockHeadingListener('transaction-count', 'click', JSON.stringify(transactions), event.nativeEvent)
26
- }
27
-
28
- return (
29
- <FlexCol className="block-heading-flexbox" alignItems="stretch" ref={blockHeadingRef} onClick={() => blockHeadingListener('block-hash', 'click', hash)}>
30
- <LinkedDivider />
31
- <HashHeadingPaper
32
- hash={hash}
33
- heading={block?.[0].block === undefined ? '' : block?.[0].block.toString()}
34
- paperProps={{ sx: { p: 1, width: '100%' } }}
35
- AdornmentEnd={(
36
- <FlexRow gap={1}>
37
- <BlockProducerChip block={block} />
38
- <TransactionCountChip
39
- onClick={e => handleTransactionCountClick(e, transactions ?? [])}
40
- transactions={transactions}
41
- />
42
- <BWVerification iconColors boundwitness={block?.[0]} />
43
- <span style={{
44
- // maxWidth is required for css animation to work and 28px is the width of the icon button
45
- display: 'flex', transition: 'max-width .5s', maxWidth: expanded ? '28px' : 0,
46
- }}
47
- >
48
- <BlockMenuExpanded block={block} />
49
- </span>
50
- </FlexRow>
51
- )}
52
- identiconProps={{ p: 0.75, size: 18 }}
53
- />
54
- </FlexCol>
55
- )
56
- }
@@ -1,7 +0,0 @@
1
- import type { SkeletonProps } from '@mui/material'
2
- import { Skeleton } from '@mui/material'
3
- import React from 'react'
4
-
5
- export const ChipSkeleton: React.FC<SkeletonProps> = (props) => {
6
- return <Skeleton width={100} {...props} />
7
- }
@@ -1,27 +0,0 @@
1
- import { Divider, Stack } from '@mui/material'
2
- import React from 'react'
3
-
4
- export const LinkedDivider: React.FC = () => {
5
- return (
6
- <>
7
- {/* An element to house the height of the divider...really just here to help with calculating
8
- the height for animation purposes and allowing for a dynamic divider height */}
9
- <Stack
10
- className="divider-spacer"
11
- justifyContent="end"
12
- sx={{
13
- width: '50%', height: 24, justifyContent: 'end',
14
- }}
15
- >
16
- <Divider
17
- className="divider"
18
- orientation="vertical"
19
- flexItem
20
- sx={{
21
- borderRightWidth: 2, height: 24, transition: 'height 1s',
22
- }}
23
- />
24
- </Stack>
25
- </>
26
- )
27
- }
@@ -1,45 +0,0 @@
1
- import type { ChipProps } from '@mui/material'
2
- import { Chip } from '@mui/material'
3
- import {
4
- EthAddressWrapper, isString, isUndefined, toAddress,
5
- } from '@xylabs/sdk-js'
6
- import { BlockiesAvatar } from '@xyo-network/react-chain-blockies'
7
- import type { HydratedBlock } from '@xyo-network/xl1-sdk'
8
- import React, { useMemo } from 'react'
9
-
10
- import { ChipSkeleton } from './ChipSkeleton.tsx'
11
-
12
- const formatProducerAddress = (address?: string): string | undefined => {
13
- if (isUndefined(address) || !isString(address)) return undefined
14
- const formattedAddress = toAddress(address)
15
- return EthAddressWrapper.parse(formattedAddress)?.toShortString(4)
16
- }
17
-
18
- export interface BlockProducerChipProps extends ChipProps {
19
- block?: HydratedBlock
20
- }
21
- export const BlockProducerChip: React.FC<BlockProducerChipProps> = ({ block, ...props }) => {
22
- const blockProducer = block?.[0].addresses[0]
23
-
24
- return <BlockAddressChip address={blockProducer} toolTipTitle={`Block producer: ${blockProducer}`} {...props} />
25
- }
26
-
27
- export const BlockAddressChip: React.FC<BlockProducerChipProps & { address?: string; toolTipTitle?: string }> = ({
28
- address, sx, toolTipTitle, ...props
29
- }) => {
30
- const shortedBlockProducer = address === undefined ? null : formatProducerAddress(address)
31
-
32
- const avatar = useMemo(() => address === '' ? undefined : <BlockiesAvatar blockiesOptions={{ seed: address }} />, [address])
33
-
34
- return (
35
- <Chip
36
- avatar={avatar}
37
- label={shortedBlockProducer ?? <ChipSkeleton width={115} />}
38
- title={toolTipTitle}
39
- sx={{
40
- fontFamily: 'monospace', cursor: 'pointer', ...sx,
41
- }}
42
- {...props}
43
- />
44
- )
45
- }
@@ -1,5 +0,0 @@
1
- import type { BlockBoundWitness } from '@xyo-network/xl1-sdk'
2
-
3
- export const blockProducer = (block: BlockBoundWitness) => {
4
- return block.addresses[0]
5
- }
@@ -1,32 +0,0 @@
1
- import type { BaseContext } from '@xyo-network/xl1-sdk'
2
- import type { ComponentType } from 'react'
3
- import React from 'react'
4
-
5
- import { txsFromBlock } from '../../../helpers/index.ts'
6
- import type {
7
- BlockChainRenderComponent,
8
- BlockComponentProps, BlockComponentWithTxsProps,
9
- } from '../../../types/index.ts'
10
-
11
- export const buildBlockChainRenderComponent = async (
12
- context: BaseContext,
13
- BlockComponent: ComponentType<BlockComponentWithTxsProps>,
14
- blockComponentProps: BlockComponentProps,
15
- ) => {
16
- const { block, ...remainingProps } = blockComponentProps
17
- const blockTxs = await txsFromBlock(block)
18
- const txHashes = blockTxs.map(([_, hash]) => hash)
19
-
20
- const item: BlockChainRenderComponent = {
21
- child: (
22
- <BlockComponent
23
- block={block}
24
- transactions={txHashes}
25
- {...remainingProps}
26
- />
27
- ),
28
- key: block[0].block.toString(),
29
- block,
30
- }
31
- return item
32
- }
@@ -1,3 +0,0 @@
1
- export * from './blockProducer.ts'
2
- export * from './buildBlockChainRenderComponent.tsx'
3
- export * from './payloadCountsFromBlock.ts'
@@ -1,10 +0,0 @@
1
- import { BoundWitnessSchema } from '@xyo-network/boundwitness-model'
2
- import type { HydratedBlockWithHashMeta } from '@xyo-network/xl1-sdk'
3
- import { isTransactionBoundWitness } from '@xyo-network/xl1-sdk'
4
-
5
- export const payloadCountsFromBlock = ([block, payloads]: HydratedBlockWithHashMeta): [number, number] => {
6
- const publicPayloads = block.payload_schemas.filter(schema => schema !== BoundWitnessSchema)
7
- const transactionHashes = payloads.filter(payload => isTransactionBoundWitness(payload)).flatMap(payload => payload.payload_hashes)
8
- const privateHashes = transactionHashes.filter(hash => !payloads.some(payload => payload._hash === hash))
9
- return [publicPayloads.length, privateHashes.length]
10
- }
@@ -1,4 +0,0 @@
1
- export * from './useAnchorElement.ts'
2
- export * from './useBlockHeadingEvents.ts'
3
- export * from './useBlockProducer.ts'
4
- export * from './usePayloadCountsFromBlock.ts'
@@ -1,19 +0,0 @@
1
- import { useRef, useState } from 'react'
2
-
3
- export const useAnchorElement = () => {
4
- const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null)
5
- const anchorRef = useRef<HTMLButtonElement>(null)
6
- const open = Boolean(anchorEl)
7
-
8
- const handleClick = (event: React.MouseEvent<HTMLElement>) => {
9
- setAnchorEl(event.currentTarget)
10
- }
11
-
12
- const handleClose = () => {
13
- setAnchorEl(null)
14
- }
15
-
16
- return {
17
- anchorEl, anchorRef, open, handleClick, handleClose,
18
- }
19
- }
@@ -1,11 +0,0 @@
1
- import { useEvent } from '@xyo-network/react-event'
2
-
3
- export type BlockHeaderEventNouns = 'transaction-count' | 'block-hash' | 'block-number' | 'block-producer' | 'block-verification' | 'payload-counts'
4
-
5
- // Extracting the type so compilers can easily strip it off vs inlining it withing the hook
6
- // which causes compilation warnings.
7
- type HookArgs<TElement extends HTMLElement> = Parameters<typeof useEvent<TElement, BlockHeaderEventNouns>>
8
-
9
- export const useBlockHeadingEvents = <TElement extends HTMLElement>(...args: HookArgs<TElement>) => {
10
- return useEvent<TElement, BlockHeaderEventNouns>(...args)
11
- }
@@ -1,11 +0,0 @@
1
- import type { HydratedBlock } from '@xyo-network/xl1-sdk'
2
- import { useMemo } from 'react'
3
-
4
- export const useBlockProducer = (block?: HydratedBlock) => {
5
- return useMemo(() => {
6
- if (block) {
7
- const producer = block[0].addresses[0]
8
- return producer
9
- }
10
- }, [block])
11
- }
@@ -1,13 +0,0 @@
1
- import type { HydratedBlockWithHashMeta } from '@xyo-network/xl1-sdk'
2
- import { useMemo } from 'react'
3
-
4
- import { payloadCountsFromBlock } from '../helpers/index.ts'
5
-
6
- export const usePayloadCountsFromBlock = (block?: HydratedBlockWithHashMeta): [number | undefined, number | undefined, Error | undefined] => {
7
- return useMemo(() => {
8
- if (block) {
9
- return [...payloadCountsFromBlock(block), undefined]
10
- }
11
- return [undefined, undefined, undefined]
12
- }, [block])
13
- }
@@ -1,6 +0,0 @@
1
- export * from './BlockHeadingFlexbox.tsx'
2
- export * from './ChipSkeleton.tsx'
3
- export * from './helpers/index.ts'
4
- export * from './hooks/index.ts'
5
- export * from './ProducerChip.tsx'
6
- export * from './table/index.ts'