Skip to content

Commit

Permalink
fix: Add back showMethodCall and keep prop drilling it
Browse files Browse the repository at this point in the history
  • Loading branch information
usame-algan committed Sep 18, 2024
1 parent 388d600 commit 20c52f2
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const ConfirmProposedTx = ({ txSummary }: ConfirmProposedTxProps): ReactElement
const text = canSign ? (canExecute ? SIGN_EXECUTE_TEXT : SIGN_TEXT) : EXECUTE_TEXT

return (
<SignOrExecuteForm txId={txId} isExecutable={canExecute} onlyExecute={!canSign}>
<SignOrExecuteForm txId={txId} isExecutable={canExecute} onlyExecute={!canSign} showMethodCall>
<Typography mb={1}>{text}</Typography>
</SignOrExecuteForm>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const ReviewSafeAppsTx = ({
const error = !isTxValid(txs)

return (
<SignOrExecuteForm onSubmit={handleSubmit} origin={origin}>
<SignOrExecuteForm onSubmit={handleSubmit} origin={origin} showMethodCall>
{error ? (
<ErrorMessage error={safeTxError}>
This Safe App initiated a transaction which cannot be processed. Please get in touch with the developer of
Expand Down
9 changes: 6 additions & 3 deletions src/components/tx/DecodedTx/index.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -86,7 +86,10 @@ const DecodedTx = ({
<HelpToolTip />
<Box flexGrow={1} />
{isMethodCallInAdvanced && decodedData?.method}
{!showMethodCall && !decodedData?.method && Number(tx?.data.value) > 0 && 'native transfer'}
{txDetails &&
isTransferTxInfo(txDetails.txInfo) &&
isNativeTokenTransfer(txDetails.txInfo.transferInfo) &&
'native transfer'}
</AccordionSummary>
<AccordionDetails data-testid="decoded-tx-details">
{showDecodedData && (
Expand Down
9 changes: 8 additions & 1 deletion src/components/tx/SignOrExecuteForm/SignOrExecuteForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export type SignOrExecuteProps = {
onlyExecute?: boolean
disableSubmit?: boolean
origin?: string
showMethodCall?: boolean
}

const trackTxEvents = (
Expand Down Expand Up @@ -141,7 +142,13 @@ export const SignOrExecuteForm = ({
</ErrorBoundary>
)}

<ConfirmationView isCreation={isCreation} txDetails={props.txDetails} safeTx={safeTx} />
<ConfirmationView
isCreation={isCreation}
txDetails={props.txDetails}
safeTx={safeTx}
isBatch={props.isBatch}
showMethodCall={props.showMethodCall}
/>

{!isCounterfactualSafe && !props.isRejection && <BlockaidBalanceChanges />}
</TxCard>
Expand Down
7 changes: 6 additions & 1 deletion src/components/tx/confirmation-views/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type ConfirmationViewProps = {
isBatch?: boolean
isApproval?: boolean
isCreation?: boolean
showMethodCall?: boolean
}

const getConfirmationViewComponent = (txType: TransactionInfoType, props: NarrowConfirmationViewProps) => {
Expand Down Expand Up @@ -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
}
/>
</>
Expand Down

0 comments on commit 20c52f2

Please sign in to comment.