mirror of
https://github.com/tornadocash/tornado-initiation-ui.git
synced 2024-11-22 01:26:51 +01:00
binance support
This commit is contained in:
parent
70f892834d
commit
2b7259f70b
@ -19,7 +19,7 @@
|
||||
v-if="typeof notice.callback === 'function'"
|
||||
@click="callbackWithClose(notice.id, notice.callback)"
|
||||
>
|
||||
Scroll to voucher
|
||||
{{ $t(notice.message) }}
|
||||
</a>
|
||||
<a
|
||||
v-if="notice.txHash"
|
||||
|
@ -128,7 +128,7 @@ export default {
|
||||
this.deployContract({ action: this.data, index: this.$vnode.key })
|
||||
},
|
||||
domainUrl(address) {
|
||||
return `https://etherscan.io/address/${address}`
|
||||
return `https://bscscan.com/address/${address}`
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -25,5 +25,7 @@
|
||||
"sendingTransaction": "Sending transaction",
|
||||
"viewOnEtherscan": "View on Etherscan",
|
||||
"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",
|
||||
"switchNetwork": "Switch to BSC"
|
||||
}
|
||||
|
@ -37,7 +37,6 @@ export default {
|
||||
}
|
||||
this.fetchDeploymentStatus()
|
||||
this.statusPooling()
|
||||
this.fetchGasPrice()
|
||||
|
||||
this.setAirdropAddresses()
|
||||
},
|
||||
@ -45,7 +44,6 @@ export default {
|
||||
...mapActions('provider', ['initProvider']),
|
||||
...mapActions('airdrop', ['setAirdropAddresses']),
|
||||
...mapActions('steps', ['statusPooling', 'fetchDeploymentStatus']),
|
||||
...mapActions('gasPrice', ['fetchGasPrice']),
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
@ -1,35 +1,18 @@
|
||||
const networkConfig = {
|
||||
netId1: {
|
||||
netId56: {
|
||||
rpcCallRetryAttempt: 15,
|
||||
gasPrices: { instant: 80, fast: 50, standard: 25, low: 8 },
|
||||
currencyName: 'ETH',
|
||||
gasPrices: { instant: 21, fast: 5, standard: 5, low: 5 },
|
||||
currencyName: 'BNB',
|
||||
explorerUrl: {
|
||||
tx: 'https://etherscan.io/tx/',
|
||||
address: 'https://etherscan.io/address/',
|
||||
tx: 'https://bscscan.com/tx/',
|
||||
address: 'https://bscscan.com/address/',
|
||||
},
|
||||
networkName: 'Mainnet',
|
||||
networkName: 'bsc',
|
||||
rpcUrls: {
|
||||
Infura: {
|
||||
name: 'Infura',
|
||||
url: 'https://mainnet.infura.io/v3/2884a3281c1d4ae8952e25c84d76bced',
|
||||
},
|
||||
MyCrypto: { name: 'MyCrypto', url: 'https://api.mycryptoapi.com/eth' },
|
||||
},
|
||||
pollInterval: 60,
|
||||
},
|
||||
netId5: {
|
||||
rpcCallRetryAttempt: 15,
|
||||
gasPrices: { instant: 80, fast: 50, standard: 25, low: 8 },
|
||||
currencyName: 'gETH',
|
||||
explorerUrl: {
|
||||
tx: 'https://goerli.etherscan.io/tx/',
|
||||
address: 'https://goerli.etherscan.io/address/',
|
||||
},
|
||||
networkName: 'goerli',
|
||||
rpcUrls: {
|
||||
Infura: {
|
||||
name: 'Infura',
|
||||
url: 'https://goerli.infura.io/v3/2884a3281c1d4ae8952e25c84d76bced',
|
||||
url:
|
||||
'https://wandering-sparkling-shadow.bsc.quiknode.pro/00115b17f97c1f4c374ac309858015da1cab3e02/',
|
||||
},
|
||||
},
|
||||
pollInterval: 200,
|
||||
|
File diff suppressed because one or more lines are too long
@ -1,4 +1,5 @@
|
||||
/* eslint-disable no-console */
|
||||
import Web3 from 'web3'
|
||||
import { hexToNumber, numberToHex } from 'web3-utils'
|
||||
import deployerABI from '../abi/deployer.abi.json'
|
||||
import deploymentActions from '../static/deploymentActions.json'
|
||||
@ -9,7 +10,7 @@ const state = () => {
|
||||
|
||||
const getters = {
|
||||
deployerContract: (state, getters, rootState, rootGetters) => (isProxy) => {
|
||||
const web3 = rootGetters['provider/getWeb3']
|
||||
const web3 = new Web3(rootGetters['provider/getNetwork'].rpcUrls.Infura.url)
|
||||
return new web3.eth.Contract(
|
||||
deployerABI,
|
||||
isProxy
|
||||
|
@ -5,10 +5,10 @@ const { toHex, toWei } = require('web3-utils')
|
||||
|
||||
export const state = () => {
|
||||
return {
|
||||
instant: networkConfig.netId1.gasPrices.instant,
|
||||
fast: networkConfig.netId1.gasPrices.fast,
|
||||
standard: networkConfig.netId1.gasPrices.standard,
|
||||
low: networkConfig.netId1.gasPrices.low,
|
||||
instant: networkConfig.netId56.gasPrices.instant,
|
||||
fast: networkConfig.netId56.gasPrices.fast,
|
||||
standard: networkConfig.netId56.gasPrices.standard,
|
||||
low: networkConfig.netId56.gasPrices.low,
|
||||
custom: null,
|
||||
}
|
||||
}
|
||||
|
@ -12,12 +12,28 @@ import {
|
||||
export default {
|
||||
async initProvider({ commit, state, getters, dispatch }, { name, network }) {
|
||||
try {
|
||||
const account = await this.$provider.initProvider(getters.getProvider)
|
||||
if (window.ethereum.chainId !== '0x38') {
|
||||
await dispatch(
|
||||
'notice/addNotice',
|
||||
{
|
||||
notice: {
|
||||
title: 'bscOnly',
|
||||
type: 'danger',
|
||||
callback: () => dispatch('addNetwork', { netId: 56 }),
|
||||
message: 'switchNetwork',
|
||||
},
|
||||
},
|
||||
{ root: true }
|
||||
)
|
||||
throw new Error('Connect to BSC')
|
||||
}
|
||||
|
||||
commit(SET_PROVIDER_NAME, name)
|
||||
commit(SET_NETWORK_NAME, network)
|
||||
|
||||
localStorage.setItem('provider', { name, network })
|
||||
|
||||
const account = await this.$provider.initProvider(getters.getProvider)
|
||||
const netId = await dispatch('checkNetworkVersion')
|
||||
|
||||
this.$provider.initWeb3(networkConfig[`netId${netId}`].rpcUrls.Infura.url)
|
||||
@ -79,4 +95,26 @@ export default {
|
||||
throw new Error(err.message)
|
||||
}
|
||||
},
|
||||
async addNetwork(_, { netId }) {
|
||||
const METAMASK_LIST = {
|
||||
56: {
|
||||
chainId: '0x38',
|
||||
chainName: 'Binance Smart Chain',
|
||||
rpcUrls: ['https://bsc-dataseed1.ninicoin.io'],
|
||||
nativeCurrency: {
|
||||
name: 'Binance Chain Native Token',
|
||||
symbol: 'BNB',
|
||||
decimals: 18,
|
||||
},
|
||||
blockExplorerUrls: ['https://bscscan.com'],
|
||||
},
|
||||
}
|
||||
|
||||
if (METAMASK_LIST[netId]) {
|
||||
await this.$provider.sendRequest({
|
||||
method: 'wallet_addEthereumChain',
|
||||
params: [METAMASK_LIST[netId]],
|
||||
})
|
||||
}
|
||||
},
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
export default () => ({
|
||||
account: null,
|
||||
network: {
|
||||
name: 'mainnet',
|
||||
id: 1,
|
||||
name: 'binance',
|
||||
id: 56,
|
||||
},
|
||||
provider: {
|
||||
name: '',
|
||||
|
@ -1,4 +1,5 @@
|
||||
/* eslint-disable no-console */
|
||||
import Web3 from 'web3'
|
||||
import deploymentActions from '../static/deploymentActions.json'
|
||||
|
||||
const state = () => {
|
||||
@ -40,23 +41,41 @@ const mutations = {
|
||||
const actions = {
|
||||
async fetchDeploymentStatus({ state, dispatch, commit, rootGetters }) {
|
||||
const deployContract = rootGetters['deploy/deployerContract'](false)
|
||||
const events = await deployContract.getPastEvents('Deployed', {
|
||||
fromBlock: 0,
|
||||
toBlock: 'latest',
|
||||
})
|
||||
for (const event of events) {
|
||||
const step = state.steps.find(
|
||||
(s) => s.expectedAddress === event.returnValues.addr
|
||||
)
|
||||
const web3 = new Web3(rootGetters['provider/getNetwork'].rpcUrls.Infura.url)
|
||||
const code = await web3.eth.getCode(deployContract._address)
|
||||
if (code === '0x') {
|
||||
return
|
||||
}
|
||||
|
||||
if (!step) {
|
||||
continue
|
||||
}
|
||||
commit(SET_DEPLOYER, {
|
||||
stepIndex: state.steps.indexOf(step),
|
||||
deployerAddress: event.returnValues.sender,
|
||||
deployTransaction: event.transactionHash,
|
||||
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) {
|
||||
const step = state.steps.find(
|
||||
(s) => s.expectedAddress === event.returnValues.addr
|
||||
)
|
||||
|
||||
if (!step) {
|
||||
continue
|
||||
}
|
||||
commit(SET_DEPLOYER, {
|
||||
stepIndex: state.steps.indexOf(step),
|
||||
deployerAddress: event.returnValues.sender,
|
||||
deployTransaction: event.transactionHash,
|
||||
})
|
||||
}
|
||||
if (events[0].returnValues.addr === deployContract._address) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
statusPooling({ dispatch }) {
|
||||
|
Loading…
Reference in New Issue
Block a user