import { __awaiter, __generator } from "tslib";
import { getContractFactory } from "../utils/getContractFactory";
import { identifier, refundProposalLiveness } from "../constants";
import { utf8ToHex } from "../../src/utils";
export function setupUmaEcosystem(owner) {
    return __awaiter(this, void 0, void 0, function () {
        var timer, finder, identifierWhitelist, mockOracle, optimisticOracle, collateralWhitelist, store;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0: return [4 /*yield*/, getContractFactory("Timer", owner)];
                case 1: return [4 /*yield*/, (_a.sent()).deploy()];
                case 2:
                    timer = _a.sent();
                    return [4 /*yield*/, getContractFactory("Finder", owner)];
                case 3: return [4 /*yield*/, (_a.sent()).deploy()];
                case 4:
                    finder = _a.sent();
                    return [4 /*yield*/, getContractFactory("IdentifierWhitelist", owner)];
                case 5: return [4 /*yield*/, (_a.sent()).deploy()];
                case 6:
                    identifierWhitelist = _a.sent();
                    return [4 /*yield*/, getContractFactory("MockOracleAncillary", owner)];
                case 7: return [4 /*yield*/, (_a.sent()).deploy(finder.address, timer.address)];
                case 8:
                    mockOracle = _a.sent();
                    return [4 /*yield*/, getContractFactory("SkinnyOptimisticOracle", owner)];
                case 9: return [4 /*yield*/, (_a.sent()).deploy(refundProposalLiveness, finder.address, timer.address)];
                case 10:
                    optimisticOracle = _a.sent();
                    return [4 /*yield*/, getContractFactory("AddressWhitelist", owner)];
                case 11: return [4 /*yield*/, (_a.sent()).deploy()];
                case 12:
                    collateralWhitelist = _a.sent();
                    return [4 /*yield*/, getContractFactory("Store", owner)];
                case 13: return [4 /*yield*/, (_a.sent()).deploy({ rawValue: "0" }, { rawValue: "0" }, timer.address)];
                case 14:
                    store = _a.sent();
                    return [4 /*yield*/, finder.changeImplementationAddress(utf8ToHex("CollateralWhitelist"), collateralWhitelist.address)];
                case 15:
                    _a.sent();
                    return [4 /*yield*/, finder.changeImplementationAddress(utf8ToHex("IdentifierWhitelist"), identifierWhitelist.address)];
                case 16:
                    _a.sent();
                    return [4 /*yield*/, finder.changeImplementationAddress(utf8ToHex("SkinnyOptimisticOracle"), optimisticOracle.address)];
                case 17:
                    _a.sent();
                    return [4 /*yield*/, finder.changeImplementationAddress(utf8ToHex("Store"), store.address)];
                case 18:
                    _a.sent();
                    return [4 /*yield*/, finder.changeImplementationAddress(utf8ToHex("Oracle"), mockOracle.address)];
                case 19:
                    _a.sent();
                    return [4 /*yield*/, identifierWhitelist.addSupportedIdentifier(identifier)];
                case 20:
                    _a.sent();
                    return [2 /*return*/, {
                            timer: timer,
                            finder: finder,
                            collateralWhitelist: collateralWhitelist,
                            identifierWhitelist: identifierWhitelist,
                            store: store,
                            optimisticOracle: optimisticOracle,
                            mockOracle: mockOracle,
                        }];
            }
        });
    });
}
//# sourceMappingURL=UmaEcosystemFixture.js.map