bitcore-lib
bitcore-lib copied to clipboard
Circular dependency on React-Native
Hi,
I am using bitcore-wallet-client on react native, polyfilling all nodejs dependencies with node-libs-browser
. Creating a wallet and generating an address works fine, however I am unable to publish a transaction proposal.
This is an error I am getting.
ExceptionsManager.js:73 TypeError: Right-hand side of 'instanceof' is not callable
at new Script (script.js:35)
at new UnspentOutput (unspentoutput.js:46)
at Transaction._fromNonP2SH (transaction.js:561)
at Transaction.from (transaction.js:554)
at transaction.js:540
at arrayEach (lodash.js:537)
at Function.forEach (lodash.js:9359)
at Transaction.from (transaction.js:539)
at Function.Utils.buildTx (utils.js:196)
at API.publishTxProposal (api.js:1773)
On this line https://github.com/bitpay/bitcore-lib/blob/master/lib/script/script.js#L35 else if (from instanceof Address)
Address is just an empty object so instanceof fails. It seems to me like a circular dependency, or am I wrong?
It would be awesome if bitcore could run on RN. Bitcoinjs-lib already works there but I would like to stick with bitcore. Thanks!
When I change Script function and require address there, it resolves properly
Original code:
var Address = require('../address');
My code:
var Address;
var Script = function Script(from) {
Address = require('../address');
// Rest of the code..
};
This is definitely not a solution, there is a circular issue somewhere but its quite difficult for me as an outsider to find it.
@Kamahl19 Man you're awesome!