Skip to content

Commit

Permalink
Merge pull request #58 from SocketDotTech/add-chains
Browse files Browse the repository at this point in the history
feat: new chains
  • Loading branch information
arthcp authored Dec 21, 2023
2 parents e4f05ba + 1cfde5c commit 08c3c2e
Show file tree
Hide file tree
Showing 5 changed files with 402 additions and 47 deletions.
12 changes: 6 additions & 6 deletions src/components/Contracts/ChainConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,27 @@ function ChainConfig() {
<div className="info-card w-80 m-2">
<div className="flex align-center font-bold text-lg p-1">
<img
src={chainDetails[Object.keys(deployments)[index]].logoURI}
className="h-6 w-6 rounded-full my-auto"
alt="C"
src={chainDetails[Object.keys(deployments)[index]]?.logoURI}
className="h-6 w-6 rounded-full my-auto text-center border border-solid text-sm"
alt={chainDetails[Object.keys(deployments)[index]]?.chainName?.slice(0, 1) || "X"}
/>
<span className="mx-1 my-auto">
{chainDetails[Object.keys(deployments)[index]].chainName}{" "}
{chainDetails[Object.keys(deployments)[index]]?.chainName}{" "}
</span>
</div>

<div className="pl-1 mt-2">
{" "}
<div className="">
<span className="font-semibold"> Chain Slug : </span>{" "}
{chainDetails[Object.keys(deployments)[index]].chainId}{" "}
{Object.keys(deployments)[index]}{" "}
</div>
<div>
<div>
{" "}
<span className="font-semibold"> Socket : </span>
<a
href={`${chainDetails[Object.keys(deployments)[index]].blockExplorerUrl
href={`${chainDetails[Object.keys(deployments)[index]]?.blockExplorerUrl
}/address/${item["Socket"]}`}
target="_blank"
>
Expand Down
12 changes: 6 additions & 6 deletions src/components/Contracts/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import React, { useState } from "react";
import { chainDetails } from "./chainDetails";

function DropdownComponent({
selectedChainId,
selectedChainSlug,
onChangeAction,
excludeChainId = "0",
excludeChainSlug = "0",
}) {
return (
<div>
Expand All @@ -13,13 +13,13 @@ function DropdownComponent({
onChange={(e) => onChangeAction(e.target.value)}
>
{Object.values(chainDetails).map((item) => {
if (item.chainId.toString() != excludeChainId) {
return item.chainId == selectedChainId ? (
<option selected value={item.chainId}>
if (item.chainSlug.toString() != excludeChainSlug) {
return item.chainSlug == selectedChainSlug ? (
<option selected value={item.chainSlug}>
{item.chainName}
</option>
) : (
<option value={item.chainId}>{item.chainName}</option>
<option value={item.chainSlug}>{item.chainName}</option>
);
}
})}
Expand Down
24 changes: 12 additions & 12 deletions src/components/Contracts/SwitchboardAddresses.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ enum PATH {
}

function SwitchboardAddresses() {
const [selectedChainId, setSelectedChainId] = useState("10");
const [selectedChainSlug, setSelectedChainSlug] = useState("10");
const [selectedDestinationChain, setSelectedDestinationChain] = useState(
"10"
);
const [selectedPath, setSelectedPath] = useState(PATH.FAST);

useEffect(() => {
const k = Object.keys(chainDetails).filter(
(id) => id !== selectedChainId.toString()
(id) => id !== selectedChainSlug.toString()
);

selectedChainId === selectedDestinationChain &&
selectedChainSlug === selectedDestinationChain &&
setSelectedDestinationChain(k[0]);
}, [selectedChainId]);
}, [selectedChainSlug]);

return (
<div>
Expand All @@ -36,16 +36,16 @@ function SwitchboardAddresses() {
<div className="flex items-center space-x-1">
<span className="font-semibold text-base"> Local : </span>
<Dropdown
onChangeAction={setSelectedChainId}
selectedChainId={selectedChainId}
onChangeAction={setSelectedChainSlug}
selectedChainSlug={selectedChainSlug}
/>
</div>

<div className="flex items-center space-x-1">
<span className="font-semibold text-base"> Sibling : </span>
<Dropdown
excludeChainId={selectedChainId}
selectedChainId={selectedDestinationChain}
excludeChainSlug={selectedChainSlug}
selectedChainSlug={selectedDestinationChain}
onChangeAction={setSelectedDestinationChain}
/>
</div>
Expand All @@ -69,15 +69,15 @@ function SwitchboardAddresses() {
</div>
</div>
<Table
selectedChainId={selectedChainId}
selectedChainSlug={selectedChainSlug}
selectedDestinationChain={selectedDestinationChain}
selectedPath={selectedPath}
/>
</div>
);
}

function Table({ selectedChainId, selectedDestinationChain, selectedPath }) {
function Table({ selectedChainSlug, selectedDestinationChain, selectedPath }) {
return (
<table>
<thead>
Expand All @@ -91,11 +91,11 @@ function Table({ selectedChainId, selectedDestinationChain, selectedPath }) {

<tbody>
<tr>
<td>{selectedChainId}</td>
<td>{selectedChainSlug}</td>
<td>{selectedDestinationChain}</td>
<td>{selectedPath}</td>
<td>
{deployments[selectedChainId].integrations?.[
{deployments[selectedChainSlug].integrations?.[
selectedDestinationChain
]?.[selectedPath]?.["switchboard"] || "Not Supported"}
</td>
Expand Down
62 changes: 43 additions & 19 deletions src/components/Contracts/chainDetails.ts
Original file line number Diff line number Diff line change
@@ -1,114 +1,138 @@
export const chainDetails = {
1: {
chainId: 1,
chainSlug: 1,
chainName: "Ethereum",
blockExplorerUrl: "https://etherscan.io",
logoURI: "https://movricons.s3.ap-south-1.amazonaws.com/Ether.svg",
},
5: {
chainId: 5,
chainSlug: 5,
chainName: "Goerli",
blockExplorerUrl: "https://goerli.etherscan.io",
logoURI: "https://movricons.s3.ap-south-1.amazonaws.com/Ether.svg",
},
10: {
chainId: 10,
chainSlug: 10,
chainName: "Optimism",
blockExplorerUrl: "https://optimistic.etherscan.io",
logoURI: "https://movricons.s3.ap-south-1.amazonaws.com/Optimism.svg",
},
56: {
chainId: 56,
chainSlug: 56,
chainName: "BNB Chain",
blockExplorerUrl: "https://bscscan.com",
logoURI: "https://movricons.s3.ap-south-1.amazonaws.com/BSC.svg",
},
89: {
chainSlug: 89,
chainName: "Viction testnet",
blockExplorerUrl: "https://testnet.tomoscan.io",
logoURI: "",
},
137: {
chainId: 137,
chainSlug: 137,
chainName: "Polygon",
blockExplorerUrl: "https://polygonscan.com",
logoURI: "https://movricons.s3.ap-south-1.amazonaws.com/Matic.svg",
},
420: {
chainId: 420,
chainSlug: 420,
chainName: "Optimism Goerli",
blockExplorerUrl: "https://goerli-optimism.etherscan.io",
logoURI: "https://movricons.s3.ap-south-1.amazonaws.com/Optimism.svg",
},
647: {
chainId: 647,
chainSlug: 647,
chainName: "Stavanger testnet",
blockExplorerUrl: "https://sn2-stavanger-blockscout.eu-north-2.gateway.fm",
logoURI: "https://movricons.s3.ap-south-1.amazonaws.com/Matic.svg",
},
901: {
chainId: 901,
chainSlug: 901,
chainName: "Lyra testnet",
blockExplorerUrl: "https://explorerl2new-prod-testnet-0eakp60405.t.conduit.xyz",
logoURI: "/img/lyra-logo.png",
},
919: {
chainSlug: 919,
chainName: "Mode testnet",
blockExplorerUrl: "https://sepolia.explorer.mode.network",
logoURI: "",
},
957: {
chainId: 957,
chainSlug: 957,
chainName: "Lyra",
blockExplorerUrl: "https://explorer.lyra.finance",
logoURI: "/img/lyra-logo.png",
},
2999: {
chainId: 2999,
chainSlug: 2999,
chainName: "Aevo",
blockExplorerUrl: "https://explorer.aevo.xyz",
logoURI: "/img/aevo-logo.png",
},
8453: {
chainSlug: 8453,
chainName: "Base",
blockExplorerUrl: "https://basescan.org",
logoURI: "https://media.socket.tech/Base.png",
},
34443: {
chainSlug: 34443,
chainName: "Mode",
blockExplorerUrl: "https://explorer.mode.network",
logoURI: "",
},
42161: {
chainId: 42161,
chainSlug: 42161,
chainName: "Arbitrum",
blockExplorerUrl: "https://arbiscan.io",
logoURI: "https://movricons.s3.ap-south-1.amazonaws.com/Arbitrum.svg",
},
80001: {
chainId: 80001,
chainSlug: 80001,
chainName: "Polygon Mumbai testnet",
blockExplorerUrl: "https://mumbai.polygonscan.com",
logoURI: "https://movricons.s3.ap-south-1.amazonaws.com/Matic.svg",
},
421613: {
chainId: 421613,
chainSlug: 421613,
chainName: "Arbitrum Goerli",
blockExplorerUrl: "https://goerli.arbiscan.io",
logoURI: "https://movricons.s3.ap-south-1.amazonaws.com/Arbitrum.svg",
},
421614: {
chainId: 421614,
chainSlug: 421614,
chainName: "Arbitrum Sepolia",
blockExplorerUrl: "https://sepolia.arbiscan.io",
logoURI: "https://movricons.s3.ap-south-1.amazonaws.com/Arbitrum.svg",
},
11155111: {
chainId: 11155111,
chainSlug: 11155111,
chainName: "Sepolia",
blockExplorerUrl: "https://sepolia.etherscan.io",
logoURI: "https://movricons.s3.ap-south-1.amazonaws.com/Ether.svg",
},
11155112: {
chainId: 11155112,
chainSlug: 11155112,
chainName: "Aevo testnet",
blockExplorerUrl: "https://explorer-testnet.aevo.xyz",
logoURI: "/img/aevo-logo.png",
},
11155420: {
chainId: 11155420,
chainSlug: 11155420,
chainName: "Optimism Sepolia",
blockExplorerUrl: "https://sepolia-optimism.etherscan.io",
logoURI: "https://movricons.s3.ap-south-1.amazonaws.com/Optimism.svg",
},
686669576: {
chainId: 686669576,
chainSlug: 686669576,
chainName: "SX Network Testnet",
blockExplorerUrl: "https://explorer.toronto.sx.technology",
logoURI: "/img/sx-logo.png",
},
1399904803: {
chainId: 1399904803,
chainSlug: 1399904803,
chainName: "XAI Testnet",
blockExplorerUrl: "https://testnet-explorer.xai-chain.net",
logoURI: "/img/xai-logo.png",
Expand Down
Loading

0 comments on commit 08c3c2e

Please sign in to comment.