add cancellation tx type, fix tx decsription for adding owner

This commit is contained in:
mmv 2019-07-15 15:32:57 +04:00
parent 4909533048
commit f7d1e0fe7d
5 changed files with 29 additions and 15 deletions

View File

@ -40,7 +40,7 @@ type DescriptionDescProps = {
}
type AddressLinkProps = {
address: string
address: string,
}
const RinkebyAddressLink = ({ address }: AddressLinkProps) => (
@ -68,13 +68,6 @@ to:
const SettingsDescription = ({ removedOwner, addedOwner, newThreshold }: DescriptionDescProps) => (
<>
{newThreshold && (
<Paragraph>
<Bold>Change required confirmations:</Bold>
<br />
{newThreshold}
</Paragraph>
)}
{removedOwner && (
<Paragraph>
<Bold>Remove owner:</Bold>
@ -89,19 +82,27 @@ const SettingsDescription = ({ removedOwner, addedOwner, newThreshold }: Descrip
<RinkebyAddressLink address={addedOwner} />
</Paragraph>
)}
{newThreshold && (
<Paragraph>
<Bold>Change required confirmations:</Bold>
<br />
{newThreshold}
</Paragraph>
)}
</>
)
const TxDescription = ({ tx, classes }: Props) => {
const {
recipient, value, modifySettingsTx, removedOwner, addedOwner, newThreshold,
recipient, value, modifySettingsTx, removedOwner, addedOwner, newThreshold, cancellationTx,
} = getTxData(tx)
return (
<Block className={classes.txDataContainer}>
{modifySettingsTx ? (
{modifySettingsTx && (
<SettingsDescription removedOwner={removedOwner} newThreshold={newThreshold} addedOwner={addedOwner} />
) : (
)}
{!cancellationTx && !modifySettingsTx && (
<TransferDescription value={value} symbol={tx.symbol} recipient={recipient} />
)}
</Block>

View File

@ -12,6 +12,7 @@ type DecodedTxData = {
removedOwner?: string,
newThreshold?: string,
addedOwner?: string,
cancellationTx?: boolean,
}
export const getTxData = (tx: Transaction): DecodedTxData => {
@ -34,8 +35,8 @@ export const getTxData = (tx: Transaction): DecodedTxData => {
txData.newThreshold = tx.decodedParams.args[2]
} else if (tx.decodedParams.methodName === 'changeThreshold') {
txData.newThreshold = tx.decodedParams.args[0]
} else if (tx.decodedParams.methodName === 'addOWnerWithThreshold') {
txData.addedOwner = tx.decodedParams.args[1]
} else if (tx.decodedParams.methodName === 'addOwnerWithThreshold') {
txData.addedOwner = tx.decodedParams.args[0]
txData.newThreshold = tx.decodedParams.args[1]
} else if (tx.decodedParams.methodName === 'swapOwner') {
txData.addedOwner = tx.decodedParams.args[0]
@ -44,6 +45,8 @@ export const getTxData = (tx: Transaction): DecodedTxData => {
}
/* eslint-enable */
}
} else if (tx.cancellationTx) {
txData.cancellationTx = true
}
return txData

View File

@ -45,10 +45,16 @@ export type TransactionRow = SortRow<TxData>
export const getTxTableData = (transactions: List<Transaction>): List<TransactionRow> => {
const rows = transactions.map((tx: Transaction) => {
const txDate = tx.isExecuted ? tx.executionDate : tx.submissionDate
let txType = 'Outgoing transfer'
if (tx.modifySettingsTx) {
txType = 'Modify Safe Settings'
} else if (tx.cancellationTx) {
txType = 'Cancellation transaction'
}
return {
[TX_TABLE_NONCE_ID]: tx.nonce,
[TX_TABLE_TYPE_ID]: tx.modifySettingsTx ? 'Modify Safe Settings' : 'Outgoing transfer',
[TX_TABLE_TYPE_ID]: txType,
[TX_TABLE_DATE_ID]: formatDate(tx.isExecuted ? tx.executionDate : tx.submissionDate),
[buildOrderFieldFrom(TX_TABLE_DATE_ID)]: getTime(txDate),
[TX_TABLE_AMOUNT_ID]: getTxAmount(tx),

View File

@ -52,7 +52,8 @@ const buildTransactionFrom = async (safeAddress: string, tx: TxServiceModel, saf
})
}),
)
const modifySettingsTx = tx.to === safeAddress && Number(tx.value) === 0
const modifySettingsTx = 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 creationTxHash = confirmations.last().hash
@ -97,6 +98,7 @@ const buildTransactionFrom = async (safeAddress: string, tx: TxServiceModel, saf
isTokenTransfer,
decodedParams,
modifySettingsTx,
cancellationTx,
})
}

View File

@ -17,6 +17,7 @@ export type TransactionProps = {
executionDate: Date,
symbol: string,
modifySettingsTx: boolean,
cancellationTx: boolean,
creationTxHash: string,
executionTxHash?: string,
cancelled?: boolean,
@ -40,6 +41,7 @@ export const makeTransaction: RecordFactory<TransactionProps> = Record({
creationTxHash: '',
cancelled: false,
modifySettingsTx: false,
cancellationTx: false,
status: 'awaiting',
isTokenTransfer: false,
decodedParams: {},