Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Add coordinator wrapper #1792

Merged
merged 55 commits into from
May 9, 2019
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
e21e353
wip first pass at coordinator wrapper
xianny Apr 19, 2019
0dfa3ba
implement cancels, helper methods, and more unit tests
xianny Apr 26, 2019
1f3a925
small cleanups
xianny Apr 26, 2019
1f2a9a9
wip: improvements after review
xianny Apr 27, 2019
182f698
add better errors and fix cancelOrdersUpTo
xianny Apr 30, 2019
4e5f670
remove default param from private method
xianny Apr 30, 2019
164dc13
bump to clear circleci cache
xianny May 1, 2019
f4688fa
improve unit tests
xianny May 2, 2019
59b8e97
lint
xianny May 2, 2019
e222a06
Merge branch 'development' into feature/coordinator-wrapper
xianny May 2, 2019
2cf8c64
remove dangling variable
xianny May 2, 2019
5a6d0c4
pin typeorm version in pipeline
xianny May 2, 2019
147644a
prettier
xianny May 3, 2019
f99f560
add export to 0x.js
xianny May 3, 2019
09daaf4
more exports; upgrade coordinator server
xianny May 3, 2019
05e4b7b
WIP/broken: cannot get valid approval signatures
xianny May 7, 2019
7022fd6
fix exports
xianny May 7, 2019
3325958
run only fillorder
xianny May 7, 2019
99e8446
recover signer address
xianny May 7, 2019
11c56e6
wip
xianny May 7, 2019
a2b7aa8
generate ZeroEx transaction using EIP712
xianny May 8, 2019
4fe23f7
wip
xianny May 8, 2019
edc0511
update Coordinator artifact
xianny May 8, 2019
058a6fb
remove repeated code
xianny May 9, 2019
e3916f5
remove inline type declaration
xianny May 9, 2019
f135aab
dont swallow error when parsing json from http response
xianny May 9, 2019
c386d2c
prettier
xianny May 9, 2019
af2b1e6
update Coordinator artifact
xianny May 9, 2019
821490b
lint
xianny May 9, 2019
16f0f2f
remove disallowed fields
xianny May 9, 2019
25fb636
tweak package.jsons
xianny May 9, 2019
9f301ee
pin pipeline version again
xianny May 9, 2019
87ea0d5
update Coordinator artifact in python packages
xianny May 9, 2019
cb3430e
add Coordinator
xianny May 9, 2019
e1d9481
add exports
xianny May 9, 2019
2564554
add cacheing, add non-coordinator-order test
xianny May 9, 2019
62593fb
change OrderError -> TypedDataError
xianny May 9, 2019
f349c6d
tweaks after review
xianny May 9, 2019
835c38f
format doc comments
xianny May 9, 2019
0960ec6
replace OrderError -> TypedDataError everywhere
xianny May 9, 2019
0e664ff
fix flatten
xianny May 9, 2019
0e21f38
simplify function
xianny May 9, 2019
be4d1fd
bump circleci
xianny May 9, 2019
3f27ea4
remove `only` flag
xianny May 9, 2019
be94f2a
try increasing node max-old-space-size
xianny May 9, 2019
e09b60c
try reducing chunk size
xianny May 9, 2019
5fbb3b2
real small chunk size
xianny May 9, 2019
6e04011
compile only contract-wrappers
xianny May 9, 2019
3461709
remove changelog
xianny May 9, 2019
cb3ae41
temporarily skip other circle jobs
xianny May 9, 2019
16ac206
Merge branch 'development' into feature/coordinator-wrapper
xianny May 9, 2019
8506112
remove ramda
xianny May 9, 2019
0cc6e98
restore circle config and changelog
xianny May 9, 2019
797d036
fix circle config
xianny May 9, 2019
fe3b56d
bump circleci
xianny May 9, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/0x.js/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ export {

export {
ContractWrappers,
CoordinatorWrapper,
CoordinatorServerCancellationResponse,
CoordinatorServerError,
DutchAuctionWrapper,
ERC20TokenWrapper,
ERC721TokenWrapper,
Expand Down
140 changes: 101 additions & 39 deletions packages/contract-artifacts/artifacts/Coordinator.json

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions packages/contract-wrappers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@
},
"devDependencies": {
"@0x/contracts-test-utils": "^3.1.2",
"@0x/coordinator-server": "0.1.1",
"@0x/dev-utils": "^2.2.1",
"@0x/fill-scenarios": "^3.0.5",
"@0x/migrations": "^4.1.1",
"@0x/subproviders": "^4.0.5",
"@0x/tslint-config": "^3.0.1",
"@types/lodash": "4.14.104",
"@types/mocha": "^2.2.42",
"@types/nock": "^10.0.1",
"@types/node": "*",
"@types/sinon": "^2.2.2",
"@types/uuid": "^3.4.3",
Expand All @@ -56,6 +58,7 @@
"dirty-chai": "^2.0.1",
"make-promises-safe": "^1.1.0",
"mocha": "^4.1.0",
"nock": "^10.0.6",
"npm-run-all": "^4.1.2",
"nyc": "^11.0.1",
"opn-cli": "^3.1.0",
Expand Down Expand Up @@ -83,6 +86,7 @@
"ethereumjs-blockstream": "6.0.0",
"ethereumjs-util": "^5.1.1",
"ethers": "~4.0.4",
"http-status-codes": "^1.3.2",
"js-sha3": "^0.7.0",
"lodash": "^4.17.11",
"uuid": "^3.3.2"
Expand Down
15 changes: 15 additions & 0 deletions packages/contract-wrappers/src/contract_wrappers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
Coordinator,
DutchAuction,
ERC20Proxy,
ERC20Token,
Expand All @@ -14,6 +15,7 @@ import { Web3Wrapper } from '@0x/web3-wrapper';
import { SupportedProvider } from 'ethereum-types';
import * as _ from 'lodash';

import { CoordinatorWrapper } from './contract_wrappers/coordinator_wrapper';
import { DutchAuctionWrapper } from './contract_wrappers/dutch_auction_wrapper';
import { ERC20ProxyWrapper } from './contract_wrappers/erc20_proxy_wrapper';
import { ERC20TokenWrapper } from './contract_wrappers/erc20_token_wrapper';
Expand Down Expand Up @@ -73,6 +75,11 @@ export class ContractWrappers {
*/
public dutchAuction: DutchAuctionWrapper;

/**
* An instance of the CoordinatorWrapper class containing methods for interacting with the Coordinator extension contract.
*/
public coordinator: CoordinatorWrapper;

private readonly _web3Wrapper: Web3Wrapper;
/**
* Instantiates a new ContractWrappers instance.
Expand All @@ -88,6 +95,7 @@ export class ContractWrappers {
};
this._web3Wrapper = new Web3Wrapper(supportedProvider, txDefaults);
const artifactsArray = [
Coordinator,
DutchAuction,
ERC20Proxy,
ERC20Token,
Expand Down Expand Up @@ -155,6 +163,13 @@ export class ContractWrappers {
config.networkId,
contractAddresses.dutchAuction,
);
this.coordinator = new CoordinatorWrapper(
this._web3Wrapper,
config.networkId,
contractAddresses.coordinator,
contractAddresses.exchange,
contractAddresses.coordinatorRegistry,
);
}
/**
* Unsubscribes from all subscriptions for all contracts.
Expand Down

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions packages/contract-wrappers/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export {
} from '@0x/abi-gen-wrappers';

export { ContractWrappers } from './contract_wrappers';
export { CoordinatorWrapper } from './contract_wrappers/coordinator_wrapper';
export { ERC20TokenWrapper } from './contract_wrappers/erc20_token_wrapper';
export { ERC721TokenWrapper } from './contract_wrappers/erc721_token_wrapper';
export { EtherTokenWrapper } from './contract_wrappers/ether_token_wrapper';
Expand Down Expand Up @@ -58,6 +59,8 @@ export {
TraderInfo,
ValidateOrderFillableOpts,
DutchAuctionData,
CoordinatorServerCancellationResponse,
CoordinatorServerError,
} from './types';

export {
Expand All @@ -72,6 +75,8 @@ export {
Order,
SignedOrder,
AssetProxyId,
SignedZeroExTransaction,
ZeroExTransaction,
} from '@0x/types';

export {
Expand Down
8 changes: 8 additions & 0 deletions packages/contract-wrappers/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,3 +225,11 @@ export interface DutchAuctionData {
beginTimeSeconds: BigNumber;
beginAmount: BigNumber;
}

export { CoordinatorServerCancellationResponse, CoordinatorServerError } from './utils/coordinator_server_types';

export interface CoordinatorTransaction {
salt: BigNumber;
signerAddress: string;
data: string;
}
61 changes: 61 additions & 0 deletions packages/contract-wrappers/src/utils/coordinator_server_types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { Order, SignedOrder, SignedZeroExTransaction } from '@0x/types';
import { BigNumber } from '@0x/utils';

export interface CoordinatorServerApprovalResponse {
signatures: string[];
expirationTimeSeconds: BigNumber[];
}
export interface CoordinatorServerApprovalRawResponse {
signatures: string[];
expirationTimeSeconds: BigNumber;
}
xianny marked this conversation as resolved.
Show resolved Hide resolved

export interface CoordinatorServerCancellationResponse {
outstandingFillSignatures: CoordinatorOutstandingFillSignatures[];
cancellationSignatures: string[];
}
export interface CoordinatorOutstandingFillSignatures {
orderHash: string;
approvalSignatures: string[];
expirationTimeSeconds: BigNumber;
takerAssetFillAmount: BigNumber;
}

export interface CoordinatorServerResponse {
isError: boolean;
status: number;
body?: CoordinatorServerCancellationResponse | CoordinatorServerApprovalRawResponse;
error?: any;
request: CoordinatorServerRequest;
coordinatorOperator: string;
orders?: Array<SignedOrder | Order>;
}

export interface CoordinatorServerRequest {
signedTransaction: SignedZeroExTransaction;
txOrigin: string;
}

export class CoordinatorServerError extends Error {
public message: CoordinatorServerErrorMsg;
public approvedOrders?: SignedOrder[] = [];
public cancellations?: CoordinatorServerCancellationResponse[] = [];
public errors: CoordinatorServerResponse[];
constructor(
message: CoordinatorServerErrorMsg,
approvedOrders: SignedOrder[],
cancellations: CoordinatorServerCancellationResponse[],
errors: CoordinatorServerResponse[],
) {
super();
this.message = message;
this.approvedOrders = approvedOrders;
this.cancellations = cancellations;
this.errors = errors;
}
}

export enum CoordinatorServerErrorMsg {
CancellationFailed = 'Failed to cancel with some coordinator server(s). See errors for more info. See cancellations for successful cancellations.',
FillFailed = 'Failed to obtain approval signatures from some coordinator server(s). See errors for more info. Current transaction has been abandoned but you may resubmit with only approvedOrders (a new ZeroEx transaction will have to be signed).',
}
Loading