From 29edd4e15e91e22e466187354c4c13413e28baaf Mon Sep 17 00:00:00 2001 From: Matt Condon Date: Thu, 4 Jan 2018 13:42:22 -0600 Subject: [PATCH 1/4] feat: implement issue and pr templates --- .github/ISSUE_TEMPLATE.md | 33 ++++++++++++++++++++++++++++++++ .github/PULL_REQUEST_TEMPLATE.md | 17 ++++++++++++++++ CONTRIBUTING.md | 2 ++ 3 files changed, 52 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 000000000..fec4b7938 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,33 @@ +## The Problem + +[] 🐛 This is a bug report. +[] 📈 This is a feature request. + + + +Briefly describe the issue you are experiencing (or the feature you want to see added to OpenZeppelin). Tell us what you were trying to do and what happened instead. **Remember, this is _not_ a place to ask for help debugging code; for that, we welcome you in the [OpenZeppelin Slack Channel](https://slack.openzeppelin.org/).** + +## 💻 Environment + +First, we need to know what your environment looks like. + +- Which version of OpenZeppelin are you using? +- What network are you deploying to? testrpc? Ganache? Ropsten? +- How are you deploying your OpenZeppelin-backed contracts? truffle? Remix? Let us know! + +## 📝 Details + +Describe the problem you have been experiencing in more detail. Include as much information as you think is relevant. Keep in mind that transactions can fail for many reasons; context is key here. + +## 🔢 Code To Reproduce Issue [ Good To Have ] + +Please remember that with sample code it's easier to reproduce the bug and it's much faster to fix it. + +``` +insert short code snippets here +``` + + + +## 👍 Other Information + diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 000000000..094c94ca1 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,17 @@ + + +- [ ] 📘 I've reviewed the [OpenZeppelin Contributor Guidelines](/docs/CONTRIBUTING.md) +- [ ] ✅ I've added tests where applicable to test my new functionality. +- [ ] 📖 I've made sure that my contracts are well-documented. +- [ ] 🎨 I've run the JavaScript linter (`npm run lint:fix`) and fixed all issues. + + + +Fixes # + +--- + +# 🚀 Description + + + \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b7a7d71d6..389c02c26 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -80,6 +80,8 @@ git checkout -b fix/some-bug git checkout -b remove/some-file ``` +If your branch is planned to fix an open issue, postfix your branch name with the issue number like `fix/some-bug-#123`. + We expect pull requests to be rebased to the master branch before merging: ```sh git remote add zep git@github.com:OpenZeppelin/zeppelin-solidity.git From 6cd84ffceb9787ea051b8b2747ffdd3e7295b62d Mon Sep 17 00:00:00 2001 From: Matt Condon Date: Fri, 5 Jan 2018 10:18:05 -0600 Subject: [PATCH 2/4] feat: add 'npm run lint:fix' script --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 793afa4cb..c79c109d1 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "scripts": { "test": "scripts/test.sh", "lint": "eslint .", + "lint:fix": "eslint . --fix", "console": "truffle console", "coverage": "scripts/coverage.sh" }, From 17884e91a1cf9b3f243fe6e3fcd7141f700cec6e Mon Sep 17 00:00:00 2001 From: Facundo Spagnuolo Date: Tue, 9 Jan 2018 12:25:50 -0300 Subject: [PATCH 3/4] Emit Trasnfer event on SimpleToken creation --- contracts/examples/SimpleToken.sol | 1 + test/SimpleToken.test.js | 41 ++++++++++++++++++++++++++++++ test/helpers/decodeLogs.js | 8 ++++++ 3 files changed, 50 insertions(+) create mode 100644 test/SimpleToken.test.js create mode 100644 test/helpers/decodeLogs.js diff --git a/contracts/examples/SimpleToken.sol b/contracts/examples/SimpleToken.sol index 51edf0873..f7cf62413 100644 --- a/contracts/examples/SimpleToken.sol +++ b/contracts/examples/SimpleToken.sol @@ -24,6 +24,7 @@ contract SimpleToken is StandardToken { function SimpleToken() public { totalSupply = INITIAL_SUPPLY; balances[msg.sender] = INITIAL_SUPPLY; + Transfer(0x0, msg.sender, INITIAL_SUPPLY); } } diff --git a/test/SimpleToken.test.js b/test/SimpleToken.test.js new file mode 100644 index 000000000..9a1870f20 --- /dev/null +++ b/test/SimpleToken.test.js @@ -0,0 +1,41 @@ +import decodeLogs from './helpers/decodeLogs'; +const SimpleToken = artifacts.require('examples/SimpleToken.sol'); + +contract('SimpleToken', accounts => { + let token; + const creator = accounts[0]; + + beforeEach(async function () { + token = await SimpleToken.new({ from: creator }); + }); + + it('has a name', async function () { + const name = await token.name(); + assert.equal(name, 'SimpleToken'); + }); + + it('has a symbol', async function () { + const symbol = await token.symbol(); + assert.equal(symbol, 'SIM'); + }); + + it('has 18 decimals', async function () { + const decimals = await token.decimals(); + assert(decimals.eq(18)); + }); + + it('assigns the initial total supply to the creator', async function () { + const totalSupply = await token.totalSupply(); + const creatorBalance = await token.balanceOf(creator); + + assert(creatorBalance.eq(totalSupply)); + + const receipt = web3.eth.getTransactionReceipt(token.transactionHash); + const logs = decodeLogs(receipt.logs, SimpleToken, token.address); + assert.equal(logs.length, 1); + assert.equal(logs[0].event, 'Transfer'); + assert.equal(logs[0].args.from.valueOf(), 0x0); + assert.equal(logs[0].args.to.valueOf(), creator); + assert(logs[0].args.value.eq(totalSupply)); + }); +}); diff --git a/test/helpers/decodeLogs.js b/test/helpers/decodeLogs.js new file mode 100644 index 000000000..c990eedcb --- /dev/null +++ b/test/helpers/decodeLogs.js @@ -0,0 +1,8 @@ +const SolidityEvent = require('web3/lib/web3/event.js'); + +export default function decodeLogs (logs, contract, address) { + return logs.map(log => { + const event = new SolidityEvent(null, contract.events[log.topics[0]], address); + return event.decode(log); + }); +} From a58e3e151a199c5adb4465027da0ccfe439e8921 Mon Sep 17 00:00:00 2001 From: Matt Condon Date: Wed, 10 Jan 2018 15:08:23 -0500 Subject: [PATCH 4/4] fixup: pr template mdown syntax --- .github/ISSUE_TEMPLATE.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index fec4b7938..68bd73a74 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,7 +1,7 @@ ## The Problem -[] 🐛 This is a bug report. -[] 📈 This is a feature request. +- [ ] 🐛 This is a bug report. +- [ ] 📈 This is a feature request.