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(pages): check verified contract and minor EVM contract details #1239

Merged
merged 2 commits into from
Feb 20, 2025
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Bug fixes

- [#1239](https://github.com/alleslabs/celatone-frontend/pull/1239) Fix check verified EVM contract and minor EVM contract details
- [#1238](https://github.com/alleslabs/celatone-frontend/pull/1238) Fix EVM verify external docs link and EVM contract details mobile
- [#1237](https://github.com/alleslabs/celatone-frontend/pull/1237) Fix EVM contract details UI layout and mobile
- [#1235](https://github.com/alleslabs/celatone-frontend/pull/1235) Support EVM custom chain id and minor bug fixes
Expand Down
33 changes: 11 additions & 22 deletions src/lib/components/UserDocsLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,6 @@ import { trackWebsite } from "lib/amplitude";
import { DEVELOPER_TOOL_DOCS_LINK, USER_GUIDE_DOCS_LINK } from "lib/data";

import { CustomIcon } from "./icon";
import { Option } from "lib/types";

const handleLink = (
href: Option<string> = "",
isExternal: boolean,
isDevTool: boolean
) => {
if (isExternal) return href;
return isDevTool
? DEVELOPER_TOOL_DOCS_LINK
: `${USER_GUIDE_DOCS_LINK}/${href}`;
};

interface UserDocsLinkProps {
href?: string;
Expand All @@ -25,7 +13,6 @@ interface UserDocsLinkProps {
isButton?: boolean;
isInline?: boolean;
isDevTool?: boolean;
isExternal?: boolean;
mt?: number;
}

Expand All @@ -36,16 +23,15 @@ export const UserDocsLink = ({
isButton = false,
isInline = false,
isDevTool = false,
isExternal = false,
mt = 8,
}: UserDocsLinkProps) => {
const link = handleLink(href, isExternal, isDevTool);

return isButton ? (
}: UserDocsLinkProps) =>
isButton ? (
<Link
href={link}
href={`${isDevTool ? DEVELOPER_TOOL_DOCS_LINK : USER_GUIDE_DOCS_LINK}/${href}`}
onClick={(e) => {
trackWebsite(link);
trackWebsite(
`${isDevTool ? DEVELOPER_TOOL_DOCS_LINK : USER_GUIDE_DOCS_LINK}/${href}`
);
e.stopPropagation();
}}
target="_blank"
Expand All @@ -72,7 +58,11 @@ export const UserDocsLink = ({
{title}
</Text>
)}
<Link href={link} target="_blank" rel="noopener noreferrer">
<Link
href={`${isDevTool ? DEVELOPER_TOOL_DOCS_LINK : USER_GUIDE_DOCS_LINK}/${href}`}
target="_blank"
rel="noopener noreferrer"
>
<Flex
gap={1}
alignItems="center"
Expand All @@ -97,4 +87,3 @@ export const UserDocsLink = ({
</Link>
</Flex>
);
};
20 changes: 13 additions & 7 deletions src/lib/components/upload/UploadCard.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Button, Flex, Text } from "@chakra-ui/react";
import { Flex, IconButton, Text } from "@chakra-ui/react";

import { AmpEvent, track } from "lib/amplitude";
import { CustomIcon, UploadIcon } from "lib/components/icon";
Expand Down Expand Up @@ -51,17 +51,23 @@ export const UploadCard = ({
</Flex>
</Flex>
<Flex align="center" gap={4}>
<Button
leftIcon={<CustomIcon name="delete" boxSize={3} />}
<IconButton
variant="ghost-error"
size="sm"
variant={themeConfig.buttonVariant}
icon={<CustomIcon name="delete" boxSize={4} />}
onClick={() => {
track(AmpEvent.USE_REMOVE_UPLOAD_FILE);
deleteFile();
}}
>
Remove file
</Button>
aria-label="upload card"
sx={{
color: "gray.600",
_hover: {
color: "error.main",
backgroundColor: "error.background",
},
}}
/>
{status === "error" && (
<CustomIcon
name="alert-triangle-solid"
Expand Down
2 changes: 0 additions & 2 deletions src/lib/components/upload/hooks/useCardTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ export const useCardTheme = (theme: CardTheme, status: Option<Status>) => {
return {
bgColor: "gray.800",
border: "1px solid var(--chakra-colors-gray-700)",
buttonVariant: "outline-gray",
};

return {
bgColor: "gray.900",
border: "1px solid var(--chakra-colors-gray-900)",
buttonVariant: "outline-primary",
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,15 @@ export const OverviewInfo = ({
<Grid
gridTemplateColumns={{
base: "1fr",
md: "minmax(0, 160px) repeat(3, minmax(0, 240px))",
md: "repeat(4, max-content)",
}}
padding={4}
bg="gray.900"
borderRadius={8}
columnGap={6}
columnGap={{
base: 14,
"2xl": 36,
}}
rowGap={4}
>
<LabelText label="Network">{currentChainId}</LabelText>
Expand All @@ -50,7 +53,6 @@ export const OverviewInfo = ({
<ExplorerLink
value={formatAddresses(sender).hex}
type="user_address"
showCopyOnHover
/>
) : (
<Text variant="body2" color="text.disabled">
Expand All @@ -70,7 +72,7 @@ export const OverviewInfo = ({
Cosmos:
</Text>
{hash ? (
<ExplorerLink value={hash} type="tx_hash" showCopyOnHover />
<ExplorerLink value={hash} type="tx_hash" />
) : (
<Text variant="body2" color="text.disabled">
-
Expand All @@ -85,7 +87,6 @@ export const OverviewInfo = ({
<ExplorerLink
value={formatEvmTxHash(evmHash)}
type="evm_tx_hash"
showCopyOnHover
/>
) : (
<Text variant="body2" color="text.disabled">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ export const ContractLicenseInfoAccordion = () => (
<UserDocsLink
mt={3}
cta="See contract license types"
href="https://github.com/github/choosealicense.com/tree/gh-pages/_licenses"
isExternal
href="source-code/license"
isDevTool
/>
</AccordionItem>
</Accordion>
Expand Down
4 changes: 2 additions & 2 deletions src/lib/pages/evm-contract-verify/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ export const getEvmContractVerifyFormDefaultValue = (
});

export const formatEvmOptions = (values: string[]) =>
values.map((value) => ({
label: value,
values.map((value, index) => ({
label: value === "default" ? `default (${values[index + 1]})` : value,
value,
}));

Expand Down
15 changes: 11 additions & 4 deletions src/lib/pages/evm-contract-verify/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ export const EvmContractVerifyBody = ({
option === EvmVerifyOptions.SolidityFoundry ||
option === EvmVerifyOptions.SolidityHardhat;

// TODO
const isFormDisabled = () => {
const isEvmContractVerifyBaseSuccess =
zEvmContractVerifyBase.safeParse({
Expand Down Expand Up @@ -181,7 +180,11 @@ export const EvmContractVerifyBody = ({
).success;
}

return !isEvmContractVerifyBaseSuccess || !isEvmOptionSuccess;
return (
!isEvmContractVerifyBaseSuccess ||
!isEvmOptionSuccess ||
!!evmVerifyInfo?.isVerified
);
};

const handleSubmit = () => {
Expand Down Expand Up @@ -222,7 +225,7 @@ export const EvmContractVerifyBody = ({
<NoMobile />
) : (
<>
<PageContainer px={12} py={9} p={0}>
<PageContainer px={12} pt={9} pb={40} p={0}>
<Grid
w="100%"
templateColumns="6fr 4fr"
Expand Down Expand Up @@ -254,7 +257,11 @@ export const EvmContractVerifyBody = ({
? "success"
: "init",
}}
error={errors.contractAddress?.message}
error={
evmVerifyInfo?.isVerified
? "Contract is already verified"
: errors.contractAddress?.message
}
rules={{
required: "",
}}
Expand Down
6 changes: 4 additions & 2 deletions src/lib/types/evm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,11 @@ export const zEvmVerifyConfig = z
.object({
license_type: z.array(z.nativeEnum(EvmVerifyLicenseType)),
solidity_compiler_versions: z.array(z.string()),
solidity_evm_versions: z.array(z.string()),
solidity_evm_versions: z
.array(z.string())
.transform((val) => val.reverse()),
vyper_compiler_versions: z.array(z.string()),
vyper_evm_versions: z.array(z.string()),
vyper_evm_versions: z.array(z.string()).transform((val) => val.reverse()),
})
.transform(snakeToCamel);
export type EvmVerifyConfig = z.infer<typeof zEvmVerifyConfig>;
Expand Down