From 20c52f2ec42b82441a0d5e165bb406b5fe16e95c Mon Sep 17 00:00:00 2001 From: Usame Algan Date: Wed, 18 Sep 2024 15:44:04 +0200 Subject: [PATCH] fix: Add back showMethodCall and keep prop drilling it --- .../tx-flow/flows/ConfirmTx/ConfirmProposedTx.tsx | 2 +- .../tx-flow/flows/SafeAppsTx/ReviewSafeAppsTx.tsx | 2 +- src/components/tx/DecodedTx/index.tsx | 9 ++++++--- .../tx/SignOrExecuteForm/SignOrExecuteForm.tsx | 9 ++++++++- src/components/tx/confirmation-views/index.tsx | 7 ++++++- 5 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/components/tx-flow/flows/ConfirmTx/ConfirmProposedTx.tsx b/src/components/tx-flow/flows/ConfirmTx/ConfirmProposedTx.tsx index 524fc9304c..c62c776a3b 100644 --- a/src/components/tx-flow/flows/ConfirmTx/ConfirmProposedTx.tsx +++ b/src/components/tx-flow/flows/ConfirmTx/ConfirmProposedTx.tsx @@ -39,7 +39,7 @@ const ConfirmProposedTx = ({ txSummary }: ConfirmProposedTxProps): ReactElement const text = canSign ? (canExecute ? SIGN_EXECUTE_TEXT : SIGN_TEXT) : EXECUTE_TEXT return ( - + {text} ) diff --git a/src/components/tx-flow/flows/SafeAppsTx/ReviewSafeAppsTx.tsx b/src/components/tx-flow/flows/SafeAppsTx/ReviewSafeAppsTx.tsx index b77ed61b2e..100f4a4869 100644 --- a/src/components/tx-flow/flows/SafeAppsTx/ReviewSafeAppsTx.tsx +++ b/src/components/tx-flow/flows/SafeAppsTx/ReviewSafeAppsTx.tsx @@ -66,7 +66,7 @@ const ReviewSafeAppsTx = ({ const error = !isTxValid(txs) return ( - + {error ? ( This Safe App initiated a transaction which cannot be processed. Please get in touch with the developer of diff --git a/src/components/tx/DecodedTx/index.tsx b/src/components/tx/DecodedTx/index.tsx index 4644c0dc95..ebfbddcec9 100644 --- a/src/components/tx/DecodedTx/index.tsx +++ b/src/components/tx/DecodedTx/index.tsx @@ -1,5 +1,5 @@ import { type SyntheticEvent, type ReactElement, memo } from 'react' -import { isCustomTxInfo } from '@/utils/transaction-guards' +import { isCustomTxInfo, isNativeTokenTransfer, isTransferTxInfo } from '@/utils/transaction-guards' import { Accordion, AccordionDetails, AccordionSummary, Box, Stack } from '@mui/material' import { OperationType, type SafeTransaction } from '@safe-global/safe-core-sdk-types' import type { DecodedDataResponse, TransactionDetails } from '@safe-global/safe-gateway-typescript-sdk' @@ -37,7 +37,7 @@ const DecodedTx = ({ showMultisend = true, showMethodCall = false, }: DecodedTxProps): ReactElement => { - const isMultisend = decodedData?.parameters + const isMultisend = !!decodedData?.parameters[0]?.valueDecoded const isMethodCallInAdvanced = !showMethodCall || (isMultisend && showMultisend) const onChangeExpand = (_: SyntheticEvent, expanded: boolean) => { @@ -86,7 +86,10 @@ const DecodedTx = ({ {isMethodCallInAdvanced && decodedData?.method} - {!showMethodCall && !decodedData?.method && Number(tx?.data.value) > 0 && 'native transfer'} + {txDetails && + isTransferTxInfo(txDetails.txInfo) && + isNativeTokenTransfer(txDetails.txInfo.transferInfo) && + 'native transfer'} {showDecodedData && ( diff --git a/src/components/tx/SignOrExecuteForm/SignOrExecuteForm.tsx b/src/components/tx/SignOrExecuteForm/SignOrExecuteForm.tsx index 118dd51f9d..ed19899426 100644 --- a/src/components/tx/SignOrExecuteForm/SignOrExecuteForm.tsx +++ b/src/components/tx/SignOrExecuteForm/SignOrExecuteForm.tsx @@ -49,6 +49,7 @@ export type SignOrExecuteProps = { onlyExecute?: boolean disableSubmit?: boolean origin?: string + showMethodCall?: boolean } const trackTxEvents = ( @@ -141,7 +142,13 @@ export const SignOrExecuteForm = ({ )} - + {!isCounterfactualSafe && !props.isRejection && } diff --git a/src/components/tx/confirmation-views/index.tsx b/src/components/tx/confirmation-views/index.tsx index 0316c25818..7a0f3ce0a3 100644 --- a/src/components/tx/confirmation-views/index.tsx +++ b/src/components/tx/confirmation-views/index.tsx @@ -16,6 +16,7 @@ type ConfirmationViewProps = { isBatch?: boolean isApproval?: boolean isCreation?: boolean + showMethodCall?: boolean } const getConfirmationViewComponent = (txType: TransactionInfoType, props: NarrowConfirmationViewProps) => { @@ -54,7 +55,11 @@ const ConfirmationView = (props: ConfirmationViewProps) => { decodedData={decodedData} showMultisend={!props.isBatch} showMethodCall={ - !ConfirmationViewComponent && !showTxDetails && !props.isApproval && isGenericConfirmation(decodedData) + props.showMethodCall && + !showTxDetails && + !props.isApproval && + isGenericConfirmation(decodedData) && + !ConfirmationViewComponent } />