Skip to content

Commit

Permalink
Merge pull request #224 from alleslabs/feat/tx-link
Browse files Browse the repository at this point in the history
feat: internal tx
  • Loading branch information
songwongtp committed Mar 1, 2023
2 parents 5af959b + b075bd2 commit 19ac443
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 26 deletions.
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
- [#226](https://github.com/alleslabs/celatone-frontend/pull/226) Add fully functional transaction details page
- [#79](https://github.com/alleslabs/celatone-frontend/pull/79) Add dropdown menu and wireup up json attach funds
- [#225](https://github.com/alleslabs/celatone-frontend/pull/225) Add assets section in account details page
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
6 changes: 3 additions & 3 deletions src/lib/components/ExplorerLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { useWallet } from "@cosmos-kit/react";

import {
getExplorerBlockUrl,
getExplorerTxUrl,
getProposalUrl,
getExplorerValidatorUrl,
} from "lib/app-fns/explorer";
Expand Down Expand Up @@ -41,7 +40,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 @@ -146,7 +145,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
8 changes: 3 additions & 5 deletions src/lib/components/modal/tx/ButtonSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ 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 { getNetworkByChainName } from "lib/data";
import type { ActionVariant, TxReceipt } from "lib/types";

// TODO: refactor props to pass param in txResultRendering instead of receipt
Expand All @@ -26,15 +25,14 @@ export const ButtonSection = ({
const { currentChainName } = useWallet();

const openExplorer = useCallback(() => {
AmpTrackMintscan("tx_hash");
const txHash = receipts.find((r) => r.title === "Tx Hash")?.value;
window.open(
`${getExplorerTxUrl(currentChainName)}/${txHash}`,
`/${getNetworkByChainName(currentChainName)}/tx/${txHash}`,
"_blank",
"noopener,noreferrer"
);
onClose?.();
}, [receipts, onClose, currentChainName]);
}, [receipts, currentChainName, 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

0 comments on commit 19ac443

Please sign in to comment.