@xyo-network/react-chain-blockchain 1.0.10 → 1.0.12

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 (129) hide show
  1. package/dist/browser/index.mjs +245 -225
  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/hooks/chain-iterator/ChainIteratorStore.d.ts +2 -2
  67. package/dist/types/hooks/chain-iterator/ChainIteratorStore.d.ts.map +1 -1
  68. package/dist/types/hooks/chain-iterator/useChainIteratorStore.d.ts.map +1 -1
  69. package/dist/types/hooks/chain-iterator/useChainIteratorUpdatingHead.d.ts.map +1 -1
  70. package/dist/types/hooks/useIterateChain.d.ts +2 -2
  71. package/dist/types/hooks/useIterateChain.d.ts.map +1 -1
  72. package/dist/types/stories/ChainArchivistDecorator.d.ts.map +1 -1
  73. package/dist/types/stories/ChainArchivistDelayedInsertDecorator.d.ts.map +1 -1
  74. package/dist/types/stories/buildRandomBlockchain.d.ts +3 -2
  75. package/dist/types/stories/buildRandomBlockchain.d.ts.map +1 -1
  76. package/dist/types/types/BlockComponentProps.d.ts +2 -2
  77. package/dist/types/types/BlockComponentProps.d.ts.map +1 -1
  78. package/dist/types/types/BlockComponents.d.ts +2 -2
  79. package/dist/types/types/BlockComponents.d.ts.map +1 -1
  80. package/package.json +13 -13
  81. package/src/components/block/BlockHeadingFlexbox.stories.tsx +2 -2
  82. package/src/components/block/BlockHeadingFlexbox.tsx +3 -3
  83. package/src/components/block/ProducerChip.tsx +3 -9
  84. package/src/components/block/helpers/buildBlockChainRenderComponent.tsx +3 -6
  85. package/src/components/block/helpers/tsxFromBlock.ts +4 -6
  86. package/src/components/block/hooks/useBlockProducer.ts +3 -3
  87. package/src/components/block/hooks/useDynamicBlockComponents.ts +6 -7
  88. package/src/components/block/hooks/useStaticBlockComponents.ts +4 -4
  89. package/src/components/block/hooks/useTxsFromBlock.ts +5 -6
  90. package/src/components/block/menu/Expanded.tsx +4 -4
  91. package/src/components/block/table/Ex.stories.tsx +4 -8
  92. package/src/components/block/table/Ex.tsx +5 -14
  93. package/src/components/block/table/cell/BlockNumber.tsx +3 -3
  94. package/src/components/block/table/cell/Hash.tsx +1 -1
  95. package/src/components/block/table/cell/JsonView.tsx +1 -1
  96. package/src/components/block/table/cell/TransactionCount.tsx +3 -6
  97. package/src/components/block/table/cell/Verification.tsx +2 -2
  98. package/src/components/block/table/cell/lib/BlockTableCellProps.ts +2 -2
  99. package/src/components/block/table/head/TableHead.tsx +19 -0
  100. package/src/components/block/table/head/index.ts +1 -0
  101. package/src/components/block/table/index.ts +1 -0
  102. package/src/components/chain/hooks/useOnBlock.ts +11 -7
  103. package/src/components/chain/render/dynamic/flexbox/Flexbox.tsx +4 -62
  104. package/src/components/chain/render/dynamic/flexbox/variants/Base.tsx +27 -0
  105. package/src/components/chain/render/dynamic/flexbox/variants/WithAnalysis.tsx +25 -0
  106. package/src/components/chain/render/dynamic/flexbox/variants/WithRemote.tsx +19 -0
  107. package/src/components/chain/render/dynamic/flexbox/variants/index.ts +3 -0
  108. package/src/components/chain/render/dynamic/hooks/useDynamicBlockRenderComponents.ts +1 -1
  109. package/src/components/chain/render/static/flexbox/Flexbox.tsx +2 -54
  110. package/src/components/chain/render/static/flexbox/variants/Base.tsx +31 -0
  111. package/src/components/chain/render/static/flexbox/variants/WithAnalysis.tsx +23 -0
  112. package/src/components/chain/render/static/flexbox/variants/index.ts +2 -0
  113. package/src/components/chain/render/static/table/Ex.tsx +2 -36
  114. package/src/components/chain/render/static/table/variants/Base.tsx +29 -0
  115. package/src/components/chain/render/static/table/variants/WithAnalysis.tsx +11 -0
  116. package/src/components/chain/render/static/table/variants/index.ts +2 -0
  117. package/src/components/payload/fields/XyoAddressTextField.tsx +2 -2
  118. package/src/components/transactions/TransactionsQuickTipButton.tsx +4 -8
  119. package/src/context/analyzer/Provider.tsx +3 -8
  120. package/src/context/analyzer/state.ts +2 -3
  121. package/src/hooks/chain-iterator/ChainIteratorStore.ts +12 -5
  122. package/src/hooks/chain-iterator/useChainIteratorStore.ts +2 -1
  123. package/src/hooks/chain-iterator/useChainIteratorUpdatingHead.ts +1 -0
  124. package/src/hooks/useIterateChain.ts +20 -7
  125. package/src/stories/ChainArchivistDecorator.tsx +4 -3
  126. package/src/stories/ChainArchivistDelayedInsertDecorator.tsx +10 -26
  127. package/src/stories/buildRandomBlockchain.ts +2 -4
  128. package/src/types/BlockComponentProps.ts +2 -2
  129. package/src/types/BlockComponents.ts +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"BlockComponents.d.ts","sourceRoot":"","sources":["../../../src/types/BlockComponents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAEjE,yEAAyE;AACzE,MAAM,WAAW,yBAA0B,SAAQ,aAAa;IAC9D,KAAK,EAAE,iBAAiB,CAAA;CACzB"}
1
+ {"version":3,"file":"BlockComponents.d.ts","sourceRoot":"","sources":["../../../src/types/BlockComponents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAE7D,yEAAyE;AACzE,MAAM,WAAW,yBAA0B,SAAQ,aAAa;IAC9D,KAAK,EAAE,aAAa,CAAA;CACrB"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "http://json.schemastore.org/package.json",
3
3
  "name": "@xyo-network/react-chain-blockchain",
4
- "version": "1.0.10",
4
+ "version": "1.0.12",
5
5
  "description": "XYO Layer One React SDK Blockchain",
6
6
  "homepage": "https://xylabs.com",
7
7
  "bugs": {
@@ -51,15 +51,15 @@
51
51
  "@xyo-network/archivist-model": "^3.10.4",
52
52
  "@xyo-network/boundwitness-builder": "^3.10.4",
53
53
  "@xyo-network/bridge-http": "^3.10.4",
54
- "@xyo-network/chain-ethereum": "^1.0.10",
55
- "@xyo-network/chain-model": "^1.0.10",
56
- "@xyo-network/chain-protocol": "^1.0.10",
57
- "@xyo-network/chain-services": "^1.0.10",
54
+ "@xyo-network/chain-ethereum": "^1.0.12",
55
+ "@xyo-network/chain-model": "^1.0.12",
56
+ "@xyo-network/chain-protocol": "^1.0.12",
57
+ "@xyo-network/chain-services": "^1.0.12",
58
58
  "@xyo-network/module-model": "^3.10.4",
59
59
  "@xyo-network/payload-builder": "^3.10.4",
60
60
  "@xyo-network/payload-model": "^3.10.4",
61
- "@xyo-network/react-chain-blockies": "^1.0.10",
62
- "@xyo-network/react-chain-boundwitness": "^1.0.10",
61
+ "@xyo-network/react-chain-blockies": "^1.0.12",
62
+ "@xyo-network/react-chain-boundwitness": "^1.0.12",
63
63
  "@xyo-network/react-event": "^5.0.7",
64
64
  "@xyo-network/react-payload-raw-info": "^5.0.7",
65
65
  "@xyo-network/react-payload-table": "^5.0.7",
@@ -72,19 +72,19 @@
72
72
  "@mui/icons-material": "^6.4.8",
73
73
  "@mui/material": "^6.4.8",
74
74
  "@mui/styles": "^6.4.8",
75
- "@storybook/react": "^8.6.7",
75
+ "@storybook/react": "^8.6.9",
76
76
  "@types/react": "^19.0.12",
77
77
  "@xylabs/delay": "^4.7.11",
78
78
  "@xylabs/hex": "^4.7.11",
79
- "@xylabs/ts-scripts-yarn3": "^6.1.4",
80
- "@xylabs/tsconfig-react": "^6.1.4",
79
+ "@xylabs/ts-scripts-yarn3": "^6.1.5",
80
+ "@xylabs/tsconfig-react": "^6.1.5",
81
81
  "@xyo-network/archivist-memory": "^3.10.4",
82
- "@xyo-network/chain-utils": "^1.0.10",
83
- "eslint": "^9.22.0",
82
+ "@xyo-network/chain-utils": "^1.0.12",
83
+ "eslint": "^9.23.0",
84
84
  "react": "^19.0.0",
85
85
  "react-dom": "^19.0.0",
86
86
  "react-router-dom": "^7.4.0",
87
- "storybook": "^8.6.7",
87
+ "storybook": "^8.6.9",
88
88
  "typescript": "^5.8.2"
89
89
  },
90
90
  "peerDependencies": {
@@ -37,8 +37,8 @@ const TemplateWithEvents: StoryFn<typeof BlockHeadingFlexbox> = (args) => {
37
37
  <div ref={ref}>
38
38
  <BlockHeadingFlexbox {...args} />
39
39
  <Stack gap={2} flexDirection="column">
40
- {eventData.length > 0 && eventData.map((event, index) => (
41
- <Alert key={index} sx={{ display: 'flex' }}>
40
+ {eventData.length > 0 && eventData.map(event => (
41
+ <Alert key={event.data} sx={{ display: 'flex' }}>
42
42
  <AlertTitle>Event Data</AlertTitle>
43
43
  <List>
44
44
  <ListItem>
@@ -15,7 +15,7 @@ import { BlockProducerChip } from './ProducerChip.tsx'
15
15
  export const BlockHeadingFlexbox: React.FC<BlockComponentWithTxsProps> = ({
16
16
  block, defaultExpanded, transactions,
17
17
  }) => {
18
- const hash = usePayloadHash(block)
18
+ const hash = usePayloadHash(block?.[0])
19
19
  const [blockHeadingRef, blockHeadingListener] = useBlockHeadingEvents<HTMLDivElement>()
20
20
  const { pollingState } = useChainPollingContext()
21
21
  const expanded = (pollingState === 'paused') || defaultExpanded
@@ -30,7 +30,7 @@ export const BlockHeadingFlexbox: React.FC<BlockComponentWithTxsProps> = ({
30
30
  <LinkedDivider />
31
31
  <HashHeadingPaper
32
32
  hash={hash}
33
- heading={block?.block === undefined ? '' : block.block.toString()}
33
+ heading={block?.[0].block === undefined ? '' : block?.[0].block.toString()}
34
34
  paperProps={{ sx: { p: 1, width: '100%' } }}
35
35
  AdornmentEnd={(
36
36
  <FlexRow gap={1}>
@@ -39,7 +39,7 @@ export const BlockHeadingFlexbox: React.FC<BlockComponentWithTxsProps> = ({
39
39
  onClick={e => handleTransactionCountClick(e, transactions ?? [])}
40
40
  transactions={transactions}
41
41
  />
42
- <BWVerification iconColors boundwitness={block} />
42
+ <BWVerification iconColors boundwitness={block?.[0]} />
43
43
  <span style={{
44
44
  // maxWidth is required for css animation to work and 28px is the width of the icon button
45
45
  display: 'flex', transition: 'max-width .5s', maxWidth: expanded ? '28px' : 0,
@@ -1,21 +1,15 @@
1
1
  import type { ChipProps } from '@mui/material'
2
2
  import { Chip } from '@mui/material'
3
3
  import { EthAddress } from '@xylabs/eth-address'
4
- import type { BlockBoundWitness } from '@xyo-network/chain-model'
4
+ import type { HydratedBlock } from '@xyo-network/chain-model'
5
5
  import { BlockiesAvatar } from '@xyo-network/react-chain-blockies'
6
6
  import React, { useMemo } from 'react'
7
7
 
8
8
  export interface BlockProducerChipProps extends ChipProps {
9
- block?: BlockBoundWitness
9
+ block?: HydratedBlock
10
10
  }
11
11
  export const BlockProducerChip: React.FC<BlockProducerChipProps> = ({ block, ...props }) => {
12
- const sharedAddress = block?.addresses[0]
13
- const blockProducer = useMemo(() => {
14
- if (block) {
15
- const producer = block.addresses.find(address => address !== sharedAddress)
16
- return producer
17
- }
18
- }, [block])
12
+ const blockProducer = block?.[0].addresses[0]
19
13
 
20
14
  const shortedBlockProducer = blockProducer ? EthAddress.parse(blockProducer)?.toShortString(3) : null
21
15
 
@@ -1,4 +1,3 @@
1
- import type { ArchivistInstance } from '@xyo-network/archivist-model'
2
1
  import type { ComponentType } from 'react'
3
2
  import React from 'react'
4
3
 
@@ -12,10 +11,9 @@ import { txsFromBlock } from './tsxFromBlock.ts'
12
11
  export const buildBlockChainRenderComponent = async (
13
12
  BlockComponent: ComponentType<BlockComponentWithTxsProps>,
14
13
  blockComponentProps: BlockComponentProps,
15
- chainArchivist: ArchivistInstance,
16
14
  ) => {
17
15
  const { block, ...remainingProps } = blockComponentProps
18
- const blockTxs = await txsFromBlock(chainArchivist, block)
16
+ const blockTxs = await txsFromBlock(block)
19
17
  const txHashes = blockTxs.map(([_, hash]) => hash)
20
18
 
21
19
  const item: BlockChainRenderComponent = {
@@ -26,7 +24,7 @@ export const buildBlockChainRenderComponent = async (
26
24
  {...remainingProps}
27
25
  />
28
26
  ),
29
- key: block.block.toString(),
27
+ key: block[0].block.toString(),
30
28
  block,
31
29
  }
32
30
  return item
@@ -34,7 +32,6 @@ export const buildBlockChainRenderComponent = async (
34
32
 
35
33
  export const buildBlockHeadingComponent = async (
36
34
  blockComponentProps: BlockComponentProps,
37
- chainArchivist: ArchivistInstance,
38
35
  ) => {
39
- return await buildBlockChainRenderComponent(BlockHeadingFlexbox, blockComponentProps, chainArchivist)
36
+ return await buildBlockChainRenderComponent(BlockHeadingFlexbox, blockComponentProps)
40
37
  }
@@ -1,10 +1,8 @@
1
- import type { ReadArchivist } from '@xyo-network/archivist-model'
2
- import type { BlockBoundWitness } from '@xyo-network/chain-model'
3
- import { isTransactionBoundWitness } from '@xyo-network/chain-model'
1
+ import { isBoundWitness } from '@xyo-network/boundwitness-model'
2
+ import type { HydratedBlock } from '@xyo-network/chain-model'
4
3
  import { PayloadBuilder } from '@xyo-network/payload-builder'
5
4
 
6
- export const txsFromBlock = async (chainArchivist: ReadArchivist, block: BlockBoundWitness) => {
7
- const payloads = await chainArchivist.get(block.payload_hashes)
8
- const transactionPayloads = payloads.filter(payload => isTransactionBoundWitness(payload))
5
+ export const txsFromBlock = async (block: HydratedBlock) => {
6
+ const transactionPayloads = block[1].filter(payload => isBoundWitness(payload))
9
7
  return await PayloadBuilder.hashPairs(transactionPayloads)
10
8
  }
@@ -1,10 +1,10 @@
1
- import type { BlockBoundWitness } from '@xyo-network/chain-model'
1
+ import type { HydratedBlock } from '@xyo-network/chain-model'
2
2
  import { useMemo } from 'react'
3
3
 
4
- export const useBlockProducer = (block?: BlockBoundWitness) => {
4
+ export const useBlockProducer = (block?: HydratedBlock) => {
5
5
  return useMemo(() => {
6
6
  if (block) {
7
- const producer = block.addresses[0]
7
+ const producer = block[0].addresses[0]
8
8
  return producer
9
9
  }
10
10
  }, [block])
@@ -1,5 +1,4 @@
1
- import type { BlockBoundWitness, XyoChainIteratorParams } from '@xyo-network/chain-model'
2
- import { isBlockBoundWitness } from '@xyo-network/chain-model'
1
+ import type { HydratedBlock, XyoChainIteratorParams } from '@xyo-network/chain-model'
3
2
  import type { ComponentType } from 'react'
4
3
  import { useState } from 'react'
5
4
 
@@ -16,14 +15,14 @@ export const useDynamicBlockComponents = (BlockComponent: ComponentType<BlockCom
16
15
 
17
16
  const { onBlock } = useChainAnalyzersContext()
18
17
 
19
- const onAddBlock = async (block: BlockBoundWitness) => {
20
- if (!isBlockBoundWitness(block) || !chainArchivist) return
18
+ const onAddBlock = async (block: HydratedBlock) => {
19
+ if (!block || !chainArchivist) return
21
20
 
22
21
  const blockComponentProps: BlockComponentProps = { block }
23
- const newBlockComponent = await buildBlockChainRenderComponent(BlockComponent, blockComponentProps, chainArchivist)
22
+ const newBlockComponent = await buildBlockChainRenderComponent(BlockComponent, blockComponentProps)
24
23
 
25
- if (block.block !== blockChainRenderComponents[0]?.block.block) {
26
- void onBlock?.(chainArchivist, block)
24
+ if (block?.[0].block !== blockChainRenderComponents[0]?.block?.[0].block) {
25
+ void onBlock?.(block)
27
26
 
28
27
  setBlockChainRenderComponents((blockComponents) => {
29
28
  const newBlockComponents = [newBlockComponent, ...blockComponents]
@@ -1,5 +1,5 @@
1
1
  import { usePromise } from '@xylabs/react-promise'
2
- import type { BlockBoundWitness, XyoChainIteratorParams } from '@xyo-network/chain-model'
2
+ import type { HydratedBlock, XyoChainIteratorParams } from '@xyo-network/chain-model'
3
3
  import type { ComponentType } from 'react'
4
4
 
5
5
  import { useChainAnalyzersContext } from '../../../context/index.ts'
@@ -9,7 +9,7 @@ import { buildBlockChainRenderComponent } from '../helpers/index.ts'
9
9
  export const useStaticBlockComponents = (
10
10
  BlockComponent: ComponentType<BlockComponentWithTxsProps>,
11
11
  params?: XyoChainIteratorParams,
12
- blocks?: BlockBoundWitness[],
12
+ blocks?: HydratedBlock[],
13
13
  ) => {
14
14
  const { onBlock } = useChainAnalyzersContext()
15
15
 
@@ -21,11 +21,11 @@ export const useStaticBlockComponents = (
21
21
 
22
22
  return await Promise.all(resolvedBlockWithStorage?.map(async (block) => {
23
23
  if (onBlock && chainArchivist) {
24
- await onBlock(chainArchivist, block)
24
+ await onBlock(block)
25
25
  }
26
26
 
27
27
  const blockComponentProps: BlockComponentProps = { block, defaultExpanded: true }
28
- return await buildBlockChainRenderComponent(BlockComponent, blockComponentProps, chainArchivist)
28
+ return await buildBlockChainRenderComponent(BlockComponent, blockComponentProps)
29
29
  }))
30
30
  }, [blocks, params, BlockComponent])
31
31
 
@@ -1,13 +1,12 @@
1
1
  import { usePromise } from '@xylabs/react-promise'
2
- import type { ReadArchivist } from '@xyo-network/archivist-model'
3
- import type { BlockBoundWitness } from '@xyo-network/chain-model'
2
+ import type { HydratedBlock } from '@xyo-network/chain-model'
4
3
 
5
4
  import { txsFromBlock } from '../helpers/index.ts'
6
5
 
7
- export const useTxsFromBlock = (chainArchivist?: ReadArchivist, block?: BlockBoundWitness) => {
6
+ export const useTxsFromBlock = (block?: HydratedBlock) => {
8
7
  return usePromise(async () => {
9
- if (block && chainArchivist) {
10
- return await txsFromBlock(chainArchivist, block)
8
+ if (block) {
9
+ return await txsFromBlock(block)
11
10
  }
12
- }, [block, chainArchivist])
11
+ }, [block])
13
12
  }
@@ -1,13 +1,13 @@
1
1
  import { MoreVert } from '@mui/icons-material'
2
2
  import { IconButton, Menu } from '@mui/material'
3
- import type { BlockBoundWitness } from '@xyo-network/chain-model'
3
+ import type { HydratedBlock } from '@xyo-network/chain-model'
4
4
  import { BWJsonMenuItem, BWPreviousHashMenuItem } from '@xyo-network/react-chain-boundwitness'
5
5
  import React from 'react'
6
6
 
7
7
  import { useAnchorElement } from '../hooks/index.ts'
8
8
 
9
9
  export interface BlockExpandedMenuProps {
10
- block?: BlockBoundWitness
10
+ block?: HydratedBlock
11
11
  }
12
12
 
13
13
  export const BlockMenuExpanded: React.FC<BlockExpandedMenuProps> = ({ block }) => {
@@ -26,8 +26,8 @@ export const BlockMenuExpanded: React.FC<BlockExpandedMenuProps> = ({ block }) =
26
26
  anchorOrigin={{ horizontal: 'left', vertical: 'bottom' }}
27
27
  onClose={handleClose}
28
28
  >
29
- <BWPreviousHashMenuItem boundwitness={block} dense onDialogClose={handleClose} />
30
- <BWJsonMenuItem boundwitness={block} dense onDialogClose={handleClose} />
29
+ <BWPreviousHashMenuItem boundwitness={block?.[0]} dense onDialogClose={handleClose} />
30
+ <BWJsonMenuItem boundwitness={block?.[0]} dense onDialogClose={handleClose} />
31
31
  </Menu>
32
32
  </>
33
33
  )
@@ -2,8 +2,6 @@ import {
2
2
  Alert, AlertTitle, Snackbar,
3
3
  } from '@mui/material'
4
4
  import type { Meta, StoryFn } from '@storybook/react'
5
- import type { BlockBoundWitness } from '@xyo-network/chain-model'
6
- import { isBlockBoundWitness } from '@xyo-network/chain-model'
7
5
  import type { Event } from '@xyo-network/react-event'
8
6
  import { useEvent } from '@xyo-network/react-event'
9
7
  import React, { useState } from 'react'
@@ -48,17 +46,15 @@ Default.args = {}
48
46
 
49
47
  const WithData = Template.bind({})
50
48
  WithData.args = {
51
- children: blocks?.filter(isBlockBoundWitness).map((block) => {
52
- const blockBoundWitness = block as unknown as BlockBoundWitness
53
- return <BlockChainTableRow key={blockBoundWitness.block} block={blockBoundWitness} />
49
+ children: blocks.map((block) => {
50
+ return <BlockChainTableRow key={block[0].block} block={block} />
54
51
  }),
55
52
  }
56
53
 
57
54
  const WithLinked = TemplateLinked.bind({})
58
55
  WithLinked.args = {
59
- children: blocks?.filter(isBlockBoundWitness).map((block) => {
60
- const blockBoundWitness = block as unknown as BlockBoundWitness
61
- return <BlockChainTableRow key={blockBoundWitness.block} block={blockBoundWitness} linked />
56
+ children: blocks.map((block) => {
57
+ return <BlockChainTableRow key={block[0].block} block={block} linked />
62
58
  }),
63
59
  }
64
60
 
@@ -1,25 +1,16 @@
1
- import {
2
- TableBody, TableCell, TableHead, TableRow,
3
- } from '@mui/material'
1
+ import { TableBody } from '@mui/material'
4
2
  import type { TableExProps } from '@xyo-network/react-table'
5
3
  import { TableEx } from '@xyo-network/react-table'
6
4
  import React from 'react'
7
5
 
6
+ import { BlockchainTableHead } from './head/index.ts'
7
+
8
8
  export const BlockchainTableEx = ({
9
9
  ref, children, ...props
10
- }: TableExProps & { ref?: React.Ref<HTMLTableElement | null> }) => {
10
+ }: TableExProps) => {
11
11
  return (
12
12
  <TableEx ref={ref} {...props}>
13
- <TableHead>
14
- <TableRow>
15
- <TableCell>Block Hash</TableCell>
16
- <TableCell>Block Number</TableCell>
17
- <TableCell>Transaction Count</TableCell>
18
- <TableCell align="center">Block Producer</TableCell>
19
- <TableCell align="center">Valid</TableCell>
20
- <TableCell align="center">JSON</TableCell>
21
- </TableRow>
22
- </TableHead>
13
+ <BlockchainTableHead />
23
14
  <TableBody>
24
15
  {children}
25
16
  </TableBody>
@@ -11,9 +11,9 @@ export interface BlockNumberTableCellProps extends BlockTableCellProps {}
11
11
  export const BlockNumberTableCell: React.FC<BlockNumberTableCellProps> = ({
12
12
  block, linked, ...props
13
13
  }) => {
14
- const [ref, handleClick] = useLinkedBlockItem('block-number', block?.block.toString())
14
+ const [ref, handleClick] = useLinkedBlockItem('block-number', block?.[0].block.toString())
15
15
 
16
- const blockNumberBigInt = block ? block.block.toString() : ''
16
+ const blockNumberBigInt = block ? block[0].block.toString() : ''
17
17
 
18
18
  return (
19
19
  <TableCell ref={ref} {...props}>
@@ -21,7 +21,7 @@ export const BlockNumberTableCell: React.FC<BlockNumberTableCellProps> = ({
21
21
  <span>
22
22
  {linked && block
23
23
  ? (
24
- <Link title={block.block.toString()} onClick={handleClick} sx={{ cursor: 'pointer' }}>{block.block.toString()}</Link>
24
+ <Link title={block[0].block.toString()} onClick={handleClick} sx={{ cursor: 'pointer' }}>{block[0].block.toString()}</Link>
25
25
  )
26
26
  : null}
27
27
  {!linked && blockNumberBigInt}
@@ -18,7 +18,7 @@ export interface BlockHashTableCellProps extends BlockTableCellProps {
18
18
  export const BlockHashTableCell: React.FC<BlockHashTableCellProps> = ({
19
19
  block, identiconProps, linked, ...props
20
20
  }) => {
21
- const hash = usePayloadHash(block)
21
+ const hash = usePayloadHash(block?.[0])
22
22
 
23
23
  const [ref, handleClick] = useLinkedBlockItem('block-hash', hash)
24
24
 
@@ -17,7 +17,7 @@ export const BlockJsonViewTableCell: React.FC<BlockJsonViewTableCellProps> = ({
17
17
  const [open, setOpen] = useState(false)
18
18
  const onClose = () => setOpen(false)
19
19
 
20
- const hash = usePayloadHash(block)
20
+ const hash = usePayloadHash(block?.[0])
21
21
  const title = hash ? `JSON for ${ellipsize(hash, 5)}` : 'JSON'
22
22
 
23
23
  return (
@@ -2,21 +2,18 @@ import { Error } from '@mui/icons-material'
2
2
  import {
3
3
  Link, TableCell, Tooltip,
4
4
  } from '@mui/material'
5
- import type { ReadArchivist } from '@xyo-network/archivist-model'
6
5
  import React from 'react'
7
6
 
8
7
  import { useTxsFromBlock } from '../../hooks/index.ts'
9
8
  import { useLinkedBlockItem } from './hooks/index.ts'
10
9
  import type { BlockTableCellProps } from './lib/index.ts'
11
10
 
12
- export interface BlockTransactionCountTableCellProps extends BlockTableCellProps {
13
- chainArchivist?: ReadArchivist
14
- }
11
+ export interface BlockTransactionCountTableCellProps extends BlockTableCellProps {}
15
12
 
16
13
  export const BlockTransactionCountTableCell: React.FC<BlockTransactionCountTableCellProps> = ({
17
- block, chainArchivist, linked, ...props
14
+ block, linked, ...props
18
15
  }) => {
19
- const [txs, error] = useTxsFromBlock(chainArchivist, block)
16
+ const [txs, error] = useTxsFromBlock(block)
20
17
  const [ref, handleClick] = useLinkedBlockItem('transaction-count', JSON.stringify(txs ?? null))
21
18
 
22
19
  return (
@@ -11,12 +11,12 @@ export interface BlockVerificationTableCellProps extends BlockTableCellProps {}
11
11
  export const BlockVerificationTableCell: React.FC<BlockVerificationTableCellProps> = ({
12
12
  block, linked, ...props
13
13
  }) => {
14
- const [ref, handleClick] = useLinkedBlockItem('block-verification', block?.block.toString())
14
+ const [ref, handleClick] = useLinkedBlockItem('block-verification', block?.[0].block.toString())
15
15
 
16
16
  return (
17
17
  <TableCell ref={ref} {...props}>
18
18
  <FlexRow sx={{ width: '100%' }}>
19
- <BWVerification onClick={linked ? handleClick : undefined} iconColors boundwitness={block} />
19
+ <BWVerification onClick={linked ? handleClick : undefined} iconColors boundwitness={block?.[0]} />
20
20
  </FlexRow>
21
21
  </TableCell>
22
22
  )
@@ -1,7 +1,7 @@
1
1
  import type { TableCellProps } from '@mui/material'
2
- import type { BlockBoundWitness } from '@xyo-network/chain-model'
2
+ import type { HydratedBlock } from '@xyo-network/chain-model'
3
3
 
4
4
  export interface BlockTableCellProps extends TableCellProps {
5
- block?: BlockBoundWitness
5
+ block?: HydratedBlock
6
6
  linked?: boolean
7
7
  }
@@ -0,0 +1,19 @@
1
+ import {
2
+ TableCell, TableHead, TableRow,
3
+ } from '@mui/material'
4
+ import React from 'react'
5
+
6
+ export const BlockchainTableHead: React.FC = () => {
7
+ return (
8
+ <TableHead>
9
+ <TableRow>
10
+ <TableCell>Block Hash</TableCell>
11
+ <TableCell>Block Number</TableCell>
12
+ <TableCell>Transaction Count</TableCell>
13
+ <TableCell align="center">Block Producer</TableCell>
14
+ <TableCell align="center">Valid</TableCell>
15
+ <TableCell align="center">JSON</TableCell>
16
+ </TableRow>
17
+ </TableHead>
18
+ )
19
+ }
@@ -0,0 +1 @@
1
+ export * from './TableHead.tsx'
@@ -1,3 +1,4 @@
1
1
  export * from './cell/index.ts'
2
2
  export * from './Ex.tsx'
3
+ export * from './head/index.ts'
3
4
  export * from './row/index.ts'
@@ -1,12 +1,12 @@
1
- import type { BlockBoundWitness } from '@xyo-network/chain-model'
1
+ import type { HydratedBlock } from '@xyo-network/chain-model'
2
2
  import { useEffect, useRef } from 'react'
3
3
 
4
4
  export type PollingState = 'paused' | 'running'
5
5
 
6
6
  export const useOnBlock = (
7
7
  initialHeadNumber?: number,
8
- onAddBlock?: (block: BlockBoundWitness) => Promise<void>,
9
- liveHead?: BlockBoundWitness,
8
+ onAddBlock?: (block: HydratedBlock) => Promise<void>,
9
+ liveHead?: HydratedBlock,
10
10
  pollingState?: PollingState,
11
11
  ) => {
12
12
  /**
@@ -14,22 +14,26 @@ export const useOnBlock = (
14
14
  * But, since we get new blockComponents regardless, the hook rerenders anyway so consumers can get
15
15
  * the latest blocksWhilePaused value without having to rely on a state update.
16
16
  */
17
- const blocksWhilePaused = useRef<BlockBoundWitness[]>([])
17
+ const blocksWhilePaused = useRef<HydratedBlock[]>([])
18
18
  // Because the useEffect has liveHead AND pollingState, every time the polling state changes, the hook will
19
19
  // run a second time with the live head from the previous run. This is why we need to keep track of the last
20
20
  // live head so we can compare it to the current live head and prevent the hook from adding the same block twice
21
- const lastLiveHead = useRef<BlockBoundWitness | undefined>(liveHead)
21
+ const lastLiveHead = useRef<HydratedBlock | undefined>(liveHead)
22
22
 
23
23
  useEffect(() => {
24
+ const lastLiveHeadBlock = lastLiveHead.current?.[0]
25
+ const blocksWhilePausedBlock = lastLiveHead.current?.[0]
26
+ const liveHeadBlock = liveHead?.[0]
27
+
24
28
  // use lastLiveHead to prevent the hook from adding the same block multiple times
25
- if (lastLiveHead.current?.block === liveHead?.block) return
29
+ if (lastLiveHeadBlock?.block === liveHeadBlock?.block) return
26
30
 
27
31
  if (liveHead && onAddBlock) {
28
32
  // update lastLiveHead
29
33
  lastLiveHead.current = liveHead
30
34
 
31
35
  // if the polling state is paused and the block is new, add it to the blocksWhilePaused array
32
- const isNewBlock = initialHeadNumber !== liveHead.block && liveHead.block !== blocksWhilePaused.current[0]?.block
36
+ const isNewBlock = initialHeadNumber !== liveHeadBlock?.block && liveHeadBlock?.block !== blocksWhilePausedBlock?.block
33
37
  if (pollingState === 'paused' && isNewBlock) {
34
38
  blocksWhilePaused.current.push(liveHead)
35
39
  } else if (pollingState === 'running') {
@@ -1,65 +1,7 @@
1
- import { ErrorRender } from '@xylabs/react-error'
2
- import { FlexCol } from '@xylabs/react-flexbox'
3
- import { ChainProducersAnalyzer } from '@xyo-network/chain-protocol'
4
- import React, { useMemo } from 'react'
5
-
6
- import type { ChainAnalyzers } from '../../../../../context/index.ts'
7
- import { ChainAnalyzersProvider, ChainPollingProvider } from '../../../../../context/index.ts'
8
- import type { BlockChainRenderFlexboxProps, RemoteBlockChainRenderFlexboxProps } from '../../../../../types/index.ts'
9
- import { BlockHeadingFlexbox } from '../../../../block/index.ts'
10
- import { MemoizedPollingControlsFlexbox } from '../../../controls/index.ts'
11
- import { BlockListAnimated } from '../../../list/index.ts'
12
- import { useDynamicBlockRenderComponents, useRemoteBlockChainRenderProps } from '../hooks/index.ts'
13
-
14
- const Base: React.FC<BlockChainRenderFlexboxProps> = ({ blockChainRenderProps, ...props }) => {
15
- const {
16
- errors, blockChainRenderComponents, blocksWhilePaused, pollingState, updatePollingState,
17
- } = useDynamicBlockRenderComponents(BlockHeadingFlexbox, blockChainRenderProps)
18
-
19
- return (
20
- <FlexCol alignItems="start" {...props}>
21
- {errors?.map((error, index) => <ErrorRender error={error} key={index} scope="DynamicBlockchainRenderFlexboxInner" />)}
22
- <MemoizedPollingControlsFlexbox
23
- blocksBehind={blocksWhilePaused?.length}
24
- pollingState={pollingState}
25
- setPollingState={updatePollingState}
26
- />
27
- <BlockListAnimated blockChainRenderComponents={blockChainRenderComponents} />
28
- </FlexCol>
29
- )
30
- }
31
-
32
- const WithAnalysis: React.FC<BlockChainRenderFlexboxProps> = ({ blockChainRenderProps, ...props }) => {
33
- const { chainInformation } = blockChainRenderProps ?? {}
34
-
35
- const analyzers = useMemo(() => {
36
- if (chainInformation) {
37
- return { producers: new ChainProducersAnalyzer() } as ChainAnalyzers
38
- }
39
- }, [chainInformation])
40
-
41
- return (
42
- <ChainAnalyzersProvider analyzers={analyzers}>
43
- <ChainPollingProvider>
44
- <DynamicBlockchainRenderFlexbox.Base blockChainRenderProps={blockChainRenderProps} {...props} />
45
- </ChainPollingProvider>
46
- </ChainAnalyzersProvider>
47
- )
48
- }
49
-
50
- const WithRemote: React.FC<RemoteBlockChainRenderFlexboxProps> = ({
51
- url, chainArchivistModuleId, blockChainRenderProps: blockChainRenderPropsArg, ...props
52
- }) => {
53
- const { error, blockChainRenderProps } = useRemoteBlockChainRenderProps(chainArchivistModuleId, url, blockChainRenderPropsArg)
54
-
55
- return (
56
- <>
57
- <ErrorRender error={error} scope="RemoteChainProviderFlexbox" />
58
- <DynamicBlockchainRenderFlexbox.WithAnalysis blockChainRenderProps={blockChainRenderProps} {...props} />
59
- </>
60
- )
61
- }
1
+ import {
2
+ DynamicListBase, WithAnalysis, WithRemote,
3
+ } from './variants/index.ts'
62
4
 
63
5
  export const DynamicBlockchainRenderFlexbox = {
64
- Base, WithAnalysis, WithRemote,
6
+ Base: DynamicListBase, WithAnalysis, WithRemote,
65
7
  }
@@ -0,0 +1,27 @@
1
+ import { ErrorRender } from '@xylabs/react-error'
2
+ import { FlexCol } 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 { MemoizedPollingControlsFlexbox } from '../../../../controls/index.ts'
8
+ import { BlockListAnimated } from '../../../../list/index.ts'
9
+ import { useDynamicBlockRenderComponents } from '../../hooks/index.ts'
10
+
11
+ export const DynamicListBase: React.FC<BlockChainRenderFlexboxProps> = ({ blockChainRenderProps, ...props }) => {
12
+ const {
13
+ errors, blockChainRenderComponents, blocksWhilePaused, pollingState, updatePollingState,
14
+ } = useDynamicBlockRenderComponents(BlockHeadingFlexbox, blockChainRenderProps)
15
+
16
+ return (
17
+ <FlexCol alignItems="start" {...props}>
18
+ {errors?.map(error => <ErrorRender error={error} key={error?.name} scope="DynamicBlockchainRenderFlexboxInner" />)}
19
+ <MemoizedPollingControlsFlexbox
20
+ blocksBehind={blocksWhilePaused?.length}
21
+ pollingState={pollingState}
22
+ setPollingState={updatePollingState}
23
+ />
24
+ <BlockListAnimated blockChainRenderComponents={blockChainRenderComponents} />
25
+ </FlexCol>
26
+ )
27
+ }