@xyo-network/react-chain-blockchain 1.20.15 → 1.20.16
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/README.md +9 -8854
- package/dist/browser/components/block/table/cell/NumberChip.d.ts.map +1 -1
- package/dist/browser/components/chain/controls/PulseSvgIcon.d.ts +5 -2
- package/dist/browser/components/chain/controls/PulseSvgIcon.d.ts.map +1 -1
- package/dist/browser/components/chain/hooks/useOnBlock.d.ts +7 -7
- package/dist/browser/components/chain/styled/BlockListWrapperFlexbox.d.ts +6 -1
- package/dist/browser/components/chain/styled/BlockListWrapperFlexbox.d.ts.map +1 -1
- package/dist/browser/components/table/StyledLinkableTableRow.d.ts +5 -4
- package/dist/browser/components/table/StyledLinkableTableRow.d.ts.map +1 -1
- package/dist/browser/context/analyzer/context.d.ts +3 -3
- package/dist/browser/context/analyzer/use.d.ts +1 -1
- package/dist/browser/context/chain/Context.d.ts +3 -3
- package/dist/browser/context/chain/use.d.ts +1 -1
- package/dist/browser/hooks/useBaseContext.d.ts +2 -8
- package/dist/browser/hooks/useBaseContext.d.ts.map +1 -1
- package/dist/browser/hooks/useTxsFromBlock.d.ts +1 -1
- package/dist/browser/hooks/useTxsFromBlock.d.ts.map +1 -1
- package/dist/browser/index.mjs.map +1 -1
- package/package.json +167 -58
- package/src/components/FeatureNotAvailable.tsx +0 -20
- package/src/components/account/BalanceHistoryFlexbox.stories.tsx +0 -25
- package/src/components/account/BalanceHistoryFlexbox.tsx +0 -53
- package/src/components/account/helpers/formatBalanceMagnitude.ts +0 -14
- package/src/components/account/helpers/index.ts +0 -1
- package/src/components/account/hooks/index.ts +0 -1
- package/src/components/account/hooks/usePagedAccountBalanceHistory.ts +0 -39
- package/src/components/account/index.ts +0 -4
- package/src/components/account/table/BalanceHistoryTableEx.stories.tsx +0 -111
- package/src/components/account/table/BalanceHistoryTableEx.tsx +0 -37
- package/src/components/account/table/BalanceHistoryTableRow.stories.tsx +0 -53
- package/src/components/account/table/BalanceHistoryTableRow.tsx +0 -60
- package/src/components/account/table/RawAmountTableCell.tsx +0 -53
- package/src/components/account/table/cell/AddressTableCell.tsx +0 -27
- package/src/components/account/table/cell/BlockNumber.tsx +0 -39
- package/src/components/account/table/cell/HashTableCell.tsx +0 -46
- package/src/components/account/table/cell/index.ts +0 -3
- package/src/components/account/table/hooks/index.ts +0 -1
- package/src/components/account/table/hooks/useLinkedBalanceHistoryItem.tsx +0 -29
- package/src/components/account/table/index.ts +0 -5
- package/src/components/account/table/types/index.ts +0 -18
- package/src/components/block/BlockHeadingFlexbox.stories.tsx +0 -75
- package/src/components/block/BlockHeadingFlexbox.tsx +0 -56
- package/src/components/block/ChipSkeleton.tsx +0 -7
- package/src/components/block/LinkedDivider.tsx +0 -27
- package/src/components/block/ProducerChip.tsx +0 -45
- package/src/components/block/helpers/blockProducer.ts +0 -5
- package/src/components/block/helpers/buildBlockChainRenderComponent.tsx +0 -32
- package/src/components/block/helpers/index.ts +0 -3
- package/src/components/block/helpers/payloadCountsFromBlock.ts +0 -10
- package/src/components/block/hooks/index.ts +0 -4
- package/src/components/block/hooks/useAnchorElement.ts +0 -19
- package/src/components/block/hooks/useBlockHeadingEvents.ts +0 -11
- package/src/components/block/hooks/useBlockProducer.ts +0 -11
- package/src/components/block/hooks/usePayloadCountsFromBlock.ts +0 -13
- package/src/components/block/index.ts +0 -6
- package/src/components/block/menu/Expanded.tsx +0 -34
- package/src/components/block/menu/index.ts +0 -1
- package/src/components/block/table/Ex.stories.tsx +0 -64
- package/src/components/block/table/Ex.tsx +0 -21
- package/src/components/block/table/cell/BlockNumber.tsx +0 -35
- package/src/components/block/table/cell/Epoch.tsx +0 -46
- package/src/components/block/table/cell/Hash.tsx +0 -46
- package/src/components/block/table/cell/JsonView.tsx +0 -44
- package/src/components/block/table/cell/NumberChip.tsx +0 -12
- package/src/components/block/table/cell/PayloadCounts.tsx +0 -65
- package/src/components/block/table/cell/Producer.tsx +0 -63
- package/src/components/block/table/cell/TransactionCount.tsx +0 -56
- package/src/components/block/table/cell/Verification.tsx +0 -25
- package/src/components/block/table/cell/helpers/index.ts +0 -1
- package/src/components/block/table/cell/helpers/timeFunctions.ts +0 -44
- package/src/components/block/table/cell/hooks/index.ts +0 -1
- package/src/components/block/table/cell/hooks/useLinkedBlockItem.tsx +0 -25
- package/src/components/block/table/cell/index.ts +0 -8
- package/src/components/block/table/cell/lib/BlockTableCellProps.ts +0 -7
- package/src/components/block/table/cell/lib/index.ts +0 -1
- package/src/components/block/table/head/TableHead.tsx +0 -48
- package/src/components/block/table/head/index.ts +0 -1
- package/src/components/block/table/index.ts +0 -4
- package/src/components/block/table/row/TableRow.stories.tsx +0 -34
- package/src/components/block/table/row/TableRow.tsx +0 -46
- package/src/components/block/table/row/index.ts +0 -1
- package/src/components/chain/controls/PollingControlsFlexbox.tsx +0 -76
- package/src/components/chain/controls/PulseSvgIcon.tsx +0 -71
- package/src/components/chain/controls/index.ts +0 -2
- package/src/components/chain/dialog/Dialog.tsx +0 -20
- package/src/components/chain/dialog/index.ts +0 -1
- package/src/components/chain/hooks/index.ts +0 -1
- package/src/components/chain/hooks/useOnBlock.ts +0 -55
- package/src/components/chain/index.ts +0 -6
- package/src/components/chain/list/Animated.tsx +0 -19
- package/src/components/chain/list/TableEx.tsx +0 -12
- package/src/components/chain/list/index.ts +0 -2
- package/src/components/chain/pagination/BlockChainPagination.tsx +0 -11
- package/src/components/chain/pagination/hooks/index.ts +0 -1
- package/src/components/chain/pagination/hooks/usePagination.tsx +0 -22
- package/src/components/chain/pagination/index.ts +0 -2
- package/src/components/chain/stats/Dialog.tsx +0 -49
- package/src/components/chain/stats/index.ts +0 -1
- package/src/components/chain/stats/producer/ProducerFlexbox.tsx +0 -32
- package/src/components/chain/stats/producer/Table.tsx +0 -39
- package/src/components/chain/stats/producer/index.ts +0 -2
- package/src/components/chain/styled/BlockListWrapperFlexbox.tsx +0 -15
- package/src/components/chain/styled/index.ts +0 -1
- package/src/components/index.ts +0 -7
- package/src/components/payload/builder/BuilderComponentProps.ts +0 -5
- package/src/components/payload/builder/Flexbox.tsx +0 -30
- package/src/components/payload/builder/index.ts +0 -4
- package/src/components/payload/builder/producer-intent/Flexbox.stories.tsx +0 -14
- package/src/components/payload/builder/producer-intent/Flexbox.tsx +0 -15
- package/src/components/payload/builder/producer-intent/Form.tsx +0 -69
- package/src/components/payload/builder/producer-intent/index.ts +0 -1
- package/src/components/payload/builder/transfer/Flexbox.stories.tsx +0 -14
- package/src/components/payload/builder/transfer/Flexbox.tsx +0 -15
- package/src/components/payload/builder/transfer/Form.tsx +0 -82
- package/src/components/payload/builder/transfer/Transfer.ts +0 -3
- package/src/components/payload/builder/transfer/builder/SingleFlexbox.tsx +0 -51
- package/src/components/payload/builder/transfer/builder/index.ts +0 -1
- package/src/components/payload/builder/transfer/index.ts +0 -2
- package/src/components/payload/fields/BlockNumberTextField.tsx +0 -40
- package/src/components/payload/fields/XyoAddressTextField.tsx +0 -71
- package/src/components/payload/fields/index.ts +0 -2
- package/src/components/payload/index.ts +0 -2
- package/src/components/rate/SpanTypography.tsx +0 -20
- package/src/components/rate/SpeedTypography.tsx +0 -17
- package/src/components/rate/TimeTypography.tsx +0 -17
- package/src/components/rate/flexbox/FlexBox.stories.tsx +0 -46
- package/src/components/rate/flexbox/FlexBox.tsx +0 -31
- package/src/components/rate/flexbox/index.ts +0 -1
- package/src/components/rate/gauge/Container.stories.tsx +0 -80
- package/src/components/rate/gauge/Container.tsx +0 -75
- package/src/components/rate/gauge/Pointer.tsx +0 -67
- package/src/components/rate/gauge/Ticks.tsx +0 -122
- package/src/components/rate/gauge/WithLabel.stories.tsx +0 -73
- package/src/components/rate/gauge/WithLabel.tsx +0 -20
- package/src/components/rate/gauge/helpers/blockRateConversions.ts +0 -104
- package/src/components/rate/gauge/helpers/index.ts +0 -1
- package/src/components/rate/gauge/index.ts +0 -4
- package/src/components/rate/index.ts +0 -6
- package/src/components/rate/support/MetricTypography.tsx +0 -78
- package/src/components/rate/support/index.ts +0 -1
- package/src/components/table/StyledLinkableTableRow.tsx +0 -12
- package/src/components/table/index.ts +0 -1
- package/src/components/transactions/TransactionCountChip.tsx +0 -34
- package/src/components/transactions/TransactionsQuickTipButton.tsx +0 -86
- package/src/components/transactions/index.ts +0 -3
- package/src/components/transactions/submit/Builder.tsx +0 -55
- package/src/components/transactions/submit/Network.tsx +0 -36
- package/src/components/transactions/submit/SubmitChain.stories.tsx +0 -14
- package/src/components/transactions/submit/SubmitChain.tsx +0 -91
- package/src/components/transactions/submit/index.ts +0 -3
- package/src/context/analyzer/Provider.tsx +0 -41
- package/src/context/analyzer/context.ts +0 -5
- package/src/context/analyzer/index.ts +0 -5
- package/src/context/analyzer/state.ts +0 -13
- package/src/context/analyzer/use.ts +0 -6
- package/src/context/chain/Context.ts +0 -5
- package/src/context/chain/Provider.tsx +0 -49
- package/src/context/chain/State.ts +0 -8
- package/src/context/chain/index.ts +0 -4
- package/src/context/chain/use.ts +0 -6
- package/src/context/index.ts +0 -3
- package/src/context/polling/Provider.tsx +0 -27
- package/src/context/polling/context.ts +0 -5
- package/src/context/polling/index.ts +0 -4
- package/src/context/polling/state.ts +0 -8
- package/src/context/polling/use.ts +0 -5
- package/src/helpers/index.ts +0 -1
- package/src/helpers/rate/index.ts +0 -1
- package/src/helpers/rate/rateUnitToLabel.ts +0 -27
- package/src/helpers/txsFromBlock.ts +0 -12
- package/src/hooks/chain-iterator/index.ts +0 -1
- package/src/hooks/chain-iterator/useChainIteratorParams.ts +0 -55
- package/src/hooks/index.ts +0 -3
- package/src/hooks/useBaseContext.ts +0 -8
- package/src/hooks/useTxsFromBlock.ts +0 -12
- package/src/index.ts +0 -3
- package/src/lib/getChainArchivist.ts +0 -20
- package/src/lib/getChainId.ts +0 -8
- package/src/lib/index.ts +0 -2
- package/src/stories/ChainArchivistDecorator.tsx +0 -43
- package/src/stories/ChainArchivistDelayedInsertDecorator.tsx +0 -71
- package/src/stories/index.ts +0 -2
- package/src/types/BlockComponentProps.ts +0 -13
- package/src/types/BlockComponents.ts +0 -7
- package/src/types/BlockListComponentProps.ts +0 -6
- package/src/types/global.d.ts +0 -1
- package/src/types/index.ts +0 -4
- package/src/types/render/BlockChainRenderProps.ts +0 -28
- package/src/types/render/RemoteArchivistProps.ts +0 -5
- package/src/types/render/flexbox/BlockChainRenderFlexboxProps.ts +0 -8
- package/src/types/render/flexbox/RenderFlexboxProps.ts +0 -5
- package/src/types/render/flexbox/index.ts +0 -2
- package/src/types/render/index.ts +0 -4
- package/src/types/render/table/BlockChainRenderTableExProps.ts +0 -8
- package/src/types/render/table/RenderTableProps.ts +0 -5
- package/src/types/render/table/index.ts +0 -2
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { Button, FormControl } from '@mui/material'
|
|
2
|
-
import { usePromise } from '@xylabs/react-promise'
|
|
3
|
-
import type { Address } from '@xylabs/sdk-js'
|
|
4
|
-
import { createProducerChainStakeIntent } from '@xyo-network/chain-protocol'
|
|
5
|
-
import type { XL1BlockNumber } from '@xyo-network/xl1-sdk'
|
|
6
|
-
import type { MouseEventHandler } from 'react'
|
|
7
|
-
import React, { useState } from 'react'
|
|
8
|
-
|
|
9
|
-
import { BlockNumberTextField, XyoAddressTextField } from '../../fields/index.ts'
|
|
10
|
-
import type { PayloadBuilderComponentProps } from '../BuilderComponentProps.ts'
|
|
11
|
-
|
|
12
|
-
export interface ProducerIntentBuilderFormProps extends PayloadBuilderComponentProps {}
|
|
13
|
-
|
|
14
|
-
export const ProducerIntentBuilderForm: React.FC<ProducerIntentBuilderFormProps> = ({ onBuild }) => {
|
|
15
|
-
const [delegate, setDelegate] = useState<Address>()
|
|
16
|
-
const [exp, setExp] = useState<XL1BlockNumber>()
|
|
17
|
-
const [nbf, setNbf] = useState<XL1BlockNumber>()
|
|
18
|
-
const [blockRangeError, setBlockRangeError] = useState<Error>()
|
|
19
|
-
|
|
20
|
-
const [intentPayload] = usePromise(async () => {
|
|
21
|
-
// confirm we have values for all fields
|
|
22
|
-
if (exp !== undefined && nbf !== undefined) {
|
|
23
|
-
// validate that expires is greater than not before
|
|
24
|
-
if (exp <= nbf) {
|
|
25
|
-
setBlockRangeError(new Error('Expires must be greater than Not Before'))
|
|
26
|
-
} else {
|
|
27
|
-
setBlockRangeError(undefined)
|
|
28
|
-
if (delegate !== undefined) {
|
|
29
|
-
// create the payload
|
|
30
|
-
const payload = await createProducerChainStakeIntent(delegate, exp, nbf)
|
|
31
|
-
return payload
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}, [delegate, exp, nbf])
|
|
36
|
-
|
|
37
|
-
const onBuildLocal: MouseEventHandler<HTMLButtonElement> = () => {
|
|
38
|
-
if (onBuild && intentPayload) onBuild?.(intentPayload)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return (
|
|
42
|
-
<>
|
|
43
|
-
<FormControl fullWidth>
|
|
44
|
-
<XyoAddressTextField label="Delegate" name="delegate" onAddressChanged={setDelegate} required size="small" />
|
|
45
|
-
</FormControl>
|
|
46
|
-
<FormControl fullWidth>
|
|
47
|
-
<BlockNumberTextField
|
|
48
|
-
errorMessage={blockRangeError?.message}
|
|
49
|
-
label="Expires"
|
|
50
|
-
name="exp"
|
|
51
|
-
onBlockNumberChanged={setExp}
|
|
52
|
-
required
|
|
53
|
-
size="small"
|
|
54
|
-
/>
|
|
55
|
-
</FormControl>
|
|
56
|
-
<FormControl fullWidth>
|
|
57
|
-
<BlockNumberTextField
|
|
58
|
-
errorMessage={blockRangeError?.message}
|
|
59
|
-
label="Not Before"
|
|
60
|
-
name="nbf"
|
|
61
|
-
onBlockNumberChanged={setNbf}
|
|
62
|
-
required
|
|
63
|
-
size="small"
|
|
64
|
-
/>
|
|
65
|
-
</FormControl>
|
|
66
|
-
<Button disabled={!intentPayload} variant="contained" onClick={onBuildLocal}>Build</Button>
|
|
67
|
-
</>
|
|
68
|
-
)
|
|
69
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Form.tsx'
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryFn } from '@storybook/react-vite'
|
|
2
|
-
import React from 'react'
|
|
3
|
-
|
|
4
|
-
import { TransferBuilderFlexbox } from './Flexbox.tsx'
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
title: 'Payload/Builder/Transfer',
|
|
8
|
-
component: TransferBuilderFlexbox,
|
|
9
|
-
} as Meta
|
|
10
|
-
|
|
11
|
-
const Template: StoryFn<typeof TransferBuilderFlexbox> = args => <TransferBuilderFlexbox {...args} />
|
|
12
|
-
|
|
13
|
-
export const Default = Template.bind({})
|
|
14
|
-
Default.args = {}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
|
|
3
|
-
import type { PayloadBuilderComponentProps } from '../BuilderComponentProps.ts'
|
|
4
|
-
import { PayloadBuilderFlexbox } from '../Flexbox.tsx'
|
|
5
|
-
import { TransferBuilderForm } from './Form.tsx'
|
|
6
|
-
|
|
7
|
-
export const TransferBuilderFlexbox: React.FC<PayloadBuilderComponentProps> = ({ onBuild, ...props }) => (
|
|
8
|
-
<PayloadBuilderFlexbox
|
|
9
|
-
gap={4}
|
|
10
|
-
alignItems="start"
|
|
11
|
-
BuilderComponent={TransferBuilderForm}
|
|
12
|
-
onBuild={onBuild}
|
|
13
|
-
{...props}
|
|
14
|
-
/>
|
|
15
|
-
)
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { Button, FormControl } from '@mui/material'
|
|
2
|
-
import type { Address, Hex } from '@xylabs/sdk-js'
|
|
3
|
-
import { isAddress } from '@xylabs/sdk-js'
|
|
4
|
-
import type { Transfer } from '@xyo-network/xl1-sdk'
|
|
5
|
-
import { TransferSchema } from '@xyo-network/xl1-sdk'
|
|
6
|
-
import type { MouseEventHandler } from 'react'
|
|
7
|
-
import React, { useMemo, useState } from 'react'
|
|
8
|
-
|
|
9
|
-
import { XyoAddressTextField } from '../../fields/index.ts'
|
|
10
|
-
import type { PayloadBuilderComponentProps } from '../BuilderComponentProps.ts'
|
|
11
|
-
import { SingleTransferBuilderFlexbox } from './builder/index.ts'
|
|
12
|
-
import type { TransferAmount } from './Transfer.ts'
|
|
13
|
-
|
|
14
|
-
export interface TransferBuilderFormProps extends PayloadBuilderComponentProps {}
|
|
15
|
-
|
|
16
|
-
export const TransferBuilderForm: React.FC<TransferBuilderFormProps> = ({ onBuild }) => {
|
|
17
|
-
const [fromAddress, setFromAddress] = useState<Address>()
|
|
18
|
-
const [transfers, setTransfers] = useState<TransferAmount[]>([])
|
|
19
|
-
|
|
20
|
-
const [epoch] = useState(() => Date.now())
|
|
21
|
-
|
|
22
|
-
const transferPayload: Transfer | undefined = useMemo(() => {
|
|
23
|
-
if (isAddress(fromAddress) && transfers.length > 0) {
|
|
24
|
-
const transfersRecord = {} as Transfer['transfers']
|
|
25
|
-
for (const transfer of transfers) {
|
|
26
|
-
transfersRecord[transfer.to] = transfer.amount
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return {
|
|
30
|
-
from: fromAddress,
|
|
31
|
-
schema: TransferSchema,
|
|
32
|
-
transfers: transfersRecord,
|
|
33
|
-
epoch,
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}, [fromAddress, transfers, epoch])
|
|
37
|
-
|
|
38
|
-
const onBuildLocal: MouseEventHandler<HTMLButtonElement> = () => {
|
|
39
|
-
if (onBuild && transferPayload) onBuild?.(transferPayload)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const onTransferAdded = () => {
|
|
43
|
-
const transferAmount: TransferAmount = {
|
|
44
|
-
amount: '' as Hex,
|
|
45
|
-
transferId: Date.now(),
|
|
46
|
-
to: '' as Address,
|
|
47
|
-
}
|
|
48
|
-
setTransfers(prev => [...prev, transferAmount])
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const onTransferRemoved = (transferId: number) => {
|
|
52
|
-
setTransfers(prev => prev.filter(transfer => transfer.transferId !== transferId))
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const onTransferUpdated = (singleTransfer: TransferAmount) => {
|
|
56
|
-
setTransfers(prev => prev.map((transfer) => {
|
|
57
|
-
if (transfer.transferId === singleTransfer.transferId) {
|
|
58
|
-
return singleTransfer
|
|
59
|
-
}
|
|
60
|
-
return transfer
|
|
61
|
-
}))
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return (
|
|
65
|
-
<>
|
|
66
|
-
<FormControl fullWidth>
|
|
67
|
-
<XyoAddressTextField label="From" name="from" onAddressChanged={setFromAddress} required size="small" />
|
|
68
|
-
</FormControl>
|
|
69
|
-
<Button onClick={onTransferAdded} size="small" variant="contained">Add Transfer</Button>
|
|
70
|
-
{transfers.map(transfer => (
|
|
71
|
-
<SingleTransferBuilderFlexbox
|
|
72
|
-
key={transfer.transferId}
|
|
73
|
-
onTransferUpdated={onTransferUpdated}
|
|
74
|
-
onRemoveTransfer={onTransferRemoved}
|
|
75
|
-
singleTransfer={transfer}
|
|
76
|
-
sx={{ width: '100%' }}
|
|
77
|
-
/>
|
|
78
|
-
))}
|
|
79
|
-
<Button disabled={!transferPayload} variant="contained" onClick={onBuildLocal}>Build</Button>
|
|
80
|
-
</>
|
|
81
|
-
)
|
|
82
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { RemoveCircle } from '@mui/icons-material'
|
|
2
|
-
import {
|
|
3
|
-
FormControl, Icon, IconButton,
|
|
4
|
-
} from '@mui/material'
|
|
5
|
-
import type { FlexBoxProps } from '@xylabs/react-flexbox'
|
|
6
|
-
import { FlexRow } from '@xylabs/react-flexbox'
|
|
7
|
-
import type { Address } from '@xylabs/sdk-js'
|
|
8
|
-
import {
|
|
9
|
-
isAddress, isDefinedNotNull, toHex,
|
|
10
|
-
} from '@xylabs/sdk-js'
|
|
11
|
-
import { BigIntInput } from '@xyo-network/react-shared'
|
|
12
|
-
import React, { useEffect, useState } from 'react'
|
|
13
|
-
|
|
14
|
-
import { XyoAddressTextField } from '../../../fields/index.ts'
|
|
15
|
-
import type { TransferAmount } from '../Transfer.ts'
|
|
16
|
-
|
|
17
|
-
export interface SingleTransferBuilderFlexboxProps extends FlexBoxProps {
|
|
18
|
-
onRemoveTransfer?: (transferId: number) => void
|
|
19
|
-
onTransferUpdated?: (transferAmount: TransferAmount) => void
|
|
20
|
-
singleTransfer: TransferAmount
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export const SingleTransferBuilderFlexbox: React.FC<SingleTransferBuilderFlexboxProps> = ({
|
|
24
|
-
onTransferUpdated, onRemoveTransfer, singleTransfer, ...props
|
|
25
|
-
}) => {
|
|
26
|
-
const [toAddress, setToAddress] = useState<Address>()
|
|
27
|
-
const [amount, setAmount] = useState<bigint>()
|
|
28
|
-
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
const transferAmount = isAddress(toAddress) && isDefinedNotNull(amount)
|
|
31
|
-
? {
|
|
32
|
-
...singleTransfer,
|
|
33
|
-
amount: toHex(amount),
|
|
34
|
-
to: toAddress,
|
|
35
|
-
}
|
|
36
|
-
: undefined
|
|
37
|
-
if (transferAmount) onTransferUpdated?.(transferAmount)
|
|
38
|
-
}, [amount, onTransferUpdated, singleTransfer, toAddress])
|
|
39
|
-
|
|
40
|
-
return (
|
|
41
|
-
<FlexRow alignItems="start" gap={1} {...props}>
|
|
42
|
-
<FormControl fullWidth>
|
|
43
|
-
<XyoAddressTextField label="To" name="to" onAddressChanged={setToAddress} required size="small" />
|
|
44
|
-
</FormControl>
|
|
45
|
-
<FormControl fullWidth>
|
|
46
|
-
<BigIntInput.TextField label="Amount" name="amount" onChangeFixedPoint={setAmount} required size="small" />
|
|
47
|
-
</FormControl>
|
|
48
|
-
<IconButton onClick={() => onRemoveTransfer?.(singleTransfer.transferId)}><Icon><RemoveCircle /></Icon></IconButton>
|
|
49
|
-
</FlexRow>
|
|
50
|
-
)
|
|
51
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './SingleFlexbox.tsx'
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import type { StandardTextFieldProps } from '@mui/material'
|
|
2
|
-
import {
|
|
3
|
-
FormControl, FormHelperText, TextField,
|
|
4
|
-
} from '@mui/material'
|
|
5
|
-
import { toXL1BlockNumber, type XL1BlockNumber } from '@xyo-network/xl1-sdk'
|
|
6
|
-
import type { ChangeEventHandler } from 'react'
|
|
7
|
-
import React, { useState } from 'react'
|
|
8
|
-
|
|
9
|
-
interface BlockNumberTextFieldProps extends StandardTextFieldProps {
|
|
10
|
-
errorMessage?: string
|
|
11
|
-
onBlockNumberChanged?: (blockNumber?: XL1BlockNumber) => void
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const BlockNumberTextField: React.FC<BlockNumberTextFieldProps> = ({
|
|
15
|
-
errorMessage, onBlockNumberChanged, onChange, ...props
|
|
16
|
-
}) => {
|
|
17
|
-
const [blockNumber, setBlockNumber] = useState<number>()
|
|
18
|
-
|
|
19
|
-
const handleChange: ChangeEventHandler<HTMLInputElement> = (e) => {
|
|
20
|
-
const value = e.target.value.replaceAll(/\D/g, '') // Remove non-digit characters
|
|
21
|
-
setBlockNumber(value.length > 0 ? Number(value) : undefined)
|
|
22
|
-
onBlockNumberChanged?.(toXL1BlockNumber(value))
|
|
23
|
-
onChange?.(e)
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const errored = errorMessage !== undefined
|
|
27
|
-
|
|
28
|
-
return (
|
|
29
|
-
<FormControl fullWidth>
|
|
30
|
-
<TextField
|
|
31
|
-
error={errored}
|
|
32
|
-
onChange={handleChange}
|
|
33
|
-
type="number"
|
|
34
|
-
value={blockNumber ?? ''}
|
|
35
|
-
{...props}
|
|
36
|
-
/>
|
|
37
|
-
{errored ? <FormHelperText sx={{ color: 'error.main' }}>{errorMessage}</FormHelperText> : null}
|
|
38
|
-
</FormControl>
|
|
39
|
-
)
|
|
40
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import type { StandardTextFieldProps } from '@mui/material'
|
|
2
|
-
import {
|
|
3
|
-
FormControl, FormHelperText, TextField,
|
|
4
|
-
} from '@mui/material'
|
|
5
|
-
import type { Address } from '@xylabs/sdk-js'
|
|
6
|
-
import {
|
|
7
|
-
asAddress, isAddress, isDefined,
|
|
8
|
-
} from '@xylabs/sdk-js'
|
|
9
|
-
import React, { useState } from 'react'
|
|
10
|
-
|
|
11
|
-
interface XyoAddressTextFieldProps extends Omit<StandardTextFieldProps, 'value'> {
|
|
12
|
-
onAddressChanged?: (address?: Address) => void
|
|
13
|
-
// increment the value to trigger rerender with empty input
|
|
14
|
-
resetValue?: number
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const XyoAddressTextField: React.FC<XyoAddressTextFieldProps> = ({
|
|
18
|
-
onAddressChanged, onChange, resetValue, ...props
|
|
19
|
-
}) => {
|
|
20
|
-
const [address, setAddress] = useState<string>('')
|
|
21
|
-
const [addressError, setAddressError] = useState<Error>()
|
|
22
|
-
|
|
23
|
-
const [previousResetValue, setPreviousResetValue] = useState<number | undefined>(resetValue)
|
|
24
|
-
|
|
25
|
-
if (isDefined(resetValue) && resetValue !== previousResetValue) {
|
|
26
|
-
setPreviousResetValue(resetValue)
|
|
27
|
-
setAddress('')
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
31
|
-
const { value } = event.target
|
|
32
|
-
// allow the parent component to also respond to the change if they need to
|
|
33
|
-
onChange?.(event)
|
|
34
|
-
|
|
35
|
-
// validate the address and call onAddressChanged if it's valid
|
|
36
|
-
const xyoAddress = asAddress(value)
|
|
37
|
-
if (isAddress(xyoAddress)) {
|
|
38
|
-
onAddressChanged?.(xyoAddress)
|
|
39
|
-
setAddressError(undefined)
|
|
40
|
-
} else if (value === '') {
|
|
41
|
-
// if the input is empty, we clear the error but don't call onAddressChanged because there's no address
|
|
42
|
-
setAddressError(undefined)
|
|
43
|
-
} else {
|
|
44
|
-
// if the address is invalid, we set an error and call onAddressChanged with undefined to clear any previously set address
|
|
45
|
-
setAddressError(new Error('Invalid address'))
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
setAddress(value)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const handleBlur = () => {
|
|
52
|
-
const xyoAddress = asAddress(address)
|
|
53
|
-
if (!isAddress(xyoAddress)) {
|
|
54
|
-
setAddressError(new Error('Invalid address'))
|
|
55
|
-
onAddressChanged?.()
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return (
|
|
60
|
-
<FormControl fullWidth>
|
|
61
|
-
<TextField
|
|
62
|
-
error={!!addressError}
|
|
63
|
-
onBlur={handleBlur}
|
|
64
|
-
onChange={handleChange}
|
|
65
|
-
value={address}
|
|
66
|
-
{...props}
|
|
67
|
-
/>
|
|
68
|
-
{addressError ? <FormHelperText sx={{ color: 'error.main' }}>{addressError.message}</FormHelperText> : null}
|
|
69
|
-
</FormControl>
|
|
70
|
-
)
|
|
71
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { ViewAgendaOutlined } from '@mui/icons-material'
|
|
2
|
-
import { Tooltip, type TypographyProps } from '@mui/material'
|
|
3
|
-
import type { XL1BlockRange } from '@xyo-network/xl1-sdk'
|
|
4
|
-
|
|
5
|
-
import { MetricTypography } from './support/index.ts'
|
|
6
|
-
|
|
7
|
-
export interface BlockRateSpanTypographyProps extends TypographyProps {
|
|
8
|
-
range?: XL1BlockRange
|
|
9
|
-
span?: number
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const BlockRateSpanTypography: React.FC<BlockRateSpanTypographyProps> = ({
|
|
13
|
-
range, span, sx, ...props
|
|
14
|
-
}) => {
|
|
15
|
-
return (
|
|
16
|
-
<Tooltip title={`Block Range: ${range?.join(' - ')}`}>
|
|
17
|
-
<MetricTypography icon={<ViewAgendaOutlined fontSize="large" />} metric={span} label="blocks" {...props} />
|
|
18
|
-
</Tooltip>
|
|
19
|
-
)
|
|
20
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { SpeedOutlined } from '@mui/icons-material'
|
|
2
|
-
import type { TypographyProps } from '@mui/material'
|
|
3
|
-
|
|
4
|
-
import { MetricTypography } from './support/index.ts'
|
|
5
|
-
|
|
6
|
-
export interface BlockRateSpeedTypographyProps extends TypographyProps {
|
|
7
|
-
rate?: number
|
|
8
|
-
rateUnitLabel?: string
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const BlockRateSpeedTypography: React.FC<BlockRateSpeedTypographyProps> = ({
|
|
12
|
-
rate, rateUnitLabel, ...props
|
|
13
|
-
}) => {
|
|
14
|
-
return (
|
|
15
|
-
<MetricTypography icon={<SpeedOutlined fontSize="large" />} metric={rate} label={rateUnitLabel} {...props} />
|
|
16
|
-
)
|
|
17
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { TimelapseOutlined } from '@mui/icons-material'
|
|
2
|
-
import { type TypographyProps } from '@mui/material'
|
|
3
|
-
|
|
4
|
-
import { MetricTypography } from './support/index.ts'
|
|
5
|
-
|
|
6
|
-
export interface BlockRateTimeTypographyProps extends TypographyProps {
|
|
7
|
-
timeDifference?: number
|
|
8
|
-
timeUnit?: string
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const BlockRateTimeTypography: React.FC<BlockRateTimeTypographyProps> = ({
|
|
12
|
-
timeUnit, timeDifference, sx, ...props
|
|
13
|
-
}) => {
|
|
14
|
-
return (
|
|
15
|
-
<MetricTypography icon={<TimelapseOutlined fontSize="large" />} metric={timeDifference} label={timeUnit} {...props} />
|
|
16
|
-
)
|
|
17
|
-
}
|
|
@@ -1,46 +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 { BlockRateFlexBox } from './FlexBox.tsx'
|
|
6
|
-
|
|
7
|
-
const blockRateSeconds: BlockRate = {
|
|
8
|
-
range: asXL1BlockRange([100, 200], true),
|
|
9
|
-
span: 100,
|
|
10
|
-
rate: 0.12,
|
|
11
|
-
timeUnit: 'seconds',
|
|
12
|
-
timeDifference: (100 * 12),
|
|
13
|
-
timePerBlock: 12,
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const blockRateMinutes: BlockRate = {
|
|
17
|
-
range: asXL1BlockRange([100, 200], true),
|
|
18
|
-
span: 100,
|
|
19
|
-
rate: 12,
|
|
20
|
-
timeUnit: 'minutes',
|
|
21
|
-
timeDifference: (100 * 12) / 60,
|
|
22
|
-
timePerBlock: 12 / 60,
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export default {
|
|
26
|
-
title: 'BlockRate/FlexBox',
|
|
27
|
-
component: BlockRateFlexBox,
|
|
28
|
-
} satisfies Meta<typeof BlockRateFlexBox>
|
|
29
|
-
|
|
30
|
-
const Template: StoryFn<typeof BlockRateFlexBox> = (args) => {
|
|
31
|
-
return <BlockRateFlexBox {...args} />
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const Default = Template.bind({})
|
|
35
|
-
Default.args = {}
|
|
36
|
-
|
|
37
|
-
const WithBlockRateSeconds = Template.bind({})
|
|
38
|
-
WithBlockRateSeconds.args = { blockRate: blockRateSeconds }
|
|
39
|
-
|
|
40
|
-
const WithBlockRateMinutes = Template.bind({})
|
|
41
|
-
WithBlockRateMinutes.args = { blockRate: blockRateMinutes }
|
|
42
|
-
|
|
43
|
-
export {
|
|
44
|
-
Default, WithBlockRateMinutes,
|
|
45
|
-
WithBlockRateSeconds,
|
|
46
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { FlexBoxProps } from '@xylabs/react-flexbox'
|
|
2
|
-
import { FlexCol } from '@xylabs/react-flexbox'
|
|
3
|
-
import { isDefined } from '@xylabs/sdk-js'
|
|
4
|
-
import type { BlockRate } from '@xyo-network/xl1-sdk'
|
|
5
|
-
|
|
6
|
-
import { rateUnitToLabel } from '../../../helpers/rate/index.ts'
|
|
7
|
-
import { BlockRateSpanTypography } from '../SpanTypography.tsx'
|
|
8
|
-
import { BlockRateSpeedTypography } from '../SpeedTypography.tsx'
|
|
9
|
-
import { BlockRateTimeTypography } from '../TimeTypography.tsx'
|
|
10
|
-
|
|
11
|
-
export interface BlockRateFlexBoxProps extends FlexBoxProps {
|
|
12
|
-
blockRate?: BlockRate
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const BlockRateFlexBox: React.FC<BlockRateFlexBoxProps> = ({
|
|
16
|
-
blockRate,
|
|
17
|
-
...flexBoxProps
|
|
18
|
-
}) => {
|
|
19
|
-
const {
|
|
20
|
-
range, span, rate, timeUnit, timeDifference,
|
|
21
|
-
} = blockRate ?? {}
|
|
22
|
-
const rateUnitLabel = isDefined(timeUnit) ? rateUnitToLabel(timeUnit) : ''
|
|
23
|
-
|
|
24
|
-
return (
|
|
25
|
-
<FlexCol alignItems="start" {...flexBoxProps}>
|
|
26
|
-
<BlockRateSpeedTypography rate={rate} rateUnitLabel={rateUnitLabel} />
|
|
27
|
-
<BlockRateSpanTypography range={range} span={span} />
|
|
28
|
-
<BlockRateTimeTypography timeUnit={timeUnit} timeDifference={timeDifference} />
|
|
29
|
-
</FlexCol>
|
|
30
|
-
)
|
|
31
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './FlexBox.tsx'
|
|
@@ -1,80 +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 { BlockRateSpeedGaugeContainer } from './Container.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
|
-
// up the block rate to test gauge scaling
|
|
30
|
-
rate: 7 * 60,
|
|
31
|
-
timeUnit: 'hours',
|
|
32
|
-
timeDifference: (100 * 12) / 60,
|
|
33
|
-
timePerBlock: 12,
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const gaugeConfigHour: GaugeConfig = {
|
|
37
|
-
// The target block rate per hour is less than blockRateHour.rate
|
|
38
|
-
// this is to show the pointer as higher than the targetPosition of 75 out of 110 max
|
|
39
|
-
targetBlockRate: 5 * 60,
|
|
40
|
-
targetBlockRateUnit: 'hours',
|
|
41
|
-
targetPosition: 75,
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const gaugeConfigHourWithoutTicks: GaugeConfig = {
|
|
45
|
-
targetBlockRate: 5 * 60,
|
|
46
|
-
targetBlockRateUnit: 'hours',
|
|
47
|
-
targetPosition: 75,
|
|
48
|
-
showTicks: false,
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export default {
|
|
52
|
-
title: 'BlockRate/Gauge',
|
|
53
|
-
component: BlockRateSpeedGaugeContainer,
|
|
54
|
-
} satisfies Meta<typeof BlockRateSpeedGaugeContainer>
|
|
55
|
-
|
|
56
|
-
const Template: StoryFn<typeof BlockRateSpeedGaugeContainer> = (args) => {
|
|
57
|
-
return <BlockRateSpeedGaugeContainer {...args} />
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const Default = Template.bind({})
|
|
61
|
-
Default.args = {}
|
|
62
|
-
|
|
63
|
-
const WithBlockRateSeconds = Template.bind({})
|
|
64
|
-
WithBlockRateSeconds.args = { blockRate: blockRateSeconds }
|
|
65
|
-
|
|
66
|
-
const WithBlockRateMinutes = Template.bind({})
|
|
67
|
-
WithBlockRateMinutes.args = { blockRate: blockRateMinutes }
|
|
68
|
-
|
|
69
|
-
const WithBlockRateHoursHigherThanTarget = Template.bind({})
|
|
70
|
-
WithBlockRateHoursHigherThanTarget.args = { blockRate: blockRateHour, gaugeConfig: gaugeConfigHour }
|
|
71
|
-
|
|
72
|
-
const WithBlockRateHoursWithoutTicks = Template.bind({})
|
|
73
|
-
WithBlockRateHoursWithoutTicks.args = { blockRate: blockRateHour, gaugeConfig: gaugeConfigHourWithoutTicks }
|
|
74
|
-
|
|
75
|
-
export {
|
|
76
|
-
Default, WithBlockRateHoursHigherThanTarget,
|
|
77
|
-
WithBlockRateHoursWithoutTicks,
|
|
78
|
-
WithBlockRateMinutes,
|
|
79
|
-
WithBlockRateSeconds,
|
|
80
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import type { GaugeContainerProps } from '@mui/x-charts'
|
|
2
|
-
import {
|
|
3
|
-
GaugeContainer, GaugeReferenceArc, GaugeValueArc,
|
|
4
|
-
} from '@mui/x-charts'
|
|
5
|
-
import type { BlockRate, TimeDurations } from '@xyo-network/xl1-sdk'
|
|
6
|
-
import type { PropsWithChildren } from 'react'
|
|
7
|
-
|
|
8
|
-
import { BlockRateConversions } from './helpers/index.ts'
|
|
9
|
-
import { GaugePointer } from './Pointer.tsx'
|
|
10
|
-
import { GaugeTicks } from './Ticks.tsx'
|
|
11
|
-
|
|
12
|
-
export type GaugeConfig = {
|
|
13
|
-
// whether to show ticks on the gauge
|
|
14
|
-
showTicks?: boolean
|
|
15
|
-
// the block rate to target on the gauge
|
|
16
|
-
targetBlockRate: number
|
|
17
|
-
// the unit of time for the target block rate (e.g., seconds, minutes)
|
|
18
|
-
targetBlockRateUnit: keyof TimeDurations
|
|
19
|
-
// the position of the pointer when the block rate matches the target rate
|
|
20
|
-
// should be approximately between 2/3 and 3/4 position of the gauge
|
|
21
|
-
targetPosition: number
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface BlockRateSpeedGaugeProps extends GaugeContainerProps, PropsWithChildren {
|
|
25
|
-
blockRate?: BlockRate
|
|
26
|
-
gaugeConfig?: GaugeConfig
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export const BlockRateSpeedGaugeContainer: React.FC<BlockRateSpeedGaugeProps> = ({
|
|
30
|
-
blockRate,
|
|
31
|
-
children,
|
|
32
|
-
gaugeConfig,
|
|
33
|
-
startAngle = -110,
|
|
34
|
-
endAngle = 110,
|
|
35
|
-
width = 200,
|
|
36
|
-
height = 150,
|
|
37
|
-
...props
|
|
38
|
-
}) => {
|
|
39
|
-
const { rate, timeUnit } = blockRate || {}
|
|
40
|
-
const {
|
|
41
|
-
targetBlockRate = 5, targetBlockRateUnit = 'minutes', targetPosition = 75, showTicks = true,
|
|
42
|
-
} = gaugeConfig || {}
|
|
43
|
-
|
|
44
|
-
// Get the appropriate converter function based on the target block rate unit
|
|
45
|
-
const converter = BlockRateConversions[targetBlockRateUnit]
|
|
46
|
-
|
|
47
|
-
// Normalize rate to the gauge
|
|
48
|
-
const maxGaugeValue = endAngle // matches endAngle
|
|
49
|
-
const blocksPerMinute = rate === undefined ? 0 : converter(rate, timeUnit)
|
|
50
|
-
|
|
51
|
-
// Scale: 5 blocks/min should map to 75 out of 110 max
|
|
52
|
-
// This means: normalizedValue = (blocksPerMinute / targetRate) * targetPosition
|
|
53
|
-
// And we want it capped at maxGaugeValue
|
|
54
|
-
const normalizedValue = Math.min((blocksPerMinute / targetBlockRate) * targetPosition, maxGaugeValue)
|
|
55
|
-
|
|
56
|
-
return (
|
|
57
|
-
<GaugeContainer
|
|
58
|
-
width={width}
|
|
59
|
-
height={height}
|
|
60
|
-
startAngle={startAngle}
|
|
61
|
-
endAngle={endAngle}
|
|
62
|
-
value={normalizedValue}
|
|
63
|
-
valueMax={endAngle}
|
|
64
|
-
innerRadius="95%"
|
|
65
|
-
outerRadius="100%"
|
|
66
|
-
{...props}
|
|
67
|
-
>
|
|
68
|
-
{showTicks && <GaugeTicks />}
|
|
69
|
-
<GaugeReferenceArc />
|
|
70
|
-
<GaugeValueArc />
|
|
71
|
-
<GaugePointer startAngle={-2} />
|
|
72
|
-
{children}
|
|
73
|
-
</GaugeContainer>
|
|
74
|
-
)
|
|
75
|
-
}
|