refactor: use array destructuring instead of indexing
This commit is contained in:
parent
ac20f05dd4
commit
0ff73687eb
1 changed files with 8 additions and 8 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
|
const _ = require('lodash/fp')
|
||||||
const Web3 = require('web3')
|
const Web3 = require('web3')
|
||||||
const web3 = new Web3()
|
const web3 = new Web3()
|
||||||
const hdkey = require('ethereumjs-wallet/hdkey')
|
const hdkey = require('ethereumjs-wallet/hdkey')
|
||||||
|
|
@ -113,20 +114,19 @@ function generateTx (_toAddress, wallet, amount, includesFee, cryptoCode) {
|
||||||
]
|
]
|
||||||
|
|
||||||
return Promise.all(promises)
|
return Promise.all(promises)
|
||||||
.then(arr => {
|
.then(([gas, gasPrice, txCount]) => [
|
||||||
const gas = arr[0]
|
gas,
|
||||||
const gasPrice = arr[1]
|
gasPrice,
|
||||||
const txCount = arr[2] <= lastUsedNonces[fromAddress]
|
_.max([txCount, lastUsedNonces[fromAddress] + 1])
|
||||||
? lastUsedNonces[fromAddress] + 1
|
])
|
||||||
: arr[2]
|
.then(([gas, gasPrice, txCount]) => {
|
||||||
|
|
||||||
lastUsedNonces[fromAddress] = txCount
|
lastUsedNonces[fromAddress] = txCount
|
||||||
|
|
||||||
const toSend = includesFee
|
const toSend = includesFee
|
||||||
? amount.minus(gasPrice.times(gas))
|
? amount.minus(gasPrice.times(gas))
|
||||||
: amount
|
: amount
|
||||||
|
|
||||||
const contract = web3.eth.contract(ABI.ERC20).at(coins.utils.getErc20Token(cryptoCode).contractAddress)
|
const contract = web3.eth.contract(ABI.ERC20).at(toAddress)
|
||||||
|
|
||||||
const rawTx = {
|
const rawTx = {
|
||||||
chainId: 1,
|
chainId: 1,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue