Send transaction to the service right after we get the tx hash (support after tx-history-service refactor)

This commit is contained in:
mmv 2019-11-11 15:11:20 +04:00
parent 29a188285f
commit dd4fe35866
2 changed files with 18 additions and 18 deletions

View File

@ -72,7 +72,7 @@ const createTransaction = (
await tx await tx
.send(sendParams) .send(sendParams)
.once('transactionHash', (hash) => { .once('transactionHash', async (hash) => {
txHash = hash txHash = hash
closeSnackbar(beforeExecutionKey) closeSnackbar(beforeExecutionKey)
const pendingExecutionNotification: Notification = isExecution const pendingExecutionNotification: Notification = isExecution
@ -85,12 +85,6 @@ const createTransaction = (
options: notificationsQueue.pendingExecution.moreConfirmationsNeeded.options, options: notificationsQueue.pendingExecution.moreConfirmationsNeeded.options,
} }
pendingExecutionKey = showSnackbar(pendingExecutionNotification, enqueueSnackbar, closeSnackbar) pendingExecutionKey = showSnackbar(pendingExecutionNotification, enqueueSnackbar, closeSnackbar)
})
.on('error', (error) => {
console.error('Tx error: ', error)
})
.then(async (receipt) => {
closeSnackbar(pendingExecutionKey)
try { try {
await saveTxToHistory( await saveTxToHistory(
@ -100,13 +94,19 @@ const createTransaction = (
txData, txData,
CALL, CALL,
nonce, nonce,
receipt.transactionHash, txHash,
from, from,
isExecution ? TX_TYPE_EXECUTION : TX_TYPE_CONFIRMATION, isExecution ? TX_TYPE_EXECUTION : TX_TYPE_CONFIRMATION,
) )
} catch (err) { } catch (err) {
console.log(err) console.error(err)
} }
})
.on('error', (error) => {
console.error('Tx error: ', error)
})
.then((receipt) => {
closeSnackbar(pendingExecutionKey)
if (isExecution) { if (isExecution) {
showSnackbar(notificationsQueue.afterExecution, enqueueSnackbar, closeSnackbar) showSnackbar(notificationsQueue.afterExecution, enqueueSnackbar, closeSnackbar)

View File

@ -104,7 +104,7 @@ const processTransaction = (
await transaction await transaction
.send(sendParams) .send(sendParams)
.once('transactionHash', (hash) => { .once('transactionHash', async (hash) => {
txHash = hash txHash = hash
closeSnackbar(beforeExecutionKey) closeSnackbar(beforeExecutionKey)
const notification: Notification = { const notification: Notification = {
@ -112,12 +112,6 @@ const processTransaction = (
options: notificationsQueue.pendingExecution.noMoreConfirmationsNeeded.options, options: notificationsQueue.pendingExecution.noMoreConfirmationsNeeded.options,
} }
pendingExecutionKey = showSnackbar(notification, enqueueSnackbar, closeSnackbar) pendingExecutionKey = showSnackbar(notification, enqueueSnackbar, closeSnackbar)
})
.on('error', (error) => {
console.error('Processing transaction error: ', error)
})
.then(async (receipt) => {
closeSnackbar(pendingExecutionKey)
try { try {
await saveTxToHistory( await saveTxToHistory(
@ -127,13 +121,19 @@ const processTransaction = (
tx.data, tx.data,
CALL, CALL,
nonce, nonce,
receipt.transactionHash, txHash,
from, from,
shouldExecute ? TX_TYPE_EXECUTION : TX_TYPE_CONFIRMATION, shouldExecute ? TX_TYPE_EXECUTION : TX_TYPE_CONFIRMATION,
) )
} catch (err) { } catch (err) {
console.log(err) console.error(err)
} }
})
.on('error', (error) => {
console.error('Processing transaction error: ', error)
})
.then((receipt) => {
closeSnackbar(pendingExecutionKey)
showSnackbar(notificationsQueue.afterExecution, enqueueSnackbar, closeSnackbar) showSnackbar(notificationsQueue.afterExecution, enqueueSnackbar, closeSnackbar)
dispatch(fetchTransactions(safeAddress)) dispatch(fetchTransactions(safeAddress))