2
0
mirror of synced 2025-02-25 04:25:16 +00:00

Added some extra checks for Wallet (from reading common mistakes on Stack Exchange).

This commit is contained in:
Richard Moore 2018-03-27 17:32:23 -04:00
parent 296473299c
commit 0f98bb5ac5
No known key found for this signature in database
GPG Key ID: 525F70A6FCABC295

View File

@ -82,7 +82,7 @@ function Wallet(privateKey, provider) {
utils.defineProperty(this, 'sign', function(transaction) {
var chainId = transaction.chainId;
if (!chainId && this.provider) { chainId = this.provider.chainId; }
if (chainId == null && this.provider) { chainId = this.provider.chainId; }
if (!chainId) { chainId = 0; }
var raw = [];
@ -241,6 +241,10 @@ utils.defineProperty(Wallet.prototype, 'estimateGas', function(transaction) {
utils.defineProperty(Wallet.prototype, 'sendTransaction', function(transaction) {
if (!this.provider) { throw new Error('missing provider'); }
if (!transaction || typeof(transaction) !== 'object') {
throw new Error('invalid transaction object');
}
var gasLimit = transaction.gasLimit;
if (gasLimit == null) { gasLimit = this.defaultGasLimit; }