@xyo-network/react-ethereum-gas-price-blocknative-plugin 2.40.36
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/LICENSE +165 -0
- package/README.md +70 -0
- package/dist/cjs/Plugin.d.ts +3 -0
- package/dist/cjs/Plugin.d.ts.map +1 -0
- package/dist/cjs/Plugin.js +24 -0
- package/dist/cjs/Plugin.js.map +1 -0
- package/dist/cjs/components/Card/Card.d.ts +12 -0
- package/dist/cjs/components/Card/Card.d.ts.map +1 -0
- package/dist/cjs/components/Card/Card.js +15 -0
- package/dist/cjs/components/Card/Card.js.map +1 -0
- package/dist/cjs/components/Card/CardContent.d.ts +12 -0
- package/dist/cjs/components/Card/CardContent.d.ts.map +1 -0
- package/dist/cjs/components/Card/CardContent.js +24 -0
- package/dist/cjs/components/Card/CardContent.js.map +1 -0
- package/dist/cjs/components/Card/CardHeader.d.ts +22 -0
- package/dist/cjs/components/Card/CardHeader.d.ts.map +1 -0
- package/dist/cjs/components/Card/CardHeader.js +15 -0
- package/dist/cjs/components/Card/CardHeader.js.map +1 -0
- package/dist/cjs/components/Card/index.d.ts +4 -0
- package/dist/cjs/components/Card/index.d.ts.map +1 -0
- package/dist/cjs/components/Card/index.js +7 -0
- package/dist/cjs/components/Card/index.js.map +1 -0
- package/dist/cjs/components/Details/Box/BlocknativeGasPriceDetailsBox.d.ts +4 -0
- package/dist/cjs/components/Details/Box/BlocknativeGasPriceDetailsBox.d.ts.map +1 -0
- package/dist/cjs/components/Details/Box/BlocknativeGasPriceDetailsBox.js +25 -0
- package/dist/cjs/components/Details/Box/BlocknativeGasPriceDetailsBox.js.map +1 -0
- package/dist/cjs/components/Details/Box/index.d.ts +2 -0
- package/dist/cjs/components/Details/Box/index.d.ts.map +1 -0
- package/dist/cjs/components/Details/Box/index.js +5 -0
- package/dist/cjs/components/Details/Box/index.js.map +1 -0
- package/dist/cjs/components/Details/index.d.ts +2 -0
- package/dist/cjs/components/Details/index.d.ts.map +1 -0
- package/dist/cjs/components/Details/index.js +5 -0
- package/dist/cjs/components/Details/index.js.map +1 -0
- package/dist/cjs/components/hooks/index.d.ts +2 -0
- package/dist/cjs/components/hooks/index.d.ts.map +1 -0
- package/dist/cjs/components/hooks/index.js +5 -0
- package/dist/cjs/components/hooks/index.js.map +1 -0
- package/dist/cjs/components/hooks/useBlocknativeTransformer.d.ts +4 -0
- package/dist/cjs/components/hooks/useBlocknativeTransformer.d.ts.map +1 -0
- package/dist/cjs/components/hooks/useBlocknativeTransformer.js +35 -0
- package/dist/cjs/components/hooks/useBlocknativeTransformer.js.map +1 -0
- package/dist/cjs/components/index.d.ts +3 -0
- package/dist/cjs/components/index.d.ts.map +1 -0
- package/dist/cjs/components/index.js +6 -0
- package/dist/cjs/components/index.js.map +1 -0
- package/dist/cjs/components/lib/constants.d.ts +2 -0
- package/dist/cjs/components/lib/constants.d.ts.map +1 -0
- package/dist/cjs/components/lib/constants.js +5 -0
- package/dist/cjs/components/lib/constants.js.map +1 -0
- package/dist/cjs/components/lib/index.d.ts +2 -0
- package/dist/cjs/components/lib/index.d.ts.map +1 -0
- package/dist/cjs/components/lib/index.js +5 -0
- package/dist/cjs/components/lib/index.js.map +1 -0
- package/dist/cjs/index.d.ts +5 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +9 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/docs.json +5352 -0
- package/dist/esm/Plugin.d.ts +3 -0
- package/dist/esm/Plugin.d.ts.map +1 -0
- package/dist/esm/Plugin.js +23 -0
- package/dist/esm/Plugin.js.map +1 -0
- package/dist/esm/components/Card/Card.d.ts +12 -0
- package/dist/esm/components/Card/Card.d.ts.map +1 -0
- package/dist/esm/components/Card/Card.js +10 -0
- package/dist/esm/components/Card/Card.js.map +1 -0
- package/dist/esm/components/Card/CardContent.d.ts +12 -0
- package/dist/esm/components/Card/CardContent.d.ts.map +1 -0
- package/dist/esm/components/Card/CardContent.js +18 -0
- package/dist/esm/components/Card/CardContent.js.map +1 -0
- package/dist/esm/components/Card/CardHeader.d.ts +22 -0
- package/dist/esm/components/Card/CardHeader.d.ts.map +1 -0
- package/dist/esm/components/Card/CardHeader.js +12 -0
- package/dist/esm/components/Card/CardHeader.js.map +1 -0
- package/dist/esm/components/Card/index.d.ts +4 -0
- package/dist/esm/components/Card/index.d.ts.map +1 -0
- package/dist/esm/components/Card/index.js +4 -0
- package/dist/esm/components/Card/index.js.map +1 -0
- package/dist/esm/components/Details/Box/BlocknativeGasPriceDetailsBox.d.ts +4 -0
- package/dist/esm/components/Details/Box/BlocknativeGasPriceDetailsBox.d.ts.map +1 -0
- package/dist/esm/components/Details/Box/BlocknativeGasPriceDetailsBox.js +19 -0
- package/dist/esm/components/Details/Box/BlocknativeGasPriceDetailsBox.js.map +1 -0
- package/dist/esm/components/Details/Box/index.d.ts +2 -0
- package/dist/esm/components/Details/Box/index.d.ts.map +1 -0
- package/dist/esm/components/Details/Box/index.js +2 -0
- package/dist/esm/components/Details/Box/index.js.map +1 -0
- package/dist/esm/components/Details/index.d.ts +2 -0
- package/dist/esm/components/Details/index.d.ts.map +1 -0
- package/dist/esm/components/Details/index.js +2 -0
- package/dist/esm/components/Details/index.js.map +1 -0
- package/dist/esm/components/hooks/index.d.ts +2 -0
- package/dist/esm/components/hooks/index.d.ts.map +1 -0
- package/dist/esm/components/hooks/index.js +2 -0
- package/dist/esm/components/hooks/index.js.map +1 -0
- package/dist/esm/components/hooks/useBlocknativeTransformer.d.ts +4 -0
- package/dist/esm/components/hooks/useBlocknativeTransformer.d.ts.map +1 -0
- package/dist/esm/components/hooks/useBlocknativeTransformer.js +30 -0
- package/dist/esm/components/hooks/useBlocknativeTransformer.js.map +1 -0
- package/dist/esm/components/index.d.ts +3 -0
- package/dist/esm/components/index.d.ts.map +1 -0
- package/dist/esm/components/index.js +3 -0
- package/dist/esm/components/index.js.map +1 -0
- package/dist/esm/components/lib/constants.d.ts +2 -0
- package/dist/esm/components/lib/constants.d.ts.map +1 -0
- package/dist/esm/components/lib/constants.js +2 -0
- package/dist/esm/components/lib/constants.js.map +1 -0
- package/dist/esm/components/lib/index.d.ts +2 -0
- package/dist/esm/components/lib/index.d.ts.map +1 -0
- package/dist/esm/components/lib/index.js +2 -0
- package/dist/esm/components/lib/index.js.map +1 -0
- package/dist/esm/index.d.ts +5 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +6 -0
- package/dist/esm/index.js.map +1 -0
- package/package.json +80 -0
- package/src/Plugin.ts +25 -0
- package/src/components/Card/Card.stories.tsx +32 -0
- package/src/components/Card/Card.tsx +17 -0
- package/src/components/Card/CardContent.tsx +34 -0
- package/src/components/Card/CardHeader.tsx +16 -0
- package/src/components/Card/index.ts +3 -0
- package/src/components/Details/Box/BlocknativeGasPriceDetailsBox.stories.tsx +32 -0
- package/src/components/Details/Box/BlocknativeGasPriceDetailsBox.tsx +48 -0
- package/src/components/Details/Box/index.ts +1 -0
- package/src/components/Details/index.ts +1 -0
- package/src/components/hooks/index.ts +1 -0
- package/src/components/hooks/useBlocknativeTransformer.tsx +33 -0
- package/src/components/index.ts +2 -0
- package/src/components/lib/constants.ts +1 -0
- package/src/components/lib/index.ts +1 -0
- package/src/index.ts +7 -0
- package/src/types/images.d.ts +5 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Card, CardProps } from '@mui/material'
|
|
2
|
+
import { XyoPayloadRenderProps } from '@xyo-network/react-payload-plugin'
|
|
3
|
+
import { forwardRef } from 'react'
|
|
4
|
+
|
|
5
|
+
import { BlocknativeGasPriceCardContent } from './CardContent'
|
|
6
|
+
import { BlocknativeGasPriceCardHeader } from './CardHeader'
|
|
7
|
+
|
|
8
|
+
export const BlocknativeGasPriceCard = forwardRef<HTMLDivElement, XyoPayloadRenderProps & CardProps>(({ payload, ...props }, ref) => {
|
|
9
|
+
return (
|
|
10
|
+
<Card ref={ref} {...props}>
|
|
11
|
+
<BlocknativeGasPriceCardHeader payload={payload} />
|
|
12
|
+
<BlocknativeGasPriceCardContent payload={payload} />
|
|
13
|
+
</Card>
|
|
14
|
+
)
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
BlocknativeGasPriceCard.displayName = 'BlocknativeGasPriceCard'
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { CardContent, CardContentProps, Grid } from '@mui/material'
|
|
2
|
+
import { XyoEthereumGasBlocknativePayload } from '@xyo-network/blocknative-ethereum-gas-payload-plugin'
|
|
3
|
+
import { GasFeeCard, ToggleRawPayloadBox } from '@xyo-network/react-gas-price'
|
|
4
|
+
import { XyoPayloadRenderProps } from '@xyo-network/react-payload-plugin'
|
|
5
|
+
import { PayloadDataMissing } from '@xyo-network/react-shared'
|
|
6
|
+
import isEmpty from 'lodash/isEmpty'
|
|
7
|
+
import { forwardRef } from 'react'
|
|
8
|
+
|
|
9
|
+
import { useBlocknativeTransformer } from '../hooks'
|
|
10
|
+
|
|
11
|
+
export const BlocknativeGasPriceCardContent = forwardRef<HTMLDivElement, XyoPayloadRenderProps & CardContentProps>(({ payload, ...props }, ref) => {
|
|
12
|
+
const gasPricePayload = payload ? (payload as XyoEthereumGasBlocknativePayload) : undefined
|
|
13
|
+
const parsedPayload = useBlocknativeTransformer(gasPricePayload)
|
|
14
|
+
|
|
15
|
+
if (isEmpty(gasPricePayload) || !gasPricePayload.blockPrices?.length) {
|
|
16
|
+
return <PayloadDataMissing alertBody="Payload is missing valid gas fee data." sx={{ m: 1 }} />
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<CardContent ref={ref} sx={{ display: 'flex', flexDirection: 'column', rowGap: 4 }} {...props}>
|
|
21
|
+
<Grid container spacing={3} columns={{ lg: 15, md: 15, sm: 12, xs: 12 }}>
|
|
22
|
+
{parsedPayload &&
|
|
23
|
+
parsedPayload?.gasPrice?.map(({ price }) => (
|
|
24
|
+
<Grid key={price?.label} item xs={12} sm={6} md={5} lg={3}>
|
|
25
|
+
<GasFeeCard gasPrice={price?.value} speed={price?.label} speedPaperElevation={4} />
|
|
26
|
+
</Grid>
|
|
27
|
+
))}
|
|
28
|
+
</Grid>
|
|
29
|
+
<ToggleRawPayloadBox gasPricePayload={gasPricePayload} alignItems="start" pr={1} />
|
|
30
|
+
</CardContent>
|
|
31
|
+
)
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
BlocknativeGasPriceCardContent.displayName = 'BlocknativeGasPriceCardContent'
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CardHeaderProps } from '@mui/material'
|
|
2
|
+
import { XyoEthereumGasBlocknativePayload } from '@xyo-network/blocknative-ethereum-gas-payload-plugin'
|
|
3
|
+
import { GasPriceWitnessCardHeader } from '@xyo-network/react-gas-price'
|
|
4
|
+
import { XyoPayloadRenderProps } from '@xyo-network/react-payload-plugin'
|
|
5
|
+
import { forwardRef } from 'react'
|
|
6
|
+
|
|
7
|
+
import { useBlocknativeTransformer } from '../hooks'
|
|
8
|
+
import { RenderTitle } from '../lib'
|
|
9
|
+
|
|
10
|
+
export const BlocknativeGasPriceCardHeader = forwardRef<HTMLDivElement, XyoPayloadRenderProps & CardHeaderProps>(({ payload }, ref) => {
|
|
11
|
+
const gasPricePayload = payload ? (payload as XyoEthereumGasBlocknativePayload) : undefined
|
|
12
|
+
const parsedPayload = useBlocknativeTransformer(gasPricePayload)
|
|
13
|
+
return <GasPriceWitnessCardHeader title={RenderTitle} parsedPayload={parsedPayload} ref={ref} />
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
BlocknativeGasPriceCardHeader.displayName = 'BlocknativeGasPriceCardHeader'
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ComponentMeta, ComponentStory } from '@storybook/react'
|
|
2
|
+
import { XyoEthereumGasBlocknativeSchema } from '@xyo-network/blocknative-ethereum-gas-payload-plugin'
|
|
3
|
+
import { sampleBlocknativeGasPricePayload } from '@xyo-network/react-storybook'
|
|
4
|
+
|
|
5
|
+
import { BlocknativeGasPriceDetailsBox } from './BlocknativeGasPriceDetailsBox'
|
|
6
|
+
|
|
7
|
+
const StorybookEntry = {
|
|
8
|
+
argTypes: {},
|
|
9
|
+
component: BlocknativeGasPriceDetailsBox,
|
|
10
|
+
parameters: {
|
|
11
|
+
docs: {
|
|
12
|
+
page: null,
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
title: 'plugin/blockchain/BlocknativeGasPrice/DetailsBox',
|
|
16
|
+
} as ComponentMeta<typeof BlocknativeGasPriceDetailsBox>
|
|
17
|
+
|
|
18
|
+
const Template: ComponentStory<typeof BlocknativeGasPriceDetailsBox> = (args) => <BlocknativeGasPriceDetailsBox {...args} />
|
|
19
|
+
|
|
20
|
+
const Default = Template.bind({})
|
|
21
|
+
Default.args = {}
|
|
22
|
+
|
|
23
|
+
const WithData = Template.bind({})
|
|
24
|
+
WithData.args = { payload: sampleBlocknativeGasPricePayload }
|
|
25
|
+
|
|
26
|
+
const WithMissingData = Template.bind({})
|
|
27
|
+
WithMissingData.args = { payload: { schema: XyoEthereumGasBlocknativeSchema } }
|
|
28
|
+
|
|
29
|
+
export { Default, WithData, WithMissingData }
|
|
30
|
+
|
|
31
|
+
// eslint-disable-next-line import/no-default-export
|
|
32
|
+
export default StorybookEntry
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Grid } from '@mui/material'
|
|
2
|
+
import { FlexBoxProps, FlexCol } from '@xylabs/react-flexbox'
|
|
3
|
+
import { XyoEthereumGasBlocknativePayload } from '@xyo-network/blocknative-ethereum-gas-payload-plugin'
|
|
4
|
+
import { GasFeeCard, GasPriceWitnessHeaderBox, ToggleRawPayloadBox } from '@xyo-network/react-gas-price'
|
|
5
|
+
import { XyoPayloadDetailsRenderProps } from '@xyo-network/react-payload-plugin'
|
|
6
|
+
import { PayloadDataMissing } from '@xyo-network/react-shared'
|
|
7
|
+
import isEmpty from 'lodash/isEmpty'
|
|
8
|
+
import { forwardRef } from 'react'
|
|
9
|
+
|
|
10
|
+
import { useBlocknativeTransformer } from '../../hooks'
|
|
11
|
+
import { RenderTitle } from '../../lib'
|
|
12
|
+
|
|
13
|
+
export const BlocknativeGasPriceDetailsBox = forwardRef<HTMLDivElement, XyoPayloadDetailsRenderProps & FlexBoxProps>(
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
15
|
+
({ payload, listMode, ...props }, ref) => {
|
|
16
|
+
const gasPricePayload: XyoEthereumGasBlocknativePayload | undefined = payload ? (payload as XyoEthereumGasBlocknativePayload) : undefined
|
|
17
|
+
const parsedPayload = useBlocknativeTransformer(gasPricePayload)
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<>
|
|
21
|
+
{isEmpty(gasPricePayload) || !gasPricePayload.blockPrices?.length ? (
|
|
22
|
+
<PayloadDataMissing alertBody="Payload is missing valid gas fee data." />
|
|
23
|
+
) : (
|
|
24
|
+
<FlexCol alignItems="start" rowGap={4} {...props} ref={ref}>
|
|
25
|
+
<GasPriceWitnessHeaderBox heading={RenderTitle} parsedPayload={parsedPayload} />
|
|
26
|
+
<Grid container spacing={3} columns={{ lg: 15, md: 15, sm: 12, xs: 12 }}>
|
|
27
|
+
{parsedPayload &&
|
|
28
|
+
parsedPayload?.gasPrice?.map(({ price, priorityFee }) => (
|
|
29
|
+
<Grid key={price?.label} item xs={12} sm={6} md={5} lg={3}>
|
|
30
|
+
<GasFeeCard
|
|
31
|
+
key={price?.label}
|
|
32
|
+
gasPrice={price?.value}
|
|
33
|
+
speed={price?.label}
|
|
34
|
+
priorityFee={priorityFee?.value}
|
|
35
|
+
priorityFeeLabel={priorityFee?.label}
|
|
36
|
+
/>
|
|
37
|
+
</Grid>
|
|
38
|
+
))}
|
|
39
|
+
</Grid>
|
|
40
|
+
<ToggleRawPayloadBox gasPricePayload={gasPricePayload} alignItems="start" />
|
|
41
|
+
</FlexCol>
|
|
42
|
+
)}
|
|
43
|
+
</>
|
|
44
|
+
)
|
|
45
|
+
},
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
BlocknativeGasPriceDetailsBox.displayName = 'BlocknativeGasPriceDetailsBox'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './BlocknativeGasPriceDetailsBox'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Box'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useBlocknativeTransformer'
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { XyoEthereumGasBlocknativePayload } from '@xyo-network/blocknative-ethereum-gas-payload-plugin'
|
|
2
|
+
import { GasPriceWitnessUIBasePayload } from '@xyo-network/react-gas-price'
|
|
3
|
+
|
|
4
|
+
export const useBlocknativeTransformer = (payload?: XyoEthereumGasBlocknativePayload): GasPriceWitnessUIBasePayload | undefined => {
|
|
5
|
+
const blockPrices = payload?.blockPrices?.[0]
|
|
6
|
+
if (blockPrices && blockPrices.estimatedPrices?.length) {
|
|
7
|
+
const estimatedPrices = blockPrices?.estimatedPrices
|
|
8
|
+
const gasPrice = estimatedPrices.map((price) => ({
|
|
9
|
+
price: {
|
|
10
|
+
label: `Confidence - ${price.confidence}`,
|
|
11
|
+
value: price.price,
|
|
12
|
+
},
|
|
13
|
+
priorityFee: {
|
|
14
|
+
label: 'maxPriorityFeePerGas',
|
|
15
|
+
value: price.maxPriorityFeePerGas,
|
|
16
|
+
},
|
|
17
|
+
}))
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
baseFee: {
|
|
21
|
+
label: 'baseFeePerGas',
|
|
22
|
+
value: blockPrices.baseFeePerGas,
|
|
23
|
+
},
|
|
24
|
+
blockNumber: {
|
|
25
|
+
label: 'blockNumber',
|
|
26
|
+
value: blockPrices.blockNumber,
|
|
27
|
+
},
|
|
28
|
+
gasPrice,
|
|
29
|
+
timestamp: payload.timestamp,
|
|
30
|
+
website: 'https://docs.Blocknative.io/v5/api/providers/provider/#Provider-getFeeData',
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const RenderTitle = 'Blocknative Gas Tracker'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './constants'
|
package/src/index.ts
ADDED