Skip to content

Commit

Permalink
donot repeat the call for the first
Browse files Browse the repository at this point in the history
  • Loading branch information
Tbaut committed Dec 12, 2024
1 parent 9288c2f commit c433b14
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions packages/ui/src/components/CallInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,18 @@ const eachFieldRendered = (value: Record<string, any>, chainInfo: ChainInfoHuman
return <li key={`not-pretty-decoded-${id}`}>{JSONprint(value)} </li>
}

const preparedCall = (
decodedCall: CreateTreeParams['decodedCall'],
chainInfo: ChainInfoHuman,
isBatch = false
) => {
interface PreparedCallParams {
decodedCall: CreateTreeParams['decodedCall']
chainInfo: ChainInfoHuman
isBatch?: boolean
isFirstCall?: boolean
}
const preparedCall = ({
decodedCall,
chainInfo,
isBatch = false,
isFirstCall = false
}: PreparedCallParams) => {
if (!decodedCall) return

if (isBatchedCall(decodedCall.type, decodedCall.value.type)) {
Expand All @@ -161,7 +168,11 @@ const preparedCall = (
return lowerLevelCalls.map((call, index) => {
return (
<BatchCallStyled key={`${call.type}-${index}`}>
{preparedCall(call as CreateTreeParams['decodedCall'], chainInfo, true)}
{preparedCall({
decodedCall: call as CreateTreeParams['decodedCall'],
chainInfo,
isBatch: true
})}
</BatchCallStyled>
)
})
Expand Down Expand Up @@ -189,6 +200,10 @@ const preparedCall = (
}
}

if (isFirstCall) {
return <PreStyled>{JSONprint(decodedCall.value.value)}</PreStyled>
}

return <PreStyled>{JSONprint(decodedCall)}</PreStyled>
}

Expand All @@ -197,7 +212,7 @@ const createUlTree = ({ name, decodedCall, chainInfo }: CreateTreeParams) => {
if (!name) return
if (!chainInfo) return

return preparedCall(decodedCall, chainInfo)
return preparedCall({ decodedCall, chainInfo, isFirstCall: true })
}

const filterProxyProxy = (agg: Props['aggregatedData']): Props['aggregatedData'] => {
Expand Down Expand Up @@ -299,6 +314,7 @@ const LinkStyled = styled(Link)`
`

const PreStyled = styled('pre')`
margin-top: 0;
overflow: auto;
`

Expand Down

0 comments on commit c433b14

Please sign in to comment.