Skip to content

Commit

Permalink
Fix: nested tx preview (#4851)
Browse files Browse the repository at this point in the history
  • Loading branch information
katspaugh authored Jan 29, 2025
1 parent 3567039 commit 9d5a370
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const ExecTransaction = ({
const [txPreview, error] = useTxPreview(
childSafeTx
? {
operation: childSafeTx.data.operation,
operation: Number(childSafeTx.data.operation),
data: childSafeTx.data.data,
to: childSafeTx.data.to,
value: childSafeTx.data.value.toString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ exports[`SignOrExecute should display a confirmation screen 1`] = `
>
<div
class="MuiCardContent-root cardContent css-1lt5qva-MuiCardContent-root"
data-testid="card-content"
>
<div
class="MuiStack-root css-1sazv7p-MuiStack-root"
Expand Down Expand Up @@ -172,6 +173,7 @@ exports[`SignOrExecute should display a confirmation screen 1`] = `
>
<div
class="MuiCardContent-root cardContent css-1lt5qva-MuiCardContent-root"
data-testid="card-content"
>
<div
class="wrapper"
Expand Down Expand Up @@ -279,6 +281,7 @@ exports[`SignOrExecute should display a loading component 1`] = `
>
<div
class="MuiCardContent-root cardContent css-1lt5qva-MuiCardContent-root"
data-testid="card-content"
>
<div
class="MuiBox-root css-17luq05"
Expand Down Expand Up @@ -343,6 +346,7 @@ exports[`SignOrExecute should display an error screen 1`] = `
>
<div
class="MuiCardContent-root cardContent css-1lt5qva-MuiCardContent-root"
data-testid="card-content"
>
<div
class="MuiStack-root css-1sazv7p-MuiStack-root"
Expand Down Expand Up @@ -507,6 +511,7 @@ exports[`SignOrExecute should display an error screen 1`] = `
>
<div
class="MuiCardContent-root cardContent css-1lt5qva-MuiCardContent-root"
data-testid="card-content"
>
<div
class="wrapper"
Expand Down
7 changes: 4 additions & 3 deletions apps/web/src/components/tx/confirmation-views/useTxPreview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,18 @@ const useTxPreview = (
customSafeAddress?: string,
txId?: string,
) => {
const skip = !!txId || !safeTxData
const {
safe: { chainId },
safeAddress,
} = useSafeInfo()
const address = customSafeAddress ?? safeAddress
const { operation = Operation.CALL, data = '', to, value } = safeTxData ?? {}

return useAsync(() => {
if (txId || !safeTxData?.data) return
const { operation = Operation.CALL, data = '', to, value } = safeTxData || {}
if (skip) return
return getTxPreview(chainId, address, operation, data, to, value)
}, [txId, chainId, address, safeTxData])
}, [skip, chainId, address, operation, data, to, value])
}

export default useTxPreview

0 comments on commit 9d5a370

Please sign in to comment.