Compare commits

..

66 Commits

Author SHA1 Message Date
Fabio Berger
cd55e346af Move tslint and tslint-eslint-rules to dev deps since this package needs them to function 2018-02-09 18:12:29 -08:00
Fabio Berger
6746428fb1 Update utils in top-level package.json 2018-02-09 16:29:09 -08:00
Fabio Berger
634032d5be Publish
- 0x.js@0.32.2
 - @0xproject/abi-gen@0.2.1
 - @0xproject/assert@0.0.18
 - chai-as-promised-typescript-typings@0.0.9
 - chai-typescript-typings@0.0.3
 - @0xproject/connect@0.5.7
 - contracts@2.1.11
 - @0xproject/deployer@0.0.8
 - @0xproject/dev-utils@0.0.12
 - @0xproject/json-schemas@0.7.10
 - @0xproject/monorepo-scripts@0.1.10
 - @0xproject/subproviders@0.4.1
 - @0xproject/testnet-faucets@1.0.12
 - @0xproject/tslint-config@0.4.8
 - @0xproject/types@0.2.1
 - @0xproject/utils@0.3.2
 - web3-typescript-typings@0.9.10
 - @0xproject/web3-wrapper@0.1.12
 - @0xproject/website@0.0.14
2018-02-09 16:19:43 -08:00
Fabio Berger
602abc53dd Fix version in CHANGELOG 2018-02-09 16:18:47 -08:00
Fabio Berger
fdbaa9768a Update changelog version 2018-02-09 16:09:53 -08:00
Fabio Berger
293d7261e0 Fix changelog version 2018-02-09 16:08:26 -08:00
Fabio Berger
efb6eb28ce Merge pull request #389 from 0xProject/fix/npmInclusionIssues
Fix NPM Inclusion Issues
2018-02-09 14:39:05 -08:00
Fabio Berger
ac5531ce85 Fix changelogs 2018-02-09 14:26:48 -08:00
Fabio Berger
bc2415c70e Add yarn-error.log to all .npmignore 2018-02-09 14:03:08 -08:00
Fabio Berger
0fd411f83f Add PR number to CHANGELOGs 2018-02-09 13:31:01 -08:00
Fabio Berger
b74ad0ad12 ignore all files starting with dots in all sub-packages 2018-02-09 13:28:32 -08:00
Fabio Berger
4c58836735 Remove top level .npmignore 2018-02-09 13:19:30 -08:00
Fabio Berger
3206b80dbd Add npmignore to web3-wrapper and update CHANGELOG 2018-02-09 13:18:49 -08:00
Fabio Berger
4910f7a61e Add npmignore and remove .gitignore 2018-02-09 13:16:16 -08:00
Fabio Berger
6e9109eaec Add npmignore to utils and update CHANGELOG 2018-02-09 13:14:31 -08:00
Fabio Berger
a04ec14cf0 Add npmignore to types and update CHANGELOG 2018-02-09 13:12:33 -08:00
Fabio Berger
7d3df3c117 cleanup npmignorex 2018-02-09 13:09:57 -08:00
Fabio Berger
b3a03f8e3e Add npmignore to subproviders and update CHANGELOG 2018-02-09 13:09:00 -08:00
Fabio Berger
e5668c1e5c Add npmignore to json-schemas and update CHANGELOG 2018-02-09 13:05:21 -08:00
Fabio Berger
92e74bc4fa Add npmignore to dev-utils and update CHANGELOG 2018-02-09 12:56:48 -08:00
Fabio Berger
7e12269baf Add npmignore to deployer along with a changelog 2018-02-09 12:52:12 -08:00
Fabio Berger
f3f264f5fd Add tslint.json to deployer package and fix all tslint issues 2018-02-09 12:50:37 -08:00
Brandon Millman
2e3c9b87df Merge pull request #388 from 0xProject/fix/testnet-faucet/base-unit-orders
Convert to baseUnits in signed order
2018-02-09 12:39:43 -08:00
Fabio Berger
0a113e1cf7 Add npmignore to subpackage and update CHANGELOG 2018-02-09 12:37:28 -08:00
Fabio Berger
fd772c48cf Add npmignore to typings packages 2018-02-09 12:37:18 -08:00
Fabio Berger
1c7dce6054 Add npmignore to subpackage and update CHANGELOG 2018-02-09 12:30:06 -08:00
Jacob Evans
0a2947b860 address is not optional in this context 2018-02-09 12:27:28 -08:00
Fabio Berger
c80877af43 Add npmignore to abi-gen and update CHANGELOG 2018-02-09 12:23:03 -08:00
Jacob Evans
e68b9c7e81 Convert to baseUnits in signed order 2018-02-09 12:20:25 -08:00
Fabio Berger
19198737a5 Add correct npmignore to 0x.js and update CHANGELOG 2018-02-09 12:18:23 -08:00
Brandon Millman
fea4b6aecd Merge pull request #387 from 0xProject/fix/testnet-faucet/ecsignature
Testnet Faucet Order conforming to JSON Schema
2018-02-09 12:01:59 -08:00
Fabio Berger
20e2673b82 Fix issue where custom TSLint rules were not being published to NPM 2018-02-09 11:53:38 -08:00
Jacob Evans
ef1375b9dd signature -> ecSignature 2018-02-09 10:50:38 -08:00
Brandon Millman
58f1939ec1 Merge pull request #382 from 0xProject/feature/clean-post-publish-scripts
Simplify standard postpublish script and remove them from some privat…
2018-02-09 10:19:33 -08:00
Leonid
936f6ac10f Merge pull request #379 from 0xProject/portal_json
Make portal order JSON compatible with 0x.js
2018-02-09 09:27:08 +01:00
Fabio Berger
7e04c4f24b Merge pull request #383 from 0xProject/fix/website/addMoreRelayersLanding
Add relayers section to landing page
2018-02-08 18:41:16 -08:00
Fabio Berger
9495c8f46c Fix links 2018-02-08 18:40:06 -08:00
Fabio Berger
b3f91600d3 Center header above relayers 2018-02-08 17:53:31 -08:00
Fabio Berger
ddf4437fb6 Add blog to topBar and as a consequence support external links in topBar menu items 2018-02-08 17:36:17 -08:00
Fabio Berger
4153d57849 Add title above "benefits" section 2018-02-08 16:27:47 -08:00
Fabio Berger
0652790703 Add Relayer section to landing 2018-02-08 16:27:37 -08:00
Brandon Millman
9c934d903d Add new entries to the PR template checklist 2018-02-08 16:20:02 -08:00
Brandon Millman
d7a7e28925 Fix missing references to 'this' 2018-02-08 12:02:13 -08:00
Brandon Millman
6dec29e214 Simplify standard postpublish script and remove them from some private packages 2018-02-08 11:46:33 -08:00
Leonid Logvinov
43cf8d30bd Implement blockchain.portalOrderToZeroExOrder 2018-02-08 18:28:54 +01:00
Leonid
254d3f53e2 Merge pull request #377 from 0xProject/feature/signed_unsigned_order_contracts
Use SignedOrder and Order types from 0x.js
2018-02-08 18:15:10 +01:00
Leonid Logvinov
ec198343b5 Make naming of schemas consistent 2018-02-08 18:14:52 +01:00
Leonid Logvinov
876517d458 Fix namings 2018-02-08 18:03:55 +01:00
Leonid Logvinov
1233c33116 Address feedback 2018-02-08 16:23:20 +01:00
Fabio Berger
eebf205817 Fix flash message when receiving test ether 2018-02-07 16:58:05 -08:00
Brandon Millman
e666bb44c6 Fix incorrect network ids 2018-02-07 16:05:14 -08:00
Brandon Millman
39cb0b5122 Update @0xproject/utils version in top level package.json 2018-02-07 13:36:48 -08:00
Leonid Logvinov
8fba0477a6 Remove hash from signatureData 2018-02-07 20:58:19 +01:00
Leonid Logvinov
e6f2c7a382 Remove networkId from orderJSON 2018-02-07 20:38:30 +01:00
Leonid Logvinov
69f5f5e946 Split Order into signedOrder and metadata 2018-02-07 20:26:13 +01:00
Leonid Logvinov
ae14b0a71d Reuse ECSignature 2018-02-07 16:13:09 +01:00
Leonid Logvinov
3c7ebe2697 Remove unused types and take their names 2018-02-07 16:11:51 +01:00
Leonid Logvinov
10fb6061cc Introduce makerToken and takerToken fields for unsigned token metadata 2018-02-07 15:26:53 +01:00
Leonid Logvinov
223df8006a Move .taker.amount to .takerTokenAmount and .maker.amount to .makerTokenAmount 2018-02-07 15:09:06 +01:00
Leonid Logvinov
1c9428cbba Move .taker.feeAmount to .takerFee and .maker.feeAmount to .makerFee 2018-02-07 15:02:41 +01:00
Leonid Logvinov
18dc5d17b5 Rename signature to ecSignature 2018-02-07 14:54:37 +01:00
Leonid Logvinov
4d50933189 Rename exchangeContract to exchangeContractAddress 2018-02-07 14:48:59 +01:00
Leonid Logvinov
9b3680780f Rename expiration to expirationUnixTimestampSec 2018-02-07 14:41:40 +01:00
Leonid Logvinov
568e4d33f2 Use Order and SignedOrder type from 0x.js 2018-02-07 13:41:30 +01:00
Leonid Logvinov
fd004032cb Introduce SignedOrder class and remove type assertions 2018-02-07 12:22:22 +01:00
Leonid Logvinov
4b6324050d Make orderHashHex a getter instead of a property 2018-02-07 11:59:40 +01:00
122 changed files with 1134 additions and 1473 deletions

View File

@@ -1,6 +0,0 @@
.*
tsconfig.json
tslint.json
webpack.config.js
yarn.lock
docs

View File

@@ -36,3 +36,7 @@
* [ ] Change requires a change to the documentation.
* [ ] Added tests to cover my changes.
* [ ] Added new entries to the relevant CHANGELOGs.
* [ ] Updated the new versions of the changed packages in the relevant CHANGELOGs.
* [ ] Labeled this PR with the 'WIP' label if it is a work in progress.
* [ ] Labeled this PR with the labels corresponding to the changed package.

View File

@@ -16,7 +16,7 @@
"mnemonic": "concert load couple harbor equip island argue ramp clarify fence smart topic"
},
"devDependencies": {
"@0xproject/utils": "^0.3.0",
"@0xproject/utils": "^0.3.2",
"async-child-process": "^1.1.1",
"ethereumjs-testrpc": "^6.0.3",
"lerna": "^2.5.1",

10
packages/0x.js/.npmignore Normal file
View File

@@ -0,0 +1,10 @@
.*
tsconfig.json
webpack.config.js
yarn-error.log
test/
/src/
/_bundles/
/contract_templates/
/generated_docs/
/scripts/

View File

@@ -1,5 +1,9 @@
# CHANGELOG
## v0.32.2 - _February 9, 2018_
* Fix publishing issue where .npmignore was not properly excluding undesired content (#389)
## v0.32.1 - _February 7, 2018_
* Reorganized `BlockParamLiteral` export into `@0xproject/types` package (#355)

View File

@@ -1,6 +1,6 @@
{
"name": "0x.js",
"version": "0.32.1",
"version": "0.32.2",
"description": "A javascript library for interacting with the 0x protocol",
"keywords": [
"0x.js",
@@ -42,9 +42,9 @@
"node": ">=6.0.0"
},
"devDependencies": {
"@0xproject/abi-gen": "^0.2.0",
"@0xproject/dev-utils": "^0.0.11",
"@0xproject/tslint-config": "^0.4.7",
"@0xproject/abi-gen": "^0.2.1",
"@0xproject/dev-utils": "^0.0.12",
"@0xproject/tslint-config": "^0.4.8",
"@types/bintrees": "^1.0.2",
"@types/jsonschema": "^1.1.1",
"@types/lodash": "^4.14.86",
@@ -55,9 +55,9 @@
"awesome-typescript-loader": "^3.1.3",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"chai-as-promised-typescript-typings": "^0.0.8",
"chai-as-promised-typescript-typings": "^0.0.9",
"chai-bignumber": "^2.0.1",
"chai-typescript-typings": "^0.0.2",
"chai-typescript-typings": "^0.0.3",
"copyfiles": "^1.2.0",
"coveralls": "^3.0.0",
"dirty-chai": "^2.0.1",
@@ -77,15 +77,15 @@
"types-bn": "^0.0.1",
"typescript": "2.7.1",
"web3-provider-engine": "^13.0.1",
"web3-typescript-typings": "^0.9.9",
"web3-typescript-typings": "^0.9.10",
"webpack": "^3.1.0"
},
"dependencies": {
"@0xproject/assert": "^0.0.17",
"@0xproject/json-schemas": "^0.7.9",
"@0xproject/types": "^0.2.0",
"@0xproject/utils": "^0.3.1",
"@0xproject/web3-wrapper": "^0.1.11",
"@0xproject/assert": "^0.0.18",
"@0xproject/json-schemas": "^0.7.10",
"@0xproject/types": "^0.2.1",
"@0xproject/utils": "^0.3.2",
"@0xproject/web3-wrapper": "^0.1.12",
"bintrees": "^1.0.2",
"bn.js": "^4.11.8",
"ethereumjs-abi": "^0.6.4",

View File

@@ -15,7 +15,7 @@ postpublish_utils
version = result.version;
const releaseName = postpublish_utils.getReleaseName(subPackageName, version);
const assets = [__dirname + '/../_bundles/index.js', __dirname + '/../_bundles/index.min.js'];
return postpublish_utils.publishReleaseNotes(tag, releaseName, assets);
return postpublish_utils.publishReleaseNotesAsync(tag, releaseName, assets);
})
.then(function(release) {
console.log('POSTPUBLISH: Release successful, generating docs...');

View File

@@ -0,0 +1,5 @@
.*
yarn-error.log
/src/
/scripts/
tsconfig.json

View File

@@ -1,12 +1,16 @@
# CHANGELOG
## v0.2.1 - _February 9, 2018_
* Fix publishing issue where .npmignore was not properly excluding undesired content (#389)
## v0.2.0 - _February 7, 2018_
* Added CLI options for explicit specifying location of partials and main template (#346)
* Added CLI option to specify networkId, adding support for the JSON artifact format found in @0xproject/contracts (#388)
* Added CLI options for explicit specifying location of partials and main template (#346)
* Added CLI option to specify networkId, adding support for the JSON artifact format found in @0xproject/contracts (#388)
## v0.1.0 - _January 11, 2018_
* Fixed array typings with union types (#295)
* Add event ABIs to context data passed to templates (#302)
* Add constructor ABIs to context data passed to templates (#304)
* Fixed array typings with union types (#295)
* Add event ABIs to context data passed to templates (#302)
* Add constructor ABIs to context data passed to templates (#304)

View File

@@ -1,6 +1,6 @@
{
"name": "@0xproject/abi-gen",
"version": "0.2.0",
"version": "0.2.1",
"description": "Generate contract wrappers from ABI and handlebars templates",
"main": "lib/index.js",
"types": "lib/index.d.ts",
@@ -23,7 +23,7 @@
},
"homepage": "https://github.com/0xProject/0x.js/packages/abi-gen/README.md",
"dependencies": {
"@0xproject/utils": "^0.3.1",
"@0xproject/utils": "^0.3.2",
"chalk": "^2.3.0",
"glob": "^7.1.2",
"handlebars": "^4.0.11",
@@ -34,7 +34,7 @@
"yargs": "^10.0.3"
},
"devDependencies": {
"@0xproject/tslint-config": "^0.4.7",
"@0xproject/tslint-config": "^0.4.8",
"@types/glob": "^5.0.33",
"@types/handlebars": "^4.0.36",
"@types/mkdirp": "^0.5.1",
@@ -44,6 +44,6 @@
"shx": "^0.2.2",
"tslint": "5.8.0",
"typescript": "2.7.1",
"web3-typescript-typings": "^0.9.9"
"web3-typescript-typings": "^0.9.10"
}
}

View File

@@ -2,14 +2,4 @@ const postpublish_utils = require('../../../scripts/postpublish_utils');
const packageJSON = require('../package.json');
const subPackageName = packageJSON.name;
postpublish_utils
.getLatestTagAndVersionAsync(subPackageName)
.then(function(result) {
const releaseName = postpublish_utils.getReleaseName(subPackageName, result.version);
const assets = [];
return postpublish_utils.publishReleaseNotes(result.tag, releaseName, assets);
})
.catch(function(err) {
throw err;
});
postpublish_utils.standardPostPublishAsync(subPackageName);

View File

@@ -0,0 +1,6 @@
.*
yarn-error.log
/src/
/scripts/
test/
tsconfig.json

View File

@@ -1,6 +1,10 @@
# CHANGELOG
## v0.0.4 - _Nov. 14, 2017_
## v0.0.18 - _February 9, 2017_
* Fix publishing issue where .npmignore was not properly excluding undesired content (#389)
## v0.0.4 - _November 14, 2017_
* Re-publish Assert previously published under NPM package @0xproject/0x-assert
* Added assertion isValidBaseUnitAmount which checks both that the value is a valid bigNumber and that it does not contain decimals.

View File

@@ -1,6 +1,6 @@
{
"name": "@0xproject/assert",
"version": "0.0.17",
"version": "0.0.18",
"description": "Provides a standard way of performing type and schema validation across 0x projects",
"main": "lib/src/index.js",
"types": "lib/src/index.d.ts",
@@ -24,12 +24,12 @@
},
"homepage": "https://github.com/0xProject/0x.js/packages/assert/README.md",
"devDependencies": {
"@0xproject/tslint-config": "^0.4.7",
"@0xproject/tslint-config": "^0.4.8",
"@types/lodash": "^4.14.86",
"@types/mocha": "^2.2.42",
"@types/valid-url": "^1.0.2",
"chai": "^4.0.1",
"chai-typescript-typings": "^0.0.2",
"chai-typescript-typings": "^0.0.3",
"dirty-chai": "^2.0.1",
"mocha": "^4.0.1",
"npm-run-all": "^4.1.2",
@@ -38,8 +38,8 @@
"typescript": "2.7.1"
},
"dependencies": {
"@0xproject/json-schemas": "^0.7.9",
"@0xproject/utils": "^0.3.1",
"@0xproject/json-schemas": "^0.7.10",
"@0xproject/utils": "^0.3.2",
"lodash": "^4.17.4",
"valid-url": "^1.0.9"
}

View File

@@ -2,14 +2,4 @@ const postpublish_utils = require('../../../scripts/postpublish_utils');
const packageJSON = require('../package.json');
const subPackageName = packageJSON.name;
postpublish_utils
.getLatestTagAndVersionAsync(subPackageName)
.then(function(result) {
const releaseName = postpublish_utils.getReleaseName(subPackageName, result.version);
const assets = [];
return postpublish_utils.publishReleaseNotes(result.tag, releaseName, assets);
})
.catch(function(err) {
throw err;
});
postpublish_utils.standardPostPublishAsync(subPackageName);

View File

@@ -0,0 +1,3 @@
.*
yarn-error.log
/scripts/

View File

@@ -1,6 +1,6 @@
{
"name": "chai-as-promised-typescript-typings",
"version": "0.0.8",
"version": "0.0.9",
"description": "Typescript type definitions for chai-as-promised",
"main": "index.d.ts",
"types": "index.d.ts",
@@ -18,6 +18,6 @@
},
"homepage": "https://github.com/0xProject/0x.js/packages/chai-as-promised-typescript-typings#readme",
"dependencies": {
"chai-typescript-typings": "^0.0.2"
"chai-typescript-typings": "^0.0.3"
}
}

View File

@@ -2,14 +2,4 @@ const postpublish_utils = require('../../../scripts/postpublish_utils');
const packageJSON = require('../package.json');
const subPackageName = packageJSON.name;
postpublish_utils
.getLatestTagAndVersionAsync(subPackageName)
.then(function(result) {
const releaseName = postpublish_utils.getReleaseName(subPackageName, result.version);
const assets = [];
return postpublish_utils.publishReleaseNotes(result.tag, releaseName, assets);
})
.catch(function(err) {
throw err;
});
postpublish_utils.standardPostPublishAsync(subPackageName);

View File

@@ -0,0 +1,3 @@
.*
yarn-error.log
/scripts/

View File

@@ -1,6 +1,6 @@
{
"name": "chai-typescript-typings",
"version": "0.0.2",
"version": "0.0.3",
"description": "Typescript type definitions for chai",
"main": "index.d.ts",
"types": "index.d.ts",

View File

@@ -2,14 +2,4 @@ const postpublish_utils = require('../../../scripts/postpublish_utils');
const packageJSON = require('../package.json');
const subPackageName = packageJSON.name;
postpublish_utils
.getLatestTagAndVersionAsync(subPackageName)
.then(function(result) {
const releaseName = postpublish_utils.getReleaseName(subPackageName, result.version);
const assets = [];
return postpublish_utils.publishReleaseNotes(result.tag, releaseName, assets);
})
.catch(function(err) {
throw err;
});
postpublish_utils.standardPostPublishAsync(subPackageName);

View File

@@ -0,0 +1,7 @@
.*
yarn-error.log
/src/
/scripts/
/generated_docs/
test/
tsconfig.json

View File

@@ -1,5 +1,9 @@
# CHANGELOG
## v0.5.7 - _February 9, 2018_
* Fix publishing issue where .npmignore was not properly excluding undesired content (#389)
## v0.5.0 - _January 17, 2018_
* Sanitize api endpoint url and remove trailing slashes (#318)

View File

@@ -1,6 +1,6 @@
{
"name": "@0xproject/connect",
"version": "0.5.6",
"version": "0.5.7",
"description": "A javascript library for interacting with the standard relayer api",
"keywords": [
"connect",
@@ -37,16 +37,16 @@
},
"homepage": "https://github.com/0xProject/0x.js/packages/connect/README.md",
"dependencies": {
"@0xproject/assert": "^0.0.17",
"@0xproject/json-schemas": "^0.7.9",
"@0xproject/utils": "^0.3.1",
"@0xproject/assert": "^0.0.18",
"@0xproject/json-schemas": "^0.7.10",
"@0xproject/utils": "^0.3.2",
"isomorphic-fetch": "^2.2.1",
"lodash": "^4.17.4",
"query-string": "^5.0.1",
"websocket": "^1.0.25"
},
"devDependencies": {
"@0xproject/tslint-config": "^0.4.7",
"@0xproject/tslint-config": "^0.4.8",
"@types/fetch-mock": "^5.12.1",
"@types/lodash": "^4.14.86",
"@types/mocha": "^2.2.42",
@@ -54,8 +54,8 @@
"@types/websocket": "^0.0.34",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"chai-as-promised-typescript-typings": "^0.0.8",
"chai-typescript-typings": "^0.0.2",
"chai-as-promised-typescript-typings": "^0.0.9",
"chai-typescript-typings": "^0.0.3",
"copyfiles": "^1.2.0",
"dirty-chai": "^2.0.1",
"fetch-mock": "^5.13.1",
@@ -65,6 +65,6 @@
"tslint": "5.8.0",
"typedoc": "~0.8.0",
"typescript": "2.7.1",
"web3-typescript-typings": "^0.9.9"
"web3-typescript-typings": "^0.9.10"
}
}

View File

@@ -1,7 +1,7 @@
{
"private": true,
"name": "contracts",
"version": "2.1.10",
"version": "2.1.11",
"description": "Smart contract components of 0x protocol",
"main": "index.js",
"directories": {
@@ -33,9 +33,9 @@
},
"homepage": "https://github.com/0xProject/0x.js/packages/contracts/README.md",
"devDependencies": {
"@0xproject/dev-utils": "^0.0.11",
"@0xproject/tslint-config": "^0.4.7",
"@0xproject/types": "^0.2.0",
"@0xproject/dev-utils": "^0.0.12",
"@0xproject/tslint-config": "^0.4.8",
"@0xproject/types": "^0.2.1",
"@types/bluebird": "^3.5.3",
"@types/lodash": "^4.14.86",
"@types/node": "^8.0.53",
@@ -43,9 +43,9 @@
"@types/yargs": "^10.0.0",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"chai-as-promised-typescript-typings": "^0.0.8",
"chai-as-promised-typescript-typings": "^0.0.9",
"chai-bignumber": "^2.0.1",
"chai-typescript-typings": "^0.0.2",
"chai-typescript-typings": "^0.0.3",
"copyfiles": "^1.2.0",
"dirty-chai": "^2.0.1",
"mocha": "^4.0.1",
@@ -55,15 +55,15 @@
"types-bn": "^0.0.1",
"types-ethereumjs-util": "0xProject/types-ethereumjs-util",
"typescript": "2.7.1",
"web3-typescript-typings": "^0.9.9",
"web3-typescript-typings": "^0.9.10",
"yargs": "^10.0.3"
},
"dependencies": {
"0x.js": "^0.32.1",
"@0xproject/deployer": "^0.0.7",
"@0xproject/json-schemas": "^0.7.9",
"@0xproject/utils": "^0.3.1",
"@0xproject/web3-wrapper": "^0.1.11",
"0x.js": "^0.32.2",
"@0xproject/deployer": "^0.0.8",
"@0xproject/json-schemas": "^0.7.10",
"@0xproject/utils": "^0.3.2",
"@0xproject/web3-wrapper": "^0.1.12",
"bluebird": "^3.5.0",
"bn.js": "^4.11.8",
"ethereumjs-abi": "^0.6.4",

View File

@@ -3,6 +3,7 @@ import {
LogErrorContractEventArgs,
LogFillContractEventArgs,
LogWithDecodedArgs,
SignedOrder,
TransactionReceiptWithDecodedLogs,
ZeroEx,
} from '0x.js';
@@ -20,7 +21,6 @@ import { Balances } from '../../util/balances';
import { constants } from '../../util/constants';
import { crypto } from '../../util/crypto';
import { ExchangeWrapper } from '../../util/exchange_wrapper';
import { Order } from '../../util/order';
import { OrderFactory } from '../../util/order_factory';
import { BalancesByOwner, ContractName, ExchangeContractErrs } from '../../util/types';
import { chaiSetup } from '../utils/chai_setup';
@@ -46,7 +46,7 @@ describe('Exchange', () => {
let exchange: ExchangeContract;
let tokenTransferProxy: TokenTransferProxyContract;
let order: Order;
let signedOrder: SignedOrder;
let balances: BalancesByOwner;
let exWrapper: ExchangeWrapper;
let dmyBalances: Balances;
@@ -84,14 +84,14 @@ describe('Exchange', () => {
exchangeContractAddress: exchange.address,
maker,
feeRecipient,
makerToken: rep.address,
takerToken: dgd.address,
makerTokenAddress: rep.address,
takerTokenAddress: dgd.address,
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
makerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18),
takerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18),
};
orderFactory = new OrderFactory(web3Wrapper, defaultOrderParams);
orderFactory = new OrderFactory(zeroEx, defaultOrderParams);
dmyBalances = new Balances([rep, dgd, zrx], [maker, taker, feeRecipient]);
await Promise.all([
rep.approve.sendTransactionAsync(tokenTransferProxy.address, INITIAL_ALLOWANCE, {
@@ -147,80 +147,85 @@ describe('Exchange', () => {
describe('fillOrder', () => {
beforeEach(async () => {
balances = await dmyBalances.getAsync();
order = await orderFactory.newSignedOrderAsync();
signedOrder = await orderFactory.newSignedOrderAsync();
});
it('should create an unfillable order', async () => {
order = await orderFactory.newSignedOrderAsync({
signedOrder = await orderFactory.newSignedOrderAsync({
makerTokenAmount: new BigNumber(1001),
takerTokenAmount: new BigNumber(3),
});
const filledTakerTokenAmountBefore = await zeroEx.exchange.getFilledTakerAmountAsync(order.params
.orderHashHex as string);
const filledTakerTokenAmountBefore = await zeroEx.exchange.getFilledTakerAmountAsync(
ZeroEx.getOrderHashHex(signedOrder),
);
expect(filledTakerTokenAmountBefore).to.be.bignumber.equal(0);
const fillTakerTokenAmount1 = new BigNumber(2);
await exWrapper.fillOrderAsync(order, taker, {
await exWrapper.fillOrderAsync(signedOrder, taker, {
fillTakerTokenAmount: fillTakerTokenAmount1,
});
const filledTakerTokenAmountAfter1 = await zeroEx.exchange.getFilledTakerAmountAsync(order.params
.orderHashHex as string);
const filledTakerTokenAmountAfter1 = await zeroEx.exchange.getFilledTakerAmountAsync(
ZeroEx.getOrderHashHex(signedOrder),
);
expect(filledTakerTokenAmountAfter1).to.be.bignumber.equal(fillTakerTokenAmount1);
const fillTakerTokenAmount2 = new BigNumber(1);
await exWrapper.fillOrderAsync(order, taker, {
await exWrapper.fillOrderAsync(signedOrder, taker, {
fillTakerTokenAmount: fillTakerTokenAmount2,
});
const filledTakerTokenAmountAfter2 = await zeroEx.exchange.getFilledTakerAmountAsync(order.params
.orderHashHex as string);
const filledTakerTokenAmountAfter2 = await zeroEx.exchange.getFilledTakerAmountAsync(
ZeroEx.getOrderHashHex(signedOrder),
);
expect(filledTakerTokenAmountAfter2).to.be.bignumber.equal(filledTakerTokenAmountAfter1);
});
it('should transfer the correct amounts when makerTokenAmount === takerTokenAmount', async () => {
order = await orderFactory.newSignedOrderAsync({
signedOrder = await orderFactory.newSignedOrderAsync({
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
});
const filledTakerTokenAmountBefore = await zeroEx.exchange.getFilledTakerAmountAsync(order.params
.orderHashHex as string);
const filledTakerTokenAmountBefore = await zeroEx.exchange.getFilledTakerAmountAsync(
ZeroEx.getOrderHashHex(signedOrder),
);
expect(filledTakerTokenAmountBefore).to.be.bignumber.equal(0);
const fillTakerTokenAmount = order.params.takerTokenAmount.div(2);
await exWrapper.fillOrderAsync(order, taker, { fillTakerTokenAmount });
const fillTakerTokenAmount = signedOrder.takerTokenAmount.div(2);
await exWrapper.fillOrderAsync(signedOrder, taker, { fillTakerTokenAmount });
const filledTakerTokenAmountAfter = await zeroEx.exchange.getFilledTakerAmountAsync(order.params
.orderHashHex as string);
const filledTakerTokenAmountAfter = await zeroEx.exchange.getFilledTakerAmountAsync(
ZeroEx.getOrderHashHex(signedOrder),
);
expect(filledTakerTokenAmountAfter).to.be.bignumber.equal(fillTakerTokenAmount);
const newBalances = await dmyBalances.getAsync();
const fillMakerTokenAmount = fillTakerTokenAmount
.times(order.params.makerTokenAmount)
.dividedToIntegerBy(order.params.takerTokenAmount);
const paidMakerFee = order.params.makerFee
.times(signedOrder.makerTokenAmount)
.dividedToIntegerBy(signedOrder.takerTokenAmount);
const paidMakerFee = signedOrder.makerFee
.times(fillMakerTokenAmount)
.dividedToIntegerBy(order.params.makerTokenAmount);
const paidTakerFee = order.params.takerFee
.dividedToIntegerBy(signedOrder.makerTokenAmount);
const paidTakerFee = signedOrder.takerFee
.times(fillMakerTokenAmount)
.dividedToIntegerBy(order.params.makerTokenAmount);
expect(newBalances[maker][order.params.makerToken]).to.be.bignumber.equal(
balances[maker][order.params.makerToken].minus(fillMakerTokenAmount),
.dividedToIntegerBy(signedOrder.makerTokenAmount);
expect(newBalances[maker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
balances[maker][signedOrder.makerTokenAddress].minus(fillMakerTokenAmount),
);
expect(newBalances[maker][order.params.takerToken]).to.be.bignumber.equal(
balances[maker][order.params.takerToken].add(fillTakerTokenAmount),
expect(newBalances[maker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
balances[maker][signedOrder.takerTokenAddress].add(fillTakerTokenAmount),
);
expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(
balances[maker][zrx.address].minus(paidMakerFee),
);
expect(newBalances[taker][order.params.takerToken]).to.be.bignumber.equal(
balances[taker][order.params.takerToken].minus(fillTakerTokenAmount),
expect(newBalances[taker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
balances[taker][signedOrder.takerTokenAddress].minus(fillTakerTokenAmount),
);
expect(newBalances[taker][order.params.makerToken]).to.be.bignumber.equal(
balances[taker][order.params.makerToken].add(fillMakerTokenAmount),
expect(newBalances[taker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
balances[taker][signedOrder.makerTokenAddress].add(fillMakerTokenAmount),
);
expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(
balances[taker][zrx.address].minus(paidTakerFee),
@@ -231,47 +236,49 @@ describe('Exchange', () => {
});
it('should transfer the correct amounts when makerTokenAmount > takerTokenAmount', async () => {
order = await orderFactory.newSignedOrderAsync({
signedOrder = await orderFactory.newSignedOrderAsync({
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
});
const filledTakerTokenAmountBefore = await zeroEx.exchange.getFilledTakerAmountAsync(order.params
.orderHashHex as string);
const filledTakerTokenAmountBefore = await zeroEx.exchange.getFilledTakerAmountAsync(
ZeroEx.getOrderHashHex(signedOrder),
);
expect(filledTakerTokenAmountBefore).to.be.bignumber.equal(0);
const fillTakerTokenAmount = order.params.takerTokenAmount.div(2);
await exWrapper.fillOrderAsync(order, taker, { fillTakerTokenAmount });
const fillTakerTokenAmount = signedOrder.takerTokenAmount.div(2);
await exWrapper.fillOrderAsync(signedOrder, taker, { fillTakerTokenAmount });
const filledTakerTokenAmountAfter = await zeroEx.exchange.getFilledTakerAmountAsync(order.params
.orderHashHex as string);
const filledTakerTokenAmountAfter = await zeroEx.exchange.getFilledTakerAmountAsync(
ZeroEx.getOrderHashHex(signedOrder),
);
expect(filledTakerTokenAmountAfter).to.be.bignumber.equal(fillTakerTokenAmount);
const newBalances = await dmyBalances.getAsync();
const fillMakerTokenAmount = fillTakerTokenAmount
.times(order.params.makerTokenAmount)
.dividedToIntegerBy(order.params.takerTokenAmount);
const paidMakerFee = order.params.makerFee
.times(signedOrder.makerTokenAmount)
.dividedToIntegerBy(signedOrder.takerTokenAmount);
const paidMakerFee = signedOrder.makerFee
.times(fillMakerTokenAmount)
.dividedToIntegerBy(order.params.makerTokenAmount);
const paidTakerFee = order.params.takerFee
.dividedToIntegerBy(signedOrder.makerTokenAmount);
const paidTakerFee = signedOrder.takerFee
.times(fillMakerTokenAmount)
.dividedToIntegerBy(order.params.makerTokenAmount);
expect(newBalances[maker][order.params.makerToken]).to.be.bignumber.equal(
balances[maker][order.params.makerToken].minus(fillMakerTokenAmount),
.dividedToIntegerBy(signedOrder.makerTokenAmount);
expect(newBalances[maker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
balances[maker][signedOrder.makerTokenAddress].minus(fillMakerTokenAmount),
);
expect(newBalances[maker][order.params.takerToken]).to.be.bignumber.equal(
balances[maker][order.params.takerToken].add(fillTakerTokenAmount),
expect(newBalances[maker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
balances[maker][signedOrder.takerTokenAddress].add(fillTakerTokenAmount),
);
expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(
balances[maker][zrx.address].minus(paidMakerFee),
);
expect(newBalances[taker][order.params.takerToken]).to.be.bignumber.equal(
balances[taker][order.params.takerToken].minus(fillTakerTokenAmount),
expect(newBalances[taker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
balances[taker][signedOrder.takerTokenAddress].minus(fillTakerTokenAmount),
);
expect(newBalances[taker][order.params.makerToken]).to.be.bignumber.equal(
balances[taker][order.params.makerToken].add(fillMakerTokenAmount),
expect(newBalances[taker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
balances[taker][signedOrder.makerTokenAddress].add(fillMakerTokenAmount),
);
expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(
balances[taker][zrx.address].minus(paidTakerFee),
@@ -282,47 +289,49 @@ describe('Exchange', () => {
});
it('should transfer the correct amounts when makerTokenAmount < takerTokenAmount', async () => {
order = await orderFactory.newSignedOrderAsync({
signedOrder = await orderFactory.newSignedOrderAsync({
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
});
const filledTakerTokenAmountBefore = await zeroEx.exchange.getFilledTakerAmountAsync(order.params
.orderHashHex as string);
const filledTakerTokenAmountBefore = await zeroEx.exchange.getFilledTakerAmountAsync(
ZeroEx.getOrderHashHex(signedOrder),
);
expect(filledTakerTokenAmountBefore).to.be.bignumber.equal(0);
const fillTakerTokenAmount = order.params.takerTokenAmount.div(2);
await exWrapper.fillOrderAsync(order, taker, { fillTakerTokenAmount });
const fillTakerTokenAmount = signedOrder.takerTokenAmount.div(2);
await exWrapper.fillOrderAsync(signedOrder, taker, { fillTakerTokenAmount });
const filledTakerTokenAmountAfter = await zeroEx.exchange.getFilledTakerAmountAsync(order.params
.orderHashHex as string);
const filledTakerTokenAmountAfter = await zeroEx.exchange.getFilledTakerAmountAsync(
ZeroEx.getOrderHashHex(signedOrder),
);
expect(filledTakerTokenAmountAfter).to.be.bignumber.equal(fillTakerTokenAmount);
const newBalances = await dmyBalances.getAsync();
const fillMakerTokenAmount = fillTakerTokenAmount
.times(order.params.makerTokenAmount)
.dividedToIntegerBy(order.params.takerTokenAmount);
const paidMakerFee = order.params.makerFee
.times(signedOrder.makerTokenAmount)
.dividedToIntegerBy(signedOrder.takerTokenAmount);
const paidMakerFee = signedOrder.makerFee
.times(fillMakerTokenAmount)
.dividedToIntegerBy(order.params.makerTokenAmount);
const paidTakerFee = order.params.takerFee
.dividedToIntegerBy(signedOrder.makerTokenAmount);
const paidTakerFee = signedOrder.takerFee
.times(fillMakerTokenAmount)
.dividedToIntegerBy(order.params.makerTokenAmount);
expect(newBalances[maker][order.params.makerToken]).to.be.bignumber.equal(
balances[maker][order.params.makerToken].minus(fillMakerTokenAmount),
.dividedToIntegerBy(signedOrder.makerTokenAmount);
expect(newBalances[maker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
balances[maker][signedOrder.makerTokenAddress].minus(fillMakerTokenAmount),
);
expect(newBalances[maker][order.params.takerToken]).to.be.bignumber.equal(
balances[maker][order.params.takerToken].add(fillTakerTokenAmount),
expect(newBalances[maker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
balances[maker][signedOrder.takerTokenAddress].add(fillTakerTokenAmount),
);
expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(
balances[maker][zrx.address].minus(paidMakerFee),
);
expect(newBalances[taker][order.params.takerToken]).to.be.bignumber.equal(
balances[taker][order.params.takerToken].minus(fillTakerTokenAmount),
expect(newBalances[taker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
balances[taker][signedOrder.takerTokenAddress].minus(fillTakerTokenAmount),
);
expect(newBalances[taker][order.params.makerToken]).to.be.bignumber.equal(
balances[taker][order.params.makerToken].add(fillMakerTokenAmount),
expect(newBalances[taker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
balances[taker][signedOrder.makerTokenAddress].add(fillMakerTokenAmount),
);
expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(
balances[taker][zrx.address].minus(paidTakerFee),
@@ -333,49 +342,51 @@ describe('Exchange', () => {
});
it('should transfer the correct amounts when taker is specified and order is claimed by taker', async () => {
order = await orderFactory.newSignedOrderAsync({
signedOrder = await orderFactory.newSignedOrderAsync({
taker,
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
});
const filledTakerTokenAmountBefore = await zeroEx.exchange.getFilledTakerAmountAsync(order.params
.orderHashHex as string);
const filledTakerTokenAmountBefore = await zeroEx.exchange.getFilledTakerAmountAsync(
ZeroEx.getOrderHashHex(signedOrder),
);
expect(filledTakerTokenAmountBefore).to.be.bignumber.equal(0);
const fillTakerTokenAmount = order.params.takerTokenAmount.div(2);
await exWrapper.fillOrderAsync(order, taker, { fillTakerTokenAmount });
const fillTakerTokenAmount = signedOrder.takerTokenAmount.div(2);
await exWrapper.fillOrderAsync(signedOrder, taker, { fillTakerTokenAmount });
const filledTakerTokenAmountAfter = await zeroEx.exchange.getFilledTakerAmountAsync(order.params
.orderHashHex as string);
const filledTakerTokenAmountAfter = await zeroEx.exchange.getFilledTakerAmountAsync(
ZeroEx.getOrderHashHex(signedOrder),
);
const expectedFillAmountTAfter = fillTakerTokenAmount.add(filledTakerTokenAmountBefore);
expect(filledTakerTokenAmountAfter).to.be.bignumber.equal(expectedFillAmountTAfter);
const newBalances = await dmyBalances.getAsync();
const fillMakerTokenAmount = fillTakerTokenAmount
.times(order.params.makerTokenAmount)
.dividedToIntegerBy(order.params.takerTokenAmount);
const paidMakerFee = order.params.makerFee
.times(signedOrder.makerTokenAmount)
.dividedToIntegerBy(signedOrder.takerTokenAmount);
const paidMakerFee = signedOrder.makerFee
.times(fillMakerTokenAmount)
.dividedToIntegerBy(order.params.makerTokenAmount);
const paidTakerFee = order.params.takerFee
.dividedToIntegerBy(signedOrder.makerTokenAmount);
const paidTakerFee = signedOrder.takerFee
.times(fillMakerTokenAmount)
.dividedToIntegerBy(order.params.makerTokenAmount);
expect(newBalances[maker][order.params.makerToken]).to.be.bignumber.equal(
balances[maker][order.params.makerToken].minus(fillMakerTokenAmount),
.dividedToIntegerBy(signedOrder.makerTokenAmount);
expect(newBalances[maker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
balances[maker][signedOrder.makerTokenAddress].minus(fillMakerTokenAmount),
);
expect(newBalances[maker][order.params.takerToken]).to.be.bignumber.equal(
balances[maker][order.params.takerToken].add(fillTakerTokenAmount),
expect(newBalances[maker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
balances[maker][signedOrder.takerTokenAddress].add(fillTakerTokenAmount),
);
expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(
balances[maker][zrx.address].minus(paidMakerFee),
);
expect(newBalances[taker][order.params.takerToken]).to.be.bignumber.equal(
balances[taker][order.params.takerToken].minus(fillTakerTokenAmount),
expect(newBalances[taker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
balances[taker][signedOrder.takerTokenAddress].minus(fillTakerTokenAmount),
);
expect(newBalances[taker][order.params.makerToken]).to.be.bignumber.equal(
balances[taker][order.params.makerToken].add(fillMakerTokenAmount),
expect(newBalances[taker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
balances[taker][signedOrder.makerTokenAddress].add(fillMakerTokenAmount),
);
expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(
balances[taker][zrx.address].minus(paidTakerFee),
@@ -386,141 +397,141 @@ describe('Exchange', () => {
});
it('should fill remaining value if fillTakerTokenAmount > remaining takerTokenAmount', async () => {
const fillTakerTokenAmount = order.params.takerTokenAmount.div(2);
await exWrapper.fillOrderAsync(order, taker, { fillTakerTokenAmount });
const fillTakerTokenAmount = signedOrder.takerTokenAmount.div(2);
await exWrapper.fillOrderAsync(signedOrder, taker, { fillTakerTokenAmount });
const res = await exWrapper.fillOrderAsync(order, taker, {
fillTakerTokenAmount: order.params.takerTokenAmount,
const res = await exWrapper.fillOrderAsync(signedOrder, taker, {
fillTakerTokenAmount: signedOrder.takerTokenAmount,
});
const log = res.logs[0] as LogWithDecodedArgs<LogFillContractEventArgs>;
expect(log.args.filledTakerTokenAmount).to.be.bignumber.equal(
order.params.takerTokenAmount.minus(fillTakerTokenAmount),
signedOrder.takerTokenAmount.minus(fillTakerTokenAmount),
);
const newBalances = await dmyBalances.getAsync();
expect(newBalances[maker][order.params.makerToken]).to.be.bignumber.equal(
balances[maker][order.params.makerToken].minus(order.params.makerTokenAmount),
expect(newBalances[maker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
balances[maker][signedOrder.makerTokenAddress].minus(signedOrder.makerTokenAmount),
);
expect(newBalances[maker][order.params.takerToken]).to.be.bignumber.equal(
balances[maker][order.params.takerToken].add(order.params.takerTokenAmount),
expect(newBalances[maker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
balances[maker][signedOrder.takerTokenAddress].add(signedOrder.takerTokenAmount),
);
expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(
balances[maker][zrx.address].minus(order.params.makerFee),
balances[maker][zrx.address].minus(signedOrder.makerFee),
);
expect(newBalances[taker][order.params.takerToken]).to.be.bignumber.equal(
balances[taker][order.params.takerToken].minus(order.params.takerTokenAmount),
expect(newBalances[taker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
balances[taker][signedOrder.takerTokenAddress].minus(signedOrder.takerTokenAmount),
);
expect(newBalances[taker][order.params.makerToken]).to.be.bignumber.equal(
balances[taker][order.params.makerToken].add(order.params.makerTokenAmount),
expect(newBalances[taker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
balances[taker][signedOrder.makerTokenAddress].add(signedOrder.makerTokenAmount),
);
expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(
balances[taker][zrx.address].minus(order.params.takerFee),
balances[taker][zrx.address].minus(signedOrder.takerFee),
);
expect(newBalances[feeRecipient][zrx.address]).to.be.bignumber.equal(
balances[feeRecipient][zrx.address].add(order.params.makerFee.add(order.params.takerFee)),
balances[feeRecipient][zrx.address].add(signedOrder.makerFee.add(signedOrder.takerFee)),
);
});
it('should log 1 event with the correct arguments when order has a feeRecipient', async () => {
const divisor = 2;
const res = await exWrapper.fillOrderAsync(order, taker, {
fillTakerTokenAmount: order.params.takerTokenAmount.div(divisor),
const res = await exWrapper.fillOrderAsync(signedOrder, taker, {
fillTakerTokenAmount: signedOrder.takerTokenAmount.div(divisor),
});
expect(res.logs).to.have.length(1);
const logArgs = (res.logs[0] as LogWithDecodedArgs<LogFillContractEventArgs>).args;
const expectedFilledMakerTokenAmount = order.params.makerTokenAmount.div(divisor);
const expectedFilledTakerTokenAmount = order.params.takerTokenAmount.div(divisor);
const expectedFeeMPaid = order.params.makerFee.div(divisor);
const expectedFeeTPaid = order.params.takerFee.div(divisor);
const tokensHashBuff = crypto.solSHA3([order.params.makerToken, order.params.takerToken]);
const expectedFilledMakerTokenAmount = signedOrder.makerTokenAmount.div(divisor);
const expectedFilledTakerTokenAmount = signedOrder.takerTokenAmount.div(divisor);
const expectedFeeMPaid = signedOrder.makerFee.div(divisor);
const expectedFeeTPaid = signedOrder.takerFee.div(divisor);
const tokensHashBuff = crypto.solSHA3([signedOrder.makerTokenAddress, signedOrder.takerTokenAddress]);
const expectedTokens = ethUtil.bufferToHex(tokensHashBuff);
expect(order.params.maker).to.be.equal(logArgs.maker);
expect(signedOrder.maker).to.be.equal(logArgs.maker);
expect(taker).to.be.equal(logArgs.taker);
expect(order.params.feeRecipient).to.be.equal(logArgs.feeRecipient);
expect(order.params.makerToken).to.be.equal(logArgs.makerToken);
expect(order.params.takerToken).to.be.equal(logArgs.takerToken);
expect(signedOrder.feeRecipient).to.be.equal(logArgs.feeRecipient);
expect(signedOrder.makerTokenAddress).to.be.equal(logArgs.makerToken);
expect(signedOrder.takerTokenAddress).to.be.equal(logArgs.takerToken);
expect(expectedFilledMakerTokenAmount).to.be.bignumber.equal(logArgs.filledMakerTokenAmount);
expect(expectedFilledTakerTokenAmount).to.be.bignumber.equal(logArgs.filledTakerTokenAmount);
expect(expectedFeeMPaid).to.be.bignumber.equal(logArgs.paidMakerFee);
expect(expectedFeeTPaid).to.be.bignumber.equal(logArgs.paidTakerFee);
expect(expectedTokens).to.be.equal(logArgs.tokens);
expect(order.params.orderHashHex).to.be.equal(logArgs.orderHash);
expect(ZeroEx.getOrderHashHex(signedOrder)).to.be.equal(logArgs.orderHash);
});
it('should log 1 event with the correct arguments when order has no feeRecipient', async () => {
order = await orderFactory.newSignedOrderAsync({
signedOrder = await orderFactory.newSignedOrderAsync({
feeRecipient: ZeroEx.NULL_ADDRESS,
});
const divisor = 2;
const res = await exWrapper.fillOrderAsync(order, taker, {
fillTakerTokenAmount: order.params.takerTokenAmount.div(divisor),
const res = await exWrapper.fillOrderAsync(signedOrder, taker, {
fillTakerTokenAmount: signedOrder.takerTokenAmount.div(divisor),
});
expect(res.logs).to.have.length(1);
const logArgs = (res.logs[0] as LogWithDecodedArgs<LogFillContractEventArgs>).args;
const expectedFilledMakerTokenAmount = order.params.makerTokenAmount.div(divisor);
const expectedFilledTakerTokenAmount = order.params.takerTokenAmount.div(divisor);
const expectedFilledMakerTokenAmount = signedOrder.makerTokenAmount.div(divisor);
const expectedFilledTakerTokenAmount = signedOrder.takerTokenAmount.div(divisor);
const expectedFeeMPaid = new BigNumber(0);
const expectedFeeTPaid = new BigNumber(0);
const tokensHashBuff = crypto.solSHA3([order.params.makerToken, order.params.takerToken]);
const tokensHashBuff = crypto.solSHA3([signedOrder.makerTokenAddress, signedOrder.takerTokenAddress]);
const expectedTokens = ethUtil.bufferToHex(tokensHashBuff);
expect(order.params.maker).to.be.equal(logArgs.maker);
expect(signedOrder.maker).to.be.equal(logArgs.maker);
expect(taker).to.be.equal(logArgs.taker);
expect(order.params.feeRecipient).to.be.equal(logArgs.feeRecipient);
expect(order.params.makerToken).to.be.equal(logArgs.makerToken);
expect(order.params.takerToken).to.be.equal(logArgs.takerToken);
expect(signedOrder.feeRecipient).to.be.equal(logArgs.feeRecipient);
expect(signedOrder.makerTokenAddress).to.be.equal(logArgs.makerToken);
expect(signedOrder.takerTokenAddress).to.be.equal(logArgs.takerToken);
expect(expectedFilledMakerTokenAmount).to.be.bignumber.equal(logArgs.filledMakerTokenAmount);
expect(expectedFilledTakerTokenAmount).to.be.bignumber.equal(logArgs.filledTakerTokenAmount);
expect(expectedFeeMPaid).to.be.bignumber.equal(logArgs.paidMakerFee);
expect(expectedFeeTPaid).to.be.bignumber.equal(logArgs.paidTakerFee);
expect(expectedTokens).to.be.equal(logArgs.tokens);
expect(order.params.orderHashHex).to.be.equal(logArgs.orderHash);
expect(ZeroEx.getOrderHashHex(signedOrder)).to.be.equal(logArgs.orderHash);
});
it('should throw when taker is specified and order is claimed by other', async () => {
order = await orderFactory.newSignedOrderAsync({
signedOrder = await orderFactory.newSignedOrderAsync({
taker: feeRecipient,
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
});
return expect(exWrapper.fillOrderAsync(order, taker)).to.be.rejectedWith(constants.REVERT);
return expect(exWrapper.fillOrderAsync(signedOrder, taker)).to.be.rejectedWith(constants.REVERT);
});
it('should throw if signature is invalid', async () => {
order = await orderFactory.newSignedOrderAsync({
signedOrder = await orderFactory.newSignedOrderAsync({
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(10), 18),
});
order.params.r = ethUtil.bufferToHex(ethUtil.sha3('invalidR'));
order.params.s = ethUtil.bufferToHex(ethUtil.sha3('invalidS'));
return expect(exWrapper.fillOrderAsync(order, taker)).to.be.rejectedWith(constants.REVERT);
signedOrder.ecSignature.r = ethUtil.bufferToHex(ethUtil.sha3('invalidR'));
signedOrder.ecSignature.s = ethUtil.bufferToHex(ethUtil.sha3('invalidS'));
return expect(exWrapper.fillOrderAsync(signedOrder, taker)).to.be.rejectedWith(constants.REVERT);
});
it('should throw if makerTokenAmount is 0', async () => {
order = await orderFactory.newSignedOrderAsync({
signedOrder = await orderFactory.newSignedOrderAsync({
makerTokenAmount: new BigNumber(0),
});
return expect(exWrapper.fillOrderAsync(order, taker)).to.be.rejectedWith(constants.REVERT);
return expect(exWrapper.fillOrderAsync(signedOrder, taker)).to.be.rejectedWith(constants.REVERT);
});
it('should throw if takerTokenAmount is 0', async () => {
order = await orderFactory.newSignedOrderAsync({
signedOrder = await orderFactory.newSignedOrderAsync({
takerTokenAmount: new BigNumber(0),
});
return expect(exWrapper.fillOrderAsync(order, taker)).to.be.rejectedWith(constants.REVERT);
return expect(exWrapper.fillOrderAsync(signedOrder, taker)).to.be.rejectedWith(constants.REVERT);
});
it('should throw if fillTakerTokenAmount is 0', async () => {
order = await orderFactory.newSignedOrderAsync();
signedOrder = await orderFactory.newSignedOrderAsync();
return expect(
exWrapper.fillOrderAsync(order, taker, {
exWrapper.fillOrderAsync(signedOrder, taker, {
fillTakerTokenAmount: new BigNumber(0),
}),
).to.be.rejectedWith(constants.REVERT);
@@ -528,23 +539,23 @@ describe('Exchange', () => {
it('should not change balances if maker balances are too low to fill order and \
shouldThrowOnInsufficientBalanceOrAllowance = false', async () => {
order = await orderFactory.newSignedOrderAsync({
signedOrder = await orderFactory.newSignedOrderAsync({
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18),
});
await exWrapper.fillOrderAsync(order, taker);
await exWrapper.fillOrderAsync(signedOrder, taker);
const newBalances = await dmyBalances.getAsync();
expect(newBalances).to.be.deep.equal(balances);
});
it('should throw if maker balances are too low to fill order and \
shouldThrowOnInsufficientBalanceOrAllowance = true', async () => {
order = await orderFactory.newSignedOrderAsync({
signedOrder = await orderFactory.newSignedOrderAsync({
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18),
});
return expect(
exWrapper.fillOrderAsync(order, taker, {
exWrapper.fillOrderAsync(signedOrder, taker, {
shouldThrowOnInsufficientBalanceOrAllowance: true,
}),
).to.be.rejectedWith(constants.REVERT);
@@ -552,23 +563,23 @@ describe('Exchange', () => {
it('should not change balances if taker balances are too low to fill order and \
shouldThrowOnInsufficientBalanceOrAllowance = false', async () => {
order = await orderFactory.newSignedOrderAsync({
signedOrder = await orderFactory.newSignedOrderAsync({
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18),
});
await exWrapper.fillOrderAsync(order, taker);
await exWrapper.fillOrderAsync(signedOrder, taker);
const newBalances = await dmyBalances.getAsync();
expect(newBalances).to.be.deep.equal(balances);
});
it('should throw if taker balances are too low to fill order and \
shouldThrowOnInsufficientBalanceOrAllowance = true', async () => {
order = await orderFactory.newSignedOrderAsync({
signedOrder = await orderFactory.newSignedOrderAsync({
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18),
});
return expect(
exWrapper.fillOrderAsync(order, taker, {
exWrapper.fillOrderAsync(signedOrder, taker, {
shouldThrowOnInsufficientBalanceOrAllowance: true,
}),
).to.be.rejectedWith(constants.REVERT);
@@ -577,7 +588,7 @@ describe('Exchange', () => {
it('should not change balances if maker allowances are too low to fill order and \
shouldThrowOnInsufficientBalanceOrAllowance = false', async () => {
await rep.approve.sendTransactionAsync(tokenTransferProxy.address, new BigNumber(0), { from: maker });
await exWrapper.fillOrderAsync(order, taker);
await exWrapper.fillOrderAsync(signedOrder, taker);
await rep.approve.sendTransactionAsync(tokenTransferProxy.address, INITIAL_ALLOWANCE, {
from: maker,
});
@@ -590,7 +601,7 @@ describe('Exchange', () => {
shouldThrowOnInsufficientBalanceOrAllowance = true', async () => {
await rep.approve.sendTransactionAsync(tokenTransferProxy.address, new BigNumber(0), { from: maker });
expect(
exWrapper.fillOrderAsync(order, taker, {
exWrapper.fillOrderAsync(signedOrder, taker, {
shouldThrowOnInsufficientBalanceOrAllowance: true,
}),
).to.be.rejectedWith(constants.REVERT);
@@ -602,7 +613,7 @@ describe('Exchange', () => {
it('should not change balances if taker allowances are too low to fill order and \
shouldThrowOnInsufficientBalanceOrAllowance = false', async () => {
await dgd.approve.sendTransactionAsync(tokenTransferProxy.address, new BigNumber(0), { from: taker });
await exWrapper.fillOrderAsync(order, taker);
await exWrapper.fillOrderAsync(signedOrder, taker);
await dgd.approve.sendTransactionAsync(tokenTransferProxy.address, INITIAL_ALLOWANCE, {
from: taker,
});
@@ -615,7 +626,7 @@ describe('Exchange', () => {
shouldThrowOnInsufficientBalanceOrAllowance = true', async () => {
await dgd.approve.sendTransactionAsync(tokenTransferProxy.address, new BigNumber(0), { from: taker });
expect(
exWrapper.fillOrderAsync(order, taker, {
exWrapper.fillOrderAsync(signedOrder, taker, {
shouldThrowOnInsufficientBalanceOrAllowance: true,
}),
).to.be.rejectedWith(constants.REVERT);
@@ -624,54 +635,54 @@ describe('Exchange', () => {
});
});
it('should not change balances if makerToken is ZRX, makerTokenAmount + makerFee > maker balance, \
it('should not change balances if makerTokenAddress is ZRX, makerTokenAmount + makerFee > maker balance, \
and shouldThrowOnInsufficientBalanceOrAllowance = false', async () => {
const makerZRXBalance = new BigNumber(balances[maker][zrx.address]);
order = await orderFactory.newSignedOrderAsync({
makerToken: zrx.address,
signedOrder = await orderFactory.newSignedOrderAsync({
makerTokenAddress: zrx.address,
makerTokenAmount: makerZRXBalance,
makerFee: new BigNumber(1),
});
await exWrapper.fillOrderAsync(order, taker);
await exWrapper.fillOrderAsync(signedOrder, taker);
const newBalances = await dmyBalances.getAsync();
expect(newBalances).to.be.deep.equal(balances);
});
it('should not change balances if makerToken is ZRX, makerTokenAmount + makerFee > maker allowance, \
it('should not change balances if makerTokenAddress is ZRX, makerTokenAmount + makerFee > maker allowance, \
and shouldThrowOnInsufficientBalanceOrAllowance = false', async () => {
const makerZRXAllowance = await zrx.allowance(maker, tokenTransferProxy.address);
order = await orderFactory.newSignedOrderAsync({
makerToken: zrx.address,
signedOrder = await orderFactory.newSignedOrderAsync({
makerTokenAddress: zrx.address,
makerTokenAmount: new BigNumber(makerZRXAllowance),
makerFee: new BigNumber(1),
});
await exWrapper.fillOrderAsync(order, taker);
await exWrapper.fillOrderAsync(signedOrder, taker);
const newBalances = await dmyBalances.getAsync();
expect(newBalances).to.be.deep.equal(balances);
});
it('should not change balances if takerToken is ZRX, takerTokenAmount + takerFee > taker balance, \
it('should not change balances if takerTokenAddress is ZRX, takerTokenAmount + takerFee > taker balance, \
and shouldThrowOnInsufficientBalanceOrAllowance = false', async () => {
const takerZRXBalance = new BigNumber(balances[taker][zrx.address]);
order = await orderFactory.newSignedOrderAsync({
takerToken: zrx.address,
signedOrder = await orderFactory.newSignedOrderAsync({
takerTokenAddress: zrx.address,
takerTokenAmount: takerZRXBalance,
takerFee: new BigNumber(1),
});
await exWrapper.fillOrderAsync(order, taker);
await exWrapper.fillOrderAsync(signedOrder, taker);
const newBalances = await dmyBalances.getAsync();
expect(newBalances).to.be.deep.equal(balances);
});
it('should not change balances if takerToken is ZRX, takerTokenAmount + takerFee > taker allowance, \
it('should not change balances if takerTokenAddress is ZRX, takerTokenAmount + takerFee > taker allowance, \
and shouldThrowOnInsufficientBalanceOrAllowance = false', async () => {
const takerZRXAllowance = await zrx.allowance(taker, tokenTransferProxy.address);
order = await orderFactory.newSignedOrderAsync({
takerToken: zrx.address,
signedOrder = await orderFactory.newSignedOrderAsync({
takerTokenAddress: zrx.address,
takerTokenAmount: new BigNumber(takerZRXAllowance),
takerFee: new BigNumber(1),
});
await exWrapper.fillOrderAsync(order, taker);
await exWrapper.fillOrderAsync(signedOrder, taker);
const newBalances = await dmyBalances.getAsync();
expect(newBalances).to.be.deep.equal(balances);
});
@@ -683,33 +694,33 @@ describe('Exchange', () => {
from: taker,
});
order = await orderFactory.newSignedOrderAsync({
takerToken: maliciousToken.address,
signedOrder = await orderFactory.newSignedOrderAsync({
takerTokenAddress: maliciousToken.address,
});
return expect(
exWrapper.fillOrderAsync(order, taker, {
exWrapper.fillOrderAsync(signedOrder, taker, {
shouldThrowOnInsufficientBalanceOrAllowance: false,
}),
).to.be.rejectedWith(constants.REVERT);
});
it('should not change balances if an order is expired', async () => {
order = await orderFactory.newSignedOrderAsync({
expirationTimestampInSec: new BigNumber(Math.floor((Date.now() - 10000) / 1000)),
signedOrder = await orderFactory.newSignedOrderAsync({
expirationUnixTimestampSec: new BigNumber(Math.floor((Date.now() - 10000) / 1000)),
});
await exWrapper.fillOrderAsync(order, taker);
await exWrapper.fillOrderAsync(signedOrder, taker);
const newBalances = await dmyBalances.getAsync();
expect(newBalances).to.be.deep.equal(balances);
});
it('should log an error event if an order is expired', async () => {
order = await orderFactory.newSignedOrderAsync({
expirationTimestampInSec: new BigNumber(Math.floor((Date.now() - 10000) / 1000)),
signedOrder = await orderFactory.newSignedOrderAsync({
expirationUnixTimestampSec: new BigNumber(Math.floor((Date.now() - 10000) / 1000)),
});
const res = await exWrapper.fillOrderAsync(order, taker);
const res = await exWrapper.fillOrderAsync(signedOrder, taker);
expect(res.logs).to.have.length(1);
const log = res.logs[0] as LogWithDecodedArgs<LogErrorContractEventArgs>;
const errCode = log.args.errorId.toNumber();
@@ -717,10 +728,10 @@ describe('Exchange', () => {
});
it('should log an error event if no value is filled', async () => {
order = await orderFactory.newSignedOrderAsync({});
await exWrapper.fillOrderAsync(order, taker);
signedOrder = await orderFactory.newSignedOrderAsync({});
await exWrapper.fillOrderAsync(signedOrder, taker);
const res = await exWrapper.fillOrderAsync(order, taker);
const res = await exWrapper.fillOrderAsync(signedOrder, taker);
expect(res.logs).to.have.length(1);
const log = res.logs[0] as LogWithDecodedArgs<LogErrorContractEventArgs>;
const errCode = log.args.errorId.toNumber();
@@ -731,43 +742,43 @@ describe('Exchange', () => {
describe('cancelOrder', () => {
beforeEach(async () => {
balances = await dmyBalances.getAsync();
order = await orderFactory.newSignedOrderAsync();
signedOrder = await orderFactory.newSignedOrderAsync();
});
it('should throw if not sent by maker', async () => {
return expect(exWrapper.cancelOrderAsync(order, taker)).to.be.rejectedWith(constants.REVERT);
return expect(exWrapper.cancelOrderAsync(signedOrder, taker)).to.be.rejectedWith(constants.REVERT);
});
it('should throw if makerTokenAmount is 0', async () => {
order = await orderFactory.newSignedOrderAsync({
signedOrder = await orderFactory.newSignedOrderAsync({
makerTokenAmount: new BigNumber(0),
});
return expect(exWrapper.cancelOrderAsync(order, maker)).to.be.rejectedWith(constants.REVERT);
return expect(exWrapper.cancelOrderAsync(signedOrder, maker)).to.be.rejectedWith(constants.REVERT);
});
it('should throw if takerTokenAmount is 0', async () => {
order = await orderFactory.newSignedOrderAsync({
signedOrder = await orderFactory.newSignedOrderAsync({
takerTokenAmount: new BigNumber(0),
});
return expect(exWrapper.cancelOrderAsync(order, maker)).to.be.rejectedWith(constants.REVERT);
return expect(exWrapper.cancelOrderAsync(signedOrder, maker)).to.be.rejectedWith(constants.REVERT);
});
it('should throw if cancelTakerTokenAmount is 0', async () => {
order = await orderFactory.newSignedOrderAsync();
signedOrder = await orderFactory.newSignedOrderAsync();
return expect(
exWrapper.cancelOrderAsync(order, maker, {
exWrapper.cancelOrderAsync(signedOrder, maker, {
cancelTakerTokenAmount: new BigNumber(0),
}),
).to.be.rejectedWith(constants.REVERT);
});
it('should be able to cancel a full order', async () => {
await exWrapper.cancelOrderAsync(order, maker);
await exWrapper.fillOrderAsync(order, taker, {
fillTakerTokenAmount: order.params.takerTokenAmount.div(2),
await exWrapper.cancelOrderAsync(signedOrder, maker);
await exWrapper.fillOrderAsync(signedOrder, taker, {
fillTakerTokenAmount: signedOrder.takerTokenAmount.div(2),
});
const newBalances = await dmyBalances.getAsync();
@@ -775,43 +786,43 @@ describe('Exchange', () => {
});
it('should be able to cancel part of an order', async () => {
const cancelTakerTokenAmount = order.params.takerTokenAmount.div(2);
await exWrapper.cancelOrderAsync(order, maker, {
const cancelTakerTokenAmount = signedOrder.takerTokenAmount.div(2);
await exWrapper.cancelOrderAsync(signedOrder, maker, {
cancelTakerTokenAmount,
});
const res = await exWrapper.fillOrderAsync(order, taker, {
fillTakerTokenAmount: order.params.takerTokenAmount,
const res = await exWrapper.fillOrderAsync(signedOrder, taker, {
fillTakerTokenAmount: signedOrder.takerTokenAmount,
});
const log = res.logs[0] as LogWithDecodedArgs<LogFillContractEventArgs>;
expect(log.args.filledTakerTokenAmount).to.be.bignumber.equal(
order.params.takerTokenAmount.minus(cancelTakerTokenAmount),
signedOrder.takerTokenAmount.minus(cancelTakerTokenAmount),
);
const newBalances = await dmyBalances.getAsync();
const cancelMakerTokenAmount = cancelTakerTokenAmount
.times(order.params.makerTokenAmount)
.dividedToIntegerBy(order.params.takerTokenAmount);
const paidMakerFee = order.params.makerFee
.times(signedOrder.makerTokenAmount)
.dividedToIntegerBy(signedOrder.takerTokenAmount);
const paidMakerFee = signedOrder.makerFee
.times(cancelMakerTokenAmount)
.dividedToIntegerBy(order.params.makerTokenAmount);
const paidTakerFee = order.params.takerFee
.dividedToIntegerBy(signedOrder.makerTokenAmount);
const paidTakerFee = signedOrder.takerFee
.times(cancelMakerTokenAmount)
.dividedToIntegerBy(order.params.makerTokenAmount);
expect(newBalances[maker][order.params.makerToken]).to.be.bignumber.equal(
balances[maker][order.params.makerToken].minus(cancelMakerTokenAmount),
.dividedToIntegerBy(signedOrder.makerTokenAmount);
expect(newBalances[maker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
balances[maker][signedOrder.makerTokenAddress].minus(cancelMakerTokenAmount),
);
expect(newBalances[maker][order.params.takerToken]).to.be.bignumber.equal(
balances[maker][order.params.takerToken].add(cancelTakerTokenAmount),
expect(newBalances[maker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
balances[maker][signedOrder.takerTokenAddress].add(cancelTakerTokenAmount),
);
expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(
balances[maker][zrx.address].minus(paidMakerFee),
);
expect(newBalances[taker][order.params.takerToken]).to.be.bignumber.equal(
balances[taker][order.params.takerToken].minus(cancelTakerTokenAmount),
expect(newBalances[taker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
balances[taker][signedOrder.takerTokenAddress].minus(cancelTakerTokenAmount),
);
expect(newBalances[taker][order.params.makerToken]).to.be.bignumber.equal(
balances[taker][order.params.makerToken].add(cancelMakerTokenAmount),
expect(newBalances[taker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
balances[taker][signedOrder.makerTokenAddress].add(cancelMakerTokenAmount),
);
expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(
balances[taker][zrx.address].minus(paidTakerFee),
@@ -823,32 +834,32 @@ describe('Exchange', () => {
it('should log 1 event with correct arguments', async () => {
const divisor = 2;
const res = await exWrapper.cancelOrderAsync(order, maker, {
cancelTakerTokenAmount: order.params.takerTokenAmount.div(divisor),
const res = await exWrapper.cancelOrderAsync(signedOrder, maker, {
cancelTakerTokenAmount: signedOrder.takerTokenAmount.div(divisor),
});
expect(res.logs).to.have.length(1);
const log = res.logs[0] as LogWithDecodedArgs<LogCancelContractEventArgs>;
const logArgs = log.args;
const expectedCancelledMakerTokenAmount = order.params.makerTokenAmount.div(divisor);
const expectedCancelledTakerTokenAmount = order.params.takerTokenAmount.div(divisor);
const tokensHashBuff = crypto.solSHA3([order.params.makerToken, order.params.takerToken]);
const expectedCancelledMakerTokenAmount = signedOrder.makerTokenAmount.div(divisor);
const expectedCancelledTakerTokenAmount = signedOrder.takerTokenAmount.div(divisor);
const tokensHashBuff = crypto.solSHA3([signedOrder.makerTokenAddress, signedOrder.takerTokenAddress]);
const expectedTokens = ethUtil.bufferToHex(tokensHashBuff);
expect(order.params.maker).to.be.equal(logArgs.maker);
expect(order.params.feeRecipient).to.be.equal(logArgs.feeRecipient);
expect(order.params.makerToken).to.be.equal(logArgs.makerToken);
expect(order.params.takerToken).to.be.equal(logArgs.takerToken);
expect(signedOrder.maker).to.be.equal(logArgs.maker);
expect(signedOrder.feeRecipient).to.be.equal(logArgs.feeRecipient);
expect(signedOrder.makerTokenAddress).to.be.equal(logArgs.makerToken);
expect(signedOrder.takerTokenAddress).to.be.equal(logArgs.takerToken);
expect(expectedCancelledMakerTokenAmount).to.be.bignumber.equal(logArgs.cancelledMakerTokenAmount);
expect(expectedCancelledTakerTokenAmount).to.be.bignumber.equal(logArgs.cancelledTakerTokenAmount);
expect(expectedTokens).to.be.equal(logArgs.tokens);
expect(order.params.orderHashHex).to.be.equal(logArgs.orderHash);
expect(ZeroEx.getOrderHashHex(signedOrder)).to.be.equal(logArgs.orderHash);
});
it('should not log events if no value is cancelled', async () => {
await exWrapper.cancelOrderAsync(order, maker);
await exWrapper.cancelOrderAsync(signedOrder, maker);
const res = await exWrapper.cancelOrderAsync(order, maker);
const res = await exWrapper.cancelOrderAsync(signedOrder, maker);
expect(res.logs).to.have.length(1);
const log = res.logs[0] as LogWithDecodedArgs<LogErrorContractEventArgs>;
const errCode = log.args.errorId.toNumber();
@@ -856,11 +867,11 @@ describe('Exchange', () => {
});
it('should not log events if order is expired', async () => {
order = await orderFactory.newSignedOrderAsync({
expirationTimestampInSec: new BigNumber(Math.floor((Date.now() - 10000) / 1000)),
signedOrder = await orderFactory.newSignedOrderAsync({
expirationUnixTimestampSec: new BigNumber(Math.floor((Date.now() - 10000) / 1000)),
});
const res = await exWrapper.cancelOrderAsync(order, maker);
const res = await exWrapper.cancelOrderAsync(signedOrder, maker);
expect(res.logs).to.have.length(1);
const log = res.logs[0] as LogWithDecodedArgs<LogErrorContractEventArgs>;
const errCode = log.args.errorId.toNumber();

View File

@@ -1,4 +1,4 @@
import { ZeroEx } from '0x.js';
import { SignedOrder, ZeroEx } from '0x.js';
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
@@ -8,7 +8,6 @@ import ethUtil = require('ethereumjs-util');
import { ExchangeContract } from '../../src/contract_wrappers/generated/exchange';
import { constants } from '../../util/constants';
import { ExchangeWrapper } from '../../util/exchange_wrapper';
import { Order } from '../../util/order';
import { OrderFactory } from '../../util/order_factory';
import { ContractName } from '../../util/types';
import { chaiSetup } from '../utils/chai_setup';
@@ -25,7 +24,7 @@ describe('Exchange', () => {
let maker: string;
let feeRecipient: string;
let order: Order;
let signedOrder: SignedOrder;
let exchangeWrapper: ExchangeWrapper;
let orderFactory: OrderFactory;
@@ -58,8 +57,8 @@ describe('Exchange', () => {
makerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18),
takerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18),
};
orderFactory = new OrderFactory(web3Wrapper, defaultOrderParams);
order = await orderFactory.newSignedOrderAsync();
orderFactory = new OrderFactory(zeroEx, defaultOrderParams);
signedOrder = await orderFactory.newSignedOrderAsync();
});
beforeEach(async () => {
@@ -70,28 +69,31 @@ describe('Exchange', () => {
});
describe('getOrderHash', () => {
it('should output the correct orderHash', async () => {
const orderHashHex = await exchangeWrapper.getOrderHashAsync(order);
expect(order.params.orderHashHex).to.be.equal(orderHashHex);
const orderHashHex = await exchangeWrapper.getOrderHashAsync(signedOrder);
expect(ZeroEx.getOrderHashHex(signedOrder)).to.be.equal(orderHashHex);
});
});
describe('isValidSignature', () => {
beforeEach(async () => {
order = await orderFactory.newSignedOrderAsync();
signedOrder = await orderFactory.newSignedOrderAsync();
});
it('should return true with a valid signature', async () => {
const success = await exchangeWrapper.isValidSignatureAsync(order);
const isValidSignature = order.isValidSignature();
const success = await exchangeWrapper.isValidSignatureAsync(signedOrder);
const orderHashHex = ZeroEx.getOrderHashHex(signedOrder);
const isValidSignature = ZeroEx.isValidSignature(orderHashHex, signedOrder.ecSignature, signedOrder.maker);
expect(isValidSignature).to.be.true();
expect(success).to.be.true();
});
it('should return false with an invalid signature', async () => {
order.params.r = ethUtil.bufferToHex(ethUtil.sha3('invalidR'));
order.params.s = ethUtil.bufferToHex(ethUtil.sha3('invalidS'));
const success = await exchangeWrapper.isValidSignatureAsync(order);
expect(order.isValidSignature()).to.be.false();
signedOrder.ecSignature.r = ethUtil.bufferToHex(ethUtil.sha3('invalidR'));
signedOrder.ecSignature.s = ethUtil.bufferToHex(ethUtil.sha3('invalidS'));
const success = await exchangeWrapper.isValidSignatureAsync(signedOrder);
const orderHashHex = ZeroEx.getOrderHashHex(signedOrder);
const isValidSignature = ZeroEx.isValidSignature(orderHashHex, signedOrder.ecSignature, signedOrder.maker);
expect(isValidSignature).to.be.false();
expect(success).to.be.false();
});
});

View File

@@ -1,4 +1,4 @@
import { ZeroEx } from '0x.js';
import { SignedOrder, ZeroEx } from '0x.js';
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
@@ -13,7 +13,6 @@ import { TokenTransferProxyContract } from '../../src/contract_wrappers/generate
import { Balances } from '../../util/balances';
import { constants } from '../../util/constants';
import { ExchangeWrapper } from '../../util/exchange_wrapper';
import { Order } from '../../util/order';
import { OrderFactory } from '../../util/order_factory';
import { BalancesByOwner, ContractName } from '../../util/types';
import { chaiSetup } from '../utils/chai_setup';
@@ -76,15 +75,15 @@ describe('Exchange', () => {
exchangeContractAddress: exchange.address,
maker,
feeRecipient,
makerToken: rep.address,
takerToken: dgd.address,
makerTokenAddress: rep.address,
takerTokenAddress: dgd.address,
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
makerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18),
takerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18),
};
orderFactory = new OrderFactory(web3Wrapper, defaultOrderParams);
orderFactory = new OrderFactory(zeroEx, defaultOrderParams);
dmyBalances = new Balances([rep, dgd, zrx], [maker, taker, feeRecipient]);
await Promise.all([
rep.approve.sendTransactionAsync(tokenTransferProxy.address, INIT_ALLOW, { from: maker }),
@@ -113,38 +112,38 @@ describe('Exchange', () => {
});
it('should transfer the correct amounts', async () => {
const order = await orderFactory.newSignedOrderAsync({
const signedOrder = await orderFactory.newSignedOrderAsync({
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
});
const fillTakerTokenAmount = order.params.takerTokenAmount.div(2);
await exWrapper.fillOrKillOrderAsync(order, taker, {
const fillTakerTokenAmount = signedOrder.takerTokenAmount.div(2);
await exWrapper.fillOrKillOrderAsync(signedOrder, taker, {
fillTakerTokenAmount,
});
const newBalances = await dmyBalances.getAsync();
const fillMakerTokenAmount = fillTakerTokenAmount
.times(order.params.makerTokenAmount)
.dividedToIntegerBy(order.params.takerTokenAmount);
const makerFee = order.params.makerFee
.times(signedOrder.makerTokenAmount)
.dividedToIntegerBy(signedOrder.takerTokenAmount);
const makerFee = signedOrder.makerFee
.times(fillMakerTokenAmount)
.dividedToIntegerBy(order.params.makerTokenAmount);
const takerFee = order.params.takerFee
.dividedToIntegerBy(signedOrder.makerTokenAmount);
const takerFee = signedOrder.takerFee
.times(fillMakerTokenAmount)
.dividedToIntegerBy(order.params.makerTokenAmount);
expect(newBalances[maker][order.params.makerToken]).to.be.bignumber.equal(
balances[maker][order.params.makerToken].minus(fillMakerTokenAmount),
.dividedToIntegerBy(signedOrder.makerTokenAmount);
expect(newBalances[maker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
balances[maker][signedOrder.makerTokenAddress].minus(fillMakerTokenAmount),
);
expect(newBalances[maker][order.params.takerToken]).to.be.bignumber.equal(
balances[maker][order.params.takerToken].add(fillTakerTokenAmount),
expect(newBalances[maker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
balances[maker][signedOrder.takerTokenAddress].add(fillTakerTokenAmount),
);
expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(balances[maker][zrx.address].minus(makerFee));
expect(newBalances[taker][order.params.takerToken]).to.be.bignumber.equal(
balances[taker][order.params.takerToken].minus(fillTakerTokenAmount),
expect(newBalances[taker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
balances[taker][signedOrder.takerTokenAddress].minus(fillTakerTokenAmount),
);
expect(newBalances[taker][order.params.makerToken]).to.be.bignumber.equal(
balances[taker][order.params.makerToken].add(fillMakerTokenAmount),
expect(newBalances[taker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
balances[taker][signedOrder.makerTokenAddress].add(fillMakerTokenAmount),
);
expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(balances[taker][zrx.address].minus(takerFee));
expect(newBalances[feeRecipient][zrx.address]).to.be.bignumber.equal(
@@ -152,30 +151,30 @@ describe('Exchange', () => {
);
});
it('should throw if an order is expired', async () => {
const order = await orderFactory.newSignedOrderAsync({
expirationTimestampInSec: new BigNumber(Math.floor((Date.now() - 10000) / 1000)),
it('should throw if an signedOrder is expired', async () => {
const signedOrder = await orderFactory.newSignedOrderAsync({
expirationUnixTimestampSec: new BigNumber(Math.floor((Date.now() - 10000) / 1000)),
});
return expect(exWrapper.fillOrKillOrderAsync(order, taker)).to.be.rejectedWith(constants.REVERT);
return expect(exWrapper.fillOrKillOrderAsync(signedOrder, taker)).to.be.rejectedWith(constants.REVERT);
});
it('should throw if entire fillTakerTokenAmount not filled', async () => {
const order = await orderFactory.newSignedOrderAsync();
const signedOrder = await orderFactory.newSignedOrderAsync();
const from = taker;
await exWrapper.fillOrderAsync(order, from, {
fillTakerTokenAmount: order.params.takerTokenAmount.div(2),
await exWrapper.fillOrderAsync(signedOrder, from, {
fillTakerTokenAmount: signedOrder.takerTokenAmount.div(2),
});
return expect(exWrapper.fillOrKillOrderAsync(order, taker)).to.be.rejectedWith(constants.REVERT);
return expect(exWrapper.fillOrKillOrderAsync(signedOrder, taker)).to.be.rejectedWith(constants.REVERT);
});
});
describe('batch functions', () => {
let orders: Order[];
let signedOrders: SignedOrder[];
beforeEach(async () => {
orders = await Promise.all([
signedOrders = await Promise.all([
orderFactory.newSignedOrderAsync(),
orderFactory.newSignedOrderAsync(),
orderFactory.newSignedOrderAsync(),
@@ -186,32 +185,32 @@ describe('Exchange', () => {
describe('batchFillOrders', () => {
it('should transfer the correct amounts', async () => {
const fillTakerTokenAmounts: BigNumber[] = [];
const makerToken = rep.address;
const takerToken = dgd.address;
orders.forEach(order => {
const fillTakerTokenAmount = order.params.takerTokenAmount.div(2);
const makerTokenAddress = rep.address;
const takerTokenAddress = dgd.address;
signedOrders.forEach(signedOrder => {
const fillTakerTokenAmount = signedOrder.takerTokenAmount.div(2);
const fillMakerTokenAmount = fillTakerTokenAmount
.times(order.params.makerTokenAmount)
.dividedToIntegerBy(order.params.takerTokenAmount);
const makerFee = order.params.makerFee
.times(signedOrder.makerTokenAmount)
.dividedToIntegerBy(signedOrder.takerTokenAmount);
const makerFee = signedOrder.makerFee
.times(fillMakerTokenAmount)
.dividedToIntegerBy(order.params.makerTokenAmount);
const takerFee = order.params.takerFee
.dividedToIntegerBy(signedOrder.makerTokenAmount);
const takerFee = signedOrder.takerFee
.times(fillMakerTokenAmount)
.dividedToIntegerBy(order.params.makerTokenAmount);
.dividedToIntegerBy(signedOrder.makerTokenAmount);
fillTakerTokenAmounts.push(fillTakerTokenAmount);
balances[maker][makerToken] = balances[maker][makerToken].minus(fillMakerTokenAmount);
balances[maker][takerToken] = balances[maker][takerToken].add(fillTakerTokenAmount);
balances[maker][makerTokenAddress] = balances[maker][makerTokenAddress].minus(fillMakerTokenAmount);
balances[maker][takerTokenAddress] = balances[maker][takerTokenAddress].add(fillTakerTokenAmount);
balances[maker][zrx.address] = balances[maker][zrx.address].minus(makerFee);
balances[taker][makerToken] = balances[taker][makerToken].add(fillMakerTokenAmount);
balances[taker][takerToken] = balances[taker][takerToken].minus(fillTakerTokenAmount);
balances[taker][makerTokenAddress] = balances[taker][makerTokenAddress].add(fillMakerTokenAmount);
balances[taker][takerTokenAddress] = balances[taker][takerTokenAddress].minus(fillTakerTokenAmount);
balances[taker][zrx.address] = balances[taker][zrx.address].minus(takerFee);
balances[feeRecipient][zrx.address] = balances[feeRecipient][zrx.address].add(
makerFee.add(takerFee),
);
});
await exWrapper.batchFillOrdersAsync(orders, taker, {
await exWrapper.batchFillOrdersAsync(signedOrders, taker, {
fillTakerTokenAmounts,
});
@@ -223,32 +222,32 @@ describe('Exchange', () => {
describe('batchFillOrKillOrders', () => {
it('should transfer the correct amounts', async () => {
const fillTakerTokenAmounts: BigNumber[] = [];
const makerToken = rep.address;
const takerToken = dgd.address;
orders.forEach(order => {
const fillTakerTokenAmount = order.params.takerTokenAmount.div(2);
const makerTokenAddress = rep.address;
const takerTokenAddress = dgd.address;
signedOrders.forEach(signedOrder => {
const fillTakerTokenAmount = signedOrder.takerTokenAmount.div(2);
const fillMakerTokenAmount = fillTakerTokenAmount
.times(order.params.makerTokenAmount)
.dividedToIntegerBy(order.params.takerTokenAmount);
const makerFee = order.params.makerFee
.times(signedOrder.makerTokenAmount)
.dividedToIntegerBy(signedOrder.takerTokenAmount);
const makerFee = signedOrder.makerFee
.times(fillMakerTokenAmount)
.dividedToIntegerBy(order.params.makerTokenAmount);
const takerFee = order.params.takerFee
.dividedToIntegerBy(signedOrder.makerTokenAmount);
const takerFee = signedOrder.takerFee
.times(fillMakerTokenAmount)
.dividedToIntegerBy(order.params.makerTokenAmount);
.dividedToIntegerBy(signedOrder.makerTokenAmount);
fillTakerTokenAmounts.push(fillTakerTokenAmount);
balances[maker][makerToken] = balances[maker][makerToken].minus(fillMakerTokenAmount);
balances[maker][takerToken] = balances[maker][takerToken].add(fillTakerTokenAmount);
balances[maker][makerTokenAddress] = balances[maker][makerTokenAddress].minus(fillMakerTokenAmount);
balances[maker][takerTokenAddress] = balances[maker][takerTokenAddress].add(fillTakerTokenAmount);
balances[maker][zrx.address] = balances[maker][zrx.address].minus(makerFee);
balances[taker][makerToken] = balances[taker][makerToken].add(fillMakerTokenAmount);
balances[taker][takerToken] = balances[taker][takerToken].minus(fillTakerTokenAmount);
balances[taker][makerTokenAddress] = balances[taker][makerTokenAddress].add(fillMakerTokenAmount);
balances[taker][takerTokenAddress] = balances[taker][takerTokenAddress].minus(fillTakerTokenAmount);
balances[taker][zrx.address] = balances[taker][zrx.address].minus(takerFee);
balances[feeRecipient][zrx.address] = balances[feeRecipient][zrx.address].add(
makerFee.add(takerFee),
);
});
await exWrapper.batchFillOrKillOrdersAsync(orders, taker, {
await exWrapper.batchFillOrKillOrdersAsync(signedOrders, taker, {
fillTakerTokenAmounts,
});
@@ -256,17 +255,17 @@ describe('Exchange', () => {
expect(newBalances).to.be.deep.equal(balances);
});
it('should throw if a single order does not fill the expected amount', async () => {
it('should throw if a single signedOrder does not fill the expected amount', async () => {
const fillTakerTokenAmounts: BigNumber[] = [];
orders.forEach(order => {
const fillTakerTokenAmount = order.params.takerTokenAmount.div(2);
signedOrders.forEach(signedOrder => {
const fillTakerTokenAmount = signedOrder.takerTokenAmount.div(2);
fillTakerTokenAmounts.push(fillTakerTokenAmount);
});
await exWrapper.fillOrKillOrderAsync(orders[0], taker);
await exWrapper.fillOrKillOrderAsync(signedOrders[0], taker);
return expect(
exWrapper.batchFillOrKillOrdersAsync(orders, taker, {
exWrapper.batchFillOrKillOrdersAsync(signedOrders, taker, {
fillTakerTokenAmounts,
}),
).to.be.rejectedWith(constants.REVERT);
@@ -275,34 +274,34 @@ describe('Exchange', () => {
describe('fillOrdersUpTo', () => {
it('should stop when the entire fillTakerTokenAmount is filled', async () => {
const fillTakerTokenAmount = orders[0].params.takerTokenAmount.plus(
orders[1].params.takerTokenAmount.div(2),
const fillTakerTokenAmount = signedOrders[0].takerTokenAmount.plus(
signedOrders[1].takerTokenAmount.div(2),
);
await exWrapper.fillOrdersUpToAsync(orders, taker, {
await exWrapper.fillOrdersUpToAsync(signedOrders, taker, {
fillTakerTokenAmount,
});
const newBalances = await dmyBalances.getAsync();
const fillMakerTokenAmount = orders[0].params.makerTokenAmount.add(
orders[1].params.makerTokenAmount.dividedToIntegerBy(2),
const fillMakerTokenAmount = signedOrders[0].makerTokenAmount.add(
signedOrders[1].makerTokenAmount.dividedToIntegerBy(2),
);
const makerFee = orders[0].params.makerFee.add(orders[1].params.makerFee.dividedToIntegerBy(2));
const takerFee = orders[0].params.takerFee.add(orders[1].params.takerFee.dividedToIntegerBy(2));
expect(newBalances[maker][orders[0].params.makerToken]).to.be.bignumber.equal(
balances[maker][orders[0].params.makerToken].minus(fillMakerTokenAmount),
const makerFee = signedOrders[0].makerFee.add(signedOrders[1].makerFee.dividedToIntegerBy(2));
const takerFee = signedOrders[0].takerFee.add(signedOrders[1].takerFee.dividedToIntegerBy(2));
expect(newBalances[maker][signedOrders[0].makerTokenAddress]).to.be.bignumber.equal(
balances[maker][signedOrders[0].makerTokenAddress].minus(fillMakerTokenAmount),
);
expect(newBalances[maker][orders[0].params.takerToken]).to.be.bignumber.equal(
balances[maker][orders[0].params.takerToken].add(fillTakerTokenAmount),
expect(newBalances[maker][signedOrders[0].takerTokenAddress]).to.be.bignumber.equal(
balances[maker][signedOrders[0].takerTokenAddress].add(fillTakerTokenAmount),
);
expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(
balances[maker][zrx.address].minus(makerFee),
);
expect(newBalances[taker][orders[0].params.takerToken]).to.be.bignumber.equal(
balances[taker][orders[0].params.takerToken].minus(fillTakerTokenAmount),
expect(newBalances[taker][signedOrders[0].takerTokenAddress]).to.be.bignumber.equal(
balances[taker][signedOrders[0].takerTokenAddress].minus(fillTakerTokenAmount),
);
expect(newBalances[taker][orders[0].params.makerToken]).to.be.bignumber.equal(
balances[taker][orders[0].params.makerToken].add(fillMakerTokenAmount),
expect(newBalances[taker][signedOrders[0].makerTokenAddress]).to.be.bignumber.equal(
balances[taker][signedOrders[0].makerTokenAddress].add(fillMakerTokenAmount),
);
expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(
balances[taker][zrx.address].minus(takerFee),
@@ -312,28 +311,28 @@ describe('Exchange', () => {
);
});
it('should fill all orders if cannot fill entire fillTakerTokenAmount', async () => {
it('should fill all signedOrders if cannot fill entire fillTakerTokenAmount', async () => {
const fillTakerTokenAmount = ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18);
orders.forEach(order => {
balances[maker][order.params.makerToken] = balances[maker][order.params.makerToken].minus(
order.params.makerTokenAmount,
signedOrders.forEach(signedOrder => {
balances[maker][signedOrder.makerTokenAddress] = balances[maker][
signedOrder.makerTokenAddress
].minus(signedOrder.makerTokenAmount);
balances[maker][signedOrder.takerTokenAddress] = balances[maker][signedOrder.takerTokenAddress].add(
signedOrder.takerTokenAmount,
);
balances[maker][order.params.takerToken] = balances[maker][order.params.takerToken].add(
order.params.takerTokenAmount,
balances[maker][zrx.address] = balances[maker][zrx.address].minus(signedOrder.makerFee);
balances[taker][signedOrder.makerTokenAddress] = balances[taker][signedOrder.makerTokenAddress].add(
signedOrder.makerTokenAmount,
);
balances[maker][zrx.address] = balances[maker][zrx.address].minus(order.params.makerFee);
balances[taker][order.params.makerToken] = balances[taker][order.params.makerToken].add(
order.params.makerTokenAmount,
);
balances[taker][order.params.takerToken] = balances[taker][order.params.takerToken].minus(
order.params.takerTokenAmount,
);
balances[taker][zrx.address] = balances[taker][zrx.address].minus(order.params.takerFee);
balances[taker][signedOrder.takerTokenAddress] = balances[taker][
signedOrder.takerTokenAddress
].minus(signedOrder.takerTokenAmount);
balances[taker][zrx.address] = balances[taker][zrx.address].minus(signedOrder.takerFee);
balances[feeRecipient][zrx.address] = balances[feeRecipient][zrx.address].add(
order.params.makerFee.add(order.params.takerFee),
signedOrder.makerFee.add(signedOrder.takerFee),
);
});
await exWrapper.fillOrdersUpToAsync(orders, taker, {
await exWrapper.fillOrdersUpToAsync(signedOrders, taker, {
fillTakerTokenAmount,
});
@@ -341,15 +340,15 @@ describe('Exchange', () => {
expect(newBalances).to.be.deep.equal(balances);
});
it('should throw when an order does not use the same takerToken', async () => {
orders = await Promise.all([
it('should throw when an signedOrder does not use the same takerTokenAddress', async () => {
signedOrders = await Promise.all([
orderFactory.newSignedOrderAsync(),
orderFactory.newSignedOrderAsync({ takerToken: zrx.address }),
orderFactory.newSignedOrderAsync({ takerTokenAddress: zrx.address }),
orderFactory.newSignedOrderAsync(),
]);
return expect(
exWrapper.fillOrdersUpToAsync(orders, taker, {
exWrapper.fillOrdersUpToAsync(signedOrders, taker, {
fillTakerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(1000), 18),
}),
).to.be.rejectedWith(constants.REVERT);
@@ -357,13 +356,13 @@ describe('Exchange', () => {
});
describe('batchCancelOrders', () => {
it('should be able to cancel multiple orders', async () => {
const cancelTakerTokenAmounts = _.map(orders, order => order.params.takerTokenAmount);
await exWrapper.batchCancelOrdersAsync(orders, maker, {
it('should be able to cancel multiple signedOrders', async () => {
const cancelTakerTokenAmounts = _.map(signedOrders, signedOrder => signedOrder.takerTokenAmount);
await exWrapper.batchCancelOrdersAsync(signedOrders, maker, {
cancelTakerTokenAmounts,
});
await exWrapper.batchFillOrdersAsync(orders, taker, {
await exWrapper.batchFillOrdersAsync(signedOrders, taker, {
fillTakerTokenAmounts: cancelTakerTokenAmounts,
});
const newBalances = await dmyBalances.getAsync();

View File

@@ -1,4 +1,4 @@
import { TransactionReceiptWithDecodedLogs, ZeroEx } from '0x.js';
import { SignedOrder, TransactionReceiptWithDecodedLogs, ZeroEx } from '0x.js';
import { BigNumber } from '@0xproject/utils';
import * as _ from 'lodash';
import * as Web3 from 'web3';
@@ -6,7 +6,7 @@ import * as Web3 from 'web3';
import { ExchangeContract } from '../src/contract_wrappers/generated/exchange';
import { formatters } from './formatters';
import { Order } from './order';
import { signedOrderUtils } from './signed_order_utils';
export class ExchangeWrapper {
private _exchange: ExchangeContract;
@@ -16,7 +16,7 @@ export class ExchangeWrapper {
this._zeroEx = zeroEx;
}
public async fillOrderAsync(
order: Order,
signedOrder: SignedOrder,
from: string,
opts: {
fillTakerTokenAmount?: BigNumber;
@@ -24,15 +24,19 @@ export class ExchangeWrapper {
} = {},
): Promise<TransactionReceiptWithDecodedLogs> {
const shouldThrowOnInsufficientBalanceOrAllowance = !!opts.shouldThrowOnInsufficientBalanceOrAllowance;
const params = order.createFill(shouldThrowOnInsufficientBalanceOrAllowance, opts.fillTakerTokenAmount);
const params = signedOrderUtils.createFill(
signedOrder,
shouldThrowOnInsufficientBalanceOrAllowance,
opts.fillTakerTokenAmount,
);
const txHash = await this._exchange.fillOrder.sendTransactionAsync(
params.orderAddresses,
params.orderValues,
params.fillTakerTokenAmount,
params.shouldThrowOnInsufficientBalanceOrAllowance,
params.v as number,
params.r as string,
params.s as string,
params.v,
params.r,
params.s,
{ from },
);
const tx = await this._zeroEx.awaitTransactionMinedAsync(txHash);
@@ -41,11 +45,11 @@ export class ExchangeWrapper {
return tx;
}
public async cancelOrderAsync(
order: Order,
signedOrder: SignedOrder,
from: string,
opts: { cancelTakerTokenAmount?: BigNumber } = {},
): Promise<TransactionReceiptWithDecodedLogs> {
const params = order.createCancel(opts.cancelTakerTokenAmount);
const params = signedOrderUtils.createCancel(signedOrder, opts.cancelTakerTokenAmount);
const txHash = await this._exchange.cancelOrder.sendTransactionAsync(
params.orderAddresses,
params.orderValues,
@@ -58,19 +62,23 @@ export class ExchangeWrapper {
return tx;
}
public async fillOrKillOrderAsync(
order: Order,
signedOrder: SignedOrder,
from: string,
opts: { fillTakerTokenAmount?: BigNumber } = {},
): Promise<TransactionReceiptWithDecodedLogs> {
const shouldThrowOnInsufficientBalanceOrAllowance = true;
const params = order.createFill(shouldThrowOnInsufficientBalanceOrAllowance, opts.fillTakerTokenAmount);
const params = signedOrderUtils.createFill(
signedOrder,
shouldThrowOnInsufficientBalanceOrAllowance,
opts.fillTakerTokenAmount,
);
const txHash = await this._exchange.fillOrKillOrder.sendTransactionAsync(
params.orderAddresses,
params.orderValues,
params.fillTakerTokenAmount,
params.v as number,
params.r as string,
params.s as string,
params.v,
params.r,
params.s,
{ from },
);
const tx = await this._zeroEx.awaitTransactionMinedAsync(txHash);
@@ -79,7 +87,7 @@ export class ExchangeWrapper {
return tx;
}
public async batchFillOrdersAsync(
orders: Order[],
orders: SignedOrder[],
from: string,
opts: {
fillTakerTokenAmounts?: BigNumber[];
@@ -108,7 +116,7 @@ export class ExchangeWrapper {
return tx;
}
public async batchFillOrKillOrdersAsync(
orders: Order[],
orders: SignedOrder[],
from: string,
opts: { fillTakerTokenAmounts?: BigNumber[]; shouldThrowOnInsufficientBalanceOrAllowance?: boolean } = {},
): Promise<TransactionReceiptWithDecodedLogs> {
@@ -133,7 +141,7 @@ export class ExchangeWrapper {
return tx;
}
public async fillOrdersUpToAsync(
orders: Order[],
orders: SignedOrder[],
from: string,
opts: { fillTakerTokenAmount: BigNumber; shouldThrowOnInsufficientBalanceOrAllowance?: boolean },
): Promise<TransactionReceiptWithDecodedLogs> {
@@ -159,7 +167,7 @@ export class ExchangeWrapper {
return tx;
}
public async batchCancelOrdersAsync(
orders: Order[],
orders: SignedOrder[],
from: string,
opts: { cancelTakerTokenAmounts?: BigNumber[] } = {},
): Promise<TransactionReceiptWithDecodedLogs> {
@@ -175,19 +183,19 @@ export class ExchangeWrapper {
_.each(tx.logs, log => wrapLogBigNumbers(log));
return tx;
}
public async getOrderHashAsync(order: Order): Promise<string> {
public async getOrderHashAsync(signedOrder: SignedOrder): Promise<string> {
const shouldThrowOnInsufficientBalanceOrAllowance = false;
const params = order.createFill(shouldThrowOnInsufficientBalanceOrAllowance);
const params = signedOrderUtils.getOrderAddressesAndValues(signedOrder);
const orderHash = await this._exchange.getOrderHash(params.orderAddresses, params.orderValues);
return orderHash;
}
public async isValidSignatureAsync(order: Order): Promise<boolean> {
public async isValidSignatureAsync(signedOrder: SignedOrder): Promise<boolean> {
const isValidSignature = await this._exchange.isValidSignature(
order.params.maker,
order.params.orderHashHex as string,
order.params.v as number,
order.params.r as string,
order.params.s as string,
signedOrder.maker,
ZeroEx.getOrderHashHex(signedOrder),
signedOrder.ecSignature.v,
signedOrder.ecSignature.r,
signedOrder.ecSignature.s,
);
return isValidSignature;
}

View File

@@ -1,12 +1,12 @@
import { SignedOrder } from '0x.js';
import { BigNumber } from '@0xproject/utils';
import * as _ from 'lodash';
import { Order } from './order';
import { BatchCancelOrders, BatchFillOrders, FillOrdersUpTo } from './types';
export const formatters = {
createBatchFill(
orders: Order[],
signedOrders: SignedOrder[],
shouldThrowOnInsufficientBalanceOrAllowance: boolean,
fillTakerTokenAmounts: BigNumber[] = [],
) {
@@ -19,33 +19,33 @@ export const formatters = {
r: [],
s: [],
};
_.forEach(orders, order => {
_.forEach(signedOrders, signedOrder => {
batchFill.orderAddresses.push([
order.params.maker,
order.params.taker,
order.params.makerToken,
order.params.takerToken,
order.params.feeRecipient,
signedOrder.maker,
signedOrder.taker,
signedOrder.makerTokenAddress,
signedOrder.takerTokenAddress,
signedOrder.feeRecipient,
]);
batchFill.orderValues.push([
order.params.makerTokenAmount,
order.params.takerTokenAmount,
order.params.makerFee,
order.params.takerFee,
order.params.expirationTimestampInSec,
order.params.salt,
signedOrder.makerTokenAmount,
signedOrder.takerTokenAmount,
signedOrder.makerFee,
signedOrder.takerFee,
signedOrder.expirationUnixTimestampSec,
signedOrder.salt,
]);
batchFill.v.push(order.params.v as number);
batchFill.r.push(order.params.r as string);
batchFill.s.push(order.params.s as string);
if (fillTakerTokenAmounts.length < orders.length) {
batchFill.fillTakerTokenAmounts.push(order.params.takerTokenAmount);
batchFill.v.push(signedOrder.ecSignature.v);
batchFill.r.push(signedOrder.ecSignature.r);
batchFill.s.push(signedOrder.ecSignature.s);
if (fillTakerTokenAmounts.length < signedOrders.length) {
batchFill.fillTakerTokenAmounts.push(signedOrder.takerTokenAmount);
}
});
return batchFill;
},
createFillUpTo(
orders: Order[],
signedOrders: SignedOrder[],
shouldThrowOnInsufficientBalanceOrAllowance: boolean,
fillTakerTokenAmount: BigNumber,
) {
@@ -58,52 +58,52 @@ export const formatters = {
r: [],
s: [],
};
orders.forEach(order => {
signedOrders.forEach(signedOrder => {
fillUpTo.orderAddresses.push([
order.params.maker,
order.params.taker,
order.params.makerToken,
order.params.takerToken,
order.params.feeRecipient,
signedOrder.maker,
signedOrder.taker,
signedOrder.makerTokenAddress,
signedOrder.takerTokenAddress,
signedOrder.feeRecipient,
]);
fillUpTo.orderValues.push([
order.params.makerTokenAmount,
order.params.takerTokenAmount,
order.params.makerFee,
order.params.takerFee,
order.params.expirationTimestampInSec,
order.params.salt,
signedOrder.makerTokenAmount,
signedOrder.takerTokenAmount,
signedOrder.makerFee,
signedOrder.takerFee,
signedOrder.expirationUnixTimestampSec,
signedOrder.salt,
]);
fillUpTo.v.push(order.params.v as number);
fillUpTo.r.push(order.params.r as string);
fillUpTo.s.push(order.params.s as string);
fillUpTo.v.push(signedOrder.ecSignature.v);
fillUpTo.r.push(signedOrder.ecSignature.r);
fillUpTo.s.push(signedOrder.ecSignature.s);
});
return fillUpTo;
},
createBatchCancel(orders: Order[], cancelTakerTokenAmounts: BigNumber[] = []) {
createBatchCancel(signedOrders: SignedOrder[], cancelTakerTokenAmounts: BigNumber[] = []) {
const batchCancel: BatchCancelOrders = {
orderAddresses: [],
orderValues: [],
cancelTakerTokenAmounts,
};
orders.forEach(order => {
signedOrders.forEach(signedOrder => {
batchCancel.orderAddresses.push([
order.params.maker,
order.params.taker,
order.params.makerToken,
order.params.takerToken,
order.params.feeRecipient,
signedOrder.maker,
signedOrder.taker,
signedOrder.makerTokenAddress,
signedOrder.takerTokenAddress,
signedOrder.feeRecipient,
]);
batchCancel.orderValues.push([
order.params.makerTokenAmount,
order.params.takerTokenAmount,
order.params.makerFee,
order.params.takerFee,
order.params.expirationTimestampInSec,
order.params.salt,
signedOrder.makerTokenAmount,
signedOrder.takerTokenAmount,
signedOrder.makerFee,
signedOrder.takerFee,
signedOrder.expirationUnixTimestampSec,
signedOrder.salt,
]);
if (cancelTakerTokenAmounts.length < orders.length) {
batchCancel.cancelTakerTokenAmounts.push(order.params.takerTokenAmount);
if (cancelTakerTokenAmounts.length < signedOrders.length) {
batchCancel.cancelTakerTokenAmounts.push(signedOrder.takerTokenAmount);
}
});
return batchCancel;

View File

@@ -1,106 +0,0 @@
import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import ethUtil = require('ethereumjs-util');
import * as _ from 'lodash';
import { crypto } from './crypto';
import { OrderParams } from './types';
export class Order {
public params: OrderParams;
private _web3Wrapper: Web3Wrapper;
constructor(web3Wrapper: Web3Wrapper, params: OrderParams) {
this.params = params;
this._web3Wrapper = web3Wrapper;
}
public isValidSignature() {
const { v, r, s } = this.params;
if (_.isUndefined(v) || _.isUndefined(r) || _.isUndefined(s)) {
throw new Error('Cannot call isValidSignature on unsigned order');
}
const orderHash = this._getOrderHash();
const msgHash = ethUtil.hashPersonalMessage(ethUtil.toBuffer(orderHash));
try {
const pubKey = ethUtil.ecrecover(msgHash, v, ethUtil.toBuffer(r), ethUtil.toBuffer(s));
const recoveredAddress = ethUtil.bufferToHex(ethUtil.pubToAddress(pubKey));
return recoveredAddress === this.params.maker;
} catch (err) {
return false;
}
}
public async signAsync() {
const orderHash = this._getOrderHash();
const signature = await this._web3Wrapper.signTransactionAsync(this.params.maker, orderHash);
const { v, r, s } = ethUtil.fromRpcSig(signature);
this.params = _.assign(this.params, {
orderHashHex: orderHash,
v,
r: ethUtil.bufferToHex(r),
s: ethUtil.bufferToHex(s),
});
}
public createFill(shouldThrowOnInsufficientBalanceOrAllowance?: boolean, fillTakerTokenAmount?: BigNumber) {
const fill = {
orderAddresses: [
this.params.maker,
this.params.taker,
this.params.makerToken,
this.params.takerToken,
this.params.feeRecipient,
],
orderValues: [
this.params.makerTokenAmount,
this.params.takerTokenAmount,
this.params.makerFee,
this.params.takerFee,
this.params.expirationTimestampInSec,
this.params.salt,
],
fillTakerTokenAmount: fillTakerTokenAmount || this.params.takerTokenAmount,
shouldThrowOnInsufficientBalanceOrAllowance: !!shouldThrowOnInsufficientBalanceOrAllowance,
v: this.params.v,
r: this.params.r,
s: this.params.s,
};
return fill;
}
public createCancel(cancelTakerTokenAmount?: BigNumber) {
const cancel = {
orderAddresses: [
this.params.maker,
this.params.taker,
this.params.makerToken,
this.params.takerToken,
this.params.feeRecipient,
],
orderValues: [
this.params.makerTokenAmount,
this.params.takerTokenAmount,
this.params.makerFee,
this.params.takerFee,
this.params.expirationTimestampInSec,
this.params.salt,
],
cancelTakerTokenAmount: cancelTakerTokenAmount || this.params.takerTokenAmount,
};
return cancel;
}
private _getOrderHash(): string {
const orderHash = crypto.solSHA3([
this.params.exchangeContractAddress,
this.params.maker,
this.params.taker,
this.params.makerToken,
this.params.takerToken,
this.params.feeRecipient,
this.params.makerTokenAmount,
this.params.takerTokenAmount,
this.params.makerFee,
this.params.takerFee,
this.params.expirationTimestampInSec,
this.params.salt,
]);
const orderHashHex = ethUtil.bufferToHex(orderHash);
return orderHashHex;
}
}

View File

@@ -1,32 +1,37 @@
import { ZeroEx } from '0x.js';
import { Order, SignedOrder, ZeroEx } from '0x.js';
import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as _ from 'lodash';
import { Order } from './order';
import { DefaultOrderParams, OptionalOrderParams, OrderParams } from './types';
import { DefaultOrderParams } from './types';
export class OrderFactory {
private _defaultOrderParams: DefaultOrderParams;
private _web3Wrapper: Web3Wrapper;
constructor(web3Wrapper: Web3Wrapper, defaultOrderParams: DefaultOrderParams) {
private _defaultOrderParams: Partial<Order>;
private _zeroEx: ZeroEx;
constructor(zeroEx: ZeroEx, defaultOrderParams: Partial<Order>) {
this._defaultOrderParams = defaultOrderParams;
this._web3Wrapper = web3Wrapper;
this._zeroEx = zeroEx;
}
public async newSignedOrderAsync(customOrderParams: OptionalOrderParams = {}): Promise<Order> {
public async newSignedOrderAsync(customOrderParams: Partial<Order> = {}): Promise<SignedOrder> {
const randomExpiration = new BigNumber(Math.floor((Date.now() + Math.random() * 100000000000) / 1000));
const orderParams: OrderParams = _.assign(
{},
{
expirationTimestampInSec: randomExpiration,
salt: ZeroEx.generatePseudoRandomSalt(),
taker: ZeroEx.NULL_ADDRESS,
},
this._defaultOrderParams,
customOrderParams,
const order = ({
expirationUnixTimestampSec: randomExpiration,
salt: ZeroEx.generatePseudoRandomSalt(),
taker: ZeroEx.NULL_ADDRESS,
...this._defaultOrderParams,
...customOrderParams,
} as any) as Order;
const orderHashHex = ZeroEx.getOrderHashHex(order);
const shouldAddPersonalMessagePrefix = false;
const ecSignature = await this._zeroEx.signOrderHashAsync(
orderHashHex,
order.maker,
shouldAddPersonalMessagePrefix,
);
const order = new Order(this._web3Wrapper, orderParams);
await order.signAsync();
return order;
const signedOrder = {
...order,
ecSignature,
};
return signedOrder;
}
}

View File

@@ -0,0 +1,49 @@
import { SignedOrder } from '0x.js';
import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import ethUtil = require('ethereumjs-util');
import * as _ from 'lodash';
import { crypto } from './crypto';
export const signedOrderUtils = {
createFill: (
signedOrder: SignedOrder,
shouldThrowOnInsufficientBalanceOrAllowance?: boolean,
fillTakerTokenAmount?: BigNumber,
) => {
const fill = {
...signedOrderUtils.getOrderAddressesAndValues(signedOrder),
fillTakerTokenAmount: fillTakerTokenAmount || signedOrder.takerTokenAmount,
shouldThrowOnInsufficientBalanceOrAllowance: !!shouldThrowOnInsufficientBalanceOrAllowance,
...signedOrder.ecSignature,
};
return fill;
},
createCancel(signedOrder: SignedOrder, cancelTakerTokenAmount?: BigNumber) {
const cancel = {
...signedOrderUtils.getOrderAddressesAndValues(signedOrder),
cancelTakerTokenAmount: cancelTakerTokenAmount || signedOrder.takerTokenAmount,
};
return cancel;
},
getOrderAddressesAndValues(signedOrder: SignedOrder) {
return {
orderAddresses: [
signedOrder.maker,
signedOrder.taker,
signedOrder.makerTokenAddress,
signedOrder.takerTokenAddress,
signedOrder.feeRecipient,
],
orderValues: [
signedOrder.makerTokenAmount,
signedOrder.takerTokenAmount,
signedOrder.makerFee,
signedOrder.takerFee,
signedOrder.expirationUnixTimestampSec,
signedOrder.salt,
],
};
},
};

View File

@@ -49,39 +49,6 @@ export interface DefaultOrderParams {
takerFee: BigNumber;
}
export interface OptionalOrderParams {
exchangeContractAddress?: string;
maker?: string;
taker?: string;
feeRecipient?: string;
makerToken?: string;
takerToken?: string;
makerTokenAmount?: BigNumber;
takerTokenAmount?: BigNumber;
makerFee?: BigNumber;
takerFee?: BigNumber;
expirationTimestampInSec?: BigNumber;
}
export interface OrderParams {
exchangeContractAddress: string;
maker: string;
taker: string;
feeRecipient: string;
makerToken: string;
takerToken: string;
makerTokenAmount: BigNumber;
takerTokenAmount: BigNumber;
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimestampInSec: BigNumber;
salt: BigNumber;
orderHashHex?: string;
v?: number;
r?: string;
s?: string;
}
export interface TransactionDataParams {
name: string;
abi: Web3.AbiDefinition[];

View File

@@ -0,0 +1,6 @@
.*
yarn-error.log
/src/
/scripts/
test/
tsconfig.json

View File

@@ -0,0 +1,5 @@
# CHANGELOG
## v0.0.8 - _February 9, 2018_
* Fix publishing issue where .npmignore was not properly excluding undesired content (#389)

View File

@@ -1,6 +1,6 @@
{
"name": "@0xproject/deployer",
"version": "0.0.7",
"version": "0.0.8",
"description": "Smart contract deployer of 0x protocol",
"main": "lib/src/index.js",
"types": "lib/src/index.d.ts",
@@ -28,14 +28,21 @@
},
"homepage": "https://github.com/0xProject/0x.js/packages/deployer/README.md",
"devDependencies": {
"@0xproject/tslint-config": "^0.4.8",
"chai": "^4.0.1",
"copyfiles": "^1.2.0",
"mocha": "^4.0.1",
"tslint": "5.8.0",
"types-bn": "^0.0.1",
"typescript": "2.7.1",
"web3-typescript-typings": "^0.9.9"
"web3-typescript-typings": "^0.9.10"
},
"dependencies": {
"@0xproject/utils": "^0.3.1",
"@0xproject/web3-wrapper": "^0.1.11",
"@0xproject/json-schemas": "^0.7.10",
"@0xproject/types": "^0.2.1",
"@0xproject/utils": "^0.3.2",
"@0xproject/web3-wrapper": "^0.1.12",
"ethereumjs-util": "^5.1.1",
"lodash": "^4.17.4",
"solc": "^0.4.18",
"web3": "^0.20.0",

View File

@@ -1,39 +1,5 @@
const execAsync = require('async-child-process').execAsync;
const postpublish_utils = require('../../../scripts/postpublish_utils');
const packageJSON = require('../package.json');
const cwd = __dirname + '/..';
const subPackageName = packageJSON.name;
const S3BucketPath = 's3://connect-docs-jsons/';
let tag;
let version;
postpublish_utils
.getLatestTagAndVersionAsync(subPackageName)
.then(function(result) {
tag = result.tag;
version = result.version;
const releaseName = postpublish_utils.getReleaseName(subPackageName, version);
return postpublish_utils.publishReleaseNotes(tag, releaseName);
})
.then(function(release) {
console.log('POSTPUBLISH: Release successful, generating docs...');
const jsonFilePath = __dirname + '/../' + postpublish_utils.generatedDocsDirectoryName + '/index.json';
return execAsync('JSON_FILE_PATH=' + jsonFilePath + ' PROJECT_DIR=' + __dirname + '/.. yarn docs:json', {
cwd,
});
})
.then(function(result) {
if (result.stderr !== '') {
throw new Error(result.stderr);
}
const fileName = 'v' + version + '.json';
console.log('POSTPUBLISH: Doc generation successful, uploading docs... as ', fileName);
const s3Url = S3BucketPath + fileName;
return execAsync('S3_URL=' + s3Url + ' yarn upload_docs_json', {
cwd,
});
})
.catch(function(err) {
throw err;
});
postpublish_utils.standardPostPublishAsync(subPackageName);

View File

@@ -1,6 +1,6 @@
import { migrator } from './migrations/migrate';
import { Compiler } from './compiler';
import { Deployer } from './deployer';
import { migrator } from './migrations/migrate';
import { CompilerOptions, DeployerOptions } from './utils/types';
export const commands = {

View File

@@ -1,8 +1,11 @@
declare module 'solc' {
// tslint:disable:completed-docs
export function compile(sources: any, optimizerEnabled: number, findImports: (importPath: string) => any): any;
export function setupMethods(solcBin: any): any;
// tslint:enable:completed-docs
}
declare module 'web3-eth-abi' {
// tslint:disable-next-line:completed-docs
export function encodeParameters(typesArray: string[], parameters: any[]): string;
}

View File

@@ -1,5 +1,5 @@
import { constants } from '../../utils/constants';
import { Token } from '../../types';
import { constants } from '../../utils/constants';
export const tokenInfo: Token[] = [
{

View File

@@ -4,6 +4,7 @@ import * as _ from 'lodash';
import { Deployer } from '../deployer';
import { constants } from '../utils/constants';
import { tokenInfo } from './config/token_info';
export const migrator = {

View File

@@ -5,6 +5,7 @@ import { Compiler } from '../src/compiler';
import { Deployer } from '../src/deployer';
import { fsWrapper } from '../src/utils/fs_wrapper';
import { CompilerOptions, ContractArtifact, ContractData, DoneCallback } from '../src/utils/types';
import { constructor_args, exchange_binary } from './fixtures/exchange_bin';
import { constants } from './util/constants';

View File

@@ -0,0 +1,3 @@
{
"extends": ["@0xproject/tslint-config"]
}

View File

@@ -0,0 +1,5 @@
.*
yarn-error.log
/src/
/scripts/
tsconfig.json

View File

@@ -1,5 +1,9 @@
# CHANGELOG
## v0.0.12 - _February 9, 2018_
* Fix publishing issue where .npmignore was not properly excluding undesired content (#389)
## v0.0.11 - _February 7, 2018_
* Updated `types-ethereumjs-util` dev dependency (#352)

View File

@@ -1,6 +1,6 @@
{
"name": "@0xproject/dev-utils",
"version": "0.0.11",
"version": "0.0.12",
"description": "0x dev TS utils",
"main": "lib/index.js",
"types": "lib/index.d.ts",
@@ -20,8 +20,8 @@
},
"homepage": "https://github.com/0xProject/0x.js/packages/dev-utils/README.md",
"devDependencies": {
"@0xproject/tslint-config": "^0.4.7",
"@0xproject/types": "^0.2.0",
"@0xproject/tslint-config": "^0.4.8",
"@0xproject/types": "^0.2.1",
"@types/lodash": "^4.14.86",
"npm-run-all": "^4.1.2",
"shx": "^0.2.2",
@@ -31,7 +31,7 @@
"typescript": "2.7.1"
},
"dependencies": {
"@0xproject/utils": "^0.3.1",
"@0xproject/utils": "^0.3.2",
"ethereumjs-util": "^5.1.2",
"lodash": "^4.17.4",
"request-promise-native": "^1.0.5",

View File

@@ -2,14 +2,4 @@ const postpublish_utils = require('../../../scripts/postpublish_utils');
const packageJSON = require('../package.json');
const subPackageName = packageJSON.name;
postpublish_utils
.getLatestTagAndVersionAsync(subPackageName)
.then(function(result) {
const releaseName = postpublish_utils.getReleaseName(subPackageName, result.version);
const assets = [];
return postpublish_utils.publishReleaseNotes(result.tag, releaseName, assets);
})
.catch(function(err) {
throw err;
});
postpublish_utils.standardPostPublishAsync(subPackageName);

View File

@@ -0,0 +1,7 @@
.*
yarn-error.log
/src/
/scripts/
/schemas/
test/
tsconfig.json

View File

@@ -1,5 +1,9 @@
# CHANGELOG
## v0.7.10 - _February 9, 2018_
* Fix publishing issue where .npmignore was not properly excluding undesired content (#389)
## v0.7.0 - _December 20, 2017_
* Rename `subscriptionOptsSchema` to `blockRangeSchema` (#272)

View File

@@ -1,6 +1,6 @@
{
"name": "@0xproject/json-schemas",
"version": "0.7.9",
"version": "0.7.10",
"description": "0x-related json schemas",
"main": "lib/src/index.js",
"types": "lib/src/index.d.ts",
@@ -28,13 +28,13 @@
"lodash.values": "^4.3.0"
},
"devDependencies": {
"@0xproject/tslint-config": "^0.4.7",
"@0xproject/utils": "^0.3.1",
"@0xproject/tslint-config": "^0.4.8",
"@0xproject/utils": "^0.3.2",
"@types/lodash.foreach": "^4.5.3",
"@types/lodash.values": "^4.3.3",
"@types/mocha": "^2.2.42",
"chai": "^4.0.1",
"chai-typescript-typings": "^0.0.2",
"chai-typescript-typings": "^0.0.3",
"dirty-chai": "^2.0.1",
"lodash.foreach": "^4.5.0",
"mocha": "^4.0.1",

View File

@@ -2,14 +2,4 @@ const postpublish_utils = require('../../../scripts/postpublish_utils');
const packageJSON = require('../package.json');
const subPackageName = packageJSON.name;
postpublish_utils
.getLatestTagAndVersionAsync(subPackageName)
.then(function(result) {
const releaseName = postpublish_utils.getReleaseName(subPackageName, result.version);
const assets = [];
return postpublish_utils.publishReleaseNotes(result.tag, releaseName, assets);
})
.catch(function(err) {
throw err;
});
postpublish_utils.standardPostPublishAsync(subPackageName);

View File

@@ -1,6 +1,6 @@
{
"name": "@0xproject/monorepo-scripts",
"version": "0.1.9",
"version": "0.1.10",
"private": true,
"description": "Helper scripts for the monorepo",
"scripts": {
@@ -20,7 +20,7 @@
},
"homepage": "https://github.com/0xProject/0x.js/packages/monorepo-scripts/README.md",
"devDependencies": {
"@0xproject/tslint-config": "^0.4.7",
"@0xproject/tslint-config": "^0.4.8",
"@types/glob": "^5.0.33",
"@types/node": "^8.0.53",
"shx": "^0.2.2",

View File

@@ -1,15 +0,0 @@
const postpublish_utils = require('../../../scripts/postpublish_utils');
const packageJSON = require('../package.json');
const subPackageName = packageJSON.name;
postpublish_utils
.getLatestTagAndVersionAsync(subPackageName)
.then(function(result) {
const releaseName = postpublish_utils.getReleaseName(subPackageName, result.version);
const assets = [];
return postpublish_utils.publishReleaseNotes(result.tag, releaseName, assets);
})
.catch(function(err) {
throw err;
});

View File

@@ -0,0 +1,6 @@
.*
yarn-error.log
/src/
/scripts/
test/
tsconfig.json

View File

@@ -1,5 +1,9 @@
# CHANGELOG
## v0.4.1 - _February 9, 2018_
* Fix publishing issue where .npmignore was not properly excluding undesired content (#389)
## v0.4.0 - _February 7, 2018_
* Added NonceTrackerSubprovider (#355)

View File

@@ -1,6 +1,6 @@
{
"name": "@0xproject/subproviders",
"version": "0.4.0",
"version": "0.4.1",
"main": "lib/src/index.js",
"types": "lib/src/index.d.ts",
"license": "Apache-2.0",
@@ -18,8 +18,8 @@
"test:integration": "run-s clean build run_mocha_integration"
},
"dependencies": {
"@0xproject/assert": "^0.0.17",
"@0xproject/utils": "^0.3.1",
"@0xproject/assert": "^0.0.18",
"@0xproject/utils": "^0.3.2",
"bn.js": "^4.11.8",
"es6-promisify": "^5.0.0",
"ethereumjs-tx": "^1.3.3",
@@ -32,17 +32,17 @@
"web3-provider-engine": "^13.0.1"
},
"devDependencies": {
"@0xproject/tslint-config": "^0.4.7",
"@0xproject/types": "^0.2.0",
"@0xproject/utils": "^0.3.1",
"@0xproject/tslint-config": "^0.4.8",
"@0xproject/types": "^0.2.1",
"@0xproject/utils": "^0.3.2",
"@types/lodash": "^4.14.86",
"@types/mocha": "^2.2.42",
"@types/node": "^8.0.53",
"awesome-typescript-loader": "^3.1.3",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"chai-as-promised-typescript-typings": "^0.0.8",
"chai-typescript-typings": "^0.0.2",
"chai-as-promised-typescript-typings": "^0.0.9",
"chai-typescript-typings": "^0.0.3",
"dirty-chai": "^2.0.1",
"mocha": "^4.0.1",
"npm-run-all": "^4.1.2",
@@ -51,7 +51,7 @@
"types-bn": "^0.0.1",
"types-ethereumjs-util": "0xProject/types-ethereumjs-util",
"typescript": "2.7.1",
"web3-typescript-typings": "^0.9.9",
"web3-typescript-typings": "^0.9.10",
"webpack": "^3.1.0"
}
}

View File

@@ -2,13 +2,4 @@ const postpublish_utils = require('../../../scripts/postpublish_utils');
const packageJSON = require('../package.json');
const subPackageName = packageJSON.name;
postpublish_utils.getLatestTagAndVersionAsync(subPackageName)
.then(function(result) {
const releaseName = postpublish_utils.getReleaseName(subPackageName, result.version);
const assets = [];
return postpublish_utils.publishReleaseNotes(result.tag, releaseName, assets);
})
.catch (function(err) {
throw err;
});
postpublish_utils.standardPostPublishAsync(subPackageName);

View File

@@ -1,7 +1,7 @@
{
"private": true,
"name": "@0xproject/testnet-faucets",
"version": "1.0.11",
"version": "1.0.12",
"description": "A faucet micro-service that dispenses test ERC20 tokens or Ether",
"main": "server.js",
"scripts": {
@@ -15,9 +15,9 @@
"author": "Fabio Berger",
"license": "Apache-2.0",
"dependencies": {
"0x.js": "^0.32.1",
"@0xproject/subproviders": "^0.4.0",
"@0xproject/utils": "^0.3.1",
"0x.js": "^0.32.2",
"@0xproject/subproviders": "^0.4.1",
"@0xproject/utils": "^0.3.2",
"body-parser": "^1.17.1",
"ethereumjs-tx": "^1.3.3",
"ethereumjs-util": "^5.1.1",
@@ -28,7 +28,7 @@
"web3-provider-engine": "^13.0.1"
},
"devDependencies": {
"@0xproject/tslint-config": "^0.4.7",
"@0xproject/tslint-config": "^0.4.8",
"@types/body-parser": "^1.16.1",
"@types/express": "^4.0.35",
"@types/lodash": "^4.14.86",
@@ -41,7 +41,7 @@
"types-bn": "^0.0.1",
"types-ethereumjs-util": "0xProject/types-ethereumjs-util",
"typescript": "2.7.1",
"web3-typescript-typings": "^0.9.9",
"web3-typescript-typings": "^0.9.10",
"webpack": "^3.1.0",
"webpack-node-externals": "^1.6.0"
}

View File

@@ -1,15 +0,0 @@
const postpublish_utils = require('../../../scripts/postpublish_utils');
const packageJSON = require('../package.json');
const subPackageName = packageJSON.name;
postpublish_utils
.getLatestTagAndVersionAsync(subPackageName)
.then(function(result) {
const releaseName = postpublish_utils.getReleaseName(subPackageName, result.version);
const assets = [];
return postpublish_utils.publishReleaseNotes(result.tag, releaseName, assets);
})
.catch(function(err) {
throw err;
});

View File

@@ -129,18 +129,18 @@ export class Handler {
}
const zeroEx = networkConfig.zeroEx;
res.setHeader('Content-Type', 'application/json');
const makerTokenAddress = await zeroEx.tokenRegistry.getTokenAddressBySymbolIfExistsAsync(requestedAssetType);
if (_.isUndefined(makerTokenAddress)) {
const makerToken = await zeroEx.tokenRegistry.getTokenBySymbolIfExistsAsync(requestedAssetType);
if (_.isUndefined(makerToken)) {
throw new Error(`Unsupported asset type: ${requestedAssetType}`);
}
const takerTokenSymbol =
requestedAssetType === RequestedAssetType.WETH ? RequestedAssetType.ZRX : RequestedAssetType.WETH;
const takerTokenAddress = await zeroEx.tokenRegistry.getTokenAddressBySymbolIfExistsAsync(takerTokenSymbol);
if (_.isUndefined(takerTokenAddress)) {
const takerToken = await zeroEx.tokenRegistry.getTokenBySymbolIfExistsAsync(takerTokenSymbol);
if (_.isUndefined(takerToken)) {
throw new Error(`Unsupported asset type: ${requestedAssetType}`);
}
const makerTokenAmount = new BigNumber(0.1);
const takerTokenAmount = new BigNumber(0.1);
const makerTokenAmount = ZeroEx.toBaseUnitAmount(new BigNumber(0.1), makerToken.decimals);
const takerTokenAmount = ZeroEx.toBaseUnitAmount(new BigNumber(0.1), takerToken.decimals);
const order: Order = {
maker: configs.DISPENSER_ADDRESS,
taker: req.params.recipient,
@@ -148,8 +148,8 @@ export class Handler {
takerFee: new BigNumber(0),
makerTokenAmount,
takerTokenAmount,
makerTokenAddress,
takerTokenAddress,
makerTokenAddress: makerToken.address,
takerTokenAddress: takerToken.address,
salt: ZeroEx.generatePseudoRandomSalt(),
exchangeContractAddress: zeroEx.exchange.getContractAddress(),
feeRecipient: ZeroEx.NULL_ADDRESS,
@@ -159,7 +159,7 @@ export class Handler {
const signature = await zeroEx.signOrderHashAsync(orderHash, configs.DISPENSER_ADDRESS, false);
const signedOrder = {
...order,
signature,
ecSignature: signature,
};
const signedOrderHash = ZeroEx.getOrderHashHex(signedOrder);
const payload = JSON.stringify(signedOrder);

View File

@@ -1,8 +1,8 @@
import { configs } from './configs';
const productionRpcUrls = {
'2': `https://ropsten.infura.io/${configs.INFURA_API_KEY}`,
'3': `https://rinkeby.infura.io/${configs.INFURA_API_KEY}`,
'3': `https://ropsten.infura.io/${configs.INFURA_API_KEY}`,
'4': `https://rinkeby.infura.io/${configs.INFURA_API_KEY}`,
'42': `https://kovan.infura.io/${configs.INFURA_API_KEY}`,
};

View File

@@ -0,0 +1,6 @@
.*
yarn-error.log
node_modules/
/scripts/
/rules/
tsconfig.json

View File

@@ -1,6 +1,14 @@
# CHANGELOG
## v0.5.0 - _TBD, 2018_
## v0.4.9 - _February 9, 2018_
* Move devDeps to deps to fix missed dependency issue in published package.
## v0.4.8 - _February 9, 2018_
* Fix publish issue where custom TSLint rules were not being included (#389)
## v0.4.7 - _February 7, 2018_
* Modified custom 'underscore-privates' rule, changing it to 'underscore-private-and-protected' requiring underscores to be prepended to both private and protected variable names (#354)

View File

@@ -1,6 +1,6 @@
{
"name": "@0xproject/tslint-config",
"version": "0.4.7",
"version": "0.4.8",
"description": "Lint rules related to 0xProject for TSLint",
"main": "tslint.json",
"scripts": {
@@ -9,11 +9,6 @@
"clean": "shx rm -rf lib",
"lint": "tslint --project . 'rules/**/*.ts'"
},
"files": [
"tslint.js",
"README.md",
"LICENSE"
],
"repository": {
"type": "git",
"url": "git://github.com/0xProject/0x.js.git"
@@ -37,12 +32,12 @@
"devDependencies": {
"@types/lodash": "^4.14.86",
"shx": "^0.2.2",
"tslint": "5.8.0",
"tslint-eslint-rules": "^4.1.1",
"typescript": "2.7.1"
},
"dependencies": {
"lodash": "^4.17.4",
"tslint": "5.8.0",
"tslint-eslint-rules": "^4.1.1",
"tslint-react": "^3.2.0"
}
}

View File

@@ -2,13 +2,4 @@ const postpublish_utils = require('../../../scripts/postpublish_utils');
const packageJSON = require('../package.json');
const subPackageName = packageJSON.name;
postpublish_utils.getLatestTagAndVersionAsync(subPackageName)
.then(function(result) {
const releaseName = postpublish_utils.getReleaseName(subPackageName, result.version);
const assets = [];
return postpublish_utils.publishReleaseNotes(result.tag, releaseName, assets);
})
.catch (function(err) {
throw err;
});
postpublish_utils.standardPostPublishAsync(subPackageName);

View File

@@ -0,0 +1,5 @@
.*
yarn-error.log
/scripts/
/src/
tsconfig.json

View File

@@ -1,5 +1,9 @@
# CHANGELOG
## v0.2.1 - _February 9, 2018_
* Fix publishing issue where .npmignore was not properly excluding undesired content (#389)
## v0.2.0 - _February 7, 2018_
* Added BlockLiteralParam and BlockParam, refactored out of 0x.js types. (#355)

View File

@@ -1,6 +1,6 @@
{
"name": "@0xproject/types",
"version": "0.2.0",
"version": "0.2.1",
"description": "0x types",
"main": "lib/index.js",
"types": "lib/index.d.ts",
@@ -20,11 +20,11 @@
},
"homepage": "https://github.com/0xProject/0x.js/packages/types/README.md",
"devDependencies": {
"@0xproject/tslint-config": "^0.4.7",
"@0xproject/tslint-config": "^0.4.8",
"shx": "^0.2.2",
"tslint": "5.8.0",
"typescript": "2.7.1",
"web3-typescript-typings": "^0.9.9"
"web3-typescript-typings": "^0.9.10"
},
"dependencies": {
"bignumber.js": "~4.1.0",

View File

@@ -2,13 +2,4 @@ const postpublish_utils = require('../../../scripts/postpublish_utils');
const packageJSON = require('../package.json');
const subPackageName = packageJSON.name;
postpublish_utils.getLatestTagAndVersionAsync(subPackageName)
.then(function(result) {
const releaseName = postpublish_utils.getReleaseName(subPackageName, result.version);
const assets = [];
return postpublish_utils.publishReleaseNotes(result.tag, releaseName, assets);
})
.catch (function(err) {
throw err;
});
postpublish_utils.standardPostPublishAsync(subPackageName);

View File

@@ -0,0 +1,5 @@
.*
yarn-error.log
/scripts/
/src/
tsconfig.json

View File

@@ -1,5 +1,9 @@
# CHANGELOG
## v0.3.2 - _February 9, 2018_
* Fix publishing issue where .npmignore was not properly excluding undesired content (#389)
## v0.3.0 - _February 5, 2018_
* Fix a bug related to event signature collisions (argument indexes aren't included in event signatures) in the abi_decoder. The decoder used to throw on unknown events with identical signatures as a known event (except indexes). (#366)

View File

@@ -1,6 +1,6 @@
{
"name": "@0xproject/utils",
"version": "0.3.1",
"version": "0.3.2",
"description": "0x TS utils",
"main": "lib/index.js",
"types": "lib/index.d.ts",
@@ -20,14 +20,14 @@
},
"homepage": "https://github.com/0xProject/0x.js/packages/utils/README.md",
"devDependencies": {
"@0xproject/tslint-config": "^0.4.7",
"@0xproject/types": "^0.2.0",
"@0xproject/tslint-config": "^0.4.8",
"@0xproject/types": "^0.2.1",
"@types/lodash": "^4.14.86",
"npm-run-all": "^4.1.2",
"shx": "^0.2.2",
"tslint": "5.8.0",
"typescript": "2.7.1",
"web3-typescript-typings": "^0.9.9"
"web3-typescript-typings": "^0.9.10"
},
"dependencies": {
"bignumber.js": "~4.1.0",

View File

@@ -2,13 +2,4 @@ const postpublish_utils = require('../../../scripts/postpublish_utils');
const packageJSON = require('../package.json');
const subPackageName = packageJSON.name;
postpublish_utils.getLatestTagAndVersionAsync(subPackageName)
.then(function(result) {
const releaseName = postpublish_utils.getReleaseName(subPackageName, result.version);
const assets = [];
return postpublish_utils.publishReleaseNotes(result.tag, releaseName, assets);
})
.catch (function(err) {
throw err;
});
postpublish_utils.standardPostPublishAsync(subPackageName);

View File

@@ -1,2 +0,0 @@
.git
node_modules

View File

@@ -0,0 +1,3 @@
.*
yarn-error.log
/scripts/

View File

@@ -1,6 +1,6 @@
{
"name": "web3-typescript-typings",
"version": "0.9.9",
"version": "0.9.10",
"description": "Typescript type definitions for web3",
"main": "index.d.ts",
"types": "index.d.ts",

View File

@@ -2,14 +2,4 @@ const postpublish_utils = require('../../../scripts/postpublish_utils');
const packageJSON = require('../package.json');
const subPackageName = packageJSON.name;
postpublish_utils
.getLatestTagAndVersionAsync(subPackageName)
.then(function(result) {
const releaseName = postpublish_utils.getReleaseName(subPackageName, result.version);
const assets = [];
return postpublish_utils.publishReleaseNotes(result.tag, releaseName, assets);
})
.catch(function(err) {
throw err;
});
postpublish_utils.standardPostPublishAsync(subPackageName);

View File

@@ -1,197 +0,0 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
"@types/bignumber.js@^4.0.2":
version "4.0.2"
resolved "https://registry.yarnpkg.com/@types/bignumber.js/-/bignumber.js-4.0.2.tgz#22a16946c9faa9f2c9c0ad4c7c3734a3033320ae"
ansi-regex@^2.0.0:
version "2.1.1"
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df"
ansi-styles@^2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe"
babel-code-frame@^6.22.0:
version "6.22.0"
resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.22.0.tgz#027620bee567a88c32561574e7fd0801d33118e4"
dependencies:
chalk "^1.1.0"
esutils "^2.0.2"
js-tokens "^3.0.0"
balanced-match@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"
bignumber.js@^4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-4.0.2.tgz#2d1dc37ee5968867ecea90b6da4d16e68608d21d"
brace-expansion@^1.1.7:
version "1.1.8"
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.8.tgz#c07b211c7c952ec1f8efd51a77ef0d1d3990a292"
dependencies:
balanced-match "^1.0.0"
concat-map "0.0.1"
chalk@^1.1.0:
version "1.1.3"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98"
dependencies:
ansi-styles "^2.2.1"
escape-string-regexp "^1.0.2"
has-ansi "^2.0.0"
strip-ansi "^3.0.0"
supports-color "^2.0.0"
colors@^1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/colors/-/colors-1.1.2.tgz#168a4701756b6a7f51a12ce0c97bfa28c084ed63"
commander@^2.9.0:
version "2.11.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.11.0.tgz#157152fd1e7a6c8d98a5b715cf376df928004563"
concat-map@0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
diff@^3.2.0:
version "3.3.0"
resolved "https://registry.yarnpkg.com/diff/-/diff-3.3.0.tgz#056695150d7aa93237ca7e378ac3b1682b7963b9"
escape-string-regexp@^1.0.2:
version "1.0.5"
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
esutils@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b"
fs.realpath@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
glob@^7.1.1:
version "7.1.2"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15"
dependencies:
fs.realpath "^1.0.0"
inflight "^1.0.4"
inherits "2"
minimatch "^3.0.4"
once "^1.3.0"
path-is-absolute "^1.0.0"
has-ansi@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91"
dependencies:
ansi-regex "^2.0.0"
inflight@^1.0.4:
version "1.0.6"
resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
dependencies:
once "^1.3.0"
wrappy "1"
inherits@2:
version "2.0.3"
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
js-tokens@^3.0.0:
version "3.0.2"
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b"
minimatch@^3.0.4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
dependencies:
brace-expansion "^1.1.7"
once@^1.3.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
dependencies:
wrappy "1"
path-is-absolute@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
path-parse@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.5.tgz#3c1adf871ea9cd6c9431b6ea2bd74a0ff055c4c1"
resolve@^1.3.2:
version "1.3.3"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.3.3.tgz#655907c3469a8680dc2de3a275a8fdd69691f0e5"
dependencies:
path-parse "^1.0.5"
semver@^5.3.0:
version "5.4.1"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.4.1.tgz#e059c09d8571f0540823733433505d3a2f00b18e"
strip-ansi@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf"
dependencies:
ansi-regex "^2.0.0"
supports-color@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7"
tslib@^1.7.1:
version "1.7.1"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.7.1.tgz#bc8004164691923a79fe8378bbeb3da2017538ec"
tslint-config-0xproject@^0.0.2:
version "0.0.2"
resolved "https://registry.yarnpkg.com/tslint-config-0xproject/-/tslint-config-0xproject-0.0.2.tgz#39901e0c0b3e9388f00092a28b90c015395d5bba"
dependencies:
tslint-react "^3.0.0"
tslint-react@^3.0.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/tslint-react/-/tslint-react-3.1.0.tgz#a4de1a22fef41b663fa44daae27cbf04dc8a59d6"
dependencies:
tsutils "^1.7.0"
tslint@^5.5.0:
version "5.5.0"
resolved "https://registry.yarnpkg.com/tslint/-/tslint-5.5.0.tgz#10e8dab3e3061fa61e9442e8cee3982acf20a6aa"
dependencies:
babel-code-frame "^6.22.0"
colors "^1.1.2"
commander "^2.9.0"
diff "^3.2.0"
glob "^7.1.1"
minimatch "^3.0.4"
resolve "^1.3.2"
semver "^5.3.0"
tslib "^1.7.1"
tsutils "^2.5.1"
tsutils@^1.7.0:
version "1.9.1"
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-1.9.1.tgz#b9f9ab44e55af9681831d5f28d0aeeaf5c750cb0"
tsutils@^2.5.1:
version "2.8.0"
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.8.0.tgz#0160173729b3bf138628dd14a1537e00851d814a"
dependencies:
tslib "^1.7.1"
typescript@^2.4.2:
version "2.4.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.4.2.tgz#f8395f85d459276067c988aa41837a8f82870844"
wrappy@1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"

View File

@@ -0,0 +1,5 @@
.*
yarn-error.log
/scripts/
/src/
tsconfig.json

View File

@@ -1,3 +1,5 @@
# CHANGELOG
## vx.x.x
## v0.1.12 _February 9, 2018_
* Fix publishing issue where .npmignore was not properly excluding undesired content (#389)

View File

@@ -1,6 +1,6 @@
{
"name": "@0xproject/web3-wrapper",
"version": "0.1.11",
"version": "0.1.12",
"description": "Wraps around web3 and gives a nicer interface",
"main": "lib/index.js",
"types": "lib/index.d.ts",
@@ -20,17 +20,17 @@
},
"homepage": "https://github.com/0xProject/0x.js/packages/web3-wrapper/README.md",
"devDependencies": {
"@0xproject/tslint-config": "^0.4.7",
"@0xproject/types": "^0.2.0",
"@0xproject/tslint-config": "^0.4.8",
"@0xproject/types": "^0.2.1",
"@types/lodash": "^4.14.86",
"npm-run-all": "^4.1.2",
"shx": "^0.2.2",
"tslint": "5.8.0",
"typescript": "2.7.1",
"web3-typescript-typings": "^0.9.9"
"web3-typescript-typings": "^0.9.10"
},
"dependencies": {
"@0xproject/utils": "^0.3.1",
"@0xproject/utils": "^0.3.2",
"lodash": "^4.17.4",
"web3": "^0.20.0"
}

View File

@@ -2,13 +2,4 @@ const postpublish_utils = require('../../../scripts/postpublish_utils');
const packageJSON = require('../package.json');
const subPackageName = packageJSON.name;
postpublish_utils.getLatestTagAndVersionAsync(subPackageName)
.then(function(result) {
const releaseName = postpublish_utils.getReleaseName(subPackageName, result.version);
const assets = [];
return postpublish_utils.publishReleaseNotes(result.tag, releaseName, assets);
})
.catch (function(err) {
throw err;
});
postpublish_utils.standardPostPublishAsync(subPackageName);

View File

@@ -1,6 +1,6 @@
{
"name": "@0xproject/website",
"version": "0.0.13",
"version": "0.0.14",
"private": true,
"description": "Website and 0x portal dapp",
"scripts": {
@@ -18,9 +18,9 @@
"author": "Fabio Berger",
"license": "Apache-2.0",
"dependencies": {
"0x.js": "^0.32.1",
"@0xproject/subproviders": "^0.4.0",
"@0xproject/utils": "^0.3.1",
"0x.js": "^0.32.2",
"@0xproject/subproviders": "^0.4.1",
"@0xproject/utils": "^0.3.2",
"accounting": "^0.4.1",
"basscss": "^8.0.3",
"blockies": "^0.0.2",
@@ -98,7 +98,7 @@
"style-loader": "0.13.x",
"tslint": "5.8.0",
"typescript": "2.7.1",
"web3-typescript-typings": "^0.9.9",
"web3-typescript-typings": "^0.9.10",
"webpack": "^3.1.0",
"webpack-dev-middleware": "^1.10.0",
"webpack-dev-server": "^2.5.0"

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

View File

@@ -2,6 +2,7 @@ import {
BlockParam,
BlockRange,
DecodedLogEvent,
ECSignature,
ExchangeContractEventArgs,
ExchangeEvents,
IndexedFilterValues,
@@ -35,10 +36,10 @@ import {
BlockchainErrs,
ContractInstance,
EtherscanLinkSuffixes,
Order as PortalOrder,
ProviderType,
Side,
SideToAssetToken,
SignatureData,
Token,
TokenByAddress,
} from 'ts/types';
@@ -288,39 +289,24 @@ export class Blockchain {
}),
);
}
public portalOrderToSignedOrder(
maker: string,
taker: string,
makerTokenAddress: string,
takerTokenAddress: string,
makerTokenAmount: BigNumber,
takerTokenAmount: BigNumber,
makerFee: BigNumber,
takerFee: BigNumber,
expirationUnixTimestampSec: BigNumber,
feeRecipient: string,
signatureData: SignatureData,
salt: BigNumber,
): SignedOrder {
const ecSignature = signatureData;
public portalOrderToZeroExOrder(portalOrder: PortalOrder): SignedOrder {
const exchangeContractAddress = this.getExchangeContractAddressIfExists();
const takerOrNullAddress = _.isEmpty(taker) ? constants.NULL_ADDRESS : taker;
const signedOrder = {
ecSignature,
const zeroExSignedOrder = {
exchangeContractAddress,
expirationUnixTimestampSec,
feeRecipient,
maker,
makerFee,
makerTokenAddress,
makerTokenAmount,
salt,
taker: takerOrNullAddress,
takerFee,
takerTokenAddress,
takerTokenAmount,
maker: portalOrder.signedOrder.maker,
taker: portalOrder.signedOrder.taker,
makerTokenAddress: portalOrder.signedOrder.makerTokenAddress,
takerTokenAddress: portalOrder.signedOrder.takerTokenAddress,
makerTokenAmount: new BigNumber(portalOrder.signedOrder.makerTokenAmount),
takerTokenAmount: new BigNumber(portalOrder.signedOrder.takerTokenAmount),
makerFee: new BigNumber(portalOrder.signedOrder.makerFee),
takerFee: new BigNumber(portalOrder.signedOrder.takerFee),
expirationUnixTimestampSec: new BigNumber(portalOrder.signedOrder.expirationUnixTimestampSec),
feeRecipient: portalOrder.signedOrder.feeRecipient,
ecSignature: portalOrder.signedOrder.ecSignature,
salt: new BigNumber(portalOrder.signedOrder.salt),
};
return signedOrder;
return zeroExSignedOrder;
}
public async fillOrderAsync(signedOrder: SignedOrder, fillTakerTokenAmount: BigNumber): Promise<BigNumber> {
utils.assert(this._doesUserAddressExist(), BlockchainCallErrs.UserHasNoAssociatedAddresses);
@@ -413,7 +399,7 @@ export class Blockchain {
return newTokenBalancePromise;
}
public async signOrderHashAsync(orderHash: string): Promise<SignatureData> {
public async signOrderHashAsync(orderHash: string): Promise<ECSignature> {
utils.assert(!_.isUndefined(this._zeroEx), 'ZeroEx must be instantiated.');
const makerAddress = this._userAddress;
// If makerAddress is undefined, this means they have a web3 instance injected into their browser
@@ -436,11 +422,8 @@ export class Blockchain {
makerAddress,
shouldAddPersonalMessagePrefix,
);
const signatureData = _.extend({}, ecSignature, {
hash: orderHash,
});
this._dispatcher.updateSignatureData(signatureData);
return signatureData;
this._dispatcher.updateECSignature(ecSignature);
return ecSignature;
}
public async mintTestTokensAsync(token: Token) {
utils.assert(this._doesUserAddressExist(), BlockchainCallErrs.UserHasNoAssociatedAddresses);

View File

@@ -18,8 +18,8 @@ import { EthereumAddress } from 'ts/components/ui/ethereum_address';
import { Identicon } from 'ts/components/ui/identicon';
import { VisualOrder } from 'ts/components/visual_order';
import { Dispatcher } from 'ts/redux/dispatcher';
import { orderSchema } from 'ts/schemas/order_schema';
import { SchemaValidator } from 'ts/schemas/validator';
import { portalOrderSchema } from 'ts/schemas/portal_order_schema';
import { validator } from 'ts/schemas/validator';
import { AlertTypes, BlockchainErrs, Order, Token, TokenByAddress, WebsitePaths } from 'ts/types';
import { colors } from 'ts/utils/colors';
import { constants } from 'ts/utils/constants';
@@ -59,7 +59,6 @@ interface FillOrderState {
}
export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
private _validator: SchemaValidator;
private _isUnmounted: boolean;
constructor(props: FillOrderProps) {
super(props);
@@ -82,7 +81,6 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
isConfirmingTokenTracking: false,
tokensToTrack: [],
};
this._validator = new SchemaValidator();
}
public componentWillMount() {
if (!_.isEmpty(this.state.orderJSON)) {
@@ -109,7 +107,6 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
<FillOrderJSON
blockchain={this.props.blockchain}
tokenByAddress={this.props.tokenByAddress}
networkId={this.props.networkId}
orderJSON={this.state.orderJSON}
onFillOrderJSONChanged={this._onFillOrderJSONChanged.bind(this)}
/>
@@ -136,7 +133,6 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
<FillOrderJSON
blockchain={this.props.blockchain}
tokenByAddress={this.props.tokenByAddress}
networkId={this.props.networkId}
orderJSON={this.state.orderJSON}
onFillOrderJSONChanged={this._onFillOrderJSONChanged.bind(this)}
/>
@@ -182,16 +178,16 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
);
}
private _renderVisualOrder() {
const takerTokenAddress = this.state.parsedOrder.taker.token.address;
const takerTokenAddress = this.state.parsedOrder.signedOrder.takerTokenAddress;
const takerToken = this.props.tokenByAddress[takerTokenAddress];
const orderTakerAmount = new BigNumber(this.state.parsedOrder.taker.amount);
const orderMakerAmount = new BigNumber(this.state.parsedOrder.maker.amount);
const orderTakerAmount = new BigNumber(this.state.parsedOrder.signedOrder.takerTokenAmount);
const orderMakerAmount = new BigNumber(this.state.parsedOrder.signedOrder.makerTokenAmount);
const takerAssetToken = {
amount: orderTakerAmount.minus(this.state.unavailableTakerAmount),
symbol: takerToken.symbol,
};
const fillToken = this.props.tokenByAddress[takerToken.address];
const makerTokenAddress = this.state.parsedOrder.maker.token.address;
const fillToken = this.props.tokenByAddress[takerTokenAddress];
const makerTokenAddress = this.state.parsedOrder.signedOrder.makerTokenAddress;
const makerToken = this.props.tokenByAddress[makerTokenAddress];
const makerAssetToken = {
amount: orderMakerAmount.times(takerAssetToken.amount).div(orderTakerAmount),
@@ -201,10 +197,7 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
amount: this.props.orderFillAmount,
symbol: takerToken.symbol,
};
const orderTaker = !_.isEmpty(this.state.parsedOrder.taker.address)
? this.state.parsedOrder.taker.address
: this.props.userAddress;
const parsedOrderExpiration = new BigNumber(this.state.parsedOrder.expiration);
const parsedOrderExpiration = new BigNumber(this.state.parsedOrder.signedOrder.expirationUnixTimestampSec);
const exchangeRate = orderMakerAmount.div(orderTakerAmount);
let orderReceiveAmount = 0;
@@ -213,7 +206,8 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
orderReceiveAmount = this._formatCurrencyAmount(orderReceiveAmountBigNumber, makerToken.decimals);
}
const isUserMaker =
!_.isUndefined(this.state.parsedOrder) && this.state.parsedOrder.maker.address === this.props.userAddress;
!_.isUndefined(this.state.parsedOrder) &&
this.state.parsedOrder.signedOrder.maker === this.props.userAddress;
const expiryDate = utils.convertToReadableDateTimeFromUnixTimestamp(parsedOrderExpiration);
return (
<div className="pt3 pb1">
@@ -224,11 +218,11 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
Maker:
</div>
<div className="col col-2 pr1">
<Identicon address={this.state.parsedOrder.maker.address} diameter={23} />
<Identicon address={this.state.parsedOrder.signedOrder.maker} diameter={23} />
</div>
<div className="col col-6">
<EthereumAddress
address={this.state.parsedOrder.maker.address}
address={this.state.parsedOrder.signedOrder.maker}
networkId={this.props.networkId}
/>
</div>
@@ -237,8 +231,6 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
<div className="lg-px4 md-px4 sm-px0">
<div className="lg-px4 md-px4 sm-px1 pt1">
<VisualOrder
orderTakerAddress={orderTaker}
orderMakerAddress={this.state.parsedOrder.maker.address}
makerAssetToken={makerAssetToken}
takerAssetToken={takerAssetToken}
tokenByAddress={this.props.tokenByAddress}
@@ -361,15 +353,16 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
return;
}
const makerTokenIfExists = this.props.tokenByAddress[this.state.parsedOrder.maker.token.address];
const takerTokenIfExists = this.props.tokenByAddress[this.state.parsedOrder.taker.token.address];
const makerTokenIfExists = this.props.tokenByAddress[this.state.parsedOrder.signedOrder.makerTokenAddress];
const takerTokenIfExists = this.props.tokenByAddress[this.state.parsedOrder.signedOrder.takerTokenAddress];
const tokensToTrack = [];
const tokensToTrack: Token[] = [];
const isUnseenMakerToken = _.isUndefined(makerTokenIfExists);
const isMakerTokenTracked = !_.isUndefined(makerTokenIfExists) && makerTokenIfExists.isTracked;
if (isUnseenMakerToken) {
tokensToTrack.push({
...this.state.parsedOrder.maker.token,
...this.state.parsedOrder.metadata.makerToken,
address: this.state.parsedOrder.signedOrder.makerTokenAddress,
iconUrl: undefined,
isTracked: false,
isRegistered: false,
@@ -381,7 +374,8 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
const isTakerTokenTracked = !_.isUndefined(takerTokenIfExists) && takerTokenIfExists.isTracked;
if (isUnseenTakerToken) {
tokensToTrack.push({
...this.state.parsedOrder.taker.token,
...this.state.parsedOrder.metadata.takerToken,
address: this.state.parsedOrder.signedOrder.takerTokenAddress,
iconUrl: undefined,
isTracked: false,
isRegistered: false,
@@ -403,9 +397,10 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
private async _validateFillOrderFireAndForgetAsync(orderJSON: string) {
let orderJSONErrMsg = '';
let parsedOrder: Order;
let orderHash: string;
try {
const order = JSON.parse(orderJSON);
const validationResult = this._validator.validate(order, orderSchema);
const validationResult = validator.validate(order, portalOrderSchema);
if (validationResult.errors.length > 0) {
orderJSONErrMsg = 'Submitted order JSON is not a valid order';
utils.consoleLog(`Unexpected order JSON validation error: ${validationResult.errors.join(', ')}`);
@@ -413,41 +408,36 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
}
parsedOrder = order;
const exchangeContractAddr = this.props.blockchain.getExchangeContractAddressIfExists();
const makerAmount = new BigNumber(parsedOrder.maker.amount);
const takerAmount = new BigNumber(parsedOrder.taker.amount);
const expiration = new BigNumber(parsedOrder.expiration);
const salt = new BigNumber(parsedOrder.salt);
const parsedMakerFee = new BigNumber(parsedOrder.maker.feeAmount);
const parsedTakerFee = new BigNumber(parsedOrder.taker.feeAmount);
const makerAmount = new BigNumber(parsedOrder.signedOrder.makerTokenAmount);
const takerAmount = new BigNumber(parsedOrder.signedOrder.takerTokenAmount);
const expiration = new BigNumber(parsedOrder.signedOrder.expirationUnixTimestampSec);
const salt = new BigNumber(parsedOrder.signedOrder.salt);
const parsedMakerFee = new BigNumber(parsedOrder.signedOrder.makerFee);
const parsedTakerFee = new BigNumber(parsedOrder.signedOrder.takerFee);
const zeroExOrder: ZeroExOrder = {
exchangeContractAddress: parsedOrder.exchangeContract,
exchangeContractAddress: parsedOrder.signedOrder.exchangeContractAddress,
expirationUnixTimestampSec: expiration,
feeRecipient: parsedOrder.feeRecipient,
maker: parsedOrder.maker.address,
feeRecipient: parsedOrder.signedOrder.feeRecipient,
maker: parsedOrder.signedOrder.maker,
makerFee: parsedMakerFee,
makerTokenAddress: parsedOrder.maker.token.address,
makerTokenAddress: parsedOrder.signedOrder.makerTokenAddress,
makerTokenAmount: makerAmount,
salt,
taker: _.isEmpty(parsedOrder.taker.address) ? constants.NULL_ADDRESS : parsedOrder.taker.address,
taker: _.isEmpty(parsedOrder.signedOrder.taker)
? constants.NULL_ADDRESS
: parsedOrder.signedOrder.taker,
takerFee: parsedTakerFee,
takerTokenAddress: parsedOrder.taker.token.address,
takerTokenAddress: parsedOrder.signedOrder.takerTokenAddress,
takerTokenAmount: takerAmount,
};
const orderHash = ZeroEx.getOrderHashHex(zeroExOrder);
orderHash = ZeroEx.getOrderHashHex(zeroExOrder);
const signature = parsedOrder.signature;
const isValidSignature = ZeroEx.isValidSignature(signature.hash, signature, parsedOrder.maker.address);
if (this.props.networkId !== parsedOrder.networkId) {
orderJSONErrMsg = `This order was made on another Ethereum network
(id: ${parsedOrder.networkId}). Connect to this network to fill.`;
parsedOrder = undefined;
} else if (exchangeContractAddr !== parsedOrder.exchangeContract) {
orderJSONErrMsg = 'This order was made using a deprecated 0x Exchange contract.';
parsedOrder = undefined;
} else if (orderHash !== signature.hash) {
orderJSONErrMsg = 'Order hash does not match supplied plaintext values';
const exchangeContractAddr = this.props.blockchain.getExchangeContractAddressIfExists();
const signature = parsedOrder.signedOrder.ecSignature;
const isValidSignature = ZeroEx.isValidSignature(orderHash, signature, parsedOrder.signedOrder.maker);
if (exchangeContractAddr !== parsedOrder.signedOrder.exchangeContractAddress) {
orderJSONErrMsg = 'This order was made on another network or using a deprecated Exchange contract';
parsedOrder = undefined;
} else if (!isValidSignature) {
orderJSONErrMsg = 'Order signature is invalid';
@@ -478,13 +468,12 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
// Clear cache entry if user updates orderJSON to invalid entry
this.props.dispatcher.updateUserSuppliedOrderCache(undefined);
} else {
const orderHash = parsedOrder.signature.hash;
unavailableTakerAmount = await this.props.blockchain.getUnavailableTakerAmountAsync(orderHash);
const isMakerTokenAddressInRegistry = await this.props.blockchain.isAddressInTokenRegistryAsync(
parsedOrder.maker.token.address,
parsedOrder.signedOrder.makerTokenAddress,
);
const isTakerTokenAddressInRegistry = await this.props.blockchain.isAddressInTokenRegistryAsync(
parsedOrder.taker.token.address,
parsedOrder.signedOrder.takerTokenAddress,
);
this.setState({
isMakerTokenAddressInRegistry,
@@ -529,20 +518,7 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
globalErrMsg = 'You must specify a fill amount';
}
const signedOrder = this.props.blockchain.portalOrderToSignedOrder(
parsedOrder.maker.address,
parsedOrder.taker.address,
parsedOrder.maker.token.address,
parsedOrder.taker.token.address,
new BigNumber(parsedOrder.maker.amount),
new BigNumber(parsedOrder.taker.amount),
new BigNumber(parsedOrder.maker.feeAmount),
new BigNumber(parsedOrder.taker.feeAmount),
new BigNumber(this.state.parsedOrder.expiration),
parsedOrder.feeRecipient,
parsedOrder.signature,
new BigNumber(parsedOrder.salt),
);
const signedOrder = this.props.blockchain.portalOrderToZeroExOrder(parsedOrder);
if (_.isEmpty(globalErrMsg)) {
try {
await this.props.blockchain.validateFillOrderThrowIfInvalidAsync(
@@ -551,7 +527,7 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
this.props.userAddress,
);
} catch (err) {
globalErrMsg = utils.zeroExErrToHumanReadableErrMsg(err.message, parsedOrder.taker.address);
globalErrMsg = utils.zeroExErrToHumanReadableErrMsg(err.message, parsedOrder.signedOrder.taker);
}
}
if (!_.isEmpty(globalErrMsg)) {
@@ -562,7 +538,7 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
return;
}
const networkName = constants.NETWORK_NAME_BY_ID[this.props.networkId];
const eventLabel = `${parsedOrder.taker.token.symbol}-${networkName}`;
const eventLabel = `${parsedOrder.metadata.takerToken.symbol}-${networkName}`;
try {
const orderFilledAmount: BigNumber = await this.props.blockchain.fillOrderAsync(
signedOrder,
@@ -572,7 +548,7 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
category: 'Portal',
action: 'Fill Order Success',
label: eventLabel,
value: parsedOrder.taker.amount,
value: parsedOrder.signedOrder.takerTokenAmount,
});
// After fill completes, let's force fetch the token balances
this.props.dispatcher.forceTokenStateRefetch();
@@ -591,7 +567,7 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
category: 'Portal',
action: 'Fill Order Failure',
label: eventLabel,
value: parsedOrder.taker.amount,
value: parsedOrder.signedOrder.takerTokenAmount,
});
const errMsg = `${err}`;
if (utils.didUserDenyWeb3Request(errMsg)) {
@@ -618,7 +594,6 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
});
const parsedOrder = this.state.parsedOrder;
const orderHash = parsedOrder.signature.hash;
const takerAddress = this.props.userAddress;
if (_.isUndefined(takerAddress)) {
@@ -630,28 +605,16 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
}
let globalErrMsg = '';
const takerTokenAmount = new BigNumber(parsedOrder.taker.amount);
const takerTokenAmount = new BigNumber(parsedOrder.signedOrder.takerTokenAmount);
const signedOrder = this.props.blockchain.portalOrderToSignedOrder(
parsedOrder.maker.address,
parsedOrder.taker.address,
parsedOrder.maker.token.address,
parsedOrder.taker.token.address,
new BigNumber(parsedOrder.maker.amount),
takerTokenAmount,
new BigNumber(parsedOrder.maker.feeAmount),
new BigNumber(parsedOrder.taker.feeAmount),
new BigNumber(this.state.parsedOrder.expiration),
parsedOrder.feeRecipient,
parsedOrder.signature,
new BigNumber(parsedOrder.salt),
);
const signedOrder = this.props.blockchain.portalOrderToZeroExOrder(parsedOrder);
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
const unavailableTakerAmount = await this.props.blockchain.getUnavailableTakerAmountAsync(orderHash);
const availableTakerTokenAmount = takerTokenAmount.minus(unavailableTakerAmount);
try {
await this.props.blockchain.validateCancelOrderThrowIfInvalidAsync(signedOrder, availableTakerTokenAmount);
} catch (err) {
globalErrMsg = utils.zeroExErrToHumanReadableErrMsg(err.message, parsedOrder.taker.address);
globalErrMsg = utils.zeroExErrToHumanReadableErrMsg(err.message, parsedOrder.signedOrder.taker);
}
if (!_.isEmpty(globalErrMsg)) {
this.setState({
@@ -661,7 +624,7 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
return;
}
const networkName = constants.NETWORK_NAME_BY_ID[this.props.networkId];
const eventLabel = `${parsedOrder.maker.token.symbol}-${networkName}`;
const eventLabel = `${parsedOrder.metadata.makerToken.symbol}-${networkName}`;
try {
await this.props.blockchain.cancelOrderAsync(signedOrder, availableTakerTokenAmount);
this.setState({
@@ -674,7 +637,7 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
category: 'Portal',
action: 'Cancel Order Success',
label: eventLabel,
value: parsedOrder.maker.amount,
value: parsedOrder.signedOrder.makerTokenAmount,
});
return;
} catch (err) {
@@ -689,7 +652,7 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
category: 'Portal',
action: 'Cancel Order Failure',
label: eventLabel,
value: parsedOrder.maker.amount,
value: parsedOrder.signedOrder.makerTokenAmount,
});
globalErrMsg = 'Failed to cancel order, please refresh and try again';
utils.consoleLog(`${err}`);

View File

@@ -12,7 +12,6 @@ import { utils } from 'ts/utils/utils';
interface FillOrderJSONProps {
blockchain: Blockchain;
tokenByAddress: TokenByAddress;
networkId: number;
orderJSON: string;
onFillOrderJSONChanged: (event: any) => void;
}
@@ -34,8 +33,7 @@ export class FillOrderJSON extends React.Component<FillOrderJSONProps, FillOrder
},
};
const hintOrderExpiryTimestamp = utils.initialOrderExpiryUnixTimestampSec();
const hintSignatureData = {
hash: '0xf965a9978a0381ab58f5a2408ad967c...',
const hintECSignature = {
r: '0xf01103f759e2289a28593eaf22e5820032...',
s: '937862111edcba395f8a9e0cc1b2c5e12320...',
v: 27,
@@ -43,7 +41,6 @@ export class FillOrderJSON extends React.Component<FillOrderJSONProps, FillOrder
const hintSalt = ZeroEx.generatePseudoRandomSalt();
const feeRecipient = constants.NULL_ADDRESS;
const hintOrder = utils.generateOrder(
this.props.networkId,
exchangeContract,
hintSideToAssetToken,
hintOrderExpiryTimestamp,
@@ -52,7 +49,7 @@ export class FillOrderJSON extends React.Component<FillOrderJSONProps, FillOrder
constants.MAKER_FEE,
constants.TAKER_FEE,
feeRecipient,
hintSignatureData,
hintECSignature,
this.props.tokenByAddress,
hintSalt,
);

Some files were not shown because too many files have changed in this diff Show More