Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

web3-eth-contract

Package Overview
Dependencies
Maintainers
1
Versions
479
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

web3-eth-contract - npm Package Compare versions

Comparing version 1.0.0-beta.11 to 1.0.0-beta.12

15

package.json
{
"name": "web3-eth-contract",
"version": "1.0.0-beta.11",
"version": "1.0.0-beta.12",
"description": "Web3 module to interact with Ethereum smart contracts.",

@@ -10,9 +10,10 @@ "repository": "https://github.com/ethereum/web3.js/tree/master/packages/web3-eth-contract",

"underscore": "1.8.3",
"web3-core-helpers": "^1.0.0-beta.11",
"web3-core-method": "^1.0.0-beta.11",
"web3-core-promievent": "^1.0.0-beta.11",
"web3-core-subscriptions": "^1.0.0-beta.11",
"web3-eth-abi": "^1.0.0-beta.11",
"web3-utils": "^1.0.0-beta.11"
"web3-core": "^1.0.0-beta.12",
"web3-core-helpers": "^1.0.0-beta.12",
"web3-core-method": "^1.0.0-beta.12",
"web3-core-promievent": "^1.0.0-beta.12",
"web3-core-subscriptions": "^1.0.0-beta.12",
"web3-eth-abi": "^1.0.0-beta.12",
"web3-utils": "^1.0.0-beta.12"
}
}

@@ -32,13 +32,10 @@ # web3-eth-contract

// in node.js
var Eth = require('web3-eth');
var Web3EthContract = require('web3-eth-contract');
var eth = new Eth('ws://localhost:8546');
// set provider for all later instances to use
Web3EthContract.setProvider('ws://localhost:8546');
// add the eth package
Web3EthContract.prototype._eth = this;
var contract = new Web3EthContract(jsonInterface, address);
contract.methods.somFunc().send({from: ....})
.on('receipt', funciton(){
.on('receipt', function(){
...

@@ -45,0 +42,0 @@ });

@@ -23,6 +23,6 @@ /*

* var Contract = require('web3-eth-contract');
* Contract.prototype._eth = needsAEthInstance;
* Contract.setProvider('ws://localhost:8546');
* var contract = new Contract(abi, address, ...);
*
* @author Fabian Vogelsteller <fabian@frozeman.de>
* @author Fabian Vogelsteller <fabian@ethereum.org>
* @date 2017

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

var _ = require('underscore');
var core = require('web3-core');
var Method = require('web3-core-method');

@@ -59,2 +60,9 @@ var utils = require('web3-utils');

// sets _requestmanager
core.packageInit(this, [Contract.currentProvider]);
this.clearSubscriptions = this._requestManager.clearSubscriptions;
if(!(this instanceof Contract)) {

@@ -68,3 +76,33 @@ throw new Error('Please use the "new" keyword to instantiate a web3.eth.contract() object!');

// add custom send Methods
var _ethereumCall = [
new Method({
name: 'estimateGas',
call: 'eth_estimateGas',
params: 1,
inputFormatter: [formatters.inputCallFormatter],
outputFormatter: utils.hexToNumber
}),
new Method({
name: 'call',
call: 'eth_call',
params: 2,
inputFormatter: [formatters.inputCallFormatter, formatters.inputDefaultBlockNumberFormatter]
}),
new Method({
name: 'sendTransaction',
call: 'eth_sendTransaction',
params: 1,
inputFormatter: [formatters.inputTransactionFormatter]
})
];
// attach methods to this._ethereumCall
this._ethereumCall = {};
_.each(_ethereumCall, function (method) {
method.attachToObject(_this._ethereumCall);
method.setRequestManager(_this._requestManager, Contract._ethAccounts); // second param means is eth.accounts (necessary for wallet signing)
});
// create the options object

@@ -175,3 +213,6 @@ this.options = {};

Contract.prototype._eth = {}; // eth is attached here in web3-eth/src/index.js
Contract.setProvider = function(provider, accounts) {
Contract.currentProvider = provider;
Contract._ethAccounts = accounts;
};

@@ -187,3 +228,3 @@

Contract.prototype._getCallback = function getCallback(args) {
if (_.isFunction(args[args.length - 1])) {
if (args && _.isFunction(args[args.length - 1])) {
return args.pop(); // modify the args array!

@@ -355,3 +396,3 @@ }

var methodSignature = this._method.signature,
args = this.arguments;
args = this.arguments || [];

@@ -363,7 +404,9 @@ var signature = false,

}).map(function (json) {
if(json.inputs.length !== args.length) {
throw new Error('The number of arguments is not matching the methods required number. You need to pass '+ json.inputs.length +' arguments.');
var inputLength = (_.isArray(json.inputs)) ? json.inputs.length : 0;
if (inputLength !== args.length) {
throw new Error('The number of arguments is not matching the methods required number. You need to pass '+ inputLength +' arguments.');
}
if(json.type === 'function') {
if (json.type === 'function') {
signature = json.signature;

@@ -586,3 +629,3 @@ }

type: 'eth',
requestManager: this._eth._requestManager
requestManager: this._requestManager
});

@@ -613,3 +656,3 @@ subscription.subscribe('logs', subOptions.params, subOptions.callback || function () {});

});
getPastLogs.setRequestManager(this._eth._requestManager);
getPastLogs.setRequestManager(this._requestManager);
var call = getPastLogs.buildCall();

@@ -630,2 +673,3 @@

Contract.prototype._createTxObject = function _createTxObject(){
var args = Array.prototype.slice.call(arguments);
var txObject = {};

@@ -645,15 +689,14 @@

if (arguments.length) {
if (arguments.length !== this.method.inputs.length) {
throw errors.InvalidNumberOfParams(arguments.length, this.method.inputs.length, this.method.name);
}
if (args.length !== this.method.inputs.length) {
throw errors.InvalidNumberOfParams(args.length, this.method.inputs.length, this.method.name);
}
txObject.arguments = arguments;
}
txObject.arguments = args;
txObject._method = this.method;
txObject._parent = this.parent;
if(this.deployData)
if(this.deployData) {
txObject._deployData = this.deployData;
}

@@ -741,3 +784,3 @@ return txObject;

return this._parent._eth.estimateGas(args.options, args.callback);
return this._parent._ethereumCall.estimateGas(args.options, args.callback);

@@ -748,22 +791,12 @@ case 'call':

this._parent._eth.call(args.options, args.defaultBlock, function (err, result) {
// decode result
// add output formatter for decoding
this._parent._ethereumCall.call.method.outputFormatter = function (result) {
if(result) {
result = _this._parent._decodeMethodReturn(_this._method.outputs, result);
}
return result;
};
// throw error
if(err) {
return utils._fireError(err, null, defer.reject, args.callback);
}
return this._parent._ethereumCall.call(args.options, args.defaultBlock, args.callback);
if(_.isFunction(args.callback)) {
args.callback(null, result);
}
defer.resolve(result);
});
return defer.eventEmitter;
case 'send':

@@ -817,3 +850,3 @@

return this._parent._eth.sendTransaction.apply(extraFormatters, [args.options, args.callback]);
return this._parent._ethereumCall.sendTransaction.apply(extraFormatters, [args.options, args.callback]);

@@ -820,0 +853,0 @@ }

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc