Skip to content
This repository has been archived by the owner on Feb 18, 2020. It is now read-only.

Commit

Permalink
Add Medianizer deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
anxolin committed Jun 1, 2018
1 parent 1fb22a0 commit 81e5c12
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 20 deletions.
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.
44 changes: 44 additions & 0 deletions migrations/3_DEV-deploy_price_feed.js
@@ -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`)
}
}
20 changes: 0 additions & 20 deletions migrations_old/3_DEV-deploy_price_feed.js

This file was deleted.

0 comments on commit 81e5c12

Please sign in to comment.