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

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 (27) hide show
  1. package/dist/browser/components/account/table/BalanceHistoryTableRow.d.ts.map +1 -1
  2. package/dist/browser/components/account/table/RawAmountTableCell.d.ts +2 -0
  3. package/dist/browser/components/account/table/RawAmountTableCell.d.ts.map +1 -1
  4. package/dist/browser/components/account/table/cell/AddressTableCell.d.ts +2 -0
  5. package/dist/browser/components/account/table/cell/AddressTableCell.d.ts.map +1 -1
  6. package/dist/browser/components/account/table/cell/BlockNumber.d.ts +14 -0
  7. package/dist/browser/components/account/table/cell/BlockNumber.d.ts.map +1 -0
  8. package/dist/browser/components/account/table/cell/HashTableCell.d.ts +3 -0
  9. package/dist/browser/components/account/table/cell/HashTableCell.d.ts.map +1 -1
  10. package/dist/browser/components/account/table/cell/index.d.ts +1 -0
  11. package/dist/browser/components/account/table/cell/index.d.ts.map +1 -1
  12. package/dist/browser/components/account/table/types/index.d.ts +2 -2
  13. package/dist/browser/components/account/table/types/index.d.ts.map +1 -1
  14. package/dist/browser/components/block/table/cell/BlockNumber.d.ts +2 -0
  15. package/dist/browser/components/block/table/cell/BlockNumber.d.ts.map +1 -1
  16. package/dist/browser/index.mjs +225 -184
  17. package/dist/browser/index.mjs.map +1 -1
  18. package/package.json +8 -8
  19. package/src/components/account/table/BalanceHistoryTableRow.stories.tsx +2 -0
  20. package/src/components/account/table/BalanceHistoryTableRow.tsx +14 -12
  21. package/src/components/account/table/RawAmountTableCell.tsx +5 -5
  22. package/src/components/account/table/cell/AddressTableCell.tsx +6 -5
  23. package/src/components/account/table/cell/BlockNumber.tsx +39 -0
  24. package/src/components/account/table/cell/HashTableCell.tsx +6 -5
  25. package/src/components/account/table/cell/index.ts +1 -0
  26. package/src/components/account/table/types/index.ts +3 -2
  27. package/src/components/block/table/cell/BlockNumber.tsx +9 -10
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.20.13",
4
+ "version": "1.20.15",
5
5
  "description": "XYO Layer One React SDK Blockchain",
6
6
  "homepage": "https://xylabs.com",
