@rosen-bridge/minimum-fee-browser
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -55,3 +55,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
this.search = function (tokenId) { return __awaiter(_this, void 0, void 0, function () { | ||
var boxes, box, chains, heights, bridgeFees, networkFees, rsnRatios, config, i, chain, chainConfig, j, height, e_1; | ||
var tokenIds, allowedTokenCount_1, fetchedBoxes, boxes, box, chains, heights, bridgeFees, networkFees, rsnRatios, config, i, chain, chainConfig, j, height, e_1; | ||
var _a, _b, _c, _d, _e; | ||
@@ -62,11 +62,18 @@ return __generator(this, function (_f) { | ||
_f.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, this.explorer.boxSearch(this.feeConfigErgoTreeTemplateHash, [this.feeConfigTokenId, tokenId])]; | ||
tokenIds = [this.feeConfigTokenId]; | ||
allowedTokenCount_1 = 1; | ||
if (tokenId !== 'erg') { | ||
tokenIds.push(tokenId); | ||
allowedTokenCount_1++; | ||
} | ||
return [4 /*yield*/, this.explorer.boxSearch(this.feeConfigErgoTreeTemplateHash, tokenIds)]; | ||
case 1: | ||
boxes = _f.sent(); | ||
fetchedBoxes = _f.sent(); | ||
boxes = fetchedBoxes.items.filter(function (box) { return box.assets.length <= allowedTokenCount_1; }); | ||
// appropriate log or error for suspects cases | ||
if (boxes.total < 1) | ||
if (boxes.length < 1) | ||
throw Error("Found no config box"); | ||
if (boxes.total > 1) | ||
throw Error("Found more than one config box. Ids: ".concat(boxes.items.map(function (box) { return box.boxId; }))); | ||
box = ErgoBox.from_json(JsonBI.stringify(boxes.items[0])); | ||
if (boxes.length > 1) | ||
throw Error("Found more than one config box. Ids: ".concat(boxes.map(function (box) { return box.boxId; }))); | ||
box = ErgoBox.from_json(JsonBI.stringify(boxes[0])); | ||
chains = (_a = box.register_value(4)) === null || _a === void 0 ? void 0 : _a.to_coll_coll_byte(); | ||
@@ -73,0 +80,0 @@ heights = (_b = box |
{ | ||
"name": "@rosen-bridge/minimum-fee-browser", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "this project gets minimum fee of the bridge for supported tokens from blockchain", | ||
@@ -5,0 +5,0 @@ "main": "dist/lib/index.js", |
Sorry, the diff of this file is not supported yet
46584
323