Skip to content

Commit

Permalink
feat: fixed e2e and demo scripts and other dependencies that uses ord…
Browse files Browse the repository at this point in the history
…erbook create/fulfill listing fees param (#893)
  • Loading branch information
reVrost authored Sep 22, 2023
1 parent 0347df2 commit b02ecb8
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/checkout/sdk/src/smartCheckout/buy/buy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export const buy = async (
};
try {
const fulfillerAddress = await provider.getSigner().getAddress();
const { actions } = await orderbook.fulfillOrder(orderId, fulfillerAddress);
const { actions } = await orderbook.fulfillOrder(orderId, fulfillerAddress, []);
unsignedTransactions = await getUnsignedTransactions(actions);
} catch {
// Silently ignore error as this is usually thrown if user does not have enough balance
Expand Down
4 changes: 2 additions & 2 deletions packages/checkout/sdk/src/smartCheckout/sell/sell.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,10 @@ describe('sell', () => {
);
expect(mockCreateListing).toBeCalledWith(
{
makerFee: {
makerFees: [{
amount: '25000000000000000',
recipient: '0xEac347177DbA4a190B632C7d9b8da2AbfF57c772',
},
}],
orderComponents: {},
orderHash: 'hash',
orderSignature: '0xSIGNED',
Expand Down
5 changes: 2 additions & 3 deletions packages/checkout/sdk/src/smartCheckout/sell/sell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,19 +181,18 @@ export const sell = async (
orderComponents: signedMessage.orderComponents,
orderHash: signedMessage.orderHash,
orderSignature: signedMessage.signedMessage,
makerFees: [],
};

if (makerFees !== undefined) {
const orderBookFees = calculateFees(makerFees, buyTokenOrNative.amount, decimals);
// @TODO add support for an array of fees when the orderbook enables it
if (orderBookFees.length !== makerFees.length) {
throw new CheckoutError(
'One of the fees is too small, must be greater than 0.000001',
CheckoutErrorType.CREATE_ORDER_LISTING_ERROR,
);
}
const [makerFee] = orderBookFees;
createListingParams.makerFee = makerFee;
createListingParams.makerFees = orderBookFees;
}

try {
Expand Down
1 change: 1 addition & 0 deletions packages/orderbook/src/test/cancel.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ describe('cancel order', () => {
orderComponents: listing.orderComponents,
orderHash: listing.orderHash,
orderSignature: signatures[0],
makerFees: [],
});

await waitForOrderToBeOfStatus(sdk, orderId, OrderStatus.ACTIVE);
Expand Down
1 change: 1 addition & 0 deletions packages/orderbook/src/test/create.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ describe('prepareListing and createOrder e2e', () => {
orderComponents: listing.orderComponents,
orderHash: listing.orderHash,
orderSignature: signatures[0],
makerFees: [],
});

await waitForOrderToBeOfStatus(sdk, orderId, OrderStatus.ACTIVE);
Expand Down
3 changes: 2 additions & 1 deletion packages/orderbook/src/test/expiry.demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ describe('', () => {
orderComponents: soonToExpireListing.orderComponents,
orderHash: soonToExpireListing.orderHash,
orderSignature: signatures[0],
makerFees: [],
});
log('Submitted order to orderbook API with expiry time set in the future');

Expand All @@ -97,7 +98,7 @@ describe('', () => {
);

try {
await sdk.fulfillOrder(orderId, fulfiller.address);
await sdk.fulfillOrder(orderId, fulfiller.address, []);
} catch (e) {
log('Fulfillment failed as expected. The error is:');
log(e);
Expand Down
8 changes: 4 additions & 4 deletions packages/orderbook/src/test/fulfil.demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ describe('', () => {
orderComponents: validListing.orderComponents,
orderHash: validListing.orderHash,
orderSignature: signatures[0],
makerFee: {
makerFees: [{
amount: '1',
recipient: offerer.address,
},
}],
});

await waitForOrderToBeOfStatus(sdk, orderId2, OrderStatus.ACTIVE);
Expand All @@ -97,10 +97,10 @@ describe('', () => {
const { actions, expiration, order } = await sdk.fulfillOrder(
orderId2,
fulfiller.address,
{
[{
amount: '1',
recipient: offerer.address,
},
}],
);

log(`Fulfilling listing ${order.id}, fulfillment transaction valid till ${expiration}`);
Expand Down
2 changes: 2 additions & 0 deletions packages/orderbook/src/test/fulfil.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,15 @@ describe('fulfil order', () => {
orderComponents: listing.orderComponents,
orderHash: listing.orderHash,
orderSignature: signatures[0],
makerFees: [],
});

await waitForOrderToBeOfStatus(sdk, orderId, OrderStatus.ACTIVE);

const fulfillment = await sdk.fulfillOrder(
orderId,
fulfiller.address,
[],
);

await actionAll(fulfillment.actions, fulfiller, provider);
Expand Down
1 change: 1 addition & 0 deletions packages/orderbook/src/test/list.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ async function createListing(
orderComponents: listing.orderComponents,
orderHash: listing.orderHash,
orderSignature: signatures[0],
makerFees: [],
});

return waitForOrderToBeOfStatus(sdk, orderId, OrderStatus.ACTIVE);
Expand Down

0 comments on commit b02ecb8

Please sign in to comment.