Skip to content

Commit afff7b7

Browse files
Merge pull request #40 from sky-ecosystem/TECH-5378-aetherlay-rpc-endpoints
Tech 5378 aetherlay rpc endpoints
2 parents 5e9018a + 18b9c7c commit afff7b7

File tree

9 files changed

+76
-77
lines changed

9 files changed

+76
-77
lines changed

.github/workflows/tests.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ jobs:
1818
- name: Start and test chainlog containers
1919
id: start-containers
2020
env:
21-
INFURA_KEY: ${{ secrets.INFURA_KEY }}
2221
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2322
working-directory: ./
2423
run: |

api.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ <h2>Code examples</h2>
4444
Please note that the above code will only retreive the latest data.<br/><br/>
4545
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>:
4646
<pre>
47-
keys = requests.post("https://mainnet.infura.io/v3/" + infura_key, json={
47+
keys = requests.post("https://chain.techops.live/eth-mainnet", json={
4848
"jsonrpc": "2.0",
4949
"method": "eth_call",
5050
"params": [{
@@ -55,7 +55,7 @@ <h2>Code examples</h2>
5555
}).json()["result"][130:]
5656
result = {}
5757
for i in range(0, len(keys), 64):
58-
address = "0x" + requests.post("https://mainnet.infura.io/v3/" + infura_key, json={
58+
address = "0x" + requests.post("https://chain.techops.live/eth-mainnet", json={
5959
"jsonrpc": "2.0",
6060
"method": "eth_call",
6161
"params": [{

deploy/prod/chainlog-logger.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@ env:
2828
PYTHONUNBUFFERED:
2929
type: kv
3030
value: "1"
31-
INFURA_KEY:
32-
type: parameterStore
33-
name: infura-key
34-
parameter_name: /eks/maker-prod/chainlog-logger/infura-key
3531
GITHUB_TOKEN:
3632
type: parameterStore
3733
name: github-token

deploy/staging/chainlog-logger.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ env:
2929
PYTHONUNBUFFERED:
3030
type: kv
3131
value: "1"
32-
INFURA_KEY:
33-
type: parameterStore
34-
name: infura-key
35-
parameter_name: /eks/maker-staging/chainlog-logger/infura-key
3632
GITHUB_TOKEN:
3733
type: parameterStore
3834
name: github-token

docker-compose.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ services:
2020
image: chainlog-logger
2121
container_name: chainlog-logger
2222
environment:
23-
INFURA_KEY: $INFURA_KEY
2423
GITHUB_TOKEN: $GITHUB_TOKEN
2524
CHAINLOG_REPO: "makerdao/chainlog-ui"
2625
PYTHONUNBUFFERED: 1

examples/python.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
import os, requests
44

5-
infura_key = os.environ["INFURA_KEY"]
6-
keys = requests.post("https://mainnet.infura.io/v3/" + infura_key, json={
5+
keys = requests.post("https://chain.techops.live/eth-mainnet", json={
76
"jsonrpc": "2.0",
87
"method": "eth_call",
98
"params": [{
@@ -14,7 +13,7 @@
1413
}).json()["result"][130:]
1514
result = {}
1615
for i in range(0, len(keys), 64):
17-
address = "0x" + requests.post("https://mainnet.infura.io/v3/" + infura_key, json={
16+
address = "0x" + requests.post("https://chain.techops.live/eth-mainnet", json={
1817
"jsonrpc": "2.0",
1918
"method": "eth_call",
2019
"params": [{

index.html

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -40,31 +40,31 @@
4040
"0x1": "Ethereum mainnet",
4141
"0x3": "Ropsten",
4242
"0x4": "Rinkeby",
43-
"0x5": "Görli",
43+
"0xaa36a7": "Sepolia",
4444
"0x2a": "Kovan"
4545
}
4646

4747
const chainPrefixes = {
4848
"0x1": "",
4949
"0x3": "ropsten.",
5050
"0x4": "rinkeby.",
51-
"0x5": "goerli.",
51+
"0xaa36a7": "sepolia.",
5252
"0x2a": "kovan."
5353
}
5454

5555
const chainApiPrefixes = {
5656
"0x1": "",
5757
"0x3": "-ropsten",
5858
"0x4": "-rinkeby",
59-
"0x5": "-goerli",
59+
"0xaa36a7": "-sepolia",
6060
"0x2a": "-kovan"
6161
}
6262

63-
const infuraPrefixes = {
63+
const chainSuffixes = {
6464
"0x1": "mainnet",
6565
"0x3": "ropsten",
6666
"0x4": "rinkeby",
67-
"0x5": "goerli",
67+
"0xaa36a7": "sepolia",
6868
"0x2a": "kovan"
6969
}
7070

@@ -79,13 +79,13 @@
7979
}, draw);
8080
}
8181

82-
let provider, chain, chainPrefix, chainApiPrefix, infuraPrefix, notice;
82+
let provider, chain, chainPrefix, chainApiPrefix, chainSuffix, notice;
8383
window.addEventListener("load", () => {
8484
if (typeof window.ethereum !== "undefined") {
8585
setTimeout(() => {
8686
if (!window.ethereum.isConnected()) {
87-
console.log("Metamask connection timed out. Falling back to Infura mainnet");
88-
setInfura();
87+
console.log("Metamask connection timed out. Falling back to TechOps mainnet");
88+
setDefaultRPC();
8989
}
9090
}, 1000);
9191
window.ethereum.on("connect", conn => {
@@ -94,8 +94,8 @@
9494
if (!chain) chain = "Unknown";
9595
chainPrefix = chainPrefixes[conn.chainId];
9696
chainApiPrefix = chainApiPrefixes[conn.chainId];
97-
infuraPrefix = infuraPrefixes[conn.chainId];
98-
endpoint = "https://" + infuraPrefix + ".infura.io/v3/633f64adbe364bb88127348d4fcc21ef";
97+
chainSuffix = chainSuffixes[conn.chainId];
98+
endpoint = chainSuffix === "mainnet" ? "https://chain.techops.live/eth-mainnet" : "https://chain.techops.live/eth-" + chainSuffix;
9999
notice = "change this in your Metamask plugin (you don’t need to unlock Metamask)";
100100
setUp();
101101
});
@@ -104,25 +104,25 @@
104104
if (!chain) chain = "Unknown";
105105
chainPrefix = chainPrefixes[chainId];
106106
chainApiPrefix = chainApiPrefixes[chainId];
107-
infuraPrefix = infuraPrefixes[chainId];
108-
endpoint = "https://" + infuraPrefix + ".infura.io/v3/633f64adbe364bb88127348d4fcc21ef";
107+
chainSuffix = chainSuffixes[chainId];
108+
endpoint = chainSuffix === "mainnet" ? "https://chain.techops.live/eth-mainnet" : "https://chain.techops.live/eth-" + chainSuffix;
109109
notice = "";
110110
setUp();
111111
});
112112
} else {
113-
setInfura();
113+
setDefaultRPC();
114114
}
115115
});
116116

117-
const setInfura = () => {
118-
provider = "Infura";
117+
const setDefaultRPC = () => {
118+
provider = "TechOps";
119119
chain = "Ethereum mainnet";
120120
chainPrefix = "";
121121
chainApiPrefix = "";
122-
infuraPrefix = "mainnet";
122+
chainSuffix = "mainnet";
123123
notice = "";
124124
chainSelect.removeAttribute("disabled");
125-
chainSelect.append(chainGoerli);
125+
chainSelect.append(chainSepolia);
126126
setUp();
127127
}
128128

@@ -170,14 +170,14 @@
170170
chainOption.innerHTML = "loading…";
171171
chainOption.setAttribute("value", "mainnet");
172172
chainSelect.append(chainOption);
173-
const chainGoerli = document.createElement("option");
174-
chainGoerli.innerHTML = "Görli";
175-
chainGoerli.setAttribute("value", "goerli");
173+
const chainSepolia = document.createElement("option");
174+
chainSepolia.innerHTML = "Sepolia";
175+
chainSepolia.setAttribute("value", "sepolia");
176176
chainSelect.addEventListener("change", () => {
177-
infuraPrefix = chainSelect.value;
178-
chainPrefix = infuraPrefix === "mainnet" ? "" : "goerli.";
179-
chainApiPrefix = infuraPrefix === "mainnet" ? "" : "-goerli";
180-
endpoint = "https://" + infuraPrefix + ".infura.io/v3/633f64adbe364bb88127348d4fcc21ef";
177+
chainSuffix = chainSelect.value;
178+
chainPrefix = chainSuffix === "mainnet" ? "" : "sepolia.";
179+
chainApiPrefix = chainSuffix === "mainnet" ? "" : "-sepolia";
180+
endpoint = chainSuffix === "mainnet" ? "https://chain.techops.live/eth-mainnet" : "https://chain.techops.live/eth-" + chainSuffix;
181181
setUp();
182182
});
183183
chainValue.append(chainSelect);
@@ -191,7 +191,7 @@
191191
canvas.innerHTML = "loading…";
192192
document.body.append(canvas);
193193

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

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

208-
const infuraCall = (params, callback) => {
208+
const rpcCall = (params, callback) => {
209209
const options = {
210210
method: "POST",
211+
headers: {
212+
"Content-Type": "application/json"
213+
},
211214
body: '{"jsonrpc": "2.0", "method": "eth_call", "params": [' + JSON.stringify(params) + ', "latest"], "id": 0}'
212215
};
213216
fetch(endpoint, options).then(response => {
214217
if (response.ok) {
215218
response.json().then(content => callback(content.result))
216219
} else {
217220
response.json().then(content => {
218-
console.error("Infura: " + content.error.message);
221+
console.error("RPC: " + content.error.message);
219222
canvas.innerHTML = "error";
220223
});
221224
}
@@ -229,11 +232,11 @@
229232
params: [ params, "latest" ]
230233
}).then(response => callback(response))
231234
.catch(error => {
232-
console.log("falling back to Infura " + infuraPrefix);
233-
infuraCall(params, callback)
235+
console.log("falling back to TechOps RPC " + chainSuffix);
236+
rpcCall(params, callback)
234237
});
235238
} else {
236-
infuraCall(params, callback);
239+
rpcCall(params, callback);
237240
}
238241
}
239242

0 commit comments

Comments
 (0)