This commit is contained in:
Danil Kovtonyuk 2021-08-21 12:42:17 +10:00
parent 2bcadbb351
commit 953bced312
No known key found for this signature in database
GPG Key ID: E72A919BF08C3746
13 changed files with 128 additions and 126 deletions

View File

@ -6,11 +6,7 @@
</b-navbar-item> </b-navbar-item>
</template> </template>
<template slot="start"> <template slot="start">
<b-navbar-item <b-navbar-item href="#" target="_blank" class="decorate" rel="noreferrer">
href="https://medium.com/@tornado-cash/tornado-cash-bsc-deployment-proposal-96dfc06055f8"
target="_blank"
class="decorate"
>
{{ $t('info') }} {{ $t('info') }}
</b-navbar-item> </b-navbar-item>
</template> </template>

View File

@ -9,7 +9,7 @@
<h4>{{ data.title }}</h4> <h4>{{ data.title }}</h4>
<h5 v-if="data.domain" class="deployed"> <h5 v-if="data.domain" class="deployed">
ENS: ENS:
<a :href="domainUrl(data.expectedAddress)" target="_blank">{{ <a :href="addressExplorerUrl(data.expectedAddress)" target="_blank">{{
data.domain data.domain
}}</a> }}</a>
</h5> </h5>
@ -80,7 +80,7 @@
:row-class="(row) => row.address === getAccount && 'is-selected'" :row-class="(row) => row.address === getAccount && 'is-selected'"
> >
<b-table-column v-slot="props" field="address" label="Address"> <b-table-column v-slot="props" field="address" label="Address">
<a :href="domainUrl(props.row.address)" target="_blank">{{ <a :href="addressExplorerUrl(props.row.address)" target="_blank">{{
props.row.address props.row.address
}}</a> }}</a>
</b-table-column> </b-table-column>
@ -117,7 +117,7 @@ export default {
computed: { computed: {
...mapGetters('provider', ['getProviderName', 'getAccount']), ...mapGetters('provider', ['getProviderName', 'getAccount']),
...mapGetters('steps', ['canDeploy']), ...mapGetters('steps', ['canDeploy']),
...mapGetters('txStorage', ['txExplorerUrl']), ...mapGetters('txStorage', ['txExplorerUrl', 'addressExplorerUrl']),
isNotLoggedIn() { isNotLoggedIn() {
return !this.getProviderName return !this.getProviderName
}, },
@ -127,9 +127,6 @@ export default {
onDeploy() { onDeploy() {
this.deployContract({ action: this.data, index: this.$vnode.key }) this.deployContract({ action: this.data, index: this.$vnode.key })
}, },
domainUrl(address) {
return `https://bscscan.com/address/${address}`
},
}, },
} }
</script> </script>

View File

@ -17,7 +17,7 @@
"deployedBy": "Deployed by: {link}", "deployedBy": "Deployed by: {link}",
"startNow": "Start now", "startNow": "Start now",
"completedTasks": "Completed Tasks: {progress}", "completedTasks": "Completed Tasks: {progress}",
"pageSubtitle": "Follow these simple steps to become part of deployment of Tornado.Cash protocol on BSC chain.", "pageSubtitle": "Follow these simple steps to become part of deployment of Tornado.Cash protocol on xDAI Chain.",
"alreadyDeployed": "Already deployed", "alreadyDeployed": "Already deployed",
"contractDeployed": "Contract successfully deployed", "contractDeployed": "Contract successfully deployed",
"transactionFailed": "Transaction was failed", "transactionFailed": "Transaction was failed",
@ -26,6 +26,6 @@
"viewOnEtherscan": "View on Etherscan", "viewOnEtherscan": "View on Etherscan",
"pleaseConnectWallet": "Please connect your wallet first", "pleaseConnectWallet": "Please connect your wallet first",
"dependsOnEns": "This action depends on {ens}", "dependsOnEns": "This action depends on {ens}",
"bscOnly": "Please switch your wallet to BSC network", "xDaiOnly": "Please switch your wallet to xDAI Chain",
"switchNetwork": "Switch to BSC" "switchNetwork": "Switch to xDAI"
} }

View File

