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

TypeError: c is not a constructor #152

Open
vgagaleski opened this issue Dec 21, 2019 · 0 comments
Open

TypeError: c is not a constructor #152

vgagaleski opened this issue Dec 21, 2019 · 0 comments

Comments

@vgagaleski
Copy link

vgagaleski commented Dec 21, 2019

I am trying to connect eosjs and scatter with the following code, but I am getting TypeError: c is not a constructor.

const fetch = require('node-fetch');
const Api = require('eosjs');
const { JsonRpc } = require('eosjs');
const ScatterJS = require('scatterjs-core').default;
const ScatterEOS = require('scatterjs-plugin-eosjs2').default;

ScatterJS.plugins(new ScatterEOS());

const { scatter } = ScatterJS;
const EOS_NETWORK_INFO = {
  blockchain: 'eos',
  protocol: 'http',
  host: 'http://127.0.0.1',
  port: 8888,
  chainId: 'cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f',
};
const rpc = new JsonRpc('http://127.0.0.1:8888', { fetch });
console.log(typeof Api); // returns Object
const eos = scatter.eos(EOS_NETWORK_INFO, Api, { rpc });
module.exports = eos;

According to the console, it fails in this call:

return proxy(new c(Object.assign(d, {
    signatureProvider: g
})), {
    get: function c(a, b) {
        return function() {
            if ("undefined" == typeof a[b]) throw new Error("".concat(b, " does not exist on the eosjs.Api() object."));
            for (var c = arguments.length, d = Array(c), f = 0; f < c; f++) d[f] = arguments[f];
            var g = d.find(function(a) {
                return a.hasOwnProperty("requiredFields")
            });
            return e = g ? g.requiredFields : {}, a[b].apply(a, d)
        }
    }
}); // Proxy

I checked the source code and on that line it expects _api constructor.
Any ideas how can I solve this issue or what am I doing wrong? I have similar implementation with JavaScript in ReactJS and it works without any errors. My idea is to make a sort of blockchain API and therefore I need Scatter for signing the user transactions.

Thanks!

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

1 participant