Skip to content

Commit 0b50ec5

Browse files
committed
Merge branch 'release/7.62.0' into chore/build/7.62.91
2 parents 0ffd517 + 3318ef9 commit 0b50ec5

23 files changed

Lines changed: 292 additions & 173 deletions

android/app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,8 @@ android {
187187
applicationId "io.metamask"
188188
minSdkVersion rootProject.ext.minSdkVersion
189189
targetSdkVersion rootProject.ext.targetSdkVersion
190-
versionName "7.62.90"
191-
versionCode 3497
190+
versionName "7.62.91"
191+
versionCode 3505
192192
testBuildType System.getProperty('testBuildType', 'debug')
193193
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
194194
manifestPlaceholders.MM_BRANCH_KEY_TEST = "$System.env.MM_BRANCH_KEY_TEST"

app/components/UI/AssetOverview/AssetOverview.test.tsx

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1891,7 +1891,7 @@ describe('getSwapTokens', () => {
18911891
});
18921892
});
18931893

1894-
it('returns default pair token as sourceToken and native gas token as destToken when asset is native gas token', () => {
1894+
it('returns native gas token as sourceToken when asset is native gas token from home page', () => {
18951895
const nativeGasToken = {
18961896
...asset,
18971897
address: '0x0000000000000000000000000000000000000000',
@@ -1900,18 +1900,8 @@ describe('getSwapTokens', () => {
19001900

19011901
const result = getSwapTokens(nativeGasToken);
19021902

1903-
// sourceToken is the default pair token for mainnet (mUSD)
1903+
// sourceToken is the native gas token (user wants to swap FROM it)
19041904
expect(result.sourceToken).toEqual({
1905-
symbol: 'mUSD',
1906-
name: 'MetaMask USD',
1907-
address: '0xaca92e438df0b2401ff60da7e4337b687a2435da',
1908-
decimals: 6,
1909-
image:
1910-
'https://static.cx.metamask.io/api/v2/tokenIcons/assets/eip155/1/erc20/0xaca92e438df0b2401ff60da7e4337b687a2435da.png',
1911-
chainId: MOCK_CHAIN_ID,
1912-
});
1913-
// destToken is the native gas token
1914-
expect(result.destToken).toEqual({
19151905
...nativeGasToken,
19161906
address: '0x0000000000000000000000000000000000000000',
19171907
chainId: MOCK_CHAIN_ID,
@@ -1920,5 +1910,25 @@ describe('getSwapTokens', () => {
19201910
name: nativeGasToken.name,
19211911
image: nativeGasToken.image,
19221912
});
1913+
// destToken is undefined (will be determined by swap UI)
1914+
expect(result.destToken).toBeUndefined();
1915+
});
1916+
1917+
it('returns native gas token as destToken when asset is native gas token from trending', () => {
1918+
const trendingNativeGasToken = {
1919+
...asset,
1920+
address: '0x0000000000000000000000000000000000000000',
1921+
isETH: true,
1922+
isFromTrending: true,
1923+
};
1924+
1925+
const result = getSwapTokens(trendingNativeGasToken);
1926+
1927+
// When coming from trending with native token, user wants to BUY it (dest position)
1928+
expect(result.destToken).toBeDefined();
1929+
expect(result.destToken?.address).toBe(
1930+
'0x0000000000000000000000000000000000000000',
1931+
);
1932+
expect(result.destToken?.symbol).toBe(trendingNativeGasToken.symbol);
19231933
});
19241934
});

app/components/UI/AssetOverview/AssetOverview.tsx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,10 @@ import { BridgeToken } from '../Bridge/types';
126126
/**
127127
* Determines the source and destination tokens for swap/bridge navigation.
128128
*
129-
* When the asset is a native gas token (e.g., ETH), we set sourceToken to the default
130-
* pair token for that chain (e.g., mUSD on mainnet) and destToken to the native token,
131-
* allowing the user to swap INTO the native token.
132-
*
133129
* When coming from the trending tokens list, the user likely wants to BUY the token,
134-
* so we configure the swap with the native token as source and the asset as destination.
130+
* so we configure the swap with the asset as destination:
131+
* - For native tokens (ETH, BNB, etc.): use default pair token as source
132+
* - For other tokens: use native token as source
135133
*
136134
* Otherwise, we assume they want to SELL, so the asset is the source.
137135
*
@@ -145,6 +143,7 @@ export const getSwapTokens = (
145143
destToken: BridgeToken | undefined;
146144
} => {
147145
const wantsToBuyToken = isAssetFromTrending(asset);
146+
const isNative = isNativeAddress(asset.address);
148147

149148
// Build bridge token from asset
150149
const bridgeToken: BridgeToken = {
@@ -157,22 +156,23 @@ export const getSwapTokens = (
157156
image: asset.image,
158157
};
159158

160-
// If the asset is a native gas token, set source to the default pair token for that chain
161-
// and dest to the native token, allowing the user to swap INTO the native token
162-
if (isNativeAddress(asset.address)) {
163-
return {
164-
sourceToken: getDefaultDestToken(bridgeToken.chainId),
165-
destToken: bridgeToken,
166-
};
167-
}
168-
159+
// Trending page: user wants to BUY the token (token as destination)
169160
if (wantsToBuyToken) {
161+
// For native tokens, use default pair token as source (e.g., mUSD for ETH)
162+
if (isNative) {
163+
return {
164+
sourceToken: getDefaultDestToken(bridgeToken.chainId),
165+
destToken: bridgeToken,
166+
};
167+
}
168+
// For non-native tokens, use native token as source
170169
return {
171170
sourceToken: getNativeSourceToken(bridgeToken.chainId),
172171
destToken: bridgeToken,
173172
};
174173
}
175174

175+
// Home page: user wants to SELL the token (token as source)
176176
return {
177177
sourceToken: bridgeToken,
178178
destToken: undefined,

app/components/UI/Predict/components/PredictActionButtons/PredictBetButton.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { Button, Text, TextColor } from '@metamask/design-system-react-native';
2+
import { Button, Text } from '@metamask/design-system-react-native';
33
import { useTailwind } from '@metamask/design-system-twrnc-preset';
44
import { useTheme } from '../../../../../util/theme';
55
import { PredictBetButtonProps } from './PredictActionButtons.types';
@@ -25,13 +25,11 @@ const PredictBetButton: React.FC<PredictBetButtonProps> = ({
2525
return variant === 'yes' ? colors.success.muted : colors.error.muted;
2626
};
2727

28-
const getTextColor = (): TextColor => {
28+
const getTextColor = (): string => {
2929
if (hasTeamColor) {
30-
return TextColor.TextDefault;
30+
return 'text-white';
3131
}
32-
return variant === 'yes'
33-
? TextColor.SuccessDefault
34-
: TextColor.ErrorDefault;
32+
return variant === 'yes' ? 'text-success-default' : 'text-error-default';
3533
};
3634

3735
return (
@@ -42,7 +40,7 @@ const PredictBetButton: React.FC<PredictBetButtonProps> = ({
4240
style={{ backgroundColor: getBackgroundColor() }}
4341
isFullWidth
4442
>
45-
<Text color={getTextColor()} style={tw.style('font-medium')}>
43+
<Text style={tw.style('font-medium ', getTextColor())}>
4644
{label.toUpperCase()} · {price}¢
4745
</Text>
4846
</Button>

app/components/UI/Predict/components/PredictGameChart/ChartTooltip.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ describe('ChartTooltip', () => {
118118
const textElements = getAllByTestId('svg-text');
119119
const textContents = textElements.map((el) => el.children[0]);
120120

121-
expect(textContents).toContain('Team A');
122-
expect(textContents).toContain('Team B');
121+
expect(textContents).toContain('TEAM A');
122+
expect(textContents).toContain('TEAM B');
123123
expect(textContents).toContain('55%');
124124
expect(textContents).toContain('45%');
125125
});

app/components/UI/Predict/components/PredictGameChart/ChartTooltip.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ const ChartTooltip: React.FC<ChartTooltipProps> = ({
134134
fontSize={FONT_SIZE_LABEL}
135135
fontWeight="500"
136136
>
137-
{pos.label}
137+
{pos.label.toUpperCase()}
138138
</SvgText>
139139
<SvgText
140140
x={labelStartX}

app/components/UI/Predict/components/PredictGameChart/EndpointDots.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ describe('EndpointDots', () => {
9191
const textElements = getAllByTestId('svg-text');
9292
const textContents = textElements.map((el) => el.children[0]);
9393

94-
expect(textContents).toContain('Team A');
95-
expect(textContents).toContain('Team B');
94+
expect(textContents).toContain('TEAM A');
95+
expect(textContents).toContain('TEAM B');
9696
});
9797

9898
it('renders values with percentage format', () => {

app/components/UI/Predict/components/PredictGameChart/EndpointDots.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ const EndpointDots: React.FC<EndpointDotsProps> = ({
8787
fontSize={FONT_SIZE_LABEL}
8888
fontWeight="500"
8989
>
90-
{pos.label}
90+
{pos.label.toUpperCase()}
9191
</SvgText>
9292
<SvgText
9393
x={labelX}

app/components/UI/Predict/components/PredictGameChart/PredictGameChart.constants.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ export const DOT_RADIUS = 6;
77
export const DOT_STROKE_WIDTH = 2;
88
export const GLOW_RADIUS = 16;
99
export const GLOW_OPACITY = 0.15;
10-
export const LABEL_OFFSET_X = 12;
11-
export const RIGHT_LABEL_OFFSET = 12;
10+
export const LABEL_OFFSET_X = 20;
11+
export const RIGHT_LABEL_OFFSET = 20;
1212
export const LABEL_TEXT_OFFSET_Y = 8;
1313
export const VALUE_TEXT_OFFSET_Y = 16;
1414
export const TIMESTAMP_Y = 12;

app/components/UI/Predict/components/PredictGameChart/PredictGameChart.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,13 @@ const PredictGameChart: React.FC<PredictGameChartProps> = ({
149149
});
150150
}, [priceHistories, tokenIds, seriesConfig]);
151151

152+
useEffect(() => {
153+
if (isLive && isFetching) {
154+
initialDataLoadedRef.current = false;
155+
setLiveChartData([]);
156+
}
157+
}, [isLive, isFetching]);
158+
152159
useEffect(() => {
153160
if (!isLive) {
154161
initialDataLoadedRef.current = false;

0 commit comments

Comments
 (0)