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: support initia module address in link #599

Merged
merged 3 commits into from
Nov 1, 2023
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: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Bug fixes

- [#599](https://github.com/alleslabs/celatone-frontend/pull/599) Fix getNavigationUrl to support move
- [#590](https://github.com/alleslabs/celatone-frontend/pull/590) Fix upload script various bugs
- [#594](https://github.com/alleslabs/celatone-frontend/pull/594) LP assets filtering and delegation ui/ux improvement
- [#584](https://github.com/alleslabs/celatone-frontend/pull/584) Throw an error when tx failed on postTx
Expand Down
33 changes: 24 additions & 9 deletions src/lib/components/ExplorerLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import { Box, Text, Flex } from "@chakra-ui/react";

import type { ExplorerConfig } from "config/chain/types";
import { useTrack } from "lib/amplitude";
import type { AddressReturnType } from "lib/app-provider";
import { type AddressReturnType } from "lib/app-provider";
import { useCelatoneApp } from "lib/app-provider/contexts";
import { useBaseApiRoute } from "lib/app-provider/hooks/useBaseApiRoute";
import { useWasmConfig } from "lib/app-provider/hooks/useConfig";
import { useCurrentChain } from "lib/app-provider/hooks/useCurrentChain";
import { useMobile } from "lib/app-provider/hooks/useMediaQuery";
import type { Option } from "lib/types";
Expand Down Expand Up @@ -36,19 +37,26 @@ interface ExplorerLinkProps extends BoxProps {
fixedHeight?: boolean;
}

export const getNavigationUrl = (
type: ExplorerLinkProps["type"],
explorerConfig: ExplorerConfig,
value: string,
lcdEndpoint: string
) => {
export const getNavigationUrl = ({
type,
explorerConfig,
value,
lcdEndpoint,
wasmEnabled = false,
}: {
type: ExplorerLinkProps["type"];
explorerConfig: ExplorerConfig;
value: string;
lcdEndpoint: string;
wasmEnabled?: boolean;
}) => {
let url = "";
switch (type) {
case "tx_hash":
url = "/txs";
break;
case "contract_address":
url = "/contracts";
url = wasmEnabled ? "/contracts" : "/accounts";
break;
case "user_address":
url = "/accounts";
Expand Down Expand Up @@ -171,6 +179,7 @@ export const ExplorerLink = ({
}: ExplorerLinkProps) => {
const { address } = useCurrentChain();
const lcdEndpoint = useBaseApiRoute("rest");
const { enabled: wasmEnabled } = useWasmConfig({ shouldRedirect: false });
const {
chainConfig: { explorerLink: explorerConfig },
} = useCelatoneApp();
Expand All @@ -184,7 +193,13 @@ export const ExplorerLink = ({
type === "pool_id";

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

Expand Down
12 changes: 6 additions & 6 deletions src/lib/components/table/proposals/ProposalsTableRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ export const ProposalsTableRow = ({
});
// TOOD: revisit retrieving url (make a proper hook)
openNewTab(
getNavigationUrl(
"proposal_id",
explorerLink,
proposal.proposalId.toString(),
lcdEndpoint
)
getNavigationUrl({
type: "proposal_id",
explorerConfig: explorerLink,
value: proposal.proposalId.toString(),
lcdEndpoint,
})
);
}
: undefined
Expand Down
12 changes: 6 additions & 6 deletions src/lib/components/tx/modal/ButtonSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ export const ButtonSection = ({
?.value?.toString();
// TOOD: revisit retrieving url (make a proper hook)
openNewTab(
getNavigationUrl(
"proposal_id",
explorerLink,
proposalId ?? "",
lcdEndpoint
)
getNavigationUrl({
type: "proposal_id",
explorerConfig: explorerLink,
value: proposalId ?? "",
lcdEndpoint,
})
);
onClose?.();
};
Expand Down