@xyo-network/react-chain-blockchain 1.18.0-rc.1 → 1.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/components/account/BalanceHistoryFlexbox.d.ts +1 -1
- package/dist/browser/components/account/BalanceHistoryFlexbox.d.ts.map +1 -1
- package/dist/browser/components/account/helpers/formatBalanceMagnitude.d.ts +1 -1
- package/dist/browser/components/account/helpers/formatBalanceMagnitude.d.ts.map +1 -1
- package/dist/browser/components/account/hooks/usePagedAccountBalanceHistory.d.ts +1 -1
- package/dist/browser/components/account/hooks/usePagedAccountBalanceHistory.d.ts.map +1 -1
- package/dist/browser/components/block/helpers/blockProducer.d.ts +6 -2
- package/dist/browser/components/block/helpers/blockProducer.d.ts.map +1 -1
- package/dist/browser/components/block/helpers/payloadCountsFromBlock.d.ts +1 -1
- package/dist/browser/components/block/helpers/payloadCountsFromBlock.d.ts.map +1 -1
- package/dist/browser/components/block/hooks/useBlockProducer.d.ts +6 -2
- package/dist/browser/components/block/hooks/useBlockProducer.d.ts.map +1 -1
- package/dist/browser/components/block/hooks/usePayloadCountsFromBlock.d.ts +1 -1
- package/dist/browser/components/block/hooks/usePayloadCountsFromBlock.d.ts.map +1 -1
- package/dist/browser/components/block/table/cell/lib/BlockTableCellProps.d.ts +1 -1
- package/dist/browser/components/block/table/cell/lib/BlockTableCellProps.d.ts.map +1 -1
- package/dist/browser/components/chain/hooks/useOnBlock.d.ts +21 -13
- package/dist/browser/components/chain/hooks/useOnBlock.d.ts.map +1 -1
- package/dist/browser/components/index.d.ts +1 -0
- package/dist/browser/components/index.d.ts.map +1 -1
- package/dist/browser/components/payload/builder/transfer/Form.d.ts.map +1 -1
- package/dist/browser/components/payload/builder/transfer/builder/SingleFlexbox.d.ts.map +1 -1
- package/dist/browser/components/payload/fields/XyoAddressTextField.d.ts.map +1 -1
- package/dist/browser/components/rate/SpanTypography.d.ts +8 -0
- package/dist/browser/components/rate/SpanTypography.d.ts.map +1 -0
- package/dist/browser/components/rate/SpeedTypography.d.ts +7 -0
- package/dist/browser/components/rate/SpeedTypography.d.ts.map +1 -0
- package/dist/browser/components/rate/TimeTypography.d.ts +7 -0
- package/dist/browser/components/rate/TimeTypography.d.ts.map +1 -0
- package/dist/browser/components/rate/flexbox/FlexBox.d.ts +7 -0
- package/dist/browser/components/rate/flexbox/FlexBox.d.ts.map +1 -0
- package/dist/browser/components/rate/flexbox/FlexBox.stories.d.ts +10 -0
- package/dist/browser/components/rate/flexbox/FlexBox.stories.d.ts.map +1 -0
- package/dist/browser/components/rate/flexbox/index.d.ts +2 -0
- package/dist/browser/components/rate/flexbox/index.d.ts.map +1 -0
- package/dist/browser/components/rate/gauge/Container.d.ts +15 -0
- package/dist/browser/components/rate/gauge/Container.d.ts.map +1 -0
- package/dist/browser/components/rate/gauge/Container.stories.d.ts +12 -0
- package/dist/browser/components/rate/gauge/Container.stories.d.ts.map +1 -0
- package/dist/browser/components/rate/gauge/Pointer.d.ts +6 -0
- package/dist/browser/components/rate/gauge/Pointer.d.ts.map +1 -0
- package/dist/browser/components/rate/gauge/Ticks.d.ts +38 -0
- package/dist/browser/components/rate/gauge/Ticks.d.ts.map +1 -0
- package/dist/browser/components/rate/gauge/WithLabel.d.ts +5 -0
- package/dist/browser/components/rate/gauge/WithLabel.d.ts.map +1 -0
- package/dist/browser/components/rate/gauge/WithLabel.stories.d.ts +11 -0
- package/dist/browser/components/rate/gauge/WithLabel.stories.d.ts.map +1 -0
- package/dist/browser/components/rate/gauge/helpers/blockRateConversions.d.ts +4 -0
- package/dist/browser/components/rate/gauge/helpers/blockRateConversions.d.ts.map +1 -0
- package/dist/browser/components/rate/gauge/helpers/index.d.ts +2 -0
- package/dist/browser/components/rate/gauge/helpers/index.d.ts.map +1 -0
- package/dist/browser/components/rate/gauge/index.d.ts +5 -0
- package/dist/browser/components/rate/gauge/index.d.ts.map +1 -0
- package/dist/browser/components/rate/index.d.ts +7 -0
- package/dist/browser/components/rate/index.d.ts.map +1 -0
- package/dist/browser/components/rate/support/MetricTypography.d.ts +11 -0
- package/dist/browser/components/rate/support/MetricTypography.d.ts.map +1 -0
- package/dist/browser/components/rate/support/index.d.ts +2 -0
- package/dist/browser/components/rate/support/index.d.ts.map +1 -0
- package/dist/browser/components/transactions/TransactionsQuickTipButton.d.ts.map +1 -1
- package/dist/browser/context/analyzer/state.d.ts +1 -1
- package/dist/browser/context/analyzer/state.d.ts.map +1 -1
- package/dist/browser/context/chain/Provider.d.ts.map +1 -1
- package/dist/browser/context/chain/State.d.ts +1 -2
- package/dist/browser/context/chain/State.d.ts.map +1 -1
- package/dist/browser/helpers/rate/index.d.ts +2 -0
- package/dist/browser/helpers/rate/index.d.ts.map +1 -0
- package/dist/browser/helpers/rate/rateUnitToLabel.d.ts +3 -0
- package/dist/browser/helpers/rate/rateUnitToLabel.d.ts.map +1 -0
- package/dist/browser/helpers/txsFromBlock.d.ts +4 -22
- package/dist/browser/helpers/txsFromBlock.d.ts.map +1 -1
- package/dist/browser/hooks/chain-iterator/useChainIteratorParams.d.ts +47 -143
- package/dist/browser/hooks/chain-iterator/useChainIteratorParams.d.ts.map +1 -1
- package/dist/browser/hooks/useTxsFromBlock.d.ts +2 -22
- package/dist/browser/hooks/useTxsFromBlock.d.ts.map +1 -1
- package/dist/browser/index.mjs +719 -326
- package/dist/browser/index.mjs.map +1 -1
- package/dist/browser/types/BlockComponentProps.d.ts +1 -1
- package/dist/browser/types/BlockComponentProps.d.ts.map +1 -1
- package/dist/browser/types/BlockComponents.d.ts +1 -1
- package/dist/browser/types/BlockComponents.d.ts.map +1 -1
- package/dist/browser/types/render/BlockChainRenderProps.d.ts +1 -2
- package/dist/browser/types/render/BlockChainRenderProps.d.ts.map +1 -1
- package/package.json +32 -33
- package/src/components/account/BalanceHistoryFlexbox.tsx +2 -2
- package/src/components/account/helpers/formatBalanceMagnitude.ts +1 -1
- package/src/components/account/hooks/usePagedAccountBalanceHistory.ts +9 -14
- package/src/components/block/helpers/blockProducer.ts +1 -1
- package/src/components/block/helpers/payloadCountsFromBlock.ts +1 -1
- package/src/components/block/hooks/useBlockProducer.ts +1 -1
- package/src/components/block/hooks/usePayloadCountsFromBlock.ts +1 -1
- package/src/components/block/table/cell/lib/BlockTableCellProps.ts +1 -1
- package/src/components/chain/hooks/useOnBlock.ts +3 -3
- package/src/components/index.ts +1 -0
- package/src/components/payload/builder/transfer/Form.tsx +5 -2
- package/src/components/payload/builder/transfer/builder/SingleFlexbox.tsx +12 -15
- package/src/components/payload/fields/XyoAddressTextField.tsx +10 -3
- package/src/components/rate/SpanTypography.tsx +20 -0
- package/src/components/rate/SpeedTypography.tsx +17 -0
- package/src/components/rate/TimeTypography.tsx +17 -0
- package/src/components/rate/flexbox/FlexBox.stories.tsx +44 -0
- package/src/components/rate/flexbox/FlexBox.tsx +31 -0
- package/src/components/rate/flexbox/index.ts +1 -0
- package/src/components/rate/gauge/Container.stories.tsx +77 -0
- package/src/components/rate/gauge/Container.tsx +75 -0
- package/src/components/rate/gauge/Pointer.tsx +67 -0
- package/src/components/rate/gauge/Ticks.tsx +122 -0
- package/src/components/rate/gauge/WithLabel.stories.tsx +70 -0
- package/src/components/rate/gauge/WithLabel.tsx +20 -0
- package/src/components/rate/gauge/helpers/blockRateConversions.ts +104 -0
- package/src/components/rate/gauge/helpers/index.ts +1 -0
- package/src/components/rate/gauge/index.ts +4 -0
- package/src/components/rate/index.ts +6 -0
- package/src/components/rate/support/MetricTypography.tsx +78 -0
- package/src/components/rate/support/index.ts +1 -0
- package/src/components/transactions/TransactionsQuickTipButton.tsx +14 -9
- package/src/context/analyzer/Provider.tsx +2 -2
- package/src/context/analyzer/state.ts +1 -1
- package/src/context/chain/Provider.tsx +28 -21
- package/src/context/chain/State.ts +1 -2
- package/src/helpers/rate/index.ts +1 -0
- package/src/helpers/rate/rateUnitToLabel.ts +27 -0
- package/src/helpers/txsFromBlock.ts +4 -2
- package/src/hooks/chain-iterator/useChainIteratorParams.ts +13 -4
- package/src/hooks/useTxsFromBlock.ts +1 -1
- package/src/types/BlockComponentProps.ts +1 -1
- package/src/types/BlockComponents.ts +1 -1
- package/src/types/render/BlockChainRenderProps.ts +1 -2
|
@@ -1,40 +1,47 @@
|
|
|
1
|
+
import { isDefined } from '@xylabs/sdk-js'
|
|
1
2
|
import type { PropsWithChildren } from 'react'
|
|
2
|
-
import React, {
|
|
3
|
+
import React, {
|
|
4
|
+
useCallback, useMemo, useState,
|
|
5
|
+
} from 'react'
|
|
3
6
|
|
|
4
7
|
import { ChainInfoContext } from './Context.ts'
|
|
5
8
|
import type { ChainInfoState } from './State.ts'
|
|
6
9
|
|
|
7
|
-
interface ChainInfoProviderProps extends PropsWithChildren, Omit<ChainInfoState, 'provided'> {
|
|
8
|
-
}
|
|
10
|
+
interface ChainInfoProviderProps extends PropsWithChildren, Omit<ChainInfoState, 'provided'> {}
|
|
9
11
|
|
|
10
12
|
export const ChainInfoProvider: React.FC<ChainInfoProviderProps> = ({
|
|
11
13
|
children, chainArchivist: chainArchivistProp, chainId: chainIdProp, chainIterator: chainIteratorProp,
|
|
12
14
|
}) => {
|
|
13
15
|
const [chainArchivist, setChainArchivist] = useState<ChainInfoState['chainArchivist']>(chainArchivistProp)
|
|
16
|
+
const [previousChainArchivist, setPreviousChainArchivist] = useState<ChainInfoState['chainArchivist']>(chainArchivistProp)
|
|
17
|
+
if (isDefined(chainArchivistProp) && chainArchivistProp !== previousChainArchivist) {
|
|
18
|
+
setChainArchivist(chainArchivistProp)
|
|
19
|
+
setPreviousChainArchivist(chainArchivistProp)
|
|
20
|
+
}
|
|
21
|
+
|
|
14
22
|
const [chainId, setChainId] = useState<ChainInfoState['chainId']>(chainIdProp)
|
|
23
|
+
const [previousChainId, setPreviousChainId] = useState<ChainInfoState['chainId']>(chainIdProp)
|
|
24
|
+
if (isDefined(chainIdProp) && chainIdProp !== previousChainId) {
|
|
25
|
+
setChainId(chainIdProp)
|
|
26
|
+
setPreviousChainId(chainIdProp)
|
|
27
|
+
}
|
|
28
|
+
|
|
15
29
|
const [chainIterator, setChainIterator] = useState<ChainInfoState['chainIterator']>(chainIteratorProp)
|
|
30
|
+
const [previousChainIterator, setPreviousChainIterator] = useState<ChainInfoState['chainIterator']>(chainIteratorProp)
|
|
31
|
+
if (isDefined(chainIteratorProp) && chainIteratorProp !== previousChainIterator) {
|
|
32
|
+
setChainIterator(chainIteratorProp)
|
|
33
|
+
setPreviousChainIterator(chainIteratorProp)
|
|
34
|
+
}
|
|
16
35
|
|
|
17
|
-
const updateChainArchivist = (chainArchivist: ChainInfoState['chainArchivist']) => {
|
|
36
|
+
const updateChainArchivist = useCallback((chainArchivist: ChainInfoState['chainArchivist']) => {
|
|
18
37
|
setChainArchivist(chainArchivist)
|
|
19
|
-
}
|
|
20
|
-
const updateChainId = (chainId: ChainInfoState['chainId']) => {
|
|
38
|
+
}, [])
|
|
39
|
+
const updateChainId = useCallback((chainId: ChainInfoState['chainId']) => {
|
|
21
40
|
setChainId(chainId)
|
|
22
|
-
}
|
|
23
|
-
const updateChainIterator = (chainIterator: ChainInfoState['chainIterator']) => {
|
|
41
|
+
}, [])
|
|
42
|
+
const updateChainIterator = useCallback((chainIterator: ChainInfoState['chainIterator']) => {
|
|
24
43
|
setChainIterator(chainIterator)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
useMemo(() => {
|
|
28
|
-
updateChainArchivist(chainArchivistProp)
|
|
29
|
-
}, [chainArchivistProp])
|
|
30
|
-
|
|
31
|
-
useMemo(() => {
|
|
32
|
-
updateChainId(chainIdProp)
|
|
33
|
-
}, [chainIdProp])
|
|
34
|
-
|
|
35
|
-
useMemo(() => {
|
|
36
|
-
updateChainIterator(chainIteratorProp)
|
|
37
|
-
}, [chainIteratorProp])
|
|
44
|
+
}, [])
|
|
38
45
|
|
|
39
46
|
const chainState: ChainInfoState = useMemo(() => ({
|
|
40
47
|
chainArchivist,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { ContextExState } from '@xylabs/react-shared'
|
|
2
2
|
import type { ArchivistInstance } from '@xyo-network/archivist-model'
|
|
3
|
-
import type { ChainId } from '@xyo-network/xl1-
|
|
4
|
-
import type { ChainBlockNumberIteratorService } from '@xyo-network/xl1-protocol-sdk'
|
|
3
|
+
import type { ChainBlockNumberIteratorService, ChainId } from '@xyo-network/xl1-sdk'
|
|
5
4
|
|
|
6
5
|
export type ChainInfoState = ContextExState<{
|
|
7
6
|
chainArchivist?: ArchivistInstance
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './rateUnitToLabel.ts'
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { TimeDurations } from '@xyo-network/xl1-sdk'
|
|
2
|
+
|
|
3
|
+
export const rateUnitToLabel = (rateUnit: keyof TimeDurations) => {
|
|
4
|
+
switch (rateUnit) {
|
|
5
|
+
case 'millis': {
|
|
6
|
+
return 'b/ms'
|
|
7
|
+
}
|
|
8
|
+
case 'seconds': {
|
|
9
|
+
return 'b/s'
|
|
10
|
+
}
|
|
11
|
+
case 'minutes': {
|
|
12
|
+
return 'b/m'
|
|
13
|
+
}
|
|
14
|
+
case 'hours': {
|
|
15
|
+
return 'b/h'
|
|
16
|
+
}
|
|
17
|
+
case 'days': {
|
|
18
|
+
return 'b/d'
|
|
19
|
+
}
|
|
20
|
+
case 'weeks': {
|
|
21
|
+
return 'b/w'
|
|
22
|
+
}
|
|
23
|
+
default: {
|
|
24
|
+
return rateUnit
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type { Hash } from '@xylabs/sdk-js'
|
|
1
2
|
import { HydratedBlockWrapper } from '@xyo-network/chain-wrappers'
|
|
2
3
|
import { PayloadBuilder } from '@xyo-network/payload-builder'
|
|
3
|
-
import type {
|
|
4
|
+
import type { Payload } from '@xyo-network/payload-model'
|
|
5
|
+
import type { HydratedBlockWithHashMeta } from '@xyo-network/xl1-sdk'
|
|
4
6
|
|
|
5
|
-
export const txsFromBlock = async (block: HydratedBlockWithHashMeta) => {
|
|
7
|
+
export const txsFromBlock = async (block: HydratedBlockWithHashMeta): Promise<[Payload, Hash][]> => {
|
|
6
8
|
const wrapper = await HydratedBlockWrapper.parse(block)
|
|
7
9
|
const txs = wrapper.transactions
|
|
8
10
|
const txPayloads = txs.map(tx => tx.boundWitness)
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
import type { UsePromiseState } from '@xylabs/react-promise'
|
|
1
2
|
import { usePromise } from '@xylabs/react-promise'
|
|
2
3
|
import { type Hash, isHash } from '@xylabs/sdk-js'
|
|
3
4
|
import { assertEx, isDefined } from '@xylabs/sdk-js'
|
|
4
5
|
import type { ReadArchivist } from '@xyo-network/archivist-model'
|
|
5
6
|
import { BoundWitnessBuilder } from '@xyo-network/boundwitness-builder'
|
|
6
|
-
import type {
|
|
7
|
-
import {
|
|
8
|
-
|
|
7
|
+
import type { Payload, WithStorageMeta } from '@xyo-network/payload-model'
|
|
8
|
+
import type {
|
|
9
|
+
BlockBoundWitness, BlockBoundWitnessWithHashMeta, ChainId, Config, PayloadMapRead,
|
|
10
|
+
} from '@xyo-network/xl1-sdk'
|
|
11
|
+
import { getDefaultConfig, isBlockBoundWitness } from '@xyo-network/xl1-sdk'
|
|
9
12
|
|
|
10
13
|
import type { BlockChainIterator } from '../../types/index.ts'
|
|
11
14
|
|
|
@@ -26,7 +29,13 @@ export const resolveDefinedHead = async (head: Hash, chainArchivist: ReadArchivi
|
|
|
26
29
|
|
|
27
30
|
export const useChainIteratorParams = ({
|
|
28
31
|
chainMap, chainId, head, name,
|
|
29
|
-
}: BlockChainIterator)
|
|
32
|
+
}: BlockChainIterator): [{
|
|
33
|
+
chainId: ChainId
|
|
34
|
+
chainMap: PayloadMapRead<WithStorageMeta<Payload>>
|
|
35
|
+
config: Config
|
|
36
|
+
head: BlockBoundWitnessWithHashMeta
|
|
37
|
+
name: string
|
|
38
|
+
} | undefined, Error | undefined, UsePromiseState | undefined] => {
|
|
30
39
|
return usePromise(async () => {
|
|
31
40
|
if (isDefined(chainMap) && isDefined(chainId) && isHash(head)) {
|
|
32
41
|
const result = await chainMap.get(head)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Hash } from '@xylabs/sdk-js'
|
|
2
|
-
import type { HydratedBlockWithHashMeta } from '@xyo-network/xl1-
|
|
2
|
+
import type { HydratedBlockWithHashMeta } from '@xyo-network/xl1-sdk'
|
|
3
3
|
|
|
4
4
|
/** Interface for all components that render a single block */
|
|
5
5
|
export interface BlockComponentProps {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { NodesWithKeys } from '@xylabs/react-animation'
|
|
2
|
-
import type { HydratedBlock } from '@xyo-network/xl1-
|
|
2
|
+
import type { HydratedBlock } from '@xyo-network/xl1-sdk'
|
|
3
3
|
|
|
4
4
|
/** Interface for all block components meant to be rendered in a chain */
|
|
5
5
|
export interface BlockChainRenderComponent extends NodesWithKeys {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { CreatableName, Hash } from '@xylabs/sdk-js'
|
|
2
2
|
import type { Payload, WithStorageMeta } from '@xyo-network/payload-model'
|
|
3
|
-
import type { ChainId } from '@xyo-network/xl1-
|
|
4
|
-
import type { PayloadMapRead } from '@xyo-network/xl1-protocol-sdk'
|
|
3
|
+
import type { ChainId, PayloadMapRead } from '@xyo-network/xl1-sdk'
|
|
5
4
|
|
|
6
5
|
/** Props that control the rendering (not blockchain specific) */
|
|
7
6
|
export interface RenderProps {
|