Skip to content
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
18 changes: 18 additions & 0 deletions .changeset/ninety-snails-smash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
"thirdweb": patch
---

Added the `sortBy` option to Bridge.routes

```ts
import { Bridge } from "thirdweb";

const routes = await Bridge.routes({
originChainId: 1,
originTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
limit: 10,
offset: 0,
sortBy: "popularity",
client: thirdwebClient,
});
```
2 changes: 2 additions & 0 deletions packages/thirdweb/src/bridge/Buy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ import type { PreparedQuote, Quote } from "./types/Quote.js";
* @param options.destinationChainId - The chain ID of the destination token.
* @param options.destinationTokenAddress - The address of the destination token.
* @param options.amount - The amount of the destination token to receive.
* @param [options.maxSteps] - Limit the number of total steps in the route.
* @param options.client - Your thirdweb client.
*
* @returns A promise that resolves to a non-finalized quote for the requested buy.
Expand Down Expand Up @@ -307,6 +308,7 @@ export declare namespace quote {
* @param options.sender - The address of the sender.
* @param options.receiver - The address of the recipient.
* @param options.purchaseData - Arbitrary data to be passed to the purchase function and included with any webhooks or status calls.
* @param [options.maxSteps] - Limit the number of total steps in the route.
* @param options.client - Your thirdweb client.
*
* @returns A promise that resolves to a finalized quote and transactions for the requested buy.
Expand Down
21 changes: 21 additions & 0 deletions packages/thirdweb/src/bridge/Routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,21 @@
* });
* ```
*
* You can sort the returned routes by `popularity`:
* ```ts
* import { Bridge } from "thirdweb";
*
* // Get the 10 most popular routes starting from mainnet ETH
* const routes = await Bridge.routes({
* originChainId: 1,
* originTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
* limit: 10,
* offset: 0,
* sortBy: "popularity",
* client: thirdwebClient,
* });
* ```
*
* @param options - The options for the quote.
* @param options.client - Your thirdweb client.
* @param options.originChainId - Filter by a specific origin chain ID.
Expand All @@ -94,6 +109,7 @@
* @param options.destinationTokenAddress - Filter by a specific destination token address.
* @param options.transactionHash - Filter by a specific transaction hash.
* @param options.maxSteps - Limit the number of steps returned.
* @param options.sortBy - Sort the routes by various categories.
* @param options.limit - Limit the number of routes returned.
* @param options.offset - Offset the number of routes returned.
*
Expand All @@ -111,6 +127,7 @@
destinationChainId,
destinationTokenAddress,
maxSteps,
sortBy,
limit,
offset,
} = options;
Expand Down Expand Up @@ -138,6 +155,9 @@
if (offset) {
url.searchParams.set("offset", offset.toString());
}
if (sortBy) {
url.searchParams.set("sortBy", sortBy);
}

Check warning on line 160 in packages/thirdweb/src/bridge/Routes.ts

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/bridge/Routes.ts#L159-L160

Added lines #L159 - L160 were not covered by tests

const response = await clientFetch(url.toString());
if (!response.ok) {
Expand All @@ -157,6 +177,7 @@
destinationChainId?: number;
destinationTokenAddress?: ox__Address.Address;
transactionHash?: ox__Hex.Hex;
sortBy?: "popularity";
maxSteps?: number;
limit?: number;
offset?: number;
Expand Down
2 changes: 2 additions & 0 deletions packages/thirdweb/src/bridge/Sell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ import type { PreparedQuote, Quote } from "./types/Quote.js";
* @param options.destinationChainId - The chain ID of the destination token.
* @param options.destinationTokenAddress - The address of the destination token.
* @param options.amount - The amount of the origin token to sell.
* @param [options.maxSteps] - Limit the number of total steps in the route.
* @param options.client - Your thirdweb client.
*
* @returns A promise that resolves to a non-finalized quote for the requested sell.
Expand Down Expand Up @@ -298,6 +299,7 @@ export declare namespace quote {
* @param options.sender - The address of the sender.
* @param options.receiver - The address of the recipient.
* @param options.purchaseData - Arbitrary data to be passed to the purchase function and included with any webhooks or status calls.
* @param [options.maxSteps] - Limit the number of total steps in the route.
* @param options.client - Your thirdweb client.
*
* @returns A promise that resolves to a finalized quote and transactions for the requested sell.
Expand Down
Loading