Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Szegoo committed Sep 19, 2024
1 parent 416c514 commit d9a0d6b
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 14 deletions.
20 changes: 14 additions & 6 deletions src/components/Panels/SaleInfoPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@ import ListIcon from '@/assets/list.png';
import ShoppingIcon from '@/assets/shopping.png';
import { useCoretimeApi } from '@/contexts/apis';
import { useSaleInfo } from '@/contexts/sales';
import { SalePhase } from '@/models';
import { NetworkType, SalePhase } from '@/models';

import { DetailCard } from './DetailCard';
import styles from './index.module.scss';
import { useNetwork } from '@/contexts/network';

export const SaleInfoPanel = () => {
const theme = useTheme();

const { network } = useNetwork();

const {
state: { symbol, decimals },
} = useCoretimeApi();
Expand Down Expand Up @@ -94,6 +97,8 @@ export const SaleInfoPanel = () => {
},
}}
button={
// https://polkadot.polkassembly.io/referenda/1172
network !== NetworkType.POLKADOT &&
<Button
onClick={onAnalyze}
size='small'
Expand All @@ -110,11 +115,14 @@ export const SaleInfoPanel = () => {
}
/>
</Box>
<PriceModal
open={priceModalOpen}
onClose={() => openPriceModal(false)}
data-cy='price-modal'
/>
{/* https://polkadot.polkassembly.io/referenda/1172 */}
{network !== NetworkType.POLKADOT &&
<PriceModal
open={priceModalOpen}
onClose={() => openPriceModal(false)}
data-cy='price-modal'
/>
}
</>
);
};
2 changes: 1 addition & 1 deletion src/contexts/network/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const NetworkProvider = ({ children }: Props) => {
useEffect(() => {
if (!router.isReady) return;
if (network === 'polkadot') setActiveNetwork(NetworkType.POLKADOT);
if (network === 'kusama') setActiveNetwork(NetworkType.KUSAMA);
else if (network === 'kusama') setActiveNetwork(NetworkType.KUSAMA);
else if (network === 'rococo') setActiveNetwork(NetworkType.ROCOCO);
else if (network === 'westend') setActiveNetwork(NetworkType.WESTEND);
else {
Expand Down
10 changes: 8 additions & 2 deletions src/contexts/sales/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { getCorePriceAt, getCurrentPhase } from '@/utils/sale';
import {
BrokerStatus,
ContextStatus,
NetworkType,
PhaseEndpoints,
RELAY_CHAIN_BLOCK_TIME,
SaleConfig,
Expand Down Expand Up @@ -90,7 +91,7 @@ interface Props {
const SaleInfoProvider = ({ children }: Props) => {
const { network } = useNetwork();
const {
state: { api: coretimeApi, isApiReady: isCoretimeReady, height },
state: { api: coretimeApi, isApiReady: isCoretimeReady, height, decimals, },
timeslicePeriod,
} = useCoretimeApi();

Expand All @@ -109,6 +110,11 @@ const SaleInfoProvider = ({ children }: Props) => {
}, [saleInfo.saleStart, height, currentPhase]);

useEffect(() => {
// https://polkadot.polkassembly.io/referenda/1172
if (network === NetworkType.POLKADOT) {
setCurrentPrice(100 * Math.pow(10, decimals));
return;
}
setCurrentPrice(
status !== ContextStatus.LOADED || height === 0 ? undefined : getCorePriceAt(at, saleInfo)
);
Expand Down Expand Up @@ -186,7 +192,7 @@ const SaleInfoProvider = ({ children }: Props) => {
useEffect(() => {
if (height === 0) return;
setCurrentPhase(getCurrentPhase(saleInfo, height));
}, [saleInfo, height]);
}, [network, saleInfo, height]);

return (
<SaleDataContext.Provider
Expand Down
8 changes: 4 additions & 4 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ export default function MyApp(props: MyAppProps) {
<meta name='viewport' content='initial-scale=1, width=device-width' />
<title>Coretime Hub</title>
</Head>
<UtilProviders>
<NetworkProvider>
<NetworkProvider>
<UtilProviders>
<AccountProvider>
<ApiProviders>
<BalanceProvider>
Expand All @@ -101,8 +101,8 @@ export default function MyApp(props: MyAppProps) {
</BalanceProvider>
</ApiProviders>
</AccountProvider>
</NetworkProvider>
</UtilProviders>
</UtilProviders>
</NetworkProvider>
<Analytics />
</CacheProvider>
);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const Home = () => {
],
bottom: {
label: 'Total Burn',
value: totalBurn ? formatBalance(totalBurn) : '...',
value: formatBalance(totalBurn),
dataCy: 'total-burn',
},
},
Expand Down
2 changes: 2 additions & 0 deletions src/utils/functions/timestamps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ export const getBlockTime = (network: NetworkType): number => {
return 6 * 1000;
case NetworkType.KUSAMA:
return 12 * 1000;
case NetworkType.POLKADOT:
return 12 * 1000;
default:
return 0;
}
Expand Down

0 comments on commit d9a0d6b

Please sign in to comment.