Compare commits
No commits in common. "e6e2e0a2919327bcb4d3e3c702d071dc38132b59" and "4b9baa63d0f11830548d7237aa06b86e27a33475" have entirely different histories.
e6e2e0a291
...
4b9baa63d0
@ -16,7 +16,7 @@ RUN ipfs init
|
|||||||
|
|
||||||
ENV GIT_REPOSITORY=https://codeberg.org/tornadocash/relayers-network-ui.git
|
ENV GIT_REPOSITORY=https://codeberg.org/tornadocash/relayers-network-ui.git
|
||||||
# From development branch, double check with tornado.ws
|
# From development branch, double check with tornado.ws
|
||||||
ENV GIT_COMMIT_HASH=e5f1b6f91c372fc58a7a6eb463e21a62a059db3b
|
ENV GIT_COMMIT_HASH=382fe5a1274a9c553cf962721e96a93b274ff823
|
||||||
|
|
||||||
# clone the repository
|
# clone the repository
|
||||||
RUN mkdir /app/
|
RUN mkdir /app/
|
||||||
|
|||||||
@ -6,5 +6,6 @@ export const GRAPHQL_LIMIT = 1000
|
|||||||
* todo: add support for subgraph on thegraph & API keys
|
* todo: add support for subgraph on thegraph & API keys
|
||||||
*/
|
*/
|
||||||
export const RELAYER_SUBGRAPH_LIST: Record<number, string> = {
|
export const RELAYER_SUBGRAPH_LIST: Record<number, string> = {
|
||||||
[ChainId.MAINNET]: process.env.MAINNET_SUBGRAPH ?? 'https://tornadocash-rpc.com/subgraphs/name/tornadocash/tornado-governance',
|
[ChainId.MAINNET]:
|
||||||
|
process.env.MAINNET_SUBGRAPH ?? 'https://tornadocash-rpc.com/subgraphs/name/tornadocash/tornado-relayer-registry',
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,22 +8,20 @@ import { getRelayerRegistry } from '@/contracts'
|
|||||||
import { DEPLOYED_BLOCK, GRAPHQL_LIMIT, RELAYER_SUBGRAPH_LIST, errors, numbers } from '@/constants'
|
import { DEPLOYED_BLOCK, GRAPHQL_LIMIT, RELAYER_SUBGRAPH_LIST, errors, numbers } from '@/constants'
|
||||||
import { ensService, tornadoRelayerService } from '@/services'
|
import { ensService, tornadoRelayerService } from '@/services'
|
||||||
import { errorParser, fromWei, toDecimalsPlaces } from '@/utilities'
|
import { errorParser, fromWei, toDecimalsPlaces } from '@/utilities'
|
||||||
import { getAddress, parseEther } from 'ethers/lib/utils'
|
import { getAddress } from 'ethers/lib/utils'
|
||||||
import { BigNumber } from 'ethers'
|
|
||||||
|
|
||||||
interface GraphRelayer {
|
interface GraphRelayer {
|
||||||
|
id: string
|
||||||
address: string
|
address: string
|
||||||
ensName: string
|
ensName: string
|
||||||
ensHash: string
|
ensHash: string
|
||||||
|
|
||||||
workers: string[]
|
|
||||||
stakeBalance: string
|
|
||||||
blockRegistration: string
|
blockRegistration: string
|
||||||
}
|
}
|
||||||
|
|
||||||
interface GraphRelayerFormatted extends Omit<GraphRelayer, 'stakeBalance' | 'blockRegistration'> {
|
interface GraphRelayerFormatted extends Omit<GraphRelayer, 'id' | 'blockRegistration'> {
|
||||||
stakeBalance: BigNumber
|
|
||||||
registerBlock: number
|
registerBlock: number
|
||||||
|
registerTx: string
|
||||||
|
registerLogIndex: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export const actions: ActionTree<RelayerState, RootState> = {
|
export const actions: ActionTree<RelayerState, RootState> = {
|
||||||
@ -69,6 +67,9 @@ export const actions: ActionTree<RelayerState, RootState> = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* todo: add worker events to relayer registry subgraph
|
||||||
|
*/
|
||||||
async getRelayersFromGraph({ getters }) {
|
async getRelayersFromGraph({ getters }) {
|
||||||
try {
|
try {
|
||||||
const { chainId } = getters.dependencies
|
const { chainId } = getters.dependencies
|
||||||
@ -84,12 +85,10 @@ export const actions: ActionTree<RelayerState, RootState> = {
|
|||||||
query: `
|
query: `
|
||||||
query getRelayers($first: Int) {
|
query getRelayers($first: Int) {
|
||||||
relayers(first: $first, orderBy: blockRegistration, orderDirection: asc) {
|
relayers(first: $first, orderBy: blockRegistration, orderDirection: asc) {
|
||||||
|
id
|
||||||
address
|
address
|
||||||
ensName
|
ensName
|
||||||
ensHash
|
ensHash
|
||||||
|
|
||||||
workers
|
|
||||||
stakeBalance
|
|
||||||
blockRegistration
|
blockRegistration
|
||||||
}
|
}
|
||||||
_meta {
|
_meta {
|
||||||
@ -116,22 +115,22 @@ export const actions: ActionTree<RelayerState, RootState> = {
|
|||||||
throw new Error(`Error from graph: ${JSON.stringify(errors)}`)
|
throw new Error(`Error from graph: ${JSON.stringify(errors)}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
if (data?._meta?.hasIndexingErrors) {
|
if (data?._meta?.hasIndexingErrors) {
|
||||||
throw new Error('Subgraph has indexing errors')
|
throw new Error('Subgraph has indexing errors');
|
||||||
}
|
}
|
||||||
|
**/
|
||||||
|
|
||||||
return (data.relayers as GraphRelayer[]).map(({ address, ensName, ensHash, workers, stakeBalance, blockRegistration }) => {
|
return (data.relayers as GraphRelayer[]).map(({ id, address, ensName, ensHash, blockRegistration }) => {
|
||||||
if (!workers.includes(address)) {
|
const [registerTx, registerLogIndex] = id.split('-')
|
||||||
workers.push(getAddress(address))
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
address: getAddress(address),
|
address: getAddress(address),
|
||||||
ensName,
|
ensName,
|
||||||
ensHash,
|
ensHash,
|
||||||
workers,
|
|
||||||
stakeBalance: parseEther(stakeBalance),
|
|
||||||
registerBlock: Number(blockRegistration),
|
registerBlock: Number(blockRegistration),
|
||||||
|
registerTx,
|
||||||
|
registerLogIndex: Number(registerLogIndex),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@ -164,8 +163,9 @@ export const actions: ActionTree<RelayerState, RootState> = {
|
|||||||
|
|
||||||
async getRelayers({ getters, commit, dispatch }) {
|
async getRelayers({ getters, commit, dispatch }) {
|
||||||
try {
|
try {
|
||||||
const { walletAddress } = getters.dependencies
|
const { walletAddress, chainId } = getters.dependencies
|
||||||
|
|
||||||
|
// todo: add worker data
|
||||||
const relayers = (await dispatch('getRelayersFromGraph')) as GraphRelayerFormatted[]
|
const relayers = (await dispatch('getRelayersFromGraph')) as GraphRelayerFormatted[]
|
||||||
|
|
||||||
const relayer = relayers.find((r) => r.address === walletAddress)
|
const relayer = relayers.find((r) => r.address === walletAddress)
|
||||||
@ -174,8 +174,13 @@ export const actions: ActionTree<RelayerState, RootState> = {
|
|||||||
throw new Error(`No relayer found for ${walletAddress}`)
|
throw new Error(`No relayer found for ${walletAddress}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
commit(RelayerMutation.SET_WORKERS, relayer.workers)
|
const registryContract = getRelayerRegistry(chainId)
|
||||||
commit(RelayerMutation.SET_BALANCE, relayer.stakeBalance)
|
|
||||||
|
const { balance } = await registryContract.callStatic.relayers(walletAddress)
|
||||||
|
|
||||||
|
// todo: add worker data
|
||||||
|
commit(RelayerMutation.SET_WORKERS, [walletAddress])
|
||||||
|
commit(RelayerMutation.SET_BALANCE, balance)
|
||||||
|
|
||||||
await dispatch('getRelayerENSData', relayer.ensName)
|
await dispatch('getRelayerENSData', relayer.ensName)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user