Commit 01e6df46 authored by Jared Pereira's avatar Jared Pereira

add network switching

parent aa0ef819
...@@ -7,5 +7,10 @@ ...@@ -7,5 +7,10 @@
"rinkeby": { "rinkeby": {
"provider": "https://rinkeby.infura.io", "provider": "https://rinkeby.infura.io",
"defaultRoom": "0x855b28d40208575951e695fa0b6a6e16e175b9d9" "defaultRoom": "0x855b28d40208575951e695fa0b6a6e16e175b9d9"
},
"mainnet": {
"provider": "https://mainnet.infura.io",
"defaultRoom": "0xd73c64f76937c0c656f8bb4f0d120ef3a29a23ce"
} }
} }
...@@ -2,7 +2,6 @@ var fs = require('fs') ...@@ -2,7 +2,6 @@ var fs = require('fs')
const path = require('path'); const path = require('path');
var config = JSON.parse(fs.readFileSync(path.join(__dirname, '../config.json'))) var config = JSON.parse(fs.readFileSync(path.join(__dirname, '../config.json')))
var network = config.rinkeby
var ws = require('ws') var ws = require('ws')
...@@ -19,6 +18,15 @@ var ethUtil = require('ethjs-util') ...@@ -19,6 +18,15 @@ var ethUtil = require('ethjs-util')
var HttpProvider = require('ethjs-provider-http'); var HttpProvider = require('ethjs-provider-http');
var Eth = require('ethjs-query'); var Eth = require('ethjs-query');
//Network Selection
if(process.env.PORT){
var network = config.mainnet
}
else {
var network = config.rinkeby
}
var eth = new Eth(new HttpProvider(network.provider)); var eth = new Eth(new HttpProvider(network.provider));
const ethContract = require('ethjs-contract') const ethContract = require('ethjs-contract')
...@@ -28,6 +36,7 @@ var abi = [{"constant":true,"inputs":[{"name":"permissions","type":"address"}]," ...@@ -28,6 +36,7 @@ var abi = [{"constant":true,"inputs":[{"name":"permissions","type":"address"}],"
var contract = new ethContract(eth) var contract = new ethContract(eth)
var Room = contract(abi) var Room = contract(abi)
var port = process.env.PORT || 8000 var port = process.env.PORT || 8000
console.log(port) console.log(port)
......
...@@ -2,7 +2,7 @@ var fs = require('fs') ...@@ -2,7 +2,7 @@ var fs = require('fs')
var path = require('path') var path = require('path')
var config = JSON.parse(fs.readFileSync(path.join(__dirname, '../config.json'))) var config = JSON.parse(fs.readFileSync(path.join(__dirname, '../config.json')))
var network = config.rinkeby
var ethUtil = require('ethereumjs-util') var ethUtil = require('ethereumjs-util')
...@@ -12,6 +12,15 @@ window.setInterval(function() { ...@@ -12,6 +12,15 @@ window.setInterval(function() {
send({cmd: 'ping'}) send({cmd: 'ping'})
}, 50000) }, 50000)
//Network Selection
if(document.domain == "darq.chat"){
var network = config.mainnet
}
else {
var network = config.rinkeby
}
//WebSocket Funcctions! //WebSocket Funcctions!
function join() { function join() {
ws = new WebSocket('ws://' + document.domain + ":" + location.port+ '/ws') ws = new WebSocket('ws://' + document.domain + ":" + location.port+ '/ws')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment