import Web3 from 'web3'

interface Web3Obj{
    provider:Web3
    id?:string
    url:string
    port?:string
}

interface ProviderConfig{
    id?:string
    url:string
    port?:string

}
/**
 * @description 默认使用infura
 * @param id 用户账户 必填
 * @param url provider地址
 * @param version 版本号
 * @returns 
 */
export const ETH_PROVIDER = (config:ProviderConfig):Web3Obj=>{
    let {id,url,port} = config
    id = id?id:''
    url = url?url:'https://ropsten.infura.io/v3/'
    port = port?port:''
    const provider = new Web3(url+port+id)
    return  {provider,id,url,port}
}




// /**
//  * @description 默认使用infura
//  * @param id 用户账户 必填
//  * @param url provider地址
//  * @param version 版本号
//  * @returns 
//  */
// export const BIAN_PROVIDER = (id?: string,port=':443',url='https://bsc-dataseed1.binance.org/')=>{
//     const provider = new Web3(url+port+id)
//     return  {provider,id,url,port}
// }