Skip to content

Commit

Permalink
7.2.2 (#354)
Browse files Browse the repository at this point in the history
* St 353 display chain selection on inactive chain click in OtherChainButtons (#329)

* WIP: chains display prefs open

* feat: open preferences on click

* cleanup

* cleanup

* feat: swap terra.kitchen/utils for @terra-money/terra-utils (#321)

* feat: guard against empty networks, chaindID, or lcd (#327)

* feat: kado integration and updated wallet buttons (#320)

* feat: kado integration and updated wallet buttons

* Fix passing/not passing

* fix prettier

* fix z-index for LatestTx popup

* fix chain filter (#344)

* fix: val name on stake withdraw (#349)

* fix: val name on stake withdraw

* cleanup

* feat: add empty condition if no staking rewards

* cleanup

* Fix ICS20 out of gas error (#350)

* ST-390: show undelegations if nothing is staked (#351)

* show undelegations if nothing is staked

* fix: no rewards message conditional

Do not display "None on selected chain" message under staking rewards while network is loading.

* fix: translate alert message

---------

Co-authored-by: Manuel Alessandro Collazo <[email protected]>

* ST-391: fix chain filer bug when switching between mainnet, testnet and classic (#352)

* fix chain filter

* if "all" is not an option select terra

---------

Co-authored-by: plubber <[email protected]>
Co-authored-by: Mike <[email protected]>
Co-authored-by: Alessandro Candeago <[email protected]>
Co-authored-by: plubber <[email protected]>
  • Loading branch information
5 people authored Apr 25, 2023
1 parent a2e99fa commit 422bc4c
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 12 deletions.
5 changes: 3 additions & 2 deletions src/components/general/ValidatorLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import { InternalLink } from "./Internal"
interface Props {
address: ValAddress
internal?: boolean
chainID?: string
}

const ValidatorLink = ({ address, internal }: Props) => {
const ValidatorLink = ({ address, internal, chainID }: Props) => {
const { data: validator } = useValidator(address)

const render = () => {
Expand All @@ -19,7 +20,7 @@ const ValidatorLink = ({ address, internal }: Props) => {
return internal ? (
<InternalLink to={`/validator/${address}`}>{moniker}</InternalLink>
) : (
<FinderLink value={address} validator>
<FinderLink chainID={chainID} value={address} validator>
{moniker}
</FinderLink>
)
Expand Down
11 changes: 9 additions & 2 deletions src/components/layout/ChainFilter.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import classNames from "classnames"
import { useNetwork } from "data/wallet"
import { useChainID, useNetwork } from "data/wallet"
import { useState, memo, useMemo, useRef, useEffect } from "react"
import { useTranslation } from "react-i18next"
import styles from "./ChainFilter.module.scss"
Expand Down Expand Up @@ -36,6 +36,7 @@ const ChainFilter = ({
const { displayChains } = useDisplayChains()
const { selectedDisplayChain, changeSelectedDisplayChain } =
useSelectedDisplayChain()
const terraChainID = useChainID()
const sortedDisplayChains = useSortedDisplayChains()

useEffect(() => {
Expand Down Expand Up @@ -144,14 +145,20 @@ const ChainFilter = ({
} else {
setChain(savedChain)
}
}, [terraOnly])
}, [terraOnly]) // eslint-disable-line

const handleSetChain = (chain: string | undefined) => {
setChain(chain)
changeSavedChain(chain)
changeSelectedDisplayChain(chain)
}

useEffect(() => {
if (selectedChain !== undefined && network[selectedChain] === undefined) {
handleSetChain(all ? undefined : terraChainID)
}
}, [network]) // eslint-disable-line

return (
<div className={outside ? styles.chainfilter__out : styles.chainfilter}>
<div
Expand Down
14 changes: 12 additions & 2 deletions src/pages/stake/Stake.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
useInterchainDelegations,
useCalcDelegationsByValidator,
useInterchainValidators,
useInterchainUnbondings,
} from "data/queries/staking"
import QuickStake from "./QuickStake"
import { TooltipIcon } from "components/display"
Expand All @@ -25,7 +26,16 @@ const Stake = () => {

const interchainDelegations = useInterchainDelegations()
const interchainValidators = useInterchainValidators()
const state = combineState(...interchainDelegations, ...interchainValidators)
const interchainUnbondings = useInterchainUnbondings()
const state = combineState(
...interchainDelegations,
...interchainValidators,
...interchainUnbondings
)
const unbondings = interchainUnbondings.reduce(
(acc, { data }) => (data ? [...data, ...acc] : acc),
[] as any[]
)

const { graphData } = useCalcDelegationsByValidator(
interchainDelegations,
Expand Down Expand Up @@ -56,7 +66,7 @@ const Stake = () => {
}
>
<Col>
{graphData?.all.length ? (
{graphData?.all.length || unbondings.length ? (
<Row>
<Col span={2}>
<div className={styles.forFetchingBar}>
Expand Down
8 changes: 6 additions & 2 deletions src/pages/stake/StakedDonut.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ const StakedDonut = ({ chain }: { chain: string }) => {

return (
<>
{graphData && graphData[chain || "all"] ? (
{graphData && graphData[chain || "all"]?.length ? (
<section className={styles.graphContainer}>
<ResponsiveContainer>
<PieChart>
Expand Down Expand Up @@ -168,7 +168,11 @@ const StakedDonut = ({ chain }: { chain: string }) => {
<h1 className={styles.title}>{t("No Delegations")}</h1>

<Grid gap={8}>
<p>{t("There are no delegations on this chain.")}</p>
<p>
{chain
? t("There are no delegations on this chain.")
: t("There are no delegations.")}
</p>
</Grid>
</section>
</article>
Expand Down
4 changes: 3 additions & 1 deletion src/pages/stake/components/StakedCard.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useTranslation } from "react-i18next"
import { PropsWithChildren } from "react"
import BigNumber from "bignumber.js"
import { Grid, Card, Flex } from "components/layout"
Expand All @@ -17,6 +18,7 @@ interface Props extends CardProps {
const StakedCard = (props: PropsWithChildren<Props>) => {
const { value, amount, denom, showTokens, children } = props
const currency = useCurrency()
const { t } = useTranslation()

return (
<Card
Expand Down Expand Up @@ -51,7 +53,7 @@ const StakedCard = (props: PropsWithChildren<Props>) => {
</Flex>
) : (
<Grid style={{ alignItems: "end", height: "100%" }}>
None on selected chain
{!props.isLoading ? t("None on selected chain") : ""}
</Grid>
)}
</Card>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/wallet/SendPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ const SendPage = () => {
gasAdjustment:
getChainIDFromAddress(addresses?.[chain ?? ""], networks) !== chain &&
AccAddress.validate(token?.denom ?? "")
? 1.5
? 2
: 1,
}

Expand Down
9 changes: 7 additions & 2 deletions src/txs/stake/WithdrawRewardsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { ValidatorLink } from "components/general"
import { Form, FormArrow, FormItem, Checkbox } from "components/form"
import { Card, Flex, Grid } from "components/layout"
import { TokenCard, TokenCardGrid } from "components/token"
import { Empty } from "components/feedback"
import styles from "./WithdrawRewardsForm.module.scss"
import Tx from "txs/Tx"
import { useInterchainAddresses } from "auth/hooks/useAddress"
Expand Down Expand Up @@ -73,7 +74,7 @@ const WithdrawRewardsForm = ({ rewards, validators, chain }: Props) => {
/* calc */
const selectedTotal = selected.reduce<Record<Denom, Amount>>(
(prev, address) => {
const item = byValidator.find((item) => item.address === address)
const item = byValidator.find((i) => i.address === address)

if (!item) return prev

Expand Down Expand Up @@ -129,6 +130,10 @@ const WithdrawRewardsForm = ({ rewards, validators, chain }: Props) => {
onSuccess: () => reset(),
}

if (Object.keys(selectedTotal).length === 0) {
return <Empty>{t("No rewards on selected chain")}</Empty>
}

return (
<Tx {...tx}>
{({ fee, submit }) => (
Expand Down Expand Up @@ -188,7 +193,7 @@ const WithdrawRewardsForm = ({ rewards, validators, chain }: Props) => {
key={address}
>
<div className={styles.item}>
<ValidatorLink address={address} />
<ValidatorLink chainID={chain} address={address} />
</div>
</Checkbox>
)
Expand Down

0 comments on commit 422bc4c

Please sign in to comment.