Merge pull request #62 from Uniswap/prepare-for-npm

Prepare for deploying the contracts and build artifacts to npmjs
This commit is contained in:
Moody Salem
2020-04-15 09:01:33 -04:00
committed by GitHub
5 changed files with 308 additions and 590 deletions

View File

@ -1,5 +1,5 @@
{
"solcVersion": "./node_modules/solc",
"compilerVersion": "./node_modules/solc",
"outputType": "all",
"compilerOptions": {
"outputSelection": {

View File

@ -1,4 +1,10 @@
{
"name": "@uniswap/v2-core",
"version": "1.0.0-beta.0",
"files": [
"contracts",
"build"
],
"engines": {
"node": ">=10"
},
@ -6,7 +12,7 @@
"@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",
@ -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"
}

View File

@ -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')
})
})

View File

@ -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')
@ -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 () => {
@ -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')

854
yarn.lock

File diff suppressed because it is too large Load Diff