"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AddressList = void 0;
const superstruct_1 = require("superstruct");
const abstract_1 = require("./abstract");
const envConfig = (0, superstruct_1.defaulted)((0, superstruct_1.array)((0, superstruct_1.string)()), []);
class AddressList extends abstract_1.AbstractAdapter {
    constructor(opts) {
        super(opts?.name ?? "process.env", opts?.path ?? "ACROSS_IGNORED_ADDRESSES", opts);
    }
    update() {
        const config = process.env[this.path];
        if (!config) {
            return Promise.resolve([]);
        }
        let addresses;
        try {
            addresses = JSON.parse(config);
            if (!envConfig.is(addresses)) {
                return this.error("Address format validation failure.");
            }
        }
        catch (err) {
            return this.error(err);
        }
        return Promise.resolve(addresses);
    }
}
exports.AddressList = AddressList;
//# sourceMappingURL=env.js.map