Merge branch 'development' into fix/docImprovements

* development: (31 commits)
  Prettier ignore Metacoin artifacts
  Publish
  Updated CHANGELOGS
  Improve deployer error message
  Fix 0x.js tests
  Fix lint issue
  Simply export
  Move NULL_BYTES to @0xproject/utils
  Simplify the tests
  Fix lint error
  Add step to publishing that upload staging doc jsons, deploys staging website, opens every docs page and asks the dev to confirm that each one renders properly before publishing
  Fix web3Wrapper build command
  Add top-level `yarn lerna:stage_docs` to upload docJsons to the staging S3 bucket for all packages with a docs page
  Refactor publish script to have it's main execution body be lean and discrete steps
  Removed unused command
  Remove 0x.js test artifacts
  Fix tslint
  Move migrations into separate monorepo subpackage and hook it up to 0x.js and contracts
  Remove unused var
  Refactor RedundantRpcSubprovider into RedundantSubprovider
  ...

# Conflicts:
#	packages/react-docs/CHANGELOG.json
This commit is contained in:
Fabio Berger 2018-04-12 08:56:13 +09:00
commit faedd2fa0b
136 changed files with 1030 additions and 543 deletions

3
.gitignore vendored
View File

@ -74,7 +74,8 @@ packages/react-docs/example/public/bundle*
bin/
# generated contract artifacts
packages/contracts/src/artifacts
packages/0x.js/test/artifacts
packages/migrations/src/artifacts
# generated contract wrappers
packages/0x.js/src/contract_wrappers/generated/

View File

@ -1,5 +1,6 @@
lib
.nyc_output
/packages/contracts/src/artifacts
/packages/metacoin/artifacts
package.json
scripts/postpublish_utils.js

View File

