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
166a1070
Commit
166a1070
authored
Mar 23, 2017
by
Remco Bloemen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add HasNoContracts
parent
94d3c447
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
0 deletions
+53
-0
HasNoContracts.sol
contracts/ownership/HasNoContracts.sol
+18
-0
HasNoContracts.js
test/HasNoContracts.js
+35
-0
No files found.
contracts/ownership/HasNoContracts.sol
0 → 100644
View file @
166a1070
pragma solidity ^0.4.8;
import "./Ownable.sol";
/// @title Contracts that should not own Contracts
/// @author Remco Bloemen <remco@2π.com>
///
/// Should contracts (anything Ownable) end up being owned by
/// this contract, it allows the owner of this contract to
/// reclaim ownership of the contracts.
contract HasNoContracts is Ownable {
/// Reclaim ownership of Ownable contracts
function reclaimContract(address contractAddr) external onlyOwner {
Ownable contractInst = Ownable(contractAddr);
contractInst.transferOwnership(owner);
}
}
test/HasNoContracts.js
0 → 100644
View file @
166a1070
'use strict'
;
import
expectThrow
from
'./helpers/expectThrow'
;
import
toPromise
from
'./helpers/toPromise'
;
const
Ownable
=
artifacts
.
require
(
'../contracts/ownership/Ownable.sol'
);
const
HasNoContracts
=
artifacts
.
require
(
'../contracts/ownership/HasNoContracts.sol'
,
);
contract
(
'HasNoContracts'
,
function
(
accounts
)
{
let
hasNoContracts
=
null
;
let
ownable
=
null
;
beforeEach
(
async
()
=>
{
// Create contract and token
hasNoContracts
=
await
HasNoContracts
.
new
();
ownable
=
await
Ownable
.
new
();
// Force ownership into contract
await
ownable
.
transferOwnership
(
hasNoContracts
.
address
);
const
owner
=
await
ownable
.
owner
();
assert
.
equal
(
owner
,
hasNoContracts
.
address
);
});
it
(
'should allow owner to reclaim contracts'
,
async
function
()
{
await
hasNoContracts
.
reclaimContract
(
ownable
.
address
);
const
owner
=
await
ownable
.
owner
();
assert
.
equal
(
owner
,
accounts
[
0
]);
});
it
(
'should allow only owner to reclaim contracts'
,
async
function
()
{
await
expectThrow
(
hasNoContracts
.
reclaimContract
(
ownable
.
address
,
{
from
:
accounts
[
1
]}),
);
});
});
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