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

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 (196) hide show
  1. package/README.md +9 -8854
  2. package/dist/browser/components/block/table/cell/NumberChip.d.ts.map +1 -1
  3. package/dist/browser/components/chain/controls/PulseSvgIcon.d.ts +5 -2
  4. package/dist/browser/components/chain/controls/PulseSvgIcon.d.ts.map +1 -1
  5. package/dist/browser/components/chain/hooks/useOnBlock.d.ts +7 -7
  6. package/dist/browser/components/chain/styled/BlockListWrapperFlexbox.d.ts +6 -1
  7. package/dist/browser/components/chain/styled/BlockListWrapperFlexbox.d.ts.map +1 -1
  8. package/dist/browser/components/table/StyledLinkableTableRow.d.ts +5 -4
  9. package/dist/browser/components/table/StyledLinkableTableRow.d.ts.map +1 -1
  10. package/dist/browser/context/analyzer/context.d.ts +3 -3
  11. package/dist/browser/context/analyzer/use.d.ts +1 -1
  12. package/dist/browser/context/chain/Context.d.ts +3 -3
  13. package/dist/browser/context/chain/use.d.ts +1 -1
  14. package/dist/browser/hooks/useBaseContext.d.ts +2 -8
  15. package/dist/browser/hooks/useBaseContext.d.ts.map +1 -1
  16. package/dist/browser/hooks/useTxsFromBlock.d.ts +1 -1
  17. package/dist/browser/hooks/useTxsFromBlock.d.ts.map +1 -1
  18. package/dist/browser/index.mjs.map +1 -1
  19. package/package.json +169 -60
  20. package/src/components/FeatureNotAvailable.tsx +0 -20
  21. package/src/components/account/BalanceHistoryFlexbox.stories.tsx +0 -25
  22. package/src/components/account/BalanceHistoryFlexbox.tsx +0 -53
  23. package/src/components/account/helpers/formatBalanceMagnitude.ts +0 -14
  24. package/src/components/account/helpers/index.ts +0 -1
  25. package/src/components/account/hooks/index.ts +0 -1
  26. package/src/components/account/hooks/usePagedAccountBalanceHistory.ts +0 -39
  27. package/src/components/account/index.ts +0 -4
  28. package/src/components/account/table/BalanceHistoryTableEx.stories.tsx +0 -111
  29. package/src/components/account/table/BalanceHistoryTableEx.tsx +0 -37
  30. package/src/components/account/table/BalanceHistoryTableRow.stories.tsx +0 -53
  31. package/src/components/account/table/BalanceHistoryTableRow.tsx +0 -60
  32. package/src/components/account/table/RawAmountTableCell.tsx +0 -53
  33. package/src/components/account/table/cell/AddressTableCell.tsx +0 -27
  34. package/src/components/account/table/cell/BlockNumber.tsx +0 -39
  35. package/src/components/account/table/cell/HashTableCell.tsx +0 -46
  36. package/src/components/account/table/cell/index.ts +0 -3
  37. package/src/components/account/table/hooks/index.ts +0 -1
  38. package/src/components/account/table/hooks/useLinkedBalanceHistoryItem.tsx +0 -29
  39. package/src/components/account/table/index.ts +0 -5
  40. package/src/components/account/table/types/index.ts +0 -18
  41. package/src/components/block/BlockHeadingFlexbox.stories.tsx +0 -75
  42. package/src/components/block/BlockHeadingFlexbox.tsx +0 -56
  43. package/src/components/block/ChipSkeleton.tsx +0 -7
  44. package/src/components/block/LinkedDivider.tsx +0 -27
  45. package/src/components/block/ProducerChip.tsx +0 -45
  46. package/src/components/block/helpers/blockProducer.ts +0 -5
  47. package/src/components/block/helpers/buildBlockChainRenderComponent.tsx +0 -32
  48. package/src/components/block/helpers/index.ts +0 -3
  49. package/src/components/block/helpers/payloadCountsFromBlock.ts +0 -10
  50. package/src/components/block/hooks/index.ts +0 -4
  51. package/src/components/block/hooks/useAnchorElement.ts +0 -19
  52. package/src/components/block/hooks/useBlockHeadingEvents.ts +0 -11
  53. package/src/components/block/hooks/useBlockProducer.ts +0 -11
  54. package/src/components/block/hooks/usePayloadCountsFromBlock.ts +0 -13
  55. package/src/components/block/index.ts +0 -6
  56. package/src/components/block/menu/Expanded.tsx +0 -34
  57. package/src/components/block/menu/index.ts +0 -1
  58. package/src/components/block/table/Ex.stories.tsx +0 -64
  59. package/src/components/block/table/Ex.tsx +0 -21
  60. package/src/components/block/table/cell/BlockNumber.tsx +0 -35
  61. package/src/components/block/table/cell/Epoch.tsx +0 -46
  62. package/src/components/block/table/cell/Hash.tsx +0 -46
  63. package/src/components/block/table/cell/JsonView.tsx +0 -44
  64. package/src/components/block/table/cell/NumberChip.tsx +0 -12
  65. package/src/components/block/table/cell/PayloadCounts.tsx +0 -65
  66. package/src/components/block/table/cell/Producer.tsx +0 -63
  67. package/src/components/block/table/cell/TransactionCount.tsx +0 -56
  68. package/src/components/block/table/cell/Verification.tsx +0 -25
  69. package/src/components/block/table/cell/helpers/index.ts +0 -1
  70. package/src/components/block/table/cell/helpers/timeFunctions.ts +0 -44
  71. package/src/components/block/table/cell/hooks/index.ts +0 -1
  72. package/src/components/block/table/cell/hooks/useLinkedBlockItem.tsx +0 -25
  73. package/src/components/block/table/cell/index.ts +0 -8
  74. package/src/components/block/table/cell/lib/BlockTableCellProps.ts +0 -7
  75. package/src/components/block/table/cell/lib/index.ts +0 -1
  76. package/src/components/block/table/head/TableHead.tsx +0 -48
  77. package/src/components/block/table/head/index.ts +0 -1
  78. package/src/components/block/table/index.ts +0 -4
  79. package/src/components/block/table/row/TableRow.stories.tsx +0 -34
  80. package/src/components/block/table/row/TableRow.tsx +0 -46
  81. package/src/components/block/table/row/index.ts +0 -1
  82. package/src/components/chain/controls/PollingControlsFlexbox.tsx +0 -76
  83. package/src/components/chain/controls/PulseSvgIcon.tsx +0 -71
  84. package/src/components/chain/controls/index.ts +0 -2
  85. package/src/components/chain/dialog/Dialog.tsx +0 -20
  86. package/src/components/chain/dialog/index.ts +0 -1
  87. package/src/components/chain/hooks/index.ts +0 -1
  88. package/src/components/chain/hooks/useOnBlock.ts +0 -55
  89. package/src/components/chain/index.ts +0 -6
  90. package/src/components/chain/list/Animated.tsx +0 -19
  91. package/src/components/chain/list/TableEx.tsx +0 -12
  92. package/src/components/chain/list/index.ts +0 -2
  93. package/src/components/chain/pagination/BlockChainPagination.tsx +0 -11
  94. package/src/components/chain/pagination/hooks/index.ts +0 -1
  95. package/src/components/chain/pagination/hooks/usePagination.tsx +0 -22
  96. package/src/components/chain/pagination/index.ts +0 -2
  97. package/src/components/chain/stats/Dialog.tsx +0 -49
  98. package/src/components/chain/stats/index.ts +0 -1
  99. package/src/components/chain/stats/producer/ProducerFlexbox.tsx +0 -32
  100. package/src/components/chain/stats/producer/Table.tsx +0 -39
  101. package/src/components/chain/stats/producer/index.ts +0 -2
  102. package/src/components/chain/styled/BlockListWrapperFlexbox.tsx +0 -15
  103. package/src/components/chain/styled/index.ts +0 -1
  104. package/src/components/index.ts +0 -7
  105. package/src/components/payload/builder/BuilderComponentProps.ts +0 -5
  106. package/src/components/payload/builder/Flexbox.tsx +0 -30
  107. package/src/components/payload/builder/index.ts +0 -4
  108. package/src/components/payload/builder/producer-intent/Flexbox.stories.tsx +0 -14
  109. package/src/components/payload/builder/producer-intent/Flexbox.tsx +0 -15
  110. package/src/components/payload/builder/producer-intent/Form.tsx +0 -69
  111. package/src/components/payload/builder/producer-intent/index.ts +0 -1
  112. package/src/components/payload/builder/transfer/Flexbox.stories.tsx +0 -14
  113. package/src/components/payload/builder/transfer/Flexbox.tsx +0 -15
  114. package/src/components/payload/builder/transfer/Form.tsx +0 -82
  115. package/src/components/payload/builder/transfer/Transfer.ts +0 -3
  116. package/src/components/payload/builder/transfer/builder/SingleFlexbox.tsx +0 -51
  117. package/src/components/payload/builder/transfer/builder/index.ts +0 -1
  118. package/src/components/payload/builder/transfer/index.ts +0 -2
  119. package/src/components/payload/fields/BlockNumberTextField.tsx +0 -40
  120. package/src/components/payload/fields/XyoAddressTextField.tsx +0 -71
  121. package/src/components/payload/fields/index.ts +0 -2
  122. package/src/components/payload/index.ts +0 -2
  123. package/src/components/rate/SpanTypography.tsx +0 -20
  124. package/src/components/rate/SpeedTypography.tsx +0 -17
  125. package/src/components/rate/TimeTypography.tsx +0 -17
  126. package/src/components/rate/flexbox/FlexBox.stories.tsx +0 -46
  127. package/src/components/rate/flexbox/FlexBox.tsx +0 -31
  128. package/src/components/rate/flexbox/index.ts +0 -1
  129. package/src/components/rate/gauge/Container.stories.tsx +0 -80
  130. package/src/components/rate/gauge/Container.tsx +0 -75
  131. package/src/components/rate/gauge/Pointer.tsx +0 -67
  132. package/src/components/rate/gauge/Ticks.tsx +0 -122
  133. package/src/components/rate/gauge/WithLabel.stories.tsx +0 -73
  134. package/src/components/rate/gauge/WithLabel.tsx +0 -20
  135. package/src/components/rate/gauge/helpers/blockRateConversions.ts +0 -104
  136. package/src/components/rate/gauge/helpers/index.ts +0 -1
  137. package/src/components/rate/gauge/index.ts +0 -4
  138. package/src/components/rate/index.ts +0 -6
  139. package/src/components/rate/support/MetricTypography.tsx +0 -78
  140. package/src/components/rate/support/index.ts +0 -1
  141. package/src/components/table/StyledLinkableTableRow.tsx +0 -12
  142. package/src/components/table/index.ts +0 -1
  143. package/src/components/transactions/TransactionCountChip.tsx +0 -34
  144. package/src/components/transactions/TransactionsQuickTipButton.tsx +0 -86
  145. package/src/components/transactions/index.ts +0 -3
  146. package/src/components/transactions/submit/Builder.tsx +0 -55
  147. package/src/components/transactions/submit/Network.tsx +0 -36
  148. package/src/components/transactions/submit/SubmitChain.stories.tsx +0 -14
  149. package/src/components/transactions/submit/SubmitChain.tsx +0 -91
  150. package/src/components/transactions/submit/index.ts +0 -3
  151. package/src/context/analyzer/Provider.tsx +0 -41
  152. package/src/context/analyzer/context.ts +0 -5
  153. package/src/context/analyzer/index.ts +0 -5
  154. package/src/context/analyzer/state.ts +0 -13
  155. package/src/context/analyzer/use.ts +0 -6
  156. package/src/context/chain/Context.ts +0 -5
  157. package/src/context/chain/Provider.tsx +0 -49
  158. package/src/context/chain/State.ts +0 -8
  159. package/src/context/chain/index.ts +0 -4
  160. package/src/context/chain/use.ts +0 -6
  161. package/src/context/index.ts +0 -3
  162. package/src/context/polling/Provider.tsx +0 -27
  163. package/src/context/polling/context.ts +0 -5
  164. package/src/context/polling/index.ts +0 -4
  165. package/src/context/polling/state.ts +0 -8
  166. package/src/context/polling/use.ts +0 -5
  167. package/src/helpers/index.ts +0 -1
  168. package/src/helpers/rate/index.ts +0 -1
  169. package/src/helpers/rate/rateUnitToLabel.ts +0 -27
  170. package/src/helpers/txsFromBlock.ts +0 -12
  171. package/src/hooks/chain-iterator/index.ts +0 -1
  172. package/src/hooks/chain-iterator/useChainIteratorParams.ts +0 -55
  173. package/src/hooks/index.ts +0 -3
  174. package/src/hooks/useBaseContext.ts +0 -8
  175. package/src/hooks/useTxsFromBlock.ts +0 -12
  176. package/src/index.ts +0 -3
  177. package/src/lib/getChainArchivist.ts +0 -20
  178. package/src/lib/getChainId.ts +0 -8
  179. package/src/lib/index.ts +0 -2
  180. package/src/stories/ChainArchivistDecorator.tsx +0 -43
  181. package/src/stories/ChainArchivistDelayedInsertDecorator.tsx +0 -71
  182. package/src/stories/index.ts +0 -2
  183. package/src/types/BlockComponentProps.ts +0 -13
  184. package/src/types/BlockComponents.ts +0 -7
  185. package/src/types/BlockListComponentProps.ts +0 -6
  186. package/src/types/global.d.ts +0 -1
  187. package/src/types/index.ts +0 -4
  188. package/src/types/render/BlockChainRenderProps.ts +0 -28
  189. package/src/types/render/RemoteArchivistProps.ts +0 -5
  190. package/src/types/render/flexbox/BlockChainRenderFlexboxProps.ts +0 -8
  191. package/src/types/render/flexbox/RenderFlexboxProps.ts +0 -5
  192. package/src/types/render/flexbox/index.ts +0 -2
  193. package/src/types/render/index.ts +0 -4
  194. package/src/types/render/table/BlockChainRenderTableExProps.ts +0 -8
  195. package/src/types/render/table/RenderTableProps.ts +0 -5
  196. package/src/types/render/table/index.ts +0 -2
@@ -1,67 +0,0 @@
1
- import { useTheme } from '@mui/material'
2
- import { useGaugeState } from '@mui/x-charts/Gauge'
3
- import { isDefined } from '@xylabs/sdk-js'
4
- import { useEffect, useState } from 'react'
5
-
6
- export interface GaugePointerProps {
7
- pointerColor?: string
8
- startAngle?: number
9
- }
10
-
11
- export const GaugePointer: React.FC<GaugePointerProps> = ({ pointerColor, startAngle = 0 }) => {
12
- const theme = useTheme()
13
- const strokeColor = isDefined(pointerColor) ? pointerColor : theme.palette.error.dark
14
- const {
15
- valueAngle, outerRadius, cx, cy,
16
- } = useGaugeState()
17
-
18
- const [currentAngle, setCurrentAngle] = useState(startAngle)
19
-
20
- useEffect(() => {
21
- if (valueAngle === null) return
22
-
23
- const duration = 500 // 0.5 second animation
24
- const startTime = Date.now()
25
- const animationStartAngle = currentAngle // Start from current position
26
- const endAngle = valueAngle
27
-
28
- const animate = () => {
29
- const now = Date.now()
30
- const elapsed = now - startTime
31
- const progress = Math.min(elapsed / duration, 1)
32
-
33
- // Ease-out cubic for smooth deceleration
34
- const easeProgress = 1 - Math.pow(1 - progress, 3)
35
-
36
- // take the current angle and add the difference to the end angle based on progress
37
- const newAngle = animationStartAngle + (endAngle - animationStartAngle) * easeProgress
38
- setCurrentAngle(newAngle)
39
-
40
- if (progress < 1) {
41
- globalThis.requestAnimationFrame(animate)
42
- }
43
- }
44
-
45
- globalThis.requestAnimationFrame(animate)
46
- }, [currentAngle, valueAngle])
47
-
48
- if (valueAngle === null) {
49
- // No value to display
50
- return null
51
- }
52
-
53
- const target = {
54
- x: cx + outerRadius * Math.sin(currentAngle),
55
- y: cy - outerRadius * Math.cos(currentAngle),
56
- }
57
- return (
58
- <g className="GaugePointer">
59
- <circle cx={cx} cy={cy} r={5} fill={strokeColor} />
60
- <path
61
- d={`M ${cx} ${cy} L ${target.x} ${target.y}`}
62
- stroke={strokeColor}
63
- strokeWidth={3}
64
- />
65
- </g>
66
- )
67
- }
@@ -1,122 +0,0 @@
1
- import { useTheme } from '@mui/material'
2
- import { useGaugeState } from '@mui/x-charts/Gauge'
3
- import { isDefined } from '@xylabs/sdk-js'
4
- import type { JSX } from 'react'
5
-
6
- export interface GaugeTicksProps {
7
- /**
8
- * Length of major ticks as a percentage of the radius
9
- * @default 0.15
10
- */
11
- majorTickLength?: number
12
- /**
13
- * Width of major ticks in pixels
14
- * @default 2
15
- */
16
- majorTickWidth?: number
17
- /**
18
- * Length of minor ticks as a percentage of the radius
19
- * @default 0.08
20
- */
21
- minorTickLength?: number
22
- /**
23
- * Width of minor ticks in pixels
24
- * @default 1
25
- */
26
- minorTickWidth?: number
27
- /**
28
- * Number of minor ticks between major ticks
29
- * @default 4
30
- */
31
- minorTicksPerMajor?: number
32
- /**
33
- * Number of major ticks to display
34
- * @default 11
35
- */
36
- numTicks?: number
37
- /**
38
- * Color of the ticks
39
- */
40
- tickColor?: string
41
- }
42
-
43
- export const GaugeTicks: React.FC<GaugeTicksProps> = ({
44
- numTicks = 11,
45
- minorTicksPerMajor = 4,
46
- majorTickLength = 0.2,
47
- minorTickLength = 0.15,
48
- majorTickWidth = 2,
49
- minorTickWidth = 1,
50
- tickColor,
51
- }) => {
52
- const theme = useTheme()
53
- const {
54
- startAngle, endAngle, outerRadius, cx, cy,
55
- } = useGaugeState()
56
-
57
- const color = isDefined(tickColor) ? tickColor : theme.vars.palette.text.secondary
58
-
59
- if (startAngle === null || endAngle === null) {
60
- return null
61
- }
62
-
63
- const ticks: JSX.Element[] = []
64
- const totalAngle = endAngle - startAngle
65
-
66
- // Generate major ticks
67
- for (let i = 0; i < numTicks; i++) {
68
- const angle = startAngle + (i / (numTicks - 1)) * totalAngle
69
- const tickLength = outerRadius * majorTickLength
70
- const tickStart = outerRadius
71
- const innerRadius = tickStart - tickLength
72
-
73
- const x1 = cx + tickStart * Math.sin(angle)
74
- const y1 = cy - tickStart * Math.cos(angle)
75
- const x2 = cx + innerRadius * Math.sin(angle)
76
- const y2 = cy - innerRadius * Math.cos(angle)
77
-
78
- ticks.push(
79
- <line
80
- className={`GaugeTick-major-${i}`}
81
- key={`major-${i}`}
82
- x1={x1}
83
- y1={y1}
84
- x2={x2}
85
- y2={y2}
86
- stroke={color}
87
- strokeWidth={majorTickWidth}
88
- // strokeLinecap="round"
89
- />,
90
- )
91
- // Generate minor ticks between major ticks (except after the last major tick)
92
- if (i < numTicks - 1) {
93
- const angleStep = totalAngle / (numTicks - 1) / (minorTicksPerMajor + 1)
94
- for (let j = 1; j <= minorTicksPerMajor; j++) {
95
- const minorAngle = angle + angleStep * j
96
- const minorTickLen = outerRadius * minorTickLength
97
- const minorTickStart = outerRadius
98
- const minorInnerRadius = minorTickStart - minorTickLen
99
-
100
- const mx1 = cx + minorTickStart * Math.sin(minorAngle)
101
- const my1 = cy - minorTickStart * Math.cos(minorAngle)
102
- const mx2 = cx + minorInnerRadius * Math.sin(minorAngle)
103
- const my2 = cy - minorInnerRadius * Math.cos(minorAngle)
104
-
105
- ticks.push(
106
- <line
107
- key={`minor-${i}-${j}`}
108
- x1={mx1}
109
- y1={my1}
110
- x2={mx2}
111
- y2={my2}
112
- stroke={color}
113
- strokeWidth={minorTickWidth}
114
- // strokeLinecap="round"
115
- />,
116
- )
117
- }
118
- }
119
- }
120
-
121
- return <g className="GaugeTicks">{ticks}</g>
122
- }
@@ -1,73 +0,0 @@
1
- import type { Meta, StoryFn } from '@storybook/react-vite'
2
- import type { BlockRate } from '@xyo-network/xl1-sdk'
3
- import { asXL1BlockRange } from '@xyo-network/xl1-sdk'
4
-
5
- import type { GaugeConfig } from './Container.tsx'
6
- import { BlockRateSpeedGaugeWithLabel } from './WithLabel.tsx'
7
-
8
- const blockRateSeconds: BlockRate = {
9
- range: asXL1BlockRange([100, 200], true),
10
- span: 100,
11
- rate: 0.083_33,
12
- timeUnit: 'seconds',
13
- timeDifference: (100 * 12),
14
- timePerBlock: 12,
15
- }
16
-
17
- const blockRateMinutes: BlockRate = {
18
- range: asXL1BlockRange([100, 200], true),
19
- span: 100,
20
- rate: 5,
21
- timeUnit: 'minutes',
22
- timeDifference: (100 * 12) / 60,
23
- timePerBlock: 12,
24
- }
25
-
26
- const blockRateHour: BlockRate = {
27
- range: asXL1BlockRange([100, 200], true),
28
- span: 100,
29
- rate: 7 * 60,
30
- timeUnit: 'hours',
31
- timeDifference: (100 * 12) / 60,
32
- timePerBlock: 12,
33
- }
34
-
35
- const gaugeConfigHours: GaugeConfig = {
36
- targetBlockRate: 5 * 60,
37
- targetBlockRateUnit: 'hours',
38
- targetPosition: 75,
39
- }
40
-
41
- const gaugeConfigMinutes: GaugeConfig = {
42
- targetBlockRate: 5,
43
- targetBlockRateUnit: 'minutes',
44
- targetPosition: 75,
45
- }
46
-
47
- export default {
48
- title: 'BlockRate/Gauge/Label',
49
- component: BlockRateSpeedGaugeWithLabel,
50
- } satisfies Meta<typeof BlockRateSpeedGaugeWithLabel>
51
-
52
- const Template: StoryFn<typeof BlockRateSpeedGaugeWithLabel> = (args) => {
53
- return <BlockRateSpeedGaugeWithLabel {...args} />
54
- }
55
-
56
- const Default = Template.bind({})
57
- Default.args = {}
58
-
59
- const WithBlockRateSeconds = Template.bind({})
60
- WithBlockRateSeconds.args = { blockRate: blockRateSeconds }
61
-
62
- const WithBlockRateMinutes = Template.bind({})
63
- WithBlockRateMinutes.args = { blockRate: blockRateMinutes, gaugeConfig: gaugeConfigMinutes }
64
-
65
- const WithBlockRateHours = Template.bind({})
66
- WithBlockRateHours.args = { blockRate: blockRateHour, gaugeConfig: gaugeConfigHours }
67
-
68
- export {
69
- Default,
70
- WithBlockRateHours,
71
- WithBlockRateMinutes,
72
- WithBlockRateSeconds,
73
- }
@@ -1,20 +0,0 @@
1
- import { FlexCol } from '@xylabs/react-flexbox'
2
- import { isDefined } from '@xylabs/sdk-js'
3
-
4
- import { rateUnitToLabel } from '../../../helpers/rate/index.ts'
5
- import { BlockRateSpeedTypography } from '../SpeedTypography.tsx'
6
- import type { BlockRateSpeedGaugeProps } from './Container.tsx'
7
- import { BlockRateSpeedGaugeContainer } from './Container.tsx'
8
-
9
- export interface BlockRateSpeedGaugeWithLabelProps extends BlockRateSpeedGaugeProps {}
10
-
11
- export const BlockRateSpeedGaugeWithLabel: React.FC<BlockRateSpeedGaugeProps> = ({ blockRate, ...props }) => {
12
- const rateUnitLabel = isDefined(blockRate?.rate) ? rateUnitToLabel(blockRate?.timeUnit) : ''
13
-
14
- return (
15
- <FlexCol>
16
- <BlockRateSpeedGaugeContainer blockRate={blockRate} {...props} />
17
- <BlockRateSpeedTypography rate={blockRate?.rate} rateUnitLabel={rateUnitLabel} />
18
- </FlexCol>
19
- )
20
- }
@@ -1,104 +0,0 @@
1
- import { isDefined, isUndefined } from '@xylabs/sdk-js'
2
- import type { TimeDurations } from '@xyo-network/xl1-sdk'
3
-
4
- export type BlockRateConverter = (rateValue: number, unit?: keyof TimeDurations) => number
5
-
6
- const toBlocksPerMillisecond: BlockRateConverter = (rateValue: number, unit?: keyof TimeDurations): number => {
7
- if (isUndefined(unit)) return rateValue
8
-
9
- const conversions: Record<keyof TimeDurations, number> = {
10
- millis: 1, // already in milliseconds
11
- seconds: 1000, // 1 second = 1000 milliseconds
12
- minutes: 60_000, // 1 minute = 60000 milliseconds
13
- hours: 3_600_000, // 1 hour = 3600000 milliseconds
14
- days: 86_400_000, // 1 day = 86400000 milliseconds
15
- weeks: 604_800_000, // 1 week = 604800000 milliseconds
16
- }
17
-
18
- return rateValue * (isDefined(conversions[unit]) ? conversions[unit] : 1)
19
- }
20
-
21
- const toBlocksPerSecond: BlockRateConverter = (rateValue: number, unit?: keyof TimeDurations): number => {
22
- if (isUndefined(unit)) return rateValue
23
-
24
- const conversions: Record<keyof TimeDurations, number> = {
25
- millis: 0.001, // 1 millisecond = 0.001 seconds
26
- seconds: 1, // already in seconds
27
- minutes: 60, // 1 minute = 60 seconds
28
- hours: 3600, // 1 hour = 3600 seconds
29
- days: 86_400, // 1 day = 86400 seconds
30
- weeks: 604_800, // 1 week = 604800 seconds
31
- }
32
-
33
- return rateValue * (isDefined(conversions[unit]) ? conversions[unit] : 1)
34
- }
35
-
36
- // Convert rate to blocks per minute based on the unit
37
- const toBlocksPerMinute: BlockRateConverter = (rateValue: number, unit?: keyof TimeDurations): number => {
38
- if (isUndefined(unit)) return rateValue
39
-
40
- const conversions: Record<keyof TimeDurations, number> = {
41
- millis: 60_000, // 1 minute = 60000 milliseconds
42
- seconds: 60, // 1 minute = 60 seconds
43
- minutes: 1, // already in minutes
44
- hours: 1 / 60, // 1 hour = 60 minutes
45
- days: 1 / 1440, // 1 day = 1440 minutes
46
- weeks: 1 / 10_080, // 1 week = 10080 minutes
47
- }
48
-
49
- return rateValue * (isDefined(conversions[unit]) ? conversions[unit] : 1)
50
- }
51
-
52
- const toBlocksPerHour: BlockRateConverter = (rateValue: number, unit?: keyof TimeDurations): number => {
53
- if (isUndefined(unit)) return rateValue
54
-
55
- const conversions: Record<keyof TimeDurations, number> = {
56
- millis: 3_600_000, // 1 hour = 3600000 milliseconds
57
- seconds: 3600, // 1 hour = 3600 seconds
58
- minutes: 60, // 1 hour = 60 minutes
59
- hours: 1, // already in hours
60
- days: 1 / 24, // 1 day = 24 hours
61
- weeks: 1 / 168, // 1 week = 168 hours
62
- }
63
-
64
- return rateValue * (isDefined(conversions[unit]) ? conversions[unit] : 1)
65
- }
66
-
67
- const toBlocksPerDay: BlockRateConverter = (rateValue: number, unit?: keyof TimeDurations): number => {
68
- if (isUndefined(unit)) return rateValue
69
-
70
- const conversions: Record<keyof TimeDurations, number> = {
71
- millis: 86_400_000, // 1 day = 86400000 milliseconds
72
- seconds: 86_400, // 1 day = 86400 seconds
73
- minutes: 1440, // 1 day = 1440 minutes
74
- hours: 24, // 1 day = 24 hours
75
- days: 1, // already in days
76
- weeks: 1 / 7, // 1 week = 7 days
77
- }
78
-
79
- return rateValue * (isDefined(conversions[unit]) ? conversions[unit] : 1)
80
- }
81
-
82
- const toBlocksPerWeek: BlockRateConverter = (rateValue: number, unit?: keyof TimeDurations): number => {
83
- if (isUndefined(unit)) return rateValue
84
-
85
- const conversions: Record<keyof TimeDurations, number> = {
86
- millis: 604_800_000, // 1 week = 604800000 milliseconds
87
- seconds: 604_800, // 1 week = 604800 seconds
88
- minutes: 10_080, // 1 week = 10080 minutes
89
- hours: 168, // 1 week = 168 hours
90
- days: 7, // 1 week = 7 days
91
- weeks: 1, // already in weeks
92
- }
93
-
94
- return rateValue * (isDefined(conversions[unit]) ? conversions[unit] : 1)
95
- }
96
-
97
- export const BlockRateConversions: Record<keyof TimeDurations, BlockRateConverter> = {
98
- millis: toBlocksPerMillisecond,
99
- seconds: toBlocksPerSecond,
100
- minutes: toBlocksPerMinute,
101
- hours: toBlocksPerHour,
102
- days: toBlocksPerDay,
103
- weeks: toBlocksPerWeek,
104
- }
@@ -1 +0,0 @@
1
- export * from './blockRateConversions.ts'
@@ -1,4 +0,0 @@
1
- export * from './Container.tsx'
2
- export * from './Pointer.tsx'
3
- export * from './Ticks.tsx'
4
- export * from './WithLabel.tsx'
@@ -1,6 +0,0 @@
1
- export * from './flexbox/index.ts'
2
- export * from './gauge/index.ts'
3
- export * from './SpanTypography.tsx'
4
- export * from './SpeedTypography.tsx'
5
- export * from './support/index.ts'
6
- export * from './TimeTypography.tsx'
@@ -1,78 +0,0 @@
1
- import type { TypographyProps } from '@mui/material'
2
- import { Icon, Typography } from '@mui/material'
3
- import { isUndefined } from '@xylabs/sdk-js'
4
- import type { ReactNode } from 'react'
5
- import { useEffect, useState } from 'react'
6
-
7
- export interface MetricTypographyProps extends TypographyProps {
8
- animationDurationMs?: number
9
- disableAnimation?: boolean
10
- icon?: ReactNode
11
- label?: ReactNode
12
- metric?: number
13
- }
14
-
15
- export const MetricTypography: React.FC<MetricTypographyProps> = ({
16
- animationDurationMs = 1000, disableAnimation, icon, label, metric, sx, ...props
17
- }) => {
18
- const [displayValue, setDisplayValue] = useState(0)
19
-
20
- if (isUndefined(metric) && displayValue !== 0) {
21
- setDisplayValue(0)
22
- }
23
-
24
- useEffect(() => {
25
- if (isUndefined(metric)) return
26
- const duration = animationDurationMs
27
- const startTime = Date.now()
28
- const startValue = 0
29
- const endValue = metric
30
-
31
- const animate = () => {
32
- const now = Date.now()
33
- const elapsed = now - startTime
34
- const progress = Math.min(elapsed / duration, 1)
35
-
36
- // Easing function for smooth animation (ease-out
37
- const easeProgress = 1 - Math.pow(1 - progress, 3)
38
-
39
- const currentValue = startValue + (endValue - startValue) * easeProgress
40
- setDisplayValue(currentValue)
41
-
42
- if (progress < 1) {
43
- requestAnimationFrame(animate)
44
- }
45
- }
46
-
47
- globalThis.requestAnimationFrame(animate)
48
- }, [animationDurationMs, metric])
49
-
50
- // Check if metric is a whole number
51
- const isWholeNumber = metric !== undefined && Number.isInteger(metric)
52
-
53
- // Format based on whether the target is a whole number
54
- const formattedValue = disableAnimation
55
- ? metric
56
- : displayValue.toLocaleString(navigator.language, {
57
- minimumFractionDigits: 0,
58
- maximumFractionDigits: isWholeNumber ? 0 : 2,
59
- })
60
-
61
- return (
62
- <Typography
63
- variant="h4"
64
- mb={1}
65
- sx={{
66
- display: 'flex', alignItems: 'end', gap: 0.5, ...sx,
67
- }}
68
- {...props}
69
- >
70
- <Icon fontSize="large">{icon}</Icon>
71
- {formattedValue}
72
- {' '}
73
- <Typography component="span" variant="caption" lineHeight={1.86}>
74
- {label}
75
- </Typography>
76
- </Typography>
77
- )
78
- }
@@ -1 +0,0 @@
1
- export * from './MetricTypography.tsx'
@@ -1,12 +0,0 @@
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
- ))
@@ -1 +0,0 @@
1
- export * from './StyledLinkableTableRow.tsx'
@@ -1,34 +0,0 @@
1
- import CompareArrowsIcon from '@mui/icons-material/CompareArrows'
2
- import type { ChipProps } from '@mui/material'
3
- import { Chip, Icon } from '@mui/material'
4
- import type { Hash } from '@xylabs/sdk-js'
5
- import React, { useMemo } from 'react'
6
-
7
- export interface TransactionCountChipProps extends ChipProps {
8
- transactions?: Hash[]
9
- }
10
-
11
- export const TransactionCountChip: React.FC<TransactionCountChipProps> = ({
12
- transactions, sx, ...props
13
- }) => {
14
- const label = useMemo(() => {
15
- if (!transactions) return '0'
16
- return transactions?.length > 10 ? '+10' : transactions.length
17
- }, [transactions])
18
-
19
- return (
20
- <Chip
21
- avatar={(
22
- <Icon>
23
- <CompareArrowsIcon />
24
- </Icon>
25
- )}
26
- label={label}
27
- title={transactions ? `Block contains ${transactions.length} transactions` : undefined}
28
- sx={{
29
- display: 'inline-flex', alignItems: 'center', justifyContent: 'center', ...sx,
30
- }}
31
- {...props}
32
- />
33
- )
34
- }
@@ -1,86 +0,0 @@
1
- import { ContentCopy as ContentCopyIcon, Paid } from '@mui/icons-material'
2
- import {
3
- Alert, AlertTitle, Collapse, Snackbar, Typography,
4
- } from '@mui/material'
5
- import { ErrorRender } from '@xylabs/react-error'
6
- import {
7
- FlexGrowCol, FlexGrowRow, FlexRow,
8
- } from '@xylabs/react-flexbox'
9
- import type { QuickTipButtonProps } from '@xylabs/react-quick-tip-button'
10
- import { QuickTipButton } from '@xylabs/react-quick-tip-button'
11
- import { type Hash, isDefined } from '@xylabs/sdk-js'
12
- import type { HydratedBlockWithHashMeta } from '@xyo-network/xl1-sdk'
13
- import React, { Fragment, useState } from 'react'
14
-
15
- import { useTxsFromBlock } from '../../hooks/index.ts'
16
-
17
- export interface TransactionsQuickTipButtonQuickTipButtonProps extends QuickTipButtonProps {
18
- block?: HydratedBlockWithHashMeta
19
- }
20
-
21
- export const TransactionsQuickTipButton: React.FC<TransactionsQuickTipButtonQuickTipButtonProps> = ({ block, ...props }) => {
22
- const [transactions, transactionsError] = useTxsFromBlock(block)
23
-
24
- const [copied, setCopied] = useState(false)
25
-
26
- const [closeDialog, setCloseDialog] = useState(false)
27
- const open = isDefined(transactionsError)
28
-
29
- // if the error changes, reopen the dialog
30
- const [previousTransactionError, setPreviousTransactionError] = useState<Error | undefined>(transactionsError)
31
- if (isDefined(transactionsError) && transactionsError !== previousTransactionError) {
32
- setPreviousTransactionError(transactionsError)
33
- setCloseDialog(false)
34
- }
35
-
36
- const onCopy = async (transactionHash: Hash) => {
37
- await navigator.clipboard.writeText(transactionHash)
38
- setCopied(true)
39
- setTimeout(() => {
40
- setCopied(false)
41
- }, 5000)
42
- }
43
-
44
- return (
45
- <>
46
- <QuickTipButton
47
- Icon={Paid}
48
- disabled={transactions?.length === 0}
49
- hoverText={`Transaction Count: ${transactions?.length ?? 0}`}
50
- disableDialog={transactions?.length === 0}
51
- dialogProps={{ fullWidth: true, maxWidth: 'md' }}
52
- {...props}
53
- >
54
- {transactions?.length === 0
55
- ? null
56
- : (
57
- <FlexGrowCol gap={1} alignItems="stretch">
58
- {transactions?.map(([_transaction, hash]) => (
59
- <Fragment key={hash}>
60
- <FlexGrowRow gap={2} justifyContent="start">
61
- <ContentCopyIcon sx={{ cursor: 'pointer' }} onClick={() => void onCopy(hash)} />
62
- <Typography sx={{
63
- overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap',
64
- }}
65
- >
66
- {hash}
67
- </Typography>
68
- </FlexGrowRow>
69
- <FlexRow>
70
- <Collapse in={copied} unmountOnExit>
71
- <Alert>
72
- <AlertTitle>Previous hash copied to clipboard</AlertTitle>
73
- </Alert>
74
- </Collapse>
75
- </FlexRow>
76
- </Fragment>
77
- ))}
78
- </FlexGrowCol>
79
- )}
80
- </QuickTipButton>
81
- <Snackbar open={open && closeDialog === false} onClose={() => setCloseDialog(true)}>
82
- <ErrorRender error={transactionsError} scope="TransactionsQuickTipButton" />
83
- </Snackbar>
84
- </>
85
- )
86
- }
@@ -1,3 +0,0 @@
1
- export * from './submit/index.ts'
2
- export * from './TransactionCountChip.tsx'
3
- export * from './TransactionsQuickTipButton.tsx'
@@ -1,55 +0,0 @@
1
- import {
2
- Button, FormControl, TextField,
3
- } from '@mui/material'
4
- import { FlexCol } from '@xylabs/react-flexbox'
5
- import { toHex } from '@xylabs/sdk-js'
6
- import type { ChainId, TransactionBoundWitnessFields } from '@xyo-network/xl1-sdk'
7
- import { defaultTransactionFees, toXL1BlockNumber } from '@xyo-network/xl1-sdk'
8
- import React from 'react'
9
-
10
- export interface ChainTransactionBuilder {
11
- onSubmitTx?: (chainTx: Omit<TransactionBoundWitnessFields, 'from'>) => Promise<void>
12
- }
13
-
14
- export const ChainTransactionBuilder: React.FC<ChainTransactionBuilder> = ({ onSubmitTx }) => {
15
- const handleSubmit = async (event: React.SubmitEvent<HTMLFormElement>) => {
16
- event.preventDefault()
17
- const formData = new FormData(event.currentTarget)
18
-
19
- // TODO - more field level validation
20
- const chainTx: Omit<TransactionBoundWitnessFields, 'from'> = {
21
- chain: formData.get('chain') as ChainId,
22
- nbf: toXL1BlockNumber(formData.get('nbf'), true),
23
- exp: toXL1BlockNumber(formData.get('exp'), true),
24
- fees: {
25
- gasLimit: toHex(defaultTransactionFees.gasLimit),
26
- gasPrice: toHex(defaultTransactionFees.gasPrice),
27
- base: toHex(defaultTransactionFees.base),
28
- priority: toHex(defaultTransactionFees.priority),
29
- },
30
- }
31
-
32
- await onSubmitTx?.(chainTx)
33
- }
34
-
35
- return (
36
- <form onSubmit={event => void handleSubmit(event)} style={{ width: '100%' }}>
37
- <FlexCol gap={2}>
38
- <FormControl fullWidth>
39
- <TextField label="Chain Address" name="chain" required />
40
- </FormControl>
41
- <FormControl fullWidth>
42
- <TextField label="Gas" name="gas" required />
43
- </FormControl>
44
- <FormControl fullWidth>
45
- <TextField label="Not Before Block" name="nbf" required />
46
- </FormControl>
47
- <FormControl fullWidth>
48
- <TextField label="Not After Block" name="exp" required />
49
- </FormControl>
50
-
51
- <Button type="submit" variant="contained">Submit</Button>
52
- </FlexCol>
53
- </form>
54
- )
55
- }