Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix apechain using mainnet gas prices #6220

Merged
merged 4 commits into from
Oct 21, 2024
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
12 changes: 10 additions & 2 deletions src/components/coin-icon/ChainBadge.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ import DegenBadge from '../../assets/badges/degenBadge.png';
import DegenBadgeDark from '../../assets/badges/degenBadgeDark.png';
import DegenBadgeLarge from '../../assets/badges/degenBadgeLarge.png';
import DegenBadgeLargeDark from '../../assets/badges/degenBadgeLargeDark.png';
import ApechainBadge from '../../assets/badges/apechainBadge.png';
import ApechainBadgeDark from '../../assets/badges/apechainBadgeDark.png';
import ApechainBadgeLarge from '../../assets/badges/apechainBadgeLarge.png';
import ApechainBadgeLargeDark from '../../assets/badges/apechainBadgeLargeDark.png';
import { Centered } from '../layout';
import styled from '@/styled-thing';
import { position as positions } from '@/styles';
Expand Down Expand Up @@ -76,7 +80,9 @@ export default function ChainBadge({
const source = useMemo(() => {
let val = null;
if (size === 'large') {
if (chainId === ChainId.arbitrum) {
if (chainId === ChainId.apechain) {
val = isDarkMode ? ApechainBadgeLargeDark : ApechainBadgeLarge;
} else if (chainId === ChainId.arbitrum) {
val = isDarkMode ? ArbitrumBadgeLargeDark : ArbitrumBadgeLarge;
} else if (chainId === ChainId.optimism) {
val = isDarkMode ? OptimismBadgeLargeDark : OptimismBadgeLarge;
Expand All @@ -96,7 +102,9 @@ export default function ChainBadge({
val = isDarkMode ? DegenBadgeLargeDark : DegenBadgeLarge;
}
} else {
if (chainId === ChainId.arbitrum) {
if (chainId === ChainId.apechain) {
val = isDarkMode ? ApechainBadgeDark : ApechainBadge;
} else if (chainId === ChainId.arbitrum) {
val = isDarkMode ? ArbitrumBadgeDark : ArbitrumBadge;
} else if (chainId === ChainId.optimism) {
val = isDarkMode ? OptimismBadgeDark : OptimismBadge;
Expand Down
10 changes: 7 additions & 3 deletions src/components/gas/GasSpeedButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -328,11 +328,15 @@ const GasSpeedButton = ({
const estimatedTime = (selectedGasFee?.estimatedTime?.display || '').split(' ');
const [estimatedTimeValue = '0', estimatedTimeUnit = 'min'] = estimatedTime;
const time = parseFloat(estimatedTimeValue).toFixed(0);

const timeSymbol = estimatedTimeUnit === 'hr' ? '>' : '~';
if (!estimatedTime || (time === '0' && estimatedTimeUnit === 'min')) {
if (!estimatedTime) {
return '';
}

if (time === '0') {
return '< 1 sec';
}

const timeSymbol = estimatedTimeUnit === 'hr' ? '>' : '~';
Comment on lines +331 to +339
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was displaying ~ 0 sec so yeah

return `${timeSymbol}${time} ${estimatedTimeUnit}`;
}, [
crossChainServiceTime,
Expand Down
4 changes: 2 additions & 2 deletions src/languages/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,7 @@
},
"avalanche": {
"text": "Avalanche is a sidechain, a distinct network that runs alongside Ethereum and is compatible with it.\n\nIt allows for cheaper and faster transactions, but unlike Layer 2 networks, Avalanche has its own security and consensus mechanisms that differ from Ethereum.",
"title": "What's Avalanche"
"title": "What's Avalanche?"
},
"degen": {
"text": "Degen Chain is a Layer 3 network that runs on top of Arbitrum Orbit and Ethereum.",
Expand All @@ -944,7 +944,7 @@
"title": "What's Blast?"
},
"apechain": {
"text": "ApeChain is a Layer 3 network that runs on top of Arbitrum Orbit and Ethereum. It significantly enhances ApeCoin's utility, fostering a robust and dynamic economy driven by $APE.",
"text": "ApeChain is a Layer 3 network that runs on top of Arbitrum Orbit and Ethereum.\n\nIt significantly enhances ApeCoin's utility, fostering a robust and dynamic economy driven by $APE.",
"title": "What's ApeChain?"
},
"zora": {
Expand Down
4 changes: 3 additions & 1 deletion src/redux/gas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ const getUpdatedGasFeeParams = (
case ChainId.degen:
nativeTokenPriceUnit = ethereumUtils.getDegenPriceUnit();
break;
case ChainId.apechain:
nativeTokenPriceUnit = ethereumUtils.getApechainPriceUnit();
break;
Comment on lines +140 to +142
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!! This needs to be backend driven too

default:
nativeTokenPriceUnit = ethereumUtils.getEthPriceUnit();
break;
Expand Down Expand Up @@ -341,7 +344,6 @@ export const gasPricesStartPolling =
const meteorologySupportsChainId = meteorologySupportedChainIds.includes(chainId);
if (!meteorologySupportsChainId) {
const adjustedGasFees = await getProviderGasPrices({ chainId });

if (!adjustedGasFees) return;

const gasFeeParamsBySpeed = parseL2GasPrices(adjustedGasFees);
Expand Down
15 changes: 15 additions & 0 deletions src/screens/ExplainSheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ const DEGEN_EXPLAINER = lang.t('explain.degen.text');

const BLAST_EXPLAINER = lang.t('explain.blast.text');

const APECHAIN_EXPLAINER = lang.t('explain.apechain.text');

const ZORA_EXPLAINER = lang.t('explain.zora.text');

const SWAP_RESET_EXPLAINER = `Rainbow doesn’t have the ability to swap across networks yet, but we’re on it. For now, Rainbow will match networks between selected tokens.`;
Expand Down Expand Up @@ -494,6 +496,19 @@ export const explainers = (params, theme) => {
text: BLAST_EXPLAINER,
title: lang.t('explain.blast.title'),
},
apechain: {
emoji: '⛽️',
extraHeight: 144,
logo: <ChainBadge chainId={ChainId.apechain} marginBottom={8} position="relative" size="large" />,
readMoreLink: buildRainbowLearnUrl({
url: 'https://learn.rainbow.me/layer-2-and-layer-3-networks',
query: {
campaign: 'explain',
},
}),
text: APECHAIN_EXPLAINER,
title: lang.t('explain.apechain.title'),
},
failed_wc_connection: {
emoji: '😵',
extraHeight: -50,
Expand Down
3 changes: 3 additions & 0 deletions src/utils/ethereumUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
BNB_MAINNET_ADDRESS,
AVAX_AVALANCHE_ADDRESS,
DEGEN_CHAIN_DEGEN_ADDRESS,
APECOIN_APECHAIN_ADDRESS,
} from '@/references';
import Routes from '@/navigation/routesNames';
import { logger, RainbowError } from '@/logger';
Expand Down Expand Up @@ -207,6 +208,7 @@ const getMaticPriceUnit = () => getAssetPrice(MATIC_MAINNET_ADDRESS);
const getBnbPriceUnit = () => getAssetPrice(BNB_MAINNET_ADDRESS);
const getAvaxPriceUnit = () => getAssetPrice(getUniqueId(AVAX_AVALANCHE_ADDRESS, ChainId.avalanche));
const getDegenPriceUnit = () => getAssetPrice(getUniqueId(DEGEN_CHAIN_DEGEN_ADDRESS, ChainId.degen));
const getApechainPriceUnit = () => getAssetPrice(getUniqueId(APECOIN_APECHAIN_ADDRESS, ChainId.apechain));

const getBalanceAmount = (
selectedGasFee: SelectedGasFee | LegacySelectedGasFee,
Expand Down Expand Up @@ -527,6 +529,7 @@ export default {
getBnbPriceUnit,
getAvaxPriceUnit,
getDegenPriceUnit,
getApechainPriceUnit,
getNativeAssetForNetwork,
getNetworkNativeAsset,
getPriceOfNativeAssetForNetwork,
Expand Down
Loading