@xyo-network/xl1-react-transaction 1.20.14 → 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.
@@ -1,9 +1,12 @@
1
+ import type { LinearProgressProps } from '@mui/material';
1
2
  import type { BlockRange } from '@xyo-network/xl1-sdk';
2
- export declare const useBlockRangeState: (blockRange: BlockRange | undefined, confirmedInBlock: number | undefined, currentBlockNumber?: number | undefined) => {
3
+ interface BlockRangeState {
3
4
  isConfirmed: boolean;
4
5
  isExpired: boolean;
5
6
  passedBlocks: number[];
6
- progressColor: import("@mui/types").OverridableStringUnion<"primary" | "secondary" | "error" | "info" | "success" | "warning" | "inherit", import("@mui/material").LinearProgressPropsColorOverrides> | undefined;
7
+ progressColor: LinearProgressProps['color'];
7
8
  range: number[];
8
- };
9
+ }
10
+ export declare const useBlockRangeState: (blockRange: BlockRange | undefined, confirmedInBlock: number | undefined, currentBlockNumber?: number | undefined) => BlockRangeState;
11
+ export {};
9
12
  //# sourceMappingURL=useBlockRangeState.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useBlockRangeState.d.ts","sourceRoot":"","sources":["../../../../src/confirmation/hooks/useBlockRangeState.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAOtD,eAAO,MAAM,kBAAkB,GAC7B,YAAY,UAAU,GAAG,SAAS,EAClC,kBAAkB,MAAM,GAAG,SAAS,EACpC,qBAAqB,MAAM,GAAG,SAAS;;;;;;CAexC,CAAA"}
1
+ {"version":3,"file":"useBlockRangeState.d.ts","sourceRoot":"","sources":["../../../../src/confirmation/hooks/useBlockRangeState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAExD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAOtD,UAAU,eAAe;IACvB,WAAW,EAAE,OAAO,CAAA;IACpB,SAAS,EAAE,OAAO,CAAA;IAClB,YAAY,EAAE,MAAM,EAAE,CAAA;IACtB,aAAa,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAA;IAC3C,KAAK,EAAE,MAAM,EAAE,CAAA;CAChB;AAED,eAAO,MAAM,kBAAkB,GAC7B,YAAY,UAAU,GAAG,SAAS,EAClC,kBAAkB,MAAM,GAAG,SAAS,EACpC,qBAAqB,MAAM,GAAG,SAAS,KACtC,eAcF,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/confirmation/components/TransactionStackProgress.tsx","../../src/confirmation/helpers/BlockFormatters.ts","../../src/confirmation/helpers/blockProgressColor.ts","../../src/confirmation/helpers/createFilledRange.ts","../../src/confirmation/helpers/getBlockProgress.ts","../../src/confirmation/helpers/isCurrentBlockPassedRange.ts","../../src/confirmation/helpers/passedBlocksInRange.ts","../../src/confirmation/hooks/useBlockRangeState.ts","../../src/confirmation/components/support/BlockConfirmationStats.tsx","../../src/confirmation/components/support/BlockRangeEntryStack.tsx"],"sourcesContent":["import type { StackProps } from '@mui/material'\nimport { LinearProgress, Stack } from '@mui/material'\nimport { isDefined } from '@xylabs/sdk-js'\nimport { type BlockRange } from '@xyo-network/xl1-sdk'\nimport React, {\n useLayoutEffect,\n useMemo,\n useRef, useState,\n} from 'react'\n\nimport { BlockFormatters, getBlockProgress } from '../helpers/index.ts'\nimport { useBlockRangeState } from '../hooks/index.ts'\nimport { BlockConfirmationStats, BlockRangeEntryStack } from './support/index.ts'\n\nexport interface TransactionStackProgressProps extends StackProps {\n blockRange?: BlockRange\n confirmedInBlock?: number\n currentBlockNumber?: number\n}\n\nexport const TransactionStackProgress: React.FC<TransactionStackProgressProps> = ({\n blockRange, confirmedInBlock, currentBlockNumber, ...props\n}) => {\n const blockPositionsRef = useRef<{ [blockNumber: number]: HTMLSpanElement | null }>({})\n const updateBlockPositionRefs = (blockNumber: number, ref: HTMLSpanElement | null) => {\n blockPositionsRef.current[blockNumber] = ref\n }\n\n const progressElementRef = useRef<HTMLDivElement | null>(null)\n\n const {\n passedBlocks, progressColor, range, isConfirmed, isExpired,\n } = useBlockRangeState(blockRange, confirmedInBlock, currentBlockNumber)\n\n const blockFormatters = useMemo(() => new BlockFormatters({ confirmedInBlock, currentBlockNumber }), [confirmedInBlock, currentBlockNumber])\n\n const [progressValue, setProgressValue] = useState(0)\n\n useLayoutEffect(() => {\n // prevent updates if the current block is past the confirmed block\n if (isDefined(currentBlockNumber) && isDefined(confirmedInBlock) && currentBlockNumber > confirmedInBlock) {\n return\n }\n const currentBlockNumberElement = isDefined(currentBlockNumber) ? blockPositionsRef.current[currentBlockNumber] : null\n const progressElement = progressElementRef.current\n // since we are relying on htmlElements, we have to use layout effect\n setProgressValue(getBlockProgress(\n currentBlockNumber,\n currentBlockNumberElement,\n progressElement,\n ))\n }, [confirmedInBlock, currentBlockNumber])\n\n return (\n <Stack direction=\"row\" {...props}>\n <Stack width=\"100%\" gap={1}>\n <Stack>\n <LinearProgress ref={progressElementRef} variant=\"determinate\" value={isExpired ? 100 : progressValue} color={progressColor} />\n <Stack direction=\"row\" justifyContent=\"space-between\">\n {range.map((block) => {\n const blockColor = blockFormatters.color(block)\n const blockStatus = blockFormatters.confirmationStatus(block)\n const formattedBlockNumber = blockFormatters.formatNumber(block)\n return (\n <BlockRangeEntryStack\n key={block}\n block={block}\n blockColor={blockColor}\n blockStatus={blockStatus}\n formattedBlockNumber={formattedBlockNumber}\n updateBlockPositionRefs={updateBlockPositionRefs}\n />\n )\n })}\n </Stack>\n </Stack>\n <BlockConfirmationStats\n confirmed={isConfirmed}\n currentBlockColor={isDefined(currentBlockNumber) ? blockFormatters.color(currentBlockNumber) : 'text.secondary'}\n currentBlockNumberValue={isDefined(currentBlockNumber) ? new Intl.NumberFormat().format(currentBlockNumber) : 'N/A'}\n passedBlocks={passedBlocks}\n />\n </Stack>\n </Stack>\n )\n}\n","import { isDefined } from '@xylabs/sdk-js'\n\nexport type BlockConfirmationStatus = 'confirmed' | 'missed' | 'pending'\n\ntype BlockFormattersParams = {\n confirmedInBlock: number | undefined\n currentBlockNumber: number | undefined\n}\n\nexport class BlockFormatters {\n private readonly params: BlockFormattersParams\n\n constructor(params: BlockFormattersParams) {\n this.params = params\n }\n\n color(blockNumber: number): string {\n const { currentBlockNumber, confirmedInBlock } = this.params\n if (blockNumber === currentBlockNumber) {\n return isDefined(confirmedInBlock) && confirmedInBlock === blockNumber ? 'success.dark' : 'text'\n }\n const status = this.confirmationStatus(blockNumber)\n switch (status) {\n case 'confirmed': {\n return 'success.dark'\n }\n case 'missed': {\n return 'warning.light'\n }\n case 'pending': {\n return 'text.secondary'\n }\n default: {\n return 'text.secondary'\n }\n }\n }\n\n confirmationStatus(blockNumber: number): BlockConfirmationStatus | undefined {\n const { currentBlockNumber, confirmedInBlock } = this.params\n if (isDefined(currentBlockNumber)) {\n if (isDefined(confirmedInBlock) && blockNumber === confirmedInBlock) {\n return 'confirmed'\n }\n return currentBlockNumber > blockNumber ? 'missed' : 'pending'\n }\n }\n\n formatNumber(blockNumber: number) {\n return blockNumber.toString().length <= 5 ? new Intl.NumberFormat().format(blockNumber) : `${blockNumber.toString().slice(-2)}`\n }\n}\n","import type { LinearProgressProps } from '@mui/material'\nimport { isDefined } from '@xylabs/sdk-js'\n\nexport const blockProgressColor = (\n confirmedInBlock: number | undefined,\n isExpired: boolean | undefined,\n): LinearProgressProps['color'] => {\n if (isDefined(confirmedInBlock)) {\n return 'success'\n }\n if (isExpired) {\n return 'error'\n }\n return 'primary'\n}\n","import { isUndefined } from '@xylabs/sdk-js'\n\nexport const createFilledRange = (range?: [number, number]): number[] => {\n if (isUndefined(range)) {\n return []\n }\n const [start, end] = range\n if (end < start) {\n console.warn('Invalid range: end is less than start')\n return []\n }\n\n const result: number[] = []\n\n for (let i = start; i <= end; i++) {\n result.push(i)\n }\n\n return result\n}\n","import { isUndefined, isUndefinedOrNull } from '@xylabs/sdk-js'\n\nexport const getBlockProgress = (\n currentBlockNumber: number | undefined,\n currentBlockRef: HTMLSpanElement | null,\n progressElementRef: HTMLDivElement | null,\n) => {\n if (isUndefined(currentBlockNumber) || isUndefinedOrNull(currentBlockRef) || isUndefinedOrNull(progressElementRef)) {\n return 0\n }\n\n const currentBlockOffsetLeft = currentBlockRef.offsetLeft\n const currentBlockOffsetWidth = currentBlockRef.clientWidth / 2\n const currentBlockCenterOffsetLeft = currentBlockOffsetLeft + currentBlockOffsetWidth\n const parentOffsetLeft = progressElementRef.offsetLeft\n const parentWidth = progressElementRef.clientWidth\n\n const relativePosition = currentBlockCenterOffsetLeft - parentOffsetLeft\n const progress = (relativePosition / parentWidth) * 100\n\n return Math.min(Math.max(progress, 0), 100)\n}\n","import { isDefined } from '@xylabs/sdk-js'\nimport type { BlockRange } from '@xyo-network/xl1-sdk'\n\nexport const isCurrentBlockPassedRange = (\n blockRange: BlockRange | undefined,\n currentBlockNumber: number | undefined,\n) => {\n if (!isDefined(blockRange) || !isDefined(currentBlockNumber)) {\n return false\n }\n const [, end] = blockRange\n return currentBlockNumber > end\n}\n","import { isDefined } from '@xylabs/sdk-js'\n\nexport const passedBlocksInRange = (\n range: number[] | undefined,\n currentBlockNumber: number | undefined,\n) => {\n if (!isDefined(currentBlockNumber) || !isDefined(range)) {\n return []\n }\n const [start] = range\n return range.filter(block => block < currentBlockNumber && block >= start)\n}\n","import { isDefined } from '@xylabs/sdk-js'\nimport type { BlockRange } from '@xyo-network/xl1-sdk'\nimport { useMemo } from 'react'\n\nimport {\n blockProgressColor, createFilledRange, isCurrentBlockPassedRange, passedBlocksInRange,\n} from '../helpers/index.ts'\n\nexport const useBlockRangeState = (\n blockRange: BlockRange | undefined,\n confirmedInBlock: number | undefined,\n currentBlockNumber?: number | undefined,\n) => {\n const range = useMemo(() => createFilledRange((blockRange)), [blockRange])\n\n const isExpired = useMemo(() => isCurrentBlockPassedRange(blockRange, currentBlockNumber), [blockRange, currentBlockNumber])\n\n const passedBlocks = useMemo(() => passedBlocksInRange(range, currentBlockNumber), [currentBlockNumber, range])\n\n const progressColor = useMemo(() => blockProgressColor(confirmedInBlock, isExpired), [confirmedInBlock, isExpired])\n\n const isConfirmed = isDefined(confirmedInBlock)\n\n return {\n isConfirmed, isExpired, passedBlocks, progressColor, range,\n }\n}\n","import { CheckCircleOutline } from '@mui/icons-material'\nimport {\n Grow, Stack, Typography,\n} from '@mui/material'\nimport { isDefined } from '@xylabs/sdk-js'\nimport React from 'react'\n\nexport interface BlockConfirmationStatsProps {\n confirmed?: boolean\n currentBlockColor?: string\n currentBlockNumberValue?: string\n passedBlocks?: number[]\n}\n\nexport const BlockConfirmationStats: React.FC<BlockConfirmationStatsProps> = ({\n confirmed, currentBlockColor, currentBlockNumberValue, passedBlocks,\n}) => {\n return (\n <Stack>\n <Typography\n variant=\"caption\"\n color={currentBlockColor}\n sx={{\n display: 'inline-flex', alignItems: 'center', gap: 0.5,\n }}\n >\n Current Block:\n {' '}\n {currentBlockNumberValue}\n {' '}\n <Grow in={confirmed}>\n <CheckCircleOutline sx={{ width: '0.8em', height: '0.8em' }} color=\"success\" />\n </Grow>\n </Typography>\n <Typography variant=\"caption\" color=\"warning.light\" sx={{ opacity: 0.75 }}>\n Passed Blocks:\n {' '}\n {isDefined(passedBlocks) && passedBlocks.length > 0 ? passedBlocks.map(block => new Intl.NumberFormat().format(block)).join(', ') : 'N/A'}\n </Typography>\n\n </Stack>\n )\n}\n","import type { BoxProps, StackProps } from '@mui/material'\nimport {\n Box, Stack, styled, Tooltip, Typography,\n} from '@mui/material'\nimport React from 'react'\n\nimport type { BlockConfirmationStatus } from '../../helpers/index.ts'\n\nexport interface BlockRangeEntryStackProps extends StackProps {\n block: number\n blockColor: string\n blockStatus: BlockConfirmationStatus | undefined\n formattedBlockNumber: string\n updateBlockPositionRefs?: (blockNumber: number, ref: HTMLSpanElement | null) => void\n}\n\nexport const BlockRangeEntryStack: React.FC<BlockRangeEntryStackProps> = ({\n block, blockColor, blockStatus, formattedBlockNumber, updateBlockPositionRefs, sx, ...props\n}) => {\n return (\n <Stack\n ref={(ref) => { if (updateBlockPositionRefs) updateBlockPositionRefs(block, ref) }}\n key={block}\n sx={{ position: 'relative', ...sx }}\n {...props}\n >\n <Box\n component=\"span\"\n sx={{\n display: 'flex', position: 'relative', width: '100%', height: 5,\n }}\n >\n <StyledBlockNumberIndicator component=\"span\" sx={{ backgroundColor: blockColor }} />\n </Box>\n <Tooltip\n title={`Block: ${new Intl.NumberFormat().format(block)} (${blockStatus})`}\n placement=\"top\"\n arrow\n >\n <Typography\n variant=\"caption\"\n sx={{\n color: blockColor,\n cursor: 'pointer',\n opacity: blockStatus === 'missed' ? 0.75 : 1,\n }}\n >\n {formattedBlockNumber}\n </Typography>\n </Tooltip>\n </Stack>\n )\n}\n\nconst StyledBlockNumberIndicator = styled(Box, { name: 'StyledBlockNumberIndicator' })<BoxProps>(({ theme }) => {\n return theme.unstable_sx({\n position: 'absolute',\n left: 'calc(50% - 1px)',\n transform: 'calc(translateX(-50%) - 1px)',\n height: 3,\n width: '1px',\n backgroundColor: 'primary.main',\n })\n})\n"],"mappings":";;;;AACA,SAASA,gBAAgBC,SAAAA,cAAa;AACtC,SAASC,aAAAA,kBAAiB;AAE1B,OAAOC,UACLC,iBACAC,WAAAA,UACAC,QAAQC,gBACH;;;ACRP,SAASC,iBAAiB;AASnB,IAAMC,kBAAN,MAAMA;EATb,OASaA;;;EACMC;EAEjB,YAAYA,QAA+B;AACzC,SAAKA,SAASA;EAChB;EAEAC,MAAMC,aAA6B;AACjC,UAAM,EAAEC,oBAAoBC,iBAAgB,IAAK,KAAKJ;AACtD,QAAIE,gBAAgBC,oBAAoB;AACtC,aAAOE,UAAUD,gBAAAA,KAAqBA,qBAAqBF,cAAc,iBAAiB;IAC5F;AACA,UAAMI,SAAS,KAAKC,mBAAmBL,WAAAA;AACvC,YAAQI,QAAAA;MACN,KAAK,aAAa;AAChB,eAAO;MACT;MACA,KAAK,UAAU;AACb,eAAO;MACT;MACA,KAAK,WAAW;AACd,e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AGC,OAAOnD,kBAAAA,IAAsB;IAC9GS;;AAKV,GAjEiF;","names":["LinearProgress","Stack","isDefined","React","useLayoutEffect","useMemo","useRef","useState","isDefined","BlockFormatters","params","color","blockNumber","currentBlockNumber","confirmedInBlock","isDefined","status","confirmationStatus","formatNumber","toString","length","Intl","NumberFormat","format","slice","isDefined","blockProgressColor","confirmedInBlock","isExpired","isDefined","isUndefined","createFilledRange","range","isUndefined","start","end","console","warn","result","i","push","isUndefined","isUndefinedOrNull","getBlockProgress","currentBlockNumber","currentBlockRef","progressElementRef","isUndefined","isUndefinedOrNull","currentBlockOffsetLeft","offsetLeft","currentBlockOffsetWidth","clientWidth","currentBlockCenterOffsetLeft","parentOffsetLeft","parentWidth","relativePosition","progress","Math","min","max","isDefined","isCurrentBlockPassedRange","blockRange","currentBlockNumber","isDefined","end","isDefined","passedBlocksInRange","range","currentBlockNumber","isDefined","start","filter","block","isDefined","useMemo","useBlockRangeState","blockRange","confirmedInBlock","currentBlockNumber","range","useMemo","createFilledRange","isExpired","isCurrentBlockPassedRange","passedBlocks","passedBlocksInRange","progressColor","blockProgressColor","isConfirmed","isDefined","CheckCircleOutline","Grow","Stack","Typography","isDefined","React","BlockConfirmationStats","confirmed","currentBlockColor","currentBlockNumberValue","passedBlocks","Stack","Typography","variant","color","sx","display","alignItems","gap","Grow","in","CheckCircleOutline","width","height","opacity","isDefined","length","map","block","Intl","NumberFormat","format","join","Box","Stack","styled","Tooltip","Typography","React","BlockRangeEntryStack","block","blockColor","blockStatus","formattedBlockNumber","updateBlockPositionRefs","sx","props","React","Stack","ref","key","position","Box","component","display","width","height","StyledBlockNumberIndicator","backgroundColor","Tooltip","title","Intl","NumberFormat","format","placement","arrow","Typography","variant","color","cursor","opacity","styled","name","theme","unstable_sx","left","transform","TransactionStackProgress","blockRange","confirmedInBlock","currentBlockNumber","props","blockPositionsRef","useRef","updateBlockPositionRefs","blockNumber","ref","current","progressElementRef","passedBlocks","progressColor","range","isConfirmed","isExpired","useBlockRangeState","blockFormatters","useMemo","BlockFormatters","progressValue","setProgressValue","useState","useLayoutEffect","isDefined","currentBlockNumberElement","progressElement","getBlockProgress","React","Stack","direction","width","gap","LinearProgress","variant","value","color","justifyContent","map","block","blockColor","blockStatus","confirmationStatus","formattedBlockNumber","formatNumber","BlockRangeEntryStack","key","BlockConfirmationStats","confirmed","currentBlockColor","currentBlockNumberValue","Intl","NumberFormat","format"]}
1
+ {"version":3,"sources":["../../src/confirmation/components/TransactionStackProgress.tsx","../../src/confirmation/helpers/BlockFormatters.ts","../../src/confirmation/helpers/blockProgressColor.ts","../../src/confirmation/helpers/createFilledRange.ts","../../src/confirmation/helpers/getBlockProgress.ts","../../src/confirmation/helpers/isCurrentBlockPassedRange.ts","../../src/confirmation/helpers/passedBlocksInRange.ts","../../src/confirmation/hooks/useBlockRangeState.ts","../../src/confirmation/components/support/BlockConfirmationStats.tsx","../../src/confirmation/components/support/BlockRangeEntryStack.tsx"],"sourcesContent":["import type { StackProps } from '@mui/material'\nimport { LinearProgress, Stack } from '@mui/material'\nimport { isDefined } from '@xylabs/sdk-js'\nimport { type BlockRange } from '@xyo-network/xl1-sdk'\nimport React, {\n useLayoutEffect,\n useMemo,\n useRef, useState,\n} from 'react'\n\nimport { BlockFormatters, getBlockProgress } from '../helpers/index.ts'\nimport { useBlockRangeState } from '../hooks/index.ts'\nimport { BlockConfirmationStats, BlockRangeEntryStack } from './support/index.ts'\n\nexport interface TransactionStackProgressProps extends StackProps {\n blockRange?: BlockRange\n confirmedInBlock?: number\n currentBlockNumber?: number\n}\n\nexport const TransactionStackProgress: React.FC<TransactionStackProgressProps> = ({\n blockRange, confirmedInBlock, currentBlockNumber, ...props\n}) => {\n const blockPositionsRef = useRef<{ [blockNumber: number]: HTMLSpanElement | null }>({})\n const updateBlockPositionRefs = (blockNumber: number, ref: HTMLSpanElement | null) => {\n blockPositionsRef.current[blockNumber] = ref\n }\n\n const progressElementRef = useRef<HTMLDivElement | null>(null)\n\n const {\n passedBlocks, progressColor, range, isConfirmed, isExpired,\n } = useBlockRangeState(blockRange, confirmedInBlock, currentBlockNumber)\n\n const blockFormatters = useMemo(() => new BlockFormatters({ confirmedInBlock, currentBlockNumber }), [confirmedInBlock, currentBlockNumber])\n\n const [progressValue, setProgressValue] = useState(0)\n\n useLayoutEffect(() => {\n // prevent updates if the current block is past the confirmed block\n if (isDefined(currentBlockNumber) && isDefined(confirmedInBlock) && currentBlockNumber > confirmedInBlock) {\n return\n }\n const currentBlockNumberElement = isDefined(currentBlockNumber) ? blockPositionsRef.current[currentBlockNumber] : null\n const progressElement = progressElementRef.current\n // since we are relying on htmlElements, we have to use layout effect\n setProgressValue(getBlockProgress(\n currentBlockNumber,\n currentBlockNumberElement,\n progressElement,\n ))\n }, [confirmedInBlock, currentBlockNumber])\n\n return (\n <Stack direction=\"row\" {...props}>\n <Stack width=\"100%\" gap={1}>\n <Stack>\n <LinearProgress ref={progressElementRef} variant=\"determinate\" value={isExpired ? 100 : progressValue} color={progressColor} />\n <Stack direction=\"row\" justifyContent=\"space-between\">\n {range.map((block) => {\n const blockColor = blockFormatters.color(block)\n const blockStatus = blockFormatters.confirmationStatus(block)\n const formattedBlockNumber = blockFormatters.formatNumber(block)\n return (\n <BlockRangeEntryStack\n key={block}\n block={block}\n blockColor={blockColor}\n blockStatus={blockStatus}\n formattedBlockNumber={formattedBlockNumber}\n updateBlockPositionRefs={updateBlockPositionRefs}\n />\n )\n })}\n </Stack>\n </Stack>\n <BlockConfirmationStats\n confirmed={isConfirmed}\n currentBlockColor={isDefined(currentBlockNumber) ? blockFormatters.color(currentBlockNumber) : 'text.secondary'}\n currentBlockNumberValue={isDefined(currentBlockNumber) ? new Intl.NumberFormat().format(currentBlockNumber) : 'N/A'}\n passedBlocks={passedBlocks}\n />\n </Stack>\n </Stack>\n )\n}\n","import { isDefined } from '@xylabs/sdk-js'\n\nexport type BlockConfirmationStatus = 'confirmed' | 'missed' | 'pending'\n\ntype BlockFormattersParams = {\n confirmedInBlock: number | undefined\n currentBlockNumber: number | undefined\n}\n\nexport class BlockFormatters {\n private readonly params: BlockFormattersParams\n\n constructor(params: BlockFormattersParams) {\n this.params = params\n }\n\n color(blockNumber: number): string {\n const { currentBlockNumber, confirmedInBlock } = this.params\n if (blockNumber === currentBlockNumber) {\n return isDefined(confirmedInBlock) && confirmedInBlock === blockNumber ? 'success.dark' : 'text'\n }\n const status = this.confirmationStatus(blockNumber)\n switch (status) {\n case 'confirmed': {\n return 'success.dark'\n }\n case 'missed': {\n return 'warning.light'\n }\n case 'pending': {\n return 'text.secondary'\n }\n default: {\n return 'text.secondary'\n }\n }\n }\n\n confirmationStatus(blockNumber: number): BlockConfirmationStatus | undefined {\n const { currentBlockNumber, confirmedInBlock } = this.params\n if (isDefined(currentBlockNumber)) {\n if (isDefined(confirmedInBlock) && blockNumber === confirmedInBlock) {\n return 'confirmed'\n }\n return currentBlockNumber > blockNumber ? 'missed' : 'pending'\n }\n }\n\n formatNumber(blockNumber: number) {\n return blockNumber.toString().length <= 5 ? new Intl.NumberFormat().format(blockNumber) : `${blockNumber.toString().slice(-2)}`\n }\n}\n","import type { LinearProgressProps } from '@mui/material'\nimport { isDefined } from '@xylabs/sdk-js'\n\nexport const blockProgressColor = (\n confirmedInBlock: number | undefined,\n isExpired: boolean | undefined,\n): LinearProgressProps['color'] => {\n if (isDefined(confirmedInBlock)) {\n return 'success'\n }\n if (isExpired) {\n return 'error'\n }\n return 'primary'\n}\n","import { isUndefined } from '@xylabs/sdk-js'\n\nexport const createFilledRange = (range?: [number, number]): number[] => {\n if (isUndefined(range)) {\n return []\n }\n const [start, end] = range\n if (end < start) {\n console.warn('Invalid range: end is less than start')\n return []\n }\n\n const result: number[] = []\n\n for (let i = start; i <= end; i++) {\n result.push(i)\n }\n\n return result\n}\n","import { isUndefined, isUndefinedOrNull } from '@xylabs/sdk-js'\n\nexport const getBlockProgress = (\n currentBlockNumber: number | undefined,\n currentBlockRef: HTMLSpanElement | null,\n progressElementRef: HTMLDivElement | null,\n) => {\n if (isUndefined(currentBlockNumber) || isUndefinedOrNull(currentBlockRef) || isUndefinedOrNull(progressElementRef)) {\n return 0\n }\n\n const currentBlockOffsetLeft = currentBlockRef.offsetLeft\n const currentBlockOffsetWidth = currentBlockRef.clientWidth / 2\n const currentBlockCenterOffsetLeft = currentBlockOffsetLeft + currentBlockOffsetWidth\n const parentOffsetLeft = progressElementRef.offsetLeft\n const parentWidth = progressElementRef.clientWidth\n\n const relativePosition = currentBlockCenterOffsetLeft - parentOffsetLeft\n const progress = (relativePosition / parentWidth) * 100\n\n return Math.min(Math.max(progress, 0), 100)\n}\n","import { isDefined } from '@xylabs/sdk-js'\nimport type { BlockRange } from '@xyo-network/xl1-sdk'\n\nexport const isCurrentBlockPassedRange = (\n blockRange: BlockRange | undefined,\n currentBlockNumber: number | undefined,\n) => {\n if (!isDefined(blockRange) || !isDefined(currentBlockNumber)) {\n return false\n }\n const [, end] = blockRange\n return currentBlockNumber > end\n}\n","import { isDefined } from '@xylabs/sdk-js'\n\nexport const passedBlocksInRange = (\n range: number[] | undefined,\n currentBlockNumber: number | undefined,\n) => {\n if (!isDefined(currentBlockNumber) || !isDefined(range)) {\n return []\n }\n const [start] = range\n return range.filter(block => block < currentBlockNumber && block >= start)\n}\n","import type { LinearProgressProps } from '@mui/material'\nimport { isDefined } from '@xylabs/sdk-js'\nimport type { BlockRange } from '@xyo-network/xl1-sdk'\nimport { useMemo } from 'react'\n\nimport {\n blockProgressColor, createFilledRange, isCurrentBlockPassedRange, passedBlocksInRange,\n} from '../helpers/index.ts'\n\ninterface BlockRangeState {\n isConfirmed: boolean\n isExpired: boolean\n passedBlocks: number[]\n progressColor: LinearProgressProps['color']\n range: number[]\n}\n\nexport const useBlockRangeState = (\n blockRange: BlockRange | undefined,\n confirmedInBlock: number | undefined,\n currentBlockNumber?: number | undefined,\n): BlockRangeState => {\n const range = useMemo(() => createFilledRange((blockRange)), [blockRange])\n\n const isExpired = useMemo(() => isCurrentBlockPassedRange(blockRange, currentBlockNumber), [blockRange, currentBlockNumber])\n\n const passedBlocks = useMemo(() => passedBlocksInRange(range, currentBlockNumber), [currentBlockNumber, range])\n\n const progressColor = useMemo(() => blockProgressColor(confirmedInBlock, isExpired), [confirmedInBlock, isExpired])\n\n const isConfirmed = isDefined(confirmedInBlock)\n\n return {\n isConfirmed, isExpired, passedBlocks, progressColor, range,\n }\n}\n","import { CheckCircleOutline } from '@mui/icons-material'\nimport {\n Grow, Stack, Typography,\n} from '@mui/material'\nimport { isDefined } from '@xylabs/sdk-js'\nimport React from 'react'\n\nexport interface BlockConfirmationStatsProps {\n confirmed?: boolean\n currentBlockColor?: string\n currentBlockNumberValue?: string\n passedBlocks?: number[]\n}\n\nexport const BlockConfirmationStats: React.FC<BlockConfirmationStatsProps> = ({\n confirmed, currentBlockColor, currentBlockNumberValue, passedBlocks,\n}) => {\n return (\n <Stack>\n <Typography\n variant=\"caption\"\n color={currentBlockColor}\n sx={{\n display: 'inline-flex', alignItems: 'center', gap: 0.5,\n }}\n >\n Current Block:\n {' '}\n {currentBlockNumberValue}\n {' '}\n <Grow in={confirmed}>\n <CheckCircleOutline sx={{ width: '0.8em', height: '0.8em' }} color=\"success\" />\n </Grow>\n </Typography>\n <Typography variant=\"caption\" color=\"warning.light\" sx={{ opacity: 0.75 }}>\n Passed Blocks:\n {' '}\n {isDefined(passedBlocks) && passedBlocks.length > 0 ? passedBlocks.map(block => new Intl.NumberFormat().format(block)).join(', ') : 'N/A'}\n </Typography>\n\n </Stack>\n )\n}\n","import type { BoxProps, StackProps } from '@mui/material'\nimport {\n Box, Stack, styled, Tooltip, Typography,\n} from '@mui/material'\nimport React from 'react'\n\nimport type { BlockConfirmationStatus } from '../../helpers/index.ts'\n\nexport interface BlockRangeEntryStackProps extends StackProps {\n block: number\n blockColor: string\n blockStatus: BlockConfirmationStatus | undefined\n formattedBlockNumber: string\n updateBlockPositionRefs?: (blockNumber: number, ref: HTMLSpanElement | null) => void\n}\n\nexport const BlockRangeEntryStack: React.FC<BlockRangeEntryStackProps> = ({\n block, blockColor, blockStatus, formattedBlockNumber, updateBlockPositionRefs, sx, ...props\n}) => {\n return (\n <Stack\n ref={(ref) => { if (updateBlockPositionRefs) updateBlockPositionRefs(block, ref) }}\n key={block}\n sx={{ position: 'relative', ...sx }}\n {...props}\n >\n <Box\n component=\"span\"\n sx={{\n display: 'flex', position: 'relative', width: '100%', height: 5,\n }}\n >\n <StyledBlockNumberIndicator component=\"span\" sx={{ backgroundColor: blockColor }} />\n </Box>\n <Tooltip\n title={`Block: ${new Intl.NumberFormat().format(block)} (${blockStatus})`}\n placement=\"top\"\n arrow\n >\n <Typography\n variant=\"caption\"\n sx={{\n color: blockColor,\n cursor: 'pointer',\n opacity: blockStatus === 'missed' ? 0.75 : 1,\n }}\n >\n {formattedBlockNumber}\n </Typography>\n </Tooltip>\n </Stack>\n )\n}\n\nconst StyledBlockNumberIndicator = styled(Box, { name: 'StyledBlockNumberIndicator' })<BoxProps>(({ theme }) => {\n return theme.unstable_sx({\n position: 'absolute',\n left: 'calc(50% - 1px)',\n transform: 'calc(translateX(-50%) - 1px)',\n height: 3,\n width: '1px',\n backgroundColor: 'primary.main',\n })\n})\n"],"mappings":";;;;AACA,SAASA,gBAAgBC,SAAAA,cAAa;AACtC,SAASC,aAAAA,kBAAiB;AAE1B,OAAOC,UACLC,iBACAC,WAAAA,UACAC,QAAQC,gBACH;;;ACRP,SAASC,iBAAiB;AASnB,IAAMC,kBAAN,MAAMA;EATb,OASaA;;;EACMC;EAEjB,YAAYA,QAA+B;AACzC,SAAKA,SAASA;EAChB;EAEAC,MAAMC,aAA6B;AACjC,UAAM,EAAEC,oBAAoBC,iBAAgB,IAAK,KAAKJ;AACtD,QAAIE,gBAAgBC,oBAAoB;AACtC,aAAOE,UAAUD,gBAAAA,KAAqBA,qBAAqBF,cAAc,iBAAiB;IAC5F;AACA,UAAMI,SAAS,KAAKC,mBAAmBL,WAAAA;AACvC,YAAQI,QAAAA;MACN,KAAK,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AA,IAAsB;IAC/FgD,yBAAyB1B,WAAUtB,kBAAAA,IAAsB,IAAIiD,KAAKC,aAAY,EAAGC,OAAOnD,kBAAAA,IAAsB;IAC9GS;;AAKV,GAjEiF;","names":["LinearProgress","Stack","isDefined","React","useLayoutEffect","useMemo","useRef","useState","isDefined","BlockFormatters","params","color","blockNumber","currentBlockNumber","confirmedInBlock","isDefined","status","confirmationStatus","formatNumber","toString","length","Intl","NumberFormat","format","slice","isDefined","blockProgressColor","confirmedInBlock","isExpired","isDefined","isUndefined","createFilledRange","range","isUndefined","start","end","console","warn","result","i","push","isUndefined","isUndefinedOrNull","getBlockProgress","currentBlockNumber","currentBlockRef","progressElementRef","isUndefined","isUndefinedOrNull","currentBlockOffsetLeft","offsetLeft","currentBlockOffsetWidth","clientWidth","currentBlockCenterOffsetLeft","parentOffsetLeft","parentWidth","relativePosition","progress","Math","min","max","isDefined","isCurrentBlockPassedRange","blockRange","currentBlockNumber","isDefined","end","isDefined","passedBlocksInRange","range","currentBlockNumber","isDefined","start","filter","block","isDefined","useMemo","useBlockRangeState","blockRange","confirmedInBlock","currentBlockNumber","range","useMemo","createFilledRange","isExpired","isCurrentBlockPassedRange","passedBlocks","passedBlocksInRange","progressColor","blockProgressColor","isConfirmed","isDefined","CheckCircleOutline","Grow","Stack","Typography","isDefined","React","BlockConfirmationStats","confirmed","currentBlockColor","currentBlockNumberValue","passedBlocks","Stack","Typography","variant","color","sx","display","alignItems","gap","Grow","in","CheckCircleOutline","width","height","opacity","isDefined","length","map","block","Intl","NumberFormat","format","join","Box","Stack","styled","Tooltip","Typography","React","BlockRangeEntryStack","block","blockColor","blockStatus","formattedBlockNumber","updateBlockPositionRefs","sx","props","React","Stack","ref","key","position","Box","component","display","width","height","StyledBlockNumberIndicator","backgroundColor","Tooltip","title","Intl","NumberFormat","format","placement","arrow","Typography","variant","color","cursor","opacity","styled","name","theme","unstable_sx","left","transform","TransactionStackProgress","blockRange","confirmedInBlock","currentBlockNumber","props","blockPositionsRef","useRef","updateBlockPositionRefs","blockNumber","ref","current","progressElementRef","passedBlocks","progressColor","range","isConfirmed","isExpired","useBlockRangeState","blockFormatters","useMemo","BlockFormatters","progressValue","setProgressValue","useState","useLayoutEffect","isDefined","currentBlockNumberElement","progressElement","getBlockProgress","React","Stack","direction","width","gap","LinearProgress","variant","value","color","justifyContent","map","block","blockColor","blockStatus","confirmationStatus","formattedBlockNumber","formatNumber","BlockRangeEntryStack","key","BlockConfirmationStats","confirmed","currentBlockColor","currentBlockNumberValue","Intl","NumberFormat","format"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "http://json.schemastore.org/package.json",
3
3
  "name": "@xyo-network/xl1-react-transaction",
4
- "version": "1.20.14",
4
+ "version": "1.20.16",
5
5
  "description": "XYO Layer One API",
6
6
  "homepage": "https://xylabs.com",
7
7
  "bugs": {
@@ -25,70 +25,115 @@
25
25
  "types": "./dist/browser/index.d.ts",
26
26
  "browser": {
27
27
  "types": "./dist/browser/index.d.ts",
28
- "source": "./src/index.ts",
29
28
  "default": "./dist/browser/index.mjs"
30
29
  },
31
- "source": "./src/index.ts",
32
30
  "default": "./dist/browser/index.mjs"
33
31
  },
34
32
  "./package.json": "./package.json"
35
33
  },
36
34
  "module": "./dist/browser/index.mjs",
37
- "source": "./src/index.ts",
38
35
  "types": "./dist/browser/index.d.ts",
39
36
  "files": [
40
37
  "dist",
41
- "src",
42
38
  "!**/*.bench.*",
43
39
  "!**/*.spec.*",
44
- "!**/*.test.*"
40
+ "!**/*.test.*",
41
+ "README.md"
45
42
  ],
43
+ "dependencies": {
44
+ "@mui/icons-material": "^7",
45
+ "@xyo-network/xl1-sdk": "^1.26.19"
46
+ },
46
47
  "devDependencies": {
47
48
  "@emotion/react": "~11.14.0",
48
49
  "@emotion/styled": "~11.14.1",
49
- "@mui/icons-material": "^7.3.9",
50
50
  "@mui/material": "^7.3.9",
51
- "@storybook/react-vite": "^10.3.3",
51
+ "@opentelemetry/api": "^1",
52
+ "@storybook/react-vite": "^10.3.5",
53
+ "@types/node": "^25.5.2",
52
54
  "@types/react": "~19.2.14",
53
- "@xylabs/sdk-js": "~5.0.90",
54
- "@xylabs/ts-scripts-common": "~7.5.11",
55
- "@xylabs/ts-scripts-yarn3": "~7.5.11",
56
- "@xylabs/tsconfig": "~7.5.11",
57
- "@xylabs/tsconfig-dom": "~7.5.11",
58
- "@xylabs/tsconfig-react": "~7.5.11",
59
- "@xyo-network/sdk-js": "~5.3.20",
60
- "@xyo-network/xl1-sdk": "~1.26.11",
61
- "axios": "^1.13.6",
62
- "dotenv": "~17.3.1",
55
+ "@xylabs/sdk-js": "~5.0.95",
56
+ "@xylabs/ts-scripts-common": "~7.9.3",
57
+ "@xylabs/ts-scripts-pnpm": "~7.9.3",
58
+ "@xylabs/tsconfig": "~7.9.3",
59
+ "@xylabs/tsconfig-dom": "~7.9.3",
60
+ "@xylabs/tsconfig-react": "~7.9.3",
61
+ "@xyo-network/account": "~5.3.30",
62
+ "@xyo-network/account-model": "~5.3.30",
63
+ "@xyo-network/api-models": "~5.3.30",
64
+ "@xyo-network/archivist-abstract": "~5.3.30",
65
+ "@xyo-network/archivist-generic": "~5.3.30",
66
+ "@xyo-network/archivist-memory": "~5.3.30",
67
+ "@xyo-network/archivist-model": "~5.3.30",
68
+ "@xyo-network/archivist-view": "~5.3.30",
69
+ "@xyo-network/archivist-wrapper": "~5.3",
70
+ "@xyo-network/boundwitness-builder": "~5.3.30",
71
+ "@xyo-network/boundwitness-validator": "~5.3.30",
72
+ "@xyo-network/bridge-abstract": "~5.3.30",
73
+ "@xyo-network/bridge-model": "~5.3.30",
74
+ "@xyo-network/config-payload-plugin": "~5.3.30",
75
+ "@xyo-network/data": "~5.3.30",
76
+ "@xyo-network/diviner-abstract": "~5.3",
77
+ "@xyo-network/diviner-boundwitness-memory": "~5.3.30",
78
+ "@xyo-network/diviner-identity": "~5.3.30",
79
+ "@xyo-network/diviner-model": "~5.3.30",
80
+ "@xyo-network/diviner-payload-generic": "~5.3.30",
81
+ "@xyo-network/diviner-payload-model": "~5.3.30",
82
+ "@xyo-network/diviner-wrapper": "~5.3",
83
+ "@xyo-network/dns": "~5.3.30",
84
+ "@xyo-network/domain-payload-plugin": "~5.3.30",
85
+ "@xyo-network/elliptic": "~5.3.30",
86
+ "@xyo-network/hash": "~5.3.30",
87
+ "@xyo-network/huri": "~5.3.30",
88
+ "@xyo-network/manifest-model": "~5.3.30",
89
+ "@xyo-network/module-abstract": "~5.3.30",
90
+ "@xyo-network/module-model": "~5.3.30",
91
+ "@xyo-network/module-resolver": "~5.3.30",
92
+ "@xyo-network/module-wrapper": "~5.3",
93
+ "@xyo-network/network": "~5.3.30",
94
+ "@xyo-network/node-abstract": "~5.3.30",
95
+ "@xyo-network/node-memory": "~5.3.30",
96
+ "@xyo-network/node-model": "~5.3.30",
97
+ "@xyo-network/node-view": "~5.3.30",
98
+ "@xyo-network/node-wrapper": "~5.3",
99
+ "@xyo-network/payload-builder": "~5.3.30",
100
+ "@xyo-network/payload-model": "~5.3.30",
101
+ "@xyo-network/payload-validator": "~5.3.30",
102
+ "@xyo-network/previous-hash-store-model": "~5.3.30",
103
+ "@xyo-network/sdk-js": "~5.3.30",
104
+ "@xyo-network/sentinel-abstract": "~5.3.30",
105
+ "@xyo-network/sentinel-memory": "~5.3.30",
106
+ "@xyo-network/sentinel-model": "~5.3.30",
107
+ "@xyo-network/wallet-model": "~5.3.30",
108
+ "@xyo-network/wasm": "~5.3.30",
109
+ "@xyo-network/witness-adhoc": "~5.3.30",
110
+ "@xyo-network/witness-model": "~5.3.30",
111
+ "ajv": "^8",
112
+ "axios": "^1.14.0",
113
+ "dotenv": "~17.4.1",
114
+ "esbuild": "*",
63
115
  "ethers": "^6.16.0",
116
+ "pako": "~2.1.0",
64
117
  "react": "^19.2.4",
65
118
  "react-dom": "^19.2.4",
66
- "storybook": "^10.3.3",
119
+ "storybook": "^10.3.5",
67
120
  "typescript": "~5.9.3",
68
- "vite": "^8.0.3",
69
- "vitest": "^4.1.2",
121
+ "vite": "^8.0.7",
122
+ "vitest": "^4.1.3",
70
123
  "zod": "^4.3.6"
71
124
  },
72
125
  "peerDependencies": {
73
- "@mui/icons-material": "^7",
74
- "@mui/material": "^7",
75
- "@xylabs/sdk-js": "^5",
76
- "@xyo-network/sdk-js": "^5",
77
- "@xyo-network/xl1-sdk": "^1",
78
- "axios": "^1",
79
- "react": "^19",
80
- "react-dom": "^19",
81
- "zod": "^4"
126
+ "@mui/material": "^7.3.9",
127
+ "@xylabs/sdk-js": "~5.0.93",
128
+ "react": "^19.2.4"
82
129
  },
83
- "packageManager": "yarn@4.6.0",
84
130
  "engines": {
85
- "node": ">=22"
131
+ "node": ">=24"
86
132
  },
87
133
  "volta": {
88
- "node": "22.5.1",
89
- "yarn": "4.6.0"
134
+ "node": ">=24"
90
135
  },
91
136
  "publishConfig": {
92
137
  "access": "public"
93
138
  }
94
- }
139
+ }
@@ -1,56 +0,0 @@
1
- import type { StoryFn } from '@storybook/react-vite'
2
- import { isUndefined } from '@xylabs/sdk-js'
3
- import { asBlockRange } from '@xyo-network/xl1-sdk'
4
- import React, { useEffect, useState } from 'react'
5
-
6
- import { TransactionStackProgress } from './TransactionStackProgress.tsx'
7
-
8
- export default {
9
- title: 'transaction/stack/progress',
10
- component: TransactionStackProgress,
11
- }
12
-
13
- const START_BLOCK = 100_001
14
- const END_BLOCK = 100_010
15
-
16
- const Template: StoryFn<typeof TransactionStackProgress> = args => <TransactionStackProgress {...args} />
17
- const TemplateWithChangingValues: StoryFn<typeof TransactionStackProgress> = (args) => {
18
- const [currentBlockNumber, setCurrentBlockNumber] = useState<number>()
19
- useEffect(() => {
20
- const interval = setInterval(() => {
21
- setCurrentBlockNumber((prev) => {
22
- if (isUndefined(prev)) {
23
- return START_BLOCK
24
- }
25
- if (prev >= END_BLOCK + 2) {
26
- return START_BLOCK
27
- }
28
- return prev + 1
29
- })
30
- }, 1000)
31
- return () => clearInterval(interval)
32
- }, [])
33
- return <TransactionStackProgress currentBlockNumber={currentBlockNumber} {...args} />
34
- }
35
-
36
- const Default = Template.bind({})
37
- Default.args = {}
38
-
39
- const WithValues = Template.bind({})
40
- WithValues.args = { currentBlockNumber: 100_003, blockRange: asBlockRange([START_BLOCK, END_BLOCK]) }
41
-
42
- const WithConfirmed = Template.bind({})
43
- WithConfirmed.args = {
44
- currentBlockNumber: 100_004, blockRange: asBlockRange([START_BLOCK, END_BLOCK]), confirmedInBlock: 100_004,
45
- }
46
-
47
- const WithExpired = Template.bind({})
48
- WithExpired.args = { currentBlockNumber: END_BLOCK + 2, blockRange: asBlockRange([START_BLOCK, END_BLOCK]) }
49
-
50
- const WithChangingValues = TemplateWithChangingValues.bind({})
51
- WithChangingValues.args = { blockRange: asBlockRange([START_BLOCK, END_BLOCK]) }
52
-
53
- export {
54
- Default, WithChangingValues, WithConfirmed, WithExpired,
55
- WithValues,
56
- }
@@ -1,86 +0,0 @@
1
- import type { StackProps } from '@mui/material'
2
- import { LinearProgress, Stack } from '@mui/material'
3
- import { isDefined } from '@xylabs/sdk-js'
4
- import { type BlockRange } from '@xyo-network/xl1-sdk'
5
- import React, {
6
- useLayoutEffect,
7
- useMemo,
8
- useRef, useState,
9
- } from 'react'
10
-
11
- import { BlockFormatters, getBlockProgress } from '../helpers/index.ts'
12
- import { useBlockRangeState } from '../hooks/index.ts'
13
- import { BlockConfirmationStats, BlockRangeEntryStack } from './support/index.ts'
14
-
15
- export interface TransactionStackProgressProps extends StackProps {
16
- blockRange?: BlockRange
17
- confirmedInBlock?: number
18
- currentBlockNumber?: number
19
- }
20
-
21
- export const TransactionStackProgress: React.FC<TransactionStackProgressProps> = ({
22
- blockRange, confirmedInBlock, currentBlockNumber, ...props
23
- }) => {
24
- const blockPositionsRef = useRef<{ [blockNumber: number]: HTMLSpanElement | null }>({})
25
- const updateBlockPositionRefs = (blockNumber: number, ref: HTMLSpanElement | null) => {
26
- blockPositionsRef.current[blockNumber] = ref
27
- }
28
-
29
- const progressElementRef = useRef<HTMLDivElement | null>(null)
30
-
31
- const {
32
- passedBlocks, progressColor, range, isConfirmed, isExpired,
33
- } = useBlockRangeState(blockRange, confirmedInBlock, currentBlockNumber)
34
-
35
- const blockFormatters = useMemo(() => new BlockFormatters({ confirmedInBlock, currentBlockNumber }), [confirmedInBlock, currentBlockNumber])
36
-
37
- const [progressValue, setProgressValue] = useState(0)
38
-
39
- useLayoutEffect(() => {
40
- // prevent updates if the current block is past the confirmed block
41
- if (isDefined(currentBlockNumber) && isDefined(confirmedInBlock) && currentBlockNumber > confirmedInBlock) {
42
- return
43
- }
44
- const currentBlockNumberElement = isDefined(currentBlockNumber) ? blockPositionsRef.current[currentBlockNumber] : null
45
- const progressElement = progressElementRef.current
46
- // since we are relying on htmlElements, we have to use layout effect
47
- setProgressValue(getBlockProgress(
48
- currentBlockNumber,
49
- currentBlockNumberElement,
50
- progressElement,
51
- ))
52
- }, [confirmedInBlock, currentBlockNumber])
53
-
54
- return (
55
- <Stack direction="row" {...props}>
56
- <Stack width="100%" gap={1}>
57
- <Stack>
58
- <LinearProgress ref={progressElementRef} variant="determinate" value={isExpired ? 100 : progressValue} color={progressColor} />
59
- <Stack direction="row" justifyContent="space-between">
60
- {range.map((block) => {
61
- const blockColor = blockFormatters.color(block)
62
- const blockStatus = blockFormatters.confirmationStatus(block)
63
- const formattedBlockNumber = blockFormatters.formatNumber(block)
64
- return (
65
- <BlockRangeEntryStack
66
- key={block}
67
- block={block}
68
- blockColor={blockColor}
69
- blockStatus={blockStatus}
70
- formattedBlockNumber={formattedBlockNumber}
71
- updateBlockPositionRefs={updateBlockPositionRefs}
72
- />
73
- )
74
- })}
75
- </Stack>
76
- </Stack>
77
- <BlockConfirmationStats
78
- confirmed={isConfirmed}
79
- currentBlockColor={isDefined(currentBlockNumber) ? blockFormatters.color(currentBlockNumber) : 'text.secondary'}
80
- currentBlockNumberValue={isDefined(currentBlockNumber) ? new Intl.NumberFormat().format(currentBlockNumber) : 'N/A'}
81
- passedBlocks={passedBlocks}
82
- />
83
- </Stack>
84
- </Stack>
85
- )
86
- }
@@ -1 +0,0 @@
1
- export * from './TransactionStackProgress.tsx'
@@ -1,43 +0,0 @@
1
- import { CheckCircleOutline } from '@mui/icons-material'
2
- import {
3
- Grow, Stack, Typography,
4
- } from '@mui/material'
5
- import { isDefined } from '@xylabs/sdk-js'
6
- import React from 'react'
7
-
8
- export interface BlockConfirmationStatsProps {
9
- confirmed?: boolean
10
- currentBlockColor?: string
11
- currentBlockNumberValue?: string
12
- passedBlocks?: number[]
13
- }
14
-
15
- export const BlockConfirmationStats: React.FC<BlockConfirmationStatsProps> = ({
16
- confirmed, currentBlockColor, currentBlockNumberValue, passedBlocks,
17
- }) => {
18
- return (
19
- <Stack>
20
- <Typography
21
- variant="caption"
22
- color={currentBlockColor}
23
- sx={{
24
- display: 'inline-flex', alignItems: 'center', gap: 0.5,
25
- }}
26
- >
27
- Current Block:
28
- {' '}
29
- {currentBlockNumberValue}
30
- {' '}
31
- <Grow in={confirmed}>
32
- <CheckCircleOutline sx={{ width: '0.8em', height: '0.8em' }} color="success" />
33
- </Grow>
34
- </Typography>
35
- <Typography variant="caption" color="warning.light" sx={{ opacity: 0.75 }}>
36
- Passed Blocks:
37
- {' '}
38
- {isDefined(passedBlocks) && passedBlocks.length > 0 ? passedBlocks.map(block => new Intl.NumberFormat().format(block)).join(', ') : 'N/A'}
39
- </Typography>
40
-
41
- </Stack>
42
- )
43
- }
@@ -1,64 +0,0 @@
1
- import type { BoxProps, StackProps } from '@mui/material'
2
- import {
3
- Box, Stack, styled, Tooltip, Typography,
4
- } from '@mui/material'
5
- import React from 'react'
6
-
7
- import type { BlockConfirmationStatus } from '../../helpers/index.ts'
8
-
9
- export interface BlockRangeEntryStackProps extends StackProps {
10
- block: number
11
- blockColor: string
12
- blockStatus: BlockConfirmationStatus | undefined
13
- formattedBlockNumber: string
14
- updateBlockPositionRefs?: (blockNumber: number, ref: HTMLSpanElement | null) => void
15
- }
16
-
17
- export const BlockRangeEntryStack: React.FC<BlockRangeEntryStackProps> = ({
18
- block, blockColor, blockStatus, formattedBlockNumber, updateBlockPositionRefs, sx, ...props
19
- }) => {
20
- return (
21
- <Stack
22
- ref={(ref) => { if (updateBlockPositionRefs) updateBlockPositionRefs(block, ref) }}
23
- key={block}
24
- sx={{ position: 'relative', ...sx }}
25
- {...props}
26
- >
27
- <Box
28
- component="span"
29
- sx={{
30
- display: 'flex', position: 'relative', width: '100%', height: 5,
31
- }}
32
- >
33
- <StyledBlockNumberIndicator component="span" sx={{ backgroundColor: blockColor }} />
34
- </Box>
35
- <Tooltip
36
- title={`Block: ${new Intl.NumberFormat().format(block)} (${blockStatus})`}
37
- placement="top"
38
- arrow
39
- >
40
- <Typography
41
- variant="caption"
42
- sx={{
43
- color: blockColor,
44
- cursor: 'pointer',
45
- opacity: blockStatus === 'missed' ? 0.75 : 1,
46
- }}
47
- >
48
- {formattedBlockNumber}
49
- </Typography>
50
- </Tooltip>
51
- </Stack>
52
- )
53
- }
54
-
55
- const StyledBlockNumberIndicator = styled(Box, { name: 'StyledBlockNumberIndicator' })<BoxProps>(({ theme }) => {
56
- return theme.unstable_sx({
57
- position: 'absolute',
58
- left: 'calc(50% - 1px)',
59
- transform: 'calc(translateX(-50%) - 1px)',
60
- height: 3,
61
- width: '1px',
62
- backgroundColor: 'primary.main',
63
- })
64
- })
@@ -1,2 +0,0 @@
1
- export * from './BlockConfirmationStats.tsx'
2
- export * from './BlockRangeEntryStack.tsx'
@@ -1,52 +0,0 @@
1
- import { isDefined } from '@xylabs/sdk-js'
2
-
3
- export type BlockConfirmationStatus = 'confirmed' | 'missed' | 'pending'
4
-
5
- type BlockFormattersParams = {
6
- confirmedInBlock: number | undefined
7
- currentBlockNumber: number | undefined
8
- }
9
-
10
- export class BlockFormatters {
11
- private readonly params: BlockFormattersParams
12
-
13
- constructor(params: BlockFormattersParams) {
14
- this.params = params
15
- }
16
-
17
- color(blockNumber: number): string {
18
- const { currentBlockNumber, confirmedInBlock } = this.params
19
- if (blockNumber === currentBlockNumber) {
20
- return isDefined(confirmedInBlock) && confirmedInBlock === blockNumber ? 'success.dark' : 'text'
21
- }
22
- const status = this.confirmationStatus(blockNumber)
23
- switch (status) {
24
- case 'confirmed': {
25
- return 'success.dark'
26
- }
27
- case 'missed': {
28
- return 'warning.light'
29
- }
30
- case 'pending': {
31
- return 'text.secondary'
32
- }
33
- default: {
34
- return 'text.secondary'
35
- }
36
- }
37
- }
38
-
39
- confirmationStatus(blockNumber: number): BlockConfirmationStatus | undefined {
40
- const { currentBlockNumber, confirmedInBlock } = this.params
41
- if (isDefined(currentBlockNumber)) {
42
- if (isDefined(confirmedInBlock) && blockNumber === confirmedInBlock) {
43
- return 'confirmed'
44
- }
45
- return currentBlockNumber > blockNumber ? 'missed' : 'pending'
46
- }
47
- }
48
-
49
- formatNumber(blockNumber: number) {
50
- return blockNumber.toString().length <= 5 ? new Intl.NumberFormat().format(blockNumber) : `${blockNumber.toString().slice(-2)}`
51
- }
52
- }
@@ -1,15 +0,0 @@
1
- import type { LinearProgressProps } from '@mui/material'
2
- import { isDefined } from '@xylabs/sdk-js'
3
-
4
- export const blockProgressColor = (
5
- confirmedInBlock: number | undefined,
6
- isExpired: boolean | undefined,
7
- ): LinearProgressProps['color'] => {
8
- if (isDefined(confirmedInBlock)) {
9
- return 'success'
10
- }
11
- if (isExpired) {
12
- return 'error'
13
- }
14
- return 'primary'
15
- }
@@ -1,20 +0,0 @@
1
- import { isUndefined } from '@xylabs/sdk-js'
2
-
3
- export const createFilledRange = (range?: [number, number]): number[] => {
4
- if (isUndefined(range)) {
5
- return []
6
- }
7
- const [start, end] = range
8
- if (end < start) {
9
- console.warn('Invalid range: end is less than start')
10
- return []
11
- }
12
-
13
- const result: number[] = []
14
-
15
- for (let i = start; i <= end; i++) {
16
- result.push(i)
17
- }
18
-
19
- return result
20
- }