Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
openzeppelin-contracts-upgradeable
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
俞永鹏
openzeppelin-contracts-upgradeable
Commits
f3606e3e
Commit
f3606e3e
authored
Sep 21, 2018
by
Francisco Giordano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
transform Ownable to initializers
parent
9c16ffca
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
3 deletions
+22
-3
OwnableMock.sol
contracts/mocks/OwnableMock.sol
+11
-0
Ownable.sol
contracts/ownership/Ownable.sol
+3
-2
Ownable.test.js
test/ownership/Ownable.test.js
+8
-1
No files found.
contracts/mocks/OwnableMock.sol
0 → 100644
View file @
f3606e3e
pragma solidity ^0.4.24;
import { Ownable } from '../ownership/Ownable.sol';
contract OwnableMock is Ownable {
constructor() {
initialize();
}
}
contracts/ownership/Ownable.sol
View file @
f3606e3e
pragma solidity ^0.4.24;
import "../Initializable.sol";
/**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/
contract Ownable {
contract Ownable
is Initializable
{
address private _owner;
...
...
@@ -21,7 +22,7 @@ contract Ownable {
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
constructor() public
{
function initialize() public initializer
{
_owner = msg.sender;
}
...
...
test/ownership/Ownable.test.js
View file @
f3606e3e
const
{
EVMRevert
}
=
require
(
'../helpers/EVMRevert'
);
const
{
expectThrow
}
=
require
(
'../helpers/expectThrow'
);
const
{
shouldBehaveLikeOwnable
}
=
require
(
'./Ownable.behavior'
);
const
Ownable
=
artifacts
.
require
(
'Ownable'
);
const
Ownable
=
artifacts
.
require
(
'Ownable
Mock
'
);
contract
(
'Ownable'
,
function
([
_
,
owner
,
...
otherAccounts
])
{
beforeEach
(
async
function
()
{
this
.
ownable
=
await
Ownable
.
new
({
from
:
owner
});
});
it
(
'cannot be reinitialized'
,
async
function
()
{
await
expectThrow
(
this
.
ownable
.
initialize
(),
EVMRevert
);
});
shouldBehaveLikeOwnable
(
owner
,
otherAccounts
);
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment