Skip to content

Commit

Permalink
Add Utils.burnTotal.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Cardona committed May 25, 2019
1 parent b14c0e7 commit e3f95b8
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 2 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <name>")
Expand Down
24 changes: 24 additions & 0 deletions lib/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
12 changes: 12 additions & 0 deletions src/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,18 @@ class Utils {
throw error
}
}

async burnTotal(transactionId: string): Promise<Object> {
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
21 changes: 21 additions & 0 deletions test/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
])
})
})
})

0 comments on commit e3f95b8

Please sign in to comment.