This repository has been archived by the owner on Feb 18, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
44 additions
and
20 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* global artifacts */ | ||
/* eslint no-undef: "error" */ | ||
const contract = require('truffle-contract') | ||
|
||
const ETH_USD_PRICE = 500 | ||
const MAGIC_NUMBER_TO_BE_RENAMED = 1516168838 * 2 | ||
|
||
const PriceFeed = artifacts.require('PriceFeed') | ||
const Medianizer = artifacts.require('Medianizer') | ||
const PriceOracleInterface = artifacts.require('PriceOracleInterface') | ||
|
||
function getMedianizerAddress () { | ||
try { | ||
return Medianizer.address | ||
} catch (error) { | ||
// Medianizer.address throw an error if there's no config address | ||
// As a result, only development should be deploying this contracts | ||
return null | ||
} | ||
} | ||
|
||
|
||
module.exports = function (deployer, network, accounts) { | ||
const medianizerAddress = getMedianizerAddress() | ||
const account = accounts[0] | ||
if (!medianizerAddress) { | ||
console.log(`Deploying Maker Dao feed contracts, because they weren published in network "${network}" yet`) | ||
// Deployment of PriceFeedInfrastructure | ||
deployer.deploy([ PriceFeed, Medianizer ]) | ||
.then(() => deployer.deploy(PriceOracleInterface, account, Medianizer.address)) | ||
.then(() => Medianizer.deployed()) | ||
.then(medianizer => medianizer.set(PriceFeed.address, { from: account })) | ||
.then(() => PriceFeed.deployed()) | ||
.then(priceFeed => priceFeed.post( | ||
ETH_USD_PRICE * 1e18, | ||
MAGIC_NUMBER_TO_BE_RENAMED, | ||
Medianizer.address, { | ||
from: account | ||
}) | ||
) | ||
} else { | ||
console.log(`No need to deploy theMaker Dao feed contracts. Using ${medianizerAddress} as the Medianizer address`) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.