Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/XLabs/wormscan-ui
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinoConti committed Dec 17, 2024
2 parents 6575483 + e7c71af commit 5b16868
Show file tree
Hide file tree
Showing 11 changed files with 93 additions and 46 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wormscan-ui",
"version": "2.0.10",
"version": "2.0.11",
"private": true,
"source": "src/index.html",
"@parcel/resolver-default": {
Expand Down
9 changes: 8 additions & 1 deletion src/components/atoms/Select/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const Select = ({
value,
}: Props) => {
const [isOpen, setIsOpen] = useState(keepOpen);
const [inputValue, setInputValue] = useState("");
const ref = useRef<HTMLDivElement>(null);

const handleOutsideClick = () => {
Expand Down Expand Up @@ -86,8 +87,8 @@ const Select = ({
<div className="select-searchable-menu">
<SelectPrimitive
aria-label={ariaLabel}
autoFocus
backspaceRemovesValue={false}
blurInputOnSelect
className="select"
classNamePrefix="select"
components={{
Expand Down Expand Up @@ -141,6 +142,12 @@ const Select = ({
onValueChange(v);
if (closeOnSelect) setIsOpen(false);
}}
onInputChange={newValue => setInputValue(newValue)}
onKeyDown={e => {
if (e.key === "Enter" && !inputValue.trim()) {
e.preventDefault();
}
}}
options={items}
placeholder="Search"
styles={{
Expand Down
11 changes: 1 addition & 10 deletions src/components/organisms/ChainActivity/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,7 @@ const ChainActivity = () => {
startDateDisplayed={startDateDisplayed}
endDateDisplayed={endDateDisplayed}
isDesktop={isDesktop}
showDateRange
/>

<Select
Expand Down Expand Up @@ -950,16 +951,6 @@ const ChainActivity = () => {
})
: "All Chains"}
</div>

<div className="chain-activity-chart-top-filters-legends-target-range">
{fromDateFormatted && toDateFormatted && (
<>
{fromDateFormatted}
<ArrowRightIcon />
{toDateFormatted}
</>
)}
</div>
</div>
</div>
</div>
Expand Down
18 changes: 7 additions & 11 deletions src/components/organisms/ChainActivity/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@
top: 0px;
transform: scale(0.94);

@media only screen and (max-width: 1240px) {
right: 88px;
}

&.is-testnet {
right: 192px;
}
Expand Down Expand Up @@ -273,7 +277,7 @@

& > span {
@include desktop {
@media screen and (max-width: 1260px) {
@media screen and (max-width: 1310px) {
display: none;
}
}
Expand Down Expand Up @@ -340,13 +344,6 @@
overflow: auto;
gap: 12px;
}

&-range {
@include centered-row;
@include text-roboto-body-400;
color: var(--color-gray-500);
margin-left: auto;
}
}
}
}
Expand Down Expand Up @@ -396,9 +393,8 @@
@include desktop {
height: 36px;

@media only screen and (max-width: 1100px) {
font-size: 12px;
width: 40px;
@media only screen and (max-width: 1240px) {
padding-right: 140px;
}
}
}
Expand Down
32 changes: 23 additions & 9 deletions src/pages/Tx/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ import { getChainName } from "src/utils/wormhole";
import {
getAlgorandTokenInfo,
getSolanaCctp,
getSuiCctp,
ISolanaSuiCctpResponse,
tryGetAddressInfo,
tryGetWrappedToken,
} from "src/utils/cryptoToolkit";
Expand Down Expand Up @@ -323,8 +325,18 @@ const Tx = () => {
}
// second error, if hash is solana-like, check if its manual cctp
if (errCount === 1 && canBeSolanaTxHash) {
getSolanaCctp(network, txHash)
.then(resp => {
Promise.all([
getSolanaCctp(network, txHash).catch(() => null),
getSuiCctp(network, txHash).catch(() => null),
]).then(([solanaResp, suiResp]) => {
const resp: ISolanaSuiCctpResponse = solanaResp || suiResp;
const chain = solanaResp
? chainToChainId("Solana")
: suiResp
? chainToChainId("Sui")
: null;

if (resp && chain) {
cancelRequests.current = true;
const toChain = getCctpDomain(resp.destinationDomain);

Expand All @@ -334,7 +346,7 @@ const Tx = () => {
hex: resp.contractAddress,
native: resp.contractAddress,
},
emitterChain: 1,
emitterChain: chain,
id: null,
content: {
payload: null,
Expand All @@ -343,13 +355,13 @@ const Tx = () => {
appIds: [CCTP_MANUAL_APP_ID],
fee: "0",
feeAddress: "",
feeChain: 1,
feeChain: chain,
fromAddress: resp.sourceAddress,
fromChain: 1,
fromChain: chain,
toAddress: resp.targetAddress,
toChain: toChain,
tokenAddress: resp.sourceTokenAddress,
tokenChain: 1,
tokenChain: chain,
overwriteTargetTokenAddress: getUsdcAddress(network, toChain),
overwriteTargetTokenChain: toChain,
},
Expand All @@ -362,7 +374,7 @@ const Tx = () => {
status: "external_tx",
sequence: "",
sourceChain: {
chainId: 1,
chainId: chain,
timestamp: new Date(resp.timestamp),
from: resp.sourceAddress,
status: undefined,
Expand All @@ -377,8 +389,10 @@ const Tx = () => {

setErrorCode(undefined);
setIsLoading(false);
})
.catch(() => (cancelRequests.current = false));
} else {
cancelRequests.current = false;
}
});
}

if (errCount === 2) {
Expand Down
17 changes: 17 additions & 0 deletions src/pages/Txs/Information/Filters/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,23 @@ const Filters = ({ params, setIsPaginationLoading }: Props) => {
setEndDateDisplayed(params.to ? new Date(params.to) : null);
}, [params]);

useEffect(() => {
const handleKeyDown = (event: KeyboardEvent) => {
if (event.key === "Enter" && showFilters) {
event.preventDefault();

if (!disableApplyButton) {
applyFilters();
}
}
};

document.addEventListener("keydown", handleKeyDown);
return () => {
document.removeEventListener("keydown", handleKeyDown);
};
}, [applyFilters, disableApplyButton, showFilters]);

return (
<div className="filters">
{showFilters && !isDesktop && <div className="filters-bg" />}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Txs/Information/Filters/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
}

@include bigDesktop {
left: 268px;
left: 221px;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/pages/Txs/Information/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Dispatch, SetStateAction } from "react";
import { useLocation } from "react-router-dom";
import { Column } from "react-table";
import { IParams, PAGE_SIZE, TransactionOutput } from "..";
import { IParams, TransactionOutput } from "..";
import { Table } from "src/components/organisms";
import { Pagination } from "src/components/atoms";
import { useNavigateCustom, useWindowSize } from "src/utils/hooks";
Expand Down
18 changes: 9 additions & 9 deletions src/pages/Txs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ const Txs = () => {

const [searchParams, setSearchParams] = useSearchParams();
const params: IParams = {
page: searchParams.get("page") || null,
address: searchParams.get("address") || null,
appId: searchParams.get("appId") || null,
exclusiveAppId: searchParams.get("exclusiveAppId") || null,
sourceChain: searchParams.get("sourceChain") || null,
targetChain: searchParams.get("targetChain") || null,
payloadType: searchParams.get("payloadType") || null,
from: searchParams.get("from") || null,
to: searchParams.get("to") || null,
page: searchParams.get("page") || "",
address: searchParams.get("address") || "",
appId: searchParams.get("appId") || "",
exclusiveAppId: searchParams.get("exclusiveAppId") || "",
sourceChain: searchParams.get("sourceChain") || "",
targetChain: searchParams.get("targetChain") || "",
payloadType: searchParams.get("payloadType") || "",
from: searchParams.get("from") || "",
to: searchParams.get("to") || "",
};

useEffect(() => {
Expand Down
17 changes: 15 additions & 2 deletions src/utils/cryptoToolkit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interface IAlgorandTokenResponse {
symbol?: string;
}

interface ISolanaCctpResponse {
export interface ISolanaSuiCctpResponse {
amount: string;
contractAddress: string;
destinationDomain: number;
Expand Down Expand Up @@ -194,9 +194,22 @@ export const getSolanaCctp = async (network: Network, txHash: string) => {
`${BFF_URL}/getSolanaCctp?network=${network}&txHash=${txHash}`,
);

const solanaCctpResponse = (await solanaCctpRequest.json()) as ISolanaCctpResponse | null;
const solanaCctpResponse = (await solanaCctpRequest.json()) as ISolanaSuiCctpResponse | null;
return solanaCctpResponse;
} catch (e) {
return null;
}
};

export const getSuiCctp = async (network: Network, txHash: string) => {
try {
const suiCctpRequest = await fetchWithTimeout(
`${BFF_URL}/getSuiCctp?network=${network}&txHash=${txHash}`,
);

const suiCctpResponse = (await suiCctpRequest.json()) as ISolanaSuiCctpResponse | null;
return suiCctpResponse;
} catch (e) {
return null;
}
};
11 changes: 10 additions & 1 deletion src/utils/fetchWithRPCsFallthrough.ts
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,11 @@ export async function fetchWithRpcFallThrough(env: Environment, searchValue: str

const toChain = getCctpDomain(destinationDomain);
const toAddress =
toChain === 1 ? hexToBase58(mintRecipient) : "0x" + mintRecipient.substring(26);
toChain === chainToChainId("Sui")
? mintRecipient
: toChain === chainToChainId("Solana")
? hexToBase58(mintRecipient)
: "0x" + mintRecipient.substring(26);

return {
amount: "" + formatUnits(amount.toString(), 6),
Expand Down Expand Up @@ -591,6 +595,7 @@ export const getCctpDomain = (dom: number) => {
if (dom === 5) return chainToChainId("Solana");
if (dom === 6) return chainToChainId("Base");
if (dom === 7) return chainToChainId("Polygon");
if (dom === 8) return chainToChainId("Sui");
return null;
};

Expand All @@ -603,6 +608,8 @@ export const getUsdcAddress = (network: Network, chain: ChainId) => {
if (chain === chainToChainId("Solana")) return "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
if (chain === chainToChainId("Base")) return "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
if (chain === chainToChainId("Polygon")) return "0x3c499c542cef5e3811e1192ce70d8cc03d5c3359";
if (chain === chainToChainId("Sui"))
return "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC";
} else {
if (chain === chainToChainId("Ethereum")) return "0x07865c6e87b9f70255377e024ace6630c1eaa37f";
if (chain === chainToChainId("Avalanche")) return "0x5425890298aed601595a70ab815c96711a31bc65";
Expand All @@ -611,6 +618,8 @@ export const getUsdcAddress = (network: Network, chain: ChainId) => {
if (chain === chainToChainId("Solana")) return "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU";
if (chain === chainToChainId("Base")) return "0xf175520c52418dfe19c8098071a252da48cd1c19";
if (chain === chainToChainId("Polygon")) return "0x9999f7fea5938fd3b1e26a12c3f2fb024e194f97";
if (chain === chainToChainId("Sui"))
return "0xa1ec7fc00a6f40db9693ad1415d0c193ad3906494428cf252621037bd7117e29::usdc::USDC";
}
return null;
};
Expand Down

0 comments on commit 5b16868

Please sign in to comment.