diff --git a/assets/styles/components/_wallets.scss b/assets/styles/components/_wallets.scss index 5df74b1..9b909d3 100644 --- a/assets/styles/components/_wallets.scss +++ b/assets/styles/components/_wallets.scss @@ -23,7 +23,7 @@ background-color: #559774; &:hover { - background-color: #94febf; + background-color: $primary; } &[disabled] { diff --git a/components/Web3Connect.vue b/components/Web3Connect.vue index cbe1d00..b887237 100644 --- a/components/Web3Connect.vue +++ b/components/Web3Connect.vue @@ -63,7 +63,7 @@ export default { }, }, methods: { - async _web3Connect(name, network = 'mainnet') { + async _web3Connect(name, network) { this.$store.dispatch('loading/enable', {}) try { await this.$store.dispatch( @@ -71,6 +71,7 @@ export default { { name, network }, { root: true } ) + this.$store.dispatch('steps/fetchDeploymentStatus', {}) } catch (e) { console.error(e) } diff --git a/plugins/provider.js b/plugins/provider.js index 7af97a9..8c70705 100644 --- a/plugins/provider.js +++ b/plugins/provider.js @@ -1,3 +1,4 @@ +import networkConfig from '@/networkConfig' import { Provider } from '../services' const MAIN_NET_ID = 1 @@ -7,6 +8,7 @@ const options = { config: { id: MAIN_NET_ID, rpcCallRetryAttempt: 15, + rpcUrl: networkConfig.netId1.rpcUrl, blockGasLimit: MAIN_NET_BLOCK_GAS_LIMIT, }, } diff --git a/services/provider.js b/services/provider.js index d7d4c87..2cbaf3a 100644 --- a/services/provider.js +++ b/services/provider.js @@ -8,6 +8,7 @@ class Provider { * @param options {object} * @param {object} options.config * @param {number} options.config.id + * @param {string} options.config.rpcUrl * @param {number} options.config.rpcCallRetryAttempt * @param {object} options.provider * @param {string} options.rpcUrl - node api endpoint. @@ -18,6 +19,7 @@ class Provider { this.version = 'new' this.config = options.config + this.web3 = new Web3(new Web3.providers.HttpProvider(options.rpcUrl)) } 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). * @@ -291,9 +306,12 @@ class Provider { * @param {string} params.id. * @returns {*} */ - _onNetworkChanged({ id }) { + _onNetworkChanged({ id, callback }) { if (id) { this.network = id + if (typeof callback === 'function') { + callback() + } window.location.reload() } } diff --git a/store/deploy.js b/store/deploy.js index f0e2812..3e6cb15 100644 --- a/store/deploy.js +++ b/store/deploy.js @@ -1,5 +1,4 @@ /* 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' @@ -10,8 +9,7 @@ const state = () => { const getters = { deployerContract: (state, getters, rootState, rootGetters) => (isProxy) => { - const { rpcUrls } = rootGetters['provider/getNetwork'] - const web3 = new Web3(rpcUrls.Infura.url) + const web3 = rootGetters['provider/getWeb3'] return new web3.eth.Contract( deployerABI, isProxy