This commit is contained in:
Alexey 2020-11-19 13:25:44 +03:00
parent 129223239f
commit dc07f3928c
10 changed files with 260 additions and 153 deletions

View File

@ -54,7 +54,9 @@
type="is-primary"
outlined
icon-left="tool"
:disabled="isNotLoggedIn || !canDeploy(data.domain)"
:disabled="
isNotLoggedIn || !canDeploy(data.domain) || data.isPending
"
@mousedown="(e) => e.preventDefault()"
@click="onDeploy"
>
@ -101,10 +103,8 @@ export default {
},
methods: {
...mapActions('deploy', ['deployContract']),
// todo pass ens domain here
onDeploy(/* domain */) {
// console.log('this.props', this.data)
this.deployContract({ action: this.data })
onDeploy() {
this.deployContract({ action: this.data, index: this.$vnode.key })
},
domainUrl(address) {
return `https://etherscan.io/address/${address}`

View File

@ -36,11 +36,12 @@ export default {
})
}
this.fetchDeploymentStatus()
this.statusPooling()
this.fetchGasPrice()
},
methods: {
...mapActions('provider', ['initProvider']),
...mapActions('steps', ['fetchDeploymentStatus']),
...mapActions('steps', ['statusPooling', 'fetchDeploymentStatus']),
...mapActions('gasPrice', ['fetchGasPrice']),
},
}

View File

@ -70,7 +70,7 @@ export default {
},
},
],
'@nuxtjs/provider',
'nuxt-web3-provider',
],
provider: {

View File

@ -12,7 +12,7 @@
"deploy-prod": "npm run generate && push-dir --dir=dist --branch=gh-pages --cleanup --remote=temp"
},
"dependencies": {
"@nuxtjs/provider": "https://github.com/tornadocash/provider",
"nuxt-web3-provider": "^0.1.1",
"core-js": "^3.6.5",
"gas-price-oracle": "^0.2.2",
"node-sass": "^4.14.1",

File diff suppressed because one or more lines are too long

View File

@ -24,7 +24,7 @@ const mutations = {}
const actions = {
async deployContract(
{ state, dispatch, getters, rootGetters, commit, rootState },
{ action }
{ action, index }
) {
try {
dispatch('loading/enable', {}, { root: true })
@ -103,6 +103,11 @@ const actions = {
})
console.log('txHash', txHash)
dispatch('loading/disable', {}, { root: true })
dispatch(
'steps/setPendingState',
{ status: true, stepIndex: index },
{ root: true }
)
const noticeId = await dispatch(
'notice/addNotice',
@ -131,6 +136,7 @@ const actions = {
title: 'contractDeployed',
type: 'success',
},
interval: 20000,
},
{ root: true }
)
@ -144,6 +150,7 @@ const actions = {
title: 'transactionFailed',
type: 'danger',
},
interval: 20000,
},
{ root: true }
)
@ -162,6 +169,11 @@ const actions = {
)
} finally {
dispatch('loading/disable', {}, { root: true })
dispatch(
'steps/setPendingState',
{ status: false, stepIndex: index },
{ root: true }
)
}
},
}

View File

@ -46,11 +46,11 @@ export const actions = {
}
},
addNoticeWithInterval({ dispatch }, { notice, interval }) {
return new Promise((resolve) => {
dispatch('addNotice', { notice }).then((id) => {
dispatch('addNoticeTimer', { id, interval })
resolve(id)
})
// eslint-disable-next-line no-async-promise-executor
return new Promise(async (resolve) => {
const id = await dispatch('addNotice', { notice })
dispatch('addNoticeTimer', { id, interval })
resolve(id)
})
},
deleteNotice({ state, commit, dispatch }, { id }) {

View File

@ -18,7 +18,9 @@ export default {
localStorage.setItem('provider', { name, network })
const account = await this.$provider.initProvider(getters.getProvider)
await dispatch('checkNetworkVersion')
const netId = await dispatch('checkNetworkVersion')
this.$provider.initWeb3(networkConfig[`netId${netId}`].rpcUrls.Infura.url)
commit(SET_ACCOUNT, account)
@ -31,6 +33,7 @@ export default {
try {
const id = await this.$provider.checkNetworkVersion()
commit(SET_NETWORK, { ...networkConfig[`netId${id}`], id: Number(id) })
return id
} catch (err) {
throw new Error(err.message)
}

View File

@ -22,6 +22,7 @@ const getters = {
}
const SET_DEPLOYER = 'SET_DEPLOYER'
const SET_PENDING_STATE = 'SET_PENDING_STATE'
const mutations = {
[SET_DEPLOYER](state, { stepIndex, deployerAddress, deployTransaction }) {
this._vm.$set(state.steps[stepIndex], 'deployerAddress', deployerAddress)
@ -31,6 +32,9 @@ const mutations = {
deployTransaction
)
},
[SET_PENDING_STATE](state, { status, stepIndex }) {
this._vm.$set(state.steps[stepIndex], 'isPending', status)
},
}
const actions = {
@ -48,7 +52,6 @@ const actions = {
if (!step) {
continue
}
console.log('event', event)
commit(SET_DEPLOYER, {
stepIndex: state.steps.indexOf(step),
deployerAddress: event.returnValues.sender,
@ -56,6 +59,19 @@ const actions = {
})
}
},
statusPooling({ dispatch }) {
setTimeout(async () => {
try {
console.log('Fetching deployment status...')
await dispatch('fetchDeploymentStatus')
} finally {
dispatch('statusPooling')
}
}, 15000)
},
setPendingState({ commit }, { status, stepIndex }) {
commit(SET_PENDING_STATE, { status, stepIndex })
},
}
export default {
namespaced: true,

View File

@ -1410,13 +1410,6 @@
consola "^2.11.3"
eslint-loader "^4.0.2"
"@nuxtjs/provider@https://github.com/tornadocash/provider":
version "0.0.5"
resolved "https://github.com/tornadocash/provider#cf186e3f2b852b95e51959855a61171309c8f478"
dependencies:
web3 "^1.3.0"
web3-utils "^1.3.0"
"@nuxtjs/youch@^4.2.3":
version "4.2.3"
resolved "https://registry.yarnpkg.com/@nuxtjs/youch/-/youch-4.2.3.tgz#36f8b22df5a0efaa81373109851e1d857aca6bed"
@ -7178,6 +7171,14 @@ nuxt-buefy@^0.4.4:
dependencies:
buefy "^0.9.4"
nuxt-web3-provider@^0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/nuxt-web3-provider/-/nuxt-web3-provider-0.1.1.tgz#8311b21444cf07e9f460c5ea4468c126c067e402"
integrity sha512-okYZwF0EsG5ukfYYCyFImnGQOCYvZLKKj2lUJfNaRbfcTR8KTbhxKBpuNtYA7V0ZJMdSQ3qbJ8ZQW64IoM9soA==
dependencies:
web3 "^1.3.0"
web3-utils "^1.3.0"
nuxt@^2.14.6:
version "2.14.6"
resolved "https://registry.yarnpkg.com/nuxt/-/nuxt-2.14.6.tgz#56ba99cbd055ebdb33250a4d1ed09f084ad7fa14"