diff options
author | Fabio Berger <me@fabioberger.com> | 2019-02-07 22:28:24 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2019-02-07 22:28:24 +0800 |
commit | 3dd652e7cf6da63831da143b73c13231a46da376 (patch) | |
tree | 52218d0b88717360fa8bfadf4bbf7e35b9ab5f66 /packages | |
parent | 8de955f3d891620c90c668b4ac0b046e772d4da8 (diff) | |
parent | f003298ce4c7a2201d2d59685b0d5d0411aeb55d (diff) | |
download | dexon-0x-contracts-3dd652e7cf6da63831da143b73c13231a46da376.tar dexon-0x-contracts-3dd652e7cf6da63831da143b73c13231a46da376.tar.gz dexon-0x-contracts-3dd652e7cf6da63831da143b73c13231a46da376.tar.bz2 dexon-0x-contracts-3dd652e7cf6da63831da143b73c13231a46da376.tar.lz dexon-0x-contracts-3dd652e7cf6da63831da143b73c13231a46da376.tar.xz dexon-0x-contracts-3dd652e7cf6da63831da143b73c13231a46da376.tar.zst dexon-0x-contracts-3dd652e7cf6da63831da143b73c13231a46da376.zip |
Merge branch 'development' into addAnalyticsToDevToolsPages
* development: (51 commits)
Publish
Updated CHANGELOGS
Updated CHANGELOGS
Update packages/sol-compiler/CHANGELOG.json
Update packages/sol-compiler/CHANGELOG.json
Move from devDep to dep
Fix linter
Update CHANGELOG
Re-run yarn since fails again on first run
Add PR numbers
Omit remapping in compiler settings equality checks
Omit remapping in compiler settings equality checks
Fix a bug when ast and legacyAST were not present in the artifacts even if requested
Update yarn.lock
Remove the bin_paths and fetch the solidity release list from github repo
Remove postinstall hack
Fix the undefined opts bug
Fix sol-compiler bug with remappings causing smart recompilation to now work
re-add postinstall hack
Fix deps versions
...
Diffstat (limited to 'packages')
141 files changed, 2232 insertions, 460 deletions
diff --git a/packages/0x.js/CHANGELOG.json b/packages/0x.js/CHANGELOG.json index 1eab891a8..69381d7a0 100644 --- a/packages/0x.js/CHANGELOG.json +++ b/packages/0x.js/CHANGELOG.json @@ -1,5 +1,32 @@ [ { + "version": "4.0.3", + "changes": [ + { + "note": "Dependencies updated" + } + ], + "timestamp": 1549547375 + }, + { + "timestamp": 1549504360, + "version": "4.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1549452781, + "version": "4.0.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "version": "4.0.0", "changes": [ { diff --git a/packages/0x.js/CHANGELOG.md b/packages/0x.js/CHANGELOG.md index cca12fda4..7c14fb586 100644 --- a/packages/0x.js/CHANGELOG.md +++ b/packages/0x.js/CHANGELOG.md @@ -5,6 +5,18 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v4.0.3 - _February 7, 2019_ + + * Dependencies updated + +## v4.0.2 - _February 7, 2019_ + + * Dependencies updated + +## v4.0.1 - _February 6, 2019_ + + * Dependencies updated + ## v4.0.0 - _February 5, 2019_ * Upgrade the bignumber.js to v8.0.2 (#1517) diff --git a/packages/0x.js/package.json b/packages/0x.js/package.json index 58cd439fd..b02176811 100644 --- a/packages/0x.js/package.json +++ b/packages/0x.js/package.json @@ -1,6 +1,6 @@ { "name": "0x.js", - "version": "4.0.0", + "version": "4.0.3", "engines": { "node": ">=6.12" }, @@ -42,10 +42,10 @@ }, "license": "Apache-2.0", "devDependencies": { - "@0x/abi-gen-wrappers": "^3.0.0", + "@0x/abi-gen-wrappers": "^3.0.2", "@0x/contract-addresses": "^2.2.1", - "@0x/dev-utils": "^2.0.0", - "@0x/migrations": "^3.0.0", + "@0x/dev-utils": "^2.0.2", + "@0x/migrations": "^3.0.3", "@0x/tslint-config": "^3.0.0", "@types/lodash": "4.14.104", "@types/mocha": "^2.2.42", @@ -72,16 +72,16 @@ "webpack": "^4.20.2" }, "dependencies": { - "@0x/assert": "^2.0.0", - "@0x/base-contract": "^4.0.0", - "@0x/contract-wrappers": "^6.0.1", - "@0x/order-utils": "^4.0.0", - "@0x/order-watcher": "^3.0.0", - "@0x/subproviders": "^3.0.0", - "@0x/types": "^2.0.0", + "@0x/assert": "^2.0.2", + "@0x/base-contract": "^4.0.2", + "@0x/contract-wrappers": "^7.0.2", + "@0x/order-utils": "^6.0.1", + "@0x/order-watcher": "^3.0.3", + "@0x/subproviders": "^3.0.2", + "@0x/types": "^2.0.2", "@0x/typescript-typings": "^4.0.0", - "@0x/utils": "^4.0.1", - "@0x/web3-wrapper": "^4.0.0", + "@0x/utils": "^4.0.3", + "@0x/web3-wrapper": "^4.0.2", "@types/web3-provider-engine": "^14.0.0", "ethereum-types": "^2.0.0", "ethers": "~4.0.4", diff --git a/packages/abi-gen-wrappers/CHANGELOG.json b/packages/abi-gen-wrappers/CHANGELOG.json index 2603ae525..a7793c5d5 100644 --- a/packages/abi-gen-wrappers/CHANGELOG.json +++ b/packages/abi-gen-wrappers/CHANGELOG.json @@ -1,5 +1,23 @@ [ { + "version": "3.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ], + "timestamp": 1549547375 + }, + { + "timestamp": 1549452781, + "version": "3.0.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "version": "3.0.0", "changes": [ { diff --git a/packages/abi-gen-wrappers/CHANGELOG.md b/packages/abi-gen-wrappers/CHANGELOG.md index 793e1f157..93e11736c 100644 --- a/packages/abi-gen-wrappers/CHANGELOG.md +++ b/packages/abi-gen-wrappers/CHANGELOG.md @@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v3.0.2 - _February 7, 2019_ + + * Dependencies updated + +## v3.0.1 - _February 6, 2019_ + + * Dependencies updated + ## v3.0.0 - _February 5, 2019_ * Upgrade the bignumber.js to v8.0.2 (#1517) diff --git a/packages/abi-gen-wrappers/package.json b/packages/abi-gen-wrappers/package.json index 2372aacda..c9682e28f 100644 --- a/packages/abi-gen-wrappers/package.json +++ b/packages/abi-gen-wrappers/package.json @@ -1,6 +1,6 @@ { "name": "@0x/abi-gen-wrappers", - "version": "3.0.0", + "version": "3.0.2", "engines": { "node": ">=6.12" }, @@ -30,19 +30,19 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/abi-gen-wrappers/README.md", "devDependencies": { - "@0x/abi-gen": "^2.0.0", + "@0x/abi-gen": "^2.0.2", "@0x/abi-gen-templates": "^2.0.0", "@0x/tslint-config": "^3.0.0", - "@0x/types": "^2.0.0", - "@0x/utils": "^4.0.1", - "@0x/web3-wrapper": "^4.0.0", + "@0x/types": "^2.0.2", + "@0x/utils": "^4.0.3", + "@0x/web3-wrapper": "^4.0.2", "ethereum-types": "^2.0.0", "ethers": "~4.0.4", "lodash": "^4.17.11", "shx": "^0.2.2" }, "dependencies": { - "@0x/base-contract": "^4.0.0" + "@0x/base-contract": "^4.0.2" }, "publishConfig": { "access": "public" diff --git a/packages/abi-gen/CHANGELOG.json b/packages/abi-gen/CHANGELOG.json index 66858db63..d7770c06d 100644 --- a/packages/abi-gen/CHANGELOG.json +++ b/packages/abi-gen/CHANGELOG.json @@ -1,5 +1,23 @@ [ { + "version": "2.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ], + "timestamp": 1549547375 + }, + { + "timestamp": 1549452781, + "version": "2.0.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "version": "2.0.0", "changes": [ { diff --git a/packages/abi-gen/CHANGELOG.md b/packages/abi-gen/CHANGELOG.md index d68608194..65c914cc9 100644 --- a/packages/abi-gen/CHANGELOG.md +++ b/packages/abi-gen/CHANGELOG.md @@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v2.0.2 - _February 7, 2019_ + + * Dependencies updated + +## v2.0.1 - _February 6, 2019_ + + * Dependencies updated + ## v2.0.0 - _February 5, 2019_ * Upgrade the bignumber.js to v8.0.2 (#1517) diff --git a/packages/abi-gen/package.json b/packages/abi-gen/package.json index 3199eb120..d07e0a580 100644 --- a/packages/abi-gen/package.json +++ b/packages/abi-gen/package.json @@ -1,6 +1,6 @@ { "name": "@0x/abi-gen", - "version": "2.0.0", + "version": "2.0.2", "engines": { "node": ">=6.12" }, @@ -32,7 +32,7 @@ "homepage": "https://github.com/0xProject/0x-monorepo/packages/abi-gen/README.md", "dependencies": { "@0x/typescript-typings": "^4.0.0", - "@0x/utils": "^4.0.1", + "@0x/utils": "^4.0.3", "chalk": "^2.3.0", "ethereum-types": "^2.0.0", "glob": "^7.1.2", diff --git a/packages/assert/CHANGELOG.json b/packages/assert/CHANGELOG.json index 814b5d148..e2231a676 100644 --- a/packages/assert/CHANGELOG.json +++ b/packages/assert/CHANGELOG.json @@ -1,5 +1,23 @@ [ { + "version": "2.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ], + "timestamp": 1549547375 + }, + { + "timestamp": 1549452781, + "version": "2.0.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "version": "2.0.0", "changes": [ { diff --git a/packages/assert/CHANGELOG.md b/packages/assert/CHANGELOG.md index 90fba7196..682115497 100644 --- a/packages/assert/CHANGELOG.md +++ b/packages/assert/CHANGELOG.md @@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v2.0.2 - _February 7, 2019_ + + * Dependencies updated + +## v2.0.1 - _February 6, 2019_ + + * Dependencies updated + ## v2.0.0 - _February 5, 2019_ * Upgrade the bignumber.js to v8.0.2 (#1517) diff --git a/packages/assert/package.json b/packages/assert/package.json index e071e3992..551414de3 100644 --- a/packages/assert/package.json +++ b/packages/assert/package.json @@ -1,6 +1,6 @@ { "name": "@0x/assert", - "version": "2.0.0", + "version": "2.0.2", "engines": { "node": ">=6.12" }, @@ -44,9 +44,9 @@ "typescript": "3.0.1" }, "dependencies": { - "@0x/json-schemas": "^3.0.0", + "@0x/json-schemas": "^3.0.2", "@0x/typescript-typings": "^4.0.0", - "@0x/utils": "^4.0.1", + "@0x/utils": "^4.0.3", "lodash": "^4.17.11", "valid-url": "^1.0.9" }, diff --git a/packages/asset-buyer/CHANGELOG.json b/packages/asset-buyer/CHANGELOG.json index 39d402084..80b02f2c6 100644 --- a/packages/asset-buyer/CHANGELOG.json +++ b/packages/asset-buyer/CHANGELOG.json @@ -1,5 +1,32 @@ [ { + "version": "5.0.3", + "changes": [ + { + "note": "Dependencies updated" + } + ], + "timestamp": 1549547375 + }, + { + "timestamp": 1549504360, + "version": "5.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1549452781, + "version": "5.0.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "version": "5.0.0", "changes": [ { diff --git a/packages/asset-buyer/CHANGELOG.md b/packages/asset-buyer/CHANGELOG.md index 5bb0d7274..c5977e3e4 100644 --- a/packages/asset-buyer/CHANGELOG.md +++ b/packages/asset-buyer/CHANGELOG.md @@ -5,6 +5,18 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v5.0.3 - _February 7, 2019_ + + * Dependencies updated + +## v5.0.2 - _February 7, 2019_ + + * Dependencies updated + +## v5.0.1 - _February 6, 2019_ + + * Dependencies updated + ## v5.0.0 - _February 5, 2019_ * Upgrade the bignumber.js to v8.0.2 (#1517) diff --git a/packages/asset-buyer/package.json b/packages/asset-buyer/package.json index e4a8dcd6a..391a5d688 100644 --- a/packages/asset-buyer/package.json +++ b/packages/asset-buyer/package.json @@ -1,6 +1,6 @@ { "name": "@0x/asset-buyer", - "version": "5.0.0", + "version": "5.0.3", "engines": { "node": ">=6.12" }, @@ -36,16 +36,16 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/asset-buyer/README.md", "dependencies": { - "@0x/assert": "^2.0.0", - "@0x/connect": "^4.0.0", - "@0x/contract-wrappers": "^6.0.1", - "@0x/json-schemas": "^3.0.0", - "@0x/order-utils": "^4.0.0", - "@0x/subproviders": "^3.0.0", - "@0x/types": "^2.0.0", + "@0x/assert": "^2.0.2", + "@0x/connect": "^4.0.3", + "@0x/contract-wrappers": "^7.0.2", + "@0x/json-schemas": "^3.0.2", + "@0x/order-utils": "^6.0.1", + "@0x/subproviders": "^3.0.2", + "@0x/types": "^2.0.2", "@0x/typescript-typings": "^4.0.0", - "@0x/utils": "^4.0.1", - "@0x/web3-wrapper": "^4.0.0", + "@0x/utils": "^4.0.3", + "@0x/web3-wrapper": "^4.0.2", "ethereum-types": "^2.0.0", "lodash": "^4.17.11" }, diff --git a/packages/base-contract/CHANGELOG.json b/packages/base-contract/CHANGELOG.json index 070f32d1d..d3cf76696 100644 --- a/packages/base-contract/CHANGELOG.json +++ b/packages/base-contract/CHANGELOG.json @@ -1,5 +1,23 @@ [ { + "version": "4.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ], + "timestamp": 1549547375 + }, + { + "timestamp": 1549452781, + "version": "4.0.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "version": "4.0.0", "changes": [ { diff --git a/packages/base-contract/CHANGELOG.md b/packages/base-contract/CHANGELOG.md index f6d3ec615..68de790bc 100644 --- a/packages/base-contract/CHANGELOG.md +++ b/packages/base-contract/CHANGELOG.md @@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v4.0.2 - _February 7, 2019_ + + * Dependencies updated + +## v4.0.1 - _February 6, 2019_ + + * Dependencies updated + ## v4.0.0 - _February 5, 2019_ * Upgrade the bignumber.js to v8.0.2 (#1517) diff --git a/packages/base-contract/package.json b/packages/base-contract/package.json index 1dbc6a854..d9970b7f4 100644 --- a/packages/base-contract/package.json +++ b/packages/base-contract/package.json @@ -1,6 +1,6 @@ { "name": "@0x/base-contract", - "version": "4.0.0", + "version": "4.0.2", "engines": { "node": ">=6.12" }, @@ -41,8 +41,8 @@ }, "dependencies": { "@0x/typescript-typings": "^4.0.0", - "@0x/utils": "^4.0.1", - "@0x/web3-wrapper": "^4.0.0", + "@0x/utils": "^4.0.3", + "@0x/web3-wrapper": "^4.0.2", "ethereum-types": "^2.0.0", "ethers": "~4.0.4", "lodash": "^4.17.11" diff --git a/packages/connect/CHANGELOG.json b/packages/connect/CHANGELOG.json index 45a1b80f8..d7e557146 100644 --- a/packages/connect/CHANGELOG.json +++ b/packages/connect/CHANGELOG.json @@ -1,5 +1,32 @@ [ { + "version": "4.0.3", + "changes": [ + { + "note": "Dependencies updated" + } + ], + "timestamp": 1549547375 + }, + { + "timestamp": 1549504360, + "version": "4.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1549452781, + "version": "4.0.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "version": "4.0.0", "changes": [ { diff --git a/packages/connect/CHANGELOG.md b/packages/connect/CHANGELOG.md index d0172b951..3094d2251 100644 --- a/packages/connect/CHANGELOG.md +++ b/packages/connect/CHANGELOG.md @@ -5,6 +5,18 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v4.0.3 - _February 7, 2019_ + + * Dependencies updated + +## v4.0.2 - _February 7, 2019_ + + * Dependencies updated + +## v4.0.1 - _February 6, 2019_ + + * Dependencies updated + ## v4.0.0 - _February 5, 2019_ * Upgrade the bignumber.js to v8.0.2 (#1517) diff --git a/packages/connect/package.json b/packages/connect/package.json index b0e1fd3b2..a9648594c 100644 --- a/packages/connect/package.json +++ b/packages/connect/package.json @@ -1,6 +1,6 @@ { "name": "@0x/connect", - "version": "4.0.0", + "version": "4.0.3", "engines": { "node": ">=6.12" }, @@ -44,12 +44,12 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/connect/README.md", "dependencies": { - "@0x/assert": "^2.0.0", - "@0x/json-schemas": "^3.0.0", - "@0x/order-utils": "^4.0.0", - "@0x/types": "^2.0.0", + "@0x/assert": "^2.0.2", + "@0x/json-schemas": "^3.0.2", + "@0x/order-utils": "^6.0.1", + "@0x/types": "^2.0.2", "@0x/typescript-typings": "^4.0.0", - "@0x/utils": "^4.0.1", + "@0x/utils": "^4.0.3", "lodash": "^4.17.11", "query-string": "^6.0.0", "sinon": "^4.0.0", diff --git a/packages/contract-wrappers/CHANGELOG.json b/packages/contract-wrappers/CHANGELOG.json index 413563f80..73c8e6070 100644 --- a/packages/contract-wrappers/CHANGELOG.json +++ b/packages/contract-wrappers/CHANGELOG.json @@ -1,13 +1,39 @@ [ { - "version": "6.0.1", + "version": "7.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ], + "timestamp": 1549547375 + }, + { + "timestamp": 1549504360, + "version": "7.0.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "version": "7.0.0", "changes": [ { "note": "Fix OrderValidatorWrapper constructor to use the correct address", "pr": 1568 + }, + { + "note": "Use new `ZeroExTransaction` interface", + "pr": 1576 + }, + { + "note": "Rename `getTransactionHex` to `getTransactionHashHex`", + "pr": 1576 } ], - "timestamp": 1549373905 + "timestamp": 1549452781 }, { "version": "6.0.0", diff --git a/packages/contract-wrappers/CHANGELOG.md b/packages/contract-wrappers/CHANGELOG.md index 03cb40fac..2e174e767 100644 --- a/packages/contract-wrappers/CHANGELOG.md +++ b/packages/contract-wrappers/CHANGELOG.md @@ -5,9 +5,19 @@ Edit the package's CHANGELOG.json file only. CHANGELOG -## v6.0.1 - _February 5, 2019_ +## v7.0.2 - _February 7, 2019_ + + * Dependencies updated + +## v7.0.1 - _February 7, 2019_ + + * Dependencies updated + +## v7.0.0 - _February 6, 2019_ * Fix OrderValidatorWrapper constructor to use the correct address (#1568) + * Use new `ZeroExTransaction` interface (#1576) + * Rename `getTransactionHex` to `getTransactionHashHex` (#1576) ## v6.0.0 - _Invalid date_ diff --git a/packages/contract-wrappers/package.json b/packages/contract-wrappers/package.json index 562eba81c..7ea270eb5 100644 --- a/packages/contract-wrappers/package.json +++ b/packages/contract-wrappers/package.json @@ -1,6 +1,6 @@ { "name": "@0x/contract-wrappers", - "version": "6.0.1", + "version": "7.0.2", "description": "Smart TS wrappers for 0x smart contracts", "keywords": [ "0xproject", @@ -37,9 +37,9 @@ "node": ">=6.0.0" }, "devDependencies": { - "@0x/dev-utils": "^2.0.0", - "@0x/migrations": "^3.0.0", - "@0x/subproviders": "^3.0.0", + "@0x/dev-utils": "^2.0.2", + "@0x/migrations": "^3.0.3", + "@0x/subproviders": "^3.0.2", "@0x/tslint-config": "^3.0.0", "@types/lodash": "4.14.104", "@types/mocha": "^2.2.42", @@ -65,18 +65,18 @@ "web3-provider-engine": "14.0.6" }, "dependencies": { - "@0x/abi-gen-wrappers": "^3.0.0", - "@0x/assert": "^2.0.0", + "@0x/abi-gen-wrappers": "^3.0.2", + "@0x/assert": "^2.0.2", "@0x/contract-addresses": "^2.2.1", "@0x/contract-artifacts": "^1.3.0", - "@0x/contracts-test-utils": "^3.0.0", - "@0x/fill-scenarios": "^2.0.0", - "@0x/json-schemas": "^3.0.0", - "@0x/order-utils": "^4.0.0", - "@0x/types": "^2.0.0", + "@0x/contracts-test-utils": "^3.0.3", + "@0x/fill-scenarios": "^2.0.3", + "@0x/json-schemas": "^3.0.2", + "@0x/order-utils": "^6.0.1", + "@0x/types": "^2.0.2", "@0x/typescript-typings": "^4.0.0", - "@0x/utils": "^4.0.1", - "@0x/web3-wrapper": "^4.0.0", + "@0x/utils": "^4.0.3", + "@0x/web3-wrapper": "^4.0.2", "ethereum-types": "^2.0.0", "ethereumjs-abi": "0.6.5", "ethereumjs-blockstream": "6.0.0", diff --git a/packages/contract-wrappers/src/utils/transaction_encoder.ts b/packages/contract-wrappers/src/utils/transaction_encoder.ts index 0cf08a8fe..307487a9b 100644 --- a/packages/contract-wrappers/src/utils/transaction_encoder.ts +++ b/packages/contract-wrappers/src/utils/transaction_encoder.ts @@ -1,9 +1,9 @@ import { ExchangeContract } from '@0x/abi-gen-wrappers'; import { schemas } from '@0x/json-schemas'; -import { eip712Utils } from '@0x/order-utils'; +import { transactionHashUtils } from '@0x/order-utils'; import { Order, SignedOrder } from '@0x/types'; -import { BigNumber, signTypedDataUtils } from '@0x/utils'; +import { BigNumber } from '@0x/utils'; import _ = require('lodash'); import { assert } from './assert'; @@ -19,23 +19,22 @@ export class TransactionEncoder { this._exchangeInstance = exchangeInstance; } /** - * Encodes the transaction data for use with the Exchange contract. + * Hashes the transaction data for use with the Exchange contract. * @param data The ABI Encoded 0x Exchange method. I.e fillOrder * @param salt A random value to provide uniqueness and prevent replay attacks. * @param signerAddress The address which will sign this transaction. - * @return An unsigned hex encoded transaction for use in 0x Exchange executeTransaction. + * @return The hash of the 0x transaction. */ - public getTransactionHex(data: string, salt: BigNumber, signerAddress: string): string { + public getTransactionHashHex(data: string, salt: BigNumber, signerAddress: string): string { const exchangeAddress = this._getExchangeContract().address; - const executeTransactionData = { + const transaction = { + verifyingContractAddress: exchangeAddress, salt, signerAddress, data, }; - const typedData = eip712Utils.createZeroExTransactionTypedData(executeTransactionData, exchangeAddress); - const eip712MessageBuffer = signTypedDataUtils.generateTypedDataHash(typedData); - const messageHex = `0x${eip712MessageBuffer.toString('hex')}`; - return messageHex; + const hashHex = transactionHashUtils.getTransactionHashHex(transaction); + return hashHex; } /** * Encodes a fillOrder transaction. diff --git a/packages/contract-wrappers/test/transaction_encoder_test.ts b/packages/contract-wrappers/test/transaction_encoder_test.ts index ef9eb2cf3..a996b9f08 100644 --- a/packages/contract-wrappers/test/transaction_encoder_test.ts +++ b/packages/contract-wrappers/test/transaction_encoder_test.ts @@ -83,8 +83,8 @@ describe('TransactionEncoder', () => { signerAddress: string = takerAddress, ): Promise<void> => { const salt = generatePseudoRandomSalt(); - const encodedTransaction = encoder.getTransactionHex(data, salt, signerAddress); - const signature = await signatureUtils.ecSignHashAsync(provider, encodedTransaction, signerAddress); + const transactionHash = encoder.getTransactionHashHex(data, salt, signerAddress); + const signature = await signatureUtils.ecSignHashAsync(provider, transactionHash, signerAddress); txHash = await contractWrappers.exchange.executeTransactionAsync( salt, signerAddress, diff --git a/packages/contracts-gen/.npmignore b/packages/contracts-gen/.npmignore new file mode 100644 index 000000000..d645458f6 --- /dev/null +++ b/packages/contracts-gen/.npmignore @@ -0,0 +1,6 @@ +.* +yarn-error.log +/src/ +/scripts/ +tsconfig.json +/lib/monorepo_scripts/ diff --git a/packages/contracts-gen/CHANGELOG.json b/packages/contracts-gen/CHANGELOG.json new file mode 100644 index 000000000..f1a523c30 --- /dev/null +++ b/packages/contracts-gen/CHANGELOG.json @@ -0,0 +1,11 @@ +[ + { + "version": "1.0.1", + "changes": [ + { + "note": "Dependencies updated" + } + ], + "timestamp": 1549547375 + } +] diff --git a/packages/contracts-gen/CHANGELOG.md b/packages/contracts-gen/CHANGELOG.md new file mode 100644 index 000000000..e046c6a0a --- /dev/null +++ b/packages/contracts-gen/CHANGELOG.md @@ -0,0 +1,10 @@ +<!-- +changelogUtils.file is auto-generated using the monorepo-scripts package. Don't edit directly. +Edit the package's CHANGELOG.json file only. +--> + +CHANGELOG + +## v1.0.1 - _February 7, 2019_ + + * Dependencies updated diff --git a/packages/contracts-gen/README.md b/packages/contracts-gen/README.md new file mode 100644 index 000000000..feaf9e65f --- /dev/null +++ b/packages/contracts-gen/README.md @@ -0,0 +1,76 @@ +# Contracts Gen + +This package allows you to generate boilerplate TypeScript code and configs for smart contracts packages. + +## Installation + +`yarn add -g @0x/contracts-gen` + +## Usage + +Run it from within your smart contracts packages. + +```bash +contracts-gen +``` + +You should run this tool after each time you move your contracts around to regenerate boilerplate code and configs. + +## What can it generate + +This tool does the following: + +- Reads your `compiler.json`. Specifically the list of smart contracts. +- Creates `wrapper.ts` file which exports all contract wrappers. +- Creates `artifacts.ts` file which exports all contract artifacts. +- Generates list of JSON artifact files in `tsconfig.json` +- Generates a glob for abi-gen in `package.json` + +On top of that - if your `compiler.json` has contracts referenced just by name - it will resolve the name to relative path and put it there. +It also sorts all the lists in it's output leading to smaller and cleaner diffs. + +## Contributing + +We welcome improvements and fixes from the wider community! To report bugs within this package, please create an issue in this repository. + +Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started. + +### Install dependencies + +If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them: + +```bash +yarn config set workspaces-experimental true +``` + +Then install dependencies + +```bash +yarn install +``` + +### Build + +To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory: + +```bash +PKG=@0x/contracts-gen yarn build +``` + +Or continuously rebuild on change: + +```bash +PKG=@0x/contracts-gen yarn watch +``` + +### Clean + +```bash +yarn clean +``` + +### Lint + +```bash +yarn lint +``` diff --git a/packages/contracts-gen/bin/contracts-gen.js b/packages/contracts-gen/bin/contracts-gen.js new file mode 100755 index 000000000..ec6ab4db6 --- /dev/null +++ b/packages/contracts-gen/bin/contracts-gen.js @@ -0,0 +1,2 @@ +#!/usr/bin/env node +require('../lib/src/contracts-gen.js'); diff --git a/packages/contracts-gen/package.json b/packages/contracts-gen/package.json new file mode 100644 index 000000000..fdf22ab45 --- /dev/null +++ b/packages/contracts-gen/package.json @@ -0,0 +1,49 @@ +{ + "name": "@0x/contracts-gen", + "version": "1.0.1", + "engines": { + "node": ">=6.12" + }, + "description": "Generates boilerplate code for smart contracts packages", + "main": "lib/src/index.js", + "types": "lib/src/index.d.ts", + "scripts": { + "lint": "tslint --format stylish --project .", + "clean": "shx rm -rf lib", + "build": "tsc -b", + "build:ci": "yarn build" + }, + "bin": { + "contracts-gen": "bin/contracts-gen.js" + }, + "repository": { + "type": "git", + "url": "https://github.com/0xProject/0x-monorepo.git" + }, + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/0xProject/0x-monorepo/issues" + }, + "homepage": "https://github.com/0xProject/0x-monorepo/packages/contracts-gen/README.md", + "dependencies": { + "@0x/sol-resolver": "^2.0.2", + "@0x/types": "^2.0.2", + "@0x/typescript-typings": "^4.0.0", + "@0x/utils": "^4.0.3", + "ethereum-types": "^2.0.0", + "lodash": "^4.17.11", + "prettier": "^1.16.3", + "to-snake-case": "^1.0.0" + }, + "devDependencies": { + "@0x/tslint-config": "^3.0.0", + "@types/node": "*", + "@types/prettier": "^1.15.2", + "shx": "^0.2.2", + "tslint": "5.11.0", + "typescript": "3.0.1" + }, + "publishConfig": { + "access": "public" + } +} diff --git a/packages/contracts-gen/src/contracts-gen.ts b/packages/contracts-gen/src/contracts-gen.ts new file mode 100644 index 000000000..0160a8204 --- /dev/null +++ b/packages/contracts-gen/src/contracts-gen.ts @@ -0,0 +1,175 @@ +#!/usr/bin/env node + +import { NameResolver } from '@0x/sol-resolver'; +import { PackageJSON } from '@0x/types'; +import { logUtils } from '@0x/utils'; +import { CompilerOptions } from 'ethereum-types'; +import * as fs from 'fs'; +import * as _ from 'lodash'; +import * as path from 'path'; +import * as prettier from 'prettier'; +import toSnakeCase = require('to-snake-case'); + +const SOLIDITY_EXTENSION = '.sol'; +const DEFAULT_ARTIFACTS_DIR = 'artifacts'; +const DEFAULT_CONTRACTS_DIR = 'contracts'; +const DEFAULT_WRAPPERS_DIR = 'generated-wrappers'; +const AUTO_GENERATED_BANNER = `/* +* ----------------------------------------------------------------------------- +* Warning: This file is auto-generated by contracts-gen. Don't edit manually. +* ----------------------------------------------------------------------------- +*/`; +const AUTO_GENERATED_BANNER_FOR_LISTS = `This list is auto-generated by contracts-gen. Don't edit manually.`; + +(async () => { + const packageDir = process.cwd(); + const compilerJSON = readJSONFile<CompilerOptions>('compiler.json'); + const contracts = compilerJSON.contracts; + const contractsDir = compilerJSON.contractsDir || DEFAULT_CONTRACTS_DIR; + const artifactsDir = compilerJSON.artifactsDir || DEFAULT_ARTIFACTS_DIR; + const wrappersDir = DEFAULT_WRAPPERS_DIR; + if (!_.isArray(contracts)) { + throw new Error('Unable to run the generator bacause contracts key in compiler.json is not of type array'); + } + const prettierConfig = await prettier.resolveConfig(packageDir); + generateCompilerJSONContractsList(contracts, contractsDir, prettierConfig); + generateArtifactsTs(contracts, artifactsDir, prettierConfig); + generateWrappersTs(contracts, wrappersDir, prettierConfig); + generateTsConfigJSONFilesList(contracts, artifactsDir, prettierConfig); + generatePackageJSONABIConfig(contracts, artifactsDir, prettierConfig); + process.exit(0); +})().catch(err => { + logUtils.log(err); + process.exit(1); +}); + +function generateCompilerJSONContractsList( + contracts: string[], + contractsDir: string, + prettierConfig: prettier.Options | null, +): void { + const COMPILER_JSON_FILE_PATH = 'compiler.json'; + const compilerJSON = readJSONFile<CompilerOptions>(COMPILER_JSON_FILE_PATH); + compilerJSON.contracts = _.map(contracts, contract => { + if (contract.endsWith(SOLIDITY_EXTENSION)) { + // If it's already a relative path - NO-OP. + return contract; + } else { + // If it's just a contract name - resolve it and rewrite. + return new NameResolver(contractsDir).resolve(contract).path; + } + }); + compilerJSON.contracts = _.sortBy(compilerJSON.contracts); + const compilerJSONString = JSON.stringify(compilerJSON); + const formattedCompilerJSON = prettier.format(compilerJSONString, { + ...prettierConfig, + filepath: COMPILER_JSON_FILE_PATH, + }); + fs.writeFileSync(COMPILER_JSON_FILE_PATH, formattedCompilerJSON); +} + +function generateArtifactsTs(contracts: string[], artifactsDir: string, prettierConfig: prettier.Options | null): void { + const imports = _.map(contracts, contract => { + const contractName = path.basename(contract, SOLIDITY_EXTENSION); + const importPath = path.join('..', artifactsDir, `${contractName}.json`); + return `import * as ${contractName} from '${importPath}';`; + }); + const sortedImports = _.sortBy(imports); + const artifacts = _.map(contracts, contract => { + const contractName = path.basename(contract, SOLIDITY_EXTENSION); + if (contractName === 'ZRXToken') { + // HACK(albrow): "as any" hack still required here because ZRXToken does not + // conform to the v2 artifact type. + return `${contractName}: (${contractName} as any) as ContractArtifact,`; + } else { + return `${contractName}: ${contractName} as ContractArtifact,`; + } + }); + const artifactsTs = ` + ${AUTO_GENERATED_BANNER} + import { ContractArtifact } from 'ethereum-types'; + + ${sortedImports.join('\n')} + export const artifacts = {${artifacts.join('\n')}}; + `; + const ARTIFACTS_TS_FILE_PATH = 'src/artifacts.ts'; + const formattedArtifactsTs = prettier.format(artifactsTs, { ...prettierConfig, filepath: ARTIFACTS_TS_FILE_PATH }); + fs.writeFileSync(ARTIFACTS_TS_FILE_PATH, formattedArtifactsTs); +} + +function generateWrappersTs(contracts: string[], wrappersDir: string, prettierConfig: prettier.Options | null): void { + const imports = _.map(contracts, contract => { + const contractName = path.basename(contract, SOLIDITY_EXTENSION); + const outputFileName = makeOutputFileName(contractName); + const exportPath = path.join('..', wrappersDir, outputFileName); + return `export * from '${exportPath}';`; + }); + const sortedImports = _.sortBy(imports); + const wrappersTs = ` + ${AUTO_GENERATED_BANNER} + ${sortedImports.join('\n')} + `; + const WRAPPERS_TS_FILE_PATH = 'src/wrappers.ts'; + const formattedArtifactsTs = prettier.format(wrappersTs, { ...prettierConfig, filepath: WRAPPERS_TS_FILE_PATH }); + fs.writeFileSync(WRAPPERS_TS_FILE_PATH, formattedArtifactsTs); +} + +function generateTsConfigJSONFilesList( + contracts: string[], + artifactsDir: string, + prettierConfig: prettier.Options | null, +): void { + const TS_CONFIG_FILE_PATH = 'tsconfig.json'; + const tsConfig = readJSONFile<any>(TS_CONFIG_FILE_PATH); + tsConfig.files = _.map(contracts, contract => { + const contractName = path.basename(contract, SOLIDITY_EXTENSION); + const artifactPath = path.join(artifactsDir, `${contractName}.json`); + return artifactPath; + }); + tsConfig.files = _.sortBy(tsConfig.files); + const tsConfigString = JSON.stringify(tsConfig); + const formattedTsConfig = prettier.format(tsConfigString, { ...prettierConfig, filepath: TS_CONFIG_FILE_PATH }); + fs.writeFileSync(TS_CONFIG_FILE_PATH, formattedTsConfig); +} + +function generatePackageJSONABIConfig( + contracts: string[], + artifactsDir: string, + prettierConfig: prettier.Options | null, +): void { + let packageJSON = readJSONFile<PackageJSON>('package.json'); + const contractNames = _.map(contracts, contract => { + const contractName = path.basename(contract, SOLIDITY_EXTENSION); + return contractName; + }); + const sortedContractNames = _.sortBy(contractNames); + packageJSON = { + ...packageJSON, + config: { + ...packageJSON.config, + 'abis:comment': AUTO_GENERATED_BANNER_FOR_LISTS, + abis: `${artifactsDir}/@(${sortedContractNames.join('|')}).json`, + }, + }; + const PACKAGE_JSON_FILE_PATH = 'package.json'; + const packageJSONString = JSON.stringify(packageJSON); + const formattedPackageJSON = prettier.format(packageJSONString, { + ...prettierConfig, + filepath: PACKAGE_JSON_FILE_PATH, + }); + fs.writeFileSync(PACKAGE_JSON_FILE_PATH, formattedPackageJSON); +} + +function makeOutputFileName(name: string): string { + let fileName = toSnakeCase(name); + // HACK: Snake case doesn't make a lot of sense for abbreviated names but we can't reliably detect abbreviations + // so we special-case the abbreviations we use. + fileName = fileName.replace('z_r_x', 'zrx').replace('e_r_c', 'erc'); + return fileName; +} + +function readJSONFile<T>(filePath: string): T { + const JSONString = fs.readFileSync(filePath, 'utf8'); + const parsed: T = JSON.parse(JSONString); + return parsed; +} diff --git a/packages/contracts-gen/src/index.ts b/packages/contracts-gen/src/index.ts new file mode 100644 index 000000000..c5f4b01f1 --- /dev/null +++ b/packages/contracts-gen/src/index.ts @@ -0,0 +1,6 @@ +/** + * This module is a CLI tool. As soon as you run it - it starts doing stuff. + * At the same time - our installation tests assume that you can import package without causing side effects. + * That's why our main entry point it empty. No side effects. But our secondary entry point - contracts-gen.ts is a CLI tool and starts running as soon as you import/run it. + */ +export {}; diff --git a/packages/contracts-gen/tsconfig.json b/packages/contracts-gen/tsconfig.json new file mode 100644 index 000000000..233008d61 --- /dev/null +++ b/packages/contracts-gen/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../tsconfig", + "compilerOptions": { + "outDir": "lib", + "rootDir": "." + }, + "include": ["./src/**/*"] +} diff --git a/packages/contracts-gen/tslint.json b/packages/contracts-gen/tslint.json new file mode 100644 index 000000000..dd9053357 --- /dev/null +++ b/packages/contracts-gen/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": ["@0x/tslint-config"] +} diff --git a/packages/dev-tools-pages/package.json b/packages/dev-tools-pages/package.json index 3a3345e82..80ff16a44 100644 --- a/packages/dev-tools-pages/package.json +++ b/packages/dev-tools-pages/package.json @@ -1,6 +1,6 @@ { "name": "@0x/dev-tools-pages", - "version": "0.0.15", + "version": "0.0.18", "engines": { "node": ">=6.12" }, @@ -26,7 +26,7 @@ }, "license": "Apache-2.0", "dependencies": { - "@0x/react-shared": "^2.0.0", + "@0x/react-shared": "^2.0.3", "basscss": "^8.0.3", "bowser": "^1.9.3", "highlight.js": "^9.13.1", diff --git a/packages/dev-utils/CHANGELOG.json b/packages/dev-utils/CHANGELOG.json index 141ac0eb6..ce6cfede5 100644 --- a/packages/dev-utils/CHANGELOG.json +++ b/packages/dev-utils/CHANGELOG.json @@ -1,5 +1,23 @@ [ { + "version": "2.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ], + "timestamp": 1549547375 + }, + { + "timestamp": 1549452781, + "version": "2.0.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "version": "2.0.0", "changes": [ { diff --git a/packages/dev-utils/CHANGELOG.md b/packages/dev-utils/CHANGELOG.md index a89a07a90..41e2ca88a 100644 --- a/packages/dev-utils/CHANGELOG.md +++ b/packages/dev-utils/CHANGELOG.md @@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v2.0.2 - _February 7, 2019_ + + * Dependencies updated + +## v2.0.1 - _February 6, 2019_ + + * Dependencies updated + ## v2.0.0 - _February 5, 2019_ * Upgrade the bignumber.js to v8.0.2 (#1517) diff --git a/packages/dev-utils/package.json b/packages/dev-utils/package.json index 41956765b..89298f4db 100644 --- a/packages/dev-utils/package.json +++ b/packages/dev-utils/package.json @@ -1,6 +1,6 @@ { "name": "@0x/dev-utils", - "version": "2.0.0", + "version": "2.0.2", "engines": { "node": ">=6.12" }, @@ -41,11 +41,11 @@ "typescript": "3.0.1" }, "dependencies": { - "@0x/subproviders": "^3.0.0", - "@0x/types": "^2.0.0", + "@0x/subproviders": "^3.0.2", + "@0x/types": "^2.0.2", "@0x/typescript-typings": "^4.0.0", - "@0x/utils": "^4.0.1", - "@0x/web3-wrapper": "^4.0.0", + "@0x/utils": "^4.0.3", + "@0x/web3-wrapper": "^4.0.2", "@types/web3-provider-engine": "^14.0.0", "chai": "^4.0.1", "ethereum-types": "^2.0.0", diff --git a/packages/fill-scenarios/CHANGELOG.json b/packages/fill-scenarios/CHANGELOG.json index 45ad00308..8615d137b 100644 --- a/packages/fill-scenarios/CHANGELOG.json +++ b/packages/fill-scenarios/CHANGELOG.json @@ -1,5 +1,32 @@ [ { + "version": "2.0.3", + "changes": [ + { + "note": "Dependencies updated" + } + ], + "timestamp": 1549547375 + }, + { + "timestamp": 1549504360, + "version": "2.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1549452781, + "version": "2.0.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "version": "2.0.0", "changes": [ { diff --git a/packages/fill-scenarios/CHANGELOG.md b/packages/fill-scenarios/CHANGELOG.md index d483661db..e87652e7d 100644 --- a/packages/fill-scenarios/CHANGELOG.md +++ b/packages/fill-scenarios/CHANGELOG.md @@ -5,6 +5,18 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v2.0.3 - _February 7, 2019_ + + * Dependencies updated + +## v2.0.2 - _February 7, 2019_ + + * Dependencies updated + +## v2.0.1 - _February 6, 2019_ + + * Dependencies updated + ## v2.0.0 - _February 5, 2019_ * Upgrade the bignumber.js to v8.0.2 (#1517) diff --git a/packages/fill-scenarios/package.json b/packages/fill-scenarios/package.json index 5bde3f23e..523bc07c1 100644 --- a/packages/fill-scenarios/package.json +++ b/packages/fill-scenarios/package.json @@ -1,6 +1,6 @@ { "name": "@0x/fill-scenarios", - "version": "2.0.0", + "version": "2.0.3", "description": "0x order fill scenario generator", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -28,14 +28,14 @@ "typescript": "3.0.1" }, "dependencies": { - "@0x/abi-gen-wrappers": "^3.0.0", - "@0x/base-contract": "^4.0.0", + "@0x/abi-gen-wrappers": "^3.0.2", + "@0x/base-contract": "^4.0.2", "@0x/contract-artifacts": "^1.3.0", - "@0x/order-utils": "^4.0.0", - "@0x/types": "^2.0.0", + "@0x/order-utils": "^6.0.1", + "@0x/types": "^2.0.2", "@0x/typescript-typings": "^4.0.0", - "@0x/utils": "^4.0.1", - "@0x/web3-wrapper": "^4.0.0", + "@0x/utils": "^4.0.3", + "@0x/web3-wrapper": "^4.0.2", "ethereum-types": "^2.0.0", "ethers": "~4.0.4", "lodash": "^4.17.11" diff --git a/packages/instant/package.json b/packages/instant/package.json index 3b7055595..0fe45e963 100644 --- a/packages/instant/package.json +++ b/packages/instant/package.json @@ -1,6 +1,6 @@ { "name": "@0x/instant", - "version": "1.0.9", + "version": "1.0.12", "engines": { "node": ">=6.12" }, @@ -42,15 +42,15 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/instant/README.md", "dependencies": { - "@0x/assert": "^2.0.0", - "@0x/asset-buyer": "^5.0.0", - "@0x/json-schemas": "^3.0.0", - "@0x/order-utils": "^4.0.0", - "@0x/subproviders": "^3.0.0", - "@0x/types": "^2.0.0", + "@0x/assert": "^2.0.2", + "@0x/asset-buyer": "^5.0.3", + "@0x/json-schemas": "^3.0.2", + "@0x/order-utils": "^6.0.1", + "@0x/subproviders": "^3.0.2", + "@0x/types": "^2.0.2", "@0x/typescript-typings": "^4.0.0", - "@0x/utils": "^4.0.1", - "@0x/web3-wrapper": "^4.0.0", + "@0x/utils": "^4.0.3", + "@0x/web3-wrapper": "^4.0.2", "babel-runtime": "^6.26.0", "bowser": "^1.9.4", "copy-to-clipboard": "^3.0.8", diff --git a/packages/json-schemas/CHANGELOG.json b/packages/json-schemas/CHANGELOG.json index 869f8bdf1..a6ae0160f 100644 --- a/packages/json-schemas/CHANGELOG.json +++ b/packages/json-schemas/CHANGELOG.json @@ -1,10 +1,32 @@ [ { + "version": "3.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ], + "timestamp": 1549547375 + }, + { + "timestamp": 1549452781, + "version": "3.0.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "version": "3.0.0", "changes": [ { "note": "Upgrade the bignumber.js to v8.0.2", "pr": 1517 + }, + { + "note": "Add `verifyingContractAddress` to `zeroExTransactionSchema`", + "pr": 1576 } ], "timestamp": 1549373905 diff --git a/packages/json-schemas/CHANGELOG.md b/packages/json-schemas/CHANGELOG.md index ea94cbaf4..91426a687 100644 --- a/packages/json-schemas/CHANGELOG.md +++ b/packages/json-schemas/CHANGELOG.md @@ -5,9 +5,18 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v3.0.2 - _February 7, 2019_ + + * Dependencies updated + +## v3.0.1 - _February 6, 2019_ + + * Dependencies updated + ## v3.0.0 - _February 5, 2019_ * Upgrade the bignumber.js to v8.0.2 (#1517) + * Add `verifyingContractAddress` to `zeroExTransactionSchema` (#1576) ## v2.1.7 - _January 15, 2019_ diff --git a/packages/json-schemas/package.json b/packages/json-schemas/package.json index a1966897f..0c101aa28 100644 --- a/packages/json-schemas/package.json +++ b/packages/json-schemas/package.json @@ -1,6 +1,6 @@ { "name": "@0x/json-schemas", - "version": "3.0.0", + "version": "3.0.2", "engines": { "node": ">=6.12" }, @@ -46,7 +46,7 @@ }, "devDependencies": { "@0x/tslint-config": "^3.0.0", - "@0x/utils": "^4.0.1", + "@0x/utils": "^4.0.3", "@types/lodash.foreach": "^4.5.3", "@types/lodash.values": "^4.3.3", "@types/mocha": "^2.2.42", diff --git a/packages/json-schemas/schemas/zero_ex_transaction_schema.json b/packages/json-schemas/schemas/zero_ex_transaction_schema.json index 0c714f14d..ffdf1f229 100644 --- a/packages/json-schemas/schemas/zero_ex_transaction_schema.json +++ b/packages/json-schemas/schemas/zero_ex_transaction_schema.json @@ -1,10 +1,11 @@ { "id": "/zeroExTransactionSchema", "properties": { + "verifyingContractAddress": { "$ref": "/addressSchema" }, "data": { "$ref": "/hexSchema" }, "signerAddress": { "$ref": "/addressSchema" }, "salt": { "$ref": "/wholeNumberSchema" } }, - "required": ["data", "salt", "signerAddress"], + "required": ["verifyingContractAddress", "data", "salt", "signerAddress"], "type": "object" } diff --git a/packages/metacoin/package.json b/packages/metacoin/package.json index 63b137df0..3afe8eb8c 100644 --- a/packages/metacoin/package.json +++ b/packages/metacoin/package.json @@ -1,6 +1,6 @@ { "name": "@0x/metacoin", - "version": "0.0.37", + "version": "0.0.39", "engines": { "node": ">=6.12" }, @@ -24,23 +24,24 @@ "profiler:report:html": "istanbul report html && open coverage/index.html", "coverage:report:lcov": "istanbul report lcov", "test:circleci": "yarn test:coverage", - "compile": "sol-compiler compile" + "compile": "sol-compiler", + "watch": "sol-compiler -w" }, "author": "", "license": "Apache-2.0", "dependencies": { - "@0x/abi-gen": "^2.0.0", + "@0x/abi-gen": "^2.0.2", "@0x/abi-gen-templates": "^2.0.0", - "@0x/base-contract": "^4.0.0", - "@0x/sol-coverage": "^2.0.0", - "@0x/sol-profiler": "^2.0.1", - "@0x/sol-trace": "^2.0.1", - "@0x/subproviders": "^3.0.0", + "@0x/base-contract": "^4.0.2", + "@0x/sol-coverage": "^2.0.2", + "@0x/sol-profiler": "^2.0.3", + "@0x/sol-trace": "^2.0.3", + "@0x/subproviders": "^3.0.2", "@0x/tslint-config": "^3.0.0", - "@0x/types": "^2.0.0", + "@0x/types": "^2.0.2", "@0x/typescript-typings": "^4.0.0", - "@0x/utils": "^4.0.1", - "@0x/web3-wrapper": "^4.0.0", + "@0x/utils": "^4.0.3", + "@0x/web3-wrapper": "^4.0.2", "@types/mocha": "^2.2.42", "copyfiles": "^2.0.0", "ethereum-types": "^2.0.0", @@ -49,8 +50,8 @@ "run-s": "^0.0.0" }, "devDependencies": { - "@0x/dev-utils": "^2.0.0", - "@0x/sol-compiler": "^3.0.0", + "@0x/dev-utils": "^2.0.2", + "@0x/sol-compiler": "^3.0.2", "chai": "^4.0.1", "chai-as-promised": "^7.1.0", "chai-bignumber": "^3.0.0", diff --git a/packages/migrations/CHANGELOG.json b/packages/migrations/CHANGELOG.json index f651e9434..9d7c22b7c 100644 --- a/packages/migrations/CHANGELOG.json +++ b/packages/migrations/CHANGELOG.json @@ -1,5 +1,32 @@ [ { + "version": "3.0.3", + "changes": [ + { + "note": "Dependencies updated" + } + ], + "timestamp": 1549547375 + }, + { + "timestamp": 1549504360, + "version": "3.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1549452781, + "version": "3.0.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "version": "3.0.0", "changes": [ { diff --git a/packages/migrations/CHANGELOG.md b/packages/migrations/CHANGELOG.md index 40add5c2c..b39732ef4 100644 --- a/packages/migrations/CHANGELOG.md +++ b/packages/migrations/CHANGELOG.md @@ -5,6 +5,18 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v3.0.3 - _February 7, 2019_ + + * Dependencies updated + +## v3.0.2 - _February 7, 2019_ + + * Dependencies updated + +## v3.0.1 - _February 6, 2019_ + + * Dependencies updated + ## v3.0.0 - _February 5, 2019_ * Upgrade the bignumber.js to v8.0.2 (#1517) diff --git a/packages/migrations/package.json b/packages/migrations/package.json index 6ad48b3a6..91476d322 100644 --- a/packages/migrations/package.json +++ b/packages/migrations/package.json @@ -1,6 +1,6 @@ { "name": "@0x/migrations", - "version": "3.0.0", + "version": "3.0.3", "engines": { "node": ">=6.12" }, @@ -35,9 +35,9 @@ }, "license": "Apache-2.0", "devDependencies": { - "@0x/dev-utils": "^2.0.0", + "@0x/dev-utils": "^2.0.2", "@0x/tslint-config": "^3.0.0", - "@0x/types": "^2.0.0", + "@0x/types": "^2.0.2", "@types/yargs": "^11.0.0", "make-promises-safe": "^1.1.0", "npm-run-all": "^4.1.2", @@ -48,16 +48,16 @@ "yargs": "^10.0.3" }, "dependencies": { - "@0x/abi-gen-wrappers": "^3.0.0", - "@0x/base-contract": "^4.0.0", + "@0x/abi-gen-wrappers": "^3.0.2", + "@0x/base-contract": "^4.0.2", "@0x/contract-addresses": "^2.2.1", "@0x/contract-artifacts": "^1.3.0", - "@0x/order-utils": "^4.0.0", - "@0x/sol-compiler": "^3.0.0", - "@0x/subproviders": "^3.0.0", + "@0x/order-utils": "^6.0.1", + "@0x/sol-compiler": "^3.0.2", + "@0x/subproviders": "^3.0.2", "@0x/typescript-typings": "^4.0.0", - "@0x/utils": "^4.0.1", - "@0x/web3-wrapper": "^4.0.0", + "@0x/utils": "^4.0.3", + "@0x/web3-wrapper": "^4.0.2", "@ledgerhq/hw-app-eth": "^4.3.0", "ethereum-types": "^2.0.0", "ethers": "~4.0.4", diff --git a/packages/monorepo-scripts/package.json b/packages/monorepo-scripts/package.json index dbe2d081c..3e9a972c2 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.20", + "version": "1.0.23", "engines": { "node": ">=6.12" }, @@ -47,7 +47,8 @@ "typescript": "3.0.1" }, "dependencies": { - "@0x/utils": "^4.0.1", + "@0x/types": "^2.0.2", + "@0x/utils": "^4.0.3", "@lerna/batch-packages": "^3.0.0-beta.18", "@types/depcheck": "^0.6.0", "async-child-process": "^1.1.1", diff --git a/packages/monorepo-scripts/src/deps_versions.ts b/packages/monorepo-scripts/src/deps_versions.ts index 0d01a2e3c..bb7e50f51 100644 --- a/packages/monorepo-scripts/src/deps_versions.ts +++ b/packages/monorepo-scripts/src/deps_versions.ts @@ -1,7 +1,7 @@ #!/usr/bin/env node +import { PackageJSON, PackageJSONConfig } from '@0x/types'; import chalk from 'chalk'; -import * as fs from 'fs'; import { sync as globSync } from 'glob'; import * as path from 'path'; @@ -24,9 +24,10 @@ interface ParsedDependencies { const PACKAGE_JSON_GLOB = '../../*/package.json'; -const config = JSON.parse(fs.readFileSync(path.join(__dirname, '../../../package.json')).toString()).config; -const dependenciesWithIgnoredVersions: string[] = config.ignoreDependencyVersions.split(' '); -const packagesWithIgnoredVersions: string[] = config.ignoreDependencyVersionsForPackage.split(' '); +const config = utils.readJSONFile<PackageJSON>(path.join(__dirname, '../../../package.json')) + .config as PackageJSONConfig; // tslint:disable-line no-unnecessary-type-assertion +const dependenciesWithIgnoredVersions: string[] = (config.ignoreDependencyVersions as string).split(' '); +const packagesWithIgnoredVersions: string[] = (config.ignoreDependencyVersionsForPackage as string).split(' '); if (require.main === module) { const dependencies = parseDependencies(); @@ -44,11 +45,10 @@ if (require.main === module) { } function getDependencies(_path: string): Dependencies { - const file = fs.readFileSync(_path).toString(); - const parsed = JSON.parse(file); + const packageJSON = utils.readJSONFile<PackageJSON>(_path); const dependencies = { - ...parsed.dependencies, - ...parsed.devDependencies, + ...packageJSON.dependencies, + ...packageJSON.devDependencies, }; return dependencies; } diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts index 105d87dcd..ddb2811f2 100644 --- a/packages/monorepo-scripts/src/publish.ts +++ b/packages/monorepo-scripts/src/publish.ts @@ -1,8 +1,8 @@ #!/usr/bin/env node +import { PackageJSON } from '@0x/types'; import { logUtils } from '@0x/utils'; import * as promisify from 'es6-promisify'; -import * as fs from 'fs'; import * as _ from 'lodash'; import * as moment from 'moment'; import opn = require('opn'); @@ -141,8 +141,8 @@ async function publishImagesToDockerHubAsync(allUpdatedPackages: Package[]): Pro function getPackagesWithDocs(allUpdatedPackages: Package[]): Package[] { const rootPackageJsonPath = `${constants.monorepoRootPath}/package.json`; - const rootPackageJson = JSON.parse(fs.readFileSync(rootPackageJsonPath).toString()); - const packagesWithDocPagesStringIfExist = _.get(rootPackageJson, 'config.packagesWithDocPages', undefined); + const rootPackageJSON = utils.readJSONFile<PackageJSON>(rootPackageJsonPath); + const packagesWithDocPagesStringIfExist = _.get(rootPackageJSON, 'config.packagesWithDocPages', undefined); if (_.isUndefined(packagesWithDocPagesStringIfExist)) { return []; // None to generate & publish } diff --git a/packages/monorepo-scripts/src/test_installation.ts b/packages/monorepo-scripts/src/test_installation.ts index 822f48967..ec145cd32 100644 --- a/packages/monorepo-scripts/src/test_installation.ts +++ b/packages/monorepo-scripts/src/test_installation.ts @@ -8,7 +8,7 @@ import { exec as execAsync } from 'promisify-child-process'; import * as rimraf from 'rimraf'; import { promisify } from 'util'; -import { Package } from './types'; +import { Changelog, Package } from './types'; import { utils } from './utils/utils'; // Packages might not be runnable if they are command-line tools or only run in browsers. @@ -100,7 +100,7 @@ async function testInstallPackageAsync( installablePackage: Package, ): Promise<void> { const changelogPath = path.join(installablePackage.location, 'CHANGELOG.json'); - const lastChangelogVersion = JSON.parse(fs.readFileSync(changelogPath).toString())[0].version; + const lastChangelogVersion = utils.readJSONFile<Changelog>(changelogPath)[0].version; const packageName = installablePackage.packageJson.name; utils.log(`Testing ${packageName}@${lastChangelogVersion}`); const packageDirName = path.join(...`${packageName}-test`.split('/')); diff --git a/packages/monorepo-scripts/src/types.ts b/packages/monorepo-scripts/src/types.ts index 4af4fd257..e285d9082 100644 --- a/packages/monorepo-scripts/src/types.ts +++ b/packages/monorepo-scripts/src/types.ts @@ -1,3 +1,5 @@ +import { PackageJSON } from '@0x/types'; + export interface UpdatedPackage { name: string; version: string; @@ -34,21 +36,6 @@ export interface GitTagsByPackageName { [packageName: string]: string[]; } -export interface PackageJSON { - private?: boolean; - version: string; - name: string; - main?: string; - scripts?: { [command: string]: string }; - config?: { - postpublish?: { - assets?: string[]; - docOmitExports?: string[]; - dockerHubRepo?: string; - }; - }; -} - export interface Package { location: string; packageJson: PackageJSON; diff --git a/packages/monorepo-scripts/src/utils/doc_generate_and_upload_utils.ts b/packages/monorepo-scripts/src/utils/doc_generate_and_upload_utils.ts index 1a4294e9c..c0e86ad44 100644 --- a/packages/monorepo-scripts/src/utils/doc_generate_and_upload_utils.ts +++ b/packages/monorepo-scripts/src/utils/doc_generate_and_upload_utils.ts @@ -1,3 +1,4 @@ +import { PackageJSON } from '@0x/types'; import { existsSync, readFileSync, writeFileSync } from 'fs'; import * as _ from 'lodash'; import * as path from 'path'; @@ -6,7 +7,7 @@ import * as ts from 'typescript'; import { constants } from '../constants'; import { docGenConfigs } from '../doc_gen_configs'; -import { ExportInfo, ExportNameToTypedocNames, ExportPathToExportedItems, PackageJSON } from '../types'; +import { ExportInfo, ExportNameToTypedocNames, ExportPathToExportedItems } from '../types'; import { utils } from './utils'; diff --git a/packages/monorepo-scripts/src/utils/utils.ts b/packages/monorepo-scripts/src/utils/utils.ts index 28c5658f3..20a6932c3 100644 --- a/packages/monorepo-scripts/src/utils/utils.ts +++ b/packages/monorepo-scripts/src/utils/utils.ts @@ -1,3 +1,4 @@ +import { PackageJSON } from '@0x/types'; import batchPackages = require('@lerna/batch-packages'); import * as fs from 'fs'; import * as _ from 'lodash'; @@ -5,7 +6,7 @@ import { exec as execAsync } from 'promisify-child-process'; import semver = require('semver'); import { constants } from '../constants'; -import { GitTagsByPackageName, Package, PackageJSON, UpdatedPackage } from '../types'; +import { GitTagsByPackageName, Package, UpdatedPackage } from '../types'; import { changelogUtils } from './changelog_utils'; @@ -13,6 +14,11 @@ export const utils = { log(...args: any[]): void { console.log(...args); // tslint:disable-line:no-console }, + readJSONFile<T>(path: string): T { + const JSONString = fs.readFileSync(path, 'utf8'); + const parsed: T = JSON.parse(JSONString); + return parsed; + }, getTopologicallySortedPackages(rootDir: string): Package[] { const packages = utils.getPackages(rootDir); const batchedPackages: PackageJSON[] = _.flatten(batchPackages(_.map(packages, pkg => pkg.packageJson), false)); @@ -23,8 +29,7 @@ export const utils = { return topsortedPackages; }, getPackages(rootDir: string): Package[] { - const rootPackageJsonString = fs.readFileSync(`${rootDir}/package.json`, 'utf8'); - const rootPackageJson = JSON.parse(rootPackageJsonString); + const rootPackageJson = utils.readJSONFile<PackageJSON>(`${rootDir}/package.json`); if (_.isUndefined(rootPackageJson.workspaces)) { throw new Error(`Did not find 'workspaces' key in root package.json`); } @@ -40,8 +45,7 @@ export const utils = { } const pathToPackageJson = `${rootDir}/${workspacePath}${subpackageName}`; try { - const packageJsonString = fs.readFileSync(`${pathToPackageJson}/package.json`, 'utf8'); - const packageJson = JSON.parse(packageJsonString); + const packageJson = utils.readJSONFile<PackageJSON>(`${pathToPackageJson}/package.json`); const pkg = { location: pathToPackageJson, packageJson, diff --git a/packages/order-utils/CHANGELOG.json b/packages/order-utils/CHANGELOG.json index 5169208c9..0028ea0c7 100644 --- a/packages/order-utils/CHANGELOG.json +++ b/packages/order-utils/CHANGELOG.json @@ -1,5 +1,39 @@ [ { + "version": "6.0.1", + "changes": [ + { + "note": "Dependencies updated" + } + ], + "timestamp": 1549547375 + }, + { + "version": "6.0.0", + "changes": { + "note": "Stop exporting the EIP712 schemas" + }, + "timestamp": 1549504360 + }, + { + "version": "5.0.0", + "changes": [ + { + "note": "Add `transactionHashUtils`", + "pr": 1576 + }, + { + "note": "Refactor `eip712Utils` to allow custom domain params", + "pr": 1576 + }, + { + "note": "Export constant EIP712 params", + "pr": 1576 + } + ], + "timestamp": 1549452781 + }, + { "version": "4.0.0", "changes": [ { diff --git a/packages/order-utils/CHANGELOG.md b/packages/order-utils/CHANGELOG.md index dd5a7c58f..06e6a2839 100644 --- a/packages/order-utils/CHANGELOG.md +++ b/packages/order-utils/CHANGELOG.md @@ -5,9 +5,24 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v6.0.1 - _February 7, 2019_ + + * Dependencies updated + +## v6.0.0 - _February 7, 2019_ + + * undefined + +## v5.0.0 - _February 6, 2019_ + + * Add `transactionHashUtils` (#1576) + * Refactor `eip712Utils` to allow custom domain params (#1576) + * Export constant EIP712 params (#1576) + ## v4.0.0 - _February 5, 2019_ * Upgrade the bignumber.js to v8.0.2 (#1517) + * Fix preSigned `isSignatureValidAsync` check (#1580) ## v3.1.2 - _January 15, 2019_ diff --git a/packages/order-utils/package.json b/packages/order-utils/package.json index 8645581ab..e2d0bcc98 100644 --- a/packages/order-utils/package.json +++ b/packages/order-utils/package.json @@ -1,6 +1,6 @@ { "name": "@0x/order-utils", - "version": "4.0.0", + "version": "6.0.1", "engines": { "node": ">=6.12" }, @@ -35,7 +35,7 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/order-utils/README.md", "devDependencies": { - "@0x/dev-utils": "^2.0.0", + "@0x/dev-utils": "^2.0.2", "@0x/tslint-config": "^3.0.0", "@types/bn.js": "^4.11.0", "@types/lodash": "4.14.104", @@ -53,16 +53,16 @@ "typescript": "3.0.1" }, "dependencies": { - "@0x/abi-gen-wrappers": "^3.0.0", - "@0x/assert": "^2.0.0", - "@0x/base-contract": "^4.0.0", - "@0x/contract-artifacts": "^1.3.0", + "@0x/abi-gen-wrappers": "^3.0.2", + "@0x/assert": "^2.0.2", + "@0x/base-contract": "^4.0.2", "@0x/contract-addresses": "^2.2.1", - "@0x/json-schemas": "^3.0.0", - "@0x/types": "^2.0.0", + "@0x/contract-artifacts": "^1.3.0", + "@0x/json-schemas": "^3.0.2", + "@0x/types": "^2.0.2", "@0x/typescript-typings": "^4.0.0", - "@0x/utils": "^4.0.1", - "@0x/web3-wrapper": "^4.0.0", + "@0x/utils": "^4.0.3", + "@0x/web3-wrapper": "^4.0.2", "@types/node": "*", "bn.js": "^4.11.8", "ethereum-types": "^2.0.0", diff --git a/packages/order-utils/src/constants.ts b/packages/order-utils/src/constants.ts index a9a687719..3c93575b3 100644 --- a/packages/order-utils/src/constants.ts +++ b/packages/order-utils/src/constants.ts @@ -68,9 +68,9 @@ export const constants = { SELECTOR_CHAR_LENGTH_WITH_PREFIX: 10, INFINITE_TIMESTAMP_SEC: new BigNumber(2524604400), // Close to infinite ZERO_AMOUNT: new BigNumber(0), - EIP712_DOMAIN_NAME: '0x Protocol', - EIP712_DOMAIN_VERSION: '2', - EIP712_DOMAIN_SCHEMA: { + EXCHANGE_DOMAIN_NAME: '0x Protocol', + EXCHANGE_DOMAIN_VERSION: '2', + DEFAULT_DOMAIN_SCHEMA: { name: 'EIP712Domain', parameters: [ { name: 'name', type: 'string' }, @@ -78,7 +78,7 @@ export const constants = { { name: 'verifyingContract', type: 'address' }, ], }, - EIP712_ORDER_SCHEMA: { + EXCHANGE_ORDER_SCHEMA: { name: 'Order', parameters: [ { name: 'makerAddress', type: 'address' }, @@ -95,7 +95,7 @@ export const constants = { { name: 'takerAssetData', type: 'bytes' }, ], }, - EIP712_ZEROEX_TRANSACTION_SCHEMA: { + EXCHANGE_ZEROEX_TRANSACTION_SCHEMA: { name: 'ZeroExTransaction', parameters: [ { name: 'salt', type: 'uint256' }, diff --git a/packages/order-utils/src/eip712_utils.ts b/packages/order-utils/src/eip712_utils.ts index 385fda989..685fdc8c8 100644 --- a/packages/order-utils/src/eip712_utils.ts +++ b/packages/order-utils/src/eip712_utils.ts @@ -1,6 +1,13 @@ import { assert } from '@0x/assert'; import { schemas } from '@0x/json-schemas'; -import { EIP712Object, EIP712TypedData, EIP712Types, Order, ZeroExTransaction } from '@0x/types'; +import { + EIP712DomainWithDefaultSchema, + EIP712Object, + EIP712TypedData, + EIP712Types, + Order, + ZeroExTransaction, +} from '@0x/types'; import * as _ from 'lodash'; import { constants } from './constants'; @@ -11,26 +18,26 @@ export const eip712Utils = { * @param primaryType The primary type found in message * @param types The additional types for the data in message * @param message The contents of the message - * @param exchangeAddress The address of the exchange contract + * @param domain Domain containing a name (optional), version (optional), and verifying contract address * @return A typed data object */ createTypedData: ( primaryType: string, types: EIP712Types, message: EIP712Object, - exchangeAddress: string, + domain: EIP712DomainWithDefaultSchema, ): EIP712TypedData => { - assert.isETHAddressHex('exchangeAddress', exchangeAddress); + assert.isETHAddressHex('verifyingContractAddress', domain.verifyingContractAddress); assert.isString('primaryType', primaryType); const typedData = { types: { - EIP712Domain: constants.EIP712_DOMAIN_SCHEMA.parameters, + EIP712Domain: constants.DEFAULT_DOMAIN_SCHEMA.parameters, ...types, }, domain: { - name: constants.EIP712_DOMAIN_NAME, - version: constants.EIP712_DOMAIN_VERSION, - verifyingContract: exchangeAddress, + name: _.isUndefined(domain.name) ? constants.EXCHANGE_DOMAIN_NAME : domain.name, + version: _.isUndefined(domain.version) ? constants.EXCHANGE_DOMAIN_VERSION : domain.version, + verifyingContract: domain.verifyingContractAddress, }, message, primaryType, @@ -48,11 +55,14 @@ export const eip712Utils = { const normalizedOrder = _.mapValues(order, value => { return !_.isString(value) ? value.toString() : value; }); + const domain = { + verifyingContractAddress: order.exchangeAddress, + }; const typedData = eip712Utils.createTypedData( - constants.EIP712_ORDER_SCHEMA.name, - { Order: constants.EIP712_ORDER_SCHEMA.parameters }, + constants.EXCHANGE_ORDER_SCHEMA.name, + { Order: constants.EXCHANGE_ORDER_SCHEMA.parameters }, normalizedOrder, - order.exchangeAddress, + domain, ); return typedData; }, @@ -60,23 +70,22 @@ export const eip712Utils = { * Creates an ExecuteTransaction EIP712TypedData object for use with signTypedData and * 0x Exchange executeTransaction. * @param ZeroExTransaction the 0x transaction - * @param exchangeAddress The address of the exchange contract * @return A typed data object */ - createZeroExTransactionTypedData: ( - zeroExTransaction: ZeroExTransaction, - exchangeAddress: string, - ): EIP712TypedData => { - assert.isETHAddressHex('exchangeAddress', exchangeAddress); + createZeroExTransactionTypedData: (zeroExTransaction: ZeroExTransaction): EIP712TypedData => { + assert.isETHAddressHex('verifyingContractAddress', zeroExTransaction.verifyingContractAddress); assert.doesConformToSchema('zeroExTransaction', zeroExTransaction, schemas.zeroExTransactionSchema); const normalizedTransaction = _.mapValues(zeroExTransaction, value => { return !_.isString(value) ? value.toString() : value; }); + const domain = { + verifyingContractAddress: zeroExTransaction.verifyingContractAddress, + }; const typedData = eip712Utils.createTypedData( - constants.EIP712_ZEROEX_TRANSACTION_SCHEMA.name, - { ZeroExTransaction: constants.EIP712_ZEROEX_TRANSACTION_SCHEMA.parameters }, + constants.EXCHANGE_ZEROEX_TRANSACTION_SCHEMA.name, + { ZeroExTransaction: constants.EXCHANGE_ZEROEX_TRANSACTION_SCHEMA.parameters }, normalizedTransaction, - exchangeAddress, + domain, ); return typedData; }, diff --git a/packages/order-utils/src/index.ts b/packages/order-utils/src/index.ts index 2150a02e4..ff37d7088 100644 --- a/packages/order-utils/src/index.ts +++ b/packages/order-utils/src/index.ts @@ -3,6 +3,7 @@ export { signatureUtils } from './signature_utils'; export { generatePseudoRandomSalt } from './salt'; export { assetDataUtils } from './asset_data_utils'; export { marketUtils } from './market_utils'; +export { transactionHashUtils } from './transaction_hash'; export { rateUtils } from './rate_utils'; export { sortingUtils } from './sorting_utils'; export { orderParsingUtils } from './parsing_utils'; @@ -50,7 +51,9 @@ export { EIP712Types, EIP712Object, EIP712ObjectValue, + EIP712DomainWithDefaultSchema, ZeroExTransaction, + SignedZeroExTransaction, } from '@0x/types'; export { OrderError, diff --git a/packages/order-utils/src/order_hash.ts b/packages/order-utils/src/order_hash.ts index c8e9be71e..ce7e6d85f 100644 --- a/packages/order-utils/src/order_hash.ts +++ b/packages/order-utils/src/order_hash.ts @@ -4,6 +4,7 @@ import { signTypedDataUtils } from '@0x/utils'; import * as _ from 'lodash'; import { assert } from './assert'; +import { constants } from './constants'; import { eip712Utils } from './eip712_utils'; const INVALID_TAKER_FORMAT = 'instance.takerAddress is not of a type(s) string'; @@ -34,8 +35,9 @@ export const orderHashUtils = { assert.doesConformToSchema('order', order, schemas.orderSchema, [schemas.hexSchema]); } catch (error) { if (_.includes(error.message, INVALID_TAKER_FORMAT)) { - const errMsg = - 'Order taker must be of type string. If you want anyone to be able to fill an order - pass ZeroEx.NULL_ADDRESS'; + const errMsg = `Order taker must be of type string. If you want anyone to be able to fill an order - pass ${ + constants.NULL_ADDRESS + }`; throw new Error(errMsg); } throw error; @@ -51,6 +53,17 @@ export const orderHashUtils = { * @return A Buffer containing the resulting orderHash from hashing the supplied order */ getOrderHashBuffer(order: SignedOrder | Order): Buffer { + try { + assert.doesConformToSchema('order', order, schemas.orderSchema, [schemas.hexSchema]); + } catch (error) { + if (_.includes(error.message, INVALID_TAKER_FORMAT)) { + const errMsg = `Order taker must be of type string. If you want anyone to be able to fill an order - pass ${ + constants.NULL_ADDRESS + }`; + throw new Error(errMsg); + } + throw error; + } const typedData = eip712Utils.createOrderTypedData(order); const orderHashBuff = signTypedDataUtils.generateTypedDataHash(typedData); return orderHashBuff; diff --git a/packages/order-utils/src/transaction_hash.ts b/packages/order-utils/src/transaction_hash.ts new file mode 100644 index 000000000..2b2345af7 --- /dev/null +++ b/packages/order-utils/src/transaction_hash.ts @@ -0,0 +1,46 @@ +import { schemas, SchemaValidator } from '@0x/json-schemas'; +import { SignedZeroExTransaction, ZeroExTransaction } from '@0x/types'; +import { signTypedDataUtils } from '@0x/utils'; +import * as _ from 'lodash'; + +import { assert } from './assert'; +import { eip712Utils } from './eip712_utils'; + +export const transactionHashUtils = { + /** + * Checks if the supplied hex encoded 0x transaction hash is valid. + * Note: Valid means it has the expected format, not that a transaction with the transactionHash exists. + * Use this method when processing transactionHashes submitted as user input. + * @param transactionHash Hex encoded transactionHash. + * @return Whether the supplied transactionHash has the expected format. + */ + isValidTransactionHash(transactionHash: string): boolean { + // Since this method can be called to check if any arbitrary string conforms to an transactionHash's + // format, we only assert that we were indeed passed a string. + assert.isString('transactionHash', transactionHash); + const schemaValidator = new SchemaValidator(); + const isValid = schemaValidator.validate(transactionHash, schemas.orderHashSchema).valid; + return isValid; + }, + /** + * Computes the transactionHash for a supplied 0x transaction. + * @param transaction An object that conforms to the ZeroExTransaction or SignedZeroExTransaction interface definitions. + * @return Hex encoded string transactionHash from hashing the supplied order. + */ + getTransactionHashHex(transaction: ZeroExTransaction | SignedZeroExTransaction): string { + assert.doesConformToSchema('transaction', transaction, schemas.zeroExTransactionSchema, [schemas.hexSchema]); + const transactionHashBuff = transactionHashUtils.getTransactionHashBuffer(transaction); + const transactionHashHex = `0x${transactionHashBuff.toString('hex')}`; + return transactionHashHex; + }, + /** + * Computes the transactionHash for a supplied 0x transaction. + * @param transaction An object that conforms to the ZeroExTransaction or SignedZeroExTransaction interface definitions. + * @return A Buffer containing the resulting transactionHash from hashing the supplied 0x transaction. + */ + getTransactionHashBuffer(transaction: ZeroExTransaction | SignedZeroExTransaction): Buffer { + const typedData = eip712Utils.createZeroExTransactionTypedData(transaction); + const transactionHashBuff = signTypedDataUtils.generateTypedDataHash(typedData); + return transactionHashBuff; + }, +}; diff --git a/packages/order-utils/test/eip712_utils_test.ts b/packages/order-utils/test/eip712_utils_test.ts index a54e49958..c97bed144 100644 --- a/packages/order-utils/test/eip712_utils_test.ts +++ b/packages/order-utils/test/eip712_utils_test.ts @@ -12,33 +12,55 @@ const expect = chai.expect; describe('EIP712 Utils', () => { describe('createTypedData', () => { - it('adds in the EIP712DomainSeparator', () => { + it('adds in the EIP712DomainSeparator with default values', () => { const primaryType = 'Test'; const typedData = eip712Utils.createTypedData( primaryType, { Test: [{ name: 'testValue', type: 'uint256' }] }, { testValue: '1' }, - constants.NULL_ADDRESS, + { verifyingContractAddress: constants.NULL_ADDRESS }, ); expect(typedData.domain).to.not.be.undefined(); expect(typedData.types.EIP712Domain).to.not.be.undefined(); const domainObject = typedData.domain; - expect(domainObject.name).to.eq(constants.EIP712_DOMAIN_NAME); + expect(domainObject.name).to.eq(constants.EXCHANGE_DOMAIN_NAME); + expect(domainObject.version).to.eq(constants.EXCHANGE_DOMAIN_VERSION); + expect(domainObject.verifyingContract).to.eq(constants.NULL_ADDRESS); + expect(typedData.primaryType).to.eq(primaryType); + }); + it('adds in the EIP712DomainSeparator without default values', () => { + const primaryType = 'Test'; + const domainName = 'testDomain'; + const domainVersion = 'testVersion'; + const typedData = eip712Utils.createTypedData( + primaryType, + { Test: [{ name: 'testValue', type: 'uint256' }] }, + { testValue: '1' }, + { name: domainName, version: domainVersion, verifyingContractAddress: constants.NULL_ADDRESS }, + ); + expect(typedData.domain).to.not.be.undefined(); + expect(typedData.types.EIP712Domain).to.not.be.undefined(); + const domainObject = typedData.domain; + expect(domainObject.name).to.eq(domainName); + expect(domainObject.version).to.eq(domainVersion); + expect(domainObject.verifyingContract).to.eq(constants.NULL_ADDRESS); expect(typedData.primaryType).to.eq(primaryType); }); }); - describe('createTypedData', () => { + describe('createZeroExTransactionTypedData', () => { it('adds in the EIP712DomainSeparator', () => { - const typedData = eip712Utils.createZeroExTransactionTypedData( - { - salt: new BigNumber('0'), - data: constants.NULL_BYTES, - signerAddress: constants.NULL_ADDRESS, - }, - constants.NULL_ADDRESS, - ); - expect(typedData.primaryType).to.eq(constants.EIP712_ZEROEX_TRANSACTION_SCHEMA.name); + const typedData = eip712Utils.createZeroExTransactionTypedData({ + salt: new BigNumber('0'), + data: constants.NULL_BYTES, + signerAddress: constants.NULL_ADDRESS, + verifyingContractAddress: constants.NULL_ADDRESS, + }); + expect(typedData.primaryType).to.eq(constants.EXCHANGE_ZEROEX_TRANSACTION_SCHEMA.name); expect(typedData.types.EIP712Domain).to.not.be.undefined(); + const domainObject = typedData.domain; + expect(domainObject.name).to.eq(constants.EXCHANGE_DOMAIN_NAME); + expect(domainObject.version).to.eq(constants.EXCHANGE_DOMAIN_VERSION); + expect(domainObject.verifyingContract).to.eq(constants.NULL_ADDRESS); }); }); }); diff --git a/packages/order-utils/test/order_hash_test.ts b/packages/order-utils/test/order_hash_test.ts index 30fb15a37..514fc2709 100644 --- a/packages/order-utils/test/order_hash_test.ts +++ b/packages/order-utils/test/order_hash_test.ts @@ -54,8 +54,9 @@ describe('Order hashing', () => { ...order, takerAddress: (null as any) as string, }; - const expectedErrorMessage = - 'Order taker must be of type string. If you want anyone to be able to fill an order - pass ZeroEx.NULL_ADDRESS'; + const expectedErrorMessage = `Order taker must be of type string. If you want anyone to be able to fill an order - pass ${ + constants.NULL_ADDRESS + }`; expect(() => orderHashUtils.getOrderHashHex(orderWithInvalidtakerFormat)).to.throw(expectedErrorMessage); }); }); diff --git a/packages/order-utils/test/transaction_hash_test.ts b/packages/order-utils/test/transaction_hash_test.ts new file mode 100644 index 000000000..c7ca33a64 --- /dev/null +++ b/packages/order-utils/test/transaction_hash_test.ts @@ -0,0 +1,56 @@ +import { ZeroExTransaction } from '@0x/types'; +import { BigNumber } from '@0x/utils'; +import * as chai from 'chai'; +import 'mocha'; + +import { transactionHashUtils } from '../src'; + +import { constants } from '../src/constants'; + +import { chaiSetup } from './utils/chai_setup'; + +chaiSetup.configure(); +const expect = chai.expect; + +describe('0x transaction hashing', () => { + describe('#getTransactionHashHex', () => { + const expectedTransactionHash = '0x82c9bb2dcac4f868ec7a15c20ff6175cfc384c20ae6a872aa0342a840f108c2b'; + const fakeVerifyingContractAddress = '0x5e72914535f202659083db3a02c984188fa26e9f'; + const transaction: ZeroExTransaction = { + verifyingContractAddress: fakeVerifyingContractAddress, + signerAddress: constants.NULL_ADDRESS, + salt: new BigNumber(0), + data: constants.NULL_BYTES, + }; + it('calculates the transaction hash', async () => { + const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); + expect(transactionHash).to.be.equal(expectedTransactionHash); + }); + it('calculates the transaction hash if amounts are strings', async () => { + // It's common for developers using javascript to provide the amounts + // as strings. Since we eventually toString() the BigNumber + // before encoding we should result in the same orderHash in this scenario + // tslint:disable-next-line:no-unnecessary-type-assertion + const transactionHash = transactionHashUtils.getTransactionHashHex({ + ...transaction, + salt: '0', + } as any); + expect(transactionHash).to.be.equal(expectedTransactionHash); + }); + }); + describe('#isValidTransactionHash', () => { + it('returns false if the value is not a hex string', () => { + const isValid = transactionHashUtils.isValidTransactionHash('not a hex'); + expect(isValid).to.be.false(); + }); + it('returns false if the length is wrong', () => { + const isValid = transactionHashUtils.isValidTransactionHash('0xdeadbeef'); + expect(isValid).to.be.false(); + }); + it('returns true if order hash is correct', () => { + const orderHashLength = 65; + const isValid = transactionHashUtils.isValidTransactionHash(`0x${Array(orderHashLength).join('0')}`); + expect(isValid).to.be.true(); + }); + }); +}); diff --git a/packages/order-watcher/CHANGELOG.json b/packages/order-watcher/CHANGELOG.json index f6d9a6aad..69bcc8d03 100644 --- a/packages/order-watcher/CHANGELOG.json +++ b/packages/order-watcher/CHANGELOG.json @@ -1,5 +1,32 @@ [ { + "version": "3.0.3", + "changes": [ + { + "note": "Dependencies updated" + } + ], + "timestamp": 1549547375 + }, + { + "timestamp": 1549504360, + "version": "3.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1549452781, + "version": "3.0.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "version": "3.0.0", "changes": [ { diff --git a/packages/order-watcher/CHANGELOG.md b/packages/order-watcher/CHANGELOG.md index 55b344b6a..7a3ede421 100644 --- a/packages/order-watcher/CHANGELOG.md +++ b/packages/order-watcher/CHANGELOG.md @@ -5,6 +5,18 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v3.0.3 - _February 7, 2019_ + + * Dependencies updated + +## v3.0.2 - _February 7, 2019_ + + * Dependencies updated + +## v3.0.1 - _February 6, 2019_ + + * Dependencies updated + ## v3.0.0 - _February 5, 2019_ * Upgrade the bignumber.js to v8.0.2 (#1517) diff --git a/packages/order-watcher/package.json b/packages/order-watcher/package.json index 472b59bbd..209c9bdc5 100644 --- a/packages/order-watcher/package.json +++ b/packages/order-watcher/package.json @@ -1,6 +1,6 @@ { "name": "@0x/order-watcher", - "version": "3.0.0", + "version": "3.0.3", "description": "An order watcher daemon that watches for order validity", "keywords": [ "0x", @@ -38,9 +38,9 @@ "node": ">=6.0.0" }, "devDependencies": { - "@0x/dev-utils": "^2.0.0", - "@0x/migrations": "^3.0.0", - "@0x/subproviders": "^3.0.0", + "@0x/dev-utils": "^2.0.2", + "@0x/migrations": "^3.0.3", + "@0x/subproviders": "^3.0.2", "@0x/tslint-config": "^3.0.0", "@types/bintrees": "^1.0.2", "@types/lodash": "4.14.104", @@ -63,19 +63,19 @@ "typescript": "3.0.1" }, "dependencies": { - "@0x/abi-gen-wrappers": "^3.0.0", - "@0x/assert": "^2.0.0", - "@0x/base-contract": "^4.0.0", + "@0x/abi-gen-wrappers": "^3.0.2", + "@0x/assert": "^2.0.2", + "@0x/base-contract": "^4.0.2", "@0x/contract-addresses": "^2.2.1", "@0x/contract-artifacts": "^1.3.0", - "@0x/contract-wrappers": "^6.0.1", - "@0x/fill-scenarios": "^2.0.0", - "@0x/json-schemas": "^3.0.0", - "@0x/order-utils": "^4.0.0", - "@0x/types": "^2.0.0", + "@0x/contract-wrappers": "^7.0.2", + "@0x/fill-scenarios": "^2.0.3", + "@0x/json-schemas": "^3.0.2", + "@0x/order-utils": "^6.0.1", + "@0x/types": "^2.0.2", "@0x/typescript-typings": "^4.0.0", - "@0x/utils": "^4.0.1", - "@0x/web3-wrapper": "^4.0.0", + "@0x/utils": "^4.0.3", + "@0x/web3-wrapper": "^4.0.2", "bintrees": "^1.0.2", "ethereum-types": "^2.0.0", "ethereumjs-blockstream": "6.0.0", diff --git a/packages/pipeline/package.json b/packages/pipeline/package.json index e1292c0df..b2ad39a5f 100644 --- a/packages/pipeline/package.json +++ b/packages/pipeline/package.json @@ -1,6 +1,6 @@ { "name": "@0x/pipeline", - "version": "1.0.6", + "version": "1.0.9", "private": true, "description": "Data pipeline for offline analysis", "scripts": { @@ -39,16 +39,16 @@ "typescript": "3.0.1" }, "dependencies": { - "@0x/connect": "^4.0.0", + "@0x/connect": "^4.0.3", "@0x/contract-addresses": "^2.2.1", "@0x/contract-artifacts": "^1.3.0", - "@0x/contract-wrappers": "^6.0.1", - "@0x/dev-utils": "^2.0.0", - "@0x/order-utils": "^4.0.0", - "@0x/subproviders": "^3.0.0", - "@0x/types": "^2.0.0", - "@0x/utils": "^4.0.1", - "@0x/web3-wrapper": "^4.0.0", + "@0x/contract-wrappers": "^7.0.2", + "@0x/dev-utils": "^2.0.2", + "@0x/order-utils": "^6.0.1", + "@0x/subproviders": "^3.0.2", + "@0x/types": "^2.0.2", + "@0x/utils": "^4.0.3", + "@0x/web3-wrapper": "^4.0.2", "@types/dockerode": "^2.5.9", "@types/p-limit": "^2.0.0", "async-parallel": "^1.2.3", @@ -57,7 +57,7 @@ "dockerode": "^2.5.7", "ethereum-types": "^2.0.0", "pg": "^7.5.0", - "prettier": "^1.15.3", + "prettier": "^1.16.3", "ramda": "^0.25.0", "reflect-metadata": "^0.1.12", "sqlite3": "^4.0.2", diff --git a/packages/react-docs/CHANGELOG.json b/packages/react-docs/CHANGELOG.json index 91c60fa9a..82e162272 100644 --- a/packages/react-docs/CHANGELOG.json +++ b/packages/react-docs/CHANGELOG.json @@ -1,5 +1,32 @@ [ { + "version": "2.0.3", + "changes": [ + { + "note": "Dependencies updated" + } + ], + "timestamp": 1549547375 + }, + { + "timestamp": 1549504360, + "version": "2.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1549452781, + "version": "2.0.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "version": "2.0.0", "changes": [ { diff --git a/packages/react-docs/CHANGELOG.md b/packages/react-docs/CHANGELOG.md index 4867a663a..fa8f387c2 100644 --- a/packages/react-docs/CHANGELOG.md +++ b/packages/react-docs/CHANGELOG.md @@ -5,6 +5,18 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v2.0.3 - _February 7, 2019_ + + * Dependencies updated + +## v2.0.2 - _February 7, 2019_ + + * Dependencies updated + +## v2.0.1 - _February 6, 2019_ + + * Dependencies updated + ## v2.0.0 - _February 5, 2019_ * Upgrade the bignumber.js to v8.0.2 (#1517) diff --git a/packages/react-docs/package.json b/packages/react-docs/package.json index d9c354e25..5a91220e0 100644 --- a/packages/react-docs/package.json +++ b/packages/react-docs/package.json @@ -1,6 +1,6 @@ { "name": "@0x/react-docs", - "version": "2.0.0", + "version": "2.0.3", "engines": { "node": ">=6.12" }, @@ -24,7 +24,7 @@ "url": "https://github.com/0xProject/0x-monorepo.git" }, "devDependencies": { - "@0x/dev-utils": "^2.0.0", + "@0x/dev-utils": "^2.0.2", "@0x/tslint-config": "^3.0.0", "@types/compare-versions": "^3.0.0", "@types/styled-components": "4.0.0", @@ -34,9 +34,9 @@ "typescript": "3.0.1" }, "dependencies": { - "@0x/react-shared": "^2.0.0", - "@0x/types": "^2.0.0", - "@0x/utils": "^4.0.1", + "@0x/react-shared": "^2.0.3", + "@0x/types": "^2.0.2", + "@0x/utils": "^4.0.3", "@types/lodash": "4.14.104", "@types/material-ui": "^0.20.0", "@types/node": "*", diff --git a/packages/react-shared/CHANGELOG.json b/packages/react-shared/CHANGELOG.json index ce5182ca6..9a7284c2a 100644 --- a/packages/react-shared/CHANGELOG.json +++ b/packages/react-shared/CHANGELOG.json @@ -1,5 +1,32 @@ [ { + "version": "2.0.3", + "changes": [ + { + "note": "Dependencies updated" + } + ], + "timestamp": 1549547375 + }, + { + "timestamp": 1549504360, + "version": "2.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1549452781, + "version": "2.0.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "version": "2.0.0", "changes": [ { diff --git a/packages/react-shared/CHANGELOG.md b/packages/react-shared/CHANGELOG.md index a5a09a9e0..e1de4a765 100644 --- a/packages/react-shared/CHANGELOG.md +++ b/packages/react-shared/CHANGELOG.md @@ -5,6 +5,18 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v2.0.3 - _February 7, 2019_ + + * Dependencies updated + +## v2.0.2 - _February 7, 2019_ + + * Dependencies updated + +## v2.0.1 - _February 6, 2019_ + + * Dependencies updated + ## v2.0.0 - _February 5, 2019_ * Upgrade the bignumber.js to v8.0.2 (#1517) diff --git a/packages/react-shared/package.json b/packages/react-shared/package.json index 72d384382..d93eb1436 100644 --- a/packages/react-shared/package.json +++ b/packages/react-shared/package.json @@ -1,6 +1,6 @@ { "name": "@0x/react-shared", - "version": "2.0.0", + "version": "2.0.3", "engines": { "node": ">=6.12" }, @@ -25,7 +25,7 @@ "url": "https://github.com/0xProject/0x-monorepo.git" }, "devDependencies": { - "@0x/dev-utils": "^2.0.0", + "@0x/dev-utils": "^2.0.2", "@0x/tslint-config": "^3.0.0", "make-promises-safe": "^1.1.0", "shx": "^0.2.2", @@ -33,7 +33,7 @@ "typescript": "3.0.1" }, "dependencies": { - "@0x/types": "^2.0.0", + "@0x/types": "^2.0.2", "@material-ui/core": "^3.0.1", "@types/is-mobile": "0.3.0", "@types/lodash": "4.14.104", @@ -52,7 +52,7 @@ "material-ui": "^0.20.0", "react": "^16.5.2", "react-dom": "^16.5.2", - "react-highlight": "0xproject/react-highlight", + "react-highlight": "0xproject/react-highlight#react-peer-deps", "react-markdown": "^3.2.2", "react-router-dom": "^4.3.1", "react-scroll": "0xproject/react-scroll#pr-330-and-replace-state", diff --git a/packages/react-shared/src/components/markdown_paragraph_block.tsx b/packages/react-shared/src/components/markdown_paragraph_block.tsx index eeaef8571..9ed44ed07 100644 --- a/packages/react-shared/src/components/markdown_paragraph_block.tsx +++ b/packages/react-shared/src/components/markdown_paragraph_block.tsx @@ -6,5 +6,9 @@ import { colors } from '../utils/colors'; export interface MarkdownParagraphBlockProps {} export const MarkdownParagraphBlock: React.StatelessComponent<MarkdownParagraphBlockProps> = ({ children }) => { - return <span style={{ color: colors.greyTheme, lineHeight: '26px' }}>{children}</span>; + return ( + <span style={{ color: colors.greyTheme, lineHeight: '26px', display: 'block', paddingBottom: 15 }}> + {children} + </span> + ); }; diff --git a/packages/sol-compiler/CHANGELOG.json b/packages/sol-compiler/CHANGELOG.json index 021804ffa..ed9c45245 100644 --- a/packages/sol-compiler/CHANGELOG.json +++ b/packages/sol-compiler/CHANGELOG.json @@ -1,5 +1,36 @@ [ { + "version": "3.0.2", + "changes": [ + { + "note": "Fix a bug when smart recompilation wasn't working because of remappings", + "pr": 1575 + }, + { + "note": "Fix a bug that made `opts` required instead of optional", + "pr": 1596 + }, + { + "note": "Remove `bin_paths` and fetch the list of Solidity compilers from Github", + "pr": 1596 + }, + { + "note": "Fix a bug causing `ast` and `legacyAST` to not be added to the artifacts even when requested", + "pr": 1596 + } + ], + "timestamp": 1549547375 + }, + { + "timestamp": 1549452781, + "version": "3.0.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "version": "3.0.0", "changes": [ { diff --git a/packages/sol-compiler/CHANGELOG.md b/packages/sol-compiler/CHANGELOG.md index 03a2b5b87..016509028 100644 --- a/packages/sol-compiler/CHANGELOG.md +++ b/packages/sol-compiler/CHANGELOG.md @@ -5,6 +5,17 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v3.0.2 - _February 7, 2019_ + + * Fix a bug when smart recompilation wasn't working because of remappings (#1575) + * Fix a bug that made `opts` required instead of optional (#1596) + * Remove `bin_paths` and fetch the list of Solidity compilers from Github (#1596) + * Fix a bug causing `ast` and `legacyAST` to not be added to the artifacts even when requested (#1596) + +## v3.0.1 - _February 6, 2019_ + + * Dependencies updated + ## v3.0.0 - _February 5, 2019_ * Upgrade the bignumber.js to v8.0.2 (#1517) diff --git a/packages/sol-compiler/package.json b/packages/sol-compiler/package.json index c16c6eb4a..3344c0b38 100644 --- a/packages/sol-compiler/package.json +++ b/packages/sol-compiler/package.json @@ -1,6 +1,6 @@ { "name": "@0x/sol-compiler", - "version": "3.0.0", + "version": "3.0.2", "engines": { "node": ">=6.12" }, @@ -42,7 +42,7 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/sol-compiler/README.md", "devDependencies": { - "@0x/dev-utils": "^2.0.0", + "@0x/dev-utils": "^2.0.2", "@0x/tslint-config": "^3.0.0", "@types/chokidar": "^1.7.5", "@types/mkdirp": "^0.5.2", @@ -67,13 +67,13 @@ "zeppelin-solidity": "1.8.0" }, "dependencies": { - "@0x/assert": "^2.0.0", - "@0x/json-schemas": "^3.0.0", - "@0x/sol-resolver": "^2.0.0", - "@0x/types": "^2.0.0", + "@0x/assert": "^2.0.2", + "@0x/json-schemas": "^3.0.2", + "@0x/sol-resolver": "^2.0.2", + "@0x/types": "^2.0.2", "@0x/typescript-typings": "^4.0.0", - "@0x/utils": "^4.0.1", - "@0x/web3-wrapper": "^4.0.0", + "@0x/utils": "^4.0.3", + "@0x/web3-wrapper": "^4.0.2", "@types/yargs": "^11.0.0", "chalk": "^2.3.0", "chokidar": "^2.0.4", diff --git a/packages/sol-compiler/src/compiler.ts b/packages/sol-compiler/src/compiler.ts index efee3eb8a..afa4cc5bb 100644 --- a/packages/sol-compiler/src/compiler.ts +++ b/packages/sol-compiler/src/compiler.ts @@ -21,7 +21,6 @@ import * as semver from 'semver'; import solc = require('solc'); import { compilerOptionsSchema } from './schemas/compiler_options_schema'; -import { binPaths } from './solc/bin_paths'; import { addHexPrefixToContractBytecode, compileDockerAsync, @@ -29,6 +28,7 @@ import { createDirIfDoesNotExistAsync, getContractArtifactIfExistsAsync, getDependencyNameToPackagePath, + getSolcJSReleasesAsync, getSourcesWithDependencies, getSourceTreeHash, makeContractPathsRelative, @@ -96,12 +96,12 @@ export class Compiler { * @return An instance of the Compiler class. */ constructor(opts?: CompilerOptions) { - assert.doesConformToSchema('opts', opts, compilerOptionsSchema); + const passedOpts = opts || {}; + assert.doesConformToSchema('opts', passedOpts, compilerOptionsSchema); // TODO: Look for config file in parent directories if not found in current directory const config: CompilerOptions = fs.existsSync(CONFIG_FILE) ? JSON.parse(fs.readFileSync(CONFIG_FILE).toString()) : {}; - const passedOpts = opts || {}; assert.doesConformToSchema('compiler.json', config, compilerOptionsSchema); this._contractsDir = path.resolve(passedOpts.contractsDir || config.contractsDir || DEFAULT_CONTRACTS_DIR); this._solcVersionIfExists = passedOpts.solcVersion || config.solcVersion; @@ -195,9 +195,7 @@ export class Compiler { path.basename(contractSource.path, constants.SOLIDITY_FILE_EXTENSION), ); } else { - contractNamesToCompile = this._specifiedContracts.map(specifiedContract => - path.basename(specifiedContract, constants.SOLIDITY_FILE_EXTENSION), - ); + return this._specifiedContracts; } return contractNamesToCompile; } @@ -213,16 +211,14 @@ export class Compiler { // map contract paths to data about them for later verification and persistence const contractPathToData: ContractPathToData = {}; + const solcJSReleases = await getSolcJSReleasesAsync(); const resolvedContractSources = []; for (const contractName of contractNames) { const spyResolver = new SpyResolver(this._resolver); const contractSource = spyResolver.resolve(contractName); - const sourceTreeHashHex = getSourceTreeHash( - spyResolver, - path.join(this._contractsDir, contractSource.path), - ).toString('hex'); + const sourceTreeHashHex = getSourceTreeHash(spyResolver, contractSource.path).toString('hex'); const contractData = { - contractName, + contractName: path.basename(contractName, constants.SOLIDITY_FILE_EXTENSION), currentArtifactIfExists: await getContractArtifactIfExistsAsync(this._artifactsDir, contractName), sourceTreeHashHex: `0x${sourceTreeHashHex}`, }; @@ -231,7 +227,7 @@ export class Compiler { } contractPathToData[contractSource.path] = contractData; const solcVersion = _.isUndefined(this._solcVersionIfExists) - ? semver.maxSatisfying(_.keys(binPaths), parseSolidityVersionRange(contractSource.source)) + ? semver.maxSatisfying(_.keys(solcJSReleases), parseSolidityVersionRange(contractSource.source)) : this._solcVersionIfExists; const isFirstContractWithThisVersion = _.isUndefined(versionToInputs[solcVersion]); if (isFirstContractWithThisVersion) { @@ -277,7 +273,7 @@ export class Compiler { fullSolcVersion = versionCommandOutputParts[versionCommandOutputParts.length - 1].trim(); compilerOutput = await compileDockerAsync(solcVersion, input.standardInput); } else { - fullSolcVersion = binPaths[solcVersion]; + fullSolcVersion = solcJSReleases[solcVersion]; compilerOutput = await compileSolcJSAsync(solcVersion, input.standardInput); } if (!_.isUndefined(compilerOutput.errors)) { @@ -329,7 +325,10 @@ export class Compiler { } else { const currentArtifact = contractData.currentArtifactIfExists as ContractArtifact; const isUserOnLatestVersion = currentArtifact.schemaVersion === constants.LATEST_ARTIFACT_VERSION; - const didCompilerSettingsChange = !_.isEqual(currentArtifact.compiler.settings, this._compilerSettings); + const didCompilerSettingsChange = !_.isEqual( + _.omit(currentArtifact.compiler.settings, 'remappings'), + _.omit(this._compilerSettings, 'remappings'), + ); const didSourceChange = currentArtifact.sourceTreeHashHex !== contractData.sourceTreeHashHex; return !isUserOnLatestVersion || didCompilerSettingsChange || didSourceChange; } diff --git a/packages/sol-compiler/src/solc/bin_paths.ts b/packages/sol-compiler/src/solc/bin_paths.ts deleted file mode 100644 index b653c0926..000000000 --- a/packages/sol-compiler/src/solc/bin_paths.ts +++ /dev/null @@ -1,52 +0,0 @@ -export interface BinaryPaths { - [key: string]: string; -} - -export const binPaths: BinaryPaths = { - '0.5.2': 'soljson-v0.5.2+commit.1df8f40c.js', - '0.5.1': 'soljson-v0.5.1+commit.c8a2cb62.js', - '0.5.0': 'soljson-v0.5.0+commit.1d4f565a.js', - '0.4.25': 'soljson-v0.4.25+commit.59dbf8f1.js', - '0.4.24': 'soljson-v0.4.24+commit.e67f0147.js', - '0.4.23': 'soljson-v0.4.23+commit.124ca40d.js', - '0.4.22': 'soljson-v0.4.22+commit.4cb486ee.js', - '0.4.21': 'soljson-v0.4.21+commit.dfe3193c.js', - '0.4.20': 'soljson-v0.4.20+commit.3155dd80.js', - '0.4.19': 'soljson-v0.4.19+commit.c4cbbb05.js', - '0.4.18': 'soljson-v0.4.18+commit.9cf6e910.js', - '0.4.17': 'soljson-v0.4.17+commit.bdeb9e52.js', - '0.4.16': 'soljson-v0.4.16+commit.d7661dd9.js', - '0.4.15': 'soljson-v0.4.15+commit.bbb8e64f.js', - '0.4.14': 'soljson-v0.4.14+commit.c2215d46.js', - '0.4.13': 'soljson-v0.4.13+commit.fb4cb1a.js', - '0.4.12': 'soljson-v0.4.12+commit.194ff033.js', - '0.4.11': 'soljson-v0.4.11+commit.68ef5810.js', - '0.4.10': 'soljson-v0.4.10+commit.f0d539ae.js', - '0.4.9': 'soljson-v0.4.9+commit.364da425.js', - '0.4.8': 'soljson-v0.4.8+commit.60cc1668.js', - '0.4.7': 'soljson-v0.4.7+commit.822622cf.js', - '0.4.6': 'soljson-v0.4.6+commit.2dabbdf0.js', - '0.4.5': 'soljson-v0.4.5+commit.b318366e.js', - '0.4.4': 'soljson-v0.4.4+commit.4633f3de.js', - '0.4.3': 'soljson-v0.4.3+commit.2353da71.js', - '0.4.2': 'soljson-v0.4.2+commit.af6afb04.js', - '0.4.1': 'soljson-v0.4.1+commit.4fc6fc2c.js', - '0.4.0': 'soljson-v0.4.0+commit.acd334c9.js', - '0.3.6': 'soljson-v0.3.6+commit.3fc68da.js', - '0.3.5': 'soljson-v0.3.5+commit.5f97274.js', - '0.3.4': 'soljson-v0.3.4+commit.7dab890.js', - '0.3.3': 'soljson-v0.3.3+commit.4dc1cb1.js', - '0.3.2': 'soljson-v0.3.2+commit.81ae2a7.js', - '0.3.1': 'soljson-v0.3.1+commit.c492d9b.js', - '0.3.0': 'soljson-v0.3.0+commit.11d6736.js', - '0.2.2': 'soljson-v0.2.2+commit.ef92f56.js', - '0.2.1': 'soljson-v0.2.1+commit.91a6b35.js', - '0.2.0': 'soljson-v0.2.0+commit.4dc2445.js', - '0.1.7': 'soljson-v0.1.7+commit.b4e666c.js', - '0.1.6': 'soljson-v0.1.6+commit.d41f8b7.js', - '0.1.5': 'soljson-v0.1.5+commit.23865e3.js', - '0.1.4': 'soljson-v0.1.4+commit.5f6c3cd.js', - '0.1.3': 'soljson-v0.1.3+commit.28f561.js', - '0.1.2': 'soljson-v0.1.2+commit.d0d36e3.js', - '0.1.1': 'soljson-v0.1.1+commit.6ff4cd6.js', -}; diff --git a/packages/sol-compiler/src/utils/compiler.ts b/packages/sol-compiler/src/utils/compiler.ts index c75f76dac..28049e453 100644 --- a/packages/sol-compiler/src/utils/compiler.ts +++ b/packages/sol-compiler/src/utils/compiler.ts @@ -9,11 +9,9 @@ import * as path from 'path'; import * as requireFromString from 'require-from-string'; import * as solc from 'solc'; -import { binPaths } from '../solc/bin_paths'; - import { constants } from './constants'; import { fsWrapper } from './fs_wrapper'; -import { CompilationError } from './types'; +import { BinaryPaths, CompilationError } from './types'; /** * Gets contract data on network or returns if an artifact does not exist. @@ -26,7 +24,10 @@ export async function getContractArtifactIfExistsAsync( contractName: string, ): Promise<ContractArtifact | void> { let contractArtifact; - const currentArtifactPath = `${artifactsDir}/${contractName}.json`; + const currentArtifactPath = `${artifactsDir}/${path.basename( + contractName, + constants.SOLIDITY_FILE_EXTENSION, + )}.json`; try { const opts = { encoding: 'utf8', @@ -116,6 +117,20 @@ export function parseDependencies(contractSource: ContractSource): string[] { return dependencies; } +let solcJSReleasesCache: BinaryPaths | undefined; + +/** + * Fetches the list of available solidity compilers + */ +export async function getSolcJSReleasesAsync(): Promise<BinaryPaths> { + if (_.isUndefined(solcJSReleasesCache)) { + const versionList = await fetch('https://ethereum.github.io/solc-bin/bin/list.json'); + const versionListJSON = await versionList.json(); + solcJSReleasesCache = versionListJSON.releases; + } + return solcJSReleasesCache as BinaryPaths; +} + /** * Compiles the contracts and prints errors/warnings * @param solcVersion Version of a solc compiler @@ -236,7 +251,7 @@ export function getSourcesWithDependencies( contractPath: string, fullSources: { [sourceName: string]: { id: number } }, ): { sourceCodes: { [sourceName: string]: string }; sources: { [sourceName: string]: { id: number } } } { - const sources = { [contractPath]: { id: fullSources[contractPath].id } }; + const sources = { [contractPath]: fullSources[contractPath] }; const sourceCodes = { [contractPath]: resolver.resolve(contractPath).source }; recursivelyGatherDependencySources( resolver, @@ -316,7 +331,8 @@ function recursivelyGatherDependencySources( * @param solcVersion The compiler version. e.g. 0.5.0 */ export async function getSolcJSAsync(solcVersion: string): Promise<solc.SolcInstance> { - const fullSolcVersion = binPaths[solcVersion]; + const solcJSReleases = await getSolcJSReleasesAsync(); + const fullSolcVersion = solcJSReleases[solcVersion]; if (_.isUndefined(fullSolcVersion)) { throw new Error(`${solcVersion} is not a known compiler version`); } diff --git a/packages/sol-compiler/src/utils/types.ts b/packages/sol-compiler/src/utils/types.ts index 64328899d..f756c51bb 100644 --- a/packages/sol-compiler/src/utils/types.ts +++ b/packages/sol-compiler/src/utils/types.ts @@ -13,6 +13,10 @@ export interface ContractSourceData { [contractName: string]: ContractSpecificSourceData; } +export interface BinaryPaths { + [key: string]: string; +} + export interface ContractSpecificSourceData { solcVersionRange: string; sourceHash: Buffer; diff --git a/packages/sol-compiler/test/compiler_test.ts b/packages/sol-compiler/test/compiler_test.ts index 464aa8bb6..cae6bce05 100644 --- a/packages/sol-compiler/test/compiler_test.ts +++ b/packages/sol-compiler/test/compiler_test.ts @@ -23,6 +23,9 @@ describe('#Compiler', function(): void { contractsDir, contracts: constants.contracts, }; + it('should create a Compiler with empty opts', async () => { + const _compiler = new Compiler(); // tslint:disable-line no-unused-variable + }); it('should create an Exchange artifact with the correct unlinked binary', async () => { compilerOpts.contracts = ['Exchange']; diff --git a/packages/sol-coverage/CHANGELOG.json b/packages/sol-coverage/CHANGELOG.json index 2a33fe578..dc5ae1a53 100644 --- a/packages/sol-coverage/CHANGELOG.json +++ b/packages/sol-coverage/CHANGELOG.json @@ -1,5 +1,23 @@ [ { + "version": "2.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ], + "timestamp": 1549547375 + }, + { + "timestamp": 1549452781, + "version": "2.0.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "version": "2.0.0", "changes": [ { diff --git a/packages/sol-coverage/CHANGELOG.md b/packages/sol-coverage/CHANGELOG.md index 0c1916717..1af9b9f26 100644 --- a/packages/sol-coverage/CHANGELOG.md +++ b/packages/sol-coverage/CHANGELOG.md @@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v2.0.2 - _February 7, 2019_ + + * Dependencies updated + +## v2.0.1 - _February 6, 2019_ + + * Dependencies updated + ## v2.0.0 - _February 5, 2019_ * Upgrade the bignumber.js to v8.0.2 (#1517) diff --git a/packages/sol-coverage/package.json b/packages/sol-coverage/package.json index 8f0681639..6724a03df 100644 --- a/packages/sol-coverage/package.json +++ b/packages/sol-coverage/package.json @@ -1,6 +1,6 @@ { "name": "@0x/sol-coverage", - "version": "2.0.0", + "version": "2.0.2", "engines": { "node": ">=6.12" }, @@ -29,8 +29,8 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/sol-coverage/README.md", "dependencies": { - "@0x/sol-tracing-utils": "^6.0.0", - "@0x/subproviders": "^3.0.0", + "@0x/sol-tracing-utils": "^6.0.2", + "@0x/subproviders": "^3.0.2", "@0x/typescript-typings": "^4.0.0", "ethereum-types": "^2.0.0", "lodash": "^4.17.11" diff --git a/packages/sol-doc/CHANGELOG.json b/packages/sol-doc/CHANGELOG.json index 2ffa21f26..d9d0ddfa2 100644 --- a/packages/sol-doc/CHANGELOG.json +++ b/packages/sol-doc/CHANGELOG.json @@ -1,5 +1,23 @@ [ { + "version": "2.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ], + "timestamp": 1549547375 + }, + { + "timestamp": 1549452781, + "version": "2.0.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "version": "2.0.0", "changes": [ { diff --git a/packages/sol-doc/CHANGELOG.md b/packages/sol-doc/CHANGELOG.md index 6eff7d01a..06ea1d7b4 100644 --- a/packages/sol-doc/CHANGELOG.md +++ b/packages/sol-doc/CHANGELOG.md @@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v2.0.2 - _February 7, 2019_ + + * Dependencies updated + +## v2.0.1 - _February 6, 2019_ + + * Dependencies updated + ## v2.0.0 - _February 5, 2019_ * Upgrade the bignumber.js to v8.0.2 (#1517) diff --git a/packages/sol-doc/package.json b/packages/sol-doc/package.json index 2004b5bd2..c413e248f 100644 --- a/packages/sol-doc/package.json +++ b/packages/sol-doc/package.json @@ -1,6 +1,6 @@ { "name": "@0x/sol-doc", - "version": "2.0.0", + "version": "2.0.2", "description": "Solidity documentation generator", "main": "lib/src/index.js", "types": "lib/src/index.d.js", @@ -25,9 +25,9 @@ "author": "F. Eugene Aumson", "license": "Apache-2.0", "dependencies": { - "@0x/sol-compiler": "^3.0.0", - "@0x/types": "^2.0.0", - "@0x/utils": "^4.0.1", + "@0x/sol-compiler": "^3.0.2", + "@0x/types": "^2.0.2", + "@0x/utils": "^4.0.3", "ethereum-types": "^2.0.0", "ethereumjs-util": "^5.1.1", "lodash": "^4.17.11", diff --git a/packages/sol-profiler/CHANGELOG.json b/packages/sol-profiler/CHANGELOG.json index 54375890d..89f3f7171 100644 --- a/packages/sol-profiler/CHANGELOG.json +++ b/packages/sol-profiler/CHANGELOG.json @@ -1,5 +1,23 @@ [ { + "version": "2.0.3", + "changes": [ + { + "note": "Dependencies updated" + } + ], + "timestamp": 1549547375 + }, + { + "timestamp": 1549452781, + "version": "2.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "version": "2.0.1", "changes": [ { diff --git a/packages/sol-profiler/CHANGELOG.md b/packages/sol-profiler/CHANGELOG.md index 32a2bac0a..bf9e59e54 100644 --- a/packages/sol-profiler/CHANGELOG.md +++ b/packages/sol-profiler/CHANGELOG.md @@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v2.0.3 - _February 7, 2019_ + + * Dependencies updated + +## v2.0.2 - _February 6, 2019_ + + * Dependencies updated + ## v2.0.1 - _February 5, 2019_ * Fix a bug when some parts of the profiling report were missing because of the coverage ignore lines (#1535) diff --git a/packages/sol-profiler/package.json b/packages/sol-profiler/package.json index 06ca7a708..cce49e22e 100644 --- a/packages/sol-profiler/package.json +++ b/packages/sol-profiler/package.json @@ -1,6 +1,6 @@ { "name": "@0x/sol-profiler", - "version": "2.0.1", + "version": "2.0.3", "engines": { "node": ">=6.12" }, @@ -29,8 +29,8 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/sol-profiler/README.md", "dependencies": { - "@0x/sol-tracing-utils": "^6.0.0", - "@0x/subproviders": "^3.0.0", + "@0x/sol-tracing-utils": "^6.0.2", + "@0x/subproviders": "^3.0.2", "@0x/typescript-typings": "^4.0.0", "ethereum-types": "^2.0.0", "lodash": "^4.17.11" diff --git a/packages/sol-resolver/CHANGELOG.json b/packages/sol-resolver/CHANGELOG.json index efca37e90..9c02b9148 100644 --- a/packages/sol-resolver/CHANGELOG.json +++ b/packages/sol-resolver/CHANGELOG.json @@ -1,5 +1,23 @@ [ { + "version": "2.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ], + "timestamp": 1549547375 + }, + { + "timestamp": 1549452781, + "version": "2.0.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "version": "2.0.0", "changes": [ { diff --git a/packages/sol-resolver/CHANGELOG.md b/packages/sol-resolver/CHANGELOG.md index 7e5fd05a8..f23c55ea8 100644 --- a/packages/sol-resolver/CHANGELOG.md +++ b/packages/sol-resolver/CHANGELOG.md @@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v2.0.2 - _February 7, 2019_ + + * Dependencies updated + +## v2.0.1 - _February 6, 2019_ + + * Dependencies updated + ## v2.0.0 - _February 5, 2019_ * Upgrade the bignumber.js to v8.0.2 (#1517) diff --git a/packages/sol-resolver/package.json b/packages/sol-resolver/package.json index 3f0fe3be4..aeb0c6bfc 100644 --- a/packages/sol-resolver/package.json +++ b/packages/sol-resolver/package.json @@ -1,6 +1,6 @@ { "name": "@0x/sol-resolver", - "version": "2.0.0", + "version": "2.0.2", "engines": { "node": ">=6.12" }, @@ -30,7 +30,7 @@ "typescript": "3.0.1" }, "dependencies": { - "@0x/types": "^2.0.0", + "@0x/types": "^2.0.2", "@0x/typescript-typings": "^4.0.0", "lodash": "^4.17.11" }, diff --git a/packages/sol-trace/CHANGELOG.json b/packages/sol-trace/CHANGELOG.json index 3897b1249..c786a56a3 100644 --- a/packages/sol-trace/CHANGELOG.json +++ b/packages/sol-trace/CHANGELOG.json @@ -1,5 +1,23 @@ [ { + "version": "2.0.3", + "changes": [ + { + "note": "Dependencies updated" + } + ], + "timestamp": 1549547375 + }, + { + "timestamp": 1549452781, + "version": "2.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "version": "2.0.1", "changes": [ { diff --git a/packages/sol-trace/CHANGELOG.md b/packages/sol-trace/CHANGELOG.md index d828b4744..bcb75c423 100644 --- a/packages/sol-trace/CHANGELOG.md +++ b/packages/sol-trace/CHANGELOG.md @@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v2.0.3 - _February 7, 2019_ + + * Dependencies updated + +## v2.0.2 - _February 6, 2019_ + + * Dependencies updated + ## v2.0.1 - _February 5, 2019_ * Improve error messages when unable to find matching bytecode (#1558) diff --git a/packages/sol-trace/package.json b/packages/sol-trace/package.json index a1439de7e..b65a8b002 100644 --- a/packages/sol-trace/package.json +++ b/packages/sol-trace/package.json @@ -1,6 +1,6 @@ { "name": "@0x/sol-trace", - "version": "2.0.1", + "version": "2.0.3", "engines": { "node": ">=6.12" }, @@ -29,8 +29,8 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/sol-trace/README.md", "dependencies": { - "@0x/sol-tracing-utils": "^6.0.0", - "@0x/subproviders": "^3.0.0", + "@0x/sol-tracing-utils": "^6.0.2", + "@0x/subproviders": "^3.0.2", "@0x/typescript-typings": "^4.0.0", "chalk": "^2.3.0", "ethereum-types": "^2.0.0", diff --git a/packages/sol-tracing-utils/CHANGELOG.json b/packages/sol-tracing-utils/CHANGELOG.json index 6b5db6c8f..911cf6c1f 100644 --- a/packages/sol-tracing-utils/CHANGELOG.json +++ b/packages/sol-tracing-utils/CHANGELOG.json @@ -1,5 +1,23 @@ [ { + "version": "6.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ], + "timestamp": 1549547375 + }, + { + "timestamp": 1549452781, + "version": "6.0.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "version": "6.0.0", "changes": [ { diff --git a/packages/sol-tracing-utils/CHANGELOG.md b/packages/sol-tracing-utils/CHANGELOG.md index 74d0ca61f..6f9fa5615 100644 --- a/packages/sol-tracing-utils/CHANGELOG.md +++ b/packages/sol-tracing-utils/CHANGELOG.md @@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v6.0.2 - _February 7, 2019_ + + * Dependencies updated + +## v6.0.1 - _February 6, 2019_ + + * Dependencies updated + ## v6.0.0 - _February 5, 2019_ * `SolCompilerArtifactAdapter` now uses `SolResolver` under the hood which allows to resolve `NPM` dependencies properly (#1535) diff --git a/packages/sol-tracing-utils/package.json b/packages/sol-tracing-utils/package.json index 082894b2c..8bccb237d 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": "6.0.0", + "version": "6.0.2", "engines": { "node": ">=6.12" }, @@ -42,13 +42,13 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/sol-tracing-utils/README.md", "dependencies": { - "@0x/dev-utils": "^2.0.0", - "@0x/sol-compiler": "^3.0.0", - "@0x/sol-resolver": "^2.0.0", - "@0x/subproviders": "^3.0.0", + "@0x/dev-utils": "^2.0.2", + "@0x/sol-compiler": "^3.0.2", + "@0x/sol-resolver": "^2.0.2", + "@0x/subproviders": "^3.0.2", "@0x/typescript-typings": "^4.0.0", - "@0x/utils": "^4.0.1", - "@0x/web3-wrapper": "^4.0.0", + "@0x/utils": "^4.0.3", + "@0x/web3-wrapper": "^4.0.2", "@types/solidity-parser-antlr": "^0.2.0", "chalk": "^2.3.0", "ethereum-types": "^2.0.0", diff --git a/packages/sra-spec/CHANGELOG.json b/packages/sra-spec/CHANGELOG.json index 0f0d50701..05ea49243 100644 --- a/packages/sra-spec/CHANGELOG.json +++ b/packages/sra-spec/CHANGELOG.json @@ -1,5 +1,23 @@ [ { + "version": "2.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ], + "timestamp": 1549547375 + }, + { + "timestamp": 1549452781, + "version": "2.0.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "version": "2.0.0", "changes": [ { diff --git a/packages/sra-spec/CHANGELOG.md b/packages/sra-spec/CHANGELOG.md index b971fb3e6..ce7a09708 100644 --- a/packages/sra-spec/CHANGELOG.md +++ b/packages/sra-spec/CHANGELOG.md @@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v2.0.2 - _February 7, 2019_ + + * Dependencies updated + +## v2.0.1 - _February 6, 2019_ + + * Dependencies updated + ## v2.0.0 - _February 5, 2019_ * Upgrade the bignumber.js to v8.0.2 (#1517) diff --git a/packages/sra-spec/package.json b/packages/sra-spec/package.json index 34cfb0205..28cf15938 100644 --- a/packages/sra-spec/package.json +++ b/packages/sra-spec/package.json @@ -1,6 +1,6 @@ { "name": "@0x/sra-spec", - "version": "2.0.0", + "version": "2.0.2", "engines": { "node": ">=6.12" }, @@ -35,7 +35,7 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/sra-spec/README.md", "dependencies": { - "@0x/json-schemas": "^3.0.0", + "@0x/json-schemas": "^3.0.2", "@loopback/openapi-v3-types": "^0.8.2" }, "devDependencies": { diff --git a/packages/subproviders/CHANGELOG.json b/packages/subproviders/CHANGELOG.json index 647d7c1d9..3d5bade1f 100644 --- a/packages/subproviders/CHANGELOG.json +++ b/packages/subproviders/CHANGELOG.json @@ -1,5 +1,23 @@ [ { + "version": "3.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ], + "timestamp": 1549547375 + }, + { + "timestamp": 1549452781, + "version": "3.0.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "version": "3.0.0", "changes": [ { diff --git a/packages/subproviders/CHANGELOG.md b/packages/subproviders/CHANGELOG.md index a3e0969be..b3dfa757a 100644 --- a/packages/subproviders/CHANGELOG.md +++ b/packages/subproviders/CHANGELOG.md @@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v3.0.2 - _February 7, 2019_ + + * Dependencies updated + +## v3.0.1 - _February 6, 2019_ + + * Dependencies updated + ## v3.0.0 - _February 5, 2019_ * Upgrade the bignumber.js to v8.0.2 (#1517) diff --git a/packages/subproviders/package.json b/packages/subproviders/package.json index ffba02051..a783bb5a2 100644 --- a/packages/subproviders/package.json +++ b/packages/subproviders/package.json @@ -1,6 +1,6 @@ { "name": "@0x/subproviders", - "version": "3.0.0", + "version": "3.0.2", "engines": { "node": ">=6.12" }, @@ -29,11 +29,11 @@ } }, "dependencies": { - "@0x/assert": "^2.0.0", - "@0x/types": "^2.0.0", + "@0x/assert": "^2.0.2", + "@0x/types": "^2.0.2", "@0x/typescript-typings": "^4.0.0", - "@0x/utils": "^4.0.1", - "@0x/web3-wrapper": "^4.0.0", + "@0x/utils": "^4.0.3", + "@0x/web3-wrapper": "^4.0.2", "@ledgerhq/hw-app-eth": "^4.3.0", "@ledgerhq/hw-transport-u2f": "4.24.0", "@types/eth-lightwallet": "^3.0.0", diff --git a/packages/testnet-faucets/package.json b/packages/testnet-faucets/package.json index dd1faf1b7..c529d4975 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.65", + "version": "1.0.68", "engines": { "node": ">=6.12" }, @@ -18,11 +18,11 @@ "author": "Fabio Berger", "license": "Apache-2.0", "dependencies": { - "0x.js": "^4.0.0", - "@0x/subproviders": "^3.0.0", + "0x.js": "^4.0.3", + "@0x/subproviders": "^3.0.2", "@0x/typescript-typings": "^4.0.0", - "@0x/utils": "^4.0.1", - "@0x/web3-wrapper": "^4.0.0", + "@0x/utils": "^4.0.3", + "@0x/web3-wrapper": "^4.0.2", "body-parser": "^1.17.1", "ethereum-types": "^2.0.0", "ethereumjs-tx": "^1.3.5", diff --git a/packages/types/CHANGELOG.json b/packages/types/CHANGELOG.json index b9ddb5acf..8f2bf967a 100644 --- a/packages/types/CHANGELOG.json +++ b/packages/types/CHANGELOG.json @@ -1,10 +1,36 @@ [ { + "version": "2.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ], + "timestamp": 1549547375 + }, + { + "timestamp": 1549452781, + "version": "2.0.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "version": "2.0.0", "changes": [ { "note": "Upgrade the bignumber.js to v8.0.2", "pr": 1517 + }, + { + "note": "Update `ZeroExTransaction` type and add `SignedZeroExTransaction` type", + "pr": 1576 + }, + { + "note": "Add `EIP712DomainWithDefaultSchema` type", + "pr": 1576 } ], "timestamp": 1549373905 diff --git a/packages/types/CHANGELOG.md b/packages/types/CHANGELOG.md index a4f185dca..a2bc34dee 100644 --- a/packages/types/CHANGELOG.md +++ b/packages/types/CHANGELOG.md @@ -5,9 +5,19 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v2.0.2 - _February 7, 2019_ + + * Dependencies updated + +## v2.0.1 - _February 6, 2019_ + + * Dependencies updated + ## v2.0.0 - _February 5, 2019_ * Upgrade the bignumber.js to v8.0.2 (#1517) + * Update `ZeroExTransaction` type and add `SignedZeroExTransaction` type (#1576) + * Add `EIP712DomainWithDefaultSchema` type (#1576) ## v1.5.2 - _January 15, 2019_ diff --git a/packages/types/package.json b/packages/types/package.json index 89d1bbd1c..951251c58 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@0x/types", - "version": "2.0.0", + "version": "2.0.2", "engines": { "node": ">=6.12" }, diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index 49f788fb0..b3a083999 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -45,11 +45,16 @@ export interface SignedOrder extends Order { * ZeroExTransaction for use with 0x Exchange executeTransaction */ export interface ZeroExTransaction { + verifyingContractAddress: string; salt: BigNumber; signerAddress: string; data: string; } +export interface SignedZeroExTransaction extends ZeroExTransaction { + signature: string; +} + /** * Elliptic Curve signature */ @@ -685,3 +690,33 @@ export interface DutchAuctionDetails { currentAmount: BigNumber; currentTimeSeconds: BigNumber; } + +export interface PackageJSONConfig { + postpublish?: { + assets?: string[]; + docOmitExports?: string[]; + dockerHubRepo?: string; + }; + 'abis:comment'?: string; + abis?: string; + ignoreDependencyVersions?: string; + ignoreDependencyVersionsForPackage?: string; +} + +export interface PackageJSON { + private?: boolean; + version: string; + name: string; + main?: string; + scripts?: { [command: string]: string }; + config?: PackageJSONConfig; + dependencies?: { [dependencyName: string]: string }; + devDependencies?: { [dependencyName: string]: string }; + workspaces?: string[]; +} + +export interface EIP712DomainWithDefaultSchema { + name?: string; + version?: string; + verifyingContractAddress: string; +} diff --git a/packages/utils/CHANGELOG.json b/packages/utils/CHANGELOG.json index 8671729d3..007591d18 100644 --- a/packages/utils/CHANGELOG.json +++ b/packages/utils/CHANGELOG.json @@ -1,5 +1,24 @@ [ { + "version": "4.0.3", + "changes": [ + { + "note": "Dependencies updated" + } + ], + "timestamp": 1549547375 + }, + { + "version": "4.0.2", + "changes": [ + { + "note": "ABI Decode NULL for all data types", + "pr": 1587 + } + ], + "timestamp": 1549452781 + }, + { "version": "4.0.1", "changes": [ { diff --git a/packages/utils/CHANGELOG.md b/packages/utils/CHANGELOG.md index f76166f94..4772bbb86 100644 --- a/packages/utils/CHANGELOG.md +++ b/packages/utils/CHANGELOG.md @@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v4.0.3 - _February 7, 2019_ + + * Dependencies updated + +## v4.0.2 - _February 6, 2019_ + + * ABI Decode NULL for all data types (#1587) + ## v4.0.1 - _February 5, 2019_ * ABI Decode NULL as False (#1582) diff --git a/packages/utils/package.json b/packages/utils/package.json index 8431b98c1..86fecbc7c 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@0x/utils", - "version": "4.0.1", + "version": "4.0.3", "engines": { "node": ">=6.12" }, @@ -44,7 +44,7 @@ "typescript": "3.0.1" }, "dependencies": { - "@0x/types": "^2.0.0", + "@0x/types": "^2.0.2", "@0x/typescript-typings": "^4.0.0", "@types/node": "*", "abortcontroller-polyfill": "^1.1.9", diff --git a/packages/utils/src/abi_encoder/abstract_data_types/data_type.ts b/packages/utils/src/abi_encoder/abstract_data_types/data_type.ts index f23324721..db4f02b89 100644 --- a/packages/utils/src/abi_encoder/abstract_data_types/data_type.ts +++ b/packages/utils/src/abi_encoder/abstract_data_types/data_type.ts @@ -47,7 +47,8 @@ export abstract class DataType { const hasSelector = !_.isUndefined(selector); const rawCalldata = new RawCalldata(calldata, hasSelector); const rules_ = _.isUndefined(rules) ? constants.DEFAULT_DECODING_RULES : rules; - const value = this.generateValue(rawCalldata, rules_); + const value = + rawCalldata.getSizeInBytes() > 0 ? this.generateValue(rawCalldata, rules_) : this.getDefaultValue(rules_); return value; } @@ -71,6 +72,7 @@ export abstract class DataType { public abstract generateCalldataBlock(value: any, parentBlock?: CalldataBlock): CalldataBlock; public abstract generateValue(calldata: RawCalldata, rules: DecodingRules): any; + public abstract getDefaultValue(rules?: DecodingRules): any; public abstract getSignatureType(): string; public abstract isStatic(): boolean; } diff --git a/packages/utils/src/abi_encoder/abstract_data_types/types/set.ts b/packages/utils/src/abi_encoder/abstract_data_types/types/set.ts index 2c6c4b0f6..d45088482 100644 --- a/packages/utils/src/abi_encoder/abstract_data_types/types/set.ts +++ b/packages/utils/src/abi_encoder/abstract_data_types/types/set.ts @@ -97,6 +97,27 @@ export abstract class AbstractSetDataType extends DataType { return isStatic; } + public getDefaultValue(rules?: DecodingRules): any[] | object { + let defaultValue: any[] | object; + if (this._isArray && _.isUndefined(this._arrayLength)) { + defaultValue = []; + } else if (!_.isUndefined(rules) && rules.shouldConvertStructsToObjects && !this._isArray) { + defaultValue = {}; + _.each(this._memberIndexByName, (idx: number, key: string) => { + const member = this._members[idx]; + const memberValue = member.getDefaultValue(); + (defaultValue as { [key: string]: any })[key] = memberValue; + }); + } else { + defaultValue = []; + _.each(this._members, (member: DataType, idx: number) => { + const memberValue = member.getDefaultValue(); + (defaultValue as any[]).push(memberValue); + }); + } + return defaultValue; + } + protected _generateCalldataBlockFromArray(value: any[], parentBlock?: CalldataBlock): SetCalldataBlock { // Sanity check: if the set has a defined length then `value` must have the same length. if (!_.isUndefined(this._arrayLength) && value.length !== this._arrayLength) { diff --git a/packages/utils/src/abi_encoder/calldata/raw_calldata.ts b/packages/utils/src/abi_encoder/calldata/raw_calldata.ts index 189841989..dbc9d4942 100644 --- a/packages/utils/src/abi_encoder/calldata/raw_calldata.ts +++ b/packages/utils/src/abi_encoder/calldata/raw_calldata.ts @@ -79,4 +79,9 @@ export class RawCalldata { public getSelector(): string { return this._selector; } + + public getSizeInBytes(): number { + const sizeInBytes = this._value.byteLength; + return sizeInBytes; + } } diff --git a/packages/utils/src/abi_encoder/evm_data_types/address.ts b/packages/utils/src/abi_encoder/evm_data_types/address.ts index 2278830eb..7e92d3888 100644 --- a/packages/utils/src/abi_encoder/evm_data_types/address.ts +++ b/packages/utils/src/abi_encoder/evm_data_types/address.ts @@ -12,6 +12,7 @@ export class AddressDataType extends AbstractBlobDataType { private static readonly _ADDRESS_SIZE_IN_BYTES = 20; private static readonly _DECODED_ADDRESS_OFFSET_IN_BYTES = constants.EVM_WORD_WIDTH_IN_BYTES - AddressDataType._ADDRESS_SIZE_IN_BYTES; + private static readonly _DEFAULT_VALUE = '0x0000000000000000000000000000000000000000'; public static matchType(type: string): boolean { return type === SolidityTypes.Address; @@ -43,6 +44,10 @@ export class AddressDataType extends AbstractBlobDataType { return valueLowercase; } + public getDefaultValue(): string { + return AddressDataType._DEFAULT_VALUE; + } + public getSignatureType(): string { return SolidityTypes.Address; } 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 ffccd6e53..24887c509 100644 --- a/packages/utils/src/abi_encoder/evm_data_types/bool.ts +++ b/packages/utils/src/abi_encoder/evm_data_types/bool.ts @@ -10,6 +10,7 @@ import { constants } from '../utils/constants'; export class BoolDataType extends AbstractBlobDataType { private static readonly _SIZE_KNOWN_AT_COMPILE_TIME: boolean = true; + private static readonly _DEFAULT_VALUE: boolean = false; public static matchType(type: string): boolean { return type === SolidityTypes.Bool; @@ -47,6 +48,10 @@ export class BoolDataType extends AbstractBlobDataType { return value; } + public getDefaultValue(): boolean { + return BoolDataType._DEFAULT_VALUE; + } + public getSignatureType(): string { return SolidityTypes.Bool; } diff --git a/packages/utils/src/abi_encoder/evm_data_types/dynamic_bytes.ts b/packages/utils/src/abi_encoder/evm_data_types/dynamic_bytes.ts index fa38b63c0..7a49a84b4 100644 --- a/packages/utils/src/abi_encoder/evm_data_types/dynamic_bytes.ts +++ b/packages/utils/src/abi_encoder/evm_data_types/dynamic_bytes.ts @@ -9,6 +9,7 @@ import { constants } from '../utils/constants'; export class DynamicBytesDataType extends AbstractBlobDataType { private static readonly _SIZE_KNOWN_AT_COMPILE_TIME: boolean = false; + private static readonly _DEFAULT_VALUE = '0x'; public static matchType(type: string): boolean { return type === SolidityTypes.Bytes; @@ -65,6 +66,10 @@ export class DynamicBytesDataType extends AbstractBlobDataType { return value; } + public getDefaultValue(): string { + return DynamicBytesDataType._DEFAULT_VALUE; + } + public getSignatureType(): string { return SolidityTypes.Bytes; } 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 f8be1f778..02278f666 100644 --- a/packages/utils/src/abi_encoder/evm_data_types/int.ts +++ b/packages/utils/src/abi_encoder/evm_data_types/int.ts @@ -15,6 +15,7 @@ export class IntDataType extends AbstractBlobDataType { private static readonly _SIZE_KNOWN_AT_COMPILE_TIME: boolean = true; private static readonly _MAX_WIDTH: number = 256; private static readonly _DEFAULT_WIDTH: number = IntDataType._MAX_WIDTH; + private static readonly _DEFAULT_VALUE = new BigNumber(0); private readonly _width: number; private readonly _minValue: BigNumber; private readonly _maxValue: BigNumber; @@ -50,13 +51,20 @@ export class IntDataType extends AbstractBlobDataType { public decodeValue(calldata: RawCalldata): BigNumber | number { const valueBuf = calldata.popWord(); const value = EncoderMath.safeDecodeNumericValue(valueBuf, this._minValue, this._maxValue); - const numberOfBytesInUint8 = 8; - if (this._width === numberOfBytesInUint8) { + if (this._width === constants.NUMBER_OF_BYTES_IN_INT8) { return value.toNumber(); } return value; } + public getDefaultValue(): BigNumber | number { + const defaultValue = IntDataType._DEFAULT_VALUE; + if (this._width === constants.NUMBER_OF_BYTES_IN_INT8) { + return defaultValue.toNumber(); + } + return defaultValue; + } + public getSignatureType(): string { return `${SolidityTypes.Int}${this._width}`; } diff --git a/packages/utils/src/abi_encoder/evm_data_types/pointer.ts b/packages/utils/src/abi_encoder/evm_data_types/pointer.ts index 250db7c64..50f68f5ea 100644 --- a/packages/utils/src/abi_encoder/evm_data_types/pointer.ts +++ b/packages/utils/src/abi_encoder/evm_data_types/pointer.ts @@ -18,4 +18,9 @@ export class PointerDataType extends AbstractPointerDataType { public getSignature(isDetailed?: boolean): string { return this._destination.getSignature(isDetailed); } + + public getDefaultValue(): any { + const defaultValue = this._destination.getDefaultValue(); + return defaultValue; + } } diff --git a/packages/utils/src/abi_encoder/evm_data_types/static_bytes.ts b/packages/utils/src/abi_encoder/evm_data_types/static_bytes.ts index cbf1957d7..a965f6796 100644 --- a/packages/utils/src/abi_encoder/evm_data_types/static_bytes.ts +++ b/packages/utils/src/abi_encoder/evm_data_types/static_bytes.ts @@ -58,6 +58,13 @@ export class StaticBytesDataType extends AbstractBlobDataType { return value; } + public getDefaultValue(): string { + const valueBufPadded = constants.EMPTY_EVM_WORD_BUFFER; + const valueBuf = valueBufPadded.slice(0, this._width); + const value = ethUtil.bufferToHex(valueBuf); + return value; + } + private _sanityCheckValue(value: string | Buffer): void { if (typeof value === 'string') { if (!_.startsWith(value, '0x')) { diff --git a/packages/utils/src/abi_encoder/evm_data_types/string.ts b/packages/utils/src/abi_encoder/evm_data_types/string.ts index 97ac46442..f54d739b4 100644 --- a/packages/utils/src/abi_encoder/evm_data_types/string.ts +++ b/packages/utils/src/abi_encoder/evm_data_types/string.ts @@ -9,6 +9,7 @@ import { constants } from '../utils/constants'; export class StringDataType extends AbstractBlobDataType { private static readonly _SIZE_KNOWN_AT_COMPILE_TIME: boolean = false; + private static readonly _DEFAULT_VALUE = ''; public static matchType(type: string): boolean { return type === SolidityTypes.String; @@ -52,6 +53,10 @@ export class StringDataType extends AbstractBlobDataType { return value; } + public getDefaultValue(): string { + return StringDataType._DEFAULT_VALUE; + } + public getSignatureType(): string { return SolidityTypes.String; } 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 a82aa789e..d530606b9 100644 --- a/packages/utils/src/abi_encoder/evm_data_types/uint.ts +++ b/packages/utils/src/abi_encoder/evm_data_types/uint.ts @@ -16,6 +16,7 @@ export class UIntDataType extends AbstractBlobDataType { private static readonly _MAX_WIDTH: number = 256; private static readonly _DEFAULT_WIDTH: number = UIntDataType._MAX_WIDTH; private static readonly _MIN_VALUE = new BigNumber(0); + private static readonly _DEFAULT_VALUE = new BigNumber(0); private readonly _width: number; private readonly _maxValue: BigNumber; @@ -49,13 +50,20 @@ export class UIntDataType extends AbstractBlobDataType { public decodeValue(calldata: RawCalldata): BigNumber | number { const valueBuf = calldata.popWord(); const value = EncoderMath.safeDecodeNumericValue(valueBuf, UIntDataType._MIN_VALUE, this._maxValue); - const numberOfBytesInUint8 = 8; - if (this._width === numberOfBytesInUint8) { + if (this._width === constants.NUMBER_OF_BYTES_IN_UINT8) { return value.toNumber(); } return value; } + public getDefaultValue(): BigNumber | number { + const defaultValue = UIntDataType._DEFAULT_VALUE; + if (this._width === constants.NUMBER_OF_BYTES_IN_UINT8) { + return defaultValue.toNumber(); + } + return defaultValue; + } + public getSignatureType(): string { return `${SolidityTypes.Uint}${this._width}`; } diff --git a/packages/utils/src/abi_encoder/utils/constants.ts b/packages/utils/src/abi_encoder/utils/constants.ts index fc586f295..b45b5b8e8 100644 --- a/packages/utils/src/abi_encoder/utils/constants.ts +++ b/packages/utils/src/abi_encoder/utils/constants.ts @@ -1,3 +1,5 @@ +import * as ethUtil from 'ethereumjs-util'; + import { DecodingRules, EncodingRules } from './rules'; export const constants = { @@ -14,4 +16,8 @@ export const constants = { DEFAULT_DECODING_RULES: { shouldConvertStructsToObjects: true } as DecodingRules, DEFAULT_ENCODING_RULES: { shouldOptimize: true, shouldAnnotate: false } as EncodingRules, /* tslint:enable no-object-literal-type-assertion */ + EMPTY_EVM_WORD_STRING: '0x0000000000000000000000000000000000000000000000000000000000000000', + EMPTY_EVM_WORD_BUFFER: ethUtil.toBuffer('0x0000000000000000000000000000000000000000000000000000000000000000'), + NUMBER_OF_BYTES_IN_UINT8: 8, + NUMBER_OF_BYTES_IN_INT8: 8, }; diff --git a/packages/utils/test/abi_encoder/abi_samples/return_value_abis.ts b/packages/utils/test/abi_encoder/abi_samples/return_value_abis.ts index ac2124011..ad07b3d24 100644 --- a/packages/utils/test/abi_encoder/abi_samples/return_value_abis.ts +++ b/packages/utils/test/abi_encoder/abi_samples/return_value_abis.ts @@ -97,3 +97,28 @@ export const mixedStaticAndDynamicReturnValues: MethodAbi = { stateMutability: 'nonpayable', type: 'function', }; + +export const structuredReturnValue: MethodAbi = { + constant: false, + inputs: [], + name: 'fillOrder', + outputs: [ + { + components: [ + { + name: 'makerAssetFilledAmount', + type: 'uint256', + }, + { + name: 'takerAssetFilledAmount', + type: 'uint256', + }, + ], + name: 'fillResults', + type: 'tuple', + }, + ], + payable: false, + stateMutability: 'nonpayable', + type: 'function', +}; 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 c146890e0..c09c0d929 100644 --- a/packages/utils/test/abi_encoder/evm_data_types_test.ts +++ b/packages/utils/test/abi_encoder/evm_data_types_test.ts @@ -11,6 +11,7 @@ const expect = chai.expect; describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const encodingRules: AbiEncoder.EncodingRules = { shouldOptimize: false }; // optimizer is tested separately. + const nullEncodedArgs = '0x'; describe('Array', () => { it('Fixed size; Static elements', async () => { // Create DataType object @@ -207,6 +208,51 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { dataType.encode(args, encodingRules); }).to.throw('Tried to assign NaN value'); }); + it('Should decode NULL to default values (Fixed size; Static elements)', async () => { + // Create DataType object + const testDataItem = { name: 'testArray', type: 'int[2]' }; + const dataType = new AbiEncoder.Array(testDataItem); + const args = [new BigNumber(0), new BigNumber(0)]; + // Decode Encoded Args and validate result + const decodedArgs = dataType.decode(nullEncodedArgs); + expect(decodedArgs).to.be.deep.equal(args); + }); + it('Should decode NULL to default values (Dynamic size; Static elements)', async () => { + // Create DataType object + const testDataItem = { name: 'testArray', type: 'int[]' }; + const dataType = new AbiEncoder.Array(testDataItem); + const args: BigNumber[] = []; + // Decode Encoded Args and validate result + const decodedArgs = dataType.decode(nullEncodedArgs); + expect(decodedArgs).to.be.deep.equal(args); + }); + it('Should decode NULL to default values (Fixed size; Dynamic elements)', async () => { + // Create DataType object + const testDataItem = { name: 'testArray', type: 'string[2]' }; + const dataType = new AbiEncoder.Array(testDataItem); + const args = ['', '']; + // Decode Encoded Args and validate result + const decodedArgs = dataType.decode(nullEncodedArgs); + expect(decodedArgs).to.be.deep.equal(args); + }); + it('Should decode NULL to default values (Dynamic size; Dynamic elements)', async () => { + // Create DataType object + const testDataItem = { name: 'testArray', type: 'string[]' }; + const dataType = new AbiEncoder.Array(testDataItem); + const args: string[] = []; + // Decode Encoded Args and validate result + const decodedArgs = dataType.decode(nullEncodedArgs); + expect(decodedArgs).to.be.deep.equal(args); + }); + it('Should decode NULL to default values (Dynamic Size; Multidimensional; Dynamic Elements)', async () => { + // Create DataType object + const testDataItem = { name: 'testArray', type: 'bytes[][]' }; + const dataType = new AbiEncoder.Array(testDataItem); + const args: string[][] = []; + // Decode Encoded Args and validate result + const decodedArgs = dataType.decode(nullEncodedArgs); + expect(decodedArgs).to.be.deep.equal(args); + }); }); describe('Tuple', () => { @@ -407,6 +453,46 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { dataType.encode(args, encodingRules); }).to.throw('Could not assign tuple to object: missing key \'field_2\' in object {"field_1":"-5"}'); }); + it('Should decode NULL to default values (static elements only)', async () => { + // Create DataType object + const testDataItem = { + name: 'Tuple', + type: 'tuple', + components: [{ name: 'field_1', type: 'int32' }, { name: 'field_2', type: 'bool' }], + }; + const dataType = new AbiEncoder.Tuple(testDataItem); + // Construct args to be encoded + const args = { field_1: new BigNumber(0), field_2: false }; + // Decode Encoded Args and validate result + const decodingRules: AbiEncoder.DecodingRules = { shouldConvertStructsToObjects: true }; + const decodedArgs = dataType.decode(nullEncodedArgs, decodingRules); + expect(decodedArgs).to.be.deep.equal(args); + }); + it('Should decode NULL to default values (static and dynamic elements)', async () => { + // Create DataType object + const testDataItem = { + name: 'Tuple', + type: 'tuple', + components: [ + { name: 'field_1', type: 'int32' }, + { name: 'field_2', type: 'string' }, + { name: 'field_3', type: 'bool' }, + { name: 'field_4', type: 'bytes' }, + ], + }; + const dataType = new AbiEncoder.Tuple(testDataItem); + // Construct args to be encoded + const args = { + field_1: new BigNumber(0), + field_2: '', + field_3: false, + field_4: '0x', + }; + // Decode Encoded Args and validate result + const decodingRules: AbiEncoder.DecodingRules = { shouldConvertStructsToObjects: true }; + const decodedArgs = dataType.decode(nullEncodedArgs, decodingRules); + expect(decodedArgs).to.be.deep.equal(args); + }); }); describe('Address', () => { @@ -450,6 +536,15 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { dataType.encode(args, encodingRules); }).to.throw(`Invalid address: '${args}'`); }); + it('Should decode NULL to default value of address zero', async () => { + // Create DataType object + const testDataItem = { name: 'Address', type: 'address' }; + const dataType = new AbiEncoder.Address(testDataItem); + const args = '0x0000000000000000000000000000000000000000'; + // Decode Encoded Args and validate result + const decodedArgs = dataType.decode(nullEncodedArgs); + expect(decodedArgs).to.be.deep.equal(args); + }); }); describe('Bool', () => { @@ -489,23 +584,14 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const argsEncodedFromSignature = dataTypeFromSignature.encode(args); expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); - it('Null should decode as False', async () => { - // Hack @hysz: there are some cases where `false` is encoded as 0x instead of 0x0. + it('Should decode NULL to default value of False', async () => { // Create DataType object const testDataItem = { name: 'Boolean', type: 'bool' }; const dataType = new AbiEncoder.Bool(testDataItem); - // Construct args to be encoded const args = false; - // Encode Args and validate result - const encodedArgs = '0x'; - const expectedEncodedArgs = '0x0000000000000000000000000000000000000000000000000000000000000000'; // Decode Encoded Args and validate result - const decodedArgs = dataType.decode(encodedArgs); + const decodedArgs = dataType.decode(nullEncodedArgs); expect(decodedArgs).to.be.deep.equal(args); - // Validate signature - const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); - const argsEncodedFromSignature = dataTypeFromSignature.encode(args); - expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); }); @@ -705,6 +791,15 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { dataType.encode(args, encodingRules); }).to.throw(); }); + it('Should decode NULL to default value of 0', async () => { + // Create DataType object + const testDataItem = { name: 'Integer (256)', type: 'int' }; + const dataType = new AbiEncoder.Int(testDataItem); + const args = new BigNumber(0); + // Decode Encoded Args and validate result + const decodedArgs = dataType.decode(nullEncodedArgs); + expect(decodedArgs).to.be.deep.equal(args); + }); }); describe('Unsigned Integer', () => { @@ -867,6 +962,15 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { dataType.encode(args, encodingRules); }).to.throw(); }); + it('Should decode NULL to default value of 0', async () => { + // Create DataType object + const testDataItem = { name: 'Unsigned Integer (256)', type: 'uint' }; + const dataType = new AbiEncoder.UInt(testDataItem); + const args = new BigNumber(0); + // Decode Encoded Args and validate result + const decodedArgs = dataType.decode(nullEncodedArgs); + expect(decodedArgs).to.be.deep.equal(args); + }); }); describe('Static Bytes', () => { @@ -1030,6 +1134,33 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { dataType.encode(args, encodingRules); }).to.throw('Tried to assign 0x010, which is contains a half-byte. Use full bytes only.'); }); + it('Should decode NULL to default value - Single Byte (byte)', async () => { + // Create DataType object + const testDataItem = { name: 'Static Byte', type: 'byte' }; + const dataType = new AbiEncoder.StaticBytes(testDataItem); + const args = '0x00'; + // Decode Encoded Args and validate result + const decodedArgs = dataType.decode(nullEncodedArgs); + expect(decodedArgs).to.be.deep.equal(args); + }); + it('Should decode NULL to default value - 4 Bytes (bytes4)', async () => { + // Create DataType object + const testDataItem = { name: 'Static Bytes4', type: 'bytes4' }; + const dataType = new AbiEncoder.StaticBytes(testDataItem); + const args = '0x00000000'; + // Decode Encoded Args and validate result + const decodedArgs = dataType.decode(nullEncodedArgs); + expect(decodedArgs).to.be.deep.equal(args); + }); + it('Should decode NULL to default value - 32 Bytes (bytes32)', async () => { + // Create DataType object + const testDataItem = { name: 'Static Bytes32', type: 'bytes32' }; + const dataType = new AbiEncoder.StaticBytes(testDataItem); + const args = '0x0000000000000000000000000000000000000000000000000000000000000000'; + // Decode Encoded Args and validate result + const decodedArgs = dataType.decode(nullEncodedArgs); + expect(decodedArgs).to.be.deep.equal(args); + }); }); describe('Dynamic Bytes', () => { @@ -1117,6 +1248,15 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { dataType.encode(args, encodingRules); }).to.throw('Tried to assign 0x010, which is contains a half-byte. Use full bytes only.'); }); + it('Should decode NULL to empty byte array', async () => { + // Create DataType object + const testDataItem = { name: 'Dynamic Bytes', type: 'bytes' }; + const dataType = new AbiEncoder.DynamicBytes(testDataItem); + const args = '0x'; + // Decode Encoded Args and validate result + const decodedArgs = dataType.decode(nullEncodedArgs); + expect(decodedArgs).to.be.deep.equal(args); + }); }); describe('String', () => { @@ -1182,5 +1322,14 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const argsEncodedFromSignature = dataTypeFromSignature.encode(args); expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); + it('Should decode NULL to empty string', async () => { + // Create DataType object + const testDataItem = { name: 'String', type: 'string' }; + const dataType = new AbiEncoder.String(testDataItem); + // Decode Encoded Args and validate result + const args = ''; + const decodedArgs = dataType.decode(nullEncodedArgs); + expect(decodedArgs).to.be.deep.equal(args); + }); }); }); diff --git a/packages/utils/test/abi_encoder/return_values_test.ts b/packages/utils/test/abi_encoder/return_values_test.ts index 308d11ee5..ccdac510d 100644 --- a/packages/utils/test/abi_encoder/return_values_test.ts +++ b/packages/utils/test/abi_encoder/return_values_test.ts @@ -1,7 +1,7 @@ import * as chai from 'chai'; import 'mocha'; -import { AbiEncoder } from '../../src/'; +import { AbiEncoder, BigNumber } from '../../src/'; import { chaiSetup } from '../utils/chai_setup'; import * as ReturnValueAbis from './abi_samples/return_value_abis'; @@ -11,67 +11,194 @@ const expect = chai.expect; describe('ABI Encoder: Return Value Encoding/Decoding', () => { const encodingRules: AbiEncoder.EncodingRules = { shouldOptimize: false }; // optimizer is tested separately. - it('No Return Value', async () => { - // Decode return value - const method = new AbiEncoder.Method(ReturnValueAbis.noReturnValues); - const returnValue = '0x'; - const decodedReturnValue = method.decodeReturnValues(returnValue, { shouldConvertStructsToObjects: false }); - const expectedDecodedReturnValue: any[] = []; - expect(decodedReturnValue).to.be.deep.equal(expectedDecodedReturnValue); - }); - it('Single static return value', async () => { - // Generate Return Value - const method = new AbiEncoder.Method(ReturnValueAbis.singleStaticReturnValue); - const returnValue = ['0x01020304']; - const encodedReturnValue = method.encodeReturnValues(returnValue, encodingRules); - const decodedReturnValue = method.decodeReturnValues(encodedReturnValue, { - shouldConvertStructsToObjects: false, - }); - // Validate decoded return value - expect(decodedReturnValue).to.be.deep.equal(returnValue); - }); - it('Multiple static return values', async () => { - // Generate Return Value - const method = new AbiEncoder.Method(ReturnValueAbis.multipleStaticReturnValues); - const returnValue = ['0x01020304', '0x05060708']; - const encodedReturnValue = method.encodeReturnValues(returnValue, encodingRules); - const decodedReturnValue = method.decodeReturnValues(encodedReturnValue, { - shouldConvertStructsToObjects: false, - }); - // Validate decoded return value - expect(decodedReturnValue).to.be.deep.equal(returnValue); - }); - it('Single dynamic return value', async () => { - // Generate Return Value - const method = new AbiEncoder.Method(ReturnValueAbis.singleDynamicReturnValue); - const returnValue = ['0x01020304']; - const encodedReturnValue = method.encodeReturnValues(returnValue, encodingRules); - const decodedReturnValue = method.decodeReturnValues(encodedReturnValue, { - shouldConvertStructsToObjects: false, - }); - // Validate decoded return value - expect(decodedReturnValue).to.be.deep.equal(returnValue); - }); - it('Multiple dynamic return values', async () => { - // Generate Return Value - const method = new AbiEncoder.Method(ReturnValueAbis.multipleDynamicReturnValues); - const returnValue = ['0x01020304', '0x05060708']; - const encodedReturnValue = method.encodeReturnValues(returnValue, encodingRules); - const decodedReturnValue = method.decodeReturnValues(encodedReturnValue, { - shouldConvertStructsToObjects: false, - }); - // Validate decoded return value - expect(decodedReturnValue).to.be.deep.equal(returnValue); + const nullEncodedReturnValue = '0x'; + describe('Standard encoding/decoding', () => { + it('No Return Value', async () => { + // Decode return value + const method = new AbiEncoder.Method(ReturnValueAbis.noReturnValues); + const returnValue = '0x'; + const decodedReturnValue = method.decodeReturnValues(returnValue, { shouldConvertStructsToObjects: false }); + const expectedDecodedReturnValue: any[] = []; + expect(decodedReturnValue).to.be.deep.equal(expectedDecodedReturnValue); + }); + it('Single static return value', async () => { + // Generate Return Value + const method = new AbiEncoder.Method(ReturnValueAbis.singleStaticReturnValue); + const returnValue = ['0x01020304']; + const encodedReturnValue = method.encodeReturnValues(returnValue, encodingRules); + const decodedReturnValue = method.decodeReturnValues(encodedReturnValue, { + shouldConvertStructsToObjects: false, + }); + // Validate decoded return value + expect(decodedReturnValue).to.be.deep.equal(returnValue); + }); + it('Multiple static return values', async () => { + // Generate Return Value + const method = new AbiEncoder.Method(ReturnValueAbis.multipleStaticReturnValues); + const returnValue = ['0x01020304', '0x05060708']; + const encodedReturnValue = method.encodeReturnValues(returnValue, encodingRules); + const decodedReturnValue = method.decodeReturnValues(encodedReturnValue, { + shouldConvertStructsToObjects: false, + }); + // Validate decoded return value + expect(decodedReturnValue).to.be.deep.equal(returnValue); + }); + it('Single dynamic return value', async () => { + // Generate Return Value + const method = new AbiEncoder.Method(ReturnValueAbis.singleDynamicReturnValue); + const returnValue = ['0x01020304']; + const encodedReturnValue = method.encodeReturnValues(returnValue, encodingRules); + const decodedReturnValue = method.decodeReturnValues(encodedReturnValue, { + shouldConvertStructsToObjects: false, + }); + // Validate decoded return value + expect(decodedReturnValue).to.be.deep.equal(returnValue); + }); + it('Multiple dynamic return values', async () => { + // Generate Return Value + const method = new AbiEncoder.Method(ReturnValueAbis.multipleDynamicReturnValues); + const returnValue = ['0x01020304', '0x05060708']; + const encodedReturnValue = method.encodeReturnValues(returnValue, encodingRules); + const decodedReturnValue = method.decodeReturnValues(encodedReturnValue, { + shouldConvertStructsToObjects: false, + }); + // Validate decoded return value + expect(decodedReturnValue).to.be.deep.equal(returnValue); + }); + it('Mixed static/dynamic return values', async () => { + // Generate Return Value + const method = new AbiEncoder.Method(ReturnValueAbis.mixedStaticAndDynamicReturnValues); + const returnValue = ['0x01020304', '0x05060708']; + const encodedReturnValue = method.encodeReturnValues(returnValue, encodingRules); + const decodedReturnValue = method.decodeReturnValues(encodedReturnValue, { + shouldConvertStructsToObjects: false, + }); + // Validate decoded return value + expect(decodedReturnValue).to.be.deep.equal(returnValue); + }); + it('Should decode NULL as default value (single; static)', async () => { + // Generate Return Value + const method = new AbiEncoder.Method(ReturnValueAbis.singleStaticReturnValue); + const returnValue = ['0x00000000']; + + const decodedReturnValue = method.decodeReturnValues(nullEncodedReturnValue, { + shouldConvertStructsToObjects: false, + }); + // Validate decoded return value + expect(decodedReturnValue).to.be.deep.equal(returnValue); + }); + it('Should decode NULL as default value (multiple; static)', async () => { + // Generate Return Value + const method = new AbiEncoder.Method(ReturnValueAbis.multipleStaticReturnValues); + const returnValue = ['0x00000000', '0x00000000']; + const decodedReturnValue = method.decodeReturnValues(nullEncodedReturnValue, { + shouldConvertStructsToObjects: false, + }); + // Validate decoded return value + expect(decodedReturnValue).to.be.deep.equal(returnValue); + }); + it('Should decode NULL as default value (single; dynamic)', async () => { + // Generate Return Value + const method = new AbiEncoder.Method(ReturnValueAbis.singleDynamicReturnValue); + const returnValue = ['0x']; + const decodedReturnValue = method.decodeReturnValues(nullEncodedReturnValue, { + shouldConvertStructsToObjects: false, + }); + // Validate decoded return value + expect(decodedReturnValue).to.be.deep.equal(returnValue); + }); }); - it('Mixed static/dynamic return values', async () => { - // Generate Return Value - const method = new AbiEncoder.Method(ReturnValueAbis.mixedStaticAndDynamicReturnValues); - const returnValue = ['0x01020304', '0x05060708']; - const encodedReturnValue = method.encodeReturnValues(returnValue, encodingRules); - const decodedReturnValue = method.decodeReturnValues(encodedReturnValue, { - shouldConvertStructsToObjects: false, - }); - // Validate decoded return value - expect(decodedReturnValue).to.be.deep.equal(returnValue); + + describe('Strict encoding/decoding', () => { + it('No Return Value', async () => { + // Decode return value + const method = new AbiEncoder.Method(ReturnValueAbis.noReturnValues); + const returnValue = '0x'; + const decodedReturnValue = method.strictDecodeReturnValue<void>(returnValue); + const expectedDecodedReturnValue = undefined; + expect(decodedReturnValue).to.be.deep.equal(expectedDecodedReturnValue); + }); + it('Single static return value', async () => { + // Generate Return Value + const method = new AbiEncoder.Method(ReturnValueAbis.singleStaticReturnValue); + const returnValue = ['0x01020304']; + const encodedReturnValue = method.encodeReturnValues(returnValue, encodingRules); + const decodedReturnValue = method.strictDecodeReturnValue<string>(encodedReturnValue); + // Validate decoded return value + expect(decodedReturnValue).to.be.deep.equal(returnValue[0]); + }); + it('Multiple static return values', async () => { + // Generate Return Value + const method = new AbiEncoder.Method(ReturnValueAbis.multipleStaticReturnValues); + const returnValue = ['0x01020304', '0x05060708']; + const encodedReturnValue = method.encodeReturnValues(returnValue, encodingRules); + const decodedReturnValue = method.strictDecodeReturnValue<[string, string]>(encodedReturnValue); + // Validate decoded return value + expect(decodedReturnValue).to.be.deep.equal(returnValue); + }); + it('Single dynamic return value', async () => { + // Generate Return Value + const method = new AbiEncoder.Method(ReturnValueAbis.singleDynamicReturnValue); + const returnValue = ['0x01020304']; + const encodedReturnValue = method.encodeReturnValues(returnValue, encodingRules); + const decodedReturnValue = method.strictDecodeReturnValue<string>(encodedReturnValue); + // Validate decoded return value + expect(decodedReturnValue).to.be.deep.equal(returnValue[0]); + }); + it('Multiple dynamic return values', async () => { + // Generate Return Value + const method = new AbiEncoder.Method(ReturnValueAbis.multipleDynamicReturnValues); + const returnValue = ['0x01020304', '0x05060708']; + const encodedReturnValue = method.encodeReturnValues(returnValue, encodingRules); + const decodedReturnValue = method.strictDecodeReturnValue<[string, string]>(encodedReturnValue); + // Validate decoded return value + expect(decodedReturnValue).to.be.deep.equal(returnValue); + }); + it('Struct should include fields', async () => { + // Generate Return Value + const method = new AbiEncoder.Method(ReturnValueAbis.structuredReturnValue); + const returnValue = { + fillResults: { + makerAssetFilledAmount: new BigNumber(50), + takerAssetFilledAmount: new BigNumber(40), + }, + }; + const encodedReturnValue = method.encodeReturnValues(returnValue, encodingRules); + const decodedReturnValue = method.strictDecodeReturnValue<{ + makerAssetFilledAmount: BigNumber; + takerAssetFilledAmount: BigNumber; + }>(encodedReturnValue); + // Validate decoded return value + // Note that only the contents of `fillResults`, not the key itself, is decoded. + // This is by design, as only a struct's contents are encoded and returned by a funciton call. + expect(decodedReturnValue).to.be.deep.equal(returnValue.fillResults); + }); + it('Should decode NULL as default value (single; static)', async () => { + // Generate Return Value + const method = new AbiEncoder.Method(ReturnValueAbis.singleStaticReturnValue); + const returnValue = '0x00000000'; + const encodedReturnValue = '0x'; + const decodedReturnValue = method.strictDecodeReturnValue<string>(encodedReturnValue); + // Validate decoded return value + expect(decodedReturnValue).to.be.deep.equal(returnValue); + }); + it('Should decode NULL as default value (multiple; static)', async () => { + // Generate Return Value + const method = new AbiEncoder.Method(ReturnValueAbis.multipleStaticReturnValues); + const returnValue = ['0x00000000', '0x00000000']; + const encodedReturnValue = '0x'; + const decodedReturnValue = method.strictDecodeReturnValue<[string, string]>(encodedReturnValue); + // Validate decoded return value + expect(decodedReturnValue).to.be.deep.equal(returnValue); + }); + it('Should decode NULL as default value (single; dynamic)', async () => { + // Generate Return Value + const method = new AbiEncoder.Method(ReturnValueAbis.singleDynamicReturnValue); + const returnValue = '0x'; + const encodedReturnValue = '0x'; + const decodedReturnValue = method.strictDecodeReturnValue<string>(encodedReturnValue); + // Validate decoded return value + expect(decodedReturnValue).to.be.deep.equal(returnValue); + }); }); }); diff --git a/packages/web3-wrapper/CHANGELOG.json b/packages/web3-wrapper/CHANGELOG.json index 8dd98a4ae..49dbe5a64 100644 --- a/packages/web3-wrapper/CHANGELOG.json +++ b/packages/web3-wrapper/CHANGELOG.json @@ -1,5 +1,23 @@ [ { + "version": "4.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ], + "timestamp": 1549547375 + }, + { + "timestamp": 1549452781, + "version": "4.0.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "version": "4.0.0", "changes": [ { diff --git a/packages/web3-wrapper/CHANGELOG.md b/packages/web3-wrapper/CHANGELOG.md index 255b37ade..461d55a26 100644 --- a/packages/web3-wrapper/CHANGELOG.md +++ b/packages/web3-wrapper/CHANGELOG.md @@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v4.0.2 - _February 7, 2019_ + + * Dependencies updated + +## v4.0.1 - _February 6, 2019_ + + * Dependencies updated + ## v4.0.0 - _February 5, 2019_ * Upgrade the bignumber.js to v8.0.2 (#1517) diff --git a/packages/web3-wrapper/package.json b/packages/web3-wrapper/package.json index eab2e6bce..d28a9894f 100644 --- a/packages/web3-wrapper/package.json +++ b/packages/web3-wrapper/package.json @@ -1,6 +1,6 @@ { "name": "@0x/web3-wrapper", - "version": "4.0.0", + "version": "4.0.2", "engines": { "node": ">=6.12" }, @@ -54,10 +54,10 @@ "typescript": "3.0.1" }, "dependencies": { - "@0x/assert": "^2.0.0", - "@0x/json-schemas": "^3.0.0", + "@0x/assert": "^2.0.2", + "@0x/json-schemas": "^3.0.2", "@0x/typescript-typings": "^4.0.0", - "@0x/utils": "^4.0.1", + "@0x/utils": "^4.0.3", "ethereum-types": "^2.0.0", "ethereumjs-util": "^5.1.1", "ethers": "~4.0.4", diff --git a/packages/website/less/all.less b/packages/website/less/all.less index 5d1dccc98..d288b182b 100644 --- a/packages/website/less/all.less +++ b/packages/website/less/all.less @@ -88,13 +88,6 @@ code { color: #1d5cde; // linkBlue } - h1, - h2, - h3, - h4 { - padding-top: 15px; - } - p, blockquote, ol, diff --git a/packages/website/package.json b/packages/website/package.json index 651b0e118..165ce5725 100644 --- a/packages/website/package.json +++ b/packages/website/package.json @@ -1,6 +1,6 @@ { "name": "@0x/website", - "version": "0.0.68", + "version": "0.0.71", "engines": { "node": ">=6.12" }, @@ -20,18 +20,18 @@ "author": "Fabio Berger", "license": "Apache-2.0", "dependencies": { - "@0x/asset-buyer": "^5.0.0", + "@0x/asset-buyer": "^5.0.3", "@0x/contract-addresses": "^2.2.1", - "@0x/contract-wrappers": "^6.0.1", - "@0x/json-schemas": "^3.0.0", - "@0x/order-utils": "^4.0.0", - "@0x/react-docs": "^2.0.0", - "@0x/react-shared": "^2.0.0", - "@0x/subproviders": "^3.0.0", - "@0x/types": "^2.0.0", + "@0x/contract-wrappers": "^7.0.2", + "@0x/json-schemas": "^3.0.2", + "@0x/order-utils": "^6.0.1", + "@0x/react-docs": "^2.0.3", + "@0x/react-shared": "^2.0.3", + "@0x/subproviders": "^3.0.2", + "@0x/types": "^2.0.2", "@0x/typescript-typings": "^4.0.0", - "@0x/utils": "^4.0.1", - "@0x/web3-wrapper": "^4.0.0", + "@0x/utils": "^4.0.3", + "@0x/web3-wrapper": "^4.0.2", "@reach/dialog": "^0.1.2", "@types/react-lazyload": "^2.3.1", "@types/react-loadable": "^5.4.2", @@ -47,7 +47,7 @@ "find-versions": "^2.0.0", "jsonschema": "^1.2.0", "less": "^2.7.2", - "lodash": "^4.17.5", + "lodash": "^4.17.11", "material-ui": "^0.20.0", "moment": "2.21.0", "numeral": "^2.0.6", |