Skip to content

Commit f5c1963

Browse files
committedOct 22, 2019
add prettier
test in typescript add GPL license pin solc version add CI
1 parent 9c4b7cc commit f5c1963

15 files changed

+1008
-380
lines changed
 

‎.circleci/config.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
version: 2
2+
jobs:
3+
build:
4+
docker:
5+
- image: circleci/node:10
6+
steps:
7+
- checkout
8+
9+
- restore_cache:
10+
keys:
11+
- v1-dependencies-{{ checksum "package.json" }}
12+
- v1-dependencies-
13+
14+
- run: yarn
15+
16+
- save_cache:
17+
key: v1-dependencies-{{ checksum "package.json" }}
18+
paths:
19+
- node_modules
20+
21+
- run: yarn prettier:check
22+
23+
- run: yarn compile
24+
25+
- run: yarn test

‎.gitattributes

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
*.sol linguist-language=Solidity
1+
*.sol linguist-language=Solidity

‎.gitignore

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
node_modules/
2-
build/
1+
build/

‎.mocharc.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"extension": ["ts"],
3+
"spec": "./test/**/*.ts",
4+
"require": "ts-node/register"
5+
}

‎.prettierrc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"semi": false,
3+
"singleQuote": true,
4+
"printWidth": 120
5+
}

‎LICENSE

+674
Large diffs are not rendered by default.

‎README.md

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1-
## Installation:
1+
# Uniswap v2 Smart Contracts
2+
3+
## Development
4+
5+
### Clone
26

3-
1) Clone Uniswap
47
```
5-
$ git clone https://github.com/Uniswap/uniswap-v2
6-
$ cd uniswap-v2
8+
git clone https://github.com/Uniswap/uniswap-v2.git
9+
cd uniswap-v2
710
```
811

9-
2) Install dependencies
12+
### Install Dependencies
1013
```
1114
yarn
1215
```
1316

14-
3) Run tests
17+
### Compile Contracts and Run Tests
1518
```
19+
yarn compile
1620
yarn test
1721
```

‎package.json

+16-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
11
{
2+
"engines": {
3+
"node": "^10"
4+
},
25
"dependencies": {
3-
"solc": "^0.5.11"
6+
"solc": "0.5.12"
47
},
58
"devDependencies": {
9+
"@types/chai": "^4.2.3",
10+
"@types/mocha": "^5.2.7",
611
"chai": "^4.2.0",
712
"ethereum-waffle": "^2.1.0",
8-
"mocha": "^6.2.0"
13+
"mocha": "^6.2.2",
14+
"prettier": "^1.18.2",
15+
"ts-node": "^8.4.1",
16+
"typescript": "^3.6.4"
917
},
1018
"scripts": {
11-
"test": "waffle && mocha"
12-
}
19+
"prettier:check": "yarn prettier ./test/*.ts --check",
20+
"prettier:write": "yarn prettier ./test/*.ts --write",
21+
"compile": "rm -rf ./build/ && waffle waffle.json",
22+
"test": "mocha"
23+
},
24+
"license": "GPL-3.0-or-later"
1325
}

‎test/testExchange.js

Whitespace-only changes.

‎test/testFactory.js

Whitespace-only changes.

‎test/testToken.js

-47
This file was deleted.

‎test/testToken.ts

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import chai from 'chai'
2+
import { createMockProvider, deployContract, getWallets, solidity } from 'ethereum-waffle'
3+
import { Contract } from 'ethers'
4+
5+
import TestTokenMock from '../build/TestERC20.json'
6+
7+
chai.use(solidity)
8+
const { expect } = chai
9+
10+
describe('INTEGRATION: Example', () => {
11+
const provider = createMockProvider()
12+
const [wallet, walletTo] = getWallets(provider)
13+
let token: Contract
14+
15+
beforeEach(async () => {
16+
token = await deployContract(wallet, TestTokenMock, ['HayCoin', 'HAY', 18, 1000])
17+
})
18+
19+
it('Is named HayCoin', async () => {
20+
expect(await token.name()).to.eq('HayCoin')
21+
})
22+
23+
it('Assigns initial balance', async () => {
24+
expect(await token.balanceOf(wallet.address)).to.eq(1000)
25+
})
26+
27+
it('Transfer adds amount to destination account', async () => {
28+
await token.transfer(walletTo.address, 7)
29+
expect(await token.balanceOf(walletTo.address)).to.eq(7)
30+
})
31+
32+
it('Transfer emits event', async () => {
33+
await expect(token.transfer(walletTo.address, 7))
34+
.to.emit(token, 'Transfer')
35+
.withArgs(wallet.address, walletTo.address, 7)
36+
})
37+
38+
it('Can not transfer above the amount', async () => {
39+
await expect(token.transfer(walletTo.address, 1007)).to.be.reverted
40+
})
41+
42+
it('Can not transfer from empty account', async () => {
43+
const tokenFromOtherWallet = token.connect(walletTo)
44+
await expect(tokenFromOtherWallet.transfer(wallet.address, 1)).to.be.reverted
45+
})
46+
})

‎tsconfig.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es5",
4+
"module": "commonjs",
5+
"strict": true,
6+
"esModuleInterop": true,
7+
"resolveJsonModule": true
8+
}
9+
}

‎waffle.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"solcVersion": "./node_modules/solc"
3+
}

‎yarn.lock

+213-320
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.