Skip to content

Commit 0897c5b

Browse files
authored
Merge pull request #62 from Uniswap/prepare-for-npm
Prepare for deploying the contracts and build artifacts to npmjs
2 parents 843d02b + 1d583b6 commit 0897c5b

5 files changed

+307
-589
lines changed

.waffle.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"solcVersion": "./node_modules/solc",
2+
"compilerVersion": "./node_modules/solc",
33
"outputType": "all",
44
"compilerOptions": {
55
"outputSelection": {

package.json

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
{
2+
"name": "@uniswap/v2-core",
3+
"version": "1.0.0-beta.0",
4+
"files": [
5+
"contracts",
6+
"build"
7+
],
28
"engines": {
39
"node": ">=10"
410
},
511
"devDependencies": {
612
"@types/chai": "^4.2.6",
713
"@types/mocha": "^5.2.7",
814
"chai": "^4.2.0",
9-
"ethereum-waffle": "^2.3.1",
15+
"ethereum-waffle": "^2.4.1",
1016
"ethereumjs-util": "^6.2.0",
1117
"mocha": "^6.2.2",
1218
"prettier": "^1.19.1",
@@ -17,12 +23,14 @@
1723
},
1824
"scripts": {
1925
"lint": "yarn prettier ./test/*.ts --check",
26+
"lint:fix": "yarn prettier ./test/*.ts --write",
2027
"clean": "rimraf ./build/",
2128
"precompile": "yarn clean",
2229
"compile": "waffle .waffle.json",
2330
"pretest": "yarn compile",
2431
"test": "mocha",
25-
"check-compile-output": "./scripts/check-compile-output.sh"
32+
"check-compile-output": "./scripts/check-compile-output.sh",
33+
"prepublishOnly": "yarn compile"
2634
},
2735
"license": "GPL-3.0-or-later"
2836
}

test/UniswapV2Factory.spec.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -66,20 +66,21 @@ describe('UniswapV2Factory', () => {
6666
})
6767

6868
it('createPair:gas', async () => {
69-
const gasCost = await factory.estimate.createPair(...TEST_ADDRESSES)
70-
expect(gasCost).to.eq(2513232)
69+
const tx = await factory.createPair(...TEST_ADDRESSES)
70+
const receipt = await tx.wait()
71+
expect(receipt.gasUsed).to.eq(2512920)
7172
})
7273

7374
it('setFeeTo', async () => {
74-
await expect(factory.connect(other).setFeeTo(other.address)).to.be.reverted // UniswapV2: FORBIDDEN
75+
await expect(factory.connect(other).setFeeTo(other.address)).to.be.revertedWith('UniswapV2: FORBIDDEN')
7576
await factory.setFeeTo(wallet.address)
7677
expect(await factory.feeTo()).to.eq(wallet.address)
7778
})
7879

7980
it('setFeeToSetter', async () => {
80-
await expect(factory.connect(other).setFeeToSetter(other.address)).to.be.reverted // UniswapV2: FORBIDDEN
81+
await expect(factory.connect(other).setFeeToSetter(other.address)).to.be.revertedWith('UniswapV2: FORBIDDEN')
8182
await factory.setFeeToSetter(other.address)
8283
expect(await factory.feeToSetter()).to.eq(other.address)
83-
await expect(factory.setFeeToSetter(wallet.address)).to.be.reverted // UniswapV2: FORBIDDEN
84+
await expect(factory.setFeeToSetter(wallet.address)).to.be.revertedWith('UniswapV2: FORBIDDEN')
8485
})
8586
})

test/UniswapV2Pair.spec.ts

+9-10
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,8 @@ describe('UniswapV2Pair', () => {
4646
await expect(pair.mint(wallet.address, overrides))
4747
.to.emit(pair, 'Transfer')
4848
.withArgs(AddressZero, AddressZero, MINIMUM_LIQUIDITY)
49-
// commented out because of this bug: https://github.com/EthWorks/Waffle/issues/100
50-
// .to.emit(pair, 'Transfer')
51-
// .withArgs(AddressZero, wallet.address, expectedLiquidity.sub(MINIMUM_LIQUIDITY))
49+
.to.emit(pair, 'Transfer')
50+
.withArgs(AddressZero, wallet.address, expectedLiquidity.sub(MINIMUM_LIQUIDITY))
5251
.to.emit(pair, 'Sync')
5352
.withArgs(token0Amount, token1Amount)
5453
.to.emit(pair, 'Mint')
@@ -176,8 +175,9 @@ describe('UniswapV2Pair', () => {
176175
const expectedOutputAmount = bigNumberify('453305446940074565')
177176
await token1.transfer(pair.address, swapAmount)
178177
await mineBlock(provider, (await provider.getBlock('latest')).timestamp + 1)
179-
const gasCost = await pair.estimate.swap(expectedOutputAmount, 0, wallet.address, '0x', overrides)
180-
expect(gasCost).to.eq(79378)
178+
const tx = await pair.swap(expectedOutputAmount, 0, wallet.address, '0x', overrides)
179+
const receipt = await tx.wait()
180+
expect(receipt.gasUsed).to.eq(73462)
181181
})
182182

183183
it('burn', async () => {
@@ -190,11 +190,10 @@ describe('UniswapV2Pair', () => {
190190
await expect(pair.burn(wallet.address, overrides))
191191
.to.emit(pair, 'Transfer')
192192
.withArgs(pair.address, AddressZero, expectedLiquidity.sub(MINIMUM_LIQUIDITY))
193-
// commented out because of this bug: https://github.com/EthWorks/Waffle/issues/100
194-
// .to.emit(token0, 'Transfer')
195-
// .withArgs(pair.address, wallet.address, token0Amount.sub(1000))
196-
// .to.emit(token1, 'Transfer')
197-
// .withArgs(pair.address, wallet.address, token1Amount.sub(1000))
193+
.to.emit(token0, 'Transfer')
194+
.withArgs(pair.address, wallet.address, token0Amount.sub(1000))
195+
.to.emit(token1, 'Transfer')
196+
.withArgs(pair.address, wallet.address, token1Amount.sub(1000))
198197
.to.emit(pair, 'Sync')
199198
.withArgs(1000, 1000)
200199
.to.emit(pair, 'Burn')

0 commit comments

Comments
 (0)