Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}).send(opts));
console.log('Deployed simpleadapter');
// link libs to fund (needed to deploy version)
const libObject = {};
let fundBytecode = fs.readFileSync('out/Fund.bin', 'utf8');
libObject[getPlaceholderFromPath('out/libraries/rewards')] = rewards.options.address;
libObject[getPlaceholderFromPath('out/exchange/adapter/simpleAdapter')] = simpleAdapter.options.address;
fundBytecode = solc.linkBytecode(fundBytecode, libObject);
fs.writeFileSync('out/Fund.bin', fundBytecode, 'utf8');
fs.writeFileSync('out/governance/Fund.bin', fundBytecode, 'utf8');
// deploy version (can use identical libs object as above)
const versionAbi = JSON.parse(fs.readFileSync('out/governance/Version.abi', 'utf8'));
let versionBytecode = fs.readFileSync('out/governance/Version.bin', 'utf8');
versionBytecode = solc.linkBytecode(versionBytecode, libObject);
const version = await (new web3.eth.Contract(versionAbi).deploy({
data: `0x${versionBytecode}`,
arguments: [mlnAddr],
}).send(opts));
for(const assetSymbol of config.protocol.registrar.assetsToRegister) {
console.log(`Registering ${assetSymbol}`);
const token = tokenInfo[environment].filter(token => token.symbol === assetSymbol)[0];
await datafeed.methods.register(
token.address,
token.name,
token.symbol,
token.decimals,
token.url,
config.protocol.registrar.ipfsHash,
config.protocol.registrar.chainId,
// deploy simpleAdapter
abi = JSON.parse(fs.readFileSync('out/exchange/adapter/simpleAdapter.abi'));
bytecode = fs.readFileSync('out/exchange/adapter/simpleAdapter.bin');
const simpleAdapter = await (new web3.eth.Contract(abi).deploy({
data: `0x${bytecode}`,
arguments: [],
}).send(opts));
console.log('Deployed simpleadapter');
// link libs to fund (needed to deploy version)
const libObject = {};
let fundBytecode = fs.readFileSync('out/Fund.bin', 'utf8');
libObject[getPlaceholderFromPath('out/libraries/rewards')] = rewards.options.address;
libObject[getPlaceholderFromPath('out/exchange/adapter/simpleAdapter')] = simpleAdapter.options.address;
fundBytecode = solc.linkBytecode(fundBytecode, libObject);
fs.writeFileSync('out/Fund.bin', fundBytecode, 'utf8');
fs.writeFileSync('out/governance/Fund.bin', fundBytecode, 'utf8');
// deploy version (can use identical libs object as above)
const versionAbi = JSON.parse(fs.readFileSync('out/governance/Version.abi', 'utf8'));
let versionBytecode = fs.readFileSync('out/governance/Version.bin', 'utf8');
versionBytecode = solc.linkBytecode(versionBytecode, libObject);
const version = await (new web3.eth.Contract(versionAbi).deploy({
data: `0x${versionBytecode}`,
arguments: [mlnAddr],
}).send(opts));
for(const assetSymbol of config.protocol.registrar.assetsToRegister) {
console.log(`Registering ${assetSymbol}`);
const token = tokenInfo[environment].filter(token => token.symbol === assetSymbol)[0];
await datafeed.methods.register(
function deployContract(symbolName, constructorArgs, callback) {
var compiledContract = compilation.contracts[symbolName + '.sol:'+symbolName];
var interface = JSON.parse(compiledContract.interface);
var bytecode = compiledContract.bytecode;
var dependencies = {};
Object.keys(contracts).forEach((symbol) => {
dependencies[symbol] = contracts[symbol].address;
});
var contract = web3.eth.contract(interface);
bytecode = contract.new.getData.apply(this, constructorArgs.concat({
data: solc.linkBytecode(bytecode, dependencies)
}));
web3.personal.unlockAccount(account, password, 300, (error) => {
if (error) {
done(error.toString());
return;
}
web3.eth.estimateGas({data: bytecode, from: account}, (error, gasEstimate) => {
if (error) {
done(error.toString());
return;
}
contract.new({data: bytecode, from: account, gas: gasEstimate + 100000}, (error, result) => {
if (error) {
done(error.toString());
return;
}