Skip to content

Commit a1b8cbb

Browse files
brandonilesBrandon Iles
and
Brandon Iles
authored
Remove pause functions (#159)
* Remove pause * Make deprecated contract properties private Co-authored-by: Brandon Iles <[email protected]>
1 parent 2590eee commit a1b8cbb

File tree

2 files changed

+4
-201
lines changed

2 files changed

+4
-201
lines changed

contracts/UFragments.sol

Lines changed: 4 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ contract UFragments is ERC20Detailed, Ownable {
3939
using SafeMathInt for int256;
4040

4141
event LogRebase(uint256 indexed epoch, uint256 totalSupply);
42-
event LogRebasePaused(bool paused);
43-
event LogTokenPaused(bool paused);
4442
event LogMonetaryPolicyUpdated(address monetaryPolicy);
4543

4644
// Used for authentication
@@ -51,19 +49,8 @@ contract UFragments is ERC20Detailed, Ownable {
5149
_;
5250
}
5351

54-
// Precautionary emergency controls.
55-
bool public rebasePaused;
56-
bool public tokenPaused;
57-
58-
modifier whenRebaseNotPaused() {
59-
require(!rebasePaused);
60-
_;
61-
}
62-
63-
modifier whenTokenNotPaused() {
64-
require(!tokenPaused);
65-
_;
66-
}
52+
bool private rebasePausedDeprecated;
53+
bool private tokenPausedDeprecated;
6754

6855
modifier validRecipient(address to) {
6956
require(to != address(0x0));
@@ -101,30 +88,6 @@ contract UFragments is ERC20Detailed, Ownable {
10188
emit LogMonetaryPolicyUpdated(monetaryPolicy_);
10289
}
10390

104-
/**
105-
* @dev Pauses or unpauses the execution of rebase operations.
106-
* @param paused Pauses rebase operations if this is true.
107-
*/
108-
function setRebasePaused(bool paused)
109-
external
110-
onlyOwner
111-
{
112-
rebasePaused = paused;
113-
emit LogRebasePaused(paused);
114-
}
115-
116-
/**
117-
* @dev Pauses or unpauses execution of ERC-20 transactions.
118-
* @param paused Pauses ERC-20 transactions if this is true.
119-
*/
120-
function setTokenPaused(bool paused)
121-
external
122-
onlyOwner
123-
{
124-
tokenPaused = paused;
125-
emit LogTokenPaused(paused);
126-
}
127-
12891
/**
12992
* @dev Notifies Fragments contract about a new rebase cycle.
13093
* @param supplyDelta The number of new fragment tokens to add into circulation via expansion.
@@ -133,7 +96,6 @@ contract UFragments is ERC20Detailed, Ownable {
13396
function rebase(uint256 epoch, int256 supplyDelta)
13497
external
13598
onlyMonetaryPolicy
136-
whenRebaseNotPaused
13799
returns (uint256)
138100
{
139101
if (supplyDelta == 0) {
@@ -175,8 +137,8 @@ contract UFragments is ERC20Detailed, Ownable {
175137
ERC20Detailed.initialize("Ampleforth", "AMPL", uint8(DECIMALS));
176138
Ownable.initialize(owner_);
177139

178-
rebasePaused = false;
179-
tokenPaused = false;
140+
rebasePausedDeprecated = false;
141+
tokenPausedDeprecated = false;
180142

181143
_totalSupply = INITIAL_FRAGMENTS_SUPPLY;
182144
_gonBalances[owner_] = TOTAL_GONS;
@@ -217,7 +179,6 @@ contract UFragments is ERC20Detailed, Ownable {
217179
function transfer(address to, uint256 value)
218180
public
219181
validRecipient(to)
220-
whenTokenNotPaused
221182
returns (bool)
222183
{
223184
uint256 gonValue = value.mul(_gonsPerFragment);
@@ -250,7 +211,6 @@ contract UFragments is ERC20Detailed, Ownable {
250211
function transferFrom(address from, address to, uint256 value)
251212
public
252213
validRecipient(to)
253-
whenTokenNotPaused
254214
returns (bool)
255215
{
256216
_allowedFragments[from][msg.sender] = _allowedFragments[from][msg.sender].sub(value);
@@ -276,7 +236,6 @@ contract UFragments is ERC20Detailed, Ownable {
276236
*/
277237
function approve(address spender, uint256 value)
278238
public
279-
whenTokenNotPaused
280239
returns (bool)
281240
{
282241
_allowedFragments[msg.sender][spender] = value;
@@ -293,7 +252,6 @@ contract UFragments is ERC20Detailed, Ownable {
293252
*/
294253
function increaseAllowance(address spender, uint256 addedValue)
295254
public
296-
whenTokenNotPaused
297255
returns (bool)
298256
{
299257
_allowedFragments[msg.sender][spender] =
@@ -310,7 +268,6 @@ contract UFragments is ERC20Detailed, Ownable {
310268
*/
311269
function decreaseAllowance(address spender, uint256 subtractedValue)
312270
public
313-
whenTokenNotPaused
314271
returns (bool)
315272
{
316273
uint256 oldValue = _allowedFragments[msg.sender][spender];

test/unit/UFragments.js

Lines changed: 0 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -123,160 +123,6 @@ contract('UFragments:setMonetaryPolicy:accessControl', function (accounts) {
123123
});
124124
});
125125

126-
contract('UFragments:PauseRebase', function (accounts) {
127-
const policy = accounts[1];
128-
const A = accounts[2];
129-
const B = accounts[3];
130-
131-
before('setup UFragments contract', async function () {
132-
await setupContracts();
133-
await uFragments.setMonetaryPolicy(policy, {from: deployer});
134-
r = await uFragments.setRebasePaused(true);
135-
});
136-
137-
it('should emit pause event', async function () {
138-
const log = r.logs[0];
139-
expect(log).to.exist;
140-
expect(log.event).to.eq('LogRebasePaused');
141-
expect(log.args.paused).to.be.true;
142-
});
143-
144-
it('should not allow calling rebase', async function () {
145-
expect(
146-
await chain.isEthException(uFragments.rebase(1, toUFrgDenomination(500), { from: policy }))
147-
).to.be.true;
148-
});
149-
150-
it('should allow calling transfer', async function () {
151-
await uFragments.transfer(A, transferAmount, { from: deployer });
152-
});
153-
154-
it('should allow calling approve', async function () {
155-
await uFragments.approve(A, transferAmount, { from: deployer });
156-
});
157-
158-
it('should allow calling allowance', async function () {
159-
await uFragments.allowance.call(deployer, A);
160-
});
161-
162-
it('should allow calling transferFrom', async function () {
163-
await uFragments.transferFrom(deployer, B, transferAmount, {from: A});
164-
});
165-
166-
it('should allow calling increaseAllowance', async function () {
167-
await uFragments.increaseAllowance(A, transferAmount, {from: deployer});
168-
});
169-
170-
it('should allow calling decreaseAllowance', async function () {
171-
await uFragments.decreaseAllowance(A, 10, {from: deployer});
172-
});
173-
174-
it('should allow calling balanceOf', async function () {
175-
await uFragments.balanceOf.call(deployer);
176-
});
177-
178-
it('should allow calling totalSupply', async function () {
179-
await uFragments.totalSupply.call();
180-
});
181-
});
182-
183-
contract('UFragments:PauseRebase:accessControl', function (accounts) {
184-
before('setup UFragments contract', setupContracts);
185-
186-
it('should be callable by owner', async function () {
187-
expect(
188-
await chain.isEthException(uFragments.setRebasePaused(true, { from: deployer }))
189-
).to.be.false;
190-
});
191-
192-
it('should NOT be callable by non-owner', async function () {
193-
expect(
194-
await chain.isEthException(uFragments.setRebasePaused(true, { from: user }))
195-
).to.be.true;
196-
});
197-
});
198-
199-
contract('UFragments:PauseToken', function (accounts) {
200-
const policy = accounts[1];
201-
const A = accounts[2];
202-
const B = accounts[3];
203-
204-
before('setup UFragments contract', async function () {
205-
await setupContracts();
206-
await uFragments.setMonetaryPolicy(policy, {from: deployer});
207-
r = await uFragments.setTokenPaused(true);
208-
});
209-
210-
it('should emit pause event', async function () {
211-
const log = r.logs[0];
212-
expect(log).to.exist;
213-
expect(log.event).to.eq('LogTokenPaused');
214-
expect(log.args.paused).to.be.true;
215-
});
216-
217-
it('should allow calling rebase', async function () {
218-
await uFragments.rebase(1, toUFrgDenomination(500), { from: policy });
219-
});
220-
221-
it('should not allow calling transfer', async function () {
222-
expect(
223-
await chain.isEthException(uFragments.transfer(A, transferAmount, { from: deployer }))
224-
).to.be.true;
225-
});
226-
227-
it('should not allow calling approve', async function () {
228-
expect(
229-
await chain.isEthException(uFragments.approve(A, transferAmount, { from: deployer }))
230-
).to.be.true;
231-
});
232-
233-
it('should allow calling allowance', async function () {
234-
await uFragments.allowance.call(deployer, A);
235-
});
236-
237-
it('should not allow calling transferFrom', async function () {
238-
expect(
239-
await chain.isEthException(uFragments.transferFrom(deployer, B, transferAmount, {from: A}))
240-
).to.be.true;
241-
});
242-
243-
it('should not allow calling increaseAllowance', async function () {
244-
expect(
245-
await chain.isEthException(uFragments.increaseAllowance(A, transferAmount, {from: deployer}))
246-
).to.be.true;
247-
});
248-
249-
it('should not allow calling decreaseAllowance', async function () {
250-
expect(
251-
await chain.isEthException(uFragments.decreaseAllowance(A, transferAmount, {from: deployer}))
252-
).to.be.true;
253-
});
254-
255-
it('should allow calling balanceOf', async function () {
256-
await uFragments.balanceOf.call(deployer);
257-
});
258-
259-
it('should allow calling totalSupply', async function () {
260-
await uFragments.totalSupply.call();
261-
});
262-
});
263-
264-
contract('UFragments:PauseToken:accessControl', function (accounts) {
265-
before('setup UFragments contract', setupContracts);
266-
267-
it('should be callable by owner', async function () {
268-
expect(
269-
await chain.isEthException(uFragments.setTokenPaused(true, { from: deployer }))
270-
).to.be.false;
271-
});
272-
273-
it('should NOT be callable by non-owner', async function () {
274-
expect(
275-
await chain.isEthException(uFragments.setTokenPaused(true, { from: user }))
276-
).to.be.true;
277-
});
278-
});
279-
280126
contract('UFragments:Rebase:accessControl', function (accounts) {
281127
before('setup UFragments contract', async function () {
282128
await setupContracts();

0 commit comments

Comments
 (0)