Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/build-android-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ jobs:

- name: Cache Gradle dependencies
uses: cirruslabs/cache@v4
if: ${{ steps.apk-cache-restore.outputs.cache-hit != 'true' }}
env:
GRADLE_CACHE_VERSION: 1
with:
Expand All @@ -134,6 +135,7 @@ jobs:
key: gradle-${{ env.GRADLE_CACHE_VERSION }}-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}

- name: Build Android E2E APKs
if: ${{ steps.apk-cache-restore.outputs.cache-hit != 'true' }}
run: |
echo "🏗 Building Android E2E APKs..."
export NODE_OPTIONS="--max-old-space-size=8192"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -586,10 +586,8 @@ exports[`EarnInputView render matches snapshot 1`] = `
{
"alignItems": "center",
"alignSelf": "stretch",
"backgroundColor": "#ffffff",
"borderColor": "#b7bbc8",
"backgroundColor": "#3c4d9d0f",
"borderRadius": 20,
"borderWidth": 1,
"flex": 1,
"flexDirection": "row",
"height": 40,
Expand Down Expand Up @@ -623,10 +621,8 @@ exports[`EarnInputView render matches snapshot 1`] = `
{
"alignItems": "center",
"alignSelf": "stretch",
"backgroundColor": "#ffffff",
"borderColor": "#b7bbc8",
"backgroundColor": "#3c4d9d0f",
"borderRadius": 20,
"borderWidth": 1,
"flex": 1,
"flexDirection": "row",
"height": 40,
Expand Down Expand Up @@ -660,10 +656,8 @@ exports[`EarnInputView render matches snapshot 1`] = `
{
"alignItems": "center",
"alignSelf": "stretch",
"backgroundColor": "#ffffff",
"borderColor": "#b7bbc8",
"backgroundColor": "#3c4d9d0f",
"borderRadius": 20,
"borderWidth": 1,
"flex": 1,
"flexDirection": "row",
"height": 40,
Expand Down Expand Up @@ -697,10 +691,8 @@ exports[`EarnInputView render matches snapshot 1`] = `
{
"alignItems": "center",
"alignSelf": "stretch",
"backgroundColor": "#ffffff",
"borderColor": "#b7bbc8",
"backgroundColor": "#3c4d9d0f",
"borderRadius": 20,
"borderWidth": 1,
"flex": 1,
"flexDirection": "row",
"height": 40,
Expand Down Expand Up @@ -2080,10 +2072,8 @@ exports[`EarnInputView when values are entered in the keypad updates ETH and fia
{
"alignItems": "center",
"alignSelf": "stretch",
"backgroundColor": "#ffffff",
"borderColor": "#b7bbc8",
"backgroundColor": "#3c4d9d0f",
"borderRadius": 20,
"borderWidth": 1,
"flex": 1,
"flexDirection": "row",
"height": 40,
Expand Down Expand Up @@ -2117,10 +2107,8 @@ exports[`EarnInputView when values are entered in the keypad updates ETH and fia
{
"alignItems": "center",
"alignSelf": "stretch",
"backgroundColor": "#ffffff",
"borderColor": "#b7bbc8",
"backgroundColor": "#3c4d9d0f",
"borderRadius": 20,
"borderWidth": 1,
"flex": 1,
"flexDirection": "row",
"height": 40,
Expand Down Expand Up @@ -2154,10 +2142,8 @@ exports[`EarnInputView when values are entered in the keypad updates ETH and fia
{
"alignItems": "center",
"alignSelf": "stretch",
"backgroundColor": "#ffffff",
"borderColor": "#b7bbc8",
"backgroundColor": "#3c4d9d0f",
"borderRadius": 20,
"borderWidth": 1,
"flex": 1,
"flexDirection": "row",
"height": 40,
Expand Down Expand Up @@ -2191,10 +2177,8 @@ exports[`EarnInputView when values are entered in the keypad updates ETH and fia
{
"alignItems": "center",
"alignSelf": "stretch",
"backgroundColor": "#ffffff",
"borderColor": "#b7bbc8",
"backgroundColor": "#3c4d9d0f",
"borderRadius": 20,
"borderWidth": 1,
"flex": 1,
"flexDirection": "row",
"height": 40,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -577,10 +577,8 @@ exports[`EarnWithdrawInputView render matches snapshot 1`] = `
{
"alignItems": "center",
"alignSelf": "stretch",
"backgroundColor": "#ffffff",
"borderColor": "#b7bbc8",
"backgroundColor": "#3c4d9d0f",
"borderRadius": 20,
"borderWidth": 1,
"flex": 1,
"flexDirection": "row",
"height": 40,
Expand Down Expand Up @@ -614,10 +612,8 @@ exports[`EarnWithdrawInputView render matches snapshot 1`] = `
{
"alignItems": "center",
"alignSelf": "stretch",
"backgroundColor": "#ffffff",
"borderColor": "#b7bbc8",
"backgroundColor": "#3c4d9d0f",
"borderRadius": 20,
"borderWidth": 1,
"flex": 1,
"flexDirection": "row",
"height": 40,
Expand Down Expand Up @@ -651,10 +647,8 @@ exports[`EarnWithdrawInputView render matches snapshot 1`] = `
{
"alignItems": "center",
"alignSelf": "stretch",
"backgroundColor": "#ffffff",
"borderColor": "#b7bbc8",
"backgroundColor": "#3c4d9d0f",
"borderRadius": 20,
"borderWidth": 1,
"flex": 1,
"flexDirection": "row",
"height": 40,
Expand Down Expand Up @@ -688,10 +682,8 @@ exports[`EarnWithdrawInputView render matches snapshot 1`] = `
{
"alignItems": "center",
"alignSelf": "stretch",
"backgroundColor": "#ffffff",
"borderColor": "#b7bbc8",
"backgroundColor": "#3c4d9d0f",
"borderRadius": 20,
"borderWidth": 1,
"flex": 1,
"flexDirection": "row",
"height": 40,
Expand Down
97 changes: 97 additions & 0 deletions app/components/UI/Ramp/Deposit/hooks/useCryptoCurrencies.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,5 +429,102 @@ describe('useCryptoCurrencies', () => {
cryptosWithMissing[0],
);
});

it('selects native token when intent has slip44 wildcard assetId', () => {
const intent = { assetId: 'eip155:1/slip44:.' };
mockUseDepositSDK.mockReturnValue(
createMockSDKReturn({
selectedRegion: MOCK_US_REGION,
selectedCryptoCurrency: null,
setSelectedCryptoCurrency: mockSetSelectedCryptoCurrency,
intent,
setIntent: mockSetIntent,
}),
);

renderHook(() => useCryptoCurrencies());

expect(mockSetSelectedCryptoCurrency).toHaveBeenCalledWith(
MOCK_ETH_TOKEN,
);
});

it('selects native token when intent has slip44 wildcard with different chainId', () => {
const mockPolygonNativeToken = {
assetId: 'eip155:137/slip44:966',
chainId: 'eip155:137',
name: 'Polygon',
symbol: 'POL',
decimals: 18,
iconUrl: 'https://example.com/pol.png',
};
const cryptosWithPolygon = [
...MOCK_CRYPTOCURRENCIES,
mockPolygonNativeToken,
];
mockUseDepositSdkMethod.mockReturnValue([
{ data: cryptosWithPolygon, error: null, isFetching: false },
mockRetryFetchCryptoCurrencies,
]);
mockUseSelector.mockReturnValue({
...mockNetworkConfigurations,
'eip155:137': { name: 'Polygon', chainId: '0x89' },
});

const intent = { assetId: 'eip155:137/slip44:.' };
mockUseDepositSDK.mockReturnValue(
createMockSDKReturn({
selectedRegion: MOCK_US_REGION,
selectedCryptoCurrency: null,
setSelectedCryptoCurrency: mockSetSelectedCryptoCurrency,
intent,
setIntent: mockSetIntent,
}),
);

renderHook(() => useCryptoCurrencies());

expect(mockSetSelectedCryptoCurrency).toHaveBeenCalledWith(
mockPolygonNativeToken,
);
});

it('falls back to first token when slip44 wildcard does not match any native token', () => {
const intent = { assetId: 'eip155:999/slip44:.' };
mockUseDepositSDK.mockReturnValue(
createMockSDKReturn({
selectedRegion: MOCK_US_REGION,
selectedCryptoCurrency: null,
setSelectedCryptoCurrency: mockSetSelectedCryptoCurrency,
intent,
setIntent: mockSetIntent,
}),
);

renderHook(() => useCryptoCurrencies());

expect(mockSetSelectedCryptoCurrency).toHaveBeenCalledWith(
MOCK_CRYPTOCURRENCIES[0],
);
});

it('prefers direct match over slip44 wildcard matching', () => {
const intent = { assetId: MOCK_USDC_TOKEN.assetId };
mockUseDepositSDK.mockReturnValue(
createMockSDKReturn({
selectedRegion: MOCK_US_REGION,
selectedCryptoCurrency: null,
setSelectedCryptoCurrency: mockSetSelectedCryptoCurrency,
intent,
setIntent: mockSetIntent,
}),
);

renderHook(() => useCryptoCurrencies());

expect(mockSetSelectedCryptoCurrency).toHaveBeenCalledWith(
MOCK_USDC_TOKEN,
);
});
});
});
19 changes: 18 additions & 1 deletion app/components/UI/Ramp/Deposit/hooks/useCryptoCurrencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { isCaipChainId } from '@metamask/utils';
import { toEvmCaipChainId } from '@metamask/multichain-network-controller';
import { toHex } from '@metamask/controller-utils';
import { toLowerCaseEquals } from '../../../../../util/general';
import { parseCAIP19AssetId } from '../../Aggregator/utils/parseCaip19AssetId';

export interface UseCryptoCurrenciesResult {
cryptoCurrencies: DepositCryptoCurrency[] | null;
Expand Down Expand Up @@ -56,10 +57,26 @@ export function useCryptoCurrencies(): UseCryptoCurrenciesResult {
useEffect(() => {
if (cryptoCurrencies && cryptoCurrencies.length > 0) {
if (intent?.assetId) {
const intentCrypto = cryptoCurrencies.find((token) =>
let intentCrypto = cryptoCurrencies.find((token) =>
toLowerCaseEquals(token.assetId, intent.assetId),
);

// Handle slip44 wildcard matching any native asset
if (!intentCrypto) {
const intentParsedCaip19 = parseCAIP19AssetId(intent.assetId);
if (intentParsedCaip19?.assetNamespace === 'slip44') {
intentCrypto = cryptoCurrencies.find((token) => {
const tokenParsed = parseCAIP19AssetId(token.assetId);
return (
tokenParsed &&
tokenParsed.namespace === intentParsedCaip19.namespace &&
tokenParsed.chainId === intentParsedCaip19.chainId &&
tokenParsed.assetNamespace === 'slip44'
);
});
}
}

setIntent((prevIntent) =>
prevIntent ? { ...prevIntent, assetId: undefined } : undefined,
);
Expand Down
4 changes: 1 addition & 3 deletions app/components/UI/Stake/components/QuickAmounts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ const createStyles = (colors: Colors) =>
},
amount: {
flex: 1,
borderWidth: 1,
borderColor: colors.border.default,
backgroundColor: colors.background.default,
backgroundColor: colors.background.muted,
flexDirection: 'row',
justifyContent: 'center',
paddingHorizontal: 16,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const styleSheet = (params: { theme: Theme }) => {

return StyleSheet.create({
container: {
backgroundColor: colors.background.alternative,
backgroundColor: colors.background.section,
borderRadius: 8,
gap: 8,
paddingVertical: 24,
Expand Down
Loading
Loading