* Copyright ConsenSys Software Inc.
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations under the License.
 * SPDX-License-Identifier: Apache-2.0

const Utils = require("./utils");
const Priv = require("./priv");
const FlexiblePrivacyGroup = require("./flexiblePrivacyGroup");
const Eth = require("./eth");
const Ptm = require("./ptm");
const Raft = require("./raft");
const Istanbul = require("./istanbul");
const Permission = require("./permission");

 * Handles elements
 * @name Web3Quorum
 * @class Web3Quorum
 * @param {Object}  web3 instance of the web3.js library
 * @param {Object}  [enclaveOptions] configs of the transaction manager required for GoQuorum case only
 * @param {string}  enclaveOptions.ipcPath     absolute file path to the ipc of the transaction manager
 * @param {string}  enclaveOptions.privateUrl  http url to the transaction manager
 * @param {Object}  enclaveOptions.tlsSettings TLS configuration for the transaction manager when using HTTPS in privateUrl
 * @param {Buffer}  enclaveOptions.tlsSettings.key           client key buffer
 * @param {Buffer}  enclaveOptions.tlsSettings.clcert        client certificate buffer
 * @param {Buffer}  enclaveOptions.tlsSettings.cacert        CA certificate buffer
 * @param {Boolean} enclaveOptions.tlsSettings.allowInsecure
 * @param {Boolean} [isQuorum=false] indicates if the connected to client is quorum or besu
function Web3Quorum(web3, enclaveOptions = {}, isQuorum = false) {
  if (web3.currentProvider == null) {
    throw new Error("Missing provider");
  // TODO: to be updated by a method call web3_clientVersion
  // eslint-disable-next-line no-param-reassign
  web3.isQuorum = isQuorum;

  // Extend the utils namespace methods

  Ptm(web3, enclaveOptions);
  // Extend the priv namespace methods
  // Extend the flexiblePrivacyGroup namespace methods

  // Extend the eth namespace methods with GoQuorum methods

  // Extend the raft namespace methods

  // Extend the Istanbul namespace methods

  // Extend the Permission namespace methods

  return web3;

module.exports = Web3Quorum;