Skip to content

Commit 8218306

Browse files
authored
Merge branch 'main' into perps/home-screen-search-nav
2 parents 920460c + 908ccaa commit 8218306

File tree

116 files changed

+5638
-1192
lines changed

Some content is hidden

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

116 files changed

+5638
-1192
lines changed

.detoxrc.js

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,12 @@ module.exports = {
6565
},
6666
'ios.sim.main.ci': {
6767
device: 'ios.simulator',
68-
app: 'ios.debug',
69-
}
68+
app: 'ios.main.release',
69+
},
70+
'ios.sim.flask.ci': {
71+
device: 'ios.simulator',
72+
app: 'ios.flask.release',
73+
},
7074
},
7175
devices: {
7276
'ios.simulator': {
@@ -110,42 +114,44 @@ module.exports = {
110114
'ios.main.release': {
111115
type: 'ios.app',
112116
binaryPath:
113-
'ios/build/Build/Products/Release-iphonesimulator/MetaMask.app',
114-
build: `yarn build:ios:main:e2e`,
117+
process.env.PREBUILT_IOS_APP_PATH || 'ios/build/Build/Products/Release-iphonesimulator/MetaMask.app',
118+
build: `export CONFIGURATION="Release" && yarn build:ios:main:e2e`,
115119
},
116120
'ios.flask.debug': {
117121
type: 'ios.app',
118122
binaryPath:
119-
'ios/build/Build/Products/Debug-iphonesimulator/MetaMask-Flask.app',
120-
build: 'yarn start:ios:e2e:flask',
123+
process.env.PREBUILT_IOS_APP_PATH || 'ios/build/Build/Products/Debug-iphonesimulator/MetaMask-Flask.app',
124+
build: 'export CONFIGURATION="Debug" && yarn build:ios:flask:e2e',
121125
},
122126
'ios.flask.release': {
123127
type: 'ios.app',
124128
binaryPath:
125-
'ios/build/Build/Products/Release-iphonesimulator/MetaMask-Flask.app',
126-
build: `yarn build:ios:flask:e2e`,
129+
process.env.PREBUILT_IOS_APP_PATH || 'ios/build/Build/Products/Release-iphonesimulator/MetaMask-Flask.app',
130+
build: `export CONFIGURATION="Release" && yarn build:ios:flask:e2e`,
127131
},
128132
'android.debug': {
129133
type: 'android.apk',
130134
binaryPath: process.env.PREBUILT_ANDROID_APK_PATH || 'android/app/build/outputs/apk/prod/debug/app-prod-debug.apk',
131135
testBinaryPath: process.env.PREBUILT_ANDROID_TEST_APK_PATH,
132-
build: 'yarn start:android:e2e',
136+
build: 'export CONFIGURATION="Debug" && yarn build:android:main:e2e',
133137
},
134-
'android.flask.debug': {
138+
'android.release': {
135139
type: 'android.apk',
136-
binaryPath: 'android/app/build/outputs/apk/flask/debug/app-flask-debug.apk',
137-
testBinaryPath: 'android/app/build/outputs/apk/androidTest/flask/debug/app-flask-debug-androidTest.apk',
138-
build: 'yarn start:android:e2e:flask',
140+
binaryPath: process.env.PREBUILT_ANDROID_APK_PATH || 'android/app/build/outputs/apk/prod/release/app-prod-release.apk',
141+
testBinaryPath: process.env.PREBUILT_ANDROID_TEST_APK_PATH,
142+
build: `export CONFIGURATION="Release" && yarn build:android:main:e2e`,
139143
},
140-
'android.release': {
144+
'android.flask.debug': {
141145
type: 'android.apk',
142-
binaryPath: 'android/app/build/outputs/apk/prod/release/app-prod-release.apk',
143-
build: `yarn build:android:main:e2e`,
146+
binaryPath: process.env.PREBUILT_ANDROID_APK_PATH || 'android/app/build/outputs/apk/flask/debug/app-flask-debug.apk',
147+
testBinaryPath: process.env.PREBUILT_ANDROID_TEST_APK_PATH,
148+
build: 'export CONFIGURATION="Debug" && yarn build:android:flask:e2e',
144149
},
145150
'android.flask.release': {
146151
type: 'android.apk',
147-
binaryPath: 'android/app/build/outputs/apk/flask/release/app-flask-release.apk',
148-
build: `yarn build:android:flask:e2e`,
152+
binaryPath: process.env.PREBUILT_ANDROID_APK_PATH || 'android/app/build/outputs/apk/flask/release/app-flask-release.apk',
153+
testBinaryPath: process.env.PREBUILT_ANDROID_TEST_APK_PATH,
154+
build: `export CONFIGURATION="Release" && yarn build:android:flask:e2e`,
149155
},
150156
},
151157
};

.github/CODEOWNERS

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ app/core/Engine/index.ts @MetaMask/mobile-pla
4040
app/core/Engine/README.md @MetaMask/mobile-platform
4141
app/core/Engine/types.ts @MetaMask/mobile-platform
4242
app/core/Engine/controllers/remote-feature-flag-controller/ @MetaMask/mobile-platform
43-
app/core/DeeplinkManager @MetaMask/mobile-platform
44-
app/core/DeeplinkManager/Handlers/handlePerpsUrl.ts @MetaMask/perps
43+
app/core/DeeplinkManager @MetaMask/mobile-platform
44+
scripts/build.sh @MetaMask/mobile-platform
4545

4646
# Platform & Snaps Code Fencing File
4747
metro.transform.js @MetaMask/mobile-platform @MetaMask/core-platform
@@ -145,6 +145,7 @@ app/components/UI/Perps/ @MetaMask/perps
145145
app/components/UI/WalletAction/*perps* @MetaMask/perps
146146
app/core/Engine/controllers/perps-controller @MetaMask/perps
147147
app/core/Engine/messengers/perps-controller-messenger @MetaMask/perps
148+
app/core/DeeplinkManager/Handlers/handlePerpsUrl.ts @MetaMask/perps
148149
**/Perps/** @MetaMask/perps
149150
**/perps/** @MetaMask/perps
150151

.github/workflows/run-e2e-smoke-tests-android.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,21 @@ jobs:
2929
changed_files: ${{ inputs.changed_files }}
3030
secrets: inherit
3131

32+
perps-android-smoke:
33+
strategy:
34+
matrix:
35+
split: [1]
36+
fail-fast: false
37+
uses: ./.github/workflows/run-e2e-workflow.yml
38+
with:
39+
test-suite-name: perps-android-smoke-${{ matrix.split }}
40+
platform: android
41+
test_suite_tag: 'SmokePerps'
42+
split_number: ${{ matrix.split }}
43+
total_splits: 1
44+
changed_files: ${{ inputs.changed_files }}
45+
secrets: inherit
46+
3247
wallet-platform-android-smoke:
3348
strategy:
3449
matrix:
@@ -155,6 +170,7 @@ jobs:
155170
if: ${{ !cancelled() }}
156171
needs:
157172
- trade-android-smoke
173+
- perps-android-smoke
158174
- wallet-platform-android-smoke
159175
- identity-android-smoke
160176
- accounts-android-smoke

.github/workflows/run-e2e-smoke-tests-ios.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,21 @@ jobs:
4444
changed_files: ${{ inputs.changed_files }}
4545
secrets: inherit
4646

47+
perps-ios-smoke:
48+
strategy:
49+
matrix:
50+
split: [1]
51+
fail-fast: false
52+
uses: ./.github/workflows/run-e2e-workflow.yml
53+
with:
54+
test-suite-name: perps-ios-smoke-${{ matrix.split }}
55+
platform: ios
56+
test_suite_tag: 'SmokePerps'
57+
split_number: ${{ matrix.split }}
58+
total_splits: 1
59+
changed_files: ${{ inputs.changed_files }}
60+
secrets: inherit
61+
4762
wallet-platform-ios-smoke:
4863
strategy:
4964
matrix:
@@ -156,6 +171,7 @@ jobs:
156171
needs:
157172
- confirmations-redesigned-ios-smoke
158173
- trade-ios-smoke
174+
- perps-ios-smoke
159175
- wallet-platform-ios-smoke
160176
- identity-ios-smoke
161177
- accounts-ios-smoke

app/components/UI/Bridge/components/TokenInputArea/TokenInputArea.test.tsx

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import {
99
getDisplayAmount,
1010
} from '.';
1111
import { BridgeToken } from '../../types';
12+
import { CHAIN_IDS } from '@metamask/transaction-controller';
13+
import { POLYGON_NATIVE_TOKEN } from '../../constants/assets';
1214

1315
jest.mock('../../hooks/useLatestBalance', () => ({
1416
useLatestBalance: jest.fn(),
@@ -242,6 +244,139 @@ describe('TokenInputArea', () => {
242244
// Assert
243245
expect(getByText('Max')).toBeTruthy();
244246
});
247+
248+
it('treats Polygon native token as native asset after zero address conversion', () => {
249+
const polygonNativeToken: BridgeToken = {
250+
address: POLYGON_NATIVE_TOKEN, // 0x0000...001010
251+
symbol: 'POL',
252+
decimals: 18,
253+
chainId: CHAIN_IDS.POLYGON as `0x${string}`,
254+
};
255+
const tokenBalance = '10';
256+
257+
const stateWithoutGasless = {
258+
...initialState,
259+
engine: {
260+
...initialState.engine,
261+
backgroundState: {
262+
...initialState.engine.backgroundState,
263+
RemoteFeatureFlagController: {
264+
remoteFeatureFlags: {
265+
...initialState.engine.backgroundState.RemoteFeatureFlagController
266+
.remoteFeatureFlags,
267+
bridgeConfigV2: {
268+
...initialState.engine.backgroundState
269+
.RemoteFeatureFlagController.remoteFeatureFlags
270+
.bridgeConfigV2,
271+
chains: {
272+
...initialState.engine.backgroundState
273+
.RemoteFeatureFlagController.remoteFeatureFlags
274+
.bridgeConfigV2.chains,
275+
'eip155:137': {
276+
isActiveSrc: true,
277+
isActiveDest: true,
278+
isGaslessSwapEnabled: false,
279+
},
280+
},
281+
},
282+
},
283+
},
284+
},
285+
},
286+
};
287+
288+
const { queryByText } = renderScreen(
289+
() => (
290+
<TokenInputArea
291+
testID="token-input"
292+
tokenType={TokenInputAreaType.Source}
293+
token={polygonNativeToken}
294+
tokenBalance={tokenBalance}
295+
onMaxPress={mockOnMaxPress}
296+
/>
297+
),
298+
{
299+
name: 'TokenInputArea',
300+
},
301+
{ state: stateWithoutGasless },
302+
);
303+
304+
// After conversion to zero address, Polygon native token is treated as native
305+
// Native tokens hide Max button when gasless swaps are disabled
306+
expect(queryByText('Max')).toBeNull();
307+
});
308+
309+
it('displays max button for Polygon native token when gasless swaps are enabled', () => {
310+
const polygonNativeToken: BridgeToken = {
311+
address: POLYGON_NATIVE_TOKEN, // 0x0000...001010
312+
symbol: 'POL',
313+
decimals: 18,
314+
chainId: CHAIN_IDS.POLYGON as `0x${string}`,
315+
};
316+
const destToken: BridgeToken = {
317+
address: '0x2791bca1f2de4661ed88a30c99a7a9449aa84174', // USDC
318+
symbol: 'USDC',
319+
decimals: 6,
320+
chainId: CHAIN_IDS.POLYGON as `0x${string}`,
321+
};
322+
const tokenBalance = '10';
323+
324+
const stateWithGaslessSwap = {
325+
...initialState,
326+
engine: {
327+
...initialState.engine,
328+
backgroundState: {
329+
...initialState.engine.backgroundState,
330+
RemoteFeatureFlagController: {
331+
remoteFeatureFlags: {
332+
...initialState.engine.backgroundState.RemoteFeatureFlagController
333+
.remoteFeatureFlags,
334+
bridgeConfigV2: {
335+
...initialState.engine.backgroundState
336+
.RemoteFeatureFlagController.remoteFeatureFlags
337+
.bridgeConfigV2,
338+
chains: {
339+
...initialState.engine.backgroundState
340+
.RemoteFeatureFlagController.remoteFeatureFlags
341+
.bridgeConfigV2.chains,
342+
'eip155:137': {
343+
isActiveSrc: true,
344+
isActiveDest: true,
345+
isGaslessSwapEnabled: true,
346+
},
347+
},
348+
},
349+
},
350+
},
351+
},
352+
},
353+
bridge: {
354+
...initialState.bridge,
355+
sourceToken: polygonNativeToken,
356+
destToken,
357+
},
358+
};
359+
360+
const { getByText } = renderScreen(
361+
() => (
362+
<TokenInputArea
363+
testID="token-input"
364+
tokenType={TokenInputAreaType.Source}
365+
token={polygonNativeToken}
366+
tokenBalance={tokenBalance}
367+
onMaxPress={mockOnMaxPress}
368+
/>
369+
),
370+
{
371+
name: 'TokenInputArea',
372+
},
373+
{ state: stateWithGaslessSwap },
374+
);
375+
376+
// After conversion to zero address, Polygon native token is treated as native
377+
// Native tokens show Max button when gasless swaps are enabled
378+
expect(getByText('Max')).toBeTruthy();
379+
});
245380
});
246381

247382
describe('calculateFontSize', () => {

app/components/UI/Bridge/components/TokenInputArea/index.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ import { renderShortAddress } from '../../../../../util/address';
4949
import { FlexDirection } from '../../../Box/box.types';
5050
import { isNativeAddress } from '@metamask/bridge-controller';
5151
import { Theme } from '../../../../../util/theme/models';
52+
import { CHAIN_IDS } from '@metamask/transaction-controller';
53+
import { POLYGON_NATIVE_TOKEN } from '../../constants/assets';
54+
import { zeroAddress } from 'ethereumjs-util';
5255

5356
const MAX_DECIMALS = 5;
5457
export const MAX_INPUT_LENGTH = 36;
@@ -301,11 +304,17 @@ export const TokenInputArea = forwardRef<
301304
}`
302305
: undefined;
303306

304-
const isNativeAsset = isNativeAddress(token?.address);
307+
// Polygon native token address can be 0x0000000000000000000000000000000000001010
308+
// so we need to use the zero address for the token address
309+
const tokenAddress =
310+
token?.chainId === CHAIN_IDS.POLYGON &&
311+
token?.address === POLYGON_NATIVE_TOKEN
312+
? zeroAddress()
313+
: token?.address;
314+
315+
const isNativeAsset = isNativeAddress(tokenAddress);
305316
const formattedAddress =
306-
token?.address && !isNativeAsset
307-
? formatAddress(token?.address)
308-
: undefined;
317+
tokenAddress && !isNativeAsset ? formatAddress(tokenAddress) : undefined;
309318

310319
const subtitle =
311320
tokenType === TokenInputAreaType.Source

app/components/UI/Perps/Views/PerpsCancelAllOrdersView/PerpsCancelAllOrdersView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ const PerpsCancelAllOrdersView: React.FC<PerpsCancelAllOrdersViewProps> = ({
8484
{ label: message, isBold: false },
8585
]
8686
: [{ label: title, isBold: true }],
87-
};
87+
} as PerpsToastOptions;
8888
showToast(toastConfig);
8989
},
9090
[showToast, theme.colors.accent03],
@@ -107,7 +107,7 @@ const PerpsCancelAllOrdersView: React.FC<PerpsCancelAllOrdersViewProps> = ({
107107
{ label: message, isBold: false },
108108
]
109109
: [{ label: title, isBold: true }],
110-
};
110+
} as PerpsToastOptions;
111111
showToast(toastConfig);
112112
},
113113
[showToast, theme.colors.accent01],

app/components/UI/Perps/Views/PerpsCloseAllPositionsView/PerpsCloseAllPositionsView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ const PerpsCloseAllPositionsView: React.FC<PerpsCloseAllPositionsViewProps> = ({
105105
{ label: message, isBold: false },
106106
]
107107
: [{ label: title, isBold: true }],
108-
};
108+
} as PerpsToastOptions;
109109
showToast(toastConfig);
110110
},
111111
[showToast, theme.colors.accent03],
@@ -128,7 +128,7 @@ const PerpsCloseAllPositionsView: React.FC<PerpsCloseAllPositionsViewProps> = ({
128128
{ label: message, isBold: false },
129129
]
130130
: [{ label: title, isBold: true }],
131-
};
131+
} as PerpsToastOptions;
132132
showToast(toastConfig);
133133
},
134134
[showToast, theme.colors.accent01],

0 commit comments

Comments
 (0)