Skip to content

Commit

Permalink
fix: sandbox header font size and add error message
Browse files Browse the repository at this point in the history
  • Loading branch information
He1DAr committed Feb 21, 2025
1 parent 348a807 commit 6909e5b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const SearchContractsForm: FC<{ rootContractAddress: string }> = ({
<Stack p={6}>
{/* <Box as="form"> */}
<Stack gap={4}>
<Title fontSize={6}>Call a contract</Title>
<Title fontSize={'2xl'}>Call a contract</Title>
<Text fontSize={'sm'}>
Manually enter contract details below, or load a contract from your transactions to
see available functions.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { Box, Grid } from '@chakra-ui/react';
import { FC } from 'react';

import { Caption, Text } from '../../../../../ui/typography';

Check warning on line 4 in src/app/sandbox/components/ContractCall/DefaultView/index.tsx

View check run for this annotation

Codecov / codecov/patch

src/app/sandbox/components/ContractCall/DefaultView/index.tsx#L4

Added line #L4 was not covered by tests
import { PopularContracts } from './PopularContracts';
import { SearchContractsForm } from './SearchContractsForm';

export const DefaultView: FC<{
rootContractAddress: string;
}> = ({ rootContractAddress }) => (
errorMessage?: string;
}> = ({ rootContractAddress, errorMessage }) => (
<Grid
width="calc((1142px / 3) * 2)"
gridTemplateColumns="repeat(2, 1fr)"
Expand All @@ -15,6 +17,11 @@ export const DefaultView: FC<{
>
<Box borderRightWidth="1px">
<SearchContractsForm rootContractAddress={rootContractAddress} />
{errorMessage && (
<Text color={`error`} fontSize={'sm'} px={6}>
{errorMessage}
</Text>
)}
</Box>
<Box p={4}>
<PopularContracts rootContractAddress={rootContractAddress} />
Expand Down
17 changes: 15 additions & 2 deletions src/app/sandbox/contract-call/[[...params]]/PageClient.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,34 @@
'use client';

import { useGlobalContext } from '../../../../common/context/useGlobalContext';

Check warning on line 3 in src/app/sandbox/contract-call/[[...params]]/PageClient.tsx

View check run for this annotation

Codecov / codecov/patch

src/app/sandbox/contract-call/[[...params]]/PageClient.tsx#L3

Added line #L3 was not covered by tests
import { useContractById } from '../../../../common/queries/useContractById';
import { useSuspensePoxInfo } from '../../../../common/queries/usePoxInfo';
import { truncateMiddle } from '../../../../common/utils/utils';

Check warning on line 6 in src/app/sandbox/contract-call/[[...params]]/PageClient.tsx

View check run for this annotation

Codecov / codecov/patch

src/app/sandbox/contract-call/[[...params]]/PageClient.tsx#L6

Added line #L6 was not covered by tests
import { DefaultView } from '../../components/ContractCall/DefaultView';
import { SelectedContractView } from '../../components/ContractCall/SelectedContractView';

export default function ContractCall({ params: { params } }: { params: { params: string[] } }) {
const contractId = params?.[0] || undefined;
const functionName = params?.[1] || undefined;
const { data: poxInfo } = useSuspensePoxInfo();
const { data: contract } = useContractById(contractId);
const { data: contract, isFetching } = useContractById(contractId);

Check warning on line 14 in src/app/sandbox/contract-call/[[...params]]/PageClient.tsx

View check run for this annotation

Codecov / codecov/patch

src/app/sandbox/contract-call/[[...params]]/PageClient.tsx#L14

Added line #L14 was not covered by tests

const rootContractAddress = poxInfo?.contract_id?.split('.')?.[0];
const networkMode = useGlobalContext().activeNetwork.mode;

Check warning on line 17 in src/app/sandbox/contract-call/[[...params]]/PageClient.tsx

View check run for this annotation

Codecov / codecov/patch

src/app/sandbox/contract-call/[[...params]]/PageClient.tsx#L17

Added line #L17 was not covered by tests

const noContractFound = !contract && !isFetching;

if (!rootContractAddress) return null;

if (!!contractId && !!contract) {
if (!!contractId) {
if (noContractFound)
return (
<DefaultView
rootContractAddress={rootContractAddress}
errorMessage={`Contract ${truncateMiddle(contractId)} not found in ${networkMode}`}
/>
);
if (!contract) return <DefaultView rootContractAddress={rootContractAddress} />;
return (
<SelectedContractView
contract={contract}
Expand Down

0 comments on commit 6909e5b

Please sign in to comment.