7
7
  "bugs": {
@@ -56,13 +56,13 @@
56
56
  "@xylabs/react-theme": "~7.1.17",
57
57
  "@xylabs/sdk-js": "~5.0.90",
58
58
  "@xyo-network/boundwitness-model": "~5.3.20",
59
- "@xyo-network/chain-analyze": "~1.20.13",
60
- "@xyo-network/chain-protocol": "~1.20.13",
61
- "@xyo-network/chain-wrappers": "~1.20.13",
59
+ "@xyo-network/chain-analyze": "~1.20.15",
60
+ "@xyo-network/chain-protocol": "~1.20.15",
61
+ "@xyo-network/chain-wrappers": "~1.20.15",
62
62
  "@xyo-network/react-boundwitness-plugin": "~7.5.8",
63
- "@xyo-network/react-chain-blockies": "~1.20.13",
64
- "@xyo-network/react-chain-provider": "~1.20.13",
65
- "@xyo-network/react-chain-shared": "~1.20.13",
63
+ "@xyo-network/react-chain-blockies": "~1.20.15",
64
+ "@xyo-network/react-chain-provider": "~1.20.15",
65
+ "@xyo-network/react-chain-shared": "~1.20.15",
66
66
  "@xyo-network/react-error": "~7.5.8",
67
67
  "@xyo-network/react-event": "~7.5.8",
68
68
  "@xyo-network/react-payload-raw-info": "~7.5.8",
@@ -88,7 +88,7 @@
88
88
  "@xylabs/tsconfig-dom": "~7.5.11",
89
89
  "@xylabs/tsconfig-react": "~7.5.11",
90
90
  "@xyo-network/bridge-http": "~5.3.20",
91
- "@xyo-network/react-chain-network": "~1.20.13",
91
+ "@xyo-network/react-chain-network": "~1.20.15",
92
92
  "@xyo-network/sdk-js": "~5.3.20",
93
93
  "@xyo-network/xl1-sdk": "~1.26.11",
94
94
  "axios": "^1.13.6",
@@ -10,12 +10,14 @@ import { BalanceHistoryTableRow } from './BalanceHistoryTableRow.tsx'
10
10
  const sampleRow: AccountBalanceHistoryItemFormatted = {
11
11
  amount: 866_949_573_941_165_034_031n,
12
12
  blockNumber: 652_126,
13
+ blockHash: 'abc123456789abcdef123456789abcdef123456789abcdef123456789abcdef' as Hash,
13
14
  debug: undefined as unknown as AccountBalanceHistoryItem,
14
15
  from: '626cfa5650444825a1633287a0b4bc8a55f54735' as Address,
15
16
  key: 'a80ee574-1c52-46bc-a5df-bbd9b9b8082e',
16
17
  timestamp: 1_769_423_309_664,
17
18
  to: 'd50a55aa2f6c9416cf8ecc9ef4790260564a7ec7' as Address,
18
19
  txHash: '123456789abcdef123456789abcdef123456789abcdef123456789abcdef1234' as Hash,
20
+ transferHash: '123456789abcdef123456789abcdef123456789abcdef123456789abcdef1234' as Hash,
19
21
  type: 'receive',
20
22
  }
21
23
 
@@ -8,9 +8,11 @@ import { RawInfoIconButton } from '@xyo-network/react-payload-raw-info'
8
8
  import type { Ref } from 'react'
9
9
  import React, { useMemo } from 'react'
10
10
 
11
- import { BlockEpochTableCellInner, BlockNumberTableCellInner } from '../../block/index.ts'
11
+ import { BlockEpochTableCellInner } from '../../block/index.ts'
12
12
  import { StyledLinkableTableRow } from '../../table/index.ts'
13
- import { AddressTableCell, HashTableCell } from './cell/index.ts'
13
+ import {
14
+ AddressTableCell, BalanceHistoryBlockNumberTableCellInner, HashTableCell,
15
+ } from './cell/index.ts'
14
16
  import { useLinkedBalanceHistoryItem } from './hooks/index.ts'
15
17
  import { RawAmountTableCell } from './RawAmountTableCell.tsx'
16
18
  import type { BalanceHistoryEventNouns } from './types/index.ts'
@@ -26,14 +28,14 @@ export const BalanceHistoryTableRow: React.FC<BalanceHistoryTableRowProps> = ({
26
28
  linked, row, ...props
27
29
  }) => {
28
30
  const {
29
- amount, blockNumber, debug, from, key, timestamp, to, type, txHash,
30
- } = row ?? {}
31
+ amount, blockHash, blockNumber, debug, from, key, timestamp, to, type, txHash, transferHash,
32
+ } = row ?? {} as AccountBalanceHistoryItemFormatted
31
33
 
32
34
  const linkedTableCallProps = useMemo(() => ({ linked }), [linked])
33
35
  const [ref, handleClick] = useLinkedBalanceHistoryItem()
34
36
 
35
- const noun: BalanceHistoryEventNouns = isDefined(txHash) ? 'tx-hash' : 'blockNumber'
36
- const data = isDefined(txHash) ? txHash : blockNumber
37
+ const noun: BalanceHistoryEventNouns = isDefined(txHash) ? 'tx-hash|transfer-hash' : 'block-hash|transfer-hash'
38
+ const data = isDefined(txHash) ? `${txHash}|${transferHash}` : `${blockHash}|${transferHash}`
37
39
 
38
40
  return (
39
41
  <StyledLinkableTableRow
@@ -43,13 +45,13 @@ export const BalanceHistoryTableRow: React.FC<BalanceHistoryTableRowProps> = ({
43
45
  ref={ref as Ref<HTMLTableRowElement> | undefined}
44
46
  {...props}
45
47
  >
46
- <HashTableCell hash={txHash} toolTipTitle={`Transaction Hash: ${txHash}`} {...linkedTableCallProps} />
47
- <BlockNumberTableCellInner blockNumber={blockNumber} {...linkedTableCallProps} />
48
+ <HashTableCell hash={txHash} toolTipTitle={`Transaction Hash: ${txHash}`} eventNoun="tx-hash" {...linkedTableCallProps} />
49
+ <BalanceHistoryBlockNumberTableCellInner blockNumber={blockNumber} eventNoun="block-number" {...linkedTableCallProps} />
48
50
  <BlockEpochTableCellInner epoch={timestamp} {...linkedTableCallProps} />
49
- <AddressTableCell address={from} toolTipTitle={`From Address: ${from}`} {...linkedTableCallProps} />
50
- <AddressTableCell address={to} toolTipTitle={`To Address: ${to}`} {...linkedTableCallProps} />
51
- {/* Intentionally not passing linked prop here till we know where a link would go */}
52
- <RawAmountTableCell amount={amount} type={type} />
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} />
53
55
  <TableCell>
54
56
  <RawInfoIconButton rawValue={debug as JsonValue} />
55
57
  </TableCell>
@@ -4,23 +4,23 @@ import {
4
4
  } from '@mui/material'
5
5
  import { isDefined, toHex } from '@xylabs/sdk-js'
6
6
  import type { BalanceTransactionType } from '@xyo-network/react-chain-provider'
7
- import { useEvent } from '@xyo-network/react-event'
8
7
  import { XL1Amount } from '@xyo-network/xl1-sdk'
9
8
  import React from 'react'
10
9
 
10
+ import { useLinkedBalanceHistoryItem } from './hooks/index.ts'
11
11
  import type { BalanceHistoryEventNouns } from './types/index.ts'
12
12
 
13
13
  export interface RawAmountTableCellProps extends TableCellProps {
14
14
  amount?: bigint
15
+ eventNoun?: BalanceHistoryEventNouns
15
16
  linked?: boolean
16
17
  type?: BalanceTransactionType
17
18
  }
18
19
 
19
20
  export const RawAmountTableCell: React.FC<RawAmountTableCellProps> = ({
20
- amount, linked, sx, type, ...props
21
+ amount, eventNoun = 'amount', linked, sx, type, ...props
21
22
  }) => {
22
- const [ref, dispatch] = useEvent<HTMLAnchorElement, BalanceHistoryEventNouns>()
23
- const handleClick = (event: React.MouseEvent<HTMLAnchorElement>) => dispatch('amount', 'click', isDefined(amount) ? toHex(amount) : '', event.nativeEvent)
23
+ const [ref, handleClick] = useLinkedBalanceHistoryItem()
24
24
 
25
25
  const formatAmount = (amount?: bigint) => {
26
26
  if (!isDefined(amount)) {
@@ -36,7 +36,7 @@ export const RawAmountTableCell: React.FC<RawAmountTableCellProps> = ({
36
36
  <Tooltip title={`Raw Amount: ${amount}`}>
37
37
  {linked
38
38
  ? (
39
- <Link onClick={handleClick} sx={{ cursor: 'pointer' }}>
39
+ <Link onClick={e => handleClick(e, eventNoun, isDefined(amount) ? toHex(amount) : '')} sx={{ cursor: 'pointer' }}>
40
40
  {type === 'send' ? '-' : ''}
41
41
  {formatAmount(amount)}
42
42
  </Link>
@@ -1,25 +1,26 @@
1
1
  import type { TableCellProps } from '@mui/material'
2
2
  import { TableCell, Tooltip } from '@mui/material'
3
- import { useEvent } from '@xyo-network/react-event'
4
3
  import React from 'react'
5
4
 
6
5
  import { BlockAddressChip } from '../../../block/index.ts'
6
+ import { useLinkedBalanceHistoryItem } from '../hooks/index.ts'
7
+ import type { BalanceHistoryEventNouns } from '../types/index.ts'
7
8
 
8
9
  export interface AddressTableCellProps extends TableCellProps {
9
10
  address?: string
11
+ eventNoun?: BalanceHistoryEventNouns
10
12
  linked?: boolean
11
13
  toolTipTitle?: string
12
14
  }
13
15
 
14
16
  export const AddressTableCell: React.FC<AddressTableCellProps> = ({
15
- address, linked, toolTipTitle, sx, ...props
17
+ address, eventNoun, linked, toolTipTitle, sx, ...props
16
18
  }) => {
17
- const [ref, dispatch] = useEvent()
18
- const handleClick = (event: React.MouseEvent<HTMLDivElement>) => dispatch('address', 'click', address, event.nativeEvent)
19
+ const [ref, handleClick] = useLinkedBalanceHistoryItem()
19
20
  return (
20
21
  <TableCell ref={ref} sx={{ cursor: linked ? 'pointer' : 'default', ...sx }} {...props}>
21
22
  <Tooltip title={toolTipTitle}>
22
- <BlockAddressChip address={address} onClick={handleClick} />
23
+ <BlockAddressChip address={address} onClick={linked ? e => handleClick(e, eventNoun, address) : undefined} />
23
24
  </Tooltip>
24
25
  </TableCell>
25
26
  )
@@ -0,0 +1,39 @@
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
+ }
@@ -6,22 +6,23 @@ import {
6
6
  import {
7
7
  ellipsize, type Hash, isDefined,
8
8
  } from '@xylabs/sdk-js'
9
- import { useEvent } from '@xyo-network/react-event'
10
9
  import React from 'react'
11
10
 
11
+ import { useLinkedBalanceHistoryItem } from '../hooks/index.ts'
12
12
  import type { BalanceHistoryEventNouns } from '../types/index.ts'
13
13
 
14
14
  export interface HashTableCellProps extends TableCellProps {
15
+ eventData?: string
16
+ eventNoun?: BalanceHistoryEventNouns
15
17
  hash?: Hash
16
18
  linked?: boolean
17
19
  toolTipTitle?: string
18
20
  }
19
21
 
20
22
  export const HashTableCell: React.FC<HashTableCellProps> = ({
21
- hash, linked, toolTipTitle, sx, ...props
23
+ eventData, eventNoun = 'tx-hash', hash, linked, toolTipTitle, sx, ...props
22
24
  }) => {
23
- const [ref, dispatch] = useEvent<HTMLTableCellElement, BalanceHistoryEventNouns>()
24
- const handleClick = (event: React.MouseEvent<HTMLAnchorElement>) => dispatch('tx-hash', 'click', hash, event.nativeEvent)
25
+ const [ref, handleClick] = useLinkedBalanceHistoryItem()
25
26
  const shortenedHash = isDefined(hash) ? ellipsize(hash as string, 6) : 'N/A'
26
27
  return (
27
28
  <TableCell ref={ref} {...props}>
@@ -31,7 +32,7 @@ export const HashTableCell: React.FC<HashTableCellProps> = ({
31
32
  <Typography component="span" variant="body1">
32
33
  {linked
33
34
  ? (
34
- <Link onClick={handleClick} sx={{ cursor: 'pointer' }}>
35
+ <Link onClick={e => handleClick(e, eventNoun, eventData)} sx={{ cursor: 'pointer' }}>
35
36
  {shortenedHash}
36
37
  </Link>
37
38
  )
@@ -1,2 +1,3 @@
1
1
  export * from './AddressTableCell.tsx'
2
+ export * from './BlockNumber.tsx'
2
3
  export * from './HashTableCell.tsx'
@@ -1,9 +1,9 @@
1
1
  import type { AccountBalanceHistoryItemFormatted } from '@xyo-network/react-chain-provider'
2
2
  import type { ExtendEventNoun } from '@xyo-network/react-event'
3
3
 
4
- export type BalanceHistoryEventNouns = ExtendEventNoun<'amount' | 'blockNumber' | 'tx-hash'>
4
+ export type BalanceHistoryEventNouns = ExtendEventNoun<'from-address' | 'to-address' | 'amount' | 'block-number' | 'tx-hash' | 'transfer-hash' | 'tx-hash|transfer-hash' | 'block-hash|transfer-hash'>
5
5
 
6
- export type TableHeadingLabels = 'Tx Hash' | 'BlockNumber' | 'Timestamp' | 'From' | 'To' | 'Amount' | 'Debug'
6
+ export type TableHeadingLabels = 'Tx Hash' | 'BlockNumber' | 'Timestamp' | 'From' | 'To' | 'Amount' | 'Debug' | 'TransferHash'
7
7
  export type TableHeadings = { [key in keyof AccountBalanceHistoryItemFormatted]: TableHeadingLabels }
8
8
 
9
9
  export const TableHeadingLabels: TableHeadingLabels[] = [
@@ -13,5 +13,6 @@ export const TableHeadingLabels: TableHeadingLabels[] = [
13
13
  'From',
14
14
  'To',
15
15
  'Amount',
16
+ 'TransferHash',
16
17
  'Debug',
17
18
  ] as const
@@ -1,29 +1,28 @@
1
1
  import {
2
- Link,
3
- TableCell, Tooltip,
4
- Typography,
2
+ Link, TableCell, Tooltip, Typography,
5
3
  } from '@mui/material'
6
- import { useEvent } from '@xyo-network/react-event'
7
4
  import React from 'react'
8
5
 
9
6
  import type { BlockHeaderEventNouns } from '../../hooks/index.ts'
7
+ import { useLinkedBlockItem } from './hooks/index.ts'
10
8
  import type { BlockTableCellProps } from './lib/index.ts'
11
9
 
12
- export interface BlockNumberTableCellProps extends BlockTableCellProps {}
10
+ export interface BlockNumberTableCellProps extends BlockTableCellProps {
11
+ eventNoun?: BlockHeaderEventNouns
12
+ }
13
13
 
14
14
  export const BlockNumberTableCell: React.FC<BlockNumberTableCellProps> = ({
15
- block, linked, ...props
15
+ block, eventNoun = 'block-number', linked, ...props
16
16
  }) => {
17
17
  const blockNumber = block?.[0].block
18
18
 
19
- return <BlockNumberTableCellInner blockNumber={blockNumber} linked={linked} {...props} />
19
+ return <BlockNumberTableCellInner blockNumber={blockNumber} eventNoun={eventNoun} linked={linked} {...props} />
20
20
  }
21
21
 
22
22
  export const BlockNumberTableCellInner: React.FC<BlockNumberTableCellProps & { blockNumber?: number; linked?: boolean }> = ({
23
- blockNumber, linked, ...props
23
+ blockNumber, eventNoun = 'block-number', linked, ...props
24
24
  }) => {
25
- const [ref, dispatch] = useEvent<HTMLTableCellElement, BlockHeaderEventNouns>()
26
- const handleClick = (event: React.MouseEvent<HTMLAnchorElement>) => dispatch('block-number', 'click', blockNumber?.toString() ?? '', event.nativeEvent)
25
+ const [ref, handleClick] = useLinkedBlockItem(eventNoun, blockNumber?.toLocaleString())
27
26
  return (
28
27
  <TableCell ref={ref} {...props}>
29
28
  <Tooltip title={`Block Number: ${blockNumber}`}>