Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parseNumber does not properly anticipate BigNumber ... still? #56

Closed
MeoMix opened this issue Nov 9, 2017 · 0 comments
Closed

parseNumber does not properly anticipate BigNumber ... still? #56

MeoMix opened this issue Nov 9, 2017 · 0 comments

Comments

@MeoMix
Copy link

MeoMix commented Nov 9, 2017

Hey there,

I tried to pack an object which stored values as BigNumber. This failed.

function parseNumber (arg) {
  var type = typeof arg
  if (type === 'string') {
    if (utils.isHexPrefixed(arg)) {
      return new BN(utils.stripHexPrefix(arg), 16)
    } else {
      return new BN(arg, 10)
    }
  } else if (type === 'number') {
    return new BN(arg)
  } else if (arg.toArray) {
    // assume this is a BN for the moment, replace with BN.isBN soon
    return arg
  } else {
    throw new Error('Argument is not a number')
  }
}

Looks like there is some code which tries to guess for BN, but fails to do so properly.

Any intent on fixing this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants