(feature): [Safe Apps] App Transaction List Details (#601)
* Adding IconText component * Get origin for TXs in Redux * Adding Icon and name app to transaction list * Fix customTx condition * Fix HTML element for text * simplify condition
This commit is contained in:
parent
8634dcc64d
commit
d5b64849b4
|
@ -0,0 +1,25 @@
|
||||||
|
// @flow
|
||||||
|
import React from 'react'
|
||||||
|
import styled from 'styled-components'
|
||||||
|
|
||||||
|
const Wrapper = styled.div`
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
`
|
||||||
|
const Icon = styled.img`
|
||||||
|
max-width: 15px;
|
||||||
|
max-height: 15px;
|
||||||
|
margin-right: 5px;
|
||||||
|
`
|
||||||
|
const Text = styled.span`
|
||||||
|
height: 17px;
|
||||||
|
`
|
||||||
|
|
||||||
|
const IconText = ({ iconUrl, text }: { iconUrl: string, text: string }) => (
|
||||||
|
<Wrapper>
|
||||||
|
<Icon src={iconUrl} alt={text} />
|
||||||
|
<Text>{text}</Text>
|
||||||
|
</Wrapper>
|
||||||
|
)
|
||||||
|
|
||||||
|
export default IconText
|
|
@ -1,3 +1,4 @@
|
||||||
// @flow
|
// @flow
|
||||||
export { default as DividerLine } from './DividerLine'
|
export { default as DividerLine } from './DividerLine'
|
||||||
export { default as TextBox } from './TextBox'
|
export { default as TextBox } from './TextBox'
|
||||||
|
export { default as IconText } from './IconText'
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// @flow
|
// @flow
|
||||||
export default [
|
const appList = [
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
name: 'Compound',
|
name: 'Compound',
|
||||||
|
@ -38,3 +38,7 @@ export default [
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
export default appList
|
||||||
|
|
||||||
|
export const getAppInfo = (appName: string) => appList.find(app => app.name === appName)
|
||||||
|
|
|
@ -1,21 +1,13 @@
|
||||||
// @flow
|
// @flow
|
||||||
import { makeStyles } from '@material-ui/core/styles'
|
|
||||||
import * as React from 'react'
|
import * as React from 'react'
|
||||||
|
|
||||||
import CustomTxIcon from './assets/custom.svg'
|
|
||||||
import IncomingTxIcon from './assets/incoming.svg'
|
|
||||||
import OutgoingTxIcon from './assets/outgoing.svg'
|
|
||||||
import SettingsTxIcon from './assets/settings.svg'
|
|
||||||
import { styles } from './style'
|
|
||||||
|
|
||||||
import Block from '~/components/layout/Block'
|
|
||||||
import Img from '~/components/layout/Img'
|
|
||||||
import Paragraph from '~/components/layout/Paragraph/'
|
|
||||||
import { type TransactionType } from '~/routes/safe/store/models/transaction'
|
import { type TransactionType } from '~/routes/safe/store/models/transaction'
|
||||||
|
import { getAppInfo } from '~/routes/safe/components/Apps/appsList'
|
||||||
|
import { IconText } from '~/components-v2'
|
||||||
|
|
||||||
type Props = {
|
import OutgoingTxIcon from './assets/outgoing.svg'
|
||||||
txType: TransactionType,
|
import IncomingTxIcon from './assets/incoming.svg'
|
||||||
}
|
import CustomTxIcon from './assets/custom.svg'
|
||||||
|
import SettingsTxIcon from './assets/settings.svg'
|
||||||
|
|
||||||
const typeToIcon = {
|
const typeToIcon = {
|
||||||
outgoing: OutgoingTxIcon,
|
outgoing: OutgoingTxIcon,
|
||||||
|
@ -37,19 +29,11 @@ const typeToLabel = {
|
||||||
upgrade: 'Contract Upgrade',
|
upgrade: 'Contract Upgrade',
|
||||||
}
|
}
|
||||||
|
|
||||||
const useStyles = makeStyles(styles)
|
const TxType = ({ txType, origin }: { txType: TransactionType, origin: string | null }) => {
|
||||||
|
const iconUrl = txType === 'third-party-app' ? getAppInfo(origin).iconUrl : typeToIcon[txType]
|
||||||
|
const text = txType === 'third-party-app' ? origin : typeToLabel[txType]
|
||||||
|
|
||||||
const TxType = ({ txType }: Props) => {
|
return <IconText iconUrl={iconUrl} text={text} />
|
||||||
const classes = useStyles()
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Block className={classes.container}>
|
|
||||||
<Img alt={typeToLabel[txType]} className={classes.img} src={typeToIcon[txType]} />
|
|
||||||
<Paragraph className={classes.type} noMargin>
|
|
||||||
{typeToLabel[txType]}
|
|
||||||
</Paragraph>
|
|
||||||
</Block>
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default TxType
|
export default TxType
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
// @flow
|
|
||||||
export const styles = () => ({
|
|
||||||
container: {
|
|
||||||
display: 'flex',
|
|
||||||
},
|
|
||||||
img: {
|
|
||||||
marginRight: '5px',
|
|
||||||
},
|
|
||||||
type: {
|
|
||||||
height: '17px',
|
|
||||||
},
|
|
||||||
})
|
|
|
@ -75,7 +75,7 @@ const getTransactionTableData = (tx: Transaction, cancelTx: ?Transaction): Trans
|
||||||
} else if (tx.cancellationTx) {
|
} else if (tx.cancellationTx) {
|
||||||
txType = 'cancellation'
|
txType = 'cancellation'
|
||||||
} else if (tx.customTx) {
|
} else if (tx.customTx) {
|
||||||
txType = 'custom'
|
txType = tx.origin ? 'third-party-app' : 'custom'
|
||||||
} else if (tx.creationTx) {
|
} else if (tx.creationTx) {
|
||||||
txType = 'creation'
|
txType = 'creation'
|
||||||
} else if (tx.upgradeTx) {
|
} else if (tx.upgradeTx) {
|
||||||
|
@ -84,7 +84,7 @@ const getTransactionTableData = (tx: Transaction, cancelTx: ?Transaction): Trans
|
||||||
|
|
||||||
return {
|
return {
|
||||||
[TX_TABLE_ID]: tx.blockNumber,
|
[TX_TABLE_ID]: tx.blockNumber,
|
||||||
[TX_TABLE_TYPE_ID]: <TxType txType={txType} />,
|
[TX_TABLE_TYPE_ID]: <TxType origin={tx.origin} txType={txType} />,
|
||||||
[TX_TABLE_DATE_ID]: txDate ? formatDate(txDate) : '',
|
[TX_TABLE_DATE_ID]: txDate ? formatDate(txDate) : '',
|
||||||
[buildOrderFieldFrom(TX_TABLE_DATE_ID)]: txDate ? getTime(parseISO(txDate)) : null,
|
[buildOrderFieldFrom(TX_TABLE_DATE_ID)]: txDate ? getTime(parseISO(txDate)) : null,
|
||||||
[TX_TABLE_AMOUNT_ID]: getTxAmount(tx),
|
[TX_TABLE_AMOUNT_ID]: getTxAmount(tx),
|
||||||
|
|
|
@ -92,8 +92,8 @@ export const buildTransactionFrom = async (safeAddress: string, tx: TxServiceMod
|
||||||
const cancellationTx = sameAddress(tx.to, safeAddress) && Number(tx.value) === 0 && !tx.data
|
const cancellationTx = sameAddress(tx.to, safeAddress) && Number(tx.value) === 0 && !tx.data
|
||||||
const isSendTokenTx = isTokenTransfer(tx.data, Number(tx.value))
|
const isSendTokenTx = isTokenTransfer(tx.data, Number(tx.value))
|
||||||
const isMultiSendTx = isMultisendTransaction(tx.data, Number(tx.value))
|
const isMultiSendTx = isMultisendTransaction(tx.data, Number(tx.value))
|
||||||
const customTx = !sameAddress(tx.to, safeAddress) && !!tx.data && !isSendTokenTx && !isMultiSendTx
|
|
||||||
const isUpgradeTx = isMultiSendTx && isUpgradeTransaction(tx.data)
|
const isUpgradeTx = isMultiSendTx && isUpgradeTransaction(tx.data)
|
||||||
|
const customTx = !sameAddress(tx.to, safeAddress) && !!tx.data && !isSendTokenTx && !isUpgradeTx
|
||||||
|
|
||||||
let refundParams = null
|
let refundParams = null
|
||||||
if (tx.gasPrice > 0) {
|
if (tx.gasPrice > 0) {
|
||||||
|
@ -176,6 +176,7 @@ export const buildTransactionFrom = async (safeAddress: string, tx: TxServiceMod
|
||||||
customTx,
|
customTx,
|
||||||
cancellationTx,
|
cancellationTx,
|
||||||
creationTx: tx.creationTx,
|
creationTx: tx.creationTx,
|
||||||
|
origin: tx.origin,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,7 @@ export type TransactionProps = {
|
||||||
decodedParams?: Object,
|
decodedParams?: Object,
|
||||||
refundParams?: Object,
|
refundParams?: Object,
|
||||||
type: string,
|
type: string,
|
||||||
|
origin: string | null,
|
||||||
}
|
}
|
||||||
|
|
||||||
export const makeTransaction: RecordFactory<TransactionProps> = Record({
|
export const makeTransaction: RecordFactory<TransactionProps> = Record({
|
||||||
|
@ -85,6 +86,7 @@ export const makeTransaction: RecordFactory<TransactionProps> = Record({
|
||||||
decodedParams: {},
|
decodedParams: {},
|
||||||
refundParams: null,
|
refundParams: null,
|
||||||
type: 'outgoing',
|
type: 'outgoing',
|
||||||
|
origin: null,
|
||||||
})
|
})
|
||||||
|
|
||||||
export type Transaction = RecordOf<TransactionProps>
|
export type Transaction = RecordOf<TransactionProps>
|
||||||
|
|
Loading…
Reference in New Issue