@@ -104,6 +104,8 @@ const signTransaction = async config => {
104104 return stx;
105105};
106106
107+// TODO(shrugs): refactor the hell out of all of these functions
108+// but especially this one
107109const sendSignedTransaction = (web3, stx, doubtNonceError, confirmationCb) => {
108110 const txn = stx.matchWith({
109111 Just: tx => tx.value,
@@ -125,7 +127,9 @@ const sendSignedTransaction = (web3, stx, doubtNonceError, confirmationCb) => {
125127 // in on-transactionHash? we don't care (much) about additional
126128 // confirms anyway.
127129 .on('confirmation', (confirmationNum, txn) => {
128− confirmationCb(txn.transactionHash, confirmationNum + 1);
130+ if (confirmationCb) {
131+ confirmationCb(txn.transactionHash, confirmationNum + 1);
132+ }
129133 resolve(txn.transactionHash);
130134 })
131135 .on('error', err => {
@@ -177,15 +181,8 @@ const isTransactionConfirmed = async (web3, txHash) => {
177181 return receipt !== null;
178182};
179183
180−async function sendAndAwaitConfirm(web3, signedTxs, usedTank) {
181− await Promise.all(
182− signedTxs.map(tx => {
183− return new Promise((resolve, reject) => {
184− sendSignedTransaction(web3, tx, usedTank, resolve);
185− });
186− })
187− );
188−}
184+const sendTransactionsAndAwaitConfirm = async (web3, signedTxs, usedTank) =>
185+ Promise.all(signedTxs.map(tx => sendSignedTransaction(web3, tx, usedTank)));
189186
190187const hexify = val => addHexPrefix(val.toString('hex'));
191188
@@ -201,6 +198,7 @@ const getTxnInfo = async (web3, addr) => {
201198 let nonce = await web3.eth.getTransactionCount(addr);
202199 let chainId = await web3.eth.net.getId();
203200 let gasPrice = await web3.eth.getGasPrice();
201+
204202 return {
205203 nonce: nonce,
206204 chainId: chainId,
@@ -222,7 +220,7 @@ export {
222220 signTransaction,
223221 sendSignedTransaction,
224222 waitForTransactionConfirm,
225− sendAndAwaitConfirm,
223+ sendTransactionsAndAwaitConfirm,
226224 isTransactionConfirmed,
227225 getTxnInfo,
228226 hexify,