@xyo-network/xl1-react-transaction 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.
- package/README.md +11 -2221
- package/dist/browser/confirmation/hooks/useBlockRangeState.d.ts +6 -3
- package/dist/browser/confirmation/hooks/useBlockRangeState.d.ts.map +1 -1
- package/dist/browser/index.mjs.map +1 -1
- package/package.json +82 -37
- package/src/confirmation/components/TransactionStackProgress.stories.tsx +0 -56
- package/src/confirmation/components/TransactionStackProgress.tsx +0 -86
- package/src/confirmation/components/index.ts +0 -1
- package/src/confirmation/components/support/BlockConfirmationStats.tsx +0 -43
- package/src/confirmation/components/support/BlockRangeEntryStack.tsx +0 -64
- package/src/confirmation/components/support/index.ts +0 -2
- package/src/confirmation/helpers/BlockFormatters.ts +0 -52
- package/src/confirmation/helpers/blockProgressColor.ts +0 -15
- package/src/confirmation/helpers/createFilledRange.ts +0 -20
- package/src/confirmation/helpers/getBlockProgress.ts +0 -22
- package/src/confirmation/helpers/index.ts +0 -6
- package/src/confirmation/helpers/isCurrentBlockPassedRange.ts +0 -13
- package/src/confirmation/helpers/passedBlocksInRange.ts +0 -12
- package/src/confirmation/hooks/index.ts +0 -1
- package/src/confirmation/hooks/useBlockRangeState.ts +0 -27
- package/src/confirmation/index.ts +0 -3
- package/src/index.ts +0 -1
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { isUndefined, isUndefinedOrNull } from '@xylabs/sdk-js'
|
|
2
|
-
|
|
3
|
-
export const getBlockProgress = (
|
|
4
|
-
currentBlockNumber: number | undefined,
|
|
5
|
-
currentBlockRef: HTMLSpanElement | null,
|
|
6
|
-
progressElementRef: HTMLDivElement | null,
|
|
7
|
-
) => {
|
|
8
|
-
if (isUndefined(currentBlockNumber) || isUndefinedOrNull(currentBlockRef) || isUndefinedOrNull(progressElementRef)) {
|
|
9
|
-
return 0
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const currentBlockOffsetLeft = currentBlockRef.offsetLeft
|
|
13
|
-
const currentBlockOffsetWidth = currentBlockRef.clientWidth / 2
|
|
14
|
-
const currentBlockCenterOffsetLeft = currentBlockOffsetLeft + currentBlockOffsetWidth
|
|
15
|
-
const parentOffsetLeft = progressElementRef.offsetLeft
|
|
16
|
-
const parentWidth = progressElementRef.clientWidth
|
|
17
|
-
|
|
18
|
-
const relativePosition = currentBlockCenterOffsetLeft - parentOffsetLeft
|
|
19
|
-
const progress = (relativePosition / parentWidth) * 100
|
|
20
|
-
|
|
21
|
-
return Math.min(Math.max(progress, 0), 100)
|
|
22
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { isDefined } from '@xylabs/sdk-js'
|
|
2
|
-
import type { BlockRange } from '@xyo-network/xl1-sdk'
|
|
3
|
-
|
|
4
|
-
export const isCurrentBlockPassedRange = (
|
|
5
|
-
blockRange: BlockRange | undefined,
|
|
6
|
-
currentBlockNumber: number | undefined,
|
|
7
|
-
) => {
|
|
8
|
-
if (!isDefined(blockRange) || !isDefined(currentBlockNumber)) {
|
|
9
|
-
return false
|
|
10
|
-
}
|
|
11
|
-
const [, end] = blockRange
|
|
12
|
-
return currentBlockNumber > end
|
|
13
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { isDefined } from '@xylabs/sdk-js'
|
|
2
|
-
|
|
3
|
-
export const passedBlocksInRange = (
|
|
4
|
-
range: number[] | undefined,
|
|
5
|
-
currentBlockNumber: number | undefined,
|
|
6
|
-
) => {
|
|
7
|
-
if (!isDefined(currentBlockNumber) || !isDefined(range)) {
|
|
8
|
-
return []
|
|
9
|
-
}
|
|
10
|
-
const [start] = range
|
|
11
|
-
return range.filter(block => block < currentBlockNumber && block >= start)
|
|
12
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './useBlockRangeState.ts'
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { isDefined } from '@xylabs/sdk-js'
|
|
2
|
-
import type { BlockRange } from '@xyo-network/xl1-sdk'
|
|
3
|
-
import { useMemo } from 'react'
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
blockProgressColor, createFilledRange, isCurrentBlockPassedRange, passedBlocksInRange,
|
|
7
|
-
} from '../helpers/index.ts'
|
|
8
|
-
|
|
9
|
-
export const useBlockRangeState = (
|
|
10
|
-
blockRange: BlockRange | undefined,
|
|
11
|
-
confirmedInBlock: number | undefined,
|
|
12
|
-
currentBlockNumber?: number | undefined,
|
|
13
|
-
) => {
|
|
14
|
-
const range = useMemo(() => createFilledRange((blockRange)), [blockRange])
|
|
15
|
-
|
|
16
|
-
const isExpired = useMemo(() => isCurrentBlockPassedRange(blockRange, currentBlockNumber), [blockRange, currentBlockNumber])
|
|
17
|
-
|
|
18
|
-
const passedBlocks = useMemo(() => passedBlocksInRange(range, currentBlockNumber), [currentBlockNumber, range])
|
|
19
|
-
|
|
20
|
-
const progressColor = useMemo(() => blockProgressColor(confirmedInBlock, isExpired), [confirmedInBlock, isExpired])
|
|
21
|
-
|
|
22
|
-
const isConfirmed = isDefined(confirmedInBlock)
|
|
23
|
-
|
|
24
|
-
return {
|
|
25
|
-
isConfirmed, isExpired, passedBlocks, progressColor, range,
|
|
26
|
-
}
|
|
27
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './confirmation/index.ts'
|