import { __awaiter, __extends, __generator, __spreadArray } from "tslib";
import { array, defaulted, string, type } from "superstruct";
import { AbstractAdapter } from "./abstract";
var DEFAULT_NAME = "bybit";
var DEFAULT_URL = "https://hackscan.hackbounty.io/public/hack-address.json";
// This type is a bit message and unweildy. Additional fields representing new chains may be added without notification.
var bybitResponse = type({
    "0221": type({
        eth: defaulted(array(string()), []),
        bsc: defaulted(array(string()), []),
        arbi: defaulted(array(string()), []),
    }),
});
var AddressList = /** @class */ (function (_super) {
    __extends(AddressList, _super);
    function AddressList(opts) {
        var _a, _b;
        return _super.call(this, (_a = opts === null || opts === void 0 ? void 0 : opts.name) !== null && _a !== void 0 ? _a : DEFAULT_NAME, (_b = opts === null || opts === void 0 ? void 0 : opts.path) !== null && _b !== void 0 ? _b : DEFAULT_URL, opts) || this;
    }
    AddressList.prototype.update = function () {
        return __awaiter(this, void 0, void 0, function () {
            var response;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, this.fetch(this.name, this.path, this.timeout, this.retries)];
                    case 1:
                        response = _a.sent();
                        if (!bybitResponse.is(response)) {
                            // nb. don't log the response because it might be very large.
                            return [2 /*return*/, this.error("Failed to validate response")];
                        }
                        return [2 /*return*/, __spreadArray(__spreadArray(__spreadArray([], response["0221"].eth, true), response["0221"].bsc, true), response["0221"].arbi, true)];
                }
            });
        });
    };
    return AddressList;
}(AbstractAdapter));
export { AddressList };
//# sourceMappingURL=bybit.js.map