contract.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import { getMainnet } from './getMainnet.js'
  2. // EOS配置
  3. export async function getNetwork () {
  4. var newwork = {}
  5. // 并发请求,获取最快主网
  6. EOS_HOST = await getMainnet()
  7. if (window.location.port === '8080' || /^test-|\.webdev2\./.test(window.location.host)) {
  8. newwork = {
  9. protocol: 'https',
  10. blockchain: 'eos',
  11. port: '443',
  12. host: 'localnet.eosget.io',
  13. chainId: 'cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f'
  14. }
  15. } else {
  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. if (window.location.port === '8080' || /^test-|\.webdev2\./.test(window.location.host)) {
  41. if (document.location.protocol === 'https:') {
  42. wsUrl = 'wss://test-ws-k3.eosget.io'
  43. } else {
  44. wsUrl = 'ws://test-ws-k3.eosget.io'
  45. }
  46. } else {
  47. if (document.location.protocol === 'https:') {
  48. wsUrl = 'wss://ws-k3.eosget.io'
  49. } else {
  50. wsUrl = 'ws://ws-k3.eosget.io'
  51. }
  52. }
  53. return wsUrl
  54. }
  55. // 主网
  56. export var mainNetMap = {
  57. 'eosplay': 'eosjs.eosplay.com',
  58. 'cypherglass': 'api.cypherglass.com',
  59. 'eoscannon': 'mainnet.eoscannon.io',
  60. 'eosbeijing': 'api.eosbeijing.one',
  61. 'eosn': 'api.eosn.io',
  62. 'eosys': 'rpc.eosys.io',
  63. 'get-scatter': 'nodes.get-scatter.com'
  64. }