Skip to content

Commit

Permalink
#11 Set nonce manually in TradingWalletFacade
Browse files Browse the repository at this point in the history
  • Loading branch information
ceres3idoo committed Feb 22, 2019
1 parent 04038ce commit bd308f6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/facades/TradingWalletFacade.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ class TradingWalletFacade {
async throwIfTokenWalletEnought(personalWalletAddress, quantity) {
const assetBalance = await this.erc20TokenService.getBalanceOfAsync(personalWalletAddress)

if (assetBalance < quantity) {
const assetBalanceToBigNumber = this.transactionLib.web3.toBigNumber(assetBalance)
const quantityToBigNumber = this.transactionLib.web3.toBigNumber(quantity)
if (assetBalanceToBigNumber.lt(quantityToBigNumber)) {
const errorMessage = 'The asset balance is < than the quantity to depoist!'
this.log.info({
personalWalletAddress,
Expand Down Expand Up @@ -98,12 +100,13 @@ class TradingWalletFacade {
quantity,
)
const gasEstimationForApprove = await this.transactionLib.getGasEstimation(approveTransactionDraftObject)
const nonceForApprove = await this.transactionLib.getNonce(personalWalletAddress)

if (allowanceToInt === 0 || (quantity > allowanceToInt && allowanceToInt > 0)) {
const signedApproveData = await this.transactionLib.sign(
approveTransactionDraftObject,
privateKey,
null,
nonceForApprove,
gasEstimationForApprove.gas,
gasEstimationForApprove.gasPrice,
)
Expand All @@ -117,6 +120,7 @@ class TradingWalletFacade {
const signedTransactionDataForDeposit = await this.transactionLib.sign(
depositTokenTransactionDraft,
privateKey,
nonceForApprove + 1,
depositTokenFixedGasEstimation,
gasEstimationForApprove.gasPrice,
)
Expand Down

0 comments on commit bd308f6

Please sign in to comment.