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

Cw docs #266

Closed
wants to merge 33 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
8f7e364
Adding contracts route
henrypalacios Sep 28, 2023
f013ae6
Add Custom Contracts and Contracts section (#195)
alongoni Sep 28, 2023
5201e21
Merge branch 'develop' into epic-custom-contracts
henrypalacios Oct 5, 2023
27607ff
Merge branch 'develop' into epic-custom-contracts
henrypalacios Oct 5, 2023
9f48dfa
Add Contract Table / Share Modal (#217)
bogos Oct 6, 2023
c68e35f
Merge branch 'develop' into epic-custom-contracts
henrypalacios Oct 9, 2023
f270fba
Merge branch 'develop' into epic-custom-contracts
henrypalacios Oct 10, 2023
7568542
Add last contracts (#229)
alongoni Oct 11, 2023
5683f4b
Merge branch 'develop' into epic-custom-contracts
alongoni Oct 13, 2023
0d305e4
fix missing type error
alongoni Oct 13, 2023
7a71c11
Add import form section (#201)
alongoni Oct 18, 2023
f912739
Feature/ Contrat table edit name and delete contract (#232)
bogos Oct 19, 2023
1751e3b
Fix infinite contract table loop (#244)
bogos Oct 23, 2023
ec9dd54
Contracts UI + Layout fixes (#238)
alongoni Oct 25, 2023
8979c19
Contract details view layout (#231)
alongoni Oct 25, 2023
06c54b2
add disabled styles
alongoni Oct 25, 2023
1f7155b
Merge branch 'epic-custom-contracts' into form-elements-styles
alongoni Oct 25, 2023
d7fdbb6
Revert "Contract details view layout (#231)"
henrypalacios Oct 25, 2023
df28515
Fix minnor bugs in contracts page table (#246)
bogos Oct 26, 2023
c69e76a
import custom deployment (#245)
henrypalacios Oct 26, 2023
36af99e
fix minnor custom contracts bugs
bogos Oct 27, 2023
6af0ef7
Merge branch 'epic-custom-contracts' of github.com:protofire/polkadot…
bogos Oct 27, 2023
461f4da
fix contract table rerender bug
bogos Oct 27, 2023
8ebefe3
Fix minnor bugs (#255)
bogos Oct 31, 2023
9b139ca
Form styles and layout fixes (#247)
alongoni Oct 31, 2023
fd430e5
Fix yarn .lock
henrypalacios Oct 31, 2023
9a2e2fa
load custom contract (#248)
henrypalacios Nov 1, 2023
621c25a
Tables UI Improvements + New Documentation (#256)
alongoni Nov 3, 2023
fed68b1
connection validations (#257)
henrypalacios Nov 3, 2023
60d61d3
added docs submodule [WIP- Check why is not compiling]
GabrielCamba Oct 27, 2023
b025885
Update be submodule
0xLucca Nov 9, 2023
6b0d680
Add DOCUMENTATION_URL env var
0xLucca Nov 9, 2023
7a7b673
Merge branch 'develop' into cw-docs
0xLucca Nov 9, 2023
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 .docker/dev.docker.env
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ DB_EXTERNAL_PORT=27027
BACKEND_EXTERNAL_PORT=8000
WEB_EXTERNAL_PORT=3000
WEB_ENVIRONMENT="production"
DOC_EXTERNAL_PORT=3020
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "ink-compiler-be"]
path = ink-compiler-be
url = https://github.com/protofire/ink-compiler-be.git
[submodule "cw_docs"]
path = cw_docs
url = https://github.com/protofire/cw_docs
1 change: 1 addition & 0 deletions cw_docs
Submodule cw_docs added at 11aa2c
10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ services:
- ${BACKEND_EXTERNAL_PORT}:8000
environment:
- MONGOURI=mongodb://mongodb:27017
- NEXT_PUBLIC_DOCUMENTATION_URL=http://localhost:${DOC_EXTERNAL_PORT}
networks:
- polkadot-wizard
depends_on:
Expand All @@ -49,3 +50,12 @@ services:
image: mongo:5.0.16
networks:
- polkadot-wizard
doc:
container_name: ${CONTAINER_BASE}_doc
build:
context: ./cw_docs
dockerfile: ./Dockerfile
ports:
- ${DOC_EXTERNAL_PORT}:3000
networks:
- polkadot-wizard
4 changes: 3 additions & 1 deletion src/constants/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ export const ROUTES = {
CONTRACTS: '/contracts',
CUSTOM: '/custom-contract',
CONTRACTDETAIL: '/contract-detail',
DOCUMENTATION: 'https://contractwizard-docs.vercel.app/',
DOCUMENTATION:
process.env.NEXT_PUBLIC_DOCUMENTATION_URL ||
'https://contractwizard-docs.vercel.app/',
TELEGRAM: 'https://t.me/+u5M4K7vKfbQxZjMx',
GITHUB: 'https://github.com/protofire/polkadot-contract-wizard"'
} as const
1 change: 1 addition & 0 deletions src/domain/Metadata.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

import { Abi, AbiMessage } from '@/services/substrate/types'

export interface Validation {
Expand Down
144 changes: 144 additions & 0 deletions src/pages/contract-detail/contract-detail.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
import React from 'react'
import { CopyToClipboardButton } from '@/view/components/CopyButton'
import { MonoTypography } from '@/view/components/MonoTypography'
import { Box, Typography, Stack, Tooltip } from '@mui/material'
import { DefaultToolTipButton } from '@/view/components/DefaultTooltipButton'
import EditIcon from '@mui/icons-material/Edit'
import ShareIcon from '@mui/icons-material/Share'
import DownloadIcon from '@mui/icons-material/Download'
import { getChain } from '@/constants/chains'
import NetworkBadge from '@/view/components/NetworkBadge'
import { UseModalBehaviour } from '@/hooks/useModalBehaviour'
import { UserContractDetails } from '@/domain'
import { isoDate, isoToReadableDate } from '@/utils/formatString'
import { useNetworkAccountsContext } from '@/context/NetworkAccountsContext'
import { ContractDetailsInteraction } from '@/view/ContractDetailsInteraction'
import { ConnectWalletSection } from '@/view/components/ConnectWalletSection'

type ContractTabType = 'Read Contract' | 'Write Contract'
const types: ContractTabType[] = ['Read Contract', 'Write Contract']

interface Props {
modalBehaviour: UseModalBehaviour
userContract: UserContractDetails
}

interface AbiSource {
source: { language: string }
}

export default function ContractDetail({
modalBehaviour,
userContract
}: Props) {
const [type, setType] = React.useState(types[0])
const { accountConnected } = useNetworkAccountsContext()
if (!userContract) {
return null
}

const chainDetails = getChain(userContract.network)
const isReadContract = type === 'Read Contract'
const abi = userContract.abi as AbiSource | undefined

const handleChange = (newValue: number) => {
setType(types[newValue])
}

return (
<>
<Stack direction="row" justifyContent="space-between">
<Stack direction="row" justifyContent="space-between">
<Typography variant="h2">{userContract.name}</Typography>
<DefaultToolTipButton
id="edit-contract-address"
sx={{ marginLeft: '0.5rem', color: 'white' }}
title="Edit"
Icon={EditIcon}
></DefaultToolTipButton>
<DefaultToolTipButton
id="download-contract-address"
sx={{ marginLeft: '0.5rem', color: 'white' }}
title="Download metadata"
Icon={DownloadIcon}
></DefaultToolTipButton>
<DefaultToolTipButton
id="share-contract-address"
sx={{ marginLeft: '0.5rem', color: 'white' }}
title="Share"
Icon={ShareIcon}
onClick={() => modalBehaviour.openModal()}
></DefaultToolTipButton>
</Stack>
<Typography variant="body1">
Added {''}
<Tooltip placement="top" title={isoDate(userContract.date)}>
<Typography variant="body1" component="span">
{isoToReadableDate(userContract.date)}
</Typography>
</Tooltip>
</Typography>
</Stack>
<Stack direction="row">
<MonoTypography>{userContract.address}</MonoTypography>
<CopyToClipboardButton
id="copy-contract-address"
sx={{ marginLeft: '0.5rem' }}
data={userContract.address}
/>
</Stack>
<Box
display="flex"
flexDirection="row"
justifyContent="space-between"
sx={{ margin: '2em 0 3rem' }}
>
<Box display="flex" flexDirection="column">
<Typography variant="caption" align="left">
TYPE
</Typography>
<Typography variant="h5" align="left">
{userContract.type}
</Typography>
</Box>
<Box display="flex" flexDirection="column">
<Typography variant="caption" align="left">
NETWORK
</Typography>
<Typography variant="h5" align="left">
<NetworkBadge
name={chainDetails.name}
logo={chainDetails.logo.src}
logoSize={{ width: 20, height: 20 }}
description={chainDetails.logo.alt}
textTooltip="This network is the one that the contract has been deployed."
/>
</Typography>
</Box>
<Box display="flex" flexDirection="column">
<Typography variant="caption" align="left">
LANGUAGE
</Typography>
<Typography variant="h5" align="left">
{abi?.source.language}
</Typography>
</Box>
<Box display="flex" flexDirection="column">
<Typography variant="caption" align="left">
Actions
</Typography>
<Typography variant="h5" align="left">
--
</Typography>
</Box>
</Box>
{accountConnected ? (
<ContractDetailsInteraction userContract={userContract} />
) : (
<ConnectWalletSection
text={'You need to connect a wallet to interact with this contract.'}
/>
)}
</>
)
}
86 changes: 86 additions & 0 deletions src/view/ContractDetailsInteraction/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import { Box, Typography } from '@mui/material'
import React from 'react'
import { UserContractDetails } from '@/domain'
import BasicTabs from '@/components/Tabs'
import SimpleAccordion from '@/components/Accordion'

type ContractTabType = 'Read Contract' | 'Write Contract'
const types: ContractTabType[] = ['Read Contract', 'Write Contract']

interface Props {
userContract: UserContractDetails
}

export function ContractDetailsInteraction({ userContract }: Props) {
const [type, setType] = React.useState(types[0])
const isReadContract = type === 'Read Contract'

const handleChange = (newValue: number) => {
setType(types[newValue])
}

return (
<>
<Box sx={{ width: '100%' }}>
<BasicTabs
options={['Read Contract', 'Write Contract']}
onChange={handleChange}
>
<>
{/* <Typography variant="h4">{type}</Typography> */}
{isReadContract ? (
<>
<Typography variant="h4">
Learn more about your contract 🔁
</Typography>
<Typography variant="body1">
Let&apos;start to work with your contract displaying each
method.
</Typography>
</>
) : (
<>
<Typography variant="h4">
Interact with your contract 🔁
</Typography>
<Typography variant="body1">
Let&apos;s start to work with your contract doing different
querys.
</Typography>
</>
)}
<SimpleAccordion
elements={
isReadContract
? [
{
tittle: 'psp22::balance',
content: 'text balance',
id: '1'
},
{
tittle: 'psp22::owners',
content: 'text owners',
id: '2'
}
]
: [
{
tittle: 'psp22::approve',
content: 'Form approve',
id: '1'
},
{
tittle: 'psp22::tranfer',
content: 'Form transfer',
id: '2'
}
]
}
/>
</>
</BasicTabs>
</Box>
</>
)
}
Loading