contract.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import { getMainnet } from './getMainnet.js'
  2. // EOS配置
  3. export async function getNetwork () {
  4. var newwork = {}
  5. // 并发请求,获取最快主网
  6. if (window.location.port === '8080' || /^test|\.webdev2\./.test(window.location.host)) {
  7. newwork = {
  8. protocol: 'https',
  9. blockchain: 'eos',
  10. port: '443',
  11. host: 'localnet.eosget.io',
  12. chainId: 'cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f'
  13. }
  14. } else {
  15. EOS_HOST = await getMainnet()
  16. newwork = {
  17. protocol: EOS_PROTOCOL,
  18. blockchain: 'eos',
  19. // host: 'nodes.get-scatter.com',
  20. port: EOS_PORT,
  21. host: EOS_HOST,
  22. chainId: 'aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906'
  23. }
  24. }
  25. return newwork
  26. }
  27. // 修改eos配置
  28. export function changeNewWork (host) {
  29. return {
  30. protocol: 'https',
  31. blockchain: 'eos',
  32. host,
  33. port: '',
  34. chainId: 'aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906'
  35. }
  36. }
  37. // WebSocket
  38. export function getWsUrl () {
  39. var wsUrl
  40. var wsProtocol = document.location.protocol === 'https:' ? 'wss://' : 'ws://'
  41. if (window.location.port === '8080' || /^test|\.webdev2\./.test(window.location.host)) {
  42. wsUrl = wsProtocol + 'test-ws.mee.chat'
  43. } else if (/^new[-.]/.test(window.location.host)) {
  44. wsUrl = wsProtocol + 'new-ws.mee.chat'
  45. } else {
  46. wsUrl = wsProtocol + 'ws.mee.chat'
  47. }
  48. return wsUrl
  49. }
  50. export function getMiniWsUrl () {
  51. var wsUrl
  52. var wsProtocol = document.location.protocol === 'https:' ? 'wss://' : 'ws://'
  53. if (window.location.port === '8080' || /^test|\.webdev2\./.test(window.location.host)) {
  54. wsUrl = wsProtocol + 'test-ws-group.mee.chat'
  55. } else if (/^new[-.]/.test(window.location.host)) {
  56. wsUrl = wsProtocol + 'new-ws-group.mee.chat'
  57. } else {
  58. wsUrl = wsProtocol + 'ws-group.mee.chat'
  59. }
  60. return wsUrl
  61. }
  62. // 主网
  63. export var mainNetMap = {
  64. 'eosplay': 'eosjs.eosplay.com',
  65. // 'hkeos': 'api.hkeos.com',
  66. 'cypherglass': 'api.cypherglass.com',
  67. 'eoscannon': 'mainnet.eoscannon.io',
  68. 'eosbeijing': 'api.eosbeijing.one',
  69. 'eosn': 'api.eosn.io',
  70. 'eosys': 'rpc.eosys.io',
  71. // 'eosnewyork': 'api.eosnewyork.io',
  72. 'get-scatter': 'nodes.get-scatter.com',
  73. 'proxy': 'proxy.eosnode.tools'
  74. }