Skip to content

Commit

Permalink
Merge pull request #791 from alleslabs/feat/cfe-322-proposal-view-json
Browse files Browse the repository at this point in the history
fix: proposal view in json
  • Loading branch information
evilpeach committed Feb 19, 2024
2 parents 5d74696 + 228a391 commit 98b9519
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Bug fixes

- [#791](https://github.com/alleslabs/celatone-frontend/pull/791) Proposal view in json direct to the lcd information
- [#789](https://github.com/alleslabs/celatone-frontend/pull/789) Remove loading overlay on pool list page causing the page look like flicking
- [#783](https://github.com/alleslabs/celatone-frontend/pull/783) Fix link used for Osmosis Pool JSON To poolmanager
- [#780](https://github.com/alleslabs/celatone-frontend/pull/780) Fix proposal vote table, scroll to top on table
Expand Down
2 changes: 2 additions & 0 deletions src/config/chain/initia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const INITIA_CHAIN_CONFIGS: ChainConfigs = {
},
gov: {
enabled: true,
version: "v1",
hideOpenProposal: true,
},
nft: {
Expand Down Expand Up @@ -186,6 +187,7 @@ export const INITIA_CHAIN_CONFIGS: ChainConfigs = {
},
gov: {
enabled: true,
version: "v1",
hideOpenProposal: true,
},
nft: {
Expand Down
3 changes: 3 additions & 0 deletions src/config/chain/osmosis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const OSMOSIS_CHAIN_CONFIGS: ChainConfigs = {
},
gov: {
enabled: true,
version: "v1",
disableStoreCodeProposal: true,
disableWhitelistProposal: true,
},
Expand Down Expand Up @@ -83,6 +84,7 @@ export const OSMOSIS_CHAIN_CONFIGS: ChainConfigs = {
},
gov: {
enabled: true,
version: "v1",
disableWhitelistProposal: true,
disableStoreCodeProposal: true,
},
Expand Down Expand Up @@ -133,6 +135,7 @@ export const OSMOSIS_CHAIN_CONFIGS: ChainConfigs = {
},
gov: {
enabled: true,
version: "v1",
disableWhitelistProposal: true,
disableStoreCodeProposal: true,
},
Expand Down
2 changes: 2 additions & 0 deletions src/config/chain/sei.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const SEI_CHAIN_CONFIGS: ChainConfigs = {
},
gov: {
enabled: true,
version: "v1beta1",
hideOpenProposal: true,
},
nft: {
Expand Down Expand Up @@ -87,6 +88,7 @@ export const SEI_CHAIN_CONFIGS: ChainConfigs = {
},
gov: {
enabled: true,
version: "v1beta1",
hideOpenProposal: true,
},
nft: {
Expand Down
2 changes: 2 additions & 0 deletions src/config/chain/stargaze.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const STARGAZE_CHAIN_CONFIGS: ChainConfigs = {
},
gov: {
enabled: true,
version: "v1",
},
nft: {
enabled: false,
Expand Down Expand Up @@ -78,6 +79,7 @@ export const STARGAZE_CHAIN_CONFIGS: ChainConfigs = {
},
gov: {
enabled: true,
version: "v1",
},
nft: {
enabled: false,
Expand Down
2 changes: 2 additions & 0 deletions src/config/chain/terra.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const TERRA_CHAIN_CONFIGS: ChainConfigs = {
},
gov: {
enabled: true,
version: "v1",
hideOpenProposal: true,
},
nft: {
Expand Down Expand Up @@ -80,6 +81,7 @@ export const TERRA_CHAIN_CONFIGS: ChainConfigs = {
},
gov: {
enabled: true,
version: "v1",
hideOpenProposal: true,
},
nft: {
Expand Down
1 change: 1 addition & 0 deletions src/config/chain/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type PublicProjectConfig = { enabled: boolean };
type GovConfig =
| {
enabled: true;
version: "v1beta1" | "v1";
hideOpenProposal?: boolean;
disableWhitelistProposal?: boolean;
disableStoreCodeProposal?: boolean;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { Button } from "@chakra-ui/react";

import { useGovConfig, useInitia, useLCDEndpoint } from "lib/app-provider";
import { CustomIcon } from "lib/components/icon";
import { openNewTab } from "lib/utils";

interface ViewProposalJsonProps {
id: number;
}

export const ViewProposalJson = ({ id }: ViewProposalJsonProps) => {
const endpoint = useLCDEndpoint();
const config = useGovConfig({ shouldRedirect: false });
const isInitia = useInitia();

if (!config.enabled) return null;

const openLcdPage = () =>
openNewTab(
`${endpoint}/${isInitia ? "initia" : "cosmos"}/gov/${config.version}/proposals/${encodeURIComponent(id)}`
);

return (
<Button
variant="outline-primary"
w={{ base: "full", md: "min-content" }}
minWidth={{ md: "150px" }}
size={{ base: "sm", md: "md" }}
rightIcon={<CustomIcon name="launch" />}
onClick={openLcdPage}
>
View in JSON
</Button>
);
};
22 changes: 5 additions & 17 deletions src/lib/pages/proposal-details/components/proposal-top/index.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
import { Button, Flex, Heading, Text } from "@chakra-ui/react";
import { Flex, Heading, Text } from "@chakra-ui/react";

import { useBaseApiRoute, useMobile } from "lib/app-provider";
import { useMobile } from "lib/app-provider";
import { Breadcrumb } from "lib/components/Breadcrumb";
import { DotSeparator } from "lib/components/DotSeparator";
import { Expedited } from "lib/components/Expedited";
import { ExplorerLink } from "lib/components/ExplorerLink";
import { CustomIcon } from "lib/components/icon";
import type { ProposalData } from "lib/types";
import { formatUTC, openNewTab } from "lib/utils";
import { formatUTC } from "lib/utils";

import { ProposalInfo } from "./proposal-info";
import { ViewProposalJson } from "./ViewProposalJson";

interface ProposalTopProps {
proposalData: ProposalData;
}

export const ProposalTop = ({ proposalData }: ProposalTopProps) => {
const isMobile = useMobile();
// TODO: use LCD and gov config version
const endpoint = useBaseApiRoute("proposals");
const openApiPage = () =>
openNewTab(`${endpoint}/${encodeURIComponent(proposalData.id)}/info`);

return (
<Flex direction="column" mb={6} gap={5}>
Expand Down Expand Up @@ -144,16 +141,7 @@ export const ProposalTop = ({ proposalData }: ProposalTopProps) => {
</Flex>
</Flex>
</Flex>
<Button
variant="outline-primary"
w={{ base: "full", md: "min-content" }}
minWidth={{ md: "150px" }}
size={{ base: "sm", md: "md" }}
rightIcon={<CustomIcon name="launch" />}
onClick={openApiPage}
>
View in JSON
</Button>
<ViewProposalJson id={proposalData.id} />
</Flex>
<ProposalInfo data={proposalData} />
</Flex>
Expand Down

0 comments on commit 98b9519

Please sign in to comment.