diff --git a/src/logic/safe/transactions/send.js b/src/logic/safe/transactions/send.js index 2afc3c69..d1ec0b13 100644 --- a/src/logic/safe/transactions/send.js +++ b/src/logic/safe/transactions/send.js @@ -5,18 +5,60 @@ import { EMPTY_DATA } from '~/logic/wallets/ethTransactions' import { isEther } from '~/logic/tokens/utils/tokenHelpers' import { type Token } from '~/logic/tokens/store/model/token' import { getGnosisSafeInstanceAt } from '~/logic/contracts/safeContracts' -import { saveTxToHistory } from '~/logic/safe/transactions' +import { type Operation, saveTxToHistory } from '~/logic/safe/transactions' import { ZERO_ADDRESS } from '~/logic/wallets/ethAddresses' export const CALL = 0 export const TX_TYPE_EXECUTION = 'execution' +export const TX_TYPE_CONFIRMATION = 'confirmation' + +export const approveTransaction = async ( + safeInstance: any, + to: string, + valueInWei: number | string, + data: string, + operation: Operation, + nonce: number, + sender: string, +) => { + const contractTxHash = await safeInstance.getTransactionHash( + to, + valueInWei, + data, + operation, + 0, + 0, + 0, + ZERO_ADDRESS, + ZERO_ADDRESS, + nonce, + { + from: sender, + }, + ) + const receipt = await safeInstance.approveHash(contractTxHash, { from: sender }) + + await saveTxToHistory( + safeInstance, + to, + valueInWei, + data, + operation, + nonce, + receipt.tx, // tx hash, + sender, + TX_TYPE_CONFIRMATION, + ) + + return receipt +} export const executeTransaction = async ( safeInstance: any, to: string, valueInWei: number | string, data: string, - operation: number | string, + operation: Operation, nonce: string | number, sender: string, ) => { diff --git a/src/logic/safe/transactions/txHistory.js b/src/logic/safe/transactions/txHistory.js index a4f642fd..d29e69c4 100644 --- a/src/logic/safe/transactions/txHistory.js +++ b/src/logic/safe/transactions/txHistory.js @@ -10,7 +10,7 @@ export type Operation = 0 | 1 | 2 const calculateBodyFrom = async ( safeInstance: any, to: string, - valueInWei: number, + valueInWei: number | string, data: string, operation: Operation, nonce: string | number, @@ -59,7 +59,7 @@ export const buildTxServiceUrl = (safeAddress: string) => { export const saveTxToHistory = async ( safeInstance: any, to: string, - valueInWei: number, + valueInWei: number | string, data: string, operation: Operation, nonce: number | string, diff --git a/src/routes/safe/components/TransactionsNew/TxsTable/Status/style.js b/src/routes/safe/components/TransactionsNew/TxsTable/Status/style.js index 56f48e76..cd0e65d5 100644 --- a/src/routes/safe/components/TransactionsNew/TxsTable/Status/style.js +++ b/src/routes/safe/components/TransactionsNew/TxsTable/Status/style.js @@ -6,7 +6,7 @@ export const styles = () => ({ display: 'flex', fontSize: smallFontSize, fontWeight: boldFont, - width: '105px', + width: '100px', padding: sm, alignItems: 'center', boxSizing: 'border-box', diff --git a/src/routes/safe/components/TransactionsNew/TxsTable/columns.js b/src/routes/safe/components/TransactionsNew/TxsTable/columns.js index 4d31d3c2..f7bd5e51 100644 --- a/src/routes/safe/components/TransactionsNew/TxsTable/columns.js +++ b/src/routes/safe/components/TransactionsNew/TxsTable/columns.js @@ -33,7 +33,7 @@ export const getTxTableData = (transactions: List): List 0 ? fromWei(toBN(tx.value), 'ether') : 'n/a', - [TX_TABLE_STATUS_ID]: tx.isExecuted ? 'success' : 'pending', + [TX_TABLE_STATUS_ID]: tx.isExecuted ? 'success' : 'awaiting', })) return rows diff --git a/src/routes/safe/store/actions/createTransaction.js b/src/routes/safe/store/actions/createTransaction.js index b3cd9de0..3fd402f9 100644 --- a/src/routes/safe/store/actions/createTransaction.js +++ b/src/routes/safe/store/actions/createTransaction.js @@ -1,11 +1,10 @@ // @flow import type { Dispatch as ReduxDispatch, GetState } from 'redux' -import { createAction } from 'redux-actions' import { EMPTY_DATA } from '~/logic/wallets/ethTransactions' import { userAccountSelector } from '~/logic/wallets/store/selectors' import { type GlobalState } from '~/store' import { getGnosisSafeInstanceAt } from '~/logic/contracts/safeContracts' -import { executeTransaction, CALL } from '~/logic/safe/transactions' +import { approveTransaction, executeTransaction, CALL } from '~/logic/safe/transactions' const createTransaction = ( safeAddress: string, @@ -28,7 +27,7 @@ const createTransaction = ( txHash = await executeTransaction(safeInstance, to, valueInWei, txData, CALL, nonce, from) openSnackbar('Transaction has been confirmed', 'success') } else { - // txHash = await approveTransaction(safeAddress, to, valueInWei, txData, CALL, nonce) + txHash = await approveTransaction(safeInstance, to, valueInWei, txData, CALL, nonce, from) } // dispatch(addTransactions(txHash))