From a4e84eff45c8d74d6784548df59dec372beb6093 Mon Sep 17 00:00:00 2001 From: MrDev023 Date: Thu, 1 Feb 2018 12:06:56 +0100 Subject: [PATCH] Bug fixes scripts npm --- contracts/Migrations.sol | 23 +++++++++++++++++++++++ migrations/1_initial_migration.js | 2 ++ 2 files changed, 25 insertions(+) create mode 100644 contracts/Migrations.sol diff --git a/contracts/Migrations.sol b/contracts/Migrations.sol new file mode 100644 index 0000000..f170cb4 --- /dev/null +++ b/contracts/Migrations.sol @@ -0,0 +1,23 @@ +pragma solidity ^0.4.17; + +contract Migrations { + address public owner; + uint public last_completed_migration; + + modifier restricted() { + if (msg.sender == owner) _; + } + + function Migrations() public { + owner = msg.sender; + } + + function setCompleted(uint completed) public restricted { + last_completed_migration = completed; + } + + function upgrade(address new_address) public restricted { + Migrations upgraded = Migrations(new_address); + upgraded.setCompleted(last_completed_migration); + } +} diff --git a/migrations/1_initial_migration.js b/migrations/1_initial_migration.js index b9de090..f811bdd 100644 --- a/migrations/1_initial_migration.js +++ b/migrations/1_initial_migration.js @@ -1,5 +1,7 @@ +var Migrations = artifacts.require("./Migrations.sol"); var HelloEthSalon = artifacts.require('./HelloEthSalon.sol'); module.exports = function(deployer) { + deployer.deploy(Migrations); deployer.deploy(HelloEthSalon); }; \ No newline at end of file