@xyo-network/react-chain-blockchain 1.0.9 → 1.0.11

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 (131) hide show
  1. package/dist/browser/index.mjs +255 -235
  2. package/dist/browser/index.mjs.map +1 -1
  3. package/dist/types/components/block/ProducerChip.d.ts +2 -2
  4. package/dist/types/components/block/ProducerChip.d.ts.map +1 -1
  5. package/dist/types/components/block/helpers/buildBlockChainRenderComponent.d.ts +2 -3
  6. package/dist/types/components/block/helpers/buildBlockChainRenderComponent.d.ts.map +1 -1
  7. package/dist/types/components/block/helpers/tsxFromBlock.d.ts +3 -4
  8. package/dist/types/components/block/helpers/tsxFromBlock.d.ts.map +1 -1
  9. package/dist/types/components/block/hooks/useBlockProducer.d.ts +2 -2
  10. package/dist/types/components/block/hooks/useBlockProducer.d.ts.map +1 -1
  11. package/dist/types/components/block/hooks/useDynamicBlockComponents.d.ts +2 -2
  12. package/dist/types/components/block/hooks/useDynamicBlockComponents.d.ts.map +1 -1
  13. package/dist/types/components/block/hooks/useStaticBlockComponents.d.ts +2 -2
  14. package/dist/types/components/block/hooks/useStaticBlockComponents.d.ts.map +1 -1
  15. package/dist/types/components/block/hooks/useTxsFromBlock.d.ts +3 -4
  16. package/dist/types/components/block/hooks/useTxsFromBlock.d.ts.map +1 -1
  17. package/dist/types/components/block/menu/Expanded.d.ts +2 -2
  18. package/dist/types/components/block/menu/Expanded.d.ts.map +1 -1
  19. package/dist/types/components/block/table/Ex.d.ts +1 -4
  20. package/dist/types/components/block/table/Ex.d.ts.map +1 -1
  21. package/dist/types/components/block/table/cell/TransactionCount.d.ts +0 -2
  22. package/dist/types/components/block/table/cell/TransactionCount.d.ts.map +1 -1
  23. package/dist/types/components/block/table/cell/lib/BlockTableCellProps.d.ts +2 -2
  24. package/dist/types/components/block/table/cell/lib/BlockTableCellProps.d.ts.map +1 -1
  25. package/dist/types/components/block/table/head/TableHead.d.ts +3 -0
  26. package/dist/types/components/block/table/head/TableHead.d.ts.map +1 -0
  27. package/dist/types/components/block/table/head/index.d.ts +2 -0
  28. package/dist/types/components/block/table/head/index.d.ts.map +1 -0
  29. package/dist/types/components/block/table/index.d.ts +1 -0
  30. package/dist/types/components/block/table/index.d.ts.map +1 -1
  31. package/dist/types/components/chain/hooks/useOnBlock.d.ts +2 -2
  32. package/dist/types/components/chain/hooks/useOnBlock.d.ts.map +1 -1
  33. package/dist/types/components/chain/render/dynamic/flexbox/Flexbox.d.ts +3 -5
  34. package/dist/types/components/chain/render/dynamic/flexbox/Flexbox.d.ts.map +1 -1
  35. package/dist/types/components/chain/render/dynamic/flexbox/variants/Base.d.ts +4 -0
  36. package/dist/types/components/chain/render/dynamic/flexbox/variants/Base.d.ts.map +1 -0
  37. package/dist/types/components/chain/render/dynamic/flexbox/variants/WithAnalysis.d.ts +4 -0
  38. package/dist/types/components/chain/render/dynamic/flexbox/variants/WithAnalysis.d.ts.map +1 -0
  39. package/dist/types/components/chain/render/dynamic/flexbox/variants/WithRemote.d.ts +4 -0
  40. package/dist/types/components/chain/render/dynamic/flexbox/variants/WithRemote.d.ts.map +1 -0
  41. package/dist/types/components/chain/render/dynamic/flexbox/variants/index.d.ts +4 -0
  42. package/dist/types/components/chain/render/dynamic/flexbox/variants/index.d.ts.map +1 -0
  43. package/dist/types/components/chain/render/dynamic/hooks/useDynamicBlockRenderComponents.d.ts +1 -1
  44. package/dist/types/components/chain/render/static/flexbox/Flexbox.d.ts +2 -4
  45. package/dist/types/components/chain/render/static/flexbox/Flexbox.d.ts.map +1 -1
  46. package/dist/types/components/chain/render/static/flexbox/variants/Base.d.ts +4 -0
  47. package/dist/types/components/chain/render/static/flexbox/variants/Base.d.ts.map +1 -0
  48. package/dist/types/components/chain/render/static/flexbox/variants/WithAnalysis.d.ts +4 -0
  49. package/dist/types/components/chain/render/static/flexbox/variants/WithAnalysis.d.ts.map +1 -0
  50. package/dist/types/components/chain/render/static/flexbox/variants/index.d.ts +3 -0
  51. package/dist/types/components/chain/render/static/flexbox/variants/index.d.ts.map +1 -0
  52. package/dist/types/components/chain/render/static/table/Ex.d.ts +2 -6
  53. package/dist/types/components/chain/render/static/table/Ex.d.ts.map +1 -1
  54. package/dist/types/components/chain/render/static/table/variants/Base.d.ts +4 -0
  55. package/dist/types/components/chain/render/static/table/variants/Base.d.ts.map +1 -0
  56. package/dist/types/components/chain/render/static/table/variants/WithAnalysis.d.ts +4 -0
  57. package/dist/types/components/chain/render/static/table/variants/WithAnalysis.d.ts.map +1 -0
  58. package/dist/types/components/chain/render/static/table/variants/index.d.ts +3 -0
  59. package/dist/types/components/chain/render/static/table/variants/index.d.ts.map +1 -0
  60. package/dist/types/components/payload/fields/XyoAddressTextField.d.ts.map +1 -1
  61. package/dist/types/components/transactions/TransactionsQuickTipButton.d.ts +2 -4
  62. package/dist/types/components/transactions/TransactionsQuickTipButton.d.ts.map +1 -1
  63. package/dist/types/context/analyzer/Provider.d.ts.map +1 -1
  64. package/dist/types/context/analyzer/state.d.ts +2 -3
  65. package/dist/types/context/analyzer/state.d.ts.map +1 -1
  66. package/dist/types/context/chain/Provider.d.ts.map +1 -1
  67. package/dist/types/hooks/chain-iterator/ChainIteratorStore.d.ts +2 -2
  68. package/dist/types/hooks/chain-iterator/ChainIteratorStore.d.ts.map +1 -1
  69. package/dist/types/hooks/chain-iterator/useChainIteratorStore.d.ts.map +1 -1
  70. package/dist/types/hooks/chain-iterator/useChainIteratorUpdatingHead.d.ts.map +1 -1
  71. package/dist/types/hooks/useIterateChain.d.ts +2 -2
  72. package/dist/types/hooks/useIterateChain.d.ts.map +1 -1
  73. package/dist/types/stories/ChainArchivistDecorator.d.ts.map +1 -1
  74. package/dist/types/stories/ChainArchivistDelayedInsertDecorator.d.ts.map +1 -1
  75. package/dist/types/stories/buildRandomBlockchain.d.ts +3 -2
  76. package/dist/types/stories/buildRandomBlockchain.d.ts.map +1 -1
  77. package/dist/types/types/BlockComponentProps.d.ts +2 -2
  78. package/dist/types/types/BlockComponentProps.d.ts.map +1 -1
  79. package/dist/types/types/BlockComponents.d.ts +2 -2
  80. package/dist/types/types/BlockComponents.d.ts.map +1 -1
  81. package/package.json +8 -8
  82. package/src/components/block/BlockHeadingFlexbox.stories.tsx +2 -2
  83. package/src/components/block/BlockHeadingFlexbox.tsx +3 -3
  84. package/src/components/block/ProducerChip.tsx +3 -9
  85. package/src/components/block/helpers/buildBlockChainRenderComponent.tsx +3 -6
  86. package/src/components/block/helpers/tsxFromBlock.ts +4 -6
  87. package/src/components/block/hooks/useBlockProducer.ts +3 -3
  88. package/src/components/block/hooks/useDynamicBlockComponents.ts +6 -7
  89. package/src/components/block/hooks/useStaticBlockComponents.ts +4 -4
  90. package/src/components/block/hooks/useTxsFromBlock.ts +5 -6
  91. package/src/components/block/menu/Expanded.tsx +4 -4
  92. package/src/components/block/table/Ex.stories.tsx +4 -8
  93. package/src/components/block/table/Ex.tsx +5 -14
  94. package/src/components/block/table/cell/BlockNumber.tsx +3 -3
  95. package/src/components/block/table/cell/Hash.tsx +1 -1
  96. package/src/components/block/table/cell/JsonView.tsx +1 -1
  97. package/src/components/block/table/cell/TransactionCount.tsx +3 -6
  98. package/src/components/block/table/cell/Verification.tsx +2 -2
  99. package/src/components/block/table/cell/lib/BlockTableCellProps.ts +2 -2
  100. package/src/components/block/table/head/TableHead.tsx +19 -0
  101. package/src/components/block/table/head/index.ts +1 -0
  102. package/src/components/block/table/index.ts +1 -0
  103. package/src/components/chain/hooks/useOnBlock.ts +11 -7
  104. package/src/components/chain/render/dynamic/flexbox/Flexbox.tsx +4 -62
  105. package/src/components/chain/render/dynamic/flexbox/variants/Base.tsx +27 -0
  106. package/src/components/chain/render/dynamic/flexbox/variants/WithAnalysis.tsx +25 -0
  107. package/src/components/chain/render/dynamic/flexbox/variants/WithRemote.tsx +19 -0
  108. package/src/components/chain/render/dynamic/flexbox/variants/index.ts +3 -0
  109. package/src/components/chain/render/dynamic/hooks/useDynamicBlockRenderComponents.ts +1 -1
  110. package/src/components/chain/render/static/flexbox/Flexbox.tsx +2 -54
  111. package/src/components/chain/render/static/flexbox/variants/Base.tsx +31 -0
  112. package/src/components/chain/render/static/flexbox/variants/WithAnalysis.tsx +23 -0
  113. package/src/components/chain/render/static/flexbox/variants/index.ts +2 -0
  114. package/src/components/chain/render/static/table/Ex.tsx +2 -36
  115. package/src/components/chain/render/static/table/variants/Base.tsx +29 -0
  116. package/src/components/chain/render/static/table/variants/WithAnalysis.tsx +11 -0
  117. package/src/components/chain/render/static/table/variants/index.ts +2 -0
  118. package/src/components/payload/fields/XyoAddressTextField.tsx +2 -2
  119. package/src/components/transactions/TransactionsQuickTipButton.tsx +4 -8
  120. package/src/context/analyzer/Provider.tsx +3 -8
  121. package/src/context/analyzer/state.ts +2 -3
  122. package/src/context/chain/Provider.tsx +4 -6
  123. package/src/hooks/chain-iterator/ChainIteratorStore.ts +12 -5
  124. package/src/hooks/chain-iterator/useChainIteratorStore.ts +2 -1
  125. package/src/hooks/chain-iterator/useChainIteratorUpdatingHead.ts +1 -0
  126. package/src/hooks/useIterateChain.ts +20 -7
  127. package/src/stories/ChainArchivistDecorator.tsx +4 -3
  128. package/src/stories/ChainArchivistDelayedInsertDecorator.tsx +10 -26
  129. package/src/stories/buildRandomBlockchain.ts +2 -4
  130. package/src/types/BlockComponentProps.ts +2 -2
  131. package/src/types/BlockComponents.ts +2 -2
@@ -0,0 +1,25 @@
1
+ import { ChainProducersAnalyzer } from '@xyo-network/chain-protocol'
2
+ import React, { useMemo } from 'react'
3
+
4
+ import type { ChainAnalyzers } from '../../../../../../context/index.ts'
5
+ import { ChainAnalyzersProvider, ChainPollingProvider } from '../../../../../../context/index.ts'
6
+ import type { BlockChainRenderFlexboxProps } from '../../../../../../types/index.ts'
7
+ import { DynamicListBase } from './Base.tsx'
8
+
9
+ export const WithAnalysis: React.FC<BlockChainRenderFlexboxProps> = ({ blockChainRenderProps, ...props }) => {
10
+ const { chainInformation } = blockChainRenderProps ?? {}
11
+
12
+ const analyzers = useMemo(() => {
13
+ if (chainInformation) {
14
+ return { producers: new ChainProducersAnalyzer() } as ChainAnalyzers
15
+ }
16
+ }, [chainInformation])
17
+
18
+ return (
19
+ <ChainAnalyzersProvider analyzers={analyzers}>
20
+ <ChainPollingProvider>
21
+ <DynamicListBase blockChainRenderProps={blockChainRenderProps} {...props} />
22
+ </ChainPollingProvider>
23
+ </ChainAnalyzersProvider>
24
+ )
25
+ }
@@ -0,0 +1,19 @@
1
+ import { ErrorRender } from '@xylabs/react-error'
2
+ import React from 'react'
3
+
4
+ import type { RemoteBlockChainRenderFlexboxProps } from '../../../../../../types/index.ts'
5
+ import { useRemoteBlockChainRenderProps } from '../../hooks/useRemoteBlockChainRenderProps.ts'
6
+ import { WithAnalysis } from './WithAnalysis.tsx'
7
+
8
+ export const WithRemote: React.FC<RemoteBlockChainRenderFlexboxProps> = ({
9
+ url, chainArchivistModuleId, blockChainRenderProps: blockChainRenderPropsArg, ...props
10
+ }) => {
11
+ const { error, blockChainRenderProps } = useRemoteBlockChainRenderProps(chainArchivistModuleId, url, blockChainRenderPropsArg)
12
+
13
+ return (
14
+ <>
15
+ <ErrorRender error={error} scope="RemoteChainProviderFlexbox" />
16
+ <WithAnalysis blockChainRenderProps={blockChainRenderProps} {...props} />
17
+ </>
18
+ )
19
+ }
@@ -0,0 +1,3 @@
1
+ export * from './Base.tsx'
2
+ export * from './WithAnalysis.tsx'
3
+ export * from './WithRemote.tsx'
@@ -24,7 +24,7 @@ export const useDynamicBlockRenderComponents = (
24
24
 
25
25
  const { pollingState, updatePollingState } = useChainPollingContext()
26
26
 
27
- const blocksWhilePaused = useOnBlock(blockChainRenderComponents[0]?.block.block, onAddBlock, liveHead, pollingState)
27
+ const blocksWhilePaused = useOnBlock(blockChainRenderComponents[0]?.block?.[0].block, onAddBlock, liveHead, pollingState)
28
28
 
29
29
  return {
30
30
  errors: [paramsError],
@@ -1,55 +1,3 @@
1
- import { ErrorRender } from '@xylabs/react-error'
2
- import { FlexCol, FlexGrowRow } from '@xylabs/react-flexbox'
3
- import { ChainProducersAnalyzer } from '@xyo-network/chain-protocol'
4
- import React, { useMemo } from 'react'
1
+ import { StaticListBase, WithAnalysis } from './variants/index.ts'
5
2
 
6
- import type { ChainAnalyzers } from '../../../../../context/index.ts'
7
- import { ChainAnalyzersProvider } from '../../../../../context/index.ts'
8
- import type { BlockChainRenderFlexboxProps } from '../../../../../types/index.ts'
9
- import { BlockHeadingFlexbox } from '../../../../block/index.ts'
10
- import { BlockListAnimated } from '../../../list/index.ts'
11
- import { BlockChainPagination } from '../../../pagination/index.ts'
12
- import { ChainAnalyzerStatsDialogFromContext } from '../../../stats/index.ts'
13
- import { useStaticBlockRenderComponents } from '../hooks/index.ts'
14
-
15
- const Base: React.FC<BlockChainRenderFlexboxProps> = ({ blockChainRenderProps, ...props }) => {
16
- const {
17
- blockComponents, errors, paginatedBlockComponents, onPageChange, page, pageSize,
18
- } = useStaticBlockRenderComponents(BlockHeadingFlexbox, blockChainRenderProps)
19
-
20
- return (
21
- <FlexCol alignItems="start" gap={2} width="100%" {...props}>
22
- {errors?.map((error, index) => <ErrorRender error={error} key={index} scope="StaticBlockchainFlexboxInner" />)}
23
- {paginatedBlockComponents?.length
24
- ? (
25
- <FlexGrowRow justifyContent="space-between" width="100%">
26
- <ChainAnalyzerStatsDialogFromContext />
27
- <BlockChainPagination count={blockComponents?.length ?? 0} onPageChange={onPageChange} page={page} rowsPerPage={pageSize} />
28
- </FlexGrowRow>
29
- )
30
- : null}
31
- <BlockListAnimated blockChainRenderComponents={paginatedBlockComponents} />
32
- </FlexCol>
33
- )
34
- }
35
-
36
- const WithAnalysis: React.FC<BlockChainRenderFlexboxProps> = ({ blockChainRenderProps, ...props }) => {
37
- const { chainInformation } = blockChainRenderProps ?? {}
38
-
39
- const analyzers = useMemo(() => {
40
- if (chainInformation) {
41
- return { producers: new ChainProducersAnalyzer() } as ChainAnalyzers
42
- }
43
- }, [chainInformation])
44
-
45
- return (
46
- <ChainAnalyzersProvider analyzers={analyzers}>
47
- <StaticBlockchainRenderFlexBox.Base blockChainRenderProps={blockChainRenderProps} {...props} />
48
- </ChainAnalyzersProvider>
49
- )
50
- }
51
-
52
- export const StaticBlockchainRenderFlexBox = {
53
- Base,
54
- WithAnalysis,
55
- }
3
+ export const StaticBlockchainRenderFlexBox = { Base: StaticListBase, WithAnalysis }
@@ -0,0 +1,31 @@
1
+ import { ErrorRender } from '@xylabs/react-error'
2
+ import { FlexCol, FlexGrowRow } from '@xylabs/react-flexbox'
3
+ import React from 'react'
4
+
5
+ import type { BlockChainRenderFlexboxProps } from '../../../../../../types/index.ts'
6
+ import { BlockHeadingFlexbox } from '../../../../../block/index.ts'
7
+ import { BlockListAnimated } from '../../../../list/index.ts'
8
+ import { BlockChainPagination } from '../../../../pagination/index.ts'
9
+ import { ChainAnalyzerStatsDialogFromContext } from '../../../../stats/index.ts'
10
+ import { useStaticBlockRenderComponents } from '../../hooks/index.ts'
11
+
12
+ export const StaticListBase: React.FC<BlockChainRenderFlexboxProps> = ({ blockChainRenderProps, ...props }) => {
13
+ const {
14
+ blockComponents, errors, paginatedBlockComponents, onPageChange, page, pageSize,
15
+ } = useStaticBlockRenderComponents(BlockHeadingFlexbox, blockChainRenderProps)
16
+
17
+ return (
18
+ <FlexCol alignItems="start" gap={2} width="100%" {...props}>
19
+ {errors?.map(error => <ErrorRender error={error} key={error.name} scope="StaticBlockchainFlexboxInner" />)}
20
+ {paginatedBlockComponents?.length
21
+ ? (
22
+ <FlexGrowRow justifyContent="space-between" width="100%">
23
+ <ChainAnalyzerStatsDialogFromContext />
24
+ <BlockChainPagination count={blockComponents?.length ?? 0} onPageChange={onPageChange} page={page} rowsPerPage={pageSize} />
25
+ </FlexGrowRow>
26
+ )
27
+ : null}
28
+ <BlockListAnimated blockChainRenderComponents={paginatedBlockComponents} />
29
+ </FlexCol>
30
+ )
31
+ }
@@ -0,0 +1,23 @@
1
+ import { ChainProducersAnalyzer } from '@xyo-network/chain-protocol'
2
+ import React, { useMemo } from 'react'
3
+
4
+ import type { ChainAnalyzers } from '../../../../../../context/index.ts'
5
+ import { ChainAnalyzersProvider } from '../../../../../../context/index.ts'
6
+ import type { BlockChainRenderFlexboxProps } from '../../../../../../types/index.ts'
7
+ import { StaticListBase } from './Base.tsx'
8
+
9
+ export const WithAnalysis: React.FC<BlockChainRenderFlexboxProps> = ({ blockChainRenderProps, ...props }) => {
10
+ const { chainInformation } = blockChainRenderProps ?? {}
11
+
12
+ const analyzers = useMemo(() => {
13
+ if (chainInformation) {
14
+ return { producers: new ChainProducersAnalyzer() } as ChainAnalyzers
15
+ }
16
+ }, [chainInformation])
17
+
18
+ return (
19
+ <ChainAnalyzersProvider analyzers={analyzers}>
20
+ <StaticListBase blockChainRenderProps={blockChainRenderProps} {...props} />
21
+ </ChainAnalyzersProvider>
22
+ )
23
+ }
@@ -0,0 +1,2 @@
1
+ export * from './Base.tsx'
2
+ export * from './WithAnalysis.tsx'
@@ -1,38 +1,4 @@
1
- import { ErrorRender } from '@xylabs/react-error'
2
- import { FlexCol, FlexGrowRow } from '@xylabs/react-flexbox'
3
- import React from 'react'
4
-
5
- import type { BlockChainRenderTableExProps } from '../../../../../types/index.ts'
6
- import { BlockChainTableRow } from '../../../../block/index.ts'
7
- import { BlockListTableEx } from '../../../list/index.ts'
8
- import { BlockChainPagination } from '../../../pagination/index.ts'
9
- import { useStaticBlockRenderComponents } from '../hooks/index.ts'
10
-
11
- export const Base: React.FC<BlockChainRenderTableExProps> = ({ blockChainRenderProps, ...props }) => {
12
- const {
13
- blockComponents, errors, paginatedBlockComponents, onPageChange, page, pageSize,
14
- } = useStaticBlockRenderComponents(BlockChainTableRow, blockChainRenderProps)
15
-
16
- return (
17
- <FlexCol alignItems="start" gap={2} width="100%" {...props}>
18
- {errors?.map((error, index) => <ErrorRender error={error} key={index} scope="StaticBlockchainFlexboxInner" />)}
19
- {paginatedBlockComponents?.length
20
- ? (
21
- <FlexGrowRow justifyContent="space-between" width="100%">
22
- <BlockChainPagination count={blockComponents?.length ?? 0} onPageChange={onPageChange} page={page} rowsPerPage={pageSize} />
23
- </FlexGrowRow>
24
- )
25
- : null}
26
- <BlockListTableEx blockChainRenderComponents={paginatedBlockComponents} />
27
- </FlexCol>
28
- )
29
- }
30
-
31
- export const WithAnalysis: React.FC<BlockChainRenderTableExProps> = ({ blockChainRenderProps, ...props }) => {
32
- // NOTE: More code here if we want to analyze the static data via ChainAnalyzers
33
- return (
34
- <StaticBlockchainRenderTableEx.Base blockChainRenderProps={blockChainRenderProps} {...props} />
35
- )
36
- }
1
+ import { Base } from './variants/index.ts'
2
+ import { WithAnalysis } from './variants/WithAnalysis.tsx'
37
3
 
38
4
  export const StaticBlockchainRenderTableEx = { Base, WithAnalysis }
@@ -0,0 +1,29 @@
1
+ import { ErrorRender } from '@xylabs/react-error'
2
+ import { FlexCol, FlexGrowRow } from '@xylabs/react-flexbox'
3
+ import React from 'react'
4
+
5
+ import type { BlockChainRenderTableExProps } from '../../../../../../types/index.ts'
6
+ import { BlockChainTableRow } from '../../../../../block/index.ts'
7
+ import { BlockListTableEx } from '../../../../list/index.ts'
8
+ import { BlockChainPagination } from '../../../../pagination/index.ts'
9
+ import { useStaticBlockRenderComponents } from '../../hooks/index.ts'
10
+
11
+ export const Base: React.FC<BlockChainRenderTableExProps> = ({ blockChainRenderProps, ...props }) => {
12
+ const {
13
+ blockComponents, errors, paginatedBlockComponents, onPageChange, page, pageSize,
14
+ } = useStaticBlockRenderComponents(BlockChainTableRow, blockChainRenderProps)
15
+
16
+ return (
17
+ <FlexCol alignItems="start" gap={2} width="100%" {...props}>
18
+ {errors?.map(error => <ErrorRender error={error} key={error.name} scope="StaticBlockchainFlexboxInner" />)}
19
+ {paginatedBlockComponents?.length
20
+ ? (
21
+ <FlexGrowRow justifyContent="space-between" width="100%">
22
+ <BlockChainPagination count={blockComponents?.length ?? 0} onPageChange={onPageChange} page={page} rowsPerPage={pageSize} />
23
+ </FlexGrowRow>
24
+ )
25
+ : null}
26
+ <BlockListTableEx blockChainRenderComponents={paginatedBlockComponents} />
27
+ </FlexCol>
28
+ )
29
+ }
@@ -0,0 +1,11 @@
1
+ import React from 'react'
2
+
3
+ import type { BlockChainRenderTableExProps } from '../../../../../../types/index.ts'
4
+ import { Base } from './Base.tsx'
5
+
6
+ export const WithAnalysis: React.FC<BlockChainRenderTableExProps> = ({ blockChainRenderProps, ...props }) => {
7
+ // NOTE: More code here if we want to analyze the static data via ChainAnalyzers
8
+ return (
9
+ <Base blockChainRenderProps={blockChainRenderProps} {...props} />
10
+ )
11
+ }
@@ -0,0 +1,2 @@
1
+ export * from './Base.tsx'
2
+ export * from './WithAnalysis.tsx'
@@ -4,7 +4,7 @@ import {
4
4
  } from '@mui/material'
5
5
  import type { Address } from '@xylabs/hex'
6
6
  import { asAddress } from '@xylabs/hex'
7
- import React, { useEffect, useState } from 'react'
7
+ import React, { useMemo, useState } from 'react'
8
8
 
9
9
  interface XyoAddressTextFieldProps extends Omit<StandardTextFieldProps, 'value'> {
10
10
  onAddressChanged?: (address?: Address) => void
@@ -18,7 +18,7 @@ export const XyoAddressTextField: React.FC<XyoAddressTextFieldProps> = ({
18
18
  const [address, setAddress] = useState<string>('')
19
19
  const [addressError, setAddressError] = useState<Error>()
20
20
 
21
- useEffect(() => setAddress(''), [resetValue])
21
+ useMemo(() => setAddress(''), [resetValue])
22
22
 
23
23
  const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
24
24
  const { value } = event.target
@@ -9,8 +9,7 @@ import {
9
9
  } from '@xylabs/react-flexbox'
10
10
  import type { QuickTipButtonProps } from '@xylabs/react-quick-tip-button'
11
11
  import { QuickTipButton } from '@xylabs/react-quick-tip-button'
12
- import type { ArchivistInstance } from '@xyo-network/archivist-model'
13
- import type { BlockBoundWitness } from '@xyo-network/chain-model'
12
+ import type { HydratedBlock } from '@xyo-network/chain-model'
14
13
  import React, {
15
14
  Fragment, useMemo, useState,
16
15
  } from 'react'
@@ -18,14 +17,11 @@ import React, {
18
17
  import { useTxsFromBlock } from '../block/index.ts'
19
18
 
20
19
  export interface TransactionsQuickTipButtonQuickTipButtonProps extends QuickTipButtonProps {
21
- block?: BlockBoundWitness
22
- chainArchivist?: ArchivistInstance
20
+ block?: HydratedBlock
23
21
  }
24
22
 
25
- export const TransactionsQuickTipButton: React.FC<TransactionsQuickTipButtonQuickTipButtonProps> = ({
26
- block, chainArchivist, ...props
27
- }) => {
28
- const [transactions, transactionsError] = useTxsFromBlock(chainArchivist, block)
23
+ export const TransactionsQuickTipButton: React.FC<TransactionsQuickTipButtonQuickTipButtonProps> = ({ block, ...props }) => {
24
+ const [transactions, transactionsError] = useTxsFromBlock(block)
29
25
 
30
26
  const [copied, setCopied] = useState(false)
31
27
  const [showError, setShowError] = useState(false)
@@ -1,7 +1,4 @@
1
- import type { ReadArchivist } from '@xyo-network/archivist-model'
2
- import type { BlockBoundWitness } from '@xyo-network/chain-model'
3
- import { hydrateBlock } from '@xyo-network/chain-protocol'
4
- import { PayloadBuilder } from '@xyo-network/payload-builder'
1
+ import type { HydratedBlock } from '@xyo-network/chain-model'
5
2
  import type { PropsWithChildren } from 'react'
6
3
  import React, {
7
4
  useCallback, useMemo, useState,
@@ -25,10 +22,8 @@ export const ChainAnalyzersProvider: React.FC<ChainAnalyzersProviderProps> = ({
25
22
  setAnalyzersState(prev => ({ ...prev, ...analyzers }))
26
23
  }, [])
27
24
 
28
- const onBlock = useCallback(async (chainArchivist: ReadArchivist, block: BlockBoundWitness) => {
29
- const hash = await PayloadBuilder.hash(block)
30
- const hydratedBlock = await hydrateBlock(chainArchivist, hash)
31
-
25
+ const onBlock = useCallback(async (hydratedBlock: HydratedBlock) => {
26
+ await Promise.resolve()
32
27
  for (const analyzer of Object.values(analyzers)) {
33
28
  void analyzer.onBlock(hydratedBlock)
34
29
  setStatsUpdated(Date.now())
@@ -1,5 +1,4 @@
1
- import type { ReadArchivist } from '@xyo-network/archivist-model'
2
- import type { BlockBoundWitness, ChainAnalyzer } from '@xyo-network/chain-model'
1
+ import type { ChainAnalyzer, HydratedBlock } from '@xyo-network/chain-model'
3
2
  import type { ContextExState } from '@xyo-network/react-shared'
4
3
 
5
4
  export type ChainAnalyzerIds = 'producers'
@@ -9,6 +8,6 @@ export type ChainAnalyzers = Record<ChainAnalyzerIds, ChainAnalyzer>
9
8
  export interface ChainAnalyzersState extends ContextExState {
10
9
  addAnalyzers: (analyzers: ChainAnalyzers) => void
11
10
  analyzers: ChainAnalyzers
12
- onBlock: (chainArchivist: ReadArchivist, block: BlockBoundWitness) => Promise<void>
11
+ onBlock: (block: HydratedBlock) => Promise<void>
13
12
  statsUpdated: number
14
13
  }
@@ -1,7 +1,5 @@
1
1
  import type { PropsWithChildren } from 'react'
2
- import React, {
3
- useEffect, useMemo, useState,
4
- } from 'react'
2
+ import React, { useMemo, useState } from 'react'
5
3
 
6
4
  import { ChainInfoContext } from './Context.ts'
7
5
  import type { ChainInfoState } from './State.ts'
@@ -26,15 +24,15 @@ export const ChainInfoProvider: React.FC<ChainInfoProviderProps> = ({
26
24
  setChainIterator(chainIterator)
27
25
  }
28
26
 
29
- useEffect(() => {
27
+ useMemo(() => {
30
28
  updateChainArchivist(chainArchivistProp)
31
29
  }, [chainArchivistProp])
32
30
 
33
- useEffect(() => {
31
+ useMemo(() => {
34
32
  updateChainInformation(chainInformationProp)
35
33
  }, [chainInformationProp])
36
34
 
37
- useEffect(() => {
35
+ useMemo(() => {
38
36
  updateChainIterator(chainIteratorProp)
39
37
  }, [chainIteratorProp])
40
38
 
@@ -1,13 +1,16 @@
1
1
  import { assertEx } from '@xylabs/assert'
2
2
  import type {
3
- BlockBoundWitness, EventingChainBlockNumberIterator, HeadEventArgs,
3
+ EventingChainBlockNumberIterator, HeadEventArgs,
4
+ HydratedBlock,
4
5
  XyoChainIteratorParams,
5
6
  } from '@xyo-network/chain-model'
7
+ import { hydrateBlock } from '@xyo-network/chain-protocol'
6
8
  import { XyoChainBlockNumberIterator } from '@xyo-network/chain-services'
9
+ import { PayloadBuilder } from '@xyo-network/payload-builder'
7
10
 
8
11
  export type Listener = (...args: Array<unknown>) => void
9
12
 
10
- export type ChainIteratorStoreValues = { chainIterator: XyoChainBlockNumberIterator; error?: Error; head: BlockBoundWitness }
13
+ export type ChainIteratorStoreValues = { chainIterator: XyoChainBlockNumberIterator; error?: Error; head: HydratedBlock }
11
14
 
12
15
  export class ChainIteratorStore {
13
16
  private _chainIterator: EventingChainBlockNumberIterator | undefined
@@ -31,17 +34,21 @@ export class ChainIteratorStore {
31
34
  // set the chainIterator
32
35
  instance._chainIterator = chainIterator
33
36
 
37
+ const head = await chainIterator.head()
38
+ const hydratedHead = await hydrateBlock(params.chainArchivist, await PayloadBuilder.hash(head))
39
+
34
40
  // set the initial values
35
41
  instance._values = {
36
42
  chainIterator,
37
- head: (await chainIterator.head()),
43
+ head: hydratedHead,
38
44
  }
39
45
 
40
46
  // set the internal listeners
41
- const headUpdatedListener = ({ blocks }: HeadEventArgs) => {
47
+ const headUpdatedListener = async ({ blocks }: HeadEventArgs) => {
48
+ const hydratedBlock = await hydrateBlock(params.chainArchivist, await PayloadBuilder.hash(blocks?.[0]))
42
49
  instance._values = {
43
50
  chainIterator,
44
- head: blocks?.[0],
51
+ head: hydratedBlock,
45
52
  }
46
53
  instance.emitChange()
47
54
  }
@@ -44,7 +44,8 @@ export const useChainIteratorStore = (chainIteratorParams?: XyoChainIteratorPara
44
44
  }
45
45
  // Only update the cached snapshot if there is no cached iterator or the head has changed
46
46
  const noCachedValue = cachedSnapshot.current.chainIterator === undefined
47
- const newBlock = cachedSnapshot.current?.head?.block !== newValues.head?.block
47
+ const cachedBlock = cachedSnapshot.current?.head?.[0]?.block
48
+ const newBlock = cachedBlock !== newValues.head?.[0]?.block
48
49
  if (noCachedValue || newBlock) {
49
50
  cachedSnapshot.current = newValues
50
51
  return newValues
@@ -42,6 +42,7 @@ export const useChainIteratorUpdatingHead = ({
42
42
  }
43
43
 
44
44
  // Schedule the next polling function
45
+ // eslint-disable-next-line @eslint-react/web-api/no-leaked-timeout
45
46
  pollArchivistTimeout = setTimeout(() => void pollingFunction(), interval)
46
47
  }
47
48
 
@@ -1,8 +1,18 @@
1
1
  import { assertEx } from '@xylabs/assert'
2
2
  import { usePromise } from '@xylabs/react-promise'
3
- import type { BlockBoundWitness, XyoChainIteratorParams } from '@xyo-network/chain-model'
3
+ import type { ReadArchivist } from '@xyo-network/archivist-model'
4
+ import type {
5
+ BlockBoundWitness, HydratedBlock, XyoChainIteratorParams,
6
+ } from '@xyo-network/chain-model'
4
7
  import { isBlockBoundWitness } from '@xyo-network/chain-model'
8
+ import { hydrateBlock } from '@xyo-network/chain-protocol'
5
9
  import { XyoChainBlockNumberIterator } from '@xyo-network/chain-services'
10
+ import { PayloadBuilder } from '@xyo-network/payload-builder'
11
+
12
+ const getHydratedBlock = async (chainArchivist: ReadArchivist, head: BlockBoundWitness) => {
13
+ const headHash = await PayloadBuilder.hash(head)
14
+ return await hydrateBlock(chainArchivist, headHash)
15
+ }
6
16
 
7
17
  const iterateChain = async (chainIteratorParams?: XyoChainIteratorParams, maxDepth?: number) => {
8
18
  const { chainArchivist, head } = chainIteratorParams ?? {} as XyoChainIteratorParams
@@ -14,26 +24,29 @@ const iterateChain = async (chainIteratorParams?: XyoChainIteratorParams, maxDep
14
24
  const chainIterator = await XyoChainBlockNumberIterator.create({ head: headBlockBoundWitness, chainArchivist })
15
25
 
16
26
  // get head of the chain
17
- let block = await chainIterator.head()
27
+ const chainHead = await chainIterator.head()
28
+ let block = await getHydratedBlock(chainArchivist, chainHead)
29
+
18
30
  // create the blocks array
19
- const blocks: BlockBoundWitness[] = [block]
31
+ const blocks: HydratedBlock[] = [block]
20
32
 
21
33
  // track the depth
22
34
  let depth = 1
23
35
  // iterate the chain
24
36
  while (block) {
25
37
  // get the next block
26
- const [, next] = await chainIterator.previous(block.block, 2)
38
+ const [, next] = await chainIterator.previous(block[0].block, 2)
27
39
  // if there is no next block, break
28
40
  if (!next) break
41
+ const nextHydratedBlock = await getHydratedBlock(chainArchivist, next)
29
42
  // push the next block
30
- blocks.push(next)
43
+ blocks.push(nextHydratedBlock)
31
44
  // set the next block as the current block
32
- block = next
45
+ block = nextHydratedBlock
33
46
  // increment the depth
34
47
  depth++
35
48
  // if max depth is set and we have reached it, break
36
- if ((maxDepth && depth >= maxDepth) || block?.block === 0) break
49
+ if ((maxDepth && depth >= maxDepth) || block?.[0].block === 0) break
37
50
  }
38
51
  return blocks
39
52
  }
@@ -3,7 +3,7 @@ import type { Decorator } from '@storybook/react'
3
3
  import { usePromise } from '@xylabs/react-promise'
4
4
  import { MemoryArchivist } from '@xyo-network/archivist-memory'
5
5
  import { ArchivistConfigSchema } from '@xyo-network/archivist-model'
6
- import { isBlockBoundWitness } from '@xyo-network/chain-model'
6
+ import { flattenHydratedBlocks } from '@xyo-network/chain-protocol'
7
7
  import React, { useEffect } from 'react'
8
8
 
9
9
  import { getChainInformation } from '../lib/index.ts'
@@ -15,7 +15,8 @@ export const ChainArchivistDecorator: Decorator = (Story, context) => {
15
15
  const [blockChainRenderProps, blockChainRenderPropsError] = usePromise(async () => {
16
16
  if (randomBlockChain) {
17
17
  const chainArchivist = await MemoryArchivist.create({ config: { schema: ArchivistConfigSchema, name: 'ChainArchivist' } })
18
- await chainArchivist.insert(randomBlockChain)
18
+ const flattened = flattenHydratedBlocks(randomBlockChain)
19
+ await chainArchivist.insert(flattened)
19
20
  const chainInformation = await getChainInformation()
20
21
  return { chainArchivist, chainInformation }
21
22
  }
@@ -34,7 +35,7 @@ export const ChainArchivistDecorator: Decorator = (Story, context) => {
34
35
  blockChainRenderProps: {
35
36
  ...(context.args.blockChainRenderProps as BlockChainRenderBaseProps),
36
37
  ...blockChainRenderProps,
37
- head: randomBlockChain?.toReversed().find(isBlockBoundWitness)?._hash,
38
+ head: randomBlockChain?.toReversed()[0][0]._hash,
38
39
  },
39
40
  },
40
41
  }
@@ -5,8 +5,7 @@ import { usePromise } from '@xylabs/react-promise'
5
5
  import { MemoryArchivist } from '@xyo-network/archivist-memory'
6
6
  import { ArchivistConfigSchema } from '@xyo-network/archivist-model'
7
7
  import type { BlockBoundWitness } from '@xyo-network/chain-model'
8
- import { isBlockBoundWitness } from '@xyo-network/chain-model'
9
- import type { Payload } from '@xyo-network/payload-model'
8
+ import { flattenHydratedBlock } from '@xyo-network/chain-protocol'
10
9
  import React, { useEffect, useState } from 'react'
11
10
 
12
11
  import { getChainInformation } from '../lib/index.ts'
@@ -30,32 +29,17 @@ export const ChainArchivistDelayedInsertDecorator: Decorator = (Story, context)
30
29
 
31
30
  const [, delayedInsertError] = usePromise(async () => {
32
31
  if (chainArchivist && randomBlockChain) {
33
- // track the next set of payloads for the next block
34
- const nextBlockPayloads: Payload[] = []
35
-
36
32
  // TODO - use buildRandomChain helper
37
- for (const payload of randomBlockChain) {
38
- if (isBlockBoundWitness(payload)) {
39
- // if we have a block, insert the block and subsequent payloads
40
- nextBlockPayloads.push(payload)
41
-
42
- // debug was we are inserting
43
- // console.log('pre-insert block', nextBlockPayloads.map(payload => isBlockBoundWitness(payload) ? payload.block : null).filter(Boolean))
44
-
45
- // insert the block and subsequent payloads
46
- await chainArchivist.insert(nextBlockPayloads)
47
-
48
- // confirm the first block was inserted and set state so the story can load
49
- setFirstBlock(prev => prev || payload)
33
+ for (const hydratedBlock of randomBlockChain) {
34
+ const flattened = flattenHydratedBlock(hydratedBlock)
35
+ // insert the block and subsequent payloads
36
+ await chainArchivist.insert(flattened)
50
37
 
51
- // clear the array
52
- nextBlockPayloads.length = 0
38
+ // confirm the first block was inserted and set state so the story can load
39
+ setFirstBlock(prev => prev || hydratedBlock[0])
53
40
 
54
- // we know we are gonna get a new block, so simulate the delay
55
- await delay(1000)
56
- } else {
57
- nextBlockPayloads.push(payload)
58
- }
41
+ // we know we are gonna get a new block, so simulate the delay
42
+ await delay(1000)
59
43
  }
60
44
  }
61
45
  }, [chainArchivist, randomBlockChain])
@@ -78,7 +62,7 @@ export const ChainArchivistDelayedInsertDecorator: Decorator = (Story, context)
78
62
  blockChainRenderProps: {
79
63
  ...(context.args.blockChainRenderProps as BlockChainRenderBaseProps),
80
64
  ...blockChainRenderProps,
81
- head: randomBlockChain?.find(isBlockBoundWitness)?._hash,
65
+ head: randomBlockChain?.[0][0]?._hash,
82
66
  },
83
67
  },
84
68
  }
@@ -1,7 +1,6 @@
1
1
  import { Account } from '@xyo-network/account'
2
2
  import { buildRandomChain } from '@xyo-network/chain-ethereum'
3
3
  import type { HydratedBlock } from '@xyo-network/chain-model'
4
- import { flattenHydratedBlocks } from '@xyo-network/chain-protocol'
5
4
 
6
5
  export const buildRandomBlockChain = async (blockCount = 10) => {
7
6
  // Create a producer
@@ -9,11 +8,10 @@ export const buildRandomBlockChain = async (blockCount = 10) => {
9
8
 
10
9
  // Create multiple blocks
11
10
  const blocks: HydratedBlock[] = await buildRandomChain(initialBlockProducer, blockCount)
12
- return flattenHydratedBlocks(blocks)
11
+ return blocks
13
12
  }
14
13
 
15
14
  export const buildRandomBlockChainBlocksOnly = async (blockCount = 10) => {
16
15
  const chain = await buildRandomChain(await Account.random(), blockCount)
17
- const blocks = chain.map(block => block[0])
18
- return blocks
16
+ return chain
19
17
  }
@@ -1,9 +1,9 @@
1
1
  import type { Hash } from '@xylabs/hex'
2
- import type { BlockBoundWitness } from '@xyo-network/chain-model'
2
+ import type { HydratedBlock } from '@xyo-network/chain-model'
3
3
 
4
4
  /** Interface for all components that render a single block */
5
5
  export interface BlockComponentProps {
6
- block: BlockBoundWitness
6
+ block: HydratedBlock
7
7
  defaultExpanded?: boolean
8
8
  }
9
9
 
@@ -1,7 +1,7 @@
1
1
  import type { NodesWithKeys } from '@xylabs/react-animation'
2
- import type { BlockBoundWitness } from '@xyo-network/chain-model'
2
+ import type { HydratedBlock } from '@xyo-network/chain-model'
3
3
 
4
4
  /** Interface for all block components meant to be rendered in a chain */
5
5
  export interface BlockChainRenderComponent extends NodesWithKeys {
6
- block: BlockBoundWitness
6
+ block: HydratedBlock
7
7
  }