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

feat: internal tx #224

Merged
merged 3 commits into from
Mar 1, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -39,6 +39,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Features

- [#224](https://github.com/alleslabs/celatone-frontend/pull/224) Support search by tx and internal tx link
- [#214](https://github.com/alleslabs/celatone-frontend/pull/214) Show code permission helper text in save new code modal
- [#218](https://github.com/alleslabs/celatone-frontend/pull/218) Add instantiated and admin contracts of an account
- [#192](https://github.com/alleslabs/celatone-frontend/pull/192) Add alternative sidebar with only icons
Expand Down
17 changes: 0 additions & 17 deletions src/lib/app-fns/explorer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,6 @@ export const explorerMap: Record<string, string> = {
osmosistestnet: "https://testnet.mintscan.io/osmosis-testnet",
};

export const getExplorerTxUrl = (chainName: string) => {
let pathSuffix = "";
switch (chainName) {
case "osmosis":
case "osmosistestnet":
pathSuffix = "txs";
break;
case "terra2":
case "terra2testnet":
pathSuffix = "tx";
break;
default:
break;
}
return `${explorerMap[chainName]}/${pathSuffix}`;
};

export const getExplorerBlockUrl = (chainName: string) => {
let pathSuffix = "";
switch (chainName) {
Expand Down
11 changes: 4 additions & 7 deletions src/lib/components/ExplorerLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ import type { BoxProps } from "@chakra-ui/react";
import { Box, Text } from "@chakra-ui/react";
import { useWallet } from "@cosmos-kit/react";

import {
getExplorerBlockUrl,
getExplorerTxUrl,
getProposalUrl,
} from "lib/app-fns/explorer";
import { getExplorerBlockUrl, getProposalUrl } from "lib/app-fns/explorer";
import type { AddressReturnType } from "lib/hooks";
import { AmpTrackMintscan } from "lib/services/amplitude";
import { truncate } from "lib/utils";
Expand Down Expand Up @@ -39,7 +35,7 @@ const getNavigationUrl = (
let url = "";
switch (type) {
case "tx_hash":
url = getExplorerTxUrl(currentChainName);
url = "/tx";
break;
case "contract_address":
url = "/contract";
Expand Down Expand Up @@ -138,7 +134,8 @@ export const ExplorerLink = ({
const isInternal =
type === "code_id" ||
type === "contract_address" ||
type === "user_address";
type === "user_address" ||
type === "tx_hash";

const [hrefLink, textValue] = [
getNavigationUrl(type, currentChainName, copyValue || value),
Expand Down
9 changes: 2 additions & 7 deletions src/lib/components/modal/tx/ButtonSection.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import { Button, Icon } from "@chakra-ui/react";
import { useWallet } from "@cosmos-kit/react";
import { useRouter } from "next/router";
import { useCallback } from "react";
import { FiChevronRight } from "react-icons/fi";

import { getExplorerTxUrl } from "lib/app-fns/explorer";
import { useInternalNavigate } from "lib/app-provider";
import { AmpTrackMintscan } from "lib/services/amplitude";
import type { ActionVariant, TxReceipt } from "lib/types";

// TODO: refactor props to pass param in txResultRendering instead of receipt
Expand All @@ -23,18 +20,16 @@ export const ButtonSection = ({
}: ButtonSectionProps) => {
const router = useRouter();
const navigate = useInternalNavigate();
const { currentChainName } = useWallet();

const openExplorer = useCallback(() => {
AmpTrackMintscan("tx_hash");
const txHash = receipts.find((r) => r.title === "Tx Hash")?.value;
window.open(
`${getExplorerTxUrl(currentChainName)}/${txHash}`,
`/${router.query.network}/tx/${txHash}`,
songwongtp marked this conversation as resolved.
Show resolved Hide resolved
"_blank",
"noopener,noreferrer"
);
onClose?.();
}, [receipts, onClose, currentChainName]);
}, [receipts, router.query.network, onClose]);

switch (actionVariant) {
case "sending":
Expand Down
4 changes: 3 additions & 1 deletion src/lib/layout/Searchbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ const getRoute = (type: SearchResultType) => {
return "/contract";
case "Wallet Address":
return "/account";
case "Transaction Hash":
return "/tx";
default:
return null;
}
Expand Down Expand Up @@ -124,7 +126,7 @@ const Searchbar = () => {
value={keyword}
h="36px"
onChange={handleSearchChange}
placeholder="Search by Wallet Address / Contract Address / Code ID"
placeholder="Search by Wallet Address / Contract Address / Code ID / Tx Hash"
focusBorderColor="lilac.main"
onFocus={() => setDisplayResults(keyword.length > 0)}
onKeyDown={handleOnKeyEnter}
Expand Down