aboutsummaryrefslogtreecommitdiffstats
path: root/packages/0x.js
diff options
context:
space:
mode:
Diffstat (limited to 'packages/0x.js')
-rw-r--r--packages/0x.js/contract_templates/contract.mustache26
-rw-r--r--packages/0x.js/contract_templates/partials/call.mustache15
-rw-r--r--packages/0x.js/contract_templates/partials/params.mustache3
-rw-r--r--packages/0x.js/contract_templates/partials/return_type.mustache6
-rw-r--r--packages/0x.js/contract_templates/partials/tx.mustache51
-rw-r--r--packages/0x.js/contract_templates/partials/typed_params.mustache3
-rw-r--r--packages/0x.js/package.json10
-rw-r--r--packages/0x.js/src/0x.ts5
-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/bignumber_config.ts11
-rw-r--r--packages/0x.js/src/contract_wrappers/contract_wrapper.ts2
-rw-r--r--packages/0x.js/src/contract_wrappers/exchange_wrapper.ts5
-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/contract_wrappers/token_registry_wrapper.ts4
-rw-r--r--packages/0x.js/src/contract_wrappers/token_transfer_proxy_wrapper.ts1
-rw-r--r--packages/0x.js/src/contract_wrappers/token_wrapper.ts2
-rw-r--r--packages/0x.js/src/index.ts5
-rw-r--r--packages/0x.js/src/order_watcher/event_watcher.ts5
-rw-r--r--packages/0x.js/src/order_watcher/expiration_watcher.ts5
-rw-r--r--packages/0x.js/src/order_watcher/order_state_watcher.ts4
-rw-r--r--packages/0x.js/src/stores/balance_proxy_allowance_lazy_store.ts1
-rw-r--r--packages/0x.js/src/stores/order_filled_cancelled_lazy_store.ts1
-rw-r--r--packages/0x.js/src/types.ts27
-rw-r--r--packages/0x.js/src/utils/assert.ts10
-rw-r--r--packages/0x.js/src/utils/class_utils.ts18
-rw-r--r--packages/0x.js/src/utils/interval_utils.ts20
-rw-r--r--packages/0x.js/src/utils/order_state_utils.ts5
-rw-r--r--packages/0x.js/src/utils/order_validation_utils.ts5
-rw-r--r--packages/0x.js/test/0x.js_test.ts6
-rw-r--r--packages/0x.js/test/artifacts_test.ts2
-rw-r--r--packages/0x.js/test/ether_token_wrapper_test.ts4
-rw-r--r--packages/0x.js/test/event_watcher_test.ts5
-rw-r--r--packages/0x.js/test/exchange_transfer_simulator_test.ts4
-rw-r--r--packages/0x.js/test/exchange_wrapper_test.ts21
-rw-r--r--packages/0x.js/test/expiration_watcher_test.ts8
-rw-r--r--packages/0x.js/test/order_state_watcher_test.ts35
-rw-r--r--packages/0x.js/test/order_validation_test.ts13
-rw-r--r--packages/0x.js/test/remaining_fillable_calculator_test.ts11
-rw-r--r--packages/0x.js/test/subscription_test.ts12
-rw-r--r--packages/0x.js/test/token_registry_wrapper_test.ts4
-rw-r--r--packages/0x.js/test/token_transfer_proxy_wrapper_test.ts1
-rw-r--r--packages/0x.js/test/token_wrapper_test.ts13
-rw-r--r--packages/0x.js/test/utils/blockchain_lifecycle.ts26
-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/report_callback_errors.ts2
-rw-r--r--packages/0x.js/test/utils/rpc.ts58
-rw-r--r--packages/0x.js/test/utils/token_utils.ts9
-rw-r--r--packages/0x.js/test/utils/web3_factory.ts3
60 files changed, 238 insertions, 2476 deletions
diff --git a/packages/0x.js/contract_templates/contract.mustache b/packages/0x.js/contract_templates/contract.mustache
new file mode 100644
index 000000000..693fbe4ee
--- /dev/null
+++ b/packages/0x.js/contract_templates/contract.mustache
@@ -0,0 +1,26 @@
+/**
+ * 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.
+ */
+// tslint:disable-next-line:no-unused-variable
+import {TxData, TxDataPayable} from '@0xproject/types';
+import {classUtils, promisify} from '@0xproject/utils';
+import {BigNumber} from 'bignumber.js';
+import * as Web3 from 'web3';
+
+import {BaseContract} from './base_contract';
+
+export class {{contractName}}Contract extends BaseContract {
+{{#each methods}}
+ {{#this.constant}}
+ {{> call contractName=../contractName}}
+ {{/this.constant}}
+ {{^this.constant}}
+ {{> tx contractName=../contractName}}
+ {{/this.constant}}
+{{/each}}
+ 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/contract_templates/partials/call.mustache b/packages/0x.js/contract_templates/partials/call.mustache
new file mode 100644
index 000000000..ef4bda724
--- /dev/null
+++ b/packages/0x.js/contract_templates/partials/call.mustache
@@ -0,0 +1,15 @@
+public {{this.name}} = {
+ async callAsync(
+ {{> typed_params inputs=inputs}}
+ defaultBlock?: Web3.BlockParam,
+ ): Promise<{{> return_type outputs=outputs}}> {
+ const self = this as {{contractName}}Contract;
+ const result = await promisify<{{> return_type outputs=outputs}}>(
+ self.web3ContractInstance.{{this.name}}.call,
+ self.web3ContractInstance,
+ )(
+ {{> params inputs=inputs}}
+ );
+ return result;
+ },
+};
diff --git a/packages/0x.js/contract_templates/partials/params.mustache b/packages/0x.js/contract_templates/partials/params.mustache
new file mode 100644
index 000000000..ac5d4ae85
--- /dev/null
+++ b/packages/0x.js/contract_templates/partials/params.mustache
@@ -0,0 +1,3 @@
+{{#each inputs}}
+{{name}},
+{{/each}}
diff --git a/packages/0x.js/contract_templates/partials/return_type.mustache b/packages/0x.js/contract_templates/partials/return_type.mustache
new file mode 100644
index 000000000..383961a40
--- /dev/null
+++ b/packages/0x.js/contract_templates/partials/return_type.mustache
@@ -0,0 +1,6 @@
+{{#singleReturnValue}}
+{{#returnType outputs.0.type}}{{/returnType}}
+{{/singleReturnValue}}
+{{^singleReturnValue}}
+[{{#each outputs}}{{#returnType type}}{{/returnType}}{{#unless @last}}, {{/unless}}{{/each}}]
+{{/singleReturnValue}}
diff --git a/packages/0x.js/contract_templates/partials/tx.mustache b/packages/0x.js/contract_templates/partials/tx.mustache
new file mode 100644
index 000000000..8a43e5319
--- /dev/null
+++ b/packages/0x.js/contract_templates/partials/tx.mustache
@@ -0,0 +1,51 @@
+public {{this.name}} = {
+ async sendTransactionAsync(
+ {{> typed_params inputs=inputs}}
+ {{#this.payable}}
+ txData: TxDataPayable = {},
+ {{/this.payable}}
+ {{^this.payable}}
+ txData: TxData = {},
+ {{/this.payable}}
+ ): Promise<string> {
+ const self = this as {{contractName}}Contract;
+ const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
+ txData,
+ self.{{this.name}}.estimateGasAsync.bind(
+ self,
+ {{> params inputs=inputs}}
+ ),
+ );
+ const txHash = await promisify<string>(
+ self.web3ContractInstance.{{this.name}}, self.web3ContractInstance,
+ )(
+ {{> params inputs=inputs}}
+ txDataWithDefaults,
+ );
+ return txHash;
+ },
+ async estimateGasAsync(
+ {{> typed_params inputs=inputs}}
+ txData: TxData = {},
+ ): Promise<number> {
+ const self = this as {{contractName}}Contract;
+ const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
+ txData,
+ );
+ const gas = await promisify<number>(
+ self.web3ContractInstance.{{this.name}}.estimateGas, self.web3ContractInstance,
+ )(
+ {{> params inputs=inputs}}
+ txDataWithDefaults,
+ );
+ return gas;
+ },
+ getABIEncodedTransactionData(
+ {{> typed_params inputs=inputs}}
+ txData: TxData = {},
+ ): string {
+ const self = this as {{contractName}}Contract;
+ const abiEncodedTransactionData = self.web3ContractInstance.{{this.name}}.getData();
+ return abiEncodedTransactionData;
+ },
+};
diff --git a/packages/0x.js/contract_templates/partials/typed_params.mustache b/packages/0x.js/contract_templates/partials/typed_params.mustache
new file mode 100644
index 000000000..3ea4b2e95
--- /dev/null
+++ b/packages/0x.js/contract_templates/partials/typed_params.mustache
@@ -0,0 +1,3 @@
+{{#each inputs}}
+ {{name}}: {{#parameterType type}}{{/parameterType}},
+{{/each}}
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..5a2d6cb05 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';
@@ -16,7 +16,6 @@ import {zeroExConfigSchema} from './schemas/zero_ex_config_schema';
import {
ECSignature,
Order,
- OrderStateWatcherConfig,
SignedOrder,
TransactionReceiptWithDecodedLogs,
Web3Provider,
@@ -26,8 +25,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/bignumber_config.ts b/packages/0x.js/src/bignumber_config.ts
deleted file mode 100644
index 2d5214e6f..000000000
--- a/packages/0x.js/src/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/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/exchange_wrapper.ts b/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts
index 1e9865395..9bed40079 100644
--- a/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts
+++ b/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts
@@ -15,9 +15,7 @@ import {
ExchangeContractEventArgs,
ExchangeEvents,
IndexedFilterValues,
- LogCancelContractEventArgs,
LogErrorContractEventArgs,
- LogFillContractEventArgs,
LogWithDecodedArgs,
MethodOpts,
Order,
@@ -26,7 +24,6 @@ import {
OrderFillRequest,
OrderTransactionOpts,
OrderValues,
- RawLog,
SignedOrder,
SubscriptionOpts,
ValidateOrderFillableOpts,
@@ -88,7 +85,7 @@ export class ExchangeWrapper extends ContractWrapper {
tokenWrapper: TokenWrapper, contractAddressIfExists?: string) {
super(web3Wrapper, networkId, abiDecoder);
this._tokenWrapper = tokenWrapper;
- this._orderValidationUtils = new OrderValidationUtils(tokenWrapper, this);
+ this._orderValidationUtils = new OrderValidationUtils(this);
this._contractAddressIfExists = contractAddressIfExists;
}
/**
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/contract_wrappers/token_registry_wrapper.ts b/packages/0x.js/src/contract_wrappers/token_registry_wrapper.ts
index 064b826d8..69e9d7e21 100644
--- a/packages/0x.js/src/contract_wrappers/token_registry_wrapper.ts
+++ b/packages/0x.js/src/contract_wrappers/token_registry_wrapper.ts
@@ -2,7 +2,7 @@ import {Web3Wrapper} from '@0xproject/web3-wrapper';
import * as _ from 'lodash';
import {artifacts} from '../artifacts';
-import {Token, TokenMetadata, ZeroExError} from '../types';
+import {Token, TokenMetadata} from '../types';
import {assert} from '../utils/assert';
import {constants} from '../utils/constants';
@@ -36,8 +36,6 @@ export class TokenRegistryWrapper extends ContractWrapper {
* @return An array of objects that conform to the Token interface.
*/
public async getTokensAsync(): Promise<Token[]> {
- const tokenRegistryContract = await this._getTokenRegistryContractAsync();
-
const addresses = await this.getTokenAddressesAsync();
const tokenPromises: Array<Promise<Token|undefined>> = _.map(
addresses,
diff --git a/packages/0x.js/src/contract_wrappers/token_transfer_proxy_wrapper.ts b/packages/0x.js/src/contract_wrappers/token_transfer_proxy_wrapper.ts
index 1a16e3540..c67ef87df 100644
--- a/packages/0x.js/src/contract_wrappers/token_transfer_proxy_wrapper.ts
+++ b/packages/0x.js/src/contract_wrappers/token_transfer_proxy_wrapper.ts
@@ -2,7 +2,6 @@ import {Web3Wrapper} from '@0xproject/web3-wrapper';
import * as _ from 'lodash';
import {artifacts} from '../artifacts';
-import {ZeroExError} from '../types';
import {ContractWrapper} from './contract_wrapper';
import {TokenTransferProxyContract} from './generated/token_transfer_proxy';
diff --git a/packages/0x.js/src/contract_wrappers/token_wrapper.ts b/packages/0x.js/src/contract_wrappers/token_wrapper.ts
index 684f291a5..d1553fa7b 100644
--- a/packages/0x.js/src/contract_wrappers/token_wrapper.ts
+++ b/packages/0x.js/src/contract_wrappers/token_wrapper.ts
@@ -23,8 +23,6 @@ import {ContractWrapper} from './contract_wrapper';
import {TokenContract} from './generated/token';
import {TokenTransferProxyWrapper} from './token_transfer_proxy_wrapper';
-const ALLOWANCE_TO_ZERO_GAS_AMOUNT = 47275;
-
/**
* This class includes all the functionality related to interacting with ERC20 token contracts.
* All ERC20 method calls are supported, along with some convenience methods for getting/setting allowances
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..197dfae65 100644
--- a/packages/0x.js/src/order_watcher/event_watcher.ts
+++ b/packages/0x.js/src/order_watcher/event_watcher.ts
@@ -1,17 +1,14 @@
+import {intervalUtils} from '@0xproject/utils';
import {Web3Wrapper} from '@0xproject/web3-wrapper';
import * as _ from 'lodash';
import * as Web3 from 'web3';
import {
BlockParamLiteral,
- EventCallback,
EventWatcherCallback,
ZeroExError,
} 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..91e8151fd 100644
--- a/packages/0x.js/src/order_watcher/expiration_watcher.ts
+++ b/packages/0x.js/src/order_watcher/expiration_watcher.ts
@@ -1,10 +1,9 @@
+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 {ZeroExError} from '../types';
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..c4a9eb1ad 100644
--- a/packages/0x.js/src/order_watcher/order_state_watcher.ts
+++ b/packages/0x.js/src/order_watcher/order_state_watcher.ts
@@ -1,9 +1,9 @@
import {schemas} from '@0xproject/json-schemas';
+import {intervalUtils} from '@0xproject/utils';
import {Web3Wrapper} from '@0xproject/web3-wrapper';
import * as _ from 'lodash';
import {ZeroEx} from '../0x';
-import {artifacts} from '../artifacts';
import {ExchangeWrapper} from '../contract_wrappers/exchange_wrapper';
import {TokenWrapper} from '../contract_wrappers/token_wrapper';
import {BalanceAndProxyAllowanceLazyStore} from '../stores/balance_proxy_allowance_lazy_store';
@@ -24,12 +24,10 @@ import {
SignedOrder,
TokenEvents,
TransferContractEventArgs,
- Web3Provider,
ZeroExError,
} 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/stores/balance_proxy_allowance_lazy_store.ts b/packages/0x.js/src/stores/balance_proxy_allowance_lazy_store.ts
index 6225e9e72..cde1ef095 100644
--- a/packages/0x.js/src/stores/balance_proxy_allowance_lazy_store.ts
+++ b/packages/0x.js/src/stores/balance_proxy_allowance_lazy_store.ts
@@ -1,6 +1,5 @@
import {BigNumber} from 'bignumber.js';
import * as _ from 'lodash';
-import * as Web3 from 'web3';
import {TokenWrapper} from '../contract_wrappers/token_wrapper';
import {BlockParamLiteral} from '../types';
diff --git a/packages/0x.js/src/stores/order_filled_cancelled_lazy_store.ts b/packages/0x.js/src/stores/order_filled_cancelled_lazy_store.ts
index 28b32f9e2..b35355e38 100644
--- a/packages/0x.js/src/stores/order_filled_cancelled_lazy_store.ts
+++ b/packages/0x.js/src/stores/order_filled_cancelled_lazy_store.ts
@@ -1,6 +1,5 @@
import {BigNumber} from 'bignumber.js';
import * as _ from 'lodash';
-import * as Web3 from 'web3';
import {ExchangeWrapper} from '../contract_wrappers/exchange_wrapper';
import {BlockParamLiteral} from '../types';
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/src/utils/assert.ts b/packages/0x.js/src/utils/assert.ts
index 4cf6caf77..86a6a7c01 100644
--- a/packages/0x.js/src/utils/assert.ts
+++ b/packages/0x.js/src/utils/assert.ts
@@ -1,15 +1,15 @@
import {assert as sharedAssert} from '@0xproject/assert';
-import {Schema, SchemaValidator} from '@0xproject/json-schemas';
+// We need those two unused imports because they're actually used by sharedAssert which gets injected here
+// tslint:disable-next-line:no-unused-variable
+import {Schema} from '@0xproject/json-schemas';
import {Web3Wrapper} from '@0xproject/web3-wrapper';
-import BigNumber from 'bignumber.js';
+// tslint:disable-next-line:no-unused-variable
+import * as BigNumber from 'bignumber.js';
import * as _ from 'lodash';
-import * as Web3 from 'web3';
import {ECSignature} from '../types';
import {signatureUtils} from '../utils/signature_utils';
-const HEX_REGEX = /^0x[0-9A-F]*$/i;
-
export const assert = {
...sharedAssert,
isValidSignature(orderHash: string, ecSignature: ECSignature, signerAddress: string) {
diff --git a/packages/0x.js/src/utils/class_utils.ts b/packages/0x.js/src/utils/class_utils.ts
deleted file mode 100644
index 04e60ee57..000000000
--- a/packages/0x.js/src/utils/class_utils.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-import * as _ from 'lodash';
-
-export const classUtils = {
- // This is useful for classes that have nested methods. Nested methods don't get bound out of the box.
- bindAll(self: any, exclude: string[] = ['contructor'], thisArg?: any): void {
- for (const key of Object.getOwnPropertyNames(self)) {
- const val = self[key];
- if (!_.includes(exclude, key)) {
- if (_.isFunction(val)) {
- self[key] = val.bind(thisArg || self);
- } else if (_.isObject(val)) {
- classUtils.bindAll(val, exclude, self);
- }
- }
- }
- return self;
- },
-};
diff --git a/packages/0x.js/src/utils/interval_utils.ts b/packages/0x.js/src/utils/interval_utils.ts
deleted file mode 100644
index 62b79f2f5..000000000
--- a/packages/0x.js/src/utils/interval_utils.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import * as _ from 'lodash';
-
-export const intervalUtils = {
- setAsyncExcludingInterval(fn: () => Promise<void>, intervalMs: number) {
- let locked = false;
- const intervalId = setInterval(async () => {
- if (locked) {
- return;
- } else {
- locked = true;
- await fn();
- locked = false;
- }
- }, intervalMs);
- return intervalId;
- },
- clearAsyncExcludingInterval(intervalId: NodeJS.Timer): void {
- clearInterval(intervalId);
- },
-};
diff --git a/packages/0x.js/src/utils/order_state_utils.ts b/packages/0x.js/src/utils/order_state_utils.ts
index 6b7f811ae..a0985d028 100644
--- a/packages/0x.js/src/utils/order_state_utils.ts
+++ b/packages/0x.js/src/utils/order_state_utils.ts
@@ -1,24 +1,19 @@
import BigNumber from 'bignumber.js';
import * as _ from 'lodash';
-import * as Web3 from 'web3';
import {ZeroEx} from '../0x';
import {ExchangeWrapper} from '../contract_wrappers/exchange_wrapper';
-import {TokenWrapper} from '../contract_wrappers/token_wrapper';
import {RemainingFillableCalculator} from '../order_watcher/remaining_fillable_calculator';
import {BalanceAndProxyAllowanceLazyStore} from '../stores/balance_proxy_allowance_lazy_store';
import {OrderFilledCancelledLazyStore} from '../stores/order_filled_cancelled_lazy_store';
import {
ExchangeContractErrs,
- MethodOpts,
OrderRelevantState,
OrderState,
OrderStateInvalid,
OrderStateValid,
SignedOrder,
} from '../types';
-import {constants} from '../utils/constants';
-import {utils} from '../utils/utils';
const ACCEPTABLE_RELATIVE_ROUNDING_ERROR = 0.0001;
diff --git a/packages/0x.js/src/utils/order_validation_utils.ts b/packages/0x.js/src/utils/order_validation_utils.ts
index d514483e0..9185eef2b 100644
--- a/packages/0x.js/src/utils/order_validation_utils.ts
+++ b/packages/0x.js/src/utils/order_validation_utils.ts
@@ -3,7 +3,6 @@ import * as _ from 'lodash';
import {ZeroEx} from '../0x';
import {ExchangeWrapper} from '../contract_wrappers/exchange_wrapper';
-import {TokenWrapper} from '../contract_wrappers/token_wrapper';
import {ExchangeContractErrs, Order, SignedOrder, TradeSide, TransferType, ZeroExError} from '../types';
import {constants} from '../utils/constants';
import {utils} from '../utils/utils';
@@ -11,7 +10,6 @@ import {utils} from '../utils/utils';
import {ExchangeTransferSimulator} from './exchange_transfer_simulator';
export class OrderValidationUtils {
- private tokenWrapper: TokenWrapper;
private exchangeWrapper: ExchangeWrapper;
public static validateCancelOrderThrowIfInvalid(
order: Order, cancelTakerTokenAmount: BigNumber, unavailableTakerTokenAmount: BigNumber,
@@ -84,8 +82,7 @@ export class OrderValidationUtils {
.round(0);
return fillMakerTokenAmount;
}
- constructor(tokenWrapper: TokenWrapper, exchangeWrapper: ExchangeWrapper) {
- this.tokenWrapper = tokenWrapper;
+ constructor(exchangeWrapper: ExchangeWrapper) {
this.exchangeWrapper = exchangeWrapper;
}
public async validateOrderFillableOrThrowAsync(
diff --git a/packages/0x.js/test/0x.js_test.ts b/packages/0x.js/test/0x.js_test.ts
index 6b7a70699..e1ceb12c8 100644
--- a/packages/0x.js/test/0x.js_test.ts
+++ b/packages/0x.js/test/0x.js_test.ts
@@ -1,18 +1,18 @@
+import {BlockchainLifecycle} from '@0xproject/dev-utils';
import BigNumber from 'bignumber.js';
import * as chai from 'chai';
import * as _ from 'lodash';
import 'mocha';
import * as Sinon from 'sinon';
-import {ApprovalContractEventArgs, LogWithDecodedArgs, Order, TokenEvents, ZeroEx, ZeroExError} from '../src';
+import {ApprovalContractEventArgs, LogWithDecodedArgs, Order, TokenEvents, ZeroEx} 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/artifacts_test.ts b/packages/0x.js/test/artifacts_test.ts
index f4599a24d..d12346db3 100644
--- a/packages/0x.js/test/artifacts_test.ts
+++ b/packages/0x.js/test/artifacts_test.ts
@@ -1,4 +1,3 @@
-import * as chai from 'chai';
import * as fs from 'fs';
import HDWalletProvider = require('truffle-hdwallet-provider');
@@ -8,7 +7,6 @@ import {chaiSetup} from './utils/chai_setup';
import {constants} from './utils/constants';
chaiSetup.configure();
-const expect = chai.expect;
// Those tests are slower cause they're talking to a remote node
const TIMEOUT = 10000;
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/event_watcher_test.ts b/packages/0x.js/test/event_watcher_test.ts
index 3d92c62a3..95af99268 100644
--- a/packages/0x.js/test/event_watcher_test.ts
+++ b/packages/0x.js/test/event_watcher_test.ts
@@ -1,5 +1,4 @@
import {Web3Wrapper} from '@0xproject/web3-wrapper';
-import BigNumber from 'bignumber.js';
import * as chai from 'chai';
import * as _ from 'lodash';
import 'mocha';
@@ -7,15 +6,12 @@ import * as Sinon from 'sinon';
import * as Web3 from 'web3';
import {
- DecodedLogEvent,
LogEvent,
- ZeroEx,
} from '../src';
import {EventWatcher} from '../src/order_watcher/event_watcher';
import {DoneCallback} from '../src/types';
import {chaiSetup} from './utils/chai_setup';
-import {constants} from './utils/constants';
import {web3Factory} from './utils/web3_factory';
chaiSetup.configure();
@@ -26,7 +22,6 @@ describe('EventWatcher', () => {
let stubs: Sinon.SinonStub[] = [];
let eventWatcher: EventWatcher;
let web3Wrapper: Web3Wrapper;
- const numConfirmations = 0;
const logA: Web3.LogEntry = {
address: '0x71d271f8b14adef568f8f28f1587ce7271ac4ca5',
blockHash: null,
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..51b511dbf 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';
@@ -8,7 +9,6 @@ import {
ExchangeContractErrs,
ExchangeEvents,
LogCancelContractEventArgs,
- LogEvent,
LogFillContractEventArgs,
OrderCancellationRequest,
OrderFillRequest,
@@ -19,7 +19,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 +27,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 +52,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 +71,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 +201,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 +436,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 +557,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 +634,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 +732,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 +767,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..30c395f00 100644
--- a/packages/0x.js/test/expiration_watcher_test.ts
+++ b/packages/0x.js/test/expiration_watcher_test.ts
@@ -1,4 +1,4 @@
-import {Web3Wrapper} from '@0xproject/web3-wrapper';
+import {BlockchainLifecycle} from '@0xproject/dev-utils';
import BigNumber from 'bignumber.js';
import * as chai from 'chai';
import * as _ from 'lodash';
@@ -12,8 +12,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 +21,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 +56,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..df32c7f14 100644
--- a/packages/0x.js/test/order_state_watcher_test.ts
+++ b/packages/0x.js/test/order_state_watcher_test.ts
@@ -1,4 +1,4 @@
-import {Web3Wrapper} from '@0xproject/web3-wrapper';
+import {BlockchainLifecycle} from '@0xproject/dev-utils';
import BigNumber from 'bignumber.js';
import * as chai from 'chai';
import * as _ from 'lodash';
@@ -6,22 +6,17 @@ import 'mocha';
import * as Web3 from 'web3';
import {
- DecodedLogEvent,
ExchangeContractErrs,
- LogEvent,
OrderState,
OrderStateInvalid,
OrderStateValid,
SignedOrder,
Token,
ZeroEx,
- ZeroExConfig,
ZeroExError,
} from '../src';
-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 +28,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;
@@ -48,7 +43,6 @@ describe('OrderStateWatcher', () => {
let takerToken: Token;
let maker: string;
let taker: string;
- let web3Wrapper: Web3Wrapper;
let signedOrder: SignedOrder;
const config = {
networkId: constants.TESTRPC_NETWORK_ID,
@@ -65,8 +59,8 @@ describe('OrderStateWatcher', () => {
tokenUtils = new TokenUtils(tokens);
zrxTokenAddress = tokenUtils.getProtocolTokenOrThrow().address;
fillScenarios = new FillScenarios(zeroEx, userAddresses, tokens, zrxTokenAddress, exchangeContractAddress);
- [makerToken, takerToken] = tokenUtils.getNonProtocolTokens();
- web3Wrapper = (zeroEx as any)._web3Wrapper;
+ await fillScenarios.initTokenBalancesAsync();
+ [makerToken, takerToken] = tokenUtils.getDummyTokens();
});
beforeEach(async () => {
await blockchainLifecycle.startAsync();
@@ -141,7 +135,6 @@ describe('OrderStateWatcher', () => {
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
makerToken.address, takerToken.address, maker, taker, fillableAmount,
);
- const orderHash = ZeroEx.getOrderHashHex(signedOrder);
zeroEx.orderStateWatcher.addOrder(signedOrder);
const callback = reportCallbackErrors(done)((orderState: OrderState) => {
throw new Error('OrderState callback fired for irrelevant order');
@@ -150,7 +143,6 @@ describe('OrderStateWatcher', () => {
const notTheMaker = userAddresses[0];
const anyRecipient = taker;
const transferAmount = new BigNumber(2);
- const notTheMakerBalance = await zeroEx.token.getBalanceAsync(makerToken.address, notTheMaker);
await zeroEx.token.transferAsync(makerToken.address, notTheMaker, anyRecipient, transferAmount);
setTimeout(() => {
done();
@@ -207,8 +199,6 @@ describe('OrderStateWatcher', () => {
);
const makerBalance = await zeroEx.token.getBalanceAsync(makerToken.address, maker);
- const takerBalance = await zeroEx.token.getBalanceAsync(makerToken.address, taker);
-
const fillAmountInBaseUnits = new BigNumber(2);
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
zeroEx.orderStateWatcher.addOrder(signedOrder);
@@ -241,11 +231,10 @@ describe('OrderStateWatcher', () => {
signedOrder = await fillScenarios.createFillableSignedOrderWithFeesAsync(
makerToken.address, takerToken.address, makerFee, takerFee, maker, taker, fillableAmount,
taker);
- const orderHash = ZeroEx.getOrderHashHex(signedOrder);
- zeroEx.orderStateWatcher.addOrder(signedOrder);
const callback = reportCallbackErrors(done)((orderState: OrderState) => {
done();
});
+ zeroEx.orderStateWatcher.addOrder(signedOrder);
zeroEx.orderStateWatcher.subscribe(callback);
await zeroEx.token.setProxyAllowanceAsync(zrxTokenAddress, maker, new BigNumber(0));
})().catch(done);
@@ -259,8 +248,6 @@ describe('OrderStateWatcher', () => {
makerToken.address, takerToken.address, maker, taker, makerFillableAmount,
takerFillableAmount,
);
- const makerBalance = await zeroEx.token.getBalanceAsync(makerToken.address, maker);
- const takerBalance = await zeroEx.token.getBalanceAsync(makerToken.address, taker);
const fillAmountInBaseUnits = ZeroEx.toBaseUnitAmount(new BigNumber(2), decimals);
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
zeroEx.orderStateWatcher.addOrder(signedOrder);
@@ -288,8 +275,6 @@ describe('OrderStateWatcher', () => {
makerToken.address, takerToken.address, maker, taker, fillableAmount,
);
- const makerBalance = await zeroEx.token.getBalanceAsync(makerToken.address, maker);
-
const changedMakerApprovalAmount = ZeroEx.toBaseUnitAmount(new BigNumber(3), decimals);
zeroEx.orderStateWatcher.addOrder(signedOrder);
@@ -342,8 +327,6 @@ describe('OrderStateWatcher', () => {
makerToken.address, takerToken.address, makerFee, takerFee, maker,
taker, fillableAmount, feeRecipient);
- const makerBalance = await zeroEx.token.getBalanceAsync(makerToken.address, maker);
-
const remainingTokenAmount = ZeroEx.toBaseUnitAmount(new BigNumber(4), decimals);
const transferTokenAmount = makerFee.sub(remainingTokenAmount);
zeroEx.orderStateWatcher.addOrder(signedOrder);
@@ -369,10 +352,7 @@ describe('OrderStateWatcher', () => {
makerToken.address, takerToken.address, makerFee, takerFee, maker,
taker, fillableAmount, feeRecipient);
- const makerBalance = await zeroEx.token.getBalanceAsync(makerToken.address, maker);
-
const remainingFeeAmount = ZeroEx.toBaseUnitAmount(new BigNumber(3), decimals);
- const transferFeeAmount = makerFee.sub(remainingFeeAmount);
const remainingTokenAmount = ZeroEx.toBaseUnitAmount(new BigNumber(4), decimals);
const transferTokenAmount = makerFee.sub(remainingTokenAmount);
@@ -400,7 +380,6 @@ describe('OrderStateWatcher', () => {
makerToken.address, takerToken.address, makerFee, takerFee, maker,
taker, fillableAmount, feeRecipient);
- const makerBalance = await zeroEx.token.getBalanceAsync(makerToken.address, maker);
zeroEx.orderStateWatcher.addOrder(signedOrder);
const callback = reportCallbackErrors(done)((orderState: OrderState) => {
@@ -433,7 +412,6 @@ describe('OrderStateWatcher', () => {
});
zeroEx.orderStateWatcher.subscribe(callback);
- const shouldThrowOnInsufficientBalanceOrAllowance = true;
await zeroEx.exchange.cancelOrderAsync(signedOrder, fillableAmount);
})().catch(done);
});
@@ -465,9 +443,6 @@ describe('OrderStateWatcher', () => {
makerToken.address, takerToken.address, maker, taker, fillableAmount,
);
- const makerBalance = await zeroEx.token.getBalanceAsync(makerToken.address, maker);
- const takerBalance = await zeroEx.token.getBalanceAsync(makerToken.address, taker);
-
const cancelAmountInBaseUnits = new BigNumber(2);
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
zeroEx.orderStateWatcher.addOrder(signedOrder);
diff --git a/packages/0x.js/test/order_validation_test.ts b/packages/0x.js/test/order_validation_test.ts
index d585c1f3c..b36a513fe 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;
@@ -34,7 +34,6 @@ describe('OrderValidation', () => {
let makerAddress: string;
let takerAddress: string;
let feeRecipient: string;
- let orderValidationUtils: OrderValidationUtils;
const fillableAmount = new BigNumber(5);
const fillTakerAmount = new BigNumber(5);
const config = {
@@ -50,10 +49,9 @@ 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);
});
beforeEach(async () => {
await blockchainLifecycle.startAsync();
@@ -181,17 +179,15 @@ describe('OrderValidation', () => {
});
describe('validateCancelOrderAndThrowIfInvalidAsync', () => {
let signedOrder: SignedOrder;
- let orderHashHex: string;
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(
makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
);
- orderHashHex = ZeroEx.getOrderHashHex(signedOrder);
});
it('should throw when cancel amount is zero', async () => {
const zeroCancelAmount = new BigNumber(0);
@@ -204,7 +200,6 @@ describe('OrderValidation', () => {
makerTokenAddress, takerTokenAddress, makerAddress, takerAddress,
fillableAmount, expirationInPast,
);
- orderHashHex = ZeroEx.getOrderHashHex(expiredSignedOrder);
return expect(zeroEx.exchange.validateCancelOrderThrowIfInvalidAsync(expiredSignedOrder, cancelAmount))
.to.be.rejectedWith(ExchangeContractErrs.OrderCancelExpired);
});
diff --git a/packages/0x.js/test/remaining_fillable_calculator_test.ts b/packages/0x.js/test/remaining_fillable_calculator_test.ts
index 610bf9b1a..95ef0a4f1 100644
--- a/packages/0x.js/test/remaining_fillable_calculator_test.ts
+++ b/packages/0x.js/test/remaining_fillable_calculator_test.ts
@@ -2,12 +2,11 @@ import BigNumber from 'bignumber.js';
import * as chai from 'chai';
import 'mocha';
-import { ZeroEx } from '../src/0x';
-import { RemainingFillableCalculator } from '../src/order_watcher/remaining_fillable_calculator';
-import { ECSignature, SignedOrder } from '../src/types';
+import {ZeroEx} from '../src/0x';
+import {RemainingFillableCalculator} from '../src/order_watcher/remaining_fillable_calculator';
+import {ECSignature, SignedOrder} from '../src/types';
-import { chaiSetup } from './utils/chai_setup';
-import { TokenUtils } from './utils/token_utils';
+import {chaiSetup} from './utils/chai_setup';
chaiSetup.configure();
const expect = chai.expect;
@@ -27,7 +26,7 @@ describe('RemainingFillableCalculator', () => {
const decimals: number = 4;
const zero: BigNumber = new BigNumber(0);
const zeroAddress = '0x0';
- const signature: ECSignature = { v: 27, r: '', s: ''};
+ const signature: ECSignature = {v: 27, r: '', s: ''};
beforeEach(async () => {
[makerAmount, takerAmount, makerFeeAmount] = [ZeroEx.toBaseUnitAmount(new BigNumber(50), decimals),
ZeroEx.toBaseUnitAmount(new BigNumber(5), decimals),
diff --git a/packages/0x.js/test/subscription_test.ts b/packages/0x.js/test/subscription_test.ts
index 3aeeaa109..43e6b63b6 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';
@@ -11,27 +12,23 @@ import {
Token,
TokenEvents,
ZeroEx,
- ZeroExError,
} from '../src';
-import {BlockParamLiteral, DoneCallback} from '../src/types';
+import {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';
-import {TokenUtils} from './utils/token_utils';
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;
let zeroEx: ZeroEx;
let userAddresses: string[];
let tokens: Token[];
- let tokenUtils: TokenUtils;
let coinbase: string;
let addressWithoutFunds: string;
const config = {
@@ -42,7 +39,6 @@ describe('SubscriptionTest', () => {
zeroEx = new ZeroEx(web3.currentProvider, config);
userAddresses = await zeroEx.getAvailableAddressesAsync();
tokens = await zeroEx.tokenRegistry.getTokensAsync();
- tokenUtils = new TokenUtils(tokens);
coinbase = userAddresses[0];
addressWithoutFunds = userAddresses[1];
});
@@ -54,9 +50,7 @@ describe('SubscriptionTest', () => {
});
describe('#subscribe', () => {
const indexFilterValues = {};
- const shouldThrowOnInsufficientBalanceOrAllowance = true;
let tokenAddress: string;
- const transferAmount = new BigNumber(42);
const allowanceAmount = new BigNumber(42);
let stubs: Sinon.SinonStub[] = [];
before(() => {
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_transfer_proxy_wrapper_test.ts b/packages/0x.js/test/token_transfer_proxy_wrapper_test.ts
index 05861d112..9674b64ac 100644
--- a/packages/0x.js/test/token_transfer_proxy_wrapper_test.ts
+++ b/packages/0x.js/test/token_transfer_proxy_wrapper_test.ts
@@ -1,7 +1,6 @@
import * as chai from 'chai';
import {ZeroEx} from '../src';
-import {TokenTransferProxyWrapper} from '../src/contract_wrappers/token_transfer_proxy_wrapper';
import {chaiSetup} from './utils/chai_setup';
import {constants} from './utils/constants';
diff --git a/packages/0x.js/test/token_wrapper_test.ts b/packages/0x.js/test/token_wrapper_test.ts
index ae6016869..70637dbfe 100644
--- a/packages/0x.js/test/token_wrapper_test.ts
+++ b/packages/0x.js/test/token_wrapper_test.ts
@@ -1,4 +1,4 @@
-import {promisify} from '@0xproject/utils';
+import {BlockchainLifecycle} from '@0xproject/dev-utils';
import {Web3Wrapper} from '@0xproject/web3-wrapper';
import BigNumber from 'bignumber.js';
import * as chai from 'chai';
@@ -7,13 +7,9 @@ import * as Web3 from 'web3';
import {
ApprovalContractEventArgs,
- ContractEvent,
DecodedLogEvent,
- LogEvent,
- LogWithDecodedArgs,
SubscriptionOpts,
Token,
- TokenContractEventArgs,
TokenEvents,
TransferContractEventArgs,
ZeroEx,
@@ -21,7 +17,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 +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('TokenWrapper', () => {
let web3: Web3;
@@ -71,8 +66,7 @@ describe('TokenWrapper', () => {
const toAddress = addressWithoutFunds;
const preBalance = await zeroEx.token.getBalanceAsync(token.address, toAddress);
expect(preBalance).to.be.bignumber.equal(0);
- const txHash = await zeroEx.token.transferAsync(token.address, fromAddress, toAddress, transferAmount);
- const receipt = await zeroEx.awaitTransactionMinedAsync(txHash);
+ await zeroEx.token.transferAsync(token.address, fromAddress, toAddress, transferAmount);
const postBalance = await zeroEx.token.getBalanceAsync(token.address, toAddress);
return expect(postBalance).to.be.bignumber.equal(transferAmount);
});
@@ -354,7 +348,6 @@ describe('TokenWrapper', () => {
});
describe('#subscribe', () => {
const indexFilterValues = {};
- const shouldThrowOnInsufficientBalanceOrAllowance = true;
let tokenAddress: string;
const transferAmount = new BigNumber(42);
const allowanceAmount = new BigNumber(42);
diff --git a/packages/0x.js/test/utils/blockchain_lifecycle.ts b/packages/0x.js/test/utils/blockchain_lifecycle.ts
deleted file mode 100644
index 9a44ccd6f..000000000
--- a/packages/0x.js/test/utils/blockchain_lifecycle.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-import {RPC} from './rpc';
-
-export class BlockchainLifecycle {
- private rpc: RPC;
- private snapshotIdsStack: number[];
- constructor() {
- this.rpc = new RPC();
- this.snapshotIdsStack = [];
- }
- // TODO: In order to run these tests on an actual node, we should check if we are running against
- // TestRPC, if so, use snapshots, otherwise re-deploy contracts before every test
- public async startAsync(): Promise<void> {
- const snapshotId = await this.rpc.takeSnapshotAsync();
- this.snapshotIdsStack.push(snapshotId);
- }
- public async revertAsync(): Promise<void> {
- const snapshotId = this.snapshotIdsStack.pop() as number;
- const didRevert = await this.rpc.revertSnapshotAsync(snapshotId);
- if (!didRevert) {
- throw new Error(`Snapshot with id #${snapshotId} failed to revert`);
- }
- }
- public async mineABlock(): Promise<void> {
- await this.rpc.mineBlockAsync();
- }
-}
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/report_callback_errors.ts b/packages/0x.js/test/utils/report_callback_errors.ts
index 8a8f4d966..0aaef3f05 100644
--- a/packages/0x.js/test/utils/report_callback_errors.ts
+++ b/packages/0x.js/test/utils/report_callback_errors.ts
@@ -1,4 +1,4 @@
-import { DoneCallback } from '../../src/types';
+import {DoneCallback} from '../../src/types';
export const reportCallbackErrors = (done: DoneCallback) => {
return (f: (...args: any[]) => void) => {
diff --git a/packages/0x.js/test/utils/rpc.ts b/packages/0x.js/test/utils/rpc.ts
deleted file mode 100644
index 309a96d5e..000000000
--- a/packages/0x.js/test/utils/rpc.ts
+++ /dev/null
@@ -1,58 +0,0 @@
-import * as ethUtil from 'ethereumjs-util';
-import * as request from 'request-promise-native';
-
-import {constants} from './constants';
-
-export class RPC {
- private host: string;
- private port: number;
- private id: number;
- constructor() {
- this.host = constants.RPC_HOST;
- this.port = constants.RPC_PORT;
- this.id = 0;
- }
- public async takeSnapshotAsync(): Promise<number> {
- const method = 'evm_snapshot';
- const params: any[] = [];
- const payload = this.toPayload(method, params);
- const snapshotIdHex = await this.sendAsync(payload);
- const snapshotId = ethUtil.bufferToInt(ethUtil.toBuffer(snapshotIdHex));
- return snapshotId;
- }
- public async revertSnapshotAsync(snapshotId: number): Promise<boolean> {
- const method = 'evm_revert';
- const params = [snapshotId];
- const payload = this.toPayload(method, params);
- const didRevert = await this.sendAsync(payload);
- return didRevert;
- }
- public async mineBlockAsync(): Promise<void> {
- const method = 'evm_mine';
- const params: any[] = [];
- const payload = this.toPayload(method, params);
- await this.sendAsync(payload);
- }
- private toPayload(method: string, params: any[] = []): string {
- const payload = JSON.stringify({
- id: this.id,
- method,
- params,
- });
- this.id += 1;
- return payload;
- }
- private async sendAsync(payload: string): Promise<any> {
- const opts = {
- method: 'POST',
- uri: `http://${this.host}:${this.port}`,
- body: payload,
- headers: {
- 'content-type': 'application/json',
- },
- };
- const bodyString = await request(opts);
- const body = JSON.parse(bodyString);
- return body.result;
- }
-}
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;