Skip to content

Commit

Permalink
chore: continue with platform
Browse files Browse the repository at this point in the history
  • Loading branch information
icfor committed Jan 22, 2024
1 parent a03efce commit a847f6d
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 8 deletions.
13 changes: 13 additions & 0 deletions src/components/icons/icon_warning.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 24 additions & 1 deletion src/screens/staking/components/staking_hero/index.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
import Trans from "next-translate/Trans";
import useTranslation from "next-translate/useTranslation";
import { useEffect } from "react";

import CtaButton from "@src/components/cta-button";
import HighlightButton from "@src/components/highlight-button";
import {
getAllAccounts,
getAllRewards,
getAllStaked,
getCoinPriceForNetwork,
setSelectedAccount,
useStakingRef,
} from "@src/screens/staking/lib/staking_sdk/context";
import { accountHasRewards } from "@src/screens/staking/lib/staking_sdk/utils/accounts";
import {
accountHasRewards,
filterOutTestnets,
filterUniqueAddresses,
} from "@src/screens/staking/lib/staking_sdk/utils/accounts";

import * as styles from "./index.module.scss";

Expand All @@ -25,6 +31,23 @@ const StakingHero = () => {

const { hasInit } = stakingRef.current.state;

useEffect(() => {
if (hasInit) {
const filteredAccounts = getAllAccounts(stakingRef.current.state)
.filter(filterUniqueAddresses())
.filter(filterOutTestnets);

const networks = new Set(
filteredAccounts.map((account) => account.networkId),
);

// Once it has init, fetch all coin prices for all the networks
Array.from(networks).forEach((networkId) => {
getCoinPriceForNetwork(stakingRef.current, networkId);
});
}
}, [hasInit, stakingRef]);

if (!hasInit) return null;

const accounts = getAllAccounts(stakingRef.current.state);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
}

.info {
background: #dbedff;
border-left: 2px solid #007fff;
background: #fffbd8;
border-left: 2px solid rgba(237, 213, 0, 1);
border-radius: 8px;
box-shadow:
0 1px 10px 0 rgba(16, 24, 40, 0.05),
Expand Down Expand Up @@ -68,7 +68,7 @@
line-height: 20px;

b {
color: #007fff;
color: #e4a11e;
font-size: 14px;
font-style: normal;
font-weight: 600;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useEffect, useState } from "react";

import FormInput from "@src/components/form_input";
import HighlightButton from "@src/components/highlight-button";
import IconInfoCircle from "@src/components/icons/info_circle_blue.svg";
import IconWarning from "@src/components/icons/icon_warning.svg";
import LoadingSpinner from "@src/components/loading_spinner";
import { toastSuccess } from "@src/components/notification";
import { displayGenericError } from "@src/screens/staking/lib/error";
Expand Down Expand Up @@ -224,7 +224,7 @@ const UnstakingModal = () => {
/>
{!!memoError && <ModalError>{memoError}</ModalError>}
<div className={styles.info}>
<IconInfoCircle />
<IconWarning />
<div className={styles.infoContent}>
<div className={styles.title}>{t("unstakingModal.infoTitle")}</div>
{networkInfo ? (
Expand Down
4 changes: 2 additions & 2 deletions src/screens/staking/lib/staking_sdk/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ const getCoinPrice = async (
context: TStakingContext,
denom: CoinDenom,
): Promise<string> => {
const { setState, state } = context;
const { state } = context;

const coinPrice = state.coinsPrices[denom];

Expand All @@ -179,7 +179,7 @@ const getCoinPrice = async (
if (coinRequest) return coinRequest;

const newRequest = geckoClient.getCoinPrice(denom).then((price): string => {
setState((prevState) => ({
context.setState((prevState) => ({
...prevState,
coinsPrices: {
...prevState.coinsPrices,
Expand Down

0 comments on commit a847f6d

Please sign in to comment.