Skip to content

Commit 0cc0a5b

Browse files
authored
TOB recommendations (#129)
* Added event when monetary policy is updated (#126) * Disabling compiler optimizations (#128) * Fixed `owner` variable shadowing issue (#127)
1 parent b85e13a commit 0cc0a5b

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

contracts/UFragments.sol

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ contract UFragments is ERC20Detailed, Ownable {
4141
event LogRebase(uint256 indexed epoch, uint256 totalSupply);
4242
event LogRebasePaused(bool paused);
4343
event LogTokenPaused(bool paused);
44+
event LogMonetaryPolicyUpdated(address monetaryPolicy);
4445

4546
// Used for authentication
4647
address public monetaryPolicy;
@@ -97,6 +98,7 @@ contract UFragments is ERC20Detailed, Ownable {
9798
onlyOwner
9899
{
99100
monetaryPolicy = monetaryPolicy_;
101+
emit LogMonetaryPolicyUpdated(monetaryPolicy_);
100102
}
101103

102104
/**
@@ -166,21 +168,21 @@ contract UFragments is ERC20Detailed, Ownable {
166168
return _totalSupply;
167169
}
168170

169-
function initialize(address owner)
171+
function initialize(address owner_)
170172
public
171173
initializer
172174
{
173175
ERC20Detailed.initialize("UFragments", "AMPL", uint8(DECIMALS));
174-
Ownable.initialize(owner);
176+
Ownable.initialize(owner_);
175177

176178
rebasePaused = false;
177179
tokenPaused = false;
178180

179181
_totalSupply = INITIAL_FRAGMENTS_SUPPLY;
180-
_gonBalances[owner] = TOTAL_GONS;
182+
_gonBalances[owner_] = TOTAL_GONS;
181183
_gonsPerFragment = TOTAL_GONS.div(_totalSupply);
182184

183-
emit Transfer(address(0x0), owner, _totalSupply);
185+
emit Transfer(address(0x0), owner_, _totalSupply);
184186
}
185187

186188
/**
@@ -227,16 +229,16 @@ contract UFragments is ERC20Detailed, Ownable {
227229

228230
/**
229231
* @dev Function to check the amount of tokens that an owner has allowed to a spender.
230-
* @param owner The address which owns the funds.
232+
* @param owner_ The address which owns the funds.
231233
* @param spender The address which will spend the funds.
232234
* @return The number of tokens still available for the spender.
233235
*/
234-
function allowance(address owner, address spender)
236+
function allowance(address owner_, address spender)
235237
public
236238
view
237239
returns (uint256)
238240
{
239-
return _allowedFragments[owner][spender];
241+
return _allowedFragments[owner_][spender];
240242
}
241243

242244
/**

contracts/UFragmentsPolicy.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,11 @@ contract UFragmentsPolicy is Ownable {
187187
* It is called at the time of contract creation to invoke parent class initializers and
188188
* initialize the contract's state variables.
189189
*/
190-
function initialize(address owner, UFragments uFrags_, uint256 baseCpi_)
190+
function initialize(address owner_, UFragments uFrags_, uint256 baseCpi_)
191191
public
192192
initializer
193193
{
194-
Ownable.initialize(owner);
194+
Ownable.initialize(owner_);
195195

196196
// deviationThreshold = 0.05e18 = 5e16
197197
deviationThreshold = 5 * 10 ** (DECIMALS-2);

test/unit/UFragments.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,14 @@ contract('UFragments:setMonetaryPolicy', function (accounts) {
8888
await uFragments.setMonetaryPolicy(policy, { from: deployer });
8989
expect(await uFragments.monetaryPolicy.call()).to.eq(policy);
9090
});
91+
92+
it('should emit policy updated event', async function () {
93+
const r = await uFragments.setMonetaryPolicy(policy, { from: deployer });
94+
const log = r.logs[0];
95+
expect(log).to.exist;
96+
expect(log.event).to.eq('LogMonetaryPolicyUpdated');
97+
expect(log.args.monetaryPolicy).to.eq(policy);
98+
});
9199
});
92100

93101
contract('UFragments:setMonetaryPolicy:accessControl', function (accounts) {

truffle.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ module.exports = {
1111
version: '0.4.24',
1212
settings: {
1313
optimizer: {
14-
enabled: true,
15-
runs: 1000000
14+
enabled: false
1615
}
1716
}
1817
}

0 commit comments

Comments
 (0)