Skip to content

Commit

Permalink
substrate claim tx
Browse files Browse the repository at this point in the history
  • Loading branch information
kingsleydon committed Oct 9, 2023
1 parent 1298dfa commit fcd62b2
Show file tree
Hide file tree
Showing 3 changed files with 306 additions and 68 deletions.
31 changes: 27 additions & 4 deletions apps/index/components/Body/Progress.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/naming-convention */
import {assets} from '@/config/common'
import useCurrentTask from '@/hooks/useTaskStatus'
import {currentTaskAtom, solutionAtom} from '@/store/core'
import {currentTaskAtom, fromChainAtom, solutionAtom} from '@/store/core'
import OpenInNewIcon from '@mui/icons-material/OpenInNew'
import {
Chip,
Expand Down Expand Up @@ -58,17 +58,20 @@ const Progress: FC<PaperProps> = ({sx, ...props}) => {
const [solution] = useAtom(solutionAtom)
const [currentTask] = useAtom(currentTaskAtom)
const {data: taskStatus} = useCurrentTask()
const [fromChain] = useAtom(fromChainAtom)

const stepOffset = fromChain?.chainType === 'Sub' ? 2 : 1

const activeStep = useMemo(() => {
let value = 0
if (taskStatus != null) {
value = taskStatus.executeIndex + 1
value = taskStatus.executeIndex + stepOffset
if ('completed' in taskStatus.status) {
value += 2
}
}
return value
}, [taskStatus])
}, [taskStatus, stepOffset])

const steps = useMemo(() => {
if (solution == null) return null
Expand Down Expand Up @@ -141,8 +144,28 @@ const Progress: FC<PaperProps> = ({sx, ...props}) => {
</Stack>
</StepLabel>
</Step>
{fromChain?.chainType === 'Sub' && (
<Step>
<StepLabel
{...(activeStep === 1 && currentTask != null && activeProps)}
>
<Stack spacing={1} direction="row" alignItems="baseline">
<Chip
label="Claim"
size="small"
sx={{textTransform: 'capitalize', width: 90}}
color={activeStep === 1 ? 'primary' : 'default'}
/>
<ExplorerLink
chain={fromChain.name}
hash={taskStatus?.claimTx}
/>
</Stack>
</StepLabel>
</Step>
)}
{steps.map((step, index) => {
const isActive = activeStep === index + 1
const isActive = activeStep === index + stepOffset
return (
<Step key={index} expanded>
<StepLabel {...(isActive && activeProps)}>
Expand Down
2 changes: 1 addition & 1 deletion apps/index/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@mui/lab": "5.0.0-alpha.145",
"@mui/material": "^5.14.10",
"@next/bundle-analyzer": "^13.5.3",
"@phala/index": "^1.0.33",
"@phala/index": "^1.0.34",
"@phala/lib": "workspace:^",
"@phala/store": "workspace:^",
"@phala/util": "workspace:^",
Expand Down
Loading

0 comments on commit fcd62b2

Please sign in to comment.