Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TW-786 Refactored transaction history for send, receive and delegate #884

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
ad2a252
TW-786 Refactored transaction history for send, receive and delegate
herkoss Jul 17, 2023
45a105f
TW-786 Fixed tests
herkoss Jul 18, 2023
f3f1070
TW-786 Fixed qa issues
herkoss Jul 27, 2023
800d7f2
TW-786 Fixed ios/TempleWallet.xcodeproj/project.pbxproj
herkoss Jul 27, 2023
bcc2e75
TW-786 Fixed selected fiat currency symbol
herkoss Jul 27, 2023
f58b554
TW-786 Fixed QA issues
herkoss Jul 31, 2023
64295fd
TW-786 Added parser
herkoss Aug 2, 2023
dd69343
TW-786 Used Parser
herkoss Aug 3, 2023
41a26da
TW-786 Finished big refactoting
herkoss Aug 4, 2023
7f9e031
Merge branch 'development' into TW-786-transaction-history-send-recei…
herkoss Aug 7, 2023
a27e35c
TW-786 Fixed snapshot
herkoss Aug 7, 2023
7ddcaff
Merge branch 'TW-786-transaction-history-send-receive-baking-rewards-…
herkoss Aug 7, 2023
3675d00
TW-786 Fixed comments
herkoss Aug 7, 2023
b20c4a9
TW-786 Fixed comments after review
herkoss Aug 10, 2023
caba37d
TW-786 Fixed comments after review
herkoss Aug 10, 2023
f24adc0
TW-786 Added known bakers
herkoss Aug 11, 2023
90f4f1c
TW-786 Fixed QA issues. Fixed activity loading and address styles
herkoss Aug 14, 2023
ae808da
TW-786 Fixed imports
herkoss Aug 15, 2023
a81335d
TW-786 Fixed activity loading
herkoss Aug 15, 2023
76d11c5
TW-786 Fixed comment
herkoss Aug 15, 2023
ae78a60
TW-786 FIed
herkoss Aug 15, 2023
710ccfe
TW-786 Fixed bug while parser return empty array of activities
herkoss Aug 16, 2023
1a08041
TW-786 deleted console.logs
herkoss Aug 16, 2023
b1d9319
TW-786 Fixed QA issues
herkoss Aug 23, 2023
fec1db6
TW-786 Added memo to callbacks
herkoss Aug 25, 2023
02ccc41
TW-786 FIxed comments
herkoss Aug 25, 2023
7965bfc
TW-786 FIxed render item functinon
herkoss Aug 25, 2023
5cec3e2
Update src/hooks/use-contract-activity.ts
herkoss Aug 28, 2023
92fda81
TW-786 Fixed comments
herkoss Aug 28, 2023
68f0079
Merge branch 'transaction-history-epic' into TW-786-transaction-histo…
herkoss Aug 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,16 @@ export const useActivityGroupAmountChangeStyles = createUseStyles(({ colors, typ
container: {
alignItems: 'flex-end'
},
amountText: {
...typography.numbersRegular17,
amountWeight: {
fontWeight: '400'
},
amountText15: {
...typography.numbersRegular15
},
amountText13: {
...typography.numbersRegular13
},
destructiveAmountText: {
color: colors.destructive
},
positiveAmountText: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,30 @@ import { conditionalStyle } from '../../../../utils/conditional-style';
import { formatAssetAmount } from '../../../../utils/number.util';
import { useActivityGroupAmountChangeStyles } from './activity-group-amount-change.styles';

export enum TextSize {
Small = 'Small',
Regular = 'Regular'
}
interface Props {
textSize?: TextSize;
nonZeroAmounts: NonZeroAmounts;
}

export const ActivityGroupAmountChange: FC<Props> = ({ nonZeroAmounts }) => {
export const ActivityGroupAmountChange: FC<Props> = ({ nonZeroAmounts, textSize = TextSize.Regular }) => {
const styles = useActivityGroupAmountChangeStyles();

return (
<View style={styles.container}>
{nonZeroAmounts.amounts.map(({ parsedAmount, isPositive, symbol }, index) => (
<Text key={index} style={[styles.amountText, conditionalStyle(isPositive, styles.positiveAmountText)]}>
<Text
key={index}
style={[
styles.amountWeight,
conditionalStyle(textSize === TextSize.Small, styles.amountText13),
conditionalStyle(textSize === TextSize.Regular, styles.amountText15),
conditionalStyle(isPositive, styles.positiveAmountText, styles.destructiveAmountText)
]}
>
{isPositive && '+'}
{formatAssetAmount(parsedAmount)} {symbol}
</Text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const useActivityGroupDollarAmountChangeStyles = createUseStyles(({ color
color: colors.destructive
},
valueText: {
...typography.numbersRegular11
...typography.numbersRegular11,
color: colors.gray1
}
}));
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React, { FC } from 'react';
import { View } from 'react-native';

import { NonZeroAmounts } from '../../../../interfaces/non-zero-amounts.interface';
import { conditionalStyle } from '../../../../utils/conditional-style';
import { FormattedAmount } from '../../../formatted-amount';
import { useActivityGroupDollarAmountChangeStyles } from './activity-group-dollar-amount-change.styles';

Expand All @@ -16,17 +15,7 @@ export const ActivityGroupDollarAmountChange: FC<Props> = ({ nonZeroAmounts }) =
return (
<View style={styles.container}>
{nonZeroAmounts.dollarSums.map((amount, index) => (
<FormattedAmount
key={index}
amount={amount}
isDollarValue={true}
showMinusSign={amount.isLessThan(0)}
showPlusSign={amount.isGreaterThan(0)}
style={[
styles.valueText,
conditionalStyle(amount.isGreaterThan(0), styles.positiveAmountText, styles.negativeAmountText)
]}
/>
<FormattedAmount key={index} amount={amount} isDollarValue={true} style={styles.valueText} />
))}
</View>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,45 @@
import { createUseStyles } from '../../../styles/create-use-styles';
import { formatSize } from '../../../styles/format-size';
import { createUseStyles } from 'src/styles/create-use-styles';
import { formatSize } from 'src/styles/format-size';

export const useActivityGroupItemStyles = createUseStyles(({ colors }) => ({
container: {
borderBottomColor: colors.lines,
borderBottomWidth: formatSize(0.5),
export const useActivityGroupItemStyles = createUseStyles(({ colors, typography }) => ({
root: {
paddingVertical: formatSize(16),
paddingRight: formatSize(16)
},
upperContainer: {
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center'
card: {
marginTop: formatSize(12),
paddingHorizontal: formatSize(12),
borderRadius: formatSize(8),
backgroundColor: colors.cardBG
},
exploreContainer: {
flexDirection: 'row',
alignItems: 'center'
oprationTitle: {
...typography.body15Regular,
color: colors.black
},
oprationSubtitle: {
...typography.numbersRegular11,
color: colors.gray1
},
lowerContainer: {
detailItem: {
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'flex-end'
alignItems: 'center',
paddingVertical: formatSize(12)
},
statusContainer: {
flexDirection: 'row',
alignItems: 'center'
detailText: {
color: colors.gray1
},
detailItemBorder: {
borderBottomWidth: formatSize(1),
borderBottomColor: colors.lines
},
row: {
flexDirection: 'row'
},
justifyBetween: {
justifyContent: 'space-between'
},
accountPkh: {
height: formatSize(24)
itemsStart: {
alignItems: 'flex-start'
}
}));
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
import React, { FC } from 'react';
import { View } from 'react-native';
import { isEmpty } from 'lodash-es';
import React, { FC, useState } from 'react';
import { View, Text, TouchableOpacity } from 'react-native';

import { useNetworkInfo } from '../../../hooks/use-network-info.hook';
import { useNonZeroAmounts } from '../../../hooks/use-non-zero-amounts.hook';
import { ActivityGroup, emptyActivity } from '../../../interfaces/activity.interface';
import { useSelectedRpcUrlSelector } from '../../../store/settings/settings-selectors';
import { formatSize } from '../../../styles/format-size';
import { tzktUrl } from '../../../utils/linking.util';
import { Divider } from '../../divider/divider';
import { ExternalLinkButton } from '../../icon/external-link-button/external-link-button';
import { PublicKeyHashText } from '../../public-key-hash-text/public-key-hash-text';
import { ActivityGroupAmountChange } from './activity-group-amount-change/activity-group-amount-change';
import { Divider } from 'src/components/divider/divider';
import { ExternalLinkButton } from 'src/components/icon/external-link-button/external-link-button';
import { Icon } from 'src/components/icon/icon';
import { IconNameEnum } from 'src/components/icon/icon-name.enum';
import { PublicKeyHashText } from 'src/components/public-key-hash-text/public-key-hash-text';
import { RobotIcon } from 'src/components/robot-icon/robot-icon';
import { WalletAddress } from 'src/components/wallet-address/wallet-address';
import { isAndroid } from 'src/config/system';
import { useNonZeroAmounts } from 'src/hooks/use-non-zero-amounts.hook';
import { ActivityGroup } from 'src/interfaces/activity.interface';
import { useSelectedRpcUrlSelector } from 'src/store/settings/settings-selectors';
import { formatSize } from 'src/styles/format-size';
import { tzktUrl } from 'src/utils/linking.util';

import { ActivityGroupAmountChange, TextSize } from './activity-group-amount-change/activity-group-amount-change';
import { ActivityGroupDollarAmountChange } from './activity-group-dollar-amount-change/activity-group-dollar-amount-change';
import { useActivityGroupItemStyles } from './activity-group-item.styles';
import { ActivityGroupType } from './activity-group-type/activity-group-type';
import { useActivityGroupInfo } from './activity-group-type/use-activity-group-info.hook';
import { ActivityStatusBadge } from './activity-status-badge/activity-status-badge';
import { ActivityTime } from './activity-time/activity-time';
import { ActivityGroupItemSelectors } from './selectors';
Expand All @@ -25,45 +31,75 @@ interface Props {
export const ActivityGroupItem: FC<Props> = ({ group }) => {
const styles = useActivityGroupItemStyles();

const {
transactionType,
transactionSubtype,
transactionHash,
destination: [label, value, address]
} = useActivityGroupInfo(group);
const nonZeroAmounts = useNonZeroAmounts(group);

const selectedRpcUrl = useSelectedRpcUrlSelector();
const { isTezosNode } = useNetworkInfo();

const firstActivity = group[0] ?? emptyActivity;
const [areDetailsVisible, setAreDetailsVisible] = useState(false);

return (
<View style={styles.container}>
<Divider size={formatSize(8)} />
<View style={styles.upperContainer}>
<ActivityGroupType group={group} />

<View style={styles.exploreContainer}>
<PublicKeyHashText
style={styles.accountPkh}
publicKeyHash={firstActivity.hash}
testID={ActivityGroupItemSelectors.operationHash}
/>
<Divider size={formatSize(4)} />
<ExternalLinkButton
url={tzktUrl(selectedRpcUrl, firstActivity.hash)}
testID={ActivityGroupItemSelectors.externalLink}
/>
<View style={styles.root}>
<View style={[styles.row, styles.justifyBetween]}>
<View style={[styles.row, styles.itemsStart]}>
<RobotIcon size={formatSize(36)} seed={transactionHash} />
<Divider size={formatSize(10)} />
<View>
<Text style={styles.oprationTitle}>{transactionType}</Text>
<Text style={styles.oprationSubtitle}>
{label} {value}
</Text>
</View>
</View>
<View>
<ActivityGroupAmountChange nonZeroAmounts={nonZeroAmounts} />
<ActivityGroupDollarAmountChange nonZeroAmounts={nonZeroAmounts} />
</View>
</View>
<Divider size={formatSize(8)} />
<ActivityGroupAmountChange nonZeroAmounts={nonZeroAmounts} />
<Divider size={formatSize(4)} />
<View style={styles.lowerContainer}>
<View style={styles.statusContainer}>
<ActivityStatusBadge status={firstActivity.status} />
<Divider size={formatSize(12)} />
<View style={[styles.row, styles.justifyBetween]}>
<View style={styles.row}>
<ActivityStatusBadge status={group[0].status} />
<Divider size={formatSize(4)} />
<ActivityTime timestamp={firstActivity.timestamp} />
<ActivityTime timestamp={1689343447} />
herkoss marked this conversation as resolved.
Show resolved Hide resolved
</View>

{isTezosNode && <ActivityGroupDollarAmountChange nonZeroAmounts={nonZeroAmounts} />}
<TouchableOpacity onPress={() => setAreDetailsVisible(prevState => !prevState)}>
herkoss marked this conversation as resolved.
Show resolved Hide resolved
<Icon name={areDetailsVisible ? IconNameEnum.DetailsArrowUp : IconNameEnum.DetailsArrowDown} />
</TouchableOpacity>
</View>
<Divider size={formatSize(16)} />
{areDetailsVisible && (
<View style={styles.card}>
{!isEmpty(nonZeroAmounts.amounts) && (
<View style={[styles.detailItem, styles.detailItemBorder]}>
<Text style={styles.detailText}>{transactionSubtype}</Text>
<View>
<ActivityGroupAmountChange textSize={TextSize.Small} nonZeroAmounts={nonZeroAmounts} />
<ActivityGroupDollarAmountChange nonZeroAmounts={nonZeroAmounts} />
</View>
</View>
)}
<View style={[styles.detailItem, styles.detailItemBorder]}>
<Text style={styles.detailText}>{label}</Text>
<WalletAddress isLocalDomainNameShowing publicKeyHash={address} isPublicKeyHashTextDisabled={isAndroid} />
</View>
<View style={styles.detailItem}>
<Text style={styles.detailText}>TxHash:</Text>
<View style={styles.row}>
<PublicKeyHashText publicKeyHash={transactionHash} testID={ActivityGroupItemSelectors.operationHash} />
<Divider size={formatSize(4)} />
<ExternalLinkButton
url={tzktUrl(selectedRpcUrl, transactionHash)}
testID={ActivityGroupItemSelectors.externalLink}
/>
</View>
</View>
</View>
)}
</View>
);
};

This file was deleted.

This file was deleted.

Loading