Compare commits

..

70 Commits

Author SHA1 Message Date
Leonid Logvinov
a824264da2 Publish
- 0x.js@2.0.3
 - @0x/abi-gen-wrappers@1.0.4
 - @0x/asset-buyer@2.2.2
 - @0x/base-contract@3.0.5
 - @0x/connect@3.0.5
 - @0x/contract-wrappers@4.0.1
 - contracts@2.1.53
 - @0x/dev-tools-pages@0.0.5
 - @0x/dev-utils@1.0.16
 - @0x/fill-scenarios@1.0.11
 - @0x/instant@0.0.6
 - @0x/metacoin@0.0.27
 - @0x/migrations@2.0.3
 - @0x/order-utils@3.0.1
 - @0x/order-watcher@2.2.3
 - @0x/react-docs@1.0.17
 - @0x/react-shared@1.0.20
 - @0x/sol-compiler@1.1.11
 - @0x/sol-cov@2.1.11
 - @0x/sol-doc@1.0.6
 - @0x/subproviders@2.1.3
 - @0x/testnet-faucets@1.0.55
 - @0x/web3-wrapper@3.1.3
 - @0x/website@0.0.58
2018-11-13 19:41:43 +01:00
Leonid Logvinov
a66c03aa21 Updated CHANGELOGS 2018-11-13 19:41:25 +01:00
Leonid Logvinov
11f0bebd7f Fix a bug when undefined was been tried to convert to an array 2018-11-13 19:27:44 +01:00
Fabio B
3fb29041b0 Merge pull request #1248 from 0xProject/fixLowercaseAddressBug
Fix lowercase address bug in LedgerSubprovider and MnemonicSubprovider
2018-11-13 15:03:30 +01:00
Brandon Millman
161a935003 Merge pull request #1251 from 0xProject/feature/instant/asset-data-map
[instant] Add extra asset metadata
2018-11-12 21:48:34 -08:00
Brandon Millman
b82148ea60 feat(instant): add extra asset metadata 2018-11-12 13:26:09 -08:00
Fabio B
add1cfd261 Merge pull request #1227 from WyseNynja/patch-1
[web3-wrapper] start jsonRpcRequestId at 1, not 0
2018-11-12 20:43:00 +01:00
Bryan Stitt
cdf78494d5 Update CHANGELOG.json 2018-11-12 09:12:59 -08:00
Bryan Stitt
789f573452 Merge branch 'development' into patch-1 2018-11-12 09:10:40 -08:00
Bryan Stitt
22f217807d Update CHANGELOG.json 2018-11-12 09:08:23 -08:00
Fabio B
08797392e0 Update packages/order-watcher/CHANGELOG.json
Co-Authored-By: WyseNynja <bryan@stitthappens.com>
2018-11-12 09:08:02 -08:00
Leonid Logvinov
853c77dc09 Update packages/order-watcher/CHANGELOG.json
Co-Authored-By: WyseNynja <bryan@stitthappens.com>
2018-11-12 09:07:54 -08:00
Leonid Logvinov
0ebbbdfca4 Publish
- 0x.js@2.0.2
 - @0x/abi-gen-wrappers@1.0.3
 - @0x/assert@1.0.16
 - @0x/asset-buyer@2.2.1
 - @0x/base-contract@3.0.4
 - @0x/connect@3.0.4
 - @0x/contract-wrappers@4.0.0
 - contracts@2.1.52
 - @0x/dev-tools-pages@0.0.4
 - @0x/dev-utils@1.0.15
 - @0x/fill-scenarios@1.0.10
 - @0x/instant@0.0.5
 - @0x/json-schemas@2.1.0
 - @0x/metacoin@0.0.26
 - @0x/migrations@2.0.2
 - @0x/order-utils@3.0.0
 - @0x/order-watcher@2.2.2
 - @0x/react-docs@1.0.16
 - @0x/react-shared@1.0.19
 - @0x/sol-compiler@1.1.10
 - @0x/sol-cov@2.1.10
 - @0x/sol-doc@1.0.5
 - @0x/sra-spec@1.0.9
 - @0x/subproviders@2.1.2
 - @0x/testnet-faucets@1.0.54
 - @0x/web3-wrapper@3.1.2
 - @0x/website@0.0.57
2018-11-12 14:30:26 +01:00
Leonid Logvinov
085d34834b Updated CHANGELOGS 2018-11-12 14:30:14 +01:00
Leonid Logvinov
b866ce787c Merge pull request #1250 from 0xProject/feature/json-schemas-connect
Move @0x/connect schemas to @0x/json-schemas
2018-11-12 14:04:28 +01:00
Leonid Logvinov
4d5bc8b8ee Fix static tests 2018-11-12 13:54:38 +01:00
Leonid Logvinov
7f013515e7 Add PR number 2018-11-12 13:53:39 +01:00
Leonid Logvinov
33dbdb0184 Move connect schemas to JSON Schemas 2018-11-12 13:44:24 +01:00
Fabio Berger
320460feb9 fix: lowercase supplied address before comparing with derived addresses (which are not checksummed) 2018-11-12 13:21:25 +01:00
Fabio Berger
dbce3f8935 Remove unused instance variable 2018-11-12 13:20:41 +01:00
Fabio B
c41622c20a Merge pull request #1235 from 0xProject/fixOrderValidation
[order-utils] Fix order validation method
2018-11-12 12:17:27 +01:00
Fabio Berger
348556a544 Add fixes affecting the public interface to the CHANGELOGs 2018-11-12 12:07:19 +01:00
Fabio Berger
6fa6579c31 Use correctly formatted signature so that it rejects with the expected reason and not because the signature is mal-formatted 2018-11-12 11:57:54 +01:00
Fabio B
6f61268514 Merge pull request #1246 from 0xProject/bug/web3-wrapper/eth-call-null
[web3-wrapper] Throws when contract returns null
2018-11-12 10:42:28 +01:00
Fabio Berger
8efc6c2112 Remove unnecessary conversion to BigNumber 2018-11-12 10:25:33 +01:00
Fabio Berger
b21c1bea46 Use rejectedWith 2018-11-12 10:23:42 +01:00
Fabio Berger
fd7ba3ecea Use RevertReason when possible 2018-11-12 10:22:22 +01:00
Fabio Berger
8aeb18bcc3 rename param 2018-11-12 10:22:03 +01:00
Brandon Millman
9e4a594eb1 Merge pull request #1238 from 0xProject/fix/website/code-splitting
[website] Fix code splitting
2018-11-11 21:21:36 -08:00
Brandon Millman
3b421ef796 fix(website): fix code splitting 2018-11-11 20:58:47 -08:00
Jacob Evans
e0c4f58970 bug(web3-wrapper): throws when contract returns null 2018-11-12 13:55:46 +11:00
Amir Bandeali
df8fd36c94 Merge pull request #1241 from 0xProject/feature/contracts/changelogs
Add CHANGELOG.json to contracts package
2018-11-11 15:57:21 -08:00
Bryan Stitt
76b3caa124 Update CHANGELOG.json 2018-11-11 15:13:42 -08:00
Bryan Stitt
0101cd73aa Merge branch 'development' into patch-1 2018-11-11 15:13:09 -08:00
Bryan Stitt
6ef628613e update changelog 2018-11-11 15:09:59 -08:00
Amir Bandeali
bc960fe8f8 Add CHANGELOG comment to README 2018-11-11 14:57:24 -08:00
Amir Bandeali
517c620397 Add CHANGELOG.json 2018-11-11 14:57:24 -08:00
Fabio Berger
d3592d362e address linter errors 2018-11-11 13:02:45 +01:00
Brandon Millman
397b4e2890 Merge pull request #1239 from 0xProject/feature/instant/privacy-mode
[instant] Handle privacy mode in wallets
2018-11-09 16:21:32 -08:00
Brandon Millman
38896c9358 feat(instant): handle privacy mode in wallets 2018-11-09 16:04:29 -08:00
Steve Klebanoff
26cbe7ae66 Merge pull request #1237 from 0xProject/feature/instant/buy-quote-heartbeat
[instant] Heartbeats for account info and buy quotes
2018-11-09 16:02:09 -08:00
Steve Klebanoff
fd83ca2cb8 linting 2018-11-09 15:52:25 -08:00
Steve Klebanoff
4072076965 Don't start heartbeat if no account 2018-11-09 15:40:13 -08:00
Steve Klebanoff
93054ae52b Lodash noop 2018-11-09 15:28:29 -08:00
Steve Klebanoff
5c1b1a1203 Using built in intervalUtils instead of rolling own 2018-11-09 15:28:08 -08:00
Steve Klebanoff
acb7e876b2 Update account more frequently 2018-11-09 15:19:16 -08:00
Steve Klebanoff
2c585bfbdc feat(instant): Dismissible overlay error messages
Adds dismissible overlay to error messages on mobile
2018-11-09 15:15:57 -08:00
Fabio Berger
1f0ac47bd9 Move signature validation into OrderValidationUtils.validateOrderFillableOrThrowAsync 2018-11-10 00:14:48 +01:00
Fabio Berger
773cf3cd14 Merge branch 'development' into fixOrderValidation
* development: (25 commits)
  Publish
  Updated CHANGELOGS
  fix(instant): fix bug where we potentially fetch balance for the wrong account
  fix: Lock Ledger hw-transport to 4.24.0
  fix: wrong prop names used
  chore: PR feedback
  fix: broken features because of merge
  fix: remove default props, fix lint problems
  chore: convert payment method to stateless component
  feat: add boxShadow on dropdown hover
  fix: various style issues
  fix: remove all:initial rule from all div based ui compoennts
  fix: token selector scrolling container height
  chore(instant): fix lint errors
  feat(instant): fetch balance at startup
  feat(instant): fetch account address at startup and drive account state changes
  chore: cleanup
  fix: restore button to previous state
  feat: implement copy-to-clipboard
  feat: add MetaMask sign, refactor Circle
  ...
2018-11-09 23:20:06 +01:00
Fabio Berger
53d0f5b98e Revert comment change 2018-11-09 23:15:34 +01:00
Steve Klebanoff
cc8debe53b Linting and renaming variables 2018-11-09 11:39:36 -08:00
Steve Klebanoff
36b8c9c5dd Use interface like named parameters here 2018-11-09 11:28:08 -08:00
Steve Klebanoff
474db7c18d Emulate named parameters with interface 2018-11-09 11:22:46 -08:00
Steve Klebanoff
39657b633b Make sure we only update price when they are not in the middle of an order 2018-11-09 11:04:44 -08:00
Steve Klebanoff
2e8f74abce Use existing functions instead of writing our own 2018-11-09 10:40:47 -08:00
Steve Klebanoff
df91d34315 Merge branch 'development' into feature/instant/buy-quote-heartbeat 2018-11-09 10:06:22 -08:00
Fabio Berger
3980bf39a9 Keep more helpful error messages, and stop swallowing errors when returning contract error 2018-11-09 18:50:25 +01:00
Steve Klebanoff
d703c13f8e Variable name cleanup 2018-11-08 17:21:17 -08:00
Steve Klebanoff
3dacc6157b Remove unneeded Promise.resolve 2018-11-08 17:20:15 -08:00
Steve Klebanoff
fd12bdbbd5 Remove old TODO 2018-11-08 17:13:33 -08:00
Steve Klebanoff
297a62fe80 move files around and rename 2018-11-08 17:13:22 -08:00
Steve Klebanoff
1e39d56cf7 wip: BuyQuote heartbeat 2018-11-08 17:09:26 -08:00
Steve Klebanoff
e45b6c7e98 Make heartbeat more generic 2018-11-08 16:54:45 -08:00
Steve Klebanoff
dd4d3b10cf wip: abstract out updating buy quote 2018-11-08 16:14:00 -08:00
Fabio Berger
eb5f514d25 Merge branch 'development' into fixOrderValidation
* development: (51 commits)
  [instant] Viewport specific errors (#1228)
  Added more comments
  Include wholeNumberSchema in sra-spec schemas
  chore(instant): fix linter
  Fix isNode
  fix(instant): update buy quote at start up in the case of default amount
  chore(instant): increase max bundle size for bundle watch
  Small code review tweaks
  fix: apply css reset to overlay as well
  fix(website): turn off production flag when building locally
  feat(instant): add Account to the ProviderState
  feat(instant): fallback to an empty wallet provider when none is injected
  [order_utils.py] is_signature_valid, via Exchange contract (#1216)
  chore: linter
  fix: progress bar
  fix: use fontSize prop in button
  feat: make instant resistant to external styles
  chore(instant): update OrderState enum to follow capitalization conventions
  feat: add faux externall css file
  Take out unneeded conditionals
  ...
2018-11-09 00:46:32 +01:00
Fabio Berger
57318a6ef2 Remove unused validateFillOrKill method 2018-11-09 00:46:07 +01:00
Fabio Berger
857a35d4f7 Fix validateOrderFillableOrThrowAsync method so it also checks order signature, cancelled, cancelledUpTo, and throws helpful error messages 2018-11-09 00:45:48 +01:00
Steve Klebanoff
624f5cee8d linting 2018-11-08 15:01:59 -08:00
Steve Klebanoff
7acaae37a9 feat(instant): Heartbeat for updating account info 2018-11-08 14:57:39 -08:00
Bryan Stitt
801004be66 start jsonRpcRequestId at 1, not 0
I'm trying to use the 0x-watcher against a parity websocket rpc and getting an error that I think is the same as https://github.com/ethereum/web3.js/issues/1967
2018-11-07 16:39:07 -08:00
144 changed files with 1424 additions and 476 deletions

View File

@@ -1,4 +1,22 @@
[
{
"timestamp": 1542134075,
"version": "2.0.3",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1542028948,
"version": "2.0.2",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "2.0.1",
"changes": [

View File

@@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v2.0.3 - _November 13, 2018_
* Dependencies updated
## v2.0.2 - _November 12, 2018_
* Dependencies updated
## v2.0.1 - _November 9, 2018_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "0x.js",
"version": "2.0.1",
"version": "2.0.3",
"engines": {
"node": ">=6.12"
},
@@ -43,10 +43,10 @@
"license": "Apache-2.0",
"devDependencies": {
"@0x/abi-gen": "^1.0.15",
"@0x/abi-gen-wrappers": "^1.0.2",
"@0x/abi-gen-wrappers": "^1.0.4",
"@0x/contract-addresses": "^1.1.0",
"@0x/dev-utils": "^1.0.14",
"@0x/migrations": "^2.0.1",
"@0x/dev-utils": "^1.0.16",
"@0x/migrations": "^2.0.3",
"@0x/tslint-config": "^1.0.10",
"@types/lodash": "4.14.104",
"@types/mocha": "^2.2.42",
@@ -73,16 +73,16 @@
"webpack": "^4.20.2"
},
"dependencies": {
"@0x/assert": "^1.0.15",
"@0x/base-contract": "^3.0.3",
"@0x/contract-wrappers": "^3.0.1",
"@0x/order-utils": "^2.0.1",
"@0x/order-watcher": "^2.2.1",
"@0x/subproviders": "^2.1.1",
"@0x/assert": "^1.0.16",
"@0x/base-contract": "^3.0.5",
"@0x/contract-wrappers": "^4.0.1",
"@0x/order-utils": "^3.0.1",
"@0x/order-watcher": "^2.2.3",
"@0x/subproviders": "^2.1.3",
"@0x/types": "^1.2.1",
"@0x/typescript-typings": "^3.0.4",
"@0x/utils": "^2.0.4",
"@0x/web3-wrapper": "^3.1.1",
"@0x/web3-wrapper": "^3.1.3",
"@types/web3-provider-engine": "^14.0.0",
"ethereum-types": "^1.1.2",
"ethers": "~4.0.4",

View File

@@ -1,4 +1,22 @@
[
{
"timestamp": 1542134075,
"version": "1.0.4",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1542028948,
"version": "1.0.3",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "1.0.2",
"changes": [

View File

@@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v1.0.4 - _November 13, 2018_
* Dependencies updated
## v1.0.3 - _November 12, 2018_
* Dependencies updated
## v1.0.2 - _November 9, 2018_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/abi-gen-wrappers",
"version": "1.0.2",
"version": "1.0.4",
"engines": {
"node": ">=6.12"
},
@@ -33,14 +33,14 @@
"@0x/abi-gen": "^1.0.15",
"@0x/tslint-config": "^1.0.10",
"@0x/utils": "^2.0.4",
"@0x/web3-wrapper": "^3.1.1",
"@0x/web3-wrapper": "^3.1.3",
"ethereum-types": "^1.1.2",
"ethers": "~4.0.4",
"lodash": "^4.17.5",
"shx": "^0.2.2"
},
"dependencies": {
"@0x/base-contract": "^3.0.3"
"@0x/base-contract": "^3.0.5"
},
"publishConfig": {
"access": "public"

View File

@@ -1,4 +1,13 @@
[
{
"timestamp": 1542028948,
"version": "1.0.16",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "1.0.15",
"changes": [

View File

@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v1.0.16 - _November 12, 2018_
* Dependencies updated
## v1.0.15 - _November 9, 2018_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/assert",
"version": "1.0.15",
"version": "1.0.16",
"engines": {
"node": ">=6.12"
},
@@ -44,7 +44,7 @@
"typescript": "3.0.1"
},
"dependencies": {
"@0x/json-schemas": "^2.0.1",
"@0x/json-schemas": "^2.1.0",
"@0x/typescript-typings": "^3.0.4",
"@0x/utils": "^2.0.4",
"lodash": "^4.17.5",

View File

@@ -1,4 +1,22 @@
[
{
"timestamp": 1542134075,
"version": "2.2.2",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1542028948,
"version": "2.2.1",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "2.2.0",
"changes": [

View File

@@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v2.2.2 - _November 13, 2018_
* Dependencies updated
## v2.2.1 - _November 12, 2018_
* Dependencies updated
## v2.2.0 - _November 9, 2018_
* `getAssetBuyerForProvidedOrders` factory function now takes 3 args instead of 4 (#1187)

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/asset-buyer",
"version": "2.2.0",
"version": "2.2.2",
"engines": {
"node": ">=6.12"
},
@@ -36,16 +36,16 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/packages/asset-buyer/README.md",
"dependencies": {
"@0x/assert": "^1.0.15",
"@0x/connect": "^3.0.3",
"@0x/contract-wrappers": "^3.0.1",
"@0x/json-schemas": "^2.0.1",
"@0x/order-utils": "^2.0.1",
"@0x/subproviders": "^2.1.1",
"@0x/assert": "^1.0.16",
"@0x/connect": "^3.0.5",
"@0x/contract-wrappers": "^4.0.1",
"@0x/json-schemas": "^2.1.0",
"@0x/order-utils": "^3.0.1",
"@0x/subproviders": "^2.1.3",
"@0x/types": "^1.2.1",
"@0x/typescript-typings": "^3.0.4",
"@0x/utils": "^2.0.4",
"@0x/web3-wrapper": "^3.1.1",
"@0x/web3-wrapper": "^3.1.3",
"ethereum-types": "^1.1.2",
"lodash": "^4.17.10"
},

View File

@@ -1,4 +1,22 @@
[
{
"timestamp": 1542134075,
"version": "3.0.5",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1542028948,
"version": "3.0.4",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "3.0.3",
"changes": [

View File

@@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v3.0.5 - _November 13, 2018_
* Dependencies updated
## v3.0.4 - _November 12, 2018_
* Dependencies updated
## v3.0.3 - _November 9, 2018_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/base-contract",
"version": "3.0.3",
"version": "3.0.5",
"engines": {
"node": ">=6.12"
},
@@ -42,7 +42,7 @@
"dependencies": {
"@0x/typescript-typings": "^3.0.4",
"@0x/utils": "^2.0.4",
"@0x/web3-wrapper": "^3.1.1",
"@0x/web3-wrapper": "^3.1.3",
"ethereum-types": "^1.1.2",
"ethers": "~4.0.4",
"lodash": "^4.17.5"

View File

@@ -1,4 +1,22 @@
[
{
"timestamp": 1542134075,
"version": "3.0.5",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1542028948,
"version": "3.0.4",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "3.0.3",
"changes": [

View File

@@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v3.0.5 - _November 13, 2018_
* Dependencies updated
## v3.0.4 - _November 12, 2018_
* Dependencies updated
## v3.0.3 - _November 9, 2018_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/connect",
"version": "3.0.3",
"version": "3.0.5",
"engines": {
"node": ">=6.12"
},
@@ -44,9 +44,9 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/packages/connect/README.md",
"dependencies": {
"@0x/assert": "^1.0.15",
"@0x/json-schemas": "^2.0.1",
"@0x/order-utils": "^2.0.1",
"@0x/assert": "^1.0.16",
"@0x/json-schemas": "^2.1.0",
"@0x/order-utils": "^3.0.1",
"@0x/types": "^1.2.1",
"@0x/typescript-typings": "^3.0.4",
"@0x/utils": "^2.0.4",

View File

@@ -19,7 +19,6 @@ import { fetchAsync } from '@0x/utils';
import * as _ from 'lodash';
import * as queryString from 'query-string';
import { schemas as clientSchemas } from './schemas/schemas';
import { Client, HttpRequestOptions, HttpRequestType } from './types';
import { relayerResponseJsonParsers } from './utils/relayer_response_json_parsers';
@@ -61,9 +60,9 @@ export class HttpClient implements Client {
requestOpts?: RequestOpts & AssetPairsRequestOpts & PagedRequestOpts,
): Promise<AssetPairsResponse> {
if (!_.isUndefined(requestOpts)) {
assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.assetPairsRequestOptsSchema);
assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.pagedRequestOptsSchema);
assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.requestOptsSchema);
assert.doesConformToSchema('requestOpts', requestOpts, schemas.assetPairsRequestOptsSchema);
assert.doesConformToSchema('requestOpts', requestOpts, schemas.pagedRequestOptsSchema);
assert.doesConformToSchema('requestOpts', requestOpts, schemas.requestOptsSchema);
}
const httpRequestOpts = {
params: requestOpts,
@@ -81,9 +80,9 @@ export class HttpClient implements Client {
requestOpts?: RequestOpts & OrdersRequestOpts & PagedRequestOpts,
): Promise<OrdersResponse> {
if (!_.isUndefined(requestOpts)) {
assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.ordersRequestOptsSchema);
assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.pagedRequestOptsSchema);
assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.requestOptsSchema);
assert.doesConformToSchema('requestOpts', requestOpts, schemas.ordersRequestOptsSchema);
assert.doesConformToSchema('requestOpts', requestOpts, schemas.pagedRequestOptsSchema);
assert.doesConformToSchema('requestOpts', requestOpts, schemas.requestOptsSchema);
}
const httpRequestOpts = {
params: requestOpts,
@@ -99,7 +98,7 @@ export class HttpClient implements Client {
*/
public async getOrderAsync(orderHash: string, requestOpts?: RequestOpts): Promise<APIOrder> {
if (!_.isUndefined(requestOpts)) {
assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.requestOptsSchema);
assert.doesConformToSchema('requestOpts', requestOpts, schemas.requestOptsSchema);
}
assert.doesConformToSchema('orderHash', orderHash, schemas.orderHashSchema);
const httpRequestOpts = {
@@ -119,10 +118,10 @@ export class HttpClient implements Client {
request: OrderbookRequest,
requestOpts?: RequestOpts & PagedRequestOpts,
): Promise<OrderbookResponse> {
assert.doesConformToSchema('request', request, clientSchemas.orderBookRequestSchema);
assert.doesConformToSchema('request', request, schemas.orderBookRequestSchema);
if (!_.isUndefined(requestOpts)) {
assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.pagedRequestOptsSchema);
assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.requestOptsSchema);
assert.doesConformToSchema('requestOpts', requestOpts, schemas.pagedRequestOptsSchema);
assert.doesConformToSchema('requestOpts', requestOpts, schemas.requestOptsSchema);
}
const httpRequestOpts = {
params: _.defaults({}, request, requestOpts),
@@ -142,9 +141,9 @@ export class HttpClient implements Client {
requestOpts?: RequestOpts,
): Promise<OrderConfigResponse> {
if (!_.isUndefined(requestOpts)) {
assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.requestOptsSchema);
assert.doesConformToSchema('requestOpts', requestOpts, schemas.requestOptsSchema);
}
assert.doesConformToSchema('request', request, clientSchemas.orderConfigRequestSchema);
assert.doesConformToSchema('request', request, schemas.orderConfigRequestSchema);
const httpRequestOpts = {
params: requestOpts,
payload: request,
@@ -160,8 +159,8 @@ export class HttpClient implements Client {
*/
public async getFeeRecipientsAsync(requestOpts?: RequestOpts & PagedRequestOpts): Promise<FeeRecipientsResponse> {
if (!_.isUndefined(requestOpts)) {
assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.pagedRequestOptsSchema);
assert.doesConformToSchema('requestOpts', requestOpts, clientSchemas.requestOptsSchema);
assert.doesConformToSchema('requestOpts', requestOpts, schemas.pagedRequestOptsSchema);
assert.doesConformToSchema('requestOpts', requestOpts, schemas.requestOptsSchema);
}
const httpRequestOpts = {
params: requestOpts,

View File

@@ -1,8 +0,0 @@
export const assetPairsRequestOptsSchema = {
id: '/AssetPairsRequestOpts',
type: 'object',
properties: {
assetDataA: { $ref: '/hexSchema' },
assetDataB: { $ref: '/hexSchema' },
},
};

View File

@@ -1,24 +0,0 @@
export const orderConfigRequestSchema = {
id: '/OrderConfigRequest',
type: 'object',
properties: {
makerAddress: { $ref: '/addressSchema' },
takerAddress: { $ref: '/addressSchema' },
makerAssetAmount: { $ref: '/numberSchema' },
takerAssetAmount: { $ref: '/numberSchema' },
makerAssetData: { $ref: '/hexSchema' },
takerAssetData: { $ref: '/hexSchema' },
exchangeAddress: { $ref: '/addressSchema' },
expirationTimeSeconds: { $ref: '/numberSchema' },
},
required: [
'makerAddress',
'takerAddress',
'makerAssetAmount',
'takerAssetAmount',
'makerAssetData',
'takerAssetData',
'exchangeAddress',
'expirationTimeSeconds',
],
};

View File

@@ -1,9 +0,0 @@
export const orderBookRequestSchema = {
id: '/OrderBookRequest',
type: 'object',
properties: {
baseAssetData: { $ref: '/hexSchema' },
quoteAssetData: { $ref: '/hexSchema' },
},
required: ['baseAssetData', 'quoteAssetData'],
};

View File

@@ -1,19 +0,0 @@
export const ordersRequestOptsSchema = {
id: '/OrdersRequestOpts',
type: 'object',
properties: {
makerAssetProxyId: { $ref: '/hexSchema' },
takerAssetProxyId: { $ref: '/hexSchema' },
makerAssetAddress: { $ref: '/addressSchema' },
takerAssetAddress: { $ref: '/addressSchema' },
exchangeAddress: { $ref: '/addressSchema' },
senderAddress: { $ref: '/addressSchema' },
makerAssetData: { $ref: '/hexSchema' },
takerAssetData: { $ref: '/hexSchema' },
traderAssetData: { $ref: '/hexSchema' },
makerAddress: { $ref: '/addressSchema' },
takerAddress: { $ref: '/addressSchema' },
traderAddress: { $ref: '/addressSchema' },
feeRecipientAddress: { $ref: '/addressSchema' },
},
};

View File

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

View File

@@ -1,7 +0,0 @@
export const requestOptsSchema = {
id: '/RequestOpts',
type: 'object',
properties: {
networkId: { type: 'number' },
},
};

View File

@@ -1,15 +0,0 @@
import { assetPairsRequestOptsSchema } from './asset_pairs_request_opts_schema';
import { orderConfigRequestSchema } from './order_config_request_schema';
import { orderBookRequestSchema } from './orderbook_request_schema';
import { ordersRequestOptsSchema } from './orders_request_opts_schema';
import { pagedRequestOptsSchema } from './paged_request_opts_schema';
import { requestOptsSchema } from './request_opts_schema';
export const schemas = {
orderConfigRequestSchema,
orderBookRequestSchema,
ordersRequestOptsSchema,
pagedRequestOptsSchema,
requestOptsSchema,
assetPairsRequestOptsSchema,
};

View File

@@ -1,4 +1,34 @@
[
{
"timestamp": 1542134075,
"version": "4.0.1",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "4.0.0",
"changes": [
{
"note":
"Add signature validation, regular cancellation and `cancelledUpTo` checks to `validateOrderFillableOrThrowAsync`",
"pr": 1235
},
{
"note":
"Improved the errors thrown by `validateOrderFillableOrThrowAsync` by making them more descriptive",
"pr": 1235
},
{
"note":
"Throw previously swallowed network errors when calling `validateOrderFillableOrThrowAsync` (see issue: #1218)",
"pr": 1235
}
],
"timestamp": 1542028948
},
{
"version": "3.0.1",
"changes": [

View File

@@ -5,6 +5,16 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v4.0.1 - _November 13, 2018_
* Dependencies updated
## v4.0.0 - _November 12, 2018_
* Add signature validation, regular cancellation and `cancelledUpTo` checks to `validateOrderFillableOrThrowAsync` (#1235)
* Improved the errors thrown by `validateOrderFillableOrThrowAsync` by making them more descriptive (#1235)
* Throw previously swallowed network errors when calling `validateOrderFillableOrThrowAsync` (see issue: #1218) (#1235)
## v3.0.1 - _November 9, 2018_
* Fix bug in `ForwarderWrapper` where `feeRecipientAddress` was not correctly normalized. (#1178)

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contract-wrappers",
"version": "3.0.1",
"version": "4.0.1",
"description": "Smart TS wrappers for 0x smart contracts",
"keywords": [
"0xproject",
@@ -37,9 +37,9 @@
"node": ">=6.0.0"
},
"devDependencies": {
"@0x/dev-utils": "^1.0.14",
"@0x/migrations": "^2.0.1",
"@0x/subproviders": "^2.1.1",
"@0x/dev-utils": "^1.0.16",
"@0x/migrations": "^2.0.3",
"@0x/subproviders": "^2.1.3",
"@0x/tslint-config": "^1.0.10",
"@types/lodash": "4.14.104",
"@types/mocha": "^2.2.42",
@@ -65,17 +65,17 @@
"web3-provider-engine": "14.0.6"
},
"dependencies": {
"@0x/abi-gen-wrappers": "^1.0.2",
"@0x/assert": "^1.0.15",
"@0x/abi-gen-wrappers": "^1.0.4",
"@0x/assert": "^1.0.16",
"@0x/contract-addresses": "^1.1.0",
"@0x/contract-artifacts": "^1.1.0",
"@0x/fill-scenarios": "^1.0.9",
"@0x/json-schemas": "^2.0.1",
"@0x/order-utils": "^2.0.1",
"@0x/fill-scenarios": "^1.0.11",
"@0x/json-schemas": "^2.1.0",
"@0x/order-utils": "^3.0.1",
"@0x/types": "^1.2.1",
"@0x/typescript-typings": "^3.0.4",
"@0x/utils": "^2.0.4",
"@0x/web3-wrapper": "^3.1.1",
"@0x/web3-wrapper": "^3.1.3",
"ethereum-types": "^1.1.2",
"ethereumjs-blockstream": "6.0.0",
"ethereumjs-util": "^5.1.1",

View File

@@ -18,6 +18,7 @@ import { OrderFilledCancelledFetcher } from '../fetchers/order_filled_cancelled_
import { methodOptsSchema } from '../schemas/method_opts_schema';
import { orderTxOptsSchema } from '../schemas/order_tx_opts_schema';
import { txOptsSchema } from '../schemas/tx_opts_schema';
import { validateOrderFillableOptsSchema } from '../schemas/validate_order_fillable_opts_schema';
import {
BlockRange,
EventCallback,
@@ -1114,6 +1115,9 @@ export class ExchangeWrapper extends ContractWrapper {
signedOrder: SignedOrder,
opts: ValidateOrderFillableOpts = {},
): Promise<void> {
assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema);
assert.doesConformToSchema('opts', opts, validateOrderFillableOptsSchema);
const balanceAllowanceFetcher = new AssetBalanceAndProxyAllowanceFetcher(
this._erc20TokenWrapper,
this._erc721TokenWrapper,
@@ -1124,7 +1128,7 @@ export class ExchangeWrapper extends ContractWrapper {
const expectedFillTakerTokenAmountIfExists = opts.expectedFillTakerTokenAmount;
const filledCancelledFetcher = new OrderFilledCancelledFetcher(this, BlockParamLiteral.Latest);
const orderValidationUtils = new OrderValidationUtils(filledCancelledFetcher);
const orderValidationUtils = new OrderValidationUtils(filledCancelledFetcher, this._web3Wrapper.getProvider());
await orderValidationUtils.validateOrderFillableOrThrowAsync(
exchangeTradeSimulator,
signedOrder,
@@ -1152,7 +1156,7 @@ export class ExchangeWrapper extends ContractWrapper {
const exchangeTradeSimulator = new ExchangeTransferSimulator(balanceAllowanceStore);
const filledCancelledFetcher = new OrderFilledCancelledFetcher(this, BlockParamLiteral.Latest);
const orderValidationUtils = new OrderValidationUtils(filledCancelledFetcher);
const orderValidationUtils = new OrderValidationUtils(filledCancelledFetcher, this._web3Wrapper.getProvider());
await orderValidationUtils.validateFillOrderThrowIfInvalidAsync(
exchangeTradeSimulator,
this._web3Wrapper.getProvider(),

View File

@@ -1,5 +1,6 @@
// tslint:disable:no-unnecessary-type-assertion
import { AbstractOrderFilledCancelledFetcher } from '@0x/order-utils';
import { AbstractOrderFilledCancelledFetcher, orderHashUtils } from '@0x/order-utils';
import { SignedOrder } from '@0x/types';
import { BigNumber } from '@0x/utils';
import { BlockParamLiteral } from 'ethereum-types';
@@ -18,9 +19,18 @@ export class OrderFilledCancelledFetcher implements AbstractOrderFilledCancelled
});
return filledTakerAmount;
}
public async isOrderCancelledAsync(orderHash: string): Promise<boolean> {
public async isOrderCancelledAsync(signedOrder: SignedOrder): Promise<boolean> {
const orderHash = orderHashUtils.getOrderHashHex(signedOrder);
const isCancelled = await this._exchange.isCancelledAsync(orderHash);
return isCancelled;
const orderEpoch = await this._exchange.getOrderEpochAsync(
signedOrder.makerAddress,
signedOrder.senderAddress,
{
defaultBlock: this._stateLayer,
},
);
const isCancelledByOrderEpoch = orderEpoch > signedOrder.salt;
return isCancelled || isCancelledByOrderEpoch;
}
public getZRXAssetData(): string {
const zrxAssetData = this._exchange.getZRXAssetData();

View File

@@ -0,0 +1,7 @@
export const validateOrderFillableOptsSchema = {
id: '/ValidateOrderFillableOpts',
properties: {
expectedFillTakerTokenAmount: { $ref: '/wholeNumberSchema' },
},
type: 'object',
};

View File

@@ -1,7 +1,7 @@
import { BlockchainLifecycle, callbackErrorReporter } from '@0x/dev-utils';
import { FillScenarios } from '@0x/fill-scenarios';
import { assetDataUtils, orderHashUtils } from '@0x/order-utils';
import { DoneCallback, SignedOrder } from '@0x/types';
import { DoneCallback, RevertReason, SignedOrder } from '@0x/types';
import { BigNumber } from '@0x/utils';
import * as chai from 'chai';
import { BlockParamLiteral } from 'ethereum-types';
@@ -282,6 +282,19 @@ describe('ExchangeWrapper', () => {
expect(ordersInfo[1].orderHash).to.be.equal(anotherOrderHash);
});
});
describe('#validateOrderFillableOrThrowAsync', () => {
it('should throw if signature is invalid', async () => {
const signedOrderWithInvalidSignature = {
...signedOrder,
signature:
'0x1b61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc3340349190569279751135161d22529dc25add4f6069af05be04cacbda2ace225403',
};
expect(
contractWrappers.exchange.validateOrderFillableOrThrowAsync(signedOrderWithInvalidSignature),
).to.eventually.to.be.rejectedWith(RevertReason.InvalidOrderSignature);
});
});
describe('#isValidSignature', () => {
it('should check if the signature is valid', async () => {
const orderHash = orderHashUtils.getOrderHashHex(signedOrder);

View File

@@ -0,0 +1,115 @@
[
{
"name": "Forwarder",
"version": "1.1.0",
"changes": [
{
"note": "Round up when calculating remaining amounts in marketBuy functions",
"pr": 1162,
"networks": {
"1": "0x5468a1dc173652ee28d249c271fa9933144746b1",
"3": "0x2240dab907db71e64d3e0dba4800c83b5c502d4e",
"42": "0x17992e4ffb22730138e4b62aaa6367fa9d3699a6"
}
}
]
},
{
"name": "Forwarder",
"version": "1.0.0",
"changes": [
{
"note": "protocol v2 deploy",
"networks": {
"1": "0x7afc2d5107af94c462a194d2c21b5bdd238709d6",
"3": "0x3983e204b12b3c02fb0638caf2cd406a62e0ead3",
"42": "0xd85e2fa7e7e252b27b01bf0d65c946959d2f45b8"
}
}
]
},
{
"name": "OrderValidator",
"version": "1.0.0",
"changes": [
{
"note": "protocol v2 deploy",
"networks": {
"1": "0x9463e518dea6810309563c81d5266c1b1d149138",
"3": "0x90431a90516ab49af23a0530e04e8c7836e7122f",
"42": "0xb389da3d204b412df2f75c6afb3d0a7ce0bc283d"
}
}
]
},
{
"name": "Exchange",
"version": "2.0.0",
"changes": [
{
"note": "protocol v2 deploy",
"networks": {
"1": "0x4f833a24e1f95d70f028921e27040ca56e09ab0b",
"3": "0x4530c0483a1633c7a1c97d2c53721caff2caaaaf",
"42": "0x35dd2932454449b14cee11a94d3674a936d5d7b2"
}
}
]
},
{
"name": "ERC20Proxy",
"version": "1.0.0",
"changes": [
{
"note": "protocol v2 deploy",
"networks": {
"1": "0x2240dab907db71e64d3e0dba4800c83b5c502d4e",
"3": "0xb1408f4c245a23c31b98d2c626777d4c0d766caa",
"42": "0xf1ec01d6236d3cd881a0bf0130ea25fe4234003e"
}
}
]
},
{
"name": "ERC721Proxy",
"version": "1.0.0",
"changes": [
{
"note": "protocol v2 deploy",
"networks": {
"1": "0x208e41fb445f1bb1b6780d58356e81405f3e6127",
"3": "0xe654aac058bfbf9f83fcaee7793311dd82f6ddb4",
"42": "0x2a9127c745688a165106c11cd4d647d2220af821"
}
}
]
},
{
"name": "AssetProxyOwner",
"version": "1.0.0",
"changes": [
{
"note": "protocol v2 deploy",
"networks": {
"1": "0x17992e4ffb22730138e4b62aaa6367fa9d3699a6",
"3": "0xf5fa5b5fed2727a0e44ac67f6772e97977aa358b",
"42": "0x2c824d2882baa668e0d5202b1e7f2922278703f8"
}
}
]
},
{
"name": "ZRXToken",
"version": "1.0.0",
"changes": [
{
"note": "protocol v1 deploy",
"networks": {
"1": "0xe41d2489571d322189246dafa5ebde1f4699f498",
"3": "0xff67881f8d12f372d91baae9752eb3631ff0ed00",
"42": "0x2002d3812f58e35f0ea1ffbf80a75a38c32175fa"
}
}
]
}
]

View File

@@ -1,6 +1,6 @@
## Contracts
Smart contracts that implement the 0x protocol. Addresses of the deployed contracts can be found [here](https://0xproject.com/wiki#Deployed-Addresses).
Smart contracts that implement the 0x protocol. Addresses of the deployed contracts can be found in the 0x [wiki](https://0xproject.com/wiki#Deployed-Addresses) or the [CHANGELOG](./CHANGELOG.json) of this package.
## Usage

View File

@@ -1,7 +1,7 @@
{
"private": true,
"name": "contracts",
"version": "2.1.51",
"version": "2.1.53",
"engines": {
"node": ">=6.12"
},
@@ -46,10 +46,10 @@
"homepage": "https://github.com/0xProject/0x-monorepo/packages/contracts/README.md",
"devDependencies": {
"@0x/abi-gen": "^1.0.15",
"@0x/dev-utils": "^1.0.14",
"@0x/sol-compiler": "^1.1.9",
"@0x/sol-cov": "^2.1.9",
"@0x/subproviders": "^2.1.1",
"@0x/dev-utils": "^1.0.16",
"@0x/sol-compiler": "^1.1.11",
"@0x/sol-cov": "^2.1.11",
"@0x/subproviders": "^2.1.3",
"@0x/tslint-config": "^1.0.10",
"@types/bn.js": "^4.11.0",
"@types/ethereumjs-abi": "^0.6.0",
@@ -71,12 +71,12 @@
"yargs": "^10.0.3"
},
"dependencies": {
"@0x/base-contract": "^3.0.3",
"@0x/order-utils": "^2.0.1",
"@0x/base-contract": "^3.0.5",
"@0x/order-utils": "^3.0.1",
"@0x/types": "^1.2.1",
"@0x/typescript-typings": "^3.0.4",
"@0x/utils": "^2.0.4",
"@0x/web3-wrapper": "^3.1.1",
"@0x/web3-wrapper": "^3.1.3",
"@types/js-combinatorics": "^0.5.29",
"bn.js": "^4.11.8",
"ethereum-types": "^1.1.2",

View File

@@ -212,13 +212,17 @@ export class ExchangeWrapper {
return tx;
}
public async getTakerAssetFilledAmountAsync(orderHashHex: string): Promise<BigNumber> {
const filledAmount = new BigNumber(await this._exchange.filled.callAsync(orderHashHex));
const filledAmount = await this._exchange.filled.callAsync(orderHashHex);
return filledAmount;
}
public async isCancelledAsync(orderHashHex: string): Promise<boolean> {
const isCancelled = await this._exchange.cancelled.callAsync(orderHashHex);
return isCancelled;
}
public async getOrderEpochAsync(makerAddress: string, senderAddress: string): Promise<BigNumber> {
const orderEpoch = await this._exchange.orderEpoch.callAsync(makerAddress, senderAddress);
return orderEpoch;
}
public async getOrderInfoAsync(signedOrder: SignedOrder): Promise<OrderInfo> {
const orderInfo = (await this._exchange.getOrderInfo.callAsync(signedOrder)) as OrderInfo;
return orderInfo;

View File

@@ -392,7 +392,7 @@ export class FillOrderCombinatorialUtils {
);
// 5. If I fill it by X, what are the resulting balances/allowances/filled amounts expected?
const orderValidationUtils = new OrderValidationUtils(orderFilledCancelledFetcher);
const orderValidationUtils = new OrderValidationUtils(orderFilledCancelledFetcher, provider);
const lazyStore = new BalanceAndProxyAllowanceLazyStore(balanceAndProxyAllowanceFetcher);
const exchangeTransferSimulator = new ExchangeTransferSimulator(lazyStore);

View File

@@ -1,4 +1,5 @@
import { AbstractOrderFilledCancelledFetcher } from '@0x/order-utils';
import { AbstractOrderFilledCancelledFetcher, orderHashUtils } from '@0x/order-utils';
import { SignedOrder } from '@0x/types';
import { BigNumber } from '@0x/utils';
import { ExchangeWrapper } from './exchange_wrapper';
@@ -14,9 +15,15 @@ export class SimpleOrderFilledCancelledFetcher implements AbstractOrderFilledCan
const filledTakerAmount = new BigNumber(await this._exchangeWrapper.getTakerAssetFilledAmountAsync(orderHash));
return filledTakerAmount;
}
public async isOrderCancelledAsync(orderHash: string): Promise<boolean> {
public async isOrderCancelledAsync(signedOrder: SignedOrder): Promise<boolean> {
const orderHash = orderHashUtils.getOrderHashHex(signedOrder);
const isCancelled = await this._exchangeWrapper.isCancelledAsync(orderHash);
return isCancelled;
const orderEpoch = await this._exchangeWrapper.getOrderEpochAsync(
signedOrder.makerAddress,
signedOrder.senderAddress,
);
const isCancelledByOrderEpoch = orderEpoch > signedOrder.salt;
return isCancelled || isCancelledByOrderEpoch;
}
public getZRXAssetData(): string {
return this._zrxAssetData;

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/dev-tools-pages",
"version": "0.0.3",
"version": "0.0.5",
"engines": {
"node": ">=6.12"
},
@@ -16,7 +16,7 @@
},
"license": "Apache-2.0",
"dependencies": {
"@0x/react-shared": "^1.0.18",
"@0x/react-shared": "^1.0.20",
"basscss": "^8.0.3",
"bowser": "^1.9.3",
"less": "^2.7.2",

View File

@@ -1,4 +1,22 @@
[
{
"timestamp": 1542134075,
"version": "1.0.16",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1542028948,
"version": "1.0.15",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "1.0.14",
"changes": [

View File

@@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v1.0.16 - _November 13, 2018_
* Dependencies updated
## v1.0.15 - _November 12, 2018_
* Dependencies updated
## v1.0.14 - _November 9, 2018_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/dev-utils",
"version": "1.0.14",
"version": "1.0.16",
"engines": {
"node": ">=6.12"
},
@@ -41,11 +41,11 @@
"typescript": "3.0.1"
},
"dependencies": {
"@0x/subproviders": "^2.1.1",
"@0x/subproviders": "^2.1.3",
"@0x/types": "^1.2.1",
"@0x/typescript-typings": "^3.0.4",
"@0x/utils": "^2.0.4",
"@0x/web3-wrapper": "^3.1.1",
"@0x/web3-wrapper": "^3.1.3",
"@types/web3-provider-engine": "^14.0.0",
"chai": "^4.0.1",
"ethereum-types": "^1.1.2",

View File

@@ -1,4 +1,22 @@
[
{
"timestamp": 1542134075,
"version": "1.0.11",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1542028948,
"version": "1.0.10",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "1.0.9",
"changes": [

View File

@@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v1.0.11 - _November 13, 2018_
* Dependencies updated
## v1.0.10 - _November 12, 2018_
* Dependencies updated
## v1.0.9 - _November 9, 2018_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/fill-scenarios",
"version": "1.0.9",
"version": "1.0.11",
"description": "0x order fill scenario generator",
"main": "lib/index.js",
"types": "lib/index.d.ts",
@@ -28,14 +28,14 @@
"typescript": "3.0.1"
},
"dependencies": {
"@0x/abi-gen-wrappers": "^1.0.2",
"@0x/base-contract": "^3.0.3",
"@0x/abi-gen-wrappers": "^1.0.4",
"@0x/base-contract": "^3.0.5",
"@0x/contract-artifacts": "^1.1.0",
"@0x/order-utils": "^2.0.1",
"@0x/order-utils": "^3.0.1",
"@0x/types": "^1.2.1",
"@0x/typescript-typings": "^3.0.4",
"@0x/utils": "^2.0.4",
"@0x/web3-wrapper": "^3.1.1",
"@0x/web3-wrapper": "^3.1.3",
"ethereum-types": "^1.1.2",
"ethers": "~4.0.4",
"lodash": "^4.17.5"

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/instant",
"version": "0.0.4",
"version": "0.0.6",
"engines": {
"node": ">=6.12"
},
@@ -45,15 +45,15 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/packages/instant/README.md",
"dependencies": {
"@0x/assert": "^1.0.15",
"@0x/asset-buyer": "^2.2.0",
"@0x/json-schemas": "^2.0.1",
"@0x/order-utils": "^2.0.1",
"@0x/subproviders": "^2.1.1",
"@0x/assert": "^1.0.16",
"@0x/asset-buyer": "^2.2.2",
"@0x/json-schemas": "^2.1.0",
"@0x/order-utils": "^3.0.1",
"@0x/subproviders": "^2.1.3",
"@0x/types": "^1.2.1",
"@0x/typescript-typings": "^3.0.4",
"@0x/utils": "^2.0.4",
"@0x/web3-wrapper": "^3.1.1",
"@0x/web3-wrapper": "^3.1.3",
"copy-to-clipboard": "^3.0.8",
"ethereum-types": "^1.1.2",
"lodash": "^4.17.10",

View File

@@ -1,11 +1,15 @@
import * as _ from 'lodash';
import { overlayBlack, styled } from '../../style/theme';
import { generateMediaWrapper, ScreenWidths } from '../../style/media';
import { generateOverlayBlack, styled } from '../../style/theme';
import { zIndex } from '../../style/z_index';
export interface OverlayProps {
zIndex?: number;
backgroundColor?: string;
width?: string;
height?: string;
showMaxWidth?: ScreenWidths;
}
export const Overlay =
@@ -20,12 +24,16 @@ export const Overlay =
left: 0;
z-index: ${props => props.zIndex}
background-color: ${props => props.backgroundColor};
${props => props.width && `width: ${props.width};`}
${props => props.height && `height: ${props.height};`}
display: ${props => (props.showMaxWidth ? 'none' : 'block')};
${props => props.showMaxWidth && generateMediaWrapper(props.showMaxWidth)`display: block;`}
}
`;
Overlay.defaultProps = {
zIndex: zIndex.overlayDefault,
backgroundColor: overlayBlack,
backgroundColor: generateOverlayBlack(0.6),
};
Overlay.displayName = 'Overlay';

View File

@@ -5,15 +5,18 @@ import * as _ from 'lodash';
import * as React from 'react';
import { Provider as ReduxProvider } from 'react-redux';
import { ACCOUNT_UPDATE_INTERVAL_TIME_MS, BUY_QUOTE_UPDATE_INTERVAL_TIME_MS } from '../constants';
import { SelectedAssetThemeProvider } from '../containers/selected_asset_theme_provider';
import { asyncData } from '../redux/async_data';
import { DEFAULT_STATE, DefaultState, State } from '../redux/reducer';
import { store, Store } from '../redux/store';
import { fonts } from '../style/fonts';
import { AffiliateInfo, AssetMetaData, Network, OrderSource } from '../types';
import { AccountState, AffiliateInfo, AssetMetaData, Network, OrderSource } from '../types';
import { assetUtils } from '../util/asset';
import { errorFlasher } from '../util/error_flasher';
import { gasPriceEstimator } from '../util/gas_price_estimator';
import { Heartbeater } from '../util/heartbeater';
import { generateAccountHeartbeater, generateBuyQuoteHeartbeater } from '../util/heartbeater_factory';
import { providerStateFactory } from '../util/provider_state_factory';
fonts.include();
@@ -37,6 +40,9 @@ export interface ZeroExInstantProviderOptionalProps {
export class ZeroExInstantProvider extends React.Component<ZeroExInstantProviderProps> {
private readonly _store: Store;
private _accountUpdateHeartbeat?: Heartbeater;
private _buyQuoteHeartbeat?: Heartbeater;
// TODO(fragosti): Write tests for this beast once we inject a provider.
private static _mergeDefaultStateWithProps(
props: ZeroExInstantProviderProps,
@@ -92,10 +98,21 @@ export class ZeroExInstantProvider extends React.Component<ZeroExInstantProvider
// tslint:disable-next-line:no-floating-promises
asyncData.fetchAvailableAssetDatasAndDispatchToStore(this._store);
}
if (state.providerState.account.state !== AccountState.None) {
this._accountUpdateHeartbeat = generateAccountHeartbeater({
store: this._store,
shouldPerformImmediatelyOnStart: true,
});
this._accountUpdateHeartbeat.start(ACCOUNT_UPDATE_INTERVAL_TIME_MS);
}
this._buyQuoteHeartbeat = generateBuyQuoteHeartbeater({
store: this._store,
shouldPerformImmediatelyOnStart: false,
});
this._buyQuoteHeartbeat.start(BUY_QUOTE_UPDATE_INTERVAL_TIME_MS);
// tslint:disable-next-line:no-floating-promises
asyncData.fetchAccountInfoAndDispatchToStore(this._store);
// tslint:disable-next-line:no-floating-promises
asyncData.fetchCurrentBuyQuoteAndDispatchToStore(this._store);
asyncData.fetchCurrentBuyQuoteAndDispatchToStore({ store: this._store, shouldSetPending: true });
// warm up the gas price estimator cache just in case we can't
// grab the gas price estimate when submitting the transaction
// tslint:disable-next-line:no-floating-promises
@@ -103,6 +120,14 @@ export class ZeroExInstantProvider extends React.Component<ZeroExInstantProvider
// tslint:disable-next-line:no-floating-promises
this._flashErrorIfWrongNetwork();
}
public componentWillUnmount(): void {
if (this._accountUpdateHeartbeat) {
this._accountUpdateHeartbeat.stop();
}
if (this._buyQuoteHeartbeat) {
this._buyQuoteHeartbeat.stop();
}
}
public render(): React.ReactNode {
return (
<ReduxProvider store={this._store}>

View File

@@ -11,6 +11,8 @@ export const WEB_3_WRAPPER_TRANSACTION_FAILED_ERROR_MSG_PREFIX = 'Transaction fa
export const GWEI_IN_WEI = new BigNumber(1000000000);
export const ONE_SECOND_MS = 1000;
export const ONE_MINUTE_MS = ONE_SECOND_MS * 60;
export const ACCOUNT_UPDATE_INTERVAL_TIME_MS = ONE_SECOND_MS * 5;
export const BUY_QUOTE_UPDATE_INTERVAL_TIME_MS = ONE_SECOND_MS * 15;
export const DEFAULT_GAS_PRICE = GWEI_IN_WEI.mul(6);
export const DEFAULT_ESTIMATED_TRANSACTION_TIME_MS = ONE_MINUTE_MS * 2;
export const ETH_GAS_STATION_API_BASE_URL = 'https://ethgasstation.info';
@@ -31,6 +33,3 @@ export const LOADING_ACCOUNT: AccountNotReady = {
export const LOCKED_ACCOUNT: AccountNotReady = {
state: AccountState.Locked,
};
export const ERROR_ACCOUNT: AccountNotReady = {
state: AccountState.Error,
};

View File

@@ -1,35 +1,60 @@
import * as React from 'react';
import { connect } from 'react-redux';
import { Dispatch } from 'redux';
import { SlideAnimationState } from '../components/animations/slide_animation';
import { SlidingError } from '../components/sliding_error';
import { Overlay } from '../components/ui/overlay';
import { Action } from '../redux/actions';
import { State } from '../redux/reducer';
import { Asset, DisplayStatus } from '../types';
import { ScreenWidths } from '../style/media';
import { generateOverlayBlack } from '../style/theme';
import { zIndex } from '../style/z_index';
import { Asset, DisplayStatus, Omit } from '../types';
import { errorFlasher } from '../util/error_flasher';
export interface LatestErrorComponentProps {
asset?: Asset;
latestErrorMessage?: string;
animationState: SlideAnimationState;
shouldRenderOverlay: boolean;
onOverlayClick: () => void;
}
export const LatestErrorComponent: React.StatelessComponent<LatestErrorComponentProps> = props => {
if (!props.latestErrorMessage) {
return <div />;
}
return <SlidingError animationState={props.animationState} icon="😢" message={props.latestErrorMessage} />;
return (
<React.Fragment>
<SlidingError animationState={props.animationState} icon="😢" message={props.latestErrorMessage} />
{props.shouldRenderOverlay && (
<Overlay
onClick={props.onOverlayClick}
zIndex={zIndex.containerOverlay}
showMaxWidth={ScreenWidths.Sm}
backgroundColor={generateOverlayBlack(0.4)}
/>
)}
</React.Fragment>
);
};
interface ConnectedState {
asset?: Asset;
latestErrorMessage?: string;
animationState: SlideAnimationState;
}
export interface LatestErrorProps {}
interface ConnectedState extends Omit<LatestErrorComponentProps, 'onOverlayClick'> {}
const mapStateToProps = (state: State, _ownProps: LatestErrorProps): ConnectedState => ({
asset: state.selectedAsset,
latestErrorMessage: state.latestErrorMessage,
animationState: state.latestErrorDisplayStatus === DisplayStatus.Present ? 'slidIn' : 'slidOut',
shouldRenderOverlay: state.latestErrorDisplayStatus === DisplayStatus.Present,
});
export const LatestError = connect(mapStateToProps)(LatestErrorComponent);
type ConnectedDispatch = Pick<LatestErrorComponentProps, 'onOverlayClick'>;
const mapDispatchToProps = (dispatch: Dispatch<Action>, _ownProps: LatestErrorProps): ConnectedDispatch => ({
onOverlayClick: () => {
errorFlasher.clearError(dispatch);
},
});
export const LatestError = connect(mapStateToProps, mapDispatchToProps)(LatestErrorComponent);

View File

@@ -69,7 +69,7 @@ const mapStateToProps = (state: State, _ownProps: SelectedERC20AssetAmountInputP
const debouncedUpdateBuyQuoteAsync = _.debounce(buyQuoteUpdater.updateBuyQuoteAsync.bind(buyQuoteUpdater), 200, {
trailing: true,
});
}) as typeof buyQuoteUpdater.updateBuyQuoteAsync;
const mapDispatchToProps = (
dispatch: Dispatch<Action>,
@@ -87,7 +87,7 @@ const mapDispatchToProps = (
// even if it's debounced, give them the illusion it's loading
dispatch(actions.setQuoteRequestStatePending());
// tslint:disable-next-line:no-floating-promises
debouncedUpdateBuyQuoteAsync(assetBuyer, dispatch, asset, value, affiliateInfo);
debouncedUpdateBuyQuoteAsync(assetBuyer, dispatch, asset, value, true, affiliateInfo);
}
},
});

View File

@@ -8,42 +8,42 @@ export const assetMetaDataMap: ObjectMap<AssetMetaData> = {
'0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498': {
assetProxyId: AssetProxyId.ERC20,
decimals: 18,
primaryColor: 'rgb(54, 50, 60)',
primaryColor: '#333333',
symbol: 'zrx',
name: '0x',
},
'0xf47261b000000000000000000000000042d6622dece394b54999fbd73d108123806f6a18': {
assetProxyId: AssetProxyId.ERC20,
decimals: 18,
primaryColor: '#ec3e6c',
primaryColor: '#EC4F81',
symbol: 'spank',
name: 'Spank',
},
'0xf47261b0000000000000000000000000d26114cd6ee289accf82350c8d8487fedb8a0c07': {
assetProxyId: AssetProxyId.ERC20,
decimals: 18,
primaryColor: '#2e61ea',
primaryColor: '#2458E7',
symbol: 'omg',
name: 'OmiseGo',
},
'0xf47261b00000000000000000000000009f8f72aa9304c8b593d555f12ef6589cc3a579a2': {
assetProxyId: AssetProxyId.ERC20,
decimals: 18,
primaryColor: '#87e4ca',
primaryColor: '#68CCBB',
symbol: 'mkr',
name: 'Maker',
},
'0xf47261b00000000000000000000000000d8775f648430679a709e98d2b0cb6250d2887ef': {
assetProxyId: AssetProxyId.ERC20,
decimals: 18,
primaryColor: '#9c326c',
primaryColor: '#FF5000',
symbol: 'bat',
name: 'Basic Attention Token',
},
'0xf47261b0000000000000000000000000744d70fdbe2ba4cf95131626614a1763df805b9e': {
assetProxyId: AssetProxyId.ERC20,
decimals: 18,
primaryColor: '#5663b0',
primaryColor: '#4763D7',
symbol: 'snt',
name: 'Status',
},
@@ -54,27 +54,6 @@ export const assetMetaDataMap: ObjectMap<AssetMetaData> = {
symbol: 'mana',
name: 'Decentraland',
},
'0xf47261b0000000000000000000000000a74476443119a942de498590fe1f2454d7d4ac0d': {
assetProxyId: AssetProxyId.ERC20,
decimals: 18,
primaryColor: '#263469',
symbol: 'gnt',
name: 'Golem',
},
'0xf47261b000000000000000000000000012480e24eb5bec1a9d4369cab6a80cad3c0a377a': {
assetProxyId: AssetProxyId.ERC20,
decimals: 18,
primaryColor: '#de5445',
symbol: 'sub',
name: 'Substratum',
},
'0xf47261b000000000000000000000000008d32b0da63e2C3bcF8019c9c5d849d7a9d791e6': {
assetProxyId: AssetProxyId.ERC20,
decimals: 18,
primaryColor: '#000',
symbol: 'dentacoin',
name: 'Dentacoin',
},
'0xf47261b00000000000000000000000001985365e9f78359a9b6ad760e32412f4a445e862': {
assetProxyId: AssetProxyId.ERC20,
decimals: 18,
@@ -82,4 +61,144 @@ export const assetMetaDataMap: ObjectMap<AssetMetaData> = {
symbol: 'rep',
name: 'Augur',
},
'0xf47261b00000000000000000000000000abdace70d3790235af448c88547603b945604ea': {
assetProxyId: AssetProxyId.ERC20,
decimals: 18,
primaryColor: '#2c3c8c',
symbol: 'dnt',
name: 'district0x',
},
'0xf47261b000000000000000000000000005f4a42e251f2d52b8ed15e9fedaacfcef1fad27': {
assetProxyId: AssetProxyId.ERC20,
decimals: 12,
primaryColor: '#048998',
symbol: 'zil',
name: 'Zilliqa',
},
'0xf47261b00000000000000000000000008f8221afbb33998d8584a2b05749ba73c37a938a': {
assetProxyId: AssetProxyId.ERC20,
decimals: 18,
primaryColor: '#58BFD6',
symbol: 'req',
name: 'Request Network',
},
'0xf47261b0000000000000000000000000e0b7927c4af23765cb51314a0e0521a9645f0e2a': {
assetProxyId: AssetProxyId.ERC20,
decimals: 9,
primaryColor: '#BC9952',
symbol: 'dgd',
name: 'DigixDao',
},
'0xf47261b00000000000000000000000004f3afec4e5a3f2a6a1a411def7d7dfe50ee057bf': {
assetProxyId: AssetProxyId.ERC20,
decimals: 9,
primaryColor: '#DEB564',
symbol: 'dgx',
name: 'Digix Gold Token',
},
'0xf47261b0000000000000000000000000419d0d8bdd9af5e606ae2232ed285aff190e711b': {
assetProxyId: AssetProxyId.ERC20,
decimals: 8,
primaryColor: '#E40057',
symbol: 'fun',
name: 'FunFair',
},
'0xf47261b000000000000000000000000041e5560054824ea6b0732e656e3ad64e20e94e45': {
assetProxyId: AssetProxyId.ERC20,
decimals: 8,
primaryColor: '#04bc24',
symbol: 'cvc',
name: 'Civic',
},
'0xf47261b00000000000000000000000005ca9a71b1d01849c0a95490cc00559717fcf0d1d': {
assetProxyId: AssetProxyId.ERC20,
decimals: 18,
primaryColor: '#F7296E',
symbol: 'ae',
name: 'Aeternity',
},
'0xf47261b0000000000000000000000000408e41876cccdc0f92210600ef50372656052a38': {
assetProxyId: AssetProxyId.ERC20,
decimals: 18,
primaryColor: '#233C5A',
symbol: 'ren',
name: 'Republic Protocol',
},
'0xf47261b0000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca': {
assetProxyId: AssetProxyId.ERC20,
decimals: 18,
primaryColor: '#325CD2',
symbol: 'link',
name: 'ChainLink',
},
'0xf47261b00000000000000000000000006810e776880c02933d47db1b9fc05908e5386b96': {
assetProxyId: AssetProxyId.ERC20,
decimals: 18,
primaryColor: '#48A4C0',
symbol: 'gno',
name: 'Gnosis',
},
'0xf47261b0000000000000000000000000960b236a07cf122663c4303350609a66a7b288c0': {
assetProxyId: AssetProxyId.ERC20,
decimals: 18,
primaryColor: '#04a29e',
symbol: 'ant',
name: 'Aragon',
},
'0xf47261b00000000000000000000000004156d3342d5c385a87d264f90653733592000581': {
assetProxyId: AssetProxyId.ERC20,
decimals: 8,
primaryColor: '#4CABA7',
symbol: 'salt',
name: 'Salt',
},
'0xf47261b0000000000000000000000000595832f8fc6bf59c85c527fec3740a1b7a361269': {
assetProxyId: AssetProxyId.ERC20,
decimals: 6,
primaryColor: '#5BC9D4',
symbol: 'powr',
name: 'PowerLedger',
},
'0xf47261b00000000000000000000000008eb24319393716668d768dcec29356ae9cffe285': {
assetProxyId: AssetProxyId.ERC20,
decimals: 8,
primaryColor: '#523CE8',
symbol: 'agi',
name: 'SingularityNET',
},
'0xf47261b000000000000000000000000039bb259f66e1c59d5abef88375979b4d20d98022': {
assetProxyId: AssetProxyId.ERC20,
decimals: 8,
primaryColor: '#EDB740',
symbol: 'wax',
name: 'WAX',
},
'0xf47261b0000000000000000000000000beb9ef514a379b997e0798fdcc901ee474b6d9a1': {
assetProxyId: AssetProxyId.ERC20,
decimals: 18,
primaryColor: '#333333',
symbol: 'mln',
name: 'Melon',
},
'0xf47261b000000000000000000000000058b6a8a3302369daec383334672404ee733ab239': {
assetProxyId: AssetProxyId.ERC20,
decimals: 18,
primaryColor: '#232D37',
symbol: 'lpt',
name: 'Livepeer',
},
'0xf47261b000000000000000000000000027054b13b1b798b345b591a4d22e6562d47ea75a': {
assetProxyId: AssetProxyId.ERC20,
decimals: 4,
primaryColor: '#3A74F6',
symbol: 'ast',
name: 'AirSwap',
},
'0xf47261b000000000000000000000000089d24a6b4ccb1b6faa2625fe562bdd9a23260359': {
assetProxyId: AssetProxyId.ERC20,
decimals: 18,
primaryColor: '#F2B350',
symbol: 'dai',
name: 'Dai Stablecoin',
},
};

View File

@@ -23,7 +23,6 @@ function createAction<T extends string, P>(type: T, data?: P): PlainAction<T> |
export enum ActionTypes {
SET_ACCOUNT_STATE_LOADING = 'SET_ACCOUNT_STATE_LOADING',
SET_ACCOUNT_STATE_LOCKED = 'SET_ACCOUNT_STATE_LOCKED',
SET_ACCOUNT_STATE_ERROR = 'SET_ACCOUNT_STATE_ERROR',
SET_ACCOUNT_STATE_READY = 'SET_ACCOUNT_STATE_READY',
UPDATE_ACCOUNT_ETH_BALANCE = 'UPDATE_ACCOUNT_ETH_BALANCE',
UPDATE_ETH_USD_PRICE = 'UPDATE_ETH_USD_PRICE',
@@ -47,7 +46,6 @@ export enum ActionTypes {
export const actions = {
setAccountStateLoading: () => createAction(ActionTypes.SET_ACCOUNT_STATE_LOADING),
setAccountStateLocked: () => createAction(ActionTypes.SET_ACCOUNT_STATE_LOCKED),
setAccountStateError: () => createAction(ActionTypes.SET_ACCOUNT_STATE_ERROR),
setAccountStateReady: (address: string) => createAction(ActionTypes.SET_ACCOUNT_STATE_READY, address),
updateAccountEthBalance: (addressAndBalance: AddressAndEthBalanceInWei) =>
createAction(ActionTypes.UPDATE_ACCOUNT_ETH_BALANCE, addressAndBalance),

View File

@@ -2,7 +2,7 @@ import { AssetProxyId } from '@0x/types';
import * as _ from 'lodash';
import { BIG_NUMBER_ZERO } from '../constants';
import { AccountState, ERC20Asset } from '../types';
import { AccountState, ERC20Asset, OrderProcessState } from '../types';
import { assetUtils } from '../util/asset';
import { buyQuoteUpdater } from '../util/buy_quote_updater';
import { coinbaseApi } from '../util/coinbase_api';
@@ -36,17 +36,23 @@ export const asyncData = {
store.dispatch(actions.setAvailableAssets([]));
}
},
fetchAccountInfoAndDispatchToStore: async (store: Store) => {
fetchAccountInfoAndDispatchToStore: async (options: { store: Store; shouldSetToLoading: boolean }) => {
const { store, shouldSetToLoading } = options;
const { providerState } = store.getState();
const web3Wrapper = providerState.web3Wrapper;
if (providerState.account.state !== AccountState.Loading) {
const provider = providerState.provider;
if (shouldSetToLoading && providerState.account.state !== AccountState.Loading) {
store.dispatch(actions.setAccountStateLoading());
}
let availableAddresses: string[];
try {
availableAddresses = await web3Wrapper.getAvailableAddressesAsync();
// TODO(bmillman): Add support at the web3Wrapper level for calling `eth_requestAccounts` instead of calling enable here
const isPrivacyModeEnabled = !_.isUndefined((provider as any).enable);
availableAddresses = isPrivacyModeEnabled
? await (provider as any).enable()
: await web3Wrapper.getAvailableAddressesAsync();
} catch (e) {
store.dispatch(actions.setAccountStateError());
store.dispatch(actions.setAccountStateLocked());
return;
}
if (!_.isEmpty(availableAddresses)) {
@@ -74,12 +80,14 @@ export const asyncData = {
return;
}
},
fetchCurrentBuyQuoteAndDispatchToStore: async (store: Store) => {
const { providerState, selectedAsset, selectedAssetAmount, affiliateInfo } = store.getState();
fetchCurrentBuyQuoteAndDispatchToStore: async (options: { store: Store; shouldSetPending: boolean }) => {
const { store, shouldSetPending } = options;
const { buyOrderState, providerState, selectedAsset, selectedAssetAmount, affiliateInfo } = store.getState();
const assetBuyer = providerState.assetBuyer;
if (
!_.isUndefined(selectedAssetAmount) &&
!_.isUndefined(selectedAsset) &&
buyOrderState.processState === OrderProcessState.None &&
selectedAsset.metaData.assetProxyId === AssetProxyId.ERC20
) {
await buyQuoteUpdater.updateBuyQuoteAsync(
@@ -87,6 +95,7 @@ export const asyncData = {
store.dispatch,
selectedAsset as ERC20Asset,
selectedAssetAmount,
shouldSetPending,
affiliateInfo,
);
}

View File

@@ -4,7 +4,7 @@ import { BigNumber } from '@0x/utils';
import { Web3Wrapper } from '@0x/web3-wrapper';
import * as _ from 'lodash';
import { ERROR_ACCOUNT, LOADING_ACCOUNT, LOCKED_ACCOUNT } from '../constants';
import { LOADING_ACCOUNT, LOCKED_ACCOUNT } from '../constants';
import { assetMetaDataMap } from '../data/asset_meta_data_map';
import {
Account,
@@ -65,8 +65,6 @@ export const createReducer = (initialState: State) => {
return reduceStateWithAccount(state, LOADING_ACCOUNT);
case ActionTypes.SET_ACCOUNT_STATE_LOCKED:
return reduceStateWithAccount(state, LOCKED_ACCOUNT);
case ActionTypes.SET_ACCOUNT_STATE_ERROR:
return reduceStateWithAccount(state, ERROR_ACCOUNT);
case ActionTypes.SET_ACCOUNT_STATE_READY: {
const account: AccountReady = {
state: AccountState.Ready,

View File

@@ -8,7 +8,7 @@ export enum ScreenWidths {
Lg = 64,
}
const generateMediaWrapper = (screenWidth: ScreenWidths) => (...args: any[]) => css`
export const generateMediaWrapper = (screenWidth: ScreenWidths) => (...args: any[]) => css`
@media (max-width: ${screenWidth}em) {
${css.apply(css, args)};
}

View File

@@ -35,7 +35,10 @@ export const theme: Theme = {
};
export const transparentWhite = 'rgba(255,255,255,0.3)';
export const overlayBlack = 'rgba(0, 0, 0, 0.6)';
export const completelyTransparent = 'rga(0, 0, 0, 0)';
export const generateOverlayBlack = (opacity = 0.6) => {
return `rgba(0, 0, 0, ${opacity})`;
};
export { styled, css, keyframes, withTheme, createGlobalStyle, ThemeProvider };

View File

@@ -3,6 +3,7 @@ export const zIndex = {
mainContainer: 20,
dropdownItems: 30,
panel: 40,
containerOverlay: 45,
errorPopup: 50,
overlayDefault: 100,
};

View File

@@ -4,6 +4,7 @@ import { Web3Wrapper } from '@0x/web3-wrapper';
import { Provider } from 'ethereum-types';
// Reusable
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
export type Maybe<T> = T | undefined;
export enum AsyncProcessState {
None = 'NONE',
@@ -101,11 +102,10 @@ export interface ProviderState {
}
export enum AccountState {
None = 'NONE,',
Loading = 'LOADING',
Ready = 'READY',
Locked = 'LOCKED', // TODO(bmillman): break this up into locked / privacy mode enabled
Error = 'ERROR',
None = 'NONE,',
Locked = 'LOCKED',
}
export interface AccountReady {
@@ -114,7 +114,7 @@ export interface AccountReady {
ethBalanceInWei?: BigNumber;
}
export interface AccountNotReady {
state: AccountState.None | AccountState.Loading | AccountState.Locked | AccountState.Error;
state: AccountState.None | AccountState.Loading | AccountState.Locked;
}
export type Account = AccountReady | AccountNotReady;

View File

@@ -16,12 +16,15 @@ export const buyQuoteUpdater = {
dispatch: Dispatch<Action>,
asset: ERC20Asset,
assetAmount: BigNumber,
setPending = true,
affiliateInfo?: AffiliateInfo,
): Promise<void> => {
// get a new buy quote.
const baseUnitValue = Web3Wrapper.toBaseUnitAmount(assetAmount, asset.metaData.decimals);
// mark quote as pending
dispatch(actions.setQuoteRequestStatePending());
if (setPending) {
// mark quote as pending
dispatch(actions.setQuoteRequestStatePending());
}
const feePercentage = oc(affiliateInfo).feePercentage();
let newBuyQuote: BuyQuote | undefined;
try {

View File

@@ -0,0 +1,35 @@
import { intervalUtils } from '@0x/utils';
import * as _ from 'lodash';
type HeartbeatableFunction = () => Promise<void>;
export class Heartbeater {
private _intervalId?: NodeJS.Timer;
private readonly _performImmediatelyOnStart: boolean;
private readonly _performFunction: HeartbeatableFunction;
public constructor(performingFunctionAsync: HeartbeatableFunction, performImmediatelyOnStart: boolean) {
this._performFunction = performingFunctionAsync;
this._performImmediatelyOnStart = performImmediatelyOnStart;
}
public start(intervalTimeMs: number): void {
if (!_.isUndefined(this._intervalId)) {
throw new Error('Heartbeat is running, please stop before restarting');
}
if (this._performImmediatelyOnStart) {
// tslint:disable-next-line:no-floating-promises
this._performFunction();
}
// tslint:disable-next-line:no-unbound-method
this._intervalId = intervalUtils.setAsyncExcludingInterval(this._performFunction, intervalTimeMs, _.noop);
}
public stop(): void {
if (this._intervalId) {
intervalUtils.clearInterval(this._intervalId);
}
this._intervalId = undefined;
}
}

View File

@@ -0,0 +1,22 @@
import { asyncData } from '../redux/async_data';
import { Store } from '../redux/store';
import { Heartbeater } from './heartbeater';
export interface HeartbeatFactoryOptions {
store: Store;
shouldPerformImmediatelyOnStart: boolean;
}
export const generateAccountHeartbeater = (options: HeartbeatFactoryOptions): Heartbeater => {
const { store, shouldPerformImmediatelyOnStart } = options;
return new Heartbeater(async () => {
await asyncData.fetchAccountInfoAndDispatchToStore({ store, shouldSetToLoading: false });
}, shouldPerformImmediatelyOnStart);
};
export const generateBuyQuoteHeartbeater = (options: HeartbeatFactoryOptions): Heartbeater => {
const { store, shouldPerformImmediatelyOnStart } = options;
return new Heartbeater(async () => {
await asyncData.fetchCurrentBuyQuoteAndDispatchToStore({ store, shouldSetPending: false });
}, shouldPerformImmediatelyOnStart);
};

View File

@@ -1,14 +1,18 @@
[
{
"version": "2.0.1",
"version": "2.1.0",
"changes": [
{
"note":
"Improve schemas by enforcing that amounts that must be whole numbers (e.g Order asset amounts) no longer allow decimal amounts",
"pr": 1173
},
{
"note": "Add schemas from @0x/connect",
"pr": 1250
}
],
"timestamp": 1541740904
"timestamp": 1542028948
},
{
"version": "2.0.0",

View File

@@ -5,9 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v2.0.1 - _November 9, 2018_
## v2.1.0 - _November 12, 2018_
* Improve schemas by enforcing that amounts that must be whole numbers (e.g Order asset amounts) no longer allow decimal amounts (#1173)
* Add schemas from @0x/connect (#1250)
## v2.0.0 - _October 18, 2018_

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/json-schemas",
"version": "2.0.1",
"version": "2.1.0",
"engines": {
"node": ">=6.12"
},

View File

@@ -0,0 +1,8 @@
{
"id": "/AssetPairsRequestOpts",
"type": "object",
"properties": {
"assetDataA": { "$ref": "/hexSchema" },
"assetDataB": { "$ref": "/hexSchema" }
}
}

View File

@@ -0,0 +1,24 @@
{
"id": "/OrderConfigRequest",
"type": "object",
"properties": {
"makerAddress": { "$ref": "/addressSchema" },
"takerAddress": { "$ref": "/addressSchema" },
"makerAssetAmount": { "$ref": "/wholeNumberSchema" },
"takerAssetAmount": { "$ref": "/wholeNumberSchema" },
"makerAssetData": { "$ref": "/hexSchema" },
"takerAssetData": { "$ref": "/hexSchema" },
"exchangeAddress": { "$ref": "/addressSchema" },
"expirationTimeSeconds": { "$ref": "/wholeNumberSchema" }
},
"required": [
"makerAddress",
"takerAddress",
"makerAssetAmount",
"takerAssetAmount",
"makerAssetData",
"takerAssetData",
"exchangeAddress",
"expirationTimeSeconds"
]
}

View File

@@ -0,0 +1,9 @@
{
"id": "/OrderBookRequest",
"type": "object",
"properties": {
"baseAssetData": { "$ref": "/hexSchema" },
"quoteAssetData": { "$ref": "/hexSchema" }
},
"required": ["baseAssetData", "quoteAssetData"]
}

View File

@@ -0,0 +1,19 @@
{
"id": "/OrdersRequestOpts",
"type": "object",
"properties": {
"makerAssetProxyId": { "$ref": "/hexSchema" },
"takerAssetProxyId": { "$ref": "/hexSchema" },
"makerAssetAddress": { "$ref": "/addressSchema" },
"takerAssetAddress": { "$ref": "/addressSchema" },
"exchangeAddress": { "$ref": "/addressSchema" },
"senderAddress": { "$ref": "/addressSchema" },
"makerAssetData": { "$ref": "/hexSchema" },
"takerAssetData": { "$ref": "/hexSchema" },
"traderAssetData": { "$ref": "/hexSchema" },
"makerAddress": { "$ref": "/addressSchema" },
"takerAddress": { "$ref": "/addressSchema" },
"traderAddress": { "$ref": "/addressSchema" },
"feeRecipientAddress": { "$ref": "/addressSchema" }
}
}

View File

@@ -0,0 +1,8 @@
{
"id": "/PagedRequestOpts",
"type": "object",
"properties": {
"page": { "type": "number" },
"perPage": { "type": "number" }
}
}

View File

@@ -0,0 +1,7 @@
{
"id": "/RequestOpts",
"type": "object",
"properties": {
"networkId": { "type": "number" }
}
}

View File

@@ -1,4 +1,5 @@
import * as addressSchema from '../schemas/address_schema.json';
import * as assetPairsRequestOptsSchema from '../schemas/asset_pairs_request_opts_schema.json';
import * as blockParamSchema from '../schemas/block_param_schema.json';
import * as blockRangeSchema from '../schemas/block_range_schema.json';
import * as callDataSchema from '../schemas/call_data_schema.json';
@@ -10,11 +11,15 @@ import * as indexFilterValuesSchema from '../schemas/index_filter_values_schema.
import * as jsNumber from '../schemas/js_number.json';
import * as numberSchema from '../schemas/number_schema.json';
import * as orderCancellationRequestsSchema from '../schemas/order_cancel_schema.json';
import * as orderConfigRequestSchema from '../schemas/order_config_request_schema.json';
import * as orderFillOrKillRequestsSchema from '../schemas/order_fill_or_kill_requests_schema.json';
import * as orderFillRequestsSchema from '../schemas/order_fill_requests_schema.json';
import * as orderHashSchema from '../schemas/order_hash_schema.json';
import * as orderSchema from '../schemas/order_schema.json';
import * as orderBookRequestSchema from '../schemas/orderbook_request_schema.json';
import * as ordersRequestOptsSchema from '../schemas/orders_request_opts_schema.json';
import * as ordersSchema from '../schemas/orders_schema.json';
import * as pagedRequestOptsSchema from '../schemas/paged_request_opts_schema.json';
import * as paginatedCollectionSchema from '../schemas/paginated_collection_schema.json';
import * as relayerApiAssetDataPairsResponseSchema from '../schemas/relayer_api_asset_data_pairs_response_schema.json';
import * as relayerApiAssetDataPairsSchema from '../schemas/relayer_api_asset_data_pairs_schema.json';
@@ -30,6 +35,7 @@ import * as relayerApiOrdersChannelSubscribeSchema from '../schemas/relayer_api_
import * as relayerApiOrdersChannelUpdateSchema from '../schemas/relayer_api_orders_channel_update_response_schema.json';
import * as relayerApiOrdersResponseSchema from '../schemas/relayer_api_orders_response_schema.json';
import * as relayerApiOrdersSchema from '../schemas/relayer_api_orders_schema.json';
import * as requestOptsSchema from '../schemas/request_opts_schema.json';
import * as signedOrderSchema from '../schemas/signed_order_schema.json';
import * as signedOrdersSchema from '../schemas/signed_orders_schema.json';
import * as tokenSchema from '../schemas/token_schema.json';
@@ -58,6 +64,12 @@ export const schemas = {
blockRangeSchema,
tokenSchema,
jsNumber,
requestOptsSchema,
pagedRequestOptsSchema,
ordersRequestOptsSchema,
orderBookRequestSchema,
orderConfigRequestSchema,
assetPairsRequestOptsSchema,
txDataSchema,
paginatedCollectionSchema,
relayerApiErrorResponseSchema,

View File

@@ -44,6 +44,12 @@
"./schemas/zero_ex_transaction_schema.json",
"./schemas/tx_data_schema.json",
"./schemas/index_filter_values_schema.json",
"./schemas/whole_number_schema.json"
"./schemas/whole_number_schema.json",
"./schemas/asset_pairs_request_opts_schema.json",
"./schemas/orderbook_request_schema.json",
"./schemas/orders_request_opts_schema.json",
"./schemas/paged_request_opts_schema.json",
"./schemas/request_opts_schema.json",
"./schemas/order_config_request_schema.json"
]
}

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/metacoin",
"version": "0.0.25",
"version": "0.0.27",
"engines": {
"node": ">=6.12"
},
@@ -30,14 +30,14 @@
"license": "Apache-2.0",
"dependencies": {
"@0x/abi-gen": "^1.0.15",
"@0x/base-contract": "^3.0.3",
"@0x/sol-cov": "^2.1.9",
"@0x/subproviders": "^2.1.1",
"@0x/base-contract": "^3.0.5",
"@0x/sol-cov": "^2.1.11",
"@0x/subproviders": "^2.1.3",
"@0x/tslint-config": "^1.0.10",
"@0x/types": "^1.2.1",
"@0x/typescript-typings": "^3.0.4",
"@0x/utils": "^2.0.4",
"@0x/web3-wrapper": "^3.1.1",
"@0x/web3-wrapper": "^3.1.3",
"@types/mocha": "^5.2.2",
"copyfiles": "^2.0.0",
"ethereum-types": "^1.1.2",
@@ -46,8 +46,8 @@
"run-s": "^0.0.0"
},
"devDependencies": {
"@0x/dev-utils": "^1.0.14",
"@0x/sol-compiler": "^1.1.9",
"@0x/dev-utils": "^1.0.16",
"@0x/sol-compiler": "^1.1.11",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"chai-bignumber": "^2.0.1",

View File

@@ -1,4 +1,22 @@
[
{
"timestamp": 1542134075,
"version": "2.0.3",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1542028948,
"version": "2.0.2",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "2.0.1",
"changes": [

View File

@@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v2.0.3 - _November 13, 2018_
* Dependencies updated
## v2.0.2 - _November 12, 2018_
* Dependencies updated
## v2.0.1 - _November 9, 2018_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/migrations",
"version": "2.0.1",
"version": "2.0.3",
"engines": {
"node": ">=6.12"
},
@@ -17,7 +17,7 @@
},
"license": "Apache-2.0",
"devDependencies": {
"@0x/dev-utils": "^1.0.14",
"@0x/dev-utils": "^1.0.16",
"@0x/tslint-config": "^1.0.10",
"@0x/types": "^1.2.1",
"@types/yargs": "^10.0.0",
@@ -29,16 +29,16 @@
"yargs": "^10.0.3"
},
"dependencies": {
"@0x/abi-gen-wrappers": "^1.0.2",
"@0x/base-contract": "^3.0.3",
"@0x/abi-gen-wrappers": "^1.0.4",
"@0x/base-contract": "^3.0.5",
"@0x/contract-addresses": "^1.1.0",
"@0x/contract-artifacts": "^1.1.0",
"@0x/order-utils": "^2.0.1",
"@0x/sol-compiler": "^1.1.9",
"@0x/subproviders": "^2.1.1",
"@0x/order-utils": "^3.0.1",
"@0x/sol-compiler": "^1.1.11",
"@0x/subproviders": "^2.1.3",
"@0x/typescript-typings": "^3.0.4",
"@0x/utils": "^2.0.4",
"@0x/web3-wrapper": "^3.1.1",
"@0x/web3-wrapper": "^3.1.3",
"@ledgerhq/hw-app-eth": "^4.3.0",
"ethereum-types": "^1.1.2",
"ethers": "~4.0.4",

View File

@@ -1,4 +1,39 @@
[
{
"timestamp": 1542134075,
"version": "3.0.1",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "3.0.0",
"changes": [
{
"note":
"Add signature validation, regular cancellation and `cancelledUpTo` checks to `validateOrderFillableOrThrowAsync`",
"pr": 1235
},
{
"note":
"Improved the errors thrown by `validateOrderFillableOrThrowAsync` by making them more descriptive",
"pr": 1235
},
{
"note":
"Throw previously swallowed network errors when calling `validateOrderFillableOrThrowAsync` (see issue: #1218)",
"pr": 1235
},
{
"note":
"Modified the `AbstractOrderFilledCancelledFetcher` interface slightly such that `isOrderCancelledAsync` accepts a `signedOrder` instead of an `orderHash` param",
"pr": 1235
}
],
"timestamp": 1542028948
},
{
"version": "2.0.1",
"changes": [

View File

@@ -5,6 +5,17 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v3.0.1 - _November 13, 2018_
* Dependencies updated
## v3.0.0 - _November 12, 2018_
* Add signature validation, regular cancellation and `cancelledUpTo` checks to `validateOrderFillableOrThrowAsync` (#1235)
* Improved the errors thrown by `validateOrderFillableOrThrowAsync` by making them more descriptive (#1235)
* Throw previously swallowed network errors when calling `validateOrderFillableOrThrowAsync` (see issue: #1218) (#1235)
* Modified the `AbstractOrderFilledCancelledFetcher` interface slightly such that `isOrderCancelledAsync` accepts a `signedOrder` instead of an `orderHash` param (#1235)
## v2.0.1 - _November 9, 2018_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/order-utils",
"version": "2.0.1",
"version": "3.0.1",
"engines": {
"node": ">=6.12"
},
@@ -35,7 +35,7 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/packages/order-utils/README.md",
"devDependencies": {
"@0x/dev-utils": "^1.0.14",
"@0x/dev-utils": "^1.0.16",
"@0x/tslint-config": "^1.0.10",
"@types/bn.js": "^4.11.0",
"@types/lodash": "4.14.104",
@@ -53,15 +53,15 @@
"typescript": "3.0.1"
},
"dependencies": {
"@0x/abi-gen-wrappers": "^1.0.2",
"@0x/assert": "^1.0.15",
"@0x/base-contract": "^3.0.3",
"@0x/abi-gen-wrappers": "^1.0.4",
"@0x/assert": "^1.0.16",
"@0x/base-contract": "^3.0.5",
"@0x/contract-artifacts": "^1.1.0",
"@0x/json-schemas": "^2.0.1",
"@0x/json-schemas": "^2.1.0",
"@0x/types": "^1.2.1",
"@0x/typescript-typings": "^3.0.4",
"@0x/utils": "^2.0.4",
"@0x/web3-wrapper": "^3.1.1",
"@0x/web3-wrapper": "^3.1.3",
"@types/node": "*",
"bn.js": "^4.11.8",
"ethereum-types": "^1.1.2",

View File

@@ -1,3 +1,4 @@
import { SignedOrder } from '@0x/types';
import { BigNumber } from '@0x/utils';
/**
@@ -17,6 +18,6 @@ export abstract class AbstractOrderFilledCancelledFetcher {
* @param orderHash OrderHash of order we are interested in
* @return Whether or not the order is cancelled
*/
public abstract async isOrderCancelledAsync(orderHash: string): Promise<boolean>;
public abstract async isOrderCancelledAsync(signedOrder: SignedOrder): Promise<boolean>;
public abstract getZRXAssetData(): string;
}

View File

@@ -1,8 +1,9 @@
import { SignedOrder } from '@0x/types';
import { BigNumber } from '@0x/utils';
export abstract class AbstractOrderFilledCancelledLazyStore {
public abstract async getFilledTakerAmountAsync(orderHash: string): Promise<BigNumber>;
public abstract async getIsCancelledAsync(orderHash: string): Promise<boolean>;
public abstract async getIsCancelledAsync(signedOrder: SignedOrder): Promise<boolean>;
public abstract setFilledTakerAmount(orderHash: string, balance: BigNumber): void;
public abstract deleteFilledTakerAmount(orderHash: string): void;
public abstract setIsCancelled(orderHash: string, isCancelled: boolean): void;

View File

@@ -117,7 +117,7 @@ export class OrderStateUtils {
public async getOpenOrderStateAsync(signedOrder: SignedOrder, transactionHash?: string): Promise<OrderState> {
const orderRelevantState = await this.getOpenOrderRelevantStateAsync(signedOrder);
const orderHash = orderHashUtils.getOrderHashHex(signedOrder);
const isOrderCancelled = await this._orderFilledCancelledFetcher.isOrderCancelledAsync(orderHash);
const isOrderCancelled = await this._orderFilledCancelledFetcher.isOrderCancelledAsync(signedOrder);
const sidedOrderRelevantState = {
isMakerSide: true,
traderBalance: orderRelevantState.makerBalance,
@@ -256,7 +256,7 @@ export class OrderStateUtils {
const filledTakerAssetAmount = await this._orderFilledCancelledFetcher.getFilledTakerAmountAsync(orderHash);
const totalMakerAssetAmount = signedOrder.makerAssetAmount;
const totalTakerAssetAmount = signedOrder.takerAssetAmount;
const isOrderCancelled = await this._orderFilledCancelledFetcher.isOrderCancelledAsync(orderHash);
const isOrderCancelled = await this._orderFilledCancelledFetcher.isOrderCancelledAsync(signedOrder);
const remainingTakerAssetAmount = isOrderCancelled
? new BigNumber(0)
: totalTakerAssetAmount.minus(filledTakerAssetAmount);

View File

@@ -1,4 +1,4 @@
import { RevertReason, SignedOrder } from '@0x/types';
import { ExchangeContractErrs, RevertReason, SignedOrder } from '@0x/types';
import { BigNumber } from '@0x/utils';
import { Provider } from 'ethereum-types';
import * as _ from 'lodash';
@@ -17,6 +17,7 @@ import { utils } from './utils';
*/
export class OrderValidationUtils {
private readonly _orderFilledCancelledFetcher: AbstractOrderFilledCancelledFetcher;
private readonly _provider: Provider;
/**
* A Typescript implementation mirroring the implementation of isRoundingError in the
* Exchange smart contract
@@ -57,65 +58,53 @@ export class OrderValidationUtils {
senderAddress: string,
zrxAssetData: string,
): Promise<void> {
try {
const fillMakerTokenAmount = utils.getPartialAmountFloor(
fillTakerAssetAmount,
signedOrder.takerAssetAmount,
signedOrder.makerAssetAmount,
);
await exchangeTradeEmulator.transferFromAsync(
signedOrder.makerAssetData,
signedOrder.makerAddress,
senderAddress,
fillMakerTokenAmount,
TradeSide.Maker,
TransferType.Trade,
);
await exchangeTradeEmulator.transferFromAsync(
signedOrder.takerAssetData,
senderAddress,
signedOrder.makerAddress,
fillTakerAssetAmount,
TradeSide.Taker,
TransferType.Trade,
);
const makerFeeAmount = utils.getPartialAmountFloor(
fillTakerAssetAmount,
signedOrder.takerAssetAmount,
signedOrder.makerFee,
);
await exchangeTradeEmulator.transferFromAsync(
zrxAssetData,
signedOrder.makerAddress,
signedOrder.feeRecipientAddress,
makerFeeAmount,
TradeSide.Maker,
TransferType.Fee,
);
const takerFeeAmount = utils.getPartialAmountFloor(
fillTakerAssetAmount,
signedOrder.takerAssetAmount,
signedOrder.takerFee,
);
await exchangeTradeEmulator.transferFromAsync(
zrxAssetData,
senderAddress,
signedOrder.feeRecipientAddress,
takerFeeAmount,
TradeSide.Taker,
TransferType.Fee,
);
} catch (err) {
throw new Error(RevertReason.TransferFailed);
}
}
private static _validateRemainingFillAmountNotZeroOrThrow(
takerAssetAmount: BigNumber,
filledTakerTokenAmount: BigNumber,
): void {
if (takerAssetAmount.eq(filledTakerTokenAmount)) {
throw new Error(RevertReason.OrderUnfillable);
}
const fillMakerTokenAmount = utils.getPartialAmountFloor(
fillTakerAssetAmount,
signedOrder.takerAssetAmount,
signedOrder.makerAssetAmount,
);
await exchangeTradeEmulator.transferFromAsync(
signedOrder.makerAssetData,
signedOrder.makerAddress,
senderAddress,
fillMakerTokenAmount,
TradeSide.Maker,
TransferType.Trade,
);
await exchangeTradeEmulator.transferFromAsync(
signedOrder.takerAssetData,
senderAddress,
signedOrder.makerAddress,
fillTakerAssetAmount,
TradeSide.Taker,
TransferType.Trade,
);
const makerFeeAmount = utils.getPartialAmountFloor(
fillTakerAssetAmount,
signedOrder.takerAssetAmount,
signedOrder.makerFee,
);
await exchangeTradeEmulator.transferFromAsync(
zrxAssetData,
signedOrder.makerAddress,
signedOrder.feeRecipientAddress,
makerFeeAmount,
TradeSide.Maker,
TransferType.Fee,
);
const takerFeeAmount = utils.getPartialAmountFloor(
fillTakerAssetAmount,
signedOrder.takerAssetAmount,
signedOrder.takerFee,
);
await exchangeTradeEmulator.transferFromAsync(
zrxAssetData,
senderAddress,
signedOrder.feeRecipientAddress,
takerFeeAmount,
TradeSide.Taker,
TransferType.Fee,
);
}
private static _validateOrderNotExpiredOrThrow(expirationTimeSeconds: BigNumber): void {
const currentUnixTimestampSec = utils.getCurrentUnixTimestampSec();
@@ -128,9 +117,13 @@ export class OrderValidationUtils {
* @param orderFilledCancelledFetcher A module that implements the AbstractOrderFilledCancelledFetcher
* @return An instance of OrderValidationUtils
*/
constructor(orderFilledCancelledFetcher: AbstractOrderFilledCancelledFetcher) {
constructor(orderFilledCancelledFetcher: AbstractOrderFilledCancelledFetcher, provider: Provider) {
this._orderFilledCancelledFetcher = orderFilledCancelledFetcher;
this._provider = provider;
}
// TODO(fabio): remove this method once the smart contracts have been refactored
// to return helpful revert reasons instead of ORDER_UNFILLABLE. Instruct devs
// to make "calls" to validate order fillability + getOrderInfo for fillable amount.
/**
* Validate if the supplied order is fillable, and throw if it isn't
* @param exchangeTradeEmulator ExchangeTradeEmulator instance
@@ -146,12 +139,29 @@ export class OrderValidationUtils {
expectedFillTakerTokenAmount?: BigNumber,
): Promise<void> {
const orderHash = orderHashUtils.getOrderHashHex(signedOrder);
const filledTakerTokenAmount = await this._orderFilledCancelledFetcher.getFilledTakerAmountAsync(orderHash);
OrderValidationUtils._validateRemainingFillAmountNotZeroOrThrow(
signedOrder.takerAssetAmount,
filledTakerTokenAmount,
const isValidSignature = await signatureUtils.isValidSignatureAsync(
this._provider,
orderHash,
signedOrder.signature,
signedOrder.makerAddress,
);
OrderValidationUtils._validateOrderNotExpiredOrThrow(signedOrder.expirationTimeSeconds);
if (!isValidSignature) {
throw new Error(RevertReason.InvalidOrderSignature);
}
const isCancelled = await this._orderFilledCancelledFetcher.isOrderCancelledAsync(signedOrder);
if (isCancelled) {
throw new Error('CANCELLED');
}
const filledTakerTokenAmount = await this._orderFilledCancelledFetcher.getFilledTakerAmountAsync(orderHash);
if (signedOrder.takerAssetAmount.eq(filledTakerTokenAmount)) {
throw new Error('FULLY_FILLED');
}
try {
OrderValidationUtils._validateOrderNotExpiredOrThrow(signedOrder.expirationTimeSeconds);
} catch (err) {
throw new Error('EXPIRED');
}
let fillTakerAssetAmount = signedOrder.takerAssetAmount.minus(filledTakerTokenAmount);
if (!_.isUndefined(expectedFillTakerTokenAmount)) {
fillTakerAssetAmount = expectedFillTakerTokenAmount;
@@ -198,10 +208,9 @@ export class OrderValidationUtils {
throw new Error(OrderError.InvalidSignature);
}
const filledTakerTokenAmount = await this._orderFilledCancelledFetcher.getFilledTakerAmountAsync(orderHash);
OrderValidationUtils._validateRemainingFillAmountNotZeroOrThrow(
signedOrder.takerAssetAmount,
filledTakerTokenAmount,
);
if (signedOrder.takerAssetAmount.eq(filledTakerTokenAmount)) {
throw new Error(RevertReason.OrderUnfillable);
}
if (signedOrder.takerAddress !== constants.NULL_ADDRESS && signedOrder.takerAddress !== takerAddress) {
throw new Error(RevertReason.InvalidTaker);
}
@@ -210,13 +219,30 @@ export class OrderValidationUtils {
const desiredFillTakerTokenAmount = remainingTakerTokenAmount.lessThan(fillTakerAssetAmount)
? remainingTakerTokenAmount
: fillTakerAssetAmount;
await OrderValidationUtils.validateFillOrderBalancesAllowancesThrowIfInvalidAsync(
exchangeTradeEmulator,
signedOrder,
desiredFillTakerTokenAmount,
takerAddress,
zrxAssetData,
);
try {
await OrderValidationUtils.validateFillOrderBalancesAllowancesThrowIfInvalidAsync(
exchangeTradeEmulator,
signedOrder,
desiredFillTakerTokenAmount,
takerAddress,
zrxAssetData,
);
} catch (err) {
const transferFailedErrorMessages = [
ExchangeContractErrs.InsufficientMakerBalance,
ExchangeContractErrs.InsufficientMakerFeeBalance,
ExchangeContractErrs.InsufficientTakerBalance,
ExchangeContractErrs.InsufficientTakerFeeBalance,
ExchangeContractErrs.InsufficientMakerAllowance,
ExchangeContractErrs.InsufficientMakerFeeAllowance,
ExchangeContractErrs.InsufficientTakerAllowance,
ExchangeContractErrs.InsufficientTakerFeeAllowance,
];
if (_.includes(transferFailedErrorMessages, err.message)) {
throw new Error(RevertReason.TransferFailed);
}
throw err;
}
const wouldRoundingErrorOccur = OrderValidationUtils.isRoundingErrorFloor(
desiredFillTakerTokenAmount,
@@ -228,33 +254,4 @@ export class OrderValidationUtils {
}
return filledTakerTokenAmount;
}
/**
* Validate a call to fillOrKillOrder and throw if it would fail
* @param exchangeTradeEmulator ExchangeTradeEmulator to use
* @param provider Web3 provider to use for JSON RPC requests
* @param signedOrder SignedOrder of interest
* @param fillTakerAssetAmount Amount we'd like to fill the order for
* @param takerAddress The taker of the order
* @param zrxAssetData ZRX asset data
*/
public async validateFillOrKillOrderThrowIfInvalidAsync(
exchangeTradeEmulator: ExchangeTransferSimulator,
provider: Provider,
signedOrder: SignedOrder,
fillTakerAssetAmount: BigNumber,
takerAddress: string,
zrxAssetData: string,
): Promise<void> {
const filledTakerTokenAmount = await this.validateFillOrderThrowIfInvalidAsync(
exchangeTradeEmulator,
provider,
signedOrder,
fillTakerAssetAmount,
takerAddress,
zrxAssetData,
);
if (filledTakerTokenAmount !== fillTakerAssetAmount) {
throw new Error(RevertReason.OrderUnfillable);
}
}
}

View File

@@ -1,8 +1,10 @@
import { SignedOrder } from '@0x/types';
import { BigNumber } from '@0x/utils';
import * as _ from 'lodash';
import { AbstractOrderFilledCancelledFetcher } from '../abstract/abstract_order_filled_cancelled_fetcher';
import { AbstractOrderFilledCancelledLazyStore } from '../abstract/abstract_order_filled_cancelled_lazy_store';
import { orderHashUtils } from '../order_hash';
/**
* Copy on read store for balances/proxyAllowances of tokens/accounts
@@ -58,9 +60,10 @@ export class OrderFilledCancelledLazyStore implements AbstractOrderFilledCancell
* @param orderHash OrderHash from order of interest
* @return Whether the order has been cancelled
*/
public async getIsCancelledAsync(orderHash: string): Promise<boolean> {
public async getIsCancelledAsync(signedOrder: SignedOrder): Promise<boolean> {
const orderHash = orderHashUtils.getOrderHashHex(signedOrder);
if (_.isUndefined(this._isCancelled[orderHash])) {
const isCancelled = await this._orderFilledCancelledFetcher.isOrderCancelledAsync(orderHash);
const isCancelled = await this._orderFilledCancelledFetcher.isOrderCancelledAsync(signedOrder);
this.setIsCancelled(orderHash, isCancelled);
}
const cachedIsCancelled = this._isCancelled[orderHash]; // tslint:disable-line:boolean-naming

View File

@@ -1,3 +1,4 @@
import { SignedOrder } from '@0x/types';
import { BigNumber } from '@0x/utils';
import * as chai from 'chai';
import 'mocha';
@@ -33,7 +34,7 @@ describe('OrderStateUtils', () => {
async getFilledTakerAmountAsync(_orderHash: string): Promise<BigNumber> {
return filledAmount;
},
async isOrderCancelledAsync(_orderHash: string): Promise<boolean> {
async isOrderCancelledAsync(_signedOrder: SignedOrder): Promise<boolean> {
return cancelled;
},
getZRXAssetData(): string {

View File

@@ -1,4 +1,27 @@
[
{
"version": "2.2.3",
"changes": [
{
"note": "Start jsonRpcRequestId at 1, not 0 as 0 breaks the web3.js websocket RPC provider",
"pr": 1227
},
{
"note":
"Fix the bug when order watcher was trying to convert undefined to an object in case of CancelUpTo event"
}
],
"timestamp": 1542134075
},
{
"timestamp": 1542028948,
"version": "2.2.2",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "2.2.1",
"changes": [

View File

@@ -5,6 +5,15 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v2.2.3 - _November 13, 2018_
* Start jsonRpcRequestId at 1, not 0 as 0 breaks the web3.js websocket RPC provider (#1227)
* Fix the bug when order watcher was trying to convert undefined to an object in case of CancelUpTo event
## v2.2.2 - _November 12, 2018_
* Dependencies updated
## v2.2.1 - _November 9, 2018_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/order-watcher",
"version": "2.2.1",
"version": "2.2.3",
"description": "An order watcher daemon that watches for order validity",
"keywords": [
"0x",
@@ -33,8 +33,8 @@
"node": ">=6.0.0"
},
"devDependencies": {
"@0x/dev-utils": "^1.0.14",
"@0x/migrations": "^2.0.1",
"@0x/dev-utils": "^1.0.16",
"@0x/migrations": "^2.0.3",
"@0x/tslint-config": "^1.0.10",
"@types/bintrees": "^1.0.2",
"@types/lodash": "4.14.104",
@@ -57,19 +57,19 @@
"typescript": "3.0.1"
},
"dependencies": {
"@0x/abi-gen-wrappers": "^1.0.2",
"@0x/assert": "^1.0.15",
"@0x/base-contract": "^3.0.3",
"@0x/abi-gen-wrappers": "^1.0.4",
"@0x/assert": "^1.0.16",
"@0x/base-contract": "^3.0.5",
"@0x/contract-addresses": "^1.1.0",
"@0x/contract-artifacts": "^1.1.0",
"@0x/contract-wrappers": "^3.0.1",
"@0x/fill-scenarios": "^1.0.9",
"@0x/json-schemas": "^2.0.1",
"@0x/order-utils": "^2.0.1",
"@0x/contract-wrappers": "^4.0.1",
"@0x/fill-scenarios": "^1.0.11",
"@0x/json-schemas": "^2.1.0",
"@0x/order-utils": "^3.0.1",
"@0x/types": "^1.2.1",
"@0x/typescript-typings": "^3.0.4",
"@0x/utils": "^2.0.4",
"@0x/web3-wrapper": "^3.1.1",
"@0x/web3-wrapper": "^3.1.3",
"bintrees": "^1.0.2",
"ethereum-types": "^1.1.2",
"ethereumjs-blockstream": "6.0.0",

View File

@@ -50,7 +50,7 @@ export class DependentOrderHashesTracker {
return uniqueOrderHashList;
}
public getDependentOrderHashesByMaker(makerAddress: string): string[] {
const dependentOrderHashes = Array.from(this._orderHashesByMakerAddress[makerAddress]);
const dependentOrderHashes = Array.from(this._orderHashesByMakerAddress[makerAddress] || {});
return dependentOrderHashes;
}
public getDependentOrderHashesByAssetDataByMaker(makerAddress: string, assetData: string): string[] {

View File

@@ -1,4 +1,22 @@
[
{
"timestamp": 1542134075,
"version": "1.0.17",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1542028948,
"version": "1.0.16",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "1.0.15",
"changes": [

View File

@@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v1.0.17 - _November 13, 2018_
* Dependencies updated
## v1.0.16 - _November 12, 2018_
* Dependencies updated
## v1.0.15 - _November 9, 2018_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/react-docs",
"version": "1.0.15",
"version": "1.0.17",
"engines": {
"node": ">=6.12"
},
@@ -24,7 +24,7 @@
"url": "https://github.com/0xProject/0x-monorepo.git"
},
"devDependencies": {
"@0x/dev-utils": "^1.0.14",
"@0x/dev-utils": "^1.0.16",
"@0x/tslint-config": "^1.0.10",
"@types/compare-versions": "^3.0.0",
"@types/styled-components": "^4.0.0",
@@ -34,7 +34,7 @@
"typescript": "3.0.1"
},
"dependencies": {
"@0x/react-shared": "^1.0.18",
"@0x/react-shared": "^1.0.20",
"@0x/types": "^1.2.1",
"@0x/utils": "^2.0.4",
"@types/lodash": "4.14.104",

View File

@@ -1,4 +1,22 @@
[
{
"timestamp": 1542134075,
"version": "1.0.20",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1542028948,
"version": "1.0.19",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "1.0.18",
"changes": [

View File

@@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v1.0.20 - _November 13, 2018_
* Dependencies updated
## v1.0.19 - _November 12, 2018_
* Dependencies updated
## v1.0.18 - _November 9, 2018_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/react-shared",
"version": "1.0.18",
"version": "1.0.20",
"engines": {
"node": ">=6.12"
},
@@ -25,7 +25,7 @@
"url": "https://github.com/0xProject/0x-monorepo.git"
},
"devDependencies": {
"@0x/dev-utils": "^1.0.14",
"@0x/dev-utils": "^1.0.16",
"@0x/tslint-config": "^1.0.10",
"make-promises-safe": "^1.1.0",
"shx": "^0.2.2",

View File

@@ -1,4 +1,22 @@
[
{
"timestamp": 1542134075,
"version": "1.1.11",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1542028948,
"version": "1.1.10",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "1.1.9",
"changes": [

View File

@@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v1.1.11 - _November 13, 2018_
* Dependencies updated
## v1.1.10 - _November 12, 2018_
* Dependencies updated
## v1.1.9 - _November 9, 2018_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/sol-compiler",
"version": "1.1.9",
"version": "1.1.11",
"engines": {
"node": ">=6.12"
},
@@ -42,7 +42,7 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/packages/sol-compiler/README.md",
"devDependencies": {
"@0x/dev-utils": "^1.0.14",
"@0x/dev-utils": "^1.0.16",
"@0x/tslint-config": "^1.0.10",
"@types/mkdirp": "^0.5.2",
"@types/require-from-string": "^1.2.0",
@@ -65,13 +65,13 @@
"zeppelin-solidity": "1.8.0"
},
"dependencies": {
"@0x/assert": "^1.0.15",
"@0x/json-schemas": "^2.0.1",
"@0x/assert": "^1.0.16",
"@0x/json-schemas": "^2.1.0",
"@0x/sol-resolver": "^1.0.16",
"@0x/types": "^1.2.1",
"@0x/typescript-typings": "^3.0.4",
"@0x/utils": "^2.0.4",
"@0x/web3-wrapper": "^3.1.1",
"@0x/web3-wrapper": "^3.1.3",
"@types/yargs": "^11.0.0",
"chalk": "^2.3.0",
"ethereum-types": "^1.1.2",

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