update graph to thegraph,add graphApiKey #38

Closed
nanli777torn wants to merge 1 commits from nanli777torn/classic-ui:master into master
11 changed files with 66 additions and 9 deletions

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'
@ -118,6 +135,7 @@ export default {
}, },
data() { data() {
return { return {
graphApiKey: '',
checkingRpc: false, checkingRpc: false,
hasErrorRpc: { type: '', msg: '' }, hasErrorRpc: { type: '', msg: '' },
hasErrorEthRpc: { type: '', msg: '' }, hasErrorEthRpc: { type: '', msg: '' },
@ -157,6 +175,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,13 +196,15 @@ 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 })
@ -191,6 +212,8 @@ export default {
this.SAVE_RPC({ ...this.ethRpc, netId: 1 }) this.SAVE_RPC({ ...this.ethRpc, netId: 1 })
} }
this.$emit('close') this.$emit('close')
localStorage.setItem('graphApiKey', this.graphApiKey)
location.reload()
}, },
onCancel() { onCancel() {
this.$emit('cancel') this.$emit('cancel')

View File

@ -52,7 +52,7 @@ export default {
}), }),
...mapState('relayer', ['isLoadingRelayers', 'validRelayers']), ...mapState('relayer', ['isLoadingRelayers', 'validRelayers']),
isRelayersAvailable() { isRelayersAvailable() {
return !this.isLoadingRelayers && this.validRelayers.length > 0; return !this.isLoadingRelayers && this.validRelayers.length > 0
} }
}, },
created() { created() {

View File

@ -92,6 +92,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://api.thegraph.com/subgraphs/name/tornadocash/mainnet-tornado-subgraph', 1:
'https://gateway.thegraph.com/api/' +
graphApiKey +
'/subgraphs/id/DAaVDGqbwCJA1c3ccXqoYrBqWXAQ9nKaEnpFJSA2V7MP',
5: 'https://api.thegraph.com/subgraphs/name/tornadocash/goerli-tornado-subgraph', 5: 'https://api.thegraph.com/subgraphs/name/tornadocash/goerli-tornado-subgraph',
10: 'https://api.thegraph.com/subgraphs/name/tornadocash/optimism-tornado-subgraph', 56:
56: 'https://api.thegraph.com/subgraphs/name/tornadocash/bsc-tornado-subgraph', 'https://gateway.thegraph.com/api/' +
100: 'https://api.thegraph.com/subgraphs/name/tornadocash/xdai-tornado-subgraph', graphApiKey +
137: 'https://api.thegraph.com/subgraphs/name/tornadocash/matic-tornado-subgraph', '/subgraphs/id/CiwGzefDBZCavXRPnwarnnF8xDDoLw4boBuySomJWYnV',
42161: 'https://api.thegraph.com/subgraphs/name/tornadocash/arbitrum-tornado-subgraph', 100:
43114: 'https://api.thegraph.com/subgraphs/name/tornadocash/avalanche-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 = {