Skip to content

Commit

Permalink
Fix format
Browse files Browse the repository at this point in the history
  • Loading branch information
yuli-ferna committed Dec 19, 2024
1 parent aed43cf commit 3ddd33f
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 69 deletions.
20 changes: 13 additions & 7 deletions src/components/ShowTx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,20 +191,26 @@ export default function ShowTx({
}`
: chainId === CHAIN_ID_WORLDCHAIN
? `https://${
CLUSTER === "testnet" ? "worldchain-sepolia.explorer.alchemy.com" : "worldscan.org"
CLUSTER === "testnet"
? "worldchain-sepolia.explorer.alchemy.com"
: "worldscan.org"
}/tx/${tx?.id}`
: chainId === CHAIN_ID_SCROLL
? `https://${
CLUSTER === "testnet" ? "sepolia.scrollscan.dev" : "scrollscan.com"
}/tx/${tx?.id}`
CLUSTER === "testnet" ? "sepolia.scrollscan.dev" : "scrollscan.com"
}/tx/${tx?.id}`
: chainId === CHAIN_ID_MANTLE
? `https://${
CLUSTER === "testnet" ? "explorer.testnet.mantle.xyz" : "explorer.mantle.xyz"
}/tx/${tx?.id}`
CLUSTER === "testnet"
? "explorer.testnet.mantle.xyz"
: "explorer.mantle.xyz"
}/tx/${tx?.id}`
: chainId === CHAIN_ID_XLAYER
? `https://${
CLUSTER === "testnet" ? "www.okx.com/web3/explorer/xlayer-test" : "www.okx.com/web3/explorer/xlayer"
}/tx/${tx?.id}`
CLUSTER === "testnet"
? "www.okx.com/web3/explorer/xlayer-test"
: "www.okx.com/web3/explorer/xlayer"
}/tx/${tx?.id}`
: undefined;
const explorerName = getExplorerName(chainId);

Expand Down
31 changes: 14 additions & 17 deletions src/components/SmartAddress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,30 +211,27 @@ export default function SmartAddress({
CLUSTER === "testnet" ? "testnet" : "mainnet"
}/address/${useableAddress}`
: chainId === CHAIN_ID_WORLDCHAIN
? `https://${
CLUSTER === "testnet" ? "worldchain-sepolia.explorer.alchemy.com" : "worldscan.org"
}/${
isAsset ? "token" : "address"
}/${useableAddress}`
? `https://${
CLUSTER === "testnet"
? "worldchain-sepolia.explorer.alchemy.com"
: "worldscan.org"
}/${isAsset ? "token" : "address"}/${useableAddress}`
: chainId === CHAIN_ID_SCROLL
? `https://${
CLUSTER === "testnet" ? "sepolia.scrollscan.dev" : "scrollscan.com"
}/${
isAsset ? "token" : "address"
}/${useableAddress}`
}/${isAsset ? "token" : "address"}/${useableAddress}`
: chainId === CHAIN_ID_MANTLE
? `https://${
CLUSTER === "testnet" ? "explorer.testnet.mantle.xyz" : "explorer.mantle.xyz"
}/${
isAsset ? "token" : "address"
}/${useableAddress}`

CLUSTER === "testnet"
? "explorer.testnet.mantle.xyz"
: "explorer.mantle.xyz"
}/${isAsset ? "token" : "address"}/${useableAddress}`
: chainId === CHAIN_ID_XLAYER
? `https://${
CLUSTER === "testnet" ? "www.okx.com/web3/explorer/xlayer-test" : "www.okx.com/web3/explorer/xlayer"
}/${
isAsset ? "token" : "address"
}/${useableAddress}`
CLUSTER === "testnet"
? "www.okx.com/web3/explorer/xlayer-test"
: "www.okx.com/web3/explorer/xlayer"
}/${isAsset ? "token" : "address"}/${useableAddress}`
: chainId === CHAIN_ID_APTOS
? propertyVersion !== undefined // NFT
? `https://explorer.aptoslabs.com/token/${useableAddress}/${propertyVersion}${
Expand Down
106 changes: 66 additions & 40 deletions src/hooks/useGetSourceParsedTokenAccounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ const createNativeParsedTokenAccount = (
wrappedAddress: string,
decimals: number,
icon: string,
symbol: string,
symbol: string
) => {
return !(provider && signerAddress)
? Promise.reject()
Expand Down Expand Up @@ -1892,46 +1892,72 @@ function useGetAvailableTokens(nft: boolean = false) {
};
}, [lookupChain, provider, signerAddress, nft, ethNativeAccount]);

//Scroll, Mantle, Xlayer native asset load
useEffect(() => {
let cancelled = false;
if (
signerAddress &&
(lookupChain === CHAIN_ID_SCROLL ||
lookupChain === CHAIN_ID_MANTLE ||
lookupChain === CHAIN_ID_XLAYER) &&
!ethNativeAccount &&
!nft
) {
setEthNativeAccountLoading(true);
let address = lookupChain === CHAIN_ID_SCROLL ? SCROLLWETH_ADDRESS : lookupChain === CHAIN_ID_MANTLE ? WMNT_ADDRESS : WOKB_ADDRESS;
let decimals = lookupChain === CHAIN_ID_SCROLL ? SCROLLWETH_DECIMALS : lookupChain === CHAIN_ID_MANTLE ? WMNT_DECIMALS : WOKB_DECIMALS;
let icon = lookupChain === CHAIN_ID_SCROLL ? scrollIcon : lookupChain === CHAIN_ID_MANTLE ? chainToIcon("Mantle") : chainToIcon("Xlayer");
let symbol = lookupChain === CHAIN_ID_SCROLL ? "scrollETH" : lookupChain === CHAIN_ID_MANTLE ? "MNT" : "OKB";
createNativeParsedTokenAccount(provider, signerAddress, address, decimals, icon, symbol).then(
(result) => {
console.log("create native account returned with value", result);
if (!cancelled) {
setEthNativeAccount(result);
setEthNativeAccountLoading(false);
setEthNativeAccountError("");
}
},
(error) => {
if (!cancelled) {
setEthNativeAccount(undefined);
setEthNativeAccountLoading(false);
setEthNativeAccountError("Unable to retrieve your MATIC balance.");
}
//Scroll, Mantle, Xlayer native asset load
useEffect(() => {
let cancelled = false;
if (
signerAddress &&
(lookupChain === CHAIN_ID_SCROLL ||
lookupChain === CHAIN_ID_MANTLE ||
lookupChain === CHAIN_ID_XLAYER) &&
!ethNativeAccount &&
!nft
) {
setEthNativeAccountLoading(true);
let address =
lookupChain === CHAIN_ID_SCROLL
? SCROLLWETH_ADDRESS
: lookupChain === CHAIN_ID_MANTLE
? WMNT_ADDRESS
: WOKB_ADDRESS;
let decimals =
lookupChain === CHAIN_ID_SCROLL
? SCROLLWETH_DECIMALS
: lookupChain === CHAIN_ID_MANTLE
? WMNT_DECIMALS
: WOKB_DECIMALS;
let icon =
lookupChain === CHAIN_ID_SCROLL
? scrollIcon
: lookupChain === CHAIN_ID_MANTLE
? chainToIcon("Mantle")
: chainToIcon("Xlayer");
let symbol =
lookupChain === CHAIN_ID_SCROLL
? "scrollETH"
: lookupChain === CHAIN_ID_MANTLE
? "MNT"
: "OKB";
createNativeParsedTokenAccount(
provider,
signerAddress,
address,
decimals,
icon,
symbol
).then(
(result) => {
console.log("create native account returned with value", result);
if (!cancelled) {
setEthNativeAccount(result);
setEthNativeAccountLoading(false);
setEthNativeAccountError("");
}
);
}

return () => {
cancelled = true;
};
}, [lookupChain, provider, signerAddress, nft, ethNativeAccount]);

},
(error) => {
if (!cancelled) {
setEthNativeAccount(undefined);
setEthNativeAccountLoading(false);
setEthNativeAccountError("Unable to retrieve your MATIC balance.");
}
}
);
}

return () => {
cancelled = true;
};
}, [lookupChain, provider, signerAddress, nft, ethNativeAccount]);

//Ethereum covalent or blockscout accounts load
useEffect(() => {
Expand Down
8 changes: 3 additions & 5 deletions src/utils/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,7 @@ export interface ChainInfo {
logo: string;
}

export const DISABLED_CHAINS: Array<Partial<ChainId>> = [
CHAIN_ID_BLAST,
];
export const DISABLED_CHAINS: Array<Partial<ChainId>> = [CHAIN_ID_BLAST];

export const CHAINS: ChainInfo[] =
CLUSTER === "mainnet"
Expand Down Expand Up @@ -262,7 +260,7 @@ export const CHAINS: ChainInfo[] =
{
id: CHAIN_ID_WORLDCHAIN,
name: "World Chain",
logo: worldchainIcon
logo: worldchainIcon,
},
]
: CLUSTER === "testnet"
Expand Down Expand Up @@ -405,7 +403,7 @@ export const CHAINS: ChainInfo[] =
{
id: CHAIN_ID_WORLDCHAIN,
name: "World Chain",
logo: worldchainIcon
logo: worldchainIcon,
},
]
: [
Expand Down

0 comments on commit 3ddd33f

Please sign in to comment.