Skip to content

Commit 70f5b17

Browse files
committed
react-app: remove all desmos related code
refs #274
1 parent c6779a2 commit 70f5b17

File tree

10 files changed

+34
-361
lines changed

10 files changed

+34
-361
lines changed

react-app/config/config.template.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ window.appConfig = {
1818
coinDecimals: 9,
1919
},
2020
},
21-
desmosRpc: "https://rpc.mainnet.desmos.network",
2221
graphql: {
2322
endpoint: "http://localhost:8080/graphql",
2423
},

react-app/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"@cosmjs/stream": "^0.28.4",
1616
"@cosmjs/tendermint-rpc": "^0.28.4",
1717
"@cosmjs/utils": "^0.28.4",
18-
"@desmoslabs/desmjs": "2.0.0-beta.4",
1918
"@graphql-codegen/introspection": "^2.1.1",
2019
"@headlessui/react": "^1.6.1",
2120
"@oursky/react-messageformat": "^2.0.2",

react-app/src/clients/queryClient.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import {
2121
setupSlashingExtension,
2222
} from "@cosmjs/stargate/build/modules";
2323
import { Tendermint34Client } from "@cosmjs/tendermint-rpc";
24-
import { DesmosClient } from "@desmoslabs/desmjs";
2524
import { ChainInfo } from "../config/Config";
2625

2726
export type ExtendedQueryClient = QueryClient &
@@ -51,12 +50,6 @@ export const newQueryClient = async (
5150
);
5251
};
5352

54-
export const newDesmosQueryClient = async (
55-
desmosRpc: string
56-
): Promise<DesmosClient> => {
57-
return DesmosClient.connect(desmosRpc);
58-
};
59-
6053
export const newStargateClient = async (
6154
chainInfo: ChainInfo
6255
): Promise<StargateClient> => {

react-app/src/components/DummyScreen/DummyScreen.tsx

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import React, { useCallback, useEffect, useState } from "react";
1+
import React, { useCallback, useState } from "react";
22
import cn from "classnames";
33
import * as Sentry from "@sentry/react";
44
import { Link } from "react-router-dom";
5-
import { Profile } from "@desmoslabs/desmjs-types/desmos/profiles/v1beta1/models_profile";
65
import { useQuery, useLazyQuery } from "@apollo/client";
76
import AppRoutes from "../../navigation/AppRoutes";
87
import LocalizedText from "../common/Localized/LocalizedText";
@@ -15,8 +14,6 @@ import {
1514
MeQueryQuery,
1615
} from "../../generated/graphql";
1716
import { useAuth } from "../../providers/AuthProvider";
18-
import { useQueryClient } from "../../providers/QueryClientProvider";
19-
import { ConnectionStatus, useWallet } from "../../providers/WalletProvider";
2017
import * as SectionedTable from "../SectionedTable/SectionedTable";
2118
import AppButton from "../common/Buttons/AppButton";
2219

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

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

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

128-
useEffect(() => {
129-
// test desmos query client on Oursky portfolio
130-
if (wallet.status === ConnectionStatus.Connected) {
131-
desmosQuery
132-
.getProfile("desmos1ze7n3xsfd7na2saj070v0cx0eu7twng9dxxrlt")
133-
.then((res) => {
134-
setProfile(res);
135-
})
136-
.catch((err) => console.error("Failed to query desmos profile =", err));
137-
}
138-
}, [setProfile, wallet, desmosQuery]);
139-
140122
return (
141123
<div
142124
className={cn(
@@ -245,13 +227,7 @@ const DummyScreen: React.FC = () => {
245227
Go to Overview Screen
246228
</Link>
247229
</div>
248-
<pre>
249-
{JSON.stringify(
250-
{ dtag: profile?.dtag, pictures: profile?.pictures },
251-
null,
252-
4
253-
)}
254-
</pre>
230+
255231
<div className={cn("flex", "flex-row", "gap-x-2")}>
256232
<button
257233
type="button"

react-app/src/components/PortfolioScreen/PortfolioPanel.tsx

Lines changed: 20 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -20,46 +20,28 @@ interface PortfolioPanelProps {
2020
}
2121

2222
const ProfilePicture: React.FC<{
23-
profile: Portfolio["profile"];
2423
className?: string;
25-
}> = ({ profile, className }) => {
26-
const profilePicture = profile?.pictures?.profile;
27-
24+
}> = ({ className }) => {
2825
return (
2926
<div className={cn("flex", "justify-center", className)}>
30-
{profilePicture ? (
31-
<img
32-
className={cn(
33-
"rounded-full",
34-
"w-[120px]",
35-
"h-[120px]",
36-
"sm:w-[180px]",
37-
"sm:h-[180px]",
38-
"object-cover"
39-
)}
40-
src={profilePicture}
41-
alt="profile picture"
27+
<div
28+
className={cn(
29+
"flex",
30+
"justify-center",
31+
"items-center",
32+
"bg-likecoin-secondarygreen",
33+
"rounded-full",
34+
"w-[120px]",
35+
"h-[120px]",
36+
"sm:w-[180px]",
37+
"sm:h-[180px]"
38+
)}
39+
>
40+
<Icon
41+
icon={IconType.Account}
42+
className={cn("w-11", "h-11", "sm:w-16", "sm:h-16")}
4243
/>
43-
) : (
44-
<div
45-
className={cn(
46-
"flex",
47-
"justify-center",
48-
"items-center",
49-
"bg-likecoin-secondarygreen",
50-
"rounded-full",
51-
"w-[120px]",
52-
"h-[120px]",
53-
"sm:w-[180px]",
54-
"sm:h-[180px]"
55-
)}
56-
>
57-
<Icon
58-
icon={IconType.Account}
59-
className={cn("w-11", "h-11", "sm:w-16", "sm:h-16")}
60-
/>
61-
</div>
62-
)}
44+
</div>
6345
</div>
6446
);
6547
};
@@ -125,14 +107,11 @@ const PortfolioPanel: React.FC<PortfolioPanelProps> = ({
125107
</h2>
126108
</div>
127109
<div className={cn("mt-11", "mb-6", "sm:flex")}>
128-
<ProfilePicture
129-
profile={portfolio.profile}
130-
className={cn("mb-9", "sm:mb-0", "sm:mr-9")}
131-
/>
110+
<ProfilePicture className={cn("mb-9", "sm:mb-0", "sm:mr-9")} />
132111

133112
<div className={cn("flex", "flex-col", "items-start")}>
134113
<p className={cn("text-xl", "leading-6", "font-medium", "mb-3")}>
135-
{portfolio.profile?.dtag ?? truncateAddress(portfolio.address)}
114+
{truncateAddress(portfolio.address)}
136115
</p>
137116

138117
<CopyableText

react-app/src/components/PortfolioScreen/PortfolioScreenAPI.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useCallback, useMemo, useState } from "react";
22
import BigNumber from "bignumber.js";
33
import { useQueryClient } from "../../providers/QueryClientProvider";
44
import { ConnectionStatus, useWallet } from "../../providers/WalletProvider";
5-
import { translateAddress, truncateAddress } from "../../utils/address";
5+
import { truncateAddress } from "../../utils/address";
66
import { useStakingAPI } from "../../api/stakingAPI";
77
import {
88
isRequestStateLoaded,
@@ -32,7 +32,7 @@ export const usePortfolioQuery = (): {
3232
const bankAPI = useBankAPI();
3333
const stakingAPI = useStakingAPI();
3434
const distribution = useDistributionAPI();
35-
const { desmosQuery, query } = useQueryClient();
35+
const { query } = useQueryClient();
3636

3737
const [stakesOrder, setStakesOrder] = useState({
3838
id: "name",
@@ -61,14 +61,12 @@ export const usePortfolioQuery = (): {
6161
unstakingBalance,
6262
commission,
6363
reward,
64-
profile,
6564
] = await Promise.all([
6665
bankAPI.getAddressBalance(address),
6766
stakingAPI.getAddressStakedBalance(address),
6867
stakingAPI.getUnstakingAmount(address),
6968
distribution.getAddressTotalCommission(address),
7069
distribution.getAddressTotalDelegationRewards(address),
71-
desmosQuery.getProfile(translateAddress(address, "desmos")),
7270
]);
7371

7472
const balance = {
@@ -81,7 +79,6 @@ export const usePortfolioQuery = (): {
8179
};
8280

8381
return {
84-
profile,
8582
balance,
8683
stakedBalance,
8784
unstakingBalance,
@@ -91,7 +88,7 @@ export const usePortfolioQuery = (): {
9188
address,
9289
};
9390
},
94-
[bankAPI, stakingAPI, distribution, desmosQuery]
91+
[bankAPI, stakingAPI, distribution]
9592
);
9693

9794
const fetchStakes = useCallback(

react-app/src/components/PortfolioScreen/PortfolioScreenModel.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { Profile } from "@desmoslabs/desmjs-types/desmos/profiles/v1beta1/models_profile";
21
import { Delegation } from "cosmjs-types/cosmos/staking/v1beta1/staking";
32
import { BigNumberCoin } from "../../models/coin";
43
import { ProposalHistory } from "../ProposalHistory/ProposalHistoryModel";
@@ -17,7 +16,6 @@ export interface Stake {
1716
}
1817

1918
export interface Portfolio {
20-
profile: Profile | null;
2119
balance: BigNumberCoin;
2220
stakedBalance: BigNumberCoin;
2321
unstakingBalance: BigNumberCoin;

react-app/src/config/Config.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ export interface IConfig {
3737
"dsn" | "environment" | "ignoreErrors"
3838
> | null;
3939
chainInfo: ChainInfo;
40-
desmosRpc: string;
4140
graphql: {
4241
endpoint: string;
4342
};
@@ -66,7 +65,6 @@ const defaultConfig: IConfig = {
6665
coinDecimals: 9,
6766
},
6867
},
69-
desmosRpc: "https://rpc.mainnet.desmos.network",
7068
graphql: {
7169
endpoint: "http://localhost:8080/graphql",
7270
},

react-app/src/providers/QueryClientProvider.tsx

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import React, { useEffect, useMemo, useState } from "react";
2-
import { DesmosClient } from "@desmoslabs/desmjs";
32
import { StargateClient } from "@cosmjs/stargate";
43
import Config from "../config/Config";
54
import {
65
ExtendedQueryClient,
76
newQueryClient,
8-
newDesmosQueryClient,
97
newStargateClient,
108
} from "../clients/queryClient";
119

@@ -15,7 +13,6 @@ interface QueryClientProviderProps {
1513

1614
interface QueryClientProviderContextValue {
1715
query: ExtendedQueryClient;
18-
desmosQuery: DesmosClient;
1916
stargateQuery: StargateClient;
2017
}
2118

@@ -26,24 +23,20 @@ const QueryClientContext = React.createContext<QueryClientProviderContextValue>(
2623
const QueryClientProvider: React.FC<QueryClientProviderProps> = (props) => {
2724
const { children } = props;
2825
const chainInfo = Config.chainInfo;
29-
const desmosRpc = Config.desmosRpc;
3026

3127
const [queryClient, setQueryClient] = useState<ExtendedQueryClient | null>(
3228
null
3329
);
34-
const [desmosQueryClient, setDesmosQueryClient] =
35-
useState<DesmosClient | null>(null);
3630
const [stargateClient, setStargateClient] = useState<StargateClient | null>(
3731
null
3832
);
3933

4034
const value = useMemo(
4135
(): QueryClientProviderContextValue => ({
4236
query: queryClient!,
43-
desmosQuery: desmosQueryClient!,
4437
stargateQuery: stargateClient!,
4538
}),
46-
[queryClient, desmosQueryClient, stargateClient]
39+
[queryClient, stargateClient]
4740
);
4841

4942
useEffect(() => {
@@ -56,16 +49,6 @@ const QueryClientProvider: React.FC<QueryClientProviderProps> = (props) => {
5649
});
5750
}, [chainInfo]);
5851

59-
useEffect(() => {
60-
newDesmosQueryClient(desmosRpc)
61-
.then((client) => {
62-
setDesmosQueryClient(client);
63-
})
64-
.catch((err) => {
65-
console.log("Error creating desmos query client", err);
66-
});
67-
}, [desmosRpc]);
68-
6952
useEffect(() => {
7053
newStargateClient(chainInfo)
7154
.then((client) => {
@@ -78,10 +61,7 @@ const QueryClientProvider: React.FC<QueryClientProviderProps> = (props) => {
7861

7962
return (
8063
<QueryClientContext.Provider value={value}>
81-
{queryClient != null &&
82-
desmosQueryClient != null &&
83-
stargateClient != null &&
84-
children}
64+
{queryClient != null && stargateClient != null && children}
8565
</QueryClientContext.Provider>
8666
);
8767
};

0 commit comments

Comments
 (0)