Skip to content

Commit 572c300

Browse files
authored
Improvements for function call viewer (#118)
* Improvements for function call viewer * Removed console log
1 parent 04edd08 commit 572c300

File tree

7 files changed

+856
-244
lines changed

7 files changed

+856
-244
lines changed

src/components/call-trace/contract-call-trace.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,8 @@ const ContractCallDetails = memo(function ContractCallDetails({ call }: { call:
350350
}
351351
];
352352

353+
const [displayFormat, setDisplayFormat] = useState<'auto' | 'raw'>('auto');
354+
353355
if (call.erc20TokenName) {
354356
details.push({
355357
name: 'Token Name',
@@ -424,10 +426,23 @@ const ContractCallDetails = memo(function ContractCallDetails({ call }: { call:
424426
rawData={call.entryPoint.calldata}
425427
decodeData={call.calldataDecoded}
426428
type={DataType.CALLDATA}
429+
displayFormat={displayFormat}
430+
setDisplayFormat={setDisplayFormat}
427431
/>
428432
)}
433+
429434
{call.decodedResult && (
430-
<DecodeDataTable decodeData={call.decodedResult} type={DataType.OUTPUT} />
435+
<DecodeDataTable
436+
decodeData={call.decodedResult}
437+
type={DataType.OUTPUT}
438+
rawData={
439+
'success' in call.result
440+
? (call.result.success as { retData: string[] }).retData
441+
: ['']
442+
}
443+
displayFormat={displayFormat}
444+
setDisplayFormat={setDisplayFormat}
445+
/>
431446
)}
432447
</div>
433448
</div>

src/components/call-trace/event-call-trace.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { memo } from 'react';
1+
import React, { memo, useState } from 'react';
22
import { useCallTrace } from '@/lib/context/call-trace-context-provider';
33
import { CALL_NESTING_SPACE_BUMP, CallTypeChip, TraceLine } from '.';
44
import { InfoBox } from '@/components/ui/info-box';
@@ -87,7 +87,7 @@ const EventCallDetails = memo(function EventCallDetails({
8787
if (!contractName) {
8888
contractName = shortenHash(contractCall.entryPoint.storageAddress, 13);
8989
}
90-
90+
const [displayFormat, setDisplayFormat] = useState<'auto' | 'raw'>('auto');
9191
const details: { name: string; value: string; isCopyable?: boolean; valueToCopy?: string }[] = [];
9292

9393
details.push(
@@ -125,7 +125,14 @@ const EventCallDetails = memo(function EventCallDetails({
125125
<div className="">
126126
<InfoBox details={details} />
127127
</div>
128-
{call.datas && <DecodeDataTable decodeData={call.datas} type={DataType.DATA} />}
128+
{call.datas && (
129+
<DecodeDataTable
130+
decodeData={call.datas}
131+
type={DataType.DATA}
132+
displayFormat={displayFormat}
133+
setDisplayFormat={setDisplayFormat}
134+
/>
135+
)}
129136
</div>
130137
</div>
131138
);

src/components/call-trace/event-entries.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { memo } from 'react';
1+
import React, { memo, useState } from 'react';
22
import { useCallTrace } from '@/lib/context/call-trace-context-provider';
33
import { CALL_NESTING_SPACE_BUMP, CallTypeChip, TraceLine } from '.';
44
import { shortenHash } from '@/lib/utils';
@@ -71,7 +71,7 @@ export function EventsList({ events }: { events: ContractCallEvent[] }) {
7171

7272
const EventDetails = memo(function EventCallDetails({ call }: { call: ContractCallEvent }) {
7373
const details: { name: string; value: string; isCopyable?: boolean; valueToCopy?: string }[] = [];
74-
74+
const [displayFormat, setDisplayFormat] = useState<'auto' | 'raw'>('auto');
7575
details.push(
7676
{
7777
name: 'Contract Address',
@@ -85,7 +85,14 @@ const EventDetails = memo(function EventCallDetails({ call }: { call: ContractCa
8585
<div className="md:w-[calc(100vw-7rem)]">
8686
<div className=""></div>
8787
<InfoBox details={details} />
88-
{call.datas && <DecodeDataTable decodeData={call.datas} type={DataType.DATA} />}
88+
{call.datas && (
89+
<DecodeDataTable
90+
decodeData={call.datas}
91+
type={DataType.DATA}
92+
displayFormat={displayFormat}
93+
setDisplayFormat={setDisplayFormat}
94+
/>
95+
)}
8996
</div>
9097
</div>
9198
);

src/components/call-trace/function-call-trace.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,6 @@ import { DebugButton } from './debug-btn';
99
import { CommonCallTrace } from './common-call-trace';
1010
import { InfoBox } from '@/components/ui/info-box';
1111
import { FnName } from '../ui/function-name';
12-
import { DropdownMenu, DropdownMenuContent, DropdownMenuTrigger } from '../ui/dropdown-menu';
13-
import CopyToClipboardElement from '../ui/copy-to-clipboard';
14-
import { Copy } from 'lucide-react';
15-
import { ScrollArea, ScrollBar } from '../ui/scroll-area';
16-
import FunctionCallViewer from '../ui/function-call-viewer';
17-
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '../ui/tooltip';
18-
import AddressLink from '../address-link';
1912
import ValueWithTooltip from '../ui/value-with-tooltip';
2013
import { ErrorTooltip } from '../error-tooltip';
2114

0 commit comments

Comments
 (0)