add contract.new.getData

This commit is contained in:
Fabian Vogelsteller 2015-10-30 12:52:51 +01:00
parent 02506d22d6
commit 29e3efb8d8
6 changed files with 77 additions and 11 deletions

22
dist/web3-light.js vendored
View File

@ -2874,6 +2874,8 @@ var checkForContractAddress = function(contract, callback){
var ContractFactory = function (eth, abi) { var ContractFactory = function (eth, abi) {
this.eth = eth; this.eth = eth;
this.abi = abi; this.abi = abi;
this.new.getData = this.getData.bind(this);
}; };
/** /**
@ -2966,6 +2968,26 @@ ContractFactory.prototype.at = function (address, callback) {
return contract; return contract;
}; };
/**
* Gets the data, which is data to deploy plus constructor params
*
* @method getData
*/
ContractFactory.prototype.getData = function () {
var options = {}; // required!
var args = Array.prototype.slice.call(arguments);
var last = args[args.length - 1];
if (utils.isObject(last) && !utils.isArray(last)) {
options = args.pop();
}
var bytes = encodeConstructorParams(this.abi, args);
options.data += bytes;
return options.data;
};
/** /**
* Should be called to create new contract instance * Should be called to create new contract instance
* *

File diff suppressed because one or more lines are too long

22
dist/web3.js vendored
View File

@ -2874,6 +2874,8 @@ var checkForContractAddress = function(contract, callback){
var ContractFactory = function (eth, abi) { var ContractFactory = function (eth, abi) {
this.eth = eth; this.eth = eth;
this.abi = abi; this.abi = abi;
this.new.getData = this.getData.bind(this);
}; };
/** /**
@ -2966,6 +2968,26 @@ ContractFactory.prototype.at = function (address, callback) {
return contract; return contract;
}; };
/**
* Gets the data, which is data to deploy plus constructor params
*
* @method getData
*/
ContractFactory.prototype.getData = function () {
var options = {}; // required!
var args = Array.prototype.slice.call(arguments);
var last = args[args.length - 1];
if (utils.isObject(last) && !utils.isArray(last)) {
options = args.pop();
}
var bytes = encodeConstructorParams(this.abi, args);
options.data += bytes;
return options.data;
};
/** /**
* Should be called to create new contract instance * Should be called to create new contract instance
* *

4
dist/web3.js.map vendored

File diff suppressed because one or more lines are too long

10
dist/web3.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -165,6 +165,8 @@ var checkForContractAddress = function(contract, callback){
var ContractFactory = function (eth, abi) { var ContractFactory = function (eth, abi) {
this.eth = eth; this.eth = eth;
this.abi = abi; this.abi = abi;
this.new.getData = this.getData.bind(this);
}; };
/** /**
@ -257,6 +259,26 @@ ContractFactory.prototype.at = function (address, callback) {
return contract; return contract;
}; };
/**
* Gets the data, which is data to deploy plus constructor params
*
* @method getData
*/
ContractFactory.prototype.getData = function () {
var options = {}; // required!
var args = Array.prototype.slice.call(arguments);
var last = args[args.length - 1];
if (utils.isObject(last) && !utils.isArray(last)) {
options = args.pop();
}
var bytes = encodeConstructorParams(this.abi, args);
options.data += bytes;
return options.data;
};
/** /**
* Should be called to create new contract instance * Should be called to create new contract instance
* *