Throw exception instead of returning null for getDefaultProvider (#351).

This commit is contained in:
Richard Moore 2018-11-21 16:23:44 -05:00
parent 98143a845b
commit 31d3ee899f
No known key found for this signature in database
GPG Key ID: 525F70A6FCABC295
1 changed files with 8 additions and 2 deletions

View File

@ -33,8 +33,14 @@ import { ContractFunction, ContractTransaction, Event, EventFilter } from './con
// Helper Functions
function getDefaultProvider(network?: utils.Network | string): providers.BaseProvider {
let n = utils.getNetwork(network || 'homestead');
if (!n || !n._defaultProvider) { return null; }
if (network == null) { network = 'homestead'; }
let n = utils.getNetwork(network);
if (!n || !n._defaultProvider) {
errors.throwError('unsupported getDefaultProvider network', errors.UNSUPPORTED_OPERATION, {
operation: 'getDefaultProvider',
network: network
});
}
return n._defaultProvider(providers);
}