Compare commits

..

66 Commits

Author SHA1 Message Date
Leonid Logvinov
633e3129d4 Update yarn.lock 2018-01-24 17:01:27 +01:00
Leonid
877bdce4c8 Merge pull request #341 from 0xProject/fix/zrx-address
Fix the bug making it impossible to specify the custom ZRX address
2018-01-24 15:25:29 +01:00
Leonid Logvinov
6e1fbd2d97 Update the CHANGELOG 2018-01-24 15:20:03 +01:00
Leonid Logvinov
36bfe62a8f Fix the bug making it impossible to specify the custom ZRX address 2018-01-24 15:17:56 +01:00
Fabio Berger
8a858501f2 Fix fill/cancel order by looking for NoError instead of empty blockchainErr given the BlockchainErrs type refactor 2018-01-21 17:48:32 +01:00
Leonid
e1af25c8a6 Merge pull request #323 from 0xProject/feature/separate-deployer
Move deployer to a separate package
2018-01-19 13:43:32 +01:00
Leonid
6091f818da Merge branch 'development' into feature/separate-deployer 2018-01-19 13:39:57 +01:00
Leonid Logvinov
a45f9b4802 Add a comment about a yarn bug 2018-01-19 13:37:41 +01:00
Fabio Berger
9ccf63b44a Add our mainnet and kovan nodes as backups for Portal requests 2018-01-19 11:33:35 +08:00
Fabio Berger
d34135ae43 Fix bug hiding the user info from topBar 2018-01-19 11:26:03 +08:00
Jacob Evans
a81f6f9ad1 Merge pull request #328 from 0xProject/fix/website/alphanumeric-token-symbol
Allow Token symbols to be alphanumeric
2018-01-19 13:41:29 +11:00
Brandon Millman
8a80b10cc2 Add dev-utils package to top level README 2018-01-18 17:23:29 -08:00
Jacob Evans
22b1ee132a Merge pull request #324 from 0xProject/fix/0x.js/negativeFillValues
Reject negative amounts in public methods
2018-01-19 12:19:14 +11:00
Jacob Evans
ab7f681f15 Prettier newline 2018-01-19 11:35:02 +11:00
Jacob Evans
2ac806ef08 Prettier 2018-01-19 10:51:57 +11:00
Jacob Evans
13ec8ed03c Allow Token symbols to be alphanumeric 2018-01-19 10:42:37 +11:00
Jacob Evans
fb77817c2d Update CHANGELOG, rebase on development 2018-01-19 10:33:25 +11:00
Jacob Evans
ceb8a492b1 Should not -> cannot 2018-01-19 10:31:06 +11:00
Jacob Evans
cfc868bf4d Reject negative amounts in isValidBaseUnitAmount 2018-01-19 10:31:06 +11:00
Fabio Berger
7b4e2257d8 Re-add changelog for 0x.js 2018-01-19 10:31:06 +11:00
Brandon Millman
4ac6e5477d Merge pull request #326 from 0xProject/greenkeeper/@0xproject/utils-0.2.0
Update @0xproject/utils to the latest version 🚀
2018-01-18 14:50:15 -08:00
Leonid Logvinov
614ea14a7f Fix prettier 2018-01-18 16:18:25 +01:00
Leonid Logvinov
ce45f99006 Update yarn.lock 2018-01-18 15:58:46 +01:00
Leonid
9203813a61 Merge pull request #325 from 0xProject/fix/portal-bugs
Small Fixes/Additions
2018-01-18 15:27:01 +01:00
Leonid Logvinov
ba987b0574 Move tests to a separate folder 2018-01-18 15:17:17 +01:00
Leonid Logvinov
b20f34adb7 Change file layout 2018-01-18 15:12:56 +01:00
Leonid Logvinov
63d0d810b1 Add bin definition 2018-01-18 14:44:53 +01:00
Leonid Logvinov
5491400684 Add postpublish scripts and README 2018-01-18 14:43:10 +01:00
Leonid Logvinov
6a5165e9b3 Fix a link 2018-01-18 14:39:41 +01:00
Leonid Logvinov
9a7c4442d2 Fix scopes 2018-01-18 14:34:35 +01:00
Leonid Logvinov
0e5363b5c3 Update yarn.lock 2018-01-18 14:26:32 +01:00
Leonid Logvinov
d41bce36be Fix merge conflicts 2018-01-18 14:23:54 +01:00
Leonid Logvinov
1380cd811e Fix CI config 2018-01-18 14:22:49 +01:00
Leonid Logvinov
d99bb3a87c Fix merge conflicts 2018-01-18 14:21:15 +01:00
Leonid Logvinov
4b9501318d Move deployer to a separate package 2018-01-18 14:18:51 +01:00
Leonid
e5eec04f92 Merge pull request #322 from 0xProject/fix/ci-time
Speed-up CI
2018-01-18 14:16:53 +01:00
Fabio Berger
f9c21efc30 Use intervalUtils.clearAsyncExcludingInterval instead of calling clearInterval directly for grepability 2018-01-18 19:29:54 +08:00
greenkeeper[bot]
ae72b71895 chore(package): update @0xproject/utils to version 0.2.0 2018-01-18 10:09:13 +00:00
Brandon Millman
87e3fe725d Run prettier to revert formatting changes made by the lerna publish step 2018-01-18 00:21:52 -08:00
Fabio Berger
807d9e3eef Add discourse forum to Community section of website footer 2018-01-18 15:20:34 +08:00
Fabio Berger
9e569b3791 Remove dead-code 2018-01-18 15:20:15 +08:00
Fabio Berger
024f093585 Fix Portal topbar so that it displays the mobile menu 2018-01-18 15:02:53 +08:00
Fabio Berger
996e9e9102 Add missing onError callbacks 2018-01-18 15:02:36 +08:00
Brandon Millman
d58bfb46cf Publish
- 0x.js@0.30.0
 - @0xproject/abi-gen@0.1.2
 - @0xproject/assert@0.0.11
 - chai-as-promised-typescript-typings@0.0.4
 - chai-typescript-typings@0.0.2
 - @0xproject/connect@0.5.0
 - contracts@2.1.4
 - @0xproject/dev-utils@0.0.5
 - @0xproject/json-schemas@0.7.3
 - @0xproject/kovan_faucets@1.0.5
 - @0xproject/monorepo-scripts@0.1.4
 - @0xproject/subproviders@0.3.1
 - @0xproject/tslint-config@0.4.2
 - @0xproject/types@0.1.4
 - @0xproject/utils@0.2.0
 - web3-typescript-typings@0.9.4
 - @0xproject/web3-wrapper@0.1.5
 - @0xproject/website@0.0.7
2018-01-17 22:45:09 -08:00
Fabio Berger
eb0d7df50b Fix balance page copy to refer to the Wrap ETH tab instead of a "convert" button 2018-01-18 14:27:12 +08:00
Leonid Logvinov
b4375d6f64 Enable restrict-plus-operands and fix issues detected 2018-01-17 16:14:25 +01:00
Leonid Logvinov
9f47c72d31 Remove unused dependencies 2018-01-17 16:07:49 +01:00
Leonid Logvinov
de3bf03f42 Add --frozen-lockfile flag on CI 2018-01-17 15:55:58 +01:00
Leonid Logvinov
59a39ac57d Fix a stupid RPC bug which caused the port togo over 65535 2018-01-17 15:35:14 +01:00
Leonid Logvinov
df9c2b193e Remove trailing slash 2018-01-16 21:28:26 +01:00
Leonid Logvinov
3894311d68 Test deployer separately from contracts 2018-01-16 21:11:30 +01:00
Leonid Logvinov
35501dd4fc Fix ignore configuration 2018-01-16 16:17:20 +01:00
Leonid Logvinov
e2ca713658 Fix the glob pattern for exclusion 2018-01-16 16:03:06 +01:00
Leonid Logvinov
a45de6d427 Return is pensing events are undefined 2018-01-16 15:50:15 +01:00
Leonid Logvinov
a350638526 Upgrade testrpc to 6.0.3 to avoid some race-conditions 2018-01-16 15:40:20 +01:00
Leonid Logvinov
59f9605ed9 Run testrpc for rest tests 2018-01-16 15:26:15 +01:00
Leonid Logvinov
9521bf8d4f Separate contracts tests from others 2018-01-16 15:20:15 +01:00
Leonid Logvinov
7c1c94d39b Change cached directory 2018-01-16 14:36:04 +01:00
Leonid Logvinov
8a74963815 Respore dependency cache 2018-01-16 14:31:28 +01:00
Leonid Logvinov
3ebd8b7f45 Revert "Don't run testrpc for the rest of the tests"
This reverts commit ae8cb2e6a8.
2018-01-16 14:11:17 +01:00
Leonid Logvinov
ae8cb2e6a8 Don't run testrpc for the rest of the tests 2018-01-16 14:05:11 +01:00
Leonid Logvinov
1ccb978612 Split tests into two bundles 2018-01-16 14:04:02 +01:00
Leonid Logvinov
7040a01cf2 Remove umd tests 2018-01-16 14:01:46 +01:00
Leonid Logvinov
6bc0e815e9 Add caching between steps 2018-01-16 13:54:13 +01:00
Leonid Logvinov
593f7e826c Specify the executor 2018-01-16 13:45:36 +01:00
Leonid Logvinov
835fa0af13 Test workflow 2018-01-16 13:44:38 +01:00
86 changed files with 593 additions and 208 deletions

View File

@@ -6,24 +6,117 @@ jobs:
- image: circleci/node:6.12
environment:
CONTRACTS_COMMIT_HASH: '9ed05f5'
working_directory: ~/repo
steps:
- checkout
- run: echo 'export PATH=$HOME/CIRCLE_PROJECT_REPONAME/node_modules/.bin:$PATH' >> $BASH_ENV
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- run:
name: yarn
command: yarn
command: yarn --frozen-lockfile
- save_cache:
key: dependency-cache-{{ checksum "package.json" }}
paths:
- ~/.cache/yarn
- ./node_modules
- run: wget https://s3.amazonaws.com/testrpc-shapshots/${CONTRACTS_COMMIT_HASH}.zip
- run: unzip ${CONTRACTS_COMMIT_HASH}.zip -d testrpc_snapshot
- run: node ./node_modules/lerna/bin/lerna.js bootstrap
- run: yarn lerna:run build
- save_cache:
key: repo-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo
test-0xjs:
docker:
- image: circleci/node:6.12
working_directory: ~/repo
steps:
- restore_cache:
keys:
- repo-{{ .Environment.CIRCLE_SHA1 }}
- run:
name: testrpc
command: npm run testrpc -- --db testrpc_snapshot
background: true
- run: yarn lerna:run test:circleci
- run: yarn lerna:run --scope 0x.js test:circleci
test-contracts:
docker:
- image: circleci/node:6.12
working_directory: ~/repo
steps:
- restore_cache:
keys:
- repo-{{ .Environment.CIRCLE_SHA1 }}
- run:
name: testrpc
command: npm run testrpc -- --db testrpc_snapshot
background: true
- run: yarn lerna:run --scope contracts test:circleci
test-deployer:
docker:
- image: circleci/node:6.12
working_directory: ~/repo
steps:
- restore_cache:
keys:
- repo-{{ .Environment.CIRCLE_SHA1 }}
- run:
name: testrpc
command: npm run testrpc -- --db testrpc_snapshot
background: true
- run: yarn lerna:run --scope @0xproject/deployer test:circleci
test-rest:
docker:
- image: circleci/node:6.12
working_directory: ~/repo
steps:
- restore_cache:
keys:
- repo-{{ .Environment.CIRCLE_SHA1 }}
- run:
name: testrpc
command: npm run testrpc -- --db testrpc_snapshot
background: true
- run: yarn lerna:run --ignore contracts --ignore 0x.js --ignore @0xproject/deployer test:circleci
lint:
working_directory: ~/repo
docker:
- image: circleci/node:6.12
steps:
- restore_cache:
keys:
- repo-{{ .Environment.CIRCLE_SHA1 }}
- run: yarn lerna:run lint
prettier:
working_directory: ~/repo
docker:
- image: circleci/node:6.12
steps:
- restore_cache:
keys:
- repo-{{ .Environment.CIRCLE_SHA1 }}
- run: yarn prettier:ci
workflows:
version: 2
main:
jobs:
- build
- test-0xjs:
requires:
- build
- test-contracts:
requires:
- build
- test-deployer:
requires:
- build
- test-rest:
requires:
- build
- prettier:
requires:
- build
- lint:
requires:
- build

View File

