diff --git a/index.js b/index.js index 27ff4ae..4ef218c 100755 --- a/index.js +++ b/index.js @@ -13,7 +13,7 @@ const repl = require("repl") const SLP = require("./lib/SLP") const clone = require("git-clone") -program.version("4.3.2", "-v, --version") +program.version("4.4.0", "-v, --version") program .command("new ") diff --git a/lib/Utils.js b/lib/Utils.js index da877e9..2500f75 100644 --- a/lib/Utils.js +++ b/lib/Utils.js @@ -242,6 +242,30 @@ var Utils = /** @class */ (function () { }); }); }; + Utils.prototype.burnTotal = function (transactionId) { + return __awaiter(this, void 0, void 0, function () { + var path, response, error_8; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + path = this.restURL + "slp/burnTotal/" + transactionId; + _a.label = 1; + case 1: + _a.trys.push([1, 3, , 4]); + return [4 /*yield*/, axios_1.default.get(path)]; + case 2: + response = _a.sent(); + return [2 /*return*/, response.data]; + case 3: + error_8 = _a.sent(); + if (error_8.response && error_8.response.data) + throw error_8.response.data; + throw error_8; + case 4: return [2 /*return*/]; + } + }); + }); + }; return Utils; }()); exports.default = Utils; diff --git a/package.json b/package.json index 7b434ba..238186c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "slp-sdk", - "version": "4.3.2", + "version": "4.4.0", "description": "SLP SDK powered by BITBOX", "main": "lib/SLP", "scripts": { diff --git a/src/Utils.ts b/src/Utils.ts index ffa6d12..07f97fd 100644 --- a/src/Utils.ts +++ b/src/Utils.ts @@ -122,6 +122,18 @@ class Utils { throw error } } + + async burnTotal(transactionId: string): Promise { + const path: string = `${this.restURL}slp/burnTotal/${transactionId}` + + try { + const response = await axios.get(path) + return response.data + } catch (error) { + if (error.response && error.response.data) throw error.response.data + throw error + } + } } export default Utils diff --git a/test/Utils.js b/test/Utils.js index e2f5930..a477ac3 100644 --- a/test/Utils.js +++ b/test/Utils.js @@ -274,4 +274,25 @@ describe("#Utils", () => { assert2.hasAnyKeys(transactions[0], ["txid", "tokenDetails"]) }) }) + + describe("#burnTotal", () => { + it(`should retrieve input, output and burn totals`, async () => { + // Mock the call to rest.bitcoin.com + // if (process.env.TEST === "unit") { + // nock(SERVER) + // .get(uri => uri.includes("/")) + // .reply(200, mockData.mockTransactions) + // } + + const burnTotal = await SLP.Utils.burnTotal( + "c7078a6c7400518a513a0bde1f4158cf740d08d3b5bfb19aa7b6657e2f4160de" + ) + assert2.hasAnyKeys(burnTotal, [ + "transactionId", + "inputTotal", + "outputTotal", + "burnTotal" + ]) + }) + }) })