You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
static create(options) {
if (typeof options === 'string')
options = networks[options];
assert(options, 'Unknown network.');
if (Network[options.type]) // <<< Line 136
return Network[options.type];
const network = new Network(options);
Network[network.type] = network;
if (!Network.primary)
Network.primary = network;
return network;
}
This method will take a string, or a set of key-value pairs it uses as options. Still, it is possible to send an empty object, or other not-specifically-handled type, and it would cause an exception on line 136. Should we create a type for these options, and use instanceof like, for example the get() method a little further down in network.js...
static get(type) {
if (!type) {
assert(Network.primary, 'No default network.');
return Network.primary;
}
if (type instanceof Network) // Like this here..
return type;
if (typeof type === 'string')
return Network.create(type);
throw new Error('Unknown network.');
}
The text was updated successfully, but these errors were encountered:
Can't we just check if options is an object instance, and if so whether it has an attribute 'type' of type string using the assert function? In case this doesn't check out, the function would simply return a message invalidating the object, and avoid the issue altogether.
If it isn't an object, we could carry out the function as done already.
In network.js..
This method will take a string, or a set of key-value pairs it uses as options. Still, it is possible to send an empty object, or other not-specifically-handled type, and it would cause an exception on line 136. Should we create a type for these options, and use instanceof like, for example the get() method a little further down in network.js...
The text was updated successfully, but these errors were encountered: