Compare commits

..

119 Commits

Author SHA1 Message Date
Brandon Millman
d12352972e Updated CHANGELOGs 2018-02-16 09:49:02 -07:00
Brandon Millman
03d3d84db3 Merge pull request #406 from 0xProject/feature/connect/heartbeat
Add configurable heartbeat to WebSocketOrderbookChannel
2018-02-16 08:10:00 -08:00
Brandon Millman
6d818c25c7 Add an enforced minimum for the heartbeat interval 2018-02-16 08:48:15 -07:00
Fabio Berger
6a8f624e75 Add Rinkeby network to smart contract docs 2018-02-16 08:47:27 -07:00
Fabio Berger
0801b1ddf9 Updated CHANGELOG 2018-02-16 08:47:10 -07:00
Fabio Berger
4fd64ca492 Merge pull request #405 from 0xProject/refactor/docs-redesign
Re-design Wiki + Doc pages
2018-02-16 07:45:55 -08:00
Brandon Millman
c4bcf24640 Add configurable heartbeat to WebSocketOrderbookChannel 2018-02-16 01:20:27 -07:00
Fabio Berger
0114fc9608 remove hard-coded color 2018-02-16 00:12:27 -07:00
Fabio Berger
8db098eaec Remove section links until they go somewhere 2018-02-16 00:09:10 -07:00
Fabio Berger
05c3a66543 Add more padding on top of section title 2018-02-16 00:08:57 -07:00
Fabio Berger
9349752baa Add hack comment explaining param count short-cut 2018-02-15 23:56:19 -07:00
Fabio Berger
974fab7284 replace repeated conditionals with variable 2018-02-15 23:54:36 -07:00
Fabio Berger
8a52ffe7b7 Remove unneeded props 2018-02-15 23:52:49 -07:00
Fabio Berger
c6ecdbd86e use const over hard-coding 2018-02-15 23:52:40 -07:00
Fabio Berger
03797545f9 uncomment dev logic 2018-02-15 23:51:10 -07:00
Fabio Berger
2778f96483 Re-design docs pages 2018-02-15 21:51:49 -07:00
Fabio Berger
6cd4e7a17e Add icons for all doc pages 2018-02-15 21:51:37 -07:00
Fabio Berger
5c91b4bfc6 Re-designed Wiki and half-redesigned docs pages 2018-02-15 20:12:47 -07:00
Fabio Berger
e2b51c5dc4 Merge branch 'development' of github.com:0xProject/0x.js into development
* 'development' of github.com:0xProject/0x.js: (24 commits)
  Rename variables
  Update CHANGELOG
  Add npm config for contracts list
  Run prettier
  Fix checks, add contract list to compile script in package.json
  Add contracts to compiler options
  Add missing public types from connect docs
  Change imports order
  Change default page params in connect to page 1 and perPage 100
  Add docs staging to 0x.js package
  Fix a typo
  Add an assertion
  Add PR numbers
  Fix entry points
  Add tests for dev-utils package
  Move subproviders from dev-utils to subproviders
  Add missing CHANGELOG entry
  Add support for intersection types in docs
  Add stagedocs script to connect package
  web3 typings fix - web3.net.peerCount returns number
  ...
2018-02-15 20:09:53 -07:00
Fabio Berger
b610b7c192 Prettier fixes 2018-02-15 20:09:24 -07:00
Amir Bandeali
b75fdd6b66 Merge pull request #400 from 0xProject/feature/deployer/selectContracts
Pass in contracts to compile in deployer
2018-02-15 12:27:43 -08:00
Amir Bandeali
060b02eaed Rename variables 2018-02-15 10:20:03 -08:00
Amir Bandeali
003e5da00d Update CHANGELOG 2018-02-15 10:13:06 -08:00
Amir Bandeali
02951d4813 Add npm config for contracts list 2018-02-15 10:13:06 -08:00
Amir Bandeali
db52ed9941 Run prettier 2018-02-15 10:13:06 -08:00
Amir Bandeali
af333b1838 Fix checks, add contract list to compile script in package.json 2018-02-15 10:13:06 -08:00
Amir Bandeali
f62762bd0e Add contracts to compiler options 2018-02-15 10:13:06 -08:00
Brandon Millman
4b67352278 Add missing public types from connect docs 2018-02-15 00:18:48 -08:00
Leonid
e22788abe8 Merge pull request #392 from 0xProject/feature/subproviders_move
Move subproviders from dev-utils to subproviders package and add tests for dev-utils
2018-02-15 00:13:12 +01:00
Leonid Logvinov
bbfbfcda85 Change imports order 2018-02-14 15:03:52 -08:00
Brandon Millman
0dfb36e675 Merge pull request #398 from 0xProject/feature/website/stage-documentation
Add support for intersection types and staged connect documentation
2018-02-14 14:45:33 -08:00
Brandon Millman
95a9d77301 Change default page params in connect to page 1 and perPage 100 2018-02-14 14:43:43 -08:00
Leonid
ab1f070901 Merge pull request #386 from 0xProject/fix/windows_install
Use system-independent rm command
2018-02-14 23:38:48 +01:00
Brandon Millman
8201d5d1f8 Add docs staging to 0x.js package 2018-02-14 14:35:31 -08:00
Leonid Logvinov
8704c34a0f Fix a typo 2018-02-14 11:54:20 -08:00
Leonid Logvinov
599adaf1bf Add an assertion 2018-02-14 11:53:40 -08:00
Leonid Logvinov
778e399438 Add PR numbers 2018-02-14 11:51:26 -08:00
Leonid Logvinov
485ae4d997 Fix entry points 2018-02-14 11:51:26 -08:00
Leonid Logvinov
8cd2ba3ad6 Add tests for dev-utils package 2018-02-14 11:51:26 -08:00
Leonid Logvinov
dbad7d1869 Move subproviders from dev-utils to subproviders 2018-02-14 11:51:26 -08:00
Leonid Logvinov
18e1c2dea5 Add missing CHANGELOG entry 2018-02-14 10:23:20 -08:00
Leonid
91ae01e484 Merge pull request #397 from gagarin55/typings-fix
web3-typescript-typings fix - web3.net.peerCount returns number
2018-02-14 19:19:48 +01:00
Brandon Millman
2897b72967 Add support for intersection types in docs 2018-02-14 10:16:00 -08:00
Brandon Millman
3510985cf4 Add stagedocs script to connect package 2018-02-14 10:15:53 -08:00
gagarin55
5927e65045 web3 typings fix - web3.net.peerCount returns number 2018-02-14 16:18:49 +03:00
Brandon Millman
13e2041d50 Merge pull request #394 from 0xProject/feature/connect/add-pagination
Add page options to relevant HttpClient methods
2018-02-13 17:30:46 -08:00
Brandon Millman
4bf530ed9e Fix error in paged request schema 2018-02-13 16:55:48 -08:00
Brandon Millman
4c797405ad Addressed PR feedback 2018-02-13 15:50:28 -08:00
Brandon Millman
713c922e35 Add page options to relevant HttpClient methods 2018-02-13 14:15:54 -08:00
Leonid
7f1e789264 Merge branch 'development' into fix/windows_install 2018-02-12 15:01:24 +01:00
Fabio Berger
07d00cc515 Publish
- 0x.js@0.32.3
 - @0xproject/abi-gen@0.2.2
 - @0xproject/assert@0.0.19
 - @0xproject/connect@0.5.8
 - contracts@2.1.12
 - @0xproject/deployer@0.0.9
 - @0xproject/dev-utils@0.0.13
 - @0xproject/json-schemas@0.7.11
 - @0xproject/monorepo-scripts@0.1.11
 - @0xproject/subproviders@0.4.2
 - @0xproject/testnet-faucets@1.0.13
 - @0xproject/tslint-config@0.4.9
 - @0xproject/types@0.2.2
 - @0xproject/utils@0.3.3
 - @0xproject/web3-wrapper@0.1.13
 - @0xproject/website@0.0.15
2018-02-09 18:36:51 -08:00
Fabio Berger
cd55e346af Move tslint and tslint-eslint-rules to dev deps since this package needs them to function 2018-02-09 18:12:29 -08:00
Fabio Berger
6746428fb1 Update utils in top-level package.json 2018-02-09 16:29:09 -08:00
Fabio Berger
634032d5be Publish
- 0x.js@0.32.2
 - @0xproject/abi-gen@0.2.1
 - @0xproject/assert@0.0.18
 - chai-as-promised-typescript-typings@0.0.9
 - chai-typescript-typings@0.0.3
 - @0xproject/connect@0.5.7
 - contracts@2.1.11
 - @0xproject/deployer@0.0.8
 - @0xproject/dev-utils@0.0.12
 - @0xproject/json-schemas@0.7.10
 - @0xproject/monorepo-scripts@0.1.10
 - @0xproject/subproviders@0.4.1
 - @0xproject/testnet-faucets@1.0.12
 - @0xproject/tslint-config@0.4.8
 - @0xproject/types@0.2.1
 - @0xproject/utils@0.3.2
 - web3-typescript-typings@0.9.10
 - @0xproject/web3-wrapper@0.1.12
 - @0xproject/website@0.0.14
2018-02-09 16:19:43 -08:00
Fabio Berger
602abc53dd Fix version in CHANGELOG 2018-02-09 16:18:47 -08:00
Fabio Berger
fdbaa9768a Update changelog version 2018-02-09 16:09:53 -08:00
Fabio Berger
293d7261e0 Fix changelog version 2018-02-09 16:08:26 -08:00
Fabio Berger
efb6eb28ce Merge pull request #389 from 0xProject/fix/npmInclusionIssues
Fix NPM Inclusion Issues
2018-02-09 14:39:05 -08:00
Fabio Berger
ac5531ce85 Fix changelogs 2018-02-09 14:26:48 -08:00
Fabio Berger
bc2415c70e Add yarn-error.log to all .npmignore 2018-02-09 14:03:08 -08:00
Fabio Berger
0fd411f83f Add PR number to CHANGELOGs 2018-02-09 13:31:01 -08:00
Fabio Berger
b74ad0ad12 ignore all files starting with dots in all sub-packages 2018-02-09 13:28:32 -08:00
Fabio Berger
4c58836735 Remove top level .npmignore 2018-02-09 13:19:30 -08:00
Fabio Berger
3206b80dbd Add npmignore to web3-wrapper and update CHANGELOG 2018-02-09 13:18:49 -08:00
Fabio Berger
4910f7a61e Add npmignore and remove .gitignore 2018-02-09 13:16:16 -08:00
Fabio Berger
6e9109eaec Add npmignore to utils and update CHANGELOG 2018-02-09 13:14:31 -08:00
Fabio Berger
a04ec14cf0 Add npmignore to types and update CHANGELOG 2018-02-09 13:12:33 -08:00
Fabio Berger
7d3df3c117 cleanup npmignorex 2018-02-09 13:09:57 -08:00
Fabio Berger
b3a03f8e3e Add npmignore to subproviders and update CHANGELOG 2018-02-09 13:09:00 -08:00
Fabio Berger
e5668c1e5c Add npmignore to json-schemas and update CHANGELOG 2018-02-09 13:05:21 -08:00
Fabio Berger
92e74bc4fa Add npmignore to dev-utils and update CHANGELOG 2018-02-09 12:56:48 -08:00
Fabio Berger
7e12269baf Add npmignore to deployer along with a changelog 2018-02-09 12:52:12 -08:00
Fabio Berger
f3f264f5fd Add tslint.json to deployer package and fix all tslint issues 2018-02-09 12:50:37 -08:00
Brandon Millman
2e3c9b87df Merge pull request #388 from 0xProject/fix/testnet-faucet/base-unit-orders
Convert to baseUnits in signed order
2018-02-09 12:39:43 -08:00
Fabio Berger
0a113e1cf7 Add npmignore to subpackage and update CHANGELOG 2018-02-09 12:37:28 -08:00
Fabio Berger
fd772c48cf Add npmignore to typings packages 2018-02-09 12:37:18 -08:00
Fabio Berger
1c7dce6054 Add npmignore to subpackage and update CHANGELOG 2018-02-09 12:30:06 -08:00
Jacob Evans
0a2947b860 address is not optional in this context 2018-02-09 12:27:28 -08:00
Fabio Berger
c80877af43 Add npmignore to abi-gen and update CHANGELOG 2018-02-09 12:23:03 -08:00
Jacob Evans
e68b9c7e81 Convert to baseUnits in signed order 2018-02-09 12:20:25 -08:00
Fabio Berger
19198737a5 Add correct npmignore to 0x.js and update CHANGELOG 2018-02-09 12:18:23 -08:00
Brandon Millman
fea4b6aecd Merge pull request #387 from 0xProject/fix/testnet-faucet/ecsignature
Testnet Faucet Order conforming to JSON Schema
2018-02-09 12:01:59 -08:00
Fabio Berger
20e2673b82 Fix issue where custom TSLint rules were not being published to NPM 2018-02-09 11:53:38 -08:00
Jacob Evans
ef1375b9dd signature -> ecSignature 2018-02-09 10:50:38 -08:00
Brandon Millman
58f1939ec1 Merge pull request #382 from 0xProject/feature/clean-post-publish-scripts
Simplify standard postpublish script and remove them from some privat…
2018-02-09 10:19:33 -08:00
Leonid Logvinov
ba57c34adb Use system-independent rm command 2018-02-09 11:49:01 +01:00
Leonid
936f6ac10f Merge pull request #379 from 0xProject/portal_json
Make portal order JSON compatible with 0x.js
2018-02-09 09:27:08 +01:00
Fabio Berger
7e04c4f24b Merge pull request #383 from 0xProject/fix/website/addMoreRelayersLanding
Add relayers section to landing page
2018-02-08 18:41:16 -08:00
Fabio Berger
9495c8f46c Fix links 2018-02-08 18:40:06 -08:00
Fabio Berger
b3f91600d3 Center header above relayers 2018-02-08 17:53:31 -08:00
Fabio Berger
ddf4437fb6 Add blog to topBar and as a consequence support external links in topBar menu items 2018-02-08 17:36:17 -08:00
Fabio Berger
4153d57849 Add title above "benefits" section 2018-02-08 16:27:47 -08:00
Fabio Berger
0652790703 Add Relayer section to landing 2018-02-08 16:27:37 -08:00
Brandon Millman
9c934d903d Add new entries to the PR template checklist 2018-02-08 16:20:02 -08:00
Brandon Millman
d7a7e28925 Fix missing references to 'this' 2018-02-08 12:02:13 -08:00
Brandon Millman
6dec29e214 Simplify standard postpublish script and remove them from some private packages 2018-02-08 11:46:33 -08:00
Leonid Logvinov
43cf8d30bd Implement blockchain.portalOrderToZeroExOrder 2018-02-08 18:28:54 +01:00
Leonid
254d3f53e2 Merge pull request #377 from 0xProject/feature/signed_unsigned_order_contracts
Use SignedOrder and Order types from 0x.js
2018-02-08 18:15:10 +01:00
Leonid Logvinov
ec198343b5 Make naming of schemas consistent 2018-02-08 18:14:52 +01:00
Leonid Logvinov
876517d458 Fix namings 2018-02-08 18:03:55 +01:00
Leonid Logvinov
1233c33116 Address feedback 2018-02-08 16:23:20 +01:00
Fabio Berger
eebf205817 Fix flash message when receiving test ether 2018-02-07 16:58:05 -08:00
Brandon Millman
e666bb44c6 Fix incorrect network ids 2018-02-07 16:05:14 -08:00
Brandon Millman
39cb0b5122 Update @0xproject/utils version in top level package.json 2018-02-07 13:36:48 -08:00
Brandon Millman
58003a2811 Publish
- 0x.js@0.32.1
 - @0xproject/abi-gen@0.2.0
 - @0xproject/assert@0.0.17
 - @0xproject/connect@0.5.6
 - contracts@2.1.10
 - @0xproject/deployer@0.0.7
 - @0xproject/dev-utils@0.0.11
 - @0xproject/json-schemas@0.7.9
 - @0xproject/subproviders@0.4.0
 - @0xproject/testnet-faucets@1.0.11
 - @0xproject/types@0.2.0
 - @0xproject/utils@0.3.1
 - @0xproject/web3-wrapper@0.1.11
 - @0xproject/website@0.0.13
2018-02-07 13:25:39 -08:00
Leonid Logvinov
8fba0477a6 Remove hash from signatureData 2018-02-07 20:58:19 +01:00
Leonid Logvinov
e6f2c7a382 Remove networkId from orderJSON 2018-02-07 20:38:30 +01:00
Leonid Logvinov
69f5f5e946 Split Order into signedOrder and metadata 2018-02-07 20:26:13 +01:00
Leonid Logvinov
ae14b0a71d Reuse ECSignature 2018-02-07 16:13:09 +01:00
Leonid Logvinov
3c7ebe2697 Remove unused types and take their names 2018-02-07 16:11:51 +01:00
Leonid Logvinov
10fb6061cc Introduce makerToken and takerToken fields for unsigned token metadata 2018-02-07 15:26:53 +01:00
Leonid Logvinov
223df8006a Move .taker.amount to .takerTokenAmount and .maker.amount to .makerTokenAmount 2018-02-07 15:09:06 +01:00
Leonid Logvinov
1c9428cbba Move .taker.feeAmount to .takerFee and .maker.feeAmount to .makerFee 2018-02-07 15:02:41 +01:00
Leonid Logvinov
18dc5d17b5 Rename signature to ecSignature 2018-02-07 14:54:37 +01:00
Leonid Logvinov
4d50933189 Rename exchangeContract to exchangeContractAddress 2018-02-07 14:48:59 +01:00
Leonid Logvinov
9b3680780f Rename expiration to expirationUnixTimestampSec 2018-02-07 14:41:40 +01:00
Leonid Logvinov
568e4d33f2 Use Order and SignedOrder type from 0x.js 2018-02-07 13:41:30 +01:00
Leonid Logvinov
fd004032cb Introduce SignedOrder class and remove type assertions 2018-02-07 12:22:22 +01:00
Leonid Logvinov
4b6324050d Make orderHashHex a getter instead of a property 2018-02-07 11:59:40 +01:00
193 changed files with 2051 additions and 3028 deletions

View File

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

View File

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

View File

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

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

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

View File

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

View File

@@ -1,6 +1,6 @@
{
"name": "0x.js",
"version": "0.32.0",
"version": "0.32.3",
"description": "A javascript library for interacting with the 0x protocol",
"keywords": [
"0x.js",
@@ -42,9 +42,9 @@
"node": ">=6.0.0"
},
"devDependencies": {
"@0xproject/abi-gen": "^0.1.7",
"@0xproject/dev-utils": "^0.0.10",
"@0xproject/tslint-config": "^0.4.7",
"@0xproject/abi-gen": "^0.2.2",
"@0xproject/dev-utils": "^0.0.13",
"@0xproject/tslint-config": "^0.4.9",
"@types/bintrees": "^1.0.2",
"@types/jsonschema": "^1.1.1",
"@types/lodash": "^4.14.86",
@@ -55,9 +55,9 @@
"awesome-typescript-loader": "^3.1.3",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"chai-as-promised-typescript-typings": "^0.0.8",
"chai-as-promised-typescript-typings": "^0.0.9",
"chai-bignumber": "^2.0.1",
"chai-typescript-typings": "^0.0.2",
"chai-typescript-typings": "^0.0.3",
"copyfiles": "^1.2.0",
"coveralls": "^3.0.0",
"dirty-chai": "^2.0.1",
@@ -77,15 +77,15 @@
"types-bn": "^0.0.1",
"typescript": "2.7.1",
"web3-provider-engine": "^13.0.1",
"web3-typescript-typings": "^0.9.9",
"web3-typescript-typings": "^0.9.10",
"webpack": "^3.1.0"
},
"dependencies": {
"@0xproject/assert": "^0.0.16",
"@0xproject/json-schemas": "^0.7.8",
"@0xproject/types": "^0.1.9",
"@0xproject/utils": "^0.3.0",
"@0xproject/web3-wrapper": "^0.1.10",
"@0xproject/assert": "^0.0.19",
"@0xproject/json-schemas": "^0.7.11",
"@0xproject/types": "^0.2.2",
"@0xproject/utils": "^0.3.3",
"@0xproject/web3-wrapper": "^0.1.13",
"bintrees": "^1.0.2",
"bn.js": "^4.11.8",
"ethereumjs-abi": "^0.6.4",

View File

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

View File

@@ -0,0 +1,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);
});

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,5 +1,14 @@
# 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_
* Sanitize api endpoint url and remove trailing slashes (#318)

View File

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

View File

@@ -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);
});

View File

@@ -13,20 +13,48 @@ import {
HttpRequestType,
OrderbookRequest,
OrderbookResponse,
OrdersRequest,
OrdersRequestOpts,
PagedRequestOpts,
SignedOrder,
TokenPairsItem,
TokenPairsRequest,
TokenPairsRequestOpts,
} from './types';
import { relayerResponseJsonParsers } from './utils/relayer_response_json_parsers';
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
* that implement the standard relayer API v0
*/
export class HttpClient implements Client {
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
* @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
* @param request A TokenPairsRequest instance describing specific token information
* to retrieve
* @param requestOpts Options specifying token information to retrieve and page information, defaults to { page: 1, perPage: 100 }
* @return The resulting TokenPairsItems that match the request
*/
public async getTokenPairsAsync(request?: TokenPairsRequest): Promise<TokenPairsItem[]> {
if (!_.isUndefined(request)) {
assert.doesConformToSchema('request', request, clientSchemas.relayerTokenPairsRequestSchema);
public async getTokenPairsAsync(requestOpts?: TokenPairsRequestOpts & PagedRequestOpts): Promise<TokenPairsItem[]> {
if (!_.isUndefined(requestOpts)) {
assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.tokenPairsRequestOptsSchema);
assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.pagedRequestOptsSchema);
}
const requestOpts = {
params: request,
const httpRequestOpts = {
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);
return tokenPairs;
}
/**
* 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
*/
public async getOrdersAsync(request?: OrdersRequest): Promise<SignedOrder[]> {
if (!_.isUndefined(request)) {
assert.doesConformToSchema('request', request, clientSchemas.relayerOrdersRequestSchema);
public async getOrdersAsync(requestOpts?: OrdersRequestOpts & PagedRequestOpts): Promise<SignedOrder[]> {
if (!_.isUndefined(requestOpts)) {
assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.ordersRequestOptsSchema);
assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.pagedRequestOptsSchema);
}
const requestOpts = {
params: request,
const httpRequestOpts = {
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);
return orders;
}
@@ -82,15 +111,22 @@ export class HttpClient implements Client {
}
/**
* 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
*/
public async getOrderbookAsync(request: OrderbookRequest): Promise<OrderbookResponse> {
assert.doesConformToSchema('request', request, clientSchemas.relayerOrderBookRequestSchema);
const requestOpts = {
params: request,
public async getOrderbookAsync(
request: OrderbookRequest,
requestOpts?: PagedRequestOpts,
): 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);
return orderbook;
}
@@ -100,11 +136,11 @@ export class HttpClient implements Client {
* @return The resulting FeesResponse that matches the request
*/
public async getFeesAsync(request: FeesRequest): Promise<FeesResponse> {
assert.doesConformToSchema('request', request, schemas.relayerApiFeesPayloadSchema);
const requestOpts = {
assert.doesConformToSchema('request', request, clientSchemas.feesRequestSchema);
const httpRequestOpts = {
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);
return fees;
}
@@ -126,11 +162,7 @@ export class HttpClient implements Client {
): Promise<any> {
const params = _.get(requestOptions, 'params');
const payload = _.get(requestOptions, 'payload');
let query = '';
if (!_.isUndefined(params) && !_.isEmpty(params)) {
const stringifiedParams = queryString.stringify(params);
query = `?${stringifiedParams}`;
}
const query = HttpClient._buildQueryStringFromHttpParams(params);
const url = `${this._apiEndpointUrl}${path}${query}`;
const headers = new Headers({
'content-type': 'application/json',

View File

@@ -11,9 +11,11 @@ export {
OrderbookChannelSubscriptionOpts,
OrderbookRequest,
OrderbookResponse,
OrdersRequest,
OrdersRequestOpts,
PagedRequestOpts,
SignedOrder,
TokenPairsItem,
TokenPairsRequest,
TokenPairsRequestOpts,
TokenTradeInfo,
WebSocketOrderbookChannelConfig,
} from './types';

View 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',
],
};

View File

@@ -1,8 +1,9 @@
export const relayerOrderBookRequestSchema = {
id: '/RelayerOrderBookRequest',
export const orderBookRequestSchema = {
id: '/OrderBookRequest',
type: 'object',
properties: {
baseTokenAddress: { $ref: '/Address' },
quoteTokenAddress: { $ref: '/Address' },
},
required: ['baseTokenAddress', 'quoteTokenAddress'],
};

View File

@@ -1,5 +1,5 @@
export const relayerOrdersRequestSchema = {
id: '/RelayerOrdersRequest',
export const ordersRequestOptsSchema = {
id: '/OrdersRequestOpts',
type: 'object',
properties: {
exchangeContractAddress: { $ref: '/Address' },

View File

@@ -0,0 +1,8 @@
export const pagedRequestOptsSchema = {
id: '/PagedRequestOpts',
type: 'object',
properties: {
page: { type: 'number' },
perPage: { type: 'number' },
},
};

View File

@@ -1,8 +0,0 @@
export const relayerOrderBookRequestSchema = {
id: '/RelayerOrderBookRequest',
type: 'object',
properties: {
baseTokenAddress: { $ref: '/Address' },
quoteTokenAddress: { $ref: '/Address' },
},
};

View File

@@ -1,9 +1,15 @@
import { relayerOrderBookRequestSchema } from './relayer_orderbook_request_schema';
import { relayerOrdersRequestSchema } from './relayer_orders_request_schema';
import { relayerTokenPairsRequestSchema } from './relayer_token_pairs_request_schema';
import { feesRequestSchema } from './fees_request_schema';
import { orderBookRequestSchema } from './orderbook_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 = {
relayerOrderBookRequestSchema,
relayerOrdersRequestSchema,
relayerTokenPairsRequestSchema,
feesRequestSchema,
orderBookRequestSchema,
ordersRequestOptsSchema,
pagedRequestOptsSchema,
tokenPairsRequestOptsSchema,
webSocketOrderbookChannelConfigSchema,
};

View File

@@ -1,5 +1,5 @@
export const relayerTokenPairsRequestSchema = {
id: '/RelayerTokenPairsRequest',
export const tokenPairsRequestOptsSchema = {
id: '/TokenPairsRequestOpts',
type: 'object',
properties: {
tokenA: { $ref: '/Address' },

View File

@@ -0,0 +1,10 @@
export const webSocketOrderbookChannelConfigSchema = {
id: '/WebSocketOrderbookChannelConfig',
type: 'object',
properties: {
heartbeatIntervalMs: {
type: 'number',
minimum: 10,
},
},
};

View File

@@ -30,10 +30,10 @@ export interface ECSignature {
}
export interface Client {
getTokenPairsAsync: (request?: TokenPairsRequest) => Promise<TokenPairsItem[]>;
getOrdersAsync: (request?: OrdersRequest) => Promise<SignedOrder[]>;
getTokenPairsAsync: (requestOpts?: TokenPairsRequestOpts & PagedRequestOpts) => Promise<TokenPairsItem[]>;
getOrdersAsync: (requestOpts?: OrdersRequestOpts & PagedRequestOpts) => Promise<SignedOrder[]>;
getOrderAsync: (orderHash: string) => Promise<SignedOrder>;
getOrderbookAsync: (request: OrderbookRequest) => Promise<OrderbookResponse>;
getOrderbookAsync: (request: OrderbookRequest, requestOpts?: PagedRequestOpts) => Promise<OrderbookResponse>;
getFeesAsync: (request: FeesRequest) => Promise<FeesResponse>;
submitOrderAsync: (signedOrder: SignedOrder) => Promise<void>;
}
@@ -43,6 +43,13 @@ export interface OrderbookChannel {
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
* 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',
}
export interface TokenPairsRequest {
export interface TokenPairsRequestOpts {
tokenA?: string;
tokenB?: string;
}
@@ -128,7 +135,7 @@ export interface TokenTradeInfo {
precision: number;
}
export interface OrdersRequest {
export interface OrdersRequestOpts {
exchangeContractAddress?: string;
tokenAddress?: string;
makerTokenAddress?: string;
@@ -167,6 +174,11 @@ export interface FeesResponse {
takerFee: BigNumber;
}
export interface PagedRequestOpts {
page?: number;
perPage?: number;
}
export interface HttpRequestOptions {
params?: object;
payload?: object;

View File

@@ -3,6 +3,7 @@ import { schemas } from '@0xproject/json-schemas';
import * as _ from 'lodash';
import * as WebSocket from 'websocket';
import { schemas as clientSchemas } from './schemas/schemas';
import {
OrderbookChannel,
OrderbookChannelHandler,
@@ -10,9 +11,13 @@ import {
OrderbookChannelSubscriptionOpts,
WebsocketClientEventType,
WebsocketConnectionEventType,
WebSocketOrderbookChannelConfig,
} from './types';
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
* that implements the standard relayer API v0
@@ -21,15 +26,25 @@ export class WebSocketOrderbookChannel implements OrderbookChannel {
private _apiEndpointUrl: string;
private _client: WebSocket.client;
private _connectionIfExists?: WebSocket.connection;
private _heartbeatTimerIfExists?: NodeJS.Timer;
private _subscriptionCounter = 0;
private _heartbeatIntervalMs: number;
/**
* Instantiates a new WebSocketOrderbookChannel instance
* @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
*/
constructor(url: string) {
constructor(url: string, config?: WebSocketOrderbookChannelConfig) {
assert.isUri('url', url);
if (!_.isUndefined(config)) {
assert.doesConformToSchema('config', config, clientSchemas.webSocketOrderbookChannelConfigSchema);
}
this._apiEndpointUrl = url;
this._heartbeatIntervalMs =
_.isUndefined(config) || _.isUndefined(config.heartbeatIntervalMs)
? DEFAULT_HEARTBEAT_INTERVAL_MS
: config.heartbeatIntervalMs;
this._client = new WebSocket.client();
}
/**
@@ -63,7 +78,7 @@ export class WebSocketOrderbookChannel implements OrderbookChannel {
connection.on(WebsocketConnectionEventType.Error, wsError => {
handler.onError(this, subscriptionOpts, wsError);
});
connection.on(WebsocketConnectionEventType.Close, () => {
connection.on(WebsocketConnectionEventType.Close, (code: number, desc: string) => {
handler.onClose(this, subscriptionOpts);
});
connection.on(WebsocketConnectionEventType.Message, message => {
@@ -80,6 +95,9 @@ export class WebSocketOrderbookChannel implements OrderbookChannel {
if (!_.isUndefined(this._connectionIfExists)) {
this._connectionIfExists.close();
}
if (!_.isUndefined(this._heartbeatTimerIfExists)) {
clearInterval(this._heartbeatTimerIfExists);
}
}
private _getConnection(callback: (error?: Error, connection?: WebSocket.connection) => void) {
if (!_.isUndefined(this._connectionIfExists) && this._connectionIfExists.connected) {
@@ -87,6 +105,20 @@ export class WebSocketOrderbookChannel implements OrderbookChannel {
} else {
this._client.on(WebsocketClientEventType.Connect, 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);
});
this._client.on(WebsocketClientEventType.ConnectFailed, error => {

View File

@@ -40,19 +40,22 @@ describe('HttpClient', () => {
});
describe('#getTokenPairsAsync', () => {
const url = `${relayUrl}/token_pairs`;
it('gets token pairs', async () => {
fetchMock.get(url, tokenPairsResponseJSON);
it('gets token pairs with default options when none are provided', async () => {
const urlWithQuery = `${url}?page=1&per_page=100`;
fetchMock.get(urlWithQuery, tokenPairsResponseJSON);
const tokenPairs = await relayerClient.getTokenPairsAsync();
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 tokenPairsRequest = {
const tokenPairsRequestOpts = {
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);
const tokenPairs = await relayerClient.getTokenPairsAsync(tokenPairsRequest);
const tokenPairs = await relayerClient.getTokenPairsAsync(tokenPairsRequestOpts);
expect(tokenPairs).to.be.deep.equal(tokenPairsResponse);
});
it('throws an error for invalid JSON response', async () => {
@@ -62,17 +65,20 @@ describe('HttpClient', () => {
});
describe('#getOrdersAsync', () => {
const url = `${relayUrl}/orders`;
it('gets orders', async () => {
fetchMock.get(url, ordersResponseJSON);
it('gets orders with default options when none are provided', async () => {
const urlWithQuery = `${url}?page=1&per_page=100`;
fetchMock.get(urlWithQuery, ordersResponseJSON);
const orders = await relayerClient.getOrdersAsync();
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 ordersRequest = {
tokenAddress,
page: 3,
perPage: 50,
};
const urlWithQuery = `${url}?tokenAddress=${tokenAddress}`;
const urlWithQuery = `${url}?page=3&per_page=50&tokenAddress=${tokenAddress}`;
fetchMock.get(urlWithQuery, ordersResponseJSON);
const orders = await relayerClient.getOrdersAsync(ordersRequest);
expect(orders).to.be.deep.equal(ordersResponse);
@@ -100,14 +106,27 @@ describe('HttpClient', () => {
baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d',
quoteTokenAddress: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32',
};
const url = `${relayUrl}/orderbook?baseTokenAddress=${request.baseTokenAddress}&quoteTokenAddress=${
request.quoteTokenAddress
}`;
it('gets order book', async () => {
fetchMock.get(url, orderbookJSON);
const url = `${relayUrl}/orderbook`;
it('gets orderbook with default page options when none are provided', async () => {
const urlWithQuery = `${url}?baseTokenAddress=${
request.baseTokenAddress
}&page=1&per_page=100&quoteTokenAddress=${request.quoteTokenAddress}`;
fetchMock.get(urlWithQuery, orderbookJSON);
const orderbook = await relayerClient.getOrderbookAsync(request);
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&quoteTokenAddress=${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 () => {
fetchMock.get(url, { test: 'dummy' });
expect(relayerClient.getOrderbookAsync(request)).to.be.rejected();

View File

@@ -1,7 +1,7 @@
{
"private": true,
"name": "contracts",
"version": "2.1.9",
"version": "2.1.12",
"description": "Smart contract components of 0x protocol",
"main": "index.js",
"directories": {
@@ -15,13 +15,16 @@
"test": "run-s compile build run_mocha",
"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": "node ../deployer/lib/src/cli.js compile --contracts-dir src/contracts --artifacts-dir src/artifacts",
"clean": "rm -rf ./lib",
"compile": "node ../deployer/lib/src/cli.js compile --contracts ${npm_package_config_contracts} --contracts-dir src/contracts --artifacts-dir src/artifacts",
"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",
"migrate": "node ../deployer/lib/src/cli.js migrate",
"lint": "tslint --project . 'migrations/**/*.ts' 'test/**/*.ts' 'util/**/*.ts' 'deploy/**/*.ts'",
"test:circleci": "yarn test"
},
"config": {
"contracts": "Exchange,DummyToken,ZRXToken,Token,WETH9,TokenTransferProxy,MultiSigWallet,MultiSigWalletWithTimeLock,MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress,MaliciousToken,TokenRegistry"
},
"repository": {
"type": "git",
"url": "https://github.com/0xProject/0x.js.git"
@@ -33,9 +36,9 @@
},
"homepage": "https://github.com/0xProject/0x.js/packages/contracts/README.md",
"devDependencies": {
"@0xproject/dev-utils": "^0.0.10",
"@0xproject/tslint-config": "^0.4.7",
"@0xproject/types": "^0.1.9",
"@0xproject/dev-utils": "^0.0.13",
"@0xproject/tslint-config": "^0.4.9",
"@0xproject/types": "^0.2.2",
"@types/bluebird": "^3.5.3",
"@types/lodash": "^4.14.86",
"@types/node": "^8.0.53",
@@ -43,27 +46,28 @@
"@types/yargs": "^10.0.0",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"chai-as-promised-typescript-typings": "^0.0.8",
"chai-as-promised-typescript-typings": "^0.0.9",
"chai-bignumber": "^2.0.1",
"chai-typescript-typings": "^0.0.2",
"chai-typescript-typings": "^0.0.3",
"copyfiles": "^1.2.0",
"dirty-chai": "^2.0.1",
"mocha": "^4.0.1",
"npm-run-all": "^4.1.2",
"solc": "^0.4.18",
"shx": "^0.2.2",
"tslint": "5.8.0",
"types-bn": "^0.0.1",
"types-ethereumjs-util": "0xProject/types-ethereumjs-util",
"typescript": "2.7.1",
"web3-typescript-typings": "^0.9.9",
"web3-typescript-typings": "^0.9.10",
"yargs": "^10.0.3"
},
"dependencies": {
"0x.js": "^0.32.0",
"@0xproject/deployer": "^0.0.6",
"@0xproject/json-schemas": "^0.7.8",
"@0xproject/utils": "^0.3.0",
"@0xproject/web3-wrapper": "^0.1.10",
"0x.js": "^0.32.3",
"@0xproject/deployer": "^0.0.9",
"@0xproject/json-schemas": "^0.7.11",
"@0xproject/utils": "^0.3.3",
"@0xproject/web3-wrapper": "^0.1.13",
"bluebird": "^3.5.0",
"bn.js": "^4.11.8",
"ethereumjs-abi": "^0.6.4",

File diff suppressed because one or more lines are too long

View File

@@ -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
}
}
}

View File

@@ -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

View File

@@ -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
}
}
}

View File

@@ -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
}
}
}

View File

@@ -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
}
}
}

View File

@@ -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
}
}
}

View File

@@ -168,7 +168,7 @@
],
"unlinked_binary":
"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

View File

@@ -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
}
}
}

View File

@@ -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
}
}
}

View File

@@ -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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,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)

View File

@@ -1,6 +1,6 @@
{
"name": "@0xproject/deployer",
"version": "0.0.6",
"version": "0.0.9",
"description": "Smart contract deployer of 0x protocol",
"main": "lib/src/index.js",
"types": "lib/src/index.d.ts",
@@ -9,7 +9,7 @@
"build": "yarn clean && copyfiles 'test/fixtures/contracts/**/*' src/solc/solc_bin/* ./lib && tsc",
"test": "npm run build; mocha lib/test/*_test.js",
"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",
"lint": "tslint --project . 'src/**/*.ts' 'test/**/*.ts'",
"test:circleci": "yarn test"
@@ -28,14 +28,22 @@
},
"homepage": "https://github.com/0xProject/0x.js/packages/deployer/README.md",
"devDependencies": {
"@0xproject/tslint-config": "^0.4.9",
"chai": "^4.0.1",
"copyfiles": "^1.2.0",
"shx": "^0.2.2",
"mocha": "^4.0.1",
"tslint": "5.8.0",
"types-bn": "^0.0.1",
"typescript": "2.7.1",
"web3-typescript-typings": "^0.9.9"
"web3-typescript-typings": "^0.9.10"
},
"dependencies": {
"@0xproject/utils": "^0.3.0",
"@0xproject/web3-wrapper": "^0.1.10",
"@0xproject/json-schemas": "^0.7.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",
"solc": "^0.4.18",
"web3": "^0.20.0",

View File

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

View File

@@ -14,6 +14,7 @@ const DEFAULT_ARTIFACTS_DIR = path.resolve('artifacts');
const DEFAULT_NETWORK_ID = 50;
const DEFAULT_JSONRPC_PORT = 8545;
const DEFAULT_GAS_PRICE = (10 ** 9 * 2).toString();
const DEFAULT_CONTRACTS_LIST = '*';
/**
* Compiles all contracts with options passed in through CLI.
@@ -25,6 +26,7 @@ async function onCompileCommand(argv: CliOptions): Promise<void> {
networkId: argv.networkId,
optimizerEnabled: argv.shouldOptimize ? 1 : 0,
artifactsDir: argv.artifactsDir,
specifiedContracts: getContractsSetFromList(argv.contracts),
};
await commands.compileAsync(opts);
}
@@ -43,6 +45,7 @@ async function onMigrateCommand(argv: CliOptions): Promise<void> {
networkId,
optimizerEnabled: argv.shouldOptimize ? 1 : 0,
artifactsDir: argv.artifactsDir,
specifiedContracts: getContractsSetFromList(argv.contracts),
};
await commands.compileAsync(compilerOpts);
@@ -72,6 +75,7 @@ async function onDeployCommand(argv: CliOptions): Promise<void> {
networkId,
optimizerEnabled: argv.shouldOptimize ? 1 : 0,
artifactsDir: argv.artifactsDir,
specifiedContracts: getContractsSetFromList(argv.contracts),
};
await commands.compileAsync(compilerOpts);
@@ -89,6 +93,18 @@ async function onDeployCommand(argv: CliOptions): Promise<void> {
const deployerArgs = deployerArgsString.split(',');
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.
* @param yargsInstance yargs instance provided in builder function callback.
@@ -144,6 +160,11 @@ function deployCommandBuilder(yargsInstance: any) {
type: 'string',
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(
'migrate',

View File

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

View File

@@ -17,6 +17,7 @@ import {
import { utils } from './utils/utils';
const SOLIDITY_FILE_EXTENSION = '.sol';
const ALL_CONTRACTS_IDENTIFIER = '*';
export class Compiler {
private _contractsDir: string;
@@ -25,6 +26,7 @@ export class Compiler {
private _artifactsDir: string;
private _contractSourcesIfExists?: ContractSources;
private _solcErrors: Set<string>;
private _specifiedContracts: Set<string>;
/**
* Recursively retrieves Solidity source code from directory.
* @param dirPath Directory to search.
@@ -106,6 +108,7 @@ export class Compiler {
this._optimizerEnabled = opts.optimizerEnabled;
this._artifactsDir = opts.artifactsDir;
this._solcErrors = new Set();
this._specifiedContracts = opts.specifiedContracts;
}
/**
* 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 currentArtifactPath = `${this._artifactsDir}/${contractName}.json`;
const sourceHash = `0x${ethUtil.sha3(source).toString('hex')}`;
const isContractSpecified =
this._specifiedContracts.has(ALL_CONTRACTS_IDENTIFIER) || this._specifiedContracts.has(contractName);
let currentArtifactString: string;
let currentArtifact: ContractArtifact;
@@ -150,11 +155,12 @@ export class Compiler {
oldNetworks = currentArtifact.networks;
const oldNetwork: ContractData = oldNetworks[this._networkId];
shouldCompile =
_.isUndefined(oldNetwork) ||
oldNetwork.keccak256 !== sourceHash ||
oldNetwork.optimizer_enabled !== this._optimizerEnabled;
(_.isUndefined(oldNetwork) ||
oldNetwork.keccak256 !== sourceHash ||
oldNetwork.optimizer_enabled !== this._optimizerEnabled) &&
isContractSpecified;
} catch (err) {
shouldCompile = true;
shouldCompile = isContractSpecified;
}
if (!shouldCompile) {

View File

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

View File

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

View File

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

View File

@@ -50,6 +50,7 @@ export interface CompilerOptions {
networkId: number;
optimizerEnabled: number;
artifactsDir: string;
specifiedContracts: Set<string>;
}
export interface DeployerOptions {

View File

@@ -5,6 +5,7 @@ import { Compiler } from '../src/compiler';
import { Deployer } from '../src/deployer';
import { fsWrapper } from '../src/utils/fs_wrapper';
import { CompilerOptions, ContractArtifact, ContractData, DoneCallback } from '../src/utils/types';
import { constructor_args, exchange_binary } from './fixtures/exchange_bin';
import { constants } from './util/constants';
@@ -17,6 +18,7 @@ const compilerOpts: CompilerOptions = {
contractsDir,
networkId: constants.networkId,
optimizerEnabled: constants.optimizerEnabled,
specifiedContracts: new Set(constants.specifiedContracts),
};
const compiler = new Compiler(compilerOpts);
const deployerOpts = {

View File

@@ -8,4 +8,5 @@ export const constants = {
timeoutMs: 20000,
zrxTokenAddress: '0xe41d2489571d322189246dafa5ebde1f4699f498',
tokenTransferProxyAddress: '0x8da0d80f5007ef1e431dd2127178d224e32c2ef4',
specifiedContracts: '*',
};

View File

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

View File

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

View File

@@ -1,5 +1,13 @@
# 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_
* Updated `types-ethereumjs-util` dev dependency (#352)

View File

@@ -1,14 +1,17 @@
{
"name": "@0xproject/dev-utils",
"version": "0.0.10",
"version": "0.0.13",
"description": "0x dev TS utils",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"main": "lib/src/index.js",
"types": "lib/src/index.d.ts",
"scripts": {
"build:watch": "tsc -w",
"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",
"lint": "tslint --project . 'src/**/*.ts'"
"lint": "tslint --project . 'src/**/*.ts' 'test/**/*.ts'"
},
"license": "Apache-2.0",
"repository": {
@@ -20,9 +23,14 @@
},
"homepage": "https://github.com/0xProject/0x.js/packages/dev-utils/README.md",
"devDependencies": {
"@0xproject/tslint-config": "^0.4.7",
"@0xproject/types": "^0.1.9",
"@types/mocha": "^2.2.42",
"@0xproject/tslint-config": "^0.4.9",
"@0xproject/types": "^0.2.2",
"@0xproject/web3-wrapper": "^0.1.13",
"@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",
"shx": "^0.2.2",
"tslint": "5.8.0",
@@ -31,7 +39,8 @@
"typescript": "2.7.1"
},
"dependencies": {
"@0xproject/utils": "^0.3.0",
"@0xproject/utils": "^0.3.3",
"@0xproject/subproviders": "^0.4.2",
"ethereumjs-util": "^5.1.2",
"lodash": "^4.17.4",
"request-promise-native": "^1.0.5",

View File

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

View File

@@ -6,8 +6,7 @@
import ProviderEngine = require('web3-provider-engine');
import RpcSubprovider = require('web3-provider-engine/subproviders/rpc');
import { EmptyWalletSubprovider } from './subproviders/empty_wallet_subprovider';
import { FakeGasEstimateSubprovider } from './subproviders/fake_gas_estimate_subprovider';
import { EmptyWalletSubprovider, FakeGasEstimateSubprovider } from '@0xproject/subproviders';
import { constants } from './constants';

View 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);
});
});
});

View 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);
});
});
});

View File

@@ -5,7 +5,9 @@
},
"include": [
"./src/**/*",
"./test/**/*",
"../../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/types-ethereumjs-util/index.d.ts"
]

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,5 +1,13 @@
# 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_
* Added NonceTrackerSubprovider (#355)

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