bitpay / bitcore-lib

A pure and powerful JavaScript Bitcoin library
https://bitcore.io/
Other
611 stars 1.03k forks source link

remove unecessary version guard #187

Closed Firescar96 closed 6 years ago

Firescar96 commented 6 years ago

This guard is making it impossible for developers to use this library without various hacks. I've seen a few complaints about it as well as hacky solutions to bypass it.

https://github.com/bitpay/bitcore-lib/search?q=versionGuard&type=Issues&utf8=✓ https://stackoverflow.com/questions/46315459/bitcore-more-than-one-instance-of-bitcore-lib-found https://forum.bitcore.io/t/more-than-one-instance-of-bitcore-lib-found/699 https://stackoverflow.com/questions/45217988/error-more-than-one-instance-of-library-found https://bitcoin.stackexchange.com/questions/46795/bitcore-error-more-than-one-instance-of-bitcore-lib-found https://stackoverflow.com/questions/47010584/nodejs-eth-lightwallet-doesnt-allow-different-bitcore-lib-versions-among-submod https://forum.bitcore.io/t/error-more-than-one-instance-of-bitcore-lib-found-please-make-sure-to-require-bitcore-lib-and-check-that-submodules-do-not-also-include-their-own-bitcore-lib-dependency/1612

Some of these issues were even marked as high priority, before being closed with the resolution as a hacky solution:

https://github.com/bitpay/bitcore/issues/1454 https://github.com/bitpay/bitcore/issues/1484 https://github.com/bitpay/bitcore/issues/1328 https://github.com/bitpay/bitcore/issues/1366 https://github.com/bitpay/bitcore/issues/1486 https://github.com/bitpay/bitcore/issues/1453 https://github.com/bitpay/bitcore/issues/1454 https://github.com/bitpay/bitcore/issues/1457 https://github.com/bitpay/bitcore/issues/1232 https://github.com/bitpay/bitcore/pull/1303 https://github.com/bitpay/bitcore/issues/1144

https://github.com/bitpay/bitcore-lib/issues/153 https://github.com/bitpay/bitcore-lib/issues/67 https://github.com/bitpay/bitcore/issues/1366 https://github.com/bitpay/bitcore/issues/1232 https://github.com/bitpay/bitcore/issues/1457 https://github.com/bitpay/bitcore-mnemonic/pull/26 https://github.com/bitpay/bitcore-mnemonic/issues/58 https://github.com/bitpay/i-made-this/issues/15 https://github.com/bitpay/bitcore-wallet-service/issues/643

People are just using delete global._bitcore or other hacks so this code is doing more harm than good.

Firescar96 commented 6 years ago

@matiu all the tests pass, are there other errors caused by deleting this code?

fanatid commented 6 years ago

@Firescar96 you can not just remove version guard without any other changes. You need remove all instanceof calls (nearly 50 calls in lib) first.

Firescar96 commented 6 years ago

I'm not sure what the version guard has to do with calls to instanceof. Calls like these? https://github.com/bitpay/bitcore-lib/blob/484683f854ad8bcac8a5b0e197d5704f80ebdae6/lib/crypto/ecdsa.js https://github.com/bitpay/bitcore-lib/blob/ed026854b27b4554ac52a44743972a7b82d97f5d/test/hdpublickey.js#L122

fanatid commented 6 years ago

@Firescar96 please check https://github.com/bitpay/bitcore/issues/1164 https://github.com/bitpay/bitcore/pull/1165

Firescar96 commented 6 years ago

I see. Another suggestion I saw was to make bitcore-lib a peer dependency. Looking at the releases NPM has supported peer dependencies for a couple years.

Would a solution be to do this for all of bitpay's other libraries, bitcore, bitcore-mnemonic, etc?

Firescar96 commented 6 years ago

closing this, https://github.com/bitpay/bitcore-mnemonic/pull/61 is a replacement