@@ -55,16 +55,16 @@ var Contract = function Contract(jsonInterface, address, options) {
55
55
var _this = this ,
56
56
args = Array . prototype . slice . call ( arguments ) ;
57
57
58
+ if ( ! ( this instanceof Contract ) ) {
59
+ throw new Error ( 'Please use the "new" keyword to instantiate a web3.eth.contract() object!' ) ;
60
+ }
58
61
59
62
// sets _requestmanager
60
- core . packageInit ( this , [ Contract . currentProvider ] ) ;
63
+ core . packageInit ( this , [ this . constructor . currentProvider ] ) ;
61
64
62
65
this . clearSubscriptions = this . _requestManager . clearSubscriptions ;
63
66
64
67
65
- if ( ! ( this instanceof Contract ) ) {
66
- throw new Error ( 'Please use the "new" keyword to instantiate a web3.eth.contract() object!' ) ;
67
- }
68
68
69
69
if ( ! jsonInterface || ! ( Array . isArray ( jsonInterface ) ) ) {
70
70
throw new Error ( 'You must provide the json interface of the contract when instantiating a contract object.' ) ;
@@ -173,8 +173,8 @@ var Contract = function Contract(jsonInterface, address, options) {
173
173
} ) ;
174
174
175
175
// get default account from the Class
176
- var defaultAccount = Contract . defaultAccount ;
177
- var defaultBlock = Contract . defaultBlock || 'latest' ;
176
+ var defaultAccount = this . constructor . defaultAccount ;
177
+ var defaultBlock = this . constructor . defaultBlock || 'latest' ;
178
178
179
179
Object . defineProperty ( this , 'defaultAccount' , {
180
180
get : function ( ) {
@@ -216,9 +216,9 @@ var Contract = function Contract(jsonInterface, address, options) {
216
216
217
217
Contract . setProvider = function ( provider , accounts ) {
218
218
// Contract.currentProvider = provider;
219
- core . packageInit ( Contract , [ provider ] ) ;
219
+ core . packageInit ( this , [ provider ] ) ;
220
220
221
- Contract . _ethAccounts = accounts ;
221
+ this . _ethAccounts = accounts ;
222
222
} ;
223
223
224
224
@@ -498,7 +498,8 @@ Contract.prototype.deploy = function(options, callback){
498
498
return this . _createTxObject . apply ( {
499
499
method : constructor ,
500
500
parent : this ,
501
- deployData : options . data
501
+ deployData : options . data ,
502
+ _ethAccounts : this . constructor . _ethAccounts
502
503
} , options . arguments ) ;
503
504
504
505
} ;
@@ -695,6 +696,7 @@ Contract.prototype._createTxObject = function _createTxObject(){
695
696
txObject . arguments = args || [ ] ;
696
697
txObject . _method = this . method ;
697
698
txObject . _parent = this . parent ;
699
+ txObject . _ethAccounts = this . constructor . _ethAccounts || this . _ethAccounts ;
698
700
699
701
if ( this . deployData ) {
700
702
txObject . _deployData = this . deployData ;
@@ -756,8 +758,8 @@ Contract.prototype._processExecuteArguments = function _processExecuteArguments(
756
758
Contract . prototype . _executeMethod = function _executeMethod ( ) {
757
759
var _this = this ,
758
760
args = this . _parent . _processExecuteArguments . call ( this , Array . prototype . slice . call ( arguments ) , defer ) ,
759
- defer = promiEvent ( ( args . type !== 'send' ) ) ;
760
-
761
+ defer = promiEvent ( ( args . type !== 'send' ) ) ,
762
+ ethAccounts = _this . constructor . _ethAccounts || _this . _ethAccounts ;
761
763
762
764
// simple return request for batch requests
763
765
if ( args . generateRequest ) {
@@ -788,7 +790,7 @@ Contract.prototype._executeMethod = function _executeMethod(){
788
790
inputFormatter : [ formatters . inputCallFormatter ] ,
789
791
outputFormatter : utils . hexToNumber ,
790
792
requestManager : _this . _parent . _requestManager ,
791
- accounts : Contract . _ethAccounts , // is eth.accounts (necessary for wallet signing)
793
+ accounts : ethAccounts , // is eth.accounts (necessary for wallet signing)
792
794
defaultAccount : _this . _parent . defaultAccount ,
793
795
defaultBlock : _this . _parent . defaultBlock
794
796
} ) ) . createFunction ( ) ;
@@ -809,7 +811,7 @@ Contract.prototype._executeMethod = function _executeMethod(){
809
811
return _this . _parent . _decodeMethodReturn ( _this . _method . outputs , result ) ;
810
812
} ,
811
813
requestManager : _this . _parent . _requestManager ,
812
- accounts : Contract . _ethAccounts , // is eth.accounts (necessary for wallet signing)
814
+ accounts : ethAccounts , // is eth.accounts (necessary for wallet signing)
813
815
defaultAccount : _this . _parent . defaultAccount ,
814
816
defaultBlock : _this . _parent . defaultBlock
815
817
} ) ) . createFunction ( ) ;
@@ -879,7 +881,7 @@ Contract.prototype._executeMethod = function _executeMethod(){
879
881
params : 1 ,
880
882
inputFormatter : [ formatters . inputTransactionFormatter ] ,
881
883
requestManager : _this . _parent . _requestManager ,
882
- accounts : Contract . _ethAccounts , // is eth.accounts (necessary for wallet signing)
884
+ accounts : _this . constructor . _ethAccounts || _this . _ethAccounts , // is eth.accounts (necessary for wallet signing)
883
885
defaultAccount : _this . _parent . defaultAccount ,
884
886
defaultBlock : _this . _parent . defaultBlock ,
885
887
extraFormatters : extraFormatters
0 commit comments