diff options
author | Fabio Berger <me@fabioberger.com> | 2018-06-02 04:05:17 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-06-02 04:05:17 +0800 |
commit | b7b45b69a66cfaf9c3737d1a8d95be21edccf527 (patch) | |
tree | 4337613836a8062bd73fc8ee1e4db444961df172 | |
parent | df9cfe7840b99d72ed95058e47f2ffb6623d440e (diff) | |
parent | 9ca41b9536908dddfa51854abd41b7926e69bd09 (diff) | |
download | dexon-sol-tools-b7b45b69a66cfaf9c3737d1a8d95be21edccf527.tar.gz dexon-sol-tools-b7b45b69a66cfaf9c3737d1a8d95be21edccf527.tar.zst dexon-sol-tools-b7b45b69a66cfaf9c3737d1a8d95be21edccf527.zip |
Merge branch 'v2-prototype' into refactor/order-utils/for-v2
* v2-prototype: (33 commits)
Only show ProviderDisplay in portal
Improve sol-cov docs
Remove old parse code
Refactor order parser and add shared order support to new portal
Add generate and fill order routes
Address feedback
Override ethereumjs-tx version
Fix missing key
Update placeholder param ordering
Change userEtherBalanceInWei to optional so we can know if its loading
Add loading state to ProviderDisplay
Tweaks
Add Placeholder component
Add StandardIconRow
Split render into loading and loaaded
Fix linter errors
Fix linter errors
Add ethereum-types to extraFileIncludes
Introduce ethereum-types package
Remove merge conflicts from yarn.lock
...
# Conflicts:
# packages/contracts/src/utils/exchange_wrapper.ts
# packages/contracts/src/utils/match_order_tester.ts
# packages/contracts/src/utils/types.ts
# packages/contracts/test/exchange/core.ts
# packages/contracts/test/exchange/match_orders.ts
# packages/contracts/test/libraries/lib_bytes.ts
# packages/sol-cov/package.json
130 files changed, 1223 insertions, 1126 deletions
diff --git a/.circleci/config.yml b/.circleci/config.yml index ab42ade09..c544bb484 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,7 +3,7 @@ version: 2 jobs: build: docker: - - image: circleci/node:6.12 + - image: circleci/node:9 environment: CONTRACTS_COMMIT_HASH: '9ed05f5' working_directory: ~/repo @@ -11,91 +11,68 @@ jobs: - checkout - run: echo 'export PATH=$HOME/CIRCLE_PROJECT_REPONAME/node_modules/.bin:$PATH' >> $BASH_ENV - restore_cache: - key: dependency-cache-{{ checksum "package.json" }} + name: Restore Yarn Package Cache + keys: + - yarn-packages-{{ .Branch }}-{{ checksum "yarn.lock" }} + - yarn-packages-{{ .Branch }} + - yarn-packages-master + - yarn-packages- - run: name: yarn - command: yarn --frozen-lockfile + command: yarn --frozen-lockfile install - save_cache: - key: dependency-cache-{{ checksum "package.json" }} + name: Save Yarn Package Cache + key: yarn-packages-{{ .Branch }}-{{ checksum "yarn.lock" }} paths: - - ./node_modules - - run: wget https://s3.amazonaws.com/testrpc-shapshots/${CONTRACTS_COMMIT_HASH}.zip - - run: unzip ${CONTRACTS_COMMIT_HASH}.zip -d testrpc_snapshot + - node_modules/ - run: node ./node_modules/lerna/bin/lerna.js bootstrap - run: yarn build - save_cache: key: repo-{{ .Environment.CIRCLE_SHA1 }} paths: - ~/repo - test-installation: - docker: - - image: circleci/node:6.12 - working_directory: ~/repo - steps: - - restore_cache: - keys: - - repo-{{ .Environment.CIRCLE_SHA1 }} - - run: yarn test:installation - test-0xjs: + test-1: docker: - - image: circleci/node:6.12 + - image: circleci/node:9 working_directory: ~/repo steps: - restore_cache: keys: - repo-{{ .Environment.CIRCLE_SHA1 }} - - run: - name: testrpc - command: npm run testrpc -- --db testrpc_snapshot - background: true - - run: yarn wsrun test:circleci 0x.js + - run: yarn wsrun test:circleci @0xproject/contract-wrappers + - run: yarn wsrun test:circleci @0xproject/sol-compiler - save_cache: - key: coverage-0xjs-{{ .Environment.CIRCLE_SHA1 }} + key: coverage-contract-wrappers-{{ .Environment.CIRCLE_SHA1 }} + paths: + - ~/repo/packages/contract-wrappers/coverage/lcov.info + - save_cache: + key: coverage-sol-compiler-{{ .Environment.CIRCLE_SHA1 }} paths: - - ~/repo/packages/0x.js/coverage/lcov.info + - ~/repo/packages/sol-compiler/coverage/lcov.info test-contracts: docker: - - image: circleci/node:6.12 + - image: circleci/node:9 working_directory: ~/repo steps: - restore_cache: keys: - repo-{{ .Environment.CIRCLE_SHA1 }} - - run: - name: testrpc - command: npm run testrpc -- --db testrpc_snapshot - background: true - run: yarn wsrun test:circleci contracts - test-sol-compiler: + test-2: docker: - - image: circleci/node:6.12 + - image: circleci/node:9 working_directory: ~/repo steps: - restore_cache: keys: - repo-{{ .Environment.CIRCLE_SHA1 }} - - run: - name: testrpc - command: npm run testrpc -- --db testrpc_snapshot - background: true - - run: yarn wsrun test:circleci @0xproject/sol-compiler - - save_cache: - key: coverage-sol-compiler-{{ .Environment.CIRCLE_SHA1 }} - paths: - - ~/repo/packages/sol-compiler/coverage/lcov.info - test-rest: - docker: - - image: circleci/node:6.12 - working_directory: ~/repo - steps: - - restore_cache: - keys: - - repo-{{ .Environment.CIRCLE_SHA1 }} - - run: - name: testrpc - command: npm run testrpc -- --db testrpc_snapshot - background: true - - run: yarn wsrun test:circleci --exclude contracts --exclude 0x.js --exclude @0xproject/sol-compiler --stages --exclude-missing + - run: yarn wsrun test:circleci @0xproject/assert + - run: yarn wsrun test:circleci @0xproject/connect + - run: yarn wsrun test:circleci @0xproject/dev-utils + - run: yarn wsrun test:circleci @0xproject/json-schemas + - run: yarn wsrun test:circleci @0xproject/subproviders + - run: yarn wsrun test:circleci @0xproject/sol-cov + - run: yarn wsrun test:circleci @0xproject/metacoin - save_cache: key: coverage-assert-{{ .Environment.CIRCLE_SHA1 }} paths: @@ -124,27 +101,19 @@ jobs: key: coverage-metacoin-{{ .Environment.CIRCLE_SHA1 }} paths: - ~/repo/packages/metacoin/coverage/lcov.info - lint: - working_directory: ~/repo - docker: - - image: circleci/node:6.12 - steps: - - restore_cache: - keys: - - repo-{{ .Environment.CIRCLE_SHA1 }} - - run: yarn lerna:run lint - prettier: + static-tests: working_directory: ~/repo docker: - - image: circleci/node:6.12 + - image: circleci/node:9 steps: - restore_cache: keys: - repo-{{ .Environment.CIRCLE_SHA1 }} - run: yarn prettier:ci + - run: yarn lerna:run lint submit-coverage: docker: - - image: circleci/node:6.12 + - image: circleci/node:9 working_directory: ~/repo steps: - restore_cache: @@ -158,6 +127,9 @@ jobs: - coverage-connect-{{ .Environment.CIRCLE_SHA1 }} - restore_cache: keys: + - coverage-contract-wrappers-{{ .Environment.CIRCLE_SHA1 }} + - restore_cache: + keys: - coverage-dev-utils-{{ .Environment.CIRCLE_SHA1 }} - restore_cache: keys: @@ -170,6 +142,9 @@ jobs: - coverage-sol-cov-{{ .Environment.CIRCLE_SHA1 }} - restore_cache: keys: + - coverage-contracts-{{ .Environment.CIRCLE_SHA1 }} + - restore_cache: + keys: - coverage-sol-compiler-{{ .Environment.CIRCLE_SHA1 }} - restore_cache: keys: @@ -183,29 +158,19 @@ workflows: main: jobs: - build - # - test-installation: - # requires: - # - build - - test-0xjs: + - test-1: requires: - build - - test-contracts: + - test-2: requires: - build - - test-sol-compiler: - requires: - - build - - test-rest: - requires: - - build - - prettier: + - test-contracts: requires: - build - - lint: + - static-tests: requires: - build - submit-coverage: requires: - - test-0xjs - - test-sol-compiler - - test-rest + - test-1 + - test-2 diff --git a/package.json b/package.json index f1b3b98fa..cdbc7a385 100644 --- a/package.json +++ b/package.json @@ -35,10 +35,13 @@ "async-child-process": "^1.1.1", "coveralls": "^3.0.0", "ganache-cli": "^6.1.0", - "lcov-result-merger": "^2.0.0", + "lcov-result-merger": "^3.0.0", "lerna": "^2.5.1", "npm-run-all": "^4.1.2", "prettier": "^1.11.1", "wsrun": "^2.2.0" + }, + "resolutions": { + "ethereumjs-tx": "0xProject/ethereumjs-tx#fake-tx-include-signature-by-default" } } diff --git a/packages/0x.js/package.json b/packages/0x.js/package.json index 9efb1c972..1324a73d1 100644 --- a/packages/0x.js/package.json +++ b/packages/0x.js/package.json @@ -44,6 +44,7 @@ "docPublishConfigs": { "extraFileIncludes": [ "../types/src/index.ts", + "../ethereum-types/src/index.ts", "../contract-wrappers/src/types.ts", "../contract-wrappers/src/contract_wrappers/ether_token_wrapper.ts", "../contract-wrappers/src/contract_wrappers/exchange_wrapper.ts", @@ -108,6 +109,7 @@ "@0xproject/typescript-typings": "^0.3.2", "@0xproject/utils": "^0.6.2", "@0xproject/web3-wrapper": "^0.6.4", + "ethereum-types": "^0.0.1", "ethers": "^3.0.15", "lodash": "^4.17.4" }, diff --git a/packages/abi-gen/package.json b/packages/abi-gen/package.json index d3af33fdf..e02b930ed 100644 --- a/packages/abi-gen/package.json +++ b/packages/abi-gen/package.json @@ -27,9 +27,9 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/abi-gen/README.md", "dependencies": { - "@0xproject/types": "^0.7.0", "@0xproject/typescript-typings": "^0.3.2", "@0xproject/utils": "^0.6.2", + "ethereum-types": "^0.0.1", "chalk": "^2.3.0", "glob": "^7.1.2", "handlebars": "^4.0.11", diff --git a/packages/abi-gen/src/index.ts b/packages/abi-gen/src/index.ts index ef5710f53..b7e6722ea 100644 --- a/packages/abi-gen/src/index.ts +++ b/packages/abi-gen/src/index.ts @@ -1,8 +1,8 @@ #!/usr/bin/env node -import { AbiDefinition, ConstructorAbi, EventAbi, MethodAbi } from '@0xproject/types'; import { abiUtils, logUtils } from '@0xproject/utils'; import chalk from 'chalk'; +import { AbiDefinition, ConstructorAbi, EventAbi, MethodAbi } from 'ethereum-types'; import * as fs from 'fs'; import { sync as globSync } from 'glob'; import * as Handlebars from 'handlebars'; diff --git a/packages/abi-gen/src/types.ts b/packages/abi-gen/src/types.ts index 648281774..68765b04d 100644 --- a/packages/abi-gen/src/types.ts +++ b/packages/abi-gen/src/types.ts @@ -1,4 +1,4 @@ -import { EventAbi, MethodAbi } from '@0xproject/types'; +import { EventAbi, MethodAbi } from 'ethereum-types'; export enum ParamKind { Input = 'input', diff --git a/packages/abi-gen/src/utils.ts b/packages/abi-gen/src/utils.ts index 20b734959..a46209dad 100644 --- a/packages/abi-gen/src/utils.ts +++ b/packages/abi-gen/src/utils.ts @@ -1,4 +1,4 @@ -import { AbiType, ConstructorAbi, DataItem } from '@0xproject/types'; +import { AbiType, ConstructorAbi, DataItem } from 'ethereum-types'; import * as fs from 'fs'; import * as _ from 'lodash'; import * as path from 'path'; diff --git a/packages/base-contract/package.json b/packages/base-contract/package.json index f79d3ebf6..c01a133e4 100644 --- a/packages/base-contract/package.json +++ b/packages/base-contract/package.json @@ -42,7 +42,7 @@ "typescript": "2.7.1" }, "dependencies": { - "@0xproject/types": "^0.7.0", + "ethereum-types": "^0.0.1", "@0xproject/typescript-typings": "^0.3.2", "@0xproject/utils": "^0.6.2", "@0xproject/web3-wrapper": "^0.6.4", diff --git a/packages/base-contract/src/index.ts b/packages/base-contract/src/index.ts index f9298f413..d9e28f9f2 100644 --- a/packages/base-contract/src/index.ts +++ b/packages/base-contract/src/index.ts @@ -1,3 +1,5 @@ +import { abiUtils, BigNumber } from '@0xproject/utils'; +import { Web3Wrapper } from '@0xproject/web3-wrapper'; import { AbiDefinition, AbiType, @@ -8,9 +10,7 @@ import { Provider, TxData, TxDataPayable, -} from '@0xproject/types'; -import { abiUtils, BigNumber } from '@0xproject/utils'; -import { Web3Wrapper } from '@0xproject/web3-wrapper'; +} from 'ethereum-types'; import * as ethers from 'ethers'; import * as _ from 'lodash'; diff --git a/packages/base-contract/src/utils.ts b/packages/base-contract/src/utils.ts index 4b86bb1ad..61f176df5 100644 --- a/packages/base-contract/src/utils.ts +++ b/packages/base-contract/src/utils.ts @@ -1,4 +1,4 @@ -import { DataItem } from '@0xproject/types'; +import { DataItem } from 'ethereum-types'; import * as _ from 'lodash'; // tslint:disable-next-line:completed-docs diff --git a/packages/contract-wrappers/package.json b/packages/contract-wrappers/package.json index b28d04685..61e92903f 100644 --- a/packages/contract-wrappers/package.json +++ b/packages/contract-wrappers/package.json @@ -85,6 +85,7 @@ "@0xproject/typescript-typings": "^0.3.2", "@0xproject/utils": "^0.6.2", "@0xproject/web3-wrapper": "^0.6.4", + "ethereum-types": "^0.0.1", "ethereumjs-blockstream": "^2.0.6", "ethereumjs-util": "^5.1.1", "ethers": "^3.0.15", diff --git a/packages/contract_templates/contract.handlebars b/packages/contract_templates/contract.handlebars index b2765b1a5..5fb19af11 100644 --- a/packages/contract_templates/contract.handlebars +++ b/packages/contract_templates/contract.handlebars @@ -2,11 +2,11 @@ * This file is auto-generated using abi-gen. Don't edit directly. * Templates can be found at https://github.com/0xProject/0x-monorepo/tree/development/packages/contract_templates. */ -// tslint:disable:no-consecutive-blank-lines +// tslint:disable:no-consecutive-blank-lines ordered-imports // tslint:disable-next-line:no-unused-variable import { BaseContract } from '@0xproject/base-contract'; import { ContractArtifact } from '@0xproject/sol-compiler'; -import { BlockParam, BlockParamLiteral, CallData, ContractAbi, DataItem, MethodAbi, Provider, TxData, TxDataPayable } from '@0xproject/types'; +import { BlockParam, BlockParamLiteral, CallData, ContractAbi, DataItem, DecodedLogArgs, MethodAbi, Provider, TxData, TxDataPayable } from 'ethereum-types'; import { BigNumber, classUtils, logUtils, promisify } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import * as ethers from 'ethers'; diff --git a/packages/contract_templates/partials/event.handlebars b/packages/contract_templates/partials/event.handlebars index 3c6100e4f..69a99d937 100644 --- a/packages/contract_templates/partials/event.handlebars +++ b/packages/contract_templates/partials/event.handlebars @@ -1,4 +1,4 @@ -export interface {{name}}ContractEventArgs { +export interface {{name}}ContractEventArgs extends DecodedLogArgs { {{#each inputs}} {{name}}: {{#returnType type components}}{{/returnType}}; {{/each}} diff --git a/packages/contracts/package.json b/packages/contracts/package.json index 8d29366a4..8b2945861 100644 --- a/packages/contracts/package.json +++ b/packages/contracts/package.json @@ -48,7 +48,9 @@ "@0xproject/subproviders": "^0.10.1", "@0xproject/sol-cov": "^0.0.11", "@types/lodash": "4.14.104", + "@types/bn.js": "^4.11.0", "@types/node": "^8.0.53", + "@types/ethereumjs-abi": "^0.6.0", "@types/yargs": "^10.0.0", "chai": "^4.0.1", "chai-as-promised": "^7.1.0", @@ -73,6 +75,7 @@ "@0xproject/typescript-typings": "^0.3.2", "@0xproject/utils": "^0.6.2", "@0xproject/web3-wrapper": "^0.6.4", + "ethereum-types": "^0.0.1", "bn.js": "^4.11.8", "ethereumjs-abi": "^0.6.4", "ethereumjs-util": "^5.1.1", diff --git a/packages/contracts/src/utils/erc20_wrapper.ts b/packages/contracts/src/utils/erc20_wrapper.ts index 92cf01cc2..0f45fb1e6 100644 --- a/packages/contracts/src/utils/erc20_wrapper.ts +++ b/packages/contracts/src/utils/erc20_wrapper.ts @@ -1,6 +1,6 @@ -import { Provider } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; +import { Provider } from 'ethereum-types'; import * as _ from 'lodash'; import { DummyERC20TokenContract } from '../contract_wrappers/generated/dummy_e_r_c20_token'; diff --git a/packages/contracts/src/utils/erc721_wrapper.ts b/packages/contracts/src/utils/erc721_wrapper.ts index bea801f3d..11a012602 100644 --- a/packages/contracts/src/utils/erc721_wrapper.ts +++ b/packages/contracts/src/utils/erc721_wrapper.ts @@ -1,7 +1,7 @@ import { generatePseudoRandomSalt } from '@0xproject/order-utils'; -import { Provider } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; +import { Provider } from 'ethereum-types'; import * as _ from 'lodash'; import { DummyERC721TokenContract } from '../contract_wrappers/generated/dummy_e_r_c721_token'; diff --git a/packages/contracts/src/utils/exchange_wrapper.ts b/packages/contracts/src/utils/exchange_wrapper.ts index 8f5915d97..dd278e77c 100644 --- a/packages/contracts/src/utils/exchange_wrapper.ts +++ b/packages/contracts/src/utils/exchange_wrapper.ts @@ -1,6 +1,7 @@ -import { AssetProxyId, Provider, SignedOrder, TransactionReceiptWithDecodedLogs } from '@0xproject/types'; +import { AssetProxyId, SignedOrder } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; +import { LogEntry, Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types'; import * as _ from 'lodash'; import { ExchangeContract } from '../contract_wrappers/generated/exchange'; diff --git a/packages/contracts/src/utils/log_decoder.ts b/packages/contracts/src/utils/log_decoder.ts index 32819b657..07d10e69d 100644 --- a/packages/contracts/src/utils/log_decoder.ts +++ b/packages/contracts/src/utils/log_decoder.ts @@ -1,13 +1,14 @@ import { ContractArtifact } from '@0xproject/sol-compiler'; +import { AbiDecoder, BigNumber } from '@0xproject/utils'; +import { Web3Wrapper } from '@0xproject/web3-wrapper'; import { AbiDefinition, + DecodedLogArgs, LogEntry, LogWithDecodedArgs, RawLog, TransactionReceiptWithDecodedLogs, -} from '@0xproject/types'; -import { AbiDecoder, BigNumber } from '@0xproject/utils'; -import { Web3Wrapper } from '@0xproject/web3-wrapper'; +} from 'ethereum-types'; import * as _ from 'lodash'; import { artifacts } from './artifacts'; @@ -36,7 +37,7 @@ export class LogDecoder { }); this._abiDecoder = new AbiDecoder(abiArrays); } - public decodeLogOrThrow<ArgsType>(log: LogEntry): LogWithDecodedArgs<ArgsType> | RawLog { + public decodeLogOrThrow<ArgsType extends DecodedLogArgs>(log: LogEntry): LogWithDecodedArgs<ArgsType> | RawLog { const logWithDecodedArgsOrLog = this._abiDecoder.tryToDecodeLogOrNoop(log); if (_.isUndefined((logWithDecodedArgsOrLog as LogWithDecodedArgs<ArgsType>).args)) { throw new Error(`Unable to decode log: ${JSON.stringify(log)}`); diff --git a/packages/contracts/src/utils/match_order_tester.ts b/packages/contracts/src/utils/match_order_tester.ts index 85348b14d..09c0d8083 100644 --- a/packages/contracts/src/utils/match_order_tester.ts +++ b/packages/contracts/src/utils/match_order_tester.ts @@ -1,8 +1,9 @@ import { BlockchainLifecycle } from '@0xproject/dev-utils'; import { assetProxyUtils, crypto, orderHashUtils } from '@0xproject/order-utils'; -import { AssetProxyId, LogWithDecodedArgs, SignedOrder } from '@0xproject/types'; +import { AssetProxyId, SignedOrder } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import * as chai from 'chai'; +import { LogWithDecodedArgs } from 'ethereum-types'; import ethUtil = require('ethereumjs-util'); import * as _ from 'lodash'; diff --git a/packages/contracts/src/utils/multi_sig_wrapper.ts b/packages/contracts/src/utils/multi_sig_wrapper.ts index d67692194..9971e8f6e 100644 --- a/packages/contracts/src/utils/multi_sig_wrapper.ts +++ b/packages/contracts/src/utils/multi_sig_wrapper.ts @@ -1,6 +1,6 @@ -import { Provider, TransactionReceiptWithDecodedLogs } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; +import { Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types'; import * as _ from 'lodash'; import { AssetProxyOwnerContract } from '../contract_wrappers/generated/asset_proxy_owner'; diff --git a/packages/contracts/src/utils/token_registry_wrapper.ts b/packages/contracts/src/utils/token_registry_wrapper.ts index 86daeca62..240c06fdc 100644 --- a/packages/contracts/src/utils/token_registry_wrapper.ts +++ b/packages/contracts/src/utils/token_registry_wrapper.ts @@ -1,16 +1,21 @@ -import * as Web3 from 'web3'; +import { Web3Wrapper } from '@0xproject/web3-wrapper'; +import { Provider } from 'ethereum-types'; import { TokenRegistryContract } from '../contract_wrappers/generated/token_registry'; import { Token } from './types'; +import { constants } from './constants'; + export class TokenRegWrapper { private _tokenReg: TokenRegistryContract; - constructor(tokenRegContract: TokenRegistryContract) { + private _web3Wrapper: Web3Wrapper; + constructor(tokenRegContract: TokenRegistryContract, provider: Provider) { this._tokenReg = tokenRegContract; + this._web3Wrapper = new Web3Wrapper(provider); } public async addTokenAsync(token: Token, from: string): Promise<string> { - const tx = this._tokenReg.addToken.sendTransactionAsync( + const txHash = await this._tokenReg.addToken.sendTransactionAsync( token.address as string, token.name, token.symbol, @@ -19,7 +24,8 @@ export class TokenRegWrapper { token.swarmHash, { from }, ); - return tx; + await this._web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS); + return txHash; } public async getTokenMetaDataAsync(tokenAddress: string): Promise<Token> { const data = await this._tokenReg.getTokenMetaData.callAsync(tokenAddress); diff --git a/packages/contracts/src/utils/types.ts b/packages/contracts/src/utils/types.ts index a6c90dae0..6340c4a51 100644 --- a/packages/contracts/src/utils/types.ts +++ b/packages/contracts/src/utils/types.ts @@ -1,5 +1,6 @@ -import { AbiDefinition, ContractAbi, Order, OrderWithoutExchangeAddress } from '@0xproject/types'; +import { Order, OrderWithoutExchangeAddress } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; +import { AbiDefinition, ContractAbi } from 'ethereum-types'; export interface ERC20BalancesByOwner { [ownerAddress: string]: { diff --git a/packages/contracts/src/utils/web3_wrapper.ts b/packages/contracts/src/utils/web3_wrapper.ts index 4b8512222..1049ab967 100644 --- a/packages/contracts/src/utils/web3_wrapper.ts +++ b/packages/contracts/src/utils/web3_wrapper.ts @@ -1,7 +1,7 @@ import { devConstants, env, EnvVars, web3Factory } from '@0xproject/dev-utils'; import { prependSubprovider } from '@0xproject/subproviders'; -import { Provider } from '@0xproject/types'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; +import { Provider } from 'ethereum-types'; import { coverage } from './coverage'; diff --git a/packages/contracts/test/asset_proxy_owner.ts b/packages/contracts/test/asset_proxy_owner.ts index 43c5da512..4c16b5cff 100644 --- a/packages/contracts/test/asset_proxy_owner.ts +++ b/packages/contracts/test/asset_proxy_owner.ts @@ -1,7 +1,7 @@ import { BlockchainLifecycle } from '@0xproject/dev-utils'; -import { LogWithDecodedArgs } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import * as chai from 'chai'; +import { LogWithDecodedArgs } from 'ethereum-types'; import * as _ from 'lodash'; import 'make-promises-safe'; import * as Web3 from 'web3'; @@ -66,8 +66,14 @@ describe('AssetProxyOwner', () => { SECONDS_TIME_LOCKED, ); multiSigWrapper = new MultiSigWrapper(multiSig, provider); - await erc20Proxy.transferOwnership.sendTransactionAsync(multiSig.address, { from: initialOwner }); - await erc721Proxy.transferOwnership.sendTransactionAsync(multiSig.address, { from: initialOwner }); + await web3Wrapper.awaitTransactionSuccessAsync( + await erc20Proxy.transferOwnership.sendTransactionAsync(multiSig.address, { from: initialOwner }), + constants.AWAIT_TRANSACTION_MINED_MS, + ); + await web3Wrapper.awaitTransactionSuccessAsync( + await erc721Proxy.transferOwnership.sendTransactionAsync(multiSig.address, { from: initialOwner }), + constants.AWAIT_TRANSACTION_MINED_MS, + ); }); beforeEach(async () => { await blockchainLifecycle.startAsync(); diff --git a/packages/contracts/test/ether_token.ts b/packages/contracts/test/ether_token.ts index 10dd635fe..4e52b658f 100644 --- a/packages/contracts/test/ether_token.ts +++ b/packages/contracts/test/ether_token.ts @@ -83,7 +83,10 @@ describe('EtherToken', () => { it('should convert ether tokens to ether with sufficient balance', async () => { const ethToDeposit = new BigNumber(Web3Wrapper.toWei(new BigNumber(1))); - await etherToken.deposit.sendTransactionAsync({ value: ethToDeposit }); + await web3Wrapper.awaitTransactionSuccessAsync( + await etherToken.deposit.sendTransactionAsync({ value: ethToDeposit }), + constants.AWAIT_TRANSACTION_MINED_MS, + ); const initEthTokenBalance = await etherToken.balanceOf.callAsync(account); const initEthBalance = await web3Wrapper.getBalanceInWeiAsync(account); const ethTokensToWithdraw = initEthTokenBalance; diff --git a/packages/contracts/test/exchange/core.ts b/packages/contracts/test/exchange/core.ts index adc57c7a4..8320e97d6 100644 --- a/packages/contracts/test/exchange/core.ts +++ b/packages/contracts/test/exchange/core.ts @@ -1,9 +1,10 @@ import { BlockchainLifecycle } from '@0xproject/dev-utils'; import { assetProxyUtils, crypto, orderHashUtils } from '@0xproject/order-utils'; -import { AssetProxyId, LogWithDecodedArgs, SignedOrder } from '@0xproject/types'; +import { AssetProxyId, SignedOrder } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import * as chai from 'chai'; +import { LogWithDecodedArgs } from 'ethereum-types'; import ethUtil = require('ethereumjs-util'); import 'make-promises-safe'; diff --git a/packages/contracts/test/exchange/match_orders.ts b/packages/contracts/test/exchange/match_orders.ts index 67281a915..07295d78a 100644 --- a/packages/contracts/test/exchange/match_orders.ts +++ b/packages/contracts/test/exchange/match_orders.ts @@ -1,9 +1,10 @@ import { BlockchainLifecycle } from '@0xproject/dev-utils'; import { assetProxyUtils, crypto } from '@0xproject/order-utils'; -import { AssetProxyId, LogWithDecodedArgs, SignedOrder } from '@0xproject/types'; +import { AssetProxyId, SignedOrder } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import * as chai from 'chai'; +import { LogWithDecodedArgs } from 'ethereum-types'; import ethUtil = require('ethereumjs-util'); import * as _ from 'lodash'; diff --git a/packages/contracts/test/libraries/lib_bytes.ts b/packages/contracts/test/libraries/lib_bytes.ts index 32b319e56..26cfa8291 100644 --- a/packages/contracts/test/libraries/lib_bytes.ts +++ b/packages/contracts/test/libraries/lib_bytes.ts @@ -1,9 +1,10 @@ import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils'; -import { AssetProxyId, LogWithDecodedArgs, TransactionReceiptWithDecodedLogs } from '@0xproject/types'; +import { AssetProxyId } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import BN = require('bn.js'); import * as chai from 'chai'; +import { LogWithDecodedArgs, TransactionReceiptWithDecodedLogs } from 'ethereum-types'; import ethUtil = require('ethereumjs-util'); import * as Web3 from 'web3'; diff --git a/packages/contracts/test/multi_sig_with_time_lock.ts b/packages/contracts/test/multi_sig_with_time_lock.ts index 7b7885a00..1302d0fa0 100644 --- a/packages/contracts/test/multi_sig_with_time_lock.ts +++ b/packages/contracts/test/multi_sig_with_time_lock.ts @@ -1,8 +1,8 @@ import { BlockchainLifecycle, web3Factory } from '@0xproject/dev-utils'; -import { LogWithDecodedArgs } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import * as chai from 'chai'; +import { LogWithDecodedArgs } from 'ethereum-types'; import * as _ from 'lodash'; import 'make-promises-safe'; import * as Web3 from 'web3'; diff --git a/packages/contracts/test/token_registry.ts b/packages/contracts/test/token_registry.ts index 7980977c8..64caac387 100644 --- a/packages/contracts/test/token_registry.ts +++ b/packages/contracts/test/token_registry.ts @@ -35,7 +35,7 @@ describe('TokenRegistry', () => { owner = accounts[0]; notOwner = accounts[1]; tokenReg = await TokenRegistryContract.deployFrom0xArtifactAsync(artifacts.TokenRegistry, provider, txDefaults); - tokenRegWrapper = new TokenRegWrapper(tokenReg); + tokenRegWrapper = new TokenRegWrapper(tokenReg, provider); }); beforeEach(async () => { await blockchainLifecycle.startAsync(); diff --git a/packages/contracts/test/tutorials/arbitrage.ts b/packages/contracts/test/tutorials/arbitrage.ts index e5787d5b8..df01f31bb 100644 --- a/packages/contracts/test/tutorials/arbitrage.ts +++ b/packages/contracts/test/tutorials/arbitrage.ts @@ -1,6 +1,6 @@ // import { ECSignature, SignedOrder, ZeroEx } from '0x.js'; // import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils'; -// import { ExchangeContractErrs } from '@0xproject/types'; +// import { ExchangeContractErrs } from 'ethereum-types'; // import { BigNumber } from '@0xproject/utils'; // import { Web3Wrapper } from '@0xproject/web3-wrapper'; // import * as chai from 'chai'; diff --git a/packages/contracts/test/unlimited_allowance_token.ts b/packages/contracts/test/unlimited_allowance_token.ts index c68d8bdcf..b2acdebaa 100644 --- a/packages/contracts/test/unlimited_allowance_token.ts +++ b/packages/contracts/test/unlimited_allowance_token.ts @@ -64,7 +64,10 @@ describe('UnlimitedAllowanceToken', () => { const receiver = spender; const initOwnerBalance = await token.balanceOf.callAsync(owner); const amountToTransfer = new BigNumber(1); - await token.transfer.sendTransactionAsync(receiver, amountToTransfer, { from: owner }); + await web3Wrapper.awaitTransactionSuccessAsync( + await token.transfer.sendTransactionAsync(receiver, amountToTransfer, { from: owner }), + constants.AWAIT_TRANSACTION_MINED_MS, + ); const finalOwnerBalance = await token.balanceOf.callAsync(owner); const finalReceiverBalance = await token.balanceOf.callAsync(receiver); @@ -86,7 +89,10 @@ describe('UnlimitedAllowanceToken', () => { it('should throw if owner has insufficient balance', async () => { const ownerBalance = await token.balanceOf.callAsync(owner); const amountToTransfer = ownerBalance.plus(1); - await token.approve.sendTransactionAsync(spender, amountToTransfer, { from: owner }); + await web3Wrapper.awaitTransactionSuccessAsync( + await token.approve.sendTransactionAsync(spender, amountToTransfer, { from: owner }), + constants.AWAIT_TRANSACTION_MINED_MS, + ); return expect( token.transferFrom.callAsync(owner, spender, amountToTransfer, { from: spender, @@ -121,11 +127,17 @@ describe('UnlimitedAllowanceToken', () => { const initOwnerBalance = await token.balanceOf.callAsync(owner); const amountToTransfer = initOwnerBalance; const initSpenderAllowance = constants.UNLIMITED_ALLOWANCE_IN_BASE_UNITS; - await token.approve.sendTransactionAsync(spender, initSpenderAllowance, { from: owner }); - await token.transferFrom.sendTransactionAsync(owner, spender, amountToTransfer, { - from: spender, - gas: constants.MAX_TOKEN_TRANSFERFROM_GAS, - }); + await web3Wrapper.awaitTransactionSuccessAsync( + await token.approve.sendTransactionAsync(spender, initSpenderAllowance, { from: owner }), + constants.AWAIT_TRANSACTION_MINED_MS, + ); + await web3Wrapper.awaitTransactionSuccessAsync( + await token.transferFrom.sendTransactionAsync(owner, spender, amountToTransfer, { + from: spender, + gas: constants.MAX_TOKEN_TRANSFERFROM_GAS, + }), + constants.AWAIT_TRANSACTION_MINED_MS, + ); const newSpenderAllowance = await token.allowance.callAsync(owner, spender); expect(initSpenderAllowance).to.be.bignumber.equal(newSpenderAllowance); @@ -135,11 +147,17 @@ describe('UnlimitedAllowanceToken', () => { const initOwnerBalance = await token.balanceOf.callAsync(owner); const amountToTransfer = initOwnerBalance; const initSpenderAllowance = initOwnerBalance; - await token.approve.sendTransactionAsync(spender, initSpenderAllowance, { from: owner }); - await token.transferFrom.sendTransactionAsync(owner, spender, amountToTransfer, { - from: spender, - gas: constants.MAX_TOKEN_TRANSFERFROM_GAS, - }); + await web3Wrapper.awaitTransactionSuccessAsync( + await token.approve.sendTransactionAsync(spender, initSpenderAllowance, { from: owner }), + constants.AWAIT_TRANSACTION_MINED_MS, + ); + await web3Wrapper.awaitTransactionSuccessAsync( + await token.transferFrom.sendTransactionAsync(owner, spender, amountToTransfer, { + from: spender, + gas: constants.MAX_TOKEN_TRANSFERFROM_GAS, + }), + constants.AWAIT_TRANSACTION_MINED_MS, + ); const newOwnerBalance = await token.balanceOf.callAsync(owner); const newSpenderBalance = await token.balanceOf.callAsync(spender); @@ -152,11 +170,17 @@ describe('UnlimitedAllowanceToken', () => { const initOwnerBalance = await token.balanceOf.callAsync(owner); const amountToTransfer = initOwnerBalance; const initSpenderAllowance = initOwnerBalance; - await token.approve.sendTransactionAsync(spender, initSpenderAllowance, { from: owner }); - await token.transferFrom.sendTransactionAsync(owner, spender, amountToTransfer, { - from: spender, - gas: constants.MAX_TOKEN_TRANSFERFROM_GAS, - }); + await web3Wrapper.awaitTransactionSuccessAsync( + await token.approve.sendTransactionAsync(spender, initSpenderAllowance, { from: owner }), + constants.AWAIT_TRANSACTION_MINED_MS, + ); + await web3Wrapper.awaitTransactionSuccessAsync( + await token.transferFrom.sendTransactionAsync(owner, spender, amountToTransfer, { + from: spender, + gas: constants.MAX_TOKEN_TRANSFERFROM_GAS, + }), + constants.AWAIT_TRANSACTION_MINED_MS, + ); const newSpenderAllowance = await token.allowance.callAsync(owner, spender); expect(newSpenderAllowance).to.be.bignumber.equal(0); diff --git a/packages/dev-utils/package.json b/packages/dev-utils/package.json index 0b11029f6..47a13733b 100644 --- a/packages/dev-utils/package.json +++ b/packages/dev-utils/package.json @@ -46,6 +46,7 @@ "dependencies": { "@0xproject/subproviders": "^0.10.2", "@0xproject/types": "^0.7.0", + "ethereum-types": "^0.0.1", "@0xproject/typescript-typings": "^0.3.2", "@0xproject/web3-wrapper": "^0.6.4", "lodash": "^4.17.4", diff --git a/packages/dev-utils/src/web3_factory.ts b/packages/dev-utils/src/web3_factory.ts index c273035da..12872c122 100644 --- a/packages/dev-utils/src/web3_factory.ts +++ b/packages/dev-utils/src/web3_factory.ts @@ -7,7 +7,7 @@ import ProviderEngine = require('web3-provider-engine'); import RpcSubprovider = require('web3-provider-engine/subproviders/rpc'); import { EmptyWalletSubprovider, FakeGasEstimateSubprovider, GanacheSubprovider } from '@0xproject/subproviders'; -import { Provider } from '@0xproject/types'; +import { Provider } from 'ethereum-types'; import * as fs from 'fs'; import * as _ from 'lodash'; import * as process from 'process'; diff --git a/packages/dev-utils/test/blockchain_lifecycle_test.ts b/packages/dev-utils/test/blockchain_lifecycle_test.ts index 857a6b50e..3d7d2e0ef 100644 --- a/packages/dev-utils/test/blockchain_lifecycle_test.ts +++ b/packages/dev-utils/test/blockchain_lifecycle_test.ts @@ -1,6 +1,6 @@ -import { BlockParamLiteral } from '@0xproject/types'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import * as chai from 'chai'; +import { BlockParamLiteral } from 'ethereum-types'; import 'make-promises-safe'; import 'mocha'; diff --git a/packages/dev-utils/test/rpc_test.ts b/packages/dev-utils/test/rpc_test.ts index 45d1226c2..cff946e23 100644 --- a/packages/dev-utils/test/rpc_test.ts +++ b/packages/dev-utils/test/rpc_test.ts @@ -1,6 +1,6 @@ -import { BlockParamLiteral } from '@0xproject/types'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import * as chai from 'chai'; +import { BlockParamLiteral } from 'ethereum-types'; import 'make-promises-safe'; import 'mocha'; diff --git a/packages/ethereum-types/.npmignore b/packages/ethereum-types/.npmignore new file mode 100644 index 000000000..24e65ad5b --- /dev/null +++ b/packages/ethereum-types/.npmignore @@ -0,0 +1,6 @@ +.* +yarn-error.log +/scripts/ +/src/ +tsconfig.json +/lib/monorepo_scripts/ diff --git a/packages/ethereum-types/CHANGELOG.json b/packages/ethereum-types/CHANGELOG.json new file mode 100644 index 000000000..ed0526ee0 --- /dev/null +++ b/packages/ethereum-types/CHANGELOG.json @@ -0,0 +1,11 @@ +[ + { + "version": "0.0.1", + "changes": [ + { + "note": "Initial publish", + "pr": "642" + } + ] + } +] diff --git a/packages/ethereum-types/README.md b/packages/ethereum-types/README.md new file mode 100644 index 000000000..817e22d15 --- /dev/null +++ b/packages/ethereum-types/README.md @@ -0,0 +1,61 @@ +## ethereum-types + +Typescript types shared across Ethereum-related packages/libraries/tools. + +## Installation + +```bash +yarn add -D ethereum-types +``` + +## Usage + +```javascript +import { TransactionReceipt, TxData, TxDataPayable } from 'ethereum-types'; +``` + +## Contributing + +We welcome improvements and fixes from the wider community! 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 +``` + +### Build + +To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory: + +```bash +PKG=ethereum-types yarn build +``` + +Or continuously rebuild on change: + +```bash +PKG=ethereum-types yarn watch +``` + +### Clean + +```bash +yarn clean +``` + +### Lint + +```bash +yarn lint +``` diff --git a/packages/ethereum-types/package.json b/packages/ethereum-types/package.json new file mode 100644 index 000000000..0c9519994 --- /dev/null +++ b/packages/ethereum-types/package.json @@ -0,0 +1,42 @@ +{ + "name": "ethereum-types", + "version": "0.0.1", + "engines": { + "node": ">=6.12" + }, + "description": "Ethereum types", + "main": "lib/index.js", + "types": "lib/index.d.ts", + "scripts": { + "watch": "tsc -w", + "build": "tsc && copyfiles -u 2 './lib/monorepo_scripts/**/*' ./scripts", + "clean": "shx rm -rf lib scripts", + "lint": "tslint --project .", + "manual:postpublish": "yarn build; node ./scripts/postpublish.js" + }, + "license": "Apache-2.0", + "repository": { + "type": "git", + "url": "https://github.com/0xProject/0x-monorepo.git" + }, + "bugs": { + "url": "https://github.com/0xProject/0x-monorepo/issues" + }, + "homepage": "https://github.com/0xProject/0x-monorepo/packages/ethereum-types/README.md", + "devDependencies": { + "@0xproject/monorepo-scripts": "^0.1.20", + "@0xproject/tslint-config": "^0.4.18", + "copyfiles": "^1.2.0", + "make-promises-safe": "^1.1.0", + "shx": "^0.2.2", + "tslint": "5.8.0", + "typescript": "2.7.1" + }, + "dependencies": { + "@types/node": "^8.0.53", + "bignumber.js": "~4.1.0" + }, + "publishConfig": { + "access": "public" + } +} diff --git a/packages/ethereum-types/src/globals.d.ts b/packages/ethereum-types/src/globals.d.ts new file mode 100644 index 000000000..94e63a32d --- /dev/null +++ b/packages/ethereum-types/src/globals.d.ts @@ -0,0 +1,6 @@ +declare module '*.json' { + const json: any; + /* tslint:disable */ + export default json; + /* tslint:enable */ +} diff --git a/packages/ethereum-types/src/index.ts b/packages/ethereum-types/src/index.ts new file mode 100644 index 000000000..f00ae963a --- /dev/null +++ b/packages/ethereum-types/src/index.ts @@ -0,0 +1,281 @@ +import { BigNumber } from 'bignumber.js'; + +export type JSONRPCErrorCallback = (err: Error | null, result?: JSONRPCResponsePayload) => void; + +/** + * Do not create your own provider. Use an existing provider from a Web3 or ProviderEngine library + * Read more about Providers in the 0x wiki. + */ +export interface Provider { + sendAsync(payload: JSONRPCRequestPayload, callback: JSONRPCErrorCallback): void; +} + +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 enum OpCode { + DelegateCall = 'DELEGATECALL', + Revert = 'REVERT', + Create = 'CREATE', + Stop = 'STOP', + Invalid = 'INVALID', + CallCode = 'CALLCODE', + StaticCall = 'STATICCALL', + Return = 'RETURN', + Call = 'CALL', + SelfDestruct = 'SELFDESTRUCT', +} + +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; + 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; +} + +export 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[]; +} + +export enum AbiType { + Function = 'function', + Constructor = 'constructor', + Event = 'event', + Fallback = 'fallback', +} + +export type ContractEventArg = string | BigNumber | number | boolean; + +export interface DecodedLogArgs { + [argName: string]: ContractEventArg; +} + +export interface LogWithDecodedArgs<ArgsType extends DecodedLogArgs> extends DecodedLogEntry<ArgsType> {} +export type RawLog = LogEntry; + +export enum BlockParamLiteral { + Earliest = 'earliest', + Latest = 'latest', + Pending = 'pending', +} + +export type BlockParam = BlockParamLiteral | number; + +export interface RawLogEntry { + logIndex: string | null; + transactionIndex: string | null; + transactionHash: string; + blockHash: string | null; + blockNumber: string | null; + address: string; + data: string; + topics: string[]; +} + +export enum SolidityTypes { + Address = 'address', + Uint256 = 'uint256', + Uint8 = 'uint8', + Uint = 'uint', +} + +/** + * Contains the logs returned by a TransactionReceipt. We attempt to decode the + * logs using AbiDecoder. If we have the logs corresponding ABI, we decode it, + * otherwise we don't. + */ +export interface TransactionReceiptWithDecodedLogs extends TransactionReceipt { + logs: Array<LogWithDecodedArgs<DecodedLogArgs> | LogEntry>; +} diff --git a/packages/ethereum-types/src/monorepo_scripts/postpublish.ts b/packages/ethereum-types/src/monorepo_scripts/postpublish.ts new file mode 100644 index 000000000..dcb99d0f7 --- /dev/null +++ b/packages/ethereum-types/src/monorepo_scripts/postpublish.ts @@ -0,0 +1,8 @@ +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/ethereum-types/tsconfig.json b/packages/ethereum-types/tsconfig.json new file mode 100644 index 000000000..82a45ea94 --- /dev/null +++ b/packages/ethereum-types/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../tsconfig", + "compilerOptions": { + "typeRoots": ["../../node_modules/@types"], + "outDir": "lib" + }, + "include": ["src/**/*"] +} diff --git a/packages/ethereum-types/tslint.json b/packages/ethereum-types/tslint.json new file mode 100644 index 000000000..ffaefe83a --- /dev/null +++ b/packages/ethereum-types/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": ["@0xproject/tslint-config"] +} diff --git a/packages/fill-scenarios/package.json b/packages/fill-scenarios/package.json index e2f1a2af1..d0d3d9ec4 100644 --- a/packages/fill-scenarios/package.json +++ b/packages/fill-scenarios/package.json @@ -39,6 +39,7 @@ "@0xproject/base-contract": "^0.3.2", "@0xproject/order-utils": "0.0.5", "@0xproject/types": "0.7.0", + "ethereum-types": "^0.0.1", "@0xproject/typescript-typings": "^0.3.2", "@0xproject/utils": "^0.6.2", "@0xproject/web3-wrapper": "^0.6.4", diff --git a/packages/json-schemas/package.json b/packages/json-schemas/package.json index 64805b6a8..603e5ab73 100644 --- a/packages/json-schemas/package.json +++ b/packages/json-schemas/package.json @@ -27,7 +27,8 @@ "assets": [], "docPublishConfigs": { "extraFileIncludes": [ - "../types/src/index.ts" + "../types/src/index.ts", + "../ethereum-types/src/index.ts" ], "s3BucketPath": "s3://doc-jsons/json-schemas/", "s3StagingBucketPath": "s3://staging-doc-jsons/json-schemas/" diff --git a/packages/metacoin/package.json b/packages/metacoin/package.json index 312aa0819..a85bf8f77 100644 --- a/packages/metacoin/package.json +++ b/packages/metacoin/package.json @@ -35,6 +35,7 @@ "@0xproject/types": "^0.7.0", "@0xproject/utils": "^0.6.2", "@0xproject/web3-wrapper": "^0.6.4", + "ethereum-types": "^0.0.1", "ethers": "^3.0.15", "lodash": "^4.17.4", "web3-provider-engine": "^14.0.4" diff --git a/packages/metacoin/test/metacoin_test.ts b/packages/metacoin/test/metacoin_test.ts index 034c1265e..3436fb49e 100644 --- a/packages/metacoin/test/metacoin_test.ts +++ b/packages/metacoin/test/metacoin_test.ts @@ -1,9 +1,9 @@ import { BlockchainLifecycle, devConstants } from '@0xproject/dev-utils'; import { ContractArtifact } from '@0xproject/sol-compiler'; -import { LogWithDecodedArgs } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import * as chai from 'chai'; +import { LogWithDecodedArgs } from 'ethereum-types'; import 'make-promises-safe'; import * as MetacoinArtifact from '../artifacts/Metacoin.json'; diff --git a/packages/migrations/package.json b/packages/migrations/package.json index b8137cab9..75d735e6a 100644 --- a/packages/migrations/package.json +++ b/packages/migrations/package.json @@ -53,6 +53,7 @@ "@0xproject/typescript-typings": "^0.3.2", "@0xproject/utils": "^0.6.2", "@0xproject/web3-wrapper": "^0.6.4", + "ethereum-types": "^0.0.1", "ethers": "^3.0.15", "lodash": "^4.17.4" }, diff --git a/packages/migrations/src/migrate.ts b/packages/migrations/src/migrate.ts index 49b4e897c..a6fd86e5a 100644 --- a/packages/migrations/src/migrate.ts +++ b/packages/migrations/src/migrate.ts @@ -1,7 +1,7 @@ #!/usr/bin/env node import { devConstants, web3Factory } from '@0xproject/dev-utils'; -import { Provider } from '@0xproject/types'; import { logUtils } from '@0xproject/utils'; +import { Provider } from 'ethereum-types'; import * as path from 'path'; import * as yargs from 'yargs'; diff --git a/packages/migrations/src/v1/migration.ts b/packages/migrations/src/v1/migration.ts index 233339244..baa776537 100644 --- a/packages/migrations/src/v1/migration.ts +++ b/packages/migrations/src/v1/migration.ts @@ -1,6 +1,6 @@ -import { Provider, TxData } from '@0xproject/types'; import { BigNumber, NULL_BYTES } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; +import { Provider, TxData } from 'ethereum-types'; import * as _ from 'lodash'; import { ArtifactWriter } from '../artifact_writer'; diff --git a/packages/migrations/src/v2/migration.ts b/packages/migrations/src/v2/migration.ts index fd7223252..08a8ad2a7 100644 --- a/packages/migrations/src/v2/migration.ts +++ b/packages/migrations/src/v2/migration.ts @@ -1,6 +1,6 @@ -import { Provider, TxData } from '@0xproject/types'; import { BigNumber, NULL_BYTES } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; +import { Provider, TxData } from 'ethereum-types'; import * as _ from 'lodash'; import { ArtifactWriter } from '../artifact_writer'; diff --git a/packages/order-utils/package.json b/packages/order-utils/package.json index f4ca7ea40..ebfd8b8b4 100644 --- a/packages/order-utils/package.json +++ b/packages/order-utils/package.json @@ -30,7 +30,8 @@ "postpublish": { "docPublishConfigs": { "extraFileIncludes": [ - "../types/src/index.ts" + "../types/src/index.ts", + "../ethereum-types/src/index.ts" ], "s3BucketPath": "s3://doc-jsons/order-utils/", "s3StagingBucketPath": "s3://staging-doc-jsons/order-utils/" @@ -50,6 +51,8 @@ "@0xproject/dev-utils": "^0.4.2", "@0xproject/monorepo-scripts": "^0.1.20", "@0xproject/tslint-config": "^0.4.18", + "@types/ethereumjs-abi": "^0.6.0", + "@types/bn.js": "^4.11.0", "@types/lodash": "4.14.104", "chai": "^4.0.1", "chai-as-promised": "^7.1.0", diff --git a/packages/order-watcher/package.json b/packages/order-watcher/package.json index 6b8165116..fcc40d56d 100644 --- a/packages/order-watcher/package.json +++ b/packages/order-watcher/package.json @@ -86,6 +86,7 @@ "@0xproject/typescript-typings": "^0.3.2", "@0xproject/utils": "^0.6.2", "@0xproject/web3-wrapper": "^0.6.4", + "ethereum-types": "^0.0.1", "bintrees": "^1.0.2", "ethers": "^3.0.15", "lodash": "^4.17.4" diff --git a/packages/react-docs/package.json b/packages/react-docs/package.json index 531c0d90c..3d9ef08e8 100644 --- a/packages/react-docs/package.json +++ b/packages/react-docs/package.json @@ -28,6 +28,7 @@ "@0xproject/dev-utils": "^0.4.2", "@0xproject/monorepo-scripts": "^0.1.20", "@0xproject/tslint-config": "^0.4.18", + "@types/compare-versions": "^3.0.0", "copyfiles": "^1.2.0", "make-promises-safe": "^1.1.0", "shx": "^0.2.2", diff --git a/packages/react-shared/package.json b/packages/react-shared/package.json index d28972325..eb964a0f4 100644 --- a/packages/react-shared/package.json +++ b/packages/react-shared/package.json @@ -41,6 +41,7 @@ "@types/react": "16.3.13", "@types/react-dom": "^16.0.3", "@types/react-scroll": "0.0.31", + "@types/is-mobile": "0.3.0", "basscss": "^8.0.3", "is-mobile": "^0.2.2", "lodash": "^4.17.4", diff --git a/packages/sol-compiler/package.json b/packages/sol-compiler/package.json index a74e4ae3e..60ed3655f 100644 --- a/packages/sol-compiler/package.json +++ b/packages/sol-compiler/package.json @@ -28,7 +28,8 @@ "assets": [], "docPublishConfigs": { "extraFileIncludes": [ - "../types/src/index.ts" + "../types/src/index.ts", + "../ethereum-types/src/index.ts" ], "s3BucketPath": "s3://doc-jsons/sol-compiler/", "s3StagingBucketPath": "s3://staging-doc-jsons/sol-compiler/" @@ -80,6 +81,7 @@ "@0xproject/utils": "^0.6.2", "@0xproject/web3-wrapper": "^0.6.4", "@types/yargs": "^11.0.0", + "ethereum-types": "^0.0.1", "chalk": "^2.3.0", "ethereumjs-util": "^5.1.1", "isomorphic-fetch": "^2.2.1", diff --git a/packages/sol-compiler/src/compiler.ts b/packages/sol-compiler/src/compiler.ts index 1d5bdb940..d2dda75ea 100644 --- a/packages/sol-compiler/src/compiler.ts +++ b/packages/sol-compiler/src/compiler.ts @@ -11,9 +11,9 @@ import { Resolver, URLResolver, } from '@0xproject/sol-resolver'; -import { ContractAbi } from '@0xproject/types'; import { logUtils, promisify } from '@0xproject/utils'; import chalk from 'chalk'; +import { ContractAbi } from 'ethereum-types'; import * as ethUtil from 'ethereumjs-util'; import * as fs from 'fs'; import 'isomorphic-fetch'; diff --git a/packages/sol-compiler/src/utils/encoder.ts b/packages/sol-compiler/src/utils/encoder.ts index 806efbbca..0f2d75691 100644 --- a/packages/sol-compiler/src/utils/encoder.ts +++ b/packages/sol-compiler/src/utils/encoder.ts @@ -1,4 +1,4 @@ -import { AbiDefinition, AbiType, ContractAbi, DataItem } from '@0xproject/types'; +import { AbiDefinition, AbiType, ContractAbi, DataItem } from 'ethereum-types'; import * as _ from 'lodash'; import * as web3Abi from 'web3-eth-abi'; diff --git a/packages/sol-compiler/src/utils/types.ts b/packages/sol-compiler/src/utils/types.ts index d43347fa6..759a7a555 100644 --- a/packages/sol-compiler/src/utils/types.ts +++ b/packages/sol-compiler/src/utils/types.ts @@ -1,4 +1,4 @@ -import { ContractAbi, Provider, TxData } from '@0xproject/types'; +import { ContractAbi, Provider, TxData } from 'ethereum-types'; import * as solc from 'solc'; import * as Web3 from 'web3'; import * as yargs from 'yargs'; diff --git a/packages/sol-compiler/test/util/provider.ts b/packages/sol-compiler/test/util/provider.ts index 2bd178129..7215ffae7 100644 --- a/packages/sol-compiler/test/util/provider.ts +++ b/packages/sol-compiler/test/util/provider.ts @@ -1,5 +1,5 @@ import { web3Factory } from '@0xproject/dev-utils'; -import { Provider } from '@0xproject/types'; +import { Provider } from 'ethereum-types'; import * as Web3 from 'web3'; const providerConfigs = { shouldUseInProcessGanache: true }; diff --git a/packages/sol-cov/package.json b/packages/sol-cov/package.json index 72110265c..4d92a610b 100644 --- a/packages/sol-cov/package.json +++ b/packages/sol-cov/package.json @@ -29,7 +29,8 @@ "docPublishConfigs": { "extraFileIncludes": [ "../subproviders/src/types.ts", - "../types/src/index.ts" + "../types/src/index.ts", + "../ethereum-types/src/index.ts" ], "s3BucketPath": "s3://doc-jsons/sol-cov/", "s3StagingBucketPath": "s3://staging-doc-jsons/sol-cov/" @@ -48,9 +49,9 @@ "dependencies": { "@0xproject/sol-compiler": "^0.5.0", "@0xproject/subproviders": "^0.10.2", - "@0xproject/types": "1.0.0", "@0xproject/typescript-typings": "^0.3.2", "@0xproject/utils": "^0.6.2", + "ethereum-types": "^0.0.1", "ethereumjs-util": "^5.1.1", "glob": "^7.1.2", "istanbul": "^0.4.5", @@ -67,6 +68,7 @@ "@types/istanbul": "^0.4.30", "@types/loglevel": "^1.5.3", "@types/mkdirp": "^0.5.1", + "@types/solidity-parser-antlr": "^0.2.0", "@types/mocha": "^2.2.42", "@types/node": "^8.0.53", "@types/rimraf": "^2.0.2", diff --git a/packages/sol-cov/src/coverage_subprovider.ts b/packages/sol-cov/src/coverage_subprovider.ts index 438339a3f..ca7f4aed2 100644 --- a/packages/sol-cov/src/coverage_subprovider.ts +++ b/packages/sol-cov/src/coverage_subprovider.ts @@ -1,5 +1,5 @@ import { Callback, ErrorCallback, NextCallback, Subprovider } from '@0xproject/subproviders'; -import { BlockParam, CallData, JSONRPCRequestPayload, TransactionTrace, TxData } from '@0xproject/types'; +import { BlockParam, CallData, JSONRPCRequestPayload, TransactionTrace, TxData } from 'ethereum-types'; import * as fs from 'fs'; import * as _ from 'lodash'; import { Lock } from 'semaphore-async-await'; diff --git a/packages/sol-cov/src/trace.ts b/packages/sol-cov/src/trace.ts index 6caea1610..1c21c8e5c 100644 --- a/packages/sol-cov/src/trace.ts +++ b/packages/sol-cov/src/trace.ts @@ -1,5 +1,5 @@ -import { OpCode, StructLog, TransactionTrace } from '@0xproject/types'; import { addressUtils, BigNumber, logUtils } from '@0xproject/utils'; +import { OpCode, StructLog, TransactionTrace } from 'ethereum-types'; import { addHexPrefix, stripHexPrefix } from 'ethereumjs-util'; import * as fs from 'fs'; import * as _ from 'lodash'; diff --git a/packages/sol-cov/test/trace_test.ts b/packages/sol-cov/test/trace_test.ts index c140cba0d..07e270b71 100644 --- a/packages/sol-cov/test/trace_test.ts +++ b/packages/sol-cov/test/trace_test.ts @@ -1,5 +1,5 @@ -import { OpCode, StructLog } from '@0xproject/types'; import * as chai from 'chai'; +import { OpCode, StructLog } from 'ethereum-types'; import * as fs from 'fs'; import * as _ from 'lodash'; import 'mocha'; diff --git a/packages/subproviders/package.json b/packages/subproviders/package.json index 3cd5f0e9b..3a28e5e8d 100644 --- a/packages/subproviders/package.json +++ b/packages/subproviders/package.json @@ -31,7 +31,8 @@ "assets": [], "docPublishConfigs": { "extraFileIncludes": [ - "../types/src/index.ts" + "../types/src/index.ts", + "../ethereum-types/src/index.ts" ], "s3BucketPath": "s3://doc-jsons/subproviders/", "s3StagingBucketPath": "s3://staging-doc-jsons/subproviders/" @@ -45,6 +46,7 @@ "@0xproject/utils": "^0.6.2", "@ledgerhq/hw-app-eth": "^4.3.0", "@ledgerhq/hw-transport-u2f": "^4.3.0", + "ethereum-types": "^0.0.1", "bip39": "^2.5.0", "bn.js": "^4.11.8", "ethereumjs-tx": "^1.3.3", @@ -61,6 +63,9 @@ "@0xproject/tslint-config": "^0.4.18", "@0xproject/utils": "^0.6.2", "@types/bip39": "^2.4.0", + "@types/bn.js": "^4.11.0", + "@types/hdkey": "^0.7.0", + "@types/ethereumjs-tx": "^1.0.0", "@types/lodash": "4.14.104", "@types/mocha": "^2.2.42", "@types/node": "^8.0.53", diff --git a/packages/subproviders/src/subproviders/base_wallet_subprovider.ts b/packages/subproviders/src/subproviders/base_wallet_subprovider.ts index a04be68e1..c4b344e3b 100644 --- a/packages/subproviders/src/subproviders/base_wallet_subprovider.ts +++ b/packages/subproviders/src/subproviders/base_wallet_subprovider.ts @@ -1,6 +1,6 @@ import { assert } from '@0xproject/assert'; -import { JSONRPCRequestPayload, JSONRPCResponsePayload } from '@0xproject/types'; import { addressUtils } from '@0xproject/utils'; +import { JSONRPCRequestPayload, JSONRPCResponsePayload } from 'ethereum-types'; import * as _ from 'lodash'; import { Callback, ErrorCallback, PartialTxParams, ResponseWithTxParams, WalletSubproviderErrors } from '../types'; diff --git a/packages/subproviders/src/subproviders/empty_wallet_subprovider.ts b/packages/subproviders/src/subproviders/empty_wallet_subprovider.ts index bd7a4b6d9..4268c67bd 100644 --- a/packages/subproviders/src/subproviders/empty_wallet_subprovider.ts +++ b/packages/subproviders/src/subproviders/empty_wallet_subprovider.ts @@ -1,4 +1,4 @@ -import { JSONRPCRequestPayload } from '@0xproject/types'; +import { JSONRPCRequestPayload } from 'ethereum-types'; import { Callback, ErrorCallback } from '../types'; diff --git a/packages/subproviders/src/subproviders/fake_gas_estimate_subprovider.ts b/packages/subproviders/src/subproviders/fake_gas_estimate_subprovider.ts index 6c49f20cf..d750505e7 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 { JSONRPCRequestPayload } from '@0xproject/types'; +import { JSONRPCRequestPayload } from 'ethereum-types'; import { Callback, ErrorCallback } from '../types'; diff --git a/packages/subproviders/src/subproviders/ganache.ts b/packages/subproviders/src/subproviders/ganache.ts index 9ab764048..73d0513cc 100644 --- a/packages/subproviders/src/subproviders/ganache.ts +++ b/packages/subproviders/src/subproviders/ganache.ts @@ -1,4 +1,4 @@ -import { JSONRPCRequestPayload, Provider } from '@0xproject/types'; +import { JSONRPCRequestPayload, Provider } from 'ethereum-types'; import * as Ganache from 'ganache-core'; import { Callback, ErrorCallback } from '../types'; diff --git a/packages/subproviders/src/subproviders/injected_web3.ts b/packages/subproviders/src/subproviders/injected_web3.ts index 73b870cd5..165c66d62 100644 --- a/packages/subproviders/src/subproviders/injected_web3.ts +++ b/packages/subproviders/src/subproviders/injected_web3.ts @@ -1,4 +1,4 @@ -import { JSONRPCRequestPayload, Provider } from '@0xproject/types'; +import { JSONRPCRequestPayload, Provider } from 'ethereum-types'; import * as _ from 'lodash'; import * as Web3 from 'web3'; diff --git a/packages/subproviders/src/subproviders/nonce_tracker.ts b/packages/subproviders/src/subproviders/nonce_tracker.ts index 345e5e975..98773e79c 100644 --- a/packages/subproviders/src/subproviders/nonce_tracker.ts +++ b/packages/subproviders/src/subproviders/nonce_tracker.ts @@ -1,6 +1,6 @@ import * as _ from 'lodash'; -import { BlockParamLiteral, JSONRPCRequestPayload } from '@0xproject/types'; +import { BlockParamLiteral, JSONRPCRequestPayload } from 'ethereum-types'; import EthereumTx = require('ethereumjs-tx'); import ethUtil = require('ethereumjs-util'); import providerEngineUtils = require('web3-provider-engine/util/rpc-cache-utils'); diff --git a/packages/subproviders/src/subproviders/redundant_subprovider.ts b/packages/subproviders/src/subproviders/redundant_subprovider.ts index 37c8bba5a..a60d6706e 100644 --- a/packages/subproviders/src/subproviders/redundant_subprovider.ts +++ b/packages/subproviders/src/subproviders/redundant_subprovider.ts @@ -1,5 +1,5 @@ -import { JSONRPCRequestPayload } from '@0xproject/types'; import { promisify } from '@0xproject/utils'; +import { JSONRPCRequestPayload } from 'ethereum-types'; import * as _ from 'lodash'; import { Callback } from '../types'; diff --git a/packages/subproviders/src/subproviders/subprovider.ts b/packages/subproviders/src/subproviders/subprovider.ts index cb6dffc4a..f9491707e 100644 --- a/packages/subproviders/src/subproviders/subprovider.ts +++ b/packages/subproviders/src/subproviders/subprovider.ts @@ -1,5 +1,5 @@ -import { JSONRPCRequestPayload, JSONRPCResponsePayload } from '@0xproject/types'; import { promisify } from '@0xproject/utils'; +import { JSONRPCRequestPayload, JSONRPCResponsePayload } from 'ethereum-types'; import * as Web3 from 'web3'; import { Callback, ErrorCallback, JSONRPCRequestPayloadWithMethod } from '../types'; diff --git a/packages/subproviders/src/types.ts b/packages/subproviders/src/types.ts index 30a3b4a4e..7a8413305 100644 --- a/packages/subproviders/src/types.ts +++ b/packages/subproviders/src/types.ts @@ -1,4 +1,5 @@ -import { ECSignature, JSONRPCRequestPayload } from '@0xproject/types'; +import { ECSignature } from '@0xproject/types'; +import { JSONRPCRequestPayload } from 'ethereum-types'; import HDNode = require('hdkey'); import * as _ from 'lodash'; diff --git a/packages/subproviders/test/integration/ledger_subprovider_test.ts b/packages/subproviders/test/integration/ledger_subprovider_test.ts index d3e9d0fde..315dfa894 100644 --- a/packages/subproviders/test/integration/ledger_subprovider_test.ts +++ b/packages/subproviders/test/integration/ledger_subprovider_test.ts @@ -1,10 +1,11 @@ -import { DoneCallback, JSONRPCResponsePayload } from '@0xproject/types'; +import { DoneCallback } from '@0xproject/types'; import { promisify } from '@0xproject/utils'; import Eth from '@ledgerhq/hw-app-eth'; // HACK: This dependency is optional and tslint skips optional dependencies // tslint:disable-next-line:no-implicit-dependencies import TransportNodeHid from '@ledgerhq/hw-transport-node-hid'; import * as chai from 'chai'; +import { JSONRPCResponsePayload } from 'ethereum-types'; import * as ethUtils from 'ethereumjs-util'; import * as _ from 'lodash'; import 'make-promises-safe'; diff --git a/packages/subproviders/test/unit/ledger_subprovider_test.ts b/packages/subproviders/test/unit/ledger_subprovider_test.ts index 8571f7d11..17e72a694 100644 --- a/packages/subproviders/test/unit/ledger_subprovider_test.ts +++ b/packages/subproviders/test/unit/ledger_subprovider_test.ts @@ -1,5 +1,5 @@ -import { JSONRPCResponsePayload } from '@0xproject/types'; import * as chai from 'chai'; +import { JSONRPCResponsePayload } from 'ethereum-types'; import * as ethUtils from 'ethereumjs-util'; import * as _ from 'lodash'; import 'make-promises-safe'; diff --git a/packages/subproviders/test/unit/mnemonic_wallet_subprovider_test.ts b/packages/subproviders/test/unit/mnemonic_wallet_subprovider_test.ts index 90565181e..fba221af0 100644 --- a/packages/subproviders/test/unit/mnemonic_wallet_subprovider_test.ts +++ b/packages/subproviders/test/unit/mnemonic_wallet_subprovider_test.ts @@ -1,5 +1,5 @@ -import { JSONRPCResponsePayload } from '@0xproject/types'; import * as chai from 'chai'; +import { JSONRPCResponsePayload } from 'ethereum-types'; import * as ethUtils from 'ethereumjs-util'; import * as _ from 'lodash'; import 'make-promises-safe'; diff --git a/packages/subproviders/test/unit/private_key_wallet_subprovider_test.ts b/packages/subproviders/test/unit/private_key_wallet_subprovider_test.ts index 864f977ea..ac88d8cac 100644 --- a/packages/subproviders/test/unit/private_key_wallet_subprovider_test.ts +++ b/packages/subproviders/test/unit/private_key_wallet_subprovider_test.ts @@ -1,5 +1,5 @@ -import { JSONRPCResponsePayload } from '@0xproject/types'; import * as chai from 'chai'; +import { JSONRPCResponsePayload } from 'ethereum-types'; import * as ethUtils from 'ethereumjs-util'; import * as _ from 'lodash'; import 'make-promises-safe'; diff --git a/packages/subproviders/test/unit/redundant_rpc_subprovider_test.ts b/packages/subproviders/test/unit/redundant_rpc_subprovider_test.ts index fdbbb332c..fcfec1367 100644 --- a/packages/subproviders/test/unit/redundant_rpc_subprovider_test.ts +++ b/packages/subproviders/test/unit/redundant_rpc_subprovider_test.ts @@ -1,5 +1,6 @@ -import { DoneCallback, JSONRPCResponsePayload } from '@0xproject/types'; +import { DoneCallback } from '@0xproject/types'; import * as chai from 'chai'; +import { JSONRPCResponsePayload } from 'ethereum-types'; import * as _ from 'lodash'; import 'make-promises-safe'; import Web3 = require('web3'); diff --git a/packages/testnet-faucets/package.json b/packages/testnet-faucets/package.json index c565d5b7d..06f8d3e84 100644 --- a/packages/testnet-faucets/package.json +++ b/packages/testnet-faucets/package.json @@ -20,7 +20,6 @@ "dependencies": { "0x.js": "^0.38.0", "@0xproject/subproviders": "^0.10.2", - "@0xproject/types": "^0.7.0", "@0xproject/typescript-typings": "^0.3.2", "@0xproject/utils": "^0.6.2", "body-parser": "^1.17.1", @@ -37,6 +36,7 @@ "@types/body-parser": "^1.16.1", "@types/express": "^4.0.35", "@types/lodash": "4.14.104", + "ethereum-types": "^0.0.1", "awesome-typescript-loader": "^3.1.3", "gulp": "^3.9.1", "make-promises-safe": "^1.1.0", diff --git a/packages/testnet-faucets/src/ts/handler.ts b/packages/testnet-faucets/src/ts/handler.ts index d5f0dc2f9..3a105742e 100644 --- a/packages/testnet-faucets/src/ts/handler.ts +++ b/packages/testnet-faucets/src/ts/handler.ts @@ -1,6 +1,6 @@ import { Order, SignedOrder, ZeroEx } from '0x.js'; -import { Provider } from '@0xproject/types'; import { BigNumber, logUtils } from '@0xproject/utils'; +import { Provider } from 'ethereum-types'; import * as express from 'express'; import * as _ from 'lodash'; import * as Web3 from 'web3'; diff --git a/packages/types/package.json b/packages/types/package.json index e70546bd3..95b7721d3 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -34,7 +34,8 @@ }, "dependencies": { "@types/node": "^8.0.53", - "bignumber.js": "~4.1.0" + "bignumber.js": "~4.1.0", + "ethereum-types": "^0.0.1" }, "publishConfig": { "access": "public" diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index b1d6f97cb..8bd6e097e 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -1,285 +1,5 @@ import { BigNumber } from 'bignumber.js'; - -export type JSONRPCErrorCallback = (err: Error | null, result?: JSONRPCResponsePayload) => void; - -/** - * Do not create your own provider. Use an existing provider from a Web3 or ProviderEngine library - * Read more about Providers in the 0x wiki. - */ -export interface Provider { - sendAsync(payload: JSONRPCRequestPayload, callback: JSONRPCErrorCallback): void; -} - -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 enum OpCode { - DelegateCall = 'DELEGATECALL', - Revert = 'REVERT', - Create = 'CREATE', - Stop = 'STOP', - Invalid = 'INVALID', - CallCode = 'CALLCODE', - StaticCall = 'STATICCALL', - Return = 'RETURN', - Call = 'CALL', - SelfDestruct = 'SELFDESTRUCT', -} - -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; - 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; -} - -export 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[]; -} - -export enum AbiType { - Function = 'function', - Constructor = 'constructor', - Event = 'event', - Fallback = 'fallback', -} - -export type ContractEventArg = string | BigNumber | number; - -export interface DecodedLogArgs { - [argName: string]: ContractEventArg; -} - -export interface LogWithDecodedArgs<ArgsType> extends DecodedLogEntry<ArgsType> {} -export type RawLog = LogEntry; -export enum SolidityTypes { - Address = 'address', - Uint256 = 'uint256', - Uint8 = 'uint8', - Uint = 'uint', -} - -/** - * Contains the logs returned by a TransactionReceipt. We attempt to decode the - * logs using AbiDecoder. If we have the logs corresponding ABI, we decode it, - * otherwise we don't. - */ -export interface TransactionReceiptWithDecodedLogs extends TransactionReceipt { - logs: Array<LogWithDecodedArgs<DecodedLogArgs> | LogEntry>; -} - -// Earliest is omitted by design. It is simply an alias for the `0` constant and -// is thus not very helpful. Moreover, this type is used in places that only accept -// `latest` or `pending`. -export enum BlockParamLiteral { - Latest = 'latest', - Pending = 'pending', -} - -export type BlockParam = BlockParamLiteral | number; - -export interface RawLogEntry { - logIndex: string | null; - transactionIndex: string | null; - transactionHash: string; - blockHash: string | null; - blockNumber: string | null; - address: string; - data: string; - topics: string[]; -} +import { ContractAbi, DecodedLogArgs, LogEntry, LogWithDecodedArgs, TransactionReceipt } from 'ethereum-types'; export interface Order { senderAddress: string; diff --git a/packages/typescript-typings/CHANGELOG.json b/packages/typescript-typings/CHANGELOG.json index 86b4a5078..555da22d1 100644 --- a/packages/typescript-typings/CHANGELOG.json +++ b/packages/typescript-typings/CHANGELOG.json @@ -1,17 +1,17 @@ [ { - "version": "0.5.0", - "changes": [ - { - "note": "Add types for `react-popper`, remove types for `react-joyride`" - } - ] - }, - { "version": "0.4.0", "changes": [ { "note": "Add types for `react-joyride`" + }, + { + "note": "Add types for `react-popper`, remove types for `react-joyride`" + }, + { + "note": + "Remove types for blockies, bn.js, compare-versions, ethereumjs-abi, ethereumjs-tx, find-versions, hdkey, is-mobile, solidity-parser-antlr, xml-js as they were moved to DefinitelyTyped", + "pr": 641 } ] }, diff --git a/packages/typescript-typings/package.json b/packages/typescript-typings/package.json index 932f89ec5..4bae1f437 100644 --- a/packages/typescript-typings/package.json +++ b/packages/typescript-typings/package.json @@ -25,13 +25,12 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/typescript-typings#readme", "dependencies": { - "@0xproject/types": "^0.7.0", + "ethereum-types": "^0.0.1", "bignumber.js": "~4.1.0" }, "devDependencies": { "@0xproject/monorepo-scripts": "^0.1.20", "copyfiles": "^1.2.0", - "make-promises-safe": "^1.1.0", "shx": "^0.2.2" }, "publishConfig": { diff --git a/packages/typescript-typings/types/blockies/index.d.ts b/packages/typescript-typings/types/blockies/index.d.ts deleted file mode 100644 index d4068e50f..000000000 --- a/packages/typescript-typings/types/blockies/index.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -// blockies declarations -declare interface BlockiesIcon { - toDataURL(): string; -} -declare interface BlockiesConfig { - seed: string; -} -declare function blockies(config: BlockiesConfig): BlockiesIcon; -declare module 'blockies' { - export = blockies; -} diff --git a/packages/typescript-typings/types/bn.js/index.d.ts b/packages/typescript-typings/types/bn.js/index.d.ts deleted file mode 100644 index f59b74bad..000000000 --- a/packages/typescript-typings/types/bn.js/index.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -declare module 'bn.js' { - import { Buffer } from 'buffer'; - - type Endianness = 'le' | 'be'; - - class BN { - constructor(num: number | string | number[] | Buffer, base?: number, endian?: Endianness); - public clone(): BN; - public toString(base?: number, length?: number): string; - public toNumber(): number; - public toJSON(): string; - public toArray(endian?: Endianness, length?: number): number[]; - public toBuffer(endian?: Endianness, length?: number): Buffer; - public bitLength(): number; - public zeroBits(): number; - public byteLength(): number; - public isNeg(): boolean; - public isEven(): boolean; - public isOdd(): boolean; - public isZero(): boolean; - public cmp(b: any): number; - public lt(b: any): boolean; - public lte(b: any): boolean; - public gt(b: any): boolean; - public gte(b: any): boolean; - public eq(b: any): boolean; - public isBN(b: any): boolean; - - public neg(): BN; - public abs(): BN; - public add(b: BN): BN; - public sub(b: BN): BN; - public mul(b: BN): BN; - public sqr(): BN; - public pow(b: BN): BN; - public div(b: BN): BN; - public mod(b: BN): BN; - public divRound(b: BN): BN; - - public or(b: BN): BN; - public and(b: BN): BN; - public xor(b: BN): BN; - public setn(b: number): BN; - public shln(b: number): BN; - public shrn(b: number): BN; - public testn(b: number): boolean; - public maskn(b: number): BN; - public bincn(b: number): BN; - public notn(w: number): BN; - - public gcd(b: BN): BN; - public egcd(b: BN): { a: BN; b: BN; gcd: BN }; - public invm(b: BN): BN; - } - - export = BN; -} diff --git a/packages/typescript-typings/types/compare-versions/index.d.ts b/packages/typescript-typings/types/compare-versions/index.d.ts deleted file mode 100644 index b19e1f94b..000000000 --- a/packages/typescript-typings/types/compare-versions/index.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -// compare-version declarations -declare function compareVersions(firstVersion: string, secondVersion: string): number; -declare module 'compare-versions' { - export = compareVersions; -} diff --git a/packages/typescript-typings/types/ethereumjs-abi/index.d.ts b/packages/typescript-typings/types/ethereumjs-abi/index.d.ts deleted file mode 100644 index e3d660a4a..000000000 --- a/packages/typescript-typings/types/ethereumjs-abi/index.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -declare module 'ethereumjs-abi' { - const soliditySHA3: (argTypes: string[], args: any[]) => Buffer; - const soliditySHA256: (argTypes: string[], args: any[]) => Buffer; - const methodID: (name: string, types: string[]) => Buffer; -} diff --git a/packages/typescript-typings/types/ethereumjs-tx/index.d.ts b/packages/typescript-typings/types/ethereumjs-tx/index.d.ts deleted file mode 100644 index 1b99d06d9..000000000 --- a/packages/typescript-typings/types/ethereumjs-tx/index.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -declare module 'ethereumjs-tx' { - class EthereumTx { - public raw: Buffer[]; - public r: Buffer; - public s: Buffer; - public v: Buffer; - public nonce: Buffer; - public serialize(): Buffer; - public sign(buffer: Buffer): void; - public getSenderAddress(): Buffer; - constructor(txParams: any); - } - export = EthereumTx; -} diff --git a/packages/typescript-typings/types/ethers/index.d.ts b/packages/typescript-typings/types/ethers/index.d.ts index addf85613..d40428a9b 100644 --- a/packages/typescript-typings/types/ethers/index.d.ts +++ b/packages/typescript-typings/types/ethers/index.d.ts @@ -1,5 +1,5 @@ declare module 'ethers' { - import { TxData } from '@0xproject/types'; + import { TxData } from 'ethereum-types'; export interface TransactionDescription { name: string; diff --git a/packages/typescript-typings/types/find-versions/index.d.ts b/packages/typescript-typings/types/find-versions/index.d.ts deleted file mode 100644 index e7c1c6461..000000000 --- a/packages/typescript-typings/types/find-versions/index.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -declare function findVersions(version: string): string[]; -declare module 'find-versions' { - export = findVersions; -} diff --git a/packages/typescript-typings/types/ganache-core/index.d.ts b/packages/typescript-typings/types/ganache-core/index.d.ts index feeb5721e..84635038f 100644 --- a/packages/typescript-typings/types/ganache-core/index.d.ts +++ b/packages/typescript-typings/types/ganache-core/index.d.ts @@ -1,5 +1,5 @@ declare module 'ganache-core' { - import { Provider } from '@0xproject/types'; + import { Provider } from 'ethereum-types'; export interface GanacheOpts { verbose?: boolean; logger?: { diff --git a/packages/typescript-typings/types/hdkey/index.d.ts b/packages/typescript-typings/types/hdkey/index.d.ts deleted file mode 100644 index 84b751bd7..000000000 --- a/packages/typescript-typings/types/hdkey/index.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -declare module 'hdkey' { - class HDNode { - public static fromMasterSeed(seed: Buffer): HDNode; - public publicKey: Buffer; - public privateKey: Buffer; - public chainCode: Buffer; - public constructor(); - public derive(path: string): HDNode; - } - export = HDNode; -} diff --git a/packages/typescript-typings/types/is-mobile/index.d.ts b/packages/typescript-typings/types/is-mobile/index.d.ts deleted file mode 100644 index 0b3b57854..000000000 --- a/packages/typescript-typings/types/is-mobile/index.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -declare function isMobile(): boolean; -declare module 'is-mobile' { - export = isMobile; -} diff --git a/packages/typescript-typings/types/solc/index.d.ts b/packages/typescript-typings/types/solc/index.d.ts index 5a87ac267..571bae101 100644 --- a/packages/typescript-typings/types/solc/index.d.ts +++ b/packages/typescript-typings/types/solc/index.d.ts @@ -114,7 +114,7 @@ declare module 'solc' { message: string; formattedMessage?: string; } - import { ContractAbi } from '@0xproject/types'; + import { ContractAbi } from 'ethereum-types'; export interface StandardContractOutput { abi: ContractAbi; evm: { diff --git a/packages/typescript-typings/types/solidity-parser-antlr/index.d.ts b/packages/typescript-typings/types/solidity-parser-antlr/index.d.ts deleted file mode 100644 index cc1246a0e..000000000 --- a/packages/typescript-typings/types/solidity-parser-antlr/index.d.ts +++ /dev/null @@ -1,314 +0,0 @@ -declare module 'solidity-parser-antlr' { - export interface BaseASTNode { - range: [number, number]; - } - export interface SourceUnit extends BaseASTNode {} - export interface PragmaDirective extends BaseASTNode {} - export interface PragmaName extends BaseASTNode {} - export interface PragmaValue extends BaseASTNode {} - export interface Version extends BaseASTNode {} - export interface VersionOperator extends BaseASTNode {} - export interface VersionConstraint extends BaseASTNode {} - export interface ImportDeclaration extends BaseASTNode {} - export interface ImportDirective extends BaseASTNode {} - export interface ContractDefinition extends BaseASTNode {} - export interface InheritanceSpecifier extends BaseASTNode {} - export interface ContractPart extends BaseASTNode {} - export interface StateVariableDeclaration extends BaseASTNode { - variables: VariableDeclaration[]; - } - export interface UsingForDeclaration extends BaseASTNode {} - export interface StructDefinition extends BaseASTNode {} - export interface ModifierDefinition extends BaseASTNode { - name: string; - } - export interface ModifierInvocation extends BaseASTNode { - name: string; - } - export interface FunctionDefinition extends BaseASTNode { - name: string; - } - export interface ReturnParameters extends BaseASTNode {} - export interface ModifierList extends BaseASTNode {} - export interface EventDefinition extends BaseASTNode {} - export interface EnumValue extends BaseASTNode {} - export interface EnumDefinition extends BaseASTNode {} - export interface ParameterList extends BaseASTNode {} - export interface Parameter extends BaseASTNode {} - export interface EventParameterList extends BaseASTNode {} - export interface EventParameter extends BaseASTNode {} - export interface FunctionTypeParameterList extends BaseASTNode {} - export interface FunctionTypeParameter extends BaseASTNode {} - export interface VariableDeclaration extends BaseASTNode { - visibility: 'public' | 'private'; - isStateVar: boolean; - } - export interface TypeName extends BaseASTNode {} - export interface UserDefinedTypeName extends BaseASTNode {} - export interface Mapping extends BaseASTNode {} - export interface FunctionTypeName extends BaseASTNode {} - export interface StorageLocation extends BaseASTNode {} - export interface StateMutability extends BaseASTNode {} - export interface Block extends BaseASTNode {} - export interface Statement extends BaseASTNode {} - export interface ExpressionStatement extends BaseASTNode { - expression: ASTNode; - } - export interface IfStatement extends BaseASTNode { - trueBody: ASTNode; - falseBody: ASTNode; - } - export interface WhileStatement extends BaseASTNode {} - export interface SimpleStatement extends BaseASTNode {} - export interface ForStatement extends BaseASTNode {} - export interface InlineAssemblyStatement extends BaseASTNode {} - export interface DoWhileStatement extends BaseASTNode {} - export interface ContinueStatement extends BaseASTNode {} - export interface BreakStatement extends BaseASTNode {} - export interface ReturnStatement extends BaseASTNode {} - export interface ThrowStatement extends BaseASTNode {} - export interface VariableDeclarationStatement extends BaseASTNode {} - export interface IdentifierList extends BaseASTNode {} - export interface ElementaryTypeName extends BaseASTNode {} - export interface Expression extends BaseASTNode {} - export interface PrimaryExpression extends BaseASTNode {} - export interface ExpressionList extends BaseASTNode {} - export interface NameValueList extends BaseASTNode {} - export interface NameValue extends BaseASTNode {} - export interface FunctionCallArguments extends BaseASTNode {} - export interface AssemblyBlock extends BaseASTNode {} - export interface AssemblyItem extends BaseASTNode {} - export interface AssemblyExpression extends BaseASTNode {} - export interface AssemblyCall extends BaseASTNode {} - export interface AssemblyLocalDefinition extends BaseASTNode {} - export interface AssemblyAssignment extends BaseASTNode {} - export interface AssemblyIdentifierOrList extends BaseASTNode {} - export interface AssemblyIdentifierList extends BaseASTNode {} - export interface AssemblyStackAssignment extends BaseASTNode {} - export interface LabelDefinition extends BaseASTNode {} - export interface AssemblySwitch extends BaseASTNode {} - export interface AssemblyCase extends BaseASTNode {} - export interface AssemblyFunctionDefinition extends BaseASTNode {} - export interface AssemblyFunctionReturns extends BaseASTNode {} - export interface AssemblyFor extends BaseASTNode {} - export interface AssemblyIf extends BaseASTNode {} - export interface AssemblyLiteral extends BaseASTNode {} - export interface SubAssembly extends BaseASTNode {} - export interface TupleExpression extends BaseASTNode {} - export interface ElementaryTypeNameExpression extends BaseASTNode {} - export interface NumberLiteral extends BaseASTNode {} - export interface Identifier extends BaseASTNode {} - export type BinOp = - | '+' - | '-' - | '*' - | '/' - | '**' - | '%' - | '<<' - | '>>' - | '&&' - | '||' - | '&' - | '|' - | '^' - | '<' - | '>' - | '<=' - | '>=' - | '==' - | '!=' - | '=' - | '|=' - | '^=' - | '&=' - | '<<=' - | '>>=' - | '+=' - | '-=' - | '*=' - | '/=' - | '%='; - export interface BinaryOperation extends BaseASTNode { - left: ASTNode; - right: ASTNode; - operator: BinOp; - } - export interface Conditional extends BaseASTNode { - trueExpression: ASTNode; - falseExpression: ASTNode; - } - - export type ASTNode = - | SourceUnit - | PragmaDirective - | PragmaName - | PragmaValue - | Version - | VersionOperator - | VersionConstraint - | ImportDeclaration - | ImportDirective - | ContractDefinition - | InheritanceSpecifier - | ContractPart - | StateVariableDeclaration - | UsingForDeclaration - | StructDefinition - | ModifierDefinition - | ModifierInvocation - | FunctionDefinition - | ReturnParameters - | ModifierList - | EventDefinition - | EnumValue - | EnumDefinition - | ParameterList - | Parameter - | EventParameterList - | EventParameter - | FunctionTypeParameterList - | FunctionTypeParameter - | VariableDeclaration - | TypeName - | UserDefinedTypeName - | Mapping - | FunctionTypeName - | StorageLocation - | StateMutability - | Block - | Statement - | ExpressionStatement - | IfStatement - | WhileStatement - | SimpleStatement - | ForStatement - | InlineAssemblyStatement - | DoWhileStatement - | ContinueStatement - | BreakStatement - | ReturnStatement - | ThrowStatement - | VariableDeclarationStatement - | IdentifierList - | ElementaryTypeName - | Expression - | PrimaryExpression - | ExpressionList - | NameValueList - | NameValue - | FunctionCallArguments - | AssemblyBlock - | AssemblyItem - | AssemblyExpression - | AssemblyCall - | AssemblyLocalDefinition - | AssemblyAssignment - | AssemblyIdentifierOrList - | AssemblyIdentifierList - | AssemblyStackAssignment - | LabelDefinition - | AssemblySwitch - | AssemblyCase - | AssemblyFunctionDefinition - | AssemblyFunctionReturns - | AssemblyFor - | AssemblyIf - | AssemblyLiteral - | SubAssembly - | TupleExpression - | ElementaryTypeNameExpression - | NumberLiteral - | Identifier - | BinaryOperation - | Conditional; - export interface Visitor { - SourceUnit?: (node: SourceUnit) => void; - PragmaDirective?: (node: PragmaDirective) => void; - PragmaName?: (node: PragmaName) => void; - PragmaValue?: (node: PragmaValue) => void; - Version?: (node: Version) => void; - VersionOperator?: (node: VersionOperator) => void; - VersionConstraint?: (node: VersionConstraint) => void; - ImportDeclaration?: (node: ImportDeclaration) => void; - ImportDirective?: (node: ImportDirective) => void; - ContractDefinition?: (node: ContractDefinition) => void; - InheritanceSpecifier?: (node: InheritanceSpecifier) => void; - ContractPart?: (node: ContractPart) => void; - StateVariableDeclaration?: (node: StateVariableDeclaration) => void; - UsingForDeclaration?: (node: UsingForDeclaration) => void; - StructDefinition?: (node: StructDefinition) => void; - ModifierDefinition?: (node: ModifierDefinition) => void; - ModifierInvocation?: (node: ModifierInvocation) => void; - FunctionDefinition?: (node: FunctionDefinition) => void; - ReturnParameters?: (node: ReturnParameters) => void; - ModifierList?: (node: ModifierList) => void; - EventDefinition?: (node: EventDefinition) => void; - EnumValue?: (node: EnumValue) => void; - EnumDefinition?: (node: EnumDefinition) => void; - ParameterList?: (node: ParameterList) => void; - Parameter?: (node: Parameter) => void; - EventParameterList?: (node: EventParameterList) => void; - EventParameter?: (node: EventParameter) => void; - FunctionTypeParameterList?: (node: FunctionTypeParameterList) => void; - FunctionTypeParameter?: (node: FunctionTypeParameter) => void; - VariableDeclaration?: (node: VariableDeclaration) => void; - TypeName?: (node: TypeName) => void; - UserDefinedTypeName?: (node: UserDefinedTypeName) => void; - Mapping?: (node: Mapping) => void; - FunctionTypeName?: (node: FunctionTypeName) => void; - StorageLocation?: (node: StorageLocation) => void; - StateMutability?: (node: StateMutability) => void; - Block?: (node: Block) => void; - Statement?: (node: Statement) => void; - ExpressionStatement?: (node: ExpressionStatement) => void; - IfStatement?: (node: IfStatement) => void; - WhileStatement?: (node: WhileStatement) => void; - SimpleStatement?: (node: SimpleStatement) => void; - ForStatement?: (node: ForStatement) => void; - InlineAssemblyStatement?: (node: InlineAssemblyStatement) => void; - DoWhileStatement?: (node: DoWhileStatement) => void; - ContinueStatement?: (node: ContinueStatement) => void; - BreakStatement?: (node: BreakStatement) => void; - ReturnStatement?: (node: ReturnStatement) => void; - ThrowStatement?: (node: ThrowStatement) => void; - VariableDeclarationStatement?: (node: VariableDeclarationStatement) => void; - IdentifierList?: (node: IdentifierList) => void; - ElementaryTypeName?: (node: ElementaryTypeName) => void; - Expression?: (node: Expression) => void; - PrimaryExpression?: (node: PrimaryExpression) => void; - ExpressionList?: (node: ExpressionList) => void; - NameValueList?: (node: NameValueList) => void; - NameValue?: (node: NameValue) => void; - FunctionCallArguments?: (node: FunctionCallArguments) => void; - AssemblyBlock?: (node: AssemblyBlock) => void; - AssemblyItem?: (node: AssemblyItem) => void; - AssemblyExpression?: (node: AssemblyExpression) => void; - AssemblyCall?: (node: AssemblyCall) => void; - AssemblyLocalDefinition?: (node: AssemblyLocalDefinition) => void; - AssemblyAssignment?: (node: AssemblyAssignment) => void; - AssemblyIdentifierOrList?: (node: AssemblyIdentifierOrList) => void; - AssemblyIdentifierList?: (node: AssemblyIdentifierList) => void; - AssemblyStackAssignment?: (node: AssemblyStackAssignment) => void; - LabelDefinition?: (node: LabelDefinition) => void; - AssemblySwitch?: (node: AssemblySwitch) => void; - AssemblyCase?: (node: AssemblyCase) => void; - AssemblyFunctionDefinition?: (node: AssemblyFunctionDefinition) => void; - AssemblyFunctionReturns?: (node: AssemblyFunctionReturns) => void; - AssemblyFor?: (node: AssemblyFor) => void; - AssemblyIf?: (node: AssemblyIf) => void; - AssemblyLiteral?: (node: AssemblyLiteral) => void; - SubAssembly?: (node: SubAssembly) => void; - TupleExpression?: (node: TupleExpression) => void; - ElementaryTypeNameExpression?: (node: ElementaryTypeNameExpression) => void; - NumberLiteral?: (node: NumberLiteral) => void; - Identifier?: (node: Identifier) => void; - BinaryOperation?: (node: BinaryOperation) => void; - Conditional?: (node: Conditional) => void; - } - export interface ParserOpts { - range?: boolean; - } - export function parse(sourceCode: string, parserOpts: ParserOpts): ASTNode; - export function visit(ast: ASTNode, visitor: Visitor): void; -} diff --git a/packages/typescript-typings/types/truffle-hdwalet-provider/index.d.ts b/packages/typescript-typings/types/truffle-hdwalet-provider/index.d.ts index af82557cb..007df61e0 100644 --- a/packages/typescript-typings/types/truffle-hdwalet-provider/index.d.ts +++ b/packages/typescript-typings/types/truffle-hdwalet-provider/index.d.ts @@ -1,5 +1,5 @@ declare module 'truffle-hdwallet-provider' { - import { JSONRPCRequestPayload, JSONRPCResponsePayload, Provider } from '@0xproject/types'; + import { JSONRPCRequestPayload, JSONRPCResponsePayload, Provider } from 'ethereum-types'; class HDWalletProvider implements Provider { constructor(mnemonic: string, rpcUrl: string); public sendAsync( diff --git a/packages/typescript-typings/types/web3-provider-engine/index.d.ts b/packages/typescript-typings/types/web3-provider-engine/index.d.ts index 8d5aef749..1733f2731 100644 --- a/packages/typescript-typings/types/web3-provider-engine/index.d.ts +++ b/packages/typescript-typings/types/web3-provider-engine/index.d.ts @@ -1,5 +1,5 @@ declare module 'web3-provider-engine' { - import { Provider, JSONRPCRequestPayload, JSONRPCResponsePayload } from '@0xproject/types'; + import { Provider, JSONRPCRequestPayload, JSONRPCResponsePayload } from 'ethereum-types'; class Web3ProviderEngine implements Provider { public on(event: string, handler: () => void): void; public send(payload: JSONRPCRequestPayload): void; @@ -23,7 +23,7 @@ declare module 'web3-provider-engine/subproviders/subprovider' { export = Subprovider; } declare module 'web3-provider-engine/subproviders/rpc' { - import { JSONRPCRequestPayload, JSONRPCResponsePayload } from '@0xproject/types'; + import { JSONRPCRequestPayload, JSONRPCResponsePayload } from 'ethereum-types'; class RpcSubprovider { constructor(options: { rpcUrl: string }); public handleRequest( @@ -41,7 +41,7 @@ declare module 'web3-provider-engine/util/rpc-cache-utils' { export = ProviderEngineRpcUtils; } declare module 'web3-provider-engine/subproviders/fixture' { - import { JSONRPCRequestPayload, JSONRPCResponsePayload } from '@0xproject/types'; + import { JSONRPCRequestPayload, JSONRPCResponsePayload } from 'ethereum-types'; class FixtureSubprovider { constructor(staticResponses: any); public handleRequest( diff --git a/packages/typescript-typings/types/web3/index.d.ts b/packages/typescript-typings/types/web3/index.d.ts index 15e7575a8..4085c71a7 100644 --- a/packages/typescript-typings/types/web3/index.d.ts +++ b/packages/typescript-typings/types/web3/index.d.ts @@ -16,7 +16,7 @@ declare module 'web3' { LogEntryEvent, JSONRPCRequestPayload, JSONRPCResponsePayload, - } from '@0xproject/types'; + } from 'ethereum-types'; type MixedData = string | number | object | any[] | BigNumber.BigNumber; diff --git a/packages/typescript-typings/types/xml-js/index.d.ts b/packages/typescript-typings/types/xml-js/index.d.ts deleted file mode 100644 index 8e4873aeb..000000000 --- a/packages/typescript-typings/types/xml-js/index.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -declare interface XML2JSONOpts { - compact?: boolean; - spaces?: number; -} -declare module 'xml-js' { - const xml2json: (xml: string, opts: XML2JSONOpts) => string; -} diff --git a/packages/utils/package.json b/packages/utils/package.json index 24551dd93..89daadbec 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -35,7 +35,7 @@ "typescript": "2.7.1" }, "dependencies": { - "@0xproject/types": "^0.7.0", + "ethereum-types": "^0.0.1", "@0xproject/typescript-typings": "^0.3.2", "@types/node": "^8.0.53", "ethereumjs-util": "^5.1.1", diff --git a/packages/utils/src/abi_decoder.ts b/packages/utils/src/abi_decoder.ts index d2d8364ca..ed3297ee1 100644 --- a/packages/utils/src/abi_decoder.ts +++ b/packages/utils/src/abi_decoder.ts @@ -8,7 +8,7 @@ import { LogWithDecodedArgs, RawLog, SolidityTypes, -} from '@0xproject/types'; +} from 'ethereum-types'; import * as ethers from 'ethers'; import * as _ from 'lodash'; @@ -22,7 +22,7 @@ export class AbiDecoder { _.forEach(abiArrays, this.addABI.bind(this)); } // This method can only decode logs from the 0x & ERC20 smart contracts - public tryToDecodeLogOrNoop<ArgsType>(log: LogEntry): LogWithDecodedArgs<ArgsType> | RawLog { + public tryToDecodeLogOrNoop<ArgsType extends DecodedLogArgs>(log: LogEntry): LogWithDecodedArgs<ArgsType> | RawLog { const methodId = log.topics[0]; const event = this._methodIds[methodId]; if (_.isUndefined(event)) { diff --git a/packages/utils/src/abi_utils.ts b/packages/utils/src/abi_utils.ts index c4533d42e..b5822425c 100644 --- a/packages/utils/src/abi_utils.ts +++ b/packages/utils/src/abi_utils.ts @@ -1,4 +1,4 @@ -import { AbiDefinition, AbiType, ConstructorAbi, ContractAbi, DataItem, MethodAbi } from '@0xproject/types'; +import { AbiDefinition, AbiType, ConstructorAbi, ContractAbi, DataItem, MethodAbi } from 'ethereum-types'; import * as _ from 'lodash'; export const abiUtils = { diff --git a/packages/web3-wrapper/package.json b/packages/web3-wrapper/package.json index 18bbf14a0..9baaba391 100644 --- a/packages/web3-wrapper/package.json +++ b/packages/web3-wrapper/package.json @@ -26,7 +26,8 @@ "postpublish": { "docPublishConfigs": { "extraFileIncludes": [ - "../types/src/index.ts" + "../types/src/index.ts", + "../ethereum-types/src/index.ts" ], "s3BucketPath": "s3://doc-jsons/web3-wrapper/", "s3StagingBucketPath": "s3://staging-doc-jsons/web3-wrapper/" @@ -62,9 +63,9 @@ "typescript": "2.7.1" }, "dependencies": { - "@0xproject/types": "^0.7.0", "@0xproject/typescript-typings": "^0.3.2", "@0xproject/utils": "^0.6.2", + "ethereum-types": "^0.0.1", "ethers": "^3.0.15", "lodash": "^4.17.4", "web3": "^0.20.0" diff --git a/packages/web3-wrapper/src/web3_wrapper.ts b/packages/web3-wrapper/src/web3_wrapper.ts index 40a554522..3de152df1 100644 --- a/packages/web3-wrapper/src/web3_wrapper.ts +++ b/packages/web3-wrapper/src/web3_wrapper.ts @@ -1,3 +1,4 @@ +import { AbiDecoder, addressUtils, BigNumber, intervalUtils, promisify } from '@0xproject/utils'; import { BlockParam, BlockWithoutTransactionData, @@ -12,8 +13,7 @@ import { TransactionReceipt, TransactionReceiptWithDecodedLogs, TxData, -} from '@0xproject/types'; -import { AbiDecoder, addressUtils, BigNumber, intervalUtils, promisify } from '@0xproject/utils'; +} from 'ethereum-types'; import * as _ from 'lodash'; import * as Web3 from 'web3'; diff --git a/packages/website/md/docs/sol_cov/usage.md b/packages/website/md/docs/sol_cov/usage.md index 63a88f595..59638f611 100644 --- a/packages/website/md/docs/sol_cov/usage.md +++ b/packages/website/md/docs/sol_cov/usage.md @@ -2,8 +2,47 @@ Sol-cov uses transaction traces in order to figure out which lines of Solidity s The CoverageSubprovider eavesdrops on the `eth_sendTransaction` and `eth_call` RPC calls and collects traces after each call using `debug_traceTransaction`. `eth_call`'s' don't generate traces - so we take a snapshot, re-submit it as a transaction, get the trace and then revert the snapshot. +Coverage subprovider needs some info about your contracts (`srcMap`, `bytecode`). It gets that info from your project's artifacts. Some frameworks have their own artifact format. Some artifact formats don't actually contain all the neccessary data. + +In order to use `CoverageSubprovider` with your favorite framework you need to pass an `artifactsAdapter` to it. + +### Sol-compiler + +If you are generating your artifacts with [@0xproject/sol-compiler](LINK) you can use the `SolCompilerArtifactsAdapter` we've implemented for you. + +```typescript +<<<<<<< HEAD +import { CoverageSubprovider } from '@0xproject/sol-cov'; +======= +import { SolCompilerArtifactsAdapter } from '@0xproject/sol-cov'; +const artifactsPath = 'src/artifacts'; +const contractsPath = 'src/contracts'; +const artifactsAdapter = new SolCompilerArtifactsAdapter(artifactsPath, contractsPath); +``` + +### Truffle + +If your project is using [Truffle](LINK), we've written a `TruffleArtifactsAdapter`for you. + +```typescript +import { TruffleArtifactAdapter } from '@0xproject/sol-cov'; +const contractsPath = 'src/contracts'; +const artifactAdapter = new TruffleArtifactAdapter(contractsDir); +``` + +Because truffle artifacts don't have all the data we need - we actually will recompile your contracts under the hood. That's why you don't need to pass an `artifactsPath`. + +### Other framework/toolset + +You'll need to write your own artifacts adapter. It should extend `AbstractArtifactsAdapter`. +Look at the code of the two adapters above for examples. + +### Usage + ```typescript import { CoverageSubprovider } from '@0xproject/sol-cov'; +import ProviderEngine = require('web3-provider-engine'); +>>>>>>> Improve sol-cov docs const provider = new ProviderEngine(); @@ -12,15 +51,20 @@ const contractsPath = 'src/contracts'; const networkId = 50; // Some calls might not have `from` address specified. Nevertheless - transactions need to be submitted from an address with at least some funds. defaultFromAddress is the address that will be used to submit those calls as transactions from. const defaultFromAddress = '0x5409ed021d9299bf6814279a6a1411a7e866a631'; +<<<<<<< HEAD const coverageSubprovider = new CoverageSubprovider(artifactsPath, contractsPath, defaultFromAddress); +======= +const isVerbose = true; +const coverageSubprovider = new CoverageSubprovider(artifactsAdapter, defaultFromAddress, isVerbose); +>>>>>>> Improve sol-cov docs provider.addProvider(coverageSubprovider); ``` -After your test suite is complete (e.g global `after` hook), you'll need to call: +After your test suite is complete (e.g in the Mocha global `after` hook), you'll need to call: ```typescript await coverageSubprovider.writeCoverageAsync(); ``` -This will create a `coverage.json` file in the `coverage` directory. This file has an [Istanbul format](https://github.com/gotwarlost/istanbul/blob/master/coverage.json.md) - so you can use any of the existing Instanbul reporters. +This will create a `coverage.json` file in a `coverage` directory. This file has an [Istanbul format](https://github.com/gotwarlost/istanbul/blob/master/coverage.json.md) - so you can use it with any of the existing Istanbul reporters. diff --git a/packages/website/package.json b/packages/website/package.json index 95804f988..a17964f2b 100644 --- a/packages/website/package.json +++ b/packages/website/package.json @@ -57,11 +57,13 @@ "web3": "^0.20.0", "web3-provider-engine": "^14.0.4", "whatwg-fetch": "^2.0.3", - "xml-js": "^1.3.2" + "xml-js": "^1.6.4" }, "devDependencies": { "@types/accounting": "^0.4.1", + "@types/blockies": "^0.0.0", "@types/deep-equal": "^1.0.0", + "@types/find-versions": "^2.0.0", "@types/jsonschema": "^1.1.1", "@types/lodash": "4.14.104", "@types/material-ui": "0.18.0", diff --git a/packages/website/ts/blockchain_watcher.ts b/packages/website/ts/blockchain_watcher.ts index c420a98a4..0d376bc74 100644 --- a/packages/website/ts/blockchain_watcher.ts +++ b/packages/website/ts/blockchain_watcher.ts @@ -10,7 +10,7 @@ export class BlockchainWatcher { private _prevNetworkId: number; private _shouldPollUserAddress: boolean; private _watchNetworkAndBalanceIntervalId: NodeJS.Timer; - private _prevUserEtherBalanceInWei: BigNumber; + private _prevUserEtherBalanceInWei?: BigNumber; private _prevUserAddressIfExists: string; constructor( dispatcher: Dispatcher, @@ -41,7 +41,7 @@ export class BlockchainWatcher { } let prevNodeVersion: string; - this._prevUserEtherBalanceInWei = new BigNumber(0); + this._prevUserEtherBalanceInWei = undefined; this._dispatcher.updateNetworkId(this._prevNetworkId); this._watchNetworkAndBalanceIntervalId = intervalUtils.setAsyncExcludingInterval( async () => { @@ -94,7 +94,7 @@ export class BlockchainWatcher { } private async _updateUserWeiBalanceAsync(userAddress: string): Promise<void> { const balanceInWei = await this._web3Wrapper.getBalanceInWeiAsync(userAddress); - if (!balanceInWei.eq(this._prevUserEtherBalanceInWei)) { + if (_.isUndefined(this._prevUserEtherBalanceInWei) || !balanceInWei.eq(this._prevUserEtherBalanceInWei)) { this._prevUserEtherBalanceInWei = balanceInWei; this._dispatcher.updateUserWeiBalance(balanceInWei); } diff --git a/packages/website/ts/components/eth_weth_conversion_button.tsx b/packages/website/ts/components/eth_weth_conversion_button.tsx index 4b91a2ebd..2fb35cc1c 100644 --- a/packages/website/ts/components/eth_weth_conversion_button.tsx +++ b/packages/website/ts/components/eth_weth_conversion_button.tsx @@ -18,7 +18,7 @@ interface EthWethConversionButtonProps { ethToken: Token; dispatcher: Dispatcher; blockchain: Blockchain; - userEtherBalanceInWei: BigNumber; + userEtherBalanceInWei?: BigNumber; isOutdatedWrappedEther: boolean; onConversionSuccessful?: () => void; isDisabled?: boolean; diff --git a/packages/website/ts/components/eth_wrappers.tsx b/packages/website/ts/components/eth_wrappers.tsx index a5758a66a..1db5ff77f 100644 --- a/packages/website/ts/components/eth_wrappers.tsx +++ b/packages/website/ts/components/eth_wrappers.tsx @@ -33,7 +33,7 @@ interface EthWrappersProps { dispatcher: Dispatcher; tokenByAddress: TokenByAddress; userAddress: string; - userEtherBalanceInWei: BigNumber; + userEtherBalanceInWei?: BigNumber; lastForceTokenStateRefetch: number; } diff --git a/packages/website/ts/components/legacy_portal/legacy_portal.tsx b/packages/website/ts/components/legacy_portal/legacy_portal.tsx index a5ea95629..e5d152e3e 100644 --- a/packages/website/ts/components/legacy_portal/legacy_portal.tsx +++ b/packages/website/ts/components/legacy_portal/legacy_portal.tsx @@ -38,6 +38,7 @@ import { } from 'ts/types'; import { configs } from 'ts/utils/configs'; import { constants } from 'ts/utils/constants'; +import { orderParser } from 'ts/utils/order_parser'; import { Translate } from 'ts/utils/translate'; import { utils } from 'ts/utils/utils'; @@ -55,7 +56,7 @@ export interface LegacyPortalProps { providerType: ProviderType; screenWidth: ScreenWidths; tokenByAddress: TokenByAddress; - userEtherBalanceInWei: BigNumber; + userEtherBalanceInWei?: BigNumber; userAddress: string; shouldBlockchainErrDialogBeOpen: boolean; userSuppliedOrderCache: Order; @@ -86,7 +87,7 @@ export class LegacyPortal extends React.Component<LegacyPortalProps, LegacyPorta } constructor(props: LegacyPortalProps) { super(props); - this._sharedOrderIfExists = this._getSharedOrderIfExists(); + this._sharedOrderIfExists = orderParser.parse(window.location.search); this._throttledScreenWidthUpdate = _.throttle(this._updateScreenWidth.bind(this), THROTTLE_TIMEOUT); const isViewingBalances = _.includes(props.location.pathname, `${WebsitePaths.Portal}/balances`); @@ -362,32 +363,6 @@ export class LegacyPortal extends React.Component<LegacyPortalProps, LegacyPorta isWethNoticeDialogOpen: false, }); } - private _getSharedOrderIfExists(): Order | undefined { - const queryString = window.location.search; - if (queryString.length === 0) { - return undefined; - } - const queryParams = queryString.substring(1).split('&'); - const orderQueryParam = _.find(queryParams, queryParam => { - const queryPair = queryParam.split('='); - return queryPair[0] === 'order'; - }); - if (_.isUndefined(orderQueryParam)) { - return undefined; - } - const orderPair = orderQueryParam.split('='); - if (orderPair.length !== 2) { - return undefined; - } - - const order = JSON.parse(decodeURIComponent(orderPair[1])); - const validationResult = validator.validate(order, portalOrderSchema); - if (validationResult.errors.length > 0) { - logUtils.log(`Invalid shared order: ${validationResult.errors}`); - return undefined; - } - return order; - } private _updateScreenWidth(): void { const newScreenWidth = utils.getScreenWidth(); this.props.dispatcher.updateScreenWidth(newScreenWidth); diff --git a/packages/website/ts/components/onboarding/portal_onboarding_flow.tsx b/packages/website/ts/components/onboarding/portal_onboarding_flow.tsx index edaeb3736..2014dd7b0 100644 --- a/packages/website/ts/components/onboarding/portal_onboarding_flow.tsx +++ b/packages/website/ts/components/onboarding/portal_onboarding_flow.tsx @@ -14,7 +14,7 @@ export interface PortalOnboardingFlowProps { providerType: ProviderType; injectedProviderName: string; blockchainIsLoaded: boolean; - userEthBalanceInWei: BigNumber; + userEtherBalanceInWei?: BigNumber; tokenByAddress: TokenByAddress; updateIsRunning: (isRunning: boolean) => void; updateOnboardingStep: (stepIndex: number) => void; @@ -85,7 +85,7 @@ export class PortalOnboardingFlow extends React.Component<PortalOnboardingFlowPr } private _userHasEth(): boolean { - return this.props.userEthBalanceInWei > new BigNumber(0); + return this.props.userEtherBalanceInWei > new BigNumber(0); } private _userHasWeth(): boolean { diff --git a/packages/website/ts/components/portal/menu.tsx b/packages/website/ts/components/portal/menu.tsx index 6a3301549..6e97ee37e 100644 --- a/packages/website/ts/components/portal/menu.tsx +++ b/packages/website/ts/components/portal/menu.tsx @@ -43,9 +43,14 @@ export const defaultMenuItemEntries: MenuItemEntry[] = [ iconName: 'zmdi-circle-o', }, { - to: `${WebsitePaths.Portal}/direct`, - labelText: 'Trade direct', - iconName: 'zmdi-swap', + to: `${WebsitePaths.Portal}/generate`, + labelText: 'Generate order', + iconName: 'zmdi-arrow-right-top', + }, + { + to: `${WebsitePaths.Portal}/fill`, + labelText: 'Fill order', + iconName: 'zmdi-arrow-left-bottom', }, ]; diff --git a/packages/website/ts/components/portal/portal.tsx b/packages/website/ts/components/portal/portal.tsx index 0e1506e17..589ad00ad 100644 --- a/packages/website/ts/components/portal/portal.tsx +++ b/packages/website/ts/components/portal/portal.tsx @@ -10,6 +10,7 @@ import { BlockchainErrDialog } from 'ts/components/dialogs/blockchain_err_dialog import { LedgerConfigDialog } from 'ts/components/dialogs/ledger_config_dialog'; import { PortalDisclaimerDialog } from 'ts/components/dialogs/portal_disclaimer_dialog'; import { EthWrappers } from 'ts/components/eth_wrappers'; +import { FillOrder } from 'ts/components/fill_order'; import { AssetPicker } from 'ts/components/generate_order/asset_picker'; import { BackButton } from 'ts/components/portal/back_button'; import { Loading } from 'ts/components/portal/loading'; @@ -42,6 +43,7 @@ import { } from 'ts/types'; import { configs } from 'ts/utils/configs'; import { constants } from 'ts/utils/constants'; +import { orderParser } from 'ts/utils/order_parser'; import { Translate } from 'ts/utils/translate'; import { utils } from 'ts/utils/utils'; @@ -57,7 +59,7 @@ export interface PortalProps { providerType: ProviderType; screenWidth: ScreenWidths; tokenByAddress: TokenByAddress; - userEtherBalanceInWei: BigNumber; + userEtherBalanceInWei?: BigNumber; userAddress: string; shouldBlockchainErrDialogBeOpen: boolean; userSuppliedOrderCache: Order; @@ -116,9 +118,11 @@ const styles: Styles = { export class Portal extends React.Component<PortalProps, PortalState> { private _blockchain: Blockchain; + private _sharedOrderIfExists: Order; private _throttledScreenWidthUpdate: () => void; constructor(props: PortalProps) { super(props); + this._sharedOrderIfExists = orderParser.parse(window.location.search); this._throttledScreenWidthUpdate = _.throttle(this._updateScreenWidth.bind(this), THROTTLE_TIMEOUT); const didAcceptPortalDisclaimer = localStorage.getItemIfExists(constants.LOCAL_STORAGE_KEY_ACCEPT_DISCLAIMER); const hasAcceptedDisclaimer = @@ -336,9 +340,14 @@ export class Portal extends React.Component<PortalProps, PortalState> { render: this._renderTradeHistory.bind(this), }, { - pathName: `${WebsitePaths.Portal}/direct`, - headerText: 'Trade Direct', - render: this._renderTradeDirect.bind(this), + pathName: `${WebsitePaths.Portal}/generate`, + headerText: 'Generate Order', + render: this._renderGenerateOrderForm.bind(this), + }, + { + pathName: `${WebsitePaths.Portal}/fill`, + headerText: 'Fill Order', + render: this._renderFillOrder.bind(this), }, ]; return ( @@ -386,7 +395,7 @@ export class Portal extends React.Component<PortalProps, PortalState> { /> ); } - private _renderTradeDirect(match: any, location: Location, history: History): React.ReactNode { + private _renderGenerateOrderForm(): React.ReactNode { return ( <GenerateOrderForm blockchain={this._blockchain} @@ -395,6 +404,25 @@ export class Portal extends React.Component<PortalProps, PortalState> { /> ); } + private _renderFillOrder(): React.ReactNode { + const initialFillOrder = !_.isUndefined(this.props.userSuppliedOrderCache) + ? this.props.userSuppliedOrderCache + : this._sharedOrderIfExists; + return ( + <FillOrder + blockchain={this._blockchain} + blockchainErr={this.props.blockchainErr} + initialOrder={initialFillOrder} + isOrderInUrl={!_.isUndefined(this._sharedOrderIfExists)} + orderFillAmount={this.props.orderFillAmount} + networkId={this.props.networkId} + userAddress={this.props.userAddress} + tokenByAddress={this.props.tokenByAddress} + dispatcher={this.props.dispatcher} + lastForceTokenStateRefetch={this.props.lastForceTokenStateRefetch} + /> + ); + } private _renderTokenBalances(): React.ReactNode { const allTokens = _.values(this.props.tokenByAddress); const trackedTokens = _.filter(allTokens, t => t.isTracked); diff --git a/packages/website/ts/components/token_balances.tsx b/packages/website/ts/components/token_balances.tsx index f5a51dabb..7a0742bbe 100644 --- a/packages/website/ts/components/token_balances.tsx +++ b/packages/website/ts/components/token_balances.tsx @@ -85,6 +85,9 @@ interface TokenBalancesState { } export class TokenBalances extends React.Component<TokenBalancesProps, TokenBalancesState> { + public static defaultProps: Partial<TokenBalancesProps> = { + userEtherBalanceInWei: new BigNumber(0), + }; private _isUnmounted: boolean; public constructor(props: TokenBalancesProps) { super(props); diff --git a/packages/website/ts/components/top_bar/provider_display.tsx b/packages/website/ts/components/top_bar/provider_display.tsx index 679ec07dc..8a337119a 100644 --- a/packages/website/ts/components/top_bar/provider_display.tsx +++ b/packages/website/ts/components/top_bar/provider_display.tsx @@ -1,5 +1,6 @@ import { Styles } from '@0xproject/react-shared'; import * as _ from 'lodash'; +import CircularProgress from 'material-ui/CircularProgress'; import RaisedButton from 'material-ui/RaisedButton'; import * as React from 'react'; @@ -23,7 +24,8 @@ export interface ProviderDisplayProps { injectedProviderName: string; providerType: ProviderType; onToggleLedgerDialog: () => void; - blockchain: Blockchain; + blockchain?: Blockchain; + blockchainIsLoaded: boolean; } interface ProviderDisplayState {} @@ -44,11 +46,18 @@ export class ProviderDisplay extends React.Component<ProviderDisplayProps, Provi this.props.providerType, this.props.injectedProviderName, ); - const displayAddress = isAddressAvailable - ? utils.getAddressBeginAndEnd(this.props.userAddress) - : isExternallyInjectedProvider - ? 'Account locked' - : '0x0000...0000'; + let displayMessage; + if (!this._isBlockchainReady()) { + displayMessage = 'loading account'; + } else if (isAddressAvailable) { + displayMessage = utils.getAddressBeginAndEnd(this.props.userAddress); + // tslint:disable-next-line: prefer-conditional-expression + } else if (isExternallyInjectedProvider) { + displayMessage = 'Account locked'; + } else { + displayMessage = '0x0000...0000'; + } + // If the "injected" provider is our fallback public node, then we want to // show the "connect a wallet" message instead of the providerName const injectedProviderName = isExternallyInjectedProvider @@ -60,10 +69,14 @@ export class ProviderDisplay extends React.Component<ProviderDisplayProps, Provi const hoverActiveNode = ( <div className="flex right lg-pr0 md-pr2 sm-pr2 p1" style={styles.root}> <div> - <Identicon address={this.props.userAddress} diameter={ROOT_HEIGHT} /> + {this._isBlockchainReady() ? ( + <Identicon address={this.props.userAddress} diameter={ROOT_HEIGHT} /> + ) : ( + <CircularProgress size={ROOT_HEIGHT} thickness={2} /> + )} </div> <div style={{ marginLeft: 12, paddingTop: 3 }}> - <div style={{ fontSize: 16, color: colors.darkGrey }}>{displayAddress}</div> + <div style={{ fontSize: 16, color: colors.darkGrey }}>{displayMessage}</div> </div> {isProviderMetamask && ( <div style={{ marginLeft: 16 }}> @@ -87,7 +100,9 @@ export class ProviderDisplay extends React.Component<ProviderDisplayProps, Provi ); } public renderPopoverContent(hasInjectedProvider: boolean, hasLedgerProvider: boolean): React.ReactNode { - if (hasInjectedProvider || hasLedgerProvider) { + if (!this._isBlockchainReady()) { + return null; + } else if (hasInjectedProvider || hasLedgerProvider) { return ( <ProviderPicker dispatcher={this.props.dispatcher} @@ -159,4 +174,7 @@ export class ProviderDisplay extends React.Component<ProviderDisplayProps, Provi ); } } + private _isBlockchainReady(): boolean { + return this.props.blockchainIsLoaded && !_.isUndefined(this.props.blockchain); + } } diff --git a/packages/website/ts/components/top_bar/top_bar.tsx b/packages/website/ts/components/top_bar/top_bar.tsx index db8e3cb82..e2d791ae3 100644 --- a/packages/website/ts/components/top_bar/top_bar.tsx +++ b/packages/website/ts/components/top_bar/top_bar.tsx @@ -261,7 +261,7 @@ export class TopBar extends React.Component<TopBarProps, TopBarState> { </div> </div> )} - {this.props.blockchainIsLoaded && ( + {this._isViewingPortal() && ( <div className="sm-hide xs-hide col col-5" style={{ paddingTop: 8, marginRight: 36 }}> <ProviderDisplay dispatcher={this.props.dispatcher} @@ -271,6 +271,7 @@ export class TopBar extends React.Component<TopBarProps, TopBarState> { providerType={this.props.providerType} onToggleLedgerDialog={this.props.onToggleLedgerDialog} blockchain={this.props.blockchain} + blockchainIsLoaded={this.props.blockchainIsLoaded} /> </div> )} diff --git a/packages/website/ts/components/wallet/wallet.tsx b/packages/website/ts/components/wallet/wallet.tsx index 30d1285f4..18dada22f 100644 --- a/packages/website/ts/components/wallet/wallet.tsx +++ b/packages/website/ts/components/wallet/wallet.tsx @@ -7,6 +7,7 @@ import { import { BigNumber } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import * as _ from 'lodash'; +import CircularProgress from 'material-ui/CircularProgress'; import FlatButton from 'material-ui/FlatButton'; import FloatingActionButton from 'material-ui/FloatingActionButton'; import { ListItem } from 'material-ui/List'; @@ -23,6 +24,7 @@ import firstBy = require('thenby'); import { Blockchain } from 'ts/blockchain'; import { AllowanceToggle } from 'ts/components/inputs/allowance_toggle'; +import { Container } from 'ts/components/ui/container'; import { IconButton } from 'ts/components/ui/icon_button'; import { Identicon } from 'ts/components/ui/identicon'; import { Island } from 'ts/components/ui/island'; @@ -59,7 +61,7 @@ export interface WalletProps { dispatcher: Dispatcher; tokenByAddress: TokenByAddress; trackedTokens: Token[]; - userEtherBalanceInWei: BigNumber; + userEtherBalanceInWei?: BigNumber; lastForceTokenStateRefetch: number; injectedProviderName: string; providerType: ProviderType; @@ -92,9 +94,6 @@ const styles: Styles = { zIndex: zIndex.aboveOverlay, position: 'relative', }, - headerItemInnerDiv: { - paddingLeft: 65, - }, footerItemInnerDiv: { paddingLeft: 24, borderTopColor: colors.walletBorder, @@ -108,6 +107,7 @@ const styles: Styles = { }, tokenItem: { backgroundColor: colors.walletDefaultItemBackground, + minHeight: 85, }, amountLabel: { fontWeight: 'bold', @@ -129,10 +129,13 @@ const styles: Styles = { color: colors.mediumBlue, fontWeight: 'bold', }, + loadingBody: { + height: 381, + }, }; const ETHER_ICON_PATH = '/images/ether.png'; -const ICON_DIMENSION = 24; +const ICON_DIMENSION = 28; const TOKEN_AMOUNT_DISPLAY_PRECISION = 3; const BODY_ITEM_KEY = 'BODY'; const HEADER_ITEM_KEY = 'HEADER'; @@ -191,26 +194,40 @@ export class Wallet extends React.Component<WalletProps, WalletState> { } } public render(): React.ReactNode { - const isReadyToRender = this.props.blockchainIsLoaded && this.props.blockchainErr === BlockchainErrs.NoError; - const isAddressAvailable = !_.isEmpty(this.props.userAddress); + const isBlockchainLoaded = this.props.blockchainIsLoaded && this.props.blockchainErr === BlockchainErrs.NoError; return ( <Island className="flex flex-column wallet" style={styles.root}> - {isReadyToRender && isAddressAvailable - ? _.concat(this._renderConnectedHeaderRows(), this._renderBody(), this._renderFooterRows()) - : _.concat(this._renderDisconnectedHeaderRows(), this._renderDisconnectedRows())} + {isBlockchainLoaded ? this._renderLoadedRows() : this._renderLoadingRows()} </Island> ); } + private _renderLoadedRows(): React.ReactNode { + const isAddressAvailable = !_.isEmpty(this.props.userAddress); + return isAddressAvailable + ? _.concat(this._renderConnectedHeaderRows(), this._renderBody(), this._renderFooterRows()) + : _.concat(this._renderDisconnectedHeaderRows(), this._renderDisconnectedRows()); + } + private _renderLoadingRows(): React.ReactNode { + return _.concat(this._renderDisconnectedHeaderRows(), this._renderLoadingBodyRows()); + } + private _renderLoadingBodyRows(): React.ReactElement<{}> { + return ( + <div key={BODY_ITEM_KEY} className="flex items-center" style={styles.loadingBody}> + <div className="mx-auto"> + <CircularProgress size={40} thickness={5} /> + </div> + </div> + ); + } private _renderDisconnectedHeaderRows(): React.ReactElement<{}> { const userAddress = this.props.userAddress; const primaryText = 'wallet'; return ( - <ListItem + <StandardIconRow key={HEADER_ITEM_KEY} - primaryText={primaryText.toUpperCase()} - leftIcon={<ActionAccountBalanceWallet color={colors.mediumBlue} />} - style={styles.paddedItem} - innerDivStyle={styles.headerItemInnerDiv} + icon={<ActionAccountBalanceWallet color={colors.mediumBlue} />} + main={primaryText.toUpperCase()} + style={styles.borderedItem} /> ); } @@ -229,11 +246,10 @@ export class Wallet extends React.Component<WalletProps, WalletState> { const primaryText = utils.getAddressBeginAndEnd(userAddress); return ( <Link key={HEADER_ITEM_KEY} to={ACCOUNT_PATH} style={{ textDecoration: 'none' }}> - <ListItem - primaryText={primaryText} - leftIcon={<Identicon address={userAddress} diameter={ICON_DIMENSION} />} - style={{ ...styles.paddedItem, ...styles.borderedItem }} - innerDivStyle={styles.headerItemInnerDiv} + <StandardIconRow + icon={<Identicon address={userAddress} diameter={ICON_DIMENSION} />} + main={primaryText} + style={styles.borderedItem} /> </Link> ); @@ -320,26 +336,23 @@ export class Wallet extends React.Component<WalletProps, WalletState> { private _renderEthRows(): React.ReactNode { const icon = <img style={{ width: ICON_DIMENSION, height: ICON_DIMENSION }} src={ETHER_ICON_PATH} />; const primaryText = this._renderAmount( - this.props.userEtherBalanceInWei, + this.props.userEtherBalanceInWei || new BigNumber(0), constants.DECIMAL_PLACES_ETH, constants.ETHER_SYMBOL, + _.isUndefined(this.props.userEtherBalanceInWei), ); const etherToken = this._getEthToken(); - const etherPrice = this.state.trackedTokenStateByAddress[etherToken.address].price; + const etherTokenState = this.state.trackedTokenStateByAddress[etherToken.address]; + const etherPrice = etherTokenState.price; const secondaryText = this._renderValue( - this.props.userEtherBalanceInWei, + this.props.userEtherBalanceInWei || new BigNumber(0), constants.DECIMAL_PLACES_ETH, etherPrice, + _.isUndefined(this.props.userEtherBalanceInWei) || !etherTokenState.isLoaded, ); const accessoryItemConfig = { wrappedEtherDirection: Side.Deposit, }; - const isInWrappedEtherState = - !_.isUndefined(this.state.wrappedEtherDirection) && - this.state.wrappedEtherDirection === accessoryItemConfig.wrappedEtherDirection; - const style = isInWrappedEtherState - ? { ...walletItemStyles.focusedItem, ...styles.paddedItem } - : { ...styles.tokenItem, ...styles.borderedItem, ...styles.paddedItem }; const key = ETHER_ITEM_KEY; return this._renderBalanceRow(key, icon, primaryText, secondaryText, accessoryItemConfig, 'eth-row'); } @@ -360,10 +373,15 @@ export class Wallet extends React.Component<WalletProps, WalletState> { EtherscanLinkSuffixes.Address, ); const icon = <TokenIcon token={token} diameter={ICON_DIMENSION} link={tokenLink} />; - const primaryText = this._renderAmount(tokenState.balance, token.decimals, token.symbol); - const secondaryText = this._renderValue(tokenState.balance, token.decimals, tokenState.price); const isWeth = token.symbol === constants.ETHER_TOKEN_SYMBOL; const wrappedEtherDirection = isWeth ? Side.Receive : undefined; + const primaryText = this._renderAmount(tokenState.balance, token.decimals, token.symbol, !tokenState.isLoaded); + const secondaryText = this._renderValue( + tokenState.balance, + token.decimals, + tokenState.price, + !tokenState.isLoaded, + ); const accessoryItemConfig: AccessoryItemConfig = { wrappedEtherDirection, allowanceToggleConfig: { @@ -391,22 +409,24 @@ export class Wallet extends React.Component<WalletProps, WalletState> { ): React.ReactNode { const shouldShowWrapEtherItem = !_.isUndefined(this.state.wrappedEtherDirection) && - this.state.wrappedEtherDirection === accessoryItemConfig.wrappedEtherDirection; - const style = shouldShowWrapEtherItem - ? { ...walletItemStyles.focusedItem, ...styles.paddedItem } - : { ...styles.tokenItem, ...styles.borderedItem, ...styles.paddedItem }; + this.state.wrappedEtherDirection === accessoryItemConfig.wrappedEtherDirection && + !_.isUndefined(this.props.userEtherBalanceInWei); + const additionalStyle = shouldShowWrapEtherItem ? walletItemStyles.focusedItem : styles.borderedItem; + const style = { ...styles.tokenItem, ...additionalStyle }; const etherToken = this._getEthToken(); return ( <div key={key} className={`flex flex-column ${className || ''}`}> - <div className="flex items-center" style={style}> - <div className="px2">{icon}</div> - <div className="flex-none pr2 pt2 pb2"> - {primaryText} - {secondaryText} - </div> - <div className="flex-auto" /> - <div>{this._renderAccessoryItems(accessoryItemConfig)}</div> - </div> + <StandardIconRow + icon={icon} + main={ + <div className="flex flex-column"> + {primaryText} + <Container marginTop="3px">{secondaryText}</Container> + </div> + } + accessory={this._renderAccessoryItems(accessoryItemConfig)} + style={style} + /> {shouldShowWrapEtherItem && ( <WrapEtherItem userAddress={this.props.userAddress} @@ -458,21 +478,45 @@ export class Wallet extends React.Component<WalletProps, WalletState> { /> ); } - private _renderAmount(amount: BigNumber, decimals: number, symbol: string): React.ReactNode { + private _renderAmount( + amount: BigNumber, + decimals: number, + symbol: string, + isLoading: boolean = false, + ): React.ReactNode { const unitAmount = Web3Wrapper.toUnitAmount(amount, decimals); const formattedAmount = unitAmount.toPrecision(TOKEN_AMOUNT_DISPLAY_PRECISION); const result = `${formattedAmount} ${symbol}`; - return <div style={styles.amountLabel}>{result}</div>; + return ( + <PlaceHolder hideChildren={isLoading}> + <div style={styles.amountLabel}>{result}</div> + </PlaceHolder> + ); } - private _renderValue(amount: BigNumber, decimals: number, price?: BigNumber): React.ReactNode { - if (_.isUndefined(price)) { - return null; + private _renderValue( + amount: BigNumber, + decimals: number, + price?: BigNumber, + isLoading: boolean = false, + ): React.ReactNode { + let result; + if (!isLoading) { + if (_.isUndefined(price)) { + result = '--'; + } else { + const unitAmount = Web3Wrapper.toUnitAmount(amount, decimals); + const value = unitAmount.mul(price); + const formattedAmount = value.toFixed(USD_DECIMAL_PLACES); + result = `$${formattedAmount}`; + } + } else { + result = '$0.00'; } - const unitAmount = Web3Wrapper.toUnitAmount(amount, decimals); - const value = unitAmount.mul(price); - const formattedAmount = value.toFixed(USD_DECIMAL_PLACES); - const result = `$${formattedAmount}`; - return <div style={styles.valueLabel}>{result}</div>; + return ( + <PlaceHolder hideChildren={isLoading}> + <div style={styles.valueLabel}>{result}</div> + </PlaceHolder> + ); } private _renderWrappedEtherButton(wrappedEtherDirection: Side): React.ReactNode { const isWrappedEtherDirectionOpen = this.state.wrappedEtherDirection === wrappedEtherDirection; @@ -589,4 +633,41 @@ export class Wallet extends React.Component<WalletProps, WalletState> { private _getEthToken(): Token { return utils.getEthToken(this.props.tokenByAddress); } -} // tslint:disable:max-file-line-count +} + +interface StandardIconRowProps { + icon: React.ReactNode; + main: React.ReactNode; + accessory?: React.ReactNode; + style?: React.CSSProperties; +} +const StandardIconRow = (props: StandardIconRowProps) => { + return ( + <div className="flex items-center" style={props.style}> + <div className="p2">{props.icon}</div> + <div className="flex-none pr2 pt2 pb2">{props.main}</div> + <div className="flex-auto" /> + <div>{props.accessory}</div> + </div> + ); +}; +interface PlaceHolderProps { + hideChildren: React.ReactNode; + children?: React.ReactNode; +} +const PlaceHolder = (props: PlaceHolderProps) => { + const rootBackgroundColor = props.hideChildren ? colors.lightGrey : 'transparent'; + const rootStyle: React.CSSProperties = { + backgroundColor: rootBackgroundColor, + display: 'inline-block', + borderRadius: 2, + }; + const childrenVisibility = props.hideChildren ? 'hidden' : 'visible'; + const childrenStyle: React.CSSProperties = { visibility: childrenVisibility }; + return ( + <div style={rootStyle}> + <div style={childrenStyle}>{props.children}</div> + </div> + ); +}; +// tslint:disable:max-file-line-count diff --git a/packages/website/ts/components/wallet/wallet_disconnected_item.tsx b/packages/website/ts/components/wallet/wallet_disconnected_item.tsx index 39a62e1fb..17fd8a19e 100644 --- a/packages/website/ts/components/wallet/wallet_disconnected_item.tsx +++ b/packages/website/ts/components/wallet/wallet_disconnected_item.tsx @@ -31,7 +31,7 @@ const styles: Styles = { }, }; -const ITEM_HEIGHT = 292; +const ITEM_HEIGHT = 381; const METAMASK_ICON_WIDTH = 35; const LEDGER_ICON_WIDTH = 30; const BUTTON_BOTTOM_PADDING = 80; diff --git a/packages/website/ts/containers/legacy_portal.ts b/packages/website/ts/containers/legacy_portal.ts index 3b1172a44..eae450c21 100644 --- a/packages/website/ts/containers/legacy_portal.ts +++ b/packages/website/ts/containers/legacy_portal.ts @@ -24,7 +24,7 @@ interface ConnectedState { providerType: ProviderType; tokenByAddress: TokenByAddress; lastForceTokenStateRefetch: number; - userEtherBalanceInWei: BigNumber; + userEtherBalanceInWei?: BigNumber; screenWidth: ScreenWidths; shouldBlockchainErrDialogBeOpen: boolean; userAddress: string; diff --git a/packages/website/ts/containers/portal.ts b/packages/website/ts/containers/portal.ts index 3f0feb6e9..b8c8fb999 100644 --- a/packages/website/ts/containers/portal.ts +++ b/packages/website/ts/containers/portal.ts @@ -21,7 +21,7 @@ interface ConnectedState { providerType: ProviderType; tokenByAddress: TokenByAddress; lastForceTokenStateRefetch: number; - userEtherBalanceInWei: BigNumber; + userEtherBalanceInWei?: BigNumber; screenWidth: ScreenWidths; shouldBlockchainErrDialogBeOpen: boolean; userAddress: string; diff --git a/packages/website/ts/containers/portal_onboarding_flow.ts b/packages/website/ts/containers/portal_onboarding_flow.ts index 84739192f..8202fb2ae 100644 --- a/packages/website/ts/containers/portal_onboarding_flow.ts +++ b/packages/website/ts/containers/portal_onboarding_flow.ts @@ -17,7 +17,7 @@ interface ConnectedState { providerType: ProviderType; injectedProviderName: string; blockchainIsLoaded: boolean; - userEthBalanceInWei: BigNumber; + userEtherBalanceInWei?: BigNumber; tokenByAddress: TokenByAddress; } @@ -33,7 +33,7 @@ const mapStateToProps = (state: State): ConnectedState => ({ providerType: state.providerType, injectedProviderName: state.injectedProviderName, blockchainIsLoaded: state.blockchainIsLoaded, - userEthBalanceInWei: state.userEtherBalanceInWei, + userEtherBalanceInWei: state.userEtherBalanceInWei, tokenByAddress: state.tokenByAddress, hasBeenSeen: state.hasPortalOnboardingBeenSeen, }); diff --git a/packages/website/ts/containers/sol_cov_documentation.ts b/packages/website/ts/containers/sol_cov_documentation.ts index 58755c1e0..bc05b6854 100644 --- a/packages/website/ts/containers/sol_cov_documentation.ts +++ b/packages/website/ts/containers/sol_cov_documentation.ts @@ -22,6 +22,9 @@ const docSections = { installation: 'installation', usage: 'usage', coverageSubprovider: 'coverageSubprovider', + abstractArtifactAdapter: 'abstractArtifactAdapter', + solCompilerArtifactAdapter: 'solCompilerArtifactAdapter', + truffleArtifactAdapter: 'truffleArtifactAdapter', types: docConstants.TYPES_SECTION_NAME, }; @@ -34,7 +37,10 @@ const docsInfoConfig: DocsInfoConfig = { introduction: [docSections.introduction], install: [docSections.installation], usage: [docSections.usage], - coverageSubprovider: [docSections.coverageSubprovider], + 'coverage-subprovider': [docSections.coverageSubprovider], + 'abstract-artifact-adapter': [docSections.abstractArtifactAdapter], + 'sol-compiler-artifact-adapter': [docSections.solCompilerArtifactAdapter], + 'truffle-artifact-adapter': [docSections.truffleArtifactAdapter], types: [docSections.types], }, sectionNameToMarkdown: { @@ -44,18 +50,40 @@ const docsInfoConfig: DocsInfoConfig = { }, sectionNameToModulePath: { [docSections.coverageSubprovider]: ['"sol-cov/src/coverage_subprovider"'], + [docSections.abstractArtifactAdapter]: ['"sol-cov/src/artifact_adapters/abstract_artifact_adapter"'], + [docSections.solCompilerArtifactAdapter]: ['"sol-cov/src/artifact_adapters/sol_compiler_artifact_adapter"'], + [docSections.truffleArtifactAdapter]: ['"sol-cov/src/artifact_adapters/truffle_artifact_adapter"'], [docSections.types]: ['"subproviders/src/types"', '"types/src/index"'], }, menuSubsectionToVersionWhenIntroduced: {}, sections: docSections, - visibleConstructors: [docSections.coverageSubprovider], + visibleConstructors: [ + docSections.coverageSubprovider, + docSections.abstractArtifactAdapter, + docSections.solCompilerArtifactAdapter, + docSections.truffleArtifactAdapter, + ], 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: ['NextCallback', 'OnNextCompleted', 'ErrorCallback', 'JSONRPCRequestPayload'], + publicTypes: [ + 'JSONRPCRequestPayload', + 'NextCallback', + 'ErrorCallback', + 'AbstractArtifactAdapter', + 'CoverageSubprovider', + 'TruffleArtifactAdapter', + 'SolCompilerArtifactAdapter', + 'ContractData', + ], typeNameToExternalLink: {}, typeNameToPrefix: {}, - typeNameToDocSection: {}, + typeNameToDocSection: { + AbstractArtifactAdapter: docSections.abstractArtifactAdapter, + CoverageSubprovider: docSections.coverageSubprovider, + TruffleArtifactAdapter: docSections.truffleArtifactAdapter, + SolCompilerArtifactAdapter: docSections.solCompilerArtifactAdapter, + }, }, }; const docsInfo = new DocsInfo(docsInfoConfig); diff --git a/packages/website/ts/redux/dispatcher.ts b/packages/website/ts/redux/dispatcher.ts index 0b4cc3938..e0ce43ae5 100644 --- a/packages/website/ts/redux/dispatcher.ts +++ b/packages/website/ts/redux/dispatcher.ts @@ -155,7 +155,7 @@ export class Dispatcher { type: ActionTypes.UpdateOrderECSignature, }); } - public updateUserWeiBalance(balance: BigNumber): void { + public updateUserWeiBalance(balance?: BigNumber): void { this._dispatch({ data: balance, type: ActionTypes.UpdateUserEtherBalance, diff --git a/packages/website/ts/redux/reducer.ts b/packages/website/ts/redux/reducer.ts index 5c57792f7..9d3d8f7d9 100644 --- a/packages/website/ts/redux/reducer.ts +++ b/packages/website/ts/redux/reducer.ts @@ -39,7 +39,7 @@ export interface State { tokenByAddress: TokenByAddress; lastForceTokenStateRefetch: number; userAddress: string; - userEtherBalanceInWei: BigNumber; + userEtherBalanceInWei?: BigNumber; portalOnboardingStep: number; isPortalOnboardingShowing: boolean; hasPortalOnboardingBeenSeen: boolean; @@ -81,7 +81,7 @@ export const INITIAL_STATE: State = { tokenByAddress: {}, lastForceTokenStateRefetch: moment().unix(), userAddress: '', - userEtherBalanceInWei: new BigNumber(0), + userEtherBalanceInWei: undefined, userSuppliedOrderCache: undefined, portalOnboardingStep: 0, isPortalOnboardingShowing: false, diff --git a/packages/website/ts/utils/order_parser.ts b/packages/website/ts/utils/order_parser.ts new file mode 100644 index 000000000..be08da80e --- /dev/null +++ b/packages/website/ts/utils/order_parser.ts @@ -0,0 +1,33 @@ +import { logUtils } from '@0xproject/utils'; +import * as _ from 'lodash'; + +import { portalOrderSchema } from 'ts/schemas/portal_order_schema'; +import { validator } from 'ts/schemas/validator'; +import { Order } from 'ts/types'; + +export const orderParser = { + parse(queryString: string): Order | undefined { + if (queryString.length === 0) { + return undefined; + } + const queryParams = queryString.substring(1).split('&'); + const orderQueryParam = _.find(queryParams, queryParam => { + const queryPair = queryParam.split('='); + return queryPair[0] === 'order'; + }); + if (_.isUndefined(orderQueryParam)) { + return undefined; + } + const orderPair = orderQueryParam.split('='); + if (orderPair.length !== 2) { + return undefined; + } + const order = JSON.parse(decodeURIComponent(orderPair[1])); + const validationResult = validator.validate(order, portalOrderSchema); + if (validationResult.errors.length > 0) { + logUtils.log(`Invalid shared order: ${validationResult.errors}`); + return undefined; + } + return order; + }, +}; @@ -138,6 +138,16 @@ dependencies: "@types/node" "*" +"@types/blockies@^0.0.0": + version "0.0.0" + resolved "https://registry.yarnpkg.com/@types/blockies/-/blockies-0.0.0.tgz#e1dea77f138ee718bebbeb5b59d5d02139983617" + +"@types/bn.js@^4.11.0": + version "4.11.0" + resolved "https://registry.yarnpkg.com/@types/bn.js/-/bn.js-4.11.0.tgz#401cb20874f0a7b8414e46308a99c449759b7de9" + dependencies: + "@types/node" "*" + "@types/body-parser@*", "@types/body-parser@^1.16.1": version "1.16.8" resolved "https://registry.yarnpkg.com/@types/body-parser/-/body-parser-1.16.8.tgz#687ec34140624a3bec2b1a8ea9268478ae8f3be3" @@ -145,6 +155,10 @@ "@types/express" "*" "@types/node" "*" +"@types/compare-versions@^3.0.0": + version "3.0.0" + resolved "https://registry.yarnpkg.com/@types/compare-versions/-/compare-versions-3.0.0.tgz#4a45dffe0ebbc00d0f2daef8a0e96ffc66cf5955" + "@types/deep-equal@^1.0.0": version "1.0.1" resolved "https://registry.yarnpkg.com/@types/deep-equal/-/deep-equal-1.0.1.tgz#71cfabb247c22bcc16d536111f50c0ed12476b03" @@ -153,6 +167,18 @@ version "0.6.0" resolved "https://registry.yarnpkg.com/@types/depcheck/-/depcheck-0.6.0.tgz#13c8654983feb0916f45c40b2d9fafe0c8b0e4a8" +"@types/ethereumjs-abi@^0.6.0": + version "0.6.0" + resolved "https://registry.yarnpkg.com/@types/ethereumjs-abi/-/ethereumjs-abi-0.6.0.tgz#72d21083a36d9288821b62905e04b15e0c12175d" + dependencies: + "@types/node" "*" + +"@types/ethereumjs-tx@^1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@types/ethereumjs-tx/-/ethereumjs-tx-1.0.0.tgz#ae2ce90a145cc1a6849656db38baf0e793ff7927" + dependencies: + "@types/node" "*" + "@types/events@*": version "1.2.0" resolved "https://registry.yarnpkg.com/@types/events/-/events-1.2.0.tgz#81a6731ce4df43619e5c8c945383b3e62a89ea86" @@ -176,6 +202,10 @@ version "5.12.2" resolved "https://registry.yarnpkg.com/@types/fetch-mock/-/fetch-mock-5.12.2.tgz#8c96517ff74303031c65c5da2d99858e34c844d2" +"@types/find-versions@^2.0.0": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@types/find-versions/-/find-versions-2.0.0.tgz#a976ca032ab8dd1161116604eded0620d2b85df2" + "@types/fs-extra@5.0.0": version "5.0.0" resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-5.0.0.tgz#d3e225b35eb5c6d3a5a782c28219df365c781413" @@ -204,6 +234,12 @@ version "4.0.37" resolved "https://registry.yarnpkg.com/@types/handlebars/-/handlebars-4.0.37.tgz#a3bc3eba0c0f03f753cac00841a5b21e26a02c03" +"@types/hdkey@^0.7.0": + version "0.7.0" + resolved "https://registry.yarnpkg.com/@types/hdkey/-/hdkey-0.7.0.tgz#6734d138e3c597f241be8fae2e60c2949bc3af87" + dependencies: + "@types/node" "*" + "@types/highlight.js@9.12.2", "@types/highlight.js@^9.1.8": version "9.12.2" resolved "https://registry.yarnpkg.com/@types/highlight.js/-/highlight.js-9.12.2.tgz#6ee7cd395effe5ec80b515d3ff1699068cd0cd1d" @@ -212,6 +248,10 @@ version "4.6.2" resolved "https://registry.yarnpkg.com/@types/history/-/history-4.6.2.tgz#12cfaba693ba20f114ed5765467ff25fdf67ddb0" +"@types/is-mobile@0.3.0": + version "0.3.0" + resolved "https://registry.yarnpkg.com/@types/is-mobile/-/is-mobile-0.3.0.tgz#821825eeddb9016c41dd11c0dd6d2db8621432fc" + "@types/istanbul@^0.4.30": version "0.4.30" resolved "https://registry.yarnpkg.com/@types/istanbul/-/istanbul-0.4.30.tgz#073159320ab3296b2cfeb481f756a1f8f4c9c8e4" @@ -414,6 +454,10 @@ version "2.3.7" resolved "https://registry.yarnpkg.com/@types/sinon/-/sinon-2.3.7.tgz#e92c2fed3297eae078d78d1da032b26788b4af86" +"@types/solidity-parser-antlr@^0.2.0": + version "0.2.0" + resolved "https://registry.yarnpkg.com/@types/solidity-parser-antlr/-/solidity-parser-antlr-0.2.0.tgz#52b2df98d8d529adfd7188adc62a854bb77f0fb3" + "@types/uuid@^3.4.2": version "3.4.3" resolved "https://registry.yarnpkg.com/@types/uuid/-/uuid-3.4.3.tgz#121ace265f5569ce40f4f6d0ff78a338c732a754" @@ -634,6 +678,12 @@ anymatch@^2.0.0: micromatch "^3.1.4" normalize-path "^2.1.1" +append-buffer@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/append-buffer/-/append-buffer-1.0.2.tgz#d8220cf466081525efea50614f3de6514dfa58f1" + dependencies: + buffer-equal "^1.0.0" + append-transform@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/append-transform/-/append-transform-0.4.0.tgz#d76ebf8ca94d276e247a36bad44a4b74ab611991" @@ -1941,6 +1991,10 @@ buffer-crc32@~0.2.3: version "0.2.13" resolved "https://registry.yarnpkg.com/buffer-crc32/-/buffer-crc32-0.2.13.tgz#0d333e3f00eac50aa1454abd30ef8c2a5d9a7242" +buffer-equal@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/buffer-equal/-/buffer-equal-1.0.0.tgz#59616b498304d556abd466966b22eeda3eca5fbe" + buffer-from@^0.1.1: version "0.1.2" resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-0.1.2.tgz#15f4b9bcef012044df31142c14333caf6e0260d0" @@ -2783,7 +2837,7 @@ conventional-recommended-bump@^1.2.1: meow "^3.3.0" object-assign "^4.0.1" -convert-source-map@^1.1.1, convert-source-map@^1.5.0, convert-source-map@^1.5.1: +convert-source-map@^1.5.0, convert-source-map@^1.5.1: version "1.5.1" resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.5.1.tgz#b8278097b9bc229365de5c62cf5fcaed8b5599e5" @@ -3589,7 +3643,7 @@ duplexer@^0.1.1, duplexer@~0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.1.tgz#ace6ff808c1ce66b57d1ebf97977acb02334cfc1" -duplexify@^3.2.0, duplexify@^3.4.2, duplexify@^3.5.3: +duplexify@^3.4.2, duplexify@^3.5.3: version "3.5.4" resolved "https://registry.yarnpkg.com/duplexify/-/duplexify-3.5.4.tgz#4bb46c1796eabebeec4ca9a2e66b808cb7a3d8b4" dependencies: @@ -3598,6 +3652,15 @@ duplexify@^3.2.0, duplexify@^3.4.2, duplexify@^3.5.3: readable-stream "^2.0.0" stream-shift "^1.0.0" +duplexify@^3.6.0: + version "3.6.0" + resolved "https://registry.yarnpkg.com/duplexify/-/duplexify-3.6.0.tgz#592903f5d80b38d037220541264d69a198fb3410" + dependencies: + end-of-stream "^1.0.0" + inherits "^2.0.1" + readable-stream "^2.0.0" + stream-shift "^1.0.0" + ecc-jsbn@~0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz#0fc73a9ed5f0d53c38193398523ef7e543777505" @@ -4029,9 +4092,9 @@ ethereumjs-blockstream@^2.0.6: source-map-support "0.4.14" uuid "3.0.1" -ethereumjs-tx@^1.0.0, ethereumjs-tx@^1.1.1, ethereumjs-tx@^1.2.0, ethereumjs-tx@^1.2.2, ethereumjs-tx@^1.3.0, ethereumjs-tx@^1.3.3: +ethereumjs-tx@0xProject/ethereumjs-tx#fake-tx-include-signature-by-default, ethereumjs-tx@^1.0.0, ethereumjs-tx@^1.1.1, ethereumjs-tx@^1.2.0, ethereumjs-tx@^1.2.2, ethereumjs-tx@^1.3.0, ethereumjs-tx@^1.3.3: version "1.3.4" - resolved "https://registry.yarnpkg.com/ethereumjs-tx/-/ethereumjs-tx-1.3.4.tgz#c2304912f6c07af03237ad8675ac036e290dad48" + resolved "https://codeload.github.com/0xProject/ethereumjs-tx/tar.gz/5f0a610849de09f922f8ccee5af1aae4bec36e51" dependencies: ethereum-common "^0.0.18" ethereumjs-util "^5.0.0" @@ -4598,7 +4661,7 @@ flow-parser@^0.*: version "0.72.0" resolved "https://registry.yarnpkg.com/flow-parser/-/flow-parser-0.72.0.tgz#6c8041e76ac7d0be1a71ce29c00cd1435fb6013c" -flush-write-stream@^1.0.0: +flush-write-stream@^1.0.0, flush-write-stream@^1.0.2: version "1.0.3" resolved "https://registry.yarnpkg.com/flush-write-stream/-/flush-write-stream-1.0.3.tgz#c5d586ef38af6097650b49bc41b55fabb19f35bd" dependencies: @@ -4716,6 +4779,13 @@ fs-extra@^5.0.0: jsonfile "^4.0.0" universalify "^0.1.0" +fs-mkdirp-stream@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs-mkdirp-stream/-/fs-mkdirp-stream-1.0.0.tgz#0b7815fc3201c6a69e14db98ce098c16935259eb" + dependencies: + graceful-fs "^4.1.11" + through2 "^2.0.3" + fs-promise@^2.0.0: version "2.0.3" resolved "https://registry.yarnpkg.com/fs-promise/-/fs-promise-2.0.3.tgz#f64e4f854bcf689aa8bddcba268916db3db46854" @@ -4972,7 +5042,7 @@ glob-parent@^2.0.0: dependencies: is-glob "^2.0.0" -glob-parent@^3.0.0, glob-parent@^3.1.0: +glob-parent@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-3.1.0.tgz#9e6af6299d8d3bd2bd40430832bd113df906c5ae" dependencies: @@ -4990,17 +5060,19 @@ glob-stream@^3.1.5: through2 "^0.6.1" unique-stream "^1.0.0" -glob-stream@^5.3.2: - version "5.3.5" - resolved "https://registry.yarnpkg.com/glob-stream/-/glob-stream-5.3.5.tgz#a55665a9a8ccdc41915a87c701e32d4e016fad22" +glob-stream@^6.1.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/glob-stream/-/glob-stream-6.1.0.tgz#7045c99413b3eb94888d83ab46d0b404cc7bdde4" dependencies: extend "^3.0.0" - glob "^5.0.3" - glob-parent "^3.0.0" - micromatch "^2.3.7" - ordered-read-streams "^0.3.0" - through2 "^0.6.0" - to-absolute-glob "^0.1.1" + glob "^7.1.1" + glob-parent "^3.1.0" + is-negated-glob "^1.0.0" + ordered-read-streams "^1.0.0" + pumpify "^1.3.5" + readable-stream "^2.1.5" + remove-trailing-separator "^1.0.1" + to-absolute-glob "^2.0.0" unique-stream "^2.0.2" glob-to-regexp@^0.3.0: @@ -5050,7 +5122,7 @@ glob@^4.3.1: minimatch "^2.0.1" once "^1.3.0" -glob@^5.0.15, glob@^5.0.3: +glob@^5.0.15: version "5.0.15" resolved "https://registry.yarnpkg.com/glob/-/glob-5.0.15.tgz#1bc936b9e02f4a603fcc222ecf7633d30b8b93b1" dependencies: @@ -5243,16 +5315,6 @@ gud@^1.0.0: version "1.0.0" resolved "https://registry.npmjs.org/gud/-/gud-1.0.0.tgz#a489581b17e6a70beca9abe3ae57de7a499852c0" -gulp-sourcemaps@1.6.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/gulp-sourcemaps/-/gulp-sourcemaps-1.6.0.tgz#b86ff349d801ceb56e1d9e7dc7bbcb4b7dee600c" - dependencies: - convert-source-map "^1.1.1" - graceful-fs "^4.1.2" - strip-bom "^2.0.0" - through2 "^2.0.0" - vinyl "^1.0.0" - gulp-util@^3.0.0: version "3.0.8" resolved "https://registry.yarnpkg.com/gulp-util/-/gulp-util-3.0.8.tgz#0054e1e744502e27c04c187c3ecc505dd54bbb4f" @@ -5372,6 +5434,10 @@ has-symbol-support-x@^1.4.1: version "1.4.2" resolved "https://registry.yarnpkg.com/has-symbol-support-x/-/has-symbol-support-x-1.4.2.tgz#1409f98bc00247da45da67cee0a36f282ff26455" +has-symbols@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.0.tgz#ba1a8f1af2a0fc39650f5c850367704122063b44" + has-to-string-tag-x@^1.2.0: version "1.4.1" resolved "https://registry.yarnpkg.com/has-to-string-tag-x/-/has-to-string-tag-x-1.4.1.tgz#a045ab383d7b4b2012a00148ab0aa5f290044d4d" @@ -6073,6 +6139,10 @@ is-natural-number@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/is-natural-number/-/is-natural-number-4.0.1.tgz#ab9d76e1db4ced51e35de0c72ebecf09f734cde8" +is-negated-glob@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-negated-glob/-/is-negated-glob-1.0.0.tgz#6910bca5da8c95e784b5751b976cf5a10fee36d2" + is-npm@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-npm/-/is-npm-1.0.0.tgz#f2fb63a65e4905b406c86072765a1a4dc793b9f4" @@ -6215,13 +6285,13 @@ is-url@^1.1.0: version "1.2.4" resolved "https://registry.yarnpkg.com/is-url/-/is-url-1.2.4.tgz#04a4df46d28c4cff3d73d01ff06abeb318a1aa52" -is-utf8@^0.2.0: +is-utf8@^0.2.0, is-utf8@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72" -is-valid-glob@^0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/is-valid-glob/-/is-valid-glob-0.3.0.tgz#d4b55c69f51886f9b65c70d6c2622d37e29f48fe" +is-valid-glob@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-valid-glob/-/is-valid-glob-1.0.0.tgz#29bf3eff701be2d4d315dbacc39bc39fe8f601aa" is-whitespace-character@^1.0.0: version "1.0.1" @@ -6630,13 +6700,19 @@ lcov-parse@^0.0.10: version "0.0.10" resolved "https://registry.yarnpkg.com/lcov-parse/-/lcov-parse-0.0.10.tgz#1b0b8ff9ac9c7889250582b70b71315d9da6d9a3" -lcov-result-merger@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/lcov-result-merger/-/lcov-result-merger-2.0.0.tgz#ba26a3b7d15b40b0efe6e603b1354b1dded28ce1" +lcov-result-merger@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/lcov-result-merger/-/lcov-result-merger-3.0.0.tgz#4b9f2fc12cc3df9013ff79a55d4d4a6f909f9d64" dependencies: - through2 "^2.0.1" - vinyl "^2.0.0" - vinyl-fs "^2.4.3" + through2 "^2.0.3" + vinyl "^2.1.0" + vinyl-fs "^3.0.2" + +lead@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/lead/-/lead-1.0.0.tgz#6f14f99a37be3a9dd784f5495690e5903466ee42" + dependencies: + flush-write-stream "^1.0.2" lerna-get-packages@^1.0.0: version "1.0.0" @@ -7035,10 +7111,6 @@ lodash.isarray@^3.0.0: version "3.0.4" resolved "https://registry.yarnpkg.com/lodash.isarray/-/lodash.isarray-3.0.4.tgz#79e4eb88c36a8122af86f844aa9bcd851b5fbb55" -lodash.isequal@^4.0.0: - version "4.5.0" - resolved "https://registry.yarnpkg.com/lodash.isequal/-/lodash.isequal-4.5.0.tgz#415c4478f2bcc30120c22ce10ed3226f7d3e18e0" - lodash.keys@^3.0.0: version "3.1.2" resolved "https://registry.yarnpkg.com/lodash.keys/-/lodash.keys-3.1.2.tgz#4dbc0472b156be50a0b286855d1bd0b0c656098a" @@ -7421,12 +7493,6 @@ merge-source-map@^1.0.2: dependencies: source-map "^0.6.1" -merge-stream@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-1.0.1.tgz#4041202d508a342ba00174008df0c251b8c135e1" - dependencies: - readable-stream "^2.0.1" - merge2@^1.2.1: version "1.2.2" resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.2.2.tgz#03212e3da8d86c4d8523cebd6318193414f94e34" @@ -8014,6 +8080,12 @@ normalize-url@^1.4.0: query-string "^4.1.0" sort-keys "^1.0.0" +now-and-later@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/now-and-later/-/now-and-later-2.0.0.tgz#bc61cbb456d79cb32207ce47ca05136ff2e7d6ee" + dependencies: + once "^1.3.2" + npm-run-all@^4.1.2: version "4.1.2" resolved "https://registry.yarnpkg.com/npm-run-all/-/npm-run-all-4.1.2.tgz#90d62d078792d20669139e718621186656cea056" @@ -8118,7 +8190,7 @@ object-inspect@~1.5.0: version "1.5.0" resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.5.0.tgz#9d876c11e40f485c79215670281b767488f9bfe3" -object-keys@^1.0.8: +object-keys@^1.0.11, object-keys@^1.0.8: version "1.0.11" resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.0.11.tgz#c54601778ad560f1142ce0e01bcca8b56d13426d" @@ -8132,6 +8204,15 @@ object-visit@^1.0.0: dependencies: isobject "^3.0.0" +object.assign@^4.0.4: + version "4.1.0" + resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.0.tgz#968bf1100d7956bb3ca086f006f846b3bc4008da" + dependencies: + define-properties "^1.1.2" + function-bind "^1.1.1" + has-symbols "^1.0.0" + object-keys "^1.0.11" + object.defaults@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/object.defaults/-/object.defaults-1.1.0.tgz#3a7f868334b407dea06da16d88d5cd29e435fecf" @@ -8181,7 +8262,7 @@ on-headers@~1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/on-headers/-/on-headers-1.0.1.tgz#928f5d0f470d49342651ea6794b0857c100693f7" -once@1.x, once@^1.3.0, once@^1.3.1, once@^1.3.3, once@^1.4.0: +once@1.x, once@^1.3.0, once@^1.3.1, once@^1.3.2, once@^1.3.3, once@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" dependencies: @@ -8265,11 +8346,10 @@ ordered-read-streams@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/ordered-read-streams/-/ordered-read-streams-0.1.0.tgz#fd565a9af8eb4473ba69b6ed8a34352cb552f126" -ordered-read-streams@^0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/ordered-read-streams/-/ordered-read-streams-0.3.0.tgz#7137e69b3298bb342247a1bbee3881c80e2fd78b" +ordered-read-streams@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/ordered-read-streams/-/ordered-read-streams-1.0.1.tgz#77c0cb37c41525d64166d990ffad7ec6a0e1363e" dependencies: - is-stream "^1.0.1" readable-stream "^2.0.1" original@>=0.0.5: @@ -9268,6 +9348,14 @@ pumpify@^1.3.3: inherits "^2.0.3" pump "^2.0.0" +pumpify@^1.3.5: + version "1.5.1" + resolved "https://registry.yarnpkg.com/pumpify/-/pumpify-1.5.1.tgz#36513be246ab27570b1a374a5ce278bfd74370ce" + dependencies: + duplexify "^3.6.0" + inherits "^2.0.3" + pump "^2.0.0" + punycode@1.3.2: version "1.3.2" resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.3.2.tgz#9653a036fb7c1ee42342f2325cceefea3926c48d" @@ -9857,6 +9945,21 @@ remark-parse@^5.0.0: vfile-location "^2.0.0" xtend "^4.0.1" +remove-bom-buffer@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/remove-bom-buffer/-/remove-bom-buffer-3.0.0.tgz#c2bf1e377520d324f623892e33c10cac2c252b53" + dependencies: + is-buffer "^1.1.5" + is-utf8 "^0.2.1" + +remove-bom-stream@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/remove-bom-stream/-/remove-bom-stream-1.2.0.tgz#05f1a593f16e42e1fb90ebf59de8e569525f9523" + dependencies: + remove-bom-buffer "^3.0.0" + safe-buffer "^5.1.0" + through2 "^2.0.3" + remove-trailing-separator@^1.0.1: version "1.1.0" resolved "https://registry.yarnpkg.com/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz#c24bce2a283adad5bc3f58e0d48249b92379d8ef" @@ -9990,6 +10093,12 @@ resolve-from@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-3.0.0.tgz#b22c7af7d9d6881bc8b6e653335eebcb0a188748" +resolve-options@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/resolve-options/-/resolve-options-1.1.0.tgz#32bb9e39c06d67338dc9378c0d6d6074566ad131" + dependencies: + value-or-function "^3.0.0" + resolve-pathname@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/resolve-pathname/-/resolve-pathname-2.2.0.tgz#7e9ae21ed815fd63ab189adeee64dc831eefa879" @@ -10989,13 +11098,6 @@ strip-ansi@~0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-0.1.1.tgz#39e8a98d044d150660abe4a6808acf70bb7bc991" -strip-bom-stream@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/strip-bom-stream/-/strip-bom-stream-1.0.0.tgz#e7144398577d51a6bed0fa1994fa05f43fd988ee" - dependencies: - first-chunk-stream "^1.0.0" - strip-bom "^2.0.0" - strip-bom-stream@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/strip-bom-stream/-/strip-bom-stream-2.0.0.tgz#f87db5ef2613f6968aa545abfe1ec728b6a829ca" @@ -11327,7 +11429,7 @@ through2-filter@^2.0.0: through2 "~2.0.0" xtend "~4.0.0" -through2@^0.6.0, through2@^0.6.1, through2@~0.6.3: +through2@^0.6.1, through2@~0.6.3: version "0.6.5" resolved "https://registry.yarnpkg.com/through2/-/through2-0.6.5.tgz#41ab9c67b29d57209071410e1d7a7a968cd3ad48" dependencies: @@ -11396,11 +11498,12 @@ tmp@^0.0.33: dependencies: os-tmpdir "~1.0.2" -to-absolute-glob@^0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/to-absolute-glob/-/to-absolute-glob-0.1.1.tgz#1cdfa472a9ef50c239ee66999b662ca0eb39937f" +to-absolute-glob@^2.0.0: + version "2.0.2" + resolved "https://registry.yarnpkg.com/to-absolute-glob/-/to-absolute-glob-2.0.2.tgz#1865f43d9e74b0822db9f145b78cff7d0f7c849b" dependencies: - extend-shallow "^2.0.1" + is-absolute "^1.0.0" + is-negated-glob "^1.0.0" to-arraybuffer@^1.0.0: version "1.0.1" @@ -11448,6 +11551,12 @@ to-space-case@^1.0.0: dependencies: to-no-case "^1.0.0" +to-through@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/to-through/-/to-through-2.0.0.tgz#fc92adaba072647bc0b67d6b03664aa195093af6" + dependencies: + through2 "^2.0.3" + toggle-selection@^1.0.3: version "1.0.6" resolved "https://registry.yarnpkg.com/toggle-selection/-/toggle-selection-1.0.6.tgz#6e45b1263f2017fa0acc7d89d78b15b8bf77da32" @@ -12083,10 +12192,6 @@ v8flags@^2.0.2: dependencies: user-home "^1.1.1" -vali-date@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/vali-date/-/vali-date-1.0.0.tgz#1b904a59609fb328ef078138420934f6b86709a6" - valid-url@^1.0.9: version "1.0.9" resolved "https://registry.yarnpkg.com/valid-url/-/valid-url-1.0.9.tgz#1c14479b40f1397a75782f115e4086447433a200" @@ -12102,6 +12207,10 @@ value-equal@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/value-equal/-/value-equal-0.4.0.tgz#c5bdd2f54ee093c04839d71ce2e4758a6890abc7" +value-or-function@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/value-or-function/-/value-or-function-3.0.0.tgz#1c243a50b595c1be54a754bfece8563b9ff8d813" + vary@^1, vary@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" @@ -12161,27 +12270,39 @@ vinyl-fs@^0.3.0: through2 "^0.6.1" vinyl "^0.4.0" -vinyl-fs@^2.4.3: - version "2.4.4" - resolved "https://registry.yarnpkg.com/vinyl-fs/-/vinyl-fs-2.4.4.tgz#be6ff3270cb55dfd7d3063640de81f25d7532239" +vinyl-fs@^3.0.2: + version "3.0.3" + resolved "https://registry.yarnpkg.com/vinyl-fs/-/vinyl-fs-3.0.3.tgz#c85849405f67428feabbbd5c5dbdd64f47d31bc7" dependencies: - duplexify "^3.2.0" - glob-stream "^5.3.2" + fs-mkdirp-stream "^1.0.0" + glob-stream "^6.1.0" graceful-fs "^4.0.0" - gulp-sourcemaps "1.6.0" - is-valid-glob "^0.3.0" + is-valid-glob "^1.0.0" lazystream "^1.0.0" - lodash.isequal "^4.0.0" - merge-stream "^1.0.0" - mkdirp "^0.5.0" - object-assign "^4.0.0" - readable-stream "^2.0.4" - strip-bom "^2.0.0" - strip-bom-stream "^1.0.0" + lead "^1.0.0" + object.assign "^4.0.4" + pumpify "^1.3.5" + readable-stream "^2.3.3" + remove-bom-buffer "^3.0.0" + remove-bom-stream "^1.2.0" + resolve-options "^1.1.0" through2 "^2.0.0" - through2-filter "^2.0.0" - vali-date "^1.0.0" - vinyl "^1.0.0" + to-through "^2.0.0" + value-or-function "^3.0.0" + vinyl "^2.0.0" + vinyl-sourcemap "^1.1.0" + +vinyl-sourcemap@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/vinyl-sourcemap/-/vinyl-sourcemap-1.1.0.tgz#92a800593a38703a8cdb11d8b300ad4be63b3e16" + dependencies: + append-buffer "^1.0.2" + convert-source-map "^1.5.0" + graceful-fs "^4.1.6" + normalize-path "^2.1.1" + now-and-later "^2.0.0" + remove-bom-buffer "^3.0.0" + vinyl "^2.0.0" vinyl@^0.4.0: version "0.4.6" @@ -12198,7 +12319,7 @@ vinyl@^0.5.0: clone-stats "^0.0.1" replace-ext "0.0.1" -vinyl@^1.0.0, vinyl@^1.1.0: +vinyl@^1.1.0: version "1.2.0" resolved "https://registry.yarnpkg.com/vinyl/-/vinyl-1.2.0.tgz#5c88036cf565e5df05558bfc911f8656df218884" dependencies: @@ -12206,7 +12327,7 @@ vinyl@^1.0.0, vinyl@^1.1.0: clone-stats "^0.0.1" replace-ext "0.0.1" -vinyl@^2.0.0, vinyl@^2.0.1: +vinyl@^2.0.0, vinyl@^2.0.1, vinyl@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/vinyl/-/vinyl-2.1.0.tgz#021f9c2cf951d6b939943c89eb5ee5add4fd924c" dependencies: @@ -12888,9 +13009,9 @@ xhr@^2.0.4, xhr@^2.2.0, xhr@^2.3.3: parse-headers "^2.0.0" xtend "^4.0.0" -xml-js@^1.3.2: - version "1.6.2" - resolved "https://registry.yarnpkg.com/xml-js/-/xml-js-1.6.2.tgz#4c4cb8413998f73701a202a1b8b2f17c985a72c5" +xml-js@^1.6.4: + version "1.6.4" + resolved "https://registry.yarnpkg.com/xml-js/-/xml-js-1.6.4.tgz#fcf9fdc9fb6d691122a02fe5a55c30f84d93ab90" dependencies: sax "^1.2.4" |