Replace lodash with built-ins where possible to reduce bundle size (#1766)
* add tslint rule to disallow lodash.isUndefined * add tslint rule to disallow lodash.isNull * apply fixes
This commit is contained in:
parent
49d951b7be
commit
7423028fea
@ -24,6 +24,7 @@
|
||||
"clean": "shx rm -rf lib generated-artifacts generated-wrappers",
|
||||
"generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --template ../../node_modules/@0x/abi-gen-templates/contract.handlebars --partials '../../node_modules/@0x/abi-gen-templates/partials/**/*.handlebars' --output generated-wrappers --backend ethers",
|
||||
"lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
||||
"fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
||||
"coverage:report:text": "istanbul report text",
|
||||
"coverage:report:html": "istanbul report html && open coverage/index.html",
|
||||
"profiler:report:html": "istanbul report html && open coverage/index.html",
|
||||
|
@ -115,7 +115,7 @@ export class ERC1155ProxyWrapper {
|
||||
valuesToTransfer,
|
||||
receiverCallbackData,
|
||||
);
|
||||
if (!_.isUndefined(extraData)) {
|
||||
if (extraData !== undefined) {
|
||||
encodedAssetData = `${encodedAssetData}${extraData}`;
|
||||
}
|
||||
const data = this._assetProxyInterface.transferFrom.getABIEncodedTransactionData(
|
||||
@ -199,10 +199,10 @@ export class ERC1155ProxyWrapper {
|
||||
// Mint tokens for each owner for this token
|
||||
for (const tokenOwnerAddress of this._tokenOwnerAddresses) {
|
||||
// tslint:disable-next-line:no-unused-variable
|
||||
if (_.isUndefined(fungibleHoldingsByOwner[tokenOwnerAddress])) {
|
||||
if (fungibleHoldingsByOwner[tokenOwnerAddress] === undefined) {
|
||||
fungibleHoldingsByOwner[tokenOwnerAddress] = {};
|
||||
}
|
||||
if (_.isUndefined(fungibleHoldingsByOwner[tokenOwnerAddress][dummyAddress])) {
|
||||
if (fungibleHoldingsByOwner[tokenOwnerAddress][dummyAddress] === undefined) {
|
||||
fungibleHoldingsByOwner[tokenOwnerAddress][dummyAddress] = {};
|
||||
}
|
||||
fungibleHoldingsByOwner[tokenOwnerAddress][dummyAddress][tokenIdAsString] =
|
||||
@ -221,13 +221,13 @@ export class ERC1155ProxyWrapper {
|
||||
const tokenIdAsString = tokenId.toString();
|
||||
this._nonFungibleTokenIds.push(tokenIdAsString);
|
||||
_.each(this._tokenOwnerAddresses, async (tokenOwnerAddress: string, i: number) => {
|
||||
if (_.isUndefined(nonFungibleHoldingsByOwner[tokenOwnerAddress])) {
|
||||
if (nonFungibleHoldingsByOwner[tokenOwnerAddress] === undefined) {
|
||||
nonFungibleHoldingsByOwner[tokenOwnerAddress] = {};
|
||||
}
|
||||
if (_.isUndefined(nonFungibleHoldingsByOwner[tokenOwnerAddress][dummyAddress])) {
|
||||
if (nonFungibleHoldingsByOwner[tokenOwnerAddress][dummyAddress] === undefined) {
|
||||
nonFungibleHoldingsByOwner[tokenOwnerAddress][dummyAddress] = {};
|
||||
}
|
||||
if (_.isUndefined(nonFungibleHoldingsByOwner[tokenOwnerAddress][dummyAddress][tokenIdAsString])) {
|
||||
if (nonFungibleHoldingsByOwner[tokenOwnerAddress][dummyAddress][tokenIdAsString] === undefined) {
|
||||
nonFungibleHoldingsByOwner[tokenOwnerAddress][dummyAddress][tokenIdAsString] = [];
|
||||
}
|
||||
this._nfts.push({ id: nftIds[i], tokenId });
|
||||
@ -278,26 +278,25 @@ export class ERC1155ProxyWrapper {
|
||||
for (const tokenOwnerAddress of this._tokenOwnerAddresses) {
|
||||
// Fungible tokens
|
||||
for (const tokenId of this._fungibleTokenIds) {
|
||||
if (_.isUndefined(tokenHoldingsByOwner[tokenOwnerAddress])) {
|
||||
if (tokenHoldingsByOwner[tokenOwnerAddress] === undefined) {
|
||||
tokenHoldingsByOwner[tokenOwnerAddress] = {};
|
||||
}
|
||||
if (_.isUndefined(tokenHoldingsByOwner[tokenOwnerAddress][tokenAddress])) {
|
||||
if (tokenHoldingsByOwner[tokenOwnerAddress][tokenAddress] === undefined) {
|
||||
tokenHoldingsByOwner[tokenOwnerAddress][tokenAddress] = {};
|
||||
}
|
||||
tokenHoldingsByOwner[tokenOwnerAddress][tokenAddress][tokenId] = balances[i++];
|
||||
}
|
||||
// Non-fungible tokens
|
||||
for (const nft of this._nfts) {
|
||||
if (_.isUndefined(nonFungibleHoldingsByOwner[tokenOwnerAddress])) {
|
||||
if (nonFungibleHoldingsByOwner[tokenOwnerAddress] === undefined) {
|
||||
nonFungibleHoldingsByOwner[tokenOwnerAddress] = {};
|
||||
}
|
||||
if (_.isUndefined(nonFungibleHoldingsByOwner[tokenOwnerAddress][tokenAddress])) {
|
||||
if (nonFungibleHoldingsByOwner[tokenOwnerAddress][tokenAddress] === undefined) {
|
||||
nonFungibleHoldingsByOwner[tokenOwnerAddress][tokenAddress] = {};
|
||||
}
|
||||
if (
|
||||
_.isUndefined(
|
||||
nonFungibleHoldingsByOwner[tokenOwnerAddress][tokenAddress][nft.tokenId.toString()],
|
||||
)
|
||||
nonFungibleHoldingsByOwner[tokenOwnerAddress][tokenAddress][nft.tokenId.toString()] ===
|
||||
undefined
|
||||
) {
|
||||
nonFungibleHoldingsByOwner[tokenOwnerAddress][tokenAddress][nft.tokenId.toString()] = [];
|
||||
}
|
||||
@ -348,25 +347,25 @@ export class ERC1155ProxyWrapper {
|
||||
const tokenWrapper = _.find(this._dummyTokenWrappers, (wrapper: Erc1155Wrapper) => {
|
||||
return wrapper.getContract().address === contractAddress;
|
||||
});
|
||||
if (_.isUndefined(tokenWrapper)) {
|
||||
if (tokenWrapper === undefined) {
|
||||
throw new Error(`Contract: ${contractAddress} was not deployed through ERC1155ProxyWrapper`);
|
||||
}
|
||||
return tokenWrapper;
|
||||
}
|
||||
private _getContractFromAddress(tokenAddress: string): ERC1155MintableContract {
|
||||
const tokenContractIfExists = _.find(this._dummyTokenWrappers, c => c.getContract().address === tokenAddress);
|
||||
if (_.isUndefined(tokenContractIfExists)) {
|
||||
if (tokenContractIfExists === undefined) {
|
||||
throw new Error(`Token: ${tokenAddress} was not deployed through ERC1155ProxyWrapper`);
|
||||
}
|
||||
return tokenContractIfExists.getContract();
|
||||
}
|
||||
private _validateDummyTokenContractsExistOrThrow(): void {
|
||||
if (_.isUndefined(this._dummyTokenWrappers)) {
|
||||
if (this._dummyTokenWrappers === undefined) {
|
||||
throw new Error('Dummy ERC1155 tokens not yet deployed, please call "deployDummyTokensAsync"');
|
||||
}
|
||||
}
|
||||
private _validateProxyContractExistsOrThrow(): void {
|
||||
if (_.isUndefined(this._proxyContract)) {
|
||||
if (this._proxyContract === undefined) {
|
||||
throw new Error('ERC1155 proxy contract not yet deployed, please call "deployProxyAsync"');
|
||||
}
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ export class ERC20Wrapper {
|
||||
_.forEach(balances, (balance, balanceIndex) => {
|
||||
const tokenAddress = balanceInfo[balanceIndex].tokenAddress;
|
||||
const tokenOwnerAddress = balanceInfo[balanceIndex].tokenOwnerAddress;
|
||||
if (_.isUndefined(balancesByOwner[tokenOwnerAddress])) {
|
||||
if (balancesByOwner[tokenOwnerAddress] === undefined) {
|
||||
balancesByOwner[tokenOwnerAddress] = {};
|
||||
}
|
||||
const wrappedBalance = new BigNumber(balance);
|
||||
@ -142,7 +142,7 @@ export class ERC20Wrapper {
|
||||
return balancesByOwner;
|
||||
}
|
||||
public addDummyTokenContract(dummy: DummyERC20TokenContract): void {
|
||||
if (!_.isUndefined(this._dummyTokenContracts)) {
|
||||
if (this._dummyTokenContracts !== undefined) {
|
||||
this._dummyTokenContracts.push(dummy);
|
||||
}
|
||||
}
|
||||
@ -160,18 +160,18 @@ export class ERC20Wrapper {
|
||||
const erc20ProxyData = assetDataUtils.decodeERC20AssetData(assetData);
|
||||
const tokenAddress = erc20ProxyData.tokenAddress;
|
||||
const tokenContractIfExists = _.find(this._dummyTokenContracts, c => c.address === tokenAddress);
|
||||
if (_.isUndefined(tokenContractIfExists)) {
|
||||
if (tokenContractIfExists === undefined) {
|
||||
throw new Error(`Token: ${tokenAddress} was not deployed through ERC20Wrapper`);
|
||||
}
|
||||
return tokenContractIfExists;
|
||||
}
|
||||
private _validateDummyTokenContractsExistOrThrow(): void {
|
||||
if (_.isUndefined(this._dummyTokenContracts)) {
|
||||
if (this._dummyTokenContracts === undefined) {
|
||||
throw new Error('Dummy ERC20 tokens not yet deployed, please call "deployDummyTokensAsync"');
|
||||
}
|
||||
}
|
||||
private _validateProxyContractExistsOrThrow(): void {
|
||||
if (_.isUndefined(this._proxyContract)) {
|
||||
if (this._proxyContract === undefined) {
|
||||
throw new Error('ERC20 proxy contract not yet deployed, please call "deployProxyAsync"');
|
||||
}
|
||||
}
|
||||
|
@ -62,12 +62,12 @@ export class ERC721Wrapper {
|
||||
for (const i of _.times(constants.NUM_ERC721_TOKENS_TO_MINT)) {
|
||||
const tokenId = generatePseudoRandomSalt();
|
||||
await this.mintAsync(dummyTokenContract.address, tokenId, tokenOwnerAddress);
|
||||
if (_.isUndefined(this._initialTokenIdsByOwner[tokenOwnerAddress])) {
|
||||
if (this._initialTokenIdsByOwner[tokenOwnerAddress] === undefined) {
|
||||
this._initialTokenIdsByOwner[tokenOwnerAddress] = {
|
||||
[dummyTokenContract.address]: [],
|
||||
};
|
||||
}
|
||||
if (_.isUndefined(this._initialTokenIdsByOwner[tokenOwnerAddress][dummyTokenContract.address])) {
|
||||
if (this._initialTokenIdsByOwner[tokenOwnerAddress][dummyTokenContract.address] === undefined) {
|
||||
this._initialTokenIdsByOwner[tokenOwnerAddress][dummyTokenContract.address] = [];
|
||||
}
|
||||
this._initialTokenIdsByOwner[tokenOwnerAddress][dummyTokenContract.address].push(tokenId);
|
||||
@ -189,12 +189,12 @@ export class ERC721Wrapper {
|
||||
_.forEach(tokenOwnerAddresses, (tokenOwnerAddress, ownerIndex) => {
|
||||
const tokenAddress = tokenInfo[ownerIndex].tokenAddress;
|
||||
const tokenId = tokenInfo[ownerIndex].tokenId;
|
||||
if (_.isUndefined(tokenIdsByOwner[tokenOwnerAddress])) {
|
||||
if (tokenIdsByOwner[tokenOwnerAddress] === undefined) {
|
||||
tokenIdsByOwner[tokenOwnerAddress] = {
|
||||
[tokenAddress]: [],
|
||||
};
|
||||
}
|
||||
if (_.isUndefined(tokenIdsByOwner[tokenOwnerAddress][tokenAddress])) {
|
||||
if (tokenIdsByOwner[tokenOwnerAddress][tokenAddress] === undefined) {
|
||||
tokenIdsByOwner[tokenOwnerAddress][tokenAddress] = [];
|
||||
}
|
||||
tokenIdsByOwner[tokenOwnerAddress][tokenAddress].push(tokenId);
|
||||
@ -210,18 +210,18 @@ export class ERC721Wrapper {
|
||||
}
|
||||
private _getTokenContractFromAssetData(tokenAddress: string): DummyERC721TokenContract {
|
||||
const tokenContractIfExists = _.find(this._dummyTokenContracts, c => c.address === tokenAddress);
|
||||
if (_.isUndefined(tokenContractIfExists)) {
|
||||
if (tokenContractIfExists === undefined) {
|
||||
throw new Error(`Token: ${tokenAddress} was not deployed through ERC20Wrapper`);
|
||||
}
|
||||
return tokenContractIfExists;
|
||||
}
|
||||
private _validateDummyTokenContractsExistOrThrow(): void {
|
||||
if (_.isUndefined(this._dummyTokenContracts)) {
|
||||
if (this._dummyTokenContracts === undefined) {
|
||||
throw new Error('Dummy ERC721 tokens not yet deployed, please call "deployDummyTokensAsync"');
|
||||
}
|
||||
}
|
||||
private _validateProxyContractExistsOrThrow(): void {
|
||||
if (_.isUndefined(this._proxyContract)) {
|
||||
if (this._proxyContract === undefined) {
|
||||
throw new Error('ERC721 proxy contract not yet deployed, please call "deployProxyAsync"');
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,7 @@
|
||||
"clean": "shx rm -rf lib generated-artifacts generated-wrappers",
|
||||
"generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --template ../../node_modules/@0x/abi-gen-templates/contract.handlebars --partials '../../node_modules/@0x/abi-gen-templates/partials/**/*.handlebars' --output generated-wrappers --backend ethers",
|
||||
"lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
||||
"fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
||||
"coverage:report:text": "istanbul report text",
|
||||
"coverage:report:html": "istanbul report html && open coverage/index.html",
|
||||
"profiler:report:html": "istanbul report html && open coverage/index.html",
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { LogDecoder, txDefaults } from '@0x/contracts-test-utils';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import { TransactionReceiptWithDecodedLogs, ZeroExProvider } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { artifacts, CoordinatorRegistryContract } from '../../src';
|
||||
|
||||
@ -26,7 +25,7 @@ export class CoordinatorRegistryWrapper {
|
||||
this._provider,
|
||||
txDefaults,
|
||||
);
|
||||
if (_.isUndefined(this._coordinatorRegistryContract)) {
|
||||
if (this._coordinatorRegistryContract === undefined) {
|
||||
throw new Error(`Failed to deploy Coordinator Registry contract.`);
|
||||
}
|
||||
return this._coordinatorRegistryContract;
|
||||
@ -56,7 +55,7 @@ export class CoordinatorRegistryWrapper {
|
||||
return coordinatorEndpoint;
|
||||
}
|
||||
private _assertCoordinatorRegistryDeployed(): void {
|
||||
if (_.isUndefined(this._coordinatorRegistryContract)) {
|
||||
if (this._coordinatorRegistryContract === undefined) {
|
||||
throw new Error(
|
||||
'The Coordinator Registry contract was not deployed through the CoordinatorRegistryWrapper. Call `deployCoordinatorRegistryAsync` to deploy.',
|
||||
);
|
||||
|
@ -24,6 +24,7 @@
|
||||
"clean": "shx rm -rf lib generated-artifacts generated-wrappers",
|
||||
"generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --template ../../node_modules/@0x/abi-gen-templates/contract.handlebars --partials '../../node_modules/@0x/abi-gen-templates/partials/**/*.handlebars' --output generated-wrappers --backend ethers",
|
||||
"lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
||||
"fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
||||
"coverage:report:text": "istanbul report text",
|
||||
"coverage:report:html": "istanbul report html && open coverage/index.html",
|
||||
"profiler:report:html": "istanbul report html && open coverage/index.html",
|
||||
|
@ -36,8 +36,8 @@ export class Erc1155Wrapper {
|
||||
callbackData?: string,
|
||||
delegatedSpender?: string,
|
||||
): Promise<TransactionReceiptWithDecodedLogs> {
|
||||
const spender = _.isUndefined(delegatedSpender) ? from : delegatedSpender;
|
||||
const callbackDataHex = _.isUndefined(callbackData) ? '0x' : callbackData;
|
||||
const spender = delegatedSpender === undefined ? from : delegatedSpender;
|
||||
const callbackDataHex = callbackData === undefined ? '0x' : callbackData;
|
||||
const tx = await this._logDecoder.getTxWithDecodedLogsAsync(
|
||||
await this._erc1155Contract.safeTransferFrom.sendTransactionAsync(from, to, token, value, callbackDataHex, {
|
||||
from: spender,
|
||||
@ -53,8 +53,8 @@ export class Erc1155Wrapper {
|
||||
callbackData?: string,
|
||||
delegatedSpender?: string,
|
||||
): Promise<TransactionReceiptWithDecodedLogs> {
|
||||
const spender = _.isUndefined(delegatedSpender) ? from : delegatedSpender;
|
||||
const callbackDataHex = _.isUndefined(callbackData) ? '0x' : callbackData;
|
||||
const spender = delegatedSpender === undefined ? from : delegatedSpender;
|
||||
const callbackDataHex = callbackData === undefined ? '0x' : callbackData;
|
||||
const tx = await this._logDecoder.getTxWithDecodedLogsAsync(
|
||||
await this._erc1155Contract.safeBatchTransferFrom.sendTransactionAsync(
|
||||
from,
|
||||
|
@ -24,6 +24,7 @@
|
||||
"clean": "shx rm -rf lib generated-artifacts generated-wrappers",
|
||||
"generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --template ../../node_modules/@0x/abi-gen-templates/contract.handlebars --partials '../../node_modules/@0x/abi-gen-templates/partials/**/*.handlebars' --output generated-wrappers --backend ethers",
|
||||
"lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
||||
"fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
||||
"coverage:report:text": "istanbul report text",
|
||||
"coverage:report:html": "istanbul report html && open coverage/index.html",
|
||||
"profiler:report:html": "istanbul report html && open coverage/index.html",
|
||||
|
@ -24,6 +24,7 @@
|
||||
"clean": "shx rm -rf lib generated-artifacts generated-wrappers",
|
||||
"generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --template ../../node_modules/@0x/abi-gen-templates/contract.handlebars --partials '../../node_modules/@0x/abi-gen-templates/partials/**/*.handlebars' --output generated-wrappers --backend ethers",
|
||||
"lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
||||
"fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
||||
"coverage:report:text": "istanbul report text",
|
||||
"coverage:report:html": "istanbul report html && open coverage/index.html",
|
||||
"profiler:report:html": "istanbul report html && open coverage/index.html",
|
||||
|
@ -24,6 +24,7 @@
|
||||
"clean": "shx rm -rf lib generated-artifacts generated-wrappers",
|
||||
"generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --template ../../node_modules/@0x/abi-gen-templates/contract.handlebars --partials '../../node_modules/@0x/abi-gen-templates/partials/**/*.handlebars' --output generated-wrappers --backend ethers",
|
||||
"lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
||||
"fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
||||
"coverage:report:text": "istanbul report text",
|
||||
"coverage:report:html": "istanbul report html && open coverage/index.html",
|
||||
"profiler:report:html": "istanbul report html && open coverage/index.html",
|
||||
|
@ -76,8 +76,8 @@ export class ForwarderWrapper {
|
||||
): Promise<TransactionReceiptWithDecodedLogs> {
|
||||
const params = ForwarderWrapper._createOptimizedOrders(orders);
|
||||
const feeParams = ForwarderWrapper._createOptimizedZrxOrders(feeOrders);
|
||||
const feePercentage = _.isUndefined(opts.feePercentage) ? constants.ZERO_AMOUNT : opts.feePercentage;
|
||||
const feeRecipient = _.isUndefined(opts.feeRecipient) ? constants.NULL_ADDRESS : opts.feeRecipient;
|
||||
const feePercentage = opts.feePercentage === undefined ? constants.ZERO_AMOUNT : opts.feePercentage;
|
||||
const feeRecipient = opts.feeRecipient === undefined ? constants.NULL_ADDRESS : opts.feeRecipient;
|
||||
const txHash = await this._forwarderContract.marketSellOrdersWithEth.sendTransactionAsync(
|
||||
params.orders,
|
||||
params.signatures,
|
||||
@ -99,8 +99,8 @@ export class ForwarderWrapper {
|
||||
): Promise<TransactionReceiptWithDecodedLogs> {
|
||||
const params = ForwarderWrapper._createOptimizedOrders(orders);
|
||||
const feeParams = ForwarderWrapper._createOptimizedZrxOrders(feeOrders);
|
||||
const feePercentage = _.isUndefined(opts.feePercentage) ? constants.ZERO_AMOUNT : opts.feePercentage;
|
||||
const feeRecipient = _.isUndefined(opts.feeRecipient) ? constants.NULL_ADDRESS : opts.feeRecipient;
|
||||
const feePercentage = opts.feePercentage === undefined ? constants.ZERO_AMOUNT : opts.feePercentage;
|
||||
const feeRecipient = opts.feeRecipient === undefined ? constants.NULL_ADDRESS : opts.feeRecipient;
|
||||
const txHash = await this._forwarderContract.marketBuyOrdersWithEth.sendTransactionAsync(
|
||||
params.orders,
|
||||
makerAssetFillAmount,
|
||||
|
@ -24,6 +24,7 @@
|
||||
"clean": "shx rm -rf lib generated-artifacts generated-wrappers",
|
||||
"generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --template ../../node_modules/@0x/abi-gen-templates/contract.handlebars --partials '../../node_modules/@0x/abi-gen-templates/partials/**/*.handlebars' --output generated-wrappers --backend ethers",
|
||||
"lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
||||
"fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
||||
"coverage:report:text": "istanbul report text",
|
||||
"coverage:report:html": "istanbul report html && open coverage/index.html",
|
||||
"profiler:report:html": "istanbul report html && open coverage/index.html",
|
||||
|
@ -24,6 +24,7 @@
|
||||
"clean": "shx rm -rf lib generated-artifacts generated-wrappers",
|
||||
"generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --template ../../node_modules/@0x/abi-gen-templates/contract.handlebars --partials '../../node_modules/@0x/abi-gen-templates/partials/**/*.handlebars' --output generated-wrappers --backend ethers",
|
||||
"lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
||||
"fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
||||
"coverage:report:text": "istanbul report text",
|
||||
"coverage:report:html": "istanbul report html && open coverage/index.html",
|
||||
"profiler:report:html": "istanbul report html && open coverage/index.html",
|
||||
|
@ -437,7 +437,7 @@ export class FillOrderCombinatorialUtils {
|
||||
lazyStore: BalanceAndProxyAllowanceLazyStore,
|
||||
fillRevertReasonIfExists: RevertReason | undefined,
|
||||
): Promise<void> {
|
||||
if (!_.isUndefined(fillRevertReasonIfExists)) {
|
||||
if (fillRevertReasonIfExists !== undefined) {
|
||||
return expectTransactionFailedAsync(
|
||||
this.exchangeWrapper.fillOrderAsync(signedOrder, this.takerAddress, { takerAssetFillAmount }),
|
||||
fillRevertReasonIfExists,
|
||||
|
@ -24,6 +24,7 @@
|
||||
"clean": "shx rm -rf lib generated-artifacts generated-wrappers",
|
||||
"generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --template ../../node_modules/@0x/abi-gen-templates/contract.handlebars --partials '../../node_modules/@0x/abi-gen-templates/partials/**/*.handlebars' --output generated-wrappers --backend ethers",
|
||||
"lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
||||
"fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
||||
"coverage:report:text": "istanbul report text",
|
||||
"coverage:report:html": "istanbul report html && open coverage/index.html",
|
||||
"profiler:report:html": "istanbul report html && open coverage/index.html",
|
||||
|
@ -12,7 +12,6 @@ import { SignedOrder } from '@0x/types';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import { TransactionReceiptWithDecodedLogs } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { artifacts, BalanceThresholdFilterContract } from '../../src';
|
||||
|
||||
@ -264,7 +263,7 @@ export class BalanceThresholdWrapper {
|
||||
gas?: number,
|
||||
): Promise<TransactionReceiptWithDecodedLogs> {
|
||||
const signedExchangeTx = this._signerTransactionFactory.newSignedTransaction(abiEncodedExchangeTxData);
|
||||
const txOpts = _.isUndefined(gas) ? { from } : { from, gas };
|
||||
const txOpts = gas === undefined ? { from } : { from, gas };
|
||||
const txHash = await this._balanceThresholdFilter.executeTransaction.sendTransactionAsync(
|
||||
signedExchangeTx.salt,
|
||||
signedExchangeTx.signerAddress,
|
||||
|
@ -24,6 +24,7 @@
|
||||
"clean": "shx rm -rf lib generated-artifacts generated-wrappers",
|
||||
"generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --template ../../packages/abi-gen-templates/contract.handlebars --partials '../../packages/abi-gen-templates/partials/**/*.handlebars' --output generated-wrappers --backend ethers",
|
||||
"lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
||||
"fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
||||
"coverage:report:text": "istanbul report text",
|
||||
"coverage:report:html": "istanbul report html && open coverage/index.html",
|
||||
"profiler:report:html": "istanbul report html && open coverage/index.html",
|
||||
|
@ -70,7 +70,7 @@ describe('MultiSigWalletWithTimeLock', () => {
|
||||
REQUIRED_APPROVALS,
|
||||
secondsTimeLocked,
|
||||
);
|
||||
expect(_.isUndefined((multiSig as any).external_call)).to.be.equal(true);
|
||||
expect((multiSig as any).external_call === undefined).to.be.equal(true);
|
||||
});
|
||||
});
|
||||
describe('confirmTransaction', () => {
|
||||
@ -271,7 +271,7 @@ describe('MultiSigWalletWithTimeLock', () => {
|
||||
|
||||
const blockNum = await web3Wrapper.getBlockNumberAsync();
|
||||
const blockInfo = await web3Wrapper.getBlockIfExistsAsync(blockNum);
|
||||
if (_.isUndefined(blockInfo)) {
|
||||
if (blockInfo === undefined) {
|
||||
throw new Error(`Unexpectedly failed to fetch block at #${blockNum}`);
|
||||
}
|
||||
const timestamp = new BigNumber(blockInfo.timestamp);
|
||||
|
@ -3,7 +3,6 @@ import { LogDecoder, Web3ProviderEngine } from '@0x/contracts-test-utils';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import { TransactionReceiptWithDecodedLogs } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { AssetProxyOwnerContract } from '../../generated-wrappers/asset_proxy_owner';
|
||||
import { artifacts } from '../../src/artifacts';
|
||||
@ -23,7 +22,7 @@ export class AssetProxyOwnerWrapper {
|
||||
from: string,
|
||||
opts: { value?: BigNumber } = {},
|
||||
): Promise<TransactionReceiptWithDecodedLogs> {
|
||||
const value = _.isUndefined(opts.value) ? new BigNumber(0) : opts.value;
|
||||
const value = opts.value === undefined ? new BigNumber(0) : opts.value;
|
||||
const txHash = await this._assetProxyOwner.submitTransaction.sendTransactionAsync(destination, value, data, {
|
||||
from,
|
||||
});
|
||||
|
@ -2,7 +2,6 @@ import { LogDecoder, Web3ProviderEngine } from '@0x/contracts-test-utils';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import { TransactionReceiptWithDecodedLogs } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { MultiSigWalletContract } from '../../generated-wrappers/multi_sig_wallet';
|
||||
import { artifacts } from '../../src/artifacts';
|
||||
@ -22,7 +21,7 @@ export class MultiSigWrapper {
|
||||
from: string,
|
||||
opts: { value?: BigNumber } = {},
|
||||
): Promise<TransactionReceiptWithDecodedLogs> {
|
||||
const value = _.isUndefined(opts.value) ? new BigNumber(0) : opts.value;
|
||||
const value = opts.value === undefined ? new BigNumber(0) : opts.value;
|
||||
const txHash = await this._multiSig.submitTransaction.sendTransactionAsync(destination, value, data, {
|
||||
from,
|
||||
});
|
||||
|
@ -17,6 +17,7 @@
|
||||
"run_mocha": "mocha --require source-map-support/register --require make-promises-safe 'lib/test/**/*.js' --timeout 100000 --bail --exit",
|
||||
"clean": "shx rm -rf lib",
|
||||
"lint": "tslint --format stylish --project tsconfig.lint.json",
|
||||
"fix": "tslint --fix --format stylish --project tsconfig.lint.json",
|
||||
"coverage:report:text": "istanbul report text",
|
||||
"coverage:report:html": "istanbul report html && open coverage/index.html",
|
||||
"profiler:report:html": "istanbul report html && open coverage/index.html",
|
||||
|
@ -24,7 +24,7 @@ export type sendTransactionResult = Promise<TransactionReceipt | TransactionRece
|
||||
* node.
|
||||
*/
|
||||
async function _getGanacheOrGethErrorAsync(ganacheError: string, gethError: string): Promise<string> {
|
||||
if (_.isUndefined(nodeType)) {
|
||||
if (nodeType === undefined) {
|
||||
nodeType = await web3Wrapper.getNodeTypeAsync();
|
||||
}
|
||||
switch (nodeType) {
|
||||
@ -99,7 +99,7 @@ export async function expectTransactionFailedAsync(p: sendTransactionResult, rea
|
||||
_.noop(e);
|
||||
});
|
||||
|
||||
if (_.isUndefined(nodeType)) {
|
||||
if (nodeType === undefined) {
|
||||
nodeType = await web3Wrapper.getNodeTypeAsync();
|
||||
}
|
||||
switch (nodeType) {
|
||||
|
@ -1,5 +1,3 @@
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { constants } from './constants';
|
||||
import { web3Wrapper } from './web3_wrapper';
|
||||
|
||||
@ -13,7 +11,7 @@ let firstAccount: string | undefined;
|
||||
* reject if the time could not be increased.
|
||||
*/
|
||||
export async function increaseTimeAndMineBlockAsync(seconds: number): Promise<number> {
|
||||
if (_.isUndefined(firstAccount)) {
|
||||
if (firstAccount === undefined) {
|
||||
const accounts = await web3Wrapper.getAvailableAddressesAsync();
|
||||
firstAccount = accounts[0];
|
||||
}
|
||||
@ -36,7 +34,7 @@ export async function increaseTimeAndMineBlockAsync(seconds: number): Promise<nu
|
||||
*/
|
||||
export async function getLatestBlockTimestampAsync(): Promise<number> {
|
||||
const currentBlockIfExists = await web3Wrapper.getBlockIfExistsAsync('latest');
|
||||
if (_.isUndefined(currentBlockIfExists)) {
|
||||
if (currentBlockIfExists === undefined) {
|
||||
throw new Error(`Unable to fetch latest block.`);
|
||||
}
|
||||
return currentBlockIfExists.timestamp;
|
||||
|
@ -1,12 +1,10 @@
|
||||
import { devConstants } from '@0x/dev-utils';
|
||||
import { CoverageSubprovider, SolCompilerArtifactAdapter } from '@0x/sol-coverage';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
let coverageSubprovider: CoverageSubprovider;
|
||||
|
||||
export const coverage = {
|
||||
getCoverageSubproviderSingleton(): CoverageSubprovider {
|
||||
if (_.isUndefined(coverageSubprovider)) {
|
||||
if (coverageSubprovider === undefined) {
|
||||
coverageSubprovider = coverage._getCoverageSubprovider();
|
||||
}
|
||||
return coverageSubprovider;
|
||||
|
@ -37,7 +37,7 @@ export class LogDecoder {
|
||||
public decodeLogOrThrow<ArgsType extends DecodedLogArgs>(log: LogEntry): LogWithDecodedArgs<ArgsType> | RawLog {
|
||||
const logWithDecodedArgsOrLog = this._abiDecoder.tryToDecodeLogOrNoop(log);
|
||||
// tslint:disable-next-line:no-unnecessary-type-assertion
|
||||
if (_.isUndefined((logWithDecodedArgsOrLog as LogWithDecodedArgs<ArgsType>).args)) {
|
||||
if ((logWithDecodedArgsOrLog as LogWithDecodedArgs<ArgsType>).args === undefined) {
|
||||
throw new Error(`Unable to decode log: ${JSON.stringify(log)}`);
|
||||
}
|
||||
LogDecoder.wrapLogBigNumbers(logWithDecodedArgsOrLog);
|
||||
|
@ -1,6 +1,5 @@
|
||||
import { devConstants } from '@0x/dev-utils';
|
||||
import { ProfilerSubprovider, SolCompilerArtifactAdapter } from '@0x/sol-profiler';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
let profilerSubprovider: ProfilerSubprovider;
|
||||
|
||||
@ -12,7 +11,7 @@ export const profiler = {
|
||||
profiler.getProfilerSubproviderSingleton().stop();
|
||||
},
|
||||
getProfilerSubproviderSingleton(): ProfilerSubprovider {
|
||||
if (_.isUndefined(profilerSubprovider)) {
|
||||
if (profilerSubprovider === undefined) {
|
||||
profilerSubprovider = profiler._getProfilerSubprovider();
|
||||
}
|
||||
return profilerSubprovider;
|
||||
|
@ -1,12 +1,11 @@
|
||||
import { devConstants } from '@0x/dev-utils';
|
||||
import { RevertTraceSubprovider, SolCompilerArtifactAdapter } from '@0x/sol-trace';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
let revertTraceSubprovider: RevertTraceSubprovider;
|
||||
|
||||
export const revertTrace = {
|
||||
getRevertTraceSubproviderSingleton(): RevertTraceSubprovider {
|
||||
if (_.isUndefined(revertTraceSubprovider)) {
|
||||
if (revertTraceSubprovider === undefined) {
|
||||
revertTraceSubprovider = revertTrace._getRevertTraceSubprovider();
|
||||
}
|
||||
return revertTraceSubprovider;
|
||||
|
@ -24,6 +24,7 @@
|
||||
"clean": "shx rm -rf lib generated-artifacts generated-wrappers",
|
||||
"generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --template ../../node_modules/@0x/abi-gen-templates/contract.handlebars --partials '../../node_modules/@0x/abi-gen-templates/partials/**/*.handlebars' --output generated-wrappers --backend ethers",
|
||||
"lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
||||
"fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
|
||||
"coverage:report:text": "istanbul report text",
|
||||
"coverage:report:html": "istanbul report html && open coverage/index.html",
|
||||
"profiler:report:html": "istanbul report html && open coverage/index.html",
|
||||
|
@ -10,6 +10,7 @@
|
||||
],
|
||||
"scripts": {
|
||||
"deps_versions:ci": "node ./packages/monorepo-scripts/lib/deps_versions.js",
|
||||
"fix": "wsrun fix $PKG --fast-exit --parallel --exclude-missing",
|
||||
"ganache": "ganache-cli -p 8545 --gasLimit 10000000 --networkId 50 -m \"${npm_package_config_mnemonic}\"",
|
||||
"prettier": "prettier --write '**/*.{ts,tsx,json,md}' --config .prettierrc",
|
||||
"prettier:ci": "prettier --list-different '**/*.{ts,tsx,json,md}' --config .prettierrc",
|
||||
|
@ -19,6 +19,7 @@
|
||||
"build:ci": "yarn build:commonjs",
|
||||
"build:all": "run-p build:umd:prod build:commonjs",
|
||||
"lint": "tslint --format stylish --project .",
|
||||
"fix": "tslint --fix --format stylish --project .",
|
||||
"test:circleci": "run-s test:coverage",
|
||||
"rebuild_and_test": "run-s build test",
|
||||
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
|
||||
|
@ -7,7 +7,6 @@ import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
||||
import { SimpleContractArtifact } from '@0x/types';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import * as ethers from 'ethers';
|
||||
import * as _ from 'lodash';
|
||||
// tslint:enable:no-unused-variable
|
||||
|
||||
{{#if events}}
|
||||
@ -46,7 +45,7 @@ export class {{contractName}}Contract extends BaseContract {
|
||||
txDefaults: Partial<TxData>,
|
||||
{{> typed_params inputs=ctor.inputs}}
|
||||
): Promise<{{contractName}}Contract> {
|
||||
if (_.isUndefined(artifact.compilerOutput)) {
|
||||
if (artifact.compilerOutput === undefined) {
|
||||
throw new Error('Compiler output not found in the artifact file');
|
||||
}
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
|
@ -13,6 +13,7 @@
|
||||
"build": "yarn pre_build && tsc -b",
|
||||
"build:ci": "yarn build",
|
||||
"lint": "tslint --format stylish --project .",
|
||||
"fix": "tslint --fix --format stylish --project .",
|
||||
"pre_build": "yarn generate_contract_wrappers",
|
||||
"clean": "shx rm -rf lib wrappers",
|
||||
"generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --template ../../node_modules/@0x/abi-gen-templates/contract.handlebars --partials '../../node_modules/@0x/abi-gen-templates/partials/**/*.handlebars' --output src/generated-wrappers --backend ethers"
|
||||
|
@ -1426,7 +1426,7 @@ export class AssetProxyOwnerContract extends BaseContract {
|
||||
_required: BigNumber,
|
||||
_secondsTimeLocked: BigNumber,
|
||||
): Promise<AssetProxyOwnerContract> {
|
||||
if (_.isUndefined(artifact.compilerOutput)) {
|
||||
if (artifact.compilerOutput === undefined) {
|
||||
throw new Error('Compiler output not found in the artifact file');
|
||||
}
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
|
@ -263,7 +263,7 @@ export class CoordinatorContract extends BaseContract {
|
||||
txDefaults: Partial<TxData>,
|
||||
_exchange: string,
|
||||
): Promise<CoordinatorContract> {
|
||||
if (_.isUndefined(artifact.compilerOutput)) {
|
||||
if (artifact.compilerOutput === undefined) {
|
||||
throw new Error('Compiler output not found in the artifact file');
|
||||
}
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
|
@ -136,7 +136,7 @@ export class CoordinatorRegistryContract extends BaseContract {
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
): Promise<CoordinatorRegistryContract> {
|
||||
if (_.isUndefined(artifact.compilerOutput)) {
|
||||
if (artifact.compilerOutput === undefined) {
|
||||
throw new Error('Compiler output not found in the artifact file');
|
||||
}
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
|
@ -760,7 +760,7 @@ export class DummyERC20TokenContract extends BaseContract {
|
||||
_decimals: BigNumber,
|
||||
_totalSupply: BigNumber,
|
||||
): Promise<DummyERC20TokenContract> {
|
||||
if (_.isUndefined(artifact.compilerOutput)) {
|
||||
if (artifact.compilerOutput === undefined) {
|
||||
throw new Error('Compiler output not found in the artifact file');
|
||||
}
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
|
@ -950,7 +950,7 @@ export class DummyERC721TokenContract extends BaseContract {
|
||||
_name: string,
|
||||
_symbol: string,
|
||||
): Promise<DummyERC721TokenContract> {
|
||||
if (_.isUndefined(artifact.compilerOutput)) {
|
||||
if (artifact.compilerOutput === undefined) {
|
||||
throw new Error('Compiler output not found in the artifact file');
|
||||
}
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
|
@ -200,7 +200,7 @@ export class DutchAuctionContract extends BaseContract {
|
||||
txDefaults: Partial<TxData>,
|
||||
_exchange: string,
|
||||
): Promise<DutchAuctionContract> {
|
||||
if (_.isUndefined(artifact.compilerOutput)) {
|
||||
if (artifact.compilerOutput === undefined) {
|
||||
throw new Error('Compiler output not found in the artifact file');
|
||||
}
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
|
@ -486,7 +486,7 @@ export class ERC20ProxyContract extends BaseContract {
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
): Promise<ERC20ProxyContract> {
|
||||
if (_.isUndefined(artifact.compilerOutput)) {
|
||||
if (artifact.compilerOutput === undefined) {
|
||||
throw new Error('Compiler output not found in the artifact file');
|
||||
}
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
|
@ -389,7 +389,7 @@ export class ERC20TokenContract extends BaseContract {
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
): Promise<ERC20TokenContract> {
|
||||
if (_.isUndefined(artifact.compilerOutput)) {
|
||||
if (artifact.compilerOutput === undefined) {
|
||||
throw new Error('Compiler output not found in the artifact file');
|
||||
}
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
|
@ -486,7 +486,7 @@ export class ERC721ProxyContract extends BaseContract {
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
): Promise<ERC721ProxyContract> {
|
||||
if (_.isUndefined(artifact.compilerOutput)) {
|
||||
if (artifact.compilerOutput === undefined) {
|
||||
throw new Error('Compiler output not found in the artifact file');
|
||||
}
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
|
@ -624,7 +624,7 @@ export class ERC721TokenContract extends BaseContract {
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
): Promise<ERC721TokenContract> {
|
||||
if (_.isUndefined(artifact.compilerOutput)) {
|
||||
if (artifact.compilerOutput === undefined) {
|
||||
throw new Error('Compiler output not found in the artifact file');
|
||||
}
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
|
@ -2229,7 +2229,7 @@ export class ExchangeContract extends BaseContract {
|
||||
txDefaults: Partial<TxData>,
|
||||
_zrxAssetData: string,
|
||||
): Promise<ExchangeContract> {
|
||||
if (_.isUndefined(artifact.compilerOutput)) {
|
||||
if (artifact.compilerOutput === undefined) {
|
||||
throw new Error('Compiler output not found in the artifact file');
|
||||
}
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
|
@ -461,7 +461,7 @@ export class ForwarderContract extends BaseContract {
|
||||
_zrxAssetData: string,
|
||||
_wethAssetData: string,
|
||||
): Promise<ForwarderContract> {
|
||||
if (_.isUndefined(artifact.compilerOutput)) {
|
||||
if (artifact.compilerOutput === undefined) {
|
||||
throw new Error('Compiler output not found in the artifact file');
|
||||
}
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
|
@ -488,7 +488,7 @@ export class IAssetProxyContract extends BaseContract {
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
): Promise<IAssetProxyContract> {
|
||||
if (_.isUndefined(artifact.compilerOutput)) {
|
||||
if (artifact.compilerOutput === undefined) {
|
||||
throw new Error('Compiler output not found in the artifact file');
|
||||
}
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
|
@ -52,7 +52,7 @@ export class IValidatorContract extends BaseContract {
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
): Promise<IValidatorContract> {
|
||||
if (_.isUndefined(artifact.compilerOutput)) {
|
||||
if (artifact.compilerOutput === undefined) {
|
||||
throw new Error('Compiler output not found in the artifact file');
|
||||
}
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
|
@ -50,7 +50,7 @@ export class IWalletContract extends BaseContract {
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
): Promise<IWalletContract> {
|
||||
if (_.isUndefined(artifact.compilerOutput)) {
|
||||
if (artifact.compilerOutput === undefined) {
|
||||
throw new Error('Compiler output not found in the artifact file');
|
||||
}
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
|
@ -625,7 +625,7 @@ export class MultiAssetProxyContract extends BaseContract {
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
): Promise<MultiAssetProxyContract> {
|
||||
if (_.isUndefined(artifact.compilerOutput)) {
|
||||
if (artifact.compilerOutput === undefined) {
|
||||
throw new Error('Compiler output not found in the artifact file');
|
||||
}
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
|
@ -232,7 +232,7 @@ export class OrderValidatorContract extends BaseContract {
|
||||
_exchange: string,
|
||||
_zrxAssetData: string,
|
||||
): Promise<OrderValidatorContract> {
|
||||
if (_.isUndefined(artifact.compilerOutput)) {
|
||||
if (artifact.compilerOutput === undefined) {
|
||||
throw new Error('Compiler output not found in the artifact file');
|
||||
}
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
|
@ -624,7 +624,7 @@ export class WETH9Contract extends BaseContract {
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
): Promise<WETH9Contract> {
|
||||
if (_.isUndefined(artifact.compilerOutput)) {
|
||||
if (artifact.compilerOutput === undefined) {
|
||||
throw new Error('Compiler output not found in the artifact file');
|
||||
}
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
|
@ -467,7 +467,7 @@ export class ZRXTokenContract extends BaseContract {
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
): Promise<ZRXTokenContract> {
|
||||
if (_.isUndefined(artifact.compilerOutput)) {
|
||||
if (artifact.compilerOutput === undefined) {
|
||||
throw new Error('Compiler output not found in the artifact file');
|
||||
}
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
|
@ -9,6 +9,7 @@
|
||||
"types": "lib/src/index.d.ts",
|
||||
"scripts": {
|
||||
"lint": "tslint --format stylish --project .",
|
||||
"fix": "tslint --fix --format stylish --project .",
|
||||
"clean": "shx rm -rf lib",
|
||||
"build": "tsc -b",
|
||||
"build:ci": "yarn build",
|
||||
|
@ -92,12 +92,12 @@ for (const abiFileName of abiFileNames) {
|
||||
let ABI;
|
||||
if (_.isArray(parsedContent)) {
|
||||
ABI = parsedContent; // ABI file
|
||||
} else if (!_.isUndefined(parsedContent.abi)) {
|
||||
} else if (parsedContent.abi !== undefined) {
|
||||
ABI = parsedContent.abi; // Truffle artifact
|
||||
} else if (!_.isUndefined(parsedContent.compilerOutput.abi)) {
|
||||
} else if (parsedContent.compilerOutput.abi !== undefined) {
|
||||
ABI = parsedContent.compilerOutput.abi; // 0x artifact
|
||||
}
|
||||
if (_.isUndefined(ABI)) {
|
||||
if (ABI === undefined) {
|
||||
logUtils.log(`${chalk.red(`ABI not found in ${abiFileName}.`)}`);
|
||||
logUtils.log(
|
||||
`Please make sure your ABI file is either an array with ABI entries or a truffle artifact or 0x sol-compiler artifact`,
|
||||
@ -114,7 +114,7 @@ for (const abiFileName of abiFileNames) {
|
||||
}
|
||||
|
||||
let ctor = ABI.find((abi: AbiDefinition) => abi.type === ABI_TYPE_CONSTRUCTOR) as ConstructorAbi;
|
||||
if (_.isUndefined(ctor)) {
|
||||
if (ctor === undefined) {
|
||||
ctor = utils.getEmptyConstructor(); // The constructor exists, but it's implicit in JSON's ABI definition
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
"build:ci": "yarn build",
|
||||
"clean": "shx rm -rf lib test_temp",
|
||||
"lint": "tslint --format stylish --project .",
|
||||
"fix": "tslint --fix --format stylish --project .",
|
||||
"run_mocha": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js --exit",
|
||||
"test": "yarn run_mocha",
|
||||
"rebuild_and_test": "run-s clean build test",
|
||||
|
@ -65,11 +65,11 @@ export const assert = {
|
||||
assert.assert(isWeb3Provider, assert.typeAssertionMessage(variableName, 'Provider', value));
|
||||
},
|
||||
doesConformToSchema(variableName: string, value: any, schema: Schema, subSchemas?: Schema[]): void {
|
||||
if (_.isUndefined(value)) {
|
||||
if (value === undefined) {
|
||||
throw new Error(`${variableName} can't be undefined`);
|
||||
}
|
||||
const schemaValidator = new SchemaValidator();
|
||||
if (!_.isUndefined(subSchemas)) {
|
||||
if (subSchemas !== undefined) {
|
||||
_.map(subSchemas, schemaValidator.addSchema.bind(schemaValidator));
|
||||
}
|
||||
const validationResult = schemaValidator.validate(value, schema);
|
||||
@ -80,11 +80,11 @@ Validation errors: ${validationResult.errors.join(', ')}`;
|
||||
assert.assert(!hasValidationErrors, msg);
|
||||
},
|
||||
isWebUri(variableName: string, value: any): void {
|
||||
const isValidUrl = !_.isUndefined(validUrl.isWebUri(value));
|
||||
const isValidUrl = validUrl.isWebUri(value) !== undefined;
|
||||
assert.assert(isValidUrl, assert.typeAssertionMessage(variableName, 'web uri', value));
|
||||
},
|
||||
isUri(variableName: string, value: any): void {
|
||||
const isValidUri = !_.isUndefined(validUrl.isUri(value));
|
||||
const isValidUri = validUrl.isUri(value) !== undefined;
|
||||
assert.assert(isValidUri, assert.typeAssertionMessage(variableName, 'uri', value));
|
||||
},
|
||||
assert(condition: boolean, message: string): void {
|
||||
|
@ -11,6 +11,7 @@
|
||||
"build": "yarn tsc -b",
|
||||
"build:ci": "yarn build",
|
||||
"lint": "tslint --format stylish --project .",
|
||||
"fix": "tslint --fix --format stylish --project .",
|
||||
"test": "yarn run_mocha",
|
||||
"rebuild_and_test": "run-s clean build test",
|
||||
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
|
||||
|
@ -234,29 +234,29 @@ export class AssetBuyer {
|
||||
options,
|
||||
);
|
||||
assert.isValidBuyQuote('buyQuote', buyQuote);
|
||||
if (!_.isUndefined(ethAmount)) {
|
||||
if (ethAmount !== undefined) {
|
||||
assert.isBigNumber('ethAmount', ethAmount);
|
||||
}
|
||||
if (!_.isUndefined(takerAddress)) {
|
||||
if (takerAddress !== undefined) {
|
||||
assert.isETHAddressHex('takerAddress', takerAddress);
|
||||
}
|
||||
assert.isETHAddressHex('feeRecipient', feeRecipient);
|
||||
if (!_.isUndefined(gasLimit)) {
|
||||
if (gasLimit !== undefined) {
|
||||
assert.isNumber('gasLimit', gasLimit);
|
||||
}
|
||||
if (!_.isUndefined(gasPrice)) {
|
||||
if (gasPrice !== undefined) {
|
||||
assert.isBigNumber('gasPrice', gasPrice);
|
||||
}
|
||||
const { orders, feeOrders, feePercentage, assetBuyAmount, worstCaseQuoteInfo } = buyQuote;
|
||||
// if no takerAddress is provided, try to get one from the provider
|
||||
let finalTakerAddress;
|
||||
if (!_.isUndefined(takerAddress)) {
|
||||
if (takerAddress !== undefined) {
|
||||
finalTakerAddress = takerAddress;
|
||||
} else {
|
||||
const web3Wrapper = new Web3Wrapper(this.provider);
|
||||
const availableAddresses = await web3Wrapper.getAvailableAddressesAsync();
|
||||
const firstAvailableAddress = _.head(availableAddresses);
|
||||
if (!_.isUndefined(firstAvailableAddress)) {
|
||||
if (firstAvailableAddress !== undefined) {
|
||||
finalTakerAddress = firstAvailableAddress;
|
||||
} else {
|
||||
throw new Error(AssetBuyerError.NoAddressAvailable);
|
||||
@ -314,7 +314,7 @@ export class AssetBuyer {
|
||||
// we are forced to OR
|
||||
// we have some last refresh time AND that time was sufficiently long ago
|
||||
const shouldRefresh =
|
||||
_.isUndefined(ordersEntryIfExists) ||
|
||||
ordersEntryIfExists === undefined ||
|
||||
shouldForceOrderRefresh ||
|
||||
// tslint:disable:restrict-plus-operands
|
||||
ordersEntryIfExists.lastRefreshTime + this.orderRefreshIntervalMs < Date.now();
|
||||
|
@ -1,6 +1,5 @@
|
||||
import { assert as sharedAssert } from '@0x/assert';
|
||||
import { schemas } from '@0x/json-schemas';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { BuyQuote, BuyQuoteInfo, OrderProvider, OrderProviderRequest } from '../types';
|
||||
|
||||
@ -13,7 +12,7 @@ export const assert = {
|
||||
assert.isValidBuyQuoteInfo(`${variableName}.bestCaseQuoteInfo`, buyQuote.bestCaseQuoteInfo);
|
||||
assert.isValidBuyQuoteInfo(`${variableName}.worstCaseQuoteInfo`, buyQuote.worstCaseQuoteInfo);
|
||||
sharedAssert.isBigNumber(`${variableName}.assetBuyAmount`, buyQuote.assetBuyAmount);
|
||||
if (!_.isUndefined(buyQuote.feePercentage)) {
|
||||
if (buyQuote.feePercentage !== undefined) {
|
||||
sharedAssert.isNumber(`${variableName}.feePercentage`, buyQuote.feePercentage);
|
||||
}
|
||||
},
|
||||
|
@ -41,7 +41,7 @@ export const orderProviderResponseProcessor = {
|
||||
// set the orders to be sorted equal to the filtered orders
|
||||
let unsortedOrders = filteredOrders;
|
||||
// if an orderValidator is provided, use on chain information to calculate remaining fillable makerAsset amounts
|
||||
if (!_.isUndefined(orderValidator)) {
|
||||
if (orderValidator !== undefined) {
|
||||
const takerAddresses = _.map(filteredOrders, () => constants.NULL_ADDRESS);
|
||||
try {
|
||||
const ordersAndTradersInfo = await orderValidator.getOrdersAndTradersInfoAsync(
|
||||
|
@ -17,7 +17,8 @@
|
||||
"run_mocha": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js --bail --exit",
|
||||
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
|
||||
"coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info",
|
||||
"lint": "tslint --format stylish --project ."
|
||||
"lint": "tslint --format stylish --project .",
|
||||
"fix": "tslint --format stylish --fix --project ."
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"repository": {
|
||||
|
@ -51,7 +51,7 @@ export class BaseContract {
|
||||
(abiDefinition: AbiDefinition) => abiDefinition.type === AbiType.Constructor,
|
||||
// tslint:disable-next-line:no-unnecessary-type-assertion
|
||||
) as ConstructorAbi | undefined;
|
||||
if (!_.isUndefined(constructorAbiIfExists)) {
|
||||
if (constructorAbiIfExists !== undefined) {
|
||||
return constructorAbiIfExists;
|
||||
} else {
|
||||
// If the constructor is not explicitly defined, it won't be included in the ABI. It is
|
||||
@ -79,7 +79,7 @@ export class BaseContract {
|
||||
...removeUndefinedProperties(txDefaults),
|
||||
...removeUndefinedProperties(txData),
|
||||
};
|
||||
if (_.isUndefined(txDataWithDefaults.gas) && !_.isUndefined(estimateGasAsync)) {
|
||||
if (txDataWithDefaults.gas === undefined && estimateGasAsync !== undefined) {
|
||||
txDataWithDefaults.gas = await estimateGasAsync(txDataWithDefaults);
|
||||
}
|
||||
return txDataWithDefaults;
|
||||
@ -122,7 +122,7 @@ export class BaseContract {
|
||||
}
|
||||
protected _lookupAbiEncoder(functionSignature: string): AbiEncoder.Method {
|
||||
const abiEncoder = this._abiEncoderByFunctionSignature[functionSignature];
|
||||
if (_.isUndefined(abiEncoder)) {
|
||||
if (abiEncoder === undefined) {
|
||||
throw new Error(`Failed to lookup method with function signature '${functionSignature}'`);
|
||||
}
|
||||
return abiEncoder;
|
||||
|
@ -20,6 +20,7 @@
|
||||
"clean": "shx rm -rf lib test_temp generated_docs",
|
||||
"copy_test_fixtures": "copyfiles -u 2 './test/fixtures/**/*.json' ./lib/test/fixtures",
|
||||
"lint": "tslint --format stylish --project .",
|
||||
"fix": "tslint --fix --format stylish --project .",
|
||||
"run_mocha": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js --exit",
|
||||
"test": "run-s copy_test_fixtures run_mocha",
|
||||
"rebuild_and_test": "run-s clean build test",
|
||||
|
@ -35,7 +35,7 @@ export class HttpClient implements Client {
|
||||
*/
|
||||
private static _buildQueryStringFromHttpParams(params?: object): string {
|
||||
// if params are undefined or empty, return an empty string
|
||||
if (_.isUndefined(params) || _.isEmpty(params)) {
|
||||
if (params === undefined || _.isEmpty(params)) {
|
||||
return '';
|
||||
}
|
||||
// stringify the formatted object
|
||||
@ -59,7 +59,7 @@ export class HttpClient implements Client {
|
||||
public async getAssetPairsAsync(
|
||||
requestOpts?: RequestOpts & AssetPairsRequestOpts & PagedRequestOpts,
|
||||
): Promise<AssetPairsResponse> {
|
||||
if (!_.isUndefined(requestOpts)) {
|
||||
if (requestOpts !== undefined) {
|
||||
assert.doesConformToSchema('requestOpts', requestOpts, schemas.assetPairsRequestOptsSchema);
|
||||
assert.doesConformToSchema('requestOpts', requestOpts, schemas.pagedRequestOptsSchema);
|
||||
assert.doesConformToSchema('requestOpts', requestOpts, schemas.requestOptsSchema);
|
||||
@ -79,7 +79,7 @@ export class HttpClient implements Client {
|
||||
public async getOrdersAsync(
|
||||
requestOpts?: RequestOpts & OrdersRequestOpts & PagedRequestOpts,
|
||||
): Promise<OrdersResponse> {
|
||||
if (!_.isUndefined(requestOpts)) {
|
||||
if (requestOpts !== undefined) {
|
||||
assert.doesConformToSchema('requestOpts', requestOpts, schemas.ordersRequestOptsSchema);
|
||||
assert.doesConformToSchema('requestOpts', requestOpts, schemas.pagedRequestOptsSchema);
|
||||
assert.doesConformToSchema('requestOpts', requestOpts, schemas.requestOptsSchema);
|
||||
@ -97,7 +97,7 @@ export class HttpClient implements Client {
|
||||
* @return The APIOrder that matches the supplied orderHash
|
||||
*/
|
||||
public async getOrderAsync(orderHash: string, requestOpts?: RequestOpts): Promise<APIOrder> {
|
||||
if (!_.isUndefined(requestOpts)) {
|
||||
if (requestOpts !== undefined) {
|
||||
assert.doesConformToSchema('requestOpts', requestOpts, schemas.requestOptsSchema);
|
||||
}
|
||||
assert.doesConformToSchema('orderHash', orderHash, schemas.orderHashSchema);
|
||||
@ -119,7 +119,7 @@ export class HttpClient implements Client {
|
||||
requestOpts?: RequestOpts & PagedRequestOpts,
|
||||
): Promise<OrderbookResponse> {
|
||||
assert.doesConformToSchema('request', request, schemas.orderBookRequestSchema);
|
||||
if (!_.isUndefined(requestOpts)) {
|
||||
if (requestOpts !== undefined) {
|
||||
assert.doesConformToSchema('requestOpts', requestOpts, schemas.pagedRequestOptsSchema);
|
||||
assert.doesConformToSchema('requestOpts', requestOpts, schemas.requestOptsSchema);
|
||||
}
|
||||
@ -140,7 +140,7 @@ export class HttpClient implements Client {
|
||||
request: OrderConfigRequest,
|
||||
requestOpts?: RequestOpts,
|
||||
): Promise<OrderConfigResponse> {
|
||||
if (!_.isUndefined(requestOpts)) {
|
||||
if (requestOpts !== undefined) {
|
||||
assert.doesConformToSchema('requestOpts', requestOpts, schemas.requestOptsSchema);
|
||||
}
|
||||
assert.doesConformToSchema('request', request, schemas.orderConfigRequestSchema);
|
||||
@ -158,7 +158,7 @@ export class HttpClient implements Client {
|
||||
* @return The resulting FeeRecipientsResponse
|
||||
*/
|
||||
public async getFeeRecipientsAsync(requestOpts?: RequestOpts & PagedRequestOpts): Promise<FeeRecipientsResponse> {
|
||||
if (!_.isUndefined(requestOpts)) {
|
||||
if (requestOpts !== undefined) {
|
||||
assert.doesConformToSchema('requestOpts', requestOpts, schemas.pagedRequestOptsSchema);
|
||||
assert.doesConformToSchema('requestOpts', requestOpts, schemas.requestOptsSchema);
|
||||
}
|
||||
|
@ -12,11 +12,11 @@ export const ordersChannelMessageParser = {
|
||||
const messageObj = JSON.parse(utf8Data);
|
||||
// ensure we have a type parameter to switch on
|
||||
const type: string = _.get(messageObj, 'type');
|
||||
assert.assert(!_.isUndefined(type), `Message is missing a type parameter: ${utf8Data}`);
|
||||
assert.assert(type !== undefined, `Message is missing a type parameter: ${utf8Data}`);
|
||||
assert.isString('type', type);
|
||||
// ensure we have a request id for the resulting message
|
||||
const requestId: string = _.get(messageObj, 'requestId');
|
||||
assert.assert(!_.isUndefined(requestId), `Message is missing a requestId parameter: ${utf8Data}`);
|
||||
assert.assert(requestId !== undefined, `Message is missing a requestId parameter: ${utf8Data}`);
|
||||
assert.isString('requestId', requestId);
|
||||
switch (type) {
|
||||
case OrdersChannelMessageTypes.Update: {
|
||||
|
@ -67,7 +67,7 @@ export class WebSocketOrdersChannel implements OrdersChannel {
|
||||
this._client.close();
|
||||
}
|
||||
private _handleWebSocketMessage(message: any): void {
|
||||
if (_.isUndefined(message.data)) {
|
||||
if (message.data === undefined) {
|
||||
this._handler.onError(this, new Error(`Message does not contain data. Url: ${this._client.url}`));
|
||||
return;
|
||||
}
|
||||
@ -75,7 +75,7 @@ export class WebSocketOrdersChannel implements OrdersChannel {
|
||||
const data = message.data;
|
||||
const parserResult = ordersChannelMessageParser.parse(data);
|
||||
const subscriptionOpts = this._subscriptionOptsMap[parserResult.requestId];
|
||||
if (_.isUndefined(subscriptionOpts)) {
|
||||
if (subscriptionOpts === undefined) {
|
||||
this._handler.onError(
|
||||
this,
|
||||
new Error(`Message has unknown requestId. Url: ${this._client.url} Message: ${data}`),
|
||||
|
@ -102,7 +102,7 @@ const networkToAddresses: { [networkId: number]: ContractAddresses } = {
|
||||
* given networkId.
|
||||
*/
|
||||
export function getContractAddressesForNetworkOrThrow(networkId: NetworkId): ContractAddresses {
|
||||
if (_.isUndefined(networkToAddresses[networkId])) {
|
||||
if (networkToAddresses[networkId] === undefined) {
|
||||
throw new Error(`Unknown network id (${networkId}). No known 0x contracts have been deployed on this network.`);
|
||||
}
|
||||
return networkToAddresses[networkId];
|
||||
|
@ -14,6 +14,7 @@
|
||||
"build": "tsc -b",
|
||||
"build:ci": "yarn build",
|
||||
"lint": "tslint --format stylish --project . --exclude **/lib/**/*",
|
||||
"fix": "tslint --fix --format stylish --project . --exclude **/lib/**/*",
|
||||
"test:circleci": "run-s test:coverage",
|
||||
"test": "yarn run_mocha",
|
||||
"rebuild_and_test": "run-s build test",
|
||||
|
@ -101,12 +101,14 @@ export class ContractWrappers {
|
||||
_.forEach(artifactsArray, artifact => {
|
||||
this._web3Wrapper.abiDecoder.addABI(artifact.compilerOutput.abi, artifact.contractName);
|
||||
});
|
||||
const blockPollingIntervalMs = _.isUndefined(config.blockPollingIntervalMs)
|
||||
? constants.DEFAULT_BLOCK_POLLING_INTERVAL
|
||||
: config.blockPollingIntervalMs;
|
||||
const contractAddresses = _.isUndefined(config.contractAddresses)
|
||||
? _getDefaultContractAddresses(config.networkId)
|
||||
: config.contractAddresses;
|
||||
const blockPollingIntervalMs =
|
||||
config.blockPollingIntervalMs === undefined
|
||||
? constants.DEFAULT_BLOCK_POLLING_INTERVAL
|
||||
: config.blockPollingIntervalMs;
|
||||
const contractAddresses =
|
||||
config.contractAddresses === undefined
|
||||
? _getDefaultContractAddresses(config.networkId)
|
||||
: config.contractAddresses;
|
||||
this.erc20Proxy = new ERC20ProxyWrapper(this._web3Wrapper, config.networkId, contractAddresses.erc20Proxy);
|
||||
this.erc721Proxy = new ERC721ProxyWrapper(this._web3Wrapper, config.networkId, contractAddresses.erc721Proxy);
|
||||
this.erc20Token = new ERC20TokenWrapper(
|
||||
|
@ -46,9 +46,8 @@ export abstract class ContractWrapper {
|
||||
constructor(web3Wrapper: Web3Wrapper, networkId: number, blockPollingIntervalMs?: number) {
|
||||
this._web3Wrapper = web3Wrapper;
|
||||
this._networkId = networkId;
|
||||
this._blockPollingIntervalMs = _.isUndefined(blockPollingIntervalMs)
|
||||
? constants.DEFAULT_BLOCK_POLLING_INTERVAL
|
||||
: blockPollingIntervalMs;
|
||||
this._blockPollingIntervalMs =
|
||||
blockPollingIntervalMs === undefined ? constants.DEFAULT_BLOCK_POLLING_INTERVAL : blockPollingIntervalMs;
|
||||
this._filters = {};
|
||||
this._filterCallbacks = {};
|
||||
this._blockAndLogStreamerIfExists = undefined;
|
||||
@ -62,10 +61,10 @@ export abstract class ContractWrapper {
|
||||
});
|
||||
}
|
||||
protected _unsubscribe(filterToken: string, err?: Error): void {
|
||||
if (_.isUndefined(this._filters[filterToken])) {
|
||||
if (this._filters[filterToken] === undefined) {
|
||||
throw new Error(ContractWrappersError.SubscriptionNotFound);
|
||||
}
|
||||
if (!_.isUndefined(err)) {
|
||||
if (err !== undefined) {
|
||||
const callback = this._filterCallbacks[filterToken];
|
||||
callback(err, undefined);
|
||||
}
|
||||
@ -84,7 +83,7 @@ export abstract class ContractWrapper {
|
||||
isVerbose: boolean = false,
|
||||
): string {
|
||||
const filter = filterUtils.getFilter(address, eventName, indexFilterValues, abi);
|
||||
if (_.isUndefined(this._blockAndLogStreamerIfExists)) {
|
||||
if (this._blockAndLogStreamerIfExists === undefined) {
|
||||
this._startBlockAndLogStream(isVerbose);
|
||||
}
|
||||
const filterToken = filterUtils.generateUUID();
|
||||
@ -125,7 +124,7 @@ export abstract class ContractWrapper {
|
||||
});
|
||||
}
|
||||
private _startBlockAndLogStream(isVerbose: boolean): void {
|
||||
if (!_.isUndefined(this._blockAndLogStreamerIfExists)) {
|
||||
if (this._blockAndLogStreamerIfExists !== undefined) {
|
||||
throw new Error(ContractWrappersError.SubscriptionAlreadyPresent);
|
||||
}
|
||||
this._blockAndLogStreamerIfExists = new BlockAndLogStreamer(
|
||||
@ -176,7 +175,7 @@ export abstract class ContractWrapper {
|
||||
return logs as RawLogEntry[];
|
||||
}
|
||||
private _stopBlockAndLogStream(): void {
|
||||
if (_.isUndefined(this._blockAndLogStreamerIfExists)) {
|
||||
if (this._blockAndLogStreamerIfExists === undefined) {
|
||||
throw new Error(ContractWrappersError.SubscriptionNotFound);
|
||||
}
|
||||
this._blockAndLogStreamerIfExists.unsubscribeFromOnLogAdded(this._onLogAddedSubscriptionToken as string);
|
||||
@ -186,11 +185,11 @@ export abstract class ContractWrapper {
|
||||
}
|
||||
private async _reconcileBlockAsync(): Promise<void> {
|
||||
const latestBlockOrNull = await this._blockstreamGetLatestBlockOrNullAsync();
|
||||
if (_.isNull(latestBlockOrNull)) {
|
||||
if (latestBlockOrNull === null) {
|
||||
return; // noop
|
||||
}
|
||||
// We need to coerce to Block type cause Web3.Block includes types for mempool blocks
|
||||
if (!_.isUndefined(this._blockAndLogStreamerIfExists)) {
|
||||
if (this._blockAndLogStreamerIfExists !== undefined) {
|
||||
// If we clear the interval while fetching the block - this._blockAndLogStreamer will be undefined
|
||||
await this._blockAndLogStreamerIfExists.reconcileNewBlock(latestBlockOrNull);
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ export class DutchAuctionWrapper extends ContractWrapper {
|
||||
*/
|
||||
public constructor(web3Wrapper: Web3Wrapper, networkId: number, address?: string) {
|
||||
super(web3Wrapper, networkId);
|
||||
this.address = _.isUndefined(address) ? _getDefaultContractAddresses(networkId).dutchAuction : address;
|
||||
this.address = address === undefined ? _getDefaultContractAddresses(networkId).dutchAuction : address;
|
||||
}
|
||||
/**
|
||||
* Matches the buy and sell orders at an amount given the following: the current block time, the auction
|
||||
@ -167,7 +167,7 @@ export class DutchAuctionWrapper extends ContractWrapper {
|
||||
return auctionDetails;
|
||||
}
|
||||
private async _getDutchAuctionContractAsync(): Promise<DutchAuctionContract> {
|
||||
if (!_.isUndefined(this._dutchAuctionContractIfExists)) {
|
||||
if (this._dutchAuctionContractIfExists !== undefined) {
|
||||
return this._dutchAuctionContractIfExists;
|
||||
}
|
||||
const contractInstance = new DutchAuctionContract(
|
||||
|
@ -26,7 +26,7 @@ export class ERC20ProxyWrapper extends ContractWrapper {
|
||||
*/
|
||||
constructor(web3Wrapper: Web3Wrapper, networkId: number, address?: string) {
|
||||
super(web3Wrapper, networkId);
|
||||
this.address = _.isUndefined(address) ? _getDefaultContractAddresses(networkId).erc20Proxy : address;
|
||||
this.address = address === undefined ? _getDefaultContractAddresses(networkId).erc20Proxy : address;
|
||||
}
|
||||
/**
|
||||
* Get the 4 bytes ID of this asset proxy
|
||||
@ -62,7 +62,7 @@ export class ERC20ProxyWrapper extends ContractWrapper {
|
||||
return authorizedAddresses;
|
||||
}
|
||||
private _getERC20ProxyContract(): ERC20ProxyContract {
|
||||
if (!_.isUndefined(this._erc20ProxyContractIfExists)) {
|
||||
if (this._erc20ProxyContractIfExists !== undefined) {
|
||||
return this._erc20ProxyContractIfExists;
|
||||
}
|
||||
const contractInstance = new ERC20ProxyContract(
|
||||
|
@ -427,7 +427,7 @@ export class ERC20TokenWrapper extends ContractWrapper {
|
||||
private async _getTokenContractAsync(tokenAddress: string): Promise<ERC20TokenContract> {
|
||||
const normalizedTokenAddress = tokenAddress.toLowerCase();
|
||||
let tokenContract = this._tokenContractsByAddress[normalizedTokenAddress];
|
||||
if (!_.isUndefined(tokenContract)) {
|
||||
if (tokenContract !== undefined) {
|
||||
return tokenContract;
|
||||
}
|
||||
const contractInstance = new ERC20TokenContract(
|
||||
|
@ -26,7 +26,7 @@ export class ERC721ProxyWrapper extends ContractWrapper {
|
||||
*/
|
||||
constructor(web3Wrapper: Web3Wrapper, networkId: number, address?: string) {
|
||||
super(web3Wrapper, networkId);
|
||||
this.address = _.isUndefined(address) ? _getDefaultContractAddresses(networkId).erc721Proxy : address;
|
||||
this.address = address === undefined ? _getDefaultContractAddresses(networkId).erc721Proxy : address;
|
||||
}
|
||||
/**
|
||||
* Get the 4 bytes ID of this asset proxy
|
||||
@ -62,7 +62,7 @@ export class ERC721ProxyWrapper extends ContractWrapper {
|
||||
return authorizedAddresses;
|
||||
}
|
||||
private _getERC721ProxyContract(): ERC721ProxyContract {
|
||||
if (!_.isUndefined(this._erc721ProxyContractIfExists)) {
|
||||
if (this._erc721ProxyContractIfExists !== undefined) {
|
||||
return this._erc721ProxyContractIfExists;
|
||||
}
|
||||
const contractInstance = new ERC721ProxyContract(
|
||||
|
@ -454,7 +454,7 @@ export class ERC721TokenWrapper extends ContractWrapper {
|
||||
private async _getTokenContractAsync(tokenAddress: string): Promise<ERC721TokenContract> {
|
||||
const normalizedTokenAddress = tokenAddress.toLowerCase();
|
||||
let tokenContract = this._tokenContractsByAddress[normalizedTokenAddress];
|
||||
if (!_.isUndefined(tokenContract)) {
|
||||
if (tokenContract !== undefined) {
|
||||
return tokenContract;
|
||||
}
|
||||
const contractInstance = new ERC721TokenContract(
|
||||
|
@ -195,7 +195,7 @@ export class EtherTokenWrapper extends ContractWrapper {
|
||||
}
|
||||
private async _getEtherTokenContractAsync(etherTokenAddress: string): Promise<WETH9Contract> {
|
||||
let etherTokenContract = this._etherTokenContractsByAddress[etherTokenAddress];
|
||||
if (!_.isUndefined(etherTokenContract)) {
|
||||
if (etherTokenContract !== undefined) {
|
||||
return etherTokenContract;
|
||||
}
|
||||
const contractInstance = new WETH9Contract(
|
||||
|
@ -77,10 +77,9 @@ export class ExchangeWrapper extends ContractWrapper {
|
||||
super(web3Wrapper, networkId, blockPollingIntervalMs);
|
||||
this._erc20TokenWrapper = erc20TokenWrapper;
|
||||
this._erc721TokenWrapper = erc721TokenWrapper;
|
||||
this.address = _.isUndefined(address) ? _getDefaultContractAddresses(networkId).exchange : address;
|
||||
this.zrxTokenAddress = _.isUndefined(zrxTokenAddress)
|
||||
? _getDefaultContractAddresses(networkId).zrxToken
|
||||
: zrxTokenAddress;
|
||||
this.address = address === undefined ? _getDefaultContractAddresses(networkId).exchange : address;
|
||||
this.zrxTokenAddress =
|
||||
zrxTokenAddress === undefined ? _getDefaultContractAddresses(networkId).zrxToken : zrxTokenAddress;
|
||||
}
|
||||
/**
|
||||
* Retrieve the address of an asset proxy by signature.
|
||||
@ -862,7 +861,7 @@ export class ExchangeWrapper extends ContractWrapper {
|
||||
): Promise<boolean> {
|
||||
assert.isETHAddressHex('signerAddress', signerAddress);
|
||||
assert.isETHAddressHex('validatorAddress', validatorAddress);
|
||||
if (!_.isUndefined(methodOpts)) {
|
||||
if (methodOpts !== undefined) {
|
||||
assert.doesConformToSchema('methodOpts', methodOpts, methodOptsSchema);
|
||||
}
|
||||
const normalizedSignerAddress = signerAddress.toLowerCase();
|
||||
@ -888,7 +887,7 @@ export class ExchangeWrapper extends ContractWrapper {
|
||||
public async isPreSignedAsync(hash: string, signerAddress: string, methodOpts: MethodOpts = {}): Promise<boolean> {
|
||||
assert.isHexString('hash', hash);
|
||||
assert.isETHAddressHex('signerAddress', signerAddress);
|
||||
if (!_.isUndefined(methodOpts)) {
|
||||
if (methodOpts !== undefined) {
|
||||
assert.doesConformToSchema('methodOpts', methodOpts, methodOptsSchema);
|
||||
}
|
||||
const exchangeInstance = await this._getExchangeContractAsync();
|
||||
@ -912,7 +911,7 @@ export class ExchangeWrapper extends ContractWrapper {
|
||||
@decorators.asyncZeroExErrorHandler
|
||||
public async isTransactionExecutedAsync(transactionHash: string, methodOpts: MethodOpts = {}): Promise<boolean> {
|
||||
assert.isHexString('transactionHash', transactionHash);
|
||||
if (!_.isUndefined(methodOpts)) {
|
||||
if (methodOpts !== undefined) {
|
||||
assert.doesConformToSchema('methodOpts', methodOpts, methodOptsSchema);
|
||||
}
|
||||
const exchangeInstance = await this._getExchangeContractAsync();
|
||||
@ -933,7 +932,7 @@ export class ExchangeWrapper extends ContractWrapper {
|
||||
@decorators.asyncZeroExErrorHandler
|
||||
public async getOrderInfoAsync(order: Order | SignedOrder, methodOpts: MethodOpts = {}): Promise<OrderInfo> {
|
||||
assert.doesConformToSchema('order', order, schemas.orderSchema);
|
||||
if (!_.isUndefined(methodOpts)) {
|
||||
if (methodOpts !== undefined) {
|
||||
assert.doesConformToSchema('methodOpts', methodOpts, methodOptsSchema);
|
||||
}
|
||||
const exchangeInstance = await this._getExchangeContractAsync();
|
||||
@ -953,7 +952,7 @@ export class ExchangeWrapper extends ContractWrapper {
|
||||
methodOpts: MethodOpts = {},
|
||||
): Promise<OrderInfo[]> {
|
||||
assert.doesConformToSchema('orders', orders, schemas.ordersSchema);
|
||||
if (!_.isUndefined(methodOpts)) {
|
||||
if (methodOpts !== undefined) {
|
||||
assert.doesConformToSchema('methodOpts', methodOpts, methodOptsSchema);
|
||||
}
|
||||
const exchangeInstance = await this._getExchangeContractAsync();
|
||||
@ -1162,9 +1161,10 @@ export class ExchangeWrapper extends ContractWrapper {
|
||||
const filledCancelledFetcher = new OrderFilledCancelledFetcher(this, BlockParamLiteral.Latest);
|
||||
|
||||
let fillableTakerAssetAmount;
|
||||
const shouldValidateRemainingOrderAmountIsFillable = _.isUndefined(opts.validateRemainingOrderAmountIsFillable)
|
||||
? true
|
||||
: opts.validateRemainingOrderAmountIsFillable;
|
||||
const shouldValidateRemainingOrderAmountIsFillable =
|
||||
opts.validateRemainingOrderAmountIsFillable === undefined
|
||||
? true
|
||||
: opts.validateRemainingOrderAmountIsFillable;
|
||||
if (opts.expectedFillTakerTokenAmount) {
|
||||
// If the caller has specified a taker fill amount, we use this for all validation
|
||||
fillableTakerAssetAmount = opts.expectedFillTakerTokenAmount;
|
||||
@ -1207,7 +1207,7 @@ export class ExchangeWrapper extends ContractWrapper {
|
||||
makerAssetAmount: BigNumber,
|
||||
takerAddress?: string,
|
||||
): Promise<void> {
|
||||
const toAddress = _.isUndefined(takerAddress) ? signedOrder.takerAddress : takerAddress;
|
||||
const toAddress = takerAddress === undefined ? signedOrder.takerAddress : takerAddress;
|
||||
const exchangeInstance = await this._getExchangeContractAsync();
|
||||
const makerAssetData = signedOrder.makerAssetData;
|
||||
const makerAssetDataProxyId = assetDataUtils.decodeAssetProxyId(signedOrder.makerAssetData);
|
||||
@ -1281,7 +1281,7 @@ export class ExchangeWrapper extends ContractWrapper {
|
||||
}
|
||||
// tslint:enable:no-unused-variable
|
||||
private async _getExchangeContractAsync(): Promise<ExchangeContract> {
|
||||
if (!_.isUndefined(this._exchangeContractIfExists)) {
|
||||
if (this._exchangeContractIfExists !== undefined) {
|
||||
return this._exchangeContractIfExists;
|
||||
}
|
||||
const contractInstance = new ExchangeContract(
|
||||
|
@ -50,13 +50,11 @@ export class ForwarderWrapper extends ContractWrapper {
|
||||
etherTokenAddress?: string,
|
||||
) {
|
||||
super(web3Wrapper, networkId);
|
||||
this.address = _.isUndefined(address) ? _getDefaultContractAddresses(networkId).exchange : address;
|
||||
this.zrxTokenAddress = _.isUndefined(zrxTokenAddress)
|
||||
? _getDefaultContractAddresses(networkId).zrxToken
|
||||
: zrxTokenAddress;
|
||||
this.etherTokenAddress = _.isUndefined(etherTokenAddress)
|
||||
? _getDefaultContractAddresses(networkId).etherToken
|
||||
: etherTokenAddress;
|
||||
this.address = address === undefined ? _getDefaultContractAddresses(networkId).exchange : address;
|
||||
this.zrxTokenAddress =
|
||||
zrxTokenAddress === undefined ? _getDefaultContractAddresses(networkId).zrxToken : zrxTokenAddress;
|
||||
this.etherTokenAddress =
|
||||
etherTokenAddress === undefined ? _getDefaultContractAddresses(networkId).etherToken : etherTokenAddress;
|
||||
}
|
||||
/**
|
||||
* Purchases as much of orders' makerAssets as possible by selling up to 95% of transaction's ETH value.
|
||||
@ -239,7 +237,7 @@ export class ForwarderWrapper extends ContractWrapper {
|
||||
return txHash;
|
||||
}
|
||||
private async _getForwarderContractAsync(): Promise<ForwarderContract> {
|
||||
if (!_.isUndefined(this._forwarderContractIfExists)) {
|
||||
if (this._forwarderContractIfExists !== undefined) {
|
||||
return this._forwarderContractIfExists;
|
||||
}
|
||||
const contractInstance = new ForwarderContract(
|
||||
|
@ -29,7 +29,7 @@ export class OrderValidatorWrapper extends ContractWrapper {
|
||||
*/
|
||||
constructor(web3Wrapper: Web3Wrapper, networkId: number, address?: string) {
|
||||
super(web3Wrapper, networkId);
|
||||
this.address = _.isUndefined(address) ? _getDefaultContractAddresses(networkId).orderValidator : address;
|
||||
this.address = address === undefined ? _getDefaultContractAddresses(networkId).orderValidator : address;
|
||||
}
|
||||
/**
|
||||
* Get an object conforming to OrderAndTraderInfo containing on-chain information of the provided order and address
|
||||
@ -170,7 +170,7 @@ export class OrderValidatorWrapper extends ContractWrapper {
|
||||
return result;
|
||||
}
|
||||
private async _getOrderValidatorContractAsync(): Promise<OrderValidatorContract> {
|
||||
if (!_.isUndefined(this._orderValidatorContractIfExists)) {
|
||||
if (this._orderValidatorContractIfExists !== undefined) {
|
||||
return this._orderValidatorContractIfExists;
|
||||
}
|
||||
const contractInstance = new OrderValidatorContract(
|
||||
|
@ -39,7 +39,7 @@ export class AssetBalanceAndProxyAllowanceFetcher implements AbstractBalanceAndP
|
||||
nestedAssetDataElement,
|
||||
userAddress,
|
||||
)).dividedToIntegerBy(nestedAmountElement);
|
||||
if (_.isUndefined(balance) || nestedAssetBalance.isLessThan(balance)) {
|
||||
if (balance === undefined || nestedAssetBalance.isLessThan(balance)) {
|
||||
balance = nestedAssetBalance;
|
||||
}
|
||||
}
|
||||
@ -81,7 +81,7 @@ export class AssetBalanceAndProxyAllowanceFetcher implements AbstractBalanceAndP
|
||||
nestedAssetDataElement,
|
||||
userAddress,
|
||||
)).dividedToIntegerBy(nestedAmountElement);
|
||||
if (_.isUndefined(proxyAllowance) || nestedAssetAllowance.isLessThan(proxyAllowance)) {
|
||||
if (proxyAllowance === undefined || nestedAssetAllowance.isLessThan(proxyAllowance)) {
|
||||
proxyAllowance = nestedAssetAllowance;
|
||||
}
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ export const assert = {
|
||||
allValues,
|
||||
)}`,
|
||||
);
|
||||
if (!_.isUndefined(value)) {
|
||||
if (value !== undefined) {
|
||||
const firstValue = _.head(allValues);
|
||||
sharedAssert.assert(
|
||||
firstValue === value,
|
||||
|
@ -28,7 +28,7 @@ export const filterUtils = {
|
||||
address,
|
||||
topics,
|
||||
};
|
||||
if (!_.isUndefined(blockRange)) {
|
||||
if (blockRange !== undefined) {
|
||||
filter = {
|
||||
...blockRange,
|
||||
...filter,
|
||||
@ -47,7 +47,7 @@ export const filterUtils = {
|
||||
if (!eventInput.indexed) {
|
||||
continue;
|
||||
}
|
||||
if (_.isUndefined(indexFilterValues[eventInput.name])) {
|
||||
if (indexFilterValues[eventInput.name] === undefined) {
|
||||
// Null is a wildcard topic in a JSON-RPC call
|
||||
topics.push(null);
|
||||
} else {
|
||||
@ -61,10 +61,10 @@ export const filterUtils = {
|
||||
return topics;
|
||||
},
|
||||
matchesFilter(log: LogEntry, filter: FilterObject): boolean {
|
||||
if (!_.isUndefined(filter.address) && log.address !== filter.address) {
|
||||
if (filter.address !== undefined && log.address !== filter.address) {
|
||||
return false;
|
||||
}
|
||||
if (!_.isUndefined(filter.topics)) {
|
||||
if (filter.topics !== undefined) {
|
||||
return filterUtils.doesMatchTopics(log.topics, filter.topics);
|
||||
}
|
||||
return true;
|
||||
|
@ -9,6 +9,7 @@
|
||||
"types": "lib/src/index.d.ts",
|
||||
"scripts": {
|
||||
"lint": "tslint --format stylish --project .",
|
||||
"fix": "tslint --fix --format stylish --project .",
|
||||
"clean": "shx rm -rf lib",
|
||||
"build": "tsc -b",
|
||||
"build:ci": "yarn build"
|
||||
|
@ -12,6 +12,7 @@
|
||||
"build:dev": "../../node_modules/.bin/webpack --mode development",
|
||||
"clean": "shx rm -f public/bundle*",
|
||||
"lint": "tslint --format stylish --project . 'ts/**/*.ts' 'ts/**/*.tsx'",
|
||||
"fix": "tslint --fix --format stylish --project . 'ts/**/*.ts' 'ts/**/*.tsx'",
|
||||
"dev": "webpack-dev-server --mode development --content-base public",
|
||||
"deploy:all": "npm run build; npm run deploy:compiler; npm run deploy:compiler:index; npm run deploy:coverage; npm run deploy:coverage:index; npm run deploy:profiler; npm run deploy:profiler:index; npm run deploy:trace; npm run deploy:trace:index;",
|
||||
"deploy:compiler": "DIR_NAME=./public/. BUCKET=s3://sol-compiler.com yarn s3:sync --exclude 'bundle-cov*' --exclude 'bundle-trace*' --exclude 'bundle-profiler*'",
|
||||
|
@ -1,4 +1,3 @@
|
||||
import * as _ from 'lodash';
|
||||
import * as React from 'react';
|
||||
import styled from 'styled-components';
|
||||
|
||||
@ -47,10 +46,10 @@ const Container = styled.div`
|
||||
|
||||
const Base = styled.div<CodeProps>`
|
||||
font-size: 0.875rem;
|
||||
color: ${props => (_.isUndefined(props.language) ? colors.white : 'inherit')};
|
||||
color: ${props => (props.language === undefined ? colors.white : 'inherit')};
|
||||
background-color: ${props =>
|
||||
props.isLight ? 'rgba(255,255,255,.15)' : _.isUndefined(props.language) ? colors.black : '#F1F4F5'};
|
||||
white-space: ${props => (_.isUndefined(props.language) ? 'nowrap' : '')};
|
||||
props.isLight ? 'rgba(255,255,255,.15)' : props.language === undefined ? colors.black : '#F1F4F5'};
|
||||
white-space: ${props => (props.language === undefined ? 'nowrap' : '')};
|
||||
position: relative;
|
||||
|
||||
${props =>
|
||||
@ -143,7 +142,7 @@ class Code extends React.Component<CodeProps, CodeState> {
|
||||
<Container>
|
||||
<Base language={language} isDiff={isDiff} isLight={isLight}>
|
||||
<StyledPre isDiff={isDiff}>
|
||||
{_.isUndefined(hlCode) ? (
|
||||
{hlCode === undefined ? (
|
||||
<code>{children}</code>
|
||||
) : (
|
||||
<StyledCodeDiff
|
||||
|
@ -70,7 +70,7 @@ const ContentBlock: React.StatelessComponent<ContentBlockProps> = props => {
|
||||
return (
|
||||
<Base>
|
||||
<Title color={props.colors}>{props.title}</Title>
|
||||
{_.isUndefined(children) ? null : <Content>{children}</Content>}
|
||||
{children === undefined ? null : <Content>{children}</Content>}
|
||||
</Base>
|
||||
);
|
||||
};
|
||||
|
@ -17,7 +17,8 @@
|
||||
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
|
||||
"coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info",
|
||||
"clean": "shx rm -rf lib",
|
||||
"lint": "tslint --format stylish --project ."
|
||||
"lint": "tslint --format stylish --project .",
|
||||
"fix": "tslint --format stylish --fix --project ."
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"repository": {
|
||||
|
@ -72,7 +72,7 @@ export class BlockchainLifecycle {
|
||||
logUtils.warn('Done mining the minimum number of blocks.');
|
||||
}
|
||||
private async _getNodeTypeAsync(): Promise<NodeType> {
|
||||
if (_.isUndefined(this._nodeType)) {
|
||||
if (this._nodeType === undefined) {
|
||||
this._nodeType = await this._web3Wrapper.getNodeTypeAsync();
|
||||
}
|
||||
return this._nodeType;
|
||||
|
@ -12,7 +12,7 @@ export const callbackErrorReporter = {
|
||||
): <T>(f?: ((value: T) => void) | undefined) => (value: T) => void {
|
||||
const callback = <T>(f?: (value: T) => void) => {
|
||||
const wrapped = (value: T) => {
|
||||
if (_.isUndefined(f)) {
|
||||
if (f === undefined) {
|
||||
done();
|
||||
return;
|
||||
}
|
||||
@ -35,10 +35,10 @@ export const callbackErrorReporter = {
|
||||
): <T>(f?: ((value: T) => void) | undefined) => (error: Error | null, value: T | undefined) => void {
|
||||
const callback = <T>(f?: (value: T) => void) => {
|
||||
const wrapped = (error: Error | null, value: T | undefined) => {
|
||||
if (!_.isNull(error)) {
|
||||
if (error !== null) {
|
||||
done(error);
|
||||
} else {
|
||||
if (_.isUndefined(f)) {
|
||||
if (f === undefined) {
|
||||
done();
|
||||
return;
|
||||
}
|
||||
@ -61,7 +61,7 @@ export const callbackErrorReporter = {
|
||||
errMsg: string,
|
||||
): <T>(error: Error | null, value: T | undefined) => void {
|
||||
const wrapped = <T>(error: Error | null, _value: T | undefined) => {
|
||||
if (_.isNull(error)) {
|
||||
if (error === null) {
|
||||
done(new Error('Expected callback to receive an error'));
|
||||
} else {
|
||||
try {
|
||||
|
@ -14,7 +14,7 @@ export const env = {
|
||||
const envVarValue = process.env[key];
|
||||
if (envVarValue === 'true') {
|
||||
isTrue = true;
|
||||
} else if (envVarValue === 'false' || _.isUndefined(envVarValue)) {
|
||||
} else if (envVarValue === 'false' || envVarValue === undefined) {
|
||||
isTrue = false;
|
||||
} else {
|
||||
throw new Error(
|
||||
|
@ -24,9 +24,9 @@ export interface Web3Config {
|
||||
export const web3Factory = {
|
||||
getRpcProvider(config: Web3Config = {}): Web3ProviderEngine {
|
||||
const provider = new Web3ProviderEngine();
|
||||
const hasAddresses = _.isUndefined(config.hasAddresses) || config.hasAddresses;
|
||||
const hasAddresses = config.hasAddresses === undefined || config.hasAddresses;
|
||||
config.shouldUseFakeGasEstimate =
|
||||
_.isUndefined(config.shouldUseFakeGasEstimate) || config.shouldUseFakeGasEstimate;
|
||||
config.shouldUseFakeGasEstimate === undefined || config.shouldUseFakeGasEstimate;
|
||||
if (!hasAddresses) {
|
||||
provider.addProvider(new EmptyWalletSubprovider());
|
||||
}
|
||||
@ -41,13 +41,13 @@ export const web3Factory = {
|
||||
};
|
||||
const shouldUseInProcessGanache = !!config.shouldUseInProcessGanache;
|
||||
if (shouldUseInProcessGanache) {
|
||||
if (!_.isUndefined(config.rpcUrl)) {
|
||||
if (config.rpcUrl !== undefined) {
|
||||
throw new Error('Cannot use both GanacheSubrovider and RPCSubprovider');
|
||||
}
|
||||
const shouldThrowErrorsOnGanacheRPCResponse =
|
||||
_.isUndefined(config.shouldThrowErrorsOnGanacheRPCResponse) ||
|
||||
config.shouldThrowErrorsOnGanacheRPCResponse === undefined ||
|
||||
config.shouldThrowErrorsOnGanacheRPCResponse;
|
||||
if (!_.isUndefined(config.ganacheDatabasePath)) {
|
||||
if (config.ganacheDatabasePath !== undefined) {
|
||||
const doesDatabaseAlreadyExist = fs.existsSync(config.ganacheDatabasePath);
|
||||
if (!doesDatabaseAlreadyExist) {
|
||||
// Working with local DB snapshot. Ganache requires this directory to exist
|
||||
|
@ -12,6 +12,7 @@
|
||||
"build:ci": "yarn build",
|
||||
"clean": "shx rm -rf lib generated_docs",
|
||||
"lint": "tslint --format stylish --project .",
|
||||
"fix": "tslint --fix --format stylish --project .",
|
||||
"docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --tsconfig typedoc-tsconfig.json --json $JSON_FILE_PATH $PROJECT_FILES"
|
||||
},
|
||||
"config": {
|
||||
|
@ -8,7 +8,8 @@
|
||||
"build": "yarn tsc -b",
|
||||
"build:ci": "yarn build",
|
||||
"clean": "shx rm -rf lib src/generated_contract_wrappers",
|
||||
"lint": "tslint --format stylish --project ."
|
||||
"lint": "tslint --format stylish --project .",
|
||||
"fix": "tslint --format stylish --fix --project ."
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"repository": {
|
||||
|
@ -13,6 +13,7 @@
|
||||
"build:ci": "yarn build",
|
||||
"dev": "dotenv webpack-dev-server -- --mode development",
|
||||
"lint": "tslint --format stylish --project .",
|
||||
"fix": "tslint --fix --format stylish --project .",
|
||||
"test": "jest",
|
||||
"test:coverage": "jest --coverage",
|
||||
"rebuild_and_test": "run-s clean build test",
|
||||
|
@ -40,9 +40,9 @@ export class BuyButton extends React.PureComponent<BuyButtonProps> {
|
||||
};
|
||||
public render(): React.ReactNode {
|
||||
const { buyQuote, accountAddress, selectedAsset } = this.props;
|
||||
const shouldDisableButton = _.isUndefined(buyQuote) || _.isUndefined(accountAddress);
|
||||
const shouldDisableButton = buyQuote === undefined || accountAddress === undefined;
|
||||
const buttonText =
|
||||
!_.isUndefined(selectedAsset) && selectedAsset.metaData.assetProxyId === AssetProxyId.ERC20
|
||||
selectedAsset !== undefined && selectedAsset.metaData.assetProxyId === AssetProxyId.ERC20
|
||||
? `Buy ${selectedAsset.metaData.symbol.toUpperCase()}`
|
||||
: 'Buy Now';
|
||||
return (
|
||||
@ -59,13 +59,13 @@ export class BuyButton extends React.PureComponent<BuyButtonProps> {
|
||||
private readonly _handleClick = async () => {
|
||||
// The button is disabled when there is no buy quote anyway.
|
||||
const { buyQuote, assetBuyer, affiliateInfo, accountAddress, accountEthBalanceInWei, web3Wrapper } = this.props;
|
||||
if (_.isUndefined(buyQuote) || _.isUndefined(accountAddress)) {
|
||||
if (buyQuote === undefined || accountAddress === undefined) {
|
||||
return;
|
||||
}
|
||||
this.props.onValidationPending(buyQuote);
|
||||
const ethNeededForBuy = buyQuote.worstCaseQuoteInfo.totalEthAmount;
|
||||
// if we don't have a balance for the user, let the transaction through, it will be handled by the wallet
|
||||
const hasSufficientEth = _.isUndefined(accountEthBalanceInWei) || accountEthBalanceInWei.gte(ethNeededForBuy);
|
||||
const hasSufficientEth = accountEthBalanceInWei === undefined || accountEthBalanceInWei.gte(ethNeededForBuy);
|
||||
if (!hasSufficientEth) {
|
||||
analytics.trackBuyNotEnoughEth(buyQuote);
|
||||
this.props.onValidationFail(buyQuote, ZeroExInstantError.InsufficientETH);
|
||||
|
@ -46,7 +46,7 @@ export class ERC20AssetAmountInput extends React.PureComponent<ERC20AssetAmountI
|
||||
const { asset } = this.props;
|
||||
return (
|
||||
<Container whiteSpace="nowrap">
|
||||
{_.isUndefined(asset) ? this._renderTokenSelectionContent() : this._renderContentForAsset(asset)}
|
||||
{asset === undefined ? this._renderTokenSelectionContent() : this._renderContentForAsset(asset)}
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
@ -92,7 +92,7 @@ export class ERC20AssetAmountInput extends React.PureComponent<ERC20AssetAmountI
|
||||
private readonly _renderTokenSelectionContent = (): React.ReactNode => {
|
||||
const { numberOfAssetsAvailable } = this.props;
|
||||
let text = 'Select Token';
|
||||
if (_.isUndefined(numberOfAssetsAvailable)) {
|
||||
if (numberOfAssetsAvailable === undefined) {
|
||||
text = 'Loading...';
|
||||
} else if (numberOfAssetsAvailable === 0) {
|
||||
text = 'Tokens Unavailable';
|
||||
@ -134,14 +134,14 @@ export class ERC20AssetAmountInput extends React.PureComponent<ERC20AssetAmountI
|
||||
// We don't want to allow opening the token selection panel if there are no assets.
|
||||
// Since styles are inferred from the presence of a click handler, we want to return undefined
|
||||
// instead of providing a noop.
|
||||
if (!this._areAnyAssetsAvailable() || _.isUndefined(this.props.onSelectAssetClick)) {
|
||||
if (!this._areAnyAssetsAvailable() || this.props.onSelectAssetClick === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
return this._handleSelectAssetClick;
|
||||
};
|
||||
private readonly _areAnyAssetsAvailable = (): boolean => {
|
||||
const { numberOfAssetsAvailable } = this.props;
|
||||
return !_.isUndefined(numberOfAssetsAvailable) && numberOfAssetsAvailable > 0;
|
||||
return numberOfAssetsAvailable !== undefined && numberOfAssetsAvailable > 0;
|
||||
};
|
||||
private readonly _handleSelectAssetClick = (): void => {
|
||||
if (this.props.onSelectAssetClick) {
|
||||
@ -151,7 +151,7 @@ export class ERC20AssetAmountInput extends React.PureComponent<ERC20AssetAmountI
|
||||
// For assets with symbols of different length,
|
||||
// start scaling the input at different character lengths
|
||||
private readonly _textLengthThresholdForAsset = (asset?: ERC20Asset): number => {
|
||||
if (_.isUndefined(asset)) {
|
||||
if (asset === undefined) {
|
||||
return 3;
|
||||
}
|
||||
const symbol = asset.metaData.symbol;
|
||||
|
@ -161,9 +161,9 @@ class TokenSelectorRowIcon extends React.PureComponent<TokenSelectorRowIconProps
|
||||
|
||||
const TokenIcon = getTokenIcon(token.metaData.symbol);
|
||||
const displaySymbol = assetUtils.bestNameForAsset(token);
|
||||
if (!_.isUndefined(iconUrlIfExists)) {
|
||||
if (iconUrlIfExists !== undefined) {
|
||||
return <img src={iconUrlIfExists} />;
|
||||
} else if (!_.isUndefined(TokenIcon)) {
|
||||
} else if (TokenIcon !== undefined) {
|
||||
return <TokenIcon />;
|
||||
} else {
|
||||
return (
|
||||
|
@ -62,7 +62,7 @@ export class InstantHeading extends React.PureComponent<InstantHeadingProps, {}>
|
||||
|
||||
private _renderAmountsSection(): React.ReactNode {
|
||||
if (
|
||||
_.isUndefined(this.props.totalEthBaseUnitAmount) &&
|
||||
this.props.totalEthBaseUnitAmount === undefined &&
|
||||
this.props.quoteRequestState !== AsyncProcessState.Pending
|
||||
) {
|
||||
return null;
|
||||
@ -106,7 +106,7 @@ export class InstantHeading extends React.PureComponent<InstantHeadingProps, {}>
|
||||
if (this.props.quoteRequestState === AsyncProcessState.Pending) {
|
||||
return <AmountPlaceholder isPulsating={true} color={PLACEHOLDER_COLOR} />;
|
||||
}
|
||||
if (_.isUndefined(this.props.selectedAssetUnitAmount)) {
|
||||
if (this.props.selectedAssetUnitAmount === undefined) {
|
||||
return <AmountPlaceholder isPulsating={false} color={PLACEHOLDER_COLOR} />;
|
||||
}
|
||||
return amountFunction();
|
||||
|
@ -97,7 +97,7 @@ export class OrderDetails extends React.PureComponent<OrderDetailsProps> {
|
||||
private _displayAmountOrPlaceholder(weiAmount?: BigNumber): React.ReactNode {
|
||||
const { baseCurrency, isLoading } = this.props;
|
||||
|
||||
if (_.isUndefined(weiAmount)) {
|
||||
if (weiAmount === undefined) {
|
||||
return (
|
||||
<Container opacity={0.5}>
|
||||
<AmountPlaceholder color={ColorOption.lightGrey} isPulsating={isLoading} />
|
||||
@ -123,10 +123,10 @@ export class OrderDetails extends React.PureComponent<OrderDetailsProps> {
|
||||
|
||||
// Display as 0 if we have a selected asset
|
||||
const displayNumTokens =
|
||||
assetName && assetName !== DEFAULT_UNKOWN_ASSET_NAME && _.isUndefined(numTokens)
|
||||
assetName && assetName !== DEFAULT_UNKOWN_ASSET_NAME && numTokens === undefined
|
||||
? new BigNumber(0)
|
||||
: numTokens;
|
||||
if (!_.isUndefined(displayNumTokens)) {
|
||||
if (displayNumTokens !== undefined) {
|
||||
let numTokensWithSymbol: React.ReactNode = displayNumTokens.toString();
|
||||
if (assetName) {
|
||||
numTokensWithSymbol += ` ${assetName}`;
|
||||
@ -153,8 +153,8 @@ export class OrderDetails extends React.PureComponent<OrderDetailsProps> {
|
||||
const buyQuoteAccessor = oc(this.props.buyQuoteInfo);
|
||||
const assetTotalInWei = buyQuoteAccessor.assetEthAmount();
|
||||
const selectedAssetUnitAmount = this.props.selectedAssetUnitAmount;
|
||||
return !_.isUndefined(assetTotalInWei) &&
|
||||
!_.isUndefined(selectedAssetUnitAmount) &&
|
||||
return assetTotalInWei !== undefined &&
|
||||
selectedAssetUnitAmount !== undefined &&
|
||||
!selectedAssetUnitAmount.eq(BIG_NUMBER_ZERO)
|
||||
? assetTotalInWei.div(selectedAssetUnitAmount).integerValue(BigNumber.ROUND_CEIL)
|
||||
: undefined;
|
||||
|
@ -36,7 +36,7 @@ export class ScalingAmountInput extends React.PureComponent<ScalingAmountInputPr
|
||||
public constructor(props: ScalingAmountInputProps) {
|
||||
super(props);
|
||||
this.state = {
|
||||
stringValue: _.isUndefined(props.value) ? '' : props.value.toString(),
|
||||
stringValue: props.value === undefined ? '' : props.value.toString(),
|
||||
};
|
||||
}
|
||||
public componentDidUpdate(): void {
|
||||
@ -49,7 +49,7 @@ export class ScalingAmountInput extends React.PureComponent<ScalingAmountInputPr
|
||||
// we dont expect to ever get into this state, but let's make sure
|
||||
// we reset if we do since we're dealing with important numbers
|
||||
this.setState({
|
||||
stringValue: _.isUndefined(currentValue) ? '' : currentValue.toString(),
|
||||
stringValue: currentValue === undefined ? '' : currentValue.toString(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user