index.js

  1. import Ethereum from './chain/ethereum/index'
  2. import Tronweb from './chain/tron/index'
  3. import ethEvolutionLand from './evolutionland/ethereum'
  4. import tronEvolutionLand from './evolutionland/tron'
  5. import units from './evolutionland/utils/unitConversion'
  6. /**
  7. * @constructor
  8. * Evolution
  9. */
  10. class Evolution {
  11. constructor(options = {}) {
  12. this.web3js = null
  13. this.tronweb = null
  14. this.units = units
  15. }
  16. /**
  17. * create web3js instance.
  18. * @param config [provider: A URL or one of the Web3 provider classes.]
  19. */
  20. async createWeb3js(config) {
  21. this.web3js = await Ethereum.createWeb3js(config)
  22. }
  23. /**
  24. * create tronweb instance
  25. * @param config [fullNode, solidityNode, eventServer, privateKey] You can also set a [fullNode]
  26. */
  27. createTronweb(config) {
  28. this.tronweb = Tronweb.createTronweb(config)
  29. }
  30. /**
  31. * create a instance for interacting with Evolution Land
  32. * @param chain ['ethereum', 'tron']
  33. * @param env Ethereum for ['main','ropsten']、 Tron for ['main', 'shasta']
  34. * @returns {*}
  35. */
  36. createEvolutionLand(chain, env, option) {
  37. switch (chain) {
  38. case 'ethereum':
  39. return this.ethEvoland = this.ethereumEvoLand = new ethEvolutionLand(this.web3js, env, option)
  40. case 'tron':
  41. return this.tronEvoland = new tronEvolutionLand(this.tronweb, env, option)
  42. default:
  43. return null;
  44. }
  45. }
  46. }
  47. window.Evolution = Evolution;
  48. export default Evolution;