Compare commits

..

61 Commits

Author SHA1 Message Date
Leonid Logvinov
e8d4f6d532 Publish
- 0x.js@0.36.0
 - @0xproject/abi-gen@0.2.10
 - @0xproject/assert@0.2.6
 - @0xproject/base-contract@0.2.0
 - @0xproject/connect@0.6.9
 - contracts@2.1.22
 - @0xproject/deployer@0.4.0
 - @0xproject/dev-utils@0.3.5
 - @0xproject/json-schemas@0.7.20
 - @0xproject/metacoin@0.0.3
 - @0xproject/monorepo-scripts@0.1.17
 - @0xproject/react-docs-example@0.0.7
 - @0xproject/react-docs@0.0.7
 - @0xproject/react-shared@0.1.2
 - @0xproject/sol-cov@0.0.7
 - @0xproject/sra-report@0.0.8
 - @0xproject/subproviders@0.8.5
 - @0xproject/testnet-faucets@1.0.23
 - @0xproject/tslint-config@0.4.15
 - @0xproject/types@0.6.0
 - @0xproject/typescript-typings@0.1.0
 - @0xproject/utils@0.5.1
 - @0xproject/web3-wrapper@0.6.0
 - @0xproject/website@0.0.25
2018-04-11 18:00:46 +02:00
Leonid Logvinov
631e7e9c58 Updated CHANGELOGS 2018-04-11 18:00:39 +02:00
Fabio Berger
c44f9e56ad Merge pull request #514 from 0xProject/publishImprovements
Add Doc Page Check To Publish Flow
2018-04-11 18:55:59 +09:00
Fabio Berger
2fe209d5ff Fix lint error 2018-04-11 18:55:42 +09:00
Brandon Millman
7d8badc86e Fix documentation links in some READMEs 2018-04-10 21:24:17 -07:00
Brandon Millman
854d65b51b Merge pull request #517 from lgedeon/development
Fix relative link
2018-04-10 21:21:31 -07:00
Luke Gedeon
df773d07f3 Fix relative link
0xproject.com/docs/json-schemas  -->  https://0xproject.com/docs/json-schemas
2018-04-10 21:29:16 -04:00
Fabio Berger
efdbc1ff6c Add step to publishing that upload staging doc jsons, deploys staging website, opens every docs page and asks the dev to confirm that each one renders properly before publishing 2018-04-10 14:49:13 +09:00
Fabio Berger
a9b5faa787 Fix web3Wrapper build command 2018-04-10 12:04:51 +09:00
Fabio Berger
49a54c0ff6 Add top-level yarn lerna:stage_docs to upload docJsons to the staging S3 bucket for all packages with a docs page 2018-04-10 12:04:11 +09:00
Amir Bandeali
70d403e6f8 Merge pull request #493 from hysz/features/deployer/multipleCodebaseSupport
Deployer: Support for External Codebases + Overloaded Function Names
2018-04-09 20:02:55 -07:00
Greg Hysen
eecf09f515 Added a detailed description of renameOverloadedMethods (special thanks to @fabioberger). Updated Javascript styles in the Abi-Gen and Utils packages, around support for function overloading. 2018-04-09 19:25:07 -07:00
Greg Hysen
61fc3346c2 Updated deployer to accept a list of contract directories as input. Contract directories are namespaced to a void clashes. Also in this commit is a fix for overloading contract functions. 2018-04-09 17:22:58 -07:00
Fabio Berger
b7e98abc43 Refactor publish script to have it's main execution body be lean and discrete steps 2018-04-09 19:11:18 +09:00
Fabio Berger
073bf738dd Since we moved Web3Wrapper class from index to it's own file, we need to update doc mapping 2018-04-07 10:41:43 +09:00
Fabio Berger
68e8d6f304 Update ERCDex logo 2018-04-07 10:24:47 +09:00
Jacob Evans
524e4707d2 Merge pull request #506 from 0xProject/feature/subproviders/pk-wallet-subprovider
Private Key subprovider
2018-04-06 16:52:44 +10:00
Jacob Evans
a0fac663f7 Update shared fixture data for network 42 2018-04-06 16:07:00 +10:00
Fabio Berger
277e58c2e5 Merge pull request #505 from 0xProject/fix/readmeContributingSection
Improve README contributing sections in all packages
2018-04-06 15:05:34 +09:00
Jacob Evans
774ab8a8ef Feedback
remove id management from testnet faucet
spread over txParams rather than modify in place
2018-04-06 15:21:08 +10:00
Brandon Millman
21dc94b709 Merge pull request #503 from 0xProject/feature/website/relayer-grid
Implement initial relayer grid
2018-04-05 12:15:16 -07:00
Brandon Millman
d6176872f7 Merge pull request #504 from 0xProject/fix/website/wallet-key-warning
Fix missing key warnings in wallet component
2018-04-05 12:14:43 -07:00
Brandon Millman
c396be42b9 Change undefined to null 2018-04-05 12:13:55 -07:00
Leonid Logvinov
7f7ddee0f9 Merge pull request #501 from 0xProject/feature/provider-over-wrapper
Use Provider over web3Wrapper
2018-04-05 13:52:43 +02:00
Leonid Logvinov
b99c797945 Fix tests 2018-04-05 13:52:19 +02:00
Leonid Logvinov
59edca4166 Call static functions as static 2018-04-05 13:06:16 +02:00
Leonid Logvinov
fbba5e054a Address feedback 2018-04-05 12:37:35 +02:00
Jacob Evans
ea47613d90 Use PKWalletSubprovider in testnet faucet 2018-04-05 15:33:04 +10:00
Jacob Evans
9d18f751c8 Create a private key subprovider 2018-04-05 15:18:38 +10:00
Fabio Berger
9745dfe2f4 Use depcheck async support 2018-04-05 11:43:48 +09:00
Fabio Berger
29d38593d6 Fix contributing links 2018-04-05 10:01:41 +09:00
Fabio Berger
d76bc18bb7 Improve contributing section of all packages so they include building entire monorepo on first contribution 2018-04-05 09:57:21 +09:00
Brandon Millman
cbe61ac315 Fix missing key warnings in wallet component 2018-04-04 13:35:08 -07:00
Brandon Millman
250d97a7c4 Implement initial relayer grid 2018-04-04 12:09:03 -07:00
Leonid Logvinov
249bf0163d Move our contract templates to accept Provider instead of Web3Wrapper 2018-04-04 11:56:32 +03:00
Fabio Berger
674e56cea6 Merge pull request #496 from 0xProject/removeUnusedDeps
Remove unused deps + Remove Dharma from website
2018-04-04 03:58:18 +09:00
Fabio Berger
61809130a6 Merge branch 'development' into removeUnusedDeps
* development:
  Temporarily remove installation test
  Fix package.json
  Remove `isPublished` from all CHANGELOG.json filesx
  Now that every version of a package published has a corresponding entry in it's CHANGELOG we no longer need the isPublished flag. Remove it.
  Remove temporary convert_changelog script

# Conflicts:
#	packages/monorepo-scripts/package.json
2018-04-04 03:57:42 +09:00
Fabio Berger
f5e6e0eaf7 Used generic declaration to remove need for any 2018-04-04 03:56:17 +09:00
Fabio Berger
b2c423dd84 Use Results type 2018-04-04 03:54:58 +09:00
Fabio Berger
4a9752d7cd Merge pull request #495 from 0xProject/fix/publishProcess
Improve Publish Flow
2018-04-04 03:14:36 +09:00
Leonid Logvinov
7db9a01639 Temporarily remove installation test 2018-04-03 12:50:23 +03:00
Fabio Berger
e9cb5c069a Add comment about ignored packages 2018-04-03 15:44:07 +09:00
Fabio Berger
03e4205700 Remove Dharma integration from Website 2018-04-03 15:39:43 +09:00
Fabio Berger
fd9278ac02 Add find_unused_deps monorepo script 2018-04-03 15:28:07 +09:00
Fabio Berger
1b7c7037b8 Remove remaining unused deps 2018-04-03 15:27:45 +09:00
Fabio Berger
913264c811 Update yarn.lock 2018-04-03 14:54:30 +09:00
Fabio Berger
e70b6630f9 Fix TS error 2018-04-03 14:52:31 +09:00
Fabio Berger
6d53947fd8 Add missing request types 2018-04-03 14:48:05 +09:00
Fabio Berger
1c0d982398 Fix yarn 2018-04-03 13:00:40 +09:00
Fabio Berger
a88b4040ff Stop using utils 2018-04-03 12:58:45 +09:00
Fabio Berger
e8073cd6f2 Update yarn.lock 2018-04-03 12:04:08 +09:00
Fabio Berger
8281be235c Use @0xproject/utils promisify everywhere 2018-04-03 12:03:59 +09:00
Fabio Berger
9ce03e3515 Update tslint-config. To avoid circular deps, this must always be one version back and must be manually updated. 2018-04-03 12:03:10 +09:00
Fabio Berger
667938696d Remove unused contracts deps 2018-04-03 11:43:23 +09:00
Fabio Berger
a165281dcf Remove unused 0x.js deps 2018-04-03 11:43:08 +09:00
Fabio Berger
185f70f2dd Fix package.json 2018-04-03 10:04:16 +09:00
Fabio Berger
cd3e14f45a Remove isPublished from all CHANGELOG.json filesx 2018-04-03 09:45:59 +09:00
Fabio Berger
dd87588dfe Now that every version of a package published has a corresponding entry in it's CHANGELOG we no longer need the isPublished flag. Remove it. 2018-04-03 09:45:30 +09:00
Fabio Berger
29042e1939 Remove temporary convert_changelog script 2018-04-03 09:36:43 +09:00
Leonid Logvinov
4dbf6559aa After publish 2018-04-02 16:12:37 +03:00
Leonid Logvinov
b987b5988d Publish
- 0x.js@0.35.0
 - @0xproject/abi-gen@0.2.9
 - @0xproject/assert@0.2.5
 - @0xproject/base-contract@0.1.0
 - @0xproject/connect@0.6.8
 - contracts@2.1.21
 - @0xproject/deployer@0.3.5
 - @0xproject/dev-utils@0.3.4
 - @0xproject/json-schemas@0.7.19
 - @0xproject/metacoin@0.0.2
 - @0xproject/monorepo-scripts@0.1.16
 - @0xproject/react-docs-example@0.0.6
 - @0xproject/react-docs@0.0.6
 - @0xproject/react-shared@0.1.1
 - @0xproject/sol-cov@0.0.6
 - @0xproject/sra-report@0.0.7
 - @0xproject/subproviders@0.8.4
 - @0xproject/testnet-faucets@1.0.22
 - @0xproject/tslint-config@0.4.14
 - @0xproject/types@0.5.0
 - @0xproject/typescript-typings@0.0.3
 - @0xproject/utils@0.5.0
 - @0xproject/web3-wrapper@0.5.0
 - @0xproject/website@0.0.24
2018-04-02 16:01:51 +03:00
216 changed files with 3682 additions and 3238 deletions

View File

@@ -183,9 +183,9 @@ workflows:
main: main:
jobs: jobs:
- build - build
- test-installation: # - test-installation:
requires: # requires:
- build # - build
- test-0xjs: - test-0xjs:
requires: requires:
- build - build

View File

@@ -18,6 +18,7 @@
"lerna:rebuild": "run-s lerna:clean lerna:build", "lerna:rebuild": "run-s lerna:clean lerna:build",
"lerna:publish": "run-s lerna:install lerna:rebuild script:publish", "lerna:publish": "run-s lerna:install lerna:rebuild script:publish",
"lerna:publish:dry": "run-s lerna:install lerna:rebuild script:publish:dry", "lerna:publish:dry": "run-s lerna:install lerna:rebuild script:publish:dry",
"lerna:stage_docs": "lerna run docs:stage",
"script:publish": "node ./packages/monorepo-scripts/lib/publish.js", "script:publish": "node ./packages/monorepo-scripts/lib/publish.js",
"script:publish:dry": "IS_DRY_RUN=true yarn script:publish" "script:publish:dry": "IS_DRY_RUN=true yarn script:publish"
}, },

View File

@@ -1,4 +1,14 @@
[ [
{
"version": "0.36.0",
"changes": [
{
"note": "Moved Web3.Provider to `@0xproject/types:Provider`",
"pr": 501
}
],
"timestamp": 1523462196
},
{ {
"version": "0.35.0", "version": "0.35.0",
"changes": [ "changes": [
@@ -46,8 +56,7 @@
"pr": 456 "pr": 456
} }
], ],
"timestamp": 1521298800, "timestamp": 1521298800
"isPublished": true
}, },
{ {
"version": "0.33.1", "version": "0.33.1",
@@ -56,8 +65,7 @@
"note": "Add missing EthersJs typescript typings as dependency" "note": "Add missing EthersJs typescript typings as dependency"
} }
], ],
"timestamp": 1520434800, "timestamp": 1520434800
"isPublished": true
}, },
{ {
"version": "0.33.0", "version": "0.33.0",
@@ -83,8 +91,7 @@
"pr": 429 "pr": 429
} }
], ],
"timestamp": 1520089200, "timestamp": 1520089200
"isPublished": true
}, },
{ {
"version": "0.32.2", "version": "0.32.2",
@@ -94,8 +101,7 @@
"pr": 389 "pr": 389
} }
], ],
"timestamp": 1518102000, "timestamp": 1518102000
"isPublished": true
}, },
{ {
"version": "0.32.1", "version": "0.32.1",
@@ -109,8 +115,7 @@
"pr": 371 "pr": 371
} }
], ],
"timestamp": 1517929200, "timestamp": 1517929200
"isPublished": true
}, },
{ {
"version": "0.32.0", "version": "0.32.0",
@@ -125,8 +130,7 @@
"pr": 366 "pr": 366
} }
], ],
"timestamp": 1517756400, "timestamp": 1517756400
"isPublished": true
}, },
{ {
"version": "0.31.1", "version": "0.31.1",
@@ -136,8 +140,7 @@
"pr": 357 "pr": 357
} }
], ],
"timestamp": 1517410800, "timestamp": 1517410800
"isPublished": true
}, },
{ {
"version": "0.31.0", "version": "0.31.0",
@@ -148,8 +151,7 @@
"pr": 349 "pr": 349
} }
], ],
"timestamp": 1517238000, "timestamp": 1517238000
"isPublished": true
}, },
{ {
"version": "0.30.2", "version": "0.30.2",
@@ -162,8 +164,7 @@
"note": "Move @0xproject/types to dependencies from devDependencies fixing missing type errors" "note": "Move @0xproject/types to dependencies from devDependencies fixing missing type errors"
} }
], ],
"timestamp": 1517151600, "timestamp": 1517151600
"isPublished": true
}, },
{ {
"version": "0.30.1", "version": "0.30.1",
@@ -177,8 +178,7 @@
"pr": 341 "pr": 341
} }
], ],
"timestamp": 1516719600, "timestamp": 1516719600
"isPublished": true
}, },
{ {
"version": "0.30.0", "version": "0.30.0",
@@ -197,8 +197,7 @@
"pr": 321 "pr": 321
} }
], ],
"timestamp": 1516114800, "timestamp": 1516114800
"isPublished": true
}, },
{ {
"version": "0.29.1", "version": "0.29.1",
@@ -208,8 +207,7 @@
"pr": 305 "pr": 305
} }
], ],
"timestamp": 1515596400, "timestamp": 1515596400
"isPublished": true
}, },
{ {
"version": "0.29.0", "version": "0.29.0",
@@ -223,8 +221,7 @@
"pr": 287 "pr": 287
} }
], ],
"timestamp": 1514386800, "timestamp": 1514386800
"isPublished": true
}, },
{ {
"version": "0.28.0", "version": "0.28.0",
@@ -270,8 +267,7 @@
"pr": 278 "pr": 278
} }
], ],
"timestamp": 1513695600, "timestamp": 1513695600
"isPublished": true
}, },
{ {
"version": "0.27.1", "version": "0.27.1",
@@ -280,8 +276,7 @@
"note": "Export `TransactionOpts` type" "note": "Export `TransactionOpts` type"
} }
], ],
"timestamp": 1511794800, "timestamp": 1511794800
"isPublished": true
}, },
{ {
"version": "0.27.0", "version": "0.27.0",
@@ -326,8 +321,7 @@
"pr": 236 "pr": 236
} }
], ],
"timestamp": 1511794800, "timestamp": 1511794800
"isPublished": true
}, },
{ {
"version": "0.26.0", "version": "0.26.0",
@@ -347,8 +341,7 @@
"pr": 225 "pr": 225
} }
], ],
"timestamp": 1511190000, "timestamp": 1511190000
"isPublished": true
}, },
{ {
"version": "0.25.1", "version": "0.25.1",
@@ -367,8 +360,7 @@
"pr": 200 "pr": 200
} }
], ],
"timestamp": 1510498800, "timestamp": 1510498800
"isPublished": true
}, },
{ {
"version": "0.23.0", "version": "0.23.0",
@@ -381,8 +373,7 @@
"note": "Subscribe callbacks now receive an error object as their first argument" "note": "Subscribe callbacks now receive an error object as their first argument"
} }
], ],
"timestamp": 1510412400, "timestamp": 1510412400
"isPublished": true
}, },
{ {
"version": "0.22.6", "version": "0.22.6",
@@ -392,8 +383,7 @@
"pr": 206 "pr": 206
} }
], ],
"timestamp": 1510239600, "timestamp": 1510239600
"isPublished": true
}, },
{ {
"version": "0.22.5", "version": "0.22.5",
@@ -402,8 +392,7 @@
"note": "Re-publish v0.22.4 to fix publishing issue" "note": "Re-publish v0.22.4 to fix publishing issue"
} }
], ],
"timestamp": 1509980400, "timestamp": 1509980400
"isPublished": true
}, },
{ {
"version": "0.22.4", "version": "0.22.4",
@@ -412,8 +401,7 @@
"note": "Upgraded bignumber.js to a new version that ships with native typings" "note": "Upgraded bignumber.js to a new version that ships with native typings"
} }
], ],
"timestamp": 1508857200, "timestamp": 1508857200
"isPublished": true
}, },
{ {
"version": "0.22.3", "version": "0.22.3",
@@ -423,8 +411,7 @@
"pr": 199 "pr": 199
} }
], ],
"timestamp": 1508857200, "timestamp": 1508857200
"isPublished": true
}, },
{ {
"version": "0.22.2", "version": "0.22.2",
@@ -434,8 +421,7 @@
"pr": 197 "pr": 197
} }
], ],
"timestamp": 1508770800, "timestamp": 1508770800
"isPublished": true
}, },
{ {
"version": "0.22.0", "version": "0.22.0",
@@ -450,8 +436,7 @@
"pr": 187 "pr": 187
} }
], ],
"timestamp": 1508079600, "timestamp": 1508079600
"isPublished": true
}, },
{ {
"version": "0.21.4", "version": "0.21.4",
@@ -462,8 +447,7 @@
"pr": 194 "pr": 194
} }
], ],
"timestamp": 1507820400, "timestamp": 1507820400
"isPublished": true
}, },
{ {
"version": "0.21.3", "version": "0.21.3",
@@ -473,8 +457,7 @@
"pr": 193 "pr": 193
} }
], ],
"timestamp": 1507734000, "timestamp": 1507734000
"isPublished": true
}, },
{ {
"version": "0.21.2", "version": "0.21.2",
@@ -484,8 +467,7 @@
"pr": 190 "pr": 190
} }
], ],
"timestamp": 1507647600, "timestamp": 1507647600
"isPublished": true
}, },
{ {
"version": "0.21.1", "version": "0.21.1",
@@ -495,8 +477,7 @@
"pr": 189 "pr": 189
} }
], ],
"timestamp": 1507647600, "timestamp": 1507647600
"isPublished": true
}, },
{ {
"version": "0.21.0", "version": "0.21.0",
@@ -542,8 +523,7 @@
"pr": 185 "pr": 185
} }
], ],
"timestamp": 1507561200, "timestamp": 1507561200
"isPublished": true
}, },
{ {
"version": "0.20.0", "version": "0.20.0",
@@ -561,8 +541,7 @@
"pr": 181 "pr": 181
} }
], ],
"timestamp": 1507129200, "timestamp": 1507129200
"isPublished": true
}, },
{ {
"version": "0.19.0", "version": "0.19.0",
@@ -580,8 +559,7 @@
"pr": 175 "pr": 175
} }
], ],
"timestamp": 1506610800, "timestamp": 1506610800
"isPublished": true
}, },
{ {
"version": "0.18.0", "version": "0.18.0",
@@ -591,8 +569,7 @@
"pr": 170 "pr": 170
} }
], ],
"timestamp": 1506351600, "timestamp": 1506351600
"isPublished": true
}, },
{ {
"version": "0.17.0", "version": "0.17.0",
@@ -602,8 +579,7 @@
"pr": 171 "pr": 171
} }
], ],
"timestamp": 1506351600, "timestamp": 1506351600
"isPublished": true
}, },
{ {
"version": "0.16.0", "version": "0.16.0",
@@ -626,8 +602,7 @@
"pr": 165 "pr": 165
} }
], ],
"timestamp": 1505833200, "timestamp": 1505833200
"isPublished": true
}, },
{ {
"version": "0.15.0", "version": "0.15.0",
@@ -638,8 +613,7 @@
"pr": 161 "pr": 161
} }
], ],
"timestamp": 1504796400, "timestamp": 1504796400
"isPublished": true
}, },
{ {
"version": "0.14.2", "version": "0.14.2",
@@ -649,8 +623,7 @@
"pr": 160 "pr": 160
} }
], ],
"timestamp": 1504710000, "timestamp": 1504710000
"isPublished": true
}, },
{ {
"version": "0.14.1", "version": "0.14.1",
@@ -660,8 +633,7 @@
"pr": 159 "pr": 159
} }
], ],
"timestamp": 1504710000, "timestamp": 1504710000
"isPublished": true
}, },
{ {
"version": "0.14.0", "version": "0.14.0",
@@ -679,8 +651,7 @@
"pr": 157 "pr": 157
} }
], ],
"timestamp": 1504623600, "timestamp": 1504623600
"isPublished": true
}, },
{ {
"version": "0.13.0", "version": "0.13.0",
@@ -704,8 +675,7 @@
"pr": 152 "pr": 152
} }
], ],
"timestamp": 1504623600, "timestamp": 1504623600
"isPublished": true
}, },
{ {
"version": "0.12.1", "version": "0.12.1",
@@ -723,8 +693,7 @@
"pr": 139 "pr": 139
} }
], ],
"timestamp": 1504278000, "timestamp": 1504278000
"isPublished": true
}, },
{ {
"version": "0.11.0", "version": "0.11.0",
@@ -742,8 +711,7 @@
"pr": 137 "pr": 137
} }
], ],
"timestamp": 1503500400, "timestamp": 1503500400
"isPublished": true
}, },
{ {
"version": "0.10.4", "version": "0.10.4",
@@ -753,8 +721,7 @@
"pr": 135 "pr": 135
} }
], ],
"timestamp": 1503500400, "timestamp": 1503500400
"isPublished": true
}, },
{ {
"version": "0.10.1", "version": "0.10.1",
@@ -808,8 +775,7 @@
"pr": 127 "pr": 127
} }
], ],
"timestamp": 1503500400, "timestamp": 1503500400
"isPublished": true
}, },
{ {
"version": "0.9.3", "version": "0.9.3",
@@ -819,8 +785,7 @@
"pr": 118 "pr": 118
} }
], ],
"timestamp": 1503327600, "timestamp": 1503327600
"isPublished": true
}, },
{ {
"version": "0.9.2", "version": "0.9.2",
@@ -833,8 +798,7 @@
"pr": 118 "pr": 118
} }
], ],
"timestamp": 1503241200, "timestamp": 1503241200
"isPublished": true
}, },
{ {
"version": "0.9.1", "version": "0.9.1",
@@ -844,8 +808,7 @@
"pr": 120 "pr": 120
} }
], ],
"timestamp": 1502809200, "timestamp": 1502809200
"isPublished": true
}, },
{ {
"version": "0.9.0", "version": "0.9.0",
@@ -882,8 +845,7 @@
"pr": 109 "pr": 109
} }
], ],
"timestamp": 1500994800, "timestamp": 1500994800
"isPublished": true
}, },
{ {
"version": "0.8.0", "version": "0.8.0",
@@ -925,8 +887,7 @@
"note": "Fixed the bug where `zeroEx.setProviderAsync` didn't invalidate etherToken contract's instance" "note": "Fixed the bug where `zeroEx.setProviderAsync` didn't invalidate etherToken contract's instance"
} }
], ],
"timestamp": 1499094000, "timestamp": 1499094000
"isPublished": true
}, },
{ {
"version": "0.7.1", "version": "0.7.1",
@@ -937,8 +898,7 @@
"pr": 81 "pr": 81
} }
], ],
"timestamp": 1498402800, "timestamp": 1498402800
"isPublished": true
}, },
{ {
"version": "0.7.0", "version": "0.7.0",
@@ -960,8 +920,7 @@
"Renamed type `LogCancelArgs` to `LogCancelContractEventArgs` and `LogFillArgs` to `LogFillContractEventArgs`" "Renamed type `LogCancelArgs` to `LogCancelContractEventArgs` and `LogFillArgs` to `LogFillContractEventArgs`"
} }
], ],
"timestamp": 1498057200, "timestamp": 1498057200
"isPublished": true
}, },
{ {
"version": "0.6.2", "version": "0.6.2",
@@ -973,8 +932,7 @@
"note": "Improved documentation" "note": "Improved documentation"
} }
], ],
"timestamp": 1497970800, "timestamp": 1497970800
"isPublished": true
}, },
{ {
"version": "0.6.1", "version": "0.6.1",
@@ -983,8 +941,7 @@
"note": "Improved documentation" "note": "Improved documentation"
} }
], ],
"timestamp": 1497798000, "timestamp": 1497798000
"isPublished": true
}, },
{ {
"version": "0.6.0", "version": "0.6.0",
@@ -996,8 +953,7 @@
"note": "Added types for contract event arguments" "note": "Added types for contract event arguments"
} }
], ],
"timestamp": 1497798000, "timestamp": 1497798000
"isPublished": true
}, },
{ {
"version": "0.5.2", "version": "0.5.2",
@@ -1007,8 +963,7 @@
"Fixed the bug in `postpublish` script that caused that only unminified UMD bundle was uploaded to release page" "Fixed the bug in `postpublish` script that caused that only unminified UMD bundle was uploaded to release page"
} }
], ],
"timestamp": 1497452400, "timestamp": 1497452400
"isPublished": true
}, },
{ {
"version": "0.5.1", "version": "0.5.1",
@@ -1017,7 +972,6 @@
"note": "Added `postpublish` script to publish to Github Releases with assets." "note": "Added `postpublish` script to publish to Github Releases with assets."
} }
], ],
"timestamp": 1497452400, "timestamp": 1497452400
"isPublished": true
} }
] ]

View File

@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG CHANGELOG
## v0.36.0 - _April 11, 2018_
* Moved Web3.Provider to `@0xproject/types:Provider` (#501)
## v0.35.0 - _April 2, 2018_ ## v0.35.0 - _April 2, 2018_
* Removed `ZeroExError.TransactionMiningTimeout` and moved it to '@0xproject/web3_wrapper' `Web3WrapperErrors.TransactionMiningTimeout` (#485) * Removed `ZeroExError.TransactionMiningTimeout` and moved it to '@0xproject/web3_wrapper' `Web3WrapperErrors.TransactionMiningTimeout` (#485)

View File

@@ -1,5 +1,9 @@
## 0x.js ## 0x.js
A TypeScript/Javascript library for interacting with the 0x protocol.
### Read the [Documentation](https://0xproject.com/docs/0xjs).
## Installation ## Installation
0x.js ships as both a [UMD](https://github.com/umdjs/umd) module and a [CommonJS](https://en.wikipedia.org/wiki/CommonJS) package. 0x.js ships as both a [UMD](https://github.com/umdjs/umd) module and a [CommonJS](https://en.wikipedia.org/wiki/CommonJS) package.
@@ -38,10 +42,66 @@ Download the UMD module from our [releases page](https://github.com/0xProject/0x
<script type="text/javascript" src="0x.js"></script> <script type="text/javascript" src="0x.js"></script>
``` ```
## Documentation ## Contributing
Extensive documentation of 0x.js can be found on [our website][docs-url]. We strongly recommend that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository.
[website-url]: https://0xproject.com/ Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
[whitepaper-url]: https://0xproject.com/pdfs/0x_white_paper.pdf
[docs-url]: https://0xproject.com/docs/0xjs ### Install dependencies
If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
```bash
yarn config set workspaces-experimental true
```
Then install dependencies
```bash
yarn install
```
### Build
If this is your **first** time building this package, you must first build **all** packages within the monorepo. This is because packages that depend on other packages located inside this monorepo are symlinked when run from **within** the monorepo. This allows you to make changes across multiple packages without first publishing dependent packages to NPM. To build all packages, run the following from the monorepo root directory:
```bash
yarn lerna:rebuild
```
Or continuously rebuild on change:
```bash
yarn dev
```
You can also build this specific package by running the following from within its directory:
```bash
yarn build
```
or continuously rebuild on change:
```bash
yarn build:watch
```
### Clean
```bash
yarn clean
```
### Lint
```bash
yarn lint
```
### Run Tests
```bash
yarn test
```

View File

@@ -1,6 +1,6 @@
{ {
"name": "0x.js", "name": "0x.js",
"version": "0.34.0", "version": "0.36.0",
"description": "A javascript library for interacting with the 0x protocol", "description": "A javascript library for interacting with the 0x protocol",
"keywords": [ "keywords": [
"0x.js", "0x.js",
@@ -60,15 +60,14 @@
"node": ">=6.0.0" "node": ">=6.0.0"
}, },
"devDependencies": { "devDependencies": {
"@0xproject/abi-gen": "^0.2.8", "@0xproject/dev-utils": "^0.3.5",
"@0xproject/dev-utils": "^0.3.3", "@0xproject/monorepo-scripts": "^0.1.17",
"@0xproject/monorepo-scripts": "^0.1.15", "@0xproject/tslint-config": "^0.4.15",
"@0xproject/tslint-config": "^0.4.13",
"@types/bintrees": "^1.0.2", "@types/bintrees": "^1.0.2",
"@types/jsonschema": "^1.1.1",
"@types/lodash": "4.14.104", "@types/lodash": "4.14.104",
"@types/mocha": "^2.2.42", "@types/mocha": "^2.2.42",
"@types/node": "^8.0.53", "@types/node": "^8.0.53",
"@types/request": "2.47.0",
"@types/sinon": "^2.2.2", "@types/sinon": "^2.2.2",
"@types/uuid": "^3.4.2", "@types/uuid": "^3.4.2",
"awesome-typescript-loader": "^3.1.3", "awesome-typescript-loader": "^3.1.3",
@@ -84,7 +83,6 @@
"opn-cli": "^3.1.0", "opn-cli": "^3.1.0",
"prettier": "^1.11.1", "prettier": "^1.11.1",
"request": "^2.81.0", "request": "^2.81.0",
"request-promise-native": "^1.0.5",
"shx": "^0.2.2", "shx": "^0.2.2",
"sinon": "^4.0.0", "sinon": "^4.0.0",
"source-map-support": "^0.5.0", "source-map-support": "^0.5.0",
@@ -92,17 +90,16 @@
"tslint": "5.8.0", "tslint": "5.8.0",
"typedoc": "0xProject/typedoc", "typedoc": "0xProject/typedoc",
"typescript": "2.7.1", "typescript": "2.7.1",
"web3-provider-engine": "^13.0.1",
"webpack": "^3.1.0" "webpack": "^3.1.0"
}, },
"dependencies": { "dependencies": {
"@0xproject/assert": "^0.2.4", "@0xproject/assert": "^0.2.6",
"@0xproject/base-contract": "^0.0.6", "@0xproject/base-contract": "^0.2.0",
"@0xproject/json-schemas": "^0.7.18", "@0xproject/json-schemas": "^0.7.20",
"@0xproject/types": "^0.4.2", "@0xproject/types": "^0.6.0",
"@0xproject/typescript-typings": "^0.0.2", "@0xproject/typescript-typings": "^0.1.0",
"@0xproject/utils": "^0.4.4", "@0xproject/utils": "^0.5.1",
"@0xproject/web3-wrapper": "^0.4.0", "@0xproject/web3-wrapper": "^0.6.0",
"bintrees": "^1.0.2", "bintrees": "^1.0.2",
"bn.js": "^4.11.8", "bn.js": "^4.11.8",
"ethereumjs-abi": "^0.6.4", "ethereumjs-abi": "^0.6.4",

View File

@@ -1,5 +1,5 @@
import { schemas, SchemaValidator } from '@0xproject/json-schemas'; import { schemas, SchemaValidator } from '@0xproject/json-schemas';
import { ECSignature, Order, SignedOrder, TransactionReceiptWithDecodedLogs } from '@0xproject/types'; import { ECSignature, Order, Provider, SignedOrder, TransactionReceiptWithDecodedLogs } from '@0xproject/types';
import { AbiDecoder, BigNumber, intervalUtils } from '@0xproject/utils'; import { AbiDecoder, BigNumber, intervalUtils } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper'; import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as ethUtil from 'ethereumjs-util'; import * as ethUtil from 'ethereumjs-util';
@@ -15,7 +15,7 @@ import { OrderStateWatcher } from './order_watcher/order_state_watcher';
import { zeroExConfigSchema } from './schemas/zero_ex_config_schema'; import { zeroExConfigSchema } from './schemas/zero_ex_config_schema';
import { zeroExPrivateNetworkConfigSchema } from './schemas/zero_ex_private_network_config_schema'; import { zeroExPrivateNetworkConfigSchema } from './schemas/zero_ex_private_network_config_schema';
import { zeroExPublicNetworkConfigSchema } from './schemas/zero_ex_public_network_config_schema'; import { zeroExPublicNetworkConfigSchema } from './schemas/zero_ex_public_network_config_schema';
import { OrderStateWatcherConfig, Web3Provider, ZeroExConfig, ZeroExError } from './types'; import { OrderStateWatcherConfig, ZeroExConfig, ZeroExError } from './types';
import { assert } from './utils/assert'; import { assert } from './utils/assert';
import { constants } from './utils/constants'; import { constants } from './utils/constants';
import { decorators } from './utils/decorators'; import { decorators } from './utils/decorators';
@@ -115,10 +115,8 @@ export class ZeroEx {
public static toUnitAmount(amount: BigNumber, decimals: number): BigNumber { public static toUnitAmount(amount: BigNumber, decimals: number): BigNumber {
assert.isValidBaseUnitAmount('amount', amount); assert.isValidBaseUnitAmount('amount', amount);
assert.isNumber('decimals', decimals); assert.isNumber('decimals', decimals);
const unitAmount = Web3Wrapper.toUnitAmount(amount, decimals);
const aUnit = new BigNumber(10).pow(decimals); return unitAmount;
const unit = amount.div(aUnit);
return unit;
} }
/** /**
* A baseUnit is defined as the smallest denomination of a token. An amount expressed in baseUnits * A baseUnit is defined as the smallest denomination of a token. An amount expressed in baseUnits
@@ -131,13 +129,7 @@ export class ZeroEx {
public static toBaseUnitAmount(amount: BigNumber, decimals: number): BigNumber { public static toBaseUnitAmount(amount: BigNumber, decimals: number): BigNumber {
assert.isBigNumber('amount', amount); assert.isBigNumber('amount', amount);
assert.isNumber('decimals', decimals); assert.isNumber('decimals', decimals);
const baseUnitAmount = Web3Wrapper.toBaseUnitAmount(amount, decimals);
const unit = new BigNumber(10).pow(decimals);
const baseUnitAmount = amount.times(unit);
const hasDecimals = baseUnitAmount.decimalPlaces() !== 0;
if (hasDecimals) {
throw new Error(`Invalid unit amount: ${amount.toString()} - Too many decimal places`);
}
return baseUnitAmount; return baseUnitAmount;
} }
/** /**
@@ -153,12 +145,12 @@ export class ZeroEx {
} }
/** /**
* Instantiates a new ZeroEx instance that provides the public interface to the 0x.js library. * Instantiates a new ZeroEx instance that provides the public interface to the 0x.js library.
* @param provider The Web3.js Provider instance you would like the 0x.js library to use for interacting with * @param provider The Provider instance you would like the 0x.js library to use for interacting with
* the Ethereum network. * the Ethereum network.
* @param config The configuration object. Look up the type for the description. * @param config The configuration object. Look up the type for the description.
* @return An instance of the 0x.js ZeroEx class. * @return An instance of the 0x.js ZeroEx class.
*/ */
constructor(provider: Web3Provider, config: ZeroExConfig) { constructor(provider: Provider, config: ZeroExConfig) {
assert.isWeb3Provider('provider', provider); assert.isWeb3Provider('provider', provider);
assert.doesConformToSchema('config', config, zeroExConfigSchema, [ assert.doesConformToSchema('config', config, zeroExConfigSchema, [
zeroExPrivateNetworkConfigSchema, zeroExPrivateNetworkConfigSchema,
@@ -199,7 +191,7 @@ export class ZeroEx {
* @param provider The Web3Provider you would like the 0x.js library to use from now on. * @param provider The Web3Provider you would like the 0x.js library to use from now on.
* @param networkId The id of the network your provider is connected to * @param networkId The id of the network your provider is connected to
*/ */
public setProvider(provider: Web3Provider, networkId: number): void { public setProvider(provider: Provider, networkId: number): void {
this._web3Wrapper.setProvider(provider); this._web3Wrapper.setProvider(provider);
(this.exchange as any)._invalidateContractInstances(); (this.exchange as any)._invalidateContractInstances();
(this.exchange as any)._setNetworkId(networkId); (this.exchange as any)._setNetworkId(networkId);
@@ -225,7 +217,7 @@ export class ZeroEx {
* This method currently supports TestRPC, Geth and Parity above and below V1.6.6 * This method currently supports TestRPC, Geth and Parity above and below V1.6.6
* @param orderHash Hex encoded orderHash to sign. * @param orderHash Hex encoded orderHash to sign.
* @param signerAddress The hex encoded Ethereum address you wish to sign it with. This address * @param signerAddress The hex encoded Ethereum address you wish to sign it with. This address
* must be available via the Web3.Provider supplied to 0x.js. * must be available via the Provider supplied to 0x.js.
* @param shouldAddPersonalMessagePrefix Some signers add the personal message prefix `\x19Ethereum Signed Message` * @param shouldAddPersonalMessagePrefix Some signers add the personal message prefix `\x19Ethereum Signed Message`
* themselves (e.g Parity Signer, Ledger, TestRPC) and others expect it to already be done by the client * themselves (e.g Parity Signer, Ledger, TestRPC) and others expect it to already be done by the client
* (e.g Metamask). Depending on which signer this request is going to, decide on whether to add the prefix * (e.g Metamask). Depending on which signer this request is going to, decide on whether to add the prefix

View File

@@ -191,7 +191,12 @@ export class EtherTokenWrapper extends ContractWrapper {
artifacts.EtherTokenArtifact, artifacts.EtherTokenArtifact,
etherTokenAddress, etherTokenAddress,
); );
const contractInstance = new EtherTokenContract(this._web3Wrapper, abi, address); const contractInstance = new EtherTokenContract(
abi,
address,
this._web3Wrapper.getProvider(),
this._web3Wrapper.getContractDefaults(),
);
etherTokenContract = contractInstance; etherTokenContract = contractInstance;
this._etherTokenContractsByAddress[etherTokenAddress] = etherTokenContract; this._etherTokenContractsByAddress[etherTokenAddress] = etherTokenContract;
return etherTokenContract; return etherTokenContract;

View File

@@ -170,7 +170,7 @@ export class ExchangeWrapper extends ContractWrapper {
* @param shouldThrowOnInsufficientBalanceOrAllowance Whether or not you wish for the contract call to throw * @param shouldThrowOnInsufficientBalanceOrAllowance Whether or not you wish for the contract call to throw
* if upon execution the tokens cannot be transferred. * if upon execution the tokens cannot be transferred.
* @param takerAddress The user Ethereum address who would like to fill this order. * @param takerAddress The user Ethereum address who would like to fill this order.
* Must be available via the supplied Web3.Provider * Must be available via the supplied Provider
* passed to 0x.js. * passed to 0x.js.
* @param orderTransactionOpts Optional arguments this method accepts. * @param orderTransactionOpts Optional arguments this method accepts.
* @return Transaction hash. * @return Transaction hash.
@@ -235,7 +235,7 @@ export class ExchangeWrapper extends ContractWrapper {
* If set to false, the call will continue to fill subsequent * If set to false, the call will continue to fill subsequent
* signedOrders even when some cannot be filled. * signedOrders even when some cannot be filled.
* @param takerAddress The user Ethereum address who would like to fill these * @param takerAddress The user Ethereum address who would like to fill these
* orders. Must be available via the supplied Web3.Provider * orders. Must be available via the supplied Provider
* passed to 0x.js. * passed to 0x.js.
* @param orderTransactionOpts Optional arguments this method accepts. * @param orderTransactionOpts Optional arguments this method accepts.
* @return Transaction hash. * @return Transaction hash.
@@ -335,7 +335,7 @@ export class ExchangeWrapper extends ContractWrapper {
* cannot be filled. * cannot be filled.
* @param takerAddress The user Ethereum address who would like to fill * @param takerAddress The user Ethereum address who would like to fill
* these orders. Must be available via the supplied * these orders. Must be available via the supplied
* Web3.Provider passed to 0x.js. * Provider passed to 0x.js.
* @param orderTransactionOpts Optional arguments this method accepts. * @param orderTransactionOpts Optional arguments this method accepts.
* @return Transaction hash. * @return Transaction hash.
*/ */
@@ -416,7 +416,7 @@ export class ExchangeWrapper extends ContractWrapper {
* signedOrder you wish to fill. * signedOrder you wish to fill.
* @param fillTakerTokenAmount The total amount of the takerTokens you would like to fill. * @param fillTakerTokenAmount The total amount of the takerTokens you would like to fill.
* @param takerAddress The user Ethereum address who would like to fill this order. * @param takerAddress The user Ethereum address who would like to fill this order.
* Must be available via the supplied Web3.Provider passed to 0x.js. * Must be available via the supplied Provider passed to 0x.js.
* @param orderTransactionOpts Optional arguments this method accepts. * @param orderTransactionOpts Optional arguments this method accepts.
* @return Transaction hash. * @return Transaction hash.
*/ */
@@ -470,7 +470,7 @@ export class ExchangeWrapper extends ContractWrapper {
* filled (each to the specified fillAmount) or aborted. * filled (each to the specified fillAmount) or aborted.
* @param orderFillRequests An array of objects that conform to the OrderFillRequest interface. * @param orderFillRequests An array of objects that conform to the OrderFillRequest interface.
* @param takerAddress The user Ethereum address who would like to fill there orders. * @param takerAddress The user Ethereum address who would like to fill there orders.
* Must be available via the supplied Web3.Provider passed to 0x.js. * Must be available via the supplied Provider passed to 0x.js.
* @param orderTransactionOpts Optional arguments this method accepts. * @param orderTransactionOpts Optional arguments this method accepts.
* @return Transaction hash. * @return Transaction hash.
*/ */
@@ -765,7 +765,7 @@ export class ExchangeWrapper extends ContractWrapper {
* signedOrder you wish to fill. * signedOrder you wish to fill.
* @param fillTakerTokenAmount The total amount of the takerTokens you would like to fill. * @param fillTakerTokenAmount The total amount of the takerTokens you would like to fill.
* @param takerAddress The user Ethereum address who would like to fill this order. * @param takerAddress The user Ethereum address who would like to fill this order.
* Must be available via the supplied Web3.Provider passed to 0x.js. * Must be available via the supplied Provider passed to 0x.js.
*/ */
public async validateFillOrderThrowIfInvalidAsync( public async validateFillOrderThrowIfInvalidAsync(
signedOrder: SignedOrder, signedOrder: SignedOrder,
@@ -812,7 +812,7 @@ export class ExchangeWrapper extends ContractWrapper {
* signedOrder you wish to fill. * signedOrder you wish to fill.
* @param fillTakerTokenAmount The total amount of the takerTokens you would like to fill. * @param fillTakerTokenAmount The total amount of the takerTokens you would like to fill.
* @param takerAddress The user Ethereum address who would like to fill this order. * @param takerAddress The user Ethereum address who would like to fill this order.
* Must be available via the supplied Web3.Provider passed to 0x.js. * Must be available via the supplied Provider passed to 0x.js.
*/ */
public async validateFillOrKillOrderThrowIfInvalidAsync( public async validateFillOrKillOrderThrowIfInvalidAsync(
signedOrder: SignedOrder, signedOrder: SignedOrder,
@@ -920,7 +920,12 @@ export class ExchangeWrapper extends ContractWrapper {
artifacts.ExchangeArtifact, artifacts.ExchangeArtifact,
this._contractAddressIfExists, this._contractAddressIfExists,
); );
const contractInstance = new ExchangeContract(this._web3Wrapper, abi, address); const contractInstance = new ExchangeContract(
abi,
address,
this._web3Wrapper.getProvider(),
this._web3Wrapper.getContractDefaults(),
);
this._exchangeContractIfExists = contractInstance; this._exchangeContractIfExists = contractInstance;
return this._exchangeContractIfExists; return this._exchangeContractIfExists;
} }

View File

@@ -121,7 +121,12 @@ export class TokenRegistryWrapper extends ContractWrapper {
artifacts.TokenRegistryArtifact, artifacts.TokenRegistryArtifact,
this._contractAddressIfExists, this._contractAddressIfExists,
); );
const contractInstance = new TokenRegistryContract(this._web3Wrapper, abi, address); const contractInstance = new TokenRegistryContract(
abi,
address,
this._web3Wrapper.getProvider(),
this._web3Wrapper.getContractDefaults(),
);
this._tokenRegistryContractIfExists = contractInstance; this._tokenRegistryContractIfExists = contractInstance;
return this._tokenRegistryContractIfExists; return this._tokenRegistryContractIfExists;
} }

View File

@@ -63,7 +63,12 @@ export class TokenTransferProxyWrapper extends ContractWrapper {
artifacts.TokenTransferProxyArtifact, artifacts.TokenTransferProxyArtifact,
this._contractAddressIfExists, this._contractAddressIfExists,
); );
const contractInstance = new TokenTransferProxyContract(this._web3Wrapper, abi, address); const contractInstance = new TokenTransferProxyContract(
abi,
address,
this._web3Wrapper.getProvider(),
this._web3Wrapper.getContractDefaults(),
);
this._tokenTransferProxyContractIfExists = contractInstance; this._tokenTransferProxyContractIfExists = contractInstance;
return this._tokenTransferProxyContractIfExists; return this._tokenTransferProxyContractIfExists;
} }

View File

@@ -421,7 +421,12 @@ export class TokenWrapper extends ContractWrapper {
artifacts.TokenArtifact, artifacts.TokenArtifact,
normalizedTokenAddress, normalizedTokenAddress,
); );
const contractInstance = new TokenContract(this._web3Wrapper, abi, address); const contractInstance = new TokenContract(
abi,
address,
this._web3Wrapper.getProvider(),
this._web3Wrapper.getContractDefaults(),
);
tokenContract = contractInstance; tokenContract = contractInstance;
this._tokenContractsByAddress[normalizedTokenAddress] = tokenContract; this._tokenContractsByAddress[normalizedTokenAddress] = tokenContract;
return tokenContract; return tokenContract;

View File

@@ -1,11 +1,3 @@
declare module 'web3_beta';
declare module 'request-promise-native';
// semver-sort declarations
declare module 'semver-sort' {
const desc: (versions: string[]) => string[];
}
declare module '*.json' { declare module '*.json' {
const json: any; const json: any;
/* tslint:disable */ /* tslint:disable */

View File

@@ -11,7 +11,6 @@ export {
OrderCancellationRequest, OrderCancellationRequest,
OrderFillRequest, OrderFillRequest,
ContractEventArgs, ContractEventArgs,
Web3Provider,
ZeroExConfig, ZeroExConfig,
MethodOpts, MethodOpts,
OrderTransactionOpts, OrderTransactionOpts,
@@ -32,6 +31,7 @@ export {
ContractEventArg, ContractEventArg,
LogWithDecodedArgs, LogWithDecodedArgs,
Order, Order,
Provider,
SignedOrder, SignedOrder,
ECSignature, ECSignature,
TransactionReceipt, TransactionReceipt,

View File

@@ -154,14 +154,6 @@ export interface OrderFillRequest {
export type AsyncMethod = (...args: any[]) => Promise<any>; export type AsyncMethod = (...args: any[]) => Promise<any>;
export type SyncMethod = (...args: any[]) => any; export type SyncMethod = (...args: any[]) => any;
/**
* We re-export the `Web3.Provider` type specified in the Web3 Typescript typings
* since it is the type of the `provider` argument to the `ZeroEx` constructor.
* It is however a `Web3` library type, not a native `0x.js` type. To learn more
* about providers, visit https://0xproject.com/wiki#Web3-Provider-Explained
*/
export type Web3Provider = Web3.Provider;
/* /*
* orderExpirationCheckingIntervalMs: How often to check for expired orders. Default: 50 * orderExpirationCheckingIntervalMs: How often to check for expired orders. Default: 50
* eventPollingIntervalMs: How often to poll the Ethereum node for new events. Default: 200 * eventPollingIntervalMs: How often to poll the Ethereum node for new events. Default: 200

View File

@@ -1,5 +1,6 @@
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils'; import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
import { BigNumber } from '@0xproject/utils'; import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as chai from 'chai'; import * as chai from 'chai';
import 'mocha'; import 'mocha';
import * as Web3 from 'web3'; import * as Web3 from 'web3';
@@ -59,7 +60,7 @@ describe('EtherTokenWrapper', () => {
userAddresses = await zeroEx.getAvailableAddressesAsync(); userAddresses = await zeroEx.getAvailableAddressesAsync();
addressWithETH = userAddresses[0]; addressWithETH = userAddresses[0];
wethContractAddress = zeroEx.etherToken.getContractAddressIfExists() as string; wethContractAddress = zeroEx.etherToken.getContractAddressIfExists() as string;
depositWeiAmount = (zeroEx as any)._web3Wrapper.toWei(new BigNumber(5)); depositWeiAmount = Web3Wrapper.toWei(new BigNumber(5));
decimalPlaces = 7; decimalPlaces = 7;
addressWithoutFunds = userAddresses[1]; addressWithoutFunds = userAddresses[1];
}); });
@@ -105,7 +106,7 @@ describe('EtherTokenWrapper', () => {
it('should throw if user has insufficient ETH balance for deposit', async () => { it('should throw if user has insufficient ETH balance for deposit', async () => {
const preETHBalance = await (zeroEx as any)._web3Wrapper.getBalanceInWeiAsync(addressWithETH); const preETHBalance = await (zeroEx as any)._web3Wrapper.getBalanceInWeiAsync(addressWithETH);
const extraETHBalance = (zeroEx as any)._web3Wrapper.toWei(5, 'ether'); const extraETHBalance = Web3Wrapper.toWei(new BigNumber(5));
const overETHBalanceinWei = preETHBalance.add(extraETHBalance); const overETHBalanceinWei = preETHBalance.add(extraETHBalance);
return expect( return expect(

View File

@@ -36,7 +36,12 @@ export class FillScenarios {
for (const token of this._tokens) { for (const token of this._tokens) {
if (token.symbol !== 'ZRX' && token.symbol !== 'WETH') { if (token.symbol !== 'ZRX' && token.symbol !== 'WETH') {
const defaults = {}; const defaults = {};
const dummyToken = new DummyTokenContract(web3Wrapper, artifacts.DummyTokenArtifact.abi, token.address); const dummyToken = new DummyTokenContract(
artifacts.DummyTokenArtifact.abi,
token.address,
web3Wrapper.getProvider(),
web3Wrapper.getContractDefaults(),
);
const tokenSupply = ZeroEx.toBaseUnitAmount(INITIAL_COINBASE_TOKEN_SUPPLY_IN_UNITS, token.decimals); const tokenSupply = ZeroEx.toBaseUnitAmount(INITIAL_COINBASE_TOKEN_SUPPLY_IN_UNITS, token.decimals);
const txHash = await dummyToken.setBalance.sendTransactionAsync(this._coinbase, tokenSupply, { const txHash = await dummyToken.setBalance.sendTransactionAsync(this._coinbase, tokenSupply, {
from: this._coinbase, from: this._coinbase,

View File

@@ -1,4 +1,13 @@
[ [
{
"timestamp": 1523462196,
"version": "0.2.10",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{ {
"timestamp": 1522673609, "timestamp": 1522673609,
"version": "0.2.9", "version": "0.2.9",
@@ -15,8 +24,7 @@
{ {
"note": "Dependencies updated" "note": "Dependencies updated"
} }
], ]
"isPublished": true
}, },
{ {
"version": "0.2.5", "version": "0.2.5",
@@ -26,8 +34,7 @@
"pr": 452 "pr": 452
} }
], ],
"timestamp": 1521298800, "timestamp": 1521298800
"isPublished": true
}, },
{ {
"version": "0.2.4", "version": "0.2.4",
@@ -47,8 +54,7 @@
"pr": 413 "pr": 413
} }
], ],
"timestamp": 1520089200, "timestamp": 1520089200
"isPublished": true
}, },
{ {
"version": "0.2.1", "version": "0.2.1",
@@ -58,8 +64,7 @@
"pr": 389 "pr": 389
} }
], ],
"timestamp": 1518102000, "timestamp": 1518102000
"isPublished": true
}, },
{ {
"version": "0.2.0", "version": "0.2.0",
@@ -74,8 +79,7 @@
"pr": 388 "pr": 388
} }
], ],
"timestamp": 1517929200, "timestamp": 1517929200
"isPublished": true
}, },
{ {
"version": "0.1.0", "version": "0.1.0",
@@ -93,7 +97,6 @@
"pr": 304 "pr": 304
} }
], ],
"timestamp": 1515596400, "timestamp": 1515596400
"isPublished": true
} }
] ]

View File

@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG CHANGELOG
## v0.2.10 - _April 11, 2018_
* Dependencies updated
## v0.2.9 - _April 2, 2018_ ## v0.2.9 - _April 2, 2018_
* Dependencies updated * Dependencies updated

View File

@@ -57,3 +57,61 @@ See the [type definition](https://github.com/0xProject/0x-monorepo/tree/developm
## Output files ## Output files
Output files will be generated within an output folder with names converted to camel case and taken from abi file names. If you already have some files in that folder they will be overwritten. Output files will be generated within an output folder with names converted to camel case and taken from abi file names. If you already have some files in that folder they will be overwritten.
## Contributing
We welcome improvements and fixes from the wider community! To report bugs within this package, please create an issue in this repository.
Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
### Install dependencies
If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
```bash
yarn config set workspaces-experimental true
```
Then install dependencies
```bash
yarn install
```
### Build
If this is your **first** time building this package, you must first build **all** packages within the monorepo. This is because packages that depend on other packages located inside this monorepo are symlinked when run from **within** the monorepo. This allows you to make changes across multiple packages without first publishing dependent packages to NPM. To build all packages, run the following from the monorepo root directory:
```bash
yarn lerna:rebuild
```
Or continuously rebuild on change:
```bash
yarn dev
```
You can also build this specific package by running the following from within its directory:
```bash
yarn build
```
or continuously rebuild on change:
```bash
yarn build:watch
```
### Clean
```bash
yarn clean
```
### Lint
```bash
yarn lint
```

View File

@@ -1,6 +1,6 @@
{ {
"name": "@0xproject/abi-gen", "name": "@0xproject/abi-gen",
"version": "0.2.8", "version": "0.2.10",
"description": "Generate contract wrappers from ABI and handlebars templates", "description": "Generate contract wrappers from ABI and handlebars templates",
"main": "lib/index.js", "main": "lib/index.js",
"types": "lib/index.d.ts", "types": "lib/index.d.ts",
@@ -24,9 +24,9 @@
}, },
"homepage": "https://github.com/0xProject/0x-monorepo/packages/abi-gen/README.md", "homepage": "https://github.com/0xProject/0x-monorepo/packages/abi-gen/README.md",
"dependencies": { "dependencies": {
"@0xproject/types": "^0.4.2", "@0xproject/types": "^0.6.0",
"@0xproject/typescript-typings": "^0.0.2", "@0xproject/typescript-typings": "^0.1.0",
"@0xproject/utils": "^0.4.4", "@0xproject/utils": "^0.5.1",
"chalk": "^2.3.0", "chalk": "^2.3.0",
"glob": "^7.1.2", "glob": "^7.1.2",
"handlebars": "^4.0.11", "handlebars": "^4.0.11",
@@ -36,8 +36,8 @@
"yargs": "^10.0.3" "yargs": "^10.0.3"
}, },
"devDependencies": { "devDependencies": {
"@0xproject/monorepo-scripts": "^0.1.15", "@0xproject/monorepo-scripts": "^0.1.17",
"@0xproject/tslint-config": "^0.4.13", "@0xproject/tslint-config": "^0.4.15",
"@types/glob": "^5.0.33", "@types/glob": "^5.0.33",
"@types/handlebars": "^4.0.36", "@types/handlebars": "^4.0.36",
"@types/mkdirp": "^0.5.1", "@types/mkdirp": "^0.5.1",

View File

@@ -1,8 +1,3 @@
declare function toSnakeCase(str: string): string;
declare module 'to-snake-case' {
export = toSnakeCase;
}
declare module '*.json' { declare module '*.json' {
const json: any; const json: any;
/* tslint:disable */ /* tslint:disable */

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env node #!/usr/bin/env node
import { AbiDefinition, ConstructorAbi, EventAbi, MethodAbi } from '@0xproject/types'; import { AbiDefinition, ConstructorAbi, EventAbi, MethodAbi } from '@0xproject/types';
import { logUtils } from '@0xproject/utils'; import { abiUtils, logUtils } from '@0xproject/utils';
import chalk from 'chalk'; import chalk from 'chalk';
import * as fs from 'fs'; import * as fs from 'fs';
import { sync as globSync } from 'glob'; import { sync as globSync } from 'glob';
@@ -12,7 +12,7 @@ import * as yargs from 'yargs';
import toSnakeCase = require('to-snake-case'); import toSnakeCase = require('to-snake-case');
import { ContextData, ContractsBackend, ParamKind } from './types'; import { ContextData, ContractsBackend, Method, ParamKind } from './types';
import { utils } from './utils'; import { utils } from './utils';
const ABI_TYPE_CONSTRUCTOR = 'constructor'; const ABI_TYPE_CONSTRUCTOR = 'constructor';
@@ -83,7 +83,6 @@ function writeOutputFile(name: string, renderedTsCode: string): void {
Handlebars.registerHelper('parameterType', utils.solTypeToTsType.bind(utils, ParamKind.Input, args.backend)); Handlebars.registerHelper('parameterType', utils.solTypeToTsType.bind(utils, ParamKind.Input, args.backend));
Handlebars.registerHelper('returnType', utils.solTypeToTsType.bind(utils, ParamKind.Output, args.backend)); Handlebars.registerHelper('returnType', utils.solTypeToTsType.bind(utils, ParamKind.Output, args.backend));
if (args.partials) { if (args.partials) {
registerPartials(args.partials); registerPartials(args.partials);
} }
@@ -126,11 +125,12 @@ for (const abiFileName of abiFileNames) {
} }
const methodAbis = ABI.filter((abi: AbiDefinition) => abi.type === ABI_TYPE_METHOD) as MethodAbi[]; const methodAbis = ABI.filter((abi: AbiDefinition) => abi.type === ABI_TYPE_METHOD) as MethodAbi[];
const methodsData = _.map(methodAbis, methodAbi => { const sanitizedMethodAbis = abiUtils.renameOverloadedMethods(methodAbis) as MethodAbi[];
_.map(methodAbi.inputs, (input, i: number) => { const methodsData = _.map(methodAbis, (methodAbi, methodAbiIndex: number) => {
_.forEach(methodAbi.inputs, (input, inputIndex: number) => {
if (_.isEmpty(input.name)) { if (_.isEmpty(input.name)) {
// Auto-generated getters don't have parameter names // Auto-generated getters don't have parameter names
input.name = `index_${i}`; input.name = `index_${inputIndex}`;
} }
}); });
// This will make templates simpler // This will make templates simpler
@@ -138,6 +138,8 @@ for (const abiFileName of abiFileNames) {
...methodAbi, ...methodAbi,
singleReturnValue: methodAbi.outputs.length === 1, singleReturnValue: methodAbi.outputs.length === 1,
hasReturnValue: methodAbi.outputs.length !== 0, hasReturnValue: methodAbi.outputs.length !== 0,
tsName: sanitizedMethodAbis[methodAbiIndex].name,
functionSignature: abiUtils.getFunctionSignature(methodAbi),
}; };
return methodData; return methodData;
}); });

View File

@@ -5,13 +5,6 @@ export enum ParamKind {
Output = 'output', Output = 'output',
} }
export enum AbiType {
Function = 'function',
Constructor = 'constructor',
Event = 'event',
Fallback = 'fallback',
}
export enum ContractsBackend { export enum ContractsBackend {
Web3 = 'web3', Web3 = 'web3',
Ethers = 'ethers', Ethers = 'ethers',
@@ -20,6 +13,8 @@ export enum ContractsBackend {
export interface Method extends MethodAbi { export interface Method extends MethodAbi {
singleReturnValue: boolean; singleReturnValue: boolean;
hasReturnValue: boolean; hasReturnValue: boolean;
tsName: string;
functionSignature: string;
} }
export interface ContextData { export interface ContextData {

View File

@@ -1,9 +1,9 @@
import { ConstructorAbi, DataItem } from '@0xproject/types'; import { AbiType, ConstructorAbi, DataItem } from '@0xproject/types';
import * as fs from 'fs'; import * as fs from 'fs';
import * as _ from 'lodash'; import * as _ from 'lodash';
import * as path from 'path'; import * as path from 'path';
import { AbiType, ContractsBackend, ParamKind } from './types'; import { ContractsBackend, ParamKind } from './types';
export const utils = { export const utils = {
solTypeToTsType(paramKind: ParamKind, backend: ContractsBackend, solType: string, components?: DataItem[]): string { solTypeToTsType(paramKind: ParamKind, backend: ContractsBackend, solType: string, components?: DataItem[]): string {

View File

@@ -1,4 +1,13 @@
[ [
{
"timestamp": 1523462196,
"version": "0.2.6",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{ {
"timestamp": 1522673609, "timestamp": 1522673609,
"version": "0.2.5", "version": "0.2.5",
@@ -15,8 +24,7 @@
{ {
"note": "Dependencies updated" "note": "Dependencies updated"
} }
], ]
"isPublished": true
}, },
{ {
"version": "0.2.0", "version": "0.2.0",
@@ -26,8 +34,7 @@
"pr": 412 "pr": 412
} }
], ],
"timestamp": 1520434800, "timestamp": 1520434800
"isPublished": true
}, },
{ {
"version": "0.1.0", "version": "0.1.0",
@@ -41,8 +48,7 @@
"pr": 385 "pr": 385
} }
], ],
"timestamp": 1520089200, "timestamp": 1520089200
"isPublished": true
}, },
{ {
"version": "0.0.18", "version": "0.0.18",
@@ -52,8 +58,7 @@
"pr": 389 "pr": 389
} }
], ],
"timestamp": 1486566000, "timestamp": 1486566000
"isPublished": true
}, },
{ {
"version": "0.0.4", "version": "0.0.4",
@@ -66,7 +71,6 @@
"Added assertion isValidBaseUnitAmount which checks both that the value is a valid bigNumber and that it does not contain decimals." "Added assertion isValidBaseUnitAmount which checks both that the value is a valid bigNumber and that it does not contain decimals."
} }
], ],
"timestamp": 1510585200, "timestamp": 1510585200
"isPublished": true
} }
] ]

View File

@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG CHANGELOG
## v0.2.6 - _April 11, 2018_
* Dependencies updated
## v0.2.5 - _April 2, 2018_ ## v0.2.5 - _April 2, 2018_
* Dependencies updated * Dependencies updated

View File

@@ -26,11 +26,11 @@ If your project is in [TypeScript](https://www.typescriptlang.org/), add the fol
## Contributing ## Contributing
We strongly encourage that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository. We welcome improvements and fixes from the wider community! To report bugs within this package, please create an issue in this repository.
Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started. Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
### Install Dependencies ### Install dependencies
If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them: If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
@@ -46,10 +46,36 @@ yarn install
### Build ### Build
If this is your **first** time building this package, you must first build **all** packages within the monorepo. This is because packages that depend on other packages located inside this monorepo are symlinked when run from **within** the monorepo. This allows you to make changes across multiple packages without first publishing dependent packages to NPM. To build all packages, run the following from the monorepo root directory:
```bash
yarn lerna:rebuild
```
Or continuously rebuild on change:
```bash
yarn dev
```
You can also build this specific package by running the following from within its directory:
```bash ```bash
yarn build yarn build
``` ```
or continuously rebuild on change:
```bash
yarn build:watch
```
### Clean
```bash
yarn clean
```
### Lint ### Lint
```bash ```bash

View File

@@ -1,6 +1,6 @@
{ {
"name": "@0xproject/assert", "name": "@0xproject/assert",
"version": "0.2.4", "version": "0.2.6",
"description": "Provides a standard way of performing type and schema validation across 0x projects", "description": "Provides a standard way of performing type and schema validation across 0x projects",
"main": "lib/src/index.js", "main": "lib/src/index.js",
"types": "lib/src/index.d.ts", "types": "lib/src/index.d.ts",
@@ -27,8 +27,8 @@
}, },
"homepage": "https://github.com/0xProject/0x-monorepo/packages/assert/README.md", "homepage": "https://github.com/0xProject/0x-monorepo/packages/assert/README.md",
"devDependencies": { "devDependencies": {
"@0xproject/monorepo-scripts": "^0.1.15", "@0xproject/monorepo-scripts": "^0.1.17",
"@0xproject/tslint-config": "^0.4.13", "@0xproject/tslint-config": "^0.4.15",
"@types/lodash": "4.14.104", "@types/lodash": "4.14.104",
"@types/mocha": "^2.2.42", "@types/mocha": "^2.2.42",
"@types/valid-url": "^1.0.2", "@types/valid-url": "^1.0.2",
@@ -43,9 +43,9 @@
"typescript": "2.7.1" "typescript": "2.7.1"
}, },
"dependencies": { "dependencies": {
"@0xproject/json-schemas": "^0.7.18", "@0xproject/json-schemas": "^0.7.20",
"@0xproject/typescript-typings": "^0.0.2", "@0xproject/typescript-typings": "^0.1.0",
"@0xproject/utils": "^0.4.4", "@0xproject/utils": "^0.5.1",
"lodash": "^4.17.4", "lodash": "^4.17.4",
"valid-url": "^1.0.9" "valid-url": "^1.0.9"
}, },

View File

@@ -61,7 +61,7 @@ export const assert = {
}, },
isWeb3Provider(variableName: string, value: any): void { isWeb3Provider(variableName: string, value: any): void {
const isWeb3Provider = _.isFunction(value.send) || _.isFunction(value.sendAsync); const isWeb3Provider = _.isFunction(value.send) || _.isFunction(value.sendAsync);
this.assert(isWeb3Provider, this.typeAssertionMessage(variableName, 'Web3.Provider', value)); this.assert(isWeb3Provider, this.typeAssertionMessage(variableName, 'Provider', value));
}, },
doesConformToSchema(variableName: string, value: any, schema: Schema, subSchemas?: Schema[]): void { doesConformToSchema(variableName: string, value: any, schema: Schema, subSchemas?: Schema[]): void {
const schemaValidator = new SchemaValidator(); const schemaValidator = new SchemaValidator();

View File

@@ -1,4 +1,14 @@
[ [
{
"version": "0.2.0",
"changes": [
{
"note": "Contract wrappers now accept Provider and defaults instead of Web3Wrapper",
"pr": 501
}
],
"timestamp": 1523462196
},
{ {
"version": "0.1.0", "version": "0.1.0",
"changes": [ "changes": [
@@ -24,8 +34,7 @@
{ {
"note": "Dependencies updated" "note": "Dependencies updated"
} }
], ]
"isPublished": true
}, },
{ {
"version": "0.0.2", "version": "0.0.2",
@@ -34,7 +43,6 @@
"note": "Initial release" "note": "Initial release"
} }
], ],
"timestamp": 1520089200, "timestamp": 1520089200
"isPublished": true
} }
] ]

View File

@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG CHANGELOG
## v0.2.0 - _April 11, 2018_
* Contract wrappers now accept Provider and defaults instead of Web3Wrapper (#501)
## v0.1.0 - _April 2, 2018_ ## v0.1.0 - _April 2, 2018_
* Add tests for traversing ABI tree (#485) * Add tests for traversing ABI tree (#485)

View File

@@ -1,6 +1,6 @@
{ {
"name": "@0xproject/base-contract", "name": "@0xproject/base-contract",
"version": "0.0.6", "version": "0.2.0",
"description": "0x Base TS contract", "description": "0x Base TS contract",
"main": "lib/src/index.js", "main": "lib/src/index.js",
"types": "lib/src/index.d.ts", "types": "lib/src/index.d.ts",
@@ -26,22 +26,22 @@
}, },
"homepage": "https://github.com/0xProject/0x-monorepo/packages/base-contract/README.md", "homepage": "https://github.com/0xProject/0x-monorepo/packages/base-contract/README.md",
"devDependencies": { "devDependencies": {
"@0xproject/monorepo-scripts": "^0.1.15", "@0xproject/monorepo-scripts": "^0.1.17",
"@0xproject/tslint-config": "^0.4.13", "@0xproject/tslint-config": "^0.4.15",
"@types/lodash": "4.14.104", "@types/lodash": "4.14.104",
"chai": "^4.0.1",
"copyfiles": "^1.2.0", "copyfiles": "^1.2.0",
"mocha": "^4.0.1",
"npm-run-all": "^4.1.2", "npm-run-all": "^4.1.2",
"shx": "^0.2.2", "shx": "^0.2.2",
"chai": "^4.0.1",
"mocha": "^4.0.1",
"tslint": "5.8.0", "tslint": "5.8.0",
"typescript": "2.7.1" "typescript": "2.7.1"
}, },
"dependencies": { "dependencies": {
"@0xproject/utils": "^0.4.3", "@0xproject/types": "^0.6.0",
"@0xproject/types": "^0.4.2", "@0xproject/typescript-typings": "^0.1.0",
"@0xproject/typescript-typings": "^0.0.2", "@0xproject/utils": "^0.5.1",
"@0xproject/web3-wrapper": "^0.4.0", "@0xproject/web3-wrapper": "^0.6.0",
"ethers-contracts": "^2.2.1", "ethers-contracts": "^2.2.1",
"lodash": "^4.17.4" "lodash": "^4.17.4"
}, },

View File

@@ -1,13 +1,26 @@
import { ContractAbi, DataItem, TxData, TxDataPayable } from '@0xproject/types'; import {
import { BigNumber } from '@0xproject/utils'; AbiDefinition,
AbiType,
ContractAbi,
DataItem,
MethodAbi,
Provider,
TxData,
TxDataPayable,
} from '@0xproject/types';
import { abiUtils, BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper'; import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as ethersContracts from 'ethers-contracts'; import * as ethersContracts from 'ethers-contracts';
import * as _ from 'lodash'; import * as _ from 'lodash';
import { formatABIDataItem } from './utils'; import { formatABIDataItem } from './utils';
export interface EthersInterfaceByFunctionSignature {
[key: string]: ethersContracts.Interface;
}
export class BaseContract { export class BaseContract {
protected _ethersInterface: ethersContracts.Interface; protected _ethersInterfacesByFunctionSignature: EthersInterfaceByFunctionSignature;
protected _web3Wrapper: Web3Wrapper; protected _web3Wrapper: Web3Wrapper;
public abi: ContractAbi; public abi: ContractAbi;
public address: string; public address: string;
@@ -49,10 +62,37 @@ export class BaseContract {
} }
return txDataWithDefaults; return txDataWithDefaults;
} }
constructor(web3Wrapper: Web3Wrapper, abi: ContractAbi, address: string) { protected _lookupEthersInterface(functionSignature: string): ethersContracts.Interface {
this._web3Wrapper = web3Wrapper; const ethersInterface = this._ethersInterfacesByFunctionSignature[functionSignature];
if (_.isUndefined(ethersInterface)) {
throw new Error(`Failed to lookup method with function signature '${functionSignature}'`);
}
return ethersInterface;
}
protected _lookupAbi(functionSignature: string): MethodAbi {
const methodAbi = _.find(this.abi, (abiDefinition: AbiDefinition) => {
if (abiDefinition.type !== AbiType.Function) {
return false;
}
const abiFunctionSignature = abiUtils.getFunctionSignature(abiDefinition);
if (abiFunctionSignature === functionSignature) {
return true;
}
return false;
}) as MethodAbi;
return methodAbi;
}
constructor(abi: ContractAbi, address: string, provider: Provider, defaults?: Partial<TxData>) {
this._web3Wrapper = new Web3Wrapper(provider, defaults);
this.abi = abi; this.abi = abi;
this.address = address; this.address = address;
this._ethersInterface = new ethersContracts.Interface(abi); const methodAbis = this.abi.filter(
(abiDefinition: AbiDefinition) => abiDefinition.type === AbiType.Function,
) as MethodAbi[];
this._ethersInterfacesByFunctionSignature = {};
_.each(methodAbis, methodAbi => {
const functionSignature = abiUtils.getFunctionSignature(methodAbi);
this._ethersInterfacesByFunctionSignature[functionSignature] = new ethersContracts.Interface([methodAbi]);
});
} }
} }

View File

@@ -1,4 +1,13 @@
[ [
{
"timestamp": 1523462196,
"version": "0.6.9",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{ {
"timestamp": 1522673609, "timestamp": 1522673609,
"version": "0.6.8", "version": "0.6.8",
@@ -15,8 +24,7 @@
{ {
"note": "Dependencies updated" "note": "Dependencies updated"
} }
], ]
"isPublished": true
}, },
{ {
"version": "0.6.4", "version": "0.6.4",
@@ -26,8 +34,7 @@
"pr": 456 "pr": 456
} }
], ],
"timestamp": 1521298800, "timestamp": 1521298800
"isPublished": true
}, },
{ {
"version": "0.6.2", "version": "0.6.2",
@@ -37,8 +44,7 @@
"pr": 407 "pr": 407
} }
], ],
"timestamp": 1518706800, "timestamp": 1518706800
"isPublished": true
}, },
{ {
"version": "0.6.0", "version": "0.6.0",
@@ -52,8 +58,7 @@
"pr": 406 "pr": 406
} }
], ],
"timestamp": 1518706800, "timestamp": 1518706800
"isPublished": true
}, },
{ {
"version": "0.5.7", "version": "0.5.7",
@@ -63,8 +68,7 @@
"pr": 389 "pr": 389
} }
], ],
"timestamp": 1518102000, "timestamp": 1518102000
"isPublished": true
}, },
{ {
"version": "0.5.0", "version": "0.5.0",
@@ -82,8 +86,7 @@
"pr": 318 "pr": 318
} }
], ],
"timestamp": 1516114800, "timestamp": 1516114800
"isPublished": true
}, },
{ {
"version": "0.4.0", "version": "0.4.0",
@@ -93,8 +96,7 @@
"pr": 296 "pr": 296
} }
], ],
"timestamp": 1515596400, "timestamp": 1515596400
"isPublished": true
}, },
{ {
"version": "0.3.0", "version": "0.3.0",
@@ -108,8 +110,7 @@
"pr": 256 "pr": 256
} }
], ],
"timestamp": 1512658800, "timestamp": 1512658800
"isPublished": true
}, },
{ {
"version": "0.2.0", "version": "0.2.0",
@@ -124,8 +125,7 @@
"note": "Remove dependency on 0x.js" "note": "Remove dependency on 0x.js"
} }
], ],
"timestamp": 1511881200, "timestamp": 1511881200
"isPublished": true
}, },
{ {
"version": "0.1.0", "version": "0.1.0",
@@ -134,7 +134,6 @@
"note": "Provide a HttpClient class for interacting with standard relayer api compliant HTTP urls" "note": "Provide a HttpClient class for interacting with standard relayer api compliant HTTP urls"
} }
], ],
"timestamp": 1511276400, "timestamp": 1511276400
"isPublished": true
} }
] ]

View File

@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG CHANGELOG
## v0.6.9 - _April 11, 2018_
* Dependencies updated
## v0.6.8 - _April 2, 2018_ ## v0.6.8 - _April 2, 2018_
* Dependencies updated * Dependencies updated

View File

@@ -23,11 +23,11 @@ If your project is in [TypeScript](https://www.typescriptlang.org/), add the fol
## Contributing ## Contributing
We strongly recommend that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository. We welcome improvements and fixes from the wider community! To report bugs within this package, please create an issue in this repository.
Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started. Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
### Install Dependencies ### Install dependencies
If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them: If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
@@ -43,10 +43,36 @@ yarn install
### Build ### Build
If this is your **first** time building this package, you must first build **all** packages within the monorepo. This is because packages that depend on other packages located inside this monorepo are symlinked when run from **within** the monorepo. This allows you to make changes across multiple packages without first publishing dependent packages to NPM. To build all packages, run the following from the monorepo root directory:
```bash
yarn lerna:rebuild
```
Or continuously rebuild on change:
```bash
yarn dev
```
You can also build this specific package by running the following from within its directory:
```bash ```bash
yarn build yarn build
``` ```
or continuously rebuild on change:
```bash
yarn build:watch
```
### Clean
```bash
yarn clean
```
### Lint ### Lint
```bash ```bash

View File

@@ -1,6 +1,6 @@
{ {
"name": "@0xproject/connect", "name": "@0xproject/connect",
"version": "0.6.7", "version": "0.6.9",
"description": "A javascript library for interacting with the standard relayer api", "description": "A javascript library for interacting with the standard relayer api",
"keywords": [ "keywords": [
"connect", "connect",
@@ -50,19 +50,19 @@
}, },
"homepage": "https://github.com/0xProject/0x-monorepo/packages/connect/README.md", "homepage": "https://github.com/0xProject/0x-monorepo/packages/connect/README.md",
"dependencies": { "dependencies": {
"@0xproject/assert": "^0.2.4", "@0xproject/assert": "^0.2.6",
"@0xproject/json-schemas": "^0.7.18", "@0xproject/json-schemas": "^0.7.20",
"@0xproject/types": "^0.4.2", "@0xproject/types": "^0.6.0",
"@0xproject/typescript-typings": "^0.0.2", "@0xproject/typescript-typings": "^0.1.0",
"@0xproject/utils": "^0.4.4", "@0xproject/utils": "^0.5.1",
"isomorphic-fetch": "^2.2.1", "isomorphic-fetch": "^2.2.1",
"lodash": "^4.17.4", "lodash": "^4.17.4",
"query-string": "^5.0.1", "query-string": "^5.0.1",
"websocket": "^1.0.25" "websocket": "^1.0.25"
}, },
"devDependencies": { "devDependencies": {
"@0xproject/monorepo-scripts": "^0.1.15", "@0xproject/monorepo-scripts": "^0.1.17",
"@0xproject/tslint-config": "^0.4.13", "@0xproject/tslint-config": "^0.4.15",
"@types/fetch-mock": "^5.12.1", "@types/fetch-mock": "^5.12.1",
"@types/lodash": "4.14.104", "@types/lodash": "4.14.104",
"@types/mocha": "^2.2.42", "@types/mocha": "^2.2.42",

View File

@@ -1,5 +1,3 @@
declare module 'async-child-process';
declare module '*.json' { declare module '*.json' {
const value: any; const value: any;
export default value; export default value;

View File

@@ -5,7 +5,7 @@
// tslint:disable:no-consecutive-blank-lines // tslint:disable:no-consecutive-blank-lines
// tslint:disable-next-line:no-unused-variable // tslint:disable-next-line:no-unused-variable
import { BaseContract } from '@0xproject/base-contract'; import { BaseContract } from '@0xproject/base-contract';
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, DataItem, MethodAbi, TxData, TxDataPayable } from '@0xproject/types'; import { BlockParam, BlockParamLiteral, CallData, ContractAbi, DataItem, MethodAbi, Provider, TxData, TxDataPayable } from '@0xproject/types';
import { BigNumber, classUtils, promisify } from '@0xproject/utils'; import { BigNumber, classUtils, promisify } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper'; import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as ethersContracts from 'ethers-contracts'; import * as ethersContracts from 'ethers-contracts';
@@ -39,8 +39,8 @@ export class {{contractName}}Contract extends BaseContract {
{{> tx contractName=../contractName}} {{> tx contractName=../contractName}}
{{/this.constant}} {{/this.constant}}
{{/each}} {{/each}}
constructor(web3Wrapper: Web3Wrapper, abi: ContractAbi, address: string) { constructor(abi: ContractAbi, address: string, provider: Provider, defaults?: Partial<TxData>) {
super(web3Wrapper, abi, address); super(abi, address, provider, defaults);
classUtils.bindAll(this, ['_ethersInterface', 'address', 'abi', '_web3Wrapper']); classUtils.bindAll(this, ['_ethersInterfacesByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
} }
} // tslint:disable:max-file-line-count } // tslint:disable:max-file-line-count

View File

@@ -5,9 +5,9 @@ async callAsync(
defaultBlock?: BlockParam, defaultBlock?: BlockParam,
): Promise<{{> return_type outputs=outputs}}> { ): Promise<{{> return_type outputs=outputs}}> {
const self = this as any as {{contractName}}Contract; const self = this as any as {{contractName}}Contract;
const inputAbi = (_.find(self.abi, {name: '{{this.name}}'}) as MethodAbi).inputs; const inputAbi = self._lookupAbi('{{this.functionSignature}}').inputs;
[{{> params inputs=inputs}}] = BaseContract._formatABIDataItemList(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(self)); [{{> params inputs=inputs}}] = BaseContract._formatABIDataItemList(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(self));
const encodedData = self._ethersInterface.functions.{{this.name}}( const encodedData = self._lookupEthersInterface('{{this.functionSignature}}').functions.{{this.name}}(
{{> params inputs=inputs}} {{> params inputs=inputs}}
).data; ).data;
const callDataWithDefaults = await self._applyDefaultsToTxDataAsync( const callDataWithDefaults = await self._applyDefaultsToTxDataAsync(

View File

@@ -1,4 +1,4 @@
public {{this.name}} = { public {{this.tsName}} = {
async sendTransactionAsync( async sendTransactionAsync(
{{> typed_params inputs=inputs}} {{> typed_params inputs=inputs}}
{{#this.payable}} {{#this.payable}}
@@ -9,17 +9,17 @@ public {{this.name}} = {
{{/this.payable}} {{/this.payable}}
): Promise<string> { ): Promise<string> {
const self = this as any as {{contractName}}Contract; const self = this as any as {{contractName}}Contract;
const inputAbi = (_.find(self.abi, {name: '{{this.name}}'}) as MethodAbi).inputs; const inputAbi = self._lookupAbi('{{this.functionSignature}}').inputs;
[{{> params inputs=inputs}}] = BaseContract._formatABIDataItemList(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(self)); [{{> params inputs=inputs}}] = BaseContract._formatABIDataItemList(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(self));
const encodedData = self._ethersInterface.functions.{{this.name}}( const encodedData = self._lookupEthersInterface('{{this.functionSignature}}').functions.{{this.name}}(
{{> params inputs=inputs}} {{> params inputs=inputs}}
).data ).data;
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ {
...txData, ...txData,
data: encodedData, data: encodedData,
}, },
self.{{this.name}}.estimateGasAsync.bind( self.{{this.tsName}}.estimateGasAsync.bind(
self, self,
{{> params inputs=inputs}} {{> params inputs=inputs}}
), ),
@@ -32,11 +32,11 @@ public {{this.name}} = {
txData: Partial<TxData> = {}, txData: Partial<TxData> = {},
): Promise<number> { ): Promise<number> {
const self = this as any as {{contractName}}Contract; const self = this as any as {{contractName}}Contract;
const inputAbi = (_.find(self.abi, {name: '{{this.name}}'}) as MethodAbi).inputs; const inputAbi = self._lookupAbi('{{this.functionSignature}}').inputs;
[{{> params inputs=inputs}}] = BaseContract._formatABIDataItemList(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(this)); [{{> params inputs=inputs}}] = BaseContract._formatABIDataItemList(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(this));
const encodedData = self._ethersInterface.functions.{{this.name}}( const encodedData = self._lookupEthersInterface('{{this.functionSignature}}').functions.{{this.name}}(
{{> params inputs=inputs}} {{> params inputs=inputs}}
).data ).data;
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{ {
...txData, ...txData,
@@ -50,11 +50,11 @@ public {{this.name}} = {
{{> typed_params inputs=inputs}} {{> typed_params inputs=inputs}}
): string { ): string {
const self = this as any as {{contractName}}Contract; const self = this as any as {{contractName}}Contract;
const inputAbi = (_.find(self.abi, {name: '{{this.name}}'}) as MethodAbi).inputs; const inputAbi = self._lookupAbi('{{this.functionSignature}}').inputs;
[{{> params inputs=inputs}}] = BaseContract._formatABIDataItemList(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(self)); [{{> params inputs=inputs}}] = BaseContract._formatABIDataItemList(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(self));
const abiEncodedTransactionData = self._ethersInterface.functions.{{this.name}}( const abiEncodedTransactionData = self._lookupEthersInterface('{{this.name}}').functions.{{this.name}}(
{{> params inputs=inputs}} {{> params inputs=inputs}}
).data ).data;
return abiEncodedTransactionData; return abiEncodedTransactionData;
}, },
{{> callAsync}} {{> callAsync}}

View File

@@ -34,11 +34,25 @@ yarn install
### Build ### Build
If this is your **first** time building this package, you must first build **all** packages within the monorepo. This is because packages that depend on other packages located inside this monorepo are symlinked when run from **within** the monorepo. This allows you to make changes across multiple packages without first publishing dependent packages to NPM. To build all packages, run the following from the monorepo root directory:
```bash
yarn lerna:rebuild
```
Or continuously rebuild on change:
```bash
yarn dev
```
You can also build this specific package by running the following from within its directory:
```bash ```bash
yarn build yarn build
``` ```
or or continuously rebuild on change:
```bash ```bash
yarn build:watch yarn build:watch

View File

@@ -1,7 +1,7 @@
{ {
"private": true, "private": true,
"name": "contracts", "name": "contracts",
"version": "2.1.20", "version": "2.1.22",
"description": "Smart contract components of 0x protocol", "description": "Smart contract components of 0x protocol",
"main": "index.js", "main": "index.js",
"directories": { "directories": {
@@ -16,7 +16,7 @@
"test:coverage": "SOLIDITY_COVERAGE=true run-s build run_mocha coverage:report:text coverage:report:lcov", "test:coverage": "SOLIDITY_COVERAGE=true run-s build run_mocha coverage:report:text coverage:report:lcov",
"run_mocha": "mocha 'lib/test/**/*.js' --timeout 100000 --bail --exit", "run_mocha": "mocha 'lib/test/**/*.js' --timeout 100000 --bail --exit",
"compile:comment": "Yarn workspaces do not link binaries correctly so we need to reference them directly https://github.com/yarnpkg/yarn/issues/3846", "compile:comment": "Yarn workspaces do not link binaries correctly so we need to reference them directly https://github.com/yarnpkg/yarn/issues/3846",
"compile": "node ../deployer/lib/src/cli.js compile --contracts ${npm_package_config_contracts} --contracts-dir src/contracts --artifacts-dir src/artifacts", "compile": "node ../deployer/lib/src/cli.js compile --contracts ${npm_package_config_contracts} --contract-dirs src/contracts --artifacts-dir src/artifacts",
"clean": "shx rm -rf ./lib", "clean": "shx rm -rf ./lib",
"generate_contract_wrappers": "node ../abi-gen/lib/index.js --abis ${npm_package_config_abis} --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/contract_wrappers/generated --backend ethers && prettier --write 'src/contract_wrappers/generated/**.ts'", "generate_contract_wrappers": "node ../abi-gen/lib/index.js --abis ${npm_package_config_abis} --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/contract_wrappers/generated --backend ethers && prettier --write 'src/contract_wrappers/generated/**.ts'",
"migrate": "yarn build && yarn compile && node ./lib/migrations/index.js", "migrate": "yarn build && yarn compile && node ./lib/migrations/index.js",
@@ -41,12 +41,10 @@
}, },
"homepage": "https://github.com/0xProject/0x-monorepo/packages/contracts/README.md", "homepage": "https://github.com/0xProject/0x-monorepo/packages/contracts/README.md",
"devDependencies": { "devDependencies": {
"@0xproject/dev-utils": "^0.3.3", "@0xproject/dev-utils": "^0.3.5",
"@0xproject/tslint-config": "^0.4.13", "@0xproject/tslint-config": "^0.4.15",
"@types/bluebird": "^3.5.3",
"@types/lodash": "4.14.104", "@types/lodash": "4.14.104",
"@types/node": "^8.0.53", "@types/node": "^8.0.53",
"@types/request-promise-native": "^1.0.2",
"@types/yargs": "^10.0.0", "@types/yargs": "^10.0.0",
"chai": "^4.0.1", "chai": "^4.0.1",
"chai-as-promised": "^7.1.0", "chai-as-promised": "^7.1.0",
@@ -63,22 +61,17 @@
"yargs": "^10.0.3" "yargs": "^10.0.3"
}, },
"dependencies": { "dependencies": {
"0x.js": "^0.34.0", "0x.js": "^0.36.0",
"@0xproject/deployer": "^0.3.4", "@0xproject/deployer": "^0.4.0",
"@0xproject/json-schemas": "^0.7.18", "@0xproject/types": "^0.6.0",
"@0xproject/types": "^0.4.2", "@0xproject/typescript-typings": "^0.1.0",
"@0xproject/typescript-typings": "^0.0.2", "@0xproject/utils": "^0.5.1",
"@0xproject/utils": "^0.4.4", "@0xproject/web3-wrapper": "^0.6.0",
"@0xproject/web3-wrapper": "^0.4.0",
"bluebird": "^3.5.0",
"bn.js": "^4.11.8", "bn.js": "^4.11.8",
"ethereumjs-abi": "^0.6.4", "ethereumjs-abi": "^0.6.4",
"ethereumjs-util": "^5.1.1", "ethereumjs-util": "^5.1.1",
"ethers-contracts": "^2.2.1", "ethers-contracts": "^2.2.1",
"isomorphic-fetch": "^2.2.1",
"lodash": "^4.17.4", "lodash": "^4.17.4",
"request": "^2.81.0", "web3": "^0.20.0"
"web3": "^0.20.0",
"web3-eth-abi": "^1.0.0-beta.24"
} }
} }

View File

@@ -9,7 +9,7 @@ import { ContractName } from '../util/types';
import { chaiSetup } from './utils/chai_setup'; import { chaiSetup } from './utils/chai_setup';
import { deployer } from './utils/deployer'; import { deployer } from './utils/deployer';
import { web3, web3Wrapper } from './utils/web3_wrapper'; import { provider, web3Wrapper } from './utils/web3_wrapper';
chaiSetup.configure(); chaiSetup.configure();
const expect = chai.expect; const expect = chai.expect;
@@ -26,7 +26,7 @@ describe('EtherToken', () => {
const etherToken = await deployer.deployAsync(ContractName.EtherToken); const etherToken = await deployer.deployAsync(ContractName.EtherToken);
etherTokenAddress = etherToken.address; etherTokenAddress = etherToken.address;
zeroEx = new ZeroEx(web3.currentProvider, { zeroEx = new ZeroEx(provider, {
gasPrice, gasPrice,
networkId: constants.TESTRPC_NETWORK_ID, networkId: constants.TESTRPC_NETWORK_ID,
}); });
@@ -51,7 +51,7 @@ describe('EtherToken', () => {
const initEthBalance = await web3Wrapper.getBalanceInWeiAsync(account); const initEthBalance = await web3Wrapper.getBalanceInWeiAsync(account);
const initEthTokenBalance = await zeroEx.token.getBalanceAsync(etherTokenAddress, account); const initEthTokenBalance = await zeroEx.token.getBalanceAsync(etherTokenAddress, account);
const ethToDeposit = new BigNumber(web3.toWei(1, 'ether')); const ethToDeposit = new BigNumber(Web3Wrapper.toWei(new BigNumber(1)));
const txHash = await zeroEx.etherToken.depositAsync(etherTokenAddress, ethToDeposit, account); const txHash = await zeroEx.etherToken.depositAsync(etherTokenAddress, ethToDeposit, account);
const receipt = await zeroEx.awaitTransactionMinedAsync(txHash); const receipt = await zeroEx.awaitTransactionMinedAsync(txHash);
@@ -76,7 +76,7 @@ describe('EtherToken', () => {
}); });
it('should convert ether tokens to ether with sufficient balance', async () => { it('should convert ether tokens to ether with sufficient balance', async () => {
const ethToDeposit = new BigNumber(web3.toWei(1, 'ether')); const ethToDeposit = new BigNumber(Web3Wrapper.toWei(new BigNumber(1)));
await zeroEx.etherToken.depositAsync(etherTokenAddress, ethToDeposit, account); await zeroEx.etherToken.depositAsync(etherTokenAddress, ethToDeposit, account);
const initEthTokenBalance = await zeroEx.token.getBalanceAsync(etherTokenAddress, account); const initEthTokenBalance = await zeroEx.token.getBalanceAsync(etherTokenAddress, account);
const initEthBalance = await web3Wrapper.getBalanceInWeiAsync(account); const initEthBalance = await web3Wrapper.getBalanceInWeiAsync(account);

View File

@@ -22,7 +22,7 @@ import { OrderFactory } from '../../util/order_factory';
import { BalancesByOwner, ContractName, ExchangeContractErrs } from '../../util/types'; import { BalancesByOwner, ContractName, ExchangeContractErrs } from '../../util/types';
import { chaiSetup } from '../utils/chai_setup'; import { chaiSetup } from '../utils/chai_setup';
import { deployer } from '../utils/deployer'; import { deployer } from '../utils/deployer';
import { web3, web3Wrapper } from '../utils/web3_wrapper'; import { provider, web3Wrapper } from '../utils/web3_wrapper';
chaiSetup.configure(); chaiSetup.configure();
const expect = chai.expect; const expect = chai.expect;
@@ -59,22 +59,22 @@ describe('Exchange', () => {
deployer.deployAsync(ContractName.DummyToken, constants.DUMMY_TOKEN_ARGS), deployer.deployAsync(ContractName.DummyToken, constants.DUMMY_TOKEN_ARGS),
deployer.deployAsync(ContractName.DummyToken, constants.DUMMY_TOKEN_ARGS), deployer.deployAsync(ContractName.DummyToken, constants.DUMMY_TOKEN_ARGS),
]); ]);
rep = new DummyTokenContract(web3Wrapper, repInstance.abi, repInstance.address); rep = new DummyTokenContract(repInstance.abi, repInstance.address, provider);
dgd = new DummyTokenContract(web3Wrapper, dgdInstance.abi, dgdInstance.address); dgd = new DummyTokenContract(dgdInstance.abi, dgdInstance.address, provider);
zrx = new DummyTokenContract(web3Wrapper, zrxInstance.abi, zrxInstance.address); zrx = new DummyTokenContract(zrxInstance.abi, zrxInstance.address, provider);
const tokenTransferProxyInstance = await deployer.deployAsync(ContractName.TokenTransferProxy); const tokenTransferProxyInstance = await deployer.deployAsync(ContractName.TokenTransferProxy);
tokenTransferProxy = new TokenTransferProxyContract( tokenTransferProxy = new TokenTransferProxyContract(
web3Wrapper,
tokenTransferProxyInstance.abi, tokenTransferProxyInstance.abi,
tokenTransferProxyInstance.address, tokenTransferProxyInstance.address,
provider,
); );
const exchangeInstance = await deployer.deployAsync(ContractName.Exchange, [ const exchangeInstance = await deployer.deployAsync(ContractName.Exchange, [
zrx.address, zrx.address,
tokenTransferProxy.address, tokenTransferProxy.address,
]); ]);
exchange = new ExchangeContract(web3Wrapper, exchangeInstance.abi, exchangeInstance.address); exchange = new ExchangeContract(exchangeInstance.abi, exchangeInstance.address, provider);
await tokenTransferProxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, { from: accounts[0] }); await tokenTransferProxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, { from: accounts[0] });
zeroEx = new ZeroEx(web3.currentProvider, { zeroEx = new ZeroEx(provider, {
exchangeContractAddress: exchange.address, exchangeContractAddress: exchange.address,
networkId: constants.TESTRPC_NETWORK_ID, networkId: constants.TESTRPC_NETWORK_ID,
}); });

View File

@@ -17,7 +17,7 @@ import { OrderFactory } from '../../util/order_factory';
import { ContractName } from '../../util/types'; import { ContractName } from '../../util/types';
import { chaiSetup } from '../utils/chai_setup'; import { chaiSetup } from '../utils/chai_setup';
import { deployer } from '../utils/deployer'; import { deployer } from '../utils/deployer';
import { web3, web3Wrapper } from '../utils/web3_wrapper'; import { provider, web3Wrapper } from '../utils/web3_wrapper';
chaiSetup.configure(); chaiSetup.configure();
const expect = chai.expect; const expect = chai.expect;
@@ -46,9 +46,9 @@ describe('Exchange', () => {
zrx.address, zrx.address,
tokenTransferProxy.address, tokenTransferProxy.address,
]); ]);
const exchange = new ExchangeContract(web3Wrapper, exchangeInstance.abi, exchangeInstance.address); const exchange = new ExchangeContract(exchangeInstance.abi, exchangeInstance.address, provider);
await tokenTransferProxy.addAuthorizedAddress(exchange.address, { from: accounts[0] }); await tokenTransferProxy.addAuthorizedAddress(exchange.address, { from: accounts[0] });
const zeroEx = new ZeroEx(web3.currentProvider, { networkId: constants.TESTRPC_NETWORK_ID }); const zeroEx = new ZeroEx(provider, { networkId: constants.TESTRPC_NETWORK_ID });
exchangeWrapper = new ExchangeWrapper(exchange, zeroEx); exchangeWrapper = new ExchangeWrapper(exchange, zeroEx);
const defaultOrderParams = { const defaultOrderParams = {
exchangeContractAddress: exchange.address, exchangeContractAddress: exchange.address,

View File

@@ -22,7 +22,7 @@ import { OrderFactory } from '../../util/order_factory';
import { BalancesByOwner, ContractName } from '../../util/types'; import { BalancesByOwner, ContractName } from '../../util/types';
import { chaiSetup } from '../utils/chai_setup'; import { chaiSetup } from '../utils/chai_setup';
import { deployer } from '../utils/deployer'; import { deployer } from '../utils/deployer';
import { web3, web3Wrapper } from '../utils/web3_wrapper'; import { provider, web3Wrapper } from '../utils/web3_wrapper';
chaiSetup.configure(); chaiSetup.configure();
const expect = chai.expect; const expect = chai.expect;
@@ -59,28 +59,24 @@ describe('Exchange', () => {
deployer.deployAsync(ContractName.DummyToken, constants.DUMMY_TOKEN_ARGS), deployer.deployAsync(ContractName.DummyToken, constants.DUMMY_TOKEN_ARGS),
deployer.deployAsync(ContractName.DummyToken, constants.DUMMY_TOKEN_ARGS), deployer.deployAsync(ContractName.DummyToken, constants.DUMMY_TOKEN_ARGS),
]); ]);
rep = new DummyTokenContract(web3Wrapper, repInstance.abi, repInstance.address); rep = new DummyTokenContract(repInstance.abi, repInstance.address, provider);
dgd = new DummyTokenContract(web3Wrapper, dgdInstance.abi, dgdInstance.address); dgd = new DummyTokenContract(dgdInstance.abi, dgdInstance.address, provider);
zrx = new DummyTokenContract(web3Wrapper, zrxInstance.abi, zrxInstance.address); zrx = new DummyTokenContract(zrxInstance.abi, zrxInstance.address, provider);
const tokenRegistryInstance = await deployer.deployAsync(ContractName.TokenRegistry); const tokenRegistryInstance = await deployer.deployAsync(ContractName.TokenRegistry);
tokenRegistry = new TokenRegistryContract( tokenRegistry = new TokenRegistryContract(tokenRegistryInstance.abi, tokenRegistryInstance.address, provider);
web3Wrapper,
tokenRegistryInstance.abi,
tokenRegistryInstance.address,
);
const tokenTransferProxyInstance = await deployer.deployAsync(ContractName.TokenTransferProxy); const tokenTransferProxyInstance = await deployer.deployAsync(ContractName.TokenTransferProxy);
tokenTransferProxy = new TokenTransferProxyContract( tokenTransferProxy = new TokenTransferProxyContract(
web3Wrapper,
tokenTransferProxyInstance.abi, tokenTransferProxyInstance.abi,
tokenTransferProxyInstance.address, tokenTransferProxyInstance.address,
provider,
); );
const exchangeInstance = await deployer.deployAsync(ContractName.Exchange, [ const exchangeInstance = await deployer.deployAsync(ContractName.Exchange, [
zrx.address, zrx.address,
tokenTransferProxy.address, tokenTransferProxy.address,
]); ]);
exchange = new ExchangeContract(web3Wrapper, exchangeInstance.abi, exchangeInstance.address); exchange = new ExchangeContract(exchangeInstance.abi, exchangeInstance.address, provider);
await tokenTransferProxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, { from: accounts[0] }); await tokenTransferProxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, { from: accounts[0] });
const zeroEx = new ZeroEx(web3.currentProvider, { networkId: constants.TESTRPC_NETWORK_ID }); const zeroEx = new ZeroEx(provider, { networkId: constants.TESTRPC_NETWORK_ID });
exWrapper = new ExchangeWrapper(exchange, zeroEx); exWrapper = new ExchangeWrapper(exchange, zeroEx);
const defaultOrderParams = { const defaultOrderParams = {

View File

@@ -15,13 +15,13 @@ import { ContractName, SubmissionContractEventArgs } from '../util/types';
import { chaiSetup } from './utils/chai_setup'; import { chaiSetup } from './utils/chai_setup';
import { deployer } from './utils/deployer'; import { deployer } from './utils/deployer';
import { web3, web3Wrapper } from './utils/web3_wrapper'; import { provider, web3Wrapper } from './utils/web3_wrapper';
const MULTI_SIG_ABI = artifacts.MultiSigWalletWithTimeLockArtifact.networks[constants.TESTRPC_NETWORK_ID].abi; const MULTI_SIG_ABI = artifacts.MultiSigWalletWithTimeLockArtifact.networks[constants.TESTRPC_NETWORK_ID].abi;
chaiSetup.configure(); chaiSetup.configure();
const expect = chai.expect; const expect = chai.expect;
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper); const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
const zeroEx = new ZeroEx(web3.currentProvider, { networkId: constants.TESTRPC_NETWORK_ID }); const zeroEx = new ZeroEx(provider, { networkId: constants.TESTRPC_NETWORK_ID });
const abiDecoder = new AbiDecoder([MULTI_SIG_ABI]); const abiDecoder = new AbiDecoder([MULTI_SIG_ABI]);
describe('MultiSigWalletWithTimeLock', () => { describe('MultiSigWalletWithTimeLock', () => {
@@ -53,9 +53,9 @@ describe('MultiSigWalletWithTimeLock', () => {
0, 0,
]); ]);
multiSig = new MultiSigWalletWithTimeLockContract( multiSig = new MultiSigWalletWithTimeLockContract(
web3Wrapper,
multiSigInstance.abi, multiSigInstance.abi,
multiSigInstance.address, multiSigInstance.address,
provider,
); );
multiSigWrapper = new MultiSigWrapper((multiSig as any) as MultiSigWalletContract); multiSigWrapper = new MultiSigWrapper((multiSig as any) as MultiSigWalletContract);
@@ -150,9 +150,9 @@ describe('MultiSigWalletWithTimeLock', () => {
SECONDS_TIME_LOCKED, SECONDS_TIME_LOCKED,
]); ]);
multiSig = new MultiSigWalletWithTimeLockContract( multiSig = new MultiSigWalletWithTimeLockContract(
web3Wrapper,
multiSigInstance.abi, multiSigInstance.abi,
multiSigInstance.address, multiSigInstance.address,
provider,
); );
multiSigWrapper = new MultiSigWrapper((multiSig as any) as MultiSigWalletContract); multiSigWrapper = new MultiSigWrapper((multiSig as any) as MultiSigWalletContract);

View File

@@ -16,7 +16,7 @@ import { ContractName, SubmissionContractEventArgs, TransactionDataParams } from
import { chaiSetup } from './utils/chai_setup'; import { chaiSetup } from './utils/chai_setup';
import { deployer } from './utils/deployer'; import { deployer } from './utils/deployer';
import { web3, web3Wrapper } from './utils/web3_wrapper'; import { provider, web3Wrapper } from './utils/web3_wrapper';
const PROXY_ABI = artifacts.TokenTransferProxyArtifact.networks[constants.TESTRPC_NETWORK_ID].abi; const PROXY_ABI = artifacts.TokenTransferProxyArtifact.networks[constants.TESTRPC_NETWORK_ID].abi;
const MUTISIG_WALLET_WITH_TIME_LOCK_EXCEPT_REMOVE_AUTHORIZED_ADDRESS_ABI = const MUTISIG_WALLET_WITH_TIME_LOCK_EXCEPT_REMOVE_AUTHORIZED_ADDRESS_ABI =
artifacts.MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddressArtifact.networks[constants.TESTRPC_NETWORK_ID] artifacts.MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddressArtifact.networks[constants.TESTRPC_NETWORK_ID]
@@ -28,7 +28,7 @@ const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
const abiDecoder = new AbiDecoder([MUTISIG_WALLET_WITH_TIME_LOCK_EXCEPT_REMOVE_AUTHORIZED_ADDRESS_ABI]); const abiDecoder = new AbiDecoder([MUTISIG_WALLET_WITH_TIME_LOCK_EXCEPT_REMOVE_AUTHORIZED_ADDRESS_ABI]);
describe('MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress', () => { describe('MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress', () => {
const zeroEx = new ZeroEx(web3.currentProvider, { networkId: constants.TESTRPC_NETWORK_ID }); const zeroEx = new ZeroEx(provider, { networkId: constants.TESTRPC_NETWORK_ID });
let owners: string[]; let owners: string[];
const requiredApprovals = 2; const requiredApprovals = 2;
const SECONDS_TIME_LOCKED = 1000000; const SECONDS_TIME_LOCKED = 1000000;
@@ -49,9 +49,9 @@ describe('MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress', () => {
const initialOwner = accounts[0]; const initialOwner = accounts[0];
const tokenTransferProxyInstance = await deployer.deployAsync(ContractName.TokenTransferProxy); const tokenTransferProxyInstance = await deployer.deployAsync(ContractName.TokenTransferProxy);
tokenTransferProxy = new TokenTransferProxyContract( tokenTransferProxy = new TokenTransferProxyContract(
web3Wrapper,
tokenTransferProxyInstance.abi, tokenTransferProxyInstance.abi,
tokenTransferProxyInstance.address, tokenTransferProxyInstance.address,
provider,
); );
await tokenTransferProxy.addAuthorizedAddress.sendTransactionAsync(authorizedAddress, { await tokenTransferProxy.addAuthorizedAddress.sendTransactionAsync(authorizedAddress, {
from: initialOwner, from: initialOwner,
@@ -61,9 +61,9 @@ describe('MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress', () => {
[owners, requiredApprovals, SECONDS_TIME_LOCKED, tokenTransferProxy.address], [owners, requiredApprovals, SECONDS_TIME_LOCKED, tokenTransferProxy.address],
); );
multiSig = new MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddressContract( multiSig = new MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddressContract(
web3Wrapper,
multiSigInstance.abi, multiSigInstance.abi,
multiSigInstance.address, multiSigInstance.address,
provider,
); );
await tokenTransferProxy.transferOwnership.sendTransactionAsync(multiSig.address, { await tokenTransferProxy.transferOwnership.sendTransactionAsync(multiSig.address, {
from: initialOwner, from: initialOwner,

View File

@@ -14,7 +14,7 @@ import { ContractName } from '../util/types';
import { chaiSetup } from './utils/chai_setup'; import { chaiSetup } from './utils/chai_setup';
import { deployer } from './utils/deployer'; import { deployer } from './utils/deployer';
import { web3, web3Wrapper } from './utils/web3_wrapper'; import { provider, web3Wrapper } from './utils/web3_wrapper';
chaiSetup.configure(); chaiSetup.configure();
const expect = chai.expect; const expect = chai.expect;
@@ -30,7 +30,7 @@ describe('TokenRegistry', () => {
owner = accounts[0]; owner = accounts[0];
notOwner = accounts[1]; notOwner = accounts[1];
const tokenRegInstance = await deployer.deployAsync(ContractName.TokenRegistry); const tokenRegInstance = await deployer.deployAsync(ContractName.TokenRegistry);
tokenReg = new TokenRegistryContract(web3Wrapper, tokenRegInstance.abi, tokenRegInstance.address); tokenReg = new TokenRegistryContract(tokenRegInstance.abi, tokenRegInstance.address, provider);
tokenRegWrapper = new TokenRegWrapper(tokenReg); tokenRegWrapper = new TokenRegWrapper(tokenReg);
}); });
beforeEach(async () => { beforeEach(async () => {

View File

@@ -8,7 +8,7 @@ import { constants } from '../../util/constants';
import { ContractName } from '../../util/types'; import { ContractName } from '../../util/types';
import { chaiSetup } from '../utils/chai_setup'; import { chaiSetup } from '../utils/chai_setup';
import { deployer } from '../utils/deployer'; import { deployer } from '../utils/deployer';
import { web3, web3Wrapper } from '../utils/web3_wrapper'; import { provider, web3Wrapper } from '../utils/web3_wrapper';
chaiSetup.configure(); chaiSetup.configure();
const expect = chai.expect; const expect = chai.expect;
@@ -25,9 +25,9 @@ describe('TokenTransferProxy', () => {
notOwner = accounts[1]; notOwner = accounts[1];
const tokenTransferProxyInstance = await deployer.deployAsync(ContractName.TokenTransferProxy); const tokenTransferProxyInstance = await deployer.deployAsync(ContractName.TokenTransferProxy);
tokenTransferProxy = new TokenTransferProxyContract( tokenTransferProxy = new TokenTransferProxyContract(
web3Wrapper,
tokenTransferProxyInstance.abi, tokenTransferProxyInstance.abi,
tokenTransferProxyInstance.address, tokenTransferProxyInstance.address,
provider,
); );
}); });
beforeEach(async () => { beforeEach(async () => {

View File

@@ -11,7 +11,7 @@ import { constants } from '../../util/constants';
import { ContractName } from '../../util/types'; import { ContractName } from '../../util/types';
import { chaiSetup } from '../utils/chai_setup'; import { chaiSetup } from '../utils/chai_setup';
import { deployer } from '../utils/deployer'; import { deployer } from '../utils/deployer';
import { web3, web3Wrapper } from '../utils/web3_wrapper'; import { provider, web3Wrapper } from '../utils/web3_wrapper';
chaiSetup.configure(); chaiSetup.configure();
const expect = chai.expect; const expect = chai.expect;
@@ -33,12 +33,12 @@ describe('TokenTransferProxy', () => {
owner = notAuthorized = accounts[0]; owner = notAuthorized = accounts[0];
const tokenTransferProxyInstance = await deployer.deployAsync(ContractName.TokenTransferProxy); const tokenTransferProxyInstance = await deployer.deployAsync(ContractName.TokenTransferProxy);
tokenTransferProxy = new TokenTransferProxyContract( tokenTransferProxy = new TokenTransferProxyContract(
web3Wrapper,
tokenTransferProxyInstance.abi, tokenTransferProxyInstance.abi,
tokenTransferProxyInstance.address, tokenTransferProxyInstance.address,
provider,
); );
const repInstance = await deployer.deployAsync(ContractName.DummyToken, constants.DUMMY_TOKEN_ARGS); const repInstance = await deployer.deployAsync(ContractName.DummyToken, constants.DUMMY_TOKEN_ARGS);
rep = new DummyTokenContract(web3Wrapper, repInstance.abi, repInstance.address); rep = new DummyTokenContract(repInstance.abi, repInstance.address, provider);
dmyBalances = new Balances([rep], [accounts[0], accounts[1]]); dmyBalances = new Balances([rep], [accounts[0], accounts[1]]);
await Promise.all([ await Promise.all([

View File

@@ -17,7 +17,7 @@ import { OrderFactory } from '../../util/order_factory';
import { BalancesByOwner, ContractName, ExchangeContractErrs } from '../../util/types'; import { BalancesByOwner, ContractName, ExchangeContractErrs } from '../../util/types';
import { chaiSetup } from '../utils/chai_setup'; import { chaiSetup } from '../utils/chai_setup';
import { deployer } from '../utils/deployer'; import { deployer } from '../utils/deployer';
import { web3, web3Wrapper } from '../utils/web3_wrapper'; import { provider, web3Wrapper } from '../utils/web3_wrapper';
chaiSetup.configure(); chaiSetup.configure();
const expect = chai.expect; const expect = chai.expect;
@@ -69,18 +69,18 @@ describe('Arbitrage', () => {
edTakerFee, edTakerFee,
edFeeRebate, edFeeRebate,
]); ]);
etherDelta = new EtherDeltaContract(web3Wrapper, etherDeltaInstance.abi, etherDeltaInstance.address); etherDelta = new EtherDeltaContract(etherDeltaInstance.abi, etherDeltaInstance.address, provider);
const tokenTransferProxy = await deployer.deployAsync(ContractName.TokenTransferProxy); const tokenTransferProxy = await deployer.deployAsync(ContractName.TokenTransferProxy);
const exchangeInstance = await deployer.deployAsync(ContractName.Exchange, [ const exchangeInstance = await deployer.deployAsync(ContractName.Exchange, [
zrx.address, zrx.address,
tokenTransferProxy.address, tokenTransferProxy.address,
]); ]);
await tokenTransferProxy.addAuthorizedAddress(exchangeInstance.address, { from: accounts[0] }); await tokenTransferProxy.addAuthorizedAddress(exchangeInstance.address, { from: accounts[0] });
zeroEx = new ZeroEx(web3.currentProvider, { zeroEx = new ZeroEx(provider, {
exchangeContractAddress: exchangeInstance.address, exchangeContractAddress: exchangeInstance.address,
networkId: constants.TESTRPC_NETWORK_ID, networkId: constants.TESTRPC_NETWORK_ID,
}); });
const exchange = new ExchangeContract(web3Wrapper, exchangeInstance.abi, exchangeInstance.address); const exchange = new ExchangeContract(exchangeInstance.abi, exchangeInstance.address, provider);
exWrapper = new ExchangeWrapper(exchange, zeroEx); exWrapper = new ExchangeWrapper(exchange, zeroEx);
makerTokenAmount = ZeroEx.toBaseUnitAmount(new BigNumber(1), 18); makerTokenAmount = ZeroEx.toBaseUnitAmount(new BigNumber(1), 18);
@@ -102,7 +102,7 @@ describe('Arbitrage', () => {
etherDelta.address, etherDelta.address,
tokenTransferProxy.address, tokenTransferProxy.address,
]); ]);
arbitrage = new ArbitrageContract(web3Wrapper, arbitrageInstance.abi, arbitrageInstance.address); arbitrage = new ArbitrageContract(arbitrageInstance.abi, arbitrageInstance.address, provider);
// Enable arbitrage and withdrawals of tokens // Enable arbitrage and withdrawals of tokens
await arbitrage.setAllowances.sendTransactionAsync(weth.address, { from: coinbase }); await arbitrage.setAllowances.sendTransactionAsync(weth.address, { from: coinbase });
await arbitrage.setAllowances.sendTransactionAsync(zrx.address, { from: coinbase }); await arbitrage.setAllowances.sendTransactionAsync(zrx.address, { from: coinbase });

View File

@@ -11,7 +11,7 @@ import { ContractName } from '../util/types';
import { chaiSetup } from './utils/chai_setup'; import { chaiSetup } from './utils/chai_setup';
import { deployer } from './utils/deployer'; import { deployer } from './utils/deployer';
import { web3, web3Wrapper } from './utils/web3_wrapper'; import { provider, web3Wrapper } from './utils/web3_wrapper';
chaiSetup.configure(); chaiSetup.configure();
const expect = chai.expect; const expect = chai.expect;
@@ -23,7 +23,7 @@ describe('UnlimitedAllowanceToken', () => {
const config = { const config = {
networkId: constants.TESTRPC_NETWORK_ID, networkId: constants.TESTRPC_NETWORK_ID,
}; };
const zeroEx = new ZeroEx(web3.currentProvider, config); const zeroEx = new ZeroEx(provider, config);
const MAX_MINT_VALUE = new BigNumber(100000000000000000000); const MAX_MINT_VALUE = new BigNumber(100000000000000000000);
let tokenAddress: string; let tokenAddress: string;
@@ -34,7 +34,7 @@ describe('UnlimitedAllowanceToken', () => {
owner = accounts[0]; owner = accounts[0];
spender = accounts[1]; spender = accounts[1];
const tokenInstance = await deployer.deployAsync(ContractName.DummyToken, constants.DUMMY_TOKEN_ARGS); const tokenInstance = await deployer.deployAsync(ContractName.DummyToken, constants.DUMMY_TOKEN_ARGS);
token = new DummyTokenContract(web3Wrapper, tokenInstance.abi, tokenInstance.address); token = new DummyTokenContract(tokenInstance.abi, tokenInstance.address, provider);
await token.mint.sendTransactionAsync(MAX_MINT_VALUE, { from: owner }); await token.mint.sendTransactionAsync(MAX_MINT_VALUE, { from: owner });
tokenAddress = token.address; tokenAddress = token.address;
}); });

View File

@@ -7,9 +7,8 @@ import { constants } from '../../util/constants';
import { web3 } from './web3_wrapper'; import { web3 } from './web3_wrapper';
const deployerOpts = { const deployerOpts = {
web3Provider: web3.currentProvider, provider: web3.currentProvider,
artifactsDir: path.resolve('src', 'artifacts'), artifactsDir: path.resolve('src', 'artifacts'),
jsonrpcUrl: devConstants.RPC_URL,
networkId: constants.TESTRPC_NETWORK_ID, networkId: constants.TESTRPC_NETWORK_ID,
defaults: { defaults: {
gas: devConstants.GAS_ESTIMATE, gas: devConstants.GAS_ESTIMATE,

View File

@@ -3,4 +3,5 @@ import { Web3Wrapper } from '@0xproject/web3-wrapper';
const web3ProviderConfig = { shouldUseInProcessGanache: true }; const web3ProviderConfig = { shouldUseInProcessGanache: true };
export const web3 = web3Factory.create(web3ProviderConfig); export const web3 = web3Factory.create(web3ProviderConfig);
export const web3Wrapper = new Web3Wrapper(web3.currentProvider); export const provider = web3.currentProvider;
export const web3Wrapper = new Web3Wrapper(provider);

View File

@@ -11,7 +11,7 @@ import { ContractName } from '../util/types';
import { chaiSetup } from './utils/chai_setup'; import { chaiSetup } from './utils/chai_setup';
import { deployer } from './utils/deployer'; import { deployer } from './utils/deployer';
import { web3, web3Wrapper } from './utils/web3_wrapper'; import { provider, web3Wrapper } from './utils/web3_wrapper';
chaiSetup.configure(); chaiSetup.configure();
const expect = chai.expect; const expect = chai.expect;
@@ -31,11 +31,11 @@ describe('ZRXToken', () => {
const accounts = await web3Wrapper.getAvailableAddressesAsync(); const accounts = await web3Wrapper.getAvailableAddressesAsync();
owner = accounts[0]; owner = accounts[0];
spender = accounts[1]; spender = accounts[1];
zeroEx = new ZeroEx(web3.currentProvider, { zeroEx = new ZeroEx(provider, {
networkId: constants.TESTRPC_NETWORK_ID, networkId: constants.TESTRPC_NETWORK_ID,
}); });
const zrxInstance = await deployer.deployAsync(ContractName.ZRXToken); const zrxInstance = await deployer.deployAsync(ContractName.ZRXToken);
zrx = new ZRXTokenContract(web3Wrapper, zrxInstance.abi, zrxInstance.address); zrx = new ZRXTokenContract(zrxInstance.abi, zrxInstance.address, provider);
zrxAddress = zrx.address; zrxAddress = zrx.address;
MAX_UINT = zeroEx.token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS; MAX_UINT = zeroEx.token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS;
}); });

View File

@@ -1,4 +1,14 @@
[ [
{
"version": "0.4.0",
"changes": [
{
"note": "Changed the config key `web3Provider` to `provider` to be consistent with other tools",
"pr": 501
}
],
"timestamp": 1523462196
},
{ {
"version": "0.3.5", "version": "0.3.5",
"changes": [ "changes": [
@@ -17,8 +27,7 @@
"pr": 491 "pr": 491
} }
], ],
"timestamp": 1522658513, "timestamp": 1522658513
"isPublished": true
}, },
{ {
"version": "0.3.1", "version": "0.3.1",
@@ -27,8 +36,7 @@
"note": "Add TS types for `yargs`" "note": "Add TS types for `yargs`"
} }
], ],
"timestamp": 1521298800, "timestamp": 1521298800
"isPublished": true
}, },
{ {
"version": "0.3.0", "version": "0.3.0",
@@ -74,8 +82,7 @@
"note": "Add `#!/usr/bin/env node` pragma above `cli.ts` script to fix command-line error." "note": "Add `#!/usr/bin/env node` pragma above `cli.ts` script to fix command-line error."
} }
], ],
"timestamp": 1521298800, "timestamp": 1521298800
"isPublished": true
}, },
{ {
"version": "0.2.0", "version": "0.2.0",
@@ -90,8 +97,7 @@
"pr": 419 "pr": 419
} }
], ],
"timestamp": 1520089200, "timestamp": 1520089200
"isPublished": true
}, },
{ {
"version": "0.1.0", "version": "0.1.0",
@@ -101,8 +107,7 @@
"pr": 400 "pr": 400
} }
], ],
"timestamp": 1518706800, "timestamp": 1518706800
"isPublished": true
}, },
{ {
"version": "0.0.8", "version": "0.0.8",
@@ -112,7 +117,6 @@
"pr": 389 "pr": 389
} }
], ],
"timestamp": 1518102000, "timestamp": 1518102000
"isPublished": true
} }
] ]

View File

@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG CHANGELOG
## v0.4.0 - _April 11, 2018_
* Changed the config key `web3Provider` to `provider` to be consistent with other tools (#501)
## v0.3.5 - _April 2, 2018_ ## v0.3.5 - _April 2, 2018_
* Don't try to write contract artifact if an error occured (#485) * Don't try to write contract artifact if an error occured (#485)

View File

@@ -2,7 +2,7 @@
This repository contains a CLI tool that facilitates compiling and deployment of smart contracts. This repository contains a CLI tool that facilitates compiling and deployment of smart contracts.
### Read the [Documentation](0xproject.com/docs/deployer). ### Read the [Documentation](https://0xproject.com/docs/deployer).
## Installation ## Installation
@@ -41,11 +41,11 @@ var Compiler = require('@0xproject/deployer').Compiler;
## Contributing ## Contributing
We strongly recommend that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository. We welcome improvements and fixes from the wider community! To report bugs within this package, please create an issue in this repository.
Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started. Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
### Install Dependencies ### Install dependencies
If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them: If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
@@ -61,16 +61,36 @@ yarn install
### Build ### Build
If this is your **first** time building this package, you must first build **all** packages within the monorepo. This is because packages that depend on other packages located inside this monorepo are symlinked when run from **within** the monorepo. This allows you to make changes across multiple packages without first publishing dependent packages to NPM. To build all packages, run the following from the monorepo root directory:
```bash
yarn lerna:rebuild
```
Or continuously rebuild on change:
```bash
yarn dev
```
You can also build this specific package by running the following from within its directory:
```bash ```bash
yarn build yarn build
``` ```
or or continuously rebuild on change:
```bash ```bash
yarn build:watch yarn build:watch
``` ```
### Clean
```bash
yarn clean
```
### Lint ### Lint
```bash ```bash

View File

@@ -1,6 +1,6 @@
{ {
"name": "@0xproject/deployer", "name": "@0xproject/deployer",
"version": "0.3.4", "version": "0.4.0",
"description": "Smart contract deployer of 0x protocol", "description": "Smart contract deployer of 0x protocol",
"main": "lib/src/index.js", "main": "lib/src/index.js",
"types": "lib/src/index.d.ts", "types": "lib/src/index.d.ts",
@@ -47,12 +47,14 @@
}, },
"homepage": "https://github.com/0xProject/0x-monorepo/packages/deployer/README.md", "homepage": "https://github.com/0xProject/0x-monorepo/packages/deployer/README.md",
"devDependencies": { "devDependencies": {
"@0xproject/monorepo-scripts": "^0.1.15", "@0xproject/dev-utils": "^0.2.1",
"@0xproject/tslint-config": "^0.4.13", "@0xproject/monorepo-scripts": "^0.1.17",
"@0xproject/tslint-config": "^0.4.15",
"@types/require-from-string": "^1.2.0", "@types/require-from-string": "^1.2.0",
"@types/semver": "^5.5.0", "@types/semver": "^5.5.0",
"@types/yargs": "^11.0.0", "@types/yargs": "^11.0.0",
"chai": "^4.0.1", "chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"copyfiles": "^1.2.0", "copyfiles": "^1.2.0",
"dirty-chai": "^2.0.1", "dirty-chai": "^2.0.1",
"mocha": "^4.0.1", "mocha": "^4.0.1",
@@ -66,11 +68,11 @@
"web3-typescript-typings": "^0.10.2" "web3-typescript-typings": "^0.10.2"
}, },
"dependencies": { "dependencies": {
"@0xproject/json-schemas": "^0.7.18", "@0xproject/json-schemas": "^0.7.20",
"@0xproject/types": "^0.4.2", "@0xproject/types": "^0.6.0",
"@0xproject/typescript-typings": "^0.0.2", "@0xproject/typescript-typings": "^0.1.0",
"@0xproject/utils": "^0.4.4", "@0xproject/utils": "^0.5.1",
"@0xproject/web3-wrapper": "^0.4.0", "@0xproject/web3-wrapper": "^0.6.0",
"ethereumjs-util": "^5.1.1", "ethereumjs-util": "^5.1.1",
"isomorphic-fetch": "^2.2.1", "isomorphic-fetch": "^2.2.1",
"lodash": "^4.17.4", "lodash": "^4.17.4",

View File

@@ -11,7 +11,7 @@ import * as yargs from 'yargs';
import { commands } from './commands'; import { commands } from './commands';
import { constants } from './utils/constants'; import { constants } from './utils/constants';
import { consoleReporter } from './utils/error_reporter'; import { consoleReporter } from './utils/error_reporter';
import { CliOptions, CompilerOptions, DeployerOptions } from './utils/types'; import { CliOptions, CompilerOptions, ContractDirectory, DeployerOptions } from './utils/types';
const DEFAULT_OPTIMIZER_ENABLED = false; const DEFAULT_OPTIMIZER_ENABLED = false;
const DEFAULT_CONTRACTS_DIR = path.resolve('src/contracts'); const DEFAULT_CONTRACTS_DIR = path.resolve('src/contracts');
@@ -27,7 +27,7 @@ const DEFAULT_CONTRACTS_LIST = '*';
*/ */
async function onCompileCommandAsync(argv: CliOptions): Promise<void> { async function onCompileCommandAsync(argv: CliOptions): Promise<void> {
const opts: CompilerOptions = { const opts: CompilerOptions = {
contractsDir: argv.contractsDir, contractDirs: getContractDirectoriesFromList(argv.contractDirs),
networkId: argv.networkId, networkId: argv.networkId,
optimizerEnabled: argv.shouldOptimize, optimizerEnabled: argv.shouldOptimize,
artifactsDir: argv.artifactsDir, artifactsDir: argv.artifactsDir,
@@ -45,7 +45,7 @@ async function onDeployCommandAsync(argv: CliOptions): Promise<void> {
const web3Wrapper = new Web3Wrapper(web3Provider); const web3Wrapper = new Web3Wrapper(web3Provider);
const networkId = await web3Wrapper.getNetworkIdAsync(); const networkId = await web3Wrapper.getNetworkIdAsync();
const compilerOpts: CompilerOptions = { const compilerOpts: CompilerOptions = {
contractsDir: argv.contractsDir, contractDirs: getContractDirectoriesFromList(argv.contractDirs),
networkId, networkId,
optimizerEnabled: argv.shouldOptimize, optimizerEnabled: argv.shouldOptimize,
artifactsDir: argv.artifactsDir, artifactsDir: argv.artifactsDir,
@@ -67,6 +67,29 @@ async function onDeployCommandAsync(argv: CliOptions): Promise<void> {
const deployerArgs = deployerArgsString.split(','); const deployerArgs = deployerArgsString.split(',');
await commands.deployAsync(argv.contract as string, deployerArgs, deployerOpts); await commands.deployAsync(argv.contract as string, deployerArgs, deployerOpts);
} }
/**
* Creates a set of contracts to compile.
* @param contractDirectoriesList Comma separated list of contract directories
* @return Set of contract directories
*/
function getContractDirectoriesFromList(contractDirectoriesList: string): Set<ContractDirectory> {
const directories = new Set();
const possiblyNamespacedDirectories = contractDirectoriesList.split(',');
_.forEach(possiblyNamespacedDirectories, namespacedDirectory => {
const directoryComponents = namespacedDirectory.split(':');
if (directoryComponents.length === 1) {
const directory = { namespace: '', path: directoryComponents[0] };
directories.add(directory);
} else if (directoryComponents.length === 2) {
const directory = { namespace: directoryComponents[0], path: directoryComponents[1] };
directories.add(directory);
} else {
throw new Error(`Unable to parse contracts directory: '${namespacedDirectory}'`);
}
});
return directories;
}
/** /**
* Creates a set of contracts to compile. * Creates a set of contracts to compile.
* @param contracts Comma separated list of contracts to compile * @param contracts Comma separated list of contracts to compile
@@ -78,8 +101,7 @@ function getContractsSetFromList(contracts: string): Set<string> {
} }
const contractsArray = contracts.split(','); const contractsArray = contracts.split(',');
_.forEach(contractsArray, contractName => { _.forEach(contractsArray, contractName => {
const fileName = `${contractName}${constants.SOLIDITY_FILE_EXTENSION}`; specifiedContracts.add(contractName);
specifiedContracts.add(fileName);
}); });
return specifiedContracts; return specifiedContracts;
} }
@@ -104,10 +126,11 @@ function deployCommandBuilder(yargsInstance: any) {
(() => { (() => {
const identityCommandBuilder = _.identity; const identityCommandBuilder = _.identity;
return yargs return yargs
.option('contracts-dir', { .option('contract-dirs', {
type: 'string', type: 'string',
default: DEFAULT_CONTRACTS_DIR, default: DEFAULT_CONTRACTS_DIR,
description: 'path of contracts directory to compile', description:
"comma separated list of contract directories.\nTo avoid filename clashes, directories should be prefixed with a namespace as follows: 'namespace:/path/to/dir'.",
}) })
.option('network-id', { .option('network-id', {
type: 'number', type: 'number',

View File

@@ -1,4 +1,4 @@
import { ContractAbi } from '@0xproject/types'; import { AbiType, ContractAbi, MethodAbi } from '@0xproject/types';
import { logUtils, promisify } from '@0xproject/utils'; import { logUtils, promisify } from '@0xproject/utils';
import * as ethUtil from 'ethereumjs-util'; import * as ethUtil from 'ethereumjs-util';
import * as fs from 'fs'; import * as fs from 'fs';
@@ -11,6 +11,8 @@ import solc = require('solc');
import { binPaths } from './solc/bin_paths'; import { binPaths } from './solc/bin_paths';
import { import {
constructContractId,
constructUniqueSourceFileId,
createDirIfDoesNotExistAsync, createDirIfDoesNotExistAsync,
findImportIfExist, findImportIfExist,
getContractArtifactIfExistsAsync, getContractArtifactIfExistsAsync,
@@ -23,11 +25,14 @@ import { fsWrapper } from './utils/fs_wrapper';
import { import {
CompilerOptions, CompilerOptions,
ContractArtifact, ContractArtifact,
ContractDirectory,
ContractIdToSourceFileId,
ContractNetworkData, ContractNetworkData,
ContractNetworks, ContractNetworks,
ContractSourceData, ContractSourceDataByFileId,
ContractSources, ContractSources,
ContractSpecificSourceData, ContractSpecificSourceData,
FunctionNameToSeenCount,
} from './utils/types'; } from './utils/types';
import { utils } from './utils/utils'; import { utils } from './utils/utils';
@@ -39,20 +44,22 @@ const SOLC_BIN_DIR = path.join(__dirname, '..', '..', 'solc_bin');
* to artifact files. * to artifact files.
*/ */
export class Compiler { export class Compiler {
private _contractsDir: string; private _contractDirs: Set<ContractDirectory>;
private _networkId: number; private _networkId: number;
private _optimizerEnabled: boolean; private _optimizerEnabled: boolean;
private _artifactsDir: string; private _artifactsDir: string;
// This get's set in the beggining of `compileAsync` function. It's not called from a constructor, but it's the only public method of that class and could as well be. // This get's set in the beggining of `compileAsync` function. It's not called from a constructor, but it's the only public method of that class and could as well be.
private _contractSources!: ContractSources; private _contractSources!: ContractSources;
private _specifiedContracts: Set<string> = new Set(); private _specifiedContracts: Set<string> = new Set();
private _contractSourceData: ContractSourceData = {}; private _contractSourceDataByFileId: ContractSourceDataByFileId = {};
/** /**
* Recursively retrieves Solidity source code from directory. * Recursively retrieves Solidity source code from directory.
* @param dirPath Directory to search. * @param dirPath Directory to search.
* @return Mapping of contract fileName to contract source. * @param contractBaseDir Base contracts directory of search tree.
* @return Mapping of sourceFilePath to the contract source.
*/ */
private static async _getContractSourcesAsync(dirPath: string): Promise<ContractSources> { private static async _getContractSourcesAsync(dirPath: string, contractBaseDir: string): Promise<ContractSources> {
let dirContents: string[] = []; let dirContents: string[] = [];
try { try {
dirContents = await fsWrapper.readdirAsync(dirPath); dirContents = await fsWrapper.readdirAsync(dirPath);
@@ -68,14 +75,18 @@ export class Compiler {
encoding: 'utf8', encoding: 'utf8',
}; };
const source = await fsWrapper.readFileAsync(contentPath, opts); const source = await fsWrapper.readFileAsync(contentPath, opts);
sources[fileName] = source; if (!_.startsWith(contentPath, contractBaseDir)) {
logUtils.log(`Reading ${fileName} source...`); throw new Error(`Expected content path '${contentPath}' to begin with '${contractBaseDir}'`);
}
const sourceFilePath = contentPath.slice(contractBaseDir.length);
sources[sourceFilePath] = source;
logUtils.log(`Reading ${sourceFilePath} source...`);
} catch (err) { } catch (err) {
logUtils.log(`Could not find file at ${contentPath}`); logUtils.log(`Could not find file at ${contentPath}`);
} }
} else { } else {
try { try {
const nestedSources = await Compiler._getContractSourcesAsync(contentPath); const nestedSources = await Compiler._getContractSourcesAsync(contentPath, contractBaseDir);
sources = { sources = {
...sources, ...sources,
...nestedSources, ...nestedSources,
@@ -93,7 +104,7 @@ export class Compiler {
* @return An instance of the Compiler class. * @return An instance of the Compiler class.
*/ */
constructor(opts: CompilerOptions) { constructor(opts: CompilerOptions) {
this._contractsDir = opts.contractsDir; this._contractDirs = opts.contractDirs;
this._networkId = opts.networkId; this._networkId = opts.networkId;
this._optimizerEnabled = opts.optimizerEnabled; this._optimizerEnabled = opts.optimizerEnabled;
this._artifactsDir = opts.artifactsDir; this._artifactsDir = opts.artifactsDir;
@@ -105,25 +116,49 @@ export class Compiler {
public async compileAsync(): Promise<void> { public async compileAsync(): Promise<void> {
await createDirIfDoesNotExistAsync(this._artifactsDir); await createDirIfDoesNotExistAsync(this._artifactsDir);
await createDirIfDoesNotExistAsync(SOLC_BIN_DIR); await createDirIfDoesNotExistAsync(SOLC_BIN_DIR);
this._contractSources = await Compiler._getContractSourcesAsync(this._contractsDir); this._contractSources = {};
_.forIn(this._contractSources, this._setContractSpecificSourceData.bind(this)); const contractIdToSourceFileId: ContractIdToSourceFileId = {};
const fileNames = this._specifiedContracts.has(ALL_CONTRACTS_IDENTIFIER) const contractDirs = Array.from(this._contractDirs.values());
? _.keys(this._contractSources) for (const contractDir of contractDirs) {
: Array.from(this._specifiedContracts.values()); const sources = await Compiler._getContractSourcesAsync(contractDir.path, contractDir.path);
for (const fileName of fileNames) { _.forIn(sources, (source, sourceFilePath) => {
await this._compileContractAsync(fileName); const sourceFileId = constructUniqueSourceFileId(contractDir.namespace, sourceFilePath);
// Record the file's source and data
if (!_.isUndefined(this._contractSources[sourceFileId])) {
throw new Error(`Found duplicate source files with ID '${sourceFileId}'`);
} }
this._contractSources[sourceFileId] = source;
// Create a mapping between the contract id and its source file id
const contractId = constructContractId(contractDir.namespace, sourceFilePath);
if (!_.isUndefined(contractIdToSourceFileId[contractId])) {
throw new Error(`Found duplicate contract with ID '${contractId}'`);
}
contractIdToSourceFileId[contractId] = sourceFileId;
});
}
_.forIn(this._contractSources, this._setContractSpecificSourceData.bind(this));
const specifiedContractIds = this._specifiedContracts.has(ALL_CONTRACTS_IDENTIFIER)
? _.keys(contractIdToSourceFileId)
: Array.from(this._specifiedContracts.values());
await Promise.all(
_.map(specifiedContractIds, async contractId =>
this._compileContractAsync(contractIdToSourceFileId[contractId]),
),
);
} }
/** /**
* Compiles contract and saves artifact to artifactsDir. * Compiles contract and saves artifact to artifactsDir.
* @param fileName Name of contract with '.sol' extension. * @param sourceFileId Unique ID of the source file.
*/ */
private async _compileContractAsync(fileName: string): Promise<void> { private async _compileContractAsync(sourceFileId: string): Promise<void> {
if (_.isUndefined(this._contractSources)) { if (_.isUndefined(this._contractSources)) {
throw new Error('Contract sources not yet initialized'); throw new Error('Contract sources not yet initialized');
} }
const contractSpecificSourceData = this._contractSourceData[fileName]; if (_.isUndefined(this._contractSourceDataByFileId[sourceFileId])) {
const currentArtifactIfExists = await getContractArtifactIfExistsAsync(this._artifactsDir, fileName); throw new Error(`Contract source for ${sourceFileId} not yet initialized`);
}
const contractSpecificSourceData = this._contractSourceDataByFileId[sourceFileId];
const currentArtifactIfExists = await getContractArtifactIfExistsAsync(this._artifactsDir, sourceFileId);
const sourceHash = `0x${contractSpecificSourceData.sourceHash.toString('hex')}`; const sourceHash = `0x${contractSpecificSourceData.sourceHash.toString('hex')}`;
const sourceTreeHash = `0x${contractSpecificSourceData.sourceTreeHash.toString('hex')}`; const sourceTreeHash = `0x${contractSpecificSourceData.sourceTreeHash.toString('hex')}`;
@@ -162,16 +197,17 @@ export class Compiler {
} }
const solcInstance = solc.setupMethods(requireFromString(solcjs, compilerBinFilename)); const solcInstance = solc.setupMethods(requireFromString(solcjs, compilerBinFilename));
logUtils.log(`Compiling ${fileName} with Solidity v${solcVersion}...`); logUtils.log(`Compiling ${sourceFileId} with Solidity v${solcVersion}...`);
const source = this._contractSources[fileName]; const source = this._contractSources[sourceFileId];
const input = { const input = {
[fileName]: source, [sourceFileId]: source,
}; };
const sourcesToCompile = { const sourcesToCompile = {
sources: input, sources: input,
}; };
const compiled = solcInstance.compile(sourcesToCompile, Number(this._optimizerEnabled), importPath => const compiled = solcInstance.compile(sourcesToCompile, Number(this._optimizerEnabled), importPath =>
findImportIfExist(this._contractSources, importPath), findImportIfExist(this._contractSources, sourceFileId, importPath),
); );
if (!_.isUndefined(compiled.errors)) { if (!_.isUndefined(compiled.errors)) {
@@ -193,11 +229,11 @@ export class Compiler {
}); });
} }
} }
const contractName = path.basename(fileName, constants.SOLIDITY_FILE_EXTENSION); const contractName = path.basename(sourceFileId, constants.SOLIDITY_FILE_EXTENSION);
const contractIdentifier = `${fileName}:${contractName}`; const contractIdentifier = `${sourceFileId}:${contractName}`;
if (_.isUndefined(compiled.contracts[contractIdentifier])) { if (_.isUndefined(compiled.contracts[contractIdentifier])) {
throw new Error( throw new Error(
`Contract ${contractName} not found in ${fileName}. Please make sure your contract has the same name as it's file name`, `Contract ${contractName} not found in ${sourceFileId}. Please make sure your contract has the same name as it's file name`,
); );
} }
const abi: ContractAbi = JSON.parse(compiled.contracts[contractIdentifier].interface); const abi: ContractAbi = JSON.parse(compiled.contracts[contractIdentifier].interface);
@@ -207,6 +243,7 @@ export class Compiler {
const sourceMapRuntime = compiled.contracts[contractIdentifier].srcmapRuntime; const sourceMapRuntime = compiled.contracts[contractIdentifier].srcmapRuntime;
const sources = _.keys(compiled.sources); const sources = _.keys(compiled.sources);
const updated_at = Date.now(); const updated_at = Date.now();
const contractNetworkData: ContractNetworkData = { const contractNetworkData: ContractNetworkData = {
solc_version: solcVersion, solc_version: solcVersion,
keccak256: sourceHash, keccak256: sourceHash,
@@ -243,28 +280,30 @@ export class Compiler {
const artifactString = utils.stringifyWithFormatting(newArtifact); const artifactString = utils.stringifyWithFormatting(newArtifact);
const currentArtifactPath = `${this._artifactsDir}/${contractName}.json`; const currentArtifactPath = `${this._artifactsDir}/${contractName}.json`;
await fsWrapper.writeFileAsync(currentArtifactPath, artifactString); await fsWrapper.writeFileAsync(currentArtifactPath, artifactString);
logUtils.log(`${fileName} artifact saved!`); logUtils.log(`${sourceFileId} artifact saved!`);
} }
/** /**
* Gets contract dependendencies and keccak256 hash from source. * Gets contract dependendencies and keccak256 hash from source.
* @param source Source code of contract. * @param source Source code of contract.
* @param fileId FileId of the contract source file.
* @return Object with contract dependencies and keccak256 hash of source. * @return Object with contract dependencies and keccak256 hash of source.
*/ */
private _setContractSpecificSourceData(source: string, fileName: string): void { private _setContractSpecificSourceData(source: string, fileId: string): void {
if (!_.isUndefined(this._contractSourceData[fileName])) { if (!_.isUndefined(this._contractSourceDataByFileId[fileId])) {
return; return;
} }
const sourceHash = ethUtil.sha3(source); const sourceHash = ethUtil.sha3(source);
const solcVersionRange = parseSolidityVersionRange(source); const solcVersionRange = parseSolidityVersionRange(source);
const dependencies = parseDependencies(source); const dependencies = parseDependencies(source, fileId);
const sourceTreeHash = this._getSourceTreeHash(fileName, sourceHash, dependencies); const sourceTreeHash = this._getSourceTreeHash(fileId, sourceHash, dependencies);
this._contractSourceData[fileName] = { this._contractSourceDataByFileId[fileId] = {
dependencies, dependencies,
solcVersionRange, solcVersionRange,
sourceHash, sourceHash,
sourceTreeHash, sourceTreeHash,
}; };
} }
/** /**
* Gets the source tree hash for a file and its dependencies. * Gets the source tree hash for a file and its dependencies.
* @param fileName Name of contract file. * @param fileName Name of contract file.
@@ -276,7 +315,7 @@ export class Compiler {
const dependencySourceTreeHashes = _.map(dependencies, dependency => { const dependencySourceTreeHashes = _.map(dependencies, dependency => {
const source = this._contractSources[dependency]; const source = this._contractSources[dependency];
this._setContractSpecificSourceData(source, dependency); this._setContractSpecificSourceData(source, dependency);
const sourceData = this._contractSourceData[dependency]; const sourceData = this._contractSourceDataByFileId[dependency];
return this._getSourceTreeHash(dependency, sourceData.sourceHash, sourceData.dependencies); return this._getSourceTreeHash(dependency, sourceData.sourceHash, sourceData.dependencies);
}); });
const sourceTreeHashesBuffer = Buffer.concat([sourceHash, ...dependencySourceTreeHashes]); const sourceTreeHashesBuffer = Buffer.concat([sourceHash, ...dependencySourceTreeHashes]);

View File

@@ -1,4 +1,4 @@
import { AbiType, ConstructorAbi, ContractAbi, TxData } from '@0xproject/types'; import { AbiType, ConstructorAbi, ContractAbi, Provider, TxData } from '@0xproject/types';
import { logUtils } from '@0xproject/utils'; import { logUtils } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper'; import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as _ from 'lodash'; import * as _ from 'lodash';
@@ -38,15 +38,15 @@ export class Deployer {
this._artifactsDir = opts.artifactsDir; this._artifactsDir = opts.artifactsDir;
this._networkId = opts.networkId; this._networkId = opts.networkId;
this._defaults = opts.defaults; this._defaults = opts.defaults;
let web3Provider: Web3.Provider; let web3Provider: Provider;
if (_.isUndefined((opts as ProviderDeployerOptions).web3Provider)) { if (_.isUndefined((opts as ProviderDeployerOptions).provider)) {
const jsonrpcUrl = (opts as UrlDeployerOptions).jsonrpcUrl; const jsonrpcUrl = (opts as UrlDeployerOptions).jsonrpcUrl;
if (_.isUndefined(jsonrpcUrl)) { if (_.isUndefined(jsonrpcUrl)) {
throw new Error(`Deployer options don't contain web3Provider nor jsonrpcUrl. Please pass one of them`); throw new Error(`Deployer options don't contain web3Provider nor jsonrpcUrl. Please pass one of them`);
} }
web3Provider = new Web3.providers.HttpProvider(jsonrpcUrl); web3Provider = new Web3.providers.HttpProvider(jsonrpcUrl);
} else { } else {
web3Provider = (opts as ProviderDeployerOptions).web3Provider; web3Provider = (opts as ProviderDeployerOptions).provider;
} }
this.web3Wrapper = new Web3Wrapper(web3Provider, this._defaults); this.web3Wrapper = new Web3Wrapper(web3Provider, this._defaults);
} }

View File

@@ -1,3 +1,4 @@
import { AbiType, ContractAbi, MethodAbi } from '@0xproject/types';
import { logUtils } from '@0xproject/utils'; import { logUtils } from '@0xproject/utils';
import * as _ from 'lodash'; import * as _ from 'lodash';
import * as path from 'path'; import * as path from 'path';
@@ -5,8 +6,48 @@ import * as solc from 'solc';
import { constants } from './constants'; import { constants } from './constants';
import { fsWrapper } from './fs_wrapper'; import { fsWrapper } from './fs_wrapper';
import { ContractArtifact, ContractSources } from './types'; import { ContractArtifact, ContractSources, FunctionNameToSeenCount } from './types';
/**
* Constructs a system-wide unique identifier for a source file.
* @param directoryNamespace Namespace of the source file's root contract directory.
* @param sourceFilePath Path to a source file, relative to contractBaseDir.
* @return sourceFileId A system-wide unique identifier for the source file.
*/
export function constructUniqueSourceFileId(directoryNamespace: string, sourceFilePath: string): string {
const namespacePrefix = !_.isEmpty(directoryNamespace) ? `/${directoryNamespace}` : '';
const sourceFilePathNoLeadingSlash = sourceFilePath.replace(/^\/+/g, '');
const sourceFileId = `${namespacePrefix}/${sourceFilePathNoLeadingSlash}`;
return sourceFileId;
}
/**
* Constructs a system-wide unique identifier for a dependency file.
* @param dependencyFilePath Path from a sourceFile to a dependency.
* @param contractBaseDir Base contracts directory of search tree.
* @return sourceFileId A system-wide unique identifier for the source file.
*/
export function constructDependencyFileId(dependencyFilePath: string, sourceFilePath: string): string {
if (_.startsWith(dependencyFilePath, '/')) {
// Path of the form /namespace/path/to/dependency.sol
return dependencyFilePath;
} else {
// Dependency is relative to the source file: ./dependency.sol, ../../some/path/dependency.sol, etc.
// Join the two paths to construct a valid source file id: /namespace/path/to/dependency.sol
return path.join(path.dirname(sourceFilePath), dependencyFilePath);
}
}
/**
* Constructs a system-wide unique identifier for a contract.
* @param directoryNamespace Namespace of the source file's root contract directory.
* @param sourceFilePath Path to a source file, relative to contractBaseDir.
* @return sourceFileId A system-wide unique identifier for contract.
*/
export function constructContractId(directoryNamespace: string, sourceFilePath: string): string {
const namespacePrefix = !_.isEmpty(directoryNamespace) ? `${directoryNamespace}:` : '';
const sourceFileName = path.basename(sourceFilePath, constants.SOLIDITY_FILE_EXTENSION);
const contractId = `${namespacePrefix}${sourceFileName}`;
return contractId;
}
/** /**
* Gets contract data on network or returns if an artifact does not exist. * Gets contract data on network or returns if an artifact does not exist.
* @param artifactsDir Path to the artifacts directory. * @param artifactsDir Path to the artifacts directory.
@@ -82,9 +123,10 @@ export function getNormalizedErrMsg(errMsg: string): string {
/** /**
* Parses the contract source code and extracts the dendencies * Parses the contract source code and extracts the dendencies
* @param source Contract source code * @param source Contract source code
* @param sourceFilePath File path of the source code.
* @return List of dependendencies * @return List of dependendencies
*/ */
export function parseDependencies(source: string): string[] { export function parseDependencies(source: string, sourceFileId: string): string[] {
// TODO: Use a proper parser // TODO: Use a proper parser
const IMPORT_REGEX = /(import\s)/; const IMPORT_REGEX = /(import\s)/;
const DEPENDENCY_PATH_REGEX = /"([^"]+)"/; // Source: https://github.com/BlockChainCompany/soljitsu/blob/master/lib/shared.js const DEPENDENCY_PATH_REGEX = /"([^"]+)"/; // Source: https://github.com/BlockChainCompany/soljitsu/blob/master/lib/shared.js
@@ -95,8 +137,8 @@ export function parseDependencies(source: string): string[] {
const dependencyMatch = line.match(DEPENDENCY_PATH_REGEX); const dependencyMatch = line.match(DEPENDENCY_PATH_REGEX);
if (!_.isNull(dependencyMatch)) { if (!_.isNull(dependencyMatch)) {
const dependencyPath = dependencyMatch[1]; const dependencyPath = dependencyMatch[1];
const basenName = path.basename(dependencyPath); const dependencyId = constructDependencyFileId(dependencyPath, sourceFileId);
dependencies.push(basenName); dependencies.push(dependencyId);
} }
} }
}); });
@@ -107,14 +149,19 @@ export function parseDependencies(source: string): string[] {
* Callback to resolve dependencies with `solc.compile`. * Callback to resolve dependencies with `solc.compile`.
* Throws error if contractSources not yet initialized. * Throws error if contractSources not yet initialized.
* @param contractSources Source codes of contracts. * @param contractSources Source codes of contracts.
* @param importPath Path to an imported dependency. * @param sourceFileId ID of the source file.
* @param importPath Path of dependency source file.
* @return Import contents object containing source code of dependency. * @return Import contents object containing source code of dependency.
*/ */
export function findImportIfExist(contractSources: ContractSources, importPath: string): solc.ImportContents { export function findImportIfExist(
const fileName = path.basename(importPath); contractSources: ContractSources,
const source = contractSources[fileName]; sourceFileId: string,
importPath: string,
): solc.ImportContents {
const dependencyFileId = constructDependencyFileId(importPath, sourceFileId);
const source = contractSources[dependencyFileId];
if (_.isUndefined(source)) { if (_.isUndefined(source)) {
throw new Error(`Contract source not found for ${fileName}`); throw new Error(`Contract source not found for ${dependencyFileId}`);
} }
const importContents: solc.ImportContents = { const importContents: solc.ImportContents = {
contents: source, contents: source,

View File

@@ -1,11 +1,9 @@
import { schemas, SchemaValidator } from '@0xproject/json-schemas'; import { schemas, SchemaValidator } from '@0xproject/json-schemas';
import { ContractAbi, EventAbi, FunctionAbi, MethodAbi, TxData } from '@0xproject/types'; import { AbiType, ContractAbi, EventAbi, FunctionAbi, MethodAbi, TxData } from '@0xproject/types';
import { promisify } from '@0xproject/utils'; import { promisify } from '@0xproject/utils';
import * as _ from 'lodash'; import * as _ from 'lodash';
import * as Web3 from 'web3'; import * as Web3 from 'web3';
import { AbiType } from './types';
export class Contract implements Web3.ContractInstance { export class Contract implements Web3.ContractInstance {
public address: string; public address: string;
public abi: ContractAbi; public abi: ContractAbi;

View File

@@ -1,9 +1,7 @@
import { AbiDefinition, ContractAbi, DataItem } from '@0xproject/types'; import { AbiDefinition, AbiType, ContractAbi, DataItem } from '@0xproject/types';
import * as _ from 'lodash'; import * as _ from 'lodash';
import * as web3Abi from 'web3-eth-abi'; import * as web3Abi from 'web3-eth-abi';
import { AbiType } from './types';
export const encoder = { export const encoder = {
encodeConstructorArgsFromAbi(args: any[], abi: ContractAbi): string { encodeConstructorArgsFromAbi(args: any[], abi: ContractAbi): string {
const constructorTypes: string[] = []; const constructorTypes: string[] = [];

View File

@@ -1,4 +1,4 @@
import { ContractAbi, TxData } from '@0xproject/types'; import { ContractAbi, Provider, TxData } from '@0xproject/types';
import * as Web3 from 'web3'; import * as Web3 from 'web3';
import * as yargs from 'yargs'; import * as yargs from 'yargs';
@@ -18,6 +18,11 @@ export interface ContractNetworks {
[key: number]: ContractNetworkData; [key: number]: ContractNetworkData;
} }
export interface ContractDirectory {
path: string;
namespace: string;
}
export interface ContractNetworkData { export interface ContractNetworkData {
solc_version: string; solc_version: string;
optimizer_enabled: boolean; optimizer_enabled: boolean;
@@ -40,7 +45,7 @@ export interface SolcErrors {
export interface CliOptions extends yargs.Arguments { export interface CliOptions extends yargs.Arguments {
artifactsDir: string; artifactsDir: string;
contractsDir: string; contractDirs: string;
jsonrpcUrl: string; jsonrpcUrl: string;
networkId: number; networkId: number;
shouldOptimize: boolean; shouldOptimize: boolean;
@@ -51,7 +56,7 @@ export interface CliOptions extends yargs.Arguments {
} }
export interface CompilerOptions { export interface CompilerOptions {
contractsDir: string; contractDirs: Set<ContractDirectory>;
networkId: number; networkId: number;
optimizerEnabled: boolean; optimizerEnabled: boolean;
artifactsDir: string; artifactsDir: string;
@@ -65,7 +70,7 @@ export interface BaseDeployerOptions {
} }
export interface ProviderDeployerOptions extends BaseDeployerOptions { export interface ProviderDeployerOptions extends BaseDeployerOptions {
web3Provider: Web3.Provider; provider: Provider;
} }
export interface UrlDeployerOptions extends BaseDeployerOptions { export interface UrlDeployerOptions extends BaseDeployerOptions {
@@ -78,7 +83,11 @@ export interface ContractSources {
[key: string]: string; [key: string]: string;
} }
export interface ContractSourceData { export interface ContractIdToSourceFileId {
[key: string]: string;
}
export interface ContractSourceDataByFileId {
[key: string]: ContractSpecificSourceData; [key: string]: ContractSpecificSourceData;
} }
@@ -98,4 +107,8 @@ export interface Token {
swarmHash: string; swarmHash: string;
} }
export interface FunctionNameToSeenCount {
[key: string]: number;
}
export type DoneCallback = (err?: Error) => void; export type DoneCallback = (err?: Error) => void;

View File

@@ -3,7 +3,13 @@ import 'mocha';
import { Compiler } from '../src/compiler'; import { Compiler } from '../src/compiler';
import { fsWrapper } from '../src/utils/fs_wrapper'; import { fsWrapper } from '../src/utils/fs_wrapper';
import { CompilerOptions, ContractArtifact, ContractNetworkData, DoneCallback } from '../src/utils/types'; import {
CompilerOptions,
ContractArtifact,
ContractDirectory,
ContractNetworkData,
DoneCallback,
} from '../src/utils/types';
import { exchange_binary } from './fixtures/exchange_bin'; import { exchange_binary } from './fixtures/exchange_bin';
import { constants } from './util/constants'; import { constants } from './util/constants';
@@ -13,11 +19,15 @@ const expect = chai.expect;
describe('#Compiler', function() { describe('#Compiler', function() {
this.timeout(constants.timeoutMs); this.timeout(constants.timeoutMs);
const artifactsDir = `${__dirname}/fixtures/artifacts`; const artifactsDir = `${__dirname}/fixtures/artifacts`;
const contractsDir = `${__dirname}/fixtures/contracts`; const mainContractDir: ContractDirectory = { path: `${__dirname}/fixtures/contracts/main`, namespace: 'main' };
const baseContractDir: ContractDirectory = { path: `${__dirname}/fixtures/contracts/base`, namespace: 'base' };
const contractDirs: Set<ContractDirectory> = new Set();
contractDirs.add(mainContractDir);
contractDirs.add(baseContractDir);
const exchangeArtifactPath = `${artifactsDir}/Exchange.json`; const exchangeArtifactPath = `${artifactsDir}/Exchange.json`;
const compilerOpts: CompilerOptions = { const compilerOpts: CompilerOptions = {
artifactsDir, artifactsDir,
contractsDir, contractDirs,
networkId: constants.networkId, networkId: constants.networkId,
optimizerEnabled: constants.optimizerEnabled, optimizerEnabled: constants.optimizerEnabled,
specifiedContracts: new Set(constants.specifiedContracts), specifiedContracts: new Set(constants.specifiedContracts),

View File

@@ -47,28 +47,34 @@ describe('Compiler utils', () => {
}); });
describe('#parseDependencies', () => { describe('#parseDependencies', () => {
it('correctly parses Exchange dependencies', async () => { it('correctly parses Exchange dependencies', async () => {
const exchangeSource = await fsWrapper.readFileAsync(`${__dirname}/fixtures/contracts/Exchange.sol`, { const exchangeSource = await fsWrapper.readFileAsync(`${__dirname}/fixtures/contracts/main/Exchange.sol`, {
encoding: 'utf8', encoding: 'utf8',
}); });
expect(parseDependencies(exchangeSource)).to.be.deep.equal([ const sourceFileId = '/main/Exchange.sol';
'TokenTransferProxy.sol', expect(parseDependencies(exchangeSource, sourceFileId)).to.be.deep.equal([
'Token.sol', '/main/TokenTransferProxy.sol',
'SafeMath.sol', '/base/Token.sol',
'/base/SafeMath.sol',
]); ]);
}); });
it('correctly parses TokenTransferProxy dependencies', async () => { it('correctly parses TokenTransferProxy dependencies', async () => {
const exchangeSource = await fsWrapper.readFileAsync( const exchangeSource = await fsWrapper.readFileAsync(
`${__dirname}/fixtures/contracts/TokenTransferProxy.sol`, `${__dirname}/fixtures/contracts/main/TokenTransferProxy.sol`,
{ {
encoding: 'utf8', encoding: 'utf8',
}, },
); );
expect(parseDependencies(exchangeSource)).to.be.deep.equal(['Token.sol', 'Ownable.sol']); const sourceFileId = '/main/TokenTransferProxy.sol';
expect(parseDependencies(exchangeSource, sourceFileId)).to.be.deep.equal([
'/base/Token.sol',
'/base/Ownable.sol',
]);
}); });
// TODO: For now that doesn't work. This will work after we switch to a grammar-based parser // TODO: For now that doesn't work. This will work after we switch to a grammar-based parser
it.skip('correctly parses commented out dependencies', async () => { it.skip('correctly parses commented out dependencies', async () => {
const contractWithCommentedOutDependencies = `// import "./TokenTransferProxy.sol";`; const contractWithCommentedOutDependencies = `// import "./TokenTransferProxy.sol";`;
expect(parseDependencies(contractWithCommentedOutDependencies)).to.be.deep.equal([]); const sourceFileId = '/main/TokenTransferProxy.sol';
expect(parseDependencies(contractWithCommentedOutDependencies, sourceFileId)).to.be.deep.equal([]);
}); });
}); });
}); });

View File

@@ -4,7 +4,13 @@ import 'mocha';
import { Compiler } from '../src/compiler'; import { Compiler } from '../src/compiler';
import { Deployer } from '../src/deployer'; import { Deployer } from '../src/deployer';
import { fsWrapper } from '../src/utils/fs_wrapper'; import { fsWrapper } from '../src/utils/fs_wrapper';
import { CompilerOptions, ContractArtifact, ContractNetworkData, DoneCallback } from '../src/utils/types'; import {
CompilerOptions,
ContractArtifact,
ContractDirectory,
ContractNetworkData,
DoneCallback,
} from '../src/utils/types';
import { constructor_args, exchange_binary } from './fixtures/exchange_bin'; import { constructor_args, exchange_binary } from './fixtures/exchange_bin';
import { constants } from './util/constants'; import { constants } from './util/constants';
@@ -13,11 +19,15 @@ const expect = chai.expect;
describe('#Deployer', () => { describe('#Deployer', () => {
const artifactsDir = `${__dirname}/fixtures/artifacts`; const artifactsDir = `${__dirname}/fixtures/artifacts`;
const contractsDir = `${__dirname}/fixtures/contracts`;
const exchangeArtifactPath = `${artifactsDir}/Exchange.json`; const exchangeArtifactPath = `${artifactsDir}/Exchange.json`;
const mainContractDir: ContractDirectory = { path: `${__dirname}/fixtures/contracts/main`, namespace: '' };
const baseContractDir: ContractDirectory = { path: `${__dirname}/fixtures/contracts/base`, namespace: 'base' };
const contractDirs: Set<ContractDirectory> = new Set();
contractDirs.add(mainContractDir);
contractDirs.add(baseContractDir);
const compilerOpts: CompilerOptions = { const compilerOpts: CompilerOptions = {
artifactsDir, artifactsDir,
contractsDir, contractDirs,
networkId: constants.networkId, networkId: constants.networkId,
optimizerEnabled: constants.optimizerEnabled, optimizerEnabled: constants.optimizerEnabled,
specifiedContracts: new Set(constants.specifiedContracts), specifiedContracts: new Set(constants.specifiedContracts),

View File

@@ -1,6 +1,6 @@
/* /*
Copyright 2017 ZeroEx Intl. Copyright 2018 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@@ -19,8 +19,8 @@
pragma solidity 0.4.14; pragma solidity 0.4.14;
import "./TokenTransferProxy.sol"; import "./TokenTransferProxy.sol";
import "./base/Token.sol"; import "/base/Token.sol";
import "./base/SafeMath.sol"; import "/base/SafeMath.sol";
/// @title Exchange - Facilitates exchange of ERC20 tokens. /// @title Exchange - Facilitates exchange of ERC20 tokens.
/// @author Amir Bandeali - <amir@0xProject.com>, Will Warren - <will@0xProject.com> /// @author Amir Bandeali - <amir@0xProject.com>, Will Warren - <will@0xProject.com>

View File

@@ -1,6 +1,6 @@
/* /*
Copyright 2017 ZeroEx Intl. Copyright 2018 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@@ -18,8 +18,8 @@
pragma solidity 0.4.14; pragma solidity 0.4.14;
import "./base/Token.sol"; import "/base/Token.sol";
import "./base/Ownable.sol"; import "/base/Ownable.sol";
/// @title TokenTransferProxy - Transfers tokens on behalf of contracts that have been approved via decentralized governance. /// @title TokenTransferProxy - Transfers tokens on behalf of contracts that have been approved via decentralized governance.
/// @author Amir Bandeali - <amir@0xProject.com>, Will Warren - <will@0xProject.com> /// @author Amir Bandeali - <amir@0xProject.com>, Will Warren - <will@0xProject.com>

View File

@@ -1,4 +1,13 @@
[ [
{
"timestamp": 1523462196,
"version": "0.3.5",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{ {
"timestamp": 1522673609, "timestamp": 1522673609,
"version": "0.3.4", "version": "0.3.4",
@@ -15,8 +24,7 @@
{ {
"note": "Dependencies updated" "note": "Dependencies updated"
} }
], ]
"isPublished": true
}, },
{ {
"version": "0.3.1", "version": "0.3.1",
@@ -28,8 +36,7 @@
"note": "Move `@0xproject/web3_wrapper` to dependencies from devDependencies." "note": "Move `@0xproject/web3_wrapper` to dependencies from devDependencies."
} }
], ],
"timestamp": 1521298800, "timestamp": 1521298800
"isPublished": true
}, },
{ {
"version": "0.3.0", "version": "0.3.0",
@@ -47,8 +54,7 @@
"pr": 426 "pr": 426
} }
], ],
"timestamp": 1521298800, "timestamp": 1521298800
"isPublished": true
}, },
{ {
"version": "0.2.0", "version": "0.2.0",
@@ -58,8 +64,7 @@
"pr": 392 "pr": 392
} }
], ],
"timestamp": 1518706800, "timestamp": 1518706800
"isPublished": true
}, },
{ {
"version": "0.0.12", "version": "0.0.12",
@@ -69,8 +74,7 @@
"pr": 389 "pr": 389
} }
], ],
"timestamp": 1518102000, "timestamp": 1518102000
"isPublished": true
}, },
{ {
"version": "0.0.11", "version": "0.0.11",
@@ -80,7 +84,6 @@
"pr": 352 "pr": 352
} }
], ],
"timestamp": 1517929200, "timestamp": 1517929200
"isPublished": true
} }
] ]

View File

@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG CHANGELOG
## v0.3.5 - _April 11, 2018_
* Dependencies updated
## v0.3.4 - _April 2, 2018_ ## v0.3.4 - _April 2, 2018_
* Dependencies updated * Dependencies updated

View File

@@ -26,3 +26,67 @@ If your project is in [TypeScript](https://www.typescriptlang.org/), add the fol
"typeRoots": ["node_modules/@0xproject/typescript-typings/types", "node_modules/@types"], "typeRoots": ["node_modules/@0xproject/typescript-typings/types", "node_modules/@types"],
} }
``` ```
## Contributing
We welcome improvements and fixes from the wider community! To report bugs within this package, please create an issue in this repository.
Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
### Install dependencies
If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
```bash
yarn config set workspaces-experimental true
```
Then install dependencies
```bash
yarn install
```
### Build
If this is your **first** time building this package, you must first build **all** packages within the monorepo. This is because packages that depend on other packages located inside this monorepo are symlinked when run from **within** the monorepo. This allows you to make changes across multiple packages without first publishing dependent packages to NPM. To build all packages, run the following from the monorepo root directory:
```bash
yarn lerna:rebuild
```
Or continuously rebuild on change:
```bash
yarn dev
```
You can also build this specific package by running the following from within its directory:
```bash
yarn build
```
or continuously rebuild on change:
```bash
yarn build:watch
```
### Clean
```bash
yarn clean
```
### Lint
```bash
yarn lint
```
### Run Tests
```bash
yarn test
```

View File

@@ -1,6 +1,6 @@
{ {
"name": "@0xproject/dev-utils", "name": "@0xproject/dev-utils",
"version": "0.3.3", "version": "0.3.5",
"description": "0x dev TS utils", "description": "0x dev TS utils",
"main": "lib/src/index.js", "main": "lib/src/index.js",
"types": "lib/src/index.d.ts", "types": "lib/src/index.d.ts",
@@ -26,8 +26,8 @@
}, },
"homepage": "https://github.com/0xProject/0x-monorepo/packages/dev-utils/README.md", "homepage": "https://github.com/0xProject/0x-monorepo/packages/dev-utils/README.md",
"devDependencies": { "devDependencies": {
"@0xproject/monorepo-scripts": "^0.1.15", "@0xproject/monorepo-scripts": "^0.1.17",
"@0xproject/tslint-config": "^0.4.13", "@0xproject/tslint-config": "^0.4.15",
"@types/lodash": "4.14.104", "@types/lodash": "4.14.104",
"@types/mocha": "^2.2.42", "@types/mocha": "^2.2.42",
"chai": "^4.0.1", "chai": "^4.0.1",
@@ -40,15 +40,12 @@
"typescript": "2.7.1" "typescript": "2.7.1"
}, },
"dependencies": { "dependencies": {
"@0xproject/sol-cov": "^0.0.5", "@0xproject/sol-cov": "^0.0.7",
"@0xproject/subproviders": "^0.8.3", "@0xproject/subproviders": "^0.8.5",
"@0xproject/types": "^0.4.2", "@0xproject/types": "^0.6.0",
"@0xproject/typescript-typings": "^0.0.2", "@0xproject/typescript-typings": "^0.1.0",
"@0xproject/utils": "^0.4.4", "@0xproject/web3-wrapper": "^0.6.0",
"@0xproject/web3-wrapper": "^0.4.0",
"ethereumjs-util": "^5.1.2",
"lodash": "^4.17.4", "lodash": "^4.17.4",
"request-promise-native": "^1.0.5",
"web3": "^0.20.0", "web3": "^0.20.0",
"web3-provider-engine": "^13.0.1" "web3-provider-engine": "^13.0.1"
}, },

View File

@@ -1,5 +1,3 @@
declare module 'web3-provider-engine/subproviders/rpc';
declare module '*.json' { declare module '*.json' {
const json: any; const json: any;
/* tslint:disable */ /* tslint:disable */

View File

@@ -7,6 +7,7 @@ import ProviderEngine = require('web3-provider-engine');
import RpcSubprovider = require('web3-provider-engine/subproviders/rpc'); import RpcSubprovider = require('web3-provider-engine/subproviders/rpc');
import { EmptyWalletSubprovider, FakeGasEstimateSubprovider, GanacheSubprovider } from '@0xproject/subproviders'; import { EmptyWalletSubprovider, FakeGasEstimateSubprovider, GanacheSubprovider } from '@0xproject/subproviders';
import { Provider } from '@0xproject/types';
import * as fs from 'fs'; import * as fs from 'fs';
import * as _ from 'lodash'; import * as _ from 'lodash';
import * as process from 'process'; import * as process from 'process';
@@ -34,7 +35,7 @@ export const web3Factory = {
web3.setProvider(provider); web3.setProvider(provider);
return web3; return web3;
}, },
getRpcProvider(config: Web3Config = {}): Web3.Provider { getRpcProvider(config: Web3Config = {}): Provider {
const provider = new ProviderEngine(); const provider = new ProviderEngine();
const isCoverageEnabled = env.parseBoolean(EnvVars.SolidityCoverage); const isCoverageEnabled = env.parseBoolean(EnvVars.SolidityCoverage);
if (isCoverageEnabled) { if (isCoverageEnabled) {

View File

@@ -1,4 +1,13 @@
[ [
{
"timestamp": 1523462196,
"version": "0.7.20",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{ {
"timestamp": 1522673609, "timestamp": 1522673609,
"version": "0.7.19", "version": "0.7.19",
@@ -15,8 +24,7 @@
{ {
"note": "Dependencies updated" "note": "Dependencies updated"
} }
], ]
"isPublished": true
}, },
{ {
"version": "0.7.13", "version": "0.7.13",
@@ -26,8 +34,7 @@
"pr": 389 "pr": 389
} }
], ],
"timestamp": 1518102000, "timestamp": 1518102000
"isPublished": true
}, },
{ {
"version": "0.7.0", "version": "0.7.0",
@@ -37,8 +44,7 @@
"pr": 272 "pr": 272
} }
], ],
"timestamp": 1513695600, "timestamp": 1513695600
"isPublished": true
}, },
{ {
"version": "0.6.7", "version": "0.6.7",
@@ -47,7 +53,6 @@
"note": "Re-publish JSON-schema previously published under NPM package 0x-json-schemas" "note": "Re-publish JSON-schema previously published under NPM package 0x-json-schemas"
} }
], ],
"timestamp": 1510585200, "timestamp": 1510585200
"isPublished": true
} }
] ]

View File

@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG CHANGELOG
## v0.7.20 - _April 11, 2018_
* Dependencies updated
## v0.7.19 - _April 2, 2018_ ## v0.7.19 - _April 2, 2018_
* Dependencies updated * Dependencies updated

View File

@@ -2,7 +2,7 @@
Contains 0x-related json schemas Contains 0x-related json schemas
### Read the [Documentation](0xproject.com/docs/json-schemas). ### Read the [Documentation](https://0xproject.com/docs/json-schemas).
## Installation ## Installation
@@ -32,11 +32,11 @@ If your project is in [TypeScript](https://www.typescriptlang.org/), add the fol
## Contributing ## Contributing
We strongly encourage that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository. We welcome improvements and fixes from the wider community! To report bugs within this package, please create an issue in this repository.
Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started. Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
### Install Dependencies ### Install dependencies
If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them: If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
@@ -52,16 +52,36 @@ yarn install
### Build ### Build
If this is your **first** time building this package, you must first build **all** packages within the monorepo. This is because packages that depend on other packages located inside this monorepo are symlinked when run from **within** the monorepo. This allows you to make changes across multiple packages without first publishing dependent packages to NPM. To build all packages, run the following from the monorepo root directory:
```bash
yarn lerna:rebuild
```
Or continuously rebuild on change:
```bash
yarn dev
```
You can also build this specific package by running the following from within its directory:
```bash ```bash
yarn build yarn build
``` ```
or or continuously rebuild on change:
```bash ```bash
yarn build:watch yarn build:watch
``` ```
### Clean
```bash
yarn clean
```
### Lint ### Lint
```bash ```bash

View File

@@ -1,6 +1,6 @@
{ {
"name": "@0xproject/json-schemas", "name": "@0xproject/json-schemas",
"version": "0.7.18", "version": "0.7.20",
"description": "0x-related json schemas", "description": "0x-related json schemas",
"main": "lib/src/index.js", "main": "lib/src/index.js",
"types": "lib/src/index.d.ts", "types": "lib/src/index.d.ts",
@@ -42,14 +42,14 @@
}, },
"homepage": "https://github.com/0xProject/0x-monorepo/packages/json-schemas/README.md", "homepage": "https://github.com/0xProject/0x-monorepo/packages/json-schemas/README.md",
"dependencies": { "dependencies": {
"@0xproject/typescript-typings": "^0.0.2", "@0xproject/typescript-typings": "^0.1.0",
"jsonschema": "^1.2.0", "jsonschema": "^1.2.0",
"lodash.values": "^4.3.0" "lodash.values": "^4.3.0"
}, },
"devDependencies": { "devDependencies": {
"@0xproject/monorepo-scripts": "^0.1.15", "@0xproject/monorepo-scripts": "^0.1.17",
"@0xproject/tslint-config": "^0.4.13", "@0xproject/tslint-config": "^0.4.15",
"@0xproject/utils": "^0.4.4", "@0xproject/utils": "^0.5.1",
"@types/lodash.foreach": "^4.5.3", "@types/lodash.foreach": "^4.5.3",
"@types/lodash.values": "^4.3.3", "@types/lodash.values": "^4.3.3",
"@types/mocha": "^2.2.42", "@types/mocha": "^2.2.42",

View File

@@ -3,10 +3,49 @@
"networks": { "networks": {
"50": { "50": {
"solc_version": "0.4.21", "solc_version": "0.4.21",
"keccak256": "0x2c3aa2e9dbef58abf57cecc148464d0852a83d7f30bbd2066f2a13b8bd3b1dd0", "keccak256": "0x85fb29ea6c21adcf07f754b2ad06482dd6fcd62d31935e36041b4d064c6a038e",
"source_tree_hash": "0x2c3aa2e9dbef58abf57cecc148464d0852a83d7f30bbd2066f2a13b8bd3b1dd0", "source_tree_hash": "0x85fb29ea6c21adcf07f754b2ad06482dd6fcd62d31935e36041b4d064c6a038e",
"optimizer_enabled": false, "optimizer_enabled": false,
"abi": [ "abi": [
{
"constant": false,
"inputs": [
{
"components": [
{
"components": [
{
"name": "to",
"type": "address"
},
{
"name": "amount",
"type": "uint256"
}
],
"name": "transferData",
"type": "tuple"
},
{
"name": "callback",
"type": "uint32"
}
],
"name": "nestedTransferData",
"type": "tuple"
}
],
"name": "transfer",
"outputs": [
{
"name": "",
"type": "int256"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{ {
"constant": true, "constant": true,
"inputs": [ "inputs": [
@@ -55,6 +94,39 @@
"stateMutability": "nonpayable", "stateMutability": "nonpayable",
"type": "function" "type": "function"
}, },
{
"constant": false,
"inputs": [
{
"components": [
{
"name": "to",
"type": "address"
},
{
"name": "amount",
"type": "uint256"
}
],
"name": "transferData",
"type": "tuple"
},
{
"name": "callback",
"type": "uint32"
}
],
"name": "transfer",
"outputs": [
{
"name": "",
"type": "int256"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{ {
"inputs": [], "inputs": [],
"payable": false, "payable": false,
@@ -84,15 +156,14 @@
"type": "event" "type": "event"
} }
], ],
"bytecode": "bytecode": "0x6060604052341561000f57600080fd5b6127106000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610613806100636000396000f300606060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063135cfdb11461006757806327e235e31461009d5780632bd14bb9146100d35780632f8086ba14610109575b600080fd5b341561007257600080fd5b6100876004610082903690610446565b61013f565b604051610094919061051c565b60405180910390f35b34156100a857600080fd5b6100bd60046100b890369061041d565b61015a565b6040516100ca9190610537565b60405180910390f35b34156100de57600080fd5b6100f360046100ee90369061046f565b610172565b6040516101009190610501565b60405180910390f35b341561011457600080fd5b6101296004610124903690610498565b6102e2565b604051610136919061051c565b60405180910390f35b6000610153826000015183602001516102e2565b9050919050565b60006020528060005260406000206000915090505481565b600081602001516000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410156101c757600090506102dd565b81602001516000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508160200151600080846000015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550816000015173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84602001516040516102d09190610537565b60405180910390a3600190505b919050565b60006102ed83610172565b508163ffffffff16905092915050565b6000610309823561059f565b905092915050565b60006060828403121561032357600080fd5b61032d6040610552565b9050600061033d8482850161035d565b600083015250604061035184828501610409565b60208301525092915050565b60006040828403121561036f57600080fd5b6103796040610552565b90506000610389848285016102fd565b600083015250602061039d848285016103f5565b60208301525092915050565b6000604082840312156103bb57600080fd5b6103c56040610552565b905060006103d5848285016102fd565b60008301525060206103e9848285016103f5565b60208301525092915050565b600061040182356105bf565b905092915050565b600061041582356105c9565b905092915050565b60006020828403121561042f57600080fd5b600061043d848285016102fd565b91505092915050565b60006060828403121561045857600080fd5b600061046684828501610311565b91505092915050565b60006040828403121561048157600080fd5b600061048f848285016103a9565b91505092915050565b600080606083850312156104ab57600080fd5b60006104b9858286016103a9565b92505060406104ca85828601610409565b9150509250929050565b6104dd8161057f565b82525050565b6104ec8161058b565b82525050565b6104fb81610595565b82525050565b600060208201905061051660008301846104d4565b92915050565b600060208201905061053160008301846104e3565b92915050565b600060208201905061054c60008301846104f2565b92915050565b6000604051905081810181811067ffffffffffffffff8211171561057557600080fd5b8060405250919050565b60008115159050919050565b6000819050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600063ffffffff821690509190505600a265627a7a72305820716a74dd7e2a73c237481496756750895b57977fc4876b1c48aef9b71759bf836c6578706572696d656e74616cf50037",
"0x6060604052341561000f57600080fd5b6127106000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610406806100636000396000f30060606040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806327e235e3146100515780632bd14bb914610087575b600080fd5b341561005c57600080fd5b610071600461006c9036906102b9565b6100bd565b60405161007e9190610344565b60405180910390f35b341561009257600080fd5b6100a760046100a29036906102e2565b6100d5565b6040516100b49190610329565b60405180910390f35b60006020528060005260406000206000915090505481565b600081602001516000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101561012a5760009050610240565b81602001516000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508160200151600080846000015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550816000015173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84602001516040516102339190610344565b60405180910390a3600190505b919050565b600061025182356103a2565b905092915050565b60006040828403121561026b57600080fd5b610275604061035f565b9050600061028584828501610245565b6000830152506020610299848285016102a5565b60208301525092915050565b60006102b182356103c2565b905092915050565b6000602082840312156102cb57600080fd5b60006102d984828501610245565b91505092915050565b6000604082840312156102f457600080fd5b600061030284828501610259565b91505092915050565b6103148161038c565b82525050565b61032381610398565b82525050565b600060208201905061033e600083018461030b565b92915050565b6000602082019050610359600083018461031a565b92915050565b6000604051905081810181811067ffffffffffffffff8211171561038257600080fd5b8060405250919050565b60008115159050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60008190509190505600a265627a7a72305820d15828219194e8ddaa624e10f9c8823c05268d79753b4c60ef401fb4fe5f09dc6c6578706572696d656e74616cf50037", "runtime_bytecode": "0x606060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063135cfdb11461006757806327e235e31461009d5780632bd14bb9146100d35780632f8086ba14610109575b600080fd5b341561007257600080fd5b6100876004610082903690610446565b61013f565b604051610094919061051c565b60405180910390f35b34156100a857600080fd5b6100bd60046100b890369061041d565b61015a565b6040516100ca9190610537565b60405180910390f35b34156100de57600080fd5b6100f360046100ee90369061046f565b610172565b6040516101009190610501565b60405180910390f35b341561011457600080fd5b6101296004610124903690610498565b6102e2565b604051610136919061051c565b60405180910390f35b6000610153826000015183602001516102e2565b9050919050565b60006020528060005260406000206000915090505481565b600081602001516000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410156101c757600090506102dd565b81602001516000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508160200151600080846000015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550816000015173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84602001516040516102d09190610537565b60405180910390a3600190505b919050565b60006102ed83610172565b508163ffffffff16905092915050565b6000610309823561059f565b905092915050565b60006060828403121561032357600080fd5b61032d6040610552565b9050600061033d8482850161035d565b600083015250604061035184828501610409565b60208301525092915050565b60006040828403121561036f57600080fd5b6103796040610552565b90506000610389848285016102fd565b600083015250602061039d848285016103f5565b60208301525092915050565b6000604082840312156103bb57600080fd5b6103c56040610552565b905060006103d5848285016102fd565b60008301525060206103e9848285016103f5565b60208301525092915050565b600061040182356105bf565b905092915050565b600061041582356105c9565b905092915050565b60006020828403121561042f57600080fd5b600061043d848285016102fd565b91505092915050565b60006060828403121561045857600080fd5b600061046684828501610311565b91505092915050565b60006040828403121561048157600080fd5b600061048f848285016103a9565b91505092915050565b600080606083850312156104ab57600080fd5b60006104b9858286016103a9565b92505060406104ca85828601610409565b9150509250929050565b6104dd8161057f565b82525050565b6104ec8161058b565b82525050565b6104fb81610595565b82525050565b600060208201905061051660008301846104d4565b92915050565b600060208201905061053160008301846104e3565b92915050565b600060208201905061054c60008301846104f2565b92915050565b6000604051905081810181811067ffffffffffffffff8211171561057557600080fd5b8060405250919050565b60008115159050919050565b6000819050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600063ffffffff821690509190505600a265627a7a72305820716a74dd7e2a73c237481496756750895b57977fc4876b1c48aef9b71759bf836c6578706572696d656e74616cf50037",
"runtime_bytecode": "updated_at": 1522966321930,
"0x60606040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806327e235e3146100515780632bd14bb914610087575b600080fd5b341561005c57600080fd5b610071600461006c9036906102b9565b6100bd565b60405161007e9190610344565b60405180910390f35b341561009257600080fd5b6100a760046100a29036906102e2565b6100d5565b6040516100b49190610329565b60405180910390f35b60006020528060005260406000206000915090505481565b600081602001516000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101561012a5760009050610240565b81602001516000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508160200151600080846000015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550816000015173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84602001516040516102339190610344565b60405180910390a3600190505b919050565b600061025182356103a2565b905092915050565b60006040828403121561026b57600080fd5b610275604061035f565b9050600061028584828501610245565b6000830152506020610299848285016102a5565b60208301525092915050565b60006102b182356103c2565b905092915050565b6000602082840312156102cb57600080fd5b60006102d984828501610245565b91505092915050565b6000604082840312156102f457600080fd5b600061030284828501610259565b91505092915050565b6103148161038c565b82525050565b61032381610398565b82525050565b600060208201905061033e600083018461030b565b92915050565b6000602082019050610359600083018461031a565b92915050565b6000604051905081810181811067ffffffffffffffff8211171561038257600080fd5b8060405250919050565b60008115159050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60008190509190505600a265627a7a72305820d15828219194e8ddaa624e10f9c8823c05268d79753b4c60ef401fb4fe5f09dc6c6578706572696d656e74616cf50037", "source_map": "60:1093:0:-;;;389:72;;;;;;;;449:5;426:8;:20;435:10;426:20;;;;;;;;;;;;;;;:28;;;;60:1093;;;;;;",
"updated_at": 1522318279735, "source_map_runtime": "60:1093:0:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;978:172;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;84:41;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;467:352;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;825:147;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;978:172;1051:3;1073:70;1082:18;:31;;;1115:18;:27;;;1073:8;:70::i;:::-;1066:77;;978:172;;;:::o;84:41::-;;;;;;;;;;;;;;;;;:::o;467:352::-;528:12;579;:19;;;556:8;:20;565:10;556:20;;;;;;;;;;;;;;;;:42;552:60;;;607:5;600:12;;;;552:60;646:12;:19;;;622:8;:20;631:10;622:20;;;;;;;;;;;;;;;;:43;;;;;;;;;;;704:12;:19;;;675:8;:25;684:12;:15;;;675:25;;;;;;;;;;;;;;;;:48;;;;;;;;;;;754:12;:15;;;733:58;;742:10;733:58;;;771:12;:19;;;733:58;;;;;;;;;;;;;;;808:4;801:11;;467:352;;;;:::o;825:147::-;903:3;918:22;927:12;918:8;:22::i;:::-;;957:8;950:15;;;;825:147;;;;:::o;5:118:-1:-;;72:46;110:6;97:20;72:46;;;63:55;;57:66;;;;;171:510;;294:4;282:9;277:3;273:19;269:30;266:2;;;312:1;309;302:12;266:2;330:20;345:4;330:20;;;321:29;;408:1;439:73;508:3;499:6;488:9;484:22;439:73;;;433:3;426:5;422:15;415:98;360:164;578:2;611:48;655:3;646:6;635:9;631:22;611:48;;;604:4;597:5;593:16;586:74;534:137;260:421;;;;;723:465;;836:4;824:9;819:3;815:19;811:30;808:2;;;854:1;851;844:12;808:2;872:20;887:4;872:20;;;863:29;;940:1;971:49;1016:3;1007:6;996:9;992:22;971:49;;;965:3;958:5;954:15;947:74;902:130;1084:2;1117:49;1162:3;1153:6;1142:9;1138:22;1117:49;;;1110:4;1103:5;1099:16;1092:75;1042:136;802:386;;;;;1230:469;;1347:4;1335:9;1330:3;1326:19;1322:30;1319:2;;;1365:1;1362;1355:12;1319:2;1383:20;1398:4;1383:20;;;1374:29;;1451:1;1482:49;1527:3;1518:6;1507:9;1503:22;1482:49;;;1476:3;1469:5;1465:15;1458:74;1413:130;1595:2;1628:49;1673:3;1664:6;1653:9;1649:22;1628:49;;;1621:4;1614:5;1610:16;1603:75;1553:136;1313:386;;;;;1706:118;;1773:46;1811:6;1798:20;1773:46;;;1764:55;;1758:66;;;;;1831:116;;1897:45;1934:6;1921:20;1897:45;;;1888:54;;1882:65;;;;;1954:241;;2058:2;2046:9;2037:7;2033:23;2029:32;2026:2;;;2074:1;2071;2064:12;2026:2;2109:1;2126:53;2171:7;2162:6;2151:9;2147:22;2126:53;;;2116:63;;2088:97;2020:175;;;;;2202:309;;2340:2;2328:9;2319:7;2315:23;2311:32;2308:2;;;2356:1;2353;2346:12;2308:2;2391:1;2408:87;2487:7;2478:6;2467:9;2463:22;2408:87;;;2398:97;;2370:131;2302:209;;;;;2518:297;;2650:2;2638:9;2629:7;2625:23;2621:32;2618:2;;;2666:1;2663;2656:12;2618:2;2701:1;2718:81;2791:7;2782:6;2771:9;2767:22;2718:81;;;2708:91;;2680:125;2612:203;;;;;2822:420;;;2970:2;2958:9;2949:7;2945:23;2941:32;2938:2;;;2986:1;2983;2976:12;2938:2;3021:1;3038:81;3111:7;3102:6;3091:9;3087:22;3038:81;;;3028:91;;3000:125;3156:2;3174:52;3218:7;3209:6;3198:9;3194:22;3174:52;;;3164:62;;3135:97;2932:310;;;;;;3249:101;3316:28;3338:5;3316:28;;;3311:3;3304:41;3298:52;;;3357:107;3428:30;3452:5;3428:30;;;3423:3;3416:43;3410:54;;;3471:110;3544:31;3569:5;3544:31;;;3539:3;3532:44;3526:55;;;3588:181;;3690:2;3679:9;3675:18;3667:26;;3704:55;3756:1;3745:9;3741:17;3732:6;3704:55;;;3661:108;;;;;3776:189;;3882:2;3871:9;3867:18;3859:26;;3896:59;3952:1;3941:9;3937:17;3928:6;3896:59;;;3853:112;;;;;3972:193;;4080:2;4069:9;4065:18;4057:26;;4094:61;4152:1;4141:9;4137:17;4128:6;4094:61;;;4051:114;;;;;4172:256;;4234:2;4228:9;4218:19;;4272:4;4264:6;4260:17;4371:6;4359:10;4356:22;4335:18;4323:10;4320:34;4317:62;4314:2;;;4392:1;4389;4382:12;4314:2;4412:10;4408:2;4401:22;4212:216;;;;;4435:92;;4515:5;4508:13;4501:21;4490:32;;4484:43;;;;4534:78;;4602:5;4591:16;;4585:27;;;;4619:79;;4688:5;4677:16;;4671:27;;;;4705:128;;4785:42;4778:5;4774:54;4763:65;;4757:76;;;;4840:79;;4909:5;4898:16;;4892:27;;;;4926:95;;5005:10;4998:5;4994:22;4983:33;;4977:44;;;",
"source_map": "60:662:0:-;;;290:72;;;;;;;;350:5;327:8;:20;336:10;327:20;;;;;;;;;;;;;;;:28;;;;60:662;;;;;;", "sources": [
"source_map_runtime": "/Metacoin.sol"
"60:662:0:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;84:41;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;368:352;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;84:41;;;;;;;;;;;;;;;;;:::o;368:352::-;429:12;480;:19;;;457:8;:20;466:10;457:20;;;;;;;;;;;;;;;;:42;453:60;;;508:5;501:12;;;;453:60;547:12;:19;;;523:8;:20;532:10;523:20;;;;;;;;;;;;;;;;:43;;;;;;;;;;;605:12;:19;;;576:8;:25;585:12;:15;;;576:25;;;;;;;;;;;;;;;;:48;;;;;;;;;;;655:12;:15;;;634:58;;643:10;634:58;;;672:12;:19;;;634:58;;;;;;;;;;;;;;;709:4;702:11;;368:352;;;;:::o;5:118:-1:-;;72:46;110:6;97:20;72:46;;;63:55;;57:66;;;;;165:469;;282:4;270:9;265:3;261:19;257:30;254:2;;;300:1;297;290:12;254:2;318:20;333:4;318:20;;;309:29;;386:1;417:49;462:3;453:6;442:9;438:22;417:49;;;411:3;404:5;400:15;393:74;348:130;530:2;563:49;608:3;599:6;588:9;584:22;563:49;;;556:4;549:5;545:16;538:75;488:136;248:386;;;;;641:118;;708:46;746:6;733:20;708:46;;;699:55;;693:66;;;;;766:241;;870:2;858:9;849:7;845:23;841:32;838:2;;;886:1;883;876:12;838:2;921:1;938:53;983:7;974:6;963:9;959:22;938:53;;;928:63;;900:97;832:175;;;;;1014:297;;1146:2;1134:9;1125:7;1121:23;1117:32;1114:2;;;1162:1;1159;1152:12;1114:2;1197:1;1214:81;1287:7;1278:6;1267:9;1263:22;1214:81;;;1204:91;;1176:125;1108:203;;;;;1318:101;1385:28;1407:5;1385:28;;;1380:3;1373:41;1367:52;;;1426:110;1499:31;1524:5;1499:31;;;1494:3;1487:44;1481:55;;;1543:181;;1645:2;1634:9;1630:18;1622:26;;1659:55;1711:1;1700:9;1696:17;1687:6;1659:55;;;1616:108;;;;;1731:193;;1839:2;1828:9;1824:18;1816:26;;1853:61;1911:1;1900:9;1896:17;1887:6;1853:61;;;1810:114;;;;;1931:256;;1993:2;1987:9;1977:19;;2031:4;2023:6;2019:17;2130:6;2118:10;2115:22;2094:18;2082:10;2079:34;2076:62;2073:2;;;2151:1;2148;2141:12;2073:2;2171:10;2167:2;2160:22;1971:216;;;;;2194:92;;2274:5;2267:13;2260:21;2249:32;;2243:43;;;;2293:79;;2362:5;2351:16;;2345:27;;;;2379:128;;2459:42;2452:5;2448:54;2437:65;;2431:76;;;;2514:79;;2583:5;2572:16;;2566:27;;;", ]
"sources": ["Metacoin.sol"]
} }
} }
} }

View File

@@ -11,6 +11,11 @@ contract Metacoin {
uint256 amount; uint256 amount;
} }
struct NestedTransferData {
TransferData transferData;
uint32 callback;
}
function Metacoin() public { function Metacoin() public {
balances[msg.sender] = 10000; balances[msg.sender] = 10000;
} }
@@ -22,4 +27,14 @@ contract Metacoin {
Transfer(msg.sender, transferData.to, transferData.amount); Transfer(msg.sender, transferData.to, transferData.amount);
return true; return true;
} }
function transfer(TransferData transferData, uint32 callback) public returns (int) {
transfer(transferData);
return callback;
}
function transfer(NestedTransferData nestedTransferData) public returns (int) {
return transfer(nestedTransferData.transferData, nestedTransferData.callback);
}
} }

View File

@@ -1,6 +1,6 @@
{ {
"name": "@0xproject/metacoin", "name": "@0xproject/metacoin",
"version": "0.0.1", "version": "0.0.3",
"private": true, "private": true,
"description": "Example solidity project using 0x dev tools", "description": "Example solidity project using 0x dev tools",
"scripts": { "scripts": {
@@ -18,33 +18,33 @@
"coverage:report:html": "istanbul report html && open coverage/index.html", "coverage:report:html": "istanbul report html && open coverage/index.html",
"coverage:report:lcov": "istanbul report lcov", "coverage:report:lcov": "istanbul report lcov",
"test:circleci": "yarn test:coverage", "test:circleci": "yarn test:coverage",
"compile": "node ../deployer/lib/src/cli.js compile --contracts Metacoin --contracts-dir contracts --artifacts-dir artifacts" "compile": "node ../deployer/lib/src/cli.js compile --contracts Metacoin --contract-dirs contracts --artifacts-dir artifacts"
}, },
"author": "", "author": "",
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"@0xproject/abi-gen": "^0.2.7", "@0xproject/abi-gen": "^0.2.10",
"@0xproject/base-contract": "^0.0.6", "@0xproject/base-contract": "^0.2.0",
"@0xproject/deployer": "^0.3.3", "@0xproject/deployer": "^0.4.0",
"@0xproject/types": "^0.4.1", "@0xproject/sol-cov": "^0.0.7",
"@0xproject/tslint-config": "^0.4.12", "@0xproject/subproviders": "^0.8.5",
"@0xproject/sol-cov": "^0.0.5", "@0xproject/tslint-config": "^0.4.15",
"@0xproject/subproviders": "^0.8.2", "@0xproject/types": "^0.6.0",
"@0xproject/web3-wrapper": "^0.4.0", "@0xproject/utils": "^0.5.1",
"@0xproject/utils": "^0.4.3", "@0xproject/web3-wrapper": "^0.6.0",
"ethers-contracts": "^2.2.1", "ethers-contracts": "^2.2.1",
"lodash": "^4.17.4", "lodash": "^4.17.4",
"web3-provider-engine": "^13.0.1" "web3-provider-engine": "^13.0.1"
}, },
"devDependencies": { "devDependencies": {
"@0xproject/dev-utils": "^0.3.2", "@0xproject/dev-utils": "^0.3.5",
"npm-run-all": "^4.1.2",
"dirty-chai": "^2.0.1",
"shx": "^0.2.2",
"tslint": "5.8.0",
"chai": "^4.0.1", "chai": "^4.0.1",
"chai-as-promised": "^7.1.0", "chai-as-promised": "^7.1.0",
"chai-bignumber": "^2.0.1", "chai-bignumber": "^2.0.1",
"dirty-chai": "^2.0.1",
"npm-run-all": "^4.1.2",
"shx": "^0.2.2",
"tslint": "5.8.0",
"typescript": "2.7.1" "typescript": "2.7.1"
} }
} }

View File

@@ -8,7 +8,7 @@ import { MetacoinContract, TransferContractEventArgs } from '../src/contract_wra
import { chaiSetup } from './utils/chai_setup'; import { chaiSetup } from './utils/chai_setup';
import { deployer } from './utils/deployer'; import { deployer } from './utils/deployer';
import { web3Wrapper } from './utils/web3_wrapper'; import { provider, web3Wrapper } from './utils/web3_wrapper';
chaiSetup.configure(); chaiSetup.configure();
const { expect } = chai; const { expect } = chai;
@@ -21,7 +21,7 @@ describe('Metacoin', () => {
before(async () => { before(async () => {
const metacoinInstance = await deployer.deployAsync('Metacoin'); const metacoinInstance = await deployer.deployAsync('Metacoin');
web3Wrapper.abiDecoder.addABI(metacoinInstance.abi); web3Wrapper.abiDecoder.addABI(metacoinInstance.abi);
metacoin = new MetacoinContract(web3Wrapper, metacoinInstance.abi, metacoinInstance.address); metacoin = new MetacoinContract(metacoinInstance.abi, metacoinInstance.address, provider);
}); });
beforeEach(async () => { beforeEach(async () => {
await blockchainLifecycle.startAsync(); await blockchainLifecycle.startAsync();
@@ -36,12 +36,12 @@ describe('Metacoin', () => {
}); });
}); });
describe('#transfer', () => { describe('#transfer', () => {
it(`should successfully transfer tokens`, async () => { it(`should successfully transfer tokens (via transfer1)`, async () => {
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'; const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
const amount = INITIAL_BALANCE.div(2); const amount = INITIAL_BALANCE.div(2);
const oldBalance = await metacoin.balances.callAsync(ZERO_ADDRESS); const oldBalance = await metacoin.balances.callAsync(ZERO_ADDRESS);
expect(oldBalance).to.be.bignumber.equal(0); expect(oldBalance).to.be.bignumber.equal(0);
const txHash = await metacoin.transfer.sendTransactionAsync( const txHash = await metacoin.transfer1.sendTransactionAsync(
{ {
to: ZERO_ADDRESS, to: ZERO_ADDRESS,
amount, amount,
@@ -58,5 +58,57 @@ describe('Metacoin', () => {
const newBalance = await metacoin.balances.callAsync(ZERO_ADDRESS); const newBalance = await metacoin.balances.callAsync(ZERO_ADDRESS);
expect(newBalance).to.be.bignumber.equal(amount); expect(newBalance).to.be.bignumber.equal(amount);
}); });
it(`should successfully transfer tokens (via transfer2)`, async () => {
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
const amount = INITIAL_BALANCE.div(2);
const oldBalance = await metacoin.balances.callAsync(ZERO_ADDRESS);
expect(oldBalance).to.be.bignumber.equal(0);
const callback = 59;
const txHash = await metacoin.transfer2.sendTransactionAsync(
{
to: ZERO_ADDRESS,
amount,
},
callback,
{ from: devConstants.TESTRPC_FIRST_ADDRESS },
);
const txReceipt = await web3Wrapper.awaitTransactionMinedAsync(txHash);
const transferLogs = txReceipt.logs[0] as LogWithDecodedArgs<TransferContractEventArgs>;
expect(transferLogs.args).to.be.deep.equal({
_to: ZERO_ADDRESS,
_from: devConstants.TESTRPC_FIRST_ADDRESS,
_value: amount,
});
const newBalance = await metacoin.balances.callAsync(ZERO_ADDRESS);
expect(newBalance).to.be.bignumber.equal(amount);
});
it(`should successfully transfer tokens (via transfer3)`, async () => {
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
const amount = INITIAL_BALANCE.div(2);
const oldBalance = await metacoin.balances.callAsync(ZERO_ADDRESS);
expect(oldBalance).to.be.bignumber.equal(0);
const callback = 59;
const txHash = await metacoin.transfer3.sendTransactionAsync(
{
transferData: {
to: ZERO_ADDRESS,
amount,
},
callback,
},
{ from: devConstants.TESTRPC_FIRST_ADDRESS },
);
const txReceipt = await web3Wrapper.awaitTransactionMinedAsync(txHash);
const transferLogs = txReceipt.logs[0] as LogWithDecodedArgs<TransferContractEventArgs>;
expect(transferLogs.args).to.be.deep.equal({
_to: ZERO_ADDRESS,
_from: devConstants.TESTRPC_FIRST_ADDRESS,
_value: amount,
});
const newBalance = await metacoin.balances.callAsync(ZERO_ADDRESS);
expect(newBalance).to.be.bignumber.equal(amount);
});
}); });
}); });

View File

@@ -6,7 +6,7 @@ import { config } from './config';
import { web3Wrapper } from './web3_wrapper'; import { web3Wrapper } from './web3_wrapper';
const deployerOpts = { const deployerOpts = {
web3Provider: web3Wrapper.getProvider(), provider: web3Wrapper.getProvider(),
artifactsDir: config.artifactsDir, artifactsDir: config.artifactsDir,
networkId: config.networkId, networkId: config.networkId,
defaults: { defaults: {

View File

@@ -8,12 +8,12 @@ import ProviderEngine = require('web3-provider-engine');
import { config } from './config'; import { config } from './config';
import { coverage } from './coverage'; import { coverage } from './coverage';
export const web3Provider = new ProviderEngine(); export const provider = new ProviderEngine();
const isCoverageEnabled = env.parseBoolean(EnvVars.SolidityCoverage); const isCoverageEnabled = env.parseBoolean(EnvVars.SolidityCoverage);
if (isCoverageEnabled) { if (isCoverageEnabled) {
web3Provider.addProvider(coverage.getCoverageSubproviderSingleton()); provider.addProvider(coverage.getCoverageSubproviderSingleton());
} }
web3Provider.addProvider( provider.addProvider(
new GanacheSubprovider({ new GanacheSubprovider({
logger: { logger: {
log: (arg: any) => { log: (arg: any) => {
@@ -25,6 +25,6 @@ web3Provider.addProvider(
mnemonic: config.mnemonic, mnemonic: config.mnemonic,
}), }),
); );
web3Provider.start(); provider.start();
export const web3Wrapper = new Web3Wrapper(web3Provider); export const web3Wrapper = new Web3Wrapper(provider);

View File

@@ -1,4 +1,13 @@
[ [
{
"timestamp": 1523462196,
"version": "0.1.17",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{ {
"timestamp": 1522658513, "timestamp": 1522658513,
"version": "0.1.16", "version": "0.1.16",
@@ -15,7 +24,6 @@
"note": "Add postpublish utils" "note": "Add postpublish utils"
} }
], ],
"timestamp": 1521298800, "timestamp": 1521298800
"isPublished": true
} }
] ]

View File

@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG CHANGELOG
## v0.1.17 - _April 11, 2018_
* Dependencies updated
## v0.1.16 - _April 2, 2018_ ## v0.1.16 - _April 2, 2018_
* Dependencies updated * Dependencies updated

View File

@@ -16,11 +16,11 @@ This will list out any dependencies that differ in versions between packages.
## Contributing ## Contributing
We strongly recommend that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository. We welcome improvements and fixes from the wider community! To report bugs within this package, please create an issue in this repository.
Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started. Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
### Install Dependencies ### Install dependencies
If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them: If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
@@ -36,11 +36,25 @@ yarn install
### Build ### Build
If this is your **first** time building this package, you must first build **all** packages within the monorepo. This is because packages that depend on other packages located inside this monorepo are symlinked when run from **within** the monorepo. This allows you to make changes across multiple packages without first publishing dependent packages to NPM. To build all packages, run the following from the monorepo root directory:
```bash
yarn lerna:rebuild
```
Or continuously rebuild on change:
```bash
yarn dev
```
You can also build this specific package by running the following from within its directory:
```bash ```bash
yarn build yarn build
``` ```
or or continuously rebuild on change:
```bash ```bash
yarn build:watch yarn build:watch
@@ -57,3 +71,9 @@ yarn clean
```bash ```bash
yarn lint yarn lint
``` ```
### Run Tests
```bash
yarn test
```

View File

@@ -1,6 +1,6 @@
{ {
"name": "@0xproject/monorepo-scripts", "name": "@0xproject/monorepo-scripts",
"version": "0.1.15", "version": "0.1.17",
"description": "Helper scripts for the monorepo", "description": "Helper scripts for the monorepo",
"main": "lib/index.js", "main": "lib/index.js",
"types": "lib/index.d.ts", "types": "lib/index.d.ts",
@@ -10,10 +10,10 @@
"clean": "shx rm -rf lib", "clean": "shx rm -rf lib",
"build": "tsc", "build": "tsc",
"test:publish": "run-s build script:publish", "test:publish": "run-s build script:publish",
"convert_changelogs": "run-s build script:convert_changelogs", "find_unused_deps": "run-s build script:find_unused_deps",
"script:deps_versions": "node ./lib/deps_versions.js", "script:deps_versions": "node ./lib/deps_versions.js",
"script:publish": "IS_DRY_RUN=true node ./lib/publish.js", "script:publish": "IS_DRY_RUN=true node ./lib/publish.js",
"script:convert_changelogs": "node ./lib/convert_changelogs.js" "script:find_unused_deps": "node ./lib/find_unused_dependencies.js"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@@ -26,10 +26,12 @@
"homepage": "https://github.com/0xProject/0x-monorepo/packages/monorepo-scripts/README.md", "homepage": "https://github.com/0xProject/0x-monorepo/packages/monorepo-scripts/README.md",
"comment": "// We purposefully use an older version of tslint-config here to avoid creating an import cycle", "comment": "// We purposefully use an older version of tslint-config here to avoid creating an import cycle",
"devDependencies": { "devDependencies": {
"@0xproject/tslint-config": "0.4.8", "@0xproject/tslint-config": "0.4.13",
"@types/glob": "^5.0.33", "@types/glob": "^5.0.33",
"@types/node": "^8.0.53", "@types/node": "^8.0.53",
"@types/opn": "^5.1.0",
"@types/rimraf": "^2.0.2", "@types/rimraf": "^2.0.2",
"depcheck": "^0.6.9",
"lerna-get-packages": "^1.0.0", "lerna-get-packages": "^1.0.0",
"npm-run-all": "^4.1.2", "npm-run-all": "^4.1.2",
"shx": "^0.2.2", "shx": "^0.2.2",
@@ -37,13 +39,16 @@
"typescript": "2.7.1" "typescript": "2.7.1"
}, },
"dependencies": { "dependencies": {
"@types/depcheck": "^0.6.0",
"async-child-process": "^1.1.1", "async-child-process": "^1.1.1",
"chalk": "^2.3.0", "chalk": "^2.3.0",
"es6-promisify": "^5.0.0", "es6-promisify": "^5.0.0",
"glob": "^7.1.2", "glob": "^7.1.2",
"lodash": "^4.17.4", "lodash": "^4.17.4",
"moment": "2.21.0", "moment": "2.21.0",
"opn": "^5.3.0",
"promisify-child-process": "^1.0.5", "promisify-child-process": "^1.0.5",
"prompt": "^1.0.0",
"publish-release": "0xproject/publish-release", "publish-release": "0xproject/publish-release",
"rimraf": "^2.6.2", "rimraf": "^2.6.2",
"semver-diff": "^2.1.0", "semver-diff": "^2.1.0",

View File

@@ -2,4 +2,5 @@ import * as path from 'path';
export const constants = { export const constants = {
monorepoRootPath: path.join(__dirname, '../../..'), monorepoRootPath: path.join(__dirname, '../../..'),
stagingWebsite: 'http://staging-0xproject.s3-website-us-east-1.amazonaws.com',
}; };

View File

@@ -1,99 +0,0 @@
#!/usr/bin/env node
/**
* TEMPORARY SCRIPT
* This script exists to migrate the legacy CHANGELOG.md to the canonical CHANGELOG.md
* TODO: Remove after migration is successful and committed.
*/
import * as fs from 'fs';
import lernaGetPackages = require('lerna-get-packages');
import * as _ from 'lodash';
import * as moment from 'moment';
import * as path from 'path';
import { exec as execAsync } from 'promisify-child-process';
import { constants } from './constants';
import { Changelog, Changes, UpdatedPackage } from './types';
import { utils } from './utils';
const HEADER_PRAGMA = '##';
(async () => {
const allLernaPackages = lernaGetPackages(constants.monorepoRootPath);
const publicLernaPackages = _.filter(allLernaPackages, pkg => !pkg.package.private);
for (const lernaPackage of publicLernaPackages) {
const changelogMdIfExists = getChangelogMdIfExists(lernaPackage.package.name, lernaPackage.location);
if (_.isUndefined(changelogMdIfExists)) {
throw new Error(`${lernaPackage.package.name} should have CHANGELOG.md b/c it's public. Add one.`);
}
const lines = changelogMdIfExists.split('\n');
const changelogs: Changelog[] = [];
let changelog: Changelog = {
version: '',
changes: [],
};
/**
* Example MD entry:
* ## v0.3.1 - _March 18, 2018_
*
* * Add TS types for `yargs` (#400)
*/
for (const line of lines) {
if (_.startsWith(line, `${HEADER_PRAGMA} `)) {
let version = line.substr(4).split(' - ')[0];
if (version === '0.x.x') {
version = utils.getNextPatchVersion(lernaPackage.package.version);
}
const dateStr = line.split('_')[1];
let date;
if (!_.includes(dateStr, 'TBD')) {
date = moment(dateStr, 'MMMM D, YYYY');
}
changelog = {
version,
changes: [],
};
if (!_.isUndefined(date)) {
changelog.timestamp = date.unix();
}
if (!_.includes(dateStr, 'TBD')) {
changelog.isPublished = true;
}
changelogs.push(changelog);
} else if (_.includes(line, '* ')) {
const note = line.split('* ')[1].split(' (#')[0];
const prChunk = line.split(' (#')[1];
let pr;
if (!_.isUndefined(prChunk)) {
pr = prChunk.split(')')[0];
}
const changes: Changes = {
note,
};
if (!_.isUndefined(pr)) {
changes.pr = _.parseInt(pr);
}
changelog.changes.push(changes);
}
}
const changelogJSON = JSON.stringify(changelogs, null, 4);
const changelogJSONPath = `${lernaPackage.location}/CHANGELOG.json`;
fs.writeFileSync(changelogJSONPath, changelogJSON);
await utils.prettifyAsync(changelogJSONPath, constants.monorepoRootPath);
}
})().catch(err => {
utils.log(err.stdout);
process.exit(1);
});
function getChangelogMdIfExists(packageName: string, location: string): string | undefined {
const changelogPath = path.join(location, 'CHANGELOG.md');
let changelogMd: string;
try {
changelogMd = fs.readFileSync(changelogPath, 'utf-8');
return changelogMd;
} catch (err) {
return undefined;
}
}

View File

@@ -0,0 +1,37 @@
#!/usr/bin/env node
import * as depcheckAsync from 'depcheck';
import * as fs from 'fs';
import lernaGetPackages = require('lerna-get-packages');
import * as _ from 'lodash';
import { exec as execAsync } from 'promisify-child-process';
import { constants } from './constants';
import { utils } from './utils';
// For some reason, `depcheck` hangs on some packages. Add them here.
const IGNORE_PACKAGES = ['@0xproject/deployer'];
(async () => {
utils.log('*** NOTE: Not all deps listed here are actually not required. ***');
utils.log("*** `depcheck` isn't perfect so double check before actually removing any. ***\n");
const lernaPackages = lernaGetPackages(constants.monorepoRootPath);
for (const lernaPackage of lernaPackages) {
if (_.includes(IGNORE_PACKAGES, lernaPackage.package.name)) {
continue; // skip
}
utils.log(`Checking ${lernaPackage.package.name} for unused deps. This might take a while...`);
const configs = {};
const { dependencies } = await depcheckAsync(lernaPackage.location, configs);
if (!_.isEmpty(dependencies)) {
_.each(dependencies, dep => {
utils.log(dep);
});
}
utils.log('\n');
}
})().catch(err => {
utils.log(err);
process.exit(1);
});

View File

@@ -3,6 +3,11 @@ declare module 'publish-release';
declare module 'es6-promisify'; declare module 'es6-promisify';
declare module 'semver-diff'; declare module 'semver-diff';
declare module 'prompt' {
const start: () => void;
const get: (promptMessages: string[], callback: (err: Error, result: string) => void) => void;
}
// semver-sort declarations // semver-sort declarations
declare module 'semver-sort' { declare module 'semver-sort' {
const desc: (versions: string[]) => string[]; const desc: (versions: string[]) => string[];
@@ -15,6 +20,7 @@ declare interface LernaPackage {
version: string; version: string;
name: string; name: string;
main?: string; main?: string;
scripts?: { [command: string]: string };
config?: { config?: {
additionalTsTypings?: string[]; additionalTsTypings?: string[];
}; };

View File

@@ -91,7 +91,7 @@ export const postpublishUtils = {
); );
}, },
async publishReleaseNotesAsync(cwd: string, packageName: string, version: string, assets: string[]): Promise<void> { async publishReleaseNotesAsync(cwd: string, packageName: string, version: string, assets: string[]): Promise<void> {
const notes = this.getReleaseNotes(packageName); const notes = this.getReleaseNotes(packageName, version);
const releaseName = this.getReleaseName(packageName, version); const releaseName = this.getReleaseName(packageName, version);
const tag = this.getTag(packageName, version); const tag = this.getTag(packageName, version);
const finalAssets = this.adjustAssetPaths(cwd, assets); const finalAssets = this.adjustAssetPaths(cwd, assets);
@@ -109,9 +109,8 @@ export const postpublishUtils = {
reuseDraftOnly: false, reuseDraftOnly: false,
assets, assets,
}); });
this.updateChangelogIsPublished(packageName);
}, },
getReleaseNotes(packageName: string) { getReleaseNotes(packageName: string, version: string) {
const packageNameWithNamespace = packageName.replace('@0xproject/', ''); const packageNameWithNamespace = packageName.replace('@0xproject/', '');
const changelogJSONPath = path.join( const changelogJSONPath = path.join(
constants.monorepoRootPath, constants.monorepoRootPath,
@@ -122,7 +121,11 @@ export const postpublishUtils = {
const changelogJSON = fs.readFileSync(changelogJSONPath, 'utf-8'); const changelogJSON = fs.readFileSync(changelogJSONPath, 'utf-8');
const changelogs = JSON.parse(changelogJSON); const changelogs = JSON.parse(changelogJSON);
const latestLog = changelogs[0]; const latestLog = changelogs[0];
if (_.isUndefined(latestLog.isPublished)) { // We sanity check that the version for the changelog notes we are about to publish to Github
// correspond to the new version of the package.
if (version !== latestLog.version) {
throw new Error('Expected CHANGELOG.json latest entry version to coincide with published version.');
}
let notes = ''; let notes = '';
_.each(latestLog.changes, change => { _.each(latestLog.changes, change => {
notes += `* ${change.note}`; notes += `* ${change.note}`;
@@ -132,23 +135,6 @@ export const postpublishUtils = {
notes += `\n`; notes += `\n`;
}); });
return notes; return notes;
}
return 'N/A';
},
updateChangelogIsPublished(packageName: string) {
const packageNameWithNamespace = packageName.replace('@0xproject/', '');
const changelogJSONPath = path.join(
constants.monorepoRootPath,
'packages',
packageNameWithNamespace,
'CHANGELOG.json',
);
const changelogJSON = fs.readFileSync(changelogJSONPath, 'utf-8');
const changelogs = JSON.parse(changelogJSON);
const latestLog = changelogs[0];
latestLog.isPublished = true;
changelogs[0] = latestLog;
fs.writeFileSync(changelogJSONPath, JSON.stringify(changelogs, null, '\t'));
}, },
getTag(packageName: string, version: string) { getTag(packageName: string, version: string) {
return `${packageName}@${version}`; return `${packageName}@${version}`;

View File

@@ -1,18 +1,23 @@
#!/usr/bin/env node #!/usr/bin/env node
import * as promisify from 'es6-promisify';
import * as fs from 'fs'; import * as fs from 'fs';
import lernaGetPackages = require('lerna-get-packages'); import lernaGetPackages = require('lerna-get-packages');
import * as _ from 'lodash'; import * as _ from 'lodash';
import * as moment from 'moment'; import * as moment from 'moment';
import opn = require('opn');
import * as path from 'path'; import * as path from 'path';
import { exec as execAsync, spawn } from 'promisify-child-process'; import { exec as execAsync, spawn } from 'promisify-child-process';
import * as prompt from 'prompt';
import semverDiff = require('semver-diff'); import semverDiff = require('semver-diff');
import semverSort = require('semver-sort'); import semverSort = require('semver-sort');
import { constants } from './constants'; import { constants } from './constants';
import { Changelog, Changes, SemVerIndex, UpdatedPackage } from './types'; import { Changelog, Changes, PackageToVersionChange, SemVerIndex, UpdatedPackage } from './types';
import { utils } from './utils'; import { utils } from './utils';
const DOC_GEN_COMMAND = 'docs:json';
const NPM_NAMESPACE = '@0xproject/';
const IS_DRY_RUN = process.env.IS_DRY_RUN === 'true'; const IS_DRY_RUN = process.env.IS_DRY_RUN === 'true';
const TODAYS_TIMESTAMP = moment().unix(); const TODAYS_TIMESTAMP = moment().unix();
const LERNA_EXECUTABLE = './node_modules/lerna/bin/lerna.js'; const LERNA_EXECUTABLE = './node_modules/lerna/bin/lerna.js';
@@ -21,8 +26,95 @@ const semverNameToIndex: { [semver: string]: number } = {
minor: SemVerIndex.Minor, minor: SemVerIndex.Minor,
major: SemVerIndex.Major, major: SemVerIndex.Major,
}; };
const packageNameToWebsitePath: { [name: string]: string } = {
'0x.js': '0xjs',
'web3-wrapper': 'web3_wrapper',
contracts: 'contracts',
connect: 'connect',
'json-schemas': 'json-schemas',
deployer: 'deployer',
'sol-cov': 'sol-cov',
subproviders: 'subproviders',
};
(async () => { (async () => {
// Fetch public, updated Lerna packages
const updatedPublicLernaPackages = await getUpdatedPublicLernaPackagesAsync();
await confirmDocPagesRenderAsync(updatedPublicLernaPackages);
// Update CHANGELOGs
const updatedPublicLernaPackageNames = _.map(updatedPublicLernaPackages, pkg => pkg.package.name);
utils.log(`Will update CHANGELOGs and publish: \n${updatedPublicLernaPackageNames.join('\n')}\n`);
const packageToVersionChange = await updateChangeLogsAsync(updatedPublicLernaPackages);
// Push changelog changes to Github
if (!IS_DRY_RUN) {
await pushChangelogsToGithubAsync();
}
// Call LernaPublish
utils.log('Version updates to apply:');
_.each(packageToVersionChange, (versionChange: string, packageName: string) => {
utils.log(`${packageName} -> ${versionChange}`);
});
utils.log(`Calling 'lerna publish'...`);
await lernaPublishAsync(packageToVersionChange);
})().catch(err => {
utils.log(err);
process.exit(1);
});
async function confirmDocPagesRenderAsync(packages: LernaPackage[]) {
// push docs to staging
utils.log("Upload all docJson's to S3 staging...");
await execAsync(`yarn lerna:stage_docs`, { cwd: constants.monorepoRootPath });
// deploy website to staging
utils.log('Deploy website to staging...');
const pathToWebsite = `${constants.monorepoRootPath}/packages/website`;
await execAsync(`yarn deploy_staging`, { cwd: pathToWebsite });
const packagesWithDocs = _.filter(packages, pkg => {
const scriptsIfExists = pkg.package.scripts;
if (_.isUndefined(scriptsIfExists)) {
throw new Error('Found a public package without any scripts in package.json');
}
return !_.isUndefined(scriptsIfExists[DOC_GEN_COMMAND]);
});
_.each(packagesWithDocs, pkg => {
const name = pkg.package.name;
const nameWithoutPrefix = _.startsWith(name, NPM_NAMESPACE) ? name.split('@0xproject/')[1] : name;
const docSegmentIfExists = packageNameToWebsitePath[nameWithoutPrefix];
if (_.isUndefined(docSegmentIfExists)) {
throw new Error(
`Found package '${name}' with doc commands but no corresponding docSegment in monorepo_scripts
package.ts. Please add an entry for it and try again.`,
);
}
const link = `${constants.stagingWebsite}/docs/${docSegmentIfExists}`;
// tslint:disable-next-line:no-floating-promises
opn(link);
});
prompt.start();
const message = 'Do all the doc pages render properly? (yn)';
const result = await promisify(prompt.get)([message]);
const didConfirm = result[message] === 'y';
if (!didConfirm) {
utils.log('Publish process aborted.');
process.exit(0);
}
}
async function pushChangelogsToGithubAsync() {
await execAsync(`git add . --all`, { cwd: constants.monorepoRootPath });
await execAsync(`git commit -m "Updated CHANGELOGS"`, { cwd: constants.monorepoRootPath });
await execAsync(`git push`, { cwd: constants.monorepoRootPath });
utils.log(`Pushed CHANGELOG updates to Github`);
}
async function getUpdatedPublicLernaPackagesAsync(): Promise<LernaPackage[]> {
const updatedPublicPackages = await getPublicLernaUpdatedPackagesAsync(); const updatedPublicPackages = await getPublicLernaUpdatedPackagesAsync();
const updatedPackageNames = _.map(updatedPublicPackages, pkg => pkg.name); const updatedPackageNames = _.map(updatedPublicPackages, pkg => pkg.name);
@@ -30,10 +122,11 @@ const semverNameToIndex: { [semver: string]: number } = {
const updatedPublicLernaPackages = _.filter(allLernaPackages, pkg => { const updatedPublicLernaPackages = _.filter(allLernaPackages, pkg => {
return _.includes(updatedPackageNames, pkg.package.name); return _.includes(updatedPackageNames, pkg.package.name);
}); });
const updatedPublicLernaPackageNames = _.map(updatedPublicLernaPackages, pkg => pkg.package.name); return updatedPublicLernaPackages;
utils.log(`Will update CHANGELOGs and publish: \n${updatedPublicLernaPackageNames.join('\n')}\n`); }
const packageToVersionChange: { [name: string]: string } = {}; async function updateChangeLogsAsync(updatedPublicLernaPackages: LernaPackage[]): Promise<PackageToVersionChange> {
const packageToVersionChange: PackageToVersionChange = {};
for (const lernaPackage of updatedPublicLernaPackages) { for (const lernaPackage of updatedPublicLernaPackages) {
const packageName = lernaPackage.package.name; const packageName = lernaPackage.package.name;
const changelogJSONPath = path.join(lernaPackage.location, 'CHANGELOG.json'); const changelogJSONPath = path.join(lernaPackage.location, 'CHANGELOG.json');
@@ -48,7 +141,7 @@ const semverNameToIndex: { [semver: string]: number } = {
} }
const currentVersion = lernaPackage.package.version; const currentVersion = lernaPackage.package.version;
const shouldAddNewEntry = shouldAddNewChangelogEntry(changelogs); const shouldAddNewEntry = shouldAddNewChangelogEntry(currentVersion, changelogs);
if (shouldAddNewEntry) { if (shouldAddNewEntry) {
// Create a new entry for a patch version with generic changelog entry. // Create a new entry for a patch version with generic changelog entry.
const nextPatchVersion = utils.getNextPatchVersion(currentVersion); const nextPatchVersion = utils.getNextPatchVersion(currentVersion);
@@ -88,23 +181,8 @@ const semverNameToIndex: { [semver: string]: number } = {
utils.log(`${packageName}: Updated CHANGELOG.md`); utils.log(`${packageName}: Updated CHANGELOG.md`);
} }
if (!IS_DRY_RUN) { return packageToVersionChange;
await execAsync(`git add . --all`, { cwd: constants.monorepoRootPath }); }
await execAsync(`git commit -m "Updated CHANGELOGS"`, { cwd: constants.monorepoRootPath });
await execAsync(`git push`, { cwd: constants.monorepoRootPath });
utils.log(`Pushed CHANGELOG updates to Github`);
}
utils.log('Version updates to apply:');
_.each(packageToVersionChange, (versionChange: string, packageName: string) => {
utils.log(`${packageName} -> ${versionChange}`);
});
utils.log(`Calling 'lerna publish'...`);
await lernaPublishAsync(packageToVersionChange);
})().catch(err => {
utils.log(err);
process.exit(1);
});
async function lernaPublishAsync(packageToVersionChange: { [name: string]: string }) { async function lernaPublishAsync(packageToVersionChange: { [name: string]: string }) {
// HACK: Lerna publish does not provide a way to specify multiple package versions via // HACK: Lerna publish does not provide a way to specify multiple package versions via
@@ -174,12 +252,13 @@ function getChangelogJSONOrCreateIfMissing(packageName: string, changelogPath: s
} }
} }
function shouldAddNewChangelogEntry(changelogs: Changelog[]): boolean { function shouldAddNewChangelogEntry(currentVersion: string, changelogs: Changelog[]): boolean {
if (_.isEmpty(changelogs)) { if (_.isEmpty(changelogs)) {
return true; return true;
} }
const lastEntry = changelogs[0]; const lastEntry = changelogs[0];
return !!lastEntry.isPublished; const lastEntryCurrentVersion = lastEntry.version === currentVersion;
return lastEntryCurrentVersion;
} }
function generateChangelogMd(changelogs: Changelog[]): string { function generateChangelogMd(changelogs: Changelog[]): string {

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