Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
name: 'getChainTag',
call: 'eth_getChainTag',
params: 0,
}),
new web3.extend.Method({
name: 'getPastLogs',
call: 'eth_getLogs',
params: 1,
inputFormatter: [web3.extend.formatters.inputLogFormatter],
outputFormatter: web3.extend.formatters.outputLogFormatter,
}),
],
})
// subscriptions
const subs = new Subscriptions({
name: 'subscribe',
type: 'eth',
subscriptions: {
newBlockHeaders: {
subscriptionName: 'newHeads',
params: 1,
inputFormatter: [inputBlockFilterFormatter],
subscriptionHandler(subscriptionMsg: any) {
if (subscriptionMsg.error) {
this.emit('error', subscriptionMsg.error)
// web3-core-subscriptions/subscription sets a default value for this.callback
this.callback(subscriptionMsg.error, null, this)
} else {
const result = web3.extend.formatters.outputBlockFormatter(subscriptionMsg.data)
if (result.removed) {
this.emit('changed', result)
var _this = this;
// sets _requestmanager
core.packageInit(this, arguments);
// overwrite setProvider
var setProvider = this.setProvider;
this.setProvider = function () {
setProvider.apply(_this, arguments);
_this.net.setProvider.apply(_this, arguments);
};
this.net = new Net(this.currentProvider);
[
new Subscriptions({
name: 'subscribe',
type: 'shh',
subscriptions: {
'messages': {
params: 1
// inputFormatter: [formatters.inputPostFormatter],
// outputFormatter: formatters.outputPostFormatter
}
}
}),
new Method({
name: 'getVersion',
call: 'shh_version',
params: 0
}),
}),
new Method({
name: 'getWork',
call: 'eth_getWork',
params: 0
}),
new Method({
name: 'getPastLogs',
call: 'eth_getLogs',
params: 1,
inputFormatter: [formatter.inputLogFormatter],
outputFormatter: formatter.outputLogFormatter
}),
// subscriptions
new Subscriptions({
name: 'subscribe',
type: 'eth',
subscriptions: {
'newBlockHeaders': {
// TODO rename on RPC side?
subscriptionName: 'newHeads', // replace subscription with this name
params: 0,
outputFormatter: formatter.outputBlockFormatter
},
'pendingTransactions': {
subscriptionName: 'newPendingTransactions', // replace subscription with this name
params: 0
},
'logs': {
params: 1,
inputFormatter: [formatter.inputLogFormatter],
}),
new Method({
name: 'getWork',
call: 'eth_getWork',
params: 0
}),
new Method({
name: 'getPastLogs',
call: 'eth_getLogs',
params: 1,
inputFormatter: [formatter.inputLogFormatter],
outputFormatter: formatter.outputLogFormatter
}),
// subscriptions
new Subscriptions({
name: 'subscribe',
type: 'eth',
subscriptions: {
'newBlockHeaders': {
// TODO rename on RPC side?
subscriptionName: 'newHeads', // replace subscription with this name
params: 0,
outputFormatter: formatter.outputBlockFormatter
},
'pendingTransactions': {
subscriptionName: 'newPendingTransactions', // replace subscription with this name
params: 0
},
'logs': {
params: 1,
inputFormatter: [formatter.inputLogFormatter],
property: 'eth',
methods: [{
name: 'getBlock',
call: blockCall,
params: 2,
inputFormatter: [web3.extend.formatters.inputBlockNumberFormatter, function (val) {
return !!val;
}],
outputFormatter: quorumOutputBlockFormatter
}]
});
// Creating a modified 'newBlockHeaders' subscription to replace the output formatter in the case of Quorum
var Subscriptions = require('web3-core-subscriptions').subscriptions;
const patchedSub = new Subscriptions({
name: 'subscribe',
type: 'eth',
subscriptions: {
'newBlockHeaders': {
subscriptionName: 'newHeads',
params: 0,
outputFormatter: quorumOutputBlockFormatter
}
}
});
let _quorumSubObject = {};
patchedSub.setRequestManager(web3._requestManager);
patchedSub.attachToObject(_quorumSubObject);
}),
new Method({
name: 'getWork',
call: 'eth_getWork',
params: 0
}),
new Method({
name: 'getPastLogs',
call: 'eth_getLogs',
params: 1,
inputFormatter: [formatter.inputLogFormatter],
outputFormatter: formatter.outputLogFormatter
}),
// subscriptions
new Subscriptions({
name: 'subscribe',
type: 'eth',
subscriptions: {
'newBlockHeaders': {
// TODO rename on RPC side?
subscriptionName: 'newHeads', // replace subscription with this name
params: 0,
outputFormatter: formatter.outputBlockFormatter
},
'pendingTransactions': {
subscriptionName: 'newPendingTransactions', // replace subscription with this name
params: 0
},
'logs': {
params: 1,
inputFormatter: [formatter.inputLogFormatter],