Skip to content

Commit

Permalink
fix: fix displayed selected rpc for linea
Browse files Browse the repository at this point in the history
  • Loading branch information
salimtb committed Nov 9, 2024
1 parent d112027 commit 5dc9fbd
Show file tree
Hide file tree
Showing 7 changed files with 187 additions and 21 deletions.
11 changes: 11 additions & 0 deletions android/.project
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,15 @@
<natures>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
<filteredResources>
<filter>
<id>1731153030486</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
11 changes: 11 additions & 0 deletions android/.settings/org.eclipse.buildship.core.prefs
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
arguments=--init-script /var/folders/j9/20w1vr5s10v1y55vbf73rbx40000gn/T/db3b08fc4a9ef609cb16b96b200fa13e563f396e9bb1ed0905fdab7bc3bc513b.gradle --init-script /var/folders/j9/20w1vr5s10v1y55vbf73rbx40000gn/T/52cde0cfcf3e28b8b7510e992210d9614505e0911af0c190bd590d7158574963.gradle
auto.sync=false
build.scans.enabled=false
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
connection.project.dir=
eclipse.preferences.version=1
gradle.user.home=
java.home=/Users/salim/Library/Java/JavaVirtualMachines/azul-16.0.2/Contents/Home
jvm.arguments=
offline.mode=false
override.workspace.settings=true
show.console.view=true
show.executions.view=true
73 changes: 73 additions & 0 deletions app/components/Views/NetworkSelector/NetworkSelector.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,46 @@ const initialState = {
mainnet: { status: 'available', EIPS: { '1559': true } },
},
networkConfigurationsByChainId: {
'0x1': {
blockExplorerUrls: [],
chainId: '0x1',
defaultRpcEndpointIndex: 1,
name: 'Ethereum Mainnet',
nativeCurrency: 'ETH',
rpcEndpoints: [
{
networkClientId: 'mainnet',
type: 'infura',
url: 'https://mainnet.infura.io/v3/{infuraProjectId}',
},
{
name: 'public',
networkClientId: 'ea57f659-c004-4902-bfca-0c9688a43872',
type: 'custom',
url: 'https://mainnet-rpc.publicnode.com',
},
],
},
'0xe708': {
blockExplorerUrls: [],
chainId: '0xe708',
defaultRpcEndpointIndex: 1,
name: 'Linea',
nativeCurrency: 'ETH',
rpcEndpoints: [
{
networkClientId: 'linea-mainnet',
type: 'infura',
url: 'https://linea-mainnet.infura.io/v3/{infuraProjectId}',
},
{
name: 'public',
networkClientId: 'ea57f659-c004-4902-bfca-0c9688a43877',
type: 'custom',
url: 'https://linea-rpc.publicnode.com',
},
],
},
'0xa86a': {
blockExplorerUrls: ['https://snowtrace.io'],
chainId: '0xa86a',
Expand Down Expand Up @@ -459,4 +499,37 @@ describe('Network Selector', () => {
fireEvent(testNetworksSwitch, 'onValueChange', false);
expect(setShowTestNetworksSpy).toBeCalledWith(false);
});

describe('renderLineaMainnet', () => {
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 lineaCell = getByText('Linea');
expect(lineaCell).toBeTruthy();
expect(lineaRpcUrl).toBeTruthy();
});
});

describe('renderRpcUrl', () => {
it('renders the RPC URL correctly for avalanche', () => {
(isNetworkUiRedesignEnabled as jest.Mock).mockImplementation(() => true);
const { getByText } = renderComponent(initialState);
const avalancheRpcUrl = getByText('api.avax.network/ext/bc/C');
const avalancheCell = getByText('Avalanche Mainnet C-Chain');
expect(avalancheRpcUrl).toBeTruthy();
expect(avalancheCell).toBeTruthy();
});
});

describe('renderMainnet', () => {
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 mainnetCell = getByText('Ethereum Mainnet');
expect(mainnetCell).toBeTruthy();
expect(mainnetRpcUrl).toBeTruthy();
});
});
});
7 changes: 5 additions & 2 deletions app/components/Views/NetworkSelector/NetworkSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ import { isNetworkUiRedesignEnabled } from '../../../util/networks/isNetworkUiRe
import { Hex } from '@metamask/utils';
import hideProtocolFromUrl from '../../../util/hideProtocolFromUrl';
import { CHAIN_IDS } from '@metamask/transaction-controller';
import { LINEA_DEFAULT_RPC_URL } from '../../../constants/urls';
import { useNetworkInfo } from '../../../selectors/selectedNetworkController';
import { NetworkConfiguration } from '@metamask/network-controller';
import Logger from '../../../util/Logger';
Expand Down Expand Up @@ -485,6 +484,10 @@ const NetworkSelector = () => {
const renderLineaMainnet = () => {
const { name: lineaMainnetName, chainId } = Networks['linea-mainnet'];
const name = networkConfigurations?.[chainId]?.name ?? lineaMainnetName;
const rpcUrl =
networkConfigurations?.[chainId]?.rpcEndpoints?.[
networkConfigurations?.[chainId]?.defaultRpcEndpointIndex
].url;

if (isNetworkUiRedesignEnabled() && isNoSearchResults('linea-mainnet'))
return null;
Expand All @@ -505,7 +508,7 @@ const NetworkSelector = () => {
onPress={() => onNetworkChange(LINEA_MAINNET)}
style={styles.networkCell}
buttonIcon={IconName.MoreVertical}
secondaryText={hideKeyFromUrl(LINEA_DEFAULT_RPC_URL)}
secondaryText={hideKeyFromUrl(rpcUrl)}
buttonProps={{
onButtonClick: () => {
openModal(chainId, false, LINEA_MAINNET, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ exports[`Network Selector renders correctly 1`] = `
}
testID="cellbase-avatar-title"
>
Ethereum Main Network
Ethereum Mainnet
</Text>
</View>
</View>
Expand Down Expand Up @@ -686,7 +686,7 @@ exports[`Network Selector renders correctly 1`] = `
}
testID="cellbase-avatar-title"
>
Linea Main Network
Linea
</Text>
</View>
</View>
Expand Down Expand Up @@ -1890,8 +1890,68 @@ exports[`Network Selector renders correctly when network UI redesign is enabled
}
testID="cellbase-avatar-title"
>
Ethereum Main Network
Ethereum Mainnet
</Text>
<TouchableOpacity
accessibilityState={
{
"busy": undefined,
"checked": undefined,
"disabled": undefined,
"expanded": undefined,
"selected": undefined,
}
}
accessible={true}
focusable={false}
onClick={[Function]}
onPress={[Function]}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
{
"alignItems": "flex-start",
"flexDirection": "row",
"marginBottom": 0,
"zIndex": 1,
}
}
>
<Text
accessibilityRole="text"
numberOfLines={1}
style={
{
"color": "#6a737d",
"fontFamily": "EuclidCircularB-Regular",
"fontSize": 14,
"fontWeight": "400",
"letterSpacing": 0,
"lineHeight": 22,
}
}
>
https://mainnet-rpc.publicnode.com
</Text>
<SvgMock
color="#141618"
height={10}
name="ArrowDown"
style={
{
"height": 10,
"paddingLeft": 8,
"paddingTop": 24,
"width": 10,
}
}
width={10}
/>
</TouchableOpacity>
</View>
</View>
</View>
Expand Down Expand Up @@ -2080,7 +2140,7 @@ exports[`Network Selector renders correctly when network UI redesign is enabled
}
testID="cellbase-avatar-title"
>
Linea Main Network
Linea
</Text>
<TouchableOpacity
accessibilityState={
Expand Down Expand Up @@ -2125,7 +2185,7 @@ exports[`Network Selector renders correctly when network UI redesign is enabled
}
}
>
https://linea-mainnet.infura.io/v3
https://linea-rpc.publicnode.com
</Text>
<SvgMock
color="#141618"
Expand Down
18 changes: 11 additions & 7 deletions ios/GoogleService-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,28 @@
<plist version="1.0">
<dict>
<key>API_KEY</key>
<string>$(FCM_CONFIG_API_KEY)</string>
<string>AIzaSyC5yxsMjSx0UAaaoRKMp1RYezlnvx_qJWc</string>
<key>GCM_SENDER_ID</key>
<string>$(FCM_CONFIG_MESSAGING_SENDER_ID)</string>
<string>824598429541</string>
<key>PLIST_VERSION</key>
<string>1</string>
<key>BUNDLE_ID</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<string>io.metamask.MetaMask</string>
<key>PROJECT_ID</key>
<string>$(FCM_CONFIG_PROJECT_ID)</string>
<string>notifications-faf39</string>
<key>STORAGE_BUCKET</key>
<string>$(FCM_CONFIG_STORAGE_BUCKET)</string>
<string>notifications-faf39.appspot.com</string>
<key>IS_ADS_ENABLED</key>
<false></false>
<key>IS_ANALYTICS_ENABLED</key>
<false></false>
<key>IS_APPINVITE_ENABLED</key>
<true></true>
<key>IS_GCM_ENABLED</key>
<true></true>
<key>IS_SIGNIN_ENABLED</key>
<true></true>
<key>GOOGLE_APP_ID</key>
<string>$(FCM_CONFIG_APP_ID)</string>
<string>1:824598429541:ios:7b7482c4598025a5beab8c</string>
</dict>
</plist>
</plist>
18 changes: 11 additions & 7 deletions ios/GoogleServices/GoogleService-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,28 @@
<plist version="1.0">
<dict>
<key>API_KEY</key>
<string>$(FCM_CONFIG_API_KEY)</string>
<string>AIzaSyC5yxsMjSx0UAaaoRKMp1RYezlnvx_qJWc</string>
<key>GCM_SENDER_ID</key>
<string>$(FCM_CONFIG_MESSAGING_SENDER_ID)</string>
<string>824598429541</string>
<key>PLIST_VERSION</key>
<string>1</string>
<key>BUNDLE_ID</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<string>io.metamask.MetaMask</string>
<key>PROJECT_ID</key>
<string>$(FCM_CONFIG_PROJECT_ID)</string>
<string>notifications-faf39</string>
<key>STORAGE_BUCKET</key>
<string>$(FCM_CONFIG_STORAGE_BUCKET)</string>
<string>notifications-faf39.appspot.com</string>
<key>IS_ADS_ENABLED</key>
<false></false>
<key>IS_ANALYTICS_ENABLED</key>
<false></false>
<key>IS_APPINVITE_ENABLED</key>
<true></true>
<key>IS_GCM_ENABLED</key>
<true></true>
<key>IS_SIGNIN_ENABLED</key>
<true></true>
<key>GOOGLE_APP_ID</key>
<string>$(FCM_CONFIG_APP_ID)</string>
<string>1:824598429541:ios:7b7482c4598025a5beab8c</string>
</dict>
</plist>
</plist>

0 comments on commit 5dc9fbd

Please sign in to comment.