Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.env
node_modules/
.devcontainer/
64 changes: 22 additions & 42 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,34 +38,22 @@

const chainNames = {
"0x1": "Ethereum mainnet",
"0x3": "Ropsten",
"0x4": "Rinkeby",
"0xaa36a7": "Sepolia",
"0x2a": "Kovan"
"0xaa36a7": "Sepolia"
}

const chainPrefixes = {
"0x1": "",
"0x3": "ropsten.",
"0x4": "rinkeby.",
"0xaa36a7": "sepolia.",
"0x2a": "kovan."
const chainDecimalIds = {
"0x1": "1",
"0xaa36a7": "11155111"
}

const chainApiPrefixes = {
"0x1": "",
"0x3": "-ropsten",
"0x4": "-rinkeby",
"0xaa36a7": "-sepolia",
"0x2a": "-kovan"
const chainRpcs = {
"1": "https://chain.techops.services/eth-mainnet",
"11155111": "https://chain.techops.services/eth-sepolia"
}

const chainSuffixes = {
"0x1": "mainnet",
"0x3": "ropsten",
"0x4": "rinkeby",
"0xaa36a7": "sepolia",
"0x2a": "kovan"
const chainExplorers = {
"1": "https://etherscan.io/address/",
"11155111": "https://sepolia.etherscan.io/address/"
}

const setUp = () => {
Expand All @@ -79,7 +67,7 @@
}, draw);
}

let provider, chain, chainPrefix, chainApiPrefix, chainSuffix, notice;
let provider, chain, chainDecimalId, notice;
window.addEventListener("load", () => {
if (typeof window.ethereum !== "undefined") {
setTimeout(() => {
Expand All @@ -92,20 +80,16 @@
provider = "Metamask";
chain = chainNames[conn.chainId];
if (!chain) chain = "Unknown";
chainPrefix = chainPrefixes[conn.chainId];
chainApiPrefix = chainApiPrefixes[conn.chainId];
chainSuffix = chainSuffixes[conn.chainId];
endpoint = chainSuffix === "mainnet" ? "https://chain.techops.services/eth-mainnet" : "https://chain.techops.services/eth-" + chainSuffix;
chainDecimalId = chainDecimalIds[conn.chainId];
endpoint = chainRpcs[chainDecimalId];
notice = "change this in your Metamask plugin (you don’t need to unlock Metamask)";
setUp();
});
window.ethereum.on("chainChanged", chainId => {
chain = chainNames[chainId];
if (!chain) chain = "Unknown";
chainPrefix = chainPrefixes[chainId];
chainApiPrefix = chainApiPrefixes[chainId];
chainSuffix = chainSuffixes[chainId];
endpoint = chainSuffix === "mainnet" ? "https://chain.techops.services/eth-mainnet" : "https://chain.techops.services/eth-" + chainSuffix;
chainDecimalId = chainDecimalIds[chainId];
endpoint = chainRpcs[chainDecimalId];
notice = "";
setUp();
});
Expand All @@ -117,9 +101,7 @@
const setDefaultRPC = () => {
provider = "TechOps";
chain = "Ethereum mainnet";
chainPrefix = "";
chainApiPrefix = "";
chainSuffix = "mainnet";
chainDecimalId = "1";
notice = "";
chainSelect.removeAttribute("disabled");
chainSelect.append(chainSepolia);
Expand Down Expand Up @@ -168,16 +150,14 @@
chainSelect.style.color = "black";
const chainOption = document.createElement("option");
chainOption.innerHTML = "loading…";
chainOption.setAttribute("value", "mainnet");
chainOption.setAttribute("value", "1");
chainSelect.append(chainOption);
const chainSepolia = document.createElement("option");
chainSepolia.innerHTML = "Sepolia";
chainSepolia.setAttribute("value", "sepolia");
chainSepolia.setAttribute("value", "11155111");
chainSelect.addEventListener("change", () => {
chainSuffix = chainSelect.value;
chainPrefix = chainSuffix === "mainnet" ? "" : "sepolia.";
chainApiPrefix = chainSuffix === "mainnet" ? "" : "-sepolia";
endpoint = chainSuffix === "mainnet" ? "https://chain.techops.services/eth-mainnet" : "https://chain.techops.services/eth-" + chainSuffix;
chainDecimalId = chainSelect.value;
endpoint = chainRpcs[chainDecimalId];
setUp();
});
chainValue.append(chainSelect);
Expand Down Expand Up @@ -574,7 +554,7 @@
escan.setAttribute("disabled", true);
getAddress(keyHex, address => {
tdView.innerHTML = address;
window.open("https://" + chainPrefix + "etherscan.io/address/" + address);
window.open(chainExplorers[chainDecimalId] + address);
escan.innerHTML = "Etherscan";
escan.removeAttribute("disabled");
if (showingAll()) {
Expand All @@ -594,7 +574,7 @@
abiCopy.innerHTML = "loading…";
abiCopy.setAttribute("disabled", true);
getAddress(keyHex, address => {
fetch("https://api" + chainApiPrefix + ".etherscan.io/api?apikey=1PX598KB4P6N6JI12SC9JVS1N3QM5QZIFB&module=contract&action=getabi"
fetch("https://api.etherscan.io/v2/api?chainid=" + chainDecimalId + "&apikey=1PX598KB4P6N6JI12SC9JVS1N3QM5QZIFB&module=contract&action=getabi"
+ "&address=" + address)
.then(response => response.json()
.then(data => {
Expand Down
64 changes: 22 additions & 42 deletions index.ipfs.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,34 +38,22 @@

const chainNames = {
"0x1": "Ethereum mainnet",
"0x3": "Ropsten",
"0x4": "Rinkeby",
"0xaa36a7": "Sepolia",
"0x2a": "Kovan"
"0xaa36a7": "Sepolia"
}

const chainPrefixes = {
"0x1": "",
"0x3": "ropsten.",
"0x4": "rinkeby.",
"0xaa36a7": "sepolia.",
"0x2a": "kovan."
const chainDecimalIds = {
"0x1": "1",
"0xaa36a7": "11155111"
}

const chainApiPrefixes = {
"0x1": "",
"0x3": "-ropsten",
"0x4": "-rinkeby",
"0xaa36a7": "-sepolia",
"0x2a": "-kovan"
const chainRpcs = {
"1": "https://chain.techops.services/eth-mainnet",
"11155111": "https://chain.techops.services/eth-sepolia"
}

const chainSuffixes = {
"0x1": "mainnet",
"0x3": "ropsten",
"0x4": "rinkeby",
"0xaa36a7": "sepolia",
"0x2a": "kovan"
const chainExplorers = {
"1": "https://etherscan.io/address/",
"11155111": "https://sepolia.etherscan.io/address/"
}

const setUp = () => {
Expand All @@ -79,7 +67,7 @@
}, draw);
}

let provider, chain, chainPrefix, chainApiPrefix, chainSuffix, notice;
let provider, chain, chainDecimalId, notice;
window.addEventListener("load", () => {
if (typeof window.ethereum !== "undefined") {
setTimeout(() => {
Expand All @@ -92,20 +80,16 @@
provider = "Metamask";
chain = chainNames[conn.chainId];
if (!chain) chain = "Unknown";
chainPrefix = chainPrefixes[conn.chainId];
chainApiPrefix = chainApiPrefixes[conn.chainId];
chainSuffix = chainSuffixes[conn.chainId];
endpoint = chainSuffix === "mainnet" ? "https://chain.techops.services/eth-mainnet" : "https://chain.techops.services/eth-" + chainSuffix;
chainDecimalId = chainDecimalIds[conn.chainId];
endpoint = chainRpcs[chainDecimalId];
notice = "change this in your Metamask plugin (you don’t need to unlock Metamask)";
setUp();
});
window.ethereum.on("chainChanged", chainId => {
chain = chainNames[chainId];
if (!chain) chain = "Unknown";
chainPrefix = chainPrefixes[chainId];
chainApiPrefix = chainApiPrefixes[chainId];
chainSuffix = chainSuffixes[chainId];
endpoint = chainSuffix === "mainnet" ? "https://chain.techops.services/eth-mainnet" : "https://chain.techops.services/eth-" + chainSuffix;
chainDecimalId = chainDecimalIds[chainId];
endpoint = chainRpcs[chainDecimalId];
notice = "";
setUp();
});
Expand All @@ -117,9 +101,7 @@
const setDefaultRPC = () => {
provider = "TechOps";
chain = "Ethereum mainnet";
chainPrefix = "";
chainApiPrefix = "";
chainSuffix = "mainnet";
chainDecimalId = "1";
notice = "";
chainSelect.removeAttribute("disabled");
chainSelect.append(chainSepolia);
Expand Down Expand Up @@ -168,16 +150,14 @@
chainSelect.style.color = "black";
const chainOption = document.createElement("option");
chainOption.innerHTML = "loading…";
chainOption.setAttribute("value", "mainnet");
chainOption.setAttribute("value", "1");
chainSelect.append(chainOption);
const chainSepolia = document.createElement("option");
chainSepolia.innerHTML = "Sepolia";
chainSepolia.setAttribute("value", "sepolia");
chainSepolia.setAttribute("value", "11155111");
chainSelect.addEventListener("change", () => {
chainSuffix = chainSelect.value;
chainPrefix = chainSuffix === "mainnet" ? "" : "sepolia.";
chainApiPrefix = chainSuffix === "mainnet" ? "" : "-sepolia";
endpoint = chainSuffix === "mainnet" ? "https://chain.techops.services/eth-mainnet" : "https://chain.techops.services/eth-" + chainSuffix;
chainDecimalId = chainSelect.value;
endpoint = chainRpcs[chainDecimalId];
setUp();
});
chainValue.append(chainSelect);
Expand Down Expand Up @@ -574,7 +554,7 @@
escan.setAttribute("disabled", true);
getAddress(keyHex, address => {
tdView.innerHTML = address;
window.open("https://" + chainPrefix + "etherscan.io/address/" + address);
window.open(chainExplorers[chainDecimalId] + address);
escan.innerHTML = "Etherscan";
escan.removeAttribute("disabled");
if (showingAll()) {
Expand All @@ -594,7 +574,7 @@
abiCopy.innerHTML = "loading…";
abiCopy.setAttribute("disabled", true);
getAddress(keyHex, address => {
fetch("https://api" + chainApiPrefix + ".etherscan.io/api?apikey=1PX598KB4P6N6JI12SC9JVS1N3QM5QZIFB&module=contract&action=getabi"
fetch("https://api.etherscan.io/v2/api?chainid=" + chainDecimalId + "&apikey=1PX598KB4P6N6JI12SC9JVS1N3QM5QZIFB&module=contract&action=getabi"
+ "&address=" + address)
.then(response => response.json()
.then(data => {
Expand Down
Loading