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 empty proposer & remove desmos #280

Merged
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
1 change: 0 additions & 1 deletion react-app/config/config.template.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ window.appConfig = {
coinDecimals: 9,
},
},
desmosRpc: "https://rpc.mainnet.desmos.network",
graphql: {
endpoint: "http://localhost:8080/graphql",
},
Expand Down
1 change: 0 additions & 1 deletion react-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"@cosmjs/stream": "^0.28.4",
"@cosmjs/tendermint-rpc": "^0.28.4",
"@cosmjs/utils": "^0.28.4",
"@desmoslabs/desmjs": "2.0.0-beta.4",
"@graphql-codegen/introspection": "^2.1.1",
"@headlessui/react": "^1.6.1",
"@oursky/react-messageformat": "^2.0.2",
Expand Down
7 changes: 0 additions & 7 deletions react-app/src/clients/queryClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
setupSlashingExtension,
} from "@cosmjs/stargate/build/modules";
import { Tendermint34Client } from "@cosmjs/tendermint-rpc";
import { DesmosClient } from "@desmoslabs/desmjs";
import { ChainInfo } from "../config/Config";

export type ExtendedQueryClient = QueryClient &
Expand Down Expand Up @@ -51,12 +50,6 @@ export const newQueryClient = async (
);
};

export const newDesmosQueryClient = async (
desmosRpc: string
): Promise<DesmosClient> => {
return DesmosClient.connect(desmosRpc);
};

