Skip to content
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.

Circular dependency on React-Native #184

Open
Kamahl19 opened this issue Dec 22, 2017 · 2 comments
Open

Circular dependency on React-Native #184

Kamahl19 opened this issue Dec 22, 2017 · 2 comments

Comments

@Kamahl19
Copy link

Kamahl19 commented Dec 22, 2017

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!

@Kamahl19 Kamahl19 changed the title Possible cyclical dependency on React-Native Possible circular dependency on React-Native Dec 22, 2017
@Kamahl19
Copy link
Author

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 Kamahl19 changed the title Possible circular dependency on React-Native Circular dependency on React-Native Jan 4, 2018
@JoyHou
Copy link

JoyHou commented Jun 9, 2018

@Kamahl19 Man you're awesome!

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

No branches or pull requests

3 participants
@Kamahl19 @JoyHou and others