@xyo-network/react-chain-blockchain 1.20.12 → 1.20.13
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.
- package/dist/browser/components/account/table/BalanceHistoryTableRow.d.ts.map +1 -1
- package/dist/browser/components/account/table/hooks/index.d.ts +2 -0
- package/dist/browser/components/account/table/hooks/index.d.ts.map +1 -0
- package/dist/browser/components/account/table/hooks/useLinkedBalanceHistoryItem.d.ts +5 -0
- package/dist/browser/components/account/table/hooks/useLinkedBalanceHistoryItem.d.ts.map +1 -0
- package/dist/browser/components/account/table/index.d.ts +1 -0
- package/dist/browser/components/account/table/index.d.ts.map +1 -1
- package/dist/browser/components/block/table/row/TableRow.d.ts.map +1 -1
- package/dist/browser/components/table/StyledLinkableTableRow.d.ts +6 -0
- package/dist/browser/components/table/StyledLinkableTableRow.d.ts.map +1 -0
- package/dist/browser/components/table/index.d.ts +2 -0
- package/dist/browser/components/table/index.d.ts.map +1 -0
- package/dist/browser/index.mjs +91 -55
- package/dist/browser/index.mjs.map +1 -1
- package/package.json +20 -20
- package/src/components/account/table/BalanceHistoryTableEx.stories.tsx +1 -1
- package/src/components/account/table/BalanceHistoryTableRow.stories.tsx +51 -0
- package/src/components/account/table/BalanceHistoryTableRow.tsx +19 -4
- package/src/components/account/table/hooks/index.ts +1 -0
- package/src/components/account/table/hooks/useLinkedBalanceHistoryItem.tsx +29 -0
- package/src/components/account/table/index.ts +1 -0
- package/src/components/block/table/row/TableRow.stories.tsx +6 -2
- package/src/components/block/table/row/TableRow.tsx +5 -12
- package/src/components/table/StyledLinkableTableRow.tsx +12 -0
- package/src/components/table/index.ts +1 -0
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.
|
|
4
|
+
"version": "1.20.13",
|
|
5
5
|
"description": "XYO Layer One React SDK Blockchain",
|
|
6
6
|
"homepage": "https://xylabs.com",
|
|
7
7
|
"bugs": {
|
|
@@ -55,22 +55,22 @@
|
|
|
55
55
|
"@xylabs/react-shared": "~7.1.17",
|
|
56
56
|
"@xylabs/react-theme": "~7.1.17",
|
|
57
57
|
"@xylabs/sdk-js": "~5.0.90",
|
|
58
|
-
"@xyo-network/boundwitness-model": "~5.3.
|
|
59
|
-
"@xyo-network/chain-analyze": "~1.20.
|
|
60
|
-
"@xyo-network/chain-protocol": "~1.20.
|
|
61
|
-
"@xyo-network/chain-wrappers": "~1.20.
|
|
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",
|
|
62
62
|
"@xyo-network/react-boundwitness-plugin": "~7.5.8",
|
|
63
|
-
"@xyo-network/react-chain-blockies": "~1.20.
|
|
64
|
-
"@xyo-network/react-chain-provider": "~1.20.
|
|
65
|
-
"@xyo-network/react-chain-shared": "~1.20.
|
|
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",
|
|
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",
|
|
69
69
|
"@xyo-network/react-payload-table": "~7.5.8",
|
|
70
70
|
"@xyo-network/react-shared": "~7.5.8",
|
|
71
71
|
"@xyo-network/react-table": "~7.5.8",
|
|
72
|
-
"@xyo-network/sdk-js": "~5.3.
|
|
73
|
-
"@xyo-network/xl1-sdk": "~1.26.
|
|
72
|
+
"@xyo-network/sdk-js": "~5.3.20",
|
|
73
|
+
"@xyo-network/xl1-sdk": "~1.26.11"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@emotion/react": "~11.14.0",
|
|
@@ -82,16 +82,16 @@
|
|
|
82
82
|
"@types/react": "~19.2.14",
|
|
83
83
|
"@xylabs/react-button": "~7.1.17",
|
|
84
84
|
"@xylabs/sdk-js": "~5.0.90",
|
|
85
|
-
"@xylabs/ts-scripts-common": "~7.5.
|
|
86
|
-
"@xylabs/ts-scripts-yarn3": "~7.5.
|
|
87
|
-
"@xylabs/tsconfig": "~7.5.
|
|
88
|
-
"@xylabs/tsconfig-dom": "~7.5.
|
|
89
|
-
"@xylabs/tsconfig-react": "~7.5.
|
|
90
|
-
"@xyo-network/bridge-http": "~5.3.
|
|
91
|
-
"@xyo-network/react-chain-network": "~1.20.
|
|
92
|
-
"@xyo-network/sdk-js": "~5.3.
|
|
93
|
-
"@xyo-network/xl1-sdk": "~1.26.
|
|
94
|
-
"axios": "^1.
|
|
85
|
+
"@xylabs/ts-scripts-common": "~7.5.11",
|
|
86
|
+
"@xylabs/ts-scripts-yarn3": "~7.5.11",
|
|
87
|
+
"@xylabs/tsconfig": "~7.5.11",
|
|
88
|
+
"@xylabs/tsconfig-dom": "~7.5.11",
|
|
89
|
+
"@xylabs/tsconfig-react": "~7.5.11",
|
|
90
|
+
"@xyo-network/bridge-http": "~5.3.20",
|
|
91
|
+
"@xyo-network/react-chain-network": "~1.20.13",
|
|
92
|
+
"@xyo-network/sdk-js": "~5.3.20",
|
|
93
|
+
"@xyo-network/xl1-sdk": "~1.26.11",
|
|
94
|
+
"axios": "^1.13.6",
|
|
95
95
|
"ethers": "^6.16.0",
|
|
96
96
|
"react": "~19.2.4",
|
|
97
97
|
"react-dom": "~19.2.4",
|
|
@@ -48,7 +48,7 @@ const TemplateLinked: StoryFn<typeof AccountBalanceHistoryTableEx> = (args) => {
|
|
|
48
48
|
noun, verb, data,
|
|
49
49
|
}))
|
|
50
50
|
|
|
51
|
-
const results = useFetchBalanceHistory(
|
|
51
|
+
const results = useFetchBalanceHistory(TEST_ADDRESS_1)
|
|
52
52
|
const [history, error, loading] = results
|
|
53
53
|
|
|
54
54
|
return (
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Table, TableBody } from '@mui/material'
|
|
2
|
+
import type { Meta, StoryFn } from '@storybook/react-vite'
|
|
3
|
+
import type { Address, Hash } from '@xylabs/sdk-js'
|
|
4
|
+
import type { AccountBalanceHistoryItemFormatted } from '@xyo-network/react-chain-provider'
|
|
5
|
+
import type { AccountBalanceHistoryItem } from '@xyo-network/xl1-sdk'
|
|
6
|
+
import React from 'react'
|
|
7
|
+
|
|
8
|
+
import { BalanceHistoryTableRow } from './BalanceHistoryTableRow.tsx'
|
|
9
|
+
|
|
10
|
+
const sampleRow: AccountBalanceHistoryItemFormatted = {
|
|
11
|
+
amount: 866_949_573_941_165_034_031n,
|
|
12
|
+
blockNumber: 652_126,
|
|
13
|
+
debug: undefined as unknown as AccountBalanceHistoryItem,
|
|
14
|
+
from: '626cfa5650444825a1633287a0b4bc8a55f54735' as Address,
|
|
15
|
+
key: 'a80ee574-1c52-46bc-a5df-bbd9b9b8082e',
|
|
16
|
+
timestamp: 1_769_423_309_664,
|
|
17
|
+
to: 'd50a55aa2f6c9416cf8ecc9ef4790260564a7ec7' as Address,
|
|
18
|
+
txHash: '123456789abcdef123456789abcdef123456789abcdef123456789abcdef1234' as Hash,
|
|
19
|
+
type: 'receive',
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default {
|
|
23
|
+
title: 'AccountBalanceHistory/TableRow',
|
|
24
|
+
component: BalanceHistoryTableRow,
|
|
25
|
+
} as Meta<typeof BalanceHistoryTableRow>
|
|
26
|
+
|
|
27
|
+
const Template: StoryFn<typeof BalanceHistoryTableRow> = args => (
|
|
28
|
+
<Table>
|
|
29
|
+
<TableBody>
|
|
30
|
+
<BalanceHistoryTableRow {...args} />
|
|
31
|
+
</TableBody>
|
|
32
|
+
</Table>
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
const Default = Template.bind({})
|
|
36
|
+
Default.args = { row: sampleRow }
|
|
37
|
+
|
|
38
|
+
const WithLinked = Template.bind({})
|
|
39
|
+
WithLinked.args = { row: sampleRow, linked: true }
|
|
40
|
+
|
|
41
|
+
const WithNoTxHash = Template.bind({})
|
|
42
|
+
WithNoTxHash.args = {
|
|
43
|
+
row: {
|
|
44
|
+
...sampleRow,
|
|
45
|
+
txHash: undefined,
|
|
46
|
+
},
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export {
|
|
50
|
+
Default, WithLinked, WithNoTxHash,
|
|
51
|
+
}
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
|
-
TableCell,
|
|
2
|
+
TableCell,
|
|
3
|
+
type TableRowProps,
|
|
3
4
|
} from '@mui/material'
|
|
4
|
-
import type
|
|
5
|
+
import { isDefined, type JsonValue } from '@xylabs/sdk-js'
|
|
5
6
|
import type { AccountBalanceHistoryItemFormatted } from '@xyo-network/react-chain-provider'
|
|
6
7
|
import { RawInfoIconButton } from '@xyo-network/react-payload-raw-info'
|
|
8
|
+
import type { Ref } from 'react'
|
|
7
9
|
import React, { useMemo } from 'react'
|
|
8
10
|
|
|
9
11
|
import { BlockEpochTableCellInner, BlockNumberTableCellInner } from '../../block/index.ts'
|
|
12
|
+
import { StyledLinkableTableRow } from '../../table/index.ts'
|
|
10
13
|
import { AddressTableCell, HashTableCell } from './cell/index.ts'
|
|
14
|
+
import { useLinkedBalanceHistoryItem } from './hooks/index.ts'
|
|
11
15
|
import { RawAmountTableCell } from './RawAmountTableCell.tsx'
|
|
16
|
+
import type { BalanceHistoryEventNouns } from './types/index.ts'
|
|
12
17
|
|
|
13
18
|
// const TEXT_TX_HASH = '123456789abcdef123456789abcdef123456789abcdef123456789abcdef1234' as Hash
|
|
14
19
|
|
|
@@ -25,9 +30,19 @@ export const BalanceHistoryTableRow: React.FC<BalanceHistoryTableRowProps> = ({
|
|
|
25
30
|
} = row ?? {}
|
|
26
31
|
|
|
27
32
|
const linkedTableCallProps = useMemo(() => ({ linked }), [linked])
|
|
33
|
+
const [ref, handleClick] = useLinkedBalanceHistoryItem()
|
|
34
|
+
|
|
35
|
+
const noun: BalanceHistoryEventNouns = isDefined(txHash) ? 'tx-hash' : 'blockNumber'
|
|
36
|
+
const data = isDefined(txHash) ? txHash : blockNumber
|
|
28
37
|
|
|
29
38
|
return (
|
|
30
|
-
<
|
|
39
|
+
<StyledLinkableTableRow
|
|
40
|
+
linked={linked}
|
|
41
|
+
key={key}
|
|
42
|
+
onClick={linked ? e => handleClick(e, noun, data) : undefined}
|
|
43
|
+
ref={ref as Ref<HTMLTableRowElement> | undefined}
|
|
44
|
+
{...props}
|
|
45
|
+
>
|
|
31
46
|
<HashTableCell hash={txHash} toolTipTitle={`Transaction Hash: ${txHash}`} {...linkedTableCallProps} />
|
|
32
47
|
<BlockNumberTableCellInner blockNumber={blockNumber} {...linkedTableCallProps} />
|
|
33
48
|
<BlockEpochTableCellInner epoch={timestamp} {...linkedTableCallProps} />
|
|
@@ -38,6 +53,6 @@ export const BalanceHistoryTableRow: React.FC<BalanceHistoryTableRowProps> = ({
|
|
|
38
53
|
<TableCell>
|
|
39
54
|
<RawInfoIconButton rawValue={debug as JsonValue} />
|
|
40
55
|
</TableCell>
|
|
41
|
-
</
|
|
56
|
+
</StyledLinkableTableRow>
|
|
42
57
|
)
|
|
43
58
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useLinkedBalanceHistoryItem.tsx'
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useEvent } from '@xyo-network/react-event'
|
|
2
|
+
import type { Ref } from 'react'
|
|
3
|
+
import type React from 'react'
|
|
4
|
+
|
|
5
|
+
import type { BalanceHistoryEventNouns } from '../types/index.ts'
|
|
6
|
+
|
|
7
|
+
export const useLinkedBalanceHistoryItem = (): [
|
|
8
|
+
Ref<HTMLElement | null>,
|
|
9
|
+
(event: React.MouseEvent, noun?: BalanceHistoryEventNouns, data?: string | number) => void,
|
|
10
|
+
] => {
|
|
11
|
+
const [ref, dispatch] = useEvent<HTMLAnchorElement, BalanceHistoryEventNouns, string, string | number>()
|
|
12
|
+
|
|
13
|
+
const handleClick = (event: React.MouseEvent, noun?: BalanceHistoryEventNouns, data?: string | number) => {
|
|
14
|
+
event.preventDefault()
|
|
15
|
+
event.stopPropagation()
|
|
16
|
+
if (noun === undefined) {
|
|
17
|
+
console.warn('useLinkedBalanceHistoryItem: noun is required')
|
|
18
|
+
return
|
|
19
|
+
}
|
|
20
|
+
const selection = globalThis.getSelection()
|
|
21
|
+
const isTextSelected = selection && selection.toString().length > 0
|
|
22
|
+
|
|
23
|
+
if (!isTextSelected) {
|
|
24
|
+
dispatch(noun, 'click', data, event.nativeEvent)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return [ref, handleClick]
|
|
29
|
+
}
|
|
@@ -24,7 +24,11 @@ const Default = Template.bind({})
|
|
|
24
24
|
Default.args = {}
|
|
25
25
|
|
|
26
26
|
const WithData = Template.bind({})
|
|
27
|
-
// TODO - use buildRandomChain helper
|
|
28
27
|
WithData.args = { block }
|
|
29
28
|
|
|
30
|
-
|
|
29
|
+
const WithDataLinked = Template.bind({})
|
|
30
|
+
WithDataLinked.args = { block, linked: true }
|
|
31
|
+
|
|
32
|
+
export {
|
|
33
|
+
Default, WithData, WithDataLinked,
|
|
34
|
+
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import type { TableRowProps } from '@mui/material'
|
|
2
|
-
import { TableRow, useTheme } from '@mui/material'
|
|
3
|
-
import { alphaCss } from '@xylabs/react-theme'
|
|
4
2
|
import { usePayloadRootHash } from '@xyo-network/react-shared'
|
|
5
3
|
import type { Ref } from 'react'
|
|
6
4
|
import React, { useMemo } from 'react'
|
|
7
5
|
|
|
8
6
|
import type { BlockComponentProps } from '../../../../types/index.ts'
|
|
7
|
+
import { StyledLinkableTableRow } from '../../../table/index.ts'
|
|
9
8
|
import { useLinkedBlockItem } from '../cell/hooks/index.ts'
|
|
10
9
|
import {
|
|
11
10
|
BlockEpochTableCell,
|
|
@@ -20,24 +19,18 @@ export interface BlockChainTableRowProps extends BlockComponentProps, TableRowPr
|
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
export const BlockChainTableRow: React.FC<BlockChainTableRowProps> = ({
|
|
23
|
-
block, deepValidation, defaultExpanded, linked,
|
|
22
|
+
block, deepValidation, defaultExpanded, linked, ...props
|
|
24
23
|
}) => {
|
|
25
24
|
const linkedTableCellProps = useMemo(() => ({ block, linked }), [block, linked])
|
|
26
25
|
const defaultTableCellProps = useMemo(() => ({ block }), [block])
|
|
27
26
|
const hash = usePayloadRootHash(block?.[0])
|
|
28
27
|
const [ref, handleClick] = useLinkedBlockItem('block-hash', hash)
|
|
29
|
-
const theme = useTheme()
|
|
30
28
|
|
|
31
29
|
return (
|
|
32
|
-
<
|
|
30
|
+
<StyledLinkableTableRow
|
|
33
31
|
onClick={linked ? handleClick : undefined}
|
|
34
32
|
ref={ref as Ref<HTMLTableRowElement> | undefined}
|
|
35
|
-
|
|
36
|
-
'cursor': linked ? 'pointer' : 'default',
|
|
37
|
-
'overflowY': 'scroll',
|
|
38
|
-
'&:hover': { backgroundColor: alphaCss(theme.vars.palette.secondary.light, 0.15) },
|
|
39
|
-
...sx,
|
|
40
|
-
}}
|
|
33
|
+
linked={linked}
|
|
41
34
|
{...props}
|
|
42
35
|
>
|
|
43
36
|
<BlockNumberTableCell align="left" {...linkedTableCellProps} />
|
|
@@ -48,6 +41,6 @@ export const BlockChainTableRow: React.FC<BlockChainTableRowProps> = ({
|
|
|
48
41
|
<BlockPayloadCountsTableCell align="left" {...linkedTableCellProps} />
|
|
49
42
|
<BlockVerificationTableCell deepValidation={deepValidation} {...defaultTableCellProps} />
|
|
50
43
|
<BlockJsonViewTableCell {...defaultTableCellProps} />
|
|
51
|
-
</
|
|
44
|
+
</StyledLinkableTableRow>
|
|
52
45
|
)
|
|
53
46
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { TableRowProps } from '@mui/material'
|
|
2
|
+
import { styled, TableRow } from '@mui/material'
|
|
3
|
+
import { alphaCss } from '@xylabs/react-theme'
|
|
4
|
+
|
|
5
|
+
export const StyledLinkableTableRow = styled(TableRow, { shouldForwardProp: prop => prop !== 'linked' })<
|
|
6
|
+
TableRowProps & { linked?: boolean }
|
|
7
|
+
>(({ theme, linked }) => ({
|
|
8
|
+
'cursor': linked ? 'pointer' : 'default',
|
|
9
|
+
'overflowY': 'scroll',
|
|
10
|
+
'&:hover': { backgroundColor: alphaCss(theme.vars.palette.secondary.light, 0.15) },
|
|
11
|
+
}
|
|
12
|
+
))
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './StyledLinkableTableRow.tsx'
|