diff options
author | Kadinsky <kandinsky454@protonmail.ch> | 2018-10-16 21:21:46 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-16 21:21:46 +0800 |
commit | e62458705039f6a187ff23e4e4ee1737476eb431 (patch) | |
tree | 27497ebaf0e7da27561620b28b28cc30833261fc /packages/contract-addresses | |
parent | 05bf7a8280bcb46144dfef9b30bb7c0e2e4a15aa (diff) | |
parent | 5938e8a52daa913668593977e44ca25e38a29e41 (diff) | |
download | dexon-sol-tools-e62458705039f6a187ff23e4e4ee1737476eb431.tar dexon-sol-tools-e62458705039f6a187ff23e4e4ee1737476eb431.tar.gz dexon-sol-tools-e62458705039f6a187ff23e4e4ee1737476eb431.tar.bz2 dexon-sol-tools-e62458705039f6a187ff23e4e4ee1737476eb431.tar.lz dexon-sol-tools-e62458705039f6a187ff23e4e4ee1737476eb431.tar.xz dexon-sol-tools-e62458705039f6a187ff23e4e4ee1737476eb431.tar.zst dexon-sol-tools-e62458705039f6a187ff23e4e4ee1737476eb431.zip |
Merge pull request #1105 from 0xProject/feature/contracts-artifacts-re-org
Reorganize and modularize generated contract wrappers and artifacts
Diffstat (limited to 'packages/contract-addresses')
-rw-r--r-- | packages/contract-addresses/CHANGELOG.json | 11 | ||||
-rw-r--r-- | packages/contract-addresses/README.md | 69 | ||||
-rw-r--r-- | packages/contract-addresses/package.json | 37 | ||||
-rw-r--r-- | packages/contract-addresses/src/index.ts | 66 | ||||
-rw-r--r-- | packages/contract-addresses/tsconfig.json | 8 | ||||
-rw-r--r-- | packages/contract-addresses/tslint.json | 3 |
6 files changed, 194 insertions, 0 deletions
diff --git a/packages/contract-addresses/CHANGELOG.json b/packages/contract-addresses/CHANGELOG.json new file mode 100644 index 000000000..d91ad0b36 --- /dev/null +++ b/packages/contract-addresses/CHANGELOG.json @@ -0,0 +1,11 @@ +[ + { + "version": "1.0.0", + "changes": [ + { + "pr": 1105, + "note": "Initial release" + } + ] + } +] diff --git a/packages/contract-addresses/README.md b/packages/contract-addresses/README.md new file mode 100644 index 000000000..6c615c422 --- /dev/null +++ b/packages/contract-addresses/README.md @@ -0,0 +1,69 @@ +## @0xproject/contract-addresses + +A tiny utility library for getting known deployed contract addresses for a +particular network. + +## Installation + +```bash +yarn add @0xproject/contract-addresses +``` + +**Import** + +```typescript +import { getContractAddressesForNetworkOrThrow } from '@0xproject/contract-addresses'; +``` + +or + +```javascript +var getContractAddressesForNetworkOrThrow = require('@0xproject/contract-addresses') + .getContractAddressesForNetworkOrThrow; +``` + +## Contributing + +We welcome improvements and fixes from the wider community! To report bugs within this package, please create an issue in this repository. + +Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started. + +### Install dependencies + +If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them: + +```bash +yarn config set workspaces-experimental true +``` + +Then install dependencies + +```bash +yarn install +``` + +### Build + +To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory: + +```bash +PKG=@0xproject/contract-addresses yarn build +``` + +### Clean + +```bash +yarn clean +``` + +### Lint + +```bash +yarn lint +``` + +### Run Tests + +```bash +yarn test +``` diff --git a/packages/contract-addresses/package.json b/packages/contract-addresses/package.json new file mode 100644 index 000000000..60642224f --- /dev/null +++ b/packages/contract-addresses/package.json @@ -0,0 +1,37 @@ +{ + "name": "@0xproject/contract-addresses", + "version": "1.0.0", + "engines": { + "node": ">=6.12" + }, + "description": "Used to get known addresses of deployed 0x contracts", + "main": "lib/src/index.js", + "directories": { + "test": "test" + }, + "scripts": { + "build": "yarn tsc -b", + "build:ci": "yarn build", + "clean": "shx rm -rf lib" + }, + "repository": { + "type": "git", + "url": "https://github.com/0xProject/0x-monorepo.git" + }, + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/0xProject/0x-monorepo/issues" + }, + "homepage": "https://github.com/0xProject/0x-monorepo/packages/contract-addresses/README.md", + "devDependencies": { + "@types/lodash": "4.14.104", + "typescript": "3.0.1", + "shx": "^0.2.2" + }, + "dependencies": { + "lodash": "^4.17.5" + }, + "publishConfig": { + "access": "public" + } +} diff --git a/packages/contract-addresses/src/index.ts b/packages/contract-addresses/src/index.ts new file mode 100644 index 000000000..1ea8c61dd --- /dev/null +++ b/packages/contract-addresses/src/index.ts @@ -0,0 +1,66 @@ +import * as _ from 'lodash'; + +export interface ContractAddresses { + erc20Proxy: string; + erc721Proxy: string; + zrxToken: string; + etherToken: string; + exchange: string; + assetProxyOwner: string; + forwarder: string; + orderValidator: string; +} + +export enum NetworkId { + Mainnet = 1, + Ropsten = 3, + Kovan = 42, +} + +const networkToAddresses: { [networkId: number]: ContractAddresses } = { + 1: { + erc20Proxy: '0x2240dab907db71e64d3e0dba4800c83b5c502d4e', + erc721Proxy: '0x208e41fb445f1bb1b6780d58356e81405f3e6127', + zrxToken: '0xe41d2489571d322189246dafa5ebde1f4699f498', + etherToken: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', + exchange: '0x4f833a24e1f95d70f028921e27040ca56e09ab0b', + assetProxyOwner: '0x17992e4ffb22730138e4b62aaa6367fa9d3699a6', + forwarder: '0x7afc2d5107af94c462a194d2c21b5bdd238709d6', + orderValidator: '0x9463e518dea6810309563c81d5266c1b1d149138', + }, + 3: { + erc20Proxy: '0xb1408f4c245a23c31b98d2c626777d4c0d766caa', + erc721Proxy: '0xe654aac058bfbf9f83fcaee7793311dd82f6ddb4', + zrxToken: '0xff67881f8d12f372d91baae9752eb3631ff0ed00', + etherToken: '0xc778417e063141139fce010982780140aa0cd5ab', + exchange: '0x4530c0483a1633c7a1c97d2c53721caff2caaaaf', + assetProxyOwner: '0xf5fa5b5fed2727a0e44ac67f6772e97977aa358b', + forwarder: '0x3983e204b12b3c02fb0638caf2cd406a62e0ead3', + orderValidator: '0x90431a90516ab49af23a0530e04e8c7836e7122f', + }, + 42: { + erc20Proxy: '0xf1ec01d6236d3cd881a0bf0130ea25fe4234003e', + erc721Proxy: '0x2a9127c745688a165106c11cd4d647d2220af821', + zrxToken: '0x2002d3812f58e35f0ea1ffbf80a75a38c32175fa', + etherToken: '0xd0a1e359811322d97991e03f863a0c30c2cf029c', + exchange: '0x35dd2932454449b14cee11a94d3674a936d5d7b2', + assetProxyOwner: '0x2c824d2882baa668e0d5202b1e7f2922278703f8', + forwarder: '0xd85e2fa7e7e252b27b01bf0d65c946959d2f45b8', + orderValidator: '0xb389da3d204b412df2f75c6afb3d0a7ce0bc283d', + }, +}; + +/** + * Used to get addresses of contracts that have been deployed to either the + * Ethereum mainnet or a supported testnet. Throws if there are no known + * contracts deployed on the corresponding network. + * @param networkId The desired networkId. + * @returns The set of addresses for contracts which have been deployed on the + * given networkId. + */ +export function getContractAddressesForNetworkOrThrow(networkId: NetworkId): ContractAddresses { + if (_.isUndefined(networkToAddresses[networkId])) { + throw new Error(`Unknown network id (${networkId}). No known 0x contracts have been deployed on this network.`); + } + return networkToAddresses[networkId]; +} diff --git a/packages/contract-addresses/tsconfig.json b/packages/contract-addresses/tsconfig.json new file mode 100644 index 000000000..233008d61 --- /dev/null +++ b/packages/contract-addresses/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../tsconfig", + "compilerOptions": { + "outDir": "lib", + "rootDir": "." + }, + "include": ["./src/**/*"] +} diff --git a/packages/contract-addresses/tslint.json b/packages/contract-addresses/tslint.json new file mode 100644 index 000000000..ffaefe83a --- /dev/null +++ b/packages/contract-addresses/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": ["@0xproject/tslint-config"] +} |