Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 5 additions & 0 deletions .changeset/curvy-paths-burn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"thirdweb": patch
---

Adds transaction `action` fields to Bridge responses. This includes and necessary approval transactions.n
17 changes: 13 additions & 4 deletions packages/thirdweb/src/bridge/Buy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,18 @@ export declare namespace quote {
* estimatedExecutionTimeMs: 1000
* transactions: [
* {
* to: NATIVE_TOKEN_ADDRESS,
* action: "approval",
* id: "0x",
* to: "0x...",
* data: "0x...",
* chainId: 10,
* type: "eip1559"
* },
* {
* action: "buy",
* to: "0x...",
* value: 10000026098875381n,
* data: "0x",
* data: "0x...",
* chainId: 10,
* type: "eip1559"
* }
Expand All @@ -167,11 +176,11 @@ export declare namespace quote {
*
* ## Sending the transactions
* The `transactions` array is a series of [ox](https://oxlib.sh) EIP-1559 transactions that must be executed one after the other in order to fulfill the complete route. There are a few things to keep in mind when executing these transactions:
* - Approvals and other preparation transactions are not included in the transactions array.
* - Approvals will have the `approval` action specified. You can perform approvals with `sendAndConfirmTransaction`, then proceed to the next transaction.
* - All transactions are assumed to be executed by the `sender` address, regardless of which chain they are on. The final transaction will use the `receiver` as the recipient address.
* - If an `expiration` timestamp is provided, all transactions must be executed before that time to guarantee successful execution at the specified price.
*
* NOTE: To get the status of each transaction, use `Bridge.status` rather than checking for transaction inclusion. This function will ensure full bridge completion on the destination chain.
* NOTE: To get the status of each non-approval transaction, use `Bridge.status` rather than checking for transaction inclusion. This function will ensure full bridge completion on the destination chain.
*
* You can access this functions input and output types with `Buy.prepare.Options` and `Buy.prepare.Result`, respectively.
*
Expand Down
19 changes: 15 additions & 4 deletions packages/thirdweb/src/bridge/Sell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,20 @@ export declare namespace quote {
* estimatedExecutionTimeMs: 1000
* transactions: [
* {
* to: NATIVE_TOKEN_ADDRESS,
* id: "0x...",
* action: "approval",
* id: "0x",
* to: "0x...",
* data: "0x...",
* chainId: 10,
* type: "eip1559"
* },
* {
* id: "0x...",
* action: "sell",
* to: "0x...",
* value: 9980000000000000000n,
* data: "0x",
* data: "0x...",
* chainId: 10,
* type: "eip1559"
* }
Expand All @@ -167,11 +178,11 @@ export declare namespace quote {
*
* ## Sending the transactions
* The `transactions` array is a series of [ox](https://oxlib.sh) EIP-1559 transactions that must be executed one after the other in order to fulfill the complete route. There are a few things to keep in mind when executing these transactions:
* - Approvals and other preparation transactions are not included in the transactions array.
* - Approvals will have the `approval` action specified. You can perform approvals with `sendAndConfirmTransaction`, then proceed to the next transaction.
* - All transactions are assumed to be executed by the `sender` address, regardless of which chain they are on. The final transaction will use the `receiver` as the recipient address.
* - If an `expiration` timestamp is provided, all transactions must be executed before that time to guarantee successful execution at the specified price.
*
* NOTE: To get the status of each transaction, use `Bridge.status` rather than checking for transaction inclusion. This function will ensure full bridge completion on the destination chain.
* NOTE: To get the status of each non-approval transaction, use `Bridge.status` rather than checking for transaction inclusion. This function will ensure full bridge completion on the destination chain.
*
* You can access this functions input and output types with `Sell.prepare.Options` and `Sell.prepare.Result`, respectively.
*
Expand Down
16 changes: 14 additions & 2 deletions packages/thirdweb/src/bridge/types/Quote.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import type { TransactionEnvelopeEip1559 as ox__TransactionEnvelopeEip1559 } from "ox";
import type {
TransactionEnvelopeEip1559 as ox__TransactionEnvelopeEip1559,
Hex as ox__Hex,
} from "ox";

export type Quote = {
/**
Expand Down Expand Up @@ -37,6 +40,15 @@ export type PreparedQuote = Quote & {
bigint,
number,
"eip1559"
>
> & {
/**
* The action this transaction performs. This can be "approve", "transfer", "buy", or "sell".
*/
action: "approval" | "transfer" | "buy" | "sell";
/**
* The transaction ID, used for tracking purposes.
*/
id: ox__Hex.Hex;
}
>;
};
Loading