@@ -1,4 +1,3 @@
1−import Tx from 'ethereumjs-tx';
2import * as azimuth from 'azimuth-js';
1import * as azimuth from 'azimuth-js';
3import * as tank from './tank';
2import * as tank from './tank';
@@ -9,7 +8,11 @@ import {
9 CRYPTO_SUITE_VERSION,
8 CRYPTO_SUITE_VERSION,
10} from './keys';
9} from './keys';
11import { addHexPrefix } from './wallet';
10import { addHexPrefix } from './wallet';
12+ sendAndAwaitAllSerial,
14+ sendSignedTransaction,
12−import { sendAndAwaitAll } from './txn';
15+} from './txn';
13import getSuggestedGasPrice from './getSuggestedGasPrice';
16import getSuggestedGasPrice from './getSuggestedGasPrice';
14import { GAS_LIMITS } from './constants';
17import { GAS_LIMITS } from './constants';
15import { toWei, toBN } from 'web3-utils';
18import { toWei, toBN } from 'web3-utils';
@@ -28,6 +31,8 @@ export const TRANSACTION_PROGRESS = {
29export async function reticketPointBetweenWallets({
32export async function reticketPointBetweenWallets({
30 fromWallet,
33 fromWallet,
@@ -143,26 +148,44 @@ export async function reticketPointBetweenWallets({
143 progress(TRANSACTION_PROGRESS.SIGNING);
148 progress(TRANSACTION_PROGRESS.SIGNING);
145 const suggestedGasPrice = await getSuggestedGasPrice(networkType);
150 const suggestedGasPrice = await getSuggestedGasPrice(networkType);
151+ const chainId = await web3.eth.net.getId();
146 const gasPrice = toWei(suggestedGasPrice.toFixed(), 'gwei');
152 const gasPrice = toWei(suggestedGasPrice.toFixed(), 'gwei');
153+ console.log(suggestedGasPrice.toFixed());
147 const gasPriceBN = toBN(gasPrice);
154 const gasPriceBN = toBN(gasPrice);
148− let totalCost = toBN(0);
155+ console.log(gasPrice);
149 let inviteNonce = await web3.eth.getTransactionCount(fromWallet.address);
156 let inviteNonce = await web3.eth.getTransactionCount(fromWallet.address);
150− txs = txs.map(tx => {
157+ console.log(txs);
151− tx.from = fromWallet.address;
158+ const totalCost = txs.reduce(
152− tx.nonce = inviteNonce++;
153− tx.gasPrice = gasPriceBN;
154− totalCost = totalCost.add(gasPriceBN.mul(toBN(tx.gas)));
159+ (acc, tx) => acc.add(gasPriceBN.mul(toBN(tx.gas))),
155− return tx;
160+ toBN(0)
165+ let txPairs = await Promise.all(
158− let txPairs = txs.map(tx => {
166+ txs.map(async (tx, idx) => {
159− let stx = new Tx(tx);
167+ const stx = await signTransaction({
160− stx.sign(Buffer.from(fromWallet.privateKey, 'hex'));
168+ wallet: fromWallet,
169+ walletType: fromWalletType,
170+ walletHdPath: fromWalletHdPath,
173+ nonce: inviteNonce + idx,
175+ gasPrice: suggestedGasPrice.toFixed(),
161− return {
181+ return {
162− raw: hexify(stx.serialize()),
182+ raw: hexify(stx.serialize()),
163− signed: stx,
183+ signed: stx,
188+ inviteNonce = inviteNonce + txs.length;
168 // ensuring funding for transactions
191 // ensuring funding for transactions
@@ -186,7 +209,8 @@ export async function reticketPointBetweenWallets({
187 progress(TRANSACTION_PROGRESS.TRANSFERRING);
210 progress(TRANSACTION_PROGRESS.TRANSFERRING);
212+ console.log(txPairs);
189− await sendAndAwaitAll(web3, txPairs.map(p => p.signed), usedTank);
213+ await sendAndAwaitAllSerial(web3, txPairs.map(p => p.signed), usedTank);
192 // move leftover eth
216 // move leftover eth
@@ -200,17 +224,24 @@ export async function reticketPointBetweenWallets({
200 const sendEthCost = gasPriceBN.mul(toBN(gasLimit));
224 const sendEthCost = gasPriceBN.mul(toBN(gasLimit));
201 if (transferEth && balance.gt(sendEthCost)) {
225 if (transferEth && balance.gt(sendEthCost)) {
202 const value = balance.sub(sendEthCost);
226 const value = balance.sub(sendEthCost);
203− const tx = {
227+ const txn = {
204 to: toWallet.ownership.keys.address,
228 to: toWallet.ownership.keys.address,
205 value: value,
229 value: value,
231+ const stx = signTransaction({
233+ walletType: fromWalletType,
234+ walletHdPath: fromWalletHdPath,
206 gasPrice: gasPriceBN,
238 gasPrice: gasPriceBN,
207− gas: gasLimit,
239+ gasLimit,
208 nonce: inviteNonce++,
240 nonce: inviteNonce++,
210− let stx = new Tx(tx);
242+ // let stx = new Tx(tx);
211− stx.sign(fromWallet.privateKey);
243+ // stx.sign(fromWallet.privateKey);
212− const rawTx = hexify(stx.serialize());
244+ sendSignedTransaction(web3, stx).catch(err => {
213− web3.eth.sendSignedTransaction(rawTx).catch(err => {
214 console.log('error sending value tx, who cares', err);
245 console.log('error sending value tx, who cares', err);