import { __awaiter, __extends, __generator } from "tslib";
import { BaseHTTPAdapter } from "./baseAdapter";
/**
 * Fallback price adapter to unconditionally return 0 on all input addresses.
 * This adapter can be used as a last-resort to default to a token price of 0
 * in case all other adapters fail to resolve a token price.
 */
var PriceFeed = /** @class */ (function (_super) {
    __extends(PriceFeed, _super);
    function PriceFeed(prices) {
        if (prices === void 0) { prices = {}; }
        var _this = _super.call(this, "Default Adapter", "127.0.0.1", {}) || this;
        _this.prices = prices;
        return _this;
    }
    PriceFeed.prototype.getPriceByAddress = function (address, currency) {
        return __awaiter(this, void 0, void 0, function () {
            var price;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, this.getPricesByAddress([address], currency)];
                    case 1:
                        price = (_a.sent())[0];
                        return [2 /*return*/, price];
                }
            });
        });
    };
    PriceFeed.prototype.getPricesByAddress = function (addresses, currency) {
        var _this = this;
        return Promise.resolve(addresses.map(function (address) {
            var _a, _b;
            return {
                address: address,
                price: (_b = (_a = _this.prices[currency]) === null || _a === void 0 ? void 0 : _a[address]) !== null && _b !== void 0 ? _b : 0,
                timestamp: 0,
            };
        }));
    };
    return PriceFeed;
}(BaseHTTPAdapter));
export { PriceFeed };
//# sourceMappingURL=default.js.map