Throw exception instead of returning null for getDefaultProvider (#351).
This commit is contained in:
parent
98143a845b
commit
31d3ee899f
|
@ -33,8 +33,14 @@ import { ContractFunction, ContractTransaction, Event, EventFilter } from './con
|
||||||
// Helper Functions
|
// Helper Functions
|
||||||
|
|
||||||
function getDefaultProvider(network?: utils.Network | string): providers.BaseProvider {
|
function getDefaultProvider(network?: utils.Network | string): providers.BaseProvider {
|
||||||
let n = utils.getNetwork(network || 'homestead');
|
if (network == null) { network = 'homestead'; }
|
||||||
if (!n || !n._defaultProvider) { return null; }
|
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);
|
return n._defaultProvider(providers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue