aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2019-01-25 04:05:44 +0800
committerfragosti <francesco.agosti93@gmail.com>2019-01-25 04:05:44 +0800
commit5b06595a6b6d459d53840d066fb204c0a9e3ed02 (patch)
treea5e9ed5c805cd69bd2f78525ac5b02cb9cdebdbf /packages
parent44aafe4d78059267c9279fdf747fd51e6c3b26e1 (diff)
parent92cbff67d196abc7755e82087dbb1831485485d1 (diff)
downloaddexon-0x-contracts-5b06595a6b6d459d53840d066fb204c0a9e3ed02.tar
dexon-0x-contracts-5b06595a6b6d459d53840d066fb204c0a9e3ed02.tar.gz
dexon-0x-contracts-5b06595a6b6d459d53840d066fb204c0a9e3ed02.tar.bz2
dexon-0x-contracts-5b06595a6b6d459d53840d066fb204c0a9e3ed02.tar.lz
dexon-0x-contracts-5b06595a6b6d459d53840d066fb204c0a9e3ed02.tar.xz
dexon-0x-contracts-5b06595a6b6d459d53840d066fb204c0a9e3ed02.tar.zst
dexon-0x-contracts-5b06595a6b6d459d53840d066fb204c0a9e3ed02.zip
Merge branch 'development' of https://github.com/0xProject/0x-monorepo into development
Diffstat (limited to 'packages')
-rw-r--r--packages/0x.js/CHANGELOG.json18
-rw-r--r--packages/0x.js/CHANGELOG.md4
-rw-r--r--packages/0x.js/package.json8
-rw-r--r--packages/abi-gen-templates/CHANGELOG.json9
-rw-r--r--packages/abi-gen-wrappers/CHANGELOG.json9
-rw-r--r--packages/abi-gen/CHANGELOG.json9
-rw-r--r--packages/assert/CHANGELOG.json9
-rw-r--r--packages/assert/src/index.ts4
-rw-r--r--packages/asset-buyer/CHANGELOG.json27
-rw-r--r--packages/asset-buyer/CHANGELOG.md4
-rw-r--r--packages/asset-buyer/package.json7
-rw-r--r--packages/asset-buyer/src/asset_buyer.ts47
-rw-r--r--packages/asset-buyer/src/index.ts3
-rw-r--r--packages/asset-buyer/src/types.ts19
-rw-r--r--packages/asset-buyer/src/utils/buy_quote_calculator.ts12
-rw-r--r--packages/asset-buyer/src/utils/calculate_liquidity.ts34
-rw-r--r--packages/asset-buyer/src/utils/order_provider_response_processor.ts7
-rw-r--r--packages/asset-buyer/src/utils/order_utils.ts28
-rw-r--r--packages/asset-buyer/test/asset_buyer_test.ts212
-rw-r--r--packages/asset-buyer/test/buy_quote_calculator_test.ts6
-rw-r--r--packages/asset-buyer/test/utils/mocks.ts68
-rw-r--r--packages/base-contract/CHANGELOG.json9
-rw-r--r--packages/base-contract/src/index.ts4
-rw-r--r--packages/connect/CHANGELOG.json9
-rw-r--r--packages/contract-wrappers/CHANGELOG.json18
-rw-r--r--packages/contract-wrappers/CHANGELOG.md4
-rw-r--r--packages/contract-wrappers/package.json6
-rw-r--r--packages/contract-wrappers/src/contract_wrappers/erc20_token_wrapper.ts6
-rw-r--r--packages/contract-wrappers/src/fetchers/asset_balance_and_proxy_allowance_fetcher.ts4
-rw-r--r--packages/contract-wrappers/src/utils/exchange_transfer_simulator.ts4
-rw-r--r--packages/contract-wrappers/src/utils/utils.ts6
-rw-r--r--packages/contract-wrappers/test/ether_token_wrapper_test.ts6
-rw-r--r--packages/dev-tools-pages/.gitignore4
-rw-r--r--packages/dev-tools-pages/assets/crawl.html33
-rw-r--r--packages/dev-tools-pages/assets/fonts/.gitkeep0
-rw-r--r--packages/dev-tools-pages/assets/fonts/MaisonNeue-Bold-subset.woff2bin0 -> 11248 bytes
-rw-r--r--packages/dev-tools-pages/assets/fonts/MaisonNeue-Book-subset.woff2bin0 -> 11232 bytes
-rw-r--r--packages/dev-tools-pages/package.json24
-rw-r--r--packages/dev-tools-pages/pages.js24
-rw-r--r--packages/dev-tools-pages/ts/components/call_to_action.tsx40
-rw-r--r--packages/dev-tools-pages/ts/components/code.tsx3
-rw-r--r--packages/dev-tools-pages/ts/components/compiler.tsx12
-rw-r--r--packages/dev-tools-pages/ts/components/footer.tsx12
-rw-r--r--packages/dev-tools-pages/ts/components/header.tsx2
-rw-r--r--packages/dev-tools-pages/ts/components/hero.tsx6
-rw-r--r--packages/dev-tools-pages/ts/components/trace.tsx13
-rw-r--r--packages/dev-tools-pages/ts/context/compiler.tsx1
-rw-r--r--packages/dev-tools-pages/ts/context/coverage.tsx (renamed from packages/dev-tools-pages/ts/context/cov.tsx)5
-rw-r--r--packages/dev-tools-pages/ts/context/index.tsx1
-rw-r--r--packages/dev-tools-pages/ts/context/profiler.tsx1
-rw-r--r--packages/dev-tools-pages/ts/context/trace.tsx1
-rw-r--r--packages/dev-tools-pages/ts/pages/compiler.tsx30
-rw-r--r--packages/dev-tools-pages/ts/pages/coverage.tsx (renamed from packages/dev-tools-pages/ts/pages/cov.tsx)76
-rw-r--r--packages/dev-tools-pages/ts/pages/profiler.tsx62
-rw-r--r--packages/dev-tools-pages/ts/pages/trace.tsx59
-rw-r--r--packages/dev-tools-pages/webpack.config.js3
-rw-r--r--packages/dev-utils/CHANGELOG.json9
-rw-r--r--packages/devnet/docker-compose.yml8
-rw-r--r--packages/devnet/genesis.json2
-rwxr-xr-xpackages/devnet/run.sh1
-rw-r--r--packages/ethereum-types/CHANGELOG.json9
-rw-r--r--packages/ethereum-types/package.json2
-rw-r--r--packages/fill-scenarios/CHANGELOG.json9
-rw-r--r--packages/instant/CHANGELOG.json9
-rw-r--r--packages/instant/README.md6
-rw-r--r--packages/instant/package.json4
-rw-r--r--packages/instant/src/components/order_details.tsx4
-rw-r--r--packages/instant/src/constants.ts2
-rw-r--r--packages/instant/src/containers/selected_erc20_asset_amount_input.ts2
-rw-r--r--packages/instant/src/index.umd.ts42
-rw-r--r--packages/instant/src/redux/async_data.ts2
-rw-r--r--packages/instant/src/util/asset.ts9
-rw-r--r--packages/instant/src/util/format.ts8
-rw-r--r--packages/instant/src/util/gas_price_estimator.ts2
-rw-r--r--packages/instant/src/util/maybe_big_number.ts2
-rw-r--r--packages/json-schemas/CHANGELOG.json9
-rw-r--r--packages/metacoin/package.json10
-rw-r--r--packages/migrations/CHANGELOG.json9
-rw-r--r--packages/monorepo-scripts/CHANGELOG.json9
-rw-r--r--packages/monorepo-scripts/package.json2
-rw-r--r--packages/monorepo-scripts/src/utils/utils.ts2
-rw-r--r--packages/order-utils/CHANGELOG.json9
-rw-r--r--packages/order-utils/package.json2
-rw-r--r--packages/order-utils/src/crypto.ts3
-rw-r--r--packages/order-utils/src/exchange_transfer_simulator.ts4
-rw-r--r--packages/order-utils/src/market_utils.ts4
-rw-r--r--packages/order-utils/src/order_state_utils.ts12
-rw-r--r--packages/order-utils/src/order_validation_utils.ts8
-rw-r--r--packages/order-utils/src/rate_utils.ts6
-rw-r--r--packages/order-utils/src/remaining_fillable_calculator.ts6
-rw-r--r--packages/order-utils/src/salt.ts2
-rw-r--r--packages/order-utils/src/utils.ts6
-rw-r--r--packages/order-utils/test/remaining_fillable_calculator_test.ts2
-rw-r--r--packages/order-utils/test/signature_utils_test.ts4
-rw-r--r--packages/order-watcher/CHANGELOG.json18
-rw-r--r--packages/order-watcher/CHANGELOG.md4
-rw-r--r--packages/order-watcher/package.json6
-rw-r--r--packages/order-watcher/src/order_watcher/expiration_watcher.ts2
-rw-r--r--packages/order-watcher/src/utils/utils.ts2
-rw-r--r--packages/order-watcher/test/order_watcher_test.ts6
-rw-r--r--packages/pipeline/package.json2
-rw-r--r--packages/pipeline/src/utils/transformers/number_to_bigint.ts2
-rw-r--r--packages/react-docs/CHANGELOG.json9
-rw-r--r--packages/react-shared/CHANGELOG.json9
-rw-r--r--packages/react-shared/package.json2
-rw-r--r--packages/sol-compiler/CHANGELOG.json9
-rw-r--r--packages/sol-compiler/package.json2
-rw-r--r--packages/sol-coverage/CHANGELOG.json18
-rw-r--r--packages/sol-coverage/CHANGELOG.md4
-rw-r--r--packages/sol-coverage/package.json4
-rw-r--r--packages/sol-coverage/src/coverage_subprovider.ts4
-rw-r--r--packages/sol-doc/CHANGELOG.json9
-rw-r--r--packages/sol-doc/package.json2
-rw-r--r--packages/sol-profiler/CHANGELOG.json27
-rw-r--r--packages/sol-profiler/CHANGELOG.md4
-rw-r--r--packages/sol-profiler/package.json4
-rw-r--r--packages/sol-resolver/CHANGELOG.json9
-rw-r--r--packages/sol-trace/CHANGELOG.json18
-rw-r--r--packages/sol-trace/CHANGELOG.md4
-rw-r--r--packages/sol-trace/package.json4
-rw-r--r--packages/sol-trace/src/revert_trace_subprovider.ts17
-rw-r--r--packages/sol-tracing-utils/CHANGELOG.json48
-rw-r--r--packages/sol-tracing-utils/CHANGELOG.md6
-rw-r--r--packages/sol-tracing-utils/package.json3
-rw-r--r--packages/sol-tracing-utils/src/artifact_adapters/sol_compiler_artifact_adapter.ts19
-rw-r--r--packages/sol-tracing-utils/src/collect_coverage_entries.ts14
-rw-r--r--packages/sol-tracing-utils/src/get_source_range_snippet.ts175
-rw-r--r--packages/sol-tracing-utils/src/trace_collection_subprovider.ts2
-rw-r--r--packages/sol-tracing-utils/src/trace_info_subprovider.ts2
-rw-r--r--packages/sol-tracing-utils/src/types.ts4
-rw-r--r--packages/sol-tracing-utils/src/utils.ts50
-rw-r--r--packages/sol-tracing-utils/test/collect_coverage_entries_test.ts3
-rw-r--r--packages/sra-spec/CHANGELOG.json9
-rw-r--r--packages/subproviders/CHANGELOG.json13
-rw-r--r--packages/subproviders/package.json4
-rw-r--r--packages/testnet-faucets/package.json4
-rw-r--r--packages/testnet-faucets/src/ts/dispense_asset_tasks.ts4
-rw-r--r--packages/testnet-faucets/src/ts/handler.ts6
-rw-r--r--packages/tslint-config/CHANGELOG.json9
-rw-r--r--packages/types/CHANGELOG.json9
-rw-r--r--packages/types/package.json2
-rw-r--r--packages/typescript-typings/CHANGELOG.json9
-rw-r--r--packages/typescript-typings/package.json2
-rw-r--r--packages/utils/CHANGELOG.json9
-rw-r--r--packages/utils/package.json4
-rw-r--r--packages/utils/src/abi_decoder.ts2
-rw-r--r--packages/utils/src/abi_encoder/evm_data_types/bool.ts4
-rw-r--r--packages/utils/src/abi_encoder/evm_data_types/int.ts6
-rw-r--r--packages/utils/src/abi_encoder/evm_data_types/uint.ts2
-rw-r--r--packages/utils/src/abi_encoder/utils/math.ts12
-rw-r--r--packages/utils/src/sign_typed_data_utils.ts5
-rw-r--r--packages/utils/test/abi_encoder/evm_data_types_test.ts2
-rw-r--r--packages/web3-wrapper/CHANGELOG.json13
-rw-r--r--packages/web3-wrapper/package.json6
-rw-r--r--packages/web3-wrapper/src/utils.ts8
-rw-r--r--packages/web3-wrapper/test/web3_wrapper_test.ts8
-rw-r--r--packages/website/md/docs/sol_coverage/installation.md2
-rw-r--r--packages/website/md/docs/sol_coverage/introduction.md2
-rw-r--r--packages/website/md/docs/sol_coverage/usage.md34
-rw-r--r--packages/website/md/docs/sol_profiler/installation.md2
-rw-r--r--packages/website/md/docs/sol_profiler/usage.md38
-rw-r--r--packages/website/md/docs/sol_trace/installation.md6
-rw-r--r--packages/website/md/docs/sol_trace/introduction.md2
-rw-r--r--packages/website/md/docs/sol_trace/usage.md44
-rw-r--r--packages/website/package.json6
-rw-r--r--packages/website/ts/blockchain.ts2
-rw-r--r--packages/website/ts/components/fill_order.tsx4
-rw-r--r--packages/website/ts/pages/documentation/docs_home.tsx77
-rw-r--r--packages/website/ts/types.ts5
-rw-r--r--packages/website/ts/utils/utils.ts2
170 files changed, 1569 insertions, 609 deletions
diff --git a/packages/0x.js/CHANGELOG.json b/packages/0x.js/CHANGELOG.json
index a849a35a2..20778f8bb 100644
--- a/packages/0x.js/CHANGELOG.json
+++ b/packages/0x.js/CHANGELOG.json
@@ -1,5 +1,23 @@
[
{
+ "version": "4.0.0",
+ "changes": [
+ {
+ "note": "Upgrade the bignumber.js to v8.0.2",
+ "pr": 1517
+ }
+ ]
+ },
+ {
+ "timestamp": 1547747677,
+ "version": "3.0.3",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"timestamp": 1547561734,
"version": "3.0.2",
"changes": [
diff --git a/packages/0x.js/CHANGELOG.md b/packages/0x.js/CHANGELOG.md
index c389c0e00..b0279f097 100644
--- a/packages/0x.js/CHANGELOG.md
+++ b/packages/0x.js/CHANGELOG.md
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
+## v3.0.3 - _January 17, 2019_
+
+ * Dependencies updated
+
## v3.0.2 - _January 15, 2019_
* Dependencies updated
diff --git a/packages/0x.js/package.json b/packages/0x.js/package.json
index ca990c0a7..64054d288 100644
--- a/packages/0x.js/package.json
+++ b/packages/0x.js/package.json
@@ -1,6 +1,6 @@
{
"name": "0x.js",
- "version": "3.0.2",
+ "version": "3.0.3",
"engines": {
"node": ">=6.12"
},
@@ -54,7 +54,7 @@
"awesome-typescript-loader": "^5.2.1",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
- "chai-bignumber": "^2.0.1",
+ "chai-bignumber": "^3.0.0",
"copyfiles": "^2.0.0",
"dirty-chai": "^2.0.1",
"make-promises-safe": "^1.1.0",
@@ -74,9 +74,9 @@
"dependencies": {
"@0x/assert": "^1.0.23",
"@0x/base-contract": "^3.0.13",
- "@0x/contract-wrappers": "^5.0.0",
+ "@0x/contract-wrappers": "^5.0.1",
"@0x/order-utils": "^3.1.2",
- "@0x/order-watcher": "^2.4.2",
+ "@0x/order-watcher": "^2.4.3",
"@0x/subproviders": "^2.1.11",
"@0x/types": "^1.5.2",
"@0x/typescript-typings": "^3.0.8",
diff --git a/packages/abi-gen-templates/CHANGELOG.json b/packages/abi-gen-templates/CHANGELOG.json
index b825c4f1f..7d444d0ca 100644
--- a/packages/abi-gen-templates/CHANGELOG.json
+++ b/packages/abi-gen-templates/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "version": "2.0.0",
+ "changes": [
+ {
+ "note": "Upgrade the bignumber.js to v8.0.2",
+ "pr": 1517
+ }
+ ]
+ },
+ {
"timestamp": 1547561734,
"version": "1.0.2",
"changes": [
diff --git a/packages/abi-gen-wrappers/CHANGELOG.json b/packages/abi-gen-wrappers/CHANGELOG.json
index 381b37cda..c604302b5 100644
--- a/packages/abi-gen-wrappers/CHANGELOG.json
+++ b/packages/abi-gen-wrappers/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "version": "3.0.0",
+ "changes": [
+ {
+ "note": "Upgrade the bignumber.js to v8.0.2",
+ "pr": 1517
+ }
+ ]
+ },
+ {
"version": "2.2.0",
"changes": [
{
diff --git a/packages/abi-gen/CHANGELOG.json b/packages/abi-gen/CHANGELOG.json
index ab516e4c6..173617b65 100644
--- a/packages/abi-gen/CHANGELOG.json
+++ b/packages/abi-gen/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "version": "2.0.0",
+ "changes": [
+ {
+ "note": "Upgrade the bignumber.js to v8.0.2",
+ "pr": 1517
+ }
+ ]
+ },
+ {
"timestamp": 1547561734,
"version": "1.0.22",
"changes": [
diff --git a/packages/assert/CHANGELOG.json b/packages/assert/CHANGELOG.json
index 0210f9400..278b7dfa1 100644
--- a/packages/assert/CHANGELOG.json
+++ b/packages/assert/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "version": "2.0.0",
+ "changes": [
+ {
+ "note": "Upgrade the bignumber.js to v8.0.2",
+ "pr": 1517
+ }
+ ]
+ },
+ {
"timestamp": 1547561734,
"version": "1.0.23",
"changes": [
diff --git a/packages/assert/src/index.ts b/packages/assert/src/index.ts
index 2d28d51e1..741bd78e1 100644
--- a/packages/assert/src/index.ts
+++ b/packages/assert/src/index.ts
@@ -7,12 +7,12 @@ const HEX_REGEX = /^0x[0-9A-F]*$/i;
export const assert = {
isBigNumber(variableName: string, value: BigNumber): void {
- const isBigNumber = _.isObject(value) && (value as any).isBigNumber;
+ const isBigNumber = BigNumber.isBigNumber(value);
assert.assert(isBigNumber, assert.typeAssertionMessage(variableName, 'BigNumber', value));
},
isValidBaseUnitAmount(variableName: string, value: BigNumber): void {
assert.isBigNumber(variableName, value);
- const isNegative = value.lessThan(0);
+ const isNegative = value.isLessThan(0);
assert.assert(!isNegative, `${variableName} cannot be a negative number, found value: ${value.toNumber()}`);
const hasDecimals = value.decimalPlaces() !== 0;
assert.assert(
diff --git a/packages/asset-buyer/CHANGELOG.json b/packages/asset-buyer/CHANGELOG.json
index 0b717a887..2de603de0 100644
--- a/packages/asset-buyer/CHANGELOG.json
+++ b/packages/asset-buyer/CHANGELOG.json
@@ -1,5 +1,32 @@
[
{
+ "version": "5.0.0",
+ "changes": [
+ {
+ "note": "Upgrade the bignumber.js to v8.0.2",
+ "pr": 1517
+ }
+ ]
+ },
+ {
+ "version": "4.1.0",
+ "changes": [
+ {
+ "note": "Adds new public method getLiquidityForAssetDataAsync, and exposes getOrdersAndFillableAmountsAsync as public method",
+ "pr": 1512
+ }
+ ]
+ },
+ {
+ "timestamp": 1547747677,
+ "version": "4.0.2",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"timestamp": 1547561734,
"version": "4.0.1",
"changes": [
diff --git a/packages/asset-buyer/CHANGELOG.md b/packages/asset-buyer/CHANGELOG.md
index 85c02479a..f2a3d2236 100644
--- a/packages/asset-buyer/CHANGELOG.md
+++ b/packages/asset-buyer/CHANGELOG.md
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
+## v4.0.2 - _January 17, 2019_
+
+ * Dependencies updated
+
## v4.0.1 - _January 15, 2019_
* Dependencies updated
diff --git a/packages/asset-buyer/package.json b/packages/asset-buyer/package.json
index 3fca31664..0f79ac06a 100644
--- a/packages/asset-buyer/package.json
+++ b/packages/asset-buyer/package.json
@@ -1,6 +1,6 @@
{
"name": "@0x/asset-buyer",
- "version": "4.0.1",
+ "version": "4.0.2",
"engines": {
"node": ">=6.12"
},
@@ -38,7 +38,7 @@
"dependencies": {
"@0x/assert": "^1.0.23",
"@0x/connect": "^3.0.13",
- "@0x/contract-wrappers": "^5.0.0",
+ "@0x/contract-wrappers": "^5.0.1",
"@0x/json-schemas": "^2.1.7",
"@0x/order-utils": "^3.1.2",
"@0x/subproviders": "^2.1.11",
@@ -56,7 +56,7 @@
"@types/node": "*",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
- "chai-bignumber": "^2.0.1",
+ "chai-bignumber": "^3.0.0",
"dirty-chai": "^2.0.1",
"make-promises-safe": "^1.1.0",
"mocha": "^4.1.0",
@@ -65,6 +65,7 @@
"shx": "^0.2.2",
"tslint": "5.11.0",
"typedoc": "0.13.0",
+ "typemoq": "^2.1.0",
"typescript": "3.0.1"
},
"publishConfig": {
diff --git a/packages/asset-buyer/src/asset_buyer.ts b/packages/asset-buyer/src/asset_buyer.ts
index 934410c55..b22b1a122 100644
--- a/packages/asset-buyer/src/asset_buyer.ts
+++ b/packages/asset-buyer/src/asset_buyer.ts
@@ -16,14 +16,16 @@ import {
BuyQuote,
BuyQuoteExecutionOpts,
BuyQuoteRequestOpts,
+ LiquidityForAssetData,
+ LiquidityRequestOpts,
OrderProvider,
- OrderProviderResponse,
OrdersAndFillableAmounts,
} from './types';
import { assert } from './utils/assert';
import { assetDataUtils } from './utils/asset_data_utils';
import { buyQuoteCalculator } from './utils/buy_quote_calculator';
+import { calculateLiquidity } from './utils/calculate_liquidity';
import { orderProviderResponseProcessor } from './utils/order_provider_response_processor';
interface OrdersEntry {
@@ -138,10 +140,10 @@ export class AssetBuyer {
// get the relevant orders for the makerAsset and fees
// if the requested assetData is ZRX, don't get the fee info
const [ordersAndFillableAmounts, feeOrdersAndFillableAmounts] = await Promise.all([
- this._getOrdersAndFillableAmountsAsync(assetData, shouldForceOrderRefresh),
+ this.getOrdersAndFillableAmountsAsync(assetData, shouldForceOrderRefresh),
isMakerAssetZrxToken
? Promise.resolve(constants.EMPTY_ORDERS_AND_FILLABLE_AMOUNTS)
- : this._getOrdersAndFillableAmountsAsync(zrxTokenAssetData, shouldForceOrderRefresh),
+ : this.getOrdersAndFillableAmountsAsync(zrxTokenAssetData, shouldForceOrderRefresh),
shouldForceOrderRefresh,
]);
if (ordersAndFillableAmounts.orders.length === 0) {
@@ -178,6 +180,41 @@ export class AssetBuyer {
return buyQuote;
}
/**
+ * Returns information about available liquidity for an asset
+ * Does not factor in slippage or fees
+ * @param assetData The assetData of the desired asset to buy (for more info: https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md).
+ * @param options Options for the request. See type definition for more information.
+ *
+ * @return An object that conforms to LiquidityForAssetData that satisfies the request. See type definition for more information.
+ */
+ public async getLiquidityForAssetDataAsync(
+ assetData: string,
+ options: Partial<LiquidityRequestOpts> = {},
+ ): Promise<LiquidityForAssetData> {
+ const shouldForceOrderRefresh =
+ options.shouldForceOrderRefresh !== undefined ? options.shouldForceOrderRefresh : false;
+ assert.isString('assetData', assetData);
+ assetDataUtils.decodeAssetDataOrThrow(assetData);
+ assert.isBoolean('options.shouldForceOrderRefresh', shouldForceOrderRefresh);
+
+ const assetPairs = await this.orderProvider.getAvailableMakerAssetDatasAsync(assetData);
+ const etherTokenAssetData = this._getEtherTokenAssetDataOrThrow();
+ if (!assetPairs.includes(etherTokenAssetData)) {
+ return {
+ tokensAvailableInBaseUnits: new BigNumber(0),
+ ethValueAvailableInWei: new BigNumber(0),
+ };
+ }
+
+ const ordersAndFillableAmounts = await this.getOrdersAndFillableAmountsAsync(
+ assetData,
+ shouldForceOrderRefresh,
+ );
+
+ return calculateLiquidity(ordersAndFillableAmounts);
+ }
+
+ /**
* Given a BuyQuote and desired rate, attempt to execute the buy.
* @param buyQuote An object that conforms to BuyQuote. See type definition for more information.
* @param options Options for the execution of the BuyQuote. See type definition for more information.
@@ -260,8 +297,10 @@ export class AssetBuyer {
}
/**
* Grab orders from the map, if there is a miss or it is time to refresh, fetch and process the orders
+ * @param assetData The assetData of the desired asset to buy (for more info: https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md).
+ * @param shouldForceOrderRefresh If set to true, new orders and state will be fetched instead of waiting for the next orderRefreshIntervalMs.
*/
- private async _getOrdersAndFillableAmountsAsync(
+ public async getOrdersAndFillableAmountsAsync(
assetData: string,
shouldForceOrderRefresh: boolean,
): Promise<OrdersAndFillableAmounts> {
diff --git a/packages/asset-buyer/src/index.ts b/packages/asset-buyer/src/index.ts
index a42d7e272..f69cfad69 100644
--- a/packages/asset-buyer/src/index.ts
+++ b/packages/asset-buyer/src/index.ts
@@ -19,6 +19,9 @@ export {
BuyQuoteExecutionOpts,
BuyQuoteInfo,
BuyQuoteRequestOpts,
+ LiquidityForAssetData,
+ LiquidityRequestOpts,
+ OrdersAndFillableAmounts,
OrderProvider,
OrderProviderRequest,
OrderProviderResponse,
diff --git a/packages/asset-buyer/src/types.ts b/packages/asset-buyer/src/types.ts
index d5d6be695..46a2338ce 100644
--- a/packages/asset-buyer/src/types.ts
+++ b/packages/asset-buyer/src/types.ts
@@ -75,6 +75,13 @@ export interface BuyQuoteRequestOpts {
slippagePercentage: number;
}
+/*
+ * Options for checking liquidity
+ *
+ * shouldForceOrderRefresh: If set to true, new orders and state will be fetched instead of waiting for the next orderRefreshIntervalMs. Defaults to false.
+ */
+export type LiquidityRequestOpts = Pick<BuyQuoteRequestOpts, 'shouldForceOrderRefresh'>;
+
/**
* ethAmount: The desired amount of eth to spend. Defaults to buyQuote.worstCaseQuoteInfo.totalEthAmount.
* takerAddress: The address to perform the buy. Defaults to the first available address from the provider.
@@ -117,7 +124,19 @@ export enum AssetBuyerError {
TransactionValueTooLow = 'TRANSACTION_VALUE_TOO_LOW',
}
+/**
+ * orders: An array of signed orders
+ * remainingFillableMakerAssetAmounts: A list of fillable amounts for the signed orders. The index of an item in the array associates the amount with the corresponding order.
+ */
export interface OrdersAndFillableAmounts {
orders: SignedOrder[];
remainingFillableMakerAssetAmounts: BigNumber[];
}
+
+/**
+ * Represents available liquidity for a given assetData
+ */
+export interface LiquidityForAssetData {
+ tokensAvailableInBaseUnits: BigNumber;
+ ethValueAvailableInWei: BigNumber;
+}
diff --git a/packages/asset-buyer/src/utils/buy_quote_calculator.ts b/packages/asset-buyer/src/utils/buy_quote_calculator.ts
index fcded6ab1..125841094 100644
--- a/packages/asset-buyer/src/utils/buy_quote_calculator.ts
+++ b/packages/asset-buyer/src/utils/buy_quote_calculator.ts
@@ -22,7 +22,7 @@ export const buyQuoteCalculator = {
const remainingFillableMakerAssetAmounts = ordersAndFillableAmounts.remainingFillableMakerAssetAmounts;
const feeOrders = feeOrdersAndFillableAmounts.orders;
const remainingFillableFeeAmounts = feeOrdersAndFillableAmounts.remainingFillableMakerAssetAmounts;
- const slippageBufferAmount = assetBuyAmount.mul(slippagePercentage).round();
+ const slippageBufferAmount = assetBuyAmount.multipliedBy(slippagePercentage).integerValue();
// find the orders that cover the desired assetBuyAmount (with slippage)
const {
resultOrders,
@@ -43,7 +43,9 @@ export const buyQuoteCalculator = {
const multiplierNeededWithSlippage = new BigNumber(1).plus(slippagePercentage);
// Given amountAvailableToFillConsideringSlippage * multiplierNeededWithSlippage = amountAbleToFill
// We divide amountUnableToFill by multiplierNeededWithSlippage to determine amountAvailableToFillConsideringSlippage
- const amountAvailableToFillConsideringSlippage = amountAbleToFill.div(multiplierNeededWithSlippage).floor();
+ const amountAvailableToFillConsideringSlippage = amountAbleToFill
+ .div(multiplierNeededWithSlippage)
+ .integerValue(BigNumber.ROUND_FLOOR);
throw new InsufficientAssetLiquidityError(amountAvailableToFillConsideringSlippage);
}
@@ -131,7 +133,7 @@ function calculateQuoteInfo(
zrxEthAmount = findEthAmountNeededToBuyZrx(feeOrdersAndFillableAmounts, zrxAmountToBuyAsset);
}
// eth amount needed to buy the affiliate fee
- const affiliateFeeEthAmount = assetEthAmount.mul(feePercentage).ceil();
+ const affiliateFeeEthAmount = assetEthAmount.multipliedBy(feePercentage).integerValue(BigNumber.ROUND_CEIL);
// eth amount needed for fees is the sum of affiliate fee and zrx fee
const feeEthAmount = affiliateFeeEthAmount.plus(zrxEthAmount);
// eth amount needed in total is the sum of the amount needed for the asset and the amount needed for fees
@@ -168,9 +170,9 @@ function findEthAmountNeededToBuyZrx(
order,
makerFillAmount,
);
- const extraFeeAmount = remainingFillableMakerAssetAmount.greaterThanOrEqualTo(adjustedMakerFillAmount)
+ const extraFeeAmount = remainingFillableMakerAssetAmount.isGreaterThanOrEqualTo(adjustedMakerFillAmount)
? constants.ZERO_AMOUNT
- : adjustedMakerFillAmount.sub(makerFillAmount);
+ : adjustedMakerFillAmount.minus(makerFillAmount);
return {
totalEthAmount: totalEthAmount.plus(takerFillAmount),
remainingZrxBuyAmount: BigNumber.max(
diff --git a/packages/asset-buyer/src/utils/calculate_liquidity.ts b/packages/asset-buyer/src/utils/calculate_liquidity.ts
new file mode 100644
index 000000000..a8d165b4b
--- /dev/null
+++ b/packages/asset-buyer/src/utils/calculate_liquidity.ts
@@ -0,0 +1,34 @@
+import { BigNumber } from '@0x/utils';
+
+import { LiquidityForAssetData, OrdersAndFillableAmounts } from '../types';
+
+import { orderUtils } from './order_utils';
+
+export const calculateLiquidity = (ordersAndFillableAmounts: OrdersAndFillableAmounts): LiquidityForAssetData => {
+ const { orders, remainingFillableMakerAssetAmounts } = ordersAndFillableAmounts;
+ const liquidityInBigNumbers = orders.reduce(
+ (acc, order, curIndex) => {
+ const availableMakerAssetAmount = remainingFillableMakerAssetAmounts[curIndex];
+ if (availableMakerAssetAmount === undefined) {
+ throw new Error(`No corresponding fillableMakerAssetAmounts at index ${curIndex}`);
+ }
+
+ const tokensAvailableForCurrentOrder = availableMakerAssetAmount;
+ const ethValueAvailableForCurrentOrder = orderUtils.getTakerFillAmount(order, availableMakerAssetAmount);
+ return {
+ tokensAvailableInBaseUnits: acc.tokensAvailableInBaseUnits.plus(tokensAvailableForCurrentOrder),
+ ethValueAvailableInWei: acc.ethValueAvailableInWei.plus(ethValueAvailableForCurrentOrder),
+ };
+ },
+ {
+ tokensAvailableInBaseUnits: new BigNumber(0),
+ ethValueAvailableInWei: new BigNumber(0),
+ },
+ );
+
+ // Turn into regular numbers
+ return {
+ tokensAvailableInBaseUnits: liquidityInBigNumbers.tokensAvailableInBaseUnits,
+ ethValueAvailableInWei: liquidityInBigNumbers.ethValueAvailableInWei,
+ };
+};
diff --git a/packages/asset-buyer/src/utils/order_provider_response_processor.ts b/packages/asset-buyer/src/utils/order_provider_response_processor.ts
index 4244d196c..f08cd6150 100644
--- a/packages/asset-buyer/src/utils/order_provider_response_processor.ts
+++ b/packages/asset-buyer/src/utils/order_provider_response_processor.ts
@@ -109,11 +109,8 @@ function getValidOrdersWithRemainingFillableMakerAssetAmountsFromOnChain(
return accOrders;
}
// if the order IS fillable, add the order and calculate the remaining fillable amount
- const transferrableAssetAmount = BigNumber.min([traderInfo.makerAllowance, traderInfo.makerBalance]);
- const transferrableFeeAssetAmount = BigNumber.min([
- traderInfo.makerZrxAllowance,
- traderInfo.makerZrxBalance,
- ]);
+ const transferrableAssetAmount = BigNumber.min(traderInfo.makerAllowance, traderInfo.makerBalance);
+ const transferrableFeeAssetAmount = BigNumber.min(traderInfo.makerZrxAllowance, traderInfo.makerZrxBalance);
const remainingTakerAssetAmount = order.takerAssetAmount.minus(orderInfo.orderTakerAssetFilledAmount);
const remainingMakerAssetAmount = orderUtils.getRemainingMakerAmount(order, remainingTakerAssetAmount);
const remainingFillableCalculator = new RemainingFillableCalculator(
diff --git a/packages/asset-buyer/src/utils/order_utils.ts b/packages/asset-buyer/src/utils/order_utils.ts
index 1cc2cf95f..3ea3cafd3 100644
--- a/packages/asset-buyer/src/utils/order_utils.ts
+++ b/packages/asset-buyer/src/utils/order_utils.ts
@@ -9,8 +9,8 @@ export const orderUtils = {
},
willOrderExpire(order: SignedOrder, secondsFromNow: number): boolean {
const millisecondsInSecond = 1000;
- const currentUnixTimestampSec = new BigNumber(Date.now() / millisecondsInSecond).round();
- return order.expirationTimeSeconds.lessThan(currentUnixTimestampSec.plus(secondsFromNow));
+ const currentUnixTimestampSec = new BigNumber(Date.now() / millisecondsInSecond).integerValue();
+ return order.expirationTimeSeconds.isLessThan(currentUnixTimestampSec.plus(secondsFromNow));
},
isOpenOrder(order: SignedOrder): boolean {
return order.takerAddress === constants.NULL_ADDRESS;
@@ -20,43 +20,43 @@ export const orderUtils = {
const remainingMakerAmount = remainingTakerAmount
.times(order.makerAssetAmount)
.div(order.takerAssetAmount)
- .floor();
+ .integerValue(BigNumber.ROUND_FLOOR);
return remainingMakerAmount;
},
// given a desired amount of makerAsset, calculate how much takerAsset is required to fill that amount
getTakerFillAmount(order: SignedOrder, makerFillAmount: BigNumber): BigNumber {
// Round up because exchange rate favors Maker
const takerFillAmount = makerFillAmount
- .mul(order.takerAssetAmount)
+ .multipliedBy(order.takerAssetAmount)
.div(order.makerAssetAmount)
- .ceil();
+ .integerValue(BigNumber.ROUND_CEIL);
return takerFillAmount;
},
// given a desired amount of takerAsset to fill, calculate how much fee is required by the taker to fill that amount
getTakerFeeAmount(order: SignedOrder, takerFillAmount: BigNumber): BigNumber {
// Round down because Taker fee rate favors Taker
const takerFeeAmount = takerFillAmount
- .mul(order.takerFee)
+ .multipliedBy(order.takerFee)
.div(order.takerAssetAmount)
- .floor();
+ .integerValue(BigNumber.ROUND_FLOOR);
return takerFeeAmount;
},
// given a desired amount of takerAsset to fill, calculate how much makerAsset will be filled
getMakerFillAmount(order: SignedOrder, takerFillAmount: BigNumber): BigNumber {
// Round down because exchange rate favors Maker
const makerFillAmount = takerFillAmount
- .mul(order.makerAssetAmount)
+ .multipliedBy(order.makerAssetAmount)
.div(order.takerAssetAmount)
- .floor();
+ .integerValue(BigNumber.ROUND_FLOOR);
return makerFillAmount;
},
// given a desired amount of makerAsset, calculate how much fee is required by the maker to fill that amount
getMakerFeeAmount(order: SignedOrder, makerFillAmount: BigNumber): BigNumber {
// Round down because Maker fee rate favors Maker
const makerFeeAmount = makerFillAmount
- .mul(order.makerFee)
+ .multipliedBy(order.makerFee)
.div(order.makerAssetAmount)
- .floor();
+ .integerValue(BigNumber.ROUND_FLOOR);
return makerFeeAmount;
},
// given a desired amount of ZRX from a fee order, calculate how much takerAsset is required to fill that amount
@@ -64,9 +64,9 @@ export const orderUtils = {
getTakerFillAmountForFeeOrder(order: SignedOrder, makerFillAmount: BigNumber): [BigNumber, BigNumber] {
// For each unit of TakerAsset we buy (MakerAsset - TakerFee)
const adjustedTakerFillAmount = makerFillAmount
- .mul(order.takerAssetAmount)
- .div(order.makerAssetAmount.sub(order.takerFee))
- .ceil();
+ .multipliedBy(order.takerAssetAmount)
+ .div(order.makerAssetAmount.minus(order.takerFee))
+ .integerValue(BigNumber.ROUND_CEIL);
// The amount that we buy will be greater than makerFillAmount, since we buy some amount for fees.
const adjustedMakerFillAmount = orderUtils.getMakerFillAmount(order, adjustedTakerFillAmount);
return [adjustedTakerFillAmount, adjustedMakerFillAmount];
diff --git a/packages/asset-buyer/test/asset_buyer_test.ts b/packages/asset-buyer/test/asset_buyer_test.ts
new file mode 100644
index 000000000..f117b4d7a
--- /dev/null
+++ b/packages/asset-buyer/test/asset_buyer_test.ts
@@ -0,0 +1,212 @@
+import { orderFactory } from '@0x/order-utils/lib/src/order_factory';
+import { Web3ProviderEngine } from '@0x/subproviders';
+import { SignedOrder } from '@0x/types';
+import { BigNumber } from '@0x/utils';
+import { Web3Wrapper } from '@0x/web3-wrapper';
+import * as chai from 'chai';
+import 'mocha';
+import * as TypeMoq from 'typemoq';
+
+import { AssetBuyer } from '../src';
+import { constants } from '../src/constants';
+import { LiquidityForAssetData, OrderProvider, OrdersAndFillableAmounts } from '../src/types';
+
+import { chaiSetup } from './utils/chai_setup';
+import {
+ mockAvailableAssetDatas,
+ mockedAssetBuyerWithOrdersAndFillableAmounts,
+ orderProviderMock,
+} from './utils/mocks';
+
+chaiSetup.configure();
+const expect = chai.expect;
+
+const FAKE_SRA_URL = 'https://fakeurl.com';
+const FAKE_ASSET_DATA = '0xf47261b00000000000000000000000001dc4c1cefef38a777b15aa20260a54e584b16c48';
+const TOKEN_DECIMALS = 18;
+const DAI_ASSET_DATA = '0xf47261b000000000000000000000000089d24a6b4ccb1b6faa2625fe562bdd9a23260359"';
+const WETH_ASSET_DATA = '0xf47261b0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2';
+const WETH_DECIMALS = constants.ETHER_TOKEN_DECIMALS;
+
+const baseUnitAmount = (unitAmount: number, decimals = TOKEN_DECIMALS): BigNumber => {
+ return Web3Wrapper.toBaseUnitAmount(new BigNumber(unitAmount), decimals);
+};
+
+const expectLiquidityResult = async (
+ web3Provider: Web3ProviderEngine,
+ orderProvider: OrderProvider,
+ ordersAndFillableAmounts: OrdersAndFillableAmounts,
+ expectedLiquidityResult: LiquidityForAssetData,
+) => {
+ const mockedAssetBuyer = mockedAssetBuyerWithOrdersAndFillableAmounts(
+ web3Provider,
+ orderProvider,
+ FAKE_ASSET_DATA,
+ ordersAndFillableAmounts,
+ );
+ const liquidityResult = await mockedAssetBuyer.object.getLiquidityForAssetDataAsync(FAKE_ASSET_DATA);
+ expect(liquidityResult).to.deep.equal(expectedLiquidityResult);
+};
+
+// tslint:disable:custom-no-magic-numbers
+describe('AssetBuyer', () => {
+ describe('getLiquidityForAssetDataAsync', () => {
+ const mockWeb3Provider = TypeMoq.Mock.ofType(Web3ProviderEngine);
+ const mockOrderProvider = orderProviderMock();
+
+ beforeEach(() => {
+ mockWeb3Provider.reset();
+ mockOrderProvider.reset();
+ });
+
+ afterEach(() => {
+ mockWeb3Provider.verifyAll();
+ mockOrderProvider.verifyAll();
+ });
+
+ describe('validation', () => {
+ it('should ensure assetData is a string', async () => {
+ const assetBuyer = AssetBuyer.getAssetBuyerForStandardRelayerAPIUrl(
+ mockWeb3Provider.object,
+ FAKE_SRA_URL,
+ );
+
+ expect(assetBuyer.getLiquidityForAssetDataAsync(false as any)).to.be.rejectedWith(
+ 'Expected assetData to be of type string, encountered: false',
+ );
+ });
+ });
+
+ describe('asset pair not supported', () => {
+ it('should return 0s when no asset pair not supported', async () => {
+ mockAvailableAssetDatas(mockOrderProvider, FAKE_ASSET_DATA, []);
+
+ const assetBuyer = new AssetBuyer(mockWeb3Provider.object, mockOrderProvider.object);
+ const liquidityResult = await assetBuyer.getLiquidityForAssetDataAsync(FAKE_ASSET_DATA);
+ expect(liquidityResult).to.deep.equal({
+ tokensAvailableInBaseUnits: new BigNumber(0),
+ ethValueAvailableInWei: new BigNumber(0),
+ });
+ });
+ it('should return 0s when only other asset pair supported', async () => {
+ mockAvailableAssetDatas(mockOrderProvider, FAKE_ASSET_DATA, [DAI_ASSET_DATA]);
+
+ const assetBuyer = new AssetBuyer(mockWeb3Provider.object, mockOrderProvider.object);
+ const liquidityResult = await assetBuyer.getLiquidityForAssetDataAsync(FAKE_ASSET_DATA);
+ expect(liquidityResult).to.deep.equal({
+ tokensAvailableInBaseUnits: new BigNumber(0),
+ ethValueAvailableInWei: new BigNumber(0),
+ });
+ });
+ });
+
+ describe('assetData is supported', () => {
+ // orders
+ const sellTwoTokensFor1Weth: SignedOrder = orderFactory.createSignedOrderFromPartial({
+ makerAssetAmount: baseUnitAmount(2),
+ takerAssetAmount: baseUnitAmount(1, WETH_DECIMALS),
+ });
+ const sellTenTokensFor10Weth: SignedOrder = orderFactory.createSignedOrderFromPartial({
+ makerAssetAmount: baseUnitAmount(10),
+ takerAssetAmount: baseUnitAmount(10, WETH_DECIMALS),
+ });
+
+ beforeEach(() => {
+ mockAvailableAssetDatas(mockOrderProvider, FAKE_ASSET_DATA, [WETH_ASSET_DATA]);
+ });
+
+ it('should return 0s when no orders available', async () => {
+ const ordersAndFillableAmounts: OrdersAndFillableAmounts = {
+ orders: [],
+ remainingFillableMakerAssetAmounts: [],
+ };
+ const expectedResult = {
+ tokensAvailableInBaseUnits: new BigNumber(0),
+ ethValueAvailableInWei: new BigNumber(0),
+ };
+ await expectLiquidityResult(
+ mockWeb3Provider.object,
+ mockOrderProvider.object,
+ ordersAndFillableAmounts,
+ expectedResult,
+ );
+ });
+
+ it('should return correct computed value when orders provided with full fillableAmounts', async () => {
+ const orders: SignedOrder[] = [sellTwoTokensFor1Weth, sellTenTokensFor10Weth];
+ const ordersAndFillableAmounts = {
+ orders: [sellTwoTokensFor1Weth, sellTenTokensFor10Weth],
+ remainingFillableMakerAssetAmounts: orders.map(o => o.makerAssetAmount),
+ };
+
+ const expectedTokensAvailable = orders[0].makerAssetAmount.plus(orders[1].makerAssetAmount);
+ const expectedEthValueAvailable = orders[0].takerAssetAmount.plus(orders[1].takerAssetAmount);
+ const expectedResult = {
+ tokensAvailableInBaseUnits: expectedTokensAvailable,
+ ethValueAvailableInWei: expectedEthValueAvailable,
+ };
+
+ await expectLiquidityResult(
+ mockWeb3Provider.object,
+ mockOrderProvider.object,
+ ordersAndFillableAmounts,
+ expectedResult,
+ );
+ });
+
+ it('should return correct computed value with one partial fillableAmounts', async () => {
+ const ordersAndFillableAmounts = {
+ orders: [sellTwoTokensFor1Weth],
+ remainingFillableMakerAssetAmounts: [baseUnitAmount(1)],
+ };
+ const expectedResult = {
+ tokensAvailableInBaseUnits: baseUnitAmount(1),
+ ethValueAvailableInWei: baseUnitAmount(0.5, WETH_DECIMALS),
+ };
+
+ await expectLiquidityResult(
+ mockWeb3Provider.object,
+ mockOrderProvider.object,
+ ordersAndFillableAmounts,
+ expectedResult,
+ );
+ });
+
+ it('should return correct computed value with multiple orders and fillable amounts', async () => {
+ const ordersAndFillableAmounts = {
+ orders: [sellTwoTokensFor1Weth, sellTenTokensFor10Weth],
+ remainingFillableMakerAssetAmounts: [baseUnitAmount(1), baseUnitAmount(3)],
+ };
+ const expectedResult = {
+ tokensAvailableInBaseUnits: baseUnitAmount(4),
+ ethValueAvailableInWei: baseUnitAmount(3.5, WETH_DECIMALS),
+ };
+
+ await expectLiquidityResult(
+ mockWeb3Provider.object,
+ mockOrderProvider.object,
+ ordersAndFillableAmounts,
+ expectedResult,
+ );
+ });
+
+ it('should return 0s when no amounts fillable', async () => {
+ const ordersAndFillableAmounts = {
+ orders: [sellTwoTokensFor1Weth, sellTenTokensFor10Weth],
+ remainingFillableMakerAssetAmounts: [baseUnitAmount(0), baseUnitAmount(0)],
+ };
+ const expectedResult = {
+ tokensAvailableInBaseUnits: baseUnitAmount(0),
+ ethValueAvailableInWei: baseUnitAmount(0, WETH_DECIMALS),
+ };
+
+ await expectLiquidityResult(
+ mockWeb3Provider.object,
+ mockOrderProvider.object,
+ ordersAndFillableAmounts,
+ expectedResult,
+ );
+ });
+ });
+ });
+});
diff --git a/packages/asset-buyer/test/buy_quote_calculator_test.ts b/packages/asset-buyer/test/buy_quote_calculator_test.ts
index 880f55180..177fd8fe6 100644
--- a/packages/asset-buyer/test/buy_quote_calculator_test.ts
+++ b/packages/asset-buyer/test/buy_quote_calculator_test.ts
@@ -234,7 +234,7 @@ describe('buyQuoteCalculator', () => {
const expectedEthAmountForAsset = new BigNumber(50);
const expectedEthAmountForZrxFees = new BigNumber(100);
const expectedFillEthAmount = expectedEthAmountForAsset;
- const expectedAffiliateFeeEthAmount = expectedEthAmountForAsset.mul(feePercentage);
+ const expectedAffiliateFeeEthAmount = expectedEthAmountForAsset.multipliedBy(feePercentage);
const expectedFeeEthAmount = expectedAffiliateFeeEthAmount.plus(expectedEthAmountForZrxFees);
const expectedTotalEthAmount = expectedFillEthAmount.plus(expectedFeeEthAmount);
expect(buyQuote.bestCaseQuoteInfo.assetEthAmount).to.bignumber.equal(expectedFillEthAmount);
@@ -272,7 +272,7 @@ describe('buyQuoteCalculator', () => {
const expectedEthAmountForAsset = new BigNumber(50);
const expectedEthAmountForZrxFees = new BigNumber(100);
const expectedFillEthAmount = expectedEthAmountForAsset;
- const expectedAffiliateFeeEthAmount = expectedEthAmountForAsset.mul(feePercentage);
+ const expectedAffiliateFeeEthAmount = expectedEthAmountForAsset.multipliedBy(feePercentage);
const expectedFeeEthAmount = expectedAffiliateFeeEthAmount.plus(expectedEthAmountForZrxFees);
const expectedTotalEthAmount = expectedFillEthAmount.plus(expectedFeeEthAmount);
expect(buyQuote.bestCaseQuoteInfo.assetEthAmount).to.bignumber.equal(expectedFillEthAmount);
@@ -282,7 +282,7 @@ describe('buyQuoteCalculator', () => {
const expectedWorstEthAmountForAsset = new BigNumber(100);
const expectedWorstEthAmountForZrxFees = new BigNumber(208);
const expectedWorstFillEthAmount = expectedWorstEthAmountForAsset;
- const expectedWorstAffiliateFeeEthAmount = expectedWorstEthAmountForAsset.mul(feePercentage);
+ const expectedWorstAffiliateFeeEthAmount = expectedWorstEthAmountForAsset.multipliedBy(feePercentage);
const expectedWorstFeeEthAmount = expectedWorstAffiliateFeeEthAmount.plus(expectedWorstEthAmountForZrxFees);
const expectedWorstTotalEthAmount = expectedWorstFillEthAmount.plus(expectedWorstFeeEthAmount);
expect(buyQuote.worstCaseQuoteInfo.assetEthAmount).to.bignumber.equal(expectedWorstFillEthAmount);
diff --git a/packages/asset-buyer/test/utils/mocks.ts b/packages/asset-buyer/test/utils/mocks.ts
new file mode 100644
index 000000000..d3e1c09c4
--- /dev/null
+++ b/packages/asset-buyer/test/utils/mocks.ts
@@ -0,0 +1,68 @@
+import { Web3ProviderEngine } from '@0x/subproviders';
+import * as TypeMoq from 'typemoq';
+
+import { AssetBuyer } from '../../src/asset_buyer';
+import { OrderProvider, OrderProviderResponse, OrdersAndFillableAmounts } from '../../src/types';
+
+// tslint:disable:promise-function-async
+
+// Implementing dummy class for using in mocks, see https://github.com/florinn/typemoq/issues/3
+class OrderProviderClass implements OrderProvider {
+ // tslint:disable-next-line:prefer-function-over-method
+ public async getOrdersAsync(): Promise<OrderProviderResponse> {
+ return Promise.resolve({ orders: [] });
+ }
+ // tslint:disable-next-line:prefer-function-over-method
+ public async getAvailableMakerAssetDatasAsync(takerAssetData: string): Promise<string[]> {
+ return Promise.resolve([]);
+ }
+}
+
+export const orderProviderMock = () => {
+ return TypeMoq.Mock.ofType(OrderProviderClass, TypeMoq.MockBehavior.Strict);
+};
+
+export const mockAvailableAssetDatas = (
+ mockOrderProvider: TypeMoq.IMock<OrderProviderClass>,
+ assetData: string,
+ availableAssetDatas: string[],
+) => {
+ mockOrderProvider
+ .setup(op => op.getAvailableMakerAssetDatasAsync(TypeMoq.It.isValue(assetData)))
+ .returns(() => {
+ return Promise.resolve(availableAssetDatas);
+ })
+ .verifiable(TypeMoq.Times.once());
+};
+
+const partiallyMockedAssetBuyer = (
+ provider: Web3ProviderEngine,
+ orderProvider: OrderProvider,
+): TypeMoq.IMock<AssetBuyer> => {
+ const rawAssetBuyer = new AssetBuyer(provider, orderProvider);
+ const mockedAssetBuyer = TypeMoq.Mock.ofInstance(rawAssetBuyer, TypeMoq.MockBehavior.Loose, false);
+ mockedAssetBuyer.callBase = true;
+ return mockedAssetBuyer;
+};
+
+const mockGetOrdersAndAvailableAmounts = (
+ mockedAssetBuyer: TypeMoq.IMock<AssetBuyer>,
+ assetData: string,
+ ordersAndFillableAmounts: OrdersAndFillableAmounts,
+): void => {
+ mockedAssetBuyer
+ .setup(a => a.getOrdersAndFillableAmountsAsync(assetData, false))
+ .returns(() => Promise.resolve(ordersAndFillableAmounts))
+ .verifiable(TypeMoq.Times.once());
+};
+
+export const mockedAssetBuyerWithOrdersAndFillableAmounts = (
+ provider: Web3ProviderEngine,
+ orderProvider: OrderProvider,
+ assetData: string,
+ ordersAndFillableAmounts: OrdersAndFillableAmounts,
+): TypeMoq.IMock<AssetBuyer> => {
+ const mockedAssetBuyer = partiallyMockedAssetBuyer(provider, orderProvider);
+ mockGetOrdersAndAvailableAmounts(mockedAssetBuyer, assetData, ordersAndFillableAmounts);
+ return mockedAssetBuyer;
+};
diff --git a/packages/base-contract/CHANGELOG.json b/packages/base-contract/CHANGELOG.json
index 68ebe8d9e..63b1fe8f7 100644
--- a/packages/base-contract/CHANGELOG.json
+++ b/packages/base-contract/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "version": "4.0.0",
+ "changes": [
+ {
+ "note": "Upgrade the bignumber.js to v8.0.2",
+ "pr": 1517
+ }
+ ]
+ },
+ {
"timestamp": 1547561734,
"version": "3.0.13",
"changes": [
diff --git a/packages/base-contract/src/index.ts b/packages/base-contract/src/index.ts
index c2b7b943b..0238106f3 100644
--- a/packages/base-contract/src/index.ts
+++ b/packages/base-contract/src/index.ts
@@ -1,4 +1,4 @@
-import { AbiEncoder, abiUtils } from '@0x/utils';
+import { AbiEncoder, abiUtils, BigNumber } from '@0x/utils';
import { Web3Wrapper } from '@0x/web3-wrapper';
import {
AbiDefinition,
@@ -43,7 +43,7 @@ export class BaseContract {
return type === 'address' ? value.toLowerCase() : value;
}
protected static _bigNumberToString(_type: string, value: any): any {
- return _.isObject(value) && value.isBigNumber ? value.toString() : value;
+ return BigNumber.isBigNumber(value) ? value.toString() : value;
}
protected static _lookupConstructorAbi(abi: ContractAbi): ConstructorAbi {
const constructorAbiIfExists = _.find(
diff --git a/packages/connect/CHANGELOG.json b/packages/connect/CHANGELOG.json
index 8fe9c562f..c2f16d96a 100644
--- a/packages/connect/CHANGELOG.json
+++ b/packages/connect/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "version": "4.0.0",
+ "changes": [
+ {
+ "note": "Upgrade the bignumber.js to v8.0.2",
+ "pr": 1517
+ }
+ ]
+ },
+ {
"timestamp": 1547561734,
"version": "3.0.13",
"changes": [
diff --git a/packages/contract-wrappers/CHANGELOG.json b/packages/contract-wrappers/CHANGELOG.json
index bfba8454c..30199ae1d 100644
--- a/packages/contract-wrappers/CHANGELOG.json
+++ b/packages/contract-wrappers/CHANGELOG.json
@@ -1,5 +1,23 @@
[
{
+ "version": "6.0.0",
+ "changes": [
+ {
+ "note": "Upgrade the bignumber.js to v8.0.2",
+ "pr": 1517
+ }
+ ]
+ },
+ {
+ "timestamp": 1547747677,
+ "version": "5.0.1",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"version": "5.0.0",
"changes": [
{
diff --git a/packages/contract-wrappers/CHANGELOG.md b/packages/contract-wrappers/CHANGELOG.md
index 8281f5050..28cbf2ec6 100644
--- a/packages/contract-wrappers/CHANGELOG.md
+++ b/packages/contract-wrappers/CHANGELOG.md
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
+## v5.0.1 - _January 17, 2019_
+
+ * Dependencies updated
+
## v5.0.0 - _January 15, 2019_
* Renamed OrderStatus enum members to PascalCase to conform with tslint enum-naming rule (#1474)
diff --git a/packages/contract-wrappers/package.json b/packages/contract-wrappers/package.json
index c4f75a5a4..cc7dc1a3e 100644
--- a/packages/contract-wrappers/package.json
+++ b/packages/contract-wrappers/package.json
@@ -1,6 +1,6 @@
{
"name": "@0x/contract-wrappers",
- "version": "5.0.0",
+ "version": "5.0.1",
"description": "Smart TS wrappers for 0x smart contracts",
"keywords": [
"0xproject",
@@ -49,7 +49,7 @@
"@types/web3-provider-engine": "^14.0.0",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
- "chai-bignumber": "^2.0.1",
+ "chai-bignumber": "^3.0.0",
"dirty-chai": "^2.0.1",
"make-promises-safe": "^1.1.0",
"mocha": "^4.1.0",
@@ -69,7 +69,7 @@
"@0x/assert": "^1.0.23",
"@0x/contract-addresses": "^2.2.0",
"@0x/contract-artifacts": "^1.3.0",
- "@0x/contracts-test-utils": "^2.0.0",
+ "@0x/contracts-test-utils": "^2.0.1",
"@0x/fill-scenarios": "^1.1.2",
"@0x/json-schemas": "^2.1.7",
"@0x/order-utils": "^3.1.2",
diff --git a/packages/contract-wrappers/src/contract_wrappers/erc20_token_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/erc20_token_wrapper.ts
index ad42cfd4f..cd79a0e5d 100644
--- a/packages/contract-wrappers/src/contract_wrappers/erc20_token_wrapper.ts
+++ b/packages/contract-wrappers/src/contract_wrappers/erc20_token_wrapper.ts
@@ -271,7 +271,7 @@ export class ERC20TokenWrapper extends ContractWrapper {
const tokenContract = await this._getTokenContractAsync(normalizedTokenAddress);
const fromAddressBalance = await this.getBalanceAsync(normalizedTokenAddress, normalizedFromAddress);
- if (fromAddressBalance.lessThan(amountInBaseUnits)) {
+ if (fromAddressBalance.isLessThan(amountInBaseUnits)) {
throw new Error(ContractWrappersError.InsufficientBalanceForTransfer);
}
@@ -327,12 +327,12 @@ export class ERC20TokenWrapper extends ContractWrapper {
normalizedFromAddress,
normalizedSenderAddress,
);
- if (fromAddressAllowance.lessThan(amountInBaseUnits)) {
+ if (fromAddressAllowance.isLessThan(amountInBaseUnits)) {
throw new Error(ContractWrappersError.InsufficientAllowanceForTransfer);
}
const fromAddressBalance = await this.getBalanceAsync(normalizedTokenAddress, normalizedFromAddress);
- if (fromAddressBalance.lessThan(amountInBaseUnits)) {
+ if (fromAddressBalance.isLessThan(amountInBaseUnits)) {
throw new Error(ContractWrappersError.InsufficientBalanceForTransfer);
}
diff --git a/packages/contract-wrappers/src/fetchers/asset_balance_and_proxy_allowance_fetcher.ts b/packages/contract-wrappers/src/fetchers/asset_balance_and_proxy_allowance_fetcher.ts
index 1ff130a48..c35b24664 100644
--- a/packages/contract-wrappers/src/fetchers/asset_balance_and_proxy_allowance_fetcher.ts
+++ b/packages/contract-wrappers/src/fetchers/asset_balance_and_proxy_allowance_fetcher.ts
@@ -39,7 +39,7 @@ export class AssetBalanceAndProxyAllowanceFetcher implements AbstractBalanceAndP
nestedAssetDataElement,
userAddress,
)).dividedToIntegerBy(nestedAmountElement);
- if (_.isUndefined(balance) || nestedAssetBalance.lessThan(balance)) {
+ if (_.isUndefined(balance) || nestedAssetBalance.isLessThan(balance)) {
balance = nestedAssetBalance;
}
}
@@ -81,7 +81,7 @@ export class AssetBalanceAndProxyAllowanceFetcher implements AbstractBalanceAndP
nestedAssetDataElement,
userAddress,
)).dividedToIntegerBy(nestedAmountElement);
- if (_.isUndefined(proxyAllowance) || nestedAssetAllowance.lessThan(proxyAllowance)) {
+ if (_.isUndefined(proxyAllowance) || nestedAssetAllowance.isLessThan(proxyAllowance)) {
proxyAllowance = nestedAssetAllowance;
}
}
diff --git a/packages/contract-wrappers/src/utils/exchange_transfer_simulator.ts b/packages/contract-wrappers/src/utils/exchange_transfer_simulator.ts
index f374d509b..4b75ea386 100644
--- a/packages/contract-wrappers/src/utils/exchange_transfer_simulator.ts
+++ b/packages/contract-wrappers/src/utils/exchange_transfer_simulator.ts
@@ -72,10 +72,10 @@ export class ExchangeTransferSimulator {
}
const balance = await this._store.getBalanceAsync(tokenAddress, from);
const proxyAllowance = await this._store.getProxyAllowanceAsync(tokenAddress, from);
- if (proxyAllowance.lessThan(amountInBaseUnits)) {
+ if (proxyAllowance.isLessThan(amountInBaseUnits)) {
ExchangeTransferSimulator._throwValidationError(FailureReason.ProxyAllowance, tradeSide, transferType);
}
- if (balance.lessThan(amountInBaseUnits)) {
+ if (balance.isLessThan(amountInBaseUnits)) {
ExchangeTransferSimulator._throwValidationError(FailureReason.Balance, tradeSide, transferType);
}
await this._decreaseProxyAllowanceAsync(tokenAddress, from, amountInBaseUnits);
diff --git a/packages/contract-wrappers/src/utils/utils.ts b/packages/contract-wrappers/src/utils/utils.ts
index 0b3270e78..ab69385e7 100644
--- a/packages/contract-wrappers/src/utils/utils.ts
+++ b/packages/contract-wrappers/src/utils/utils.ts
@@ -7,13 +7,15 @@ import { constants } from './constants';
export const utils = {
getCurrentUnixTimestampSec(): BigNumber {
const milisecondsInSecond = 1000;
- return new BigNumber(Date.now() / milisecondsInSecond).round();
+ return new BigNumber(Date.now() / milisecondsInSecond).integerValue();
},
getCurrentUnixTimestampMs(): BigNumber {
return new BigNumber(Date.now());
},
numberPercentageToEtherTokenAmountPercentage(percentage: number): BigNumber {
- return Web3Wrapper.toBaseUnitAmount(constants.ONE_AMOUNT, constants.ETHER_TOKEN_DECIMALS).mul(percentage);
+ return Web3Wrapper.toBaseUnitAmount(constants.ONE_AMOUNT, constants.ETHER_TOKEN_DECIMALS).multipliedBy(
+ percentage,
+ );
},
removeUndefinedProperties<T extends object>(obj: T): Partial<T> {
return _.pickBy(obj);
diff --git a/packages/contract-wrappers/test/ether_token_wrapper_test.ts b/packages/contract-wrappers/test/ether_token_wrapper_test.ts
index e3efef19d..cc2419aa2 100644
--- a/packages/contract-wrappers/test/ether_token_wrapper_test.ts
+++ b/packages/contract-wrappers/test/ether_token_wrapper_test.ts
@@ -116,7 +116,7 @@ describe('EtherTokenWrapper', () => {
const preETHBalance = await web3Wrapper.getBalanceInWeiAsync(addressWithETH);
const extraETHBalance = Web3Wrapper.toWei(new BigNumber(5));
- const overETHBalanceinWei = preETHBalance.add(extraETHBalance);
+ const overETHBalanceinWei = preETHBalance.plus(extraETHBalance);
return expect(
contractWrappers.etherToken.depositAsync(wethContractAddress, overETHBalanceinWei, addressWithETH),
@@ -153,7 +153,7 @@ describe('EtherTokenWrapper', () => {
);
expect(postWETHBalanceInBaseUnits).to.be.bignumber.equal(0);
- const expectedETHBalance = preETHBalance.add(depositWeiAmount).round(decimalPlaces);
+ const expectedETHBalance = preETHBalance.plus(depositWeiAmount).integerValue(decimalPlaces);
gasCost = expectedETHBalance.minus(postETHBalance);
expect(gasCost).to.be.bignumber.lte(MAX_REASONABLE_GAS_COST_IN_WEI);
});
@@ -165,7 +165,7 @@ describe('EtherTokenWrapper', () => {
expect(preWETHBalance).to.be.bignumber.equal(0);
// tslint:disable-next-line:custom-no-magic-numbers
- const overWETHBalance = preWETHBalance.add(999999999);
+ const overWETHBalance = preWETHBalance.plus(999999999);
return expect(
contractWrappers.etherToken.withdrawAsync(wethContractAddress, overWETHBalance, addressWithETH),
diff --git a/packages/dev-tools-pages/.gitignore b/packages/dev-tools-pages/.gitignore
index 557b82311..d70ebaa1d 100644
--- a/packages/dev-tools-pages/.gitignore
+++ b/packages/dev-tools-pages/.gitignore
@@ -1,3 +1 @@
-public
-assets/fonts/*.woff
-assets/fonts/*.woff2 \ No newline at end of file
+public \ No newline at end of file
diff --git a/packages/dev-tools-pages/assets/crawl.html b/packages/dev-tools-pages/assets/crawl.html
index 9135c3ede..352300d73 100644
--- a/packages/dev-tools-pages/assets/crawl.html
+++ b/packages/dev-tools-pages/assets/crawl.html
@@ -1,20 +1,17 @@
<!DOCTYPE html>
<html lang="en">
-<head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <meta http-equiv="X-UA-Compatible" content="ie=edge">
- <title>Document</title>
-</head>
-<body>
-
-<ul>
-<li><a href="/compiler">Compiler</a></li>
-<li><a href="/cov">Cov</a></li>
-<li><a href="/profiler">Profiler</a></li>
-<li><a href="/trace">Trace</a></li>
-
-</ul>
-
-</body>
-</html> \ No newline at end of file
+ <head>
+ <meta charset="UTF-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ <meta http-equiv="X-UA-Compatible" content="ie=edge" />
+ <title>Test</title>
+ </head>
+ <body>
+ <ul>
+ <li><a href="/compiler">Compiler</a></li>
+ <li><a href="/coverage">Coverage</a></li>
+ <li><a href="/profiler">Profiler</a></li>
+ <li><a href="/trace">Trace</a></li>
+ </ul>
+ </body>
+</html>
diff --git a/packages/dev-tools-pages/assets/fonts/.gitkeep b/packages/dev-tools-pages/assets/fonts/.gitkeep
deleted file mode 100644
index e69de29bb..000000000
--- a/packages/dev-tools-pages/assets/fonts/.gitkeep
+++ /dev/null
diff --git a/packages/dev-tools-pages/assets/fonts/MaisonNeue-Bold-subset.woff2 b/packages/dev-tools-pages/assets/fonts/MaisonNeue-Bold-subset.woff2
new file mode 100644
index 000000000..54424f6fc
--- /dev/null
+++ b/packages/dev-tools-pages/assets/fonts/MaisonNeue-Bold-subset.woff2
Binary files differ
diff --git a/packages/dev-tools-pages/assets/fonts/MaisonNeue-Book-subset.woff2 b/packages/dev-tools-pages/assets/fonts/MaisonNeue-Book-subset.woff2
new file mode 100644
index 000000000..8c2dea7ef
--- /dev/null
+++ b/packages/dev-tools-pages/assets/fonts/MaisonNeue-Book-subset.woff2
Binary files differ
diff --git a/packages/dev-tools-pages/package.json b/packages/dev-tools-pages/package.json
index 79d4a840f..feab72856 100644
--- a/packages/dev-tools-pages/package.json
+++ b/packages/dev-tools-pages/package.json
@@ -1,18 +1,28 @@
{
"name": "@0x/dev-tools-pages",
- "version": "0.0.13",
+ "version": "0.0.14",
"engines": {
"node": ">=6.12"
},
"private": true,
"description": "0x Dev tools pages",
"scripts": {
- "build": "node --max_old_space_size=8192 ../../node_modules/.bin/webpack --mode production && react-snap",
+ "build": "node --max_old_space_size=8192 ../../node_modules/.bin/webpack --mode production",
"build:ci": "yarn build",
"build:dev": "../../node_modules/.bin/webpack --mode development",
"clean": "shx rm -f public/bundle*",
"lint": "tslint --format stylish --project . 'ts/**/*.ts' 'ts/**/*.tsx'",
- "dev": "webpack-dev-server --mode development --content-base public"
+ "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*'",
+ "deploy:coverage": "DIR_NAME=./public/. BUCKET=s3://sol-coverage.com yarn s3:sync --exclude 'bundle-compiler*' --exclude 'bundle-trace*' --exclude 'bundle-profiler*'",
+ "deploy:profiler": "DIR_NAME=./public/. BUCKET=s3://sol-profiler.com yarn s3:sync --exclude 'bundle-cov*' --exclude 'bundle-trace*' --exclude 'bundle-compiler*'",
+ "deploy:trace": "DIR_NAME=./public/. BUCKET=s3://sol-trace.com yarn s3:sync --exclude 'bundle-cov*' --exclude 'bundle-compiler*' --exclude 'bundle-profiler*'",
+ "deploy:compiler:index": "DIR_NAME=./public/compiler/. BUCKET=s3://sol-compiler.com yarn s3:sync",
+ "deploy:coverage:index": "DIR_NAME=./public/coverage/. BUCKET=s3://sol-coverage.com yarn s3:sync",
+ "deploy:profiler:index": "DIR_NAME=./public/profiler/. BUCKET=s3://sol-profiler.com yarn s3:sync",
+ "deploy:trace:index": "DIR_NAME=./public/trace/. BUCKET=s3://sol-trace.com yarn s3:sync",
+ "s3:sync": "aws s3 sync $DIR_NAME $BUCKET --profile 0xproject --region us-east-1 --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --exclude *.map.js --exclude 'profiler/*' --exclude 'trace/*' --exclude 'coverage/*' --exclude 'compiler/*'"
},
"license": "Apache-2.0",
"dependencies": {
@@ -51,7 +61,6 @@
"less-loader": "^4.1.0",
"make-promises-safe": "^1.1.0",
"raw-loader": "^0.5.1",
- "react-snap": "^1.19.0",
"react-svg-loader": "^2.1.0",
"shx": "^0.2.2",
"source-map-loader": "^0.2.4",
@@ -65,12 +74,5 @@
"webpack-bundle-analyzer": "^3.0.3",
"webpack-cli": "3.1.2",
"webpack-dev-server": "^3.1.9"
- },
- "reactSnap": {
- "source": "public",
- "puppeteerArgs": [
- "--no-sandbox",
- "--disable-setuid-sandbox"
- ]
}
}
diff --git a/packages/dev-tools-pages/pages.js b/packages/dev-tools-pages/pages.js
index 7609a07e9..488c2ecd7 100644
--- a/packages/dev-tools-pages/pages.js
+++ b/packages/dev-tools-pages/pages.js
@@ -11,26 +11,26 @@ const pages = [
'og-title': { property: 'og:title', content: 'sol-compiler' },
'og-description': { property: 'og:description', content: 'Solidity compilation that just works' },
'og-type': { property: 'og:type', content: 'website' },
- 'og-image': { property: 'og:image', content: '/images/og-compiler' },
+ 'og-image': { property: 'og:image', content: '/images/og-compiler.png' },
'twitter:site': '@0xproject',
- 'twitter:image': '/images/og-compiler',
+ 'twitter:image': '/images/og-compiler.png',
},
},
{
- title: 'sol-cov',
- filename: 'cov/index.html',
+ title: 'sol-coverage',
+ filename: 'coverage/index.html',
template: 'assets/index.html',
- chunks: ['cov'],
+ chunks: ['coverage'],
favicon: 'assets/favicons/cov.ico',
minify: true,
meta: {
description: 'Solidity code coverage',
- 'og-title': { property: 'og:title', content: 'sol-cov' },
+ 'og-title': { property: 'og:title', content: 'sol-coverage' },
'og-description': { property: 'og:description', content: 'Solidity code coverage' },
'og-type': { property: 'og:type', content: 'website' },
- 'og-image': { property: 'og:image', content: '/images/og-cov' },
+ 'og-image': { property: 'og:image', content: '/images/og-cov.png' },
'twitter:site': '@0xproject',
- 'twitter:image': '/images/og-cov',
+ 'twitter:image': '/images/og-cov.png',
},
},
{
@@ -45,9 +45,9 @@ const pages = [
'og-title': { property: 'og:title', content: 'sol-profiler' },
'og-description': { property: 'og:description', content: 'Gas profiling for Solidity' },
'og-type': { property: 'og:type', content: 'website' },
- 'og-image': { property: 'og:image', content: '/images/og-profiler' },
+ 'og-image': { property: 'og:image', content: '/images/og-profiler.png' },
'twitter:site': '@0xproject',
- 'twitter:image': '/images/og-profiler',
+ 'twitter:image': '/images/og-profiler.png',
},
},
{
@@ -62,9 +62,9 @@ const pages = [
'og-title': { property: 'og:title', content: 'sol-trace' },
'og-description': { property: 'og:description', content: 'Human-readable stack traces' },
'og-type': { property: 'og:type', content: 'website' },
- 'og-image': { property: 'og:image', content: '/images/og-trace' },
+ 'og-image': { property: 'og:image', content: '/images/og-trace.png' },
'twitter:site': '@0xproject',
- 'twitter:image': '/images/og-trace',
+ 'twitter:image': '/images/og-trace.png',
},
},
];
diff --git a/packages/dev-tools-pages/ts/components/call_to_action.tsx b/packages/dev-tools-pages/ts/components/call_to_action.tsx
new file mode 100644
index 000000000..3805a7c8c
--- /dev/null
+++ b/packages/dev-tools-pages/ts/components/call_to_action.tsx
@@ -0,0 +1,40 @@
+import * as React from 'react';
+import styled from 'styled-components';
+
+import { ContextInterface, ThemeContext } from 'ts/context';
+
+import { Button } from './button';
+
+const CallToAction: React.StatelessComponent<ContextInterface> = ({ children }) => (
+ <ThemeContext.Consumer>
+ {({ docLink }: ContextInterface) => (
+ <StyledCallToAction>
+ <CallToActionContainer>
+ <Button as="a" href={docLink} target="_blank" large={true}>
+ Read the Docs
+ </Button>
+ </CallToActionContainer>
+ {children}
+ </StyledCallToAction>
+ )}
+ </ThemeContext.Consumer>
+);
+
+const StyledCallToAction = styled.section`
+ text-align: center;
+ padding-top: 0;
+ padding-bottom: 1rem;
+ padding-left: 2.5rem;
+ padding-right: 2.5rem;
+ min-height: min-content;
+ max-height: 37.5rem;
+ height: 20vh;
+ position: relative;
+`;
+
+const CallToActionContainer = styled.div`
+ margin: 0 auto;
+ max-width: 590px;
+`;
+
+export { CallToAction };
diff --git a/packages/dev-tools-pages/ts/components/code.tsx b/packages/dev-tools-pages/ts/components/code.tsx
index c4f9cee24..0f7d6a0cd 100644
--- a/packages/dev-tools-pages/ts/components/code.tsx
+++ b/packages/dev-tools-pages/ts/components/code.tsx
@@ -139,7 +139,6 @@ class Code extends React.Component<CodeProps, CodeState> {
public render(): React.ReactNode {
const { language, isLight, isDiff, children, gutterLength, canCopy } = this.props;
const { hlCode } = this.state;
-
return (
<Container>
<Base language={language} isDiff={isDiff} isLight={isLight}>
@@ -157,7 +156,7 @@ class Code extends React.Component<CodeProps, CodeState> {
<StyledCopyInput readOnly={true} aria-hidden="true" ref={this._code} value={children} />
) : null}
</Base>
- {navigator.userAgent !== 'ReactSnap' && canCopy ? (
+ {canCopy ? (
<Button onClick={this._handleCopyAsync.bind(this)}>{this.state.didCopy ? 'Copied' : 'Copy'}</Button>
) : null}
</Container>
diff --git a/packages/dev-tools-pages/ts/components/compiler.tsx b/packages/dev-tools-pages/ts/components/compiler.tsx
index 694a535dd..c00e3a2b9 100644
--- a/packages/dev-tools-pages/ts/components/compiler.tsx
+++ b/packages/dev-tools-pages/ts/components/compiler.tsx
@@ -45,7 +45,7 @@ const Dd = styled.dd`
const cards = [
{
- title: 'A Project-centric',
+ title: 'Project-centric',
body: (
<React.Fragment>
Compiles an entire project instead of only individual <InlineCode isAlt={true}>.sol</InlineCode> files.
@@ -54,7 +54,7 @@ const cards = [
},
{
title: 'Incremental builds',
- body: 'Recompiles your smart contracts after they have changed',
+ body: 'Only recompiles smart contracts that have been modified.',
},
{
title: 'Customizable artifacts',
@@ -63,12 +63,16 @@ const cards = [
},
{
title: 'Seamless',
- body: 'Fetches and caches the required compiler binaries.',
+ body: 'Fetches and caches the required compiler binaries for the Solidity versions you use.',
},
{
title: 'Versioning',
body:
- 'Compiles each contract with the version specified at the top of its file (sol-compiler even supports version ranges!).',
+ 'Compiles each contract with the Solidity version specified at the top of its file (it even supports version ranges!).',
+ },
+ {
+ title: 'Watch mode',
+ body: 'Have your contracts instantly recompile on file save.',
},
];
diff --git a/packages/dev-tools-pages/ts/components/footer.tsx b/packages/dev-tools-pages/ts/components/footer.tsx
index 04fd9b88e..7e44bf128 100644
--- a/packages/dev-tools-pages/ts/components/footer.tsx
+++ b/packages/dev-tools-pages/ts/components/footer.tsx
@@ -3,7 +3,7 @@ import * as React from 'react';
import styled from 'styled-components';
import { context as compiler } from 'ts/context/compiler';
-import { context as cov } from 'ts/context/cov';
+import { context as coverage } from 'ts/context/coverage';
import { context as profiler } from 'ts/context/profiler';
import { context as trace } from 'ts/context/trace';
import MainIcon from 'ts/icons/logos/0x.svg';
@@ -12,7 +12,7 @@ import { media } from 'ts/variables';
import { Container } from './container';
import { Alpha, Beta } from './typography';
-const tools = [trace, cov, compiler, profiler];
+const tools = [trace, coverage, compiler, profiler];
const Footer: React.StatelessComponent<{}> = () => (
<StyledFooter>
@@ -20,9 +20,9 @@ const Footer: React.StatelessComponent<{}> = () => (
<Top>
<Alpha>Other tools by 0x</Alpha>
<List>
- {_.map(tools, ({ title, subtitle, icon }) => (
+ {_.map(tools, ({ title, subtitle, icon, name }) => (
<ListItem key={title}>
- <ListLink href="#">
+ <ListLink href={`https://sol-${name}.com`}>
<Icon as={icon as 'svg'} />
<div>
<Beta>{title}</Beta>
@@ -37,6 +37,10 @@ const Footer: React.StatelessComponent<{}> = () => (
<Icon as={MainIcon} />
<Small>
0x is an open, permissionless protocol allowing for tokens to be traded on the Ethereum blockchain.
+ Interested in joining our team?{' '}
+ <a href="https://0x.org/careers" target="_blank">
+ We're hiring
+ </a>
</Small>
</Media>
</Container>
diff --git a/packages/dev-tools-pages/ts/components/header.tsx b/packages/dev-tools-pages/ts/components/header.tsx
index 2787692c1..4d3a8685c 100644
--- a/packages/dev-tools-pages/ts/components/header.tsx
+++ b/packages/dev-tools-pages/ts/components/header.tsx
@@ -17,7 +17,7 @@ const Header: React.StatelessComponent<{}> = () => (
<Title>{title}</Title>
</LogoMark>
- <Link as="a" href="https://0xproject.com/">
+ <Link as="a" href="https://0x.org/" target="_blank">
Built by 0x
</Link>
</Container>
diff --git a/packages/dev-tools-pages/ts/components/hero.tsx b/packages/dev-tools-pages/ts/components/hero.tsx
index cdcad6982..e2977f3f2 100644
--- a/packages/dev-tools-pages/ts/components/hero.tsx
+++ b/packages/dev-tools-pages/ts/components/hero.tsx
@@ -9,16 +9,16 @@ import { Beta } from './typography';
const Hero: React.StatelessComponent<ContextInterface> = ({ children }) => (
<ThemeContext.Consumer>
- {({ subtitle, tagline }: ContextInterface) => (
+ {({ subtitle, tagline, docLink }: ContextInterface) => (
<StyledHero>
<HeroContainer>
<Subtitle>{subtitle}</Subtitle>
<Tagline as="p">{tagline}</Tagline>
- <Button as="a" href="#" large={true}>
+ <Button as="a" href={docLink} target="_blank" large={true}>
Read the Docs
</Button>
</HeroContainer>
- {navigator.userAgent !== 'ReactSnap' ? children : null}
+ {children}
</StyledHero>
)}
</ThemeContext.Consumer>
diff --git a/packages/dev-tools-pages/ts/components/trace.tsx b/packages/dev-tools-pages/ts/components/trace.tsx
index f41dac9b7..81f6db0ab 100644
--- a/packages/dev-tools-pages/ts/components/trace.tsx
+++ b/packages/dev-tools-pages/ts/components/trace.tsx
@@ -25,7 +25,7 @@ const Trace: React.StatelessComponent<{}> = () => (
troublemaking line of code. The only hint you'll get is a generic error.
</MainCopy>
<Breakout>
- <Code isLight={true}>Error: VM Exception while processing transaction: rever</Code>
+ <Code isLight={true}>Error: VM Exception while processing transaction: revert</Code>
</Breakout>
<List>
@@ -44,8 +44,8 @@ const Trace: React.StatelessComponent<{}> = () => (
<Copy dark={true}>
<Gamma as="h3">Time-consuming</Gamma>
<p>
- Working with a large code-base that contains hundreds of smart contracts,
- finding the failing line of code quickly becomes a daunting task.
+ Working within a large code-base that contains many smart contracts, finding the
+ failing line of code quickly becomes a daunting task.
</p>
</Copy>
<Icon as={TimeConsuming} />
@@ -78,8 +78,8 @@ const Trace: React.StatelessComponent<{}> = () => (
<Copy>
<Gamma as="h3">Exact location</Gamma>
<p>
- It shows you the exact location of the specific code linen and where it was
- called from.
+ It shows you the exact location of the offending line and where it was called
+ from.
</p>
</Copy>
<Icon as={ExactLocation} />
@@ -90,8 +90,7 @@ const Trace: React.StatelessComponent<{}> = () => (
<Gamma as="h3">Time-saving</Gamma>
<p>
Turning "Your code failed somewhere, good luck debugging it" into "Your code
- failed on line X of contract Y", it drastically improves the developer
- experience.
+ failed on line X of contract Y", drastically improves the developer experience.
</p>
</Copy>
<Icon as={TimeSaving} />
diff --git a/packages/dev-tools-pages/ts/context/compiler.tsx b/packages/dev-tools-pages/ts/context/compiler.tsx
index 177e265e5..e4642c826 100644
--- a/packages/dev-tools-pages/ts/context/compiler.tsx
+++ b/packages/dev-tools-pages/ts/context/compiler.tsx
@@ -5,6 +5,7 @@ import { ContextInterface } from './index';
export const context: ContextInterface = {
title: 'sol-compiler',
name: 'compiler',
+ docLink: 'https://0x.org/docs/sol-compiler',
subtitle: 'Solidity compilation that just works',
tagline: 'Seamlessly compile an entire solidity project and generate customisable artifacts',
icon: Icon,
diff --git a/packages/dev-tools-pages/ts/context/cov.tsx b/packages/dev-tools-pages/ts/context/coverage.tsx
index 1ade45e9d..3e44b6ec2 100644
--- a/packages/dev-tools-pages/ts/context/cov.tsx
+++ b/packages/dev-tools-pages/ts/context/coverage.tsx
@@ -3,9 +3,10 @@ import Icon from 'ts/icons/logos/cov.svg';
import { ContextInterface } from './index';
export const context: ContextInterface = {
- title: 'sol-cov',
- name: 'cov',
+ title: 'sol-coverage',
+ name: 'coverage',
subtitle: 'Solidity code coverage',
+ docLink: 'https://0x.org/docs/sol-coverage',
tagline: 'Measure Solidity code coverage',
icon: Icon,
colors: {
diff --git a/packages/dev-tools-pages/ts/context/index.tsx b/packages/dev-tools-pages/ts/context/index.tsx
index 35c647ad6..97ccf5c16 100644
--- a/packages/dev-tools-pages/ts/context/index.tsx
+++ b/packages/dev-tools-pages/ts/context/index.tsx
@@ -3,6 +3,7 @@ import { createContext } from 'react';
interface ContextInterface {
title?: string;
name?: string;
+ docLink?: string;
subtitle?: string;
tagline?: string;
icon?: React.ReactNode;
diff --git a/packages/dev-tools-pages/ts/context/profiler.tsx b/packages/dev-tools-pages/ts/context/profiler.tsx
index 5ccfa5b4c..e2ddcb230 100644
--- a/packages/dev-tools-pages/ts/context/profiler.tsx
+++ b/packages/dev-tools-pages/ts/context/profiler.tsx
@@ -5,6 +5,7 @@ import { ContextInterface } from './index';
export const context: ContextInterface = {
title: 'sol-profiler',
name: 'profiler',
+ docLink: 'https://0x.org/docs/sol-profiler',
subtitle: 'Gas profiling for Solidity',
tagline: "Implement data-guided optimizations by profiling your contract's gas usage",
icon: Icon,
diff --git a/packages/dev-tools-pages/ts/context/trace.tsx b/packages/dev-tools-pages/ts/context/trace.tsx
index 9627cc0a4..3c19661f2 100644
--- a/packages/dev-tools-pages/ts/context/trace.tsx
+++ b/packages/dev-tools-pages/ts/context/trace.tsx
@@ -6,6 +6,7 @@ export const context: ContextInterface = {
title: 'sol-trace',
name: 'trace',
subtitle: 'Human-readable stack traces',
+ docLink: 'https://0x.org/docs/sol-trace',
tagline: 'Immediately locate Solidity errors and rapidly debug failed transactions',
icon: Icon,
colors: {
diff --git a/packages/dev-tools-pages/ts/pages/compiler.tsx b/packages/dev-tools-pages/ts/pages/compiler.tsx
index 93a667562..407646add 100644
--- a/packages/dev-tools-pages/ts/pages/compiler.tsx
+++ b/packages/dev-tools-pages/ts/pages/compiler.tsx
@@ -6,6 +6,7 @@ import { context } from 'ts/context/compiler';
import { Base } from 'ts/components/base';
import { Breakout } from 'ts/components/breakout';
+import { CallToAction } from 'ts/components/call_to_action';
import { Code } from 'ts/components/code';
import { Compiler as CompilerComponent } from 'ts/components/compiler';
import { Content } from 'ts/components/content';
@@ -24,6 +25,9 @@ const Animation = Loadable({
},
});
+const SOLIDITY_INPUT_FORMAT_DOCS =
+ 'https://solidity.readthedocs.io/en/v0.4.24/using-the-compiler.html#compiler-input-and-output-json-description';
+
const Compiler: React.StatelessComponent<{}> = () => (
<Base context={context}>
<Hero>
@@ -40,7 +44,7 @@ const Compiler: React.StatelessComponent<{}> = () => (
<ContentBlock title="Run">
<Breakout>
- <Code>cd /your_project_dir && sol-compiler</Code>
+ <Code canCopy={true}>cd /your_project_dir && sol-compiler</Code>
</Breakout>
</ContentBlock>
@@ -49,11 +53,11 @@ const Compiler: React.StatelessComponent<{}> = () => (
Configure via a <InlineCode>compiler.json</InlineCode> file.
</p>
<Breakout>
- <Code>mkdir compiler.json</Code>
+ <Code canCopy={true}>mkdir compiler.json</Code>
</Breakout>
<p>Example of settings:</p>
<Breakout>
- <Code language="json">
+ <Code language="json" canCopy={true}>
{`{
"contractsDir": "contracts",
"artifactsDir": "artifacts",
@@ -74,15 +78,19 @@ const Compiler: React.StatelessComponent<{}> = () => (
<Content dark={true}>
<ContentBlock main={true} title="Artifacts">
<Lead>
- Sol compiler uses solidity standard JSON output format for the artifacts. This way, you can define
- which parts of the artifact you need.
+ Sol compiler uses{' '}
+ <a href={SOLIDITY_INPUT_FORMAT_DOCS} target="_blank">
+ Solidity standard JSON input format
+ </a>{' '}
+ to specify what to include in the generated artifacts. This way, you have complete flexibility on
+ what is included.
</Lead>
</ContentBlock>
<ContentBlock title="Production">
<p>
- Sol compiler uses solidity standard JSON output format for the artifacts. This way, you can define
- which parts of the artifact you need.
+ In production, you want to optimize for a small bundle size, so your compiler.json config would
+ instruct sol-compiler to only output the contract ABI.
</p>
<Breakout>
<Code isLight={true} language="json" isEtc={true}>
@@ -109,8 +117,9 @@ const Compiler: React.StatelessComponent<{}> = () => (
</ContentBlock>
<ContentBlock title="Development">
<p>
- Sometimes you need to use some debuggers or other dev tools and you’ll need more info in the
- artifact.
+ In development, you need to use profiler and other dev tools that require more information from the
+ artifact. To do this, you can specify that the artifact also contain the bytecode, deployed bytecode
+ and source maps.
</p>
<Breakout>
<Code isLight={true} language="json" isEtc={true}>
@@ -158,6 +167,9 @@ const Compiler: React.StatelessComponent<{}> = () => (
</Breakout>
</ContentBlock>
</Content>
+ <div style={{ paddingTop: '5rem' }}>
+ <CallToAction />
+ </div>
</Base>
);
diff --git a/packages/dev-tools-pages/ts/pages/cov.tsx b/packages/dev-tools-pages/ts/pages/coverage.tsx
index 85487248a..575891f3b 100644
--- a/packages/dev-tools-pages/ts/pages/cov.tsx
+++ b/packages/dev-tools-pages/ts/pages/coverage.tsx
@@ -2,10 +2,11 @@ import * as React from 'react';
import { hydrate, render } from 'react-dom';
import * as Loadable from 'react-loadable';
-import { context } from 'ts/context/cov';
+import { context } from 'ts/context/coverage';
import { Base } from 'ts/components/base';
import { Breakout } from 'ts/components/breakout';
+import { CallToAction } from 'ts/components/call_to_action';
import { Code } from 'ts/components/code';
import { Content } from 'ts/components/content';
import { ContentBlock } from 'ts/components/content-block';
@@ -25,7 +26,7 @@ const Animation = Loadable({
},
});
-const Cov: React.StatelessComponent<{}> = () => (
+const Coverage: React.StatelessComponent<{}> = () => (
<Base context={context}>
<Hero>
<Animation />
@@ -33,9 +34,9 @@ const Cov: React.StatelessComponent<{}> = () => (
<Intro>
<IntroLead title="Measure your tests">
<p>
- When it comes to writing smart contracts, testing is one of the most important steps of the process.
- In order to quantify the robustness of your Solidity testing suite, you need to measure its code
- coverage.
+ When it comes to writing secure smart contracts, testing is one of the most important steps in the
+ process. In order to quantify the robustness of your Solidity testing suite, you need to measure its
+ code coverage.
</p>
</IntroLead>
<IntroAside>
@@ -69,29 +70,57 @@ const Cov: React.StatelessComponent<{}> = () => (
<ContentBlock title="Prerequisites">
<List>
<ListItem>
- Use <a href="#">ganache-cli</a> as a backing node.
+ Use{' '}
+ <a href="https://github.com/ethereum/go-ethereum" target="_blank">
+ Geth
+ </a>{' '}
+ as a backing node. We recommend using our{' '}
+ <a href="https://hub.docker.com/r/0xorg/devnet" target="_blank">
+ Devnet Docker container
+ </a>{' '}
+ which sets up a Geth node for testing purposes.{' '}
+ <a href="https://github.com/0xProject/0x-monorepo/issues/1520" target="_blank">
+ Ganache support is a work in progress.
+ </a>
</ListItem>
<ListItem>
- Understand and use <a href="#">web3-provider-engine</a>.
+ Understand and use{' '}
+ <a href="https://github.com/MetaMask/provider-engine" target="_blank">
+ web3-provider-engine
+ </a>
+ .
</ListItem>
</List>
</ContentBlock>
<ContentBlock title="Installation">
<Breakout>
- <Code>npm install @0x/sol-coverage --save</Code>
+ <Code canCopy={true}>npm install @0x/sol-coverage --save</Code>
</Breakout>
<p>
- Sol-cov is a subprovider that needs to be prepended to your <a href="#">provider engine</a>.
- Depending on your project setup, you will need to use a specific ArtifactAdapter. Sol-cov ships with
- the <InlineCode>SolCompilerArtifactAdapter</InlineCode> for use with <a href="#">Sol-compiler</a>{' '}
+ Sol-coverage is a subprovider that needs to be prepended to your{' '}
+ <a href="https://github.com/MetaMask/provider-engine" target="_blank">
+ provider engine
+ </a>
+ . Depending on your project setup, you will need to use a specific ArtifactAdapter. Sol-coverage
+ ships with the <InlineCode>SolCompilerArtifactAdapter</InlineCode> for use with{' '}
+ <a href="https://sol-compiler.com" target="_blank">
+ Sol-compiler
+ </a>{' '}
and <InlineCode>TruffleArtifactAdapter</InlineCode> for use with the{' '}
- <a href="#">Truffle framework</a>. You can also write your own and support any artifact format.
+ <a href="https://truffleframework.com/truffle" target="_blank">
+ Truffle framework
+ </a>{' '}
+ (Also see our{' '}
+ <a href="https://github.com/0xProject/dev-tools-truffle-example" target="_blank">
+ Truffle example project
+ </a>{' '}
+ for a complete walk-through). You can also write your own and support any artifact format.
</p>
<Tabs>
<TabBlock title="Sol-compiler">
- <Code language="javascript">
+ <Code language="javascript" canCopy={true}>
{`import { SolCompilerArtifactAdapter } from '@0x/sol-trace';
// Both artifactsDir and contractsDir are optional and will be fetched from compiler.json if not passed in
@@ -99,16 +128,16 @@ const artifactAdapter = new SolCompilerArtifactAdapter(artifactsDir, contractsDi
</Code>
</TabBlock>
<TabBlock title="Truffle">
- <Code language="javascript">
+ <Code language="javascript" canCopy={true}>
{`import { TruffleArtifactAdapter } from '@0x/sol-trace';
const projectRoot = '.';
-const solcVersion = '0.4.24';
+const solcVersion = '0.5.0';
const artifactAdapter = new TruffleArtifactAdapter(projectRoot, solcVersion);`}
</Code>
</TabBlock>
<TabBlock title="Custom">
- <Code language="javascript">
+ <Code language="javascript" canCopy={true}>
{`import { AbstractArtifactAdapter } from '@0x/sol-trace';
class YourCustomArtifactsAdapter extends AbstractArtifactAdapter {...};
@@ -118,32 +147,33 @@ const artifactAdapter = new YourCustomArtifactsAdapter(...);`}
</Tabs>
<p>
Now that we have an <InlineCode>artifactAdapter</InlineCode>, we can create a{' '}
- <InlineCode>RevertTraceSubprovider</InlineCode> and append it to our provider engine.
+ <InlineCode>CoverageSubprovider</InlineCode> and append it to our provider engine.
</p>
<Breakout>
- <Code language="javascript">
+ <Code language="javascript" canCopy={true}>
{`import { ProviderEngine, RpcSubprovider } from 'web3-provider-engine';
-import { RevertTraceSubprovider } from '@0x/sol-coverage';
+import { CoverageSubprovider } from '@0x/sol-coverage';
const defaultFromAddress = "..."; // Some ethereum address with test funds
-const revertTraceSubprovider = new RevertTraceSubprovider(artifactAdapter, defaultFromAddress);
+const coverageSubprovider = new CoverageSubprovider(artifactAdapter, defaultFromAddress);
const providerEngine = new ProviderEngine();
-providerEngine.addProvider(revertTraceSubprovider);
+providerEngine.addProvider(coverageSubprovider);
providerEngine.addProvider(new RpcSubprovider({rpcUrl: 'http://localhost:8545'}));
providerEngine.start();`}
</Code>
</Breakout>
</ContentBlock>
</Content>
+ <CallToAction />
</Base>
);
const root = document.getElementById('app');
if (root.hasChildNodes()) {
- hydrate(<Cov />, root);
+ hydrate(<Coverage />, root);
} else {
- render(<Cov />, root);
+ render(<Coverage />, root);
}
diff --git a/packages/dev-tools-pages/ts/pages/profiler.tsx b/packages/dev-tools-pages/ts/pages/profiler.tsx
index 16ac9088e..0bc4efa45 100644
--- a/packages/dev-tools-pages/ts/pages/profiler.tsx
+++ b/packages/dev-tools-pages/ts/pages/profiler.tsx
@@ -6,6 +6,7 @@ import { context } from 'ts/context/profiler';
import { Base } from 'ts/components/base';
import { Breakout } from 'ts/components/breakout';
+import { CallToAction } from 'ts/components/call_to_action';
import { Code } from 'ts/components/code';
import { Content } from 'ts/components/content';
import { ContentBlock } from 'ts/components/content-block';
@@ -66,29 +67,57 @@ const Profiler: React.StatelessComponent<{}> = () => (
<ContentBlock title="Prerequisites">
<List>
<ListItem>
- Use <a href="#">ganache-cli</a> as a backing node.
+ Use{' '}
+ <a href="https://github.com/ethereum/go-ethereum" target="_blank">
+ Geth
+ </a>{' '}
+ as a backing node. We recommend using our{' '}
+ <a href="https://hub.docker.com/r/0xorg/devnet" target="_blank">
+ Devnet Docker container
+ </a>{' '}
+ which sets up a Geth node for testing purposes.{' '}
+ <a href="https://github.com/0xProject/0x-monorepo/issues/1520" target="_blank">
+ Ganache support is a work in progress.
+ </a>
</ListItem>
<ListItem>
- Understand and use <a href="#">web3-provider-engine</a>.
+ Understand and use{' '}
+ <a href="https://github.com/MetaMask/provider-engine" target="_blank">
+ web3-provider-engine
+ </a>
+ .
</ListItem>
</List>
</ContentBlock>
<ContentBlock title="Installation">
<Breakout>
- <Code>npm install @0x/sol-trace --save</Code>
+ <Code canCopy={true}>npm install @0x/sol-trace --save</Code>
</Breakout>
<p>
- Sol-trace is a subprovider that needs to be prepended to your <a href="#">provider engine</a>.
- Depending on your project setup, you will need to use a specific ArtifactAdapter. Sol-trace ships
+ Sol-trace is a subprovider that needs to be prepended to your{' '}
+ <a href="https://github.com/MetaMask/provider-engine" target="_blank">
+ provider engine
+ </a>
+ . Depending on your project setup, you will need to use a specific ArtifactAdapter. Sol-trace ships
with the <InlineCode>SolCompilerArtifactAdapter</InlineCode> for use with{' '}
- <a href="#">Sol-compiler</a> and <InlineCode>TruffleArtifactAdapter</InlineCode> for use with the{' '}
- <a href="#">Truffle framework</a>. You can also write your own and support any artifact format.
+ <a href="https://sol-compiler.com" target="_blank">
+ Sol-compiler
+ </a>{' '}
+ and <InlineCode>TruffleArtifactAdapter</InlineCode> for use with the{' '}
+ <a href="https://truffleframework.com/truffle" target="_blank">
+ Truffle framework
+ </a>{' '}
+ (Also see our{' '}
+ <a href="https://github.com/0xProject/dev-tools-truffle-example" target="_blank">
+ Truffle example project
+ </a>{' '}
+ for a complete walk-through). You can also write your own and support any artifact format.
</p>
<Tabs>
<TabBlock title="Sol-compiler">
- <Code language="javascript">
+ <Code language="javascript" canCopy={true}>
{`import { SolCompilerArtifactAdapter } from '@0x/sol-trace';
// Both artifactsDir and contractsDir are optional and will be fetched from compiler.json if not passed in
@@ -96,16 +125,16 @@ const artifactAdapter = new SolCompilerArtifactAdapter(artifactsDir, contractsDi
</Code>
</TabBlock>
<TabBlock title="Truffle">
- <Code language="javascript">
+ <Code language="javascript" canCopy={true}>
{`import { TruffleArtifactAdapter } from '@0x/sol-trace';
const projectRoot = '.';
-const solcVersion = '0.4.24';
+const solcVersion = '0.5.0';
const artifactAdapter = new TruffleArtifactAdapter(projectRoot, solcVersion);`}
</Code>
</TabBlock>
<TabBlock title="Custom">
- <Code language="javascript">
+ <Code language="javascript" canCopy={true}>
{`import { AbstractArtifactAdapter } from '@0x/sol-trace';
class YourCustomArtifactsAdapter extends AbstractArtifactAdapter {...};
@@ -115,25 +144,26 @@ const artifactAdapter = new YourCustomArtifactsAdapter(...);`}
</Tabs>
<p>
Now that we have an <InlineCode>artifactAdapter</InlineCode>, we can create a{' '}
- <InlineCode>RevertTraceSubprovider</InlineCode> and append it to our provider engine.
+ <InlineCode>ProfilerSubprovider</InlineCode> and append it to our provider engine.
</p>
<Breakout>
- <Code language="javascript">
+ <Code language="javascript" canCopy={true}>
{`import { ProviderEngine, RpcSubprovider } from 'web3-provider-engine';
-import { RevertTraceSubprovider } from '@0x/sol-coverage';
+import { ProfilerSubprovider } from '@0x/sol-profiler';
const defaultFromAddress = "..."; // Some ethereum address with test funds
-const revertTraceSubprovider = new RevertTraceSubprovider(artifactAdapter, defaultFromAddress);
+const profilerSubprovider = new ProfilerSubprovider(artifactAdapter, defaultFromAddress);
const providerEngine = new ProviderEngine();
-providerEngine.addProvider(revertTraceSubprovider);
+providerEngine.addProvider(profilerSubprovider);
providerEngine.addProvider(new RpcSubprovider({rpcUrl: 'http://localhost:8545'}));
providerEngine.start();`}
</Code>
</Breakout>
</ContentBlock>
</Content>
+ <CallToAction />
</Base>
);
diff --git a/packages/dev-tools-pages/ts/pages/trace.tsx b/packages/dev-tools-pages/ts/pages/trace.tsx
index cc34e0fbe..cd6180fb9 100644
--- a/packages/dev-tools-pages/ts/pages/trace.tsx
+++ b/packages/dev-tools-pages/ts/pages/trace.tsx
@@ -6,6 +6,7 @@ import { context } from 'ts/context/trace';
import { Base } from 'ts/components/base';
import { Breakout } from 'ts/components/breakout';
+import { CallToAction } from 'ts/components/call_to_action';
import { Code } from 'ts/components/code';
import { Content } from 'ts/components/content';
import { ContentBlock } from 'ts/components/content-block';
@@ -36,29 +37,57 @@ const Trace: React.StatelessComponent<{}> = () => (
<ContentBlock title="Prerequisites">
<List>
<ListItem>
- Use <a href="#">ganache-cli</a> as a backing node.
+ Use{' '}
+ <a href="https://github.com/ethereum/go-ethereum" target="_blank">
+ Geth
+ </a>{' '}
+ as a backing node. We recommend using our{' '}
+ <a href="https://hub.docker.com/r/0xorg/devnet" target="_blank">
+ Devnet Docker container
+ </a>{' '}
+ which sets up a Geth node for testing purposes.{' '}
+ <a href="https://github.com/0xProject/0x-monorepo/issues/1520" target="_blank">
+ Ganache support is a work in progress.
+ </a>
</ListItem>
<ListItem>
- Understand and use <a href="#">web3-provider-engine</a>.
+ Understand and use{' '}
+ <a href="https://github.com/MetaMask/provider-engine" target="_blank">
+ web3-provider-engine
+ </a>
+ .
</ListItem>
</List>
</ContentBlock>
<ContentBlock title="Installation">
<Breakout>
- <Code>npm install @0x/sol-trace --save</Code>
+ <Code canCopy={true}>npm install @0x/sol-trace --save</Code>
</Breakout>
<p>
- Sol-trace is a subprovider that needs to be prepended to your <a href="#">provider engine</a>.
- Depending on your project setup, you will need to use a specific ArtifactAdapter. Sol-trace ships
+ Sol-trace is a subprovider that needs to be prepended to your{' '}
+ <a href="https://github.com/MetaMask/provider-engine" target="_blank">
+ provider engine
+ </a>
+ . Depending on your project setup, you will need to use a specific ArtifactAdapter. Sol-trace ships
with the <InlineCode>SolCompilerArtifactAdapter</InlineCode> for use with{' '}
- <a href="#">Sol-compiler</a> and <InlineCode>TruffleArtifactAdapter</InlineCode> for use with the{' '}
- <a href="#">Truffle framework</a>. You can also write your own and support any artifact format.
+ <a href="https://sol-compiler.com" target="_blank">
+ Sol-compiler
+ </a>{' '}
+ and <InlineCode>TruffleArtifactAdapter</InlineCode> for use with the{' '}
+ <a href="https://truffleframework.com/truffle" target="_blank">
+ Truffle framework
+ </a>{' '}
+ (Also see our{' '}
+ <a href="https://github.com/0xProject/dev-tools-truffle-example" target="_blank">
+ Truffle example project
+ </a>{' '}
+ for a complete walk-through). You can also write your own and support any artifact format.
</p>
<Tabs>
<TabBlock title="Sol-compiler">
- <Code language="javascript">
+ <Code language="javascript" canCopy={true}>
{`import { SolCompilerArtifactAdapter } from '@0x/sol-trace';
// Both artifactsDir and contractsDir are optional and will be fetched from compiler.json if not passed in
@@ -66,16 +95,16 @@ const artifactAdapter = new SolCompilerArtifactAdapter(artifactsDir, contractsDi
</Code>
</TabBlock>
<TabBlock title="Truffle">
- <Code language="javascript">
+ <Code language="javascript" canCopy={true}>
{`import { TruffleArtifactAdapter } from '@0x/sol-trace';
const projectRoot = '.';
-const solcVersion = '0.4.24';
+const solcVersion = '0.5.0';
const artifactAdapter = new TruffleArtifactAdapter(projectRoot, solcVersion);`}
</Code>
</TabBlock>
<TabBlock title="Custom">
- <Code language="javascript">
+ <Code language="javascript" canCopy={true}>
{`import { AbstractArtifactAdapter } from '@0x/sol-trace';
class YourCustomArtifactsAdapter extends AbstractArtifactAdapter {...};
@@ -85,13 +114,13 @@ const artifactAdapter = new YourCustomArtifactsAdapter(...);`}
</Tabs>
<p>
Now that we have an <InlineCode>artifactAdapter</InlineCode>, we can create a{' '}
- <InlineCode>RevertTraceSubprovider</InlineCode> and append it to our provider engine.
+ <InlineCode>revertTraceSubprovider</InlineCode> and append it to our provider engine.
</p>
<Breakout>
- <Code language="javascript">
+ <Code language="javascript" canCopy={true}>
{`import { ProviderEngine, RpcSubprovider } from 'web3-provider-engine';
-import { RevertTraceSubprovider } from '@0x/sol-coverage';
+import { RevertTraceSubprovider } from '@0x/sol-trace';
const defaultFromAddress = "..."; // Some ethereum address with test funds
const revertTraceSubprovider = new RevertTraceSubprovider(artifactAdapter, defaultFromAddress);
@@ -102,8 +131,10 @@ providerEngine.addProvider(new RpcSubprovider({rpcUrl: 'http://localhost:8545'})
providerEngine.start();`}
</Code>
</Breakout>
+ <p>Stack traces will now be printed whenever your contracts revert!</p>
</ContentBlock>
</Content>
+ <CallToAction />
</Base>
);
diff --git a/packages/dev-tools-pages/webpack.config.js b/packages/dev-tools-pages/webpack.config.js
index 640297770..ef2f98cf2 100644
--- a/packages/dev-tools-pages/webpack.config.js
+++ b/packages/dev-tools-pages/webpack.config.js
@@ -3,7 +3,6 @@ const webpack = require('webpack');
const TerserPlugin = require('terser-webpack-plugin');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const HtmlWebpackPlugin = require('html-webpack-plugin');
-const childProcess = require('child_process');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
@@ -12,7 +11,7 @@ const pages = require('./pages');
const config = {
entry: {
compiler: './ts/pages/compiler.tsx',
- cov: './ts/pages/cov.tsx',
+ coverage: './ts/pages/coverage.tsx',
profiler: './ts/pages/profiler.tsx',
trace: './ts/pages/trace.tsx',
},
diff --git a/packages/dev-utils/CHANGELOG.json b/packages/dev-utils/CHANGELOG.json
index 85189d70b..d05e41d2d 100644
--- a/packages/dev-utils/CHANGELOG.json
+++ b/packages/dev-utils/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "version": "2.0.0",
+ "changes": [
+ {
+ "note": "Upgrade the bignumber.js to v8.0.2",
+ "pr": 1517
+ }
+ ]
+ },
+ {
"timestamp": 1547561734,
"version": "1.0.24",
"changes": [
diff --git a/packages/devnet/docker-compose.yml b/packages/devnet/docker-compose.yml
new file mode 100644
index 000000000..1c1e7ca75
--- /dev/null
+++ b/packages/devnet/docker-compose.yml
@@ -0,0 +1,8 @@
+version: '3'
+services:
+ devnet:
+ image: 0x-devnet:latest
+ build:
+ context: .
+ ports:
+ - 8501:8501
diff --git a/packages/devnet/genesis.json b/packages/devnet/genesis.json
index 03dc5d623..073672dd9 100644
--- a/packages/devnet/genesis.json
+++ b/packages/devnet/genesis.json
@@ -8,7 +8,7 @@
"eip158Block": 3,
"byzantiumBlock": 4,
"clique": {
- "period": 1,
+ "period": 0,
"epoch": 30000
}
},
diff --git a/packages/devnet/run.sh b/packages/devnet/run.sh
index dea243396..6000813f0 100755
--- a/packages/devnet/run.sh
+++ b/packages/devnet/run.sh
@@ -15,6 +15,7 @@ mkdir -p /var/log
--rpc \
--rpcaddr '0.0.0.0' \
--rpcport 8501 \
+ --rpcvhosts '*' \
--rpcapi 'personal,db,eth,net,web3,txpool,miner,debug' \
--networkid 50 \
--gasprice '2000000000' \
diff --git a/packages/ethereum-types/CHANGELOG.json b/packages/ethereum-types/CHANGELOG.json
index 6265e01a1..c106d43a9 100644
--- a/packages/ethereum-types/CHANGELOG.json
+++ b/packages/ethereum-types/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "version": "2.0.0",
+ "changes": [
+ {
+ "note": "Upgrade the bignumber.js to v8.0.2",
+ "pr": 1517
+ }
+ ]
+ },
+ {
"timestamp": 1547561734,
"version": "1.1.6",
"changes": [
diff --git a/packages/ethereum-types/package.json b/packages/ethereum-types/package.json
index 953b323c6..bd3748058 100644
--- a/packages/ethereum-types/package.json
+++ b/packages/ethereum-types/package.json
@@ -37,7 +37,7 @@
},
"dependencies": {
"@types/node": "*",
- "bignumber.js": "~4.1.0"
+ "bignumber.js": "~8.0.2"
},
"publishConfig": {
"access": "public"
diff --git a/packages/fill-scenarios/CHANGELOG.json b/packages/fill-scenarios/CHANGELOG.json
index d8f2591a4..beffdd097 100644
--- a/packages/fill-scenarios/CHANGELOG.json
+++ b/packages/fill-scenarios/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "version": "2.0.0",
+ "changes": [
+ {
+ "note": "Upgrade the bignumber.js to v8.0.2",
+ "pr": 1517
+ }
+ ]
+ },
+ {
"timestamp": 1547561734,
"version": "1.1.2",
"changes": [
diff --git a/packages/instant/CHANGELOG.json b/packages/instant/CHANGELOG.json
index 537670584..c7348c3c0 100644
--- a/packages/instant/CHANGELOG.json
+++ b/packages/instant/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "version": "3.0.0",
+ "changes": [
+ {
+ "note": "Upgrade the bignumber.js to v8.0.2",
+ "pr": 1517
+ }
+ ]
+ },
+ {
"version": "2.0.0",
"changes": [
{
diff --git a/packages/instant/README.md b/packages/instant/README.md
index 8832e562d..f09c4776c 100644
--- a/packages/instant/README.md
+++ b/packages/instant/README.md
@@ -8,11 +8,11 @@ Check out a live sample integration [here](https://www.rexrelay.com/instant).
## Installation
-The package is available as a UMD module named `zeroExInstant` at https://instant.0xproject.com/instant.js.
+The package is available as a UMD module named `zeroExInstant` at https://instant.0x.org/instant.js.
```html
<head>
- <script type="text/javascript" src="https://instant.0xproject.com/instant.js" charset="utf-8"></script>
+ <script type="text/javascript" src="https://instant.0x.org/instant.js" charset="utf-8"></script>
</head>
<body>
<div id="zeroExInstantContainer"></div>
@@ -47,7 +47,7 @@ To build and deploy to this bundle, run
yarn deploy_staging
```
-Finally, we have our live production bundle that is only meant to be updated with stable, polished releases: https://instant.0xproject.com/instant.js
+Finally, we have our live production bundle that is only meant to be updated with stable, polished releases: https://instant.0x.org/instant.js
To build and deploy to this bundle, run
diff --git a/packages/instant/package.json b/packages/instant/package.json
index 36409ef3d..86fac9afe 100644
--- a/packages/instant/package.json
+++ b/packages/instant/package.json
@@ -1,6 +1,6 @@
{
"name": "@0x/instant",
- "version": "1.0.7",
+ "version": "1.0.8",
"engines": {
"node": ">=6.12"
},
@@ -42,7 +42,7 @@
"homepage": "https://github.com/0xProject/0x-monorepo/packages/instant/README.md",
"dependencies": {
"@0x/assert": "^1.0.23",
- "@0x/asset-buyer": "^4.0.1",
+ "@0x/asset-buyer": "^4.0.2",
"@0x/json-schemas": "^2.1.7",
"@0x/order-utils": "^3.1.2",
"@0x/subproviders": "^2.1.11",
diff --git a/packages/instant/src/components/order_details.tsx b/packages/instant/src/components/order_details.tsx
index 4db20b13e..3ded50652 100644
--- a/packages/instant/src/components/order_details.tsx
+++ b/packages/instant/src/components/order_details.tsx
@@ -77,7 +77,7 @@ export class OrderDetails extends React.PureComponent<OrderDetailsProps> {
}
private _hadErrorFetchingUsdPrice(): boolean {
- return this.props.ethUsdPrice ? this.props.ethUsdPrice.equals(BIG_NUMBER_ZERO) : false;
+ return this.props.ethUsdPrice ? this.props.ethUsdPrice.isEqualTo(BIG_NUMBER_ZERO) : false;
}
private _totalCostSecondaryValue(): React.ReactNode {
@@ -156,7 +156,7 @@ export class OrderDetails extends React.PureComponent<OrderDetailsProps> {
return !_.isUndefined(assetTotalInWei) &&
!_.isUndefined(selectedAssetUnitAmount) &&
!selectedAssetUnitAmount.eq(BIG_NUMBER_ZERO)
- ? assetTotalInWei.div(selectedAssetUnitAmount).ceil()
+ ? assetTotalInWei.div(selectedAssetUnitAmount).integerValue(BigNumber.ROUND_CEIL)
: undefined;
}
diff --git a/packages/instant/src/constants.ts b/packages/instant/src/constants.ts
index bfd9e9098..d407925a3 100644
--- a/packages/instant/src/constants.ts
+++ b/packages/instant/src/constants.ts
@@ -21,7 +21,7 @@ export const NPM_PACKAGE_VERSION = process.env.NPM_PACKAGE_VERSION;
export const DEFAULT_UNKOWN_ASSET_NAME = '???';
export const ACCOUNT_UPDATE_INTERVAL_TIME_MS = ONE_SECOND_MS * 5;
export const BUY_QUOTE_UPDATE_INTERVAL_TIME_MS = ONE_SECOND_MS * 15;
-export const DEFAULT_GAS_PRICE = GWEI_IN_WEI.mul(6);
+export const DEFAULT_GAS_PRICE = GWEI_IN_WEI.multipliedBy(6);
export const DEFAULT_ESTIMATED_TRANSACTION_TIME_MS = ONE_MINUTE_MS * 2;
export const MAGIC_TRIGGER_ERROR_INPUT = '0€';
export const MAGIC_TRIGGER_ERROR_MESSAGE = 'Triggered error';
diff --git a/packages/instant/src/containers/selected_erc20_asset_amount_input.ts b/packages/instant/src/containers/selected_erc20_asset_amount_input.ts
index cb9df527e..4b9993332 100644
--- a/packages/instant/src/containers/selected_erc20_asset_amount_input.ts
+++ b/packages/instant/src/containers/selected_erc20_asset_amount_input.ts
@@ -84,7 +84,7 @@ const mapDispatchToProps = (
// reset our buy state
dispatch(actions.setBuyOrderStateNone());
- if (!_.isUndefined(value) && value.greaterThan(0) && !_.isUndefined(asset)) {
+ if (!_.isUndefined(value) && value.isGreaterThan(0) && !_.isUndefined(asset)) {
// even if it's debounced, give them the illusion it's loading
dispatch(actions.setQuoteRequestStatePending());
// tslint:disable-next-line:no-floating-promises
diff --git a/packages/instant/src/index.umd.ts b/packages/instant/src/index.umd.ts
index d172f4145..0acf3f2ad 100644
--- a/packages/instant/src/index.umd.ts
+++ b/packages/instant/src/index.umd.ts
@@ -1,3 +1,6 @@
+import { AssetBuyer, BigNumber } from '@0x/asset-buyer';
+import { assetDataUtils } from '@0x/order-utils';
+import { Provider } from 'ethereum-types';
import * as _ from 'lodash';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
@@ -9,9 +12,12 @@ import {
INJECTED_DIV_ID,
NPM_PACKAGE_VERSION,
} from './constants';
+import { assetMetaDataMap } from './data/asset_meta_data_map';
import { ZeroExInstantOverlay, ZeroExInstantOverlayProps } from './index';
+import { Network, OrderSource } from './types';
import { analytics } from './util/analytics';
import { assert } from './util/assert';
+import { providerFactory } from './util/provider_factory';
import { util } from './util/util';
const isInstantRendered = (): boolean => !!document.getElementById(INJECTED_DIV_ID);
@@ -122,6 +128,42 @@ export const render = (config: ZeroExInstantConfig, selector: string = DEFAULT_Z
window.onpopstate = onPopStateHandler;
};
+export const assetDataForERC20TokenAddress = (tokenAddress: string): string => {
+ assert.isETHAddressHex('tokenAddress', tokenAddress);
+ return assetDataUtils.encodeERC20AssetData(tokenAddress);
+};
+
+export const hasMetaDataForAssetData = (assetData: string): boolean => {
+ assert.isHexString('assetData', assetData);
+ return assetMetaDataMap[assetData] !== undefined;
+};
+
+export const hasLiquidityForAssetDataAsync = async (
+ assetData: string,
+ orderSource: OrderSource,
+ networkId: Network = Network.Mainnet,
+ provider?: Provider,
+): Promise<boolean> => {
+ assert.isHexString('assetData', assetData);
+ assert.isValidOrderSource('orderSource', orderSource);
+ assert.isNumber('networkId', networkId);
+
+ if (provider !== undefined) {
+ assert.isWeb3Provider('provider', provider);
+ }
+
+ const bestProvider: Provider = provider || providerFactory.getFallbackNoSigningProvider(networkId);
+
+ const assetBuyerOptions = { networkId };
+
+ const assetBuyer = _.isString(orderSource)
+ ? AssetBuyer.getAssetBuyerForStandardRelayerAPIUrl(bestProvider, orderSource, assetBuyerOptions)
+ : AssetBuyer.getAssetBuyerForProvidedOrders(bestProvider, orderSource, assetBuyerOptions);
+
+ const liquidity = await assetBuyer.getLiquidityForAssetDataAsync(assetData);
+ return liquidity.ethValueAvailableInWei.gt(new BigNumber(0));
+};
+
// Write version info to the exported object for debugging
export const GIT_SHA = GIT_SHA_FROM_CONSTANT;
export const NPM_VERSION = NPM_PACKAGE_VERSION;
diff --git a/packages/instant/src/redux/async_data.ts b/packages/instant/src/redux/async_data.ts
index 884ab103d..f20fe319f 100644
--- a/packages/instant/src/redux/async_data.ts
+++ b/packages/instant/src/redux/async_data.ts
@@ -99,7 +99,7 @@ export const asyncData = {
if (
!_.isUndefined(selectedAssetUnitAmount) &&
!_.isUndefined(selectedAsset) &&
- selectedAssetUnitAmount.greaterThan(BIG_NUMBER_ZERO) &&
+ selectedAssetUnitAmount.isGreaterThan(BIG_NUMBER_ZERO) &&
buyOrderState.processState === OrderProcessState.None &&
selectedAsset.metaData.assetProxyId === AssetProxyId.ERC20
) {
diff --git a/packages/instant/src/util/asset.ts b/packages/instant/src/util/asset.ts
index 709561dbc..b5c97913d 100644
--- a/packages/instant/src/util/asset.ts
+++ b/packages/instant/src/util/asset.ts
@@ -114,15 +114,18 @@ export const assetUtils = {
const assetName = assetUtils.bestNameForAsset(asset, 'of this asset');
if (
error instanceof InsufficientAssetLiquidityError &&
- error.amountAvailableToFill.greaterThan(BIG_NUMBER_ZERO)
+ error.amountAvailableToFill.isGreaterThan(BIG_NUMBER_ZERO)
) {
const unitAmountAvailableToFill = Web3Wrapper.toUnitAmount(
error.amountAvailableToFill,
asset.metaData.decimals,
);
- const roundedUnitAmountAvailableToFill = unitAmountAvailableToFill.round(2, BigNumber.ROUND_DOWN);
+ const roundedUnitAmountAvailableToFill = unitAmountAvailableToFill.decimalPlaces(
+ 2,
+ BigNumber.ROUND_DOWN,
+ );
- if (roundedUnitAmountAvailableToFill.greaterThan(BIG_NUMBER_ZERO)) {
+ if (roundedUnitAmountAvailableToFill.isGreaterThan(BIG_NUMBER_ZERO)) {
return `There are only ${roundedUnitAmountAvailableToFill} ${assetName} available to buy`;
}
}
diff --git a/packages/instant/src/util/format.ts b/packages/instant/src/util/format.ts
index 4adb63e21..61aeb839f 100644
--- a/packages/instant/src/util/format.ts
+++ b/packages/instant/src/util/format.ts
@@ -25,16 +25,16 @@ export const format = {
if (_.isUndefined(ethUnitAmount)) {
return defaultText;
}
- let roundedAmount = ethUnitAmount.round(decimalPlaces).toDigits(decimalPlaces);
+ let roundedAmount = ethUnitAmount.decimalPlaces(decimalPlaces).precision(decimalPlaces);
- if (roundedAmount.eq(BIG_NUMBER_ZERO) && ethUnitAmount.greaterThan(BIG_NUMBER_ZERO)) {
+ if (roundedAmount.eq(BIG_NUMBER_ZERO) && ethUnitAmount.isGreaterThan(BIG_NUMBER_ZERO)) {
// Sometimes for small ETH amounts (i.e. 0.000045) the amount rounded to 4 decimalPlaces is 0
// If that is the case, show to 1 significant digit
roundedAmount = new BigNumber(ethUnitAmount.toPrecision(1));
}
const displayAmount =
- roundedAmount.greaterThan(BIG_NUMBER_ZERO) && roundedAmount.lessThan(minUnitAmountToDisplay)
+ roundedAmount.isGreaterThan(BIG_NUMBER_ZERO) && roundedAmount.isLessThan(minUnitAmountToDisplay)
? `< ${minUnitAmountToDisplay.toString()}`
: roundedAmount.toString();
@@ -62,7 +62,7 @@ export const format = {
if (_.isUndefined(ethUnitAmount) || _.isUndefined(ethUsdPrice)) {
return defaultText;
}
- const rawUsdPrice = ethUnitAmount.mul(ethUsdPrice);
+ const rawUsdPrice = ethUnitAmount.multipliedBy(ethUsdPrice);
const roundedUsdPrice = rawUsdPrice.toFixed(decimalPlaces);
if (roundedUsdPrice === '0.00' && rawUsdPrice.gt(BIG_NUMBER_ZERO)) {
return '<$0.01';
diff --git a/packages/instant/src/util/gas_price_estimator.ts b/packages/instant/src/util/gas_price_estimator.ts
index 332c8d00a..9792b60ba 100644
--- a/packages/instant/src/util/gas_price_estimator.ts
+++ b/packages/instant/src/util/gas_price_estimator.ts
@@ -35,7 +35,7 @@ const fetchFastAmountInWeiAsync = async (): Promise<GasInfo> => {
const gasPriceInGwei = new BigNumber(gasInfo.fast / 10);
// Time is in minutes
const estimatedTimeMs = gasInfo.fastWait * 60 * 1000; // Minutes to MS
- return { gasPriceInWei: gasPriceInGwei.mul(GWEI_IN_WEI), estimatedTimeMs };
+ return { gasPriceInWei: gasPriceInGwei.multipliedBy(GWEI_IN_WEI), estimatedTimeMs };
};
export class GasPriceEstimator {
diff --git a/packages/instant/src/util/maybe_big_number.ts b/packages/instant/src/util/maybe_big_number.ts
index 9d3746e10..f48473389 100644
--- a/packages/instant/src/util/maybe_big_number.ts
+++ b/packages/instant/src/util/maybe_big_number.ts
@@ -18,7 +18,7 @@ export const maybeBigNumberUtil = {
},
areMaybeBigNumbersEqual: (val1: Maybe<BigNumber>, val2: Maybe<BigNumber>): boolean => {
if (!_.isUndefined(val1) && !_.isUndefined(val2)) {
- return val1.equals(val2);
+ return val1.isEqualTo(val2);
}
return _.isUndefined(val1) && _.isUndefined(val2);
},
diff --git a/packages/json-schemas/CHANGELOG.json b/packages/json-schemas/CHANGELOG.json
index 1388b4dca..66de84299 100644
--- a/packages/json-schemas/CHANGELOG.json
+++ b/packages/json-schemas/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "version": "3.0.0",
+ "changes": [
+ {
+ "note": "Upgrade the bignumber.js to v8.0.2",
+ "pr": 1517
+ }
+ ]
+ },
+ {
"timestamp": 1547561734,
"version": "2.1.7",
"changes": [
diff --git a/packages/metacoin/package.json b/packages/metacoin/package.json
index accdd2949..3b082f075 100644
--- a/packages/metacoin/package.json
+++ b/packages/metacoin/package.json
@@ -1,6 +1,6 @@
{
"name": "@0x/metacoin",
- "version": "0.0.35",
+ "version": "0.0.36",
"engines": {
"node": ">=6.12"
},
@@ -32,9 +32,9 @@
"@0x/abi-gen": "^1.0.22",
"@0x/abi-gen-templates": "^1.0.2",
"@0x/base-contract": "^3.0.13",
- "@0x/sol-coverage": "^1.0.2",
- "@0x/sol-profiler": "^1.0.2",
- "@0x/sol-trace": "^1.0.2",
+ "@0x/sol-coverage": "^1.0.3",
+ "@0x/sol-profiler": "^1.0.3",
+ "@0x/sol-trace": "^1.0.3",
"@0x/subproviders": "^2.1.11",
"@0x/tslint-config": "^2.0.2",
"@0x/types": "^1.5.2",
@@ -53,7 +53,7 @@
"@0x/sol-compiler": "^2.0.2",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
- "chai-bignumber": "^2.0.1",
+ "chai-bignumber": "^3.0.0",
"dirty-chai": "^2.0.1",
"make-promises-safe": "^1.1.0",
"npm-run-all": "^4.1.2",
diff --git a/packages/migrations/CHANGELOG.json b/packages/migrations/CHANGELOG.json
index 5962a9886..64ae94b14 100644
--- a/packages/migrations/CHANGELOG.json
+++ b/packages/migrations/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "version": "3.0.0",
+ "changes": [
+ {
+ "note": "Upgrade the bignumber.js to v8.0.2",
+ "pr": 1517
+ }
+ ]
+ },
+ {
"version": "2.4.0",
"changes": [
{
diff --git a/packages/monorepo-scripts/CHANGELOG.json b/packages/monorepo-scripts/CHANGELOG.json
index cebe7ec72..a71bfbd6d 100644
--- a/packages/monorepo-scripts/CHANGELOG.json
+++ b/packages/monorepo-scripts/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "version": "2.0.0",
+ "changes": [
+ {
+ "note": "Upgrade the bignumber.js to v8.0.2",
+ "pr": 1517
+ }
+ ]
+ },
+ {
"version": "1.0.6",
"changes": [
{
diff --git a/packages/monorepo-scripts/package.json b/packages/monorepo-scripts/package.json
index e18aa1d2f..187a80c93 100644
--- a/packages/monorepo-scripts/package.json
+++ b/packages/monorepo-scripts/package.json
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@0x/monorepo-scripts",
- "version": "1.0.18",
+ "version": "1.0.19",
"engines": {
"node": ">=6.12"
},
diff --git a/packages/monorepo-scripts/src/utils/utils.ts b/packages/monorepo-scripts/src/utils/utils.ts
index 95b187cc2..28c5658f3 100644
--- a/packages/monorepo-scripts/src/utils/utils.ts
+++ b/packages/monorepo-scripts/src/utils/utils.ts
@@ -106,8 +106,10 @@ export const utils = {
return nextVersionIfValid;
},
async getRemoteGitTagsAsync(): Promise<string[]> {
+ const TEN_MEGA_BYTES = 1024 * 1024 * 10; // tslint:disable-line custom-no-magic-numbers
const result = await execAsync(`git ls-remote --tags`, {
cwd: constants.monorepoRootPath,
+ maxBuffer: TEN_MEGA_BYTES,
});
const tagsString = result.stdout;
const tagOutputs: string[] = tagsString.split('\n');
diff --git a/packages/order-utils/CHANGELOG.json b/packages/order-utils/CHANGELOG.json
index ace3656c4..08d88da5b 100644
--- a/packages/order-utils/CHANGELOG.json
+++ b/packages/order-utils/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "version": "4.0.0",
+ "changes": [
+ {
+ "note": "Upgrade the bignumber.js to v8.0.2",
+ "pr": 1517
+ }
+ ]
+ },
+ {
"timestamp": 1547561734,
"version": "3.1.2",
"changes": [
diff --git a/packages/order-utils/package.json b/packages/order-utils/package.json
index bdcbd2dfc..7a4d4aa84 100644
--- a/packages/order-utils/package.json
+++ b/packages/order-utils/package.json
@@ -41,7 +41,7 @@
"@types/lodash": "4.14.104",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
- "chai-bignumber": "^2.0.1",
+ "chai-bignumber": "^3.0.0",
"dirty-chai": "^2.0.1",
"make-promises-safe": "^1.1.0",
"mocha": "^4.1.0",
diff --git a/packages/order-utils/src/crypto.ts b/packages/order-utils/src/crypto.ts
index 0f1504a72..8b835ff48 100644
--- a/packages/order-utils/src/crypto.ts
+++ b/packages/order-utils/src/crypto.ts
@@ -1,3 +1,4 @@
+import { BigNumber } from '@0x/utils';
import BN = require('bn.js');
import ABI = require('ethereumjs-abi');
import ethUtil = require('ethereumjs-util');
@@ -24,7 +25,7 @@ export const crypto = {
const isNumber = _.isFinite(arg);
if (isNumber) {
argTypes.push('uint8');
- } else if (arg.isBigNumber) {
+ } else if (BigNumber.isBigNumber(arg)) {
argTypes.push('uint256');
const base = 10;
args[i] = new BN(arg.toString(base), base);
diff --git a/packages/order-utils/src/exchange_transfer_simulator.ts b/packages/order-utils/src/exchange_transfer_simulator.ts
index 06621fd9e..922ae8e17 100644
--- a/packages/order-utils/src/exchange_transfer_simulator.ts
+++ b/packages/order-utils/src/exchange_transfer_simulator.ts
@@ -88,14 +88,14 @@ export class ExchangeTransferSimulator {
}
const balance = await this._store.getBalanceAsync(assetData, from);
const proxyAllowance = await this._store.getProxyAllowanceAsync(assetData, from);
- if (proxyAllowance.lessThan(amountInBaseUnits)) {
+ if (proxyAllowance.isLessThan(amountInBaseUnits)) {
ExchangeTransferSimulator._throwValidationError(
FailureReason.ProxyAllowance,
tradeSide,
transferType,
);
}
- if (balance.lessThan(amountInBaseUnits)) {
+ if (balance.isLessThan(amountInBaseUnits)) {
ExchangeTransferSimulator._throwValidationError(FailureReason.Balance, tradeSide, transferType);
}
await this._decreaseProxyAllowanceAsync(assetData, from, amountInBaseUnits);
diff --git a/packages/order-utils/src/market_utils.ts b/packages/order-utils/src/market_utils.ts
index fa32f1413..9042551fa 100644
--- a/packages/order-utils/src/market_utils.ts
+++ b/packages/order-utils/src/market_utils.ts
@@ -52,7 +52,7 @@ export const marketUtils = {
const result = _.reduce(
orders,
({ resultOrders, remainingFillAmount, ordersRemainingFillableMakerAssetAmounts }, order, index) => {
- if (remainingFillAmount.lessThanOrEqualTo(constants.ZERO_AMOUNT)) {
+ if (remainingFillAmount.isLessThanOrEqualTo(constants.ZERO_AMOUNT)) {
return {
resultOrders,
remainingFillAmount: constants.ZERO_AMOUNT,
@@ -137,7 +137,7 @@ export const marketUtils = {
(accFees, order, index) => {
const makerAssetAmountAvailable = remainingFillableMakerAssetAmounts[index];
const feeToFillMakerAssetAmountAvailable = makerAssetAmountAvailable
- .mul(order.takerFee)
+ .multipliedBy(order.takerFee)
.dividedToIntegerBy(order.makerAssetAmount);
return accFees.plus(feeToFillMakerAssetAmountAvailable);
},
diff --git a/packages/order-utils/src/order_state_utils.ts b/packages/order-utils/src/order_state_utils.ts
index 389419587..430178b5d 100644
--- a/packages/order-utils/src/order_state_utils.ts
+++ b/packages/order-utils/src/order_state_utils.ts
@@ -214,10 +214,10 @@ export class OrderStateUtils {
const remainingFillableTakerAssetAmountGivenTakersStatus = orderRelevantTakerState.remainingFillableAssetAmount;
// The min of these two in the actualy max fillable by either party
- const fillableTakerAssetAmount = BigNumber.min([
+ const fillableTakerAssetAmount = BigNumber.min(
remainingFillableTakerAssetAmountGivenMakersStatus,
remainingFillableTakerAssetAmountGivenTakersStatus,
- ]);
+ );
return fillableTakerAssetAmount;
}
@@ -260,8 +260,8 @@ export class OrderStateUtils {
traderAddress,
);
- const transferrableTraderAssetAmount = BigNumber.min([traderProxyAllowance, traderBalance]);
- const transferrableFeeAssetAmount = BigNumber.min([traderFeeProxyAllowance, traderFeeBalance]);
+ const transferrableTraderAssetAmount = BigNumber.min(traderProxyAllowance, traderBalance);
+ const transferrableFeeAssetAmount = BigNumber.min(traderFeeProxyAllowance, traderFeeBalance);
const orderHash = orderHashUtils.getOrderHashHex(signedOrder);
const filledTakerAssetAmount = await this._orderFilledCancelledFetcher.getFilledTakerAmountAsync(orderHash);
@@ -312,7 +312,7 @@ export class OrderStateUtils {
const tokenAddress = decodedAssetData.tokenAddress;
balances[tokenAddress] = _.isUndefined(initialBalances[tokenAddress])
? balance
- : balances[tokenAddress].add(balance);
+ : balances[tokenAddress].plus(balance);
} else if (assetDataUtils.isMultiAssetData(decodedAssetData)) {
for (const assetDataElement of decodedAssetData.nestedAssetData) {
balances = await this._getAssetBalancesAsync(assetDataElement, traderAddress, balances);
@@ -335,7 +335,7 @@ export class OrderStateUtils {
const tokenAddress = decodedAssetData.tokenAddress;
allowances[tokenAddress] = _.isUndefined(initialAllowances[tokenAddress])
? allowance
- : allowances[tokenAddress].add(allowance);
+ : allowances[tokenAddress].plus(allowance);
} else if (assetDataUtils.isMultiAssetData(decodedAssetData)) {
for (const assetDataElement of decodedAssetData.nestedAssetData) {
allowances = await this._getAssetBalancesAsync(assetDataElement, traderAddress, allowances);
diff --git a/packages/order-utils/src/order_validation_utils.ts b/packages/order-utils/src/order_validation_utils.ts
index ae4291ea8..95215d918 100644
--- a/packages/order-utils/src/order_validation_utils.ts
+++ b/packages/order-utils/src/order_validation_utils.ts
@@ -31,13 +31,13 @@ export class OrderValidationUtils {
if (denominator.eq(0)) {
throw new Error('denominator cannot be 0');
}
- const remainder = target.mul(numerator).mod(denominator);
+ const remainder = target.multipliedBy(numerator).mod(denominator);
if (remainder.eq(0)) {
return false; // no rounding error
}
// tslint:disable-next-line:custom-no-magic-numbers
- const errPercentageTimes1000000 = remainder.mul(1000000).div(numerator.mul(target));
+ const errPercentageTimes1000000 = remainder.multipliedBy(1000000).div(numerator.multipliedBy(target));
// tslint:disable-next-line:custom-no-magic-numbers
const isError = errPercentageTimes1000000.gt(1000);
return isError;
@@ -108,7 +108,7 @@ export class OrderValidationUtils {
}
private static _validateOrderNotExpiredOrThrow(expirationTimeSeconds: BigNumber): void {
const currentUnixTimestampSec = utils.getCurrentUnixTimestampSec();
- if (expirationTimeSeconds.lessThan(currentUnixTimestampSec)) {
+ if (expirationTimeSeconds.isLessThan(currentUnixTimestampSec)) {
throw new Error(RevertReason.OrderUnfillable);
}
}
@@ -216,7 +216,7 @@ export class OrderValidationUtils {
}
OrderValidationUtils._validateOrderNotExpiredOrThrow(signedOrder.expirationTimeSeconds);
const remainingTakerTokenAmount = signedOrder.takerAssetAmount.minus(filledTakerTokenAmount);
- const desiredFillTakerTokenAmount = remainingTakerTokenAmount.lessThan(fillTakerAssetAmount)
+ const desiredFillTakerTokenAmount = remainingTakerTokenAmount.isLessThan(fillTakerAssetAmount)
? remainingTakerTokenAmount
: fillTakerAssetAmount;
try {
diff --git a/packages/order-utils/src/rate_utils.ts b/packages/order-utils/src/rate_utils.ts
index 416e00c67..dacdbd5a2 100644
--- a/packages/order-utils/src/rate_utils.ts
+++ b/packages/order-utils/src/rate_utils.ts
@@ -22,7 +22,7 @@ export const rateUtils = {
feeRate.gte(constants.ZERO_AMOUNT),
`Expected feeRate: ${feeRate} to be greater than or equal to 0`,
);
- const takerAssetAmountNeededToPayForFees = order.takerFee.mul(feeRate);
+ const takerAssetAmountNeededToPayForFees = order.takerFee.multipliedBy(feeRate);
const totalTakerAssetAmount = takerAssetAmountNeededToPayForFees.plus(order.takerAssetAmount);
const rate = totalTakerAssetAmount.div(order.makerAssetAmount);
return rate;
@@ -35,9 +35,9 @@ export const rateUtils = {
*/
getFeeAdjustedRateOfFeeOrder(feeOrder: Order): BigNumber {
assert.doesConformToSchema('feeOrder', feeOrder, schemas.orderSchema);
- const zrxAmountAfterFees = feeOrder.makerAssetAmount.sub(feeOrder.takerFee);
+ const zrxAmountAfterFees = feeOrder.makerAssetAmount.minus(feeOrder.takerFee);
assert.assert(
- zrxAmountAfterFees.greaterThan(constants.ZERO_AMOUNT),
+ zrxAmountAfterFees.isGreaterThan(constants.ZERO_AMOUNT),
`Expected takerFee: ${JSON.stringify(feeOrder.takerFee)} to be less than makerAssetAmount: ${JSON.stringify(
feeOrder.makerAssetAmount,
)}`,
diff --git a/packages/order-utils/src/remaining_fillable_calculator.ts b/packages/order-utils/src/remaining_fillable_calculator.ts
index 052eafa1d..92ffc8e80 100644
--- a/packages/order-utils/src/remaining_fillable_calculator.ts
+++ b/packages/order-utils/src/remaining_fillable_calculator.ts
@@ -39,15 +39,15 @@ export class RemainingFillableCalculator {
private _hasSufficientFundsForFeeAndTransferAmount(): boolean {
if (this._isTraderAssetZRX) {
const totalZRXTransferAmountRequired = this._remainingOrderAssetAmount.plus(this._remainingOrderFeeAmount);
- const hasSufficientFunds = this._transferrableAssetAmount.greaterThanOrEqualTo(
+ const hasSufficientFunds = this._transferrableAssetAmount.isGreaterThanOrEqualTo(
totalZRXTransferAmountRequired,
);
return hasSufficientFunds;
} else {
- const hasSufficientFundsForTransferAmount = this._transferrableAssetAmount.greaterThanOrEqualTo(
+ const hasSufficientFundsForTransferAmount = this._transferrableAssetAmount.isGreaterThanOrEqualTo(
this._remainingOrderAssetAmount,
);
- const hasSufficientFundsForFeeAmount = this._transferrableFeeAmount.greaterThanOrEqualTo(
+ const hasSufficientFundsForFeeAmount = this._transferrableFeeAmount.isGreaterThanOrEqualTo(
this._remainingOrderFeeAmount,
);
const hasSufficientFunds = hasSufficientFundsForTransferAmount && hasSufficientFundsForFeeAmount;
diff --git a/packages/order-utils/src/salt.ts b/packages/order-utils/src/salt.ts
index ff47ab5d2..95df66c99 100644
--- a/packages/order-utils/src/salt.ts
+++ b/packages/order-utils/src/salt.ts
@@ -13,6 +13,6 @@ export function generatePseudoRandomSalt(): BigNumber {
// Source: https://mikemcl.github.io/bignumber.js/#random
const randomNumber = BigNumber.random(MAX_DIGITS_IN_UNSIGNED_256_INT);
const factor = new BigNumber(10).pow(MAX_DIGITS_IN_UNSIGNED_256_INT - 1);
- const salt = randomNumber.times(factor).round();
+ const salt = randomNumber.times(factor).integerValue();
return salt;
}
diff --git a/packages/order-utils/src/utils.ts b/packages/order-utils/src/utils.ts
index 6b2261001..64195dbed 100644
--- a/packages/order-utils/src/utils.ts
+++ b/packages/order-utils/src/utils.ts
@@ -10,13 +10,13 @@ export const utils = {
},
getCurrentUnixTimestampSec(): BigNumber {
const milisecondsInSecond = 1000;
- return new BigNumber(Date.now() / milisecondsInSecond).round();
+ return new BigNumber(Date.now() / milisecondsInSecond).integerValue();
},
getPartialAmountFloor(numerator: BigNumber, denominator: BigNumber, target: BigNumber): BigNumber {
const fillMakerTokenAmount = numerator
- .mul(target)
+ .multipliedBy(target)
.div(denominator)
- .round(0);
+ .integerValue(0);
return fillMakerTokenAmount;
},
};
diff --git a/packages/order-utils/test/remaining_fillable_calculator_test.ts b/packages/order-utils/test/remaining_fillable_calculator_test.ts
index c55a76def..affad8f1c 100644
--- a/packages/order-utils/test/remaining_fillable_calculator_test.ts
+++ b/packages/order-utils/test/remaining_fillable_calculator_test.ts
@@ -162,7 +162,7 @@ describe('RemainingFillableCalculator', () => {
remainingMakeAssetAmount,
);
const calculatedFillableAmount = calculator.computeRemainingFillable();
- expect(calculatedFillableAmount.lessThanOrEqualTo(transferrableMakeAssetAmount)).to.be.true();
+ expect(calculatedFillableAmount.isLessThanOrEqualTo(transferrableMakeAssetAmount)).to.be.true();
expect(calculatedFillableAmount).to.be.bignumber.greaterThan(new BigNumber(0));
const orderToFeeRatio = signedOrder.makerAssetAmount.dividedBy(signedOrder.makerFee);
const calculatedFeeAmount = calculatedFillableAmount.dividedBy(orderToFeeRatio);
diff --git a/packages/order-utils/test/signature_utils_test.ts b/packages/order-utils/test/signature_utils_test.ts
index 84e5559a9..937382056 100644
--- a/packages/order-utils/test/signature_utils_test.ts
+++ b/packages/order-utils/test/signature_utils_test.ts
@@ -132,10 +132,10 @@ describe('Signature utils', () => {
});
it('generates salt in range [0..2^256)', () => {
const salt = generatePseudoRandomSalt();
- expect(salt.greaterThanOrEqualTo(0)).to.be.true();
+ expect(salt.isGreaterThanOrEqualTo(0)).to.be.true();
// tslint:disable-next-line:custom-no-magic-numbers
const twoPow256 = new BigNumber(2).pow(256);
- expect(salt.lessThan(twoPow256)).to.be.true();
+ expect(salt.isLessThan(twoPow256)).to.be.true();
});
});
describe('#ecSignOrderAsync', () => {
diff --git a/packages/order-watcher/CHANGELOG.json b/packages/order-watcher/CHANGELOG.json
index bb77feee0..585bb48e6 100644
--- a/packages/order-watcher/CHANGELOG.json
+++ b/packages/order-watcher/CHANGELOG.json
@@ -1,5 +1,23 @@
[
{
+ "version": "3.0.0",
+ "changes": [
+ {
+ "note": "Upgrade the bignumber.js to v8.0.2",
+ "pr": 1517
+ }
+ ]
+ },
+ {
+ "timestamp": 1547747677,
+ "version": "2.4.3",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"timestamp": 1547561734,
"version": "2.4.2",
"changes": [
diff --git a/packages/order-watcher/CHANGELOG.md b/packages/order-watcher/CHANGELOG.md
index e5f4833cd..df065866c 100644
--- a/packages/order-watcher/CHANGELOG.md
+++ b/packages/order-watcher/CHANGELOG.md
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
+## v2.4.3 - _January 17, 2019_
+
+ * Dependencies updated
+
## v2.4.2 - _January 15, 2019_
* Dependencies updated
diff --git a/packages/order-watcher/package.json b/packages/order-watcher/package.json
index dd9c59640..895c64813 100644
--- a/packages/order-watcher/package.json
+++ b/packages/order-watcher/package.json
@@ -1,6 +1,6 @@
{
"name": "@0x/order-watcher",
- "version": "2.4.2",
+ "version": "2.4.3",
"description": "An order watcher daemon that watches for order validity",
"keywords": [
"0x",
@@ -49,7 +49,7 @@
"@types/sinon": "^2.2.2",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
- "chai-bignumber": "^2.0.1",
+ "chai-bignumber": "^3.0.0",
"dirty-chai": "^2.0.1",
"make-promises-safe": "^1.1.0",
"mocha": "^4.1.0",
@@ -68,7 +68,7 @@
"@0x/base-contract": "^3.0.13",
"@0x/contract-addresses": "^2.2.0",
"@0x/contract-artifacts": "^1.3.0",
- "@0x/contract-wrappers": "^5.0.0",
+ "@0x/contract-wrappers": "^5.0.1",
"@0x/fill-scenarios": "^1.1.2",
"@0x/json-schemas": "^2.1.7",
"@0x/order-utils": "^3.1.2",
diff --git a/packages/order-watcher/src/order_watcher/expiration_watcher.ts b/packages/order-watcher/src/order_watcher/expiration_watcher.ts
index ad20a6e3f..82590efde 100644
--- a/packages/order-watcher/src/order_watcher/expiration_watcher.ts
+++ b/packages/order-watcher/src/order_watcher/expiration_watcher.ts
@@ -73,7 +73,7 @@ export class ExpirationWatcher {
break;
}
const nextOrderHashToExpire = this._orderHashByExpirationRBTree.min();
- const hasNoExpiredOrders = this._expiration[nextOrderHashToExpire].greaterThan(
+ const hasNoExpiredOrders = this._expiration[nextOrderHashToExpire].isGreaterThan(
currentUnixTimestampMs.plus(this._expirationMarginMs),
);
const isSubscriptionActive = _.isUndefined(this._orderExpirationCheckingIntervalIdIfExists);
diff --git a/packages/order-watcher/src/utils/utils.ts b/packages/order-watcher/src/utils/utils.ts
index a7d10aaf9..9c3849ff1 100644
--- a/packages/order-watcher/src/utils/utils.ts
+++ b/packages/order-watcher/src/utils/utils.ts
@@ -3,7 +3,7 @@ import { BigNumber } from '@0x/utils';
export const utils = {
getCurrentUnixTimestampSec(): BigNumber {
const milisecondsInASecond = 1000;
- return new BigNumber(Date.now() / milisecondsInASecond).round();
+ return new BigNumber(Date.now() / milisecondsInASecond).integerValue();
},
getCurrentUnixTimestampMs(): BigNumber {
return new BigNumber(Date.now());
diff --git a/packages/order-watcher/test/order_watcher_test.ts b/packages/order-watcher/test/order_watcher_test.ts
index 41dc884d5..28b564b32 100644
--- a/packages/order-watcher/test/order_watcher_test.ts
+++ b/packages/order-watcher/test/order_watcher_test.ts
@@ -317,7 +317,7 @@ describe('OrderWatcher', () => {
const validOrderState = orderState as OrderStateValid;
expect(validOrderState.orderHash).to.be.equal(orderHash);
const orderRelevantState = validOrderState.orderRelevantState;
- const remainingMakerBalance = makerBalance.sub(fillAmountInBaseUnits);
+ const remainingMakerBalance = makerBalance.minus(fillAmountInBaseUnits);
const remainingFillable = fillableAmount.minus(fillAmountInBaseUnits);
expect(orderRelevantState.remainingFillableMakerAssetAmount).to.be.bignumber.equal(
remainingFillable,
@@ -434,7 +434,7 @@ describe('OrderWatcher', () => {
);
const remainingAmount = Web3Wrapper.toBaseUnitAmount(new BigNumber(1), decimals);
- const transferAmount = makerBalance.sub(remainingAmount);
+ const transferAmount = makerBalance.minus(remainingAmount);
await orderWatcher.addOrderAsync(signedOrder);
const callback = callbackErrorReporter.reportNodeCallbackErrors(done)((orderState: OrderState) => {
@@ -475,7 +475,7 @@ describe('OrderWatcher', () => {
const remainingFeeAmount = Web3Wrapper.toBaseUnitAmount(new BigNumber(3), decimals);
const remainingTokenAmount = Web3Wrapper.toBaseUnitAmount(new BigNumber(4), decimals);
- const transferTokenAmount = makerFee.sub(remainingTokenAmount);
+ const transferTokenAmount = makerFee.minus(remainingTokenAmount);
await orderWatcher.addOrderAsync(signedOrder);
const callback = callbackErrorReporter.reportNodeCallbackErrors(done)((orderState: OrderState) => {
diff --git a/packages/pipeline/package.json b/packages/pipeline/package.json
index 988dd8b74..908734687 100644
--- a/packages/pipeline/package.json
+++ b/packages/pipeline/package.json
@@ -32,7 +32,7 @@
"@types/ramda": "^0.25.38",
"chai": "^4.1.2",
"chai-as-promised": "^7.1.1",
- "chai-bignumber": "^2.0.2",
+ "chai-bignumber": "^3.0.0",
"dirty-chai": "^2.0.1",
"mocha": "^5.2.0",
"tslint": "5.11.0",
diff --git a/packages/pipeline/src/utils/transformers/number_to_bigint.ts b/packages/pipeline/src/utils/transformers/number_to_bigint.ts
index 9736d7c18..8fbd52093 100644
--- a/packages/pipeline/src/utils/transformers/number_to_bigint.ts
+++ b/packages/pipeline/src/utils/transformers/number_to_bigint.ts
@@ -19,7 +19,7 @@ export class NumberToBigIntTransformer implements ValueTransformer {
// tslint:disable-next-line:prefer-function-over-method
public from(value: string): number {
- if (new BigNumber(value).greaterThan(Number.MAX_SAFE_INTEGER)) {
+ if (new BigNumber(value).isGreaterThan(Number.MAX_SAFE_INTEGER)) {
throw new Error(
`Attempted to convert PostgreSQL bigint value (${value}) to JavaScript number type but it is too big to safely convert`,
);
diff --git a/packages/react-docs/CHANGELOG.json b/packages/react-docs/CHANGELOG.json
index 101da65c7..8b418fc11 100644
--- a/packages/react-docs/CHANGELOG.json
+++ b/packages/react-docs/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "version": "2.0.0",
+ "changes": [
+ {
+ "note": "Upgrade the bignumber.js to v8.0.2",
+ "pr": 1517
+ }
+ ]
+ },
+ {
"timestamp": 1547561734,
"version": "1.0.25",
"changes": [
diff --git a/packages/react-shared/CHANGELOG.json b/packages/react-shared/CHANGELOG.json
index a6d2c4fa0..99a8779ac 100644
--- a/packages/react-shared/CHANGELOG.json
+++ b/packages/react-shared/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "version": "2.0.0",
+ "changes": [
+ {
+ "note": "Upgrade the bignumber.js to v8.0.2",
+ "pr": 1517
+ }
+ ]
+ },
+ {
"timestamp": 1547561734,
"version": "1.1.2",
"changes": [
diff --git a/packages/react-shared/package.json b/packages/react-shared/package.json
index 47d36ca66..4be4742b0 100644
--- a/packages/react-shared/package.json
+++ b/packages/react-shared/package.json
@@ -52,7 +52,7 @@
"material-ui": "^0.20.0",
"react": "^16.5.2",
"react-dom": "^16.5.2",
- "react-highlight": "0xproject/react-highlight#699ac4d9529e33520bff4b9bd9c624d21efbba75",
+ "react-highlight": "0xproject/react-highlight#fix/react-version",
"react-markdown": "^3.2.2",
"react-router-dom": "^4.1.1",
"react-scroll": "0xproject/react-scroll#pr-330-and-replace-state",
diff --git a/packages/sol-compiler/CHANGELOG.json b/packages/sol-compiler/CHANGELOG.json
index d7dd5a454..672939a4a 100644
--- a/packages/sol-compiler/CHANGELOG.json
+++ b/packages/sol-compiler/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "version": "3.0.0",
+ "changes": [
+ {
+ "note": "Upgrade the bignumber.js to v8.0.2",
+ "pr": 1517
+ }
+ ]
+ },
+ {
"timestamp": 1547561734,
"version": "2.0.2",
"changes": [
diff --git a/packages/sol-compiler/package.json b/packages/sol-compiler/package.json
index 26c8e8833..0b53cffd5 100644
--- a/packages/sol-compiler/package.json
+++ b/packages/sol-compiler/package.json
@@ -51,7 +51,7 @@
"@types/semver": "^5.5.0",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
- "chai-bignumber": "^2.0.2",
+ "chai-bignumber": "^3.0.0",
"copyfiles": "^2.0.0",
"dirty-chai": "^2.0.1",
"make-promises-safe": "^1.1.0",
diff --git a/packages/sol-coverage/CHANGELOG.json b/packages/sol-coverage/CHANGELOG.json
index 8157d441e..550ca2feb 100644
--- a/packages/sol-coverage/CHANGELOG.json
+++ b/packages/sol-coverage/CHANGELOG.json
@@ -1,5 +1,23 @@
[
{
+ "version": "2.0.0",
+ "changes": [
+ {
+ "note": "Upgrade the bignumber.js to v8.0.2",
+ "pr": 1517
+ }
+ ]
+ },
+ {
+ "timestamp": 1547747677,
+ "version": "1.0.3",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"timestamp": 1547561734,
"version": "1.0.2",
"changes": [
diff --git a/packages/sol-coverage/CHANGELOG.md b/packages/sol-coverage/CHANGELOG.md
index ac09a1bbf..18c1719bf 100644
--- a/packages/sol-coverage/CHANGELOG.md
+++ b/packages/sol-coverage/CHANGELOG.md
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
+## v1.0.3 - _January 17, 2019_
+
+ * Dependencies updated
+
## v1.0.2 - _January 15, 2019_
* Dependencies updated
diff --git a/packages/sol-coverage/package.json b/packages/sol-coverage/package.json
index efe91cf2b..805e2e670 100644
--- a/packages/sol-coverage/package.json
+++ b/packages/sol-coverage/package.json
@@ -1,6 +1,6 @@
{
"name": "@0x/sol-coverage",
- "version": "1.0.2",
+ "version": "1.0.3",
"engines": {
"node": ">=6.12"
},
@@ -29,7 +29,7 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/packages/sol-coverage/README.md",
"dependencies": {
- "@0x/sol-tracing-utils": "^4.0.0",
+ "@0x/sol-tracing-utils": "^4.0.1",
"@0x/subproviders": "^2.1.11",
"@0x/typescript-typings": "^3.0.8",
"ethereum-types": "^1.1.6",
diff --git a/packages/sol-coverage/src/coverage_subprovider.ts b/packages/sol-coverage/src/coverage_subprovider.ts
index d03963ed6..2d92b25ca 100644
--- a/packages/sol-coverage/src/coverage_subprovider.ts
+++ b/packages/sol-coverage/src/coverage_subprovider.ts
@@ -50,6 +50,8 @@ export class CoverageSubprovider extends TraceInfoSubprovider {
}
}
+const IGNORE_REGEXP = /\/\*\s*solcov\s+ignore\s+next\s*\*\/\s*/gm;
+
/**
* Computed partial coverage for a single file & subtrace.
* @param contractData Contract metadata (source, srcMap, bytecode)
@@ -65,7 +67,7 @@ export const coverageHandler: SingleFileSubtraceHandler = (
fileIndex: number,
): Coverage => {
const absoluteFileName = contractData.sources[fileIndex];
- const coverageEntriesDescription = collectCoverageEntries(contractData.sourceCodes[fileIndex]);
+ const coverageEntriesDescription = collectCoverageEntries(contractData.sourceCodes[fileIndex], IGNORE_REGEXP);
// if the source wasn't provided for the fileIndex, we can't cover the file
if (_.isUndefined(coverageEntriesDescription)) {
diff --git a/packages/sol-doc/CHANGELOG.json b/packages/sol-doc/CHANGELOG.json
index f95702ee4..662915faf 100644
--- a/packages/sol-doc/CHANGELOG.json
+++ b/packages/sol-doc/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "version": "2.0.0",
+ "changes": [
+ {
+ "note": "Upgrade the bignumber.js to v8.0.2",
+ "pr": 1517
+ }
+ ]
+ },
+ {
"timestamp": 1547561734,
"version": "1.0.14",
"changes": [
diff --git a/packages/sol-doc/package.json b/packages/sol-doc/package.json
index dee6ef2e5..179f45e81 100644
--- a/packages/sol-doc/package.json
+++ b/packages/sol-doc/package.json
@@ -37,7 +37,7 @@
"@0x/tslint-config": "^2.0.2",
"chai": "^4.1.2",
"chai-as-promised": "^7.1.0",
- "chai-bignumber": "^2.0.2",
+ "chai-bignumber": "^3.0.0",
"dirty-chai": "^2.0.1",
"make-promises-safe": "^1.1.0",
"mocha": "^5.2.0",
diff --git a/packages/sol-profiler/CHANGELOG.json b/packages/sol-profiler/CHANGELOG.json
index 8157d441e..fc928b516 100644
--- a/packages/sol-profiler/CHANGELOG.json
+++ b/packages/sol-profiler/CHANGELOG.json
@@ -1,5 +1,32 @@
[
{
+ "version": "2.0.1",
+ "changes": [
+ {
+ "note": "Fix a bug when some parts of the profiling report were missing because of the coverage ignore lines",
+ "pr": 1535
+ }
+ ]
+ },
+ {
+ "version": "2.0.0",
+ "changes": [
+ {
+ "note": "Upgrade the bignumber.js to v8.0.2",
+ "pr": 1517
+ }
+ ]
+ },
+ {
+ "timestamp": 1547747677,
+ "version": "1.0.3",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"timestamp": 1547561734,
"version": "1.0.2",
"changes": [
diff --git a/packages/sol-profiler/CHANGELOG.md b/packages/sol-profiler/CHANGELOG.md
index ac09a1bbf..18c1719bf 100644
--- a/packages/sol-profiler/CHANGELOG.md
+++ b/packages/sol-profiler/CHANGELOG.md
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
+## v1.0.3 - _January 17, 2019_
+
+ * Dependencies updated
+
## v1.0.2 - _January 15, 2019_
* Dependencies updated
diff --git a/packages/sol-profiler/package.json b/packages/sol-profiler/package.json
index 1a89e0a6b..4fe2928c7 100644
--- a/packages/sol-profiler/package.json
+++ b/packages/sol-profiler/package.json
@@ -1,6 +1,6 @@
{
"name": "@0x/sol-profiler",
- "version": "1.0.2",
+ "version": "1.0.3",
"engines": {
"node": ">=6.12"
},
@@ -29,7 +29,7 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/packages/sol-profiler/README.md",
"dependencies": {
- "@0x/sol-tracing-utils": "^4.0.0",
+ "@0x/sol-tracing-utils": "^4.0.1",
"@0x/subproviders": "^2.1.11",
"@0x/typescript-typings": "^3.0.8",
"ethereum-types": "^1.1.6",
diff --git a/packages/sol-resolver/CHANGELOG.json b/packages/sol-resolver/CHANGELOG.json
index e5f4a8ac1..f5a005fd4 100644
--- a/packages/sol-resolver/CHANGELOG.json
+++ b/packages/sol-resolver/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "version": "2.0.0",
+ "changes": [
+ {
+ "note": "Upgrade the bignumber.js to v8.0.2",
+ "pr": 1517
+ }
+ ]
+ },
+ {
"timestamp": 1547561734,
"version": "1.2.3",
"changes": [
diff --git a/packages/sol-trace/CHANGELOG.json b/packages/sol-trace/CHANGELOG.json
index 8157d441e..550ca2feb 100644
--- a/packages/sol-trace/CHANGELOG.json
+++ b/packages/sol-trace/CHANGELOG.json
@@ -1,5 +1,23 @@
[
{
+ "version": "2.0.0",
+ "changes": [
+ {
+ "note": "Upgrade the bignumber.js to v8.0.2",
+ "pr": 1517
+ }
+ ]
+ },
+ {
+ "timestamp": 1547747677,
+ "version": "1.0.3",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"timestamp": 1547561734,
"version": "1.0.2",
"changes": [
diff --git a/packages/sol-trace/CHANGELOG.md b/packages/sol-trace/CHANGELOG.md
index ac09a1bbf..18c1719bf 100644
--- a/packages/sol-trace/CHANGELOG.md
+++ b/packages/sol-trace/CHANGELOG.md
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
+## v1.0.3 - _January 17, 2019_
+
+ * Dependencies updated
+
## v1.0.2 - _January 15, 2019_
* Dependencies updated
diff --git a/packages/sol-trace/package.json b/packages/sol-trace/package.json
index acae60303..2aedf7ebc 100644
--- a/packages/sol-trace/package.json
+++ b/packages/sol-trace/package.json
@@ -1,6 +1,6 @@
{
"name": "@0x/sol-trace",
- "version": "1.0.2",
+ "version": "1.0.3",
"engines": {
"node": ">=6.12"
},
@@ -29,7 +29,7 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/packages/sol-trace/README.md",
"dependencies": {
- "@0x/sol-tracing-utils": "^4.0.0",
+ "@0x/sol-tracing-utils": "^4.0.1",
"@0x/subproviders": "^2.1.11",
"@0x/typescript-typings": "^3.0.8",
"ethereum-types": "^1.1.6",
diff --git a/packages/sol-trace/src/revert_trace_subprovider.ts b/packages/sol-trace/src/revert_trace_subprovider.ts
index fa065cfcb..046dad812 100644
--- a/packages/sol-trace/src/revert_trace_subprovider.ts
+++ b/packages/sol-trace/src/revert_trace_subprovider.ts
@@ -109,9 +109,7 @@ export class RevertTraceSubprovider extends TraceCollectionSubprovider {
const fileNameToFileIndex = _.invert(contractData.sources);
const fileIndex = _.parseInt(fileNameToFileIndex[sourceRange.fileName]);
const sourceSnippet = getSourceRangeSnippet(sourceRange, contractData.sourceCodes[fileIndex]);
- if (sourceSnippet !== null) {
- sourceSnippets.push(sourceSnippet);
- }
+ sourceSnippets.push(sourceSnippet);
}
const filteredSnippets = filterSnippets(sourceSnippets);
if (filteredSnippets.length > 0) {
@@ -135,9 +133,7 @@ function filterSnippets(sourceSnippets: SourceSnippet[]): SourceSnippet[] {
const results: SourceSnippet[] = [sourceSnippets[0]];
let prev = sourceSnippets[0];
for (const sourceSnippet of sourceSnippets) {
- if (sourceSnippet.type === 'IfStatement') {
- continue;
- } else if (sourceSnippet.source === prev.source) {
+ if (sourceSnippet.source === prev.source) {
prev = sourceSnippet;
continue;
}
@@ -157,12 +153,5 @@ function getStackTraceString(sourceSnippet: SourceSnippet): string {
}
function getSourceSnippetString(sourceSnippet: SourceSnippet): string {
- switch (sourceSnippet.type) {
- case 'ContractDefinition':
- return `contract ${sourceSnippet.name}`;
- case 'FunctionDefinition':
- return `function ${sourceSnippet.name}`;
- default:
- return `${sourceSnippet.source}`;
- }
+ return `${sourceSnippet.source}`;
}
diff --git a/packages/sol-tracing-utils/CHANGELOG.json b/packages/sol-tracing-utils/CHANGELOG.json
index b470d3e87..16a12ca63 100644
--- a/packages/sol-tracing-utils/CHANGELOG.json
+++ b/packages/sol-tracing-utils/CHANGELOG.json
@@ -1,5 +1,53 @@
[
{
+ "version": "6.0.0",
+ "changes": [
+ {
+ "note": "`SolCompilerArtifactAdapter` now uses `SolResolver` under the hood which allows to resolve `NPM` dependencies properly",
+ "pr": 1535
+ },
+ {
+ "note": "Cache the `utils.getContractDataIfExists` leading to faster execution",
+ "pr": 1535
+ },
+ {
+ "note": "`SolCompilerArtifactAdapter` now doesn't return the `ContractData` for interfaces",
+ "pr": 1535
+ },
+ {
+ "note": "Print resasonable error message on bytecode collision",
+ "pr": 1535
+ }
+ ]
+ },
+ {
+ "version": "5.0.0",
+ "changes": [
+ {
+ "note": "Upgrade the bignumber.js to v8.0.2",
+ "pr": 1517
+ }
+ ]
+ },
+ {
+ "version": "4.0.1",
+ "changes": [
+ {
+ "note": "Fix a bug where a custom `Geth` tracer didn't return stack entries for `DELEGATECALL`",
+ "pr": 1521
+ },
+ {
+ "note": "Fix a bug where `TraceCollectionSubprovider` was hanging on the fake `Geth` snapshot transaction",
+ "pr": 1521
+ },
+ {
+ "note": "Fix/simplify handling of revert trace snippets",
+ "pr": 1521
+ }
+ ],
+ "timestamp": 1547747677
+ },
+ {
"version": "4.0.0",
"changes": [
{
diff --git a/packages/sol-tracing-utils/CHANGELOG.md b/packages/sol-tracing-utils/CHANGELOG.md
index 00d36844c..9bffb2a6d 100644
--- a/packages/sol-tracing-utils/CHANGELOG.md
+++ b/packages/sol-tracing-utils/CHANGELOG.md
@@ -5,6 +5,12 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
+## v4.0.1 - _January 17, 2019_
+
+ * Fix a bug where a custom `Geth` tracer didn't return stack entries for `DELEGATECALL` (#1521)
+ * Fix a bug where `TraceCollectionSubprovider` was hanging on the fake `Geth` snapshot transaction (#1521)
+ * Fix/simplify handling of revert trace snippets (#1521)
+
## v4.0.0 - _January 15, 2019_
* Fix a bug with incorrect parsing of `sourceMaps` due to sources being in an array instead of a map (#1498)
diff --git a/packages/sol-tracing-utils/package.json b/packages/sol-tracing-utils/package.json
index e3e52f42c..4b0fff222 100644
--- a/packages/sol-tracing-utils/package.json
+++ b/packages/sol-tracing-utils/package.json
@@ -1,6 +1,6 @@
{
"name": "@0x/sol-tracing-utils",
- "version": "4.0.0",
+ "version": "4.0.1",
"engines": {
"node": ">=6.12"
},
@@ -44,6 +44,7 @@
"dependencies": {
"@0x/dev-utils": "^1.0.24",
"@0x/sol-compiler": "^2.0.2",
+ "@0x/sol-resolver": "^1.2.3",
"@0x/subproviders": "^2.1.11",
"@0x/typescript-typings": "^3.0.8",
"@0x/utils": "^3.0.1",
diff --git a/packages/sol-tracing-utils/src/artifact_adapters/sol_compiler_artifact_adapter.ts b/packages/sol-tracing-utils/src/artifact_adapters/sol_compiler_artifact_adapter.ts
index d52587f2c..bfd3a504a 100644
--- a/packages/sol-tracing-utils/src/artifact_adapters/sol_compiler_artifact_adapter.ts
+++ b/packages/sol-tracing-utils/src/artifact_adapters/sol_compiler_artifact_adapter.ts
@@ -1,3 +1,4 @@
+import { FallthroughResolver, FSResolver, NPMResolver, RelativeFSResolver, URLResolver } from '@0x/sol-resolver';
import { logUtils } from '@0x/utils';
import { CompilerOptions, ContractArtifact } from 'ethereum-types';
import * as fs from 'fs';
@@ -14,6 +15,7 @@ const CONFIG_FILE = 'compiler.json';
export class SolCompilerArtifactAdapter extends AbstractArtifactAdapter {
private readonly _artifactsPath: string;
private readonly _sourcesPath: string;
+ private readonly _resolver: FallthroughResolver;
/**
* Instantiates a SolCompilerArtifactAdapter
* @param artifactsPath Path to your artifacts directory
@@ -32,6 +34,12 @@ export class SolCompilerArtifactAdapter extends AbstractArtifactAdapter {
throw new Error(`contractsDir not found in ${CONFIG_FILE}`);
}
this._sourcesPath = (sourcesPath || config.contractsDir) as string;
+ this._resolver = new FallthroughResolver();
+ this._resolver.appendResolver(new URLResolver());
+ const packagePath = path.resolve('');
+ this._resolver.appendResolver(new NPMResolver(packagePath));
+ this._resolver.appendResolver(new RelativeFSResolver(this._sourcesPath));
+ this._resolver.appendResolver(new FSResolver());
}
public async collectContractsDataAsync(): Promise<ContractData[]> {
const artifactsGlob = `${this._artifactsPath}/**/*.json`;
@@ -46,10 +54,9 @@ export class SolCompilerArtifactAdapter extends AbstractArtifactAdapter {
const sources: Sources = {};
const sourceCodes: SourceCodes = {};
_.map(artifact.sources, (value: { id: number }, relativeFilePath: string) => {
- const filePath = path.resolve(this._sourcesPath, relativeFilePath);
- const fileContent = fs.readFileSync(filePath).toString();
- sources[value.id] = filePath;
- sourceCodes[value.id] = fileContent;
+ const source = this._resolver.resolve(relativeFilePath);
+ sources[value.id] = source.absolutePath;
+ sourceCodes[value.id] = source.source;
});
const contractData = {
sourceCodes,
@@ -59,6 +66,10 @@ export class SolCompilerArtifactAdapter extends AbstractArtifactAdapter {
runtimeBytecode: artifact.compilerOutput.evm.deployedBytecode.object,
sourceMapRuntime: artifact.compilerOutput.evm.deployedBytecode.sourceMap,
};
+ const isInterfaceContract = contractData.bytecode === '0x' && contractData.runtimeBytecode === '0x';
+ if (isInterfaceContract) {
+ continue;
+ }
contractsData.push(contractData);
}
return contractsData;
diff --git a/packages/sol-tracing-utils/src/collect_coverage_entries.ts b/packages/sol-tracing-utils/src/collect_coverage_entries.ts
index 9e3591d74..d5045b106 100644
--- a/packages/sol-tracing-utils/src/collect_coverage_entries.ts
+++ b/packages/sol-tracing-utils/src/collect_coverage_entries.ts
@@ -5,18 +5,18 @@ import * as parser from 'solidity-parser-antlr';
import { ASTVisitor, CoverageEntriesDescription } from './ast_visitor';
import { getOffsetToLocation } from './source_maps';
-const IGNORE_RE = /\/\*\s*solcov\s+ignore\s+next\s*\*\/\s*/gm;
-
// Parsing source code for each transaction/code is slow and therefore we cache it
const sourceHashToCoverageEntries: { [sourceHash: string]: CoverageEntriesDescription } = {};
-export const collectCoverageEntries = (contractSource: string) => {
+export const collectCoverageEntries = (contractSource: string, ignoreRegexp?: RegExp) => {
const sourceHash = ethUtil.sha3(contractSource).toString('hex');
if (_.isUndefined(sourceHashToCoverageEntries[sourceHash]) && !_.isUndefined(contractSource)) {
const ast = parser.parse(contractSource, { range: true });
const offsetToLocation = getOffsetToLocation(contractSource);
- const ignoreRangesBegingingAt = gatherRangesToIgnore(contractSource);
- const visitor = new ASTVisitor(offsetToLocation, ignoreRangesBegingingAt);
+ const ignoreRangesBeginningAt = _.isUndefined(ignoreRegexp)
+ ? []
+ : gatherRangesToIgnore(contractSource, ignoreRegexp);
+ const visitor = new ASTVisitor(offsetToLocation, ignoreRangesBeginningAt);
parser.visit(ast, visitor);
sourceHashToCoverageEntries[sourceHash] = visitor.getCollectedCoverageEntries();
}
@@ -25,12 +25,12 @@ export const collectCoverageEntries = (contractSource: string) => {
};
// Gather the start index of all code blocks preceeded by "/* solcov ignore next */"
-function gatherRangesToIgnore(contractSource: string): number[] {
+function gatherRangesToIgnore(contractSource: string, ignoreRegexp: RegExp): number[] {
const ignoreRangesStart = [];
let match;
do {
- match = IGNORE_RE.exec(contractSource);
+ match = ignoreRegexp.exec(contractSource);
if (match) {
const matchLen = match[0].length;
ignoreRangesStart.push(match.index + matchLen);
diff --git a/packages/sol-tracing-utils/src/get_source_range_snippet.ts b/packages/sol-tracing-utils/src/get_source_range_snippet.ts
index 7aef00fee..c1f6e3a4e 100644
--- a/packages/sol-tracing-utils/src/get_source_range_snippet.ts
+++ b/packages/sol-tracing-utils/src/get_source_range_snippet.ts
@@ -1,185 +1,16 @@
-import * as ethUtil from 'ethereumjs-util';
-import * as _ from 'lodash';
-import * as Parser from 'solidity-parser-antlr';
-
-import { SingleFileSourceRange, SourceRange, SourceSnippet } from './types';
+import { SourceRange, SourceSnippet } from './types';
import { utils } from './utils';
-interface ASTInfo {
- type: string;
- node: Parser.ASTNode;
- name: string | null;
- range?: SingleFileSourceRange;
-}
-
-// Parsing source code for each transaction/code is slow and therefore we cache it
-const hashToParsedSource: { [sourceHash: string]: Parser.ASTNode } = {};
-
/**
* Gets the source range snippet by source range to be used by revert trace.
* @param sourceRange source range
* @param sourceCode source code
*/
-export function getSourceRangeSnippet(sourceRange: SourceRange, sourceCode: string): SourceSnippet | null {
- const sourceHash = ethUtil.sha3(sourceCode).toString('hex');
- if (_.isUndefined(hashToParsedSource[sourceHash])) {
- hashToParsedSource[sourceHash] = Parser.parse(sourceCode, { loc: true });
- }
- const astNode = hashToParsedSource[sourceHash];
- const visitor = new ASTInfoVisitor();
- Parser.visit(astNode, visitor);
- const astInfo = visitor.getASTInfoForRange(sourceRange);
- if (astInfo === null) {
- return null;
- }
+export function getSourceRangeSnippet(sourceRange: SourceRange, sourceCode: string): SourceSnippet {
const sourceCodeInRange = utils.getRange(sourceCode, sourceRange.location);
return {
- ...astInfo,
- range: astInfo.range as SingleFileSourceRange,
+ range: sourceRange.location,
source: sourceCodeInRange,
fileName: sourceRange.fileName,
};
}
-
-// A visitor which collects ASTInfo for most nodes in the AST.
-class ASTInfoVisitor {
- private readonly _astInfos: ASTInfo[] = [];
- public getASTInfoForRange(sourceRange: SourceRange): ASTInfo | null {
- // HACK(albrow): Sometimes the source range doesn't exactly match that
- // of astInfo. To work around that we try with a +/-1 offset on
- // end.column. If nothing matches even with the offset, we return null.
- const offset = {
- start: {
- line: 0,
- column: 0,
- },
- end: {
- line: 0,
- column: 0,
- },
- };
- let astInfo = this._getASTInfoForRange(sourceRange, offset);
- if (astInfo !== null) {
- return astInfo;
- }
- offset.end.column += 1;
- astInfo = this._getASTInfoForRange(sourceRange, offset);
- if (astInfo !== null) {
- return astInfo;
- }
- offset.end.column -= 2;
- astInfo = this._getASTInfoForRange(sourceRange, offset);
- if (astInfo !== null) {
- return astInfo;
- }
- return null;
- }
- public ContractDefinition(ast: Parser.ContractDefinition): void {
- this._visitContractDefinition(ast);
- }
- public IfStatement(ast: Parser.IfStatement): void {
- this._visitStatement(ast);
- }
- public FunctionDefinition(ast: Parser.FunctionDefinition): void {
- this._visitFunctionLikeDefinition(ast);
- }
- public ModifierDefinition(ast: Parser.ModifierDefinition): void {
- this._visitFunctionLikeDefinition(ast);
- }
- public ForStatement(ast: Parser.ForStatement): void {
- this._visitStatement(ast);
- }
- public ReturnStatement(ast: Parser.ReturnStatement): void {
- this._visitStatement(ast);
- }
- public BreakStatement(ast: Parser.BreakStatement): void {
- this._visitStatement(ast);
- }
- public ContinueStatement(ast: Parser.ContinueStatement): void {
- this._visitStatement(ast);
- }
- public EmitStatement(ast: any /* TODO: Parser.EmitStatement */): void {
- this._visitStatement(ast);
- }
- public VariableDeclarationStatement(ast: Parser.VariableDeclarationStatement): void {
- this._visitStatement(ast);
- }
- public Statement(ast: Parser.Statement): void {
- this._visitStatement(ast);
- }
- public WhileStatement(ast: Parser.WhileStatement): void {
- this._visitStatement(ast);
- }
- public SimpleStatement(ast: Parser.SimpleStatement): void {
- this._visitStatement(ast);
- }
- public ThrowStatement(ast: Parser.ThrowStatement): void {
- this._visitStatement(ast);
- }
- public DoWhileStatement(ast: Parser.DoWhileStatement): void {
- this._visitStatement(ast);
- }
- public ExpressionStatement(ast: Parser.ExpressionStatement): void {
- this._visitStatement(ast.expression);
- }
- public InlineAssemblyStatement(ast: Parser.InlineAssemblyStatement): void {
- this._visitStatement(ast);
- }
- public ModifierInvocation(ast: Parser.ModifierInvocation): void {
- const BUILTIN_MODIFIERS = ['public', 'view', 'payable', 'external', 'internal', 'pure', 'constant'];
- if (!_.includes(BUILTIN_MODIFIERS, ast.name)) {
- this._visitStatement(ast);
- }
- }
- private _visitStatement(ast: Parser.ASTNode): void {
- this._astInfos.push({
- type: ast.type,
- node: ast,
- name: null,
- range: ast.loc,
- });
- }
- private _visitFunctionLikeDefinition(ast: Parser.ModifierDefinition | Parser.FunctionDefinition): void {
- this._astInfos.push({
- type: ast.type,
- node: ast,
- name: ast.name,
- range: ast.loc,
- });
- }
- private _visitContractDefinition(ast: Parser.ContractDefinition): void {
- this._astInfos.push({
- type: ast.type,
- node: ast,
- name: ast.name,
- range: ast.loc,
- });
- }
- private _getASTInfoForRange(sourceRange: SourceRange, offset: SingleFileSourceRange): ASTInfo | null {
- const offsetSourceRange = {
- ...sourceRange,
- location: {
- start: {
- line: sourceRange.location.start.line + offset.start.line,
- column: sourceRange.location.start.column + offset.start.column,
- },
- end: {
- line: sourceRange.location.end.line + offset.end.line,
- column: sourceRange.location.end.column + offset.end.column,
- },
- },
- };
- for (const astInfo of this._astInfos) {
- const astInfoRange = astInfo.range as SingleFileSourceRange;
- if (
- astInfoRange.start.column === offsetSourceRange.location.start.column &&
- astInfoRange.start.line === offsetSourceRange.location.start.line &&
- astInfoRange.end.column === offsetSourceRange.location.end.column &&
- astInfoRange.end.line === offsetSourceRange.location.end.line
- ) {
- return astInfo;
- }
- }
- return null;
- }
-}
diff --git a/packages/sol-tracing-utils/src/trace_collection_subprovider.ts b/packages/sol-tracing-utils/src/trace_collection_subprovider.ts
index 323e1523c..5118921fa 100644
--- a/packages/sol-tracing-utils/src/trace_collection_subprovider.ts
+++ b/packages/sol-tracing-utils/src/trace_collection_subprovider.ts
@@ -144,7 +144,7 @@ export abstract class TraceCollectionSubprovider extends Subprovider {
txHash: string | undefined,
cb: Callback,
): Promise<void> {
- if (!txData.isFakeTransaction) {
+ if (!(txData.isFakeTransaction || txData.from === txData.to)) {
// This transaction is a usual transaction. Not a call executed as one.
// And we don't want it to be executed within a snapshotting period
await this._lock.acquire();
diff --git a/packages/sol-tracing-utils/src/trace_info_subprovider.ts b/packages/sol-tracing-utils/src/trace_info_subprovider.ts
index b75fc7bf7..de42e1862 100644
--- a/packages/sol-tracing-utils/src/trace_info_subprovider.ts
+++ b/packages/sol-tracing-utils/src/trace_info_subprovider.ts
@@ -31,7 +31,7 @@ export abstract class TraceInfoSubprovider extends TraceCollectionSubprovider {
const depth = 0 | log.getDepth();
const gasCost = 0 | log.getCost();
const gas = 0 | log.getGas();
- const isCall = opn == 0xf1 || opn == 0xf2 || opn == 0xf4 || opn == 0xf5;
+ const isCall = opn == 0xf1 || opn == 0xf2 || opn == 0xf4 || opn == 0xf5 || opn == 0xfa;
const stack = isCall ? ['0x'+log.stack.peek(1).toString(16), null] : null;
this.data.push({ pc, gasCost, depth, op, stack, gas });
},
diff --git a/packages/sol-tracing-utils/src/types.ts b/packages/sol-tracing-utils/src/types.ts
index 27568ae03..97b5e6b37 100644
--- a/packages/sol-tracing-utils/src/types.ts
+++ b/packages/sol-tracing-utils/src/types.ts
@@ -1,5 +1,4 @@
import { StructLog } from 'ethereum-types';
-import * as Parser from 'solidity-parser-antlr';
export interface LineColumn {
line: number;
@@ -126,8 +125,5 @@ export type EvmCallStack = EvmCallStackEntry[];
export interface SourceSnippet {
source: string;
fileName: string;
- type: string;
- node: Parser.ASTNode;
- name: string | null;
range: SingleFileSourceRange;
}
diff --git a/packages/sol-tracing-utils/src/utils.ts b/packages/sol-tracing-utils/src/utils.ts
index 644321f32..7dc1844a5 100644
--- a/packages/sol-tracing-utils/src/utils.ts
+++ b/packages/sol-tracing-utils/src/utils.ts
@@ -1,13 +1,13 @@
-import { addressUtils, BigNumber } from '@0x/utils';
+import { addressUtils, BigNumber, logUtils } from '@0x/utils';
import { OpCode, StructLog } from 'ethereum-types';
import { addHexPrefix } from 'ethereumjs-util';
import * as _ from 'lodash';
import { ContractData, LineColumn, SingleFileSourceRange } from './types';
-// This is the minimum length of valid contract bytecode. The Solidity compiler
-// metadata is 86 bytes. If you add the '0x' prefix, we get 88.
-const MIN_CONTRACT_BYTECODE_LENGTH = 88;
+const STATICCALL_GAS_COST = 40;
+
+const bytecodeToContractDataIfExists: { [bytecode: string]: ContractData | undefined } = {};
export const utils = {
compareLineColumn(lhs: LineColumn, rhs: LineColumn): number {
@@ -46,22 +46,29 @@ export const utils = {
if (!bytecode.startsWith('0x')) {
throw new Error(`0x hex prefix missing: ${bytecode}`);
}
- const contractData = _.find(contractsData, contractDataCandidate => {
+ // HACK(leo): We want to cache the values that are possibly undefined.
+ // That's why we can't check for undefined as we usually do, but need to use `hasOwnProperty`.
+ if (bytecodeToContractDataIfExists.hasOwnProperty(bytecode)) {
+ return bytecodeToContractDataIfExists[bytecode];
+ }
+ const contractDataCandidates = _.filter(contractsData, contractDataCandidate => {
const bytecodeRegex = utils.bytecodeToBytecodeRegex(contractDataCandidate.bytecode);
- // If the bytecode is less than the minimum length, we are probably
- // dealing with an interface. This isn't what we're looking for.
- if (bytecodeRegex.length < MIN_CONTRACT_BYTECODE_LENGTH) {
- return false;
- }
const runtimeBytecodeRegex = utils.bytecodeToBytecodeRegex(contractDataCandidate.runtimeBytecode);
- if (runtimeBytecodeRegex.length < MIN_CONTRACT_BYTECODE_LENGTH) {
- return false;
- }
// We use that function to find by bytecode or runtimeBytecode. Those are quasi-random strings so
// collisions are practically impossible and it allows us to reuse that code
return !_.isNull(bytecode.match(bytecodeRegex)) || !_.isNull(bytecode.match(runtimeBytecodeRegex));
});
- return contractData;
+ if (contractDataCandidates.length > 1) {
+ const candidates = contractDataCandidates.map(
+ contractDataCandidate => _.values(contractDataCandidate.sources)[0],
+ );
+ const errMsg =
+ "We've found more than one artifact that contains the exact same bytecode and therefore are unable to detect which contract was executed. " +
+ "We'll be assigning all traces to the first one.";
+ logUtils.warn(errMsg);
+ logUtils.warn(candidates);
+ }
+ return (bytecodeToContractDataIfExists[bytecode] = contractDataCandidates[0]);
},
isCallLike(op: OpCode): boolean {
return _.includes([OpCode.CallCode, OpCode.StaticCall, OpCode.Call, OpCode.DelegateCall], op);
@@ -76,10 +83,17 @@ export const utils = {
normalizeStructLogs(structLogs: StructLog[]): StructLog[] {
if (structLogs[0].depth === 1) {
// Geth uses 1-indexed depth counter whilst ganache starts from 0
- const newStructLogs = _.map(structLogs, structLog => ({
- ...structLog,
- depth: structLog.depth - 1,
- }));
+ const newStructLogs = _.map(structLogs, structLog => {
+ const newStructLog = {
+ ...structLog,
+ depth: structLog.depth - 1,
+ };
+ if (newStructLog.op === 'STATICCALL') {
+ // HACK(leo): Geth traces sometimes returns those gas costs incorrectly as very big numbers so we manually fix them.
+ newStructLog.gasCost = STATICCALL_GAS_COST;
+ }
+ return newStructLog;
+ });
return newStructLogs;
}
return structLogs;
diff --git a/packages/sol-tracing-utils/test/collect_coverage_entries_test.ts b/packages/sol-tracing-utils/test/collect_coverage_entries_test.ts
index 7832ec316..d3ca8930c 100644
--- a/packages/sol-tracing-utils/test/collect_coverage_entries_test.ts
+++ b/packages/sol-tracing-utils/test/collect_coverage_entries_test.ts
@@ -130,7 +130,8 @@ describe('Collect coverage entries', () => {
solcovIgnoreContractBaseName,
);
const solcovIgnoreContract = fs.readFileSync(solcovIgnoreContractFileName).toString();
- const coverageEntries = collectCoverageEntries(solcovIgnoreContract);
+ const IGNORE_REGEXP = /\/\*\s*solcov\s+ignore\s+next\s*\*\/\s*/gm;
+ const coverageEntries = collectCoverageEntries(solcovIgnoreContract, IGNORE_REGEXP);
const fnIds = _.keys(coverageEntries.fnMap);
expect(fnIds.length).to.be.equal(1);
diff --git a/packages/sra-spec/CHANGELOG.json b/packages/sra-spec/CHANGELOG.json
index 3f2a9fbc1..e22a3b0e4 100644
--- a/packages/sra-spec/CHANGELOG.json
+++ b/packages/sra-spec/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "version": "2.0.0",
+ "changes": [
+ {
+ "note": "Upgrade the bignumber.js to v8.0.2",
+ "pr": 1517
+ }
+ ]
+ },
+ {
"timestamp": 1547561734,
"version": "1.0.16",
"changes": [
diff --git a/packages/subproviders/CHANGELOG.json b/packages/subproviders/CHANGELOG.json
index dd4dccf4e..ffb9740cd 100644
--- a/packages/subproviders/CHANGELOG.json
+++ b/packages/subproviders/CHANGELOG.json
@@ -1,5 +1,18 @@
[
{
+ "version": "3.0.0",
+ "changes": [
+ {
+ "note": "Upgrade the bignumber.js to v8.0.2",
+ "pr": 1517
+ },
+ {
+ "note": "Update ganache-core to v2.3.3",
+ "pr": 1518
+ }
+ ]
+ },
+ {
"timestamp": 1547561734,
"version": "2.1.11",
"changes": [
diff --git a/packages/subproviders/package.json b/packages/subproviders/package.json
index d5dc2b052..b54cc11db 100644
--- a/packages/subproviders/package.json
+++ b/packages/subproviders/package.json
@@ -37,7 +37,7 @@
"@ledgerhq/hw-app-eth": "^4.3.0",
"@ledgerhq/hw-transport-u2f": "4.24.0",
"@types/eth-lightwallet": "^3.0.0",
- "@types/ganache-core": "^2.1.0",
+ "@types/ganache-core": "^2.1.2",
"@types/hdkey": "^0.7.0",
"@types/web3-provider-engine": "^14.0.0",
"bip39": "^2.5.0",
@@ -46,7 +46,7 @@
"ethereum-types": "^1.1.6",
"ethereumjs-tx": "^1.3.5",
"ethereumjs-util": "^5.1.1",
- "ganache-core": "^2.2.1",
+ "ganache-core": "^2.3.3",
"hdkey": "^0.7.1",
"json-rpc-error": "2.0.0",
"lodash": "^4.17.5",
diff --git a/packages/testnet-faucets/package.json b/packages/testnet-faucets/package.json
index b6e84698d..da7477be4 100644
--- a/packages/testnet-faucets/package.json
+++ b/packages/testnet-faucets/package.json
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@0x/testnet-faucets",
- "version": "1.0.63",
+ "version": "1.0.64",
"engines": {
"node": ">=6.12"
},
@@ -18,7 +18,7 @@
"author": "Fabio Berger",
"license": "Apache-2.0",
"dependencies": {
- "0x.js": "^3.0.2",
+ "0x.js": "^3.0.3",
"@0x/subproviders": "^2.1.11",
"@0x/typescript-typings": "^3.0.8",
"@0x/utils": "^3.0.1",
diff --git a/packages/testnet-faucets/src/ts/dispense_asset_tasks.ts b/packages/testnet-faucets/src/ts/dispense_asset_tasks.ts
index 32f5cb623..58caeeeaa 100644
--- a/packages/testnet-faucets/src/ts/dispense_asset_tasks.ts
+++ b/packages/testnet-faucets/src/ts/dispense_asset_tasks.ts
@@ -19,7 +19,7 @@ export const dispenseAssetTasks = {
logUtils.log(`Processing ETH ${recipientAddress}`);
const userBalance = await web3Wrapper.getBalanceInWeiAsync(recipientAddress);
const maxAmountInWei = Web3Wrapper.toWei(new BigNumber(DISPENSE_MAX_AMOUNT_ETHER));
- if (userBalance.greaterThanOrEqualTo(maxAmountInWei)) {
+ if (userBalance.isGreaterThanOrEqualTo(maxAmountInWei)) {
logUtils.log(
`User exceeded ETH balance maximum (${maxAmountInWei}) ${recipientAddress} ${userBalance} `,
);
@@ -55,7 +55,7 @@ export const dispenseAssetTasks = {
new BigNumber(DISPENSE_MAX_AMOUNT_TOKEN),
tokenIfExists.decimals,
);
- if (userBalanceBaseUnits.greaterThanOrEqualTo(maxAmountBaseUnits)) {
+ if (userBalanceBaseUnits.isGreaterThanOrEqualTo(maxAmountBaseUnits)) {
logUtils.log(
`User exceeded token balance maximum (${maxAmountBaseUnits}) ${recipientAddress} ${userBalanceBaseUnits} `,
);
diff --git a/packages/testnet-faucets/src/ts/handler.ts b/packages/testnet-faucets/src/ts/handler.ts
index 8f642d4b0..533e1f8b3 100644
--- a/packages/testnet-faucets/src/ts/handler.ts
+++ b/packages/testnet-faucets/src/ts/handler.ts
@@ -178,8 +178,10 @@ export class Handler {
exchangeAddress: networkConfig.contractWrappers.exchange.address,
feeRecipientAddress: NULL_ADDRESS,
senderAddress: NULL_ADDRESS,
- // tslint:disable-next-line:custom-no-magic-numbers
- expirationTimeSeconds: new BigNumber(Date.now() + FIVE_DAYS_IN_MS).div(1000).floor(),
+ expirationTimeSeconds: new BigNumber(Date.now() + FIVE_DAYS_IN_MS)
+ // tslint:disable-next-line:custom-no-magic-numbers
+ .div(1000)
+ .integerValue(BigNumber.ROUND_FLOOR),
};
const orderHash = orderHashUtils.getOrderHashHex(order);
const signature = await signatureUtils.ecSignHashAsync(
diff --git a/packages/tslint-config/CHANGELOG.json b/packages/tslint-config/CHANGELOG.json
index fe34592fd..34ea6aa6b 100644
--- a/packages/tslint-config/CHANGELOG.json
+++ b/packages/tslint-config/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "version": "3.0.0",
+ "changes": [
+ {
+ "note": "Upgrade the bignumber.js to v8.0.2",
+ "pr": 1517
+ }
+ ]
+ },
+ {
"timestamp": 1547561734,
"version": "2.0.2",
"changes": [
diff --git a/packages/types/CHANGELOG.json b/packages/types/CHANGELOG.json
index 40a46ac84..7a6d205ee 100644
--- a/packages/types/CHANGELOG.json
+++ b/packages/types/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "version": "2.0.0",
+ "changes": [
+ {
+ "note": "Upgrade the bignumber.js to v8.0.2",
+ "pr": 1517
+ }
+ ]
+ },
+ {
"timestamp": 1547561734,
"version": "1.5.2",
"changes": [
diff --git a/packages/types/package.json b/packages/types/package.json
index 2fea809bc..440f05423 100644
--- a/packages/types/package.json
+++ b/packages/types/package.json
@@ -31,7 +31,7 @@
},
"dependencies": {
"@types/node": "*",
- "bignumber.js": "~4.1.0",
+ "bignumber.js": "~8.0.2",
"ethereum-types": "^1.1.6"
},
"publishConfig": {
diff --git a/packages/typescript-typings/CHANGELOG.json b/packages/typescript-typings/CHANGELOG.json
index cc7ef7fa4..e3ae60231 100644
--- a/packages/typescript-typings/CHANGELOG.json
+++ b/packages/typescript-typings/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "version": "4.0.0",
+ "changes": [
+ {
+ "note": "Upgrade the bignumber.js to v8.0.2",
+ "pr": 1517
+ }
+ ]
+ },
+ {
"timestamp": 1547561734,
"version": "3.0.8",
"changes": [
diff --git a/packages/typescript-typings/package.json b/packages/typescript-typings/package.json
index 6640760e4..01cab8c63 100644
--- a/packages/typescript-typings/package.json
+++ b/packages/typescript-typings/package.json
@@ -26,7 +26,7 @@
"dependencies": {
"@types/bn.js": "^4.11.0",
"@types/react": "*",
- "bignumber.js": "~4.1.0",
+ "bignumber.js": "~8.0.2",
"ethereum-types": "^1.1.6",
"popper.js": "1.14.3"
},
diff --git a/packages/utils/CHANGELOG.json b/packages/utils/CHANGELOG.json
index 851c106d8..0fb199e58 100644
--- a/packages/utils/CHANGELOG.json
+++ b/packages/utils/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "version": "4.0.0",
+ "changes": [
+ {
+ "note": "Upgrade the bignumber.js to v8.0.2",
+ "pr": 1517
+ }
+ ]
+ },
+ {
"timestamp": 1547561734,
"version": "3.0.1",
"changes": [
diff --git a/packages/utils/package.json b/packages/utils/package.json
index 315f5a08f..b6be39210 100644
--- a/packages/utils/package.json
+++ b/packages/utils/package.json
@@ -34,7 +34,7 @@
"@types/mocha": "^2.2.42",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
- "chai-bignumber": "^2.0.1",
+ "chai-bignumber": "^3.0.0",
"dirty-chai": "^2.0.1",
"make-promises-safe": "^1.1.0",
"mocha": "^4.1.0",
@@ -48,7 +48,7 @@
"@0x/typescript-typings": "^3.0.8",
"@types/node": "*",
"abortcontroller-polyfill": "^1.1.9",
- "bignumber.js": "~4.1.0",
+ "bignumber.js": "~8.0.2",
"chalk": "^2.4.1",
"detect-node": "2.0.3",
"ethereum-types": "^1.1.6",
diff --git a/packages/utils/src/abi_decoder.ts b/packages/utils/src/abi_decoder.ts
index 2da46db35..28b6418d8 100644
--- a/packages/utils/src/abi_decoder.ts
+++ b/packages/utils/src/abi_decoder.ts
@@ -69,7 +69,7 @@ export class AbiDecoder {
}
if (param.type === SolidityTypes.Address) {
const baseHex = 16;
- value = addressUtils.padZeros(new BigNumber(value).toString(baseHex));
+ value = addressUtils.padZeros(new BigNumber((value as string).toLowerCase()).toString(baseHex));
} else if (param.type === SolidityTypes.Uint256 || param.type === SolidityTypes.Uint) {
value = new BigNumber(value);
} else if (param.type === SolidityTypes.Uint8) {
diff --git a/packages/utils/src/abi_encoder/evm_data_types/bool.ts b/packages/utils/src/abi_encoder/evm_data_types/bool.ts
index 7f91f34e6..23298bc88 100644
--- a/packages/utils/src/abi_encoder/evm_data_types/bool.ts
+++ b/packages/utils/src/abi_encoder/evm_data_types/bool.ts
@@ -37,11 +37,11 @@ export class BoolDataType extends AbstractBlobDataType {
const valueBuf = calldata.popWord();
const valueHex = ethUtil.bufferToHex(valueBuf);
const valueNumber = new BigNumber(valueHex, constants.HEX_BASE);
- if (!(valueNumber.equals(0) || valueNumber.equals(1))) {
+ if (!(valueNumber.isEqualTo(0) || valueNumber.isEqualTo(1))) {
throw new Error(`Failed to decode boolean. Expected 0x0 or 0x1, got ${valueHex}`);
}
/* tslint:disable boolean-naming */
- const value: boolean = !valueNumber.equals(0);
+ const value: boolean = !valueNumber.isEqualTo(0);
/* tslint:enable boolean-naming */
return value;
}
diff --git a/packages/utils/src/abi_encoder/evm_data_types/int.ts b/packages/utils/src/abi_encoder/evm_data_types/int.ts
index 8d98e195b..f8be1f778 100644
--- a/packages/utils/src/abi_encoder/evm_data_types/int.ts
+++ b/packages/utils/src/abi_encoder/evm_data_types/int.ts
@@ -10,7 +10,7 @@ import * as EncoderMath from '../utils/math';
export class IntDataType extends AbstractBlobDataType {
private static readonly _MATCHER = RegExp(
- '^int(8|16|24|32|40|48|56|64|72|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256){0,1}$',
+ '^int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256){0,1}$',
);
private static readonly _SIZE_KNOWN_AT_COMPILE_TIME: boolean = true;
private static readonly _MAX_WIDTH: number = 256;
@@ -38,8 +38,8 @@ export class IntDataType extends AbstractBlobDataType {
throw new Error(`Tried to instantiate Int with bad input: ${dataItem}`);
}
this._width = IntDataType._decodeWidthFromType(dataItem.type);
- this._minValue = new BigNumber(2).toPower(this._width - 1).times(-1);
- this._maxValue = new BigNumber(2).toPower(this._width - 1).sub(1);
+ this._minValue = new BigNumber(2).exponentiatedBy(this._width - 1).times(-1);
+ this._maxValue = new BigNumber(2).exponentiatedBy(this._width - 1).minus(1);
}
public encodeValue(value: BigNumber | string | number): Buffer {
diff --git a/packages/utils/src/abi_encoder/evm_data_types/uint.ts b/packages/utils/src/abi_encoder/evm_data_types/uint.ts
index 8e382e8dc..a82aa789e 100644
--- a/packages/utils/src/abi_encoder/evm_data_types/uint.ts
+++ b/packages/utils/src/abi_encoder/evm_data_types/uint.ts
@@ -38,7 +38,7 @@ export class UIntDataType extends AbstractBlobDataType {
throw new Error(`Tried to instantiate UInt with bad input: ${dataItem}`);
}
this._width = UIntDataType._decodeWidthFromType(dataItem.type);
- this._maxValue = new BigNumber(2).toPower(this._width).sub(1);
+ this._maxValue = new BigNumber(2).exponentiatedBy(this._width).minus(1);
}
public encodeValue(value: BigNumber | string | number): Buffer {
diff --git a/packages/utils/src/abi_encoder/utils/math.ts b/packages/utils/src/abi_encoder/utils/math.ts
index d84983c5b..a2a79e2a8 100644
--- a/packages/utils/src/abi_encoder/utils/math.ts
+++ b/packages/utils/src/abi_encoder/utils/math.ts
@@ -1,7 +1,7 @@
-import BigNumber from 'bignumber.js';
import * as ethUtil from 'ethereumjs-util';
import * as _ from 'lodash';
+import { BigNumber } from '../../configured_bignumber';
import { constants } from '../utils/constants';
function sanityCheckBigNumberRange(
@@ -10,10 +10,12 @@ function sanityCheckBigNumberRange(
maxValue: BigNumber,
): void {
const value = new BigNumber(value_, 10);
- if (value.greaterThan(maxValue)) {
+ if (value.isGreaterThan(maxValue)) {
throw new Error(`Tried to assign value of ${value}, which exceeds max value of ${maxValue}`);
- } else if (value.lessThan(minValue)) {
+ } else if (value.isLessThan(minValue)) {
throw new Error(`Tried to assign value of ${value}, which exceeds min value of ${minValue}`);
+ } else if (value.isNaN()) {
+ throw new Error(`Tried to assign NaN value`);
}
}
function bigNumberToPaddedBuffer(value: BigNumber): Buffer {
@@ -30,7 +32,7 @@ function bigNumberToPaddedBuffer(value: BigNumber): Buffer {
export function encodeNumericValue(value_: BigNumber | string | number): Buffer {
const value = new BigNumber(value_, 10);
// Case 1/2: value is non-negative
- if (value.greaterThanOrEqualTo(0)) {
+ if (value.isGreaterThanOrEqualTo(0)) {
const encodedPositiveValue = bigNumberToPaddedBuffer(value);
return encodedPositiveValue;
}
@@ -74,7 +76,7 @@ export function decodeNumericValue(encodedValue: Buffer, minValue: BigNumber): B
const valueHex = ethUtil.bufferToHex(encodedValue);
// Case 1/3: value is definitely non-negative because of numeric boundaries
const value = new BigNumber(valueHex, constants.HEX_BASE);
- if (!minValue.lessThan(0)) {
+ if (!minValue.isLessThan(0)) {
return value;
}
// Case 2/3: value is non-negative because there is no leading 1 (encoded as two's-complement)
diff --git a/packages/utils/src/sign_typed_data_utils.ts b/packages/utils/src/sign_typed_data_utils.ts
index 6963b9084..adb66622d 100644
--- a/packages/utils/src/sign_typed_data_utils.ts
+++ b/packages/utils/src/sign_typed_data_utils.ts
@@ -1,8 +1,9 @@
+import { EIP712Object, EIP712ObjectValue, EIP712TypedData, EIP712Types } from '@0x/types';
import * as ethUtil from 'ethereumjs-util';
import * as ethers from 'ethers';
import * as _ from 'lodash';
-import { EIP712Object, EIP712ObjectValue, EIP712TypedData, EIP712Types } from '@0x/types';
+import { BigNumber } from './configured_bignumber';
export const signTypedDataUtils = {
/**
@@ -70,7 +71,7 @@ export const signTypedDataUtils = {
return ethers.utils.defaultAbiCoder.encode(encodedTypes, encodedValues);
},
_normalizeValue(type: string, value: any): EIP712ObjectValue {
- const normalizedValue = type === 'uint256' && _.isObject(value) && value.isBigNumber ? value.toString() : value;
+ const normalizedValue = type === 'uint256' && BigNumber.isBigNumber(value) ? value.toString() : value;
return normalizedValue;
},
_typeHash(primaryType: string, types: EIP712Types): Buffer {
diff --git a/packages/utils/test/abi_encoder/evm_data_types_test.ts b/packages/utils/test/abi_encoder/evm_data_types_test.ts
index 54d536a7e..4814ce28b 100644
--- a/packages/utils/test/abi_encoder/evm_data_types_test.ts
+++ b/packages/utils/test/abi_encoder/evm_data_types_test.ts
@@ -205,7 +205,7 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => {
// Encode Args and validate result
expect(() => {
dataType.encode(args, encodingRules);
- }).to.throw();
+ }).to.throw('Tried to assign NaN value');
});
});
diff --git a/packages/web3-wrapper/CHANGELOG.json b/packages/web3-wrapper/CHANGELOG.json
index b9d5a37b1..4a639f662 100644
--- a/packages/web3-wrapper/CHANGELOG.json
+++ b/packages/web3-wrapper/CHANGELOG.json
@@ -1,5 +1,18 @@
[
{
+ "version": "4.0.0",
+ "changes": [
+ {
+ "note": "Upgrade the bignumber.js to v8.0.2",
+ "pr": 1517
+ },
+ {
+ "note": "Update ganache-core to v2.3.3",
+ "pr": 1518
+ }
+ ]
+ },
+ {
"timestamp": 1547561734,
"version": "3.2.4",
"changes": [
diff --git a/packages/web3-wrapper/package.json b/packages/web3-wrapper/package.json
index ce9c41ae7..f28cc36ca 100644
--- a/packages/web3-wrapper/package.json
+++ b/packages/web3-wrapper/package.json
@@ -37,13 +37,13 @@
"homepage": "https://github.com/0xProject/0x-monorepo/packages/web3-wrapper/README.md",
"devDependencies": {
"@0x/tslint-config": "^2.0.2",
- "@types/ganache-core": "^2.1.0",
+ "@types/ganache-core": "^2.1.2",
"@types/lodash": "4.14.104",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
- "chai-bignumber": "^2.0.1",
+ "chai-bignumber": "^3.0.0",
"dirty-chai": "^2.0.1",
- "ganache-core": "0xProject/ganache-core#monorepo-dep",
+ "ganache-core": "^2.3.3",
"make-promises-safe": "^1.1.0",
"mocha": "^4.1.0",
"npm-run-all": "^4.1.2",
diff --git a/packages/web3-wrapper/src/utils.ts b/packages/web3-wrapper/src/utils.ts
index c68587632..1aba3c75a 100644
--- a/packages/web3-wrapper/src/utils.ts
+++ b/packages/web3-wrapper/src/utils.ts
@@ -2,10 +2,6 @@ import { BigNumber } from '@0x/utils';
import * as _ from 'lodash';
export const utils = {
- isBigNumber(value: any): boolean {
- const isBigNumber = _.isObject(value) && value.isBigNumber;
- return isBigNumber;
- },
convertHexToNumber(value: string): number {
const valueBigNumber = new BigNumber(value);
const valueNumber = valueBigNumber.toNumber();
@@ -20,7 +16,7 @@ export const utils = {
},
convertAmountToBigNumber(value: string | number | BigNumber): BigNumber {
const num = value || 0;
- const isBigNumber = utils.isBigNumber(num);
+ const isBigNumber = BigNumber.isBigNumber(num);
if (isBigNumber) {
return num as BigNumber;
}
@@ -37,7 +33,7 @@ export const utils = {
const hexBase = 16;
const valueHex = valueBigNumber.toString(hexBase);
- return valueBigNumber.lessThan(0) ? `-0x${valueHex.substr(1)}` : `0x${valueHex}`;
+ return valueBigNumber.isLessThan(0) ? `-0x${valueHex.substr(1)}` : `0x${valueHex}`;
},
numberToHex(value: number): string {
if (!isFinite(value) && !utils.isHexStrict(value)) {
diff --git a/packages/web3-wrapper/test/web3_wrapper_test.ts b/packages/web3-wrapper/test/web3_wrapper_test.ts
index 935c67636..c4ee91d3d 100644
--- a/packages/web3-wrapper/test/web3_wrapper_test.ts
+++ b/packages/web3-wrapper/test/web3_wrapper_test.ts
@@ -1,10 +1,10 @@
+import { BigNumber } from '@0x/utils';
import * as chai from 'chai';
import { BlockParamLiteral, JSONRPCErrorCallback, JSONRPCRequestPayload, TransactionReceipt } from 'ethereum-types';
import * as Ganache from 'ganache-core';
import * as _ from 'lodash';
import 'mocha';
-import { utils } from '../src/utils';
import { Web3Wrapper } from '../src/web3_wrapper';
import { chaiSetup } from './utils/chai_setup';
@@ -35,7 +35,7 @@ describe('Web3Wrapper tests', () => {
describe('#getNodeVersionAsync', () => {
it('gets the node version', async () => {
const nodeVersion = await web3Wrapper.getNodeVersionAsync();
- const NODE_VERSION = 'EthereumJS TestRPC/v2.1.2/ethereum-js';
+ const NODE_VERSION = 'EthereumJS TestRPC/v2.3.3/ethereum-js';
expect(nodeVersion).to.be.equal(NODE_VERSION);
});
});
@@ -118,7 +118,7 @@ describe('Web3Wrapper tests', () => {
throw new Error('Expected block to exist');
}
expect(blockIfExists.number).to.be.equal(0);
- expect(utils.isBigNumber(blockIfExists.difficulty)).to.equal(true);
+ expect(BigNumber.isBigNumber(blockIfExists.difficulty)).to.equal(true);
expect(_.isNumber(blockIfExists.gasLimit)).to.equal(true);
});
it('gets block when supplied a block number', async () => {
@@ -151,7 +151,7 @@ describe('Web3Wrapper tests', () => {
const blockParamLiteral = BlockParamLiteral.Earliest;
const block = await web3Wrapper.getBlockWithTransactionDataAsync(blockParamLiteral);
expect(block.number).to.be.equal(0);
- expect(utils.isBigNumber(block.difficulty)).to.equal(true);
+ expect(BigNumber.isBigNumber(block.difficulty)).to.equal(true);
expect(_.isNumber(block.gasLimit)).to.equal(true);
});
it('should throw if supplied invalid blockParam value', async () => {
diff --git a/packages/website/md/docs/sol_coverage/installation.md b/packages/website/md/docs/sol_coverage/installation.md
index c7aaf07e9..7c9840ab8 100644
--- a/packages/website/md/docs/sol_coverage/installation.md
+++ b/packages/website/md/docs/sol_coverage/installation.md
@@ -1,7 +1,7 @@
**Install**
```bash
-yarn add @0x/sol-coverage
+yarn add -D @0x/sol-coverage
```
**Import**
diff --git a/packages/website/md/docs/sol_coverage/introduction.md b/packages/website/md/docs/sol_coverage/introduction.md
index 3214e93a9..f21f8ecbe 100644
--- a/packages/website/md/docs/sol_coverage/introduction.md
+++ b/packages/website/md/docs/sol_coverage/introduction.md
@@ -1 +1 @@
-Welcome to the [sol-coverage](https://github.com/0xProject/0x-monorepo/tree/development/packages/sol-coverage) documentation! Sol-coverage is a Solidity coverage tool for your smart contract tests.
+Welcome to the [sol-coverage](https://github.com/0xProject/0x-monorepo/tree/development/packages/sol-coverage) documentation! Sol-coverage is a Solidity coverage tool.
diff --git a/packages/website/md/docs/sol_coverage/usage.md b/packages/website/md/docs/sol_coverage/usage.md
index dd3cdf597..d194f8abd 100644
--- a/packages/website/md/docs/sol_coverage/usage.md
+++ b/packages/website/md/docs/sol_coverage/usage.md
@@ -1,4 +1,4 @@
-Sol-coverage uses transaction traces in order to figure out which lines of Solidity source code have been covered by your tests. In order for it to gather these traces, you must add the `CoverageSubprovider` to the [ProviderEngine](https://github.com/MetaMask/provider-engine) instance you use when running your Solidity tests. If you're unfamiliar with ProviderEngine, please read the [Web3 Provider explained](https://0x.org/wiki#Web3-Provider-Explained) wiki article.
+Sol-coverage uses transaction traces in order to figure out which lines of Solidity source code have been covered by your tests. In order for it to gather these traces, you must add the `CoverageSubprovider` to the [ProviderEngine](https://github.com/MetaMask/provider-engine) instance you use when running your Solidity tests. If you're unfamiliar with `ProviderEngine`, please read the [Web3 Provider explained](https://0x.org/wiki#Web3-Provider-Explained) wiki article.
The CoverageSubprovider eavesdrops on the `eth_sendTransaction` and `eth_call` RPC calls and collects traces after each call using `debug_traceTransaction`. `eth_call`'s' don't generate traces - so we take a snapshot, re-submit it as a transaction, get the trace and then revert the snapshot.
@@ -12,9 +12,8 @@ If you are generating your artifacts with [@0x/sol-compiler](https://0x.org/docs
```typescript
import { SolCompilerArtifactsAdapter } from '@0x/sol-coverage';
-const artifactsPath = 'src/artifacts';
-const contractsPath = 'src/contracts';
-const artifactsAdapter = new SolCompilerArtifactsAdapter(artifactsPath, contractsPath);
+// Both artifactsDir and contractsDir are optional and will be fetched from compiler.json if not passed in
+const artifactAdapter = new SolCompilerArtifactAdapter(artifactsDir, contractsDir);
```
### Truffle
@@ -23,8 +22,9 @@ If your project is using [Truffle](https://truffleframework.com/), we've written
```typescript
import { TruffleArtifactAdapter } from '@0x/sol-coverage';
-const contractsPath = 'src/contracts';
-const artifactAdapter = new TruffleArtifactAdapter(contractsDir);
+const projectRoot = '.';
+const solcVersion = '0.5.0';
+const artifactAdapter = new TruffleArtifactAdapter(projectRoot, solcVersion);
```
Because truffle artifacts don't have all the data we need - we actually will recompile your contracts under the hood. That's why you don't need to pass an `artifactsPath`.
@@ -32,7 +32,13 @@ Because truffle artifacts don't have all the data we need - we actually will rec
### Other framework/toolset
You'll need to write your own artifacts adapter. It should extend `AbstractArtifactsAdapter`.
-Look at the code of the two adapters above for examples.
+
+```typescript
+import { AbstractArtifactAdapter } from '@0x/sol-trace';
+
+class YourCustomArtifactsAdapter extends AbstractArtifactAdapter {...};
+const artifactAdapter = new YourCustomArtifactsAdapter(...);
+```
### Usage
@@ -41,16 +47,14 @@ import { CoverageSubprovider } from '@0x/sol-coverage';
import ProviderEngine = require('web3-provider-engine');
const provider = new ProviderEngine();
-
-const artifactsPath = 'src/artifacts';
-const contractsPath = 'src/contracts';
-const networkId = 50;
// Some calls might not have `from` address specified. Nevertheless - transactions need to be submitted from an address with at least some funds. defaultFromAddress is the address that will be used to submit those calls as transactions from.
const defaultFromAddress = '0x5409ed021d9299bf6814279a6a1411a7e866a631';
const isVerbose = true;
const coverageSubprovider = new CoverageSubprovider(artifactsAdapter, defaultFromAddress, isVerbose);
provider.addProvider(coverageSubprovider);
+// Add all your other providers
+provider.start();
```
After your test suite is complete (e.g in the Mocha global `after` hook), you'll need to call:
@@ -60,3 +64,11 @@ await coverageSubprovider.writeCoverageAsync();
```
This will create a `coverage.json` file in a `coverage` directory. This file has an [Istanbul format](https://github.com/gotwarlost/istanbul/blob/master/coverage.json.md) - so you can use it with any of the existing Istanbul reporters.
+
+```bash
+yarn add -D istanbul
+istanbul report html
+open coverage/index.html
+```
+
+Use [Geth](https://github.com/ethereum/go-ethereum) as a backing node. We recommend using our [Devnet Docker container](https://hub.docker.com/r/0xorg/devnet) which sets up a Geth node for testing purposes. Ganache support is a [work in progress](https://github.com/0xProject/0x-monorepo/issues/1520).
diff --git a/packages/website/md/docs/sol_profiler/installation.md b/packages/website/md/docs/sol_profiler/installation.md
index be9a365f5..e29ac5ae7 100644
--- a/packages/website/md/docs/sol_profiler/installation.md
+++ b/packages/website/md/docs/sol_profiler/installation.md
@@ -1,7 +1,7 @@
**Install**
```bash
-yarn add @0x/sol-profiler
+yarn add -D @0x/sol-profiler
```
**Import**
diff --git a/packages/website/md/docs/sol_profiler/usage.md b/packages/website/md/docs/sol_profiler/usage.md
index 35ea140da..0fbc31bc1 100644
--- a/packages/website/md/docs/sol_profiler/usage.md
+++ b/packages/website/md/docs/sol_profiler/usage.md
@@ -1,4 +1,4 @@
-Sol-profiler uses transaction traces in order to figure out which lines of Solidity source code have been covered by your tests. In order for it to gather these traces, you must add the `ProfilerSubprovider` to the [ProviderEngine](https://github.com/MetaMask/provider-engine) instance you use when running your Solidity tests. If you're unfamiliar with ProviderEngine, please read the [Web3 Provider explained](https://0x.org/wiki#Web3-Provider-Explained) wiki article.
+Sol-profiler uses transaction traces in order to figure out which lines of Solidity source code have been covered by your tests. In order for it to gather these traces, you must add the `ProfilerSubprovider` to the [ProviderEngine](https://github.com/MetaMask/provider-engine) instance you use when running your Solidity tests. If you're unfamiliar with `ProviderEngine`, please read the [Web3 Provider explained](https://0x.org/wiki#Web3-Provider-Explained) wiki article.
The ProfilerSubprovider eavesdrops on the `eth_sendTransaction` and `eth_call` RPC calls and collects traces after each call using `debug_traceTransaction`. `eth_call`'s' don't generate traces - so we take a snapshot, re-submit it as a transaction, get the trace and then revert the snapshot.
@@ -12,9 +12,8 @@ If you are generating your artifacts with [@0x/sol-compiler](https://0x.org/docs
```typescript
import { SolCompilerArtifactsAdapter } from '@0x/sol-profiler';
-const artifactsPath = 'src/artifacts';
-const contractsPath = 'src/contracts';
-const artifactsAdapter = new SolCompilerArtifactsAdapter(artifactsPath, contractsPath);
+// Both artifactsDir and contractsDir are optional and will be fetched from compiler.json if not passed in
+const artifactAdapter = new SolCompilerArtifactAdapter(artifactsDir, contractsDir);
```
### Truffle
@@ -23,8 +22,9 @@ If your project is using [Truffle](https://truffleframework.com/), we've written
```typescript
import { TruffleArtifactAdapter } from '@0x/sol-profiler';
-const contractsPath = 'src/contracts';
-const artifactAdapter = new TruffleArtifactAdapter(contractsDir);
+const projectRoot = '.';
+const solcVersion = '0.5.0';
+const artifactAdapter = new TruffleArtifactAdapter(projectRoot, solcVersion);
```
Because truffle artifacts don't have all the data we need - we actually will recompile your contracts under the hood. That's why you don't need to pass an `artifactsPath`.
@@ -32,7 +32,13 @@ Because truffle artifacts don't have all the data we need - we actually will rec
### Other framework/toolset
You'll need to write your own artifacts adapter. It should extend `AbstractArtifactsAdapter`.
-Look at the code of the two adapters above for examples.
+
+```typescript
+import { AbstractArtifactAdapter } from '@0x/sol-trace';
+
+class YourCustomArtifactsAdapter extends AbstractArtifactAdapter {...};
+const artifactAdapter = new YourCustomArtifactsAdapter(...);
+```
### Usage
@@ -41,22 +47,28 @@ import { ProfilerSubprovider } from '@0x/sol-profiler';
import ProviderEngine = require('web3-provider-engine');
const provider = new ProviderEngine();
-
-const artifactsPath = 'src/artifacts';
-const contractsPath = 'src/contracts';
-const networkId = 50;
// Some calls might not have `from` address specified. Nevertheless - transactions need to be submitted from an address with at least some funds. defaultFromAddress is the address that will be used to submit those calls as transactions from.
const defaultFromAddress = '0x5409ed021d9299bf6814279a6a1411a7e866a631';
const isVerbose = true;
const profilerSubprovider = new ProfilerSubprovider(artifactsAdapter, defaultFromAddress, isVerbose);
provider.addProvider(profilerSubprovider);
+// Add all your other providers
+provider.start();
```
After your test suite is complete (e.g in the Mocha global `after` hook), you'll need to call:
```typescript
-await profilerSubprovider.writeProfilerAsync();
+await profilerSubprovider.writeProfilerOutputAsync();
+```
+
+This will create a `coverage.json` file in a `coverage` directory. This file has an [Istanbul format](https://github.com/gotwarlost/istanbul/blob/master/profiler.json.md) - so you can use it with any of the existing Istanbul reporters.
+
+```bash
+yarn add -D istanbul
+istanbul report html
+open coverage/index.html
```
-This will create a `profiler.json` file in a `profiler` directory. This file has an [Istanbul format](https://github.com/gotwarlost/istanbul/blob/master/profiler.json.md) - so you can use it with any of the existing Istanbul reporters.
+Use [Geth](https://github.com/ethereum/go-ethereum) as a backing node. We recommend using our [Devnet Docker container](https://hub.docker.com/r/0xorg/devnet) which sets up a Geth node for testing purposes. Ganache support is a [work in progress](https://github.com/0xProject/0x-monorepo/issues/1520).
diff --git a/packages/website/md/docs/sol_trace/installation.md b/packages/website/md/docs/sol_trace/installation.md
index 2f794b2f8..eb7bf08b8 100644
--- a/packages/website/md/docs/sol_trace/installation.md
+++ b/packages/website/md/docs/sol_trace/installation.md
@@ -1,17 +1,17 @@
**Install**
```bash
-yarn add @0x/sol-trace
+yarn add -D @0x/sol-trace
```
**Import**
```javascript
-import { TraceSubprovider } from '@0x/sol-trace';
+import { RevertTraceSubprovider } from '@0x/sol-trace';
```
or
```javascript
-var TraceSubprovider = require('@0x/sol-trace').TraceSubprovider;
+var RevertTraceSubprovider = require('@0x/sol-trace').RevertTraceSubprovider;
```
diff --git a/packages/website/md/docs/sol_trace/introduction.md b/packages/website/md/docs/sol_trace/introduction.md
index 21fea764e..73f5c2bcd 100644
--- a/packages/website/md/docs/sol_trace/introduction.md
+++ b/packages/website/md/docs/sol_trace/introduction.md
@@ -1 +1 @@
-Welcome to the [sol-trace](https://github.com/0xProject/0x-monorepo/tree/development/packages/sol-trace) documentation! Sol-trace is a Solidity trace tool for your smart contract tests.
+Welcome to the [sol-trace](https://github.com/0xProject/0x-monorepo/tree/development/packages/sol-trace) documentation! Sol-trace gives you a human-readable error stack trace when a revert happens in your Solidity code.
diff --git a/packages/website/md/docs/sol_trace/usage.md b/packages/website/md/docs/sol_trace/usage.md
index f3aa6fc35..d117a0faf 100644
--- a/packages/website/md/docs/sol_trace/usage.md
+++ b/packages/website/md/docs/sol_trace/usage.md
@@ -1,10 +1,10 @@
-Sol-trace uses transaction traces in order to figure out which lines of Solidity source code have been covered by your tests. In order for it to gather these traces, you must add the `TraceSubprovider` to the [ProviderEngine](https://github.com/MetaMask/provider-engine) instance you use when running your Solidity tests. If you're unfamiliar with ProviderEngine, please read the [Web3 Provider explained](https://0x.org/wiki#Web3-Provider-Explained) wiki article.
+Sol-trace uses transaction traces to reconstruct the stack trace when reverts happen in Solidity. In order for it to gather these traces, you must add the `RevertTraceSubprovider` to the [ProviderEngine](https://github.com/MetaMask/provider-engine) instance you use when running your Solidity tests. If you're unfamiliar with `ProviderEngine`, please read the [Web3 Provider explained](https://0x.org/wiki#Web3-Provider-Explained) wiki article.
-The TraceSubprovider eavesdrops on the `eth_sendTransaction` and `eth_call` RPC calls and collects traces after each call using `debug_traceTransaction`. `eth_call`'s' don't generate traces - so we take a snapshot, re-submit it as a transaction, get the trace and then revert the snapshot.
+The `RevertTraceSubprovider` eavesdrops on the `eth_sendTransaction` and `eth_call` RPC calls and collects traces after each call using `debug_traceTransaction`. `eth_call`'s' don't generate traces - so we take a snapshot, re-submit it as a transaction, get the trace and then revert the snapshot.
Trace subprovider needs some info about your contracts (`srcMap`, `bytecode`). It gets that info from your project's artifacts. Some frameworks have their own artifact format. Some artifact formats don't actually contain all the neccessary data.
-In order to use `TraceSubprovider` with your favorite framework you need to pass an `artifactsAdapter` to it.
+In order to use `RevertTraceSubprovider` with your favorite framework you need to pass an `artifactsAdapter` to it.
### Sol-compiler
@@ -12,9 +12,8 @@ If you are generating your artifacts with [@0x/sol-compiler](https://0x.org/docs
```typescript
import { SolCompilerArtifactsAdapter } from '@0x/sol-trace';
-const artifactsPath = 'src/artifacts';
-const contractsPath = 'src/contracts';
-const artifactsAdapter = new SolCompilerArtifactsAdapter(artifactsPath, contractsPath);
+// Both artifactsDir and contractsDir are optional and will be fetched from compiler.json if not passed in
+const artifactAdapter = new SolCompilerArtifactAdapter(artifactsDir, contractsDir);
```
### Truffle
@@ -23,8 +22,9 @@ If your project is using [Truffle](https://truffleframework.com/), we've written
```typescript
import { TruffleArtifactAdapter } from '@0x/sol-trace';
-const contractsPath = 'src/contracts';
-const artifactAdapter = new TruffleArtifactAdapter(contractsDir);
+const projectRoot = '.';
+const solcVersion = '0.5.0';
+const artifactAdapter = new TruffleArtifactAdapter(projectRoot, solcVersion);
```
Because truffle artifacts don't have all the data we need - we actually will recompile your contracts under the hood. That's why you don't need to pass an `artifactsPath`.
@@ -32,31 +32,31 @@ Because truffle artifacts don't have all the data we need - we actually will rec
### Other framework/toolset
You'll need to write your own artifacts adapter. It should extend `AbstractArtifactsAdapter`.
-Look at the code of the two adapters above for examples.
+
+```typescript
+import { AbstractArtifactAdapter } from '@0x/sol-trace';
+
+class YourCustomArtifactsAdapter extends AbstractArtifactAdapter {...};
+const artifactAdapter = new YourCustomArtifactsAdapter(...);
+```
### Usage
```typescript
-import { TraceSubprovider } from '@0x/sol-trace';
+import { RevertTraceSubprovider } from '@0x/sol-trace';
import ProviderEngine = require('web3-provider-engine');
const provider = new ProviderEngine();
-
-const artifactsPath = 'src/artifacts';
-const contractsPath = 'src/contracts';
-const networkId = 50;
// Some calls might not have `from` address specified. Nevertheless - transactions need to be submitted from an address with at least some funds. defaultFromAddress is the address that will be used to submit those calls as transactions from.
const defaultFromAddress = '0x5409ed021d9299bf6814279a6a1411a7e866a631';
const isVerbose = true;
-const traceSubprovider = new TraceSubprovider(artifactsAdapter, defaultFromAddress, isVerbose);
+const revertTraceSubprovider = new RevertTraceSubprovider(artifactsAdapter, defaultFromAddress, isVerbose);
-provider.addProvider(traceSubprovider);
+provider.addProvider(revertTraceSubprovider);
+// Add all your other providers
+provider.start();
```
-After your test suite is complete (e.g in the Mocha global `after` hook), you'll need to call:
-
-```typescript
-await traceSubprovider.writeTraceAsync();
-```
+Now when you run your tests, it should print out stack traces when encountering an error.
-This will create a `trace.json` file in a `trace` directory. This file has an [Istanbul format](https://github.com/gotwarlost/istanbul/blob/master/trace.json.md) - so you can use it with any of the existing Istanbul reporters.
+Use [Geth](https://github.com/ethereum/go-ethereum) as a backing node. We recommend using our [Devnet Docker container](https://hub.docker.com/r/0xorg/devnet) which sets up a Geth node for testing purposes. Ganache support is a [work in progress](https://github.com/0xProject/0x-monorepo/issues/1520).
diff --git a/packages/website/package.json b/packages/website/package.json
index 0d2773a2c..ce7ed395f 100644
--- a/packages/website/package.json
+++ b/packages/website/package.json
@@ -1,6 +1,6 @@
{
"name": "@0x/website",
- "version": "0.0.66",
+ "version": "0.0.67",
"engines": {
"node": ">=6.12"
},
@@ -20,9 +20,9 @@
"author": "Fabio Berger",
"license": "Apache-2.0",
"dependencies": {
- "@0x/asset-buyer": "^4.0.1",
+ "@0x/asset-buyer": "^4.0.2",
"@0x/contract-addresses": "^2.2.0",
- "@0x/contract-wrappers": "^5.0.0",
+ "@0x/contract-wrappers": "^5.0.1",
"@0x/json-schemas": "^2.1.7",
"@0x/order-utils": "^3.1.2",
"@0x/react-docs": "^1.0.25",
diff --git a/packages/website/ts/blockchain.ts b/packages/website/ts/blockchain.ts
index 37f746f7c..ea5a59340 100644
--- a/packages/website/ts/blockchain.ts
+++ b/packages/website/ts/blockchain.ts
@@ -944,7 +944,7 @@ export class Blockchain {
try {
const gasInfo = await backendClient.getGasInfoAsync();
const gasPriceInGwei = new BigNumber(gasInfo.fast / 10);
- const gasPriceInWei = gasPriceInGwei.mul(1000000000);
+ const gasPriceInWei = gasPriceInGwei.multipliedBy(1000000000);
this._defaultGasPrice = gasPriceInWei;
} catch (err) {
return;
diff --git a/packages/website/ts/components/fill_order.tsx b/packages/website/ts/components/fill_order.tsx
index 7fee8c4df..95a3671c4 100644
--- a/packages/website/ts/components/fill_order.tsx
+++ b/packages/website/ts/components/fill_order.tsx
@@ -205,7 +205,7 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
amount: orderMakerAmount
.times(takerAssetToken.amount)
.div(orderTakerAmount)
- .floor(),
+ .integerValue(BigNumber.ROUND_FLOOR),
symbol: makerToken.symbol,
};
const fillAssetToken = {
@@ -219,7 +219,7 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
const orderReceiveAmountBigNumber = orderMakerAmount
.times(this.props.orderFillAmount)
.dividedBy(orderTakerAmount)
- .floor();
+ .integerValue(BigNumber.ROUND_FLOOR);
orderReceiveAmount = this._formatCurrencyAmount(orderReceiveAmountBigNumber, makerToken.decimals);
}
const isUserMaker =
diff --git a/packages/website/ts/pages/documentation/docs_home.tsx b/packages/website/ts/pages/documentation/docs_home.tsx
index d11cf02fb..5849a2a03 100644
--- a/packages/website/ts/pages/documentation/docs_home.tsx
+++ b/packages/website/ts/pages/documentation/docs_home.tsx
@@ -55,7 +55,7 @@ const TUTORIALS: TutorialInfo[] = [
];
const CATEGORY_TO_PACKAGES: ObjectMap<Package[]> = {
- [Categories.ZeroExProtocol]: [
+ [Categories.ZeroExProtocolTypescript]: [
{
description:
'A library for interacting with the 0x protocol. It is a high level package which combines a number of smaller specific-purpose packages such as [order-utils](https://0x.org/docs/order-utils) and [contract-wrappers](https://0x.org/docs/contract-wrappers).',
@@ -92,23 +92,6 @@ const CATEGORY_TO_PACKAGES: ObjectMap<Package[]> = {
},
{
description:
- "A Python library for interacting with 0x orders. Generate an orderHash, sign an order, validate it's signature and more.",
- link: {
- title: '0x-order-utils.py',
- to: 'http://0x-order-utils-py.s3-website-us-east-1.amazonaws.com/',
- shouldOpenInNewTab: true,
- },
- },
- {
- description: 'A Python Standard Relayer API client',
- link: {
- title: '0x-sra-client.py',
- to: 'https://pypi.org/project/0x-sra-client/',
- shouldOpenInNewTab: true,
- },
- },
- {
- description:
'An http & websocket client for interacting with relayers that have implemented the [Standard Relayer API](https://github.com/0xProject/standard-relayer-api)',
link: {
title: '@0x/connect',
@@ -190,6 +173,57 @@ const CATEGORY_TO_PACKAGES: ObjectMap<Package[]> = {
},
},
],
+ [Categories.ZeroExProtocolPython]: [
+ {
+ description:
+ "A library for interacting with 0x orders. Generate an orderHash, sign an order, validate it's signature and more.",
+ link: {
+ title: '0x-order-utils',
+ to: 'https://pypi.org/project/0x-order-utils/',
+ shouldOpenInNewTab: true,
+ },
+ },
+ {
+ description: 'A Standard Relayer API client',
+ link: {
+ title: '0x-sra-client',
+ to: 'https://pypi.org/project/0x-sra-client/',
+ shouldOpenInNewTab: true,
+ },
+ },
+ {
+ description: 'Package containing the addresses at which the 0x smart contracts have been deployed',
+ link: {
+ title: '0x-contract-addresses',
+ to: 'https://pypi.org/project/0x-contract-addresses/',
+ shouldOpenInNewTab: true,
+ },
+ },
+ {
+ description: 'Package containing the 0x smart contract compilation artifacts',
+ link: {
+ title: '0x-contract-artifacts',
+ to: 'https://pypi.org/project/0x-contract-artifacts/',
+ shouldOpenInNewTab: true,
+ },
+ },
+ {
+ description: '0x JSON schemas for those developing on top of 0x protocol',
+ link: {
+ title: '0x-json-schemas',
+ to: 'https://pypi.org/project/0x-json-schemas/',
+ shouldOpenInNewTab: true,
+ },
+ },
+ {
+ description: 'Demo project showing how to interact with the 0x smart contracts using Python',
+ link: {
+ title: '0x-contract-demo',
+ to: 'https://github.com/0xProject/0x-monorepo/blob/development/python-packages/contract_demo/README.md',
+ shouldOpenInNewTab: true,
+ },
+ },
+ ],
[Categories.Ethereum]: [
{
description:
@@ -409,7 +443,10 @@ export class DocsHome extends React.Component<DocsHomeProps, DocsHomeState> {
title: this.props.translate.get(tutorialInfo.link.title as Key, Deco.Cap),
};
}),
- [Categories.ZeroExProtocol]: _.map(CATEGORY_TO_PACKAGES[Categories.ZeroExProtocol], pkg => pkg.link),
+ [Categories.ZeroExProtocolTypescript]: _.map(
+ CATEGORY_TO_PACKAGES[Categories.ZeroExProtocolTypescript],
+ pkg => pkg.link,
+ ),
[Categories.Ethereum]: _.map(CATEGORY_TO_PACKAGES[Categories.Ethereum], pkg => pkg.link),
[Categories.CommunityMaintained]: _.map(
CATEGORY_TO_PACKAGES[Categories.CommunityMaintained],
@@ -466,4 +503,4 @@ export class DocsHome extends React.Component<DocsHomeProps, DocsHomeState> {
});
return menuItems;
}
-}
+} // tslint:disable:max-file-line-count
diff --git a/packages/website/ts/types.ts b/packages/website/ts/types.ts
index 9492da5a5..081c6d014 100644
--- a/packages/website/ts/types.ts
+++ b/packages/website/ts/types.ts
@@ -655,8 +655,9 @@ export interface TutorialInfo {
}
export enum Categories {
- ZeroExProtocol = '0x Protocol',
- Ethereum = 'Ethereum',
+ ZeroExProtocolTypescript = '0x Protocol (Typescript/Javascript)',
+ ZeroExProtocolPython = '0x Protocol (Python)',
+ Ethereum = 'Ethereum (Typescript/Javascript)',
CommunityMaintained = 'Community Maintained',
}
diff --git a/packages/website/ts/utils/utils.ts b/packages/website/ts/utils/utils.ts
index 890f1553a..e84f9d0cc 100644
--- a/packages/website/ts/utils/utils.ts
+++ b/packages/website/ts/utils/utils.ts
@@ -394,7 +394,7 @@ export const utils = {
},
getUsdValueFormattedAmount(amount: BigNumber, decimals: number, price: BigNumber): string {
const unitAmount = Web3Wrapper.toUnitAmount(amount, decimals);
- const value = unitAmount.mul(price);
+ const value = unitAmount.multipliedBy(price);
return utils.format(value, constants.NUMERAL_USD_FORMAT);
},
openUrl(url: string): void {