import { array, defaulted, string } from "superstruct";
import { AbstractAdapter } from "./abstract";
const envConfig = defaulted(array(string()), []);
export class AddressList extends 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);
    }
}
//# sourceMappingURL=env.js.map