forked from Uniswap/sdk-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update the init code hash, other small tweaks (Uniswap#19)
* Update the init code hash, other small tweaks * Lint * Use pair ABI instead of token ABI to get reserves * Update package description Set the prototype of our custom errors * codepoints -> emoji * skip the data tests * Factory address, fix checksum warning Co-authored-by: Noah Zinsmeister <[email protected]>
- Loading branch information
1 parent
c08d9a2
commit 5826a6d
Showing
10 changed files
with
52 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
dist | ||
dist | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,6 @@ | |
[](https://github.com/prettier/prettier) | ||
[](https://github.com/Uniswap/uniswap-sdk) | ||
[](https://www.npmjs.com/package/@uniswap/sdk/v/next) | ||
[](https://bundlephobia.com/result?p=@uniswap/[email protected]) | ||
|
||
In-depth documentation on this SDK is available at [uniswap.org](https://uniswap.org/docs/v2/SDK/getting-started/). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,18 @@ | ||
// see https://stackoverflow.com/a/41102306 | ||
const CAN_SET_PROTOTYPE = 'setPrototypeOf' in Object | ||
|
||
export class InsufficientReservesError extends Error { | ||
public constructor() { | ||
super() | ||
this.name = this.constructor.name | ||
if (CAN_SET_PROTOTYPE) Object.setPrototypeOf(this, new.target.prototype) | ||
} | ||
} | ||
|
||
export class InsufficientInputAmountError extends Error { | ||
public constructor() { | ||
super() | ||
this.name = this.constructor.name | ||
if (CAN_SET_PROTOTYPE) Object.setPrototypeOf(this, new.target.prototype) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { INIT_CODE_HASH } from '../src/constants' | ||
|
||
import { bytecode } from '@uniswap/v2-core/build/UniswapV2Pair.json' | ||
import { keccak256 } from '@ethersproject/solidity' | ||
|
||
// this _could_ go in constants, except that it would cost every consumer of the sdk the CPU to compute the hash | ||
// and load the JSON. | ||
const COMPUTED_INIT_CODE_HASH = keccak256(['bytes'], [`0x${bytecode}`]) | ||
|
||
describe('constants', () => { | ||
describe('INIT_CODE_HASH', () => { | ||
it.only('matches computed bytecode hash', () => { | ||
expect(COMPUTED_INIT_CODE_HASH).toEqual(INIT_CODE_HASH) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Token, Pair } from '../src/entities' | ||
import { ChainId } from '../src/constants' | ||
|
||
describe('Pair', () => { | ||
describe('#getAddress', () => { | ||
it('returns the correct address', () => { | ||
const usdc = new Token(ChainId.MAINNET, '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', 18, 'USDC', 'USD Coin') | ||
const dai = new Token(ChainId.MAINNET, '0x6B175474E89094C44Da98b954EedeAC495271d0F', 18, 'DAI', 'DAI Stablecoin') | ||
expect(Pair.getAddress(usdc, dai)).toEqual('0xAE461cA67B15dc8dc81CE7615e0320dA1A9aB8D5') | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1401,6 +1401,11 @@ | |
semver "^6.3.0" | ||
tsutils "^3.17.1" | ||
|
||
"@uniswap/[email protected]": | ||
version "1.0.0" | ||
resolved "https://registry.yarnpkg.com/@uniswap/v2-core/-/v2-core-1.0.0.tgz#e0fab91a7d53e8cafb5326ae4ca18351116b0844" | ||
integrity sha512-BJiXrBGnN8mti7saW49MXwxDBRFiWemGetE58q8zgfnPPzQKq55ADltEILqOt6VFZ22kVeVKbF8gVd8aY3l7pA== | ||
|
||
abab@^2.0.0: | ||
version "2.0.3" | ||
resolved "https://registry.yarnpkg.com/abab/-/abab-2.0.3.tgz#623e2075e02eb2d3f2475e49f99c91846467907a" | ||
|