contract.js 2.2 KB

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