Skip to content

Commit

Permalink
fix: fallback explorer link for validator/proposal and gov params tok…
Browse files Browse the repository at this point in the history
…en symbol
  • Loading branch information
poomthiti committed Jun 22, 2023
1 parent e139c93 commit ad16513
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 12 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

- [#400](https://github.com/alleslabs/celatone-frontend/pull/400) Fallback explorer link for validator/proposal and gov params token symbol
- [#395](https://github.com/alleslabs/celatone-frontend/pull/395) Disable wasm related tabs on the account detail page
- [#392](https://github.com/alleslabs/celatone-frontend/pull/392) Fix format denom function
- [#390](https://github.com/alleslabs/celatone-frontend/pull/390) Fix minor styling
Expand Down
4 changes: 2 additions & 2 deletions src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ export const CHAIN_CONFIGS: ChainConfigs = {
"osmovaloper1hh0g5xf23e5zekg45cmerc97hs4n2004dy2t26" as ValidatorAddr,
},
explorerLink: {
validator: "https://www.mintscan.io/osmosis/validators",
proposal: "https://www.mintscan.io/osmosis/proposals",
validator: "",
proposal: "",
},
},
};
Expand Down
6 changes: 5 additions & 1 deletion src/lib/components/EstimatedFeeRender.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ export const EstimatedFeeRender = ({
const chainAssetInfo = getAssetInfo(coin.denom);
return (
<>
{formatBalanceWithDenom({ coin, precision: chainAssetInfo?.precision })}
{formatBalanceWithDenom({
coin,
precision: chainAssetInfo?.precision,
symbol: chainAssetInfo?.symbol,
})}
</>
);
};
15 changes: 11 additions & 4 deletions src/lib/components/ExplorerLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { ExplorerConfig } from "config/types";
import type { AddressReturnType } from "lib/app-provider";
import { useCelatoneApp } from "lib/app-provider/contexts";
import { useCurrentChain } from "lib/app-provider/hooks/useCurrentChain";
import { useLCDEndpoint } from "lib/app-provider/hooks/useLCDEndpoint";
import { AmpTrackMintscan } from "lib/services/amplitude";
import type { Option } from "lib/types";
import { truncate } from "lib/utils";
Expand Down Expand Up @@ -35,7 +36,8 @@ interface ExplorerLinkProps extends BoxProps {
const getNavigationUrl = (
type: ExplorerLinkProps["type"],
explorerConfig: ExplorerConfig,
value: string
value: string,
lcdEndpoint: string
) => {
let url = "";
switch (type) {
Expand All @@ -49,7 +51,9 @@ const getNavigationUrl = (
url = "/accounts";
break;
case "validator_address":
url = explorerConfig.validator;
url =
explorerConfig.validator ||
`${lcdEndpoint}/cosmos/staking/v1beta1/validators`;
break;
case "code_id":
url = "/codes";
Expand All @@ -58,7 +62,9 @@ const getNavigationUrl = (
url = "/blocks";
break;
case "proposal_id":
url = explorerConfig.proposal;
url =
explorerConfig.proposal ||
`${lcdEndpoint}/cosmos/gov/v1beta1/proposals`;
break;
case "invalid_address":
return "";
Expand Down Expand Up @@ -153,6 +159,7 @@ export const ExplorerLink = ({
...componentProps
}: ExplorerLinkProps) => {
const { address } = useCurrentChain();
const lcdEndpoint = useLCDEndpoint();
const {
chainConfig: { explorerLink: explorerConfig },
} = useCelatoneApp();
Expand All @@ -165,7 +172,7 @@ export const ExplorerLink = ({
type === "block_height";

const [hrefLink, textValue] = [
getNavigationUrl(type, explorerConfig, copyValue || value),
getNavigationUrl(type, explorerConfig, copyValue || value, lcdEndpoint),
getValueText(value === address, textFormat === "truncate", value),
];

Expand Down
7 changes: 5 additions & 2 deletions src/lib/components/table/proposals/ProposalsTableRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { DividerProps, GridProps } from "@chakra-ui/react";
import { Grid } from "@chakra-ui/react";

import { TableRow, TableRowFreeze } from "../tableComponents";
import { useCelatoneApp } from "lib/app-provider";
import { useCelatoneApp, useLCDEndpoint } from "lib/app-provider";
import { ExplorerLink } from "lib/components/ExplorerLink";
import { StopPropagationBox } from "lib/components/StopPropagationBox";
import { Proposer } from "lib/components/table/proposals/Proposer";
Expand Down Expand Up @@ -32,6 +32,7 @@ export const ProposalsTableRow = ({
explorerLink: { proposal: explorerProposal },
},
} = useCelatoneApp();
const lcdEndpoint = useLCDEndpoint();

// TODO - Revisit split columnsWidth
const columnsWidth = templateColumns?.toString().split(" ");
Expand Down Expand Up @@ -59,7 +60,9 @@ export const ProposalsTableRow = ({
status: proposal.status,
});
openNewTab(
`${explorerProposal}/${proposal.proposalId.toString()}`
explorerProposal
? `${explorerProposal}/${proposal.proposalId.toString()}`
: `${lcdEndpoint}/cosmos/gov/v1beta1/proposals/${proposal.proposalId.toString()}`
);
}
: undefined
Expand Down
13 changes: 11 additions & 2 deletions src/lib/components/tx/modal/ButtonSection.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { Button } from "@chakra-ui/react";
import { useRouter } from "next/router";

import { useInternalNavigate, useCelatoneApp } from "lib/app-provider";
import {
useInternalNavigate,
useCelatoneApp,
useLCDEndpoint,
} from "lib/app-provider";
import { CustomIcon } from "lib/components/icon";
import { openNewTab, useOpenTxTab } from "lib/hooks";
import type { ActionVariant, TxReceipt } from "lib/types";
Expand All @@ -26,6 +30,7 @@ export const ButtonSection = ({
explorerLink: { proposal: explorerProposal },
},
} = useCelatoneApp();
const lcdEndpoint = useLCDEndpoint();

const openTxExplorer = () => {
const txHash = receipts
Expand All @@ -39,7 +44,11 @@ export const ButtonSection = ({
const proposalId = receipts
.find((r) => r.title === "Proposal ID")
?.value?.toString();
openNewTab(`${explorerProposal}/${proposalId}`);
openNewTab(
explorerProposal
? `${explorerProposal}/${proposalId}`
: `${lcdEndpoint}/cosmos/gov/v1beta1/proposals/${proposalId}`
);
onClose?.();
};

Expand Down
2 changes: 1 addition & 1 deletion src/lib/services/contractService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export const useInstantiatedListByUserQuery = (
return useQuery(
["instantiated_list_by_user", walletAddr, indexerGraphClient],
queryFn,
{ enabled: !!walletAddr }
{ enabled: !!walletAddr, refetchOnWindowFocus: false }
);
};

Expand Down
1 change: 1 addition & 0 deletions src/lib/services/proposalService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ export const useGovParams = (): UseQueryResult<GovParams> => {
formattedToken: formatBalanceWithDenom({
coin: minDepositParam,
precision: assetInfo?.precision,
symbol: assetInfo?.symbol,
}),
precision: assetInfo?.precision ?? 0,
},
Expand Down

0 comments on commit ad16513

Please sign in to comment.