@@ -27,12 +27,13 @@ This repository contains all the 0x developer tools written in TypeScript. Our h
| [`@0xproject/abi-gen`](/packages/abi-gen) | [![npm](https://img.shields.io/npm/v/@0xproject/abi-gen.svg)](https://www.npmjs.com/package/@0xproject/abi-gen) | Tool to generate TS wrappers from smart contract ABIs |
| [`@0xproject/assert`](/packages/assert) | [![npm](https://img.shields.io/npm/v/@0xproject/assert.svg)](https://www.npmjs.com/package/@0xproject/assert) | Type and schema assertions used by our packages |
| [`@0xproject/connect`](/packages/connect) | [![npm](https://img.shields.io/npm/v/@0xproject/connect.svg)](https://www.npmjs.com/package/@0xproject/connect) | A Javascript library for interacting with the standard relayer api |
| [`@0xproject/dev-utils`](/packages/dev-utils) | [![npm](https://img.shields.io/npm/v/@0xproject/dev-utils.svg)](https://www.npmjs.com/package/@0xproject/dev-utils) | Dev utils to be shared across 0x projects and packages |
| [`@0xproject/json-schemas`](/packages/json-schemas) | [![npm](https://img.shields.io/npm/v/@0xproject/json-schemas.svg)](https://www.npmjs.com/package/@0xproject/json-schemas) | 0x-related json schemas |
| [`@0xproject/subproviders`](/packages/subproviders) | [![npm](https://img.shields.io/npm/v/@0xproject/subproviders.svg)](https://www.npmjs.com/package/@0xproject/subproviders) | Useful web3 subproviders (e.g LedgerSubprovider) |
| [`@0xproject/tslint-config`](/packages/tslint-config) | [![npm](https://img.shields.io/npm/v/@0xproject/tslint-config.svg)](https://www.npmjs.com/package/@0xproject/tslint-config) | Custom 0x development TSLint rules |
| [`@0xproject/types`](/packages/types) | [![npm](https://img.shields.io/npm/v/@0xproject/types.svg)](https://www.npmjs.com/package/@0xproject/types) | Shared type declarations |
| [`@0xproject/utils`](/packages/utils) | [![npm](https://img.shields.io/npm/v/@0xproject/utils.svg)](https://www.npmjs.com/package/@0xproject/utils) | Shared utilities |
| [`@0xproject/web3-wrapper`](/packages/web3-wrapper) | [![npm](https://img.shields.io/npm/v/@0xproject/web3-wrapper.svg)](https://www.npmjs.com/package/@0xproject/web3-wrapper) | Web3 wrapper | |
| [`@0xproject/web3-wrapper`](/packages/web3-wrapper) | [![npm](https://img.shields.io/npm/v/@0xproject/web3-wrapper.svg)](https://www.npmjs.com/package/@0xproject/web3-wrapper) | Web3 wrapper |
### Private Packages

View File

@@ -15,9 +15,9 @@
"mnemonic": "concert load couple harbor equip island argue ramp clarify fence smart topic"
},
"devDependencies": {
"@0xproject/utils": "^0.1.0",
"@0xproject/utils": "^0.2.0",
"async-child-process": "^1.1.1",
"ethereumjs-testrpc": "6.0.3",
"ethereumjs-testrpc": "^6.0.3",
"lerna": "^2.5.1",
"prettier": "1.9.2",
"publish-release": "0xproject/publish-release",

View File

@@ -1,5 +1,10 @@
# CHANGELOG
## v0.30.1 - _January 18, 2018_
* Fix a bug allowing negative fill values (#212)
* Fix a bug that made it impossible to pass a custom ZRX address (#341)
## v0.30.0 - _January 17, 2018_
* Add an error parameter to the order watcher callback (#312)

View File

@@ -1,6 +1,6 @@
{
"name": "0x.js",
"version": "0.29.2",
"version": "0.30.0",
"description": "A javascript library for interacting with the 0x protocol",
"keywords": ["0x.js", "0xproject", "ethereum", "tokens", "exchange"],
"main": "lib/src/index.js",
@@ -14,21 +14,16 @@
"generate_contract_wrappers":
"node ../abi-gen/lib/index.js --abiGlob 'src/artifacts/@(Exchange|Token|TokenTransferProxy|EtherToken|TokenRegistry|DummyToken).json' --templates contract_templates --output src/contract_wrappers/generated",
"lint": "tslint --project . 'src/**/*.ts' 'test/**/*.ts'",
"test:circleci":
"run-s test:coverage report_test_coverage && if [ $CIRCLE_BRANCH = \"development\" ]; then yarn test:umd; fi",
"test:circleci": "run-s test:coverage report_test_coverage",
"test": "run-s clean test:commonjs",
"test:umd": "./scripts/test_umd.sh",
"test:coverage": "nyc npm run test --all",
"report_test_coverage": "nyc report --reporter=text-lcov | coveralls",
"update_contracts":
"for i in ${npm_package_config_artifacts}; do copyfiles -u 4 ../contracts/build/contracts/$i.json ../0x.js/src/artifacts; done;",
"clean": "shx rm -rf _bundles lib test_temp",
"build:umd:dev": "webpack",
"build:umd:prod": "NODE_ENV=production webpack",
"build:commonjs": "tsc && copyfiles -u 2 './src/artifacts/**/*.json' ./lib/src/artifacts;",
"test:commonjs": "run-s build:commonjs run_mocha",
"pretest:umd": "run-s clean build:umd:dev build:commonjs",
"substitute_umd_bundle": "shx mv _bundles/* lib/src",
"run_mocha": "mocha lib/test/**/*_test.js --timeout 10000 --bail --exit"
},
"config": {
@@ -43,10 +38,10 @@
"node": ">=6.0.0"
},
"devDependencies": {
"@0xproject/abi-gen": "^0.1.1",
"@0xproject/dev-utils": "^0.0.4",
"@0xproject/tslint-config": "^0.4.1",
"@0xproject/types": "^0.1.3",
"@0xproject/abi-gen": "^0.1.2",
"@0xproject/dev-utils": "^0.0.5",
"@0xproject/tslint-config": "^0.4.2",
"@0xproject/types": "^0.1.4",
"@types/bintrees": "^1.0.2",
"@types/jsonschema": "^1.1.1",
"@types/lodash": "^4.14.86",
@@ -57,9 +52,9 @@
"awesome-typescript-loader": "^3.1.3",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"chai-as-promised-typescript-typings": "^0.0.3",
"chai-as-promised-typescript-typings": "^0.0.4",
"chai-bignumber": "^2.0.1",
"chai-typescript-typings": "^0.0.1",
"chai-typescript-typings": "^0.0.2",
"copyfiles": "^1.2.0",
"coveralls": "^3.0.0",
"dirty-chai": "^2.0.1",
@@ -78,21 +73,19 @@
"typedoc": "~0.8.0",
"typescript": "~2.6.1",
"web3-provider-engine": "^13.0.1",
"web3-typescript-typings": "^0.9.3",
"web3-typescript-typings": "^0.9.4",
"webpack": "^3.1.0"
},
"dependencies": {
"@0xproject/assert": "^0.0.10",
"@0xproject/json-schemas": "^0.7.2",
"@0xproject/utils": "^0.1.3",
"@0xproject/web3-wrapper": "^0.1.4",
"@0xproject/assert": "^0.0.11",
"@0xproject/json-schemas": "^0.7.3",
"@0xproject/utils": "^0.2.0",
"@0xproject/web3-wrapper": "^0.1.5",
"bintrees": "^1.0.2",
"bn.js": "^4.11.8",
"compare-versions": "^3.0.1",
"ethereumjs-abi": "^0.6.4",
"ethereumjs-blockstream": "^2.0.6",
"ethereumjs-util": "^5.1.1",
"find-versions": "^2.0.0",
"js-sha3": "^0.6.1",
"lodash": "^4.17.4",
"uuid": "^3.1.0",

View File

@@ -1,6 +0,0 @@
#!/usr/bin/env bash
# This script runs umd tests and cleans up after them while preserving the `return_code` for CI
# UMD tests should only be run after building the commonjs because they reuse some of the commonjs build artifacts
run-s substitute_umd_bundle run_mocha
return_code=$?
exit $return_code

View File

@@ -191,6 +191,7 @@ export class ZeroEx {
this._abiDecoder,
this.token,
config.exchangeContractAddress,
config.zrxContractAddress,
);
this.tokenRegistry = new TokenRegistryWrapper(
this._web3Wrapper,

View File

@@ -87,11 +87,13 @@ export class ExchangeWrapper extends ContractWrapper {
abiDecoder: AbiDecoder,
tokenWrapper: TokenWrapper,
contractAddressIfExists?: string,
zrxContractAddressIfExists?: string,
) {
super(web3Wrapper, networkId, abiDecoder);
this._tokenWrapper = tokenWrapper;
this._orderValidationUtils = new OrderValidationUtils(this);
this._contractAddressIfExists = contractAddressIfExists;
this._zrxContractAddressIfExists = zrxContractAddressIfExists;
}
/**
* Returns the unavailable takerAmount of an order. Unavailable amount is defined as the total

View File

@@ -25,18 +25,6 @@ declare module '*.json' {
/* tslint:enable */
}
// find-version declarations
declare function findVersions(version: string): string[];
declare module 'find-versions' {
export = findVersions;
}
// compare-version declarations
declare function compareVersions(firstVersion: string, secondVersion: string): number;
declare module 'compare-versions' {
export = compareVersions;
}
declare module 'ethereumjs-abi' {
const soliditySHA3: (argTypes: string[], args: any[]) => Buffer;
}

View File

@@ -51,6 +51,10 @@ export class EventWatcher {
}
private async _pollForBlockchainEventsAsync(callback: EventWatcherCallback): Promise<void> {
const pendingEvents = await this._getEventsAsync();
if (_.isUndefined(pendingEvents)) {
// HACK: This should never happen, but happens frequently on CI due to a ganache bug
return;
}
if (pendingEvents.length === 0) {
// HACK: Sometimes when node rebuilds the pending block we get back the empty result.
// We don't want to emit a lot of removal events and bring them back after a couple of miliseconds,

View File

@@ -290,6 +290,7 @@ export interface OrderStateWatcherConfig {
* networkId: The id of the underlying ethereum network your provider is connected to. (1-mainnet, 42-kovan, 50-testrpc)
* gasPrice: Gas price to use with every transaction
* exchangeContractAddress: The address of an exchange contract to use
* zrxContractAddress: The address of the ZRX contract to use
* tokenRegistryContractAddress: The address of a token registry contract to use
* tokenTransferProxyContractAddress: The address of the token transfer proxy contract to use
* orderWatcherConfig: All the configs related to the orderWatcher
@@ -298,6 +299,7 @@ export interface ZeroExConfig {
networkId: number;
gasPrice?: BigNumber;
exchangeContractAddress?: string;
zrxContractAddress?: string;
tokenRegistryContractAddress?: string;
tokenTransferProxyContractAddress?: string;
orderWatcherConfig?: OrderStateWatcherConfig;

View File

@@ -390,6 +390,29 @@ describe('ExchangeWrapper', () => {
).to.not.be.rejectedWith(ExchangeContractErrs.OrderFillAmountZero);
});
});
describe('negative fill amount', async () => {
let signedOrder: SignedOrder;
const negativeFillTakerAmount = new BigNumber(-100);
beforeEach(async () => {
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
makerTokenAddress,
takerTokenAddress,
makerAddress,
takerAddress,
fillableAmount,
);
});
it('should not allow the exchange wrapper to fill if amount is negative', async () => {
return expect(
zeroEx.exchange.fillOrderAsync(
signedOrder,
negativeFillTakerAmount,
shouldThrowOnInsufficientBalanceOrAllowance,
takerAddress,
),
).to.be.rejected();
});
});
});
describe('#batchFillOrdersAsync', () => {
let signedOrder: SignedOrder;
@@ -498,6 +521,30 @@ describe('ExchangeWrapper', () => {
).to.not.be.rejectedWith(ExchangeContractErrs.OrderFillAmountZero);
});
});
describe('negative batch fill amount', async () => {
beforeEach(async () => {
const negativeFillTakerAmount = new BigNumber(-100);
orderFillBatch = [
{
signedOrder,
takerTokenFillAmount,
},
{
signedOrder: anotherSignedOrder,
takerTokenFillAmount: negativeFillTakerAmount,
},
];
});
it('should not allow the exchange wrapper to batch fill if any amount is negative', async () => {
return expect(
zeroEx.exchange.batchFillOrdersAsync(
orderFillBatch,
shouldThrowOnInsufficientBalanceOrAllowance,
takerAddress,
),
).to.be.rejected();
});
});
});
describe('#fillOrdersUpTo', () => {
let signedOrder: SignedOrder;

View File

@@ -1,6 +1,6 @@
export const constants = {
NULL_ADDRESS: '0x0000000000000000000000000000000000000000',
RPC_URL: 'http://localhost:8545/',
RPC_URL: 'http://localhost:8545',
ROPSTEN_NETWORK_ID: 3,
KOVAN_NETWORK_ID: 42,
TESTRPC_NETWORK_ID: 50,

View File

@@ -1,6 +1,6 @@
{
"name": "@0xproject/abi-gen",
"version": "0.1.1",
"version": "0.1.2",
"description": "Generate contract wrappers from ABI and handlebars templates",
"main": "lib/index.js",
"types": "lib/index.d.ts",
@@ -22,7 +22,7 @@
},
"homepage": "https://github.com/0xProject/0x.js/packages/abi-gen/README.md",
"dependencies": {
"@0xproject/utils": "^0.1.3",
"@0xproject/utils": "^0.2.0",
"chalk": "^2.3.0",
"glob": "^7.1.2",
"handlebars": "^4.0.11",
@@ -33,7 +33,7 @@
"yargs": "^10.0.3"
},
"devDependencies": {
"@0xproject/tslint-config": "^0.4.1",
"@0xproject/tslint-config": "^0.4.2",
"@types/glob": "^5.0.33",
"@types/handlebars": "^4.0.36",
"@types/mkdirp": "^0.5.1",
@@ -43,6 +43,6 @@
"shx": "^0.2.2",
"tslint": "5.8.0",
"typescript": "~2.6.1",
"web3-typescript-typings": "^0.9.3"
"web3-typescript-typings": "^0.9.4"
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "@0xproject/assert",
"version": "0.0.10",
"version": "0.0.11",
"description": "Provides a standard way of performing type and schema validation across 0x projects",
"main": "lib/src/index.js",
"types": "lib/src/index.d.ts",
@@ -23,12 +23,12 @@
},
"homepage": "https://github.com/0xProject/0x.js/packages/assert/README.md",
"devDependencies": {
"@0xproject/tslint-config": "^0.4.1",
"@0xproject/tslint-config": "^0.4.2",
"@types/lodash": "^4.14.86",
"@types/mocha": "^2.2.42",
"@types/valid-url": "^1.0.2",
"chai": "^4.0.1",
"chai-typescript-typings": "^0.0.1",
"chai-typescript-typings": "^0.0.2",
"dirty-chai": "^2.0.1",
"mocha": "^4.0.1",
"npm-run-all": "^4.1.2",
@@ -37,8 +37,8 @@
"typescript": "~2.6.1"
},
"dependencies": {
"@0xproject/json-schemas": "^0.7.2",
"@0xproject/utils": "^0.1.3",
"@0xproject/json-schemas": "^0.7.3",
"@0xproject/utils": "^0.2.0",
"lodash": "^4.17.4",
"valid-url": "^1.0.9"
}

View File

@@ -12,6 +12,8 @@ export const assert = {
},
isValidBaseUnitAmount(variableName: string, value: BigNumber) {
assert.isBigNumber(variableName, value);
const isNegative = value.lessThan(0);
this.assert(!isNegative, `${variableName} cannot be a negative number, found value: ${value.toNumber()}`);
const hasDecimals = value.decimalPlaces() !== 0;
this.assert(
!hasDecimals,

View File

@@ -22,6 +22,20 @@ describe('Assertions', () => {
invalidInputs.forEach(input => expect(assert.isBigNumber.bind(assert, variableName, input)).to.throw());
});
});
describe('#isValidBaseUnitAmount', () => {
it('should not throw for valid input', () => {
const validInputs = [new BigNumber(23), new BigNumber('45000000')];
validInputs.forEach(input =>
expect(assert.isValidBaseUnitAmount.bind(assert, variableName, input)).to.not.throw(),
);
});
it('should throw for invalid input', () => {
const invalidInputs = [0, undefined, new BigNumber(3.145), 3.145, new BigNumber(-400)];
invalidInputs.forEach(input =>
expect(assert.isValidBaseUnitAmount.bind(assert, variableName, input)).to.throw(),
);
});
});
describe('#isString', () => {
it('should not throw for valid input', () => {
const validInputs = ['hello', 'goodbye'];

View File

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

View File

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

View File

@@ -1,6 +1,6 @@
{
"name": "@0xproject/connect",
"version": "0.4.1",
"version": "0.5.0",
"description": "A javascript library for interacting with the standard relayer api",
"keywords": ["connect", "0xproject", "ethereum", "tokens", "exchange"],
"main": "lib/src/index.js",
@@ -31,16 +31,16 @@
},
"homepage": "https://github.com/0xProject/0x.js/packages/connect/README.md",
"dependencies": {
"@0xproject/assert": "^0.0.10",
"@0xproject/json-schemas": "^0.7.2",
"@0xproject/utils": "^0.1.3",
"@0xproject/assert": "^0.0.11",
"@0xproject/json-schemas": "^0.7.3",
"@0xproject/utils": "^0.2.0",
"isomorphic-fetch": "^2.2.1",
"lodash": "^4.17.4",
"query-string": "^5.0.1",
"websocket": "^1.0.25"
},
"devDependencies": {
"@0xproject/tslint-config": "^0.4.1",
"@0xproject/tslint-config": "^0.4.2",
"@types/fetch-mock": "^5.12.1",
"@types/lodash": "^4.14.86",
"@types/mocha": "^2.2.42",
@@ -48,8 +48,8 @@
"@types/websocket": "^0.0.34",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"chai-as-promised-typescript-typings": "^0.0.3",
"chai-typescript-typings": "^0.0.1",
"chai-as-promised-typescript-typings": "^0.0.4",
"chai-typescript-typings": "^0.0.2",
"copyfiles": "^1.2.0",
"dirty-chai": "^2.0.1",
"fetch-mock": "^5.13.1",
@@ -59,6 +59,6 @@
"tslint": "5.8.0",
"typedoc": "~0.8.0",
"typescript": "~2.6.1",
"web3-typescript-typings": "^0.9.3"
"web3-typescript-typings": "^0.9.4"
}
}

View File

@@ -1,7 +1,7 @@
{
"private": true,
"name": "contracts",
"version": "2.1.3",
"version": "2.1.4",
"description": "Smart contract components of 0x protocol",
"main": "index.js",
"directories": {
@@ -11,13 +11,13 @@
"build":
"rm -rf ./lib; copyfiles ./build/**/* ./deploy/solc/solc_bin/* ./deploy/test/fixtures/contracts/**/* ./deploy/test/fixtures/contracts/* ./lib; tsc;",
"test": "npm run build; truffle test",
"compile": "npm run build; node lib/deploy/cli.js compile",
"compile:comment":
"Yarn workspaces do not link binaries correctly so we need to reference them directly https://github.com/yarnpkg/yarn/issues/3846",
"compile": "node ../deployer/lib/src/cli.js compile",
"clean": "rm -rf ./lib",
"migrate:truffle": "npm run build; truffle migrate",
"migrate": "npm run build; node lib/deploy/cli.js migrate",
"migrate": "node ../deployer/lib/src/cli.js migrate",
"lint": "tslint --project . 'migrations/**/*.ts' 'test/**/*.ts' 'util/**/*.ts' 'deploy/**/*.ts'",
"test:circleci": "yarn test; yarn test:deployer",
"test:deployer": "npm run build; mocha lib/deploy/test/*_test.js"
"test:circleci": "yarn test"
},
"repository": {
"type": "git",
@@ -30,9 +30,9 @@
},
"homepage": "https://github.com/0xProject/0x.js/packages/contracts/README.md",
"devDependencies": {
"@0xproject/dev-utils": "^0.0.4",
"@0xproject/tslint-config": "^0.4.1",
"@0xproject/types": "^0.1.3",
"@0xproject/dev-utils": "^0.0.5",
"@0xproject/tslint-config": "^0.4.2",
"@0xproject/types": "^0.1.4",
"@types/bluebird": "^3.5.3",
"@types/lodash": "^4.14.86",
"@types/node": "^8.0.53",
@@ -40,9 +40,9 @@
"@types/yargs": "^10.0.0",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"chai-as-promised-typescript-typings": "^0.0.3",
"chai-as-promised-typescript-typings": "^0.0.4",
"chai-bignumber": "^2.0.1",
"chai-typescript-typings": "^0.0.1",
"chai-typescript-typings": "^0.0.2",
"copyfiles": "^1.2.0",
"dirty-chai": "^2.0.1",
"mocha": "^4.0.1",
@@ -52,14 +52,15 @@
"types-bn": "^0.0.1",
"types-ethereumjs-util": "0xProject/types-ethereumjs-util",
"typescript": "~2.6.1",
"web3-typescript-typings": "^0.9.3",
"web3-typescript-typings": "^0.9.4",
"yargs": "^10.0.3"
},
"dependencies": {
"0x.js": "^0.29.2",
"@0xproject/json-schemas": "^0.7.2",
"@0xproject/utils": "^0.1.3",
"@0xproject/web3-wrapper": "^0.1.4",
"0x.js": "^0.30.0",
"@0xproject/deployer": "*",
"@0xproject/json-schemas": "^0.7.3",
"@0xproject/utils": "^0.2.0",
"@0xproject/web3-wrapper": "^0.1.5",
"bluebird": "^3.5.0",
"bn.js": "^4.11.8",
"ethereumjs-abi": "^0.6.4",

View File

@@ -84,15 +84,6 @@ export interface TransactionDataParams {
args: any[];
}
export interface Token {
address?: string;
name: string;
symbol: string;
decimals: number;
ipfsHash: string;
swarmHash: string;
}
export interface MultiSigConfig {
owners: string[];
confirmationsRequired: number;
@@ -103,6 +94,15 @@ export interface MultiSigConfigByNetwork {
[networkName: string]: MultiSigConfig;
}
export interface Token {
address?: string;
name: string;
symbol: string;
decimals: number;
ipfsHash: string;
swarmHash: string;
}
export interface TokenInfoByNetwork {
development: Token[];
live: Token[];

View File

@@ -0,0 +1,73 @@
## @0xproject/deployer
This repository contains a CLI tool that facilitates compiling and deployment of smart contracts.
## Installation
```bash
yarn add @0xproject/deployer
```
## Usage
```bash
node ./node_modules/@0xproject/deployer/lib/cli.js --help
cli.js [command]
Commands:
cli.js compile compile contracts
cli.js migrate compile and deploy contracts using migration scripts
cli.js deploy deploy a single contract with provided arguments
Options:
--version Show version number [boolean]
--contracts-dir path of contracts directory to compile
[string] [default: "/Users/leonidlogvinov/Dev/0x/0x.js/contracts"]
--network-id mainnet=1, kovan=42, testrpc=50 [number] [default: 50]
--should-optimize enable optimizer [boolean] [default: false]
--artifacts-dir path to write contracts artifacts to
[string] [default: "/Users/leonidlogvinov/Dev/0x/0x.js/build/artifacts/"]
--jsonrpc-port port connected to JSON RPC [number] [default: 8545]
--gas-price gasPrice to be used for transactions
[string] [default: "2000000000"]
--account account to use for deploying contracts [string]
--help Show help [boolean]
```
## Contributing
We strongly recommend that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository.
Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
### Install Dependencies
If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
```bash
yarn config set workspaces-experimental true
```
Then install dependencies
```bash
yarn install
```
### Build
```bash
yarn build
```
### Lint
```bash
yarn lint
```
### Run Tests
```bash
yarn test
```

View File

@@ -0,0 +1,43 @@
{
"name": "@0xproject/deployer",
"version": "0.0.1",
"description": "Smart contract deployer of 0x protocol",
"main": "lib/src/cli.js",
"scripts": {
"build": "yarn clean && copyfiles 'test/fixtures/contracts/**/*' src/solc/solc_bin/* ./lib && tsc",
"test": "npm run build; mocha lib/test/*_test.js",
"compile": "npm run build; node lib/src/cli.js compile",
"clean": "rm -rf ./lib",
"migrate": "npm run build; node lib/src/cli.js migrate",
"lint": "tslint --project . 'src/**/*.ts' 'test/**/*.ts'",
"test:circleci": "yarn test"
},
"bin": {
"0x-deployer": "lib/src/cli.js"
},
"repository": {
"type": "git",
"url": "https://github.com/0xProject/0x.js.git"
},
"author": "Amir Bandeali",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/0xProject/0x.js/issues"
},
"homepage": "https://github.com/0xProject/0x.js/packages/deployer/README.md",
"devDependencies": {
"copyfiles": "^1.2.0",
"web3-typescript-typings": "^0.9.3",
"types-bn": "^0.0.1",
"typescript": "~2.6.1"
},
"dependencies": {
"@0xproject/utils": "^0.1.3",
"@0xproject/web3-wrapper": "^0.1.4",
"lodash": "^4.17.4",
"solc": "^0.4.18",
"yargs": "^10.0.3",
"web3-eth-abi": "^1.0.0-beta.24",
"web3": "^0.20.0"
}
}

View File

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

View File

@@ -5,8 +5,8 @@ import * as path from 'path';
import * as Web3 from 'web3';
import * as yargs from 'yargs';
import { commands } from './src/commands';
import { CliOptions, CompilerOptions, DeployerOptions } from './src/utils/types';
import { commands } from './commands';
import { CliOptions, CompilerOptions, DeployerOptions } from './utils/types';
const DEFAULT_OPTIMIZER_ENABLED = false;
const DEFAULT_CONTRACTS_DIR = path.resolve('contracts');

View File

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

View File

@@ -4,7 +4,7 @@ import * as path from 'path';
import solc = require('solc');
import * as Web3 from 'web3';
import { binPaths } from './../solc/bin_paths';
import { binPaths } from './solc/bin_paths';
import { fsWrapper } from './utils/fs_wrapper';
import {
CompilerOptions,
@@ -113,7 +113,6 @@ export class Compiler {
public async compileAllAsync(): Promise<void> {
await this._createArtifactsDirIfDoesNotExistAsync();
this._contractSourcesIfExists = await Compiler._getContractSourcesAsync(this._contractsDir);
const contractBaseNames = _.keys(this._contractSourcesIfExists);
const compiledContractPromises = _.map(contractBaseNames, async (contractBaseName: string): Promise<void> => {
return this._compileContractAsync(contractBaseName);
@@ -167,7 +166,7 @@ export class Compiler {
};
const solcVersion = Compiler._parseSolidityVersion(source);
const fullSolcVersion = binPaths[solcVersion];
const solcBinPath = `./../solc/solc_bin/${fullSolcVersion}`;
const solcBinPath = `./solc/solc_bin/${fullSolcVersion}`;
const solcBin = require(solcBinPath);
const solcInstance = solc.setupMethods(solcBin);

8
packages/deployer/src/globals.d.ts vendored Normal file
View File

@@ -0,0 +1,8 @@
declare module 'solc' {
export function compile(sources: any, optimizerEnabled: number, findImports: (importPath: string) => any): any;
export function setupMethods(solcBin: any): any;
}
declare module 'web3-eth-abi' {
export function encodeParameters(typesArray: string[], parameters: any[]): string;
}

View File

@@ -0,0 +1,10 @@
import { MultiSigConfigByNetwork } from '../../types';
// Make a copy of this file named `multisig.js` and input custom params as needed
export const multiSig: MultiSigConfigByNetwork = {
kovan: {
owners: [],
confirmationsRequired: 0,
secondsRequired: 0,
},
};

View File

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

View File

@@ -2,8 +2,8 @@ import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as _ from 'lodash';
import { Deployer } from './../src/deployer';
import { constants } from './../src/utils/constants';
import { Deployer } from '../deployer';
import { constants } from '../utils/constants';
import { tokenInfo } from './config/token_info';
export const migrator = {

View File

@@ -0,0 +1,23 @@
export interface MultiSigConfig {
owners: string[];
confirmationsRequired: number;
secondsRequired: number;
}
export interface MultiSigConfigByNetwork {
[networkName: string]: MultiSigConfig;
}
export interface Token {
address?: string;
name: string;
symbol: string;
decimals: number;
ipfsHash: string;
swarmHash: string;
}
export interface TokenInfoByNetwork {
development: Token[];
live: Token[];
}

View File

@@ -1,10 +1,10 @@
import * as chai from 'chai';
import 'mocha';
import { Compiler } from './../src/compiler';
import { Deployer } from './../src/deployer';
import { fsWrapper } from './../src/utils/fs_wrapper';
import { CompilerOptions, ContractArtifact, ContractData, DoneCallback } from './../src/utils/types';
import { Compiler } from '../src/compiler';
import { Deployer } from '../src/deployer';
import { fsWrapper } from '../src/utils/fs_wrapper';
import { CompilerOptions, ContractArtifact, ContractData, DoneCallback } from '../src/utils/types';
import { constructor_args, exchange_binary } from './fixtures/exchange_bin';
import { constants } from './util/constants';

View File

@@ -0,0 +1,16 @@
{
"extends": "../../tsconfig",
"compilerOptions": {
"outDir": "lib",
"strictFunctionTypes": false,
"strictNullChecks": false
},
"include": [
"./src/**/*",
"./test/**/*",
"../../node_modules/types-bn/index.d.ts",
"../../node_modules/types-ethereumjs-util/index.d.ts",
"../../node_modules/chai-typescript-typings/index.d.ts",
"../../node_modules/web3-typescript-typings/index.d.ts"
]
}

View File

@@ -1,6 +1,6 @@
{
"name": "@0xproject/dev-utils",
"version": "0.0.4",
"version": "0.0.5",
"description": "0x dev TS utils",
"main": "lib/index.js",
"types": "lib/index.d.ts",
@@ -19,7 +19,7 @@
},
"homepage": "https://github.com/0xProject/0x.js/packages/dev-utils/README.md",
"devDependencies": {
"@0xproject/tslint-config": "^0.4.1",
"@0xproject/tslint-config": "^0.4.2",
"@types/lodash": "^4.14.86",
"npm-run-all": "^4.1.2",
"shx": "^0.2.2",
@@ -29,7 +29,7 @@
"typescript": "~2.6.1"
},
"dependencies": {
"@0xproject/utils": "^0.1.3",
"@0xproject/utils": "^0.2.0",
"ethereumjs-util": "^5.1.2",
"lodash": "^4.17.4",
"request-promise-native": "^1.0.5"

View File

@@ -41,7 +41,7 @@ export class RPC {
method,
params,
});
this._url += 1;
this._id += 1;
return payload;
}
private async _sendAsync(payload: string): Promise<any> {

View File

@@ -1,6 +1,6 @@
{
"name": "@0xproject/json-schemas",
"version": "0.7.2",
"version": "0.7.3",
"description": "0x-related json schemas",
"main": "lib/src/index.js",
"types": "lib/src/index.d.ts",
@@ -27,13 +27,13 @@
"lodash.values": "^4.3.0"
},
"devDependencies": {
"@0xproject/tslint-config": "^0.4.1",
"@0xproject/utils": "^0.1.3",
"@0xproject/tslint-config": "^0.4.2",
"@0xproject/utils": "^0.2.0",
"@types/lodash.foreach": "^4.5.3",
"@types/lodash.values": "^4.3.3",
"@types/mocha": "^2.2.42",
"chai": "^4.0.1",
"chai-typescript-typings": "^0.0.1",
"chai-typescript-typings": "^0.0.2",
"dirty-chai": "^2.0.1",
"lodash.foreach": "^4.5.0",
"mocha": "^4.0.1",

View File

@@ -1,7 +1,7 @@
{
"private": true,
"name": "@0xproject/kovan_faucets",
"version": "1.0.4",
"version": "1.0.5",
"description": "A faucet micro-service that dispenses test ERC20 tokens or Ether",
"main": "server.js",
"scripts": {
@@ -14,8 +14,8 @@
"author": "Fabio Berger",
"license": "Apache-2.0",
"dependencies": {
"0x.js": "^0.29.2",
"@0xproject/utils": "^0.1.3",
"0x.js": "^0.30.0",
"@0xproject/utils": "^0.2.0",
"body-parser": "^1.17.1",
"ethereumjs-tx": "^1.3.3",
"express": "^4.15.2",
@@ -25,7 +25,7 @@
"web3-provider-engine": "^13.0.1"
},
"devDependencies": {
"@0xproject/tslint-config": "^0.4.1",
"@0xproject/tslint-config": "^0.4.2",
"@types/body-parser": "^1.16.1",
"@types/express": "^4.0.35",
"@types/lodash": "^4.14.86",
@@ -36,7 +36,7 @@
"source-map-loader": "^0.1.6",
"tslint": "5.8.0",
"typescript": "~2.6.1",
"web3-typescript-typings": "^0.9.3",
"web3-typescript-typings": "^0.9.4",
"webpack": "^3.1.0",
"webpack-node-externals": "^1.6.0"
}

View File

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

View File

@@ -1,6 +1,6 @@
{
"name": "@0xproject/subproviders",
"version": "0.3.0",
"version": "0.3.1",
"main": "lib/src/index.js",
"types": "lib/src/index.d.ts",
"license": "Apache-2.0",
@@ -17,8 +17,8 @@
"test:integration": "run-s clean build run_mocha_integration"
},
"dependencies": {
"@0xproject/assert": "^0.0.10",
"@0xproject/utils": "^0.1.3",
"@0xproject/assert": "^0.0.11",
"@0xproject/utils": "^0.2.0",
"bn.js": "^4.11.8",
"es6-promisify": "^5.0.0",
"ethereumjs-tx": "^1.3.3",
@@ -31,16 +31,16 @@
"web3-provider-engine": "^13.0.1"
},
"devDependencies": {
"@0xproject/tslint-config": "^0.4.1",
"@0xproject/utils": "^0.1.3",
"@0xproject/tslint-config": "^0.4.2",
"@0xproject/utils": "^0.2.0",
"@types/lodash": "^4.14.86",
"@types/mocha": "^2.2.42",
"@types/node": "^8.0.53",
"awesome-typescript-loader": "^3.1.3",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"chai-as-promised-typescript-typings": "^0.0.3",
"chai-typescript-typings": "^0.0.1",
"chai-as-promised-typescript-typings": "^0.0.4",
"chai-typescript-typings": "^0.0.2",
"dirty-chai": "^2.0.1",
"mocha": "^4.0.1",
"npm-run-all": "^4.1.2",

View File

@@ -1,6 +1,6 @@
{
"name": "@0xproject/tslint-config",
"version": "0.4.1",
"version": "0.4.2",
"description": "Lint rules related to 0xProject for TSLint",
"main": "tslint.json",
"scripts": {

View File

@@ -60,6 +60,7 @@
"prefer-function-over-method": true,
"promise-function-async": true,
"quotemark": [true, "single", "avoid-escape", "jsx-double"],
"restrict-plus-operands": true,
"semicolon": [true, "always"],
"space-before-function-paren": [
true,

View File

@@ -1,6 +1,6 @@
{
"name": "@0xproject/types",
"version": "0.1.3",
"version": "0.1.4",
"description": "0x types",
"main": "lib/index.js",
"types": "lib/index.d.ts",
@@ -19,13 +19,13 @@
},
"homepage": "https://github.com/0xProject/0x.js/packages/types/README.md",
"devDependencies": {
"@0xproject/tslint-config": "^0.4.1",
"@0xproject/tslint-config": "^0.4.2",
"shx": "^0.2.2",
"tslint": "5.8.0",
"typescript": "~2.6.1"
},
"dependencies": {
"@0xproject/utils": "^0.1.3",
"@0xproject/utils": "^0.2.0",
"web3": "^0.20.0"
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "@0xproject/utils",
"version": "0.1.3",
"version": "0.2.0",
"description": "0x TS utils",
"main": "lib/index.js",
"types": "lib/index.d.ts",
@@ -19,7 +19,7 @@
},
"homepage": "https://github.com/0xProject/0x.js/packages/utils/README.md",
"devDependencies": {
"@0xproject/tslint-config": "^0.4.1",
"@0xproject/tslint-config": "^0.4.2",
"@types/lodash": "^4.14.86",
"npm-run-all": "^4.1.2",
"shx": "^0.2.2",

View File

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

View File

@@ -1,6 +1,6 @@
{
"name": "@0xproject/web3-wrapper",
"version": "0.1.4",
"version": "0.1.5",
"description": "Wraps around web3 and gives a nicer interface",
"main": "lib/index.js",
"types": "lib/index.d.ts",
@@ -19,17 +19,17 @@
},
"homepage": "https://github.com/0xProject/0x.js/packages/web3-wrapper/README.md",
"devDependencies": {
"@0xproject/tslint-config": "^0.4.1",
"@0xproject/types": "^0.1.3",
"@0xproject/tslint-config": "^0.4.2",
"@0xproject/types": "^0.1.4",
"@types/lodash": "^4.14.86",
"npm-run-all": "^4.1.2",
"shx": "^0.2.2",
"tslint": "5.8.0",
"typescript": "~2.6.1",
"web3-typescript-typings": "^0.9.3"
"web3-typescript-typings": "^0.9.4"
},
"dependencies": {
"@0xproject/utils": "^0.1.3",
"@0xproject/utils": "^0.2.0",
"lodash": "^4.17.4",
"web3": "^0.20.0"
}

View File

@@ -1,6 +1,6 @@
{
"name": "@0xproject/website",
"version": "0.0.6",
"version": "0.0.7",
"private": true,
"description": "Website and 0x portal dapp",
"scripts": {
@@ -21,9 +21,9 @@
"author": "Fabio Berger",
"license": "Apache-2.0",
"dependencies": {
"0x.js": "^0.29.2",
"@0xproject/subproviders": "^0.3.0",
"@0xproject/utils": "^0.1.3",
"0x.js": "^0.30.0",
"@0xproject/subproviders": "^0.3.1",
"@0xproject/utils": "^0.2.0",
"accounting": "^0.4.1",
"basscss": "^8.0.3",
"blockies": "^0.0.2",
@@ -101,7 +101,7 @@
"style-loader": "0.13.x",
"tslint": "5.8.0",
"typescript": "~2.6.1",
"web3-typescript-typings": "^0.9.3",
"web3-typescript-typings": "^0.9.4",
"webpack": "^3.1.0",
"webpack-dev-middleware": "^1.10.0",
"webpack-dev-server": "^2.5.0"

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@@ -368,14 +368,22 @@ export class Blockchain {
const [currBalance] = await this.getTokenBalanceAndAllowanceAsync(this._userAddress, token.address);
this._zrxPollIntervalId = intervalUtils.setAsyncExcludingInterval(async () => {
const [balance] = await this.getTokenBalanceAndAllowanceAsync(this._userAddress, token.address);
if (!balance.eq(currBalance)) {
this._dispatcher.replaceTokenBalanceByAddress(token.address, balance);
clearInterval(this._zrxPollIntervalId);
this._zrxPollIntervalId = intervalUtils.setAsyncExcludingInterval(
async () => {
const [balance] = await this.getTokenBalanceAndAllowanceAsync(this._userAddress, token.address);
if (!balance.eq(currBalance)) {
this._dispatcher.replaceTokenBalanceByAddress(token.address, balance);
intervalUtils.clearAsyncExcludingInterval(this._zrxPollIntervalId);
delete this._zrxPollIntervalId;
}
},
5000,
(err: Error) => {
utils.consoleLog(`Polling tokenBalance failed: ${err}`);
intervalUtils.clearAsyncExcludingInterval(this._zrxPollIntervalId);
delete this._zrxPollIntervalId;
}
}, 5000);
},
);
}
public async signOrderHashAsync(orderHash: string): Promise<SignatureData> {
utils.assert(!_.isUndefined(this._zeroEx), 'ZeroEx must be instantiated.');
@@ -471,7 +479,7 @@ export class Blockchain {
this._web3Wrapper.updatePrevUserAddress(newUserAddress);
}
public destroy() {
clearInterval(this._zrxPollIntervalId);
intervalUtils.clearAsyncExcludingInterval(this._zrxPollIntervalId);
this._web3Wrapper.destroy();
this._stopWatchingExchangeLogFillEvents();
}

View File

@@ -105,7 +105,7 @@ export class EthWethConversionButton extends React.Component<
}
this.props.onConversionSuccessful();
} catch (err) {
const errMsg = '' + err;
const errMsg = `${err}`;
if (_.includes(errMsg, BlockchainCallErrs.UserHasNoAssociatedAddresses)) {
this.props.dispatcher.updateShouldBlockchainErrDialogBeOpen(true);
} else if (!_.includes(errMsg, 'User denied transaction')) {

View File

@@ -493,7 +493,7 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
await this._checkForUntrackedTokensAndAskToAdd();
}
private async _onFillOrderClickFireAndForgetAsync(): Promise<void> {
if (!_.isEmpty(this.props.blockchainErr) || _.isEmpty(this.props.userAddress)) {
if (this.props.blockchainErr !== BlockchainErrs.NoError || _.isEmpty(this.props.userAddress)) {
this.props.dispatcher.updateShouldBlockchainErrDialogBeOpen(true);
return;
}
@@ -586,7 +586,7 @@ export class FillOrder extends React.Component<FillOrderProps, FillOrderState> {
}
}
private async _onCancelOrderClickFireAndForgetAsync(): Promise<void> {
if (!_.isEmpty(this.props.blockchainErr) || _.isEmpty(this.props.userAddress)) {
if (this.props.blockchainErr !== BlockchainErrs.NoError || _.isEmpty(this.props.userAddress)) {
this.props.dispatcher.updateShouldBlockchainErrDialogBeOpen(true);
return;
}

View File

@@ -13,7 +13,6 @@ interface FooterMenuItem {
title: string;
path?: string;
isExternal?: boolean;
fileName?: string;
}
enum Sections {
@@ -56,25 +55,26 @@ const menuItemsBySection: MenuItemsBySection = {
title: 'Rocket.chat',
isExternal: true,
path: constants.URL_ZEROEX_CHAT,
fileName: 'rocketchat.png',
},
{
title: 'Blog',
isExternal: true,
path: constants.URL_BLOG,
fileName: 'medium.png',
},
{
title: 'Twitter',
isExternal: true,
path: constants.URL_TWITTER,
fileName: 'twitter.png',
},
{
title: 'Reddit',
isExternal: true,
path: constants.URL_REDDIT,
fileName: 'reddit.png',
},
{
title: 'Forum',
isExternal: true,
path: constants.URL_DISCOURSE_FORUM,
},
],
Organization: [
@@ -105,6 +105,7 @@ const titleToIcon: { [title: string]: string } = {
Blog: 'medium.png',
Twitter: 'twitter.png',
Reddit: 'reddit.png',
Forum: 'discourse.png',
};
export interface FooterProps {}

View File

@@ -329,7 +329,7 @@ export class GenerateOrderForm extends React.Component<GenerateOrderFormProps, G
${validationResult.errors}`);
}
} catch (err) {
const errMsg = '' + err;
const errMsg = `${err}`;
if (utils.didUserDenyWeb3Request(errMsg)) {
globalErrMsg = 'User denied sign request';
} else {

View File

@@ -189,8 +189,8 @@ export class NewTokenForm extends React.Component<NewTokenFormProps, NewTokenFor
const tokenWithSymbolExists = !_.isUndefined(_.find(tokens, { symbol }));
if (symbol === '') {
symbolErrText = 'Symbol is required';
} else if (!this._isLetters(symbol)) {
symbolErrText = 'Can only include letters';
} else if (!this._isAlphanumeric(symbol)) {
symbolErrText = 'Can only include alphanumeric characters';
} else if (symbol.length > maxLength) {
symbolErrText = `Max length is ${maxLength}`;
} else if (tokenWithSymbolExists) {
@@ -231,7 +231,7 @@ export class NewTokenForm extends React.Component<NewTokenFormProps, NewTokenFor
private _isInteger(input: string) {
return /^[0-9]+$/i.test(input);
}
private _isLetters(input: string) {
return /^[a-zA-Z]+$/i.test(input);
private _isAlphanumeric(input: string) {
return /^[a-zA-Z0-9]+$/i.test(input);
}
}

View File

@@ -77,7 +77,7 @@ export class AllowanceToggle extends React.Component<AllowanceToggleProps, Allow
this.setState({
isSpinnerVisible: false,
});
const errMsg = '' + err;
const errMsg = `${err}`;
if (_.includes(errMsg, 'User denied transaction')) {
return;
}

View File

@@ -169,7 +169,7 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala
? 'In order to try out the 0x Portal Dapp, request some test ether to pay for \
gas costs. It might take a bit of time for the test ether to show up.'
: 'Ether must be converted to Ether Tokens in order to be tradable via 0x. \
You can convert between Ether and Ether Tokens by clicking the "convert" button below.'}
You can convert between Ether and Ether Tokens from the "Wrap ETH" tab.'}
</div>
<Table selectable={false} style={styles.bgColor}>
<TableHeader displaySelectAll={false} adjustForCheckbox={false}>
@@ -514,7 +514,7 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala
this.props.dispatcher.showFlashMessage(`Successfully minted ${amount.toString(10)} ${token.symbol}`);
return true;
} catch (err) {
const errMsg = '' + err;
const errMsg = `${err}`;
if (_.includes(errMsg, BlockchainCallErrs.UserHasNoAssociatedAddresses)) {
this.props.dispatcher.updateShouldBlockchainErrDialogBeOpen(true);
return false;

View File

@@ -168,14 +168,14 @@ export class TopBar extends React.Component<TopBarProps, TopBarState> {
</div>
)}
{this.props.blockchainIsLoaded &&
!_.isEmpty(this.props.userAddress) && <div className="col col-5">{this._renderUser()}</div>}
{!this._isViewingPortal() && (
<div className={`col ${isFullWidthPage ? 'col-2 pl2' : 'col-1'} md-hide lg-hide`}>
<div style={menuIconStyle}>
<i className="zmdi zmdi-menu" onClick={this._onMenuButtonClick.bind(this)} />
</div>
!_.isEmpty(this.props.userAddress) && (
<div className="col col-5 sm-hide xs-hide">{this._renderUser()}</div>
)}
<div className={`col ${isFullWidthPage ? 'col-2 pl2' : 'col-1'} md-hide lg-hide`}>
<div style={menuIconStyle}>
<i className="zmdi zmdi-menu" onClick={this._onMenuButtonClick.bind(this)} />
</div>
)}
</div>
</div>
{this._renderDrawer()}
</div>

View File

@@ -118,8 +118,8 @@ export const configs = {
] as OutdatedWrappedEtherByNetworkId[],
// The order matters. We first try first node and only then fall back to others.
PUBLIC_NODE_URLS_BY_NETWORK_ID: {
[1]: [`https://mainnet.infura.io/${INFURA_API_KEY}`],
[42]: [`https://kovan.infura.io/${INFURA_API_KEY}`],
[1]: [`https://mainnet.infura.io/${INFURA_API_KEY}`, 'https://mainnet.0xproject.com'],
[42]: [`https://kovan.infura.io/${INFURA_API_KEY}`, 'https://kovan.0xproject.com'],
} as PublicNodeUrlsByNetworkId,
SHOULD_DEPRECATE_OLD_WETH_TOKEN: true,
SYMBOLS_OF_MINTABLE_TOKENS: ['MKR', 'MLN', 'GNT', 'DGD', 'REP'],

View File

@@ -65,6 +65,7 @@ export const constants = {
URL_BIGNUMBERJS_GITHUB: 'http://mikemcl.github.io/bignumber.js',
URL_BITLY_API: 'https://api-ssl.bitly.com',
URL_BLOG: 'https://blog.0xproject.com/latest',
URL_DISCOURSE_FORUM: 'https://forum.0xproject.com',
URL_FIREFOX_U2F_ADDON: 'https://addons.mozilla.org/en-US/firefox/addon/u2f-support-add-on/',
URL_ETHER_FAUCET: 'https://faucet.0xproject.com',
URL_GITHUB_ORG: 'https://github.com/0xProject',

View File

@@ -1,6 +1,7 @@
import { BigNumber, intervalUtils, promisify } from '@0xproject/utils';
import * as _ from 'lodash';
import { Dispatcher } from 'ts/redux/dispatcher';
import { utils } from 'ts/utils/utils';
import * as Web3 from 'web3';
export class Web3Wrapper {
@@ -101,41 +102,48 @@ export class Web3Wrapper {
let prevNodeVersion: string;
this._prevUserEtherBalanceInEth = new BigNumber(0);
this._dispatcher.updateNetworkId(this._prevNetworkId);
this._watchNetworkAndBalanceIntervalId = intervalUtils.setAsyncExcludingInterval(async () => {
// Check for network state changes
const currentNetworkId = await this.getNetworkIdIfExists();
if (currentNetworkId !== this._prevNetworkId) {
this._prevNetworkId = currentNetworkId;
this._dispatcher.updateNetworkId(currentNetworkId);
}
// Check for node version changes
const currentNodeVersion = await this.getNodeVersionAsync();
if (currentNodeVersion !== prevNodeVersion) {
prevNodeVersion = currentNodeVersion;
this._dispatcher.updateNodeVersion(currentNodeVersion);
}
if (this._shouldPollUserAddress) {
const userAddressIfExists = await this.getFirstAccountIfExistsAsync();
// Update makerAddress on network change
if (this._prevUserAddress !== userAddressIfExists) {
this._prevUserAddress = userAddressIfExists;
this._dispatcher.updateUserAddress(userAddressIfExists);
this._watchNetworkAndBalanceIntervalId = intervalUtils.setAsyncExcludingInterval(
async () => {
// Check for network state changes
const currentNetworkId = await this.getNetworkIdIfExists();
if (currentNetworkId !== this._prevNetworkId) {
this._prevNetworkId = currentNetworkId;
this._dispatcher.updateNetworkId(currentNetworkId);
}
// Check for user ether balance changes
if (userAddressIfExists !== '') {
await this._updateUserEtherBalanceAsync(userAddressIfExists);
// Check for node version changes
const currentNodeVersion = await this.getNodeVersionAsync();
if (currentNodeVersion !== prevNodeVersion) {
prevNodeVersion = currentNodeVersion;
this._dispatcher.updateNodeVersion(currentNodeVersion);
}
} else {
// This logic is primarily for the Ledger, since we don't regularly poll for the address
// we simply update the balance for the last fetched address.
if (!_.isEmpty(this._prevUserAddress)) {
await this._updateUserEtherBalanceAsync(this._prevUserAddress);
if (this._shouldPollUserAddress) {
const userAddressIfExists = await this.getFirstAccountIfExistsAsync();
// Update makerAddress on network change
if (this._prevUserAddress !== userAddressIfExists) {
this._prevUserAddress = userAddressIfExists;
this._dispatcher.updateUserAddress(userAddressIfExists);
}
// Check for user ether balance changes
if (userAddressIfExists !== '') {
await this._updateUserEtherBalanceAsync(userAddressIfExists);
}
} else {
// This logic is primarily for the Ledger, since we don't regularly poll for the address
// we simply update the balance for the last fetched address.
if (!_.isEmpty(this._prevUserAddress)) {
await this._updateUserEtherBalanceAsync(this._prevUserAddress);
}
}
}
}, 5000);
},
5000,
(err: Error) => {
utils.consoleLog(`Watching network and balances failed: ${err}`);
this._stopEmittingNetworkConnectionAndUserBalanceStateAsync();
},
);
}
private async _updateUserEtherBalanceAsync(userAddress: string) {
const balance = await this.getBalanceInEthAsync(userAddress);
@@ -145,6 +153,6 @@ export class Web3Wrapper {
}
}
private _stopEmittingNetworkConnectionAndUserBalanceStateAsync() {
clearInterval(this._watchNetworkAndBalanceIntervalId);
intervalUtils.clearAsyncExcludingInterval(this._watchNetworkAndBalanceIntervalId);
}
}

View File

@@ -2,6 +2,14 @@
# yarn lockfile v1
"@0xproject/utils@^0.1.3":
version "0.1.3"
resolved "https://registry.yarnpkg.com/@0xproject/utils/-/utils-0.1.3.tgz#58a9c7e19ab7710e0af17a0c2f1c7fc1b3140e85"
dependencies:
bignumber.js "~4.1.0"
js-sha3 "^0.7.0"
lodash "^4.17.4"
"@types/accounting@^0.4.1":
version "0.4.1"
resolved "https://registry.yarnpkg.com/@types/accounting/-/accounting-0.4.1.tgz#865d9f5694fd7c438fba34eb4bc82eec6f34cdd5"
@@ -3184,7 +3192,7 @@ ethereumjs-blockstream@^2.0.6:
source-map-support "0.4.14"
uuid "3.0.1"
ethereumjs-testrpc@6.0.3:
ethereumjs-testrpc@^6.0.3:
version "6.0.3"
resolved "https://registry.yarnpkg.com/ethereumjs-testrpc/-/ethereumjs-testrpc-6.0.3.tgz#7a0b87bf3670f92f607f98fa6a78801d9741b124"
dependencies: