Skip to content

Commit 40bf9de

Browse files
authored
Merge eaccab7 into 65e1902
2 parents 65e1902 + eaccab7 commit 40bf9de

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1970
-233
lines changed

e2e/flows/transactions/SendNft.yaml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,23 @@ tags:
8585
- longPressOn: 'Hold to Send'
8686
- runFlow: ../../utils/MaybeSetupPin.yaml
8787

88-
# Test transaction was done
89-
- assertVisible: 'Pending'
90-
- assertVisible: 'Sending.*'
91-
92-
- tapOn: Sending.*
93-
88+
# Check toast data
89+
- assertVisible:
90+
text: 'Sending'
91+
childOf:
92+
id: toast-.*
93+
- assertVisible:
94+
text: 'Rainbow Pooly 104'
95+
childOf:
96+
id: toast-.*
97+
# Open toast
98+
- tapOn:
99+
id: toast-.*
100+
- assertVisible: 'Sending'
101+
- assertVisible: 'Rainbow Pooly'
102+
- tapOn:
103+
id: toast-expanded-.*
104+
# Check transaction sheet
94105
- assertVisible: 'Sending'
95106
- assertVisible: '.*Tx Hash.*'
96107
- assertVisible: 'View on Etherscan'

e2e/flows/transactions/SendTransaction.yaml

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ tags:
5151
commands:
5252
- tapOn:
5353
id: send-asset
54-
54+
- tapOn:
55+
id: selected-asset-field-input
5556
- inputText: '0.01'
5657

5758
- retry:
@@ -62,7 +63,7 @@ tags:
6263

6364
# Test enter amount
6465
- assertVisible: 'Sending'
65-
- assertVisible: '$0.01'
66+
- assertVisible: '0.01 ETH'
6667
- assertVisible: 'rainbowwallet.eth'
6768

6869
# iOS is 'Hold to Send' button is stuck on 'Loading...'
@@ -74,12 +75,30 @@ tags:
7475
- longPressOn: 'Hold to Send'
7576
- runFlow: ../../utils/MaybeSetupPin.yaml
7677

77-
# Test transaction was done
78-
- assertVisible: 'Pending'
79-
- assertVisible: 'Sending*.'
80-
81-
- tapOn: Sending*.
82-
78+
# Check toast data
79+
- assertVisible:
80+
text: 'Sending'
81+
childOf:
82+
id: toast-.*
83+
- assertVisible:
84+
text: '0.01 ETH'
85+
childOf:
86+
id: toast-.*
87+
# Open toast
88+
- tapOn:
89+
id: toast-.*
90+
# Check expended toast data
91+
- assertVisible:
92+
text: 'Sending'
93+
childOf:
94+
id: toast-expanded-.*
95+
- assertVisible:
96+
text: '0.01 ETH'
97+
childOf:
98+
id: toast-expanded-.*
99+
- tapOn:
100+
id: toast-expanded-.*
101+
# Check transaction sheet
83102
- assertVisible: 'Sending'
84103
- assertVisible: '.*Tx Hash*.'
85104
- assertVisible: 'View on Etherscan'

src/App.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import { AbsolutePortalRoot } from './components/AbsolutePortal';
4040
import { PerformanceProfiler } from '@shopify/react-native-performance';
4141
import { PerformanceReports, PerformanceReportSegments, PerformanceTracking } from './performance/tracking';
4242
import { TestDeeplinkHandler } from './components/TestDeeplinkHandler';
43+
import { RainbowToastDisplay } from '@/components/rainbow-toast/RainbowToast';
4344

4445
if (IS_DEV) {
4546
reactNativeDisableYellowBox && LogBox.ignoreAllLogs();
@@ -127,6 +128,7 @@ function Root() {
127128
<SharedValuesProvider>
128129
<ErrorBoundary>
129130
<App />
131+
<RainbowToastDisplay />
130132
</ErrorBoundary>
131133
</SharedValuesProvider>
132134
</RainbowContextWrapper>

src/components/activity-list/ActivityList.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,13 @@ export const ActivityList = ({ scrollY, paddingTopForNavBar }: Props) => {
100100
items.push({ key: 'paddingTopForNavBar', type: 'paddingTopForNavBar' });
101101
}
102102

103-
sections.forEach(section => {
103+
sections.forEach((section, sectionIndex) => {
104104
if (section.data.length > 0) {
105105
items.push({ key: `${accountAddress}${section.title}`, type: 'header', value: section });
106106
for (const item of section.data) {
107+
const key = `${item.chainId}${'requestId' in item ? item.requestId : item.hash}`;
107108
items.push({
108-
key: `${accountAddress}${item.chainId}${'requestId' in item ? item.requestId : item.hash}-entry`,
109+
key: `${sectionIndex}-${accountAddress}-${key}-entry`,
109110
type: section.type,
110111
value: item,
111112
});

src/components/cards/remote-cards/RemoteCardCarousel.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import React, { useRef } from 'react';
44
import { CarouselCard } from '../CarouselCard';
55

66
import { RemoteCard } from '@/components/cards/remote-cards';
7-
import { REMOTE_CARDS, getExperimetalFlag } from '@/config';
7+
import { REMOTE_CARDS, getExperimentalFlag } from '@/config';
88
import { Separator, useColorMode } from '@/design-system';
99
import { useDimensions } from '@/hooks';
1010
import { useRemoteConfig } from '@/model/remoteConfig';
@@ -33,7 +33,7 @@ export const RemoteCardCarousel = React.memo(function RemoteCardCarousel() {
3333
const config = useRemoteConfig();
3434
const { width } = useDimensions();
3535

36-
const remoteCardsEnabled = getExperimetalFlag(REMOTE_CARDS) || config.remote_cards_enabled;
36+
const remoteCardsEnabled = getExperimentalFlag(REMOTE_CARDS) || config.remote_cards_enabled;
3737
const cardIds = remoteCardsStore(state => state.getCardIdsForScreen(name as keyof typeof Routes));
3838

3939
const gutterSize = getGutterSizeForCardAmount(cardIds.length);

src/components/coin-row/FastTransactionCoinRow.tsx

Lines changed: 6 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -11,95 +11,14 @@ import { ImgixImage } from '../images';
1111
import { CardSize } from '../unique-token/CardSize';
1212
import { ChainId } from '@/state/backendNetworks/types';
1313
import { address } from '@/utils/abbreviations';
14-
import {
15-
convertAmountAndPriceToNativeDisplay,
16-
convertAmountToBalanceDisplay,
17-
convertRawAmountToBalance,
18-
convertRawAmountToDecimalFormat,
19-
greaterThan,
20-
handleSignificantDecimals,
21-
} from '@/helpers/utilities';
2214
import { TwoCoinsIcon } from '../coin-icon/TwoCoinsIcon';
2315
import Spinner from '../Spinner';
24-
import * as lang from '@/languages';
16+
2517
import RainbowCoinIcon from '@/components/coin-icon/RainbowCoinIcon';
26-
import { checkForPendingSwap } from '@/helpers/checkForPendingSwap';
2718
import { ChainImage } from '../coin-icon/ChainImage';
2819
import { useSuperTokenStore } from '@/screens/token-launcher/state/rainbowSuperTokenStore';
20+
import { activityValues, useTransactionLaunchToken } from '@/helpers/transactions';
2921

30-
export const getApprovalLabel = ({ approvalAmount, asset, type }: Pick<RainbowTransaction, 'type' | 'asset' | 'approvalAmount'>) => {
31-
if (!approvalAmount || !asset) return;
32-
if (approvalAmount === 'UNLIMITED') return lang.t(lang.l.transactions.approvals.unlimited);
33-
if (type === 'revoke') return lang.t(lang.l.transactions.approvals.no_allowance);
34-
const amountDisplay = convertRawAmountToBalance(
35-
approvalAmount,
36-
{ decimals: asset?.decimals, symbol: asset?.symbol },
37-
undefined,
38-
true
39-
)?.display;
40-
return amountDisplay || '';
41-
};
42-
43-
const approvalTypeValues = (transaction: RainbowTransaction) => {
44-
const { asset, approvalAmount } = transaction;
45-
46-
if (!asset || !approvalAmount) return;
47-
transaction.protocol;
48-
return [transaction.protocol || '', getApprovalLabel(transaction)];
49-
};
50-
51-
const swapTypeValues = (changes: RainbowTransaction['changes'], status: RainbowTransaction['status']) => {
52-
const tokenIn = changes?.filter(c => c?.direction === 'in')[0];
53-
const tokenOut = changes?.filter(c => c?.direction === 'out')[0];
54-
55-
// NOTE: For pending txns let's use the change values instead of
56-
// the transaction balance change since that hasn't happened yet
57-
if (status === TransactionStatus.pending) {
58-
const decimalsOut = typeof tokenOut?.asset.decimals === 'number' ? tokenOut.asset.decimals : 18;
59-
const decimalsIn = typeof tokenIn?.asset.decimals === 'number' ? tokenIn.asset.decimals : 18;
60-
61-
const valueOut = `${handleSignificantDecimals(convertRawAmountToDecimalFormat(tokenOut?.value?.toString() || '0', decimalsOut), decimalsOut)} ${tokenOut?.asset.symbol}`;
62-
const valueIn = `+${handleSignificantDecimals(convertRawAmountToDecimalFormat(tokenIn?.value?.toString() || '0', decimalsIn), decimalsIn)} ${tokenIn?.asset.symbol}`;
63-
64-
return [valueOut, valueIn];
65-
}
66-
67-
if (!tokenIn?.asset.balance?.amount || !tokenOut?.asset.balance?.amount) return;
68-
69-
const valueOut = `${convertAmountToBalanceDisplay(tokenOut?.asset.balance?.amount, { ...tokenOut?.asset })}`;
70-
const valueIn = `+${convertAmountToBalanceDisplay(tokenIn?.asset.balance?.amount, { ...tokenIn?.asset })}`;
71-
72-
return [valueOut, valueIn];
73-
};
74-
75-
const activityValues = (transaction: RainbowTransaction, nativeCurrency: NativeCurrencyKey) => {
76-
const { changes, direction, type, status } = transaction;
77-
if (checkForPendingSwap(transaction)) return swapTypeValues(changes, status);
78-
if (['approve', 'revoke'].includes(type)) return approvalTypeValues(transaction as RainbowTransaction);
79-
80-
const change = changes?.filter(c => c?.direction === direction && c?.asset.type !== 'nft')[0];
81-
let valueSymbol = direction === 'out' ? '-' : '+';
82-
83-
if (type === 'send') {
84-
valueSymbol = '-';
85-
}
86-
if (type === 'receive') {
87-
valueSymbol = '+';
88-
}
89-
90-
if (!change?.asset) return;
91-
92-
const { balance } = change.asset;
93-
94-
const assetValue = convertAmountToBalanceDisplay(balance?.amount || '0', change.asset);
95-
96-
const nativeBalance = convertAmountAndPriceToNativeDisplay(balance?.amount || '0', change.asset.price?.value || '0', nativeCurrency);
97-
const assetNativeValue = greaterThan(nativeBalance.amount, '0')
98-
? `${valueSymbol}${nativeBalance?.display}`
99-
: lang.t(lang.l.transactions.no_value);
100-
101-
return greaterThan(nativeBalance.amount, '0') ? [`${assetValue}`, assetNativeValue] : [assetNativeValue, `${valueSymbol}${assetValue}`];
102-
};
10322
const getIconTopMargin = (type: TransactionType) => {
10423
switch (type) {
10524
case 'swap':
@@ -137,6 +56,7 @@ const activityTypeIcon: Record<TransactionType, string> = {
13756
claim: '􀄩',
13857
borrow: '􀄩',
13958
deployment: '􀄩',
59+
launch: '􀓎',
14060
};
14161

14262
export const ActivityTypeIcon = ({
@@ -177,12 +97,7 @@ const BottomRow = React.memo(function BottomRow({
17797
nativeCurrency: NativeCurrencyKey;
17898
theme: ThemeContextProps;
17999
}) {
180-
const rainbowSuperToken = useMemo(() => {
181-
if (transaction?.type === 'launch') {
182-
return useSuperTokenStore.getState().getSuperTokenByTransactionHash(transaction.hash);
183-
}
184-
return undefined;
185-
}, [transaction.hash, transaction.type]);
100+
const launchToken = useTransactionLaunchToken(transaction);
186101

187102
const { type, to, asset } = transaction;
188103
const separatorSecondary = useForegroundColor('separatorSecondary');
@@ -194,8 +109,8 @@ const BottomRow = React.memo(function BottomRow({
194109
tag = transaction.description;
195110
}
196111

197-
if (type === 'launch' && rainbowSuperToken) {
198-
description = rainbowSuperToken?.name;
112+
if (type === 'launch' && launchToken) {
113+
description = launchToken?.name;
199114
}
200115

201116
if (transaction?.type === 'mint') {

0 commit comments

Comments
 (0)