From 342d671b244f48e508c52885fef5ffa7cf93e516 Mon Sep 17 00:00:00 2001 From: Gabriel Cardona Date: Tue, 21 Aug 2018 15:52:46 -0700 Subject: [PATCH] Stringify arrays --- index.js | 2 +- lib/Blockchain.js | 15 +++++++++++++++ package.json | 2 +- src/Blockchain.js | 15 +++++++++++++++ 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 1a48adb0..9f0b3927 100755 --- a/index.js +++ b/index.js @@ -18,7 +18,7 @@ let clone = require('git-clone'); let cmd = require('node-cmd'); program - .version('1.5.11'); + .version('1.5.12'); program .command('new ') diff --git a/lib/Blockchain.js b/lib/Blockchain.js index 09c26307..676d8bed 100644 --- a/lib/Blockchain.js +++ b/lib/Blockchain.js @@ -113,6 +113,9 @@ var Blockchain = function () { // // Result: // "hash" (string) The block hash + if (typeof height !== 'string') { + height = JSON.stringify(height); + } return _axios2.default.get(this.restURL + 'blockchain/getBlockHash/' + height).then(function (response) { return response.data; }).catch(function (error) { @@ -152,6 +155,9 @@ var Blockchain = function () { // // Result (for verbose=false): // "data" (string) A string that is serialized, hex-encoded data for block 'hash'. + if (typeof hash !== 'string') { + hash = JSON.stringify(hash); + } return _axios2.default.get(this.restURL + 'blockchain/getBlockHeader/' + hash + '?verbose=' + verbose).then(function (response) { return response.data; }).catch(function (error) { @@ -244,6 +250,9 @@ var Blockchain = function () { // ... ] // }, ... // } + if (typeof txid !== 'string') { + txid = JSON.stringify(txid); + } return _axios2.default.get(this.restURL + 'blockchain/getMempoolAncestors/' + txid + '?verbose=' + verbose).then(function (response) { return response.data; }).catch(function (error) { @@ -288,6 +297,9 @@ var Blockchain = function () { // ... ] // }, ... // } + if (typeof txid !== 'string') { + txid = JSON.stringify(txid); + } return _axios2.default.get(this.restURL + 'blockchain/getMempoolDescendants/' + txid + '?verbose=' + verbose).then(function (response) { return response.data; @@ -322,6 +334,9 @@ var Blockchain = function () { // "transactionid", (string) parent transaction id // ... ] // } + if (typeof txid !== 'string') { + txid = JSON.stringify(txid); + } return _axios2.default.get(this.restURL + 'blockchain/getMempoolEntry/' + txid).then(function (response) { return response.data; diff --git a/package.json b/package.json index b1606b27..59a2f049 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bitbox-cli", - "version": "1.5.11", + "version": "1.5.12", "description": "BITBOX javascript sdk for Bitcoin Cash", "author": "Gabriel Cardona @ Bitcoin.com", "main": "index.js", diff --git a/src/Blockchain.js b/src/Blockchain.js index f45ab220..6665835a 100644 --- a/src/Blockchain.js +++ b/src/Blockchain.js @@ -94,6 +94,9 @@ class Blockchain { // // Result: // "hash" (string) The block hash + if(typeof height !== 'string') { + height = JSON.stringify(height); + } return axios.get(`${this.restURL}blockchain/getBlockHash/${height}`) .then((response) => { return response.data; @@ -132,6 +135,9 @@ class Blockchain { // // Result (for verbose=false): // "data" (string) A string that is serialized, hex-encoded data for block 'hash'. + if(typeof hash !== 'string') { + hash = JSON.stringify(hash); + } return axios.get(`${this.restURL}blockchain/getBlockHeader/${hash}?verbose=${verbose}`) .then((response) => { return response.data; @@ -225,6 +231,9 @@ class Blockchain { // ... ] // }, ... // } + if(typeof txid !== 'string') { + txid = JSON.stringify(txid); + } return axios.get(`${this.restURL}blockchain/getMempoolAncestors/${txid}?verbose=${verbose}`) .then((response) => { return response.data; @@ -268,6 +277,9 @@ class Blockchain { // ... ] // }, ... // } + if(typeof txid !== 'string') { + txid = JSON.stringify(txid); + } return axios.get(`${this.restURL}blockchain/getMempoolDescendants/${txid}?verbose=${verbose}`) .then((response) => { @@ -303,6 +315,9 @@ class Blockchain { // "transactionid", (string) parent transaction id // ... ] // } + if(typeof txid !== 'string') { + txid = JSON.stringify(txid); + } return axios.get(`${this.restURL}blockchain/getMempoolEntry/${txid}`) .then((response) => {