@@ -104,6 +104,8 @@ const signTransaction = async config => {
104 return stx;
104 return stx;
107+// TODO(shrugs): refactor the hell out of all of these functions
108+// but especially this one
107const sendSignedTransaction = (web3, stx, doubtNonceError, confirmationCb) => {
109const sendSignedTransaction = (web3, stx, doubtNonceError, confirmationCb) => {
108 const txn = stx.matchWith({
110 const txn = stx.matchWith({
109 Just: tx => tx.value,
111 Just: tx => tx.value,
@@ -125,7 +127,9 @@ const sendSignedTransaction = (web3, stx, doubtNonceError, confirmationCb) => {
125 // in on-transactionHash? we don't care (much) about additional
127 // in on-transactionHash? we don't care (much) about additional
126 // confirms anyway.
128 // confirms anyway.
127 .on('confirmation', (confirmationNum, txn) => {
129 .on('confirmation', (confirmationNum, txn) => {
130+ if (confirmationCb) {
128− confirmationCb(txn.transactionHash, confirmationNum + 1);
131+ confirmationCb(txn.transactionHash, confirmationNum + 1);
129 resolve(txn.transactionHash);
133 resolve(txn.transactionHash);
131 .on('error', err => {
135 .on('error', err => {
@@ -177,15 +181,8 @@ const isTransactionConfirmed = async (web3, txHash) => {
177 return receipt !== null;
181 return receipt !== null;
180−async function sendAndAwaitConfirm(web3, signedTxs, usedTank) {
184+const sendTransactionsAndAwaitConfirm = async (web3, signedTxs, usedTank) =>
182− signedTxs.map(tx => {
183− return new Promise((resolve, reject) => {
184− sendSignedTransaction(web3, tx, usedTank, resolve);
185+ Promise.all(signedTxs.map(tx => sendSignedTransaction(web3, tx, usedTank)));
190const hexify = val => addHexPrefix(val.toString('hex'));
187const hexify = val => addHexPrefix(val.toString('hex'));
@@ -201,6 +198,7 @@ const getTxnInfo = async (web3, addr) => {
201 let nonce = await web3.eth.getTransactionCount(addr);
198 let nonce = await web3.eth.getTransactionCount(addr);
202 let chainId = await web3.eth.net.getId();
199 let chainId = await web3.eth.net.getId();
203 let gasPrice = await web3.eth.getGasPrice();
200 let gasPrice = await web3.eth.getGasPrice();
205 nonce: nonce,
203 nonce: nonce,
206 chainId: chainId,
204 chainId: chainId,
@@ -222,7 +220,7 @@ export {
222 signTransaction,
220 signTransaction,
223 sendSignedTransaction,
221 sendSignedTransaction,
224 waitForTransactionConfirm,
222 waitForTransactionConfirm,
225− sendAndAwaitConfirm,
223+ sendTransactionsAndAwaitConfirm,
226 isTransactionConfirmed,
224 isTransactionConfirmed,
227 getTxnInfo,
225 getTxnInfo,