From f892b7dbf657f71f4fec177e838883de8327624b Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 11 Apr 2018 22:00:54 +0900 Subject: Move NULL_BYTES to @0xproject/utils --- packages/0x.js/test/utils/constants.ts | 1 - packages/contracts/test/token_registry.ts | 6 +- packages/contracts/util/constants.ts | 1 - packages/migrations/src/migration.ts | 12 ++-- packages/migrations/src/utils/constants.ts | 3 - packages/migrations/src/utils/token_info.ts | 24 ++++---- packages/utils/CHANGELOG.json | 9 +++ packages/utils/src/constants.ts | 1 + packages/utils/src/index.ts | 2 + yarn.lock | 93 +---------------------------- 10 files changed, 35 insertions(+), 117 deletions(-) delete mode 100644 packages/migrations/src/utils/constants.ts create mode 100644 packages/utils/src/constants.ts diff --git a/packages/0x.js/test/utils/constants.ts b/packages/0x.js/test/utils/constants.ts index 3b74fa863..cf030259c 100644 --- a/packages/0x.js/test/utils/constants.ts +++ b/packages/0x.js/test/utils/constants.ts @@ -6,5 +6,4 @@ export const constants = { KOVAN_RPC_URL: 'https://kovan.infura.io/', ROPSTEN_RPC_URL: 'https://ropsten.infura.io/', ZRX_DECIMALS: 18, - NULL_BYTES: '0x', }; diff --git a/packages/contracts/test/token_registry.ts b/packages/contracts/test/token_registry.ts index 12fc52dbc..4c404176b 100644 --- a/packages/contracts/test/token_registry.ts +++ b/packages/contracts/test/token_registry.ts @@ -1,6 +1,6 @@ import { ZeroEx } from '0x.js'; import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils'; -import { BigNumber } from '@0xproject/utils'; +import { BigNumber, NULL_BYTES } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import * as chai from 'chai'; import ethUtil = require('ethereumjs-util'); @@ -66,8 +66,8 @@ describe('TokenRegistry', () => { name: '', symbol: '', decimals: 0, - ipfsHash: constants.NULL_BYTES, - swarmHash: constants.NULL_BYTES, + ipfsHash: NULL_BYTES, + swarmHash: NULL_BYTES, }; describe('addToken', () => { diff --git a/packages/contracts/util/constants.ts b/packages/contracts/util/constants.ts index 9bb090a2a..d1152e683 100644 --- a/packages/contracts/util/constants.ts +++ b/packages/contracts/util/constants.ts @@ -4,7 +4,6 @@ const DUMMY_TOKEN_DECIMALS = 18; const DUMMY_TOKEN_TOTAL_SUPPLY = 0; export const constants = { - NULL_BYTES: '0x', INVALID_OPCODE: 'invalid opcode', REVERT: 'revert', TESTRPC_NETWORK_ID: 50, diff --git a/packages/migrations/src/migration.ts b/packages/migrations/src/migration.ts index be899cc65..4827328fc 100644 --- a/packages/migrations/src/migration.ts +++ b/packages/migrations/src/migration.ts @@ -1,10 +1,8 @@ import { Deployer } from '@0xproject/deployer'; -import { BigNumber } from '@0xproject/utils'; +import { BigNumber, NULL_BYTES } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import * as _ from 'lodash'; -import { constants } from './utils/constants'; - import { ContractName } from './types'; import { tokenInfo } from './utils/token_info'; @@ -51,8 +49,8 @@ export const runMigrationsAsync = async (deployer: Deployer) => { '0x Protocol Token', 'ZRX', 18, - constants.NULL_BYTES, - constants.NULL_BYTES, + NULL_BYTES, + NULL_BYTES, { from: owner, gas: addTokenGasEstimate, @@ -63,8 +61,8 @@ export const runMigrationsAsync = async (deployer: Deployer) => { 'Ether Token', 'WETH', 18, - constants.NULL_BYTES, - constants.NULL_BYTES, + NULL_BYTES, + NULL_BYTES, { from: owner, gas: addTokenGasEstimate, diff --git a/packages/migrations/src/utils/constants.ts b/packages/migrations/src/utils/constants.ts deleted file mode 100644 index 8871a470d..000000000 --- a/packages/migrations/src/utils/constants.ts +++ /dev/null @@ -1,3 +0,0 @@ -export const constants = { - NULL_BYTES: '0x', -}; diff --git a/packages/migrations/src/utils/token_info.ts b/packages/migrations/src/utils/token_info.ts index f2ca3e8b3..968665c7d 100644 --- a/packages/migrations/src/utils/token_info.ts +++ b/packages/migrations/src/utils/token_info.ts @@ -1,41 +1,41 @@ -import { Token } from '../types'; +import { NULL_BYTES } from '@0xproject/utils'; -import { constants } from './constants'; +import { Token } from '../types'; export const tokenInfo: Token[] = [ { name: 'Augur Reputation Token', symbol: 'REP', decimals: 18, - ipfsHash: constants.NULL_BYTES, - swarmHash: constants.NULL_BYTES, + ipfsHash: NULL_BYTES, + swarmHash: NULL_BYTES, }, { name: 'Digix DAO Token', symbol: 'DGD', decimals: 18, - ipfsHash: constants.NULL_BYTES, - swarmHash: constants.NULL_BYTES, + ipfsHash: NULL_BYTES, + swarmHash: NULL_BYTES, }, { name: 'Golem Network Token', symbol: 'GNT', decimals: 18, - ipfsHash: constants.NULL_BYTES, - swarmHash: constants.NULL_BYTES, + ipfsHash: NULL_BYTES, + swarmHash: NULL_BYTES, }, { name: 'MakerDAO', symbol: 'MKR', decimals: 18, - ipfsHash: constants.NULL_BYTES, - swarmHash: constants.NULL_BYTES, + ipfsHash: NULL_BYTES, + swarmHash: NULL_BYTES, }, { name: 'Melon Token', symbol: 'MLN', decimals: 18, - ipfsHash: constants.NULL_BYTES, - swarmHash: constants.NULL_BYTES, + ipfsHash: NULL_BYTES, + swarmHash: NULL_BYTES, }, ]; diff --git a/packages/utils/CHANGELOG.json b/packages/utils/CHANGELOG.json index 0c71963c3..3ba1f7d01 100644 --- a/packages/utils/CHANGELOG.json +++ b/packages/utils/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "version": "0.5.1", + "changes": [ + { + "note": "Export NULL_BYTES constant", + "pr": 500 + } + ] + }, { "version": "0.5.0", "changes": [ diff --git a/packages/utils/src/constants.ts b/packages/utils/src/constants.ts new file mode 100644 index 000000000..2894d4747 --- /dev/null +++ b/packages/utils/src/constants.ts @@ -0,0 +1 @@ +export const NULL_BYTES = '0x'; diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts index 0da4b265d..75c096ee6 100644 --- a/packages/utils/src/index.ts +++ b/packages/utils/src/index.ts @@ -6,3 +6,5 @@ export { BigNumber } from './configured_bignumber'; export { AbiDecoder } from './abi_decoder'; export { logUtils } from './log_utils'; export { abiUtils } from './abi_utils'; + +export { NULL_BYTES } from './constants'; diff --git a/yarn.lock b/yarn.lock index 3d2d6a817..265b194e3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6,41 +6,6 @@ version "0.3.9" resolved "https://registry.yarnpkg.com/8fold-marked/-/8fold-marked-0.3.9.tgz#bb89c645612f8ccfaffac1ca6e3c11f168c9cf59" -"@0xproject/dev-utils@^0.2.1": - version "0.2.1" - resolved "https://registry.yarnpkg.com/@0xproject/dev-utils/-/dev-utils-0.2.1.tgz#a54465376fd7c8cf58781b02b1790d74fb51e91b" - dependencies: - "@0xproject/subproviders" "^0.7.0" - "@0xproject/types" "^0.3.1" - "@0xproject/utils" "^0.4.1" - ethereumjs-util "^5.1.2" - lodash "^4.17.4" - request-promise-native "^1.0.5" - web3 "^0.20.0" - web3-provider-engine "^13.0.1" - -"@0xproject/subproviders@^0.7.0": - version "0.7.0" - resolved "https://registry.yarnpkg.com/@0xproject/subproviders/-/subproviders-0.7.0.tgz#ce3379a85649773e5c08f5fc3239e8ed07f13361" - dependencies: - "@0xproject/assert" "^0.2.0" - "@0xproject/types" "^0.3.1" - "@0xproject/utils" "^0.4.1" - "@ledgerhq/hw-app-eth" "^4.3.0" - "@ledgerhq/hw-transport-u2f" "^4.3.0" - bn.js "^4.11.8" - es6-promisify "^5.0.0" - ethereumjs-tx "^1.3.3" - ethereumjs-util "^5.1.1" - hdkey "^0.7.1" - lodash "^4.17.4" - semaphore-async-await "^1.5.1" - web3 "^0.20.0" - web3-provider-engine "^13.0.1" - web3-typescript-typings "^0.10.0" - optionalDependencies: - "@ledgerhq/hw-transport-node-hid" "^4.3.0" - "@0xproject/tslint-config@0.4.13": version "0.4.13" resolved "https://registry.yarnpkg.com/@0xproject/tslint-config/-/tslint-config-0.4.13.tgz#98c71c5ae5e80315a23eda0134cc9f6f4438cac2" @@ -50,40 +15,6 @@ tslint-eslint-rules "^4.1.1" tslint-react "^3.2.0" -"@0xproject/types@^0.3.1": - version "0.3.1" - resolved "https://registry.yarnpkg.com/@0xproject/types/-/types-0.3.1.tgz#9a75be6d3a2d41b7ecbd9105c3fdc09f3e3ec297" - dependencies: - bignumber.js "~4.1.0" - web3 "^0.20.0" - web3-typescript-typings "^0.10.0" - -"@0xproject/types@^0.4.2": - version "0.4.2" - resolved "https://registry.yarnpkg.com/@0xproject/types/-/types-0.4.2.tgz#83d6ebef60f41e6209acb2656b1d68ff79367ca5" - dependencies: - bignumber.js "~4.1.0" - -"@0xproject/typescript-typings@^0.0.2": - version "0.0.2" - resolved "https://registry.yarnpkg.com/@0xproject/typescript-typings/-/typescript-typings-0.0.2.tgz#b549ea3c81ce2d81b99f05583bdf7c411a3ca90c" - dependencies: - "@0xproject/types" "^0.4.2" - bignumber.js "~4.1.0" - -"@0xproject/utils@^0.4.1": - version "0.4.4" - resolved "https://registry.yarnpkg.com/@0xproject/utils/-/utils-0.4.4.tgz#bce4f7a5a46570a69911f4a4ade5d49016330087" - dependencies: - "@0xproject/types" "^0.4.2" - "@0xproject/typescript-typings" "^0.0.2" - "@types/node" "^8.0.53" - bignumber.js "~4.1.0" - ethers-contracts "^2.2.1" - js-sha3 "^0.7.0" - lodash "^4.17.4" - web3 "^0.20.0" - "@ledgerhq/hw-app-eth@^4.3.0": version "4.7.3" resolved "https://registry.yarnpkg.com/@ledgerhq/hw-app-eth/-/hw-app-eth-4.7.3.tgz#d352e19658ae296532e522c53c8ec2a1a77b64e5" @@ -3653,7 +3584,7 @@ ethereumjs-util@^4.0.1, ethereumjs-util@^4.3.0, ethereumjs-util@^4.4.0: rlp "^2.0.0" secp256k1 "^3.0.1" -ethereumjs-util@^5.0.0, ethereumjs-util@^5.0.1, ethereumjs-util@^5.1.1, ethereumjs-util@^5.1.2, ethereumjs-util@^5.1.3, ethereumjs-util@^5.1.5: +ethereumjs-util@^5.0.0, ethereumjs-util@^5.0.1, ethereumjs-util@^5.1.1, ethereumjs-util@^5.1.3, ethereumjs-util@^5.1.5: version "5.1.5" resolved "https://registry.yarnpkg.com/ethereumjs-util/-/ethereumjs-util-5.1.5.tgz#2f02575852627d45622426f25ee4a0b5f377f27a" dependencies: @@ -8988,20 +8919,6 @@ request-ip@~1.2.3: version "1.2.3" resolved "https://registry.yarnpkg.com/request-ip/-/request-ip-1.2.3.tgz#66988f0e22406ec4af630d19b573fe4b447c3b49" -request-promise-core@1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/request-promise-core/-/request-promise-core-1.1.1.tgz#3eee00b2c5aa83239cfb04c5700da36f81cd08b6" - dependencies: - lodash "^4.13.1" - -request-promise-native@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/request-promise-native/-/request-promise-native-1.0.5.tgz#5281770f68e0c9719e5163fd3fab482215f4fda5" - dependencies: - request-promise-core "1.1.1" - stealthy-require "^1.1.0" - tough-cookie ">=2.3.3" - request@2.81.0: version "2.81.0" resolved "https://registry.yarnpkg.com/request/-/request-2.81.0.tgz#c6928946a0e06c5f8d6f8a9333469ffda46298a0" @@ -9887,10 +9804,6 @@ static-extend@^0.1.1: version "1.4.0" resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.4.0.tgz#bb73d446da2796106efcc1b601a253d6c46bd087" -stealthy-require@^1.1.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/stealthy-require/-/stealthy-require-1.1.1.tgz#35b09875b4ff49f26a777e509b3090a3226bf24b" - stream-browserify@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/stream-browserify/-/stream-browserify-2.0.1.tgz#66266ee5f9bdb9940a4e4514cafb43bb71e5c9db" @@ -10463,7 +10376,7 @@ touch@^3.1.0: dependencies: nopt "~1.0.10" -tough-cookie@>=2.3.3, tough-cookie@~2.3.0, tough-cookie@~2.3.3: +tough-cookie@~2.3.0, tough-cookie@~2.3.3: version "2.3.4" resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.3.4.tgz#ec60cee38ac675063ffc97a5c18970578ee83655" dependencies: @@ -11418,7 +11331,7 @@ web3-shh@1.0.0-beta.33: web3-core-subscriptions "1.0.0-beta.33" web3-net "1.0.0-beta.33" -web3-typescript-typings@^0.10.0, web3-typescript-typings@^0.10.2: +web3-typescript-typings@^0.10.2: version "0.10.2" resolved "https://registry.yarnpkg.com/web3-typescript-typings/-/web3-typescript-typings-0.10.2.tgz#a9903815d2a8a0dbd73fd5db374070de0bd30497" dependencies: -- cgit v1.2.3