forked from tornadocash/classic-ui
fix: goerli note account
This commit is contained in:
parent
704c853a3c
commit
9f8aad114c
@ -101,7 +101,7 @@
|
|||||||
"spent": "Потрачен",
|
"spent": "Потрачен",
|
||||||
"unspent": "Непотрачен",
|
"unspent": "Непотрачен",
|
||||||
"thereAreNoElements": "Нет элементов, которые соответствуют фильтрам.",
|
"thereAreNoElements": "Нет элементов, которые соответствуют фильтрам.",
|
||||||
"txHash": "Хеш траназакции",
|
"txHash": "Хеш транзакции",
|
||||||
"status": "Состояние",
|
"status": "Состояние",
|
||||||
"copyNote": "Скопировать",
|
"copyNote": "Скопировать",
|
||||||
"decryptCopyNote": "Дешифровать и копировать",
|
"decryptCopyNote": "Дешифровать и копировать",
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { graph } from '@/services'
|
import { getEventsFromBlockPart } from './utils'
|
||||||
|
|
||||||
export async function checkExistAccount({ getters, dispatch, rootState, rootGetters }) {
|
export async function checkExistAccount({ getters, dispatch, rootState, rootGetters }) {
|
||||||
const { ethAccount, netId } = rootState.metamask
|
const { ethAccount, netId } = rootState.metamask
|
||||||
@ -12,10 +12,15 @@ export async function checkExistAccount({ getters, dispatch, rootState, rootGett
|
|||||||
const web3 = this.$provider.getWeb3(rpc.url)
|
const web3 = this.$provider.getWeb3(rpc.url)
|
||||||
const currentBlockNumber = await web3.eth.getBlockNumber()
|
const currentBlockNumber = await web3.eth.getBlockNumber()
|
||||||
|
|
||||||
const isExist = await getEventsFromBlockPart(
|
const events = await getEventsFromBlockPart({
|
||||||
{ getters, dispatch, rootState, rootGetters },
|
netId,
|
||||||
{ netId, currentBlockNumber, address: ethAccount }
|
currentBlockNumber,
|
||||||
)
|
address: ethAccount,
|
||||||
|
echoContract: getters.echoContract
|
||||||
|
})
|
||||||
|
|
||||||
|
const isExist = Boolean(Array.isArray(events) && Boolean(events.length))
|
||||||
|
|
||||||
console.log('isExist', isExist)
|
console.log('isExist', isExist)
|
||||||
|
|
||||||
dispatch('createMutation', {
|
dispatch('createMutation', {
|
||||||
@ -26,52 +31,3 @@ export async function checkExistAccount({ getters, dispatch, rootState, rootGett
|
|||||||
throw new Error(`Method checkExistAccount has error: ${err.message}`)
|
throw new Error(`Method checkExistAccount has error: ${err.message}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getEventsFromBlockPart(
|
|
||||||
{ getters, rootGetters, dispatch },
|
|
||||||
{ address, currentBlockNumber, netId }
|
|
||||||
) {
|
|
||||||
try {
|
|
||||||
const { events: graphEvents, lastSyncBlock } = await graph.getNoteAccounts({ address, netId })
|
|
||||||
|
|
||||||
const blockDifference = Math.ceil(currentBlockNumber - lastSyncBlock)
|
|
||||||
let blockRange = 1
|
|
||||||
|
|
||||||
if (Number(netId) === 56) {
|
|
||||||
blockRange = 4950
|
|
||||||
}
|
|
||||||
|
|
||||||
let numberParts = blockDifference === 0 ? 1 : Math.ceil(blockDifference / blockRange)
|
|
||||||
const part = Math.ceil(blockDifference / numberParts)
|
|
||||||
|
|
||||||
let events = []
|
|
||||||
|
|
||||||
let fromBlock = lastSyncBlock
|
|
||||||
let toBlock = lastSyncBlock + part
|
|
||||||
|
|
||||||
if (toBlock >= currentBlockNumber) {
|
|
||||||
toBlock = 'latest'
|
|
||||||
numberParts = 1
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let i = 0; i < numberParts; i++) {
|
|
||||||
const partOfEvents = await getters.echoContract.getEvents({
|
|
||||||
fromBlock,
|
|
||||||
toBlock,
|
|
||||||
address
|
|
||||||
})
|
|
||||||
if (partOfEvents) {
|
|
||||||
events = events.concat(partOfEvents)
|
|
||||||
}
|
|
||||||
fromBlock = toBlock
|
|
||||||
toBlock += part
|
|
||||||
}
|
|
||||||
|
|
||||||
events = graphEvents.concat(events)
|
|
||||||
|
|
||||||
return Boolean(Array.isArray(events) && Boolean(events.length))
|
|
||||||
} catch (err) {
|
|
||||||
console.log(`getEventsFromBlock has error: ${err.message}`)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { graph } from '@/services'
|
import { getEventsFromBlockPart } from '../utils'
|
||||||
import { unpackEncryptedMessage } from '@/utils'
|
import { unpackEncryptedMessage } from '@/utils'
|
||||||
|
|
||||||
export async function getAccountFromAddress({ getters, rootGetters }, address) {
|
export async function getAccountFromAddress({ getters, rootGetters }, address) {
|
||||||
@ -9,7 +9,12 @@ export async function getAccountFromAddress({ getters, rootGetters }, address) {
|
|||||||
const web3 = this.$provider.getWeb3(rpc.url)
|
const web3 = this.$provider.getWeb3(rpc.url)
|
||||||
const currentBlockNumber = await web3.eth.getBlockNumber()
|
const currentBlockNumber = await web3.eth.getBlockNumber()
|
||||||
|
|
||||||
const events = await getEventsFromBlockPart({ getters }, { netId, currentBlockNumber, address })
|
const events = await getEventsFromBlockPart({
|
||||||
|
netId,
|
||||||
|
currentBlockNumber,
|
||||||
|
address,
|
||||||
|
echoContract: getters.echoContract
|
||||||
|
})
|
||||||
|
|
||||||
const [lastEvent] = events.slice(-1)
|
const [lastEvent] = events.slice(-1)
|
||||||
|
|
||||||
@ -31,50 +36,3 @@ export async function getAccountFromAddress({ getters, rootGetters }, address) {
|
|||||||
throw new Error(`Method getAccountFromAddress has error: ${err.message}`)
|
throw new Error(`Method getAccountFromAddress has error: ${err.message}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getEventsFromBlockPart({ getters }, { address, currentBlockNumber, netId }) {
|
|
||||||
try {
|
|
||||||
const { events: graphEvents, lastSyncBlock } = await graph.getNoteAccounts({ address, netId })
|
|
||||||
|
|
||||||
const blockDifference = Math.ceil(currentBlockNumber - lastSyncBlock)
|
|
||||||
|
|
||||||
let blockRange = 1
|
|
||||||
|
|
||||||
if (Number(netId) === 56) {
|
|
||||||
blockRange = 4950
|
|
||||||
}
|
|
||||||
|
|
||||||
let numberParts = blockDifference === 0 ? 1 : Math.ceil(blockDifference / blockRange)
|
|
||||||
const part = Math.ceil(blockDifference / numberParts)
|
|
||||||
|
|
||||||
let events = []
|
|
||||||
|
|
||||||
let fromBlock = lastSyncBlock
|
|
||||||
let toBlock = lastSyncBlock + part
|
|
||||||
|
|
||||||
if (toBlock >= currentBlockNumber) {
|
|
||||||
toBlock = 'latest'
|
|
||||||
numberParts = 1
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let i = 0; i < numberParts; i++) {
|
|
||||||
const partOfEvents = await getters.echoContract.getEvents({
|
|
||||||
fromBlock,
|
|
||||||
toBlock,
|
|
||||||
address
|
|
||||||
})
|
|
||||||
if (partOfEvents) {
|
|
||||||
events = events.concat(partOfEvents)
|
|
||||||
}
|
|
||||||
fromBlock = toBlock
|
|
||||||
toBlock += part
|
|
||||||
}
|
|
||||||
|
|
||||||
events = graphEvents.concat(events)
|
|
||||||
|
|
||||||
return events
|
|
||||||
} catch (err) {
|
|
||||||
console.log(`getEventsFromBlock has error: ${err.message}`)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
import { graph } from '@/services'
|
||||||
|
import networkConfig from '@/networkConfig'
|
||||||
|
|
||||||
function createMutation({ commit, rootState }, { type, payload }) {
|
function createMutation({ commit, rootState }, { type, payload }) {
|
||||||
const { netId } = rootState.metamask
|
const { netId } = rootState.metamask
|
||||||
|
|
||||||
@ -11,4 +14,59 @@ function clearState({ dispatch }, { key }) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export { clearState, createMutation }
|
async function getEventsFromBlockPart({ echoContract, address, currentBlockNumber, netId }) {
|
||||||
|
try {
|
||||||
|
const { events: graphEvents, lastSyncBlock } = await graph.getNoteAccounts({ address, netId })
|
||||||
|
|
||||||
|
if (graphEvents.length) {
|
||||||
|
return graphEvents
|
||||||
|
}
|
||||||
|
|
||||||
|
let { NOTE_ACCOUNT_BLOCK: fromBlock } = networkConfig[`netId${netId}`].constants
|
||||||
|
if (lastSyncBlock) {
|
||||||
|
fromBlock = lastSyncBlock
|
||||||
|
}
|
||||||
|
|
||||||
|
const blockDifference = Math.ceil(currentBlockNumber - lastSyncBlock)
|
||||||
|
|
||||||
|
let blockRange = blockDifference
|
||||||
|
|
||||||
|
if (Number(netId) === 56) {
|
||||||
|
blockRange = 4950
|
||||||
|
}
|
||||||
|
|
||||||
|
let numberParts = blockDifference === 0 ? 1 : Math.ceil(blockDifference / blockRange)
|
||||||
|
const part = Math.ceil(blockDifference / numberParts)
|
||||||
|
|
||||||
|
let events = []
|
||||||
|
|
||||||
|
let toBlock = lastSyncBlock + part
|
||||||
|
|
||||||
|
if (toBlock >= currentBlockNumber) {
|
||||||
|
toBlock = 'latest'
|
||||||
|
numberParts = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let i = 0; i < numberParts; i++) {
|
||||||
|
const partOfEvents = await echoContract.getEvents({
|
||||||
|
fromBlock,
|
||||||
|
toBlock,
|
||||||
|
address
|
||||||
|
})
|
||||||
|
if (partOfEvents) {
|
||||||
|
events = events.concat(partOfEvents)
|
||||||
|
}
|
||||||
|
fromBlock = toBlock
|
||||||
|
toBlock += part
|
||||||
|
}
|
||||||
|
|
||||||
|
events = graphEvents.concat(events)
|
||||||
|
|
||||||
|
return events
|
||||||
|
} catch (err) {
|
||||||
|
console.log(`getEventsFromBlock has error: ${err.message}`)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export { clearState, createMutation, getEventsFromBlockPart }
|
||||||
|
@ -116,7 +116,8 @@ export default {
|
|||||||
ensSubdomainKey: 'mainnet-tornado',
|
ensSubdomainKey: 'mainnet-tornado',
|
||||||
pollInterval: 30,
|
pollInterval: 30,
|
||||||
constants: {
|
constants: {
|
||||||
NOTE_ACCOUNT_BLOCK: 14248730,
|
NOTE_ACCOUNT_BLOCK: 11842486,
|
||||||
|
ENCRYPTED_NOTES_BLOCK: 14248730,
|
||||||
MINING_BLOCK_TIME: 15
|
MINING_BLOCK_TIME: 15
|
||||||
},
|
},
|
||||||
'torn.contract.tornadocash.eth': '0x77777FeDdddFfC19Ff86DB637967013e6C6A116C',
|
'torn.contract.tornadocash.eth': '0x77777FeDdddFfC19Ff86DB637967013e6C6A116C',
|
||||||
@ -174,7 +175,8 @@ export default {
|
|||||||
ensSubdomainKey: 'bsc-tornado',
|
ensSubdomainKey: 'bsc-tornado',
|
||||||
pollInterval: 60,
|
pollInterval: 60,
|
||||||
constants: {
|
constants: {
|
||||||
NOTE_ACCOUNT_BLOCK: 8159269
|
NOTE_ACCOUNT_BLOCK: 8159269,
|
||||||
|
ENCRYPTED_NOTES_BLOCK: 8159269
|
||||||
},
|
},
|
||||||
'tornado-proxy-light.contract.tornadocash.eth': '0x0D5550d52428E7e3175bfc9550207e4ad3859b17'
|
'tornado-proxy-light.contract.tornadocash.eth': '0x0D5550d52428E7e3175bfc9550207e4ad3859b17'
|
||||||
},
|
},
|
||||||
@ -224,7 +226,8 @@ export default {
|
|||||||
ensSubdomainKey: 'polygon-tornado',
|
ensSubdomainKey: 'polygon-tornado',
|
||||||
pollInterval: 60,
|
pollInterval: 60,
|
||||||
constants: {
|
constants: {
|
||||||
NOTE_ACCOUNT_BLOCK: 16257996
|
NOTE_ACCOUNT_BLOCK: 16257996,
|
||||||
|
ENCRYPTED_NOTES_BLOCK: 16257996
|
||||||
},
|
},
|
||||||
'tornado-proxy-light.contract.tornadocash.eth': '0x0D5550d52428E7e3175bfc9550207e4ad3859b17'
|
'tornado-proxy-light.contract.tornadocash.eth': '0x0D5550d52428E7e3175bfc9550207e4ad3859b17'
|
||||||
},
|
},
|
||||||
@ -275,7 +278,8 @@ export default {
|
|||||||
ensSubdomainKey: 'optimism-tornado',
|
ensSubdomainKey: 'optimism-tornado',
|
||||||
pollInterval: 20,
|
pollInterval: 20,
|
||||||
constants: {
|
constants: {
|
||||||
NOTE_ACCOUNT_BLOCK: 2243694
|
NOTE_ACCOUNT_BLOCK: 2243694,
|
||||||
|
ENCRYPTED_NOTES_BLOCK: 2243694
|
||||||
},
|
},
|
||||||
'tornado-proxy-light.contract.tornadocash.eth': '0x0D5550d52428E7e3175bfc9550207e4ad3859b17'
|
'tornado-proxy-light.contract.tornadocash.eth': '0x0D5550d52428E7e3175bfc9550207e4ad3859b17'
|
||||||
},
|
},
|
||||||
@ -329,7 +333,8 @@ export default {
|
|||||||
ensSubdomainKey: 'arbitrum-tornado',
|
ensSubdomainKey: 'arbitrum-tornado',
|
||||||
pollInterval: 20,
|
pollInterval: 20,
|
||||||
constants: {
|
constants: {
|
||||||
NOTE_ACCOUNT_BLOCK: 3430605
|
NOTE_ACCOUNT_BLOCK: 3430605,
|
||||||
|
ENCRYPTED_NOTES_BLOCK: 3430605
|
||||||
},
|
},
|
||||||
'tornado-proxy-light.contract.tornadocash.eth': '0x0D5550d52428E7e3175bfc9550207e4ad3859b17'
|
'tornado-proxy-light.contract.tornadocash.eth': '0x0D5550d52428E7e3175bfc9550207e4ad3859b17'
|
||||||
},
|
},
|
||||||
@ -375,7 +380,8 @@ export default {
|
|||||||
ensSubdomainKey: 'gnosis-tornado',
|
ensSubdomainKey: 'gnosis-tornado',
|
||||||
pollInterval: 60,
|
pollInterval: 60,
|
||||||
constants: {
|
constants: {
|
||||||
NOTE_ACCOUNT_BLOCK: 17754564
|
NOTE_ACCOUNT_BLOCK: 17754564,
|
||||||
|
ENCRYPTED_NOTES_BLOCK: 17754564
|
||||||
},
|
},
|
||||||
'tornado-proxy-light.contract.tornadocash.eth': '0x0D5550d52428E7e3175bfc9550207e4ad3859b17'
|
'tornado-proxy-light.contract.tornadocash.eth': '0x0D5550d52428E7e3175bfc9550207e4ad3859b17'
|
||||||
},
|
},
|
||||||
@ -420,7 +426,8 @@ export default {
|
|||||||
ensSubdomainKey: 'avalanche-tornado',
|
ensSubdomainKey: 'avalanche-tornado',
|
||||||
pollInterval: 60,
|
pollInterval: 60,
|
||||||
constants: {
|
constants: {
|
||||||
NOTE_ACCOUNT_BLOCK: 4429813
|
NOTE_ACCOUNT_BLOCK: 4429813,
|
||||||
|
ENCRYPTED_NOTES_BLOCK: 4429813
|
||||||
},
|
},
|
||||||
'tornado-proxy-light.contract.tornadocash.eth': '0x0D5550d52428E7e3175bfc9550207e4ad3859b17'
|
'tornado-proxy-light.contract.tornadocash.eth': '0x0D5550d52428E7e3175bfc9550207e4ad3859b17'
|
||||||
},
|
},
|
||||||
@ -528,6 +535,7 @@ export default {
|
|||||||
pollInterval: 30,
|
pollInterval: 30,
|
||||||
constants: {
|
constants: {
|
||||||
NOTE_ACCOUNT_BLOCK: 4131375,
|
NOTE_ACCOUNT_BLOCK: 4131375,
|
||||||
|
ENCRYPTED_NOTES_BLOCK: 4131375,
|
||||||
MINING_BLOCK_TIME: 15
|
MINING_BLOCK_TIME: 15
|
||||||
},
|
},
|
||||||
'torn.contract.tornadocash.eth': '0x77777FeDdddFfC19Ff86DB637967013e6C6A116C',
|
'torn.contract.tornadocash.eth': '0x77777FeDdddFfC19Ff86DB637967013e6C6A116C',
|
||||||
|
@ -445,7 +445,7 @@ const actions = {
|
|||||||
try {
|
try {
|
||||||
const { netId } = rootState.metamask
|
const { netId } = rootState.metamask
|
||||||
const rpc = rootGetters['settings/currentRpc']
|
const rpc = rootGetters['settings/currentRpc']
|
||||||
let { NOTE_ACCOUNT_BLOCK: deployedBlock } = networkConfig[`netId${netId}`].constants
|
let { ENCRYPTED_NOTES_BLOCK: deployedBlock } = networkConfig[`netId${netId}`].constants
|
||||||
|
|
||||||
const contractInstance = getters.tornadoProxyContract({ netId })
|
const contractInstance = getters.tornadoProxyContract({ netId })
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user