Procházet zdrojové kódy

Make Migrations contract Ownable

Tom Pointon před 3 roky
rodič
revize
8a6121b455

+ 5 - 12
ethereum/contracts/Migrations.sol

@@ -1,19 +1,12 @@
 // SPDX-License-Identifier: MIT
 pragma solidity >=0.4.22 <0.9.0;
 
-contract Migrations {
-    address public owner = msg.sender;
-    uint public last_completed_migration;
+import "@openzeppelin/contracts/access/Ownable.sol";
 
-    modifier restricted() {
-        require(
-            msg.sender == owner,
-            "This function is restricted to the contract's owner"
-        );
-        _;
-    }
+contract Migrations is Ownable {
+    uint public last_completed_migration;
 
-    function setCompleted(uint completed) public restricted {
+    function setCompleted(uint completed) public onlyOwner  {
         last_completed_migration = completed;
     }
-}
+}

+ 1 - 2
ethereum/package-lock.json

@@ -1854,8 +1854,7 @@
     "@openzeppelin/contracts": {
       "version": "4.5.0",
       "resolved": "https://registry.npmjs.org/@openzeppelin/contracts/-/contracts-4.5.0.tgz",
-      "integrity": "sha512-fdkzKPYMjrRiPK6K4y64e6GzULR7R7RwxSigHS8DDp7aWDeoReqsQI+cxHV1UuhAqX69L1lAaWDxenfP+xiqzA==",
-      "dev": true
+      "integrity": "sha512-fdkzKPYMjrRiPK6K4y64e6GzULR7R7RwxSigHS8DDp7aWDeoReqsQI+cxHV1UuhAqX69L1lAaWDxenfP+xiqzA=="
     },
     "@openzeppelin/contracts-upgradeable": {
       "version": "4.5.2",

+ 1 - 1
ethereum/package.json

@@ -6,7 +6,6 @@
   "devDependencies": {
     "@chainsafe/truffle-plugin-abigen": "0.0.1",
     "@openzeppelin/cli": "^2.8.2",
-    "@openzeppelin/contracts": "^4.5.0",
     "@openzeppelin/test-environment": "^0.1.9",
     "@openzeppelin/test-helpers": "^0.5.15",
     "@openzeppelin/truffle-upgrades": "^1.14.0",
@@ -30,6 +29,7 @@
   "author": "",
   "license": "ISC",
   "dependencies": {
+    "@openzeppelin/contracts": "^4.5.0",
     "@openzeppelin/contracts-upgradeable": "^4.5.2",
     "dotenv": "^10.0.0",
     "elliptic": "^6.5.2",