2020-10-30 09:01:41 +01:00
|
|
|
/* eslint-disable no-console */
|
|
|
|
import txStatus from './txStatus'
|
|
|
|
const { hexToNumber } = require('web3-utils')
|
|
|
|
|
|
|
|
export const getters = {
|
2020-11-03 12:48:03 +01:00
|
|
|
txExplorerUrl: (state, getters, rootState, rootGetters) => (txHash) => {
|
|
|
|
const { explorerUrl } = rootGetters['provider/getNetwork']
|
|
|
|
return explorerUrl.tx + txHash
|
2020-10-30 09:01:41 +01:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
export const actions = {
|
2020-11-03 12:48:03 +01:00
|
|
|
async runTxWatcher({ commit, dispatch }, { txHash }) {
|
|
|
|
const result = await dispatch(
|
|
|
|
'provider/waitForTxReceipt',
|
2020-10-30 09:01:41 +01:00
|
|
|
{ txHash },
|
|
|
|
{ root: true }
|
|
|
|
)
|
2020-11-03 12:48:03 +01:00
|
|
|
|
|
|
|
console.info('runTxWatcher result', JSON.stringify(result))
|
|
|
|
|
|
|
|
if (!result || !result.status) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
const status =
|
|
|
|
hexToNumber(result.status) === 1 ? txStatus.success : txStatus.fail
|
|
|
|
|
2020-10-30 09:01:41 +01:00
|
|
|
return status === txStatus.success
|
|
|
|
},
|
|
|
|
}
|