mirror of
https://github.com/tornadocash/tornado-initiation-ui.git
synced 2025-01-05 11:35:05 +01:00
fix steps
This commit is contained in:
parent
ee9fb9dcde
commit
a23fd6faba
@ -3,6 +3,12 @@
|
||||
<diamond :active="!!data.deployerAddress" />
|
||||
<div class="step-body">
|
||||
<h4>{{ data.title }}</h4>
|
||||
<h6 v-if="data.domain">
|
||||
ENS:
|
||||
<a :href="domainUrl(data.expectedAddress)" target="_blank">{{
|
||||
data.domain
|
||||
}}</a>
|
||||
</h6>
|
||||
<i18n
|
||||
v-if="data.deployerAddress"
|
||||
class="deployed"
|
||||
@ -10,7 +16,9 @@
|
||||
path="deployedBy"
|
||||
>
|
||||
<template v-slot:link>
|
||||
<a href="#">{{ data.deployerAddress }}</a>
|
||||
<a :href="txHash(data.deployTransaction)" target="_blank">{{
|
||||
data.deployerAddress
|
||||
}}</a>
|
||||
</template>
|
||||
</i18n>
|
||||
</div>
|
||||
@ -24,7 +32,7 @@
|
||||
type="is-primary"
|
||||
outlined
|
||||
icon-left="tool"
|
||||
:disabled="isNotLoggedIn"
|
||||
:disabled="isNotLoggedIn || !canDeploy(data.domain)"
|
||||
@mousedown="(e) => e.preventDefault()"
|
||||
@click="onDeploy"
|
||||
>
|
||||
@ -50,6 +58,7 @@ export default {
|
||||
},
|
||||
computed: {
|
||||
...mapGetters('provider', ['getProviderName']),
|
||||
...mapGetters('steps', ['canDeploy']),
|
||||
isNotLoggedIn() {
|
||||
return !this.getProviderName
|
||||
},
|
||||
@ -59,7 +68,13 @@ export default {
|
||||
// todo pass ens domain here
|
||||
onDeploy(/* domain */) {
|
||||
// console.log('this.props', this.data)
|
||||
this.deployContract({ domain: this.data.domain })
|
||||
this.deployContract({ action: this.data })
|
||||
},
|
||||
domainUrl(address) {
|
||||
return `https://etherscan.io/address/${address}`
|
||||
},
|
||||
txHash(txHash) {
|
||||
return `https://etherscan.io/tx/${txHash}`
|
||||
},
|
||||
},
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
@ -1,6 +1,6 @@
|
||||
/* eslint-disable no-console */
|
||||
import Web3 from 'web3'
|
||||
import { numberToHex } from 'web3-utils'
|
||||
import { hexToNumber, numberToHex } from 'web3-utils'
|
||||
import deployerABI from '../abi/deployer.abi.json'
|
||||
import deploymentActions from '../static/deploymentActions.json'
|
||||
|
||||
@ -9,10 +9,15 @@ const state = () => {
|
||||
}
|
||||
|
||||
const getters = {
|
||||
deployerContract: (state, getters, rootState, rootGetters) => {
|
||||
deployerContract: (state, getters, rootState, rootGetters) => (isProxy) => {
|
||||
const { rpcUrls } = rootGetters['provider/getNetwork']
|
||||
const web3 = new Web3(rpcUrls.Infura.url)
|
||||
return new web3.eth.Contract(deployerABI, deploymentActions.deployer)
|
||||
return new web3.eth.Contract(
|
||||
deployerABI,
|
||||
isProxy
|
||||
? deploymentActions.deployer
|
||||
: deploymentActions.actions[0].expectedAddress
|
||||
)
|
||||
},
|
||||
}
|
||||
|
||||
@ -21,20 +26,15 @@ const mutations = {}
|
||||
const actions = {
|
||||
async deployContract(
|
||||
{ state, dispatch, getters, rootGetters, commit, rootState },
|
||||
{ domain }
|
||||
{ action }
|
||||
) {
|
||||
try {
|
||||
dispatch('loading/enable', {}, { root: true })
|
||||
const isProxy = action.domain === 'deployer.deploy.tornadocash.eth'
|
||||
const ethAccount = rootGetters['provider/getAccount']
|
||||
const web3 = rootGetters['provider/getWeb3']
|
||||
const { salt } = deploymentActions
|
||||
const { bytecode, expectedAddress } = deploymentActions.actions.filter(
|
||||
(action) => {
|
||||
return action.domain === domain
|
||||
}
|
||||
)[0]
|
||||
|
||||
const code = await web3.eth.getCode(expectedAddress)
|
||||
const code = await web3.eth.getCode(action.expectedAddress)
|
||||
console.log('code', code)
|
||||
if (code !== '0x') {
|
||||
dispatch(
|
||||
@ -52,17 +52,39 @@ const actions = {
|
||||
|
||||
const gasPrice = rootGetters['gasPrice/fastGasPrice']
|
||||
|
||||
const data = getters.deployerContract.methods
|
||||
.deploy(bytecode, salt)
|
||||
const data = getters
|
||||
.deployerContract(isProxy)
|
||||
.methods.deploy(action.bytecode, deploymentActions.salt)
|
||||
.encodeABI()
|
||||
|
||||
const callParamsEstimate = {
|
||||
method: 'eth_estimateGas',
|
||||
params: [
|
||||
{
|
||||
from: ethAccount,
|
||||
to: getters.deployerContract(isProxy)._address,
|
||||
// gas: numberToHex(6e6),
|
||||
gasPrice,
|
||||
value: `0x0`,
|
||||
data,
|
||||
},
|
||||
],
|
||||
from: ethAccount,
|
||||
}
|
||||
const gasEstimate =
|
||||
action.domain === 'deployer.deploy.tornadocash.eth'
|
||||
? numberToHex(1e6)
|
||||
: await dispatch('provider/sendRequest', callParamsEstimate, {
|
||||
root: true,
|
||||
})
|
||||
const gasWithBuffer = Math.ceil(hexToNumber(gasEstimate) * 1.1)
|
||||
console.log('xyu', gasWithBuffer)
|
||||
const callParams = {
|
||||
method: 'eth_sendTransaction',
|
||||
params: [
|
||||
{
|
||||
from: ethAccount,
|
||||
to: getters.deployerContract._address,
|
||||
gas: numberToHex(6e6),
|
||||
to: getters.deployerContract(isProxy)._address,
|
||||
gas: numberToHex(gasWithBuffer),
|
||||
gasPrice,
|
||||
value: 0,
|
||||
data,
|
||||
|
166
store/steps.js
166
store/steps.js
@ -1,163 +1,59 @@
|
||||
/* eslint-disable no-console */
|
||||
import Web3 from 'web3'
|
||||
import deploymentActions from '../static/deploymentActions.json'
|
||||
|
||||
const state = () => {
|
||||
return {
|
||||
steps: [
|
||||
{
|
||||
title: 'TORN token',
|
||||
domain: 'torn.deploy.tornadocash.eth',
|
||||
deployerAddress: null,
|
||||
},
|
||||
{
|
||||
title: 'Governance Implementation',
|
||||
domain: 'governance-impl.deploy.tornadocash.eth',
|
||||
deployerAddress: null,
|
||||
},
|
||||
{
|
||||
title: 'Governance Upgradable Proxy',
|
||||
domain: 'governance.deploy.tornadocash.eth',
|
||||
deployerAddress: null,
|
||||
},
|
||||
{
|
||||
title: 'Anonymity mining: Verifier (1/3)',
|
||||
domain: 'reward-verifier.deploy.tornadocash.eth',
|
||||
deployerAddress: null,
|
||||
},
|
||||
{
|
||||
title: 'Anonymity mining: Verifier (2/3)',
|
||||
domain: 'withdraw-verifier.deploy.tornadocash.eth',
|
||||
deployerAddress: null,
|
||||
},
|
||||
{
|
||||
title: 'Anonymity mining: Verifier (3/3)',
|
||||
domain: 'tree-update-verifier.deploy.tornadocash.eth',
|
||||
deployerAddress: null,
|
||||
},
|
||||
{
|
||||
title: 'Anonymity mining: Swap contract for private points',
|
||||
domain: 'reward-swap.deploy.tornadocash.eth',
|
||||
deployerAddress: null,
|
||||
},
|
||||
{
|
||||
title: 'Poseidon hasher for two arguments',
|
||||
domain: 'poseidon2.deploy.tornadocash.eth',
|
||||
deployerAddress: null,
|
||||
},
|
||||
{
|
||||
title: 'Poseidon hasher for three arguments',
|
||||
domain: 'poseidon3.deploy.tornadocash.eth',
|
||||
deployerAddress: null,
|
||||
},
|
||||
{
|
||||
title: 'A proxy contract for ETH Tornado.cash instances',
|
||||
domain: 'tornado-proxy.deploy.tornadocash.eth',
|
||||
deployerAddress: null,
|
||||
},
|
||||
{
|
||||
title: 'Anonymity mining: TornadoTrees contract',
|
||||
domain: 'tornado-trees.deploy.tornadocash.eth',
|
||||
deployerAddress: null,
|
||||
},
|
||||
{
|
||||
title: 'Anonymity mining: Miner contract',
|
||||
domain: 'mining-v2.deploy.tornadocash.eth',
|
||||
deployerAddress: null,
|
||||
},
|
||||
{
|
||||
title: 'Airdrop contract',
|
||||
domain: 'voucher.deploy.tornadocash.eth',
|
||||
deployerAddress: null,
|
||||
},
|
||||
{
|
||||
title: 'Team vestings (1/5)',
|
||||
domain: 'team1.vesting.deploy.tornadocash.eth',
|
||||
deployerAddress: null,
|
||||
},
|
||||
{
|
||||
title: 'Team vestings (2/5)',
|
||||
domain: 'team2.vesting.deploy.tornadocash.eth',
|
||||
deployerAddress: null,
|
||||
},
|
||||
{
|
||||
title: 'Team vestings (3/5)',
|
||||
domain: 'team2.vesting.deploy.tornadocash.eth',
|
||||
deployerAddress: null,
|
||||
},
|
||||
{
|
||||
title: 'Team vestings (4/5)',
|
||||
domain: 'team2.vesting.deploy.tornadocash.eth',
|
||||
deployerAddress: null,
|
||||
},
|
||||
{
|
||||
title: 'Team vestings (5/5)',
|
||||
domain: 'team2.vesting.deploy.tornadocash.eth',
|
||||
deployerAddress: null,
|
||||
},
|
||||
{
|
||||
domain: 'mining-v3.vesting.deploy.tornadocash.eth',
|
||||
deployerAddress: null,
|
||||
title: 'Vesting for the future anonymity mining (V3 release)',
|
||||
},
|
||||
{
|
||||
domain: 'governance.vesting.deploy.tornadocash.eth',
|
||||
deployerAddress: null,
|
||||
title: 'Vesting for the governance itself',
|
||||
},
|
||||
],
|
||||
steps: deploymentActions.actions,
|
||||
}
|
||||
}
|
||||
|
||||
const getters = {
|
||||
deployedCount: (state) => {
|
||||
const deployed = state.steps.filter((step) => {
|
||||
return !!step.deployerAddress
|
||||
}).length
|
||||
const deployed = state.steps.filter((step) => !!step.deployerAddress).length
|
||||
const all = state.steps.length
|
||||
return `${deployed}/${all}`
|
||||
},
|
||||
canDeploy: (state) => (domain) => {
|
||||
const { dependsOn } = state.steps.find((s) => s.domain === domain)
|
||||
return dependsOn.every(
|
||||
(d) => !!state.steps.find((s) => s.domain === d).deployerAddress
|
||||
)
|
||||
},
|
||||
}
|
||||
|
||||
const SET_DEPLOYER = 'SET_DEPLOYER'
|
||||
const mutations = {
|
||||
[SET_DEPLOYER](state, { stepIndex, deployerAddress }) {
|
||||
[SET_DEPLOYER](state, { stepIndex, deployerAddress, deployTransaction }) {
|
||||
this._vm.$set(state.steps[stepIndex], 'deployerAddress', deployerAddress)
|
||||
this._vm.$set(
|
||||
state.steps[stepIndex],
|
||||
'deployTransaction',
|
||||
deployTransaction
|
||||
)
|
||||
},
|
||||
}
|
||||
|
||||
const actions = {
|
||||
async fetchDeploymentStatus({ state, dispatch, commit, rootGetters }) {
|
||||
// const deployContract = rootGetters['deploy/deployerContract']
|
||||
// const events = await deployContract.getPastEvents('Deployed', {
|
||||
// // filter: {
|
||||
// // addr: ['0xd51154a046d2af2c572e850a4ed5bd65db2d83f0'],
|
||||
// // },
|
||||
// fromBlock: 21895260,
|
||||
// toBlock: 'latest',
|
||||
// })
|
||||
// console.log('events', events)
|
||||
const { rpcUrls } = rootGetters['provider/getNetwork']
|
||||
const web3 = new Web3(rpcUrls.Infura.url)
|
||||
const deployContract = rootGetters['deploy/deployerContract'](false)
|
||||
const events = await deployContract.getPastEvents('Deployed', {
|
||||
fromBlock: 21895260,
|
||||
toBlock: 'latest',
|
||||
})
|
||||
for (const event of events) {
|
||||
const step = state.steps.find(
|
||||
(s) => s.expectedAddress === event.returnValues.addr
|
||||
)
|
||||
|
||||
try {
|
||||
for (const [stepIndex, step] of state.steps.entries()) {
|
||||
const { expectedAddress } = deploymentActions.actions.find((action) => {
|
||||
return action.domain === step.domain
|
||||
})
|
||||
|
||||
const code = await web3.eth.getCode(expectedAddress)
|
||||
|
||||
if (code !== '0x') {
|
||||
// todo collect deployerAddress from chain
|
||||
commit(SET_DEPLOYER, {
|
||||
stepIndex,
|
||||
deployerAddress: '0x03Ebd0748Aa4D1457cF479cce56309641e0a98F5',
|
||||
})
|
||||
}
|
||||
if (!step) {
|
||||
continue
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('fetchDeploymentStatus', e.message)
|
||||
console.log('event', event)
|
||||
commit(SET_DEPLOYER, {
|
||||
stepIndex: state.steps.indexOf(step),
|
||||
deployerAddress: event.returnValues.sender,
|
||||
deployTransaction: event.transactionHash,
|
||||
})
|
||||
}
|
||||
},
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user