Commit 86d574cd authored by POA's avatar POA

Fix lint:tsc errors

parent cb203e6e
export type TxAction = { export type TxAction = {
protocol: string; protocol: 'uniswap_v3';
type: string; type: 'mint' | 'burn' | 'collect' | 'swap' | 'mint_nft';
data: { data: {
name: string; name: string;
symbol: string; symbol: string;
...@@ -14,5 +14,4 @@ export type TxAction = { ...@@ -14,5 +14,4 @@ export type TxAction = {
symbol1: string; symbol1: string;
address1: string; address1: string;
}; };
isLast: boolean;
} }
...@@ -12,9 +12,12 @@ import TokenSnippet from 'ui/shared/TokenSnippet/TokenSnippet'; ...@@ -12,9 +12,12 @@ import TokenSnippet from 'ui/shared/TokenSnippet/TokenSnippet';
const uniswapIconUrl = 'https://raw.githubusercontent.com/trustwallet/assets/master/dapps/app.uniswap.org.png'; const uniswapIconUrl = 'https://raw.githubusercontent.com/trustwallet/assets/master/dapps/app.uniswap.org.png';
type Props = TTxAction; interface Props {
action: TTxAction;
isLast: boolean;
}
function actionName(actionType: string) { function uniswapActionName(actionType: string) {
switch (actionType) { switch (actionType) {
case 'mint': return [ 'Add', 'Liquidity To' ]; case 'mint': return [ 'Add', 'Liquidity To' ];
case 'burn': return [ 'Remove', 'Liquidity From' ]; case 'burn': return [ 'Remove', 'Liquidity From' ];
...@@ -24,7 +27,13 @@ function actionName(actionType: string) { ...@@ -24,7 +27,13 @@ function actionName(actionType: string) {
} }
} }
const TxDetailsAction = ({ protocol, type, data, isLast }: Props) => { function unknownAction() {
return (<span>Unrecognized action</span>);
}
const TxDetailsAction = ({ action, isLast }: Props) => {
const { protocol, type, data } = action;
if (protocol === 'uniswap_v3') { if (protocol === 'uniswap_v3') {
if ([ 'mint', 'burn', 'collect', 'swap' ].includes(type)) { if ([ 'mint', 'burn', 'collect', 'swap' ].includes(type)) {
const amount0 = BigNumber(data.amount0).toFormat(); const amount0 = BigNumber(data.amount0).toFormat();
...@@ -33,7 +42,7 @@ const TxDetailsAction = ({ protocol, type, data, isLast }: Props) => { ...@@ -33,7 +42,7 @@ const TxDetailsAction = ({ protocol, type, data, isLast }: Props) => {
return ( return (
<Flex flexWrap="wrap" columnGap={ 1 } rowGap={ 2 } className={ isLast ? 'lastItem' : '' } marginBottom={ isLast ? 5 : 0 }> <Flex flexWrap="wrap" columnGap={ 1 } rowGap={ 2 } className={ isLast ? 'lastItem' : '' } marginBottom={ isLast ? 5 : 0 }>
<Text color="gray.500" as="span"> <Text color="gray.500" as="span">
{ actionName(type)[0] } { uniswapActionName(type)[0] }
</Text> </Text>
<Flex columnGap={ 1 }> <Flex columnGap={ 1 }>
...@@ -51,7 +60,7 @@ const TxDetailsAction = ({ protocol, type, data, isLast }: Props) => { ...@@ -51,7 +60,7 @@ const TxDetailsAction = ({ protocol, type, data, isLast }: Props) => {
</Flex> </Flex>
<Text color="gray.500" as="span"> <Text color="gray.500" as="span">
{ actionName(type)[1] } { uniswapActionName(type)[1] }
</Text> </Text>
<Flex columnGap={ 1 }> <Flex columnGap={ 1 }>
...@@ -100,7 +109,11 @@ const TxDetailsAction = ({ protocol, type, data, isLast }: Props) => { ...@@ -100,7 +109,11 @@ const TxDetailsAction = ({ protocol, type, data, isLast }: Props) => {
</Flex> </Flex>
</Flex> </Flex>
); );
} else {
return unknownAction();
} }
} else {
return unknownAction();
} }
}; };
......
...@@ -54,7 +54,7 @@ const TxDetailsActions = ({ actions }: Props) => { ...@@ -54,7 +54,7 @@ const TxDetailsActions = ({ actions }: Props) => {
w="100%" w="100%"
fontWeight={ 500 } fontWeight={ 500 }
> >
{ actions.map((action, index: number) => <TxDetailsAction key={ index } { ...action } isLast={ index === actions.length - 1 }/>) } { actions.map((action, index: number) => <TxDetailsAction key={ index } action={ action } isLast={ index === actions.length - 1 }/>) }
</Flex> </Flex>
</Box> </Box>
{ /* eslint-disable-next-line react/jsx-no-bind */ } { /* eslint-disable-next-line react/jsx-no-bind */ }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment