Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TD-927] update order book openapi client #914

Merged
merged 3 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions packages/orderbook/src/api-client/api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ export class ImmutableApiClient {
],
fees: makerFees.map((x) => ({
amount: x.amount,
fee_type: FeeType.MAKER_MARKETPLACE as unknown as Fee.fee_type,
fee_type: FeeType.MAKER_ECOSYSTEM as unknown as Fee.fee_type,
recipient: x.recipient,
})),
end_time: new Date(
end_at: new Date(
parseInt(`${orderComponents.endTime.toString()}000`, 10),
).toISOString(),
protocol_data: {
Expand All @@ -127,7 +127,7 @@ export class ImmutableApiClient {
},
],
signature: orderSignature,
start_time: new Date(
start_at: new Date(
parseInt(`${orderComponents.startTime.toString()}000`, 10),
).toISOString(),
},
Expand Down
8 changes: 4 additions & 4 deletions packages/orderbook/src/openapi/mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ export function mapFromOpenApiOrder(order: OpenApiOrder): Order {
type: fee.fee_type as unknown as FeeType,
})),
chain: order.chain,
createTime: order.create_time,
endTime: order.end_time,
createdAt: order.created_at,
endAt: order.end_at,
protocolData: {
counter: order.protocol_data.counter,
orderType: order.protocol_data.order_type,
Expand All @@ -65,9 +65,9 @@ export function mapFromOpenApiOrder(order: OpenApiOrder): Order {
},
salt: order.salt,
signature: order.signature,
startTime: order.start_time,
startAt: order.start_at,
status: order.status,
updateTime: order.update_time,
updatedAt: order.updated_at,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export type CreateListingRequestBody = {
/**
* Time after which the Order is considered expired
*/
end_time: string;
end_at: string;
protocol_data: ProtocolData;
/**
* A random value added to the create Order request
Expand All @@ -37,6 +37,6 @@ export type CreateListingRequestBody = {
/**
* Time after which Order is considered active
*/
start_time: string;
start_at: string;
};

4 changes: 2 additions & 2 deletions packages/orderbook/src/openapi/sdk/models/Fee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ export namespace Fee {
*/
export enum fee_type {
ROYALTY = 'ROYALTY',
MAKER_MARKETPLACE = 'MAKER_MARKETPLACE',
TAKER_MARKETPLACE = 'TAKER_MARKETPLACE',
MAKER_ECOSYSTEM = 'MAKER_ECOSYSTEM',
TAKER_ECOSYSTEM = 'TAKER_ECOSYSTEM',
PROTOCOL = 'PROTOCOL',
}

Expand Down
8 changes: 4 additions & 4 deletions packages/orderbook/src/openapi/sdk/models/Order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ export type Order = {
/**
* Time the Order is created
*/
create_time: string;
created_at: string;
/**
* Time after which the Order is considered expired
*/
end_time: string;
end_at: string;
/**
* Global Order identifier
*/
Expand All @@ -38,11 +38,11 @@ export type Order = {
/**
* Time after which Order is considered active
*/
start_time: string;
start_at: string;
status: OrderStatus;
/**
* Time the Order is last updated
*/
update_time: string;
updated_at: string;
};

Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ export class OrdersService {
/**
* Trade field to sort by
*/
sortBy?: 'created_at',
sortBy?: 'indexed_at',
/**
* Ascending or descending direction for sort
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/orderbook/src/orderbook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export class Orderbook {
fees: takerFees.map((fee) => ({
amount: fee.amount,
fee_type:
FeeType.TAKER_MARKETPLACE as unknown as OpenApiFee.fee_type.TAKER_MARKETPLACE,
FeeType.TAKER_ECOSYSTEM as unknown as OpenApiFee.fee_type.TAKER_ECOSYSTEM,
recipient: fee.recipient,
})),
},
Expand Down
4 changes: 2 additions & 2 deletions packages/orderbook/src/seaport/map-to-seaport-order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ export function mapImmutableOrderToSeaportOrderComponents(
};
}),
counter,
endTime: Math.round(new Date(order.end_time).getTime() / 1000).toString(),
endTime: Math.round(new Date(order.end_at).getTime() / 1000).toString(),
startTime: Math.round(
new Date(order.start_time).getTime() / 1000,
new Date(order.start_at).getTime() / 1000,
).toString(),
salt: order.salt,
offerer: order.account_address,
Expand Down
8 changes: 4 additions & 4 deletions packages/orderbook/src/seaport/seaport.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,8 @@ describe('Seaport', () => {
buy: [{ item_type: 'NATIVE', start_amount: '100' }],
fees: [],
chain: { id: '1', name: 'imtbl-zkevm-local' },
create_time: new Date().toISOString(),
end_time: new Date().toISOString(),
created_at: new Date().toISOString(),
end_at: new Date().toISOString(),
id: '1',
protocol_data: {
order_type: ProtocolData.order_type.FULL_RESTRICTED,
Expand All @@ -412,8 +412,8 @@ describe('Seaport', () => {
],
signature: randomAddress(),
status: OrderStatus.ACTIVE,
start_time: new Date().toISOString(),
update_time: new Date().toISOString(),
start_at: new Date().toISOString(),
updated_at: new Date().toISOString(),
};

beforeEach(() => {
Expand Down
12 changes: 6 additions & 6 deletions packages/orderbook/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ Parameters<typeof OrdersService.prototype.listTrades>[0],
>;

export enum FeeType {
MAKER_MARKETPLACE = OpenapiFee.fee_type.MAKER_MARKETPLACE,
TAKER_MARKETPLACE = OpenapiFee.fee_type.TAKER_MARKETPLACE,
MAKER_ECOSYSTEM = OpenapiFee.fee_type.MAKER_ECOSYSTEM,
TAKER_ECOSYSTEM = OpenapiFee.fee_type.TAKER_ECOSYSTEM,
PROTOCOL = OpenapiFee.fee_type.PROTOCOL,
ROYALTY = OpenapiFee.fee_type.ROYALTY,
}
Expand Down Expand Up @@ -134,16 +134,16 @@ export interface Order {
id: string;
name: string;
};
createTime: string;
updateTime: string;
createdAt: string;
updatedAt: string;
/**
* Time after which the Order is considered active
*/
startTime: string;
startAt: string;
/**
* Time after which the Order is expired
*/
endTime: string;
endAt: string;
protocolData: {
orderType: 'FULL_RESTRICTED';
zoneAddress: string;
Expand Down