mirror of
https://github.com/tornadocash/tornado-initiation-ui.git
synced 2025-02-14 13:10:29 +01:00
update provider
This commit is contained in:
parent
3739a32448
commit
d4f872010e
@ -23,7 +23,7 @@
|
|||||||
background-color: #559774;
|
background-color: #559774;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background-color: #94febf;
|
background-color: $primary;
|
||||||
}
|
}
|
||||||
|
|
||||||
&[disabled] {
|
&[disabled] {
|
||||||
|
@ -63,7 +63,7 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async _web3Connect(name, network = 'mainnet') {
|
async _web3Connect(name, network) {
|
||||||
this.$store.dispatch('loading/enable', {})
|
this.$store.dispatch('loading/enable', {})
|
||||||
try {
|
try {
|
||||||
await this.$store.dispatch(
|
await this.$store.dispatch(
|
||||||
@ -71,6 +71,7 @@ export default {
|
|||||||
{ name, network },
|
{ name, network },
|
||||||
{ root: true }
|
{ root: true }
|
||||||
)
|
)
|
||||||
|
this.$store.dispatch('steps/fetchDeploymentStatus', {})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(e)
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import networkConfig from '@/networkConfig'
|
||||||
import { Provider } from '../services'
|
import { Provider } from '../services'
|
||||||
|
|
||||||
const MAIN_NET_ID = 1
|
const MAIN_NET_ID = 1
|
||||||
@ -7,6 +8,7 @@ const options = {
|
|||||||
config: {
|
config: {
|
||||||
id: MAIN_NET_ID,
|
id: MAIN_NET_ID,
|
||||||
rpcCallRetryAttempt: 15,
|
rpcCallRetryAttempt: 15,
|
||||||
|
rpcUrl: networkConfig.netId1.rpcUrl,
|
||||||
blockGasLimit: MAIN_NET_BLOCK_GAS_LIMIT,
|
blockGasLimit: MAIN_NET_BLOCK_GAS_LIMIT,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ class Provider {
|
|||||||
* @param options {object}
|
* @param options {object}
|
||||||
* @param {object} options.config
|
* @param {object} options.config
|
||||||
* @param {number} options.config.id
|
* @param {number} options.config.id
|
||||||
|
* @param {string} options.config.rpcUrl
|
||||||
* @param {number} options.config.rpcCallRetryAttempt
|
* @param {number} options.config.rpcCallRetryAttempt
|
||||||
* @param {object} options.provider
|
* @param {object} options.provider
|
||||||
* @param {string} options.rpcUrl - node api endpoint.
|
* @param {string} options.rpcUrl - node api endpoint.
|
||||||
@ -18,6 +19,7 @@ class Provider {
|
|||||||
this.version = 'new'
|
this.version = 'new'
|
||||||
|
|
||||||
this.config = options.config
|
this.config = options.config
|
||||||
|
this.web3 = new Web3(new Web3.providers.HttpProvider(options.rpcUrl))
|
||||||
}
|
}
|
||||||
|
|
||||||
async initProvider(provider) {
|
async initProvider(provider) {
|
||||||
@ -227,6 +229,19 @@ class Provider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Subscribe to event in provider.
|
||||||
|
*
|
||||||
|
* @param method {string}
|
||||||
|
* @param {function} callback
|
||||||
|
* @returns {*}
|
||||||
|
*/
|
||||||
|
on(method, callback) {
|
||||||
|
if (method) {
|
||||||
|
this.provider.on(method, callback)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a request to the provider (old api).
|
* Send a request to the provider (old api).
|
||||||
*
|
*
|
||||||
@ -291,9 +306,12 @@ class Provider {
|
|||||||
* @param {string} params.id.
|
* @param {string} params.id.
|
||||||
* @returns {*}
|
* @returns {*}
|
||||||
*/
|
*/
|
||||||
_onNetworkChanged({ id }) {
|
_onNetworkChanged({ id, callback }) {
|
||||||
if (id) {
|
if (id) {
|
||||||
this.network = id
|
this.network = id
|
||||||
|
if (typeof callback === 'function') {
|
||||||
|
callback()
|
||||||
|
}
|
||||||
window.location.reload()
|
window.location.reload()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
import Web3 from 'web3'
|
|
||||||
import { hexToNumber, numberToHex } from 'web3-utils'
|
import { hexToNumber, numberToHex } from 'web3-utils'
|
||||||
import deployerABI from '../abi/deployer.abi.json'
|
import deployerABI from '../abi/deployer.abi.json'
|
||||||
import deploymentActions from '../static/deploymentActions.json'
|
import deploymentActions from '../static/deploymentActions.json'
|
||||||
@ -10,8 +9,7 @@ const state = () => {
|
|||||||
|
|
||||||
const getters = {
|
const getters = {
|
||||||
deployerContract: (state, getters, rootState, rootGetters) => (isProxy) => {
|
deployerContract: (state, getters, rootState, rootGetters) => (isProxy) => {
|
||||||
const { rpcUrls } = rootGetters['provider/getNetwork']
|
const web3 = rootGetters['provider/getWeb3']
|
||||||
const web3 = new Web3(rpcUrls.Infura.url)
|
|
||||||
return new web3.eth.Contract(
|
return new web3.eth.Contract(
|
||||||
deployerABI,
|
deployerABI,
|
||||||
isProxy
|
isProxy
|
||||||
|
Loading…
x
Reference in New Issue
Block a user