Skip to content

Commit ae22219

Browse files
authored
fix(transfer): activity for transfer to savings boosts (#2421)
1 parent 94798cc commit ae22219

File tree

5 files changed

+14
-30
lines changed

5 files changed

+14
-30
lines changed

src/screens/Activity/ListItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ const OnchainListItem = ({
117117
if (transfer) {
118118
title = t('activity_transfer');
119119
icon = (
120-
<ThemedView style={styles.icon} color="brand16">
120+
<ThemedView style={styles.icon} color="brand16" testID="TransferIcon">
121121
<TransferIcon color="brand" />
122122
</ThemedView>
123123
);

src/screens/Wallets/index.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { RefreshControl, ScrollView } from 'react-native-gesture-handler';
55
import { useSafeAreaInsets } from 'react-native-safe-area-context';
66
import { useTranslation } from 'react-i18next';
77

8+
import { View as ThemedView } from '../../styles/components';
89
import { useBalance } from '../../hooks/wallet';
910
import useColors from '../../hooks/colors';
1011
import { useAppDispatch, useAppSelector } from '../../hooks/redux';
@@ -107,7 +108,7 @@ const Wallets = ({ navigation, onFocus }: Props): ReactElement => {
107108
Object.keys(widgets).length > 0;
108109

109110
return (
110-
<>
111+
<ThemedView style={styles.root}>
111112
<SafeAreaInset type="top" />
112113
<View style={[styles.header, { top: insets.top }]}>
113114
<Header />
@@ -154,11 +155,14 @@ const Wallets = ({ navigation, onFocus }: Props): ReactElement => {
154155
)}
155156
</ScrollView>
156157
</DetectSwipe>
157-
</>
158+
</ThemedView>
158159
);
159160
};
160161

161162
const styles = StyleSheet.create({
163+
root: {
164+
flex: 1,
165+
},
162166
header: {
163167
position: 'absolute',
164168
left: 0,

src/store/utils/activity.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export const updateOnChainActivityList = async (): Promise<Result<string>> => {
9797

9898
const transactions = currentWallet.transactions[selectedNetwork];
9999
const promises = Object.values(transactions).map(async (tx) => {
100-
return await onChainTransactionToActivityItem({ transaction: tx });
100+
return onChainTransactionToActivityItem({ transaction: tx });
101101
});
102102
const activityItems = await Promise.all(promises);
103103

src/utils/activity/index.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,11 @@ export const onChainTransactionToActivityItem = async ({
2121
}: {
2222
transaction: IFormattedTransaction;
2323
}): Promise<TOnchainActivityItem> => {
24+
const { type, value, fee } = transaction;
2425
const transfer = await getTransferForTx(transaction);
2526

2627
// subtract fee from amount if applicable
27-
const amount =
28-
transaction.type === 'sent'
29-
? transaction.value + transaction.fee
30-
: transaction.value;
28+
const amount = type === 'sent' ? value + fee : value;
3129

3230
return {
3331
id: transaction.txid,

src/utils/boost.ts

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { IBoostedTransactions, Wallet as TWallet } from 'beignet';
22

3-
import { getActivityStore, getWalletStore } from '../store/helpers';
4-
import { IActivityItem, TOnchainActivityItem } from '../store/types/activity';
3+
import { getWalletStore } from '../store/helpers';
4+
import { TOnchainActivityItem } from '../store/types/activity';
55
import { TWalletName } from '../store/types/wallet';
66
import { EAvailableNetwork } from './networks';
77
import {
@@ -85,26 +85,6 @@ const getRootParentActivity = async ({
8585
return filteredItem;
8686
};
8787

88-
/**
89-
* Returns an array of activity items for the provided array of parent txids.
90-
* CURRENTLY UNUSED
91-
* // TODO: Migrate to Beignet
92-
* @param {string[]} [parents]
93-
* @param {IActivityItem[]} [items]
94-
*/
95-
export const getParentsActivity = ({
96-
parents = [],
97-
items = [],
98-
}: {
99-
parents?: string[];
100-
items?: IActivityItem[];
101-
}): IActivityItem[] => {
102-
if (!items) {
103-
items = getActivityStore().items;
104-
}
105-
return items.filter((i) => parents.includes(i.id));
106-
};
107-
10888
/**
10989
* Loop through activity items and format them to be displayed as boosted if applicable.
11090
* @param {TOnchainActivityItem[]} [items]
@@ -172,6 +152,8 @@ export const formatBoostedActivityItems = async ({
172152
fee: rootParent.fee + item.fee,
173153
address: rootParent.address,
174154
isBoosted: true,
155+
isTransfer: rootParent.isTransfer,
156+
transferTxId: rootParent.transferTxId,
175157
});
176158
}
177159

0 commit comments

Comments
 (0)