-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #616 from oasisprotocol/csillag/more-account-details
Display Contract ByteCode
- Loading branch information
Showing
22 changed files
with
188 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
For contracts, display bytecode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { FC } from 'react' | ||
import Typography from '@mui/material/Typography' | ||
import Box from '@mui/material/Box' | ||
import { COLORS } from '../../../styles/theme/colors' | ||
|
||
export const ScrollingDataDisplay: FC<{ data: string; fontWeight?: number }> = ({ | ||
data, | ||
fontWeight = 700, | ||
}) => { | ||
return ( | ||
<Box | ||
sx={{ | ||
display: 'flex', | ||
padding: '10px 0px 0px 0px', | ||
flexDirection: 'column', | ||
alignItems: 'flex-start', | ||
gap: '10px', | ||
}} | ||
> | ||
<Box | ||
sx={{ | ||
borderRadius: '5px', | ||
background: COLORS.grayLight, | ||
border: `1px solid ${COLORS.grayMedium}`, | ||
height: '349px', | ||
overflowY: 'scroll', | ||
p: 3, | ||
}} | ||
> | ||
<Typography | ||
variant="mono" | ||
fontSize={16} | ||
sx={{ | ||
fontWeight, | ||
overflowWrap: 'anywhere', | ||
}} | ||
color={COLORS.grayMedium} | ||
> | ||
{data} | ||
</Typography> | ||
</Box> | ||
</Box> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { FC } from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
import Card from '@mui/material/Card' | ||
import CardContent from '@mui/material/CardContent' | ||
import { ScrollingDiv } from '../../components/PageLayout/ScrollingDiv' | ||
import { useAccount } from './hook' | ||
import { useRequiredScopeParam } from '../../hooks/useScopeParam' | ||
import { useLoaderData } from 'react-router-dom' | ||
import { CardEmptyState } from './CardEmptyState' | ||
import Typography from '@mui/material/Typography' | ||
import { ScrollingDataDisplay } from '../../components/ScrollingDataDisplay' | ||
import Box from '@mui/material/Box' | ||
import { CopyToClipboard } from '../../components/CopyToClipboard' | ||
import { useScreenSize } from '../../hooks/useScreensize' | ||
|
||
export const contractCodeContainerId = 'code' | ||
|
||
const CodeDisplay: FC<{ code: string | undefined; label: string; extraTopPadding?: boolean }> = ({ | ||
code, | ||
label, | ||
extraTopPadding, | ||
}) => { | ||
const { t } = useTranslation() | ||
const { isMobile } = useScreenSize() | ||
return code === undefined ? null : ( | ||
<> | ||
<Box | ||
sx={{ | ||
display: 'flex', | ||
justifyContent: 'space-between', | ||
alignItems: 'center', | ||
my: 3, | ||
pt: extraTopPadding ? 4 : 0, | ||
}} | ||
> | ||
<Typography variant="h4" component="h4"> | ||
{label} | ||
</Typography> | ||
<CopyToClipboard | ||
value={code} | ||
label={isMobile ? t('common.copy') : t('contract.copyButton', { subject: label })} | ||
/> | ||
</Box> | ||
|
||
<ScrollingDataDisplay data={code} /> | ||
</> | ||
) | ||
} | ||
|
||
export const ContractCodeCard: FC = () => { | ||
const { t } = useTranslation() | ||
const scope = useRequiredScopeParam() | ||
const address = useLoaderData() as string | ||
|
||
const { isFetched, account } = useAccount(scope, address) | ||
const contract = account?.evm_contract | ||
const noCode = isFetched && !contract?.creation_bytecode && !contract?.runtime_bytecode | ||
return ( | ||
<Card> | ||
<ScrollingDiv id={contractCodeContainerId}> | ||
{noCode && <CardEmptyState label={t('contract.noCode')} />} | ||
{contract && (contract.creation_bytecode || contract.runtime_bytecode) && ( | ||
<CardContent> | ||
<CodeDisplay code={contract.creation_bytecode} label={t('contract.creationByteCode')} /> | ||
<CodeDisplay | ||
code={contract.runtime_bytecode} | ||
label={t('contract.runtimeByteCode')} | ||
extraTopPadding={!!contract.creation_bytecode} | ||
/> | ||
</CardContent> | ||
)} | ||
</ScrollingDiv> | ||
</Card> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.