export const newStargateClient = async (
chainInfo: ChainInfo
): Promise<StargateClient> => {
Expand Down
28 changes: 2 additions & 26 deletions react-app/src/components/DummyScreen/DummyScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React, { useCallback, useEffect, useState } from "react";
import React, { useCallback, useState } from "react";
import cn from "classnames";
import * as Sentry from "@sentry/react";
import { Link } from "react-router-dom";
import { Profile } from "@desmoslabs/desmjs-types/desmos/profiles/v1beta1/models_profile";
import { useQuery, useLazyQuery } from "@apollo/client";
import AppRoutes from "../../navigation/AppRoutes";
import LocalizedText from "../common/Localized/LocalizedText";
Expand All @@ -15,8 +14,6 @@ import {
MeQueryQuery,
} from "../../generated/graphql";
import { useAuth } from "../../providers/AuthProvider";
import { useQueryClient } from "../../providers/QueryClientProvider";
import { ConnectionStatus, useWallet } from "../../providers/WalletProvider";
import * as SectionedTable from "../SectionedTable/SectionedTable";
import AppButton from "../common/Buttons/AppButton";

Expand Down Expand Up @@ -74,10 +71,7 @@ const dummyTableItems: SectionedTable.SectionItem<DummyTableItem>[] = [
const DummyScreen: React.FC = () => {
const { setLocale } = useLocale();
const auth = useAuth();
const { desmosQuery } = useQueryClient();
const wallet = useWallet();

const [profile, setProfile] = useState<Profile | null>(null);
const [dummyTableSort, setDummyTableSort] =
useState<SectionedTable.ColumnOrder | null>(null);

Expand Down Expand Up @@ -125,18 +119,6 @@ const DummyScreen: React.FC = () => {
Sentry.captureException(new Error("This is my fake error message"));
}, []);

useEffect(() => {
// test desmos query client on Oursky portfolio
if (wallet.status === ConnectionStatus.Connected) {
desmosQuery
.getProfile("desmos1ze7n3xsfd7na2saj070v0cx0eu7twng9dxxrlt")
.then((res) => {
setProfile(res);
})
.catch((err) => console.error("Failed to query desmos profile =", err));
}
}, [setProfile, wallet, desmosQuery]);

return (
<div
className={cn(
Expand Down Expand Up @@ -245,13 +227,7 @@ const DummyScreen: React.FC = () => {
Go to Overview Screen
</Link>
</div>
<pre>
{JSON.stringify(
{ dtag: profile?.dtag, pictures: profile?.pictures },
null,
4
)}
</pre>

<div className={cn("flex", "flex-row", "gap-x-2")}>
<button
type="button"
Expand Down
61 changes: 20 additions & 41 deletions react-app/src/components/PortfolioScreen/PortfolioPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,46 +20,28 @@ interface PortfolioPanelProps {
}

const ProfilePicture: React.FC<{
profile: Portfolio["profile"];
className?: string;
}> = ({ profile, className }) => {
const profilePicture = profile?.pictures?.profile;

}> = ({ className }) => {
return (
<div className={cn("flex", "justify-center", className)}>
{profilePicture ? (
<img
className={cn(
"rounded-full",
"w-[120px]",
"h-[120px]",
"sm:w-[180px]",
"sm:h-[180px]",
"object-cover"
)}
src={profilePicture}
alt="profile picture"
<div
className={cn(
"flex",
"justify-center",
"items-center",
"bg-likecoin-secondarygreen",
"rounded-full",
"w-[120px]",
"h-[120px]",
"sm:w-[180px]",
"sm:h-[180px]"
)}
>
<Icon
icon={IconType.Account}
className={cn("w-11", "h-11", "sm:w-16", "sm:h-16")}
/>
) : (
<div
className={cn(
"flex",
"justify-center",
"items-center",
"bg-likecoin-secondarygreen",
"rounded-full",
"w-[120px]",
"h-[120px]",
"sm:w-[180px]",
"sm:h-[180px]"
)}
>
<Icon
icon={IconType.Account}
className={cn("w-11", "h-11", "sm:w-16", "sm:h-16")}
/>
</div>
)}
</div>
</div>
);
};
Expand Down Expand Up @@ -133,14 +115,11 @@ const PortfolioPanel: React.FC<PortfolioPanelProps> = ({
"overflow-x-auto"
)}
>
<ProfilePicture
profile={portfolio.profile}
className={cn("mb-9", "sm:mb-0", "sm:mr-9")}
/>
<ProfilePicture className={cn("mb-9", "sm:mb-0", "sm:mr-9")} />

<div className={cn("flex", "flex-col", "items-start", "w-full")}>
<p className={cn("text-xl", "leading-6", "font-medium", "mb-3")}>
{portfolio.profile?.dtag ?? truncateAddress(portfolio.address)}
{truncateAddress(portfolio.address)}
</p>

<CopyableText
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { useCallback, useMemo, useState } from "react";
import BigNumber from "bignumber.js";
import { useQueryClient } from "../../providers/QueryClientProvider";
import { ConnectionStatus, useWallet } from "../../providers/WalletProvider";
import { translateAddress } from "../../utils/address";
import { useStakingAPI } from "../../api/stakingAPI";
import {
isRequestStateLoaded,
Expand Down Expand Up @@ -32,7 +31,7 @@ export const usePortfolioQuery = (): {
const bankAPI = useBankAPI();
const stakingAPI = useStakingAPI();
const distribution = useDistributionAPI();
const { desmosQuery, query } = useQueryClient();
const { query } = useQueryClient();

const [stakesOrder, setStakesOrder] = useState({
id: "name",
Expand Down Expand Up @@ -61,14 +60,12 @@ export const usePortfolioQuery = (): {
unstakingBalance,
commission,
reward,
profile,
] = await Promise.all([
bankAPI.getAddressBalance(address),
stakingAPI.getAddressStakedBalance(address),
stakingAPI.getUnstakingAmount(address),
distribution.getAddressTotalCommission(address),
distribution.getAddressTotalDelegationRewards(address),
desmosQuery.getProfile(translateAddress(address, "desmos")),
]);

const balance = {
Expand All @@ -81,7 +78,6 @@ export const usePortfolioQuery = (): {
};

return {
profile,
balance,
stakedBalance,
unstakingBalance,
Expand All @@ -91,7 +87,7 @@ export const usePortfolioQuery = (): {
address,
};
},
[bankAPI, stakingAPI, distribution, desmosQuery]
[bankAPI, stakingAPI, distribution]
);

const fetchStakes = useCallback(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Profile } from "@desmoslabs/desmjs-types/desmos/profiles/v1beta1/models_profile";
import { Delegation } from "cosmjs-types/cosmos/staking/v1beta1/staking";
import { BigNumberCoin } from "../../models/coin";
import { ProposalHistory } from "../ProposalHistory/ProposalHistoryModel";
Expand All @@ -13,7 +12,6 @@ export interface Stake {
}

export interface Portfolio {
profile: Profile | null;
balance: BigNumberCoin;
stakedBalance: BigNumberCoin;
unstakingBalance: BigNumberCoin;
Expand Down
57 changes: 22 additions & 35 deletions react-app/src/components/ProposalDetailScreen/ProposalHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React, { useCallback, useEffect, useMemo, useState } from "react";
import React, { useCallback, useMemo } from "react";
import cn from "classnames";
import { isBefore, isWithinInterval } from "date-fns";
import { Link } from "react-router-dom";
import Paper from "../common/Paper/Paper";
import Badge from "../common/Badge/Badge";
import AppButton from "../common/Buttons/AppButton";
import LocalizedText from "../common/Localized/LocalizedText";
import { translateAddress, truncateAddress } from "../../utils/address";
import { truncateAddress } from "../../utils/address";
import UTCDatetime from "../common/DateTime/UTCDatetime";
import { convertBigNumberToLocalizedIntegerString } from "../../utils/number";
import Config from "../../config/Config";
Expand All @@ -16,7 +16,6 @@ import { DefaultReactionMap, ReactionType } from "../reactions/ReactionModel";
import ProposalStatusBadge from "../proposals/ProposalStatusBadge";
import { ProposalStatus } from "../../generated/graphql";
import AppRoutes from "../../navigation/AppRoutes";
import { useQueryClient } from "../../providers/QueryClientProvider";
import { Proposal } from "./ProposalDetailScreenModel";

const CoinDenom = Config.chainInfo.currency.coinDenom;
Expand Down Expand Up @@ -143,22 +142,6 @@ const ProposalTypeAndProposer: React.FC<{ proposal: Proposal }> = ({
}) => {
const { type, proposerAddress, submitTime } = proposal;

const [proposerName, setProposerName] = useState<string>();
const { desmosQuery } = useQueryClient();

useEffect(() => {
desmosQuery
.getProfile(translateAddress(proposerAddress, "desmos"))
.then((res) => {
if (res) {
setProposerName(res.dtag);
}
})
.catch((err) => {
console.error("failed to fetch desmos profile =", err);
});
}, [desmosQuery, proposerAddress]);

return (
<div
className={cn(
Expand All @@ -181,23 +164,27 @@ const ProposalTypeAndProposer: React.FC<{ proposal: Proposal }> = ({
<LocalizedText messageID="ProposalDetail.publishedBy" />
</p>
<div>
<Link
to={AppRoutes.OtherPortfolio.replace(":address", proposerAddress)}
>
<span className={cn("text-sm", "text-likecoin-green")}>
{proposerName ?? truncateAddress(proposerAddress)}
</span>
<span
className={cn(
"text-xs",
"text-likecoin-lightgreen",
"ml-2",
"text-xs"
)}
{proposerAddress ? (
<Link
to={AppRoutes.OtherPortfolio.replace(":address", proposerAddress)}
>
{truncateAddress(proposerAddress)}
</span>
</Link>
<span className={cn("text-sm", "text-likecoin-green")}>
{truncateAddress(proposerAddress)}
</span>
<span
className={cn(
"text-xs",
"text-likecoin-lightgreen",
"ml-2",
"text-xs"
)}
>
{truncateAddress(proposerAddress)}
</span>
</Link>
) : (
<span className={cn("text-sm", "text-likecoin-green")}>-</span>
)}
</div>
<UTCDatetime className={cn("text-xs")} date={submitTime} />
</div>
Expand Down
2 changes: 0 additions & 2 deletions react-app/src/config/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export interface IConfig {
"dsn" | "environment" | "ignoreErrors"
> | null;
chainInfo: ChainInfo;
desmosRpc: string;
graphql: {
endpoint: string;
};
Expand Down Expand Up @@ -66,7 +65,6 @@ const defaultConfig: IConfig = {
coinDecimals: 9,
},
},
desmosRpc: "https://rpc.mainnet.desmos.network",
graphql: {
endpoint: "http://localhost:8080/graphql",
},
Expand Down
Loading