From ea816c30b15bec7bd33809c5cffac01d6cd2b434 Mon Sep 17 00:00:00 2001 From: alwx Date: Tue, 16 May 2017 22:08:16 +0300 Subject: [PATCH] fromAscii fix --- cli.js | 6 ++++-- index.js | 12 ++++-------- package.json | 2 +- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/cli.js b/cli.js index 4786836..7cf53f4 100755 --- a/cli.js +++ b/cli.js @@ -83,9 +83,11 @@ function getCurrentPackageData() { } function getPackageData(contact) { - var contactData = contact; + var contactData; if (!contact) { - contactData = getCurrentPackageData(); + contactData = JSON.stringify(getCurrentPackageData()); + } else { + contactData = contact; } return contactData; } diff --git a/index.js b/index.js index 47505b3..58e42c1 100755 --- a/index.js +++ b/index.js @@ -10,10 +10,6 @@ function fromAscii(str) { return "0x" + hex; }; -function encodeObject(obj) { - return fromAscii(JSON.stringify(obj)); -} - var StatusDev = function(options) { this.url = "http://" + options.ip + ":5561"; }; @@ -23,7 +19,7 @@ StatusDev.prototype.addContact = function(contactData, cb) { url: this.url + "/add-dapp", method: "POST", json: true, - body: { encoded: encodeObject(contactData) } + body: { encoded: fromAscii(contactData) } }, function (error, response, body) { if (cb === undefined) { return } cb(error, response); @@ -35,7 +31,7 @@ StatusDev.prototype.removeContact = function(contactData, cb) { url: this.url + "/remove-dapp", method: "POST", json: true, - body: { encoded: encodeObject(contactData) } + body: { encoded: fromAscii(contactData) } }, function (error, response, body) { if (cb === undefined) { return } cb(error, response); @@ -47,7 +43,7 @@ StatusDev.prototype.refreshContact = function(contactData, cb) { url: this.url + "/dapp-changed", method: "POST", json: true, - body: { encoded: encodeObject(contactData) } + body: { encoded: fromAscii(contactData) } }, function (error, response, body) { if (cb === undefined) { return } cb(error, response); @@ -59,7 +55,7 @@ StatusDev.prototype.switchNode = function(rpcUrl, cb) { url: this.url + "/switch-node", method: "POST", json: true, - body: {encoded: encodeObject({"url": rpcUrl})} + body: {encoded: fromAscii({"url": rpcUrl})} }, function (error, response, body) { if (cb === undefined) { return } cb(error, response); diff --git a/package.json b/package.json index 14dc364..e67be82 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "status-dev-cli", - "version": "3.0.0", + "version": "3.0.1", "description": "CLI for Status", "main": "index.js", "bin": {