@dydxfoundation/governance
Version:
dYdX governance smart contracts
57 lines (56 loc) • 2.39 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDeployedContractsOnceForTest = void 0;
const config_1 = __importDefault(require("../../src/config"));
const get_deployed_contracts_1 = require("../../src/migrations/helpers/get-deployed-contracts");
const deploy_contracts_for_test_1 = require("../migrations/deploy-contracts-for-test");
let globalDeployedContracts;
let globalDeployError = null;
/**
* Helper to get contracts depending on the network, and make sure contracts are only deployed once
* when on the test network.
*/
async function getDeployedContractsOnceForTest() {
if (globalDeployError) {
throw globalDeployError;
}
if (!globalDeployedContracts) {
try {
globalDeployedContracts = await getDeployedContractsForTest();
}
catch (error) {
globalDeployError = error;
throw error;
}
}
return globalDeployedContracts;
}
exports.getDeployedContractsOnceForTest = getDeployedContractsOnceForTest;
async function getAllContracts() {
return (0, get_deployed_contracts_1.getMainnetDeployedContracts)();
}
async function getDeployedContractsForTest() {
if (!config_1.default.isHardhat()) {
return getAllContracts();
}
let deployedContracts;
if (config_1.default.FORK_MAINNET) {
deployedContracts = await getAllContracts();
}
else {
deployedContracts = await (0, deploy_contracts_for_test_1.deployContractsForTest)();
// Execute the proposals which have already been executed on mainnet.
//
// The proposals will be executed when running on a local test network,
// but will not be executed when running on a mainnet fork.
await (0, deploy_contracts_for_test_1.executeSafetyModuleRecoveryProposalsForTest)(deployedContracts);
await (0, deploy_contracts_for_test_1.executeStarkProxyProposalForTest)(deployedContracts);
}
// Execute the proposals which have not yet been executed on mainnet.
await (0, deploy_contracts_for_test_1.executeGrantsProgramProposalForTest)(deployedContracts);
await (0, deploy_contracts_for_test_1.configureForTest)(deployedContracts);
return deployedContracts;
}