diff --git a/src/routes/safe/component/Transactions/index.jsx b/src/routes/safe/component/Transactions/index.jsx index 0f5cdaa4..22988209 100644 --- a/src/routes/safe/component/Transactions/index.jsx +++ b/src/routes/safe/component/Transactions/index.jsx @@ -6,7 +6,7 @@ import { sleep } from '~/utils/timer' import { type Safe } from '~/routes/safe/store/model/safe' import actions, { type Actions } from './actions' import selector, { type SelectorProps } from './selector' -import transaction, { createTransaction, TX_NAME_PARAM, TX_DESTINATION_PARAM, TX_VALUE_PARAM } from './transactions' +import transaction, { storeTransaction, TX_NAME_PARAM, TX_DESTINATION_PARAM, TX_VALUE_PARAM } from './transactions' import MultisigForm from './MultisigForm' import ReviewTx from './ReviewTx' @@ -38,9 +38,9 @@ class Transactions extends React.Component { const destination = values[TX_DESTINATION_PARAM] const value = values[TX_VALUE_PARAM] const tx = await transaction(safe.get('address'), destination, value, nonce, userAddress) - await createTransaction( + await storeTransaction( values[TX_NAME_PARAM], nonce, destination, value, userAddress, - safe.get('owners'), tx, safe.get('address'), safe.get('confirmations'), + safe.get('owners'), tx.tx, safe.get('address'), safe.get('confirmations'), ) await sleep(1500) this.props.fetchTransactions() diff --git a/src/routes/safe/component/Transactions/test/transactions.test.js b/src/routes/safe/component/Transactions/test/transactions.test.js index dda2dff8..4d3fdf7f 100644 --- a/src/routes/safe/component/Transactions/test/transactions.test.js +++ b/src/routes/safe/component/Transactions/test/transactions.test.js @@ -1,6 +1,6 @@ // @flow import { List, Map } from 'immutable' -import { createTransaction } from '~/routes/safe/component/Transactions/transactions' +import { storeTransaction } from '~/routes/safe/component/Transactions/transactions' import { type Transaction } from '~/routes/safe/store/model/transaction' import { SafeFactory } from '~/routes/safe/store/test/builder/safe.builder' import { type Safe } from '~/routes/safe/store/model/safe' @@ -31,7 +31,7 @@ describe('Transactions Suite', () => { // GIVEN const txName = 'Buy butteries for project' const nonce: number = 10 - createTransaction(txName, nonce, destination, value, 'foo', owners, '', safe.get('address'), safe.get('confirmations')) + storeTransaction(txName, nonce, destination, value, 'foo', owners, '', safe.get('address'), safe.get('confirmations')) // WHEN const transactions: Map> = loadSafeTransactions() @@ -51,11 +51,11 @@ describe('Transactions Suite', () => { const firstTxName = 'Buy butteries for project' const firstNonce: number = Date.now() const safeAddress = safe.get('address') - createTransaction(firstTxName, firstNonce, destination, value, 'foo', owners, '', safeAddress, safe.get('confirmations')) + storeTransaction(firstTxName, firstNonce, destination, value, 'foo', owners, '', safeAddress, safe.get('confirmations')) const secondTxName = 'Buy printers for project' const secondNonce: number = firstNonce + 100 - createTransaction(secondTxName, secondNonce, destination, value, 'foo', owners, '', safeAddress, safe.get('confirmations')) + storeTransaction(secondTxName, secondNonce, destination, value, 'foo', owners, '', safeAddress, safe.get('confirmations')) // WHEN const transactions: Map> = loadSafeTransactions() @@ -75,13 +75,13 @@ describe('Transactions Suite', () => { const txName = 'Buy batteris for Alplha project' const nonce = 10 const safeAddress = safe.address - createTransaction(txName, nonce, destination, value, 'foo', owners, '', safeAddress, safe.get('confirmations')) + storeTransaction(txName, nonce, destination, value, 'foo', owners, '', safeAddress, safe.get('confirmations')) const secondSafe = SafeFactory.dailyLimitSafe(10, 2) const txSecondName = 'Buy batteris for Beta project' const txSecondNonce = 10 const secondSafeAddress = secondSafe.address - createTransaction( + storeTransaction( txSecondName, txSecondNonce, destination, value, '0x03db1a8b26d08df23337e9276a36b474510f0023', secondSafe.get('owners'), '', secondSafeAddress, secondSafe.get('confirmations'), ) @@ -100,7 +100,7 @@ describe('Transactions Suite', () => { // WHEN const txFirstName = 'Buy paper for Alplha project' const txFirstNonce = 11 - createTransaction( + storeTransaction( txFirstName, txFirstNonce, destination, value, 'foo', safe.get('owners'), '', safe.get('address'), safe.get('confirmations'), ) @@ -136,10 +136,10 @@ describe('Transactions Suite', () => { // GIVEN const txName = 'Buy butteries for project' const nonce: number = 10 - createTransaction(txName, nonce, destination, value, 'foo', owners, '', safe.get('address'), safe.get('confirmations')) + storeTransaction(txName, nonce, destination, value, 'foo', owners, '', safe.get('address'), safe.get('confirmations')) // WHEN - const createTxFnc = () => createTransaction(txName, nonce, destination, value, 'foo', owners, '', safe.get('address'), safe.get('confirmations')) + const createTxFnc = () => storeTransaction(txName, nonce, destination, value, 'foo', owners, '', safe.get('address'), safe.get('confirmations')) expect(createTxFnc).toThrow(/Transaction with same nonce/) }) @@ -147,7 +147,7 @@ describe('Transactions Suite', () => { // GIVEN const txName = 'Buy butteries for project' const nonce: number = 10 - createTransaction(txName, nonce, destination, value, 'foo', owners, '', safe.get('address'), safe.get('confirmations')) + storeTransaction(txName, nonce, destination, value, 'foo', owners, '', safe.get('address'), safe.get('confirmations')) // WHEN const transactions: Map> = loadSafeTransactions() @@ -161,7 +161,7 @@ describe('Transactions Suite', () => { const txName = 'Buy butteries for project' const nonce: number = 10 const ownerName = 'invented' - const createTxFnc = () => createTransaction(txName, nonce, destination, value, ownerName, owners, '', safe.get('address'), safe.get('confirmations')) + const createTxFnc = () => storeTransaction(txName, nonce, destination, value, ownerName, owners, '', safe.get('address'), safe.get('confirmations')) expect(createTxFnc).toThrow(/The creator of the tx is not an owner/) }) @@ -172,7 +172,7 @@ describe('Transactions Suite', () => { const txName = 'Buy butteries for project' const nonce: number = 10 const tx = '' - const createTxFnc = () => createTransaction(txName, nonce, destination, value, ownerName, oneOwnerSafe.get('owners'), tx, oneOwnerSafe.get('address'), oneOwnerSafe.get('confirmations')) + const createTxFnc = () => storeTransaction(txName, nonce, destination, value, ownerName, oneOwnerSafe.get('owners'), tx, oneOwnerSafe.get('address'), oneOwnerSafe.get('confirmations')) expect(createTxFnc).toThrow(/The tx should be mined before storing it in safes with one owner/) }) diff --git a/src/routes/safe/component/Transactions/transactions.js b/src/routes/safe/component/Transactions/transactions.js index e5ab22ef..5db5a7cf 100644 --- a/src/routes/safe/component/Transactions/transactions.js +++ b/src/routes/safe/component/Transactions/transactions.js @@ -23,7 +23,7 @@ const buildConfirmationsFrom = (owners: List, creator: string): List makeConfirmation({ owner, status: owner.get('address') === creator })) } -export const createTransaction = ( +export const storeTransaction = ( name: string, nonce: number, destination: string,