Merge branch 'development' into feature/sra-reporter

* development: (79 commits)
  remove from devDeps
  Remove date for now
  Add ethers typescript typings to 0x.js deps. The library works without this atm since another dep of 0x.js has it as a dep. But it's more robust to have it here.
  Add  missing instructions to add external types to tsconfig.json after installing the package
  Fix bugs in postpublish_utils.js
  Update @0xproject/utils in top-level package.json
  Changelog tweaks
  Publish
  Updated CHANGELOGS
  Fix typo
  Add PR number to changelog entry
  Add changelog update to subproviders package
  Add `numberOfAccounts` param to `LedgerSubprovider` method `getAccountsAsync` and add tests
  Remove unnecessary type assertion
  Fix comments
  Add comments
  Don't need any external packages for 0x connect docs yet
  Instead of adding `@0xproject/types` to tsconfig.json, let's only add it when calling TypeDoc
  Fix styling
  Make prettier ignore postpublish_utils
  ...
This commit is contained in:
Brandon Millman 2018-03-05 15:08:56 -08:00
commit d171ce4fba
103 changed files with 1397 additions and 430 deletions

View File

@ -2,3 +2,4 @@ lib
.nyc_output .nyc_output
/packages/contracts/src/artifacts /packages/contracts/src/artifacts
package.json package.json
scripts/postpublish_utils.js

View File

@ -23,7 +23,7 @@ If the sub-package you are modifying has a `CHANGELOG.md` file, make sure to add
### Styleguide ### Styleguide
We use [TSLint](https://palantir.github.io/tslint/) with [custom configs](https://github.com/0xProject/0x.js/tree/development/packages/tslint-config) to keep our code style consistent. We use [TSLint](https://palantir.github.io/tslint/) with [custom configs](https://github.com/0xProject/0x-monorepo/tree/development/packages/tslint-config) to keep our code style consistent.
To lint your code just run: `yarn lint` To lint your code just run: `yarn lint`

View File

@ -4,17 +4,17 @@
[0x][website-url] is an open protocol that facilitates trustless, low friction exchange of Ethereum-based assets. A full description of the protocol may be found in our [whitepaper][whitepaper-url]. [0x][website-url] is an open protocol that facilitates trustless, low friction exchange of Ethereum-based assets. A full description of the protocol may be found in our [whitepaper][whitepaper-url].
This repository contains all the 0x developer tools written in TypeScript. Our hope is that these tools make it easy to build Relayers and other DApps that use the 0x protocol. This repository is a monorepo including the 0x protocol smart contracts and numerous developer tools. Each public sub-package is independently published to NPM.
[website-url]: https://0xproject.com/ [website-url]: https://0xproject.com/
[whitepaper-url]: https://0xproject.com/pdfs/0x_white_paper.pdf [whitepaper-url]: https://0xproject.com/pdfs/0x_white_paper.pdf
[![CircleCI](https://circleci.com/gh/0xProject/0x.js.svg?style=svg&circle-token=61bf7cd8c9b4e11b132089dfcffdd1be277d1e0c)](https://circleci.com/gh/0xProject/0x.js) [![CircleCI](https://circleci.com/gh/0xProject/0x-monorepo.svg?style=svg&circle-token=61bf7cd8c9b4e11b132089dfcffdd1be277d1e0c)](https://circleci.com/gh/0xProject/0x-monorepo)
[![Coverage Status](https://coveralls.io/repos/github/0xProject/0x.js/badge.svg?branch=master&t=fp0cXD)](https://coveralls.io/github/0xProject/0x.js?branch=master) [![Coverage Status](https://coveralls.io/repos/github/0xProject/0x-monorepo/badge.svg?branch=master&t=fp0cXD)](https://coveralls.io/github/0xProject/0x-monorepo?branch=master)
[![Discord](https://img.shields.io/badge/chat-rocket.chat-yellow.svg?style=flat)](https://chat.0xproject.com) [![Discord](https://img.shields.io/badge/chat-rocket.chat-yellow.svg?style=flat)](https://chat.0xproject.com)
[![Join the chat at https://gitter.im/0xProject/Lobby](https://badges.gitter.im/0xProject/Lobby.svg)](https://gitter.im/0xProject/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Join the chat at https://gitter.im/0xProject/Lobby](https://badges.gitter.im/0xProject/Lobby.svg)](https://gitter.im/0xProject/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Greenkeeper badge](https://badges.greenkeeper.io/0xProject/0x.js.svg?token=7c22e5c72acf39d3ead8d29c5d9bb38f9096df3e643024dcedd53ab732847be1&ts=1496426342666)](https://greenkeeper.io/) [![Greenkeeper badge](https://badges.greenkeeper.io/0xProject/0x-monorepo.svg?token=7c22e5c72acf39d3ead8d29c5d9bb38f9096df3e643024dcedd53ab732847be1&ts=1496426342666)](https://greenkeeper.io/)
### Published Packages ### Published Packages

View File

@ -1,6 +1,11 @@
{ {
"lerna": "2.5.1", "lerna": "2.5.1",
"packages": ["packages/*"], "packages": ["packages/*"],
"commands": {
"publish": {
"allowBranch": "development"
}
},
"version": "independent", "version": "independent",
"commands": { "commands": {
"publish": { "publish": {

View File

@ -1,6 +1,6 @@
{ {
"private": true, "private": true,
"name": "0x.js", "name": "0x-monorepo",
"workspaces": ["packages/*"], "workspaces": ["packages/*"],
"scripts": { "scripts": {
"dev": "lerna run --parallel build:watch", "dev": "lerna run --parallel build:watch",
@ -16,7 +16,7 @@
"mnemonic": "concert load couple harbor equip island argue ramp clarify fence smart topic" "mnemonic": "concert load couple harbor equip island argue ramp clarify fence smart topic"
}, },
"devDependencies": { "devDependencies": {
"@0xproject/utils": "^0.3.4", "@0xproject/utils": "^0.4.0",
"async-child-process": "^1.1.1", "async-child-process": "^1.1.1",
"ethereumjs-testrpc": "^6.0.3", "ethereumjs-testrpc": "^6.0.3",
"lerna": "^2.5.1", "lerna": "^2.5.1",

View File

@ -1,11 +1,16 @@
# CHANGELOG # CHANGELOG
## v0.33.0 - _TBD, 2018_ ## v0.33.1 - _TBD, 2018_
* Add missing EthersJs typescript typings as dependency
## v0.33.0 - _March 4, 2018_
* Validate and lowercase all addresses in public methods (#373) * Validate and lowercase all addresses in public methods (#373)
* Improve validation to force passing contract addresses on private networks (#385) * Improve validation to force passing contract addresses on private networks (#385)
* Change `LogErrorContractEventArgs.errorId` type from `BigNumber` to `number` (#413) * Change `LogErrorContractEventArgs.errorId` type from `BigNumber` to `number` (#413)
* Rename all public `_unsubscribeAll` methods to `unsubscribeAll` (#415) * Rename all public `_unsubscribeAll` methods to `unsubscribeAll` (#415)
* Move web3 typings from devDep to dep since cannot use this package without it (#429)
## v0.32.2 - _February 9, 2018_ ## v0.32.2 - _February 9, 2018_

View File

@ -18,11 +18,20 @@ npm install 0x.js --save
import { ZeroEx } from '0x.js'; import { ZeroEx } from '0x.js';
``` ```
If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`:
```
"include": [
"./node_modules/web3-typescript-typings/index.d.ts",
"./node_modules/ethers-typescript-typings/index.d.ts"
]
```
#### UMD: #### UMD:
**Install** **Install**
Download the UMD module from our [releases page](https://github.com/0xProject/0x.js/releases) and add it to your project. Download the UMD module from our [releases page](https://github.com/0xProject/0x-monorepo/releases) and add it to your project.
**Import** **Import**

View File

@ -1,6 +1,6 @@
{ {
"name": "0x.js", "name": "0x.js",
"version": "0.32.4", "version": "0.33.0",
"description": "A javascript library for interacting with the 0x protocol", "description": "A javascript library for interacting with the 0x protocol",
"keywords": [ "keywords": [
"0x.js", "0x.js",
@ -15,7 +15,7 @@
"build:watch": "tsc -w", "build:watch": "tsc -w",
"prebuild": "run-s clean generate_contract_wrappers", "prebuild": "run-s clean generate_contract_wrappers",
"build": "run-p build:umd:prod build:commonjs; exit 0;", "build": "run-p build:umd:prod build:commonjs; exit 0;",
"docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --json $JSON_FILE_PATH $PROJECT_DIR", "docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --json $JSON_FILE_PATH $PROJECT_FILES",
"upload_docs_json": "aws s3 cp generated_docs/index.json $S3_URL --profile 0xproject --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --content-type application/json", "upload_docs_json": "aws s3 cp generated_docs/index.json $S3_URL --profile 0xproject --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --content-type application/json",
"generate_contract_wrappers": "node ../abi-gen/lib/index.js --abis 'src/artifacts/@(Exchange|Token|TokenTransferProxy|EtherToken|TokenRegistry|DummyToken).json' --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/contract_wrappers/generated --backend ethers && prettier --write 'src/contract_wrappers/generated/**.ts'", "generate_contract_wrappers": "node ../abi-gen/lib/index.js --abis 'src/artifacts/@(Exchange|Token|TokenTransferProxy|EtherToken|TokenRegistry|DummyToken).json' --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/contract_wrappers/generated --backend ethers && prettier --write 'src/contract_wrappers/generated/**.ts'",
"lint": "tslint --project . 'src/**/*.ts' 'test/**/*.ts'", "lint": "tslint --project . 'src/**/*.ts' 'test/**/*.ts'",
@ -35,16 +35,16 @@
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/0xProject/0x.js" "url": "https://github.com/0xProject/0x-monorepo"
}, },
"license": "Apache-2.0", "license": "Apache-2.0",
"engines": { "engines": {
"node": ">=6.0.0" "node": ">=6.0.0"
}, },
"devDependencies": { "devDependencies": {
"@0xproject/abi-gen": "^0.2.3", "@0xproject/abi-gen": "^0.2.4",
"@0xproject/dev-utils": "^0.1.0", "@0xproject/dev-utils": "^0.2.0",
"@0xproject/tslint-config": "^0.4.9", "@0xproject/tslint-config": "^0.4.10",
"@types/bintrees": "^1.0.2", "@types/bintrees": "^1.0.2",
"@types/jsonschema": "^1.1.1", "@types/jsonschema": "^1.1.1",
"@types/lodash": "^4.14.86", "@types/lodash": "^4.14.86",
@ -55,9 +55,9 @@
"awesome-typescript-loader": "^3.1.3", "awesome-typescript-loader": "^3.1.3",
"chai": "^4.0.1", "chai": "^4.0.1",
"chai-as-promised": "^7.1.0", "chai-as-promised": "^7.1.0",
"chai-as-promised-typescript-typings": "^0.0.9", "chai-as-promised-typescript-typings": "^0.0.10",
"chai-bignumber": "^2.0.1", "chai-bignumber": "^2.0.1",
"chai-typescript-typings": "^0.0.3", "chai-typescript-typings": "^0.0.4",
"copyfiles": "^1.2.0", "copyfiles": "^1.2.0",
"coveralls": "^3.0.0", "coveralls": "^3.0.0",
"dirty-chai": "^2.0.1", "dirty-chai": "^2.0.1",
@ -73,30 +73,30 @@
"source-map-support": "^0.5.0", "source-map-support": "^0.5.0",
"truffle-hdwallet-provider": "^0.0.3", "truffle-hdwallet-provider": "^0.0.3",
"tslint": "5.8.0", "tslint": "5.8.0",
"typedoc": "~0.8.0", "typedoc": "0xProject/typedoc",
"types-bn": "^0.0.1", "types-bn": "^0.0.1",
"typescript": "2.7.1", "typescript": "2.7.1",
"web3-provider-engine": "^13.0.1", "web3-provider-engine": "^13.0.1",
"ethers-typescript-typings": "^0.0.1",
"web3-typescript-typings": "^0.9.11",
"webpack": "^3.1.0" "webpack": "^3.1.0"
}, },
"dependencies": { "dependencies": {
"@0xproject/assert": "^0.0.20", "@0xproject/assert": "^0.1.0",
"@0xproject/base-contract": "^0.0.1", "@0xproject/base-contract": "^0.0.2",
"@0xproject/json-schemas": "^0.7.12", "@0xproject/json-schemas": "^0.7.13",
"@0xproject/types": "^0.2.3", "@0xproject/types": "^0.3.0",
"@0xproject/utils": "^0.3.4", "@0xproject/utils": "^0.4.0",
"@0xproject/web3-wrapper": "^0.1.14", "@0xproject/web3-wrapper": "^0.2.0",
"bintrees": "^1.0.2", "bintrees": "^1.0.2",
"bn.js": "^4.11.8", "bn.js": "^4.11.8",
"ethers-contracts": "^2.2.1",
"ethereumjs-abi": "^0.6.4", "ethereumjs-abi": "^0.6.4",
"ethereumjs-blockstream": "^2.0.6", "ethereumjs-blockstream": "^2.0.6",
"ethereumjs-util": "^5.1.1", "ethereumjs-util": "^5.1.1",
"ethers-contracts": "^2.2.1",
"ethers-typescript-typings": "^0.0.2",
"js-sha3": "^0.7.0", "js-sha3": "^0.7.0",
"lodash": "^4.17.4", "lodash": "^4.17.4",
"uuid": "^3.1.0", "uuid": "^3.1.0",
"web3": "^0.20.0" "web3": "^0.20.0",
"web3-typescript-typings": "^0.10.0"
} }
} }

View File

@ -1,9 +1,16 @@
const execAsync = require('async-child-process').execAsync; const execAsync = require('async-child-process').execAsync;
const postpublish_utils = require('../../../scripts/postpublish_utils'); const postpublish_utils = require('../../../scripts/postpublish_utils');
const packageJSON = require('../package.json'); const packageJSON = require('../package.json');
const tsConfig = require('../tsconfig.json');
const cwd = __dirname + '/..'; const cwd = __dirname + '/..';
const subPackageName = packageJSON.name; const subPackageName = packageJSON.name;
// Include any external packages that are part of the 0x.js public interface
// to this array so that TypeDoc picks it up and adds it to the Docs JSON
// So far, we only have @0xproject/types as part of 0x.js's public interface.
const fileIncludes = [...tsConfig.include, '../types/src/index.ts'];
const fileIncludesAdjusted = postpublish_utils.adjustFileIncludePaths(fileIncludes, __dirname);
const projectFiles = fileIncludesAdjusted.join(' ');
const S3BucketPath = 's3://0xjs-docs-jsons/'; const S3BucketPath = 's3://0xjs-docs-jsons/';
let tag; let tag;
@ -20,7 +27,7 @@ postpublish_utils
.then(function(release) { .then(function(release) {
console.log('POSTPUBLISH: Release successful, generating docs...'); console.log('POSTPUBLISH: Release successful, generating docs...');
const jsonFilePath = __dirname + '/../' + postpublish_utils.generatedDocsDirectoryName + '/index.json'; const jsonFilePath = __dirname + '/../' + postpublish_utils.generatedDocsDirectoryName + '/index.json';
return execAsync('JSON_FILE_PATH=' + jsonFilePath + ' PROJECT_DIR=' + __dirname + '/.. yarn docs:json', { return execAsync('JSON_FILE_PATH=' + jsonFilePath + ' PROJECT_FILES="' + projectFiles + '" yarn docs:json', {
cwd, cwd,
}); });
}) })

View File

@ -1,15 +1,22 @@
const execAsync = require('async-child-process').execAsync; const execAsync = require('async-child-process').execAsync;
const postpublish_utils = require('../../../scripts/postpublish_utils'); const postpublish_utils = require('../../../scripts/postpublish_utils');
const tsConfig = require('../tsconfig.json');
const cwd = __dirname + '/..'; const cwd = __dirname + '/..';
const S3BucketPath = 's3://staging-0xjs-docs-jsons/'; const S3BucketPath = 's3://staging-0xjs-docs-jsons/';
// Include any external packages that are part of the 0x.js public interface
// to this array so that TypeDoc picks it up and adds it to the Docs JSON
// So far, we only have @0xproject/types as part of 0x.js's public interface.
const fileIncludes = [...tsConfig.include, '../types/src/index.ts'];
const fileIncludesAdjusted = postpublish_utils.adjustFileIncludePaths(fileIncludes, __dirname);
const projectFiles = fileIncludesAdjusted.join(' ');
const jsonFilePath = __dirname + '/../' + postpublish_utils.generatedDocsDirectoryName + '/index.json'; const jsonFilePath = __dirname + '/../' + postpublish_utils.generatedDocsDirectoryName + '/index.json';
const version = process.env.DOCS_VERSION; const version = process.env.DOCS_VERSION;
execAsync('JSON_FILE_PATH=' + jsonFilePath + ' PROJECT_DIR=' + __dirname + '/.. yarn docs:json', { execAsync('JSON_FILE_PATH=' + jsonFilePath + ' PROJECT_FILES="' + projectFiles + '" yarn docs:json', {
cwd, cwd,
}) })
.then(function(result) { .then(function(result) {
if (result.stderr !== '') { if (result.stderr !== '') {
throw new Error(result.stderr); throw new Error(result.stderr);
} }
@ -18,7 +25,7 @@ execAsync('JSON_FILE_PATH=' + jsonFilePath + ' PROJECT_DIR=' + __dirname + '/..
return execAsync('S3_URL=' + s3Url + ' yarn upload_docs_json', { return execAsync('S3_URL=' + s3Url + ' yarn upload_docs_json', {
cwd, cwd,
}); });
}) })
.catch(function(err) { .catch(function(err) {
console.log(err); console.log(err);
}); });

View File

@ -34,6 +34,7 @@ export {
BlockParam, BlockParam,
ContractEventArg, ContractEventArg,
LogWithDecodedArgs, LogWithDecodedArgs,
TransactionReceipt,
TransactionReceiptWithDecodedLogs, TransactionReceiptWithDecodedLogs,
} from '@0xproject/types'; } from '@0xproject/types';
@ -58,5 +59,3 @@ export {
ExchangeContractEventArgs, ExchangeContractEventArgs,
ExchangeEvents, ExchangeEvents,
} from './contract_wrappers/generated/exchange'; } from './contract_wrappers/generated/exchange';
export { TransactionReceipt } from '@0xproject/types';

View File

@ -1,6 +1,6 @@
# CHANGELOG # CHANGELOG
## v0.2.3 - _TBD, 2018_ ## v0.2.4 - _March 4, 2018_
* Add a `backend` parameter that allows you to specify the Ethereum library you use in your templates (`web3` or `ethers`). Ethers auto-converts small ints to numbers whereas Web3 doesn't. Defaults to `web3` (#413) * Add a `backend` parameter that allows you to specify the Ethereum library you use in your templates (`web3` or `ethers`). Ethers auto-converts small ints to numbers whereas Web3 doesn't. Defaults to `web3` (#413)
* Add support for [tuple types](https://solidity.readthedocs.io/en/develop/abi-spec.html#handling-tuple-types) (#413) * Add support for [tuple types](https://solidity.readthedocs.io/en/develop/abi-spec.html#handling-tuple-types) (#413)

View File

@ -4,8 +4,8 @@ This package allows you to generate TypeScript contract wrappers from ABI files.
It's heavily inspired by [Geth abigen](https://github.com/ethereum/go-ethereum/wiki/Native-DApps:-Go-bindings-to-Ethereum-contracts) but takes a different approach. It's heavily inspired by [Geth abigen](https://github.com/ethereum/go-ethereum/wiki/Native-DApps:-Go-bindings-to-Ethereum-contracts) but takes a different approach.
You can write your custom handlebars templates which will allow you to seamlessly integrate the generated code into your existing codebase with existing conventions. You can write your custom handlebars templates which will allow you to seamlessly integrate the generated code into your existing codebase with existing conventions.
For an example of the generated [wrapper files](https://github.com/0xProject/0x.js/tree/development/packages/0x.js/src/contract_wrappers/generated) check out 0x.js. For an example of the generated [wrapper files](https://github.com/0xProject/0x-monorepo/tree/development/packages/0x.js/src/contract_wrappers/generated) check out 0x.js.
[Here](https://github.com/0xProject/0x.js/tree/development/packages/0x.js/contract_templates) are the templates used to generate those files. [Here](https://github.com/0xProject/0x-monorepo/tree/development/packages/0x.js/contract_templates) are the templates used to generate those files.
## Installation ## Installation
@ -36,14 +36,14 @@ The abi file should be either a [Truffle](http://truffleframework.com/) contract
## How to write custom templates? ## How to write custom templates?
The best way to get started is to copy [0x.js templates](https://github.com/0xProject/0x.js/tree/development/packages/0x.js/contract_templates) and start adjusting them for your needs. The best way to get started is to copy [0x.js templates](https://github.com/0xProject/0x-monorepo/tree/development/packages/0x.js/contract_templates) and start adjusting them for your needs.
We use [handlebars](http://handlebarsjs.com/) template engine under the hood. We use [handlebars](http://handlebarsjs.com/) template engine under the hood.
You need to have a master template called `contract.mustache`. it will be used to generate each contract wrapper. Although - you don't need and probably shouldn't write all your logic in a single template file. You can write [partial templates](http://handlebarsjs.com/partials.html) and as long as they are within a partials folder - they will be registered and available. You need to have a master template called `contract.mustache`. it will be used to generate each contract wrapper. Although - you don't need and probably shouldn't write all your logic in a single template file. You can write [partial templates](http://handlebarsjs.com/partials.html) and as long as they are within a partials folder - they will be registered and available.
## Which data/context do I get in my templates? ## Which data/context do I get in my templates?
For now you don't get much on top of methods abi, some useful helpers and a contract name because it was enough for our use-case, but if you need something else - create a PR. For now you don't get much on top of methods abi, some useful helpers and a contract name because it was enough for our use-case, but if you need something else - create a PR.
See the [type definition](https://github.com/0xProject/0x.js/tree/development/packages/abi-gen/src/types.ts) of what we pass to the render method. See the [type definition](https://github.com/0xProject/0x-monorepo/tree/development/packages/abi-gen/src/types.ts) of what we pass to the render method.
## Output files ## Output files

View File

@ -1,6 +1,6 @@
{ {
"name": "@0xproject/abi-gen", "name": "@0xproject/abi-gen",
"version": "0.2.3", "version": "0.2.4",
"description": "Generate contract wrappers from ABI and handlebars templates", "description": "Generate contract wrappers from ABI and handlebars templates",
"main": "lib/index.js", "main": "lib/index.js",
"types": "lib/index.d.ts", "types": "lib/index.d.ts",
@ -15,15 +15,15 @@
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/0xProject/0x.js.git" "url": "https://github.com/0xProject/0x-monorepo.git"
}, },
"license": "Apache-2.0", "license": "Apache-2.0",
"bugs": { "bugs": {
"url": "https://github.com/0xProject/0x.js/issues" "url": "https://github.com/0xProject/0x-monorepo/issues"
}, },
"homepage": "https://github.com/0xProject/0x.js/packages/abi-gen/README.md", "homepage": "https://github.com/0xProject/0x-monorepo/packages/abi-gen/README.md",
"dependencies": { "dependencies": {
"@0xproject/utils": "^0.3.4", "@0xproject/utils": "^0.4.0",
"chalk": "^2.3.0", "chalk": "^2.3.0",
"glob": "^7.1.2", "glob": "^7.1.2",
"handlebars": "^4.0.11", "handlebars": "^4.0.11",
@ -34,7 +34,7 @@
"yargs": "^10.0.3" "yargs": "^10.0.3"
}, },
"devDependencies": { "devDependencies": {
"@0xproject/tslint-config": "^0.4.9", "@0xproject/tslint-config": "^0.4.10",
"@types/glob": "^5.0.33", "@types/glob": "^5.0.33",
"@types/handlebars": "^4.0.36", "@types/handlebars": "^4.0.36",
"@types/mkdirp": "^0.5.1", "@types/mkdirp": "^0.5.1",
@ -44,6 +44,6 @@
"shx": "^0.2.2", "shx": "^0.2.2",
"tslint": "5.8.0", "tslint": "5.8.0",
"typescript": "2.7.1", "typescript": "2.7.1",
"web3-typescript-typings": "^0.9.11" "web3-typescript-typings": "^0.10.0"
} }
} }

View File

@ -1,6 +1,6 @@
# CHANGELOG # CHANGELOG
## v0.1.0 - _TBD, 2018_ ## v0.1.0 - _March 4, 2018_
* Remove isETHAddressHex checksum address check and assume address will be lowercased (#373) * Remove isETHAddressHex checksum address check and assume address will be lowercased (#373)
* Add an optional parameter `subSchemas` to `doesConformToSchema` method (#385) * Add an optional parameter `subSchemas` to `doesConformToSchema` method (#385)

View File

@ -8,6 +8,14 @@ Standard type and schema assertions to be used across all 0x projects and packag
yarn add @0xproject/assert yarn add @0xproject/assert
``` ```
If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`:
```
"include": [
"./node_modules/web3-typescript-typings/index.d.ts",
]
```
## Usage ## Usage
```typescript ```typescript

View File

@ -1,6 +1,6 @@
{ {
"name": "@0xproject/assert", "name": "@0xproject/assert",
"version": "0.0.20", "version": "0.1.0",
"description": "Provides a standard way of performing type and schema validation across 0x projects", "description": "Provides a standard way of performing type and schema validation across 0x projects",
"main": "lib/src/index.js", "main": "lib/src/index.js",
"types": "lib/src/index.d.ts", "types": "lib/src/index.d.ts",
@ -17,19 +17,19 @@
"license": "Apache-2.0", "license": "Apache-2.0",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/0xProject/0x.js.git" "url": "https://github.com/0xProject/0x-monorepo.git"
}, },
"bugs": { "bugs": {
"url": "https://github.com/0xProject/0x.js/issues" "url": "https://github.com/0xProject/0x-monorepo/issues"
}, },
"homepage": "https://github.com/0xProject/0x.js/packages/assert/README.md", "homepage": "https://github.com/0xProject/0x-monorepo/packages/assert/README.md",
"devDependencies": { "devDependencies": {
"@0xproject/tslint-config": "^0.4.9", "@0xproject/tslint-config": "^0.4.10",
"@types/lodash": "^4.14.86", "@types/lodash": "^4.14.86",
"@types/mocha": "^2.2.42", "@types/mocha": "^2.2.42",
"@types/valid-url": "^1.0.2", "@types/valid-url": "^1.0.2",
"chai": "^4.0.1", "chai": "^4.0.1",
"chai-typescript-typings": "^0.0.3", "chai-typescript-typings": "^0.0.4",
"dirty-chai": "^2.0.1", "dirty-chai": "^2.0.1",
"mocha": "^4.0.1", "mocha": "^4.0.1",
"npm-run-all": "^4.1.2", "npm-run-all": "^4.1.2",
@ -38,8 +38,8 @@
"typescript": "2.7.1" "typescript": "2.7.1"
}, },
"dependencies": { "dependencies": {
"@0xproject/json-schemas": "^0.7.12", "@0xproject/json-schemas": "^0.7.13",
"@0xproject/utils": "^0.3.4", "@0xproject/utils": "^0.4.0",
"lodash": "^4.17.4", "lodash": "^4.17.4",
"valid-url": "^1.0.9" "valid-url": "^1.0.9"
} }

View File

@ -1,5 +1,5 @@
# CHANGELOG # CHANGELOG
## v0.0.1 - _TBD, 2018_ ## v0.0.2 - _March 4, 2018_
* Initial release (#TBD) * Initial release

View File

@ -8,6 +8,15 @@ BaseContract to derive all auto-generated wrappers from
yarn add @0xproject/base-contract yarn add @0xproject/base-contract
``` ```
If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`:
```
"include": [
"./node_modules/web3-typescript-typings/index.d.ts",
"./node_modules/ethers-typescript-typings/index.d.ts"
]
```
## Usage ## Usage
```javascript ```javascript

View File

@ -1,6 +1,6 @@
{ {
"name": "@0xproject/base-contract", "name": "@0xproject/base-contract",
"version": "0.0.1", "version": "0.0.2",
"description": "0x Base TS contract", "description": "0x Base TS contract",
"main": "lib/index.js", "main": "lib/index.js",
"types": "lib/index.d.ts", "types": "lib/index.d.ts",
@ -13,27 +13,27 @@
"license": "Apache-2.0", "license": "Apache-2.0",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/0xProject/0x.js.git" "url": "https://github.com/0xProject/0x-monorepo.git"
}, },
"bugs": { "bugs": {
"url": "https://github.com/0xProject/0x.js/issues" "url": "https://github.com/0xProject/0x-monorepo/issues"
}, },
"homepage": "https://github.com/0xProject/0x.js/packages/base-contract/README.md", "homepage": "https://github.com/0xProject/0x-monorepo/packages/base-contract/README.md",
"devDependencies": { "devDependencies": {
"@0xproject/tslint-config": "^0.4.9", "@0xproject/tslint-config": "^0.4.10",
"@types/lodash": "^4.14.86", "@types/lodash": "^4.14.86",
"npm-run-all": "^4.1.2", "npm-run-all": "^4.1.2",
"shx": "^0.2.2", "shx": "^0.2.2",
"tslint": "5.8.0", "tslint": "5.8.0",
"typescript": "2.7.1", "typescript": "2.7.1"
"ethers-typescript-typings": "^0.0.1",
"web3-typescript-typings": "^0.9.11"
}, },
"dependencies": { "dependencies": {
"@0xproject/types": "^0.2.3", "@0xproject/types": "^0.3.0",
"@0xproject/web3-wrapper": "^0.1.14", "@0xproject/web3-wrapper": "^0.2.0",
"ethers-contracts": "^2.2.1", "ethers-contracts": "^2.2.1",
"ethers-typescript-typings": "^0.0.2",
"lodash": "^4.17.4", "lodash": "^4.17.4",
"web3": "^0.20.0" "web3": "^0.20.0",
"web3-typescript-typings": "^0.10.0"
} }
} }

View File

@ -1,12 +1,12 @@
{ {
"name": "chai-as-promised-typescript-typings", "name": "chai-as-promised-typescript-typings",
"version": "0.0.9", "version": "0.0.10",
"description": "Typescript type definitions for chai-as-promised", "description": "Typescript type definitions for chai-as-promised",
"main": "index.d.ts", "main": "index.d.ts",
"types": "index.d.ts", "types": "index.d.ts",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/0xProject/0x.js.git" "url": "git+https://github.com/0xProject/0x-monorepo.git"
}, },
"author": "Fabio Berger", "author": "Fabio Berger",
"contributors": [ "contributors": [
@ -14,10 +14,10 @@
], ],
"license": "Apache-2.0", "license": "Apache-2.0",
"bugs": { "bugs": {
"url": "https://github.com/0xProject/0x.js/issues" "url": "https://github.com/0xProject/0x-monorepo/issues"
}, },
"homepage": "https://github.com/0xProject/0x.js/packages/chai-as-promised-typescript-typings#readme", "homepage": "https://github.com/0xProject/0x-monorepo/packages/chai-as-promised-typescript-typings#readme",
"dependencies": { "dependencies": {
"chai-typescript-typings": "^0.0.3" "chai-typescript-typings": "^0.0.4"
} }
} }

View File

@ -1,16 +1,16 @@
{ {
"name": "chai-typescript-typings", "name": "chai-typescript-typings",
"version": "0.0.3", "version": "0.0.4",
"description": "Typescript type definitions for chai", "description": "Typescript type definitions for chai",
"main": "index.d.ts", "main": "index.d.ts",
"types": "index.d.ts", "types": "index.d.ts",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/0xProject/0x.js.git" "url": "git+https://github.com/0xProject/0x-monorepo.git"
}, },
"license": "Apache-2.0", "license": "Apache-2.0",
"bugs": { "bugs": {
"url": "https://github.com/0xProject/0x.js/issues" "url": "https://github.com/0xProject/0x-monorepo/issues"
}, },
"homepage": "https://github.com/0xProject/0x.js/packages/chai-typescript-typings#readme" "homepage": "https://github.com/0xProject/0x-monorepo/packages/chai-typescript-typings#readme"
} }

View File

@ -1,6 +1,6 @@
# CHANGELOG # CHANGELOG
## v0.6.1 - _February 16, 2018_ ## v0.6.2 - _February 16, 2018_
* Fix JSON parse empty response (#407) * Fix JSON parse empty response (#407)

View File

@ -8,6 +8,14 @@ This repository contains a Javascript library that makes it easy to interact wit
yarn add @0xproject/connect yarn add @0xproject/connect
``` ```
If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`:
```
"include": [
"./node_modules/web3-typescript-typings/index.d.ts",
]
```
## Usage ## Usage
* [Docs](https://0xproject.com/docs/connect) * [Docs](https://0xproject.com/docs/connect)

View File

@ -1,6 +1,6 @@
{ {
"name": "@0xproject/connect", "name": "@0xproject/connect",
"version": "0.6.1", "version": "0.6.2",
"description": "A javascript library for interacting with the standard relayer api", "description": "A javascript library for interacting with the standard relayer api",
"keywords": [ "keywords": [
"connect", "connect",
@ -15,7 +15,7 @@
"build:watch": "tsc -w", "build:watch": "tsc -w",
"build": "tsc", "build": "tsc",
"clean": "shx rm -rf _bundles lib test_temp", "clean": "shx rm -rf _bundles lib test_temp",
"docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --json $JSON_FILE_PATH $PROJECT_DIR", "docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --json $JSON_FILE_PATH $PROJECT_FILES",
"upload_docs_json": "aws s3 cp generated_docs/index.json $S3_URL --profile 0xproject --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --content-type application/json", "upload_docs_json": "aws s3 cp generated_docs/index.json $S3_URL --profile 0xproject --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --content-type application/json",
"copy_test_fixtures": "copyfiles -u 2 './test/fixtures/**/*.json' ./lib/test/fixtures", "copy_test_fixtures": "copyfiles -u 2 './test/fixtures/**/*.json' ./lib/test/fixtures",
"lint": "tslint --project . 'src/**/*.ts' 'test/**/*.ts'", "lint": "tslint --project . 'src/**/*.ts' 'test/**/*.ts'",
@ -25,7 +25,7 @@
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/0xProject/0x.js.git" "url": "https://github.com/0xProject/0x-monorepo.git"
}, },
"author": "Brandon Millman", "author": "Brandon Millman",
"license": "Apache-2.0", "license": "Apache-2.0",
@ -33,20 +33,20 @@
"node": ">=6.0.0" "node": ">=6.0.0"
}, },
"bugs": { "bugs": {
"url": "https://github.com/0xProject/0x.js/issues" "url": "https://github.com/0xProject/0x-monorepo/issues"
}, },
"homepage": "https://github.com/0xProject/0x.js/packages/connect/README.md", "homepage": "https://github.com/0xProject/0x-monorepo/packages/connect/README.md",
"dependencies": { "dependencies": {
"@0xproject/assert": "^0.0.20", "@0xproject/assert": "^0.1.0",
"@0xproject/json-schemas": "^0.7.12", "@0xproject/json-schemas": "^0.7.13",
"@0xproject/utils": "^0.3.4", "@0xproject/utils": "^0.4.0",
"isomorphic-fetch": "^2.2.1", "isomorphic-fetch": "^2.2.1",
"lodash": "^4.17.4", "lodash": "^4.17.4",
"query-string": "^5.0.1", "query-string": "^5.0.1",
"websocket": "^1.0.25" "websocket": "^1.0.25"
}, },
"devDependencies": { "devDependencies": {
"@0xproject/tslint-config": "^0.4.9", "@0xproject/tslint-config": "^0.4.10",
"@types/fetch-mock": "^5.12.1", "@types/fetch-mock": "^5.12.1",
"@types/lodash": "^4.14.86", "@types/lodash": "^4.14.86",
"@types/mocha": "^2.2.42", "@types/mocha": "^2.2.42",
@ -54,8 +54,8 @@
"@types/websocket": "^0.0.34", "@types/websocket": "^0.0.34",
"chai": "^4.0.1", "chai": "^4.0.1",
"chai-as-promised": "^7.1.0", "chai-as-promised": "^7.1.0",
"chai-as-promised-typescript-typings": "^0.0.9", "chai-as-promised-typescript-typings": "^0.0.10",
"chai-typescript-typings": "^0.0.3", "chai-typescript-typings": "^0.0.4",
"copyfiles": "^1.2.0", "copyfiles": "^1.2.0",
"dirty-chai": "^2.0.1", "dirty-chai": "^2.0.1",
"fetch-mock": "^5.13.1", "fetch-mock": "^5.13.1",
@ -65,6 +65,6 @@
"tslint": "5.8.0", "tslint": "5.8.0",
"typedoc": "~0.8.0", "typedoc": "~0.8.0",
"typescript": "2.7.1", "typescript": "2.7.1",
"web3-typescript-typings": "^0.9.11" "web3-typescript-typings": "^0.10.0"
} }
} }

View File

@ -1,10 +1,16 @@
const execAsync = require('async-child-process').execAsync; const execAsync = require('async-child-process').execAsync;
const postpublish_utils = require('../../../scripts/postpublish_utils'); const postpublish_utils = require('../../../scripts/postpublish_utils');
const packageJSON = require('../package.json'); const packageJSON = require('../package.json');
const tsConfig = require('../tsconfig.json');
const cwd = __dirname + '/..'; const cwd = __dirname + '/..';
const subPackageName = packageJSON.name; const subPackageName = packageJSON.name;
const S3BucketPath = 's3://connect-docs-jsons/'; const S3BucketPath = 's3://connect-docs-jsons/';
// Include any external packages that are part of the @0xproject/connect public interface
// to this array so that TypeDoc picks it up and adds it to the Docs JSON
const fileIncludes = [...tsConfig.include];
const fileIncludesAdjusted = postpublish_utils.adjustFileIncludePaths(fileIncludes, __dirname);
const projectFiles = fileIncludesAdjusted.join(' ');
let tag; let tag;
let version; let version;
@ -19,7 +25,7 @@ postpublish_utils
.then(function(release) { .then(function(release) {
console.log('POSTPUBLISH: Release successful, generating docs...'); console.log('POSTPUBLISH: Release successful, generating docs...');
const jsonFilePath = __dirname + '/../' + postpublish_utils.generatedDocsDirectoryName + '/index.json'; const jsonFilePath = __dirname + '/../' + postpublish_utils.generatedDocsDirectoryName + '/index.json';
return execAsync('JSON_FILE_PATH=' + jsonFilePath + ' PROJECT_DIR=' + __dirname + '/.. yarn docs:json', { return execAsync('JSON_FILE_PATH=' + jsonFilePath + ' PROJECT_FILES="' + projectFiles + '" yarn docs:json', {
cwd, cwd,
}); });
}) })

View File

@ -1,15 +1,21 @@
const execAsync = require('async-child-process').execAsync; const execAsync = require('async-child-process').execAsync;
const postpublish_utils = require('../../../scripts/postpublish_utils'); const postpublish_utils = require('../../../scripts/postpublish_utils');
const tsConfig = require('../tsconfig.json');
const cwd = __dirname + '/..'; const cwd = __dirname + '/..';
const S3BucketPath = 's3://staging-connect-docs-jsons/'; const S3BucketPath = 's3://staging-connect-docs-jsons/';
const jsonFilePath = __dirname + '/../' + postpublish_utils.generatedDocsDirectoryName + '/index.json'; const jsonFilePath = __dirname + '/../' + postpublish_utils.generatedDocsDirectoryName + '/index.json';
const version = process.env.DOCS_VERSION; const version = process.env.DOCS_VERSION;
// Include any external packages that are part of the @0xproject/connect public interface
// to this array so that TypeDoc picks it up and adds it to the Docs JSON
const fileIncludes = [...tsConfig.include];
const fileIncludesAdjusted = postpublish_utils.adjustFileIncludePaths(fileIncludes, __dirname);
const projectFiles = fileIncludesAdjusted.join(' ');
execAsync('JSON_FILE_PATH=' + jsonFilePath + ' PROJECT_DIR=' + __dirname + '/.. yarn docs:json', { execAsync('JSON_FILE_PATH=' + jsonFilePath + ' PROJECT_FILES="' + projectFiles + '" yarn docs:json', {
cwd, cwd,
}) })
.then(function(result) { .then(function(result) {
if (result.stderr !== '') { if (result.stderr !== '') {
throw new Error(result.stderr); throw new Error(result.stderr);
} }
@ -18,7 +24,7 @@ execAsync('JSON_FILE_PATH=' + jsonFilePath + ' PROJECT_DIR=' + __dirname + '/..
return execAsync('S3_URL=' + s3Url + ' yarn upload_docs_json', { return execAsync('S3_URL=' + s3Url + ' yarn upload_docs_json', {
cwd, cwd,
}); });
}) })
.catch(function(err) { .catch(function(err) {
console.log(err); console.log(err);
}); });

View File

@ -1,6 +1,6 @@
/** /**
* This file is auto-generated using abi-gen. Don't edit directly. * This file is auto-generated using abi-gen. Don't edit directly.
* Templates can be found at https://github.com/0xProject/0x.js/tree/development/packages/contract_templates. * Templates can be found at https://github.com/0xProject/0x-monorepo/tree/development/packages/contract_templates.
*/ */
// tslint:disable:no-consecutive-blank-lines // tslint:disable:no-consecutive-blank-lines
// tslint:disable-next-line:no-unused-variable // tslint:disable-next-line:no-unused-variable

View File

@ -60,7 +60,7 @@ yarn lint
Before running the tests, you will need to spin up a [TestRPC](https://www.npmjs.com/package/ethereumjs-testrpc) instance. Before running the tests, you will need to spin up a [TestRPC](https://www.npmjs.com/package/ethereumjs-testrpc) instance.
In a separate terminal, start TestRPC (a convenience command is provided as part of the [0x.js monorepo](https://github.com/0xProject/0x.js)) In a separate terminal, start TestRPC (a convenience command is provided as part of the [0x.js monorepo](https://github.com/0xProject/0x-monorepo))
```bash ```bash
cd ../.. cd ../..

View File

@ -30,5 +30,6 @@ declare module 'web3-eth-abi' {
declare module 'ethereumjs-abi' { declare module 'ethereumjs-abi' {
const soliditySHA3: (argTypes: string[], args: any[]) => Buffer; const soliditySHA3: (argTypes: string[], args: any[]) => Buffer;
const soliditySHA256: (argTypes: string[], args: any[]) => Buffer;
const methodID: (name: string, types: string[]) => Buffer; const methodID: (name: string, types: string[]) => Buffer;
} }

View File

@ -1,7 +1,7 @@
{ {
"private": true, "private": true,
"name": "contracts", "name": "contracts",
"version": "2.1.13", "version": "2.1.14",
"description": "Smart contract components of 0x protocol", "description": "Smart contract components of 0x protocol",
"main": "index.js", "main": "index.js",
"directories": { "directories": {
@ -17,27 +17,27 @@
"compile:comment": "Yarn workspaces do not link binaries correctly so we need to reference them directly https://github.com/yarnpkg/yarn/issues/3846", "compile:comment": "Yarn workspaces do not link binaries correctly so we need to reference them directly https://github.com/yarnpkg/yarn/issues/3846",
"compile": "node ../deployer/lib/src/cli.js compile --contracts ${npm_package_config_contracts} --contracts-dir src/contracts --artifacts-dir src/artifacts", "compile": "node ../deployer/lib/src/cli.js compile --contracts ${npm_package_config_contracts} --contracts-dir src/contracts --artifacts-dir src/artifacts",
"clean": "shx rm -rf ./lib", "clean": "shx rm -rf ./lib",
"generate_contract_wrappers": "node ../abi-gen/lib/index.js --abis 'src/artifacts/@(DummyToken|TokenTransferProxy|Exchange|TokenRegistry|MultiSigWallet|MultiSigWalletWithTimeLock|MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress|TokenRegistry|ZRXToken).json' --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/contract_wrappers/generated --backend ethers && prettier --write 'src/contract_wrappers/generated/**.ts'", "generate_contract_wrappers": "node ../abi-gen/lib/index.js --abis 'src/artifacts/@(DummyToken|TokenTransferProxy|Exchange|TokenRegistry|MultiSigWallet|MultiSigWalletWithTimeLock|MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress|TokenRegistry|ZRXToken|Arbitrage|EtherDelta|AccountLevels).json' --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/contract_wrappers/generated --backend ethers && prettier --write 'src/contract_wrappers/generated/**.ts'",
"migrate": "node ../deployer/lib/src/cli.js migrate", "migrate": "node ../deployer/lib/src/cli.js migrate",
"lint": "tslint --project . 'migrations/**/*.ts' 'test/**/*.ts' 'util/**/*.ts' 'deploy/**/*.ts'", "lint": "tslint --project . 'migrations/**/*.ts' 'test/**/*.ts' 'util/**/*.ts' 'deploy/**/*.ts'",
"test:circleci": "yarn test" "test:circleci": "yarn test"
}, },
"config": { "config": {
"contracts": "Exchange,DummyToken,ZRXToken,Token,WETH9,TokenTransferProxy,MultiSigWallet,MultiSigWalletWithTimeLock,MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress,MaliciousToken,TokenRegistry" "contracts": "Exchange,DummyToken,ZRXToken,Token,WETH9,TokenTransferProxy,MultiSigWallet,MultiSigWalletWithTimeLock,MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress,MaliciousToken,TokenRegistry,Arbitrage,EtherDelta,AccountLevels"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/0xProject/0x.js.git" "url": "https://github.com/0xProject/0x-monorepo.git"
}, },
"author": "Amir Bandeali", "author": "Amir Bandeali",
"license": "Apache-2.0", "license": "Apache-2.0",
"bugs": { "bugs": {
"url": "https://github.com/0xProject/0x.js/issues" "url": "https://github.com/0xProject/0x-monorepo/issues"
}, },
"homepage": "https://github.com/0xProject/0x.js/packages/contracts/README.md", "homepage": "https://github.com/0xProject/0x-monorepo/packages/contracts/README.md",
"devDependencies": { "devDependencies": {
"@0xproject/dev-utils": "^0.1.0", "@0xproject/dev-utils": "^0.2.0",
"@0xproject/tslint-config": "^0.4.9", "@0xproject/tslint-config": "^0.4.10",
"@types/bluebird": "^3.5.3", "@types/bluebird": "^3.5.3",
"@types/lodash": "^4.14.86", "@types/lodash": "^4.14.86",
"@types/node": "^8.0.53", "@types/node": "^8.0.53",
@ -45,11 +45,12 @@
"@types/yargs": "^10.0.0", "@types/yargs": "^10.0.0",
"chai": "^4.0.1", "chai": "^4.0.1",
"chai-as-promised": "^7.1.0", "chai-as-promised": "^7.1.0",
"chai-as-promised-typescript-typings": "^0.0.9", "chai-as-promised-typescript-typings": "^0.0.10",
"chai-bignumber": "^2.0.1", "chai-bignumber": "^2.0.1",
"chai-typescript-typings": "^0.0.3", "chai-typescript-typings": "^0.0.4",
"copyfiles": "^1.2.0", "copyfiles": "^1.2.0",
"dirty-chai": "^2.0.1", "dirty-chai": "^2.0.1",
"ethers-typescript-typings": "^0.0.2",
"mocha": "^4.0.1", "mocha": "^4.0.1",
"npm-run-all": "^4.1.2", "npm-run-all": "^4.1.2",
"shx": "^0.2.2", "shx": "^0.2.2",
@ -58,18 +59,16 @@
"types-bn": "^0.0.1", "types-bn": "^0.0.1",
"types-ethereumjs-util": "0xProject/types-ethereumjs-util", "types-ethereumjs-util": "0xProject/types-ethereumjs-util",
"typescript": "2.7.1", "typescript": "2.7.1",
"ethers-typescript-typings": "^0.0.1", "web3-typescript-typings": "^0.10.0",
"web3-typescript-typings": "^0.9.11",
"yargs": "^10.0.3" "yargs": "^10.0.3"
}, },
"dependencies": { "dependencies": {
"0x.js": "^0.32.4", "0x.js": "^0.33.0",
"@0xproject/web3-wrapper": "^0.1.14", "@0xproject/deployer": "^0.2.0",
"@0xproject/deployer": "^0.1.0", "@0xproject/json-schemas": "^0.7.13",
"@0xproject/json-schemas": "^0.7.12", "@0xproject/types": "^0.3.0",
"@0xproject/types": "^0.2.3", "@0xproject/utils": "^0.4.0",
"@0xproject/utils": "^0.3.4", "@0xproject/web3-wrapper": "^0.2.0",
"@0xproject/web3-wrapper": "^0.1.14",
"bluebird": "^3.5.0", "bluebird": "^3.5.0",
"bn.js": "^4.11.8", "bn.js": "^4.11.8",
"ethereumjs-abi": "^0.6.4", "ethereumjs-abi": "^0.6.4",

View File

@ -0,0 +1,114 @@
pragma solidity ^0.4.19;
import { Exchange } from "../../protocol/Exchange/Exchange.sol";
import { EtherDelta } from "../EtherDelta/EtherDelta.sol";
import { Ownable } from "../../utils/Ownable/Ownable.sol";
import { Token } from "../../tokens/Token/Token.sol";
/// @title Arbitrage - Facilitates atomic arbitrage of ERC20 tokens between EtherDelta and 0x Exchange contract.
/// @author Leonid Logvinov - <leo@0xProject.com>
contract Arbitrage is Ownable {
Exchange exchange;
EtherDelta etherDelta;
address proxyAddress;
uint256 constant MAX_UINT = 2**256 - 1;
function Arbitrage(address _exchangeAddress, address _etherDeltaAddress, address _proxyAddress) {
exchange = Exchange(_exchangeAddress);
etherDelta = EtherDelta(_etherDeltaAddress);
proxyAddress = _proxyAddress;
}
/*
* Makes token tradeable by setting an allowance for etherDelta and 0x proxy contract.
* Also sets an allowance for the owner of the contracts therefore allowing to withdraw tokens.
*/
function setAllowances(address tokenAddress) external onlyOwner {
Token token = Token(tokenAddress);
token.approve(address(etherDelta), MAX_UINT);
token.approve(proxyAddress, MAX_UINT);
token.approve(owner, MAX_UINT);
}
/*
* Because of the limits on the number of local variables in Solidity we need to compress parameters while loosing
* readability. Scheme of the parameter layout:
*
* addresses
* 0..4 orderAddresses
* 5 user
*
* values
* 0..5 orderValues
* 6 fillTakerTokenAmount
* 7 amountGet
* 8 amountGive
* 9 expires
* 10 nonce
* 11 amount
* signature
* exchange then etherDelta
*/
function makeAtomicTrade(
address[6] addresses, uint[12] values,
uint8[2] v, bytes32[2] r, bytes32[2] s
) external onlyOwner {
makeExchangeTrade(addresses, values, v, r, s);
makeEtherDeltaTrade(addresses, values, v, r, s);
}
function makeEtherDeltaTrade(
address[6] addresses, uint[12] values,
uint8[2] v, bytes32[2] r, bytes32[2] s
) internal {
uint amount = values[11];
etherDelta.depositToken(
addresses[2], // tokenGet === makerToken
values[7] // amountGet
);
etherDelta.trade(
addresses[2], // tokenGet === makerToken
values[7], // amountGet
addresses[3], // tokenGive === takerToken
values[8], // amountGive
values[9], // expires
values[10], // nonce
addresses[5], // user
v[1],
r[1],
s[1],
amount
);
etherDelta.withdrawToken(
addresses[3], // tokenGive === tokenToken
values[8] // amountGive
);
}
function makeExchangeTrade(
address[6] addresses, uint[12] values,
uint8[2] v, bytes32[2] r, bytes32[2] s
) internal {
address[5] memory orderAddresses = [
addresses[0], // maker
addresses[1], // taker
addresses[2], // makerToken
addresses[3], // takerToken
addresses[4] // feeRecepient
];
uint[6] memory orderValues = [
values[0], // makerTokenAmount
values[1], // takerTokenAmount
values[2], // makerFee
values[3], // takerFee
values[4], // expirationTimestampInSec
values[5] // salt
];
uint fillTakerTokenAmount = values[6]; // fillTakerTokenAmount
// Execute Exchange trade. It either succeeds in full or fails and reverts all the changes.
exchange.fillOrKillOrder(orderAddresses, orderValues, fillTakerTokenAmount, v[0], r[0], s[0]);
}
}

View File

@ -0,0 +1,11 @@
pragma solidity ^0.4.19;
contract AccountLevels {
//given a user, returns an account level
//0 = regular user (pays take fee and make fee)
//1 = market maker silver (pays take fee, no make fee, gets rebate)
//2 = market maker gold (pays take fee, no make fee, gets entire counterparty's take fee as rebate)
function accountLevel(address user) constant returns(uint) {
return 0;
}
}

View File

@ -0,0 +1,168 @@
pragma solidity ^0.4.19;
import { SafeMath } from "../../utils/SafeMath/SafeMath.sol";
import { AccountLevels } from "./AccountLevels.sol";
import { Token } from "../../tokens/Token/Token.sol";
contract EtherDelta is SafeMath {
address public admin; //the admin address
address public feeAccount; //the account that will receive fees
address public accountLevelsAddr; //the address of the AccountLevels contract
uint public feeMake; //percentage times (1 ether)
uint public feeTake; //percentage times (1 ether)
uint public feeRebate; //percentage times (1 ether)
mapping (address => mapping (address => uint)) public tokens; //mapping of token addresses to mapping of account balances (token=0 means Ether)
mapping (address => mapping (bytes32 => bool)) public orders; //mapping of user accounts to mapping of order hashes to booleans (true = submitted by user, equivalent to offchain signature)
mapping (address => mapping (bytes32 => uint)) public orderFills; //mapping of user accounts to mapping of order hashes to uints (amount of order that has been filled)
event Order(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user);
event Cancel(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s);
event Trade(address tokenGet, uint amountGet, address tokenGive, uint amountGive, address get, address give);
event Deposit(address token, address user, uint amount, uint balance);
event Withdraw(address token, address user, uint amount, uint balance);
function EtherDelta(address admin_, address feeAccount_, address accountLevelsAddr_, uint feeMake_, uint feeTake_, uint feeRebate_) {
admin = admin_;
feeAccount = feeAccount_;
accountLevelsAddr = accountLevelsAddr_;
feeMake = feeMake_;
feeTake = feeTake_;
feeRebate = feeRebate_;
}
function() {
throw;
}
function changeAdmin(address admin_) {
if (msg.sender != admin) throw;
admin = admin_;
}
function changeAccountLevelsAddr(address accountLevelsAddr_) {
if (msg.sender != admin) throw;
accountLevelsAddr = accountLevelsAddr_;
}
function changeFeeAccount(address feeAccount_) {
if (msg.sender != admin) throw;
feeAccount = feeAccount_;
}
function changeFeeMake(uint feeMake_) {
if (msg.sender != admin) throw;
if (feeMake_ > feeMake) throw;
feeMake = feeMake_;
}
function changeFeeTake(uint feeTake_) {
if (msg.sender != admin) throw;
if (feeTake_ > feeTake || feeTake_ < feeRebate) throw;
feeTake = feeTake_;
}
function changeFeeRebate(uint feeRebate_) {
if (msg.sender != admin) throw;
if (feeRebate_ < feeRebate || feeRebate_ > feeTake) throw;
feeRebate = feeRebate_;
}
function deposit() payable {
tokens[0][msg.sender] = safeAdd(tokens[0][msg.sender], msg.value);
Deposit(0, msg.sender, msg.value, tokens[0][msg.sender]);
}
function withdraw(uint amount) {
if (tokens[0][msg.sender] < amount) throw;
tokens[0][msg.sender] = safeSub(tokens[0][msg.sender], amount);
if (!msg.sender.call.value(amount)()) throw;
Withdraw(0, msg.sender, amount, tokens[0][msg.sender]);
}
function depositToken(address token, uint amount) {
//remember to call Token(address).approve(this, amount) or this contract will not be able to do the transfer on your behalf.
if (token==0) throw;
if (!Token(token).transferFrom(msg.sender, this, amount)) throw;
tokens[token][msg.sender] = safeAdd(tokens[token][msg.sender], amount);
Deposit(token, msg.sender, amount, tokens[token][msg.sender]);
}
function withdrawToken(address token, uint amount) {
if (token==0) throw;
if (tokens[token][msg.sender] < amount) throw;
tokens[token][msg.sender] = safeSub(tokens[token][msg.sender], amount);
if (!Token(token).transfer(msg.sender, amount)) throw;
Withdraw(token, msg.sender, amount, tokens[token][msg.sender]);
}
function balanceOf(address token, address user) constant returns (uint) {
return tokens[token][user];
}
function order(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce) {
bytes32 hash = sha256(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce);
orders[msg.sender][hash] = true;
Order(tokenGet, amountGet, tokenGive, amountGive, expires, nonce, msg.sender);
}
function trade(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s, uint amount) {
//amount is in amountGet terms
bytes32 hash = sha256(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce);
if (!(
(orders[user][hash] || ecrecover(sha3("\x19Ethereum Signed Message:\n32", hash),v,r,s) == user) &&
block.number <= expires &&
safeAdd(orderFills[user][hash], amount) <= amountGet
)) throw;
tradeBalances(tokenGet, amountGet, tokenGive, amountGive, user, amount);
orderFills[user][hash] = safeAdd(orderFills[user][hash], amount);
Trade(tokenGet, amount, tokenGive, amountGive * amount / amountGet, user, msg.sender);
}
function tradeBalances(address tokenGet, uint amountGet, address tokenGive, uint amountGive, address user, uint amount) private {
uint feeMakeXfer = safeMul(amount, feeMake) / (1 ether);
uint feeTakeXfer = safeMul(amount, feeTake) / (1 ether);
uint feeRebateXfer = 0;
if (accountLevelsAddr != 0x0) {
uint accountLevel = AccountLevels(accountLevelsAddr).accountLevel(user);
if (accountLevel==1) feeRebateXfer = safeMul(amount, feeRebate) / (1 ether);
if (accountLevel==2) feeRebateXfer = feeTakeXfer;
}
tokens[tokenGet][msg.sender] = safeSub(tokens[tokenGet][msg.sender], safeAdd(amount, feeTakeXfer));
tokens[tokenGet][user] = safeAdd(tokens[tokenGet][user], safeSub(safeAdd(amount, feeRebateXfer), feeMakeXfer));
tokens[tokenGet][feeAccount] = safeAdd(tokens[tokenGet][feeAccount], safeSub(safeAdd(feeMakeXfer, feeTakeXfer), feeRebateXfer));
tokens[tokenGive][user] = safeSub(tokens[tokenGive][user], safeMul(amountGive, amount) / amountGet);
tokens[tokenGive][msg.sender] = safeAdd(tokens[tokenGive][msg.sender], safeMul(amountGive, amount) / amountGet);
}
function testTrade(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s, uint amount, address sender) constant returns(bool) {
if (!(
tokens[tokenGet][sender] >= amount &&
availableVolume(tokenGet, amountGet, tokenGive, amountGive, expires, nonce, user, v, r, s) >= amount
)) return false;
return true;
}
function availableVolume(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s) constant returns(uint) {
bytes32 hash = sha256(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce);
if (!(
(orders[user][hash] || ecrecover(sha3("\x19Ethereum Signed Message:\n32", hash),v,r,s) == user) &&
block.number <= expires
)) return 0;
uint available1 = safeSub(amountGet, orderFills[user][hash]);
uint available2 = safeMul(tokens[tokenGive][user], amountGet) / amountGive;
if (available1<available2) return available1;
return available2;
}
function amountFilled(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s) constant returns(uint) {
bytes32 hash = sha256(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce);
return orderFills[user][hash];
}
function cancelOrder(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, uint8 v, bytes32 r, bytes32 s) {
bytes32 hash = sha256(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce);
if (!(orders[msg.sender][hash] || ecrecover(sha3("\x19Ethereum Signed Message:\n32", hash),v,r,s) == msg.sender)) throw;
orderFills[msg.sender][hash] = amountGet;
Cancel(tokenGet, amountGet, tokenGive, amountGive, expires, nonce, msg.sender, v, r, s);
}
}

View File

@ -0,0 +1,226 @@
import { ECSignature, SignedOrder, ZeroEx } from '0x.js';
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as chai from 'chai';
import ethUtil = require('ethereumjs-util');
import * as Web3 from 'web3';
import { ArbitrageContract } from '../../src/contract_wrappers/generated/arbitrage';
import { EtherDeltaContract } from '../../src/contract_wrappers/generated/ether_delta';
import { ExchangeContract } from '../../src/contract_wrappers/generated/exchange';
import { Balances } from '../../util/balances';
import { constants } from '../../util/constants';
import { crypto } from '../../util/crypto';
import { ExchangeWrapper } from '../../util/exchange_wrapper';
import { OrderFactory } from '../../util/order_factory';
import { BalancesByOwner, ContractName, ExchangeContractErrs } from '../../util/types';
import { chaiSetup } from '../utils/chai_setup';
import { deployer } from '../utils/deployer';
chaiSetup.configure();
const expect = chai.expect;
const web3 = web3Factory.create();
const web3Wrapper = new Web3Wrapper(web3.currentProvider);
const blockchainLifecycle = new BlockchainLifecycle();
describe('Arbitrage', () => {
let coinbase: string;
let maker: string;
let edMaker: string;
let edFrontRunner: string;
let amountGet: BigNumber;
let amountGive: BigNumber;
let makerTokenAmount: BigNumber;
let takerTokenAmount: BigNumber;
const feeRecipient = ZeroEx.NULL_ADDRESS;
const INITIAL_BALANCE = ZeroEx.toBaseUnitAmount(new BigNumber(10000), 18);
const INITIAL_ALLOWANCE = ZeroEx.toBaseUnitAmount(new BigNumber(10000), 18);
let weth: Web3.ContractInstance;
let zrx: Web3.ContractInstance;
let arbitrage: ArbitrageContract;
let etherDelta: EtherDeltaContract;
let signedOrder: SignedOrder;
let exWrapper: ExchangeWrapper;
let orderFactory: OrderFactory;
let zeroEx: ZeroEx;
// From a bird's eye view - we create two orders.
// 0x order of 1 ZRX (maker) for 1 WETH (taker)
// ED order of 2 WETH (tokenGive) for 1 ZRX (tokenGet)
// And then we do an atomic arbitrage between them which gives us 1 WETH.
before(async () => {
const accounts = await web3Wrapper.getAvailableAddressesAsync();
[coinbase, maker, edMaker, edFrontRunner] = accounts;
weth = await deployer.deployAsync(ContractName.DummyToken);
zrx = await deployer.deployAsync(ContractName.DummyToken);
const accountLevels = await deployer.deployAsync(ContractName.AccountLevels);
const edAdminAddress = accounts[0];
const edMakerFee = 0;
const edTakerFee = 0;
const edFeeRebate = 0;
const etherDeltaInstance = await deployer.deployAsync(ContractName.EtherDelta, [
edAdminAddress,
feeRecipient,
accountLevels.address,
edMakerFee,
edTakerFee,
edFeeRebate,
]);
etherDelta = new EtherDeltaContract(web3Wrapper, etherDeltaInstance.abi, etherDeltaInstance.address);
const tokenTransferProxy = await deployer.deployAsync(ContractName.TokenTransferProxy);
const exchangeInstance = await deployer.deployAsync(ContractName.Exchange, [
zrx.address,
tokenTransferProxy.address,
]);
await tokenTransferProxy.addAuthorizedAddress(exchangeInstance.address, { from: accounts[0] });
zeroEx = new ZeroEx(web3.currentProvider, {
exchangeContractAddress: exchangeInstance.address,
networkId: constants.TESTRPC_NETWORK_ID,
});
const exchange = new ExchangeContract(web3Wrapper, exchangeInstance.abi, exchangeInstance.address);
exWrapper = new ExchangeWrapper(exchange, zeroEx);
makerTokenAmount = ZeroEx.toBaseUnitAmount(new BigNumber(1), 18);
takerTokenAmount = makerTokenAmount;
const defaultOrderParams = {
exchangeContractAddress: exchange.address,
maker,
feeRecipient,
makerTokenAddress: zrx.address,
takerTokenAddress: weth.address,
makerTokenAmount,
takerTokenAmount,
makerFee: new BigNumber(0),
takerFee: new BigNumber(0),
};
orderFactory = new OrderFactory(zeroEx, defaultOrderParams);
const arbitrageInstance = await deployer.deployAsync(ContractName.Arbitrage, [
exchange.address,
etherDelta.address,
tokenTransferProxy.address,
]);
arbitrage = new ArbitrageContract(web3Wrapper, arbitrageInstance.abi, arbitrageInstance.address);
// Enable arbitrage and withdrawals of tokens
await arbitrage.setAllowances.sendTransactionAsync(weth.address, { from: coinbase });
await arbitrage.setAllowances.sendTransactionAsync(zrx.address, { from: coinbase });
// Give some tokens to arbitrage contract
await weth.setBalance(arbitrage.address, takerTokenAmount, { from: coinbase });
// Fund the maker on exchange side
await zrx.setBalance(maker, makerTokenAmount, { from: coinbase });
// Set the allowance for the maker on Exchange side
await zrx.approve(tokenTransferProxy.address, INITIAL_ALLOWANCE, { from: maker });
amountGive = ZeroEx.toBaseUnitAmount(new BigNumber(2), 18);
// Fund the maker on EtherDelta side
await weth.setBalance(edMaker, amountGive, { from: coinbase });
// Set the allowance for the maker on EtherDelta side
await weth.approve(etherDelta.address, INITIAL_ALLOWANCE, { from: edMaker });
// Deposit maker funds into EtherDelta
await etherDelta.depositToken.sendTransactionAsync(weth.address, amountGive, { from: edMaker });
amountGet = makerTokenAmount;
// Fund the front runner on EtherDelta side
await zrx.setBalance(edFrontRunner, amountGet, { from: coinbase });
// Set the allowance for the front-runner on EtherDelta side
await zrx.approve(etherDelta.address, INITIAL_ALLOWANCE, { from: edFrontRunner });
// Deposit front runner funds into EtherDelta
await etherDelta.depositToken.sendTransactionAsync(zrx.address, amountGet, { from: edFrontRunner });
});
beforeEach(async () => {
await blockchainLifecycle.startAsync();
});
afterEach(async () => {
await blockchainLifecycle.revertAsync();
});
describe('makeAtomicTrade', () => {
let addresses: string[];
let values: BigNumber[];
let v: number[];
let r: string[];
let s: string[];
let tokenGet: string;
let tokenGive: string;
let expires: BigNumber;
let nonce: BigNumber;
let edSignature: ECSignature;
before(async () => {
signedOrder = await orderFactory.newSignedOrderAsync();
tokenGet = zrx.address;
tokenGive = weth.address;
const blockNumber = await web3Wrapper.getBlockNumberAsync();
const ED_ORDER_EXPIRATION_IN_BLOCKS = 10;
expires = new BigNumber(blockNumber + ED_ORDER_EXPIRATION_IN_BLOCKS);
nonce = new BigNumber(42);
const edOrderHash = `0x${crypto
.solSHA256([etherDelta.address, tokenGet, amountGet, tokenGive, amountGive, expires, nonce])
.toString('hex')}`;
const shouldAddPersonalMessagePrefix = false;
edSignature = await zeroEx.signOrderHashAsync(edOrderHash, edMaker, shouldAddPersonalMessagePrefix);
addresses = [
signedOrder.maker,
signedOrder.taker,
signedOrder.makerTokenAddress,
signedOrder.takerTokenAddress,
signedOrder.feeRecipient,
edMaker,
];
const fillTakerTokenAmount = takerTokenAmount;
const edFillAmount = makerTokenAmount;
values = [
signedOrder.makerTokenAmount,
signedOrder.takerTokenAmount,
signedOrder.makerFee,
signedOrder.takerFee,
signedOrder.expirationUnixTimestampSec,
signedOrder.salt,
fillTakerTokenAmount,
amountGet,
amountGive,
expires,
nonce,
edFillAmount,
];
v = [signedOrder.ecSignature.v, edSignature.v];
r = [signedOrder.ecSignature.r, edSignature.r];
s = [signedOrder.ecSignature.s, edSignature.s];
});
it('should successfully execute the arbitrage if not front-runned', async () => {
const txHash = await arbitrage.makeAtomicTrade.sendTransactionAsync(addresses, values, v, r, s, {
from: coinbase,
});
const res = await zeroEx.awaitTransactionMinedAsync(txHash);
const postBalance = await weth.balanceOf(arbitrage.address);
expect(postBalance).to.be.bignumber.equal(amountGive);
});
it('should fail and revert if front-runned', async () => {
const preBalance = await weth.balanceOf(arbitrage.address);
// Front-running transaction
await etherDelta.trade.sendTransactionAsync(
tokenGet,
amountGet,
tokenGive,
amountGive,
expires,
nonce,
edMaker,
edSignature.v,
edSignature.r,
edSignature.s,
amountGet,
{ from: edFrontRunner },
);
// tslint:disable-next-line:await-promise
await expect(
arbitrage.makeAtomicTrade.sendTransactionAsync(addresses, values, v, r, s, { from: coinbase }),
).to.be.rejectedWith(constants.REVERT);
const postBalance = await weth.balanceOf(arbitrage.address);
expect(preBalance).to.be.bignumber.equal(postBalance);
});
});
});

View File

@ -13,6 +13,12 @@ export const crypto = {
* valid Ethereum address -> address * valid Ethereum address -> address
*/ */
solSHA3(args: any[]): Buffer { solSHA3(args: any[]): Buffer {
return crypto._solHash(args, ABI.soliditySHA3);
},
solSHA256(args: any[]): Buffer {
return crypto._solHash(args, ABI.soliditySHA256);
},
_solHash(args: any[], hashFunction: (types: string[], values: any[]) => Buffer) {
const argTypes: string[] = []; const argTypes: string[] = [];
_.each(args, (arg, i) => { _.each(args, (arg, i) => {
const isNumber = _.isFinite(arg); const isNumber = _.isFinite(arg);
@ -31,7 +37,7 @@ export const crypto = {
throw new Error(`Unable to guess arg type: ${arg}`); throw new Error(`Unable to guess arg type: ${arg}`);
} }
}); });
const hash = ABI.soliditySHA3(argTypes, args); const hash = hashFunction(argTypes, args);
return hash; return hash;
}, },
}; };

View File

@ -96,6 +96,9 @@ export enum ContractName {
EtherToken = 'WETH9', EtherToken = 'WETH9',
MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress = 'MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress', MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress = 'MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress',
MaliciousToken = 'MaliciousToken', MaliciousToken = 'MaliciousToken',
AccountLevels = 'AccountLevels',
EtherDelta = 'EtherDelta',
Arbitrage = 'Arbitrage',
} }
export interface Artifact { export interface Artifact {

View File

@ -1,6 +1,6 @@
# CHANGELOG # CHANGELOG
## v0.2.0 - _TBD, 2018_ ## v0.2.0 - _March 4, 2018_
* Check dependencies when determining if contracts should be recompiled (#408). * Check dependencies when determining if contracts should be recompiled (#408).

View File

@ -22,11 +22,11 @@ Commands:
Options: Options:
--version Show version number [boolean] --version Show version number [boolean]
--contracts-dir path of contracts directory to compile --contracts-dir path of contracts directory to compile
[string] [default: "/Users/leonidlogvinov/Dev/0x/0x.js/contracts"] [string] [default: "/Users/leonidlogvinov/Dev/0x/contracts"]
--network-id mainnet=1, kovan=42, testrpc=50 [number] [default: 50] --network-id mainnet=1, kovan=42, testrpc=50 [number] [default: 50]
--should-optimize enable optimizer [boolean] [default: false] --should-optimize enable optimizer [boolean] [default: false]
--artifacts-dir path to write contracts artifacts to --artifacts-dir path to write contracts artifacts to
[string] [default: "/Users/leonidlogvinov/Dev/0x/0x.js/build/artifacts/"] [string] [default: "/Users/leonidlogvinov/Dev/0x/build/artifacts/"]
--jsonrpc-port port connected to JSON RPC [number] [default: 8545] --jsonrpc-port port connected to JSON RPC [number] [default: 8545]
--gas-price gasPrice to be used for transactions --gas-price gasPrice to be used for transactions
[string] [default: "2000000000"] [string] [default: "2000000000"]

View File

@ -1,6 +1,6 @@
{ {
"name": "@0xproject/deployer", "name": "@0xproject/deployer",
"version": "0.1.0", "version": "0.2.0",
"description": "Smart contract deployer of 0x protocol", "description": "Smart contract deployer of 0x protocol",
"main": "lib/src/index.js", "main": "lib/src/index.js",
"types": "lib/src/index.d.ts", "types": "lib/src/index.d.ts",
@ -19,31 +19,31 @@
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/0xProject/0x.js.git" "url": "https://github.com/0xProject/0x-monorepo.git"
}, },
"author": "Amir Bandeali", "author": "Amir Bandeali",
"license": "Apache-2.0", "license": "Apache-2.0",
"bugs": { "bugs": {
"url": "https://github.com/0xProject/0x.js/issues" "url": "https://github.com/0xProject/0x-monorepo/issues"
}, },
"homepage": "https://github.com/0xProject/0x.js/packages/deployer/README.md", "homepage": "https://github.com/0xProject/0x-monorepo/packages/deployer/README.md",
"devDependencies": { "devDependencies": {
"@0xproject/tslint-config": "^0.4.9", "@0xproject/tslint-config": "^0.4.10",
"chai": "^4.0.1", "chai": "^4.0.1",
"copyfiles": "^1.2.0", "copyfiles": "^1.2.0",
"ethers-typescript-typings": "^0.0.2",
"mocha": "^4.0.1", "mocha": "^4.0.1",
"shx": "^0.2.2", "shx": "^0.2.2",
"tslint": "5.8.0", "tslint": "5.8.0",
"types-bn": "^0.0.1", "types-bn": "^0.0.1",
"typescript": "2.7.1", "typescript": "2.7.1",
"ethers-typescript-typings": "^0.0.1", "web3-typescript-typings": "^0.10.0"
"web3-typescript-typings": "^0.9.11"
}, },
"dependencies": { "dependencies": {
"@0xproject/json-schemas": "^0.7.12", "@0xproject/json-schemas": "^0.7.13",
"@0xproject/types": "^0.2.3", "@0xproject/types": "^0.3.0",
"@0xproject/utils": "^0.3.4", "@0xproject/utils": "^0.4.0",
"@0xproject/web3-wrapper": "^0.1.14", "@0xproject/web3-wrapper": "^0.2.0",
"ethereumjs-util": "^5.1.1", "ethereumjs-util": "^5.1.1",
"lodash": "^4.17.4", "lodash": "^4.17.4",
"solc": "^0.4.18", "solc": "^0.4.18",

View File

@ -1,6 +1,6 @@
# CHANGELOG # CHANGELOG
## v0.1.0 - _February 16, 2018_ ## v0.2.0 - _February 16, 2018_
* Remove subproviders (#392) * Remove subproviders (#392)

View File

@ -7,3 +7,11 @@ Dev utils to be shared across 0x projects and packages
```bash ```bash
yarn add @0xproject/dev-utils yarn add @0xproject/dev-utils
``` ```
If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`:
```
"include": [
"./node_modules/web3-typescript-typings/index.d.ts",
]
```

View File

@ -1,6 +1,6 @@
{ {
"name": "@0xproject/dev-utils", "name": "@0xproject/dev-utils",
"version": "0.1.0", "version": "0.2.0",
"description": "0x dev TS utils", "description": "0x dev TS utils",
"main": "lib/src/index.js", "main": "lib/src/index.js",
"types": "lib/src/index.d.ts", "types": "lib/src/index.d.ts",
@ -16,19 +16,19 @@
"license": "Apache-2.0", "license": "Apache-2.0",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/0xProject/0x.js.git" "url": "https://github.com/0xProject/0x-monorepo.git"
}, },
"bugs": { "bugs": {
"url": "https://github.com/0xProject/0x.js/issues" "url": "https://github.com/0xProject/0x-monorepo/issues"
}, },
"homepage": "https://github.com/0xProject/0x.js/packages/dev-utils/README.md", "homepage": "https://github.com/0xProject/0x-monorepo/packages/dev-utils/README.md",
"devDependencies": { "devDependencies": {
"@0xproject/tslint-config": "^0.4.9", "@0xproject/tslint-config": "^0.4.10",
"@0xproject/web3-wrapper": "^0.1.14", "@0xproject/web3-wrapper": "^0.2.0",
"@types/lodash": "^4.14.86", "@types/lodash": "^4.14.86",
"@types/mocha": "^2.2.42", "@types/mocha": "^2.2.42",
"chai": "^4.0.1", "chai": "^4.0.1",
"chai-typescript-typings": "^0.0.3", "chai-typescript-typings": "^0.0.4",
"mocha": "^4.0.1", "mocha": "^4.0.1",
"npm-run-all": "^4.1.2", "npm-run-all": "^4.1.2",
"shx": "^0.2.2", "shx": "^0.2.2",
@ -38,9 +38,9 @@
"typescript": "2.7.1" "typescript": "2.7.1"
}, },
"dependencies": { "dependencies": {
"@0xproject/subproviders": "^0.5.0", "@0xproject/subproviders": "^0.6.0",
"@0xproject/types": "^0.2.3", "@0xproject/types": "^0.3.0",
"@0xproject/utils": "^0.3.4", "@0xproject/utils": "^0.4.0",
"ethereumjs-util": "^5.1.2", "ethereumjs-util": "^5.1.2",
"lodash": "^4.17.4", "lodash": "^4.17.4",
"request-promise-native": "^1.0.5", "request-promise-native": "^1.0.5",

View File

@ -1,5 +1,5 @@
# CHANGELOG # CHANGELOG
## v0.0.1 - _TBD, 2018_ ## v0.0.2 - _March 4, 2018_
* Initial types (#413) * Initial types (#413)

View File

@ -1,6 +1,6 @@
{ {
"name": "ethers-typescript-typings", "name": "ethers-typescript-typings",
"version": "0.0.1", "version": "0.0.2",
"description": "Typescript type definitions for ethers.js", "description": "Typescript type definitions for ethers.js",
"main": "index.d.ts", "main": "index.d.ts",
"types": "index.d.ts", "types": "index.d.ts",
@ -9,7 +9,7 @@
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/0xProject/0x.js.git" "url": "git+https://github.com/0xProject/0x-monorepo.git"
}, },
"author": "Fabio Berger", "author": "Fabio Berger",
"contributors": [ "contributors": [
@ -17,9 +17,9 @@
], ],
"license": "Apache-2.0", "license": "Apache-2.0",
"bugs": { "bugs": {
"url": "https://github.com/0xProject/0x.js/issues" "url": "https://github.com/0xProject/0x-monorepo/issues"
}, },
"homepage": "https://github.com/0xProject/0x.js/packages/ethers-typescript-typings#readme", "homepage": "https://github.com/0xProject/0x-monorepo/packages/ethers-typescript-typings#readme",
"devDependencies": { "devDependencies": {
"tslint": "5.8.0", "tslint": "5.8.0",
"tslint-config-0xproject": "^0.0.2", "tslint-config-0xproject": "^0.0.2",

View File

@ -1,8 +1,8 @@
# CHANGELOG # CHANGELOG
## v0.7.10 - _February 9, 2018_ ## v0.7.13 - _February 9, 2018_
* Fix publishing issue where .npmignore was not properly excluding undesired content (#389) * Fix publishing issue where .npmignore was not properly excluding undesired content (#389)
## v0.7.0 - _December 20, 2017_ ## v0.7.0 - _December 20, 2017_

View File

@ -1,6 +1,6 @@
{ {
"name": "@0xproject/json-schemas", "name": "@0xproject/json-schemas",
"version": "0.7.12", "version": "0.7.13",
"description": "0x-related json schemas", "description": "0x-related json schemas",
"main": "lib/src/index.js", "main": "lib/src/index.js",
"types": "lib/src/index.d.ts", "types": "lib/src/index.d.ts",
@ -15,26 +15,26 @@
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/0xProject/0x.js.git" "url": "https://github.com/0xProject/0x-monorepo.git"
}, },
"author": "", "author": "",
"license": "Apache-2.0", "license": "Apache-2.0",
"bugs": { "bugs": {
"url": "https://github.com/0xProject/0x.js/issues" "url": "https://github.com/0xProject/0x-monorepo/issues"
}, },
"homepage": "https://github.com/0xProject/0x.js/packages/json-schemas/README.md", "homepage": "https://github.com/0xProject/0x-monorepo/packages/json-schemas/README.md",
"dependencies": { "dependencies": {
"jsonschema": "^1.2.0", "jsonschema": "^1.2.0",
"lodash.values": "^4.3.0" "lodash.values": "^4.3.0"
}, },
"devDependencies": { "devDependencies": {
"@0xproject/tslint-config": "^0.4.9", "@0xproject/tslint-config": "^0.4.10",
"@0xproject/utils": "^0.3.4", "@0xproject/utils": "^0.4.0",
"@types/lodash.foreach": "^4.5.3", "@types/lodash.foreach": "^4.5.3",
"@types/lodash.values": "^4.3.3", "@types/lodash.values": "^4.3.3",
"@types/mocha": "^2.2.42", "@types/mocha": "^2.2.42",
"chai": "^4.0.1", "chai": "^4.0.1",
"chai-typescript-typings": "^0.0.3", "chai-typescript-typings": "^0.0.4",
"dirty-chai": "^2.0.1", "dirty-chai": "^2.0.1",
"lodash.foreach": "^4.5.0", "lodash.foreach": "^4.5.0",
"mocha": "^4.0.1", "mocha": "^4.0.1",

View File

@ -1,6 +1,6 @@
{ {
"name": "@0xproject/monorepo-scripts", "name": "@0xproject/monorepo-scripts",
"version": "0.1.11", "version": "0.1.12",
"private": true, "private": true,
"description": "Helper scripts for the monorepo", "description": "Helper scripts for the monorepo",
"scripts": { "scripts": {
@ -12,15 +12,15 @@
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/0xProject/0x.js.git" "url": "https://github.com/0xProject/0x-monorepo.git"
}, },
"license": "Apache-2.0", "license": "Apache-2.0",
"bugs": { "bugs": {
"url": "https://github.com/0xProject/0x.js/issues" "url": "https://github.com/0xProject/0x-monorepo/issues"
}, },
"homepage": "https://github.com/0xProject/0x.js/packages/monorepo-scripts/README.md", "homepage": "https://github.com/0xProject/0x-monorepo/packages/monorepo-scripts/README.md",
"devDependencies": { "devDependencies": {
"@0xproject/tslint-config": "^0.4.9", "@0xproject/tslint-config": "^0.4.10",
"@types/glob": "^5.0.33", "@types/glob": "^5.0.33",
"@types/node": "^8.0.53", "@types/node": "^8.0.53",
"shx": "^0.2.2", "shx": "^0.2.2",

View File

@ -1,5 +1,10 @@
# CHANGELOG # CHANGELOG
## v0.6.0 - _March 4, 2018_
* Move web3 types from being a devDep to a dep since one cannot use this package without it (#429)
* Add `numberOfAccounts` param to `LedgerSubprovider` method `getAccountsAsync` (#432)
## v0.5.0 - _February 16, 2018_ ## v0.5.0 - _February 16, 2018_
* Add EmptyWalletSubprovider and FakeGasEstimateSubprovider (#392) * Add EmptyWalletSubprovider and FakeGasEstimateSubprovider (#392)

View File

@ -10,6 +10,14 @@ We have written up a [Wiki](https://0xproject.com/wiki#Web3-Provider-Examples) a
yarn add @0xproject/subproviders yarn add @0xproject/subproviders
``` ```
If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`:
```
"include": [
"./node_modules/web3-typescript-typings/index.d.ts",
]
```
## Usage ## Usage
Simply import the subprovider you are interested in using: Simply import the subprovider you are interested in using:

View File

@ -1,6 +1,6 @@
{ {
"name": "@0xproject/subproviders", "name": "@0xproject/subproviders",
"version": "0.5.0", "version": "0.6.0",
"main": "lib/src/index.js", "main": "lib/src/index.js",
"types": "lib/src/index.d.ts", "types": "lib/src/index.d.ts",
"license": "Apache-2.0", "license": "Apache-2.0",
@ -18,9 +18,9 @@
"test:integration": "run-s clean build run_mocha_integration" "test:integration": "run-s clean build run_mocha_integration"
}, },
"dependencies": { "dependencies": {
"@0xproject/assert": "^0.0.20", "@0xproject/assert": "^0.1.0",
"@0xproject/types": "^0.2.3", "@0xproject/types": "^0.3.0",
"@0xproject/utils": "^0.3.4", "@0xproject/utils": "^0.4.0",
"bn.js": "^4.11.8", "bn.js": "^4.11.8",
"es6-promisify": "^5.0.0", "es6-promisify": "^5.0.0",
"ethereumjs-tx": "^1.3.3", "ethereumjs-tx": "^1.3.3",
@ -30,19 +30,20 @@
"lodash": "^4.17.4", "lodash": "^4.17.4",
"semaphore-async-await": "^1.5.1", "semaphore-async-await": "^1.5.1",
"web3": "^0.20.0", "web3": "^0.20.0",
"web3-provider-engine": "^13.0.1" "web3-provider-engine": "^13.0.1",
"web3-typescript-typings": "^0.10.0"
}, },
"devDependencies": { "devDependencies": {
"@0xproject/tslint-config": "^0.4.9", "@0xproject/tslint-config": "^0.4.10",
"@0xproject/utils": "^0.3.4", "@0xproject/utils": "^0.4.0",
"@types/lodash": "^4.14.86", "@types/lodash": "^4.14.86",
"@types/mocha": "^2.2.42", "@types/mocha": "^2.2.42",
"@types/node": "^8.0.53", "@types/node": "^8.0.53",
"awesome-typescript-loader": "^3.1.3", "awesome-typescript-loader": "^3.1.3",
"chai": "^4.0.1", "chai": "^4.0.1",
"chai-as-promised": "^7.1.0", "chai-as-promised": "^7.1.0",
"chai-as-promised-typescript-typings": "^0.0.9", "chai-as-promised-typescript-typings": "^0.0.10",
"chai-typescript-typings": "^0.0.3", "chai-typescript-typings": "^0.0.4",
"dirty-chai": "^2.0.1", "dirty-chai": "^2.0.1",
"mocha": "^4.0.1", "mocha": "^4.0.1",
"npm-run-all": "^4.1.2", "npm-run-all": "^4.1.2",
@ -51,7 +52,6 @@
"types-bn": "^0.0.1", "types-bn": "^0.0.1",
"types-ethereumjs-util": "0xProject/types-ethereumjs-util", "types-ethereumjs-util": "0xProject/types-ethereumjs-util",
"typescript": "2.7.1", "typescript": "2.7.1",
"web3-typescript-typings": "^0.9.11",
"webpack": "^3.1.0" "webpack": "^3.1.0"
} }
} }

View File

@ -19,7 +19,7 @@ import {
import { Subprovider } from './subprovider'; import { Subprovider } from './subprovider';
const DEFAULT_DERIVATION_PATH = `44'/60'/0'`; const DEFAULT_DERIVATION_PATH = `44'/60'/0'`;
const NUM_ADDRESSES_TO_FETCH = 10; const DEFAULT_NUM_ADDRESSES_TO_FETCH = 10;
const ASK_FOR_ON_DEVICE_CONFIRMATION = false; const ASK_FOR_ON_DEVICE_CONFIRMATION = false;
const SHOULD_GET_CHAIN_CODE = true; const SHOULD_GET_CHAIN_CODE = true;
@ -129,7 +129,7 @@ export class LedgerSubprovider extends Subprovider {
return; return;
} }
} }
public async getAccountsAsync(): Promise<string[]> { public async getAccountsAsync(numberOfAccounts: number = DEFAULT_NUM_ADDRESSES_TO_FETCH): Promise<string[]> {
this._ledgerClientIfExists = await this._createLedgerClientAsync(); this._ledgerClientIfExists = await this._createLedgerClientAsync();
let ledgerResponse; let ledgerResponse;
@ -148,7 +148,7 @@ export class LedgerSubprovider extends Subprovider {
hdKey.chainCode = new Buffer(ledgerResponse.chainCode, 'hex'); hdKey.chainCode = new Buffer(ledgerResponse.chainCode, 'hex');
const accounts = []; const accounts = [];
for (let i = 0; i < NUM_ADDRESSES_TO_FETCH; i++) { for (let i = 0; i < numberOfAccounts; i++) {
const derivedHDNode = hdKey.derive(`m/${i + this._derivationPathIndex}`); const derivedHDNode = hdKey.derive(`m/${i + this._derivationPathIndex}`);
const derivedPublicKey = derivedHDNode.publicKey; const derivedPublicKey = derivedHDNode.publicKey;
const shouldSanitizePublicKey = true; const shouldSanitizePublicKey = true;

View File

@ -26,11 +26,17 @@ describe('LedgerSubprovider', () => {
}); });
}); });
describe('direct method calls', () => { describe('direct method calls', () => {
it('returns a list of accounts', async () => { it('returns default number of accounts', async () => {
const accounts = await ledgerSubprovider.getAccountsAsync(); const accounts = await ledgerSubprovider.getAccountsAsync();
expect(accounts[0]).to.not.be.an('undefined'); expect(accounts[0]).to.not.be.an('undefined');
expect(accounts.length).to.be.equal(10); expect(accounts.length).to.be.equal(10);
}); });
it('returns requested number of accounts', async () => {
const numberOfAccounts = 20;
const accounts = await ledgerSubprovider.getAccountsAsync(numberOfAccounts);
expect(accounts[0]).to.not.be.an('undefined');
expect(accounts.length).to.be.equal(numberOfAccounts);
});
it('signs a personal message', async () => { it('signs a personal message', async () => {
const data = ethUtils.bufferToHex(ethUtils.toBuffer('hello world')); const data = ethUtils.bufferToHex(ethUtils.toBuffer('hello world'));
const ecSignatureHex = await ledgerSubprovider.signPersonalMessageAsync(data); const ecSignatureHex = await ledgerSubprovider.signPersonalMessageAsync(data);
@ -172,7 +178,7 @@ describe('LedgerSubprovider', () => {
}; };
const callback = reportCallbackErrors(done)((err: Error, response: Web3.JSONRPCResponsePayload) => { const callback = reportCallbackErrors(done)((err: Error, response: Web3.JSONRPCResponsePayload) => {
expect(err).to.be.a('null'); expect(err).to.be.a('null');
const result = response.result.result; const result = response.result;
expect(result.length).to.be.equal(66); expect(result.length).to.be.equal(66);
expect(result.substr(0, 2)).to.be.equal('0x'); expect(result.substr(0, 2)).to.be.equal('0x');
done(); done();

View File

@ -62,11 +62,17 @@ describe('LedgerSubprovider', () => {
}); });
describe('direct method calls', () => { describe('direct method calls', () => {
describe('success cases', () => { describe('success cases', () => {
it('returns a list of accounts', async () => { it('returns default number of accounts', async () => {
const accounts = await ledgerSubprovider.getAccountsAsync(); const accounts = await ledgerSubprovider.getAccountsAsync();
expect(accounts[0]).to.be.equal(FAKE_ADDRESS); expect(accounts[0]).to.be.equal(FAKE_ADDRESS);
expect(accounts.length).to.be.equal(10); expect(accounts.length).to.be.equal(10);
}); });
it('returns requested number of accounts', async () => {
const numberOfAccounts = 20;
const accounts = await ledgerSubprovider.getAccountsAsync(numberOfAccounts);
expect(accounts[0]).to.be.equal(FAKE_ADDRESS);
expect(accounts.length).to.be.equal(numberOfAccounts);
});
it('signs a personal message', async () => { it('signs a personal message', async () => {
const data = ethUtils.bufferToHex(ethUtils.toBuffer('hello world')); const data = ethUtils.bufferToHex(ethUtils.toBuffer('hello world'));
const ecSignatureHex = await ledgerSubprovider.signPersonalMessageAsync(data); const ecSignatureHex = await ledgerSubprovider.signPersonalMessageAsync(data);

View File

@ -1,7 +1,7 @@
{ {
"private": true, "private": true,
"name": "@0xproject/testnet-faucets", "name": "@0xproject/testnet-faucets",
"version": "1.0.14", "version": "1.0.15",
"description": "A faucet micro-service that dispenses test ERC20 tokens or Ether", "description": "A faucet micro-service that dispenses test ERC20 tokens or Ether",
"main": "server.js", "main": "server.js",
"scripts": { "scripts": {
@ -15,9 +15,9 @@
"author": "Fabio Berger", "author": "Fabio Berger",
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"0x.js": "^0.32.4", "0x.js": "^0.33.0",
"@0xproject/subproviders": "^0.5.0", "@0xproject/subproviders": "^0.6.0",
"@0xproject/utils": "^0.3.4", "@0xproject/utils": "^0.4.0",
"body-parser": "^1.17.1", "body-parser": "^1.17.1",
"ethereumjs-tx": "^1.3.3", "ethereumjs-tx": "^1.3.3",
"ethereumjs-util": "^5.1.1", "ethereumjs-util": "^5.1.1",
@ -28,7 +28,7 @@
"web3-provider-engine": "^13.0.1" "web3-provider-engine": "^13.0.1"
}, },
"devDependencies": { "devDependencies": {
"@0xproject/tslint-config": "^0.4.9", "@0xproject/tslint-config": "^0.4.10",
"@types/body-parser": "^1.16.1", "@types/body-parser": "^1.16.1",
"@types/express": "^4.0.35", "@types/express": "^4.0.35",
"@types/lodash": "^4.14.86", "@types/lodash": "^4.14.86",
@ -41,7 +41,7 @@
"types-bn": "^0.0.1", "types-bn": "^0.0.1",
"types-ethereumjs-util": "0xProject/types-ethereumjs-util", "types-ethereumjs-util": "0xProject/types-ethereumjs-util",
"typescript": "2.7.1", "typescript": "2.7.1",
"web3-typescript-typings": "^0.9.11", "web3-typescript-typings": "^0.10.0",
"webpack": "^3.1.0", "webpack": "^3.1.0",
"webpack-node-externals": "^1.6.0" "webpack-node-externals": "^1.6.0"
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "@0xproject/tslint-config", "name": "@0xproject/tslint-config",
"version": "0.4.9", "version": "0.4.10",
"description": "Lint rules related to 0xProject for TSLint", "description": "Lint rules related to 0xProject for TSLint",
"main": "tslint.json", "main": "tslint.json",
"scripts": { "scripts": {
@ -11,7 +11,7 @@
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git://github.com/0xProject/0x.js.git" "url": "git://github.com/0xProject/0x-monorepo.git"
}, },
"keywords": [ "keywords": [
"tslint", "tslint",
@ -26,9 +26,9 @@
}, },
"license": "Apache-2.0", "license": "Apache-2.0",
"bugs": { "bugs": {
"url": "https://github.com/0xProject/0x.js/issues" "url": "https://github.com/0xProject/0x-monorepo/issues"
}, },
"homepage": "https://github.com/0xProject/0x.js/packages/tslint-config/README.md", "homepage": "https://github.com/0xProject/0x-monorepo/packages/tslint-config/README.md",
"devDependencies": { "devDependencies": {
"@types/lodash": "^4.14.86", "@types/lodash": "^4.14.86",
"shx": "^0.2.2", "shx": "^0.2.2",

View File

@ -1,9 +1,10 @@
# CHANGELOG # CHANGELOG
## v0.2.4 - _TBD, 2018_ ## v0.3.0 - _March 4, 2018_
* Add `data` to `TxData` (#413) * Add `data` to `TxData` (#413)
* Add `number` as an option to `ContractEventArg` (#413) * Add `number` as an option to `ContractEventArg` (#413)
* Move web3 types from devDep to dep since required when using this package (#429)
## v0.2.1 - _February 9, 2018_ ## v0.2.1 - _February 9, 2018_

View File

@ -8,6 +8,14 @@ Typescript types shared across 0x projects and packages
yarn add -D @0xproject/types yarn add -D @0xproject/types
``` ```
If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`:
```
"include": [
"./node_modules/web3-typescript-typings/index.d.ts",
]
```
## Usage ## Usage
```javascript ```javascript

View File

@ -1,6 +1,6 @@
{ {
"name": "@0xproject/types", "name": "@0xproject/types",
"version": "0.2.3", "version": "0.3.0",
"description": "0x types", "description": "0x types",
"main": "lib/index.js", "main": "lib/index.js",
"types": "lib/index.d.ts", "types": "lib/index.d.ts",
@ -13,21 +13,21 @@
"license": "Apache-2.0", "license": "Apache-2.0",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/0xProject/0x.js.git" "url": "https://github.com/0xProject/0x-monorepo.git"
}, },
"bugs": { "bugs": {
"url": "https://github.com/0xProject/0x.js/issues" "url": "https://github.com/0xProject/0x-monorepo/issues"
}, },
"homepage": "https://github.com/0xProject/0x.js/packages/types/README.md", "homepage": "https://github.com/0xProject/0x-monorepo/packages/types/README.md",
"devDependencies": { "devDependencies": {
"@0xproject/tslint-config": "^0.4.9", "@0xproject/tslint-config": "^0.4.10",
"shx": "^0.2.2", "shx": "^0.2.2",
"tslint": "5.8.0", "tslint": "5.8.0",
"typescript": "2.7.1", "typescript": "2.7.1"
"web3-typescript-typings": "^0.9.11"
}, },
"dependencies": { "dependencies": {
"bignumber.js": "~4.1.0", "bignumber.js": "~4.1.0",
"web3": "^0.20.0" "web3": "^0.20.0",
"web3-typescript-typings": "^0.10.0"
} }
} }

View File

@ -1,8 +1,9 @@
# CHANGELOG # CHANGELOG
## v0.4.0 - _TBD, 2018_ ## v0.4.0 - _March 4, 2018_
* Use `ethers-contracts` as a backend to decode event args (#413) * Use `ethers-contracts` as a backend to decode event args (#413)
* Move web3 types from devDep to dep since required when using this package (#429)
## v0.3.2 - _February 9, 2018_ ## v0.3.2 - _February 9, 2018_

View File

@ -8,6 +8,14 @@ Utils to be shared across 0x projects and packages
yarn add @0xproject/utils yarn add @0xproject/utils
``` ```
If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`:
```
"include": [
"./node_modules/web3-typescript-typings/index.d.ts",
]
```
## Usage ## Usage
```javascript ```javascript

View File

@ -1,6 +1,6 @@
{ {
"name": "@0xproject/utils", "name": "@0xproject/utils",
"version": "0.3.4", "version": "0.4.0",
"description": "0x TS utils", "description": "0x TS utils",
"main": "lib/index.js", "main": "lib/index.js",
"types": "lib/index.d.ts", "types": "lib/index.d.ts",
@ -13,28 +13,28 @@
"license": "Apache-2.0", "license": "Apache-2.0",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/0xProject/0x.js.git" "url": "https://github.com/0xProject/0x-monorepo.git"
}, },
"bugs": { "bugs": {
"url": "https://github.com/0xProject/0x.js/issues" "url": "https://github.com/0xProject/0x-monorepo/issues"
}, },
"homepage": "https://github.com/0xProject/0x.js/packages/utils/README.md", "homepage": "https://github.com/0xProject/0x-monorepo/packages/utils/README.md",
"devDependencies": { "devDependencies": {
"@0xproject/tslint-config": "^0.4.9", "@0xproject/tslint-config": "^0.4.10",
"@types/lodash": "^4.14.86", "@types/lodash": "^4.14.86",
"npm-run-all": "^4.1.2", "npm-run-all": "^4.1.2",
"shx": "^0.2.2", "shx": "^0.2.2",
"tslint": "5.8.0", "tslint": "5.8.0",
"typescript": "2.7.1", "typescript": "2.7.1"
"ethers-typescript-typings": "^0.0.1",
"web3-typescript-typings": "^0.9.11"
}, },
"dependencies": { "dependencies": {
"@0xproject/types": "^0.2.3", "@0xproject/types": "^0.3.0",
"bignumber.js": "~4.1.0", "bignumber.js": "~4.1.0",
"ethers-contracts": "^2.2.1", "ethers-contracts": "^2.2.1",
"ethers-typescript-typings": "^0.0.2",
"js-sha3": "^0.7.0", "js-sha3": "^0.7.0",
"lodash": "^4.17.4", "lodash": "^4.17.4",
"web3": "^0.20.0" "web3": "^0.20.0",
"web3-typescript-typings": "^0.10.0"
} }
} }

View File

@ -1,6 +1,6 @@
# CHANGELOG # CHANGELOG
## v0.10.0 - _TBD, 2018_ ## v0.10.0 - _March 4, 2018_
* Support ABIv2 (#401) * Support ABIv2 (#401)

View File

@ -1,6 +1,6 @@
{ {
"name": "web3-typescript-typings", "name": "web3-typescript-typings",
"version": "0.9.11", "version": "0.10.0",
"description": "Typescript type definitions for web3", "description": "Typescript type definitions for web3",
"main": "index.d.ts", "main": "index.d.ts",
"types": "index.d.ts", "types": "index.d.ts",
@ -9,7 +9,7 @@
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/0xProject/0x.js.git" "url": "git+https://github.com/0xProject/0x-monorepo.git"
}, },
"author": "Fabio Berger", "author": "Fabio Berger",
"contributors": [ "contributors": [
@ -17,9 +17,9 @@
], ],
"license": "Apache-2.0", "license": "Apache-2.0",
"bugs": { "bugs": {
"url": "https://github.com/0xProject/0x.js/issues" "url": "https://github.com/0xProject/0x-monorepo/issues"
}, },
"homepage": "https://github.com/0xProject/0x.js/packages/web3-typescript-typings#readme", "homepage": "https://github.com/0xProject/0x-monorepo/packages/web3-typescript-typings#readme",
"devDependencies": { "devDependencies": {
"@types/bignumber.js": "^4.0.2", "@types/bignumber.js": "^4.0.2",
"tslint": "5.8.0", "tslint": "5.8.0",

View File

@ -1,6 +1,6 @@
# CHANGELOG # CHANGELOG
## v0.2.0 _TBD, 2018_ ## v0.2.0 _March 4, 2018_
* Ensure all returned user addresses are lowercase (#373) * Ensure all returned user addresses are lowercase (#373)
* Add `web3Wrapper.callAsync` (#413) * Add `web3Wrapper.callAsync` (#413)

View File

@ -8,6 +8,14 @@ Wrapped version of web3 with a nicer interface that is used across 0x projects a
yarn add @0xproject/web3-wrapper yarn add @0xproject/web3-wrapper
``` ```
If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`:
```
"include": [
"./node_modules/web3-typescript-typings/index.d.ts",
]
```
## Usage ## Usage
```typescript ```typescript

View File

@ -1,6 +1,6 @@
{ {
"name": "@0xproject/web3-wrapper", "name": "@0xproject/web3-wrapper",
"version": "0.1.14", "version": "0.2.0",
"description": "Wraps around web3 and gives a nicer interface", "description": "Wraps around web3 and gives a nicer interface",
"main": "lib/index.js", "main": "lib/index.js",
"types": "lib/index.d.ts", "types": "lib/index.d.ts",
@ -13,27 +13,27 @@
"license": "Apache-2.0", "license": "Apache-2.0",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/0xProject/0x.js.git" "url": "https://github.com/0xProject/0x-monorepo.git"
}, },
"bugs": { "bugs": {
"url": "https://github.com/0xProject/0x.js/issues" "url": "https://github.com/0xProject/0x-monorepo/issues"
}, },
"homepage": "https://github.com/0xProject/0x.js/packages/web3-wrapper/README.md", "homepage": "https://github.com/0xProject/0x-monorepo/packages/web3-wrapper/README.md",
"devDependencies": { "devDependencies": {
"@0xproject/tslint-config": "^0.4.9", "@0xproject/tslint-config": "^0.4.10",
"@types/lodash": "^4.14.86", "@types/lodash": "^4.14.86",
"npm-run-all": "^4.1.2", "npm-run-all": "^4.1.2",
"shx": "^0.2.2", "shx": "^0.2.2",
"tslint": "5.8.0", "tslint": "5.8.0",
"typescript": "2.7.1", "typescript": "2.7.1"
"web3-typescript-typings": "^0.9.11"
}, },
"dependencies": { "dependencies": {
"@0xproject/types": "^0.2.3", "@0xproject/types": "^0.3.0",
"@0xproject/utils": "^0.3.4", "@0xproject/utils": "^0.4.0",
"ethers-contracts": "^2.2.1", "ethers-contracts": "^2.2.1",
"ethers-typescript-typings": "^0.0.1", "ethers-typescript-typings": "^0.0.2",
"lodash": "^4.17.4", "lodash": "^4.17.4",
"web3": "^0.20.0" "web3": "^0.20.0",
"web3-typescript-typings": "^0.10.0"
} }
} }

View File

@ -18,7 +18,7 @@ import { ZeroEx } from '0x.js';
**Install** **Install**
Download the UMD module from our [releases page](https://github.com/0xProject/0x.js/releases) and add it to your project. Download the UMD module from our [releases page](https://github.com/0xProject/0x-monorepo/releases) and add it to your project.
**Import** **Import**

View File

@ -1 +1 @@
Welcome to the [0x.js](https://github.com/0xProject/0x.js) documentation! 0x.js is a Javascript library for interacting with the 0x protocol. With it, you can easily make calls to the 0x smart contracts as well as any ERC20 token. Functionality includes generating, signing, filling and cancelling orders, verifying an orders signature, setting or checking a users ERC20 token balance/allowance and much more. Welcome to the [0x.js](https://github.com/0xProject/0x-monorepo) documentation! 0x.js is a Javascript library for interacting with the 0x protocol. With it, you can easily make calls to the 0x smart contracts as well as any ERC20 token. Functionality includes generating, signing, filling and cancelling orders, verifying an orders signature, setting or checking a users ERC20 token balance/allowance and much more.

View File

@ -12,4 +12,4 @@ import { HttpClient } from '@0xproject/connect';
### Wiki ### Wiki
Check out our [0x Connect introduction tutorial](https://0xproject.com/wiki#Intro-Tutorial:-Connect) for information on how to integrate relayers into your application. Check out our [0x Connect introduction tutorial](https://0xproject.com/wiki#Intro-Tutorial) for information on how to integrate relayers into your application.

View File

@ -1 +1 @@
Welcome to the [0x Connect](https://github.com/0xProject/0x.js/tree/development/packages/connect) documentation! 0x Connect is a Javascript library that makes it easy to interact with relayers that conform to the [Standard Relayer API](https://github.com/0xProject/standard-relayer-api). Functionality includes getting supported token pairs from a relayer, getting orders filtered by different attributes, getting individual orders specified by order hash, getting orderbooks for specific token pairs, getting fee information, and submitting orders. Welcome to the [0x Connect](https://github.com/0xProject/0x-monorepo/tree/development/packages/connect) documentation! 0x Connect is a Javascript library that makes it easy to interact with relayers that conform to the [Standard Relayer API](https://github.com/0xProject/standard-relayer-api). Functionality includes getting supported token pairs from a relayer, getting orders filtered by different attributes, getting individual orders specified by order hash, getting orderbooks for specific token pairs, getting fee information, and submitting orders.

View File

@ -1,6 +1,6 @@
{ {
"name": "@0xproject/website", "name": "@0xproject/website",
"version": "0.0.16", "version": "0.0.17",
"private": true, "private": true,
"description": "Website and 0x portal dapp", "description": "Website and 0x portal dapp",
"scripts": { "scripts": {
@ -18,9 +18,9 @@
"author": "Fabio Berger", "author": "Fabio Berger",
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"0x.js": "^0.32.4", "0x.js": "^0.33.0",
"@0xproject/subproviders": "^0.5.0", "@0xproject/subproviders": "^0.6.0",
"@0xproject/utils": "^0.3.4", "@0xproject/utils": "^0.4.0",
"accounting": "^0.4.1", "accounting": "^0.4.1",
"basscss": "^8.0.3", "basscss": "^8.0.3",
"blockies": "^0.0.2", "blockies": "^0.0.2",
@ -43,10 +43,10 @@
"react-document-title": "^2.0.3", "react-document-title": "^2.0.3",
"react-dom": "15.6.1", "react-dom": "15.6.1",
"react-ga": "^2.4.1", "react-ga": "^2.4.1",
"react-highlight": "^0.10.0", "react-highlight": "0xproject/react-highlight",
"react-html5video": "^2.1.0", "react-html5video": "^2.1.0",
"react-inlinesvg": "^0.5.5", "react-inlinesvg": "^0.5.5",
"react-markdown": "^2.5.0", "react-markdown": "^3.2.2",
"react-recaptcha": "^2.3.2", "react-recaptcha": "^2.3.2",
"react-redux": "^5.0.3", "react-redux": "^5.0.3",
"react-router-dom": "^4.1.1", "react-router-dom": "^4.1.1",
@ -87,7 +87,7 @@
"copy-webpack-plugin": "^4.0.1", "copy-webpack-plugin": "^4.0.1",
"copyfiles": "^1.2.0", "copyfiles": "^1.2.0",
"css-loader": "0.23.x", "css-loader": "0.23.x",
"ethers-typescript-typings": "^0.0.1", "ethers-typescript-typings": "^0.0.2",
"exports-loader": "0.6.x", "exports-loader": "0.6.x",
"imports-loader": "0.6.x", "imports-loader": "0.6.x",
"json-loader": "^0.5.4", "json-loader": "^0.5.4",
@ -99,7 +99,7 @@
"tslint": "5.8.0", "tslint": "5.8.0",
"tslint-config-0xproject": "^0.0.2", "tslint-config-0xproject": "^0.0.2",
"typescript": "2.7.1", "typescript": "2.7.1",
"web3-typescript-typings": "^0.9.11", "web3-typescript-typings": "^0.10.0",
"webpack": "^3.1.0", "webpack": "^3.1.0",
"webpack-dev-middleware": "^1.10.0", "webpack-dev-middleware": "^1.10.0",
"webpack-dev-server": "^2.5.0" "webpack-dev-server": "^2.5.0"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 361 B

After

Width:  |  Height:  |  Size: 289 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 930 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -69,14 +69,6 @@ export class Blockchain {
private _cachedProviderNetworkId: number; private _cachedProviderNetworkId: number;
private _ledgerSubprovider: LedgerWalletSubprovider; private _ledgerSubprovider: LedgerWalletSubprovider;
private _defaultGasPrice: BigNumber; private _defaultGasPrice: BigNumber;
private static async _onPageLoadAsync(): Promise<void> {
if (document.readyState === 'complete') {
return; // Already loaded
}
return new Promise<void>((resolve, reject) => {
window.onload = () => resolve();
});
}
private static _getNameGivenProvider(provider: Web3.Provider): string { private static _getNameGivenProvider(provider: Web3.Provider): string {
if (!_.isUndefined((provider as any).isMetaMask)) { if (!_.isUndefined((provider as any).isMetaMask)) {
return constants.PROVIDER_NAME_METAMASK; return constants.PROVIDER_NAME_METAMASK;
@ -710,7 +702,7 @@ export class Blockchain {
return tokenByAddress; return tokenByAddress;
} }
private async _onPageLoadInitFireAndForgetAsync() { private async _onPageLoadInitFireAndForgetAsync() {
await Blockchain._onPageLoadAsync(); // wait for page to load await utils.onPageLoadAsync(); // wait for page to load
// Hack: We need to know the networkId the injectedWeb3 is connected to (if it is defined) in // Hack: We need to know the networkId the injectedWeb3 is connected to (if it is defined) in
// order to properly instantiate the web3Wrapper. Since we must use the async call, we cannot // order to properly instantiate the web3Wrapper. Since we must use the async call, we cannot

View File

@ -28,7 +28,7 @@ const docsInfoConfig: DocsInfoConfig = {
id: DocPackages.Connect, id: DocPackages.Connect,
type: SupportedDocJson.TypeDoc, type: SupportedDocJson.TypeDoc,
displayName: '0x Connect', displayName: '0x Connect',
packageUrl: 'https://github.com/0xProject/0x.js', packageUrl: 'https://github.com/0xProject/0x-monorepo',
menu: { menu: {
introduction: [connectDocSections.introduction], introduction: [connectDocSections.introduction],
install: [connectDocSections.installation], install: [connectDocSections.installation],

View File

@ -40,7 +40,7 @@ const docsInfoConfig: DocsInfoConfig = {
id: DocPackages.ZeroExJs, id: DocPackages.ZeroExJs,
type: SupportedDocJson.TypeDoc, type: SupportedDocJson.TypeDoc,
displayName: '0x.js', displayName: '0x.js',
packageUrl: 'https://github.com/0xProject/0x.js', packageUrl: 'https://github.com/0xProject/0x-monorepo',
menu: { menu: {
introduction: [zeroExJsDocSections.introduction], introduction: [zeroExJsDocSections.introduction],
install: [zeroExJsDocSections.installation], install: [zeroExJsDocSections.installation],
@ -102,6 +102,7 @@ const docsInfoConfig: DocsInfoConfig = {
'ApprovalContractEventArgs', 'ApprovalContractEventArgs',
'TokenContractEventArgs', 'TokenContractEventArgs',
'ZeroExConfig', 'ZeroExConfig',
'TransactionReceipt',
'TransactionReceiptWithDecodedLogs', 'TransactionReceiptWithDecodedLogs',
'LogWithDecodedArgs', 'LogWithDecodedArgs',
'EtherTokenEvents', 'EtherTokenEvents',
@ -124,17 +125,33 @@ const docsInfoConfig: DocsInfoConfig = {
'FilterObject', 'FilterObject',
], ],
sectionNameToModulePath: { sectionNameToModulePath: {
[zeroExJsDocSections.zeroEx]: ['"src/0x"'], [zeroExJsDocSections.zeroEx]: ['"0x.js/src/0x"', '"src/0x"'],
[zeroExJsDocSections.exchange]: ['"src/contract_wrappers/exchange_wrapper"'], [zeroExJsDocSections.exchange]: [
[zeroExJsDocSections.tokenRegistry]: ['"src/contract_wrappers/token_registry_wrapper"'], '"0x.js/src/contract_wrappers/exchange_wrapper"',
[zeroExJsDocSections.token]: ['"src/contract_wrappers/token_wrapper"'], '"src/contract_wrappers/exchange_wrapper"',
[zeroExJsDocSections.etherToken]: ['"src/contract_wrappers/ether_token_wrapper"'], ],
[zeroExJsDocSections.tokenRegistry]: [
'"0x.js/src/contract_wrappers/token_registry_wrapper"',
'"src/contract_wrappers/token_registry_wrapper"',
],
[zeroExJsDocSections.token]: [
'"0x.js/src/contract_wrappers/token_wrapper"',
'"src/contract_wrappers/token_wrapper"',
],
[zeroExJsDocSections.etherToken]: [
'"0x.js/src/contract_wrappers/ether_token_wrapper"',
'"src/contract_wrappers/ether_token_wrapper"',
],
[zeroExJsDocSections.proxy]: [ [zeroExJsDocSections.proxy]: [
'"src/contract_wrappers/proxy_wrapper"', '"0x.js/src/contract_wrappers/proxy_wrapper"',
'"0x.js/src/contract_wrappers/token_transfer_proxy_wrapper"',
'"src/contract_wrappers/token_transfer_proxy_wrapper"', '"src/contract_wrappers/token_transfer_proxy_wrapper"',
], ],
[zeroExJsDocSections.orderWatcher]: ['"src/order_watcher/order_state_watcher"'], [zeroExJsDocSections.orderWatcher]: [
[zeroExJsDocSections.types]: ['"src/types"'], '"0x.js/src/order_watcher/order_state_watcher"',
'"src/order_watcher/order_state_watcher"',
],
[zeroExJsDocSections.types]: ['"0x.js/src/types"', '"src/types"', '"types/src/index"'],
}, },
menuSubsectionToVersionWhenIntroduced: { menuSubsectionToVersionWhenIntroduced: {
[zeroExJsDocSections.etherToken]: '0.7.1', [zeroExJsDocSections.etherToken]: '0.7.1',

View File

@ -15,7 +15,7 @@ const defaultProps = {
export const Comment: React.SFC<CommentProps> = (props: CommentProps) => { export const Comment: React.SFC<CommentProps> = (props: CommentProps) => {
return ( return (
<div className={`${props.className} comment`}> <div className={`${props.className} comment`}>
<ReactMarkdown source={props.comment} renderers={{ CodeBlock: MarkdownCodeBlock }} /> <ReactMarkdown source={props.comment} renderers={{ code: MarkdownCodeBlock }} />
</div> </div>
); );
}; };

View File

@ -29,11 +29,11 @@ import {
TypescriptMethod, TypescriptMethod,
} from 'ts/types'; } from 'ts/types';
import { colors } from 'ts/utils/colors'; import { colors } from 'ts/utils/colors';
import { configs } from 'ts/utils/configs';
import { constants } from 'ts/utils/constants'; import { constants } from 'ts/utils/constants';
import { utils } from 'ts/utils/utils'; import { utils } from 'ts/utils/utils';
const TOP_BAR_HEIGHT = 60; const TOP_BAR_HEIGHT = 60;
const SCROLL_TOP_ID = 'docsScrollTop';
const networkNameToColor: { [network: string]: string } = { const networkNameToColor: { [network: string]: string } = {
[Networks.Kovan]: colors.purple, [Networks.Kovan]: colors.purple,
@ -76,7 +76,8 @@ const styles: Styles = {
export class Documentation extends React.Component<DocumentationProps, DocumentationState> { export class Documentation extends React.Component<DocumentationProps, DocumentationState> {
public componentDidUpdate(prevProps: DocumentationProps, prevState: DocumentationState) { public componentDidUpdate(prevProps: DocumentationProps, prevState: DocumentationState) {
if (!_.isEqual(prevProps.docAgnosticFormat, this.props.docAgnosticFormat)) { if (!_.isEqual(prevProps.docAgnosticFormat, this.props.docAgnosticFormat)) {
this._scrollToHash(); const hash = this.props.location.hash.slice(1);
utils.scrollToHash(hash, configs.SCROLL_CONTAINER_ID);
} }
} }
public render() { public render() {
@ -115,8 +116,12 @@ export class Documentation extends React.Component<DocumentationProps, Documenta
className="relative col lg-col-9 md-col-9 sm-col-12 col-12" className="relative col lg-col-9 md-col-9 sm-col-12 col-12"
style={{ backgroundColor: colors.white }} style={{ backgroundColor: colors.white }}
> >
<div id="documentation" style={styles.mainContainers} className="absolute px1"> <div
<div id={SCROLL_TOP_ID} /> id={configs.SCROLL_CONTAINER_ID}
style={styles.mainContainers}
className="absolute px1"
>
<div id={configs.SCROLL_TOP_ID} />
{this._renderDocumentation()} {this._renderDocumentation()}
</div> </div>
</div> </div>
@ -325,17 +330,4 @@ export class Documentation extends React.Component<DocumentationProps, Documenta
/> />
); );
} }
private _scrollToHash(): void {
const hashWithPrefix = this.props.location.hash;
let hash = hashWithPrefix.slice(1);
if (_.isEmpty(hash)) {
hash = SCROLL_TOP_ID; // scroll to the top
}
scroller.scrollTo(hash, {
duration: 0,
offset: 0,
containerId: 'documentation',
});
}
} }

View File

@ -25,9 +25,10 @@ export class EventDefinition extends React.Component<EventDefinitionProps, Event
} }
public render() { public render() {
const event = this.props.event; const event = this.props.event;
const id = `${this.props.sectionName}-${event.name}`;
return ( return (
<div <div
id={`${this.props.sectionName}-${event.name}`} id={id}
className="pb2" className="pb2"
style={{ overflow: 'hidden', width: '100%' }} style={{ overflow: 'hidden', width: '100%' }}
onMouseOver={this._setAnchorVisibility.bind(this, true)} onMouseOver={this._setAnchorVisibility.bind(this, true)}
@ -36,7 +37,7 @@ export class EventDefinition extends React.Component<EventDefinitionProps, Event
<AnchorTitle <AnchorTitle
headerSize={HeaderSizes.H3} headerSize={HeaderSizes.H3}
title={`Event ${event.name}`} title={`Event ${event.name}`}
id={event.name} id={id}
shouldShowAnchor={this.state.shouldShowAnchor} shouldShowAnchor={this.state.shouldShowAnchor}
/> />
<div style={{ fontSize: 16 }}> <div style={{ fontSize: 16 }}>

View File

@ -113,8 +113,10 @@ export class TypeDefinition extends React.Component<TypeDefinitionProps, TypeDef
<code className="hljs">{codeSnippet}</code> <code className="hljs">{codeSnippet}</code>
</pre> </pre>
</div> </div>
<div style={{ maxWidth: 620 }}>
{customType.comment && <Comment comment={customType.comment} className="py2" />} {customType.comment && <Comment comment={customType.comment} className="py2" />}
</div> </div>
</div>
); );
} }
private _setAnchorVisibility(shouldShowAnchor: boolean) { private _setAnchorVisibility(shouldShowAnchor: boolean) {

View File

@ -3,7 +3,7 @@ import * as React from 'react';
import * as HighLight from 'react-highlight'; import * as HighLight from 'react-highlight';
interface MarkdownCodeBlockProps { interface MarkdownCodeBlockProps {
literal: string; value: string;
language: string; language: string;
} }
@ -13,12 +13,12 @@ export class MarkdownCodeBlock extends React.Component<MarkdownCodeBlockProps, M
// Re-rendering a codeblock causes any use selection to become de-selected. This is annoying when trying // Re-rendering a codeblock causes any use selection to become de-selected. This is annoying when trying
// to copy-paste code examples. We therefore noop re-renders on this component if it's props haven't changed. // to copy-paste code examples. We therefore noop re-renders on this component if it's props haven't changed.
public shouldComponentUpdate(nextProps: MarkdownCodeBlockProps, nextState: MarkdownCodeBlockState) { public shouldComponentUpdate(nextProps: MarkdownCodeBlockProps, nextState: MarkdownCodeBlockState) {
return nextProps.literal !== this.props.literal || nextProps.language !== this.props.language; return nextProps.value !== this.props.value || nextProps.language !== this.props.language;
} }
public render() { public render() {
return ( return (
<span style={{ fontSize: 14 }}> <span style={{ fontSize: 14 }}>
<HighLight className={this.props.language || 'javascript'}>{this.props.literal}</HighLight> <HighLight className={this.props.language || 'javascript'}>{this.props.value}</HighLight>
</span> </span>
); );
} }

View File

@ -0,0 +1,46 @@
import * as _ from 'lodash';
import * as React from 'react';
import { configs } from 'ts/utils/configs';
import { utils } from 'ts/utils/utils';
interface MarkdownLinkBlockProps {
href: string;
}
interface MarkdownLinkBlockState {}
export class MarkdownLinkBlock extends React.Component<MarkdownLinkBlockProps, MarkdownLinkBlockState> {
// Re-rendering a linkBlock causes it to remain unclickable.
// We therefore noop re-renders on this component if it's props haven't changed.
public shouldComponentUpdate(nextProps: MarkdownLinkBlockProps, nextState: MarkdownLinkBlockState) {
return nextProps.href !== this.props.href;
}
public render() {
const href = this.props.href;
const isLinkToSection = _.startsWith(href, '#');
// If protocol is http or https, we can open in a new tab, otherwise don't for security reasons
if (_.startsWith(href, 'http') || _.startsWith(href, 'https')) {
return (
<a href={href} target="_blank" rel="nofollow noreferrer noopener">
{this.props.children}
</a>
);
} else if (isLinkToSection) {
return (
<a
style={{ cursor: 'pointer', textDecoration: 'underline' }}
onClick={this._onHashUrlClick.bind(this, href)}
>
{this.props.children}
</a>
);
} else {
return <a href={href}>{this.props.children}</a>;
}
}
private _onHashUrlClick(href: string) {
const hash = href.split('#')[1];
utils.scrollToHash(hash, configs.SCROLL_CONTAINER_ID);
utils.setUrlHash(hash);
}
}

View File

@ -5,6 +5,7 @@ import * as ReactMarkdown from 'react-markdown';
import { Element as ScrollElement } from 'react-scroll'; import { Element as ScrollElement } from 'react-scroll';
import { AnchorTitle } from 'ts/pages/shared/anchor_title'; import { AnchorTitle } from 'ts/pages/shared/anchor_title';
import { MarkdownCodeBlock } from 'ts/pages/shared/markdown_code_block'; import { MarkdownCodeBlock } from 'ts/pages/shared/markdown_code_block';
import { MarkdownLinkBlock } from 'ts/pages/shared/markdown_link_block';
import { HeaderSizes } from 'ts/types'; import { HeaderSizes } from 'ts/types';
import { colors } from 'ts/utils/colors'; import { colors } from 'ts/utils/colors';
import { utils } from 'ts/utils/utils'; import { utils } from 'ts/utils/utils';
@ -64,7 +65,14 @@ export class MarkdownSection extends React.Component<MarkdownSectionProps, Markd
</div> </div>
</div> </div>
<hr style={{ border: `1px solid ${colors.lightestGrey}` }} /> <hr style={{ border: `1px solid ${colors.lightestGrey}` }} />
<ReactMarkdown source={this.props.markdownContent} renderers={{ CodeBlock: MarkdownCodeBlock }} /> <ReactMarkdown
source={this.props.markdownContent}
escapeHtml={false}
renderers={{
code: MarkdownCodeBlock,
link: MarkdownLinkBlock,
}}
/>
</ScrollElement> </ScrollElement>
</div> </div>
); );

View File

@ -86,14 +86,14 @@ export class NestedSidebarMenu extends React.Component<NestedSidebarMenuProps, N
docs docs
</div> </div>
</div> </div>
<div className="pl1" style={{ color: colors.grey350, paddingBottom: 9, paddingLeft: 14, height: 17 }}> <div className="pl1" style={{ color: colors.grey350, paddingBottom: 9, paddingLeft: 10, height: 17 }}>
| |
</div> </div>
<div className="flex"> <div className="flex">
<div> <div>
<img src={`/images/doc_icons/${titleToIcon[this.props.title]}`} width="24" /> <img src={`/images/doc_icons/${titleToIcon[this.props.title]}`} width="22" />
</div> </div>
<div className="pl1" style={{ fontWeight: 600, fontSize: 20, lineHeight: 1 }}> <div className="pl1" style={{ fontWeight: 600, fontSize: 20, lineHeight: 1.2 }}>
{this.props.title} {this.props.title}
</div> </div>
</div> </div>

View File

@ -2,6 +2,7 @@ import * as React from 'react';
import { Element as ScrollElement } from 'react-scroll'; import { Element as ScrollElement } from 'react-scroll';
import { AnchorTitle } from 'ts/pages/shared/anchor_title'; import { AnchorTitle } from 'ts/pages/shared/anchor_title';
import { HeaderSizes } from 'ts/types'; import { HeaderSizes } from 'ts/types';
import { colors } from 'ts/utils/colors';
import { utils } from 'ts/utils/utils'; import { utils } from 'ts/utils/utils';
interface SectionHeaderProps { interface SectionHeaderProps {
@ -34,7 +35,19 @@ export class SectionHeader extends React.Component<SectionHeaderProps, SectionHe
<ScrollElement name={id}> <ScrollElement name={id}>
<AnchorTitle <AnchorTitle
headerSize={this.props.headerSize} headerSize={this.props.headerSize}
title={<span style={{ textTransform: 'capitalize' }}>{sectionName}</span>} title={
<span
style={{
textTransform: 'uppercase',
color: colors.grey,
fontFamily: 'Roboto Mono',
fontWeight: 300,
fontSize: 27,
}}
>
{sectionName}
</span>
}
id={id} id={id}
shouldShowAnchor={this.state.shouldShowAnchor} shouldShowAnchor={this.state.shouldShowAnchor}
/> />

View File

@ -2,6 +2,7 @@ import * as _ from 'lodash';
import DropDownMenu from 'material-ui/DropDownMenu'; import DropDownMenu from 'material-ui/DropDownMenu';
import MenuItem from 'material-ui/MenuItem'; import MenuItem from 'material-ui/MenuItem';
import * as React from 'react'; import * as React from 'react';
import { utils } from 'ts/utils/utils';
interface VersionDropDownProps { interface VersionDropDownProps {
selectedVersion: string; selectedVersion: string;
@ -31,8 +32,6 @@ export class VersionDropDown extends React.Component<VersionDropDownProps, Versi
return items; return items;
} }
private _updateSelectedVersion(e: any, index: number, semver: string) { private _updateSelectedVersion(e: any, index: number, semver: string) {
const port = window.location.port;
const hasPort = !_.isUndefined(port);
let path = window.location.pathname; let path = window.location.pathname;
const lastChar = path[path.length - 1]; const lastChar = path[path.length - 1];
if (_.isFinite(_.parseInt(lastChar))) { if (_.isFinite(_.parseInt(lastChar))) {
@ -40,7 +39,7 @@ export class VersionDropDown extends React.Component<VersionDropDownProps, Versi
pathSections.pop(); pathSections.pop();
path = pathSections.join('/'); path = pathSections.join('/');
} }
const baseUrl = `https://${window.location.hostname}${hasPort ? `:${port}` : ''}${path}`; const baseUrl = utils.getCurrentBaseUrl();
window.location.href = `${baseUrl}/${semver}${window.location.hash}`; window.location.href = `${baseUrl}${path}/${semver}${window.location.hash}`;
} }
} }

View File

@ -135,11 +135,11 @@ export class Wiki extends React.Component<WikiProps, WikiState> {
}} }}
> >
<div <div
id="documentation" id={configs.SCROLL_CONTAINER_ID}
style={{ ...mainContainersStyle, overflow: 'auto' }} style={{ ...mainContainersStyle, overflow: 'auto' }}
className="absolute" className="absolute"
> >
<div id="0xProtocolWiki" /> <div id={configs.SCROLL_TOP_ID} />
<div id="wiki" style={{ paddingRight: 2 }}> <div id="wiki" style={{ paddingRight: 2 }}>
{this._renderWikiArticles()} {this._renderWikiArticles()}
</div> </div>
@ -188,19 +188,6 @@ export class Wiki extends React.Component<WikiProps, WikiState> {
</div> </div>
); );
} }
private _scrollToHash(): void {
const hashWithPrefix = this.props.location.hash;
let hash = hashWithPrefix.slice(1);
if (_.isEmpty(hash)) {
hash = '0xProtocolWiki'; // scroll to the top
}
scroller.scrollTo(hash, {
duration: 0,
offset: 0,
containerId: 'documentation',
});
}
private async _fetchArticlesBySectionAsync(): Promise<void> { private async _fetchArticlesBySectionAsync(): Promise<void> {
const endpoint = `${configs.BACKEND_BASE_URL}${WebsitePaths.Wiki}`; const endpoint = `${configs.BACKEND_BASE_URL}${WebsitePaths.Wiki}`;
const response = await fetch(endpoint); const response = await fetch(endpoint);
@ -224,8 +211,10 @@ export class Wiki extends React.Component<WikiProps, WikiState> {
{ {
articlesBySection, articlesBySection,
}, },
() => { async () => {
this._scrollToHash(); await utils.onPageLoadAsync();
const hash = this.props.location.hash.slice(1);
utils.scrollToHash(hash, configs.SCROLL_CONTAINER_ID);
}, },
); );
} }

View File

@ -308,7 +308,7 @@ export interface TypeDocNode {
returns?: string; returns?: string;
declaration: TypeDocNode; declaration: TypeDocNode;
flags?: TypeDocFlags; flags?: TypeDocFlags;
indexSignature?: TypeDocNode[]; indexSignature?: TypeDocNode | TypeDocNode[]; // TypeDocNode in TypeDoc <V0.9.0, TypeDocNode[] in >V0.9.0
signatures?: TypeDocNode[]; signatures?: TypeDocNode[];
parameters?: TypeDocNode[]; parameters?: TypeDocNode[];
typeParameter?: TypeDocNode[]; typeParameter?: TypeDocNode[];

View File

@ -94,6 +94,8 @@ export const configs = {
[3]: [`https://ropsten.infura.io/${INFURA_API_KEY}`], [3]: [`https://ropsten.infura.io/${INFURA_API_KEY}`],
[4]: [`https://rinkeby.infura.io/${INFURA_API_KEY}`], [4]: [`https://rinkeby.infura.io/${INFURA_API_KEY}`],
} as PublicNodeUrlsByNetworkId, } as PublicNodeUrlsByNetworkId,
SCROLL_CONTAINER_ID: 'documentation',
SCROLL_TOP_ID: 'pageScrollTop',
SHOULD_DEPRECATE_OLD_WETH_TOKEN: true, SHOULD_DEPRECATE_OLD_WETH_TOKEN: true,
SYMBOLS_OF_MINTABLE_KOVAN_TOKENS: ['MKR', 'MLN', 'GNT', 'DGD', 'REP'], SYMBOLS_OF_MINTABLE_KOVAN_TOKENS: ['MKR', 'MLN', 'GNT', 'DGD', 'REP'],
SYMBOLS_OF_MINTABLE_RINKEBY_ROPSTEN_TOKENS: [ SYMBOLS_OF_MINTABLE_RINKEBY_ROPSTEN_TOKENS: [

View File

@ -41,18 +41,17 @@ export const typeDocUtils = {
isPrivateOrProtectedProperty(propertyName: string): boolean { isPrivateOrProtectedProperty(propertyName: string): boolean {
return _.startsWith(propertyName, '_'); return _.startsWith(propertyName, '_');
}, },
getModuleDefinitionBySectionNameIfExists( getModuleDefinitionsBySectionName(versionDocObj: TypeDocNode, configModulePaths: string[]): TypeDocNode[] {
versionDocObj: TypeDocNode, const moduleDefinitions: TypeDocNode[] = [];
modulePaths: string[], const jsonModules = versionDocObj.children;
): TypeDocNode | undefined { _.each(jsonModules, jsonMod => {
const modules = versionDocObj.children; _.each(configModulePaths, configModulePath => {
for (const mod of modules) { if (_.includes(configModulePath, jsonMod.name)) {
if (_.includes(modulePaths, mod.name)) { moduleDefinitions.push(jsonMod);
const moduleWithName = mod;
return moduleWithName;
} }
} });
return undefined; });
return moduleDefinitions;
}, },
convertToDocAgnosticFormat(typeDocJson: TypeDocNode, docsInfo: DocsInfo): DocAgnosticFormat { convertToDocAgnosticFormat(typeDocJson: TypeDocNode, docsInfo: DocsInfo): DocAgnosticFormat {
const subMenus = _.values(docsInfo.getMenu()); const subMenus = _.values(docsInfo.getMenu());
@ -63,12 +62,23 @@ export const typeDocUtils = {
if (_.isUndefined(modulePathsIfExists)) { if (_.isUndefined(modulePathsIfExists)) {
return; // no-op return; // no-op
} }
const packageDefinitionIfExists = typeDocUtils.getModuleDefinitionBySectionNameIfExists( const packageDefinitions = typeDocUtils.getModuleDefinitionsBySectionName(typeDocJson, modulePathsIfExists);
typeDocJson, let packageDefinitionWithMergedChildren;
modulePathsIfExists, if (_.isEmpty(packageDefinitions)) {
);
if (_.isUndefined(packageDefinitionIfExists)) {
return; // no-op return; // no-op
} else if (packageDefinitions.length === 1) {
packageDefinitionWithMergedChildren = packageDefinitions[0];
} else {
// HACK: For now, if there are two modules to display in a single section,
// we simply concat the children. This works for our limited use-case where
// we want to display types stored in two files under a single section
packageDefinitionWithMergedChildren = packageDefinitions[0];
for (let i = 1; i < packageDefinitions.length; i++) {
packageDefinitionWithMergedChildren.children = [
...packageDefinitionWithMergedChildren.children,
...packageDefinitions[i].children,
];
}
} }
// Since the `types.ts` file is the only file that does not export a module/class but // Since the `types.ts` file is the only file that does not export a module/class but
@ -77,10 +87,10 @@ export const typeDocUtils = {
let entities; let entities;
let packageComment = ''; let packageComment = '';
if (sectionName === docsInfo.sections.types) { if (sectionName === docsInfo.sections.types) {
entities = packageDefinitionIfExists.children; entities = packageDefinitionWithMergedChildren.children;
} else { } else {
entities = packageDefinitionIfExists.children[0].children; entities = packageDefinitionWithMergedChildren.children[0].children;
const commentObj = packageDefinitionIfExists.children[0].comment; const commentObj = packageDefinitionWithMergedChildren.children[0].comment;
packageComment = !_.isUndefined(commentObj) ? commentObj.shortText : packageComment; packageComment = !_.isUndefined(commentObj) ? commentObj.shortText : packageComment;
} }
@ -170,8 +180,16 @@ export const typeDocUtils = {
const methodIfExists = !_.isUndefined(entity.declaration) const methodIfExists = !_.isUndefined(entity.declaration)
? typeDocUtils._convertMethod(entity.declaration, isConstructor, sections, sectionName, docId) ? typeDocUtils._convertMethod(entity.declaration, isConstructor, sections, sectionName, docId)
: undefined; : undefined;
const indexSignatureIfExists = !_.isUndefined(entity.indexSignature) const doesIndexSignatureExist = !_.isUndefined(entity.indexSignature);
? typeDocUtils._convertIndexSignature(entity.indexSignature[0], sections, sectionName, docId) const isIndexSignatureArray = _.isArray(entity.indexSignature);
// HACK: TypeDoc Versions <0.9.0 indexSignature is of type TypeDocNode[]
// Versions >0.9.0 have it as type TypeDocNode
const indexSignature =
doesIndexSignatureExist && isIndexSignatureArray
? (entity.indexSignature as TypeDocNode[])[0]
: (entity.indexSignature as TypeDocNode);
const indexSignatureIfExists = doesIndexSignatureExist
? typeDocUtils._convertIndexSignature(indexSignature, sections, sectionName, docId)
: undefined; : undefined;
const commentIfExists = const commentIfExists =
!_.isUndefined(entity.comment) && !_.isUndefined(entity.comment.shortText) !_.isUndefined(entity.comment) && !_.isUndefined(entity.comment.shortText)

Some files were not shown because too many files have changed in this diff Show More