Skip to content
This repository has been archived by the owner on Oct 14, 2021. It is now read-only.

Commit

Permalink
Merge pull request #62 from Uniswap/prepare-for-npm
Browse files Browse the repository at this point in the history
Prepare for deploying the contracts and build artifacts to npmjs
  • Loading branch information
moodysalem authored Apr 15, 2020
2 parents 843d02b + 1d583b6 commit 0897c5b
Show file tree
Hide file tree
Showing 5 changed files with 307 additions and 589 deletions.
2 changes: 1 addition & 1 deletion .waffle.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"solcVersion": "./node_modules/solc",
"compilerVersion": "./node_modules/solc",
"outputType": "all",
"compilerOptions": {
"outputSelection": {
Expand Down
12 changes: 10 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
{
"name": "@uniswap/v2-core",
"version": "1.0.0-beta.0",
"files": [
"contracts",
"build"
],
"engines": {
"node": ">=10"
},
"devDependencies": {
"@types/chai": "^4.2.6",
"@types/mocha": "^5.2.7",
"chai": "^4.2.0",
"ethereum-waffle": "^2.3.1",
"ethereum-waffle": "^2.4.1",
"ethereumjs-util": "^6.2.0",
"mocha": "^6.2.2",
"prettier": "^1.19.1",
Expand All @@ -17,12 +23,14 @@
},
"scripts": {
"lint": "yarn prettier ./test/*.ts --check",
"lint:fix": "yarn prettier ./test/*.ts --write",
"clean": "rimraf ./build/",
"precompile": "yarn clean",
"compile": "waffle .waffle.json",
"pretest": "yarn compile",
"test": "mocha",
"check-compile-output": "./scripts/check-compile-output.sh"
"check-compile-output": "./scripts/check-compile-output.sh",
"prepublishOnly": "yarn compile"
},
"license": "GPL-3.0-or-later"
}
11 changes: 6 additions & 5 deletions test/UniswapV2Factory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,21 @@ describe('UniswapV2Factory', () => {
})

it('createPair:gas', async () => {
const gasCost = await factory.estimate.createPair(...TEST_ADDRESSES)
expect(gasCost).to.eq(2513232)
const tx = await factory.createPair(...TEST_ADDRESSES)
const receipt = await tx.wait()
expect(receipt.gasUsed).to.eq(2512920)
})

it('setFeeTo', async () => {
await expect(factory.connect(other).setFeeTo(other.address)).to.be.reverted // UniswapV2: FORBIDDEN
await expect(factory.connect(other).setFeeTo(other.address)).to.be.revertedWith('UniswapV2: FORBIDDEN')
await factory.setFeeTo(wallet.address)
expect(await factory.feeTo()).to.eq(wallet.address)
})

it('setFeeToSetter', async () => {
await expect(factory.connect(other).setFeeToSetter(other.address)).to.be.reverted // UniswapV2: FORBIDDEN
await expect(factory.connect(other).setFeeToSetter(other.address)).to.be.revertedWith('UniswapV2: FORBIDDEN')
await factory.setFeeToSetter(other.address)
expect(await factory.feeToSetter()).to.eq(other.address)
await expect(factory.setFeeToSetter(wallet.address)).to.be.reverted // UniswapV2: FORBIDDEN
await expect(factory.setFeeToSetter(wallet.address)).to.be.revertedWith('UniswapV2: FORBIDDEN')
})
})
19 changes: 9 additions & 10 deletions test/UniswapV2Pair.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ describe('UniswapV2Pair', () => {
await expect(pair.mint(wallet.address, overrides))
.to.emit(pair, 'Transfer')
.withArgs(AddressZero, AddressZero, MINIMUM_LIQUIDITY)
// commented out because of this bug: https://github.com/EthWorks/Waffle/issues/100
// .to.emit(pair, 'Transfer')
// .withArgs(AddressZero, wallet.address, expectedLiquidity.sub(MINIMUM_LIQUIDITY))
.to.emit(pair, 'Transfer')
.withArgs(AddressZero, wallet.address, expectedLiquidity.sub(MINIMUM_LIQUIDITY))
.to.emit(pair, 'Sync')
.withArgs(token0Amount, token1Amount)
.to.emit(pair, 'Mint')
Expand Down Expand Up @@ -176,8 +175,9 @@ describe('UniswapV2Pair', () => {
const expectedOutputAmount = bigNumberify('453305446940074565')
await token1.transfer(pair.address, swapAmount)
await mineBlock(provider, (await provider.getBlock('latest')).timestamp + 1)
const gasCost = await pair.estimate.swap(expectedOutputAmount, 0, wallet.address, '0x', overrides)
expect(gasCost).to.eq(79378)
const tx = await pair.swap(expectedOutputAmount, 0, wallet.address, '0x', overrides)
const receipt = await tx.wait()
expect(receipt.gasUsed).to.eq(73462)
})

it('burn', async () => {
Expand All @@ -190,11 +190,10 @@ describe('UniswapV2Pair', () => {
await expect(pair.burn(wallet.address, overrides))
.to.emit(pair, 'Transfer')
.withArgs(pair.address, AddressZero, expectedLiquidity.sub(MINIMUM_LIQUIDITY))
// commented out because of this bug: https://github.com/EthWorks/Waffle/issues/100
// .to.emit(token0, 'Transfer')
// .withArgs(pair.address, wallet.address, token0Amount.sub(1000))
// .to.emit(token1, 'Transfer')
// .withArgs(pair.address, wallet.address, token1Amount.sub(1000))
.to.emit(token0, 'Transfer')
.withArgs(pair.address, wallet.address, token0Amount.sub(1000))
.to.emit(token1, 'Transfer')
.withArgs(pair.address, wallet.address, token1Amount.sub(1000))
.to.emit(pair, 'Sync')
.withArgs(1000, 1000)
.to.emit(pair, 'Burn')
Expand Down
Loading

0 comments on commit 0897c5b

Please sign in to comment.