"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getABIDir = getABIDir;
exports.getABI = getABI;
var tslib_1 = require("tslib");
var fs = tslib_1.__importStar(require("fs/promises"));
var typeguards_1 = require("../../typeguards");
function getABIDir() {
    return "".concat(__dirname, "/contracts");
}
function getABI(contractName) {
    return tslib_1.__awaiter(this, void 0, void 0, function () {
        var _a, _b, err_1, msg;
        return tslib_1.__generator(this, function (_c) {
            switch (_c.label) {
                case 0:
                    _c.trys.push([0, 2, , 3]);
                    _b = (_a = JSON).parse;
                    return [4, fs.readFile("".concat(getABIDir(), "/").concat(contractName, ".json"), { encoding: "utf8" })];
                case 1: return [2, _b.apply(_a, [_c.sent()])];
                case 2:
                    err_1 = _c.sent();
                    msg = (0, typeguards_1.isError)(err_1) ? err_1.message : err_1 === null || err_1 === void 0 ? void 0 : err_1.code;
                    throw new Error("Unable to retrieve ".concat(contractName, " ABI (").concat(msg !== null && msg !== void 0 ? msg : "unknown error", ")"));
                case 3: return [2];
            }
        });
    });
}
//# sourceMappingURL=index.js.map