Merge branch 'development'
This commit is contained in:
		@@ -5,7 +5,7 @@ jobs:
 | 
			
		||||
    docker:
 | 
			
		||||
      - image: circleci/node:6.12
 | 
			
		||||
    environment:
 | 
			
		||||
      CONTRACTS_COMMIT_HASH: '78fe8dd'
 | 
			
		||||
      CONTRACTS_COMMIT_HASH: '6bda6a2'
 | 
			
		||||
    steps:
 | 
			
		||||
      - checkout
 | 
			
		||||
      - run: echo 'export PATH=$HOME/CIRCLE_PROJECT_REPONAME/node_modules/.bin:$PATH' >> $BASH_ENV
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -68,3 +68,6 @@ generated_docs/
 | 
			
		||||
TODO.md
 | 
			
		||||
 | 
			
		||||
packages/website/public/bundle*
 | 
			
		||||
 | 
			
		||||
# generated binaries
 | 
			
		||||
bin/
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										36
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										36
									
								
								README.md
									
									
									
									
									
								
							@@ -17,20 +17,26 @@ This repository contains all the 0x developer tools written in TypeScript. Our h
 | 
			
		||||
[](https://opensource.org/licenses/Apache-2.0)
 | 
			
		||||
[](https://greenkeeper.io/)
 | 
			
		||||
 | 
			
		||||
### Core Packages
 | 
			
		||||
### Published Packages
 | 
			
		||||
 | 
			
		||||
| Package | Version | Description |
 | 
			
		||||
|--------|-------|------------|
 | 
			
		||||
| [`0x.js`](/packages/0x.js) | [](https://www.npmjs.com/package/0x.js) | A Javascript library for interacting with the 0x protocol |
 | 
			
		||||
| [`@0xproject/connect`](/packages/connect) | [](https://www.npmjs.com/package/@0xproject/connect) | A Javascript library for interacting with the standard relayer api |
 | 
			
		||||
| [`@0xproject/contracts`](/packages/contracts) | | Smart contracts |
 | 
			
		||||
| [`@0xproject/website`](/packages/website) | | 0x website |
 | 
			
		||||
| [`@0xproject/subproviders`](/packages/subproviders) | [](https://www.npmjs.com/package/@0xproject/subproviders) | Web3 subproviders |
 | 
			
		||||
| [`@0xproject/abi-gen`](/packages/abi-gen) | [](https://www.npmjs.com/package/@0xproject/abi-gen) | Tool to generate TS code from ABI |
 | 
			
		||||
| [`@0xproject/assert`](/packages/assert) | [](https://www.npmjs.com/package/@0xproject/assert) | Standard type and schema assertions |
 | 
			
		||||
| [`@0xproject/json-schemas`](/packages/json-schemas) | [](https://www.npmjs.com/package/@0xproject/json-schemas) | 0x-related json schemas |
 | 
			
		||||
| [`@0xproject/monorepo-scripts`](/packages/monorepo-scripts) | | Shared monorepo scripts |
 | 
			
		||||
| [`@0xproject/tslint-config`](/packages/tslint-config) | [](https://www.npmjs.com/package/@0xproject/tslint-config) | Custom 0x project TSLint rules |
 | 
			
		||||
| [`@0xproject/types`](/packages/types) | [](https://www.npmjs.com/package/@0xproject/types) | Shared types |
 | 
			
		||||
| [`@0xproject/utils`](/packages/utils) | [](https://www.npmjs.com/package/@0xproject/utils) | Shared utils |
 | 
			
		||||
| [`@0xproject/web3-wrapper`](/packages/web3-wrapper) | [](https://www.npmjs.com/package/@0xproject/web3-wrapper) | Web3 wrapper |
 | 
			
		||||
|---------|---------|-------------|
 | 
			
		||||
| [`0x.js`](/packages/0x.js) | [](https://www.npmjs.com/package/0x.js) | A Javascript library for interacting with the 0x protocol |
 | 
			
		||||
| [`@0xproject/abi-gen`](/packages/abi-gen) | [](https://www.npmjs.com/package/@0xproject/abi-gen) | Tool to generate TS code from ABI |
 | 
			
		||||
| [`@0xproject/assert`](/packages/assert) | [](https://www.npmjs.com/package/@0xproject/assert) | Standard type and schema assertions |
 | 
			
		||||
| [`@0xproject/connect`](/packages/connect) | [](https://www.npmjs.com/package/@0xproject/connect) | A Javascript library for interacting with the standard relayer api |
 | 
			
		||||
| [`@0xproject/json-schemas`](/packages/json-schemas) | [](https://www.npmjs.com/package/@0xproject/json-schemas) | 0x-related json schemas |
 | 
			
		||||
| [`@0xproject/subproviders`](/packages/subproviders) | [](https://www.npmjs.com/package/@0xproject/subproviders) | Web3 subproviders |
 | 
			
		||||
| [`@0xproject/tslint-config`](/packages/tslint-config) | [](https://www.npmjs.com/package/@0xproject/tslint-config) | Custom 0x project TSLint rules |
 | 
			
		||||
| [`@0xproject/types`](/packages/types) | [](https://www.npmjs.com/package/@0xproject/types) | Shared types |
 | 
			
		||||
| [`@0xproject/utils`](/packages/utils) | [](https://www.npmjs.com/package/@0xproject/utils) | Shared utils |
 | 
			
		||||
| [`@0xproject/web3-wrapper`](/packages/web3-wrapper) | [](https://www.npmjs.com/package/@0xproject/web3-wrapper) | Web3 wrapper |
 | 
			
		||||
 | 
			
		||||
### Private Packages
 | 
			
		||||
 | 
			
		||||
| Package | Description |
 | 
			
		||||
|---------|-------------|
 | 
			
		||||
| [`@0xproject/contracts`](/packages/contracts) | Smart contracts |
 | 
			
		||||
| [`@0xproject/kovan_faucets`](/packages/kovan-faucets) | A faucet micro-service that dispenses test ERC20 tokens or Ether |
 | 
			
		||||
| [`@0xproject/monorepo-scripts`](/packages/monorepo-scripts) | Shared monorepo scripts |
 | 
			
		||||
| [`@0xproject/website`](/packages/website) | 0x website |
 | 
			
		||||
 
 | 
			
		||||
@@ -2,13 +2,11 @@
 | 
			
		||||
 * 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/abi-gen-templates.
 | 
			
		||||
 */
 | 
			
		||||
import {promisify} from '@0xproject/utils';
 | 
			
		||||
import {TxData, TxDataPayable} from '@0xproject/types';
 | 
			
		||||
import {classUtils, promisify} from '@0xproject/utils';
 | 
			
		||||
import {BigNumber} from 'bignumber.js';
 | 
			
		||||
import * as Web3 from 'web3';
 | 
			
		||||
 | 
			
		||||
import {TxData, TxDataPayable} from '../../types';
 | 
			
		||||
import {classUtils} from '../../utils/class_utils';
 | 
			
		||||
 | 
			
		||||
import {BaseContract} from './base_contract';
 | 
			
		||||
 | 
			
		||||
export class {{contractName}}Contract extends BaseContract {
 | 
			
		||||
@@ -12,11 +12,11 @@
 | 
			
		||||
  "main": "lib/src/index.js",
 | 
			
		||||
  "types": "lib/src/index.d.ts",
 | 
			
		||||
  "scripts": {
 | 
			
		||||
    "prebuild": "npm run clean",
 | 
			
		||||
    "prebuild": "run-s clean generate_contract_wrappers",
 | 
			
		||||
    "build": "run-p build:umd:prod build:commonjs; exit 0;",
 | 
			
		||||
    "docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --json $JSON_FILE_PATH $PROJECT_DIR",
 | 
			
		||||
    "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": "abi-gen --abiGlob 'src/artifacts/@(Exchange|Token|TokenTransferProxy|EtherToken|TokenRegistry).json' --templates ../abi-gen-templates/ --output src/contract_wrappers/generated --fileExtension ts",
 | 
			
		||||
    "generate_contract_wrappers": "node ../abi-gen/lib/index.js --abiGlob 'src/artifacts/@(Exchange|Token|TokenTransferProxy|EtherToken|TokenRegistry|DummyToken).json' --templates contract_templates --output src/contract_wrappers/generated",
 | 
			
		||||
    "lint": "tslint --project . 'src/**/*.ts' 'test/**/*.ts'",
 | 
			
		||||
    "test:circleci": "run-s test:coverage report_test_coverage && if [ $CIRCLE_BRANCH = \"development\" ]; then yarn test:umd; fi",
 | 
			
		||||
    "test": "run-s clean test:commonjs",
 | 
			
		||||
@@ -31,7 +31,7 @@
 | 
			
		||||
    "test:commonjs": "run-s build:commonjs run_mocha",
 | 
			
		||||
    "pretest:umd": "run-s clean build:umd:dev build:commonjs",
 | 
			
		||||
    "substitute_umd_bundle": "shx mv _bundles/* lib/src",
 | 
			
		||||
    "run_mocha": "mocha lib/test/**/*_test.js --timeout 5000 --bail --exit"
 | 
			
		||||
    "run_mocha": "mocha lib/test/**/*_test.js --timeout 10000 --bail --exit"
 | 
			
		||||
  },
 | 
			
		||||
  "config": {
 | 
			
		||||
    "artifacts": "TokenTransferProxy Exchange TokenRegistry Token EtherToken"
 | 
			
		||||
@@ -48,6 +48,7 @@
 | 
			
		||||
    "@0xproject/abi-gen": "^0.0.2",
 | 
			
		||||
    "@0xproject/tslint-config": "^0.2.1",
 | 
			
		||||
    "@0xproject/types": "^0.1.0",
 | 
			
		||||
    "@0xproject/dev-utils": "^0.0.1",
 | 
			
		||||
    "@types/bintrees": "^1.0.2",
 | 
			
		||||
    "@types/jsonschema": "^1.1.1",
 | 
			
		||||
    "@types/lodash": "^4.14.86",
 | 
			
		||||
@@ -55,7 +56,6 @@
 | 
			
		||||
    "@types/node": "^8.0.53",
 | 
			
		||||
    "@types/sinon": "^2.2.2",
 | 
			
		||||
    "@types/uuid": "^3.4.2",
 | 
			
		||||
    "abi-gen-templates": "^0.0.2",
 | 
			
		||||
    "awesome-typescript-loader": "^3.1.3",
 | 
			
		||||
    "chai": "^4.0.1",
 | 
			
		||||
    "chai-as-promised": "^7.1.0",
 | 
			
		||||
@@ -78,8 +78,6 @@
 | 
			
		||||
    "truffle-hdwallet-provider": "^0.0.3",
 | 
			
		||||
    "tslint": "5.8.0",
 | 
			
		||||
    "typedoc": "~0.8.0",
 | 
			
		||||
    "types-bn": "^0.0.1",
 | 
			
		||||
    "types-ethereumjs-util": "0xProject/types-ethereumjs-util",
 | 
			
		||||
    "typescript": "~2.6.1",
 | 
			
		||||
    "web3-provider-engine": "^13.0.1",
 | 
			
		||||
    "web3-typescript-typings": "^0.7.2",
 | 
			
		||||
 
 | 
			
		||||
@@ -1,11 +1,11 @@
 | 
			
		||||
import {schemas, SchemaValidator} from '@0xproject/json-schemas';
 | 
			
		||||
import {bigNumberConfigs, intervalUtils} from '@0xproject/utils';
 | 
			
		||||
import {Web3Wrapper} from '@0xproject/web3-wrapper';
 | 
			
		||||
import BigNumber from 'bignumber.js';
 | 
			
		||||
import * as ethUtil from 'ethereumjs-util';
 | 
			
		||||
import * as _ from 'lodash';
 | 
			
		||||
 | 
			
		||||
import {artifacts} from './artifacts';
 | 
			
		||||
import {bigNumberConfigs} from './bignumber_config';
 | 
			
		||||
import {EtherTokenWrapper} from './contract_wrappers/ether_token_wrapper';
 | 
			
		||||
import {ExchangeWrapper} from './contract_wrappers/exchange_wrapper';
 | 
			
		||||
import {TokenRegistryWrapper} from './contract_wrappers/token_registry_wrapper';
 | 
			
		||||
@@ -26,7 +26,6 @@ import {
 | 
			
		||||
import {AbiDecoder} from './utils/abi_decoder';
 | 
			
		||||
import {assert} from './utils/assert';
 | 
			
		||||
import {constants} from './utils/constants';
 | 
			
		||||
import {intervalUtils} from './utils/interval_utils';
 | 
			
		||||
import {OrderStateUtils} from './utils/order_state_utils';
 | 
			
		||||
import {signatureUtils} from './utils/signature_utils';
 | 
			
		||||
import {utils} from './utils/utils';
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,4 @@
 | 
			
		||||
import * as DummyTokenArtifact from './artifacts/DummyToken.json';
 | 
			
		||||
import * as EtherTokenArtifact from './artifacts/EtherToken.json';
 | 
			
		||||
import * as ExchangeArtifact from './artifacts/Exchange.json';
 | 
			
		||||
import * as TokenArtifact from './artifacts/Token.json';
 | 
			
		||||
@@ -8,6 +9,7 @@ import {Artifact} from './types';
 | 
			
		||||
 | 
			
		||||
export const artifacts = {
 | 
			
		||||
    ZRXArtifact: ZRXArtifact as any as Artifact,
 | 
			
		||||
    DummyTokenArtifact: DummyTokenArtifact as any as Artifact,
 | 
			
		||||
    TokenArtifact: TokenArtifact as any as Artifact,
 | 
			
		||||
    ExchangeArtifact: ExchangeArtifact as any as Artifact,
 | 
			
		||||
    EtherTokenArtifact: EtherTokenArtifact as any as Artifact,
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										23
									
								
								packages/0x.js/src/artifacts/DummyToken.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								packages/0x.js/src/artifacts/DummyToken.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,23 @@
 | 
			
		||||
{
 | 
			
		||||
    "contract_name": "DummyToken",
 | 
			
		||||
    "abi":
 | 
			
		||||
    [
 | 
			
		||||
        {
 | 
			
		||||
            "constant": false,
 | 
			
		||||
            "inputs": [
 | 
			
		||||
                {
 | 
			
		||||
                    "name": "_target",
 | 
			
		||||
                    "type": "address"
 | 
			
		||||
                },
 | 
			
		||||
                {
 | 
			
		||||
                    "name": "_value",
 | 
			
		||||
                    "type": "uint256"
 | 
			
		||||
                }
 | 
			
		||||
            ],
 | 
			
		||||
            "name": "setBalance",
 | 
			
		||||
            "outputs": [],
 | 
			
		||||
            "payable": false,
 | 
			
		||||
            "type": "function"
 | 
			
		||||
        }
 | 
			
		||||
    ]
 | 
			
		||||
}
 | 
			
		||||
@@ -244,7 +244,7 @@
 | 
			
		||||
      "address": "0x05d090b51c40b020eab3bfcb6a2dff130df22e9c"
 | 
			
		||||
    },
 | 
			
		||||
    "50": {
 | 
			
		||||
      "address": "0x48bacb9266a570d521063ef5dd96e61686dbe788"
 | 
			
		||||
      "address": "0x871dd7c2b4b25e1aa18728e9d5f2af4c4e431f5c"
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -601,7 +601,7 @@
 | 
			
		||||
      "address": "0x90fe2af704b34e0224bf2299c838e04d4dcf1364"
 | 
			
		||||
    },
 | 
			
		||||
    "50": {
 | 
			
		||||
      "address": "0xb69e673309512a9d726f87304c6984054f87a93b"
 | 
			
		||||
      "address": "0x48bacb9266a570d521063ef5dd96e61686dbe788"
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -178,7 +178,7 @@
 | 
			
		||||
        "address": "0x087eed4bc1ee3de49befbd66c662b434b15d49d4"
 | 
			
		||||
      },
 | 
			
		||||
      "50": {
 | 
			
		||||
        "address": "0x871dd7c2b4b25e1aa18728e9d5f2af4c4e431f5c"
 | 
			
		||||
        "address": "0x1dc4c1cefef38a777b15aa20260a54e584b16c48"
 | 
			
		||||
      }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -11,7 +11,7 @@
 | 
			
		||||
      "address": "0x6ff6c0ff1d68b964901f986d4c9fa3ac68346570"
 | 
			
		||||
    },
 | 
			
		||||
    "50": {
 | 
			
		||||
      "address": "0x25b8fe1de9daf8ba351890744ff28cf7dfa8f5e3"
 | 
			
		||||
      "address": "0x1d7022f5b17d2f8b695918fb48fa1089c9f85401"
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,4 @@
 | 
			
		||||
import {intervalUtils} from '@0xproject/utils';
 | 
			
		||||
import {Web3Wrapper} from '@0xproject/web3-wrapper';
 | 
			
		||||
import {Block, BlockAndLogStreamer} from 'ethereumjs-blockstream';
 | 
			
		||||
import * as _ from 'lodash';
 | 
			
		||||
@@ -19,7 +20,6 @@ import {
 | 
			
		||||
import {AbiDecoder} from '../utils/abi_decoder';
 | 
			
		||||
import {constants} from '../utils/constants';
 | 
			
		||||
import {filterUtils} from '../utils/filter_utils';
 | 
			
		||||
import {intervalUtils} from '../utils/interval_utils';
 | 
			
		||||
 | 
			
		||||
const CONTRACT_NAME_TO_NOT_FOUND_ERROR: {[contractName: string]: ZeroExError} = {
 | 
			
		||||
    ZRX: ZeroExError.ZRXContractDoesNotExist,
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										6
									
								
								packages/0x.js/src/contract_wrappers/generated/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								packages/0x.js/src/contract_wrappers/generated/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,6 @@
 | 
			
		||||
dummy_token.ts
 | 
			
		||||
ether_token.ts
 | 
			
		||||
exchange.ts
 | 
			
		||||
token_registry.ts
 | 
			
		||||
token_transfer_proxy.ts
 | 
			
		||||
token.ts
 | 
			
		||||
@@ -1,8 +1,7 @@
 | 
			
		||||
import {TxData, TxDataPayable} from '@0xproject/types';
 | 
			
		||||
import * as _ from 'lodash';
 | 
			
		||||
import * as Web3 from 'web3';
 | 
			
		||||
 | 
			
		||||
import {TxData, TxDataPayable} from '../../types';
 | 
			
		||||
 | 
			
		||||
export class BaseContract {
 | 
			
		||||
    protected web3ContractInstance: Web3.ContractInstance;
 | 
			
		||||
    protected defaults: Partial<TxData>;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,363 +0,0 @@
 | 
			
		||||
/**
 | 
			
		||||
 * 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/abi-gen-templates.
 | 
			
		||||
 */
 | 
			
		||||
import {promisify} from '@0xproject/utils';
 | 
			
		||||
import {BigNumber} from 'bignumber.js';
 | 
			
		||||
import * as Web3 from 'web3';
 | 
			
		||||
 | 
			
		||||
import {TxData, TxDataPayable} from '../../types';
 | 
			
		||||
import {classUtils} from '../../utils/class_utils';
 | 
			
		||||
 | 
			
		||||
import {BaseContract} from './base_contract';
 | 
			
		||||
 | 
			
		||||
export class EtherTokenContract extends BaseContract {
 | 
			
		||||
    public name = {
 | 
			
		||||
        async callAsync(
 | 
			
		||||
            defaultBlock?: Web3.BlockParam,
 | 
			
		||||
        ): Promise<string
 | 
			
		||||
    > {
 | 
			
		||||
            const self = this as EtherTokenContract;
 | 
			
		||||
            const result = await promisify<string
 | 
			
		||||
    >(
 | 
			
		||||
                self.web3ContractInstance.name.call,
 | 
			
		||||
                self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
            );
 | 
			
		||||
            return result;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public approve = {
 | 
			
		||||
        async sendTransactionAsync(
 | 
			
		||||
            _spender: string,
 | 
			
		||||
            _value: BigNumber,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<string> {
 | 
			
		||||
            const self = this as EtherTokenContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
                self.approve.estimateGasAsync.bind(
 | 
			
		||||
                    self,
 | 
			
		||||
                    _spender,
 | 
			
		||||
                    _value,
 | 
			
		||||
                ),
 | 
			
		||||
            );
 | 
			
		||||
            const txHash = await promisify<string>(
 | 
			
		||||
                self.web3ContractInstance.approve, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                _spender,
 | 
			
		||||
                _value,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return txHash;
 | 
			
		||||
        },
 | 
			
		||||
        async estimateGasAsync(
 | 
			
		||||
            _spender: string,
 | 
			
		||||
            _value: BigNumber,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<number> {
 | 
			
		||||
            const self = this as EtherTokenContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
            );
 | 
			
		||||
            const gas = await promisify<number>(
 | 
			
		||||
                self.web3ContractInstance.approve.estimateGas, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                _spender,
 | 
			
		||||
                _value,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return gas;
 | 
			
		||||
        },
 | 
			
		||||
        getABIEncodedTransactionData(
 | 
			
		||||
            _spender: string,
 | 
			
		||||
            _value: BigNumber,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): string {
 | 
			
		||||
            const self = this as EtherTokenContract;
 | 
			
		||||
            const abiEncodedTransactionData = self.web3ContractInstance.approve.getData();
 | 
			
		||||
            return abiEncodedTransactionData;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public totalSupply = {
 | 
			
		||||
        async callAsync(
 | 
			
		||||
            defaultBlock?: Web3.BlockParam,
 | 
			
		||||
        ): Promise<BigNumber
 | 
			
		||||
    > {
 | 
			
		||||
            const self = this as EtherTokenContract;
 | 
			
		||||
            const result = await promisify<BigNumber
 | 
			
		||||
    >(
 | 
			
		||||
                self.web3ContractInstance.totalSupply.call,
 | 
			
		||||
                self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
            );
 | 
			
		||||
            return result;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public transferFrom = {
 | 
			
		||||
        async sendTransactionAsync(
 | 
			
		||||
            _from: string,
 | 
			
		||||
            _to: string,
 | 
			
		||||
            _value: BigNumber,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<string> {
 | 
			
		||||
            const self = this as EtherTokenContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
                self.transferFrom.estimateGasAsync.bind(
 | 
			
		||||
                    self,
 | 
			
		||||
                    _from,
 | 
			
		||||
                    _to,
 | 
			
		||||
                    _value,
 | 
			
		||||
                ),
 | 
			
		||||
            );
 | 
			
		||||
            const txHash = await promisify<string>(
 | 
			
		||||
                self.web3ContractInstance.transferFrom, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                _from,
 | 
			
		||||
                _to,
 | 
			
		||||
                _value,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return txHash;
 | 
			
		||||
        },
 | 
			
		||||
        async estimateGasAsync(
 | 
			
		||||
            _from: string,
 | 
			
		||||
            _to: string,
 | 
			
		||||
            _value: BigNumber,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<number> {
 | 
			
		||||
            const self = this as EtherTokenContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
            );
 | 
			
		||||
            const gas = await promisify<number>(
 | 
			
		||||
                self.web3ContractInstance.transferFrom.estimateGas, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                _from,
 | 
			
		||||
                _to,
 | 
			
		||||
                _value,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return gas;
 | 
			
		||||
        },
 | 
			
		||||
        getABIEncodedTransactionData(
 | 
			
		||||
            _from: string,
 | 
			
		||||
            _to: string,
 | 
			
		||||
            _value: BigNumber,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): string {
 | 
			
		||||
            const self = this as EtherTokenContract;
 | 
			
		||||
            const abiEncodedTransactionData = self.web3ContractInstance.transferFrom.getData();
 | 
			
		||||
            return abiEncodedTransactionData;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public withdraw = {
 | 
			
		||||
        async sendTransactionAsync(
 | 
			
		||||
            amount: BigNumber,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<string> {
 | 
			
		||||
            const self = this as EtherTokenContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
                self.withdraw.estimateGasAsync.bind(
 | 
			
		||||
                    self,
 | 
			
		||||
                    amount,
 | 
			
		||||
                ),
 | 
			
		||||
            );
 | 
			
		||||
            const txHash = await promisify<string>(
 | 
			
		||||
                self.web3ContractInstance.withdraw, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                amount,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return txHash;
 | 
			
		||||
        },
 | 
			
		||||
        async estimateGasAsync(
 | 
			
		||||
            amount: BigNumber,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<number> {
 | 
			
		||||
            const self = this as EtherTokenContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
            );
 | 
			
		||||
            const gas = await promisify<number>(
 | 
			
		||||
                self.web3ContractInstance.withdraw.estimateGas, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                amount,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return gas;
 | 
			
		||||
        },
 | 
			
		||||
        getABIEncodedTransactionData(
 | 
			
		||||
            amount: BigNumber,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): string {
 | 
			
		||||
            const self = this as EtherTokenContract;
 | 
			
		||||
            const abiEncodedTransactionData = self.web3ContractInstance.withdraw.getData();
 | 
			
		||||
            return abiEncodedTransactionData;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public decimals = {
 | 
			
		||||
        async callAsync(
 | 
			
		||||
            defaultBlock?: Web3.BlockParam,
 | 
			
		||||
        ): Promise<BigNumber
 | 
			
		||||
    > {
 | 
			
		||||
            const self = this as EtherTokenContract;
 | 
			
		||||
            const result = await promisify<BigNumber
 | 
			
		||||
    >(
 | 
			
		||||
                self.web3ContractInstance.decimals.call,
 | 
			
		||||
                self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
            );
 | 
			
		||||
            return result;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public balanceOf = {
 | 
			
		||||
        async callAsync(
 | 
			
		||||
            _owner: string,
 | 
			
		||||
            defaultBlock?: Web3.BlockParam,
 | 
			
		||||
        ): Promise<BigNumber
 | 
			
		||||
    > {
 | 
			
		||||
            const self = this as EtherTokenContract;
 | 
			
		||||
            const result = await promisify<BigNumber
 | 
			
		||||
    >(
 | 
			
		||||
                self.web3ContractInstance.balanceOf.call,
 | 
			
		||||
                self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                _owner,
 | 
			
		||||
            );
 | 
			
		||||
            return result;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public symbol = {
 | 
			
		||||
        async callAsync(
 | 
			
		||||
            defaultBlock?: Web3.BlockParam,
 | 
			
		||||
        ): Promise<string
 | 
			
		||||
    > {
 | 
			
		||||
            const self = this as EtherTokenContract;
 | 
			
		||||
            const result = await promisify<string
 | 
			
		||||
    >(
 | 
			
		||||
                self.web3ContractInstance.symbol.call,
 | 
			
		||||
                self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
            );
 | 
			
		||||
            return result;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public transfer = {
 | 
			
		||||
        async sendTransactionAsync(
 | 
			
		||||
            _to: string,
 | 
			
		||||
            _value: BigNumber,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<string> {
 | 
			
		||||
            const self = this as EtherTokenContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
                self.transfer.estimateGasAsync.bind(
 | 
			
		||||
                    self,
 | 
			
		||||
                    _to,
 | 
			
		||||
                    _value,
 | 
			
		||||
                ),
 | 
			
		||||
            );
 | 
			
		||||
            const txHash = await promisify<string>(
 | 
			
		||||
                self.web3ContractInstance.transfer, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                _to,
 | 
			
		||||
                _value,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return txHash;
 | 
			
		||||
        },
 | 
			
		||||
        async estimateGasAsync(
 | 
			
		||||
            _to: string,
 | 
			
		||||
            _value: BigNumber,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<number> {
 | 
			
		||||
            const self = this as EtherTokenContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
            );
 | 
			
		||||
            const gas = await promisify<number>(
 | 
			
		||||
                self.web3ContractInstance.transfer.estimateGas, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                _to,
 | 
			
		||||
                _value,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return gas;
 | 
			
		||||
        },
 | 
			
		||||
        getABIEncodedTransactionData(
 | 
			
		||||
            _to: string,
 | 
			
		||||
            _value: BigNumber,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): string {
 | 
			
		||||
            const self = this as EtherTokenContract;
 | 
			
		||||
            const abiEncodedTransactionData = self.web3ContractInstance.transfer.getData();
 | 
			
		||||
            return abiEncodedTransactionData;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public deposit = {
 | 
			
		||||
        async sendTransactionAsync(
 | 
			
		||||
            txData: TxDataPayable = {},
 | 
			
		||||
        ): Promise<string> {
 | 
			
		||||
            const self = this as EtherTokenContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
                self.deposit.estimateGasAsync.bind(
 | 
			
		||||
                    self,
 | 
			
		||||
                ),
 | 
			
		||||
            );
 | 
			
		||||
            const txHash = await promisify<string>(
 | 
			
		||||
                self.web3ContractInstance.deposit, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return txHash;
 | 
			
		||||
        },
 | 
			
		||||
        async estimateGasAsync(
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<number> {
 | 
			
		||||
            const self = this as EtherTokenContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
            );
 | 
			
		||||
            const gas = await promisify<number>(
 | 
			
		||||
                self.web3ContractInstance.deposit.estimateGas, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return gas;
 | 
			
		||||
        },
 | 
			
		||||
        getABIEncodedTransactionData(
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): string {
 | 
			
		||||
            const self = this as EtherTokenContract;
 | 
			
		||||
            const abiEncodedTransactionData = self.web3ContractInstance.deposit.getData();
 | 
			
		||||
            return abiEncodedTransactionData;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public allowance = {
 | 
			
		||||
        async callAsync(
 | 
			
		||||
            _owner: string,
 | 
			
		||||
            _spender: string,
 | 
			
		||||
            defaultBlock?: Web3.BlockParam,
 | 
			
		||||
        ): Promise<BigNumber
 | 
			
		||||
    > {
 | 
			
		||||
            const self = this as EtherTokenContract;
 | 
			
		||||
            const result = await promisify<BigNumber
 | 
			
		||||
    >(
 | 
			
		||||
                self.web3ContractInstance.allowance.call,
 | 
			
		||||
                self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                _owner,
 | 
			
		||||
                _spender,
 | 
			
		||||
            );
 | 
			
		||||
            return result;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    constructor(web3ContractInstance: Web3.ContractInstance, defaults: Partial<TxData>) {
 | 
			
		||||
        super(web3ContractInstance, defaults);
 | 
			
		||||
        classUtils.bindAll(this, ['web3ContractInstance', 'defaults']);
 | 
			
		||||
    }
 | 
			
		||||
} // tslint:disable:max-file-line-count
 | 
			
		||||
@@ -1,730 +0,0 @@
 | 
			
		||||
/**
 | 
			
		||||
 * 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/abi-gen-templates.
 | 
			
		||||
 */
 | 
			
		||||
import {promisify} from '@0xproject/utils';
 | 
			
		||||
import {BigNumber} from 'bignumber.js';
 | 
			
		||||
import * as Web3 from 'web3';
 | 
			
		||||
 | 
			
		||||
import {TxData, TxDataPayable} from '../../types';
 | 
			
		||||
import {classUtils} from '../../utils/class_utils';
 | 
			
		||||
 | 
			
		||||
import {BaseContract} from './base_contract';
 | 
			
		||||
 | 
			
		||||
export class ExchangeContract extends BaseContract {
 | 
			
		||||
    public isRoundingError = {
 | 
			
		||||
        async callAsync(
 | 
			
		||||
            numerator: BigNumber,
 | 
			
		||||
            denominator: BigNumber,
 | 
			
		||||
            target: BigNumber,
 | 
			
		||||
            defaultBlock?: Web3.BlockParam,
 | 
			
		||||
        ): Promise<boolean
 | 
			
		||||
    > {
 | 
			
		||||
            const self = this as ExchangeContract;
 | 
			
		||||
            const result = await promisify<boolean
 | 
			
		||||
    >(
 | 
			
		||||
                self.web3ContractInstance.isRoundingError.call,
 | 
			
		||||
                self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                numerator,
 | 
			
		||||
                denominator,
 | 
			
		||||
                target,
 | 
			
		||||
            );
 | 
			
		||||
            return result;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public filled = {
 | 
			
		||||
        async callAsync(
 | 
			
		||||
            index: string,
 | 
			
		||||
            defaultBlock?: Web3.BlockParam,
 | 
			
		||||
        ): Promise<BigNumber
 | 
			
		||||
    > {
 | 
			
		||||
            const self = this as ExchangeContract;
 | 
			
		||||
            const result = await promisify<BigNumber
 | 
			
		||||
    >(
 | 
			
		||||
                self.web3ContractInstance.filled.call,
 | 
			
		||||
                self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                index,
 | 
			
		||||
            );
 | 
			
		||||
            return result;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public cancelled = {
 | 
			
		||||
        async callAsync(
 | 
			
		||||
            index: string,
 | 
			
		||||
            defaultBlock?: Web3.BlockParam,
 | 
			
		||||
        ): Promise<BigNumber
 | 
			
		||||
    > {
 | 
			
		||||
            const self = this as ExchangeContract;
 | 
			
		||||
            const result = await promisify<BigNumber
 | 
			
		||||
    >(
 | 
			
		||||
                self.web3ContractInstance.cancelled.call,
 | 
			
		||||
                self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                index,
 | 
			
		||||
            );
 | 
			
		||||
            return result;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public fillOrdersUpTo = {
 | 
			
		||||
        async sendTransactionAsync(
 | 
			
		||||
            orderAddresses: string[][],
 | 
			
		||||
            orderValues: BigNumber[][],
 | 
			
		||||
            fillTakerTokenAmount: BigNumber,
 | 
			
		||||
            shouldThrowOnInsufficientBalanceOrAllowance: boolean,
 | 
			
		||||
            v: number|BigNumber[],
 | 
			
		||||
            r: string[],
 | 
			
		||||
            s: string[],
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<string> {
 | 
			
		||||
            const self = this as ExchangeContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
                self.fillOrdersUpTo.estimateGasAsync.bind(
 | 
			
		||||
                    self,
 | 
			
		||||
                    orderAddresses,
 | 
			
		||||
                    orderValues,
 | 
			
		||||
                    fillTakerTokenAmount,
 | 
			
		||||
                    shouldThrowOnInsufficientBalanceOrAllowance,
 | 
			
		||||
                    v,
 | 
			
		||||
                    r,
 | 
			
		||||
                    s,
 | 
			
		||||
                ),
 | 
			
		||||
            );
 | 
			
		||||
            const txHash = await promisify<string>(
 | 
			
		||||
                self.web3ContractInstance.fillOrdersUpTo, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                orderAddresses,
 | 
			
		||||
                orderValues,
 | 
			
		||||
                fillTakerTokenAmount,
 | 
			
		||||
                shouldThrowOnInsufficientBalanceOrAllowance,
 | 
			
		||||
                v,
 | 
			
		||||
                r,
 | 
			
		||||
                s,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return txHash;
 | 
			
		||||
        },
 | 
			
		||||
        async estimateGasAsync(
 | 
			
		||||
            orderAddresses: string[][],
 | 
			
		||||
            orderValues: BigNumber[][],
 | 
			
		||||
            fillTakerTokenAmount: BigNumber,
 | 
			
		||||
            shouldThrowOnInsufficientBalanceOrAllowance: boolean,
 | 
			
		||||
            v: number|BigNumber[],
 | 
			
		||||
            r: string[],
 | 
			
		||||
            s: string[],
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<number> {
 | 
			
		||||
            const self = this as ExchangeContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
            );
 | 
			
		||||
            const gas = await promisify<number>(
 | 
			
		||||
                self.web3ContractInstance.fillOrdersUpTo.estimateGas, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                orderAddresses,
 | 
			
		||||
                orderValues,
 | 
			
		||||
                fillTakerTokenAmount,
 | 
			
		||||
                shouldThrowOnInsufficientBalanceOrAllowance,
 | 
			
		||||
                v,
 | 
			
		||||
                r,
 | 
			
		||||
                s,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return gas;
 | 
			
		||||
        },
 | 
			
		||||
        getABIEncodedTransactionData(
 | 
			
		||||
            orderAddresses: string[][],
 | 
			
		||||
            orderValues: BigNumber[][],
 | 
			
		||||
            fillTakerTokenAmount: BigNumber,
 | 
			
		||||
            shouldThrowOnInsufficientBalanceOrAllowance: boolean,
 | 
			
		||||
            v: number|BigNumber[],
 | 
			
		||||
            r: string[],
 | 
			
		||||
            s: string[],
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): string {
 | 
			
		||||
            const self = this as ExchangeContract;
 | 
			
		||||
            const abiEncodedTransactionData = self.web3ContractInstance.fillOrdersUpTo.getData();
 | 
			
		||||
            return abiEncodedTransactionData;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public cancelOrder = {
 | 
			
		||||
        async sendTransactionAsync(
 | 
			
		||||
            orderAddresses: string[],
 | 
			
		||||
            orderValues: BigNumber[],
 | 
			
		||||
            cancelTakerTokenAmount: BigNumber,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<string> {
 | 
			
		||||
            const self = this as ExchangeContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
                self.cancelOrder.estimateGasAsync.bind(
 | 
			
		||||
                    self,
 | 
			
		||||
                    orderAddresses,
 | 
			
		||||
                    orderValues,
 | 
			
		||||
                    cancelTakerTokenAmount,
 | 
			
		||||
                ),
 | 
			
		||||
            );
 | 
			
		||||
            const txHash = await promisify<string>(
 | 
			
		||||
                self.web3ContractInstance.cancelOrder, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                orderAddresses,
 | 
			
		||||
                orderValues,
 | 
			
		||||
                cancelTakerTokenAmount,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return txHash;
 | 
			
		||||
        },
 | 
			
		||||
        async estimateGasAsync(
 | 
			
		||||
            orderAddresses: string[],
 | 
			
		||||
            orderValues: BigNumber[],
 | 
			
		||||
            cancelTakerTokenAmount: BigNumber,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<number> {
 | 
			
		||||
            const self = this as ExchangeContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
            );
 | 
			
		||||
            const gas = await promisify<number>(
 | 
			
		||||
                self.web3ContractInstance.cancelOrder.estimateGas, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                orderAddresses,
 | 
			
		||||
                orderValues,
 | 
			
		||||
                cancelTakerTokenAmount,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return gas;
 | 
			
		||||
        },
 | 
			
		||||
        getABIEncodedTransactionData(
 | 
			
		||||
            orderAddresses: string[],
 | 
			
		||||
            orderValues: BigNumber[],
 | 
			
		||||
            cancelTakerTokenAmount: BigNumber,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): string {
 | 
			
		||||
            const self = this as ExchangeContract;
 | 
			
		||||
            const abiEncodedTransactionData = self.web3ContractInstance.cancelOrder.getData();
 | 
			
		||||
            return abiEncodedTransactionData;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public ZRX_TOKEN_CONTRACT = {
 | 
			
		||||
        async callAsync(
 | 
			
		||||
            defaultBlock?: Web3.BlockParam,
 | 
			
		||||
        ): Promise<string
 | 
			
		||||
    > {
 | 
			
		||||
            const self = this as ExchangeContract;
 | 
			
		||||
            const result = await promisify<string
 | 
			
		||||
    >(
 | 
			
		||||
                self.web3ContractInstance.ZRX_TOKEN_CONTRACT.call,
 | 
			
		||||
                self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
            );
 | 
			
		||||
            return result;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public batchFillOrKillOrders = {
 | 
			
		||||
        async sendTransactionAsync(
 | 
			
		||||
            orderAddresses: string[][],
 | 
			
		||||
            orderValues: BigNumber[][],
 | 
			
		||||
            fillTakerTokenAmounts: BigNumber[],
 | 
			
		||||
            v: number|BigNumber[],
 | 
			
		||||
            r: string[],
 | 
			
		||||
            s: string[],
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<string> {
 | 
			
		||||
            const self = this as ExchangeContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
                self.batchFillOrKillOrders.estimateGasAsync.bind(
 | 
			
		||||
                    self,
 | 
			
		||||
                    orderAddresses,
 | 
			
		||||
                    orderValues,
 | 
			
		||||
                    fillTakerTokenAmounts,
 | 
			
		||||
                    v,
 | 
			
		||||
                    r,
 | 
			
		||||
                    s,
 | 
			
		||||
                ),
 | 
			
		||||
            );
 | 
			
		||||
            const txHash = await promisify<string>(
 | 
			
		||||
                self.web3ContractInstance.batchFillOrKillOrders, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                orderAddresses,
 | 
			
		||||
                orderValues,
 | 
			
		||||
                fillTakerTokenAmounts,
 | 
			
		||||
                v,
 | 
			
		||||
                r,
 | 
			
		||||
                s,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return txHash;
 | 
			
		||||
        },
 | 
			
		||||
        async estimateGasAsync(
 | 
			
		||||
            orderAddresses: string[][],
 | 
			
		||||
            orderValues: BigNumber[][],
 | 
			
		||||
            fillTakerTokenAmounts: BigNumber[],
 | 
			
		||||
            v: number|BigNumber[],
 | 
			
		||||
            r: string[],
 | 
			
		||||
            s: string[],
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<number> {
 | 
			
		||||
            const self = this as ExchangeContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
            );
 | 
			
		||||
            const gas = await promisify<number>(
 | 
			
		||||
                self.web3ContractInstance.batchFillOrKillOrders.estimateGas, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                orderAddresses,
 | 
			
		||||
                orderValues,
 | 
			
		||||
                fillTakerTokenAmounts,
 | 
			
		||||
                v,
 | 
			
		||||
                r,
 | 
			
		||||
                s,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return gas;
 | 
			
		||||
        },
 | 
			
		||||
        getABIEncodedTransactionData(
 | 
			
		||||
            orderAddresses: string[][],
 | 
			
		||||
            orderValues: BigNumber[][],
 | 
			
		||||
            fillTakerTokenAmounts: BigNumber[],
 | 
			
		||||
            v: number|BigNumber[],
 | 
			
		||||
            r: string[],
 | 
			
		||||
            s: string[],
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): string {
 | 
			
		||||
            const self = this as ExchangeContract;
 | 
			
		||||
            const abiEncodedTransactionData = self.web3ContractInstance.batchFillOrKillOrders.getData();
 | 
			
		||||
            return abiEncodedTransactionData;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public fillOrKillOrder = {
 | 
			
		||||
        async sendTransactionAsync(
 | 
			
		||||
            orderAddresses: string[],
 | 
			
		||||
            orderValues: BigNumber[],
 | 
			
		||||
            fillTakerTokenAmount: BigNumber,
 | 
			
		||||
            v: number|BigNumber,
 | 
			
		||||
            r: string,
 | 
			
		||||
            s: string,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<string> {
 | 
			
		||||
            const self = this as ExchangeContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
                self.fillOrKillOrder.estimateGasAsync.bind(
 | 
			
		||||
                    self,
 | 
			
		||||
                    orderAddresses,
 | 
			
		||||
                    orderValues,
 | 
			
		||||
                    fillTakerTokenAmount,
 | 
			
		||||
                    v,
 | 
			
		||||
                    r,
 | 
			
		||||
                    s,
 | 
			
		||||
                ),
 | 
			
		||||
            );
 | 
			
		||||
            const txHash = await promisify<string>(
 | 
			
		||||
                self.web3ContractInstance.fillOrKillOrder, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                orderAddresses,
 | 
			
		||||
                orderValues,
 | 
			
		||||
                fillTakerTokenAmount,
 | 
			
		||||
                v,
 | 
			
		||||
                r,
 | 
			
		||||
                s,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return txHash;
 | 
			
		||||
        },
 | 
			
		||||
        async estimateGasAsync(
 | 
			
		||||
            orderAddresses: string[],
 | 
			
		||||
            orderValues: BigNumber[],
 | 
			
		||||
            fillTakerTokenAmount: BigNumber,
 | 
			
		||||
            v: number|BigNumber,
 | 
			
		||||
            r: string,
 | 
			
		||||
            s: string,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<number> {
 | 
			
		||||
            const self = this as ExchangeContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
            );
 | 
			
		||||
            const gas = await promisify<number>(
 | 
			
		||||
                self.web3ContractInstance.fillOrKillOrder.estimateGas, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                orderAddresses,
 | 
			
		||||
                orderValues,
 | 
			
		||||
                fillTakerTokenAmount,
 | 
			
		||||
                v,
 | 
			
		||||
                r,
 | 
			
		||||
                s,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return gas;
 | 
			
		||||
        },
 | 
			
		||||
        getABIEncodedTransactionData(
 | 
			
		||||
            orderAddresses: string[],
 | 
			
		||||
            orderValues: BigNumber[],
 | 
			
		||||
            fillTakerTokenAmount: BigNumber,
 | 
			
		||||
            v: number|BigNumber,
 | 
			
		||||
            r: string,
 | 
			
		||||
            s: string,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): string {
 | 
			
		||||
            const self = this as ExchangeContract;
 | 
			
		||||
            const abiEncodedTransactionData = self.web3ContractInstance.fillOrKillOrder.getData();
 | 
			
		||||
            return abiEncodedTransactionData;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public getUnavailableTakerTokenAmount = {
 | 
			
		||||
        async callAsync(
 | 
			
		||||
            orderHash: string,
 | 
			
		||||
            defaultBlock?: Web3.BlockParam,
 | 
			
		||||
        ): Promise<BigNumber
 | 
			
		||||
    > {
 | 
			
		||||
            const self = this as ExchangeContract;
 | 
			
		||||
            const result = await promisify<BigNumber
 | 
			
		||||
    >(
 | 
			
		||||
                self.web3ContractInstance.getUnavailableTakerTokenAmount.call,
 | 
			
		||||
                self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                orderHash,
 | 
			
		||||
            );
 | 
			
		||||
            return result;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public isValidSignature = {
 | 
			
		||||
        async callAsync(
 | 
			
		||||
            signer: string,
 | 
			
		||||
            hash: string,
 | 
			
		||||
            v: number|BigNumber,
 | 
			
		||||
            r: string,
 | 
			
		||||
            s: string,
 | 
			
		||||
            defaultBlock?: Web3.BlockParam,
 | 
			
		||||
        ): Promise<boolean
 | 
			
		||||
    > {
 | 
			
		||||
            const self = this as ExchangeContract;
 | 
			
		||||
            const result = await promisify<boolean
 | 
			
		||||
    >(
 | 
			
		||||
                self.web3ContractInstance.isValidSignature.call,
 | 
			
		||||
                self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                signer,
 | 
			
		||||
                hash,
 | 
			
		||||
                v,
 | 
			
		||||
                r,
 | 
			
		||||
                s,
 | 
			
		||||
            );
 | 
			
		||||
            return result;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public getPartialAmount = {
 | 
			
		||||
        async callAsync(
 | 
			
		||||
            numerator: BigNumber,
 | 
			
		||||
            denominator: BigNumber,
 | 
			
		||||
            target: BigNumber,
 | 
			
		||||
            defaultBlock?: Web3.BlockParam,
 | 
			
		||||
        ): Promise<BigNumber
 | 
			
		||||
    > {
 | 
			
		||||
            const self = this as ExchangeContract;
 | 
			
		||||
            const result = await promisify<BigNumber
 | 
			
		||||
    >(
 | 
			
		||||
                self.web3ContractInstance.getPartialAmount.call,
 | 
			
		||||
                self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                numerator,
 | 
			
		||||
                denominator,
 | 
			
		||||
                target,
 | 
			
		||||
            );
 | 
			
		||||
            return result;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public TOKEN_TRANSFER_PROXY_CONTRACT = {
 | 
			
		||||
        async callAsync(
 | 
			
		||||
            defaultBlock?: Web3.BlockParam,
 | 
			
		||||
        ): Promise<string
 | 
			
		||||
    > {
 | 
			
		||||
            const self = this as ExchangeContract;
 | 
			
		||||
            const result = await promisify<string
 | 
			
		||||
    >(
 | 
			
		||||
                self.web3ContractInstance.TOKEN_TRANSFER_PROXY_CONTRACT.call,
 | 
			
		||||
                self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
            );
 | 
			
		||||
            return result;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public batchFillOrders = {
 | 
			
		||||
        async sendTransactionAsync(
 | 
			
		||||
            orderAddresses: string[][],
 | 
			
		||||
            orderValues: BigNumber[][],
 | 
			
		||||
            fillTakerTokenAmounts: BigNumber[],
 | 
			
		||||
            shouldThrowOnInsufficientBalanceOrAllowance: boolean,
 | 
			
		||||
            v: number|BigNumber[],
 | 
			
		||||
            r: string[],
 | 
			
		||||
            s: string[],
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<string> {
 | 
			
		||||
            const self = this as ExchangeContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
                self.batchFillOrders.estimateGasAsync.bind(
 | 
			
		||||
                    self,
 | 
			
		||||
                    orderAddresses,
 | 
			
		||||
                    orderValues,
 | 
			
		||||
                    fillTakerTokenAmounts,
 | 
			
		||||
                    shouldThrowOnInsufficientBalanceOrAllowance,
 | 
			
		||||
                    v,
 | 
			
		||||
                    r,
 | 
			
		||||
                    s,
 | 
			
		||||
                ),
 | 
			
		||||
            );
 | 
			
		||||
            const txHash = await promisify<string>(
 | 
			
		||||
                self.web3ContractInstance.batchFillOrders, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                orderAddresses,
 | 
			
		||||
                orderValues,
 | 
			
		||||
                fillTakerTokenAmounts,
 | 
			
		||||
                shouldThrowOnInsufficientBalanceOrAllowance,
 | 
			
		||||
                v,
 | 
			
		||||
                r,
 | 
			
		||||
                s,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return txHash;
 | 
			
		||||
        },
 | 
			
		||||
        async estimateGasAsync(
 | 
			
		||||
            orderAddresses: string[][],
 | 
			
		||||
            orderValues: BigNumber[][],
 | 
			
		||||
            fillTakerTokenAmounts: BigNumber[],
 | 
			
		||||
            shouldThrowOnInsufficientBalanceOrAllowance: boolean,
 | 
			
		||||
            v: number|BigNumber[],
 | 
			
		||||
            r: string[],
 | 
			
		||||
            s: string[],
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<number> {
 | 
			
		||||
            const self = this as ExchangeContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
            );
 | 
			
		||||
            const gas = await promisify<number>(
 | 
			
		||||
                self.web3ContractInstance.batchFillOrders.estimateGas, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                orderAddresses,
 | 
			
		||||
                orderValues,
 | 
			
		||||
                fillTakerTokenAmounts,
 | 
			
		||||
                shouldThrowOnInsufficientBalanceOrAllowance,
 | 
			
		||||
                v,
 | 
			
		||||
                r,
 | 
			
		||||
                s,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return gas;
 | 
			
		||||
        },
 | 
			
		||||
        getABIEncodedTransactionData(
 | 
			
		||||
            orderAddresses: string[][],
 | 
			
		||||
            orderValues: BigNumber[][],
 | 
			
		||||
            fillTakerTokenAmounts: BigNumber[],
 | 
			
		||||
            shouldThrowOnInsufficientBalanceOrAllowance: boolean,
 | 
			
		||||
            v: number|BigNumber[],
 | 
			
		||||
            r: string[],
 | 
			
		||||
            s: string[],
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): string {
 | 
			
		||||
            const self = this as ExchangeContract;
 | 
			
		||||
            const abiEncodedTransactionData = self.web3ContractInstance.batchFillOrders.getData();
 | 
			
		||||
            return abiEncodedTransactionData;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public batchCancelOrders = {
 | 
			
		||||
        async sendTransactionAsync(
 | 
			
		||||
            orderAddresses: string[][],
 | 
			
		||||
            orderValues: BigNumber[][],
 | 
			
		||||
            cancelTakerTokenAmounts: BigNumber[],
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<string> {
 | 
			
		||||
            const self = this as ExchangeContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
                self.batchCancelOrders.estimateGasAsync.bind(
 | 
			
		||||
                    self,
 | 
			
		||||
                    orderAddresses,
 | 
			
		||||
                    orderValues,
 | 
			
		||||
                    cancelTakerTokenAmounts,
 | 
			
		||||
                ),
 | 
			
		||||
            );
 | 
			
		||||
            const txHash = await promisify<string>(
 | 
			
		||||
                self.web3ContractInstance.batchCancelOrders, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                orderAddresses,
 | 
			
		||||
                orderValues,
 | 
			
		||||
                cancelTakerTokenAmounts,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return txHash;
 | 
			
		||||
        },
 | 
			
		||||
        async estimateGasAsync(
 | 
			
		||||
            orderAddresses: string[][],
 | 
			
		||||
            orderValues: BigNumber[][],
 | 
			
		||||
            cancelTakerTokenAmounts: BigNumber[],
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<number> {
 | 
			
		||||
            const self = this as ExchangeContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
            );
 | 
			
		||||
            const gas = await promisify<number>(
 | 
			
		||||
                self.web3ContractInstance.batchCancelOrders.estimateGas, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                orderAddresses,
 | 
			
		||||
                orderValues,
 | 
			
		||||
                cancelTakerTokenAmounts,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return gas;
 | 
			
		||||
        },
 | 
			
		||||
        getABIEncodedTransactionData(
 | 
			
		||||
            orderAddresses: string[][],
 | 
			
		||||
            orderValues: BigNumber[][],
 | 
			
		||||
            cancelTakerTokenAmounts: BigNumber[],
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): string {
 | 
			
		||||
            const self = this as ExchangeContract;
 | 
			
		||||
            const abiEncodedTransactionData = self.web3ContractInstance.batchCancelOrders.getData();
 | 
			
		||||
            return abiEncodedTransactionData;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public fillOrder = {
 | 
			
		||||
        async sendTransactionAsync(
 | 
			
		||||
            orderAddresses: string[],
 | 
			
		||||
            orderValues: BigNumber[],
 | 
			
		||||
            fillTakerTokenAmount: BigNumber,
 | 
			
		||||
            shouldThrowOnInsufficientBalanceOrAllowance: boolean,
 | 
			
		||||
            v: number|BigNumber,
 | 
			
		||||
            r: string,
 | 
			
		||||
            s: string,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<string> {
 | 
			
		||||
            const self = this as ExchangeContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
                self.fillOrder.estimateGasAsync.bind(
 | 
			
		||||
                    self,
 | 
			
		||||
                    orderAddresses,
 | 
			
		||||
                    orderValues,
 | 
			
		||||
                    fillTakerTokenAmount,
 | 
			
		||||
                    shouldThrowOnInsufficientBalanceOrAllowance,
 | 
			
		||||
                    v,
 | 
			
		||||
                    r,
 | 
			
		||||
                    s,
 | 
			
		||||
                ),
 | 
			
		||||
            );
 | 
			
		||||
            const txHash = await promisify<string>(
 | 
			
		||||
                self.web3ContractInstance.fillOrder, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                orderAddresses,
 | 
			
		||||
                orderValues,
 | 
			
		||||
                fillTakerTokenAmount,
 | 
			
		||||
                shouldThrowOnInsufficientBalanceOrAllowance,
 | 
			
		||||
                v,
 | 
			
		||||
                r,
 | 
			
		||||
                s,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return txHash;
 | 
			
		||||
        },
 | 
			
		||||
        async estimateGasAsync(
 | 
			
		||||
            orderAddresses: string[],
 | 
			
		||||
            orderValues: BigNumber[],
 | 
			
		||||
            fillTakerTokenAmount: BigNumber,
 | 
			
		||||
            shouldThrowOnInsufficientBalanceOrAllowance: boolean,
 | 
			
		||||
            v: number|BigNumber,
 | 
			
		||||
            r: string,
 | 
			
		||||
            s: string,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<number> {
 | 
			
		||||
            const self = this as ExchangeContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
            );
 | 
			
		||||
            const gas = await promisify<number>(
 | 
			
		||||
                self.web3ContractInstance.fillOrder.estimateGas, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                orderAddresses,
 | 
			
		||||
                orderValues,
 | 
			
		||||
                fillTakerTokenAmount,
 | 
			
		||||
                shouldThrowOnInsufficientBalanceOrAllowance,
 | 
			
		||||
                v,
 | 
			
		||||
                r,
 | 
			
		||||
                s,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return gas;
 | 
			
		||||
        },
 | 
			
		||||
        getABIEncodedTransactionData(
 | 
			
		||||
            orderAddresses: string[],
 | 
			
		||||
            orderValues: BigNumber[],
 | 
			
		||||
            fillTakerTokenAmount: BigNumber,
 | 
			
		||||
            shouldThrowOnInsufficientBalanceOrAllowance: boolean,
 | 
			
		||||
            v: number|BigNumber,
 | 
			
		||||
            r: string,
 | 
			
		||||
            s: string,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): string {
 | 
			
		||||
            const self = this as ExchangeContract;
 | 
			
		||||
            const abiEncodedTransactionData = self.web3ContractInstance.fillOrder.getData();
 | 
			
		||||
            return abiEncodedTransactionData;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public getOrderHash = {
 | 
			
		||||
        async callAsync(
 | 
			
		||||
            orderAddresses: string[],
 | 
			
		||||
            orderValues: BigNumber[],
 | 
			
		||||
            defaultBlock?: Web3.BlockParam,
 | 
			
		||||
        ): Promise<string
 | 
			
		||||
    > {
 | 
			
		||||
            const self = this as ExchangeContract;
 | 
			
		||||
            const result = await promisify<string
 | 
			
		||||
    >(
 | 
			
		||||
                self.web3ContractInstance.getOrderHash.call,
 | 
			
		||||
                self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                orderAddresses,
 | 
			
		||||
                orderValues,
 | 
			
		||||
            );
 | 
			
		||||
            return result;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public EXTERNAL_QUERY_GAS_LIMIT = {
 | 
			
		||||
        async callAsync(
 | 
			
		||||
            defaultBlock?: Web3.BlockParam,
 | 
			
		||||
        ): Promise<BigNumber
 | 
			
		||||
    > {
 | 
			
		||||
            const self = this as ExchangeContract;
 | 
			
		||||
            const result = await promisify<BigNumber
 | 
			
		||||
    >(
 | 
			
		||||
                self.web3ContractInstance.EXTERNAL_QUERY_GAS_LIMIT.call,
 | 
			
		||||
                self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
            );
 | 
			
		||||
            return result;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public VERSION = {
 | 
			
		||||
        async callAsync(
 | 
			
		||||
            defaultBlock?: Web3.BlockParam,
 | 
			
		||||
        ): Promise<string
 | 
			
		||||
    > {
 | 
			
		||||
            const self = this as ExchangeContract;
 | 
			
		||||
            const result = await promisify<string
 | 
			
		||||
    >(
 | 
			
		||||
                self.web3ContractInstance.VERSION.call,
 | 
			
		||||
                self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
            );
 | 
			
		||||
            return result;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    constructor(web3ContractInstance: Web3.ContractInstance, defaults: Partial<TxData>) {
 | 
			
		||||
        super(web3ContractInstance, defaults);
 | 
			
		||||
        classUtils.bindAll(this, ['web3ContractInstance', 'defaults']);
 | 
			
		||||
    }
 | 
			
		||||
} // tslint:disable:max-file-line-count
 | 
			
		||||
@@ -1,232 +0,0 @@
 | 
			
		||||
/**
 | 
			
		||||
 * 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/abi-gen-templates.
 | 
			
		||||
 */
 | 
			
		||||
import {promisify} from '@0xproject/utils';
 | 
			
		||||
import {BigNumber} from 'bignumber.js';
 | 
			
		||||
import * as Web3 from 'web3';
 | 
			
		||||
 | 
			
		||||
import {TxData, TxDataPayable} from '../../types';
 | 
			
		||||
import {classUtils} from '../../utils/class_utils';
 | 
			
		||||
 | 
			
		||||
import {BaseContract} from './base_contract';
 | 
			
		||||
 | 
			
		||||
export class TokenContract extends BaseContract {
 | 
			
		||||
    public approve = {
 | 
			
		||||
        async sendTransactionAsync(
 | 
			
		||||
            _spender: string,
 | 
			
		||||
            _value: BigNumber,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<string> {
 | 
			
		||||
            const self = this as TokenContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
                self.approve.estimateGasAsync.bind(
 | 
			
		||||
                    self,
 | 
			
		||||
                    _spender,
 | 
			
		||||
                    _value,
 | 
			
		||||
                ),
 | 
			
		||||
            );
 | 
			
		||||
            const txHash = await promisify<string>(
 | 
			
		||||
                self.web3ContractInstance.approve, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                _spender,
 | 
			
		||||
                _value,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return txHash;
 | 
			
		||||
        },
 | 
			
		||||
        async estimateGasAsync(
 | 
			
		||||
            _spender: string,
 | 
			
		||||
            _value: BigNumber,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<number> {
 | 
			
		||||
            const self = this as TokenContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
            );
 | 
			
		||||
            const gas = await promisify<number>(
 | 
			
		||||
                self.web3ContractInstance.approve.estimateGas, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                _spender,
 | 
			
		||||
                _value,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return gas;
 | 
			
		||||
        },
 | 
			
		||||
        getABIEncodedTransactionData(
 | 
			
		||||
            _spender: string,
 | 
			
		||||
            _value: BigNumber,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): string {
 | 
			
		||||
            const self = this as TokenContract;
 | 
			
		||||
            const abiEncodedTransactionData = self.web3ContractInstance.approve.getData();
 | 
			
		||||
            return abiEncodedTransactionData;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public totalSupply = {
 | 
			
		||||
        async callAsync(
 | 
			
		||||
            defaultBlock?: Web3.BlockParam,
 | 
			
		||||
        ): Promise<BigNumber
 | 
			
		||||
    > {
 | 
			
		||||
            const self = this as TokenContract;
 | 
			
		||||
            const result = await promisify<BigNumber
 | 
			
		||||
    >(
 | 
			
		||||
                self.web3ContractInstance.totalSupply.call,
 | 
			
		||||
                self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
            );
 | 
			
		||||
            return result;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public transferFrom = {
 | 
			
		||||
        async sendTransactionAsync(
 | 
			
		||||
            _from: string,
 | 
			
		||||
            _to: string,
 | 
			
		||||
            _value: BigNumber,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<string> {
 | 
			
		||||
            const self = this as TokenContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
                self.transferFrom.estimateGasAsync.bind(
 | 
			
		||||
                    self,
 | 
			
		||||
                    _from,
 | 
			
		||||
                    _to,
 | 
			
		||||
                    _value,
 | 
			
		||||
                ),
 | 
			
		||||
            );
 | 
			
		||||
            const txHash = await promisify<string>(
 | 
			
		||||
                self.web3ContractInstance.transferFrom, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                _from,
 | 
			
		||||
                _to,
 | 
			
		||||
                _value,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return txHash;
 | 
			
		||||
        },
 | 
			
		||||
        async estimateGasAsync(
 | 
			
		||||
            _from: string,
 | 
			
		||||
            _to: string,
 | 
			
		||||
            _value: BigNumber,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<number> {
 | 
			
		||||
            const self = this as TokenContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
            );
 | 
			
		||||
            const gas = await promisify<number>(
 | 
			
		||||
                self.web3ContractInstance.transferFrom.estimateGas, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                _from,
 | 
			
		||||
                _to,
 | 
			
		||||
                _value,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return gas;
 | 
			
		||||
        },
 | 
			
		||||
        getABIEncodedTransactionData(
 | 
			
		||||
            _from: string,
 | 
			
		||||
            _to: string,
 | 
			
		||||
            _value: BigNumber,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): string {
 | 
			
		||||
            const self = this as TokenContract;
 | 
			
		||||
            const abiEncodedTransactionData = self.web3ContractInstance.transferFrom.getData();
 | 
			
		||||
            return abiEncodedTransactionData;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public balanceOf = {
 | 
			
		||||
        async callAsync(
 | 
			
		||||
            _owner: string,
 | 
			
		||||
            defaultBlock?: Web3.BlockParam,
 | 
			
		||||
        ): Promise<BigNumber
 | 
			
		||||
    > {
 | 
			
		||||
            const self = this as TokenContract;
 | 
			
		||||
            const result = await promisify<BigNumber
 | 
			
		||||
    >(
 | 
			
		||||
                self.web3ContractInstance.balanceOf.call,
 | 
			
		||||
                self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                _owner,
 | 
			
		||||
            );
 | 
			
		||||
            return result;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public transfer = {
 | 
			
		||||
        async sendTransactionAsync(
 | 
			
		||||
            _to: string,
 | 
			
		||||
            _value: BigNumber,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<string> {
 | 
			
		||||
            const self = this as TokenContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
                self.transfer.estimateGasAsync.bind(
 | 
			
		||||
                    self,
 | 
			
		||||
                    _to,
 | 
			
		||||
                    _value,
 | 
			
		||||
                ),
 | 
			
		||||
            );
 | 
			
		||||
            const txHash = await promisify<string>(
 | 
			
		||||
                self.web3ContractInstance.transfer, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                _to,
 | 
			
		||||
                _value,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return txHash;
 | 
			
		||||
        },
 | 
			
		||||
        async estimateGasAsync(
 | 
			
		||||
            _to: string,
 | 
			
		||||
            _value: BigNumber,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<number> {
 | 
			
		||||
            const self = this as TokenContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
            );
 | 
			
		||||
            const gas = await promisify<number>(
 | 
			
		||||
                self.web3ContractInstance.transfer.estimateGas, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                _to,
 | 
			
		||||
                _value,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return gas;
 | 
			
		||||
        },
 | 
			
		||||
        getABIEncodedTransactionData(
 | 
			
		||||
            _to: string,
 | 
			
		||||
            _value: BigNumber,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): string {
 | 
			
		||||
            const self = this as TokenContract;
 | 
			
		||||
            const abiEncodedTransactionData = self.web3ContractInstance.transfer.getData();
 | 
			
		||||
            return abiEncodedTransactionData;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public allowance = {
 | 
			
		||||
        async callAsync(
 | 
			
		||||
            _owner: string,
 | 
			
		||||
            _spender: string,
 | 
			
		||||
            defaultBlock?: Web3.BlockParam,
 | 
			
		||||
        ): Promise<BigNumber
 | 
			
		||||
    > {
 | 
			
		||||
            const self = this as TokenContract;
 | 
			
		||||
            const result = await promisify<BigNumber
 | 
			
		||||
    >(
 | 
			
		||||
                self.web3ContractInstance.allowance.call,
 | 
			
		||||
                self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                _owner,
 | 
			
		||||
                _spender,
 | 
			
		||||
            );
 | 
			
		||||
            return result;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    constructor(web3ContractInstance: Web3.ContractInstance, defaults: Partial<TxData>) {
 | 
			
		||||
        super(web3ContractInstance, defaults);
 | 
			
		||||
        classUtils.bindAll(this, ['web3ContractInstance', 'defaults']);
 | 
			
		||||
    }
 | 
			
		||||
} // tslint:disable:max-file-line-count
 | 
			
		||||
@@ -1,550 +0,0 @@
 | 
			
		||||
/**
 | 
			
		||||
 * 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/abi-gen-templates.
 | 
			
		||||
 */
 | 
			
		||||
import {promisify} from '@0xproject/utils';
 | 
			
		||||
import {BigNumber} from 'bignumber.js';
 | 
			
		||||
import * as Web3 from 'web3';
 | 
			
		||||
 | 
			
		||||
import {TxData, TxDataPayable} from '../../types';
 | 
			
		||||
import {classUtils} from '../../utils/class_utils';
 | 
			
		||||
 | 
			
		||||
import {BaseContract} from './base_contract';
 | 
			
		||||
 | 
			
		||||
export class TokenRegistryContract extends BaseContract {
 | 
			
		||||
    public removeToken = {
 | 
			
		||||
        async sendTransactionAsync(
 | 
			
		||||
            _token: string,
 | 
			
		||||
            _index: BigNumber,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<string> {
 | 
			
		||||
            const self = this as TokenRegistryContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
                self.removeToken.estimateGasAsync.bind(
 | 
			
		||||
                    self,
 | 
			
		||||
                    _token,
 | 
			
		||||
                    _index,
 | 
			
		||||
                ),
 | 
			
		||||
            );
 | 
			
		||||
            const txHash = await promisify<string>(
 | 
			
		||||
                self.web3ContractInstance.removeToken, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                _token,
 | 
			
		||||
                _index,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return txHash;
 | 
			
		||||
        },
 | 
			
		||||
        async estimateGasAsync(
 | 
			
		||||
            _token: string,
 | 
			
		||||
            _index: BigNumber,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<number> {
 | 
			
		||||
            const self = this as TokenRegistryContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
            );
 | 
			
		||||
            const gas = await promisify<number>(
 | 
			
		||||
                self.web3ContractInstance.removeToken.estimateGas, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                _token,
 | 
			
		||||
                _index,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return gas;
 | 
			
		||||
        },
 | 
			
		||||
        getABIEncodedTransactionData(
 | 
			
		||||
            _token: string,
 | 
			
		||||
            _index: BigNumber,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): string {
 | 
			
		||||
            const self = this as TokenRegistryContract;
 | 
			
		||||
            const abiEncodedTransactionData = self.web3ContractInstance.removeToken.getData();
 | 
			
		||||
            return abiEncodedTransactionData;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public getTokenAddressByName = {
 | 
			
		||||
        async callAsync(
 | 
			
		||||
            _name: string,
 | 
			
		||||
            defaultBlock?: Web3.BlockParam,
 | 
			
		||||
        ): Promise<string
 | 
			
		||||
    > {
 | 
			
		||||
            const self = this as TokenRegistryContract;
 | 
			
		||||
            const result = await promisify<string
 | 
			
		||||
    >(
 | 
			
		||||
                self.web3ContractInstance.getTokenAddressByName.call,
 | 
			
		||||
                self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                _name,
 | 
			
		||||
            );
 | 
			
		||||
            return result;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public getTokenAddressBySymbol = {
 | 
			
		||||
        async callAsync(
 | 
			
		||||
            _symbol: string,
 | 
			
		||||
            defaultBlock?: Web3.BlockParam,
 | 
			
		||||
        ): Promise<string
 | 
			
		||||
    > {
 | 
			
		||||
            const self = this as TokenRegistryContract;
 | 
			
		||||
            const result = await promisify<string
 | 
			
		||||
    >(
 | 
			
		||||
                self.web3ContractInstance.getTokenAddressBySymbol.call,
 | 
			
		||||
                self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                _symbol,
 | 
			
		||||
            );
 | 
			
		||||
            return result;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public setTokenSwarmHash = {
 | 
			
		||||
        async sendTransactionAsync(
 | 
			
		||||
            _token: string,
 | 
			
		||||
            _swarmHash: string,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<string> {
 | 
			
		||||
            const self = this as TokenRegistryContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
                self.setTokenSwarmHash.estimateGasAsync.bind(
 | 
			
		||||
                    self,
 | 
			
		||||
                    _token,
 | 
			
		||||
                    _swarmHash,
 | 
			
		||||
                ),
 | 
			
		||||
            );
 | 
			
		||||
            const txHash = await promisify<string>(
 | 
			
		||||
                self.web3ContractInstance.setTokenSwarmHash, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                _token,
 | 
			
		||||
                _swarmHash,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return txHash;
 | 
			
		||||
        },
 | 
			
		||||
        async estimateGasAsync(
 | 
			
		||||
            _token: string,
 | 
			
		||||
            _swarmHash: string,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<number> {
 | 
			
		||||
            const self = this as TokenRegistryContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
            );
 | 
			
		||||
            const gas = await promisify<number>(
 | 
			
		||||
                self.web3ContractInstance.setTokenSwarmHash.estimateGas, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                _token,
 | 
			
		||||
                _swarmHash,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return gas;
 | 
			
		||||
        },
 | 
			
		||||
        getABIEncodedTransactionData(
 | 
			
		||||
            _token: string,
 | 
			
		||||
            _swarmHash: string,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): string {
 | 
			
		||||
            const self = this as TokenRegistryContract;
 | 
			
		||||
            const abiEncodedTransactionData = self.web3ContractInstance.setTokenSwarmHash.getData();
 | 
			
		||||
            return abiEncodedTransactionData;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public getTokenMetaData = {
 | 
			
		||||
        async callAsync(
 | 
			
		||||
            _token: string,
 | 
			
		||||
            defaultBlock?: Web3.BlockParam,
 | 
			
		||||
        ): Promise<[string, string, string, BigNumber, string, string]
 | 
			
		||||
    > {
 | 
			
		||||
            const self = this as TokenRegistryContract;
 | 
			
		||||
            const result = await promisify<[string, string, string, BigNumber, string, string]
 | 
			
		||||
    >(
 | 
			
		||||
                self.web3ContractInstance.getTokenMetaData.call,
 | 
			
		||||
                self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                _token,
 | 
			
		||||
            );
 | 
			
		||||
            return result;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public owner = {
 | 
			
		||||
        async callAsync(
 | 
			
		||||
            defaultBlock?: Web3.BlockParam,
 | 
			
		||||
        ): Promise<string
 | 
			
		||||
    > {
 | 
			
		||||
            const self = this as TokenRegistryContract;
 | 
			
		||||
            const result = await promisify<string
 | 
			
		||||
    >(
 | 
			
		||||
                self.web3ContractInstance.owner.call,
 | 
			
		||||
                self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
            );
 | 
			
		||||
            return result;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public addToken = {
 | 
			
		||||
        async sendTransactionAsync(
 | 
			
		||||
            _token: string,
 | 
			
		||||
            _name: string,
 | 
			
		||||
            _symbol: string,
 | 
			
		||||
            _decimals: number|BigNumber,
 | 
			
		||||
            _ipfsHash: string,
 | 
			
		||||
            _swarmHash: string,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<string> {
 | 
			
		||||
            const self = this as TokenRegistryContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
                self.addToken.estimateGasAsync.bind(
 | 
			
		||||
                    self,
 | 
			
		||||
                    _token,
 | 
			
		||||
                    _name,
 | 
			
		||||
                    _symbol,
 | 
			
		||||
                    _decimals,
 | 
			
		||||
                    _ipfsHash,
 | 
			
		||||
                    _swarmHash,
 | 
			
		||||
                ),
 | 
			
		||||
            );
 | 
			
		||||
            const txHash = await promisify<string>(
 | 
			
		||||
                self.web3ContractInstance.addToken, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                _token,
 | 
			
		||||
                _name,
 | 
			
		||||
                _symbol,
 | 
			
		||||
                _decimals,
 | 
			
		||||
                _ipfsHash,
 | 
			
		||||
                _swarmHash,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return txHash;
 | 
			
		||||
        },
 | 
			
		||||
        async estimateGasAsync(
 | 
			
		||||
            _token: string,
 | 
			
		||||
            _name: string,
 | 
			
		||||
            _symbol: string,
 | 
			
		||||
            _decimals: number|BigNumber,
 | 
			
		||||
            _ipfsHash: string,
 | 
			
		||||
            _swarmHash: string,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<number> {
 | 
			
		||||
            const self = this as TokenRegistryContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
            );
 | 
			
		||||
            const gas = await promisify<number>(
 | 
			
		||||
                self.web3ContractInstance.addToken.estimateGas, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                _token,
 | 
			
		||||
                _name,
 | 
			
		||||
                _symbol,
 | 
			
		||||
                _decimals,
 | 
			
		||||
                _ipfsHash,
 | 
			
		||||
                _swarmHash,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return gas;
 | 
			
		||||
        },
 | 
			
		||||
        getABIEncodedTransactionData(
 | 
			
		||||
            _token: string,
 | 
			
		||||
            _name: string,
 | 
			
		||||
            _symbol: string,
 | 
			
		||||
            _decimals: number|BigNumber,
 | 
			
		||||
            _ipfsHash: string,
 | 
			
		||||
            _swarmHash: string,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): string {
 | 
			
		||||
            const self = this as TokenRegistryContract;
 | 
			
		||||
            const abiEncodedTransactionData = self.web3ContractInstance.addToken.getData();
 | 
			
		||||
            return abiEncodedTransactionData;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public setTokenName = {
 | 
			
		||||
        async sendTransactionAsync(
 | 
			
		||||
            _token: string,
 | 
			
		||||
            _name: string,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<string> {
 | 
			
		||||
            const self = this as TokenRegistryContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
                self.setTokenName.estimateGasAsync.bind(
 | 
			
		||||
                    self,
 | 
			
		||||
                    _token,
 | 
			
		||||
                    _name,
 | 
			
		||||
                ),
 | 
			
		||||
            );
 | 
			
		||||
            const txHash = await promisify<string>(
 | 
			
		||||
                self.web3ContractInstance.setTokenName, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                _token,
 | 
			
		||||
                _name,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return txHash;
 | 
			
		||||
        },
 | 
			
		||||
        async estimateGasAsync(
 | 
			
		||||
            _token: string,
 | 
			
		||||
            _name: string,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<number> {
 | 
			
		||||
            const self = this as TokenRegistryContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
            );
 | 
			
		||||
            const gas = await promisify<number>(
 | 
			
		||||
                self.web3ContractInstance.setTokenName.estimateGas, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                _token,
 | 
			
		||||
                _name,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return gas;
 | 
			
		||||
        },
 | 
			
		||||
        getABIEncodedTransactionData(
 | 
			
		||||
            _token: string,
 | 
			
		||||
            _name: string,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): string {
 | 
			
		||||
            const self = this as TokenRegistryContract;
 | 
			
		||||
            const abiEncodedTransactionData = self.web3ContractInstance.setTokenName.getData();
 | 
			
		||||
            return abiEncodedTransactionData;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public tokens = {
 | 
			
		||||
        async callAsync(
 | 
			
		||||
            index: string,
 | 
			
		||||
            defaultBlock?: Web3.BlockParam,
 | 
			
		||||
        ): Promise<[string, string, string, BigNumber, string, string]
 | 
			
		||||
    > {
 | 
			
		||||
            const self = this as TokenRegistryContract;
 | 
			
		||||
            const result = await promisify<[string, string, string, BigNumber, string, string]
 | 
			
		||||
    >(
 | 
			
		||||
                self.web3ContractInstance.tokens.call,
 | 
			
		||||
                self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                index,
 | 
			
		||||
            );
 | 
			
		||||
            return result;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public tokenAddresses = {
 | 
			
		||||
        async callAsync(
 | 
			
		||||
            index: BigNumber,
 | 
			
		||||
            defaultBlock?: Web3.BlockParam,
 | 
			
		||||
        ): Promise<string
 | 
			
		||||
    > {
 | 
			
		||||
            const self = this as TokenRegistryContract;
 | 
			
		||||
            const result = await promisify<string
 | 
			
		||||
    >(
 | 
			
		||||
                self.web3ContractInstance.tokenAddresses.call,
 | 
			
		||||
                self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                index,
 | 
			
		||||
            );
 | 
			
		||||
            return result;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public getTokenByName = {
 | 
			
		||||
        async callAsync(
 | 
			
		||||
            _name: string,
 | 
			
		||||
            defaultBlock?: Web3.BlockParam,
 | 
			
		||||
        ): Promise<[string, string, string, BigNumber, string, string]
 | 
			
		||||
    > {
 | 
			
		||||
            const self = this as TokenRegistryContract;
 | 
			
		||||
            const result = await promisify<[string, string, string, BigNumber, string, string]
 | 
			
		||||
    >(
 | 
			
		||||
                self.web3ContractInstance.getTokenByName.call,
 | 
			
		||||
                self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                _name,
 | 
			
		||||
            );
 | 
			
		||||
            return result;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public getTokenAddresses = {
 | 
			
		||||
        async callAsync(
 | 
			
		||||
            defaultBlock?: Web3.BlockParam,
 | 
			
		||||
        ): Promise<string[]
 | 
			
		||||
    > {
 | 
			
		||||
            const self = this as TokenRegistryContract;
 | 
			
		||||
            const result = await promisify<string[]
 | 
			
		||||
    >(
 | 
			
		||||
                self.web3ContractInstance.getTokenAddresses.call,
 | 
			
		||||
                self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
            );
 | 
			
		||||
            return result;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public setTokenIpfsHash = {
 | 
			
		||||
        async sendTransactionAsync(
 | 
			
		||||
            _token: string,
 | 
			
		||||
            _ipfsHash: string,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<string> {
 | 
			
		||||
            const self = this as TokenRegistryContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
                self.setTokenIpfsHash.estimateGasAsync.bind(
 | 
			
		||||
                    self,
 | 
			
		||||
                    _token,
 | 
			
		||||
                    _ipfsHash,
 | 
			
		||||
                ),
 | 
			
		||||
            );
 | 
			
		||||
            const txHash = await promisify<string>(
 | 
			
		||||
                self.web3ContractInstance.setTokenIpfsHash, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                _token,
 | 
			
		||||
                _ipfsHash,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return txHash;
 | 
			
		||||
        },
 | 
			
		||||
        async estimateGasAsync(
 | 
			
		||||
            _token: string,
 | 
			
		||||
            _ipfsHash: string,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<number> {
 | 
			
		||||
            const self = this as TokenRegistryContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
            );
 | 
			
		||||
            const gas = await promisify<number>(
 | 
			
		||||
                self.web3ContractInstance.setTokenIpfsHash.estimateGas, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                _token,
 | 
			
		||||
                _ipfsHash,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return gas;
 | 
			
		||||
        },
 | 
			
		||||
        getABIEncodedTransactionData(
 | 
			
		||||
            _token: string,
 | 
			
		||||
            _ipfsHash: string,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): string {
 | 
			
		||||
            const self = this as TokenRegistryContract;
 | 
			
		||||
            const abiEncodedTransactionData = self.web3ContractInstance.setTokenIpfsHash.getData();
 | 
			
		||||
            return abiEncodedTransactionData;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public getTokenBySymbol = {
 | 
			
		||||
        async callAsync(
 | 
			
		||||
            _symbol: string,
 | 
			
		||||
            defaultBlock?: Web3.BlockParam,
 | 
			
		||||
        ): Promise<[string, string, string, BigNumber, string, string]
 | 
			
		||||
    > {
 | 
			
		||||
            const self = this as TokenRegistryContract;
 | 
			
		||||
            const result = await promisify<[string, string, string, BigNumber, string, string]
 | 
			
		||||
    >(
 | 
			
		||||
                self.web3ContractInstance.getTokenBySymbol.call,
 | 
			
		||||
                self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                _symbol,
 | 
			
		||||
            );
 | 
			
		||||
            return result;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public setTokenSymbol = {
 | 
			
		||||
        async sendTransactionAsync(
 | 
			
		||||
            _token: string,
 | 
			
		||||
            _symbol: string,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<string> {
 | 
			
		||||
            const self = this as TokenRegistryContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
                self.setTokenSymbol.estimateGasAsync.bind(
 | 
			
		||||
                    self,
 | 
			
		||||
                    _token,
 | 
			
		||||
                    _symbol,
 | 
			
		||||
                ),
 | 
			
		||||
            );
 | 
			
		||||
            const txHash = await promisify<string>(
 | 
			
		||||
                self.web3ContractInstance.setTokenSymbol, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                _token,
 | 
			
		||||
                _symbol,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return txHash;
 | 
			
		||||
        },
 | 
			
		||||
        async estimateGasAsync(
 | 
			
		||||
            _token: string,
 | 
			
		||||
            _symbol: string,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<number> {
 | 
			
		||||
            const self = this as TokenRegistryContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
            );
 | 
			
		||||
            const gas = await promisify<number>(
 | 
			
		||||
                self.web3ContractInstance.setTokenSymbol.estimateGas, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                _token,
 | 
			
		||||
                _symbol,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return gas;
 | 
			
		||||
        },
 | 
			
		||||
        getABIEncodedTransactionData(
 | 
			
		||||
            _token: string,
 | 
			
		||||
            _symbol: string,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): string {
 | 
			
		||||
            const self = this as TokenRegistryContract;
 | 
			
		||||
            const abiEncodedTransactionData = self.web3ContractInstance.setTokenSymbol.getData();
 | 
			
		||||
            return abiEncodedTransactionData;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public transferOwnership = {
 | 
			
		||||
        async sendTransactionAsync(
 | 
			
		||||
            newOwner: string,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<string> {
 | 
			
		||||
            const self = this as TokenRegistryContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
                self.transferOwnership.estimateGasAsync.bind(
 | 
			
		||||
                    self,
 | 
			
		||||
                    newOwner,
 | 
			
		||||
                ),
 | 
			
		||||
            );
 | 
			
		||||
            const txHash = await promisify<string>(
 | 
			
		||||
                self.web3ContractInstance.transferOwnership, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                newOwner,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return txHash;
 | 
			
		||||
        },
 | 
			
		||||
        async estimateGasAsync(
 | 
			
		||||
            newOwner: string,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<number> {
 | 
			
		||||
            const self = this as TokenRegistryContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
            );
 | 
			
		||||
            const gas = await promisify<number>(
 | 
			
		||||
                self.web3ContractInstance.transferOwnership.estimateGas, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                newOwner,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return gas;
 | 
			
		||||
        },
 | 
			
		||||
        getABIEncodedTransactionData(
 | 
			
		||||
            newOwner: string,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): string {
 | 
			
		||||
            const self = this as TokenRegistryContract;
 | 
			
		||||
            const abiEncodedTransactionData = self.web3ContractInstance.transferOwnership.getData();
 | 
			
		||||
            return abiEncodedTransactionData;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    constructor(web3ContractInstance: Web3.ContractInstance, defaults: Partial<TxData>) {
 | 
			
		||||
        super(web3ContractInstance, defaults);
 | 
			
		||||
        classUtils.bindAll(this, ['web3ContractInstance', 'defaults']);
 | 
			
		||||
    }
 | 
			
		||||
} // tslint:disable:max-file-line-count
 | 
			
		||||
@@ -1,285 +0,0 @@
 | 
			
		||||
/**
 | 
			
		||||
 * 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/abi-gen-templates.
 | 
			
		||||
 */
 | 
			
		||||
import {promisify} from '@0xproject/utils';
 | 
			
		||||
import {BigNumber} from 'bignumber.js';
 | 
			
		||||
import * as Web3 from 'web3';
 | 
			
		||||
 | 
			
		||||
import {TxData, TxDataPayable} from '../../types';
 | 
			
		||||
import {classUtils} from '../../utils/class_utils';
 | 
			
		||||
 | 
			
		||||
import {BaseContract} from './base_contract';
 | 
			
		||||
 | 
			
		||||
export class TokenTransferProxyContract extends BaseContract {
 | 
			
		||||
    public transferFrom = {
 | 
			
		||||
        async sendTransactionAsync(
 | 
			
		||||
            token: string,
 | 
			
		||||
            from: string,
 | 
			
		||||
            to: string,
 | 
			
		||||
            value: BigNumber,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<string> {
 | 
			
		||||
            const self = this as TokenTransferProxyContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
                self.transferFrom.estimateGasAsync.bind(
 | 
			
		||||
                    self,
 | 
			
		||||
                    token,
 | 
			
		||||
                    from,
 | 
			
		||||
                    to,
 | 
			
		||||
                    value,
 | 
			
		||||
                ),
 | 
			
		||||
            );
 | 
			
		||||
            const txHash = await promisify<string>(
 | 
			
		||||
                self.web3ContractInstance.transferFrom, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                token,
 | 
			
		||||
                from,
 | 
			
		||||
                to,
 | 
			
		||||
                value,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return txHash;
 | 
			
		||||
        },
 | 
			
		||||
        async estimateGasAsync(
 | 
			
		||||
            token: string,
 | 
			
		||||
            from: string,
 | 
			
		||||
            to: string,
 | 
			
		||||
            value: BigNumber,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<number> {
 | 
			
		||||
            const self = this as TokenTransferProxyContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
            );
 | 
			
		||||
            const gas = await promisify<number>(
 | 
			
		||||
                self.web3ContractInstance.transferFrom.estimateGas, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                token,
 | 
			
		||||
                from,
 | 
			
		||||
                to,
 | 
			
		||||
                value,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return gas;
 | 
			
		||||
        },
 | 
			
		||||
        getABIEncodedTransactionData(
 | 
			
		||||
            token: string,
 | 
			
		||||
            from: string,
 | 
			
		||||
            to: string,
 | 
			
		||||
            value: BigNumber,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): string {
 | 
			
		||||
            const self = this as TokenTransferProxyContract;
 | 
			
		||||
            const abiEncodedTransactionData = self.web3ContractInstance.transferFrom.getData();
 | 
			
		||||
            return abiEncodedTransactionData;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public addAuthorizedAddress = {
 | 
			
		||||
        async sendTransactionAsync(
 | 
			
		||||
            target: string,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<string> {
 | 
			
		||||
            const self = this as TokenTransferProxyContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
                self.addAuthorizedAddress.estimateGasAsync.bind(
 | 
			
		||||
                    self,
 | 
			
		||||
                    target,
 | 
			
		||||
                ),
 | 
			
		||||
            );
 | 
			
		||||
            const txHash = await promisify<string>(
 | 
			
		||||
                self.web3ContractInstance.addAuthorizedAddress, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                target,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return txHash;
 | 
			
		||||
        },
 | 
			
		||||
        async estimateGasAsync(
 | 
			
		||||
            target: string,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<number> {
 | 
			
		||||
            const self = this as TokenTransferProxyContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
            );
 | 
			
		||||
            const gas = await promisify<number>(
 | 
			
		||||
                self.web3ContractInstance.addAuthorizedAddress.estimateGas, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                target,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return gas;
 | 
			
		||||
        },
 | 
			
		||||
        getABIEncodedTransactionData(
 | 
			
		||||
            target: string,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): string {
 | 
			
		||||
            const self = this as TokenTransferProxyContract;
 | 
			
		||||
            const abiEncodedTransactionData = self.web3ContractInstance.addAuthorizedAddress.getData();
 | 
			
		||||
            return abiEncodedTransactionData;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public authorities = {
 | 
			
		||||
        async callAsync(
 | 
			
		||||
            index: BigNumber,
 | 
			
		||||
            defaultBlock?: Web3.BlockParam,
 | 
			
		||||
        ): Promise<string
 | 
			
		||||
    > {
 | 
			
		||||
            const self = this as TokenTransferProxyContract;
 | 
			
		||||
            const result = await promisify<string
 | 
			
		||||
    >(
 | 
			
		||||
                self.web3ContractInstance.authorities.call,
 | 
			
		||||
                self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                index,
 | 
			
		||||
            );
 | 
			
		||||
            return result;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public removeAuthorizedAddress = {
 | 
			
		||||
        async sendTransactionAsync(
 | 
			
		||||
            target: string,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<string> {
 | 
			
		||||
            const self = this as TokenTransferProxyContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
                self.removeAuthorizedAddress.estimateGasAsync.bind(
 | 
			
		||||
                    self,
 | 
			
		||||
                    target,
 | 
			
		||||
                ),
 | 
			
		||||
            );
 | 
			
		||||
            const txHash = await promisify<string>(
 | 
			
		||||
                self.web3ContractInstance.removeAuthorizedAddress, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                target,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return txHash;
 | 
			
		||||
        },
 | 
			
		||||
        async estimateGasAsync(
 | 
			
		||||
            target: string,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<number> {
 | 
			
		||||
            const self = this as TokenTransferProxyContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
            );
 | 
			
		||||
            const gas = await promisify<number>(
 | 
			
		||||
                self.web3ContractInstance.removeAuthorizedAddress.estimateGas, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                target,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return gas;
 | 
			
		||||
        },
 | 
			
		||||
        getABIEncodedTransactionData(
 | 
			
		||||
            target: string,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): string {
 | 
			
		||||
            const self = this as TokenTransferProxyContract;
 | 
			
		||||
            const abiEncodedTransactionData = self.web3ContractInstance.removeAuthorizedAddress.getData();
 | 
			
		||||
            return abiEncodedTransactionData;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public owner = {
 | 
			
		||||
        async callAsync(
 | 
			
		||||
            defaultBlock?: Web3.BlockParam,
 | 
			
		||||
        ): Promise<string
 | 
			
		||||
    > {
 | 
			
		||||
            const self = this as TokenTransferProxyContract;
 | 
			
		||||
            const result = await promisify<string
 | 
			
		||||
    >(
 | 
			
		||||
                self.web3ContractInstance.owner.call,
 | 
			
		||||
                self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
            );
 | 
			
		||||
            return result;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public authorized = {
 | 
			
		||||
        async callAsync(
 | 
			
		||||
            index: string,
 | 
			
		||||
            defaultBlock?: Web3.BlockParam,
 | 
			
		||||
        ): Promise<boolean
 | 
			
		||||
    > {
 | 
			
		||||
            const self = this as TokenTransferProxyContract;
 | 
			
		||||
            const result = await promisify<boolean
 | 
			
		||||
    >(
 | 
			
		||||
                self.web3ContractInstance.authorized.call,
 | 
			
		||||
                self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                index,
 | 
			
		||||
            );
 | 
			
		||||
            return result;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public getAuthorizedAddresses = {
 | 
			
		||||
        async callAsync(
 | 
			
		||||
            defaultBlock?: Web3.BlockParam,
 | 
			
		||||
        ): Promise<string[]
 | 
			
		||||
    > {
 | 
			
		||||
            const self = this as TokenTransferProxyContract;
 | 
			
		||||
            const result = await promisify<string[]
 | 
			
		||||
    >(
 | 
			
		||||
                self.web3ContractInstance.getAuthorizedAddresses.call,
 | 
			
		||||
                self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
            );
 | 
			
		||||
            return result;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    public transferOwnership = {
 | 
			
		||||
        async sendTransactionAsync(
 | 
			
		||||
            newOwner: string,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<string> {
 | 
			
		||||
            const self = this as TokenTransferProxyContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
                self.transferOwnership.estimateGasAsync.bind(
 | 
			
		||||
                    self,
 | 
			
		||||
                    newOwner,
 | 
			
		||||
                ),
 | 
			
		||||
            );
 | 
			
		||||
            const txHash = await promisify<string>(
 | 
			
		||||
                self.web3ContractInstance.transferOwnership, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                newOwner,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return txHash;
 | 
			
		||||
        },
 | 
			
		||||
        async estimateGasAsync(
 | 
			
		||||
            newOwner: string,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): Promise<number> {
 | 
			
		||||
            const self = this as TokenTransferProxyContract;
 | 
			
		||||
            const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
 | 
			
		||||
                txData,
 | 
			
		||||
            );
 | 
			
		||||
            const gas = await promisify<number>(
 | 
			
		||||
                self.web3ContractInstance.transferOwnership.estimateGas, self.web3ContractInstance,
 | 
			
		||||
            )(
 | 
			
		||||
                newOwner,
 | 
			
		||||
                txDataWithDefaults,
 | 
			
		||||
            );
 | 
			
		||||
            return gas;
 | 
			
		||||
        },
 | 
			
		||||
        getABIEncodedTransactionData(
 | 
			
		||||
            newOwner: string,
 | 
			
		||||
            txData: TxData = {},
 | 
			
		||||
        ): string {
 | 
			
		||||
            const self = this as TokenTransferProxyContract;
 | 
			
		||||
            const abiEncodedTransactionData = self.web3ContractInstance.transferOwnership.getData();
 | 
			
		||||
            return abiEncodedTransactionData;
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
    constructor(web3ContractInstance: Web3.ContractInstance, defaults: Partial<TxData>) {
 | 
			
		||||
        super(web3ContractInstance, defaults);
 | 
			
		||||
        classUtils.bindAll(this, ['web3ContractInstance', 'defaults']);
 | 
			
		||||
    }
 | 
			
		||||
} // tslint:disable:max-file-line-count
 | 
			
		||||
@@ -27,7 +27,6 @@ export {
 | 
			
		||||
    ContractEventArg,
 | 
			
		||||
    Web3Provider,
 | 
			
		||||
    ZeroExConfig,
 | 
			
		||||
    TransactionReceipt,
 | 
			
		||||
    TransactionReceiptWithDecodedLogs,
 | 
			
		||||
    LogWithDecodedArgs,
 | 
			
		||||
    MethodOpts,
 | 
			
		||||
@@ -42,3 +41,7 @@ export {
 | 
			
		||||
    OrderStateInvalid,
 | 
			
		||||
    OrderState,
 | 
			
		||||
} from './types';
 | 
			
		||||
 | 
			
		||||
export {
 | 
			
		||||
    TransactionReceipt,
 | 
			
		||||
} from '@0xproject/types';
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,4 @@
 | 
			
		||||
import {intervalUtils} from '@0xproject/utils';
 | 
			
		||||
import {Web3Wrapper} from '@0xproject/web3-wrapper';
 | 
			
		||||
import * as _ from 'lodash';
 | 
			
		||||
import * as Web3 from 'web3';
 | 
			
		||||
@@ -10,7 +11,6 @@ import {
 | 
			
		||||
} from '../types';
 | 
			
		||||
import {AbiDecoder} from '../utils/abi_decoder';
 | 
			
		||||
import {assert} from '../utils/assert';
 | 
			
		||||
import {intervalUtils} from '../utils/interval_utils';
 | 
			
		||||
import {utils} from '../utils/utils';
 | 
			
		||||
 | 
			
		||||
const DEFAULT_EVENT_POLLING_INTERVAL_MS = 200;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,10 +1,10 @@
 | 
			
		||||
import {intervalUtils} from '@0xproject/utils';
 | 
			
		||||
import {BigNumber} from 'bignumber.js';
 | 
			
		||||
import {RBTree} from 'bintrees';
 | 
			
		||||
import * as _ from 'lodash';
 | 
			
		||||
 | 
			
		||||
import {ZeroEx} from '../0x';
 | 
			
		||||
import {SignedOrder, ZeroExError} from '../types';
 | 
			
		||||
import {intervalUtils} from '../utils/interval_utils';
 | 
			
		||||
import {utils} from '../utils/utils';
 | 
			
		||||
 | 
			
		||||
const DEFAULT_EXPIRATION_MARGIN_MS = 0;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,5 @@
 | 
			
		||||
import {schemas} from '@0xproject/json-schemas';
 | 
			
		||||
import {intervalUtils} from '@0xproject/utils';
 | 
			
		||||
import {Web3Wrapper} from '@0xproject/web3-wrapper';
 | 
			
		||||
import * as _ from 'lodash';
 | 
			
		||||
 | 
			
		||||
@@ -29,7 +30,6 @@ import {
 | 
			
		||||
} from '../types';
 | 
			
		||||
import {AbiDecoder} from '../utils/abi_decoder';
 | 
			
		||||
import {assert} from '../utils/assert';
 | 
			
		||||
import {intervalUtils} from '../utils/interval_utils';
 | 
			
		||||
import {OrderStateUtils} from '../utils/order_state_utils';
 | 
			
		||||
import {utils} from '../utils/utils';
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,4 @@
 | 
			
		||||
import {TransactionReceipt} from '@0xproject/types';
 | 
			
		||||
import BigNumber from 'bignumber.js';
 | 
			
		||||
import * as Web3 from 'web3';
 | 
			
		||||
 | 
			
		||||
@@ -385,28 +386,4 @@ export interface OrderStateInvalid {
 | 
			
		||||
export type OrderState = OrderStateValid|OrderStateInvalid;
 | 
			
		||||
 | 
			
		||||
export type OnOrderStateChangeCallback = (orderState: OrderState) => void;
 | 
			
		||||
 | 
			
		||||
export interface TxData {
 | 
			
		||||
    from?: string;
 | 
			
		||||
    gas?: number;
 | 
			
		||||
    gasPrice?: BigNumber;
 | 
			
		||||
    nonce?: number;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface TxDataPayable extends TxData {
 | 
			
		||||
    value?: BigNumber;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface TransactionReceipt {
 | 
			
		||||
    blockHash: string;
 | 
			
		||||
    blockNumber: number;
 | 
			
		||||
    transactionHash: string;
 | 
			
		||||
    transactionIndex: number;
 | 
			
		||||
    from: string;
 | 
			
		||||
    to: string;
 | 
			
		||||
    status: null|0|1;
 | 
			
		||||
    cumulativeGasUsed: number;
 | 
			
		||||
    gasUsed: number;
 | 
			
		||||
    contractAddress: string|null;
 | 
			
		||||
    logs: Web3.LogEntry[];
 | 
			
		||||
} // tslint:disable:max-file-line-count
 | 
			
		||||
// tslint:disable:max-file-line-count
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,4 @@
 | 
			
		||||
import {BlockchainLifecycle} from '@0xproject/dev-utils';
 | 
			
		||||
import BigNumber from 'bignumber.js';
 | 
			
		||||
import * as chai from 'chai';
 | 
			
		||||
import * as _ from 'lodash';
 | 
			
		||||
@@ -6,13 +7,12 @@ import * as Sinon from 'sinon';
 | 
			
		||||
 | 
			
		||||
import {ApprovalContractEventArgs, LogWithDecodedArgs, Order, TokenEvents, ZeroEx, ZeroExError} from '../src';
 | 
			
		||||
 | 
			
		||||
import {BlockchainLifecycle} from './utils/blockchain_lifecycle';
 | 
			
		||||
import {chaiSetup} from './utils/chai_setup';
 | 
			
		||||
import {constants} from './utils/constants';
 | 
			
		||||
import {TokenUtils} from './utils/token_utils';
 | 
			
		||||
import {web3Factory} from './utils/web3_factory';
 | 
			
		||||
 | 
			
		||||
const blockchainLifecycle = new BlockchainLifecycle();
 | 
			
		||||
const blockchainLifecycle = new BlockchainLifecycle(constants.RPC_URL);
 | 
			
		||||
chaiSetup.configure();
 | 
			
		||||
const expect = chai.expect;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,4 @@
 | 
			
		||||
import {BlockchainLifecycle} from '@0xproject/dev-utils';
 | 
			
		||||
import BigNumber from 'bignumber.js';
 | 
			
		||||
import * as chai from 'chai';
 | 
			
		||||
import 'mocha';
 | 
			
		||||
@@ -5,14 +6,13 @@ import * as Web3 from 'web3';
 | 
			
		||||
 | 
			
		||||
import {ZeroEx, ZeroExError} from '../src';
 | 
			
		||||
 | 
			
		||||
import {BlockchainLifecycle} from './utils/blockchain_lifecycle';
 | 
			
		||||
import {chaiSetup} from './utils/chai_setup';
 | 
			
		||||
import {constants} from './utils/constants';
 | 
			
		||||
import {web3Factory} from './utils/web3_factory';
 | 
			
		||||
 | 
			
		||||
chaiSetup.configure();
 | 
			
		||||
const expect = chai.expect;
 | 
			
		||||
const blockchainLifecycle = new BlockchainLifecycle();
 | 
			
		||||
const blockchainLifecycle = new BlockchainLifecycle(constants.RPC_URL);
 | 
			
		||||
 | 
			
		||||
// Since the address depositing/withdrawing ETH/WETH also needs to pay gas costs for the transaction,
 | 
			
		||||
// a small amount of ETH will be used to pay this gas cost. We therefore check that the difference between
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,4 @@
 | 
			
		||||
import {BlockchainLifecycle} from '@0xproject/dev-utils';
 | 
			
		||||
import BigNumber from 'bignumber.js';
 | 
			
		||||
import * as chai from 'chai';
 | 
			
		||||
 | 
			
		||||
@@ -5,14 +6,13 @@ import {ExchangeContractErrs, Token, ZeroEx} from '../src';
 | 
			
		||||
import {BlockParamLiteral, TradeSide, TransferType} from '../src/types';
 | 
			
		||||
import {ExchangeTransferSimulator} from '../src/utils/exchange_transfer_simulator';
 | 
			
		||||
 | 
			
		||||
import {BlockchainLifecycle} from './utils/blockchain_lifecycle';
 | 
			
		||||
import {chaiSetup} from './utils/chai_setup';
 | 
			
		||||
import {constants} from './utils/constants';
 | 
			
		||||
import {web3Factory} from './utils/web3_factory';
 | 
			
		||||
 | 
			
		||||
chaiSetup.configure();
 | 
			
		||||
const expect = chai.expect;
 | 
			
		||||
const blockchainLifecycle = new BlockchainLifecycle();
 | 
			
		||||
const blockchainLifecycle = new BlockchainLifecycle(constants.RPC_URL);
 | 
			
		||||
 | 
			
		||||
describe('ExchangeTransferSimulator', () => {
 | 
			
		||||
    const web3 = web3Factory.create();
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,4 @@
 | 
			
		||||
import {BlockchainLifecycle} from '@0xproject/dev-utils';
 | 
			
		||||
import BigNumber from 'bignumber.js';
 | 
			
		||||
import * as chai from 'chai';
 | 
			
		||||
import 'mocha';
 | 
			
		||||
@@ -19,7 +20,6 @@ import {
 | 
			
		||||
} from '../src';
 | 
			
		||||
import {BlockParamLiteral, DoneCallback} from '../src/types';
 | 
			
		||||
 | 
			
		||||
import {BlockchainLifecycle} from './utils/blockchain_lifecycle';
 | 
			
		||||
import {chaiSetup} from './utils/chai_setup';
 | 
			
		||||
import {constants} from './utils/constants';
 | 
			
		||||
import {FillScenarios} from './utils/fill_scenarios';
 | 
			
		||||
@@ -28,7 +28,7 @@ import {web3Factory} from './utils/web3_factory';
 | 
			
		||||
 | 
			
		||||
chaiSetup.configure();
 | 
			
		||||
const expect = chai.expect;
 | 
			
		||||
const blockchainLifecycle = new BlockchainLifecycle();
 | 
			
		||||
const blockchainLifecycle = new BlockchainLifecycle(constants.RPC_URL);
 | 
			
		||||
 | 
			
		||||
const NON_EXISTENT_ORDER_HASH = '0x79370342234e7acd6bbeac335bd3bb1d368383294b64b8160a00f4060e4d3777';
 | 
			
		||||
 | 
			
		||||
@@ -53,6 +53,7 @@ describe('ExchangeWrapper', () => {
 | 
			
		||||
        tokenUtils = new TokenUtils(tokens);
 | 
			
		||||
        zrxTokenAddress = tokenUtils.getProtocolTokenOrThrow().address;
 | 
			
		||||
        fillScenarios = new FillScenarios(zeroEx, userAddresses, tokens, zrxTokenAddress, exchangeContractAddress);
 | 
			
		||||
        await fillScenarios.initTokenBalancesAsync();
 | 
			
		||||
    });
 | 
			
		||||
    beforeEach(async () => {
 | 
			
		||||
        await blockchainLifecycle.startAsync();
 | 
			
		||||
@@ -71,7 +72,7 @@ describe('ExchangeWrapper', () => {
 | 
			
		||||
        before(async () => {
 | 
			
		||||
            [coinbase, makerAddress, takerAddress, feeRecipient] = userAddresses;
 | 
			
		||||
            tokens = await zeroEx.tokenRegistry.getTokensAsync();
 | 
			
		||||
            const [makerToken, takerToken] = tokenUtils.getNonProtocolTokens();
 | 
			
		||||
            const [makerToken, takerToken] = tokenUtils.getDummyTokens();
 | 
			
		||||
            makerTokenAddress = makerToken.address;
 | 
			
		||||
            takerTokenAddress = takerToken.address;
 | 
			
		||||
        });
 | 
			
		||||
@@ -201,7 +202,7 @@ describe('ExchangeWrapper', () => {
 | 
			
		||||
        before(async () => {
 | 
			
		||||
            [coinbase, makerAddress, takerAddress, feeRecipient] = userAddresses;
 | 
			
		||||
            tokens = await zeroEx.tokenRegistry.getTokensAsync();
 | 
			
		||||
            const [makerToken, takerToken] = tokenUtils.getNonProtocolTokens();
 | 
			
		||||
            const [makerToken, takerToken] = tokenUtils.getDummyTokens();
 | 
			
		||||
            makerTokenAddress = makerToken.address;
 | 
			
		||||
            takerTokenAddress = takerToken.address;
 | 
			
		||||
        });
 | 
			
		||||
@@ -436,7 +437,7 @@ describe('ExchangeWrapper', () => {
 | 
			
		||||
        const cancelAmount = new BigNumber(3);
 | 
			
		||||
        beforeEach(async () => {
 | 
			
		||||
            [coinbase, makerAddress, takerAddress] = userAddresses;
 | 
			
		||||
            const [makerToken, takerToken] = tokenUtils.getNonProtocolTokens();
 | 
			
		||||
            const [makerToken, takerToken] = tokenUtils.getDummyTokens();
 | 
			
		||||
            makerTokenAddress = makerToken.address;
 | 
			
		||||
            takerTokenAddress = takerToken.address;
 | 
			
		||||
            signedOrder = await fillScenarios.createFillableSignedOrderAsync(
 | 
			
		||||
@@ -557,7 +558,8 @@ describe('ExchangeWrapper', () => {
 | 
			
		||||
        let orderHash: string;
 | 
			
		||||
        before(() => {
 | 
			
		||||
            takerAddress = userAddresses[1];
 | 
			
		||||
            const [makerToken, takerToken] = tokens;
 | 
			
		||||
            tokenUtils = new TokenUtils(tokens);
 | 
			
		||||
            const [makerToken, takerToken] = tokenUtils.getDummyTokens();
 | 
			
		||||
            makerTokenAddress = makerToken.address;
 | 
			
		||||
            takerTokenAddress = takerToken.address;
 | 
			
		||||
        });
 | 
			
		||||
@@ -633,7 +635,7 @@ describe('ExchangeWrapper', () => {
 | 
			
		||||
        const cancelTakerAmountInBaseUnits = new BigNumber(1);
 | 
			
		||||
        before(() => {
 | 
			
		||||
            [coinbase, makerAddress, takerAddress] = userAddresses;
 | 
			
		||||
            const [makerToken, takerToken] = tokens;
 | 
			
		||||
            const [makerToken, takerToken] = tokenUtils.getDummyTokens();
 | 
			
		||||
            makerTokenAddress = makerToken.address;
 | 
			
		||||
            takerTokenAddress = takerToken.address;
 | 
			
		||||
        });
 | 
			
		||||
@@ -731,7 +733,7 @@ describe('ExchangeWrapper', () => {
 | 
			
		||||
        const fillableAmount = new BigNumber(5);
 | 
			
		||||
        before(async () => {
 | 
			
		||||
            [, makerAddress, takerAddress] = userAddresses;
 | 
			
		||||
            const [makerToken, takerToken] = tokenUtils.getNonProtocolTokens();
 | 
			
		||||
            const [makerToken, takerToken] = tokenUtils.getDummyTokens();
 | 
			
		||||
            makerTokenAddress = makerToken.address;
 | 
			
		||||
            takerTokenAddress = takerToken.address;
 | 
			
		||||
        });
 | 
			
		||||
@@ -766,7 +768,7 @@ describe('ExchangeWrapper', () => {
 | 
			
		||||
        let txHash: string;
 | 
			
		||||
        before(async () => {
 | 
			
		||||
            [, makerAddress, takerAddress] = userAddresses;
 | 
			
		||||
            const [makerToken, takerToken] = tokenUtils.getNonProtocolTokens();
 | 
			
		||||
            const [makerToken, takerToken] = tokenUtils.getDummyTokens();
 | 
			
		||||
            makerTokenAddress = makerToken.address;
 | 
			
		||||
            takerTokenAddress = takerToken.address;
 | 
			
		||||
        });
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,4 @@
 | 
			
		||||
import {BlockchainLifecycle} from '@0xproject/dev-utils';
 | 
			
		||||
import {Web3Wrapper} from '@0xproject/web3-wrapper';
 | 
			
		||||
import BigNumber from 'bignumber.js';
 | 
			
		||||
import * as chai from 'chai';
 | 
			
		||||
@@ -12,8 +13,8 @@ import {DoneCallback, Token} from '../src/types';
 | 
			
		||||
import {constants} from '../src/utils/constants';
 | 
			
		||||
import {utils} from '../src/utils/utils';
 | 
			
		||||
 | 
			
		||||
import {BlockchainLifecycle} from './utils/blockchain_lifecycle';
 | 
			
		||||
import {chaiSetup} from './utils/chai_setup';
 | 
			
		||||
import {constants as testConstants} from './utils/constants';
 | 
			
		||||
import {FillScenarios} from './utils/fill_scenarios';
 | 
			
		||||
import {reportCallbackErrors} from './utils/report_callback_errors';
 | 
			
		||||
import {TokenUtils} from './utils/token_utils';
 | 
			
		||||
@@ -21,7 +22,7 @@ import {web3Factory} from './utils/web3_factory';
 | 
			
		||||
 | 
			
		||||
chaiSetup.configure();
 | 
			
		||||
const expect = chai.expect;
 | 
			
		||||
const blockchainLifecycle = new BlockchainLifecycle();
 | 
			
		||||
const blockchainLifecycle = new BlockchainLifecycle(testConstants.RPC_URL);
 | 
			
		||||
 | 
			
		||||
describe('ExpirationWatcher', () => {
 | 
			
		||||
    let web3: Web3;
 | 
			
		||||
@@ -56,7 +57,7 @@ describe('ExpirationWatcher', () => {
 | 
			
		||||
        fillScenarios = new FillScenarios(zeroEx, userAddresses, tokens, zrxTokenAddress, exchangeContractAddress);
 | 
			
		||||
        [coinbase, makerAddress, takerAddress, feeRecipient] = userAddresses;
 | 
			
		||||
        tokens = await zeroEx.tokenRegistry.getTokensAsync();
 | 
			
		||||
        const [makerToken, takerToken] = tokenUtils.getNonProtocolTokens();
 | 
			
		||||
        const [makerToken, takerToken] = tokenUtils.getDummyTokens();
 | 
			
		||||
        makerTokenAddress = makerToken.address;
 | 
			
		||||
        takerTokenAddress = takerToken.address;
 | 
			
		||||
    });
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,4 @@
 | 
			
		||||
import {BlockchainLifecycle} from '@0xproject/dev-utils';
 | 
			
		||||
import {Web3Wrapper} from '@0xproject/web3-wrapper';
 | 
			
		||||
import BigNumber from 'bignumber.js';
 | 
			
		||||
import * as chai from 'chai';
 | 
			
		||||
@@ -21,7 +22,6 @@ import {
 | 
			
		||||
import {OrderStateWatcher} from '../src/order_watcher/order_state_watcher';
 | 
			
		||||
import {DoneCallback} from '../src/types';
 | 
			
		||||
 | 
			
		||||
import {BlockchainLifecycle} from './utils/blockchain_lifecycle';
 | 
			
		||||
import {chaiSetup} from './utils/chai_setup';
 | 
			
		||||
import {constants} from './utils/constants';
 | 
			
		||||
import {FillScenarios} from './utils/fill_scenarios';
 | 
			
		||||
@@ -33,7 +33,7 @@ const TIMEOUT_MS = 150;
 | 
			
		||||
 | 
			
		||||
chaiSetup.configure();
 | 
			
		||||
const expect = chai.expect;
 | 
			
		||||
const blockchainLifecycle = new BlockchainLifecycle();
 | 
			
		||||
const blockchainLifecycle = new BlockchainLifecycle(constants.RPC_URL);
 | 
			
		||||
 | 
			
		||||
describe('OrderStateWatcher', () => {
 | 
			
		||||
    let web3: Web3;
 | 
			
		||||
@@ -65,7 +65,8 @@ describe('OrderStateWatcher', () => {
 | 
			
		||||
        tokenUtils = new TokenUtils(tokens);
 | 
			
		||||
        zrxTokenAddress = tokenUtils.getProtocolTokenOrThrow().address;
 | 
			
		||||
        fillScenarios = new FillScenarios(zeroEx, userAddresses, tokens, zrxTokenAddress, exchangeContractAddress);
 | 
			
		||||
        [makerToken, takerToken] = tokenUtils.getNonProtocolTokens();
 | 
			
		||||
        await fillScenarios.initTokenBalancesAsync();
 | 
			
		||||
        [makerToken, takerToken] = tokenUtils.getDummyTokens();
 | 
			
		||||
        web3Wrapper = (zeroEx as any)._web3Wrapper;
 | 
			
		||||
    });
 | 
			
		||||
    beforeEach(async () => {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,4 @@
 | 
			
		||||
import {BlockchainLifecycle} from '@0xproject/dev-utils';
 | 
			
		||||
import BigNumber from 'bignumber.js';
 | 
			
		||||
import * as chai from 'chai';
 | 
			
		||||
import * as Sinon from 'sinon';
 | 
			
		||||
@@ -8,7 +9,6 @@ import {BlockParamLiteral, TradeSide, TransferType} from '../src/types';
 | 
			
		||||
import {ExchangeTransferSimulator} from '../src/utils/exchange_transfer_simulator';
 | 
			
		||||
import {OrderValidationUtils} from '../src/utils/order_validation_utils';
 | 
			
		||||
 | 
			
		||||
import {BlockchainLifecycle} from './utils/blockchain_lifecycle';
 | 
			
		||||
import {chaiSetup} from './utils/chai_setup';
 | 
			
		||||
import {constants} from './utils/constants';
 | 
			
		||||
import {FillScenarios} from './utils/fill_scenarios';
 | 
			
		||||
@@ -17,7 +17,7 @@ import {web3Factory} from './utils/web3_factory';
 | 
			
		||||
 | 
			
		||||
chaiSetup.configure();
 | 
			
		||||
const expect = chai.expect;
 | 
			
		||||
const blockchainLifecycle = new BlockchainLifecycle();
 | 
			
		||||
const blockchainLifecycle = new BlockchainLifecycle(constants.RPC_URL);
 | 
			
		||||
 | 
			
		||||
describe('OrderValidation', () => {
 | 
			
		||||
    let web3: Web3;
 | 
			
		||||
@@ -50,7 +50,7 @@ describe('OrderValidation', () => {
 | 
			
		||||
        tokenUtils = new TokenUtils(tokens);
 | 
			
		||||
        zrxTokenAddress = tokenUtils.getProtocolTokenOrThrow().address;
 | 
			
		||||
        fillScenarios = new FillScenarios(zeroEx, userAddresses, tokens, zrxTokenAddress, exchangeContractAddress);
 | 
			
		||||
        const [makerToken, takerToken] = tokenUtils.getNonProtocolTokens();
 | 
			
		||||
        const [makerToken, takerToken] = tokenUtils.getDummyTokens();
 | 
			
		||||
        makerTokenAddress = makerToken.address;
 | 
			
		||||
        takerTokenAddress = takerToken.address;
 | 
			
		||||
        orderValidationUtils = new OrderValidationUtils(zeroEx.token, zeroEx.exchange);
 | 
			
		||||
@@ -185,7 +185,7 @@ describe('OrderValidation', () => {
 | 
			
		||||
        const cancelAmount = new BigNumber(3);
 | 
			
		||||
        beforeEach(async () => {
 | 
			
		||||
            [coinbase, makerAddress, takerAddress] = userAddresses;
 | 
			
		||||
            const [makerToken, takerToken] = tokenUtils.getNonProtocolTokens();
 | 
			
		||||
            const [makerToken, takerToken] = tokenUtils.getDummyTokens();
 | 
			
		||||
            makerTokenAddress = makerToken.address;
 | 
			
		||||
            takerTokenAddress = takerToken.address;
 | 
			
		||||
            signedOrder = await fillScenarios.createFillableSignedOrderAsync(
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,4 @@
 | 
			
		||||
import {BlockchainLifecycle} from '@0xproject/dev-utils';
 | 
			
		||||
import BigNumber from 'bignumber.js';
 | 
			
		||||
import * as chai from 'chai';
 | 
			
		||||
import * as _ from 'lodash';
 | 
			
		||||
@@ -15,7 +16,6 @@ import {
 | 
			
		||||
} from '../src';
 | 
			
		||||
import {BlockParamLiteral, DoneCallback} from '../src/types';
 | 
			
		||||
 | 
			
		||||
import {BlockchainLifecycle} from './utils/blockchain_lifecycle';
 | 
			
		||||
import {chaiSetup} from './utils/chai_setup';
 | 
			
		||||
import {constants} from './utils/constants';
 | 
			
		||||
import {reportCallbackErrors} from './utils/report_callback_errors';
 | 
			
		||||
@@ -24,7 +24,7 @@ import {web3Factory} from './utils/web3_factory';
 | 
			
		||||
 | 
			
		||||
chaiSetup.configure();
 | 
			
		||||
const expect = chai.expect;
 | 
			
		||||
const blockchainLifecycle = new BlockchainLifecycle();
 | 
			
		||||
const blockchainLifecycle = new BlockchainLifecycle(constants.RPC_URL);
 | 
			
		||||
 | 
			
		||||
describe('SubscriptionTest', () => {
 | 
			
		||||
    let web3: Web3;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,4 @@
 | 
			
		||||
import {BlockchainLifecycle} from '@0xproject/dev-utils';
 | 
			
		||||
import {schemas, SchemaValidator} from '@0xproject/json-schemas';
 | 
			
		||||
import * as chai from 'chai';
 | 
			
		||||
import * as _ from 'lodash';
 | 
			
		||||
@@ -5,14 +6,13 @@ import 'mocha';
 | 
			
		||||
 | 
			
		||||
import {Token, ZeroEx} from '../src';
 | 
			
		||||
 | 
			
		||||
import {BlockchainLifecycle} from './utils/blockchain_lifecycle';
 | 
			
		||||
import {chaiSetup} from './utils/chai_setup';
 | 
			
		||||
import {constants} from './utils/constants';
 | 
			
		||||
import {web3Factory} from './utils/web3_factory';
 | 
			
		||||
 | 
			
		||||
chaiSetup.configure();
 | 
			
		||||
const expect = chai.expect;
 | 
			
		||||
const blockchainLifecycle = new BlockchainLifecycle();
 | 
			
		||||
const blockchainLifecycle = new BlockchainLifecycle(constants.RPC_URL);
 | 
			
		||||
 | 
			
		||||
const TOKEN_REGISTRY_SIZE_AFTER_MIGRATION = 7;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,4 @@
 | 
			
		||||
import {BlockchainLifecycle} from '@0xproject/dev-utils';
 | 
			
		||||
import {promisify} from '@0xproject/utils';
 | 
			
		||||
import {Web3Wrapper} from '@0xproject/web3-wrapper';
 | 
			
		||||
import BigNumber from 'bignumber.js';
 | 
			
		||||
@@ -21,7 +22,6 @@ import {
 | 
			
		||||
} from '../src';
 | 
			
		||||
import {BlockParamLiteral, DoneCallback} from '../src/types';
 | 
			
		||||
 | 
			
		||||
import {BlockchainLifecycle} from './utils/blockchain_lifecycle';
 | 
			
		||||
import {chaiSetup} from './utils/chai_setup';
 | 
			
		||||
import {constants} from './utils/constants';
 | 
			
		||||
import {TokenUtils} from './utils/token_utils';
 | 
			
		||||
@@ -29,7 +29,7 @@ import {web3Factory} from './utils/web3_factory';
 | 
			
		||||
 | 
			
		||||
chaiSetup.configure();
 | 
			
		||||
const expect = chai.expect;
 | 
			
		||||
const blockchainLifecycle = new BlockchainLifecycle();
 | 
			
		||||
const blockchainLifecycle = new BlockchainLifecycle(constants.RPC_URL);
 | 
			
		||||
 | 
			
		||||
describe('TokenWrapper', () => {
 | 
			
		||||
    let web3: Web3;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,6 @@
 | 
			
		||||
export const constants = {
 | 
			
		||||
    NULL_ADDRESS: '0x0000000000000000000000000000000000000000',
 | 
			
		||||
    RPC_HOST: 'localhost',
 | 
			
		||||
    RPC_PORT: 8545,
 | 
			
		||||
    RPC_URL: 'http://localhost:8545',
 | 
			
		||||
    ROPSTEN_NETWORK_ID: 3,
 | 
			
		||||
    KOVAN_NETWORK_ID: 42,
 | 
			
		||||
    TESTRPC_NETWORK_ID: 50,
 | 
			
		||||
 
 | 
			
		||||
@@ -1,10 +1,15 @@
 | 
			
		||||
import {Web3Wrapper} from '@0xproject/web3-wrapper';
 | 
			
		||||
import BigNumber from 'bignumber.js';
 | 
			
		||||
 | 
			
		||||
import {SignedOrder, Token, ZeroEx} from '../../src';
 | 
			
		||||
import {artifacts} from '../../src/artifacts';
 | 
			
		||||
import {DummyTokenContract} from '../../src/contract_wrappers/generated/dummy_token';
 | 
			
		||||
import {orderFactory} from '../utils/order_factory';
 | 
			
		||||
 | 
			
		||||
import {constants} from './constants';
 | 
			
		||||
 | 
			
		||||
const INITIAL_COINBASE_TOKEN_SUPPLY_IN_UNITS = new BigNumber(100);
 | 
			
		||||
 | 
			
		||||
export class FillScenarios {
 | 
			
		||||
    private zeroEx: ZeroEx;
 | 
			
		||||
    private userAddresses: string[];
 | 
			
		||||
@@ -21,6 +26,23 @@ export class FillScenarios {
 | 
			
		||||
        this.zrxTokenAddress = zrxTokenAddress;
 | 
			
		||||
        this.exchangeContractAddress = exchangeContractAddress;
 | 
			
		||||
    }
 | 
			
		||||
    public async initTokenBalancesAsync() {
 | 
			
		||||
        const web3Wrapper = (this.zeroEx as any)._web3Wrapper as Web3Wrapper;
 | 
			
		||||
        for (const token of this.tokens) {
 | 
			
		||||
            if (token.symbol !== 'ZRX' && token.symbol !== 'WETH') {
 | 
			
		||||
                const contractInstance = web3Wrapper.getContractInstance(
 | 
			
		||||
                    artifacts.DummyTokenArtifact.abi, token.address,
 | 
			
		||||
                );
 | 
			
		||||
                const defaults = {};
 | 
			
		||||
                const dummyToken = new DummyTokenContract(contractInstance, defaults);
 | 
			
		||||
                const tokenSupply = ZeroEx.toBaseUnitAmount(INITIAL_COINBASE_TOKEN_SUPPLY_IN_UNITS, token.decimals);
 | 
			
		||||
                const txHash = await dummyToken.setBalance.sendTransactionAsync(this.coinbase, tokenSupply, {
 | 
			
		||||
                    from: this.coinbase,
 | 
			
		||||
                });
 | 
			
		||||
                await this.zeroEx.awaitTransactionMinedAsync(txHash);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    public async createFillableSignedOrderAsync(makerTokenAddress: string, takerTokenAddress: string,
 | 
			
		||||
                                                makerAddress: string, takerAddress: string,
 | 
			
		||||
                                                fillableAmount: BigNumber,
 | 
			
		||||
 
 | 
			
		||||
@@ -3,6 +3,7 @@ import * as _ from 'lodash';
 | 
			
		||||
import {InternalZeroExError, Token} from '../../src/types';
 | 
			
		||||
 | 
			
		||||
const PROTOCOL_TOKEN_SYMBOL = 'ZRX';
 | 
			
		||||
const WETH_TOKEN_SYMBOL = 'WETH';
 | 
			
		||||
 | 
			
		||||
export class TokenUtils {
 | 
			
		||||
    private tokens: Token[];
 | 
			
		||||
@@ -16,10 +17,10 @@ export class TokenUtils {
 | 
			
		||||
        }
 | 
			
		||||
        return zrxToken;
 | 
			
		||||
    }
 | 
			
		||||
    public getNonProtocolTokens(): Token[] {
 | 
			
		||||
        const nonProtocolTokens = _.filter(this.tokens, token => {
 | 
			
		||||
            return token.symbol !== PROTOCOL_TOKEN_SYMBOL;
 | 
			
		||||
    public getDummyTokens(): Token[] {
 | 
			
		||||
        const dummyTokens = _.filter(this.tokens, token => {
 | 
			
		||||
            return !_.includes([PROTOCOL_TOKEN_SYMBOL, WETH_TOKEN_SYMBOL], token.symbol);
 | 
			
		||||
        });
 | 
			
		||||
        return nonProtocolTokens;
 | 
			
		||||
        return dummyTokens;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -21,13 +21,12 @@ export const web3Factory = {
 | 
			
		||||
    },
 | 
			
		||||
    getRpcProvider(hasAddresses: boolean = true): Web3.Provider {
 | 
			
		||||
        const provider = new ProviderEngine();
 | 
			
		||||
        const rpcUrl = `http://${constants.RPC_HOST}:${constants.RPC_PORT}`;
 | 
			
		||||
        if (!hasAddresses) {
 | 
			
		||||
            provider.addProvider(new EmptyWalletSubprovider());
 | 
			
		||||
        }
 | 
			
		||||
        provider.addProvider(new FakeGasEstimateSubprovider(constants.GAS_ESTIMATE));
 | 
			
		||||
        provider.addProvider(new RpcSubprovider({
 | 
			
		||||
            rpcUrl,
 | 
			
		||||
            rpcUrl: constants.RPC_URL,
 | 
			
		||||
        }));
 | 
			
		||||
        provider.start();
 | 
			
		||||
        return provider;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,15 +0,0 @@
 | 
			
		||||
{
 | 
			
		||||
  "name": "abi-gen-templates",
 | 
			
		||||
  "private": true,
 | 
			
		||||
  "version": "0.0.2",
 | 
			
		||||
  "description": "Handlebars templates to generate TS contract wrappers",
 | 
			
		||||
  "repository": {
 | 
			
		||||
    "type": "git",
 | 
			
		||||
    "url": "https://github.com/0xProject/0x.js.git"
 | 
			
		||||
  },
 | 
			
		||||
  "license": "Apache-2.0",
 | 
			
		||||
  "bugs": {
 | 
			
		||||
    "url": "https://github.com/0xProject/0x.js/issues"
 | 
			
		||||
  },
 | 
			
		||||
  "homepage": "https://github.com/0xProject/0x.js/packages/abi-gen-templates/README.md"
 | 
			
		||||
}
 | 
			
		||||
@@ -5,7 +5,7 @@ It's heavily inspired by [Geth abigen](https://github.com/ethereum/go-ethereum/w
 | 
			
		||||
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.
 | 
			
		||||
[Here](https://github.com/0xProject/0x.js/tree/development/packages/abi-gen-templates) are the templates used to generate those files.
 | 
			
		||||
[Here](https://github.com/0xProject/0x.js/tree/development/packages/0x.js/src/contract_templates) are the templates used to generate those files.
 | 
			
		||||
 | 
			
		||||
## Instalation
 | 
			
		||||
`yarn add -g @0xproject/abi-gen`
 | 
			
		||||
@@ -29,7 +29,7 @@ We could've just used `--abiGlob 'src/artifacts/*.json` but we wanted to exclude
 | 
			
		||||
 | 
			
		||||
The abi file should be either a [Truffle](http://truffleframework.com/) contract artifact (a JSON object with an abi key) or a JSON abi array.
 | 
			
		||||
## 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/abi-gen-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.js/tree/development/packages/0x.js/src/contract_templates) and start adjusting them for your needs.
 | 
			
		||||
We use [handlebars](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.
 | 
			
		||||
## Which data/context do I get in my templates?
 | 
			
		||||
 
 | 
			
		||||
@@ -11,49 +11,34 @@ import {tokenInfo} from './config/token_info';
 | 
			
		||||
export const migrator = {
 | 
			
		||||
    /**
 | 
			
		||||
     * Custom migrations should be defined in this function. This will be called with the CLI 'migrate' command.
 | 
			
		||||
     * Some operations might be completed in parallel, but we don't do that on purpose.
 | 
			
		||||
     * That way the addresses are deterministic.
 | 
			
		||||
     * @param deployer Deployer instance.
 | 
			
		||||
     */
 | 
			
		||||
    async runMigrationsAsync(deployer: Deployer): Promise<void> {
 | 
			
		||||
        const web3Wrapper: Web3Wrapper = deployer.web3Wrapper;
 | 
			
		||||
        const accounts: string[] = await web3Wrapper.getAvailableAddressesAsync();
 | 
			
		||||
 | 
			
		||||
        const independentContracts: Web3.ContractInstance[] = await Promise.all([
 | 
			
		||||
            deployer.deployAndSaveAsync('TokenTransferProxy'),
 | 
			
		||||
            deployer.deployAndSaveAsync('ZRXToken'),
 | 
			
		||||
            deployer.deployAndSaveAsync('EtherToken'),
 | 
			
		||||
            deployer.deployAndSaveAsync('TokenRegistry'),
 | 
			
		||||
        ]);
 | 
			
		||||
        const [tokenTransferProxy, zrxToken, etherToken, tokenReg] = independentContracts;
 | 
			
		||||
        const tokenTransferProxy = await deployer.deployAndSaveAsync('TokenTransferProxy');
 | 
			
		||||
        const zrxToken = await deployer.deployAndSaveAsync('ZRXToken');
 | 
			
		||||
        const etherToken = await deployer.deployAndSaveAsync('EtherToken');
 | 
			
		||||
        const tokenReg = await deployer.deployAndSaveAsync('TokenRegistry');
 | 
			
		||||
 | 
			
		||||
        const exchangeArgs = [zrxToken.address, tokenTransferProxy.address];
 | 
			
		||||
        const owners = [accounts[0], accounts[1]];
 | 
			
		||||
        const confirmationsRequired = new BigNumber(2);
 | 
			
		||||
        const secondsRequired = new BigNumber(0);
 | 
			
		||||
        const multiSigArgs = [owners, confirmationsRequired, secondsRequired, tokenTransferProxy.address];
 | 
			
		||||
        const dependentContracts: Web3.ContractInstance[] = await Promise.all([
 | 
			
		||||
            deployer.deployAndSaveAsync('Exchange', exchangeArgs),
 | 
			
		||||
            deployer.deployAndSaveAsync('MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress', multiSigArgs),
 | 
			
		||||
        ]);
 | 
			
		||||
        const [exchange, multiSig] = dependentContracts;
 | 
			
		||||
        const exchange = await deployer.deployAndSaveAsync('Exchange', exchangeArgs);
 | 
			
		||||
        const multiSig = await deployer.deployAndSaveAsync(
 | 
			
		||||
            'MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress', multiSigArgs,
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        const owner = accounts[0];
 | 
			
		||||
        await tokenTransferProxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, {from: owner});
 | 
			
		||||
        await tokenTransferProxy.transferOwnership.sendTransactionAsync(multiSig.address, {from: owner});
 | 
			
		||||
 | 
			
		||||
        const tokensToRegister: Web3.ContractInstance[] = await Promise.all(
 | 
			
		||||
            _.map(tokenInfo, async (token: Token): Promise<Web3.ContractInstance> => {
 | 
			
		||||
                const totalSupply = new BigNumber(0);
 | 
			
		||||
                const args = [
 | 
			
		||||
                    token.name,
 | 
			
		||||
                    token.symbol,
 | 
			
		||||
                    token.decimals,
 | 
			
		||||
                    totalSupply,
 | 
			
		||||
                ];
 | 
			
		||||
                return deployer.deployAsync('DummyToken', args);
 | 
			
		||||
            }),
 | 
			
		||||
        );
 | 
			
		||||
        const addTokenGasEstimate = await tokenReg.addToken.estimateGasAsync(
 | 
			
		||||
            tokensToRegister[0].address,
 | 
			
		||||
            zrxToken.address,
 | 
			
		||||
            tokenInfo[0].name,
 | 
			
		||||
            tokenInfo[0].symbol,
 | 
			
		||||
            tokenInfo[0].decimals,
 | 
			
		||||
@@ -61,8 +46,7 @@ export const migrator = {
 | 
			
		||||
            tokenInfo[0].swarmHash,
 | 
			
		||||
            {from: owner},
 | 
			
		||||
        );
 | 
			
		||||
        const addTokenPromises = [
 | 
			
		||||
            tokenReg.addToken.sendTransactionAsync(
 | 
			
		||||
        await tokenReg.addToken.sendTransactionAsync(
 | 
			
		||||
            zrxToken.address,
 | 
			
		||||
            '0x Protocol Token',
 | 
			
		||||
            'ZRX',
 | 
			
		||||
@@ -73,8 +57,8 @@ export const migrator = {
 | 
			
		||||
                from: owner,
 | 
			
		||||
                gas: addTokenGasEstimate,
 | 
			
		||||
            },
 | 
			
		||||
            ),
 | 
			
		||||
            tokenReg.addToken.sendTransactionAsync(
 | 
			
		||||
        );
 | 
			
		||||
        await tokenReg.addToken.sendTransactionAsync(
 | 
			
		||||
            etherToken.address,
 | 
			
		||||
            'Ether Token',
 | 
			
		||||
            'WETH',
 | 
			
		||||
@@ -85,11 +69,18 @@ export const migrator = {
 | 
			
		||||
                from: owner,
 | 
			
		||||
                gas: addTokenGasEstimate,
 | 
			
		||||
            },
 | 
			
		||||
            ),
 | 
			
		||||
        );
 | 
			
		||||
        for (const token of tokenInfo) {
 | 
			
		||||
            const totalSupply = new BigNumber(0);
 | 
			
		||||
            const args = [
 | 
			
		||||
                token.name,
 | 
			
		||||
                token.symbol,
 | 
			
		||||
                token.decimals,
 | 
			
		||||
                totalSupply,
 | 
			
		||||
            ];
 | 
			
		||||
        const addDummyTokenPromises = _.map(tokenInfo, async (token: Token, i: number): Promise<void> => {
 | 
			
		||||
            return tokenReg.addToken.sendTransactionAsync(
 | 
			
		||||
                tokensToRegister[i].address,
 | 
			
		||||
            const dummyToken = await deployer.deployAsync('DummyToken', args);
 | 
			
		||||
            await tokenReg.addToken.sendTransactionAsync(
 | 
			
		||||
                dummyToken.address,
 | 
			
		||||
                token.name,
 | 
			
		||||
                token.symbol,
 | 
			
		||||
                token.decimals,
 | 
			
		||||
@@ -100,7 +91,6 @@ export const migrator = {
 | 
			
		||||
                    gas: addTokenGasEstimate,
 | 
			
		||||
                },
 | 
			
		||||
            );
 | 
			
		||||
        });
 | 
			
		||||
        await Promise.all([...addDummyTokenPromises, ...addTokenPromises]);
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -29,6 +29,7 @@
 | 
			
		||||
  },
 | 
			
		||||
  "homepage": "https://github.com/0xProject/0x.js/packages/contracts/README.md",
 | 
			
		||||
  "devDependencies": {
 | 
			
		||||
    "@0xproject/dev-utils": "^0.0.1",
 | 
			
		||||
    "@0xproject/tslint-config": "^0.2.1",
 | 
			
		||||
    "@0xproject/types": "^0.1.0",
 | 
			
		||||
    "@types/bluebird": "^3.5.3",
 | 
			
		||||
@@ -54,7 +55,7 @@
 | 
			
		||||
    "yargs": "^10.0.3"
 | 
			
		||||
  },
 | 
			
		||||
  "dependencies": {
 | 
			
		||||
    "0x.js": "^0.27.1",
 | 
			
		||||
    "0x.js": "~0.27.2",
 | 
			
		||||
    "@0xproject/json-schemas": "^0.6.10",
 | 
			
		||||
    "@0xproject/utils": "^0.1.0",
 | 
			
		||||
    "@0xproject/web3-wrapper": "^0.1.0",
 | 
			
		||||
 
 | 
			
		||||
@@ -1,13 +1,14 @@
 | 
			
		||||
import {RPC} from '@0xproject/dev-utils';
 | 
			
		||||
import {promisify} from '@0xproject/utils';
 | 
			
		||||
import {BigNumber} from 'bignumber.js';
 | 
			
		||||
import * as chai from 'chai';
 | 
			
		||||
import Web3 = require('web3');
 | 
			
		||||
 | 
			
		||||
import * as multiSigWalletJSON from '../../build/contracts/MultiSigWalletWithTimeLock.json';
 | 
			
		||||
import * as truffleConf from '../../truffle.js';
 | 
			
		||||
import {Artifacts} from '../../util/artifacts';
 | 
			
		||||
import {constants} from '../../util/constants';
 | 
			
		||||
import {MultiSigWrapper} from '../../util/multi_sig_wrapper';
 | 
			
		||||
import {RPC} from '../../util/rpc';
 | 
			
		||||
import {ContractInstance} from '../../util/types';
 | 
			
		||||
 | 
			
		||||
import {chaiSetup} from './utils/chai_setup';
 | 
			
		||||
@@ -38,7 +39,8 @@ contract('MultiSigWalletWithTimeLock', (accounts: string[]) => {
 | 
			
		||||
 | 
			
		||||
        const secondsTimeLocked = await multiSig.secondsTimeLocked.call();
 | 
			
		||||
        initialSecondsTimeLocked = secondsTimeLocked.toNumber();
 | 
			
		||||
        rpc = new RPC();
 | 
			
		||||
        const rpcUrl = `http://${truffleConf.networks.development.host}:${truffleConf.networks.development.port}`;
 | 
			
		||||
        rpc = new RPC(rpcUrl);
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    describe('changeTimeLock', () => {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
import {bigNumberConfigs} from '@0xproject/utils';
 | 
			
		||||
import {BigNumber} from 'bignumber.js';
 | 
			
		||||
import * as _ from 'lodash';
 | 
			
		||||
 | 
			
		||||
import {bigNumberConfigs} from './bignumber_config';
 | 
			
		||||
import {BalancesByOwner, ContractInstance} from './types';
 | 
			
		||||
 | 
			
		||||
bigNumberConfigs.configure();
 | 
			
		||||
 
 | 
			
		||||
@@ -1,11 +0,0 @@
 | 
			
		||||
import {BigNumber} from 'bignumber.js';
 | 
			
		||||
 | 
			
		||||
export const bigNumberConfigs = {
 | 
			
		||||
    configure() {
 | 
			
		||||
        // By default BigNumber's `toString` method converts to exponential notation if the value has
 | 
			
		||||
        // more then 20 digits. We want to avoid this behavior, so we set EXPONENTIAL_AT to a high number
 | 
			
		||||
        BigNumber.config({
 | 
			
		||||
            EXPONENTIAL_AT: 1000,
 | 
			
		||||
        });
 | 
			
		||||
    },
 | 
			
		||||
};
 | 
			
		||||
@@ -1,43 +0,0 @@
 | 
			
		||||
import 'isomorphic-fetch';
 | 
			
		||||
 | 
			
		||||
import * as truffleConf from '../truffle.js';
 | 
			
		||||
 | 
			
		||||
export class RPC {
 | 
			
		||||
    private host: string;
 | 
			
		||||
    private port: number;
 | 
			
		||||
    private id: number;
 | 
			
		||||
    constructor() {
 | 
			
		||||
        this.host = truffleConf.networks.development.host;
 | 
			
		||||
        this.port = truffleConf.networks.development.port;
 | 
			
		||||
        this.id = 0;
 | 
			
		||||
    }
 | 
			
		||||
    public async increaseTimeAsync(time: number) {
 | 
			
		||||
        const method = 'evm_increaseTime';
 | 
			
		||||
        const params = [time];
 | 
			
		||||
        const payload = this.toPayload(method, params);
 | 
			
		||||
        return this.sendAsync(payload);
 | 
			
		||||
    }
 | 
			
		||||
    public async mineBlockAsync() {
 | 
			
		||||
        const method = 'evm_mine';
 | 
			
		||||
        const payload = this.toPayload(method);
 | 
			
		||||
        return this.sendAsync(payload);
 | 
			
		||||
    }
 | 
			
		||||
    private toPayload(method: string, params: any[] = []) {
 | 
			
		||||
        const payload = JSON.stringify({
 | 
			
		||||
            id: this.id,
 | 
			
		||||
            method,
 | 
			
		||||
            params,
 | 
			
		||||
        });
 | 
			
		||||
        this.id++;
 | 
			
		||||
        return payload;
 | 
			
		||||
    }
 | 
			
		||||
    private async sendAsync(payload: string): Promise<any> {
 | 
			
		||||
        const opts = {
 | 
			
		||||
            method: 'POST',
 | 
			
		||||
            body: payload,
 | 
			
		||||
        };
 | 
			
		||||
        const response = await fetch(`http://${this.host}:${this.port}`, opts);
 | 
			
		||||
        const responsePayload = await response.json();
 | 
			
		||||
        return responsePayload;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										10
									
								
								packages/dev-utils/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								packages/dev-utils/README.md
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,10 @@
 | 
			
		||||
Dev utils
 | 
			
		||||
------
 | 
			
		||||
 | 
			
		||||
Dev utils to be shared across 0x projects and packages
 | 
			
		||||
 | 
			
		||||
## Install
 | 
			
		||||
 | 
			
		||||
```bash
 | 
			
		||||
yarn add @0xproject/dev-utils
 | 
			
		||||
```
 | 
			
		||||
							
								
								
									
										37
									
								
								packages/dev-utils/package.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								packages/dev-utils/package.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,37 @@
 | 
			
		||||
{
 | 
			
		||||
  "name": "@0xproject/dev-utils",
 | 
			
		||||
  "version": "0.0.1",
 | 
			
		||||
  "description": "0x dev TS utils",
 | 
			
		||||
  "main": "lib/index.js",
 | 
			
		||||
  "types": "lib/index.d.ts",
 | 
			
		||||
  "scripts": {
 | 
			
		||||
    "build": "tsc",
 | 
			
		||||
    "clean": "shx rm -rf lib",
 | 
			
		||||
    "lint": "tslint --project . 'src/**/*.ts'"
 | 
			
		||||
  },
 | 
			
		||||
  "license": "Apache-2.0",
 | 
			
		||||
  "repository": {
 | 
			
		||||
    "type": "git",
 | 
			
		||||
    "url": "https://github.com/0xProject/0x.js.git"
 | 
			
		||||
  },
 | 
			
		||||
  "bugs": {
 | 
			
		||||
    "url": "https://github.com/0xProject/0x.js/issues"
 | 
			
		||||
  },
 | 
			
		||||
  "homepage": "https://github.com/0xProject/0x.js/packages/dev-utils/README.md",
 | 
			
		||||
  "devDependencies": {
 | 
			
		||||
    "@0xproject/tslint-config": "^0.2.0",
 | 
			
		||||
    "@types/lodash": "^4.14.86",
 | 
			
		||||
    "npm-run-all": "^4.1.2",
 | 
			
		||||
    "shx": "^0.2.2",
 | 
			
		||||
    "tslint": "5.8.0",
 | 
			
		||||
    "typescript": "~2.6.1",
 | 
			
		||||
    "types-bn": "^0.0.1",
 | 
			
		||||
    "types-ethereumjs-util": "0xProject/types-ethereumjs-util"
 | 
			
		||||
  },
 | 
			
		||||
  "dependencies": {
 | 
			
		||||
    "bignumber.js": "~4.1.0",
 | 
			
		||||
    "ethereumjs-util": "^5.1.2",
 | 
			
		||||
    "lodash": "^4.17.4",
 | 
			
		||||
    "request-promise-native": "^1.0.5"
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@@ -3,8 +3,8 @@ import {RPC} from './rpc';
 | 
			
		||||
export class BlockchainLifecycle {
 | 
			
		||||
    private rpc: RPC;
 | 
			
		||||
    private snapshotIdsStack: number[];
 | 
			
		||||
    constructor() {
 | 
			
		||||
        this.rpc = new RPC();
 | 
			
		||||
    constructor(url: string) {
 | 
			
		||||
        this.rpc = new RPC(url);
 | 
			
		||||
        this.snapshotIdsStack = [];
 | 
			
		||||
    }
 | 
			
		||||
    // TODO: In order to run these tests on an actual node, we should check if we are running against
 | 
			
		||||
							
								
								
									
										2
									
								
								packages/dev-utils/src/index.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								packages/dev-utils/src/index.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,2 @@
 | 
			
		||||
export {RPC} from './rpc';
 | 
			
		||||
export {BlockchainLifecycle} from './blockchain_lifecycle';
 | 
			
		||||
@@ -1,15 +1,12 @@
 | 
			
		||||
import * as ethUtil from 'ethereumjs-util';
 | 
			
		||||
import * as request from 'request-promise-native';
 | 
			
		||||
 | 
			
		||||
import {constants} from './constants';
 | 
			
		||||
 | 
			
		||||
export class RPC {
 | 
			
		||||
    private host: string;
 | 
			
		||||
    private url: string;
 | 
			
		||||
    private port: number;
 | 
			
		||||
    private id: number;
 | 
			
		||||
    constructor() {
 | 
			
		||||
        this.host = constants.RPC_HOST;
 | 
			
		||||
        this.port = constants.RPC_PORT;
 | 
			
		||||
    constructor(url: string) {
 | 
			
		||||
        this.url = url;
 | 
			
		||||
        this.id = 0;
 | 
			
		||||
    }
 | 
			
		||||
    public async takeSnapshotAsync(): Promise<number> {
 | 
			
		||||
@@ -27,6 +24,12 @@ export class RPC {
 | 
			
		||||
        const didRevert = await this.sendAsync(payload);
 | 
			
		||||
        return didRevert;
 | 
			
		||||
    }
 | 
			
		||||
    public async increaseTimeAsync(time: number) {
 | 
			
		||||
        const method = 'evm_increaseTime';
 | 
			
		||||
        const params = [time];
 | 
			
		||||
        const payload = this.toPayload(method, params);
 | 
			
		||||
        return this.sendAsync(payload);
 | 
			
		||||
    }
 | 
			
		||||
    public async mineBlockAsync(): Promise<void> {
 | 
			
		||||
        const method = 'evm_mine';
 | 
			
		||||
        const params: any[] = [];
 | 
			
		||||
@@ -45,7 +48,7 @@ export class RPC {
 | 
			
		||||
    private async sendAsync(payload: string): Promise<any> {
 | 
			
		||||
        const opts = {
 | 
			
		||||
            method: 'POST',
 | 
			
		||||
            uri: `http://${this.host}:${this.port}`,
 | 
			
		||||
            uri: this.url,
 | 
			
		||||
            body: payload,
 | 
			
		||||
            headers: {
 | 
			
		||||
                'content-type': 'application/json',
 | 
			
		||||
							
								
								
									
										17
									
								
								packages/dev-utils/tsconfig.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								packages/dev-utils/tsconfig.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,17 @@
 | 
			
		||||
{
 | 
			
		||||
  "compilerOptions": {
 | 
			
		||||
    "module": "commonjs",
 | 
			
		||||
    "target": "es5",
 | 
			
		||||
    "lib": [ "es2017", "dom"],
 | 
			
		||||
    "outDir": "lib",
 | 
			
		||||
    "sourceMap": true,
 | 
			
		||||
    "declaration": true,
 | 
			
		||||
    "noImplicitAny": true,
 | 
			
		||||
    "strictNullChecks": true
 | 
			
		||||
  },
 | 
			
		||||
  "include": [
 | 
			
		||||
    "./src/**/*",
 | 
			
		||||
    "../../node_modules/types-bn/index.d.ts",
 | 
			
		||||
    "../../node_modules/types-ethereumjs-util/index.d.ts"
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										5
									
								
								packages/dev-utils/tslint.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								packages/dev-utils/tslint.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,5 @@
 | 
			
		||||
{
 | 
			
		||||
  "extends": [
 | 
			
		||||
    "@0xproject/tslint-config"
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										13
									
								
								packages/kovan-faucets/Dockerfile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								packages/kovan-faucets/Dockerfile
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,13 @@
 | 
			
		||||
FROM node
 | 
			
		||||
 | 
			
		||||
WORKDIR /src
 | 
			
		||||
 | 
			
		||||
COPY package.json .
 | 
			
		||||
RUN npm i
 | 
			
		||||
RUN npm install forever -g
 | 
			
		||||
 | 
			
		||||
COPY . .
 | 
			
		||||
 | 
			
		||||
EXPOSE 3000
 | 
			
		||||
 | 
			
		||||
CMD ["forever", "./bin/server.js"]
 | 
			
		||||
							
								
								
									
										66
									
								
								packages/kovan-faucets/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								packages/kovan-faucets/README.md
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,66 @@
 | 
			
		||||
Test Ether Faucet
 | 
			
		||||
----------------------
 | 
			
		||||
 | 
			
		||||
This faucet dispenses 0.1 test ether to one recipient per second. It has a max queue size of 1000.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
## Install
 | 
			
		||||
 | 
			
		||||
Install project dependencies:
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
npm install
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## Start
 | 
			
		||||
 | 
			
		||||
Set the following environment variables:
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
export FAUCET_ENVIRONMENT=development
 | 
			
		||||
export DISPENSER_ADDRESS=0x5409ed021d9299bf6814279a6a1411a7e866a631
 | 
			
		||||
export DISPENSER_PRIVATE_KEY=f2f48ee19680706196e2e339e5da3491186e0c4c5030670656b0e0164837257d
 | 
			
		||||
export FAUCET_ROLLBAR_ACCESS_KEY={GET_THIS_FROM_ROLLBAR_ACCOUNT_SETTINGS}
 | 
			
		||||
export INFURA_API_KEY={GET_THIS_FROM_INFURA}
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
Infura API Key can be requested here: https://infura.io/register.html
 | 
			
		||||
 | 
			
		||||
Note: The above public/private keys exist when running `testrpc` with the following option `--mnemonic concert load couple harbor equip island argue ramp clarify fence smart topic`.
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
npm run dev
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## Endpoints
 | 
			
		||||
 | 
			
		||||
```GET /ether/:recipient```
 | 
			
		||||
 | 
			
		||||
Where recipient_address is a hex encoded Ethereum address prefixed with `0x`.
 | 
			
		||||
 | 
			
		||||
```GET /zrx/:recipient```
 | 
			
		||||
 | 
			
		||||
Where recipient_address is a hex encoded Ethereum address prefixed with `0x`.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
```javascript
 | 
			
		||||
{
 | 
			
		||||
    "full": false,
 | 
			
		||||
    "size": 0
 | 
			
		||||
}
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## Docker configs
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
docker run -d \
 | 
			
		||||
-p 80:3000 \
 | 
			
		||||
--name kovan-faucets \
 | 
			
		||||
--log-opt max-size=100m \
 | 
			
		||||
--log-opt max-file=20 \
 | 
			
		||||
-e DISPENSER_ADDRESS=$DISPENSER_ADDRESS \
 | 
			
		||||
-e DISPENSER_PRIVATE_KEY=$DISPENSER_PRIVATE_KEY \
 | 
			
		||||
-e FAUCET_ROLLBAR_ACCESS_KEY=$FAUCET_ROLLBAR_ACCESS_KEY \
 | 
			
		||||
-e FAUCET_ENVIRONMENT=production \
 | 
			
		||||
kovan-faucets
 | 
			
		||||
```
 | 
			
		||||
							
								
								
									
										92
									
								
								packages/kovan-faucets/gulpfile.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										92
									
								
								packages/kovan-faucets/gulpfile.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,92 @@
 | 
			
		||||
const gulp = require('gulp');
 | 
			
		||||
const nodemon = require('nodemon');
 | 
			
		||||
const path = require('path');
 | 
			
		||||
const webpack = require('webpack');
 | 
			
		||||
const fs = require('fs');
 | 
			
		||||
const nodeExternals = require('webpack-node-externals');
 | 
			
		||||
 | 
			
		||||
const config = {
 | 
			
		||||
    target: 'node',
 | 
			
		||||
    entry: [path.join(__dirname, '/src/ts/server.ts')],
 | 
			
		||||
    output: {
 | 
			
		||||
        path: path.join(__dirname, '/bin'),
 | 
			
		||||
        filename: 'server.js',
 | 
			
		||||
    },
 | 
			
		||||
    devtool: 'source-map',
 | 
			
		||||
    resolve: {
 | 
			
		||||
        modules: [
 | 
			
		||||
            path.join(__dirname, '/src/ts'),
 | 
			
		||||
            'node_modules',
 | 
			
		||||
        ],
 | 
			
		||||
        extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'],
 | 
			
		||||
        alias: {
 | 
			
		||||
            ts: path.join(__dirname, '/src/ts'),
 | 
			
		||||
            contract_artifacts: path.join(__dirname, '/src/contract_artifacts'),
 | 
			
		||||
        },
 | 
			
		||||
    },
 | 
			
		||||
    module: {
 | 
			
		||||
        rules: [
 | 
			
		||||
            {
 | 
			
		||||
                test: /\.js$/,
 | 
			
		||||
                loader: 'source-map-loader',
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                test: /\.tsx?$/,
 | 
			
		||||
                loader: 'awesome-typescript-loader',
 | 
			
		||||
            },
 | 
			
		||||
        ],
 | 
			
		||||
    },
 | 
			
		||||
    plugins: [
 | 
			
		||||
        new webpack.BannerPlugin({
 | 
			
		||||
            banner: 'require("source-map-support").install();',
 | 
			
		||||
            raw: true,
 | 
			
		||||
            entryOnly: false,
 | 
			
		||||
        }),
 | 
			
		||||
    ],
 | 
			
		||||
    externals: nodeExternals({
 | 
			
		||||
        modulesDir: path.join(__dirname, '../../node_modules')
 | 
			
		||||
    }),
 | 
			
		||||
    watchOptions: {
 | 
			
		||||
        ignored: /bin|node_modules|transpiled/
 | 
			
		||||
    },
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
gulp.task('build', function(done) {
 | 
			
		||||
    webpack(config).run(onBuild(done));
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
gulp.task('watch', function() {
 | 
			
		||||
    webpack(config).watch(100, function(err, stats) {
 | 
			
		||||
        onBuild()(err, stats);
 | 
			
		||||
        nodemon.restart();
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
gulp.task('run', ['watch'], function() {
 | 
			
		||||
    nodemon({
 | 
			
		||||
        execMap: {
 | 
			
		||||
            js: 'node',
 | 
			
		||||
        },
 | 
			
		||||
        script: path.join(__dirname, 'bin/server'),
 | 
			
		||||
        ignore: ['*'],
 | 
			
		||||
        watch: ['foo/'],
 | 
			
		||||
        ext: 'noop',
 | 
			
		||||
    }).on('restart', function() {
 | 
			
		||||
        console.log('Restarted!');
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
function onBuild(done) {
 | 
			
		||||
  return function(err, stats) {
 | 
			
		||||
    if(err) {
 | 
			
		||||
      console.log('Error', err);
 | 
			
		||||
    }
 | 
			
		||||
    else {
 | 
			
		||||
      console.log(stats.toString());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if(done) {
 | 
			
		||||
      done();
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										44
									
								
								packages/kovan-faucets/package.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								packages/kovan-faucets/package.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,44 @@
 | 
			
		||||
{
 | 
			
		||||
  "private": true,
 | 
			
		||||
  "name": "@0xproject/kovan_faucets",
 | 
			
		||||
  "version": "1.0.0",
 | 
			
		||||
  "description": "A faucet micro-service that dispenses test ERC20 tokens or Ether",
 | 
			
		||||
  "main": "server.js",
 | 
			
		||||
  "scripts": {
 | 
			
		||||
    "build": "node ../../node_modules/gulp/bin/gulp.js build",
 | 
			
		||||
    "dev": "node ../../node_modules/gulp/bin/gulp.js run",
 | 
			
		||||
    "start": "node ./bin/server.js",
 | 
			
		||||
    "lint": "tslint --project . 'src/**/*.ts'",
 | 
			
		||||
    "clean": "shx rm -rf bin"
 | 
			
		||||
  },
 | 
			
		||||
  "author": "Fabio Berger",
 | 
			
		||||
  "license": "Apache-2.0",
 | 
			
		||||
  "dependencies": {
 | 
			
		||||
    "@0xproject/utils": "^0.1.0",    
 | 
			
		||||
    "0x.js": "~0.27.2",
 | 
			
		||||
    "bignumber.js": "~4.1.0",
 | 
			
		||||
    "body-parser": "^1.17.1",
 | 
			
		||||
    "ethereumjs-tx": "^1.3.3",
 | 
			
		||||
    "express": "^4.15.2",
 | 
			
		||||
    "lodash": "^4.17.4",
 | 
			
		||||
    "rollbar": "^0.6.5",
 | 
			
		||||
    "web3": "^0.20.0",
 | 
			
		||||
    "web3-provider-engine": "^13.0.1"
 | 
			
		||||
  },
 | 
			
		||||
  "devDependencies": {
 | 
			
		||||
    "@0xproject/tslint-config": "^0.2.1",
 | 
			
		||||
    "@types/body-parser": "^1.16.1",
 | 
			
		||||
    "@types/express": "^4.0.35",
 | 
			
		||||
    "@types/lodash": "^4.14.86",
 | 
			
		||||
    "awesome-typescript-loader": "^3.1.3",
 | 
			
		||||
    "gulp": "^3.9.1",
 | 
			
		||||
    "nodemon": "^1.11.0",
 | 
			
		||||
    "shx": "^0.2.2",
 | 
			
		||||
    "source-map-loader": "^0.1.6",
 | 
			
		||||
    "tslint": "5.8.0",
 | 
			
		||||
    "typescript": "~2.6.1",
 | 
			
		||||
    "web3-typescript-typings": "^0.7.2",
 | 
			
		||||
    "webpack": "^3.1.0",
 | 
			
		||||
    "webpack-node-externals": "^1.6.0"
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										11
									
								
								packages/kovan-faucets/src/ts/configs.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								packages/kovan-faucets/src/ts/configs.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,11 @@
 | 
			
		||||
export const configs = {
 | 
			
		||||
    DISPENSER_ADDRESS: process.env.DISPENSER_ADDRESS.toLowerCase(),
 | 
			
		||||
    DISPENSER_PRIVATE_KEY: process.env.DISPENSER_PRIVATE_KEY,
 | 
			
		||||
    ENVIRONMENT: process.env.FAUCET_ENVIRONMENT,
 | 
			
		||||
    ROLLBAR_ACCESS_KEY: process.env.FAUCET_ROLLBAR_ACCESS_KEY,
 | 
			
		||||
    RPC_URL: process.env.FAUCET_ENVIRONMENT === 'development' ?
 | 
			
		||||
        'http://127.0.0.1:8545' :
 | 
			
		||||
        `https://kovan.infura.io/${process.env.INFURA_API_KEY}`,
 | 
			
		||||
    ZRX_TOKEN_ADDRESS: '0x6ff6c0ff1d68b964901f986d4c9fa3ac68346570',
 | 
			
		||||
    KOVAN_NETWORK_ID: 42,
 | 
			
		||||
};
 | 
			
		||||
							
								
								
									
										41
									
								
								packages/kovan-faucets/src/ts/error_reporter.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								packages/kovan-faucets/src/ts/error_reporter.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,41 @@
 | 
			
		||||
import * as express from 'express';
 | 
			
		||||
import * as fs from 'fs';
 | 
			
		||||
import rollbar = require('rollbar');
 | 
			
		||||
 | 
			
		||||
import {configs} from './configs';
 | 
			
		||||
import {utils} from './utils';
 | 
			
		||||
 | 
			
		||||
export const errorReporter = {
 | 
			
		||||
    setup() {
 | 
			
		||||
        rollbar.init(configs.ROLLBAR_ACCESS_KEY, {
 | 
			
		||||
            environment: configs.ENVIRONMENT,
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        rollbar.handleUncaughtExceptions(configs.ROLLBAR_ACCESS_KEY);
 | 
			
		||||
 | 
			
		||||
        process.on('unhandledRejection', (err: Error) => {
 | 
			
		||||
            utils.consoleLog(`Uncaught exception ${err}. Stack: ${err.stack}`);
 | 
			
		||||
            this.report(err);
 | 
			
		||||
            process.exit(1);
 | 
			
		||||
        });
 | 
			
		||||
    },
 | 
			
		||||
    async reportAsync(err: Error, req?: express.Request): Promise<any> {
 | 
			
		||||
        if (configs.ENVIRONMENT === 'development') {
 | 
			
		||||
            return; // Do not log development environment errors
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return new Promise((resolve, reject) => {
 | 
			
		||||
            rollbar.handleError(err, req, (rollbarErr: Error) => {
 | 
			
		||||
                if (rollbarErr) {
 | 
			
		||||
                    utils.consoleLog(`Error reporting to rollbar, ignoring: ${rollbarErr}`);
 | 
			
		||||
                    reject(rollbarErr);
 | 
			
		||||
                } else {
 | 
			
		||||
                    resolve();
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        });
 | 
			
		||||
    },
 | 
			
		||||
    errorHandler() {
 | 
			
		||||
        return rollbar.errorHandler(configs.ROLLBAR_ACCESS_KEY);
 | 
			
		||||
    },
 | 
			
		||||
};
 | 
			
		||||
							
								
								
									
										27
									
								
								packages/kovan-faucets/src/ts/ether_request_queue.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								packages/kovan-faucets/src/ts/ether_request_queue.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,27 @@
 | 
			
		||||
import {promisify} from '@0xproject/utils';
 | 
			
		||||
import * as _ from 'lodash';
 | 
			
		||||
 | 
			
		||||
import {configs} from './configs';
 | 
			
		||||
import {errorReporter} from './error_reporter';
 | 
			
		||||
import {RequestQueue} from './request_queue';
 | 
			
		||||
import {utils} from './utils';
 | 
			
		||||
 | 
			
		||||
const DISPENSE_AMOUNT_ETHER = 0.1;
 | 
			
		||||
 | 
			
		||||
export class EtherRequestQueue extends RequestQueue {
 | 
			
		||||
    protected async processNextRequestFireAndForgetAsync(recipientAddress: string) {
 | 
			
		||||
        utils.consoleLog(`Processing ETH ${recipientAddress}`);
 | 
			
		||||
        const sendTransactionAsync = promisify(this.web3.eth.sendTransaction);
 | 
			
		||||
        try {
 | 
			
		||||
            const txHash = await sendTransactionAsync({
 | 
			
		||||
                from: configs.DISPENSER_ADDRESS,
 | 
			
		||||
                to: recipientAddress,
 | 
			
		||||
                value: this.web3.toWei(DISPENSE_AMOUNT_ETHER, 'ether'),
 | 
			
		||||
            });
 | 
			
		||||
            utils.consoleLog(`Sent ${DISPENSE_AMOUNT_ETHER} ETH to ${recipientAddress} tx: ${txHash}`);
 | 
			
		||||
        } catch (err) {
 | 
			
		||||
            utils.consoleLog(`Unexpected err: ${err} - ${JSON.stringify(err)}`);
 | 
			
		||||
            await errorReporter.reportAsync(err);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										26
									
								
								packages/kovan-faucets/src/ts/global.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								packages/kovan-faucets/src/ts/global.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,26 @@
 | 
			
		||||
declare module 'rollbar';
 | 
			
		||||
declare module 'web3-provider-engine';
 | 
			
		||||
declare module 'web3-provider-engine/subproviders/rpc';
 | 
			
		||||
declare module 'web3-provider-engine/subproviders/nonce-tracker';
 | 
			
		||||
declare module 'web3-provider-engine/subproviders/hooked-wallet';
 | 
			
		||||
 | 
			
		||||
declare module '*.json' {
 | 
			
		||||
    const json: any;
 | 
			
		||||
    /* tslint:disable */
 | 
			
		||||
    export default json;
 | 
			
		||||
    /* tslint:enable */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Ethereumjs-tx declarations
 | 
			
		||||
declare module 'ethereumjs-tx' {
 | 
			
		||||
    class EthereumTx {
 | 
			
		||||
        public raw: Buffer[];
 | 
			
		||||
        public r: Buffer;
 | 
			
		||||
        public s: Buffer;
 | 
			
		||||
        public v: Buffer;
 | 
			
		||||
        public serialize(): Buffer;
 | 
			
		||||
        public sign(buffer: Buffer): void;
 | 
			
		||||
        constructor(txParams: any);
 | 
			
		||||
    }
 | 
			
		||||
    export = EthereumTx;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										91
									
								
								packages/kovan-faucets/src/ts/handler.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										91
									
								
								packages/kovan-faucets/src/ts/handler.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,91 @@
 | 
			
		||||
import * as express from 'express';
 | 
			
		||||
import * as _ from 'lodash';
 | 
			
		||||
import ProviderEngine = require('web3-provider-engine');
 | 
			
		||||
import HookedWalletSubprovider = require('web3-provider-engine/subproviders/hooked-wallet');
 | 
			
		||||
import NonceSubprovider = require('web3-provider-engine/subproviders/nonce-tracker');
 | 
			
		||||
import RpcSubprovider = require('web3-provider-engine/subproviders/rpc');
 | 
			
		||||
 | 
			
		||||
import {configs} from './configs';
 | 
			
		||||
import {EtherRequestQueue} from './ether_request_queue';
 | 
			
		||||
import {idManagement} from './id_management';
 | 
			
		||||
import {utils} from './utils';
 | 
			
		||||
import {ZRXRequestQueue} from './zrx_request_queue';
 | 
			
		||||
 | 
			
		||||
// HACK: web3 leaks XMLHttpRequest into the global scope and causes requests to hang
 | 
			
		||||
// because they are using the wrong XHR package.
 | 
			
		||||
// Issue: https://github.com/trufflesuite/truffle-contract/issues/14
 | 
			
		||||
// tslint:disable-next-line:ordered-imports
 | 
			
		||||
import * as Web3 from 'web3';
 | 
			
		||||
 | 
			
		||||
export class Handler {
 | 
			
		||||
    private etherRequestQueue: EtherRequestQueue;
 | 
			
		||||
    private zrxRequestQueue: ZRXRequestQueue;
 | 
			
		||||
    private web3: Web3;
 | 
			
		||||
    constructor() {
 | 
			
		||||
        // Setup provider engine to talk with RPC node
 | 
			
		||||
        const providerObj = this.createProviderEngine(configs.RPC_URL);
 | 
			
		||||
        this.web3 = new Web3(providerObj);
 | 
			
		||||
 | 
			
		||||
        this.etherRequestQueue = new EtherRequestQueue(this.web3);
 | 
			
		||||
        this.zrxRequestQueue = new ZRXRequestQueue(this.web3);
 | 
			
		||||
    }
 | 
			
		||||
    public dispenseEther(req: express.Request, res: express.Response) {
 | 
			
		||||
        const recipientAddress = req.params.recipient;
 | 
			
		||||
        if (_.isUndefined(recipientAddress) || !this.isValidEthereumAddress(recipientAddress)) {
 | 
			
		||||
            res.status(400).send('INVALID_REQUEST');
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        const lowerCaseRecipientAddress = recipientAddress.toLowerCase();
 | 
			
		||||
        const didAddToQueue = this.etherRequestQueue.add(lowerCaseRecipientAddress);
 | 
			
		||||
        if (!didAddToQueue) {
 | 
			
		||||
            res.status(503).send('QUEUE_IS_FULL');
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        utils.consoleLog(`Added ${lowerCaseRecipientAddress} to the ETH queue`);
 | 
			
		||||
        res.status(200).end();
 | 
			
		||||
    }
 | 
			
		||||
    public dispenseZRX(req: express.Request, res: express.Response) {
 | 
			
		||||
        const recipientAddress = req.params.recipient;
 | 
			
		||||
        if (_.isUndefined(recipientAddress) || !this.isValidEthereumAddress(recipientAddress)) {
 | 
			
		||||
            res.status(400).send('INVALID_REQUEST');
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        const lowerCaseRecipientAddress = recipientAddress.toLowerCase();
 | 
			
		||||
        const didAddToQueue = this.zrxRequestQueue.add(lowerCaseRecipientAddress);
 | 
			
		||||
        if (!didAddToQueue) {
 | 
			
		||||
            res.status(503).send('QUEUE_IS_FULL');
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        utils.consoleLog(`Added ${lowerCaseRecipientAddress} to the ZRX queue`);
 | 
			
		||||
        res.status(200).end();
 | 
			
		||||
    }
 | 
			
		||||
    public getQueueInfo(req: express.Request, res: express.Response) {
 | 
			
		||||
        res.setHeader('Content-Type', 'application/json');
 | 
			
		||||
        const payload = JSON.stringify({
 | 
			
		||||
            ether: {
 | 
			
		||||
                full: this.etherRequestQueue.isFull(),
 | 
			
		||||
                size: this.etherRequestQueue.size(),
 | 
			
		||||
            },
 | 
			
		||||
            zrx: {
 | 
			
		||||
                full: this.zrxRequestQueue.isFull(),
 | 
			
		||||
                size: this.zrxRequestQueue.size(),
 | 
			
		||||
            },
 | 
			
		||||
        });
 | 
			
		||||
        res.status(200).send(payload);
 | 
			
		||||
    }
 | 
			
		||||
    // tslint:disable-next-line:prefer-function-over-method
 | 
			
		||||
    private createProviderEngine(rpcUrl: string) {
 | 
			
		||||
        const engine = new ProviderEngine();
 | 
			
		||||
        engine.addProvider(new NonceSubprovider());
 | 
			
		||||
        engine.addProvider(new HookedWalletSubprovider(idManagement));
 | 
			
		||||
        engine.addProvider(new RpcSubprovider({
 | 
			
		||||
            rpcUrl,
 | 
			
		||||
        }));
 | 
			
		||||
        engine.start();
 | 
			
		||||
        return engine;
 | 
			
		||||
    }
 | 
			
		||||
    private isValidEthereumAddress(address: string): boolean {
 | 
			
		||||
        const lowercaseAddress = address.toLowerCase();
 | 
			
		||||
        return this.web3.isAddress(lowercaseAddress);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										25
									
								
								packages/kovan-faucets/src/ts/id_management.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								packages/kovan-faucets/src/ts/id_management.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,25 @@
 | 
			
		||||
import EthereumTx = require('ethereumjs-tx');
 | 
			
		||||
 | 
			
		||||
import {configs} from './configs';
 | 
			
		||||
import {utils} from './utils';
 | 
			
		||||
 | 
			
		||||
type Callback = (err: Error, accounts: any) => void;
 | 
			
		||||
 | 
			
		||||
export const idManagement = {
 | 
			
		||||
    getAccounts(callback: Callback) {
 | 
			
		||||
        utils.consoleLog(`configs.DISPENSER_ADDRESS: ${configs.DISPENSER_ADDRESS}`);
 | 
			
		||||
        callback(null, [
 | 
			
		||||
            configs.DISPENSER_ADDRESS,
 | 
			
		||||
        ]);
 | 
			
		||||
    },
 | 
			
		||||
    approveTransaction(txData: object, callback: Callback) {
 | 
			
		||||
        callback(null, true);
 | 
			
		||||
    },
 | 
			
		||||
    signTransaction(txData: object, callback: Callback) {
 | 
			
		||||
        const tx = new EthereumTx(txData);
 | 
			
		||||
        const privateKeyBuffer = new Buffer(configs.DISPENSER_PRIVATE_KEY, 'hex');
 | 
			
		||||
        tx.sign(privateKeyBuffer);
 | 
			
		||||
        const rawTx = `0x${tx.serialize().toString('hex')}`;
 | 
			
		||||
        callback(null, rawTx);
 | 
			
		||||
    },
 | 
			
		||||
};
 | 
			
		||||
							
								
								
									
										57
									
								
								packages/kovan-faucets/src/ts/request_queue.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								packages/kovan-faucets/src/ts/request_queue.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,57 @@
 | 
			
		||||
import * as _ from 'lodash';
 | 
			
		||||
import * as timers from 'timers';
 | 
			
		||||
 | 
			
		||||
// HACK: web3 leaks XMLHttpRequest into the global scope and causes requests to hang
 | 
			
		||||
// because they are using the wrong XHR package.
 | 
			
		||||
// Issue: https://github.com/trufflesuite/truffle-contract/issues/14
 | 
			
		||||
// tslint:disable-next-line:ordered-imports
 | 
			
		||||
import * as Web3 from 'web3';
 | 
			
		||||
 | 
			
		||||
const MAX_QUEUE_SIZE = 500;
 | 
			
		||||
const DEFAULT_QUEUE_INTERVAL_MS = 1000;
 | 
			
		||||
 | 
			
		||||
export class RequestQueue {
 | 
			
		||||
    protected queueIntervalMs: number;
 | 
			
		||||
    protected queue: string[];
 | 
			
		||||
    protected queueIntervalId: NodeJS.Timer;
 | 
			
		||||
    protected web3: Web3;
 | 
			
		||||
    constructor(web3: any) {
 | 
			
		||||
        this.queueIntervalMs = DEFAULT_QUEUE_INTERVAL_MS;
 | 
			
		||||
        this.queue = [];
 | 
			
		||||
 | 
			
		||||
        this.web3 = web3;
 | 
			
		||||
 | 
			
		||||
        this.start();
 | 
			
		||||
    }
 | 
			
		||||
    public add(recipientAddress: string): boolean {
 | 
			
		||||
        if (this.isFull()) {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        this.queue.push(recipientAddress);
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
    public size(): number {
 | 
			
		||||
        return this.queue.length;
 | 
			
		||||
    }
 | 
			
		||||
    public isFull(): boolean {
 | 
			
		||||
        return this.size() >= MAX_QUEUE_SIZE;
 | 
			
		||||
    }
 | 
			
		||||
    protected start() {
 | 
			
		||||
        this.queueIntervalId = timers.setInterval(() => {
 | 
			
		||||
            if (this.queue.length === 0) {
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            const recipientAddress = this.queue.shift();
 | 
			
		||||
                // tslint:disable-next-line:no-floating-promises
 | 
			
		||||
            this.processNextRequestFireAndForgetAsync(recipientAddress);
 | 
			
		||||
 | 
			
		||||
        }, this.queueIntervalMs);
 | 
			
		||||
    }
 | 
			
		||||
    protected stop() {
 | 
			
		||||
        clearInterval(this.queueIntervalId);
 | 
			
		||||
    }
 | 
			
		||||
    // tslint:disable-next-line:prefer-function-over-method
 | 
			
		||||
    protected async processNextRequestFireAndForgetAsync(recipientAddress: string) {
 | 
			
		||||
        throw new Error('Expected processNextRequestFireAndForgetAsync to be implemented by a superclass');
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										26
									
								
								packages/kovan-faucets/src/ts/server.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								packages/kovan-faucets/src/ts/server.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,26 @@
 | 
			
		||||
import * as bodyParser from 'body-parser';
 | 
			
		||||
import * as express from 'express';
 | 
			
		||||
 | 
			
		||||
import {errorReporter} from './error_reporter';
 | 
			
		||||
import {Handler} from './handler';
 | 
			
		||||
 | 
			
		||||
// Setup the errorReporter to catch uncaught exceptions and unhandled rejections
 | 
			
		||||
errorReporter.setup();
 | 
			
		||||
 | 
			
		||||
const app = express();
 | 
			
		||||
app.use(bodyParser.json()); // for parsing application/json
 | 
			
		||||
app.use((req, res, next) => {
 | 
			
		||||
  res.header('Access-Control-Allow-Origin', '*');
 | 
			
		||||
  res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');
 | 
			
		||||
  next();
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
const handler = new Handler();
 | 
			
		||||
app.get('/ping', (req: express.Request, res: express.Response) => { res.status(200).send('pong'); });
 | 
			
		||||
app.get('/ether/:recipient', handler.dispenseEther.bind(handler));
 | 
			
		||||
app.get('/zrx/:recipient', handler.dispenseZRX.bind(handler));
 | 
			
		||||
 | 
			
		||||
// Log to rollbar any errors unhandled by handlers
 | 
			
		||||
app.use(errorReporter.errorHandler());
 | 
			
		||||
const port = process.env.PORT || 3000;
 | 
			
		||||
app.listen(port);
 | 
			
		||||
							
								
								
									
										10
									
								
								packages/kovan-faucets/src/ts/utils.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								packages/kovan-faucets/src/ts/utils.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,10 @@
 | 
			
		||||
import * as express from 'express';
 | 
			
		||||
import * as _ from 'lodash';
 | 
			
		||||
 | 
			
		||||
export const utils = {
 | 
			
		||||
    consoleLog(message: string) {
 | 
			
		||||
        /* tslint:disable */
 | 
			
		||||
        console.log(message);
 | 
			
		||||
        /* tslint:enable */
 | 
			
		||||
    },
 | 
			
		||||
};
 | 
			
		||||
							
								
								
									
										43
									
								
								packages/kovan-faucets/src/ts/zrx_request_queue.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								packages/kovan-faucets/src/ts/zrx_request_queue.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,43 @@
 | 
			
		||||
import {ZeroEx} from '0x.js';
 | 
			
		||||
import {promisify} from '@0xproject/utils';
 | 
			
		||||
import BigNumber from 'bignumber.js';
 | 
			
		||||
import * as _ from 'lodash';
 | 
			
		||||
 | 
			
		||||
import {configs} from './configs';
 | 
			
		||||
import {errorReporter} from './error_reporter';
 | 
			
		||||
import {RequestQueue} from './request_queue';
 | 
			
		||||
import {utils} from './utils';
 | 
			
		||||
 | 
			
		||||
// HACK: web3 leaks XMLHttpRequest into the global scope and causes requests to hang
 | 
			
		||||
// because they are using the wrong XHR package.
 | 
			
		||||
// Issue: https://github.com/trufflesuite/truffle-contract/issues/14
 | 
			
		||||
// tslint:disable-next-line:ordered-imports
 | 
			
		||||
import * as Web3 from 'web3';
 | 
			
		||||
 | 
			
		||||
const DISPENSE_AMOUNT_ZRX = new BigNumber(0.1);
 | 
			
		||||
const QUEUE_INTERVAL_MS = 5000;
 | 
			
		||||
 | 
			
		||||
export class ZRXRequestQueue extends RequestQueue {
 | 
			
		||||
    private zeroEx: ZeroEx;
 | 
			
		||||
    constructor(web3: Web3) {
 | 
			
		||||
        super(web3);
 | 
			
		||||
        this.queueIntervalMs = QUEUE_INTERVAL_MS;
 | 
			
		||||
        const zeroExConfig = {
 | 
			
		||||
            networkId: configs.KOVAN_NETWORK_ID,
 | 
			
		||||
        };
 | 
			
		||||
        this.zeroEx = new ZeroEx(web3.currentProvider, zeroExConfig);
 | 
			
		||||
    }
 | 
			
		||||
    protected async processNextRequestFireAndForgetAsync(recipientAddress: string) {
 | 
			
		||||
        utils.consoleLog(`Processing ZRX ${recipientAddress}`);
 | 
			
		||||
        const baseUnitAmount = ZeroEx.toBaseUnitAmount(DISPENSE_AMOUNT_ZRX, 18);
 | 
			
		||||
        try {
 | 
			
		||||
            await this.zeroEx.token.transferAsync(
 | 
			
		||||
                configs.ZRX_TOKEN_ADDRESS, configs.DISPENSER_ADDRESS, recipientAddress, baseUnitAmount,
 | 
			
		||||
            );
 | 
			
		||||
            utils.consoleLog(`Sent ${DISPENSE_AMOUNT_ZRX} ZRX to ${recipientAddress}`);
 | 
			
		||||
        } catch (err) {
 | 
			
		||||
            utils.consoleLog(`Unexpected err: ${err} - ${JSON.stringify(err)}`);
 | 
			
		||||
            await errorReporter.reportAsync(err);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										16
									
								
								packages/kovan-faucets/tsconfig.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								packages/kovan-faucets/tsconfig.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,16 @@
 | 
			
		||||
{
 | 
			
		||||
  "compilerOptions": {
 | 
			
		||||
    "module": "commonjs",
 | 
			
		||||
    "target": "es5",
 | 
			
		||||
    "lib": [ "es2015", "dom" ],
 | 
			
		||||
    "outDir": "lib",
 | 
			
		||||
    "sourceMap": true,
 | 
			
		||||
    "declaration": true,
 | 
			
		||||
    "noImplicitAny": true,
 | 
			
		||||
    "experimentalDecorators": true,
 | 
			
		||||
  },
 | 
			
		||||
  "include": [
 | 
			
		||||
    "../../node_modules/web3-typescript-typings/index.d.ts",
 | 
			
		||||
    "./src/ts/**/*"
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										5
									
								
								packages/kovan-faucets/tslint.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								packages/kovan-faucets/tslint.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,5 @@
 | 
			
		||||
{
 | 
			
		||||
  "extends": [
 | 
			
		||||
    "@0xproject/tslint-config"
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
@@ -8,6 +8,10 @@ export interface TxData {
 | 
			
		||||
    nonce?: number;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface TxDataPayable extends TxData {
 | 
			
		||||
    value?: BigNumber;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface TransactionReceipt {
 | 
			
		||||
    blockHash: string;
 | 
			
		||||
    blockNumber: number;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,2 +1,5 @@
 | 
			
		||||
export {promisify} from './promisify';
 | 
			
		||||
export {addressUtils} from './address_utils';
 | 
			
		||||
export {classUtils} from './class_utils';
 | 
			
		||||
export {intervalUtils} from './interval_utils';
 | 
			
		||||
export {bigNumberConfigs} from './bignumber_config';
 | 
			
		||||
 
 | 
			
		||||
@@ -18,7 +18,7 @@
 | 
			
		||||
  "author": "Fabio Berger",
 | 
			
		||||
  "license": "Apache-2.0",
 | 
			
		||||
  "dependencies": {
 | 
			
		||||
    "0x.js": "0.27.1",
 | 
			
		||||
    "0x.js": "~0.27.2",
 | 
			
		||||
    "@0xproject/subproviders": "^0.1.0",
 | 
			
		||||
    "accounting": "^0.4.1",
 | 
			
		||||
    "basscss": "^8.0.3",
 | 
			
		||||
 
 | 
			
		||||
@@ -23,7 +23,7 @@ import {
 | 
			
		||||
    LedgerWalletSubprovider,
 | 
			
		||||
    RedundantRPCSubprovider,
 | 
			
		||||
} from '@0xproject/subproviders';
 | 
			
		||||
import {promisify} from '@0xproject/utils';
 | 
			
		||||
import {intervalUtils, promisify} from '@0xproject/utils';
 | 
			
		||||
import BigNumber from 'bignumber.js';
 | 
			
		||||
import compareVersions = require('compare-versions');
 | 
			
		||||
import ethUtil = require('ethereumjs-util');
 | 
			
		||||
@@ -75,7 +75,7 @@ export class Blockchain {
 | 
			
		||||
    private userAddress: string;
 | 
			
		||||
    private cachedProvider: Web3.Provider;
 | 
			
		||||
    private ledgerSubprovider: LedgerWalletSubprovider;
 | 
			
		||||
    private zrxPollIntervalId: number;
 | 
			
		||||
    private zrxPollIntervalId: NodeJS.Timer;
 | 
			
		||||
    private static async onPageLoadAsync() {
 | 
			
		||||
        if (document.readyState === 'complete') {
 | 
			
		||||
            return; // Already loaded
 | 
			
		||||
@@ -359,7 +359,7 @@ export class Blockchain {
 | 
			
		||||
 | 
			
		||||
        const [currBalance] = await this.getTokenBalanceAndAllowanceAsync(this.userAddress, token.address);
 | 
			
		||||
 | 
			
		||||
        this.zrxPollIntervalId = window.setInterval(async () => {
 | 
			
		||||
        this.zrxPollIntervalId = intervalUtils.setAsyncExcludingInterval(async () => {
 | 
			
		||||
            const [balance] = await this.getTokenBalanceAndAllowanceAsync(this.userAddress, token.address);
 | 
			
		||||
            if (!balance.eq(currBalance)) {
 | 
			
		||||
                this.dispatcher.replaceTokenBalanceByAddress(token.address, balance);
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
import {promisify} from '@0xproject/utils';
 | 
			
		||||
import {intervalUtils, promisify} from '@0xproject/utils';
 | 
			
		||||
import BigNumber from 'bignumber.js';
 | 
			
		||||
import * as _ from 'lodash';
 | 
			
		||||
import {Dispatcher} from 'ts/redux/dispatcher';
 | 
			
		||||
@@ -9,7 +9,7 @@ export class Web3Wrapper {
 | 
			
		||||
    private web3: Web3;
 | 
			
		||||
    private prevNetworkId: number;
 | 
			
		||||
    private shouldPollUserAddress: boolean;
 | 
			
		||||
    private watchNetworkAndBalanceIntervalId: number;
 | 
			
		||||
    private watchNetworkAndBalanceIntervalId: NodeJS.Timer;
 | 
			
		||||
    private prevUserEtherBalanceInEth: BigNumber;
 | 
			
		||||
    private prevUserAddress: string;
 | 
			
		||||
    constructor(dispatcher: Dispatcher, provider: Web3.Provider, networkIdIfExists: number,
 | 
			
		||||
@@ -98,7 +98,7 @@ export class Web3Wrapper {
 | 
			
		||||
        let prevNodeVersion: string;
 | 
			
		||||
        this.prevUserEtherBalanceInEth = new BigNumber(0);
 | 
			
		||||
        this.dispatcher.updateNetworkId(this.prevNetworkId);
 | 
			
		||||
        this.watchNetworkAndBalanceIntervalId = window.setInterval(async () => {
 | 
			
		||||
        this.watchNetworkAndBalanceIntervalId = intervalUtils.setAsyncExcludingInterval(async () => {
 | 
			
		||||
            // Check for network state changes
 | 
			
		||||
            const currentNetworkId = await this.getNetworkIdIfExists();
 | 
			
		||||
            if (currentNetworkId !== this.prevNetworkId) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user