Skip to content

Commit

Permalink
Use CGW
Browse files Browse the repository at this point in the history
  • Loading branch information
katspaugh committed Dec 30, 2024
1 parent 742a9a7 commit f7afb4f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 34 deletions.
35 changes: 1 addition & 34 deletions apps/web/src/components/transactions/TxDetails/TxNote.tsx
Original file line number Diff line number Diff line change
@@ -1,42 +1,9 @@
import { Tooltip, Typography } from '@mui/material'
import type { TransactionDetails } from '@safe-global/safe-gateway-typescript-sdk'
import useAsync from '@/hooks/useAsync'
import { useCurrentChain } from '@/hooks/useChains'
import { isMultisigDetailedExecutionInfo } from '@/utils/transaction-guards'
import InfoIcon from '@/public/images/notifications/info.svg'

function useTxNote(txDetails: TransactionDetails | undefined): string | undefined {
const currentChain = useCurrentChain()
const txService = currentChain?.transactionService

let safeTxHash = ''
if (txDetails && isMultisigDetailedExecutionInfo(txDetails.detailedExecutionInfo)) {
safeTxHash = txDetails.detailedExecutionInfo?.safeTxHash
}

const [data] = useAsync(() => {
if (!safeTxHash || !txService) return
return fetch(`${txService}/api/v1/multisig-transactions/${safeTxHash}`).then((res) => res.json())
}, [safeTxHash, txService])

let note: string | undefined
if (data) {
try {
const origin = JSON.parse(data.origin)
const parsedName = JSON.parse(origin.name)
if (typeof parsedName.note === 'string') {
note = parsedName.note
}
} catch {
// Ignore, no note
}
}

return note
}

const TxNote = ({ txDetails }: { txDetails: TransactionDetails | undefined }) => {
const note = useTxNote(txDetails)
const note = (txDetails as TransactionDetails & { note: string | null })?.note

return note ? (
<div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
border-bottom: 1px solid var(--color-border-light);
}

.txNote:empty {
display: none;
}

.loading,
.error,
.txData,
Expand Down

0 comments on commit f7afb4f

Please sign in to comment.