// 

import { crypto } from 'bcoin'

import { Socket } from 'net'
import { TLSSocket } from 'tls'

import { makeEdgeCorePlugins } from './plugin/currencyPlugin.js'
import {



  makeEdgeSocket
} from './plugin/pluginIo.js'

export function makeNodeIo(io) {
  const { secp256k1, pbkdf2 } = crypto
  return {
    ...io,
    pbkdf2,
    secp256k1,
    makeSocket(opts) {
      let socket
      if (opts.type === 'tcp') socket = new Socket()
      else if (opts.type === 'tls') socket = new TLSSocket(new Socket())
      else throw new Error('Unsupported socket type')

      return Promise.resolve(makeEdgeSocket(socket, opts))
    }
  }
}

const edgeCorePlugins = makeEdgeCorePlugins(opts => makeNodeIo(opts.io))

export default edgeCorePlugins
