From 41fdd5d4c6d52aa723348d4891b88c06a4d46efa Mon Sep 17 00:00:00 2001 From: qdeswaef Date: Thu, 15 Dec 2016 15:32:08 +0100 Subject: [PATCH 1/3] fixes gh-109: resolve conflict between Ownable and ERC20 token. --- contracts/Ownable.sol | 4 ++-- test/Ownable.js | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/contracts/Ownable.sol b/contracts/Ownable.sol index 40fc08146..705f081bc 100644 --- a/contracts/Ownable.sol +++ b/contracts/Ownable.sol @@ -14,12 +14,12 @@ contract Ownable { owner = msg.sender; } - modifier onlyOwner() { + modifier onlyOwner() { if (msg.sender == owner) _; } - function transfer(address newOwner) onlyOwner { + function transferOwnership(address newOwner) onlyOwner { if (newOwner != address(0)) owner = newOwner; } diff --git a/test/Ownable.js b/test/Ownable.js index abf8a9272..24a2d239c 100644 --- a/test/Ownable.js +++ b/test/Ownable.js @@ -12,7 +12,7 @@ contract('Ownable', function(accounts) { it("changes owner after transfer", async function() { let other = accounts[1]; - let transfer = await ownable.transfer(other); + let transfer = await ownable.transferOwnership(other); let owner = await ownable.owner(); assert.isTrue(owner === other); @@ -20,7 +20,7 @@ contract('Ownable', function(accounts) { it("should prevent non-owners from transfering", async function() { let other = accounts[2]; - let transfer = await ownable.transfer(other, {from: accounts[2]}); + let transfer = await ownable.transferOwnership(other, {from: accounts[2]}); let owner = await ownable.owner(); assert.isFalse(owner === other); @@ -29,9 +29,9 @@ contract('Ownable', function(accounts) { it("should guard ownership against stuck state", async function() { let ownable = Ownable.deployed(); let originalOwner = await ownable.owner(); - let transfer = await ownable.transfer(null, {from: originalOwner}); + let transfer = await ownable.transferOwnership(null, {from: originalOwner}); let newOwner = await ownable.owner(); - + assert.equal(originalOwner, newOwner); }); From 77e732218e911b4a6c1a99b25e3c99e1ea2924ef Mon Sep 17 00:00:00 2001 From: qdeswaef Date: Thu, 15 Dec 2016 15:59:25 +0100 Subject: [PATCH 2/3] Also change claimable to avoid conflicts with ERC20 tokens --- contracts/Claimable.sol | 6 +++--- test/Claimable.js | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/contracts/Claimable.sol b/contracts/Claimable.sol index d51d34f01..e7490e05d 100644 --- a/contracts/Claimable.sol +++ b/contracts/Claimable.sol @@ -7,8 +7,8 @@ import './Ownable.sol'; /* * Claimable - * - * Extension for the Ownable contract, where the ownership needs to be claimed. This allows the new owner to accept the transfer. + * + * Extension for the Ownable contract, where the ownership needs to be claimed. This allows the new owner to accept the transfer. */ contract Claimable is Ownable { address public pendingOwner; @@ -18,7 +18,7 @@ contract Claimable is Ownable { _; } - function transfer(address newOwner) onlyOwner { + function transferOwnership(address newOwner) onlyOwner { pendingOwner = newOwner; } diff --git a/test/Claimable.js b/test/Claimable.js index b30b31d2d..ae3acc5cc 100644 --- a/test/Claimable.js +++ b/test/Claimable.js @@ -12,7 +12,7 @@ contract('Claimable', function(accounts) { it("changes pendingOwner after transfer", async function() { let newOwner = accounts[1]; - let transfer = await claimable.transfer(newOwner); + let transfer = await claimable.transferOwnership(newOwner); let pendingOwner = await claimable.pendingOwner(); assert.isTrue(pendingOwner === newOwner); @@ -21,12 +21,12 @@ contract('Claimable', function(accounts) { it("should prevent to claimOwnership from no pendingOwner", async function() { let claimedOwner = await claimable.claimOwnership({from: accounts[2]}); let owner = await claimable.owner(); - + assert.isTrue(owner != accounts[2]); }); it("should prevent non-owners from transfering", async function() { - let transfer = await claimable.transfer(accounts[2], {from: accounts[2]}); + let transfer = await claimable.transferOwnership(accounts[2], {from: accounts[2]}); let pendingOwner = await claimable.pendingOwner(); assert.isFalse(pendingOwner === accounts[2]); @@ -37,7 +37,7 @@ contract('Claimable', function(accounts) { beforeEach(async function () { newOwner = accounts[1]; - await claimable.transfer(newOwner); + await claimable.transferOwnership(newOwner); }); it("changes allow pending owner to claim ownership", async function() { From ed6df57f88b4f019ccc3fdf43e6baef84001843d Mon Sep 17 00:00:00 2001 From: qdeswaef Date: Fri, 16 Dec 2016 10:15:08 +0100 Subject: [PATCH 3/3] updated documentation for claimable and ownable interfaces --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 598347dd6..6a9274583 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ Sets the address of the creator of the contract as the owner. #### modifier onlyOwner( ) Prevents function from running if it is called by anyone other than the owner. -#### transfer(address newOwner) onlyOwner +#### transferOwnership(address newOwner) onlyOwner Transfers ownership of the contract to the passed address. --- @@ -97,7 +97,7 @@ ___ ### Claimable Extension for the Ownable contract, where the ownership needs to be claimed -#### transfer(address newOwner) onlyOwner +#### transferOwnership(address newOwner) onlyOwner Sets the passed address as the pending owner. #### modifier onlyPendingOwner