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

Hotfix tx hash #216

Merged
merged 5 commits into from
Oct 5, 2023
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
3 changes: 2 additions & 1 deletion src/domain/UserContractDetails.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { TokenType } from '@/domain/TokenType'
import { ContractCompiledRaw } from '@/infrastructure'
import { ContractType } from '@/domain/repositories/DeploymentRepository'
import { ChainId } from '@/infrastructure/useink/chains'

export type ContractMetadata = ContractCompiledRaw

export interface UserContractDetails {
userAddress: string
blockchain: string
blockchain: ChainId
address: string
txHash: string
codeHash: string
Expand Down
1 change: 0 additions & 1 deletion src/view/components/CopyButton/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { IconButton, SxProps } from '@mui/material'
import ContentCopyRoundedIcon from '@mui/icons-material/ContentCopyRounded'
// import { Tooltip } from 'react-tooltip'
import Tooltip from '@mui/material/Tooltip'

import { useCopyToClipboard } from '@/hooks'
Expand Down
46 changes: 46 additions & 0 deletions src/view/components/ExplorerLink/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { useMemo } from 'react'
import OpenInNewRoundedIcon from '@mui/icons-material/OpenInNewRounded'
import { IconButton, Link, Tooltip } from '@mui/material'

import { getChain } from '@/constants/chains'
import { ChainId } from '@/infrastructure/useink/chains'
import React from 'react'

interface ExplorerLinkProps {
blockchain: ChainId
txHash?: string
}

export function ExplorerLink({
blockchain,
txHash
}: ExplorerLinkProps): JSX.Element | null {
const explorerUrl = useMemo(
() => getChain(blockchain).subscanUrl,
[blockchain]
)
const linkDisabled = txHash ? false : true

if (!explorerUrl) return null

const iconWithStyles = linkDisabled ? (
<Tooltip title="Transaction hash is not available.">
<OpenInNewRoundedIcon fontSize="small" />
</Tooltip>
) : (
<OpenInNewRoundedIcon fontSize="small" />
)

return (
<Link href={`${explorerUrl}extrinsic/${txHash}`} target="_blank">
<IconButton
component="a"
disabled={linkDisabled}
size="small"
color="primary"
>
{iconWithStyles}
</IconButton>
</Link>
)
}
3 changes: 2 additions & 1 deletion src/view/wizardView/BackNextButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ export default function BackNextButton(props: Props) {
<Grid
item
xs={12}
mt={9}
mt={8}
mb={1}
sx={{ display: 'flex', justifyContent: 'space-between' }}
>
{hiddenBack ? (
Expand Down
26 changes: 17 additions & 9 deletions src/view/wizardView/GridDeployInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@ import { styled } from '@mui/material/styles'

import { emptyAsDash, truncateAddress } from '@/utils/formatString'
import { CopyToClipboardButton, MonoTypography } from '@/components'
import OpenInNewRoundedIcon from '@mui/icons-material/OpenInNewRounded'
import { UserContractDetails } from '@/domain'
import { ExplorerLink } from '@/components/ExplorerLink'

const BoxGridStyled = styled(Box)<BoxProps>(() => ({
export const BoxGridStyled = styled(Box)<BoxProps>(() => ({
display: 'grid',
gridTemplateColumns: '1fr',
gridTemplateRows: 'repeat(3, 1fr)',
gap: '1rem',
paddingTop: '2rem'
marginTop: '1rem'
}))

const BoxRow = styled(Box)<BoxProps>(() => ({
export const BoxRow = styled(Box)<BoxProps>(() => ({
display: 'inherit'
}))

Expand Down Expand Up @@ -52,18 +54,24 @@ export function GridDeployInfo({
</BoxRow>
<BoxRow>
<Typography variant="caption" fontWeight="500">
Block Number
Transaction Hash
</Typography>
<Stack direction="row" alignSelf="center">
<MonoTypography variant="body1">
{truncateAddress(deployedContract?.txHash, 8)}
</MonoTypography>
{deployedContract?.txHash && (
<CopyToClipboardButton
id="copy-block-number"
sx={{ marginLeft: '0.5rem' }}
data={deployedContract.txHash}
/>
<Box flexDirection="row">
<CopyToClipboardButton
id="copy-block-number"
sx={{ marginLeft: '0.5rem' }}
data={deployedContract.txHash}
/>
<ExplorerLink
blockchain={deployedContract.blockchain}
txHash={deployedContract.txHash}
/>
</Box>
)}
</Stack>
</BoxRow>
Expand Down
Loading