From c8ebf67a742bf08b8b106823290c42db23bd73d8 Mon Sep 17 00:00:00 2001 From: Nicole O'Brien Date: Thu, 16 May 2024 16:35:16 +0100 Subject: [PATCH] enhancement: present smart contract inputs as `name: value` --- .../popup/popups/EvmTransactionFromDappPopup.svelte | 7 +++++-- .../evm/info/EvmSmartContractInformation.svelte | 8 +++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/desktop/components/popup/popups/EvmTransactionFromDappPopup.svelte b/packages/desktop/components/popup/popups/EvmTransactionFromDappPopup.svelte index d2e7d08e26..09f1a6fd07 100644 --- a/packages/desktop/components/popup/popups/EvmTransactionFromDappPopup.svelte +++ b/packages/desktop/components/popup/popups/EvmTransactionFromDappPopup.svelte @@ -53,7 +53,7 @@ let baseCoinTransfer: TokenTransferData | undefined let isSmartContractCall = false let methodName: string | undefined = undefined - let inputs: IParsedInput[] | undefined = undefined + let inputs: Record | undefined = undefined let busy = false setTransactionInformation() @@ -76,7 +76,10 @@ ) methodName = parsedData?.parsedMethod?.name - inputs = parsedData?.parsedMethod?.inputs + inputs = parsedData?.parsedMethod?.inputs.reduce((acc, input: IParsedInput) => { + acc[input.name] = input.value + return acc + }, {}) switch (parsedData?.type) { case ParsedSmartContractType.CoinTransfer: { diff --git a/packages/shared/src/components/activities/evm/info/EvmSmartContractInformation.svelte b/packages/shared/src/components/activities/evm/info/EvmSmartContractInformation.svelte index e4b19d47ae..9f8d614223 100644 --- a/packages/shared/src/components/activities/evm/info/EvmSmartContractInformation.svelte +++ b/packages/shared/src/components/activities/evm/info/EvmSmartContractInformation.svelte @@ -11,6 +11,12 @@ const url = getExplorerUrl(activity.destinationNetworkId, ExplorerEndpoint.Address, address) openUrlInBrowser(url) } + + // change inputs from object with index as key to object with name as key + $: inputs = activity.inputs?.reduce((acc, input) => { + acc[input.name] = input.value + return acc + }, {})