Skip to content
Open
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
3 changes: 1 addition & 2 deletions src/utils/encoders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ export const encodeOrders = ([order0, order1]: [DecodedOrder, DecodedOrder]): [

export const isOrderEncodable = (order: DecodedOrder): boolean => {
try {
encodeOrder(order);
return true;
return encodeOrder(order).B > 0n;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it is more correct to enforce this inside encodeOrder - and not in isOrderEncodable which is a function that seems to only be used in the tests

Copy link
Copy Markdown
Collaborator Author

@barakman barakman Apr 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the SDK of the new carbon version, I have ended up implementing it in a separate function named validOrder.

Other than getting rid of the "toxic" usage of try/catch (can fail for any other unrelated bug or error), it also seems the more correct way to handle order-creation.

In this version of carbon, the conditions are much more simple, and if you decide to adopt the suggestion above, then you'll just need to put your current checks in that function, and then add this check (B > 0) on top.

} catch {
return false;
}
Expand Down