thirdweb 5.100.0-nightly-713ebe0a2d6d8a409e41ce0f0317fc34b1f221bb-20250520000414 → 5.100.0

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 (223) hide show
  1. package/dist/cjs/bridge/Buy.js +1 -1
  2. package/dist/cjs/bridge/Onramp.js +152 -0
  3. package/dist/cjs/bridge/Onramp.js.map +1 -0
  4. package/dist/cjs/bridge/OnrampStatus.js +78 -0
  5. package/dist/cjs/bridge/OnrampStatus.js.map +1 -0
  6. package/dist/cjs/bridge/Sell.js +1 -1
  7. package/dist/cjs/bridge/index.js +2 -1
  8. package/dist/cjs/bridge/index.js.map +1 -1
  9. package/dist/cjs/{react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.js → bridge/types/BridgeAction.js} +1 -1
  10. package/dist/cjs/bridge/types/BridgeAction.js.map +1 -0
  11. package/dist/cjs/extensions/ens/resolve-l2-name.js +0 -2
  12. package/dist/cjs/extensions/ens/resolve-l2-name.js.map +1 -1
  13. package/dist/cjs/pay/buyWithFiat/getQuote.js +129 -33
  14. package/dist/cjs/pay/buyWithFiat/getQuote.js.map +1 -1
  15. package/dist/cjs/pay/buyWithFiat/getStatus.js +71 -20
  16. package/dist/cjs/pay/buyWithFiat/getStatus.js.map +1 -1
  17. package/dist/cjs/pay/utils/commonTypes.js +1 -1
  18. package/dist/cjs/pay/utils/commonTypes.js.map +1 -1
  19. package/dist/cjs/pay/utils/definitions.js +1 -13
  20. package/dist/cjs/pay/utils/definitions.js.map +1 -1
  21. package/dist/cjs/react/core/hooks/pay/useBuyWithFiatStatus.js +1 -3
  22. package/dist/cjs/react/core/hooks/pay/useBuyWithFiatStatus.js.map +1 -1
  23. package/dist/cjs/react/core/hooks/transaction/useSendTransaction.js +42 -38
  24. package/dist/cjs/react/core/hooks/transaction/useSendTransaction.js.map +1 -1
  25. package/dist/cjs/react/core/utils/wallet.js +15 -0
  26. package/dist/cjs/react/core/utils/wallet.js.map +1 -1
  27. package/dist/cjs/react/web/hooks/transaction/useSendTransaction.js +1 -1
  28. package/dist/cjs/react/web/hooks/transaction/useSendTransaction.js.map +1 -1
  29. package/dist/cjs/react/web/ui/ConnectWallet/TransactionsScreen.js +0 -9
  30. package/dist/cjs/react/web/ui/ConnectWallet/TransactionsScreen.js.map +1 -1
  31. package/dist/cjs/react/web/ui/ConnectWallet/locale/en.js +1 -1
  32. package/dist/cjs/react/web/ui/ConnectWallet/locale/en.js.map +1 -1
  33. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatSteps.js +0 -177
  34. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatSteps.js.map +1 -1
  35. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js +2 -10
  36. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js.map +1 -1
  37. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.js +5 -8
  38. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.js.map +1 -1
  39. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.js +0 -15
  40. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.js.map +1 -1
  41. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/statusMeta.js +0 -60
  42. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/statusMeta.js.map +1 -1
  43. package/dist/cjs/react/web/ui/TransactionButton/DepositScreen.js +133 -0
  44. package/dist/cjs/react/web/ui/TransactionButton/DepositScreen.js.map +1 -0
  45. package/dist/cjs/react/web/ui/TransactionButton/ExecutingScreen.js +4 -3
  46. package/dist/cjs/react/web/ui/TransactionButton/ExecutingScreen.js.map +1 -1
  47. package/dist/cjs/react/web/ui/TransactionButton/TransactionModal.js +9 -1
  48. package/dist/cjs/react/web/ui/TransactionButton/TransactionModal.js.map +1 -1
  49. package/dist/cjs/version.js +1 -1
  50. package/dist/cjs/version.js.map +1 -1
  51. package/dist/esm/bridge/Buy.js +1 -1
  52. package/dist/esm/bridge/Onramp.js +147 -0
  53. package/dist/esm/bridge/Onramp.js.map +1 -0
  54. package/dist/esm/bridge/OnrampStatus.js +75 -0
  55. package/dist/esm/bridge/OnrampStatus.js.map +1 -0
  56. package/dist/esm/bridge/Sell.js +1 -1
  57. package/dist/esm/bridge/index.js +1 -0
  58. package/dist/esm/bridge/index.js.map +1 -1
  59. package/dist/esm/bridge/types/BridgeAction.js +2 -0
  60. package/dist/esm/bridge/types/BridgeAction.js.map +1 -0
  61. package/dist/esm/extensions/ens/resolve-l2-name.js +0 -2
  62. package/dist/esm/extensions/ens/resolve-l2-name.js.map +1 -1
  63. package/dist/esm/pay/buyWithFiat/getQuote.js +129 -33
  64. package/dist/esm/pay/buyWithFiat/getQuote.js.map +1 -1
  65. package/dist/esm/pay/buyWithFiat/getStatus.js +71 -20
  66. package/dist/esm/pay/buyWithFiat/getStatus.js.map +1 -1
  67. package/dist/esm/pay/utils/commonTypes.js +1 -1
  68. package/dist/esm/pay/utils/commonTypes.js.map +1 -1
  69. package/dist/esm/pay/utils/definitions.js +0 -10
  70. package/dist/esm/pay/utils/definitions.js.map +1 -1
  71. package/dist/esm/react/core/hooks/pay/useBuyWithFiatStatus.js +1 -3
  72. package/dist/esm/react/core/hooks/pay/useBuyWithFiatStatus.js.map +1 -1
  73. package/dist/esm/react/core/hooks/transaction/useSendTransaction.js +42 -38
  74. package/dist/esm/react/core/hooks/transaction/useSendTransaction.js.map +1 -1
  75. package/dist/esm/react/core/utils/wallet.js +15 -0
  76. package/dist/esm/react/core/utils/wallet.js.map +1 -1
  77. package/dist/esm/react/web/hooks/transaction/useSendTransaction.js +1 -1
  78. package/dist/esm/react/web/hooks/transaction/useSendTransaction.js.map +1 -1
  79. package/dist/esm/react/web/ui/ConnectWallet/TransactionsScreen.js +0 -9
  80. package/dist/esm/react/web/ui/ConnectWallet/TransactionsScreen.js.map +1 -1
  81. package/dist/esm/react/web/ui/ConnectWallet/locale/en.js +1 -1
  82. package/dist/esm/react/web/ui/ConnectWallet/locale/en.js.map +1 -1
  83. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatSteps.js +4 -180
  84. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatSteps.js.map +1 -1
  85. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js +2 -10
  86. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js.map +1 -1
  87. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.js +5 -8
  88. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.js.map +1 -1
  89. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.js +2 -16
  90. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.js.map +1 -1
  91. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/statusMeta.js +0 -59
  92. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/statusMeta.js.map +1 -1
  93. package/dist/esm/react/web/ui/TransactionButton/DepositScreen.js +130 -0
  94. package/dist/esm/react/web/ui/TransactionButton/DepositScreen.js.map +1 -0
  95. package/dist/esm/react/web/ui/TransactionButton/ExecutingScreen.js +4 -3
  96. package/dist/esm/react/web/ui/TransactionButton/ExecutingScreen.js.map +1 -1
  97. package/dist/esm/react/web/ui/TransactionButton/TransactionModal.js +9 -1
  98. package/dist/esm/react/web/ui/TransactionButton/TransactionModal.js.map +1 -1
  99. package/dist/esm/version.js +1 -1
  100. package/dist/esm/version.js.map +1 -1
  101. package/dist/types/bridge/Buy.d.ts +1 -1
  102. package/dist/types/bridge/Onramp.d.ts +123 -0
  103. package/dist/types/bridge/Onramp.d.ts.map +1 -0
  104. package/dist/types/bridge/OnrampStatus.d.ts +108 -0
  105. package/dist/types/bridge/OnrampStatus.d.ts.map +1 -0
  106. package/dist/types/bridge/Sell.d.ts +1 -1
  107. package/dist/types/bridge/index.d.ts +6 -3
  108. package/dist/types/bridge/index.d.ts.map +1 -1
  109. package/dist/types/bridge/types/BridgeAction.d.ts +2 -0
  110. package/dist/types/bridge/types/BridgeAction.d.ts.map +1 -0
  111. package/dist/types/bridge/types/Quote.d.ts +3 -65
  112. package/dist/types/bridge/types/Quote.d.ts.map +1 -1
  113. package/dist/types/bridge/types/Route.d.ts +35 -0
  114. package/dist/types/bridge/types/Route.d.ts.map +1 -1
  115. package/dist/types/bridge/types/Token.d.ts +1 -0
  116. package/dist/types/bridge/types/Token.d.ts.map +1 -1
  117. package/dist/types/extensions/ens/resolve-l2-name.d.ts.map +1 -1
  118. package/dist/types/pay/buyWithFiat/getQuote.d.ts.map +1 -1
  119. package/dist/types/pay/buyWithFiat/getStatus.d.ts +1 -12
  120. package/dist/types/pay/buyWithFiat/getStatus.d.ts.map +1 -1
  121. package/dist/types/pay/utils/commonTypes.d.ts +1 -1
  122. package/dist/types/pay/utils/commonTypes.d.ts.map +1 -1
  123. package/dist/types/pay/utils/definitions.d.ts +0 -10
  124. package/dist/types/pay/utils/definitions.d.ts.map +1 -1
  125. package/dist/types/react/core/hooks/pay/useBuyWithFiatStatus.d.ts.map +1 -1
  126. package/dist/types/react/core/hooks/transaction/useSendTransaction.d.ts +1 -0
  127. package/dist/types/react/core/hooks/transaction/useSendTransaction.d.ts.map +1 -1
  128. package/dist/types/react/core/utils/wallet.d.ts.map +1 -1
  129. package/dist/types/react/web/hooks/transaction/useSendTransaction.d.ts.map +1 -1
  130. package/dist/types/react/web/ui/ConnectWallet/TransactionsScreen.d.ts.map +1 -1
  131. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatSteps.d.ts +1 -30
  132. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatSteps.d.ts.map +1 -1
  133. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/types.d.ts +2 -0
  134. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/types.d.ts.map +1 -1
  135. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.d.ts +2 -0
  136. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.d.ts.map +1 -1
  137. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.d.ts +0 -5
  138. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.d.ts.map +1 -1
  139. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/statusMeta.d.ts +1 -3
  140. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/statusMeta.d.ts.map +1 -1
  141. package/dist/types/react/web/ui/TransactionButton/DepositScreen.d.ts +15 -0
  142. package/dist/types/react/web/ui/TransactionButton/DepositScreen.d.ts.map +1 -0
  143. package/dist/types/react/web/ui/TransactionButton/ExecutingScreen.d.ts.map +1 -1
  144. package/dist/types/react/web/ui/TransactionButton/TransactionModal.d.ts +1 -0
  145. package/dist/types/react/web/ui/TransactionButton/TransactionModal.d.ts.map +1 -1
  146. package/dist/types/version.d.ts +1 -1
  147. package/dist/types/version.d.ts.map +1 -1
  148. package/package.json +15 -15
  149. package/src/bridge/Buy.ts +1 -1
  150. package/src/bridge/Onramp.test.ts +118 -0
  151. package/src/bridge/Onramp.ts +244 -0
  152. package/src/bridge/OnrampStatus.ts +133 -0
  153. package/src/bridge/Sell.ts +1 -1
  154. package/src/bridge/index.ts +11 -3
  155. package/src/bridge/types/BridgeAction.ts +1 -0
  156. package/src/bridge/types/Quote.ts +3 -65
  157. package/src/bridge/types/Route.ts +39 -0
  158. package/src/bridge/types/Token.ts +1 -0
  159. package/src/extensions/ens/resolve-l2-name.ts +0 -2
  160. package/src/pay/buyWithFiat/getQuote.ts +184 -33
  161. package/src/pay/buyWithFiat/getStatus.ts +101 -42
  162. package/src/pay/convert/cryptoToFiat.test.ts +7 -5
  163. package/src/pay/convert/fiatToCrypto.test.ts +6 -4
  164. package/src/pay/utils/commonTypes.ts +1 -1
  165. package/src/pay/utils/definitions.ts +0 -14
  166. package/src/react/core/hooks/pay/useBuyWithFiatStatus.ts +0 -2
  167. package/src/react/core/hooks/transaction/useSendTransaction.ts +48 -41
  168. package/src/react/core/utils/wallet.ts +15 -0
  169. package/src/react/web/hooks/transaction/useSendTransaction.tsx +1 -0
  170. package/src/react/web/ui/ConnectWallet/TransactionsScreen.tsx +0 -53
  171. package/src/react/web/ui/ConnectWallet/locale/en.ts +1 -1
  172. package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatSteps.tsx +3 -510
  173. package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.tsx +2 -12
  174. package/src/react/web/ui/ConnectWallet/screens/Buy/main/types.ts +2 -0
  175. package/src/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.ts +19 -20
  176. package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.tsx +1 -37
  177. package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/statusMeta.test.ts +1 -95
  178. package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/statusMeta.ts +0 -69
  179. package/src/react/web/ui/TransactionButton/DepositScreen.tsx +295 -0
  180. package/src/react/web/ui/TransactionButton/ExecutingScreen.tsx +4 -3
  181. package/src/react/web/ui/TransactionButton/TransactionModal.tsx +20 -1
  182. package/src/version.ts +1 -1
  183. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatTxDetailsTable.js +0 -37
  184. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatTxDetailsTable.js.map +0 -1
  185. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.js +0 -86
  186. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.js.map +0 -1
  187. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.js +0 -25
  188. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.js.map +0 -1
  189. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.js +0 -81
  190. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.js.map +0 -1
  191. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.js +0 -17
  192. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.js.map +0 -1
  193. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.js.map +0 -1
  194. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatTxDetailsTable.js +0 -34
  195. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatTxDetailsTable.js.map +0 -1
  196. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.js +0 -83
  197. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.js.map +0 -1
  198. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.js +0 -22
  199. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.js.map +0 -1
  200. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.js +0 -78
  201. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.js.map +0 -1
  202. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.js +0 -14
  203. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.js.map +0 -1
  204. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.js +0 -2
  205. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.js.map +0 -1
  206. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatTxDetailsTable.d.ts +0 -26
  207. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatTxDetailsTable.d.ts.map +0 -1
  208. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.d.ts +0 -16
  209. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.d.ts.map +0 -1
  210. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.d.ts +0 -23
  211. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.d.ts.map +0 -1
  212. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.d.ts +0 -14
  213. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.d.ts.map +0 -1
  214. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.d.ts +0 -14
  215. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.d.ts.map +0 -1
  216. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.d.ts +0 -10
  217. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.d.ts.map +0 -1
  218. package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatTxDetailsTable.tsx +0 -142
  219. package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.tsx +0 -170
  220. package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.tsx +0 -63
  221. package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.tsx +0 -138
  222. package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.tsx +0 -45
  223. package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.ts +0 -12
@@ -213,7 +213,7 @@ export async function quote(options) {
213
213
  * ```
214
214
  *
215
215
  * ## Sending the transactions
216
- * 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:
216
+ * The `transactions` array is a series of transactions ready to be executed (with `sendTransaction`) one after the other in order to fulfill the complete route. There are a few things to keep in mind when executing these transactions:
217
217
  * - Approvals will have the `approval` action specified. You can perform approvals with `sendAndConfirmTransaction`, then proceed to the next transaction.
218
218
  * - 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.
219
219
  * - If an `expiration` timestamp is provided, all transactions must be executed before that time to guarantee successful execution at the specified price.
@@ -0,0 +1,147 @@
1
+ import { getThirdwebBaseUrl } from "../utils/domains.js";
2
+ import { getClientFetch } from "../utils/fetch.js";
3
+ import { stringify } from "../utils/json.js";
4
+ // export status within the Onramp module
5
+ export { status } from "./OnrampStatus.js";
6
+ /**
7
+ * Prepares an onramp transaction, returning a link from the specified provider to onramp to the specified token.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * import { Bridge } from "thirdweb";
12
+ * import { ethereum } from "thirdweb/chains";
13
+ * import { NATIVE_TOKEN_ADDRESS, toWei } from "thirdweb/utils";
14
+ *
15
+ * const preparedOnramp = await Bridge.Onramp.prepare({
16
+ * client: thirdwebClient,
17
+ * onramp: "stripe",
18
+ * chainId: ethereum.id,
19
+ * tokenAddress: NATIVE_TOKEN_ADDRESS,
20
+ * receiver: "0x...", // receiver's address
21
+ * amount: toWei("10"), // 10 of the destination token
22
+ * // Optional params:
23
+ * // sender: "0x...", // sender's address
24
+ * // onrampTokenAddress: NATIVE_TOKEN_ADDRESS, // token to initially onramp to
25
+ * // onrampChainId: 1, // chain to initially onramp to
26
+ * // currency: "USD",
27
+ * // maxSteps: 2,
28
+ * // purchaseData: { customId: "123" }
29
+ * });
30
+ *
31
+ * console.log(preparedOnramp.link); // URL to redirect the user to
32
+ * console.log(preparedOnramp.currencyAmount); // Amount in fiat the user will pay
33
+ * ```
34
+ *
35
+ * This function returns a quote that might look like:
36
+ * ```typescript
37
+ * {
38
+ * id: "123e4567-e89b-12d3-a456-426614174000",
39
+ * link: "https://onramp.example.com/session?id=...",
40
+ * currency: "USD",
41
+ * currencyAmount: 10.52,
42
+ * destinationAmount: 10000000000000000000n, // 10 ETH if decimals 18
43
+ * timestamp: 1689812800,
44
+ * expiration: 1689842800,
45
+ * steps: [
46
+ * // ... further steps if any post-onramp swaps are needed
47
+ * ],
48
+ * intent: {
49
+ * onramp: "stripe",
50
+ * chainId: 1,
51
+ * tokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
52
+ * receiver: "0x...",
53
+ * amount: "10000000000000000000"
54
+ * }
55
+ * }
56
+ * ```
57
+ *
58
+ * @param options - The options for preparing the onramp.
59
+ * @param options.client - Your thirdweb client.
60
+ * @param options.onramp - The onramp provider to use (e.g., "stripe", "coinbase", "transak").
61
+ * @param options.chainId - The destination chain ID.
62
+ * @param options.tokenAddress - The destination token address.
63
+ * @param options.receiver - The address that will receive the output token.
64
+ * @param [options.amount] - The desired token amount in wei.
65
+ * @param [options.purchaseData] - Arbitrary purchase data.
66
+ * @param [options.sender] - An optional address to associate as the onramp sender.
67
+ * @param [options.onrampTokenAddress] - The token to initially onramp to if the destination token is not supported by the provider.
68
+ * @param [options.onrampChainId] - The chain ID to initially onramp to if the destination chain is not supported.
69
+ * @param [options.currency] - The currency for the onramp (e.g., "USD", "GBP"). Defaults to user's preferred or "USD".
70
+ * @param [options.maxSteps] - Maximum number of post-onramp steps.
71
+ * @param [options.excludeChainIds] - Chain IDs to exclude from the route (string or array of strings).
72
+ *
73
+ * @returns A promise that resolves to the prepared onramp details, including the link and quote.
74
+ * @throws Will throw an error if there is an issue preparing the onramp.
75
+ * @bridge Onramp
76
+ * @beta
77
+ */
78
+ export async function prepare(options) {
79
+ const { client, onramp, chainId, tokenAddress, receiver, amount, purchaseData, sender, onrampTokenAddress, onrampChainId, currency, maxSteps, excludeChainIds, } = options;
80
+ const clientFetch = getClientFetch(client);
81
+ const url = `${getThirdwebBaseUrl("bridge")}/v1/onramp/prepare`;
82
+ const apiRequestBody = {
83
+ onramp,
84
+ chainId: Number(chainId),
85
+ tokenAddress,
86
+ receiver,
87
+ };
88
+ if (amount !== undefined) {
89
+ apiRequestBody.amount = amount.toString();
90
+ }
91
+ if (purchaseData !== undefined) {
92
+ apiRequestBody.purchaseData = purchaseData;
93
+ }
94
+ if (sender !== undefined) {
95
+ apiRequestBody.sender = sender;
96
+ }
97
+ if (onrampTokenAddress !== undefined) {
98
+ apiRequestBody.onrampTokenAddress = onrampTokenAddress;
99
+ }
100
+ if (onrampChainId !== undefined) {
101
+ apiRequestBody.onrampChainId = Number(onrampChainId);
102
+ }
103
+ if (currency !== undefined) {
104
+ apiRequestBody.currency = currency;
105
+ }
106
+ if (maxSteps !== undefined) {
107
+ apiRequestBody.maxSteps = maxSteps;
108
+ }
109
+ if (excludeChainIds !== undefined) {
110
+ apiRequestBody.excludeChainIds = Array.isArray(excludeChainIds)
111
+ ? excludeChainIds.join(",")
112
+ : excludeChainIds;
113
+ }
114
+ const response = await clientFetch(url, {
115
+ method: "POST",
116
+ headers: {
117
+ "Content-Type": "application/json",
118
+ },
119
+ body: stringify(apiRequestBody),
120
+ });
121
+ if (!response.ok) {
122
+ const errorJson = await response.json();
123
+ throw new Error(`${errorJson.code || response.status} | ${errorJson.message || response.statusText} - ${errorJson.correlationId || "N/A"}`);
124
+ }
125
+ const { data } = await response.json();
126
+ // Transform amounts from string to bigint where appropriate
127
+ const transformedSteps = data.steps.map((step) => ({
128
+ ...step,
129
+ originAmount: BigInt(step.originAmount),
130
+ destinationAmount: BigInt(step.destinationAmount),
131
+ transactions: step.transactions.map((tx) => ({
132
+ ...tx,
133
+ value: tx.value ? BigInt(tx.value) : undefined,
134
+ })),
135
+ }));
136
+ const intentFromResponse = {
137
+ ...data.intent,
138
+ amount: data.intent.amount ? data.intent.amount : undefined,
139
+ };
140
+ return {
141
+ ...data,
142
+ destinationAmount: BigInt(data.destinationAmount),
143
+ steps: transformedSteps,
144
+ intent: intentFromResponse,
145
+ };
146
+ }
147
+ //# sourceMappingURL=Onramp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Onramp.js","sourceRoot":"","sources":["../../../src/bridge/Onramp.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAI7C,yCAAyC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AA8C3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuEG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,OAAwB;IAExB,MAAM,EACJ,MAAM,EACN,MAAM,EACN,OAAO,EACP,YAAY,EACZ,QAAQ,EACR,MAAM,EACN,YAAY,EACZ,MAAM,EACN,kBAAkB,EAClB,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,eAAe,GAChB,GAAG,OAAO,CAAC;IAEZ,MAAM,WAAW,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;IAC3C,MAAM,GAAG,GAAG,GAAG,kBAAkB,CAAC,QAAQ,CAAC,oBAAoB,CAAC;IAEhE,MAAM,cAAc,GAAyB;QAC3C,MA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 import { getThirdwebBaseUrl } from "../utils/domains.js";
2
+ import { getClientFetch } from "../utils/fetch.js";
3
+ /**
4
+ * Retrieves the status of an Onramp session created via {@link Bridge.Onramp.prepare}. The
5
+ * status will include any on-chain transactions that have occurred as a result of the onramp
6
+ * as well as any arbitrary `purchaseData` that was supplied when the onramp was
7
+ * prepared.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * import { Bridge } from "thirdweb";
12
+ *
13
+ * const onrampStatus = await Bridge.Onramp.status({
14
+ * id: "022218cc-96af-4291-b90c-dadcb47571ec",
15
+ * client: thirdwebClient,
16
+ * });
17
+ *
18
+ * // Possible results:
19
+ * // {
20
+ * // status: "CREATED",
21
+ * // transactions: [],
22
+ * // purchaseData: {
23
+ * // orderId: "abc-123",
24
+ * // },
25
+ * // }
26
+ * //
27
+ * // or
28
+ * // {
29
+ * // status: "PENDING",
30
+ * // transactions: [],
31
+ * // purchaseData: {
32
+ * // orderId: "abc-123",
33
+ * // },
34
+ * // }
35
+ * //
36
+ * // or
37
+ * // {
38
+ * // status: "COMPLETED",
39
+ * // transactions: [
40
+ * // {
41
+ * // chainId: 1,
42
+ * // transactionHash:
43
+ * // "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
44
+ * // },
45
+ * // ],
46
+ * // purchaseData: {
47
+ * // orderId: "abc-123",
48
+ * // },
49
+ * // }
50
+ * ```
51
+ *
52
+ * @param options - The options for fetching the onramp status.
53
+ * @param options.id - The UUID returned from {@link Bridge.Onramp.prepare}.
54
+ * @param options.client - Your thirdweb client instance.
55
+ *
56
+ * @returns A promise that resolves to the status of the onramp session.
57
+ *
58
+ * @throws Will throw an error if there is an issue fetching the status.
59
+ * @bridge Onramp
60
+ * @beta
61
+ */
62
+ export async function status(options) {
63
+ const { id, client } = options;
64
+ const clientFetch = getClientFetch(client);
65
+ const url = new URL(`${getThirdwebBaseUrl("bridge")}/v1/onramp/status`);
66
+ url.searchParams.set("id", id);
67
+ const response = await clientFetch(url.toString());
68
+ if (!response.ok) {
69
+ const errorJson = await response.json();
70
+ throw new Error(`${errorJson.code || response.status} | ${errorJson.message || response.statusText} - ${errorJson.correlationId || "N/A"}`);
71
+ }
72
+ const { data } = await response.json();
73
+ return data;
74
+ }
75
+ //# sourceMappingURL=OnrampStatus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OnrampStatus.js","sourceRoot":"","sources":["../../../src/bridge/OnrampStatus.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,OAAuB;IAClD,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAE/B,MAAM,WAAW,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;IAC3C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,kBAAkB,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAC;IACxE,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAE/B,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;IACnD,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CACb,GAAG,SAAS,CAAC,IAAI,IAAI,QAAQ,CAAC,MAAM,MAAM,SAAS,CAAC,OAAO,IAAI,QAAQ,CAAC,UAAU,MAAM,SAAS,CAAC,aAAa,IAAI,KAAK,EAAE,CAC3H,CAAC;IACJ,CAAC;IAED,MAAM,EAAE,IAAI,EAAE,GAA4B,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IAChE,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -211,7 +211,7 @@ export async function quote(options) {
211
211
  * ```
212
212
  *
213
213
  * ## Sending the transactions
214
- * 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:
214
+ * The `transactions` array is a series of transactions ready to be executed (with `sendTransaction`) 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:
215
215
  * - Approvals will have the `approval` action specified. You can perform approvals with `sendAndConfirmTransaction`, then proceed to the next transaction.
216
216
  * - 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.
217
217
  * - If an `expiration` timestamp is provided, all transactions must be executed before that time to guarantee successful execution at the specified price.
@@ -1,6 +1,7 @@
1
1
  export * as Buy from "./Buy.js";
2
2
  export * as Sell from "./Sell.js";
3
3
  export * as Transfer from "./Transfer.js";
4
+ export * as Onramp from "./Onramp.js";
4
5
  export { status } from "./Status.js";
5
6
  export { routes } from "./Routes.js";
6
7
  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,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"}
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,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,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=BridgeAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BridgeAction.js","sourceRoot":"","sources":["../../../../src/bridge/types/BridgeAction.ts"],"names":[],"mappings":""}
@@ -3,7 +3,6 @@ import * as ox__Bytes from "ox/Bytes";
3
3
  import * as ox__Ens from "ox/Ens";
4
4
  import * as ox__Hash from "ox/Hash";
5
5
  import * as ox__Hex from "ox/Hex";
6
- import { keccak256 } from "viem";
7
6
  import { getContract } from "../../contract/contract.js";
8
7
  import { withCache } from "../../utils/promise/withCache.js";
9
8
  import { name } from "./__generated__/L2Resolver/read/name.js";
@@ -20,7 +19,6 @@ const convertReverseNodeToBytes = (address, chainId) => {
20
19
  const chainCoinType = cointype.toString(16).toLocaleUpperCase();
21
20
  const reverseNode = ox__Ens.namehash(`${chainCoinType.toLocaleUpperCase()}.reverse`);
22
21
  const addressReverseNode = ox__Hash.keccak256(ox__AbiParameters.encodePacked(["bytes32", "bytes32"], [reverseNode, addressNode]));
23
- keccak256;
24
22
  return addressReverseNode;
25
23
  };
26
24
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"resolve-l2-name.js","sourceRoot":"","sources":["../../../../src/extensions/ens/resolve-l2-name.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,iBAAiB,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,SAAS,MAAM,UAAU,CAAC;AACtC,OAAO,KAAK,OAAO,MAAM,QAAQ,CAAC;AAClC,OAAO,KAAK,QAAQ,MAAM,SAAS,CAAC;AACpC,OAAO,KAAK,OAAO,MAAM,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C;YAC9B,QAAQ;YACR,IAAI,EAAE,WAAW;SAClB,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;YACb,IAAI,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;gBAC3C,OAAO,IAAI,CAAC;YACd,CAAC;YACD,MAAM,CAAC,CAAC;QACV,CAAC,CAAC,CAAC;QAEH,IAAI,YAAY,KAAK,EAAE,EAAE,CAAC;YACxB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,YAAY,CAAC;IACtB,CAAC,EACD;QACE,QAAQ,EAAE,YAAY,aAAa,IAAI,OAAO,EAAE;QAChD,aAAa;QACb,SAAS,EAAE,EAAE,GAAG,IAAI;KACrB,CACF,CAAC;AACJ,CAAC"}
@@ -1,6 +1,9 @@
1
- import { getClientFetch } from "../../utils/fetch.js";
2
- import { stringify } from "../../utils/json.js";
3
- import { getPayBuyWithFiatQuoteEndpoint } from "../utils/definitions.js";
1
+ import { prepare as prepareOnramp } from "../../bridge/Onramp.js";
2
+ import { getCachedChain } from "../../chains/utils.js";
3
+ import { NATIVE_TOKEN_ADDRESS } from "../../constants/addresses.js";
4
+ import { getContract } from "../../contract/contract.js";
5
+ import { decimals } from "../../extensions/erc20/read/decimals.js";
6
+ import { toTokens, toUnits } from "../../utils/units.js";
4
7
  /**
5
8
  * Get a quote of type [`BuyWithFiatQuote`](https://portal.thirdweb.com/references/typescript/v5/BuyWithFiatQuote) to buy given token with fiat currency.
6
9
  * This quote contains the information about the swap such as token amounts, processing fees, estimated time etc.
@@ -51,38 +54,131 @@ import { getPayBuyWithFiatQuoteEndpoint } from "../utils/definitions.js";
51
54
  */
52
55
  export async function getBuyWithFiatQuote(params) {
53
56
  try {
54
- const clientFetch = getClientFetch(params.client);
55
- const response = await clientFetch(getPayBuyWithFiatQuoteEndpoint(), {
56
- method: "POST",
57
- headers: {
58
- Accept: "application/json",
59
- "Content-Type": "application/json",
60
- },
61
- body: stringify({
62
- toAddress: params.toAddress,
63
- fromCurrencySymbol: params.fromCurrencySymbol,
64
- toChainId: params.toChainId.toString(),
65
- toTokenAddress: params.toTokenAddress,
66
- fromAmount: params.fromAmount,
67
- toAmount: params.toAmount,
68
- maxSlippageBPS: params.maxSlippageBPS,
69
- isTestMode: params.isTestMode,
70
- purchaseData: params.purchaseData,
71
- fromAddress: params.fromAddress,
72
- toGasAmountWei: params.toGasAmountWei,
73
- preferredProvider: params.preferredProvider,
74
- multiHopSupported: true,
75
- }),
76
- });
77
- // Assuming the response directly matches the SwapResponse interface
78
- if (!response.ok) {
79
- const errorObj = await response.json();
80
- if (errorObj && "error" in errorObj) {
81
- throw errorObj;
57
+ // map preferred provider (FiatProvider) → onramp string expected by Onramp.prepare
58
+ const mapProviderToOnramp = (provider) => {
59
+ switch (provider) {
60
+ case "STRIPE":
61
+ return "stripe";
62
+ case "TRANSAK":
63
+ return "transak";
64
+ default: // default to coinbase when undefined or any other value
65
+ return "coinbase";
82
66
  }
83
- throw new Error(`HTTP error! status: ${response.status}`);
67
+ };
68
+ // Choose provider or default to STRIPE
69
+ const onrampProvider = mapProviderToOnramp(params.preferredProvider);
70
+ const d = params.toTokenAddress !== NATIVE_TOKEN_ADDRESS
71
+ ? await decimals({
72
+ contract: getContract({
73
+ client: params.client,
74
+ address: params.toTokenAddress,
75
+ chain: getCachedChain(params.toChainId),
76
+ }),
77
+ })
78
+ : 18;
79
+ // Prepare amount in wei if provided
80
+ const amountWei = params.toAmount ? toUnits(params.toAmount, d) : undefined;
81
+ // Call new Onramp.prepare to get the quote & link
82
+ const prepared = await prepareOnramp({
83
+ client: params.client,
84
+ onramp: onrampProvider,
85
+ chainId: params.toChainId,
86
+ tokenAddress: params.toTokenAddress,
87
+ receiver: params.toAddress,
88
+ sender: params.fromAddress,
89
+ amount: amountWei,
90
+ purchaseData: params.purchaseData,
91
+ currency: params.fromCurrencySymbol,
92
+ maxSteps: 2,
93
+ onrampTokenAddress: NATIVE_TOKEN_ADDRESS, // force onramp to native token to avoid missing gas issues
94
+ });
95
+ // Determine tokens based on steps rules
96
+ const hasSteps = prepared.steps.length > 0;
97
+ const firstStep = hasSteps
98
+ ? prepared.steps[0]
99
+ : undefined;
100
+ // Estimated duration in seconds – sum of all step durations
101
+ const estimatedDurationSeconds = Math.max(120, Math.ceil(prepared.steps.reduce((acc, s) => acc + s.estimatedExecutionTimeMs, 0) /
102
+ 1000));
103
+ const estimatedToAmountMinWeiBigInt = prepared.destinationAmount;
104
+ const maxSlippageBPS = params.maxSlippageBPS ?? 0;
105
+ const slippageWei = (estimatedToAmountMinWeiBigInt * BigInt(maxSlippageBPS)) / 10000n;
106
+ const toAmountMinWeiBigInt = estimatedToAmountMinWeiBigInt - slippageWei;
107
+ const estimatedToAmountMin = toTokens(estimatedToAmountMinWeiBigInt, d);
108
+ const toAmountMin = toTokens(toAmountMinWeiBigInt, d);
109
+ // Helper to convert a Token → PayTokenInfo
110
+ const tokenToPayTokenInfo = (token) => ({
111
+ chainId: token.chainId,
112
+ tokenAddress: token.address,
113
+ decimals: token.decimals,
114
+ priceUSDCents: Math.round(token.priceUsd * 100),
115
+ name: token.name,
116
+ symbol: token.symbol,
117
+ });
118
+ // Determine the raw token objects using new simplified rules
119
+ // 1. toToken is always the destination token
120
+ const toTokenRaw = prepared.destinationToken;
121
+ // 2. onRampToken: if exactly one step -> originToken of that step, else toTokenRaw
122
+ const onRampTokenRaw = prepared.steps.length > 0 && firstStep
123
+ ? firstStep.originToken
124
+ : toTokenRaw;
125
+ // 3. routingToken: if exactly two steps -> originToken of second step, else undefined
126
+ const routingTokenRaw = prepared.steps.length > 1
127
+ ? prepared.steps[1].originToken
128
+ : undefined;
129
+ // Amounts for onRampToken/raw
130
+ const onRampTokenAmountWei = prepared.steps.length > 0 && firstStep
131
+ ? firstStep.originAmount
132
+ : prepared.destinationAmount;
133
+ const onRampTokenAmount = toTokens(onRampTokenAmountWei, onRampTokenRaw.decimals);
134
+ // Build info objects
135
+ const onRampTokenObject = {
136
+ amount: onRampTokenAmount,
137
+ amountWei: onRampTokenAmountWei.toString(),
138
+ amountUSDCents: Math.round(Number(onRampTokenAmount) * onRampTokenRaw.priceUsd * 100),
139
+ token: tokenToPayTokenInfo(onRampTokenRaw),
140
+ };
141
+ let routingTokenObject;
142
+ if (routingTokenRaw) {
143
+ const routingAmountWei = prepared.steps[1].originAmount;
144
+ const routingAmount = toTokens(routingAmountWei, routingTokenRaw.decimals);
145
+ routingTokenObject = {
146
+ amount: routingAmount,
147
+ amountWei: routingAmountWei.toString(),
148
+ amountUSDCents: Math.round(Number(routingAmount) * routingTokenRaw.priceUsd * 100),
149
+ token: tokenToPayTokenInfo(routingTokenRaw),
150
+ };
84
151
  }
85
- return (await response.json()).result;
152
+ const buyWithFiatQuote = {
153
+ estimatedDurationSeconds,
154
+ estimatedToAmountMin: estimatedToAmountMin,
155
+ estimatedToAmountMinWei: estimatedToAmountMinWeiBigInt.toString(),
156
+ toAmountMinWei: toAmountMinWeiBigInt.toString(),
157
+ toAmountMin: toAmountMin,
158
+ fromCurrency: {
159
+ amount: prepared.currencyAmount.toString(),
160
+ amountUnits: Number(prepared.currencyAmount).toFixed(2),
161
+ decimals: 2,
162
+ currencySymbol: prepared.currency,
163
+ },
164
+ fromCurrencyWithFees: {
165
+ amount: prepared.currencyAmount.toString(),
166
+ amountUnits: Number(prepared.currencyAmount).toFixed(2),
167
+ decimals: 2,
168
+ currencySymbol: prepared.currency,
169
+ },
170
+ toToken: tokenToPayTokenInfo(toTokenRaw),
171
+ toAddress: params.toAddress,
172
+ fromAddress: params.fromAddress,
173
+ maxSlippageBPS: maxSlippageBPS,
174
+ intentId: prepared.id,
175
+ processingFees: [],
176
+ onRampToken: onRampTokenObject,
177
+ routingToken: routingTokenObject,
178
+ onRampLink: prepared.link,
179
+ provider: (params.preferredProvider ?? "COINBASE"),
180
+ };
181
+ return buyWithFiatQuote;
86
182
  }
87
183
  catch (error) {
88
184
  console.error("Error getting buy with fiat quote", error);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C,mCAAmC,EAAE,KAAK,CAAC,CAAC;QAC1D,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -1,5 +1,4 @@
1
- import { getClientFetch } from "../../utils/fetch.js";
2
- import { getPayBuyWithFiatStatusEndpoint } from "../utils/definitions.js";
1
+ import { status as onrampStatus } from "../../bridge/OnrampStatus.js";
3
2
  /**
4
3
  * Once you get a `quote` from [`getBuyWithFiatQuote`](https://portal.thirdweb.com/references/typescript/v5/getBuyWithFiatQuote)
5
4
  * and open the `quote.onRampLink` in a new tab, you can start polling for the transaction status using `getBuyWithFiatStatus`
@@ -38,28 +37,80 @@ import { getPayBuyWithFiatStatusEndpoint } from "../utils/definitions.js";
38
37
  * })
39
38
  *
40
39
  * // when the fiatStatus.status is "ON_RAMP_TRANSFER_COMPLETED" - the process is complete
41
- * // when the fiatStatus.status is "CRYPTO_SWAP_REQUIRED" - start the swap process
42
40
  * ```
43
41
  * @deprecated
44
42
  * @buyCrypto
45
43
  */
46
44
  export async function getBuyWithFiatStatus(params) {
47
- try {
48
- const queryParams = new URLSearchParams({
49
- intentId: params.intentId,
50
- });
51
- const queryString = queryParams.toString();
52
- const url = `${getPayBuyWithFiatStatusEndpoint()}?${queryString}`;
53
- const response = await getClientFetch(params.client)(url);
54
- if (!response.ok) {
55
- const error = await response.text().catch(() => null);
56
- throw new Error(`HTTP error! status: ${response.status} - ${response.statusText}: ${error || "unknown error"}`);
57
- }
58
- return (await response.json()).result;
59
- }
60
- catch (error) {
61
- console.error("Fetch error:", error);
62
- throw new Error(`Fetch failed: ${error}`);
63
- }
45
+ const result = await onrampStatus({
46
+ id: params.intentId,
47
+ client: params.client,
48
+ });
49
+ return toBuyWithFiatStatus({ intentId: params.intentId, result });
50
+ }
51
+ ////////////////////////////////////////////////////////////////////////////////
52
+ // Helpers
53
+ ////////////////////////////////////////////////////////////////////////////////
54
+ function toBuyWithFiatStatus(args) {
55
+ const { intentId, result } = args;
56
+ // Map status constants from the Bridge.Onramp.status response to BuyWithFiatStatus equivalents.
57
+ const STATUS_MAP = {
58
+ CREATED: "PENDING_PAYMENT",
59
+ PENDING: "PENDING_PAYMENT",
60
+ FAILED: "PAYMENT_FAILED",
61
+ COMPLETED: "ON_RAMP_TRANSFER_COMPLETED",
62
+ };
63
+ const mappedStatus = STATUS_MAP[result.status];
64
+ return buildPlaceholderStatus({
65
+ intentId,
66
+ status: mappedStatus,
67
+ purchaseData: result.purchaseData,
68
+ });
69
+ }
70
+ function buildPlaceholderStatus(args) {
71
+ const { intentId, status, purchaseData } = args;
72
+ // Build a minimal—but type-complete—object that satisfies BuyWithFiatStatus.
73
+ const emptyToken = {
74
+ chainId: 0,
75
+ tokenAddress: "",
76
+ decimals: 18,
77
+ priceUSDCents: 0,
78
+ name: "",
79
+ symbol: "",
80
+ };
81
+ const quote = {
82
+ estimatedOnRampAmount: "0",
83
+ estimatedOnRampAmountWei: "0",
84
+ estimatedToTokenAmount: "0",
85
+ estimatedToTokenAmountWei: "0",
86
+ fromCurrency: {
87
+ amount: "0",
88
+ amountUnits: "USD",
89
+ decimals: 2,
90
+ currencySymbol: "USD",
91
+ },
92
+ fromCurrencyWithFees: {
93
+ amount: "0",
94
+ amountUnits: "USD",
95
+ decimals: 2,
96
+ currencySymbol: "USD",
97
+ },
98
+ onRampToken: emptyToken,
99
+ toToken: emptyToken,
100
+ estimatedDurationSeconds: 0,
101
+ createdAt: new Date().toISOString(),
102
+ };
103
+ // The source/destination fields can only be filled accurately when extra context is returned
104
+ // by the API. Since Bridge.Onramp.status doesn't yet provide these details, we omit them for
105
+ // now (they are optional).
106
+ const base = {
107
+ intentId,
108
+ status,
109
+ toAddress: "",
110
+ fromAddress: "",
111
+ quote,
112
+ purchaseData: purchaseData,
113
+ };
114
+ return base;
64
115
  }
65
116
  //# sourceMappingURL=getStatus.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getStatus.js","sourceRoot":"","sources":["../../../../src/pay/buyWithFiat/getStatus.ts"],"names":[],"mappings":"AAC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wBAAwB,EAAE,GAAG;QAE7B,sBAAsB,EAAE,GAAG;QAC3B,yBAAyB,EAAE,GAAG;QAE9B,YAAY,EAAE;YACZ,MAAM,EAAE,GAAG;YACX,WAAW,EAAE,KAAK;YAClB,QAAQ,EAAE,CAAC;YACX,cAAc,EAAE,KAAK;SACtB;QACD,oBAAoB,EAAE;YACpB,MAAM,EAAE,GAAG;YACX,WAAW,EAAE,KAAK;YAClB,QAAQ,EAAE,CAAC;YACX,cAAc,EAAE,KAAK;SACtB;QACD,WAAW,EAAE,UAAU;QACvB,OAAO,EAAE,UAAU;QACnB,wBAAwB,EAAE,CAAC;QAC3B,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;KACE,CAAC;IAExC,6FAA6F;IAC7F,6FAA6F;IAC7F,2BAA2B;IAE3B,MAAM,IAAI,GAAwD;QAChE,QAAQ;QACR,MAAM;QACN,SAAS,EAAE,EAAE;QACb,WAAW,EAAE,EAAE;QACf,KAAK;QACL,YAAY,EAAE,YAAkC;KACjD,CAAC;IAEF,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -1,2 +1,2 @@
1
- export const FiatProviders = ["COINBASE", "STRIPE", "TRANSAK", "KADO"];
1
+ export const FiatProviders = ["COINBASE", "STRIPE", "TRANSAK"];
2
2
  //# sourceMappingURL=commonTypes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"commonTypes.js","sourceRoot":"","sources":["../../../../src/pay/utils/commonTypes.ts"],"names":[],"mappings":"AAqBA,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAU,CAAC"}
1
+ {"version":3,"file":"commonTypes.js","sourceRoot":"","sources":["../../../../src/pay/utils/commonTypes.ts"],"names":[],"mappings":"AAqBA,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,UAAU,EAAE,QAAQ,EAAE,SAAS,CAAU,CAAC"}