import { mainNetMap } from './contract'

export async function getMainnet () {
  let promiseAll = []
  for (let i in mainNetMap) {
    let p1 = new Promise((resolve, reject) => {
      let mainnet = mainNetMap[i]
      fetch(`https://${mainnet}/v1/chain/get_info`)
        .then(data => {
          resolve(mainnet)
        })
        .catch(error => {
          reject(error)
        })
    })
    promiseAll.push(p1)
  }
  let result = await Promise.race(promiseAll)
  return result
}
