Compare commits
118 Commits
contracts@
...
@0xproject
Author | SHA1 | Date | |
---|---|---|---|
|
d12352972e | ||
|
03d3d84db3 | ||
|
6d818c25c7 | ||
|
6a8f624e75 | ||
|
0801b1ddf9 | ||
|
4fd64ca492 | ||
|
c4bcf24640 | ||
|
0114fc9608 | ||
|
8db098eaec | ||
|
05c3a66543 | ||
|
9349752baa | ||
|
974fab7284 | ||
|
8a52ffe7b7 | ||
|
c6ecdbd86e | ||
|
03797545f9 | ||
|
2778f96483 | ||
|
6cd4e7a17e | ||
|
5c91b4bfc6 | ||
|
e2b51c5dc4 | ||
|
b610b7c192 | ||
|
b75fdd6b66 | ||
|
060b02eaed | ||
|
003e5da00d | ||
|
02951d4813 | ||
|
db52ed9941 | ||
|
af333b1838 | ||
|
f62762bd0e | ||
|
4b67352278 | ||
|
e22788abe8 | ||
|
bbfbfcda85 | ||
|
0dfb36e675 | ||
|
95a9d77301 | ||
|
ab1f070901 | ||
|
8201d5d1f8 | ||
|
8704c34a0f | ||
|
599adaf1bf | ||
|
778e399438 | ||
|
485ae4d997 | ||
|
8cd2ba3ad6 | ||
|
dbad7d1869 | ||
|
18e1c2dea5 | ||
|
91ae01e484 | ||
|
2897b72967 | ||
|
3510985cf4 | ||
|
5927e65045 | ||
|
13e2041d50 | ||
|
4bf530ed9e | ||
|
4c797405ad | ||
|
713c922e35 | ||
|
7f1e789264 | ||
|
07d00cc515 | ||
|
cd55e346af | ||
|
6746428fb1 | ||
|
634032d5be | ||
|
602abc53dd | ||
|
fdbaa9768a | ||
|
293d7261e0 | ||
|
efb6eb28ce | ||
|
ac5531ce85 | ||
|
bc2415c70e | ||
|
0fd411f83f | ||
|
b74ad0ad12 | ||
|
4c58836735 | ||
|
3206b80dbd | ||
|
4910f7a61e | ||
|
6e9109eaec | ||
|
a04ec14cf0 | ||
|
7d3df3c117 | ||
|
b3a03f8e3e | ||
|
e5668c1e5c | ||
|
92e74bc4fa | ||
|
7e12269baf | ||
|
f3f264f5fd | ||
|
2e3c9b87df | ||
|
0a113e1cf7 | ||
|
fd772c48cf | ||
|
1c7dce6054 | ||
|
0a2947b860 | ||
|
c80877af43 | ||
|
e68b9c7e81 | ||
|
19198737a5 | ||
|
fea4b6aecd | ||
|
20e2673b82 | ||
|
ef1375b9dd | ||
|
58f1939ec1 | ||
|
ba57c34adb | ||
|
936f6ac10f | ||
|
7e04c4f24b | ||
|
9495c8f46c | ||
|
b3f91600d3 | ||
|
ddf4437fb6 | ||
|
4153d57849 | ||
|
0652790703 | ||
|
9c934d903d | ||
|
d7a7e28925 | ||
|
6dec29e214 | ||
|
43cf8d30bd | ||
|
254d3f53e2 | ||
|
ec198343b5 | ||
|
876517d458 | ||
|
1233c33116 | ||
|
eebf205817 | ||
|
e666bb44c6 | ||
|
39cb0b5122 | ||
|
8fba0477a6 | ||
|
e6f2c7a382 | ||
|
69f5f5e946 | ||
|
ae14b0a71d | ||
|
3c7ebe2697 | ||
|
10fb6061cc | ||
|
223df8006a | ||
|
1c9428cbba | ||
|
18dc5d17b5 | ||
|
4d50933189 | ||
|
9b3680780f | ||
|
568e4d33f2 | ||
|
fd004032cb | ||
|
4b6324050d |
@@ -1,6 +0,0 @@
|
|||||||
.*
|
|
||||||
tsconfig.json
|
|
||||||
tslint.json
|
|
||||||
webpack.config.js
|
|
||||||
yarn.lock
|
|
||||||
docs
|
|
@@ -36,3 +36,7 @@
|
|||||||
|
|
||||||
* [ ] Change requires a change to the documentation.
|
* [ ] Change requires a change to the documentation.
|
||||||
* [ ] Added tests to cover my changes.
|
* [ ] 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.
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
"mnemonic": "concert load couple harbor equip island argue ramp clarify fence smart topic"
|
"mnemonic": "concert load couple harbor equip island argue ramp clarify fence smart topic"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@0xproject/utils": "^0.3.0",
|
"@0xproject/utils": "^0.3.2",
|
||||||
"async-child-process": "^1.1.1",
|
"async-child-process": "^1.1.1",
|
||||||
"ethereumjs-testrpc": "^6.0.3",
|
"ethereumjs-testrpc": "^6.0.3",
|
||||||
"lerna": "^2.5.1",
|
"lerna": "^2.5.1",
|
||||||
|
10
packages/0x.js/.npmignore
Normal file
10
packages/0x.js/.npmignore
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
.*
|
||||||
|
tsconfig.json
|
||||||
|
webpack.config.js
|
||||||
|
yarn-error.log
|
||||||
|
test/
|
||||||
|
/src/
|
||||||
|
/_bundles/
|
||||||
|
/contract_templates/
|
||||||
|
/generated_docs/
|
||||||
|
/scripts/
|
@@ -1,5 +1,9 @@
|
|||||||
# CHANGELOG
|
# 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_
|
## v0.32.1 - _February 7, 2018_
|
||||||
|
|
||||||
* Reorganized `BlockParamLiteral` export into `@0xproject/types` package (#355)
|
* Reorganized `BlockParamLiteral` export into `@0xproject/types` package (#355)
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "0x.js",
|
"name": "0x.js",
|
||||||
"version": "0.32.1",
|
"version": "0.32.3",
|
||||||
"description": "A javascript library for interacting with the 0x protocol",
|
"description": "A javascript library for interacting with the 0x protocol",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"0x.js",
|
"0x.js",
|
||||||
@@ -42,9 +42,9 @@
|
|||||||
"node": ">=6.0.0"
|
"node": ">=6.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@0xproject/abi-gen": "^0.2.0",
|
"@0xproject/abi-gen": "^0.2.2",
|
||||||
"@0xproject/dev-utils": "^0.0.11",
|
"@0xproject/dev-utils": "^0.0.13",
|
||||||
"@0xproject/tslint-config": "^0.4.7",
|
"@0xproject/tslint-config": "^0.4.9",
|
||||||
"@types/bintrees": "^1.0.2",
|
"@types/bintrees": "^1.0.2",
|
||||||
"@types/jsonschema": "^1.1.1",
|
"@types/jsonschema": "^1.1.1",
|
||||||
"@types/lodash": "^4.14.86",
|
"@types/lodash": "^4.14.86",
|
||||||
@@ -55,9 +55,9 @@
|
|||||||
"awesome-typescript-loader": "^3.1.3",
|
"awesome-typescript-loader": "^3.1.3",
|
||||||
"chai": "^4.0.1",
|
"chai": "^4.0.1",
|
||||||
"chai-as-promised": "^7.1.0",
|
"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-bignumber": "^2.0.1",
|
||||||
"chai-typescript-typings": "^0.0.2",
|
"chai-typescript-typings": "^0.0.3",
|
||||||
"copyfiles": "^1.2.0",
|
"copyfiles": "^1.2.0",
|
||||||
"coveralls": "^3.0.0",
|
"coveralls": "^3.0.0",
|
||||||
"dirty-chai": "^2.0.1",
|
"dirty-chai": "^2.0.1",
|
||||||
@@ -77,15 +77,15 @@
|
|||||||
"types-bn": "^0.0.1",
|
"types-bn": "^0.0.1",
|
||||||
"typescript": "2.7.1",
|
"typescript": "2.7.1",
|
||||||
"web3-provider-engine": "^13.0.1",
|
"web3-provider-engine": "^13.0.1",
|
||||||
"web3-typescript-typings": "^0.9.9",
|
"web3-typescript-typings": "^0.9.10",
|
||||||
"webpack": "^3.1.0"
|
"webpack": "^3.1.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@0xproject/assert": "^0.0.17",
|
"@0xproject/assert": "^0.0.19",
|
||||||
"@0xproject/json-schemas": "^0.7.9",
|
"@0xproject/json-schemas": "^0.7.11",
|
||||||
"@0xproject/types": "^0.2.0",
|
"@0xproject/types": "^0.2.2",
|
||||||
"@0xproject/utils": "^0.3.1",
|
"@0xproject/utils": "^0.3.3",
|
||||||
"@0xproject/web3-wrapper": "^0.1.11",
|
"@0xproject/web3-wrapper": "^0.1.13",
|
||||||
"bintrees": "^1.0.2",
|
"bintrees": "^1.0.2",
|
||||||
"bn.js": "^4.11.8",
|
"bn.js": "^4.11.8",
|
||||||
"ethereumjs-abi": "^0.6.4",
|
"ethereumjs-abi": "^0.6.4",
|
||||||
|
@@ -15,7 +15,7 @@ postpublish_utils
|
|||||||
version = result.version;
|
version = result.version;
|
||||||
const releaseName = postpublish_utils.getReleaseName(subPackageName, version);
|
const releaseName = postpublish_utils.getReleaseName(subPackageName, version);
|
||||||
const assets = [__dirname + '/../_bundles/index.js', __dirname + '/../_bundles/index.min.js'];
|
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) {
|
.then(function(release) {
|
||||||
console.log('POSTPUBLISH: Release successful, generating docs...');
|
console.log('POSTPUBLISH: Release successful, generating docs...');
|
||||||
|
24
packages/0x.js/scripts/stagedocs.js
Normal file
24
packages/0x.js/scripts/stagedocs.js
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
const execAsync = require('async-child-process').execAsync;
|
||||||
|
const postpublish_utils = require('../../../scripts/postpublish_utils');
|
||||||
|
|
||||||
|
const cwd = __dirname + '/..';
|
||||||
|
const S3BucketPath = 's3://staging-0xjs-docs-jsons/';
|
||||||
|
const jsonFilePath = __dirname + '/../' + postpublish_utils.generatedDocsDirectoryName + '/index.json';
|
||||||
|
const version = process.env.DOCS_VERSION;
|
||||||
|
|
||||||
|
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';
|
||||||
|
const s3Url = S3BucketPath + fileName;
|
||||||
|
return execAsync('S3_URL=' + s3Url + ' yarn upload_docs_json', {
|
||||||
|
cwd,
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(function(err) {
|
||||||
|
console.log(err);
|
||||||
|
});
|
5
packages/abi-gen/.npmignore
Normal file
5
packages/abi-gen/.npmignore
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
.*
|
||||||
|
yarn-error.log
|
||||||
|
/src/
|
||||||
|
/scripts/
|
||||||
|
tsconfig.json
|
@@ -1,12 +1,16 @@
|
|||||||
# CHANGELOG
|
# 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_
|
## v0.2.0 - _February 7, 2018_
|
||||||
|
|
||||||
* Added CLI options for explicit specifying location of partials and main template (#346)
|
* 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 option to specify networkId, adding support for the JSON artifact format found in @0xproject/contracts (#388)
|
||||||
|
|
||||||
## v0.1.0 - _January 11, 2018_
|
## v0.1.0 - _January 11, 2018_
|
||||||
|
|
||||||
* Fixed array typings with union types (#295)
|
* Fixed array typings with union types (#295)
|
||||||
* Add event ABIs to context data passed to templates (#302)
|
* Add event ABIs to context data passed to templates (#302)
|
||||||
* Add constructor ABIs to context data passed to templates (#304)
|
* Add constructor ABIs to context data passed to templates (#304)
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@0xproject/abi-gen",
|
"name": "@0xproject/abi-gen",
|
||||||
"version": "0.2.0",
|
"version": "0.2.2",
|
||||||
"description": "Generate contract wrappers from ABI and handlebars templates",
|
"description": "Generate contract wrappers from ABI and handlebars templates",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"types": "lib/index.d.ts",
|
"types": "lib/index.d.ts",
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/0xProject/0x.js/packages/abi-gen/README.md",
|
"homepage": "https://github.com/0xProject/0x.js/packages/abi-gen/README.md",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@0xproject/utils": "^0.3.1",
|
"@0xproject/utils": "^0.3.3",
|
||||||
"chalk": "^2.3.0",
|
"chalk": "^2.3.0",
|
||||||
"glob": "^7.1.2",
|
"glob": "^7.1.2",
|
||||||
"handlebars": "^4.0.11",
|
"handlebars": "^4.0.11",
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
"yargs": "^10.0.3"
|
"yargs": "^10.0.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@0xproject/tslint-config": "^0.4.7",
|
"@0xproject/tslint-config": "^0.4.9",
|
||||||
"@types/glob": "^5.0.33",
|
"@types/glob": "^5.0.33",
|
||||||
"@types/handlebars": "^4.0.36",
|
"@types/handlebars": "^4.0.36",
|
||||||
"@types/mkdirp": "^0.5.1",
|
"@types/mkdirp": "^0.5.1",
|
||||||
@@ -44,6 +44,6 @@
|
|||||||
"shx": "^0.2.2",
|
"shx": "^0.2.2",
|
||||||
"tslint": "5.8.0",
|
"tslint": "5.8.0",
|
||||||
"typescript": "2.7.1",
|
"typescript": "2.7.1",
|
||||||
"web3-typescript-typings": "^0.9.9"
|
"web3-typescript-typings": "^0.9.10"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,14 +2,4 @@ const postpublish_utils = require('../../../scripts/postpublish_utils');
|
|||||||
const packageJSON = require('../package.json');
|
const packageJSON = require('../package.json');
|
||||||
|
|
||||||
const subPackageName = packageJSON.name;
|
const subPackageName = packageJSON.name;
|
||||||
|
postpublish_utils.standardPostPublishAsync(subPackageName);
|
||||||
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;
|
|
||||||
});
|
|
6
packages/assert/.npmignore
Normal file
6
packages/assert/.npmignore
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
.*
|
||||||
|
yarn-error.log
|
||||||
|
/src/
|
||||||
|
/scripts/
|
||||||
|
test/
|
||||||
|
tsconfig.json
|
@@ -1,6 +1,10 @@
|
|||||||
# CHANGELOG
|
# 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
|
* 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.
|
* Added assertion isValidBaseUnitAmount which checks both that the value is a valid bigNumber and that it does not contain decimals.
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@0xproject/assert",
|
"name": "@0xproject/assert",
|
||||||
"version": "0.0.17",
|
"version": "0.0.19",
|
||||||
"description": "Provides a standard way of performing type and schema validation across 0x projects",
|
"description": "Provides a standard way of performing type and schema validation across 0x projects",
|
||||||
"main": "lib/src/index.js",
|
"main": "lib/src/index.js",
|
||||||
"types": "lib/src/index.d.ts",
|
"types": "lib/src/index.d.ts",
|
||||||
@@ -24,12 +24,12 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/0xProject/0x.js/packages/assert/README.md",
|
"homepage": "https://github.com/0xProject/0x.js/packages/assert/README.md",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@0xproject/tslint-config": "^0.4.7",
|
"@0xproject/tslint-config": "^0.4.9",
|
||||||
"@types/lodash": "^4.14.86",
|
"@types/lodash": "^4.14.86",
|
||||||
"@types/mocha": "^2.2.42",
|
"@types/mocha": "^2.2.42",
|
||||||
"@types/valid-url": "^1.0.2",
|
"@types/valid-url": "^1.0.2",
|
||||||
"chai": "^4.0.1",
|
"chai": "^4.0.1",
|
||||||
"chai-typescript-typings": "^0.0.2",
|
"chai-typescript-typings": "^0.0.3",
|
||||||
"dirty-chai": "^2.0.1",
|
"dirty-chai": "^2.0.1",
|
||||||
"mocha": "^4.0.1",
|
"mocha": "^4.0.1",
|
||||||
"npm-run-all": "^4.1.2",
|
"npm-run-all": "^4.1.2",
|
||||||
@@ -38,8 +38,8 @@
|
|||||||
"typescript": "2.7.1"
|
"typescript": "2.7.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@0xproject/json-schemas": "^0.7.9",
|
"@0xproject/json-schemas": "^0.7.11",
|
||||||
"@0xproject/utils": "^0.3.1",
|
"@0xproject/utils": "^0.3.3",
|
||||||
"lodash": "^4.17.4",
|
"lodash": "^4.17.4",
|
||||||
"valid-url": "^1.0.9"
|
"valid-url": "^1.0.9"
|
||||||
}
|
}
|
||||||
|
@@ -2,14 +2,4 @@ const postpublish_utils = require('../../../scripts/postpublish_utils');
|
|||||||
const packageJSON = require('../package.json');
|
const packageJSON = require('../package.json');
|
||||||
|
|
||||||
const subPackageName = packageJSON.name;
|
const subPackageName = packageJSON.name;
|
||||||
|
postpublish_utils.standardPostPublishAsync(subPackageName);
|
||||||
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;
|
|
||||||
});
|
|
3
packages/chai-as-promised-typescript-typings/.npmignore
Normal file
3
packages/chai-as-promised-typescript-typings/.npmignore
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
.*
|
||||||
|
yarn-error.log
|
||||||
|
/scripts/
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "chai-as-promised-typescript-typings",
|
"name": "chai-as-promised-typescript-typings",
|
||||||
"version": "0.0.8",
|
"version": "0.0.9",
|
||||||
"description": "Typescript type definitions for chai-as-promised",
|
"description": "Typescript type definitions for chai-as-promised",
|
||||||
"main": "index.d.ts",
|
"main": "index.d.ts",
|
||||||
"types": "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",
|
"homepage": "https://github.com/0xProject/0x.js/packages/chai-as-promised-typescript-typings#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"chai-typescript-typings": "^0.0.2"
|
"chai-typescript-typings": "^0.0.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,14 +2,4 @@ const postpublish_utils = require('../../../scripts/postpublish_utils');
|
|||||||
const packageJSON = require('../package.json');
|
const packageJSON = require('../package.json');
|
||||||
|
|
||||||
const subPackageName = packageJSON.name;
|
const subPackageName = packageJSON.name;
|
||||||
|
postpublish_utils.standardPostPublishAsync(subPackageName);
|
||||||
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;
|
|
||||||
});
|
|
3
packages/chai-typescript-typings/.npmignore
Normal file
3
packages/chai-typescript-typings/.npmignore
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
.*
|
||||||
|
yarn-error.log
|
||||||
|
/scripts/
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "chai-typescript-typings",
|
"name": "chai-typescript-typings",
|
||||||
"version": "0.0.2",
|
"version": "0.0.3",
|
||||||
"description": "Typescript type definitions for chai",
|
"description": "Typescript type definitions for chai",
|
||||||
"main": "index.d.ts",
|
"main": "index.d.ts",
|
||||||
"types": "index.d.ts",
|
"types": "index.d.ts",
|
||||||
|
@@ -2,14 +2,4 @@ const postpublish_utils = require('../../../scripts/postpublish_utils');
|
|||||||
const packageJSON = require('../package.json');
|
const packageJSON = require('../package.json');
|
||||||
|
|
||||||
const subPackageName = packageJSON.name;
|
const subPackageName = packageJSON.name;
|
||||||
|
postpublish_utils.standardPostPublishAsync(subPackageName);
|
||||||
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;
|
|
||||||
});
|
|
7
packages/connect/.npmignore
Normal file
7
packages/connect/.npmignore
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
.*
|
||||||
|
yarn-error.log
|
||||||
|
/src/
|
||||||
|
/scripts/
|
||||||
|
/generated_docs/
|
||||||
|
test/
|
||||||
|
tsconfig.json
|
@@ -1,5 +1,14 @@
|
|||||||
# CHANGELOG
|
# CHANGELOG
|
||||||
|
|
||||||
|
## v0.6.0 - _February 16, 2018_
|
||||||
|
|
||||||
|
* Add pagination options to HttpClient methods (#393)
|
||||||
|
* Add heartbeat configuration to WebSocketOrderbookChannel constructor (#406)
|
||||||
|
|
||||||
|
## v0.5.7 - _February 9, 2018_
|
||||||
|
|
||||||
|
* Fix publishing issue where .npmignore was not properly excluding undesired content (#389)
|
||||||
|
|
||||||
## v0.5.0 - _January 17, 2018_
|
## v0.5.0 - _January 17, 2018_
|
||||||
|
|
||||||
* Sanitize api endpoint url and remove trailing slashes (#318)
|
* Sanitize api endpoint url and remove trailing slashes (#318)
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@0xproject/connect",
|
"name": "@0xproject/connect",
|
||||||
"version": "0.5.6",
|
"version": "0.5.8",
|
||||||
"description": "A javascript library for interacting with the standard relayer api",
|
"description": "A javascript library for interacting with the standard relayer api",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"connect",
|
"connect",
|
||||||
@@ -37,16 +37,16 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/0xProject/0x.js/packages/connect/README.md",
|
"homepage": "https://github.com/0xProject/0x.js/packages/connect/README.md",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@0xproject/assert": "^0.0.17",
|
"@0xproject/assert": "^0.0.19",
|
||||||
"@0xproject/json-schemas": "^0.7.9",
|
"@0xproject/json-schemas": "^0.7.11",
|
||||||
"@0xproject/utils": "^0.3.1",
|
"@0xproject/utils": "^0.3.3",
|
||||||
"isomorphic-fetch": "^2.2.1",
|
"isomorphic-fetch": "^2.2.1",
|
||||||
"lodash": "^4.17.4",
|
"lodash": "^4.17.4",
|
||||||
"query-string": "^5.0.1",
|
"query-string": "^5.0.1",
|
||||||
"websocket": "^1.0.25"
|
"websocket": "^1.0.25"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@0xproject/tslint-config": "^0.4.7",
|
"@0xproject/tslint-config": "^0.4.9",
|
||||||
"@types/fetch-mock": "^5.12.1",
|
"@types/fetch-mock": "^5.12.1",
|
||||||
"@types/lodash": "^4.14.86",
|
"@types/lodash": "^4.14.86",
|
||||||
"@types/mocha": "^2.2.42",
|
"@types/mocha": "^2.2.42",
|
||||||
@@ -54,8 +54,8 @@
|
|||||||
"@types/websocket": "^0.0.34",
|
"@types/websocket": "^0.0.34",
|
||||||
"chai": "^4.0.1",
|
"chai": "^4.0.1",
|
||||||
"chai-as-promised": "^7.1.0",
|
"chai-as-promised": "^7.1.0",
|
||||||
"chai-as-promised-typescript-typings": "^0.0.8",
|
"chai-as-promised-typescript-typings": "^0.0.9",
|
||||||
"chai-typescript-typings": "^0.0.2",
|
"chai-typescript-typings": "^0.0.3",
|
||||||
"copyfiles": "^1.2.0",
|
"copyfiles": "^1.2.0",
|
||||||
"dirty-chai": "^2.0.1",
|
"dirty-chai": "^2.0.1",
|
||||||
"fetch-mock": "^5.13.1",
|
"fetch-mock": "^5.13.1",
|
||||||
@@ -65,6 +65,6 @@
|
|||||||
"tslint": "5.8.0",
|
"tslint": "5.8.0",
|
||||||
"typedoc": "~0.8.0",
|
"typedoc": "~0.8.0",
|
||||||
"typescript": "2.7.1",
|
"typescript": "2.7.1",
|
||||||
"web3-typescript-typings": "^0.9.9"
|
"web3-typescript-typings": "^0.9.10"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
24
packages/connect/scripts/stagedocs.js
Normal file
24
packages/connect/scripts/stagedocs.js
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
const execAsync = require('async-child-process').execAsync;
|
||||||
|
const postpublish_utils = require('../../../scripts/postpublish_utils');
|
||||||
|
|
||||||
|
const cwd = __dirname + '/..';
|
||||||
|
const S3BucketPath = 's3://staging-connect-docs-jsons/';
|
||||||
|
const jsonFilePath = __dirname + '/../' + postpublish_utils.generatedDocsDirectoryName + '/index.json';
|
||||||
|
const version = process.env.DOCS_VERSION;
|
||||||
|
|
||||||
|
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';
|
||||||
|
const s3Url = S3BucketPath + fileName;
|
||||||
|
return execAsync('S3_URL=' + s3Url + ' yarn upload_docs_json', {
|
||||||
|
cwd,
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(function(err) {
|
||||||
|
console.log(err);
|
||||||
|
});
|
@@ -13,20 +13,48 @@ import {
|
|||||||
HttpRequestType,
|
HttpRequestType,
|
||||||
OrderbookRequest,
|
OrderbookRequest,
|
||||||
OrderbookResponse,
|
OrderbookResponse,
|
||||||
OrdersRequest,
|
OrdersRequestOpts,
|
||||||
|
PagedRequestOpts,
|
||||||
SignedOrder,
|
SignedOrder,
|
||||||
TokenPairsItem,
|
TokenPairsItem,
|
||||||
TokenPairsRequest,
|
TokenPairsRequestOpts,
|
||||||
} from './types';
|
} from './types';
|
||||||
import { relayerResponseJsonParsers } from './utils/relayer_response_json_parsers';
|
import { relayerResponseJsonParsers } from './utils/relayer_response_json_parsers';
|
||||||
|
|
||||||
const TRAILING_SLASHES_REGEX = /\/+$/;
|
const TRAILING_SLASHES_REGEX = /\/+$/;
|
||||||
|
const DEFAULT_PAGED_REQUEST_OPTS: PagedRequestOpts = {
|
||||||
|
page: 1,
|
||||||
|
perPage: 100,
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* This mapping defines how an option property name gets converted into an HTTP request query field
|
||||||
|
*/
|
||||||
|
const OPTS_TO_QUERY_FIELD_MAP = {
|
||||||
|
perPage: 'per_page',
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class includes all the functionality related to interacting with a set of HTTP endpoints
|
* This class includes all the functionality related to interacting with a set of HTTP endpoints
|
||||||
* that implement the standard relayer API v0
|
* that implement the standard relayer API v0
|
||||||
*/
|
*/
|
||||||
export class HttpClient implements Client {
|
export class HttpClient implements Client {
|
||||||
private _apiEndpointUrl: string;
|
private _apiEndpointUrl: string;
|
||||||
|
/**
|
||||||
|
* Format parameters to be appended to http requests into query string form
|
||||||
|
*/
|
||||||
|
private static _buildQueryStringFromHttpParams(params?: object): string {
|
||||||
|
// if params are undefined or empty, return an empty string
|
||||||
|
if (_.isUndefined(params) || _.isEmpty(params)) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
// format params into a form the api expects
|
||||||
|
const formattedParams = _.mapKeys(params, (value: any, key: string) => {
|
||||||
|
return _.get(OPTS_TO_QUERY_FIELD_MAP, key, key);
|
||||||
|
});
|
||||||
|
// stringify the formatted object
|
||||||
|
const stringifiedParams = queryString.stringify(formattedParams);
|
||||||
|
return `?${stringifiedParams}`;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Instantiates a new HttpClient instance
|
* Instantiates a new HttpClient instance
|
||||||
* @param url The relayer API base HTTP url you would like to interact with
|
* @param url The relayer API base HTTP url you would like to interact with
|
||||||
@@ -38,34 +66,35 @@ export class HttpClient implements Client {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Retrieve token pair info from the API
|
* Retrieve token pair info from the API
|
||||||
* @param request A TokenPairsRequest instance describing specific token information
|
* @param requestOpts Options specifying token information to retrieve and page information, defaults to { page: 1, perPage: 100 }
|
||||||
* to retrieve
|
|
||||||
* @return The resulting TokenPairsItems that match the request
|
* @return The resulting TokenPairsItems that match the request
|
||||||
*/
|
*/
|
||||||
public async getTokenPairsAsync(request?: TokenPairsRequest): Promise<TokenPairsItem[]> {
|
public async getTokenPairsAsync(requestOpts?: TokenPairsRequestOpts & PagedRequestOpts): Promise<TokenPairsItem[]> {
|
||||||
if (!_.isUndefined(request)) {
|
if (!_.isUndefined(requestOpts)) {
|
||||||
assert.doesConformToSchema('request', request, clientSchemas.relayerTokenPairsRequestSchema);
|
assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.tokenPairsRequestOptsSchema);
|
||||||
|
assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.pagedRequestOptsSchema);
|
||||||
}
|
}
|
||||||
const requestOpts = {
|
const httpRequestOpts = {
|
||||||
params: request,
|
params: _.defaults({}, requestOpts, DEFAULT_PAGED_REQUEST_OPTS),
|
||||||
};
|
};
|
||||||
const responseJson = await this._requestAsync('/token_pairs', HttpRequestType.Get, requestOpts);
|
const responseJson = await this._requestAsync('/token_pairs', HttpRequestType.Get, httpRequestOpts);
|
||||||
const tokenPairs = relayerResponseJsonParsers.parseTokenPairsJson(responseJson);
|
const tokenPairs = relayerResponseJsonParsers.parseTokenPairsJson(responseJson);
|
||||||
return tokenPairs;
|
return tokenPairs;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Retrieve orders from the API
|
* Retrieve orders from the API
|
||||||
* @param request An OrdersRequest instance describing specific orders to retrieve
|
* @param requestOpts Options specifying orders to retrieve and page information, defaults to { page: 1, perPage: 100 }
|
||||||
* @return The resulting SignedOrders that match the request
|
* @return The resulting SignedOrders that match the request
|
||||||
*/
|
*/
|
||||||
public async getOrdersAsync(request?: OrdersRequest): Promise<SignedOrder[]> {
|
public async getOrdersAsync(requestOpts?: OrdersRequestOpts & PagedRequestOpts): Promise<SignedOrder[]> {
|
||||||
if (!_.isUndefined(request)) {
|
if (!_.isUndefined(requestOpts)) {
|
||||||
assert.doesConformToSchema('request', request, clientSchemas.relayerOrdersRequestSchema);
|
assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.ordersRequestOptsSchema);
|
||||||
|
assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.pagedRequestOptsSchema);
|
||||||
}
|
}
|
||||||
const requestOpts = {
|
const httpRequestOpts = {
|
||||||
params: request,
|
params: _.defaults({}, requestOpts, DEFAULT_PAGED_REQUEST_OPTS),
|
||||||
};
|
};
|
||||||
const responseJson = await this._requestAsync(`/orders`, HttpRequestType.Get, requestOpts);
|
const responseJson = await this._requestAsync(`/orders`, HttpRequestType.Get, httpRequestOpts);
|
||||||
const orders = relayerResponseJsonParsers.parseOrdersJson(responseJson);
|
const orders = relayerResponseJsonParsers.parseOrdersJson(responseJson);
|
||||||
return orders;
|
return orders;
|
||||||
}
|
}
|
||||||
@@ -82,15 +111,22 @@ export class HttpClient implements Client {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Retrieve an orderbook from the API
|
* Retrieve an orderbook from the API
|
||||||
* @param request An OrderbookRequest instance describing the specific orderbook to retrieve
|
* @param request An OrderbookRequest instance describing the specific orderbook to retrieve
|
||||||
|
* @param requestOpts Options specifying page information, defaults to { page: 1, perPage: 100 }
|
||||||
* @return The resulting OrderbookResponse that matches the request
|
* @return The resulting OrderbookResponse that matches the request
|
||||||
*/
|
*/
|
||||||
public async getOrderbookAsync(request: OrderbookRequest): Promise<OrderbookResponse> {
|
public async getOrderbookAsync(
|
||||||
assert.doesConformToSchema('request', request, clientSchemas.relayerOrderBookRequestSchema);
|
request: OrderbookRequest,
|
||||||
const requestOpts = {
|
requestOpts?: PagedRequestOpts,
|
||||||
params: request,
|
): Promise<OrderbookResponse> {
|
||||||
|
assert.doesConformToSchema('request', request, clientSchemas.orderBookRequestSchema);
|
||||||
|
if (!_.isUndefined(requestOpts)) {
|
||||||
|
assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.pagedRequestOptsSchema);
|
||||||
|
}
|
||||||
|
const httpRequestOpts = {
|
||||||
|
params: _.defaults({}, request, requestOpts, DEFAULT_PAGED_REQUEST_OPTS),
|
||||||
};
|
};
|
||||||
const responseJson = await this._requestAsync('/orderbook', HttpRequestType.Get, requestOpts);
|
const responseJson = await this._requestAsync('/orderbook', HttpRequestType.Get, httpRequestOpts);
|
||||||
const orderbook = relayerResponseJsonParsers.parseOrderbookResponseJson(responseJson);
|
const orderbook = relayerResponseJsonParsers.parseOrderbookResponseJson(responseJson);
|
||||||
return orderbook;
|
return orderbook;
|
||||||
}
|
}
|
||||||
@@ -100,11 +136,11 @@ export class HttpClient implements Client {
|
|||||||
* @return The resulting FeesResponse that matches the request
|
* @return The resulting FeesResponse that matches the request
|
||||||
*/
|
*/
|
||||||
public async getFeesAsync(request: FeesRequest): Promise<FeesResponse> {
|
public async getFeesAsync(request: FeesRequest): Promise<FeesResponse> {
|
||||||
assert.doesConformToSchema('request', request, schemas.relayerApiFeesPayloadSchema);
|
assert.doesConformToSchema('request', request, clientSchemas.feesRequestSchema);
|
||||||
const requestOpts = {
|
const httpRequestOpts = {
|
||||||
payload: request,
|
payload: request,
|
||||||
};
|
};
|
||||||
const responseJson = await this._requestAsync('/fees', HttpRequestType.Post, requestOpts);
|
const responseJson = await this._requestAsync('/fees', HttpRequestType.Post, httpRequestOpts);
|
||||||
const fees = relayerResponseJsonParsers.parseFeesResponseJson(responseJson);
|
const fees = relayerResponseJsonParsers.parseFeesResponseJson(responseJson);
|
||||||
return fees;
|
return fees;
|
||||||
}
|
}
|
||||||
@@ -126,11 +162,7 @@ export class HttpClient implements Client {
|
|||||||
): Promise<any> {
|
): Promise<any> {
|
||||||
const params = _.get(requestOptions, 'params');
|
const params = _.get(requestOptions, 'params');
|
||||||
const payload = _.get(requestOptions, 'payload');
|
const payload = _.get(requestOptions, 'payload');
|
||||||
let query = '';
|
const query = HttpClient._buildQueryStringFromHttpParams(params);
|
||||||
if (!_.isUndefined(params) && !_.isEmpty(params)) {
|
|
||||||
const stringifiedParams = queryString.stringify(params);
|
|
||||||
query = `?${stringifiedParams}`;
|
|
||||||
}
|
|
||||||
const url = `${this._apiEndpointUrl}${path}${query}`;
|
const url = `${this._apiEndpointUrl}${path}${query}`;
|
||||||
const headers = new Headers({
|
const headers = new Headers({
|
||||||
'content-type': 'application/json',
|
'content-type': 'application/json',
|
||||||
|
@@ -11,9 +11,11 @@ export {
|
|||||||
OrderbookChannelSubscriptionOpts,
|
OrderbookChannelSubscriptionOpts,
|
||||||
OrderbookRequest,
|
OrderbookRequest,
|
||||||
OrderbookResponse,
|
OrderbookResponse,
|
||||||
OrdersRequest,
|
OrdersRequestOpts,
|
||||||
|
PagedRequestOpts,
|
||||||
SignedOrder,
|
SignedOrder,
|
||||||
TokenPairsItem,
|
TokenPairsItem,
|
||||||
TokenPairsRequest,
|
TokenPairsRequestOpts,
|
||||||
TokenTradeInfo,
|
TokenTradeInfo,
|
||||||
|
WebSocketOrderbookChannelConfig,
|
||||||
} from './types';
|
} from './types';
|
||||||
|
26
packages/connect/src/schemas/fees_request_schema.ts
Normal file
26
packages/connect/src/schemas/fees_request_schema.ts
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
export const feesRequestSchema = {
|
||||||
|
id: '/FeesRequest',
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
exchangeContractAddress: { $ref: '/Address' },
|
||||||
|
maker: { $ref: '/Address' },
|
||||||
|
taker: { $ref: '/Address' },
|
||||||
|
makerTokenAddress: { $ref: '/Address' },
|
||||||
|
takerTokenAddress: { $ref: '/Address' },
|
||||||
|
makerTokenAmount: { $ref: '/Number' },
|
||||||
|
takerTokenAmount: { $ref: '/Number' },
|
||||||
|
expirationUnixTimestampSec: { $ref: '/Number' },
|
||||||
|
salt: { $ref: '/Number' },
|
||||||
|
},
|
||||||
|
required: [
|
||||||
|
'exchangeContractAddress',
|
||||||
|
'maker',
|
||||||
|
'taker',
|
||||||
|
'makerTokenAddress',
|
||||||
|
'takerTokenAddress',
|
||||||
|
'makerTokenAmount',
|
||||||
|
'takerTokenAmount',
|
||||||
|
'expirationUnixTimestampSec',
|
||||||
|
'salt',
|
||||||
|
],
|
||||||
|
};
|
@@ -1,8 +1,9 @@
|
|||||||
export const relayerOrderBookRequestSchema = {
|
export const orderBookRequestSchema = {
|
||||||
id: '/RelayerOrderBookRequest',
|
id: '/OrderBookRequest',
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
baseTokenAddress: { $ref: '/Address' },
|
baseTokenAddress: { $ref: '/Address' },
|
||||||
quoteTokenAddress: { $ref: '/Address' },
|
quoteTokenAddress: { $ref: '/Address' },
|
||||||
},
|
},
|
||||||
|
required: ['baseTokenAddress', 'quoteTokenAddress'],
|
||||||
};
|
};
|
@@ -1,5 +1,5 @@
|
|||||||
export const relayerOrdersRequestSchema = {
|
export const ordersRequestOptsSchema = {
|
||||||
id: '/RelayerOrdersRequest',
|
id: '/OrdersRequestOpts',
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
exchangeContractAddress: { $ref: '/Address' },
|
exchangeContractAddress: { $ref: '/Address' },
|
@@ -0,0 +1,8 @@
|
|||||||
|
export const pagedRequestOptsSchema = {
|
||||||
|
id: '/PagedRequestOpts',
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
page: { type: 'number' },
|
||||||
|
perPage: { type: 'number' },
|
||||||
|
},
|
||||||
|
};
|
@@ -1,8 +0,0 @@
|
|||||||
export const relayerOrderBookRequestSchema = {
|
|
||||||
id: '/RelayerOrderBookRequest',
|
|
||||||
type: 'object',
|
|
||||||
properties: {
|
|
||||||
baseTokenAddress: { $ref: '/Address' },
|
|
||||||
quoteTokenAddress: { $ref: '/Address' },
|
|
||||||
},
|
|
||||||
};
|
|
@@ -1,9 +1,15 @@
|
|||||||
import { relayerOrderBookRequestSchema } from './relayer_orderbook_request_schema';
|
import { feesRequestSchema } from './fees_request_schema';
|
||||||
import { relayerOrdersRequestSchema } from './relayer_orders_request_schema';
|
import { orderBookRequestSchema } from './orderbook_request_schema';
|
||||||
import { relayerTokenPairsRequestSchema } from './relayer_token_pairs_request_schema';
|
import { ordersRequestOptsSchema } from './orders_request_opts_schema';
|
||||||
|
import { pagedRequestOptsSchema } from './paged_request_opts_schema';
|
||||||
|
import { tokenPairsRequestOptsSchema } from './token_pairs_request_opts_schema';
|
||||||
|
import { webSocketOrderbookChannelConfigSchema } from './websocket_orderbook_channel_config_schema';
|
||||||
|
|
||||||
export const schemas = {
|
export const schemas = {
|
||||||
relayerOrderBookRequestSchema,
|
feesRequestSchema,
|
||||||
relayerOrdersRequestSchema,
|
orderBookRequestSchema,
|
||||||
relayerTokenPairsRequestSchema,
|
ordersRequestOptsSchema,
|
||||||
|
pagedRequestOptsSchema,
|
||||||
|
tokenPairsRequestOptsSchema,
|
||||||
|
webSocketOrderbookChannelConfigSchema,
|
||||||
};
|
};
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
export const relayerTokenPairsRequestSchema = {
|
export const tokenPairsRequestOptsSchema = {
|
||||||
id: '/RelayerTokenPairsRequest',
|
id: '/TokenPairsRequestOpts',
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
tokenA: { $ref: '/Address' },
|
tokenA: { $ref: '/Address' },
|
@@ -0,0 +1,10 @@
|
|||||||
|
export const webSocketOrderbookChannelConfigSchema = {
|
||||||
|
id: '/WebSocketOrderbookChannelConfig',
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
heartbeatIntervalMs: {
|
||||||
|
type: 'number',
|
||||||
|
minimum: 10,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
@@ -30,10 +30,10 @@ export interface ECSignature {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface Client {
|
export interface Client {
|
||||||
getTokenPairsAsync: (request?: TokenPairsRequest) => Promise<TokenPairsItem[]>;
|
getTokenPairsAsync: (requestOpts?: TokenPairsRequestOpts & PagedRequestOpts) => Promise<TokenPairsItem[]>;
|
||||||
getOrdersAsync: (request?: OrdersRequest) => Promise<SignedOrder[]>;
|
getOrdersAsync: (requestOpts?: OrdersRequestOpts & PagedRequestOpts) => Promise<SignedOrder[]>;
|
||||||
getOrderAsync: (orderHash: string) => Promise<SignedOrder>;
|
getOrderAsync: (orderHash: string) => Promise<SignedOrder>;
|
||||||
getOrderbookAsync: (request: OrderbookRequest) => Promise<OrderbookResponse>;
|
getOrderbookAsync: (request: OrderbookRequest, requestOpts?: PagedRequestOpts) => Promise<OrderbookResponse>;
|
||||||
getFeesAsync: (request: FeesRequest) => Promise<FeesResponse>;
|
getFeesAsync: (request: FeesRequest) => Promise<FeesResponse>;
|
||||||
submitOrderAsync: (signedOrder: SignedOrder) => Promise<void>;
|
submitOrderAsync: (signedOrder: SignedOrder) => Promise<void>;
|
||||||
}
|
}
|
||||||
@@ -43,6 +43,13 @@ export interface OrderbookChannel {
|
|||||||
close: () => void;
|
close: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* heartbeatInterval: Interval in milliseconds that the orderbook channel should ping the underlying websocket. Default: 15000
|
||||||
|
*/
|
||||||
|
export interface WebSocketOrderbookChannelConfig {
|
||||||
|
heartbeatIntervalMs?: number;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* baseTokenAddress: The address of token designated as the baseToken in the currency pair calculation of price
|
* baseTokenAddress: The address of token designated as the baseToken in the currency pair calculation of price
|
||||||
* quoteTokenAddress: The address of token designated as the quoteToken in the currency pair calculation of price
|
* quoteTokenAddress: The address of token designated as the quoteToken in the currency pair calculation of price
|
||||||
@@ -111,7 +118,7 @@ export enum WebsocketClientEventType {
|
|||||||
ConnectFailed = 'connectFailed',
|
ConnectFailed = 'connectFailed',
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TokenPairsRequest {
|
export interface TokenPairsRequestOpts {
|
||||||
tokenA?: string;
|
tokenA?: string;
|
||||||
tokenB?: string;
|
tokenB?: string;
|
||||||
}
|
}
|
||||||
@@ -128,7 +135,7 @@ export interface TokenTradeInfo {
|
|||||||
precision: number;
|
precision: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface OrdersRequest {
|
export interface OrdersRequestOpts {
|
||||||
exchangeContractAddress?: string;
|
exchangeContractAddress?: string;
|
||||||
tokenAddress?: string;
|
tokenAddress?: string;
|
||||||
makerTokenAddress?: string;
|
makerTokenAddress?: string;
|
||||||
@@ -167,6 +174,11 @@ export interface FeesResponse {
|
|||||||
takerFee: BigNumber;
|
takerFee: BigNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface PagedRequestOpts {
|
||||||
|
page?: number;
|
||||||
|
perPage?: number;
|
||||||
|
}
|
||||||
|
|
||||||
export interface HttpRequestOptions {
|
export interface HttpRequestOptions {
|
||||||
params?: object;
|
params?: object;
|
||||||
payload?: object;
|
payload?: object;
|
||||||
|
@@ -3,6 +3,7 @@ import { schemas } from '@0xproject/json-schemas';
|
|||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
import * as WebSocket from 'websocket';
|
import * as WebSocket from 'websocket';
|
||||||
|
|
||||||
|
import { schemas as clientSchemas } from './schemas/schemas';
|
||||||
import {
|
import {
|
||||||
OrderbookChannel,
|
OrderbookChannel,
|
||||||
OrderbookChannelHandler,
|
OrderbookChannelHandler,
|
||||||
@@ -10,9 +11,13 @@ import {
|
|||||||
OrderbookChannelSubscriptionOpts,
|
OrderbookChannelSubscriptionOpts,
|
||||||
WebsocketClientEventType,
|
WebsocketClientEventType,
|
||||||
WebsocketConnectionEventType,
|
WebsocketConnectionEventType,
|
||||||
|
WebSocketOrderbookChannelConfig,
|
||||||
} from './types';
|
} from './types';
|
||||||
import { orderbookChannelMessageParser } from './utils/orderbook_channel_message_parser';
|
import { orderbookChannelMessageParser } from './utils/orderbook_channel_message_parser';
|
||||||
|
|
||||||
|
const DEFAULT_HEARTBEAT_INTERVAL_MS = 15000;
|
||||||
|
const MINIMUM_HEARTBEAT_INTERVAL_MS = 10;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class includes all the functionality related to interacting with a websocket endpoint
|
* This class includes all the functionality related to interacting with a websocket endpoint
|
||||||
* that implements the standard relayer API v0
|
* that implements the standard relayer API v0
|
||||||
@@ -21,15 +26,25 @@ export class WebSocketOrderbookChannel implements OrderbookChannel {
|
|||||||
private _apiEndpointUrl: string;
|
private _apiEndpointUrl: string;
|
||||||
private _client: WebSocket.client;
|
private _client: WebSocket.client;
|
||||||
private _connectionIfExists?: WebSocket.connection;
|
private _connectionIfExists?: WebSocket.connection;
|
||||||
|
private _heartbeatTimerIfExists?: NodeJS.Timer;
|
||||||
private _subscriptionCounter = 0;
|
private _subscriptionCounter = 0;
|
||||||
|
private _heartbeatIntervalMs: number;
|
||||||
/**
|
/**
|
||||||
* Instantiates a new WebSocketOrderbookChannel instance
|
* Instantiates a new WebSocketOrderbookChannel instance
|
||||||
* @param url The relayer API base WS url you would like to interact with
|
* @param url The relayer API base WS url you would like to interact with
|
||||||
|
* @param url The configuration object. Look up the type for the description.
|
||||||
* @return An instance of WebSocketOrderbookChannel
|
* @return An instance of WebSocketOrderbookChannel
|
||||||
*/
|
*/
|
||||||
constructor(url: string) {
|
constructor(url: string, config?: WebSocketOrderbookChannelConfig) {
|
||||||
assert.isUri('url', url);
|
assert.isUri('url', url);
|
||||||
|
if (!_.isUndefined(config)) {
|
||||||
|
assert.doesConformToSchema('config', config, clientSchemas.webSocketOrderbookChannelConfigSchema);
|
||||||
|
}
|
||||||
this._apiEndpointUrl = url;
|
this._apiEndpointUrl = url;
|
||||||
|
this._heartbeatIntervalMs =
|
||||||
|
_.isUndefined(config) || _.isUndefined(config.heartbeatIntervalMs)
|
||||||
|
? DEFAULT_HEARTBEAT_INTERVAL_MS
|
||||||
|
: config.heartbeatIntervalMs;
|
||||||
this._client = new WebSocket.client();
|
this._client = new WebSocket.client();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -63,7 +78,7 @@ export class WebSocketOrderbookChannel implements OrderbookChannel {
|
|||||||
connection.on(WebsocketConnectionEventType.Error, wsError => {
|
connection.on(WebsocketConnectionEventType.Error, wsError => {
|
||||||
handler.onError(this, subscriptionOpts, wsError);
|
handler.onError(this, subscriptionOpts, wsError);
|
||||||
});
|
});
|
||||||
connection.on(WebsocketConnectionEventType.Close, () => {
|
connection.on(WebsocketConnectionEventType.Close, (code: number, desc: string) => {
|
||||||
handler.onClose(this, subscriptionOpts);
|
handler.onClose(this, subscriptionOpts);
|
||||||
});
|
});
|
||||||
connection.on(WebsocketConnectionEventType.Message, message => {
|
connection.on(WebsocketConnectionEventType.Message, message => {
|
||||||
@@ -80,6 +95,9 @@ export class WebSocketOrderbookChannel implements OrderbookChannel {
|
|||||||
if (!_.isUndefined(this._connectionIfExists)) {
|
if (!_.isUndefined(this._connectionIfExists)) {
|
||||||
this._connectionIfExists.close();
|
this._connectionIfExists.close();
|
||||||
}
|
}
|
||||||
|
if (!_.isUndefined(this._heartbeatTimerIfExists)) {
|
||||||
|
clearInterval(this._heartbeatTimerIfExists);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
private _getConnection(callback: (error?: Error, connection?: WebSocket.connection) => void) {
|
private _getConnection(callback: (error?: Error, connection?: WebSocket.connection) => void) {
|
||||||
if (!_.isUndefined(this._connectionIfExists) && this._connectionIfExists.connected) {
|
if (!_.isUndefined(this._connectionIfExists) && this._connectionIfExists.connected) {
|
||||||
@@ -87,6 +105,20 @@ export class WebSocketOrderbookChannel implements OrderbookChannel {
|
|||||||
} else {
|
} else {
|
||||||
this._client.on(WebsocketClientEventType.Connect, connection => {
|
this._client.on(WebsocketClientEventType.Connect, connection => {
|
||||||
this._connectionIfExists = connection;
|
this._connectionIfExists = connection;
|
||||||
|
if (this._heartbeatIntervalMs >= MINIMUM_HEARTBEAT_INTERVAL_MS) {
|
||||||
|
this._heartbeatTimerIfExists = setInterval(() => {
|
||||||
|
connection.ping('');
|
||||||
|
}, this._heartbeatIntervalMs);
|
||||||
|
} else {
|
||||||
|
callback(
|
||||||
|
new Error(
|
||||||
|
`Heartbeat interval is ${
|
||||||
|
this._heartbeatIntervalMs
|
||||||
|
}ms which is less than the required minimum of ${MINIMUM_HEARTBEAT_INTERVAL_MS}ms`,
|
||||||
|
),
|
||||||
|
undefined,
|
||||||
|
);
|
||||||
|
}
|
||||||
callback(undefined, this._connectionIfExists);
|
callback(undefined, this._connectionIfExists);
|
||||||
});
|
});
|
||||||
this._client.on(WebsocketClientEventType.ConnectFailed, error => {
|
this._client.on(WebsocketClientEventType.ConnectFailed, error => {
|
||||||
|
@@ -40,19 +40,22 @@ describe('HttpClient', () => {
|
|||||||
});
|
});
|
||||||
describe('#getTokenPairsAsync', () => {
|
describe('#getTokenPairsAsync', () => {
|
||||||
const url = `${relayUrl}/token_pairs`;
|
const url = `${relayUrl}/token_pairs`;
|
||||||
it('gets token pairs', async () => {
|
it('gets token pairs with default options when none are provided', async () => {
|
||||||
fetchMock.get(url, tokenPairsResponseJSON);
|
const urlWithQuery = `${url}?page=1&per_page=100`;
|
||||||
|
fetchMock.get(urlWithQuery, tokenPairsResponseJSON);
|
||||||
const tokenPairs = await relayerClient.getTokenPairsAsync();
|
const tokenPairs = await relayerClient.getTokenPairsAsync();
|
||||||
expect(tokenPairs).to.be.deep.equal(tokenPairsResponse);
|
expect(tokenPairs).to.be.deep.equal(tokenPairsResponse);
|
||||||
});
|
});
|
||||||
it('gets specific token pairs for request', async () => {
|
it('gets token pairs with specified request options', async () => {
|
||||||
const tokenAddress = '0x323b5d4c32345ced77393b3530b1eed0f346429d';
|
const tokenAddress = '0x323b5d4c32345ced77393b3530b1eed0f346429d';
|
||||||
const tokenPairsRequest = {
|
const tokenPairsRequestOpts = {
|
||||||
tokenA: tokenAddress,
|
tokenA: tokenAddress,
|
||||||
|
page: 3,
|
||||||
|
perPage: 50,
|
||||||
};
|
};
|
||||||
const urlWithQuery = `${url}?tokenA=${tokenAddress}`;
|
const urlWithQuery = `${url}?page=3&per_page=50&tokenA=${tokenAddress}`;
|
||||||
fetchMock.get(urlWithQuery, tokenPairsResponseJSON);
|
fetchMock.get(urlWithQuery, tokenPairsResponseJSON);
|
||||||
const tokenPairs = await relayerClient.getTokenPairsAsync(tokenPairsRequest);
|
const tokenPairs = await relayerClient.getTokenPairsAsync(tokenPairsRequestOpts);
|
||||||
expect(tokenPairs).to.be.deep.equal(tokenPairsResponse);
|
expect(tokenPairs).to.be.deep.equal(tokenPairsResponse);
|
||||||
});
|
});
|
||||||
it('throws an error for invalid JSON response', async () => {
|
it('throws an error for invalid JSON response', async () => {
|
||||||
@@ -62,17 +65,20 @@ describe('HttpClient', () => {
|
|||||||
});
|
});
|
||||||
describe('#getOrdersAsync', () => {
|
describe('#getOrdersAsync', () => {
|
||||||
const url = `${relayUrl}/orders`;
|
const url = `${relayUrl}/orders`;
|
||||||
it('gets orders', async () => {
|
it('gets orders with default options when none are provided', async () => {
|
||||||
fetchMock.get(url, ordersResponseJSON);
|
const urlWithQuery = `${url}?page=1&per_page=100`;
|
||||||
|
fetchMock.get(urlWithQuery, ordersResponseJSON);
|
||||||
const orders = await relayerClient.getOrdersAsync();
|
const orders = await relayerClient.getOrdersAsync();
|
||||||
expect(orders).to.be.deep.equal(ordersResponse);
|
expect(orders).to.be.deep.equal(ordersResponse);
|
||||||
});
|
});
|
||||||
it('gets specific orders for request', async () => {
|
it('gets orders with specified request options', async () => {
|
||||||
const tokenAddress = '0x323b5d4c32345ced77393b3530b1eed0f346429d';
|
const tokenAddress = '0x323b5d4c32345ced77393b3530b1eed0f346429d';
|
||||||
const ordersRequest = {
|
const ordersRequest = {
|
||||||
tokenAddress,
|
tokenAddress,
|
||||||
|
page: 3,
|
||||||
|
perPage: 50,
|
||||||
};
|
};
|
||||||
const urlWithQuery = `${url}?tokenAddress=${tokenAddress}`;
|
const urlWithQuery = `${url}?page=3&per_page=50&tokenAddress=${tokenAddress}`;
|
||||||
fetchMock.get(urlWithQuery, ordersResponseJSON);
|
fetchMock.get(urlWithQuery, ordersResponseJSON);
|
||||||
const orders = await relayerClient.getOrdersAsync(ordersRequest);
|
const orders = await relayerClient.getOrdersAsync(ordersRequest);
|
||||||
expect(orders).to.be.deep.equal(ordersResponse);
|
expect(orders).to.be.deep.equal(ordersResponse);
|
||||||
@@ -100,14 +106,27 @@ describe('HttpClient', () => {
|
|||||||
baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d',
|
baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d',
|
||||||
quoteTokenAddress: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32',
|
quoteTokenAddress: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32',
|
||||||
};
|
};
|
||||||
const url = `${relayUrl}/orderbook?baseTokenAddress=${request.baseTokenAddress}"eTokenAddress=${
|
const url = `${relayUrl}/orderbook`;
|
||||||
request.quoteTokenAddress
|
it('gets orderbook with default page options when none are provided', async () => {
|
||||||
}`;
|
const urlWithQuery = `${url}?baseTokenAddress=${
|
||||||
it('gets order book', async () => {
|
request.baseTokenAddress
|
||||||
fetchMock.get(url, orderbookJSON);
|
}&page=1&per_page=100"eTokenAddress=${request.quoteTokenAddress}`;
|
||||||
|
fetchMock.get(urlWithQuery, orderbookJSON);
|
||||||
const orderbook = await relayerClient.getOrderbookAsync(request);
|
const orderbook = await relayerClient.getOrderbookAsync(request);
|
||||||
expect(orderbook).to.be.deep.equal(orderbookResponse);
|
expect(orderbook).to.be.deep.equal(orderbookResponse);
|
||||||
});
|
});
|
||||||
|
it('gets orderbook with specified page options', async () => {
|
||||||
|
const urlWithQuery = `${url}?baseTokenAddress=${
|
||||||
|
request.baseTokenAddress
|
||||||
|
}&page=3&per_page=50"eTokenAddress=${request.quoteTokenAddress}`;
|
||||||
|
fetchMock.get(urlWithQuery, orderbookJSON);
|
||||||
|
const pagedRequestOptions = {
|
||||||
|
page: 3,
|
||||||
|
perPage: 50,
|
||||||
|
};
|
||||||
|
const orderbook = await relayerClient.getOrderbookAsync(request, pagedRequestOptions);
|
||||||
|
expect(orderbook).to.be.deep.equal(orderbookResponse);
|
||||||
|
});
|
||||||
it('throws an error for invalid JSON response', async () => {
|
it('throws an error for invalid JSON response', async () => {
|
||||||
fetchMock.get(url, { test: 'dummy' });
|
fetchMock.get(url, { test: 'dummy' });
|
||||||
expect(relayerClient.getOrderbookAsync(request)).to.be.rejected();
|
expect(relayerClient.getOrderbookAsync(request)).to.be.rejected();
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"private": true,
|
"private": true,
|
||||||
"name": "contracts",
|
"name": "contracts",
|
||||||
"version": "2.1.10",
|
"version": "2.1.12",
|
||||||
"description": "Smart contract components of 0x protocol",
|
"description": "Smart contract components of 0x protocol",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"directories": {
|
"directories": {
|
||||||
@@ -15,13 +15,16 @@
|
|||||||
"test": "run-s compile build run_mocha",
|
"test": "run-s compile build run_mocha",
|
||||||
"run_mocha": "mocha 'lib/test/**/*.js' --timeout 10000 --bail --exit",
|
"run_mocha": "mocha 'lib/test/**/*.js' --timeout 10000 --bail --exit",
|
||||||
"compile:comment": "Yarn workspaces do not link binaries correctly so we need to reference them directly https://github.com/yarnpkg/yarn/issues/3846",
|
"compile:comment": "Yarn workspaces do not link binaries correctly so we need to reference them directly https://github.com/yarnpkg/yarn/issues/3846",
|
||||||
"compile": "node ../deployer/lib/src/cli.js compile --contracts-dir src/contracts --artifacts-dir src/artifacts",
|
"compile": "node ../deployer/lib/src/cli.js compile --contracts ${npm_package_config_contracts} --contracts-dir src/contracts --artifacts-dir src/artifacts",
|
||||||
"clean": "rm -rf ./lib",
|
"clean": "shx rm -rf ./lib",
|
||||||
"generate_contract_wrappers": "node ../abi-gen/lib/index.js --abis 'src/artifacts/@(DummyToken|TokenTransferProxy|Exchange|TokenRegistry|MultiSigWallet|MultiSigWalletWithTimeLock|MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress|TokenRegistry|ZRXToken).json' --template contract_templates/contract.handlebars --partials 'contract_templates/partials/**/*.handlebars' --output src/contract_wrappers/generated",
|
"generate_contract_wrappers": "node ../abi-gen/lib/index.js --abis 'src/artifacts/@(DummyToken|TokenTransferProxy|Exchange|TokenRegistry|MultiSigWallet|MultiSigWalletWithTimeLock|MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress|TokenRegistry|ZRXToken).json' --template contract_templates/contract.handlebars --partials 'contract_templates/partials/**/*.handlebars' --output src/contract_wrappers/generated",
|
||||||
"migrate": "node ../deployer/lib/src/cli.js migrate",
|
"migrate": "node ../deployer/lib/src/cli.js migrate",
|
||||||
"lint": "tslint --project . 'migrations/**/*.ts' 'test/**/*.ts' 'util/**/*.ts' 'deploy/**/*.ts'",
|
"lint": "tslint --project . 'migrations/**/*.ts' 'test/**/*.ts' 'util/**/*.ts' 'deploy/**/*.ts'",
|
||||||
"test:circleci": "yarn test"
|
"test:circleci": "yarn test"
|
||||||
},
|
},
|
||||||
|
"config": {
|
||||||
|
"contracts": "Exchange,DummyToken,ZRXToken,Token,WETH9,TokenTransferProxy,MultiSigWallet,MultiSigWalletWithTimeLock,MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress,MaliciousToken,TokenRegistry"
|
||||||
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/0xProject/0x.js.git"
|
"url": "https://github.com/0xProject/0x.js.git"
|
||||||
@@ -33,9 +36,9 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/0xProject/0x.js/packages/contracts/README.md",
|
"homepage": "https://github.com/0xProject/0x.js/packages/contracts/README.md",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@0xproject/dev-utils": "^0.0.11",
|
"@0xproject/dev-utils": "^0.0.13",
|
||||||
"@0xproject/tslint-config": "^0.4.7",
|
"@0xproject/tslint-config": "^0.4.9",
|
||||||
"@0xproject/types": "^0.2.0",
|
"@0xproject/types": "^0.2.2",
|
||||||
"@types/bluebird": "^3.5.3",
|
"@types/bluebird": "^3.5.3",
|
||||||
"@types/lodash": "^4.14.86",
|
"@types/lodash": "^4.14.86",
|
||||||
"@types/node": "^8.0.53",
|
"@types/node": "^8.0.53",
|
||||||
@@ -43,27 +46,28 @@
|
|||||||
"@types/yargs": "^10.0.0",
|
"@types/yargs": "^10.0.0",
|
||||||
"chai": "^4.0.1",
|
"chai": "^4.0.1",
|
||||||
"chai-as-promised": "^7.1.0",
|
"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-bignumber": "^2.0.1",
|
||||||
"chai-typescript-typings": "^0.0.2",
|
"chai-typescript-typings": "^0.0.3",
|
||||||
"copyfiles": "^1.2.0",
|
"copyfiles": "^1.2.0",
|
||||||
"dirty-chai": "^2.0.1",
|
"dirty-chai": "^2.0.1",
|
||||||
"mocha": "^4.0.1",
|
"mocha": "^4.0.1",
|
||||||
"npm-run-all": "^4.1.2",
|
"npm-run-all": "^4.1.2",
|
||||||
"solc": "^0.4.18",
|
"solc": "^0.4.18",
|
||||||
|
"shx": "^0.2.2",
|
||||||
"tslint": "5.8.0",
|
"tslint": "5.8.0",
|
||||||
"types-bn": "^0.0.1",
|
"types-bn": "^0.0.1",
|
||||||
"types-ethereumjs-util": "0xProject/types-ethereumjs-util",
|
"types-ethereumjs-util": "0xProject/types-ethereumjs-util",
|
||||||
"typescript": "2.7.1",
|
"typescript": "2.7.1",
|
||||||
"web3-typescript-typings": "^0.9.9",
|
"web3-typescript-typings": "^0.9.10",
|
||||||
"yargs": "^10.0.3"
|
"yargs": "^10.0.3"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"0x.js": "^0.32.1",
|
"0x.js": "^0.32.3",
|
||||||
"@0xproject/deployer": "^0.0.7",
|
"@0xproject/deployer": "^0.0.9",
|
||||||
"@0xproject/json-schemas": "^0.7.9",
|
"@0xproject/json-schemas": "^0.7.11",
|
||||||
"@0xproject/utils": "^0.3.1",
|
"@0xproject/utils": "^0.3.3",
|
||||||
"@0xproject/web3-wrapper": "^0.1.11",
|
"@0xproject/web3-wrapper": "^0.1.13",
|
||||||
"bluebird": "^3.5.0",
|
"bluebird": "^3.5.0",
|
||||||
"bn.js": "^4.11.8",
|
"bn.js": "^4.11.8",
|
||||||
"ethereumjs-abi": "^0.6.4",
|
"ethereumjs-abi": "^0.6.4",
|
||||||
|
File diff suppressed because one or more lines are too long
@@ -1,188 +0,0 @@
|
|||||||
{
|
|
||||||
"contract_name": "ERC20Token",
|
|
||||||
"networks": {
|
|
||||||
"50": {
|
|
||||||
"solc_version": "0.4.18",
|
|
||||||
"keccak256": "0x31be5b5f8d7ae32e5ac282b8740cc7aa87cdc383cabafa02292ea6f38302efcc",
|
|
||||||
"optimizer_enabled": 0,
|
|
||||||
"abi": [
|
|
||||||
{
|
|
||||||
"constant": false,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"name": "_spender",
|
|
||||||
"type": "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "_value",
|
|
||||||
"type": "uint256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "approve",
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "",
|
|
||||||
"type": "bool"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"payable": false,
|
|
||||||
"stateMutability": "nonpayable",
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"constant": true,
|
|
||||||
"inputs": [],
|
|
||||||
"name": "totalSupply",
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "",
|
|
||||||
"type": "uint256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"payable": false,
|
|
||||||
"stateMutability": "view",
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"constant": false,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"name": "_from",
|
|
||||||
"type": "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "_to",
|
|
||||||
"type": "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "_value",
|
|
||||||
"type": "uint256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "transferFrom",
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "",
|
|
||||||
"type": "bool"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"payable": false,
|
|
||||||
"stateMutability": "nonpayable",
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"constant": true,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"name": "_owner",
|
|
||||||
"type": "address"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "balanceOf",
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "",
|
|
||||||
"type": "uint256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"payable": false,
|
|
||||||
"stateMutability": "view",
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"constant": false,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"name": "_to",
|
|
||||||
"type": "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "_value",
|
|
||||||
"type": "uint256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "transfer",
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "",
|
|
||||||
"type": "bool"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"payable": false,
|
|
||||||
"stateMutability": "nonpayable",
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"constant": true,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"name": "_owner",
|
|
||||||
"type": "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "_spender",
|
|
||||||
"type": "address"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "allowance",
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "",
|
|
||||||
"type": "uint256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"payable": false,
|
|
||||||
"stateMutability": "view",
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"anonymous": false,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"indexed": true,
|
|
||||||
"name": "_from",
|
|
||||||
"type": "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"indexed": true,
|
|
||||||
"name": "_to",
|
|
||||||
"type": "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"indexed": false,
|
|
||||||
"name": "_value",
|
|
||||||
"type": "uint256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "Transfer",
|
|
||||||
"type": "event"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"anonymous": false,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"indexed": true,
|
|
||||||
"name": "_owner",
|
|
||||||
"type": "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"indexed": true,
|
|
||||||
"name": "_spender",
|
|
||||||
"type": "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"indexed": false,
|
|
||||||
"name": "_value",
|
|
||||||
"type": "uint256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "Approval",
|
|
||||||
"type": "event"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"unlinked_binary":
|
|
||||||
"0x6060604052341561000f57600080fd5b6109528061001e6000396000f300606060405260043610610078576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063095ea7b31461007d57806318160ddd146100d757806323b872dd1461010057806370a0823114610179578063a9059cbb146101c6578063dd62ed3e14610220575b600080fd5b341561008857600080fd5b6100bd600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190505061028c565b604051808215151515815260200191505060405180910390f35b34156100e257600080fd5b6100ea61037e565b6040518082815260200191505060405180910390f35b341561010b57600080fd5b61015f600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610384565b604051808215151515815260200191505060405180910390f35b341561018457600080fd5b6101b0600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610677565b6040518082815260200191505060405180910390f35b34156101d157600080fd5b610206600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506106bf565b604051808215151515815260200191505060405180910390f35b341561022b57600080fd5b610276600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061089f565b6040518082815260200191505060405180910390f35b600081600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60025481565b6000816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410158015610450575081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410155b80156104da57506000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020540110155b15156104e557600080fd5b816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6000816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015801561078d57506000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020540110155b151561079857600080fd5b816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050929150505600a165627a7a72305820d9af9b2b6ffe19f00d45d30a243f833e31053a2e48142e183c9f1e6b0ead7a9e0029",
|
|
||||||
"updated_at": 1517509619365
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,182 +0,0 @@
|
|||||||
{
|
|
||||||
"contract_name": "ERC20Token_v1",
|
|
||||||
"networks": {
|
|
||||||
"50": {
|
|
||||||
"solc_version": "0.4.11",
|
|
||||||
"keccak256": "0x3d710b436c430d6fe49f64b091555405360d76da6454b93faa8e213eea34a96d",
|
|
||||||
"optimizer_enabled": 0,
|
|
||||||
"abi": [
|
|
||||||
{
|
|
||||||
"constant": false,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"name": "_spender",
|
|
||||||
"type": "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "_value",
|
|
||||||
"type": "uint256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "approve",
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "",
|
|
||||||
"type": "bool"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"payable": false,
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"constant": true,
|
|
||||||
"inputs": [],
|
|
||||||
"name": "totalSupply",
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "",
|
|
||||||
"type": "uint256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"payable": false,
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"constant": false,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"name": "_from",
|
|
||||||
"type": "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "_to",
|
|
||||||
"type": "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "_value",
|
|
||||||
"type": "uint256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "transferFrom",
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "",
|
|
||||||
"type": "bool"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"payable": false,
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"constant": true,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"name": "_owner",
|
|
||||||
"type": "address"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "balanceOf",
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "",
|
|
||||||
"type": "uint256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"payable": false,
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"constant": false,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"name": "_to",
|
|
||||||
"type": "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "_value",
|
|
||||||
"type": "uint256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "transfer",
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "",
|
|
||||||
"type": "bool"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"payable": false,
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"constant": true,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"name": "_owner",
|
|
||||||
"type": "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "_spender",
|
|
||||||
"type": "address"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "allowance",
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "",
|
|
||||||
"type": "uint256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"payable": false,
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"anonymous": false,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"indexed": true,
|
|
||||||
"name": "_from",
|
|
||||||
"type": "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"indexed": true,
|
|
||||||
"name": "_to",
|
|
||||||
"type": "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"indexed": false,
|
|
||||||
"name": "_value",
|
|
||||||
"type": "uint256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "Transfer",
|
|
||||||
"type": "event"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"anonymous": false,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"indexed": true,
|
|
||||||
"name": "_owner",
|
|
||||||
"type": "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"indexed": true,
|
|
||||||
"name": "_spender",
|
|
||||||
"type": "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"indexed": false,
|
|
||||||
"name": "_value",
|
|
||||||
"type": "uint256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "Approval",
|
|
||||||
"type": "event"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"unlinked_binary":
|
|
||||||
"0x6060604052341561000c57fe5b5b61095b8061001c6000396000f30060606040523615610076576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063095ea7b31461007857806318160ddd146100cf57806323b872dd146100f557806370a082311461016b578063a9059cbb146101b5578063dd62ed3e1461020c575bfe5b341561008057fe5b6100b5600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610275565b604051808215151515815260200191505060405180910390f35b34156100d757fe5b6100df610368565b6040518082815260200191505060405180910390f35b34156100fd57fe5b610151600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190505061036e565b604051808215151515815260200191505060405180910390f35b341561017357fe5b61019f600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061066f565b6040518082815260200191505060405180910390f35b34156101bd57fe5b6101f2600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506106b9565b604051808215151515815260200191505060405180910390f35b341561021457fe5b61025f600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506108a7565b6040518082815260200191505060405180910390f35b600081600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a3600190505b92915050565b60025481565b600081600060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015801561043b575081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410155b80156104c75750600060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482600060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020540110155b1561065e5781600060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254019250508190555081600060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a360019050610668565b60009050610668565b5b9392505050565b6000600060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490505b919050565b600081600060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015801561078a5750600060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482600060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020540110155b156108975781600060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190506108a1565b600090506108a1565b5b92915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490505b929150505600a165627a7a72305820441601e8451e1c2d31e6cde19fc920b8f95e79f9d42dd662aeefad13fd8bcfaa0029",
|
|
||||||
"updated_at": 1517509621756
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,49 +0,0 @@
|
|||||||
{
|
|
||||||
"contract_name": "Ownable",
|
|
||||||
"networks": {
|
|
||||||
"50": {
|
|
||||||
"solc_version": "0.4.18",
|
|
||||||
"keccak256": "0x04e5204925913f5ff6b8193f4ab38eef9d53fc9a553f1a737924fc69db492a99",
|
|
||||||
"optimizer_enabled": 0,
|
|
||||||
"abi": [
|
|
||||||
{
|
|
||||||
"constant": true,
|
|
||||||
"inputs": [],
|
|
||||||
"name": "owner",
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "",
|
|
||||||
"type": "address"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"payable": false,
|
|
||||||
"stateMutability": "view",
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"constant": false,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"name": "newOwner",
|
|
||||||
"type": "address"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "transferOwnership",
|
|
||||||
"outputs": [],
|
|
||||||
"payable": false,
|
|
||||||
"stateMutability": "nonpayable",
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"inputs": [],
|
|
||||||
"payable": false,
|
|
||||||
"stateMutability": "nonpayable",
|
|
||||||
"type": "constructor"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"unlinked_binary":
|
|
||||||
"0x6060604052341561000f57600080fd5b336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506102058061005e6000396000f30060606040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680638da5cb5b14610051578063f2fde38b146100a6575b600080fd5b341561005c57600080fd5b6100646100df565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156100b157600080fd5b6100dd600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610104565b005b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561015f57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415156101d657806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b505600a165627a7a723058202c25abe7564c2f872e2f210a96faa6c7691055d67e9a3edd56dcef376c646e170029",
|
|
||||||
"updated_at": 1517509621376
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,46 +0,0 @@
|
|||||||
{
|
|
||||||
"contract_name": "Ownable_v1",
|
|
||||||
"networks": {
|
|
||||||
"50": {
|
|
||||||
"solc_version": "0.4.11",
|
|
||||||
"keccak256": "0x82a6595d8d4c3c9cd44ef0fd8f77528195c35c8173970d2b119374f5d74332f4",
|
|
||||||
"optimizer_enabled": 0,
|
|
||||||
"abi": [
|
|
||||||
{
|
|
||||||
"constant": true,
|
|
||||||
"inputs": [],
|
|
||||||
"name": "owner",
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "",
|
|
||||||
"type": "address"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"payable": false,
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"constant": false,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"name": "newOwner",
|
|
||||||
"type": "address"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "transferOwnership",
|
|
||||||
"outputs": [],
|
|
||||||
"payable": false,
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"inputs": [],
|
|
||||||
"payable": false,
|
|
||||||
"type": "constructor"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"unlinked_binary":
|
|
||||||
"0x6060604052341561000c57fe5b5b33600060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b5b6101fa8061005f6000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680638da5cb5b14610046578063f2fde38b14610098575bfe5b341561004e57fe5b6100566100ce565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156100a057fe5b6100cc600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506100f4565b005b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156101515760006000fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415156101c95780600060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b5b5b505600a165627a7a723058201bce811586dc86b1fc25fa9779089c5bf0b5d2cf9e981a580ef44253300866520029",
|
|
||||||
"updated_at": 1517535966230
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,14 +0,0 @@
|
|||||||
{
|
|
||||||
"contract_name": "SafeMath",
|
|
||||||
"networks": {
|
|
||||||
"50": {
|
|
||||||
"solc_version": "0.4.18",
|
|
||||||
"keccak256": "0xb1d52f567a893c86f452bd80fbb6907d992046a31b35830bc779116d23fd5549",
|
|
||||||
"optimizer_enabled": 0,
|
|
||||||
"abi": [],
|
|
||||||
"unlinked_binary":
|
|
||||||
"0x60606040523415600e57600080fd5b603580601b6000396000f3006060604052600080fd00a165627a7a723058206526256c7c1e7d1d1b2df1caefcbd76717428d6237de37aacbb5097658456b720029",
|
|
||||||
"updated_at": 1517509621492
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,14 +0,0 @@
|
|||||||
{
|
|
||||||
"contract_name": "SafeMath_v1",
|
|
||||||
"networks": {
|
|
||||||
"50": {
|
|
||||||
"solc_version": "0.4.11",
|
|
||||||
"keccak256": "0xd2c1f0518a23e63d5892f66e7b8d228c7486495b139a0f3b049f6ba7803c892d",
|
|
||||||
"optimizer_enabled": 0,
|
|
||||||
"abi": [],
|
|
||||||
"unlinked_binary":
|
|
||||||
"0x60606040523415600b57fe5b5b60338060196000396000f30060606040525bfe00a165627a7a72305820acbb91f6e4b200e929056917b84223c3fedbdeca5c35f7bf9292edf2a8ee4aa00029",
|
|
||||||
"updated_at": 1517509621851
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -168,7 +168,7 @@
|
|||||||
],
|
],
|
||||||
"unlinked_binary":
|
"unlinked_binary":
|
||||||
"0x6060604052341561000f57600080fd5b6102ac8061001e6000396000f30060606040526004361061006d576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063095ea7b31461007257806323b872dd146100cc57806370a0823114610145578063a9059cbb14610192578063dd62ed3e146101ec575b600080fd5b341561007d57600080fd5b6100b2600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610258565b604051808215151515815260200191505060405180910390f35b34156100d757600080fd5b61012b600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610260565b604051808215151515815260200191505060405180910390f35b341561015057600080fd5b61017c600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610269565b6040518082815260200191505060405180910390f35b341561019d57600080fd5b6101d2600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610270565b604051808215151515815260200191505060405180910390f35b34156101f757600080fd5b610242600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610278565b6040518082815260200191505060405180910390f35b600092915050565b60009392505050565b6000919050565b600092915050565b6000929150505600a165627a7a723058201ef98a5ecc619c89a935fee340b114a09fe44aa51aa765f4037dd3423f49d42d0029",
|
"0x6060604052341561000f57600080fd5b6102ac8061001e6000396000f30060606040526004361061006d576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063095ea7b31461007257806323b872dd146100cc57806370a0823114610145578063a9059cbb14610192578063dd62ed3e146101ec575b600080fd5b341561007d57600080fd5b6100b2600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610258565b604051808215151515815260200191505060405180910390f35b34156100d757600080fd5b61012b600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610260565b604051808215151515815260200191505060405180910390f35b341561015057600080fd5b61017c600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610269565b6040518082815260200191505060405180910390f35b341561019d57600080fd5b6101d2600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610270565b604051808215151515815260200191505060405180910390f35b34156101f757600080fd5b610242600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610278565b6040518082815260200191505060405180910390f35b600092915050565b60009392505050565b6000919050565b600092915050565b6000929150505600a165627a7a723058201ef98a5ecc619c89a935fee340b114a09fe44aa51aa765f4037dd3423f49d42d0029",
|
||||||
"updated_at": 1517509619496
|
"updated_at": 1518645860796
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,182 +0,0 @@
|
|||||||
{
|
|
||||||
"contract_name": "Token_v1",
|
|
||||||
"networks": {
|
|
||||||
"50": {
|
|
||||||
"solc_version": "0.4.11",
|
|
||||||
"keccak256": "0x35a82bc7bc0994caa97f8ea44660b9b5e796acfe72705b5ff7ed8f2a3c47ff37",
|
|
||||||
"optimizer_enabled": 0,
|
|
||||||
"abi": [
|
|
||||||
{
|
|
||||||
"constant": false,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"name": "_spender",
|
|
||||||
"type": "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "_value",
|
|
||||||
"type": "uint256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "approve",
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "success",
|
|
||||||
"type": "bool"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"payable": false,
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"constant": true,
|
|
||||||
"inputs": [],
|
|
||||||
"name": "totalSupply",
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "supply",
|
|
||||||
"type": "uint256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"payable": false,
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"constant": false,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"name": "_from",
|
|
||||||
"type": "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "_to",
|
|
||||||
"type": "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "_value",
|
|
||||||
"type": "uint256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "transferFrom",
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "success",
|
|
||||||
"type": "bool"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"payable": false,
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"constant": true,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"name": "_owner",
|
|
||||||
"type": "address"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "balanceOf",
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "balance",
|
|
||||||
"type": "uint256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"payable": false,
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"constant": false,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"name": "_to",
|
|
||||||
"type": "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "_value",
|
|
||||||
"type": "uint256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "transfer",
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "success",
|
|
||||||
"type": "bool"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"payable": false,
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"constant": true,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"name": "_owner",
|
|
||||||
"type": "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "_spender",
|
|
||||||
"type": "address"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "allowance",
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "remaining",
|
|
||||||
"type": "uint256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"payable": false,
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"anonymous": false,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"indexed": true,
|
|
||||||
"name": "_from",
|
|
||||||
"type": "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"indexed": true,
|
|
||||||
"name": "_to",
|
|
||||||
"type": "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"indexed": false,
|
|
||||||
"name": "_value",
|
|
||||||
"type": "uint256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "Transfer",
|
|
||||||
"type": "event"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"anonymous": false,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"indexed": true,
|
|
||||||
"name": "_owner",
|
|
||||||
"type": "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"indexed": true,
|
|
||||||
"name": "_spender",
|
|
||||||
"type": "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"indexed": false,
|
|
||||||
"name": "_value",
|
|
||||||
"type": "uint256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "Approval",
|
|
||||||
"type": "event"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"unlinked_binary":
|
|
||||||
"0x6060604052341561000c57fe5b5b6102d48061001c6000396000f30060606040523615610076576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063095ea7b31461007857806318160ddd146100cf57806323b872dd146100f557806370a082311461016b578063a9059cbb146101b5578063dd62ed3e1461020c575bfe5b341561008057fe5b6100b5600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610275565b604051808215151515815260200191505060405180910390f35b34156100d757fe5b6100df61027e565b6040518082815260200191505060405180910390f35b34156100fd57fe5b610151600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610284565b604051808215151515815260200191505060405180910390f35b341561017357fe5b61019f600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061028e565b6040518082815260200191505060405180910390f35b34156101bd57fe5b6101f2600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610296565b604051808215151515815260200191505060405180910390f35b341561021457fe5b61025f600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061029f565b6040518082815260200191505060405180910390f35b60005b92915050565b60005b90565b60005b9392505050565b60005b919050565b60005b92915050565b60005b929150505600a165627a7a72305820b8fd6d6a6fe5fb53fa4968f246aad074b179498a6d15208c4b2d8be473df69420029",
|
|
||||||
"updated_at": 1517509621946
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,188 +0,0 @@
|
|||||||
{
|
|
||||||
"contract_name": "UnlimitedAllowanceToken",
|
|
||||||
"networks": {
|
|
||||||
"50": {
|
|
||||||
"solc_version": "0.4.18",
|
|
||||||
"keccak256": "0xfc55032f0942ce4081a9f8c3eacfa0bddf61e1fb76593c8d6514adcb97a96690",
|
|
||||||
"optimizer_enabled": 0,
|
|
||||||
"abi": [
|
|
||||||
{
|
|
||||||
"constant": false,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"name": "_spender",
|
|
||||||
"type": "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "_value",
|
|
||||||
"type": "uint256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "approve",
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "",
|
|
||||||
"type": "bool"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"payable": false,
|
|
||||||
"stateMutability": "nonpayable",
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"constant": true,
|
|
||||||
"inputs": [],
|
|
||||||
"name": "totalSupply",
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "",
|
|
||||||
"type": "uint256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"payable": false,
|
|
||||||
"stateMutability": "view",
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"constant": false,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"name": "_from",
|
|
||||||
"type": "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "_to",
|
|
||||||
"type": "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "_value",
|
|
||||||
"type": "uint256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "transferFrom",
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "",
|
|
||||||
"type": "bool"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"payable": false,
|
|
||||||
"stateMutability": "nonpayable",
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"constant": true,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"name": "_owner",
|
|
||||||
"type": "address"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "balanceOf",
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "",
|
|
||||||
"type": "uint256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"payable": false,
|
|
||||||
"stateMutability": "view",
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"constant": false,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"name": "_to",
|
|
||||||
"type": "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "_value",
|
|
||||||
"type": "uint256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "transfer",
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "",
|
|
||||||
"type": "bool"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"payable": false,
|
|
||||||
"stateMutability": "nonpayable",
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"constant": true,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"name": "_owner",
|
|
||||||
"type": "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "_spender",
|
|
||||||
"type": "address"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "allowance",
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "",
|
|
||||||
"type": "uint256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"payable": false,
|
|
||||||
"stateMutability": "view",
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"anonymous": false,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"indexed": true,
|
|
||||||
"name": "_from",
|
|
||||||
"type": "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"indexed": true,
|
|
||||||
"name": "_to",
|
|
||||||
"type": "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"indexed": false,
|
|
||||||
"name": "_value",
|
|
||||||
"type": "uint256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "Transfer",
|
|
||||||
"type": "event"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"anonymous": false,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"indexed": true,
|
|
||||||
"name": "_owner",
|
|
||||||
"type": "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"indexed": true,
|
|
||||||
"name": "_spender",
|
|
||||||
"type": "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"indexed": false,
|
|
||||||
"name": "_value",
|
|
||||||
"type": "uint256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "Approval",
|
|
||||||
"type": "event"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"unlinked_binary":
|
|
||||||
"0x6060604052341561000f57600080fd5b6109808061001e6000396000f300606060405260043610610078576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063095ea7b31461007d57806318160ddd146100d757806323b872dd1461010057806370a0823114610179578063a9059cbb146101c6578063dd62ed3e14610220575b600080fd5b341561008857600080fd5b6100bd600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190505061028c565b604051808215151515815260200191505060405180910390f35b34156100e257600080fd5b6100ea61037e565b6040518082815260200191505060405180910390f35b341561010b57600080fd5b61015f600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610384565b604051808215151515815260200191505060405180910390f35b341561018457600080fd5b6101b0600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506106a5565b6040518082815260200191505060405180910390f35b34156101d157600080fd5b610206600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506106ed565b604051808215151515815260200191505060405180910390f35b341561022b57600080fd5b610276600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506108cd565b6040518082815260200191505060405180910390f35b600081600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60025481565b600080600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050826000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101580156104545750828110155b80156104de57506000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020540110155b15156104e957600080fd5b826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550826000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8110156106345782600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055505b8373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a360019150509392505050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6000816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101580156107bb57506000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020540110155b15156107c657600080fd5b816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050929150505600a165627a7a72305820fcfe717221cfe35887f7cf953f3c89ebf20f5cc389a92a5b68e2fd22c236d0e30029",
|
|
||||||
"updated_at": 1517509620184
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,182 +0,0 @@
|
|||||||
{
|
|
||||||
"contract_name": "UnlimitedAllowanceToken_v1",
|
|
||||||
"networks": {
|
|
||||||
"50": {
|
|
||||||
"solc_version": "0.4.11",
|
|
||||||
"keccak256": "0x3b548a72cde0786747f9bdf42901fcf51ec546ced40506335d28b0778e35d25a",
|
|
||||||
"optimizer_enabled": 0,
|
|
||||||
"abi": [
|
|
||||||
{
|
|
||||||
"constant": false,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"name": "_spender",
|
|
||||||
"type": "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "_value",
|
|
||||||
"type": "uint256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "approve",
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "",
|
|
||||||
"type": "bool"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"payable": false,
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"constant": true,
|
|
||||||
"inputs": [],
|
|
||||||
"name": "totalSupply",
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "",
|
|
||||||
"type": "uint256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"payable": false,
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"constant": false,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"name": "_from",
|
|
||||||
"type": "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "_to",
|
|
||||||
"type": "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "_value",
|
|
||||||
"type": "uint256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "transferFrom",
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "",
|
|
||||||
"type": "bool"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"payable": false,
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"constant": true,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"name": "_owner",
|
|
||||||
"type": "address"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "balanceOf",
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "",
|
|
||||||
"type": "uint256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"payable": false,
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"constant": false,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"name": "_to",
|
|
||||||
"type": "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "_value",
|
|
||||||
"type": "uint256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "transfer",
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "",
|
|
||||||
"type": "bool"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"payable": false,
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"constant": true,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"name": "_owner",
|
|
||||||
"type": "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "_spender",
|
|
||||||
"type": "address"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "allowance",
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "",
|
|
||||||
"type": "uint256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"payable": false,
|
|
||||||
"type": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"anonymous": false,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"indexed": true,
|
|
||||||
"name": "_from",
|
|
||||||
"type": "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"indexed": true,
|
|
||||||
"name": "_to",
|
|
||||||
"type": "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"indexed": false,
|
|
||||||
"name": "_value",
|
|
||||||
"type": "uint256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "Transfer",
|
|
||||||
"type": "event"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"anonymous": false,
|
|
||||||
"inputs": [
|
|
||||||
{
|
|
||||||
"indexed": true,
|
|
||||||
"name": "_owner",
|
|
||||||
"type": "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"indexed": true,
|
|
||||||
"name": "_spender",
|
|
||||||
"type": "address"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"indexed": false,
|
|
||||||
"name": "_value",
|
|
||||||
"type": "uint256"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "Approval",
|
|
||||||
"type": "event"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"unlinked_binary":
|
|
||||||
"0x6060604052341561000c57fe5b5b61098a8061001c6000396000f30060606040523615610076576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063095ea7b31461007857806318160ddd146100cf57806323b872dd146100f557806370a082311461016b578063a9059cbb146101b5578063dd62ed3e1461020c575bfe5b341561008057fe5b6100b5600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610275565b604051808215151515815260200191505060405180910390f35b34156100d757fe5b6100df610368565b6040518082815260200191505060405180910390f35b34156100fd57fe5b610151600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190505061036e565b604051808215151515815260200191505060405180910390f35b341561017357fe5b61019f600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061069e565b6040518082815260200191505060405180910390f35b34156101bd57fe5b6101f2600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506106e8565b604051808215151515815260200191505060405180910390f35b341561021457fe5b61025f600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506108d6565b6040518082815260200191505060405180910390f35b600081600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a3600190505b92915050565b60025481565b60006000600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082600060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101580156104405750828110155b80156104cc5750600060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483600060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020540110155b1561068c5782600060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254019250508190555082600060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81101561061e5782600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055505b8373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a360019150610696565b60009150610696565b5b509392505050565b6000600060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490505b919050565b600081600060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101580156107b95750600060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482600060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020540110155b156108c65781600060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190506108d0565b600090506108d0565b5b92915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490505b929150505600a165627a7a723058204c2e4edd6947d81382e4a79ca7070d2068e887e849a5998d8cd99e1ae7e4107b0029",
|
|
||||||
"updated_at": 1517509622346
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -3,6 +3,7 @@ import {
|
|||||||
LogErrorContractEventArgs,
|
LogErrorContractEventArgs,
|
||||||
LogFillContractEventArgs,
|
LogFillContractEventArgs,
|
||||||
LogWithDecodedArgs,
|
LogWithDecodedArgs,
|
||||||
|
SignedOrder,
|
||||||
TransactionReceiptWithDecodedLogs,
|
TransactionReceiptWithDecodedLogs,
|
||||||
ZeroEx,
|
ZeroEx,
|
||||||
} from '0x.js';
|
} from '0x.js';
|
||||||
@@ -20,7 +21,6 @@ import { Balances } from '../../util/balances';
|
|||||||
import { constants } from '../../util/constants';
|
import { constants } from '../../util/constants';
|
||||||
import { crypto } from '../../util/crypto';
|
import { crypto } from '../../util/crypto';
|
||||||
import { ExchangeWrapper } from '../../util/exchange_wrapper';
|
import { ExchangeWrapper } from '../../util/exchange_wrapper';
|
||||||
import { Order } from '../../util/order';
|
|
||||||
import { OrderFactory } from '../../util/order_factory';
|
import { OrderFactory } from '../../util/order_factory';
|
||||||
import { BalancesByOwner, ContractName, ExchangeContractErrs } from '../../util/types';
|
import { BalancesByOwner, ContractName, ExchangeContractErrs } from '../../util/types';
|
||||||
import { chaiSetup } from '../utils/chai_setup';
|
import { chaiSetup } from '../utils/chai_setup';
|
||||||
@@ -46,7 +46,7 @@ describe('Exchange', () => {
|
|||||||
let exchange: ExchangeContract;
|
let exchange: ExchangeContract;
|
||||||
let tokenTransferProxy: TokenTransferProxyContract;
|
let tokenTransferProxy: TokenTransferProxyContract;
|
||||||
|
|
||||||
let order: Order;
|
let signedOrder: SignedOrder;
|
||||||
let balances: BalancesByOwner;
|
let balances: BalancesByOwner;
|
||||||
let exWrapper: ExchangeWrapper;
|
let exWrapper: ExchangeWrapper;
|
||||||
let dmyBalances: Balances;
|
let dmyBalances: Balances;
|
||||||
@@ -84,14 +84,14 @@ describe('Exchange', () => {
|
|||||||
exchangeContractAddress: exchange.address,
|
exchangeContractAddress: exchange.address,
|
||||||
maker,
|
maker,
|
||||||
feeRecipient,
|
feeRecipient,
|
||||||
makerToken: rep.address,
|
makerTokenAddress: rep.address,
|
||||||
takerToken: dgd.address,
|
takerTokenAddress: dgd.address,
|
||||||
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
|
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
|
||||||
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
|
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
|
||||||
makerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18),
|
makerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18),
|
||||||
takerFee: 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]);
|
dmyBalances = new Balances([rep, dgd, zrx], [maker, taker, feeRecipient]);
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
rep.approve.sendTransactionAsync(tokenTransferProxy.address, INITIAL_ALLOWANCE, {
|
rep.approve.sendTransactionAsync(tokenTransferProxy.address, INITIAL_ALLOWANCE, {
|
||||||
@@ -147,80 +147,85 @@ describe('Exchange', () => {
|
|||||||
describe('fillOrder', () => {
|
describe('fillOrder', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
balances = await dmyBalances.getAsync();
|
balances = await dmyBalances.getAsync();
|
||||||
order = await orderFactory.newSignedOrderAsync();
|
signedOrder = await orderFactory.newSignedOrderAsync();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create an unfillable order', async () => {
|
it('should create an unfillable order', async () => {
|
||||||
order = await orderFactory.newSignedOrderAsync({
|
signedOrder = await orderFactory.newSignedOrderAsync({
|
||||||
makerTokenAmount: new BigNumber(1001),
|
makerTokenAmount: new BigNumber(1001),
|
||||||
takerTokenAmount: new BigNumber(3),
|
takerTokenAmount: new BigNumber(3),
|
||||||
});
|
});
|
||||||
|
|
||||||
const filledTakerTokenAmountBefore = await zeroEx.exchange.getFilledTakerAmountAsync(order.params
|
const filledTakerTokenAmountBefore = await zeroEx.exchange.getFilledTakerAmountAsync(
|
||||||
.orderHashHex as string);
|
ZeroEx.getOrderHashHex(signedOrder),
|
||||||
|
);
|
||||||
expect(filledTakerTokenAmountBefore).to.be.bignumber.equal(0);
|
expect(filledTakerTokenAmountBefore).to.be.bignumber.equal(0);
|
||||||
|
|
||||||
const fillTakerTokenAmount1 = new BigNumber(2);
|
const fillTakerTokenAmount1 = new BigNumber(2);
|
||||||
await exWrapper.fillOrderAsync(order, taker, {
|
await exWrapper.fillOrderAsync(signedOrder, taker, {
|
||||||
fillTakerTokenAmount: fillTakerTokenAmount1,
|
fillTakerTokenAmount: fillTakerTokenAmount1,
|
||||||
});
|
});
|
||||||
|
|
||||||
const filledTakerTokenAmountAfter1 = await zeroEx.exchange.getFilledTakerAmountAsync(order.params
|
const filledTakerTokenAmountAfter1 = await zeroEx.exchange.getFilledTakerAmountAsync(
|
||||||
.orderHashHex as string);
|
ZeroEx.getOrderHashHex(signedOrder),
|
||||||
|
);
|
||||||
expect(filledTakerTokenAmountAfter1).to.be.bignumber.equal(fillTakerTokenAmount1);
|
expect(filledTakerTokenAmountAfter1).to.be.bignumber.equal(fillTakerTokenAmount1);
|
||||||
|
|
||||||
const fillTakerTokenAmount2 = new BigNumber(1);
|
const fillTakerTokenAmount2 = new BigNumber(1);
|
||||||
await exWrapper.fillOrderAsync(order, taker, {
|
await exWrapper.fillOrderAsync(signedOrder, taker, {
|
||||||
fillTakerTokenAmount: fillTakerTokenAmount2,
|
fillTakerTokenAmount: fillTakerTokenAmount2,
|
||||||
});
|
});
|
||||||
|
|
||||||
const filledTakerTokenAmountAfter2 = await zeroEx.exchange.getFilledTakerAmountAsync(order.params
|
const filledTakerTokenAmountAfter2 = await zeroEx.exchange.getFilledTakerAmountAsync(
|
||||||
.orderHashHex as string);
|
ZeroEx.getOrderHashHex(signedOrder),
|
||||||
|
);
|
||||||
expect(filledTakerTokenAmountAfter2).to.be.bignumber.equal(filledTakerTokenAmountAfter1);
|
expect(filledTakerTokenAmountAfter2).to.be.bignumber.equal(filledTakerTokenAmountAfter1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should transfer the correct amounts when makerTokenAmount === takerTokenAmount', async () => {
|
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),
|
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
|
||||||
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
|
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
|
||||||
});
|
});
|
||||||
|
|
||||||
const filledTakerTokenAmountBefore = await zeroEx.exchange.getFilledTakerAmountAsync(order.params
|
const filledTakerTokenAmountBefore = await zeroEx.exchange.getFilledTakerAmountAsync(
|
||||||
.orderHashHex as string);
|
ZeroEx.getOrderHashHex(signedOrder),
|
||||||
|
);
|
||||||
expect(filledTakerTokenAmountBefore).to.be.bignumber.equal(0);
|
expect(filledTakerTokenAmountBefore).to.be.bignumber.equal(0);
|
||||||
|
|
||||||
const fillTakerTokenAmount = order.params.takerTokenAmount.div(2);
|
const fillTakerTokenAmount = signedOrder.takerTokenAmount.div(2);
|
||||||
await exWrapper.fillOrderAsync(order, taker, { fillTakerTokenAmount });
|
await exWrapper.fillOrderAsync(signedOrder, taker, { fillTakerTokenAmount });
|
||||||
|
|
||||||
const filledTakerTokenAmountAfter = await zeroEx.exchange.getFilledTakerAmountAsync(order.params
|
const filledTakerTokenAmountAfter = await zeroEx.exchange.getFilledTakerAmountAsync(
|
||||||
.orderHashHex as string);
|
ZeroEx.getOrderHashHex(signedOrder),
|
||||||
|
);
|
||||||
expect(filledTakerTokenAmountAfter).to.be.bignumber.equal(fillTakerTokenAmount);
|
expect(filledTakerTokenAmountAfter).to.be.bignumber.equal(fillTakerTokenAmount);
|
||||||
|
|
||||||
const newBalances = await dmyBalances.getAsync();
|
const newBalances = await dmyBalances.getAsync();
|
||||||
|
|
||||||
const fillMakerTokenAmount = fillTakerTokenAmount
|
const fillMakerTokenAmount = fillTakerTokenAmount
|
||||||
.times(order.params.makerTokenAmount)
|
.times(signedOrder.makerTokenAmount)
|
||||||
.dividedToIntegerBy(order.params.takerTokenAmount);
|
.dividedToIntegerBy(signedOrder.takerTokenAmount);
|
||||||
const paidMakerFee = order.params.makerFee
|
const paidMakerFee = signedOrder.makerFee
|
||||||
.times(fillMakerTokenAmount)
|
.times(fillMakerTokenAmount)
|
||||||
.dividedToIntegerBy(order.params.makerTokenAmount);
|
.dividedToIntegerBy(signedOrder.makerTokenAmount);
|
||||||
const paidTakerFee = order.params.takerFee
|
const paidTakerFee = signedOrder.takerFee
|
||||||
.times(fillMakerTokenAmount)
|
.times(fillMakerTokenAmount)
|
||||||
.dividedToIntegerBy(order.params.makerTokenAmount);
|
.dividedToIntegerBy(signedOrder.makerTokenAmount);
|
||||||
expect(newBalances[maker][order.params.makerToken]).to.be.bignumber.equal(
|
expect(newBalances[maker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
|
||||||
balances[maker][order.params.makerToken].minus(fillMakerTokenAmount),
|
balances[maker][signedOrder.makerTokenAddress].minus(fillMakerTokenAmount),
|
||||||
);
|
);
|
||||||
expect(newBalances[maker][order.params.takerToken]).to.be.bignumber.equal(
|
expect(newBalances[maker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
|
||||||
balances[maker][order.params.takerToken].add(fillTakerTokenAmount),
|
balances[maker][signedOrder.takerTokenAddress].add(fillTakerTokenAmount),
|
||||||
);
|
);
|
||||||
expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(
|
expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(
|
||||||
balances[maker][zrx.address].minus(paidMakerFee),
|
balances[maker][zrx.address].minus(paidMakerFee),
|
||||||
);
|
);
|
||||||
expect(newBalances[taker][order.params.takerToken]).to.be.bignumber.equal(
|
expect(newBalances[taker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
|
||||||
balances[taker][order.params.takerToken].minus(fillTakerTokenAmount),
|
balances[taker][signedOrder.takerTokenAddress].minus(fillTakerTokenAmount),
|
||||||
);
|
);
|
||||||
expect(newBalances[taker][order.params.makerToken]).to.be.bignumber.equal(
|
expect(newBalances[taker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
|
||||||
balances[taker][order.params.makerToken].add(fillMakerTokenAmount),
|
balances[taker][signedOrder.makerTokenAddress].add(fillMakerTokenAmount),
|
||||||
);
|
);
|
||||||
expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(
|
expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(
|
||||||
balances[taker][zrx.address].minus(paidTakerFee),
|
balances[taker][zrx.address].minus(paidTakerFee),
|
||||||
@@ -231,47 +236,49 @@ describe('Exchange', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should transfer the correct amounts when makerTokenAmount > takerTokenAmount', async () => {
|
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),
|
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
|
||||||
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
|
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
|
||||||
});
|
});
|
||||||
|
|
||||||
const filledTakerTokenAmountBefore = await zeroEx.exchange.getFilledTakerAmountAsync(order.params
|
const filledTakerTokenAmountBefore = await zeroEx.exchange.getFilledTakerAmountAsync(
|
||||||
.orderHashHex as string);
|
ZeroEx.getOrderHashHex(signedOrder),
|
||||||
|
);
|
||||||
expect(filledTakerTokenAmountBefore).to.be.bignumber.equal(0);
|
expect(filledTakerTokenAmountBefore).to.be.bignumber.equal(0);
|
||||||
|
|
||||||
const fillTakerTokenAmount = order.params.takerTokenAmount.div(2);
|
const fillTakerTokenAmount = signedOrder.takerTokenAmount.div(2);
|
||||||
await exWrapper.fillOrderAsync(order, taker, { fillTakerTokenAmount });
|
await exWrapper.fillOrderAsync(signedOrder, taker, { fillTakerTokenAmount });
|
||||||
|
|
||||||
const filledTakerTokenAmountAfter = await zeroEx.exchange.getFilledTakerAmountAsync(order.params
|
const filledTakerTokenAmountAfter = await zeroEx.exchange.getFilledTakerAmountAsync(
|
||||||
.orderHashHex as string);
|
ZeroEx.getOrderHashHex(signedOrder),
|
||||||
|
);
|
||||||
expect(filledTakerTokenAmountAfter).to.be.bignumber.equal(fillTakerTokenAmount);
|
expect(filledTakerTokenAmountAfter).to.be.bignumber.equal(fillTakerTokenAmount);
|
||||||
|
|
||||||
const newBalances = await dmyBalances.getAsync();
|
const newBalances = await dmyBalances.getAsync();
|
||||||
|
|
||||||
const fillMakerTokenAmount = fillTakerTokenAmount
|
const fillMakerTokenAmount = fillTakerTokenAmount
|
||||||
.times(order.params.makerTokenAmount)
|
.times(signedOrder.makerTokenAmount)
|
||||||
.dividedToIntegerBy(order.params.takerTokenAmount);
|
.dividedToIntegerBy(signedOrder.takerTokenAmount);
|
||||||
const paidMakerFee = order.params.makerFee
|
const paidMakerFee = signedOrder.makerFee
|
||||||
.times(fillMakerTokenAmount)
|
.times(fillMakerTokenAmount)
|
||||||
.dividedToIntegerBy(order.params.makerTokenAmount);
|
.dividedToIntegerBy(signedOrder.makerTokenAmount);
|
||||||
const paidTakerFee = order.params.takerFee
|
const paidTakerFee = signedOrder.takerFee
|
||||||
.times(fillMakerTokenAmount)
|
.times(fillMakerTokenAmount)
|
||||||
.dividedToIntegerBy(order.params.makerTokenAmount);
|
.dividedToIntegerBy(signedOrder.makerTokenAmount);
|
||||||
expect(newBalances[maker][order.params.makerToken]).to.be.bignumber.equal(
|
expect(newBalances[maker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
|
||||||
balances[maker][order.params.makerToken].minus(fillMakerTokenAmount),
|
balances[maker][signedOrder.makerTokenAddress].minus(fillMakerTokenAmount),
|
||||||
);
|
);
|
||||||
expect(newBalances[maker][order.params.takerToken]).to.be.bignumber.equal(
|
expect(newBalances[maker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
|
||||||
balances[maker][order.params.takerToken].add(fillTakerTokenAmount),
|
balances[maker][signedOrder.takerTokenAddress].add(fillTakerTokenAmount),
|
||||||
);
|
);
|
||||||
expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(
|
expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(
|
||||||
balances[maker][zrx.address].minus(paidMakerFee),
|
balances[maker][zrx.address].minus(paidMakerFee),
|
||||||
);
|
);
|
||||||
expect(newBalances[taker][order.params.takerToken]).to.be.bignumber.equal(
|
expect(newBalances[taker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
|
||||||
balances[taker][order.params.takerToken].minus(fillTakerTokenAmount),
|
balances[taker][signedOrder.takerTokenAddress].minus(fillTakerTokenAmount),
|
||||||
);
|
);
|
||||||
expect(newBalances[taker][order.params.makerToken]).to.be.bignumber.equal(
|
expect(newBalances[taker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
|
||||||
balances[taker][order.params.makerToken].add(fillMakerTokenAmount),
|
balances[taker][signedOrder.makerTokenAddress].add(fillMakerTokenAmount),
|
||||||
);
|
);
|
||||||
expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(
|
expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(
|
||||||
balances[taker][zrx.address].minus(paidTakerFee),
|
balances[taker][zrx.address].minus(paidTakerFee),
|
||||||
@@ -282,47 +289,49 @@ describe('Exchange', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should transfer the correct amounts when makerTokenAmount < takerTokenAmount', async () => {
|
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),
|
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
|
||||||
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
|
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
|
||||||
});
|
});
|
||||||
|
|
||||||
const filledTakerTokenAmountBefore = await zeroEx.exchange.getFilledTakerAmountAsync(order.params
|
const filledTakerTokenAmountBefore = await zeroEx.exchange.getFilledTakerAmountAsync(
|
||||||
.orderHashHex as string);
|
ZeroEx.getOrderHashHex(signedOrder),
|
||||||
|
);
|
||||||
expect(filledTakerTokenAmountBefore).to.be.bignumber.equal(0);
|
expect(filledTakerTokenAmountBefore).to.be.bignumber.equal(0);
|
||||||
|
|
||||||
const fillTakerTokenAmount = order.params.takerTokenAmount.div(2);
|
const fillTakerTokenAmount = signedOrder.takerTokenAmount.div(2);
|
||||||
await exWrapper.fillOrderAsync(order, taker, { fillTakerTokenAmount });
|
await exWrapper.fillOrderAsync(signedOrder, taker, { fillTakerTokenAmount });
|
||||||
|
|
||||||
const filledTakerTokenAmountAfter = await zeroEx.exchange.getFilledTakerAmountAsync(order.params
|
const filledTakerTokenAmountAfter = await zeroEx.exchange.getFilledTakerAmountAsync(
|
||||||
.orderHashHex as string);
|
ZeroEx.getOrderHashHex(signedOrder),
|
||||||
|
);
|
||||||
expect(filledTakerTokenAmountAfter).to.be.bignumber.equal(fillTakerTokenAmount);
|
expect(filledTakerTokenAmountAfter).to.be.bignumber.equal(fillTakerTokenAmount);
|
||||||
|
|
||||||
const newBalances = await dmyBalances.getAsync();
|
const newBalances = await dmyBalances.getAsync();
|
||||||
|
|
||||||
const fillMakerTokenAmount = fillTakerTokenAmount
|
const fillMakerTokenAmount = fillTakerTokenAmount
|
||||||
.times(order.params.makerTokenAmount)
|
.times(signedOrder.makerTokenAmount)
|
||||||
.dividedToIntegerBy(order.params.takerTokenAmount);
|
.dividedToIntegerBy(signedOrder.takerTokenAmount);
|
||||||
const paidMakerFee = order.params.makerFee
|
const paidMakerFee = signedOrder.makerFee
|
||||||
.times(fillMakerTokenAmount)
|
.times(fillMakerTokenAmount)
|
||||||
.dividedToIntegerBy(order.params.makerTokenAmount);
|
.dividedToIntegerBy(signedOrder.makerTokenAmount);
|
||||||
const paidTakerFee = order.params.takerFee
|
const paidTakerFee = signedOrder.takerFee
|
||||||
.times(fillMakerTokenAmount)
|
.times(fillMakerTokenAmount)
|
||||||
.dividedToIntegerBy(order.params.makerTokenAmount);
|
.dividedToIntegerBy(signedOrder.makerTokenAmount);
|
||||||
expect(newBalances[maker][order.params.makerToken]).to.be.bignumber.equal(
|
expect(newBalances[maker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
|
||||||
balances[maker][order.params.makerToken].minus(fillMakerTokenAmount),
|
balances[maker][signedOrder.makerTokenAddress].minus(fillMakerTokenAmount),
|
||||||
);
|
);
|
||||||
expect(newBalances[maker][order.params.takerToken]).to.be.bignumber.equal(
|
expect(newBalances[maker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
|
||||||
balances[maker][order.params.takerToken].add(fillTakerTokenAmount),
|
balances[maker][signedOrder.takerTokenAddress].add(fillTakerTokenAmount),
|
||||||
);
|
);
|
||||||
expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(
|
expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(
|
||||||
balances[maker][zrx.address].minus(paidMakerFee),
|
balances[maker][zrx.address].minus(paidMakerFee),
|
||||||
);
|
);
|
||||||
expect(newBalances[taker][order.params.takerToken]).to.be.bignumber.equal(
|
expect(newBalances[taker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
|
||||||
balances[taker][order.params.takerToken].minus(fillTakerTokenAmount),
|
balances[taker][signedOrder.takerTokenAddress].minus(fillTakerTokenAmount),
|
||||||
);
|
);
|
||||||
expect(newBalances[taker][order.params.makerToken]).to.be.bignumber.equal(
|
expect(newBalances[taker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
|
||||||
balances[taker][order.params.makerToken].add(fillMakerTokenAmount),
|
balances[taker][signedOrder.makerTokenAddress].add(fillMakerTokenAmount),
|
||||||
);
|
);
|
||||||
expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(
|
expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(
|
||||||
balances[taker][zrx.address].minus(paidTakerFee),
|
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 () => {
|
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,
|
taker,
|
||||||
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
|
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
|
||||||
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
|
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
|
||||||
});
|
});
|
||||||
|
|
||||||
const filledTakerTokenAmountBefore = await zeroEx.exchange.getFilledTakerAmountAsync(order.params
|
const filledTakerTokenAmountBefore = await zeroEx.exchange.getFilledTakerAmountAsync(
|
||||||
.orderHashHex as string);
|
ZeroEx.getOrderHashHex(signedOrder),
|
||||||
|
);
|
||||||
expect(filledTakerTokenAmountBefore).to.be.bignumber.equal(0);
|
expect(filledTakerTokenAmountBefore).to.be.bignumber.equal(0);
|
||||||
|
|
||||||
const fillTakerTokenAmount = order.params.takerTokenAmount.div(2);
|
const fillTakerTokenAmount = signedOrder.takerTokenAmount.div(2);
|
||||||
await exWrapper.fillOrderAsync(order, taker, { fillTakerTokenAmount });
|
await exWrapper.fillOrderAsync(signedOrder, taker, { fillTakerTokenAmount });
|
||||||
|
|
||||||
const filledTakerTokenAmountAfter = await zeroEx.exchange.getFilledTakerAmountAsync(order.params
|
const filledTakerTokenAmountAfter = await zeroEx.exchange.getFilledTakerAmountAsync(
|
||||||
.orderHashHex as string);
|
ZeroEx.getOrderHashHex(signedOrder),
|
||||||
|
);
|
||||||
const expectedFillAmountTAfter = fillTakerTokenAmount.add(filledTakerTokenAmountBefore);
|
const expectedFillAmountTAfter = fillTakerTokenAmount.add(filledTakerTokenAmountBefore);
|
||||||
expect(filledTakerTokenAmountAfter).to.be.bignumber.equal(expectedFillAmountTAfter);
|
expect(filledTakerTokenAmountAfter).to.be.bignumber.equal(expectedFillAmountTAfter);
|
||||||
|
|
||||||
const newBalances = await dmyBalances.getAsync();
|
const newBalances = await dmyBalances.getAsync();
|
||||||
|
|
||||||
const fillMakerTokenAmount = fillTakerTokenAmount
|
const fillMakerTokenAmount = fillTakerTokenAmount
|
||||||
.times(order.params.makerTokenAmount)
|
.times(signedOrder.makerTokenAmount)
|
||||||
.dividedToIntegerBy(order.params.takerTokenAmount);
|
.dividedToIntegerBy(signedOrder.takerTokenAmount);
|
||||||
const paidMakerFee = order.params.makerFee
|
const paidMakerFee = signedOrder.makerFee
|
||||||
.times(fillMakerTokenAmount)
|
.times(fillMakerTokenAmount)
|
||||||
.dividedToIntegerBy(order.params.makerTokenAmount);
|
.dividedToIntegerBy(signedOrder.makerTokenAmount);
|
||||||
const paidTakerFee = order.params.takerFee
|
const paidTakerFee = signedOrder.takerFee
|
||||||
.times(fillMakerTokenAmount)
|
.times(fillMakerTokenAmount)
|
||||||
.dividedToIntegerBy(order.params.makerTokenAmount);
|
.dividedToIntegerBy(signedOrder.makerTokenAmount);
|
||||||
expect(newBalances[maker][order.params.makerToken]).to.be.bignumber.equal(
|
expect(newBalances[maker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
|
||||||
balances[maker][order.params.makerToken].minus(fillMakerTokenAmount),
|
balances[maker][signedOrder.makerTokenAddress].minus(fillMakerTokenAmount),
|
||||||
);
|
);
|
||||||
expect(newBalances[maker][order.params.takerToken]).to.be.bignumber.equal(
|
expect(newBalances[maker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
|
||||||
balances[maker][order.params.takerToken].add(fillTakerTokenAmount),
|
balances[maker][signedOrder.takerTokenAddress].add(fillTakerTokenAmount),
|
||||||
);
|
);
|
||||||
expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(
|
expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(
|
||||||
balances[maker][zrx.address].minus(paidMakerFee),
|
balances[maker][zrx.address].minus(paidMakerFee),
|
||||||
);
|
);
|
||||||
expect(newBalances[taker][order.params.takerToken]).to.be.bignumber.equal(
|
expect(newBalances[taker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
|
||||||
balances[taker][order.params.takerToken].minus(fillTakerTokenAmount),
|
balances[taker][signedOrder.takerTokenAddress].minus(fillTakerTokenAmount),
|
||||||
);
|
);
|
||||||
expect(newBalances[taker][order.params.makerToken]).to.be.bignumber.equal(
|
expect(newBalances[taker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
|
||||||
balances[taker][order.params.makerToken].add(fillMakerTokenAmount),
|
balances[taker][signedOrder.makerTokenAddress].add(fillMakerTokenAmount),
|
||||||
);
|
);
|
||||||
expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(
|
expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(
|
||||||
balances[taker][zrx.address].minus(paidTakerFee),
|
balances[taker][zrx.address].minus(paidTakerFee),
|
||||||
@@ -386,141 +397,141 @@ describe('Exchange', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should fill remaining value if fillTakerTokenAmount > remaining takerTokenAmount', async () => {
|
it('should fill remaining value if fillTakerTokenAmount > remaining takerTokenAmount', async () => {
|
||||||
const fillTakerTokenAmount = order.params.takerTokenAmount.div(2);
|
const fillTakerTokenAmount = signedOrder.takerTokenAmount.div(2);
|
||||||
await exWrapper.fillOrderAsync(order, taker, { fillTakerTokenAmount });
|
await exWrapper.fillOrderAsync(signedOrder, taker, { fillTakerTokenAmount });
|
||||||
|
|
||||||
const res = await exWrapper.fillOrderAsync(order, taker, {
|
const res = await exWrapper.fillOrderAsync(signedOrder, taker, {
|
||||||
fillTakerTokenAmount: order.params.takerTokenAmount,
|
fillTakerTokenAmount: signedOrder.takerTokenAmount,
|
||||||
});
|
});
|
||||||
const log = res.logs[0] as LogWithDecodedArgs<LogFillContractEventArgs>;
|
const log = res.logs[0] as LogWithDecodedArgs<LogFillContractEventArgs>;
|
||||||
expect(log.args.filledTakerTokenAmount).to.be.bignumber.equal(
|
expect(log.args.filledTakerTokenAmount).to.be.bignumber.equal(
|
||||||
order.params.takerTokenAmount.minus(fillTakerTokenAmount),
|
signedOrder.takerTokenAmount.minus(fillTakerTokenAmount),
|
||||||
);
|
);
|
||||||
const newBalances = await dmyBalances.getAsync();
|
const newBalances = await dmyBalances.getAsync();
|
||||||
|
|
||||||
expect(newBalances[maker][order.params.makerToken]).to.be.bignumber.equal(
|
expect(newBalances[maker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
|
||||||
balances[maker][order.params.makerToken].minus(order.params.makerTokenAmount),
|
balances[maker][signedOrder.makerTokenAddress].minus(signedOrder.makerTokenAmount),
|
||||||
);
|
);
|
||||||
expect(newBalances[maker][order.params.takerToken]).to.be.bignumber.equal(
|
expect(newBalances[maker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
|
||||||
balances[maker][order.params.takerToken].add(order.params.takerTokenAmount),
|
balances[maker][signedOrder.takerTokenAddress].add(signedOrder.takerTokenAmount),
|
||||||
);
|
);
|
||||||
expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(
|
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(
|
expect(newBalances[taker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
|
||||||
balances[taker][order.params.takerToken].minus(order.params.takerTokenAmount),
|
balances[taker][signedOrder.takerTokenAddress].minus(signedOrder.takerTokenAmount),
|
||||||
);
|
);
|
||||||
expect(newBalances[taker][order.params.makerToken]).to.be.bignumber.equal(
|
expect(newBalances[taker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
|
||||||
balances[taker][order.params.makerToken].add(order.params.makerTokenAmount),
|
balances[taker][signedOrder.makerTokenAddress].add(signedOrder.makerTokenAmount),
|
||||||
);
|
);
|
||||||
expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(
|
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(
|
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 () => {
|
it('should log 1 event with the correct arguments when order has a feeRecipient', async () => {
|
||||||
const divisor = 2;
|
const divisor = 2;
|
||||||
const res = await exWrapper.fillOrderAsync(order, taker, {
|
const res = await exWrapper.fillOrderAsync(signedOrder, taker, {
|
||||||
fillTakerTokenAmount: order.params.takerTokenAmount.div(divisor),
|
fillTakerTokenAmount: signedOrder.takerTokenAmount.div(divisor),
|
||||||
});
|
});
|
||||||
expect(res.logs).to.have.length(1);
|
expect(res.logs).to.have.length(1);
|
||||||
|
|
||||||
const logArgs = (res.logs[0] as LogWithDecodedArgs<LogFillContractEventArgs>).args;
|
const logArgs = (res.logs[0] as LogWithDecodedArgs<LogFillContractEventArgs>).args;
|
||||||
const expectedFilledMakerTokenAmount = order.params.makerTokenAmount.div(divisor);
|
const expectedFilledMakerTokenAmount = signedOrder.makerTokenAmount.div(divisor);
|
||||||
const expectedFilledTakerTokenAmount = order.params.takerTokenAmount.div(divisor);
|
const expectedFilledTakerTokenAmount = signedOrder.takerTokenAmount.div(divisor);
|
||||||
const expectedFeeMPaid = order.params.makerFee.div(divisor);
|
const expectedFeeMPaid = signedOrder.makerFee.div(divisor);
|
||||||
const expectedFeeTPaid = order.params.takerFee.div(divisor);
|
const expectedFeeTPaid = signedOrder.takerFee.div(divisor);
|
||||||
const tokensHashBuff = crypto.solSHA3([order.params.makerToken, order.params.takerToken]);
|
const tokensHashBuff = crypto.solSHA3([signedOrder.makerTokenAddress, signedOrder.takerTokenAddress]);
|
||||||
const expectedTokens = ethUtil.bufferToHex(tokensHashBuff);
|
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(taker).to.be.equal(logArgs.taker);
|
||||||
expect(order.params.feeRecipient).to.be.equal(logArgs.feeRecipient);
|
expect(signedOrder.feeRecipient).to.be.equal(logArgs.feeRecipient);
|
||||||
expect(order.params.makerToken).to.be.equal(logArgs.makerToken);
|
expect(signedOrder.makerTokenAddress).to.be.equal(logArgs.makerToken);
|
||||||
expect(order.params.takerToken).to.be.equal(logArgs.takerToken);
|
expect(signedOrder.takerTokenAddress).to.be.equal(logArgs.takerToken);
|
||||||
expect(expectedFilledMakerTokenAmount).to.be.bignumber.equal(logArgs.filledMakerTokenAmount);
|
expect(expectedFilledMakerTokenAmount).to.be.bignumber.equal(logArgs.filledMakerTokenAmount);
|
||||||
expect(expectedFilledTakerTokenAmount).to.be.bignumber.equal(logArgs.filledTakerTokenAmount);
|
expect(expectedFilledTakerTokenAmount).to.be.bignumber.equal(logArgs.filledTakerTokenAmount);
|
||||||
expect(expectedFeeMPaid).to.be.bignumber.equal(logArgs.paidMakerFee);
|
expect(expectedFeeMPaid).to.be.bignumber.equal(logArgs.paidMakerFee);
|
||||||
expect(expectedFeeTPaid).to.be.bignumber.equal(logArgs.paidTakerFee);
|
expect(expectedFeeTPaid).to.be.bignumber.equal(logArgs.paidTakerFee);
|
||||||
expect(expectedTokens).to.be.equal(logArgs.tokens);
|
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 () => {
|
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,
|
feeRecipient: ZeroEx.NULL_ADDRESS,
|
||||||
});
|
});
|
||||||
const divisor = 2;
|
const divisor = 2;
|
||||||
const res = await exWrapper.fillOrderAsync(order, taker, {
|
const res = await exWrapper.fillOrderAsync(signedOrder, taker, {
|
||||||
fillTakerTokenAmount: order.params.takerTokenAmount.div(divisor),
|
fillTakerTokenAmount: signedOrder.takerTokenAmount.div(divisor),
|
||||||
});
|
});
|
||||||
expect(res.logs).to.have.length(1);
|
expect(res.logs).to.have.length(1);
|
||||||
|
|
||||||
const logArgs = (res.logs[0] as LogWithDecodedArgs<LogFillContractEventArgs>).args;
|
const logArgs = (res.logs[0] as LogWithDecodedArgs<LogFillContractEventArgs>).args;
|
||||||
const expectedFilledMakerTokenAmount = order.params.makerTokenAmount.div(divisor);
|
const expectedFilledMakerTokenAmount = signedOrder.makerTokenAmount.div(divisor);
|
||||||
const expectedFilledTakerTokenAmount = order.params.takerTokenAmount.div(divisor);
|
const expectedFilledTakerTokenAmount = signedOrder.takerTokenAmount.div(divisor);
|
||||||
const expectedFeeMPaid = new BigNumber(0);
|
const expectedFeeMPaid = new BigNumber(0);
|
||||||
const expectedFeeTPaid = 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);
|
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(taker).to.be.equal(logArgs.taker);
|
||||||
expect(order.params.feeRecipient).to.be.equal(logArgs.feeRecipient);
|
expect(signedOrder.feeRecipient).to.be.equal(logArgs.feeRecipient);
|
||||||
expect(order.params.makerToken).to.be.equal(logArgs.makerToken);
|
expect(signedOrder.makerTokenAddress).to.be.equal(logArgs.makerToken);
|
||||||
expect(order.params.takerToken).to.be.equal(logArgs.takerToken);
|
expect(signedOrder.takerTokenAddress).to.be.equal(logArgs.takerToken);
|
||||||
expect(expectedFilledMakerTokenAmount).to.be.bignumber.equal(logArgs.filledMakerTokenAmount);
|
expect(expectedFilledMakerTokenAmount).to.be.bignumber.equal(logArgs.filledMakerTokenAmount);
|
||||||
expect(expectedFilledTakerTokenAmount).to.be.bignumber.equal(logArgs.filledTakerTokenAmount);
|
expect(expectedFilledTakerTokenAmount).to.be.bignumber.equal(logArgs.filledTakerTokenAmount);
|
||||||
expect(expectedFeeMPaid).to.be.bignumber.equal(logArgs.paidMakerFee);
|
expect(expectedFeeMPaid).to.be.bignumber.equal(logArgs.paidMakerFee);
|
||||||
expect(expectedFeeTPaid).to.be.bignumber.equal(logArgs.paidTakerFee);
|
expect(expectedFeeTPaid).to.be.bignumber.equal(logArgs.paidTakerFee);
|
||||||
expect(expectedTokens).to.be.equal(logArgs.tokens);
|
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 () => {
|
it('should throw when taker is specified and order is claimed by other', async () => {
|
||||||
order = await orderFactory.newSignedOrderAsync({
|
signedOrder = await orderFactory.newSignedOrderAsync({
|
||||||
taker: feeRecipient,
|
taker: feeRecipient,
|
||||||
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
|
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
|
||||||
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 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 () => {
|
it('should throw if signature is invalid', async () => {
|
||||||
order = await orderFactory.newSignedOrderAsync({
|
signedOrder = await orderFactory.newSignedOrderAsync({
|
||||||
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(10), 18),
|
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(10), 18),
|
||||||
});
|
});
|
||||||
|
|
||||||
order.params.r = ethUtil.bufferToHex(ethUtil.sha3('invalidR'));
|
signedOrder.ecSignature.r = ethUtil.bufferToHex(ethUtil.sha3('invalidR'));
|
||||||
order.params.s = ethUtil.bufferToHex(ethUtil.sha3('invalidS'));
|
signedOrder.ecSignature.s = ethUtil.bufferToHex(ethUtil.sha3('invalidS'));
|
||||||
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 makerTokenAmount is 0', async () => {
|
it('should throw if makerTokenAmount is 0', async () => {
|
||||||
order = await orderFactory.newSignedOrderAsync({
|
signedOrder = await orderFactory.newSignedOrderAsync({
|
||||||
makerTokenAmount: new BigNumber(0),
|
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 () => {
|
it('should throw if takerTokenAmount is 0', async () => {
|
||||||
order = await orderFactory.newSignedOrderAsync({
|
signedOrder = await orderFactory.newSignedOrderAsync({
|
||||||
takerTokenAmount: new BigNumber(0),
|
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 () => {
|
it('should throw if fillTakerTokenAmount is 0', async () => {
|
||||||
order = await orderFactory.newSignedOrderAsync();
|
signedOrder = await orderFactory.newSignedOrderAsync();
|
||||||
|
|
||||||
return expect(
|
return expect(
|
||||||
exWrapper.fillOrderAsync(order, taker, {
|
exWrapper.fillOrderAsync(signedOrder, taker, {
|
||||||
fillTakerTokenAmount: new BigNumber(0),
|
fillTakerTokenAmount: new BigNumber(0),
|
||||||
}),
|
}),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
).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 \
|
it('should not change balances if maker balances are too low to fill order and \
|
||||||
shouldThrowOnInsufficientBalanceOrAllowance = false', async () => {
|
shouldThrowOnInsufficientBalanceOrAllowance = false', async () => {
|
||||||
order = await orderFactory.newSignedOrderAsync({
|
signedOrder = await orderFactory.newSignedOrderAsync({
|
||||||
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18),
|
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18),
|
||||||
});
|
});
|
||||||
|
|
||||||
await exWrapper.fillOrderAsync(order, taker);
|
await exWrapper.fillOrderAsync(signedOrder, taker);
|
||||||
const newBalances = await dmyBalances.getAsync();
|
const newBalances = await dmyBalances.getAsync();
|
||||||
expect(newBalances).to.be.deep.equal(balances);
|
expect(newBalances).to.be.deep.equal(balances);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw if maker balances are too low to fill order and \
|
it('should throw if maker balances are too low to fill order and \
|
||||||
shouldThrowOnInsufficientBalanceOrAllowance = true', async () => {
|
shouldThrowOnInsufficientBalanceOrAllowance = true', async () => {
|
||||||
order = await orderFactory.newSignedOrderAsync({
|
signedOrder = await orderFactory.newSignedOrderAsync({
|
||||||
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18),
|
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18),
|
||||||
});
|
});
|
||||||
|
|
||||||
return expect(
|
return expect(
|
||||||
exWrapper.fillOrderAsync(order, taker, {
|
exWrapper.fillOrderAsync(signedOrder, taker, {
|
||||||
shouldThrowOnInsufficientBalanceOrAllowance: true,
|
shouldThrowOnInsufficientBalanceOrAllowance: true,
|
||||||
}),
|
}),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
).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 \
|
it('should not change balances if taker balances are too low to fill order and \
|
||||||
shouldThrowOnInsufficientBalanceOrAllowance = false', async () => {
|
shouldThrowOnInsufficientBalanceOrAllowance = false', async () => {
|
||||||
order = await orderFactory.newSignedOrderAsync({
|
signedOrder = await orderFactory.newSignedOrderAsync({
|
||||||
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18),
|
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18),
|
||||||
});
|
});
|
||||||
|
|
||||||
await exWrapper.fillOrderAsync(order, taker);
|
await exWrapper.fillOrderAsync(signedOrder, taker);
|
||||||
const newBalances = await dmyBalances.getAsync();
|
const newBalances = await dmyBalances.getAsync();
|
||||||
expect(newBalances).to.be.deep.equal(balances);
|
expect(newBalances).to.be.deep.equal(balances);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw if taker balances are too low to fill order and \
|
it('should throw if taker balances are too low to fill order and \
|
||||||
shouldThrowOnInsufficientBalanceOrAllowance = true', async () => {
|
shouldThrowOnInsufficientBalanceOrAllowance = true', async () => {
|
||||||
order = await orderFactory.newSignedOrderAsync({
|
signedOrder = await orderFactory.newSignedOrderAsync({
|
||||||
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18),
|
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18),
|
||||||
});
|
});
|
||||||
|
|
||||||
return expect(
|
return expect(
|
||||||
exWrapper.fillOrderAsync(order, taker, {
|
exWrapper.fillOrderAsync(signedOrder, taker, {
|
||||||
shouldThrowOnInsufficientBalanceOrAllowance: true,
|
shouldThrowOnInsufficientBalanceOrAllowance: true,
|
||||||
}),
|
}),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
).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 \
|
it('should not change balances if maker allowances are too low to fill order and \
|
||||||
shouldThrowOnInsufficientBalanceOrAllowance = false', async () => {
|
shouldThrowOnInsufficientBalanceOrAllowance = false', async () => {
|
||||||
await rep.approve.sendTransactionAsync(tokenTransferProxy.address, new BigNumber(0), { from: maker });
|
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, {
|
await rep.approve.sendTransactionAsync(tokenTransferProxy.address, INITIAL_ALLOWANCE, {
|
||||||
from: maker,
|
from: maker,
|
||||||
});
|
});
|
||||||
@@ -590,7 +601,7 @@ describe('Exchange', () => {
|
|||||||
shouldThrowOnInsufficientBalanceOrAllowance = true', async () => {
|
shouldThrowOnInsufficientBalanceOrAllowance = true', async () => {
|
||||||
await rep.approve.sendTransactionAsync(tokenTransferProxy.address, new BigNumber(0), { from: maker });
|
await rep.approve.sendTransactionAsync(tokenTransferProxy.address, new BigNumber(0), { from: maker });
|
||||||
expect(
|
expect(
|
||||||
exWrapper.fillOrderAsync(order, taker, {
|
exWrapper.fillOrderAsync(signedOrder, taker, {
|
||||||
shouldThrowOnInsufficientBalanceOrAllowance: true,
|
shouldThrowOnInsufficientBalanceOrAllowance: true,
|
||||||
}),
|
}),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
).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 \
|
it('should not change balances if taker allowances are too low to fill order and \
|
||||||
shouldThrowOnInsufficientBalanceOrAllowance = false', async () => {
|
shouldThrowOnInsufficientBalanceOrAllowance = false', async () => {
|
||||||
await dgd.approve.sendTransactionAsync(tokenTransferProxy.address, new BigNumber(0), { from: taker });
|
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, {
|
await dgd.approve.sendTransactionAsync(tokenTransferProxy.address, INITIAL_ALLOWANCE, {
|
||||||
from: taker,
|
from: taker,
|
||||||
});
|
});
|
||||||
@@ -615,7 +626,7 @@ describe('Exchange', () => {
|
|||||||
shouldThrowOnInsufficientBalanceOrAllowance = true', async () => {
|
shouldThrowOnInsufficientBalanceOrAllowance = true', async () => {
|
||||||
await dgd.approve.sendTransactionAsync(tokenTransferProxy.address, new BigNumber(0), { from: taker });
|
await dgd.approve.sendTransactionAsync(tokenTransferProxy.address, new BigNumber(0), { from: taker });
|
||||||
expect(
|
expect(
|
||||||
exWrapper.fillOrderAsync(order, taker, {
|
exWrapper.fillOrderAsync(signedOrder, taker, {
|
||||||
shouldThrowOnInsufficientBalanceOrAllowance: true,
|
shouldThrowOnInsufficientBalanceOrAllowance: true,
|
||||||
}),
|
}),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
).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 () => {
|
and shouldThrowOnInsufficientBalanceOrAllowance = false', async () => {
|
||||||
const makerZRXBalance = new BigNumber(balances[maker][zrx.address]);
|
const makerZRXBalance = new BigNumber(balances[maker][zrx.address]);
|
||||||
order = await orderFactory.newSignedOrderAsync({
|
signedOrder = await orderFactory.newSignedOrderAsync({
|
||||||
makerToken: zrx.address,
|
makerTokenAddress: zrx.address,
|
||||||
makerTokenAmount: makerZRXBalance,
|
makerTokenAmount: makerZRXBalance,
|
||||||
makerFee: new BigNumber(1),
|
makerFee: new BigNumber(1),
|
||||||
});
|
});
|
||||||
await exWrapper.fillOrderAsync(order, taker);
|
await exWrapper.fillOrderAsync(signedOrder, taker);
|
||||||
const newBalances = await dmyBalances.getAsync();
|
const newBalances = await dmyBalances.getAsync();
|
||||||
expect(newBalances).to.be.deep.equal(balances);
|
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 () => {
|
and shouldThrowOnInsufficientBalanceOrAllowance = false', async () => {
|
||||||
const makerZRXAllowance = await zrx.allowance(maker, tokenTransferProxy.address);
|
const makerZRXAllowance = await zrx.allowance(maker, tokenTransferProxy.address);
|
||||||
order = await orderFactory.newSignedOrderAsync({
|
signedOrder = await orderFactory.newSignedOrderAsync({
|
||||||
makerToken: zrx.address,
|
makerTokenAddress: zrx.address,
|
||||||
makerTokenAmount: new BigNumber(makerZRXAllowance),
|
makerTokenAmount: new BigNumber(makerZRXAllowance),
|
||||||
makerFee: new BigNumber(1),
|
makerFee: new BigNumber(1),
|
||||||
});
|
});
|
||||||
await exWrapper.fillOrderAsync(order, taker);
|
await exWrapper.fillOrderAsync(signedOrder, taker);
|
||||||
const newBalances = await dmyBalances.getAsync();
|
const newBalances = await dmyBalances.getAsync();
|
||||||
expect(newBalances).to.be.deep.equal(balances);
|
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 () => {
|
and shouldThrowOnInsufficientBalanceOrAllowance = false', async () => {
|
||||||
const takerZRXBalance = new BigNumber(balances[taker][zrx.address]);
|
const takerZRXBalance = new BigNumber(balances[taker][zrx.address]);
|
||||||
order = await orderFactory.newSignedOrderAsync({
|
signedOrder = await orderFactory.newSignedOrderAsync({
|
||||||
takerToken: zrx.address,
|
takerTokenAddress: zrx.address,
|
||||||
takerTokenAmount: takerZRXBalance,
|
takerTokenAmount: takerZRXBalance,
|
||||||
takerFee: new BigNumber(1),
|
takerFee: new BigNumber(1),
|
||||||
});
|
});
|
||||||
await exWrapper.fillOrderAsync(order, taker);
|
await exWrapper.fillOrderAsync(signedOrder, taker);
|
||||||
const newBalances = await dmyBalances.getAsync();
|
const newBalances = await dmyBalances.getAsync();
|
||||||
expect(newBalances).to.be.deep.equal(balances);
|
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 () => {
|
and shouldThrowOnInsufficientBalanceOrAllowance = false', async () => {
|
||||||
const takerZRXAllowance = await zrx.allowance(taker, tokenTransferProxy.address);
|
const takerZRXAllowance = await zrx.allowance(taker, tokenTransferProxy.address);
|
||||||
order = await orderFactory.newSignedOrderAsync({
|
signedOrder = await orderFactory.newSignedOrderAsync({
|
||||||
takerToken: zrx.address,
|
takerTokenAddress: zrx.address,
|
||||||
takerTokenAmount: new BigNumber(takerZRXAllowance),
|
takerTokenAmount: new BigNumber(takerZRXAllowance),
|
||||||
takerFee: new BigNumber(1),
|
takerFee: new BigNumber(1),
|
||||||
});
|
});
|
||||||
await exWrapper.fillOrderAsync(order, taker);
|
await exWrapper.fillOrderAsync(signedOrder, taker);
|
||||||
const newBalances = await dmyBalances.getAsync();
|
const newBalances = await dmyBalances.getAsync();
|
||||||
expect(newBalances).to.be.deep.equal(balances);
|
expect(newBalances).to.be.deep.equal(balances);
|
||||||
});
|
});
|
||||||
@@ -683,33 +694,33 @@ describe('Exchange', () => {
|
|||||||
from: taker,
|
from: taker,
|
||||||
});
|
});
|
||||||
|
|
||||||
order = await orderFactory.newSignedOrderAsync({
|
signedOrder = await orderFactory.newSignedOrderAsync({
|
||||||
takerToken: maliciousToken.address,
|
takerTokenAddress: maliciousToken.address,
|
||||||
});
|
});
|
||||||
|
|
||||||
return expect(
|
return expect(
|
||||||
exWrapper.fillOrderAsync(order, taker, {
|
exWrapper.fillOrderAsync(signedOrder, taker, {
|
||||||
shouldThrowOnInsufficientBalanceOrAllowance: false,
|
shouldThrowOnInsufficientBalanceOrAllowance: false,
|
||||||
}),
|
}),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
).to.be.rejectedWith(constants.REVERT);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not change balances if an order is expired', async () => {
|
it('should not change balances if an order is expired', async () => {
|
||||||
order = await orderFactory.newSignedOrderAsync({
|
signedOrder = await orderFactory.newSignedOrderAsync({
|
||||||
expirationTimestampInSec: new BigNumber(Math.floor((Date.now() - 10000) / 1000)),
|
expirationUnixTimestampSec: new BigNumber(Math.floor((Date.now() - 10000) / 1000)),
|
||||||
});
|
});
|
||||||
await exWrapper.fillOrderAsync(order, taker);
|
await exWrapper.fillOrderAsync(signedOrder, taker);
|
||||||
|
|
||||||
const newBalances = await dmyBalances.getAsync();
|
const newBalances = await dmyBalances.getAsync();
|
||||||
expect(newBalances).to.be.deep.equal(balances);
|
expect(newBalances).to.be.deep.equal(balances);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should log an error event if an order is expired', async () => {
|
it('should log an error event if an order is expired', async () => {
|
||||||
order = await orderFactory.newSignedOrderAsync({
|
signedOrder = await orderFactory.newSignedOrderAsync({
|
||||||
expirationTimestampInSec: new BigNumber(Math.floor((Date.now() - 10000) / 1000)),
|
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);
|
expect(res.logs).to.have.length(1);
|
||||||
const log = res.logs[0] as LogWithDecodedArgs<LogErrorContractEventArgs>;
|
const log = res.logs[0] as LogWithDecodedArgs<LogErrorContractEventArgs>;
|
||||||
const errCode = log.args.errorId.toNumber();
|
const errCode = log.args.errorId.toNumber();
|
||||||
@@ -717,10 +728,10 @@ describe('Exchange', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should log an error event if no value is filled', async () => {
|
it('should log an error event if no value is filled', async () => {
|
||||||
order = await orderFactory.newSignedOrderAsync({});
|
signedOrder = await orderFactory.newSignedOrderAsync({});
|
||||||
await exWrapper.fillOrderAsync(order, taker);
|
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);
|
expect(res.logs).to.have.length(1);
|
||||||
const log = res.logs[0] as LogWithDecodedArgs<LogErrorContractEventArgs>;
|
const log = res.logs[0] as LogWithDecodedArgs<LogErrorContractEventArgs>;
|
||||||
const errCode = log.args.errorId.toNumber();
|
const errCode = log.args.errorId.toNumber();
|
||||||
@@ -731,43 +742,43 @@ describe('Exchange', () => {
|
|||||||
describe('cancelOrder', () => {
|
describe('cancelOrder', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
balances = await dmyBalances.getAsync();
|
balances = await dmyBalances.getAsync();
|
||||||
order = await orderFactory.newSignedOrderAsync();
|
signedOrder = await orderFactory.newSignedOrderAsync();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw if not sent by maker', async () => {
|
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 () => {
|
it('should throw if makerTokenAmount is 0', async () => {
|
||||||
order = await orderFactory.newSignedOrderAsync({
|
signedOrder = await orderFactory.newSignedOrderAsync({
|
||||||
makerTokenAmount: new BigNumber(0),
|
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 () => {
|
it('should throw if takerTokenAmount is 0', async () => {
|
||||||
order = await orderFactory.newSignedOrderAsync({
|
signedOrder = await orderFactory.newSignedOrderAsync({
|
||||||
takerTokenAmount: new BigNumber(0),
|
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 () => {
|
it('should throw if cancelTakerTokenAmount is 0', async () => {
|
||||||
order = await orderFactory.newSignedOrderAsync();
|
signedOrder = await orderFactory.newSignedOrderAsync();
|
||||||
|
|
||||||
return expect(
|
return expect(
|
||||||
exWrapper.cancelOrderAsync(order, maker, {
|
exWrapper.cancelOrderAsync(signedOrder, maker, {
|
||||||
cancelTakerTokenAmount: new BigNumber(0),
|
cancelTakerTokenAmount: new BigNumber(0),
|
||||||
}),
|
}),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
).to.be.rejectedWith(constants.REVERT);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to cancel a full order', async () => {
|
it('should be able to cancel a full order', async () => {
|
||||||
await exWrapper.cancelOrderAsync(order, maker);
|
await exWrapper.cancelOrderAsync(signedOrder, maker);
|
||||||
await exWrapper.fillOrderAsync(order, taker, {
|
await exWrapper.fillOrderAsync(signedOrder, taker, {
|
||||||
fillTakerTokenAmount: order.params.takerTokenAmount.div(2),
|
fillTakerTokenAmount: signedOrder.takerTokenAmount.div(2),
|
||||||
});
|
});
|
||||||
|
|
||||||
const newBalances = await dmyBalances.getAsync();
|
const newBalances = await dmyBalances.getAsync();
|
||||||
@@ -775,43 +786,43 @@ describe('Exchange', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to cancel part of an order', async () => {
|
it('should be able to cancel part of an order', async () => {
|
||||||
const cancelTakerTokenAmount = order.params.takerTokenAmount.div(2);
|
const cancelTakerTokenAmount = signedOrder.takerTokenAmount.div(2);
|
||||||
await exWrapper.cancelOrderAsync(order, maker, {
|
await exWrapper.cancelOrderAsync(signedOrder, maker, {
|
||||||
cancelTakerTokenAmount,
|
cancelTakerTokenAmount,
|
||||||
});
|
});
|
||||||
|
|
||||||
const res = await exWrapper.fillOrderAsync(order, taker, {
|
const res = await exWrapper.fillOrderAsync(signedOrder, taker, {
|
||||||
fillTakerTokenAmount: order.params.takerTokenAmount,
|
fillTakerTokenAmount: signedOrder.takerTokenAmount,
|
||||||
});
|
});
|
||||||
const log = res.logs[0] as LogWithDecodedArgs<LogFillContractEventArgs>;
|
const log = res.logs[0] as LogWithDecodedArgs<LogFillContractEventArgs>;
|
||||||
expect(log.args.filledTakerTokenAmount).to.be.bignumber.equal(
|
expect(log.args.filledTakerTokenAmount).to.be.bignumber.equal(
|
||||||
order.params.takerTokenAmount.minus(cancelTakerTokenAmount),
|
signedOrder.takerTokenAmount.minus(cancelTakerTokenAmount),
|
||||||
);
|
);
|
||||||
|
|
||||||
const newBalances = await dmyBalances.getAsync();
|
const newBalances = await dmyBalances.getAsync();
|
||||||
const cancelMakerTokenAmount = cancelTakerTokenAmount
|
const cancelMakerTokenAmount = cancelTakerTokenAmount
|
||||||
.times(order.params.makerTokenAmount)
|
.times(signedOrder.makerTokenAmount)
|
||||||
.dividedToIntegerBy(order.params.takerTokenAmount);
|
.dividedToIntegerBy(signedOrder.takerTokenAmount);
|
||||||
const paidMakerFee = order.params.makerFee
|
const paidMakerFee = signedOrder.makerFee
|
||||||
.times(cancelMakerTokenAmount)
|
.times(cancelMakerTokenAmount)
|
||||||
.dividedToIntegerBy(order.params.makerTokenAmount);
|
.dividedToIntegerBy(signedOrder.makerTokenAmount);
|
||||||
const paidTakerFee = order.params.takerFee
|
const paidTakerFee = signedOrder.takerFee
|
||||||
.times(cancelMakerTokenAmount)
|
.times(cancelMakerTokenAmount)
|
||||||
.dividedToIntegerBy(order.params.makerTokenAmount);
|
.dividedToIntegerBy(signedOrder.makerTokenAmount);
|
||||||
expect(newBalances[maker][order.params.makerToken]).to.be.bignumber.equal(
|
expect(newBalances[maker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
|
||||||
balances[maker][order.params.makerToken].minus(cancelMakerTokenAmount),
|
balances[maker][signedOrder.makerTokenAddress].minus(cancelMakerTokenAmount),
|
||||||
);
|
);
|
||||||
expect(newBalances[maker][order.params.takerToken]).to.be.bignumber.equal(
|
expect(newBalances[maker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
|
||||||
balances[maker][order.params.takerToken].add(cancelTakerTokenAmount),
|
balances[maker][signedOrder.takerTokenAddress].add(cancelTakerTokenAmount),
|
||||||
);
|
);
|
||||||
expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(
|
expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(
|
||||||
balances[maker][zrx.address].minus(paidMakerFee),
|
balances[maker][zrx.address].minus(paidMakerFee),
|
||||||
);
|
);
|
||||||
expect(newBalances[taker][order.params.takerToken]).to.be.bignumber.equal(
|
expect(newBalances[taker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
|
||||||
balances[taker][order.params.takerToken].minus(cancelTakerTokenAmount),
|
balances[taker][signedOrder.takerTokenAddress].minus(cancelTakerTokenAmount),
|
||||||
);
|
);
|
||||||
expect(newBalances[taker][order.params.makerToken]).to.be.bignumber.equal(
|
expect(newBalances[taker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
|
||||||
balances[taker][order.params.makerToken].add(cancelMakerTokenAmount),
|
balances[taker][signedOrder.makerTokenAddress].add(cancelMakerTokenAmount),
|
||||||
);
|
);
|
||||||
expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(
|
expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(
|
||||||
balances[taker][zrx.address].minus(paidTakerFee),
|
balances[taker][zrx.address].minus(paidTakerFee),
|
||||||
@@ -823,32 +834,32 @@ describe('Exchange', () => {
|
|||||||
|
|
||||||
it('should log 1 event with correct arguments', async () => {
|
it('should log 1 event with correct arguments', async () => {
|
||||||
const divisor = 2;
|
const divisor = 2;
|
||||||
const res = await exWrapper.cancelOrderAsync(order, maker, {
|
const res = await exWrapper.cancelOrderAsync(signedOrder, maker, {
|
||||||
cancelTakerTokenAmount: order.params.takerTokenAmount.div(divisor),
|
cancelTakerTokenAmount: signedOrder.takerTokenAmount.div(divisor),
|
||||||
});
|
});
|
||||||
expect(res.logs).to.have.length(1);
|
expect(res.logs).to.have.length(1);
|
||||||
|
|
||||||
const log = res.logs[0] as LogWithDecodedArgs<LogCancelContractEventArgs>;
|
const log = res.logs[0] as LogWithDecodedArgs<LogCancelContractEventArgs>;
|
||||||
const logArgs = log.args;
|
const logArgs = log.args;
|
||||||
const expectedCancelledMakerTokenAmount = order.params.makerTokenAmount.div(divisor);
|
const expectedCancelledMakerTokenAmount = signedOrder.makerTokenAmount.div(divisor);
|
||||||
const expectedCancelledTakerTokenAmount = order.params.takerTokenAmount.div(divisor);
|
const expectedCancelledTakerTokenAmount = signedOrder.takerTokenAmount.div(divisor);
|
||||||
const tokensHashBuff = crypto.solSHA3([order.params.makerToken, order.params.takerToken]);
|
const tokensHashBuff = crypto.solSHA3([signedOrder.makerTokenAddress, signedOrder.takerTokenAddress]);
|
||||||
const expectedTokens = ethUtil.bufferToHex(tokensHashBuff);
|
const expectedTokens = ethUtil.bufferToHex(tokensHashBuff);
|
||||||
|
|
||||||
expect(order.params.maker).to.be.equal(logArgs.maker);
|
expect(signedOrder.maker).to.be.equal(logArgs.maker);
|
||||||
expect(order.params.feeRecipient).to.be.equal(logArgs.feeRecipient);
|
expect(signedOrder.feeRecipient).to.be.equal(logArgs.feeRecipient);
|
||||||
expect(order.params.makerToken).to.be.equal(logArgs.makerToken);
|
expect(signedOrder.makerTokenAddress).to.be.equal(logArgs.makerToken);
|
||||||
expect(order.params.takerToken).to.be.equal(logArgs.takerToken);
|
expect(signedOrder.takerTokenAddress).to.be.equal(logArgs.takerToken);
|
||||||
expect(expectedCancelledMakerTokenAmount).to.be.bignumber.equal(logArgs.cancelledMakerTokenAmount);
|
expect(expectedCancelledMakerTokenAmount).to.be.bignumber.equal(logArgs.cancelledMakerTokenAmount);
|
||||||
expect(expectedCancelledTakerTokenAmount).to.be.bignumber.equal(logArgs.cancelledTakerTokenAmount);
|
expect(expectedCancelledTakerTokenAmount).to.be.bignumber.equal(logArgs.cancelledTakerTokenAmount);
|
||||||
expect(expectedTokens).to.be.equal(logArgs.tokens);
|
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 () => {
|
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);
|
expect(res.logs).to.have.length(1);
|
||||||
const log = res.logs[0] as LogWithDecodedArgs<LogErrorContractEventArgs>;
|
const log = res.logs[0] as LogWithDecodedArgs<LogErrorContractEventArgs>;
|
||||||
const errCode = log.args.errorId.toNumber();
|
const errCode = log.args.errorId.toNumber();
|
||||||
@@ -856,11 +867,11 @@ describe('Exchange', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should not log events if order is expired', async () => {
|
it('should not log events if order is expired', async () => {
|
||||||
order = await orderFactory.newSignedOrderAsync({
|
signedOrder = await orderFactory.newSignedOrderAsync({
|
||||||
expirationTimestampInSec: new BigNumber(Math.floor((Date.now() - 10000) / 1000)),
|
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);
|
expect(res.logs).to.have.length(1);
|
||||||
const log = res.logs[0] as LogWithDecodedArgs<LogErrorContractEventArgs>;
|
const log = res.logs[0] as LogWithDecodedArgs<LogErrorContractEventArgs>;
|
||||||
const errCode = log.args.errorId.toNumber();
|
const errCode = log.args.errorId.toNumber();
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { ZeroEx } from '0x.js';
|
import { SignedOrder, ZeroEx } from '0x.js';
|
||||||
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
|
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
|
||||||
import { BigNumber } from '@0xproject/utils';
|
import { BigNumber } from '@0xproject/utils';
|
||||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||||
@@ -8,7 +8,6 @@ import ethUtil = require('ethereumjs-util');
|
|||||||
import { ExchangeContract } from '../../src/contract_wrappers/generated/exchange';
|
import { ExchangeContract } from '../../src/contract_wrappers/generated/exchange';
|
||||||
import { constants } from '../../util/constants';
|
import { constants } from '../../util/constants';
|
||||||
import { ExchangeWrapper } from '../../util/exchange_wrapper';
|
import { ExchangeWrapper } from '../../util/exchange_wrapper';
|
||||||
import { Order } from '../../util/order';
|
|
||||||
import { OrderFactory } from '../../util/order_factory';
|
import { OrderFactory } from '../../util/order_factory';
|
||||||
import { ContractName } from '../../util/types';
|
import { ContractName } from '../../util/types';
|
||||||
import { chaiSetup } from '../utils/chai_setup';
|
import { chaiSetup } from '../utils/chai_setup';
|
||||||
@@ -25,7 +24,7 @@ describe('Exchange', () => {
|
|||||||
let maker: string;
|
let maker: string;
|
||||||
let feeRecipient: string;
|
let feeRecipient: string;
|
||||||
|
|
||||||
let order: Order;
|
let signedOrder: SignedOrder;
|
||||||
let exchangeWrapper: ExchangeWrapper;
|
let exchangeWrapper: ExchangeWrapper;
|
||||||
let orderFactory: OrderFactory;
|
let orderFactory: OrderFactory;
|
||||||
|
|
||||||
@@ -58,8 +57,8 @@ describe('Exchange', () => {
|
|||||||
makerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18),
|
makerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18),
|
||||||
takerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18),
|
takerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18),
|
||||||
};
|
};
|
||||||
orderFactory = new OrderFactory(web3Wrapper, defaultOrderParams);
|
orderFactory = new OrderFactory(zeroEx, defaultOrderParams);
|
||||||
order = await orderFactory.newSignedOrderAsync();
|
signedOrder = await orderFactory.newSignedOrderAsync();
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
@@ -70,28 +69,31 @@ describe('Exchange', () => {
|
|||||||
});
|
});
|
||||||
describe('getOrderHash', () => {
|
describe('getOrderHash', () => {
|
||||||
it('should output the correct orderHash', async () => {
|
it('should output the correct orderHash', async () => {
|
||||||
const orderHashHex = await exchangeWrapper.getOrderHashAsync(order);
|
const orderHashHex = await exchangeWrapper.getOrderHashAsync(signedOrder);
|
||||||
expect(order.params.orderHashHex).to.be.equal(orderHashHex);
|
expect(ZeroEx.getOrderHashHex(signedOrder)).to.be.equal(orderHashHex);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('isValidSignature', () => {
|
describe('isValidSignature', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
order = await orderFactory.newSignedOrderAsync();
|
signedOrder = await orderFactory.newSignedOrderAsync();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return true with a valid signature', async () => {
|
it('should return true with a valid signature', async () => {
|
||||||
const success = await exchangeWrapper.isValidSignatureAsync(order);
|
const success = await exchangeWrapper.isValidSignatureAsync(signedOrder);
|
||||||
const isValidSignature = order.isValidSignature();
|
const orderHashHex = ZeroEx.getOrderHashHex(signedOrder);
|
||||||
|
const isValidSignature = ZeroEx.isValidSignature(orderHashHex, signedOrder.ecSignature, signedOrder.maker);
|
||||||
expect(isValidSignature).to.be.true();
|
expect(isValidSignature).to.be.true();
|
||||||
expect(success).to.be.true();
|
expect(success).to.be.true();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return false with an invalid signature', async () => {
|
it('should return false with an invalid signature', async () => {
|
||||||
order.params.r = ethUtil.bufferToHex(ethUtil.sha3('invalidR'));
|
signedOrder.ecSignature.r = ethUtil.bufferToHex(ethUtil.sha3('invalidR'));
|
||||||
order.params.s = ethUtil.bufferToHex(ethUtil.sha3('invalidS'));
|
signedOrder.ecSignature.s = ethUtil.bufferToHex(ethUtil.sha3('invalidS'));
|
||||||
const success = await exchangeWrapper.isValidSignatureAsync(order);
|
const success = await exchangeWrapper.isValidSignatureAsync(signedOrder);
|
||||||
expect(order.isValidSignature()).to.be.false();
|
const orderHashHex = ZeroEx.getOrderHashHex(signedOrder);
|
||||||
|
const isValidSignature = ZeroEx.isValidSignature(orderHashHex, signedOrder.ecSignature, signedOrder.maker);
|
||||||
|
expect(isValidSignature).to.be.false();
|
||||||
expect(success).to.be.false();
|
expect(success).to.be.false();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { ZeroEx } from '0x.js';
|
import { SignedOrder, ZeroEx } from '0x.js';
|
||||||
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
|
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
|
||||||
import { BigNumber } from '@0xproject/utils';
|
import { BigNumber } from '@0xproject/utils';
|
||||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||||
@@ -13,7 +13,6 @@ import { TokenTransferProxyContract } from '../../src/contract_wrappers/generate
|
|||||||
import { Balances } from '../../util/balances';
|
import { Balances } from '../../util/balances';
|
||||||
import { constants } from '../../util/constants';
|
import { constants } from '../../util/constants';
|
||||||
import { ExchangeWrapper } from '../../util/exchange_wrapper';
|
import { ExchangeWrapper } from '../../util/exchange_wrapper';
|
||||||
import { Order } from '../../util/order';
|
|
||||||
import { OrderFactory } from '../../util/order_factory';
|
import { OrderFactory } from '../../util/order_factory';
|
||||||
import { BalancesByOwner, ContractName } from '../../util/types';
|
import { BalancesByOwner, ContractName } from '../../util/types';
|
||||||
import { chaiSetup } from '../utils/chai_setup';
|
import { chaiSetup } from '../utils/chai_setup';
|
||||||
@@ -76,15 +75,15 @@ describe('Exchange', () => {
|
|||||||
exchangeContractAddress: exchange.address,
|
exchangeContractAddress: exchange.address,
|
||||||
maker,
|
maker,
|
||||||
feeRecipient,
|
feeRecipient,
|
||||||
makerToken: rep.address,
|
makerTokenAddress: rep.address,
|
||||||
takerToken: dgd.address,
|
takerTokenAddress: dgd.address,
|
||||||
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
|
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
|
||||||
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
|
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
|
||||||
makerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18),
|
makerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18),
|
||||||
takerFee: 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]);
|
dmyBalances = new Balances([rep, dgd, zrx], [maker, taker, feeRecipient]);
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
rep.approve.sendTransactionAsync(tokenTransferProxy.address, INIT_ALLOW, { from: maker }),
|
rep.approve.sendTransactionAsync(tokenTransferProxy.address, INIT_ALLOW, { from: maker }),
|
||||||
@@ -113,38 +112,38 @@ describe('Exchange', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should transfer the correct amounts', async () => {
|
it('should transfer the correct amounts', async () => {
|
||||||
const order = await orderFactory.newSignedOrderAsync({
|
const signedOrder = await orderFactory.newSignedOrderAsync({
|
||||||
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
|
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
|
||||||
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
|
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
|
||||||
});
|
});
|
||||||
const fillTakerTokenAmount = order.params.takerTokenAmount.div(2);
|
const fillTakerTokenAmount = signedOrder.takerTokenAmount.div(2);
|
||||||
await exWrapper.fillOrKillOrderAsync(order, taker, {
|
await exWrapper.fillOrKillOrderAsync(signedOrder, taker, {
|
||||||
fillTakerTokenAmount,
|
fillTakerTokenAmount,
|
||||||
});
|
});
|
||||||
|
|
||||||
const newBalances = await dmyBalances.getAsync();
|
const newBalances = await dmyBalances.getAsync();
|
||||||
|
|
||||||
const fillMakerTokenAmount = fillTakerTokenAmount
|
const fillMakerTokenAmount = fillTakerTokenAmount
|
||||||
.times(order.params.makerTokenAmount)
|
.times(signedOrder.makerTokenAmount)
|
||||||
.dividedToIntegerBy(order.params.takerTokenAmount);
|
.dividedToIntegerBy(signedOrder.takerTokenAmount);
|
||||||
const makerFee = order.params.makerFee
|
const makerFee = signedOrder.makerFee
|
||||||
.times(fillMakerTokenAmount)
|
.times(fillMakerTokenAmount)
|
||||||
.dividedToIntegerBy(order.params.makerTokenAmount);
|
.dividedToIntegerBy(signedOrder.makerTokenAmount);
|
||||||
const takerFee = order.params.takerFee
|
const takerFee = signedOrder.takerFee
|
||||||
.times(fillMakerTokenAmount)
|
.times(fillMakerTokenAmount)
|
||||||
.dividedToIntegerBy(order.params.makerTokenAmount);
|
.dividedToIntegerBy(signedOrder.makerTokenAmount);
|
||||||
expect(newBalances[maker][order.params.makerToken]).to.be.bignumber.equal(
|
expect(newBalances[maker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
|
||||||
balances[maker][order.params.makerToken].minus(fillMakerTokenAmount),
|
balances[maker][signedOrder.makerTokenAddress].minus(fillMakerTokenAmount),
|
||||||
);
|
);
|
||||||
expect(newBalances[maker][order.params.takerToken]).to.be.bignumber.equal(
|
expect(newBalances[maker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
|
||||||
balances[maker][order.params.takerToken].add(fillTakerTokenAmount),
|
balances[maker][signedOrder.takerTokenAddress].add(fillTakerTokenAmount),
|
||||||
);
|
);
|
||||||
expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(balances[maker][zrx.address].minus(makerFee));
|
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(
|
expect(newBalances[taker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
|
||||||
balances[taker][order.params.takerToken].minus(fillTakerTokenAmount),
|
balances[taker][signedOrder.takerTokenAddress].minus(fillTakerTokenAmount),
|
||||||
);
|
);
|
||||||
expect(newBalances[taker][order.params.makerToken]).to.be.bignumber.equal(
|
expect(newBalances[taker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
|
||||||
balances[taker][order.params.makerToken].add(fillMakerTokenAmount),
|
balances[taker][signedOrder.makerTokenAddress].add(fillMakerTokenAmount),
|
||||||
);
|
);
|
||||||
expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(balances[taker][zrx.address].minus(takerFee));
|
expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(balances[taker][zrx.address].minus(takerFee));
|
||||||
expect(newBalances[feeRecipient][zrx.address]).to.be.bignumber.equal(
|
expect(newBalances[feeRecipient][zrx.address]).to.be.bignumber.equal(
|
||||||
@@ -152,30 +151,30 @@ describe('Exchange', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw if an order is expired', async () => {
|
it('should throw if an signedOrder is expired', async () => {
|
||||||
const order = await orderFactory.newSignedOrderAsync({
|
const signedOrder = await orderFactory.newSignedOrderAsync({
|
||||||
expirationTimestampInSec: new BigNumber(Math.floor((Date.now() - 10000) / 1000)),
|
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 () => {
|
it('should throw if entire fillTakerTokenAmount not filled', async () => {
|
||||||
const order = await orderFactory.newSignedOrderAsync();
|
const signedOrder = await orderFactory.newSignedOrderAsync();
|
||||||
|
|
||||||
const from = taker;
|
const from = taker;
|
||||||
await exWrapper.fillOrderAsync(order, from, {
|
await exWrapper.fillOrderAsync(signedOrder, from, {
|
||||||
fillTakerTokenAmount: order.params.takerTokenAmount.div(2),
|
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', () => {
|
describe('batch functions', () => {
|
||||||
let orders: Order[];
|
let signedOrders: SignedOrder[];
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
orders = await Promise.all([
|
signedOrders = await Promise.all([
|
||||||
orderFactory.newSignedOrderAsync(),
|
orderFactory.newSignedOrderAsync(),
|
||||||
orderFactory.newSignedOrderAsync(),
|
orderFactory.newSignedOrderAsync(),
|
||||||
orderFactory.newSignedOrderAsync(),
|
orderFactory.newSignedOrderAsync(),
|
||||||
@@ -186,32 +185,32 @@ describe('Exchange', () => {
|
|||||||
describe('batchFillOrders', () => {
|
describe('batchFillOrders', () => {
|
||||||
it('should transfer the correct amounts', async () => {
|
it('should transfer the correct amounts', async () => {
|
||||||
const fillTakerTokenAmounts: BigNumber[] = [];
|
const fillTakerTokenAmounts: BigNumber[] = [];
|
||||||
const makerToken = rep.address;
|
const makerTokenAddress = rep.address;
|
||||||
const takerToken = dgd.address;
|
const takerTokenAddress = dgd.address;
|
||||||
orders.forEach(order => {
|
signedOrders.forEach(signedOrder => {
|
||||||
const fillTakerTokenAmount = order.params.takerTokenAmount.div(2);
|
const fillTakerTokenAmount = signedOrder.takerTokenAmount.div(2);
|
||||||
const fillMakerTokenAmount = fillTakerTokenAmount
|
const fillMakerTokenAmount = fillTakerTokenAmount
|
||||||
.times(order.params.makerTokenAmount)
|
.times(signedOrder.makerTokenAmount)
|
||||||
.dividedToIntegerBy(order.params.takerTokenAmount);
|
.dividedToIntegerBy(signedOrder.takerTokenAmount);
|
||||||
const makerFee = order.params.makerFee
|
const makerFee = signedOrder.makerFee
|
||||||
.times(fillMakerTokenAmount)
|
.times(fillMakerTokenAmount)
|
||||||
.dividedToIntegerBy(order.params.makerTokenAmount);
|
.dividedToIntegerBy(signedOrder.makerTokenAmount);
|
||||||
const takerFee = order.params.takerFee
|
const takerFee = signedOrder.takerFee
|
||||||
.times(fillMakerTokenAmount)
|
.times(fillMakerTokenAmount)
|
||||||
.dividedToIntegerBy(order.params.makerTokenAmount);
|
.dividedToIntegerBy(signedOrder.makerTokenAmount);
|
||||||
fillTakerTokenAmounts.push(fillTakerTokenAmount);
|
fillTakerTokenAmounts.push(fillTakerTokenAmount);
|
||||||
balances[maker][makerToken] = balances[maker][makerToken].minus(fillMakerTokenAmount);
|
balances[maker][makerTokenAddress] = balances[maker][makerTokenAddress].minus(fillMakerTokenAmount);
|
||||||
balances[maker][takerToken] = balances[maker][takerToken].add(fillTakerTokenAmount);
|
balances[maker][takerTokenAddress] = balances[maker][takerTokenAddress].add(fillTakerTokenAmount);
|
||||||
balances[maker][zrx.address] = balances[maker][zrx.address].minus(makerFee);
|
balances[maker][zrx.address] = balances[maker][zrx.address].minus(makerFee);
|
||||||
balances[taker][makerToken] = balances[taker][makerToken].add(fillMakerTokenAmount);
|
balances[taker][makerTokenAddress] = balances[taker][makerTokenAddress].add(fillMakerTokenAmount);
|
||||||
balances[taker][takerToken] = balances[taker][takerToken].minus(fillTakerTokenAmount);
|
balances[taker][takerTokenAddress] = balances[taker][takerTokenAddress].minus(fillTakerTokenAmount);
|
||||||
balances[taker][zrx.address] = balances[taker][zrx.address].minus(takerFee);
|
balances[taker][zrx.address] = balances[taker][zrx.address].minus(takerFee);
|
||||||
balances[feeRecipient][zrx.address] = balances[feeRecipient][zrx.address].add(
|
balances[feeRecipient][zrx.address] = balances[feeRecipient][zrx.address].add(
|
||||||
makerFee.add(takerFee),
|
makerFee.add(takerFee),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
await exWrapper.batchFillOrdersAsync(orders, taker, {
|
await exWrapper.batchFillOrdersAsync(signedOrders, taker, {
|
||||||
fillTakerTokenAmounts,
|
fillTakerTokenAmounts,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -223,32 +222,32 @@ describe('Exchange', () => {
|
|||||||
describe('batchFillOrKillOrders', () => {
|
describe('batchFillOrKillOrders', () => {
|
||||||
it('should transfer the correct amounts', async () => {
|
it('should transfer the correct amounts', async () => {
|
||||||
const fillTakerTokenAmounts: BigNumber[] = [];
|
const fillTakerTokenAmounts: BigNumber[] = [];
|
||||||
const makerToken = rep.address;
|
const makerTokenAddress = rep.address;
|
||||||
const takerToken = dgd.address;
|
const takerTokenAddress = dgd.address;
|
||||||
orders.forEach(order => {
|
signedOrders.forEach(signedOrder => {
|
||||||
const fillTakerTokenAmount = order.params.takerTokenAmount.div(2);
|
const fillTakerTokenAmount = signedOrder.takerTokenAmount.div(2);
|
||||||
const fillMakerTokenAmount = fillTakerTokenAmount
|
const fillMakerTokenAmount = fillTakerTokenAmount
|
||||||
.times(order.params.makerTokenAmount)
|
.times(signedOrder.makerTokenAmount)
|
||||||
.dividedToIntegerBy(order.params.takerTokenAmount);
|
.dividedToIntegerBy(signedOrder.takerTokenAmount);
|
||||||
const makerFee = order.params.makerFee
|
const makerFee = signedOrder.makerFee
|
||||||
.times(fillMakerTokenAmount)
|
.times(fillMakerTokenAmount)
|
||||||
.dividedToIntegerBy(order.params.makerTokenAmount);
|
.dividedToIntegerBy(signedOrder.makerTokenAmount);
|
||||||
const takerFee = order.params.takerFee
|
const takerFee = signedOrder.takerFee
|
||||||
.times(fillMakerTokenAmount)
|
.times(fillMakerTokenAmount)
|
||||||
.dividedToIntegerBy(order.params.makerTokenAmount);
|
.dividedToIntegerBy(signedOrder.makerTokenAmount);
|
||||||
fillTakerTokenAmounts.push(fillTakerTokenAmount);
|
fillTakerTokenAmounts.push(fillTakerTokenAmount);
|
||||||
balances[maker][makerToken] = balances[maker][makerToken].minus(fillMakerTokenAmount);
|
balances[maker][makerTokenAddress] = balances[maker][makerTokenAddress].minus(fillMakerTokenAmount);
|
||||||
balances[maker][takerToken] = balances[maker][takerToken].add(fillTakerTokenAmount);
|
balances[maker][takerTokenAddress] = balances[maker][takerTokenAddress].add(fillTakerTokenAmount);
|
||||||
balances[maker][zrx.address] = balances[maker][zrx.address].minus(makerFee);
|
balances[maker][zrx.address] = balances[maker][zrx.address].minus(makerFee);
|
||||||
balances[taker][makerToken] = balances[taker][makerToken].add(fillMakerTokenAmount);
|
balances[taker][makerTokenAddress] = balances[taker][makerTokenAddress].add(fillMakerTokenAmount);
|
||||||
balances[taker][takerToken] = balances[taker][takerToken].minus(fillTakerTokenAmount);
|
balances[taker][takerTokenAddress] = balances[taker][takerTokenAddress].minus(fillTakerTokenAmount);
|
||||||
balances[taker][zrx.address] = balances[taker][zrx.address].minus(takerFee);
|
balances[taker][zrx.address] = balances[taker][zrx.address].minus(takerFee);
|
||||||
balances[feeRecipient][zrx.address] = balances[feeRecipient][zrx.address].add(
|
balances[feeRecipient][zrx.address] = balances[feeRecipient][zrx.address].add(
|
||||||
makerFee.add(takerFee),
|
makerFee.add(takerFee),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
await exWrapper.batchFillOrKillOrdersAsync(orders, taker, {
|
await exWrapper.batchFillOrKillOrdersAsync(signedOrders, taker, {
|
||||||
fillTakerTokenAmounts,
|
fillTakerTokenAmounts,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -256,17 +255,17 @@ describe('Exchange', () => {
|
|||||||
expect(newBalances).to.be.deep.equal(balances);
|
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[] = [];
|
const fillTakerTokenAmounts: BigNumber[] = [];
|
||||||
orders.forEach(order => {
|
signedOrders.forEach(signedOrder => {
|
||||||
const fillTakerTokenAmount = order.params.takerTokenAmount.div(2);
|
const fillTakerTokenAmount = signedOrder.takerTokenAmount.div(2);
|
||||||
fillTakerTokenAmounts.push(fillTakerTokenAmount);
|
fillTakerTokenAmounts.push(fillTakerTokenAmount);
|
||||||
});
|
});
|
||||||
|
|
||||||
await exWrapper.fillOrKillOrderAsync(orders[0], taker);
|
await exWrapper.fillOrKillOrderAsync(signedOrders[0], taker);
|
||||||
|
|
||||||
return expect(
|
return expect(
|
||||||
exWrapper.batchFillOrKillOrdersAsync(orders, taker, {
|
exWrapper.batchFillOrKillOrdersAsync(signedOrders, taker, {
|
||||||
fillTakerTokenAmounts,
|
fillTakerTokenAmounts,
|
||||||
}),
|
}),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
).to.be.rejectedWith(constants.REVERT);
|
||||||
@@ -275,34 +274,34 @@ describe('Exchange', () => {
|
|||||||
|
|
||||||
describe('fillOrdersUpTo', () => {
|
describe('fillOrdersUpTo', () => {
|
||||||
it('should stop when the entire fillTakerTokenAmount is filled', async () => {
|
it('should stop when the entire fillTakerTokenAmount is filled', async () => {
|
||||||
const fillTakerTokenAmount = orders[0].params.takerTokenAmount.plus(
|
const fillTakerTokenAmount = signedOrders[0].takerTokenAmount.plus(
|
||||||
orders[1].params.takerTokenAmount.div(2),
|
signedOrders[1].takerTokenAmount.div(2),
|
||||||
);
|
);
|
||||||
await exWrapper.fillOrdersUpToAsync(orders, taker, {
|
await exWrapper.fillOrdersUpToAsync(signedOrders, taker, {
|
||||||
fillTakerTokenAmount,
|
fillTakerTokenAmount,
|
||||||
});
|
});
|
||||||
|
|
||||||
const newBalances = await dmyBalances.getAsync();
|
const newBalances = await dmyBalances.getAsync();
|
||||||
|
|
||||||
const fillMakerTokenAmount = orders[0].params.makerTokenAmount.add(
|
const fillMakerTokenAmount = signedOrders[0].makerTokenAmount.add(
|
||||||
orders[1].params.makerTokenAmount.dividedToIntegerBy(2),
|
signedOrders[1].makerTokenAmount.dividedToIntegerBy(2),
|
||||||
);
|
);
|
||||||
const makerFee = orders[0].params.makerFee.add(orders[1].params.makerFee.dividedToIntegerBy(2));
|
const makerFee = signedOrders[0].makerFee.add(signedOrders[1].makerFee.dividedToIntegerBy(2));
|
||||||
const takerFee = orders[0].params.takerFee.add(orders[1].params.takerFee.dividedToIntegerBy(2));
|
const takerFee = signedOrders[0].takerFee.add(signedOrders[1].takerFee.dividedToIntegerBy(2));
|
||||||
expect(newBalances[maker][orders[0].params.makerToken]).to.be.bignumber.equal(
|
expect(newBalances[maker][signedOrders[0].makerTokenAddress]).to.be.bignumber.equal(
|
||||||
balances[maker][orders[0].params.makerToken].minus(fillMakerTokenAmount),
|
balances[maker][signedOrders[0].makerTokenAddress].minus(fillMakerTokenAmount),
|
||||||
);
|
);
|
||||||
expect(newBalances[maker][orders[0].params.takerToken]).to.be.bignumber.equal(
|
expect(newBalances[maker][signedOrders[0].takerTokenAddress]).to.be.bignumber.equal(
|
||||||
balances[maker][orders[0].params.takerToken].add(fillTakerTokenAmount),
|
balances[maker][signedOrders[0].takerTokenAddress].add(fillTakerTokenAmount),
|
||||||
);
|
);
|
||||||
expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(
|
expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(
|
||||||
balances[maker][zrx.address].minus(makerFee),
|
balances[maker][zrx.address].minus(makerFee),
|
||||||
);
|
);
|
||||||
expect(newBalances[taker][orders[0].params.takerToken]).to.be.bignumber.equal(
|
expect(newBalances[taker][signedOrders[0].takerTokenAddress]).to.be.bignumber.equal(
|
||||||
balances[taker][orders[0].params.takerToken].minus(fillTakerTokenAmount),
|
balances[taker][signedOrders[0].takerTokenAddress].minus(fillTakerTokenAmount),
|
||||||
);
|
);
|
||||||
expect(newBalances[taker][orders[0].params.makerToken]).to.be.bignumber.equal(
|
expect(newBalances[taker][signedOrders[0].makerTokenAddress]).to.be.bignumber.equal(
|
||||||
balances[taker][orders[0].params.makerToken].add(fillMakerTokenAmount),
|
balances[taker][signedOrders[0].makerTokenAddress].add(fillMakerTokenAmount),
|
||||||
);
|
);
|
||||||
expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(
|
expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(
|
||||||
balances[taker][zrx.address].minus(takerFee),
|
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);
|
const fillTakerTokenAmount = ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18);
|
||||||
orders.forEach(order => {
|
signedOrders.forEach(signedOrder => {
|
||||||
balances[maker][order.params.makerToken] = balances[maker][order.params.makerToken].minus(
|
balances[maker][signedOrder.makerTokenAddress] = balances[maker][
|
||||||
order.params.makerTokenAmount,
|
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(
|
balances[maker][zrx.address] = balances[maker][zrx.address].minus(signedOrder.makerFee);
|
||||||
order.params.takerTokenAmount,
|
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][signedOrder.takerTokenAddress] = balances[taker][
|
||||||
balances[taker][order.params.makerToken] = balances[taker][order.params.makerToken].add(
|
signedOrder.takerTokenAddress
|
||||||
order.params.makerTokenAmount,
|
].minus(signedOrder.takerTokenAmount);
|
||||||
);
|
balances[taker][zrx.address] = balances[taker][zrx.address].minus(signedOrder.takerFee);
|
||||||
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[feeRecipient][zrx.address] = balances[feeRecipient][zrx.address].add(
|
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,
|
fillTakerTokenAmount,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -341,15 +340,15 @@ describe('Exchange', () => {
|
|||||||
expect(newBalances).to.be.deep.equal(balances);
|
expect(newBalances).to.be.deep.equal(balances);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw when an order does not use the same takerToken', async () => {
|
it('should throw when an signedOrder does not use the same takerTokenAddress', async () => {
|
||||||
orders = await Promise.all([
|
signedOrders = await Promise.all([
|
||||||
orderFactory.newSignedOrderAsync(),
|
orderFactory.newSignedOrderAsync(),
|
||||||
orderFactory.newSignedOrderAsync({ takerToken: zrx.address }),
|
orderFactory.newSignedOrderAsync({ takerTokenAddress: zrx.address }),
|
||||||
orderFactory.newSignedOrderAsync(),
|
orderFactory.newSignedOrderAsync(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return expect(
|
return expect(
|
||||||
exWrapper.fillOrdersUpToAsync(orders, taker, {
|
exWrapper.fillOrdersUpToAsync(signedOrders, taker, {
|
||||||
fillTakerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(1000), 18),
|
fillTakerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(1000), 18),
|
||||||
}),
|
}),
|
||||||
).to.be.rejectedWith(constants.REVERT);
|
).to.be.rejectedWith(constants.REVERT);
|
||||||
@@ -357,13 +356,13 @@ describe('Exchange', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('batchCancelOrders', () => {
|
describe('batchCancelOrders', () => {
|
||||||
it('should be able to cancel multiple orders', async () => {
|
it('should be able to cancel multiple signedOrders', async () => {
|
||||||
const cancelTakerTokenAmounts = _.map(orders, order => order.params.takerTokenAmount);
|
const cancelTakerTokenAmounts = _.map(signedOrders, signedOrder => signedOrder.takerTokenAmount);
|
||||||
await exWrapper.batchCancelOrdersAsync(orders, maker, {
|
await exWrapper.batchCancelOrdersAsync(signedOrders, maker, {
|
||||||
cancelTakerTokenAmounts,
|
cancelTakerTokenAmounts,
|
||||||
});
|
});
|
||||||
|
|
||||||
await exWrapper.batchFillOrdersAsync(orders, taker, {
|
await exWrapper.batchFillOrdersAsync(signedOrders, taker, {
|
||||||
fillTakerTokenAmounts: cancelTakerTokenAmounts,
|
fillTakerTokenAmounts: cancelTakerTokenAmounts,
|
||||||
});
|
});
|
||||||
const newBalances = await dmyBalances.getAsync();
|
const newBalances = await dmyBalances.getAsync();
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { TransactionReceiptWithDecodedLogs, ZeroEx } from '0x.js';
|
import { SignedOrder, TransactionReceiptWithDecodedLogs, ZeroEx } from '0x.js';
|
||||||
import { BigNumber } from '@0xproject/utils';
|
import { BigNumber } from '@0xproject/utils';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
import * as Web3 from 'web3';
|
import * as Web3 from 'web3';
|
||||||
@@ -6,7 +6,7 @@ import * as Web3 from 'web3';
|
|||||||
import { ExchangeContract } from '../src/contract_wrappers/generated/exchange';
|
import { ExchangeContract } from '../src/contract_wrappers/generated/exchange';
|
||||||
|
|
||||||
import { formatters } from './formatters';
|
import { formatters } from './formatters';
|
||||||
import { Order } from './order';
|
import { signedOrderUtils } from './signed_order_utils';
|
||||||
|
|
||||||
export class ExchangeWrapper {
|
export class ExchangeWrapper {
|
||||||
private _exchange: ExchangeContract;
|
private _exchange: ExchangeContract;
|
||||||
@@ -16,7 +16,7 @@ export class ExchangeWrapper {
|
|||||||
this._zeroEx = zeroEx;
|
this._zeroEx = zeroEx;
|
||||||
}
|
}
|
||||||
public async fillOrderAsync(
|
public async fillOrderAsync(
|
||||||
order: Order,
|
signedOrder: SignedOrder,
|
||||||
from: string,
|
from: string,
|
||||||
opts: {
|
opts: {
|
||||||
fillTakerTokenAmount?: BigNumber;
|
fillTakerTokenAmount?: BigNumber;
|
||||||
@@ -24,15 +24,19 @@ export class ExchangeWrapper {
|
|||||||
} = {},
|
} = {},
|
||||||
): Promise<TransactionReceiptWithDecodedLogs> {
|
): Promise<TransactionReceiptWithDecodedLogs> {
|
||||||
const shouldThrowOnInsufficientBalanceOrAllowance = !!opts.shouldThrowOnInsufficientBalanceOrAllowance;
|
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(
|
const txHash = await this._exchange.fillOrder.sendTransactionAsync(
|
||||||
params.orderAddresses,
|
params.orderAddresses,
|
||||||
params.orderValues,
|
params.orderValues,
|
||||||
params.fillTakerTokenAmount,
|
params.fillTakerTokenAmount,
|
||||||
params.shouldThrowOnInsufficientBalanceOrAllowance,
|
params.shouldThrowOnInsufficientBalanceOrAllowance,
|
||||||
params.v as number,
|
params.v,
|
||||||
params.r as string,
|
params.r,
|
||||||
params.s as string,
|
params.s,
|
||||||
{ from },
|
{ from },
|
||||||
);
|
);
|
||||||
const tx = await this._zeroEx.awaitTransactionMinedAsync(txHash);
|
const tx = await this._zeroEx.awaitTransactionMinedAsync(txHash);
|
||||||
@@ -41,11 +45,11 @@ export class ExchangeWrapper {
|
|||||||
return tx;
|
return tx;
|
||||||
}
|
}
|
||||||
public async cancelOrderAsync(
|
public async cancelOrderAsync(
|
||||||
order: Order,
|
signedOrder: SignedOrder,
|
||||||
from: string,
|
from: string,
|
||||||
opts: { cancelTakerTokenAmount?: BigNumber } = {},
|
opts: { cancelTakerTokenAmount?: BigNumber } = {},
|
||||||
): Promise<TransactionReceiptWithDecodedLogs> {
|
): Promise<TransactionReceiptWithDecodedLogs> {
|
||||||
const params = order.createCancel(opts.cancelTakerTokenAmount);
|
const params = signedOrderUtils.createCancel(signedOrder, opts.cancelTakerTokenAmount);
|
||||||
const txHash = await this._exchange.cancelOrder.sendTransactionAsync(
|
const txHash = await this._exchange.cancelOrder.sendTransactionAsync(
|
||||||
params.orderAddresses,
|
params.orderAddresses,
|
||||||
params.orderValues,
|
params.orderValues,
|
||||||
@@ -58,19 +62,23 @@ export class ExchangeWrapper {
|
|||||||
return tx;
|
return tx;
|
||||||
}
|
}
|
||||||
public async fillOrKillOrderAsync(
|
public async fillOrKillOrderAsync(
|
||||||
order: Order,
|
signedOrder: SignedOrder,
|
||||||
from: string,
|
from: string,
|
||||||
opts: { fillTakerTokenAmount?: BigNumber } = {},
|
opts: { fillTakerTokenAmount?: BigNumber } = {},
|
||||||
): Promise<TransactionReceiptWithDecodedLogs> {
|
): Promise<TransactionReceiptWithDecodedLogs> {
|
||||||
const shouldThrowOnInsufficientBalanceOrAllowance = true;
|
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(
|
const txHash = await this._exchange.fillOrKillOrder.sendTransactionAsync(
|
||||||
params.orderAddresses,
|
params.orderAddresses,
|
||||||
params.orderValues,
|
params.orderValues,
|
||||||
params.fillTakerTokenAmount,
|
params.fillTakerTokenAmount,
|
||||||
params.v as number,
|
params.v,
|
||||||
params.r as string,
|
params.r,
|
||||||
params.s as string,
|
params.s,
|
||||||
{ from },
|
{ from },
|
||||||
);
|
);
|
||||||
const tx = await this._zeroEx.awaitTransactionMinedAsync(txHash);
|
const tx = await this._zeroEx.awaitTransactionMinedAsync(txHash);
|
||||||
@@ -79,7 +87,7 @@ export class ExchangeWrapper {
|
|||||||
return tx;
|
return tx;
|
||||||
}
|
}
|
||||||
public async batchFillOrdersAsync(
|
public async batchFillOrdersAsync(
|
||||||
orders: Order[],
|
orders: SignedOrder[],
|
||||||
from: string,
|
from: string,
|
||||||
opts: {
|
opts: {
|
||||||
fillTakerTokenAmounts?: BigNumber[];
|
fillTakerTokenAmounts?: BigNumber[];
|
||||||
@@ -108,7 +116,7 @@ export class ExchangeWrapper {
|
|||||||
return tx;
|
return tx;
|
||||||
}
|
}
|
||||||
public async batchFillOrKillOrdersAsync(
|
public async batchFillOrKillOrdersAsync(
|
||||||
orders: Order[],
|
orders: SignedOrder[],
|
||||||
from: string,
|
from: string,
|
||||||
opts: { fillTakerTokenAmounts?: BigNumber[]; shouldThrowOnInsufficientBalanceOrAllowance?: boolean } = {},
|
opts: { fillTakerTokenAmounts?: BigNumber[]; shouldThrowOnInsufficientBalanceOrAllowance?: boolean } = {},
|
||||||
): Promise<TransactionReceiptWithDecodedLogs> {
|
): Promise<TransactionReceiptWithDecodedLogs> {
|
||||||
@@ -133,7 +141,7 @@ export class ExchangeWrapper {
|
|||||||
return tx;
|
return tx;
|
||||||
}
|
}
|
||||||
public async fillOrdersUpToAsync(
|
public async fillOrdersUpToAsync(
|
||||||
orders: Order[],
|
orders: SignedOrder[],
|
||||||
from: string,
|
from: string,
|
||||||
opts: { fillTakerTokenAmount: BigNumber; shouldThrowOnInsufficientBalanceOrAllowance?: boolean },
|
opts: { fillTakerTokenAmount: BigNumber; shouldThrowOnInsufficientBalanceOrAllowance?: boolean },
|
||||||
): Promise<TransactionReceiptWithDecodedLogs> {
|
): Promise<TransactionReceiptWithDecodedLogs> {
|
||||||
@@ -159,7 +167,7 @@ export class ExchangeWrapper {
|
|||||||
return tx;
|
return tx;
|
||||||
}
|
}
|
||||||
public async batchCancelOrdersAsync(
|
public async batchCancelOrdersAsync(
|
||||||
orders: Order[],
|
orders: SignedOrder[],
|
||||||
from: string,
|
from: string,
|
||||||
opts: { cancelTakerTokenAmounts?: BigNumber[] } = {},
|
opts: { cancelTakerTokenAmounts?: BigNumber[] } = {},
|
||||||
): Promise<TransactionReceiptWithDecodedLogs> {
|
): Promise<TransactionReceiptWithDecodedLogs> {
|
||||||
@@ -175,19 +183,19 @@ export class ExchangeWrapper {
|
|||||||
_.each(tx.logs, log => wrapLogBigNumbers(log));
|
_.each(tx.logs, log => wrapLogBigNumbers(log));
|
||||||
return tx;
|
return tx;
|
||||||
}
|
}
|
||||||
public async getOrderHashAsync(order: Order): Promise<string> {
|
public async getOrderHashAsync(signedOrder: SignedOrder): Promise<string> {
|
||||||
const shouldThrowOnInsufficientBalanceOrAllowance = false;
|
const shouldThrowOnInsufficientBalanceOrAllowance = false;
|
||||||
const params = order.createFill(shouldThrowOnInsufficientBalanceOrAllowance);
|
const params = signedOrderUtils.getOrderAddressesAndValues(signedOrder);
|
||||||
const orderHash = await this._exchange.getOrderHash(params.orderAddresses, params.orderValues);
|
const orderHash = await this._exchange.getOrderHash(params.orderAddresses, params.orderValues);
|
||||||
return orderHash;
|
return orderHash;
|
||||||
}
|
}
|
||||||
public async isValidSignatureAsync(order: Order): Promise<boolean> {
|
public async isValidSignatureAsync(signedOrder: SignedOrder): Promise<boolean> {
|
||||||
const isValidSignature = await this._exchange.isValidSignature(
|
const isValidSignature = await this._exchange.isValidSignature(
|
||||||
order.params.maker,
|
signedOrder.maker,
|
||||||
order.params.orderHashHex as string,
|
ZeroEx.getOrderHashHex(signedOrder),
|
||||||
order.params.v as number,
|
signedOrder.ecSignature.v,
|
||||||
order.params.r as string,
|
signedOrder.ecSignature.r,
|
||||||
order.params.s as string,
|
signedOrder.ecSignature.s,
|
||||||
);
|
);
|
||||||
return isValidSignature;
|
return isValidSignature;
|
||||||
}
|
}
|
||||||
|
@@ -1,12 +1,12 @@
|
|||||||
|
import { SignedOrder } from '0x.js';
|
||||||
import { BigNumber } from '@0xproject/utils';
|
import { BigNumber } from '@0xproject/utils';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
import { Order } from './order';
|
|
||||||
import { BatchCancelOrders, BatchFillOrders, FillOrdersUpTo } from './types';
|
import { BatchCancelOrders, BatchFillOrders, FillOrdersUpTo } from './types';
|
||||||
|
|
||||||
export const formatters = {
|
export const formatters = {
|
||||||
createBatchFill(
|
createBatchFill(
|
||||||
orders: Order[],
|
signedOrders: SignedOrder[],
|
||||||
shouldThrowOnInsufficientBalanceOrAllowance: boolean,
|
shouldThrowOnInsufficientBalanceOrAllowance: boolean,
|
||||||
fillTakerTokenAmounts: BigNumber[] = [],
|
fillTakerTokenAmounts: BigNumber[] = [],
|
||||||
) {
|
) {
|
||||||
@@ -19,33 +19,33 @@ export const formatters = {
|
|||||||
r: [],
|
r: [],
|
||||||
s: [],
|
s: [],
|
||||||
};
|
};
|
||||||
_.forEach(orders, order => {
|
_.forEach(signedOrders, signedOrder => {
|
||||||
batchFill.orderAddresses.push([
|
batchFill.orderAddresses.push([
|
||||||
order.params.maker,
|
signedOrder.maker,
|
||||||
order.params.taker,
|
signedOrder.taker,
|
||||||
order.params.makerToken,
|
signedOrder.makerTokenAddress,
|
||||||
order.params.takerToken,
|
signedOrder.takerTokenAddress,
|
||||||
order.params.feeRecipient,
|
signedOrder.feeRecipient,
|
||||||
]);
|
]);
|
||||||
batchFill.orderValues.push([
|
batchFill.orderValues.push([
|
||||||
order.params.makerTokenAmount,
|
signedOrder.makerTokenAmount,
|
||||||
order.params.takerTokenAmount,
|
signedOrder.takerTokenAmount,
|
||||||
order.params.makerFee,
|
signedOrder.makerFee,
|
||||||
order.params.takerFee,
|
signedOrder.takerFee,
|
||||||
order.params.expirationTimestampInSec,
|
signedOrder.expirationUnixTimestampSec,
|
||||||
order.params.salt,
|
signedOrder.salt,
|
||||||
]);
|
]);
|
||||||
batchFill.v.push(order.params.v as number);
|
batchFill.v.push(signedOrder.ecSignature.v);
|
||||||
batchFill.r.push(order.params.r as string);
|
batchFill.r.push(signedOrder.ecSignature.r);
|
||||||
batchFill.s.push(order.params.s as string);
|
batchFill.s.push(signedOrder.ecSignature.s);
|
||||||
if (fillTakerTokenAmounts.length < orders.length) {
|
if (fillTakerTokenAmounts.length < signedOrders.length) {
|
||||||
batchFill.fillTakerTokenAmounts.push(order.params.takerTokenAmount);
|
batchFill.fillTakerTokenAmounts.push(signedOrder.takerTokenAmount);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return batchFill;
|
return batchFill;
|
||||||
},
|
},
|
||||||
createFillUpTo(
|
createFillUpTo(
|
||||||
orders: Order[],
|
signedOrders: SignedOrder[],
|
||||||
shouldThrowOnInsufficientBalanceOrAllowance: boolean,
|
shouldThrowOnInsufficientBalanceOrAllowance: boolean,
|
||||||
fillTakerTokenAmount: BigNumber,
|
fillTakerTokenAmount: BigNumber,
|
||||||
) {
|
) {
|
||||||
@@ -58,52 +58,52 @@ export const formatters = {
|
|||||||
r: [],
|
r: [],
|
||||||
s: [],
|
s: [],
|
||||||
};
|
};
|
||||||
orders.forEach(order => {
|
signedOrders.forEach(signedOrder => {
|
||||||
fillUpTo.orderAddresses.push([
|
fillUpTo.orderAddresses.push([
|
||||||
order.params.maker,
|
signedOrder.maker,
|
||||||
order.params.taker,
|
signedOrder.taker,
|
||||||
order.params.makerToken,
|
signedOrder.makerTokenAddress,
|
||||||
order.params.takerToken,
|
signedOrder.takerTokenAddress,
|
||||||
order.params.feeRecipient,
|
signedOrder.feeRecipient,
|
||||||
]);
|
]);
|
||||||
fillUpTo.orderValues.push([
|
fillUpTo.orderValues.push([
|
||||||
order.params.makerTokenAmount,
|
signedOrder.makerTokenAmount,
|
||||||
order.params.takerTokenAmount,
|
signedOrder.takerTokenAmount,
|
||||||
order.params.makerFee,
|
signedOrder.makerFee,
|
||||||
order.params.takerFee,
|
signedOrder.takerFee,
|
||||||
order.params.expirationTimestampInSec,
|
signedOrder.expirationUnixTimestampSec,
|
||||||
order.params.salt,
|
signedOrder.salt,
|
||||||
]);
|
]);
|
||||||
fillUpTo.v.push(order.params.v as number);
|
fillUpTo.v.push(signedOrder.ecSignature.v);
|
||||||
fillUpTo.r.push(order.params.r as string);
|
fillUpTo.r.push(signedOrder.ecSignature.r);
|
||||||
fillUpTo.s.push(order.params.s as string);
|
fillUpTo.s.push(signedOrder.ecSignature.s);
|
||||||
});
|
});
|
||||||
return fillUpTo;
|
return fillUpTo;
|
||||||
},
|
},
|
||||||
createBatchCancel(orders: Order[], cancelTakerTokenAmounts: BigNumber[] = []) {
|
createBatchCancel(signedOrders: SignedOrder[], cancelTakerTokenAmounts: BigNumber[] = []) {
|
||||||
const batchCancel: BatchCancelOrders = {
|
const batchCancel: BatchCancelOrders = {
|
||||||
orderAddresses: [],
|
orderAddresses: [],
|
||||||
orderValues: [],
|
orderValues: [],
|
||||||
cancelTakerTokenAmounts,
|
cancelTakerTokenAmounts,
|
||||||
};
|
};
|
||||||
orders.forEach(order => {
|
signedOrders.forEach(signedOrder => {
|
||||||
batchCancel.orderAddresses.push([
|
batchCancel.orderAddresses.push([
|
||||||
order.params.maker,
|
signedOrder.maker,
|
||||||
order.params.taker,
|
signedOrder.taker,
|
||||||
order.params.makerToken,
|
signedOrder.makerTokenAddress,
|
||||||
order.params.takerToken,
|
signedOrder.takerTokenAddress,
|
||||||
order.params.feeRecipient,
|
signedOrder.feeRecipient,
|
||||||
]);
|
]);
|
||||||
batchCancel.orderValues.push([
|
batchCancel.orderValues.push([
|
||||||
order.params.makerTokenAmount,
|
signedOrder.makerTokenAmount,
|
||||||
order.params.takerTokenAmount,
|
signedOrder.takerTokenAmount,
|
||||||
order.params.makerFee,
|
signedOrder.makerFee,
|
||||||
order.params.takerFee,
|
signedOrder.takerFee,
|
||||||
order.params.expirationTimestampInSec,
|
signedOrder.expirationUnixTimestampSec,
|
||||||
order.params.salt,
|
signedOrder.salt,
|
||||||
]);
|
]);
|
||||||
if (cancelTakerTokenAmounts.length < orders.length) {
|
if (cancelTakerTokenAmounts.length < signedOrders.length) {
|
||||||
batchCancel.cancelTakerTokenAmounts.push(order.params.takerTokenAmount);
|
batchCancel.cancelTakerTokenAmounts.push(signedOrder.takerTokenAmount);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return batchCancel;
|
return batchCancel;
|
||||||
|
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,32 +1,37 @@
|
|||||||
import { ZeroEx } from '0x.js';
|
import { Order, SignedOrder, ZeroEx } from '0x.js';
|
||||||
import { BigNumber } from '@0xproject/utils';
|
import { BigNumber } from '@0xproject/utils';
|
||||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
import { Order } from './order';
|
import { DefaultOrderParams } from './types';
|
||||||
import { DefaultOrderParams, OptionalOrderParams, OrderParams } from './types';
|
|
||||||
|
|
||||||
export class OrderFactory {
|
export class OrderFactory {
|
||||||
private _defaultOrderParams: DefaultOrderParams;
|
private _defaultOrderParams: Partial<Order>;
|
||||||
private _web3Wrapper: Web3Wrapper;
|
private _zeroEx: ZeroEx;
|
||||||
constructor(web3Wrapper: Web3Wrapper, defaultOrderParams: DefaultOrderParams) {
|
constructor(zeroEx: ZeroEx, defaultOrderParams: Partial<Order>) {
|
||||||
this._defaultOrderParams = defaultOrderParams;
|
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 randomExpiration = new BigNumber(Math.floor((Date.now() + Math.random() * 100000000000) / 1000));
|
||||||
const orderParams: OrderParams = _.assign(
|
const order = ({
|
||||||
{},
|
expirationUnixTimestampSec: randomExpiration,
|
||||||
{
|
salt: ZeroEx.generatePseudoRandomSalt(),
|
||||||
expirationTimestampInSec: randomExpiration,
|
taker: ZeroEx.NULL_ADDRESS,
|
||||||
salt: ZeroEx.generatePseudoRandomSalt(),
|
...this._defaultOrderParams,
|
||||||
taker: ZeroEx.NULL_ADDRESS,
|
...customOrderParams,
|
||||||
},
|
} as any) as Order;
|
||||||
this._defaultOrderParams,
|
const orderHashHex = ZeroEx.getOrderHashHex(order);
|
||||||
customOrderParams,
|
const shouldAddPersonalMessagePrefix = false;
|
||||||
|
const ecSignature = await this._zeroEx.signOrderHashAsync(
|
||||||
|
orderHashHex,
|
||||||
|
order.maker,
|
||||||
|
shouldAddPersonalMessagePrefix,
|
||||||
);
|
);
|
||||||
const order = new Order(this._web3Wrapper, orderParams);
|
const signedOrder = {
|
||||||
await order.signAsync();
|
...order,
|
||||||
return order;
|
ecSignature,
|
||||||
|
};
|
||||||
|
return signedOrder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
49
packages/contracts/util/signed_order_utils.ts
Normal file
49
packages/contracts/util/signed_order_utils.ts
Normal 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,
|
||||||
|
],
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
@@ -49,39 +49,6 @@ export interface DefaultOrderParams {
|
|||||||
takerFee: BigNumber;
|
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 {
|
export interface TransactionDataParams {
|
||||||
name: string;
|
name: string;
|
||||||
abi: Web3.AbiDefinition[];
|
abi: Web3.AbiDefinition[];
|
||||||
|
6
packages/deployer/.npmignore
Normal file
6
packages/deployer/.npmignore
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
.*
|
||||||
|
yarn-error.log
|
||||||
|
/src/
|
||||||
|
/scripts/
|
||||||
|
test/
|
||||||
|
tsconfig.json
|
9
packages/deployer/CHANGELOG.md
Normal file
9
packages/deployer/CHANGELOG.md
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# CHANGELOG
|
||||||
|
|
||||||
|
## v0.1.0 - _February 16, 2018_
|
||||||
|
|
||||||
|
* Add the ability to pass in specific contracts to compile in CLI (#400)
|
||||||
|
|
||||||
|
## v0.0.8 - _February 9, 2018_
|
||||||
|
|
||||||
|
* Fix publishing issue where .npmignore was not properly excluding undesired content (#389)
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@0xproject/deployer",
|
"name": "@0xproject/deployer",
|
||||||
"version": "0.0.7",
|
"version": "0.0.9",
|
||||||
"description": "Smart contract deployer of 0x protocol",
|
"description": "Smart contract deployer of 0x protocol",
|
||||||
"main": "lib/src/index.js",
|
"main": "lib/src/index.js",
|
||||||
"types": "lib/src/index.d.ts",
|
"types": "lib/src/index.d.ts",
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
"build": "yarn clean && copyfiles 'test/fixtures/contracts/**/*' src/solc/solc_bin/* ./lib && tsc",
|
"build": "yarn clean && copyfiles 'test/fixtures/contracts/**/*' src/solc/solc_bin/* ./lib && tsc",
|
||||||
"test": "npm run build; mocha lib/test/*_test.js",
|
"test": "npm run build; mocha lib/test/*_test.js",
|
||||||
"compile": "npm run build; node lib/src/cli.js compile",
|
"compile": "npm run build; node lib/src/cli.js compile",
|
||||||
"clean": "rm -rf ./lib",
|
"clean": "shx rm -rf ./lib",
|
||||||
"migrate": "npm run build; node lib/src/cli.js migrate",
|
"migrate": "npm run build; node lib/src/cli.js migrate",
|
||||||
"lint": "tslint --project . 'src/**/*.ts' 'test/**/*.ts'",
|
"lint": "tslint --project . 'src/**/*.ts' 'test/**/*.ts'",
|
||||||
"test:circleci": "yarn test"
|
"test:circleci": "yarn test"
|
||||||
@@ -28,14 +28,22 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/0xProject/0x.js/packages/deployer/README.md",
|
"homepage": "https://github.com/0xProject/0x.js/packages/deployer/README.md",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@0xproject/tslint-config": "^0.4.9",
|
||||||
|
"chai": "^4.0.1",
|
||||||
"copyfiles": "^1.2.0",
|
"copyfiles": "^1.2.0",
|
||||||
|
"shx": "^0.2.2",
|
||||||
|
"mocha": "^4.0.1",
|
||||||
|
"tslint": "5.8.0",
|
||||||
"types-bn": "^0.0.1",
|
"types-bn": "^0.0.1",
|
||||||
"typescript": "2.7.1",
|
"typescript": "2.7.1",
|
||||||
"web3-typescript-typings": "^0.9.9"
|
"web3-typescript-typings": "^0.9.10"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@0xproject/utils": "^0.3.1",
|
"@0xproject/json-schemas": "^0.7.11",
|
||||||
"@0xproject/web3-wrapper": "^0.1.11",
|
"@0xproject/types": "^0.2.2",
|
||||||
|
"@0xproject/utils": "^0.3.3",
|
||||||
|
"@0xproject/web3-wrapper": "^0.1.13",
|
||||||
|
"ethereumjs-util": "^5.1.1",
|
||||||
"lodash": "^4.17.4",
|
"lodash": "^4.17.4",
|
||||||
"solc": "^0.4.18",
|
"solc": "^0.4.18",
|
||||||
"web3": "^0.20.0",
|
"web3": "^0.20.0",
|
||||||
|
@@ -1,39 +1,5 @@
|
|||||||
const execAsync = require('async-child-process').execAsync;
|
|
||||||
const postpublish_utils = require('../../../scripts/postpublish_utils');
|
const postpublish_utils = require('../../../scripts/postpublish_utils');
|
||||||
const packageJSON = require('../package.json');
|
const packageJSON = require('../package.json');
|
||||||
|
|
||||||
const cwd = __dirname + '/..';
|
|
||||||
const subPackageName = packageJSON.name;
|
const subPackageName = packageJSON.name;
|
||||||
const S3BucketPath = 's3://connect-docs-jsons/';
|
postpublish_utils.standardPostPublishAsync(subPackageName);
|
||||||
|
|
||||||
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;
|
|
||||||
});
|
|
@@ -14,6 +14,7 @@ const DEFAULT_ARTIFACTS_DIR = path.resolve('artifacts');
|
|||||||
const DEFAULT_NETWORK_ID = 50;
|
const DEFAULT_NETWORK_ID = 50;
|
||||||
const DEFAULT_JSONRPC_PORT = 8545;
|
const DEFAULT_JSONRPC_PORT = 8545;
|
||||||
const DEFAULT_GAS_PRICE = (10 ** 9 * 2).toString();
|
const DEFAULT_GAS_PRICE = (10 ** 9 * 2).toString();
|
||||||
|
const DEFAULT_CONTRACTS_LIST = '*';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compiles all contracts with options passed in through CLI.
|
* Compiles all contracts with options passed in through CLI.
|
||||||
@@ -25,6 +26,7 @@ async function onCompileCommand(argv: CliOptions): Promise<void> {
|
|||||||
networkId: argv.networkId,
|
networkId: argv.networkId,
|
||||||
optimizerEnabled: argv.shouldOptimize ? 1 : 0,
|
optimizerEnabled: argv.shouldOptimize ? 1 : 0,
|
||||||
artifactsDir: argv.artifactsDir,
|
artifactsDir: argv.artifactsDir,
|
||||||
|
specifiedContracts: getContractsSetFromList(argv.contracts),
|
||||||
};
|
};
|
||||||
await commands.compileAsync(opts);
|
await commands.compileAsync(opts);
|
||||||
}
|
}
|
||||||
@@ -43,6 +45,7 @@ async function onMigrateCommand(argv: CliOptions): Promise<void> {
|
|||||||
networkId,
|
networkId,
|
||||||
optimizerEnabled: argv.shouldOptimize ? 1 : 0,
|
optimizerEnabled: argv.shouldOptimize ? 1 : 0,
|
||||||
artifactsDir: argv.artifactsDir,
|
artifactsDir: argv.artifactsDir,
|
||||||
|
specifiedContracts: getContractsSetFromList(argv.contracts),
|
||||||
};
|
};
|
||||||
await commands.compileAsync(compilerOpts);
|
await commands.compileAsync(compilerOpts);
|
||||||
|
|
||||||
@@ -72,6 +75,7 @@ async function onDeployCommand(argv: CliOptions): Promise<void> {
|
|||||||
networkId,
|
networkId,
|
||||||
optimizerEnabled: argv.shouldOptimize ? 1 : 0,
|
optimizerEnabled: argv.shouldOptimize ? 1 : 0,
|
||||||
artifactsDir: argv.artifactsDir,
|
artifactsDir: argv.artifactsDir,
|
||||||
|
specifiedContracts: getContractsSetFromList(argv.contracts),
|
||||||
};
|
};
|
||||||
await commands.compileAsync(compilerOpts);
|
await commands.compileAsync(compilerOpts);
|
||||||
|
|
||||||
@@ -89,6 +93,18 @@ async function onDeployCommand(argv: CliOptions): Promise<void> {
|
|||||||
const deployerArgs = deployerArgsString.split(',');
|
const deployerArgs = deployerArgsString.split(',');
|
||||||
await commands.deployAsync(argv.contract, deployerArgs, deployerOpts);
|
await commands.deployAsync(argv.contract, deployerArgs, deployerOpts);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Creates a set of contracts to compile.
|
||||||
|
* @param contracts Comma separated list of contracts to compile
|
||||||
|
*/
|
||||||
|
function getContractsSetFromList(contracts: string): Set<string> {
|
||||||
|
const specifiedContracts = new Set();
|
||||||
|
const contractsArray = contracts.split(',');
|
||||||
|
_.forEach(contractsArray, contractName => {
|
||||||
|
specifiedContracts.add(contractName);
|
||||||
|
});
|
||||||
|
return specifiedContracts;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Provides extra required options for deploy command.
|
* Provides extra required options for deploy command.
|
||||||
* @param yargsInstance yargs instance provided in builder function callback.
|
* @param yargsInstance yargs instance provided in builder function callback.
|
||||||
@@ -144,6 +160,11 @@ function deployCommandBuilder(yargsInstance: any) {
|
|||||||
type: 'string',
|
type: 'string',
|
||||||
description: 'account to use for deploying contracts',
|
description: 'account to use for deploying contracts',
|
||||||
})
|
})
|
||||||
|
.option('contracts', {
|
||||||
|
type: 'string',
|
||||||
|
default: DEFAULT_CONTRACTS_LIST,
|
||||||
|
description: 'comma separated list of contracts to compile',
|
||||||
|
})
|
||||||
.command('compile', 'compile contracts', identityCommandBuilder, onCompileCommand)
|
.command('compile', 'compile contracts', identityCommandBuilder, onCompileCommand)
|
||||||
.command(
|
.command(
|
||||||
'migrate',
|
'migrate',
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import { migrator } from './migrations/migrate';
|
|
||||||
import { Compiler } from './compiler';
|
import { Compiler } from './compiler';
|
||||||
import { Deployer } from './deployer';
|
import { Deployer } from './deployer';
|
||||||
|
import { migrator } from './migrations/migrate';
|
||||||
import { CompilerOptions, DeployerOptions } from './utils/types';
|
import { CompilerOptions, DeployerOptions } from './utils/types';
|
||||||
|
|
||||||
export const commands = {
|
export const commands = {
|
||||||
|
@@ -17,6 +17,7 @@ import {
|
|||||||
import { utils } from './utils/utils';
|
import { utils } from './utils/utils';
|
||||||
|
|
||||||
const SOLIDITY_FILE_EXTENSION = '.sol';
|
const SOLIDITY_FILE_EXTENSION = '.sol';
|
||||||
|
const ALL_CONTRACTS_IDENTIFIER = '*';
|
||||||
|
|
||||||
export class Compiler {
|
export class Compiler {
|
||||||
private _contractsDir: string;
|
private _contractsDir: string;
|
||||||
@@ -25,6 +26,7 @@ export class Compiler {
|
|||||||
private _artifactsDir: string;
|
private _artifactsDir: string;
|
||||||
private _contractSourcesIfExists?: ContractSources;
|
private _contractSourcesIfExists?: ContractSources;
|
||||||
private _solcErrors: Set<string>;
|
private _solcErrors: Set<string>;
|
||||||
|
private _specifiedContracts: Set<string>;
|
||||||
/**
|
/**
|
||||||
* Recursively retrieves Solidity source code from directory.
|
* Recursively retrieves Solidity source code from directory.
|
||||||
* @param dirPath Directory to search.
|
* @param dirPath Directory to search.
|
||||||
@@ -106,6 +108,7 @@ export class Compiler {
|
|||||||
this._optimizerEnabled = opts.optimizerEnabled;
|
this._optimizerEnabled = opts.optimizerEnabled;
|
||||||
this._artifactsDir = opts.artifactsDir;
|
this._artifactsDir = opts.artifactsDir;
|
||||||
this._solcErrors = new Set();
|
this._solcErrors = new Set();
|
||||||
|
this._specifiedContracts = opts.specifiedContracts;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Compiles all Solidity files found in contractsDir and writes JSON artifacts to artifactsDir.
|
* Compiles all Solidity files found in contractsDir and writes JSON artifacts to artifactsDir.
|
||||||
@@ -136,6 +139,8 @@ export class Compiler {
|
|||||||
const contractName = path.basename(contractBaseName, SOLIDITY_FILE_EXTENSION);
|
const contractName = path.basename(contractBaseName, SOLIDITY_FILE_EXTENSION);
|
||||||
const currentArtifactPath = `${this._artifactsDir}/${contractName}.json`;
|
const currentArtifactPath = `${this._artifactsDir}/${contractName}.json`;
|
||||||
const sourceHash = `0x${ethUtil.sha3(source).toString('hex')}`;
|
const sourceHash = `0x${ethUtil.sha3(source).toString('hex')}`;
|
||||||
|
const isContractSpecified =
|
||||||
|
this._specifiedContracts.has(ALL_CONTRACTS_IDENTIFIER) || this._specifiedContracts.has(contractName);
|
||||||
|
|
||||||
let currentArtifactString: string;
|
let currentArtifactString: string;
|
||||||
let currentArtifact: ContractArtifact;
|
let currentArtifact: ContractArtifact;
|
||||||
@@ -150,11 +155,12 @@ export class Compiler {
|
|||||||
oldNetworks = currentArtifact.networks;
|
oldNetworks = currentArtifact.networks;
|
||||||
const oldNetwork: ContractData = oldNetworks[this._networkId];
|
const oldNetwork: ContractData = oldNetworks[this._networkId];
|
||||||
shouldCompile =
|
shouldCompile =
|
||||||
_.isUndefined(oldNetwork) ||
|
(_.isUndefined(oldNetwork) ||
|
||||||
oldNetwork.keccak256 !== sourceHash ||
|
oldNetwork.keccak256 !== sourceHash ||
|
||||||
oldNetwork.optimizer_enabled !== this._optimizerEnabled;
|
oldNetwork.optimizer_enabled !== this._optimizerEnabled) &&
|
||||||
|
isContractSpecified;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
shouldCompile = true;
|
shouldCompile = isContractSpecified;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!shouldCompile) {
|
if (!shouldCompile) {
|
||||||
|
3
packages/deployer/src/globals.d.ts
vendored
3
packages/deployer/src/globals.d.ts
vendored
@@ -1,8 +1,11 @@
|
|||||||
declare module 'solc' {
|
declare module 'solc' {
|
||||||
|
// tslint:disable:completed-docs
|
||||||
export function compile(sources: any, optimizerEnabled: number, findImports: (importPath: string) => any): any;
|
export function compile(sources: any, optimizerEnabled: number, findImports: (importPath: string) => any): any;
|
||||||
export function setupMethods(solcBin: any): any;
|
export function setupMethods(solcBin: any): any;
|
||||||
|
// tslint:enable:completed-docs
|
||||||
}
|
}
|
||||||
|
|
||||||
declare module 'web3-eth-abi' {
|
declare module 'web3-eth-abi' {
|
||||||
|
// tslint:disable-next-line:completed-docs
|
||||||
export function encodeParameters(typesArray: string[], parameters: any[]): string;
|
export function encodeParameters(typesArray: string[], parameters: any[]): string;
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { constants } from '../../utils/constants';
|
|
||||||
import { Token } from '../../types';
|
import { Token } from '../../types';
|
||||||
|
import { constants } from '../../utils/constants';
|
||||||
|
|
||||||
export const tokenInfo: Token[] = [
|
export const tokenInfo: Token[] = [
|
||||||
{
|
{
|
||||||
|
@@ -4,6 +4,7 @@ import * as _ from 'lodash';
|
|||||||
|
|
||||||
import { Deployer } from '../deployer';
|
import { Deployer } from '../deployer';
|
||||||
import { constants } from '../utils/constants';
|
import { constants } from '../utils/constants';
|
||||||
|
|
||||||
import { tokenInfo } from './config/token_info';
|
import { tokenInfo } from './config/token_info';
|
||||||
|
|
||||||
export const migrator = {
|
export const migrator = {
|
||||||
|
@@ -50,6 +50,7 @@ export interface CompilerOptions {
|
|||||||
networkId: number;
|
networkId: number;
|
||||||
optimizerEnabled: number;
|
optimizerEnabled: number;
|
||||||
artifactsDir: string;
|
artifactsDir: string;
|
||||||
|
specifiedContracts: Set<string>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DeployerOptions {
|
export interface DeployerOptions {
|
||||||
|
@@ -5,6 +5,7 @@ import { Compiler } from '../src/compiler';
|
|||||||
import { Deployer } from '../src/deployer';
|
import { Deployer } from '../src/deployer';
|
||||||
import { fsWrapper } from '../src/utils/fs_wrapper';
|
import { fsWrapper } from '../src/utils/fs_wrapper';
|
||||||
import { CompilerOptions, ContractArtifact, ContractData, DoneCallback } from '../src/utils/types';
|
import { CompilerOptions, ContractArtifact, ContractData, DoneCallback } from '../src/utils/types';
|
||||||
|
|
||||||
import { constructor_args, exchange_binary } from './fixtures/exchange_bin';
|
import { constructor_args, exchange_binary } from './fixtures/exchange_bin';
|
||||||
import { constants } from './util/constants';
|
import { constants } from './util/constants';
|
||||||
|
|
||||||
@@ -17,6 +18,7 @@ const compilerOpts: CompilerOptions = {
|
|||||||
contractsDir,
|
contractsDir,
|
||||||
networkId: constants.networkId,
|
networkId: constants.networkId,
|
||||||
optimizerEnabled: constants.optimizerEnabled,
|
optimizerEnabled: constants.optimizerEnabled,
|
||||||
|
specifiedContracts: new Set(constants.specifiedContracts),
|
||||||
};
|
};
|
||||||
const compiler = new Compiler(compilerOpts);
|
const compiler = new Compiler(compilerOpts);
|
||||||
const deployerOpts = {
|
const deployerOpts = {
|
||||||
|
@@ -8,4 +8,5 @@ export const constants = {
|
|||||||
timeoutMs: 20000,
|
timeoutMs: 20000,
|
||||||
zrxTokenAddress: '0xe41d2489571d322189246dafa5ebde1f4699f498',
|
zrxTokenAddress: '0xe41d2489571d322189246dafa5ebde1f4699f498',
|
||||||
tokenTransferProxyAddress: '0x8da0d80f5007ef1e431dd2127178d224e32c2ef4',
|
tokenTransferProxyAddress: '0x8da0d80f5007ef1e431dd2127178d224e32c2ef4',
|
||||||
|
specifiedContracts: '*',
|
||||||
};
|
};
|
||||||
|
3
packages/deployer/tslint.json
Normal file
3
packages/deployer/tslint.json
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"extends": ["@0xproject/tslint-config"]
|
||||||
|
}
|
5
packages/dev-utils/.npmignore
Normal file
5
packages/dev-utils/.npmignore
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
.*
|
||||||
|
yarn-error.log
|
||||||
|
/src/
|
||||||
|
/scripts/
|
||||||
|
tsconfig.json
|
@@ -1,5 +1,13 @@
|
|||||||
# CHANGELOG
|
# CHANGELOG
|
||||||
|
|
||||||
|
## v0.1.0 - _February 16, 2018_
|
||||||
|
|
||||||
|
* Remove subproviders (#392)
|
||||||
|
|
||||||
|
## v0.0.12 - _February 9, 2018_
|
||||||
|
|
||||||
|
* Fix publishing issue where .npmignore was not properly excluding undesired content (#389)
|
||||||
|
|
||||||
## v0.0.11 - _February 7, 2018_
|
## v0.0.11 - _February 7, 2018_
|
||||||
|
|
||||||
* Updated `types-ethereumjs-util` dev dependency (#352)
|
* Updated `types-ethereumjs-util` dev dependency (#352)
|
||||||
|
@@ -1,14 +1,17 @@
|
|||||||
{
|
{
|
||||||
"name": "@0xproject/dev-utils",
|
"name": "@0xproject/dev-utils",
|
||||||
"version": "0.0.11",
|
"version": "0.0.13",
|
||||||
"description": "0x dev TS utils",
|
"description": "0x dev TS utils",
|
||||||
"main": "lib/index.js",
|
"main": "lib/src/index.js",
|
||||||
"types": "lib/index.d.ts",
|
"types": "lib/src/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build:watch": "tsc -w",
|
"build:watch": "tsc -w",
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
|
"test": "run-s clean build run_mocha",
|
||||||
|
"test:circleci": "yarn test",
|
||||||
|
"run_mocha": "mocha lib/test/**/*_test.js --bail --exit",
|
||||||
"clean": "shx rm -rf lib",
|
"clean": "shx rm -rf lib",
|
||||||
"lint": "tslint --project . 'src/**/*.ts'"
|
"lint": "tslint --project . 'src/**/*.ts' 'test/**/*.ts'"
|
||||||
},
|
},
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -20,9 +23,14 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/0xProject/0x.js/packages/dev-utils/README.md",
|
"homepage": "https://github.com/0xProject/0x.js/packages/dev-utils/README.md",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@0xproject/tslint-config": "^0.4.7",
|
"@types/mocha": "^2.2.42",
|
||||||
"@0xproject/types": "^0.2.0",
|
"@0xproject/tslint-config": "^0.4.9",
|
||||||
|
"@0xproject/types": "^0.2.2",
|
||||||
|
"@0xproject/web3-wrapper": "^0.1.13",
|
||||||
"@types/lodash": "^4.14.86",
|
"@types/lodash": "^4.14.86",
|
||||||
|
"chai": "^4.0.1",
|
||||||
|
"chai-typescript-typings": "^0.0.3",
|
||||||
|
"mocha": "^4.0.1",
|
||||||
"npm-run-all": "^4.1.2",
|
"npm-run-all": "^4.1.2",
|
||||||
"shx": "^0.2.2",
|
"shx": "^0.2.2",
|
||||||
"tslint": "5.8.0",
|
"tslint": "5.8.0",
|
||||||
@@ -31,7 +39,8 @@
|
|||||||
"typescript": "2.7.1"
|
"typescript": "2.7.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@0xproject/utils": "^0.3.1",
|
"@0xproject/utils": "^0.3.3",
|
||||||
|
"@0xproject/subproviders": "^0.4.2",
|
||||||
"ethereumjs-util": "^5.1.2",
|
"ethereumjs-util": "^5.1.2",
|
||||||
"lodash": "^4.17.4",
|
"lodash": "^4.17.4",
|
||||||
"request-promise-native": "^1.0.5",
|
"request-promise-native": "^1.0.5",
|
||||||
|
@@ -2,14 +2,4 @@ const postpublish_utils = require('../../../scripts/postpublish_utils');
|
|||||||
const packageJSON = require('../package.json');
|
const packageJSON = require('../package.json');
|
||||||
|
|
||||||
const subPackageName = packageJSON.name;
|
const subPackageName = packageJSON.name;
|
||||||
|
postpublish_utils.standardPostPublishAsync(subPackageName);
|
||||||
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;
|
|
||||||
});
|
|
@@ -6,8 +6,7 @@
|
|||||||
import ProviderEngine = require('web3-provider-engine');
|
import ProviderEngine = require('web3-provider-engine');
|
||||||
import RpcSubprovider = require('web3-provider-engine/subproviders/rpc');
|
import RpcSubprovider = require('web3-provider-engine/subproviders/rpc');
|
||||||
|
|
||||||
import { EmptyWalletSubprovider } from './subproviders/empty_wallet_subprovider';
|
import { EmptyWalletSubprovider, FakeGasEstimateSubprovider } from '@0xproject/subproviders';
|
||||||
import { FakeGasEstimateSubprovider } from './subproviders/fake_gas_estimate_subprovider';
|
|
||||||
|
|
||||||
import { constants } from './constants';
|
import { constants } from './constants';
|
||||||
|
|
||||||
|
27
packages/dev-utils/test/blockchain_lifecycle_test.ts
Normal file
27
packages/dev-utils/test/blockchain_lifecycle_test.ts
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import { BlockParamLiteral } from '@0xproject/types';
|
||||||
|
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||||
|
import * as chai from 'chai';
|
||||||
|
import 'mocha';
|
||||||
|
|
||||||
|
import { BlockchainLifecycle, RPC, web3Factory } from '../src';
|
||||||
|
|
||||||
|
const expect = chai.expect;
|
||||||
|
|
||||||
|
describe('BlockchainLifecycle tests', () => {
|
||||||
|
const web3 = web3Factory.create();
|
||||||
|
const web3Wrapper = new Web3Wrapper(web3.currentProvider);
|
||||||
|
const rpc = new RPC();
|
||||||
|
const blockchainLifecycle = new BlockchainLifecycle();
|
||||||
|
describe('#startAsync/revertAsync', () => {
|
||||||
|
it('reverts changes in between', async () => {
|
||||||
|
const blockNumberBefore = await web3Wrapper.getBlockNumberAsync();
|
||||||
|
await blockchainLifecycle.startAsync();
|
||||||
|
await rpc.mineBlockAsync();
|
||||||
|
const blockNumberAfter = await web3Wrapper.getBlockNumberAsync();
|
||||||
|
expect(blockNumberAfter).to.be.equal(blockNumberBefore + 1);
|
||||||
|
await blockchainLifecycle.revertAsync();
|
||||||
|
const blockNumberAfterRevert = await web3Wrapper.getBlockNumberAsync();
|
||||||
|
expect(blockNumberAfterRevert).to.be.equal(blockNumberBefore);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
42
packages/dev-utils/test/rpc_test.ts
Normal file
42
packages/dev-utils/test/rpc_test.ts
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
import { BlockParamLiteral } from '@0xproject/types';
|
||||||
|
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||||
|
import * as chai from 'chai';
|
||||||
|
import 'mocha';
|
||||||
|
|
||||||
|
import { RPC, web3Factory } from '../src';
|
||||||
|
|
||||||
|
const expect = chai.expect;
|
||||||
|
|
||||||
|
describe('RPC tests', () => {
|
||||||
|
const web3 = web3Factory.create();
|
||||||
|
const web3Wrapper = new Web3Wrapper(web3.currentProvider);
|
||||||
|
const rpc = new RPC();
|
||||||
|
describe('#mineBlockAsync', () => {
|
||||||
|
it('increases block number when called', async () => {
|
||||||
|
const blockNumberBefore = await web3Wrapper.getBlockNumberAsync();
|
||||||
|
await rpc.mineBlockAsync();
|
||||||
|
const blockNumberAfter = await web3Wrapper.getBlockNumberAsync();
|
||||||
|
expect(blockNumberAfter).to.be.equal(blockNumberBefore + 1);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe('#increaseTimeAsync', () => {
|
||||||
|
it('increases time when called', async () => {
|
||||||
|
const TIME_DELTA = 1000;
|
||||||
|
const blockTimestampBefore = await web3Wrapper.getBlockTimestampAsync(BlockParamLiteral.Latest);
|
||||||
|
await rpc.increaseTimeAsync(TIME_DELTA);
|
||||||
|
await rpc.mineBlockAsync();
|
||||||
|
const blockTimestampAfter = await web3Wrapper.getBlockTimestampAsync(BlockParamLiteral.Latest);
|
||||||
|
expect(blockTimestampAfter).to.be.at.least(blockTimestampBefore + TIME_DELTA);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe('#takeSnapshotAsync/revertSnapshotAsync', () => {
|
||||||
|
it('reverts changes in between', async () => {
|
||||||
|
const blockNumberBefore = await web3Wrapper.getBlockNumberAsync();
|
||||||
|
const snapshotId = await rpc.takeSnapshotAsync();
|
||||||
|
await rpc.mineBlockAsync();
|
||||||
|
await rpc.revertSnapshotAsync(snapshotId);
|
||||||
|
const blockNumberAfter = await web3Wrapper.getBlockNumberAsync();
|
||||||
|
expect(blockNumberAfter).to.be.equal(blockNumberBefore);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@@ -5,7 +5,9 @@
|
|||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"./src/**/*",
|
"./src/**/*",
|
||||||
|
"./test/**/*",
|
||||||
"../../node_modules/types-bn/index.d.ts",
|
"../../node_modules/types-bn/index.d.ts",
|
||||||
|
"../../node_modules/chai-typescript-typings/index.d.ts",
|
||||||
"../../node_modules/web3-typescript-typings/index.d.ts",
|
"../../node_modules/web3-typescript-typings/index.d.ts",
|
||||||
"../../node_modules/types-ethereumjs-util/index.d.ts"
|
"../../node_modules/types-ethereumjs-util/index.d.ts"
|
||||||
]
|
]
|
||||||
|
7
packages/json-schemas/.npmignore
Normal file
7
packages/json-schemas/.npmignore
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
.*
|
||||||
|
yarn-error.log
|
||||||
|
/src/
|
||||||
|
/scripts/
|
||||||
|
/schemas/
|
||||||
|
test/
|
||||||
|
tsconfig.json
|
@@ -1,5 +1,9 @@
|
|||||||
# CHANGELOG
|
# 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_
|
## v0.7.0 - _December 20, 2017_
|
||||||
|
|
||||||
* Rename `subscriptionOptsSchema` to `blockRangeSchema` (#272)
|
* Rename `subscriptionOptsSchema` to `blockRangeSchema` (#272)
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@0xproject/json-schemas",
|
"name": "@0xproject/json-schemas",
|
||||||
"version": "0.7.9",
|
"version": "0.7.11",
|
||||||
"description": "0x-related json schemas",
|
"description": "0x-related json schemas",
|
||||||
"main": "lib/src/index.js",
|
"main": "lib/src/index.js",
|
||||||
"types": "lib/src/index.d.ts",
|
"types": "lib/src/index.d.ts",
|
||||||
@@ -28,13 +28,13 @@
|
|||||||
"lodash.values": "^4.3.0"
|
"lodash.values": "^4.3.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@0xproject/tslint-config": "^0.4.7",
|
"@0xproject/tslint-config": "^0.4.9",
|
||||||
"@0xproject/utils": "^0.3.1",
|
"@0xproject/utils": "^0.3.3",
|
||||||
"@types/lodash.foreach": "^4.5.3",
|
"@types/lodash.foreach": "^4.5.3",
|
||||||
"@types/lodash.values": "^4.3.3",
|
"@types/lodash.values": "^4.3.3",
|
||||||
"@types/mocha": "^2.2.42",
|
"@types/mocha": "^2.2.42",
|
||||||
"chai": "^4.0.1",
|
"chai": "^4.0.1",
|
||||||
"chai-typescript-typings": "^0.0.2",
|
"chai-typescript-typings": "^0.0.3",
|
||||||
"dirty-chai": "^2.0.1",
|
"dirty-chai": "^2.0.1",
|
||||||
"lodash.foreach": "^4.5.0",
|
"lodash.foreach": "^4.5.0",
|
||||||
"mocha": "^4.0.1",
|
"mocha": "^4.0.1",
|
||||||
|
@@ -2,14 +2,4 @@ const postpublish_utils = require('../../../scripts/postpublish_utils');
|
|||||||
const packageJSON = require('../package.json');
|
const packageJSON = require('../package.json');
|
||||||
|
|
||||||
const subPackageName = packageJSON.name;
|
const subPackageName = packageJSON.name;
|
||||||
|
postpublish_utils.standardPostPublishAsync(subPackageName);
|
||||||
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;
|
|
||||||
});
|
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@0xproject/monorepo-scripts",
|
"name": "@0xproject/monorepo-scripts",
|
||||||
"version": "0.1.9",
|
"version": "0.1.11",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "Helper scripts for the monorepo",
|
"description": "Helper scripts for the monorepo",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/0xProject/0x.js/packages/monorepo-scripts/README.md",
|
"homepage": "https://github.com/0xProject/0x.js/packages/monorepo-scripts/README.md",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@0xproject/tslint-config": "^0.4.7",
|
"@0xproject/tslint-config": "^0.4.9",
|
||||||
"@types/glob": "^5.0.33",
|
"@types/glob": "^5.0.33",
|
||||||
"@types/node": "^8.0.53",
|
"@types/node": "^8.0.53",
|
||||||
"shx": "^0.2.2",
|
"shx": "^0.2.2",
|
||||||
|
@@ -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;
|
|
||||||
});
|
|
6
packages/subproviders/.npmignore
Normal file
6
packages/subproviders/.npmignore
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
.*
|
||||||
|
yarn-error.log
|
||||||
|
/src/
|
||||||
|
/scripts/
|
||||||
|
test/
|
||||||
|
tsconfig.json
|
@@ -1,5 +1,13 @@
|
|||||||
# CHANGELOG
|
# CHANGELOG
|
||||||
|
|
||||||
|
## v0.5.0 - _February 16, 2018_
|
||||||
|
|
||||||
|
* Add EmptyWalletSubprovider and FakeGasEstimateSubprovider (#392)
|
||||||
|
|
||||||
|
## v0.4.1 - _February 9, 2018_
|
||||||
|
|
||||||
|
* Fix publishing issue where .npmignore was not properly excluding undesired content (#389)
|
||||||
|
|
||||||
## v0.4.0 - _February 7, 2018_
|
## v0.4.0 - _February 7, 2018_
|
||||||
|
|
||||||
* Added NonceTrackerSubprovider (#355)
|
* Added NonceTrackerSubprovider (#355)
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user