Socket
Socket
Sign inDemoInstall

web3-core-method

Package Overview
Dependencies
25
Maintainers
1
Versions
137
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0-beta.21 to 1.0.0-beta.22

10

package.json
{
"name": "web3-core-method",
"namespace": "ethereum",
"version": "1.0.0-beta.21",
"version": "1.0.0-beta.22",
"description": "Creates the methods on the web3 modules. This is an internal package.",

@@ -11,7 +11,7 @@ "repository": "https://github.com/ethereum/web3.js/tree/master/packages/web3-core-method",

"underscore": "1.8.3",
"web3-core-helpers": "^1.0.0-beta.21",
"web3-core-promievent": "^1.0.0-beta.21",
"web3-core-subscriptions": "^1.0.0-beta.21",
"web3-utils": "^1.0.0-beta.21"
"web3-core-helpers": "^1.0.0-beta.22",
"web3-core-promievent": "^1.0.0-beta.22",
"web3-core-subscriptions": "^1.0.0-beta.22",
"web3-utils": "^1.0.0-beta.22"
}
}

@@ -48,2 +48,3 @@ /*

this.transformPayload = options.transformPayload;
this.extraFormatters = options.extraFormatters;

@@ -60,3 +61,2 @@ this.requestManager = options.requestManager;

Method.prototype.setRequestManager = function (requestManager, accounts) {
var _this = this;
this.requestManager = requestManager;

@@ -69,42 +69,25 @@

// add custom send Methods
var _ethereumCall = [
new Method({
name: 'getTransactionReceipt',
call: 'eth_getTransactionReceipt',
params: 1,
inputFormatter: [null],
outputFormatter: formatters.outputTransactionReceiptFormatter
}),
new Method({
name: 'getCode',
call: 'eth_getCode',
params: 2,
inputFormatter: [formatters.inputAddressFormatter, formatters.inputDefaultBlockNumberFormatter]
}),
new Method({
name: 'getGasPrice',
call: 'eth_gasPrice',
params: 0
}),
new Subscriptions({
name: 'subscribe',
type: 'eth',
subscriptions: {
'newBlockHeaders': {
subscriptionName: 'newHeads', // replace subscription with this name
params: 0,
outputFormatter: formatters.outputBlockFormatter
}
}
})
];
// attach methods to this._ethereumCall
this._ethereumCall = {};
_.each(_ethereumCall, function (method) {
method.attachToObject(_this._ethereumCall);
method.requestManager = _this.requestManager; // assign rather than call setRequestManager()
});
};
Method.prototype.createFunction = function (requestManager, accounts) {
var func = this.buildCall();
func.call = this.call;
this.setRequestManager(requestManager || this.requestManager, accounts || this.accounts);
return func;
};
Method.prototype.attachToObject = function (obj) {
var func = this.buildCall();
func.call = this.call;
var name = this.name.split('.');
if (name.length > 1) {
obj[name[0]] = obj[name[0]] || {};
obj[name[0]][name[1]] = func;
} else {
obj[name[0]] = func;
}
};
/**

@@ -212,15 +195,4 @@ * Should be used to determine name of the jsonrpc method based on arguments

Method.prototype.attachToObject = function (obj) {
var func = this.buildCall();
func.call = this.call; // TODO!!! that's ugly. filter.js uses it
var name = this.name.split('.');
if (name.length > 1) {
obj[name[0]] = obj[name[0]] || {};
obj[name[0]][name[1]] = func;
} else {
obj[name[0]] = func;
}
};
Method.prototype._confirmTransaction = function (defer, result, payload, extraFormatters) {
Method.prototype._confirmTransaction = function (defer, result, payload) {
var method = this,

@@ -239,2 +211,37 @@ promiseResolved = false,

// add custom send Methods
var _ethereumCalls = [
new Method({
name: 'getTransactionReceipt',
call: 'eth_getTransactionReceipt',
params: 1,
inputFormatter: [null],
outputFormatter: formatters.outputTransactionReceiptFormatter
}),
new Method({
name: 'getCode',
call: 'eth_getCode',
params: 2,
inputFormatter: [formatters.inputAddressFormatter, formatters.inputDefaultBlockNumberFormatter]
}),
new Subscriptions({
name: 'subscribe',
type: 'eth',
subscriptions: {
'newBlockHeaders': {
subscriptionName: 'newHeads', // replace subscription with this name
params: 0,
outputFormatter: formatters.outputBlockFormatter
}
}
})
];
// attach methods to this._ethereumCall
var _ethereumCall = {};
_.each(_ethereumCalls, function (mthd) {
mthd.attachToObject(_ethereumCall);
mthd.requestManager = method.requestManager; // assign rather than call setRequestManager()
});
// fire "receipt" and confirmation events and resolve after

@@ -252,3 +259,3 @@ var checkConfirmation = function (err, blockHeader, sub, existingReceipt) {

// if we have a valid receipt we don't need to send a request
return (existingReceipt ? promiEvent.resolve(existingReceipt) : method._ethereumCall.getTransactionReceipt(result))
return (existingReceipt ? promiEvent.resolve(existingReceipt) : _ethereumCall.getTransactionReceipt(result))
// catch error from requesting receipt

@@ -264,8 +271,8 @@ .catch(function (err) {

if (!receipt || !receipt.blockHash) {
throw new Error('Receipt is "null"');
throw new Error('Receipt missing or blockHash null');
}
// apply extra formatters
if (extraFormatters && extraFormatters.receiptFormatter) {
receipt = extraFormatters.receiptFormatter(receipt);
if (method.extraFormatters && method.extraFormatters.receiptFormatter) {
receipt = method.extraFormatters.receiptFormatter(receipt);
}

@@ -304,3 +311,3 @@

method._ethereumCall.getCode(receipt.contractAddress, function (e, code) {
_ethereumCall.getCode(receipt.contractAddress, function (e, code) {

@@ -316,4 +323,4 @@ if (!code) {

// if contract, return instance instead of receipt
if (extraFormatters && extraFormatters.contractDeployFormatter) {
defer.resolve(extraFormatters.contractDeployFormatter(receipt));
if (method.extraFormatters && method.extraFormatters.contractDeployFormatter) {
defer.resolve(method.extraFormatters.contractDeployFormatter(receipt));
} else {

@@ -393,3 +400,3 @@ defer.resolve(receipt);

if (_.isFunction(this.requestManager.provider.on)) {
method._ethereumCall.subscribe('newBlockHeaders', checkConfirmation);
_ethereumCall.subscribe('newBlockHeaders', checkConfirmation);
} else {

@@ -400,4 +407,5 @@ intervalId = setInterval(checkConfirmation, 1000);

// first check if we already have a confirmed transaction
method._ethereumCall.getTransactionReceipt(result)
_ethereumCall.getTransactionReceipt(result)
.then(function(receipt) {

@@ -449,3 +457,2 @@ if (receipt && receipt.blockHash) {

var send = function () {
var extraFormatters = this;
var defer = promiEvent(!isSendTx),

@@ -491,3 +498,3 @@ payload = method.toPayload(Array.prototype.slice.call(arguments));

method._confirmTransaction(defer, result, payload, extraFormatters);
method._confirmTransaction(defer, result, payload);
}

@@ -554,4 +561,10 @@

method._ethereumCall.getGasPrice(function (err, gasPrice) {
var getGasPrice = (new Method({
name: 'getGasPrice',
call: 'eth_gasPrice',
params: 0
})).createFunction(method.requestManager);
getGasPrice(function (err, gasPrice) {
if (gasPrice) {

@@ -558,0 +571,0 @@ payload.params[0].gasPrice = gasPrice;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc