netgum / archanova

Archanova monorepo
https://archanova.io/
19 stars 11 forks source link

Error when estimating topup virtual balance #72

Closed pedrouid closed 4 years ago

pedrouid commented 4 years ago

On Rinkeby, using the playground with the account address 0x2AC21C80e9bA7f8FB21e18086D439ccdc9DE823A, I'm getting an error saying Assertion failed when estimating topup virtual balance.

This only happens when a tokenAddress is passed and not with ETH.

Example code

const value = 20000000000000000000;
const tokenAddress = '0x3615757011112560521536258c1e7325ae3b48ae';

sdk
  .estimateTopUpAccountVirtualBalance(value, tokenAddress)
  .then(estimated => console.log('estimated', estimated))
  .catch(console.error);
pedrouid commented 4 years ago

Forgot to mention this happens with SDK outside the playground too. Using the latest version (v1.1.0)

stanislaw-glogowski commented 4 years ago

Can you try to use bn.js instead of number type?

const value = new BN('20000000000000000000', 10);
pedrouid commented 4 years ago

That worked. It also works if I pass the number as a string too.

The assertion failed issue comes from anyToBN method from the utils library which doesnt accept a number