Skip to content

Commit 3ba032e

Browse files
Simulation fixes (#5194)
* Use simulation fetch config * Update green/red colors * Add Moti * Clean up routes, use signTransactionSheetConfig on iOS * UI cleanup, state fixes, make cards expandable * Trim trailing zeros from simulation amounts * Fix GasSpeedButton jank * Block signing sheet dismiss gestures * Revert "Update green/red colors" This reverts commit 50ee10d. * Fixed: Update green/red colors * Fix button shadows * Fix display nonce * Remove unused code * Fix type * Upgrade reanimated to fix crash * Cleanup * Fix type errors from reanimated upgrade * lint * Fix Android scrolling * Revert "lint" This reverts commit 94fbd40. * Revert "Fix type errors from reanimated upgrade" This reverts commit 8cf75da. * Revert "Upgrade reanimated to fix crash" This reverts commit 22d1b0b. * Prevent crash without upgrading reanimated Moving the reanimated upgrade to another PR * Fix zIndex * Android fixes --------- Co-authored-by: Christian Baroni <[email protected]> Co-authored-by: Ben Goldberg <[email protected]>
1 parent 8a1a0ad commit 3ba032e

File tree

18 files changed

+1588
-851
lines changed

18 files changed

+1588
-851
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@
189189
"make-color-more-chill": "0.2.2",
190190
"match-sorter": "6.3.0",
191191
"mnemonist": "0.38.1",
192+
"moti": "0.27.2",
192193
"multiformats": "9.6.2",
193194
"nanoid": "3.2.0",
194195
"p-queue": "7.2.0",

src/components/asset-list/RecyclerAssetList2/profile-header/ProfileActionButtonsRow.tsx

-5
Original file line numberDiff line numberDiff line change
@@ -273,11 +273,6 @@ export function MoreButton() {
273273
Clipboard.setString(accountAddress);
274274
}, [accountAddress, isToastActive, setToastActive]);
275275

276-
const { navigate } = useNavigation();
277-
const navigateToSigningSheet = React.useCallback(() => {
278-
navigate(Routes.SIGN_TRANSACTION_SHEET);
279-
}, [navigate]);
280-
281276
return (
282277
<>
283278
{/* @ts-expect-error JavaScript component */}

src/components/coin-icon/ChainImage.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@ import ZoraBadge from '../../assets/badges/zora.png';
1414
import { ImgixImage } from '../images';
1515

1616
export function ChainImage({
17-
borderRadius = 20,
1817
chain,
1918
size = 20,
2019
}: {
21-
borderRadius?: number;
2220
chain: Network | null | undefined;
2321
size?: number;
2422
}) {
@@ -48,7 +46,7 @@ export function ChainImage({
4846
<ImgixImage
4947
size={size}
5048
source={source}
51-
style={{ borderRadius, height: size, width: size }}
49+
style={{ borderRadius: size / 2, height: size, width: size }}
5250
/>
5351
);
5452
}

src/components/contacts/ContactAvatar.js

+17-8
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ import ShadowStack from '@/react-native-shadow-stack';
1010
import { IS_ANDROID } from '@/env';
1111

1212
const buildShadows = (color, size, darkMode, colors) => {
13-
// TODO: remove `legacySmall` size once rainbow home screen revamp is released
14-
if (size === 'small' || size === 'legacySmall') {
13+
if (size === 'small') {
1514
return [
1615
[0, 3, 5, colors.shadow, 0.14],
1716
[
@@ -46,6 +45,17 @@ const buildShadows = (color, size, darkMode, colors) => {
4645
0.4,
4746
],
4847
];
48+
} else if (size === 'signing') {
49+
return [
50+
[
51+
0,
52+
4,
53+
12,
54+
darkMode ? colors.shadow : colors.avatarBackgrounds[color] || color,
55+
darkMode ? 0.16 : 0.2,
56+
],
57+
[0, 2, 6, colors.trueBlack, 0.02],
58+
];
4959
} else {
5060
return sizeConfigs(colors)[size]['shadow'];
5161
}
@@ -84,6 +94,10 @@ const sizeConfigs = colors => ({
8494
],
8595
textSize: 'larger',
8696
},
97+
signing: {
98+
dimensions: 44,
99+
textSize: 25,
100+
},
87101
small: {
88102
dimensions: 36,
89103
textSize: 'large',
@@ -93,11 +107,6 @@ const sizeConfigs = colors => ({
93107
textSize: 'large',
94108
shadow: [[0, 0, 0, colors.shadow, 0]],
95109
},
96-
// TODO: remove `legacySmall` size once rainbow home screen revamp is released
97-
legacySmall: {
98-
dimensions: 34,
99-
textSize: 'large',
100-
},
101110
smaller: {
102111
dimensions: 20,
103112
textSize: 'micro',
@@ -135,7 +144,7 @@ const ContactAvatar = ({ color, size = 'medium', value, ...props }) => {
135144
typeof color === 'number'
136145
? // sometimes the color is gonna be missing so we fallback to white
137146
// otherwise there will be only shadows without the the placeholder "circle"
138-
colors.avatarBackgrounds[color] ?? 'white'
147+
colors.avatarBackgrounds[color] ?? colors.white
139148
: color;
140149

141150
return (

src/components/contacts/ImageAvatar.js

+19-11
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ import styled from '@/styled-thing';
55
import { borders } from '@/styles';
66
import ShadowStack from '@/react-native-shadow-stack';
77
import { IS_ANDROID } from '@/env';
8+
import { useAccountAccentColor } from '@/hooks';
89

910
const buildSmallShadows = (color, colors) => [
1011
[0, 3, 5, colors.shadow, 0.14],
1112
[0, 6, 10, colors.avatarBackgrounds[color] || color, 0.2],
1213
];
1314

14-
const sizeConfigs = (colors, isDarkMode) => ({
15+
const sizeConfigs = (accentColor, colors, isDarkMode) => ({
1516
header: {
1617
dimensions: 34,
1718
textSize: 'large',
@@ -32,19 +33,25 @@ const sizeConfigs = (colors, isDarkMode) => ({
3233
],
3334
textSize: 28,
3435
},
35-
sim: {
36-
dimensions: 44,
37-
shadow: [
38-
[0, 4, 6, colors.shadow, 0.04],
39-
[0, 1, 3, colors.shadow, 0.08],
40-
],
41-
textSize: 'larger',
42-
},
4336
medium: {
4437
dimensions: 40,
4538
shadow: [[0, 4, 12, colors.shadow, isDarkMode ? 0.3 : 0.15]],
4639
textSize: 'larger',
4740
},
41+
signing: {
42+
dimensions: 44,
43+
shadow: [
44+
[
45+
0,
46+
4,
47+
12,
48+
!isDarkMode && accentColor ? accentColor : colors.shadow,
49+
isDarkMode ? 0.16 : 0.2,
50+
],
51+
[0, 2, 6, colors.trueBlack, 0.02],
52+
],
53+
textSize: 25,
54+
},
4855
small: {
4956
dimensions: 30,
5057
shadow: [[0, 3, 9, colors.shadow, 0.1]],
@@ -87,10 +94,11 @@ const ImageAvatar = ({
8794
onLoad = undefined,
8895
...props
8996
}) => {
97+
const { accentColor } = useAccountAccentColor();
9098
const { colors, isDarkMode } = useTheme();
9199
const { dimensions, shadow } = useMemo(
92-
() => sizeConfigs(colors, isDarkMode)[size],
93-
[colors, isDarkMode, size]
100+
() => sizeConfigs(accentColor, colors, isDarkMode)[size],
101+
[accentColor, colors, isDarkMode, size]
94102
);
95103

96104
const shadows = useMemo(

src/components/gas/GasSpeedButton.js

+36-14
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ import AnimateNumber from '@bankify/react-native-animate-number';
44
import lang from 'i18n-js';
55
import { isEmpty, isNaN, isNil, upperFirst } from 'lodash';
66
import makeColorMoreChill from 'make-color-more-chill';
7+
import { AnimatePresence, MotiView } from 'moti';
78
import React, { useCallback, useEffect, useMemo, useState } from 'react';
89
import { InteractionManager, Keyboard } from 'react-native';
10+
import { Easing } from 'react-native-reanimated';
911
import { darkModeThemeColors } from '../../styles/colors';
1012
import { ButtonPressAnimation } from '../animations';
1113
import { ChainBadge, CoinIcon } from '../coin-icon';
@@ -95,7 +97,13 @@ const ChainBadgeContainer = styled.View.attrs({
9597
...margin.object(0),
9698
});
9799

98-
const NativeCoinIconWrapper = styled(Column)(margin.object(1.5, 5, 0, 0));
100+
const NativeCoinIconWrapper = styled(Column).attrs({})({
101+
...margin.object(1, 5, 0, 0),
102+
alignItems: 'center',
103+
height: 18,
104+
justifyContent: 'center',
105+
width: 18,
106+
});
99107

100108
const Container = styled(Column).attrs({
101109
alignItems: 'center',
@@ -591,19 +599,33 @@ const GasSpeedButton = ({
591599
>
592600
<Row>
593601
<NativeCoinIconWrapper>
594-
{currentNetwork === Network.mainnet ? (
595-
<CoinIcon
596-
address={nativeFeeCurrency.address}
597-
size={18}
598-
symbol={nativeFeeCurrency.symbol}
599-
/>
600-
) : (
601-
<ChainBadge
602-
assetType={currentNetwork}
603-
size="gas"
604-
position="relative"
605-
/>
606-
)}
602+
<AnimatePresence>
603+
{!!currentNetwork && (
604+
<MotiView
605+
animate={{ opacity: 1 }}
606+
from={{ opacity: 0 }}
607+
transition={{
608+
duration: 300,
609+
easing: Easing.bezier(0.2, 0, 0, 1),
610+
type: 'timing',
611+
}}
612+
>
613+
{currentNetwork === Network.mainnet ? (
614+
<CoinIcon
615+
address={nativeFeeCurrency.address}
616+
size={18}
617+
symbol={nativeFeeCurrency.symbol}
618+
/>
619+
) : (
620+
<ChainBadge
621+
assetType={currentNetwork}
622+
size="gas"
623+
position="relative"
624+
/>
625+
)}
626+
</MotiView>
627+
)}
628+
</AnimatePresence>
607629
</NativeCoinIconWrapper>
608630
<TextContainer>
609631
<Text>

src/components/sheet/sheet-action-buttons/SheetActionButton.tsx

+9-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ type Props = PropsWithChildren<{
2424
label?: string;
2525
lightShadows?: boolean;
2626
marginBottom?: number;
27+
newShadows?: boolean;
2728
nftShadows?: boolean;
2829
onPress?: () => void;
2930
scaleTo?: number;
@@ -89,6 +90,7 @@ const SheetActionButton: React.FC<Props> = ({
8990
label = null,
9091
lightShadows,
9192
onPress,
93+
newShadows,
9294
nftShadows,
9395
scaleTo = 0.9,
9496
size = null,
@@ -105,7 +107,12 @@ const SheetActionButton: React.FC<Props> = ({
105107
const isWhite = color === colors.white;
106108
const textColor = givenTextColor || colors.whiteLabel;
107109
const shadowsForButtonColor = useMemo(() => {
108-
if (nftShadows) {
110+
if (newShadows) {
111+
return [
112+
[0, 2, 6, colors.trueBlack, 0.02],
113+
[0, 10, 30, isDarkMode ? colors.shadow : color, 0.4],
114+
];
115+
} else if (nftShadows) {
109116
return [[0, 10, 30, colors.alpha(colors.shadowBlack, 0.3)]];
110117
} else if (!forceShadows && (disabled || isTransparent)) {
111118
return [[0, 0, 0, colors.transparent, 0]];
@@ -128,6 +135,7 @@ const SheetActionButton: React.FC<Props> = ({
128135
isTransparent,
129136
isDarkMode,
130137
lightShadows,
138+
newShadows,
131139
nftShadows,
132140
isWhite,
133141
]);

src/graphql/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const metadataClient = getMetadataSdk(
1010
getFetchRequester(config.metadata)
1111
);
1212
export const simulationClient = getMetadataSdk(
13-
getFetchRequester(config.metadata)
13+
getFetchRequester(config.simulation)
1414
);
1515
export const arcClient = getArcSdk(getFetchRequester(config.arc));
1616
export const arcDevClient = getArcDevSdk(getFetchRequester(config.arcDev));

src/helpers/utilities.ts

+14-4
Original file line numberDiff line numberDiff line change
@@ -374,14 +374,20 @@ export const convertRawAmountToNativeDisplay = (
374374
export const convertRawAmountToBalance = (
375375
value: BigNumberish,
376376
asset: { decimals: number; symbol?: string },
377-
buffer?: number
377+
buffer?: number,
378+
trimTrailingZeros?: boolean
378379
) => {
379380
const decimals = asset?.decimals ?? 18;
380381
const assetBalance = convertRawAmountToDecimalFormat(value, decimals);
381382

382383
return {
383384
amount: assetBalance,
384-
display: convertAmountToBalanceDisplay(assetBalance, asset, buffer),
385+
display: convertAmountToBalanceDisplay(
386+
assetBalance,
387+
asset,
388+
buffer,
389+
trimTrailingZeros
390+
),
385391
};
386392
};
387393

@@ -391,11 +397,15 @@ export const convertRawAmountToBalance = (
391397
export const convertAmountToBalanceDisplay = (
392398
value: BigNumberish,
393399
asset: { decimals: number; symbol?: string },
394-
buffer?: number
400+
buffer?: number,
401+
trimTrailingZeros?: boolean
395402
) => {
396403
const decimals = asset?.decimals ?? 18;
397404
const display = handleSignificantDecimals(value, decimals, buffer);
398-
return `${display} ${asset?.symbol || ''}`;
405+
const formattedDisplay = trimTrailingZeros
406+
? display.replace(/\.?0+$/, '')
407+
: display;
408+
return `${formattedDisplay} ${asset?.symbol || ''}`;
399409
};
400410

401411
/**

src/languages/en_US.json

+11-1
Original file line numberDiff line numberDiff line change
@@ -2363,7 +2363,8 @@
23632363
"types": {
23642364
"chain": "Network",
23652365
"contract": "Contract",
2366-
"contract_created": "Contact Created",
2366+
"contract_created": "Contract Created",
2367+
"to": "To",
23672368
"function": "Function",
23682369
"source_code": "Source Code",
23692370
"nonce": "Nonce"
@@ -2385,6 +2386,15 @@
23852386
"confirm": "􀎽 Confirm",
23862387
"get_native_token": "Get %{symbol}",
23872388
"buy_native_token": "Buy %{symbol}"
2389+
},
2390+
"formatted_dates": {
2391+
"today": "Today",
2392+
"day_ago": "day ago",
2393+
"days_ago": "days ago",
2394+
"week_ago": "week ago",
2395+
"weeks_ago": "weeks ago",
2396+
"month_ago": "month ago",
2397+
"months_ago": "months ago"
23882398
}
23892399
}
23902400
},

src/navigation/Routes.android.tsx

-4
Original file line numberDiff line numberDiff line change
@@ -387,10 +387,6 @@ function BSNavigator() {
387387
name={Routes.CONFIRM_REQUEST}
388388
options={walletconnectBottomSheetPreset}
389389
/>
390-
<BSStack.Screen
391-
name={Routes.SIGN_TRANSACTION_SHEET}
392-
component={SignTransactionSheet}
393-
/>
394390
</BSStack.Navigator>
395391
);
396392
}

src/navigation/Routes.ios.tsx

+1-14
Original file line numberDiff line numberDiff line change
@@ -330,15 +330,7 @@ function NativeStackNavigator() {
330330
<NativeStack.Screen
331331
component={SignTransactionSheet}
332332
name={Routes.CONFIRM_REQUEST}
333-
options={{
334-
allowsDragToDismiss: false,
335-
allowsTapToDismiss: false,
336-
backgroundOpacity: 1,
337-
customStack: true,
338-
headerHeight: 0,
339-
isShortFormEnabled: false,
340-
topOffset: 0,
341-
}}
333+
{...signTransactionSheetConfig}
342334
/>
343335
<NativeStack.Screen
344336
component={ExpandedAssetSheet}
@@ -424,11 +416,6 @@ function NativeStackNavigator() {
424416
component={SendFlowNavigator}
425417
name={Routes.SEND_SHEET_NAVIGATOR}
426418
/>
427-
<NativeStack.Screen
428-
component={SignTransactionSheet}
429-
name={Routes.SIGN_TRANSACTION_SHEET}
430-
{...signTransactionSheetConfig}
431-
/>
432419
<NativeStack.Screen
433420
component={WalletConnectApprovalSheet}
434421
name={Routes.WALLET_CONNECT_APPROVAL_SHEET}

src/navigation/config.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ export const signTransactionSheetConfig = {
204204
backgroundOpacity: 1,
205205
cornerRadius: 0,
206206
springDamping: 1,
207+
topOffset: 0,
207208
transitionDuration: 0.3,
208209
}),
209210
}),

0 commit comments

Comments
 (0)