update graph to thegraph,add graphApiKey #40

Open
nanli777torn wants to merge 3 commits from nanli777torn/classic-ui:development into development
11 changed files with 65 additions and 9 deletions
Showing only changes of commit 8791b5aff8 - Show all commits

View File

@ -1,4 +1,4 @@
# Tornado Cash Classic UI test # Tornado Cash Classic UI
> Self-hostable Tornado Cash UI software for interacting with the protocol > Self-hostable Tornado Cash UI software for interacting with the protocol

View File

@ -46,6 +46,22 @@
<p v-if="hasErrorRpc.msg" class="help" :class="hasErrorRpc.type"> <p v-if="hasErrorRpc.msg" class="help" :class="hasErrorRpc.type">
{{ hasErrorRpc.msg }} {{ hasErrorRpc.msg }}
</p> </p>
<b-field :label="'Graph ApiKey'" class="has-custom-field" data-test="rpc_endpoint_dropdown">
<div slot="trigger" class="has-custom-field">
<b-field class="has-custom-field">
Graph ApiKey
</b-field>
</div>
</b-field>
<div class="field has-custom-field">
<b-input
ref="customInput"
v-model="graphApiKey"
type="url"
:placeholder="$t('customGraphApiKey')"
:use-html5-validation="false"
></b-input>
</div>
</div> </div>
<template v-if="!isEthereumNetwork"> <template v-if="!isEthereumNetwork">
<div class="field"> <div class="field">
@ -105,6 +121,7 @@
<script> <script>
/* eslint-disable no-console */ /* eslint-disable no-console */
import { mapGetters, mapMutations } from 'vuex' import { mapGetters, mapMutations } from 'vuex'
import { GRAPH_APIKEY } from '@/constants'
import { debounce } from '@/utils' import { debounce } from '@/utils'
import networkConfig from '@/networkConfig' import networkConfig from '@/networkConfig'
@ -157,6 +174,7 @@ export default {
this.rpc = this.getRpc(this.netId) this.rpc = this.getRpc(this.netId)
this.selectedRpc = this.rpc.name this.selectedRpc = this.rpc.name
this.selectedEthRpc = this.ethRpc.name this.selectedEthRpc = this.ethRpc.name
this.graphApiKey = localStorage.getItem('graphApiKey')
if (this.selectedRpc === 'custom') { if (this.selectedRpc === 'custom') {
this.$nextTick(() => { this.$nextTick(() => {
@ -177,20 +195,24 @@ export default {
onReset() { onReset() {
this.checkingRpc = false this.checkingRpc = false
this.hasErrorRpc = { type: '', msg: '' } this.hasErrorRpc = { type: '', msg: '' }
this.graphApiKey = GRAPH_APIKEY
localStorage.setItem('graphApiKey', this.graphApiKey)
this.rpc = Object.entries(this.networkConfig.rpcUrls)[0][1] this.rpc = Object.entries(this.networkConfig.rpcUrls)[0][1]
this.ethRpc = Object.entries(this.ethNetworkConfig.rpcUrls)[0][1] this.ethRpc = Object.entries(this.ethNetworkConfig.rpcUrls)[0][1]
this.selectedRpc = this.rpc.name this.selectedRpc = this.rpc.name
this.selectedEthRpc = this.ethRpc.name this.selectedEthRpc = this.ethRpc.name
this.checkEthRpc(this.ethRpc) this.checkEthRpc(this.ethRpc)
this.checkRpc(this.rpc) this.checkRpc(this.rpc)
location.reload()
}, },
onSave() { onSave() {
this.SAVE_RPC({ ...this.rpc, netId: this.netId }) this.SAVE_RPC({ ...this.rpc, netId: this.netId })
if (this.netId !== 1) { if (this.netId !== 1) {
this.SAVE_RPC({ ...this.ethRpc, netId: 1 }) this.SAVE_RPC({ ...this.ethRpc, netId: 1 })
} }
localStorage.setItem('graphApiKey', this.graphApiKey)
this.$emit('close') this.$emit('close')
location.reload()
}, },
onCancel() { onCancel() {
this.$emit('cancel') this.$emit('cancel')

View File

@ -89,6 +89,8 @@ export const REGISTRY_DEPLOYED_BLOCK = {
} }
export const DONATIONS_ADDRESS = '0xB008Ce23852Be9e7d43638432617617b2e07B41e' export const DONATIONS_ADDRESS = '0xB008Ce23852Be9e7d43638432617617b2e07B41e'
export const GRAPH_APIKEY = '6a217817dd87d33db10beed79b044a91'
export const trees = { export const trees = {
PARTS_COUNT: 4, PARTS_COUNT: 4,
LEVELS: 20 // const from contract LEVELS: 20 // const from contract

View File

@ -176,6 +176,7 @@
"rpcSelectError": "All predefined RPCs are down. It's probably a network error. Please select custom RPC in Settings", "rpcSelectError": "All predefined RPCs are down. It's probably a network error. Please select custom RPC in Settings",
"rpcShouldSupportSSL": "The RPC should support SSL", "rpcShouldSupportSSL": "The RPC should support SSL",
"customRpcPlaceholder": "Paste your RPC URL", "customRpcPlaceholder": "Paste your RPC URL",
"customGraphApiKey": "Paste your Graph ApiKey",
"customRpc": "Custom", "customRpc": "Custom",
"enterRecoveryKey": "Please enter your recovery key", "enterRecoveryKey": "Please enter your recovery key",
"copy": "Copy", "copy": "Copy",

View File

@ -172,6 +172,7 @@
"rpcSelectError": "Ninguno de los RPCs predefinidos responden. Probablemente se debe a un fallo de red. Por favor selecciones un RCP personalizado en Configuración", "rpcSelectError": "Ninguno de los RPCs predefinidos responden. Probablemente se debe a un fallo de red. Por favor selecciones un RCP personalizado en Configuración",
"rpcShouldSupportSSL": "El RPC debería soportar SSL", "rpcShouldSupportSSL": "El RPC debería soportar SSL",
"customRpcPlaceholder": "Pegue la URL del RPC", "customRpcPlaceholder": "Pegue la URL del RPC",
"customGraphApiKey": "Pegue la URL del Graph ApiKey",
"customRpc": "Personalizado", "customRpc": "Personalizado",
"enterRecoveryKey": "Por favor introduzca su clave de recuperación", "enterRecoveryKey": "Por favor introduzca su clave de recuperación",
"copy": "Copiar", "copy": "Copiar",

View File

@ -172,6 +172,7 @@
"rpcSelectError": "Tous les RPCs prédéfinis sont en panne. Il s'agit probablement d'une erreur de réseau. Veuillez sélectionner un RPC personnalisé dans les paramètres", "rpcSelectError": "Tous les RPCs prédéfinis sont en panne. Il s'agit probablement d'une erreur de réseau. Veuillez sélectionner un RPC personnalisé dans les paramètres",
"rpcShouldSupportSSL": "Le RPC doit supporter SSL", "rpcShouldSupportSSL": "Le RPC doit supporter SSL",
"customRpcPlaceholder": "Coller votre URL RPC", "customRpcPlaceholder": "Coller votre URL RPC",
"customGraphApiKey": "Coller votre Graph ApiKey",
"customRpc": "Personnalisé", "customRpc": "Personnalisé",
"enterRecoveryKey": "Veuillez entrer votre clé de récupération", "enterRecoveryKey": "Veuillez entrer votre clé de récupération",
"copy": "Copier", "copy": "Copier",

View File

@ -176,6 +176,7 @@
"rpcSelectError": "Все RPC по умолчанию не отвечают. Возможно, это сетевая ошибка. Вы можете выбрать свой RPC в Настройках", "rpcSelectError": "Все RPC по умолчанию не отвечают. Возможно, это сетевая ошибка. Вы можете выбрать свой RPC в Настройках",
"rpcShouldSupportSSL": "RPC должен поддерживать SSL", "rpcShouldSupportSSL": "RPC должен поддерживать SSL",
"customRpcPlaceholder": "Вставьте RPC URL", "customRpcPlaceholder": "Вставьте RPC URL",
"customGraphApiKey": "Вставьте Graph ApiKey",
"customRpc": "Свой RPC", "customRpc": "Свой RPC",
"enterRecoveryKey": "Введите свой ключ восстановления", "enterRecoveryKey": "Введите свой ключ восстановления",
"copy": "Копировать", "copy": "Копировать",

View File

@ -172,6 +172,7 @@
"rpcSelectError": "Önceden tanımlanmış RPCler çalışmıyor. Muhtemelen bir ağ hatası var. Lütfen Ayarlarda özel RPCyi seçin", "rpcSelectError": "Önceden tanımlanmış RPCler çalışmıyor. Muhtemelen bir ağ hatası var. Lütfen Ayarlarda özel RPCyi seçin",
"rpcShouldSupportSSL": "RPC, SSL desteklemelidir.", "rpcShouldSupportSSL": "RPC, SSL desteklemelidir.",
"customRpcPlaceholder": "RPC URLini yapıştırın.", "customRpcPlaceholder": "RPC URLini yapıştırın.",
"customGraphApiKey": "Graph ApiKeyini yapıştırın.",
"customRpc": "Özel", "customRpc": "Özel",
"enterRecoveryKey": "Lütfen kurtarma anahtarını girin", "enterRecoveryKey": "Lütfen kurtarma anahtarını girin",
"copy": "Kopyala", "copy": "Kopyala",

View File

@ -171,6 +171,7 @@
"rpcSelectError": "Всі RPC за замовчуванням не відповідають. Можливо, це мережева помилка. Ви можете вибрати свій RPC в Настройках", "rpcSelectError": "Всі RPC за замовчуванням не відповідають. Можливо, це мережева помилка. Ви можете вибрати свій RPC в Настройках",
"rpcShouldSupportSSL": "RPC повинен підтримувати SSL", "rpcShouldSupportSSL": "RPC повинен підтримувати SSL",
"customRpcPlaceholder": "Вставте RPC URL", "customRpcPlaceholder": "Вставте RPC URL",
"customGraphApiKey": "Вставте Graph ApiKey",
"customRpc": "Свій RPC", "customRpc": "Свій RPC",
"enterRecoveryKey": "Введіть свій ключ відновлення", "enterRecoveryKey": "Введіть свій ключ відновлення",
"copy": "Копіювати", "copy": "Копіювати",

View File

@ -176,6 +176,7 @@
"rpcSelectError": "所有内置节点均无法连接,可能您的网络存在问题", "rpcSelectError": "所有内置节点均无法连接,可能您的网络存在问题",
"rpcShouldSupportSSL": "节点应支持 SSL", "rpcShouldSupportSSL": "节点应支持 SSL",
"customRpcPlaceholder": "粘贴您的节点地址", "customRpcPlaceholder": "粘贴您的节点地址",
"customGraphApiKey": "粘贴您的Graph ApiKey",
"customRpc": "自定义", "customRpc": "自定义",
"enterRecoveryKey": "请输入您的恢复密钥", "enterRecoveryKey": "请输入您的恢复密钥",
"copy": "复制", "copy": "复制",

View File

@ -1,4 +1,5 @@
import { ApolloClient, InMemoryCache, gql } from '@apollo/client/core' import { ApolloClient, InMemoryCache, gql } from '@apollo/client/core'
import { GRAPH_APIKEY } from './../constants/variables'
import { import {
_META, _META,
@ -19,15 +20,39 @@ const link = ({ getContext }) => {
return CHAIN_GRAPH_URLS[chainId] return CHAIN_GRAPH_URLS[chainId]
} }
let graphApiKey = localStorage.getItem('graphApiKey')
if (!graphApiKey) {
graphApiKey = GRAPH_APIKEY
localStorage.setItem('graphApiKey', graphApiKey)
}
const CHAIN_GRAPH_URLS = { const CHAIN_GRAPH_URLS = {
1: 'https://tornadocash-rpc.com/subgraphs/name/tornadocash/mainnet-tornado-subgraph', 1:
'https://gateway.thegraph.com/api/' +
graphApiKey +
'/subgraphs/id/DAaVDGqbwCJA1c3ccXqoYrBqWXAQ9nKaEnpFJSA2V7MP',
10: 'https://tornadocash-rpc.com/subgraphs/name/tornadocash/optimism-tornado-subgraph', 10: 'https://tornadocash-rpc.com/subgraphs/name/tornadocash/optimism-tornado-subgraph',
56: 'https://tornadocash-rpc.com/subgraphs/name/tornadocash/bsc-tornado-subgraph', 56:
Review

Some comments,

  1. TheGraph is an american company, if the US Gov requests to remove any Tornado Cash subgraphs, they must comply.

  2. Therefore, not only the graphApiKey but also the entire endpoint URL ( https://gateway.thegraph.com/api ) should be in replaceable format ( you can refer my previous work https://codeberg.org/tornadocash/classic-ui/pulls/2/files about the changes ).

  3. Also, I would recommend leaving the default URL as is, it is under the control of Theo and will be fixed during this week.

Some comments, 1. TheGraph is an american company, if the US Gov requests to remove any Tornado Cash subgraphs, they must comply. 2. Therefore, not only the graphApiKey but also the entire endpoint URL ( https://gateway.thegraph.com/api ) should be in replaceable format ( you can refer my previous work https://codeberg.org/tornadocash/classic-ui/pulls/2/files about the changes ). 3. Also, I would recommend leaving the default URL as is, it is under the control of Theo and will be fixed during this week.
100: 'https://tornadocash-rpc.com/subgraphs/name/tornadocash/xdai-tornado-subgraph', 'https://gateway.thegraph.com/api/' +
137: 'https://tornadocash-rpc.com/subgraphs/name/tornadocash/matic-tornado-subgraph', graphApiKey +
42161: 'https://tornadocash-rpc.com/subgraphs/name/tornadocash/arbitrum-tornado-subgraph', '/subgraphs/id/CiwGzefDBZCavXRPnwarnnF8xDDoLw4boBuySomJWYnV',
43114: 'https://api.thegraph.com/subgraphs/name/tornadocash/avalanche-tornado-subgraph', 100:
11155111: 'https://tornadocash-rpc.com/subgraphs/name/tornadocash/sepolia-tornado-subgraph' 'https://gateway.thegraph.com/api/' +
graphApiKey +
'/subgraphs/id/F1m8vxuGatCBRvP8fPnnWUJ1oK7kfE1DGdRacqoamLjF',
137:
'https://gateway.thegraph.com/api/' +
graphApiKey +
'/subgraphs/id/HUMgwMYNrPQpnBJgesFXyy5u6jSiJ6u5nNWQng9ayCmD',
42161:
'https://gateway.thegraph.com/api/' +
graphApiKey +
'/subgraphs/id/8x8o6XFAqYZmiPwrJ51UxGTaZLYyW1fFtghvsEy7a1KJ',
43114:
'https://gateway.thegraph.com/api/' +
graphApiKey +
'/subgraphs/id/CqUYVKJT9Jsyt7qnGNrf4FJNHw75ZbFGuzaJgqdaFASo'
} }
const defaultOptions = { const defaultOptions = {