update fetchDeploymentStatus

This commit is contained in:
Danil Kovtonyuk 2020-11-03 23:33:33 +10:00
parent b41e441395
commit b97b2312fa
2 changed files with 24 additions and 13 deletions

View File

@ -27,17 +27,15 @@ export default {
Loading, Loading,
Notices, Notices,
}, },
mounted() { async mounted() {
this.fetchDeploymentStatus()
const result = localStorage.getItem('provider') const result = localStorage.getItem('provider')
if (result && result.name) { if (result && result.name) {
this.initProvider({ await this.initProvider({
name: result.name, name: result.name,
network: result.network, network: result.network,
}) })
} }
this.fetchDeploymentStatus()
this.fetchGasPrice() this.fetchGasPrice()
}, },
methods: { methods: {

View File

@ -1,4 +1,6 @@
/* eslint-disable no-console */ /* eslint-disable no-console */
import Web3 from 'web3'
import deploymentActions from '../static/deploymentActions.json'
const state = () => { const state = () => {
return { return {
@ -105,20 +107,31 @@ const getters = {
const SET_DEPLOYER = 'SET_DEPLOYER' const SET_DEPLOYER = 'SET_DEPLOYER'
const mutations = { const mutations = {
[SET_DEPLOYER](state, { stepIndex, deployerAddress }) { [SET_DEPLOYER](state, { stepIndex, deployerAddress }) {
console.log('SET_DEPLOYER', stepIndex, deployerAddress)
console.log('state.steps[stepIndex]', state.steps[stepIndex])
this._vm.$set(state.steps[stepIndex], 'deployerAddress', deployerAddress) this._vm.$set(state.steps[stepIndex], 'deployerAddress', deployerAddress)
}, },
} }
const actions = { const actions = {
fetchDeploymentStatus({ state, dispatch, commit }) { async fetchDeploymentStatus({ state, dispatch, commit, rootGetters }) {
const { rpcUrls } = rootGetters['provider/getNetwork']
const web3 = new Web3(rpcUrls.Infura.url)
try { try {
// todo collect data from chain 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, { commit(SET_DEPLOYER, {
stepIndex: 0, stepIndex,
deployerAddress: '0x03Ebd0748Aa4D1457cF479cce56309641e0a98F5', deployerAddress: '0x03Ebd0748Aa4D1457cF479cce56309641e0a98F5',
}) })
}
}
} catch (e) { } catch (e) {
console.error('fetchDeploymentStatus', e.message) console.error('fetchDeploymentStatus', e.message)
} }