Skip to content

Stop monkey patching bn.js #125

@paddyquinn

Description

@paddyquinn

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions