thirdweb 5.99.3 → 5.100.0-nightly-713ebe0a2d6d8a409e41ce0f0317fc34b1f221bb-20250520000414

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. package/dist/cjs/bridge/Buy.js +16 -12
  2. package/dist/cjs/bridge/Buy.js.map +1 -1
  3. package/dist/cjs/bridge/Chains.js +2 -2
  4. package/dist/cjs/bridge/Chains.js.map +1 -1
  5. package/dist/cjs/bridge/Routes.js +2 -2
  6. package/dist/cjs/bridge/Routes.js.map +1 -1
  7. package/dist/cjs/bridge/Sell.js +17 -13
  8. package/dist/cjs/bridge/Sell.js.map +1 -1
  9. package/dist/cjs/bridge/Status.js +15 -2
  10. package/dist/cjs/bridge/Status.js.map +1 -1
  11. package/dist/cjs/bridge/Transfer.js +229 -0
  12. package/dist/cjs/bridge/Transfer.js.map +1 -0
  13. package/dist/cjs/bridge/index.js +2 -1
  14. package/dist/cjs/bridge/index.js.map +1 -1
  15. package/dist/cjs/bridge/types/Token.js +3 -0
  16. package/dist/cjs/bridge/types/Token.js.map +1 -0
  17. package/dist/cjs/pay/buyWithCrypto/getQuote.js +159 -53
  18. package/dist/cjs/pay/buyWithCrypto/getQuote.js.map +1 -1
  19. package/dist/cjs/pay/buyWithCrypto/getStatus.js +160 -14
  20. package/dist/cjs/pay/buyWithCrypto/getStatus.js.map +1 -1
  21. package/dist/cjs/pay/buyWithCrypto/getTransfer.js +95 -37
  22. package/dist/cjs/pay/buyWithCrypto/getTransfer.js.map +1 -1
  23. package/dist/cjs/pay/utils/definitions.js +1 -31
  24. package/dist/cjs/pay/utils/definitions.js.map +1 -1
  25. package/dist/cjs/react/core/hooks/transaction/useSendTransaction.js +23 -21
  26. package/dist/cjs/react/core/hooks/transaction/useSendTransaction.js.map +1 -1
  27. package/dist/cjs/react/web/ui/ConnectWallet/TransactionsScreen.js +2 -15
  28. package/dist/cjs/react/web/ui/ConnectWallet/TransactionsScreen.js.map +1 -1
  29. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +1 -1
  30. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
  31. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.js +0 -135
  32. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.js.map +1 -1
  33. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.js +3 -1
  34. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.js.map +1 -1
  35. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/fetchBalancesForWallet.js +1 -1
  36. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/fetchBalancesForWallet.js.map +1 -1
  37. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/pendingSwapTx.js +4 -4
  38. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/pendingSwapTx.js.map +1 -1
  39. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.js +83 -34
  40. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.js.map +1 -1
  41. package/dist/cjs/react/web/ui/TransactionButton/ExecutingScreen.js +2 -2
  42. package/dist/cjs/react/web/ui/TransactionButton/ExecutingScreen.js.map +1 -1
  43. package/dist/cjs/utils/any-evm/zksync/constants.js +1 -0
  44. package/dist/cjs/utils/any-evm/zksync/constants.js.map +1 -1
  45. package/dist/cjs/utils/domains.js +3 -0
  46. package/dist/cjs/utils/domains.js.map +1 -1
  47. package/dist/cjs/version.js +1 -1
  48. package/dist/cjs/version.js.map +1 -1
  49. package/dist/esm/bridge/Buy.js +16 -12
  50. package/dist/esm/bridge/Buy.js.map +1 -1
  51. package/dist/esm/bridge/Chains.js +2 -2
  52. package/dist/esm/bridge/Chains.js.map +1 -1
  53. package/dist/esm/bridge/Routes.js +2 -2
  54. package/dist/esm/bridge/Routes.js.map +1 -1
  55. package/dist/esm/bridge/Sell.js +17 -13
  56. package/dist/esm/bridge/Sell.js.map +1 -1
  57. package/dist/esm/bridge/Status.js +15 -2
  58. package/dist/esm/bridge/Status.js.map +1 -1
  59. package/dist/esm/bridge/Transfer.js +226 -0
  60. package/dist/esm/bridge/Transfer.js.map +1 -0
  61. package/dist/esm/bridge/index.js +1 -0
  62. package/dist/esm/bridge/index.js.map +1 -1
  63. package/dist/esm/bridge/types/Token.js +2 -0
  64. package/dist/esm/bridge/types/Token.js.map +1 -0
  65. package/dist/esm/pay/buyWithCrypto/getQuote.js +159 -53
  66. package/dist/esm/pay/buyWithCrypto/getQuote.js.map +1 -1
  67. package/dist/esm/pay/buyWithCrypto/getStatus.js +160 -14
  68. package/dist/esm/pay/buyWithCrypto/getStatus.js.map +1 -1
  69. package/dist/esm/pay/buyWithCrypto/getTransfer.js +95 -37
  70. package/dist/esm/pay/buyWithCrypto/getTransfer.js.map +1 -1
  71. package/dist/esm/pay/utils/definitions.js +0 -25
  72. package/dist/esm/pay/utils/definitions.js.map +1 -1
  73. package/dist/esm/react/core/hooks/transaction/useSendTransaction.js +23 -21
  74. package/dist/esm/react/core/hooks/transaction/useSendTransaction.js.map +1 -1
  75. package/dist/esm/react/web/ui/ConnectWallet/TransactionsScreen.js +2 -15
  76. package/dist/esm/react/web/ui/ConnectWallet/TransactionsScreen.js.map +1 -1
  77. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +1 -1
  78. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
  79. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.js +1 -134
  80. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.js.map +1 -1
  81. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.js +3 -1
  82. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.js.map +1 -1
  83. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/fetchBalancesForWallet.js +1 -1
  84. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/fetchBalancesForWallet.js.map +1 -1
  85. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/pendingSwapTx.js +1 -1
  86. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/pendingSwapTx.js.map +1 -1
  87. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.js +84 -34
  88. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.js.map +1 -1
  89. package/dist/esm/react/web/ui/TransactionButton/ExecutingScreen.js +2 -2
  90. package/dist/esm/react/web/ui/TransactionButton/ExecutingScreen.js.map +1 -1
  91. package/dist/esm/utils/any-evm/zksync/constants.js +1 -0
  92. package/dist/esm/utils/any-evm/zksync/constants.js.map +1 -1
  93. package/dist/esm/utils/domains.js +3 -0
  94. package/dist/esm/utils/domains.js.map +1 -1
  95. package/dist/esm/version.js +1 -1
  96. package/dist/esm/version.js.map +1 -1
  97. package/dist/types/bridge/Buy.d.ts +10 -8
  98. package/dist/types/bridge/Buy.d.ts.map +1 -1
  99. package/dist/types/bridge/Sell.d.ts +12 -10
  100. package/dist/types/bridge/Sell.d.ts.map +1 -1
  101. package/dist/types/bridge/Status.d.ts.map +1 -1
  102. package/dist/types/bridge/Transfer.d.ts +199 -0
  103. package/dist/types/bridge/Transfer.d.ts.map +1 -0
  104. package/dist/types/bridge/index.d.ts +1 -0
  105. package/dist/types/bridge/index.d.ts.map +1 -1
  106. package/dist/types/bridge/types/Route.d.ts +3 -17
  107. package/dist/types/bridge/types/Route.d.ts.map +1 -1
  108. package/dist/types/bridge/types/Status.d.ts +15 -0
  109. package/dist/types/bridge/types/Status.d.ts.map +1 -1
  110. package/dist/types/bridge/types/Token.d.ts +10 -0
  111. package/dist/types/bridge/types/Token.d.ts.map +1 -0
  112. package/dist/types/pay/buyWithCrypto/commonTypes.d.ts +0 -9
  113. package/dist/types/pay/buyWithCrypto/commonTypes.d.ts.map +1 -1
  114. package/dist/types/pay/buyWithCrypto/getQuote.d.ts.map +1 -1
  115. package/dist/types/pay/buyWithCrypto/getStatus.d.ts +1 -1
  116. package/dist/types/pay/buyWithCrypto/getStatus.d.ts.map +1 -1
  117. package/dist/types/pay/buyWithCrypto/getTransfer.d.ts.map +1 -1
  118. package/dist/types/pay/utils/definitions.d.ts +0 -25
  119. package/dist/types/pay/utils/definitions.d.ts.map +1 -1
  120. package/dist/types/react/core/hooks/transaction/useSendTransaction.d.ts.map +1 -1
  121. package/dist/types/react/web/ui/ConnectWallet/TransactionsScreen.d.ts.map +1 -1
  122. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.d.ts +2 -13
  123. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.d.ts.map +1 -1
  124. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.d.ts.map +1 -1
  125. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/pendingSwapTx.d.ts +0 -1
  126. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/pendingSwapTx.d.ts.map +1 -1
  127. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.d.ts +8 -4
  128. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.d.ts.map +1 -1
  129. package/dist/types/react/web/ui/TransactionButton/ExecutingScreen.d.ts.map +1 -1
  130. package/dist/types/utils/any-evm/zksync/constants.d.ts.map +1 -1
  131. package/dist/types/utils/domains.d.ts +6 -0
  132. package/dist/types/utils/domains.d.ts.map +1 -1
  133. package/dist/types/version.d.ts +1 -1
  134. package/dist/types/version.d.ts.map +1 -1
  135. package/package.json +1 -1
  136. package/src/bridge/Buy.ts +18 -12
  137. package/src/bridge/Chains.ts +2 -2
  138. package/src/bridge/Routes.ts +2 -2
  139. package/src/bridge/Sell.ts +19 -13
  140. package/src/bridge/Status.ts +15 -2
  141. package/src/bridge/Transfer.test.ts +76 -0
  142. package/src/bridge/Transfer.ts +270 -0
  143. package/src/bridge/index.ts +1 -0
  144. package/src/bridge/types/Route.ts +3 -17
  145. package/src/bridge/types/Status.ts +15 -1
  146. package/src/bridge/types/Token.ts +10 -0
  147. package/src/pay/buyWithCrypto/commonTypes.ts +0 -10
  148. package/src/pay/buyWithCrypto/getQuote.ts +210 -100
  149. package/src/pay/buyWithCrypto/getStatus.ts +213 -20
  150. package/src/pay/buyWithCrypto/getTransfer.ts +129 -61
  151. package/src/pay/utils/definitions.ts +0 -34
  152. package/src/react/core/hooks/transaction/useSendTransaction.ts +27 -33
  153. package/src/react/web/ui/ConnectWallet/TransactionsScreen.tsx +29 -35
  154. package/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx +3 -1
  155. package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.ts +2 -181
  156. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.tsx +3 -1
  157. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/fetchBalancesForWallet.tsx +1 -1
  158. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/pendingSwapTx.ts +1 -3
  159. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.ts +118 -63
  160. package/src/react/web/ui/TransactionButton/ExecutingScreen.tsx +0 -2
  161. package/src/utils/any-evm/zksync/constants.ts +1 -0
  162. package/src/utils/domain.test.ts +1 -0
  163. package/src/utils/domains.ts +8 -0
  164. package/src/version.ts +1 -1
  165. package/dist/cjs/bridge/constants.js +0 -5
  166. package/dist/cjs/bridge/constants.js.map +0 -1
  167. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.js +0 -54
  168. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.js.map +0 -1
  169. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistoryButton.js +0 -52
  170. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistoryButton.js.map +0 -1
  171. package/dist/esm/bridge/constants.js +0 -2
  172. package/dist/esm/bridge/constants.js.map +0 -1
  173. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.js +0 -51
  174. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.js.map +0 -1
  175. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistoryButton.js +0 -48
  176. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistoryButton.js.map +0 -1
  177. package/dist/types/bridge/constants.d.ts +0 -2
  178. package/dist/types/bridge/constants.d.ts.map +0 -1
  179. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.d.ts +0 -10
  180. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.d.ts.map +0 -1
  181. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistoryButton.d.ts +0 -9
  182. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistoryButton.d.ts.map +0 -1
  183. package/src/bridge/constants.ts +0 -1
  184. package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.tsx +0 -163
  185. package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistoryButton.tsx +0 -127
@@ -1,5 +1,5 @@
1
+ import { getThirdwebBaseUrl } from "../utils/domains.js";
1
2
  import { getClientFetch } from "../utils/fetch.js";
2
- import { UNIVERSAL_BRIDGE_URL } from "./constants.js";
3
3
  /**
4
4
  * Retrieves a Universal Bridge quote for the provided sell intent. The quote will specify the expected `destinationAmount` that will be received in exchange for the specified `originAmount`, which is specified with the `sellAmountWei` option.
5
5
  *
@@ -102,7 +102,7 @@ export async function status(options) {
102
102
  const { transactionHash, client } = options;
103
103
  const chainId = "chainId" in options ? options.chainId : options.chain.id;
104
104
  const clientFetch = getClientFetch(client);
105
- const url = new URL(`${UNIVERSAL_BRIDGE_URL}/status`);
105
+ const url = new URL(`${getThirdwebBaseUrl("bridge")}/v1/status`);
106
106
  url.searchParams.set("transactionHash", transactionHash);
107
107
  url.searchParams.set("chainId", chainId.toString());
108
108
  const response = await clientFetch(url.toString());
@@ -114,6 +114,7 @@ export async function status(options) {
114
114
  if (data.status === "FAILED") {
115
115
  return {
116
116
  status: "FAILED",
117
+ paymentId: data.paymentId,
117
118
  transactions: data.transactions,
118
119
  };
119
120
  }
@@ -126,11 +127,18 @@ export async function status(options) {
126
127
  originTokenAddress: data.originTokenAddress,
127
128
  destinationTokenAddress: data.destinationTokenAddress,
128
129
  transactions: data.transactions,
130
+ originToken: data.originToken,
131
+ destinationToken: data.destinationToken,
132
+ sender: data.sender,
133
+ receiver: data.receiver,
134
+ paymentId: data.paymentId,
135
+ purchaseData: data.purchaseData,
129
136
  };
130
137
  }
131
138
  if (data.status === "NOT_FOUND") {
132
139
  return {
133
140
  status: "NOT_FOUND",
141
+ paymentId: data.paymentId,
134
142
  transactions: [],
135
143
  };
136
144
  }
@@ -143,6 +151,11 @@ export async function status(options) {
143
151
  originTokenAddress: data.originTokenAddress,
144
152
  destinationTokenAddress: data.destinationTokenAddress,
145
153
  transactions: data.transactions,
154
+ originToken: data.originToken,
155
+ destinationToken: data.destinationToken,
156
+ sender: data.sender,
157
+ receiver: data.receiver,
158
+ paymentId: data.paymentId,
146
159
  purchaseData: data.purchaseData,
147
160
  };
148
161
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Status.js","sourceRoot":"","sources":["../../../src/bridge/Status.ts"],"names":[],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IAAI,CAAC,QAAQ;QACvB,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,YAAY,EAAE,IAAI,CAAC,YAAY;KAChC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,226 @@
1
+ import { defineChain } from "../chains/utils.js";
2
+ import { getThirdwebBaseUrl } from "../utils/domains.js";
3
+ import { getClientFetch } from "../utils/fetch.js";
4
+ import { stringify } from "../utils/json.js";
5
+ /**
6
+ * Prepares a **finalized** Universal Bridge quote for the provided transfer request with transaction data.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import { Bridge, NATIVE_TOKEN_ADDRESS } from "thirdweb";
11
+ *
12
+ * const quote = await Bridge.Transfer.prepare({
13
+ * chainId: 1,
14
+ * tokenAddress: NATIVE_TOKEN_ADDRESS,
15
+ * amount: toWei("0.01"),
16
+ * sender: "0x...",
17
+ * receiver: "0x...",
18
+ * client: thirdwebClient,
19
+ * });
20
+ * ```
21
+ *
22
+ * This will return a quote that might look like:
23
+ * ```typescript
24
+ * {
25
+ * originAmount: 10000026098875381n,
26
+ * destinationAmount: 10000000000000000n,
27
+ * blockNumber: 22026509n,
28
+ * timestamp: 1741730936680,
29
+ * estimatedExecutionTimeMs: 1000
30
+ * steps: [
31
+ * {
32
+ * originToken: {
33
+ * chainId: 1,
34
+ * address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
35
+ * symbol: "ETH",
36
+ * name: "Ethereum",
37
+ * decimals: 18,
38
+ * priceUsd: 2000,
39
+ * iconUri: "https://..."
40
+ * },
41
+ * destinationToken: {
42
+ * chainId: 1,
43
+ * address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
44
+ * symbol: "ETH",
45
+ * name: "Ethereum",
46
+ * decimals: 18,
47
+ * priceUsd: 2000,
48
+ * iconUri: "https://..."
49
+ * },
50
+ * originAmount: 10000026098875381n,
51
+ * destinationAmount: 10000000000000000n,
52
+ * estimatedExecutionTimeMs: 1000
53
+ * transactions: [
54
+ * {
55
+ * action: "approval",
56
+ * id: "0x",
57
+ * to: "0x...",
58
+ * data: "0x...",
59
+ * chainId: 1,
60
+ * type: "eip1559"
61
+ * },
62
+ * {
63
+ * action: "transfer",
64
+ * to: "0x...",
65
+ * value: 10000026098875381n,
66
+ * data: "0x...",
67
+ * chainId: 1,
68
+ * type: "eip1559"
69
+ * }
70
+ * ]
71
+ * }
72
+ * ],
73
+ * expiration: 1741730936680,
74
+ * intent: {
75
+ * chainId: 1,
76
+ * tokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
77
+ * amount: 10000000000000000n,
78
+ * sender: "0x...",
79
+ * receiver: "0x..."
80
+ * }
81
+ * }
82
+ * ```
83
+ *
84
+ * ## Sending the transactions
85
+ * 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:
86
+ * - Approvals will have the `approval` action specified. You can perform approvals with `sendAndConfirmTransaction`, then proceed to the next transaction.
87
+ * - 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.
88
+ * - If an `expiration` timestamp is provided, all transactions must be executed before that time to guarantee successful execution at the specified price.
89
+ *
90
+ * NOTE: To get the status of each non-approval transaction, use `Bridge.status` rather than checking for transaction inclusion. This function will ensure full completion of the transfer.
91
+ *
92
+ * You can access this functions input and output types with `Transfer.prepare.Options` and `Transfer.prepare.Result`, respectively.
93
+ *
94
+ * You can include arbitrary data to be included on any webhooks and status responses with the `purchaseData` option.
95
+ *
96
+ * ```ts
97
+ * const quote = await Bridge.Transfer.prepare({
98
+ * chainId: 1,
99
+ * tokenAddress: NATIVE_TOKEN_ADDRESS,
100
+ * amount: toWei("0.01"),
101
+ * sender: "0x...",
102
+ * receiver: "0x...",
103
+ * purchaseData: {
104
+ * reference: "payment-123",
105
+ * metadata: {
106
+ * note: "Transfer to Alice"
107
+ * }
108
+ * },
109
+ * client: thirdwebClient,
110
+ * });
111
+ * ```
112
+ *
113
+ * ## Fees
114
+ * There may be fees associated with the transfer. These fees are paid by the `feePayer` address, which defaults to the `sender` address. You can specify a different address with the `feePayer` option. If you do not specify an option or explicitly specify `sender`, the fees will be added to the input amount. If you specify the `receiver` as the fee payer the fees will be subtracted from the destination amount.
115
+ *
116
+ * For example, if you were to request a transfer with `feePayer` set to `receiver`:
117
+ * ```typescript
118
+ * const quote = await Bridge.Transfer.prepare({
119
+ * chainId: 1,
120
+ * tokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
121
+ * amount: 100_000_000n, // 100 USDC
122
+ * sender: "0x...",
123
+ * receiver: "0x...",
124
+ * feePayer: "receiver",
125
+ * client: thirdwebClient,
126
+ * });
127
+ * ```
128
+ *
129
+ * The returned quote might look like:
130
+ * ```typescript
131
+ * {
132
+ * originAmount: 100_000_000n, // 100 USDC
133
+ * destinationAmount: 99_970_000n, // 99.97 USDC
134
+ * ...
135
+ * }
136
+ * ```
137
+ *
138
+ * If you were to request a transfer with `feePayer` set to `sender`:
139
+ * ```typescript
140
+ * const quote = await Bridge.Transfer.prepare({
141
+ * chainId: 1,
142
+ * tokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
143
+ * amount: 100_000_000n, // 100 USDC
144
+ * sender: "0x...",
145
+ * receiver: "0x...",
146
+ * feePayer: "sender",
147
+ * client: thirdwebClient,
148
+ * });
149
+ * ```
150
+ *
151
+ * The returned quote might look like:
152
+ * ```typescript
153
+ * {
154
+ * originAmount: 100_030_000n, // 100.03 USDC
155
+ * destinationAmount: 100_000_000n, // 100 USDC
156
+ * ...
157
+ * }
158
+ * ```
159
+ *
160
+ * @param options - The options for the quote.
161
+ * @param options.chainId - The chain ID of the token.
162
+ * @param options.tokenAddress - The address of the token.
163
+ * @param options.amount - The amount of the token to transfer.
164
+ * @param options.sender - The address of the sender.
165
+ * @param options.receiver - The address of the recipient.
166
+ * @param options.purchaseData - Arbitrary data to be passed to the transfer function and included with any webhooks or status calls.
167
+ * @param options.client - Your thirdweb client.
168
+ * @param [options.feePayer] - The address that will pay the fees for the transfer. If not specified, the sender will be used. Values can be "sender" or "receiver".
169
+ *
170
+ * @returns A promise that resolves to a finalized quote and transactions for the requested transfer.
171
+ *
172
+ * @throws Will throw an error if there is an issue fetching the quote.
173
+ * @bridge Transfer
174
+ * @beta
175
+ */
176
+ export async function prepare(options) {
177
+ const { chainId, tokenAddress, sender, receiver, client, amount, purchaseData, feePayer, } = options;
178
+ const clientFetch = getClientFetch(client);
179
+ const url = new URL(`${getThirdwebBaseUrl("bridge")}/v1/transfer/prepare`);
180
+ const response = await clientFetch(url.toString(), {
181
+ method: "POST",
182
+ headers: {
183
+ "Content-Type": "application/json",
184
+ },
185
+ body: stringify({
186
+ transferAmountWei: amount.toString(), // legacy
187
+ amount: amount.toString(),
188
+ chainId: chainId.toString(),
189
+ tokenAddress,
190
+ sender,
191
+ receiver,
192
+ purchaseData,
193
+ feePayer,
194
+ }),
195
+ });
196
+ if (!response.ok) {
197
+ const errorJson = await response.json();
198
+ throw new Error(`${errorJson.code} | ${errorJson.message} - ${errorJson.correlationId}`);
199
+ }
200
+ const { data } = await response.json();
201
+ return {
202
+ originAmount: BigInt(data.originAmount),
203
+ destinationAmount: BigInt(data.destinationAmount),
204
+ blockNumber: data.blockNumber ? BigInt(data.blockNumber) : undefined,
205
+ timestamp: data.timestamp,
206
+ estimatedExecutionTimeMs: data.estimatedExecutionTimeMs,
207
+ steps: data.steps.map((step) => ({
208
+ ...step,
209
+ transactions: step.transactions.map((transaction) => ({
210
+ ...transaction,
211
+ value: transaction.value ? BigInt(transaction.value) : undefined,
212
+ client,
213
+ chain: defineChain(transaction.chainId),
214
+ })),
215
+ })),
216
+ intent: {
217
+ chainId,
218
+ tokenAddress,
219
+ amount,
220
+ sender,
221
+ receiver,
222
+ feePayer,
223
+ },
224
+ };
225
+ }
226
+ //# sourceMappingURL=Trans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
1
  export * as Buy from "./Buy.js";
2
2
  export * as Sell from "./Sell.js";
3
+ export * as Transfer from "./Transfer.js";
3
4
  export { status } from "./Status.js";
4
5
  export { routes } from "./Routes.js";
5
6
  export { chains } from "./Chains.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/bridge/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/bridge/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Token.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Token.js","sourceRoot":"","sources":["../../../../src/bridge/types/Token.ts"],"names":[],"mappings":""}
@@ -1,7 +1,10 @@
1
+ import { Value } from "ox";
2
+ import * as ox__AbiFunction from "ox/AbiFunction";
3
+ import * as Bridge from "../../bridge/index.js";
1
4
  import { getCachedChain } from "../../chains/utils.js";
2
- import { getClientFetch } from "../../utils/fetch.js";
3
- import { stringify } from "../../utils/json.js";
4
- import { getPayBuyWithCryptoQuoteEndpoint } from "../utils/definitions.js";
5
+ import { NATIVE_TOKEN_ADDRESS } from "../../constants/addresses.js";
6
+ import { getContract } from "../../contract/contract.js";
7
+ import { decimals } from "../../extensions/erc20/read/decimals.js";
5
8
  /**
6
9
  * Get a quote of type [`BuyWithCryptoQuote`](https://portal.thirdweb.com/references/typescript/v5/BuyWithCryptoQuote) to buy any given token with crypto.
7
10
  * This quote contains the information about the swap such as token amounts, processing fees, estimated time etc.
@@ -32,65 +35,168 @@ import { getPayBuyWithCryptoQuoteEndpoint } from "../utils/definitions.js";
32
35
  */
33
36
  export async function getBuyWithCryptoQuote(params) {
34
37
  try {
35
- const clientFetch = getClientFetch(params.client);
36
- const response = await clientFetch(getPayBuyWithCryptoQuoteEndpoint(), {
37
- method: "POST",
38
- headers: {
39
- Accept: "application/json",
40
- "Content-Type": "application/json",
41
- },
42
- body: stringify({
43
- fromAddress: params.fromAddress,
44
- toAddress: params.toAddress,
45
- fromChainId: params.fromChainId.toString(),
46
- fromTokenAddress: params.fromTokenAddress,
47
- toChainId: params.toChainId.toString(),
48
- toTokenAddress: params.toTokenAddress,
49
- fromAmount: params.fromAmount,
50
- toAmount: params.toAmount,
51
- maxSlippageBPS: params.maxSlippageBPS,
52
- intentId: params.intentId,
53
- purchaseData: params.purchaseData,
54
- }),
55
- });
56
- // Assuming the response directly matches the SwapResponse interface
57
- if (!response.ok) {
58
- const errorObj = await response.json();
59
- if (errorObj && "error" in errorObj) {
60
- throw errorObj;
38
+ const quote = await (async () => {
39
+ if (params.toAmount) {
40
+ const destinationTokenContract = getContract({
41
+ address: params.toTokenAddress,
42
+ chain: getCachedChain(params.toChainId),
43
+ client: params.client,
44
+ });
45
+ const tokenDecimals = destinationTokenContract.address.toLowerCase() ===
46
+ NATIVE_TOKEN_ADDRESS
47
+ ? 18
48
+ : await decimals({
49
+ contract: destinationTokenContract,
50
+ });
51
+ const amount = Value.from(params.toAmount, tokenDecimals);
52
+ return Bridge.Buy.prepare({
53
+ sender: params.fromAddress,
54
+ receiver: params.toAddress,
55
+ originChainId: params.fromChainId,
56
+ originTokenAddress: params.fromTokenAddress,
57
+ destinationChainId: params.toChainId,
58
+ destinationTokenAddress: params.toTokenAddress,
59
+ amount: amount,
60
+ purchaseData: params.purchaseData,
61
+ client: params.client,
62
+ });
61
63
  }
62
- throw new Error(`HTTP error! status: ${response.status}`);
63
- }
64
- const data = (await response.json())
65
- .result;
64
+ else if (params.fromAmount) {
65
+ const originTokenContract = getContract({
66
+ address: params.fromTokenAddress,
67
+ chain: getCachedChain(params.fromChainId),
68
+ client: params.client,
69
+ });
70
+ const tokenDecimals = await decimals({
71
+ contract: originTokenContract,
72
+ });
73
+ const amount = Value.from(params.fromAmount, tokenDecimals);
74
+ return Bridge.Sell.prepare({
75
+ sender: params.fromAddress,
76
+ receiver: params.toAddress,
77
+ originChainId: params.fromChainId,
78
+ originTokenAddress: params.fromTokenAddress,
79
+ destinationChainId: params.toChainId,
80
+ destinationTokenAddress: params.toTokenAddress,
81
+ amount: amount,
82
+ purchaseData: params.purchaseData,
83
+ client: params.client,
84
+ });
85
+ }
86
+ throw new Error("Invalid quote request, must provide either `fromAmount` or `toAmount`");
87
+ })();
66
88
  // check if the fromAddress already has approval for the given amount
67
- const approvalData = data.approval;
89
+ const firstStep = quote.steps[0];
90
+ if (!firstStep) {
91
+ throw new Error("This quote is incompatible with getBuyWithCryptoQuote. Please use Bridge.Buy.prepare instead.");
92
+ }
93
+ const approvalTxs = firstStep.transactions.filter((tx) => tx.action === "approval");
94
+ if (approvalTxs.length > 1) {
95
+ throw new Error("This quote is incompatible with getBuyWithCryptoQuote. Please use Bridge.Buy.prepare instead.");
96
+ }
97
+ const approvalTx = approvalTxs[0];
98
+ const txs = firstStep.transactions.filter((tx) => tx.action !== "approval");
99
+ if (txs.length > 1) {
100
+ throw new Error("This quote is incompatible with getBuyWithCryptoQuote. Please use Bridge.Buy.prepare instead.");
101
+ }
102
+ const tx = txs[0];
103
+ if (!tx) {
104
+ throw new Error("This quote is incompatible with getBuyWithCryptoQuote. Please use Bridge.Buy.prepare instead.");
105
+ }
106
+ let approvalData;
107
+ if (approvalTx) {
108
+ const abiFunction = ox__AbiFunction.from([
109
+ "function approve(address spender, uint256 amount)",
110
+ ]);
111
+ const [spender, amount] = ox__AbiFunction.decodeData(abiFunction, approvalTx.data);
112
+ approvalData = {
113
+ chainId: firstStep.originToken.chainId,
114
+ tokenAddress: firstStep.originToken.address,
115
+ spenderAddress: spender,
116
+ amountWei: amount.toString(),
117
+ };
118
+ }
68
119
  const swapRoute = {
69
120
  transactionRequest: {
70
- chain: getCachedChain(data.transactionRequest.chainId),
71
- client: params.client,
72
- data: data.transactionRequest.data,
73
- to: data.transactionRequest.to,
74
- value: BigInt(data.transactionRequest.value),
121
+ ...tx,
75
122
  extraGas: 50000n, // extra gas buffer
76
123
  },
77
124
  approvalData,
78
125
  swapDetails: {
79
- fromAddress: data.fromAddress,
80
- toAddress: data.toAddress,
81
- fromToken: data.fromToken,
82
- toToken: data.toToken,
83
- fromAmount: data.fromAmount,
84
- fromAmountWei: data.fromAmountWei,
85
- toAmountMinWei: data.toAmountMinWei,
86
- toAmountMin: data.toAmountMin,
87
- toAmountWei: data.toAmountWei,
88
- toAmount: data.toAmount,
89
- estimated: data.estimated,
90
- maxSlippageBPS: data.maxSlippageBPS,
126
+ fromAddress: quote.intent.sender,
127
+ toAddress: quote.intent.receiver,
128
+ fromToken: {
129
+ tokenAddress: firstStep.originToken.address,
130
+ chainId: firstStep.originToken.chainId,
131
+ decimals: firstStep.originToken.decimals,
132
+ symbol: firstStep.originToken.symbol,
133
+ name: firstStep.originToken.name,
134
+ priceUSDCents: firstStep.originToken.priceUsd * 100,
135
+ },
136
+ toToken: {
137
+ tokenAddress: firstStep.destinationToken.address,
138
+ chainId: firstStep.destinationToken.chainId,
139
+ decimals: firstStep.destinationToken.decimals,
140
+ symbol: firstStep.destinationToken.symbol,
141
+ name: firstStep.destinationToken.name,
142
+ priceUSDCents: firstStep.destinationToken.priceUsd * 100,
143
+ },
144
+ fromAmount: Value.format(quote.originAmount, firstStep.originToken.decimals).toString(),
145
+ fromAmountWei: quote.originAmount.toString(),
146
+ toAmountMinWei: quote.destinationAmount.toString(),
147
+ toAmountMin: Value.format(quote.destinationAmount, firstStep.destinationToken.decimals).toString(),
148
+ toAmountWei: quote.destinationAmount.toString(),
149
+ toAmount: Value.format(quote.destinationAmount, firstStep.destinationToken.decimals).toString(),
150
+ estimated: {
151
+ fromAmountUSDCents: Number(Value.format(quote.originAmount, firstStep.originToken.decimals)) *
152
+ firstStep.originToken.priceUsd *
153
+ 100,
154
+ toAmountMinUSDCents: Number(Value.format(quote.destinationAmount, firstStep.destinationToken.decimals)) *
155
+ firstStep.destinationToken.priceUsd *
156
+ 100,
157
+ toAmountUSDCents: Number(Value.format(quote.destinationAmount, firstStep.destinationToken.decimals)) *
158
+ firstStep.destinationToken.priceUsd *
159
+ 100,
160
+ slippageBPS: 0,
161
+ feesUSDCents: 0,
162
+ gasCostUSDCents: 0,
163
+ durationSeconds: firstStep.estimatedExecutionTimeMs / 1000,
164
+ },
165
+ maxSlippageBPS: 0,
91
166
  },
92
- paymentTokens: data.paymentTokens,
93
- processingFees: data.processingFees,
167
+ paymentTokens: [
168
+ {
169
+ token: {
170
+ tokenAddress: firstStep.originToken.address,
171
+ chainId: firstStep.originToken.chainId,
172
+ decimals: firstStep.originToken.decimals,
173
+ symbol: firstStep.originToken.symbol,
174
+ name: firstStep.originToken.name,
175
+ priceUSDCents: firstStep.originToken.priceUsd * 100,
176
+ },
177
+ amountWei: quote.originAmount.toString(),
178
+ amount: Value.format(quote.originAmount, firstStep.originToken.decimals).toString(),
179
+ amountUSDCents: Number(Value.format(quote.originAmount, firstStep.originToken.decimals)) *
180
+ firstStep.originToken.priceUsd *
181
+ 100,
182
+ },
183
+ ],
184
+ // TODO (UB): add develope and platform fees in API
185
+ processingFees: [
186
+ {
187
+ token: {
188
+ tokenAddress: firstStep.originToken.address,
189
+ chainId: firstStep.originToken.chainId,
190
+ decimals: firstStep.originToken.decimals,
191
+ symbol: firstStep.originToken.symbol,
192
+ name: firstStep.originToken.name,
193
+ priceUSDCents: firstStep.originToken.priceUsd * 100,
194
+ },
195
+ amountUSDCents: 0,
196
+ amountWei: "0",
197
+ amount: "0",
198
+ },
199
+ ],
94
200
  client: params.client,
95
201
  };
96
202
  return swapRoute;
@@ -1 +1 @@
1
- {"version":3,"file":"getQuote.js","sourceRoot":"","sources":["../../../../src/pay/buyWithCrypto/getQuote.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGvD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,gCAAgC,EAAE,MAAM,yBAAyB,CAAC;AAmL3E;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,MAAmC;IAEnC,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAElD,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,gCAAgC,EAAE,EAAE;YACrE,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,MAAM,EAAE,kBAAkB;gBAC1B,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI,EAAE,SAAS,CAAC;gBACd,WAAW,EAAE,MAAM,CAAC,WAAW;gBAC/B,SAAS,EAAE,MAAM,CAAC,SAAS;gBAC3B,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,QAAQ,EAAE;gBAC1C,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;gBACzC,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE;gBACtC,cAAc,EAAE,MAAM,CAAC,cAAc;gBACrC,UAAU,EAAE,MAAM,CAAC,UAAU;gBAC7B,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,cAAc,EAAE,MAAM,CAAC,cAA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