forked from OpenZeppelin/openzeppelin-contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
103 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
## The Problem | ||
|
||
- [ ] 🐛 This is a bug report. | ||
- [ ] 📈 This is a feature request. | ||
|
||
<!-- Please check one of the above by placing an x in the box. --> | ||
|
||
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 | ||
``` | ||
|
||
<!-- If your code is larger, consider linking us to a repo illustrating your issue. --> | ||
|
||
## 👍 Other Information | ||
<!-- List any other information that is relevant to your issue. Error logs, related issues, suggestions on how to fix, Stack Overflow links, forum links, etc. --> |
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,17 @@ | ||
<!-- 🎉 Thank you for submitting a PR! Before submitting, please review the following checklist: --> | ||
|
||
- [ ] 📘 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. | ||
|
||
<!-- **Does this close any open issues?** If so, list them here. --> | ||
|
||
Fixes # | ||
|
||
--- | ||
|
||
# 🚀 Description | ||
|
||
<!-- Describe the changes introduced in this pull request --> | ||
<!-- Include any context necessary for understanding the PR's purpose. --> |
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
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,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)); | ||
}); | ||
}); |
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,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); | ||
}); | ||
} |