aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
Diffstat (limited to 'packages')
-rw-r--r--packages/0x.js/CHANGELOG.json9
-rw-r--r--packages/0x.js/package.json4
-rw-r--r--packages/0x.js/src/order_watcher/expiration_watcher.ts13
-rw-r--r--packages/0x.js/test/0x.js_test.ts7
-rw-r--r--packages/0x.js/test/expiration_watcher_test.ts39
-rw-r--r--packages/0x.js/test/global_hooks.ts7
-rw-r--r--packages/base-contract/CHANGELOG.json9
-rw-r--r--packages/base-contract/package.json2
-rw-r--r--packages/base-contract/src/index.ts8
-rw-r--r--packages/contract_templates/contract.handlebars2
-rw-r--r--packages/contract_templates/partials/callAsync.handlebars11
-rw-r--r--packages/contract_templates/partials/return_type.handlebars2
-rw-r--r--packages/metacoin/package.json2
-rw-r--r--packages/migrations/src/migration.ts2
-rw-r--r--packages/typescript-typings/CHANGELOG.json9
-rw-r--r--packages/typescript-typings/types/ethers/index.d.ts (renamed from packages/typescript-typings/types/ethers-contracts/index.d.ts)9
-rw-r--r--packages/utils/CHANGELOG.json9
-rw-r--r--packages/utils/package.json2
-rw-r--r--packages/utils/src/abi_decoder.ts8
-rw-r--r--packages/web3-wrapper/package.json2
-rw-r--r--packages/website/public/images/landing/project_logos/imToken.pngbin0 -> 4933 bytes
-rw-r--r--packages/website/ts/pages/landing/landing.tsx12
-rw-r--r--packages/website/ts/utils/constants.ts2
23 files changed, 129 insertions, 41 deletions
diff --git a/packages/0x.js/CHANGELOG.json b/packages/0x.js/CHANGELOG.json
index 04d115809..ef4bb1e07 100644
--- a/packages/0x.js/CHANGELOG.json
+++ b/packages/0x.js/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "version": "0.36.4",
+ "changes": [
+ {
+ "note": "Fixed expiration watcher comparator to handle orders with equal expiration times",
+ "pr": 526
+ }
+ ]
+ },
+ {
"version": "0.36.3",
"changes": [
{
diff --git a/packages/0x.js/package.json b/packages/0x.js/package.json
index 4b2d92240..e7cdff09e 100644
--- a/packages/0x.js/package.json
+++ b/packages/0x.js/package.json
@@ -26,7 +26,7 @@
"build:umd:prod": "NODE_ENV=production webpack",
"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",
+ "run_mocha": "mocha lib/test/**/*_test.js lib/test/global_hooks.js --timeout 10000 --bail --exit",
"manual:postpublish": "yarn build; node ./scripts/postpublish.js",
"docs:stage": "yarn build && node ./scripts/stage_docs.js",
"docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --json $JSON_FILE_PATH $PROJECT_FILES",
@@ -109,7 +109,7 @@
"ethereumjs-abi": "^0.6.4",
"ethereumjs-blockstream": "^2.0.6",
"ethereumjs-util": "^5.1.1",
- "ethers-contracts": "^2.2.1",
+ "ethers": "^3.0.15",
"js-sha3": "^0.7.0",
"lodash": "^4.17.4",
"uuid": "^3.1.0",
diff --git a/packages/0x.js/src/order_watcher/expiration_watcher.ts b/packages/0x.js/src/order_watcher/expiration_watcher.ts
index 8b306bf3b..27ec7107d 100644
--- a/packages/0x.js/src/order_watcher/expiration_watcher.ts
+++ b/packages/0x.js/src/order_watcher/expiration_watcher.ts
@@ -22,8 +22,17 @@ export class ExpirationWatcher {
this._expirationMarginMs = expirationMarginIfExistsMs || DEFAULT_EXPIRATION_MARGIN_MS;
this._orderExpirationCheckingIntervalMs =
expirationMarginIfExistsMs || DEFAULT_ORDER_EXPIRATION_CHECKING_INTERVAL_MS;
- const scoreFunction = (orderHash: string) => this._expiration[orderHash].toNumber();
- const comparator = (lhs: string, rhs: string) => scoreFunction(lhs) - scoreFunction(rhs);
+ const comparator = (lhsOrderHash: string, rhsOrderHash: string) => {
+ const lhsExpiration = this._expiration[lhsOrderHash].toNumber();
+ const rhsExpiration = this._expiration[rhsOrderHash].toNumber();
+ if (lhsExpiration !== rhsExpiration) {
+ return lhsExpiration - rhsExpiration;
+ } else {
+ // HACK: If two orders have identical expirations, the order in which they are emitted by the
+ // ExpirationWatcher does not matter, so we emit them in alphabetical order by orderHash.
+ return lhsOrderHash.localeCompare(rhsOrderHash);
+ }
+ };
this._orderHashByExpirationRBTree = new RBTree(comparator);
}
public subscribe(callback: (orderHash: string) => void): void {
diff --git a/packages/0x.js/test/0x.js_test.ts b/packages/0x.js/test/0x.js_test.ts
index de5a6be58..838ee7080 100644
--- a/packages/0x.js/test/0x.js_test.ts
+++ b/packages/0x.js/test/0x.js_test.ts
@@ -1,9 +1,4 @@
-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';
@@ -15,7 +10,6 @@ import { ApprovalContractEventArgs, LogWithDecodedArgs, Order, TokenEvents, Zero
import { chaiSetup } from './utils/chai_setup';
import { constants } from './utils/constants';
-import { deployer } from './utils/deployer';
import { TokenUtils } from './utils/token_utils';
import { provider, web3Wrapper } from './utils/web3_wrapper';
@@ -28,7 +22,6 @@ const SHOULD_ADD_PERSONAL_MESSAGE_PREFIX = false;
describe('ZeroEx library', () => {
let zeroEx: ZeroEx;
before(async () => {
- await runMigrationsAsync(deployer);
const config = {
networkId: constants.TESTRPC_NETWORK_ID,
};
diff --git a/packages/0x.js/test/expiration_watcher_test.ts b/packages/0x.js/test/expiration_watcher_test.ts
index 29b111fa3..1b022539a 100644
--- a/packages/0x.js/test/expiration_watcher_test.ts
+++ b/packages/0x.js/test/expiration_watcher_test.ts
@@ -153,4 +153,43 @@ describe('ExpirationWatcher', () => {
timer.tick(order2Lifetime * 1000);
})().catch(done);
});
+ it('emits events in correct order when expirations are equal', (done: DoneCallback) => {
+ (async () => {
+ const order1Lifetime = 60;
+ const order2Lifetime = 60;
+ const order1ExpirationUnixTimestampSec = currentUnixTimestampSec.plus(order1Lifetime);
+ const order2ExpirationUnixTimestampSec = currentUnixTimestampSec.plus(order2Lifetime);
+ const signedOrder1 = await fillScenarios.createFillableSignedOrderAsync(
+ makerTokenAddress,
+ takerTokenAddress,
+ makerAddress,
+ takerAddress,
+ fillableAmount,
+ order1ExpirationUnixTimestampSec,
+ );
+ const signedOrder2 = await fillScenarios.createFillableSignedOrderAsync(
+ makerTokenAddress,
+ takerTokenAddress,
+ makerAddress,
+ takerAddress,
+ fillableAmount,
+ order2ExpirationUnixTimestampSec,
+ );
+ const orderHash1 = ZeroEx.getOrderHashHex(signedOrder1);
+ const orderHash2 = ZeroEx.getOrderHashHex(signedOrder2);
+ expirationWatcher.addOrder(orderHash1, signedOrder1.expirationUnixTimestampSec.times(1000));
+ expirationWatcher.addOrder(orderHash2, signedOrder2.expirationUnixTimestampSec.times(1000));
+ const expirationOrder = orderHash1 < orderHash2 ? [orderHash1, orderHash2] : [orderHash2, orderHash1];
+ const expectToBeCalledOnce = false;
+ const callbackAsync = reportNoErrorCallbackErrors(done, expectToBeCalledOnce)((hash: string) => {
+ const orderHash = expirationOrder.shift();
+ expect(hash).to.be.equal(orderHash);
+ if (_.isEmpty(expirationOrder)) {
+ done();
+ }
+ });
+ expirationWatcher.subscribe(callbackAsync);
+ timer.tick(order2Lifetime * 1000);
+ })().catch(done);
+ });
});
diff --git a/packages/0x.js/test/global_hooks.ts b/packages/0x.js/test/global_hooks.ts
new file mode 100644
index 000000000..e3c986524
--- /dev/null
+++ b/packages/0x.js/test/global_hooks.ts
@@ -0,0 +1,7 @@
+import { runMigrationsAsync } from '@0xproject/migrations';
+
+import { deployer } from './utils/deployer';
+
+before('migrate contracts', async () => {
+ await runMigrationsAsync(deployer);
+});
diff --git a/packages/base-contract/CHANGELOG.json b/packages/base-contract/CHANGELOG.json
index ed3c86465..c5d467b7f 100644
--- a/packages/base-contract/CHANGELOG.json
+++ b/packages/base-contract/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "version": "0.3.0",
+ "changes": [
+ {
+ "note": "Update ethers-contracts to ethers.js",
+ "pr": 540
+ }
+ ]
+ },
+ {
"timestamp": 1524044013,
"version": "0.2.1",
"changes": [
diff --git a/packages/base-contract/package.json b/packages/base-contract/package.json
index 22ae43cdc..78dcbfe7f 100644
--- a/packages/base-contract/package.json
+++ b/packages/base-contract/package.json
@@ -42,7 +42,7 @@
"@0xproject/typescript-typings": "^0.2.0",
"@0xproject/utils": "^0.5.2",
"@0xproject/web3-wrapper": "^0.6.1",
- "ethers-contracts": "^2.2.1",
+ "ethers": "^3.0.15",
"lodash": "^4.17.4"
},
"publishConfig": {
diff --git a/packages/base-contract/src/index.ts b/packages/base-contract/src/index.ts
index bfa99fac1..e95b18db6 100644
--- a/packages/base-contract/src/index.ts
+++ b/packages/base-contract/src/index.ts
@@ -10,13 +10,13 @@ import {
} from '@0xproject/types';
import { abiUtils, BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
-import * as ethersContracts from 'ethers-contracts';
+import * as ethers from 'ethers';
import * as _ from 'lodash';
import { formatABIDataItem } from './utils';
export interface EthersInterfaceByFunctionSignature {
- [key: string]: ethersContracts.Interface;
+ [key: string]: ethers.Interface;
}
export class BaseContract {
@@ -62,7 +62,7 @@ export class BaseContract {
}
return txDataWithDefaults;
}
- protected _lookupEthersInterface(functionSignature: string): ethersContracts.Interface {
+ protected _lookupEthersInterface(functionSignature: string): ethers.Interface {
const ethersInterface = this._ethersInterfacesByFunctionSignature[functionSignature];
if (_.isUndefined(ethersInterface)) {
throw new Error(`Failed to lookup method with function signature '${functionSignature}'`);
@@ -92,7 +92,7 @@ export class BaseContract {
this._ethersInterfacesByFunctionSignature = {};
_.each(methodAbis, methodAbi => {
const functionSignature = abiUtils.getFunctionSignature(methodAbi);
- this._ethersInterfacesByFunctionSignature[functionSignature] = new ethersContracts.Interface([methodAbi]);
+ this._ethersInterfacesByFunctionSignature[functionSignature] = new ethers.Interface([methodAbi]);
});
}
}
diff --git a/packages/contract_templates/contract.handlebars b/packages/contract_templates/contract.handlebars
index 472452d74..cf51dad90 100644
--- a/packages/contract_templates/contract.handlebars
+++ b/packages/contract_templates/contract.handlebars
@@ -8,7 +8,7 @@ import { BaseContract } from '@0xproject/base-contract';
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, DataItem, MethodAbi, Provider, TxData, TxDataPayable } from '@0xproject/types';
import { BigNumber, classUtils, promisify } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
-import * as ethersContracts from 'ethers-contracts';
+import * as ethers from 'ethers';
import * as _ from 'lodash';
{{#if events}}
diff --git a/packages/contract_templates/partials/callAsync.handlebars b/packages/contract_templates/partials/callAsync.handlebars
index a6f4abdf2..58fb2f09c 100644
--- a/packages/contract_templates/partials/callAsync.handlebars
+++ b/packages/contract_templates/partials/callAsync.handlebars
@@ -5,20 +5,21 @@ async callAsync(
defaultBlock?: BlockParam,
): Promise<{{> return_type outputs=outputs}}> {
const self = this as any as {{contractName}}Contract;
- const inputAbi = self._lookupAbi('{{this.functionSignature}}').inputs;
+ const functionSignature = '{{this.functionSignature}}';
+ const inputAbi = self._lookupAbi(functionSignature).inputs;
[{{> params inputs=inputs}}] = BaseContract._formatABIDataItemList(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(self));
- const encodedData = self._lookupEthersInterface('{{this.functionSignature}}').functions.{{this.name}}(
+ const ethersFunction = self._lookupEthersInterface(functionSignature).functions.{{this.name}}(
{{> params inputs=inputs}}
- ).data;
+ ) as ethers.CallDescription;
+ const encodedData = ethersFunction.data;
const callDataWithDefaults = await self._applyDefaultsToTxDataAsync(
{
data: encodedData,
}
)
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
+ let resultArray = ethersFunction.parse(rawCallResult);
const outputAbi = (_.find(self.abi, {name: '{{this.name}}'}) as MethodAbi).outputs;
- const outputParamsTypes = _.map(outputAbi, 'type');
- let resultArray = ethersContracts.Interface.decodeParams(outputParamsTypes, rawCallResult) as any;
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
return resultArray{{#singleReturnValue}}[0]{{/singleReturnValue}};
diff --git a/packages/contract_templates/partials/return_type.handlebars b/packages/contract_templates/partials/return_type.handlebars
index 9dd509953..77d96e8c4 100644
--- a/packages/contract_templates/partials/return_type.handlebars
+++ b/packages/contract_templates/partials/return_type.handlebars
@@ -1,6 +1,6 @@
{{#if outputs.length}}
{{#singleReturnValue}}
-{{#returnType outputs.0.type components}}{{/returnType}}
+{{#returnType outputs.0.type outputs.0.components}}{{/returnType}}
{{/singleReturnValue}}
{{^singleReturnValue}}
[{{#each outputs}}{{#returnType type components}}{{/returnType}}{{#unless @last}}, {{/unless}}{{/each}}]
diff --git a/packages/metacoin/package.json b/packages/metacoin/package.json
index 80bd22791..e944d725b 100644
--- a/packages/metacoin/package.json
+++ b/packages/metacoin/package.json
@@ -32,7 +32,7 @@
"@0xproject/types": "^0.6.1",
"@0xproject/utils": "^0.5.2",
"@0xproject/web3-wrapper": "^0.6.1",
- "ethers-contracts": "^2.2.1",
+ "ethers": "^3.0.15",
"lodash": "^4.17.4",
"web3-provider-engine": "^13.0.1"
},
diff --git a/packages/migrations/src/migration.ts b/packages/migrations/src/migration.ts
index 4827328fc..6313efcff 100644
--- a/packages/migrations/src/migration.ts
+++ b/packages/migrations/src/migration.ts
@@ -69,7 +69,7 @@ export const runMigrationsAsync = async (deployer: Deployer) => {
},
);
for (const token of tokenInfo) {
- const totalSupply = new BigNumber(0);
+ const totalSupply = new BigNumber(100000000000000000000);
const args = [token.name, token.symbol, token.decimals, totalSupply];
const dummyToken = await deployer.deployAsync(ContractName.DummyToken, args);
await tokenReg.addToken.sendTransactionAsync(
diff --git a/packages/typescript-typings/CHANGELOG.json b/packages/typescript-typings/CHANGELOG.json
index a2f1e7615..f3f68d509 100644
--- a/packages/typescript-typings/CHANGELOG.json
+++ b/packages/typescript-typings/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "version": "0.3.0",
+ "changes": [
+ {
+ "note": "Add types for `ethers.js`, removing `ethers-contracts`",
+ "pr": 540
+ }
+ ]
+ },
+ {
"version": "0.2.0",
"changes": [
{
diff --git a/packages/typescript-typings/types/ethers-contracts/index.d.ts b/packages/typescript-typings/types/ethers/index.d.ts
index e5d38819e..7e04c7dd1 100644
--- a/packages/typescript-typings/types/ethers-contracts/index.d.ts
+++ b/packages/typescript-typings/types/ethers/index.d.ts
@@ -1,4 +1,4 @@
-declare module 'ethers-contracts' {
+declare module 'ethers' {
export interface TransactionDescription {
name: string;
signature: string;
@@ -12,17 +12,20 @@ declare module 'ethers-contracts' {
(...params: any[]): TransactionDescription | CallDescription;
inputs: { names: string[]; types: string[] };
outputs: { names: string[]; types: string[] };
+ type: string;
}
export interface EventDescription {
parse: (...args: any[]) => any;
inputs: { names: string[]; types: string[] };
signature: string;
- topic: string;
+ topics: string[];
}
export class Interface {
public functions: { [functionName: string]: FunctionDescription };
public events: { [eventName: string]: EventDescription };
- public static decodeParams(types: string[], data: string): any[];
constructor(abi: any);
}
+ export class Contract {
+ constructor(address: string, abi: any, provider: any);
+ }
}
diff --git a/packages/utils/CHANGELOG.json b/packages/utils/CHANGELOG.json
index 1aeb3b457..e7f3c052c 100644
--- a/packages/utils/CHANGELOG.json
+++ b/packages/utils/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "version": "0.6.0",
+ "changes": [
+ {
+ "note": "Update ethers-contracts to ethers.js",
+ "pr": 540
+ }
+ ]
+ },
+ {
"version": "0.5.2",
"changes": [
{
diff --git a/packages/utils/package.json b/packages/utils/package.json
index bbc87c53f..f309c2126 100644
--- a/packages/utils/package.json
+++ b/packages/utils/package.json
@@ -35,7 +35,7 @@
"@0xproject/typescript-typings": "^0.2.0",
"@types/node": "^8.0.53",
"bignumber.js": "~4.1.0",
- "ethers-contracts": "^2.2.1",
+ "ethers": "^3.0.15",
"js-sha3": "^0.7.0",
"lodash": "^4.17.4",
"web3": "^0.20.0"
diff --git a/packages/utils/src/abi_decoder.ts b/packages/utils/src/abi_decoder.ts
index 36c7839cf..150f74a15 100644
--- a/packages/utils/src/abi_decoder.ts
+++ b/packages/utils/src/abi_decoder.ts
@@ -9,7 +9,7 @@ import {
RawLog,
SolidityTypes,
} from '@0xproject/types';
-import * as ethersContracts from 'ethers-contracts';
+import * as ethers from 'ethers';
import * as _ from 'lodash';
import { BigNumber } from './configured_bignumber';
@@ -36,7 +36,7 @@ export class AbiDecoder {
if (_.isUndefined(event)) {
return log;
}
- const ethersInterface = new ethersContracts.Interface([event]);
+ const ethersInterface = new ethers.Interface([event]);
const logData = log.data;
const decodedParams: DecodedLogArgs = {};
let topicsIndex = 1;
@@ -77,10 +77,10 @@ export class AbiDecoder {
if (_.isUndefined(abiArray)) {
return;
}
- const ethersInterface = new ethersContracts.Interface(abiArray);
+ const ethersInterface = new ethers.Interface(abiArray);
_.map(abiArray, (abi: AbiDefinition) => {
if (abi.type === AbiType.Event) {
- const topic = ethersInterface.events[abi.name].topic;
+ const topic = ethersInterface.events[abi.name].topics[0];
this._methodIds[topic] = abi;
}
});
diff --git a/packages/web3-wrapper/package.json b/packages/web3-wrapper/package.json
index 61a886e46..118330707 100644
--- a/packages/web3-wrapper/package.json
+++ b/packages/web3-wrapper/package.json
@@ -61,7 +61,7 @@
"@0xproject/types": "^0.6.1",
"@0xproject/typescript-typings": "^0.2.0",
"@0xproject/utils": "^0.5.2",
- "ethers-contracts": "^2.2.1",
+ "ethers": "^3.0.15",
"lodash": "^4.17.4",
"web3": "^0.20.0"
},
diff --git a/packages/website/public/images/landing/project_logos/imToken.png b/packages/website/public/images/landing/project_logos/imToken.png
new file mode 100644
index 000000000..ffb3b2fd3
--- /dev/null
+++ b/packages/website/public/images/landing/project_logos/imToken.png
Binary files differ
diff --git a/packages/website/ts/pages/landing/landing.tsx b/packages/website/ts/pages/landing/landing.tsx
index c943e3d79..f961220fd 100644
--- a/packages/website/ts/pages/landing/landing.tsx
+++ b/packages/website/ts/pages/landing/landing.tsx
@@ -92,8 +92,8 @@ const relayersAndDappProjects: Project[] = [
projectUrl: constants.PROJECT_URL_BLOCKNET,
},
{
- logoFileName: 'status.png',
- projectUrl: constants.PROJECT_URL_STATUS,
+ logoFileName: 'imtoken.png',
+ projectUrl: constants.PROJECT_URL_IMTOKEN,
},
{
logoFileName: 'augur.png',
@@ -123,10 +123,6 @@ const relayerProjects: Project[] = [
projectUrl: constants.PROJECT_URL_0CEAN,
},
{
- logoFileName: 'dydx.png',
- projectUrl: constants.PROJECT_URL_DYDX,
- },
- {
logoFileName: 'amadeus.png',
projectUrl: constants.PROJECT_URL_AMADEUS,
},
@@ -154,6 +150,10 @@ const relayerProjects: Project[] = [
logoFileName: 'idt.png',
projectUrl: constants.PROJECT_URL_IDT,
},
+ {
+ logoFileName: 'imtoken.png',
+ projectUrl: constants.PROJECT_URL_IMTOKEN,
+ },
];
export interface LandingProps {
diff --git a/packages/website/ts/utils/constants.ts b/packages/website/ts/utils/constants.ts
index 0584938eb..f8710b349 100644
--- a/packages/website/ts/utils/constants.ts
+++ b/packages/website/ts/utils/constants.ts
@@ -53,7 +53,7 @@ export const constants = {
PROJECT_URL_ARAGON: 'https://aragon.one',
PROJECT_URL_BLOCKNET: 'https://blocknet.co',
PROJECT_URL_0CEAN: 'http://the0cean.com',
- PROJECT_URL_STATUS: 'https://status.im',
+ PROJECT_URL_IMTOKEN: 'https://tokenlon.token.im/',
PROJECT_URL_AUGUR: 'https://augur.net',
PROJECT_URL_AUCTUS: 'https://auctus.org',
PROJECT_URL_OPEN_ANX: 'https://www.openanx.org',