-
Notifications
You must be signed in to change notification settings - Fork 464
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
119 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { DataRow } from '@/components/common/Table/DataRow' | ||
import useAsync from '@/hooks/useAsync' | ||
import { useCurrentChain } from '@/hooks/useChains' | ||
import { isMultisigDetailedExecutionInfo } from '@/utils/transaction-guards' | ||
import { Box, Divider } from '@mui/material' | ||
import { TransactionDetails } from '@safe-global/safe-gateway-typescript-sdk' | ||
|
||
const TxNote = ({ txDetails }: { txDetails: TransactionDetails }) => { | ||
const currentChain = useCurrentChain() | ||
const txService = currentChain?.transactionService | ||
|
||
let safeTxHash = '' | ||
if (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 = '' | ||
if (data) { | ||
try { | ||
const origin = JSON.parse(data.origin) | ||
const parsedName = JSON.parse(origin.name) | ||
note = parsedName.note | ||
} catch { | ||
// Ignore, no note | ||
} | ||
} | ||
|
||
return note ? ( | ||
<> | ||
<Box m={2} py={1}> | ||
<DataRow title="Proposer note:">{note}</DataRow> | ||
</Box> | ||
|
||
<Divider sx={{ mb: 2 }} /> | ||
</> | ||
) : null | ||
} | ||
|
||
export default TxNote |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { useState } from 'react' | ||
import { Button, Stack, TextField, Typography } from '@mui/material' | ||
import TxCard from '@/components/tx-flow/common/TxCard' | ||
|
||
const TxNoteForm = ({ onSubmit }: { onSubmit: (note: string) => void }) => { | ||
const [note, setNote] = useState('') | ||
|
||
const onFormSubmit = (e: React.FormEvent<HTMLFormElement>) => { | ||
e.preventDefault() | ||
const formData = new FormData(e.currentTarget) | ||
const value = formData.get('note') as string | ||
if (value) { | ||
onSubmit(value) | ||
setNote(value) | ||
} | ||
} | ||
|
||
return ( | ||
<TxCard> | ||
<form onSubmit={onFormSubmit}> | ||
<Typography variant="h6">Add a note</Typography> | ||
|
||
<TextField name="note" label="Transaction description" fullWidth margin="normal" disabled={!!note} /> | ||
|
||
<Stack direction="row" spacing={2} alignItems="center" justifyContent="flex-end" sx={{ mt: 1 }}> | ||
<Typography variant="caption" flex={1}> | ||
Attention: transaction notes are public | ||
</Typography> | ||
{note && <Typography variant="body2">Note added</Typography>} | ||
<Button variant="outlined" type="submit" disabled={!!note}> | ||
Add note | ||
</Button> | ||
</Stack> | ||
</form> | ||
</TxCard> | ||
) | ||
} | ||
|
||
export default TxNoteForm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters