Skip to content

Commit

Permalink
Merge branch 'main' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
mjlescano committed Oct 23, 2024
2 parents 8f2ace8 + 2230911 commit 4b358a4
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 70 deletions.
38 changes: 19 additions & 19 deletions packages/builder/src/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -880,29 +880,29 @@ export const chainDefinitionSchema = z
'Turns off inclusion of source code in packages. When set to true, Cannon cannot verify contracts on Etherscan. Defaults to false.'
)
.optional(),
/**
* Description for the package
*/
description: z.string().describe('Description for the package').optional(),
/**
* Keywords for search indexing
*/
keywords: z.array(z.string()).describe('Keywords for search indexing').optional(),
/**
* Any deployers that could publish this package. Will be used for automatic version management.
*/
deployers: z
.array(
z.string().refine((val) => !!val.match(RegExp(/^0x[a-fA-F0-9]{40}$/, 'gm')), {
message: 'Invalid Ethereum address',
})
)
.describe('Any deployers that could publish this package. Will be used for automatic version management.')
.optional(),
})
.merge(
z
.object({
/**
* Description for the package
*/
description: z.string().describe('Description for the package'),
/**
* Keywords for search indexing
*/
keywords: z.array(z.string()).describe('Keywords for search indexing'),
/**
* Any deployers that could publish this package. Will be used for automatic version management.
*/
deployers: z
.array(
z.string().refine((val) => !!val.match(RegExp(/^0x[a-fA-F0-9]{40}$/, 'gm')), {
message: 'Invalid Ethereum address',
})
)
.optional()
.describe('Any deployers that could publish this package. Will be used for automatic version management.'),
/**
* Object that allows the definition of values for use in next operations
* ```toml
Expand Down
113 changes: 64 additions & 49 deletions packages/website/src/features/Docs/DocsCannonfilesPage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use client';

import { CommandPreview } from '@/components/CommandPreview';
import { CustomSpinner } from '@/components/CustomSpinner';
import { useCannonfileSpecs } from '@/hooks/cannonfileSpecs';
import {
Expand Down Expand Up @@ -121,31 +122,11 @@ const deploymentDataExample = {
},
miscUrl: 'ipfs://Qm...',
};
interface CustomLinkProps {
href: string;
children: React.ReactNode;
}

const CustomLink: FC<CustomLinkProps> = ({ href, children }) => (
<Link
display="block"
textDecoration="none"
borderRadius="md"
mb={0.5}
py={0.5}
px="2"
cursor="pointer"
fontSize="sm"
_hover={{ background: 'gray.800' }}
href={href}
>
{children}
</Link>
);

interface LinkItem {
href: string;
text: string;
monospace?: boolean;
}

interface SectionProps {
Expand All @@ -167,9 +148,22 @@ const Section: FC<SectionProps> = ({ title, links }) => (
</Heading>
<Box mb={6}>
{links.map((link, index) => (
<CustomLink key={index} href={link.href}>
<Link
key={index}
display="block"
textDecoration="none"
borderRadius="md"
mb={0.5}
py={0.5}
px="2"
cursor="pointer"
fontSize="sm"
fontFamily={link.monospace ? 'var(--font-mono)' : undefined}
_hover={{ background: 'gray.800' }}
href={link.href}
>
{link.text}
</CustomLink>
</Link>
))}
</Box>
</Box>
Expand Down Expand Up @@ -246,10 +240,11 @@ const DocsCannonfilesPage: FC = () => {
>
<Box px={3} pb={2}>
<Section
title="Cannonfile Specification"
title="Cannonfile Spec"
links={[
{ href: '#cannonfile-metadata', text: 'Cannonfile Metadata' },
{ href: '#cannonfile-metadata', text: 'Metadata' },
{ href: '#constants', text: 'Constants' },
{ href: '#utilities', text: 'Utilities' },
...Array.from(cannonfileSpecs, ([key]) => key)
.filter(
(key) =>
Expand All @@ -258,7 +253,8 @@ const DocsCannonfilesPage: FC = () => {
)
.map((key) => ({
href: `#${key}`,
text: key as string,
text: `[${key}.*]`,
monospace: true,
})),
]}
/>
Expand Down Expand Up @@ -424,47 +420,66 @@ const DocsCannonfilesPage: FC = () => {
<CustomTable
data={[
{
key: 'Zero',
dataType: 'number',
value: 'The BigNumber value representing "0".',
},
{
key: 'One',
dataType: 'number',
value: 'The BigNumber value representing "1".',
},
{
key: 'Two',
dataType: 'number',
value: 'The BigNumber value representing "2".',
key: 'AddressZero | zeroAddress',
dataType: 'string',
value:
'Zero Addres string: "0x0000000000000000000000000000000000000000".',
},
{
key: 'WeiPerEther',
dataType: 'number',
key: 'HashZero | zeroHash',
dataType: 'string',
value:
'The BigNumber value representing "1000000000000000000", which is the number of Wei per Ether.',
'Zero hash value: "0x0000000000000000000000000000000000000000000000000000000000000000"',
},
{
key: 'MaxUint256',
key: 'maxInt8...256',
dataType: 'number',
value:
'The BigNumber value representing the maximum uint256 value.',
'BigNumber values representing from maxInt8 to maxInt256.',
},
{
key: 'MinInt256',
key: 'minInt8...256',
dataType: 'number',
value:
'The BigNumber value representing the minimum int256 value.',
'BigNumber values representing from minInt8 to minInt256.',
},
{
key: 'MaxInt256',
key: 'maxUint8...256',
dataType: 'number',
value:
'The BigNumber value representing the maximum int256 value.',
'BigNumber values representing from maxUint8 to maxUint256.',
},
]}
/>
</Box>
<Box mb={16} id="utilities">
<Heading mb={4} fontSize="lg">
Utilities
<Link
color="gray.300"
ml={2}
textDecoration="none"
_hover={{ textDecoration: 'underline' }}
href={'#constants'}
>
#
</Link>
</Heading>
<Text mb="4">
<Link
href="https://viem.sh/docs/utilities/getAddress"
isExternal
>
Viem.sh
</Link>{' '}
utility functions are available inside interpolation values,
e.g.:
</Text>
<CommandPreview
backgroundColor="black"
command={'args = ["<%= keccak256(\'some string\') %>"]'}
/>
</Box>
{Array.from(cannonfileSpecs)
.sort((a, b) => {
const aDeprecated = cannonfileSpecs?.get(a[0])?.deprecated
Expand All @@ -480,7 +495,7 @@ const DocsCannonfilesPage: FC = () => {
<Box key={key} id={key} mb={16}>
<Heading mb={4} fontSize="lg">
<Code px={0} fontSize="lg">
{key}
[{key}.*]
</Code>
<Link
color="gray.300"
Expand Down
5 changes: 3 additions & 2 deletions packages/website/src/hooks/cannonfileSpecs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,14 @@ async function fetchCannonfileSpecs() {

const result = new Map<string, CannonfileSpec>();

const metadataKeys = ['name', 'preset', 'version', 'description', 'keywords', 'privateSourceCode'];
const metadataKeys = ['name', 'preset', 'version', 'description', 'keywords', 'privateSourceCode', 'deployers'];
const metadataSpecs: Spec[] = [];
for (const key of metadataKeys) {
metadataSpecs.push(await getSpec(chainDefinitionJsonSchema, key));
}

result.set('metadata', {
description: 'Provide metadata for your Cannonfile.',
description: 'Provide metadata for your Cannonfile. These are the top-most attributes on your Cannonfile.',
specs: metadataSpecs,
});

Expand Down

0 comments on commit 4b358a4

Please sign in to comment.