This repository has been archived by the owner on Jan 12, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename of SettableTransferXcert to PausableXcert.
- Loading branch information
Showing
9 changed files
with
110 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
pragma solidity ^0.4.19; | ||
|
||
import "./Xcert.sol"; | ||
|
||
contract PausableXcert is Xcert { | ||
|
||
/* | ||
* @dev This emits when ability of beeing able to transfer NFTokens changes (paused/unpaused). | ||
*/ | ||
event IsPaused(bool _isPaused); | ||
|
||
/* | ||
* @dev Are NFTokens paused or not. | ||
*/ | ||
bool public isPaused; | ||
|
||
function PausableXcert(string _name, string _symbol) | ||
Xcert(_name, _symbol) | ||
public | ||
{ | ||
supportedInterfaces[0xbedb86fb] = true; // PausableXcert | ||
isPaused = false; | ||
} | ||
|
||
/* | ||
* @dev Guarantees that the msg.sender is allowed to transfer NFToken. | ||
* @param _tokenId ID of the NFToken to transfer. | ||
*/ | ||
modifier canTransfer(uint256 _tokenId) { | ||
address owner = idToOwner[_tokenId]; | ||
require(!isPaused && ( | ||
owner == msg.sender | ||
|| getApproved(_tokenId) == msg.sender | ||
|| ownerToOperators[owner][msg.sender]) | ||
); | ||
|
||
_; | ||
} | ||
|
||
/* | ||
* @dev Sets if NFTokens are paused or not. | ||
* @param _isPaused Pause status. | ||
*/ | ||
function setPause(bool _isPaused) | ||
external | ||
onlyOwner | ||
{ | ||
require(isPaused != _isPaused); | ||
isPaused = _isPaused; | ||
IsPaused(_isPaused); | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const PausableXcert = artifacts.require('PausableXcert'); | ||
const util = require('ethjs-util'); | ||
const assertRevert = require('../helpers/assertRevert'); | ||
|
||
contract('PausableXcert', (accounts) => { | ||
let xcert; | ||
let id1 = web3.sha3('test1'); | ||
let id2 = web3.sha3('test2'); | ||
let id3 = web3.sha3('test3'); | ||
let id4 = web3.sha3('test4'); | ||
let mockProof = "1e205550c271490347e5e2393a02e94d284bbe9903f023ba098355b8d75974c8"; | ||
|
||
beforeEach(async function () { | ||
xcert = await PausableXcert.new('Foo', 'F'); | ||
}); | ||
|
||
it('correctly sets pause state', async () => { | ||
var { logs } = await xcert.setPause(true); | ||
let isPausedEvent = logs.find(e => e.event === 'IsPaused'); | ||
assert.notEqual(isPausedEvent, undefined); | ||
var pauseState = await xcert.isPaused(); | ||
assert.equal(pauseState, true); | ||
}); | ||
|
||
it('reverts trying to set the same pause state', async () => { | ||
await assertRevert(xcert.setPause(false)); | ||
}); | ||
|
||
it('reverts when someone else then the owner tries to change pause state', async () => { | ||
await assertRevert(xcert.setPause(true, {from: accounts[1]})); | ||
}); | ||
|
||
it('succefully transfers when token is not paused', async () => { | ||
await xcert.mint(accounts[0], id1, mockProof, 'url1'); | ||
await xcert.transferFrom(accounts[0], accounts[1], id1); | ||
var owner = await xcert.ownerOf(id1); | ||
assert.equal(owner, accounts[1]); | ||
}); | ||
|
||
it('reverts trying to transfer when token is paused', async () => { | ||
await xcert.mint(accounts[0], id1, mockProof, 'url1'); | ||
await xcert.setPause(true); | ||
await assertRevert(xcert.transferFrom(accounts[0], accounts[1], id1)); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters