aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contract-wrappers
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-05-24 05:16:32 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-05-24 05:16:32 +0800
commit3fe94891d3569a4615f4aa32d47f0065b5957fe9 (patch)
tree83d4e4ccf7748d2100aa935c457de0a893eaec9c /packages/contract-wrappers
parentd0abc60176dba3116cb3986d298ab5164c1fe49c (diff)
parentf6b81f588d98e09e7a5806902d94e2892d029481 (diff)
downloaddexon-sol-tools-3fe94891d3569a4615f4aa32d47f0065b5957fe9.tar
dexon-sol-tools-3fe94891d3569a4615f4aa32d47f0065b5957fe9.tar.gz
dexon-sol-tools-3fe94891d3569a4615f4aa32d47f0065b5957fe9.tar.bz2
dexon-sol-tools-3fe94891d3569a4615f4aa32d47f0065b5957fe9.tar.lz
dexon-sol-tools-3fe94891d3569a4615f4aa32d47f0065b5957fe9.tar.xz
dexon-sol-tools-3fe94891d3569a4615f4aa32d47f0065b5957fe9.tar.zst
dexon-sol-tools-3fe94891d3569a4615f4aa32d47f0065b5957fe9.zip
Merge branch 'v2-prototype' into feature/website/wallet-flex-box
* v2-prototype: (95 commits) Add missing dep to website Upgrade solidity parser Fix trace test Fix linter issues Move contract utils Fix prettier Fix NameResolver Fix prettier Remove 0x.js as a dependency from website Enable 0x.js tests Fix small bug in order-utils Address feedback Fix Tslint error caused by "PromiseLike" value Fix Tslint error caused by "PromiseLike" value Update dogfood url fix contract-wrappers version Parse compiler.json in SolCompilerArtifactsAdapter Fix TokenTransferProxy artifact name since it's now suffixed with _v1 Update yarn.lock Fix signature verification test ...
Diffstat (limited to 'packages/contract-wrappers')
-rw-r--r--packages/contract-wrappers/CHANGELOG.json10
-rw-r--r--packages/contract-wrappers/CHANGELOG.md8
-rw-r--r--packages/contract-wrappers/package.json36
-rw-r--r--packages/contract-wrappers/src/schemas/contract_wrappers_public_network_config_schema.ts16
-rw-r--r--packages/contract-wrappers/src/utils/constants.ts1
-rw-r--r--packages/contract-wrappers/src/utils/filter_utils.ts8
-rw-r--r--packages/contract-wrappers/src/utils/utils.ts3
-rw-r--r--packages/contract-wrappers/test/artifacts_test.ts4
-rw-r--r--packages/contract-wrappers/test/ether_token_wrapper_test.ts4
-rw-r--r--packages/contract-wrappers/test/global_hooks.ts3
-rw-r--r--packages/contract-wrappers/test/order_validation_test.ts7
-rw-r--r--packages/contract-wrappers/test/utils/web3_wrapper.ts5
12 files changed, 73 insertions, 32 deletions
diff --git a/packages/contract-wrappers/CHANGELOG.json b/packages/contract-wrappers/CHANGELOG.json
index 18ca4143e..84e773933 100644
--- a/packages/contract-wrappers/CHANGELOG.json
+++ b/packages/contract-wrappers/CHANGELOG.json
@@ -1,5 +1,15 @@
[
{
+ "version": "0.0.2",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ],
+ "timestamp": 1527008544
+ },
+ {
+ "timestamp": 1527008270,
"version": "0.0.1",
"changes": [
{
diff --git a/packages/contract-wrappers/CHANGELOG.md b/packages/contract-wrappers/CHANGELOG.md
index 5565d6210..c8a0145d5 100644
--- a/packages/contract-wrappers/CHANGELOG.md
+++ b/packages/contract-wrappers/CHANGELOG.md
@@ -4,3 +4,11 @@ Edit the package's CHANGELOG.json file only.
-->
CHANGELOG
+
+## v0.0.2 - _May 22, 2018_
+
+ * Dependencies updated
+
+## v0.0.1 - _May 22, 2018_
+
+ * Moved contractWrappers out of 0x.js (#579)
diff --git a/packages/contract-wrappers/package.json b/packages/contract-wrappers/package.json
index 6cb16c2c0..10719c831 100644
--- a/packages/contract-wrappers/package.json
+++ b/packages/contract-wrappers/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/contract-wrappers",
- "version": "0.0.1",
+ "version": "0.0.2",
"description": "Smart TS wrappers for 0x smart contracts",
"keywords": [
"0xproject",
@@ -27,7 +27,7 @@
},
"config": {
"compact_artifacts": "Exchange DummyToken ZRXToken Token EtherToken TokenTransferProxy TokenRegistry",
- "contracts": "Exchange DummyToken ZRXToken Token WETH9 TokenTransferProxy MultiSigWallet MultiSigWalletWithTimeLock MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress MaliciousToken TokenRegistry Arbitrage EtherDelta AccountLevels",
+ "contracts": "Exchange DummyToken ZRXToken Token WETH9 TokenTransferProxy_v1 MultiSigWallet MultiSigWalletWithTimeLock MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress MaliciousToken TokenRegistry Arbitrage EtherDelta AccountLevels",
"postpublish": {
"assets": [
"packages/contract-wrappers/_bundles/index.js",
@@ -44,13 +44,13 @@
"node": ">=6.0.0"
},
"devDependencies": {
- "@0xproject/abi-gen": "^0.2.13",
- "@0xproject/dev-utils": "^0.4.1",
- "@0xproject/migrations": "^0.0.5",
- "@0xproject/monorepo-scripts": "^0.1.19",
- "@0xproject/sol-compiler": "^0.4.3",
- "@0xproject/subproviders": "^0.10.1",
- "@0xproject/tslint-config": "^0.4.17",
+ "@0xproject/abi-gen": "^0.3.0",
+ "@0xproject/dev-utils": "^0.4.2",
+ "@0xproject/migrations": "^0.0.6",
+ "@0xproject/monorepo-scripts": "^0.1.20",
+ "@0xproject/sol-compiler": "^0.5.0",
+ "@0xproject/subproviders": "^0.10.2",
+ "@0xproject/tslint-config": "^0.4.18",
"@types/lodash": "4.14.104",
"@types/mocha": "^2.2.42",
"@types/node": "^8.0.53",
@@ -76,15 +76,15 @@
"web3-provider-engine": "^14.0.4"
},
"dependencies": {
- "@0xproject/assert": "^0.2.9",
- "@0xproject/base-contract": "^0.3.1",
- "@0xproject/fill-scenarios": "^0.0.1",
- "@0xproject/json-schemas": "^0.7.23",
- "@0xproject/order-utils": "^0.0.4",
- "@0xproject/types": "^0.6.3",
- "@0xproject/typescript-typings": "^0.3.1",
- "@0xproject/utils": "^0.6.1",
- "@0xproject/web3-wrapper": "^0.6.3",
+ "@0xproject/assert": "^0.2.10",
+ "@0xproject/base-contract": "^0.3.2",
+ "@0xproject/fill-scenarios": "^0.0.2",
+ "@0xproject/json-schemas": "^0.7.24",
+ "@0xproject/order-utils": "^0.0.5",
+ "@0xproject/types": "^0.7.0",
+ "@0xproject/typescript-typings": "^0.3.2",
+ "@0xproject/utils": "^0.6.2",
+ "@0xproject/web3-wrapper": "^0.6.4",
"ethereumjs-blockstream": "^2.0.6",
"ethereumjs-util": "^5.1.1",
"ethers": "^3.0.15",
diff --git a/packages/contract-wrappers/src/schemas/contract_wrappers_public_network_config_schema.ts b/packages/contract-wrappers/src/schemas/contract_wrappers_public_network_config_schema.ts
index bf1000afa..304cd100b 100644
--- a/packages/contract-wrappers/src/schemas/contract_wrappers_public_network_config_schema.ts
+++ b/packages/contract-wrappers/src/schemas/contract_wrappers_public_network_config_schema.ts
@@ -1,9 +1,23 @@
+const networkNameToId: { [networkName: string]: number } = {
+ mainnet: 1,
+ ropsten: 3,
+ rinkeby: 4,
+ kovan: 42,
+ ganache: 50,
+};
+
export const contractWrappersPublicNetworkConfigSchema = {
id: '/ZeroExContractPublicNetworkConfig',
properties: {
networkId: {
type: 'number',
- enum: [1, 3, 4, 42, 50],
+ enum: [
+ networkNameToId.mainnet,
+ networkNameToId.kovan,
+ networkNameToId.ropsten,
+ networkNameToId.rinkeby,
+ networkNameToId.ganache,
+ ],
},
gasPrice: { $ref: '/Number' },
zrxContractAddress: { $ref: '/Address' },
diff --git a/packages/contract-wrappers/src/utils/constants.ts b/packages/contract-wrappers/src/utils/constants.ts
index 07da6745d..76d805cac 100644
--- a/packages/contract-wrappers/src/utils/constants.ts
+++ b/packages/contract-wrappers/src/utils/constants.ts
@@ -6,6 +6,7 @@ export const constants = {
INVALID_JUMP_PATTERN: 'invalid JUMP at',
OUT_OF_GAS_PATTERN: 'out of gas',
INVALID_TAKER_FORMAT: 'instance.taker is not of a type(s) string',
+ // tslint:disable-next-line:custom-no-magic-numbers
UNLIMITED_ALLOWANCE_IN_BASE_UNITS: new BigNumber(2).pow(256).minus(1),
DEFAULT_BLOCK_POLLING_INTERVAL: 1000,
};
diff --git a/packages/contract-wrappers/src/utils/filter_utils.ts b/packages/contract-wrappers/src/utils/filter_utils.ts
index c5df7321e..4ec9e256b 100644
--- a/packages/contract-wrappers/src/utils/filter_utils.ts
+++ b/packages/contract-wrappers/src/utils/filter_utils.ts
@@ -73,14 +73,14 @@ export const filterUtils = {
return false;
}
if (!_.isUndefined(filter.topics)) {
- return filterUtils.matchesTopics(log.topics, filter.topics);
+ return filterUtils.doesMatchTopics(log.topics, filter.topics);
}
return true;
},
- matchesTopics(logTopics: string[], filterTopics: Array<string[] | string | null>): boolean {
+ doesMatchTopics(logTopics: string[], filterTopics: Array<string[] | string | null>): boolean {
const matchesTopic = _.zipWith(logTopics, filterTopics, filterUtils.matchesTopic.bind(filterUtils));
- const matchesTopics = _.every(matchesTopic);
- return matchesTopics;
+ const doesMatchTopics = _.every(matchesTopic);
+ return doesMatchTopics;
},
matchesTopic(logTopic: string, filterTopic: string[] | string | null): boolean {
if (_.isArray(filterTopic)) {
diff --git a/packages/contract-wrappers/src/utils/utils.ts b/packages/contract-wrappers/src/utils/utils.ts
index af1125632..7cf9450a0 100644
--- a/packages/contract-wrappers/src/utils/utils.ts
+++ b/packages/contract-wrappers/src/utils/utils.ts
@@ -5,7 +5,8 @@ export const utils = {
return new Error(`Unexpected switch value: ${value} encountered for ${name}`);
},
getCurrentUnixTimestampSec(): BigNumber {
- return new BigNumber(Date.now() / 1000).round();
+ const milisecondsInSecond = 1000;
+ return new BigNumber(Date.now() / milisecondsInSecond).round();
},
getCurrentUnixTimestampMs(): BigNumber {
return new BigNumber(Date.now());
diff --git a/packages/contract-wrappers/test/artifacts_test.ts b/packages/contract-wrappers/test/artifacts_test.ts
index 446b8f9d1..eaaa89c48 100644
--- a/packages/contract-wrappers/test/artifacts_test.ts
+++ b/packages/contract-wrappers/test/artifacts_test.ts
@@ -15,7 +15,7 @@ const TIMEOUT = 10000;
describe('Artifacts', () => {
describe('contracts are deployed on kovan', () => {
const kovanRpcUrl = constants.KOVAN_RPC_URL;
- const provider = web3Factory.create({ rpcUrl: kovanRpcUrl }).currentProvider;
+ const provider = web3Factory.getRpcProvider({ rpcUrl: kovanRpcUrl });
const config = {
networkId: constants.KOVAN_NETWORK_ID,
};
@@ -32,7 +32,7 @@ describe('Artifacts', () => {
});
describe('contracts are deployed on ropsten', () => {
const ropstenRpcUrl = constants.ROPSTEN_RPC_URL;
- const provider = web3Factory.create({ rpcUrl: ropstenRpcUrl }).currentProvider;
+ const provider = web3Factory.getRpcProvider({ rpcUrl: ropstenRpcUrl });
const config = {
networkId: constants.ROPSTEN_NETWORK_ID,
};
diff --git a/packages/contract-wrappers/test/ether_token_wrapper_test.ts b/packages/contract-wrappers/test/ether_token_wrapper_test.ts
index 974db34b1..e06fe96e5 100644
--- a/packages/contract-wrappers/test/ether_token_wrapper_test.ts
+++ b/packages/contract-wrappers/test/ether_token_wrapper_test.ts
@@ -42,7 +42,7 @@ describe('EtherTokenWrapper', () => {
let addressWithETH: string;
let wethContractAddress: string;
let depositWeiAmount: BigNumber;
- let decimalPlaces: number;
+ const decimalPlaces = 7;
let addressWithoutFunds: string;
const gasPrice = new BigNumber(1);
const zeroExConfig = {
@@ -60,7 +60,6 @@ describe('EtherTokenWrapper', () => {
addressWithETH = userAddresses[0];
wethContractAddress = contractWrappers.etherToken.getContractAddressIfExists() as string;
depositWeiAmount = Web3Wrapper.toWei(new BigNumber(5));
- decimalPlaces = 7;
addressWithoutFunds = userAddresses[1];
});
beforeEach(async () => {
@@ -155,6 +154,7 @@ describe('EtherTokenWrapper', () => {
const preWETHBalance = await contractWrappers.token.getBalanceAsync(wethContractAddress, addressWithETH);
expect(preWETHBalance).to.be.bignumber.equal(0);
+ // tslint:disable-next-line:custom-no-magic-numbers
const overWETHBalance = preWETHBalance.add(999999999);
return expect(
diff --git a/packages/contract-wrappers/test/global_hooks.ts b/packages/contract-wrappers/test/global_hooks.ts
index 53b3ef545..fa1dfae38 100644
--- a/packages/contract-wrappers/test/global_hooks.ts
+++ b/packages/contract-wrappers/test/global_hooks.ts
@@ -8,7 +8,8 @@ import { provider } from './utils/web3_wrapper';
before('migrate contracts', async function(): Promise<void> {
// HACK: Since the migrations take longer then our global mocha timeout limit
// we manually increase it for this before hook.
- this.timeout(20000);
+ const mochaTestTimeoutMs = 20000;
+ this.timeout(mochaTestTimeoutMs);
const txDefaults = {
gas: devConstants.GAS_ESTIMATE,
from: devConstants.TESTRPC_FIRST_ADDRESS,
diff --git a/packages/contract-wrappers/test/order_validation_test.ts b/packages/contract-wrappers/test/order_validation_test.ts
index 2acdece3e..a14dc24b6 100644
--- a/packages/contract-wrappers/test/order_validation_test.ts
+++ b/packages/contract-wrappers/test/order_validation_test.ts
@@ -106,6 +106,7 @@ describe('OrderValidation', () => {
});
it('should succeed if the order is asymmetric and fillable', async () => {
const makerFillableAmount = fillableAmount;
+ // tslint:disable-next-line:custom-no-magic-numbers
const takerFillableAmount = fillableAmount.minus(4);
const signedOrder = await fillScenarios.createAsymmetricFillableSignedOrderAsync(
makerTokenAddress,
@@ -172,6 +173,7 @@ describe('OrderValidation', () => {
fillableAmount,
);
// 27 <--> 28
+ // tslint:disable-next-line:custom-no-magic-numbers
signedOrder.ecSignature.v = 28 - signedOrder.ecSignature.v + 27;
return expect(
contractWrappers.exchange.validateFillOrderThrowIfInvalidAsync(
@@ -206,6 +208,7 @@ describe('OrderValidation', () => {
takerAddress,
fillableAmount,
);
+ // tslint:disable-next-line:custom-no-magic-numbers
const nonTakerAddress = userAddresses[6];
return expect(
contractWrappers.exchange.validateFillOrderThrowIfInvalidAsync(
@@ -353,6 +356,7 @@ describe('OrderValidation', () => {
takerAddress,
zrxTokenAddress,
);
+ // tslint:disable-next-line:custom-no-magic-numbers
expect(transferFromAsync.callCount).to.be.equal(4);
expect(
transferFromAsync
@@ -423,6 +427,7 @@ describe('OrderValidation', () => {
takerAddress,
zrxTokenAddress,
);
+ // tslint:disable-next-line:custom-no-magic-numbers
expect(transferFromAsync.callCount).to.be.equal(4);
expect(
transferFromAsync
@@ -491,6 +496,7 @@ describe('OrderValidation', () => {
takerAddress,
zrxTokenAddress,
);
+ // tslint:disable-next-line:custom-no-magic-numbers
expect(transferFromAsync.callCount).to.be.equal(4);
const makerFillAmount = transferFromAsync.getCall(0).args[3];
expect(makerFillAmount).to.be.bignumber.equal(makerTokenAmount);
@@ -518,6 +524,7 @@ describe('OrderValidation', () => {
);
const makerPartialFee = makerFee.div(2);
const takerPartialFee = takerFee.div(2);
+ // tslint:disable-next-line:custom-no-magic-numbers
expect(transferFromAsync.callCount).to.be.equal(4);
const partialMakerFee = transferFromAsync.getCall(2).args[3];
expect(partialMakerFee).to.be.bignumber.equal(makerPartialFee);
diff --git a/packages/contract-wrappers/test/utils/web3_wrapper.ts b/packages/contract-wrappers/test/utils/web3_wrapper.ts
index b0ccfa546..71a0dc1c2 100644
--- a/packages/contract-wrappers/test/utils/web3_wrapper.ts
+++ b/packages/contract-wrappers/test/utils/web3_wrapper.ts
@@ -2,8 +2,7 @@ import { devConstants, web3Factory } from '@0xproject/dev-utils';
import { Provider } from '@0xproject/types';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
-const web3 = web3Factory.create({ shouldUseInProcessGanache: true });
-const provider: Provider = web3.currentProvider;
-const web3Wrapper = new Web3Wrapper(web3.currentProvider);
+const provider: Provider = web3Factory.getRpcProvider({ shouldUseInProcessGanache: true });
+const web3Wrapper = new Web3Wrapper(provider);
export { provider, web3Wrapper };