Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: inputs and favicon #7

Merged
merged 2 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added public/favicon.ico
Binary file not shown.
Binary file added public/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion public/vite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
220 changes: 187 additions & 33 deletions src/routes/Blocks/Inputs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { useState, Fragment } from 'react';
import {
InnerHeading,
StyledAccordion,
TypographyData,
} from '../../components/StyledComponents';
import AccordionDetails from '@mui/material/AccordionDetails';
import AccordionSummary from '@mui/material/AccordionSummary';
Expand All @@ -33,9 +32,8 @@ import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
import { useGetBlockByHeightOrHash } from '../../api/hooks/useBlocks';
import { useTheme } from '@mui/material/styles';
import Grid from '@mui/material/Grid';
import Divider from '@mui/material/Divider';
import { shortenString } from '../../utils/helpers';
import CopyToClipboard from '../../components/CopyToClipboard';
import { toHexString } from '../../utils/helpers';
import GridItem from './GridItem';

function Inputs({ blockHeight }: { blockHeight: string }) {
const { data } = useGetBlockByHeightOrHash(blockHeight);
Expand All @@ -48,8 +46,156 @@ function Inputs({ blockHeight }: { blockHeight: string }) {
};

const renderItems = data?.block.body.inputs.map(
(input: any, index: number) => {
(content: any, index: number) => {
const expandedPanel = `panel${index}`;
const items = [
{
label: 'Features',
copy: false,
children: [
{
label: 'Version',
value: content.features.version,
copy: false,
},
{
label: 'Output Type',
value: content.features.output_type,
copy: false,
},
{
label: 'Maturity',
value: content.features.maturity,
copy: false,
},
],
},
{
label: 'Commitment',
value: toHexString(content.commitment.data),
copy: true,
},
{
label: 'Hash',
value: toHexString(content.hash.data),
copy: true,
},
{
label: 'Script',
value: content.script.data,
copy: false,
},
{
label: 'Input Data',
value: toHexString(content.input_data.data),
copy: true,
},
{
label: 'Sender Offset Public Key',
value: toHexString(content.sender_offset_public_key.data),
copy: true,
},
{
label: 'Script Signature',
copy: false,
children: [
{
label: 'Ephemeral commitment',
value: toHexString(
content.script_signature.ephemeral_commitment.data
),
copy: true,
},
{
label: 'Ephemeral pubkey',
value: toHexString(
content.script_signature.ephemeral_pubkey.data
),
copy: true,
},
{
label: 'u_a',
value: toHexString(content.script_signature.u_a.data),
copy: true,
},
{
label: 'u_x',
value: toHexString(content.script_signature.u_x.data),
copy: true,
},
{
label: 'u_y',
value: toHexString(content.script_signature.u_y.data),
copy: true,
},
],
},
{
label: 'Output Hash',
value: toHexString(content.output_hash.data),
copy: true,
},
{
label: 'Covenant',
value: content.covenant.data,
copy: false,
},
{
label: 'Version',
value: content.version,
copy: false,
},
{
label: 'Encrypted Data',
value: toHexString(content.encrypted_data.data),
copy: true,
},
{
label: 'Minimum Value Promise',
value: content.minimum_value_promise,
copy: false,
},
{
label: 'Metadata Signature',
copy: false,
children: [
{
label: 'Ephemeral commitment',
value: toHexString(
content.metadata_signature.ephemeral_commitment.data
),
copy: true,
},
{
label: 'Ephemeral pubkey',
value: toHexString(
content.metadata_signature.ephemeral_pubkey.data
),
copy: true,
},
{
label: 'u_a',
value: toHexString(content.metadata_signature.u_a.data),
copy: true,
},
{
label: 'u_x',
value: toHexString(content.metadata_signature.u_x.data),
copy: true,
},
{
label: 'u_y',
value: toHexString(content.metadata_signature.u_y.data),
copy: true,
},
],
},
{
label: 'Rangeproof Hash',
value: toHexString(content.rangeproof_hash.data),
copy: true,
},
];

return (
<StyledAccordion
Expand All @@ -67,36 +213,44 @@ function Inputs({ blockHeight }: { blockHeight: string }) {
</AccordionSummary>
<AccordionDetails>
<Grid container spacing={2}>
{[
{
label: 'Features:',
value: input.features,
copy: false,
header: false,
},
].map((item, subIndex) => (
{items.map((item, subIndex) => (
<Fragment key={subIndex}>
<Grid item xs={12}>
<Divider color={theme.palette.background.paper} />
</Grid>
<Grid item xs={12} md={4} lg={4}>
<Typography variant="body2">{item.label}</Typography>
</Grid>
<Grid item xs={12} md={8} lg={8}>
<TypographyData>
{item.copy ? (
<>
{shortenString(item.value)}
<CopyToClipboard
copy={item.value}
key={`${index}-${subIndex}-copy`}
/>
</>
) : (
item.value
{item.children ? (
<Fragment>
{GridItem(
theme,
item.label,
item.value,
item.copy,
index,
subIndex,
true
)}
</TypographyData>
</Grid>
{item.children.map((child, innerIndex) => (
<Fragment key={innerIndex}>
{GridItem(
theme,
child.label,
child.value,
child.copy,
index,
subIndex,
false
)}
</Fragment>
))}
</Fragment>
) : (
GridItem(
theme,
item.label,
item.value,
item.copy,
index,
subIndex,
true
)
)}
</Fragment>
))}
</Grid>
Expand Down
18 changes: 9 additions & 9 deletions src/routes/Blocks/Kernels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,44 +55,44 @@ function Kernels({ blockHeight }: { blockHeight: string }) {

const items = [
{
label: 'Features:',
label: 'Features',
value: content.features,
copy: false,
},
{
label: 'Fee:',
label: 'Fee',
value: content.fee,
copy: false,
},
{
label: 'Lock Height:',
label: 'Lock Height',
value: content.lock_height,
copy: false,
},
{
label: 'Excess:',
label: 'Excess',
value: excessData,
copy: true,
},
{
label: 'Excess Sig:',
label: 'Excess Sig',
copy: false,
children: [
{
label: 'Public Nonce:',
label: 'Public Nonce',
value: publicNonce,
copy: true,
},
{
label: 'Signature:',
label: 'Signature',
value: signature,
copy: true,
},
],
},
{ label: 'Hash:', value: hashData, copy: true, header: false },
{ label: 'Hash', value: hashData, copy: true, header: false },
{
label: 'Version:',
label: 'Version',
value: content.version,
copy: false,
},
Expand Down
18 changes: 9 additions & 9 deletions src/routes/Blocks/Outputs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function Outputs({ blockHeight }: { blockHeight: string }) {
const expandedPanel = `panel${index}`;
const items = [
{
label: 'Features:',
label: 'Features',
copy: false,
children: [
{
Expand All @@ -71,27 +71,27 @@ function Outputs({ blockHeight }: { blockHeight: string }) {
],
},
{
label: 'Commitment:',
label: 'Commitment',
value: toHexString(content.commitment.data),
copy: true,
},
{
label: 'Hash:',
label: 'Hash',
value: toHexString(content.hash.data),
copy: true,
},
{
label: 'Script:',
value: content.script.data,
copy: false,
label: 'Script',
value: toHexString(content.script.data),
copy: true,
},
{
label: 'Sender Offset Public Key:',
label: 'Sender Offset Public Key',
value: toHexString(content.sender_offset_public_key.data),
copy: true,
},
{
label: 'Metadata Signature:',
label: 'Metadata Signature',
copy: false,
children: [
{
Expand Down Expand Up @@ -126,7 +126,7 @@ function Outputs({ blockHeight }: { blockHeight: string }) {
],
},
{
label: 'Covenant Version:',
label: 'Covenant Version',
value: content.covenant.data,
copy: false,
},
Expand Down