create transaction with threshold > 1, txs table for awaiting confirmation txs

This commit is contained in:
mmv 2019-06-20 17:52:27 +04:00
parent 57ddfad2b0
commit 0867448aca
5 changed files with 50 additions and 9 deletions

View File

@ -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,
) => {

View File

@ -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,

View File

@ -6,7 +6,7 @@ export const styles = () => ({
display: 'flex',
fontSize: smallFontSize,
fontWeight: boldFont,
width: '105px',
width: '100px',
padding: sm,
alignItems: 'center',
boxSizing: 'border-box',

View File

@ -33,7 +33,7 @@ export const getTxTableData = (transactions: List<Transaction>): List<BalanceRow
[TX_TABLE_TYPE_ID]: 'Outgoing transfer',
[TX_TABLE_DATE_ID]: formatDate(tx.isExecuted ? tx.executionDate : tx.submissionDate),
[TX_TABLE_AMOUNT_ID]: Number(tx.value) > 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

View File

@ -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))