Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
__embarkWhisperNewWeb3.setProvider = function(options) {
const self = this;
let endpoint;
if (options === undefined) {
endpoint = "localhost:8546";
} else {
endpoint = options.server + ':' + options.port;
}
// TODO: take into account type
const provider = new Web3.providers.WebsocketProvider("ws://" + endpoint, options.providerOptions);
self.web3 = new Web3(provider);
self.requestManager = new Manager(provider);
self.web3.currentProvider.on('connect', () => {
self.getWhisperVersion(function(err, version) {
if (err) {
console.log("whisper not available");
} else if (version >= 5) {
self.web3.shh.newSymKey().then((id) => {
self.symKeyID = id;
});
self.web3.shh.newKeyPair().then((id) => {
self.sig = id;
});
} else {
throw new Error("version of whisper not supported");
}
self.whisperVersion = self.web3.version.whisper;
__embarkWhisperNewWeb3.setProvider = function(options) {
const self = this;
let endpoint;
if (options === undefined) {
endpoint = "localhost:8546";
} else {
endpoint = options.server + ':' + options.port;
}
// TODO: take into account type
const provider = new Web3.providers.WebsocketProvider("ws://" + endpoint, options.providerOptions);
self.web3 = new Web3(provider);
self.requestManager = new Manager(provider);
self.web3.currentProvider.on('connect', () => {
self.getWhisperVersion(function(err, version) {
if (err) {
console.log("whisper not available");
} else if (version >= 5) {
self.web3.shh.newSymKey().then((id) => {
self.symKeyID = id;
});
self.web3.shh.newKeyPair().then((id) => {
self.sig = id;
});
} else {
throw new Error("version of whisper not supported");
}
self.whisperVersion = self.web3.version.whisper;
return pkg._provider;
},
set: function (value) {
return pkg.setProvider(value);
},
enumerable: true,
configurable: true
});
// inherit from web3 umbrella package
if (args[0] && args[0]._requestManager) {
pkg._requestManager = new requestManager.Manager(args[0].currentProvider);
// set requestmanager on package
} else {
pkg._requestManager = new requestManager.Manager();
pkg._requestManager.setProvider(args[0], args[1]);
}
// add givenProvider
pkg.givenProvider = requestManager.Manager.givenProvider;
pkg.providers = requestManager.Manager.providers;
pkg._provider = pkg._requestManager.provider;
// add SETPROVIDER function (don't overwrite if already existing)
if (!pkg.setProvider) {
pkg.setProvider = function (provider, net) {
pkg._requestManager.setProvider(provider, net);
pkg._provider = pkg._requestManager.provider;
return true;
};
pkg.givenProvider = requestManager.Manager.givenProvider;
pkg.providers = requestManager.Manager.providers;
pkg._provider = pkg._requestManager.provider;
// add SETPROVIDER function (don't overwrite if already existing)
if (!pkg.setProvider) {
pkg.setProvider = function (provider, net) {
pkg._requestManager.setProvider(provider, net);
pkg._provider = pkg._requestManager.provider;
return true;
};
}
// attach batch request creation
pkg.BatchRequest = requestManager.BatchManager.bind(null, pkg._requestManager);
// attach extend function
pkg.extend = extend(pkg);
},
addProviders: function (pkg) {
_createWeb3RequestManager(provider) {
return new Web3RequestManager.Manager(provider);
}
constructor() {
return new Web3RequestManager(this);
}
send(payload, callback) {
} else if (host.includes('ropsten')) {
this.query = 'ropsten';
} else if (host.includes('kovan')) {
this.query = 'kovan';
} else if (host.includes('poa')) {
this.query = 'poa';
} else if (host.includes('goerli')) {
this.query = 'goerli';
}
this.network = networks.find(o => o[this.query])[this.query];
this.provider = new PocketProvider(
this.network.ticker,
this.network.netid,
devid
);
return new Web3RequestManager(this);
}
send(payload, callback) {
constructor(embark, web3, blockchainName) {
this.embark = embark;
this.blockchainName = blockchainName;
this.web3 = web3;
this.requestManager = new Manager(web3.currentProvider);
this.fs = embark.fs;
this.logFile = dappPath(".embark", "contractEvents.json");
}
constructor(host, options, store, eventHub) {
this.givenProvider = Object.assign({}, host);
const requestManager = new Web3RequestManager(host);
options = options ? options : null;
if (this.givenProvider.sendAsync) {
this.givenProvider.send = this.givenProvider.sendAsync;
delete this.givenProvider.sendAsync;
}
this.givenProvider.send_ = this.givenProvider.send;
delete this.givenProvider.send;
this.givenProvider.send = (payload, callback) => {
const req = {
payload,
store,
requestManager,
eventHub
};
const middleware = new MiddleWare();
middleware.use(ethSendTransaction);