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

chore(website): Add documentation to learn page #1177

Merged
merged 12 commits into from
Jul 30, 2024
154 changes: 151 additions & 3 deletions packages/website/src/features/Docs/DocsCannonfilesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,109 @@ import {
Tr,
Badge,
Code,
UnorderedList,
ListItem,
} from '@chakra-ui/react';
import React, { FC } from 'react';
import { a11yDark, CodeBlock } from 'react-code-blocks';

const artifactDataExample = {
artifacts: {
MyContract: {
_format: 'hh-sol-artifact-1',
contractName: 'MyContract',
sourceName: 'contracts/MyContract.sol',
abi: ['...'],
bytecode: '0x...',
deployedBytecode: '0x...',
linkReferences: {},
deployedLinkReferences: {},
source: {
solcVersion: '0.8.24+commit.e11b9ed9',
input:
'{"language":"Solidity","sources":{"example/example/contracts/MyContract.sol":{"content":\\ Your Contract Source Code',
},
},
},
};

const deploymentDataExample = {
generator: 'cannon cli 2.15.0',
timestamp: 1718767889,
def: {
name: 'my-package',
version: '1.0.0',
setting: {
owner: {
defaultValue: '0x...',
},
},
contract: {
MyContract: {
artifact: 'MyContract',
owner: '<%= settings.owner %>',
},
},
},
state: {
'setting.owner': {
artifacts: {
settings: {
owner: '0x...',
},
},
hash: '...',
version: 7,
},
'contract.MyContract': {
artifacts: {
contracts: {
Implementation: {
address: '0x...',
abi: ['...'],
constructorArgs: ['...'],
linkedLibraries: {},
deployTxnHash: '0x...',
sourceName: 'contracts/MyContract.sol',
contractName: 'MyContract',
deployedOn: 'contract.MyContract',
gasUsed: 2172726,
gasCost: '4726073795',
},
},
},
hash: '...',
version: 7,
},
},
options: {},
meta: {
name: 'my-package',
version: '1.0.0',
private: true,
description: 'My Custom Contract package',
scripts: {
test: 'hardhat compile && hardhat --network hardhat test',
coverage: 'hardhat coverage',
},
repository: {
type: 'git',
url: 'git+https://github.com/example/example.git',
},
author: '',
license: 'MIT',
bugs: {
url: 'https://github.com/example/example/issues',
},
homepage: 'https://github.com/example/example#readme',
devDependencies: {
ethers: '5.7.1',
hardhat: '^2.22.3',
'hardhat-cannon': '^2.14.3',
},
},
miscUrl: 'ipfs://Qm...',
};
interface CustomLinkProps {
href: string;
children: React.ReactNode;
Expand Down Expand Up @@ -395,7 +495,25 @@ export const DocsCannonfilesPage: FC = () => {
#
</Link>
</Heading>
<Text color="gray.400">Coming soon.</Text>
<Text color="gray.400">
Primary source of cannon package information which contains
package definition and on-chain state data derived changes
made by defined steps in the cannonfile definition. Deployment
data is stored on IPFS and is locally stored in your
filesystem in the default storage location
<Code>~/.local/share/cannon/tags</Code> or the storage
location defined by the CANNON_DIRECTORY environment variable.
<br />
<br />
Here is an example of a cannon deployment data:
<CodeBlock
text={JSON.stringify(deploymentDataExample, null, 2)}
language="bash"
showLineNumbers={false}
theme={a11yDark}
customStyle={{ fontSize: '14px', maxHeight: '10rem' }}
/>
</Text>
</Box>

<Box mb={16} id="package-code">
Expand All @@ -411,7 +529,20 @@ export const DocsCannonfilesPage: FC = () => {
#
</Link>
</Heading>
<Text color="gray.400">Coming soon.</Text>
<Text color="gray.400">
Contains artifact data and other contract source code data
about the contracts deployed during the build.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We really need to expand on this with detailed information of what is inside the package code. Would be good to show the contents/explanation of the fields inside the data, and how to pull/parse it out.

<br />
<br />
Here is an example of a deployments package data:
<CodeBlock
text={JSON.stringify(artifactDataExample, null, 2)}
language="bash"
showLineNumbers={false}
theme={a11yDark}
customStyle={{ fontSize: '14px', maxHeight: '10rem' }}
/>
</Text>
</Box>

<Box mb={16} id="metadata">
Expand All @@ -427,7 +558,24 @@ export const DocsCannonfilesPage: FC = () => {
#
</Link>
</Heading>
<Text color="gray.400">Coming soon.</Text>
<Text color="gray.400">
Metadata contains external information related to the cannon
package. Currently metadata includes the following:
<UnorderedList>
<ListItem> Git Repo URL</ListItem>
<ListItem>
Commit hash of the changes in which the last instance of
the package were made
</ListItem>
<ListItem>
Link to the package git repo README file
</ListItem>
</UnorderedList>
Metadata is also stored on IPFS and is locally stored in your
filesystem in the default storage location
<Code>~/.local/share/cannon/tags</Code> or the storage
location defined by the CANNON_DIRECTORY environment variable.
</Text>
</Box>
</Box>

Expand Down
Loading