Skip to content

Commit

Permalink
fix: fix error on stake screen
Browse files Browse the repository at this point in the history
  • Loading branch information
WaDadidou committed May 14, 2024
1 parent 5402f69 commit 34decdc
Showing 1 changed file with 40 additions and 39 deletions.
79 changes: 40 additions & 39 deletions packages/screens/Stake/components/ValidatorsList.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Decimal } from "@cosmjs/math";
import {Decimal} from "@cosmjs/math";

Check failure on line 1 in packages/screens/Stake/components/ValidatorsList.tsx

View workflow job for this annotation

GitHub Actions / lint-and-build

Replace `Decimal` with `·Decimal·`
import React from "react";
import {
ActivityIndicator,
Expand All @@ -8,19 +8,19 @@ import {
ViewStyle,
} from "react-native";

import { BrandText } from "@/components/BrandText";
import { PrimaryButtonOutline } from "@/components/buttons/PrimaryButtonOutline";
import { SecondaryButtonOutline } from "@/components/buttons/SecondaryButtonOutline";
import { RoundedGradientImage } from "@/components/images/RoundedGradientImage";
import { SpacerRow } from "@/components/spacer";
import { TableColumns, TableHeader } from "@/components/table/TableHeader";
import { useCosmosValidatorBondedAmount } from "@/hooks/useCosmosValidatorBondedAmount";
import { useIsMobile } from "@/hooks/useIsMobile";
import { useKeybaseAvatarURL } from "@/hooks/useKeybaseAvatarURL";
import { Reward, rewardsPrice, useRewards } from "@/hooks/useRewards";
import { UserKind, getStakingCurrency, parseUserId } from "@/networks";
import { prettyPrice } from "@/utils/coins";
import { removeObjectKey, removeObjectKeys } from "@/utils/object";
import {BrandText} from "@/components/BrandText";

Check failure on line 11 in packages/screens/Stake/components/ValidatorsList.tsx

View workflow job for this annotation

GitHub Actions / lint-and-build

Replace `BrandText` with `·BrandText·`
import {PrimaryButtonOutline} from "@/components/buttons/PrimaryButtonOutline";

Check failure on line 12 in packages/screens/Stake/components/ValidatorsList.tsx

View workflow job for this annotation

GitHub Actions / lint-and-build

Replace `PrimaryButtonOutline` with `·PrimaryButtonOutline·`
import {SecondaryButtonOutline} from "@/components/buttons/SecondaryButtonOutline";

Check failure on line 13 in packages/screens/Stake/components/ValidatorsList.tsx

View workflow job for this annotation

GitHub Actions / lint-and-build

Replace `SecondaryButtonOutline` with `·SecondaryButtonOutline·`
import {RoundedGradientImage} from "@/components/images/RoundedGradientImage";

Check failure on line 14 in packages/screens/Stake/components/ValidatorsList.tsx

View workflow job for this annotation

GitHub Actions / lint-and-build

Replace `RoundedGradientImage` with `·RoundedGradientImage·`
import {SpacerRow} from "@/components/spacer";

Check failure on line 15 in packages/screens/Stake/components/ValidatorsList.tsx

View workflow job for this annotation

GitHub Actions / lint-and-build

Replace `SpacerRow` with `·SpacerRow·`
import {TableColumns, TableHeader} from "@/components/table/TableHeader";

Check failure on line 16 in packages/screens/Stake/components/ValidatorsList.tsx

View workflow job for this annotation

GitHub Actions / lint-and-build

Replace `TableColumns,·TableHeader` with `·TableColumns,·TableHeader·`
import {useCosmosValidatorBondedAmount} from "@/hooks/useCosmosValidatorBondedAmount";

Check failure on line 17 in packages/screens/Stake/components/ValidatorsList.tsx

View workflow job for this annotation

GitHub Actions / lint-and-build

Replace `useCosmosValidatorBondedAmount` with `·useCosmosValidatorBondedAmount·`
import {useIsMobile} from "@/hooks/useIsMobile";
import {useKeybaseAvatarURL} from "@/hooks/useKeybaseAvatarURL";
import {Reward, rewardsPrice, useRewards} from "@/hooks/useRewards";
import {UserKind, getStakingCurrency, parseUserId} from "@/networks";
import {prettyPrice} from "@/utils/coins";
import {removeObjectKey, removeObjectKeys} from "@/utils/object";
import {
errorColor,
mineShaftColor,
Expand All @@ -29,9 +29,9 @@ import {
successColor,
yellowDefault,
} from "@/utils/style/colors";
import { fontSemibold11, fontSemibold13 } from "@/utils/style/fonts";
import { layout } from "@/utils/style/layout";
import { ValidatorInfo } from "@/utils/types/staking";
import {fontSemibold11, fontSemibold13} from "@/utils/style/fonts";
import {layout} from "@/utils/style/layout";
import {ValidatorInfo} from "@/utils/types/staking";

const serviceScoreSize = 24;

Expand Down Expand Up @@ -82,7 +82,7 @@ export const ValidatorsTable: React.FC<{
style?: StyleProp<ViewStyle>;
userId: string | undefined;
userKind: UserKind;
}> = ({ validators: validatorsProp, actions, style, userId, userKind }) => {
}> = ({validators: validatorsProp, actions, style, userId, userKind}) => {
const isMobile = useIsMobile();

const [sortBy, setSortBy] = React.useState<string>("rank");
Expand All @@ -103,20 +103,21 @@ export const ValidatorsTable: React.FC<{
const COLUMNS = userId
? COLUMNS_TMP
: removeObjectKeys(COLUMNS_TMP, ["staked", "claimable"]);
const { rewards, claimReward } = useRewards(userId, userKind);
const {rewards, claimReward} = useRewards(userId, userKind);

return (
<>
<TableHeader
columns={COLUMNS}
allowSelect={["rank", "serviceScore"]}
onPressItem={(key) => setSortBy(key)}
style={{
paddingHorizontal: layout.spacing_x2_5,
}}
/>
<FlatList
data={validators}
style={style}
keyExtractor={(item) => item.address}
renderItem={({ item }) => (
renderItem={({item}) => (
<ValidatorRow
validator={item}
userId={userId}
Expand All @@ -138,14 +139,14 @@ const ValidatorRow: React.FC<{
claimReward: (validatorAddress: string) => Promise<void>;
actions?: (validator: ValidatorInfo) => ValidatorsListAction[];
userId: string | undefined;
}> = ({ validator, claimReward, pendingRewards, actions, userId }) => {
}> = ({validator, claimReward, pendingRewards, actions, userId}) => {
const isMobile = useIsMobile();
const imageURL = useKeybaseAvatarURL(validator.identity);
const [network, userAddress] = parseUserId(userId);
// Rewards price with all denoms
const claimablePrice = rewardsPrice(pendingRewards);
const stakingCurrency = getStakingCurrency(network?.id);
const { bondedTokens } = useCosmosValidatorBondedAmount(
const {bondedTokens} = useCosmosValidatorBondedAmount(
userId,
validator?.address,
);
Expand All @@ -168,7 +169,7 @@ const ValidatorRow: React.FC<{
<BrandText
style={[
isMobile ? fontSemibold11 : fontSemibold13,
{ flex: TABLE_COLUMNS.rank.flex, paddingRight: layout.spacing_x1 },
{flex: TABLE_COLUMNS.rank.flex, paddingRight: layout.spacing_x1},
]}
>
{validator.rank}
Expand All @@ -182,9 +183,9 @@ const ValidatorRow: React.FC<{
paddingRight: layout.spacing_x1,
}}
>
<RoundedGradientImage size="XS" sourceURI={imageURL} />
<RoundedGradientImage size="XS" sourceURI={imageURL}/>

<SpacerRow size={1} />
<SpacerRow size={1}/>
<BrandText
style={[isMobile ? fontSemibold11 : fontSemibold13]}
numberOfLines={1}
Expand All @@ -205,14 +206,14 @@ const ValidatorRow: React.FC<{
{validator.votingPowerPercent.toFixed(2)}%
{!!stakingCurrency &&
" - " +
prettyPrice(
network?.id,
Decimal.fromUserInput(
validator.votingPower,
stakingCurrency?.decimals,
).atomics,
stakingCurrency?.denom,
)}
prettyPrice(
network?.id,
Decimal.fromUserInput(
validator.votingPower,
stakingCurrency?.decimals,
).atomics,
stakingCurrency?.denom,
)}
</BrandText>
<View
style={{
Expand All @@ -224,7 +225,7 @@ const ValidatorRow: React.FC<{
}}
>
{validator.serviceScore === undefined ? (
<ActivityIndicator size={serviceScoreSize} />
<ActivityIndicator size={serviceScoreSize}/>
) : (
<>
<View
Expand All @@ -240,7 +241,7 @@ const ValidatorRow: React.FC<{
<BrandText
style={[
isMobile ? fontSemibold11 : fontSemibold13,
{ color: mapScoreToColor(validator.serviceScore) },
{color: mapScoreToColor(validator.serviceScore)},
]}
>
{validator.serviceScore === null
Expand Down Expand Up @@ -303,8 +304,8 @@ const ValidatorRow: React.FC<{
size={isMobile ? "XXS" : "XS"}
style={
isMobile
? { paddingTop: layout.spacing_x1 }
: { paddingLeft: layout.spacing_x2 }
? {paddingTop: layout.spacing_x1}
: {paddingLeft: layout.spacing_x2}
}
text="Claim"
disabled={!userAddress}
Expand Down

0 comments on commit 34decdc

Please sign in to comment.