Skip to content

Commit

Permalink
add prettier
Browse files Browse the repository at this point in the history
test in typescript

add GPL license

pin solc version

add CI
  • Loading branch information
NoahZinsmeister committed Oct 22, 2019
1 parent 9c4b7cc commit f5c1963
Show file tree
Hide file tree
Showing 15 changed files with 1,008 additions and 380 deletions.
25 changes: 25 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
version: 2
jobs:
build:
docker:
- image: circleci/node:10
steps:
- checkout

- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
- v1-dependencies-

- run: yarn

- save_cache:
key: v1-dependencies-{{ checksum "package.json" }}
paths:
- node_modules

- run: yarn prettier:check

- run: yarn compile

- run: yarn test
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1 @@
*.sol linguist-language=Solidity
*.sol linguist-language=Solidity
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
node_modules/
build/
build/
5 changes: 5 additions & 0 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extension": ["ts"],
"spec": "./test/**/*.ts",
"require": "ts-node/register"
}
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"semi": false,
"singleQuote": true,
"printWidth": 120
}
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
## Installation:
# Uniswap v2 Smart Contracts

## Development

### Clone

1) Clone Uniswap
```
$ git clone https://github.com/Uniswap/uniswap-v2
$ cd uniswap-v2
git clone https://github.com/Uniswap/uniswap-v2.git
cd uniswap-v2
```

2) Install dependencies
### Install Dependencies
```
yarn
```

3) Run tests
### Compile Contracts and Run Tests
```
yarn compile
yarn test
```
20 changes: 16 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
{
"engines": {
"node": "^10"
},
"dependencies": {
"solc": "^0.5.11"
"solc": "0.5.12"
},
"devDependencies": {
"@types/chai": "^4.2.3",
"@types/mocha": "^5.2.7",
"chai": "^4.2.0",
"ethereum-waffle": "^2.1.0",
"mocha": "^6.2.0"
"mocha": "^6.2.2",
"prettier": "^1.18.2",
"ts-node": "^8.4.1",
"typescript": "^3.6.4"
},
"scripts": {
"test": "waffle && mocha"
}
"prettier:check": "yarn prettier ./test/*.ts --check",
"prettier:write": "yarn prettier ./test/*.ts --write",
"compile": "rm -rf ./build/ && waffle waffle.json",
"test": "mocha"
},
"license": "GPL-3.0-or-later"
}
Empty file removed test/testExchange.js
Empty file.
Empty file removed test/testFactory.js
Empty file.
47 changes: 0 additions & 47 deletions test/testToken.js

This file was deleted.

46 changes: 46 additions & 0 deletions test/testToken.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import chai from 'chai'
import { createMockProvider, deployContract, getWallets, solidity } from 'ethereum-waffle'
import { Contract } from 'ethers'

import TestTokenMock from '../build/TestERC20.json'

chai.use(solidity)
const { expect } = chai

describe('INTEGRATION: Example', () => {
const provider = createMockProvider()
const [wallet, walletTo] = getWallets(provider)
let token: Contract

beforeEach(async () => {
token = await deployContract(wallet, TestTokenMock, ['HayCoin', 'HAY', 18, 1000])
})

it('Is named HayCoin', async () => {
expect(await token.name()).to.eq('HayCoin')
})

it('Assigns initial balance', async () => {
expect(await token.balanceOf(wallet.address)).to.eq(1000)
})

it('Transfer adds amount to destination account', async () => {
await token.transfer(walletTo.address, 7)
expect(await token.balanceOf(walletTo.address)).to.eq(7)
})

it('Transfer emits event', async () => {
await expect(token.transfer(walletTo.address, 7))
.to.emit(token, 'Transfer')
.withArgs(wallet.address, walletTo.address, 7)
})

it('Can not transfer above the amount', async () => {
await expect(token.transfer(walletTo.address, 1007)).to.be.reverted
})

it('Can not transfer from empty account', async () => {
const tokenFromOtherWallet = token.connect(walletTo)
await expect(tokenFromOtherWallet.transfer(wallet.address, 1)).to.be.reverted
})
})
9 changes: 9 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"strict": true,
"esModuleInterop": true,
"resolveJsonModule": true
}
}
3 changes: 3 additions & 0 deletions waffle.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"solcVersion": "./node_modules/solc"
}
Loading

0 comments on commit f5c1963

Please sign in to comment.