From 02ede26893d5801c827f68d4ffb24c216b873a09 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Thu, 15 Mar 2018 16:22:42 +0100 Subject: Rename onDeployCommand to onDeployCommandAsync and onCompileCommand to onCompileCommandAsync --- packages/deployer/src/cli.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'packages') diff --git a/packages/deployer/src/cli.ts b/packages/deployer/src/cli.ts index 7913c6344..b131a96d8 100644 --- a/packages/deployer/src/cli.ts +++ b/packages/deployer/src/cli.ts @@ -24,7 +24,7 @@ const DEFAULT_CONTRACTS_LIST = '*'; * Compiles all contracts with options passed in through CLI. * @param argv Instance of process.argv provided by yargs. */ -async function onCompileCommand(argv: CliOptions): Promise { +async function onCompileCommandAsync(argv: CliOptions): Promise { const opts: CompilerOptions = { contractsDir: argv.contractsDir, networkId: argv.networkId, @@ -38,7 +38,7 @@ async function onCompileCommand(argv: CliOptions): Promise { * Deploys a single contract with provided name and args. * @param argv Instance of process.argv provided by yargs. */ -async function onDeployCommand(argv: CliOptions): Promise { +async function onDeployCommandAsync(argv: CliOptions): Promise { const url = argv.jsonrpcUrl; const web3Provider = new Web3.providers.HttpProvider(url); const web3Wrapper = new Web3Wrapper(web3Provider); @@ -142,7 +142,12 @@ function deployCommandBuilder(yargsInstance: any) { default: DEFAULT_CONTRACTS_LIST, description: 'comma separated list of contracts to compile', }) - .command('compile', 'compile contracts', identityCommandBuilder, onCompileCommand) - .command('deploy', 'deploy a single contract with provided arguments', deployCommandBuilder, onDeployCommand) + .command('compile', 'compile contracts', identityCommandBuilder, onCompileCommandAsync) + .command( + 'deploy', + 'deploy a single contract with provided arguments', + deployCommandBuilder, + onDeployCommandAsync, + ) .help().argv; })(); -- cgit v1.2.3 From 3c36135d6c9c4b4deb1985bd71ba6f4002d16d0e Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Thu, 15 Mar 2018 16:29:55 +0100 Subject: Stop printing help on error --- packages/deployer/src/cli.ts | 5 +++-- packages/deployer/src/utils/error_reporter.ts | 13 +++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 packages/deployer/src/utils/error_reporter.ts (limited to 'packages') diff --git a/packages/deployer/src/cli.ts b/packages/deployer/src/cli.ts index b131a96d8..176eaf973 100644 --- a/packages/deployer/src/cli.ts +++ b/packages/deployer/src/cli.ts @@ -10,6 +10,7 @@ import * as yargs from 'yargs'; import { commands } from './commands'; import { constants } from './utils/constants'; +import { consoleReporter } from './utils/error_reporter'; import { CliOptions, CompilerOptions, DeployerOptions } from './utils/types'; const DEFAULT_OPTIMIZER_ENABLED = false; @@ -142,12 +143,12 @@ function deployCommandBuilder(yargsInstance: any) { default: DEFAULT_CONTRACTS_LIST, description: 'comma separated list of contracts to compile', }) - .command('compile', 'compile contracts', identityCommandBuilder, onCompileCommandAsync) + .command('compile', 'compile contracts', identityCommandBuilder, consoleReporter(onCompileCommandAsync)) .command( 'deploy', 'deploy a single contract with provided arguments', deployCommandBuilder, - onDeployCommandAsync, + consoleReporter(onDeployCommandAsync), ) .help().argv; })(); diff --git a/packages/deployer/src/utils/error_reporter.ts b/packages/deployer/src/utils/error_reporter.ts new file mode 100644 index 000000000..b28e4fbbe --- /dev/null +++ b/packages/deployer/src/utils/error_reporter.ts @@ -0,0 +1,13 @@ +import { logUtils } from '@0xproject/utils'; + +export function consoleReporter(asyncFn: (arg: T) => Promise) { + const noThrowFnAsync = async (arg: T) => { + try { + const result = await asyncFn(arg); + return result; + } catch (err) { + logUtils.log(`${err}`); + } + }; + return noThrowFnAsync; +} -- cgit v1.2.3 From 8fd705d2afe6ddcb53a16973256a0674e180be67 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Thu, 15 Mar 2018 16:30:18 +0100 Subject: Throw an error if contract file doesn't contain the contract with the same name --- packages/deployer/src/compiler.ts | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'packages') diff --git a/packages/deployer/src/compiler.ts b/packages/deployer/src/compiler.ts index 83977709b..206f333f6 100644 --- a/packages/deployer/src/compiler.ts +++ b/packages/deployer/src/compiler.ts @@ -228,6 +228,11 @@ export class Compiler { } const contractName = path.basename(fileName, constants.SOLIDITY_FILE_EXTENSION); const contractIdentifier = `${fileName}:${contractName}`; + if (_.isUndefined(compiled.contracts[contractIdentifier])) { + throw new Error( + `Contract ${contractName} not found in ${fileName}. Please make sure your contract has the same name as a file`, + ); + } const abi: Web3.ContractAbi = JSON.parse(compiled.contracts[contractIdentifier].interface); const bytecode = `0x${compiled.contracts[contractIdentifier].bytecode}`; const runtimeBytecode = `0x${compiled.contracts[contractIdentifier].runtimeBytecode}`; -- cgit v1.2.3 From c4b4bb9e8e50af5a21091f4e8f54176ffb337739 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Thu, 15 Mar 2018 16:42:36 +0100 Subject: Compile contracts sequentially --- packages/deployer/src/compiler.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'packages') diff --git a/packages/deployer/src/compiler.ts b/packages/deployer/src/compiler.ts index 206f333f6..4563752f6 100644 --- a/packages/deployer/src/compiler.ts +++ b/packages/deployer/src/compiler.ts @@ -162,7 +162,9 @@ export class Compiler { _.forEach(fileNames, fileName => { this._setSourceTreeHash(fileName); }); - await Promise.all(_.map(fileNames, async fileName => this._compileContractAsync(fileName))); + for (const fileName of fileNames) { + await this._compileContractAsync(fileName); + } this._solcErrors.forEach(errMsg => { logUtils.log(errMsg); }); -- cgit v1.2.3 From 32feadee424b1ea8d96073d63790f5c5731dd30e Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Thu, 15 Mar 2018 17:07:57 +0100 Subject: Change version ranges to only support patch version increments --- .../src/contracts/current/multisig/MultiSigWallet/MultiSigWallet.sol | 2 +- .../multisig/MultiSigWalletWithTimeLock/MultiSigWalletWithTimeLock.sol | 2 +- .../MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.sol | 2 +- packages/contracts/src/contracts/current/protocol/Exchange/Exchange.sol | 2 +- .../src/contracts/current/protocol/TokenRegistry/TokenRegistry.sol | 2 +- .../current/protocol/TokenTransferProxy/TokenTransferProxy.sol | 2 +- packages/contracts/src/contracts/current/test/DummyToken/DummyToken.sol | 2 +- .../src/contracts/current/test/MaliciousToken/MaliciousToken.sol | 2 +- packages/contracts/src/contracts/current/test/Mintable/Mintable.sol | 2 +- .../contracts/src/contracts/current/tokens/ERC20Token/ERC20Token.sol | 2 +- packages/contracts/src/contracts/current/tokens/Token/Token.sol | 2 +- .../current/tokens/UnlimitedAllowanceToken/UnlimitedAllowanceToken.sol | 2 +- packages/contracts/src/contracts/current/tokens/WETH9/WETH9.sol | 2 +- packages/contracts/src/contracts/current/tokens/ZRXToken/ZRXToken.sol | 2 +- .../contracts/src/contracts/current/tutorials/Arbitrage/Arbitrage.sol | 2 +- .../src/contracts/current/tutorials/EtherDelta/AccountLevels.sol | 2 +- .../contracts/src/contracts/current/tutorials/EtherDelta/EtherDelta.sol | 2 +- packages/contracts/src/contracts/current/utils/Ownable/Ownable.sol | 2 +- packages/contracts/src/contracts/current/utils/SafeMath/SafeMath.sol | 2 +- packages/contracts/src/contracts/previous/ERC20Token/ERC20Token_v1.sol | 2 +- packages/contracts/src/contracts/previous/Ownable/Ownable_v1.sol | 2 +- packages/contracts/src/contracts/previous/SafeMath/SafeMath_v1.sol | 2 +- packages/contracts/src/contracts/previous/Token/Token_v1.sol | 2 +- .../previous/UnlimitedAllowanceToken/UnlimitedAllowanceToken_v1.sol | 2 +- 24 files changed, 24 insertions(+), 24 deletions(-) (limited to 'packages') diff --git a/packages/contracts/src/contracts/current/multisig/MultiSigWallet/MultiSigWallet.sol b/packages/contracts/src/contracts/current/multisig/MultiSigWallet/MultiSigWallet.sol index 79fd92029..56c4d20a9 100644 --- a/packages/contracts/src/contracts/current/multisig/MultiSigWallet/MultiSigWallet.sol +++ b/packages/contracts/src/contracts/current/multisig/MultiSigWallet/MultiSigWallet.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.10; +pragma solidity ~0.4.10; /// @title Multisignature wallet - Allows multiple parties to agree on transactions before execution. /// @author Stefan George - diff --git a/packages/contracts/src/contracts/current/multisig/MultiSigWalletWithTimeLock/MultiSigWalletWithTimeLock.sol b/packages/contracts/src/contracts/current/multisig/MultiSigWalletWithTimeLock/MultiSigWalletWithTimeLock.sol index a545d9813..791c01af8 100644 --- a/packages/contracts/src/contracts/current/multisig/MultiSigWalletWithTimeLock/MultiSigWalletWithTimeLock.sol +++ b/packages/contracts/src/contracts/current/multisig/MultiSigWalletWithTimeLock/MultiSigWalletWithTimeLock.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.10; +pragma solidity ~0.4.10; import { MultiSigWallet } from "../MultiSigWallet/MultiSigWallet.sol"; diff --git a/packages/contracts/src/contracts/current/multisig/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.sol b/packages/contracts/src/contracts/current/multisig/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.sol index 3c6a3d2ef..ca2989483 100644 --- a/packages/contracts/src/contracts/current/multisig/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.sol +++ b/packages/contracts/src/contracts/current/multisig/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.10; +pragma solidity ~0.4.10; import { MultiSigWalletWithTimeLock } from "../MultiSigWalletWithTimeLock/MultiSigWalletWithTimeLock.sol"; diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/Exchange.sol b/packages/contracts/src/contracts/current/protocol/Exchange/Exchange.sol index 8dacf797c..b1bf8a260 100644 --- a/packages/contracts/src/contracts/current/protocol/Exchange/Exchange.sol +++ b/packages/contracts/src/contracts/current/protocol/Exchange/Exchange.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.14; +pragma solidity ~0.4.14; import { TokenTransferProxy } from "../TokenTransferProxy/TokenTransferProxy.sol"; import { Token_v1 as Token } from "../../../previous/Token/Token_v1.sol"; diff --git a/packages/contracts/src/contracts/current/protocol/TokenRegistry/TokenRegistry.sol b/packages/contracts/src/contracts/current/protocol/TokenRegistry/TokenRegistry.sol index 3bd2fbfaf..9ab72f72d 100644 --- a/packages/contracts/src/contracts/current/protocol/TokenRegistry/TokenRegistry.sol +++ b/packages/contracts/src/contracts/current/protocol/TokenRegistry/TokenRegistry.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.11; +pragma solidity ~0.4.11; import { Ownable_v1 as Ownable } from "../../../previous/Ownable/Ownable_v1.sol"; diff --git a/packages/contracts/src/contracts/current/protocol/TokenTransferProxy/TokenTransferProxy.sol b/packages/contracts/src/contracts/current/protocol/TokenTransferProxy/TokenTransferProxy.sol index 1ce949fa6..e78d264d4 100644 --- a/packages/contracts/src/contracts/current/protocol/TokenTransferProxy/TokenTransferProxy.sol +++ b/packages/contracts/src/contracts/current/protocol/TokenTransferProxy/TokenTransferProxy.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.11; +pragma solidity ~0.4.11; import { Token_v1 as Token } from "../../../previous/Token/Token_v1.sol"; import { Ownable_v1 as Ownable } from "../../../previous/Ownable/Ownable_v1.sol"; diff --git a/packages/contracts/src/contracts/current/test/DummyToken/DummyToken.sol b/packages/contracts/src/contracts/current/test/DummyToken/DummyToken.sol index ab04f4d16..0cd04312d 100644 --- a/packages/contracts/src/contracts/current/test/DummyToken/DummyToken.sol +++ b/packages/contracts/src/contracts/current/test/DummyToken/DummyToken.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.18; +pragma solidity ~0.4.18; import { Mintable } from "../Mintable/Mintable.sol"; import { Ownable } from "../../utils/Ownable/Ownable.sol"; diff --git a/packages/contracts/src/contracts/current/test/MaliciousToken/MaliciousToken.sol b/packages/contracts/src/contracts/current/test/MaliciousToken/MaliciousToken.sol index 9e502616c..c5d6207e8 100644 --- a/packages/contracts/src/contracts/current/test/MaliciousToken/MaliciousToken.sol +++ b/packages/contracts/src/contracts/current/test/MaliciousToken/MaliciousToken.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.18; +pragma solidity ~0.4.18; import { ERC20Token } from "../../tokens/ERC20Token/ERC20Token.sol"; diff --git a/packages/contracts/src/contracts/current/test/Mintable/Mintable.sol b/packages/contracts/src/contracts/current/test/Mintable/Mintable.sol index cf7ee35a5..33022cfc6 100644 --- a/packages/contracts/src/contracts/current/test/Mintable/Mintable.sol +++ b/packages/contracts/src/contracts/current/test/Mintable/Mintable.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.18; +pragma solidity ~0.4.18; import { UnlimitedAllowanceToken } from "../../tokens/UnlimitedAllowanceToken/UnlimitedAllowanceToken.sol"; import { SafeMath } from "../../utils/SafeMath/SafeMath.sol"; diff --git a/packages/contracts/src/contracts/current/tokens/ERC20Token/ERC20Token.sol b/packages/contracts/src/contracts/current/tokens/ERC20Token/ERC20Token.sol index 0e5b87aa4..c59ab3e7a 100644 --- a/packages/contracts/src/contracts/current/tokens/ERC20Token/ERC20Token.sol +++ b/packages/contracts/src/contracts/current/tokens/ERC20Token/ERC20Token.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.18; +pragma solidity ~0.4.18; import { Token } from "../Token/Token.sol"; diff --git a/packages/contracts/src/contracts/current/tokens/Token/Token.sol b/packages/contracts/src/contracts/current/tokens/Token/Token.sol index bf4e71dcd..6bf83cd51 100644 --- a/packages/contracts/src/contracts/current/tokens/Token/Token.sol +++ b/packages/contracts/src/contracts/current/tokens/Token/Token.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.18; +pragma solidity ~0.4.18; contract Token { diff --git a/packages/contracts/src/contracts/current/tokens/UnlimitedAllowanceToken/UnlimitedAllowanceToken.sol b/packages/contracts/src/contracts/current/tokens/UnlimitedAllowanceToken/UnlimitedAllowanceToken.sol index 699f535d2..569b4f021 100644 --- a/packages/contracts/src/contracts/current/tokens/UnlimitedAllowanceToken/UnlimitedAllowanceToken.sol +++ b/packages/contracts/src/contracts/current/tokens/UnlimitedAllowanceToken/UnlimitedAllowanceToken.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.18; +pragma solidity ~0.4.18; import { ERC20Token } from "../ERC20Token/ERC20Token.sol"; diff --git a/packages/contracts/src/contracts/current/tokens/WETH9/WETH9.sol b/packages/contracts/src/contracts/current/tokens/WETH9/WETH9.sol index 733ca414b..22df0600c 100644 --- a/packages/contracts/src/contracts/current/tokens/WETH9/WETH9.sol +++ b/packages/contracts/src/contracts/current/tokens/WETH9/WETH9.sol @@ -13,7 +13,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -pragma solidity ^0.4.18; +pragma solidity ~0.4.18; contract WETH9 { string public name = "Wrapped Ether"; diff --git a/packages/contracts/src/contracts/current/tokens/ZRXToken/ZRXToken.sol b/packages/contracts/src/contracts/current/tokens/ZRXToken/ZRXToken.sol index 7f5e1f849..b12a6a186 100644 --- a/packages/contracts/src/contracts/current/tokens/ZRXToken/ZRXToken.sol +++ b/packages/contracts/src/contracts/current/tokens/ZRXToken/ZRXToken.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.11; +pragma solidity ~0.4.11; import { UnlimitedAllowanceToken_v1 as UnlimitedAllowanceToken } from "../../../previous/UnlimitedAllowanceToken/UnlimitedAllowanceToken_v1.sol"; diff --git a/packages/contracts/src/contracts/current/tutorials/Arbitrage/Arbitrage.sol b/packages/contracts/src/contracts/current/tutorials/Arbitrage/Arbitrage.sol index a9f3c22e6..1867781fb 100644 --- a/packages/contracts/src/contracts/current/tutorials/Arbitrage/Arbitrage.sol +++ b/packages/contracts/src/contracts/current/tutorials/Arbitrage/Arbitrage.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.19; +pragma solidity ~0.4.19; import { Exchange } from "../../protocol/Exchange/Exchange.sol"; import { EtherDelta } from "../EtherDelta/EtherDelta.sol"; diff --git a/packages/contracts/src/contracts/current/tutorials/EtherDelta/AccountLevels.sol b/packages/contracts/src/contracts/current/tutorials/EtherDelta/AccountLevels.sol index 8d7a930d3..17d839eb7 100644 --- a/packages/contracts/src/contracts/current/tutorials/EtherDelta/AccountLevels.sol +++ b/packages/contracts/src/contracts/current/tutorials/EtherDelta/AccountLevels.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.19; +pragma solidity ~0.4.19; contract AccountLevels { //given a user, returns an account level diff --git a/packages/contracts/src/contracts/current/tutorials/EtherDelta/EtherDelta.sol b/packages/contracts/src/contracts/current/tutorials/EtherDelta/EtherDelta.sol index 49847ab48..fc5e5f9de 100644 --- a/packages/contracts/src/contracts/current/tutorials/EtherDelta/EtherDelta.sol +++ b/packages/contracts/src/contracts/current/tutorials/EtherDelta/EtherDelta.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.19; +pragma solidity ~0.4.19; import { SafeMath } from "../../utils/SafeMath/SafeMath.sol"; import { AccountLevels } from "./AccountLevels.sol"; diff --git a/packages/contracts/src/contracts/current/utils/Ownable/Ownable.sol b/packages/contracts/src/contracts/current/utils/Ownable/Ownable.sol index 9b3d6b9cf..9416c8f8e 100644 --- a/packages/contracts/src/contracts/current/utils/Ownable/Ownable.sol +++ b/packages/contracts/src/contracts/current/utils/Ownable/Ownable.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.18; +pragma solidity ~0.4.18; /* * Ownable diff --git a/packages/contracts/src/contracts/current/utils/SafeMath/SafeMath.sol b/packages/contracts/src/contracts/current/utils/SafeMath/SafeMath.sol index 955a9e379..c816b3fd1 100644 --- a/packages/contracts/src/contracts/current/utils/SafeMath/SafeMath.sol +++ b/packages/contracts/src/contracts/current/utils/SafeMath/SafeMath.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.18; +pragma solidity ~0.4.18; contract SafeMath { function safeMul(uint a, uint b) diff --git a/packages/contracts/src/contracts/previous/ERC20Token/ERC20Token_v1.sol b/packages/contracts/src/contracts/previous/ERC20Token/ERC20Token_v1.sol index e05ee2d5e..b2a5636ae 100644 --- a/packages/contracts/src/contracts/previous/ERC20Token/ERC20Token_v1.sol +++ b/packages/contracts/src/contracts/previous/ERC20Token/ERC20Token_v1.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.11; +pragma solidity ~0.4.11; import { Token_v1 as Token } from "../Token/Token_v1.sol"; diff --git a/packages/contracts/src/contracts/previous/Ownable/Ownable_v1.sol b/packages/contracts/src/contracts/previous/Ownable/Ownable_v1.sol index c87438fa4..c1b67956e 100644 --- a/packages/contracts/src/contracts/previous/Ownable/Ownable_v1.sol +++ b/packages/contracts/src/contracts/previous/Ownable/Ownable_v1.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.11; +pragma solidity ~0.4.11; /* * Ownable diff --git a/packages/contracts/src/contracts/previous/SafeMath/SafeMath_v1.sol b/packages/contracts/src/contracts/previous/SafeMath/SafeMath_v1.sol index 341d611ec..ea8f899ef 100644 --- a/packages/contracts/src/contracts/previous/SafeMath/SafeMath_v1.sol +++ b/packages/contracts/src/contracts/previous/SafeMath/SafeMath_v1.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.11; +pragma solidity ~0.4.11; contract SafeMath_v1 { function safeMul(uint a, uint b) diff --git a/packages/contracts/src/contracts/previous/Token/Token_v1.sol b/packages/contracts/src/contracts/previous/Token/Token_v1.sol index de619fb7e..5a9c82ded 100644 --- a/packages/contracts/src/contracts/previous/Token/Token_v1.sol +++ b/packages/contracts/src/contracts/previous/Token/Token_v1.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.11; +pragma solidity ~0.4.11; contract Token_v1 { diff --git a/packages/contracts/src/contracts/previous/UnlimitedAllowanceToken/UnlimitedAllowanceToken_v1.sol b/packages/contracts/src/contracts/previous/UnlimitedAllowanceToken/UnlimitedAllowanceToken_v1.sol index 6376f3f2c..ccb4f8d28 100644 --- a/packages/contracts/src/contracts/previous/UnlimitedAllowanceToken/UnlimitedAllowanceToken_v1.sol +++ b/packages/contracts/src/contracts/previous/UnlimitedAllowanceToken/UnlimitedAllowanceToken_v1.sol @@ -16,7 +16,7 @@ */ -pragma solidity ^0.4.11; +pragma solidity ~0.4.11; import { ERC20Token_v1 as ERC20Token } from "../ERC20Token/ERC20Token_v1.sol"; -- cgit v1.2.3 From f45191d0e81e3ad3873e78c3891fdd5f9e9fd55c Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Thu, 15 Mar 2018 17:08:48 +0100 Subject: Support proper semver version ranges --- packages/deployer/package.json | 2 ++ packages/deployer/src/compiler.ts | 35 ++++++++++++++++++++--------------- packages/deployer/src/utils/types.ts | 2 +- 3 files changed, 23 insertions(+), 16 deletions(-) (limited to 'packages') diff --git a/packages/deployer/package.json b/packages/deployer/package.json index e6e8dcc4b..3982c0067 100644 --- a/packages/deployer/package.json +++ b/packages/deployer/package.json @@ -33,6 +33,7 @@ "@0xproject/monorepo-scripts": "^0.1.14", "@0xproject/tslint-config": "^0.4.12", "@types/require-from-string": "^1.2.0", + "@types/semver": "^5.5.0", "@types/yargs": "^11.0.0", "chai": "^4.0.1", "copyfiles": "^1.2.0", @@ -54,6 +55,7 @@ "isomorphic-fetch": "^2.2.1", "lodash": "^4.17.4", "require-from-string": "^2.0.1", + "semver": "^5.5.0", "solc": "^0.4.18", "web3": "^0.20.0", "web3-eth-abi": "^1.0.0-beta.24", diff --git a/packages/deployer/src/compiler.ts b/packages/deployer/src/compiler.ts index 4563752f6..942777458 100644 --- a/packages/deployer/src/compiler.ts +++ b/packages/deployer/src/compiler.ts @@ -5,6 +5,7 @@ import 'isomorphic-fetch'; import * as _ from 'lodash'; import * as path from 'path'; import * as requireFromString from 'require-from-string'; +import * as semver from 'semver'; import solc = require('solc'); import * as Web3 from 'web3'; @@ -23,7 +24,7 @@ import { import { utils } from './utils/utils'; const ALL_CONTRACTS_IDENTIFIER = '*'; -const SOLIDITY_VERSION_REGEX = /(?:solidity\s\^?)(\d+\.\d+\.\d+)/; +const SOLIDITY_VERSION_RANGE_REGEX = /pragma solidity (.*);/; const SOLIDITY_FILE_EXTENSION_REGEX = /(.*\.sol)/; const IMPORT_REGEX = /(import\s)/; const DEPENDENCY_PATH_REGEX = /"([^"]+)"/; // Source: https://github.com/BlockChainCompany/soljitsu/blob/master/lib/shared.js @@ -85,10 +86,10 @@ export class Compiler { private static _getContractSpecificSourceData(source: string): ContractSpecificSourceData { const dependencies: string[] = []; const sourceHash = ethUtil.sha3(source); - const solcVersion = Compiler._parseSolidityVersion(source); + const solcVersionRange = Compiler._parseSolidityVersionRange(source); const contractSpecificSourceData: ContractSpecificSourceData = { dependencies, - solcVersion, + solcVersionRange, sourceHash, }; const lines = source.split('\n'); @@ -105,17 +106,17 @@ export class Compiler { return contractSpecificSourceData; } /** - * Searches Solidity source code for compiler version. + * Searches Solidity source code for compiler version range. * @param source Source code of contract. - * @return Solc compiler version. + * @return Solc compiler version range. */ - private static _parseSolidityVersion(source: string): string { - const solcVersionMatch = source.match(SOLIDITY_VERSION_REGEX); - if (_.isNull(solcVersionMatch)) { - throw new Error('Could not find Solidity version in source'); + private static _parseSolidityVersionRange(source: string): string { + const solcVersionRangeMatch = source.match(SOLIDITY_VERSION_RANGE_REGEX); + if (_.isNull(solcVersionRangeMatch)) { + throw new Error('Could not find Solidity version range in source'); } - const solcVersion = solcVersionMatch[1]; - return solcVersion; + const solcVersionRange = solcVersionRangeMatch[1]; + return solcVersionRange; } /** * Normalizes the path found in the error message. @@ -189,8 +190,12 @@ export class Compiler { if (!shouldCompile) { return; } - - const fullSolcVersion = binPaths[contractSpecificSourceData.solcVersion]; + const availableCompilerVersions = _.keys(binPaths); + const solcVersion = semver.maxSatisfying( + availableCompilerVersions, + contractSpecificSourceData.solcVersionRange, + ); + const fullSolcVersion = binPaths[solcVersion]; const compilerBinFilename = path.join(__dirname, '../../solc_bin', fullSolcVersion); let solcjs: string; const isCompilerAvailableLocally = fs.existsSync(compilerBinFilename); @@ -208,7 +213,7 @@ export class Compiler { } const solcInstance = solc.setupMethods(requireFromString(solcjs, compilerBinFilename)); - logUtils.log(`Compiling ${fileName}...`); + logUtils.log(`Compiling ${fileName} with Solidity v${solcVersion}...`); const source = this._contractSources[fileName]; const input = { [fileName]: source, @@ -243,7 +248,7 @@ export class Compiler { const sources = _.keys(compiled.sources); const updated_at = Date.now(); const contractNetworkData: ContractNetworkData = { - solc_version: contractSpecificSourceData.solcVersion, + solc_version: solcVersion, keccak256: sourceHash, source_tree_hash: sourceTreeHash, optimizer_enabled: this._optimizerEnabled, diff --git a/packages/deployer/src/utils/types.ts b/packages/deployer/src/utils/types.ts index 0068faf6a..f33f8f66a 100644 --- a/packages/deployer/src/utils/types.ts +++ b/packages/deployer/src/utils/types.ts @@ -84,7 +84,7 @@ export interface ContractSourceData { export interface ContractSpecificSourceData { dependencies: string[]; - solcVersion: string; + solcVersionRange: string; sourceHash: Buffer; sourceTreeHashIfExists?: Buffer; } -- cgit v1.2.3 From 439e8640859cf790bac51c1beeec4cf65aa33c57 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Fri, 16 Mar 2018 11:09:12 +0100 Subject: Change the type of optimizerEnabled to boolean and convert it to number only before passing to a compiler --- packages/deployer/src/cli.ts | 4 ++-- packages/deployer/src/compiler.ts | 4 ++-- packages/deployer/src/utils/types.ts | 4 ++-- packages/deployer/test/util/constants.ts | 2 +- packages/deployer/tsconfig.json | 3 +-- 5 files changed, 8 insertions(+), 9 deletions(-) (limited to 'packages') diff --git a/packages/deployer/src/cli.ts b/packages/deployer/src/cli.ts index 176eaf973..efbf56bb0 100644 --- a/packages/deployer/src/cli.ts +++ b/packages/deployer/src/cli.ts @@ -29,7 +29,7 @@ async function onCompileCommandAsync(argv: CliOptions): Promise { const opts: CompilerOptions = { contractsDir: argv.contractsDir, networkId: argv.networkId, - optimizerEnabled: argv.shouldOptimize ? 1 : 0, + optimizerEnabled: argv.shouldOptimize, artifactsDir: argv.artifactsDir, specifiedContracts: getContractsSetFromList(argv.contracts), }; @@ -47,7 +47,7 @@ async function onDeployCommandAsync(argv: CliOptions): Promise { const compilerOpts: CompilerOptions = { contractsDir: argv.contractsDir, networkId, - optimizerEnabled: argv.shouldOptimize ? 1 : 0, + optimizerEnabled: argv.shouldOptimize, artifactsDir: argv.artifactsDir, specifiedContracts: getContractsSetFromList(argv.contracts), }; diff --git a/packages/deployer/src/compiler.ts b/packages/deployer/src/compiler.ts index 942777458..28232a661 100644 --- a/packages/deployer/src/compiler.ts +++ b/packages/deployer/src/compiler.ts @@ -32,7 +32,7 @@ const DEPENDENCY_PATH_REGEX = /"([^"]+)"/; // Source: https://github.com/BlockCh export class Compiler { private _contractsDir: string; private _networkId: number; - private _optimizerEnabled: number; + private _optimizerEnabled: boolean; private _artifactsDir: string; private _contractSources?: ContractSources; private _solcErrors: Set = new Set(); @@ -223,7 +223,7 @@ export class Compiler { }; const compiled = solcInstance.compile( sourcesToCompile, - this._optimizerEnabled, + Number(this._optimizerEnabled), this._findImportsIfSourcesExist.bind(this), ); diff --git a/packages/deployer/src/utils/types.ts b/packages/deployer/src/utils/types.ts index f33f8f66a..13b24b9b7 100644 --- a/packages/deployer/src/utils/types.ts +++ b/packages/deployer/src/utils/types.ts @@ -20,7 +20,7 @@ export interface ContractNetworks { export interface ContractNetworkData { solc_version: string; - optimizer_enabled: number; + optimizer_enabled: boolean; keccak256: string; source_tree_hash: string; abi: Web3.ContractAbi; @@ -53,7 +53,7 @@ export interface CliOptions extends yargs.Arguments { export interface CompilerOptions { contractsDir: string; networkId: number; - optimizerEnabled: number; + optimizerEnabled: boolean; artifactsDir: string; specifiedContracts: Set; } diff --git a/packages/deployer/test/util/constants.ts b/packages/deployer/test/util/constants.ts index 7b6960359..7ba94c1f2 100644 --- a/packages/deployer/test/util/constants.ts +++ b/packages/deployer/test/util/constants.ts @@ -3,7 +3,7 @@ import { BigNumber } from '@0xproject/utils'; export const constants = { networkId: 0, jsonrpcUrl: 'http://localhost:8545', - optimizerEnabled: 0, + optimizerEnabled: true, gasPrice: new BigNumber(20000000000), timeoutMs: 20000, zrxTokenAddress: '0xe41d2489571d322189246dafa5ebde1f4699f498', diff --git a/packages/deployer/tsconfig.json b/packages/deployer/tsconfig.json index 897446b66..befcde5b7 100644 --- a/packages/deployer/tsconfig.json +++ b/packages/deployer/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../tsconfig", "compilerOptions": { "outDir": "lib", - "strictFunctionTypes": false, - "strictNullChecks": false + "strictFunctionTypes": false }, "include": [ "./src/**/*", -- cgit v1.2.3 From 18b9fe525622d9e18491f76136d7697806996a09 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Fri, 16 Mar 2018 15:09:11 +0100 Subject: Enable strictNullChecks --- packages/deployer/src/cli.ts | 4 +- packages/deployer/src/commands.ts | 2 +- packages/deployer/src/compiler.ts | 210 +++++++++----------------------- packages/deployer/src/utils/compiler.ts | 118 ++++++++++++++++++ packages/deployer/src/utils/types.ts | 2 +- packages/deployer/test/deploy_test.ts | 2 +- 6 files changed, 182 insertions(+), 156 deletions(-) create mode 100644 packages/deployer/src/utils/compiler.ts (limited to 'packages') diff --git a/packages/deployer/src/cli.ts b/packages/deployer/src/cli.ts index efbf56bb0..d1bd645b3 100644 --- a/packages/deployer/src/cli.ts +++ b/packages/deployer/src/cli.ts @@ -63,9 +63,9 @@ async function onDeployCommandAsync(argv: CliOptions): Promise { networkId, defaults, }; - const deployerArgsString = argv.args; + const deployerArgsString = argv.args as string; const deployerArgs = deployerArgsString.split(','); - await commands.deployAsync(argv.contract, deployerArgs, deployerOpts); + await commands.deployAsync(argv.contract as string, deployerArgs, deployerOpts); } /** * Creates a set of contracts to compile. diff --git a/packages/deployer/src/commands.ts b/packages/deployer/src/commands.ts index 32af7fc3f..8e544a60b 100644 --- a/packages/deployer/src/commands.ts +++ b/packages/deployer/src/commands.ts @@ -5,7 +5,7 @@ import { CompilerOptions, DeployerOptions } from './utils/types'; export const commands = { async compileAsync(opts: CompilerOptions): Promise { const compiler = new Compiler(opts); - await compiler.compileAllAsync(); + await compiler.compileAsync(); }, async deployAsync(contractName: string, args: any[], opts: DeployerOptions): Promise { const deployer = new Deployer(opts); diff --git a/packages/deployer/src/compiler.ts b/packages/deployer/src/compiler.ts index 28232a661..d9571488e 100644 --- a/packages/deployer/src/compiler.ts +++ b/packages/deployer/src/compiler.ts @@ -10,6 +10,14 @@ import solc = require('solc'); import * as Web3 from 'web3'; import { binPaths } from './solc/bin_paths'; +import { + createArtifactsDirIfDoesNotExistAsync, + findImportIfExist, + getContractArtifactIfExistsAsync, + getNormalizedErrMsg, + parseDependencies, + parseSolidityVersionRange, +} from './utils/compiler'; import { constants } from './utils/constants'; import { fsWrapper } from './utils/fs_wrapper'; import { @@ -24,17 +32,13 @@ import { import { utils } from './utils/utils'; const ALL_CONTRACTS_IDENTIFIER = '*'; -const SOLIDITY_VERSION_RANGE_REGEX = /pragma solidity (.*);/; -const SOLIDITY_FILE_EXTENSION_REGEX = /(.*\.sol)/; -const IMPORT_REGEX = /(import\s)/; -const DEPENDENCY_PATH_REGEX = /"([^"]+)"/; // Source: https://github.com/BlockChainCompany/soljitsu/blob/master/lib/shared.js export class Compiler { private _contractsDir: string; private _networkId: number; private _optimizerEnabled: boolean; private _artifactsDir: string; - private _contractSources?: ContractSources; + private _contractSources!: ContractSources; private _solcErrors: Set = new Set(); private _specifiedContracts: Set = new Set(); private _contractSourceData: ContractSourceData = {}; @@ -78,64 +82,6 @@ export class Compiler { } return sources; } - /** - * Gets contract dependendencies and keccak256 hash from source. - * @param source Source code of contract. - * @return Object with contract dependencies and keccak256 hash of source. - */ - private static _getContractSpecificSourceData(source: string): ContractSpecificSourceData { - const dependencies: string[] = []; - const sourceHash = ethUtil.sha3(source); - const solcVersionRange = Compiler._parseSolidityVersionRange(source); - const contractSpecificSourceData: ContractSpecificSourceData = { - dependencies, - solcVersionRange, - sourceHash, - }; - const lines = source.split('\n'); - _.forEach(lines, line => { - if (!_.isNull(line.match(IMPORT_REGEX))) { - const dependencyMatch = line.match(DEPENDENCY_PATH_REGEX); - if (!_.isNull(dependencyMatch)) { - const dependencyPath = dependencyMatch[1]; - const fileName = path.basename(dependencyPath); - contractSpecificSourceData.dependencies.push(fileName); - } - } - }); - return contractSpecificSourceData; - } - /** - * Searches Solidity source code for compiler version range. - * @param source Source code of contract. - * @return Solc compiler version range. - */ - private static _parseSolidityVersionRange(source: string): string { - const solcVersionRangeMatch = source.match(SOLIDITY_VERSION_RANGE_REGEX); - if (_.isNull(solcVersionRangeMatch)) { - throw new Error('Could not find Solidity version range in source'); - } - const solcVersionRange = solcVersionRangeMatch[1]; - return solcVersionRange; - } - /** - * Normalizes the path found in the error message. - * Example: converts 'base/Token.sol:6:46: Warning: Unused local variable' - * to 'Token.sol:6:46: Warning: Unused local variable' - * This is used to prevent logging the same error multiple times. - * @param errMsg An error message from the compiled output. - * @return The error message with directories truncated from the contract path. - */ - private static _getNormalizedErrMsg(errMsg: string): string { - const errPathMatch = errMsg.match(SOLIDITY_FILE_EXTENSION_REGEX); - if (_.isNull(errPathMatch)) { - throw new Error('Could not find a path in error message'); - } - const errPath = errPathMatch[0]; - const baseContract = path.basename(errPath); - const normalizedErrMsg = errMsg.replace(errPath, baseContract); - return normalizedErrMsg; - } /** * Instantiates a new instance of the Compiler class. * @param opts Options specifying directories, network, and optimization settings. @@ -149,20 +95,15 @@ export class Compiler { this._specifiedContracts = opts.specifiedContracts; } /** - * Compiles all Solidity files found in contractsDir and writes JSON artifacts to artifactsDir. + * Compiles selected Solidity files and writes JSON artifacts to artifactsDir. */ - public async compileAllAsync(): Promise { - await this._createArtifactsDirIfDoesNotExistAsync(); + public async compileAsync(): Promise { + await createArtifactsDirIfDoesNotExistAsync(this._artifactsDir); this._contractSources = await Compiler._getContractSourcesAsync(this._contractsDir); - _.forIn(this._contractSources, (source, fileName) => { - this._contractSourceData[fileName] = Compiler._getContractSpecificSourceData(source); - }); + _.forIn(this._contractSources, this._setContractSpecificSourceData.bind(this)); const fileNames = this._specifiedContracts.has(ALL_CONTRACTS_IDENTIFIER) ? _.keys(this._contractSources) : Array.from(this._specifiedContracts.values()); - _.forEach(fileNames, fileName => { - this._setSourceTreeHash(fileName); - }); for (const fileName of fileNames) { await this._compileContractAsync(fileName); } @@ -179,14 +120,19 @@ export class Compiler { throw new Error('Contract sources not yet initialized'); } const contractSpecificSourceData = this._contractSourceData[fileName]; - const currentArtifactIfExists = (await this._getContractArtifactIfExistsAsync(fileName)) as ContractArtifact; + const currentArtifactIfExists = await getContractArtifactIfExistsAsync(this._artifactsDir, fileName); const sourceHash = `0x${contractSpecificSourceData.sourceHash.toString('hex')}`; - const sourceTreeHash = `0x${contractSpecificSourceData.sourceTreeHashIfExists.toString('hex')}`; + const sourceTreeHash = `0x${contractSpecificSourceData.sourceTreeHash.toString('hex')}`; - const shouldCompile = - _.isUndefined(currentArtifactIfExists) || - currentArtifactIfExists.networks[this._networkId].optimizer_enabled !== this._optimizerEnabled || - currentArtifactIfExists.networks[this._networkId].source_tree_hash !== sourceTreeHash; + let shouldCompile = false; + if (_.isUndefined(currentArtifactIfExists)) { + shouldCompile = true; + } else { + const currentArtifact = currentArtifactIfExists as ContractArtifact; + shouldCompile = + currentArtifact.networks[this._networkId].optimizer_enabled !== this._optimizerEnabled || + currentArtifact.networks[this._networkId].source_tree_hash !== sourceTreeHash; + } if (!shouldCompile) { return; } @@ -221,15 +167,13 @@ export class Compiler { const sourcesToCompile = { sources: input, }; - const compiled = solcInstance.compile( - sourcesToCompile, - Number(this._optimizerEnabled), - this._findImportsIfSourcesExist.bind(this), + const compiled = solcInstance.compile(sourcesToCompile, Number(this._optimizerEnabled), importPath => + findImportIfExist(this._contractSources, importPath), ); if (!_.isUndefined(compiled.errors)) { _.forEach(compiled.errors, errMsg => { - const normalizedErrMsg = Compiler._getNormalizedErrMsg(errMsg); + const normalizedErrMsg = getNormalizedErrMsg(errMsg); this._solcErrors.add(normalizedErrMsg); }); } @@ -263,10 +207,11 @@ export class Compiler { let newArtifact: ContractArtifact; if (!_.isUndefined(currentArtifactIfExists)) { + const currentArtifact = currentArtifactIfExists as ContractArtifact; newArtifact = { - ...currentArtifactIfExists, + ...currentArtifact, networks: { - ...currentArtifactIfExists.networks, + ...currentArtifact.networks, [this._networkId]: contractNetworkData, }, }; @@ -285,79 +230,42 @@ export class Compiler { logUtils.log(`${fileName} artifact saved!`); } /** - * Sets the source tree hash for a file and its dependencies. - * @param fileName Name of contract file. - */ - private _setSourceTreeHash(fileName: string): void { - const contractSpecificSourceData = this._contractSourceData[fileName]; - if (_.isUndefined(contractSpecificSourceData)) { - throw new Error(`Contract data for ${fileName} not yet set`); - } - if (_.isUndefined(contractSpecificSourceData.sourceTreeHashIfExists)) { - const dependencies = contractSpecificSourceData.dependencies; - if (dependencies.length === 0) { - contractSpecificSourceData.sourceTreeHashIfExists = contractSpecificSourceData.sourceHash; - } else { - _.forEach(dependencies, dependency => { - this._setSourceTreeHash(dependency); - }); - const dependencySourceTreeHashes = _.map( - dependencies, - dependency => this._contractSourceData[dependency].sourceTreeHashIfExists, - ); - const sourceTreeHashesBuffer = Buffer.concat([ - contractSpecificSourceData.sourceHash, - ...dependencySourceTreeHashes, - ]); - contractSpecificSourceData.sourceTreeHashIfExists = ethUtil.sha3(sourceTreeHashesBuffer); - } - } - } - /** - * Callback to resolve dependencies with `solc.compile`. - * Throws error if contractSources not yet initialized. - * @param importPath Path to an imported dependency. - * @return Import contents object containing source code of dependency. + * Gets contract dependendencies and keccak256 hash from source. + * @param source Source code of contract. + * @return Object with contract dependencies and keccak256 hash of source. */ - private _findImportsIfSourcesExist(importPath: string): solc.ImportContents { - const fileName = path.basename(importPath); - const source = this._contractSources[fileName]; - if (_.isUndefined(source)) { - throw new Error(`Contract source not found for ${fileName}`); + private _setContractSpecificSourceData(source: string, fileName: string): void { + if (!_.isUndefined(this._contractSourceData[fileName])) { + return; } - const importContents: solc.ImportContents = { - contents: source, + const sourceHash = ethUtil.sha3(source); + const solcVersionRange = parseSolidityVersionRange(source); + const dependencies = parseDependencies(source); + const sourceTreeHash = this._getSourceTreeHash(fileName, sourceHash, dependencies); + this._contractSourceData[fileName] = { + dependencies, + solcVersionRange, + sourceHash, + sourceTreeHash, }; - return importContents; - } - /** - * Creates the artifacts directory if it does not already exist. - */ - private async _createArtifactsDirIfDoesNotExistAsync(): Promise { - if (!fsWrapper.doesPathExistSync(this._artifactsDir)) { - logUtils.log('Creating artifacts directory...'); - await fsWrapper.mkdirAsync(this._artifactsDir); - } } /** - * Gets contract data on network or returns if an artifact does not exist. + * Gets the source tree hash for a file and its dependencies. * @param fileName Name of contract file. - * @return Contract data on network or undefined. */ - private async _getContractArtifactIfExistsAsync(fileName: string): Promise { - let contractArtifact; - const contractName = path.basename(fileName, constants.SOLIDITY_FILE_EXTENSION); - const currentArtifactPath = `${this._artifactsDir}/${contractName}.json`; - try { - const opts = { - encoding: 'utf8', - }; - const contractArtifactString = await fsWrapper.readFileAsync(currentArtifactPath, opts); - contractArtifact = JSON.parse(contractArtifactString); - return contractArtifact; - } catch (err) { - logUtils.log(`Artifact for ${fileName} does not exist`); - return undefined; + private _getSourceTreeHash(fileName: string, sourceHash: Buffer, dependencies: string[]): Buffer { + if (dependencies.length === 0) { + return sourceHash; + } else { + const dependencySourceTreeHashes = _.map(dependencies, dependency => { + const source = this._contractSources[dependency]; + this._setContractSpecificSourceData(source, dependency); + const sourceData = this._contractSourceData[dependency]; + return this._getSourceTreeHash(dependency, sourceData.sourceHash, sourceData.dependencies); + }); + const sourceTreeHashesBuffer = Buffer.concat([sourceHash, ...dependencySourceTreeHashes]); + const sourceTreeHash = ethUtil.sha3(sourceTreeHashesBuffer); + return sourceTreeHash; } } } diff --git a/packages/deployer/src/utils/compiler.ts b/packages/deployer/src/utils/compiler.ts new file mode 100644 index 000000000..3fb35e9ed --- /dev/null +++ b/packages/deployer/src/utils/compiler.ts @@ -0,0 +1,118 @@ +import { logUtils } from '@0xproject/utils'; +import * as _ from 'lodash'; +import * as path from 'path'; +import * as solc from 'solc'; + +import { constants } from './constants'; +import { fsWrapper } from './fs_wrapper'; +import { ContractArtifact, ContractSources } from './types'; + +/** + * Gets contract data on network or returns if an artifact does not exist. + * @param fileName Name of contract file. + * @return Contract data on network or undefined. + */ +export async function getContractArtifactIfExistsAsync( + artifactsDir: string, + fileName: string, +): Promise { + let contractArtifact; + const contractName = path.basename(fileName, constants.SOLIDITY_FILE_EXTENSION); + const currentArtifactPath = `${artifactsDir}/${contractName}.json`; + try { + const opts = { + encoding: 'utf8', + }; + const contractArtifactString = await fsWrapper.readFileAsync(currentArtifactPath, opts); + contractArtifact = JSON.parse(contractArtifactString); + return contractArtifact; + } catch (err) { + logUtils.log(`Artifact for ${fileName} does not exist`); + return undefined; + } +} + +/** + * Creates the artifacts directory if it does not already exist. + */ +export async function createArtifactsDirIfDoesNotExistAsync(artifactsDir: string): Promise { + if (!fsWrapper.doesPathExistSync(artifactsDir)) { + logUtils.log('Creating artifacts directory...'); + await fsWrapper.mkdirAsync(artifactsDir); + } +} + +/** + * Searches Solidity source code for compiler version range. + * @param source Source code of contract. + * @return Solc compiler version range. + */ +export function parseSolidityVersionRange(source: string): string { + const SOLIDITY_VERSION_RANGE_REGEX = /pragma solidity (.*);/; + const solcVersionRangeMatch = source.match(SOLIDITY_VERSION_RANGE_REGEX); + if (_.isNull(solcVersionRangeMatch)) { + throw new Error('Could not find Solidity version range in source'); + } + const solcVersionRange = solcVersionRangeMatch[1]; + return solcVersionRange; +} + +/** + * Normalizes the path found in the error message. + * Example: converts 'base/Token.sol:6:46: Warning: Unused local variable' + * to 'Token.sol:6:46: Warning: Unused local variable' + * This is used to prevent logging the same error multiple times. + * @param errMsg An error message from the compiled output. + * @return The error message with directories truncated from the contract path. + */ +export function getNormalizedErrMsg(errMsg: string): string { + const SOLIDITY_FILE_EXTENSION_REGEX = /(.*\.sol)/; + const errPathMatch = errMsg.match(SOLIDITY_FILE_EXTENSION_REGEX); + if (_.isNull(errPathMatch)) { + throw new Error('Could not find a path in error message'); + } + const errPath = errPathMatch[0]; + const baseContract = path.basename(errPath); + const normalizedErrMsg = errMsg.replace(errPath, baseContract); + return normalizedErrMsg; +} + +export function parseDependencies(source: string): string[] { + // TODO: Use a proper parser + const IMPORT_REGEX = /(import\s)/; + const DEPENDENCY_PATH_REGEX = /"([^"]+)"/; // Source: https://github.com/BlockChainCompany/soljitsu/blob/master/lib/shared.js + const dependencies: string[] = []; + const lines = source.split('\n'); + _.forEach(lines, line => { + if (!_.isNull(line.match(IMPORT_REGEX))) { + const dependencyMatch = line.match(DEPENDENCY_PATH_REGEX); + if (!_.isNull(dependencyMatch)) { + const dependencyPath = dependencyMatch[1]; + const basenName = path.basename(dependencyPath); + dependencies.push(basenName); + } + } + }); + return dependencies; +} + +/** + * Callback to resolve dependencies with `solc.compile`. + * Throws error if contractSources not yet initialized. + * @param importPath Path to an imported dependency. + * @return Import contents object containing source code of dependency. + */ +export function findImportIfExist(contractSources: ContractSources, importPath: string): solc.ImportContents { + const fileName = path.basename(importPath); + if (_.isUndefined(contractSources)) { + throw new Error('Contract sources not yet initialized'); + } + const source = contractSources[fileName]; + if (_.isUndefined(source)) { + throw new Error(`Contract source not found for ${fileName}`); + } + const importContents: solc.ImportContents = { + contents: source, + }; + return importContents; +} diff --git a/packages/deployer/src/utils/types.ts b/packages/deployer/src/utils/types.ts index 13b24b9b7..72ee0df2f 100644 --- a/packages/deployer/src/utils/types.ts +++ b/packages/deployer/src/utils/types.ts @@ -86,7 +86,7 @@ export interface ContractSpecificSourceData { dependencies: string[]; solcVersionRange: string; sourceHash: Buffer; - sourceTreeHashIfExists?: Buffer; + sourceTreeHash: Buffer; } // TODO: Consolidate with 0x.js definitions once types are moved into a separate package. diff --git a/packages/deployer/test/deploy_test.ts b/packages/deployer/test/deploy_test.ts index 26ce337ef..f67cd8234 100644 --- a/packages/deployer/test/deploy_test.ts +++ b/packages/deployer/test/deploy_test.ts @@ -38,7 +38,7 @@ beforeEach(function(done: DoneCallback) { if (fsWrapper.doesPathExistSync(exchangeArtifactPath)) { await fsWrapper.removeFileAsync(exchangeArtifactPath); } - await compiler.compileAllAsync(); + await compiler.compileAsync(); done(); })().catch(done); }); -- cgit v1.2.3 From 8b52793f2fa21bcb23a3c38b6d3773cfc20186fd Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Fri, 16 Mar 2018 16:34:02 +0100 Subject: Add tests for compiler utils --- packages/deployer/package.json | 5 +- packages/deployer/src/globals.d.ts | 2 + packages/deployer/src/utils/compiler.ts | 5 +- packages/deployer/src/utils/fs_wrapper.ts | 1 + packages/deployer/test/compiler_test.ts | 47 ++++++++++++++ packages/deployer/test/compiler_utils_test.ts | 74 +++++++++++++++++++++ packages/deployer/test/deploy_test.ts | 93 --------------------------- packages/deployer/test/deployer_test.ts | 76 ++++++++++++++++++++++ 8 files changed, 205 insertions(+), 98 deletions(-) create mode 100644 packages/deployer/test/compiler_test.ts create mode 100644 packages/deployer/test/compiler_utils_test.ts delete mode 100644 packages/deployer/test/deploy_test.ts create mode 100644 packages/deployer/test/deployer_test.ts (limited to 'packages') diff --git a/packages/deployer/package.json b/packages/deployer/package.json index 3982c0067..77f017ef3 100644 --- a/packages/deployer/package.json +++ b/packages/deployer/package.json @@ -7,7 +7,8 @@ "scripts": { "build:watch": "tsc -w", "build": "yarn clean && copyfiles 'test/fixtures/contracts/**/*' ./lib && tsc && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts", - "test": "npm run build; mocha lib/test/*_test.js", + "test": "run-s build run_mocha", + "run_mocha": "mocha lib/test/*_test.js", "test:coverage": "nyc npm run test --all && yarn coverage:report:lcov", "coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info", "compile": "npm run build; node lib/src/cli.js compile", @@ -37,6 +38,7 @@ "@types/yargs": "^11.0.0", "chai": "^4.0.1", "copyfiles": "^1.2.0", + "dirty-chai": "^2.0.1", "ethers-typescript-typings": "^0.0.4", "mocha": "^4.0.1", "nyc": "^11.0.1", @@ -51,6 +53,7 @@ "@0xproject/types": "^0.4.1", "@0xproject/utils": "^0.4.3", "@0xproject/web3-wrapper": "^0.3.1", + "npm-run-all": "^4.1.2", "ethereumjs-util": "^5.1.1", "isomorphic-fetch": "^2.2.1", "lodash": "^4.17.4", diff --git a/packages/deployer/src/globals.d.ts b/packages/deployer/src/globals.d.ts index 3cff8a909..83db346f9 100644 --- a/packages/deployer/src/globals.d.ts +++ b/packages/deployer/src/globals.d.ts @@ -1,3 +1,5 @@ +declare module 'dirty-chai'; + // tslint:disable:completed-docs declare module 'solc' { import * as Web3 from 'web3'; diff --git a/packages/deployer/src/utils/compiler.ts b/packages/deployer/src/utils/compiler.ts index 3fb35e9ed..1d21d7d31 100644 --- a/packages/deployer/src/utils/compiler.ts +++ b/packages/deployer/src/utils/compiler.ts @@ -48,7 +48,7 @@ export async function createArtifactsDirIfDoesNotExistAsync(artifactsDir: string * @return Solc compiler version range. */ export function parseSolidityVersionRange(source: string): string { - const SOLIDITY_VERSION_RANGE_REGEX = /pragma solidity (.*);/; + const SOLIDITY_VERSION_RANGE_REGEX = /pragma\s+solidity\s+(.*);/; const solcVersionRangeMatch = source.match(SOLIDITY_VERSION_RANGE_REGEX); if (_.isNull(solcVersionRangeMatch)) { throw new Error('Could not find Solidity version range in source'); @@ -104,9 +104,6 @@ export function parseDependencies(source: string): string[] { */ export function findImportIfExist(contractSources: ContractSources, importPath: string): solc.ImportContents { const fileName = path.basename(importPath); - if (_.isUndefined(contractSources)) { - throw new Error('Contract sources not yet initialized'); - } const source = contractSources[fileName]; if (_.isUndefined(source)) { throw new Error(`Contract source not found for ${fileName}`); diff --git a/packages/deployer/src/utils/fs_wrapper.ts b/packages/deployer/src/utils/fs_wrapper.ts index 34c7caa0e..e02c83f27 100644 --- a/packages/deployer/src/utils/fs_wrapper.ts +++ b/packages/deployer/src/utils/fs_wrapper.ts @@ -7,5 +7,6 @@ export const fsWrapper = { writeFileAsync: promisify(fs.writeFile), mkdirAsync: promisify(fs.mkdir), doesPathExistSync: fs.existsSync, + rmdirSync: fs.rmdirSync, removeFileAsync: promisify(fs.unlink), }; diff --git a/packages/deployer/test/compiler_test.ts b/packages/deployer/test/compiler_test.ts new file mode 100644 index 000000000..1c4d3c697 --- /dev/null +++ b/packages/deployer/test/compiler_test.ts @@ -0,0 +1,47 @@ +import * as chai from 'chai'; +import 'mocha'; + +import { Compiler } from '../src/compiler'; +import { fsWrapper } from '../src/utils/fs_wrapper'; +import { CompilerOptions, ContractArtifact, ContractNetworkData, DoneCallback } from '../src/utils/types'; + +import { exchange_binary } from './fixtures/exchange_bin'; +import { constants } from './util/constants'; + +const expect = chai.expect; + +describe('#Compiler', () => { + const artifactsDir = `${__dirname}/fixtures/artifacts`; + const contractsDir = `${__dirname}/fixtures/contracts`; + const exchangeArtifactPath = `${artifactsDir}/Exchange.json`; + const compilerOpts: CompilerOptions = { + artifactsDir, + contractsDir, + networkId: constants.networkId, + optimizerEnabled: constants.optimizerEnabled, + specifiedContracts: new Set(constants.specifiedContracts), + }; + const compiler = new Compiler(compilerOpts); + beforeEach(function(done: DoneCallback) { + this.timeout(constants.timeoutMs); + (async () => { + if (fsWrapper.doesPathExistSync(exchangeArtifactPath)) { + await fsWrapper.removeFileAsync(exchangeArtifactPath); + } + await compiler.compileAsync(); + done(); + })().catch(done); + }); + it('should create an Exchange artifact with the correct unlinked binary', async () => { + const opts = { + encoding: 'utf8', + }; + const exchangeArtifactString = await fsWrapper.readFileAsync(exchangeArtifactPath, opts); + const exchangeArtifact: ContractArtifact = JSON.parse(exchangeArtifactString); + const exchangeContractData: ContractNetworkData = exchangeArtifact.networks[constants.networkId]; + // The last 43 bytes of the binaries are metadata which may not be equivalent + const unlinkedBinaryWithoutMetadata = exchangeContractData.bytecode.slice(0, -86); + const exchangeBinaryWithoutMetadata = exchange_binary.slice(0, -86); + expect(unlinkedBinaryWithoutMetadata).to.equal(exchangeBinaryWithoutMetadata); + }); +}); diff --git a/packages/deployer/test/compiler_utils_test.ts b/packages/deployer/test/compiler_utils_test.ts new file mode 100644 index 000000000..f86a44862 --- /dev/null +++ b/packages/deployer/test/compiler_utils_test.ts @@ -0,0 +1,74 @@ +import * as chai from 'chai'; +import * as dirtyChai from 'dirty-chai'; +import 'mocha'; + +import { + createArtifactsDirIfDoesNotExistAsync, + getNormalizedErrMsg, + parseDependencies, + parseSolidityVersionRange, +} from '../src/utils/compiler'; +import { fsWrapper } from '../src/utils/fs_wrapper'; + +chai.use(dirtyChai); +const expect = chai.expect; + +describe.only('Compiler utils', () => { + describe('#getNormalizedErrorMessage', () => { + it('normalizes the error message', () => { + const errMsg = 'base/Token.sol:6:46: Warning: Unused local variable'; + const normalizedErrMsg = getNormalizedErrMsg(errMsg); + expect(normalizedErrMsg).to.be.equal('Token.sol:6:46: Warning: Unused local variable'); + }); + }); + describe('#createArtifactsDirIfDoesNotExistAsync', () => { + it('creates artifacts dir', async () => { + const artifactsDir = `${__dirname}/artifacts`; + expect(fsWrapper.doesPathExistSync(artifactsDir)).to.be.false(); + await createArtifactsDirIfDoesNotExistAsync(artifactsDir); + expect(fsWrapper.doesPathExistSync(artifactsDir)).to.be.true(); + fsWrapper.rmdirSync(artifactsDir); + expect(fsWrapper.doesPathExistSync(artifactsDir)).to.be.false(); + }); + }); + describe('#parseSolidityVersionRange', () => { + it('correctly parses the version range', () => { + expect(parseSolidityVersionRange('pragma solidity ^0.0.1;')).to.be.equal('^0.0.1'); + expect(parseSolidityVersionRange('\npragma solidity 0.0.1;')).to.be.equal('0.0.1'); + expect(parseSolidityVersionRange('pragma solidity <=1.0.1;')).to.be.equal('<=1.0.1'); + expect(parseSolidityVersionRange('pragma solidity ~1.0.1;')).to.be.equal('~1.0.1'); + }); + // TODO: For now that doesn't work. This will work after we switch to a grammar-based parser + it.skip('correctly parses the version range with comments', () => { + expect(parseSolidityVersionRange('// pragma solidity ~1.0.1;\npragma solidity ~1.0.2;')).to.be.equal( + '~1.0.2', + ); + }); + }); + describe('#parseDependencies', () => { + it('correctly parses Exchange dependencies', async () => { + const exchangeSource = await fsWrapper.readFileAsync(`${__dirname}/fixtures/contracts/Exchange.sol`, { + encoding: 'utf8', + }); + expect(parseDependencies(exchangeSource)).to.be.deep.equal([ + 'TokenTransferProxy.sol', + 'Token.sol', + 'SafeMath.sol', + ]); + }); + it('correctly parses TokenTransferProxy dependencies', async () => { + const exchangeSource = await fsWrapper.readFileAsync( + `${__dirname}/fixtures/contracts/TokenTransferProxy.sol`, + { + encoding: 'utf8', + }, + ); + expect(parseDependencies(exchangeSource)).to.be.deep.equal(['Token.sol', 'Ownable.sol']); + }); + // TODO: For now that doesn't work. This will work after we switch to a grammar-based parser + it.skip('correctly parses commented out dependencies', async () => { + const contractWithCommentedOutDependencies = `// import "./TokenTransferProxy.sol";`; + expect(parseDependencies(contractWithCommentedOutDependencies)).to.be.deep.equal([]); + }); + }); +}); diff --git a/packages/deployer/test/deploy_test.ts b/packages/deployer/test/deploy_test.ts deleted file mode 100644 index f67cd8234..000000000 --- a/packages/deployer/test/deploy_test.ts +++ /dev/null @@ -1,93 +0,0 @@ -import * as chai from 'chai'; -import 'mocha'; - -import { Compiler } from '../src/compiler'; -import { Deployer } from '../src/deployer'; -import { fsWrapper } from '../src/utils/fs_wrapper'; -import { CompilerOptions, ContractArtifact, ContractNetworkData, DoneCallback } from '../src/utils/types'; - -import { constructor_args, exchange_binary } from './fixtures/exchange_bin'; -import { constants } from './util/constants'; - -const expect = chai.expect; -const artifactsDir = `${__dirname}/fixtures/artifacts`; -const contractsDir = `${__dirname}/fixtures/contracts`; -const exchangeArtifactPath = `${artifactsDir}/Exchange.json`; -const compilerOpts: CompilerOptions = { - artifactsDir, - contractsDir, - networkId: constants.networkId, - optimizerEnabled: constants.optimizerEnabled, - specifiedContracts: new Set(constants.specifiedContracts), -}; -const compiler = new Compiler(compilerOpts); -const deployerOpts = { - artifactsDir, - networkId: constants.networkId, - jsonrpcUrl: constants.jsonrpcUrl, - defaults: { - gasPrice: constants.gasPrice, - }, -}; -const deployer = new Deployer(deployerOpts); - -/* tslint:disable */ -beforeEach(function(done: DoneCallback) { - this.timeout(constants.timeoutMs); - (async () => { - if (fsWrapper.doesPathExistSync(exchangeArtifactPath)) { - await fsWrapper.removeFileAsync(exchangeArtifactPath); - } - await compiler.compileAsync(); - done(); - })().catch(done); -}); -/* tslint:enable */ - -describe('#Compiler', () => { - it('should create an Exchange artifact with the correct unlinked binary', async () => { - const opts = { - encoding: 'utf8', - }; - const exchangeArtifactString = await fsWrapper.readFileAsync(exchangeArtifactPath, opts); - const exchangeArtifact: ContractArtifact = JSON.parse(exchangeArtifactString); - const exchangeContractData: ContractNetworkData = exchangeArtifact.networks[constants.networkId]; - // The last 43 bytes of the binaries are metadata which may not be equivalent - const unlinkedBinaryWithoutMetadata = exchangeContractData.bytecode.slice(0, -86); - const exchangeBinaryWithoutMetadata = exchange_binary.slice(0, -86); - expect(unlinkedBinaryWithoutMetadata).to.equal(exchangeBinaryWithoutMetadata); - }); -}); -describe('#Deployer', () => { - describe('#deployAsync', () => { - it('should deploy the Exchange contract without updating the Exchange artifact', async () => { - const exchangeConstructorArgs = [constants.zrxTokenAddress, constants.tokenTransferProxyAddress]; - const exchangeContractInstance = await deployer.deployAsync('Exchange', exchangeConstructorArgs); - const opts = { - encoding: 'utf8', - }; - const exchangeArtifactString = await fsWrapper.readFileAsync(exchangeArtifactPath, opts); - const exchangeArtifact: ContractArtifact = JSON.parse(exchangeArtifactString); - const exchangeContractData: ContractNetworkData = exchangeArtifact.networks[constants.networkId]; - const exchangeAddress = exchangeContractInstance.address; - expect(exchangeAddress).to.not.equal(undefined); - expect(exchangeContractData.address).to.equal(undefined); - expect(exchangeContractData.constructor_args).to.equal(undefined); - }); - }); - describe('#deployAndSaveAsync', () => { - it('should save the correct contract address and constructor arguments to the Exchange artifact', async () => { - const exchangeConstructorArgs = [constants.zrxTokenAddress, constants.tokenTransferProxyAddress]; - const exchangeContractInstance = await deployer.deployAndSaveAsync('Exchange', exchangeConstructorArgs); - const opts = { - encoding: 'utf8', - }; - const exchangeArtifactString = await fsWrapper.readFileAsync(exchangeArtifactPath, opts); - const exchangeArtifact: ContractArtifact = JSON.parse(exchangeArtifactString); - const exchangeContractData: ContractNetworkData = exchangeArtifact.networks[constants.networkId]; - const exchangeAddress = exchangeContractInstance.address; - expect(exchangeAddress).to.be.equal(exchangeContractData.address); - expect(constructor_args).to.be.equal(exchangeContractData.constructor_args); - }); - }); -}); diff --git a/packages/deployer/test/deployer_test.ts b/packages/deployer/test/deployer_test.ts new file mode 100644 index 000000000..9c34d74aa --- /dev/null +++ b/packages/deployer/test/deployer_test.ts @@ -0,0 +1,76 @@ +import * as chai from 'chai'; +import 'mocha'; + +import { Compiler } from '../src/compiler'; +import { Deployer } from '../src/deployer'; +import { fsWrapper } from '../src/utils/fs_wrapper'; +import { CompilerOptions, ContractArtifact, ContractNetworkData, DoneCallback } from '../src/utils/types'; + +import { constructor_args, exchange_binary } from './fixtures/exchange_bin'; +import { constants } from './util/constants'; + +const expect = chai.expect; + +describe('#Deployer', () => { + const artifactsDir = `${__dirname}/fixtures/artifacts`; + const contractsDir = `${__dirname}/fixtures/contracts`; + const exchangeArtifactPath = `${artifactsDir}/Exchange.json`; + const compilerOpts: CompilerOptions = { + artifactsDir, + contractsDir, + networkId: constants.networkId, + optimizerEnabled: constants.optimizerEnabled, + specifiedContracts: new Set(constants.specifiedContracts), + }; + const compiler = new Compiler(compilerOpts); + const deployerOpts = { + artifactsDir, + networkId: constants.networkId, + jsonrpcUrl: constants.jsonrpcUrl, + defaults: { + gasPrice: constants.gasPrice, + }, + }; + const deployer = new Deployer(deployerOpts); + beforeEach(function(done: DoneCallback) { + this.timeout(constants.timeoutMs); + (async () => { + if (fsWrapper.doesPathExistSync(exchangeArtifactPath)) { + await fsWrapper.removeFileAsync(exchangeArtifactPath); + } + await compiler.compileAsync(); + done(); + })().catch(done); + }); + describe('#deployAsync', () => { + it('should deploy the Exchange contract without updating the Exchange artifact', async () => { + const exchangeConstructorArgs = [constants.zrxTokenAddress, constants.tokenTransferProxyAddress]; + const exchangeContractInstance = await deployer.deployAsync('Exchange', exchangeConstructorArgs); + const opts = { + encoding: 'utf8', + }; + const exchangeArtifactString = await fsWrapper.readFileAsync(exchangeArtifactPath, opts); + const exchangeArtifact: ContractArtifact = JSON.parse(exchangeArtifactString); + const exchangeContractData: ContractNetworkData = exchangeArtifact.networks[constants.networkId]; + const exchangeAddress = exchangeContractInstance.address; + expect(exchangeAddress).to.not.equal(undefined); + expect(exchangeContractData.address).to.equal(undefined); + expect(exchangeContractData.constructor_args).to.equal(undefined); + }); + }); + describe('#deployAndSaveAsync', () => { + it('should save the correct contract address and constructor arguments to the Exchange artifact', async () => { + const exchangeConstructorArgs = [constants.zrxTokenAddress, constants.tokenTransferProxyAddress]; + const exchangeContractInstance = await deployer.deployAndSaveAsync('Exchange', exchangeConstructorArgs); + const opts = { + encoding: 'utf8', + }; + const exchangeArtifactString = await fsWrapper.readFileAsync(exchangeArtifactPath, opts); + const exchangeArtifact: ContractArtifact = JSON.parse(exchangeArtifactString); + const exchangeContractData: ContractNetworkData = exchangeArtifact.networks[constants.networkId]; + const exchangeAddress = exchangeContractInstance.address; + expect(exchangeAddress).to.be.equal(exchangeContractData.address); + expect(constructor_args).to.be.equal(exchangeContractData.constructor_args); + }); + }); +}); -- cgit v1.2.3 From 477daf416805633d02c6d387be26bee6ed747ebe Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Fri, 16 Mar 2018 16:54:48 +0100 Subject: Add function docs --- packages/deployer/src/utils/compiler.ts | 5 +++++ packages/deployer/src/utils/error_reporter.ts | 1 + 2 files changed, 6 insertions(+) (limited to 'packages') diff --git a/packages/deployer/src/utils/compiler.ts b/packages/deployer/src/utils/compiler.ts index 1d21d7d31..d8b5f78c9 100644 --- a/packages/deployer/src/utils/compiler.ts +++ b/packages/deployer/src/utils/compiler.ts @@ -77,6 +77,11 @@ export function getNormalizedErrMsg(errMsg: string): string { return normalizedErrMsg; } +/** + * Parses the contract source code and extracts the dendencies + * @param source Contract source code + * @return List of dependendencies + */ export function parseDependencies(source: string): string[] { // TODO: Use a proper parser const IMPORT_REGEX = /(import\s)/; diff --git a/packages/deployer/src/utils/error_reporter.ts b/packages/deployer/src/utils/error_reporter.ts index b28e4fbbe..bf3f96a7c 100644 --- a/packages/deployer/src/utils/error_reporter.ts +++ b/packages/deployer/src/utils/error_reporter.ts @@ -1,5 +1,6 @@ import { logUtils } from '@0xproject/utils'; +// Makes an async function no-throw printing errors to the console export function consoleReporter(asyncFn: (arg: T) => Promise) { const noThrowFnAsync = async (arg: T) => { try { -- cgit v1.2.3 From 111f7e917ed3cb16de9930e093ea7dbcb9451d19 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Wed, 21 Mar 2018 15:24:41 +0100 Subject: Add function docs --- packages/deployer/src/utils/error_reporter.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'packages') diff --git a/packages/deployer/src/utils/error_reporter.ts b/packages/deployer/src/utils/error_reporter.ts index bf3f96a7c..4e73307f0 100644 --- a/packages/deployer/src/utils/error_reporter.ts +++ b/packages/deployer/src/utils/error_reporter.ts @@ -1,7 +1,11 @@ import { logUtils } from '@0xproject/utils'; -// Makes an async function no-throw printing errors to the console -export function consoleReporter(asyncFn: (arg: T) => Promise) { +/** + * Makes an async function no-throw printing errors to the console + * @param asyncFn async function to wrap + * @return Wrapped version of the passed function + */ +export function consoleReporter(asyncFn: (arg: T) => Promise): (arg: T) => Promise { const noThrowFnAsync = async (arg: T) => { try { const result = await asyncFn(arg); -- cgit v1.2.3 From d118116548950c82541b372fe5d3781982c25b45 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Wed, 21 Mar 2018 16:34:57 +0100 Subject: Revert version range changes --- .../src/contracts/current/multisig/MultiSigWallet/MultiSigWallet.sol | 2 +- .../multisig/MultiSigWalletWithTimeLock/MultiSigWalletWithTimeLock.sol | 2 +- .../MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.sol | 2 +- packages/contracts/src/contracts/current/protocol/Exchange/Exchange.sol | 2 +- .../src/contracts/current/protocol/TokenRegistry/TokenRegistry.sol | 2 +- .../current/protocol/TokenTransferProxy/TokenTransferProxy.sol | 2 +- packages/contracts/src/contracts/current/test/DummyToken/DummyToken.sol | 2 +- .../src/contracts/current/test/MaliciousToken/MaliciousToken.sol | 2 +- packages/contracts/src/contracts/current/test/Mintable/Mintable.sol | 2 +- .../contracts/src/contracts/current/tokens/ERC20Token/ERC20Token.sol | 2 +- packages/contracts/src/contracts/current/tokens/Token/Token.sol | 2 +- .../current/tokens/UnlimitedAllowanceToken/UnlimitedAllowanceToken.sol | 2 +- packages/contracts/src/contracts/current/tokens/WETH9/WETH9.sol | 2 +- packages/contracts/src/contracts/current/tokens/ZRXToken/ZRXToken.sol | 2 +- .../contracts/src/contracts/current/tutorials/Arbitrage/Arbitrage.sol | 2 +- .../src/contracts/current/tutorials/EtherDelta/AccountLevels.sol | 2 +- .../contracts/src/contracts/current/tutorials/EtherDelta/EtherDelta.sol | 2 +- packages/contracts/src/contracts/current/utils/Ownable/Ownable.sol | 2 +- packages/contracts/src/contracts/current/utils/SafeMath/SafeMath.sol | 2 +- packages/contracts/src/contracts/previous/ERC20Token/ERC20Token_v1.sol | 2 +- packages/contracts/src/contracts/previous/Ownable/Ownable_v1.sol | 2 +- packages/contracts/src/contracts/previous/SafeMath/SafeMath_v1.sol | 2 +- packages/contracts/src/contracts/previous/Token/Token_v1.sol | 2 +- .../previous/UnlimitedAllowanceToken/UnlimitedAllowanceToken_v1.sol | 2 +- 24 files changed, 24 insertions(+), 24 deletions(-) (limited to 'packages') diff --git a/packages/contracts/src/contracts/current/multisig/MultiSigWallet/MultiSigWallet.sol b/packages/contracts/src/contracts/current/multisig/MultiSigWallet/MultiSigWallet.sol index 56c4d20a9..79fd92029 100644 --- a/packages/contracts/src/contracts/current/multisig/MultiSigWallet/MultiSigWallet.sol +++ b/packages/contracts/src/contracts/current/multisig/MultiSigWallet/MultiSigWallet.sol @@ -1,4 +1,4 @@ -pragma solidity ~0.4.10; +pragma solidity ^0.4.10; /// @title Multisignature wallet - Allows multiple parties to agree on transactions before execution. /// @author Stefan George - diff --git a/packages/contracts/src/contracts/current/multisig/MultiSigWalletWithTimeLock/MultiSigWalletWithTimeLock.sol b/packages/contracts/src/contracts/current/multisig/MultiSigWalletWithTimeLock/MultiSigWalletWithTimeLock.sol index 791c01af8..a545d9813 100644 --- a/packages/contracts/src/contracts/current/multisig/MultiSigWalletWithTimeLock/MultiSigWalletWithTimeLock.sol +++ b/packages/contracts/src/contracts/current/multisig/MultiSigWalletWithTimeLock/MultiSigWalletWithTimeLock.sol @@ -16,7 +16,7 @@ */ -pragma solidity ~0.4.10; +pragma solidity ^0.4.10; import { MultiSigWallet } from "../MultiSigWallet/MultiSigWallet.sol"; diff --git a/packages/contracts/src/contracts/current/multisig/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.sol b/packages/contracts/src/contracts/current/multisig/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.sol index ca2989483..3c6a3d2ef 100644 --- a/packages/contracts/src/contracts/current/multisig/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.sol +++ b/packages/contracts/src/contracts/current/multisig/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.sol @@ -16,7 +16,7 @@ */ -pragma solidity ~0.4.10; +pragma solidity ^0.4.10; import { MultiSigWalletWithTimeLock } from "../MultiSigWalletWithTimeLock/MultiSigWalletWithTimeLock.sol"; diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/Exchange.sol b/packages/contracts/src/contracts/current/protocol/Exchange/Exchange.sol index b1bf8a260..8dacf797c 100644 --- a/packages/contracts/src/contracts/current/protocol/Exchange/Exchange.sol +++ b/packages/contracts/src/contracts/current/protocol/Exchange/Exchange.sol @@ -16,7 +16,7 @@ */ -pragma solidity ~0.4.14; +pragma solidity ^0.4.14; import { TokenTransferProxy } from "../TokenTransferProxy/TokenTransferProxy.sol"; import { Token_v1 as Token } from "../../../previous/Token/Token_v1.sol"; diff --git a/packages/contracts/src/contracts/current/protocol/TokenRegistry/TokenRegistry.sol b/packages/contracts/src/contracts/current/protocol/TokenRegistry/TokenRegistry.sol index 9ab72f72d..3bd2fbfaf 100644 --- a/packages/contracts/src/contracts/current/protocol/TokenRegistry/TokenRegistry.sol +++ b/packages/contracts/src/contracts/current/protocol/TokenRegistry/TokenRegistry.sol @@ -16,7 +16,7 @@ */ -pragma solidity ~0.4.11; +pragma solidity ^0.4.11; import { Ownable_v1 as Ownable } from "../../../previous/Ownable/Ownable_v1.sol"; diff --git a/packages/contracts/src/contracts/current/protocol/TokenTransferProxy/TokenTransferProxy.sol b/packages/contracts/src/contracts/current/protocol/TokenTransferProxy/TokenTransferProxy.sol index e78d264d4..1ce949fa6 100644 --- a/packages/contracts/src/contracts/current/protocol/TokenTransferProxy/TokenTransferProxy.sol +++ b/packages/contracts/src/contracts/current/protocol/TokenTransferProxy/TokenTransferProxy.sol @@ -16,7 +16,7 @@ */ -pragma solidity ~0.4.11; +pragma solidity ^0.4.11; import { Token_v1 as Token } from "../../../previous/Token/Token_v1.sol"; import { Ownable_v1 as Ownable } from "../../../previous/Ownable/Ownable_v1.sol"; diff --git a/packages/contracts/src/contracts/current/test/DummyToken/DummyToken.sol b/packages/contracts/src/contracts/current/test/DummyToken/DummyToken.sol index 0cd04312d..ab04f4d16 100644 --- a/packages/contracts/src/contracts/current/test/DummyToken/DummyToken.sol +++ b/packages/contracts/src/contracts/current/test/DummyToken/DummyToken.sol @@ -1,4 +1,4 @@ -pragma solidity ~0.4.18; +pragma solidity ^0.4.18; import { Mintable } from "../Mintable/Mintable.sol"; import { Ownable } from "../../utils/Ownable/Ownable.sol"; diff --git a/packages/contracts/src/contracts/current/test/MaliciousToken/MaliciousToken.sol b/packages/contracts/src/contracts/current/test/MaliciousToken/MaliciousToken.sol index c5d6207e8..9e502616c 100644 --- a/packages/contracts/src/contracts/current/test/MaliciousToken/MaliciousToken.sol +++ b/packages/contracts/src/contracts/current/test/MaliciousToken/MaliciousToken.sol @@ -1,4 +1,4 @@ -pragma solidity ~0.4.18; +pragma solidity ^0.4.18; import { ERC20Token } from "../../tokens/ERC20Token/ERC20Token.sol"; diff --git a/packages/contracts/src/contracts/current/test/Mintable/Mintable.sol b/packages/contracts/src/contracts/current/test/Mintable/Mintable.sol index 33022cfc6..cf7ee35a5 100644 --- a/packages/contracts/src/contracts/current/test/Mintable/Mintable.sol +++ b/packages/contracts/src/contracts/current/test/Mintable/Mintable.sol @@ -1,4 +1,4 @@ -pragma solidity ~0.4.18; +pragma solidity ^0.4.18; import { UnlimitedAllowanceToken } from "../../tokens/UnlimitedAllowanceToken/UnlimitedAllowanceToken.sol"; import { SafeMath } from "../../utils/SafeMath/SafeMath.sol"; diff --git a/packages/contracts/src/contracts/current/tokens/ERC20Token/ERC20Token.sol b/packages/contracts/src/contracts/current/tokens/ERC20Token/ERC20Token.sol index c59ab3e7a..0e5b87aa4 100644 --- a/packages/contracts/src/contracts/current/tokens/ERC20Token/ERC20Token.sol +++ b/packages/contracts/src/contracts/current/tokens/ERC20Token/ERC20Token.sol @@ -1,4 +1,4 @@ -pragma solidity ~0.4.18; +pragma solidity ^0.4.18; import { Token } from "../Token/Token.sol"; diff --git a/packages/contracts/src/contracts/current/tokens/Token/Token.sol b/packages/contracts/src/contracts/current/tokens/Token/Token.sol index 6bf83cd51..bf4e71dcd 100644 --- a/packages/contracts/src/contracts/current/tokens/Token/Token.sol +++ b/packages/contracts/src/contracts/current/tokens/Token/Token.sol @@ -1,4 +1,4 @@ -pragma solidity ~0.4.18; +pragma solidity ^0.4.18; contract Token { diff --git a/packages/contracts/src/contracts/current/tokens/UnlimitedAllowanceToken/UnlimitedAllowanceToken.sol b/packages/contracts/src/contracts/current/tokens/UnlimitedAllowanceToken/UnlimitedAllowanceToken.sol index 569b4f021..699f535d2 100644 --- a/packages/contracts/src/contracts/current/tokens/UnlimitedAllowanceToken/UnlimitedAllowanceToken.sol +++ b/packages/contracts/src/contracts/current/tokens/UnlimitedAllowanceToken/UnlimitedAllowanceToken.sol @@ -16,7 +16,7 @@ */ -pragma solidity ~0.4.18; +pragma solidity ^0.4.18; import { ERC20Token } from "../ERC20Token/ERC20Token.sol"; diff --git a/packages/contracts/src/contracts/current/tokens/WETH9/WETH9.sol b/packages/contracts/src/contracts/current/tokens/WETH9/WETH9.sol index 22df0600c..733ca414b 100644 --- a/packages/contracts/src/contracts/current/tokens/WETH9/WETH9.sol +++ b/packages/contracts/src/contracts/current/tokens/WETH9/WETH9.sol @@ -13,7 +13,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -pragma solidity ~0.4.18; +pragma solidity ^0.4.18; contract WETH9 { string public name = "Wrapped Ether"; diff --git a/packages/contracts/src/contracts/current/tokens/ZRXToken/ZRXToken.sol b/packages/contracts/src/contracts/current/tokens/ZRXToken/ZRXToken.sol index b12a6a186..7f5e1f849 100644 --- a/packages/contracts/src/contracts/current/tokens/ZRXToken/ZRXToken.sol +++ b/packages/contracts/src/contracts/current/tokens/ZRXToken/ZRXToken.sol @@ -16,7 +16,7 @@ */ -pragma solidity ~0.4.11; +pragma solidity ^0.4.11; import { UnlimitedAllowanceToken_v1 as UnlimitedAllowanceToken } from "../../../previous/UnlimitedAllowanceToken/UnlimitedAllowanceToken_v1.sol"; diff --git a/packages/contracts/src/contracts/current/tutorials/Arbitrage/Arbitrage.sol b/packages/contracts/src/contracts/current/tutorials/Arbitrage/Arbitrage.sol index 1867781fb..a9f3c22e6 100644 --- a/packages/contracts/src/contracts/current/tutorials/Arbitrage/Arbitrage.sol +++ b/packages/contracts/src/contracts/current/tutorials/Arbitrage/Arbitrage.sol @@ -1,4 +1,4 @@ -pragma solidity ~0.4.19; +pragma solidity ^0.4.19; import { Exchange } from "../../protocol/Exchange/Exchange.sol"; import { EtherDelta } from "../EtherDelta/EtherDelta.sol"; diff --git a/packages/contracts/src/contracts/current/tutorials/EtherDelta/AccountLevels.sol b/packages/contracts/src/contracts/current/tutorials/EtherDelta/AccountLevels.sol index 17d839eb7..8d7a930d3 100644 --- a/packages/contracts/src/contracts/current/tutorials/EtherDelta/AccountLevels.sol +++ b/packages/contracts/src/contracts/current/tutorials/EtherDelta/AccountLevels.sol @@ -1,4 +1,4 @@ -pragma solidity ~0.4.19; +pragma solidity ^0.4.19; contract AccountLevels { //given a user, returns an account level diff --git a/packages/contracts/src/contracts/current/tutorials/EtherDelta/EtherDelta.sol b/packages/contracts/src/contracts/current/tutorials/EtherDelta/EtherDelta.sol index fc5e5f9de..49847ab48 100644 --- a/packages/contracts/src/contracts/current/tutorials/EtherDelta/EtherDelta.sol +++ b/packages/contracts/src/contracts/current/tutorials/EtherDelta/EtherDelta.sol @@ -1,4 +1,4 @@ -pragma solidity ~0.4.19; +pragma solidity ^0.4.19; import { SafeMath } from "../../utils/SafeMath/SafeMath.sol"; import { AccountLevels } from "./AccountLevels.sol"; diff --git a/packages/contracts/src/contracts/current/utils/Ownable/Ownable.sol b/packages/contracts/src/contracts/current/utils/Ownable/Ownable.sol index 9416c8f8e..9b3d6b9cf 100644 --- a/packages/contracts/src/contracts/current/utils/Ownable/Ownable.sol +++ b/packages/contracts/src/contracts/current/utils/Ownable/Ownable.sol @@ -1,4 +1,4 @@ -pragma solidity ~0.4.18; +pragma solidity ^0.4.18; /* * Ownable diff --git a/packages/contracts/src/contracts/current/utils/SafeMath/SafeMath.sol b/packages/contracts/src/contracts/current/utils/SafeMath/SafeMath.sol index c816b3fd1..955a9e379 100644 --- a/packages/contracts/src/contracts/current/utils/SafeMath/SafeMath.sol +++ b/packages/contracts/src/contracts/current/utils/SafeMath/SafeMath.sol @@ -1,4 +1,4 @@ -pragma solidity ~0.4.18; +pragma solidity ^0.4.18; contract SafeMath { function safeMul(uint a, uint b) diff --git a/packages/contracts/src/contracts/previous/ERC20Token/ERC20Token_v1.sol b/packages/contracts/src/contracts/previous/ERC20Token/ERC20Token_v1.sol index b2a5636ae..e05ee2d5e 100644 --- a/packages/contracts/src/contracts/previous/ERC20Token/ERC20Token_v1.sol +++ b/packages/contracts/src/contracts/previous/ERC20Token/ERC20Token_v1.sol @@ -1,4 +1,4 @@ -pragma solidity ~0.4.11; +pragma solidity ^0.4.11; import { Token_v1 as Token } from "../Token/Token_v1.sol"; diff --git a/packages/contracts/src/contracts/previous/Ownable/Ownable_v1.sol b/packages/contracts/src/contracts/previous/Ownable/Ownable_v1.sol index c1b67956e..c87438fa4 100644 --- a/packages/contracts/src/contracts/previous/Ownable/Ownable_v1.sol +++ b/packages/contracts/src/contracts/previous/Ownable/Ownable_v1.sol @@ -1,4 +1,4 @@ -pragma solidity ~0.4.11; +pragma solidity ^0.4.11; /* * Ownable diff --git a/packages/contracts/src/contracts/previous/SafeMath/SafeMath_v1.sol b/packages/contracts/src/contracts/previous/SafeMath/SafeMath_v1.sol index ea8f899ef..341d611ec 100644 --- a/packages/contracts/src/contracts/previous/SafeMath/SafeMath_v1.sol +++ b/packages/contracts/src/contracts/previous/SafeMath/SafeMath_v1.sol @@ -1,4 +1,4 @@ -pragma solidity ~0.4.11; +pragma solidity ^0.4.11; contract SafeMath_v1 { function safeMul(uint a, uint b) diff --git a/packages/contracts/src/contracts/previous/Token/Token_v1.sol b/packages/contracts/src/contracts/previous/Token/Token_v1.sol index 5a9c82ded..de619fb7e 100644 --- a/packages/contracts/src/contracts/previous/Token/Token_v1.sol +++ b/packages/contracts/src/contracts/previous/Token/Token_v1.sol @@ -1,4 +1,4 @@ -pragma solidity ~0.4.11; +pragma solidity ^0.4.11; contract Token_v1 { diff --git a/packages/contracts/src/contracts/previous/UnlimitedAllowanceToken/UnlimitedAllowanceToken_v1.sol b/packages/contracts/src/contracts/previous/UnlimitedAllowanceToken/UnlimitedAllowanceToken_v1.sol index ccb4f8d28..6376f3f2c 100644 --- a/packages/contracts/src/contracts/previous/UnlimitedAllowanceToken/UnlimitedAllowanceToken_v1.sol +++ b/packages/contracts/src/contracts/previous/UnlimitedAllowanceToken/UnlimitedAllowanceToken_v1.sol @@ -16,7 +16,7 @@ */ -pragma solidity ~0.4.11; +pragma solidity ^0.4.11; import { ERC20Token_v1 as ERC20Token } from "../ERC20Token/ERC20Token_v1.sol"; -- cgit v1.2.3 From 2c7fdac5cd52ceb24cc2cb19ade124fc1acc8c9d Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Wed, 21 Mar 2018 16:39:37 +0100 Subject: Remove .only --- packages/deployer/test/compiler_utils_test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages') diff --git a/packages/deployer/test/compiler_utils_test.ts b/packages/deployer/test/compiler_utils_test.ts index f86a44862..1867177dc 100644 --- a/packages/deployer/test/compiler_utils_test.ts +++ b/packages/deployer/test/compiler_utils_test.ts @@ -13,7 +13,7 @@ import { fsWrapper } from '../src/utils/fs_wrapper'; chai.use(dirtyChai); const expect = chai.expect; -describe.only('Compiler utils', () => { +describe('Compiler utils', () => { describe('#getNormalizedErrorMessage', () => { it('normalizes the error message', () => { const errMsg = 'base/Token.sol:6:46: Warning: Unused local variable'; -- cgit v1.2.3 From ee77b81551e6aa879e68d56cb55e9a81be895296 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Wed, 21 Mar 2018 17:19:46 +0100 Subject: Revert optimizer config --- packages/deployer/test/util/constants.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages') diff --git a/packages/deployer/test/util/constants.ts b/packages/deployer/test/util/constants.ts index 7ba94c1f2..5d3aab47c 100644 --- a/packages/deployer/test/util/constants.ts +++ b/packages/deployer/test/util/constants.ts @@ -3,7 +3,7 @@ import { BigNumber } from '@0xproject/utils'; export const constants = { networkId: 0, jsonrpcUrl: 'http://localhost:8545', - optimizerEnabled: true, + optimizerEnabled: false, gasPrice: new BigNumber(20000000000), timeoutMs: 20000, zrxTokenAddress: '0xe41d2489571d322189246dafa5ebde1f4699f498', -- cgit v1.2.3 From 629edd3108425c4ff8541b6e66921d4812c40de2 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Wed, 21 Mar 2018 17:20:30 +0100 Subject: Move npm-run-all to devDependencies --- packages/deployer/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages') diff --git a/packages/deployer/package.json b/packages/deployer/package.json index 77f017ef3..3f0613677 100644 --- a/packages/deployer/package.json +++ b/packages/deployer/package.json @@ -36,6 +36,7 @@ "@types/require-from-string": "^1.2.0", "@types/semver": "^5.5.0", "@types/yargs": "^11.0.0", + "npm-run-all": "^4.1.2", "chai": "^4.0.1", "copyfiles": "^1.2.0", "dirty-chai": "^2.0.1", @@ -53,7 +54,6 @@ "@0xproject/types": "^0.4.1", "@0xproject/utils": "^0.4.3", "@0xproject/web3-wrapper": "^0.3.1", - "npm-run-all": "^4.1.2", "ethereumjs-util": "^5.1.1", "isomorphic-fetch": "^2.2.1", "lodash": "^4.17.4", -- cgit v1.2.3 From 32b85625c10279e53d75488fe81e3723afce0a1b Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Wed, 21 Mar 2018 17:23:07 +0100 Subject: Add a comment --- packages/deployer/src/compiler.ts | 1 + 1 file changed, 1 insertion(+) (limited to 'packages') diff --git a/packages/deployer/src/compiler.ts b/packages/deployer/src/compiler.ts index d9571488e..fcff9e22f 100644 --- a/packages/deployer/src/compiler.ts +++ b/packages/deployer/src/compiler.ts @@ -38,6 +38,7 @@ export class Compiler { private _networkId: number; private _optimizerEnabled: boolean; private _artifactsDir: string; + // This get's set in the beggining of `compileAsync` function. It's not called from a constructor, but it's the only public method of that class and could as well be. private _contractSources!: ContractSources; private _solcErrors: Set = new Set(); private _specifiedContracts: Set = new Set(); -- cgit v1.2.3 From 73f8ae9a47b151d518d759d0d7cf79f6bea794d3 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Wed, 21 Mar 2018 18:01:26 +0100 Subject: Fix a comment --- packages/deployer/src/compiler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages') diff --git a/packages/deployer/src/compiler.ts b/packages/deployer/src/compiler.ts index fcff9e22f..712169c89 100644 --- a/packages/deployer/src/compiler.ts +++ b/packages/deployer/src/compiler.ts @@ -182,7 +182,7 @@ export class Compiler { const contractIdentifier = `${fileName}:${contractName}`; if (_.isUndefined(compiled.contracts[contractIdentifier])) { throw new Error( - `Contract ${contractName} not found in ${fileName}. Please make sure your contract has the same name as a file`, + `Contract ${contractName} not found in ${fileName}. Please make sure your contract has the same name as it's file name`, ); } const abi: Web3.ContractAbi = JSON.parse(compiled.contracts[contractIdentifier].interface); -- cgit v1.2.3 From e31ba2e12e90cca10037d2f6bf8ae17fe42e1991 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Wed, 21 Mar 2018 18:06:50 +0100 Subject: Add missing param comments --- packages/deployer/src/utils/compiler.ts | 3 +++ 1 file changed, 3 insertions(+) (limited to 'packages') diff --git a/packages/deployer/src/utils/compiler.ts b/packages/deployer/src/utils/compiler.ts index d8b5f78c9..9c8fef26d 100644 --- a/packages/deployer/src/utils/compiler.ts +++ b/packages/deployer/src/utils/compiler.ts @@ -9,6 +9,7 @@ import { ContractArtifact, ContractSources } from './types'; /** * Gets contract data on network or returns if an artifact does not exist. + * @param artifactsDir Path to the artifacts directory. * @param fileName Name of contract file. * @return Contract data on network or undefined. */ @@ -34,6 +35,7 @@ export async function getContractArtifactIfExistsAsync( /** * Creates the artifacts directory if it does not already exist. + * @param artifactsDir Path to the artifacts directory. */ export async function createArtifactsDirIfDoesNotExistAsync(artifactsDir: string): Promise { if (!fsWrapper.doesPathExistSync(artifactsDir)) { @@ -104,6 +106,7 @@ export function parseDependencies(source: string): string[] { /** * Callback to resolve dependencies with `solc.compile`. * Throws error if contractSources not yet initialized. + * @param contractSources Source codes of contracts. * @param importPath Path to an imported dependency. * @return Import contents object containing source code of dependency. */ -- cgit v1.2.3 From e476682922ac57e268cf3bb7b3f46f8fba47497d Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Thu, 22 Mar 2018 12:37:44 +0100 Subject: Remove redundant types --- packages/deployer/src/utils/types.ts | 18 ------------------ 1 file changed, 18 deletions(-) (limited to 'packages') diff --git a/packages/deployer/src/utils/types.ts b/packages/deployer/src/utils/types.ts index 72ee0df2f..540b31aff 100644 --- a/packages/deployer/src/utils/types.ts +++ b/packages/deployer/src/utils/types.ts @@ -89,24 +89,6 @@ export interface ContractSpecificSourceData { sourceTreeHash: Buffer; } -// TODO: Consolidate with 0x.js definitions once types are moved into a separate package. -export enum ZeroExError { - ContractDoesNotExist = 'CONTRACT_DOES_NOT_EXIST', - ExchangeContractDoesNotExist = 'EXCHANGE_CONTRACT_DOES_NOT_EXIST', - UnhandledError = 'UNHANDLED_ERROR', - UserHasNoAssociatedAddress = 'USER_HAS_NO_ASSOCIATED_ADDRESSES', - InvalidSignature = 'INVALID_SIGNATURE', - ContractNotDeployedOnNetwork = 'CONTRACT_NOT_DEPLOYED_ON_NETWORK', - InsufficientAllowanceForTransfer = 'INSUFFICIENT_ALLOWANCE_FOR_TRANSFER', - InsufficientBalanceForTransfer = 'INSUFFICIENT_BALANCE_FOR_TRANSFER', - InsufficientEthBalanceForDeposit = 'INSUFFICIENT_ETH_BALANCE_FOR_DEPOSIT', - InsufficientWEthBalanceForWithdrawal = 'INSUFFICIENT_WETH_BALANCE_FOR_WITHDRAWAL', - InvalidJump = 'INVALID_JUMP', - OutOfGas = 'OUT_OF_GAS', - NoNetworkId = 'NO_NETWORK_ID', - SubscriptionNotFound = 'SUBSCRIPTION_NOT_FOUND', -} - export interface Token { address?: string; name: string; -- cgit v1.2.3 From 7ef6bd4b14b7502617c6929010d4a9991e1d577d Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Thu, 22 Mar 2018 14:26:24 +0100 Subject: Set timeout for compiler tests --- packages/deployer/test/compiler_test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'packages') diff --git a/packages/deployer/test/compiler_test.ts b/packages/deployer/test/compiler_test.ts index 1c4d3c697..b03ae7935 100644 --- a/packages/deployer/test/compiler_test.ts +++ b/packages/deployer/test/compiler_test.ts @@ -10,7 +10,8 @@ import { constants } from './util/constants'; const expect = chai.expect; -describe('#Compiler', () => { +describe('#Compiler', function() { + this.timeout(constants.timeoutMs); const artifactsDir = `${__dirname}/fixtures/artifacts`; const contractsDir = `${__dirname}/fixtures/contracts`; const exchangeArtifactPath = `${artifactsDir}/Exchange.json`; @@ -22,8 +23,7 @@ describe('#Compiler', () => { specifiedContracts: new Set(constants.specifiedContracts), }; const compiler = new Compiler(compilerOpts); - beforeEach(function(done: DoneCallback) { - this.timeout(constants.timeoutMs); + beforeEach((done: DoneCallback) => { (async () => { if (fsWrapper.doesPathExistSync(exchangeArtifactPath)) { await fsWrapper.removeFileAsync(exchangeArtifactPath); -- cgit v1.2.3 From a2e4aaa9a394c359b9bf817ff154572eb33d4fb5 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Mon, 26 Mar 2018 13:00:56 +0200 Subject: Add clean-state tests --- packages/0x.js/README.md | 9 +- packages/0x.js/package.json | 7 +- packages/0x.js/test/0x.js_test.ts | 2 +- packages/0x.js/tsconfig.json | 6 +- packages/abi-gen/package.json | 4 +- packages/abi-gen/tsconfig.json | 2 +- packages/assert/README.md | 16 +- packages/assert/package.json | 2 +- packages/assert/tsconfig.json | 7 +- packages/base-contract/README.md | 9 +- packages/base-contract/package.json | 5 +- packages/base-contract/tsconfig.json | 6 +- .../chai-as-promised-typescript-typings/.npmignore | 3 - .../CHANGELOG.md | 3 - .../chai-as-promised-typescript-typings/README.md | 43 - .../chai-as-promised-typescript-typings/index.d.ts | 268 ----- .../monorepo_scripts/globals.d.ts | 6 - .../monorepo_scripts/postpublish.ts | 8 - .../package.json | 35 - .../tsconfig.json | 7 - .../tslint.json | 3 - packages/chai-typescript-typings/.npmignore | 3 - packages/chai-typescript-typings/CHANGELOG.md | 3 - packages/chai-typescript-typings/README.md | 43 - packages/chai-typescript-typings/index.d.ts | 1254 -------------------- .../monorepo_scripts/globals.d.ts | 6 - .../monorepo_scripts/postpublish.ts | 8 - packages/chai-typescript-typings/package.json | 28 - packages/chai-typescript-typings/tsconfig.json | 7 - packages/chai-typescript-typings/tslint.json | 3 - packages/connect/README.md | 8 +- packages/connect/package.json | 6 +- packages/connect/tsconfig.json | 8 +- packages/contracts/package.json | 5 +- packages/contracts/tsconfig.json | 5 - packages/deployer/README.md | 8 + packages/deployer/package.json | 2 +- packages/deployer/tsconfig.json | 5 +- packages/dev-utils/README.md | 8 +- packages/dev-utils/package.json | 2 +- packages/dev-utils/tsconfig.json | 3 - packages/ethers-typescript-typings/.npmignore | 3 - packages/ethers-typescript-typings/CHANGELOG.md | 5 - packages/ethers-typescript-typings/README.md | 49 - packages/ethers-typescript-typings/index.d.ts | 28 - .../monorepo_scripts/globals.d.ts | 6 - .../monorepo_scripts/postpublish.ts | 8 - packages/ethers-typescript-typings/package.json | 36 - packages/ethers-typescript-typings/tsconfig.json | 7 - packages/ethers-typescript-typings/tslint.json | 3 - packages/json-schemas/README.md | 12 +- packages/json-schemas/package.json | 2 +- packages/json-schemas/tsconfig.json | 7 +- packages/monorepo-scripts/package.json | 4 + packages/monorepo-scripts/src/globals.d.ts | 19 + packages/monorepo-scripts/src/test_installation.ts | 57 + packages/monorepo-scripts/tsconfig.json | 2 +- packages/react-docs-example/package.json | 4 +- packages/react-docs/README.md | 8 + packages/react-docs/package.json | 4 +- packages/react-docs/tsconfig.json | 2 +- packages/react-shared/README.md | 8 + packages/react-shared/package.json | 4 +- packages/sol-cov/package.json | 2 +- packages/sol-cov/tsconfig.json | 2 - packages/sra-report/package.json | 3 +- packages/sra-report/tsconfig.json | 9 +- packages/subproviders/README.md | 8 +- packages/subproviders/package.json | 6 +- packages/subproviders/tsconfig.json | 5 +- packages/testnet-faucets/package.json | 2 +- packages/testnet-faucets/tsconfig.json | 4 +- packages/tslint-config/tsconfig.json | 2 +- packages/types/README.md | 8 +- packages/types/package.json | 4 +- packages/types/tsconfig.json | 2 +- packages/typescript-typings/.npmignore | 3 + packages/typescript-typings/CHANGELOG.md | 3 + packages/typescript-typings/README.md | 45 + .../monorepo_scripts/globals.d.ts | 6 + .../monorepo_scripts/postpublish.ts | 8 + packages/typescript-typings/package.json | 33 + packages/typescript-typings/tsconfig.json | 7 + packages/typescript-typings/tslint.json | 3 + .../types/chai-as-promised/index.d.ts | 268 +++++ packages/typescript-typings/types/chai/index.d.ts | 1254 ++++++++++++++++++++ .../types/ethers-contracts/index.d.ts | 28 + packages/typescript-typings/types/web3/index.d.ts | 440 +++++++ packages/utils/README.md | 8 +- packages/utils/package.json | 5 +- packages/utils/tsconfig.json | 6 +- packages/web3-typescript-typings/.npmignore | 3 - packages/web3-typescript-typings/CHANGELOG.md | 16 - packages/web3-typescript-typings/README.md | 49 - packages/web3-typescript-typings/index.d.ts | 440 ------- .../monorepo_scripts/globals.d.ts | 6 - .../monorepo_scripts/postpublish.ts | 8 - packages/web3-typescript-typings/package.json | 40 - packages/web3-typescript-typings/tsconfig.json | 7 - packages/web3-typescript-typings/tslint.json | 3 - packages/web3-wrapper/README.md | 8 +- packages/web3-wrapper/package.json | 5 +- packages/web3-wrapper/tsconfig.json | 6 +- packages/website/package.json | 7 +- .../dialogs/eth_weth_conversion_dialog.tsx | 4 +- .../website/ts/components/dialogs/send_dialog.tsx | 4 +- packages/website/ts/components/footer.tsx | 2 +- packages/website/tsconfig.json | 6 +- 108 files changed, 2308 insertions(+), 2624 deletions(-) delete mode 100644 packages/chai-as-promised-typescript-typings/.npmignore delete mode 100644 packages/chai-as-promised-typescript-typings/CHANGELOG.md delete mode 100644 packages/chai-as-promised-typescript-typings/README.md delete mode 100644 packages/chai-as-promised-typescript-typings/index.d.ts delete mode 100644 packages/chai-as-promised-typescript-typings/monorepo_scripts/globals.d.ts delete mode 100644 packages/chai-as-promised-typescript-typings/monorepo_scripts/postpublish.ts delete mode 100644 packages/chai-as-promised-typescript-typings/package.json delete mode 100644 packages/chai-as-promised-typescript-typings/tsconfig.json delete mode 100644 packages/chai-as-promised-typescript-typings/tslint.json delete mode 100644 packages/chai-typescript-typings/.npmignore delete mode 100644 packages/chai-typescript-typings/CHANGELOG.md delete mode 100644 packages/chai-typescript-typings/README.md delete mode 100644 packages/chai-typescript-typings/index.d.ts delete mode 100644 packages/chai-typescript-typings/monorepo_scripts/globals.d.ts delete mode 100644 packages/chai-typescript-typings/monorepo_scripts/postpublish.ts delete mode 100644 packages/chai-typescript-typings/package.json delete mode 100644 packages/chai-typescript-typings/tsconfig.json delete mode 100644 packages/chai-typescript-typings/tslint.json delete mode 100644 packages/ethers-typescript-typings/.npmignore delete mode 100644 packages/ethers-typescript-typings/CHANGELOG.md delete mode 100644 packages/ethers-typescript-typings/README.md delete mode 100644 packages/ethers-typescript-typings/index.d.ts delete mode 100644 packages/ethers-typescript-typings/monorepo_scripts/globals.d.ts delete mode 100644 packages/ethers-typescript-typings/monorepo_scripts/postpublish.ts delete mode 100644 packages/ethers-typescript-typings/package.json delete mode 100644 packages/ethers-typescript-typings/tsconfig.json delete mode 100644 packages/ethers-typescript-typings/tslint.json create mode 100644 packages/monorepo-scripts/src/test_installation.ts create mode 100644 packages/typescript-typings/.npmignore create mode 100644 packages/typescript-typings/CHANGELOG.md create mode 100644 packages/typescript-typings/README.md create mode 100644 packages/typescript-typings/monorepo_scripts/globals.d.ts create mode 100644 packages/typescript-typings/monorepo_scripts/postpublish.ts create mode 100644 packages/typescript-typings/package.json create mode 100644 packages/typescript-typings/tsconfig.json create mode 100644 packages/typescript-typings/tslint.json create mode 100644 packages/typescript-typings/types/chai-as-promised/index.d.ts create mode 100644 packages/typescript-typings/types/chai/index.d.ts create mode 100644 packages/typescript-typings/types/ethers-contracts/index.d.ts create mode 100644 packages/typescript-typings/types/web3/index.d.ts delete mode 100644 packages/web3-typescript-typings/.npmignore delete mode 100644 packages/web3-typescript-typings/CHANGELOG.md delete mode 100644 packages/web3-typescript-typings/README.md delete mode 100644 packages/web3-typescript-typings/index.d.ts delete mode 100644 packages/web3-typescript-typings/monorepo_scripts/globals.d.ts delete mode 100644 packages/web3-typescript-typings/monorepo_scripts/postpublish.ts delete mode 100644 packages/web3-typescript-typings/package.json delete mode 100644 packages/web3-typescript-typings/tsconfig.json delete mode 100644 packages/web3-typescript-typings/tslint.json (limited to 'packages') diff --git a/packages/0x.js/README.md b/packages/0x.js/README.md index 2d0394726..5b17dac8b 100644 --- a/packages/0x.js/README.md +++ b/packages/0x.js/README.md @@ -20,11 +20,10 @@ import { ZeroEx } from '0x.js'; If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`: -``` -"include": [ - "./node_modules/web3-typescript-typings/index.d.ts", - "./node_modules/ethers-typescript-typings/index.d.ts" -] +```json +"compilerOptions": { + "typeRoots": ["node_modules/@0xproject/typescript-typings/types", "node_modules/@types"], +} ``` #### UMD: diff --git a/packages/0x.js/package.json b/packages/0x.js/package.json index 5f5b32aac..49d96235c 100644 --- a/packages/0x.js/package.json +++ b/packages/0x.js/package.json @@ -68,9 +68,7 @@ "awesome-typescript-loader": "^3.1.3", "chai": "^4.0.1", "chai-as-promised": "^7.1.0", - "chai-as-promised-typescript-typings": "^0.0.12", "chai-bignumber": "^2.0.1", - "chai-typescript-typings": "^0.0.6", "copyfiles": "^1.2.0", "dirty-chai": "^2.0.1", "json-loader": "^0.5.4", @@ -99,18 +97,17 @@ "@0xproject/types": "^0.4.1", "@0xproject/utils": "^0.4.3", "@0xproject/web3-wrapper": "^0.3.1", + "@0xproject/typescript-typings": "^0.0.1", "bintrees": "^1.0.2", "bn.js": "^4.11.8", "ethereumjs-abi": "^0.6.4", "ethereumjs-blockstream": "^2.0.6", "ethereumjs-util": "^5.1.1", "ethers-contracts": "^2.2.1", - "ethers-typescript-typings": "^0.0.4", "js-sha3": "^0.7.0", "lodash": "^4.17.4", "uuid": "^3.1.0", - "web3": "^0.20.0", - "web3-typescript-typings": "^0.10.2" + "web3": "^0.20.0" }, "publishConfig": { "access": "public" diff --git a/packages/0x.js/test/0x.js_test.ts b/packages/0x.js/test/0x.js_test.ts index d61847d1d..8ba2e53f7 100644 --- a/packages/0x.js/test/0x.js_test.ts +++ b/packages/0x.js/test/0x.js_test.ts @@ -216,7 +216,7 @@ describe('ZeroEx library', () => { s: '0x050aa3cc1f2c435e67e114cdce54b9527b4f50548342401bc5d2b77adbdacb02', }; stubs = [ - Sinon.stub((zeroEx as any)._web3Wrapper, 'signTransactionAsync').returns(Promise.resolve(signature)), + Sinon.stub((zeroEx as any)._web3Wrapper, 'signMessageAsync').returns(Promise.resolve(signature)), Sinon.stub(ZeroEx, 'isValidSignature').returns(true), ]; diff --git a/packages/0x.js/tsconfig.json b/packages/0x.js/tsconfig.json index a6b5c71c2..ddf5a910e 100644 --- a/packages/0x.js/tsconfig.json +++ b/packages/0x.js/tsconfig.json @@ -8,10 +8,6 @@ "./src/**/*", "./test/**/*", "../../node_modules/types-bn/index.d.ts", - "../../node_modules/types-ethereumjs-util/index.d.ts", - "../../node_modules/ethers-typescript-typings/index.d.ts", - "../../node_modules/web3-typescript-typings/index.d.ts", - "../../node_modules/chai-typescript-typings/index.d.ts", - "../../node_modules/chai-as-promised-typescript-typings/index.d.ts" + "../../node_modules/types-ethereumjs-util/index.d.ts" ] } diff --git a/packages/abi-gen/package.json b/packages/abi-gen/package.json index fc1adeb06..2fdf19320 100644 --- a/packages/abi-gen/package.json +++ b/packages/abi-gen/package.json @@ -24,6 +24,7 @@ "homepage": "https://github.com/0xProject/0x-monorepo/packages/abi-gen/README.md", "dependencies": { "@0xproject/utils": "^0.4.3", + "@0xproject/typescript-typings": "^0.0.1", "chalk": "^2.3.0", "glob": "^7.1.2", "handlebars": "^4.0.11", @@ -45,8 +46,7 @@ "npm-run-all": "^4.1.2", "shx": "^0.2.2", "tslint": "5.8.0", - "typescript": "2.7.1", - "web3-typescript-typings": "^0.10.2" + "typescript": "2.7.1" }, "publishConfig": { "access": "public" diff --git a/packages/abi-gen/tsconfig.json b/packages/abi-gen/tsconfig.json index 5e0c7c6d3..e35816553 100644 --- a/packages/abi-gen/tsconfig.json +++ b/packages/abi-gen/tsconfig.json @@ -3,5 +3,5 @@ "compilerOptions": { "outDir": "lib" }, - "include": ["./src/**/*", "./test/**/*", "../../node_modules/web3-typescript-typings/index.d.ts"] + "include": ["./src/**/*", "./test/**/*"] } diff --git a/packages/assert/README.md b/packages/assert/README.md index 1ea6acfb5..7f80e7e5d 100644 --- a/packages/assert/README.md +++ b/packages/assert/README.md @@ -8,14 +8,6 @@ Standard type and schema assertions to be used across all 0x projects and packag yarn add @0xproject/assert ``` -If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`: - -``` -"include": [ - "./node_modules/web3-typescript-typings/index.d.ts", -] -``` - ## Usage ```typescript @@ -24,6 +16,14 @@ import { assert } from '@0xproject/assert'; assert.isValidBaseUnitAmount('baseUnitAmount', baseUnitAmount); ``` +If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`: + +```json +"compilerOptions": { + "typeRoots": ["node_modules/@0xproject/typescript-typings/types", "node_modules/@types"], +} +``` + ## Contributing We strongly encourage that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository. diff --git a/packages/assert/package.json b/packages/assert/package.json index 73b3b7f37..3df7eab8d 100644 --- a/packages/assert/package.json +++ b/packages/assert/package.json @@ -32,7 +32,6 @@ "@types/mocha": "^2.2.42", "@types/valid-url": "^1.0.2", "chai": "^4.0.1", - "chai-typescript-typings": "^0.0.6", "copyfiles": "^1.2.0", "dirty-chai": "^2.0.1", "mocha": "^4.0.1", @@ -45,6 +44,7 @@ "dependencies": { "@0xproject/json-schemas": "^0.7.17", "@0xproject/utils": "^0.4.3", + "@0xproject/typescript-typings": "^0.0.1", "lodash": "^4.17.4", "valid-url": "^1.0.9" }, diff --git a/packages/assert/tsconfig.json b/packages/assert/tsconfig.json index 10354fa33..e35816553 100644 --- a/packages/assert/tsconfig.json +++ b/packages/assert/tsconfig.json @@ -3,10 +3,5 @@ "compilerOptions": { "outDir": "lib" }, - "include": [ - "./src/**/*", - "./test/**/*", - "../../node_modules/web3-typescript-typings/index.d.ts", - "../../node_modules/chai-typescript-typings/index.d.ts" - ] + "include": ["./src/**/*", "./test/**/*"] } diff --git a/packages/base-contract/README.md b/packages/base-contract/README.md index fa2f3da10..a689d0130 100644 --- a/packages/base-contract/README.md +++ b/packages/base-contract/README.md @@ -10,11 +10,10 @@ yarn add @0xproject/base-contract If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`: -``` -"include": [ - "./node_modules/web3-typescript-typings/index.d.ts", - "./node_modules/ethers-typescript-typings/index.d.ts" -] +```json +"compilerOptions": { + "typeRoots": ["node_modules/@0xproject/typescript-typings/types", "node_modules/@types"], +} ``` ## Usage diff --git a/packages/base-contract/package.json b/packages/base-contract/package.json index 4e0260417..554f0a41c 100644 --- a/packages/base-contract/package.json +++ b/packages/base-contract/package.json @@ -32,11 +32,10 @@ "dependencies": { "@0xproject/types": "^0.4.1", "@0xproject/web3-wrapper": "^0.3.1", + "@0xproject/typescript-typings": "^0.0.1", "ethers-contracts": "^2.2.1", - "ethers-typescript-typings": "^0.0.4", "lodash": "^4.17.4", - "web3": "^0.20.0", - "web3-typescript-typings": "^0.10.2" + "web3": "^0.20.0" }, "publishConfig": { "access": "public" diff --git a/packages/base-contract/tsconfig.json b/packages/base-contract/tsconfig.json index 8114d99cd..c56d255d5 100644 --- a/packages/base-contract/tsconfig.json +++ b/packages/base-contract/tsconfig.json @@ -3,9 +3,5 @@ "compilerOptions": { "outDir": "lib" }, - "include": [ - "./src/**/*", - "../../node_modules/web3-typescript-typings/index.d.ts", - "../../node_modules/ethers-typescript-typings/index.d.ts" - ] + "include": ["./src/**/*"] } diff --git a/packages/chai-as-promised-typescript-typings/.npmignore b/packages/chai-as-promised-typescript-typings/.npmignore deleted file mode 100644 index 104d718ed..000000000 --- a/packages/chai-as-promised-typescript-typings/.npmignore +++ /dev/null @@ -1,3 +0,0 @@ -.* -yarn-error.log -/scripts/ diff --git a/packages/chai-as-promised-typescript-typings/CHANGELOG.md b/packages/chai-as-promised-typescript-typings/CHANGELOG.md deleted file mode 100644 index 8c52570da..000000000 --- a/packages/chai-as-promised-typescript-typings/CHANGELOG.md +++ /dev/null @@ -1,3 +0,0 @@ -# CHANGELOG - -## v0.x.x - _TBD, 2018_ diff --git a/packages/chai-as-promised-typescript-typings/README.md b/packages/chai-as-promised-typescript-typings/README.md deleted file mode 100644 index 72784ef53..000000000 --- a/packages/chai-as-promised-typescript-typings/README.md +++ /dev/null @@ -1,43 +0,0 @@ -## chai-as-promised-typescript-typings - -Fork of type definitions for chai-as-promised that includes changes made by dirty-chai - -## Installation - -```bash -yarn add -D chai-as-promised-typescript-typings -``` - -## Usage - -Add the following line within an `include` section of your `tsconfig.json` - -```json -"./node_modules/chai-as-promised-typescript-typings/index.d.ts" -``` - -## Contributing - -We strongly encourage that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository. - -Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started. - -### Install Dependencies - -If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them: - -```bash -yarn config set workspaces-experimental true -``` - -Then install dependencies - -```bash -yarn install -``` - -### Lint - -```bash -yarn lint -``` diff --git a/packages/chai-as-promised-typescript-typings/index.d.ts b/packages/chai-as-promised-typescript-typings/index.d.ts deleted file mode 100644 index ba6dabdcc..000000000 --- a/packages/chai-as-promised-typescript-typings/index.d.ts +++ /dev/null @@ -1,268 +0,0 @@ -// Type definitions for chai-as-promised -// Project: https://github.com/domenic/chai-as-promised/ -// Definitions by: jt000 , Yuki Kokubun -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -declare module 'chai-as-promised' { - function chaiAsPromised(chai: any, utils: any): void; - namespace chaiAsPromised { - - } - export = chaiAsPromised; -} - -// tslint:disable:no-namespace ban-types member-ordering -declare namespace Chai { - // For BDD API - interface Assertion extends LanguageChains, NumericComparison, TypeComparison { - eventually: PromisedAssertion; - fulfilled: PromisedAssertion; - become(expected: any): PromisedAssertion; - rejected(): PromisedAssertion; - rejectedWith(expected: any, message?: string | RegExp): PromisedAssertion; - notify(fn: Function): PromisedAssertion; - } - - // Eventually does not have .then(), but PromisedAssertion have. - interface Eventually extends PromisedLanguageChains, PromisedNumericComparison, PromisedTypeComparison { - // From chai-as-promised - become(expected: PromiseLike): PromisedAssertion; - fulfilled: PromisedAssertion; - rejected: () => PromisedAssertion; - rejectedWith(expected: any, message?: string | RegExp): PromisedAssertion; - notify(fn: Function): PromisedAssertion; - - // From chai - not: PromisedAssertion; - deep: PromisedDeep; - all: PromisedKeyFilter; - a: PromisedTypeComparison; - an: PromisedTypeComparison; - include: PromisedInclude; - contain: PromisedInclude; - ok: PromisedAssertion; - true: () => PromisedAssertion; - false: () => PromisedAssertion; - null: PromisedAssertion; - undefined: PromisedAssertion; - exist: PromisedAssertion; - empty: PromisedAssertion; - arguments: PromisedAssertion; - Arguments: PromisedAssertion; - equal: PromisedEqual; - equals: PromisedEqual; - eq: PromisedEqual; - eql: PromisedEqual; - eqls: PromisedEqual; - property: PromisedProperty; - ownProperty: PromisedOwnProperty; - haveOwnProperty: PromisedOwnProperty; - length: PromisedLength; - lengthOf: PromisedLength; - match(regexp: RegExp | string, message?: string): PromisedAssertion; - string(string: string, message?: string): PromisedAssertion; - keys: PromisedKeys; - key(string: string): PromisedAssertion; - throw: PromisedThrow; - throws: PromisedThrow; - Throw: PromisedThrow; - respondTo(method: string, message?: string): PromisedAssertion; - itself: PromisedAssertion; - satisfy(matcher: Function, message?: string): PromisedAssertion; - closeTo(expected: number, delta: number, message?: string): PromisedAssertion; - members: PromisedMembers; - } - - interface PromisedAssertion extends Eventually, PromiseLike {} - - interface PromisedLanguageChains { - eventually: Eventually; - - // From chai - to: PromisedAssertion; - be: PromisedAssertion; - been: PromisedAssertion; - is: PromisedAssertion; - that: PromisedAssertion; - which: PromisedAssertion; - and: PromisedAssertion; - has: PromisedAssertion; - have: PromisedAssertion; - with: PromisedAssertion; - at: PromisedAssertion; - of: PromisedAssertion; - same: PromisedAssertion; - } - - interface PromisedNumericComparison { - above: PromisedNumberComparer; - gt: PromisedNumberComparer; - greaterThan: PromisedNumberComparer; - least: PromisedNumberComparer; - gte: PromisedNumberComparer; - below: PromisedNumberComparer; - lt: PromisedNumberComparer; - lessThan: PromisedNumberComparer; - most: PromisedNumberComparer; - lte: PromisedNumberComparer; - within(start: number, finish: number, message?: string): PromisedAssertion; - } - - type PromisedNumberComparer = (value: number, message?: string) => PromisedAssertion; - - interface PromisedTypeComparison { - (type: string, message?: string): PromisedAssertion; - instanceof: PromisedInstanceOf; - instanceOf: PromisedInstanceOf; - } - - type PromisedInstanceOf = (constructor: Object, message?: string) => PromisedAssertion; - - interface PromisedDeep { - equal: PromisedEqual; - include: PromisedInclude; - property: PromisedProperty; - } - - interface PromisedKeyFilter { - keys: PromisedKeys; - } - - type PromisedEqual = (value: any, message?: string) => PromisedAssertion; - - type PromisedProperty = (name: string, value?: any, message?: string) => PromisedAssertion; - - type PromisedOwnProperty = (name: string, message?: string) => PromisedAssertion; - - interface PromisedLength extends PromisedLanguageChains, PromisedNumericComparison { - (length: number, message?: string): PromisedAssertion; - } - - interface PromisedInclude { - (value: Object | string | number, message?: string): PromisedAssertion; - keys: PromisedKeys; - members: PromisedMembers; - all: PromisedKeyFilter; - } - - interface PromisedKeys { - (...keys: string[]): PromisedAssertion; - (keys: any[]): PromisedAssertion; - } - - interface PromisedThrow { - (): PromisedAssertion; - (expected: string | RegExp, message?: string): PromisedAssertion; - (constructor: Error | Function, expected?: string | RegExp, message?: string): PromisedAssertion; - } - - type PromisedMembers = (set: any[], message?: string) => PromisedAssertion; - - // For Assert API - interface Assert { - eventually: PromisedAssert; - isFulfilled(promise: PromiseLike, message?: string): PromiseLike; - becomes(promise: PromiseLike, expected: any, message?: string): PromiseLike; - doesNotBecome(promise: PromiseLike, expected: any, message?: string): PromiseLike; - isRejected(promise: PromiseLike, message?: string): PromiseLike; - isRejected(promise: PromiseLike, expected: any | RegExp, message?: string): PromiseLike; - notify(fn: Function): PromiseLike; - } - - export interface PromisedAssert { - fail(actual?: any, expected?: any, msg?: string, operator?: string): PromiseLike; - - ok(val: any, msg?: string): PromiseLike; - notOk(val: any, msg?: string): PromiseLike; - - equal(act: any, exp: any, msg?: string): PromiseLike; - notEqual(act: any, exp: any, msg?: string): PromiseLike; - - strictEqual(act: any, exp: any, msg?: string): PromiseLike; - notStrictEqual(act: any, exp: any, msg?: string): PromiseLike; - - deepEqual(act: any, exp: any, msg?: string): PromiseLike; - notDeepEqual(act: any, exp: any, msg?: string): PromiseLike; - - isTrue(val: any, msg?: string): PromiseLike; - isFalse(val: any, msg?: string): PromiseLike; - - isNull(val: any, msg?: string): PromiseLike; - isNotNull(val: any, msg?: string): PromiseLike; - - isUndefined(val: any, msg?: string): PromiseLike; - isDefined(val: any, msg?: string): PromiseLike; - - isFunction(val: any, msg?: string): PromiseLike; - isNotFunction(val: any, msg?: string): PromiseLike; - - isObject(val: any, msg?: string): PromiseLike; - isNotObject(val: any, msg?: string): PromiseLike; - - isArray(val: any, msg?: string): PromiseLike; - isNotArray(val: any, msg?: string): PromiseLike; - - isString(val: any, msg?: string): PromiseLike; - isNotString(val: any, msg?: string): PromiseLike; - - isNumber(val: any, msg?: string): PromiseLike; - isNotNumber(val: any, msg?: string): PromiseLike; - - isBoolean(val: any, msg?: string): PromiseLike; - isNotBoolean(val: any, msg?: string): PromiseLike; - - typeOf(val: any, type: string, msg?: string): PromiseLike; - notTypeOf(val: any, type: string, msg?: string): PromiseLike; - - instanceOf(val: any, type: Function, msg?: string): PromiseLike; - notInstanceOf(val: any, type: Function, msg?: string): PromiseLike; - - include(exp: string | any[], inc: any, msg?: string): PromiseLike; - - notInclude(exp: string | any[], inc: any, msg?: string): PromiseLike; - - match(exp: any, re: RegExp, msg?: string): PromiseLike; - notMatch(exp: any, re: RegExp, msg?: string): PromiseLike; - - property(obj: Object, prop: string, msg?: string): PromiseLike; - notProperty(obj: Object, prop: string, msg?: string): PromiseLike; - deepProperty(obj: Object, prop: string, msg?: string): PromiseLike; - notDeepProperty(obj: Object, prop: string, msg?: string): PromiseLike; - - propertyVal(obj: Object, prop: string, val: any, msg?: string): PromiseLike; - propertyNotVal(obj: Object, prop: string, val: any, msg?: string): PromiseLike; - - deepPropertyVal(obj: Object, prop: string, val: any, msg?: string): PromiseLike; - deepPropertyNotVal(obj: Object, prop: string, val: any, msg?: string): PromiseLike; - - lengthOf(exp: any, len: number, msg?: string): PromiseLike; - // alias frenzy - throw(fn: Function, msg?: string): PromiseLike; - throw(fn: Function, regExp: RegExp): PromiseLike; - throw(fn: Function, errType: Function, msg?: string): PromiseLike; - throw(fn: Function, errType: Function, regExp: RegExp): PromiseLike; - - throws(fn: Function, msg?: string): PromiseLike; - throws(fn: Function, regExp: RegExp): PromiseLike; - throws(fn: Function, errType: Function, msg?: string): PromiseLike; - throws(fn: Function, errType: Function, regExp: RegExp): PromiseLike; - - Throw(fn: Function, msg?: string): PromiseLike; - Throw(fn: Function, regExp: RegExp): PromiseLike; - Throw(fn: Function, errType: Function, msg?: string): PromiseLike; - Throw(fn: Function, errType: Function, regExp: RegExp): PromiseLike; - - doesNotThrow(fn: Function, msg?: string): PromiseLike; - doesNotThrow(fn: Function, regExp: RegExp): PromiseLike; - doesNotThrow(fn: Function, errType: Function, msg?: string): PromiseLike; - doesNotThrow(fn: Function, errType: Function, regExp: RegExp): PromiseLike; - - operator(val: any, operator: string, val2: any, msg?: string): PromiseLike; - closeTo(act: number, exp: number, delta: number, msg?: string): PromiseLike; - - sameMembers(set1: any[], set2: any[], msg?: string): PromiseLike; - includeMembers(set1: any[], set2: any[], msg?: string): PromiseLike; - - ifError(val: any, msg?: string): PromiseLike; - } -} diff --git a/packages/chai-as-promised-typescript-typings/monorepo_scripts/globals.d.ts b/packages/chai-as-promised-typescript-typings/monorepo_scripts/globals.d.ts deleted file mode 100644 index 94e63a32d..000000000 --- a/packages/chai-as-promised-typescript-typings/monorepo_scripts/globals.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -declare module '*.json' { - const json: any; - /* tslint:disable */ - export default json; - /* tslint:enable */ -} diff --git a/packages/chai-as-promised-typescript-typings/monorepo_scripts/postpublish.ts b/packages/chai-as-promised-typescript-typings/monorepo_scripts/postpublish.ts deleted file mode 100644 index dcb99d0f7..000000000 --- a/packages/chai-as-promised-typescript-typings/monorepo_scripts/postpublish.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { postpublishUtils } from '@0xproject/monorepo-scripts'; - -import * as packageJSON from '../package.json'; -import * as tsConfigJSON from '../tsconfig.json'; - -const cwd = `${__dirname}/..`; -// tslint:disable-next-line:no-floating-promises -postpublishUtils.runAsync(packageJSON, tsConfigJSON, cwd); diff --git a/packages/chai-as-promised-typescript-typings/package.json b/packages/chai-as-promised-typescript-typings/package.json deleted file mode 100644 index cbf2630ec..000000000 --- a/packages/chai-as-promised-typescript-typings/package.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "name": "chai-as-promised-typescript-typings", - "version": "0.0.12", - "description": "Typescript type definitions for chai-as-promised", - "main": "index.d.ts", - "types": "index.d.ts", - "scripts": { - "build": "tsc && copyfiles -u 1 './lib/**/*' ./scripts", - "clean": "shx rm -rf scripts" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/0xProject/0x-monorepo.git" - }, - "author": "Fabio Berger", - "contributors": [ - "Leonid Logvinov " - ], - "license": "Apache-2.0", - "bugs": { - "url": "https://github.com/0xProject/0x-monorepo/issues" - }, - "homepage": "https://github.com/0xProject/0x-monorepo/packages/chai-as-promised-typescript-typings#readme", - "dependencies": { - "chai-typescript-typings": "^0.0.6" - }, - "devDependencies": { - "@0xproject/monorepo-scripts": "^0.1.14", - "copyfiles": "^1.2.0", - "shx": "^0.2.2" - }, - "publishConfig": { - "access": "public" - } -} diff --git a/packages/chai-as-promised-typescript-typings/tsconfig.json b/packages/chai-as-promised-typescript-typings/tsconfig.json deleted file mode 100644 index bc453af4b..000000000 --- a/packages/chai-as-promised-typescript-typings/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "../../tsconfig", - "compilerOptions": { - "outDir": "lib" - }, - "include": ["./monorepo_scripts/**/*"] -} diff --git a/packages/chai-as-promised-typescript-typings/tslint.json b/packages/chai-as-promised-typescript-typings/tslint.json deleted file mode 100644 index 9a93a1f74..000000000 --- a/packages/chai-as-promised-typescript-typings/tslint.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": ["tslint-config-0xproject"] -} diff --git a/packages/chai-typescript-typings/.npmignore b/packages/chai-typescript-typings/.npmignore deleted file mode 100644 index 104d718ed..000000000 --- a/packages/chai-typescript-typings/.npmignore +++ /dev/null @@ -1,3 +0,0 @@ -.* -yarn-error.log -/scripts/ diff --git a/packages/chai-typescript-typings/CHANGELOG.md b/packages/chai-typescript-typings/CHANGELOG.md deleted file mode 100644 index 8c52570da..000000000 --- a/packages/chai-typescript-typings/CHANGELOG.md +++ /dev/null @@ -1,3 +0,0 @@ -# CHANGELOG - -## v0.x.x - _TBD, 2018_ diff --git a/packages/chai-typescript-typings/README.md b/packages/chai-typescript-typings/README.md deleted file mode 100644 index 9bd0574d1..000000000 --- a/packages/chai-typescript-typings/README.md +++ /dev/null @@ -1,43 +0,0 @@ -## chai-typescript-typings - -Fork of type definitions for chai that includes changes made by dirty-chai - -## Installation - -```bash -yarn add -D chai-typescript-typings -``` - -## Usage - -Add the following line within an `include` section of your `tsconfig.json` - -```json -"./node_modules/chai-typescript-typings/index.d.ts" -``` - -## Contributing - -We strongly encourage that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository. - -Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started. - -### Install Dependencies - -If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them: - -```bash -yarn config set workspaces-experimental true -``` - -Then install dependencies - -```bash -yarn install -``` - -### Lint - -```bash -yarn lint -``` diff --git a/packages/chai-typescript-typings/index.d.ts b/packages/chai-typescript-typings/index.d.ts deleted file mode 100644 index 8b3e4c079..000000000 --- a/packages/chai-typescript-typings/index.d.ts +++ /dev/null @@ -1,1254 +0,0 @@ -// Type definitions for chai 4.0.0 -// Project: http://chaijs.com/ -// Definitions by: Jed Mao , -// Bart van der Schoor , -// Andrew Brown , -// Olivier Chevet , -// Matt Wistrand , -// Josh Goldberg -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -// - -// tslint:disable:no-namespace member-ordering ban-types unified-signatures variable-name callable-types -declare namespace Chai { - interface ChaiStatic { - expect: ExpectStatic; - should(): Should; - /** - * Provides a way to extend the internals of Chai - */ - use(fn: (chai: any, utils: any) => void): ChaiStatic; - assert: AssertStatic; - config: Config; - AssertionError: typeof AssertionError; - version: string; - } - - export interface ExpectStatic extends AssertionStatic { - fail(actual?: any, expected?: any, message?: string, operator?: Operator): void; - } - - export interface AssertStatic extends Assert {} - - type AssertionStatic = (target: any, message?: string) => Assertion; - - export type Operator = string; // "==" | "===" | ">" | ">=" | "<" | "<=" | "!=" | "!=="; - - export type OperatorComparable = boolean | null | number | string | undefined | Date; - - interface ShouldAssertion { - equal(value1: any, value2: any, message?: string): void; - Throw: ShouldThrow; - throw: ShouldThrow; - exist(value: any, message?: string): void; - } - - interface Should extends ShouldAssertion { - not: ShouldAssertion; - fail(actual: any, expected: any, message?: string, operator?: Operator): void; - } - - interface ShouldThrow { - (actual: Function): void; - (actual: Function, expected: string | RegExp, message?: string): void; - (actual: Function, constructor: Error | Function, expected?: string | RegExp, message?: string): void; - } - - interface Assertion extends LanguageChains, NumericComparison, TypeComparison { - not: Assertion; - deep: Deep; - nested: Nested; - any: KeyFilter; - all: KeyFilter; - a: TypeComparison; - an: TypeComparison; - include: Include; - includes: Include; - contain: Include; - contains: Include; - ok: Assertion; - true: () => Assertion; - false: () => Assertion; - null: () => Assertion; - undefined: () => Assertion; - NaN: Assertion; - exist: Assertion; - empty: Assertion; - arguments: Assertion; - Arguments: Assertion; - equal: Equal; - equals: Equal; - eq: Equal; - eql: Equal; - eqls: Equal; - property: Property; - ownProperty: OwnProperty; - haveOwnProperty: OwnProperty; - ownPropertyDescriptor: OwnPropertyDescriptor; - haveOwnPropertyDescriptor: OwnPropertyDescriptor; - length: Length; - lengthOf: Length; - match: Match; - matches: Match; - string(string: string, message?: string): Assertion; - keys: Keys; - key(string: string): Assertion; - throw: (message?: string) => Assertion; - throws: Throw; - Throw: Throw; - respondTo: RespondTo; - respondsTo: RespondTo; - itself: Assertion; - satisfy: Satisfy; - satisfies: Satisfy; - closeTo: CloseTo; - approximately: CloseTo; - members: Members; - increase: PropertyChange; - increases: PropertyChange; - decrease: PropertyChange; - decreases: PropertyChange; - change: PropertyChange; - changes: PropertyChange; - extensible: Assertion; - sealed: Assertion; - frozen: Assertion; - oneOf(list: any[], message?: string): Assertion; - } - - interface LanguageChains { - to: Assertion; - be: Assertion; - been: Assertion; - is: Assertion; - that: Assertion; - which: Assertion; - and: Assertion; - has: Assertion; - have: Assertion; - with: Assertion; - at: Assertion; - of: Assertion; - same: Assertion; - } - - interface NumericComparison { - above: NumberComparer; - gt: NumberComparer; - greaterThan: NumberComparer; - least: NumberComparer; - gte: NumberComparer; - below: NumberComparer; - lt: NumberComparer; - lessThan: NumberComparer; - most: NumberComparer; - lte: NumberComparer; - within(start: number, finish: number, message?: string): Assertion; - } - - interface NumberComparer { - (value: number, message?: string): Assertion; - } - - interface TypeComparison { - (type: string, message?: string): Assertion; - instanceof: InstanceOf; - instanceOf: InstanceOf; - } - - interface InstanceOf { - (constructor: Object, message?: string): Assertion; - } - - interface CloseTo { - (expected: number, delta: number, message?: string): Assertion; - } - - interface Nested { - include: Include; - property: Property; - members: Members; - } - - interface Deep { - equal: Equal; - equals: Equal; - eq: Equal; - include: Include; - property: Property; - members: Members; - } - - interface KeyFilter { - keys: Keys; - } - - interface Equal { - (value: any, message?: string): Assertion; - } - - interface Property { - (name: string, value?: any, message?: string): Assertion; - } - - interface OwnProperty { - (name: string, message?: string): Assertion; - } - - interface OwnPropertyDescriptor { - (name: string, descriptor: PropertyDescriptor, message?: string): Assertion; - (name: string, message?: string): Assertion; - } - - interface Length extends LanguageChains, NumericComparison { - (length: number, message?: string): Assertion; - } - - interface Include { - (value: Object | string | number, message?: string): Assertion; - keys: Keys; - members: Members; - any: KeyFilter; - all: KeyFilter; - } - - interface Match { - (regexp: RegExp | string, message?: string): Assertion; - } - - interface Keys { - (...keys: string[]): Assertion; - (keys: any[]): Assertion; - (keys: Object): Assertion; - } - - interface Throw { - (): Assertion; - (expected: string, message?: string): Assertion; - (expected: RegExp, message?: string): Assertion; - (constructor: Error, expected?: string, message?: string): Assertion; - (constructor: Error, expected?: RegExp, message?: string): Assertion; - (constructor: Function, expected?: string, message?: string): Assertion; - (constructor: Function, expected?: RegExp, message?: string): Assertion; - } - - interface RespondTo { - (method: string, message?: string): Assertion; - } - - interface Satisfy { - (matcher: Function, message?: string): Assertion; - } - - interface Members { - (set: any[], message?: string): Assertion; - } - - interface PropertyChange { - (object: Object, property: string, message?: string): Assertion; - } - - export interface Assert { - /** - * @param expression Expression to test for truthiness. - * @param message Message to display on error. - */ - (expression: any, message?: string): void; - - /** - * Throws a failure. - * - * @type T Type of the objects. - * @param actual Actual value. - * @param expected Potential expected value. - * @param message Message to display on error. - * @param operator Comparison operator, if not strict equality. - * @remarks Node.js assert module-compatible. - */ - fail(actual?: T, expected?: T, message?: string, operator?: Operator): void; - - /** - * Asserts that object is truthy. - * - * @type T Type of object. - * @param object Object to test. - * @param message Message to display on error. - */ - isOk(value: T, message?: string): void; - - /** - * Asserts that object is truthy. - * - * @type T Type of object. - * @param object Object to test. - * @param message Message to display on error. - */ - ok(value: T, message?: string): void; - - /** - * Asserts that object is falsy. - * - * @type T Type of object. - * @param object Object to test. - * @param message Message to display on error. - */ - isNotOk(value: T, message?: string): void; - - /** - * Asserts that object is falsy. - * - * @type T Type of object. - * @param object Object to test. - * @param message Message to display on error. - */ - notOk(value: T, message?: string): void; - - /** - * Asserts non-strict equality (==) of actual and expected. - * - * @type T Type of the objects. - * @param actual Actual value. - * @param expected Potential expected value. - * @param message Message to display on error. - */ - equal(actual: T, expected: T, message?: string): void; - - /** - * Asserts non-strict inequality (==) of actual and expected. - * - * @type T Type of the objects. - * @param actual Actual value. - * @param expected Potential expected value. - * @param message Message to display on error. - */ - notEqual(actual: T, expected: T, message?: string): void; - - /** - * Asserts strict equality (===) of actual and expected. - * - * @type T Type of the objects. - * @param actual Actual value. - * @param expected Potential expected value. - * @param message Message to display on error. - */ - strictEqual(actual: T, expected: T, message?: string): void; - - /** - * Asserts strict inequality (==) of actual and expected. - * - * @type T Type of the objects. - * @param actual Actual value. - * @param expected Potential expected value. - * @param message Message to display on error. - */ - notStrictEqual(actual: T, expected: T, message?: string): void; - - /** - * Asserts that actual is deeply equal to expected. - * - * @type T Type of the objects. - * @param actual Actual value. - * @param expected Potential expected value. - * @param message Message to display on error. - */ - deepEqual(actual: T, expected: T, message?: string): void; - - /** - * Asserts that actual is not deeply equal to expected. - * - * @type T Type of the objects. - * @param actual Actual value. - * @param expected Potential expected value. - * @param message Message to display on error. - */ - notDeepEqual(actual: T, expected: T, message?: string): void; - - /** - * Asserts valueToCheck is strictly greater than (>) valueToBeAbove. - * - * @param valueToCheck Actual value. - * @param valueToBeAbove Minimum Potential expected value. - * @param message Message to display on error. - */ - isAbove(valueToCheck: number, valueToBeAbove: number, message?: string): void; - - /** - * Asserts valueToCheck is greater than or equal to (>=) valueToBeAtLeast. - * - * @param valueToCheck Actual value. - * @param valueToBeAtLeast Minimum Potential expected value. - * @param message Message to display on error. - */ - isAtLeast(valueToCheck: number, valueToBeAtLeast: number, message?: string): void; - - /** - * Asserts valueToCheck is strictly less than (<) valueToBeBelow. - * - * @param valueToCheck Actual value. - * @param valueToBeBelow Minimum Potential expected value. - * @param message Message to display on error. - */ - isBelow(valueToCheck: number, valueToBeBelow: number, message?: string): void; - - /** - * Asserts valueToCheck is greater than or equal to (>=) valueToBeAtMost. - * - * @param valueToCheck Actual value. - * @param valueToBeAtMost Minimum Potential expected value. - * @param message Message to display on error. - */ - isAtMost(valueToCheck: number, valueToBeAtMost: number, message?: string): void; - - /** - * Asserts that value is true. - * - * @type T Type of value. - * @param value Actual value. - * @param message Message to display on error. - */ - isTrue(value: T, message?: string): void; - - /** - * Asserts that value is false. - * - * @type T Type of value. - * @param value Actual value. - * @param message Message to display on error. - */ - isFalse(value: T, message?: string): void; - - /** - * Asserts that value is not true. - * - * @type T Type of value. - * @param value Actual value. - * @param message Message to display on error. - */ - isNotTrue(value: T, message?: string): void; - - /** - * Asserts that value is not false. - * - * @type T Type of value. - * @param value Actual value. - * @param message Message to display on error. - */ - isNotFalse(value: T, message?: string): void; - - /** - * Asserts that value is null. - * - * @type T Type of value. - * @param value Actual value. - * @param message Message to display on error. - */ - isNull(value: T, message?: string): void; - - /** - * Asserts that value is not null. - * - * @type T Type of value. - * @param value Actual value. - * @param message Message to display on error. - */ - isNotNull(value: T, message?: string): void; - - /** - * Asserts that value is not null. - * - * @type T Type of value. - * @param value Actual value. - * @param message Message to display on error. - */ - isNaN(value: T, message?: string): void; - - /** - * Asserts that value is not null. - * - * @type T Type of value. - * @param value Actual value. - * @param message Message to display on error. - */ - isNotNaN(value: T, message?: string): void; - - /** - * Asserts that value is undefined. - * - * @type T Type of value. - * @param value Actual value. - * @param message Message to display on error. - */ - isUndefined(value: T, message?: string): void; - - /** - * Asserts that value is not undefined. - * - * @type T Type of value. - * @param value Actual value. - * @param message Message to display on error. - */ - isDefined(value: T, message?: string): void; - - /** - * Asserts that value is a function. - * - * @type T Type of value. - * @param value Actual value. - * @param message Message to display on error. - */ - isFunction(value: T, message?: string): void; - - /** - * Asserts that value is not a function. - * - * @type T Type of value. - * @param value Actual value. - * @param message Message to display on error. - */ - isNotFunction(value: T, message?: string): void; - - /** - * Asserts that value is an object of type 'Object' - * (as revealed by Object.prototype.toString). - * - * @type T Type of value. - * @param value Actual value. - * @param message Message to display on error. - * @remarks The assertion does not match subclassed objects. - */ - isObject(value: T, message?: string): void; - - /** - * Asserts that value is not an object of type 'Object' - * (as revealed by Object.prototype.toString). - * - * @type T Type of value. - * @param value Actual value. - * @param message Message to display on error. - */ - isNotObject(value: T, message?: string): void; - - /** - * Asserts that value is an array. - * - * @type T Type of value. - * @param value Actual value. - * @param message Message to display on error. - */ - isArray(value: T, message?: string): void; - - /** - * Asserts that value is not an array. - * - * @type T Type of value. - * @param value Actual value. - * @param message Message to display on error. - */ - isNotArray(value: T, message?: string): void; - - /** - * Asserts that value is a string. - * - * @type T Type of value. - * @param value Actual value. - * @param message Message to display on error. - */ - isString(value: T, message?: string): void; - - /** - * Asserts that value is not a string. - * - * @type T Type of value. - * @param value Actual value. - * @param message Message to display on error. - */ - isNotString(value: T, message?: string): void; - - /** - * Asserts that value is a number. - * - * @type T Type of value. - * @param value Actual value. - * @param message Message to display on error. - */ - isNumber(value: T, message?: string): void; - - /** - * Asserts that value is not a number. - * - * @type T Type of value. - * @param value Actual value. - * @param message Message to display on error. - */ - isNotNumber(value: T, message?: string): void; - - /** - * Asserts that value is a boolean. - * - * @type T Type of value. - * @param value Actual value. - * @param message Message to display on error. - */ - isBoolean(value: T, message?: string): void; - - /** - * Asserts that value is not a boolean. - * - * @type T Type of value. - * @param value Actual value. - * @param message Message to display on error. - */ - isNotBoolean(value: T, message?: string): void; - - /** - * Asserts that value's type is name, as determined by Object.prototype.toString. - * - * @type T Type of value. - * @param value Actual value. - * @param name Potential expected type name of value. - * @param message Message to display on error. - */ - typeOf(value: T, name: string, message?: string): void; - - /** - * Asserts that value's type is not name, as determined by Object.prototype.toString. - * - * @type T Type of value. - * @param value Actual value. - * @param name Potential expected type name of value. - * @param message Message to display on error. - */ - notTypeOf(value: T, name: string, message?: string): void; - - /** - * Asserts that value is an instance of constructor. - * - * @type T Type of value. - * @param value Actual value. - * @param constructor Potential expected contructor of value. - * @param message Message to display on error. - */ - instanceOf(value: T, constructor: Function, message?: string): void; - - /** - * Asserts that value is not an instance of constructor. - * - * @type T Type of value. - * @param value Actual value. - * @param constructor Potential expected contructor of value. - * @param message Message to display on error. - */ - notInstanceOf(value: T, type: Function, message?: string): void; - - /** - * Asserts that haystack includes needle. - * - * @param haystack Container string. - * @param needle Potential expected substring of haystack. - * @param message Message to display on error. - */ - include(haystack: string, needle: string, message?: string): void; - - /** - * Asserts that haystack includes needle. - * - * @type T Type of values in haystack. - * @param haystack Container array. - * @param needle Potential value contained in haystack. - * @param message Message to display on error. - */ - include(haystack: T[], needle: T, message?: string): void; - - /** - * Asserts that haystack does not include needle. - * - * @param haystack Container string. - * @param needle Potential expected substring of haystack. - * @param message Message to display on error. - */ - notInclude(haystack: string, needle: any, message?: string): void; - - /** - * Asserts that haystack does not include needle. - * - * @type T Type of values in haystack. - * @param haystack Container array. - * @param needle Potential value contained in haystack. - * @param message Message to display on error. - */ - notInclude(haystack: any[], needle: any, message?: string): void; - - /** - * Asserts that value matches the regular expression regexp. - * - * @param value Actual value. - * @param regexp Potential match of value. - * @param message Message to display on error. - */ - match(value: string, regexp: RegExp, message?: string): void; - - /** - * Asserts that value does not match the regular expression regexp. - * - * @param value Actual value. - * @param regexp Potential match of value. - * @param message Message to display on error. - */ - notMatch(expected: any, regexp: RegExp, message?: string): void; - - /** - * Asserts that object has a property named by property. - * - * @type T Type of object. - * @param object Container object. - * @param property Potential contained property of object. - * @param message Message to display on error. - */ - property(object: T, property: string /* keyof T */, message?: string): void; - - /** - * Asserts that object has a property named by property. - * - * @type T Type of object. - * @param object Container object. - * @param property Potential contained property of object. - * @param message Message to display on error. - */ - notProperty(object: T, property: string /* keyof T */, message?: string): void; - - /** - * Asserts that object has a property named by property, which can be a string - * using dot- and bracket-notation for deep reference. - * - * @type T Type of object. - * @param object Container object. - * @param property Potential contained property of object. - * @param message Message to display on error. - */ - deepProperty(object: T, property: string, message?: string): void; - - /** - * Asserts that object does not have a property named by property, which can be a - * string using dot- and bracket-notation for deep reference. - * - * @type T Type of object. - * @param object Container object. - * @param property Potential contained property of object. - * @param message Message to display on error. - */ - notDeepProperty(object: T, property: string, message?: string): void; - - /** - * Asserts that object has a property named by property with value given by value. - * - * @type T Type of object. - * @type V Type of value. - * @param object Container object. - * @param property Potential contained property of object. - * @param value Potential expected property value. - * @param message Message to display on error. - */ - propertyVal(object: T, property: string /* keyof T */, value: V, message?: string): void; - - /** - * Asserts that object has a property named by property with value given by value. - * - * @type T Type of object. - * @type V Type of value. - * @param object Container object. - * @param property Potential contained property of object. - * @param value Potential expected property value. - * @param message Message to display on error. - */ - propertyNotVal(object: T, property: string /* keyof T */, value: V, message?: string): void; - - /** - * Asserts that object has a property named by property, which can be a string - * using dot- and bracket-notation for deep reference. - * - * @type T Type of object. - * @type V Type of value. - * @param object Container object. - * @param property Potential contained property of object. - * @param value Potential expected property value. - * @param message Message to display on error. - */ - deepPropertyVal(object: T, property: string, value: V, message?: string): void; - - /** - * Asserts that object does not have a property named by property, which can be a - * string using dot- and bracket-notation for deep reference. - * - * @type T Type of object. - * @type V Type of value. - * @param object Container object. - * @param property Potential contained property of object. - * @param value Potential expected property value. - * @param message Message to display on error. - */ - deepPropertyNotVal(object: T, property: string, value: V, message?: string): void; - - /** - * Asserts that object has a length property with the expected value. - * - * @type T Type of object. - * @param object Container object. - * @param length Potential expected length of object. - * @param message Message to display on error. - */ - lengthOf(object: T, length: number, message?: string): void; - - /** - * Asserts that fn will throw an error. - * - * @param fn Function that may throw. - * @param message Message to display on error. - */ - throw(fn: Function, message?: string): void; - - /** - * Asserts that function will throw an error with message matching regexp. - * - * @param fn Function that may throw. - * @param regExp Potential expected message match. - * @param message Message to display on error. - */ - throw(fn: Function, regExp: RegExp): void; - - /** - * Asserts that function will throw an error that is an instance of constructor. - * - * @param fn Function that may throw. - * @param constructor Potential expected error constructor. - * @param message Message to display on error. - */ - throw(fn: Function, constructor: Function, message?: string): void; - - /** - * Asserts that function will throw an error that is an instance of constructor - * and an error with message matching regexp. - * - * @param fn Function that may throw. - * @param constructor Potential expected error constructor. - * @param message Message to display on error. - */ - throw(fn: Function, constructor: Function, regExp: RegExp): void; - - /** - * Asserts that fn will throw an error. - * - * @param fn Function that may throw. - * @param message Message to display on error. - */ - throws(fn: Function, message?: string): void; - - /** - * Asserts that function will throw an error with message matching regexp. - * - * @param fn Function that may throw. - * @param regExp Potential expected message match. - * @param message Message to display on error. - */ - throws(fn: Function, regExp: RegExp, message?: string): void; - - /** - * Asserts that function will throw an error that is an instance of constructor. - * - * @param fn Function that may throw. - * @param constructor Potential expected error constructor. - * @param message Message to display on error. - */ - throws(fn: Function, errType: Function, message?: string): void; - - /** - * Asserts that function will throw an error that is an instance of constructor - * and an error with message matching regexp. - * - * @param fn Function that may throw. - * @param constructor Potential expected error constructor. - * @param message Message to display on error. - */ - throws(fn: Function, errType: Function, regExp: RegExp): void; - - /** - * Asserts that fn will throw an error. - * - * @param fn Function that may throw. - * @param message Message to display on error. - */ - Throw(fn: Function, message?: string): void; - - /** - * Asserts that function will throw an error with message matching regexp. - * - * @param fn Function that may throw. - * @param regExp Potential expected message match. - * @param message Message to display on error. - */ - Throw(fn: Function, regExp: RegExp): void; - - /** - * Asserts that function will throw an error that is an instance of constructor. - * - * @param fn Function that may throw. - * @param constructor Potential expected error constructor. - * @param message Message to display on error. - */ - Throw(fn: Function, errType: Function, message?: string): void; - - /** - * Asserts that function will throw an error that is an instance of constructor - * and an error with message matching regexp. - * - * @param fn Function that may throw. - * @param constructor Potential expected error constructor. - * @param message Message to display on error. - */ - Throw(fn: Function, errType: Function, regExp: RegExp): void; - - /** - * Asserts that fn will not throw an error. - * - * @param fn Function that may throw. - * @param message Message to display on error. - */ - doesNotThrow(fn: Function, message?: string): void; - - /** - * Asserts that function will throw an error with message matching regexp. - * - * @param fn Function that may throw. - * @param regExp Potential expected message match. - * @param message Message to display on error. - */ - doesNotThrow(fn: Function, regExp: RegExp): void; - - /** - * Asserts that function will throw an error that is an instance of constructor. - * - * @param fn Function that may throw. - * @param constructor Potential expected error constructor. - * @param message Message to display on error. - */ - doesNotThrow(fn: Function, errType: Function, message?: string): void; - - /** - * Asserts that function will throw an error that is an instance of constructor - * and an error with message matching regexp. - * - * @param fn Function that may throw. - * @param constructor Potential expected error constructor. - * @param message Message to display on error. - */ - doesNotThrow(fn: Function, errType: Function, regExp: RegExp): void; - - /** - * Compares two values using operator. - * - * @param val1 Left value during comparison. - * @param operator Comparison operator. - * @param val2 Right value during comparison. - * @param message Message to display on error. - */ - operator(val1: OperatorComparable, operator: Operator, val2: OperatorComparable, message?: string): void; - - /** - * Asserts that the target is equal to expected, to within a +/- delta range. - * - * @param actual Actual value - * @param expected Potential expected value. - * @param delta Maximum differenced between values. - * @param message Message to display on error. - */ - closeTo(actual: number, expected: number, delta: number, message?: string): void; - - /** - * Asserts that the target is equal to expected, to within a +/- delta range. - * - * @param actual Actual value - * @param expected Potential expected value. - * @param delta Maximum differenced between values. - * @param message Message to display on error. - */ - approximately(act: number, exp: number, delta: number, message?: string): void; - - /** - * Asserts that set1 and set2 have the same members. Order is not take into account. - * - * @type T Type of set values. - * @param set1 Actual set of values. - * @param set2 Potential expected set of values. - * @param message Message to display on error. - */ - sameMembers(set1: T[], set2: T[], message?: string): void; - - /** - * Asserts that set1 and set2 have the same members using deep equality checking. - * Order is not take into account. - * - * @type T Type of set values. - * @param set1 Actual set of values. - * @param set2 Potential expected set of values. - * @param message Message to display on error. - */ - sameDeepMembers(set1: T[], set2: T[], message?: string): void; - - /** - * Asserts that subset is included in superset. Order is not take into account. - * - * @type T Type of set values. - * @param superset Actual set of values. - * @param subset Potential contained set of values. - * @param message Message to display on error. - */ - includeMembers(superset: T[], subset: T[], message?: string): void; - - /** - * Asserts that subset is included in superset using deep equality checking. - * Order is not take into account. - * - * @type T Type of set values. - * @param superset Actual set of values. - * @param subset Potential contained set of values. - * @param message Message to display on error. - */ - includeDeepMembers(superset: T[], subset: T[], message?: string): void; - - /** - * Asserts that non-object, non-array value inList appears in the flat array list. - * - * @type T Type of list values. - * @param inList Value expected to be in the list. - * @param list List of values. - * @param message Message to display on error. - */ - oneOf(inList: T, list: T[], message?: string): void; - - /** - * Asserts that a function changes the value of a property. - * - * @type T Type of object. - * @param modifier Function to run. - * @param object Container object. - * @param property Property of object expected to be modified. - * @param message Message to display on error. - */ - changes(modifier: Function, object: T, property: string /* keyof T */, message?: string): void; - - /** - * Asserts that a function does not change the value of a property. - * - * @type T Type of object. - * @param modifier Function to run. - * @param object Container object. - * @param property Property of object expected not to be modified. - * @param message Message to display on error. - */ - doesNotChange(modifier: Function, object: T, property: string /* keyof T */, message?: string): void; - - /** - * Asserts that a function increases an object property. - * - * @type T Type of object. - * @param modifier Function to run. - * @param object Container object. - * @param property Property of object expected to be increased. - * @param message Message to display on error. - */ - increases(modifier: Function, object: T, property: string /* keyof T */, message?: string): void; - - /** - * Asserts that a function does not increase an object property. - * - * @type T Type of object. - * @param modifier Function to run. - * @param object Container object. - * @param property Property of object expected not to be increased. - * @param message Message to display on error. - */ - doesNotIncrease(modifier: Function, object: T, property: string /* keyof T */, message?: string): void; - - /** - * Asserts that a function decreases an object property. - * - * @type T Type of object. - * @param modifier Function to run. - * @param object Container object. - * @param property Property of object expected to be decreased. - * @param message Message to display on error. - */ - decreases(modifier: Function, object: T, property: string /* keyof T */, message?: string): void; - - /** - * Asserts that a function does not decrease an object property. - * - * @type T Type of object. - * @param modifier Function to run. - * @param object Container object. - * @param property Property of object expected not to be decreased. - * @param message Message to display on error. - */ - doesNotDecrease(modifier: Function, object: T, property: string /* keyof T */, message?: string): void; - - /** - * Asserts if value is not a false value, and throws if it is a true value. - * - * @type T Type of object. - * @param object Actual value. - * @param message Message to display on error. - * @remarks This is added to allow for chai to be a drop-in replacement for - * Node’s assert class. - */ - ifError(object: T, message?: string): void; - - /** - * Asserts that object is extensible (can have new properties added to it). - * - * @type T Type of object - * @param object Actual value. - * @param message Message to display on error. - */ - isExtensible(object: T, message?: string): void; - - /** - * Asserts that object is extensible (can have new properties added to it). - * - * @type T Type of object - * @param object Actual value. - * @param message Message to display on error. - */ - extensible(object: T, message?: string): void; - - /** - * Asserts that object is not extensible. - * - * @type T Type of object - * @param object Actual value. - * @param message Message to display on error. - */ - isNotExtensible(object: T, message?: string): void; - - /** - * Asserts that object is not extensible. - * - * @type T Type of object - * @param object Actual value. - * @param message Message to display on error. - */ - notExtensible(object: T, message?: string): void; - - /** - * Asserts that object is sealed (can have new properties added to it - * and its existing properties cannot be removed). - * - * @type T Type of object - * @param object Actual value. - * @param message Message to display on error. - */ - isSealed(object: T, message?: string): void; - - /** - * Asserts that object is sealed (can have new properties added to it - * and its existing properties cannot be removed). - * - * @type T Type of object - * @param object Actual value. - * @param message Message to display on error. - */ - sealed(object: T, message?: string): void; - - /** - * Asserts that object is not sealed. - * - * @type T Type of object - * @param object Actual value. - * @param message Message to display on error. - */ - isNotSealed(object: T, message?: string): void; - - /** - * Asserts that object is not sealed. - * - * @type T Type of object - * @param object Actual value. - * @param message Message to display on error. - */ - notSealed(object: T, message?: string): void; - - /** - * Asserts that object is frozen (cannot have new properties added to it - * and its existing properties cannot be removed). - * - * @type T Type of object - * @param object Actual value. - * @param message Message to display on error. - */ - isFrozen(object: T, message?: string): void; - - /** - * Asserts that object is frozen (cannot have new properties added to it - * and its existing properties cannot be removed). - * - * @type T Type of object - * @param object Actual value. - * @param message Message to display on error. - */ - frozen(object: T, message?: string): void; - - /** - * Asserts that object is not frozen (cannot have new properties added to it - * and its existing properties cannot be removed). - * - * @type T Type of object - * @param object Actual value. - * @param message Message to display on error. - */ - isNotFrozen(object: T, message?: string): void; - - /** - * Asserts that object is not frozen (cannot have new properties added to it - * and its existing properties cannot be removed). - * - * @type T Type of object - * @param object Actual value. - * @param message Message to display on error. - */ - notFrozen(object: T, message?: string): void; - } - - export interface Config { - /** - * Default: false - */ - includeStack: boolean; - - /** - * Default: true - */ - showDiff: boolean; - - /** - * Default: 40 - */ - truncateThreshold: number; - } - - export class AssertionError { - constructor(message: string, _props?: any, ssf?: Function); - public name: string; - public message: string; - public showDiff: boolean; - public stack: string; - } -} - -declare const chai: Chai.ChaiStatic; - -declare module 'chai' { - export = chai; -} - -interface Object { - should: Chai.Assertion; -} diff --git a/packages/chai-typescript-typings/monorepo_scripts/globals.d.ts b/packages/chai-typescript-typings/monorepo_scripts/globals.d.ts deleted file mode 100644 index 94e63a32d..000000000 --- a/packages/chai-typescript-typings/monorepo_scripts/globals.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -declare module '*.json' { - const json: any; - /* tslint:disable */ - export default json; - /* tslint:enable */ -} diff --git a/packages/chai-typescript-typings/monorepo_scripts/postpublish.ts b/packages/chai-typescript-typings/monorepo_scripts/postpublish.ts deleted file mode 100644 index dcb99d0f7..000000000 --- a/packages/chai-typescript-typings/monorepo_scripts/postpublish.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { postpublishUtils } from '@0xproject/monorepo-scripts'; - -import * as packageJSON from '../package.json'; -import * as tsConfigJSON from '../tsconfig.json'; - -const cwd = `${__dirname}/..`; -// tslint:disable-next-line:no-floating-promises -postpublishUtils.runAsync(packageJSON, tsConfigJSON, cwd); diff --git a/packages/chai-typescript-typings/package.json b/packages/chai-typescript-typings/package.json deleted file mode 100644 index 96b58cce3..000000000 --- a/packages/chai-typescript-typings/package.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "name": "chai-typescript-typings", - "version": "0.0.6", - "description": "Typescript type definitions for chai", - "main": "index.d.ts", - "types": "index.d.ts", - "scripts": { - "build": "tsc && copyfiles -u 1 './lib/**/*' ./scripts", - "clean": "shx rm -rf scripts" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/0xProject/0x-monorepo.git" - }, - "license": "Apache-2.0", - "bugs": { - "url": "https://github.com/0xProject/0x-monorepo/issues" - }, - "homepage": "https://github.com/0xProject/0x-monorepo/packages/chai-typescript-typings#readme", - "devDependencies": { - "@0xproject/monorepo-scripts": "^0.1.14", - "copyfiles": "^1.2.0", - "shx": "^0.2.2" - }, - "publishConfig": { - "access": "public" - } -} diff --git a/packages/chai-typescript-typings/tsconfig.json b/packages/chai-typescript-typings/tsconfig.json deleted file mode 100644 index bc453af4b..000000000 --- a/packages/chai-typescript-typings/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "../../tsconfig", - "compilerOptions": { - "outDir": "lib" - }, - "include": ["./monorepo_scripts/**/*"] -} diff --git a/packages/chai-typescript-typings/tslint.json b/packages/chai-typescript-typings/tslint.json deleted file mode 100644 index 9a93a1f74..000000000 --- a/packages/chai-typescript-typings/tslint.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": ["tslint-config-0xproject"] -} diff --git a/packages/connect/README.md b/packages/connect/README.md index 393ea70a0..7087214d6 100644 --- a/packages/connect/README.md +++ b/packages/connect/README.md @@ -10,10 +10,10 @@ yarn add @0xproject/connect If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`: -``` -"include": [ - "./node_modules/web3-typescript-typings/index.d.ts", -] +```json +"compilerOptions": { + "typeRoots": ["node_modules/@0xproject/typescript-typings/types", "node_modules/@types"], +} ``` ## Usage diff --git a/packages/connect/package.json b/packages/connect/package.json index ae243f288..3e9f3053c 100644 --- a/packages/connect/package.json +++ b/packages/connect/package.json @@ -53,6 +53,7 @@ "@0xproject/json-schemas": "^0.7.17", "@0xproject/types": "^0.4.1", "@0xproject/utils": "^0.4.3", + "@0xproject/typescript-typings": "^0.0.1", "isomorphic-fetch": "^2.2.1", "lodash": "^4.17.4", "query-string": "^5.0.1", @@ -69,8 +70,6 @@ "async-child-process": "^1.1.1", "chai": "^4.0.1", "chai-as-promised": "^7.1.0", - "chai-as-promised-typescript-typings": "^0.0.12", - "chai-typescript-typings": "^0.0.6", "copyfiles": "^1.2.0", "dirty-chai": "^2.0.1", "fetch-mock": "^5.13.1", @@ -80,8 +79,7 @@ "shx": "^0.2.2", "tslint": "5.8.0", "typedoc": "~0.8.0", - "typescript": "2.7.1", - "web3-typescript-typings": "^0.10.2" + "typescript": "2.7.1" }, "publishConfig": { "access": "public" diff --git a/packages/connect/tsconfig.json b/packages/connect/tsconfig.json index fd9e604ad..e35816553 100644 --- a/packages/connect/tsconfig.json +++ b/packages/connect/tsconfig.json @@ -3,11 +3,5 @@ "compilerOptions": { "outDir": "lib" }, - "include": [ - "./src/**/*", - "./test/**/*", - "../../node_modules/web3-typescript-typings/index.d.ts", - "../../node_modules/chai-as-promised-typescript-typings/index.d.ts", - "../../node_modules/chai-typescript-typings/index.d.ts" - ] + "include": ["./src/**/*", "./test/**/*"] } diff --git a/packages/contracts/package.json b/packages/contracts/package.json index 377fba473..0c931344d 100644 --- a/packages/contracts/package.json +++ b/packages/contracts/package.json @@ -49,12 +49,9 @@ "@types/yargs": "^10.0.0", "chai": "^4.0.1", "chai-as-promised": "^7.1.0", - "chai-as-promised-typescript-typings": "^0.0.12", "chai-bignumber": "^2.0.1", - "chai-typescript-typings": "^0.0.6", "copyfiles": "^1.2.0", "dirty-chai": "^2.0.1", - "ethers-typescript-typings": "^0.0.4", "mocha": "^4.0.1", "npm-run-all": "^4.1.2", "prettier": "^1.11.1", @@ -64,7 +61,6 @@ "types-bn": "^0.0.1", "types-ethereumjs-util": "0xProject/types-ethereumjs-util", "typescript": "2.7.1", - "web3-typescript-typings": "^0.10.2", "yargs": "^10.0.3" }, "dependencies": { @@ -74,6 +70,7 @@ "@0xproject/types": "^0.4.1", "@0xproject/utils": "^0.4.3", "@0xproject/web3-wrapper": "^0.3.1", + "@0xproject/typescript-typings": "^0.0.1", "bluebird": "^3.5.0", "bn.js": "^4.11.8", "ethereumjs-abi": "^0.6.4", diff --git a/packages/contracts/tsconfig.json b/packages/contracts/tsconfig.json index 490531eeb..f32a3682a 100644 --- a/packages/contracts/tsconfig.json +++ b/packages/contracts/tsconfig.json @@ -8,11 +8,6 @@ "allowJs": true }, "include": [ - "../../node_modules/types-ethereumjs-util/index.d.ts", - "../../node_modules/chai-typescript-typings/index.d.ts", - "../../node_modules/web3-typescript-typings/index.d.ts", - "../../node_modules/ethers-typescript-typings/index.d.ts", - "../../node_modules/chai-as-promised-typescript-typings/index.d.ts", "../../node_modules/types-ethereumjs-util/index.d.ts", "../../node_modules/types-bn/index.d.ts", "./globals.d.ts", diff --git a/packages/deployer/README.md b/packages/deployer/README.md index 8fe82f59e..812e8c31b 100644 --- a/packages/deployer/README.md +++ b/packages/deployer/README.md @@ -18,6 +18,14 @@ yarn global add @0xproject/deployer yarn add @0xproject/deployer ``` +If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`: + +```json +"compilerOptions": { + "typeRoots": ["node_modules/@0xproject/typescript-typings/types", "node_modules/@types"], +} +``` + **Import** ```typescript diff --git a/packages/deployer/package.json b/packages/deployer/package.json index a8b847cd0..362bc659e 100644 --- a/packages/deployer/package.json +++ b/packages/deployer/package.json @@ -53,7 +53,6 @@ "chai": "^4.0.1", "copyfiles": "^1.2.0", "dirty-chai": "^2.0.1", - "ethers-typescript-typings": "^0.0.4", "mocha": "^4.0.1", "nyc": "^11.0.1", "shx": "^0.2.2", @@ -68,6 +67,7 @@ "@0xproject/types": "^0.4.1", "@0xproject/utils": "^0.4.3", "@0xproject/web3-wrapper": "^0.3.1", + "@0xproject/typescript-typings": "^0.0.1", "ethereumjs-util": "^5.1.1", "isomorphic-fetch": "^2.2.1", "lodash": "^4.17.4", diff --git a/packages/deployer/tsconfig.json b/packages/deployer/tsconfig.json index befcde5b7..a4cbc37c5 100644 --- a/packages/deployer/tsconfig.json +++ b/packages/deployer/tsconfig.json @@ -8,9 +8,6 @@ "./src/**/*", "./test/**/*", "../../node_modules/types-bn/index.d.ts", - "../../node_modules/types-ethereumjs-util/index.d.ts", - "../../node_modules/chai-typescript-typings/index.d.ts", - "../../node_modules/ethers-typescript-typings/index.d.ts", - "../../node_modules/web3-typescript-typings/index.d.ts" + "../../node_modules/types-ethereumjs-util/index.d.ts" ] } diff --git a/packages/dev-utils/README.md b/packages/dev-utils/README.md index 0c4175e35..d7e580d9f 100644 --- a/packages/dev-utils/README.md +++ b/packages/dev-utils/README.md @@ -21,8 +21,8 @@ yarn add @0xproject/dev-utils If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`: -``` -"include": [ - "./node_modules/web3-typescript-typings/index.d.ts", -] +```json +"compilerOptions": { + "typeRoots": ["node_modules/@0xproject/typescript-typings/types", "node_modules/@types"], +} ``` diff --git a/packages/dev-utils/package.json b/packages/dev-utils/package.json index de18f4354..71c1615e8 100644 --- a/packages/dev-utils/package.json +++ b/packages/dev-utils/package.json @@ -30,7 +30,6 @@ "@types/lodash": "4.14.104", "@types/mocha": "^2.2.42", "chai": "^4.0.1", - "chai-typescript-typings": "^0.0.6", "copyfiles": "^1.2.0", "mocha": "^4.0.1", "npm-run-all": "^4.1.2", @@ -47,6 +46,7 @@ "@0xproject/types": "^0.4.1", "@0xproject/utils": "^0.4.3", "@0xproject/web3-wrapper": "^0.3.1", + "@0xproject/typescript-typings": "^0.0.1", "ethereumjs-util": "^5.1.2", "lodash": "^4.17.4", "request-promise-native": "^1.0.5", diff --git a/packages/dev-utils/tsconfig.json b/packages/dev-utils/tsconfig.json index 1ed3fbc9c..7b93af0da 100644 --- a/packages/dev-utils/tsconfig.json +++ b/packages/dev-utils/tsconfig.json @@ -7,9 +7,6 @@ "./src/**/*", "./test/**/*", "../../node_modules/types-bn/index.d.ts", - "../../node_modules/chai-typescript-typings/index.d.ts", - "../../node_modules/ethers-typescript-typings/index.d.ts", - "../../node_modules/web3-typescript-typings/index.d.ts", "../../node_modules/types-ethereumjs-util/index.d.ts" ] } diff --git a/packages/ethers-typescript-typings/.npmignore b/packages/ethers-typescript-typings/.npmignore deleted file mode 100644 index 104d718ed..000000000 --- a/packages/ethers-typescript-typings/.npmignore +++ /dev/null @@ -1,3 +0,0 @@ -.* -yarn-error.log -/scripts/ diff --git a/packages/ethers-typescript-typings/CHANGELOG.md b/packages/ethers-typescript-typings/CHANGELOG.md deleted file mode 100644 index 00bf165a4..000000000 --- a/packages/ethers-typescript-typings/CHANGELOG.md +++ /dev/null @@ -1,5 +0,0 @@ -# CHANGELOG - -## v0.0.2 - _March 4, 2018_ - - * Initial types (#413) diff --git a/packages/ethers-typescript-typings/README.md b/packages/ethers-typescript-typings/README.md deleted file mode 100644 index 56ce5f138..000000000 --- a/packages/ethers-typescript-typings/README.md +++ /dev/null @@ -1,49 +0,0 @@ -## ethers-typescript-typings - -There currently isn't an official [Ethers][ethers] -type definition included in the [DefinitelyTyped][definitelytyped] project. -Until that happens, we will continue to improve our own type definition. -If it get's close to comprehensive, we'll add it to [DefinitelyTyped][definitelytyped]. - -[ethers]: https://github.com/ethers-io/ethers.js -[definitelytyped]: https://github.com/DefinitelyTyped/DefinitelyTyped - -## Installation - -```bash -yarn add -D ethers-typescript-typings -``` - -## Usage - -Add the following line within an `include` section of your `tsconfig.json` - -```json -"./node_modules/ethers-typescript-typings/index.d.ts" -``` - -## Contributing - -We strongly encourage that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository. - -Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started. - -### Install Dependencies - -If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them: - -```bash -yarn config set workspaces-experimental true -``` - -Then install dependencies - -```bash -yarn install -``` - -### Lint - -```bash -yarn lint -``` diff --git a/packages/ethers-typescript-typings/index.d.ts b/packages/ethers-typescript-typings/index.d.ts deleted file mode 100644 index e5d38819e..000000000 --- a/packages/ethers-typescript-typings/index.d.ts +++ /dev/null @@ -1,28 +0,0 @@ -declare module 'ethers-contracts' { - export interface TransactionDescription { - name: string; - signature: string; - sighash: string; - data: string; - } - export interface CallDescription extends TransactionDescription { - parse: (...args: any[]) => any; - } - export interface FunctionDescription { - (...params: any[]): TransactionDescription | CallDescription; - inputs: { names: string[]; types: string[] }; - outputs: { names: string[]; types: string[] }; - } - export interface EventDescription { - parse: (...args: any[]) => any; - inputs: { names: string[]; types: string[] }; - signature: string; - topic: string; - } - export class Interface { - public functions: { [functionName: string]: FunctionDescription }; - public events: { [eventName: string]: EventDescription }; - public static decodeParams(types: string[], data: string): any[]; - constructor(abi: any); - } -} diff --git a/packages/ethers-typescript-typings/monorepo_scripts/globals.d.ts b/packages/ethers-typescript-typings/monorepo_scripts/globals.d.ts deleted file mode 100644 index 94e63a32d..000000000 --- a/packages/ethers-typescript-typings/monorepo_scripts/globals.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -declare module '*.json' { - const json: any; - /* tslint:disable */ - export default json; - /* tslint:enable */ -} diff --git a/packages/ethers-typescript-typings/monorepo_scripts/postpublish.ts b/packages/ethers-typescript-typings/monorepo_scripts/postpublish.ts deleted file mode 100644 index dcb99d0f7..000000000 --- a/packages/ethers-typescript-typings/monorepo_scripts/postpublish.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { postpublishUtils } from '@0xproject/monorepo-scripts'; - -import * as packageJSON from '../package.json'; -import * as tsConfigJSON from '../tsconfig.json'; - -const cwd = `${__dirname}/..`; -// tslint:disable-next-line:no-floating-promises -postpublishUtils.runAsync(packageJSON, tsConfigJSON, cwd); diff --git a/packages/ethers-typescript-typings/package.json b/packages/ethers-typescript-typings/package.json deleted file mode 100644 index d797033e1..000000000 --- a/packages/ethers-typescript-typings/package.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "name": "ethers-typescript-typings", - "version": "0.0.4", - "description": "Typescript type definitions for ethers.js", - "main": "index.d.ts", - "types": "index.d.ts", - "scripts": { - "lint": "tslint index.d.ts", - "build": "tsc && copyfiles -u 1 './lib/**/*' ./scripts", - "clean": "shx rm -rf scripts" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/0xProject/0x-monorepo.git" - }, - "author": "Fabio Berger", - "contributors": [ - "Leonid Logvinov " - ], - "license": "Apache-2.0", - "bugs": { - "url": "https://github.com/0xProject/0x-monorepo/issues" - }, - "homepage": "https://github.com/0xProject/0x-monorepo/packages/ethers-typescript-typings#readme", - "devDependencies": { - "@0xproject/monorepo-scripts": "^0.1.14", - "copyfiles": "^1.2.0", - "shx": "^0.2.2", - "tslint": "5.8.0", - "tslint-config-0xproject": "^0.0.2", - "typescript": "2.7.1" - }, - "publishConfig": { - "access": "public" - } -} diff --git a/packages/ethers-typescript-typings/tsconfig.json b/packages/ethers-typescript-typings/tsconfig.json deleted file mode 100644 index bc453af4b..000000000 --- a/packages/ethers-typescript-typings/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "../../tsconfig", - "compilerOptions": { - "outDir": "lib" - }, - "include": ["./monorepo_scripts/**/*"] -} diff --git a/packages/ethers-typescript-typings/tslint.json b/packages/ethers-typescript-typings/tslint.json deleted file mode 100644 index 9a93a1f74..000000000 --- a/packages/ethers-typescript-typings/tslint.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": ["tslint-config-0xproject"] -} diff --git a/packages/json-schemas/README.md b/packages/json-schemas/README.md index f320196e9..980d17416 100644 --- a/packages/json-schemas/README.md +++ b/packages/json-schemas/README.md @@ -12,8 +12,8 @@ yarn add @0xproject/json-schemas **Import** -```javascript -import { schemas } from '@0xproject/json-schemas'; +```typescript +import { SchemaValidator, ValidatorResult, schemas } from '@0xproject/json-schemas'; ``` or @@ -22,6 +22,14 @@ or var schemas = require('@0xproject/json-schemas').schemas; ``` +If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`: + +```json +"compilerOptions": { + "typeRoots": ["node_modules/@0xproject/typescript-typings/types", "node_modules/@types"], +} +``` + ## Contributing We strongly encourage that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository. diff --git a/packages/json-schemas/package.json b/packages/json-schemas/package.json index 1266f964b..f4f4c63b5 100644 --- a/packages/json-schemas/package.json +++ b/packages/json-schemas/package.json @@ -39,6 +39,7 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/json-schemas/README.md", "dependencies": { + "@0xproject/typescript-typings": "^0.0.1", "jsonschema": "^1.2.0", "lodash.values": "^4.3.0" }, @@ -50,7 +51,6 @@ "@types/lodash.values": "^4.3.3", "@types/mocha": "^2.2.42", "chai": "^4.0.1", - "chai-typescript-typings": "^0.0.6", "copyfiles": "^1.2.0", "dirty-chai": "^2.0.1", "lodash.foreach": "^4.5.0", diff --git a/packages/json-schemas/tsconfig.json b/packages/json-schemas/tsconfig.json index 10354fa33..e35816553 100644 --- a/packages/json-schemas/tsconfig.json +++ b/packages/json-schemas/tsconfig.json @@ -3,10 +3,5 @@ "compilerOptions": { "outDir": "lib" }, - "include": [ - "./src/**/*", - "./test/**/*", - "../../node_modules/web3-typescript-typings/index.d.ts", - "../../node_modules/chai-typescript-typings/index.d.ts" - ] + "include": ["./src/**/*", "./test/**/*"] } diff --git a/packages/monorepo-scripts/package.json b/packages/monorepo-scripts/package.json index a8f4918ca..5333e6cad 100644 --- a/packages/monorepo-scripts/package.json +++ b/packages/monorepo-scripts/package.json @@ -25,6 +25,8 @@ "@0xproject/tslint-config": "0.4.8", "@types/glob": "^5.0.33", "@types/node": "^8.0.53", + "@types/rimraf": "^2.0.2", + "lerna-get-packages": "^1.0.0", "shx": "^0.2.2", "tslint": "5.8.0", "typescript": "2.7.1" @@ -35,7 +37,9 @@ "es6-promisify": "^5.0.0", "glob": "^7.1.2", "lodash": "^4.17.4", + "promisify-child-process": "^1.0.5", "publish-release": "0xproject/publish-release", + "rimraf": "^2.6.2", "semver-sort": "^0.0.4" }, "publishConfig": { diff --git a/packages/monorepo-scripts/src/globals.d.ts b/packages/monorepo-scripts/src/globals.d.ts index 757ae4097..1d49559f2 100644 --- a/packages/monorepo-scripts/src/globals.d.ts +++ b/packages/monorepo-scripts/src/globals.d.ts @@ -6,3 +6,22 @@ declare module 'es6-promisify'; declare module 'semver-sort' { const desc: (versions: string[]) => string[]; } + +declare interface LernaPackage { + location: string; + package: { + private?: boolean; + name: string; + main?: string; + config?: { + additionalTsTypings?: string[]; + }; + }; +} +declare function lernaGetPackages(path: string): LernaPackage[]; +// lerna-get-packages declarations +declare module 'lerna-get-packages' { + export = lernaGetPackages; +} + +declare module 'promisify-child-process'; diff --git a/packages/monorepo-scripts/src/test_installation.ts b/packages/monorepo-scripts/src/test_installation.ts new file mode 100644 index 000000000..116b70f3a --- /dev/null +++ b/packages/monorepo-scripts/src/test_installation.ts @@ -0,0 +1,57 @@ +#!/usr/bin/env node + +import * as fs from 'fs'; +import lernaGetPackages = require('lerna-get-packages'); +import * as _ from 'lodash'; +import * as path from 'path'; +import { exec as execAsync } from 'promisify-child-process'; +import * as rimraf from 'rimraf'; + +import { utils } from './utils'; + +(async () => { + const monorepoRootPath = path.join(__dirname, '../../..'); + const lernaPackages = lernaGetPackages(monorepoRootPath); + const installablePackages = _.filter( + lernaPackages, + lernaPackage => + !lernaPackage.package.private && + !_.isUndefined(lernaPackage.package.main) && + lernaPackage.package.main.endsWith('.js'), + ); + for (const installableLernaPackage of installablePackages) { + const packagePath = installableLernaPackage.location; + const packageName = installableLernaPackage.package.name; + utils.log(`Testing ${packageName}`); + let result = await execAsync('npm pack', { cwd: packagePath }); + const packedPackageFileName = result.stdout.trim(); + const testDirectory = path.join(monorepoRootPath, '../test-env'); + fs.mkdirSync(testDirectory); + result = await execAsync('yarn init --yes', { cwd: testDirectory }); + utils.log(`Installing ${packedPackageFileName}`); + result = await execAsync(`yarn add ${packagePath}/${packedPackageFileName}`, { cwd: testDirectory }); + const indexFilePath = path.join(testDirectory, 'index.ts'); + fs.writeFileSync(indexFilePath, `import * as Package from '${packageName}'`); + const tsConfig = { + compilerOptions: { + module: 'commonjs', + target: 'es5', + lib: ['es2017', 'dom'], + declaration: true, + noImplicitReturns: true, + pretty: true, + strict: true, + }, + include: ['index.ts'], + }; + const tsconfigFilePath = path.join(testDirectory, 'tsconfig.json'); + fs.writeFileSync(tsconfigFilePath, JSON.stringify(tsConfig, null, 4)); + utils.log(`Compiling ${packageName}`); + await execAsync('../node_modules/typescript/bin/tsc', { cwd: testDirectory }); + utils.log(`Successfully compiled with ${packageName} as a dependency`); + rimraf.sync(testDirectory); + } +})().catch(err => { + utils.log(err.stdout); + process.exit(1); +}); diff --git a/packages/monorepo-scripts/tsconfig.json b/packages/monorepo-scripts/tsconfig.json index 3d967d05f..c56d255d5 100644 --- a/packages/monorepo-scripts/tsconfig.json +++ b/packages/monorepo-scripts/tsconfig.json @@ -3,5 +3,5 @@ "compilerOptions": { "outDir": "lib" }, - "include": ["./src/**/*", "../../node_modules/web3-typescript-typings/index.d.ts"] + "include": ["./src/**/*"] } diff --git a/packages/react-docs-example/package.json b/packages/react-docs-example/package.json index 2dce1a0eb..25fa1ecd2 100644 --- a/packages/react-docs-example/package.json +++ b/packages/react-docs-example/package.json @@ -27,8 +27,8 @@ "@types/lodash": "4.14.104", "@types/material-ui": "0.18.0", "@types/node": "^8.0.53", - "@types/react": "^15.0.15", - "@types/react-dom": "^0.14.23", + "@types/react": "^16.0.34", + "@types/react-dom": "^16.0.3", "@types/react-tap-event-plugin": "0.0.30", "awesome-typescript-loader": "^3.1.3", "copyfiles": "^1.2.0", diff --git a/packages/react-docs/README.md b/packages/react-docs/README.md index cad05ca67..9be370f10 100644 --- a/packages/react-docs/README.md +++ b/packages/react-docs/README.md @@ -33,6 +33,14 @@ This package exposes both a single `Documentation` react component that will ren Currently this package still has some external dependencies outside of the `Documentation` component, so please start your project off by copying the [react-docs-example](https://github.com/0xProject/0x-monorepo/tree/development/packages/react-docs-example) directory and modifying it there. If you need changes in the [react-docs](https://github.com/0xProject/0x-monorepo/tree/development/packages/react-docs) package, fork the 0x monorepo, make the required changes and submit a PR. Until we merge it, you can have your project depend on your own custom fork. +If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`: + +```json +"compilerOptions": { + "typeRoots": ["node_modules/@0xproject/typescript-typings/types", "node_modules/@types"], +} +``` + ## Future improvements Feel free to contribute to these improvements! diff --git a/packages/react-docs/package.json b/packages/react-docs/package.json index ebc445d98..0b0a52efa 100644 --- a/packages/react-docs/package.json +++ b/packages/react-docs/package.json @@ -35,8 +35,8 @@ "@types/lodash": "4.14.104", "@types/material-ui": "0.18.0", "@types/node": "^8.0.53", - "@types/react": "^15.0.15", - "@types/react-dom": "^0.14.23", + "@types/react": "^16.0.34", + "@types/react-dom": "^16.0.3", "@types/react-scroll": "0.0.31", "@types/react-tap-event-plugin": "0.0.30", "basscss": "^8.0.3", diff --git a/packages/react-docs/tsconfig.json b/packages/react-docs/tsconfig.json index 9af6638a2..82f44a62c 100644 --- a/packages/react-docs/tsconfig.json +++ b/packages/react-docs/tsconfig.json @@ -9,5 +9,5 @@ "*": ["node_modules/@types/*", "*"] } }, - "include": ["./src/**/*", "../../node_modules/web3-typescript-typings/index.d.ts"] + "include": ["./src/**/*"] } diff --git a/packages/react-shared/README.md b/packages/react-shared/README.md index da7ff83af..9165cf78d 100644 --- a/packages/react-shared/README.md +++ b/packages/react-shared/README.md @@ -8,6 +8,14 @@ Contains React components & frontend types/utils shared between 0x projects. yarn add @0xproject/react-shared ``` +If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`: + +```json +"compilerOptions": { + "typeRoots": ["node_modules/@0xproject/typescript-typings/types", "node_modules/@types"], +} +``` + ## Contributing We strongly encourage that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository. diff --git a/packages/react-shared/package.json b/packages/react-shared/package.json index e5201536e..8b7a0ebbb 100644 --- a/packages/react-shared/package.json +++ b/packages/react-shared/package.json @@ -33,8 +33,8 @@ "@types/lodash": "4.14.104", "@types/material-ui": "0.18.0", "@types/node": "^8.0.53", - "@types/react": "^15.0.15", - "@types/react-dom": "^0.14.23", + "@types/react": "^16.0.34", + "@types/react-dom": "^16.0.3", "@types/react-scroll": "0.0.31", "basscss": "^8.0.3", "is-mobile": "^0.2.2", diff --git a/packages/sol-cov/package.json b/packages/sol-cov/package.json index 106c47d13..6b5183ff2 100644 --- a/packages/sol-cov/package.json +++ b/packages/sol-cov/package.json @@ -40,6 +40,7 @@ "dependencies": { "@0xproject/subproviders": "^0.8.2", "@0xproject/utils": "^0.3.4", + "@0xproject/typescript-typings": "^0.0.1", "ethereumjs-util": "^5.1.1", "glob": "^7.1.2", "istanbul": "^0.4.5", @@ -57,7 +58,6 @@ "@types/mocha": "^2.2.42", "@types/node": "^8.0.53", "chai": "^4.0.1", - "chai-typescript-typings": "^0.0.6", "copyfiles": "^1.2.0", "dirty-chai": "^2.0.1", "mocha": "^4.0.1", diff --git a/packages/sol-cov/tsconfig.json b/packages/sol-cov/tsconfig.json index 44e43719b..7b93af0da 100644 --- a/packages/sol-cov/tsconfig.json +++ b/packages/sol-cov/tsconfig.json @@ -7,8 +7,6 @@ "./src/**/*", "./test/**/*", "../../node_modules/types-bn/index.d.ts", - "../../node_modules/web3-typescript-typings/index.d.ts", - "../../node_modules/chai-typescript-typings/index.d.ts", "../../node_modules/types-ethereumjs-util/index.d.ts" ] } diff --git a/packages/sra-report/package.json b/packages/sra-report/package.json index 78c37e002..d8cbea70e 100644 --- a/packages/sra-report/package.json +++ b/packages/sra-report/package.json @@ -33,6 +33,7 @@ "@0xproject/connect": "^0.6.6", "@0xproject/json-schemas": "^0.7.17", "@0xproject/utils": "^0.4.3", + "@0xproject/typescript-typings": "^0.0.1", "chalk": "^2.3.0", "lodash": "^4.17.4", "newman": "^3.9.3", @@ -48,8 +49,6 @@ "@types/yargs": "^10.0.0", "chai": "^4.0.1", "chai-as-promised": "^7.1.0", - "chai-as-promised-typescript-typings": "^0.0.10", - "chai-typescript-typings": "^0.0.4", "copyfiles": "^1.2.0", "dirty-chai": "^2.0.1", "mocha": "^4.0.1", diff --git a/packages/sra-report/tsconfig.json b/packages/sra-report/tsconfig.json index a0a54410a..e35816553 100644 --- a/packages/sra-report/tsconfig.json +++ b/packages/sra-report/tsconfig.json @@ -3,12 +3,5 @@ "compilerOptions": { "outDir": "lib" }, - "include": [ - "./src/**/*", - "./test/**/*", - "../../node_modules/chai-as-promised-typescript-typings/index.d.ts", - "../../node_modules/chai-typescript-typings/index.d.ts", - "../../node_modules/web3-typescript-typings/index.d.ts", - "../../node_modules/ethers-typescript-typings/index.d.ts" - ] + "include": ["./src/**/*", "./test/**/*"] } diff --git a/packages/subproviders/README.md b/packages/subproviders/README.md index a2bf75768..ac92b89d2 100644 --- a/packages/subproviders/README.md +++ b/packages/subproviders/README.md @@ -14,10 +14,10 @@ yarn add @0xproject/subproviders If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`: -``` -"include": [ - "./node_modules/web3-typescript-typings/index.d.ts", -] +```json +"compilerOptions": { + "typeRoots": ["node_modules/@0xproject/typescript-typings/types", "node_modules/@types"], +} ``` ## Contributing diff --git a/packages/subproviders/package.json b/packages/subproviders/package.json index 96d3e7f00..411fe22dc 100644 --- a/packages/subproviders/package.json +++ b/packages/subproviders/package.json @@ -36,6 +36,7 @@ "@0xproject/assert": "^0.2.3", "@0xproject/types": "^0.4.1", "@0xproject/utils": "^0.4.3", + "@0xproject/typescript-typings": "^0.0.1", "@ledgerhq/hw-app-eth": "^4.3.0", "@ledgerhq/hw-transport-u2f": "^4.3.0", "bn.js": "^4.11.8", @@ -47,8 +48,7 @@ "lodash": "^4.17.4", "semaphore-async-await": "^1.5.1", "web3": "^0.20.0", - "web3-provider-engine": "^13.0.1", - "web3-typescript-typings": "^0.10.2" + "web3-provider-engine": "^13.0.1" }, "devDependencies": { "@0xproject/monorepo-scripts": "^0.1.14", @@ -59,8 +59,6 @@ "@types/node": "^8.0.53", "chai": "^4.0.1", "chai-as-promised": "^7.1.0", - "chai-as-promised-typescript-typings": "^0.0.12", - "chai-typescript-typings": "^0.0.6", "copyfiles": "^1.2.0", "dirty-chai": "^2.0.1", "mocha": "^4.0.1", diff --git a/packages/subproviders/tsconfig.json b/packages/subproviders/tsconfig.json index 9a65a0a97..7b93af0da 100644 --- a/packages/subproviders/tsconfig.json +++ b/packages/subproviders/tsconfig.json @@ -6,10 +6,7 @@ "include": [ "./src/**/*", "./test/**/*", - "../../node_modules/chai-typescript-typings/index.d.ts", - "../../node_modules/web3-typescript-typings/index.d.ts", "../../node_modules/types-bn/index.d.ts", - "../../node_modules/types-ethereumjs-util/index.d.ts", - "../../node_modules/chai-as-promised-typescript-typings/index.d.ts" + "../../node_modules/types-ethereumjs-util/index.d.ts" ] } diff --git a/packages/testnet-faucets/package.json b/packages/testnet-faucets/package.json index 7159af988..7b43db4e7 100644 --- a/packages/testnet-faucets/package.json +++ b/packages/testnet-faucets/package.json @@ -18,6 +18,7 @@ "0x.js": "^0.33.6", "@0xproject/subproviders": "^0.8.2", "@0xproject/utils": "^0.4.3", + "@0xproject/typescript-typings": "^0.0.1", "body-parser": "^1.17.1", "ethereumjs-tx": "^1.3.3", "ethereumjs-util": "^5.1.1", @@ -41,7 +42,6 @@ "types-bn": "^0.0.1", "types-ethereumjs-util": "0xProject/types-ethereumjs-util", "typescript": "2.7.1", - "web3-typescript-typings": "^0.10.2", "webpack": "^3.1.0", "webpack-node-externals": "^1.6.0" } diff --git a/packages/testnet-faucets/tsconfig.json b/packages/testnet-faucets/tsconfig.json index 237f62169..b0e7ba00c 100644 --- a/packages/testnet-faucets/tsconfig.json +++ b/packages/testnet-faucets/tsconfig.json @@ -6,9 +6,7 @@ }, "include": [ "./src/ts/**/*", - "../../node_modules/ethers-typescript-typings/index.d.ts", "../../node_modules/types-bn/index.d.ts", - "../../node_modules/types-ethereumjs-util/index.d.ts", - "../../node_modules/web3-typescript-typings/index.d.ts" + "../../node_modules/types-ethereumjs-util/index.d.ts" ] } diff --git a/packages/tslint-config/tsconfig.json b/packages/tslint-config/tsconfig.json index 6e5f060a4..85c88035a 100644 --- a/packages/tslint-config/tsconfig.json +++ b/packages/tslint-config/tsconfig.json @@ -3,5 +3,5 @@ "compilerOptions": { "outDir": "lib" }, - "include": ["./rules/**/*", "./monorepo_scripts/**/*", "../../node_modules/web3-typescript-typings/index.d.ts"] + "include": ["./rules/**/*", "./monorepo_scripts/**/*"] } diff --git a/packages/types/README.md b/packages/types/README.md index 5101ee544..b971eaee7 100644 --- a/packages/types/README.md +++ b/packages/types/README.md @@ -10,10 +10,10 @@ yarn add -D @0xproject/types If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`: -``` -"include": [ - "./node_modules/web3-typescript-typings/index.d.ts", -] +```json +"compilerOptions": { + "typeRoots": ["node_modules/@0xproject/typescript-typings/types", "node_modules/@types"], +} ``` ## Usage diff --git a/packages/types/package.json b/packages/types/package.json index e664b06ae..1142d252a 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -28,9 +28,9 @@ "typescript": "2.7.1" }, "dependencies": { + "@0xproject/typescript-typings": "^0.0.1", "bignumber.js": "~4.1.0", - "web3": "^0.20.0", - "web3-typescript-typings": "^0.10.2" + "web3": "^0.20.0" }, "publishConfig": { "access": "public" diff --git a/packages/types/tsconfig.json b/packages/types/tsconfig.json index 3d967d05f..c56d255d5 100644 --- a/packages/types/tsconfig.json +++ b/packages/types/tsconfig.json @@ -3,5 +3,5 @@ "compilerOptions": { "outDir": "lib" }, - "include": ["./src/**/*", "../../node_modules/web3-typescript-typings/index.d.ts"] + "include": ["./src/**/*"] } diff --git a/packages/typescript-typings/.npmignore b/packages/typescript-typings/.npmignore new file mode 100644 index 000000000..104d718ed --- /dev/null +++ b/packages/typescript-typings/.npmignore @@ -0,0 +1,3 @@ +.* +yarn-error.log +/scripts/ diff --git a/packages/typescript-typings/CHANGELOG.md b/packages/typescript-typings/CHANGELOG.md new file mode 100644 index 000000000..8c52570da --- /dev/null +++ b/packages/typescript-typings/CHANGELOG.md @@ -0,0 +1,3 @@ +# CHANGELOG + +## v0.x.x - _TBD, 2018_ diff --git a/packages/typescript-typings/README.md b/packages/typescript-typings/README.md new file mode 100644 index 000000000..9a74739f3 --- /dev/null +++ b/packages/typescript-typings/README.md @@ -0,0 +1,45 @@ +## @0xproject/typescript-typings + +Type repository for external packages used by 0x. This is like our small version of [DefinitelyTyped](https://github.com/DefinitelyTyped/DefinitelyTyped) + +## Installation + +```bash +yarn add -D @0xproject/typescript-typings +``` + +## Usage + +Add the following line within an `compilerOptions` section of your `tsconfig.json` + +```json +"typeRoots": ["node_modules/@0xproject/typescript-typings/types", "node_modules/@types"] +``` + +This will allow the TS compiler to first look into that repo and then fallback to DT types. + +## Contributing + +We strongly encourage that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository. + +Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started. + +### Install Dependencies + +If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them: + +```bash +yarn config set workspaces-experimental true +``` + +Then install dependencies + +```bash +yarn install +``` + +### Lint + +```bash +yarn lint +``` diff --git a/packages/typescript-typings/monorepo_scripts/globals.d.ts b/packages/typescript-typings/monorepo_scripts/globals.d.ts new file mode 100644 index 000000000..94e63a32d --- /dev/null +++ b/packages/typescript-typings/monorepo_scripts/globals.d.ts @@ -0,0 +1,6 @@ +declare module '*.json' { + const json: any; + /* tslint:disable */ + export default json; + /* tslint:enable */ +} diff --git a/packages/typescript-typings/monorepo_scripts/postpublish.ts b/packages/typescript-typings/monorepo_scripts/postpublish.ts new file mode 100644 index 000000000..dcb99d0f7 --- /dev/null +++ b/packages/typescript-typings/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/typescript-typings/package.json b/packages/typescript-typings/package.json new file mode 100644 index 000000000..8fce84272 --- /dev/null +++ b/packages/typescript-typings/package.json @@ -0,0 +1,33 @@ +{ + "name": "@0xproject/typescript-typings", + "version": "0.0.1", + "description": "0x project typescript type definitions", + "scripts": { + "build": "tsc && copyfiles -u 1 './lib/**/*' ./scripts", + "clean": "shx rm -rf scripts" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/0xProject/0x-monorepo.git" + }, + "author": "Fabio Berger", + "contributors": [ + "Leonid Logvinov " + ], + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/0xProject/0x-monorepo/issues" + }, + "homepage": "https://github.com/0xProject/0x-monorepo/packages/typescript-typings#readme", + "dependencies": { + "bignumber.js": "~4.1.0" + }, + "devDependencies": { + "@0xproject/monorepo-scripts": "^0.1.14", + "copyfiles": "^1.2.0", + "shx": "^0.2.2" + }, + "publishConfig": { + "access": "public" + } +} diff --git a/packages/typescript-typings/tsconfig.json b/packages/typescript-typings/tsconfig.json new file mode 100644 index 000000000..bc453af4b --- /dev/null +++ b/packages/typescript-typings/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tsconfig", + "compilerOptions": { + "outDir": "lib" + }, + "include": ["./monorepo_scripts/**/*"] +} diff --git a/packages/typescript-typings/tslint.json b/packages/typescript-typings/tslint.json new file mode 100644 index 000000000..9a93a1f74 --- /dev/null +++ b/packages/typescript-typings/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": ["tslint-config-0xproject"] +} diff --git a/packages/typescript-typings/types/chai-as-promised/index.d.ts b/packages/typescript-typings/types/chai-as-promised/index.d.ts new file mode 100644 index 000000000..ba6dabdcc --- /dev/null +++ b/packages/typescript-typings/types/chai-as-promised/index.d.ts @@ -0,0 +1,268 @@ +// Type definitions for chai-as-promised +// Project: https://github.com/domenic/chai-as-promised/ +// Definitions by: jt000 , Yuki Kokubun +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare module 'chai-as-promised' { + function chaiAsPromised(chai: any, utils: any): void; + namespace chaiAsPromised { + + } + export = chaiAsPromised; +} + +// tslint:disable:no-namespace ban-types member-ordering +declare namespace Chai { + // For BDD API + interface Assertion extends LanguageChains, NumericComparison, TypeComparison { + eventually: PromisedAssertion; + fulfilled: PromisedAssertion; + become(expected: any): PromisedAssertion; + rejected(): PromisedAssertion; + rejectedWith(expected: any, message?: string | RegExp): PromisedAssertion; + notify(fn: Function): PromisedAssertion; + } + + // Eventually does not have .then(), but PromisedAssertion have. + interface Eventually extends PromisedLanguageChains, PromisedNumericComparison, PromisedTypeComparison { + // From chai-as-promised + become(expected: PromiseLike): PromisedAssertion; + fulfilled: PromisedAssertion; + rejected: () => PromisedAssertion; + rejectedWith(expected: any, message?: string | RegExp): PromisedAssertion; + notify(fn: Function): PromisedAssertion; + + // From chai + not: PromisedAssertion; + deep: PromisedDeep; + all: PromisedKeyFilter; + a: PromisedTypeComparison; + an: PromisedTypeComparison; + include: PromisedInclude; + contain: PromisedInclude; + ok: PromisedAssertion; + true: () => PromisedAssertion; + false: () => PromisedAssertion; + null: PromisedAssertion; + undefined: PromisedAssertion; + exist: PromisedAssertion; + empty: PromisedAssertion; + arguments: PromisedAssertion; + Arguments: PromisedAssertion; + equal: PromisedEqual; + equals: PromisedEqual; + eq: PromisedEqual; + eql: PromisedEqual; + eqls: PromisedEqual; + property: PromisedProperty; + ownProperty: PromisedOwnProperty; + haveOwnProperty: PromisedOwnProperty; + length: PromisedLength; + lengthOf: PromisedLength; + match(regexp: RegExp | string, message?: string): PromisedAssertion; + string(string: string, message?: string): PromisedAssertion; + keys: PromisedKeys; + key(string: string): PromisedAssertion; + throw: PromisedThrow; + throws: PromisedThrow; + Throw: PromisedThrow; + respondTo(method: string, message?: string): PromisedAssertion; + itself: PromisedAssertion; + satisfy(matcher: Function, message?: string): PromisedAssertion; + closeTo(expected: number, delta: number, message?: string): PromisedAssertion; + members: PromisedMembers; + } + + interface PromisedAssertion extends Eventually, PromiseLike {} + + interface PromisedLanguageChains { + eventually: Eventually; + + // From chai + to: PromisedAssertion; + be: PromisedAssertion; + been: PromisedAssertion; + is: PromisedAssertion; + that: PromisedAssertion; + which: PromisedAssertion; + and: PromisedAssertion; + has: PromisedAssertion; + have: PromisedAssertion; + with: PromisedAssertion; + at: PromisedAssertion; + of: PromisedAssertion; + same: PromisedAssertion; + } + + interface PromisedNumericComparison { + above: PromisedNumberComparer; + gt: PromisedNumberComparer; + greaterThan: PromisedNumberComparer; + least: PromisedNumberComparer; + gte: PromisedNumberComparer; + below: PromisedNumberComparer; + lt: PromisedNumberComparer; + lessThan: PromisedNumberComparer; + most: PromisedNumberComparer; + lte: PromisedNumberComparer; + within(start: number, finish: number, message?: string): PromisedAssertion; + } + + type PromisedNumberComparer = (value: number, message?: string) => PromisedAssertion; + + interface PromisedTypeComparison { + (type: string, message?: string): PromisedAssertion; + instanceof: PromisedInstanceOf; + instanceOf: PromisedInstanceOf; + } + + type PromisedInstanceOf = (constructor: Object, message?: string) => PromisedAssertion; + + interface PromisedDeep { + equal: PromisedEqual; + include: PromisedInclude; + property: PromisedProperty; + } + + interface PromisedKeyFilter { + keys: PromisedKeys; + } + + type PromisedEqual = (value: any, message?: string) => PromisedAssertion; + + type PromisedProperty = (name: string, value?: any, message?: string) => PromisedAssertion; + + type PromisedOwnProperty = (name: string, message?: string) => PromisedAssertion; + + interface PromisedLength extends PromisedLanguageChains, PromisedNumericComparison { + (length: number, message?: string): PromisedAssertion; + } + + interface PromisedInclude { + (value: Object | string | number, message?: string): PromisedAssertion; + keys: PromisedKeys; + members: PromisedMembers; + all: PromisedKeyFilter; + } + + interface PromisedKeys { + (...keys: string[]): PromisedAssertion; + (keys: any[]): PromisedAssertion; + } + + interface PromisedThrow { + (): PromisedAssertion; + (expected: string | RegExp, message?: string): PromisedAssertion; + (constructor: Error | Function, expected?: string | RegExp, message?: string): PromisedAssertion; + } + + type PromisedMembers = (set: any[], message?: string) => PromisedAssertion; + + // For Assert API + interface Assert { + eventually: PromisedAssert; + isFulfilled(promise: PromiseLike, message?: string): PromiseLike; + becomes(promise: PromiseLike, expected: any, message?: string): PromiseLike; + doesNotBecome(promise: PromiseLike, expected: any, message?: string): PromiseLike; + isRejected(promise: PromiseLike, message?: string): PromiseLike; + isRejected(promise: PromiseLike, expected: any | RegExp, message?: string): PromiseLike; + notify(fn: Function): PromiseLike; + } + + export interface PromisedAssert { + fail(actual?: any, expected?: any, msg?: string, operator?: string): PromiseLike; + + ok(val: any, msg?: string): PromiseLike; + notOk(val: any, msg?: string): PromiseLike; + + equal(act: any, exp: any, msg?: string): PromiseLike; + notEqual(act: any, exp: any, msg?: string): PromiseLike; + + strictEqual(act: any, exp: any, msg?: string): PromiseLike; + notStrictEqual(act: any, exp: any, msg?: string): PromiseLike; + + deepEqual(act: any, exp: any, msg?: string): PromiseLike; + notDeepEqual(act: any, exp: any, msg?: string): PromiseLike; + + isTrue(val: any, msg?: string): PromiseLike; + isFalse(val: any, msg?: string): PromiseLike; + + isNull(val: any, msg?: string): PromiseLike; + isNotNull(val: any, msg?: string): PromiseLike; + + isUndefined(val: any, msg?: string): PromiseLike; + isDefined(val: any, msg?: string): PromiseLike; + + isFunction(val: any, msg?: string): PromiseLike; + isNotFunction(val: any, msg?: string): PromiseLike; + + isObject(val: any, msg?: string): PromiseLike; + isNotObject(val: any, msg?: string): PromiseLike; + + isArray(val: any, msg?: string): PromiseLike; + isNotArray(val: any, msg?: string): PromiseLike; + + isString(val: any, msg?: string): PromiseLike; + isNotString(val: any, msg?: string): PromiseLike; + + isNumber(val: any, msg?: string): PromiseLike; + isNotNumber(val: any, msg?: string): PromiseLike; + + isBoolean(val: any, msg?: string): PromiseLike; + isNotBoolean(val: any, msg?: string): PromiseLike; + + typeOf(val: any, type: string, msg?: string): PromiseLike; + notTypeOf(val: any, type: string, msg?: string): PromiseLike; + + instanceOf(val: any, type: Function, msg?: string): PromiseLike; + notInstanceOf(val: any, type: Function, msg?: string): PromiseLike; + + include(exp: string | any[], inc: any, msg?: string): PromiseLike; + + notInclude(exp: string | any[], inc: any, msg?: string): PromiseLike; + + match(exp: any, re: RegExp, msg?: string): PromiseLike; + notMatch(exp: any, re: RegExp, msg?: string): PromiseLike; + + property(obj: Object, prop: string, msg?: string): PromiseLike; + notProperty(obj: Object, prop: string, msg?: string): PromiseLike; + deepProperty(obj: Object, prop: string, msg?: string): PromiseLike; + notDeepProperty(obj: Object, prop: string, msg?: string): PromiseLike; + + propertyVal(obj: Object, prop: string, val: any, msg?: string): PromiseLike; + propertyNotVal(obj: Object, prop: string, val: any, msg?: string): PromiseLike; + + deepPropertyVal(obj: Object, prop: string, val: any, msg?: string): PromiseLike; + deepPropertyNotVal(obj: Object, prop: string, val: any, msg?: string): PromiseLike; + + lengthOf(exp: any, len: number, msg?: string): PromiseLike; + // alias frenzy + throw(fn: Function, msg?: string): PromiseLike; + throw(fn: Function, regExp: RegExp): PromiseLike; + throw(fn: Function, errType: Function, msg?: string): PromiseLike; + throw(fn: Function, errType: Function, regExp: RegExp): PromiseLike; + + throws(fn: Function, msg?: string): PromiseLike; + throws(fn: Function, regExp: RegExp): PromiseLike; + throws(fn: Function, errType: Function, msg?: string): PromiseLike; + throws(fn: Function, errType: Function, regExp: RegExp): PromiseLike; + + Throw(fn: Function, msg?: string): PromiseLike; + Throw(fn: Function, regExp: RegExp): PromiseLike; + Throw(fn: Function, errType: Function, msg?: string): PromiseLike; + Throw(fn: Function, errType: Function, regExp: RegExp): PromiseLike; + + doesNotThrow(fn: Function, msg?: string): PromiseLike; + doesNotThrow(fn: Function, regExp: RegExp): PromiseLike; + doesNotThrow(fn: Function, errType: Function, msg?: string): PromiseLike; + doesNotThrow(fn: Function, errType: Function, regExp: RegExp): PromiseLike; + + operator(val: any, operator: string, val2: any, msg?: string): PromiseLike; + closeTo(act: number, exp: number, delta: number, msg?: string): PromiseLike; + + sameMembers(set1: any[], set2: any[], msg?: string): PromiseLike; + includeMembers(set1: any[], set2: any[], msg?: string): PromiseLike; + + ifError(val: any, msg?: string): PromiseLike; + } +} diff --git a/packages/typescript-typings/types/chai/index.d.ts b/packages/typescript-typings/types/chai/index.d.ts new file mode 100644 index 000000000..8b3e4c079 --- /dev/null +++ b/packages/typescript-typings/types/chai/index.d.ts @@ -0,0 +1,1254 @@ +// Type definitions for chai 4.0.0 +// Project: http://chaijs.com/ +// Definitions by: Jed Mao , +// Bart van der Schoor , +// Andrew Brown , +// Olivier Chevet , +// Matt Wistrand , +// Josh Goldberg +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +// + +// tslint:disable:no-namespace member-ordering ban-types unified-signatures variable-name callable-types +declare namespace Chai { + interface ChaiStatic { + expect: ExpectStatic; + should(): Should; + /** + * Provides a way to extend the internals of Chai + */ + use(fn: (chai: any, utils: any) => void): ChaiStatic; + assert: AssertStatic; + config: Config; + AssertionError: typeof AssertionError; + version: string; + } + + export interface ExpectStatic extends AssertionStatic { + fail(actual?: any, expected?: any, message?: string, operator?: Operator): void; + } + + export interface AssertStatic extends Assert {} + + type AssertionStatic = (target: any, message?: string) => Assertion; + + export type Operator = string; // "==" | "===" | ">" | ">=" | "<" | "<=" | "!=" | "!=="; + + export type OperatorComparable = boolean | null | number | string | undefined | Date; + + interface ShouldAssertion { + equal(value1: any, value2: any, message?: string): void; + Throw: ShouldThrow; + throw: ShouldThrow; + exist(value: any, message?: string): void; + } + + interface Should extends ShouldAssertion { + not: ShouldAssertion; + fail(actual: any, expected: any, message?: string, operator?: Operator): void; + } + + interface ShouldThrow { + (actual: Function): void; + (actual: Function, expected: string | RegExp, message?: string): void; + (actual: Function, constructor: Error | Function, expected?: string | RegExp, message?: string): void; + } + + interface Assertion extends LanguageChains, NumericComparison, TypeComparison { + not: Assertion; + deep: Deep; + nested: Nested; + any: KeyFilter; + all: KeyFilter; + a: TypeComparison; + an: TypeComparison; + include: Include; + includes: Include; + contain: Include; + contains: Include; + ok: Assertion; + true: () => Assertion; + false: () => Assertion; + null: () => Assertion; + undefined: () => Assertion; + NaN: Assertion; + exist: Assertion; + empty: Assertion; + arguments: Assertion; + Arguments: Assertion; + equal: Equal; + equals: Equal; + eq: Equal; + eql: Equal; + eqls: Equal; + property: Property; + ownProperty: OwnProperty; + haveOwnProperty: OwnProperty; + ownPropertyDescriptor: OwnPropertyDescriptor; + haveOwnPropertyDescriptor: OwnPropertyDescriptor; + length: Length; + lengthOf: Length; + match: Match; + matches: Match; + string(string: string, message?: string): Assertion; + keys: Keys; + key(string: string): Assertion; + throw: (message?: string) => Assertion; + throws: Throw; + Throw: Throw; + respondTo: RespondTo; + respondsTo: RespondTo; + itself: Assertion; + satisfy: Satisfy; + satisfies: Satisfy; + closeTo: CloseTo; + approximately: CloseTo; + members: Members; + increase: PropertyChange; + increases: PropertyChange; + decrease: PropertyChange; + decreases: PropertyChange; + change: PropertyChange; + changes: PropertyChange; + extensible: Assertion; + sealed: Assertion; + frozen: Assertion; + oneOf(list: any[], message?: string): Assertion; + } + + interface LanguageChains { + to: Assertion; + be: Assertion; + been: Assertion; + is: Assertion; + that: Assertion; + which: Assertion; + and: Assertion; + has: Assertion; + have: Assertion; + with: Assertion; + at: Assertion; + of: Assertion; + same: Assertion; + } + + interface NumericComparison { + above: NumberComparer; + gt: NumberComparer; + greaterThan: NumberComparer; + least: NumberComparer; + gte: NumberComparer; + below: NumberComparer; + lt: NumberComparer; + lessThan: NumberComparer; + most: NumberComparer; + lte: NumberComparer; + within(start: number, finish: number, message?: string): Assertion; + } + + interface NumberComparer { + (value: number, message?: string): Assertion; + } + + interface TypeComparison { + (type: string, message?: string): Assertion; + instanceof: InstanceOf; + instanceOf: InstanceOf; + } + + interface InstanceOf { + (constructor: Object, message?: string): Assertion; + } + + interface CloseTo { + (expected: number, delta: number, message?: string): Assertion; + } + + interface Nested { + include: Include; + property: Property; + members: Members; + } + + interface Deep { + equal: Equal; + equals: Equal; + eq: Equal; + include: Include; + property: Property; + members: Members; + } + + interface KeyFilter { + keys: Keys; + } + + interface Equal { + (value: any, message?: string): Assertion; + } + + interface Property { + (name: string, value?: any, message?: string): Assertion; + } + + interface OwnProperty { + (name: string, message?: string): Assertion; + } + + interface OwnPropertyDescriptor { + (name: string, descriptor: PropertyDescriptor, message?: string): Assertion; + (name: string, message?: string): Assertion; + } + + interface Length extends LanguageChains, NumericComparison { + (length: number, message?: string): Assertion; + } + + interface Include { + (value: Object | string | number, message?: string): Assertion; + keys: Keys; + members: Members; + any: KeyFilter; + all: KeyFilter; + } + + interface Match { + (regexp: RegExp | string, message?: string): Assertion; + } + + interface Keys { + (...keys: string[]): Assertion; + (keys: any[]): Assertion; + (keys: Object): Assertion; + } + + interface Throw { + (): Assertion; + (expected: string, message?: string): Assertion; + (expected: RegExp, message?: string): Assertion; + (constructor: Error, expected?: string, message?: string): Assertion; + (constructor: Error, expected?: RegExp, message?: string): Assertion; + (constructor: Function, expected?: string, message?: string): Assertion; + (constructor: Function, expected?: RegExp, message?: string): Assertion; + } + + interface RespondTo { + (method: string, message?: string): Assertion; + } + + interface Satisfy { + (matcher: Function, message?: string): Assertion; + } + + interface Members { + (set: any[], message?: string): Assertion; + } + + interface PropertyChange { + (object: Object, property: string, message?: string): Assertion; + } + + export interface Assert { + /** + * @param expression Expression to test for truthiness. + * @param message Message to display on error. + */ + (expression: any, message?: string): void; + + /** + * Throws a failure. + * + * @type T Type of the objects. + * @param actual Actual value. + * @param expected Potential expected value. + * @param message Message to display on error. + * @param operator Comparison operator, if not strict equality. + * @remarks Node.js assert module-compatible. + */ + fail(actual?: T, expected?: T, message?: string, operator?: Operator): void; + + /** + * Asserts that object is truthy. + * + * @type T Type of object. + * @param object Object to test. + * @param message Message to display on error. + */ + isOk(value: T, message?: string): void; + + /** + * Asserts that object is truthy. + * + * @type T Type of object. + * @param object Object to test. + * @param message Message to display on error. + */ + ok(value: T, message?: string): void; + + /** + * Asserts that object is falsy. + * + * @type T Type of object. + * @param object Object to test. + * @param message Message to display on error. + */ + isNotOk(value: T, message?: string): void; + + /** + * Asserts that object is falsy. + * + * @type T Type of object. + * @param object Object to test. + * @param message Message to display on error. + */ + notOk(value: T, message?: string): void; + + /** + * Asserts non-strict equality (==) of actual and expected. + * + * @type T Type of the objects. + * @param actual Actual value. + * @param expected Potential expected value. + * @param message Message to display on error. + */ + equal(actual: T, expected: T, message?: string): void; + + /** + * Asserts non-strict inequality (==) of actual and expected. + * + * @type T Type of the objects. + * @param actual Actual value. + * @param expected Potential expected value. + * @param message Message to display on error. + */ + notEqual(actual: T, expected: T, message?: string): void; + + /** + * Asserts strict equality (===) of actual and expected. + * + * @type T Type of the objects. + * @param actual Actual value. + * @param expected Potential expected value. + * @param message Message to display on error. + */ + strictEqual(actual: T, expected: T, message?: string): void; + + /** + * Asserts strict inequality (==) of actual and expected. + * + * @type T Type of the objects. + * @param actual Actual value. + * @param expected Potential expected value. + * @param message Message to display on error. + */ + notStrictEqual(actual: T, expected: T, message?: string): void; + + /** + * Asserts that actual is deeply equal to expected. + * + * @type T Type of the objects. + * @param actual Actual value. + * @param expected Potential expected value. + * @param message Message to display on error. + */ + deepEqual(actual: T, expected: T, message?: string): void; + + /** + * Asserts that actual is not deeply equal to expected. + * + * @type T Type of the objects. + * @param actual Actual value. + * @param expected Potential expected value. + * @param message Message to display on error. + */ + notDeepEqual(actual: T, expected: T, message?: string): void; + + /** + * Asserts valueToCheck is strictly greater than (>) valueToBeAbove. + * + * @param valueToCheck Actual value. + * @param valueToBeAbove Minimum Potential expected value. + * @param message Message to display on error. + */ + isAbove(valueToCheck: number, valueToBeAbove: number, message?: string): void; + + /** + * Asserts valueToCheck is greater than or equal to (>=) valueToBeAtLeast. + * + * @param valueToCheck Actual value. + * @param valueToBeAtLeast Minimum Potential expected value. + * @param message Message to display on error. + */ + isAtLeast(valueToCheck: number, valueToBeAtLeast: number, message?: string): void; + + /** + * Asserts valueToCheck is strictly less than (<) valueToBeBelow. + * + * @param valueToCheck Actual value. + * @param valueToBeBelow Minimum Potential expected value. + * @param message Message to display on error. + */ + isBelow(valueToCheck: number, valueToBeBelow: number, message?: string): void; + + /** + * Asserts valueToCheck is greater than or equal to (>=) valueToBeAtMost. + * + * @param valueToCheck Actual value. + * @param valueToBeAtMost Minimum Potential expected value. + * @param message Message to display on error. + */ + isAtMost(valueToCheck: number, valueToBeAtMost: number, message?: string): void; + + /** + * Asserts that value is true. + * + * @type T Type of value. + * @param value Actual value. + * @param message Message to display on error. + */ + isTrue(value: T, message?: string): void; + + /** + * Asserts that value is false. + * + * @type T Type of value. + * @param value Actual value. + * @param message Message to display on error. + */ + isFalse(value: T, message?: string): void; + + /** + * Asserts that value is not true. + * + * @type T Type of value. + * @param value Actual value. + * @param message Message to display on error. + */ + isNotTrue(value: T, message?: string): void; + + /** + * Asserts that value is not false. + * + * @type T Type of value. + * @param value Actual value. + * @param message Message to display on error. + */ + isNotFalse(value: T, message?: string): void; + + /** + * Asserts that value is null. + * + * @type T Type of value. + * @param value Actual value. + * @param message Message to display on error. + */ + isNull(value: T, message?: string): void; + + /** + * Asserts that value is not null. + * + * @type T Type of value. + * @param value Actual value. + * @param message Message to display on error. + */ + isNotNull(value: T, message?: string): void; + + /** + * Asserts that value is not null. + * + * @type T Type of value. + * @param value Actual value. + * @param message Message to display on error. + */ + isNaN(value: T, message?: string): void; + + /** + * Asserts that value is not null. + * + * @type T Type of value. + * @param value Actual value. + * @param message Message to display on error. + */ + isNotNaN(value: T, message?: string): void; + + /** + * Asserts that value is undefined. + * + * @type T Type of value. + * @param value Actual value. + * @param message Message to display on error. + */ + isUndefined(value: T, message?: string): void; + + /** + * Asserts that value is not undefined. + * + * @type T Type of value. + * @param value Actual value. + * @param message Message to display on error. + */ + isDefined(value: T, message?: string): void; + + /** + * Asserts that value is a function. + * + * @type T Type of value. + * @param value Actual value. + * @param message Message to display on error. + */ + isFunction(value: T, message?: string): void; + + /** + * Asserts that value is not a function. + * + * @type T Type of value. + * @param value Actual value. + * @param message Message to display on error. + */ + isNotFunction(value: T, message?: string): void; + + /** + * Asserts that value is an object of type 'Object' + * (as revealed by Object.prototype.toString). + * + * @type T Type of value. + * @param value Actual value. + * @param message Message to display on error. + * @remarks The assertion does not match subclassed objects. + */ + isObject(value: T, message?: string): void; + + /** + * Asserts that value is not an object of type 'Object' + * (as revealed by Object.prototype.toString). + * + * @type T Type of value. + * @param value Actual value. + * @param message Message to display on error. + */ + isNotObject(value: T, message?: string): void; + + /** + * Asserts that value is an array. + * + * @type T Type of value. + * @param value Actual value. + * @param message Message to display on error. + */ + isArray(value: T, message?: string): void; + + /** + * Asserts that value is not an array. + * + * @type T Type of value. + * @param value Actual value. + * @param message Message to display on error. + */ + isNotArray(value: T, message?: string): void; + + /** + * Asserts that value is a string. + * + * @type T Type of value. + * @param value Actual value. + * @param message Message to display on error. + */ + isString(value: T, message?: string): void; + + /** + * Asserts that value is not a string. + * + * @type T Type of value. + * @param value Actual value. + * @param message Message to display on error. + */ + isNotString(value: T, message?: string): void; + + /** + * Asserts that value is a number. + * + * @type T Type of value. + * @param value Actual value. + * @param message Message to display on error. + */ + isNumber(value: T, message?: string): void; + + /** + * Asserts that value is not a number. + * + * @type T Type of value. + * @param value Actual value. + * @param message Message to display on error. + */ + isNotNumber(value: T, message?: string): void; + + /** + * Asserts that value is a boolean. + * + * @type T Type of value. + * @param value Actual value. + * @param message Message to display on error. + */ + isBoolean(value: T, message?: string): void; + + /** + * Asserts that value is not a boolean. + * + * @type T Type of value. + * @param value Actual value. + * @param message Message to display on error. + */ + isNotBoolean(value: T, message?: string): void; + + /** + * Asserts that value's type is name, as determined by Object.prototype.toString. + * + * @type T Type of value. + * @param value Actual value. + * @param name Potential expected type name of value. + * @param message Message to display on error. + */ + typeOf(value: T, name: string, message?: string): void; + + /** + * Asserts that value's type is not name, as determined by Object.prototype.toString. + * + * @type T Type of value. + * @param value Actual value. + * @param name Potential expected type name of value. + * @param message Message to display on error. + */ + notTypeOf(value: T, name: string, message?: string): void; + + /** + * Asserts that value is an instance of constructor. + * + * @type T Type of value. + * @param value Actual value. + * @param constructor Potential expected contructor of value. + * @param message Message to display on error. + */ + instanceOf(value: T, constructor: Function, message?: string): void; + + /** + * Asserts that value is not an instance of constructor. + * + * @type T Type of value. + * @param value Actual value. + * @param constructor Potential expected contructor of value. + * @param message Message to display on error. + */ + notInstanceOf(value: T, type: Function, message?: string): void; + + /** + * Asserts that haystack includes needle. + * + * @param haystack Container string. + * @param needle Potential expected substring of haystack. + * @param message Message to display on error. + */ + include(haystack: string, needle: string, message?: string): void; + + /** + * Asserts that haystack includes needle. + * + * @type T Type of values in haystack. + * @param haystack Container array. + * @param needle Potential value contained in haystack. + * @param message Message to display on error. + */ + include(haystack: T[], needle: T, message?: string): void; + + /** + * Asserts that haystack does not include needle. + * + * @param haystack Container string. + * @param needle Potential expected substring of haystack. + * @param message Message to display on error. + */ + notInclude(haystack: string, needle: any, message?: string): void; + + /** + * Asserts that haystack does not include needle. + * + * @type T Type of values in haystack. + * @param haystack Container array. + * @param needle Potential value contained in haystack. + * @param message Message to display on error. + */ + notInclude(haystack: any[], needle: any, message?: string): void; + + /** + * Asserts that value matches the regular expression regexp. + * + * @param value Actual value. + * @param regexp Potential match of value. + * @param message Message to display on error. + */ + match(value: string, regexp: RegExp, message?: string): void; + + /** + * Asserts that value does not match the regular expression regexp. + * + * @param value Actual value. + * @param regexp Potential match of value. + * @param message Message to display on error. + */ + notMatch(expected: any, regexp: RegExp, message?: string): void; + + /** + * Asserts that object has a property named by property. + * + * @type T Type of object. + * @param object Container object. + * @param property Potential contained property of object. + * @param message Message to display on error. + */ + property(object: T, property: string /* keyof T */, message?: string): void; + + /** + * Asserts that object has a property named by property. + * + * @type T Type of object. + * @param object Container object. + * @param property Potential contained property of object. + * @param message Message to display on error. + */ + notProperty(object: T, property: string /* keyof T */, message?: string): void; + + /** + * Asserts that object has a property named by property, which can be a string + * using dot- and bracket-notation for deep reference. + * + * @type T Type of object. + * @param object Container object. + * @param property Potential contained property of object. + * @param message Message to display on error. + */ + deepProperty(object: T, property: string, message?: string): void; + + /** + * Asserts that object does not have a property named by property, which can be a + * string using dot- and bracket-notation for deep reference. + * + * @type T Type of object. + * @param object Container object. + * @param property Potential contained property of object. + * @param message Message to display on error. + */ + notDeepProperty(object: T, property: string, message?: string): void; + + /** + * Asserts that object has a property named by property with value given by value. + * + * @type T Type of object. + * @type V Type of value. + * @param object Container object. + * @param property Potential contained property of object. + * @param value Potential expected property value. + * @param message Message to display on error. + */ + propertyVal(object: T, property: string /* keyof T */, value: V, message?: string): void; + + /** + * Asserts that object has a property named by property with value given by value. + * + * @type T Type of object. + * @type V Type of value. + * @param object Container object. + * @param property Potential contained property of object. + * @param value Potential expected property value. + * @param message Message to display on error. + */ + propertyNotVal(object: T, property: string /* keyof T */, value: V, message?: string): void; + + /** + * Asserts that object has a property named by property, which can be a string + * using dot- and bracket-notation for deep reference. + * + * @type T Type of object. + * @type V Type of value. + * @param object Container object. + * @param property Potential contained property of object. + * @param value Potential expected property value. + * @param message Message to display on error. + */ + deepPropertyVal(object: T, property: string, value: V, message?: string): void; + + /** + * Asserts that object does not have a property named by property, which can be a + * string using dot- and bracket-notation for deep reference. + * + * @type T Type of object. + * @type V Type of value. + * @param object Container object. + * @param property Potential contained property of object. + * @param value Potential expected property value. + * @param message Message to display on error. + */ + deepPropertyNotVal(object: T, property: string, value: V, message?: string): void; + + /** + * Asserts that object has a length property with the expected value. + * + * @type T Type of object. + * @param object Container object. + * @param length Potential expected length of object. + * @param message Message to display on error. + */ + lengthOf(object: T, length: number, message?: string): void; + + /** + * Asserts that fn will throw an error. + * + * @param fn Function that may throw. + * @param message Message to display on error. + */ + throw(fn: Function, message?: string): void; + + /** + * Asserts that function will throw an error with message matching regexp. + * + * @param fn Function that may throw. + * @param regExp Potential expected message match. + * @param message Message to display on error. + */ + throw(fn: Function, regExp: RegExp): void; + + /** + * Asserts that function will throw an error that is an instance of constructor. + * + * @param fn Function that may throw. + * @param constructor Potential expected error constructor. + * @param message Message to display on error. + */ + throw(fn: Function, constructor: Function, message?: string): void; + + /** + * Asserts that function will throw an error that is an instance of constructor + * and an error with message matching regexp. + * + * @param fn Function that may throw. + * @param constructor Potential expected error constructor. + * @param message Message to display on error. + */ + throw(fn: Function, constructor: Function, regExp: RegExp): void; + + /** + * Asserts that fn will throw an error. + * + * @param fn Function that may throw. + * @param message Message to display on error. + */ + throws(fn: Function, message?: string): void; + + /** + * Asserts that function will throw an error with message matching regexp. + * + * @param fn Function that may throw. + * @param regExp Potential expected message match. + * @param message Message to display on error. + */ + throws(fn: Function, regExp: RegExp, message?: string): void; + + /** + * Asserts that function will throw an error that is an instance of constructor. + * + * @param fn Function that may throw. + * @param constructor Potential expected error constructor. + * @param message Message to display on error. + */ + throws(fn: Function, errType: Function, message?: string): void; + + /** + * Asserts that function will throw an error that is an instance of constructor + * and an error with message matching regexp. + * + * @param fn Function that may throw. + * @param constructor Potential expected error constructor. + * @param message Message to display on error. + */ + throws(fn: Function, errType: Function, regExp: RegExp): void; + + /** + * Asserts that fn will throw an error. + * + * @param fn Function that may throw. + * @param message Message to display on error. + */ + Throw(fn: Function, message?: string): void; + + /** + * Asserts that function will throw an error with message matching regexp. + * + * @param fn Function that may throw. + * @param regExp Potential expected message match. + * @param message Message to display on error. + */ + Throw(fn: Function, regExp: RegExp): void; + + /** + * Asserts that function will throw an error that is an instance of constructor. + * + * @param fn Function that may throw. + * @param constructor Potential expected error constructor. + * @param message Message to display on error. + */ + Throw(fn: Function, errType: Function, message?: string): void; + + /** + * Asserts that function will throw an error that is an instance of constructor + * and an error with message matching regexp. + * + * @param fn Function that may throw. + * @param constructor Potential expected error constructor. + * @param message Message to display on error. + */ + Throw(fn: Function, errType: Function, regExp: RegExp): void; + + /** + * Asserts that fn will not throw an error. + * + * @param fn Function that may throw. + * @param message Message to display on error. + */ + doesNotThrow(fn: Function, message?: string): void; + + /** + * Asserts that function will throw an error with message matching regexp. + * + * @param fn Function that may throw. + * @param regExp Potential expected message match. + * @param message Message to display on error. + */ + doesNotThrow(fn: Function, regExp: RegExp): void; + + /** + * Asserts that function will throw an error that is an instance of constructor. + * + * @param fn Function that may throw. + * @param constructor Potential expected error constructor. + * @param message Message to display on error. + */ + doesNotThrow(fn: Function, errType: Function, message?: string): void; + + /** + * Asserts that function will throw an error that is an instance of constructor + * and an error with message matching regexp. + * + * @param fn Function that may throw. + * @param constructor Potential expected error constructor. + * @param message Message to display on error. + */ + doesNotThrow(fn: Function, errType: Function, regExp: RegExp): void; + + /** + * Compares two values using operator. + * + * @param val1 Left value during comparison. + * @param operator Comparison operator. + * @param val2 Right value during comparison. + * @param message Message to display on error. + */ + operator(val1: OperatorComparable, operator: Operator, val2: OperatorComparable, message?: string): void; + + /** + * Asserts that the target is equal to expected, to within a +/- delta range. + * + * @param actual Actual value + * @param expected Potential expected value. + * @param delta Maximum differenced between values. + * @param message Message to display on error. + */ + closeTo(actual: number, expected: number, delta: number, message?: string): void; + + /** + * Asserts that the target is equal to expected, to within a +/- delta range. + * + * @param actual Actual value + * @param expected Potential expected value. + * @param delta Maximum differenced between values. + * @param message Message to display on error. + */ + approximately(act: number, exp: number, delta: number, message?: string): void; + + /** + * Asserts that set1 and set2 have the same members. Order is not take into account. + * + * @type T Type of set values. + * @param set1 Actual set of values. + * @param set2 Potential expected set of values. + * @param message Message to display on error. + */ + sameMembers(set1: T[], set2: T[], message?: string): void; + + /** + * Asserts that set1 and set2 have the same members using deep equality checking. + * Order is not take into account. + * + * @type T Type of set values. + * @param set1 Actual set of values. + * @param set2 Potential expected set of values. + * @param message Message to display on error. + */ + sameDeepMembers(set1: T[], set2: T[], message?: string): void; + + /** + * Asserts that subset is included in superset. Order is not take into account. + * + * @type T Type of set values. + * @param superset Actual set of values. + * @param subset Potential contained set of values. + * @param message Message to display on error. + */ + includeMembers(superset: T[], subset: T[], message?: string): void; + + /** + * Asserts that subset is included in superset using deep equality checking. + * Order is not take into account. + * + * @type T Type of set values. + * @param superset Actual set of values. + * @param subset Potential contained set of values. + * @param message Message to display on error. + */ + includeDeepMembers(superset: T[], subset: T[], message?: string): void; + + /** + * Asserts that non-object, non-array value inList appears in the flat array list. + * + * @type T Type of list values. + * @param inList Value expected to be in the list. + * @param list List of values. + * @param message Message to display on error. + */ + oneOf(inList: T, list: T[], message?: string): void; + + /** + * Asserts that a function changes the value of a property. + * + * @type T Type of object. + * @param modifier Function to run. + * @param object Container object. + * @param property Property of object expected to be modified. + * @param message Message to display on error. + */ + changes(modifier: Function, object: T, property: string /* keyof T */, message?: string): void; + + /** + * Asserts that a function does not change the value of a property. + * + * @type T Type of object. + * @param modifier Function to run. + * @param object Container object. + * @param property Property of object expected not to be modified. + * @param message Message to display on error. + */ + doesNotChange(modifier: Function, object: T, property: string /* keyof T */, message?: string): void; + + /** + * Asserts that a function increases an object property. + * + * @type T Type of object. + * @param modifier Function to run. + * @param object Container object. + * @param property Property of object expected to be increased. + * @param message Message to display on error. + */ + increases(modifier: Function, object: T, property: string /* keyof T */, message?: string): void; + + /** + * Asserts that a function does not increase an object property. + * + * @type T Type of object. + * @param modifier Function to run. + * @param object Container object. + * @param property Property of object expected not to be increased. + * @param message Message to display on error. + */ + doesNotIncrease(modifier: Function, object: T, property: string /* keyof T */, message?: string): void; + + /** + * Asserts that a function decreases an object property. + * + * @type T Type of object. + * @param modifier Function to run. + * @param object Container object. + * @param property Property of object expected to be decreased. + * @param message Message to display on error. + */ + decreases(modifier: Function, object: T, property: string /* keyof T */, message?: string): void; + + /** + * Asserts that a function does not decrease an object property. + * + * @type T Type of object. + * @param modifier Function to run. + * @param object Container object. + * @param property Property of object expected not to be decreased. + * @param message Message to display on error. + */ + doesNotDecrease(modifier: Function, object: T, property: string /* keyof T */, message?: string): void; + + /** + * Asserts if value is not a false value, and throws if it is a true value. + * + * @type T Type of object. + * @param object Actual value. + * @param message Message to display on error. + * @remarks This is added to allow for chai to be a drop-in replacement for + * Node’s assert class. + */ + ifError(object: T, message?: string): void; + + /** + * Asserts that object is extensible (can have new properties added to it). + * + * @type T Type of object + * @param object Actual value. + * @param message Message to display on error. + */ + isExtensible(object: T, message?: string): void; + + /** + * Asserts that object is extensible (can have new properties added to it). + * + * @type T Type of object + * @param object Actual value. + * @param message Message to display on error. + */ + extensible(object: T, message?: string): void; + + /** + * Asserts that object is not extensible. + * + * @type T Type of object + * @param object Actual value. + * @param message Message to display on error. + */ + isNotExtensible(object: T, message?: string): void; + + /** + * Asserts that object is not extensible. + * + * @type T Type of object + * @param object Actual value. + * @param message Message to display on error. + */ + notExtensible(object: T, message?: string): void; + + /** + * Asserts that object is sealed (can have new properties added to it + * and its existing properties cannot be removed). + * + * @type T Type of object + * @param object Actual value. + * @param message Message to display on error. + */ + isSealed(object: T, message?: string): void; + + /** + * Asserts that object is sealed (can have new properties added to it + * and its existing properties cannot be removed). + * + * @type T Type of object + * @param object Actual value. + * @param message Message to display on error. + */ + sealed(object: T, message?: string): void; + + /** + * Asserts that object is not sealed. + * + * @type T Type of object + * @param object Actual value. + * @param message Message to display on error. + */ + isNotSealed(object: T, message?: string): void; + + /** + * Asserts that object is not sealed. + * + * @type T Type of object + * @param object Actual value. + * @param message Message to display on error. + */ + notSealed(object: T, message?: string): void; + + /** + * Asserts that object is frozen (cannot have new properties added to it + * and its existing properties cannot be removed). + * + * @type T Type of object + * @param object Actual value. + * @param message Message to display on error. + */ + isFrozen(object: T, message?: string): void; + + /** + * Asserts that object is frozen (cannot have new properties added to it + * and its existing properties cannot be removed). + * + * @type T Type of object + * @param object Actual value. + * @param message Message to display on error. + */ + frozen(object: T, message?: string): void; + + /** + * Asserts that object is not frozen (cannot have new properties added to it + * and its existing properties cannot be removed). + * + * @type T Type of object + * @param object Actual value. + * @param message Message to display on error. + */ + isNotFrozen(object: T, message?: string): void; + + /** + * Asserts that object is not frozen (cannot have new properties added to it + * and its existing properties cannot be removed). + * + * @type T Type of object + * @param object Actual value. + * @param message Message to display on error. + */ + notFrozen(object: T, message?: string): void; + } + + export interface Config { + /** + * Default: false + */ + includeStack: boolean; + + /** + * Default: true + */ + showDiff: boolean; + + /** + * Default: 40 + */ + truncateThreshold: number; + } + + export class AssertionError { + constructor(message: string, _props?: any, ssf?: Function); + public name: string; + public message: string; + public showDiff: boolean; + public stack: string; + } +} + +declare const chai: Chai.ChaiStatic; + +declare module 'chai' { + export = chai; +} + +interface Object { + should: Chai.Assertion; +} diff --git a/packages/typescript-typings/types/ethers-contracts/index.d.ts b/packages/typescript-typings/types/ethers-contracts/index.d.ts new file mode 100644 index 000000000..e5d38819e --- /dev/null +++ b/packages/typescript-typings/types/ethers-contracts/index.d.ts @@ -0,0 +1,28 @@ +declare module 'ethers-contracts' { + export interface TransactionDescription { + name: string; + signature: string; + sighash: string; + data: string; + } + export interface CallDescription extends TransactionDescription { + parse: (...args: any[]) => any; + } + export interface FunctionDescription { + (...params: any[]): TransactionDescription | CallDescription; + inputs: { names: string[]; types: string[] }; + outputs: { names: string[]; types: string[] }; + } + export interface EventDescription { + parse: (...args: any[]) => any; + inputs: { names: string[]; types: string[] }; + signature: string; + topic: string; + } + export class Interface { + public functions: { [functionName: string]: FunctionDescription }; + public events: { [eventName: string]: EventDescription }; + public static decodeParams(types: string[], data: string): any[]; + constructor(abi: any); + } +} diff --git a/packages/typescript-typings/types/web3/index.d.ts b/packages/typescript-typings/types/web3/index.d.ts new file mode 100644 index 000000000..cbe067b37 --- /dev/null +++ b/packages/typescript-typings/types/web3/index.d.ts @@ -0,0 +1,440 @@ +declare module 'web3' { + import * as BigNumber from 'bignumber.js'; + + type MixedData = string | number | object | any[] | BigNumber.BigNumber; + + class Web3 { + public static providers: typeof providers; + public currentProvider: Web3.Provider; + + public eth: Web3.EthApi; + public personal: Web3.PersonalApi | undefined; + public version: Web3.VersionApi; + public net: Web3.NetApi; + + public constructor(provider?: Web3.Provider); + + public isConnected(): boolean; + public setProvider(provider: Web3.Provider): void; + public reset(keepIsSyncing: boolean): void; + public toHex(data: MixedData): string; + public toAscii(hex: string): string; + public fromAscii(ascii: string, padding?: number): string; + public toDecimal(hex: string): number; + public fromDecimal(value: number | string): string; + public fromWei(value: number | string, unit: Web3.Unit): string; + public fromWei(value: BigNumber.BigNumber, unit: Web3.Unit): BigNumber.BigNumber; + public toWei(amount: number | string, unit: Web3.Unit): string; + public toWei(amount: BigNumber.BigNumber, unit: Web3.Unit): BigNumber.BigNumber; + public toBigNumber(value: number | string): BigNumber.BigNumber; + public isAddress(address: string): boolean; + public isChecksumAddress(address: string): boolean; + public sha3(value: string, options?: Web3.Sha3Options): string; + } + + namespace providers { + class HttpProvider implements Web3.Provider { + constructor(url?: string, timeout?: number, username?: string, password?: string); + public sendAsync( + payload: Web3.JSONRPCRequestPayload, + callback: (err: Error, result: Web3.JSONRPCResponsePayload) => void, + ): void; + } + } + + namespace Web3 { + type ContractAbi = AbiDefinition[]; + + type AbiDefinition = FunctionAbi | EventAbi; + + type FunctionAbi = MethodAbi | ConstructorAbi | FallbackAbi; + + enum AbiType { + Function = 'function', + Constructor = 'constructor', + Event = 'event', + Fallback = 'fallback', + } + + type ConstructorStateMutability = 'nonpayable' | 'payable'; + type StateMutability = 'pure' | 'view' | ConstructorStateMutability; + + interface MethodAbi { + type: AbiType.Function; + name: string; + inputs: DataItem[]; + outputs: DataItem[]; + constant: boolean; + stateMutability: StateMutability; + payable: boolean; + } + + interface ConstructorAbi { + type: AbiType.Constructor; + inputs: DataItem[]; + payable: boolean; + stateMutability: ConstructorStateMutability; + } + + interface FallbackAbi { + type: AbiType.Fallback; + payable: boolean; + } + + interface EventParameter extends DataItem { + indexed: boolean; + } + + interface EventAbi { + type: AbiType.Event; + name: string; + inputs: EventParameter[]; + anonymous: boolean; + } + + interface DataItem { + name: string; + type: string; + components: DataItem[]; + } + + interface ContractInstance { + address: string; + abi: Web3.ContractAbi; + [name: string]: any; + } + + interface Contract { + at(address: string): A; + getData(...args: any[]): string; + 'new'(...args: any[]): A; + } + + interface FilterObject { + fromBlock?: number | string; + toBlock?: number | string; + address?: string; + topics?: LogTopic[]; + } + + type LogTopic = null | string | string[]; + + interface DecodedLogEntry extends LogEntry { + event: string; + args: A; + } + + interface DecodedLogEntryEvent extends DecodedLogEntry { + removed: boolean; + } + + interface LogEntryEvent extends LogEntry { + removed: boolean; + } + + interface FilterResult { + get(callback: () => void): void; + watch(callback: (err: Error, result: LogEntryEvent) => void): void; + stopWatching(callback?: () => void): void; + } + + export interface JSONRPCRequestPayload { + params: any[]; + method: string; + id: number; + jsonrpc: string; + } + + export interface JSONRPCResponsePayload { + result: any; + id: number; + jsonrpc: string; + } + + export type OpCode = string; + + export interface StructLog { + depth: number; + error: string; + gas: number; + gasCost: number; + memory: string[]; + op: OpCode; + pc: number; + stack: string[]; + storage: { [location: string]: string }; + } + export interface TransactionTrace { + gas: number; + returnValue: any; + structLogs: StructLog[]; + } + + interface Provider { + sendAsync( + payload: JSONRPCRequestPayload, + callback: (err: Error, result: JSONRPCResponsePayload) => void, + ): void; + } + + interface Sha3Options { + encoding: 'hex'; + } + + interface EthApi { + coinbase: string; + mining: boolean; + hashrate: number; + gasPrice: BigNumber.BigNumber; + accounts: string[]; + blockNumber: number; + defaultAccount?: string; + defaultBlock: Web3.BlockParam; + syncing: Web3.SyncingResult; + compile: { + solidity(sourceString: string, cb?: (err: Error, result: any) => void): object; + }; + getMining(cd: (err: Error, mining: boolean) => void): void; + getHashrate(cd: (err: Error, hashrate: number) => void): void; + getGasPrice(cd: (err: Error, gasPrice: BigNumber.BigNumber) => void): void; + getAccounts(cd: (err: Error, accounts: string[]) => void): void; + getBlockNumber(callback: (err: Error, blockNumber: number) => void): void; + getSyncing(cd: (err: Error, syncing: Web3.SyncingResult) => void): void; + isSyncing(cb: (err: Error, isSyncing: boolean, syncingState: Web3.SyncingState) => void): Web3.IsSyncing; + + getBlock(hashStringOrBlockNumber: string | Web3.BlockParam): Web3.BlockWithoutTransactionData; + getBlock( + hashStringOrBlockNumber: string | Web3.BlockParam, + callback: (err: Error, blockObj: Web3.BlockWithoutTransactionData) => void, + ): void; + getBlock( + hashStringOrBlockNumber: string | Web3.BlockParam, + returnTransactionObjects: true, + ): Web3.BlockWithTransactionData; + getBlock( + hashStringOrBlockNumber: string | Web3.BlockParam, + returnTransactionObjects: true, + callback: (err: Error, blockObj: Web3.BlockWithTransactionData) => void, + ): void; + + getBlockTransactionCount(hashStringOrBlockNumber: string | Web3.BlockParam): number; + getBlockTransactionCount( + hashStringOrBlockNumber: string | Web3.BlockParam, + callback: (err: Error, blockTransactionCount: number) => void, + ): void; + + // TODO returnTransactionObjects + getUncle( + hashStringOrBlockNumber: string | Web3.BlockParam, + uncleNumber: number, + ): Web3.BlockWithoutTransactionData; + getUncle( + hashStringOrBlockNumber: string | Web3.BlockParam, + uncleNumber: number, + callback: (err: Error, uncle: Web3.BlockWithoutTransactionData) => void, + ): void; + + getTransaction(transactionHash: string): Web3.Transaction; + getTransaction( + transactionHash: string, + callback: (err: Error, transaction: Web3.Transaction) => void, + ): void; + + getTransactionFromBlock( + hashStringOrBlockNumber: string | Web3.BlockParam, + indexNumber: number, + ): Web3.Transaction; + getTransactionFromBlock( + hashStringOrBlockNumber: string | Web3.BlockParam, + indexNumber: number, + callback: (err: Error, transaction: Web3.Transaction) => void, + ): void; + + contract(abi: Web3.AbiDefinition[]): Web3.Contract; + + // TODO block param + getBalance(addressHexString: string): BigNumber.BigNumber; + getBalance(addressHexString: string, callback: (err: Error, result: BigNumber.BigNumber) => void): void; + + // TODO block param + getStorageAt(address: string, position: number): string; + getStorageAt(address: string, position: number, callback: (err: Error, storage: string) => void): void; + + // TODO block param + getCode(addressHexString: string): string; + getCode(addressHexString: string, callback: (err: Error, code: string) => void): void; + + filter(value: string | Web3.FilterObject): Web3.FilterResult; + + sendTransaction(txData: Web3.TxData): string; + sendTransaction(txData: Web3.TxData, callback: (err: Error, value: string) => void): void; + + sendRawTransaction(rawTxData: string): string; + sendRawTransaction(rawTxData: string, callback: (err: Error, value: string) => void): void; + + sign(address: string, data: string): string; + sign(address: string, data: string, callback: (err: Error, signature: string) => void): void; + + getTransactionReceipt(txHash: string): Web3.TransactionReceipt | null; + getTransactionReceipt( + txHash: string, + callback: (err: Error, receipt: Web3.TransactionReceipt | null) => void, + ): void; + + // TODO block param + call(callData: Web3.CallData): string; + call(callData: Web3.CallData, callback: (err: Error, result: string) => void): void; + + estimateGas(callData: Web3.CallData): number; + estimateGas(callData: Web3.CallData, callback: (err: Error, gas: number) => void): void; + + // TODO defaultBlock + getTransactionCount(address: string): number; + getTransactionCount(address: string, callback: (err: Error, count: number) => void): void; + } + + interface VersionApi { + api: string; + network: string; + node: string; + ethereum: string; + whisper: string; + getNetwork(cd: (err: Error, networkId: string) => void): void; + getNode(cd: (err: Error, nodeVersion: string) => void): void; + getEthereum(cd: (err: Error, ethereum: string) => void): void; + getWhisper(cd: (err: Error, whisper: string) => void): void; + } + + interface PersonalApi { + listAccounts: string[] | undefined; + newAccount(password?: string): string; + unlockAccount(address: string, password?: string, duration?: number): boolean; + lockAccount(address: string): boolean; + sign(message: string, account: string, password: string): string; + sign(hexMessage: string, account: string, callback: (error: Error, signature: string) => void): void; + } + + interface NetApi { + listening: boolean; + peerCount: number; + getListening(cd: (err: Error, listening: boolean) => void): void; + getPeerCount(cd: (err: Error, peerCount: number) => void): void; + } + + type BlockParam = number | 'earliest' | 'latest' | 'pending'; + + type Unit = + | 'kwei' + | 'ada' + | 'mwei' + | 'babbage' + | 'gwei' + | 'shannon' + | 'szabo' + | 'finney' + | 'ether' + | 'kether' + | 'grand' + | 'einstein' + | 'mether' + | 'gether' + | 'tether'; + + interface SyncingState { + startingBlock: number; + currentBlock: number; + highestBlock: number; + } + type SyncingResult = false | SyncingState; + + interface IsSyncing { + addCallback(cb: (err: Error, isSyncing: boolean, syncingState: SyncingState) => void): void; + stopWatching(): void; + } + + interface AbstractBlock { + number: number | null; + hash: string | null; + parentHash: string; + nonce: string | null; + sha3Uncles: string; + logsBloom: string | null; + transactionsRoot: string; + stateRoot: string; + miner: string; + difficulty: BigNumber.BigNumber; + totalDifficulty: BigNumber.BigNumber; + extraData: string; + size: number; + gasLimit: number; + gasUsed: number; + timestamp: number; + uncles: string[]; + } + interface BlockWithoutTransactionData extends AbstractBlock { + transactions: string[]; + } + interface BlockWithTransactionData extends AbstractBlock { + transactions: Transaction[]; + } + + interface Transaction { + hash: string; + nonce: number; + blockHash: string | null; + blockNumber: number | null; + transactionIndex: number | null; + from: string; + to: string | null; + value: BigNumber.BigNumber; + gasPrice: BigNumber.BigNumber; + gas: number; + input: string; + } + + interface CallTxDataBase { + to?: string; + value?: number | string | BigNumber.BigNumber; + gas?: number | string | BigNumber.BigNumber; + gasPrice?: number | string | BigNumber.BigNumber; + data?: string; + nonce?: number; + } + + interface TxData extends CallTxDataBase { + from: string; + } + + interface CallData extends CallTxDataBase { + from?: string; + } + + interface TransactionReceipt { + blockHash: string; + blockNumber: number; + transactionHash: string; + transactionIndex: number; + from: string; + to: string; + status: null | string | 0 | 1; + cumulativeGasUsed: number; + gasUsed: number; + contractAddress: string | null; + logs: LogEntry[]; + } + + interface LogEntry { + logIndex: number | null; + transactionIndex: number | null; + transactionHash: string; + blockHash: string | null; + blockNumber: number | null; + address: string; + data: string; + topics: string[]; + } + } + /* tslint:disable */ + export = Web3; + /* tslint:enable */ +} diff --git a/packages/utils/README.md b/packages/utils/README.md index 22de85f4a..fde0780a9 100644 --- a/packages/utils/README.md +++ b/packages/utils/README.md @@ -10,10 +10,10 @@ yarn add @0xproject/utils If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`: -``` -"include": [ - "./node_modules/web3-typescript-typings/index.d.ts", -] +```json +"compilerOptions": { + "typeRoots": ["node_modules/@0xproject/typescript-typings/types", "node_modules/@types"], +} ``` ## Usage diff --git a/packages/utils/package.json b/packages/utils/package.json index ffdd7fe2e..bc869fe1e 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -31,14 +31,13 @@ }, "dependencies": { "@0xproject/types": "^0.4.1", + "@0xproject/typescript-typings": "^0.0.1", "@types/node": "^8.0.53", "bignumber.js": "~4.1.0", "ethers-contracts": "^2.2.1", - "ethers-typescript-typings": "^0.0.4", "js-sha3": "^0.7.0", "lodash": "^4.17.4", - "web3": "^0.20.0", - "web3-typescript-typings": "^0.10.2" + "web3": "^0.20.0" }, "publishConfig": { "access": "public" diff --git a/packages/utils/tsconfig.json b/packages/utils/tsconfig.json index 8114d99cd..c56d255d5 100644 --- a/packages/utils/tsconfig.json +++ b/packages/utils/tsconfig.json @@ -3,9 +3,5 @@ "compilerOptions": { "outDir": "lib" }, - "include": [ - "./src/**/*", - "../../node_modules/web3-typescript-typings/index.d.ts", - "../../node_modules/ethers-typescript-typings/index.d.ts" - ] + "include": ["./src/**/*"] } diff --git a/packages/web3-typescript-typings/.npmignore b/packages/web3-typescript-typings/.npmignore deleted file mode 100644 index 104d718ed..000000000 --- a/packages/web3-typescript-typings/.npmignore +++ /dev/null @@ -1,3 +0,0 @@ -.* -yarn-error.log -/scripts/ diff --git a/packages/web3-typescript-typings/CHANGELOG.md b/packages/web3-typescript-typings/CHANGELOG.md deleted file mode 100644 index 845b1ecd2..000000000 --- a/packages/web3-typescript-typings/CHANGELOG.md +++ /dev/null @@ -1,16 +0,0 @@ -# CHANGELOG - -## v0.10.0 - _March 4, 2018_ - - * Support ABIv2 (#401) - * Add types for transaction traces (#426) - -## v0.9.11 - _February 16, 2018_ - - * Fix `web3.net.peerCount` to be of type number instead of boolean (#397) - -## v0.9.3 - _January 11, 2018_ - - * Fix `getTransactionReceipt` not returning null (#338) - * Add type for getData on a contract - * Fixed the `defaultAccount` not allowing for `undefined` value (#320) diff --git a/packages/web3-typescript-typings/README.md b/packages/web3-typescript-typings/README.md deleted file mode 100644 index 95c193287..000000000 --- a/packages/web3-typescript-typings/README.md +++ /dev/null @@ -1,49 +0,0 @@ -## web3-typescript-typings - -There currently isn't an official [Web3][web3] -type definition included in the [DefinitelyTyped][definitelytyped] project. -Until that happens, we will continue to improve our own type definition. -If it get's close to comprehensive, we'll add it to [DefinitelyTyped][definitelytyped]. - -[web3]: https://github.com/ethereum/web3.js/ -[definitelytyped]: https://github.com/DefinitelyTyped/DefinitelyTyped - -## Installation - -```bash -yarn add -D web3-typescript-typings -``` - -## Usage - -Add the following line within an `include` section of your `tsconfig.json` - -```json -"./node_modules/web3-typescript-typings/index.d.ts" -``` - -## Contributing - -We strongly encourage that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository. - -Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started. - -### Install Dependencies - -If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them: - -```bash -yarn config set workspaces-experimental true -``` - -Then install dependencies - -```bash -yarn install -``` - -### Lint - -```bash -yarn lint -``` diff --git a/packages/web3-typescript-typings/index.d.ts b/packages/web3-typescript-typings/index.d.ts deleted file mode 100644 index cbe067b37..000000000 --- a/packages/web3-typescript-typings/index.d.ts +++ /dev/null @@ -1,440 +0,0 @@ -declare module 'web3' { - import * as BigNumber from 'bignumber.js'; - - type MixedData = string | number | object | any[] | BigNumber.BigNumber; - - class Web3 { - public static providers: typeof providers; - public currentProvider: Web3.Provider; - - public eth: Web3.EthApi; - public personal: Web3.PersonalApi | undefined; - public version: Web3.VersionApi; - public net: Web3.NetApi; - - public constructor(provider?: Web3.Provider); - - public isConnected(): boolean; - public setProvider(provider: Web3.Provider): void; - public reset(keepIsSyncing: boolean): void; - public toHex(data: MixedData): string; - public toAscii(hex: string): string; - public fromAscii(ascii: string, padding?: number): string; - public toDecimal(hex: string): number; - public fromDecimal(value: number | string): string; - public fromWei(value: number | string, unit: Web3.Unit): string; - public fromWei(value: BigNumber.BigNumber, unit: Web3.Unit): BigNumber.BigNumber; - public toWei(amount: number | string, unit: Web3.Unit): string; - public toWei(amount: BigNumber.BigNumber, unit: Web3.Unit): BigNumber.BigNumber; - public toBigNumber(value: number | string): BigNumber.BigNumber; - public isAddress(address: string): boolean; - public isChecksumAddress(address: string): boolean; - public sha3(value: string, options?: Web3.Sha3Options): string; - } - - namespace providers { - class HttpProvider implements Web3.Provider { - constructor(url?: string, timeout?: number, username?: string, password?: string); - public sendAsync( - payload: Web3.JSONRPCRequestPayload, - callback: (err: Error, result: Web3.JSONRPCResponsePayload) => void, - ): void; - } - } - - namespace Web3 { - type ContractAbi = AbiDefinition[]; - - type AbiDefinition = FunctionAbi | EventAbi; - - type FunctionAbi = MethodAbi | ConstructorAbi | FallbackAbi; - - enum AbiType { - Function = 'function', - Constructor = 'constructor', - Event = 'event', - Fallback = 'fallback', - } - - type ConstructorStateMutability = 'nonpayable' | 'payable'; - type StateMutability = 'pure' | 'view' | ConstructorStateMutability; - - interface MethodAbi { - type: AbiType.Function; - name: string; - inputs: DataItem[]; - outputs: DataItem[]; - constant: boolean; - stateMutability: StateMutability; - payable: boolean; - } - - interface ConstructorAbi { - type: AbiType.Constructor; - inputs: DataItem[]; - payable: boolean; - stateMutability: ConstructorStateMutability; - } - - interface FallbackAbi { - type: AbiType.Fallback; - payable: boolean; - } - - interface EventParameter extends DataItem { - indexed: boolean; - } - - interface EventAbi { - type: AbiType.Event; - name: string; - inputs: EventParameter[]; - anonymous: boolean; - } - - interface DataItem { - name: string; - type: string; - components: DataItem[]; - } - - interface ContractInstance { - address: string; - abi: Web3.ContractAbi; - [name: string]: any; - } - - interface Contract { - at(address: string): A; - getData(...args: any[]): string; - 'new'(...args: any[]): A; - } - - interface FilterObject { - fromBlock?: number | string; - toBlock?: number | string; - address?: string; - topics?: LogTopic[]; - } - - type LogTopic = null | string | string[]; - - interface DecodedLogEntry extends LogEntry { - event: string; - args: A; - } - - interface DecodedLogEntryEvent extends DecodedLogEntry { - removed: boolean; - } - - interface LogEntryEvent extends LogEntry { - removed: boolean; - } - - interface FilterResult { - get(callback: () => void): void; - watch(callback: (err: Error, result: LogEntryEvent) => void): void; - stopWatching(callback?: () => void): void; - } - - export interface JSONRPCRequestPayload { - params: any[]; - method: string; - id: number; - jsonrpc: string; - } - - export interface JSONRPCResponsePayload { - result: any; - id: number; - jsonrpc: string; - } - - export type OpCode = string; - - export interface StructLog { - depth: number; - error: string; - gas: number; - gasCost: number; - memory: string[]; - op: OpCode; - pc: number; - stack: string[]; - storage: { [location: string]: string }; - } - export interface TransactionTrace { - gas: number; - returnValue: any; - structLogs: StructLog[]; - } - - interface Provider { - sendAsync( - payload: JSONRPCRequestPayload, - callback: (err: Error, result: JSONRPCResponsePayload) => void, - ): void; - } - - interface Sha3Options { - encoding: 'hex'; - } - - interface EthApi { - coinbase: string; - mining: boolean; - hashrate: number; - gasPrice: BigNumber.BigNumber; - accounts: string[]; - blockNumber: number; - defaultAccount?: string; - defaultBlock: Web3.BlockParam; - syncing: Web3.SyncingResult; - compile: { - solidity(sourceString: string, cb?: (err: Error, result: any) => void): object; - }; - getMining(cd: (err: Error, mining: boolean) => void): void; - getHashrate(cd: (err: Error, hashrate: number) => void): void; - getGasPrice(cd: (err: Error, gasPrice: BigNumber.BigNumber) => void): void; - getAccounts(cd: (err: Error, accounts: string[]) => void): void; - getBlockNumber(callback: (err: Error, blockNumber: number) => void): void; - getSyncing(cd: (err: Error, syncing: Web3.SyncingResult) => void): void; - isSyncing(cb: (err: Error, isSyncing: boolean, syncingState: Web3.SyncingState) => void): Web3.IsSyncing; - - getBlock(hashStringOrBlockNumber: string | Web3.BlockParam): Web3.BlockWithoutTransactionData; - getBlock( - hashStringOrBlockNumber: string | Web3.BlockParam, - callback: (err: Error, blockObj: Web3.BlockWithoutTransactionData) => void, - ): void; - getBlock( - hashStringOrBlockNumber: string | Web3.BlockParam, - returnTransactionObjects: true, - ): Web3.BlockWithTransactionData; - getBlock( - hashStringOrBlockNumber: string | Web3.BlockParam, - returnTransactionObjects: true, - callback: (err: Error, blockObj: Web3.BlockWithTransactionData) => void, - ): void; - - getBlockTransactionCount(hashStringOrBlockNumber: string | Web3.BlockParam): number; - getBlockTransactionCount( - hashStringOrBlockNumber: string | Web3.BlockParam, - callback: (err: Error, blockTransactionCount: number) => void, - ): void; - - // TODO returnTransactionObjects - getUncle( - hashStringOrBlockNumber: string | Web3.BlockParam, - uncleNumber: number, - ): Web3.BlockWithoutTransactionData; - getUncle( - hashStringOrBlockNumber: string | Web3.BlockParam, - uncleNumber: number, - callback: (err: Error, uncle: Web3.BlockWithoutTransactionData) => void, - ): void; - - getTransaction(transactionHash: string): Web3.Transaction; - getTransaction( - transactionHash: string, - callback: (err: Error, transaction: Web3.Transaction) => void, - ): void; - - getTransactionFromBlock( - hashStringOrBlockNumber: string | Web3.BlockParam, - indexNumber: number, - ): Web3.Transaction; - getTransactionFromBlock( - hashStringOrBlockNumber: string | Web3.BlockParam, - indexNumber: number, - callback: (err: Error, transaction: Web3.Transaction) => void, - ): void; - - contract(abi: Web3.AbiDefinition[]): Web3.Contract; - - // TODO block param - getBalance(addressHexString: string): BigNumber.BigNumber; - getBalance(addressHexString: string, callback: (err: Error, result: BigNumber.BigNumber) => void): void; - - // TODO block param - getStorageAt(address: string, position: number): string; - getStorageAt(address: string, position: number, callback: (err: Error, storage: string) => void): void; - - // TODO block param - getCode(addressHexString: string): string; - getCode(addressHexString: string, callback: (err: Error, code: string) => void): void; - - filter(value: string | Web3.FilterObject): Web3.FilterResult; - - sendTransaction(txData: Web3.TxData): string; - sendTransaction(txData: Web3.TxData, callback: (err: Error, value: string) => void): void; - - sendRawTransaction(rawTxData: string): string; - sendRawTransaction(rawTxData: string, callback: (err: Error, value: string) => void): void; - - sign(address: string, data: string): string; - sign(address: string, data: string, callback: (err: Error, signature: string) => void): void; - - getTransactionReceipt(txHash: string): Web3.TransactionReceipt | null; - getTransactionReceipt( - txHash: string, - callback: (err: Error, receipt: Web3.TransactionReceipt | null) => void, - ): void; - - // TODO block param - call(callData: Web3.CallData): string; - call(callData: Web3.CallData, callback: (err: Error, result: string) => void): void; - - estimateGas(callData: Web3.CallData): number; - estimateGas(callData: Web3.CallData, callback: (err: Error, gas: number) => void): void; - - // TODO defaultBlock - getTransactionCount(address: string): number; - getTransactionCount(address: string, callback: (err: Error, count: number) => void): void; - } - - interface VersionApi { - api: string; - network: string; - node: string; - ethereum: string; - whisper: string; - getNetwork(cd: (err: Error, networkId: string) => void): void; - getNode(cd: (err: Error, nodeVersion: string) => void): void; - getEthereum(cd: (err: Error, ethereum: string) => void): void; - getWhisper(cd: (err: Error, whisper: string) => void): void; - } - - interface PersonalApi { - listAccounts: string[] | undefined; - newAccount(password?: string): string; - unlockAccount(address: string, password?: string, duration?: number): boolean; - lockAccount(address: string): boolean; - sign(message: string, account: string, password: string): string; - sign(hexMessage: string, account: string, callback: (error: Error, signature: string) => void): void; - } - - interface NetApi { - listening: boolean; - peerCount: number; - getListening(cd: (err: Error, listening: boolean) => void): void; - getPeerCount(cd: (err: Error, peerCount: number) => void): void; - } - - type BlockParam = number | 'earliest' | 'latest' | 'pending'; - - type Unit = - | 'kwei' - | 'ada' - | 'mwei' - | 'babbage' - | 'gwei' - | 'shannon' - | 'szabo' - | 'finney' - | 'ether' - | 'kether' - | 'grand' - | 'einstein' - | 'mether' - | 'gether' - | 'tether'; - - interface SyncingState { - startingBlock: number; - currentBlock: number; - highestBlock: number; - } - type SyncingResult = false | SyncingState; - - interface IsSyncing { - addCallback(cb: (err: Error, isSyncing: boolean, syncingState: SyncingState) => void): void; - stopWatching(): void; - } - - interface AbstractBlock { - number: number | null; - hash: string | null; - parentHash: string; - nonce: string | null; - sha3Uncles: string; - logsBloom: string | null; - transactionsRoot: string; - stateRoot: string; - miner: string; - difficulty: BigNumber.BigNumber; - totalDifficulty: BigNumber.BigNumber; - extraData: string; - size: number; - gasLimit: number; - gasUsed: number; - timestamp: number; - uncles: string[]; - } - interface BlockWithoutTransactionData extends AbstractBlock { - transactions: string[]; - } - interface BlockWithTransactionData extends AbstractBlock { - transactions: Transaction[]; - } - - interface Transaction { - hash: string; - nonce: number; - blockHash: string | null; - blockNumber: number | null; - transactionIndex: number | null; - from: string; - to: string | null; - value: BigNumber.BigNumber; - gasPrice: BigNumber.BigNumber; - gas: number; - input: string; - } - - interface CallTxDataBase { - to?: string; - value?: number | string | BigNumber.BigNumber; - gas?: number | string | BigNumber.BigNumber; - gasPrice?: number | string | BigNumber.BigNumber; - data?: string; - nonce?: number; - } - - interface TxData extends CallTxDataBase { - from: string; - } - - interface CallData extends CallTxDataBase { - from?: string; - } - - interface TransactionReceipt { - blockHash: string; - blockNumber: number; - transactionHash: string; - transactionIndex: number; - from: string; - to: string; - status: null | string | 0 | 1; - cumulativeGasUsed: number; - gasUsed: number; - contractAddress: string | null; - logs: LogEntry[]; - } - - interface LogEntry { - logIndex: number | null; - transactionIndex: number | null; - transactionHash: string; - blockHash: string | null; - blockNumber: number | null; - address: string; - data: string; - topics: string[]; - } - } - /* tslint:disable */ - export = Web3; - /* tslint:enable */ -} diff --git a/packages/web3-typescript-typings/monorepo_scripts/globals.d.ts b/packages/web3-typescript-typings/monorepo_scripts/globals.d.ts deleted file mode 100644 index 94e63a32d..000000000 --- a/packages/web3-typescript-typings/monorepo_scripts/globals.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -declare module '*.json' { - const json: any; - /* tslint:disable */ - export default json; - /* tslint:enable */ -} diff --git a/packages/web3-typescript-typings/monorepo_scripts/postpublish.ts b/packages/web3-typescript-typings/monorepo_scripts/postpublish.ts deleted file mode 100644 index dcb99d0f7..000000000 --- a/packages/web3-typescript-typings/monorepo_scripts/postpublish.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { postpublishUtils } from '@0xproject/monorepo-scripts'; - -import * as packageJSON from '../package.json'; -import * as tsConfigJSON from '../tsconfig.json'; - -const cwd = `${__dirname}/..`; -// tslint:disable-next-line:no-floating-promises -postpublishUtils.runAsync(packageJSON, tsConfigJSON, cwd); diff --git a/packages/web3-typescript-typings/package.json b/packages/web3-typescript-typings/package.json deleted file mode 100644 index d56b83421..000000000 --- a/packages/web3-typescript-typings/package.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "name": "web3-typescript-typings", - "version": "0.10.2", - "description": "Typescript type definitions for web3", - "main": "index.d.ts", - "types": "index.d.ts", - "scripts": { - "lint": "tslint index.d.ts", - "build": "tsc && copyfiles -u 1 './lib/**/*' ./scripts", - "clean": "shx rm -rf scripts" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/0xProject/0x-monorepo.git" - }, - "author": "Fabio Berger", - "contributors": [ - "Leonid Logvinov " - ], - "license": "Apache-2.0", - "bugs": { - "url": "https://github.com/0xProject/0x-monorepo/issues" - }, - "homepage": "https://github.com/0xProject/0x-monorepo/packages/web3-typescript-typings#readme", - "devDependencies": { - "@0xproject/monorepo-scripts": "^0.1.14", - "@types/bignumber.js": "^4.0.2", - "copyfiles": "^1.2.0", - "shx": "^0.2.2", - "tslint": "5.8.0", - "tslint-config-0xproject": "^0.0.2", - "typescript": "2.7.1" - }, - "dependencies": { - "bignumber.js": "~4.1.0" - }, - "publishConfig": { - "access": "public" - } -} diff --git a/packages/web3-typescript-typings/tsconfig.json b/packages/web3-typescript-typings/tsconfig.json deleted file mode 100644 index bc453af4b..000000000 --- a/packages/web3-typescript-typings/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "../../tsconfig", - "compilerOptions": { - "outDir": "lib" - }, - "include": ["./monorepo_scripts/**/*"] -} diff --git a/packages/web3-typescript-typings/tslint.json b/packages/web3-typescript-typings/tslint.json deleted file mode 100644 index 9a93a1f74..000000000 --- a/packages/web3-typescript-typings/tslint.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": ["tslint-config-0xproject"] -} diff --git a/packages/web3-wrapper/README.md b/packages/web3-wrapper/README.md index 1fed11407..e7491acb0 100644 --- a/packages/web3-wrapper/README.md +++ b/packages/web3-wrapper/README.md @@ -12,10 +12,10 @@ yarn add @0xproject/web3-wrapper If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`: -``` -"include": [ - "./node_modules/web3-typescript-typings/index.d.ts", -] +```json +"compilerOptions": { + "typeRoots": ["node_modules/@0xproject/typescript-typings/types", "node_modules/@types"], +} ``` ## Contributing diff --git a/packages/web3-wrapper/package.json b/packages/web3-wrapper/package.json index 176f796c8..fa79fa377 100644 --- a/packages/web3-wrapper/package.json +++ b/packages/web3-wrapper/package.json @@ -45,11 +45,10 @@ "dependencies": { "@0xproject/types": "^0.4.1", "@0xproject/utils": "^0.4.3", + "@0xproject/typescript-typings": "^0.0.1", "ethers-contracts": "^2.2.1", - "ethers-typescript-typings": "^0.0.4", "lodash": "^4.17.4", - "web3": "^0.20.0", - "web3-typescript-typings": "^0.10.2" + "web3": "^0.20.0" }, "publishConfig": { "access": "public" diff --git a/packages/web3-wrapper/tsconfig.json b/packages/web3-wrapper/tsconfig.json index 7bae7f9f0..c56d255d5 100644 --- a/packages/web3-wrapper/tsconfig.json +++ b/packages/web3-wrapper/tsconfig.json @@ -3,9 +3,5 @@ "compilerOptions": { "outDir": "lib" }, - "include": [ - "./src/**/*", - "../../node_modules/ethers-typescript-typings/index.d.ts", - "../../node_modules/web3-typescript-typings/index.d.ts" - ] + "include": ["./src/**/*"] } diff --git a/packages/website/package.json b/packages/website/package.json index c455306ee..3869fb040 100644 --- a/packages/website/package.json +++ b/packages/website/package.json @@ -24,6 +24,7 @@ "@0xproject/subproviders": "^0.8.2", "@0xproject/utils": "^0.4.3", "@0xproject/web3-wrapper": "^0.3.1", + "@0xproject/typescript-typings": "^0.0.1", "accounting": "^0.4.1", "basscss": "^8.0.3", "blockies": "^0.0.2", @@ -75,9 +76,9 @@ "@types/moment": "^2.13.0", "@types/node": "^8.0.53", "@types/query-string": "^5.0.1", - "@types/react": "^15.0.15", + "@types/react": "^16.0.34", "@types/react-copy-to-clipboard": "^4.2.0", - "@types/react-dom": "^0.14.23", + "@types/react-dom": "^16.0.3", "@types/react-redux": "^4.4.37", "@types/react-router-dom": "^4.0.4", "@types/react-scroll": "0.0.31", @@ -87,7 +88,6 @@ "copy-webpack-plugin": "^4.0.1", "copyfiles": "^1.2.0", "css-loader": "0.23.x", - "ethers-typescript-typings": "^0.0.4", "exports-loader": "0.6.x", "imports-loader": "0.6.x", "json-loader": "^0.5.4", @@ -99,7 +99,6 @@ "tslint": "5.8.0", "tslint-config-0xproject": "^0.0.2", "typescript": "2.7.1", - "web3-typescript-typings": "^0.10.2", "webpack": "^3.1.0", "webpack-dev-middleware": "^1.10.0", "webpack-dev-server": "^2.5.0" diff --git a/packages/website/ts/components/dialogs/eth_weth_conversion_dialog.tsx b/packages/website/ts/components/dialogs/eth_weth_conversion_dialog.tsx index d1bdb447f..42ca1713d 100644 --- a/packages/website/ts/components/dialogs/eth_weth_conversion_dialog.tsx +++ b/packages/website/ts/components/dialogs/eth_weth_conversion_dialog.tsx @@ -37,8 +37,8 @@ export class EthWethConversionDialog extends React.Component< EthWethConversionDialogState > { private _isUnmounted: boolean; - constructor() { - super(); + constructor(props: EthWethConversionDialogProps) { + super(props); this._isUnmounted = false; this.state = { shouldShowIncompleteErrs: false, diff --git a/packages/website/ts/components/dialogs/send_dialog.tsx b/packages/website/ts/components/dialogs/send_dialog.tsx index d44dd9aab..2af7fd7ac 100644 --- a/packages/website/ts/components/dialogs/send_dialog.tsx +++ b/packages/website/ts/components/dialogs/send_dialog.tsx @@ -27,8 +27,8 @@ interface SendDialogState { } export class SendDialog extends React.Component { - constructor() { - super(); + constructor(props: SendDialogProps) { + super(props); this.state = { recipient: '', shouldShowIncompleteErrs: false, diff --git a/packages/website/ts/components/footer.tsx b/packages/website/ts/components/footer.tsx index 957ed2044..6c0186ac0 100644 --- a/packages/website/ts/components/footer.tsx +++ b/packages/website/ts/components/footer.tsx @@ -45,7 +45,7 @@ interface FooterState { export class Footer extends React.Component { constructor(props: FooterProps) { - super(); + super(props); this.state = { selectedLanguage: props.translate.getLanguage(), }; diff --git a/packages/website/tsconfig.json b/packages/website/tsconfig.json index 99f465bc2..34171b51e 100644 --- a/packages/website/tsconfig.json +++ b/packages/website/tsconfig.json @@ -13,9 +13,5 @@ "*": ["node_modules/@types/*", "*"] } }, - "include": [ - "./ts/**/*", - "../../node_modules/web3-typescript-typings/index.d.ts", - "../../node_modules/ethers-typescript-typings/index.d.ts" - ] + "include": ["./ts/**/*"] } -- cgit v1.2.3 From ec06d8d6067488b53183db392b4da91be0cc219e Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 27 Mar 2018 15:05:05 +0200 Subject: Add typeRoots --- packages/monorepo-scripts/src/test_installation.ts | 1 + 1 file changed, 1 insertion(+) (limited to 'packages') diff --git a/packages/monorepo-scripts/src/test_installation.ts b/packages/monorepo-scripts/src/test_installation.ts index 116b70f3a..195b64b2a 100644 --- a/packages/monorepo-scripts/src/test_installation.ts +++ b/packages/monorepo-scripts/src/test_installation.ts @@ -34,6 +34,7 @@ import { utils } from './utils'; fs.writeFileSync(indexFilePath, `import * as Package from '${packageName}'`); const tsConfig = { compilerOptions: { + typeRoots: ['node_modules/@0xproject/typescript-typings/types', 'node_modules/@types'], module: 'commonjs', target: 'es5', lib: ['es2017', 'dom'], -- cgit v1.2.3