This repository has been archived by the owner on Jul 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 465
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* wip first pass at coordinator wrapper * implement cancels, helper methods, and more unit tests * pin typeorm version in pipeline * prettier * add export to 0x.js * generate ZeroEx transaction using EIP712 * update Coordinator artifact * change OrderError -> TypedDataError
- Loading branch information
Showing
22 changed files
with
2,391 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
140 changes: 101 additions & 39 deletions
140
packages/contract-artifacts/artifacts/Coordinator.json
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
856 changes: 856 additions & 0 deletions
856
packages/contract-wrappers/src/contract_wrappers/coordinator_wrapper.ts
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
packages/contract-wrappers/src/utils/coordinator_server_types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
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).', | ||
} |
Oops, something went wrong.