diff --git a/devtools.js b/devtools.js deleted file mode 100644 index 239ce57..0000000 --- a/devtools.js +++ /dev/null @@ -1,32 +0,0 @@ -var status = { - addDApp: function(to, argsHex) { - web3.shh.post({ - "from": to, - "to": to, - "topics": ["status-dapp-topic"], - "ttl": 5, - "payload": web3.fromAscii("{:type :debug :action :add-dapp :args \"" + argsHex + "\"}\n") - }); - return "Request sent"; - }, - removeDApp: function(to, argsHex) { - web3.shh.post({ - "from": to, - "to": to, - "topics": ["status-dapp-topic"], - "ttl": 5, - "payload": web3.fromAscii("{:type :debug :action :remove-dapp :args \"" + argsHex + "\"}\n") - }); - return "Request sent"; - }, - notifyDAppChanged: function(to, argsHex) { - web3.shh.post({ - "from": to, - "to": to, - "topics": ["status-dapp-topic"], - "ttl": 2, - "payload": web3.fromAscii("{:type :debug :action :dapp-changed :args \"" + argsHex + "\"}\n") - }); - return "Notification sent"; - } -}; diff --git a/index.js b/index.js index d9a16a9..dc592b7 100644 --- a/index.js +++ b/index.js @@ -4,7 +4,6 @@ const child = require('child_process') const watchman = require('fb-watchman'); const pkgJson = require(__dirname + '/package.json'); -const devtoolsPath = __dirname + '/devtools.js'; var client = new watchman.Client(); @@ -19,7 +18,7 @@ function fromAscii(str) { return "0x" + hex; }; -function makeSubscription(client, watch, relativePath, attachTo, publicKey, dapp) { +function makeSubscription(client, watch, relativePath, ip, dapp) { sub = { expression: ["allof", ["match", "*.*"]], fields: ["name"] @@ -45,45 +44,30 @@ function makeSubscription(client, watch, relativePath, attachTo, publicKey, dapp console.log('File changed: ' + file); }); - child.execSync( - "geth --exec '" + - "loadScript(\"" + devtoolsPath + "\");" + - "status.notifyDAppChanged(\"" + publicKey + "\", \"" + dapp + "\");'" + - " " + - "attach " + attachTo - ); + url = "http://" + ip + ":5561/dapp-changed"; + child.execSync("curl -X POST -H \"Content-Type: application/json\" -d '{\"encoded\": \"" + dapp + "\"}' " + url); }); } cli.version(pkgJson.version); -cli.command("add-dapp ") +cli.command("add-dapp ") .description("Adds a DApp to contacts and chats") - .action(function (attachTo, publicKey, dapp) { + .action(function (ip, dapp) { dapp = fromAscii(dapp); - child.execSync( - "geth --exec '" + - "loadScript(\"" + devtoolsPath + "\");" + - "status.addDApp(\"" + publicKey + "\", \"" + dapp + "\");'" + - " " + - "attach " + attachTo - ); + url = "http://" + ip + ":5561/add-dapp"; + child.execSync("curl -X POST -H \"Content-Type: application/json\" -d '{\"encoded\": \"" + dapp + "\"}' " + url); }); -cli.command("remove-dapp ") +cli.command("remove-dapp ") .description("Removes a debuggable DApp") - .action(function (attachTo, publicKey, dappIdentity) { + .action(function (ip, dappIdentity) { dapp = fromAscii(JSON.stringify({"whisper-identity": dappIdentity})); - child.execSync( - "geth --exec '" + - "loadScript(\"" + devtoolsPath + "\");" + - "status.removeDApp(\"" + publicKey + "\", \"" + dapp + "\");'" + - " " + - "attach " + attachTo - ); + url = "http://" + ip + ":5561/remove-dapp"; + child.execSync("curl -X POST -H \"Content-Type: application/json\" -d '{\"encoded\": \"" + dapp + "\"}' " + url); }); -cli.command("watch-dapp ") +cli.command("watch-dapp ") .description("Starts watching for DApp changes") .action(function (attachTo, publicKey, dappIdentity, dappDir) { dapp = fromAscii(JSON.stringify({"whisper-identity": dappIdentity})); @@ -113,8 +97,7 @@ cli.command("watch-dapp ") client, resp.watch, resp.relative_path, - attachTo, - publicKey, + ip, dapp ); } diff --git a/package.json b/package.json index d91175d..6662b44 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "status-dev-cli", - "version": "1.0.0", + "version": "1.1.2", "description": "CLI for Status", "main": "index.js", "bin": {