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

View File

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

View File

@ -92,6 +92,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

@ -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://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',
10: 'https://api.thegraph.com/subgraphs/name/tornadocash/optimism-tornado-subgraph',
56: 'https://api.thegraph.com/subgraphs/name/tornadocash/bsc-tornado-subgraph',
100: 'https://api.thegraph.com/subgraphs/name/tornadocash/xdai-tornado-subgraph',
137: 'https://api.thegraph.com/subgraphs/name/tornadocash/matic-tornado-subgraph',
42161: 'https://api.thegraph.com/subgraphs/name/tornadocash/arbitrum-tornado-subgraph',
43114: 'https://api.thegraph.com/subgraphs/name/tornadocash/avalanche-tornado-subgraph'
56:
'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 = {