Skip to content

Commit 0f98bb5

Browse files
committed
Added some extra checks for Wallet (from reading common mistakes on Stack Exchange).
1 parent 2964732 commit 0f98bb5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

wallet/wallet.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ function Wallet(privateKey, provider) {
8282

8383
utils.defineProperty(this, 'sign', function(transaction) {
8484
var chainId = transaction.chainId;
85-
if (!chainId && this.provider) { chainId = this.provider.chainId; }
85+
if (chainId == null && this.provider) { chainId = this.provider.chainId; }
8686
if (!chainId) { chainId = 0; }
8787

8888
var raw = [];
@@ -241,6 +241,10 @@ utils.defineProperty(Wallet.prototype, 'estimateGas', function(transaction) {
241241
utils.defineProperty(Wallet.prototype, 'sendTransaction', function(transaction) {
242242
if (!this.provider) { throw new Error('missing provider'); }
243243

244+
if (!transaction || typeof(transaction) !== 'object') {
245+
throw new Error('invalid transaction object');
246+
}
247+
244248
var gasLimit = transaction.gasLimit;
245249
if (gasLimit == null) { gasLimit = this.defaultGasLimit; }
246250

0 commit comments

Comments
 (0)