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: 0 additions & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ jobs:
- name: Start and test chainlog containers
id: start-containers
env:
INFURA_KEY: ${{ secrets.INFURA_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
working-directory: ./
run: |
Expand Down
4 changes: 2 additions & 2 deletions api.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ <h2>Code examples</h2>
Please note that the above code will only retreive the latest data.<br/><br/>
You can also ditch web3 libraries and perform low-level JSON RPC calls. Here is an <a href="https://github.com/makerdao/chainlog-ui/blob/main/examples/python.py">example with Python</a>:
<pre>
keys = requests.post("https://mainnet.infura.io/v3/" + infura_key, json={
keys = requests.post("https://chain.techops.live/eth-mainnet", json={
"jsonrpc": "2.0",
"method": "eth_call",
"params": [{
Expand All @@ -55,7 +55,7 @@ <h2>Code examples</h2>
}).json()["result"][130:]
result = {}
for i in range(0, len(keys), 64):
address = "0x" + requests.post("https://mainnet.infura.io/v3/" + infura_key, json={
address = "0x" + requests.post("https://chain.techops.live/eth-mainnet", json={
"jsonrpc": "2.0",
"method": "eth_call",
"params": [{
Expand Down
4 changes: 0 additions & 4 deletions deploy/prod/chainlog-logger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ env:
PYTHONUNBUFFERED:
type: kv
value: "1"
INFURA_KEY:
type: parameterStore
name: infura-key
parameter_name: /eks/maker-prod/chainlog-logger/infura-key
GITHUB_TOKEN:
type: parameterStore
name: github-token
Expand Down
4 changes: 0 additions & 4 deletions deploy/staging/chainlog-logger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ env:
PYTHONUNBUFFERED:
type: kv
value: "1"
INFURA_KEY:
type: parameterStore
name: infura-key
parameter_name: /eks/maker-staging/chainlog-logger/infura-key
GITHUB_TOKEN:
type: parameterStore
name: github-token
Expand Down
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ services:
image: chainlog-logger
container_name: chainlog-logger
environment:
INFURA_KEY: $INFURA_KEY
GITHUB_TOKEN: $GITHUB_TOKEN
CHAINLOG_REPO: "makerdao/chainlog-ui"
PYTHONUNBUFFERED: 1
Expand Down
5 changes: 2 additions & 3 deletions examples/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import os, requests

infura_key = os.environ["INFURA_KEY"]
keys = requests.post("https://mainnet.infura.io/v3/" + infura_key, json={
keys = requests.post("https://chain.techops.live/eth-mainnet", json={
"jsonrpc": "2.0",
"method": "eth_call",
"params": [{
Expand All @@ -14,7 +13,7 @@
}).json()["result"][130:]
result = {}
for i in range(0, len(keys), 64):
address = "0x" + requests.post("https://mainnet.infura.io/v3/" + infura_key, json={
address = "0x" + requests.post("https://chain.techops.live/eth-mainnet", json={
"jsonrpc": "2.0",
"method": "eth_call",
"params": [{
Expand Down
63 changes: 33 additions & 30 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,31 +40,31 @@
"0x1": "Ethereum mainnet",
"0x3": "Ropsten",
"0x4": "Rinkeby",
"0x5": "Görli",
"0xaa36a7": "Sepolia",
"0x2a": "Kovan"
}

const chainPrefixes = {
"0x1": "",
"0x3": "ropsten.",
"0x4": "rinkeby.",
"0x5": "goerli.",
"0xaa36a7": "sepolia.",
"0x2a": "kovan."
}

const chainApiPrefixes = {
"0x1": "",
"0x3": "-ropsten",
"0x4": "-rinkeby",
"0x5": "-goerli",
"0xaa36a7": "-sepolia",
"0x2a": "-kovan"
}

const infuraPrefixes = {
const chainSuffixes = {
"0x1": "mainnet",
"0x3": "ropsten",
"0x4": "rinkeby",
"0x5": "goerli",
"0xaa36a7": "sepolia",
"0x2a": "kovan"
}

Expand All @@ -79,13 +79,13 @@
}, draw);
}

let provider, chain, chainPrefix, chainApiPrefix, infuraPrefix, notice;
let provider, chain, chainPrefix, chainApiPrefix, chainSuffix, notice;
window.addEventListener("load", () => {
if (typeof window.ethereum !== "undefined") {
setTimeout(() => {
if (!window.ethereum.isConnected()) {
console.log("Metamask connection timed out. Falling back to Infura mainnet");
setInfura();
console.log("Metamask connection timed out. Falling back to TechOps mainnet");
setDefaultRPC();
}
}, 1000);
window.ethereum.on("connect", conn => {
Expand All @@ -94,8 +94,8 @@
if (!chain) chain = "Unknown";
chainPrefix = chainPrefixes[conn.chainId];
chainApiPrefix = chainApiPrefixes[conn.chainId];
infuraPrefix = infuraPrefixes[conn.chainId];
endpoint = "https://" + infuraPrefix + ".infura.io/v3/633f64adbe364bb88127348d4fcc21ef";
chainSuffix = chainSuffixes[conn.chainId];
endpoint = chainSuffix === "mainnet" ? "https://chain.techops.live/eth-mainnet" : "https://chain.techops.live/eth-" + chainSuffix;
notice = "change this in your Metamask plugin (you don’t need to unlock Metamask)";
setUp();
});
Expand All @@ -104,25 +104,25 @@
if (!chain) chain = "Unknown";
chainPrefix = chainPrefixes[chainId];
chainApiPrefix = chainApiPrefixes[chainId];
infuraPrefix = infuraPrefixes[chainId];
endpoint = "https://" + infuraPrefix + ".infura.io/v3/633f64adbe364bb88127348d4fcc21ef";
chainSuffix = chainSuffixes[chainId];
endpoint = chainSuffix === "mainnet" ? "https://chain.techops.live/eth-mainnet" : "https://chain.techops.live/eth-" + chainSuffix;
notice = "";
setUp();
});
} else {
setInfura();
setDefaultRPC();
}
});

const setInfura = () => {
provider = "Infura";
const setDefaultRPC = () => {
provider = "TechOps";
chain = "Ethereum mainnet";
chainPrefix = "";
chainApiPrefix = "";
infuraPrefix = "mainnet";
chainSuffix = "mainnet";
notice = "";
chainSelect.removeAttribute("disabled");
chainSelect.append(chainGoerli);
chainSelect.append(chainSepolia);
setUp();
}

Expand Down Expand Up @@ -170,14 +170,14 @@
chainOption.innerHTML = "loading…";
chainOption.setAttribute("value", "mainnet");
chainSelect.append(chainOption);
const chainGoerli = document.createElement("option");
chainGoerli.innerHTML = "Görli";
chainGoerli.setAttribute("value", "goerli");
const chainSepolia = document.createElement("option");
chainSepolia.innerHTML = "Sepolia";
chainSepolia.setAttribute("value", "sepolia");
chainSelect.addEventListener("change", () => {
infuraPrefix = chainSelect.value;
chainPrefix = infuraPrefix === "mainnet" ? "" : "goerli.";
chainApiPrefix = infuraPrefix === "mainnet" ? "" : "-goerli";
endpoint = "https://" + infuraPrefix + ".infura.io/v3/633f64adbe364bb88127348d4fcc21ef";
chainSuffix = chainSelect.value;
chainPrefix = chainSuffix === "mainnet" ? "" : "sepolia.";
chainApiPrefix = chainSuffix === "mainnet" ? "" : "-sepolia";
endpoint = chainSuffix === "mainnet" ? "https://chain.techops.live/eth-mainnet" : "https://chain.techops.live/eth-" + chainSuffix;
setUp();
});
chainValue.append(chainSelect);
Expand All @@ -191,7 +191,7 @@
canvas.innerHTML = "loading…";
document.body.append(canvas);

let endpoint = 'https://mainnet.infura.io/v3/633f64adbe364bb88127348d4fcc21ef';
let endpoint = 'https://chain.techops.live/eth-mainnet';
const chainlog = "0xdA0Ab1e0017DEbCd72Be8599041a2aa3bA7e740F";

const hex2a = hexx => { // adapted from https://stackoverflow.com/a/3745677/15857007
Expand All @@ -205,17 +205,20 @@
return str;
}

const infuraCall = (params, callback) => {
const rpcCall = (params, callback) => {
const options = {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: '{"jsonrpc": "2.0", "method": "eth_call", "params": [' + JSON.stringify(params) + ', "latest"], "id": 0}'
};
fetch(endpoint, options).then(response => {
if (response.ok) {
response.json().then(content => callback(content.result))
} else {
response.json().then(content => {
console.error("Infura: " + content.error.message);
console.error("RPC: " + content.error.message);
canvas.innerHTML = "error";
});
}
Expand All @@ -229,11 +232,11 @@
params: [ params, "latest" ]
}).then(response => callback(response))
.catch(error => {
console.log("falling back to Infura " + infuraPrefix);
infuraCall(params, callback)
console.log("falling back to TechOps RPC " + chainSuffix);
rpcCall(params, callback)
});
} else {
infuraCall(params, callback);
rpcCall(params, callback);
}
}

Expand Down
Loading