0xProject / 0x-monorepo

0x protocol monorepo - includes our smart contracts and many developer tools
Other
1.41k stars 467 forks source link

order.takerTokenAmount.eq is not a function #912

Closed rhrahul closed 6 years ago

rhrahul commented 6 years ago

Expected Behavior

I am using,

zeroEx.exchange.cancelOrderAsync(
      signedOrderToCancel,
      new BigNumber(AmountToCancel)
);

And I am keep getting this error,

Uncaught (in promise) TypeError: order.takerTokenAmount.eq is not a function
    at Function../node_modules/@0xproject/contract-wrappers/lib/src/utils/order_validation_utils.js.OrderValidationUtils.validateCancelOrderThrowIfInvalid

Current Behavior

I am keep getting this error,

Uncaught (in promise) TypeError: order.takerTokenAmount.eq is not a function
    at Function../node_modules/@0xproject/contract-wrappers/lib/src/utils/order_validation_utils.js.OrderValidationUtils.validateCancelOrderThrowIfInvalid

Your Environment

Package Version
0x.js 0.38.6
Exchange Contract v1
Network
mainnet
rhrahul commented 6 years ago

Also getting this error in fillOrderAsync Funciton.

zeroEx.exchange.fillOrderAsync(
            signedOrder,
            ZeroEx.toBaseUnitAmount(
              new BigNumber(Amount),
              Decimals
            ),
            true,
            TakerAccount
);

output :

Uncaught (in promise) TypeError: takerTokenAmount.eq is not a function
    at Function../node_modules/@0xproject/contract-wrappers/lib/src/utils/order_validation_utils.js.OrderValidationUtils._validateRemainingFillAmountNotZeroOrThrow
dekz commented 6 years ago

@rhrahul make sure the amount fields in signedOrder are BigNumbers. Can you show how signedOrder is constructed?

rhrahul commented 6 years ago

Yes, I changed type to BigNumber and it worked. Thanks

One more thing, can you suggest me how can I set manual transaction options, Like set gas fees manually in function calling, for example,

zeroEx.exchange.fillOrderAsync(
            signedOrder,
            ZeroEx.toBaseUnitAmount(
              new BigNumber(Amount),
              Decimals
            ),
            true,
            TakerAccount,
            {GASPRICE, GASLIMIT}
);

Any suggestion on how to do that ?

dekz commented 6 years ago

All of those functions take a OrderTransactionOpts argument.

zeroEx.exchange.fillOrderAsync(
            signedOrder,
            ZeroEx.toBaseUnitAmount(
              new BigNumber(Amount),
              Decimals
            ),
            true,
            TakerAccount,
            {gasPrice: GASPRICE, gasLimit: GASLIMIT}
);
rhrahul commented 6 years ago

Ok, Thanks 👍

rhrahul commented 6 years ago

@dekz Any Suggestions on this ? https://github.com/0xProject/0x-monorepo/issues/922