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 783 transaction history unknown operation mobile #936

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
50 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
008c282
TW-783 wip
herkoss Aug 8, 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
21ccb06
Merge branch 'TW-786-transaction-history-send-receive-baking-rewards-…
herkoss Aug 14, 2023
fc92e1b
TW-783 upgraded parser
herkoss Aug 14, 2023
90f4f1c
TW-786 Fixed QA issues. Fixed activity loading and address styles
herkoss Aug 14, 2023
fa1f92e
Merge branch 'TW-786-transaction-history-send-receive-baking-rewards-…
herkoss Aug 14, 2023
95f78ff
TW-783 wip
herkoss Aug 15, 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
3a6d99f
Merge branch 'TW-786-transaction-history-send-receive-baking-rewards-…
herkoss Aug 15, 2023
3afc0af
TW-783 Finished unknown operations
herkoss Aug 16, 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
ea16d0f
Merge branch 'TW-786-transaction-history-send-receive-baking-rewards-…
herkoss Aug 28, 2023
bf42b6e
WIP
herkoss Aug 30, 2023
7dbb94b
TW-783 Finished working on unknown operations
herkoss Sep 1, 2023
205e293
Merge branch 'transaction-history-epic' of github.com:madfish-solutio…
herkoss Sep 1, 2023
a3bc8ce
TW-783 Fixed activity order
herkoss Sep 1, 2023
e8626ab
TW-783 Fixed comments, added memo
herkoss Sep 4, 2023
2bc8e4d
TW-783 Added equality fn
herkoss Sep 4, 2023
7156d80
TW-783 Fixed undefined matadata
herkoss Sep 5, 2023
3d54c49
TW-783 Added memo
herkoss Sep 6, 2023
76fb83b
TW-783 Fixed dispatching metadata
herkoss Sep 6, 2023
88c8718
TW-783 Fixed qa issues
herkoss Sep 8, 2023
dfe06d9
TW-783 Fixed comments
herkoss Sep 11, 2023
17cfeae
TW-783 Fixed qa issues
herkoss Sep 12, 2023
6ea5b28
TW-783 Fixed delegation components and render list
herkoss Sep 18, 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 @@ -2,7 +2,7 @@ import React, { FC, useMemo } from 'react';
import { Text, View } from 'react-native';

import { ActivityAmount } from 'src/interfaces/non-zero-amounts.interface';
import { isDoubleTokenOperation, isSingleTokenOperation } from 'src/utils/activity.utils';
import { isSingleTokenOperation, separateAmountsBySign } from 'src/utils/activity.utils';
import { conditionalStyle } from 'src/utils/conditional-style';
import { shortizeSymbol } from 'src/utils/token-metadata.utils';

Expand Down Expand Up @@ -38,9 +38,9 @@ export const ActivityGroupAmountChange: FC<Props> = ({ nonZeroAmounts, textSize
);
}

const { isPositive, parsedAmount, symbol } = nonZeroAmounts[FIRST_AMOUNT_INDEX];

if (isSingleTokenOperation(nonZeroAmounts)) {
const { isPositive, parsedAmount, symbol } = nonZeroAmounts[FIRST_AMOUNT_INDEX];

return (
<ItemAmountChange
amount={parsedAmount}
Expand All @@ -55,37 +55,105 @@ export const ActivityGroupAmountChange: FC<Props> = ({ nonZeroAmounts, textSize
);
}

if (isDoubleTokenOperation(nonZeroAmounts)) {
const symbols = nonZeroAmounts.map(({ symbol }) => symbol).join(',');
const { positiveAmounts, negativeAmounts } = separateAmountsBySign(nonZeroAmounts);

if (positiveAmounts.length === 0) {
if (negativeAmounts.length === 0) {
return null;
}
const { symbol, parsedAmount } = negativeAmounts[FIRST_AMOUNT_INDEX];
if (negativeAmounts.length === 1) {
return (
<ItemAmountChange
amount={parsedAmount}
isPositive={false}
symbol={symbol}
textStyle={[
styles.amountWeight,
conditionalStyle(textSize === TextSize.Small, styles.amountText13),
conditionalStyle(textSize === TextSize.Regular, styles.amountText15)
]}
/>
);
}
if (negativeAmounts.length === 2) {
const symbols = negativeAmounts.map(({ symbol }) => symbol).join(',');

return (
<Text
style={[
styles.amountWeight,
styles.destructiveAmountText,
conditionalStyle(textSize === TextSize.Small, styles.amountText13),
conditionalStyle(textSize === TextSize.Regular, styles.amountText15)
]}
>
-{shortizeSymbol(symbols)}
</Text>
);
}

return (
<Text
style={[
styles.amountWeight,
styles.destructiveAmountText,
conditionalStyle(textSize === TextSize.Small, styles.amountText13),
conditionalStyle(textSize === TextSize.Regular, styles.amountText15),
conditionalStyle(isPositive, styles.positiveAmountText, styles.destructiveAmountText)
conditionalStyle(textSize === TextSize.Regular, styles.amountText15)
]}
>
{isPositive && '+'}
{shortizeSymbol(symbols)}
-{shortizeSymbol(symbol)} and {negativeAmounts.length - 1} others
</Text>
);
}
} else {
if (positiveAmounts.length === 0) {
return null;
}
const { symbol, parsedAmount } = positiveAmounts[FIRST_AMOUNT_INDEX];
if (positiveAmounts.length === 1) {
return (
<ItemAmountChange
amount={parsedAmount}
isPositive
symbol={symbol}
textStyle={[
styles.amountWeight,
conditionalStyle(textSize === TextSize.Small, styles.amountText13),
conditionalStyle(textSize === TextSize.Regular, styles.amountText15)
]}
/>
);
}
if (positiveAmounts.length === 2) {
const symbols = positiveAmounts.map(({ symbol }) => symbol).join(',');

return (
<Text
style={[
styles.amountWeight,
styles.destructiveAmountText,
conditionalStyle(textSize === TextSize.Small, styles.amountText13),
conditionalStyle(textSize === TextSize.Regular, styles.amountText15)
]}
>
+{shortizeSymbol(symbols)}
</Text>
);
}

return (
<Text
style={[
styles.amountWeight,
conditionalStyle(textSize === TextSize.Small, styles.amountText13),
conditionalStyle(textSize === TextSize.Regular, styles.amountText15),
conditionalStyle(isPositive, styles.positiveAmountText, styles.destructiveAmountText)
]}
>
{isPositive ? '+' : '-'}
{shortizeSymbol(symbol)} and {nonZeroAmounts.length - 1} others
</Text>
);
return (
<Text
style={[
styles.amountWeight,
styles.positiveAmountText,
conditionalStyle(textSize === TextSize.Small, styles.amountText13),
conditionalStyle(textSize === TextSize.Regular, styles.amountText15)
]}
>
+{shortizeSymbol(symbol)} and {positiveAmounts.length - 1} others
</Text>
);
}
}, [nonZeroAmounts, textSize]);

return <View style={styles.container}>{children}</View>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,11 @@ const ApproveDetails: FC<{ address: string; symbol: string; hash: string }> = me
<View style={[styles.itemWrapper, styles.border]}>
<Text style={styles.text}>To:</Text>

<WalletAddress isLocalDomainNameShowing publicKeyHash={address} />
<View style={commonStyles.row}>
<WalletAddress isLocalDomainNameShowing publicKeyHash={address} />
<Divider size={formatSize(4)} />
<ExternalLinkButton url={tzktUrl(selectedRpcUrl, address)} testID={ActivityGroupItemSelectors.externalLink} />
</View>
</View>

<View style={styles.itemWrapper}>
Expand Down Expand Up @@ -138,8 +142,11 @@ const RevokeDetails: FC<{ address: string; symbol: string; hash: string }> = mem

<View style={[styles.itemWrapper, styles.border]}>
<Text style={styles.text}>From:</Text>

<WalletAddress isLocalDomainNameShowing publicKeyHash={address} />
<View style={commonStyles.row}>
<WalletAddress isLocalDomainNameShowing publicKeyHash={address} />
<Divider size={formatSize(4)} />
<ExternalLinkButton url={tzktUrl(selectedRpcUrl, address)} testID={ActivityGroupItemSelectors.externalLink} />
</View>
</View>

<View style={styles.itemWrapper}>
Expand Down
2 changes: 0 additions & 2 deletions src/utils/activity.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import { isDefined } from './is-defined';

export const isSingleTokenOperation = (amounts: Array<ActivityAmount>) => amounts.length === 1;

export const isDoubleTokenOperation = (amounts: Array<ActivityAmount>) => amounts.length === 2;

const ZERO = new BigNumber(0);

export const calculateDollarValue = (amounts: Array<ActivityAmount>) =>
Expand Down
3 changes: 2 additions & 1 deletion src/utils/token-operations.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ export const loadActivity = async (
return { activities: [], reachedTheEnd };
}

const oldestOperationNew = operationGroups[operationGroups.length - 1]?.[0];
const lastGroup = operationGroups[operationGroups.length - 1];
const oldestOperationNew = lastGroup[lastGroup.length - 1];

const activities = operationGroups
.map(group => parseOperations(group, selectedAccount.publicKeyHash, knownBakers))
Expand Down