Skip to content

Commit

Permalink
add to contract field in details, fix bugs, secret explorer
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexeyAdoniev committed Aug 3, 2023
1 parent 1c2bfae commit 7f4ff48
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 60 deletions.
30 changes: 25 additions & 5 deletions src/components/Details/DetailsCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import SoundOffIcon from "../../assets/icons/sound-off.svg";
import { ImgOrFail } from "../elements/ImgOrFail";

import { extractHash } from "./helpers";
import { FromLink } from "../elements/ExplorerLink";

import { truncate } from "./helpers";
export interface DetailsCard {
data: {
loading: boolean;
Expand All @@ -38,7 +38,10 @@ const DetailsCard = ({ data, copyProps }: DetailsCard) => {
const nftVideo = useRef<HTMLVideoElement | null>(null);

const isMobile = useIsMobile();
const truncateSize = useMemo(() => (isMobile ? 33 : 60), [isMobile]);
const truncateSize = useMemo(
() => (window.innerWidth < 1150 ? 33 : 65),
[isMobile]
);

// @ts-ignore
const toggleSound = () => {
Expand Down Expand Up @@ -250,8 +253,21 @@ const DetailsCard = ({ data, copyProps }: DetailsCard) => {
>
ID:
</div>
<div className="text-[#222222] w-32">
{dataLoad ? "" : event.tokenId}
<div className="copyBtnWrapper">
<span className="text-[#222222] ">
{dataLoad
? ""
: event.tokenId && event.tokenId.length > 50
? truncate(event.tokenId, truncateSize)
: event.tokenId}
</span>
{!dataLoad && (
<CopyWithTooltip
copyValue={event?.tokenId}
copyProps={copyProps}
copyIdx={2}
/>
)}
</div>
</div>
{!dataLoad && (
Expand All @@ -276,7 +292,11 @@ const DetailsCard = ({ data, copyProps }: DetailsCard) => {
rel="noreferrer"
className="text-[#222222] w-32 trxHash"
>
<FromLink event={event} />
{truncate(
event?.fromHash &&
extractHash(event.fromHash),
truncateSize
) || "N/A"}
</a>
<div className="copyBtnWrapper">
{" "}
Expand Down
38 changes: 37 additions & 1 deletion src/components/Details/DetailsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ const DetailsList = ({ data, copyProps }: DetailsCard) => {
// setToIconSrc("");
// }
chains?.map((chain) => {
if (chain?.name === chainNoncetoName[event?.fromChain || 0]) {
if (
chain.name?.toLowerCase() ===
chainNoncetoName[event?.fromChain || 0]?.toLowerCase()
) {
if (chain?.icon[0] === ".") {
setFromIconSrc(chain?.icon?.slice(1));
} else {
Expand Down Expand Up @@ -282,6 +285,39 @@ const DetailsList = ({ data, copyProps }: DetailsCard) => {
)}
</p>
</div>
{event?.destContract && (
<div className="flex items-start justify-start gap-2 border-b py-4 detailsListRow">
<div className="text-[#222222] font-medium w-32">
To Contract:
</div>
<p
className={`md:pl-14 break-words shrink w-[calc(100%-8rem)] md:w-fit ${
dataLoad ? "loadingWrapper" : "loadedWrapper"
}`}
>
<a
target="_blank"
rel="noreferrer"
href={`${
event?.toChain &&
addressExplorers[event.toChain]
}${encodeURIComponent(event.destContract)}`}
>
<span className="text-[#235EF5]">
{truncate(event.destContract, truncateSize) ||
"N/A"}
</span>
</a>
{!dataLoad && (
<CopyWithTooltip
copyValue={event?.targetAddress}
copyProps={copyProps}
copyIdx={8}
/>
)}
</p>
</div>
)}
<div className="flex items-start justify-start gap-2 border-b py-4 detailsListRow">
<div className="text-[#222222] font-medium w-32">Date:</div>
<p
Expand Down
12 changes: 3 additions & 9 deletions src/components/ExplorerEvents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ export interface IEvent {
imgUri?: string;
name: string;
contract?: string;
destContract?: string;
collectionName?: string;
destCollectionName?: string;
originalChainNonce?: string;
originalContract?: string;
originalTokenId?: string;
Expand Down Expand Up @@ -391,15 +393,7 @@ export const ExplorerEvents: FC<{ status?: string }> = ({ status = "" }) => {

<TableData className="CollectioName">
<CollectionNameRow
hash={extractHash(
event.toHash!
)}
collectionName={
event?.collectionName
? event?.collectionName
: "-"
}
chain={event.toChain!}
event={event}
/>
</TableData>

Expand Down
60 changes: 26 additions & 34 deletions src/components/Table/CollectionNameRow.tsx
Original file line number Diff line number Diff line change
@@ -1,42 +1,34 @@
import { truncate } from "../Details/helpers";
import { txExplorers } from "../../constants";
import { useState } from "react";

import { IEvent } from "../ExplorerEvents";
import { setShowByCollection } from "../../store/global";
import { useDispatch } from "react-redux";

export const CollectionNameRow = ({
collectionName,
chain,
hash,
}: {
collectionName: string;
chain: string;
hash: string;
}) => {
const [events, setEvents] = useState<IEvent[]>([]);
const dispatch = useDispatch();
const showCollection = (e: any) => {
e.stopPropagation();
//console.log("collectionName row", collectionName);
export const CollectionNameRow = ({ event }: { event: IEvent }) => {
const dispatch = useDispatch();
const { collectionName } = event;
const showCollection = (e: any) => {
e.stopPropagation();
//console.log("collectionName row", collectionName);

a();
};

a();
};
const a = () => {
//console.log("collectionName a", collectionName);
dispatch(setShowByCollection(collectionName));
//console.log("collectionName a", collectionName);
};

const a = () => {
//console.log("collectionName a", collectionName);
dispatch(setShowByCollection(collectionName));
//console.log("collectionName a", collectionName);
};
return (
<button
className="text-[#235EF5] text-xs"
onClick={(e) => showCollection(e)}
// href={`${txExplorers[chain]}${hash}`}
// target="_blank"
// rel="noreferrer"
>
{collectionName && truncate(collectionName, 15, undefined, "Last")}
</button>
);
return (
<button
className="text-[#235EF5] text-xs"
onClick={(e) => showCollection(e)}
// href={`${txExplorers[chain]}${hash}`}
// target="_blank"
// rel="noreferrer"
>
{collectionName && truncate(collectionName, 15, undefined, "Last")}
</button>
);
};
4 changes: 2 additions & 2 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const txExplorers: any = {
"25": "https://explore.vechain.org/transactions/",
"15": "https://algoexplorer.io/tx/",
"22": "https://v1.gwscan.com/tx/",
"24": "https://secretnodes.com/secret/transactions/",
"24": "https://www.mintscan.io/secret/transactions/",
"32": "https://moonscan.io/tx/",
"33": "https://scan.abeychain.com/tx/",
"28": "https://dashboard.internetcomputer.org/account/",
Expand Down Expand Up @@ -104,7 +104,7 @@ export const addressExplorers: any = {
"25": "https://explore.vechain.org/accounts/",
"15": "https://algoexplorer.io/address/",
"22": "https://v1.gwscan.com/tx/",
"24": `https://atomscan.com/secret-network/accounts/`,
"24": `https://www.mintscan.io/secret/accounts/`,
"32": "https://moonscan.io/address/",
"27": "https://tonscan.org/address/",
"33": "https://scan.abeychain.com/address/",
Expand Down
10 changes: 1 addition & 9 deletions src/pages/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -390,15 +390,7 @@ export const Search = (props: any) => {

<TableData className="CollectioName">
<CollectionNameRow
hash={extractHash(
event.toHash!
)}
collectionName={
event?.collectionName
? event?.collectionName
: "-"
}
chain={event.toChain!}
event={event}
/>
</TableData>

Expand Down

0 comments on commit 7f4ff48

Please sign in to comment.