Skip to content

Commit

Permalink
Merge branch 'main' into zs/new-browsing-experience
Browse files Browse the repository at this point in the history
  • Loading branch information
ziad-saab authored Dec 18, 2024
2 parents ec25d3b + 25375aa commit e25dde2
Show file tree
Hide file tree
Showing 23 changed files with 1,375 additions and 1,101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ exports[`OptinMetrics render matches snapshot 1`] = `
}
}
>
We'll use this data to learn how you interact with our marketing communications. We may share relavent news (like product features).
We'll use this data to learn how you interact with our marketing communications. We may share relevant news (like product features).
</Text>
</TouchableOpacity>
<View>
Expand Down
51 changes: 51 additions & 0 deletions app/components/UI/Ramp/hooks/useCryptoCurrencies.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const mockuseRampSDKInitialValues: DeepPartial<RampSDK> = {
selectedFiatCurrencyId: 'test-fiat-currency-id',
selectedAsset: null,
setSelectedAsset: jest.fn(),
setIntent: jest.fn(),
selectedChainId: '1',
isBuy: true,
};
Expand Down Expand Up @@ -354,4 +355,54 @@ describe('useCryptoCurrencies', () => {
queryGetCryptoCurrencies: mockQueryGetCryptoCurrencies,
});
});

it('selects the crypto currency from intent if available and resets it', () => {
const mockQueryGetCryptoCurrencies = jest.fn();
(useSDKMethod as jest.Mock).mockReturnValue([
{
data: [
{ network: { chainId: '1' }, address: 'test-address-1' },
{ network: { chainId: '1' }, address: 'test-address-2' },
{ network: { chainId: '1' }, address: NATIVE_ADDRESS },
],
error: null,
isFetching: false,
},
mockQueryGetCryptoCurrencies,
]);

mockUseRampSDKValues.selectedAsset = {
network: { chainId: '1' },
address: 'test-address-3',
};

const mockedIntent = { address: 'test-address-2' };
mockUseRampSDKValues.intent = mockedIntent;

const { result } = renderHookWithProvider(() => useCryptoCurrencies());

expect(mockUseRampSDKValues.setSelectedAsset).toHaveBeenCalledWith({
network: { chainId: '1' },
address: 'test-address-2',
});
expect(result.current).toEqual({
cryptoCurrencies: [
{ network: { chainId: '1' }, address: 'test-address-1' },
{ network: { chainId: '1' }, address: 'test-address-2' },
{ network: { chainId: '1' }, address: NATIVE_ADDRESS },
],
errorCryptoCurrencies: null,
isFetchingCryptoCurrencies: false,
queryGetCryptoCurrencies: mockQueryGetCryptoCurrencies,
});

expect(mockUseRampSDKValues.setIntent).toHaveBeenCalledWith(
expect.any(Function),
);
const setIntentFunction = (mockUseRampSDKValues.setIntent as jest.Mock).mock
.calls[0][0];
expect(setIntentFunction(mockedIntent)).toEqual({
address: undefined,
});
});
});
3 changes: 3 additions & 0 deletions app/components/UI/Ramp/hooks/useCryptoCurrencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default function useCryptoCurrencies() {
selectedChainId,
isBuy,
intent,
setIntent,
} = useRampSDK();

const [
Expand Down Expand Up @@ -62,6 +63,7 @@ export default function useCryptoCurrencies() {
);
if (intentAsset) {
setSelectedAsset(intentAsset);
setIntent((prevIntent) => ({ ...prevIntent, address: undefined }));
return;
}
}
Expand All @@ -85,6 +87,7 @@ export default function useCryptoCurrencies() {
selectedAsset,
selectedChainId,
setSelectedAsset,
setIntent,
]);

return {
Expand Down
22 changes: 22 additions & 0 deletions app/components/Views/NetworkSelector/NetworkSelector.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,28 @@ const createStyles = (colors: Colors) =>
fontSize: 10,
marginTop: 4,
},
screen: { justifyContent: 'flex-end' },
scrollableDescription: {
maxHeight: Device.getDeviceHeight() * 0.7,
},
sheet: {
backgroundColor: colors.background.default,
borderTopLeftRadius: 20,
borderTopRightRadius: 20,
},
title: {
textAlign: 'center',
marginTop: 8,
marginBottom: 8,
},
notch: {
width: 48,
height: 5,
borderRadius: 4,
backgroundColor: colors.border.default,
marginTop: 8,
alignSelf: 'center',
},
searchContainer: {
marginLeft: 16,
marginRight: 16,
Expand Down
4 changes: 2 additions & 2 deletions app/components/Views/NetworkSelector/NetworkSelector.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ describe('Network Selector', () => {
it('renders the linea mainnet cell correctly', () => {
(isNetworkUiRedesignEnabled as jest.Mock).mockImplementation(() => true);
const { getByText } = renderComponent(initialState);
const lineaRpcUrl = getByText('https://linea-rpc.publicnode.com');
const lineaRpcUrl = getByText('linea-rpc.publicnode.com');
const lineaCell = getByText('Linea');
expect(lineaCell).toBeTruthy();
expect(lineaRpcUrl).toBeTruthy();
Expand Down Expand Up @@ -572,7 +572,7 @@ describe('Network Selector', () => {
it('renders the mainnet cell correctly', () => {
(isNetworkUiRedesignEnabled as jest.Mock).mockImplementation(() => true);
const { getByText } = renderComponent(initialState);
const mainnetRpcUrl = getByText('https://mainnet-rpc.publicnode.com');
const mainnetRpcUrl = getByText('mainnet-rpc.publicnode.com');
const mainnetCell = getByText('Ethereum Mainnet');
expect(mainnetCell).toBeTruthy();
expect(mainnetRpcUrl).toBeTruthy();
Expand Down
Loading

0 comments on commit e25dde2

Please sign in to comment.