@ -1,18 +1,22 @@
const networkConfig = { const networkConfig = {
netId56: { netId100: {
rpcCallRetryAttempt: 15, rpcCallRetryAttempt: 15,
gasPrices: { instant: 21, fast: 5, standard: 5, low: 5 }, gasPrices: {
currencyName: 'BNB', instant: 5,
explorerUrl: { fast: 4,
tx: 'https://bscscan.com/tx/', standard: 3,
address: 'https://bscscan.com/address/', low: 1,
}, },
networkName: 'bsc', currencyName: 'xDAI',
explorerUrl: {
tx: 'https://blockscout.com/xdai/mainnet/tx/',
address: 'https://blockscout.com/xdai/mainnet/address/',
},
networkName: 'xdai',
rpcUrls: { rpcUrls: {
Infura: { Infura: {
name: 'Infura', name: 'xDAI Chain RPC',
url: url: 'https://rpc.xdaichain.com/tornado',
'https://wandering-sparkling-shadow.bsc.quiknode.pro/00115b17f97c1f4c374ac309858015da1cab3e02/',
}, },
}, },
pollInterval: 200, pollInterval: 200,

View File

@ -14,7 +14,7 @@
"dependencies": { "dependencies": {
"nuxt-web3-provider": "^0.1.1", "nuxt-web3-provider": "^0.1.1",
"core-js": "^3.6.5", "core-js": "^3.6.5",
"gas-price-oracle": "^0.2.2", "gas-price-oracle": "^0.3.4",
"node-sass": "^4.14.1", "node-sass": "^4.14.1",
"nuxt": "^2.14.6", "nuxt": "^2.14.6",
"nuxt-buefy": "^0.4.4", "nuxt-buefy": "^0.4.4",

View File

@ -1,7 +1,7 @@
<template> <template>
<div> <div>
<h1 class="title has-text-centered"> <h1 class="title has-text-centered">
Tornado.cash <span>BSC</span> Deployment Tornado.cash <span>xDAI</span> Deployment
</h1> </h1>
<h2 class="subtitle has-text-centered">{{ $t('pageSubtitle') }}</h2> <h2 class="subtitle has-text-centered">{{ $t('pageSubtitle') }}</h2>

File diff suppressed because one or more lines are too long

View File

@ -3,12 +3,11 @@ import { GasPriceOracle } from 'gas-price-oracle'
import networkConfig from '@/networkConfig' import networkConfig from '@/networkConfig'
const { toHex, toWei } = require('web3-utils') const { toHex, toWei } = require('web3-utils')
const GAS_PRICES = networkConfig.netId100.gasPrices
export const state = () => { export const state = () => {
return { return {
instant: networkConfig.netId56.gasPrices.instant, ...GAS_PRICES,
fast: networkConfig.netId56.gasPrices.fast,
standard: networkConfig.netId56.gasPrices.standard,
low: networkConfig.netId56.gasPrices.low,
custom: null, custom: null,
} }
} }
@ -17,7 +16,11 @@ export const getters = {
oracle: (state, getters, rootState, rootGetters) => { oracle: (state, getters, rootState, rootGetters) => {
const currentRpc = rootGetters['provider/getNetwork'].rpcUrls.Infura.url const currentRpc = rootGetters['provider/getNetwork'].rpcUrls.Infura.url
console.log('currentRpc', currentRpc) console.log('currentRpc', currentRpc)
return new GasPriceOracle({ defaultRpc: currentRpc }) return new GasPriceOracle({
chainId: 100,
defaultRpc: currentRpc,
defaultFallbackGasPrices: GAS_PRICES,
})
}, },
fastGasPrice: (state) => { fastGasPrice: (state) => {
return toHex(toWei(state.fast.toString(), 'gwei')) return toHex(toWei(state.fast.toString(), 'gwei'))

View File

@ -1,5 +1,6 @@
import networkConfig from '@/networkConfig' import networkConfig from '@/networkConfig'
import { localStorage } from '@/utillites' import { localStorage } from '@/utillites'
import { numberToHex } from 'web3-utils'
import { import {
SET_ACCOUNT, SET_ACCOUNT,
SET_NETWORK, SET_NETWORK,
@ -13,20 +14,20 @@ export default {
async initProvider({ commit, state, getters, dispatch }, { name, network }) { async initProvider({ commit, state, getters, dispatch }, { name, network }) {
try { try {
const account = await this.$provider.initProvider(getters.getProvider) const account = await this.$provider.initProvider(getters.getProvider)
if (window.ethereum.chainId !== '0x38') { if (window.ethereum.chainId !== '0x64') {
await dispatch( await dispatch(
'notice/addNotice', 'notice/addNotice',
{ {
notice: { notice: {
title: 'bscOnly', title: 'xDaiOnly',
type: 'danger', type: 'danger',
callback: () => dispatch('addNetwork', { netId: 56 }), callback: () => dispatch('switchNetwork', { netId: 100 }),
message: 'switchNetwork', message: 'switchNetwork',
}, },
}, },
{ root: true } { root: true }
) )
throw new Error('Connect to BSC') throw new Error('Connect to xDai')
} }
commit(SET_PROVIDER_NAME, name) commit(SET_PROVIDER_NAME, name)
@ -95,18 +96,33 @@ export default {
throw new Error(err.message) throw new Error(err.message)
} }
}, },
async switchNetwork({ dispatch }, { netId }) {
try {
await this.$provider.sendRequest({
method: 'wallet_switchEthereumChain',
params: [{ chainId: numberToHex(netId) }],
})
} catch (err) {
// This error indicates that the chain has not been added to MetaMask.
if (err.message.includes('wallet_addEthereumChain')) {
return dispatch('addNetwork', { netId })
}
throw new Error(err.message)
}
},
async addNetwork(_, { netId }) { async addNetwork(_, { netId }) {
const METAMASK_LIST = { const METAMASK_LIST = {
56: { 100: {
chainId: '0x38', chainId: '0x64',
chainName: 'Binance Smart Chain', chainName: 'xDAI Chain',
rpcUrls: ['https://bsc-dataseed1.ninicoin.io'], rpcUrls: ['https://rpc.xdaichain.com'],
nativeCurrency: { nativeCurrency: {
name: 'Binance Chain Native Token', name: 'xDAI',
symbol: 'BNB', symbol: 'xDAI',
decimals: 18, decimals: 18,
}, },
blockExplorerUrls: ['https://bscscan.com'], blockExplorerUrls: ['https://blockscout.com/xdai/mainnet'],
}, },
} }

View File

@ -1,8 +1,8 @@
export default () => ({ export default () => ({
account: null, account: null,
network: { network: {
name: 'binance', name: 'xdai',
id: 56, id: 100,
}, },
provider: { provider: {
name: '', name: '',

View File

@ -1,5 +1,4 @@
/* eslint-disable no-console */ /* eslint-disable no-console */
import Web3 from 'web3'
import deploymentActions from '../static/deploymentActions.json' import deploymentActions from '../static/deploymentActions.json'
const state = () => { const state = () => {
@ -41,23 +40,11 @@ const mutations = {
const actions = { const actions = {
async fetchDeploymentStatus({ state, dispatch, commit, rootGetters }) { async fetchDeploymentStatus({ state, dispatch, commit, rootGetters }) {
const deployContract = rootGetters['deploy/deployerContract'](false) const deployContract = rootGetters['deploy/deployerContract'](false)
const web3 = new Web3(rootGetters['provider/getNetwork'].rpcUrls.Infura.url) const events = await deployContract.getPastEvents('Deployed', {
const code = await web3.eth.getCode(deployContract._address) fromBlock: 0,
if (code === '0x') { toBlock: 'latest',
return
}
const latestBlock = await web3.eth.getBlock('latest')
let number = latestBlock.number
let events = []
while (true) {
const fromBlock = number - 4500
events = await deployContract.getPastEvents('Deployed', {
fromBlock,
toBlock: number,
}) })
number = fromBlock
if (events.length > 0) {
for (const event of events) { for (const event of events) {
const step = state.steps.find( const step = state.steps.find(
(s) => s.expectedAddress === event.returnValues.addr (s) => s.expectedAddress === event.returnValues.addr
@ -72,11 +59,6 @@ const actions = {
deployTransaction: event.transactionHash, deployTransaction: event.transactionHash,
}) })
} }
if (events[0].returnValues.addr === deployContract._address) {
break
}
}
}
}, },
statusPooling({ dispatch }) { statusPooling({ dispatch }) {
setTimeout(async () => { setTimeout(async () => {

View File

@ -7,6 +7,10 @@ export const getters = {
const { explorerUrl } = rootGetters['provider/getNetwork'] const { explorerUrl } = rootGetters['provider/getNetwork']
return explorerUrl.tx + txHash return explorerUrl.tx + txHash
}, },
addressExplorerUrl: (state, getters, rootState, rootGetters) => (address) => {
const { explorerUrl } = rootGetters['provider/getNetwork']
return explorerUrl.address + address
},
} }
export const actions = { export const actions = {

View File

@ -5020,10 +5020,10 @@ functional-red-black-tree@^1.0.1:
resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327" resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327"
integrity sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc= integrity sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=
gas-price-oracle@^0.2.2: gas-price-oracle@^0.3.4:
version "0.2.2" version "0.3.4"
resolved "https://registry.yarnpkg.com/gas-price-oracle/-/gas-price-oracle-0.2.2.tgz#32c57a9aa6bc69152be96812880232efebfecbc6" resolved "https://registry.yarnpkg.com/gas-price-oracle/-/gas-price-oracle-0.3.4.tgz#c98f6e24cf4bea96be2fe85383d53601b2ab5761"
integrity sha512-I4+rLbc7C1vgYXV+cYY0MKeqdZVna2hXpNfD2fcIvf/wIgvtIYmG9gsmhiaYGSgOE2RSPUs2xf/W4K2nJOoNuQ== integrity sha512-bba9zWd2hQ32AuPFDzL8E5QxAzXNfGKR1UZCa14fSYJWc9yo3k7wabITMkGEv0cbKpHmyK/kHhhDTBtugI6eAg==
dependencies: dependencies:
axios "^0.19.2" axios "^0.19.2"
bignumber.js "^9.0.0" bignumber.js "^9.0.0"