aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeonid <logvinov.leon@gmail.com>2017-12-15 00:48:45 +0800
committerGitHub <noreply@github.com>2017-12-15 00:48:45 +0800
commita0aa21103b51ad287de1579832a4a490ca90175a (patch)
treed65274497474e65302a91e78efa1796558aa4380
parentd69143487ec441939a85ef2a7e92bb0a15cb2e6c (diff)
parentce242b10e2c4d35bbba3842d198b78373dd609f0 (diff)
downloaddexon-sol-tools-a0aa21103b51ad287de1579832a4a490ca90175a.tar.gz
dexon-sol-tools-a0aa21103b51ad287de1579832a4a490ca90175a.tar.zst
dexon-sol-tools-a0aa21103b51ad287de1579832a4a490ca90175a.zip
Merge pull request #258 from 0xProject/feature/contracts-refactor
A bunch of refactorings
-rw-r--r--.circleci/config.yml2
-rw-r--r--packages/0x.js/contract_templates/contract.mustache (renamed from packages/abi-gen-templates/contract.mustache)6
-rw-r--r--packages/0x.js/contract_templates/partials/call.mustache (renamed from packages/abi-gen-templates/partials/call.mustache)0
-rw-r--r--packages/0x.js/contract_templates/partials/params.mustache (renamed from packages/abi-gen-templates/partials/params.mustache)0
-rw-r--r--packages/0x.js/contract_templates/partials/return_type.mustache (renamed from packages/abi-gen-templates/partials/return_type.mustache)0
-rw-r--r--packages/0x.js/contract_templates/partials/tx.mustache (renamed from packages/abi-gen-templates/partials/tx.mustache)0
-rw-r--r--packages/0x.js/contract_templates/partials/typed_params.mustache (renamed from packages/abi-gen-templates/partials/typed_params.mustache)0
-rw-r--r--packages/0x.js/package.json10
-rw-r--r--packages/0x.js/src/0x.ts3
-rw-r--r--packages/0x.js/src/artifacts.ts2
-rw-r--r--packages/0x.js/src/artifacts/DummyToken.json23
-rw-r--r--packages/0x.js/src/artifacts/EtherToken.json2
-rw-r--r--packages/0x.js/src/artifacts/Exchange.json2
-rw-r--r--packages/0x.js/src/artifacts/TokenTransferProxy.json2
-rw-r--r--packages/0x.js/src/artifacts/ZRX.json2
-rw-r--r--packages/0x.js/src/contract_wrappers/contract_wrapper.ts2
-rw-r--r--packages/0x.js/src/contract_wrappers/generated/.gitignore6
-rw-r--r--packages/0x.js/src/contract_wrappers/generated/base_contract.ts3
-rw-r--r--packages/0x.js/src/contract_wrappers/generated/ether_token.ts363
-rw-r--r--packages/0x.js/src/contract_wrappers/generated/exchange.ts730
-rw-r--r--packages/0x.js/src/contract_wrappers/generated/token.ts232
-rw-r--r--packages/0x.js/src/contract_wrappers/generated/token_registry.ts550
-rw-r--r--packages/0x.js/src/contract_wrappers/generated/token_transfer_proxy.ts285
-rw-r--r--packages/0x.js/src/index.ts5
-rw-r--r--packages/0x.js/src/order_watcher/event_watcher.ts2
-rw-r--r--packages/0x.js/src/order_watcher/expiration_watcher.ts2
-rw-r--r--packages/0x.js/src/order_watcher/order_state_watcher.ts2
-rw-r--r--packages/0x.js/src/types.ts27
-rw-r--r--packages/0x.js/test/0x.js_test.ts4
-rw-r--r--packages/0x.js/test/ether_token_wrapper_test.ts4
-rw-r--r--packages/0x.js/test/exchange_transfer_simulator_test.ts4
-rw-r--r--packages/0x.js/test/exchange_wrapper_test.ts20
-rw-r--r--packages/0x.js/test/expiration_watcher_test.ts7
-rw-r--r--packages/0x.js/test/order_state_watcher_test.ts7
-rw-r--r--packages/0x.js/test/order_validation_test.ts8
-rw-r--r--packages/0x.js/test/subscription_test.ts4
-rw-r--r--packages/0x.js/test/token_registry_wrapper_test.ts4
-rw-r--r--packages/0x.js/test/token_wrapper_test.ts4
-rw-r--r--packages/0x.js/test/utils/constants.ts3
-rw-r--r--packages/0x.js/test/utils/fill_scenarios.ts22
-rw-r--r--packages/0x.js/test/utils/token_utils.ts9
-rw-r--r--packages/0x.js/test/utils/web3_factory.ts3
-rw-r--r--packages/abi-gen-templates/package.json15
-rw-r--r--packages/abi-gen/README.md4
-rw-r--r--packages/contracts/deploy/migrations/migrate.ts104
-rw-r--r--packages/contracts/package.json1
-rw-r--r--packages/contracts/test/ts/multi_sig_with_time_lock.ts6
-rw-r--r--packages/contracts/util/balances.ts2
-rw-r--r--packages/contracts/util/bignumber_config.ts11
-rw-r--r--packages/contracts/util/rpc.ts43
-rw-r--r--packages/dev-utils/README.md10
-rw-r--r--packages/dev-utils/package.json37
-rw-r--r--packages/dev-utils/src/blockchain_lifecycle.ts (renamed from packages/0x.js/test/utils/blockchain_lifecycle.ts)4
-rw-r--r--packages/dev-utils/src/index.ts2
-rw-r--r--packages/dev-utils/src/rpc.ts (renamed from packages/0x.js/test/utils/rpc.ts)17
-rw-r--r--packages/dev-utils/tsconfig.json17
-rw-r--r--packages/dev-utils/tslint.json5
-rw-r--r--packages/kovan-faucets/src/ts/global.d.ts2
-rw-r--r--packages/types/src/index.ts4
-rw-r--r--packages/utils/src/bignumber_config.ts (renamed from packages/0x.js/src/bignumber_config.ts)0
-rw-r--r--packages/utils/src/class_utils.ts (renamed from packages/0x.js/src/utils/class_utils.ts)0
-rw-r--r--packages/utils/src/index.ts3
-rw-r--r--packages/utils/src/interval_utils.ts (renamed from packages/0x.js/src/utils/interval_utils.ts)0
-rw-r--r--packages/website/ts/blockchain.ts6
-rw-r--r--packages/website/ts/web3_wrapper.ts6
-rw-r--r--yarn.lock4
66 files changed, 272 insertions, 2397 deletions
diff --git a/.circleci/config.yml b/.circleci/config.yml
index fa3388ad5..86a3e2968 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -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
diff --git a/packages/abi-gen-templates/contract.mustache b/packages/0x.js/contract_templates/contract.mustache
index ec06df507..4c59d4f58 100644
--- a/packages/abi-gen-templates/contract.mustache
+++ b/packages/0x.js/contract_templates/contract.mustache
@@ -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 {
diff --git a/packages/abi-gen-templates/partials/call.mustache b/packages/0x.js/contract_templates/partials/call.mustache
index ef4bda724..ef4bda724 100644
--- a/packages/abi-gen-templates/partials/call.mustache
+++ b/packages/0x.js/contract_templates/partials/call.mustache
diff --git a/packages/abi-gen-templates/partials/params.mustache b/packages/0x.js/contract_templates/partials/params.mustache
index ac5d4ae85..ac5d4ae85 100644
--- a/packages/abi-gen-templates/partials/params.mustache
+++ b/packages/0x.js/contract_templates/partials/params.mustache
diff --git a/packages/abi-gen-templates/partials/return_type.mustache b/packages/0x.js/contract_templates/partials/return_type.mustache
index 383961a40..383961a40 100644
--- a/packages/abi-gen-templates/partials/return_type.mustache
+++ b/packages/0x.js/contract_templates/partials/return_type.mustache
diff --git a/packages/abi-gen-templates/partials/tx.mustache b/packages/0x.js/contract_templates/partials/tx.mustache
index 8a43e5319..8a43e5319 100644
--- a/packages/abi-gen-templates/partials/tx.mustache
+++ b/packages/0x.js/contract_templates/partials/tx.mustache
diff --git a/packages/abi-gen-templates/partials/typed_params.mustache b/packages/0x.js/contract_templates/partials/typed_params.mustache
index 3ea4b2e95..3ea4b2e95 100644
--- a/packages/abi-gen-templates/partials/typed_params.mustache
+++ b/packages/0x.js/contract_templates/partials/typed_params.mustache
diff --git a/packages/0x.js/package.json b/packages/0x.js/package.json
index 62f9ed0f5..fcb08646a 100644
--- a/packages/0x.js/package.json
+++ b/packages/0x.js/package.json
@@ -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",
diff --git a/packages/0x.js/src/0x.ts b/packages/0x.js/src/0x.ts
index 935e4ac1a..83d470845 100644
--- a/packages/0x.js/src/0x.ts
+++ b/packages/0x.js/src/0x.ts
@@ -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';
diff --git a/packages/0x.js/src/artifacts.ts b/packages/0x.js/src/artifacts.ts
index de2030812..7219ac8e2 100644
--- a/packages/0x.js/src/artifacts.ts
+++ b/packages/0x.js/src/artifacts.ts
@@ -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,
diff --git a/packages/0x.js/src/artifacts/DummyToken.json b/packages/0x.js/src/artifacts/DummyToken.json
new file mode 100644
index 000000000..fd44397db
--- /dev/null
+++ b/packages/0x.js/src/artifacts/DummyToken.json
@@ -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"
+ }
+ ]
+}
diff --git a/packages/0x.js/src/artifacts/EtherToken.json b/packages/0x.js/src/artifacts/EtherToken.json
index 8c1d0f499..de6946cf2 100644
--- a/packages/0x.js/src/artifacts/EtherToken.json
+++ b/packages/0x.js/src/artifacts/EtherToken.json
@@ -244,7 +244,7 @@
"address": "0x05d090b51c40b020eab3bfcb6a2dff130df22e9c"
},
"50": {
- "address": "0x48bacb9266a570d521063ef5dd96e61686dbe788"
+ "address": "0x871dd7c2b4b25e1aa18728e9d5f2af4c4e431f5c"
}
}
}
diff --git a/packages/0x.js/src/artifacts/Exchange.json b/packages/0x.js/src/artifacts/Exchange.json
index 25495a041..cf9124ca7 100644
--- a/packages/0x.js/src/artifacts/Exchange.json
+++ b/packages/0x.js/src/artifacts/Exchange.json
@@ -601,7 +601,7 @@
"address": "0x90fe2af704b34e0224bf2299c838e04d4dcf1364"
},
"50": {
- "address": "0xb69e673309512a9d726f87304c6984054f87a93b"
+ "address": "0x48bacb9266a570d521063ef5dd96e61686dbe788"
}
}
}
diff --git a/packages/0x.js/src/artifacts/TokenTransferProxy.json b/packages/0x.js/src/artifacts/TokenTransferProxy.json
index 065343919..023f39bdf 100644
--- a/packages/0x.js/src/artifacts/TokenTransferProxy.json
+++ b/packages/0x.js/src/artifacts/TokenTransferProxy.json
@@ -178,7 +178,7 @@
"address": "0x087eed4bc1ee3de49befbd66c662b434b15d49d4"
},
"50": {
- "address": "0x871dd7c2b4b25e1aa18728e9d5f2af4c4e431f5c"
+ "address": "0x1dc4c1cefef38a777b15aa20260a54e584b16c48"
}
}
}
diff --git a/packages/0x.js/src/artifacts/ZRX.json b/packages/0x.js/src/artifacts/ZRX.json
index 7da67fde0..a9fe1799a 100644
--- a/packages/0x.js/src/artifacts/ZRX.json
+++ b/packages/0x.js/src/artifacts/ZRX.json
@@ -11,7 +11,7 @@
"address": "0x6ff6c0ff1d68b964901f986d4c9fa3ac68346570"
},
"50": {
- "address": "0x25b8fe1de9daf8ba351890744ff28cf7dfa8f5e3"
+ "address": "0x1d7022f5b17d2f8b695918fb48fa1089c9f85401"
}
}
}
diff --git a/packages/0x.js/src/contract_wrappers/contract_wrapper.ts b/packages/0x.js/src/contract_wrappers/contract_wrapper.ts
index 5caf06db2..a796dc1ec 100644
--- a/packages/0x.js/src/contract_wrappers/contract_wrapper.ts
+++ b/packages/0x.js/src/contract_wrappers/contract_wrapper.ts
@@ -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,
diff --git a/packages/0x.js/src/contract_wrappers/generated/.gitignore b/packages/0x.js/src/contract_wrappers/generated/.gitignore
new file mode 100644
index 000000000..834808b48
--- /dev/null
+++ b/packages/0x.js/src/contract_wrappers/generated/.gitignore
@@ -0,0 +1,6 @@
+dummy_token.ts
+ether_token.ts
+exchange.ts
+token_registry.ts
+token_transfer_proxy.ts
+token.ts
diff --git a/packages/0x.js/src/contract_wrappers/generated/base_contract.ts b/packages/0x.js/src/contract_wrappers/generated/base_contract.ts
index 396a4d593..28a7e2f52 100644
--- a/packages/0x.js/src/contract_wrappers/generated/base_contract.ts
+++ b/packages/0x.js/src/contract_wrappers/generated/base_contract.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>;
diff --git a/packages/0x.js/src/contract_wrappers/generated/ether_token.ts b/packages/0x.js/src/contract_wrappers/generated/ether_token.ts
deleted file mode 100644
index ce3f9f527..000000000
--- a/packages/0x.js/src/contract_wrappers/generated/ether_token.ts
+++ /dev/null
@@ -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
diff --git a/packages/0x.js/src/contract_wrappers/generated/exchange.ts b/packages/0x.js/src/contract_wrappers/generated/exchange.ts
deleted file mode 100644
index e06ed960c..000000000
--- a/packages/0x.js/src/contract_wrappers/generated/exchange.ts
+++ /dev/null
@@ -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
diff --git a/packages/0x.js/src/contract_wrappers/generated/token.ts b/packages/0x.js/src/contract_wrappers/generated/token.ts
deleted file mode 100644
index 83a4ead34..000000000
--- a/packages/0x.js/src/contract_wrappers/generated/token.ts
+++ /dev/null
@@ -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
diff --git a/packages/0x.js/src/contract_wrappers/generated/token_registry.ts b/packages/0x.js/src/contract_wrappers/generated/token_registry.ts
deleted file mode 100644
index 5d9ad9016..000000000
--- a/packages/0x.js/src/contract_wrappers/generated/token_registry.ts
+++ /dev/null
@@ -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
diff --git a/packages/0x.js/src/contract_wrappers/generated/token_transfer_proxy.ts b/packages/0x.js/src/contract_wrappers/generated/token_transfer_proxy.ts
deleted file mode 100644
index fd50a5894..000000000
--- a/packages/0x.js/src/contract_wrappers/generated/token_transfer_proxy.ts
+++ /dev/null
@@ -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
diff --git a/packages/0x.js/src/index.ts b/packages/0x.js/src/index.ts
index d4193a3e9..2f5296a9f 100644
--- a/packages/0x.js/src/index.ts
+++ b/packages/0x.js/src/index.ts
@@ -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';
diff --git a/packages/0x.js/src/order_watcher/event_watcher.ts b/packages/0x.js/src/order_watcher/event_watcher.ts
index d5b30d567..c11079208 100644
--- a/packages/0x.js/src/order_watcher/event_watcher.ts
+++ b/packages/0x.js/src/order_watcher/event_watcher.ts
@@ -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;
diff --git a/packages/0x.js/src/order_watcher/expiration_watcher.ts b/packages/0x.js/src/order_watcher/expiration_watcher.ts
index 9a1bb1ca4..5faac43cf 100644
--- a/packages/0x.js/src/order_watcher/expiration_watcher.ts
+++ b/packages/0x.js/src/order_watcher/expiration_watcher.ts
@@ -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;
diff --git a/packages/0x.js/src/order_watcher/order_state_watcher.ts b/packages/0x.js/src/order_watcher/order_state_watcher.ts
index 08f52d6e1..9ae1579c6 100644
--- a/packages/0x.js/src/order_watcher/order_state_watcher.ts
+++ b/packages/0x.js/src/order_watcher/order_state_watcher.ts
@@ -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';
diff --git a/packages/0x.js/src/types.ts b/packages/0x.js/src/types.ts
index 3586919cb..f33e05bb8 100644
--- a/packages/0x.js/src/types.ts
+++ b/packages/0x.js/src/types.ts
@@ -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
diff --git a/packages/0x.js/test/0x.js_test.ts b/packages/0x.js/test/0x.js_test.ts
index 6b7a70699..52f9566dc 100644
--- a/packages/0x.js/test/0x.js_test.ts
+++ b/packages/0x.js/test/0x.js_test.ts
@@ -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;
diff --git a/packages/0x.js/test/ether_token_wrapper_test.ts b/packages/0x.js/test/ether_token_wrapper_test.ts
index d3e4439ee..e0d738f84 100644
--- a/packages/0x.js/test/ether_token_wrapper_test.ts
+++ b/packages/0x.js/test/ether_token_wrapper_test.ts
@@ -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
diff --git a/packages/0x.js/test/exchange_transfer_simulator_test.ts b/packages/0x.js/test/exchange_transfer_simulator_test.ts
index a1d9bdade..dbd1e99bd 100644
--- a/packages/0x.js/test/exchange_transfer_simulator_test.ts
+++ b/packages/0x.js/test/exchange_transfer_simulator_test.ts
@@ -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();
diff --git a/packages/0x.js/test/exchange_wrapper_test.ts b/packages/0x.js/test/exchange_wrapper_test.ts
index 14559c706..dea961026 100644
--- a/packages/0x.js/test/exchange_wrapper_test.ts
+++ b/packages/0x.js/test/exchange_wrapper_test.ts
@@ -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;
});
diff --git a/packages/0x.js/test/expiration_watcher_test.ts b/packages/0x.js/test/expiration_watcher_test.ts
index d4581259d..c1618ce9d 100644
--- a/packages/0x.js/test/expiration_watcher_test.ts
+++ b/packages/0x.js/test/expiration_watcher_test.ts
@@ -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;
});
diff --git a/packages/0x.js/test/order_state_watcher_test.ts b/packages/0x.js/test/order_state_watcher_test.ts
index b5968dc24..99e6646a3 100644
--- a/packages/0x.js/test/order_state_watcher_test.ts
+++ b/packages/0x.js/test/order_state_watcher_test.ts
@@ -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 () => {
diff --git a/packages/0x.js/test/order_validation_test.ts b/packages/0x.js/test/order_validation_test.ts
index d585c1f3c..c6d5d3392 100644
--- a/packages/0x.js/test/order_validation_test.ts
+++ b/packages/0x.js/test/order_validation_test.ts
@@ -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(
diff --git a/packages/0x.js/test/subscription_test.ts b/packages/0x.js/test/subscription_test.ts
index 3aeeaa109..d280d720a 100644
--- a/packages/0x.js/test/subscription_test.ts
+++ b/packages/0x.js/test/subscription_test.ts
@@ -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;
diff --git a/packages/0x.js/test/token_registry_wrapper_test.ts b/packages/0x.js/test/token_registry_wrapper_test.ts
index f1f307f3a..533384450 100644
--- a/packages/0x.js/test/token_registry_wrapper_test.ts
+++ b/packages/0x.js/test/token_registry_wrapper_test.ts
@@ -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;
diff --git a/packages/0x.js/test/token_wrapper_test.ts b/packages/0x.js/test/token_wrapper_test.ts
index ae6016869..1ee2b25fc 100644
--- a/packages/0x.js/test/token_wrapper_test.ts
+++ b/packages/0x.js/test/token_wrapper_test.ts
@@ -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;
diff --git a/packages/0x.js/test/utils/constants.ts b/packages/0x.js/test/utils/constants.ts
index 75fdf49c9..d486da581 100644
--- a/packages/0x.js/test/utils/constants.ts
+++ b/packages/0x.js/test/utils/constants.ts
@@ -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,
diff --git a/packages/0x.js/test/utils/fill_scenarios.ts b/packages/0x.js/test/utils/fill_scenarios.ts
index 090493935..5f3e89906 100644
--- a/packages/0x.js/test/utils/fill_scenarios.ts
+++ b/packages/0x.js/test/utils/fill_scenarios.ts
@@ -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,
diff --git a/packages/0x.js/test/utils/token_utils.ts b/packages/0x.js/test/utils/token_utils.ts
index 9c20f52a1..4634899a7 100644
--- a/packages/0x.js/test/utils/token_utils.ts
+++ b/packages/0x.js/test/utils/token_utils.ts
@@ -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;
}
}
diff --git a/packages/0x.js/test/utils/web3_factory.ts b/packages/0x.js/test/utils/web3_factory.ts
index da4828943..6f72cec58 100644
--- a/packages/0x.js/test/utils/web3_factory.ts
+++ b/packages/0x.js/test/utils/web3_factory.ts
@@ -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;
diff --git a/packages/abi-gen-templates/package.json b/packages/abi-gen-templates/package.json
deleted file mode 100644
index 60b88d8d7..000000000
--- a/packages/abi-gen-templates/package.json
+++ /dev/null
@@ -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"
-}
diff --git a/packages/abi-gen/README.md b/packages/abi-gen/README.md
index 16dd9b969..0eaacd86f 100644
--- a/packages/abi-gen/README.md
+++ b/packages/abi-gen/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?
diff --git a/packages/contracts/deploy/migrations/migrate.ts b/packages/contracts/deploy/migrations/migrate.ts
index c3d38875e..f40b7c4ba 100644
--- a/packages/contracts/deploy/migrations/migrate.ts
+++ b/packages/contracts/deploy/migrations/migrate.ts
@@ -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,35 +46,41 @@ export const migrator = {
tokenInfo[0].swarmHash,
{from: owner},
);
- const addTokenPromises = [
- tokenReg.addToken.sendTransactionAsync(
- zrxToken.address,
- '0x Protocol Token',
- 'ZRX',
- 18,
- constants.NULL_BYTES,
- constants.NULL_BYTES,
- {
- from: owner,
- gas: addTokenGasEstimate,
- },
- ),
- tokenReg.addToken.sendTransactionAsync(
- etherToken.address,
- 'Ether Token',
- 'WETH',
- 18,
- constants.NULL_BYTES,
- constants.NULL_BYTES,
- {
- from: owner,
- gas: addTokenGasEstimate,
- },
- ),
- ];
- const addDummyTokenPromises = _.map(tokenInfo, async (token: Token, i: number): Promise<void> => {
- return tokenReg.addToken.sendTransactionAsync(
- tokensToRegister[i].address,
+ await tokenReg.addToken.sendTransactionAsync(
+ zrxToken.address,
+ '0x Protocol Token',
+ 'ZRX',
+ 18,
+ constants.NULL_BYTES,
+ constants.NULL_BYTES,
+ {
+ from: owner,
+ gas: addTokenGasEstimate,
+ },
+ );
+ await tokenReg.addToken.sendTransactionAsync(
+ etherToken.address,
+ 'Ether Token',
+ 'WETH',
+ 18,
+ constants.NULL_BYTES,
+ constants.NULL_BYTES,
+ {
+ from: owner,
+ gas: addTokenGasEstimate,
+ },
+ );
+ for (const token of tokenInfo) {
+ const totalSupply = new BigNumber(0);
+ const args = [
+ token.name,
+ token.symbol,
+ token.decimals,
+ totalSupply,
+ ];
+ 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]);
+ }
},
};
diff --git a/packages/contracts/package.json b/packages/contracts/package.json
index 93f28f990..c8ccd0a3a 100644
--- a/packages/contracts/package.json
+++ b/packages/contracts/package.json
@@ -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",
diff --git a/packages/contracts/test/ts/multi_sig_with_time_lock.ts b/packages/contracts/test/ts/multi_sig_with_time_lock.ts
index 84eb21b4a..d92c5967f 100644
--- a/packages/contracts/test/ts/multi_sig_with_time_lock.ts
+++ b/packages/contracts/test/ts/multi_sig_with_time_lock.ts
@@ -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', () => {
diff --git a/packages/contracts/util/balances.ts b/packages/contracts/util/balances.ts
index fce15db6d..7f5e843a5 100644
--- a/packages/contracts/util/balances.ts
+++ b/packages/contracts/util/balances.ts
@@ -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();
diff --git a/packages/contracts/util/bignumber_config.ts b/packages/contracts/util/bignumber_config.ts
deleted file mode 100644
index 38f59d341..000000000
--- a/packages/contracts/util/bignumber_config.ts
+++ /dev/null
@@ -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,
- });
- },
-};
diff --git a/packages/contracts/util/rpc.ts b/packages/contracts/util/rpc.ts
deleted file mode 100644
index 023602bd6..000000000
--- a/packages/contracts/util/rpc.ts
+++ /dev/null
@@ -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;
- }
-}
diff --git a/packages/dev-utils/README.md b/packages/dev-utils/README.md
new file mode 100644
index 000000000..98f31cda6
--- /dev/null
+++ b/packages/dev-utils/README.md
@@ -0,0 +1,10 @@
+Dev utils
+------
+
+Dev utils to be shared across 0x projects and packages
+
+## Install
+
+```bash
+yarn add @0xproject/dev-utils
+```
diff --git a/packages/dev-utils/package.json b/packages/dev-utils/package.json
new file mode 100644
index 000000000..d9a0fa193
--- /dev/null
+++ b/packages/dev-utils/package.json
@@ -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"
+ }
+}
diff --git a/packages/0x.js/test/utils/blockchain_lifecycle.ts b/packages/dev-utils/src/blockchain_lifecycle.ts
index 9a44ccd6f..19c5ac184 100644
--- a/packages/0x.js/test/utils/blockchain_lifecycle.ts
+++ b/packages/dev-utils/src/blockchain_lifecycle.ts
@@ -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
diff --git a/packages/dev-utils/src/index.ts b/packages/dev-utils/src/index.ts
new file mode 100644
index 000000000..97c5ebc0c
--- /dev/null
+++ b/packages/dev-utils/src/index.ts
@@ -0,0 +1,2 @@
+export {RPC} from './rpc';
+export {BlockchainLifecycle} from './blockchain_lifecycle';
diff --git a/packages/0x.js/test/utils/rpc.ts b/packages/dev-utils/src/rpc.ts
index 309a96d5e..c276b2452 100644
--- a/packages/0x.js/test/utils/rpc.ts
+++ b/packages/dev-utils/src/rpc.ts
@@ -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',
diff --git a/packages/dev-utils/tsconfig.json b/packages/dev-utils/tsconfig.json
new file mode 100644
index 000000000..66609c87d
--- /dev/null
+++ b/packages/dev-utils/tsconfig.json
@@ -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"
+ ]
+}
diff --git a/packages/dev-utils/tslint.json b/packages/dev-utils/tslint.json
new file mode 100644
index 000000000..a07795151
--- /dev/null
+++ b/packages/dev-utils/tslint.json
@@ -0,0 +1,5 @@
+{
+ "extends": [
+ "@0xproject/tslint-config"
+ ]
+}
diff --git a/packages/kovan-faucets/src/ts/global.d.ts b/packages/kovan-faucets/src/ts/global.d.ts
index c698207dd..97cd35680 100644
--- a/packages/kovan-faucets/src/ts/global.d.ts
+++ b/packages/kovan-faucets/src/ts/global.d.ts
@@ -19,7 +19,7 @@ declare module 'ethereumjs-tx' {
public s: Buffer;
public v: Buffer;
public serialize(): Buffer;
- public sign(buffer: Buffer): void;
+ public sign(buffer: Buffer): void;
constructor(txParams: any);
}
export = EthereumTx;
diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts
index 8d69af63d..3db1aebe1 100644
--- a/packages/types/src/index.ts
+++ b/packages/types/src/index.ts
@@ -8,6 +8,10 @@ export interface TxData {
nonce?: number;
}
+export interface TxDataPayable extends TxData {
+ value?: BigNumber;
+}
+
export interface TransactionReceipt {
blockHash: string;
blockNumber: number;
diff --git a/packages/0x.js/src/bignumber_config.ts b/packages/utils/src/bignumber_config.ts
index 2d5214e6f..2d5214e6f 100644
--- a/packages/0x.js/src/bignumber_config.ts
+++ b/packages/utils/src/bignumber_config.ts
diff --git a/packages/0x.js/src/utils/class_utils.ts b/packages/utils/src/class_utils.ts
index 04e60ee57..04e60ee57 100644
--- a/packages/0x.js/src/utils/class_utils.ts
+++ b/packages/utils/src/class_utils.ts
diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts
index edfd192b2..403bc7236 100644
--- a/packages/utils/src/index.ts
+++ b/packages/utils/src/index.ts
@@ -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';
diff --git a/packages/0x.js/src/utils/interval_utils.ts b/packages/utils/src/interval_utils.ts
index 62b79f2f5..62b79f2f5 100644
--- a/packages/0x.js/src/utils/interval_utils.ts
+++ b/packages/utils/src/interval_utils.ts
diff --git a/packages/website/ts/blockchain.ts b/packages/website/ts/blockchain.ts
index 172ba6b52..321a603ef 100644
--- a/packages/website/ts/blockchain.ts
+++ b/packages/website/ts/blockchain.ts
@@ -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);
diff --git a/packages/website/ts/web3_wrapper.ts b/packages/website/ts/web3_wrapper.ts
index b713f8a33..1bf7ffed5 100644
--- a/packages/website/ts/web3_wrapper.ts
+++ b/packages/website/ts/web3_wrapper.ts
@@ -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) {
diff --git a/yarn.lock b/yarn.lock
index 83887c3ba..5c084bace 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -3132,7 +3132,7 @@ ethereumjs-util@4.5.0, ethereumjs-util@^4.0.0, ethereumjs-util@^4.0.1, ethereumj
rlp "^2.0.0"
secp256k1 "^3.0.1"
-ethereumjs-util@^5.0.0, ethereumjs-util@^5.0.1, ethereumjs-util@^5.1.1:
+ethereumjs-util@^5.0.0, ethereumjs-util@^5.0.1, ethereumjs-util@^5.1.1, ethereumjs-util@^5.1.2:
version "5.1.2"
resolved "https://registry.yarnpkg.com/ethereumjs-util/-/ethereumjs-util-5.1.2.tgz#25ba0215cbb4c2f0b108a6f96af2a2e62e45921f"
dependencies:
@@ -7608,7 +7608,7 @@ request-promise-core@1.1.1:
dependencies:
lodash "^4.13.1"
-request-promise-native@^1.0.4:
+request-promise-native@^1.0.4, request-promise-native@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/request-promise-native/-/request-promise-native-1.0.5.tgz#5281770f68e0c9719e5163fd3fab482215f4fda5"
dependencies: