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

Stop monkey patching bn.js #125

Open
paddyquinn opened this issue May 16, 2019 · 3 comments
Open

Stop monkey patching bn.js #125

paddyquinn opened this issue May 16, 2019 · 3 comments

Comments

@paddyquinn
Copy link

In the bn.js file within dashcore-lib, the bn.js npm module is brought into scope. Note that bn.js here refers to two different things, the file within this lib and the module published to npm. The file pulls in the module and then overrides some methods from the module (aka monkey patching). This can cause unexpected and hard to find errors when using dashcore-lib. For example, I have a repository that uses ethereumjs-abi, which pulls in the bn.js npm module. Pulling dashcore-lib into that repository started breaking ethereum functionality because the BN.prototype.toBuffer had been dynamically overridden by dashcore-lib. This is a frustrating developer experience as a user of dashcore-lib and I don't see a good reason why the library is built this way.

@antouhou
Copy link
Collaborator

antouhou commented May 17, 2019

That's a great catch! We should also notify @bitpay on the issue, since it's a fork of their lib: https://github.com/bitpay/bitcore/blob/v8.0.0/packages/bitcore-lib/lib/crypto/bn.js

@paddyquinn
Copy link
Author

@antouhou I just submitted an issue with @bitpay here.

@dashameter
Copy link

The bug has not been fixed upstream yet, also an additional concern has been raised there: bitpay/bitcore#2190 (comment)

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

No branches or pull requests

3 participants