uport-project / mnid

Multi Network Identifier - spec and reference implementation
36 stars 6 forks source link

[BUG] MNID object is undefined using ES6/Webpack import #6

Open kamescg opened 6 years ago

kamescg commented 6 years ago

When the mnid object imported from the dependency I get undefined.

import mnid, {decode} from 'mnid'
console.log(mnid)
console.log(decode)

*console output*

undefined
ƒ decode(encoded) {
  var data = _buffer.Buffer.from(base58.decode(encoded));
  var netLength = data.length - 24;
  var version = data.slice(0, 1);
  var network = data.slice(1, netLength);
  var addre…

I presume this is just a Webpack/ES6 import bug for bundling (personally I don't feel digging in)? To be safe would it make sense to add export default object exporting the functions?

export default {
 checksum,
 encode,
 decode,
 isMNID
}
microchipgnu commented 6 years ago

I've tried to use mnid.decode and it logs undefined too. I tried to add export default, but it didn't solve the problem. I used Truffle uPort boilerplate.