Use safe tx hash as transaction id

This commit is contained in:
Germán Martínez 2019-07-23 11:36:16 +02:00
parent 11a4b84c9b
commit 6cda678c9e
3 changed files with 9 additions and 23 deletions

View File

@ -54,8 +54,8 @@ const TxsTable = ({
}: Props) => { }: Props) => {
const [expandedTx, setExpandedTx] = useState<string | null>(null) const [expandedTx, setExpandedTx] = useState<string | null>(null)
const handleTxExpand = (creationTxHash) => { const handleTxExpand = (safeTxHash) => {
setExpandedTx(prevTx => (prevTx === creationTxHash ? null : creationTxHash)) setExpandedTx(prevTx => (prevTx === safeTxHash ? null : safeTxHash))
} }
const columns = generateColumns() const columns = generateColumns()
@ -77,8 +77,8 @@ const TxsTable = ({
<React.Fragment key={index}> <React.Fragment key={index}>
<TableRow <TableRow
tabIndex={-1} tabIndex={-1}
className={cn(classes.row, expandedTx === row.tx.creationTxHash && classes.expandedRow)} className={cn(classes.row, expandedTx === row.tx.safeTxHash && classes.expandedRow)}
onClick={() => handleTxExpand(row.tx.creationTxHash)} onClick={() => handleTxExpand(row.tx.safeTxHash)}
data-testid={TRANSACTION_ROW_TEST_ID} data-testid={TRANSACTION_ROW_TEST_ID}
> >
{autoColumns.map((column: Column) => ( {autoColumns.map((column: Column) => (
@ -98,7 +98,7 @@ const TxsTable = ({
</Row> </Row>
</TableCell> </TableCell>
<TableCell style={expandCellStyle}> <TableCell style={expandCellStyle}>
<IconButton disableRipple>{expandedTx === row.nonce ? <ExpandLess /> : <ExpandMore />}</IconButton> <IconButton disableRipple>{expandedTx === row.safeTxHash ? <ExpandLess /> : <ExpandMore />}</IconButton>
</TableCell> </TableCell>
</TableRow> </TableRow>
<TableRow> <TableRow>
@ -108,7 +108,7 @@ const TxsTable = ({
className={classes.extendedTxContainer} className={classes.extendedTxContainer}
> >
<Collapse <Collapse
in={expandedTx === row.tx.creationTxHash} in={expandedTx === row.tx.safeTxHash}
timeout="auto" timeout="auto"
component={ExpandedTxComponent} component={ExpandedTxComponent}
unmountOnExit unmountOnExit

View File

@ -38,19 +38,6 @@ type TxServiceModel = {
isExecuted: boolean, isExecuted: boolean,
} }
const compareConfirmations = (a, b) => {
const confA = a.hash.toLowerCase()
const confB = b.hash.toLowerCase()
let comparison = 0
if (confA > confB) {
comparison = 1
} else if (confA < confB) {
comparison = -1
}
return comparison
}
export const buildTransactionFrom = async ( export const buildTransactionFrom = async (
safeAddress: string, safeAddress: string,
tx: TxServiceModel, tx: TxServiceModel,
@ -72,7 +59,6 @@ export const buildTransactionFrom = async (
const modifySettingsTx = tx.to === safeAddress && Number(tx.value) === 0 && !!tx.data const modifySettingsTx = tx.to === safeAddress && Number(tx.value) === 0 && !!tx.data
const cancellationTx = tx.to === safeAddress && Number(tx.value) === 0 && !tx.data const cancellationTx = tx.to === safeAddress && Number(tx.value) === 0 && !tx.data
const isTokenTransfer = await isAddressAToken(tx.to) const isTokenTransfer = await isAddressAToken(tx.to)
const creationTxHash = confirmations.sort(compareConfirmations).first().hash
let executionTxHash let executionTxHash
const executionTx = confirmations.find(conf => conf.type === TX_TYPE_EXECUTION) const executionTx = confirmations.find(conf => conf.type === TX_TYPE_EXECUTION)
@ -109,7 +95,7 @@ export const buildTransactionFrom = async (
submissionDate: tx.submissionDate, submissionDate: tx.submissionDate,
executionDate: tx.executionDate, executionDate: tx.executionDate,
executionTxHash, executionTxHash,
creationTxHash, safeTxHash: tx.safeTxHash,
isTokenTransfer, isTokenTransfer,
decodedParams, decodedParams,
modifySettingsTx, modifySettingsTx,

View File

@ -18,7 +18,7 @@ export type TransactionProps = {
symbol: string, symbol: string,
modifySettingsTx: boolean, modifySettingsTx: boolean,
cancellationTx: boolean, cancellationTx: boolean,
creationTxHash: string, safeTxHash: string,
executionTxHash?: string, executionTxHash?: string,
cancelled?: boolean, cancelled?: boolean,
status?: TransactionStatus, status?: TransactionStatus,
@ -38,7 +38,7 @@ export const makeTransaction: RecordFactory<TransactionProps> = Record({
executionDate: '', executionDate: '',
symbol: '', symbol: '',
executionTxHash: undefined, executionTxHash: undefined,
creationTxHash: '', safeTxHash: '',
cancelled: false, cancelled: false,
modifySettingsTx: false, modifySettingsTx: false,
cancellationTx: false, cancellationTx: false,