aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
Diffstat (limited to 'packages')
-rw-r--r--packages/0x.js/.npmignore1
-rw-r--r--packages/0x.js/CHANGELOG.md34
-rw-r--r--packages/0x.js/README.md9
-rw-r--r--packages/0x.js/package.json7
-rw-r--r--packages/0x.js/src/artifacts/TokenRegistry.json2
-rw-r--r--packages/0x.js/src/contract_wrappers/contract_wrapper.ts18
-rw-r--r--packages/0x.js/src/contract_wrappers/exchange_wrapper.ts4
-rw-r--r--packages/0x.js/src/contract_wrappers/generated/.gitignore1
-rw-r--r--packages/0x.js/src/globals.d.ts5
-rw-r--r--packages/0x.js/src/index.ts2
-rw-r--r--packages/0x.js/src/order_watcher/event_watcher.ts10
-rw-r--r--packages/0x.js/src/types.ts11
-rw-r--r--packages/0x.js/src/utils/filter_utils.ts24
-rw-r--r--packages/0x.js/test/0x.js_test.ts4
-rw-r--r--packages/0x.js/test/event_watcher_test.ts13
-rw-r--r--packages/0x.js/tsconfig.json6
-rw-r--r--packages/abi-gen/.npmignore1
-rw-r--r--packages/abi-gen/package.json6
-rw-r--r--packages/abi-gen/src/index.ts8
-rw-r--r--packages/abi-gen/src/types.ts6
-rw-r--r--packages/abi-gen/src/utils.ts11
-rw-r--r--packages/abi-gen/tsconfig.json2
-rw-r--r--packages/assert/.npmignore1
-rw-r--r--packages/assert/README.md16
-rw-r--r--packages/assert/package.json2
-rw-r--r--packages/assert/tsconfig.json7
-rw-r--r--packages/base-contract/.npmignore1
-rw-r--r--packages/base-contract/README.md9
-rw-r--r--packages/base-contract/package.json6
-rw-r--r--packages/base-contract/src/index.ts13
-rw-r--r--packages/base-contract/tsconfig.json6
-rw-r--r--packages/chai-as-promised-typescript-typings/.npmignore3
-rw-r--r--packages/chai-as-promised-typescript-typings/README.md43
-rw-r--r--packages/chai-typescript-typings/CHANGELOG.md3
-rw-r--r--packages/chai-typescript-typings/monorepo_scripts/globals.d.ts6
-rw-r--r--packages/chai-typescript-typings/monorepo_scripts/postpublish.ts8
-rw-r--r--packages/chai-typescript-typings/package.json28
-rw-r--r--packages/chai-typescript-typings/tsconfig.json7
-rw-r--r--packages/chai-typescript-typings/tslint.json3
-rw-r--r--packages/connect/.npmignore1
-rw-r--r--packages/connect/README.md8
-rw-r--r--packages/connect/package.json6
-rw-r--r--packages/connect/tsconfig.json8
-rw-r--r--packages/contract_templates/contract.handlebars4
-rw-r--r--packages/contract_templates/partials/callAsync.handlebars19
-rw-r--r--packages/contract_templates/partials/tx.handlebars27
-rw-r--r--packages/contracts/package.json5
-rw-r--r--packages/contracts/src/contract_wrappers/generated/.gitignore1
-rw-r--r--packages/contracts/tsconfig.json5
-rw-r--r--packages/contracts/util/multi_sig_wrapper.ts5
-rw-r--r--packages/contracts/util/types.ts6
-rw-r--r--packages/deployer/.npmignore1
-rw-r--r--packages/deployer/README.md8
-rw-r--r--packages/deployer/package.json9
-rw-r--r--packages/deployer/solc_bin/.gitignore1
-rw-r--r--packages/deployer/src/cli.ts22
-rw-r--r--packages/deployer/src/commands.ts2
-rw-r--r--packages/deployer/src/compiler.ts239
-rw-r--r--packages/deployer/src/deployer.ts6
-rw-r--r--packages/deployer/src/globals.d.ts3
-rw-r--r--packages/deployer/src/utils/compiler.ts123
-rw-r--r--packages/deployer/src/utils/contract.ts17
-rw-r--r--packages/deployer/src/utils/encoder.ts8
-rw-r--r--packages/deployer/src/utils/error_reporter.ts18
-rw-r--r--packages/deployer/src/utils/fs_wrapper.ts1
-rw-r--r--packages/deployer/src/utils/types.ts30
-rw-r--r--packages/deployer/test/compiler_test.ts47
-rw-r--r--packages/deployer/test/compiler_utils_test.ts74
-rw-r--r--packages/deployer/test/deployer_test.ts (renamed from packages/deployer/test/deploy_test.ts)77
-rw-r--r--packages/deployer/test/util/constants.ts2
-rw-r--r--packages/deployer/tsconfig.json8
-rw-r--r--packages/dev-utils/.npmignore1
-rw-r--r--packages/dev-utils/README.md8
-rw-r--r--packages/dev-utils/package.json2
-rw-r--r--packages/dev-utils/tsconfig.json3
-rw-r--r--packages/ethers-typescript-typings/.npmignore3
-rw-r--r--packages/ethers-typescript-typings/CHANGELOG.md5
-rw-r--r--packages/ethers-typescript-typings/README.md49
-rw-r--r--packages/ethers-typescript-typings/monorepo_scripts/globals.d.ts6
-rw-r--r--packages/ethers-typescript-typings/monorepo_scripts/postpublish.ts8
-rw-r--r--packages/ethers-typescript-typings/package.json36
-rw-r--r--packages/ethers-typescript-typings/tsconfig.json7
-rw-r--r--packages/ethers-typescript-typings/tslint.json3
-rw-r--r--packages/json-schemas/.npmignore1
-rw-r--r--packages/json-schemas/README.md12
-rw-r--r--packages/json-schemas/package.json2
-rw-r--r--packages/json-schemas/tsconfig.json7
-rw-r--r--packages/monorepo-scripts/package.json4
-rw-r--r--packages/monorepo-scripts/src/globals.d.ts19
-rw-r--r--packages/monorepo-scripts/src/test_installation.ts58
-rw-r--r--packages/monorepo-scripts/tsconfig.json3
-rw-r--r--packages/react-docs-example/package.json4
-rw-r--r--packages/react-docs-example/ts/docs.tsx27
-rw-r--r--packages/react-docs/.npmignore1
-rw-r--r--packages/react-docs/README.md8
-rw-r--r--packages/react-docs/package.json4
-rw-r--r--packages/react-docs/tsconfig.json2
-rw-r--r--packages/react-shared/.npmignore1
-rw-r--r--packages/react-shared/README.md8
-rw-r--r--packages/react-shared/package.json4
-rw-r--r--packages/sol-cov/.npmignore1
-rw-r--r--packages/sol-cov/package.json11
-rw-r--r--packages/sol-cov/src/coverage_subprovider.ts14
-rw-r--r--packages/sol-cov/tsconfig.json2
-rw-r--r--packages/sra-report/.npmignore1
-rw-r--r--packages/sra-report/package.json3
-rw-r--r--packages/sra-report/tsconfig.json9
-rw-r--r--packages/subproviders/.npmignore1
-rw-r--r--packages/subproviders/README.md8
-rw-r--r--packages/subproviders/package.json6
-rw-r--r--packages/subproviders/src/globals.d.ts8
-rw-r--r--packages/subproviders/src/index.ts2
-rw-r--r--packages/subproviders/src/subproviders/empty_wallet_subprovider.ts4
-rw-r--r--packages/subproviders/src/subproviders/fake_gas_estimate_subprovider.ts4
-rw-r--r--packages/subproviders/src/subproviders/ganache.ts3
-rw-r--r--packages/subproviders/src/subproviders/injected_web3.ts3
-rw-r--r--packages/subproviders/src/subproviders/ledger.ts4
-rw-r--r--packages/subproviders/src/subproviders/nonce_tracker.ts17
-rw-r--r--packages/subproviders/src/subproviders/redundant_rpc.ts6
-rw-r--r--packages/subproviders/src/subproviders/subprovider.ts5
-rw-r--r--packages/subproviders/src/types.ts7
-rw-r--r--packages/subproviders/test/integration/ledger_subprovider_test.ts11
-rw-r--r--packages/subproviders/test/unit/ledger_subprovider_test.ts17
-rw-r--r--packages/subproviders/test/unit/redundant_rpc_subprovider_test.ts5
-rw-r--r--packages/subproviders/tsconfig.json5
-rw-r--r--packages/testnet-faucets/package.json2
-rw-r--r--packages/testnet-faucets/tsconfig.json4
-rw-r--r--packages/tslint-config/.npmignore1
-rw-r--r--packages/tslint-config/CHANGELOG.md2
-rw-r--r--packages/tslint-config/tsconfig.json3
-rw-r--r--packages/types/.npmignore1
-rw-r--r--packages/types/README.md8
-rw-r--r--packages/types/package.json5
-rw-r--r--packages/types/src/index.ts201
-rw-r--r--packages/types/tsconfig.json3
-rw-r--r--packages/typescript-typings/.npmignore (renamed from packages/chai-typescript-typings/.npmignore)1
-rw-r--r--packages/typescript-typings/CHANGELOG.md (renamed from packages/chai-as-promised-typescript-typings/CHANGELOG.md)0
-rw-r--r--packages/typescript-typings/README.md (renamed from packages/chai-typescript-typings/README.md)12
-rw-r--r--packages/typescript-typings/monorepo_scripts/globals.d.ts (renamed from packages/chai-as-promised-typescript-typings/monorepo_scripts/globals.d.ts)0
-rw-r--r--packages/typescript-typings/monorepo_scripts/postpublish.ts (renamed from packages/chai-as-promised-typescript-typings/monorepo_scripts/postpublish.ts)0
-rw-r--r--packages/typescript-typings/package.json (renamed from packages/chai-as-promised-typescript-typings/package.json)13
-rw-r--r--packages/typescript-typings/tsconfig.json (renamed from packages/chai-as-promised-typescript-typings/tsconfig.json)0
-rw-r--r--packages/typescript-typings/tslint.json (renamed from packages/chai-as-promised-typescript-typings/tslint.json)0
-rw-r--r--packages/typescript-typings/types/chai-as-promised/index.d.ts (renamed from packages/chai-as-promised-typescript-typings/index.d.ts)0
-rw-r--r--packages/typescript-typings/types/chai/index.d.ts (renamed from packages/chai-typescript-typings/index.d.ts)0
-rw-r--r--packages/typescript-typings/types/ethers-contracts/index.d.ts (renamed from packages/ethers-typescript-typings/index.d.ts)0
-rw-r--r--packages/typescript-typings/types/web3/index.d.ts237
-rw-r--r--packages/utils/.npmignore1
-rw-r--r--packages/utils/README.md8
-rw-r--r--packages/utils/package.json5
-rw-r--r--packages/utils/src/abi_decoder.ts27
-rw-r--r--packages/utils/tsconfig.json6
-rw-r--r--packages/web3-typescript-typings/.npmignore3
-rw-r--r--packages/web3-typescript-typings/CHANGELOG.md16
-rw-r--r--packages/web3-typescript-typings/README.md49
-rw-r--r--packages/web3-typescript-typings/index.d.ts440
-rw-r--r--packages/web3-typescript-typings/monorepo_scripts/globals.d.ts6
-rw-r--r--packages/web3-typescript-typings/monorepo_scripts/postpublish.ts8
-rw-r--r--packages/web3-typescript-typings/package.json40
-rw-r--r--packages/web3-typescript-typings/tsconfig.json7
-rw-r--r--packages/web3-typescript-typings/tslint.json3
-rw-r--r--packages/web3-wrapper/.npmignore1
-rw-r--r--packages/web3-wrapper/CHANGELOG.md8
-rw-r--r--packages/web3-wrapper/README.md8
-rw-r--r--packages/web3-wrapper/package.json5
-rw-r--r--packages/web3-wrapper/src/index.ts36
-rw-r--r--packages/web3-wrapper/tsconfig.json6
-rw-r--r--packages/website/package.json7
-rw-r--r--packages/website/ts/blockchain.ts38
-rw-r--r--packages/website/ts/components/dialogs/blockchain_err_dialog.tsx14
-rw-r--r--packages/website/ts/components/dialogs/eth_weth_conversion_dialog.tsx4
-rw-r--r--packages/website/ts/components/dialogs/send_dialog.tsx4
-rw-r--r--packages/website/ts/components/fill_order.tsx6
-rw-r--r--packages/website/ts/components/footer.tsx2
-rw-r--r--packages/website/ts/containers/web3_wrapper_documentation.ts27
-rw-r--r--packages/website/ts/globals.d.ts4
-rw-r--r--packages/website/ts/types.ts1
-rw-r--r--packages/website/ts/utils/configs.ts7
-rw-r--r--packages/website/ts/utils/utils.ts3
-rw-r--r--packages/website/tsconfig.json6
180 files changed, 1373 insertions, 1517 deletions
diff --git a/packages/0x.js/.npmignore b/packages/0x.js/.npmignore
index 7fd911797..6a3eb57bd 100644
--- a/packages/0x.js/.npmignore
+++ b/packages/0x.js/.npmignore
@@ -8,3 +8,4 @@ test/
/contract_templates/
/generated_docs/
/scripts/
+/lib/src/monorepo_scripts/
diff --git a/packages/0x.js/CHANGELOG.md b/packages/0x.js/CHANGELOG.md
index fa3b3db91..ca6b985d3 100644
--- a/packages/0x.js/CHANGELOG.md
+++ b/packages/0x.js/CHANGELOG.md
@@ -2,7 +2,6 @@
## v0.34.0 - _TBD_
- * Update Kovan EtherToken artifact address to match TokenRegistry.
* Fix the bug causing `zeroEx.exchange.fillOrdersUpToAsync` validation to fail if there were some extra orders passed (#470)
## v0.33.2 - _March 18, 2018_
@@ -42,10 +41,7 @@
## v0.31.0 - _January 30, 2018_
- * Add the `shouldAddPersonalMessagePrefix` parameter to `signOrderHashAsync` so that the
- caller can decide on whether to add the personalMessage prefix before relaying the request
- to the signer. Parity Signer, Ledger and TestRPC add the prefix themselves, Metamask expects
- it to have already been added. (#349)
+ * Add the `shouldAddPersonalMessagePrefix` parameter to `signOrderHashAsync` so that the caller can decide on whether to add the personalMessage prefix before relaying the request to the signer. Parity Signer, Ledger and TestRPC add the prefix themselves, Metamask expects it to have already been added. (#349)
## v0.30.2 - _January 29, 2018_
@@ -238,11 +234,11 @@
* Added `zeroEx.token.setUnlimitedAllowanceAsync` (#137)
* Added `zeroEx.token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS` (#137)
-## v0.10.4 - _Aug 24, 2017_
+## v0.10.4 - _August 24, 2017_
* Fixed a bug where checksummed addresses were being pulled from artifacts and not lower-cased. (#135)
-## v0.10.1 - _Aug 24, 2017_
+## v0.10.1 - _August 24, 2017_
* Added `zeroEx.exchange.validateFillOrderThrowIfInvalidAsync` (#128)
* Added `zeroEx.exchange.validateFillOrKillOrderThrowIfInvalidAsync` (#128)
@@ -257,20 +253,20 @@
* Added clear error message when checksummed address is passed to a public method (#124)
* Fixes the description of `shouldThrowOnInsufficientBalanceOrAllowance` in docs (#127)
-## v0.9.3 - _Aug 22, 2017_
+## v0.9.3 - _August 22, 2017_
* Update contract artifacts to include latest Kovan and Mainnet deploys (#118)
-## v0.9.2 - _Aug 21, 2017_
+## v0.9.2 - _August 21, 2017_
* *This version was unpublished because of a publishing issue.*
* Update contract artifacts to include latest Kovan and Mainnet deploys (#118)
-## v0.9.1 - _Aug. 16, 2017_
+## v0.9.1 - _August 16, 2017_
* Fixed the bug causing `zeroEx.token.getBalanceAsync()` to fail if no addresses available (#120)
-## v0.9.0 - _Jul. 26, 2017_
+## v0.9.0 - _July 26, 2017_
* Migrated to the new version of smart contracts (#101)
* Removed the ability to call methods on multiple authorized Exchange smart contracts (#106)
@@ -281,7 +277,7 @@
* Updated to typescript v2.4 (#104)
* Fixed an issue with incorrect balance/allowance validation when ZRX is one of the tokens traded (#109)
-## v0.8.0 - _Jul. 4, 2017_
+## v0.8.0 - _July 4, 2017_
* Added the ability to call methods on different authorized versions of the Exchange smart contract (#82)
* Updated contract artifacts to reflect latest changes to the smart contracts (0xproject/contracts#59)
@@ -294,35 +290,35 @@
* `zeroEx.tokenRegistry.invalidateContractInstance`
* Fixed the bug where `zeroEx.setProviderAsync` didn't invalidate etherToken contract's instance
-## v0.7.1 - _Jun. 26, 2017_
+## v0.7.1 - _June 26, 2017_
* Added the ability to convert Ether to wrapped Ether tokens and back via `zeroEx.etherToken.depostAsync` and `zeroEx.etherToken.withdrawAsync` (#81)
-## v0.7.0 - _Jun. 22, 2017_
+## v0.7.0 - _June 22, 2017_
* Added Kovan smart contract artifacts (#78)
* Started returning fillAmount from `fillOrderAsync` and `fillUpToAsync` (#72)
* Started returning cancelledAmount from `cancelOrderAsync` (#72)
* Renamed type `LogCancelArgs` to `LogCancelContractEventArgs` and `LogFillArgs` to `LogFillContractEventArgs`
-## v0.6.2 - _Jun. 21, 2017_
+## v0.6.2 - _June 21, 2017_
* Reduced bundle size
* Improved documentation
-## v0.6.1 - _Jun. 19, 2017_
+## v0.6.1 - _June 19, 2017_
* Improved documentation
-## v0.6.0 - _Jun. 19, 2017_
+## v0.6.0 - _June 19, 2017_
* Made `ZeroEx` class accept `Web3Provider` instance instead of `Web3` instance
* Added types for contract event arguments
-## v0.5.2 - _Jun. 15, 2017_
+## v0.5.2 - _June 15, 2017_
* Fixed the bug in `postpublish` script that caused that only unminified UMD bundle was uploaded to release page
-## v0.5.1 - _Jun. 15, 2017_
+## v0.5.1 - _June 15, 2017_
* Added `postpublish` script to publish to Github Releases with assets.
diff --git a/packages/0x.js/README.md b/packages/0x.js/README.md
index 2d0394726..5b17dac8b 100644
--- a/packages/0x.js/README.md
+++ b/packages/0x.js/README.md
@@ -20,11 +20,10 @@ import { ZeroEx } from '0x.js';
If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`:
-```
-"include": [
- "./node_modules/web3-typescript-typings/index.d.ts",
- "./node_modules/ethers-typescript-typings/index.d.ts"
-]
+```json
+"compilerOptions": {
+ "typeRoots": ["node_modules/@0xproject/typescript-typings/types", "node_modules/@types"],
+}
```
#### UMD:
diff --git a/packages/0x.js/package.json b/packages/0x.js/package.json
index 5f5b32aac..49d96235c 100644
--- a/packages/0x.js/package.json
+++ b/packages/0x.js/package.json
@@ -68,9 +68,7 @@
"awesome-typescript-loader": "^3.1.3",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
- "chai-as-promised-typescript-typings": "^0.0.12",
"chai-bignumber": "^2.0.1",
- "chai-typescript-typings": "^0.0.6",
"copyfiles": "^1.2.0",
"dirty-chai": "^2.0.1",
"json-loader": "^0.5.4",
@@ -99,18 +97,17 @@
"@0xproject/types": "^0.4.1",
"@0xproject/utils": "^0.4.3",
"@0xproject/web3-wrapper": "^0.3.1",
+ "@0xproject/typescript-typings": "^0.0.1",
"bintrees": "^1.0.2",
"bn.js": "^4.11.8",
"ethereumjs-abi": "^0.6.4",
"ethereumjs-blockstream": "^2.0.6",
"ethereumjs-util": "^5.1.1",
"ethers-contracts": "^2.2.1",
- "ethers-typescript-typings": "^0.0.4",
"js-sha3": "^0.7.0",
"lodash": "^4.17.4",
"uuid": "^3.1.0",
- "web3": "^0.20.0",
- "web3-typescript-typings": "^0.10.2"
+ "web3": "^0.20.0"
},
"publishConfig": {
"access": "public"
diff --git a/packages/0x.js/src/artifacts/TokenRegistry.json b/packages/0x.js/src/artifacts/TokenRegistry.json
index 95bee4b1d..0f583628c 100644
--- a/packages/0x.js/src/artifacts/TokenRegistry.json
+++ b/packages/0x.js/src/artifacts/TokenRegistry.json
@@ -538,7 +538,7 @@
"address": "0x4e9aad8184de8833365fea970cd9149372fdf1e6"
},
"42": {
- "address": "0xd0a1e359811322d97991e03f863a0c30c2cf029c"
+ "address": "0xf18e504561f4347bea557f3d4558f559dddbae7f"
},
"50": {
"address": "0x0b1ba0af832d7c05fd64161e0db78e85978e8082"
diff --git a/packages/0x.js/src/contract_wrappers/contract_wrapper.ts b/packages/0x.js/src/contract_wrappers/contract_wrapper.ts
index ad7727de5..6c96428ed 100644
--- a/packages/0x.js/src/contract_wrappers/contract_wrapper.ts
+++ b/packages/0x.js/src/contract_wrappers/contract_wrapper.ts
@@ -1,4 +1,4 @@
-import { BlockParamLiteral, LogWithDecodedArgs, RawLog } from '@0xproject/types';
+import { BlockParamLiteral, ContractAbi, FilterObject, LogEntry, LogWithDecodedArgs, RawLog } from '@0xproject/types';
import { AbiDecoder, intervalUtils } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import { Block, BlockAndLogStreamer } from 'ethereumjs-blockstream';
@@ -35,7 +35,7 @@ export class ContractWrapper {
private _abiDecoder?: AbiDecoder;
private _blockAndLogStreamerIfExists?: BlockAndLogStreamer;
private _blockAndLogStreamIntervalIfExists?: NodeJS.Timer;
- private _filters: { [filterToken: string]: Web3.FilterObject };
+ private _filters: { [filterToken: string]: FilterObject };
private _filterCallbacks: {
[filterToken: string]: EventCallback<ContractEventArgs>;
};
@@ -75,7 +75,7 @@ export class ContractWrapper {
address: string,
eventName: ContractEvents,
indexFilterValues: IndexedFilterValues,
- abi: Web3.ContractAbi,
+ abi: ContractAbi,
callback: EventCallback<ArgsType>,
): string {
const filter = filterUtils.getFilter(address, eventName, indexFilterValues, abi);
@@ -92,7 +92,7 @@ export class ContractWrapper {
eventName: ContractEvents,
blockRange: BlockRange,
indexFilterValues: IndexedFilterValues,
- abi: Web3.ContractAbi,
+ abi: ContractAbi,
): Promise<Array<LogWithDecodedArgs<ArgsType>>> {
const filter = filterUtils.getFilter(address, eventName, indexFilterValues, abi, blockRange);
const logs = await this._web3Wrapper.getLogsAsync(filter);
@@ -100,7 +100,7 @@ export class ContractWrapper {
return logsWithDecodedArguments;
}
protected _tryToDecodeLogOrNoop<ArgsType extends ContractEventArgs>(
- log: Web3.LogEntry,
+ log: LogEntry,
): LogWithDecodedArgs<ArgsType> | RawLog {
if (_.isUndefined(this._abiDecoder)) {
throw new Error(InternalZeroExError.NoAbiDecoder);
@@ -111,7 +111,7 @@ export class ContractWrapper {
protected async _getContractAbiAndAddressFromArtifactsAsync(
artifact: Artifact,
addressIfExists?: string,
- ): Promise<[Web3.ContractAbi, string]> {
+ ): Promise<[ContractAbi, string]> {
let contractAddress: string;
if (_.isUndefined(addressIfExists)) {
if (_.isUndefined(artifact.networks[this._networkId])) {
@@ -125,7 +125,7 @@ export class ContractWrapper {
if (!doesContractExist) {
throw new Error(CONTRACT_NAME_TO_NOT_FOUND_ERROR[artifact.contract_name]);
}
- const abiAndAddress: [Web3.ContractAbi, string] = [artifact.abi, contractAddress];
+ const abiAndAddress: [ContractAbi, string] = [artifact.abi, contractAddress];
return abiAndAddress;
}
protected _getContractAddress(artifact: Artifact, addressIfExists?: string): string {
@@ -139,8 +139,8 @@ export class ContractWrapper {
return addressIfExists;
}
}
- private _onLogStateChanged<ArgsType extends ContractEventArgs>(isRemoved: boolean, log: Web3.LogEntry): void {
- _.forEach(this._filters, (filter: Web3.FilterObject, filterToken: string) => {
+ private _onLogStateChanged<ArgsType extends ContractEventArgs>(isRemoved: boolean, log: LogEntry): void {
+ _.forEach(this._filters, (filter: FilterObject, filterToken: string) => {
if (filterUtils.matchesFilter(log, filter)) {
const decodedLog = this._tryToDecodeLogOrNoop(log) as LogWithDecodedArgs<ArgsType>;
const logEvent = {
diff --git a/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts b/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts
index 59bd4db6b..6b5a75a9a 100644
--- a/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts
+++ b/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts
@@ -3,6 +3,7 @@ import {
BlockParamLiteral,
DecodedLogArgs,
ECSignature,
+ LogEntry,
LogWithDecodedArgs,
Order,
SignedOrder,
@@ -10,7 +11,6 @@ import {
import { AbiDecoder, BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as _ from 'lodash';
-import * as Web3 from 'web3';
import { artifacts } from '../artifacts';
import {
@@ -863,7 +863,7 @@ export class ExchangeWrapper extends ContractWrapper {
* Checks if logs contain LogError, which is emitted by Exchange contract on transaction failure.
* @param logs Transaction logs as returned by `zeroEx.awaitTransactionMinedAsync`
*/
- public throwLogErrorsAsErrors(logs: Array<LogWithDecodedArgs<DecodedLogArgs> | Web3.LogEntry>): void {
+ public throwLogErrorsAsErrors(logs: Array<LogWithDecodedArgs<DecodedLogArgs> | LogEntry>): void {
const errLog = _.find(logs, {
event: ExchangeEvents.LogError,
});
diff --git a/packages/0x.js/src/contract_wrappers/generated/.gitignore b/packages/0x.js/src/contract_wrappers/generated/.gitignore
deleted file mode 100644
index 72e8ffc0d..000000000
--- a/packages/0x.js/src/contract_wrappers/generated/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-*
diff --git a/packages/0x.js/src/globals.d.ts b/packages/0x.js/src/globals.d.ts
index e2c321f38..3e8ea21bc 100644
--- a/packages/0x.js/src/globals.d.ts
+++ b/packages/0x.js/src/globals.d.ts
@@ -37,12 +37,13 @@ declare module 'ethereumjs-abi' {
// truffle-hdwallet-provider declarations
declare module 'truffle-hdwallet-provider' {
+ import { JSONRPCRequestPayload, JSONRPCResponsePayload } from '@0xproject/types';
import * as Web3 from 'web3';
class HDWalletProvider implements Web3.Provider {
constructor(mnemonic: string, rpcUrl: string);
public sendAsync(
- payload: Web3.JSONRPCRequestPayload,
- callback: (err: Error, result: Web3.JSONRPCResponsePayload) => void,
+ payload: JSONRPCRequestPayload,
+ callback: (err: Error, result: JSONRPCResponsePayload) => void,
): void;
}
export = HDWalletProvider;
diff --git a/packages/0x.js/src/index.ts b/packages/0x.js/src/index.ts
index 7885fb82a..e353a1d3d 100644
--- a/packages/0x.js/src/index.ts
+++ b/packages/0x.js/src/index.ts
@@ -16,7 +16,6 @@ export {
MethodOpts,
OrderTransactionOpts,
TransactionOpts,
- FilterObject,
LogEvent,
DecodedLogEvent,
EventWatcherCallback,
@@ -28,6 +27,7 @@ export {
export {
BlockParamLiteral,
+ FilterObject,
BlockParam,
ContractEventArg,
LogWithDecodedArgs,
diff --git a/packages/0x.js/src/order_watcher/event_watcher.ts b/packages/0x.js/src/order_watcher/event_watcher.ts
index e67b93251..246ab8292 100644
--- a/packages/0x.js/src/order_watcher/event_watcher.ts
+++ b/packages/0x.js/src/order_watcher/event_watcher.ts
@@ -1,9 +1,7 @@
+import { BlockParamLiteral, LogEntry } from '@0xproject/types';
import { intervalUtils } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as _ from 'lodash';
-import * as Web3 from 'web3';
-
-import { BlockParamLiteral } from '@0xproject/types';
import { EventWatcherCallback, ZeroExError } from '../types';
import { assert } from '../utils/assert';
@@ -23,7 +21,7 @@ export class EventWatcher {
private _web3Wrapper: Web3Wrapper;
private _pollingIntervalMs: number;
private _intervalIdIfExists?: NodeJS.Timer;
- private _lastEvents: Web3.LogEntry[] = [];
+ private _lastEvents: LogEntry[] = [];
constructor(web3Wrapper: Web3Wrapper, pollingIntervalIfExistsMs: undefined | number) {
this._web3Wrapper = web3Wrapper;
this._pollingIntervalMs = _.isUndefined(pollingIntervalIfExistsMs)
@@ -69,7 +67,7 @@ export class EventWatcher {
await this._emitDifferencesAsync(newEvents, LogEventState.Added, callback);
this._lastEvents = pendingEvents;
}
- private async _getEventsAsync(): Promise<Web3.LogEntry[]> {
+ private async _getEventsAsync(): Promise<LogEntry[]> {
const eventFilter = {
fromBlock: BlockParamLiteral.Pending,
toBlock: BlockParamLiteral.Pending,
@@ -78,7 +76,7 @@ export class EventWatcher {
return events;
}
private async _emitDifferencesAsync(
- logs: Web3.LogEntry[],
+ logs: LogEntry[],
logEventState: LogEventState,
callback: EventWatcherCallback,
): Promise<void> {
diff --git a/packages/0x.js/src/types.ts b/packages/0x.js/src/types.ts
index 65342b694..38cfb6306 100644
--- a/packages/0x.js/src/types.ts
+++ b/packages/0x.js/src/types.ts
@@ -3,7 +3,10 @@ import { BigNumber } from '@0xproject/utils';
import {
BlockParam,
BlockParamLiteral,
+ ContractAbi,
ContractEventArg,
+ FilterObject,
+ LogEntryEvent,
LogWithDecodedArgs,
Order,
SignedOrder,
@@ -48,7 +51,7 @@ export type OrderAddresses = [string, string, string, string, string];
export type OrderValues = [BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, BigNumber];
-export type LogEvent = Web3.LogEntryEvent;
+export type LogEvent = LogEntryEvent;
export interface DecodedLogEvent<ArgsType> {
isRemoved: boolean;
log: LogWithDecodedArgs<ArgsType>;
@@ -197,7 +200,7 @@ export type ArtifactContractName = 'ZRX' | 'TokenTransferProxy' | 'TokenRegistry
export interface Artifact {
contract_name: ArtifactContractName;
- abi: Web3.ContractAbi;
+ abi: ContractAbi;
networks: {
[networkId: number]: {
address: string;
@@ -222,7 +225,7 @@ export interface ValidateOrderFillableOpts {
* flag when running Parity).
*/
export interface MethodOpts {
- defaultBlock?: Web3.BlockParam;
+ defaultBlock?: BlockParam;
}
/*
@@ -242,8 +245,6 @@ export interface OrderTransactionOpts extends TransactionOpts {
shouldValidate?: boolean;
}
-export type FilterObject = Web3.FilterObject;
-
export enum TradeSide {
Maker = 'maker',
Taker = 'taker',
diff --git a/packages/0x.js/src/utils/filter_utils.ts b/packages/0x.js/src/utils/filter_utils.ts
index 97205ace3..c5df7321e 100644
--- a/packages/0x.js/src/utils/filter_utils.ts
+++ b/packages/0x.js/src/utils/filter_utils.ts
@@ -1,8 +1,16 @@
+import {
+ ConstructorAbi,
+ ContractAbi,
+ EventAbi,
+ FallbackAbi,
+ FilterObject,
+ LogEntry,
+ MethodAbi,
+} from '@0xproject/types';
import * as ethUtil from 'ethereumjs-util';
import * as jsSHA3 from 'js-sha3';
import * as _ from 'lodash';
import * as uuid from 'uuid/v4';
-import * as Web3 from 'web3';
import { BlockRange, ContractEvents, IndexedFilterValues } from '../types';
@@ -16,15 +24,15 @@ export const filterUtils = {
address: string,
eventName: ContractEvents,
indexFilterValues: IndexedFilterValues,
- abi: Web3.ContractAbi,
+ abi: ContractAbi,
blockRange?: BlockRange,
- ): Web3.FilterObject {
- const eventAbi = _.find(abi, { name: eventName }) as Web3.EventAbi;
+ ): FilterObject {
+ const eventAbi = _.find(abi, { name: eventName }) as EventAbi;
const eventSignature = filterUtils.getEventSignatureFromAbiByName(eventAbi, eventName);
const topicForEventSignature = ethUtil.addHexPrefix(jsSHA3.keccak256(eventSignature));
const topicsForIndexedArgs = filterUtils.getTopicsForIndexedArgs(eventAbi, indexFilterValues);
const topics = [topicForEventSignature, ...topicsForIndexedArgs];
- let filter: Web3.FilterObject = {
+ let filter: FilterObject = {
address,
topics,
};
@@ -36,12 +44,12 @@ export const filterUtils = {
}
return filter;
},
- getEventSignatureFromAbiByName(eventAbi: Web3.EventAbi, eventName: ContractEvents): string {
+ getEventSignatureFromAbiByName(eventAbi: EventAbi, eventName: ContractEvents): string {
const types = _.map(eventAbi.inputs, 'type');
const signature = `${eventAbi.name}(${types.join(',')})`;
return signature;
},
- getTopicsForIndexedArgs(abi: Web3.EventAbi, indexFilterValues: IndexedFilterValues): Array<string | null> {
+ getTopicsForIndexedArgs(abi: EventAbi, indexFilterValues: IndexedFilterValues): Array<string | null> {
const topics: Array<string | null> = [];
for (const eventInput of abi.inputs) {
if (!eventInput.indexed) {
@@ -60,7 +68,7 @@ export const filterUtils = {
}
return topics;
},
- matchesFilter(log: Web3.LogEntry, filter: Web3.FilterObject): boolean {
+ matchesFilter(log: LogEntry, filter: FilterObject): boolean {
if (!_.isUndefined(filter.address) && log.address !== filter.address) {
return false;
}
diff --git a/packages/0x.js/test/0x.js_test.ts b/packages/0x.js/test/0x.js_test.ts
index d61847d1d..70e85aa52 100644
--- a/packages/0x.js/test/0x.js_test.ts
+++ b/packages/0x.js/test/0x.js_test.ts
@@ -216,7 +216,7 @@ describe('ZeroEx library', () => {
s: '0x050aa3cc1f2c435e67e114cdce54b9527b4f50548342401bc5d2b77adbdacb02',
};
stubs = [
- Sinon.stub((zeroEx as any)._web3Wrapper, 'signTransactionAsync').returns(Promise.resolve(signature)),
+ Sinon.stub((zeroEx as any)._web3Wrapper, 'signMessageAsync').returns(Promise.resolve(signature)),
Sinon.stub(ZeroEx, 'isValidSignature').returns(true),
];
@@ -237,7 +237,7 @@ describe('ZeroEx library', () => {
s: '0x2dea66f25a608bbae457e020fb6decb763deb8b7192abab624997242da248960',
};
stubs = [
- Sinon.stub((zeroEx as any)._web3Wrapper, 'signTransactionAsync').returns(Promise.resolve(signature)),
+ Sinon.stub((zeroEx as any)._web3Wrapper, 'signMessageAsync').returns(Promise.resolve(signature)),
Sinon.stub(ZeroEx, 'isValidSignature').returns(true),
];
diff --git a/packages/0x.js/test/event_watcher_test.ts b/packages/0x.js/test/event_watcher_test.ts
index 93ee9cd1c..2fa6c0580 100644
--- a/packages/0x.js/test/event_watcher_test.ts
+++ b/packages/0x.js/test/event_watcher_test.ts
@@ -1,4 +1,5 @@
import { web3Factory } from '@0xproject/dev-utils';
+import { LogEntry } from '@0xproject/types';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as chai from 'chai';
import * as _ from 'lodash';
@@ -21,7 +22,7 @@ describe('EventWatcher', () => {
let stubs: Sinon.SinonStub[] = [];
let eventWatcher: EventWatcher;
let web3Wrapper: Web3Wrapper;
- const logA: Web3.LogEntry = {
+ const logA: LogEntry = {
address: '0x71d271f8b14adef568f8f28f1587ce7271ac4ca5',
blockHash: null,
blockNumber: null,
@@ -31,7 +32,7 @@ describe('EventWatcher', () => {
transactionHash: '0x004881d38cd4a8f72f1a0d68c8b9b8124504706041ff37019c1d1ed6bfda8e17',
transactionIndex: 0,
};
- const logB: Web3.LogEntry = {
+ const logB: LogEntry = {
address: '0x8d12a197cb00d4747a1fe03395095ce2a5cc6819',
blockHash: null,
blockNumber: null,
@@ -41,7 +42,7 @@ describe('EventWatcher', () => {
transactionHash: '0x01ef3c048b18d9b09ea195b4ed94cf8dd5f3d857a1905ff886b152cfb1166f25',
transactionIndex: 0,
};
- const logC: Web3.LogEntry = {
+ const logC: LogEntry = {
address: '0x1d271f8b174adef58f1587ce68f8f27271ac4ca5',
blockHash: null,
blockNumber: null,
@@ -64,7 +65,7 @@ describe('EventWatcher', () => {
eventWatcher.unsubscribe();
});
it('correctly emits initial log events', (done: DoneCallback) => {
- const logs: Web3.LogEntry[] = [logA, logB];
+ const logs: LogEntry[] = [logA, logB];
const expectedLogEvents = [
{
removed: false,
@@ -89,8 +90,8 @@ describe('EventWatcher', () => {
eventWatcher.subscribe(callback);
});
it('correctly computes the difference and emits only changes', (done: DoneCallback) => {
- const initialLogs: Web3.LogEntry[] = [logA, logB];
- const changedLogs: Web3.LogEntry[] = [logA, logC];
+ const initialLogs: LogEntry[] = [logA, logB];
+ const changedLogs: LogEntry[] = [logA, logC];
const expectedLogEvents = [
{
removed: false,
diff --git a/packages/0x.js/tsconfig.json b/packages/0x.js/tsconfig.json
index a6b5c71c2..ddf5a910e 100644
--- a/packages/0x.js/tsconfig.json
+++ b/packages/0x.js/tsconfig.json
@@ -8,10 +8,6 @@
"./src/**/*",
"./test/**/*",
"../../node_modules/types-bn/index.d.ts",
- "../../node_modules/types-ethereumjs-util/index.d.ts",
- "../../node_modules/ethers-typescript-typings/index.d.ts",
- "../../node_modules/web3-typescript-typings/index.d.ts",
- "../../node_modules/chai-typescript-typings/index.d.ts",
- "../../node_modules/chai-as-promised-typescript-typings/index.d.ts"
+ "../../node_modules/types-ethereumjs-util/index.d.ts"
]
}
diff --git a/packages/abi-gen/.npmignore b/packages/abi-gen/.npmignore
index 87bc30436..d645458f6 100644
--- a/packages/abi-gen/.npmignore
+++ b/packages/abi-gen/.npmignore
@@ -3,3 +3,4 @@ yarn-error.log
/src/
/scripts/
tsconfig.json
+/lib/monorepo_scripts/
diff --git a/packages/abi-gen/package.json b/packages/abi-gen/package.json
index fc1adeb06..3c20249dd 100644
--- a/packages/abi-gen/package.json
+++ b/packages/abi-gen/package.json
@@ -24,13 +24,14 @@
"homepage": "https://github.com/0xProject/0x-monorepo/packages/abi-gen/README.md",
"dependencies": {
"@0xproject/utils": "^0.4.3",
+ "@0xproject/types": "^0.4.1",
+ "@0xproject/typescript-typings": "^0.0.1",
"chalk": "^2.3.0",
"glob": "^7.1.2",
"handlebars": "^4.0.11",
"lodash": "^4.17.4",
"mkdirp": "^0.5.1",
"to-snake-case": "^1.0.0",
- "web3": "^0.20.0",
"yargs": "^10.0.3"
},
"devDependencies": {
@@ -45,8 +46,7 @@
"npm-run-all": "^4.1.2",
"shx": "^0.2.2",
"tslint": "5.8.0",
- "typescript": "2.7.1",
- "web3-typescript-typings": "^0.10.2"
+ "typescript": "2.7.1"
},
"publishConfig": {
"access": "public"
diff --git a/packages/abi-gen/src/index.ts b/packages/abi-gen/src/index.ts
index 8932e4045..942bb12db 100644
--- a/packages/abi-gen/src/index.ts
+++ b/packages/abi-gen/src/index.ts
@@ -1,5 +1,6 @@
#!/usr/bin/env node
+import { AbiDefinition, ConstructorAbi, EventAbi, MethodAbi } from '@0xproject/types';
import { logUtils } from '@0xproject/utils';
import chalk from 'chalk';
import * as fs from 'fs';
@@ -10,7 +11,6 @@ import * as mkdirp from 'mkdirp';
import * as yargs from 'yargs';
import toSnakeCase = require('to-snake-case');
-import * as Web3 from 'web3';
import { ContextData, ContractsBackend, ParamKind } from './types';
import { utils } from './utils';
@@ -120,12 +120,12 @@ for (const abiFileName of abiFileNames) {
process.exit(1);
}
- let ctor = ABI.find((abi: Web3.AbiDefinition) => abi.type === ABI_TYPE_CONSTRUCTOR) as Web3.ConstructorAbi;
+ let ctor = ABI.find((abi: AbiDefinition) => abi.type === ABI_TYPE_CONSTRUCTOR) as ConstructorAbi;
if (_.isUndefined(ctor)) {
ctor = utils.getEmptyConstructor(); // The constructor exists, but it's implicit in JSON's ABI definition
}
- const methodAbis = ABI.filter((abi: Web3.AbiDefinition) => abi.type === ABI_TYPE_METHOD) as Web3.MethodAbi[];
+ const methodAbis = ABI.filter((abi: AbiDefinition) => abi.type === ABI_TYPE_METHOD) as MethodAbi[];
const methodsData = _.map(methodAbis, methodAbi => {
_.map(methodAbi.inputs, (input, i: number) => {
if (_.isEmpty(input.name)) {
@@ -142,7 +142,7 @@ for (const abiFileName of abiFileNames) {
return methodData;
});
- const eventAbis = ABI.filter((abi: Web3.AbiDefinition) => abi.type === ABI_TYPE_EVENT) as Web3.EventAbi[];
+ const eventAbis = ABI.filter((abi: AbiDefinition) => abi.type === ABI_TYPE_EVENT) as EventAbi[];
const contextData = {
contractName: namedContent.name,
diff --git a/packages/abi-gen/src/types.ts b/packages/abi-gen/src/types.ts
index deddb1857..df5b1feaf 100644
--- a/packages/abi-gen/src/types.ts
+++ b/packages/abi-gen/src/types.ts
@@ -1,4 +1,4 @@
-import * as Web3 from 'web3';
+import { EventAbi, MethodAbi } from '@0xproject/types';
export enum ParamKind {
Input = 'input',
@@ -17,7 +17,7 @@ export enum ContractsBackend {
Ethers = 'ethers',
}
-export interface Method extends Web3.MethodAbi {
+export interface Method extends MethodAbi {
singleReturnValue: boolean;
hasReturnValue: boolean;
}
@@ -25,5 +25,5 @@ export interface Method extends Web3.MethodAbi {
export interface ContextData {
contractName: string;
methods: Method[];
- events: Web3.EventAbi[];
+ events: EventAbi[];
}
diff --git a/packages/abi-gen/src/utils.ts b/packages/abi-gen/src/utils.ts
index c4520ade0..755fbc71a 100644
--- a/packages/abi-gen/src/utils.ts
+++ b/packages/abi-gen/src/utils.ts
@@ -1,17 +1,12 @@
+import { ConstructorAbi, DataItem } from '@0xproject/types';
import * as fs from 'fs';
import * as _ from 'lodash';
import * as path from 'path';
-import * as Web3 from 'web3';
import { AbiType, ContractsBackend, ParamKind } from './types';
export const utils = {
- solTypeToTsType(
- paramKind: ParamKind,
- backend: ContractsBackend,
- solType: string,
- components?: Web3.DataItem[],
- ): string {
+ solTypeToTsType(paramKind: ParamKind, backend: ContractsBackend, solType: string, components?: DataItem[]): string {
const trailingArrayRegex = /\[\d*\]$/;
if (solType.match(trailingArrayRegex)) {
const arrayItemSolType = solType.replace(trailingArrayRegex, '');
@@ -89,7 +84,7 @@ export const utils = {
throw new Error(`Failed to read ${filename}: ${err}`);
}
},
- getEmptyConstructor(): Web3.ConstructorAbi {
+ getEmptyConstructor(): ConstructorAbi {
return {
type: AbiType.Constructor,
stateMutability: 'nonpayable',
diff --git a/packages/abi-gen/tsconfig.json b/packages/abi-gen/tsconfig.json
index 5e0c7c6d3..e35816553 100644
--- a/packages/abi-gen/tsconfig.json
+++ b/packages/abi-gen/tsconfig.json
@@ -3,5 +3,5 @@
"compilerOptions": {
"outDir": "lib"
},
- "include": ["./src/**/*", "./test/**/*", "../../node_modules/web3-typescript-typings/index.d.ts"]
+ "include": ["./src/**/*", "./test/**/*"]
}
diff --git a/packages/assert/.npmignore b/packages/assert/.npmignore
index 05fa23a59..44df80fad 100644
--- a/packages/assert/.npmignore
+++ b/packages/assert/.npmignore
@@ -4,3 +4,4 @@ yarn-error.log
/scripts/
test/
tsconfig.json
+/lib/src/monorepo_scripts/
diff --git a/packages/assert/README.md b/packages/assert/README.md
index 1ea6acfb5..7f80e7e5d 100644
--- a/packages/assert/README.md
+++ b/packages/assert/README.md
@@ -8,14 +8,6 @@ Standard type and schema assertions to be used across all 0x projects and packag
yarn add @0xproject/assert
```
-If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`:
-
-```
-"include": [
- "./node_modules/web3-typescript-typings/index.d.ts",
-]
-```
-
## Usage
```typescript
@@ -24,6 +16,14 @@ import { assert } from '@0xproject/assert';
assert.isValidBaseUnitAmount('baseUnitAmount', baseUnitAmount);
```
+If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`:
+
+```json
+"compilerOptions": {
+ "typeRoots": ["node_modules/@0xproject/typescript-typings/types", "node_modules/@types"],
+}
+```
+
## Contributing
We strongly encourage that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository.
diff --git a/packages/assert/package.json b/packages/assert/package.json
index 73b3b7f37..3df7eab8d 100644
--- a/packages/assert/package.json
+++ b/packages/assert/package.json
@@ -32,7 +32,6 @@
"@types/mocha": "^2.2.42",
"@types/valid-url": "^1.0.2",
"chai": "^4.0.1",
- "chai-typescript-typings": "^0.0.6",
"copyfiles": "^1.2.0",
"dirty-chai": "^2.0.1",
"mocha": "^4.0.1",
@@ -45,6 +44,7 @@
"dependencies": {
"@0xproject/json-schemas": "^0.7.17",
"@0xproject/utils": "^0.4.3",
+ "@0xproject/typescript-typings": "^0.0.1",
"lodash": "^4.17.4",
"valid-url": "^1.0.9"
},
diff --git a/packages/assert/tsconfig.json b/packages/assert/tsconfig.json
index 10354fa33..e35816553 100644
--- a/packages/assert/tsconfig.json
+++ b/packages/assert/tsconfig.json
@@ -3,10 +3,5 @@
"compilerOptions": {
"outDir": "lib"
},
- "include": [
- "./src/**/*",
- "./test/**/*",
- "../../node_modules/web3-typescript-typings/index.d.ts",
- "../../node_modules/chai-typescript-typings/index.d.ts"
- ]
+ "include": ["./src/**/*", "./test/**/*"]
}
diff --git a/packages/base-contract/.npmignore b/packages/base-contract/.npmignore
index ad5ffcd56..24e65ad5b 100644
--- a/packages/base-contract/.npmignore
+++ b/packages/base-contract/.npmignore
@@ -3,3 +3,4 @@ yarn-error.log
/scripts/
/src/
tsconfig.json
+/lib/monorepo_scripts/
diff --git a/packages/base-contract/README.md b/packages/base-contract/README.md
index fa2f3da10..a689d0130 100644
--- a/packages/base-contract/README.md
+++ b/packages/base-contract/README.md
@@ -10,11 +10,10 @@ yarn add @0xproject/base-contract
If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`:
-```
-"include": [
- "./node_modules/web3-typescript-typings/index.d.ts",
- "./node_modules/ethers-typescript-typings/index.d.ts"
-]
+```json
+"compilerOptions": {
+ "typeRoots": ["node_modules/@0xproject/typescript-typings/types", "node_modules/@types"],
+}
```
## Usage
diff --git a/packages/base-contract/package.json b/packages/base-contract/package.json
index 4e0260417..e9015713c 100644
--- a/packages/base-contract/package.json
+++ b/packages/base-contract/package.json
@@ -32,11 +32,9 @@
"dependencies": {
"@0xproject/types": "^0.4.1",
"@0xproject/web3-wrapper": "^0.3.1",
+ "@0xproject/typescript-typings": "^0.0.1",
"ethers-contracts": "^2.2.1",
- "ethers-typescript-typings": "^0.0.4",
- "lodash": "^4.17.4",
- "web3": "^0.20.0",
- "web3-typescript-typings": "^0.10.2"
+ "lodash": "^4.17.4"
},
"publishConfig": {
"access": "public"
diff --git a/packages/base-contract/src/index.ts b/packages/base-contract/src/index.ts
index cc1e16a13..961da8842 100644
--- a/packages/base-contract/src/index.ts
+++ b/packages/base-contract/src/index.ts
@@ -1,16 +1,15 @@
-import { TxData, TxDataPayable } from '@0xproject/types';
+import { ContractAbi, DataItem, TxData, TxDataPayable } from '@0xproject/types';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as ethersContracts from 'ethers-contracts';
import * as _ from 'lodash';
-import * as Web3 from 'web3';
export class BaseContract {
protected _ethersInterface: ethersContracts.Interface;
protected _web3Wrapper: Web3Wrapper;
- public abi: Web3.ContractAbi;
+ public abi: ContractAbi;
public address: string;
protected static _transformABIData(
- abis: Web3.DataItem[],
+ abis: DataItem[],
values: any[],
transformation: (type: string, value: any) => any,
): any {
@@ -46,20 +45,20 @@ export class BaseContract {
// 2. Global config passed in at library instantiation
// 3. Gas estimate calculation + safety margin
const removeUndefinedProperties = _.pickBy;
- const txDataWithDefaults = {
+ const txDataWithDefaults = ({
to: this.address,
...removeUndefinedProperties(this._web3Wrapper.getContractDefaults()),
...removeUndefinedProperties(txData as any),
// HACK: TS can't prove that T is spreadable.
// Awaiting https://github.com/Microsoft/TypeScript/pull/13288 to be merged
- };
+ } as any) as TxData;
if (_.isUndefined(txDataWithDefaults.gas) && !_.isUndefined(estimateGasAsync)) {
const estimatedGas = await estimateGasAsync(txData);
txDataWithDefaults.gas = estimatedGas;
}
return txDataWithDefaults;
}
- constructor(web3Wrapper: Web3Wrapper, abi: Web3.ContractAbi, address: string) {
+ constructor(web3Wrapper: Web3Wrapper, abi: ContractAbi, address: string) {
this._web3Wrapper = web3Wrapper;
this.abi = abi;
this.address = address;
diff --git a/packages/base-contract/tsconfig.json b/packages/base-contract/tsconfig.json
index 8114d99cd..c56d255d5 100644
--- a/packages/base-contract/tsconfig.json
+++ b/packages/base-contract/tsconfig.json
@@ -3,9 +3,5 @@
"compilerOptions": {
"outDir": "lib"
},
- "include": [
- "./src/**/*",
- "../../node_modules/web3-typescript-typings/index.d.ts",
- "../../node_modules/ethers-typescript-typings/index.d.ts"
- ]
+ "include": ["./src/**/*"]
}
diff --git a/packages/chai-as-promised-typescript-typings/.npmignore b/packages/chai-as-promised-typescript-typings/.npmignore
deleted file mode 100644
index 104d718ed..000000000
--- a/packages/chai-as-promised-typescript-typings/.npmignore
+++ /dev/null
@@ -1,3 +0,0 @@
-.*
-yarn-error.log
-/scripts/
diff --git a/packages/chai-as-promised-typescript-typings/README.md b/packages/chai-as-promised-typescript-typings/README.md
deleted file mode 100644
index 72784ef53..000000000
--- a/packages/chai-as-promised-typescript-typings/README.md
+++ /dev/null
@@ -1,43 +0,0 @@
-## chai-as-promised-typescript-typings
-
-Fork of type definitions for chai-as-promised that includes changes made by dirty-chai
-
-## Installation
-
-```bash
-yarn add -D chai-as-promised-typescript-typings
-```
-
-## Usage
-
-Add the following line within an `include` section of your `tsconfig.json`
-
-```json
-"./node_modules/chai-as-promised-typescript-typings/index.d.ts"
-```
-
-## Contributing
-
-We strongly encourage that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository.
-
-Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
-
-### Install Dependencies
-
-If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
-
-```bash
-yarn config set workspaces-experimental true
-```
-
-Then install dependencies
-
-```bash
-yarn install
-```
-
-### Lint
-
-```bash
-yarn lint
-```
diff --git a/packages/chai-typescript-typings/CHANGELOG.md b/packages/chai-typescript-typings/CHANGELOG.md
deleted file mode 100644
index 8c52570da..000000000
--- a/packages/chai-typescript-typings/CHANGELOG.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# CHANGELOG
-
-## v0.x.x - _TBD, 2018_
diff --git a/packages/chai-typescript-typings/monorepo_scripts/globals.d.ts b/packages/chai-typescript-typings/monorepo_scripts/globals.d.ts
deleted file mode 100644
index 94e63a32d..000000000
--- a/packages/chai-typescript-typings/monorepo_scripts/globals.d.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-declare module '*.json' {
- const json: any;
- /* tslint:disable */
- export default json;
- /* tslint:enable */
-}
diff --git a/packages/chai-typescript-typings/monorepo_scripts/postpublish.ts b/packages/chai-typescript-typings/monorepo_scripts/postpublish.ts
deleted file mode 100644
index dcb99d0f7..000000000
--- a/packages/chai-typescript-typings/monorepo_scripts/postpublish.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import { postpublishUtils } from '@0xproject/monorepo-scripts';
-
-import * as packageJSON from '../package.json';
-import * as tsConfigJSON from '../tsconfig.json';
-
-const cwd = `${__dirname}/..`;
-// tslint:disable-next-line:no-floating-promises
-postpublishUtils.runAsync(packageJSON, tsConfigJSON, cwd);
diff --git a/packages/chai-typescript-typings/package.json b/packages/chai-typescript-typings/package.json
deleted file mode 100644
index 96b58cce3..000000000
--- a/packages/chai-typescript-typings/package.json
+++ /dev/null
@@ -1,28 +0,0 @@
-{
- "name": "chai-typescript-typings",
- "version": "0.0.6",
- "description": "Typescript type definitions for chai",
- "main": "index.d.ts",
- "types": "index.d.ts",
- "scripts": {
- "build": "tsc && copyfiles -u 1 './lib/**/*' ./scripts",
- "clean": "shx rm -rf scripts"
- },
- "repository": {
- "type": "git",
- "url": "git+https://github.com/0xProject/0x-monorepo.git"
- },
- "license": "Apache-2.0",
- "bugs": {
- "url": "https://github.com/0xProject/0x-monorepo/issues"
- },
- "homepage": "https://github.com/0xProject/0x-monorepo/packages/chai-typescript-typings#readme",
- "devDependencies": {
- "@0xproject/monorepo-scripts": "^0.1.14",
- "copyfiles": "^1.2.0",
- "shx": "^0.2.2"
- },
- "publishConfig": {
- "access": "public"
- }
-}
diff --git a/packages/chai-typescript-typings/tsconfig.json b/packages/chai-typescript-typings/tsconfig.json
deleted file mode 100644
index bc453af4b..000000000
--- a/packages/chai-typescript-typings/tsconfig.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "extends": "../../tsconfig",
- "compilerOptions": {
- "outDir": "lib"
- },
- "include": ["./monorepo_scripts/**/*"]
-}
diff --git a/packages/chai-typescript-typings/tslint.json b/packages/chai-typescript-typings/tslint.json
deleted file mode 100644
index 9a93a1f74..000000000
--- a/packages/chai-typescript-typings/tslint.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "extends": ["tslint-config-0xproject"]
-}
diff --git a/packages/connect/.npmignore b/packages/connect/.npmignore
index a9d200050..9db6e838d 100644
--- a/packages/connect/.npmignore
+++ b/packages/connect/.npmignore
@@ -5,3 +5,4 @@ yarn-error.log
/generated_docs/
test/
tsconfig.json
+/lib/src/monorepo_scripts/
diff --git a/packages/connect/README.md b/packages/connect/README.md
index 393ea70a0..7087214d6 100644
--- a/packages/connect/README.md
+++ b/packages/connect/README.md
@@ -10,10 +10,10 @@ yarn add @0xproject/connect
If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`:
-```
-"include": [
- "./node_modules/web3-typescript-typings/index.d.ts",
-]
+```json
+"compilerOptions": {
+ "typeRoots": ["node_modules/@0xproject/typescript-typings/types", "node_modules/@types"],
+}
```
## Usage
diff --git a/packages/connect/package.json b/packages/connect/package.json
index ae243f288..3e9f3053c 100644
--- a/packages/connect/package.json
+++ b/packages/connect/package.json
@@ -53,6 +53,7 @@
"@0xproject/json-schemas": "^0.7.17",
"@0xproject/types": "^0.4.1",
"@0xproject/utils": "^0.4.3",
+ "@0xproject/typescript-typings": "^0.0.1",
"isomorphic-fetch": "^2.2.1",
"lodash": "^4.17.4",
"query-string": "^5.0.1",
@@ -69,8 +70,6 @@
"async-child-process": "^1.1.1",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
- "chai-as-promised-typescript-typings": "^0.0.12",
- "chai-typescript-typings": "^0.0.6",
"copyfiles": "^1.2.0",
"dirty-chai": "^2.0.1",
"fetch-mock": "^5.13.1",
@@ -80,8 +79,7 @@
"shx": "^0.2.2",
"tslint": "5.8.0",
"typedoc": "~0.8.0",
- "typescript": "2.7.1",
- "web3-typescript-typings": "^0.10.2"
+ "typescript": "2.7.1"
},
"publishConfig": {
"access": "public"
diff --git a/packages/connect/tsconfig.json b/packages/connect/tsconfig.json
index fd9e604ad..e35816553 100644
--- a/packages/connect/tsconfig.json
+++ b/packages/connect/tsconfig.json
@@ -3,11 +3,5 @@
"compilerOptions": {
"outDir": "lib"
},
- "include": [
- "./src/**/*",
- "./test/**/*",
- "../../node_modules/web3-typescript-typings/index.d.ts",
- "../../node_modules/chai-as-promised-typescript-typings/index.d.ts",
- "../../node_modules/chai-typescript-typings/index.d.ts"
- ]
+ "include": ["./src/**/*", "./test/**/*"]
}
diff --git a/packages/contract_templates/contract.handlebars b/packages/contract_templates/contract.handlebars
index 132cd60cc..08310c8f2 100644
--- a/packages/contract_templates/contract.handlebars
+++ b/packages/contract_templates/contract.handlebars
@@ -5,7 +5,7 @@
// tslint:disable:no-consecutive-blank-lines
// tslint:disable-next-line:no-unused-variable
import { BaseContract } from '@0xproject/base-contract';
-import { TxData, TxDataPayable } from '@0xproject/types';
+import { BlockParam, BlockParamLiteral, CallData, ContractAbi, DataItem, MethodAbi, TxData, TxDataPayable } from '@0xproject/types';
import { BigNumber, classUtils, promisify } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as ethersContracts from 'ethers-contracts';
@@ -40,7 +40,7 @@ export class {{contractName}}Contract extends BaseContract {
{{> tx contractName=../contractName}}
{{/this.constant}}
{{/each}}
- constructor(web3Wrapper: Web3Wrapper, abi: Web3.ContractAbi, address: string) {
+ constructor(web3Wrapper: Web3Wrapper, abi: ContractAbi, address: string) {
super(web3Wrapper, abi, address);
classUtils.bindAll(this, ['_ethersInterface', 'address', 'abi', '_web3Wrapper']);
}
diff --git a/packages/contract_templates/partials/callAsync.handlebars b/packages/contract_templates/partials/callAsync.handlebars
index 93d347145..e3fc2bdf9 100644
--- a/packages/contract_templates/partials/callAsync.handlebars
+++ b/packages/contract_templates/partials/callAsync.handlebars
@@ -1,27 +1,22 @@
{{#hasReturnValue}}
async callAsync(
{{> typed_params inputs=inputs}}
-{{#this.payable}}
- txData: TxDataPayable = {},
-{{/this.payable}}
-{{^this.payable}}
- txData: TxData = {},
-{{/this.payable}}
- defaultBlock?: Web3.BlockParam,
+ callData: Partial<CallData> = {},
+ defaultBlock?: BlockParam,
): Promise<{{> return_type outputs=outputs}}> {
const self = this as {{contractName}}Contract;
- const inputAbi = _.find(this.abi, {name: '{{this.name}}'}).inputs;
- [{{> params inputs=inputs}}] = BaseContract._transformABIData(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(this));
+ const inputAbi = (_.find(self.abi, {name: '{{this.name}}'}) as MethodAbi).inputs;
+ [{{> params inputs=inputs}}] = BaseContract._transformABIData(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(self));
const encodedData = self._ethersInterface.functions.{{this.name}}(
{{> params inputs=inputs}}
).data;
- const callData = await self._applyDefaultsToTxDataAsync(
+ const callDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{
data: encodedData,
}
)
- const rawCallResult = await self._web3Wrapper.callAsync(callData, defaultBlock);
- const outputAbi = _.find(this.abi, {name: '{{this.name}}'}).outputs as Web3.DataItem[];
+ const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
+ const outputAbi = (_.find(self.abi, {name: '{{this.name}}'}) as MethodAbi).outputs;
const outputParamsTypes = _.map(outputAbi, 'type');
let resultArray = ethersContracts.Interface.decodeParams(outputParamsTypes, rawCallResult) as any;
resultArray = BaseContract._transformABIData(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
diff --git a/packages/contract_templates/partials/tx.handlebars b/packages/contract_templates/partials/tx.handlebars
index d517a9f7f..f76de3a70 100644
--- a/packages/contract_templates/partials/tx.handlebars
+++ b/packages/contract_templates/partials/tx.handlebars
@@ -2,16 +2,16 @@ public {{this.name}} = {
async sendTransactionAsync(
{{> typed_params inputs=inputs}}
{{#this.payable}}
- txData: TxDataPayable = {},
+ txData: Partial<TxDataPayable> = {},
{{/this.payable}}
{{^this.payable}}
- txData: TxData = {},
+ txData: Partial<TxData> = {},
{{/this.payable}}
): Promise<string> {
const self = this as {{contractName}}Contract;
- const inputAbi = _.find(this.abi, {name: '{{this.name}}'}).inputs;
- [{{> params inputs=inputs}}] = BaseContract._transformABIData(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(this));
- const encodedData = this._ethersInterface.functions.{{this.name}}(
+ const inputAbi = (_.find(self.abi, {name: '{{this.name}}'}) as MethodAbi).inputs;
+ [{{> params inputs=inputs}}] = BaseContract._transformABIData(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(self));
+ const encodedData = self._ethersInterface.functions.{{this.name}}(
{{> params inputs=inputs}}
).data
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
@@ -24,17 +24,17 @@ public {{this.name}} = {
{{> params inputs=inputs}}
),
);
- const txHash = await this._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
+ const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
return txHash;
},
async estimateGasAsync(
{{> typed_params inputs=inputs}}
- txData: TxData = {},
+ txData: Partial<TxData> = {},
): Promise<number> {
const self = this as {{contractName}}Contract;
- const inputAbi = _.find(this.abi, {name: '{{this.name}}'}).inputs;
+ const inputAbi = (_.find(self.abi, {name: '{{this.name}}'}) as MethodAbi).inputs;
[{{> params inputs=inputs}}] = BaseContract._transformABIData(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(this));
- const encodedData = this._ethersInterface.functions.{{this.name}}(
+ const encodedData = self._ethersInterface.functions.{{this.name}}(
{{> params inputs=inputs}}
).data
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
@@ -43,17 +43,16 @@ public {{this.name}} = {
data: encodedData,
}
);
- const gas = await this._web3Wrapper.estimateGasAsync(txDataWithDefaults);
+ const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
return gas;
},
getABIEncodedTransactionData(
{{> typed_params inputs=inputs}}
- txData: TxData = {},
): string {
const self = this as {{contractName}}Contract;
- const inputAbi = _.find(this.abi, {name: '{{this.name}}'}).inputs;
- [{{> params inputs=inputs}}] = BaseContract._transformABIData(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(this));
- const abiEncodedTransactionData = this._ethersInterface.functions.{{this.name}}(
+ const inputAbi = (_.find(self.abi, {name: '{{this.name}}'}) as MethodAbi).inputs;
+ [{{> params inputs=inputs}}] = BaseContract._transformABIData(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(self));
+ const abiEncodedTransactionData = self._ethersInterface.functions.{{this.name}}(
{{> params inputs=inputs}}
).data
return abiEncodedTransactionData;
diff --git a/packages/contracts/package.json b/packages/contracts/package.json
index 377fba473..0c931344d 100644
--- a/packages/contracts/package.json
+++ b/packages/contracts/package.json
@@ -49,12 +49,9 @@
"@types/yargs": "^10.0.0",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
- "chai-as-promised-typescript-typings": "^0.0.12",
"chai-bignumber": "^2.0.1",
- "chai-typescript-typings": "^0.0.6",
"copyfiles": "^1.2.0",
"dirty-chai": "^2.0.1",
- "ethers-typescript-typings": "^0.0.4",
"mocha": "^4.0.1",
"npm-run-all": "^4.1.2",
"prettier": "^1.11.1",
@@ -64,7 +61,6 @@
"types-bn": "^0.0.1",
"types-ethereumjs-util": "0xProject/types-ethereumjs-util",
"typescript": "2.7.1",
- "web3-typescript-typings": "^0.10.2",
"yargs": "^10.0.3"
},
"dependencies": {
@@ -74,6 +70,7 @@
"@0xproject/types": "^0.4.1",
"@0xproject/utils": "^0.4.3",
"@0xproject/web3-wrapper": "^0.3.1",
+ "@0xproject/typescript-typings": "^0.0.1",
"bluebird": "^3.5.0",
"bn.js": "^4.11.8",
"ethereumjs-abi": "^0.6.4",
diff --git a/packages/contracts/src/contract_wrappers/generated/.gitignore b/packages/contracts/src/contract_wrappers/generated/.gitignore
deleted file mode 100644
index 72e8ffc0d..000000000
--- a/packages/contracts/src/contract_wrappers/generated/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-*
diff --git a/packages/contracts/tsconfig.json b/packages/contracts/tsconfig.json
index 490531eeb..f32a3682a 100644
--- a/packages/contracts/tsconfig.json
+++ b/packages/contracts/tsconfig.json
@@ -9,11 +9,6 @@
},
"include": [
"../../node_modules/types-ethereumjs-util/index.d.ts",
- "../../node_modules/chai-typescript-typings/index.d.ts",
- "../../node_modules/web3-typescript-typings/index.d.ts",
- "../../node_modules/ethers-typescript-typings/index.d.ts",
- "../../node_modules/chai-as-promised-typescript-typings/index.d.ts",
- "../../node_modules/types-ethereumjs-util/index.d.ts",
"../../node_modules/types-bn/index.d.ts",
"./globals.d.ts",
"./src/**/*",
diff --git a/packages/contracts/util/multi_sig_wrapper.ts b/packages/contracts/util/multi_sig_wrapper.ts
index 3b83ccb7b..9f6dcec52 100644
--- a/packages/contracts/util/multi_sig_wrapper.ts
+++ b/packages/contracts/util/multi_sig_wrapper.ts
@@ -1,3 +1,4 @@
+import { AbiDefinition, MethodAbi } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import ABI = require('ethereumjs-abi');
import ethUtil = require('ethereumjs-util');
@@ -10,8 +11,8 @@ import { TransactionDataParams } from './types';
export class MultiSigWrapper {
private _multiSig: MultiSigWalletContract;
- public static encodeFnArgs(name: string, abi: Web3.AbiDefinition[], args: any[]) {
- const abiEntity = _.find(abi, { name }) as Web3.MethodAbi;
+ public static encodeFnArgs(name: string, abi: AbiDefinition[], args: any[]) {
+ const abiEntity = _.find(abi, { name }) as MethodAbi;
if (_.isUndefined(abiEntity)) {
throw new Error(`Did not find abi entry for name: ${name}`);
}
diff --git a/packages/contracts/util/types.ts b/packages/contracts/util/types.ts
index 61a19acb4..321084c42 100644
--- a/packages/contracts/util/types.ts
+++ b/packages/contracts/util/types.ts
@@ -1,5 +1,5 @@
+import { AbiDefinition, ContractAbi } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
-import * as Web3 from 'web3';
export interface BalancesByOwner {
[ownerAddress: string]: {
@@ -51,7 +51,7 @@ export interface DefaultOrderParams {
export interface TransactionDataParams {
name: string;
- abi: Web3.AbiDefinition[];
+ abi: AbiDefinition[];
args: any[];
}
@@ -105,7 +105,7 @@ export interface Artifact {
contract_name: ContractName;
networks: {
[networkId: number]: {
- abi: Web3.ContractAbi;
+ abi: ContractAbi;
solc_version: string;
keccak256: string;
optimizer_enabled: number;
diff --git a/packages/deployer/.npmignore b/packages/deployer/.npmignore
index 05fa23a59..44df80fad 100644
--- a/packages/deployer/.npmignore
+++ b/packages/deployer/.npmignore
@@ -4,3 +4,4 @@ yarn-error.log
/scripts/
test/
tsconfig.json
+/lib/src/monorepo_scripts/
diff --git a/packages/deployer/README.md b/packages/deployer/README.md
index 8fe82f59e..812e8c31b 100644
--- a/packages/deployer/README.md
+++ b/packages/deployer/README.md
@@ -18,6 +18,14 @@ yarn global add @0xproject/deployer
yarn add @0xproject/deployer
```
+If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`:
+
+```json
+"compilerOptions": {
+ "typeRoots": ["node_modules/@0xproject/typescript-typings/types", "node_modules/@types"],
+}
+```
+
**Import**
```typescript
diff --git a/packages/deployer/package.json b/packages/deployer/package.json
index f44e803eb..362bc659e 100644
--- a/packages/deployer/package.json
+++ b/packages/deployer/package.json
@@ -7,7 +7,8 @@
"scripts": {
"build:watch": "tsc -w",
"build": "yarn clean && copyfiles 'test/fixtures/contracts/**/*' ./lib && tsc && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts",
- "test": "npm run build; mocha lib/test/*_test.js",
+ "test": "run-s build run_mocha",
+ "run_mocha": "mocha lib/test/*_test.js",
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
"coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info",
"compile": "npm run build; node lib/src/cli.js compile",
@@ -46,10 +47,12 @@
"@0xproject/monorepo-scripts": "^0.1.14",
"@0xproject/tslint-config": "^0.4.12",
"@types/require-from-string": "^1.2.0",
+ "@types/semver": "^5.5.0",
"@types/yargs": "^11.0.0",
+ "npm-run-all": "^4.1.2",
"chai": "^4.0.1",
"copyfiles": "^1.2.0",
- "ethers-typescript-typings": "^0.0.4",
+ "dirty-chai": "^2.0.1",
"mocha": "^4.0.1",
"nyc": "^11.0.1",
"shx": "^0.2.2",
@@ -64,10 +67,12 @@
"@0xproject/types": "^0.4.1",
"@0xproject/utils": "^0.4.3",
"@0xproject/web3-wrapper": "^0.3.1",
+ "@0xproject/typescript-typings": "^0.0.1",
"ethereumjs-util": "^5.1.1",
"isomorphic-fetch": "^2.2.1",
"lodash": "^4.17.4",
"require-from-string": "^2.0.1",
+ "semver": "^5.5.0",
"solc": "^0.4.18",
"web3": "^0.20.0",
"web3-eth-abi": "^1.0.0-beta.24",
diff --git a/packages/deployer/solc_bin/.gitignore b/packages/deployer/solc_bin/.gitignore
deleted file mode 100644
index a6c7c2852..000000000
--- a/packages/deployer/solc_bin/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-*.js
diff --git a/packages/deployer/src/cli.ts b/packages/deployer/src/cli.ts
index 7913c6344..d1bd645b3 100644
--- a/packages/deployer/src/cli.ts
+++ b/packages/deployer/src/cli.ts
@@ -10,6 +10,7 @@ import * as yargs from 'yargs';
import { commands } from './commands';
import { constants } from './utils/constants';
+import { consoleReporter } from './utils/error_reporter';
import { CliOptions, CompilerOptions, DeployerOptions } from './utils/types';
const DEFAULT_OPTIMIZER_ENABLED = false;
@@ -24,11 +25,11 @@ const DEFAULT_CONTRACTS_LIST = '*';
* Compiles all contracts with options passed in through CLI.
* @param argv Instance of process.argv provided by yargs.
*/
-async function onCompileCommand(argv: CliOptions): Promise<void> {
+async function onCompileCommandAsync(argv: CliOptions): Promise<void> {
const opts: CompilerOptions = {
contractsDir: argv.contractsDir,
networkId: argv.networkId,
- optimizerEnabled: argv.shouldOptimize ? 1 : 0,
+ optimizerEnabled: argv.shouldOptimize,
artifactsDir: argv.artifactsDir,
specifiedContracts: getContractsSetFromList(argv.contracts),
};
@@ -38,7 +39,7 @@ async function onCompileCommand(argv: CliOptions): Promise<void> {
* Deploys a single contract with provided name and args.
* @param argv Instance of process.argv provided by yargs.
*/
-async function onDeployCommand(argv: CliOptions): Promise<void> {
+async function onDeployCommandAsync(argv: CliOptions): Promise<void> {
const url = argv.jsonrpcUrl;
const web3Provider = new Web3.providers.HttpProvider(url);
const web3Wrapper = new Web3Wrapper(web3Provider);
@@ -46,7 +47,7 @@ async function onDeployCommand(argv: CliOptions): Promise<void> {
const compilerOpts: CompilerOptions = {
contractsDir: argv.contractsDir,
networkId,
- optimizerEnabled: argv.shouldOptimize ? 1 : 0,
+ optimizerEnabled: argv.shouldOptimize,
artifactsDir: argv.artifactsDir,
specifiedContracts: getContractsSetFromList(argv.contracts),
};
@@ -62,9 +63,9 @@ async function onDeployCommand(argv: CliOptions): Promise<void> {
networkId,
defaults,
};
- const deployerArgsString = argv.args;
+ const deployerArgsString = argv.args as string;
const deployerArgs = deployerArgsString.split(',');
- await commands.deployAsync(argv.contract, deployerArgs, deployerOpts);
+ await commands.deployAsync(argv.contract as string, deployerArgs, deployerOpts);
}
/**
* Creates a set of contracts to compile.
@@ -142,7 +143,12 @@ function deployCommandBuilder(yargsInstance: any) {
default: DEFAULT_CONTRACTS_LIST,
description: 'comma separated list of contracts to compile',
})
- .command('compile', 'compile contracts', identityCommandBuilder, onCompileCommand)
- .command('deploy', 'deploy a single contract with provided arguments', deployCommandBuilder, onDeployCommand)
+ .command('compile', 'compile contracts', identityCommandBuilder, consoleReporter(onCompileCommandAsync))
+ .command(
+ 'deploy',
+ 'deploy a single contract with provided arguments',
+ deployCommandBuilder,
+ consoleReporter(onDeployCommandAsync),
+ )
.help().argv;
})();
diff --git a/packages/deployer/src/commands.ts b/packages/deployer/src/commands.ts
index 32af7fc3f..8e544a60b 100644
--- a/packages/deployer/src/commands.ts
+++ b/packages/deployer/src/commands.ts
@@ -5,7 +5,7 @@ import { CompilerOptions, DeployerOptions } from './utils/types';
export const commands = {
async compileAsync(opts: CompilerOptions): Promise<void> {
const compiler = new Compiler(opts);
- await compiler.compileAllAsync();
+ await compiler.compileAsync();
},
async deployAsync(contractName: string, args: any[], opts: DeployerOptions): Promise<void> {
const deployer = new Deployer(opts);
diff --git a/packages/deployer/src/compiler.ts b/packages/deployer/src/compiler.ts
index e840ed572..4741a9086 100644
--- a/packages/deployer/src/compiler.ts
+++ b/packages/deployer/src/compiler.ts
@@ -1,3 +1,4 @@
+import { ContractAbi } from '@0xproject/types';
import { logUtils, promisify } from '@0xproject/utils';
import * as ethUtil from 'ethereumjs-util';
import * as fs from 'fs';
@@ -5,10 +6,18 @@ import 'isomorphic-fetch';
import * as _ from 'lodash';
import * as path from 'path';
import * as requireFromString from 'require-from-string';
+import * as semver from 'semver';
import solc = require('solc');
-import * as Web3 from 'web3';
import { binPaths } from './solc/bin_paths';
+import {
+ createArtifactsDirIfDoesNotExistAsync,
+ findImportIfExist,
+ getContractArtifactIfExistsAsync,
+ getNormalizedErrMsg,
+ parseDependencies,
+ parseSolidityVersionRange,
+} from './utils/compiler';
import { constants } from './utils/constants';
import { fsWrapper } from './utils/fs_wrapper';
import {
@@ -23,10 +32,6 @@ import {
import { utils } from './utils/utils';
const ALL_CONTRACTS_IDENTIFIER = '*';
-const SOLIDITY_VERSION_REGEX = /(?:solidity\s\^?)(\d+\.\d+\.\d+)/;
-const SOLIDITY_FILE_EXTENSION_REGEX = /(.*\.sol)/;
-const IMPORT_REGEX = /(import\s)/;
-const DEPENDENCY_PATH_REGEX = /"([^"]+)"/; // Source: https://github.com/BlockChainCompany/soljitsu/blob/master/lib/shared.js
/**
* The Compiler facilitates compiling Solidity smart contracts and saves the results
@@ -35,9 +40,10 @@ const DEPENDENCY_PATH_REGEX = /"([^"]+)"/; // Source: https://github.com/BlockCh
export class Compiler {
private _contractsDir: string;
private _networkId: number;
- private _optimizerEnabled: number;
+ private _optimizerEnabled: boolean;
private _artifactsDir: string;
- private _contractSources?: ContractSources;
+ // This get's set in the beggining of `compileAsync` function. It's not called from a constructor, but it's the only public method of that class and could as well be.
+ private _contractSources!: ContractSources;
private _solcErrors: Set<string> = new Set();
private _specifiedContracts: Set<string> = new Set();
private _contractSourceData: ContractSourceData = {};
@@ -82,64 +88,6 @@ export class Compiler {
return sources;
}
/**
- * Gets contract dependendencies and keccak256 hash from source.
- * @param source Source code of contract.
- * @return Object with contract dependencies and keccak256 hash of source.
- */
- private static _getContractSpecificSourceData(source: string): ContractSpecificSourceData {
- const dependencies: string[] = [];
- const sourceHash = ethUtil.sha3(source);
- const solcVersion = Compiler._parseSolidityVersion(source);
- const contractSpecificSourceData: ContractSpecificSourceData = {
- dependencies,
- solcVersion,
- sourceHash,
- };
- const lines = source.split('\n');
- _.forEach(lines, line => {
- if (!_.isNull(line.match(IMPORT_REGEX))) {
- const dependencyMatch = line.match(DEPENDENCY_PATH_REGEX);
- if (!_.isNull(dependencyMatch)) {
- const dependencyPath = dependencyMatch[1];
- const fileName = path.basename(dependencyPath);
- contractSpecificSourceData.dependencies.push(fileName);
- }
- }
- });
- return contractSpecificSourceData;
- }
- /**
- * Searches Solidity source code for compiler version.
- * @param source Source code of contract.
- * @return Solc compiler version.
- */
- private static _parseSolidityVersion(source: string): string {
- const solcVersionMatch = source.match(SOLIDITY_VERSION_REGEX);
- if (_.isNull(solcVersionMatch)) {
- throw new Error('Could not find Solidity version in source');
- }
- const solcVersion = solcVersionMatch[1];
- return solcVersion;
- }
- /**
- * Normalizes the path found in the error message.
- * Example: converts 'base/Token.sol:6:46: Warning: Unused local variable'
- * to 'Token.sol:6:46: Warning: Unused local variable'
- * This is used to prevent logging the same error multiple times.
- * @param errMsg An error message from the compiled output.
- * @return The error message with directories truncated from the contract path.
- */
- private static _getNormalizedErrMsg(errMsg: string): string {
- const errPathMatch = errMsg.match(SOLIDITY_FILE_EXTENSION_REGEX);
- if (_.isNull(errPathMatch)) {
- throw new Error('Could not find a path in error message');
- }
- const errPath = errPathMatch[0];
- const baseContract = path.basename(errPath);
- const normalizedErrMsg = errMsg.replace(errPath, baseContract);
- return normalizedErrMsg;
- }
- /**
* Instantiates a new instance of the Compiler class.
* @param opts Options specifying directories, network, and optimization settings.
* @return An instance of the Compiler class.
@@ -152,21 +100,18 @@ export class Compiler {
this._specifiedContracts = opts.specifiedContracts;
}
/**
- * Compiles all Solidity files found in `contractsDir` and writes JSON artifacts to `artifactsDir`.
+ * Compiles selected Solidity files found in `contractsDir` and writes JSON artifacts to `artifactsDir`.
*/
- public async compileAllAsync(): Promise<void> {
- await this._createArtifactsDirIfDoesNotExistAsync();
+ public async compileAsync(): Promise<void> {
+ await createArtifactsDirIfDoesNotExistAsync(this._artifactsDir);
this._contractSources = await Compiler._getContractSourcesAsync(this._contractsDir);
- _.forIn(this._contractSources, (source, fileName) => {
- this._contractSourceData[fileName] = Compiler._getContractSpecificSourceData(source);
- });
+ _.forIn(this._contractSources, this._setContractSpecificSourceData.bind(this));
const fileNames = this._specifiedContracts.has(ALL_CONTRACTS_IDENTIFIER)
? _.keys(this._contractSources)
: Array.from(this._specifiedContracts.values());
- _.forEach(fileNames, fileName => {
- this._setSourceTreeHash(fileName);
- });
- await Promise.all(_.map(fileNames, async fileName => this._compileContractAsync(fileName)));
+ for (const fileName of fileNames) {
+ await this._compileContractAsync(fileName);
+ }
this._solcErrors.forEach(errMsg => {
logUtils.log(errMsg);
});
@@ -180,19 +125,28 @@ export class Compiler {
throw new Error('Contract sources not yet initialized');
}
const contractSpecificSourceData = this._contractSourceData[fileName];
- const currentArtifactIfExists = (await this._getContractArtifactIfExistsAsync(fileName)) as ContractArtifact;
+ const currentArtifactIfExists = await getContractArtifactIfExistsAsync(this._artifactsDir, fileName);
const sourceHash = `0x${contractSpecificSourceData.sourceHash.toString('hex')}`;
- const sourceTreeHash = `0x${contractSpecificSourceData.sourceTreeHashIfExists.toString('hex')}`;
+ const sourceTreeHash = `0x${contractSpecificSourceData.sourceTreeHash.toString('hex')}`;
- const shouldCompile =
- _.isUndefined(currentArtifactIfExists) ||
- currentArtifactIfExists.networks[this._networkId].optimizer_enabled !== this._optimizerEnabled ||
- currentArtifactIfExists.networks[this._networkId].source_tree_hash !== sourceTreeHash;
+ let shouldCompile = false;
+ if (_.isUndefined(currentArtifactIfExists)) {
+ shouldCompile = true;
+ } else {
+ const currentArtifact = currentArtifactIfExists as ContractArtifact;
+ shouldCompile =
+ currentArtifact.networks[this._networkId].optimizer_enabled !== this._optimizerEnabled ||
+ currentArtifact.networks[this._networkId].source_tree_hash !== sourceTreeHash;
+ }
if (!shouldCompile) {
return;
}
-
- const fullSolcVersion = binPaths[contractSpecificSourceData.solcVersion];
+ const availableCompilerVersions = _.keys(binPaths);
+ const solcVersion = semver.maxSatisfying(
+ availableCompilerVersions,
+ contractSpecificSourceData.solcVersionRange,
+ );
+ const fullSolcVersion = binPaths[solcVersion];
const compilerBinFilename = path.join(__dirname, '../../solc_bin', fullSolcVersion);
let solcjs: string;
const isCompilerAvailableLocally = fs.existsSync(compilerBinFilename);
@@ -210,7 +164,7 @@ export class Compiler {
}
const solcInstance = solc.setupMethods(requireFromString(solcjs, compilerBinFilename));
- logUtils.log(`Compiling ${fileName}...`);
+ logUtils.log(`Compiling ${fileName} with Solidity v${solcVersion}...`);
const source = this._contractSources[fileName];
const input = {
[fileName]: source,
@@ -218,21 +172,24 @@ export class Compiler {
const sourcesToCompile = {
sources: input,
};
- const compiled = solcInstance.compile(
- sourcesToCompile,
- this._optimizerEnabled,
- this._findImportsIfSourcesExist.bind(this),
+ const compiled = solcInstance.compile(sourcesToCompile, Number(this._optimizerEnabled), importPath =>
+ findImportIfExist(this._contractSources, importPath),
);
if (!_.isUndefined(compiled.errors)) {
_.forEach(compiled.errors, errMsg => {
- const normalizedErrMsg = Compiler._getNormalizedErrMsg(errMsg);
+ const normalizedErrMsg = getNormalizedErrMsg(errMsg);
this._solcErrors.add(normalizedErrMsg);
});
}
const contractName = path.basename(fileName, constants.SOLIDITY_FILE_EXTENSION);
const contractIdentifier = `${fileName}:${contractName}`;
- const abi: Web3.ContractAbi = JSON.parse(compiled.contracts[contractIdentifier].interface);
+ if (_.isUndefined(compiled.contracts[contractIdentifier])) {
+ throw new Error(
+ `Contract ${contractName} not found in ${fileName}. Please make sure your contract has the same name as it's file name`,
+ );
+ }
+ const abi: ContractAbi = JSON.parse(compiled.contracts[contractIdentifier].interface);
const bytecode = `0x${compiled.contracts[contractIdentifier].bytecode}`;
const runtimeBytecode = `0x${compiled.contracts[contractIdentifier].runtimeBytecode}`;
const sourceMap = compiled.contracts[contractIdentifier].srcmap;
@@ -240,7 +197,7 @@ export class Compiler {
const sources = _.keys(compiled.sources);
const updated_at = Date.now();
const contractNetworkData: ContractNetworkData = {
- solc_version: contractSpecificSourceData.solcVersion,
+ solc_version: solcVersion,
keccak256: sourceHash,
source_tree_hash: sourceTreeHash,
optimizer_enabled: this._optimizerEnabled,
@@ -255,10 +212,11 @@ export class Compiler {
let newArtifact: ContractArtifact;
if (!_.isUndefined(currentArtifactIfExists)) {
+ const currentArtifact = currentArtifactIfExists as ContractArtifact;
newArtifact = {
- ...currentArtifactIfExists,
+ ...currentArtifact,
networks: {
- ...currentArtifactIfExists.networks,
+ ...currentArtifact.networks,
[this._networkId]: contractNetworkData,
},
};
@@ -277,79 +235,42 @@ export class Compiler {
logUtils.log(`${fileName} artifact saved!`);
}
/**
- * Sets the source tree hash for a file and its dependencies.
- * @param fileName Name of contract file.
- */
- private _setSourceTreeHash(fileName: string): void {
- const contractSpecificSourceData = this._contractSourceData[fileName];
- if (_.isUndefined(contractSpecificSourceData)) {
- throw new Error(`Contract data for ${fileName} not yet set`);
- }
- if (_.isUndefined(contractSpecificSourceData.sourceTreeHashIfExists)) {
- const dependencies = contractSpecificSourceData.dependencies;
- if (dependencies.length === 0) {
- contractSpecificSourceData.sourceTreeHashIfExists = contractSpecificSourceData.sourceHash;
- } else {
- _.forEach(dependencies, dependency => {
- this._setSourceTreeHash(dependency);
- });
- const dependencySourceTreeHashes = _.map(
- dependencies,
- dependency => this._contractSourceData[dependency].sourceTreeHashIfExists,
- );
- const sourceTreeHashesBuffer = Buffer.concat([
- contractSpecificSourceData.sourceHash,
- ...dependencySourceTreeHashes,
- ]);
- contractSpecificSourceData.sourceTreeHashIfExists = ethUtil.sha3(sourceTreeHashesBuffer);
- }
- }
- }
- /**
- * Callback to resolve dependencies with `solc.compile`.
- * Throws error if contractSources not yet initialized.
- * @param importPath Path to an imported dependency.
- * @return Import contents object containing source code of dependency.
+ * Gets contract dependendencies and keccak256 hash from source.
+ * @param source Source code of contract.
+ * @return Object with contract dependencies and keccak256 hash of source.
*/
- private _findImportsIfSourcesExist(importPath: string): solc.ImportContents {
- const fileName = path.basename(importPath);
- const source = this._contractSources[fileName];
- if (_.isUndefined(source)) {
- throw new Error(`Contract source not found for ${fileName}`);
+ private _setContractSpecificSourceData(source: string, fileName: string): void {
+ if (!_.isUndefined(this._contractSourceData[fileName])) {
+ return;
}
- const importContents: solc.ImportContents = {
- contents: source,
+ const sourceHash = ethUtil.sha3(source);
+ const solcVersionRange = parseSolidityVersionRange(source);
+ const dependencies = parseDependencies(source);
+ const sourceTreeHash = this._getSourceTreeHash(fileName, sourceHash, dependencies);
+ this._contractSourceData[fileName] = {
+ dependencies,
+ solcVersionRange,
+ sourceHash,
+ sourceTreeHash,
};
- return importContents;
- }
- /**
- * Creates the artifacts directory if it does not already exist.
- */
- private async _createArtifactsDirIfDoesNotExistAsync(): Promise<void> {
- if (!fsWrapper.doesPathExistSync(this._artifactsDir)) {
- logUtils.log('Creating artifacts directory...');
- await fsWrapper.mkdirAsync(this._artifactsDir);
- }
}
/**
- * Gets contract data on network or returns if an artifact does not exist.
+ * Gets the source tree hash for a file and its dependencies.
* @param fileName Name of contract file.
- * @return Contract data on network or undefined.
*/
- private async _getContractArtifactIfExistsAsync(fileName: string): Promise<ContractArtifact | void> {
- let contractArtifact;
- const contractName = path.basename(fileName, constants.SOLIDITY_FILE_EXTENSION);
- const currentArtifactPath = `${this._artifactsDir}/${contractName}.json`;
- try {
- const opts = {
- encoding: 'utf8',
- };
- const contractArtifactString = await fsWrapper.readFileAsync(currentArtifactPath, opts);
- contractArtifact = JSON.parse(contractArtifactString);
- return contractArtifact;
- } catch (err) {
- logUtils.log(`Artifact for ${fileName} does not exist`);
- return undefined;
+ private _getSourceTreeHash(fileName: string, sourceHash: Buffer, dependencies: string[]): Buffer {
+ if (dependencies.length === 0) {
+ return sourceHash;
+ } else {
+ const dependencySourceTreeHashes = _.map(dependencies, dependency => {
+ const source = this._contractSources[dependency];
+ this._setContractSpecificSourceData(source, dependency);
+ const sourceData = this._contractSourceData[dependency];
+ return this._getSourceTreeHash(dependency, sourceData.sourceHash, sourceData.dependencies);
+ });
+ const sourceTreeHashesBuffer = Buffer.concat([sourceHash, ...dependencySourceTreeHashes]);
+ const sourceTreeHash = ethUtil.sha3(sourceTreeHashesBuffer);
+ return sourceTreeHash;
}
}
}
diff --git a/packages/deployer/src/deployer.ts b/packages/deployer/src/deployer.ts
index 68518a931..7ee45fed5 100644
--- a/packages/deployer/src/deployer.ts
+++ b/packages/deployer/src/deployer.ts
@@ -1,4 +1,4 @@
-import { AbiType, TxData } from '@0xproject/types';
+import { AbiType, ConstructorAbi, ContractAbi, TxData } from '@0xproject/types';
import { logUtils } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as _ from 'lodash';
@@ -71,7 +71,7 @@ export class Deployer {
gas,
};
const abi = contractNetworkDataIfExists.abi;
- const constructorAbi = _.find(abi, { type: AbiType.Constructor }) as Web3.ConstructorAbi;
+ const constructorAbi = _.find(abi, { type: AbiType.Constructor }) as ConstructorAbi;
const constructorArgs = _.isUndefined(constructorAbi) ? [] : constructorAbi.inputs;
if (constructorArgs.length !== args.length) {
const constructorSignature = `constructor(${_.map(constructorArgs, arg => `${arg.type} ${arg.name}`).join(
@@ -107,7 +107,7 @@ export class Deployer {
* @param txData Tx options used for deployment.
* @return Promise that resolves to a web3 contract instance.
*/
- private async _deployFromAbiAsync(abi: Web3.ContractAbi, args: any[], txData: Web3.TxData): Promise<any> {
+ private async _deployFromAbiAsync(abi: ContractAbi, args: any[], txData: TxData): Promise<any> {
const contract: Web3.Contract<Web3.ContractInstance> = this.web3Wrapper.getContractFromAbi(abi);
const deployPromise = new Promise((resolve, reject) => {
/**
diff --git a/packages/deployer/src/globals.d.ts b/packages/deployer/src/globals.d.ts
index 3cff8a909..5b0d495d5 100644
--- a/packages/deployer/src/globals.d.ts
+++ b/packages/deployer/src/globals.d.ts
@@ -1,6 +1,7 @@
+declare module 'dirty-chai';
+
// tslint:disable:completed-docs
declare module 'solc' {
- import * as Web3 from 'web3';
export interface ContractCompilationResult {
srcmap: string;
srcmapRuntime: string;
diff --git a/packages/deployer/src/utils/compiler.ts b/packages/deployer/src/utils/compiler.ts
new file mode 100644
index 000000000..9c8fef26d
--- /dev/null
+++ b/packages/deployer/src/utils/compiler.ts
@@ -0,0 +1,123 @@
+import { logUtils } from '@0xproject/utils';
+import * as _ from 'lodash';
+import * as path from 'path';
+import * as solc from 'solc';
+
+import { constants } from './constants';
+import { fsWrapper } from './fs_wrapper';
+import { ContractArtifact, ContractSources } from './types';
+
+/**
+ * Gets contract data on network or returns if an artifact does not exist.
+ * @param artifactsDir Path to the artifacts directory.
+ * @param fileName Name of contract file.
+ * @return Contract data on network or undefined.
+ */
+export async function getContractArtifactIfExistsAsync(
+ artifactsDir: string,
+ fileName: string,
+): Promise<ContractArtifact | void> {
+ let contractArtifact;
+ const contractName = path.basename(fileName, constants.SOLIDITY_FILE_EXTENSION);
+ const currentArtifactPath = `${artifactsDir}/${contractName}.json`;
+ try {
+ const opts = {
+ encoding: 'utf8',
+ };
+ const contractArtifactString = await fsWrapper.readFileAsync(currentArtifactPath, opts);
+ contractArtifact = JSON.parse(contractArtifactString);
+ return contractArtifact;
+ } catch (err) {
+ logUtils.log(`Artifact for ${fileName} does not exist`);
+ return undefined;
+ }
+}
+
+/**
+ * Creates the artifacts directory if it does not already exist.
+ * @param artifactsDir Path to the artifacts directory.
+ */
+export async function createArtifactsDirIfDoesNotExistAsync(artifactsDir: string): Promise<void> {
+ if (!fsWrapper.doesPathExistSync(artifactsDir)) {
+ logUtils.log('Creating artifacts directory...');
+ await fsWrapper.mkdirAsync(artifactsDir);
+ }
+}
+
+/**
+ * Searches Solidity source code for compiler version range.
+ * @param source Source code of contract.
+ * @return Solc compiler version range.
+ */
+export function parseSolidityVersionRange(source: string): string {
+ const SOLIDITY_VERSION_RANGE_REGEX = /pragma\s+solidity\s+(.*);/;
+ const solcVersionRangeMatch = source.match(SOLIDITY_VERSION_RANGE_REGEX);
+ if (_.isNull(solcVersionRangeMatch)) {
+ throw new Error('Could not find Solidity version range in source');
+ }
+ const solcVersionRange = solcVersionRangeMatch[1];
+ return solcVersionRange;
+}
+
+/**
+ * Normalizes the path found in the error message.
+ * Example: converts 'base/Token.sol:6:46: Warning: Unused local variable'
+ * to 'Token.sol:6:46: Warning: Unused local variable'
+ * This is used to prevent logging the same error multiple times.
+ * @param errMsg An error message from the compiled output.
+ * @return The error message with directories truncated from the contract path.
+ */
+export function getNormalizedErrMsg(errMsg: string): string {
+ const SOLIDITY_FILE_EXTENSION_REGEX = /(.*\.sol)/;
+ const errPathMatch = errMsg.match(SOLIDITY_FILE_EXTENSION_REGEX);
+ if (_.isNull(errPathMatch)) {
+ throw new Error('Could not find a path in error message');
+ }
+ const errPath = errPathMatch[0];
+ const baseContract = path.basename(errPath);
+ const normalizedErrMsg = errMsg.replace(errPath, baseContract);
+ return normalizedErrMsg;
+}
+
+/**
+ * Parses the contract source code and extracts the dendencies
+ * @param source Contract source code
+ * @return List of dependendencies
+ */
+export function parseDependencies(source: string): string[] {
+ // TODO: Use a proper parser
+ const IMPORT_REGEX = /(import\s)/;
+ const DEPENDENCY_PATH_REGEX = /"([^"]+)"/; // Source: https://github.com/BlockChainCompany/soljitsu/blob/master/lib/shared.js
+ const dependencies: string[] = [];
+ const lines = source.split('\n');
+ _.forEach(lines, line => {
+ if (!_.isNull(line.match(IMPORT_REGEX))) {
+ const dependencyMatch = line.match(DEPENDENCY_PATH_REGEX);
+ if (!_.isNull(dependencyMatch)) {
+ const dependencyPath = dependencyMatch[1];
+ const basenName = path.basename(dependencyPath);
+ dependencies.push(basenName);
+ }
+ }
+ });
+ return dependencies;
+}
+
+/**
+ * Callback to resolve dependencies with `solc.compile`.
+ * Throws error if contractSources not yet initialized.
+ * @param contractSources Source codes of contracts.
+ * @param importPath Path to an imported dependency.
+ * @return Import contents object containing source code of dependency.
+ */
+export function findImportIfExist(contractSources: ContractSources, importPath: string): solc.ImportContents {
+ const fileName = path.basename(importPath);
+ const source = contractSources[fileName];
+ if (_.isUndefined(source)) {
+ throw new Error(`Contract source not found for ${fileName}`);
+ }
+ const importContents: solc.ImportContents = {
+ contents: source,
+ };
+ return importContents;
+}
diff --git a/packages/deployer/src/utils/contract.ts b/packages/deployer/src/utils/contract.ts
index 9c57751ff..9b7baac11 100644
--- a/packages/deployer/src/utils/contract.ts
+++ b/packages/deployer/src/utils/contract.ts
@@ -1,4 +1,5 @@
import { schemas, SchemaValidator } from '@0xproject/json-schemas';
+import { ContractAbi, EventAbi, FunctionAbi, MethodAbi, TxData } from '@0xproject/types';
import { promisify } from '@0xproject/utils';
import * as _ from 'lodash';
import * as Web3 from 'web3';
@@ -7,14 +8,14 @@ import { AbiType } from './types';
export class Contract implements Web3.ContractInstance {
public address: string;
- public abi: Web3.ContractAbi;
+ public abi: ContractAbi;
private _contract: Web3.ContractInstance;
- private _defaults: Partial<Web3.TxData>;
+ private _defaults: Partial<TxData>;
private _validator: SchemaValidator;
// This class instance is going to be populated with functions and events depending on the ABI
// and we don't know their types in advance
[name: string]: any;
- constructor(web3ContractInstance: Web3.ContractInstance, defaults: Partial<Web3.TxData>) {
+ constructor(web3ContractInstance: Web3.ContractInstance, defaults: Partial<TxData>) {
this._contract = web3ContractInstance;
this.address = web3ContractInstance.address;
this.abi = web3ContractInstance.abi;
@@ -24,8 +25,8 @@ export class Contract implements Web3.ContractInstance {
this._validator = new SchemaValidator();
}
private _populateFunctions(): void {
- const functionsAbi = _.filter(this.abi, abiPart => abiPart.type === AbiType.Function) as Web3.FunctionAbi[];
- _.forEach(functionsAbi, (functionAbi: Web3.MethodAbi) => {
+ const functionsAbi = _.filter(this.abi, abiPart => abiPart.type === AbiType.Function) as FunctionAbi[];
+ _.forEach(functionsAbi, (functionAbi: MethodAbi) => {
if (functionAbi.constant) {
const cbStyleCallFunction = this._contract[functionAbi.name].call;
this[functionAbi.name] = promisify(cbStyleCallFunction, this._contract);
@@ -42,8 +43,8 @@ export class Contract implements Web3.ContractInstance {
});
}
private _populateEvents(): void {
- const eventsAbi = _.filter(this.abi, abiPart => abiPart.type === AbiType.Event) as Web3.EventAbi[];
- _.forEach(eventsAbi, (eventAbi: Web3.EventAbi) => {
+ const eventsAbi = _.filter(this.abi, abiPart => abiPart.type === AbiType.Event) as EventAbi[];
+ _.forEach(eventsAbi, (eventAbi: EventAbi) => {
this[eventAbi.name] = this._contract[eventAbi.name];
});
}
@@ -51,7 +52,7 @@ export class Contract implements Web3.ContractInstance {
const promisifiedWithDefaultParams = async (...args: any[]) => {
const promise = new Promise((resolve, reject) => {
const lastArg = args[args.length - 1];
- let txData: Partial<Web3.TxData> = {};
+ let txData: Partial<TxData> = {};
if (this._isTxData(lastArg)) {
txData = args.pop();
}
diff --git a/packages/deployer/src/utils/encoder.ts b/packages/deployer/src/utils/encoder.ts
index e3acde252..4f62662e1 100644
--- a/packages/deployer/src/utils/encoder.ts
+++ b/packages/deployer/src/utils/encoder.ts
@@ -1,15 +1,15 @@
+import { AbiDefinition, ContractAbi, DataItem } from '@0xproject/types';
import * as _ from 'lodash';
-import * as Web3 from 'web3';
import * as web3Abi from 'web3-eth-abi';
import { AbiType } from './types';
export const encoder = {
- encodeConstructorArgsFromAbi(args: any[], abi: Web3.ContractAbi): string {
+ encodeConstructorArgsFromAbi(args: any[], abi: ContractAbi): string {
const constructorTypes: string[] = [];
- _.each(abi, (element: Web3.AbiDefinition) => {
+ _.each(abi, (element: AbiDefinition) => {
if (element.type === AbiType.Constructor) {
- _.each(element.inputs, (input: Web3.DataItem) => {
+ _.each(element.inputs, (input: DataItem) => {
constructorTypes.push(input.type);
});
}
diff --git a/packages/deployer/src/utils/error_reporter.ts b/packages/deployer/src/utils/error_reporter.ts
new file mode 100644
index 000000000..4e73307f0
--- /dev/null
+++ b/packages/deployer/src/utils/error_reporter.ts
@@ -0,0 +1,18 @@
+import { logUtils } from '@0xproject/utils';
+
+/**
+ * Makes an async function no-throw printing errors to the console
+ * @param asyncFn async function to wrap
+ * @return Wrapped version of the passed function
+ */
+export function consoleReporter<T>(asyncFn: (arg: T) => Promise<void>): (arg: T) => Promise<void> {
+ const noThrowFnAsync = async (arg: T) => {
+ try {
+ const result = await asyncFn(arg);
+ return result;
+ } catch (err) {
+ logUtils.log(`${err}`);
+ }
+ };
+ return noThrowFnAsync;
+}
diff --git a/packages/deployer/src/utils/fs_wrapper.ts b/packages/deployer/src/utils/fs_wrapper.ts
index 34c7caa0e..e02c83f27 100644
--- a/packages/deployer/src/utils/fs_wrapper.ts
+++ b/packages/deployer/src/utils/fs_wrapper.ts
@@ -7,5 +7,6 @@ export const fsWrapper = {
writeFileAsync: promisify<undefined>(fs.writeFile),
mkdirAsync: promisify<undefined>(fs.mkdir),
doesPathExistSync: fs.existsSync,
+ rmdirSync: fs.rmdirSync,
removeFileAsync: promisify<undefined>(fs.unlink),
};
diff --git a/packages/deployer/src/utils/types.ts b/packages/deployer/src/utils/types.ts
index 0068faf6a..7cb3958cb 100644
--- a/packages/deployer/src/utils/types.ts
+++ b/packages/deployer/src/utils/types.ts
@@ -1,4 +1,4 @@
-import { TxData } from '@0xproject/types';
+import { ContractAbi, TxData } from '@0xproject/types';
import * as Web3 from 'web3';
import * as yargs from 'yargs';
@@ -20,10 +20,10 @@ export interface ContractNetworks {
export interface ContractNetworkData {
solc_version: string;
- optimizer_enabled: number;
+ optimizer_enabled: boolean;
keccak256: string;
source_tree_hash: string;
- abi: Web3.ContractAbi;
+ abi: ContractAbi;
bytecode: string;
runtime_bytecode: string;
address?: string;
@@ -53,7 +53,7 @@ export interface CliOptions extends yargs.Arguments {
export interface CompilerOptions {
contractsDir: string;
networkId: number;
- optimizerEnabled: number;
+ optimizerEnabled: boolean;
artifactsDir: string;
specifiedContracts: Set<string>;
}
@@ -84,27 +84,9 @@ export interface ContractSourceData {
export interface ContractSpecificSourceData {
dependencies: string[];
- solcVersion: string;
+ solcVersionRange: string;
sourceHash: Buffer;
- sourceTreeHashIfExists?: Buffer;
-}
-
-// TODO: Consolidate with 0x.js definitions once types are moved into a separate package.
-export enum ZeroExError {
- ContractDoesNotExist = 'CONTRACT_DOES_NOT_EXIST',
- ExchangeContractDoesNotExist = 'EXCHANGE_CONTRACT_DOES_NOT_EXIST',
- UnhandledError = 'UNHANDLED_ERROR',
- UserHasNoAssociatedAddress = 'USER_HAS_NO_ASSOCIATED_ADDRESSES',
- InvalidSignature = 'INVALID_SIGNATURE',
- ContractNotDeployedOnNetwork = 'CONTRACT_NOT_DEPLOYED_ON_NETWORK',
- InsufficientAllowanceForTransfer = 'INSUFFICIENT_ALLOWANCE_FOR_TRANSFER',
- InsufficientBalanceForTransfer = 'INSUFFICIENT_BALANCE_FOR_TRANSFER',
- InsufficientEthBalanceForDeposit = 'INSUFFICIENT_ETH_BALANCE_FOR_DEPOSIT',
- InsufficientWEthBalanceForWithdrawal = 'INSUFFICIENT_WETH_BALANCE_FOR_WITHDRAWAL',
- InvalidJump = 'INVALID_JUMP',
- OutOfGas = 'OUT_OF_GAS',
- NoNetworkId = 'NO_NETWORK_ID',
- SubscriptionNotFound = 'SUBSCRIPTION_NOT_FOUND',
+ sourceTreeHash: Buffer;
}
export interface Token {
diff --git a/packages/deployer/test/compiler_test.ts b/packages/deployer/test/compiler_test.ts
new file mode 100644
index 000000000..b03ae7935
--- /dev/null
+++ b/packages/deployer/test/compiler_test.ts
@@ -0,0 +1,47 @@
+import * as chai from 'chai';
+import 'mocha';
+
+import { Compiler } from '../src/compiler';
+import { fsWrapper } from '../src/utils/fs_wrapper';
+import { CompilerOptions, ContractArtifact, ContractNetworkData, DoneCallback } from '../src/utils/types';
+
+import { exchange_binary } from './fixtures/exchange_bin';
+import { constants } from './util/constants';
+
+const expect = chai.expect;
+
+describe('#Compiler', function() {
+ this.timeout(constants.timeoutMs);
+ const artifactsDir = `${__dirname}/fixtures/artifacts`;
+ const contractsDir = `${__dirname}/fixtures/contracts`;
+ const exchangeArtifactPath = `${artifactsDir}/Exchange.json`;
+ const compilerOpts: CompilerOptions = {
+ artifactsDir,
+ contractsDir,
+ networkId: constants.networkId,
+ optimizerEnabled: constants.optimizerEnabled,
+ specifiedContracts: new Set(constants.specifiedContracts),
+ };
+ const compiler = new Compiler(compilerOpts);
+ beforeEach((done: DoneCallback) => {
+ (async () => {
+ if (fsWrapper.doesPathExistSync(exchangeArtifactPath)) {
+ await fsWrapper.removeFileAsync(exchangeArtifactPath);
+ }
+ await compiler.compileAsync();
+ done();
+ })().catch(done);
+ });
+ it('should create an Exchange artifact with the correct unlinked binary', async () => {
+ const opts = {
+ encoding: 'utf8',
+ };
+ const exchangeArtifactString = await fsWrapper.readFileAsync(exchangeArtifactPath, opts);
+ const exchangeArtifact: ContractArtifact = JSON.parse(exchangeArtifactString);
+ const exchangeContractData: ContractNetworkData = exchangeArtifact.networks[constants.networkId];
+ // The last 43 bytes of the binaries are metadata which may not be equivalent
+ const unlinkedBinaryWithoutMetadata = exchangeContractData.bytecode.slice(0, -86);
+ const exchangeBinaryWithoutMetadata = exchange_binary.slice(0, -86);
+ expect(unlinkedBinaryWithoutMetadata).to.equal(exchangeBinaryWithoutMetadata);
+ });
+});
diff --git a/packages/deployer/test/compiler_utils_test.ts b/packages/deployer/test/compiler_utils_test.ts
new file mode 100644
index 000000000..1867177dc
--- /dev/null
+++ b/packages/deployer/test/compiler_utils_test.ts
@@ -0,0 +1,74 @@
+import * as chai from 'chai';
+import * as dirtyChai from 'dirty-chai';
+import 'mocha';
+
+import {
+ createArtifactsDirIfDoesNotExistAsync,
+ getNormalizedErrMsg,
+ parseDependencies,
+ parseSolidityVersionRange,
+} from '../src/utils/compiler';
+import { fsWrapper } from '../src/utils/fs_wrapper';
+
+chai.use(dirtyChai);
+const expect = chai.expect;
+
+describe('Compiler utils', () => {
+ describe('#getNormalizedErrorMessage', () => {
+ it('normalizes the error message', () => {
+ const errMsg = 'base/Token.sol:6:46: Warning: Unused local variable';
+ const normalizedErrMsg = getNormalizedErrMsg(errMsg);
+ expect(normalizedErrMsg).to.be.equal('Token.sol:6:46: Warning: Unused local variable');
+ });
+ });
+ describe('#createArtifactsDirIfDoesNotExistAsync', () => {
+ it('creates artifacts dir', async () => {
+ const artifactsDir = `${__dirname}/artifacts`;
+ expect(fsWrapper.doesPathExistSync(artifactsDir)).to.be.false();
+ await createArtifactsDirIfDoesNotExistAsync(artifactsDir);
+ expect(fsWrapper.doesPathExistSync(artifactsDir)).to.be.true();
+ fsWrapper.rmdirSync(artifactsDir);
+ expect(fsWrapper.doesPathExistSync(artifactsDir)).to.be.false();
+ });
+ });
+ describe('#parseSolidityVersionRange', () => {
+ it('correctly parses the version range', () => {
+ expect(parseSolidityVersionRange('pragma solidity ^0.0.1;')).to.be.equal('^0.0.1');
+ expect(parseSolidityVersionRange('\npragma solidity 0.0.1;')).to.be.equal('0.0.1');
+ expect(parseSolidityVersionRange('pragma solidity <=1.0.1;')).to.be.equal('<=1.0.1');
+ expect(parseSolidityVersionRange('pragma solidity ~1.0.1;')).to.be.equal('~1.0.1');
+ });
+ // TODO: For now that doesn't work. This will work after we switch to a grammar-based parser
+ it.skip('correctly parses the version range with comments', () => {
+ expect(parseSolidityVersionRange('// pragma solidity ~1.0.1;\npragma solidity ~1.0.2;')).to.be.equal(
+ '~1.0.2',
+ );
+ });
+ });
+ describe('#parseDependencies', () => {
+ it('correctly parses Exchange dependencies', async () => {
+ const exchangeSource = await fsWrapper.readFileAsync(`${__dirname}/fixtures/contracts/Exchange.sol`, {
+ encoding: 'utf8',
+ });
+ expect(parseDependencies(exchangeSource)).to.be.deep.equal([
+ 'TokenTransferProxy.sol',
+ 'Token.sol',
+ 'SafeMath.sol',
+ ]);
+ });
+ it('correctly parses TokenTransferProxy dependencies', async () => {
+ const exchangeSource = await fsWrapper.readFileAsync(
+ `${__dirname}/fixtures/contracts/TokenTransferProxy.sol`,
+ {
+ encoding: 'utf8',
+ },
+ );
+ expect(parseDependencies(exchangeSource)).to.be.deep.equal(['Token.sol', 'Ownable.sol']);
+ });
+ // TODO: For now that doesn't work. This will work after we switch to a grammar-based parser
+ it.skip('correctly parses commented out dependencies', async () => {
+ const contractWithCommentedOutDependencies = `// import "./TokenTransferProxy.sol";`;
+ expect(parseDependencies(contractWithCommentedOutDependencies)).to.be.deep.equal([]);
+ });
+ });
+});
diff --git a/packages/deployer/test/deploy_test.ts b/packages/deployer/test/deployer_test.ts
index 26ce337ef..9c34d74aa 100644
--- a/packages/deployer/test/deploy_test.ts
+++ b/packages/deployer/test/deployer_test.ts
@@ -10,55 +10,38 @@ import { constructor_args, exchange_binary } from './fixtures/exchange_bin';
import { constants } from './util/constants';
const expect = chai.expect;
-const artifactsDir = `${__dirname}/fixtures/artifacts`;
-const contractsDir = `${__dirname}/fixtures/contracts`;
-const exchangeArtifactPath = `${artifactsDir}/Exchange.json`;
-const compilerOpts: CompilerOptions = {
- artifactsDir,
- contractsDir,
- networkId: constants.networkId,
- optimizerEnabled: constants.optimizerEnabled,
- specifiedContracts: new Set(constants.specifiedContracts),
-};
-const compiler = new Compiler(compilerOpts);
-const deployerOpts = {
- artifactsDir,
- networkId: constants.networkId,
- jsonrpcUrl: constants.jsonrpcUrl,
- defaults: {
- gasPrice: constants.gasPrice,
- },
-};
-const deployer = new Deployer(deployerOpts);
-/* tslint:disable */
-beforeEach(function(done: DoneCallback) {
- this.timeout(constants.timeoutMs);
- (async () => {
- if (fsWrapper.doesPathExistSync(exchangeArtifactPath)) {
- await fsWrapper.removeFileAsync(exchangeArtifactPath);
- }
- await compiler.compileAllAsync();
- done();
- })().catch(done);
-});
-/* tslint:enable */
-
-describe('#Compiler', () => {
- it('should create an Exchange artifact with the correct unlinked binary', async () => {
- const opts = {
- encoding: 'utf8',
- };
- const exchangeArtifactString = await fsWrapper.readFileAsync(exchangeArtifactPath, opts);
- const exchangeArtifact: ContractArtifact = JSON.parse(exchangeArtifactString);
- const exchangeContractData: ContractNetworkData = exchangeArtifact.networks[constants.networkId];
- // The last 43 bytes of the binaries are metadata which may not be equivalent
- const unlinkedBinaryWithoutMetadata = exchangeContractData.bytecode.slice(0, -86);
- const exchangeBinaryWithoutMetadata = exchange_binary.slice(0, -86);
- expect(unlinkedBinaryWithoutMetadata).to.equal(exchangeBinaryWithoutMetadata);
- });
-});
describe('#Deployer', () => {
+ const artifactsDir = `${__dirname}/fixtures/artifacts`;
+ const contractsDir = `${__dirname}/fixtures/contracts`;
+ const exchangeArtifactPath = `${artifactsDir}/Exchange.json`;
+ const compilerOpts: CompilerOptions = {
+ artifactsDir,
+ contractsDir,
+ networkId: constants.networkId,
+ optimizerEnabled: constants.optimizerEnabled,
+ specifiedContracts: new Set(constants.specifiedContracts),
+ };
+ const compiler = new Compiler(compilerOpts);
+ const deployerOpts = {
+ artifactsDir,
+ networkId: constants.networkId,
+ jsonrpcUrl: constants.jsonrpcUrl,
+ defaults: {
+ gasPrice: constants.gasPrice,
+ },
+ };
+ const deployer = new Deployer(deployerOpts);
+ beforeEach(function(done: DoneCallback) {
+ this.timeout(constants.timeoutMs);
+ (async () => {
+ if (fsWrapper.doesPathExistSync(exchangeArtifactPath)) {
+ await fsWrapper.removeFileAsync(exchangeArtifactPath);
+ }
+ await compiler.compileAsync();
+ done();
+ })().catch(done);
+ });
describe('#deployAsync', () => {
it('should deploy the Exchange contract without updating the Exchange artifact', async () => {
const exchangeConstructorArgs = [constants.zrxTokenAddress, constants.tokenTransferProxyAddress];
diff --git a/packages/deployer/test/util/constants.ts b/packages/deployer/test/util/constants.ts
index 7b6960359..5d3aab47c 100644
--- a/packages/deployer/test/util/constants.ts
+++ b/packages/deployer/test/util/constants.ts
@@ -3,7 +3,7 @@ import { BigNumber } from '@0xproject/utils';
export const constants = {
networkId: 0,
jsonrpcUrl: 'http://localhost:8545',
- optimizerEnabled: 0,
+ optimizerEnabled: false,
gasPrice: new BigNumber(20000000000),
timeoutMs: 20000,
zrxTokenAddress: '0xe41d2489571d322189246dafa5ebde1f4699f498',
diff --git a/packages/deployer/tsconfig.json b/packages/deployer/tsconfig.json
index 897446b66..a4cbc37c5 100644
--- a/packages/deployer/tsconfig.json
+++ b/packages/deployer/tsconfig.json
@@ -2,16 +2,12 @@
"extends": "../../tsconfig",
"compilerOptions": {
"outDir": "lib",
- "strictFunctionTypes": false,
- "strictNullChecks": false
+ "strictFunctionTypes": false
},
"include": [
"./src/**/*",
"./test/**/*",
"../../node_modules/types-bn/index.d.ts",
- "../../node_modules/types-ethereumjs-util/index.d.ts",
- "../../node_modules/chai-typescript-typings/index.d.ts",
- "../../node_modules/ethers-typescript-typings/index.d.ts",
- "../../node_modules/web3-typescript-typings/index.d.ts"
+ "../../node_modules/types-ethereumjs-util/index.d.ts"
]
}
diff --git a/packages/dev-utils/.npmignore b/packages/dev-utils/.npmignore
index 05fa23a59..44df80fad 100644
--- a/packages/dev-utils/.npmignore
+++ b/packages/dev-utils/.npmignore
@@ -4,3 +4,4 @@ yarn-error.log
/scripts/
test/
tsconfig.json
+/lib/src/monorepo_scripts/
diff --git a/packages/dev-utils/README.md b/packages/dev-utils/README.md
index 0c4175e35..d7e580d9f 100644
--- a/packages/dev-utils/README.md
+++ b/packages/dev-utils/README.md
@@ -21,8 +21,8 @@ yarn add @0xproject/dev-utils
If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`:
-```
-"include": [
- "./node_modules/web3-typescript-typings/index.d.ts",
-]
+```json
+"compilerOptions": {
+ "typeRoots": ["node_modules/@0xproject/typescript-typings/types", "node_modules/@types"],
+}
```
diff --git a/packages/dev-utils/package.json b/packages/dev-utils/package.json
index de18f4354..71c1615e8 100644
--- a/packages/dev-utils/package.json
+++ b/packages/dev-utils/package.json
@@ -30,7 +30,6 @@
"@types/lodash": "4.14.104",
"@types/mocha": "^2.2.42",
"chai": "^4.0.1",
- "chai-typescript-typings": "^0.0.6",
"copyfiles": "^1.2.0",
"mocha": "^4.0.1",
"npm-run-all": "^4.1.2",
@@ -47,6 +46,7 @@
"@0xproject/types": "^0.4.1",
"@0xproject/utils": "^0.4.3",
"@0xproject/web3-wrapper": "^0.3.1",
+ "@0xproject/typescript-typings": "^0.0.1",
"ethereumjs-util": "^5.1.2",
"lodash": "^4.17.4",
"request-promise-native": "^1.0.5",
diff --git a/packages/dev-utils/tsconfig.json b/packages/dev-utils/tsconfig.json
index 1ed3fbc9c..7b93af0da 100644
--- a/packages/dev-utils/tsconfig.json
+++ b/packages/dev-utils/tsconfig.json
@@ -7,9 +7,6 @@
"./src/**/*",
"./test/**/*",
"../../node_modules/types-bn/index.d.ts",
- "../../node_modules/chai-typescript-typings/index.d.ts",
- "../../node_modules/ethers-typescript-typings/index.d.ts",
- "../../node_modules/web3-typescript-typings/index.d.ts",
"../../node_modules/types-ethereumjs-util/index.d.ts"
]
}
diff --git a/packages/ethers-typescript-typings/.npmignore b/packages/ethers-typescript-typings/.npmignore
deleted file mode 100644
index 104d718ed..000000000
--- a/packages/ethers-typescript-typings/.npmignore
+++ /dev/null
@@ -1,3 +0,0 @@
-.*
-yarn-error.log
-/scripts/
diff --git a/packages/ethers-typescript-typings/CHANGELOG.md b/packages/ethers-typescript-typings/CHANGELOG.md
deleted file mode 100644
index 00bf165a4..000000000
--- a/packages/ethers-typescript-typings/CHANGELOG.md
+++ /dev/null
@@ -1,5 +0,0 @@
-# CHANGELOG
-
-## v0.0.2 - _March 4, 2018_
-
- * Initial types (#413)
diff --git a/packages/ethers-typescript-typings/README.md b/packages/ethers-typescript-typings/README.md
deleted file mode 100644
index 56ce5f138..000000000
--- a/packages/ethers-typescript-typings/README.md
+++ /dev/null
@@ -1,49 +0,0 @@
-## ethers-typescript-typings
-
-There currently isn't an official [Ethers][ethers]
-type definition included in the [DefinitelyTyped][definitelytyped] project.
-Until that happens, we will continue to improve our own type definition.
-If it get's close to comprehensive, we'll add it to [DefinitelyTyped][definitelytyped].
-
-[ethers]: https://github.com/ethers-io/ethers.js
-[definitelytyped]: https://github.com/DefinitelyTyped/DefinitelyTyped
-
-## Installation
-
-```bash
-yarn add -D ethers-typescript-typings
-```
-
-## Usage
-
-Add the following line within an `include` section of your `tsconfig.json`
-
-```json
-"./node_modules/ethers-typescript-typings/index.d.ts"
-```
-
-## Contributing
-
-We strongly encourage that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository.
-
-Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
-
-### Install Dependencies
-
-If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
-
-```bash
-yarn config set workspaces-experimental true
-```
-
-Then install dependencies
-
-```bash
-yarn install
-```
-
-### Lint
-
-```bash
-yarn lint
-```
diff --git a/packages/ethers-typescript-typings/monorepo_scripts/globals.d.ts b/packages/ethers-typescript-typings/monorepo_scripts/globals.d.ts
deleted file mode 100644
index 94e63a32d..000000000
--- a/packages/ethers-typescript-typings/monorepo_scripts/globals.d.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-declare module '*.json' {
- const json: any;
- /* tslint:disable */
- export default json;
- /* tslint:enable */
-}
diff --git a/packages/ethers-typescript-typings/monorepo_scripts/postpublish.ts b/packages/ethers-typescript-typings/monorepo_scripts/postpublish.ts
deleted file mode 100644
index dcb99d0f7..000000000
--- a/packages/ethers-typescript-typings/monorepo_scripts/postpublish.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import { postpublishUtils } from '@0xproject/monorepo-scripts';
-
-import * as packageJSON from '../package.json';
-import * as tsConfigJSON from '../tsconfig.json';
-
-const cwd = `${__dirname}/..`;
-// tslint:disable-next-line:no-floating-promises
-postpublishUtils.runAsync(packageJSON, tsConfigJSON, cwd);
diff --git a/packages/ethers-typescript-typings/package.json b/packages/ethers-typescript-typings/package.json
deleted file mode 100644
index d797033e1..000000000
--- a/packages/ethers-typescript-typings/package.json
+++ /dev/null
@@ -1,36 +0,0 @@
-{
- "name": "ethers-typescript-typings",
- "version": "0.0.4",
- "description": "Typescript type definitions for ethers.js",
- "main": "index.d.ts",
- "types": "index.d.ts",
- "scripts": {
- "lint": "tslint index.d.ts",
- "build": "tsc && copyfiles -u 1 './lib/**/*' ./scripts",
- "clean": "shx rm -rf scripts"
- },
- "repository": {
- "type": "git",
- "url": "git+https://github.com/0xProject/0x-monorepo.git"
- },
- "author": "Fabio Berger",
- "contributors": [
- "Leonid Logvinov <logvinov.leon@gmail.com>"
- ],
- "license": "Apache-2.0",
- "bugs": {
- "url": "https://github.com/0xProject/0x-monorepo/issues"
- },
- "homepage": "https://github.com/0xProject/0x-monorepo/packages/ethers-typescript-typings#readme",
- "devDependencies": {
- "@0xproject/monorepo-scripts": "^0.1.14",
- "copyfiles": "^1.2.0",
- "shx": "^0.2.2",
- "tslint": "5.8.0",
- "tslint-config-0xproject": "^0.0.2",
- "typescript": "2.7.1"
- },
- "publishConfig": {
- "access": "public"
- }
-}
diff --git a/packages/ethers-typescript-typings/tsconfig.json b/packages/ethers-typescript-typings/tsconfig.json
deleted file mode 100644
index bc453af4b..000000000
--- a/packages/ethers-typescript-typings/tsconfig.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "extends": "../../tsconfig",
- "compilerOptions": {
- "outDir": "lib"
- },
- "include": ["./monorepo_scripts/**/*"]
-}
diff --git a/packages/ethers-typescript-typings/tslint.json b/packages/ethers-typescript-typings/tslint.json
deleted file mode 100644
index 9a93a1f74..000000000
--- a/packages/ethers-typescript-typings/tslint.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "extends": ["tslint-config-0xproject"]
-}
diff --git a/packages/json-schemas/.npmignore b/packages/json-schemas/.npmignore
index e14c0cba7..5333847e7 100644
--- a/packages/json-schemas/.npmignore
+++ b/packages/json-schemas/.npmignore
@@ -5,3 +5,4 @@ yarn-error.log
/schemas/
test/
tsconfig.json
+/lib/src/monorepo_scripts/
diff --git a/packages/json-schemas/README.md b/packages/json-schemas/README.md
index f320196e9..980d17416 100644
--- a/packages/json-schemas/README.md
+++ b/packages/json-schemas/README.md
@@ -12,8 +12,8 @@ yarn add @0xproject/json-schemas
**Import**
-```javascript
-import { schemas } from '@0xproject/json-schemas';
+```typescript
+import { SchemaValidator, ValidatorResult, schemas } from '@0xproject/json-schemas';
```
or
@@ -22,6 +22,14 @@ or
var schemas = require('@0xproject/json-schemas').schemas;
```
+If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`:
+
+```json
+"compilerOptions": {
+ "typeRoots": ["node_modules/@0xproject/typescript-typings/types", "node_modules/@types"],
+}
+```
+
## Contributing
We strongly encourage that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository.
diff --git a/packages/json-schemas/package.json b/packages/json-schemas/package.json
index 1266f964b..f4f4c63b5 100644
--- a/packages/json-schemas/package.json
+++ b/packages/json-schemas/package.json
@@ -39,6 +39,7 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/packages/json-schemas/README.md",
"dependencies": {
+ "@0xproject/typescript-typings": "^0.0.1",
"jsonschema": "^1.2.0",
"lodash.values": "^4.3.0"
},
@@ -50,7 +51,6 @@
"@types/lodash.values": "^4.3.3",
"@types/mocha": "^2.2.42",
"chai": "^4.0.1",
- "chai-typescript-typings": "^0.0.6",
"copyfiles": "^1.2.0",
"dirty-chai": "^2.0.1",
"lodash.foreach": "^4.5.0",
diff --git a/packages/json-schemas/tsconfig.json b/packages/json-schemas/tsconfig.json
index 10354fa33..e35816553 100644
--- a/packages/json-schemas/tsconfig.json
+++ b/packages/json-schemas/tsconfig.json
@@ -3,10 +3,5 @@
"compilerOptions": {
"outDir": "lib"
},
- "include": [
- "./src/**/*",
- "./test/**/*",
- "../../node_modules/web3-typescript-typings/index.d.ts",
- "../../node_modules/chai-typescript-typings/index.d.ts"
- ]
+ "include": ["./src/**/*", "./test/**/*"]
}
diff --git a/packages/monorepo-scripts/package.json b/packages/monorepo-scripts/package.json
index a8f4918ca..5333e6cad 100644
--- a/packages/monorepo-scripts/package.json
+++ b/packages/monorepo-scripts/package.json
@@ -25,6 +25,8 @@
"@0xproject/tslint-config": "0.4.8",
"@types/glob": "^5.0.33",
"@types/node": "^8.0.53",
+ "@types/rimraf": "^2.0.2",
+ "lerna-get-packages": "^1.0.0",
"shx": "^0.2.2",
"tslint": "5.8.0",
"typescript": "2.7.1"
@@ -35,7 +37,9 @@
"es6-promisify": "^5.0.0",
"glob": "^7.1.2",
"lodash": "^4.17.4",
+ "promisify-child-process": "^1.0.5",
"publish-release": "0xproject/publish-release",
+ "rimraf": "^2.6.2",
"semver-sort": "^0.0.4"
},
"publishConfig": {
diff --git a/packages/monorepo-scripts/src/globals.d.ts b/packages/monorepo-scripts/src/globals.d.ts
index 757ae4097..1d49559f2 100644
--- a/packages/monorepo-scripts/src/globals.d.ts
+++ b/packages/monorepo-scripts/src/globals.d.ts
@@ -6,3 +6,22 @@ declare module 'es6-promisify';
declare module 'semver-sort' {
const desc: (versions: string[]) => string[];
}
+
+declare interface LernaPackage {
+ location: string;
+ package: {
+ private?: boolean;
+ name: string;
+ main?: string;
+ config?: {
+ additionalTsTypings?: string[];
+ };
+ };
+}
+declare function lernaGetPackages(path: string): LernaPackage[];
+// lerna-get-packages declarations
+declare module 'lerna-get-packages' {
+ export = lernaGetPackages;
+}
+
+declare module 'promisify-child-process';
diff --git a/packages/monorepo-scripts/src/test_installation.ts b/packages/monorepo-scripts/src/test_installation.ts
new file mode 100644
index 000000000..195b64b2a
--- /dev/null
+++ b/packages/monorepo-scripts/src/test_installation.ts
@@ -0,0 +1,58 @@
+#!/usr/bin/env node
+
+import * as fs from 'fs';
+import lernaGetPackages = require('lerna-get-packages');
+import * as _ from 'lodash';
+import * as path from 'path';
+import { exec as execAsync } from 'promisify-child-process';
+import * as rimraf from 'rimraf';
+
+import { utils } from './utils';
+
+(async () => {
+ const monorepoRootPath = path.join(__dirname, '../../..');
+ const lernaPackages = lernaGetPackages(monorepoRootPath);
+ const installablePackages = _.filter(
+ lernaPackages,
+ lernaPackage =>
+ !lernaPackage.package.private &&
+ !_.isUndefined(lernaPackage.package.main) &&
+ lernaPackage.package.main.endsWith('.js'),
+ );
+ for (const installableLernaPackage of installablePackages) {
+ const packagePath = installableLernaPackage.location;
+ const packageName = installableLernaPackage.package.name;
+ utils.log(`Testing ${packageName}`);
+ let result = await execAsync('npm pack', { cwd: packagePath });
+ const packedPackageFileName = result.stdout.trim();
+ const testDirectory = path.join(monorepoRootPath, '../test-env');
+ fs.mkdirSync(testDirectory);
+ result = await execAsync('yarn init --yes', { cwd: testDirectory });
+ utils.log(`Installing ${packedPackageFileName}`);
+ result = await execAsync(`yarn add ${packagePath}/${packedPackageFileName}`, { cwd: testDirectory });
+ const indexFilePath = path.join(testDirectory, 'index.ts');
+ fs.writeFileSync(indexFilePath, `import * as Package from '${packageName}'`);
+ const tsConfig = {
+ compilerOptions: {
+ typeRoots: ['node_modules/@0xproject/typescript-typings/types', 'node_modules/@types'],
+ module: 'commonjs',
+ target: 'es5',
+ lib: ['es2017', 'dom'],
+ declaration: true,
+ noImplicitReturns: true,
+ pretty: true,
+ strict: true,
+ },
+ include: ['index.ts'],
+ };
+ const tsconfigFilePath = path.join(testDirectory, 'tsconfig.json');
+ fs.writeFileSync(tsconfigFilePath, JSON.stringify(tsConfig, null, 4));
+ utils.log(`Compiling ${packageName}`);
+ await execAsync('../node_modules/typescript/bin/tsc', { cwd: testDirectory });
+ utils.log(`Successfully compiled with ${packageName} as a dependency`);
+ rimraf.sync(testDirectory);
+ }
+})().catch(err => {
+ utils.log(err.stdout);
+ process.exit(1);
+});
diff --git a/packages/monorepo-scripts/tsconfig.json b/packages/monorepo-scripts/tsconfig.json
index 3d967d05f..5ec2db5e0 100644
--- a/packages/monorepo-scripts/tsconfig.json
+++ b/packages/monorepo-scripts/tsconfig.json
@@ -1,7 +1,8 @@
{
"extends": "../../tsconfig",
"compilerOptions": {
+ "typeRoots": ["node_modules/@types"],
"outDir": "lib"
},
- "include": ["./src/**/*", "../../node_modules/web3-typescript-typings/index.d.ts"]
+ "include": ["./src/**/*"]
}
diff --git a/packages/react-docs-example/package.json b/packages/react-docs-example/package.json
index 2dce1a0eb..25fa1ecd2 100644
--- a/packages/react-docs-example/package.json
+++ b/packages/react-docs-example/package.json
@@ -27,8 +27,8 @@
"@types/lodash": "4.14.104",
"@types/material-ui": "0.18.0",
"@types/node": "^8.0.53",
- "@types/react": "^15.0.15",
- "@types/react-dom": "^0.14.23",
+ "@types/react": "^16.0.34",
+ "@types/react-dom": "^16.0.3",
"@types/react-tap-event-plugin": "0.0.30",
"awesome-typescript-loader": "^3.1.3",
"copyfiles": "^1.2.0",
diff --git a/packages/react-docs-example/ts/docs.tsx b/packages/react-docs-example/ts/docs.tsx
index 68db66b60..eef331813 100644
--- a/packages/react-docs-example/ts/docs.tsx
+++ b/packages/react-docs-example/ts/docs.tsx
@@ -46,26 +46,25 @@ const docsInfoConfig: DocsInfoConfig = {
typeConfigs: {
// Note: This needs to be kept in sync with the types exported in index.ts. Unfortunately there is
// currently no way to extract the re-exported types from index.ts via TypeDoc :(
- publicTypes: ['TxData', 'TransactionReceipt', 'RawLogEntry'],
+ publicTypes: [
+ 'TxData',
+ 'TransactionReceipt',
+ 'RawLogEntry',
+ 'BlockParam',
+ 'ContractAbi',
+ 'FilterObject',
+ 'LogEntry',
+ 'BlockWithoutTransactionData',
+ 'CallData',
+ 'LogEntryEvent',
+ ],
typeNameToExternalLink: {
Web3: 'https://github.com/ethereum/wiki/wiki/JavaScript-API',
Provider: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L150',
- BigNumber: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L127',
- LogEntryEvent: 'http://mikemcl.github.io/bignumber.js',
- CallData: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L348',
- BlockWithoutTransactionData:
- 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L314',
- LogEntry: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L366',
- FilterObject: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L109',
- ['Web3.BlockParam']: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L278',
- ['Web3.ContractAbi']: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L47',
+ BigNumber: 'http://mikemcl.github.io/bignumber.js',
},
typeNameToPrefix: {
Provider: 'Web3',
- CallData: 'Web3',
- BlockWithoutTransactionData: 'Web3',
- LogEntry: 'Web3',
- FilterObject: 'Web3',
},
typeNameToDocSection: {
Web3Wrapper: docSections.web3Wrapper,
diff --git a/packages/react-docs/.npmignore b/packages/react-docs/.npmignore
index 87bc30436..d645458f6 100644
--- a/packages/react-docs/.npmignore
+++ b/packages/react-docs/.npmignore
@@ -3,3 +3,4 @@ yarn-error.log
/src/
/scripts/
tsconfig.json
+/lib/monorepo_scripts/
diff --git a/packages/react-docs/README.md b/packages/react-docs/README.md
index cad05ca67..9be370f10 100644
--- a/packages/react-docs/README.md
+++ b/packages/react-docs/README.md
@@ -33,6 +33,14 @@ This package exposes both a single `Documentation` react component that will ren
Currently this package still has some external dependencies outside of the `Documentation` component, so please start your project off by copying the [react-docs-example](https://github.com/0xProject/0x-monorepo/tree/development/packages/react-docs-example) directory and modifying it there. If you need changes in the [react-docs](https://github.com/0xProject/0x-monorepo/tree/development/packages/react-docs) package, fork the 0x monorepo, make the required changes and submit a PR. Until we merge it, you can have your project depend on your own custom fork.
+If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`:
+
+```json
+"compilerOptions": {
+ "typeRoots": ["node_modules/@0xproject/typescript-typings/types", "node_modules/@types"],
+}
+```
+
## Future improvements
Feel free to contribute to these improvements!
diff --git a/packages/react-docs/package.json b/packages/react-docs/package.json
index ebc445d98..0b0a52efa 100644
--- a/packages/react-docs/package.json
+++ b/packages/react-docs/package.json
@@ -35,8 +35,8 @@
"@types/lodash": "4.14.104",
"@types/material-ui": "0.18.0",
"@types/node": "^8.0.53",
- "@types/react": "^15.0.15",
- "@types/react-dom": "^0.14.23",
+ "@types/react": "^16.0.34",
+ "@types/react-dom": "^16.0.3",
"@types/react-scroll": "0.0.31",
"@types/react-tap-event-plugin": "0.0.30",
"basscss": "^8.0.3",
diff --git a/packages/react-docs/tsconfig.json b/packages/react-docs/tsconfig.json
index 9af6638a2..82f44a62c 100644
--- a/packages/react-docs/tsconfig.json
+++ b/packages/react-docs/tsconfig.json
@@ -9,5 +9,5 @@
"*": ["node_modules/@types/*", "*"]
}
},
- "include": ["./src/**/*", "../../node_modules/web3-typescript-typings/index.d.ts"]
+ "include": ["./src/**/*"]
}
diff --git a/packages/react-shared/.npmignore b/packages/react-shared/.npmignore
index 87bc30436..d645458f6 100644
--- a/packages/react-shared/.npmignore
+++ b/packages/react-shared/.npmignore
@@ -3,3 +3,4 @@ yarn-error.log
/src/
/scripts/
tsconfig.json
+/lib/monorepo_scripts/
diff --git a/packages/react-shared/README.md b/packages/react-shared/README.md
index da7ff83af..9165cf78d 100644
--- a/packages/react-shared/README.md
+++ b/packages/react-shared/README.md
@@ -8,6 +8,14 @@ Contains React components & frontend types/utils shared between 0x projects.
yarn add @0xproject/react-shared
```
+If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`:
+
+```json
+"compilerOptions": {
+ "typeRoots": ["node_modules/@0xproject/typescript-typings/types", "node_modules/@types"],
+}
+```
+
## Contributing
We strongly encourage that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository.
diff --git a/packages/react-shared/package.json b/packages/react-shared/package.json
index e5201536e..8b7a0ebbb 100644
--- a/packages/react-shared/package.json
+++ b/packages/react-shared/package.json
@@ -33,8 +33,8 @@
"@types/lodash": "4.14.104",
"@types/material-ui": "0.18.0",
"@types/node": "^8.0.53",
- "@types/react": "^15.0.15",
- "@types/react-dom": "^0.14.23",
+ "@types/react": "^16.0.34",
+ "@types/react-dom": "^16.0.3",
"@types/react-scroll": "0.0.31",
"basscss": "^8.0.3",
"is-mobile": "^0.2.2",
diff --git a/packages/sol-cov/.npmignore b/packages/sol-cov/.npmignore
index 87bc30436..037786e46 100644
--- a/packages/sol-cov/.npmignore
+++ b/packages/sol-cov/.npmignore
@@ -3,3 +3,4 @@ yarn-error.log
/src/
/scripts/
tsconfig.json
+/lib/src/monorepo_scripts/
diff --git a/packages/sol-cov/package.json b/packages/sol-cov/package.json
index 106c47d13..1e3124822 100644
--- a/packages/sol-cov/package.json
+++ b/packages/sol-cov/package.json
@@ -39,7 +39,9 @@
"homepage": "https://github.com/0xProject/0x.js/packages/sol-cov/README.md",
"dependencies": {
"@0xproject/subproviders": "^0.8.2",
- "@0xproject/utils": "^0.3.4",
+ "@0xproject/utils": "^0.4.3",
+ "@0xproject/typescript-typings": "^0.0.1",
+ "@0xproject/types": "^0.4.1",
"ethereumjs-util": "^5.1.1",
"glob": "^7.1.2",
"istanbul": "^0.4.5",
@@ -47,8 +49,7 @@
"semaphore-async-await": "^1.5.1",
"solidity-coverage": "^0.4.10",
"solidity-parser-antlr": "^0.2.7",
- "solidity-parser-sc": "^0.4.4",
- "web3": "^0.20.0"
+ "solidity-parser-sc": "^0.4.4"
},
"devDependencies": {
"@0xproject/monorepo-scripts": "^0.1.14",
@@ -57,7 +58,6 @@
"@types/mocha": "^2.2.42",
"@types/node": "^8.0.53",
"chai": "^4.0.1",
- "chai-typescript-typings": "^0.0.6",
"copyfiles": "^1.2.0",
"dirty-chai": "^2.0.1",
"mocha": "^4.0.1",
@@ -67,8 +67,7 @@
"sinon": "^4.0.0",
"tslint": "5.8.0",
"typedoc": "0xProject/typedoc",
- "typescript": "2.7.1",
- "web3-typescript-typings": "^0.9.11"
+ "typescript": "2.7.1"
},
"publishConfig": {
"access": "public"
diff --git a/packages/sol-cov/src/coverage_subprovider.ts b/packages/sol-cov/src/coverage_subprovider.ts
index 37682c45f..1c80dca7b 100644
--- a/packages/sol-cov/src/coverage_subprovider.ts
+++ b/packages/sol-cov/src/coverage_subprovider.ts
@@ -1,14 +1,14 @@
import { Callback, ErrorCallback, NextCallback, Subprovider } from '@0xproject/subproviders';
+import { BlockParam, CallData, JSONRPCRequestPayload, TransactionTrace, TxData } from '@0xproject/types';
import { promisify } from '@0xproject/utils';
import * as _ from 'lodash';
import { Lock } from 'semaphore-async-await';
-import * as Web3 from 'web3';
import { constants } from './constants';
import { CoverageManager } from './coverage_manager';
import { TraceInfoExistingContract, TraceInfoNewContract } from './types';
-interface MaybeFakeTxData extends Web3.TxData {
+interface MaybeFakeTxData extends TxData {
isFakeTransaction?: boolean;
}
@@ -58,7 +58,7 @@ export class CoverageSubprovider extends Subprovider {
* @param end Callback to call if subprovider handled the request and wants to pass back the request.
*/
// tslint:disable-next-line:prefer-function-over-method
- public handleRequest(payload: Web3.JSONRPCRequestPayload, next: NextCallback, end: ErrorCallback) {
+ public handleRequest(payload: JSONRPCRequestPayload, next: NextCallback, end: ErrorCallback) {
switch (payload.method) {
case 'eth_sendTransaction':
const txData = payload.params[0];
@@ -110,8 +110,8 @@ export class CoverageSubprovider extends Subprovider {
cb();
}
private async _onCallExecutedAsync(
- callData: Partial<Web3.CallData>,
- blockNumber: Web3.BlockParam,
+ callData: Partial<CallData>,
+ blockNumber: BlockParam,
err: Error | null,
callResult: string,
cb: Callback,
@@ -125,7 +125,7 @@ export class CoverageSubprovider extends Subprovider {
params: [txHash, { disableMemory: true, disableStack: true, disableStorage: true }], // TODO For now testrpc just ignores those parameters https://github.com/trufflesuite/ganache-cli/issues/489
};
const jsonRPCResponsePayload = await this.emitPayloadAsync(payload);
- const trace: Web3.TransactionTrace = jsonRPCResponsePayload.result;
+ const trace: TransactionTrace = jsonRPCResponsePayload.result;
const coveredPcs = _.map(trace.structLogs, log => log.pc);
if (address === constants.NEW_CONTRACT) {
const traceInfo: TraceInfoNewContract = {
@@ -147,7 +147,7 @@ export class CoverageSubprovider extends Subprovider {
this._coverageManager.appendTraceInfo(traceInfo);
}
}
- private async _recordCallTraceAsync(callData: Partial<Web3.CallData>, blockNumber: Web3.BlockParam): Promise<void> {
+ private async _recordCallTraceAsync(callData: Partial<CallData>, blockNumber: BlockParam): Promise<void> {
// We don't want other transactions to be exeucted during snashotting period, that's why we lock the
// transaction execution for all transactions except our fake ones.
await this._lock.acquire();
diff --git a/packages/sol-cov/tsconfig.json b/packages/sol-cov/tsconfig.json
index 44e43719b..7b93af0da 100644
--- a/packages/sol-cov/tsconfig.json
+++ b/packages/sol-cov/tsconfig.json
@@ -7,8 +7,6 @@
"./src/**/*",
"./test/**/*",
"../../node_modules/types-bn/index.d.ts",
- "../../node_modules/web3-typescript-typings/index.d.ts",
- "../../node_modules/chai-typescript-typings/index.d.ts",
"../../node_modules/types-ethereumjs-util/index.d.ts"
]
}
diff --git a/packages/sra-report/.npmignore b/packages/sra-report/.npmignore
index 87bc30436..d645458f6 100644
--- a/packages/sra-report/.npmignore
+++ b/packages/sra-report/.npmignore
@@ -3,3 +3,4 @@ yarn-error.log
/src/
/scripts/
tsconfig.json
+/lib/monorepo_scripts/
diff --git a/packages/sra-report/package.json b/packages/sra-report/package.json
index 78c37e002..d8cbea70e 100644
--- a/packages/sra-report/package.json
+++ b/packages/sra-report/package.json
@@ -33,6 +33,7 @@
"@0xproject/connect": "^0.6.6",
"@0xproject/json-schemas": "^0.7.17",
"@0xproject/utils": "^0.4.3",
+ "@0xproject/typescript-typings": "^0.0.1",
"chalk": "^2.3.0",
"lodash": "^4.17.4",
"newman": "^3.9.3",
@@ -48,8 +49,6 @@
"@types/yargs": "^10.0.0",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
- "chai-as-promised-typescript-typings": "^0.0.10",
- "chai-typescript-typings": "^0.0.4",
"copyfiles": "^1.2.0",
"dirty-chai": "^2.0.1",
"mocha": "^4.0.1",
diff --git a/packages/sra-report/tsconfig.json b/packages/sra-report/tsconfig.json
index a0a54410a..e35816553 100644
--- a/packages/sra-report/tsconfig.json
+++ b/packages/sra-report/tsconfig.json
@@ -3,12 +3,5 @@
"compilerOptions": {
"outDir": "lib"
},
- "include": [
- "./src/**/*",
- "./test/**/*",
- "../../node_modules/chai-as-promised-typescript-typings/index.d.ts",
- "../../node_modules/chai-typescript-typings/index.d.ts",
- "../../node_modules/web3-typescript-typings/index.d.ts",
- "../../node_modules/ethers-typescript-typings/index.d.ts"
- ]
+ "include": ["./src/**/*", "./test/**/*"]
}
diff --git a/packages/subproviders/.npmignore b/packages/subproviders/.npmignore
index 05fa23a59..44df80fad 100644
--- a/packages/subproviders/.npmignore
+++ b/packages/subproviders/.npmignore
@@ -4,3 +4,4 @@ yarn-error.log
/scripts/
test/
tsconfig.json
+/lib/src/monorepo_scripts/
diff --git a/packages/subproviders/README.md b/packages/subproviders/README.md
index a2bf75768..ac92b89d2 100644
--- a/packages/subproviders/README.md
+++ b/packages/subproviders/README.md
@@ -14,10 +14,10 @@ yarn add @0xproject/subproviders
If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`:
-```
-"include": [
- "./node_modules/web3-typescript-typings/index.d.ts",
-]
+```json
+"compilerOptions": {
+ "typeRoots": ["node_modules/@0xproject/typescript-typings/types", "node_modules/@types"],
+}
```
## Contributing
diff --git a/packages/subproviders/package.json b/packages/subproviders/package.json
index 96d3e7f00..411fe22dc 100644
--- a/packages/subproviders/package.json
+++ b/packages/subproviders/package.json
@@ -36,6 +36,7 @@
"@0xproject/assert": "^0.2.3",
"@0xproject/types": "^0.4.1",
"@0xproject/utils": "^0.4.3",
+ "@0xproject/typescript-typings": "^0.0.1",
"@ledgerhq/hw-app-eth": "^4.3.0",
"@ledgerhq/hw-transport-u2f": "^4.3.0",
"bn.js": "^4.11.8",
@@ -47,8 +48,7 @@
"lodash": "^4.17.4",
"semaphore-async-await": "^1.5.1",
"web3": "^0.20.0",
- "web3-provider-engine": "^13.0.1",
- "web3-typescript-typings": "^0.10.2"
+ "web3-provider-engine": "^13.0.1"
},
"devDependencies": {
"@0xproject/monorepo-scripts": "^0.1.14",
@@ -59,8 +59,6 @@
"@types/node": "^8.0.53",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
- "chai-as-promised-typescript-typings": "^0.0.12",
- "chai-typescript-typings": "^0.0.6",
"copyfiles": "^1.2.0",
"dirty-chai": "^2.0.1",
"mocha": "^4.0.1",
diff --git a/packages/subproviders/src/globals.d.ts b/packages/subproviders/src/globals.d.ts
index 2c86346f5..ebc4efe86 100644
--- a/packages/subproviders/src/globals.d.ts
+++ b/packages/subproviders/src/globals.d.ts
@@ -73,11 +73,11 @@ declare module 'web3-provider-engine/subproviders/subprovider' {
export = Subprovider;
}
declare module 'web3-provider-engine/subproviders/rpc' {
- import * as Web3 from 'web3';
+ import { JSONRPCRequestPayload } from '@0xproject/types';
class RpcSubprovider {
constructor(options: { rpcUrl: string });
public handleRequest(
- payload: Web3.JSONRPCRequestPayload,
+ payload: JSONRPCRequestPayload,
next: () => void,
end: (err: Error | null, data?: any) => void,
): void;
@@ -102,11 +102,11 @@ declare module 'web3-provider-engine/util/rpc-cache-utils' {
export = ProviderEngineRpcUtils;
}
declare module 'web3-provider-engine/subproviders/fixture' {
- import * as Web3 from 'web3';
+ import { JSONRPCRequestPayload } from '@0xproject/types';
class FixtureSubprovider {
constructor(staticResponses: any);
public handleRequest(
- payload: Web3.JSONRPCRequestPayload,
+ payload: JSONRPCRequestPayload,
next: () => void,
end: (err: Error | null, data?: any) => void,
): void;
diff --git a/packages/subproviders/src/index.ts b/packages/subproviders/src/index.ts
index d88792fd0..9786347e6 100644
--- a/packages/subproviders/src/index.ts
+++ b/packages/subproviders/src/index.ts
@@ -1,5 +1,6 @@
import Eth from '@ledgerhq/hw-app-eth';
import TransportU2F from '@ledgerhq/hw-transport-u2f';
+export { ECSignature } from '@0xproject/types';
import { LedgerEthereumClient } from './types';
@@ -15,7 +16,6 @@ export {
Callback,
ErrorCallback,
NextCallback,
- ECSignature,
LedgerWalletSubprovider,
LedgerCommunicationClient,
NonceSubproviderErrors,
diff --git a/packages/subproviders/src/subproviders/empty_wallet_subprovider.ts b/packages/subproviders/src/subproviders/empty_wallet_subprovider.ts
index dc570b152..595ec654d 100644
--- a/packages/subproviders/src/subproviders/empty_wallet_subprovider.ts
+++ b/packages/subproviders/src/subproviders/empty_wallet_subprovider.ts
@@ -1,4 +1,4 @@
-import * as Web3 from 'web3';
+import { JSONRPCRequestPayload } from '@0xproject/types';
import { Callback, ErrorCallback } from '../types';
@@ -18,7 +18,7 @@ export class EmptyWalletSubprovider extends Subprovider {
* @param end Callback to call if subprovider handled the request and wants to pass back the request.
*/
// tslint:disable-next-line:prefer-function-over-method
- public handleRequest(payload: Web3.JSONRPCRequestPayload, next: Callback, end: ErrorCallback) {
+ public handleRequest(payload: JSONRPCRequestPayload, next: Callback, end: ErrorCallback) {
switch (payload.method) {
case 'eth_accounts':
end(null, []);
diff --git a/packages/subproviders/src/subproviders/fake_gas_estimate_subprovider.ts b/packages/subproviders/src/subproviders/fake_gas_estimate_subprovider.ts
index a6f978db1..966c37d8a 100644
--- a/packages/subproviders/src/subproviders/fake_gas_estimate_subprovider.ts
+++ b/packages/subproviders/src/subproviders/fake_gas_estimate_subprovider.ts
@@ -1,4 +1,4 @@
-import * as Web3 from 'web3';
+import { JSONRPCRequestPayload } from '@0xproject/types';
import { Callback, ErrorCallback } from '../types';
@@ -32,7 +32,7 @@ export class FakeGasEstimateSubprovider extends Subprovider {
* @param end Callback to call if subprovider handled the request and wants to pass back the request.
*/
// tslint:disable-next-line:prefer-function-over-method
- public handleRequest(payload: Web3.JSONRPCRequestPayload, next: Callback, end: ErrorCallback) {
+ public handleRequest(payload: JSONRPCRequestPayload, next: Callback, end: ErrorCallback) {
switch (payload.method) {
case 'eth_estimateGas':
end(null, this._constantGasAmount);
diff --git a/packages/subproviders/src/subproviders/ganache.ts b/packages/subproviders/src/subproviders/ganache.ts
index fc0b9c3d2..785de792d 100644
--- a/packages/subproviders/src/subproviders/ganache.ts
+++ b/packages/subproviders/src/subproviders/ganache.ts
@@ -1,3 +1,4 @@
+import { JSONRPCRequestPayload } from '@0xproject/types';
import * as Ganache from 'ganache-core';
import * as Web3 from 'web3';
@@ -28,7 +29,7 @@ export class GanacheSubprovider extends Subprovider {
* @param end Callback to call if subprovider handled the request and wants to pass back the request.
*/
// tslint:disable-next-line:prefer-function-over-method
- public handleRequest(payload: Web3.JSONRPCRequestPayload, next: Callback, end: ErrorCallback) {
+ public handleRequest(payload: JSONRPCRequestPayload, next: Callback, end: ErrorCallback) {
this._ganacheProvider.sendAsync(payload, (err: Error | null, result: any) => {
end(err, result && result.result);
});
diff --git a/packages/subproviders/src/subproviders/injected_web3.ts b/packages/subproviders/src/subproviders/injected_web3.ts
index cd9b0b603..edecd8bf6 100644
--- a/packages/subproviders/src/subproviders/injected_web3.ts
+++ b/packages/subproviders/src/subproviders/injected_web3.ts
@@ -1,3 +1,4 @@
+import { JSONRPCRequestPayload } from '@0xproject/types';
import * as _ from 'lodash';
import * as Web3 from 'web3';
@@ -30,7 +31,7 @@ export class InjectedWeb3Subprovider extends Subprovider {
* @param end Callback to call if subprovider handled the request and wants to pass back the request.
*/
// tslint:disable-next-line:prefer-function-over-method
- public handleRequest(payload: Web3.JSONRPCRequestPayload, next: Callback, end: ErrorCallback) {
+ public handleRequest(payload: JSONRPCRequestPayload, next: Callback, end: ErrorCallback) {
switch (payload.method) {
case 'web3_clientVersion':
this._injectedWeb3.version.getNode(end);
diff --git a/packages/subproviders/src/subproviders/ledger.ts b/packages/subproviders/src/subproviders/ledger.ts
index 8bc70d8b6..95784a391 100644
--- a/packages/subproviders/src/subproviders/ledger.ts
+++ b/packages/subproviders/src/subproviders/ledger.ts
@@ -1,11 +1,11 @@
import { assert } from '@0xproject/assert';
+import { JSONRPCRequestPayload } from '@0xproject/types';
import { addressUtils } from '@0xproject/utils';
import EthereumTx = require('ethereumjs-tx');
import ethUtil = require('ethereumjs-util');
import HDNode = require('hdkey');
import * as _ from 'lodash';
import { Lock } from 'semaphore-async-await';
-import * as Web3 from 'web3';
import {
Callback,
@@ -208,7 +208,7 @@ export class LedgerSubprovider extends Subprovider {
*/
// tslint:disable-next-line:async-suffix
public async handleRequest(
- payload: Web3.JSONRPCRequestPayload,
+ payload: JSONRPCRequestPayload,
next: Callback,
end: (err: Error | null, result?: any) => void,
) {
diff --git a/packages/subproviders/src/subproviders/nonce_tracker.ts b/packages/subproviders/src/subproviders/nonce_tracker.ts
index 249f16199..907330111 100644
--- a/packages/subproviders/src/subproviders/nonce_tracker.ts
+++ b/packages/subproviders/src/subproviders/nonce_tracker.ts
@@ -1,9 +1,8 @@
import * as _ from 'lodash';
-import { BlockParamLiteral } from '@0xproject/types';
+import { BlockParamLiteral, JSONRPCRequestPayload } from '@0xproject/types';
import EthereumTx = require('ethereumjs-tx');
import ethUtil = require('ethereumjs-util');
-import * as Web3 from 'web3';
import providerEngineUtils = require('web3-provider-engine/util/rpc-cache-utils');
import { Callback, ErrorCallback, NextCallback, NonceSubproviderErrors } from '../types';
@@ -19,7 +18,7 @@ const NONCE_TOO_LOW_ERROR_MESSAGE = 'Transaction nonce is too low';
*/
export class NonceTrackerSubprovider extends Subprovider {
private _nonceCache: { [address: string]: string } = {};
- private static _reconstructTransaction(payload: Web3.JSONRPCRequestPayload): EthereumTx {
+ private static _reconstructTransaction(payload: JSONRPCRequestPayload): EthereumTx {
const raw = payload.params[0];
if (_.isUndefined(raw)) {
throw new Error(NonceSubproviderErrors.EmptyParametersFound);
@@ -28,7 +27,7 @@ export class NonceTrackerSubprovider extends Subprovider {
const transaction = new EthereumTx(rawData);
return transaction;
}
- private static _determineAddress(payload: Web3.JSONRPCRequestPayload): string {
+ private static _determineAddress(payload: JSONRPCRequestPayload): string {
let address: string;
switch (payload.method) {
case 'eth_getTransactionCount':
@@ -55,11 +54,7 @@ export class NonceTrackerSubprovider extends Subprovider {
* @param end Callback to call if subprovider handled the request and wants to pass back the request.
*/
// tslint:disable-next-line:async-suffix
- public async handleRequest(
- payload: Web3.JSONRPCRequestPayload,
- next: NextCallback,
- end: ErrorCallback,
- ): Promise<void> {
+ public async handleRequest(payload: JSONRPCRequestPayload, next: NextCallback, end: ErrorCallback): Promise<void> {
switch (payload.method) {
case 'eth_getTransactionCount':
const requestDefaultBlock = providerEngineUtils.blockTagForPayload(payload);
@@ -92,7 +87,7 @@ export class NonceTrackerSubprovider extends Subprovider {
return next();
}
}
- private _handleSuccessfulTransaction(payload: Web3.JSONRPCRequestPayload): void {
+ private _handleSuccessfulTransaction(payload: JSONRPCRequestPayload): void {
const address = NonceTrackerSubprovider._determineAddress(payload);
const transaction = NonceTrackerSubprovider._reconstructTransaction(payload);
// Increment the nonce from the previous successfully submitted transaction
@@ -105,7 +100,7 @@ export class NonceTrackerSubprovider extends Subprovider {
const nextPrefixedHexNonce = `0x${nextHexNonce}`;
this._nonceCache[address] = nextPrefixedHexNonce;
}
- private _handleSendTransactionError(payload: Web3.JSONRPCRequestPayload, err: Error): void {
+ private _handleSendTransactionError(payload: JSONRPCRequestPayload, err: Error): void {
const address = NonceTrackerSubprovider._determineAddress(payload);
if (this._nonceCache[address] && _.includes(err.message, NONCE_TOO_LOW_ERROR_MESSAGE)) {
delete this._nonceCache[address];
diff --git a/packages/subproviders/src/subproviders/redundant_rpc.ts b/packages/subproviders/src/subproviders/redundant_rpc.ts
index ace2ed3c8..f8ff0915d 100644
--- a/packages/subproviders/src/subproviders/redundant_rpc.ts
+++ b/packages/subproviders/src/subproviders/redundant_rpc.ts
@@ -1,6 +1,6 @@
+import { JSONRPCRequestPayload } from '@0xproject/types';
import { promisify } from '@0xproject/utils';
import * as _ from 'lodash';
-import * as Web3 from 'web3';
import RpcSubprovider = require('web3-provider-engine/subproviders/rpc');
import { Callback } from '../types';
@@ -16,7 +16,7 @@ export class RedundantRPCSubprovider extends Subprovider {
private _rpcs: RpcSubprovider[];
private static async _firstSuccessAsync(
rpcs: RpcSubprovider[],
- payload: Web3.JSONRPCRequestPayload,
+ payload: JSONRPCRequestPayload,
next: Callback,
): Promise<any> {
let lastErr: Error | undefined;
@@ -55,7 +55,7 @@ export class RedundantRPCSubprovider extends Subprovider {
*/
// tslint:disable-next-line:async-suffix
public async handleRequest(
- payload: Web3.JSONRPCRequestPayload,
+ payload: JSONRPCRequestPayload,
next: Callback,
end: (err: Error | null, data?: any) => void,
): Promise<void> {
diff --git a/packages/subproviders/src/subproviders/subprovider.ts b/packages/subproviders/src/subproviders/subprovider.ts
index 4fa351e11..26ce19305 100644
--- a/packages/subproviders/src/subproviders/subprovider.ts
+++ b/packages/subproviders/src/subproviders/subprovider.ts
@@ -1,3 +1,4 @@
+import { JSONRPCRequestPayload, JSONRPCResponsePayload } from '@0xproject/types';
import promisify = require('es6-promisify');
import * as Web3 from 'web3';
@@ -37,9 +38,7 @@ export class Subprovider {
* @param payload JSON RPC payload
* @returns JSON RPC response payload
*/
- public async emitPayloadAsync(
- payload: Partial<JSONRPCRequestPayloadWithMethod>,
- ): Promise<Web3.JSONRPCResponsePayload> {
+ public async emitPayloadAsync(payload: Partial<JSONRPCRequestPayloadWithMethod>): Promise<JSONRPCResponsePayload> {
const finalPayload = Subprovider._createFinalPayload(payload);
const response = await promisify(this._engine.sendAsync, this._engine)(finalPayload);
return response;
diff --git a/packages/subproviders/src/types.ts b/packages/subproviders/src/types.ts
index 9bb9ff696..a1fec1882 100644
--- a/packages/subproviders/src/types.ts
+++ b/packages/subproviders/src/types.ts
@@ -1,8 +1,5 @@
-import { ECSignature } from '@0xproject/types';
+import { ECSignature, JSONRPCRequestPayload } from '@0xproject/types';
import * as _ from 'lodash';
-import * as Web3 from 'web3';
-
-export { ECSignature } from '@0xproject/types';
export interface LedgerCommunicationClient {
close: () => Promise<void>;
@@ -116,6 +113,6 @@ export type Callback = () => void;
export type OnNextCompleted = (err: Error | null, result: any, cb: Callback) => void;
export type NextCallback = (callback?: OnNextCompleted) => void;
-export interface JSONRPCRequestPayloadWithMethod extends Web3.JSONRPCRequestPayload {
+export interface JSONRPCRequestPayloadWithMethod extends JSONRPCRequestPayload {
method: string;
}
diff --git a/packages/subproviders/test/integration/ledger_subprovider_test.ts b/packages/subproviders/test/integration/ledger_subprovider_test.ts
index a94cfbe3a..969081ad5 100644
--- a/packages/subproviders/test/integration/ledger_subprovider_test.ts
+++ b/packages/subproviders/test/integration/ledger_subprovider_test.ts
@@ -1,3 +1,4 @@
+import { JSONRPCResponsePayload } from '@0xproject/types';
import Eth from '@ledgerhq/hw-app-eth';
// HACK: This depdency is optional and tslint skips optional depdencies
// tslint:disable-next-line:no-implicit-dependencies
@@ -97,7 +98,7 @@ describe('LedgerSubprovider', () => {
params: [],
id: 1,
};
- const callback = reportCallbackErrors(done)((err: Error, response: Web3.JSONRPCResponsePayload) => {
+ const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
expect(err).to.be.a('null');
expect(response.result.length).to.be.equal(10);
done();
@@ -115,7 +116,7 @@ describe('LedgerSubprovider', () => {
params: [signer, messageHex],
id: 1,
};
- const callback = reportCallbackErrors(done)((err: Error, response: Web3.JSONRPCResponsePayload) => {
+ const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
expect(err).to.be.a('null');
expect(response.result.length).to.be.equal(132);
expect(response.result.substr(0, 2)).to.be.equal('0x');
@@ -135,7 +136,7 @@ describe('LedgerSubprovider', () => {
params: [messageHex, signer],
id: 1,
};
- const callback = reportCallbackErrors(done)((err: Error, response: Web3.JSONRPCResponsePayload) => {
+ const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
expect(err).to.be.a('null');
expect(response.result.length).to.be.equal(132);
expect(response.result.substr(0, 2)).to.be.equal('0x');
@@ -155,7 +156,7 @@ describe('LedgerSubprovider', () => {
params: [tx],
id: 1,
};
- const callback = reportCallbackErrors(done)((err: Error, response: Web3.JSONRPCResponsePayload) => {
+ const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
expect(err).to.be.a('null');
expect(response.result.raw.length).to.be.equal(206);
expect(response.result.raw.substr(0, 2)).to.be.equal('0x');
@@ -193,7 +194,7 @@ describe('LedgerSubprovider', () => {
params: [tx],
id: 1,
};
- const callback = reportCallbackErrors(done)((err: Error, response: Web3.JSONRPCResponsePayload) => {
+ const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
expect(err).to.be.a('null');
const result = response.result;
expect(result.length).to.be.equal(66);
diff --git a/packages/subproviders/test/unit/ledger_subprovider_test.ts b/packages/subproviders/test/unit/ledger_subprovider_test.ts
index 4c0803a29..3cb487f02 100644
--- a/packages/subproviders/test/unit/ledger_subprovider_test.ts
+++ b/packages/subproviders/test/unit/ledger_subprovider_test.ts
@@ -1,3 +1,4 @@
+import { JSONRPCResponsePayload } from '@0xproject/types';
import * as chai from 'chai';
import * as ethUtils from 'ethereumjs-util';
import * as _ from 'lodash';
@@ -112,7 +113,7 @@ describe('LedgerSubprovider', () => {
params: [],
id: 1,
};
- const callback = reportCallbackErrors(done)((err: Error, response: Web3.JSONRPCResponsePayload) => {
+ const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
expect(err).to.be.a('null');
expect(response.result.length).to.be.equal(10);
expect(response.result[0]).to.be.equal(FAKE_ADDRESS);
@@ -128,7 +129,7 @@ describe('LedgerSubprovider', () => {
params: ['0x0000000000000000000000000000000000000000', messageHex],
id: 1,
};
- const callback = reportCallbackErrors(done)((err: Error, response: Web3.JSONRPCResponsePayload) => {
+ const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
expect(err).to.be.a('null');
expect(response.result).to.be.equal(
'0xa6cc284bff14b42bdf5e9286730c152be91719d478605ec46b3bebcd0ae491480652a1a7b742ceb0213d1e744316e285f41f878d8af0b8e632cbca4c279132d001',
@@ -145,7 +146,7 @@ describe('LedgerSubprovider', () => {
params: [messageHex, '0x0000000000000000000000000000000000000000'],
id: 1,
};
- const callback = reportCallbackErrors(done)((err: Error, response: Web3.JSONRPCResponsePayload) => {
+ const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
expect(err).to.be.a('null');
expect(response.result).to.be.equal(
'0xa6cc284bff14b42bdf5e9286730c152be91719d478605ec46b3bebcd0ae491480652a1a7b742ceb0213d1e744316e285f41f878d8af0b8e632cbca4c279132d001',
@@ -168,7 +169,7 @@ describe('LedgerSubprovider', () => {
params: [tx],
id: 1,
};
- const callback = reportCallbackErrors(done)((err: Error, response: Web3.JSONRPCResponsePayload) => {
+ const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
expect(err).to.be.a('null');
expect(response.result.raw.length).to.be.equal(192);
expect(response.result.raw.substr(0, 2)).to.be.equal('0x');
@@ -186,7 +187,7 @@ describe('LedgerSubprovider', () => {
params: ['0x0000000000000000000000000000000000000000', nonHexMessage],
id: 1,
};
- const callback = reportCallbackErrors(done)((err: Error, response: Web3.JSONRPCResponsePayload) => {
+ const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
expect(err).to.not.be.a('null');
expect(err.message).to.be.equal('Expected data to be of type HexString, encountered: hello world');
done();
@@ -201,7 +202,7 @@ describe('LedgerSubprovider', () => {
params: [nonHexMessage, '0x0000000000000000000000000000000000000000'],
id: 1,
};
- const callback = reportCallbackErrors(done)((err: Error, response: Web3.JSONRPCResponsePayload) => {
+ const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
expect(err).to.not.be.a('null');
expect(err.message).to.be.equal('Expected data to be of type HexString, encountered: hello world');
done();
@@ -219,7 +220,7 @@ describe('LedgerSubprovider', () => {
params: [tx],
id: 1,
};
- const callback = reportCallbackErrors(done)((err: Error, response: Web3.JSONRPCResponsePayload) => {
+ const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
expect(err).to.not.be.a('null');
expect(err.message).to.be.equal(LedgerSubproviderErrors.SenderInvalidOrNotSupplied);
done();
@@ -238,7 +239,7 @@ describe('LedgerSubprovider', () => {
params: [tx],
id: 1,
};
- const callback = reportCallbackErrors(done)((err: Error, response: Web3.JSONRPCResponsePayload) => {
+ const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
expect(err).to.not.be.a('null');
expect(err.message).to.be.equal(LedgerSubproviderErrors.SenderInvalidOrNotSupplied);
done();
diff --git a/packages/subproviders/test/unit/redundant_rpc_subprovider_test.ts b/packages/subproviders/test/unit/redundant_rpc_subprovider_test.ts
index c3170745c..a347ab765 100644
--- a/packages/subproviders/test/unit/redundant_rpc_subprovider_test.ts
+++ b/packages/subproviders/test/unit/redundant_rpc_subprovider_test.ts
@@ -1,3 +1,4 @@
+import { JSONRPCResponsePayload } from '@0xproject/types';
import * as chai from 'chai';
import * as _ from 'lodash';
import Web3 = require('web3');
@@ -26,7 +27,7 @@ describe('RedundantRpcSubprovider', () => {
params: [],
id: 1,
};
- const callback = reportCallbackErrors(done)((err: Error, response: Web3.JSONRPCResponsePayload) => {
+ const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
expect(err).to.be.a('null');
expect(response.result.length).to.be.equal(10);
done();
@@ -46,7 +47,7 @@ describe('RedundantRpcSubprovider', () => {
params: [],
id: 1,
};
- const callback = reportCallbackErrors(done)((err: Error, response: Web3.JSONRPCResponsePayload) => {
+ const callback = reportCallbackErrors(done)((err: Error, response: JSONRPCResponsePayload) => {
expect(err).to.be.a('null');
expect(response.result.length).to.be.equal(10);
done();
diff --git a/packages/subproviders/tsconfig.json b/packages/subproviders/tsconfig.json
index 9a65a0a97..7b93af0da 100644
--- a/packages/subproviders/tsconfig.json
+++ b/packages/subproviders/tsconfig.json
@@ -6,10 +6,7 @@
"include": [
"./src/**/*",
"./test/**/*",
- "../../node_modules/chai-typescript-typings/index.d.ts",
- "../../node_modules/web3-typescript-typings/index.d.ts",
"../../node_modules/types-bn/index.d.ts",
- "../../node_modules/types-ethereumjs-util/index.d.ts",
- "../../node_modules/chai-as-promised-typescript-typings/index.d.ts"
+ "../../node_modules/types-ethereumjs-util/index.d.ts"
]
}
diff --git a/packages/testnet-faucets/package.json b/packages/testnet-faucets/package.json
index 7159af988..7b43db4e7 100644
--- a/packages/testnet-faucets/package.json
+++ b/packages/testnet-faucets/package.json
@@ -18,6 +18,7 @@
"0x.js": "^0.33.6",
"@0xproject/subproviders": "^0.8.2",
"@0xproject/utils": "^0.4.3",
+ "@0xproject/typescript-typings": "^0.0.1",
"body-parser": "^1.17.1",
"ethereumjs-tx": "^1.3.3",
"ethereumjs-util": "^5.1.1",
@@ -41,7 +42,6 @@
"types-bn": "^0.0.1",
"types-ethereumjs-util": "0xProject/types-ethereumjs-util",
"typescript": "2.7.1",
- "web3-typescript-typings": "^0.10.2",
"webpack": "^3.1.0",
"webpack-node-externals": "^1.6.0"
}
diff --git a/packages/testnet-faucets/tsconfig.json b/packages/testnet-faucets/tsconfig.json
index 237f62169..b0e7ba00c 100644
--- a/packages/testnet-faucets/tsconfig.json
+++ b/packages/testnet-faucets/tsconfig.json
@@ -6,9 +6,7 @@
},
"include": [
"./src/ts/**/*",
- "../../node_modules/ethers-typescript-typings/index.d.ts",
"../../node_modules/types-bn/index.d.ts",
- "../../node_modules/types-ethereumjs-util/index.d.ts",
- "../../node_modules/web3-typescript-typings/index.d.ts"
+ "../../node_modules/types-ethereumjs-util/index.d.ts"
]
}
diff --git a/packages/tslint-config/.npmignore b/packages/tslint-config/.npmignore
index 1767d198e..c46793a87 100644
--- a/packages/tslint-config/.npmignore
+++ b/packages/tslint-config/.npmignore
@@ -4,3 +4,4 @@ node_modules/
/scripts/
/rules/
tsconfig.json
+/lib/monorepo_scripts/
diff --git a/packages/tslint-config/CHANGELOG.md b/packages/tslint-config/CHANGELOG.md
index 18e4980e7..f6454d67c 100644
--- a/packages/tslint-config/CHANGELOG.md
+++ b/packages/tslint-config/CHANGELOG.md
@@ -21,7 +21,7 @@
* Added rules for unused imports, variables and Async suffixes (#265)
-## v0.1.0 - _Nov. 14, 2017_
+## v0.1.0 - _November 14, 2017_
* Re-published TsLintConfig previously published under NPM package `tslint-config-0xproject`
* Updated to TSLint v5.8.0, requiring several rule additions to keep our conventions aligned.
diff --git a/packages/tslint-config/tsconfig.json b/packages/tslint-config/tsconfig.json
index 6e5f060a4..fd9b23316 100644
--- a/packages/tslint-config/tsconfig.json
+++ b/packages/tslint-config/tsconfig.json
@@ -1,7 +1,8 @@
{
"extends": "../../tsconfig",
"compilerOptions": {
+ "typeRoots": ["node_modules/@types"],
"outDir": "lib"
},
- "include": ["./rules/**/*", "./monorepo_scripts/**/*", "../../node_modules/web3-typescript-typings/index.d.ts"]
+ "include": ["./rules/**/*", "./monorepo_scripts/**/*"]
}
diff --git a/packages/types/.npmignore b/packages/types/.npmignore
index ad5ffcd56..24e65ad5b 100644
--- a/packages/types/.npmignore
+++ b/packages/types/.npmignore
@@ -3,3 +3,4 @@ yarn-error.log
/scripts/
/src/
tsconfig.json
+/lib/monorepo_scripts/
diff --git a/packages/types/README.md b/packages/types/README.md
index 5101ee544..b971eaee7 100644
--- a/packages/types/README.md
+++ b/packages/types/README.md
@@ -10,10 +10,10 @@ yarn add -D @0xproject/types
If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`:
-```
-"include": [
- "./node_modules/web3-typescript-typings/index.d.ts",
-]
+```json
+"compilerOptions": {
+ "typeRoots": ["node_modules/@0xproject/typescript-typings/types", "node_modules/@types"],
+}
```
## Usage
diff --git a/packages/types/package.json b/packages/types/package.json
index e664b06ae..16737f5ea 100644
--- a/packages/types/package.json
+++ b/packages/types/package.json
@@ -22,15 +22,14 @@
"devDependencies": {
"@0xproject/monorepo-scripts": "^0.1.14",
"@0xproject/tslint-config": "^0.4.12",
+ "@types/node": "^8.0.53",
"copyfiles": "^1.2.0",
"shx": "^0.2.2",
"tslint": "5.8.0",
"typescript": "2.7.1"
},
"dependencies": {
- "bignumber.js": "~4.1.0",
- "web3": "^0.20.0",
- "web3-typescript-typings": "^0.10.2"
+ "bignumber.js": "~4.1.0"
},
"publishConfig": {
"access": "public"
diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts
index 2147a3edb..57b14e230 100644
--- a/packages/types/src/index.ts
+++ b/packages/types/src/index.ts
@@ -1,14 +1,195 @@
import { BigNumber } from 'bignumber.js';
-import * as Web3 from 'web3';
-export interface TxData {
+export type ContractAbi = AbiDefinition[];
+
+export type AbiDefinition = FunctionAbi | EventAbi;
+
+export type FunctionAbi = MethodAbi | ConstructorAbi | FallbackAbi;
+
+export type ConstructorStateMutability = 'nonpayable' | 'payable';
+export type StateMutability = 'pure' | 'view' | ConstructorStateMutability;
+
+export interface MethodAbi {
+ type: AbiType.Function;
+ name: string;
+ inputs: DataItem[];
+ outputs: DataItem[];
+ constant: boolean;
+ stateMutability: StateMutability;
+ payable: boolean;
+}
+
+export interface ConstructorAbi {
+ type: AbiType.Constructor;
+ inputs: DataItem[];
+ payable: boolean;
+ stateMutability: ConstructorStateMutability;
+}
+
+export interface FallbackAbi {
+ type: AbiType.Fallback;
+ payable: boolean;
+}
+
+export interface EventParameter extends DataItem {
+ indexed: boolean;
+}
+
+export interface EventAbi {
+ type: AbiType.Event;
+ name: string;
+ inputs: EventParameter[];
+ anonymous: boolean;
+}
+
+export interface DataItem {
+ name: string;
+ type: string;
+ components: DataItem[];
+}
+
+export type OpCode = string;
+
+export interface StructLog {
+ depth: number;
+ error: string;
+ gas: number;
+ gasCost: number;
+ memory: string[];
+ op: OpCode;
+ pc: number;
+ stack: string[];
+ storage: { [location: string]: string };
+}
+
+export interface TransactionTrace {
+ gas: number;
+ returnValue: any;
+ structLogs: StructLog[];
+}
+
+export type Unit =
+ | 'kwei'
+ | 'ada'
+ | 'mwei'
+ | 'babbage'
+ | 'gwei'
+ | 'shannon'
+ | 'szabo'
+ | 'finney'
+ | 'ether'
+ | 'kether'
+ | 'grand'
+ | 'einstein'
+ | 'mether'
+ | 'gether'
+ | 'tether';
+
+export interface JSONRPCRequestPayload {
+ params: any[];
+ method: string;
+ id: number;
+ jsonrpc: string;
+}
+
+export interface JSONRPCResponsePayload {
+ result: any;
+ id: number;
+ jsonrpc: string;
+}
+
+export interface AbstractBlock {
+ number: number | null;
+ hash: string | null;
+ parentHash: string;
+ nonce: string | null;
+ sha3Uncles: string;
+ logsBloom: string | null;
+ transactionsRoot: string;
+ stateRoot: string;
+ miner: string;
+ difficulty: BigNumber;
+ totalDifficulty: BigNumber;
+ extraData: string;
+ size: number;
+ gasLimit: number;
+ gasUsed: number;
+ timestamp: number;
+ uncles: string[];
+}
+
+export interface BlockWithoutTransactionData extends AbstractBlock {
+ transactions: string[];
+}
+
+export interface BlockWithTransactionData extends AbstractBlock {
+ transactions: Transaction[];
+}
+
+export interface Transaction {
+ hash: string;
+ nonce: number;
+ blockHash: string | null;
+ blockNumber: number | null;
+ transactionIndex: number | null;
+ from: string;
+ to: string | null;
+ value: BigNumber;
+ gasPrice: BigNumber;
+ gas: number;
+ input: string;
+}
+
+export interface CallTxDataBase {
+ to?: string;
+ value?: number | string | BigNumber;
+ gas?: number | string | BigNumber;
+ gasPrice?: number | string | BigNumber;
data?: string;
- from?: string;
- gas?: number;
- gasPrice?: BigNumber;
nonce?: number;
}
+export interface TxData extends CallTxDataBase {
+ from: string;
+}
+
+export interface CallData extends CallTxDataBase {
+ from?: string;
+}
+
+export interface FilterObject {
+ fromBlock?: number | string;
+ toBlock?: number | string;
+ address?: string;
+ topics?: LogTopic[];
+}
+
+export type LogTopic = null | string | string[];
+
+export interface DecodedLogEntry<A> extends LogEntry {
+ event: string;
+ args: A;
+}
+
+export interface DecodedLogEntryEvent<A> extends DecodedLogEntry<A> {
+ removed: boolean;
+}
+
+export interface LogEntryEvent extends LogEntry {
+ removed: boolean;
+}
+
+export interface LogEntry {
+ logIndex: number | null;
+ transactionIndex: number | null;
+ transactionHash: string;
+ blockHash: string | null;
+ blockNumber: number | null;
+ address: string;
+ data: string;
+ topics: string[];
+}
+
export interface TxDataPayable extends TxData {
value?: BigNumber;
}
@@ -20,11 +201,11 @@ export interface TransactionReceipt {
transactionIndex: number;
from: string;
to: string;
- status: null | 0 | 1;
+ status: null | string | 0 | 1;
cumulativeGasUsed: number;
gasUsed: number;
contractAddress: string | null;
- logs: Web3.LogEntry[];
+ logs: LogEntry[];
}
export enum AbiType {
@@ -40,8 +221,8 @@ export interface DecodedLogArgs {
[argName: string]: ContractEventArg;
}
-export interface LogWithDecodedArgs<ArgsType> extends Web3.DecodedLogEntry<ArgsType> {}
-export type RawLog = Web3.LogEntry;
+export interface LogWithDecodedArgs<ArgsType> extends DecodedLogEntry<ArgsType> {}
+export type RawLog = LogEntry;
export enum SolidityTypes {
Address = 'address',
Uint256 = 'uint256',
@@ -50,7 +231,7 @@ export enum SolidityTypes {
}
export interface TransactionReceiptWithDecodedLogs extends TransactionReceipt {
- logs: Array<LogWithDecodedArgs<DecodedLogArgs> | Web3.LogEntry>;
+ logs: Array<LogWithDecodedArgs<DecodedLogArgs> | LogEntry>;
}
// Earliest is omitted by design. It is simply an alias for the `0` constant and
diff --git a/packages/types/tsconfig.json b/packages/types/tsconfig.json
index 3d967d05f..5ec2db5e0 100644
--- a/packages/types/tsconfig.json
+++ b/packages/types/tsconfig.json
@@ -1,7 +1,8 @@
{
"extends": "../../tsconfig",
"compilerOptions": {
+ "typeRoots": ["node_modules/@types"],
"outDir": "lib"
},
- "include": ["./src/**/*", "../../node_modules/web3-typescript-typings/index.d.ts"]
+ "include": ["./src/**/*"]
}
diff --git a/packages/chai-typescript-typings/.npmignore b/packages/typescript-typings/.npmignore
index 104d718ed..53eb3e269 100644
--- a/packages/chai-typescript-typings/.npmignore
+++ b/packages/typescript-typings/.npmignore
@@ -1,3 +1,4 @@
.*
yarn-error.log
/scripts/
+/lib/monorepo_scripts/
diff --git a/packages/chai-as-promised-typescript-typings/CHANGELOG.md b/packages/typescript-typings/CHANGELOG.md
index 8c52570da..8c52570da 100644
--- a/packages/chai-as-promised-typescript-typings/CHANGELOG.md
+++ b/packages/typescript-typings/CHANGELOG.md
diff --git a/packages/chai-typescript-typings/README.md b/packages/typescript-typings/README.md
index 9bd0574d1..9a74739f3 100644
--- a/packages/chai-typescript-typings/README.md
+++ b/packages/typescript-typings/README.md
@@ -1,21 +1,23 @@
-## chai-typescript-typings
+## @0xproject/typescript-typings
-Fork of type definitions for chai that includes changes made by dirty-chai
+Type repository for external packages used by 0x. This is like our small version of [DefinitelyTyped](https://github.com/DefinitelyTyped/DefinitelyTyped)
## Installation
```bash
-yarn add -D chai-typescript-typings
+yarn add -D @0xproject/typescript-typings
```
## Usage
-Add the following line within an `include` section of your `tsconfig.json`
+Add the following line within an `compilerOptions` section of your `tsconfig.json`
```json
-"./node_modules/chai-typescript-typings/index.d.ts"
+"typeRoots": ["node_modules/@0xproject/typescript-typings/types", "node_modules/@types"]
```
+This will allow the TS compiler to first look into that repo and then fallback to DT types.
+
## Contributing
We strongly encourage that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository.
diff --git a/packages/chai-as-promised-typescript-typings/monorepo_scripts/globals.d.ts b/packages/typescript-typings/monorepo_scripts/globals.d.ts
index 94e63a32d..94e63a32d 100644
--- a/packages/chai-as-promised-typescript-typings/monorepo_scripts/globals.d.ts
+++ b/packages/typescript-typings/monorepo_scripts/globals.d.ts
diff --git a/packages/chai-as-promised-typescript-typings/monorepo_scripts/postpublish.ts b/packages/typescript-typings/monorepo_scripts/postpublish.ts
index dcb99d0f7..dcb99d0f7 100644
--- a/packages/chai-as-promised-typescript-typings/monorepo_scripts/postpublish.ts
+++ b/packages/typescript-typings/monorepo_scripts/postpublish.ts
diff --git a/packages/chai-as-promised-typescript-typings/package.json b/packages/typescript-typings/package.json
index cbf2630ec..c38ebf1f7 100644
--- a/packages/chai-as-promised-typescript-typings/package.json
+++ b/packages/typescript-typings/package.json
@@ -1,9 +1,7 @@
{
- "name": "chai-as-promised-typescript-typings",
- "version": "0.0.12",
- "description": "Typescript type definitions for chai-as-promised",
- "main": "index.d.ts",
- "types": "index.d.ts",
+ "name": "@0xproject/typescript-typings",
+ "version": "0.0.1",
+ "description": "0x project typescript type definitions",
"scripts": {
"build": "tsc && copyfiles -u 1 './lib/**/*' ./scripts",
"clean": "shx rm -rf scripts"
@@ -20,9 +18,10 @@
"bugs": {
"url": "https://github.com/0xProject/0x-monorepo/issues"
},
- "homepage": "https://github.com/0xProject/0x-monorepo/packages/chai-as-promised-typescript-typings#readme",
+ "homepage": "https://github.com/0xProject/0x-monorepo/packages/typescript-typings#readme",
"dependencies": {
- "chai-typescript-typings": "^0.0.6"
+ "@0xproject/types": "^0.4.1",
+ "bignumber.js": "~4.1.0"
},
"devDependencies": {
"@0xproject/monorepo-scripts": "^0.1.14",
diff --git a/packages/chai-as-promised-typescript-typings/tsconfig.json b/packages/typescript-typings/tsconfig.json
index bc453af4b..bc453af4b 100644
--- a/packages/chai-as-promised-typescript-typings/tsconfig.json
+++ b/packages/typescript-typings/tsconfig.json
diff --git a/packages/chai-as-promised-typescript-typings/tslint.json b/packages/typescript-typings/tslint.json
index 9a93a1f74..9a93a1f74 100644
--- a/packages/chai-as-promised-typescript-typings/tslint.json
+++ b/packages/typescript-typings/tslint.json
diff --git a/packages/chai-as-promised-typescript-typings/index.d.ts b/packages/typescript-typings/types/chai-as-promised/index.d.ts
index ba6dabdcc..ba6dabdcc 100644
--- a/packages/chai-as-promised-typescript-typings/index.d.ts
+++ b/packages/typescript-typings/types/chai-as-promised/index.d.ts
diff --git a/packages/chai-typescript-typings/index.d.ts b/packages/typescript-typings/types/chai/index.d.ts
index 8b3e4c079..8b3e4c079 100644
--- a/packages/chai-typescript-typings/index.d.ts
+++ b/packages/typescript-typings/types/chai/index.d.ts
diff --git a/packages/ethers-typescript-typings/index.d.ts b/packages/typescript-typings/types/ethers-contracts/index.d.ts
index e5d38819e..e5d38819e 100644
--- a/packages/ethers-typescript-typings/index.d.ts
+++ b/packages/typescript-typings/types/ethers-contracts/index.d.ts
diff --git a/packages/typescript-typings/types/web3/index.d.ts b/packages/typescript-typings/types/web3/index.d.ts
new file mode 100644
index 000000000..f4ebd41b9
--- /dev/null
+++ b/packages/typescript-typings/types/web3/index.d.ts
@@ -0,0 +1,237 @@
+declare module 'web3' {
+ import * as BigNumber from 'bignumber.js';
+ import {
+ AbiDefinition,
+ BlockWithTransactionData,
+ BlockWithoutTransactionData,
+ BlockParam,
+ CallData,
+ Unit,
+ TxData,
+ Transaction,
+ ContractAbi,
+ TransactionReceipt,
+ FilterObject,
+ LogEntryEvent,
+ JSONRPCRequestPayload,
+ JSONRPCResponsePayload,
+ } from '@0xproject/types';
+
+ type MixedData = string | number | object | any[] | BigNumber.BigNumber;
+
+ class Web3 {
+ public static providers: typeof providers;
+ public currentProvider: Web3.Provider;
+
+ public eth: Web3.EthApi;
+ public personal: Web3.PersonalApi | undefined;
+ public version: Web3.VersionApi;
+ public net: Web3.NetApi;
+
+ public constructor(provider?: Web3.Provider);
+
+ public isConnected(): boolean;
+ public setProvider(provider: Web3.Provider): void;
+ public reset(keepIsSyncing: boolean): void;
+ public toHex(data: MixedData): string;
+ public toAscii(hex: string): string;
+ public fromAscii(ascii: string, padding?: number): string;
+ public toDecimal(hex: string): number;
+ public fromDecimal(value: number | string): string;
+ public fromWei(value: number | string, unit: Unit): string;
+ public fromWei(value: BigNumber.BigNumber, unit: Unit): BigNumber.BigNumber;
+ public toWei(amount: number | string, unit: Unit): string;
+ public toWei(amount: BigNumber.BigNumber, unit: Unit): BigNumber.BigNumber;
+ public toBigNumber(value: number | string): BigNumber.BigNumber;
+ public isAddress(address: string): boolean;
+ public isChecksumAddress(address: string): boolean;
+ public sha3(value: string, options?: Web3.Sha3Options): string;
+ }
+
+ namespace providers {
+ class HttpProvider implements Web3.Provider {
+ constructor(url?: string, timeout?: number, username?: string, password?: string);
+ public sendAsync(
+ payload: JSONRPCRequestPayload,
+ callback: (err: Error, result: JSONRPCResponsePayload) => void,
+ ): void;
+ }
+ }
+
+ namespace Web3 {
+ interface ContractInstance {
+ address: string;
+ abi: ContractAbi;
+ [name: string]: any;
+ }
+
+ interface Contract<A extends ContractInstance> {
+ at(address: string): A;
+ getData(...args: any[]): string;
+ 'new'(...args: any[]): A;
+ }
+
+ interface FilterResult {
+ get(callback: () => void): void;
+ watch(callback: (err: Error, result: LogEntryEvent) => void): void;
+ stopWatching(callback?: () => void): void;
+ }
+
+ interface Provider {
+ sendAsync(
+ payload: JSONRPCRequestPayload,
+ callback: (err: Error, result: JSONRPCResponsePayload) => void,
+ ): void;
+ }
+
+ interface Sha3Options {
+ encoding: 'hex';
+ }
+
+ interface EthApi {
+ coinbase: string;
+ mining: boolean;
+ hashrate: number;
+ gasPrice: BigNumber.BigNumber;
+ accounts: string[];
+ blockNumber: number;
+ defaultAccount?: string;
+ defaultBlock: BlockParam;
+ syncing: Web3.SyncingResult;
+ compile: {
+ solidity(sourceString: string, cb?: (err: Error, result: any) => void): object;
+ };
+ getMining(cd: (err: Error, mining: boolean) => void): void;
+ getHashrate(cd: (err: Error, hashrate: number) => void): void;
+ getGasPrice(cd: (err: Error, gasPrice: BigNumber.BigNumber) => void): void;
+ getAccounts(cd: (err: Error, accounts: string[]) => void): void;
+ getBlockNumber(callback: (err: Error, blockNumber: number) => void): void;
+ getSyncing(cd: (err: Error, syncing: Web3.SyncingResult) => void): void;
+ isSyncing(cb: (err: Error, isSyncing: boolean, syncingState: Web3.SyncingState) => void): Web3.IsSyncing;
+
+ getBlock(hashStringOrBlockNumber: string | BlockParam): BlockWithoutTransactionData;
+ getBlock(
+ hashStringOrBlockNumber: string | BlockParam,
+ callback: (err: Error, blockObj: BlockWithoutTransactionData) => void,
+ ): void;
+ getBlock(
+ hashStringOrBlockNumber: string | BlockParam,
+ returnTransactionObjects: true,
+ ): BlockWithTransactionData;
+ getBlock(
+ hashStringOrBlockNumber: string | BlockParam,
+ returnTransactionObjects: true,
+ callback: (err: Error, blockObj: BlockWithTransactionData) => void,
+ ): void;
+
+ getBlockTransactionCount(hashStringOrBlockNumber: string | BlockParam): number;
+ getBlockTransactionCount(
+ hashStringOrBlockNumber: string | BlockParam,
+ callback: (err: Error, blockTransactionCount: number) => void,
+ ): void;
+
+ // TODO returnTransactionObjects
+ getUncle(hashStringOrBlockNumber: string | BlockParam, uncleNumber: number): BlockWithoutTransactionData;
+ getUncle(
+ hashStringOrBlockNumber: string | BlockParam,
+ uncleNumber: number,
+ callback: (err: Error, uncle: BlockWithoutTransactionData) => void,
+ ): void;
+
+ getTransaction(transactionHash: string): Transaction;
+ getTransaction(transactionHash: string, callback: (err: Error, transaction: Transaction) => void): void;
+
+ getTransactionFromBlock(hashStringOrBlockNumber: string | BlockParam, indexNumber: number): Transaction;
+ getTransactionFromBlock(
+ hashStringOrBlockNumber: string | BlockParam,
+ indexNumber: number,
+ callback: (err: Error, transaction: Transaction) => void,
+ ): void;
+
+ contract(abi: AbiDefinition[]): Web3.Contract<any>;
+
+ // TODO block param
+ getBalance(addressHexString: string): BigNumber.BigNumber;
+ getBalance(addressHexString: string, callback: (err: Error, result: BigNumber.BigNumber) => void): void;
+
+ // TODO block param
+ getStorageAt(address: string, position: number): string;
+ getStorageAt(address: string, position: number, callback: (err: Error, storage: string) => void): void;
+
+ // TODO block param
+ getCode(addressHexString: string): string;
+ getCode(addressHexString: string, callback: (err: Error, code: string) => void): void;
+
+ filter(value: string | FilterObject): Web3.FilterResult;
+
+ sendTransaction(txData: TxData): string;
+ sendTransaction(txData: TxData, callback: (err: Error, value: string) => void): void;
+
+ sendRawTransaction(rawTxData: string): string;
+ sendRawTransaction(rawTxData: string, callback: (err: Error, value: string) => void): void;
+
+ sign(address: string, data: string): string;
+ sign(address: string, data: string, callback: (err: Error, signature: string) => void): void;
+
+ getTransactionReceipt(txHash: string): TransactionReceipt | null;
+ getTransactionReceipt(
+ txHash: string,
+ callback: (err: Error, receipt: TransactionReceipt | null) => void,
+ ): void;
+
+ // TODO block param
+ call(callData: CallData): string;
+ call(callData: CallData, callback: (err: Error, result: string) => void): void;
+
+ estimateGas(callData: CallData): number;
+ estimateGas(callData: CallData, callback: (err: Error, gas: number) => void): void;
+
+ // TODO defaultBlock
+ getTransactionCount(address: string): number;
+ getTransactionCount(address: string, callback: (err: Error, count: number) => void): void;
+ }
+
+ interface VersionApi {
+ api: string;
+ network: string;
+ node: string;
+ ethereum: string;
+ whisper: string;
+ getNetwork(cd: (err: Error, networkId: string) => void): void;
+ getNode(cd: (err: Error, nodeVersion: string) => void): void;
+ getEthereum(cd: (err: Error, ethereum: string) => void): void;
+ getWhisper(cd: (err: Error, whisper: string) => void): void;
+ }
+
+ interface PersonalApi {
+ listAccounts: string[] | undefined;
+ newAccount(password?: string): string;
+ unlockAccount(address: string, password?: string, duration?: number): boolean;
+ lockAccount(address: string): boolean;
+ sign(message: string, account: string, password: string): string;
+ sign(hexMessage: string, account: string, callback: (error: Error, signature: string) => void): void;
+ }
+
+ interface NetApi {
+ listening: boolean;
+ peerCount: number;
+ getListening(cd: (err: Error, listening: boolean) => void): void;
+ getPeerCount(cd: (err: Error, peerCount: number) => void): void;
+ }
+
+ interface SyncingState {
+ startingBlock: number;
+ currentBlock: number;
+ highestBlock: number;
+ }
+ type SyncingResult = false | SyncingState;
+
+ interface IsSyncing {
+ addCallback(cb: (err: Error, isSyncing: boolean, syncingState: SyncingState) => void): void;
+ stopWatching(): void;
+ }
+ }
+ /* tslint:disable */
+ export = Web3;
+ /* tslint:enable */
+}
diff --git a/packages/utils/.npmignore b/packages/utils/.npmignore
index ad5ffcd56..24e65ad5b 100644
--- a/packages/utils/.npmignore
+++ b/packages/utils/.npmignore
@@ -3,3 +3,4 @@ yarn-error.log
/scripts/
/src/
tsconfig.json
+/lib/monorepo_scripts/
diff --git a/packages/utils/README.md b/packages/utils/README.md
index 22de85f4a..fde0780a9 100644
--- a/packages/utils/README.md
+++ b/packages/utils/README.md
@@ -10,10 +10,10 @@ yarn add @0xproject/utils
If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`:
-```
-"include": [
- "./node_modules/web3-typescript-typings/index.d.ts",
-]
+```json
+"compilerOptions": {
+ "typeRoots": ["node_modules/@0xproject/typescript-typings/types", "node_modules/@types"],
+}
```
## Usage
diff --git a/packages/utils/package.json b/packages/utils/package.json
index ffdd7fe2e..bc869fe1e 100644
--- a/packages/utils/package.json
+++ b/packages/utils/package.json
@@ -31,14 +31,13 @@
},
"dependencies": {
"@0xproject/types": "^0.4.1",
+ "@0xproject/typescript-typings": "^0.0.1",
"@types/node": "^8.0.53",
"bignumber.js": "~4.1.0",
"ethers-contracts": "^2.2.1",
- "ethers-typescript-typings": "^0.0.4",
"js-sha3": "^0.7.0",
"lodash": "^4.17.4",
- "web3": "^0.20.0",
- "web3-typescript-typings": "^0.10.2"
+ "web3": "^0.20.0"
},
"publishConfig": {
"access": "public"
diff --git a/packages/utils/src/abi_decoder.ts b/packages/utils/src/abi_decoder.ts
index 2b496eb17..d49906cfb 100644
--- a/packages/utils/src/abi_decoder.ts
+++ b/packages/utils/src/abi_decoder.ts
@@ -1,13 +1,22 @@
-import { AbiType, DecodedLogArgs, LogWithDecodedArgs, RawLog, SolidityTypes } from '@0xproject/types';
+import {
+ AbiDefinition,
+ AbiType,
+ DecodedLogArgs,
+ EventAbi,
+ EventParameter,
+ LogEntry,
+ LogWithDecodedArgs,
+ RawLog,
+ SolidityTypes,
+} from '@0xproject/types';
import * as ethersContracts from 'ethers-contracts';
import * as _ from 'lodash';
-import * as Web3 from 'web3';
import { BigNumber } from './configured_bignumber';
export class AbiDecoder {
- private _savedABIs: Web3.AbiDefinition[] = [];
- private _methodIds: { [signatureHash: string]: Web3.EventAbi } = {};
+ private _savedABIs: AbiDefinition[] = [];
+ private _methodIds: { [signatureHash: string]: EventAbi } = {};
private static _padZeros(address: string) {
let formatted = address;
if (_.startsWith(formatted, '0x')) {
@@ -17,11 +26,11 @@ export class AbiDecoder {
formatted = _.padStart(formatted, 40, '0');
return `0x${formatted}`;
}
- constructor(abiArrays: Web3.AbiDefinition[][]) {
+ constructor(abiArrays: AbiDefinition[][]) {
_.forEach(abiArrays, this._addABI.bind(this));
}
// This method can only decode logs from the 0x & ERC20 smart contracts
- public tryToDecodeLogOrNoop<ArgsType>(log: Web3.LogEntry): LogWithDecodedArgs<ArgsType> | RawLog {
+ public tryToDecodeLogOrNoop<ArgsType>(log: LogEntry): LogWithDecodedArgs<ArgsType> | RawLog {
const methodId = log.topics[0];
const event = this._methodIds[methodId];
if (_.isUndefined(event)) {
@@ -37,7 +46,7 @@ export class AbiDecoder {
const decodedData = ethersInterface.events[event.name].parse(log.data);
let failedToDecode = false;
- _.forEach(event.inputs, (param: Web3.EventParameter, i: number) => {
+ _.forEach(event.inputs, (param: EventParameter, i: number) => {
// Indexed parameters are stored in topics. Non-indexed ones in decodedData
let value: BigNumber | string | number = param.indexed ? log.topics[topicsIndex++] : decodedData[i];
if (_.isUndefined(value)) {
@@ -64,12 +73,12 @@ export class AbiDecoder {
};
}
}
- private _addABI(abiArray: Web3.AbiDefinition[]): void {
+ private _addABI(abiArray: AbiDefinition[]): void {
if (_.isUndefined(abiArray)) {
return;
}
const ethersInterface = new ethersContracts.Interface(abiArray);
- _.map(abiArray, (abi: Web3.AbiDefinition) => {
+ _.map(abiArray, (abi: AbiDefinition) => {
if (abi.type === AbiType.Event) {
const topic = ethersInterface.events[abi.name].topic;
this._methodIds[topic] = abi;
diff --git a/packages/utils/tsconfig.json b/packages/utils/tsconfig.json
index 8114d99cd..c56d255d5 100644
--- a/packages/utils/tsconfig.json
+++ b/packages/utils/tsconfig.json
@@ -3,9 +3,5 @@
"compilerOptions": {
"outDir": "lib"
},
- "include": [
- "./src/**/*",
- "../../node_modules/web3-typescript-typings/index.d.ts",
- "../../node_modules/ethers-typescript-typings/index.d.ts"
- ]
+ "include": ["./src/**/*"]
}
diff --git a/packages/web3-typescript-typings/.npmignore b/packages/web3-typescript-typings/.npmignore
deleted file mode 100644
index 104d718ed..000000000
--- a/packages/web3-typescript-typings/.npmignore
+++ /dev/null
@@ -1,3 +0,0 @@
-.*
-yarn-error.log
-/scripts/
diff --git a/packages/web3-typescript-typings/CHANGELOG.md b/packages/web3-typescript-typings/CHANGELOG.md
deleted file mode 100644
index 845b1ecd2..000000000
--- a/packages/web3-typescript-typings/CHANGELOG.md
+++ /dev/null
@@ -1,16 +0,0 @@
-# CHANGELOG
-
-## v0.10.0 - _March 4, 2018_
-
- * Support ABIv2 (#401)
- * Add types for transaction traces (#426)
-
-## v0.9.11 - _February 16, 2018_
-
- * Fix `web3.net.peerCount` to be of type number instead of boolean (#397)
-
-## v0.9.3 - _January 11, 2018_
-
- * Fix `getTransactionReceipt` not returning null (#338)
- * Add type for getData on a contract
- * Fixed the `defaultAccount` not allowing for `undefined` value (#320)
diff --git a/packages/web3-typescript-typings/README.md b/packages/web3-typescript-typings/README.md
deleted file mode 100644
index 95c193287..000000000
--- a/packages/web3-typescript-typings/README.md
+++ /dev/null
@@ -1,49 +0,0 @@
-## web3-typescript-typings
-
-There currently isn't an official [Web3][web3]
-type definition included in the [DefinitelyTyped][definitelytyped] project.
-Until that happens, we will continue to improve our own type definition.
-If it get's close to comprehensive, we'll add it to [DefinitelyTyped][definitelytyped].
-
-[web3]: https://github.com/ethereum/web3.js/
-[definitelytyped]: https://github.com/DefinitelyTyped/DefinitelyTyped
-
-## Installation
-
-```bash
-yarn add -D web3-typescript-typings
-```
-
-## Usage
-
-Add the following line within an `include` section of your `tsconfig.json`
-
-```json
-"./node_modules/web3-typescript-typings/index.d.ts"
-```
-
-## Contributing
-
-We strongly encourage that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository.
-
-Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
-
-### Install Dependencies
-
-If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
-
-```bash
-yarn config set workspaces-experimental true
-```
-
-Then install dependencies
-
-```bash
-yarn install
-```
-
-### Lint
-
-```bash
-yarn lint
-```
diff --git a/packages/web3-typescript-typings/index.d.ts b/packages/web3-typescript-typings/index.d.ts
deleted file mode 100644
index cbe067b37..000000000
--- a/packages/web3-typescript-typings/index.d.ts
+++ /dev/null
@@ -1,440 +0,0 @@
-declare module 'web3' {
- import * as BigNumber from 'bignumber.js';
-
- type MixedData = string | number | object | any[] | BigNumber.BigNumber;
-
- class Web3 {
- public static providers: typeof providers;
- public currentProvider: Web3.Provider;
-
- public eth: Web3.EthApi;
- public personal: Web3.PersonalApi | undefined;
- public version: Web3.VersionApi;
- public net: Web3.NetApi;
-
- public constructor(provider?: Web3.Provider);
-
- public isConnected(): boolean;
- public setProvider(provider: Web3.Provider): void;
- public reset(keepIsSyncing: boolean): void;
- public toHex(data: MixedData): string;
- public toAscii(hex: string): string;
- public fromAscii(ascii: string, padding?: number): string;
- public toDecimal(hex: string): number;
- public fromDecimal(value: number | string): string;
- public fromWei(value: number | string, unit: Web3.Unit): string;
- public fromWei(value: BigNumber.BigNumber, unit: Web3.Unit): BigNumber.BigNumber;
- public toWei(amount: number | string, unit: Web3.Unit): string;
- public toWei(amount: BigNumber.BigNumber, unit: Web3.Unit): BigNumber.BigNumber;
- public toBigNumber(value: number | string): BigNumber.BigNumber;
- public isAddress(address: string): boolean;
- public isChecksumAddress(address: string): boolean;
- public sha3(value: string, options?: Web3.Sha3Options): string;
- }
-
- namespace providers {
- class HttpProvider implements Web3.Provider {
- constructor(url?: string, timeout?: number, username?: string, password?: string);
- public sendAsync(
- payload: Web3.JSONRPCRequestPayload,
- callback: (err: Error, result: Web3.JSONRPCResponsePayload) => void,
- ): void;
- }
- }
-
- namespace Web3 {
- type ContractAbi = AbiDefinition[];
-
- type AbiDefinition = FunctionAbi | EventAbi;
-
- type FunctionAbi = MethodAbi | ConstructorAbi | FallbackAbi;
-
- enum AbiType {
- Function = 'function',
- Constructor = 'constructor',
- Event = 'event',
- Fallback = 'fallback',
- }
-
- type ConstructorStateMutability = 'nonpayable' | 'payable';
- type StateMutability = 'pure' | 'view' | ConstructorStateMutability;
-
- interface MethodAbi {
- type: AbiType.Function;
- name: string;
- inputs: DataItem[];
- outputs: DataItem[];
- constant: boolean;
- stateMutability: StateMutability;
- payable: boolean;
- }
-
- interface ConstructorAbi {
- type: AbiType.Constructor;
- inputs: DataItem[];
- payable: boolean;
- stateMutability: ConstructorStateMutability;
- }
-
- interface FallbackAbi {
- type: AbiType.Fallback;
- payable: boolean;
- }
-
- interface EventParameter extends DataItem {
- indexed: boolean;
- }
-
- interface EventAbi {
- type: AbiType.Event;
- name: string;
- inputs: EventParameter[];
- anonymous: boolean;
- }
-
- interface DataItem {
- name: string;
- type: string;
- components: DataItem[];
- }
-
- interface ContractInstance {
- address: string;
- abi: Web3.ContractAbi;
- [name: string]: any;
- }
-
- interface Contract<A extends ContractInstance> {
- at(address: string): A;
- getData(...args: any[]): string;
- 'new'(...args: any[]): A;
- }
-
- interface FilterObject {
- fromBlock?: number | string;
- toBlock?: number | string;
- address?: string;
- topics?: LogTopic[];
- }
-
- type LogTopic = null | string | string[];
-
- interface DecodedLogEntry<A> extends LogEntry {
- event: string;
- args: A;
- }
-
- interface DecodedLogEntryEvent<A> extends DecodedLogEntry<A> {
- removed: boolean;
- }
-
- interface LogEntryEvent extends LogEntry {
- removed: boolean;
- }
-
- interface FilterResult {
- get(callback: () => void): void;
- watch(callback: (err: Error, result: LogEntryEvent) => void): void;
- stopWatching(callback?: () => void): void;
- }
-
- export interface JSONRPCRequestPayload {
- params: any[];
- method: string;
- id: number;
- jsonrpc: string;
- }
-
- export interface JSONRPCResponsePayload {
- result: any;
- id: number;
- jsonrpc: string;
- }
-
- export type OpCode = string;
-
- export interface StructLog {
- depth: number;
- error: string;
- gas: number;
- gasCost: number;
- memory: string[];
- op: OpCode;
- pc: number;
- stack: string[];
- storage: { [location: string]: string };
- }
- export interface TransactionTrace {
- gas: number;
- returnValue: any;
- structLogs: StructLog[];
- }
-
- interface Provider {
- sendAsync(
- payload: JSONRPCRequestPayload,
- callback: (err: Error, result: JSONRPCResponsePayload) => void,
- ): void;
- }
-
- interface Sha3Options {
- encoding: 'hex';
- }
-
- interface EthApi {
- coinbase: string;
- mining: boolean;
- hashrate: number;
- gasPrice: BigNumber.BigNumber;
- accounts: string[];
- blockNumber: number;
- defaultAccount?: string;
- defaultBlock: Web3.BlockParam;
- syncing: Web3.SyncingResult;
- compile: {
- solidity(sourceString: string, cb?: (err: Error, result: any) => void): object;
- };
- getMining(cd: (err: Error, mining: boolean) => void): void;
- getHashrate(cd: (err: Error, hashrate: number) => void): void;
- getGasPrice(cd: (err: Error, gasPrice: BigNumber.BigNumber) => void): void;
- getAccounts(cd: (err: Error, accounts: string[]) => void): void;
- getBlockNumber(callback: (err: Error, blockNumber: number) => void): void;
- getSyncing(cd: (err: Error, syncing: Web3.SyncingResult) => void): void;
- isSyncing(cb: (err: Error, isSyncing: boolean, syncingState: Web3.SyncingState) => void): Web3.IsSyncing;
-
- getBlock(hashStringOrBlockNumber: string | Web3.BlockParam): Web3.BlockWithoutTransactionData;
- getBlock(
- hashStringOrBlockNumber: string | Web3.BlockParam,
- callback: (err: Error, blockObj: Web3.BlockWithoutTransactionData) => void,
- ): void;
- getBlock(
- hashStringOrBlockNumber: string | Web3.BlockParam,
- returnTransactionObjects: true,
- ): Web3.BlockWithTransactionData;
- getBlock(
- hashStringOrBlockNumber: string | Web3.BlockParam,
- returnTransactionObjects: true,
- callback: (err: Error, blockObj: Web3.BlockWithTransactionData) => void,
- ): void;
-
- getBlockTransactionCount(hashStringOrBlockNumber: string | Web3.BlockParam): number;
- getBlockTransactionCount(
- hashStringOrBlockNumber: string | Web3.BlockParam,
- callback: (err: Error, blockTransactionCount: number) => void,
- ): void;
-
- // TODO returnTransactionObjects
- getUncle(
- hashStringOrBlockNumber: string | Web3.BlockParam,
- uncleNumber: number,
- ): Web3.BlockWithoutTransactionData;
- getUncle(
- hashStringOrBlockNumber: string | Web3.BlockParam,
- uncleNumber: number,
- callback: (err: Error, uncle: Web3.BlockWithoutTransactionData) => void,
- ): void;
-
- getTransaction(transactionHash: string): Web3.Transaction;
- getTransaction(
- transactionHash: string,
- callback: (err: Error, transaction: Web3.Transaction) => void,
- ): void;
-
- getTransactionFromBlock(
- hashStringOrBlockNumber: string | Web3.BlockParam,
- indexNumber: number,
- ): Web3.Transaction;
- getTransactionFromBlock(
- hashStringOrBlockNumber: string | Web3.BlockParam,
- indexNumber: number,
- callback: (err: Error, transaction: Web3.Transaction) => void,
- ): void;
-
- contract(abi: Web3.AbiDefinition[]): Web3.Contract<any>;
-
- // TODO block param
- getBalance(addressHexString: string): BigNumber.BigNumber;
- getBalance(addressHexString: string, callback: (err: Error, result: BigNumber.BigNumber) => void): void;
-
- // TODO block param
- getStorageAt(address: string, position: number): string;
- getStorageAt(address: string, position: number, callback: (err: Error, storage: string) => void): void;
-
- // TODO block param
- getCode(addressHexString: string): string;
- getCode(addressHexString: string, callback: (err: Error, code: string) => void): void;
-
- filter(value: string | Web3.FilterObject): Web3.FilterResult;
-
- sendTransaction(txData: Web3.TxData): string;
- sendTransaction(txData: Web3.TxData, callback: (err: Error, value: string) => void): void;
-
- sendRawTransaction(rawTxData: string): string;
- sendRawTransaction(rawTxData: string, callback: (err: Error, value: string) => void): void;
-
- sign(address: string, data: string): string;
- sign(address: string, data: string, callback: (err: Error, signature: string) => void): void;
-
- getTransactionReceipt(txHash: string): Web3.TransactionReceipt | null;
- getTransactionReceipt(
- txHash: string,
- callback: (err: Error, receipt: Web3.TransactionReceipt | null) => void,
- ): void;
-
- // TODO block param
- call(callData: Web3.CallData): string;
- call(callData: Web3.CallData, callback: (err: Error, result: string) => void): void;
-
- estimateGas(callData: Web3.CallData): number;
- estimateGas(callData: Web3.CallData, callback: (err: Error, gas: number) => void): void;
-
- // TODO defaultBlock
- getTransactionCount(address: string): number;
- getTransactionCount(address: string, callback: (err: Error, count: number) => void): void;
- }
-
- interface VersionApi {
- api: string;
- network: string;
- node: string;
- ethereum: string;
- whisper: string;
- getNetwork(cd: (err: Error, networkId: string) => void): void;
- getNode(cd: (err: Error, nodeVersion: string) => void): void;
- getEthereum(cd: (err: Error, ethereum: string) => void): void;
- getWhisper(cd: (err: Error, whisper: string) => void): void;
- }
-
- interface PersonalApi {
- listAccounts: string[] | undefined;
- newAccount(password?: string): string;
- unlockAccount(address: string, password?: string, duration?: number): boolean;
- lockAccount(address: string): boolean;
- sign(message: string, account: string, password: string): string;
- sign(hexMessage: string, account: string, callback: (error: Error, signature: string) => void): void;
- }
-
- interface NetApi {
- listening: boolean;
- peerCount: number;
- getListening(cd: (err: Error, listening: boolean) => void): void;
- getPeerCount(cd: (err: Error, peerCount: number) => void): void;
- }
-
- type BlockParam = number | 'earliest' | 'latest' | 'pending';
-
- type Unit =
- | 'kwei'
- | 'ada'
- | 'mwei'
- | 'babbage'
- | 'gwei'
- | 'shannon'
- | 'szabo'
- | 'finney'
- | 'ether'
- | 'kether'
- | 'grand'
- | 'einstein'
- | 'mether'
- | 'gether'
- | 'tether';
-
- interface SyncingState {
- startingBlock: number;
- currentBlock: number;
- highestBlock: number;
- }
- type SyncingResult = false | SyncingState;
-
- interface IsSyncing {
- addCallback(cb: (err: Error, isSyncing: boolean, syncingState: SyncingState) => void): void;
- stopWatching(): void;
- }
-
- interface AbstractBlock {
- number: number | null;
- hash: string | null;
- parentHash: string;
- nonce: string | null;
- sha3Uncles: string;
- logsBloom: string | null;
- transactionsRoot: string;
- stateRoot: string;
- miner: string;
- difficulty: BigNumber.BigNumber;
- totalDifficulty: BigNumber.BigNumber;
- extraData: string;
- size: number;
- gasLimit: number;
- gasUsed: number;
- timestamp: number;
- uncles: string[];
- }
- interface BlockWithoutTransactionData extends AbstractBlock {
- transactions: string[];
- }
- interface BlockWithTransactionData extends AbstractBlock {
- transactions: Transaction[];
- }
-
- interface Transaction {
- hash: string;
- nonce: number;
- blockHash: string | null;
- blockNumber: number | null;
- transactionIndex: number | null;
- from: string;
- to: string | null;
- value: BigNumber.BigNumber;
- gasPrice: BigNumber.BigNumber;
- gas: number;
- input: string;
- }
-
- interface CallTxDataBase {
- to?: string;
- value?: number | string | BigNumber.BigNumber;
- gas?: number | string | BigNumber.BigNumber;
- gasPrice?: number | string | BigNumber.BigNumber;
- data?: string;
- nonce?: number;
- }
-
- interface TxData extends CallTxDataBase {
- from: string;
- }
-
- interface CallData extends CallTxDataBase {
- from?: string;
- }
-
- interface TransactionReceipt {
- blockHash: string;
- blockNumber: number;
- transactionHash: string;
- transactionIndex: number;
- from: string;
- to: string;
- status: null | string | 0 | 1;
- cumulativeGasUsed: number;
- gasUsed: number;
- contractAddress: string | null;
- logs: LogEntry[];
- }
-
- interface LogEntry {
- logIndex: number | null;
- transactionIndex: number | null;
- transactionHash: string;
- blockHash: string | null;
- blockNumber: number | null;
- address: string;
- data: string;
- topics: string[];
- }
- }
- /* tslint:disable */
- export = Web3;
- /* tslint:enable */
-}
diff --git a/packages/web3-typescript-typings/monorepo_scripts/globals.d.ts b/packages/web3-typescript-typings/monorepo_scripts/globals.d.ts
deleted file mode 100644
index 94e63a32d..000000000
--- a/packages/web3-typescript-typings/monorepo_scripts/globals.d.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-declare module '*.json' {
- const json: any;
- /* tslint:disable */
- export default json;
- /* tslint:enable */
-}
diff --git a/packages/web3-typescript-typings/monorepo_scripts/postpublish.ts b/packages/web3-typescript-typings/monorepo_scripts/postpublish.ts
deleted file mode 100644
index dcb99d0f7..000000000
--- a/packages/web3-typescript-typings/monorepo_scripts/postpublish.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import { postpublishUtils } from '@0xproject/monorepo-scripts';
-
-import * as packageJSON from '../package.json';
-import * as tsConfigJSON from '../tsconfig.json';
-
-const cwd = `${__dirname}/..`;
-// tslint:disable-next-line:no-floating-promises
-postpublishUtils.runAsync(packageJSON, tsConfigJSON, cwd);
diff --git a/packages/web3-typescript-typings/package.json b/packages/web3-typescript-typings/package.json
deleted file mode 100644
index d56b83421..000000000
--- a/packages/web3-typescript-typings/package.json
+++ /dev/null
@@ -1,40 +0,0 @@
-{
- "name": "web3-typescript-typings",
- "version": "0.10.2",
- "description": "Typescript type definitions for web3",
- "main": "index.d.ts",
- "types": "index.d.ts",
- "scripts": {
- "lint": "tslint index.d.ts",
- "build": "tsc && copyfiles -u 1 './lib/**/*' ./scripts",
- "clean": "shx rm -rf scripts"
- },
- "repository": {
- "type": "git",
- "url": "git+https://github.com/0xProject/0x-monorepo.git"
- },
- "author": "Fabio Berger",
- "contributors": [
- "Leonid Logvinov <logvinov.leon@gmail.com>"
- ],
- "license": "Apache-2.0",
- "bugs": {
- "url": "https://github.com/0xProject/0x-monorepo/issues"
- },
- "homepage": "https://github.com/0xProject/0x-monorepo/packages/web3-typescript-typings#readme",
- "devDependencies": {
- "@0xproject/monorepo-scripts": "^0.1.14",
- "@types/bignumber.js": "^4.0.2",
- "copyfiles": "^1.2.0",
- "shx": "^0.2.2",
- "tslint": "5.8.0",
- "tslint-config-0xproject": "^0.0.2",
- "typescript": "2.7.1"
- },
- "dependencies": {
- "bignumber.js": "~4.1.0"
- },
- "publishConfig": {
- "access": "public"
- }
-}
diff --git a/packages/web3-typescript-typings/tsconfig.json b/packages/web3-typescript-typings/tsconfig.json
deleted file mode 100644
index bc453af4b..000000000
--- a/packages/web3-typescript-typings/tsconfig.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "extends": "../../tsconfig",
- "compilerOptions": {
- "outDir": "lib"
- },
- "include": ["./monorepo_scripts/**/*"]
-}
diff --git a/packages/web3-typescript-typings/tslint.json b/packages/web3-typescript-typings/tslint.json
deleted file mode 100644
index 9a93a1f74..000000000
--- a/packages/web3-typescript-typings/tslint.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "extends": ["tslint-config-0xproject"]
-}
diff --git a/packages/web3-wrapper/.npmignore b/packages/web3-wrapper/.npmignore
index ad5ffcd56..24e65ad5b 100644
--- a/packages/web3-wrapper/.npmignore
+++ b/packages/web3-wrapper/.npmignore
@@ -3,3 +3,4 @@ yarn-error.log
/scripts/
/src/
tsconfig.json
+/lib/monorepo_scripts/
diff --git a/packages/web3-wrapper/CHANGELOG.md b/packages/web3-wrapper/CHANGELOG.md
index 9fbc9021c..d86a759a8 100644
--- a/packages/web3-wrapper/CHANGELOG.md
+++ b/packages/web3-wrapper/CHANGELOG.md
@@ -1,22 +1,22 @@
# CHANGELOG
-## v0.4.0 _TBD_
+## v0.4.0 - _TBD_
* Rename `signTransactionAsync` to `signMessageAsync` for clarity (#465)
-## v0.3.0 _March 18, 2018_
+## v0.3.0 - _March 18, 2018_
* Add `web3Wrapper.takeSnapshotAsync`, `web3Wrapper.revertSnapshotAsync`, `web3Wrapper.mineBlockAsync`, `web3Wrapper.increaseTimeAsync` (#426)
* Add `web3Wrapper.isZeroExWeb3Wrapper` for runtime instanceOf checks (#426)
* Add a `getProvider` method (#444)
-## v0.2.0 _March 4, 2018_
+## v0.2.0 - _March 4, 2018_
* Ensure all returned user addresses are lowercase (#373)
* Add `web3Wrapper.callAsync` (#413)
* Make `web3Wrapper.estimateGas` accept whole `txData` instead of `data` (#413)
* Remove `web3Wrapper.getContractInstance` (#413)
-## v0.1.12 _February 9, 2018_
+## v0.1.12 - _February 9, 2018_
* Fix publishing issue where .npmignore was not properly excluding undesired content (#389)
diff --git a/packages/web3-wrapper/README.md b/packages/web3-wrapper/README.md
index 1fed11407..e7491acb0 100644
--- a/packages/web3-wrapper/README.md
+++ b/packages/web3-wrapper/README.md
@@ -12,10 +12,10 @@ yarn add @0xproject/web3-wrapper
If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`:
-```
-"include": [
- "./node_modules/web3-typescript-typings/index.d.ts",
-]
+```json
+"compilerOptions": {
+ "typeRoots": ["node_modules/@0xproject/typescript-typings/types", "node_modules/@types"],
+}
```
## Contributing
diff --git a/packages/web3-wrapper/package.json b/packages/web3-wrapper/package.json
index 176f796c8..fa79fa377 100644
--- a/packages/web3-wrapper/package.json
+++ b/packages/web3-wrapper/package.json
@@ -45,11 +45,10 @@
"dependencies": {
"@0xproject/types": "^0.4.1",
"@0xproject/utils": "^0.4.3",
+ "@0xproject/typescript-typings": "^0.0.1",
"ethers-contracts": "^2.2.1",
- "ethers-typescript-typings": "^0.0.4",
"lodash": "^4.17.4",
- "web3": "^0.20.0",
- "web3-typescript-typings": "^0.10.2"
+ "web3": "^0.20.0"
},
"publishConfig": {
"access": "public"
diff --git a/packages/web3-wrapper/src/index.ts b/packages/web3-wrapper/src/index.ts
index 2ce2580ee..87c69b269 100644
--- a/packages/web3-wrapper/src/index.ts
+++ b/packages/web3-wrapper/src/index.ts
@@ -1,4 +1,16 @@
-import { RawLogEntry, TransactionReceipt, TxData } from '@0xproject/types';
+import {
+ BlockParam,
+ BlockWithoutTransactionData,
+ CallData,
+ ContractAbi,
+ FilterObject,
+ JSONRPCRequestPayload,
+ JSONRPCResponsePayload,
+ LogEntry,
+ RawLogEntry,
+ TransactionReceipt,
+ TxData,
+} from '@0xproject/types';
import { BigNumber, promisify } from '@0xproject/utils';
import * as _ from 'lodash';
import * as Web3 from 'web3';
@@ -157,8 +169,8 @@ export class Web3Wrapper {
* @param blockParam The block you wish to fetch (blockHash, blockNumber or blockLiteral)
* @returns The requested block without transaction data
*/
- public async getBlockAsync(blockParam: string | Web3.BlockParam): Promise<Web3.BlockWithoutTransactionData> {
- const block = await promisify<Web3.BlockWithoutTransactionData>(this._web3.eth.getBlock)(blockParam);
+ public async getBlockAsync(blockParam: string | BlockParam): Promise<BlockWithoutTransactionData> {
+ const block = await promisify<BlockWithoutTransactionData>(this._web3.eth.getBlock)(blockParam);
return block;
}
/**
@@ -166,7 +178,7 @@ export class Web3Wrapper {
* @param blockParam The block you wish to fetch (blockHash, blockNumber or blockLiteral)
* @returns The block's timestamp
*/
- public async getBlockTimestampAsync(blockParam: string | Web3.BlockParam): Promise<number> {
+ public async getBlockTimestampAsync(blockParam: string | BlockParam): Promise<number> {
const { timestamp } = await this.getBlockAsync(blockParam);
return timestamp;
}
@@ -214,7 +226,7 @@ export class Web3Wrapper {
* @param filter Parameters by which to filter which logs to retrieve
* @returns The corresponding log entries
*/
- public async getLogsAsync(filter: Web3.FilterObject): Promise<Web3.LogEntry[]> {
+ public async getLogsAsync(filter: FilterObject): Promise<LogEntry[]> {
let fromBlock = filter.fromBlock;
if (_.isNumber(fromBlock)) {
fromBlock = this._web3.toHex(fromBlock);
@@ -243,7 +255,7 @@ export class Web3Wrapper {
* @param abi Smart contract ABI
* @returns Web3 contract factory which can create Web3 Contract instances from the supplied ABI
*/
- public getContractFromAbi(abi: Web3.ContractAbi): Web3.Contract<any> {
+ public getContractFromAbi(abi: ContractAbi): Web3.Contract<any> {
const web3Contract = this._web3.eth.contract(abi);
return web3Contract;
}
@@ -252,7 +264,7 @@ export class Web3Wrapper {
* @param txData Transaction data
* @returns Estimated gas cost
*/
- public async estimateGasAsync(txData: Partial<Web3.TxData>): Promise<number> {
+ public async estimateGasAsync(txData: Partial<TxData>): Promise<number> {
const gas = await promisify<number>(this._web3.eth.estimateGas)(txData);
return gas;
}
@@ -262,7 +274,7 @@ export class Web3Wrapper {
* @param defaultBlock Block height at which to make the call. Defaults to `latest`
* @returns The raw call result
*/
- public async callAsync(callData: Web3.CallData, defaultBlock?: Web3.BlockParam): Promise<string> {
+ public async callAsync(callData: CallData, defaultBlock?: BlockParam): Promise<string> {
const rawCallResult = await promisify<string>(this._web3.eth.call)(callData, defaultBlock);
return rawCallResult;
}
@@ -271,13 +283,13 @@ export class Web3Wrapper {
* @param txData Transaction data
* @returns Transaction hash
*/
- public async sendTransactionAsync(txData: Web3.TxData): Promise<string> {
+ public async sendTransactionAsync(txData: TxData): Promise<string> {
const txHash = await promisify<string>(this._web3.eth.sendTransaction)(txData);
return txHash;
}
- private async _sendRawPayloadAsync<A>(payload: Partial<Web3.JSONRPCRequestPayload>): Promise<A> {
+ private async _sendRawPayloadAsync<A>(payload: Partial<JSONRPCRequestPayload>): Promise<A> {
const sendAsync = this._web3.currentProvider.sendAsync.bind(this._web3.currentProvider);
- const response = await promisify<Web3.JSONRPCResponsePayload>(sendAsync)(payload);
+ const response = await promisify<JSONRPCResponsePayload>(sendAsync)(payload);
const result = response.result;
return result;
}
@@ -295,7 +307,7 @@ export class Web3Wrapper {
return status;
}
}
- private _formatLog(rawLog: RawLogEntry): Web3.LogEntry {
+ private _formatLog(rawLog: RawLogEntry): LogEntry {
const formattedLog = {
...rawLog,
logIndex: this._hexToDecimal(rawLog.logIndex),
diff --git a/packages/web3-wrapper/tsconfig.json b/packages/web3-wrapper/tsconfig.json
index 7bae7f9f0..c56d255d5 100644
--- a/packages/web3-wrapper/tsconfig.json
+++ b/packages/web3-wrapper/tsconfig.json
@@ -3,9 +3,5 @@
"compilerOptions": {
"outDir": "lib"
},
- "include": [
- "./src/**/*",
- "../../node_modules/ethers-typescript-typings/index.d.ts",
- "../../node_modules/web3-typescript-typings/index.d.ts"
- ]
+ "include": ["./src/**/*"]
}
diff --git a/packages/website/package.json b/packages/website/package.json
index c455306ee..3869fb040 100644
--- a/packages/website/package.json
+++ b/packages/website/package.json
@@ -24,6 +24,7 @@
"@0xproject/subproviders": "^0.8.2",
"@0xproject/utils": "^0.4.3",
"@0xproject/web3-wrapper": "^0.3.1",
+ "@0xproject/typescript-typings": "^0.0.1",
"accounting": "^0.4.1",
"basscss": "^8.0.3",
"blockies": "^0.0.2",
@@ -75,9 +76,9 @@
"@types/moment": "^2.13.0",
"@types/node": "^8.0.53",
"@types/query-string": "^5.0.1",
- "@types/react": "^15.0.15",
+ "@types/react": "^16.0.34",
"@types/react-copy-to-clipboard": "^4.2.0",
- "@types/react-dom": "^0.14.23",
+ "@types/react-dom": "^16.0.3",
"@types/react-redux": "^4.4.37",
"@types/react-router-dom": "^4.0.4",
"@types/react-scroll": "0.0.31",
@@ -87,7 +88,6 @@
"copy-webpack-plugin": "^4.0.1",
"copyfiles": "^1.2.0",
"css-loader": "0.23.x",
- "ethers-typescript-typings": "^0.0.4",
"exports-loader": "0.6.x",
"imports-loader": "0.6.x",
"json-loader": "^0.5.4",
@@ -99,7 +99,6 @@
"tslint": "5.8.0",
"tslint-config-0xproject": "^0.0.2",
"typescript": "2.7.1",
- "web3-typescript-typings": "^0.10.2",
"webpack": "^3.1.0",
"webpack-dev-middleware": "^1.10.0",
"webpack-dev-server": "^2.5.0"
diff --git a/packages/website/ts/blockchain.ts b/packages/website/ts/blockchain.ts
index a3427baee..72cb94c02 100644
--- a/packages/website/ts/blockchain.ts
+++ b/packages/website/ts/blockchain.ts
@@ -151,13 +151,6 @@ export class Blockchain {
}
public async isAddressInTokenRegistryAsync(tokenAddress: string): Promise<boolean> {
utils.assert(!_.isUndefined(this._zeroEx), 'ZeroEx must be instantiated.');
- // HACK: temporarily whitelist the new WETH token address `as if` they were
- // already in the tokenRegistry.
- // TODO: Remove this hack once we've updated the TokenRegistries
- // Airtable task: https://airtable.com/tblFe0Q9JuKJPYbTn/viwsOG2Y97qdIeCIO/recv3VGmIorFzHBVz
- if (configs.SHOULD_DEPRECATE_OLD_WETH_TOKEN && tokenAddress === configs.NEW_WRAPPED_ETHERS[this.networkId]) {
- return true;
- }
const tokenIfExists = await this._zeroEx.tokenRegistry.getTokenIfExistsAsync(tokenAddress);
return !_.isUndefined(tokenIfExists);
}
@@ -544,6 +537,22 @@ export class Blockchain {
? {}
: trackedTokenStorage.getTrackedTokensByAddress(this._userAddressIfExists, this.networkId);
const tokenRegistryTokens = _.values(tokenRegistryTokensByAddress);
+ const tokenRegistryTokenSymbols = _.map(tokenRegistryTokens, t => t.symbol);
+ const defaultTrackedTokensInRegistry = _.intersection(
+ tokenRegistryTokenSymbols,
+ configs.DEFAULT_TRACKED_TOKEN_SYMBOLS,
+ );
+ if (defaultTrackedTokensInRegistry.length !== configs.DEFAULT_TRACKED_TOKEN_SYMBOLS.length) {
+ this._dispatcher.updateShouldBlockchainErrDialogBeOpen(true);
+ this._dispatcher.encounteredBlockchainError(BlockchainErrs.DefaultTokensNotInTokenRegistry);
+ const err = new Error(
+ `Default tracked tokens (${JSON.stringify(
+ configs.DEFAULT_TRACKED_TOKEN_SYMBOLS,
+ )}) not found in tokenRegistry: ${JSON.stringify(tokenRegistryTokens)}`,
+ );
+ await errorReporter.reportAsync(err);
+ return;
+ }
if (_.isEmpty(trackedTokensByAddress)) {
_.each(configs.DEFAULT_TRACKED_TOKEN_SYMBOLS, symbol => {
const token = _.find(tokenRegistryTokens, t => t.symbol === symbol);
@@ -728,22 +737,9 @@ export class Blockchain {
// HACK: For now we have a hard-coded list of iconUrls for the dummyTokens
// TODO: Refactor this out and pull the iconUrl directly from the TokenRegistry
const iconUrl = configs.ICON_URL_BY_SYMBOL[t.symbol];
- // HACK: Temporarily we hijack the WETH addresses fetched from the tokenRegistry
- // so that we can take our time with actually updating it. This ensures that when
- // we deploy the new WETH page, everyone will re-fill their trackedTokens with the
- // new canonical WETH.
- // TODO: Remove this hack once we've updated the TokenRegistries
- // Airtable task: https://airtable.com/tblFe0Q9JuKJPYbTn/viwsOG2Y97qdIeCIO/recv3VGmIorFzHBVz
- let address = t.address;
- if (configs.SHOULD_DEPRECATE_OLD_WETH_TOKEN && t.symbol === 'WETH') {
- const newEtherTokenAddressIfExists = configs.NEW_WRAPPED_ETHERS[this.networkId];
- if (!_.isUndefined(newEtherTokenAddressIfExists)) {
- address = newEtherTokenAddressIfExists;
- }
- }
const token: Token = {
iconUrl,
- address,
+ address: t.address,
name: t.name,
symbol: t.symbol,
decimals: t.decimals,
diff --git a/packages/website/ts/components/dialogs/blockchain_err_dialog.tsx b/packages/website/ts/components/dialogs/blockchain_err_dialog.tsx
index e71a0f7d1..1c3b7458d 100644
--- a/packages/website/ts/components/dialogs/blockchain_err_dialog.tsx
+++ b/packages/website/ts/components/dialogs/blockchain_err_dialog.tsx
@@ -52,6 +52,8 @@ export class BlockchainErrDialog extends React.Component<BlockchainErrDialogProp
return 'Enable wallet communication';
} else if (this.props.blockchainErr === BlockchainErrs.DisconnectedFromEthereumNode) {
return 'Disconnected from Ethereum network';
+ } else if (this.props.blockchainErr === BlockchainErrs.DefaultTokensNotInTokenRegistry) {
+ return 'Default TokenRegistry tokens missing';
} else {
return 'Unexpected error';
}
@@ -63,6 +65,8 @@ export class BlockchainErrDialog extends React.Component<BlockchainErrDialogProp
return this._renderNoWalletFoundExplanation();
} else if (this.props.blockchainErr === BlockchainErrs.DisconnectedFromEthereumNode) {
return this._renderDisconnectedFromNode();
+ } else if (this.props.blockchainErr === BlockchainErrs.DefaultTokensNotInTokenRegistry) {
+ return this._renderDefaultTokenNotInTokenRegistry();
} else {
return this._renderUnexpectedErrorExplanation();
}
@@ -82,6 +86,16 @@ export class BlockchainErrDialog extends React.Component<BlockchainErrDialogProp
</div>
);
}
+ private _renderDefaultTokenNotInTokenRegistry() {
+ return (
+ <div>
+ The TokenRegistry deployed on your network does not contain the needed default tokens for 0x Portal to
+ operate. Please try one of the supported networks (Mainnet, Kovan, Ropsten, Rinkeby). If on a local
+ Testnet, make sure the TokenRegistry contract is deployed and loaded with some default tokens (i.e WETH
+ & ZRX).
+ </div>
+ );
+ }
private _renderUnexpectedErrorExplanation() {
return <div>We encountered an unexpected error. Please try refreshing the page.</div>;
}
diff --git a/packages/website/ts/components/dialogs/eth_weth_conversion_dialog.tsx b/packages/website/ts/components/dialogs/eth_weth_conversion_dialog.tsx
index d1bdb447f..42ca1713d 100644
--- a/packages/website/ts/components/dialogs/eth_weth_conversion_dialog.tsx
+++ b/packages/website/ts/components/dialogs/eth_weth_conversion_dialog.tsx
@@ -37,8 +37,8 @@ export class EthWethConversionDialog extends React.Component<
EthWethConversionDialogState
> {
private _isUnmounted: boolean;
- constructor() {
- super();
+ constructor(props: EthWethConversionDialogProps) {
+ super(props);
this._isUnmounted = false;
this.state = {
shouldShowIncompleteErrs: false,
diff --git a/packages/website/ts/components/dialogs/send_dialog.tsx b/packages/website/ts/components/dialogs/send_dialog.tsx
index d44dd9aab..2af7fd7ac 100644
--- a/packages/website/ts/components/dialogs/send_dialog.tsx
+++ b/packages/website/ts/components/dialogs/send_dialog.tsx
@@ -27,8 +27,8 @@ interface SendDialogState {
}
export class SendDialog extends React.Component<SendDialogProps, SendDialogState> {
- constructor() {
- super();
+ constructor(props: SendDialogProps) {
+ super(props);
this.state = {
recipient: '',
shouldShowIncompleteErrs: false,
diff --git a/packages/website/ts/components/fill_order.tsx b/packages/website/ts/components/fill_order.tsx
index a6144bd6b..ea94e0987 100644
--- a/packages/website/ts/components/fill_order.tsx
+++ b/packages/website/ts/components/fill_order.tsx
@@ -198,11 +198,13 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
symbol: takerToken.symbol,
};
const parsedOrderExpiration = new BigNumber(this.state.parsedOrder.signedOrder.expirationUnixTimestampSec);
- const exchangeRate = orderMakerAmount.div(orderTakerAmount);
let orderReceiveAmount = 0;
if (!_.isUndefined(this.props.orderFillAmount)) {
- const orderReceiveAmountBigNumber = exchangeRate.mul(this.props.orderFillAmount);
+ const orderReceiveAmountBigNumber = orderMakerAmount
+ .times(this.props.orderFillAmount)
+ .dividedBy(orderTakerAmount)
+ .floor();
orderReceiveAmount = this._formatCurrencyAmount(orderReceiveAmountBigNumber, makerToken.decimals);
}
const isUserMaker =
diff --git a/packages/website/ts/components/footer.tsx b/packages/website/ts/components/footer.tsx
index 957ed2044..6c0186ac0 100644
--- a/packages/website/ts/components/footer.tsx
+++ b/packages/website/ts/components/footer.tsx
@@ -45,7 +45,7 @@ interface FooterState {
export class Footer extends React.Component<FooterProps, FooterState> {
constructor(props: FooterProps) {
- super();
+ super(props);
this.state = {
selectedLanguage: props.translate.getLanguage(),
};
diff --git a/packages/website/ts/containers/web3_wrapper_documentation.ts b/packages/website/ts/containers/web3_wrapper_documentation.ts
index 0a0911b80..289006f10 100644
--- a/packages/website/ts/containers/web3_wrapper_documentation.ts
+++ b/packages/website/ts/containers/web3_wrapper_documentation.ts
@@ -48,26 +48,25 @@ const docsInfoConfig: DocsInfoConfig = {
typeConfigs: {
// Note: This needs to be kept in sync with the types exported in index.ts. Unfortunately there is
// currently no way to extract the re-exported types from index.ts via TypeDoc :(
- publicTypes: ['TxData', 'TransactionReceipt', 'RawLogEntry'],
+ publicTypes: [
+ 'TxData',
+ 'TransactionReceipt',
+ 'RawLogEntry',
+ 'ContractAbi',
+ 'BlockParam',
+ 'FilterObject',
+ 'LogEntry',
+ 'BlockWithoutTransactionData',
+ 'CallData',
+ 'LogEntryEvent',
+ ],
typeNameToExternalLink: {
Web3: 'https://github.com/ethereum/wiki/wiki/JavaScript-API',
Provider: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L150',
- BigNumber: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L127',
- LogEntryEvent: 'http://mikemcl.github.io/bignumber.js',
- CallData: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L348',
- BlockWithoutTransactionData:
- 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L314',
- LogEntry: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L366',
- FilterObject: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L109',
- ['Web3.BlockParam']: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L278',
- ['Web3.ContractAbi']: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L47',
+ BigNumber: 'http://mikemcl.github.io/bignumber.js',
},
typeNameToPrefix: {
Provider: 'Web3',
- CallData: 'Web3',
- BlockWithoutTransactionData: 'Web3',
- LogEntry: 'Web3',
- FilterObject: 'Web3',
},
typeNameToDocSection: {
Web3Wrapper: docSections.web3Wrapper,
diff --git a/packages/website/ts/globals.d.ts b/packages/website/ts/globals.d.ts
index ef276519c..3791b3269 100644
--- a/packages/website/ts/globals.d.ts
+++ b/packages/website/ts/globals.d.ts
@@ -115,11 +115,11 @@ declare module 'web3-provider-engine/subproviders/subprovider' {
export = Subprovider;
}
declare module 'web3-provider-engine/subproviders/rpc' {
- import * as Web3 from 'web3';
+ import { JSONRPCRequestPayload } from '@0xproject/types';
class RpcSubprovider {
constructor(options: { rpcUrl: string });
public handleRequest(
- payload: Web3.JSONRPCRequestPayload,
+ payload: JSONRPCRequestPayload,
next: () => void,
end: (err: Error | null, data?: any) => void,
): void;
diff --git a/packages/website/ts/types.ts b/packages/website/ts/types.ts
index 104d2e50f..901483327 100644
--- a/packages/website/ts/types.ts
+++ b/packages/website/ts/types.ts
@@ -223,6 +223,7 @@ export enum AlertTypes {
export enum BlockchainErrs {
AContractNotDeployedOnNetwork = 'A_CONTRACT_NOT_DEPLOYED_ON_NETWORK',
DisconnectedFromEthereumNode = 'DISCONNECTED_FROM_ETHEREUM_NODE',
+ DefaultTokensNotInTokenRegistry = 'DEFAULT_TOKENS_NOT_IN_TOKEN_REGISTRY',
NoError = 'NO_ERROR',
}
diff --git a/packages/website/ts/utils/configs.ts b/packages/website/ts/utils/configs.ts
index 597e9689a..a54fc56a8 100644
--- a/packages/website/ts/utils/configs.ts
+++ b/packages/website/ts/utils/configs.ts
@@ -65,12 +65,6 @@ export const configs = {
GOOGLE_ANALYTICS_ID: 'UA-98720122-1',
LAST_LOCAL_STORAGE_FILL_CLEARANCE_DATE: '2017-11-22',
LAST_LOCAL_STORAGE_TRACKED_TOKEN_CLEARANCE_DATE: '2017-12-19',
- // NEW_WRAPPED_ETHERS is temporary until we remove the SHOULD_DEPRECATE_OLD_WETH_TOKEN flag
- // and add the new WETHs to the tokenRegistry
- NEW_WRAPPED_ETHERS: {
- 1: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
- 42: '0xd0a1e359811322d97991e03f863a0c30c2cf029c',
- } as { [networkId: string]: string },
OUTDATED_WRAPPED_ETHERS: [
{
42: {
@@ -96,7 +90,6 @@ export const configs = {
[3]: [`https://ropsten.infura.io/${INFURA_API_KEY}`],
[4]: [`https://rinkeby.infura.io/${INFURA_API_KEY}`],
} as PublicNodeUrlsByNetworkId,
- SHOULD_DEPRECATE_OLD_WETH_TOKEN: true,
SYMBOLS_OF_MINTABLE_KOVAN_TOKENS: ['MKR', 'MLN', 'GNT', 'DGD', 'REP'],
SYMBOLS_OF_MINTABLE_RINKEBY_ROPSTEN_TOKENS: [
'TKN0',
diff --git a/packages/website/ts/utils/utils.ts b/packages/website/ts/utils/utils.ts
index 25d7e449b..75597a7e2 100644
--- a/packages/website/ts/utils/utils.ts
+++ b/packages/website/ts/utils/utils.ts
@@ -219,7 +219,8 @@ export const utils = {
[ExchangeContractErrs.OrderFillAmountZero]: "Order fill amount can't be 0",
[ExchangeContractErrs.OrderRemainingFillAmountZero]:
'This order has already been completely filled or cancelled',
- [ExchangeContractErrs.OrderFillRoundingError]: 'Rounding error will occur when filling this order',
+ [ExchangeContractErrs.OrderFillRoundingError]:
+ 'Rounding error will occur when filling this order. Please try filling a different amount.',
[ExchangeContractErrs.InsufficientTakerBalance]:
'Taker no longer has a sufficient balance to complete this order',
[ExchangeContractErrs.InsufficientTakerAllowance]:
diff --git a/packages/website/tsconfig.json b/packages/website/tsconfig.json
index 99f465bc2..34171b51e 100644
--- a/packages/website/tsconfig.json
+++ b/packages/website/tsconfig.json
@@ -13,9 +13,5 @@
"*": ["node_modules/@types/*", "*"]
}
},
- "include": [
- "./ts/**/*",
- "../../node_modules/web3-typescript-typings/index.d.ts",
- "../../node_modules/ethers-typescript-typings/index.d.ts"
- ]
+ "include": ["./ts/**/*"]
}