scatter-js
scatter-js copied to clipboard
TypeError: c is not a constructor
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!