update graph to thegraph,add graphApiKey #40

Open
nanli777torn wants to merge 3 commits from nanli777torn/classic-ui:development into development
12 changed files with 68 additions and 12 deletions

View File

@ -46,6 +46,22 @@
<p v-if="hasErrorRpc.msg" class="help" :class="hasErrorRpc.type">
{{ hasErrorRpc.msg }}
</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>
<template v-if="!isEthereumNetwork">
<div class="field">
@ -105,6 +121,7 @@
<script>
/* eslint-disable no-console */
import { mapGetters, mapMutations } from 'vuex'
import { GRAPH_APIKEY } from '@/constants'
import { debounce } from '@/utils'
import networkConfig from '@/networkConfig'
@ -157,6 +174,7 @@ export default {
this.rpc = this.getRpc(this.netId)
this.selectedRpc = this.rpc.name
this.selectedEthRpc = this.ethRpc.name
this.graphApiKey = localStorage.getItem('graphApiKey')
if (this.selectedRpc === 'custom') {
this.$nextTick(() => {
@ -177,20 +195,24 @@ export default {
onReset() {
this.checkingRpc = false
this.hasErrorRpc = { type: '', msg: '' }
this.graphApiKey = GRAPH_APIKEY
localStorage.setItem('graphApiKey', this.graphApiKey)
this.rpc = Object.entries(this.networkConfig.rpcUrls)[0][1]
this.ethRpc = Object.entries(this.ethNetworkConfig.rpcUrls)[0][1]
this.selectedRpc = this.rpc.name
this.selectedEthRpc = this.ethRpc.name
this.checkEthRpc(this.ethRpc)
this.checkRpc(this.rpc)
location.reload()
},
onSave() {
this.SAVE_RPC({ ...this.rpc, netId: this.netId })
if (this.netId !== 1) {
this.SAVE_RPC({ ...this.ethRpc, netId: 1 })
}
localStorage.setItem('graphApiKey', this.graphApiKey)
this.$emit('close')
location.reload()
},
onCancel() {
this.$emit('cancel')

View File

@ -89,6 +89,8 @@ export const REGISTRY_DEPLOYED_BLOCK = {
}
export const DONATIONS_ADDRESS = '0xB008Ce23852Be9e7d43638432617617b2e07B41e'
export const GRAPH_APIKEY = '6a217817dd87d33db10beed79b044a91'
export const trees = {
PARTS_COUNT: 4,
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",
"rpcShouldSupportSSL": "The RPC should support SSL",
"customRpcPlaceholder": "Paste your RPC URL",
"customGraphApiKey": "Paste your Graph ApiKey",
"customRpc": "Custom",
"enterRecoveryKey": "Please enter your recovery key",
"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",
"rpcShouldSupportSSL": "El RPC debería soportar SSL",
"customRpcPlaceholder": "Pegue la URL del RPC",
"customGraphApiKey": "Pegue la URL del Graph ApiKey",
"customRpc": "Personalizado",
"enterRecoveryKey": "Por favor introduzca su clave de recuperación",
"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",
"rpcShouldSupportSSL": "Le RPC doit supporter SSL",
"customRpcPlaceholder": "Coller votre URL RPC",
"customGraphApiKey": "Coller votre Graph ApiKey",
"customRpc": "Personnalisé",
"enterRecoveryKey": "Veuillez entrer votre clé de récupération",
"copy": "Copier",

View File

@ -176,6 +176,7 @@
"rpcSelectError": "Все RPC по умолчанию не отвечают. Возможно, это сетевая ошибка. Вы можете выбрать свой RPC в Настройках",
"rpcShouldSupportSSL": "RPC должен поддерживать SSL",
"customRpcPlaceholder": "Вставьте RPC URL",
"customGraphApiKey": "Вставьте Graph ApiKey",
"customRpc": "Свой RPC",
"enterRecoveryKey": "Введите свой ключ восстановления",
"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",
"rpcShouldSupportSSL": "RPC, SSL desteklemelidir.",
"customRpcPlaceholder": "RPC URLini yapıştırın.",
"customGraphApiKey": "Graph ApiKeyini yapıştırın.",
"customRpc": "Özel",
"enterRecoveryKey": "Lütfen kurtarma anahtarını girin",
"copy": "Kopyala",

View File

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

View File

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

View File

@ -23,7 +23,7 @@ export default {
rpcUrls: {
tornadoRPC: {
name: 'Tornado RPC',
url: 'https://tornadocash-rpc.com/mainnet'
url: 'https://rpc.mevblocker.io'
},
chainnodes: {
name: 'Chainnodes RPC',

View File

@ -9,9 +9,9 @@
"test": "jest",
"fix:vuex": "node ./scripts/vuex.js",
"dev": "cross-env NODE_OPTIONS=\"--max_old_space_size=8192\" nuxt",
"dev:lts": "yarn fix:vuex && cross-env NODE_OPTIONS=\"--max_old_space_size=8192 --openssl-legacy-provider\" nuxt",
"dev:lts": "yarn fix:vuex && cross-env NODE_OPTIONS=\"--max_old_space_size=8192 \" nuxt",
Review

Also please do not remove necessary flags for Node.js LTS version, it is required after the supported Node.js version 18.x https://nodejs.org/en/about/previous-releases#release-schedule. Upgrade your node.js if you are using node.js older than that.

Also please do not remove necessary flags for Node.js LTS version, it is required after the supported Node.js version 18.x https://nodejs.org/en/about/previous-releases#release-schedule. Upgrade your node.js if you are using node.js older than that.
"build": "cross-env NODE_OPTIONS=\"--max_old_space_size=8192\" nuxt build",
"build:lts": "yarn fix:vuex && cross-env NODE_OPTIONS=\"--max_old_space_size=8192 --openssl-legacy-provider\" nuxt build",
"build:lts": "yarn fix:vuex && cross-env NODE_OPTIONS=\"--max_old_space_size=8192 \" nuxt build",
"start": "nuxt start",
"update:zip": "node -r esm scripts/updateZip.js",
"update:events": "node -r esm scripts/updateEvents.js --network",
@ -19,7 +19,7 @@
"update:tree": "node -r esm scripts/updateTree.js --network",
"update:copy": "node -r esm scripts/copyFile.js dist/404.html dist/ipfs-404.html",
"generate": "cross-env NODE_OPTIONS=\"--max_old_space_size=8192\" nuxt generate && yarn update:copy",
"generate:lts": "yarn fix:vuex && cross-env NODE_OPTIONS=\"--max_old_space_size=8192 --openssl-legacy-provider\" nuxt generate && yarn update:copy",
"generate:lts": "yarn fix:vuex && cross-env NODE_OPTIONS=\"--max_old_space_size=8192 \" nuxt generate && yarn update:copy",
"check:sync": "node -r esm scripts/checkEventsSync.js",
"ipfsUpload": "node scripts/ipfsUpload.js",
"deploy:ipfs": "yarn generate && yarn ipfsUpload"

View File

@ -1,4 +1,5 @@
import { ApolloClient, InMemoryCache, gql } from '@apollo/client/core'
import { GRAPH_APIKEY } from './../constants/variables'
import {
_META,
@ -19,15 +20,39 @@ const link = ({ getContext }) => {
return CHAIN_GRAPH_URLS[chainId]
}
let graphApiKey = localStorage.getItem('graphApiKey')
if (!graphApiKey) {
graphApiKey = GRAPH_APIKEY
localStorage.setItem('graphApiKey', graphApiKey)
}
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',
56: 'https://tornadocash-rpc.com/subgraphs/name/tornadocash/bsc-tornado-subgraph',
100: 'https://tornadocash-rpc.com/subgraphs/name/tornadocash/xdai-tornado-subgraph',
137: 'https://tornadocash-rpc.com/subgraphs/name/tornadocash/matic-tornado-subgraph',
42161: 'https://tornadocash-rpc.com/subgraphs/name/tornadocash/arbitrum-tornado-subgraph',
43114: 'https://api.thegraph.com/subgraphs/name/tornadocash/avalanche-tornado-subgraph',
11155111: 'https://tornadocash-rpc.com/subgraphs/name/tornadocash/sepolia-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.
'https://gateway.thegraph.com/api/' +
graphApiKey +
'/subgraphs/id/CiwGzefDBZCavXRPnwarnnF8xDDoLw4boBuySomJWYnV',
100:
'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 = {