From 3f46dafafe50c77cf389a6f282d4b564602bc7f8 Mon Sep 17 00:00:00 2001 From: Ahmed Date: Sun, 18 Nov 2018 14:54:01 -0800 Subject: [PATCH] Remove underscore suffix from public variable names --- contracts/MarketOracle.sol | 30 +++++++------- contracts/MarketSource.sol | 12 +++--- package-lock.json | 65 +++++++++++++++--------------- package.json | 2 +- test/unit/market_oracle.js | 14 +++---- test/unit/market_source.js | 4 +- test/unit/market_source_factory.js | 4 +- 7 files changed, 66 insertions(+), 65 deletions(-) diff --git a/contracts/MarketOracle.sol b/contracts/MarketOracle.sol index f37d04f..d981c2a 100644 --- a/contracts/MarketOracle.sol +++ b/contracts/MarketOracle.sol @@ -18,7 +18,7 @@ contract MarketOracle is Ownable { using SafeMath for uint256; // Whitelist of sources - MarketSource[] public _whitelist; + MarketSource[] public whitelist; event LogSourceAdded(MarketSource source); event LogSourceRemoved(MarketSource source); @@ -42,11 +42,11 @@ contract MarketOracle is Ownable { uint256 partialVolume = 0; bool isSourceFresh = false; - for (uint256 i = 0; i < _whitelist.length; i++) { - (isSourceFresh, partialRate, partialVolume) = _whitelist[i].getReport(); + for (uint256 i = 0; i < whitelist.length; i++) { + (isSourceFresh, partialRate, partialVolume) = whitelist[i].getReport(); if (!isSourceFresh) { - emit LogSourceExpired(_whitelist[i]); + emit LogSourceExpired(whitelist[i]); continue; } @@ -70,7 +70,7 @@ contract MarketOracle is Ownable { external onlyOwner { - _whitelist.push(source); + whitelist.push(source); emit LogSourceAdded(source); } @@ -82,8 +82,8 @@ contract MarketOracle is Ownable { external onlyOwner { - for (uint256 i = 0; i < _whitelist.length; i++) { - if (_whitelist[i] == source) { + for (uint256 i = 0; i < whitelist.length; i++) { + if (whitelist[i] == source) { removeSourceAtIndex(i); break; } @@ -98,8 +98,8 @@ contract MarketOracle is Ownable { external { uint256 i = 0; - while (i < _whitelist.length) { - if (isContractDestructed(_whitelist[i])) { + while (i < whitelist.length) { + if (isContractDestructed(whitelist[i])) { removeSourceAtIndex(i); } else { i++; @@ -115,7 +115,7 @@ contract MarketOracle is Ownable { view returns (uint256) { - return _whitelist.length; + return whitelist.length; } /** @@ -139,11 +139,11 @@ contract MarketOracle is Ownable { function removeSourceAtIndex(uint256 index) private { - // assert(_whitelist.length > index); - emit LogSourceRemoved(_whitelist[index]); - if (index != _whitelist.length-1) { - _whitelist[index] = _whitelist[_whitelist.length-1]; + // assert(whitelist.length > index); + emit LogSourceRemoved(whitelist[index]); + if (index != whitelist.length-1) { + whitelist[index] = whitelist[whitelist.length-1]; } - _whitelist.length--; + whitelist.length--; } } diff --git a/contracts/MarketSource.sol b/contracts/MarketSource.sol index 092df6a..db6e6fb 100644 --- a/contracts/MarketSource.sol +++ b/contracts/MarketSource.sol @@ -21,7 +21,7 @@ contract MarketSource is Destructible { ); // Name of the source reporting exchange rates - string public _name; + string public name; // These are the three oracle values that are continuously reported. // Smaller types are used here locally to save on storage gas. @@ -30,11 +30,11 @@ contract MarketSource is Destructible { uint64 private _timestampSec; // The number of seconds after which the report must be deemed expired. - uint64 public _reportExpirationTimeSec; + uint64 public reportExpirationTimeSec; - constructor(string name, uint64 reportExpirationTimeSec) public { - _name = name; - _reportExpirationTimeSec = reportExpirationTimeSec; + constructor(string name_, uint64 reportExpirationTimeSec_) public { + name = name_; + reportExpirationTimeSec = reportExpirationTimeSec_; } /** @@ -73,7 +73,7 @@ contract MarketSource is Destructible { view returns (bool, uint256, uint256) { - bool isFresh = (uint256(_timestampSec).add(_reportExpirationTimeSec) > now); + bool isFresh = (uint256(_timestampSec).add(reportExpirationTimeSec) > now); return ( isFresh, uint256(_exchangeRate), diff --git a/package-lock.json b/package-lock.json index 6263a2a..02d80fe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -34,9 +34,9 @@ } }, "aes-js": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.1.1.tgz", - "integrity": "sha512-cEA0gBelItZZV7iBiL8ApCiNgc+gBWJJ4uoORhbu6vOqAJ0UL9wIlxr4RI7ij9SSVzy6AnPwiu37kVYiHCl3nw==" + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.1.2.tgz", + "integrity": "sha512-e5pEa2kBnBOgR4Y/p20pskXI74UEz7de8ZGVo58asOtvSVG5YAbJeELPZxOmt+Bnz3rX753YKhfIn4X4l1PPRQ==" }, "ajv": { "version": "5.5.2", @@ -235,9 +235,9 @@ "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" }, "base-x": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.4.tgz", - "integrity": "sha512-UYOadoSIkEI/VrRGSG6qp93rp2WdokiAiNYDfGW5qURAY8GiAQkvMbwNNSDYiVJopqv4gCna7xqf4rrNGp+5AA==", + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.5.tgz", + "integrity": "sha512-C3picSgzPSLE+jW3tcBzJoGwitOtazb5B+5YmAxZm2ybmTi9LNgAtDO/jjVEBZwHoXmDBZ9m/IELj3elJVRBcA==", "requires": { "safe-buffer": "^5.0.1" } @@ -253,9 +253,9 @@ } }, "bindings": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.3.0.tgz", - "integrity": "sha512-DpLh5EzMR2kzvX1KIlVC0VkC3iZtHKTgdtZ0a3pglBZdaQFjt5S9g9xd1lE+YvXyfd6mtCeRnrUfOLYiTMlNSw==" + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.3.1.tgz", + "integrity": "sha512-i47mqjF9UbjxJhxGf+pZ6kSxrnI3wBLlnGI2ArWJ4r0VrvDS7ZYXkprq/pLaBWYq4GM0r4zdHY+NNRqEMU7uew==" }, "bip39": { "version": "2.5.0", @@ -278,9 +278,9 @@ } }, "bn.js": { - "version": "4.11.6", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.6.tgz", - "integrity": "sha1-UzRK2xRhehP26N0s4okF0cC6MhU=" + "version": "4.11.8", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", + "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==" }, "brace-expansion": { "version": "1.1.11", @@ -303,7 +303,7 @@ }, "browserify-aes": { "version": "1.2.0", - "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", + "resolved": "http://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==", "requires": { "buffer-xor": "^1.0.3", @@ -571,7 +571,7 @@ }, "create-hash": { "version": "1.2.0", - "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", + "resolved": "http://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", "integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==", "requires": { "cipher-base": "^1.0.1", @@ -583,7 +583,7 @@ }, "create-hmac": { "version": "1.1.7", - "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", + "resolved": "http://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==", "requires": { "cipher-base": "^1.0.3", @@ -726,9 +726,9 @@ } }, "elliptic": { - "version": "6.4.0", - "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.0.tgz", - "integrity": "sha1-ysmvh2LIWDYYcAPI3+GT5eLq5d8=", + "version": "6.4.1", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.1.tgz", + "integrity": "sha512-BsXLz5sqX8OHcsh7CqBMztyXARmGQ3LWPtGjJi6DiJHq5C/qvi9P3OqgswKSDftbu8+IoI/QDTAm2fFnQ9SZSQ==", "requires": { "bn.js": "^4.4.0", "brorand": "^1.0.1", @@ -1343,8 +1343,8 @@ } }, "frg-ethereum-runners": { - "version": "git+ssh://git@github.com/frgprotocol/frg-ethereum-runners.git#91adfc385f1b446443d7f7260c951512118f0b48", - "from": "git+ssh://git@github.com/frgprotocol/frg-ethereum-runners.git#master", + "version": "git+ssh://git@github.com/frgprotocol/frg-ethereum-runners.git#090d0589359a1466c7ad86c64a6a04bc3ef9ac18", + "from": "git+ssh://git@github.com/frgprotocol/frg-ethereum-runners.git", "requires": { "app-root-path": "^2.1.0", "bip39": "^2.5.0", @@ -1584,12 +1584,12 @@ } }, "hash.js": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.3.tgz", - "integrity": "sha512-/UETyP0W22QILqS+6HowevwhEFJ3MBJnwTf75Qob9Wz9t0DPuisL8kW8YZMK62dHAKE1c1p+gY1TtOLY+USEHA==", + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.5.tgz", + "integrity": "sha512-eWI5HG9Np+eHV1KQhisXWwM+4EPPYe5dFX1UZZH7k/E3JzDEazVH+VGlZi6R94ZqImq+A3D1mCEtrFIfg/E7sA==", "requires": { "inherits": "^2.0.3", - "minimalistic-assert": "^1.0.0" + "minimalistic-assert": "^1.0.1" } }, "hdkey": { @@ -2055,12 +2055,13 @@ } }, "md5.js": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.4.tgz", - "integrity": "sha1-6b296UogpawYsENA/Fdk1bCdkB0=", + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", + "integrity": "sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==", "requires": { "hash-base": "^3.0.0", - "inherits": "^2.0.1" + "inherits": "^2.0.1", + "safe-buffer": "^5.1.2" } }, "memorystream": { @@ -2333,9 +2334,9 @@ "dev": true }, "pbkdf2": { - "version": "3.0.16", - "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.16.tgz", - "integrity": "sha512-y4CXP3thSxqf7c0qmOF+9UeOTrifiVTIM+u7NWlq+PRsHbr7r7dpCmvzrZxa96JJUNi0Y5w9VqG5ZNeCVMoDcA==", + "version": "3.0.17", + "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.17.tgz", + "integrity": "sha512-U/il5MsrZp7mGg3mSQfn742na2T+1/vHDCG5/iTI3X9MKUuYUZVLQhyRsg06mCgDBTd57TxzgZt7P+fYfjRLtA==", "requires": { "create-hash": "^1.1.2", "create-hmac": "^1.1.4", @@ -2749,7 +2750,7 @@ }, "sha.js": { "version": "2.4.11", - "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", + "resolved": "http://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", "requires": { "inherits": "^2.0.1", diff --git a/package.json b/package.json index d7dfbd3..85f70df 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ }, "dependencies": { "app-root-path": "^2.0.1", - "frg-ethereum-runners": "git+ssh://git@github.com/frgprotocol/frg-ethereum-runners.git#master", + "frg-ethereum-runners": "git+ssh://git@github.com/frgprotocol/frg-ethereum-runners.git", "js-yaml": "^3.11.0", "openzeppelin-solidity": "1.10.0", "truffle": "^4.1.13" diff --git a/test/unit/market_oracle.js b/test/unit/market_oracle.js index c0b940b..9a51554 100644 --- a/test/unit/market_oracle.js +++ b/test/unit/market_oracle.js @@ -51,7 +51,7 @@ contract('MarketOracle:addSource', async function (accounts) { expect(event.args.source).to.eq(source.address); }); it('should add source to the whitelist', async function () { - expect(await oracle._whitelist.call(0)).to.eq(source.address); + expect(await oracle.whitelist.call(0)).to.eq(source.address); (await oracle.whitelistSize.call()).should.be.bignumber.eq(1); }); }); @@ -92,7 +92,7 @@ contract('MarketOracle:removeSource', async function (accounts) { expect(event.args.source).to.eq(source.address); }); it('should remove source from the whitelist', async function () { - expect(await oracle._whitelist.call(0)).to.eq(source2.address); + expect(await oracle.whitelist.call(0)).to.eq(source2.address); (await oracle.whitelistSize.call()).should.be.bignumber.eq(1); }); }); @@ -113,8 +113,8 @@ contract('MarketOracle:removeSource', async function (accounts) { expect(logs).to.be.empty; }); it('should NOT remove source any from the whitelist', async function () { - expect(await oracle._whitelist.call(0)).to.eq(source.address); - expect(await oracle._whitelist.call(1)).to.eq(source2.address); + expect(await oracle.whitelist.call(0)).to.eq(source.address); + expect(await oracle.whitelist.call(1)).to.eq(source2.address); (await oracle.whitelistSize.call()).should.be.bignumber.eq(2); }); }); @@ -249,7 +249,7 @@ contract('MarketOracle:removeDestructedSources', async function (accounts) { }); it('should remove the dead source from the whitelist', async function () { - expect(await oracle._whitelist.call(0)).to.eq(source.address); + expect(await oracle.whitelist.call(0)).to.eq(source.address); (await oracle.whitelistSize.call()).should.be.bignumber.eq(1); }); }); @@ -270,8 +270,8 @@ contract('MarketOracle:removeDestructedSources', async function (accounts) { expect(logs).to.be.empty; }); it('should NOT remove any source from the whitelist', async function () { - expect(await oracle._whitelist.call(0)).to.eq(source.address); - expect(await oracle._whitelist.call(1)).to.eq(source2.address); + expect(await oracle.whitelist.call(0)).to.eq(source.address); + expect(await oracle.whitelist.call(1)).to.eq(source2.address); (await oracle.whitelistSize.call()).should.be.bignumber.eq(2); }); }); diff --git a/test/unit/market_source.js b/test/unit/market_source.js index 4108bfd..500ccfa 100644 --- a/test/unit/market_source.js +++ b/test/unit/market_source.js @@ -30,11 +30,11 @@ contract('MarketSource:initialization', async function (accounts) { }); it('should set the name', async function () { - expect(await source._name.call()).to.eq('GDAX'); + expect(await source.name.call()).to.eq('GDAX'); }); it('should set the expiration time', async function () { - (await source._reportExpirationTimeSec.call()).should.be.bignumber.eq(600); + (await source.reportExpirationTimeSec.call()).should.be.bignumber.eq(600); }); }); diff --git a/test/unit/market_source_factory.js b/test/unit/market_source_factory.js index 0597295..62be23b 100644 --- a/test/unit/market_source_factory.js +++ b/test/unit/market_source_factory.js @@ -35,8 +35,8 @@ contract('MarketSourceFactory', async function (accounts) { it('should transfer ownership to sender', async function () { const marketSource = MarketSource.at(sourceContractAddr); expect(await marketSource.owner.call()).to.eq(A); - expect(await marketSource._name.call()).to.eq('GDAX'); - (await marketSource._reportExpirationTimeSec.call()).should.be.bignumber.eq(3600); + expect(await marketSource.name.call()).to.eq('GDAX'); + (await marketSource.reportExpirationTimeSec.call()).should.be.bignumber.eq(3600); }); }); });