@ -74,7 +74,7 @@ You can include those by prepending @0xproject/typescript-typings package to you
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.
#### Read our [contribution guidelines](./CONTRIBUTING.md).
### Install dependencies
@ -118,24 +118,6 @@ yarn lerna:run lint
### Run Tests
Before running the tests, you will need to spin up a [TestRPC](https://www.npmjs.com/package/ethereumjs-testrpc) instance and deploy all the 0x smart contracts.
In a separate terminal, start TestRPC (a convenience command is provided as part of this repo)
```bash
yarn testrpc
```
Then in your main terminal run
```
cd packages/contracts
yarn migrate
cd ..
```
And finally from the root project directory run
```bash
yarn lerna:run test
yarn lerna:test
```

View File

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

View File

@ -6,7 +6,8 @@
"note": "Moved Web3.Provider to `@0xproject/types:Provider`",
"pr": 501
}
]
],
"timestamp": 1523462196
},
{
"version": "0.35.0",

View File

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

View File

@ -1,6 +1,6 @@
{
"name": "0x.js",
"version": "0.35.0",
"version": "0.36.0",
"description": "A javascript library for interacting with the 0x protocol",
"keywords": [
"0x.js",
@ -15,16 +15,16 @@
"build:watch": "tsc -w",
"prebuild": "run-s clean generate_contract_wrappers",
"build": "run-p build:umd:prod build:commonjs; exit 0;",
"generate_contract_wrappers": "node ../abi-gen/lib/index.js --abis 'src/artifacts/@(Exchange|Token|TokenTransferProxy|EtherToken|TokenRegistry|DummyToken).json' --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/contract_wrappers/generated --backend ethers && prettier --write 'src/contract_wrappers/generated/**.ts'",
"generate_contract_wrappers": "node ../abi-gen/lib/index.js --abis 'src/compact_artifacts/@(Exchange|Token|TokenTransferProxy|EtherToken|TokenRegistry|DummyToken).json' --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/contract_wrappers/generated --backend ethers && prettier --write 'src/contract_wrappers/generated/**.ts'",
"lint": "tslint --project . 'src/**/*.ts' 'test/**/*.ts'",
"test:circleci": "run-s test:coverage",
"test": "run-s clean test:commonjs",
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
"coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info",
"update_contracts": "for i in ${npm_package_config_artifacts}; do copyfiles -u 4 ../contracts/build/contracts/$i.json ../0x.js/src/artifacts; done;",
"update_artifacts": "for i in ${npm_package_config_contracts}; do copyfiles -u 4 ../migrations/src/artifacts/$i.json test/artifacts; done;",
"clean": "shx rm -rf _bundles lib test_temp scripts",
"build:umd:prod": "NODE_ENV=production webpack",
"build:commonjs": "tsc && copyfiles -u 2 './src/artifacts/**/*.json' ./lib/src/artifacts && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts",
"build:commonjs": "tsc && yarn update_artifacts && copyfiles -u 2 './src/compact_artifacts/**/*.json' ./lib/src/compact_artifacts && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts",
"test:commonjs": "run-s build:commonjs run_mocha",
"run_mocha": "mocha lib/test/**/*_test.js --timeout 10000 --bail --exit",
"manual:postpublish": "yarn build; node ./scripts/postpublish.js",
@ -33,7 +33,8 @@
"upload_docs_json": "aws s3 cp generated_docs/index.json $S3_URL --profile 0xproject --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --content-type application/json"
},
"config": {
"artifacts": "TokenTransferProxy Exchange TokenRegistry Token EtherToken",
"compact_artifacts": "Exchange DummyToken ZRXToken Token EtherToken TokenTransferProxy TokenRegistry",
"contracts": "Exchange DummyToken ZRXToken Token WETH9 TokenTransferProxy MultiSigWallet MultiSigWalletWithTimeLock MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress MaliciousToken TokenRegistry Arbitrage EtherDelta AccountLevels",
"postpublish": {
"assets": [
"packages/0x.js/_bundles/index.js",
@ -60,9 +61,11 @@
"node": ">=6.0.0"
},
"devDependencies": {
"@0xproject/dev-utils": "^0.3.4",
"@0xproject/monorepo-scripts": "^0.1.16",
"@0xproject/tslint-config": "^0.4.14",
"@0xproject/deployer": "^0.4.0",
"@0xproject/dev-utils": "^0.3.5",
"@0xproject/monorepo-scripts": "^0.1.17",
"@0xproject/subproviders": "^0.8.4",
"@0xproject/tslint-config": "^0.4.15",
"@types/bintrees": "^1.0.2",
"@types/lodash": "4.14.104",
"@types/mocha": "^2.2.42",
@ -90,16 +93,17 @@
"tslint": "5.8.0",
"typedoc": "0xProject/typedoc",
"typescript": "2.7.1",
"web3-provider-engine": "^13.0.1",
"webpack": "^3.1.0"
},
"dependencies": {
"@0xproject/assert": "^0.2.5",
"@0xproject/base-contract": "^0.1.0",
"@0xproject/json-schemas": "^0.7.19",
"@0xproject/types": "^0.5.0",
"@0xproject/typescript-typings": "^0.0.3",
"@0xproject/utils": "^0.5.0",
"@0xproject/web3-wrapper": "^0.5.0",
"@0xproject/assert": "^0.2.6",
"@0xproject/base-contract": "^0.2.0",
"@0xproject/json-schemas": "^0.7.20",
"@0xproject/types": "^0.6.0",
"@0xproject/typescript-typings": "^0.1.0",
"@0xproject/utils": "^0.5.1",
"@0xproject/web3-wrapper": "^0.6.0",
"bintrees": "^1.0.2",
"bn.js": "^4.11.8",
"ethereumjs-abi": "^0.6.4",
@ -111,6 +115,9 @@
"uuid": "^3.1.0",
"web3": "^0.20.0"
},
"optionalDependencies": {
"@0xproject/migrations": "^0.0.1"
},
"publishConfig": {
"access": "public"
}

View File

@ -1,10 +1,10 @@
import * as DummyTokenArtifact from './artifacts/DummyToken.json';
import * as EtherTokenArtifact from './artifacts/EtherToken.json';
import * as ExchangeArtifact from './artifacts/Exchange.json';
import * as TokenArtifact from './artifacts/Token.json';
import * as TokenRegistryArtifact from './artifacts/TokenRegistry.json';
import * as TokenTransferProxyArtifact from './artifacts/TokenTransferProxy.json';
import * as ZRXArtifact from './artifacts/ZRX.json';
import * as DummyTokenArtifact from './compact_artifacts/DummyToken.json';
import * as EtherTokenArtifact from './compact_artifacts/EtherToken.json';
import * as ExchangeArtifact from './compact_artifacts/Exchange.json';
import * as TokenArtifact from './compact_artifacts/Token.json';
import * as TokenRegistryArtifact from './compact_artifacts/TokenRegistry.json';
import * as TokenTransferProxyArtifact from './compact_artifacts/TokenTransferProxy.json';
import * as ZRXArtifact from './compact_artifacts/ZRX.json';
import { Artifact } from './types';
export const artifacts = {

View File

@ -1,16 +1,23 @@
import { Deployer } from '@0xproject/deployer';
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
// HACK: This dependency is optional since it is only available when run from within
// the monorepo. tslint doesn't handle optional dependencies
// tslint:disable-next-line:no-implicit-dependencies
import { runMigrationsAsync } from '@0xproject/migrations';
import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
import * as _ from 'lodash';
import 'mocha';
import * as path from 'path';
import * as Sinon from 'sinon';
import { ApprovalContractEventArgs, LogWithDecodedArgs, Order, TokenEvents, ZeroEx } from '../src';
import { chaiSetup } from './utils/chai_setup';
import { constants } from './utils/constants';
import { deployer } from './utils/deployer';
import { TokenUtils } from './utils/token_utils';
import { web3, web3Wrapper } from './utils/web3_wrapper';
import { provider, web3Wrapper } from './utils/web3_wrapper';
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
chaiSetup.configure();
@ -19,10 +26,14 @@ const expect = chai.expect;
const SHOULD_ADD_PERSONAL_MESSAGE_PREFIX = false;
describe('ZeroEx library', () => {
const config = {
networkId: constants.TESTRPC_NETWORK_ID,
};
const zeroEx = new ZeroEx(web3.currentProvider, config);
let zeroEx: ZeroEx;
before(async () => {
await runMigrationsAsync(deployer);
const config = {
networkId: constants.TESTRPC_NETWORK_ID,
};
zeroEx = new ZeroEx(provider, config);
});
describe('#setProvider', () => {
it('overrides provider in nested web3s and invalidates contractInstances', async () => {
// Instantiate the contract instances with the current provider
@ -31,10 +42,9 @@ describe('ZeroEx library', () => {
expect((zeroEx.exchange as any)._exchangeContractIfExists).to.not.be.undefined();
expect((zeroEx.tokenRegistry as any)._tokenRegistryContractIfExists).to.not.be.undefined();
const newProvider = web3Factory.getRpcProvider();
// Add property to newProvider so that we can differentiate it from old provider
(newProvider as any).zeroExTestId = 1;
zeroEx.setProvider(newProvider, constants.TESTRPC_NETWORK_ID);
(provider as any).zeroExTestId = 1;
zeroEx.setProvider(provider, constants.TESTRPC_NETWORK_ID);
// Check that contractInstances with old provider are removed after provider update
expect((zeroEx.exchange as any)._exchangeContractIfExists).to.be.undefined();
@ -278,7 +288,7 @@ describe('ZeroEx library', () => {
exchangeContractAddress: ZeroEx.NULL_ADDRESS,
networkId: constants.TESTRPC_NETWORK_ID,
};
const zeroExWithWrongExchangeAddress = new ZeroEx(web3.currentProvider, zeroExConfig);
const zeroExWithWrongExchangeAddress = new ZeroEx(provider, zeroExConfig);
expect(zeroExWithWrongExchangeAddress.exchange.getContractAddress()).to.be.equal(ZeroEx.NULL_ADDRESS);
});
it('allows to specify token registry token contract address', async () => {
@ -286,7 +296,7 @@ describe('ZeroEx library', () => {
tokenRegistryContractAddress: ZeroEx.NULL_ADDRESS,
networkId: constants.TESTRPC_NETWORK_ID,
};
const zeroExWithWrongTokenRegistryAddress = new ZeroEx(web3.currentProvider, zeroExConfig);
const zeroExWithWrongTokenRegistryAddress = new ZeroEx(provider, zeroExConfig);
expect(zeroExWithWrongTokenRegistryAddress.tokenRegistry.getContractAddress()).to.be.equal(
ZeroEx.NULL_ADDRESS,
);

View File

@ -17,11 +17,11 @@ describe('Artifacts', () => {
const packageJSONContent = fs.readFileSync('package.json', 'utf-8');
const packageJSON = JSON.parse(packageJSONContent);
const mnemonic = packageJSON.config.mnemonic;
const web3Provider = new HDWalletProvider(mnemonic, kovanRpcUrl);
const provider = new HDWalletProvider(mnemonic, kovanRpcUrl);
const config = {
networkId: constants.KOVAN_NETWORK_ID,
};
const zeroEx = new ZeroEx(web3Provider, config);
const zeroEx = new ZeroEx(provider, config);
it('token registry contract is deployed', async () => {
await (zeroEx.tokenRegistry as any)._getTokenRegistryContractAsync();
}).timeout(TIMEOUT);
@ -37,11 +37,11 @@ describe('Artifacts', () => {
const packageJSONContent = fs.readFileSync('package.json', 'utf-8');
const packageJSON = JSON.parse(packageJSONContent);
const mnemonic = packageJSON.config.mnemonic;
const web3Provider = new HDWalletProvider(mnemonic, ropstenRpcUrl);
const provider = new HDWalletProvider(mnemonic, ropstenRpcUrl);
const config = {
networkId: constants.ROPSTEN_NETWORK_ID,
};
const zeroEx = new ZeroEx(web3Provider, config);
const zeroEx = new ZeroEx(provider, config);
it('token registry contract is deployed', async () => {
await (zeroEx.tokenRegistry as any)._getTokenRegistryContractAsync();
}).timeout(TIMEOUT);

View File

@ -6,15 +6,15 @@ import { ZeroEx } from '../src';
import { assert } from '../src/utils/assert';
import { constants } from './utils/constants';
import { provider } from './utils/web3_wrapper';
const expect = chai.expect;
describe('Assertion library', () => {
const web3 = web3Factory.create();
const config = {
networkId: constants.TESTRPC_NETWORK_ID,
};
const zeroEx = new ZeroEx(web3.currentProvider, config);
const zeroEx = new ZeroEx(provider, config);
describe('#isSenderAddressHexAsync', () => {
it('throws when address is invalid', async () => {
const address = '0xdeadbeef';

View File

@ -3,7 +3,6 @@ import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as chai from 'chai';
import 'mocha';
import * as Web3 from 'web3';
import {
ApprovalContractEventArgs,
@ -24,7 +23,7 @@ import { chaiSetup } from './utils/chai_setup';
import { constants } from './utils/constants';
import { reportNodeCallbackErrors } from './utils/report_callback_errors';
import { TokenUtils } from './utils/token_utils';
import { web3, web3Wrapper } from './utils/web3_wrapper';
import { provider, web3Wrapper } from './utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
@ -55,7 +54,7 @@ describe('EtherTokenWrapper', () => {
const depositAmount = new BigNumber(42);
const withdrawalAmount = new BigNumber(42);
before(async () => {
zeroEx = new ZeroEx(web3.currentProvider, zeroExConfig);
zeroEx = new ZeroEx(provider, zeroExConfig);
tokens = await zeroEx.tokenRegistry.getTokensAsync();
userAddresses = await zeroEx.getAvailableAddressesAsync();
addressWithETH = userAddresses[0];
@ -79,7 +78,7 @@ describe('EtherTokenWrapper', () => {
const UNKNOWN_NETWORK_NETWORK_ID = 10;
expect(
() =>
new ZeroEx(web3.currentProvider, {
new ZeroEx(provider, {
networkId: UNKNOWN_NETWORK_NETWORK_ID,
} as any),
).to.throw();
@ -261,8 +260,7 @@ describe('EtherTokenWrapper', () => {
callbackNeverToBeCalled,
);
const callbackToBeCalled = reportNodeCallbackErrors(done)();
const newProvider = web3Factory.getRpcProvider();
zeroEx.setProvider(newProvider, constants.TESTRPC_NETWORK_ID);
zeroEx.setProvider(provider, constants.TESTRPC_NETWORK_ID);
await zeroEx.etherToken.depositAsync(etherTokenAddress, transferAmount, addressWithETH);
zeroEx.etherToken.subscribe(
etherTokenAddress,

View File

@ -5,7 +5,6 @@ import * as chai from 'chai';
import * as _ from 'lodash';
import 'mocha';
import * as Sinon from 'sinon';
import * as Web3 from 'web3';
import { LogEvent } from '../src';
import { EventWatcher } from '../src/order_watcher/event_watcher';
@ -13,12 +12,12 @@ import { DoneCallback } from '../src/types';
import { chaiSetup } from './utils/chai_setup';
import { reportNodeCallbackErrors } from './utils/report_callback_errors';
import { provider } from './utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
describe('EventWatcher', () => {
let web3: Web3;
let stubs: Sinon.SinonStub[] = [];
let eventWatcher: EventWatcher;
let web3Wrapper: Web3Wrapper;
@ -53,9 +52,8 @@ describe('EventWatcher', () => {
transactionIndex: 0,
};
before(async () => {
web3 = web3Factory.create();
const pollingIntervalMs = 10;
web3Wrapper = new Web3Wrapper(web3.currentProvider);
web3Wrapper = new Web3Wrapper(provider);
eventWatcher = new EventWatcher(web3Wrapper, pollingIntervalMs);
});
afterEach(() => {

View File

@ -9,7 +9,7 @@ import { ExchangeTransferSimulator } from '../src/utils/exchange_transfer_simula
import { chaiSetup } from './utils/chai_setup';
import { constants } from './utils/constants';
import { web3, web3Wrapper } from './utils/web3_wrapper';
import { provider, web3Wrapper } from './utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
@ -19,7 +19,7 @@ describe('ExchangeTransferSimulator', () => {
const config = {
networkId: constants.TESTRPC_NETWORK_ID,
};
const zeroEx = new ZeroEx(web3.currentProvider, config);
const zeroEx = new ZeroEx(provider, config);
const transferAmount = new BigNumber(5);
let userAddresses: string[];
let tokens: Token[];

View File

@ -4,7 +4,6 @@ import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
import * as _ from 'lodash';
import 'mocha';
import * as Web3 from 'web3';
import {
BlockRange,
@ -26,7 +25,7 @@ import { constants } from './utils/constants';
import { FillScenarios } from './utils/fill_scenarios';
import { reportNodeCallbackErrors } from './utils/report_callback_errors';
import { TokenUtils } from './utils/token_utils';
import { web3, web3Wrapper } from './utils/web3_wrapper';
import { provider, web3Wrapper } from './utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
@ -46,7 +45,7 @@ describe('ExchangeWrapper', () => {
networkId: constants.TESTRPC_NETWORK_ID,
};
before(async () => {
zeroEx = new ZeroEx(web3.currentProvider, config);
zeroEx = new ZeroEx(provider, config);
exchangeContractAddress = zeroEx.exchange.getContractAddress();
userAddresses = await zeroEx.getAvailableAddressesAsync();
tokens = await zeroEx.tokenRegistry.getTokensAsync();
@ -977,8 +976,7 @@ describe('ExchangeWrapper', () => {
);
zeroEx.exchange.subscribe(ExchangeEvents.LogFill, indexFilterValues, callbackNeverToBeCalled);
const newProvider = web3Factory.getRpcProvider();
zeroEx.setProvider(newProvider, constants.TESTRPC_NETWORK_ID);
zeroEx.setProvider(provider, constants.TESTRPC_NETWORK_ID);
const callback = reportNodeCallbackErrors(done)(
(logEvent: DecodedLogEvent<LogFillContractEventArgs>) => {

View File

@ -4,7 +4,6 @@ import * as chai from 'chai';
import * as _ from 'lodash';
import 'mocha';
import * as Sinon from 'sinon';
import * as Web3 from 'web3';
import { ZeroEx } from '../src/0x';
import { ExpirationWatcher } from '../src/order_watcher/expiration_watcher';
@ -16,7 +15,7 @@ import { constants } from './utils/constants';
import { FillScenarios } from './utils/fill_scenarios';
import { reportNoErrorCallbackErrors } from './utils/report_callback_errors';
import { TokenUtils } from './utils/token_utils';
import { web3, web3Wrapper } from './utils/web3_wrapper';
import { provider, web3Wrapper } from './utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
@ -44,7 +43,7 @@ describe('ExpirationWatcher', () => {
const config = {
networkId: constants.TESTRPC_NETWORK_ID,
};
zeroEx = new ZeroEx(web3.currentProvider, config);
zeroEx = new ZeroEx(provider, config);
exchangeContractAddress = zeroEx.exchange.getContractAddress();
userAddresses = await zeroEx.getAvailableAddressesAsync();
tokens = await zeroEx.tokenRegistry.getTokensAsync();

View File

@ -3,7 +3,6 @@ import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
import * as _ from 'lodash';
import 'mocha';
import * as Web3 from 'web3';
import {
ExchangeContractErrs,
@ -23,7 +22,7 @@ import { constants } from './utils/constants';
import { FillScenarios } from './utils/fill_scenarios';
import { reportNodeCallbackErrors } from './utils/report_callback_errors';
import { TokenUtils } from './utils/token_utils';
import { web3, web3Wrapper } from './utils/web3_wrapper';
import { provider, web3Wrapper } from './utils/web3_wrapper';
const TIMEOUT_MS = 150;
@ -51,7 +50,7 @@ describe('OrderStateWatcher', () => {
const decimals = constants.ZRX_DECIMALS;
const fillableAmount = ZeroEx.toBaseUnitAmount(new BigNumber(5), decimals);
before(async () => {
zeroEx = new ZeroEx(web3.currentProvider, config);
zeroEx = new ZeroEx(provider, config);
orderStateWatcher = zeroEx.createOrderStateWatcher();
exchangeContractAddress = zeroEx.exchange.getContractAddress();
userAddresses = await zeroEx.getAvailableAddressesAsync();

View File

@ -3,7 +3,6 @@ import { BlockParamLiteral } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
import * as Sinon from 'sinon';
import * as Web3 from 'web3';
import { ExchangeContractErrs, SignedOrder, Token, ZeroEx, ZeroExError } from '../src';
import { TradeSide, TransferType } from '../src/types';
@ -14,7 +13,7 @@ import { chaiSetup } from './utils/chai_setup';
import { constants } from './utils/constants';
import { FillScenarios } from './utils/fill_scenarios';
import { TokenUtils } from './utils/token_utils';
import { web3, web3Wrapper } from './utils/web3_wrapper';
import { provider, web3Wrapper } from './utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
@ -40,7 +39,7 @@ describe('OrderValidation', () => {
networkId: constants.TESTRPC_NETWORK_ID,
};
before(async () => {
zeroEx = new ZeroEx(web3.currentProvider, config);
zeroEx = new ZeroEx(provider, config);
exchangeContractAddress = zeroEx.exchange.getContractAddress();
userAddresses = await zeroEx.getAvailableAddressesAsync();
[coinbase, makerAddress, takerAddress, feeRecipient] = userAddresses;

View File

@ -3,7 +3,6 @@ import { BigNumber } from '@0xproject/utils';
import * as _ from 'lodash';
import 'mocha';
import * as Sinon from 'sinon';
import * as Web3 from 'web3';
import { ApprovalContractEventArgs, DecodedLogEvent, Token, TokenEvents, ZeroEx } from '../src';
import { DoneCallback } from '../src/types';
@ -11,7 +10,7 @@ import { DoneCallback } from '../src/types';
import { chaiSetup } from './utils/chai_setup';
import { constants } from './utils/constants';
import { assertNodeCallbackError } from './utils/report_callback_errors';
import { web3, web3Wrapper } from './utils/web3_wrapper';
import { provider, web3Wrapper } from './utils/web3_wrapper';
chaiSetup.configure();
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
@ -26,7 +25,7 @@ describe('SubscriptionTest', () => {
networkId: constants.TESTRPC_NETWORK_ID,
};
before(async () => {
zeroEx = new ZeroEx(web3.currentProvider, config);
zeroEx = new ZeroEx(provider, config);
userAddresses = await zeroEx.getAvailableAddressesAsync();
tokens = await zeroEx.tokenRegistry.getTokensAsync();
coinbase = userAddresses[0];

View File

@ -8,7 +8,7 @@ import { Token, ZeroEx } from '../src';
import { chaiSetup } from './utils/chai_setup';
import { constants } from './utils/constants';
import { web3, web3Wrapper } from './utils/web3_wrapper';
import { provider, web3Wrapper } from './utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
@ -31,7 +31,7 @@ describe('TokenRegistryWrapper', () => {
networkId: constants.TESTRPC_NETWORK_ID,
};
before(async () => {
zeroEx = new ZeroEx(web3.currentProvider, config);
zeroEx = new ZeroEx(provider, config);
tokens = await zeroEx.tokenRegistry.getTokensAsync();
_.map(tokens, token => {
tokenAddressBySymbol[token.symbol] = token.address;

View File

@ -1,14 +1,13 @@
import { web3Factory } from '@0xproject/dev-utils';
import * as chai from 'chai';
import { ZeroEx } from '../src';
import { chaiSetup } from './utils/chai_setup';
import { constants } from './utils/constants';
import { provider } from './utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
const web3 = web3Factory.create();
describe('TokenTransferProxyWrapper', () => {
let zeroEx: ZeroEx;
@ -16,7 +15,7 @@ describe('TokenTransferProxyWrapper', () => {
networkId: constants.TESTRPC_NETWORK_ID,
};
before(async () => {
zeroEx = new ZeroEx(web3.currentProvider, config);
zeroEx = new ZeroEx(provider, config);
});
describe('#isAuthorizedAsync', () => {
it('should return false if the address is not authorized', async () => {

View File

@ -1,9 +1,10 @@
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
import { BlockchainLifecycle, devConstants } from '@0xproject/dev-utils';
import { EmptyWalletSubprovider } from '@0xproject/subproviders';
import { Provider } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as chai from 'chai';
import 'mocha';
import * as Web3 from 'web3';
import Web3ProviderEngine = require('web3-provider-engine');
import {
ApprovalContractEventArgs,
@ -22,7 +23,7 @@ import { chaiSetup } from './utils/chai_setup';
import { constants } from './utils/constants';
import { reportNodeCallbackErrors } from './utils/report_callback_errors';
import { TokenUtils } from './utils/token_utils';
import { web3, web3Wrapper } from './utils/web3_wrapper';
import { provider, web3Wrapper } from './utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
@ -39,7 +40,7 @@ describe('TokenWrapper', () => {
networkId: constants.TESTRPC_NETWORK_ID,
};
before(async () => {
zeroEx = new ZeroEx(web3.currentProvider, config);
zeroEx = new ZeroEx(provider, config);
userAddresses = await zeroEx.getAvailableAddressesAsync();
tokens = await zeroEx.tokenRegistry.getTokensAsync();
tokenUtils = new TokenUtils(tokens);
@ -164,7 +165,7 @@ describe('TokenWrapper', () => {
});
});
describe('#getBalanceAsync', () => {
describe('With web3 provider with accounts', () => {
describe('With provider with accounts', () => {
it('should return the balance for an existing ERC20 token', async () => {
const token = tokens[0];
const ownerAddress = coinbase;
@ -187,14 +188,14 @@ describe('TokenWrapper', () => {
return expect(balance).to.be.bignumber.equal(expectedBalance);
});
});
describe('With web3 provider without accounts', () => {
describe('With provider without accounts', () => {
let zeroExWithoutAccounts: ZeroEx;
before(async () => {
const hasAddresses = false;
const web3WithoutAccounts = web3Factory.create({ hasAddresses });
zeroExWithoutAccounts = new ZeroEx(web3WithoutAccounts.currentProvider, config);
const emptyWalletProvider = addEmptyWalletSubprovider(provider);
zeroExWithoutAccounts = new ZeroEx(emptyWalletProvider, config);
});
it('should return balance even when called with Web3 provider instance without addresses', async () => {
it('should return balance even when called with provider instance without addresses', async () => {
const token = tokens[0];
const ownerAddress = coinbase;
const balance = await zeroExWithoutAccounts.token.getBalanceAsync(token.address, ownerAddress);
@ -277,7 +278,7 @@ describe('TokenWrapper', () => {
});
});
describe('#getAllowanceAsync', () => {
describe('With web3 provider with accounts', () => {
describe('With provider with accounts', () => {
it('should get the proxy allowance', async () => {
const token = tokens[0];
const ownerAddress = coinbase;
@ -299,12 +300,12 @@ describe('TokenWrapper', () => {
return expect(allowance).to.be.bignumber.equal(expectedAllowance);
});
});
describe('With web3 provider without accounts', () => {
describe('With provider without accounts', () => {
let zeroExWithoutAccounts: ZeroEx;
before(async () => {
const hasAddresses = false;
const web3WithoutAccounts = web3Factory.create({ hasAddresses });
zeroExWithoutAccounts = new ZeroEx(web3WithoutAccounts.currentProvider, config);
const emptyWalletProvider = addEmptyWalletSubprovider(provider);
zeroExWithoutAccounts = new ZeroEx(emptyWalletProvider, config);
});
it('should get the proxy allowance', async () => {
const token = tokens[0];
@ -424,8 +425,7 @@ describe('TokenWrapper', () => {
);
zeroEx.token.subscribe(tokenAddress, TokenEvents.Transfer, indexFilterValues, callbackNeverToBeCalled);
const callbackToBeCalled = reportNodeCallbackErrors(done)();
const newProvider = web3Factory.getRpcProvider();
zeroEx.setProvider(newProvider, constants.TESTRPC_NETWORK_ID);
zeroEx.setProvider(provider, constants.TESTRPC_NETWORK_ID);
zeroEx.token.subscribe(tokenAddress, TokenEvents.Transfer, indexFilterValues, callbackToBeCalled);
await zeroEx.token.transferAsync(tokenAddress, coinbase, addressWithoutFunds, transferAmount);
})().catch(done);
@ -515,3 +515,14 @@ describe('TokenWrapper', () => {
});
});
// tslint:disable:max-file-line-count
function addEmptyWalletSubprovider(p: Provider): Provider {
const providerEngine = new Web3ProviderEngine();
providerEngine.addProvider(new EmptyWalletSubprovider());
const currentSubproviders = (p as any)._providers;
for (const subprovider of currentSubproviders) {
providerEngine.addProvider(subprovider);
}
providerEngine.start();
return providerEngine;
}

View File

@ -2,19 +2,17 @@ import { Deployer } from '@0xproject/deployer';
import { devConstants } from '@0xproject/dev-utils';
import * as path from 'path';
import { constants } from '../util/constants';
import { constants } from './constants';
import { runMigrationsAsync } from './migrate';
import { provider } from './web3_wrapper';
const artifactsDir = path.resolve('test', 'artifacts');
const deployerOpts = {
artifactsDir: path.resolve('src', 'artifacts'),
jsonrpcUrl: devConstants.RPC_URL,
artifactsDir,
provider,
networkId: constants.TESTRPC_NETWORK_ID,
defaults: {
gas: devConstants.GAS_ESTIMATE,
},
};
export const deployer = new Deployer(deployerOpts);
runMigrationsAsync(deployer).catch(console.log);

View File

@ -1,6 +1,12 @@
import { web3Factory } from '@0xproject/dev-utils';
import { devConstants, web3Factory } from '@0xproject/dev-utils';
import { Provider } from '@0xproject/types';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as Web3 from 'web3';
export const web3 = web3Factory.create();
export const web3Wrapper = new Web3Wrapper(web3.currentProvider);
import { constants } from './constants';
const web3 = web3Factory.create({ shouldUseInProcessGanache: true });
const provider: Provider = web3.currentProvider;
const web3Wrapper = new Web3Wrapper(web3.currentProvider);
export { provider, web3Wrapper };

View File

@ -1,4 +1,13 @@
[
{
"timestamp": 1523462196,
"version": "0.2.10",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1522673609,
"version": "0.2.9",

View File

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

View File

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

View File

@ -1,4 +1,13 @@
[
{
"timestamp": 1523462196,
"version": "0.2.6",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1522673609,
"version": "0.2.5",

View File

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

View File

@ -1,6 +1,6 @@
{
"name": "@0xproject/assert",
"version": "0.2.5",
"version": "0.2.6",
"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",
@ -9,7 +9,7 @@
"build": "tsc && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts",
"clean": "shx rm -rf lib test_temp scripts",
"lint": "tslint --project . 'src/**/*.ts' 'test/**/*.ts'",
"run_mocha": "mocha lib/test/**/*_test.js",
"run_mocha": "mocha lib/test/**/*_test.js --exit",
"prepublishOnly": "run-p build",
"test": "run-s clean build run_mocha",
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
@ -27,8 +27,8 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/packages/assert/README.md",
"devDependencies": {
"@0xproject/monorepo-scripts": "^0.1.16",
"@0xproject/tslint-config": "^0.4.14",
"@0xproject/monorepo-scripts": "^0.1.17",
"@0xproject/tslint-config": "^0.4.15",
"@types/lodash": "4.14.104",
"@types/mocha": "^2.2.42",
"@types/valid-url": "^1.0.2",
@ -43,9 +43,9 @@
"typescript": "2.7.1"
},
"dependencies": {
"@0xproject/json-schemas": "^0.7.19",
"@0xproject/typescript-typings": "^0.0.3",
"@0xproject/utils": "^0.5.0",
"@0xproject/json-schemas": "^0.7.20",
"@0xproject/typescript-typings": "^0.1.0",
"@0xproject/utils": "^0.5.1",
"lodash": "^4.17.4",
"valid-url": "^1.0.9"
},

View File

@ -6,7 +6,8 @@
"note": "Contract wrappers now accept Provider and defaults instead of Web3Wrapper",
"pr": 501
}
]
],
"timestamp": 1523462196
},
{
"version": "0.1.0",

View File

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

View File

@ -1,6 +1,6 @@
{
"name": "@0xproject/base-contract",
"version": "0.1.0",
"version": "0.2.0",
"description": "0x Base TS contract",
"main": "lib/src/index.js",
"types": "lib/src/index.d.ts",
@ -26,8 +26,8 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/packages/base-contract/README.md",
"devDependencies": {
"@0xproject/monorepo-scripts": "^0.1.16",
"@0xproject/tslint-config": "^0.4.14",
"@0xproject/monorepo-scripts": "^0.1.17",
"@0xproject/tslint-config": "^0.4.15",
"@types/lodash": "4.14.104",
"chai": "^4.0.1",
"copyfiles": "^1.2.0",
@ -38,10 +38,10 @@
"typescript": "2.7.1"
},
"dependencies": {
"@0xproject/types": "^0.5.0",
"@0xproject/typescript-typings": "^0.0.3",
"@0xproject/utils": "^0.5.0",
"@0xproject/web3-wrapper": "^0.5.0",
"@0xproject/types": "^0.6.0",
"@0xproject/typescript-typings": "^0.1.0",
"@0xproject/utils": "^0.5.1",
"@0xproject/web3-wrapper": "^0.6.0",
"ethers-contracts": "^2.2.1",
"lodash": "^4.17.4"
},

View File

@ -1,4 +1,13 @@
[
{
"timestamp": 1523462196,
"version": "0.6.9",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1522673609,
"version": "0.6.8",

View File

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

View File

@ -1,6 +1,6 @@
{
"name": "@0xproject/connect",
"version": "0.6.8",
"version": "0.6.9",
"description": "A javascript library for interacting with the standard relayer api",
"keywords": [
"connect",
@ -17,7 +17,7 @@
"clean": "shx rm -rf lib test_temp scripts",
"copy_test_fixtures": "copyfiles -u 2 './test/fixtures/**/*.json' ./lib/test/fixtures",
"lint": "tslint --project . 'src/**/*.ts' 'test/**/*.ts'",
"run_mocha": "mocha lib/test/**/*_test.js",
"run_mocha": "mocha lib/test/**/*_test.js --exit",
"test": "run-s clean build copy_test_fixtures run_mocha",
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
"coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info",
@ -50,19 +50,19 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/packages/connect/README.md",
"dependencies": {
"@0xproject/assert": "^0.2.5",
"@0xproject/json-schemas": "^0.7.19",
"@0xproject/types": "^0.5.0",
"@0xproject/typescript-typings": "^0.0.3",
"@0xproject/utils": "^0.5.0",
"@0xproject/assert": "^0.2.6",
"@0xproject/json-schemas": "^0.7.20",
"@0xproject/types": "^0.6.0",
"@0xproject/typescript-typings": "^0.1.0",
"@0xproject/utils": "^0.5.1",
"isomorphic-fetch": "^2.2.1",
"lodash": "^4.17.4",
"query-string": "^5.0.1",
"websocket": "^1.0.25"
},
"devDependencies": {
"@0xproject/monorepo-scripts": "^0.1.16",
"@0xproject/tslint-config": "^0.4.14",
"@0xproject/monorepo-scripts": "^0.1.17",
"@0xproject/tslint-config": "^0.4.15",
"@types/fetch-mock": "^5.12.1",
"@types/lodash": "4.14.104",
"@types/mocha": "^2.2.42",

View File

@ -72,17 +72,6 @@ yarn lint
### Run Tests
Before running the tests, you will need to spin up a [TestRPC](https://www.npmjs.com/package/ethereumjs-testrpc) instance.
In a separate terminal, start TestRPC (a convenience command is provided as part of the [0x.js monorepo](https://github.com/0xProject/0x-monorepo))
```bash
cd ../..
yarn testrpc
```
Then in your main terminal run
```bash
yarn test
```

View File

@ -1,10 +0,0 @@
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,23 +0,0 @@
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,7 +1,7 @@
{
"private": true,
"name": "contracts",
"version": "2.1.21",
"version": "2.1.22",
"description": "Smart contract components of 0x protocol",
"main": "index.js",
"directories": {
@ -10,16 +10,15 @@
"scripts": {
"build:watch": "tsc -w",
"prebuild": "run-s clean compile copy_artifacts generate_contract_wrappers",
"copy_artifacts": "copyfiles './src/artifacts/**/*' ./lib",
"copy_artifacts": "copyfiles -u 4 '../migrations/src/artifacts/**/*' ./lib/src/artifacts;",
"build": "tsc",
"test": "run-s build run_mocha",
"test:coverage": "SOLIDITY_COVERAGE=true run-s build run_mocha coverage:report:text coverage:report:lcov",
"run_mocha": "mocha 'lib/test/**/*.js' --timeout 100000 --bail --exit",
"compile:comment": "Yarn workspaces do not link binaries correctly so we need to reference them directly https://github.com/yarnpkg/yarn/issues/3846",
"compile": "node ../deployer/lib/src/cli.js compile --contracts ${npm_package_config_contracts} --contract-dirs src/contracts --artifacts-dir src/artifacts",
"compile": "node ../deployer/lib/src/cli.js compile --contracts ${npm_package_config_contracts} --contract-dirs src/contracts --artifacts-dir ../migrations/src/artifacts",
"clean": "shx rm -rf ./lib",
"generate_contract_wrappers": "node ../abi-gen/lib/index.js --abis ${npm_package_config_abis} --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/contract_wrappers/generated --backend ethers && prettier --write 'src/contract_wrappers/generated/**.ts'",
"migrate": "yarn build && yarn compile && node ./lib/migrations/index.js",
"lint": "tslint --project . 'migrations/**/*.ts' 'test/**/*.ts' 'util/**/*.ts' 'deploy/**/*.ts'",
"coverage:report:text": "istanbul report text",
"coverage:report:html": "istanbul report html && open coverage/index.html",
@ -27,7 +26,7 @@
"test:circleci": "yarn test:coverage"
},
"config": {
"abis": "src/artifacts/@(DummyToken|TokenTransferProxy|Exchange|TokenRegistry|MultiSigWallet|MultiSigWalletWithTimeLock|MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress|TokenRegistry|ZRXToken|Arbitrage|EtherDelta|AccountLevels).json",
"abis": "../migrations/src/artifacts/@(DummyToken|TokenTransferProxy|Exchange|TokenRegistry|MultiSigWallet|MultiSigWalletWithTimeLock|MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress|TokenRegistry|ZRXToken|Arbitrage|EtherDelta|AccountLevels).json",
"contracts": "Exchange,DummyToken,ZRXToken,Token,WETH9,TokenTransferProxy,MultiSigWallet,MultiSigWalletWithTimeLock,MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress,MaliciousToken,TokenRegistry,Arbitrage,EtherDelta,AccountLevels"
},
"repository": {
@ -41,8 +40,8 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/packages/contracts/README.md",
"devDependencies": {
"@0xproject/dev-utils": "^0.3.4",
"@0xproject/tslint-config": "^0.4.14",
"@0xproject/dev-utils": "^0.3.5",
"@0xproject/tslint-config": "^0.4.15",
"@types/lodash": "4.14.104",
"@types/node": "^8.0.53",
"@types/yargs": "^10.0.0",
@ -61,12 +60,12 @@
"yargs": "^10.0.3"
},
"dependencies": {
"0x.js": "^0.35.0",
"@0xproject/deployer": "^0.3.5",
"@0xproject/types": "^0.5.0",
"@0xproject/typescript-typings": "^0.0.3",
"@0xproject/utils": "^0.5.0",
"@0xproject/web3-wrapper": "^0.5.0",
"0x.js": "^0.36.0",
"@0xproject/deployer": "^0.4.0",
"@0xproject/types": "^0.6.0",
"@0xproject/typescript-typings": "^0.1.0",
"@0xproject/utils": "^0.5.1",
"@0xproject/web3-wrapper": "^0.6.0",
"bn.js": "^4.11.8",
"ethereumjs-abi": "^0.6.4",
"ethereumjs-util": "^5.1.1",

View File

@ -46,7 +46,7 @@ describe('MultiSigWalletWithTimeLock', () => {
describe('changeTimeLock', () => {
describe('initially non-time-locked', async () => {
before('deploy a walet', async () => {
before('deploy a wallet', async () => {
const multiSigInstance = await deployer.deployAsync(ContractName.MultiSigWalletWithTimeLock, [
owners,
SIGNATURES_REQUIRED,
@ -143,7 +143,7 @@ describe('MultiSigWalletWithTimeLock', () => {
});
});
describe('initially time-locked', async () => {
before('deploy a walet', async () => {
before('deploy a wallet', async () => {
const multiSigInstance = await deployer.deployAsync(ContractName.MultiSigWalletWithTimeLock, [
owners,
SIGNATURES_REQUIRED,

View File

@ -1,6 +1,6 @@
import { ZeroEx } from '0x.js';
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
import { BigNumber } from '@0xproject/utils';
import { BigNumber, NULL_BYTES } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as chai from 'chai';
import ethUtil = require('ethereumjs-util');
@ -66,8 +66,8 @@ describe('TokenRegistry', () => {
name: '',
symbol: '',
decimals: 0,
ipfsHash: constants.NULL_BYTES,
swarmHash: constants.NULL_BYTES,
ipfsHash: NULL_BYTES,
swarmHash: NULL_BYTES,
};
describe('addToken', () => {

View File

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

View File

@ -1,7 +1,8 @@
import { web3Factory } from '@0xproject/dev-utils';
import { Provider } from '@0xproject/types';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
const web3ProviderConfig = { shouldUseInProcessGanache: true };
export const web3 = web3Factory.create(web3ProviderConfig);
const providerConfigs = { shouldUseInProcessGanache: true };
export const web3 = web3Factory.create(providerConfigs);
export const provider = web3.currentProvider;
export const web3Wrapper = new Web3Wrapper(provider);

View File

@ -4,7 +4,6 @@ const DUMMY_TOKEN_DECIMALS = 18;
const DUMMY_TOKEN_TOTAL_SUPPLY = 0;
export const constants = {
NULL_BYTES: '0x',
INVALID_OPCODE: 'invalid opcode',
REVERT: 'revert',
TESTRPC_NETWORK_ID: 50,

View File

@ -6,7 +6,8 @@
"note": "Changed the config key `web3Provider` to `provider` to be consistent with other tools",
"pr": 501
}
]
],
"timestamp": 1523462196
},
{
"version": "0.3.5",

View File

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

View File

@ -1,6 +1,6 @@
{
"name": "@0xproject/deployer",
"version": "0.3.5",
"version": "0.4.0",
"description": "Smart contract deployer of 0x protocol",
"main": "lib/src/index.js",
"types": "lib/src/index.d.ts",
@ -8,7 +8,7 @@
"build:watch": "tsc -w",
"build": "yarn clean && copyfiles 'test/fixtures/contracts/**/*' ./lib && tsc && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts",
"test": "run-s build run_mocha",
"run_mocha": "mocha lib/test/*_test.js",
"run_mocha": "mocha lib/test/*_test.js --bail --exit",
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
"coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info",
"compile": "npm run build; node lib/src/cli.js compile",
@ -47,9 +47,9 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/packages/deployer/README.md",
"devDependencies": {
"@0xproject/dev-utils": "^0.2.1",
"@0xproject/monorepo-scripts": "^0.1.16",
"@0xproject/tslint-config": "^0.4.14",
"@0xproject/dev-utils": "^0.3.4",
"@0xproject/monorepo-scripts": "^0.1.17",
"@0xproject/tslint-config": "^0.4.15",
"@types/require-from-string": "^1.2.0",
"@types/semver": "^5.5.0",
"@types/yargs": "^11.0.0",
@ -68,11 +68,11 @@
"web3-typescript-typings": "^0.10.2"
},
"dependencies": {
"@0xproject/json-schemas": "^0.7.19",
"@0xproject/types": "^0.5.0",
"@0xproject/typescript-typings": "^0.0.3",
"@0xproject/utils": "^0.5.0",
"@0xproject/web3-wrapper": "^0.5.0",
"@0xproject/json-schemas": "^0.7.20",
"@0xproject/types": "^0.6.0",
"@0xproject/typescript-typings": "^0.1.0",
"@0xproject/utils": "^0.5.1",
"@0xproject/web3-wrapper": "^0.6.0",
"ethereumjs-util": "^5.1.1",
"isomorphic-fetch": "^2.2.1",
"lodash": "^4.17.4",

View File

@ -41,8 +41,8 @@ async function onCompileCommandAsync(argv: CliOptions): Promise<void> {
*/
async function onDeployCommandAsync(argv: CliOptions): Promise<void> {
const url = argv.jsonrpcUrl;
const web3Provider = new Web3.providers.HttpProvider(url);
const web3Wrapper = new Web3Wrapper(web3Provider);
const provider = new Web3.providers.HttpProvider(url);
const web3Wrapper = new Web3Wrapper(provider);
const networkId = await web3Wrapper.getNetworkIdAsync();
const compilerOpts: CompilerOptions = {
contractDirs: getContractDirectoriesFromList(argv.contractDirs),

View File

@ -38,17 +38,17 @@ export class Deployer {
this._artifactsDir = opts.artifactsDir;
this._networkId = opts.networkId;
this._defaults = opts.defaults;
let web3Provider: Provider;
let provider: Provider;
if (_.isUndefined((opts as ProviderDeployerOptions).provider)) {
const jsonrpcUrl = (opts as UrlDeployerOptions).jsonrpcUrl;
if (_.isUndefined(jsonrpcUrl)) {
throw new Error(`Deployer options don't contain web3Provider nor jsonrpcUrl. Please pass one of them`);
throw new Error(`Deployer options don't contain provider nor jsonrpcUrl. Please pass one of them`);
}
web3Provider = new Web3.providers.HttpProvider(jsonrpcUrl);
provider = new Web3.providers.HttpProvider(jsonrpcUrl);
} else {
web3Provider = (opts as ProviderDeployerOptions).provider;
provider = (opts as ProviderDeployerOptions).provider;
}
this.web3Wrapper = new Web3Wrapper(web3Provider, this._defaults);
this.web3Wrapper = new Web3Wrapper(provider, this._defaults);
}
/**
* Loads a contract's corresponding artifacts and deploys it with the supplied constructor arguments.
@ -170,7 +170,7 @@ export class Deployer {
const contractArtifact: ContractArtifact = require(artifactPath);
return contractArtifact;
} catch (err) {
throw new Error(`Artifact not found for contract: ${contractName}`);
throw new Error(`Artifact not found for contract: ${contractName} at ${artifactPath}`);
}
}
/**

View File

@ -14,6 +14,7 @@ import {
import { constructor_args, exchange_binary } from './fixtures/exchange_bin';
import { constants } from './util/constants';
import { provider } from './util/provider';
const expect = chai.expect;
@ -36,7 +37,7 @@ describe('#Deployer', () => {
const deployerOpts = {
artifactsDir,
networkId: constants.networkId,
jsonrpcUrl: constants.jsonrpcUrl,
provider,
defaults: {
gasPrice: constants.gasPrice,
},

View File

@ -2,7 +2,6 @@ import { BigNumber } from '@0xproject/utils';
export const constants = {
networkId: 0,
jsonrpcUrl: 'http://localhost:8545',
optimizerEnabled: false,
gasPrice: new BigNumber(20000000000),
timeoutMs: 30000,

View File

@ -0,0 +1,9 @@
import { web3Factory } from '@0xproject/dev-utils';
import { Provider } from '@0xproject/types';
import * as Web3 from 'web3';
const providerConfigs = { shouldUseInProcessGanache: true };
const web3Instance = web3Factory.create(providerConfigs);
const provider: Provider = web3Instance.currentProvider;
export { provider };

View File

@ -1,4 +1,13 @@
[
{
"timestamp": 1523462196,
"version": "0.3.5",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1522673609,
"version": "0.3.4",

View File

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

View File

@ -1,6 +1,6 @@
{
"name": "@0xproject/dev-utils",
"version": "0.3.4",
"version": "0.3.5",
"description": "0x dev TS utils",
"main": "lib/src/index.js",
"types": "lib/src/index.d.ts",
@ -26,8 +26,8 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/packages/dev-utils/README.md",
"devDependencies": {
"@0xproject/monorepo-scripts": "^0.1.16",
"@0xproject/tslint-config": "^0.4.14",
"@0xproject/monorepo-scripts": "^0.1.17",
"@0xproject/tslint-config": "^0.4.15",
"@types/lodash": "4.14.104",
"@types/mocha": "^2.2.42",
"chai": "^4.0.1",
@ -40,11 +40,11 @@
"typescript": "2.7.1"
},
"dependencies": {
"@0xproject/sol-cov": "^0.0.6",
"@0xproject/subproviders": "^0.8.4",
"@0xproject/types": "^0.5.0",
"@0xproject/typescript-typings": "^0.0.3",
"@0xproject/web3-wrapper": "^0.5.0",
"@0xproject/sol-cov": "^0.0.7",
"@0xproject/subproviders": "^0.8.5",
"@0xproject/types": "^0.6.0",
"@0xproject/typescript-typings": "^0.1.0",
"@0xproject/web3-wrapper": "^0.6.0",
"lodash": "^4.17.4",
"web3": "^0.20.0",
"web3-provider-engine": "^13.0.1"

View File

@ -8,8 +8,8 @@ import { BlockchainLifecycle, web3Factory } from '../src';
const expect = chai.expect;
describe('BlockchainLifecycle tests', () => {
const web3Provider = web3Factory.getRpcProvider();
const web3Wrapper = new Web3Wrapper(web3Provider);
const provider = web3Factory.getRpcProvider({ shouldUseInProcessGanache: true });
const web3Wrapper = new Web3Wrapper(provider);
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
describe('#startAsync/revertAsync', () => {
it('reverts changes in between', async () => {

View File

@ -8,8 +8,8 @@ import { web3Factory } from '../src';
const expect = chai.expect;
describe('RPC tests', () => {
const web3Provider = web3Factory.getRpcProvider();
const web3Wrapper = new Web3Wrapper(web3Provider);
const provider = web3Factory.getRpcProvider({ shouldUseInProcessGanache: true });
const web3Wrapper = new Web3Wrapper(provider);
describe('#mineBlockAsync', () => {
it('increases block number when called', async () => {
const blockNumberBefore = await web3Wrapper.getBlockNumberAsync();

View File

@ -1,4 +1,13 @@
[
{
"timestamp": 1523462196,
"version": "0.7.20",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1522673609,
"version": "0.7.19",

View File

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

View File

@ -1,6 +1,6 @@
{
"name": "@0xproject/json-schemas",
"version": "0.7.19",
"version": "0.7.20",
"description": "0x-related json schemas",
"main": "lib/src/index.js",
"types": "lib/src/index.d.ts",
@ -11,7 +11,7 @@
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
"coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info",
"test:circleci": "yarn test:coverage",
"run_mocha": "mocha lib/test/**/*_test.js",
"run_mocha": "mocha lib/test/**/*_test.js --exit",
"clean": "shx rm -rf lib test_temp scripts",
"build": "tsc && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts",
"manual:postpublish": "yarn build; node ./scripts/postpublish.js",
@ -42,14 +42,14 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/packages/json-schemas/README.md",
"dependencies": {
"@0xproject/typescript-typings": "^0.0.3",
"@0xproject/typescript-typings": "^0.1.0",
"jsonschema": "^1.2.0",
"lodash.values": "^4.3.0"
},
"devDependencies": {
"@0xproject/monorepo-scripts": "^0.1.16",
"@0xproject/tslint-config": "^0.4.14",
"@0xproject/utils": "^0.5.0",
"@0xproject/monorepo-scripts": "^0.1.17",
"@0xproject/tslint-config": "^0.4.15",
"@0xproject/utils": "^0.5.1",
"@types/lodash.foreach": "^4.5.3",
"@types/lodash.values": "^4.3.3",
"@types/mocha": "^2.2.42",

View File

@ -1,6 +1,6 @@
{
"name": "@0xproject/metacoin",
"version": "0.0.2",
"version": "0.0.3",
"private": true,
"description": "Example solidity project using 0x dev tools",
"scripts": {
@ -12,7 +12,7 @@
"build": "tsc",
"test": "run-s build run_mocha",
"test:coverage": "SOLIDITY_COVERAGE=true run-s build run_mocha coverage:report:text coverage:report:lcov",
"run_mocha": "mocha 'lib/test/**/*.js'",
"run_mocha": "mocha lib/test/**/*.js --bail --exit",
"generate_contract_wrappers": "node ../abi-gen/lib/index.js --abis 'artifacts/Metacoin.json' --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/contract_wrappers --backend ethers && prettier --write 'src/contract_wrappers/**.ts'",
"coverage:report:text": "istanbul report text",
"coverage:report:html": "istanbul report html && open coverage/index.html",
@ -23,21 +23,21 @@
"author": "",
"license": "Apache-2.0",
"dependencies": {
"@0xproject/abi-gen": "^0.2.9",
"@0xproject/base-contract": "^0.1.0",
"@0xproject/deployer": "^0.3.5",
"@0xproject/sol-cov": "^0.0.6",
"@0xproject/subproviders": "^0.8.4",
"@0xproject/tslint-config": "^0.4.14",
"@0xproject/types": "^0.5.0",
"@0xproject/utils": "^0.5.0",
"@0xproject/web3-wrapper": "^0.5.0",
"@0xproject/abi-gen": "^0.2.10",
"@0xproject/base-contract": "^0.2.0",
"@0xproject/deployer": "^0.4.0",
"@0xproject/sol-cov": "^0.0.7",
"@0xproject/subproviders": "^0.8.5",
"@0xproject/tslint-config": "^0.4.15",
"@0xproject/types": "^0.6.0",
"@0xproject/utils": "^0.5.1",
"@0xproject/web3-wrapper": "^0.6.0",
"ethers-contracts": "^2.2.1",
"lodash": "^4.17.4",
"web3-provider-engine": "^13.0.1"
},
"devDependencies": {
"@0xproject/dev-utils": "^0.3.4",
"@0xproject/dev-utils": "^0.3.5",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"chai-bignumber": "^2.0.1",

View File

@ -0,0 +1,69 @@
## Migrations
Migrate the 0x system of smart contracts on the network of your choice using these migrations.
## Contributing
We welcome improvements and fixes from the wider community! To report bugs within this package, please create an issue in this repository.
Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
### Install dependencies
If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
```bash
yarn config set workspaces-experimental true
```
Then install dependencies
```bash
yarn install
```
### Build
If this is your **first** time building this package, you must first build **all** packages within the monorepo. This is because packages that depend on other packages located inside this monorepo are symlinked when run from **within** the monorepo. This allows you to make changes across multiple packages without first publishing dependent packages to NPM. To build all packages, run the following from the monorepo root directory:
```bash
yarn lerna:rebuild
```
Or continuously rebuild on change:
```bash
yarn dev
```
You can also build this specific package by running the following from within its directory:
```bash
yarn build
```
or continuously rebuild on change:
```bash
yarn build:watch
```
### Clean
```bash
yarn clean
```
### Lint
```bash
yarn lint
```
### Migrate
In order to migrate the 0x smart contracts to TestRPC/Ganache running at `http://localhost:8545`, run:
```bash
yarn migrate
```

View File

@ -0,0 +1,36 @@
{
"private": true,
"name": "@0xproject/migrations",
"version": "0.0.1",
"description": "0x smart contract migrations",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
"build:watch": "tsc -w",
"build": "tsc",
"clean": "shx rm -rf lib",
"lint": "tslint --project . 'src/**/*.ts'",
"migrate": "run-s build compile script:migrate",
"script:migrate": "node ./lib/migrate.js",
"copy_artifacts": "copyfiles 'src/artifacts/**/*' ./lib",
"compile": "node ../deployer/lib/src/cli.js compile --contracts ${npm_package_config_contracts} --contracts-dir ../contracts/src/contracts --artifacts-dir src/artifacts"
},
"config": {
"contracts": "Exchange,DummyToken,ZRXToken,Token,WETH9,TokenTransferProxy,MultiSigWallet,MultiSigWalletWithTimeLock,MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress,MaliciousToken,TokenRegistry,Arbitrage,EtherDelta,AccountLevels"
},
"license": "Apache-2.0",
"devDependencies": {
"@0xproject/tslint-config": "^0.4.14",
"@0xproject/dev-utils": "^0.3.4",
"npm-run-all": "^4.1.2",
"shx": "^0.2.2",
"tslint": "5.8.0",
"typescript": "2.7.1"
},
"dependencies": {
"@0xproject/deployer": "^0.4.0",
"@0xproject/utils": "^0.5.0",
"@0xproject/web3-wrapper": "^0.5.0",
"lodash": "^4.17.4"
}
}

6
packages/migrations/src/globals.d.ts vendored Normal file
View File

@ -0,0 +1,6 @@
declare module '*.json' {
const json: any;
/* tslint:disable */
export default json;
/* tslint:enable */
}

View File

@ -0,0 +1 @@
export { runMigrationsAsync } from './migration';

View File

@ -0,0 +1,25 @@
#!/usr/bin/env node
import { Deployer } from '@0xproject/deployer';
import { devConstants } from '@0xproject/dev-utils';
import { logUtils } from '@0xproject/utils';
import * as path from 'path';
import { runMigrationsAsync } from './migration';
(async () => {
const deployerOpts = {
jsonrpcUrl: 'http://localhost:8545',
artifactsDir: path.resolve('src', 'artifacts'),
networkId: 50,
defaults: {
gas: devConstants.GAS_ESTIMATE,
},
};
const deployer = new Deployer(deployerOpts);
await runMigrationsAsync(deployer);
})().catch(err => {
logUtils.log(err);
process.exit(1);
});

View File

@ -1,12 +1,10 @@
import { Deployer } from '@0xproject/deployer';
import { BigNumber } from '@0xproject/utils';
import { BigNumber, NULL_BYTES } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as _ from 'lodash';
import { constants } from '../util/constants';
import { ContractName } from '../util/types';
import { tokenInfo } from './config/token_info';
import { ContractName } from './types';
import { tokenInfo } from './utils/token_info';
/**
* Custom migrations should be defined in this function. This will be called with the CLI 'migrate' command.
@ -20,7 +18,7 @@ export const runMigrationsAsync = async (deployer: Deployer) => {
const tokenTransferProxy = await deployer.deployAndSaveAsync(ContractName.TokenTransferProxy);
const zrxToken = await deployer.deployAndSaveAsync(ContractName.ZRXToken);
const etherToken = await deployer.deployAndSaveAsync(ContractName.EtherToken);
const etherToken = await deployer.deployAndSaveAsync(ContractName.WETH9);
const tokenReg = await deployer.deployAndSaveAsync(ContractName.TokenRegistry);
const exchangeArgs = [zrxToken.address, tokenTransferProxy.address];
@ -51,8 +49,8 @@ export const runMigrationsAsync = async (deployer: Deployer) => {
'0x Protocol Token',
'ZRX',
18,
constants.NULL_BYTES,
constants.NULL_BYTES,
NULL_BYTES,
NULL_BYTES,
{
from: owner,
gas: addTokenGasEstimate,
@ -63,8 +61,8 @@ export const runMigrationsAsync = async (deployer: Deployer) => {
'Ether Token',
'WETH',
18,
constants.NULL_BYTES,
constants.NULL_BYTES,
NULL_BYTES,
NULL_BYTES,
{
from: owner,
gas: addTokenGasEstimate,

View File

@ -0,0 +1,38 @@
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[];
}
export enum ContractName {
TokenTransferProxy = 'TokenTransferProxy',
TokenRegistry = 'TokenRegistry',
MultiSigWalletWithTimeLock = 'MultiSigWalletWithTimeLock',
Exchange = 'Exchange',
ZRXToken = 'ZRXToken',
DummyToken = 'DummyToken',
WETH9 = 'WETH9',
MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress = 'MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress',
MaliciousToken = 'MaliciousToken',
AccountLevels = 'AccountLevels',
EtherDelta = 'EtherDelta',
Arbitrage = 'Arbitrage',
}

View File

@ -1,4 +1,5 @@
import { constants } from '../../util/constants';
import { NULL_BYTES } from '@0xproject/utils';
import { Token } from '../types';
export const tokenInfo: Token[] = [
@ -6,35 +7,35 @@ export const tokenInfo: Token[] = [
name: 'Augur Reputation Token',
symbol: 'REP',
decimals: 18,
ipfsHash: constants.NULL_BYTES,
swarmHash: constants.NULL_BYTES,
ipfsHash: NULL_BYTES,
swarmHash: NULL_BYTES,
},
{
name: 'Digix DAO Token',
symbol: 'DGD',
decimals: 18,
ipfsHash: constants.NULL_BYTES,
swarmHash: constants.NULL_BYTES,
ipfsHash: NULL_BYTES,
swarmHash: NULL_BYTES,
},
{
name: 'Golem Network Token',
symbol: 'GNT',
decimals: 18,
ipfsHash: constants.NULL_BYTES,
swarmHash: constants.NULL_BYTES,
ipfsHash: NULL_BYTES,
swarmHash: NULL_BYTES,
},
{
name: 'MakerDAO',
symbol: 'MKR',
decimals: 18,
ipfsHash: constants.NULL_BYTES,
swarmHash: constants.NULL_BYTES,
ipfsHash: NULL_BYTES,
swarmHash: NULL_BYTES,
},
{
name: 'Melon Token',
symbol: 'MLN',
decimals: 18,
ipfsHash: constants.NULL_BYTES,
swarmHash: constants.NULL_BYTES,
ipfsHash: NULL_BYTES,
swarmHash: NULL_BYTES,
},
];

View File

@ -0,0 +1,7 @@
{
"extends": "../../tsconfig",
"compilerOptions": {
"outDir": "lib"
},
"include": ["src/**/*"]
}

View File

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

View File

@ -1,4 +1,13 @@
[
{
"timestamp": 1523462196,
"version": "0.1.17",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1522658513,
"version": "0.1.16",

View File

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

View File

@ -1,6 +1,6 @@
{
"name": "@0xproject/monorepo-scripts",
"version": "0.1.16",
"version": "0.1.17",
"description": "Helper scripts for the monorepo",
"main": "lib/index.js",
"types": "lib/index.d.ts",
@ -29,6 +29,7 @@
"@0xproject/tslint-config": "0.4.13",
"@types/glob": "^5.0.33",
"@types/node": "^8.0.53",
"@types/opn": "^5.1.0",
"@types/rimraf": "^2.0.2",
"depcheck": "^0.6.9",
"lerna-get-packages": "^1.0.0",
@ -45,7 +46,9 @@
"glob": "^7.1.2",
"lodash": "^4.17.4",
"moment": "2.21.0",
"opn": "^5.3.0",
"promisify-child-process": "^1.0.5",
"prompt": "^1.0.0",
"publish-release": "0xproject/publish-release",
"rimraf": "^2.6.2",
"semver-diff": "^2.1.0",

View File

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

View File

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

View File

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

View File

@ -21,3 +21,7 @@ export enum SemVerIndex {
Minor,
Major,
}
export interface PackageToVersionChange {
[name: string]: string;
}

View File

@ -1,7 +1,7 @@
{
"private": true,
"name": "@0xproject/react-docs-example",
"version": "0.0.6",
"version": "0.0.7",
"description": "An example app using react-docs",
"scripts": {
"lint": "tslint --project . 'ts/**/*.ts' 'ts/**/*.tsx'",
@ -23,7 +23,7 @@
"url": "https://github.com/0xProject/0x-monorepo.git"
},
"devDependencies": {
"@0xproject/tslint-config": "^0.4.14",
"@0xproject/tslint-config": "^0.4.15",
"@types/lodash": "4.14.104",
"@types/material-ui": "0.18.0",
"@types/node": "^8.0.53",
@ -46,7 +46,7 @@
"webpack-dev-server": "^2.11.1"
},
"dependencies": {
"@0xproject/react-docs": "^0.0.6",
"@0xproject/react-docs": "^0.0.7",
"basscss": "^8.0.3",
"lodash": "^4.17.4",
"material-ui": "^0.17.1",

View File

@ -1,6 +1,6 @@
[
{
"version": "0.0.7",
"version": "0.0.8",
"changes": [
{
"note": "Added support for rendering default param values",
@ -12,6 +12,15 @@
}
]
},
{
"timestamp": 1523462196,
"version": "0.0.7",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1522673609,
"version": "0.0.6",

View File

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

View File

@ -1,6 +1,6 @@
{
"name": "@0xproject/react-docs",
"version": "0.0.6",
"version": "0.0.7",
"description": "React documentation component for rendering TypeDoc & Doxity generated JSON",
"main": "lib/index.js",
"types": "lib/index.d.ts",
@ -22,17 +22,17 @@
"url": "https://github.com/0xProject/0x-monorepo.git"
},
"devDependencies": {
"@0xproject/dev-utils": "^0.3.4",
"@0xproject/monorepo-scripts": "^0.1.16",
"@0xproject/tslint-config": "^0.4.14",
"@0xproject/dev-utils": "^0.3.5",
"@0xproject/monorepo-scripts": "^0.1.17",
"@0xproject/tslint-config": "^0.4.15",
"copyfiles": "^1.2.0",
"shx": "^0.2.2",
"tslint": "^5.9.1",
"typescript": "2.7.1"
},
"dependencies": {
"@0xproject/react-shared": "^0.1.1",
"@0xproject/utils": "^0.5.0",
"@0xproject/react-shared": "^0.1.2",
"@0xproject/utils": "^0.5.1",
"@types/lodash": "4.14.104",
"@types/material-ui": "0.18.0",
"@types/node": "^8.0.53",

View File

@ -1,4 +1,13 @@
[
{
"timestamp": 1523462196,
"version": "0.1.2",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1522673609,
"version": "0.1.1",

View File

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

View File

@ -1,6 +1,6 @@
{
"name": "@0xproject/react-shared",
"version": "0.1.1",
"version": "0.1.2",
"description": "0x shared react components",
"main": "lib/index.js",
"types": "lib/index.d.ts",
@ -22,9 +22,9 @@
"url": "https://github.com/0xProject/0x-monorepo.git"
},
"devDependencies": {
"@0xproject/dev-utils": "^0.3.4",
"@0xproject/monorepo-scripts": "^0.1.16",
"@0xproject/tslint-config": "^0.4.14",
"@0xproject/dev-utils": "^0.3.5",
"@0xproject/monorepo-scripts": "^0.1.17",
"@0xproject/tslint-config": "^0.4.15",
"copyfiles": "^1.2.0",
"shx": "^0.2.2",
"tslint": "^5.9.1",

View File

@ -1,4 +1,13 @@
[
{
"timestamp": 1523462196,
"version": "0.0.7",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1522673609,
"version": "0.0.6",

View File

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

View File

@ -1,6 +1,6 @@
{
"name": "@0xproject/sol-cov",
"version": "0.0.6",
"version": "0.0.7",
"description": "Generate coverage reports for Solidity code",
"main": "lib/src/index.js",
"types": "lib/src/index.d.ts",
@ -11,7 +11,7 @@
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
"coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info",
"test:circleci": "yarn test:coverage",
"run_mocha": "mocha lib/test/**/*_test.js",
"run_mocha": "mocha lib/test/**/*_test.js --exit",
"clean": "shx rm -rf lib scripts",
"build": "copyfiles 'test/fixtures/**/*' ./lib && tsc && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts",
"manual:postpublish": "yarn build; node ./scripts/postpublish.js",
@ -42,9 +42,9 @@
},
"homepage": "https://github.com/0xProject/0x.js/packages/sol-cov/README.md",
"dependencies": {
"@0xproject/subproviders": "^0.8.4",
"@0xproject/types": "^0.5.0",
"@0xproject/typescript-typings": "^0.0.3",
"@0xproject/subproviders": "^0.8.5",
"@0xproject/types": "^0.6.0",
"@0xproject/typescript-typings": "^0.1.0",
"ethereumjs-util": "^5.1.1",
"glob": "^7.1.2",
"istanbul": "^0.4.5",
@ -53,8 +53,8 @@
"solidity-parser-antlr": "^0.2.8"
},
"devDependencies": {
"@0xproject/monorepo-scripts": "^0.1.16",
"@0xproject/tslint-config": "^0.4.14",
"@0xproject/monorepo-scripts": "^0.1.17",
"@0xproject/tslint-config": "^0.4.15",
"@types/istanbul": "^0.4.29",
"@types/mocha": "^2.2.42",
"@types/node": "^8.0.53",

View File

@ -56,8 +56,8 @@ export class CoverageSubprovider extends Subprovider {
* @param next Callback to call if this subprovider decides not to handle the request
* @param end Callback to call if subprovider handled the request and wants to pass back the request.
*/
// tslint:disable-next-line:prefer-function-over-method
public handleRequest(payload: JSONRPCRequestPayload, next: NextCallback, end: ErrorCallback) {
// tslint:disable-next-line:prefer-function-over-method async-suffix
public async handleRequest(payload: JSONRPCRequestPayload, next: NextCallback, end: ErrorCallback) {
switch (payload.method) {
case 'eth_sendTransaction':
const txData = payload.params[0];

View File

@ -1,4 +1,13 @@
[
{
"timestamp": 1523462196,
"version": "0.0.8",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1522673609,
"version": "0.0.7",

View File

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

View File

@ -1,6 +1,6 @@
{
"name": "@0xproject/sra-report",
"version": "0.0.7",
"version": "0.0.8",
"description": "Generate reports for standard relayer API compliance",
"main": "lib/index.js",
"types": "lib/index.d.ts",
@ -12,7 +12,7 @@
"test": "run-s clean build copy_test_environments copy_test_fixtures run_mocha",
"copy_test_fixtures": "copyfiles -u 2 './test/fixtures/**/*.json' ./lib/test/fixtures",
"copy_test_environments": "copyfiles -u 2 './test/environments/**/*.json' ./lib/test/environments",
"run_mocha": "mocha lib/test/**/*_test.js",
"run_mocha": "mocha lib/test/**/*_test.js --exit",
"manual:postpublish": "yarn build; node ./scripts/postpublish.js"
},
"bin": {
@ -28,20 +28,20 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/packages/sra-report/README.md",
"dependencies": {
"0x.js": "^0.35.0",
"@0xproject/assert": "^0.2.5",
"@0xproject/connect": "^0.6.8",
"@0xproject/json-schemas": "^0.7.19",
"@0xproject/typescript-typings": "^0.0.3",
"@0xproject/utils": "^0.5.0",
"0x.js": "^0.36.0",
"@0xproject/assert": "^0.2.6",
"@0xproject/connect": "^0.6.9",
"@0xproject/json-schemas": "^0.7.20",
"@0xproject/typescript-typings": "^0.1.0",
"@0xproject/utils": "^0.5.1",
"chalk": "^2.3.0",
"lodash": "^4.17.4",
"newman": "^3.9.3",
"yargs": "^10.0.3"
},
"devDependencies": {
"@0xproject/monorepo-scripts": "^0.1.16",
"@0xproject/tslint-config": "^0.4.14",
"@0xproject/monorepo-scripts": "^0.1.17",
"@0xproject/tslint-config": "^0.4.15",
"@types/lodash": "4.14.104",
"@types/mocha": "^2.2.48",
"@types/nock": "^9.1.2",

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