Fixed wrong default gasLimit bug and clearing provider.

This commit is contained in:
ricmoo 2016-08-04 03:20:01 -04:00
parent af62f54042
commit db757b5bbb

@ -32,7 +32,9 @@ function Wallet(privateKey, provider) {
enumerable: true,
get: function() { return provider; },
set: function(value) {
if (!providers.isProvider(value)) { throw new Error('invalid provider'); }
if (value !== null && !providers.isProvider(value)) {
throw new Error('invalid provider');
}
provider = value;
}
});
@ -148,8 +150,8 @@ utils.defineProperty(Wallet.prototype, 'estimateGas', function(transaction) {
});
utils.defineProperty(Wallet.prototype, 'sendTransaction', function(transaction) {
var gasLimit = 3000000;
if (transaction.gasLimit != null) { gasLimit = transaction.gasLimit; }
var gasLimit = transaction.gasLimit;
if (gasLimit == null) { gasLimit = 3000000; }
var self = this;
@ -170,7 +172,7 @@ utils.defineProperty(Wallet.prototype, 'sendTransaction', function(transaction)
if (transaction.nonce) {
return resolve(transaction.nonce);
}
provider.getTransactionCount(self.address).then(function(transactionCount) {
provider.getTransactionCount(self.address, 'pending').then(function(transactionCount) {
resolve(transactionCount);
}, function(error) {
reject(error);
@ -181,7 +183,7 @@ utils.defineProperty(Wallet.prototype, 'sendTransaction', function(transaction)
Promise.all([gasPrice, nonce]).then(function(results) {
var signedTransaction = self.sign({
to: transaction.to,
gasLimit: results[1],
gasLimit: gasLimit,
gasPrice: results[0],
nonce: results[1],
value: transaction.value