diff --git a/.changeset/blue-seals-relate.md b/.changeset/blue-seals-relate.md new file mode 100644 index 0000000000..84b94339ee --- /dev/null +++ b/.changeset/blue-seals-relate.md @@ -0,0 +1,5 @@ +--- +"@latticexyz/dev-tools": minor +--- + +Improved rendering of transactions that make calls via World's `call` and `callFrom` methods diff --git a/packages/dev-tools/src/actions/WriteSummary.tsx b/packages/dev-tools/src/actions/WriteSummary.tsx index f7f4dca1a5..42aee498ec 100644 --- a/packages/dev-tools/src/actions/WriteSummary.tsx +++ b/packages/dev-tools/src/actions/WriteSummary.tsx @@ -1,4 +1,4 @@ -import { decodeEventLog, AbiEventSignatureNotFoundError } from "viem"; +import { decodeEventLog, AbiEventSignatureNotFoundError, decodeFunctionData, Hex } from "viem"; import { twMerge } from "tailwind-merge"; import { isDefined } from "@latticexyz/common/utils"; import { PendingIcon } from "../icons/PendingIcon"; @@ -56,6 +56,17 @@ export function WriteSummary({ write }: Props) { .filter(isDefined) : null; + let functionName = write.request.functionName; + let functionArgs = write.request.args; + if (functionName === "call" || functionName === "callFrom") { + const functionSelectorAndArgs: Hex = write.request?.args?.length + ? (write.request.args[write.request.args.length - 1] as Hex) + : `0x`; + const functionData = decodeFunctionData({ abi: worldAbi, data: functionSelectorAndArgs }); + functionName = functionData.functionName; + functionArgs = functionData.args; + } + return (
{ @@ -73,7 +84,10 @@ export function WriteSummary({ write }: Props) { )} >
- {write.request.functionName}({write.request.args?.map((value) => serialize(value)).join(", ")}) + {functionName}({functionArgs?.map((value) => serialize(value)).join(", ")}){" "} + {write.request.functionName !== functionName ? ( + via {write.request.functionName} + ) : null}
{transactionReceipt.status === "fulfilled" ? (