mirror of https://github.com/status-im/web3.js.git
add contract.new.getData
This commit is contained in:
parent
02506d22d6
commit
29e3efb8d8
|
@ -2874,6 +2874,8 @@ var checkForContractAddress = function(contract, callback){
|
|||
var ContractFactory = function (eth, abi) {
|
||||
this.eth = eth;
|
||||
this.abi = abi;
|
||||
|
||||
this.new.getData = this.getData.bind(this);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -2966,6 +2968,26 @@ ContractFactory.prototype.at = function (address, callback) {
|
|||
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
|
||||
*
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -2874,6 +2874,8 @@ var checkForContractAddress = function(contract, callback){
|
|||
var ContractFactory = function (eth, abi) {
|
||||
this.eth = eth;
|
||||
this.abi = abi;
|
||||
|
||||
this.new.getData = this.getData.bind(this);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -2966,6 +2968,26 @@ ContractFactory.prototype.at = function (address, callback) {
|
|||
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
|
||||
*
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -165,6 +165,8 @@ var checkForContractAddress = function(contract, callback){
|
|||
var ContractFactory = function (eth, abi) {
|
||||
this.eth = eth;
|
||||
this.abi = abi;
|
||||
|
||||
this.new.getData = this.getData.bind(this);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -257,6 +259,26 @@ ContractFactory.prototype.at = function (address, callback) {
|
|||
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
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue