Skip to content

Commit

Permalink
fix: image icons issue
Browse files Browse the repository at this point in the history
  • Loading branch information
VGau committed Jun 14, 2023
1 parent 88f2296 commit fe77740
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 21 deletions.
4 changes: 4 additions & 0 deletions app/components/UI/Tokens/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
getDecimalChainId,
getNetworkNameFromProvider,
getTestNetImageByChainId,
isLineaMainnetByChainId,
isMainnetByChainId,
isTestNet,
} from '../../../util/networks';
Expand Down Expand Up @@ -261,12 +262,15 @@ const Tokens: React.FC<TokensI> = ({ tokens }) => {
asset = { ...asset, balanceFiat };

const isMainnet = isMainnetByChainId(chainId);
const isLineaMainnet = isLineaMainnetByChainId(chainId);

const NetworkBadgeSource = () => {
if (isTestNet(chainId)) return getTestNetImageByChainId(chainId);

if (isMainnet) return images.ETHEREUM;

if (isLineaMainnet) return images['LINEA-MAINNET'];

return images[ticker];
};

Expand Down
2 changes: 1 addition & 1 deletion app/components/Views/NetworkSelector/NetworkSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ const NetworkSelector = () => {
avatarProps={{
variant: AvatarVariants.Network,
name: lineaMainnetName,
imageSource: images.LINEA_MAINNET,
imageSource: images['LINEA-MAINNET'],
}}
isSelected={chainId.toString() === providerConfig.chainId}
onPress={() => onNetworkChange(LINEA_MAINNET)}
Expand Down
2 changes: 1 addition & 1 deletion app/components/Views/Settings/NetworksSettings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ class NetworksSettings extends PureComponent {
onPress={() => this.onNetworkPress(LINEA_MAINNET)}
>
<View style={styles.networkWrapper}>
<ImageIcons image="LINEA_MAINNET" style={styles.networkIcon} />
<ImageIcons image="LINEA-MAINNET" style={styles.networkIcon} />
<View style={styles.networkInfo}>
<Text style={styles.networkLabel}>{lineaMainnetName}</Text>
</View>
Expand Down
3 changes: 1 addition & 2 deletions app/constants/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,5 @@ export const NETWORKS_CHAIN_ID = {
SEPOLIA: '11155111',
LINEA_GOERLI: '59140',
GOERLI: '5',
// TODO: change linea mainnet chainId once linea mainnet infrastructure is ready
LINEA_MAINNET: '59140',
LINEA_MAINNET: '59144',
};
2 changes: 1 addition & 1 deletion app/images/image-icons.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ export default {
GOERLI,
'LINEA-GOERLI': LINEA_GOERLI,
SEPOLIA,
LINEA_MAINNET,
'LINEA-MAINNET': LINEA_MAINNET,
};
12 changes: 7 additions & 5 deletions app/util/networks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,9 @@ const NetworkList = {
[LINEA_MAINNET]: {
name: 'Linea Main Network',
shortName: 'Linea',
// TODO: change linea mainnet networid and chainId once the linea mainnet infrastructure is ready
networkId: 59140,
chainId: 59140,
hexChainId: '0xe704',
networkId: 59144,
chainId: 59144,
hexChainId: '0xe708',
color: '#121212',
networkType: 'linea-mainnet',
imageSource: lineaMainnetLogo,
Expand Down Expand Up @@ -138,6 +137,9 @@ export const getDecimalChainId = (chainId) => {
export const isMainnetByChainId = (chainId) =>
getDecimalChainId(String(chainId)) === String(1);

export const isLineaMainnetByChainId = (chainId) =>
getDecimalChainId(String(chainId)) === String(59144);

export const isMultiLayerFeeNetwork = (chainId) =>
chainId === NETWORKS_CHAIN_ID.OPTIMISM;

Expand Down Expand Up @@ -482,5 +484,5 @@ export const shouldShowLineaMainnetNetwork = async (rpcUrl) => {
chainId = null;
}

return currentDateHigherThanReleaseDate && Boolean(chainId);
return currentDateHigherThanReleaseDate && chainId;
};
2 changes: 1 addition & 1 deletion app/util/networks/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ describe('NetworkUtils::getNetworkName', () => {
});

it(`should get network name for ${LINEA_MAINNET} id`, () => {
const main = getNetworkName(String(59140));
const main = getNetworkName(String(59144));
expect(main).toEqual(LINEA_MAINNET);
});

Expand Down
14 changes: 6 additions & 8 deletions patches/@metamask+controller-utils+3.0.0.patch
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ index e77af58..0ffbafb 100644
localhost: '',
};
diff --git a/node_modules/@metamask/controller-utils/dist/types.d.ts b/node_modules/@metamask/controller-utils/dist/types.d.ts
index 4403885..054c6d7 100644
index 4403885..5f52027 100644
--- a/node_modules/@metamask/controller-utils/dist/types.d.ts
+++ b/node_modules/@metamask/controller-utils/dist/types.d.ts
@@ -1,11 +1,14 @@
@@ -1,11 +1,13 @@
/**
* Human-readable network name
*/
Expand All @@ -45,22 +45,20 @@ index 4403885..054c6d7 100644
goerli = "5",
sepolia = "11155111",
+ "linea-goerli" = "59140",
+ // TODO: change linea mainnet chain ID
+ "linea-mainnet" = "59140",
+ "linea-mainnet" = "59144",
localhost = "",
rpc = ""
}
diff --git a/node_modules/@metamask/controller-utils/dist/types.js b/node_modules/@metamask/controller-utils/dist/types.js
index ea81681..ff15d48 100644
index ea81681..a5135ca 100644
--- a/node_modules/@metamask/controller-utils/dist/types.js
+++ b/node_modules/@metamask/controller-utils/dist/types.js
@@ -6,6 +6,9 @@ var NetworksChainId;
@@ -6,6 +6,8 @@ var NetworksChainId;
NetworksChainId["mainnet"] = "1";
NetworksChainId["goerli"] = "5";
NetworksChainId["sepolia"] = "11155111";
+ NetworksChainId["linea-goerli"] = "59140";
+ // TODO: change linea mainnet chain ID
+ NetworksChainId["linea-mainnet"] = "59140";
+ NetworksChainId["linea-mainnet"] = "59144";
NetworksChainId["localhost"] = "";
NetworksChainId["rpc"] = "";
})(NetworksChainId = exports.NetworksChainId || (exports.NetworksChainId = {}));
4 changes: 2 additions & 2 deletions patches/@metamask+transaction-controller+4.0.0.patch
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ index 6d58813..afa8eb9 100644
}
export default TransactionController;
diff --git a/node_modules/@metamask/transaction-controller/dist/TransactionController.js b/node_modules/@metamask/transaction-controller/dist/TransactionController.js
index 31a22b6..bab235b 100644
index 31a22b6..5756d1f 100644
--- a/node_modules/@metamask/transaction-controller/dist/TransactionController.js
+++ b/node_modules/@metamask/transaction-controller/dist/TransactionController.js
@@ -59,6 +59,10 @@ exports.CANCEL_RATE = 1.5;
Expand Down Expand Up @@ -134,7 +134,7 @@ index 31a22b6..bab235b 100644
getCommonConfiguration() {
const { network: networkId, providerConfig: { type: chain, chainId, nickname: name }, } = this.getNetworkState();
- if (chain !== controller_utils_1.RPC) {
+ if (chain !== controller_utils_1.RPC && chain !== 'linea-goerli') {
+ if (chain !== controller_utils_1.RPC && chain !== 'linea-goerli' && chain !== 'linea-mainnet') {
return new common_1.default({ chain, hardfork: HARDFORK });
}
const customChainParams = {
Expand Down

0 comments on commit fe77740

Please sign in to comment.