code: function getNetwork(network) {
      // No network (null)
      if (network == null) {
          return null;
      }
      if (typeof (network) === 'number') {
          for (var name_1 in networks) {
              var n_1 = networks[name_1];
              if (n_1.chainId === network) {
                  return {
                      name: n_1.name,
                      chainId: n_1.chainId,
                      ensAddress: (n_1.ensAddress || null),
                      _defaultProvider: (n_1._defaultProvider || null)
                  };
              }
          }
          return {
              chainId: network,
              name: 'unknown'
          };
      }
      if (typeof (network) === 'string') {
          var n_2 = networks[network];
          if (n_2 == null) {
              return null;
          }
          return {
              name: n_2.name,
              chainId: n_2.chainId,
              ensAddress: n_2.ensAddress,
              _defaultProvider: (n_2._defaultProvider || null)
          };
      }
      var n = networks[network.name];
      // Not a standard network; check that it is a valid network in general
      if (!n) {
          if (typeof (network.chainId) !== 'number') {
              errors.throwError('invalid network chainId', errors.INVALID_ARGUMENT, { arg: 'network', value: network });
          }
          return network;
      }
      // Make sure the chainId matches the expected network chainId (or is 0; disable EIP-155)
      if (network.chainId !== 0 && network.chainId !== n.chainId) {
          errors.throwError('network chainId mismatch', errors.INVALID_ARGUMENT, { arg: 'network', value: network });
      }
      // Standard Network (allow overriding the ENS address)
      return {
          name: network.name,
          chainId: n.chainId,
          ensAddress: (network.ensAddress || n.ensAddress || null),
          _defaultProvider: (network._defaultProvider || n._defaultProvider || null)
      };
  }
docs: getNetwork
  
  Converts a named common networks or chain ID (network ID) to a Network
  and verifies a network is a valid Network..